27 |
27 |
28 namespace QtService |
28 namespace QtService |
29 { |
29 { |
30 |
30 |
31 /*! |
31 /*! |
32 \class ServiceFwIPC |
32 \class ServiceFwIPC |
33 Public interface class for IPC operations |
33 \brief Public interface class for IPC operations |
34 */ |
34 */ |
35 |
35 |
36 /*! |
36 /*! |
37 Destructor |
37 Destructor |
38 */ |
38 */ |
39 ServiceFwIPC::~ServiceFwIPC() |
39 ServiceFwIPC::~ServiceFwIPC() |
40 { |
40 { |
41 XQSERVICE_DEBUG_PRINT("ServiceFwIPC::~ServiceFwIPC"); |
41 XQSERVICE_DEBUG_PRINT("ServiceFwIPC::~ServiceFwIPC"); |
42 delete d; |
42 delete d; |
43 } |
43 } |
44 |
44 |
45 /*! |
45 /*! |
46 Constructor |
46 Constructor. |
47 @param aBackend IPC backend to use |
47 \param aParent Parent to this QObject |
48 @param aParent Parent to this QObject |
48 \param aBackend IPC backend to use |
49 */ |
49 */ |
50 ServiceFwIPC::ServiceFwIPC(QObject* aParent, TServiceIPCBackends aBackend) : |
50 ServiceFwIPC::ServiceFwIPC(QObject* aParent, TServiceIPCBackends aBackend) : |
51 QObject(aParent), iAsyncRequestPending(false) |
51 QObject(aParent), iAsyncRequestPending(false) |
52 { |
52 { |
53 XQSERVICE_DEBUG_PRINT("ServiceFwIPC::ServiceFwIPC"); |
53 XQSERVICE_DEBUG_PRINT("ServiceFwIPC::ServiceFwIPC"); |
54 // Private implementation pattern |
54 // Private implementation pattern |
56 d = ServiceFwIPCFactory::createBackend(aBackend); |
56 d = ServiceFwIPCFactory::createBackend(aBackend); |
57 d->q = this; |
57 d->q = this; |
58 } |
58 } |
59 |
59 |
60 /*! |
60 /*! |
61 Connect to the server |
61 Connect to the server. |
62 @param aServerName name of the server to connect to |
62 \param aServerName name of the server to connect to. |
63 @return true if connected, false if not |
63 \return true if connected, false if not. |
64 */ |
64 */ |
65 bool ServiceFwIPC::connect(const QString& aServerName) |
65 bool ServiceFwIPC::connect(const QString& aServerName) |
66 { |
66 { |
67 XQSERVICE_DEBUG_PRINT("ServiceFwIPC::connect"); |
67 XQSERVICE_DEBUG_PRINT("ServiceFwIPC::connect"); |
68 return d->connect(aServerName); |
68 return d->connect(aServerName); |
69 } |
69 } |
70 |
70 |
71 /*! |
71 /*! |
72 Disconnect from the server |
72 Disconnect from the server. |
73 @return void |
73 */ |
74 */ |
|
75 void ServiceFwIPC::disconnect() |
74 void ServiceFwIPC::disconnect() |
76 { |
75 { |
77 XQSERVICE_DEBUG_PRINT("ServiceFwIPC::disconnect"); |
76 XQSERVICE_DEBUG_PRINT("ServiceFwIPC::disconnect"); |
78 d->disconnect(); |
77 d->disconnect(); |
79 } |
78 } |
80 |
79 |
81 /*! |
80 /*! |
82 Starts the service |
81 Starts the service. |
83 @param aServerName name of the server |
82 \param aServerName Name of the server. |
84 @param aExeName executable of the server |
83 \param aExeName Executable of the server. |
85 @return true if connected |
84 \return true if connected. |
86 */ |
85 */ |
87 bool ServiceFwIPC::startServer(const QString& aServerName, |
86 bool ServiceFwIPC::startServer(const QString& aServerName, |
88 const QString& aExeName, |
87 const QString& aExeName, |
89 quint64& processId, |
88 quint64& processId, |
90 ServiceIPCStartServerOptions options) |
89 ServiceIPCStartServerOptions options) |
91 { |
90 { |
92 XQSERVICE_DEBUG_PRINT("ServiceFwIPC::startServer"); |
91 XQSERVICE_DEBUG_PRINT("ServiceFwIPC::startServer"); |
93 return d->startServer(aServerName, aExeName, processId, options); |
92 return d->startServer(aServerName, aExeName, processId, options); |
94 } |
93 } |
95 |
94 |
96 /*! |
95 /*! |
97 Send a request synchronously |
96 Send a request synchronously. |
98 @param aRequestType name of the request |
97 \param aRequestType Name of the request. |
99 @param aData data to send |
98 \param aData Data to send. |
100 @return true if sent successful, otherwise false |
99 \return true if sent successful, otherwise false. |
101 */ |
100 */ |
102 bool ServiceFwIPC::sendSync(const QString& aRequestType, |
101 bool ServiceFwIPC::sendSync(const QString& aRequestType, |
103 const QByteArray& aData) |
102 const QByteArray& aData) |
104 { |
103 { |
105 XQSERVICE_DEBUG_PRINT("ServiceFwIPC::sendSync"); |
104 XQSERVICE_DEBUG_PRINT("ServiceFwIPC::sendSync"); |
106 #ifdef _DEBUG |
105 #ifdef _DEBUG |
113 return sent; |
112 return sent; |
114 } |
113 } |
115 |
114 |
116 |
115 |
117 /*! |
116 /*! |
118 Send a request asynchronously |
117 Send a request asynchronously. |
119 @param aRequestType name of the request |
118 \param aRequestType Name of the request. |
120 @param aData data to send |
119 \param aData Data to send. |
121 @note Errors will be emitted via errors() signal |
120 \note Errors will be emitted via error() signal. |
122 @return void |
121 */ |
123 */ |
|
124 void ServiceFwIPC::sendAsync(const QString& aRequestType, |
122 void ServiceFwIPC::sendAsync(const QString& aRequestType, |
125 const QByteArray& aData) |
123 const QByteArray& aData) |
126 { |
124 { |
127 XQSERVICE_DEBUG_PRINT("ServiceFwIPC::sendAsync"); |
125 XQSERVICE_DEBUG_PRINT("ServiceFwIPC::sendAsync"); |
128 #ifdef _DEBUG |
126 #ifdef _DEBUG |
130 #endif // _DEBUG |
128 #endif // _DEBUG |
131 d->sendAsync(aRequestType, aData); |
129 d->sendAsync(aRequestType, aData); |
132 iAsyncRequestPending = true; |
130 iAsyncRequestPending = true; |
133 } |
131 } |
134 |
132 |
135 /** |
133 /*! |
136 * Async read |
134 Asynchronous read. |
137 */ |
135 \param aArray Array where read data will be put. |
|
136 */ |
138 void ServiceFwIPC::readAll(QByteArray& aArray) |
137 void ServiceFwIPC::readAll(QByteArray& aArray) |
139 { |
138 { |
140 XQSERVICE_DEBUG_PRINT("ServiceFwIPC::readAll(1)"); |
139 XQSERVICE_DEBUG_PRINT("ServiceFwIPC::readAll(1)"); |
141 d->readAll(aArray); |
140 d->readAll(aArray); |
142 } |
141 } |
143 |
142 |
144 /** |
143 /*! |
145 * sync read |
144 Synchronous read. |
|
145 \return Array which where read data is put. |
146 */ |
146 */ |
147 QByteArray ServiceFwIPC::readAll() |
147 QByteArray ServiceFwIPC::readAll() |
148 { |
148 { |
149 XQSERVICE_DEBUG_PRINT("ServiceFwIPC::readAll(2)"); |
149 XQSERVICE_DEBUG_PRINT("ServiceFwIPC::readAll(2)"); |
150 return d->readAll(); |
150 return d->readAll(); |
151 } |
151 } |
152 |
152 |
153 /*! |
153 /*! |
154 Waits until data is available for reading |
154 Waits until data is available for reading. |
155 @return true if data is available for reading |
155 \return true if data is available for reading. |
156 */ |
156 */ |
157 bool ServiceFwIPC::waitForRead() |
157 bool ServiceFwIPC::waitForRead() |
158 { |
158 { |
159 XQSERVICE_DEBUG_PRINT("ServiceFwIPC::waitForRead"); |
159 XQSERVICE_DEBUG_PRINT("ServiceFwIPC::waitForRead"); |
160 return d->waitForRead(); |
160 return d->waitForRead(); |
161 } |
161 } |
162 |
162 |
163 /*! |
163 /*! |
164 Check if an async request is already pending |
164 Check if an async request is already pending. |
165 @return true if an async request is pending |
165 \return true if an async request is pending, |
166 false otherwise |
166 false otherwise. |
167 */ |
167 */ |
168 bool ServiceFwIPC::requestPending() |
168 bool ServiceFwIPC::requestPending() |
169 { |
169 { |
170 XQSERVICE_DEBUG_PRINT("ServiceFwIPC::requestPending"); |
170 XQSERVICE_DEBUG_PRINT("ServiceFwIPC::requestPending"); |
171 return iAsyncRequestPending; |
171 return iAsyncRequestPending; |
172 } |
172 } |
180 } |
180 } |
181 |
181 |
182 |
182 |
183 |
183 |
184 /*! |
184 /*! |
185 \fn QtService::ServiceFwIPC::error( int aError ) |
185 \fn QtService::ServiceFwIPC::error( int aError ) |
186 |
186 |
187 Signal emitted to handle any errors |
187 Signal emitted to handle any errors. |
188 @param aError error code |
188 \param aError error code |
189 @note: For local socket implementation, the error can be interpreted |
189 \note For local socket implementation, the error can be interpreted |
190 as QLocalSocket::LocalSocketError |
190 as QLocalSocket::LocalSocketError |
191 @return void |
191 */ |
192 */ |
192 |
193 |
193 /*! |
194 /*! |
194 \fn QtService::ServiceFwIPC::readyRead() |
195 \fn QtService::ServiceFwIPC::readyRead() |
195 |
196 |
196 Handle when a reply has been received for async requests. |
197 Handle when a reply has been received for async requests\n |
197 Emitted when the entire data packet has been received |
198 Emitted when the entire data packet has been received |
198 */ |
199 @return void |
199 |
200 */ |
200 /*! |
|
201 \fn QtService::ServiceFwIPC::ReadDone() |
|
202 |
|
203 Emitted when reading has completed. |
|
204 */ |
201 // END OF FILE |
205 // END OF FILE |