|
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 serviceipc_p_h |
|
19 #define serviceipc_p_h |
|
20 |
|
21 #include "serviceipc.h" |
|
22 #include <QtCore> |
|
23 #include <QByteArray> |
|
24 |
|
25 namespace WRT { |
|
26 |
|
27 /** |
|
28 * Private implementation class for IPC |
|
29 */ |
|
30 class ServiceFwIPC; |
|
31 class ServiceFwIPCPrivate |
|
32 { |
|
33 public: |
|
34 /** |
|
35 * Virtual destructor |
|
36 */ |
|
37 virtual ~ServiceFwIPCPrivate() {}; |
|
38 |
|
39 |
|
40 // Virtual functions |
|
41 |
|
42 /** |
|
43 * Connect to the server |
|
44 * @param aServerName name of the server to connect to |
|
45 * @return true if connected, false if not |
|
46 */ |
|
47 virtual bool connect(const QString& aServerName) = 0; |
|
48 |
|
49 /** |
|
50 * Disconnect from the server |
|
51 */ |
|
52 virtual void disconnect() = 0; |
|
53 |
|
54 /** |
|
55 * Starts the service |
|
56 * @note: refer to public API ServiceFwIPC |
|
57 */ |
|
58 virtual bool startServer(const QString& aServerName, |
|
59 const QString& aExeName) = 0; |
|
60 |
|
61 /** |
|
62 * Send a request synchronously |
|
63 * @note: refer to public API ServiceFwIPC |
|
64 */ |
|
65 virtual bool sendSync(const QString& aRequestType, |
|
66 const QByteArray& aData) = 0; |
|
67 |
|
68 /** |
|
69 * Send a request asynchronously |
|
70 * @note: refer to public API ServiceFwIPC |
|
71 */ |
|
72 virtual void sendAsync(const QString& aRequestType, |
|
73 const QByteArray& aData) = 0; |
|
74 |
|
75 /** |
|
76 * Reads all data pending in the buffer |
|
77 * @note: refer to public API ServiceFwIPC |
|
78 */ |
|
79 virtual QByteArray readAll() = 0; |
|
80 |
|
81 /** |
|
82 * Waits until data is available for reading |
|
83 * @note: refer to public API ServiceFwIPC |
|
84 */ |
|
85 virtual bool waitForRead() = 0; |
|
86 |
|
87 /** |
|
88 * Retrieves the session id synchronously |
|
89 * @note: refer to public API ServiceFwIPC |
|
90 */ |
|
91 bool getSessionId(int& aSessionId); |
|
92 |
|
93 /** |
|
94 * Sets the session id |
|
95 * @note: refer to public API ServiceFwIPC |
|
96 */ |
|
97 bool setSessionId(int aSessionId); |
|
98 |
|
99 protected: |
|
100 // TODO: Move to inl file |
|
101 inline void emitReadyRead() |
|
102 { |
|
103 if (q->m_AsyncRequestPending) { |
|
104 q->m_AsyncRequestPending = false; |
|
105 emit q->readyRead(); |
|
106 } |
|
107 }; |
|
108 |
|
109 inline void emitError(int aError) |
|
110 { |
|
111 emit q->error(aError); |
|
112 }; |
|
113 |
|
114 inline bool asyncPending() |
|
115 { |
|
116 return q->requestPending(); |
|
117 } |
|
118 private: |
|
119 friend class ServiceFwIPC; |
|
120 ServiceFwIPC* q; // not owned |
|
121 }; |
|
122 |
|
123 } |
|
124 #endif // serviceipc_p_h |