utilities/serviceipcserver/serviceipcserver.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 serviceipcserver_h
       
    19 #define serviceipcserver_h
       
    20 
       
    21 #include <QtCore>
       
    22 #include <serviceipcdefs.h>
       
    23 
       
    24 namespace WRT {
       
    25     
       
    26     // Forward Declarations
       
    27     class ServiceFwIPCServerPrivate;
       
    28     class MServiceIPCObserver;
       
    29     
       
    30     class SFWIPCSRV_EXPORT ServiceFwIPCServer : public QObject
       
    31     {
       
    32 	 Q_OBJECT
       
    33     public:
       
    34     
       
    35         ServiceFwIPCServer(MServiceIPCObserver* aObserver,
       
    36                            QObject* aParent,
       
    37                            TServiceIPCBackends aBackend = EDefaultIPC);
       
    38     
       
    39         virtual ~ServiceFwIPCServer();
       
    40     
       
    41     // APIs provided
       
    42     public:
       
    43     
       
    44         bool listen(const QString& aServerName);
       
    45     
       
    46         void disconnect();
       
    47         
       
    48         void configIpcServerLifetime(bool aKeepServer);
       
    49    
       
    50         /**
       
    51         * Send a broadcast message to all clients connected to this server
       
    52         * @param aMessage the contents of the message
       
    53         */ 
       
    54         void broadcast( const QByteArray& aMessage );
       
    55         
       
    56         /**
       
    57         * Send a message to a particular client connected to this server
       
    58         * @param aSessionId, id of a session to broadcast to
       
    59         * @param aMessage the contents of the message
       
    60         */ 
       
    61         void sendMessage( qint32 aSessionId, QByteArray& aMessage );
       
    62                              
       
    63              
       
    64     signals:
       
    65         void handleExit();
       
    66         
       
    67     private:
       
    68         void startTimer();
       
    69         
       
    70         void stopTimer();
       
    71         
       
    72     protected:
       
    73         // data
       
    74         MServiceIPCObserver* m_Observer;
       
    75         
       
    76     private:
       
    77         friend class ServiceFwIPCServerPrivate;
       
    78         ServiceFwIPCServerPrivate* d;
       
    79         QTimer *m_Timer;
       
    80         
       
    81     };
       
    82 
       
    83 }
       
    84 #endif // serviceipcserver_h