Merging in relevant changes from the libplasma private fork. Porting
tests as required. CCMAIL: r.scheepmaker@student.utwente.nl CCMAIL: aseigo@kde.org svn path=/branches/work/~ervin/qtjolie/; revision=1020942
This commit is contained in:
parent
705b930ca3
commit
4f8e3e3333
@ -40,7 +40,7 @@ public:
|
||||
|
||||
|
||||
private:
|
||||
virtual void relay(Server *server, int descriptor, const Message &message) = 0;
|
||||
virtual void relay(Server *server, int clientId, const Message &message) = 0;
|
||||
|
||||
friend class ServerPrivate;
|
||||
|
||||
|
@ -22,7 +22,6 @@
|
||||
#include "server_p.h"
|
||||
|
||||
#include <QtCore/QDebug>
|
||||
#include <QtCore/QString>
|
||||
|
||||
#include "abstractadaptor.h"
|
||||
#include "serverthread_p.h"
|
||||
@ -30,9 +29,6 @@
|
||||
#include "pendingcall.h"
|
||||
#include "pendingreply.h"
|
||||
|
||||
#define QT_NO_CAST_FROM_ASCII
|
||||
#define QT_NO_CAST_TO_ASCII
|
||||
|
||||
using namespace Jolie;
|
||||
|
||||
Server::Server(quint16 port)
|
||||
@ -58,9 +54,13 @@ QString Server::errorString() const
|
||||
return d->errorString;
|
||||
}
|
||||
|
||||
void Server::sendReply(int clientId, const Message &reply)
|
||||
{
|
||||
d->serverThread->sendMessage(clientId, reply);
|
||||
}
|
||||
|
||||
bool Server::registerAdaptor(const QByteArray &path, AbstractAdaptor *adaptor)
|
||||
{
|
||||
//qDebug() << "registering an adaptor: " << QString(path);
|
||||
if (path.isEmpty() || d->adaptors.contains(path)) {
|
||||
return false;
|
||||
}
|
||||
@ -74,16 +74,10 @@ bool Server::unregisterAdaptor(const QByteArray &path)
|
||||
return d->adaptors.take(path)!=0;
|
||||
}
|
||||
|
||||
void Server::sendMessage(int descriptor, const Message &message)
|
||||
{
|
||||
d->serverThread->sendMessage(descriptor, message);
|
||||
}
|
||||
|
||||
void ServerPrivate::messageReceived(int descriptor, const Message &message)
|
||||
{
|
||||
if (adaptors.contains(message.resourcePath())) {
|
||||
adaptors[message.resourcePath()]->relay(q, descriptor, message);
|
||||
//serverThread->sendMessage(descriptor, reply);
|
||||
} else {
|
||||
qWarning() << "Got a message for an unregistered object:"
|
||||
<< message.operationName()
|
||||
|
@ -45,9 +45,10 @@ public:
|
||||
Error error() const;
|
||||
QString errorString() const;
|
||||
|
||||
void sendReply(int clientId, const Message &reply);
|
||||
|
||||
bool registerAdaptor(const QByteArray &path, AbstractAdaptor *adaptor);
|
||||
bool unregisterAdaptor(const QByteArray &path);
|
||||
void sendMessage(int descriptor, const Message &message);
|
||||
|
||||
private:
|
||||
friend class ServerPrivate;
|
||||
|
@ -191,7 +191,6 @@ inline QByteArray sodepReadByteArray(QIODevice &io)
|
||||
|
||||
char *data = new char[length+1];
|
||||
io.read(data, length);
|
||||
//data[length] = '\0';
|
||||
|
||||
QByteArray result(data, length);
|
||||
delete[] data;
|
||||
|
@ -46,7 +46,7 @@ signals:
|
||||
void added(int a, int b, int result);
|
||||
|
||||
private:
|
||||
Message relay(Server *server, const Message &message)
|
||||
void relay(Server *server, int clientId, const Message &message)
|
||||
{
|
||||
qint32 x = message.data().children("x").first().toInt();
|
||||
qint32 y = message.data().children("y").first().toInt();
|
||||
@ -59,7 +59,7 @@ private:
|
||||
message.id());
|
||||
reply.setData(Value(x+y));
|
||||
|
||||
return reply;
|
||||
server->sendReply(clientId, reply);
|
||||
}
|
||||
};
|
||||
|
||||
|
@ -46,7 +46,7 @@ public:
|
||||
PresenterAdaptor(MainWindow *parent);
|
||||
|
||||
private:
|
||||
Message relay(Server *server, const Message &message);
|
||||
void relay(Server *server, int clientId, const Message &message);
|
||||
|
||||
MainWindow *m_window;
|
||||
};
|
||||
@ -174,7 +174,7 @@ PresenterAdaptor::PresenterAdaptor(MainWindow *parent)
|
||||
{
|
||||
}
|
||||
|
||||
Message PresenterAdaptor::relay(Server *server, const Message &message)
|
||||
void PresenterAdaptor::relay(Server *server, int clientId, const Message &message)
|
||||
{
|
||||
if ((message.resourcePath()=="/") && (message.operationName()=="goToPage")) {
|
||||
int pageNumber = 0;
|
||||
@ -198,7 +198,7 @@ Message PresenterAdaptor::relay(Server *server, const Message &message)
|
||||
<< message.operationName();
|
||||
}
|
||||
|
||||
return Message();
|
||||
server->sendReply(clientId, Message());
|
||||
}
|
||||
|
||||
int main(int argc, char **argv)
|
||||
|
Loading…
Reference in New Issue
Block a user