utilities/serviceipcclient/serviceipcclient.h
changeset 16 3c88a81ff781
equal deleted inserted replaced
14:6aeb7a756187 16:3c88a81ff781
       
     1 /**
       
     2    This file is part of CWRT package **
       
     3 
       
     4    Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). **
       
     5 
       
     6    This program is free software: you can redistribute it and/or modify
       
     7    it under the terms of the GNU (Lesser) General Public License as
       
     8    published by the Free Software Foundation, version 2.1 of the License.
       
     9    This program is distributed in the hope that it will be useful, but
       
    10    WITHOUT ANY WARRANTY; without even the implied warranty of
       
    11    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
       
    12    (Lesser) General Public License for more details. You should have
       
    13    received a copy of the GNU (Lesser) General Public License along
       
    14    with this program. If not, see <http://www.gnu.org/licenses/>.
       
    15 */
       
    16 
       
    17 
       
    18 #ifndef Q_SERVICEIPCCLIENT_H
       
    19 #define Q_SERVICEIPCCLIENT_H
       
    20 
       
    21 #include <QtCore>
       
    22 #include "serviceipcdefs.h"
       
    23 
       
    24 namespace WRT {
       
    25     
       
    26     class ServiceFwIPC;
       
    27     
       
    28     class SFWIPC_EXPORT ServiceIPCClient : public QObject
       
    29     {
       
    30     Q_OBJECT
       
    31     public:
       
    32         virtual ~ ServiceIPCClient();
       
    33     
       
    34         explicit ServiceIPCClient(QObject* aParent, TServiceIPCBackends aBackend = EDefaultIPC);
       
    35     
       
    36     public:
       
    37         bool connect(const QString& aServerName);
       
    38     
       
    39         void disconnect();
       
    40     
       
    41         bool startServer(const QString& aServerName, const QString& aExeName);
       
    42     
       
    43         bool sendSync(const QString& aRequestType, const QByteArray& aData);
       
    44     
       
    45         void sendAsync(const QString& aRequestType, const QByteArray& aData);
       
    46     
       
    47         QByteArray readAll();
       
    48     
       
    49         //bool requestPending();
       
    50         
       
    51         inline qint32 sessionId() {return m_sessionId;}
       
    52     
       
    53     signals:
       
    54     
       
    55         void error(int aError);
       
    56     
       
    57         void readyRead(); //keep interface for ServiceFwIPC
       
    58         
       
    59         void readAsync(QByteArray ipcResult); //read async result
       
    60 
       
    61         void handleMessage( QByteArray aMessage );  //send broadcast msg 
       
    62         
       
    63     private slots:
       
    64     /**
       
    65      * Handle the IPC client "readyRead" signal
       
    66      */
       
    67         void handleAsyncMsg(); 
       
    68         void handleBroadcastMsg();
       
    69         
       
    70     private:    
       
    71         void subscribeBroadcastMsg();
       
    72             
       
    73         // Member Variables
       
    74     protected:        
       
    75        // friend class ServiceFwIPC;
       
    76         // One instance of the IPC endpoint to handle async messages
       
    77         ServiceFwIPC* m_asyncIPC;
       
    78         
       
    79         // Another instance of the IPC endpoint to handle sync messages
       
    80         ServiceFwIPC* m_syncIPC;
       
    81         
       
    82         // Another instance of the IPC endpoint to handle broadcast messages
       
    83         ServiceFwIPC* m_broadcastIPC;
       
    84         
       
    85     private:
       
    86         qint32 m_sessionId;
       
    87     };
       
    88 
       
    89 }
       
    90 #endif // Q_SERVICEIPCCLIENT_H