64 return key; |
69 return key; |
65 } |
70 } |
66 |
71 |
67 return (-1); |
72 return (-1); |
68 } |
73 } |
|
74 |
69 TInt SmfServerSymbian::removeFromSessionMap(SmfServerSymbianSession* aSession,RMessage2& aMsg) |
75 TInt SmfServerSymbian::removeFromSessionMap(SmfServerSymbianSession* aSession,RMessage2& aMsg) |
70 { |
76 { |
|
77 //To be implemented |
71 Q_UNUSED(aSession) |
78 Q_UNUSED(aSession) |
72 Q_UNUSED(aMsg) |
79 Q_UNUSED(aMsg) |
73 //To be implemented |
|
74 return 0; |
80 return 0; |
75 } |
81 } |
76 |
82 |
77 //TODO - change this to a macro using qdebug to avoid file opening and closing |
83 |
78 /*void SmfServerSymbian::writeLog(QString log) const |
|
79 { |
|
80 #ifdef WRITE_LOG |
|
81 QFile file("c:\\data\\SmfServerLogs.txt"); |
|
82 if (!file.open(QIODevice::Append | QIODevice::Text)) |
|
83 return; |
|
84 QTextStream out(&file); |
|
85 out << log << "\n"; |
|
86 file.close(); |
|
87 #else |
|
88 Q_UNUSED(log) |
|
89 #endif |
|
90 }*/ |
|
91 SmfServerSymbian::~SmfServerSymbian() |
|
92 { |
|
93 |
|
94 } |
|
95 SmfServer* SmfServerSymbian::wrapper() |
84 SmfServer* SmfServerSymbian::wrapper() |
96 { |
85 { |
97 return iWrapper; |
86 return iWrapper; |
98 } |
87 } |
|
88 |
99 CSession2* SmfServerSymbian::NewSessionL(const TVersion& aVersion, const RMessage2& /*aMessage*/) const |
89 CSession2* SmfServerSymbian::NewSessionL(const TVersion& aVersion, const RMessage2& /*aMessage*/) const |
100 { |
90 { |
|
91 qDebug()<<"Inside SmfServerSymbian::NewSessionL()"; |
|
92 |
101 Q_UNUSED(aVersion) |
93 Q_UNUSED(aVersion) |
102 // Check that the version is OK |
94 // Check that the version is OK |
103 // TVersion v( 0, 1, 0 ); |
95 // TVersion v( 0, 1, 0 ); |
104 // if (!User::QueryVersionSupported( v, aVersion )) |
96 // if (!User::QueryVersionSupported( v, aVersion )) |
105 // User::Leave( KErrNotSupported ); |
97 // User::Leave( KErrNotSupported ); |
|
98 |
106 // Create the session. |
99 // Create the session. |
107 QString log("New session created"); |
100 qDebug()<<"New session created"; |
108 qDebug()<<(log); |
|
109 return new (ELeave) SmfServerSymbianSession( const_cast<SmfServerSymbian*>(this) ); |
101 return new (ELeave) SmfServerSymbianSession( const_cast<SmfServerSymbian*>(this) ); |
110 } |
102 } |
|
103 |
111 SmfServerSymbianSession* SmfServerSymbian::findSession(TInt id) |
104 SmfServerSymbianSession* SmfServerSymbian::findSession(TInt id) |
112 { |
105 { |
113 qDebug()<<("SmfServerSymbian::findSession"); |
106 qDebug()<<"Inside SmfServerSymbian::findSession()"; |
114 CSessionStruct* sessionStruct = iMap.Find(id); |
107 CSessionStruct* sessionStruct = iMap.Find(id); |
115 if(sessionStruct) |
108 if(sessionStruct) |
116 { |
109 { |
117 qDebug()<<("Session id found"); |
110 qDebug()<<"Session id found"; |
118 return sessionStruct->iSession; |
111 return sessionStruct->iSession; |
119 } |
112 } |
120 else |
113 else |
121 { |
114 { |
122 qDebug()<<("Session id not found"); |
115 qDebug()<<"Session id not found"; |
123 return NULL; |
116 return NULL; |
124 } |
117 } |
125 } |
118 } |
|
119 |
126 TInt SmfServerSymbian::findAndServiceclient(TInt requestID,QByteArray* parsedData,SmfError error) |
120 TInt SmfServerSymbian::findAndServiceclient(TInt requestID,QByteArray* parsedData,SmfError error) |
127 { |
121 { |
128 qDebug()<<("SmfServerSymbian::findAndServiceclient"); |
122 qDebug()<<"Inside SmfServerSymbian::findAndServiceclient()"; |
129 SmfServerSymbianSession* sessionToservice = findSession(requestID); |
123 SmfServerSymbianSession* sessionToservice = findSession(requestID); |
130 if(sessionToservice) |
124 if(sessionToservice) |
131 { |
125 { |
132 sessionToservice->resultsAvailable(parsedData,error); |
126 sessionToservice->resultsAvailable(parsedData,error); |
133 } |
127 } |
134 return 0; |
128 return 0; |
135 } |
129 } |
|
130 |
|
131 |
|
132 |
136 SmfServerSymbianSession::SmfServerSymbianSession(SmfServerSymbian* aServer): |
133 SmfServerSymbianSession::SmfServerSymbianSession(SmfServerSymbian* aServer): |
137 iServer(aServer),iPtrToBuf(NULL,0) , |
134 iServer(aServer),iPtrToBuf(NULL,0) , |
138 iIntfNmaeSymbian(NULL,0), iProviderSymbian(NULL,0), |
135 iIntfNameSymbian8(NULL,0), iProviderSymbian8(NULL,0), |
139 iIntfNameSymbian16(NULL,0) ,iXtraDataPtr(NULL,0), |
136 iIntfNameSymbian(NULL,0) ,iXtraDataPtr8(NULL,0), |
140 iPtrToDataForClient(NULL,0) ,iPtrDataForDSM(NULL,0),iPtrDataFromDSM(NULL,0) |
137 iPtrToDataForClient(NULL,0) ,iPtr8DataForDSM(NULL,0),iPtr8DataFromDSM(NULL,0) |
141 { |
138 { |
|
139 qDebug()<<"Inside SmfServerSymbianSession::SmfServerSymbianSession()"; |
142 iServer->iSessionCount++; |
140 iServer->iSessionCount++; |
143 } |
141 } |
|
142 |
144 SmfServerSymbianSession::~SmfServerSymbianSession() |
143 SmfServerSymbianSession::~SmfServerSymbianSession() |
145 { |
144 { |
|
145 qDebug()<<"Inside SmfServerSymbianSession::~SmfServerSymbianSession()"; |
146 //cleanup of client resources |
146 //cleanup of client resources |
147 iServer->iSessionCount--; |
147 iServer->iSessionCount--; |
148 } |
148 } |
149 |
149 |
150 |
150 void SmfServerSymbianSession::clientAuthorizationFinished(bool success) |
151 void SmfServerSymbianSession::clientathorizationFinished(bool success) |
151 { |
152 { |
152 qDebug()<<"Inside SmfServerSymbianSession::clientAuthorizationFinished() = "<<success; |
|
153 |
153 //Client authorization failed |
154 //Client authorization failed |
154 if(!success) |
155 if(!success) |
155 { |
156 { |
156 //TODO:- Should use smf wide error instead |
157 //TODO:- Should use smf wide error instead |
157 iMessage.Complete(KErrPermissionDenied); |
158 iMessage.Complete(KErrPermissionDenied); |
218 *so it seems PM needs to provide two overloaded getPlugins API But for every client intf instanciation |
217 *so it seems PM needs to provide two overloaded getPlugins API But for every client intf instanciation |
219 *we would execute the same things twice. |
218 *we would execute the same things twice. |
220 *TODO:- to be changed after GetServices returns SmfProvider+pluginID |
219 *TODO:- to be changed after GetServices returns SmfProvider+pluginID |
221 * |
220 * |
222 */ |
221 */ |
223 if(iLastRequest == SmfGetService) |
222 if( (SmfGetService == iLastRequest) || |
224 { |
223 (SmfPostGetMaxCharsInPost == iLastRequest) || |
225 HandleGetService(aMessage); |
224 (SmfPostGetMaxItems == iLastRequest) || |
|
225 (SmfPostGetSupportedFormats == iLastRequest)|| |
|
226 (SmfPostGetAppearanceSupport == iLastRequest) ) |
|
227 |
|
228 { |
|
229 HandleSyncServiceL(aMessage); |
226 } |
230 } |
227 else if(iLastRequest == SmfRelationCreate || |
231 else if(iLastRequest == SmfRelationCreate || |
228 iLastRequest == SmfRelationAssociate || |
232 iLastRequest == SmfRelationAssociate || |
229 iLastRequest == SmfRelationSearchById || |
233 iLastRequest == SmfRelationSearchById || |
230 iLastRequest == SmfRelationSearchByContact || |
234 iLastRequest == SmfRelationSearchByContact || |
231 iLastRequest == SmfRelationCount || |
235 iLastRequest == SmfRelationCount || |
232 iLastRequest == SmfRelationGet || |
236 iLastRequest == SmfRelationGet || |
233 iLastRequest == SmfRelationGetAll || |
237 iLastRequest == SmfRelationGetAll || |
234 iLastRequest == SmfRelationGetAllRelations |
238 iLastRequest == SmfRelationGetAllRelations || |
|
239 iLastRequest == SmfRelationDeleteRelation |
235 ) |
240 ) |
236 { |
241 { |
237 HandleDSMServiceL(aMessage); |
242 HandleDSMServiceL(aMessage); |
238 } |
243 } |
239 else |
244 else |
240 { |
245 { |
241 HandleCommonServiceL(aMessage); |
246 HandleCommonServiceL(aMessage); |
242 } |
247 } |
243 } |
248 } |
|
249 |
244 void SmfServerSymbianSession::HandleDSMServiceL(const RMessage2 & aMessage) |
250 void SmfServerSymbianSession::HandleDSMServiceL(const RMessage2 & aMessage) |
245 { |
251 { |
|
252 qDebug()<<"Inside SmfServerSymbianSession::HandleDSMServiceL()"; |
246 //TODO:-If DSM takes care of deserialization and formation of User and social |
253 //TODO:-If DSM takes care of deserialization and formation of User and social |
247 //profile from the params then switch case can be removed |
254 //profile from the params then switch case can be removed |
248 if(iDataForDSM) |
255 if(iData8ForDSM) |
249 { |
256 { |
250 delete iDataForDSM; |
257 delete iData8ForDSM; |
251 iDataForDSM = NULL; |
258 iData8ForDSM = NULL; |
252 } |
259 } |
253 |
260 |
254 switch(iLastRequest) |
261 switch(iLastRequest) |
255 { |
262 { |
256 case SmfRelationCreate: |
263 case SmfRelationCreate: |
257 { |
264 { |
258 iDataForDSM = HBufC8::New(maxSmfRelationIdSize); |
265 iData8ForDSM = HBufC8::New(maxSmfRelationIdSize); |
259 iPtrDataForDSM.Set(iDataForDSM->Des()); |
266 iPtr8DataForDSM.Set(iData8ForDSM->Des()); |
260 TInt readerr0 = aMessage.Read(0,iPtrDataForDSM); |
267 TInt readerr0 = aMessage.Read(0,iPtr8DataForDSM); |
261 |
|
262 } |
268 } |
263 break; |
269 break; |
264 case SmfRelationAssociate: |
270 case SmfRelationAssociate: |
265 { |
271 { |
266 int maxAlloc = 100; |
272 int maxAlloc = 100; |
267 iDataForDSM = HBufC8::New(maxAlloc); |
273 iData8ForDSM = HBufC8::New(maxAlloc); |
268 iPtrDataForDSM.Set(iDataForDSM->Des()); |
274 iPtr8DataForDSM.Set(iData8ForDSM->Des()); |
269 TInt readerr0 = aMessage.Read(0,iPtrDataForDSM); |
275 TInt readerr0 = aMessage.Read(0,iPtr8DataForDSM); |
270 } |
276 } |
271 break; |
277 break; |
|
278 case SmfRelationRemove: |
|
279 { |
|
280 iData8ForDSM = HBufC8::New(100); |
|
281 iPtr8DataForDSM.Set(iData8ForDSM->Des()); |
|
282 TInt readerr0 = aMessage.Read(0,iPtr8DataForDSM); |
|
283 break; |
|
284 } |
272 case SmfRelationSearchById: |
285 case SmfRelationSearchById: |
273 { |
286 { |
274 int maxAlloc = MaxSmfContactSize; |
287 int maxAlloc = MaxSmfContactSize; |
275 iDataForDSM = HBufC8::New(maxAlloc); |
288 iData8ForDSM = HBufC8::New(maxAlloc); |
276 iPtrDataForDSM.Set(iDataForDSM->Des()); |
289 iPtr8DataForDSM.Set(iData8ForDSM->Des()); |
277 TInt readerr0 = aMessage.Read(0,iPtrDataForDSM); |
290 TInt readerr0 = aMessage.Read(0,iPtr8DataForDSM); |
|
291 } |
|
292 break; |
|
293 case SmfRelationSearchByContact: |
|
294 { |
|
295 int maxAlloc = 500; // hard coded in relation manager |
|
296 iData8ForDSM = HBufC8::New(maxAlloc); |
|
297 iPtr8DataForDSM.Set(iData8ForDSM->Des()); |
|
298 TInt readerr0 = aMessage.Read(0,iPtr8DataForDSM); |
278 } |
299 } |
279 break; |
300 break; |
280 case SmfRelationCount: |
301 case SmfRelationCount: |
281 { |
302 { |
282 int maxAlloc = 100; |
303 int maxAlloc = 100; |
283 iDataForDSM = HBufC8::New(maxAlloc); |
304 iData8ForDSM = HBufC8::New(maxAlloc); |
284 iPtrDataForDSM.Set(iDataForDSM->Des()); |
305 iPtr8DataForDSM.Set(iData8ForDSM->Des()); |
285 TInt readerr0 = aMessage.Read(0,iPtrDataForDSM); |
306 TInt readerr0 = aMessage.Read(0,iPtr8DataForDSM); |
286 } |
307 } |
287 break; |
308 break; |
288 case SmfRelationGet: |
309 case SmfRelationGet: |
289 { |
310 { |
290 int maxAlloc = maxSmfRelationItemSize*maxRelationItems; |
311 int maxAlloc = maxSmfRelationItemSize*maxRelationItems; |
291 iDataForDSM = HBufC8::New(maxAlloc); |
312 iData8ForDSM = HBufC8::New(maxAlloc); |
292 iPtrDataForDSM.Set(iDataForDSM->Des()); |
313 iPtr8DataForDSM.Set(iData8ForDSM->Des()); |
293 TInt readerr0 = aMessage.Read(0,iPtrDataForDSM); |
314 TInt readerr0 = aMessage.Read(0,iPtr8DataForDSM); |
294 } |
315 } |
295 break; |
316 break; |
296 case SmfRelationGetAll: |
317 case SmfRelationGetAll: |
297 { |
318 { |
298 int maxAlloc = maxSmfRelationItemSize*maxRelationItems; |
319 int maxAlloc = maxSmfRelationItemSize*maxRelationItems; |
299 iDataForDSM = HBufC8::New(maxAlloc); |
320 iData8ForDSM = HBufC8::New(maxAlloc); |
300 iPtrDataForDSM.Set(iDataForDSM->Des()); |
321 iPtr8DataForDSM.Set(iData8ForDSM->Des()); |
301 TInt readerr0 = aMessage.Read(0,iPtrDataForDSM); |
322 TInt readerr0 = aMessage.Read(0,iPtr8DataForDSM); |
302 } |
323 } |
303 break; |
324 break; |
|
325 case SmfRelationGetAllRelations: |
|
326 { |
|
327 int maxAlloc = maxSmfRelationItemSize*maxRelationItems; |
|
328 iData8ForDSM = HBufC8::New(maxAlloc); |
|
329 iPtr8DataForDSM.Set(iData8ForDSM->Des()); |
|
330 TInt readerr0 = aMessage.Read(0,iPtr8DataForDSM); |
|
331 break; |
|
332 } |
|
333 case SmfRelationDeleteRelation: |
|
334 { |
|
335 int maxAlloc = 100; |
|
336 iData8ForDSM = HBufC8::New(maxAlloc); |
|
337 iPtr8DataForDSM.Set(iData8ForDSM->Des()); |
|
338 TInt readerr0 = aMessage.Read(0,iPtr8DataForDSM); |
|
339 break; |
|
340 } |
304 default: |
341 default: |
305 break; |
342 break; |
306 } |
343 } |
307 //Convert into QByteArray |
344 //Convert into QByteArray |
308 QByteArray qtdataForDSM(reinterpret_cast<const char*>(iPtrDataForDSM.Ptr()),iPtrDataForDSM.Length()) ; |
345 QByteArray qtdataForDSM(reinterpret_cast<const char*>(iPtr8DataForDSM.Ptr()),iPtr8DataForDSM.Length()) ; |
309 QByteArray qtdataFromDSM; |
346 QByteArray qtdataFromDSM; |
310 SmfRequestTypeID opcode = (SmfRequestTypeID)iLastRequest; |
347 SmfRequestTypeID opcode = (SmfRequestTypeID)iLastRequest; |
311 SmfError dsmErr = iServer->wrapper()->sendToDSM(qtdataForDSM,opcode,qtdataFromDSM); |
348 SmfError dsmErr = iServer->wrapper()->sendToDSM(qtdataForDSM,opcode,qtdataFromDSM); |
312 if(dsmErr == SmfNoError) |
349 if(dsmErr == SmfNoError) |
313 { |
350 { |
314 if(qtdataFromDSM.size()) |
351 if(qtdataFromDSM.size()) |
315 { |
352 { |
316 if(iDataFromDSM) |
353 if(iData8FromDSM) |
317 { |
354 { |
318 delete iDataFromDSM; |
355 delete iData8FromDSM; |
319 iDataFromDSM = NULL; |
356 iData8FromDSM = NULL; |
320 } |
357 } |
321 iDataFromDSM = HBufC8::NewL(qtdataFromDSM.size()); |
358 iData8FromDSM = HBufC8::NewL(qtdataFromDSM.size()); |
322 iPtrDataFromDSM.Set(iDataFromDSM->Des()); |
359 iPtr8DataFromDSM.Set(iData8FromDSM->Des()); |
323 iPtrDataFromDSM.Copy(reinterpret_cast<const TText8*>(qtdataFromDSM.constData()),qtdataFromDSM.length()); |
360 iPtr8DataFromDSM.Copy(reinterpret_cast<const TText8*>(qtdataFromDSM.constData()),qtdataFromDSM.length()); |
324 TInt writeErr = aMessage.Write(1,iPtrDataFromDSM); |
361 TInt writeErr = aMessage.Write(1,iPtr8DataFromDSM); |
325 } |
362 } |
326 } |
363 } |
327 else |
364 else |
328 { |
365 { |
329 iDSMErr.Zero(); |
366 iDSMErr.Zero(); |
330 TInt errInt = dsmErr; |
367 TInt errInt = dsmErr; |
331 iDSMErr.AppendNum(errInt); |
368 iDSMErr.AppendNum(errInt); |
332 TInt writeErr = aMessage.Write(2,iDSMErr); |
369 TInt writeErr = aMessage.Write(2,iDSMErr); |
333 } |
370 } |
334 } |
371 } |
335 void SmfServerSymbianSession::HandleGetService(const RMessage2 & aMessage) |
372 |
336 { |
373 |
337 qDebug()<<("SmfServerSymbianSession::HandleGetService"); |
374 void SmfServerSymbianSession::HandleSyncServiceL(const RMessage2 & aMessage) |
338 |
375 { |
339 /** |
376 qDebug()<<"Inside SmfServerSymbianSession::HandleSyncServiceL()"; |
340 * Note:- client sends message for this opcode in the following format,- |
377 |
341 * Slot 0:- Interface Name buffer |
378 // Following is the data format sent by client |
342 * Slot 1:- Ptr to data block to be filled with SmfProvideList* serialized into QByteArray |
379 // 1. SmfProvider +PageInfo flag+ aPageNum + aPerPage (if pageinfoflag is set) + XtraInfo flag(size of xtra data) Serialized |
343 * Slot 2:- Max data size allocated in the client side |
380 // 2. Interface name as string ("org.symbian.smf.client.gallery") |
344 * TODO:- What if size of SmfProviderList to be passed to client is greater than |
381 // 3. Data pointer to be filled by serialized data(eg: QList<smfProvider>) |
345 * this size??? |
382 // 4. Input Data if xtra flag is set |
346 */ |
383 |
347 |
384 TInt intfNameSize = aMessage.GetDesLength(1); |
348 iInterfaceNametbuf.Zero(); |
385 if(iIntfNameBuf8) |
349 TInt readerr = aMessage.Read(0,iInterfaceNametbuf); |
386 { |
350 qDebug()<<(QString::number(readerr)); |
387 delete iIntfNameBuf8; |
351 QByteArray bytearray(reinterpret_cast<const char*>(iInterfaceNametbuf.Ptr()),iInterfaceNametbuf.Length()) ; |
388 iIntfNameBuf8 = NULL; |
352 QDataStream stream3(&bytearray,QIODevice::ReadOnly); |
389 } |
353 stream3>>iInterfaceID; |
390 iIntfNameBuf8 = HBufC8::NewL(intfNameSize); |
354 qDebug()<<("iInterfaceID="); |
391 iIntfNameSymbian8.Set(iIntfNameBuf8->Des()); |
355 qDebug()<<(iInterfaceID); |
392 |
|
393 //read it into iIntfNameSymbian8 |
|
394 aMessage.ReadL(1,iIntfNameSymbian8); |
|
395 |
|
396 QByteArray intfName(reinterpret_cast<const char*>(iIntfNameSymbian8.Ptr()),iIntfNameSymbian8.Length()) ; |
|
397 QDataStream readIntfNameStream(&intfName,QIODevice::ReadOnly); |
|
398 iInterfaceID.clear(); |
|
399 readIntfNameStream>>iInterfaceID; |
|
400 qDebug()<<"After de-serializing into iInterfaceID = "<<iInterfaceID; |
|
401 |
356 //Interface names are diff in client and plugin, replacing *.client.* with *.plugin.* |
402 //Interface names are diff in client and plugin, replacing *.client.* with *.plugin.* |
357 iInterfaceID.replace(QString(".client"),QString(".plugin")); |
403 iInterfaceID.replace(QString(".client"),QString(".plugin")); |
358 iServer->wrapper()->getPlugins(iInterfaceID,iPluginIDMap); |
404 |
|
405 // for get services |
|
406 if(SmfGetService == aMessage.Function()) |
|
407 HandleGetService(aMessage, iInterfaceID); |
|
408 |
|
409 // for other services |
|
410 else |
|
411 { |
|
412 // read provider info |
|
413 TInt providerSize = aMessage.GetDesLength(0); |
|
414 if(iProviderBuf8) |
|
415 { |
|
416 delete iProviderBuf8; |
|
417 iProviderBuf8 = NULL; |
|
418 } |
|
419 iProviderBuf8 = HBufC8::NewL(providerSize); |
|
420 iProviderSymbian8.Set(iProviderBuf8->Des()); |
|
421 |
|
422 //read it into iProviderSymbian8 |
|
423 aMessage.ReadL(0,iProviderSymbian8); |
|
424 |
|
425 //convert SmfProvider info from Symbian into bytearray |
|
426 QByteArray providerBufQt(reinterpret_cast<const char*>(iProviderSymbian8.Ptr()),iProviderSymbian8.Length()); |
|
427 qDebug()<<"providerBufQt.size = "<<providerBufQt.size(); |
|
428 |
|
429 //now de-serialize it |
|
430 QDataStream readProviderStream(&providerBufQt,QIODevice::ReadOnly); |
|
431 SmfProvider provider; |
|
432 readProviderStream>>provider; |
|
433 QByteArray XtraBufQt; |
|
434 readProviderStream>>XtraBufQt; |
|
435 |
|
436 //Get the plugin ID who matches provider info for a given intf name |
|
437 SmfPluginID pluginID = iServer->wrapper()->getPlugin(iInterfaceID,provider); |
|
438 qDebug()<<"pluginID from PM = "<<pluginID; |
|
439 |
|
440 //we need to check only this pluginID is authorized |
|
441 iPluginIDList.clear(); |
|
442 iPluginIDList<<pluginID; |
|
443 |
|
444 //iAuthList will contain pluginID for a successfull case |
|
445 iAuthList.clear(); |
|
446 iServer->wrapper()->getAuthorizedPlugins(iPluginIDList,iAuthList); |
|
447 |
|
448 if(iAuthList.contains(pluginID)) |
|
449 { |
|
450 //Plugin ID is authorised, service the request |
|
451 //Generate request id only if the plugin ID is authorised |
|
452 //request PM to get the data |
|
453 SmfRequestTypeID opcode = (SmfRequestTypeID)aMessage.Function(); |
|
454 resultData.clear(); |
|
455 SmfError err = iServer->wrapper()->sendToPluginManager(pluginID,iInterfaceID,opcode,XtraBufQt, resultData); |
|
456 |
|
457 if(resultData.size()) |
|
458 { |
|
459 TPtrC8 resultPtr8(reinterpret_cast<const TText8*>(resultData.constData()),resultData.length()); |
|
460 |
|
461 TInt writeErr = aMessage.Write(2,resultPtr8); |
|
462 qDebug()<<"aMessage.Write(2) = "<<writeErr; |
|
463 } |
|
464 else |
|
465 { |
|
466 iErrBuf.Zero(); |
|
467 iErrBuf.AppendNum(err); |
|
468 iMessage.Write(2,iErrBuf); |
|
469 } |
|
470 |
|
471 //signal completion |
|
472 aMessage.Complete(iLastRequest); |
|
473 } |
|
474 else |
|
475 { |
|
476 SmfError err = SmfNoAuthorizedPlugin; |
|
477 iErrBuf.Zero(); |
|
478 iErrBuf.AppendNum(err); |
|
479 iMessage.Write(2,iErrBuf); |
|
480 aMessage.Complete(iLastRequest); |
|
481 } |
|
482 } |
|
483 } |
|
484 |
|
485 void SmfServerSymbianSession::HandleGetService(const RMessage2 & aMessage, const SmfInterfaceID& aInterfaceID) |
|
486 { |
|
487 qDebug()<<"Inside SmfServerSymbianSession::HandleGetService()"; |
|
488 |
|
489 iServer->wrapper()->getPlugins(aInterfaceID,iPluginIDMap); |
|
490 |
359 //form the plugin id list from the map |
491 //form the plugin id list from the map |
360 QMapIterator<SmfPluginID, SmfProvider> iter(iPluginIDMap); |
|
361 iPluginIDList.clear(); |
492 iPluginIDList.clear(); |
362 while (iter.hasNext()) |
493 iPluginIDList = iPluginIDMap.uniqueKeys(); |
363 { |
494 |
364 iter.next(); |
|
365 iPluginIDList<<iter.key(); |
|
366 } |
|
367 //iAuthList will be filled by credential manager |
495 //iAuthList will be filled by credential manager |
368 iServer->wrapper()->getAuthorizedPlugins(iPluginIDList,iAuthList); |
496 iServer->wrapper()->getAuthorizedPlugins(iPluginIDList,iAuthList); |
369 |
497 |
370 //iPluginIDMap now contains SmfProvider info to return to the client |
498 // iPluginIDMap now contains SmfProvider info to return to the client |
371 //No need to add this to session map, as we are not requesting PM for this |
499 // No need to add this to session map, as we are not requesting PM for this |
372 QMap<SmfPluginID, SmfProvider> tempMap; |
500 QMap<SmfPluginID, SmfProvider> tempMap; |
373 QMapIterator<SmfPluginID, SmfProvider> i(iPluginIDMap); |
501 QMapIterator<SmfPluginID, SmfProvider> i(iPluginIDMap); |
374 while (i.hasNext()) |
502 while(i.hasNext()) |
375 { |
503 { |
376 i.next(); |
504 i.next(); |
377 if(iAuthList.contains(i.key())) |
505 if(iAuthList.contains(i.key())) |
378 { |
506 { |
379 tempMap.insert(i.key(),i.value()); |
507 tempMap.insert(i.key(),i.value()); |
380 } |
508 } |
381 } |
509 } |
382 //now tempMapcontains the info to be passed to the client |
510 //now tempMap contains the info to be passed to the client |
383 iPluginIDMap.clear(); |
511 iPluginIDMap.clear(); |
384 iPluginIDMap = tempMap; |
512 iPluginIDMap = tempMap; |
|
513 |
385 //form list of smfprovider from this map,- |
514 //form list of smfprovider from this map,- |
386 QList<SmfProvider> providerList; |
515 QList<SmfProvider> providerList = iPluginIDMap.values(); |
387 i = iPluginIDMap; |
516 |
388 while(i.hasNext()) |
|
389 { |
|
390 i.next(); |
|
391 providerList.append(i.value()); |
|
392 } |
|
393 //now serialize this list into bytearray |
517 //now serialize this list into bytearray |
394 byteArrayToClnt.clear(); |
518 resultData.clear(); |
395 QDataStream stream(&byteArrayToClnt,QIODevice::WriteOnly); |
519 QDataStream stream(&resultData,QIODevice::WriteOnly); |
396 stream<<providerList; |
520 stream<<providerList; |
397 qDebug()<<("providerList.count()="); |
521 qDebug()<<"providerList.count() = "<<providerList.count(); |
398 qDebug()<<(QString::number(providerList.count())); |
522 |
399 qDebug()<<("Before providerListSymbian"); |
523 qDebug()<<"Before providerListSymbian"; |
400 //now convert it into TPtr8 |
524 //now convert it into TPtr8 |
401 TPtrC8 providerListSymbian(reinterpret_cast<const TText8*>(byteArrayToClnt.constData()),byteArrayToClnt.length()); |
525 TPtrC8 providerListSymbian(reinterpret_cast<const TText8*>(resultData.constData()),resultData.length()); |
402 qDebug()<<("After providerListSymbian"); |
526 qDebug()<<"After providerListSymbian"; |
403 TInt writeErr = aMessage.Write(1,providerListSymbian); |
527 |
404 qDebug()<<("Write="); |
528 TInt writeErr = aMessage.Write(2,providerListSymbian); |
405 QString wrErr = QString::number(writeErr); |
529 qDebug()<<"aMessage.Write(2) = "<<writeErr; |
406 qDebug()<<(wrErr); |
530 |
407 //signal completion |
531 //signal completion |
408 TInt completion = SmfGetServiceComplete ; |
532 TInt completion = SmfGetService; |
409 aMessage.Complete(completion); |
533 aMessage.Complete(completion); |
410 } |
534 } |
|
535 |
411 void SmfServerSymbianSession::HandleCommonServiceL(const RMessage2& aMessage) |
536 void SmfServerSymbianSession::HandleCommonServiceL(const RMessage2& aMessage) |
412 { |
537 { |
|
538 qDebug()<<"Inside SmfServerSymbianSession::HandleCommonServiceL() = "<<aMessage.Function(); |
413 /** |
539 /** |
414 * Note:- client sends message in the following format,- |
540 * Note:- client sends message in the following format,- |
415 * Slot 0:- SmfProvider* serialized+Page info flag+page number+per page (if page info flag)+xtra info flag |
541 * Slot 0:- SmfProvider* serialized+Page info flag+page number+per page (if page info flag)+xtra info flag |
416 * Slot 1:- Interface Name buffer |
542 * Slot 1:- Interface Name buffer |
417 * Slot 2:- Ptr to data block to be filled |
543 * Slot 2:- Ptr to data block to be filled |
418 * Slot 3 :- Xtra Data if xtra data flag |
544 * Slot 3 :- Xtra Data if xtra data flag |
419 */ |
545 */ |
420 //TODO:- Use macro instead, shared betn client-server |
546 //TODO:- Use macro instead, shared betn client-server |
421 TInt maxProvidersize = 1000; |
|
422 TInt maxOtherInfoSize = 300; |
|
423 TInt providerSize = aMessage.GetDesLength(0); |
547 TInt providerSize = aMessage.GetDesLength(0); |
424 if(iProviderBuf) |
548 if(iProviderBuf8) |
425 { |
549 { |
426 delete iProviderBuf; |
550 delete iProviderBuf8; |
427 iProviderBuf = NULL; |
551 iProviderBuf8 = NULL; |
428 } |
552 } |
429 iProviderBuf = HBufC8::NewL(maxProvidersize + maxOtherInfoSize); |
553 iProviderBuf8 = HBufC8::NewL(providerSize); |
430 iProviderSymbian.Set(iProviderBuf->Des()); |
554 iProviderSymbian8.Set(iProviderBuf8->Des()); |
431 |
555 |
432 TInt intfNameSize = aMessage.GetDesLength(1); |
556 //read it into iProviderSymbian8 |
433 if(iIntfNameBuf) |
557 aMessage.ReadL(0,iProviderSymbian8); |
434 { |
|
435 delete iIntfNameBuf; |
|
436 iIntfNameBuf = NULL; |
|
437 } |
|
438 iIntfNameBuf = HBufC8::NewL(1000);//for safeside |
|
439 iIntfNmaeSymbian.Set(iIntfNameBuf->Des()); |
|
440 |
|
441 |
|
442 //read it into iProviderSymbian |
|
443 aMessage.ReadL(0,iProviderSymbian); |
|
444 //read it into iIntfNmaeSymbian |
|
445 aMessage.ReadL(1,iIntfNmaeSymbian); |
|
446 |
558 |
447 //convert SmfProvider info from Symbian into bytearray |
559 //convert SmfProvider info from Symbian into bytearray |
448 QByteArray providerBufQt(reinterpret_cast<const char*>(iProviderSymbian.Ptr()),iProviderSymbian.Length()); |
560 QByteArray providerBufQt(reinterpret_cast<const char*>(iProviderSymbian8.Ptr()),iProviderSymbian8.Length()); |
449 qDebug()<<("providerBufQt.size="); |
561 qDebug()<<"providerBufQt.size = "<<providerBufQt.size(); |
450 qDebug()<<(QString::number(providerBufQt.size())); |
|
451 |
562 |
452 //now de-serialize it |
563 //now de-serialize it |
453 QDataStream stream(&providerBufQt,QIODevice::ReadOnly); |
564 QDataStream stream(&providerBufQt,QIODevice::ReadOnly); |
454 SmfProvider provider; |
565 SmfProvider provider; |
455 stream>>provider ; |
566 stream>>provider; |
456 TInt pageinfoFlag=0; |
567 QByteArray XtraBufQt; |
457 stream>>pageinfoFlag; |
568 stream>>XtraBufQt; |
458 TInt pageNo=-1; |
569 qDebug()<<"XtraBufQt size = "<<XtraBufQt.size(); |
459 TInt perpage=-1; |
570 TInt intfNameSize = aMessage.GetDesLength(1); |
460 if(pageinfoFlag) |
571 if(iIntfNameBuf8) |
461 { |
572 { |
462 stream>>pageNo; |
573 delete iIntfNameBuf8; |
463 stream>>perpage; |
574 iIntfNameBuf8 = NULL; |
464 qDebug()<<("pageNo="); |
575 } |
465 qDebug()<<(QString::number(pageNo)); |
576 iIntfNameBuf8 = HBufC8::NewL(intfNameSize); |
466 qDebug()<<("perpage="); |
577 iIntfNameSymbian8.Set(iIntfNameBuf8->Des()); |
467 qDebug()<<(QString::number(perpage)); |
578 |
468 } |
579 //read it into iIntfNameSymbian8 |
469 TInt XtraInfoFlag = 0; |
580 aMessage.ReadL(1,iIntfNameSymbian8); |
470 TBool isXtraData = EFalse; |
581 qDebug()<<"iIntfNameSymbian8.Size = "<<iIntfNameSymbian8.Size(); |
471 stream>>XtraInfoFlag; |
582 |
472 if(XtraInfoFlag) |
583 QByteArray bytearray(reinterpret_cast<const char*>(iIntfNameSymbian8.Ptr()),iIntfNameSymbian8.Length()) ; |
473 { |
|
474 isXtraData = ETrue; |
|
475 qDebug()<<("XtraInfoFlag="); |
|
476 qDebug()<<(QString::number(XtraInfoFlag)); |
|
477 } |
|
478 qDebug()<<("iIntfNmaeSymbian.Size="); |
|
479 qDebug()<<(QString::number(iIntfNmaeSymbian.Size())); |
|
480 QByteArray bytearray(reinterpret_cast<const char*>(iIntfNmaeSymbian.Ptr()),iIntfNmaeSymbian.Length()) ; |
|
481 QDataStream intfNameStream(&bytearray,QIODevice::ReadOnly); |
584 QDataStream intfNameStream(&bytearray,QIODevice::ReadOnly); |
482 iInterfaceID.clear(); |
585 iInterfaceID.clear(); |
483 intfNameStream>>iInterfaceID; |
586 intfNameStream>>iInterfaceID; |
484 qDebug()<<("After de-serializing into iInterfaceID="); |
587 qDebug()<<"Interface Name = "<<iInterfaceID; |
485 qDebug()<<(iInterfaceID); |
588 |
486 //Interface names are diff in client and plugin, replacing *.client.* with *.plugin.* |
589 //Interface names are diff in client and plugin, replacing *.client.* with *.plugin.* |
487 iInterfaceID.replace(QString(".client"),QString(".plugin")); |
590 iInterfaceID.replace(QString(".client"),QString(".plugin")); |
|
591 |
488 //Get the plugin ID who matches provider info for a given intf name |
592 //Get the plugin ID who matches provider info for a given intf name |
489 SmfPluginID pluginID = iServer->wrapper()->getPlugin(iInterfaceID,provider); |
593 SmfPluginID pluginID = iServer->wrapper()->getPlugin(iInterfaceID,provider); |
490 qDebug()<<("pluginID from PM="); |
594 qDebug()<<"pluginID from PM = "<<pluginID; |
491 qDebug()<<(pluginID); |
595 |
|
596 //we need to check only this pluginID is authorized? |
492 iPluginIDList.clear(); |
597 iPluginIDList.clear(); |
493 //we need to check only this pluginID is authorized? |
|
494 iPluginIDList<<pluginID; |
598 iPluginIDList<<pluginID; |
|
599 |
495 //iAuthList will contain pluginID for a successfull case |
600 //iAuthList will contain pluginID for a successfull case |
496 iAuthList.clear(); |
601 iAuthList.clear(); |
497 iServer->wrapper()->getAuthorizedPlugins(iPluginIDList,iAuthList); |
602 iServer->wrapper()->getAuthorizedPlugins(iPluginIDList,iAuthList); |
498 if(iAuthList.contains(pluginID)) |
603 if(iAuthList.contains(pluginID)) |
499 { |
604 { |
500 //Plugin ID is authorised, service the request |
605 //Plugin ID is authorised, service the request |
501 //Gnerate request id only if the plugin ID is authorised |
606 //Gnerate request id only if the plugin ID is authorised |
502 TInt id = iServer->addToSessionMap(this,aMessage); |
607 TInt id = iServer->addToSessionMap(this,aMessage); |
503 //request PM to get the data |
608 //request PM to get the data |
504 SmfRequestTypeID opcode = (SmfRequestTypeID)iLastRequest; |
609 SmfRequestTypeID opcode = (SmfRequestTypeID)iLastRequest; |
505 if(isXtraData) |
610 |
506 { |
611 iServer->wrapper()->sendToPluginManager(id,pluginID,iInterfaceID,opcode,XtraBufQt); |
507 if(iXtraDataBuf) |
|
508 { |
|
509 delete iXtraDataBuf; |
|
510 iXtraDataBuf = NULL; |
|
511 } |
|
512 iXtraDataBuf = HBufC8::NewL(XtraInfoFlag); |
|
513 iXtraDataPtr.Set(iXtraDataBuf->Des()); |
|
514 QByteArray XtraBufQt(reinterpret_cast<const char*>(iXtraDataPtr.Ptr()),iXtraDataPtr.Length()); |
|
515 qDebug()<<("XtraBufQt size="); |
|
516 qDebug()<<(QString::number(XtraBufQt.size())); |
|
517 iServer->wrapper()->sendToPluginManager(id,pluginID,iInterfaceID,opcode,XtraBufQt); |
|
518 } |
|
519 else |
|
520 { |
|
521 iServer->wrapper()->sendToPluginManager(id,pluginID,iInterfaceID,opcode); |
|
522 } |
|
523 } |
612 } |
524 else |
613 else |
525 { |
614 { |
526 SmfError err = SmfNoAuthorizedPlugin; |
615 SmfError err = SmfNoAuthorizedPlugin; |
527 iErrBuf.Zero(); |
616 iErrBuf.Zero(); |
528 iErrBuf.AppendNum(err); |
617 iErrBuf.AppendNum(err); |
529 iMessage.Write(2,iErrBuf); |
618 iMessage.Write(2,iErrBuf); |
530 } |
619 } |
531 |
620 } |
532 |
|
533 } |
|