qthighway/xqservice/src/xqservicerequest.cpp
changeset 24 9d760f716ca8
parent 19 46686fb6258c
equal deleted inserted replaced
19:46686fb6258c 24:9d760f716ca8
    28 #include "xqserviceadaptor.h"
    28 #include "xqserviceadaptor.h"
    29 #include "xqrequestutil.h"
    29 #include "xqrequestutil.h"
    30 #include <QStringList>
    30 #include <QStringList>
    31 #include <xqservicemanager.h>
    31 #include <xqservicemanager.h>
    32 
    32 
       
    33 /*!
       
    34     \class XQServiceRequest_Private
       
    35     \inpublicgroup QtBaseModule
       
    36 
       
    37     \ingroup ipc
       
    38     \brief Private implementation of the XQServiceRequest.
       
    39 */
       
    40 
    33 class XQServiceRequest_Private : public XQServiceRequestCompletedAsync
    41 class XQServiceRequest_Private : public XQServiceRequestCompletedAsync
    34 {
    42 {
    35 public:
    43 public:
    36     XQServiceRequest_Private(XQServiceRequest* parent)
    44     XQServiceRequest_Private(XQServiceRequest* parent)
    37         : mSynchronous(true), mParent(parent),mServiceManager(NULL)
    45         : mSynchronous(true), mParent(parent),mServiceManager(NULL)
    99     XQSERVICE_DEBUG_PRINT("XQServiceRequest_Private::requestErrorAsync");
   107     XQSERVICE_DEBUG_PRINT("XQServiceRequest_Private::requestErrorAsync");
   100     emit mParent->requestError(err);
   108     emit mParent->requestError(err);
   101 }
   109 }
   102 
   110 
   103 /*!
   111 /*!
   104   Construct a null service request.
   112     \class XQServiceRequest
   105   setService() and setMessage() must be called before send(), but the
   113     \inpublicgroup QtBaseModule
   106   service may be written prior to the calls.
   114 
       
   115     \ingroup ipc
       
   116     \brief Allows applications to request services from other applications.
       
   117     
       
   118     The XQServiceRequest class allows applications to request services from other applications.
       
   119     A XQServiceRequest encapsulates a service name and the message to be sent to that service.
       
   120     
       
   121     \note One should be using XQApplicationManager and the related XQAiwRequest instead of XQServiceRequest.
       
   122           The XQApplicationManager and related classes encapsulate basic, target-architecture approved
       
   123           support for out-of-process Application Interworking, e.g. support for launching URLs
       
   124           (including activity URLs), normal files, sharable files, etc. (whatever needed).
       
   125     
       
   126     \b Examples: \n
       
   127     
       
   128     How to create synchronous request without parameters and return value? 
       
   129     \note The full name (yourservice.Interface) need to be used (with dot (.) between service name and interface name).
       
   130     
       
   131     \code
       
   132         XQServiceRequest request("yourservice.<b>Interface</b>", "functionName1()");
       
   133         bool res = request.send();
       
   134         if  (!res) {
       
   135             int error = request.latestError();
       
   136         }
       
   137     \endcode
       
   138     
       
   139     How to create synchronous request with several parameters and return value?
       
   140     
       
   141     \code
       
   142         QString parameter1("+3581234567890");
       
   143         int parameter2 = 3;
       
   144         XQServiceRequest request("yourservice.<b>Interface</b>", "functionName2(QString, int)");
       
   145         request << parameter1;
       
   146         request << parameter2;
       
   147         int returnvalue;
       
   148         bool res = request.send(returnvalue);
       
   149         if  (!res) {
       
   150             int error = request.latestError();
       
   151         }
       
   152     \endcode
       
   153     
       
   154     How to create asynchronous request without return value?
       
   155     
       
   156     \code
       
   157         QString parameter1("+3581234567890");
       
   158         int parameter2 = 3;
       
   159         XQServiceRequest request("yourservice.Interface", "functionName2(QString, int)", false);
       
   160         request << parameter1;
       
   161         request << parameter2;
       
   162         bool res = request.send();
       
   163         if (!res) {
       
   164             int error = request.latestError();
       
   165         }
       
   166     \endcode
       
   167     
       
   168     How to create asynchronous request with return value?
       
   169     
       
   170     \code
       
   171         QString parameter1("+3581234567890");
       
   172         int parameter2 = 3;
       
   173         XQServiceRequest request("yourservice.Interface", "functionName2(QString, int)", false);
       
   174         request << parameter1;
       
   175         request << parameter2;
       
   176         connect(request, SIGNAL(requestCompleted(QVariant)), this, SLOT(requestCompleted(QVariant)));
       
   177         bool res = request.send();
       
   178         if (!res) {
       
   179             int error = request.latestError();
       
   180         }
       
   181 
       
   182         ...
       
   183 
       
   184         void requestCompleted(const QVariant& value)
       
   185         {
       
   186             int returnvalue = value.toInt();
       
   187         }
       
   188     \endcode
       
   189     
       
   190     How to use declare custom type?
       
   191     
       
   192     Header:
       
   193     \code
       
   194         class CustomType 
       
   195         { 
       
   196         public: 
       
   197             CustomType (){}; 
       
   198             virtual ~CustomType(){};
       
   199 
       
   200             QString mString1; 
       
   201             QString mString2; 
       
   202             QUuid mUid;
       
   203 
       
   204             template <typename Stream> void serialize(Stream &stream) const; 
       
   205             template <typename Stream> void deserialize(Stream &stream); 
       
   206         };
       
   207 
       
   208         Q_DECLARE_USER_METATYPE(CustomType)
       
   209     \endcode
       
   210     
       
   211     Implementation:
       
   212     \code        
       
   213         template <typename Stream> void CustomType::serialize(Stream &s) const 
       
   214             { 
       
   215             s << mString1; 
       
   216             s << mString2; 
       
   217             s << mUid; 
       
   218             }
       
   219 
       
   220         template <typename Stream> void CustomType::deserialize(Stream &s) 
       
   221             { 
       
   222             s >> mString1; 
       
   223             s >> mString2; 
       
   224             s >> mUid; 
       
   225             }
       
   226 
       
   227         Q_IMPLEMENT_USER_METATYPE(CustomType)
       
   228     \endcode
       
   229     
       
   230     How to declare custom type that doesn't need data stream operators?
       
   231     
       
   232     Header:
       
   233     \code
       
   234         typedef QList<CustomType> CustomTypeList;
       
   235 
       
   236         Q_DECLARE_USER_METATYPE_NO_OPERATORS(CustomTypeList)
       
   237     \endcode
       
   238     
       
   239     Implementation:
       
   240     \code
       
   241         Q_IMPLEMENT_USER_METATYPE_NO_OPERATORS(CustomTypeList)
       
   242     \endcode
       
   243 */
       
   244 
       
   245 /*!
       
   246     \fn bool XQServiceRequest::send(T& retValue)
       
   247 
       
   248     Sends the request. If the request is synchronous, then client is blocked
       
   249     until service provider completes the request or request fails for some reason.
       
   250     If the request is asynchronous, then client won't be blocked.
       
   251     \param retValue Defines refence to a value service provider will return after service.
       
   252     \return False if there was no application that could service the request, otherwise true.
       
   253 */
       
   254 
       
   255 /*!
       
   256     \fn XQServiceRequest &XQServiceRequest::operator<< (const T &var)
       
   257 
       
   258     Adds \a var to the list of arguments for this service request.
       
   259     \param var Defines the argument value to add to the list of arguments.
       
   260 */
       
   261 
       
   262 /*!
       
   263     \fn XQServiceRequest &XQServiceRequest::operator<< (const char *var)
       
   264 
       
   265     Adds \a var to the list of arguments for this service request.
       
   266     \param var Defines the argument value to add to the list of arguments.
       
   267 */
       
   268 
       
   269 /*!
       
   270     \fn void XQServiceRequest::requestCompleted(const QVariant& value)
       
   271 
       
   272     This signal is emitted when service provider returns a return value asynchronously back to the client.
       
   273     \param value Result of the request.
       
   274 */
       
   275 
       
   276 /*!
       
   277     \fn void XQServiceRequest::requestError(int err);
       
   278 
       
   279     This signal is emitted when error has happened in request handling.
       
   280     \param err Error code as integer value.
       
   281     \sa XQService::ServiceIPCErrors
       
   282 */
       
   283 
       
   284 /*!
       
   285     \fn void XQServiceRequest::addVariantArg(const QVariant& var)
       
   286 
       
   287     Adds the variant value to the list of arguments, so that the variant's
       
   288     value is serialized in send() rather than the variant itself.
       
   289     \param var Value to be added to the list of arguments.
       
   290 */
       
   291 
       
   292 /*!
       
   293     Construct a null service request.
       
   294     setService() and setMessage() must be called before send(), but the
       
   295     service may be written prior to the calls.
   107  */
   296  */
   108 XQServiceRequest::XQServiceRequest()
   297 XQServiceRequest::XQServiceRequest()
   109 {
   298 {
   110     XQSERVICE_DEBUG_PRINT("XQServiceRequest::XQServiceRequest(1)");
   299     XQSERVICE_DEBUG_PRINT("XQServiceRequest::XQServiceRequest(1)");
   111     mData = new XQServiceRequest_Private(this);
   300     mData = new XQServiceRequest_Private(this);
   112 }
   301 }
   113 
   302 
   114 /*!
   303 /*!
   115   Construct a service request that will send \a message to
   304     Construct a service request that will send \a message to
   116   a \a service when send() is called. The service may be written
   305     a \a service when send() is called. The service may be written
   117   prior to the calls.
   306     prior to the calls.
       
   307     \param service Defines the full service name to send message. The full name is:
       
   308                    - The name of the service in the service configuration file
       
   309                    - Character *.* (dot)
       
   310                    - The name of the interface from the service XML.
       
   311     \param message Defines the message to send to the service provider i.e. it is
       
   312                  the signature of the service provider function to be called.
       
   313     \param synchronous Defines should message be sent synchronously or asynchronously.
       
   314                      By default message is sent synchronously.
   118 */
   315 */
   119 XQServiceRequest::XQServiceRequest(const QString& service, const QString& message, const bool &synchronous)
   316 XQServiceRequest::XQServiceRequest(const QString& service, const QString& message, const bool &synchronous)
   120 {
   317 {
   121     XQSERVICE_DEBUG_PRINT("XQServiceRequest::XQServiceRequest(2)");
   318     XQSERVICE_DEBUG_PRINT("XQServiceRequest::XQServiceRequest(2)");
   122     XQSERVICE_DEBUG_PRINT("service: %s, message: %s, synchronous: %d", qPrintable(service), qPrintable(message), synchronous);
   319     XQSERVICE_DEBUG_PRINT("service: %s, message: %s, synchronous: %d", qPrintable(service), qPrintable(message), synchronous);
   123     mData = new XQServiceRequest_Private(service,message,synchronous,this);
   320     mData = new XQServiceRequest_Private(service,message,synchronous,this);
   124 }
   321 }
   125 
   322 
   126 /*!
   323 /*!
   127   Copy constructor. Any data previously written to the \a orig
   324     Copy constructor. Any data previously written to the \a orig
   128   service will be in the copy.
   325     service will be in the copy.
       
   326     \param orig XQServiceRequest from which data will be copied to this object.
   129 */
   327 */
   130 XQServiceRequest::XQServiceRequest(const XQServiceRequest& orig)
   328 XQServiceRequest::XQServiceRequest(const XQServiceRequest& orig)
   131 {
   329 {
   132     XQSERVICE_DEBUG_PRINT("XQServiceRequest::XQServiceRequest(3)");
   330     XQSERVICE_DEBUG_PRINT("XQServiceRequest::XQServiceRequest(3)");
   133     mData = new XQServiceRequest_Private(orig.mData->mService,orig.mData->mMessage,orig.mData->mSynchronous,this);
   331     mData = new XQServiceRequest_Private(orig.mData->mService,orig.mData->mMessage,orig.mData->mSynchronous,this);
   134     mData->mArguments = orig.mData->mArguments;
   332     mData->mArguments = orig.mData->mArguments;
   135 }
   333 }
   136 
   334 
   137 /*!
   335 /*!
   138   Construct a service request by service descriptor which contains exact details of the service and interface.
   336     Construct a service request by service descriptor which contains exact details of the service and interface.
   139   a \a service when send() is called. The service may be written
   337     The service may be written prior to the calls.
   140   prior to the calls.
   338     \param descriptor Defines details of the service and it's interface.
       
   339     \param message Message to be sent when send() is called.
       
   340     \param synchronous Defines should message be sent synchronously or asynchronously.
       
   341                        By default message is sent synchronously.
   141 */
   342 */
   142 XQServiceRequest::XQServiceRequest(const XQAiwInterfaceDescriptor &descriptor, const QString& message, const bool &synchronous)
   343 XQServiceRequest::XQServiceRequest(const XQAiwInterfaceDescriptor &descriptor, const QString& message, const bool &synchronous)
   143 {
   344 {
   144     XQSERVICE_DEBUG_PRINT("XQServiceRequest::XQServiceRequest(2)");
   345     XQSERVICE_DEBUG_PRINT("XQServiceRequest::XQServiceRequest(2)");
   145     XQSERVICE_DEBUG_PRINT("service: %s, interface %s, message: %s, synchronous: %d",
   346     XQSERVICE_DEBUG_PRINT("service: %s, interface %s, message: %s, synchronous: %d",
   147                           qPrintable(message), synchronous);
   348                           qPrintable(message), synchronous);
   148     mData = new XQServiceRequest_Private(descriptor,message,synchronous,this);
   349     mData = new XQServiceRequest_Private(descriptor,message,synchronous,this);
   149 }
   350 }
   150 
   351 
   151 /*!
   352 /*!
   152   Assignment operator.
   353     Assignment operator.
   153   Any data previously written to the \a orig
   354     Any data previously written to the \a orig
   154   service will be in the copy.
   355     service will be in the copy.
   155 */
   356 */
   156 XQServiceRequest& XQServiceRequest::operator=(const XQServiceRequest& orig)
   357 XQServiceRequest& XQServiceRequest::operator=(const XQServiceRequest& orig)
   157 {
   358 {
   158     XQSERVICE_DEBUG_PRINT("XQServiceRequest::operator=");
   359     XQSERVICE_DEBUG_PRINT("XQServiceRequest::operator=");
   159     if( &orig == this )
   360     if( &orig == this )
   166 
   367 
   167     return *this;
   368     return *this;
   168 }
   369 }
   169 
   370 
   170 /*!
   371 /*!
   171   Destructs the service request. Unlike QtopiaIpcEnvelope, the
   372     Destroys the service request. Unlike QtopiaIpcEnvelope, the
   172   request is not automatically sent.
   373     request is not automatically sent.
   173 */
   374 */
   174 XQServiceRequest::~XQServiceRequest()
   375 XQServiceRequest::~XQServiceRequest()
   175 {
   376 {
   176     XQSERVICE_DEBUG_PRINT("XQServiceRequest::~XQServiceRequest %s", qPrintable(mData->mUniqueChannelName));
   377     XQSERVICE_DEBUG_PRINT("XQServiceRequest::~XQServiceRequest %s", qPrintable(mData->mUniqueChannelName));
   177     XQServiceAdaptor::cancelPendingSend(mData->mUniqueChannelName);
   378     XQServiceAdaptor::cancelPendingSend(mData->mUniqueChannelName);
   178     delete mData;
   379     delete mData;
   179 }
   380 }
   180 
   381 
   181 /*!
   382 /*!
   182   Returns true if either the service() or message() is not set.
   383     Checks if request is NULL.
   183 
   384     \return True if either the service() or message() is not set.
   184   \sa service(), message()
   385     \sa service(), message()
   185  */
   386  */
   186 bool XQServiceRequest::isNull() const
   387 bool XQServiceRequest::isNull() const
   187 {
   388 {
   188     XQSERVICE_DEBUG_PRINT("XQServiceRequest::isNull");
   389     XQSERVICE_DEBUG_PRINT("XQServiceRequest::isNull");
   189     bool ret = mData->mService.isEmpty() || mData->mService.isNull() || mData->mMessage.isNull();
   390     bool ret = mData->mService.isEmpty() || mData->mService.isNull() || mData->mMessage.isNull();
   192 	XQSERVICE_DEBUG_PRINT("mData->mMessage.isNull() = %d", mData->mMessage.isNull());
   393 	XQSERVICE_DEBUG_PRINT("mData->mMessage.isNull() = %d", mData->mMessage.isNull());
   193 	XQSERVICE_DEBUG_PRINT("return %d", ret);
   394 	XQSERVICE_DEBUG_PRINT("return %d", ret);
   194 	return ret;
   395 	return ret;
   195 }
   396 }
   196 
   397 
       
   398 /*!
       
   399     Checks if request is synchronous or asynchronous.
       
   400     \return True if request is synchronous, false if request is asynchronous.
       
   401     \sa setSynchronous()
       
   402  */
   197 bool XQServiceRequest::isSynchronous() const
   403 bool XQServiceRequest::isSynchronous() const
   198 {
   404 {
   199     XQSERVICE_DEBUG_PRINT("XQServiceRequest::isSynchronous");
   405     XQSERVICE_DEBUG_PRINT("XQServiceRequest::isSynchronous");
   200     return mData->mSynchronous;
   406     return mData->mSynchronous;
   201 }
   407 }
   202 
   408 
       
   409 /*!
       
   410     Sets request to be synchronous or asynchronous.
       
   411     \param synchronous If set to true, request will be synchronous.
       
   412                        If set to false, request will be asynchronous.
       
   413     \sa isSynchronous()
       
   414  */
   203 void XQServiceRequest::setSynchronous(const bool& synchronous)
   415 void XQServiceRequest::setSynchronous(const bool& synchronous)
   204 {
   416 {
   205     XQSERVICE_DEBUG_PRINT("XQServiceRequest::setSynchronous");
   417     XQSERVICE_DEBUG_PRINT("XQServiceRequest::setSynchronous");
   206     mData->mSynchronous = synchronous;
   418     mData->mSynchronous = synchronous;
   207 }
   419 }
   208 /*!
   420 /*!
   209   \fn QString XQServiceRequest::send()
   421     Sends the request. If the request is synchronous, then client is blocked
   210   Sends the request. Returns false if there was no application that could
   422     until service provider completes the request or request fails for some reason.
   211   service the request.
   423     If the request is asynchronous, then client won't be blocked. If the request
       
   424     is asynchronous and clients wants to receive a return value from the service
       
   425     provider, then clients should connect to the requestCompleted() signal.
       
   426     \return False if there was no application that could service the request, otherwise true.
   212 */
   427 */
   213 bool XQServiceRequest::send()
   428 bool XQServiceRequest::send()
   214 {
   429 {
   215     XQSERVICE_DEBUG_PRINT("XQServiceRequest::send(1)");
   430     XQSERVICE_DEBUG_PRINT("XQServiceRequest::send(1)");
   216     QVariant retValue;
   431     QVariant retValue;
   217     return send(retValue);
   432     return send(retValue);
   218 }
   433 }
   219 
   434 
   220 /*!
   435 /*!
   221   \fn QString XQServiceRequest::send()
   436     Sends the request. If the request is synchronous, then client is blocked
   222   Sends the request. Returns false if there was no application that could
   437     until service provider completes the request or request fails for some reason.
   223   service the request.
   438     If the request is asynchronous, then client won't be blocked.
       
   439     \param retData Defines refence to a value service provider will return after service.
       
   440     \return False if there was no application that could service the request, otherwise true.
   224 */
   441 */
   225 bool XQServiceRequest::send(QVariant& retData)
   442 bool XQServiceRequest::send(QVariant& retData)
   226 {
   443 {
   227     XQSERVICE_DEBUG_PRINT("XQServiceRequest::send(2)");
   444     XQSERVICE_DEBUG_PRINT("XQServiceRequest::send(2)");
   228     if (isNull())
   445     if (isNull())
   259     XQSERVICE_DEBUG_PRINT("XQServiceRequest::send(2):uniqueChannel=%s", qPrintable(mData->mUniqueChannelName));
   476     XQSERVICE_DEBUG_PRINT("XQServiceRequest::send(2):uniqueChannel=%s", qPrintable(mData->mUniqueChannelName));
   260     return XQServiceAdaptor::send(mData->mUniqueChannelName,  message(), mData->mArguments, retData, mData->mSynchronous,mData,
   477     return XQServiceAdaptor::send(mData->mUniqueChannelName,  message(), mData->mArguments, retData, mData->mSynchronous,mData,
   261                                  (const void *)&mData->mRequestUtil);
   478                                  (const void *)&mData->mRequestUtil);
   262 }
   479 }
   263 /*!
   480 /*!
   264   Sets the \a service to which the request will be sent.
   481     Sets the full name of the service to which the request will be sent.
   265 
   482     \param fullServiceName Full name of the service to send message to. See
   266   \sa service()
   483                            XQServiceRequest(const QString& service, const QString& message, const bool &synchronous)
       
   484                            for the full name definition.
       
   485     \sa service()
   267  */
   486  */
   268 void XQServiceRequest::setService(const QString& fullServiceName)
   487 void XQServiceRequest::setService(const QString& fullServiceName)
   269 {
   488 {
   270     XQSERVICE_DEBUG_PRINT("XQServiceRequest::setService");
   489     XQSERVICE_DEBUG_PRINT("XQServiceRequest::setService");
   271     XQSERVICE_DEBUG_PRINT("service: %s", qPrintable(fullServiceName));
   490     XQSERVICE_DEBUG_PRINT("service: %s", qPrintable(fullServiceName));
   273     mData->mArguments.clear();
   492     mData->mArguments.clear();
   274     mData->mRequestUtil.mDescriptor = XQAiwInterfaceDescriptor(); // Invalid descriptor
   493     mData->mRequestUtil.mDescriptor = XQAiwInterfaceDescriptor(); // Invalid descriptor
   275 }
   494 }
   276 
   495 
   277 /*!
   496 /*!
   278   \fn QString XQServiceRequest::service() const
   497     Gets the service name to which this request will be sent.
   279 
   498     \return Full service name to which request will be sent.
   280   Returns the service to which this request will be sent.
   499     \sa setService()
   281 
       
   282   \sa setService()
       
   283 */
   500 */
   284 QString XQServiceRequest::service() const
   501 QString XQServiceRequest::service() const
   285 {
   502 {
   286     XQSERVICE_DEBUG_PRINT("XQServiceRequest::service");
   503     XQSERVICE_DEBUG_PRINT("XQServiceRequest::service");
   287     XQSERVICE_DEBUG_PRINT("service: %s", qPrintable(mData->mService));
   504     XQSERVICE_DEBUG_PRINT("service: %s", qPrintable(mData->mService));
   288     return mData->mService;
   505     return mData->mService;
   289 }
   506 }
   290 
   507 
   291 /*!
   508 /*!
   292     Sets the \a message to be sent to the service.
   509     Sets the \a message to be sent to the service.
   293 
   510     \param message Defines the message to send to a service provider. The message
       
   511                    is a valid Qt slot signature published by the service provider.
       
   512                    For example, "view(QString)".
   294     \sa message()
   513     \sa message()
   295 */
   514 */
   296 void XQServiceRequest::setMessage(const QString& message)
   515 void XQServiceRequest::setMessage(const QString& message)
   297 {
   516 {
   298     XQSERVICE_DEBUG_PRINT("XQServiceRequest::setMessage");
   517     XQSERVICE_DEBUG_PRINT("XQServiceRequest::setMessage");
   299     XQSERVICE_DEBUG_PRINT("message: %s", qPrintable(message));
   518     XQSERVICE_DEBUG_PRINT("message: %s", qPrintable(message));
   300     mData->mMessage = message;
   519     mData->mMessage = message;
   301     mData->mArguments.clear();
   520     mData->mArguments.clear();
   302 }
   521 }
   303 
   522 
       
   523 /*!
       
   524     Gets the message set for the request.
       
   525     \return Message of the request as QString.
       
   526     \sa setMessage()
       
   527 */
   304 QString XQServiceRequest::message() const
   528 QString XQServiceRequest::message() const
   305 { 
   529 { 
   306     XQSERVICE_DEBUG_PRINT("XQServiceRequest::message");
   530     XQSERVICE_DEBUG_PRINT("XQServiceRequest::message");
   307     XQSERVICE_DEBUG_PRINT("message: %s", qPrintable(mData->mMessage));
   531     XQSERVICE_DEBUG_PRINT("message: %s", qPrintable(mData->mMessage));
   308     return mData->mMessage;
   532     return mData->mMessage;
   309 }
   533 }
   310 
   534 
       
   535 /*!
       
   536     Gets the complete list of arguments for this service request.
       
   537     \return List of arguments set to the request.
       
   538     \sa setArguments()
       
   539 */
   311 const QList<QVariant> &XQServiceRequest::arguments() const 
   540 const QList<QVariant> &XQServiceRequest::arguments() const 
   312 {
   541 {
   313     XQSERVICE_DEBUG_PRINT("XQServiceRequest::arguments");
   542     XQSERVICE_DEBUG_PRINT("XQServiceRequest::arguments");
   314     return mData->mArguments; 
   543     return mData->mArguments; 
   315 }
   544 }
   316 
   545 
       
   546 /*!
       
   547     Sets \a arguments for this service request.
       
   548     \param arguments Complete list of arguments for this service request
       
   549                      i.e. the values to be transferred to service provider
       
   550                      function to be called.
       
   551     \sa arguments()
       
   552 */
   317 void XQServiceRequest::setArguments(const QList<QVariant> &arguments)
   553 void XQServiceRequest::setArguments(const QList<QVariant> &arguments)
   318 {
   554 {
   319     XQSERVICE_DEBUG_PRINT("XQServiceRequest::setArguments");
   555     XQSERVICE_DEBUG_PRINT("XQServiceRequest::setArguments");
   320     mData->mArguments = arguments;
   556     mData->mArguments = arguments;
   321 }
   557 }
   322 
   558 
       
   559 /*!
       
   560     Gets the latest error that happened in the request execution.
       
   561     \return The latest error that happened in the request execution.
       
   562             Errors are defined in xqserviceglobal.h. 
       
   563     \sa XQService::ServiceIPCErrors.
       
   564 */
   323 int XQServiceRequest::latestError()
   565 int XQServiceRequest::latestError()
   324     {
   566     {
   325     XQSERVICE_DEBUG_PRINT("XQServiceRequest::latestError");
   567     XQSERVICE_DEBUG_PRINT("XQServiceRequest::latestError");
   326     return XQServiceAdaptor::latestError();
   568     return XQServiceAdaptor::latestError();
   327     }
   569     }
   328 
   570 
       
   571 /*!
       
   572     Sets additional options for the request, like embedding or start to background.
       
   573     \param info Additional info to be set to the request.
       
   574     \sa info()
       
   575 */
   329 void XQServiceRequest::setInfo(const XQRequestInfo &info)
   576 void XQServiceRequest::setInfo(const XQRequestInfo &info)
   330 {
   577 {
   331     XQSERVICE_DEBUG_PRINT("XQServiceRequest::setInfo");
   578     XQSERVICE_DEBUG_PRINT("XQServiceRequest::setInfo");
   332     mData->mRequestUtil.mInfo = info;
   579     mData->mRequestUtil.mInfo = info;
   333 }
   580 }
   334 
   581 
       
   582 /*!
       
   583     Gets current info set for the request.
       
   584     \return Info data set to the request.
       
   585     \sa setInfo()
       
   586 */
   335 XQRequestInfo XQServiceRequest::info() const
   587 XQRequestInfo XQServiceRequest::info() const
   336 {
   588 {
   337     XQSERVICE_DEBUG_PRINT("XQServiceRequest::info");
   589     XQSERVICE_DEBUG_PRINT("XQServiceRequest::info");
   338     return mData->mRequestUtil.mInfo;
   590     return mData->mRequestUtil.mInfo;
   339 }
   591 }
   340     
   592 
   341 /*!
   593 /*!
   342   \fn QString XQServiceRequest::message() const
   594     \internal
   343 
       
   344   Returns the message of the request.
       
   345 
       
   346   \sa setMessage()
       
   347 */
       
   348 
       
   349 /*!
       
   350     \fn const QList<QVariant> &XQServiceRequest::arguments() const
       
   351 
       
   352     Returns the complete list of arguments for this service request.
       
   353 */
       
   354 
       
   355 /*!
       
   356     \fn void XQServiceRequest::setArguments(const QList<QVariant> &arguments)
       
   357 
       
   358     Sets the complete list of \a arguments for this service request.
       
   359 */
       
   360 
       
   361 /*!
       
   362     \fn XQServiceRequest &XQServiceRequest::operator<< (const T &var)
       
   363 
       
   364     Adds \a var to the list of arguments for this service request.
       
   365 */
       
   366 
       
   367 /*!
       
   368     \fn XQServiceRequest &XQServiceRequest::operator<< (const char *var)
       
   369 
       
   370     Adds \a var to the list of arguments for this service request.
       
   371 */
       
   372 
       
   373 /*!
       
   374     \fn void XQServiceRequest::addArg(const QVariant& var)
       
   375 
       
   376     Adds the variant \a var to the list of arguments, so that the variant's
   595     Adds the variant \a var to the list of arguments, so that the variant's
   377     value is serialized in send() rather than the variant itself.
   596     value is serialized in send() rather than the variant itself.
   378 */
       
   379 
       
   380 /*!
       
   381     \internal
       
   382 */
   597 */
   383 void XQServiceRequest::addArg(const QVariant& v)
   598 void XQServiceRequest::addArg(const QVariant& v)
   384 {
   599 {
   385     XQSERVICE_DEBUG_PRINT("XQServiceRequest::addArg %s,%d", v.typeName());
   600     XQSERVICE_DEBUG_PRINT("XQServiceRequest::addArg %s,%d", v.typeName());
   386     XQSERVICE_DEBUG_PRINT("v: %s", qPrintable(v.toString()));
   601     XQSERVICE_DEBUG_PRINT("v: %s", qPrintable(v.toString()));
   387     mData->mArguments.append(v);
   602     mData->mArguments.append(v);
   388 }
   603 }
   389 
   604 
   390 
   605 /*!
   391 /*!
   606     \internal
   392     \fn void XQServiceRequest::handleSharableFileArg()
       
   393 
       
   394     Picks the XQSharableFile argument, if any, into the request util
   607     Picks the XQSharableFile argument, if any, into the request util
   395     By this way scan parameter list only once.
   608     This way scan parameter is listed only once.
   396 */
       
   397 
       
   398 /*!
       
   399     \internal
       
   400 */
   609 */
   401 bool XQServiceRequest::handleSharableFileArgs()
   610 bool XQServiceRequest::handleSharableFileArgs()
   402 {
   611 {
   403     XQSERVICE_DEBUG_PRINT("XQServiceRequest::handleSharableFile");
   612     XQSERVICE_DEBUG_PRINT("XQServiceRequest::handleSharableFile");
   404 
   613 
   438     return ret;
   647     return ret;
   439 }
   648 }
   440 
   649 
   441 
   650 
   442 /*!
   651 /*!
   443     \internal
   652     Serializes all the arguments from the service request.
       
   653     \param action Defines the request having arguments to be serialized.
       
   654     \return Serialized arguments in byte array.
   444 */
   655 */
   445 QByteArray XQServiceRequest::serializeArguments(const XQServiceRequest &action)
   656 QByteArray XQServiceRequest::serializeArguments(const XQServiceRequest &action)
   446 {
   657 {
   447     XQSERVICE_DEBUG_PRINT("XQServiceRequest::serializeArguments");
   658     XQSERVICE_DEBUG_PRINT("XQServiceRequest::serializeArguments");
   448     QByteArray ret;
   659     QByteArray ret;
   453 
   664 
   454     delete buffer;
   665     delete buffer;
   455     return ret;
   666     return ret;
   456 }
   667 }
   457 /*!
   668 /*!
   458     \internal
   669     Deserializes all the arguments from the byte array to service request.
       
   670     \param action Defines the request where arguments are deserialized.
       
   671     \param data Defines the byte array of serialized arguments.
   459 */
   672 */
   460 void XQServiceRequest::deserializeArguments(XQServiceRequest &action,
   673 void XQServiceRequest::deserializeArguments(XQServiceRequest &action,
   461         const QByteArray &data)
   674         const QByteArray &data)
   462 {
   675 {
   463     XQSERVICE_DEBUG_PRINT("XQServiceRequest::deserializeArguments");
   676     XQSERVICE_DEBUG_PRINT("XQServiceRequest::deserializeArguments");
   464     QDataStream stream(data);
   677     QDataStream stream(data);
   465     stream >> action.mData->mArguments;
   678     stream >> action.mData->mArguments;
   466 }
   679 }
   467 
   680 
   468 /*!
   681 /*!
   469     \internal
   682     Serializes this request to the stream.
   470     \fn void XQServiceRequest::serialize(Stream &stream) const
   683     \param stream Defines stream this request is serialized to.
   471 */
   684 */
   472 template <typename Stream> void XQServiceRequest::serialize(Stream &stream) const
   685 template <typename Stream> void XQServiceRequest::serialize(Stream &stream) const
   473 {
   686 {
   474     XQSERVICE_DEBUG_PRINT("XQServiceRequest::serialize");
   687     XQSERVICE_DEBUG_PRINT("XQServiceRequest::serialize");
   475     stream << mData->mArguments;
   688     stream << mData->mArguments;
   477     stream << mData->mMessage;
   690     stream << mData->mMessage;
   478     stream << mData->mSynchronous;
   691     stream << mData->mSynchronous;
   479 }
   692 }
   480 
   693 
   481 /*!
   694 /*!
   482     \internal
   695     Deserializes this request from the stream.
   483     \fn void XQServiceRequest::deserialize(Stream &stream)
   696     \param stream Defines the stream this request is deserialized from.
   484 */
   697 */
   485 template <typename Stream> void XQServiceRequest::deserialize(Stream &stream)
   698 template <typename Stream> void XQServiceRequest::deserialize(Stream &stream)
   486 {
   699 {
   487     XQSERVICE_DEBUG_PRINT("XQServiceRequest::deserialize");
   700     XQSERVICE_DEBUG_PRINT("XQServiceRequest::deserialize");
   488     stream >> mData->mArguments;
   701     stream >> mData->mArguments;