qthighway/xqservice/src/xqaiwservicedriver.cpp
changeset 11 06b8e2af4411
parent 4 90517678cc4f
equal deleted inserted replaced
8:71781823f776 11:06b8e2af4411
    38 // Constants
    38 // Constants
    39 
    39 
    40 XQAiwServiceDriver::XQAiwServiceDriver(const XQAiwInterfaceDescriptor& descriptor, const QString &operation)
    40 XQAiwServiceDriver::XQAiwServiceDriver(const XQAiwInterfaceDescriptor& descriptor, const QString &operation)
    41     : XQAiwRequestDriver(),
    41     : XQAiwRequestDriver(),
    42       currentRequest(NULL),
    42       currentRequest(NULL),
    43       asyncErrorSet(false)
    43       completeSignalConnected(false),
       
    44       errorSignalConnected(false)
    44     {
    45     {
    45     mErrorMsg = "";
    46     mErrorMsg = "";
    46     mDescr = descriptor; 
    47     mDescr = descriptor; 
    47     mOperation = operation; 
    48     mOperation = operation; 
    48     XQSERVICE_DEBUG_PRINT("XQAiwServiceDriver::XQAiwServiceDriver: %s %s,%x",
    49     XQSERVICE_DEBUG_PRINT("XQAiwServiceDriver::XQAiwServiceDriver: %s %s,%x",
    56 
    57 
    57 XQAiwServiceDriver::~XQAiwServiceDriver()
    58 XQAiwServiceDriver::~XQAiwServiceDriver()
    58 {
    59 {
    59     XQSERVICE_DEBUG_PRINT("~XQAiwServiceDriver::XQAiwServiceDriver");
    60     XQSERVICE_DEBUG_PRINT("~XQAiwServiceDriver::XQAiwServiceDriver");
    60 
    61 
    61     // Disconnect error
    62     // Disconnect signals
    62     if (asyncErrorSet)
    63     if (completeSignalConnected)
    63     {
    64     {
    64         disconnect(currentRequest, SIGNAL(requestCompleted(const QVariant&)), this, SLOT(handleAsyncResponse(const QVariant&)));
    65         disconnect(currentRequest, SIGNAL(requestCompleted(const QVariant&)), this, SLOT(handleAsyncResponse(const QVariant&)));
       
    66     }
       
    67     if (errorSignalConnected)
       
    68     {
    65         disconnect(currentRequest, SIGNAL(requestError(int)), this, SLOT(handleAsyncError(int)));
    69         disconnect(currentRequest, SIGNAL(requestError(int)), this, SLOT(handleAsyncError(int)));
    66     }
    70     }
    67     
    71     
    68     delete currentRequest; // Destructor cancels the async request
    72     delete currentRequest; // Destructor cancels the async request
    69 
    73 
   141     }
   145     }
   142     currentRequest->setInfo(opt);
   146     currentRequest->setInfo(opt);
   143     
   147     
   144     QStringList list;
   148     QStringList list;
   145     bool res = true;
   149     bool res = true;
   146     if (!currentRequest->isSynchronous() && !asyncErrorSet)
   150     if (!currentRequest->isSynchronous() && !completeSignalConnected)
   147     {
   151     {
   148         // Async request 
   152         // Async request. Connect signal only once
   149         XQSERVICE_DEBUG_PRINT("request::async send");
   153         XQSERVICE_DEBUG_PRINT("request::async send");
   150         connect(currentRequest, SIGNAL(requestCompleted(const QVariant&)), this, SLOT(handleAsyncResponse(const QVariant&)));
   154         connect(currentRequest, SIGNAL(requestCompleted(const QVariant&)), this, SLOT(handleAsyncResponse(const QVariant&)));
       
   155         completeSignalConnected = true;
       
   156     }
       
   157     if (!errorSignalConnected)
       
   158     {
       
   159         // Connect error signal only once
   151         connect(currentRequest, SIGNAL(requestError(int)), this, SLOT(handleAsyncError(int)));
   160         connect(currentRequest, SIGNAL(requestError(int)), this, SLOT(handleAsyncError(int)));
   152         asyncErrorSet = true;
   161         errorSignalConnected = true;
   153     }
   162     }
   154 
       
   155     
   163     
   156     XQSERVICE_DEBUG_PRINT("request::send>>>");
   164     XQSERVICE_DEBUG_PRINT("request::send>>>");
   157     res = currentRequest->send(retValue);  // Result is valid for sync request only
   165     res = currentRequest->send(retValue);  // Result is valid for sync request only
   158     XQSERVICE_DEBUG_PRINT("request::send: %d<<<", res);
   166     XQSERVICE_DEBUG_PRINT("request::send: %d<<<", res);
   159     
   167