18
|
1 |
/**
|
|
2 |
* Copyright (c) 2010 Sasken Communication Technologies Ltd.
|
|
3 |
* All rights reserved.
|
|
4 |
* This component and the accompanying materials are made available
|
|
5 |
* under the terms of the "Eclipse Public License v1.0"
|
|
6 |
* which accompanies this distribution, and is available
|
|
7 |
* at the URL "http://www.eclipse.org/legal/epl-v10.html"
|
|
8 |
*
|
|
9 |
* Initial Contributors:
|
|
10 |
* Chandradeep Gandhi, Sasken Communication Technologies Ltd - Initial contribution
|
|
11 |
*
|
|
12 |
* Contributors:
|
|
13 |
* Manasij Roy, Nalina Hariharan
|
|
14 |
*/
|
|
15 |
|
|
16 |
|
|
17 |
#include <e32cmn.h>
|
|
18 |
#include <QtGlobal>
|
|
19 |
#include <e32svr.h>
|
|
20 |
#include <e32base.h>
|
|
21 |
#include <QByteArray>
|
|
22 |
#include <qdebug.h>
|
|
23 |
|
|
24 |
#include "smfclientsymbian.h"
|
|
25 |
|
|
26 |
// Function Declaration - For starting the server process
|
|
27 |
static TInt StartServerL();
|
|
28 |
static TInt CreateServerProcessL();
|
|
29 |
|
|
30 |
|
|
31 |
CSmfClientSymbian* CSmfClientSymbian::NewL(smfObserver* aObserver )
|
|
32 |
{
|
|
33 |
CSmfClientSymbian* self = NewLC( aObserver );
|
|
34 |
CleanupStack::Pop( self );
|
|
35 |
return( self ) ;
|
|
36 |
}
|
|
37 |
|
|
38 |
CSmfClientSymbian* CSmfClientSymbian::NewLC(smfObserver* aObserver )
|
|
39 |
{
|
|
40 |
CSmfClientSymbian* self = new ( ELeave ) CSmfClientSymbian( aObserver );
|
|
41 |
CleanupStack::PushL( self );
|
|
42 |
self->ConstructL();
|
|
43 |
return self;
|
|
44 |
}
|
|
45 |
|
|
46 |
CSmfClientSymbian::CSmfClientSymbian(smfObserver* aObserver)
|
25
|
47 |
: CActive( EPriorityStandard ),
|
|
48 |
iObserver(aObserver),
|
|
49 |
iDataPtr(NULL, 0, 0)
|
18
|
50 |
{
|
|
51 |
CActiveScheduler::Add(this);
|
|
52 |
}
|
|
53 |
|
|
54 |
void CSmfClientSymbian::ConstructL()
|
|
55 |
{
|
|
56 |
User::LeaveIfError(iSession.connectToServer());
|
|
57 |
}
|
|
58 |
|
|
59 |
CSmfClientSymbian::~CSmfClientSymbian()
|
|
60 |
{
|
|
61 |
qDebug()<<"~CSmfClientSymbian";
|
|
62 |
Cancel(); // Causes call to DoCancel()
|
|
63 |
iSession.Close();
|
|
64 |
}
|
|
65 |
|
|
66 |
void CSmfClientSymbian::DoCancel()
|
|
67 |
{
|
|
68 |
Cancel();
|
|
69 |
}
|
|
70 |
|
|
71 |
TInt CSmfClientSymbian::RunError(TInt aError)
|
|
72 |
{
|
|
73 |
qDebug()<<"Inside CSmfClientSymbian::RunError(), error = "<<aError;
|
|
74 |
return KErrNone;
|
|
75 |
}
|
|
76 |
|
|
77 |
void CSmfClientSymbian::RunL()
|
|
78 |
{
|
|
79 |
qDebug()<<"Inside CSmfClientSymbian::RunL()";
|
|
80 |
qDebug()<<"iStatus = "<<iStatus.Int();
|
|
81 |
|
|
82 |
switch ( iStatus.Int() )
|
|
83 |
{
|
|
84 |
case KErrCancel:
|
|
85 |
// The request was canceled
|
|
86 |
qDebug()<<"KErrCancel";
|
|
87 |
break ;
|
|
88 |
|
|
89 |
case KErrNotReady:
|
|
90 |
qDebug()<<"KErrNotReady";
|
|
91 |
break;
|
|
92 |
|
|
93 |
default:
|
|
94 |
{
|
|
95 |
qDebug()<<"RunL :- default";
|
|
96 |
//This contains error followed by actual data
|
|
97 |
QByteArray receivedData(reinterpret_cast<const char*>(iSession.iDataPtr8.Ptr()),iSession.iDataPtr8.Length());
|
|
98 |
qDebug()<<"receivedData size = "<<receivedData.size();
|
|
99 |
|
|
100 |
SmfError errVal;
|
|
101 |
int errInt;
|
|
102 |
QByteArray data;
|
|
103 |
QDataStream reader(&receivedData,QIODevice::ReadOnly);
|
|
104 |
reader>>errInt;
|
|
105 |
qDebug()<<"errInt = "<<errInt;
|
|
106 |
|
|
107 |
errVal = (SmfError)errInt;
|
|
108 |
reader>>data;
|
|
109 |
qDebug()<<"data size = "<<data.size();
|
|
110 |
|
|
111 |
SmfRequestTypeID opcode = (SmfRequestTypeID)iSession.getLastRequest();
|
|
112 |
if(iObserver)
|
|
113 |
{
|
|
114 |
iObserver->resultsAvailable(data,opcode,errVal);
|
|
115 |
}
|
|
116 |
}
|
|
117 |
break;
|
|
118 |
}
|
|
119 |
}
|
|
120 |
|
|
121 |
// Sync request for server other than getservices
|
|
122 |
QByteArray CSmfClientSymbian::sendRequest(QString aInterfaceName,
|
|
123 |
SmfRequestTypeID requestType,
|
|
124 |
TInt aMaxAllocation,
|
|
125 |
QByteArray& aSerializedData)
|
|
126 |
{
|
|
127 |
//Gets data synchronously from the server
|
|
128 |
TPtr8 symbianBuf(iSession.sendSyncRequest(aInterfaceName,requestType, aMaxAllocation, aSerializedData));
|
|
129 |
//convert this into bytearray
|
|
130 |
QByteArray receivedData(reinterpret_cast<const char*>(symbianBuf.Ptr()),symbianBuf.Length());
|
|
131 |
return receivedData;
|
|
132 |
}
|
|
133 |
|
|
134 |
QByteArray CSmfClientSymbian::sendSyncRequest(QString aInterfaceName,
|
|
135 |
SmfRequestTypeID requestType,TInt maxSize,
|
|
136 |
QByteArray& aSerializedData )
|
|
137 |
{
|
|
138 |
//This will be a synchronous request
|
|
139 |
//note session is opened in ctor and closed in dtor
|
|
140 |
qDebug()<<"Inside CSmfClientSymbian::sendSyncRequest()";
|
|
141 |
qDebug()<<"Interface name = "<<aInterfaceName;
|
|
142 |
|
|
143 |
//Gets data synchronously from the server
|
|
144 |
TPtr8 symbianBuf(iSession.sendSyncRequest(aInterfaceName,requestType,maxSize, aSerializedData));
|
|
145 |
//convert this into bytearray
|
|
146 |
QByteArray receivedData(reinterpret_cast<const char*>(symbianBuf.Ptr()),symbianBuf.Length());
|
|
147 |
return receivedData;
|
|
148 |
}
|
|
149 |
|
|
150 |
QByteArray CSmfClientSymbian::sendDSMSyncRequest(SmfRequestTypeID requestType,QByteArray& aSerializedData,SmfError& aErr,TInt maxSize)
|
|
151 |
{
|
|
152 |
Q_UNUSED(aErr)
|
|
153 |
|
|
154 |
qDebug()<<"CSmfClientSymbian::sendDSMSyncRequest for : "<<requestType;
|
|
155 |
SmfError err = SmfNoError;
|
|
156 |
//Gets data synchronously from the server
|
|
157 |
TPtr8 symbianBuf(iSession.sendDSMSyncRequest(requestType,aSerializedData,err,maxSize));
|
|
158 |
//convert this into bytearray
|
|
159 |
QByteArray receivedData(reinterpret_cast<const char*>(symbianBuf.Ptr()),symbianBuf.Length());
|
|
160 |
qDebug()<<"receivedData size="<<receivedData.size();
|
|
161 |
return receivedData;
|
|
162 |
}
|
|
163 |
|
|
164 |
TInt CSmfClientSymbian::sendRequest( QByteArray& aSerializedData, QString aInterfaceName,
|
|
165 |
SmfRequestTypeID requestType, TInt aMaxAllocation)
|
|
166 |
{
|
|
167 |
//RSessionBase objects sendreceive is called
|
|
168 |
iSession.sendAsyncRequest(aSerializedData,aInterfaceName,requestType,iStatus,aMaxAllocation);
|
|
169 |
SetActive();
|
|
170 |
|
|
171 |
return KErrNone;
|
|
172 |
}
|
|
173 |
|
|
174 |
|
|
175 |
|
|
176 |
|
|
177 |
RSmfClientSymbianSession::RSmfClientSymbianSession()
|
25
|
178 |
:iDataPtr8(NULL, 0, 0),
|
|
179 |
iDataPtr16(NULL,0),
|
|
180 |
iPtrProvider(NULL,0),
|
|
181 |
iPtrProvider8(NULL,0),
|
|
182 |
iIntfNamePtr(NULL,0),
|
|
183 |
iIntfNamePtr8(NULL,0),
|
|
184 |
iPtrToXtraInfo(NULL, 0),
|
|
185 |
iPtrToXtraInfo8(NULL,0),
|
18
|
186 |
iPtr8ToSlot0(NULL,0)
|
|
187 |
{
|
|
188 |
// No implementation required
|
|
189 |
}
|
|
190 |
|
|
191 |
TInt RSmfClientSymbianSession::connectToServer()
|
|
192 |
{
|
|
193 |
TInt error = ::StartServerL();
|
|
194 |
qDebug()<<"StartServerL = "<<error;
|
|
195 |
|
|
196 |
if ( KErrNone == error )
|
|
197 |
{
|
|
198 |
error = CreateSession(KSmfServerName,
|
|
199 |
Version(),
|
|
200 |
4 ); // 4 slots used
|
|
201 |
qDebug()<<"CreateSession = "<<error;
|
|
202 |
}
|
|
203 |
return error;
|
|
204 |
}
|
|
205 |
|
|
206 |
TPtr8 RSmfClientSymbianSession::sendSyncRequest(QByteArray& aSerializedData,
|
|
207 |
QString aInterfaceName, SmfRequestTypeID aRequestType, TInt maxSize)
|
|
208 |
{
|
|
209 |
iLastRequest = aRequestType;
|
|
210 |
/**
|
|
211 |
* The message body consists of.-
|
|
212 |
* 1. Serialized data to server SmfProvider+page information+extra information
|
|
213 |
* 2. Interface name as string ("org.symbian.smf.client.gallery")
|
|
214 |
* 3. Data pointer to be filled by serialized data(QList<smfProvider>)
|
|
215 |
* 4. Xtra information if any
|
|
216 |
*/
|
|
217 |
if(iProviderBuf8)
|
|
218 |
{
|
|
219 |
delete iProviderBuf8;
|
|
220 |
iProviderBuf8 = NULL;
|
|
221 |
}
|
|
222 |
iProviderBuf8 = HBufC8::NewL(aSerializedData.size());
|
|
223 |
iPtrProvider8.Set(iProviderBuf8->Des());
|
|
224 |
iPtrProvider8.Copy(reinterpret_cast<const TText8*>(aSerializedData.constData()),aSerializedData.length());
|
|
225 |
|
|
226 |
//convert the QByteArray into TPtr
|
|
227 |
TPtrC8 ptrSlot0(reinterpret_cast<const TText8*>(aSerializedData.constData()),aSerializedData.length());
|
|
228 |
qDebug()<<"ptrSlot0 size = "<<ptrSlot0.Size();
|
|
229 |
|
|
230 |
iInterfaceNamebyte.clear();
|
|
231 |
//Pass serialized QString for interface name
|
|
232 |
QDataStream intfNameStream(&iInterfaceNamebyte,QIODevice::WriteOnly);
|
|
233 |
intfNameStream<<aInterfaceName;
|
|
234 |
qDebug()<<"iInterfaceNamebyte size = "<<iInterfaceNamebyte.size();
|
|
235 |
if(iIntfNameBuffer8)
|
|
236 |
{
|
|
237 |
delete iIntfNameBuffer8;
|
|
238 |
iIntfNameBuffer8 = NULL;
|
|
239 |
}
|
|
240 |
iIntfNameBuffer8 = HBufC8::NewL(iInterfaceNamebyte.size());
|
|
241 |
iIntfNamePtr8.Set(iIntfNameBuffer8->Des());
|
|
242 |
iIntfNamePtr8.Copy(reinterpret_cast<const TText8*>(iInterfaceNamebyte.constData()),iInterfaceNamebyte.length());
|
|
243 |
qDebug()<<"After iIntfNamePtr8.Copy";
|
|
244 |
|
|
245 |
if(iBuffer8)
|
|
246 |
{
|
|
247 |
delete iBuffer8;
|
|
248 |
iBuffer8 = NULL;
|
|
249 |
}
|
|
250 |
iBuffer8 = HBufC8::NewL(maxSize);
|
|
251 |
iDataPtr8.Set(iBuffer8->Des());
|
|
252 |
qDebug()<<"After iDataPtr8.Set";
|
|
253 |
|
|
254 |
TIpcArgs args;
|
|
255 |
|
|
256 |
//filling the slots
|
|
257 |
args.Set(0, &iPtrProvider8);
|
|
258 |
args.Set(1, &iIntfNamePtr8);
|
|
259 |
args.Set(2, &iDataPtr8);
|
|
260 |
qDebug()<<"After setting 0,1,2 slots";
|
|
261 |
|
|
262 |
qDebug()<<"Before handle";
|
|
263 |
if (Handle())
|
|
264 |
{
|
|
265 |
qDebug()<<"Before sendreceive";
|
|
266 |
//synchronous request
|
|
267 |
TInt sendErr = SendReceive(aRequestType, args);
|
|
268 |
if(sendErr)
|
|
269 |
qDebug()<<"SendReceive error = "<<sendErr;
|
|
270 |
}
|
|
271 |
return iDataPtr8;
|
|
272 |
}
|
|
273 |
|
|
274 |
|
|
275 |
|
|
276 |
TPtr8 RSmfClientSymbianSession::sendSyncRequest(QString aInterfaceName,
|
|
277 |
SmfRequestTypeID aRequestType,
|
|
278 |
TInt maxSize,
|
|
279 |
QByteArray& aSerializedData)
|
|
280 |
{
|
|
281 |
qDebug()<<"Inside RSmfClientSymbianSession::sendSyncRequest()";
|
|
282 |
qDebug()<<"aInterfaceName = "<<aInterfaceName;
|
|
283 |
|
|
284 |
iLastRequest = aRequestType;
|
|
285 |
/**
|
|
286 |
* The message body consists of.-
|
|
287 |
* slot 0 = SmfProvider + argument flag + argument + etc
|
|
288 |
* slot 1 = Interface name serialized
|
|
289 |
* slot 2 = Data pointer to be filled by server
|
|
290 |
* slot 3 = not used now
|
|
291 |
*/
|
|
292 |
|
|
293 |
//Convert the interface name into TPtr
|
|
294 |
//lets pass serialized QString
|
|
295 |
iInterfaceNamebyte.clear();
|
|
296 |
QDataStream intfNameStream(&iInterfaceNamebyte,QIODevice::WriteOnly);
|
|
297 |
intfNameStream<<aInterfaceName;
|
|
298 |
qDebug()<<"iInterfaceNamebyte size = "<<iInterfaceNamebyte.size();
|
|
299 |
if(iIntfNameBuffer8)
|
|
300 |
{
|
|
301 |
delete iIntfNameBuffer8;
|
|
302 |
iIntfNameBuffer8 = NULL;
|
|
303 |
}
|
|
304 |
iIntfNameBuffer8 = HBufC8::NewL(iInterfaceNamebyte.size());
|
|
305 |
iIntfNamePtr8.Set(iIntfNameBuffer8->Des());
|
|
306 |
iIntfNamePtr8.Copy(reinterpret_cast<TUint8*>(iInterfaceNamebyte.data()),iInterfaceNamebyte.length());
|
25
|
307 |
qDebug()<<"iIntfNamePtr8 (1) size = "<<iIntfNamePtr8.Size();
|
18
|
308 |
|
|
309 |
if(iBuffer8)
|
|
310 |
{
|
|
311 |
delete iBuffer8;
|
|
312 |
iBuffer8 = NULL;
|
|
313 |
}
|
|
314 |
qDebug()<<"Allocated for output = "<<maxSize;
|
|
315 |
iBuffer8 = HBufC8::NewL(maxSize);
|
|
316 |
iDataPtr8.Set(iBuffer8->Des());
|
|
317 |
|
|
318 |
if(iProviderBuf8)
|
|
319 |
{
|
|
320 |
delete iProviderBuf8;
|
|
321 |
iProviderBuf8 = NULL;
|
|
322 |
}
|
|
323 |
iProviderBuf8 = HBufC8::NewL(aSerializedData.size());
|
|
324 |
iPtrProvider8.Set(iProviderBuf8->Des());
|
|
325 |
iPtrProvider8.Copy(reinterpret_cast<const TText8*>(aSerializedData.constData()),aSerializedData.length());
|
|
326 |
|
|
327 |
//convert the QByteArray into TPtr
|
|
328 |
TPtrC8 ptrSlot0(reinterpret_cast<const TText8*>(aSerializedData.constData()),aSerializedData.length());
|
|
329 |
qDebug()<<"ptrSlot0 size = "<<ptrSlot0.Size();
|
|
330 |
|
|
331 |
TIpcArgs args;
|
|
332 |
args.Set(0, &iPtrProvider8);
|
|
333 |
args.Set(1, &iIntfNamePtr8);
|
|
334 |
args.Set(2, &iDataPtr8);
|
|
335 |
|
|
336 |
qDebug()<<"Before handle";
|
|
337 |
if (Handle())
|
|
338 |
{
|
|
339 |
qDebug()<<"Before sendreceive";
|
|
340 |
TInt sendErr = SendReceive(aRequestType, args);
|
|
341 |
if(sendErr)
|
|
342 |
qDebug()<<"SendReceive error = "<<sendErr;
|
|
343 |
}
|
|
344 |
return iDataPtr8;
|
|
345 |
}
|
|
346 |
|
|
347 |
/**
|
|
348 |
* Sends sync DSM request to the Smf server
|
|
349 |
*/
|
|
350 |
TPtr8 RSmfClientSymbianSession::sendDSMSyncRequest(SmfRequestTypeID aRequestType,
|
25
|
351 |
QByteArray& aSerializedData, SmfError& aErr, TInt maxSize)
|
18
|
352 |
{
|
|
353 |
/**
|
|
354 |
* Slot 0:- Data to be passed to DSM
|
|
355 |
* Slot 1:- Data returned from DSM
|
|
356 |
* Slot 2:- Error
|
|
357 |
*/
|
|
358 |
qDebug()<<"Inside RSmfClientSymbianSession::sendDSMSyncRequest()";
|
|
359 |
iLastRequest = aRequestType;
|
|
360 |
if(iSlot0Buffer8)
|
|
361 |
{
|
|
362 |
delete iSlot0Buffer8;
|
|
363 |
iSlot0Buffer8 = NULL;
|
|
364 |
}
|
|
365 |
iSlot0Buffer8 = HBufC8::NewL(aSerializedData.size());
|
|
366 |
iPtr8ToSlot0.Set(iSlot0Buffer8->Des());
|
25
|
367 |
iPtr8ToSlot0.Copy(reinterpret_cast<const TText8*>(aSerializedData.constData()),aSerializedData.length());
|
18
|
368 |
|
|
369 |
if(iBuffer8)
|
|
370 |
{
|
|
371 |
delete iBuffer8;
|
|
372 |
iBuffer8 = NULL;
|
|
373 |
}
|
|
374 |
iBuffer8 = HBufC8::NewL(maxSize);
|
|
375 |
iDataPtr8.Set(iBuffer8->Des());
|
|
376 |
|
|
377 |
TIpcArgs args;
|
|
378 |
args.Set(0, &iPtr8ToSlot0);
|
|
379 |
args.Set(1, &iDataPtr8);
|
|
380 |
iDSMErr.Zero();
|
|
381 |
args.Set(2,&iDSMErr);
|
|
382 |
|
|
383 |
TInt sendErr = SendReceive(aRequestType,args);
|
|
384 |
qDebug()<<"DSM SendReceive = "<<sendErr;
|
|
385 |
TInt numIndex;
|
|
386 |
TLex iLex(iDSMErr);
|
|
387 |
|
|
388 |
iLex.Val(numIndex);
|
|
389 |
aErr = (SmfError)numIndex;
|
|
390 |
return iDataPtr8;
|
|
391 |
}
|
|
392 |
|
|
393 |
/**
|
|
394 |
* sendAsyncRequest()
|
|
395 |
* Calls SendReceive() after converting into symbian descriptors
|
|
396 |
*/
|
|
397 |
void RSmfClientSymbianSession::sendAsyncRequest(QByteArray& aSerializedData,
|
|
398 |
QString aInterfaceName,
|
|
399 |
SmfRequestTypeID aRequestType,
|
|
400 |
TRequestStatus& aStatus,
|
|
401 |
TInt aMaxAllocation )
|
|
402 |
{
|
|
403 |
/**
|
|
404 |
* The message body consists of.-
|
|
405 |
* slot 0 = SmfProvider + argument flag + argument + etc
|
|
406 |
* slot 1 = Interface name serialized
|
|
407 |
* slot 2 = Data pointer to be filled by server
|
|
408 |
* slot 3 = not used now
|
|
409 |
*/
|
|
410 |
qDebug()<<"Inside RSmfClientSymbianSession::sendAsyncRequest()";
|
|
411 |
qDebug()<<"iInterfaceName = "<<aInterfaceName;
|
|
412 |
iLastRequest = aRequestType;
|
|
413 |
|
|
414 |
if(iProviderBuf8)
|
|
415 |
{
|
|
416 |
delete iProviderBuf8;
|
|
417 |
iProviderBuf8 = NULL;
|
|
418 |
}
|
|
419 |
iProviderBuf8 = HBufC8::NewL(aSerializedData.size());
|
|
420 |
iPtrProvider8.Set(iProviderBuf8->Des());
|
|
421 |
iPtrProvider8.Copy(reinterpret_cast<const TText8*>(aSerializedData.constData()),aSerializedData.length());
|
|
422 |
|
|
423 |
//convert the QByteArray into TPtr
|
|
424 |
TPtrC8 ptrSlot0(reinterpret_cast<const TText8*>(aSerializedData.constData()),aSerializedData.length());
|
25
|
425 |
qDebug()<<"ptrSlot0 size = "<<iPtrProvider8.Size();
|
18
|
426 |
|
|
427 |
//Convert the interface name into TPtr
|
|
428 |
//Pass serialized QString for interface name
|
|
429 |
iInterfaceNamebyte.clear();
|
|
430 |
QDataStream intfNameStream(&iInterfaceNamebyte,QIODevice::WriteOnly);
|
|
431 |
intfNameStream<<aInterfaceName;
|
|
432 |
qDebug()<<"iInterfaceNamebyte size = "<<iInterfaceNamebyte.size();
|
|
433 |
if(iIntfNameBuffer8)
|
|
434 |
{
|
|
435 |
delete iIntfNameBuffer8;
|
|
436 |
iIntfNameBuffer8 = NULL;
|
|
437 |
}
|
|
438 |
iIntfNameBuffer8 = HBufC8::NewL(iInterfaceNamebyte.size());
|
|
439 |
iIntfNamePtr8.Set(iIntfNameBuffer8->Des());
|
|
440 |
iIntfNamePtr8.Copy(reinterpret_cast<const TText8*>(iInterfaceNamebyte.constData()),iInterfaceNamebyte.length());
|
25
|
441 |
qDebug()<<"ptrSlot1 size = "<<iIntfNamePtr8.Size();
|
18
|
442 |
|
|
443 |
if(iBuffer8)
|
|
444 |
{
|
|
445 |
delete iBuffer8;
|
|
446 |
iBuffer8 = NULL;
|
|
447 |
}
|
|
448 |
iBuffer8 = HBufC8::NewL(aMaxAllocation);
|
|
449 |
iDataPtr8.Set(iBuffer8->Des());
|
|
450 |
qDebug()<<"After iDataPtr.Set";
|
|
451 |
|
|
452 |
TIpcArgs args;
|
|
453 |
|
|
454 |
//filling the slots
|
|
455 |
args.Set(0, &iPtrProvider8);
|
|
456 |
args.Set(1, &iIntfNamePtr8);
|
|
457 |
args.Set(2, &iDataPtr8);
|
|
458 |
qDebug()<<"After setting 0,1,2 slots";
|
|
459 |
|
|
460 |
qDebug()<<"Before Handle()";
|
|
461 |
if (Handle())
|
|
462 |
{
|
|
463 |
qDebug()<<"Before sendreceive";
|
|
464 |
SendReceive(aRequestType, args, aStatus);
|
25
|
465 |
qDebug()<<"After sendreceive";
|
18
|
466 |
}
|
|
467 |
}
|
|
468 |
|
|
469 |
// -----------------------------------------------------------------------------
|
|
470 |
// CreateServerProcessL()
|
|
471 |
// Creates a server process
|
|
472 |
// -----------------------------------------------------------------------------
|
|
473 |
//
|
|
474 |
static TInt CreateServerProcessL()
|
|
475 |
{
|
|
476 |
TInt result;
|
|
477 |
TUid KSmfServerUID3 = { 0xE5027327 };
|
|
478 |
const TUidType serverUid( KNullUid, KNullUid, KSmfServerUID3 );
|
|
479 |
|
|
480 |
RProcess server;
|
|
481 |
|
|
482 |
result = server.Create( KSmfServerFilename, KNullDesC, serverUid );
|
25
|
483 |
qDebug()<<"server.Create() = "<<result;
|
18
|
484 |
if ( result != KErrNone )
|
|
485 |
{
|
|
486 |
return result;
|
|
487 |
}
|
|
488 |
|
|
489 |
server.Resume();
|
|
490 |
server.Close();
|
|
491 |
return KErrNone;
|
|
492 |
}
|
|
493 |
|
|
494 |
// -----------------------------------------------------------------------------
|
|
495 |
// StartServerL()
|
|
496 |
// Starts the server - Internally creates a server process
|
|
497 |
// -----------------------------------------------------------------------------
|
|
498 |
//
|
|
499 |
static TInt StartServerL()
|
|
500 |
{
|
|
501 |
TInt result;
|
|
502 |
|
|
503 |
TFindServer findSmfServer( KSmfServerFilename );
|
|
504 |
TFullName name;
|
|
505 |
|
|
506 |
result = findSmfServer.Next( name );
|
|
507 |
if ( result == KErrNone )
|
|
508 |
{
|
|
509 |
// Server already running
|
|
510 |
return KErrNone;
|
|
511 |
}
|
|
512 |
|
|
513 |
RSemaphore semaphore;
|
|
514 |
result = semaphore.CreateGlobal( KSmfServerSemaphoreName, 0 );
|
|
515 |
|
|
516 |
if ( result != KErrNone )
|
|
517 |
{
|
|
518 |
return result;
|
|
519 |
}
|
|
520 |
|
|
521 |
result = CreateServerProcessL();
|
|
522 |
qDebug()<<"CreateServerProcessL = "<<result;
|
|
523 |
|
|
524 |
if ( result != KErrNone )
|
|
525 |
{
|
|
526 |
return result;
|
|
527 |
}
|
|
528 |
|
|
529 |
semaphore.Wait();
|
|
530 |
semaphore.Close();
|
|
531 |
|
|
532 |
return KErrNone;
|
|
533 |
}
|