qthighway/tests/auto/xqservice/common/xqserviceipcclient_stub.cpp
changeset 18 1b485afba084
parent 16 19b186e43276
child 28 19321a443c34
equal deleted inserted replaced
16:19b186e43276 18:1b485afba084
     1 /*
       
     2 * Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
       
     3 * All rights reserved.
       
     4 *
       
     5 * This program is free software: you can redistribute it and/or modify
       
     6 * it under the terms of the GNU Lesser General Public License as published by
       
     7 * the Free Software Foundation, version 2.1 of the License.
       
     8 * 
       
     9 * This program is distributed in the hope that it will be useful,
       
    10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
       
    11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
       
    12 * GNU Lesser General Public License for more details.
       
    13 *
       
    14 * You should have received a copy of the GNU Lesser General Public License
       
    15 * along with this program.  If not, 
       
    16 * see "http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html/".
       
    17 *
       
    18 * Description:                                                         
       
    19 *
       
    20 */
       
    21 
       
    22 /* THIS IS A XQServiceIpcClient STUB used only for UNIT TEST */
       
    23 
       
    24 #include "xqserviceipcclient.h"
       
    25 #include "xqservicechannel.h"
       
    26 #include "xqservicethreaddata.h"
       
    27 
       
    28 
       
    29 struct XQServicePacketHeader
       
    30 {
       
    31     int totalLength;
       
    32     int command;
       
    33     int chLength;
       
    34     int msgLength;
       
    35     int dataLength;
       
    36 };
       
    37 
       
    38 XQServiceIpcClient::XQServiceIpcClient(const QString& ipcConName, bool isServer, bool isSync,
       
    39                                        XQServiceRequestCompletedAsync* rc,
       
    40                                        const void *userData)
       
    41     : QObject(), serviceIpc(NULL), serviceIpcServer(NULL), callBackRequestComplete(rc),
       
    42       mUserData(userData)
       
    43 {
       
    44     mIpcConName = ipcConName;
       
    45     server = isServer;
       
    46     synchronous = isSync ;
       
    47     currentRequest = NULL ;
       
    48 }
       
    49 
       
    50 XQServiceIpcClient::~XQServiceIpcClient()
       
    51 {
       
    52 disconnected();
       
    53 }
       
    54 
       
    55 bool XQServiceIpcClient::listen()
       
    56 {
       
    57     return true;
       
    58 }
       
    59 
       
    60 bool XQServiceIpcClient::connectToServer()
       
    61 {
       
    62     return true;
       
    63 }
       
    64 
       
    65 bool XQServiceIpcClient::handleRequest( ServiceIPCRequest *aRequest )
       
    66 {
       
    67     bool result(true);
       
    68     int index = setCurrentRequest(aRequest);
       
    69         
       
    70     QVariant ret;
       
    71 
       
    72     if (!requestAsync) {
       
    73         completeRequest(index,ret);
       
    74     }
       
    75     
       
    76     return result;
       
    77 }
       
    78 
       
    79 /*!
       
    80  * From MServiceIPCObserver
       
    81  * \see MServiceIPCObserver::handleCancelRequest( ServiceIPCRequest *aRequest )
       
    82  */
       
    83 void XQServiceIpcClient::handleCancelRequest( ServiceIPCRequest* /*aRequest*/ )
       
    84 {
       
    85 //TODO:
       
    86 }
       
    87 
       
    88 /*!
       
    89  * From MServiceIPCObserver
       
    90  * \see MServiceIPCObserver::handleCancelRequest( ServiceIPCRequest *aRequest )
       
    91  */
       
    92 void XQServiceIpcClient::handleDeleteRequest( ServiceIPCRequest* /*aRequest*/ )
       
    93 {
       
    94 //TODO:
       
    95 }
       
    96 
       
    97 bool XQServiceIpcClient::sendChannelCommand(int cmd, const QString& ch)
       
    98 {    
       
    99     return true;
       
   100 }
       
   101 
       
   102 bool XQServiceIpcClient::send
       
   103     (const QString& ch, const QString& msg, const QByteArray& data, QByteArray &retData, int cmd)
       
   104 {
       
   105     return true;
       
   106 }
       
   107 
       
   108 bool XQServiceIpcClient::cancelPendingSend(const QString& channel)
       
   109 {
       
   110     return true;
       
   111 }
       
   112 
       
   113 void XQServiceIpcClient::disconnected()
       
   114 {
       
   115 }
       
   116 
       
   117 void XQServiceIpcClient::clientError(int error)
       
   118 {
       
   119 }
       
   120 
       
   121 int XQServiceIpcClient::setCurrentRequest(ServiceIPCRequest* request)
       
   122 {
       
   123     if (currentRequest && request)
       
   124         return 0;
       
   125     currentRequest = request;
       
   126     requestAsync = false;
       
   127     //TODO:
       
   128     return 1;
       
   129 }
       
   130 
       
   131 int XQServiceIpcClient::setCurrentRequestAsync()
       
   132 {
       
   133     requestAsync = true;
       
   134     //TODO:
       
   135     return 1;
       
   136 }
       
   137 
       
   138 bool XQServiceIpcClient::completeRequest(int index, const QVariant& retValue)
       
   139 {
       
   140     //TODO:
       
   141     Q_UNUSED(index);
       
   142     if (!currentRequest)
       
   143         return false;
       
   144     
       
   145     bool ret = true;
       
   146     setCurrentRequest(NULL) ;
       
   147     return ret;
       
   148 }
       
   149 
       
   150 
       
   151 //
       
   152 // This function need to be called during a slot call before returning from
       
   153 // the slot.
       
   154 // The lastId might change after returning from the slot call as
       
   155 // other possible requests may arrive
       
   156 //
       
   157 XQRequestInfo XQServiceIpcClient::requestInfo() const
       
   158 {
       
   159     // Dummy
       
   160     return XQRequestInfo();
       
   161 }
       
   162 
       
   163 //
       
   164 // This internal function need to be called before a slot call to set the request info
       
   165 // The provider can then call requestInfo() to get the data.
       
   166 // The lastId might change after returning from the slot call as
       
   167 // other possible requests may arrive
       
   168 //
       
   169 bool XQServiceIpcClient::setRequestInfo(XQRequestInfo &info)
       
   170 {
       
   171     // Dummy
       
   172     return true;
       
   173 }
       
   174 
       
   175 
       
   176 
       
   177 void XQServiceIpcClient::readyRead()
       
   178 {
       
   179 }
       
   180 
       
   181 void XQServiceIpcClient::readDone()
       
   182 {
       
   183 }
       
   184