PDA

View Full Version : Creating QDS service



bowser
22nd October 2007, 13:48
Hi all,

I'm having some difficulties in implementing a QDS service in qtopia, precisely how to send and retrieve the actual data.

I've been following http://doc.trolltech.com/qtopia4.2/datasharing.html, with these results:

1. The service is being called successfully by my application (despite ignoring any streamed data)
2. The service does require some data to be sent to it, but it is somewhat empty when its read.
3. The service responds with no errors to my application

Here's some pseudo-code of what I'm doing:

My application calling the service:

action = new QDSAction(service); // it is a valid service
// the response and error signals are properly attached to slots
QByteArray array;
QDataStream stream(&array, QIODevice::WriteOnly);
stream << response; // some random string (the request type specified by service)
data = QDSData(array, QMimeType("text/x-qstring"));
data.store();
action->invoke(data);

In the service:


QDSActionRequest requestCopy(request);
// requestCopy.requestData().data() is ""
// I ignore this and try to send a response

QByteArray array;
QDataStream stream(&array, QIODevice::WriteOnly);
stream << response; // some random string (the return type specified by service)
data = QDSData(array, QMimeType("text/x-qstring"));
data.store();

requestCopy.respond(data);

In the response signal of my application:

// the copy is necessary to run anything in responseData
// copy.data() is ""
QDSData copy = QDSData(responseData);

In the link above, it is said to create a QByteArray with the method QDSData.store(), but the following line is troublesome:


// responseData is a reference, thus need a copy to execute store()
// store() does not return a QByteArray
QByteArray imageKey = responseData.store();

What am I doing wrong? How can I actually see the data the service gets, and the data the service responds?
I think all the relevant information is said, as this post seems rather long, but I can provide more if requested. I'm using Qtopia 4.2.

Thanks in advance.

bowser
29th October 2007, 12:12
The objective of this is to have a service ready to communicate with an external source.
Is any alternative more easily achieved?
I can't find any other resources for implementing a QDSService, and by the looks of the already existent, I'm not doing anything different...