39 const TInt KServerBuildVersionNumber = 0; |
39 const TInt KServerBuildVersionNumber = 0; |
40 |
40 |
41 |
41 |
42 |
42 |
43 /*! |
43 /*! |
44 \class CServiceSymbianIPC |
44 \class CServiceSymbianIPC |
45 |
45 \brief Symbian Client backend for the service IPC |
46 Symbian Client backend for the service IPC |
46 */ |
47 */ |
47 |
48 |
48 /*! |
49 /*! |
49 Constructor. |
50 Constructor |
50 */ |
51 */ |
|
52 CServiceSymbianIPC::CServiceSymbianIPC() : |
51 CServiceSymbianIPC::CServiceSymbianIPC() : |
53 CActive(CActive::EPriorityStandard), iDataSize(0) |
52 CActive(CActive::EPriorityStandard), iDataSize(0) |
54 { |
53 { |
55 XQSERVICE_DEBUG_PRINT("CServiceSymbianIPC::CServiceSymbianIPC"); |
54 XQSERVICE_DEBUG_PRINT("CServiceSymbianIPC::CServiceSymbianIPC"); |
56 CActiveScheduler::Add(this); |
55 CActiveScheduler::Add(this); |
57 } |
56 } |
58 |
57 |
59 /*! |
58 /*! |
60 Destructor |
59 Destructor. |
61 */ |
60 */ |
62 CServiceSymbianIPC::~CServiceSymbianIPC() |
61 CServiceSymbianIPC::~CServiceSymbianIPC() |
63 { |
62 { |
64 XQSERVICE_DEBUG_PRINT("CServiceSymbianIPC::~CServiceSymbianIPC"); |
63 XQSERVICE_DEBUG_PRINT("CServiceSymbianIPC::~CServiceSymbianIPC"); |
65 Cancel(); |
64 Cancel(); |
66 delete iAsyncData; |
65 delete iAsyncData; |
67 delete iRequestData; |
66 delete iRequestData; |
68 } |
67 } |
69 |
68 |
70 /*! |
69 /*! |
71 2nd phased constructor |
70 2nd phased constructor. |
72 */ |
71 */ |
73 void CServiceSymbianIPC::ConstructL() |
72 void CServiceSymbianIPC::ConstructL() |
74 { |
73 { |
75 } |
74 } |
76 |
75 |
77 /*! |
76 /*! |
78 Two Phased Constructor |
77 Two Phased Constructor. |
79 */ |
78 */ |
80 CServiceSymbianIPC* CServiceSymbianIPC::NewL() |
79 CServiceSymbianIPC* CServiceSymbianIPC::NewL() |
81 { |
80 { |
82 XQSERVICE_DEBUG_PRINT("CServiceSymbianIPC::NewL"); |
81 XQSERVICE_DEBUG_PRINT("CServiceSymbianIPC::NewL"); |
83 CServiceSymbianIPC* self = new (ELeave) CServiceSymbianIPC(); |
82 CServiceSymbianIPC* self = new (ELeave) CServiceSymbianIPC(); |
84 CleanupStack::PushL(self); |
83 CleanupStack::PushL(self); |
86 CleanupStack::Pop(self); |
85 CleanupStack::Pop(self); |
87 return self; |
86 return self; |
88 } |
87 } |
89 |
88 |
90 /*! |
89 /*! |
91 Connect to the server |
90 Connect to the server. |
92 @param aServerName name of the server to connect to |
91 \param aServerName Name of the server to connect to. |
93 @return true if connected, false if not |
92 \return true if connected, false if not. |
94 */ |
93 */ |
95 bool CServiceSymbianIPC::connect(const QString& aServerName) |
94 bool CServiceSymbianIPC::connect(const QString& aServerName) |
96 { |
95 { |
97 XQSERVICE_DEBUG_PRINT("CServiceSymbianIPC::connect"); |
96 XQSERVICE_DEBUG_PRINT("CServiceSymbianIPC::connect"); |
98 // Version informaton |
97 // Version informaton |
99 TVersion version(KServerMajorVersionNumber, |
98 TVersion version(KServerMajorVersionNumber, |
104 |
103 |
105 return (err == KErrNone); |
104 return (err == KErrNone); |
106 } |
105 } |
107 |
106 |
108 /*! |
107 /*! |
109 Disconnect from the server |
108 Disconnect from the server. |
110 */ |
109 */ |
111 void CServiceSymbianIPC::disconnect() |
110 void CServiceSymbianIPC::disconnect() |
112 { |
111 { |
113 XQSERVICE_DEBUG_PRINT("CServiceSymbianIPC::disconnect"); |
112 XQSERVICE_DEBUG_PRINT("CServiceSymbianIPC::disconnect"); |
114 Cancel(); |
113 Cancel(); |
115 iSession.Close(); |
114 iSession.Close(); |
116 } |
115 } |
117 |
116 |
118 /*! |
117 /*! |
119 Starts the service |
118 Starts the service. |
120 @param aServerName server name |
119 \param aServerName Server name. |
121 @param aExeName server executable name |
120 \param aExeName Server executable name. |
122 */ |
121 \return true if successful. |
|
122 */ |
123 bool CServiceSymbianIPC::startServer(const QString& /*aServerName*/, |
123 bool CServiceSymbianIPC::startServer(const QString& /*aServerName*/, |
124 const QString& aExeName, |
124 const QString& aExeName, |
125 quint64& /*processId*/, |
125 quint64& /*processId*/, |
126 int /*options*/) |
126 int /*options*/) |
127 { |
127 { |
130 TInt err = iSession.StartServer(serverName); |
130 TInt err = iSession.StartServer(serverName); |
131 return (err == KErrNone); |
131 return (err == KErrNone); |
132 } |
132 } |
133 |
133 |
134 /*! |
134 /*! |
135 Send a request synchronously |
135 Send a request synchronously. |
136 @param aRequestType type of request to send to the server |
136 \param aRequestType Type of request to send to the server. |
137 @param aData data to send to the server |
137 \param aData Data to send to the server. |
138 */ |
138 \return true if successful. |
|
139 */ |
139 bool CServiceSymbianIPC::sendSync(const QString& aRequestType, |
140 bool CServiceSymbianIPC::sendSync(const QString& aRequestType, |
140 const QByteArray& aData) |
141 const QByteArray& aData) |
141 { |
142 { |
142 XQSERVICE_DEBUG_PRINT("CServiceSymbianIPC::sendSync"); |
143 XQSERVICE_DEBUG_PRINT("CServiceSymbianIPC::sendSync"); |
143 // Convert from QString to TPtr |
144 // Convert from QString to TPtr |
168 XQSERVICE_DEBUG_PRINT("CServiceSymbianIPC::sendSync status%d", err); |
169 XQSERVICE_DEBUG_PRINT("CServiceSymbianIPC::sendSync status%d", err); |
169 return (err == KErrNone); |
170 return (err == KErrNone); |
170 } |
171 } |
171 |
172 |
172 |
173 |
173 /* |
174 /*! |
174 * read sync |
175 Read sync. |
|
176 \return Result of the read. |
175 */ |
177 */ |
176 QByteArray CServiceSymbianIPC::readAll() |
178 QByteArray CServiceSymbianIPC::readAll() |
177 { |
179 { |
178 // this is sync operation |
180 // this is sync operation |
179 |
181 |
216 } |
218 } |
217 |
219 |
218 |
220 |
219 |
221 |
220 /*! |
222 /*! |
221 Send a request asynchronously |
223 Send a request asynchronously. |
222 @param aRequestType type of request to send to the server |
224 \param aRequestType Type of request to send to the server. |
223 @param aData data to send to the server |
225 \param aData Data to send to the server. |
224 */ |
226 */ |
225 void CServiceSymbianIPC::sendAsync(const QString& aRequestType, |
227 void CServiceSymbianIPC::sendAsync(const QString& aRequestType, |
226 const QByteArray& aData) |
228 const QByteArray& aData) |
227 { |
229 { |
228 XQSERVICE_DEBUG_PRINT("CServiceSymbianIPC::sendAsync"); |
230 XQSERVICE_DEBUG_PRINT("CServiceSymbianIPC::sendAsync"); |
229 delete iRequestData; |
231 delete iRequestData; |
253 |
255 |
254 iSession.SendReceive(cmd, args, iStatus); |
256 iSession.SendReceive(cmd, args, iStatus); |
255 iState = ESend; |
257 iState = ESend; |
256 SetActive(); |
258 SetActive(); |
257 } |
259 } |
258 /* |
260 /*! |
259 * read async |
261 Read async. |
260 */ |
262 \param aArray Array where result will be put. |
|
263 */ |
261 void CServiceSymbianIPC::readAll(QByteArray& aArray) |
264 void CServiceSymbianIPC::readAll(QByteArray& aArray) |
262 { |
265 { |
263 XQSERVICE_DEBUG_PRINT("CServiceSymbianIPC::readAll"); |
266 XQSERVICE_DEBUG_PRINT("CServiceSymbianIPC::readAll"); |
264 |
267 |
265 // this is async operation |
268 // this is async operation |
272 } |
275 } |
273 |
276 |
274 } |
277 } |
275 |
278 |
276 /*! |
279 /*! |
277 Reads all data pending in the buffer, leaves if an error occured |
280 Reads all data pending in the buffer, leaves if an error occured. |
278 @return QByteArray containing the result data |
281 \param aArray QByteArray containing the result data. |
279 */ |
282 */ |
280 void CServiceSymbianIPC::doReadAllL(QByteArray& aArray) |
283 void CServiceSymbianIPC::doReadAllL(QByteArray& aArray) |
281 { |
284 { |
282 XQSERVICE_DEBUG_PRINT("CServiceSymbianIPC::doReadAllL"); |
285 XQSERVICE_DEBUG_PRINT("CServiceSymbianIPC::doReadAllL"); |
283 //shouldn't be active when this is called |
286 //shouldn't be active when this is called |
284 if ( IsActive() ) |
287 if ( IsActive() ) |
296 SetActive(); |
299 SetActive(); |
297 } |
300 } |
298 |
301 |
299 |
302 |
300 /*! |
303 /*! |
301 Maps error codes from Symbian error codes to Service IPC error codes |
304 Maps error codes from Symbian error codes to Service IPC error codes. |
302 @param aError Symbian error code |
305 \param aError Symbian error code. |
303 @return mapped error code |
306 \return Mapped error code. |
304 */ |
307 */ |
305 int CServiceSymbianIPC::doMapErrors(TInt aError) |
308 int CServiceSymbianIPC::doMapErrors(TInt aError) |
306 { |
309 { |
307 XQSERVICE_DEBUG_PRINT("CServiceSymbianIPC::doMapErrors"); |
310 XQSERVICE_DEBUG_PRINT("CServiceSymbianIPC::doMapErrors"); |
308 int error(ERROR_NoError); |
311 int error(ERROR_NoError); |
309 switch (aError) { |
312 switch (aError) { |
337 } |
340 } |
338 } |
341 } |
339 return error; |
342 return error; |
340 } |
343 } |
341 /*! |
344 /*! |
342 Waits until data is available for reading |
345 Waits until data is available for reading |
343 @return bool always true, no need to wait |
346 \return bool Always true, no need to wait |
344 */ |
347 */ |
345 bool CServiceSymbianIPC::waitForRead() |
348 bool CServiceSymbianIPC::waitForRead() |
346 { |
349 { |
347 XQSERVICE_DEBUG_PRINT("CServiceSymbianIPC::waitForRead"); |
350 XQSERVICE_DEBUG_PRINT("CServiceSymbianIPC::waitForRead"); |
348 // Symbian Client-server is blocking, so no need to wait for read |
351 // Symbian Client-server is blocking, so no need to wait for read |
349 return true; |
352 return true; |
350 } |
353 } |
351 |
354 |
352 /*! |
355 /*! |
353 Active object callback |
356 Active object callback. |
354 */ |
357 */ |
355 TInt CServiceSymbianIPC::RunError(TInt err) |
358 TInt CServiceSymbianIPC::RunError(TInt err) |
356 { |
359 { |
357 XQSERVICE_DEBUG_PRINT("CServiceSymbianIPC::error"); |
360 XQSERVICE_DEBUG_PRINT("CServiceSymbianIPC::error"); |
358 emitError(doMapErrors(err)); |
361 emitError(doMapErrors(err)); |
359 return KErrNone; |
362 return KErrNone; |
360 } |
363 } |
361 |
364 |
|
365 /*! |
|
366 Active object RunL() function. |
|
367 */ |
362 void CServiceSymbianIPC::RunL() |
368 void CServiceSymbianIPC::RunL() |
363 { |
369 { |
364 XQSERVICE_DEBUG_PRINT("CServiceSymbianIPC::RunL"); |
370 XQSERVICE_DEBUG_PRINT("CServiceSymbianIPC::RunL"); |
365 TInt err = iStatus.Int(); |
371 TInt err = iStatus.Int(); |
366 User::LeaveIfError(err); |
372 User::LeaveIfError(err); |