2008-11-05 19:48:16 +01:00
|
|
|
/**
|
|
|
|
* This file is part of the KDE project
|
|
|
|
* Copyright (C) 2008 Kevin Ottens <ervin@kde.org>
|
|
|
|
*
|
|
|
|
* This library is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU Library General Public
|
|
|
|
* License as published by the Free Software Foundation; either
|
|
|
|
* version 2 of the License, or (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This library is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
|
* Library General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU Library General Public License
|
|
|
|
* along with this library; see the file COPYING.LIB. If not, write to
|
|
|
|
* the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
|
|
|
|
* Boston, MA 02110-1301, USA.
|
|
|
|
*/
|
|
|
|
|
2009-04-25 15:50:35 +02:00
|
|
|
#include "message.h"
|
2008-11-05 19:48:16 +01:00
|
|
|
|
2009-05-30 10:44:34 +02:00
|
|
|
#include <QtCore/QByteArray>
|
2008-11-05 19:48:16 +01:00
|
|
|
|
|
|
|
#include "sodephelpers_p.h"
|
|
|
|
|
2009-04-25 15:50:35 +02:00
|
|
|
namespace Jolie
|
|
|
|
{
|
|
|
|
|
|
|
|
class MessagePrivate
|
2008-11-05 19:48:16 +01:00
|
|
|
{
|
|
|
|
public:
|
2009-04-25 15:50:35 +02:00
|
|
|
MessagePrivate() : id(0) {}
|
2008-11-05 19:48:16 +01:00
|
|
|
|
|
|
|
qint64 id;
|
2009-05-30 10:44:34 +02:00
|
|
|
QByteArray resourcePath;
|
|
|
|
QByteArray operationName;
|
2009-04-25 15:50:35 +02:00
|
|
|
Fault fault;
|
|
|
|
Value data;
|
2008-11-05 19:48:16 +01:00
|
|
|
};
|
|
|
|
|
2009-04-25 15:50:35 +02:00
|
|
|
} // namespace Jolie
|
|
|
|
|
|
|
|
using namespace Jolie;
|
|
|
|
|
|
|
|
Message::Message()
|
|
|
|
: d(new MessagePrivate)
|
2008-11-05 19:48:16 +01:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2009-05-30 10:44:34 +02:00
|
|
|
Message::Message(const QByteArray &resourcePath, const QByteArray &operationName, qint64 id)
|
2009-04-25 15:50:35 +02:00
|
|
|
: d(new MessagePrivate)
|
2008-11-05 19:48:16 +01:00
|
|
|
{
|
2009-03-27 14:49:17 +01:00
|
|
|
static qint64 lastId = 0;
|
|
|
|
|
|
|
|
if (id==0) {
|
|
|
|
d->id = ++lastId;
|
|
|
|
} else {
|
|
|
|
d->id = id;
|
|
|
|
}
|
2008-11-05 19:48:16 +01:00
|
|
|
d->resourcePath = resourcePath;
|
|
|
|
d->operationName = operationName;
|
|
|
|
}
|
|
|
|
|
2009-04-25 15:50:35 +02:00
|
|
|
Message::Message(const Message &other)
|
|
|
|
: d(new MessagePrivate)
|
2008-11-05 19:48:16 +01:00
|
|
|
{
|
|
|
|
*d = *other.d;
|
|
|
|
}
|
|
|
|
|
2009-04-25 15:50:35 +02:00
|
|
|
Message::~Message()
|
2008-11-05 19:48:16 +01:00
|
|
|
{
|
|
|
|
delete d;
|
|
|
|
}
|
|
|
|
|
2009-04-25 15:50:35 +02:00
|
|
|
Message &Message::operator=(const Message &other)
|
2008-11-05 19:48:16 +01:00
|
|
|
{
|
|
|
|
*d = *other.d;
|
|
|
|
|
|
|
|
return *this;
|
|
|
|
}
|
|
|
|
|
2009-04-25 15:50:35 +02:00
|
|
|
qint64 Message::id() const
|
2008-11-05 19:48:16 +01:00
|
|
|
{
|
|
|
|
return d->id;
|
|
|
|
}
|
|
|
|
|
2009-05-30 10:44:34 +02:00
|
|
|
QByteArray Message::resourcePath() const
|
2008-11-05 19:48:16 +01:00
|
|
|
{
|
|
|
|
return d->resourcePath;
|
|
|
|
}
|
|
|
|
|
2009-05-30 10:44:34 +02:00
|
|
|
QByteArray Message::operationName() const
|
2008-11-05 19:48:16 +01:00
|
|
|
{
|
|
|
|
return d->operationName;
|
|
|
|
}
|
|
|
|
|
2009-04-25 15:50:35 +02:00
|
|
|
Fault Message::fault() const
|
2008-11-05 19:48:16 +01:00
|
|
|
{
|
|
|
|
return d->fault;
|
|
|
|
}
|
|
|
|
|
2009-04-25 15:50:35 +02:00
|
|
|
void Message::setFault(const Fault &fault)
|
2008-11-05 19:48:16 +01:00
|
|
|
{
|
|
|
|
d->fault = fault;
|
|
|
|
}
|
|
|
|
|
2009-04-25 15:50:35 +02:00
|
|
|
Value Message::data() const
|
2008-11-05 19:48:16 +01:00
|
|
|
{
|
|
|
|
return d->data;
|
|
|
|
}
|
|
|
|
|
2009-04-25 15:50:35 +02:00
|
|
|
void Message::setData(const Value &data)
|
2008-11-05 19:48:16 +01:00
|
|
|
{
|
|
|
|
d->data = data;
|
|
|
|
}
|
|
|
|
|
2009-04-25 15:50:35 +02:00
|
|
|
bool Message::isValid()
|
2008-11-05 19:48:16 +01:00
|
|
|
{
|
|
|
|
return !d->resourcePath.isEmpty() && !d->operationName.isEmpty();
|
|
|
|
}
|
|
|
|
|