|
1 /* |
|
2 * Copyright (c) 2007 Nokia Corporation and/or its subsidiary(-ies). |
|
3 * All rights reserved. |
|
4 * This component and the accompanying materials are made available |
|
5 * under the terms of "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 * Nokia Corporation - initial contribution. |
|
11 * |
|
12 * Contributors: |
|
13 * |
|
14 * Description: LBT Sever Logic |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 // INCLUDE FILES |
|
20 #include <ecom.h> |
|
21 #include <e32base.h> |
|
22 #include <implementationproxy.h> |
|
23 #include <e32property.h> |
|
24 #include <lbtstatuspskeys.h> |
|
25 #include <lbttriggeringsystemsettings.h> |
|
26 #include <lbterrors.h> |
|
27 #include "lbtcontainertriggerfilter.h" |
|
28 #include "lbtserverlogic.h" |
|
29 #include "lbtserverconsts.h" |
|
30 #include "lbtcreatetriggeraooperation.h" |
|
31 #include "lbtstrategybase.h" |
|
32 #include "lbttriggerfirehandler.h" |
|
33 #include "lbtbackuprestorelistener.h" |
|
34 #include "lbtcontainer.h" |
|
35 #include "lbtglobal.h" |
|
36 #include "lbtstratergycontainer.h" |
|
37 #include "lbtlistaooperation.h" |
|
38 #include "lbtsettingsmanager.h" |
|
39 #include "lbtcontainertriggerentry.h" |
|
40 #include "lbttriggermodifyaooperation.h" |
|
41 #include "lbtnotificationmap.h" |
|
42 #include "lbttriggerchangeevent.h" |
|
43 #include "lbtcontainerupdatefilter.h" |
|
44 #include "lbttriggerfilterbyattribute.h" |
|
45 #include "lbtlogger.h" |
|
46 #include "lbtdeletesessiontriggers.h" |
|
47 #include "lbtappchangehandler.h" |
|
48 #include "lbtcleanuphandler.h" |
|
49 #include "lbtsimchangehandler.h" |
|
50 #include "lbtlogger.h" |
|
51 |
|
52 // ===================== LOCAL FUNCTIONS ===================== |
|
53 |
|
54 const TImplementationProxy ImplementationTable[] = |
|
55 { |
|
56 IMPLEMENTATION_PROXY_ENTRY( 0x1028312C, CLbtServerLogic::NewL ) |
|
57 }; |
|
58 |
|
59 EXPORT_C const TImplementationProxy* ImplementationGroupProxy( TInt& aTableCount ) |
|
60 { |
|
61 aTableCount = sizeof( ImplementationTable ) / sizeof( TImplementationProxy ); |
|
62 return ImplementationTable; |
|
63 } |
|
64 |
|
65 |
|
66 TInt OrderTriggerEntryBySid( |
|
67 const CLbtContainerTriggerEntry& aLhs, |
|
68 const CLbtContainerTriggerEntry& aRhs) |
|
69 { |
|
70 CLbtContainerTriggerEntry& lhs = const_cast<CLbtContainerTriggerEntry&>(aLhs); |
|
71 CLbtContainerTriggerEntry& rhs = const_cast<CLbtContainerTriggerEntry&>(aRhs); |
|
72 |
|
73 if(lhs.ExtendedTriggerInfo()->OwnerSid() < rhs.ExtendedTriggerInfo()->OwnerSid()) |
|
74 { |
|
75 return -1; |
|
76 } |
|
77 else if(lhs.ExtendedTriggerInfo()->OwnerSid() > rhs.ExtendedTriggerInfo()->OwnerSid()) |
|
78 { |
|
79 return 1; |
|
80 } |
|
81 else |
|
82 { |
|
83 return 0; |
|
84 } |
|
85 } |
|
86 |
|
87 // ===================== MEMBER FUNCTIONS ===================== |
|
88 |
|
89 // --------------------------------------------------------------------------- |
|
90 // CLbtServerLogic::NewL |
|
91 // Symbian Two - phase constructor |
|
92 // --------------------------------------------------------------------------- |
|
93 // |
|
94 CLbtServerLogic* CLbtServerLogic::NewL() |
|
95 { |
|
96 LBT_TRACE(KLbtLogVerbose|KLbtLogServerLogic,__FILE__, __LINE__, "Entering NewL" ); |
|
97 CLbtServerLogic* self = new ( ELeave ) CLbtServerLogic; |
|
98 CleanupStack::PushL( self ); |
|
99 self->ConstructL(); |
|
100 CleanupStack::Pop(); |
|
101 LBT_TRACE(KLbtLogVerbose|KLbtLogServerLogic,__FILE__, __LINE__, "Returning from NewL" ); |
|
102 return self; |
|
103 } |
|
104 |
|
105 // --------------------------------------------------------------------------- |
|
106 // CLbtServerLogic::~CLbtServerLogic |
|
107 // Destructor |
|
108 // --------------------------------------------------------------------------- |
|
109 // |
|
110 CLbtServerLogic::~CLbtServerLogic() |
|
111 { |
|
112 FUNC_ENTER("CLbtServerLogic::~CLbtServerLogic"); |
|
113 // Cancel all outstanding operations. |
|
114 CancelAllOperations(); |
|
115 |
|
116 delete iBackupRestoreListener; |
|
117 delete iStratergyContainer; |
|
118 delete iSettingsManager; |
|
119 delete iFireHandler; |
|
120 delete iAppChangeHandler; |
|
121 delete iNotificationMap; |
|
122 delete iCleanupHandler; |
|
123 delete iSimChangeHandler; |
|
124 iAOOArray.ResetAndDestroy(); |
|
125 iDeleteSessionTriggersArray.ResetAndDestroy(); |
|
126 CLbtContainer::Destroy(); |
|
127 iProperty.Close(); |
|
128 } |
|
129 |
|
130 // --------------------------------------------------------------------------- |
|
131 // CLbtServerLogic::CLbtServerLogic |
|
132 // --------------------------------------------------------------------------- |
|
133 // |
|
134 CLbtServerLogic::CLbtServerLogic() : iContainer(NULL) |
|
135 { |
|
136 } |
|
137 |
|
138 // --------------------------------------------------------------------------- |
|
139 // CLbtServerLogic::ServiceL |
|
140 // --------------------------------------------------------------------------- |
|
141 // |
|
142 void CLbtServerLogic::ServiceL(const RMessage2 &aMessage, TSubSessionType aType) |
|
143 { |
|
144 FUNC_ENTER("CLbtServerLogic::ServiceL"); |
|
145 LBT_TRACE(KLbtLogVerbose|KLbtLogServerLogic,__FILE__, __LINE__, "Received IPC function = %d client = %x", aMessage.Function(), aMessage.SecureId().iId ); |
|
146 // If backup or restore operation is in progress then return server busy |
|
147 if(iBackupRestoreListener->IsBackupRestoreOperationInProgress()) |
|
148 { |
|
149 LbtGlobal::RequestComplete(aMessage, KErrServerBusy); |
|
150 return; |
|
151 } |
|
152 |
|
153 /** |
|
154 * All IPC messages which requires notification will be |
|
155 * stored and serviced by server logic. Other messages will |
|
156 * be serviced by AOOperation objects |
|
157 */ |
|
158 switch(aMessage.Function()) |
|
159 { |
|
160 /** |
|
161 * The below are all notification requests. Hence insert the |
|
162 * message into the message array and notify the requestor |
|
163 * when the event occurs |
|
164 */ |
|
165 case ELbtNotifyTriggerChangeEvent: |
|
166 case ELbtNotifyTriggerFired: |
|
167 case ELbtNotifyNearestTriggerChange: |
|
168 case ELbtNotifyTriggeringSysSettingChange: |
|
169 case ELbtNotifyTriggeringSysStatusChange: |
|
170 { |
|
171 TInt retValue=ValidateChangeNotification(aMessage); |
|
172 |
|
173 if(retValue!=KErrNone) |
|
174 { |
|
175 // If validation failed then complete the request with the appropriate error code |
|
176 LbtGlobal::RequestComplete(aMessage, retValue); |
|
177 break; |
|
178 } |
|
179 InsertIntoNotificationMapL(aMessage, aType); |
|
180 break; |
|
181 } |
|
182 case ELbtCnclNotifyTriggerChangeEvent: |
|
183 { |
|
184 TInt retVal = RemoveFromNotificationMap(aMessage, ELbtNotifyTriggerChangeEvent); |
|
185 LbtGlobal::RequestComplete(aMessage, retVal); |
|
186 break; |
|
187 } |
|
188 case ELbtCnclNotifyTriggerFired: |
|
189 { |
|
190 TInt retVal = RemoveFromNotificationMap(aMessage, ELbtNotifyTriggerFired); |
|
191 LbtGlobal::RequestComplete(aMessage, retVal); |
|
192 break; |
|
193 } |
|
194 case ELbtCnclNotifyNearestTriggerChange: |
|
195 { |
|
196 TInt retVal = RemoveFromNotificationMap(aMessage, ELbtNotifyNearestTriggerChange); |
|
197 LbtGlobal::RequestComplete(aMessage, retVal); |
|
198 break; |
|
199 } |
|
200 case ELbtCnclNotifyTriggeringSysStatusChange: |
|
201 { |
|
202 TInt retVal = RemoveFromNotificationMap(aMessage, ELbtNotifyTriggeringSysStatusChange); |
|
203 LbtGlobal::RequestComplete(aMessage, retVal); |
|
204 break; |
|
205 } |
|
206 case ELbtCnclNotifyTriggeringSysSettingChange: |
|
207 { |
|
208 TInt retVal = RemoveFromNotificationMap(aMessage, ELbtNotifyTriggeringSysSettingChange); |
|
209 LbtGlobal::RequestComplete(aMessage, retVal); |
|
210 break; |
|
211 } |
|
212 case ELbtCreateTrigger: // create trigger |
|
213 { |
|
214 // Validate the IPC message and the trigger for create trigger |
|
215 TInt retVal = ValidateCreateTriggerMessage(aMessage); |
|
216 |
|
217 if( retVal != KErrNone ) |
|
218 { |
|
219 // If validation failed then complete the request with the appropriate error code |
|
220 LbtGlobal::RequestComplete(aMessage, retVal); |
|
221 break; |
|
222 } |
|
223 |
|
224 // If capability check is successful then create the aooperation object |
|
225 CLbtCreateTriggerAOOperation* operation = |
|
226 CLbtCreateTriggerAOOperation::NewL(*this, |
|
227 aMessage, |
|
228 *iContainer, |
|
229 aType, |
|
230 *iSettingsManager); |
|
231 iAOOArray.Append(operation); |
|
232 operation->StartOperationL(); |
|
233 break; |
|
234 } |
|
235 case ELbtGetTriggers: |
|
236 case ELbtGetFiredTriggers: |
|
237 case ELbtListTriggerIds: |
|
238 { |
|
239 TInt retValue=ValidateGeneralOperation(aMessage); |
|
240 |
|
241 if(retValue!=KErrNone) |
|
242 { |
|
243 // If validation failed then complete the request with the appropriate error code |
|
244 LbtGlobal::RequestComplete(aMessage, retValue); |
|
245 break; |
|
246 } |
|
247 for(TInt i = 0; i < iAOOArray.Count(); ++i) |
|
248 { |
|
249 CLbtAOOperationBase* operation = iAOOArray[i]; |
|
250 if(operation->GetSecureId() == aMessage.SecureId() && |
|
251 operation->GetSubSessionHandle() == aMessage.Int3() && |
|
252 ( iAOOArray[i]->GetFunction() == ELbtGetTriggersBufferSize || |
|
253 iAOOArray[i]->GetFunction() == EGetFiredTriggersCount || |
|
254 iAOOArray[i]->GetFunction() == ELbtGetListTriggerIdsSize ) ) |
|
255 { |
|
256 // The session id and the client of the message are the |
|
257 // same and since a sub-session can have just one outstanding |
|
258 // asynchronous service request, the AO object obtained must be |
|
259 // the listAO operation object to service this request |
|
260 CLbtListAOOperation* listOperation = static_cast<CLbtListAOOperation*>(operation); |
|
261 listOperation->ServiceMessageL(aMessage); |
|
262 break; |
|
263 } |
|
264 } |
|
265 break; |
|
266 } |
|
267 case ELbtGetTriggersBufferSize: |
|
268 case EGetFiredTriggersCount: |
|
269 case ELbtGetListTriggerIdsSize: |
|
270 { |
|
271 TInt retValue=ValidateGeneralOperation(aMessage); |
|
272 |
|
273 if(retValue!=KErrNone) |
|
274 { |
|
275 // If validation failed then complete the request with the appropriate error code |
|
276 LbtGlobal::RequestComplete(aMessage, retValue); |
|
277 break; |
|
278 } |
|
279 CLbtListAOOperation* operation = |
|
280 CLbtListAOOperation::NewL(*this, aMessage, *iContainer, aType); |
|
281 iAOOArray.Append(operation); |
|
282 operation->StartOperationL(); |
|
283 break; |
|
284 } |
|
285 case ELbtUpdateTrigger: |
|
286 case ELbtSetTriggerState: |
|
287 case ELbtSetTriggersState: |
|
288 case ELbtDeleteTrigger: |
|
289 case ELbtDeleteTriggers: |
|
290 { |
|
291 TInt retValue=ValidateGeneralOperation(aMessage); |
|
292 |
|
293 if(retValue!=KErrNone) |
|
294 { |
|
295 // If validation failed then complete the request with the appropriate error code |
|
296 LbtGlobal::RequestComplete(aMessage, retValue); |
|
297 break; |
|
298 } |
|
299 |
|
300 CLbtTriggerModifyAOOperation* operation = |
|
301 CLbtTriggerModifyAOOperation::NewL(*this, aMessage, *iContainer, aType,*iSettingsManager); |
|
302 iAOOArray.Append(operation); |
|
303 operation->StartOperationL(); |
|
304 break; |
|
305 } |
|
306 case ELbtGetTriggeringSysSetting: |
|
307 { |
|
308 TInt retValue=ValidateGetTriggeringSysSetting(aMessage); |
|
309 |
|
310 if(retValue!=KErrNone) |
|
311 { |
|
312 // If validation failed then complete the request with the appropriate error code |
|
313 LbtGlobal::RequestComplete(aMessage, retValue); |
|
314 break; |
|
315 } |
|
316 |
|
317 TInt retVal = GetTriggeringSystemSettings( aMessage, aType ); |
|
318 |
|
319 if(retVal == KErrNone) |
|
320 { |
|
321 LbtGlobal::RequestComplete(aMessage, KErrNone); |
|
322 } |
|
323 break; |
|
324 } |
|
325 |
|
326 case ELbtSetTriggeringSettings: |
|
327 { |
|
328 TInt retValue=ValidateSetTriggeringSetting(aMessage); |
|
329 |
|
330 if(retValue!=KErrNone) |
|
331 { |
|
332 // If validation failed then complete the request with the appropriate error code |
|
333 LbtGlobal::RequestComplete(aMessage, retValue); |
|
334 break; |
|
335 } |
|
336 |
|
337 // The request can only be through the LT management API. |
|
338 // ToDo : Check for capabilities. |
|
339 if ( TLbtManagementLibrary != aType ) |
|
340 { |
|
341 // This is not a management library. Hence return access denied. |
|
342 aMessage.Complete( KErrAccessDenied ); |
|
343 } |
|
344 else |
|
345 { |
|
346 TLbtTriggeringSystemManagementSettings settings; |
|
347 TPckg<TLbtTriggeringSystemManagementSettings> pckgSettings(settings); |
|
348 // In case of error in LbtGlobal::Read then the client is already |
|
349 // panic'ed hence there is no need to complete the message again. |
|
350 if( !LbtGlobal::Read(aMessage, KParamSettings, pckgSettings) ) |
|
351 { |
|
352 // KParamMask slot contains the mask of the settings to be changed. |
|
353 SetTriggeringSystemSettings( settings, aMessage.Int0() ); |
|
354 aMessage.Complete( KErrNone ); |
|
355 } |
|
356 } |
|
357 // TODO: Handle triggering settings change request from management library |
|
358 //HandleNotificationOperationsL(aMessage); |
|
359 break; |
|
360 } |
|
361 case ELbtGetTriggeringSysStatus: |
|
362 { |
|
363 TInt retValue=ValidateGetTriggeringSysStatus(aMessage); |
|
364 |
|
365 if(retValue!=KErrNone) |
|
366 { |
|
367 // If validation failed then complete the request with the appropriate error code |
|
368 LbtGlobal::RequestComplete(aMessage, retValue); |
|
369 break; |
|
370 } |
|
371 |
|
372 if ( TLbtManagementLibrary != aType ) |
|
373 { |
|
374 // This is not a management library. Hence return access denied. |
|
375 aMessage.Complete( KErrAccessDenied ); |
|
376 } |
|
377 |
|
378 TLbtTriggeringSystemStatus systemStatus; |
|
379 GetTriggeringSysStatus( systemStatus ); |
|
380 |
|
381 TPckg<TLbtTriggeringSystemStatus> systemStatusPckg( systemStatus ); |
|
382 |
|
383 TInt error = LbtGlobal::Write(aMessage, KParamStatus, systemStatusPckg); |
|
384 LbtGlobal::RequestComplete(aMessage, error); |
|
385 |
|
386 break; |
|
387 } |
|
388 |
|
389 case ELbtCancelCreateTrigger: |
|
390 { |
|
391 if(!iAOOArray.Count()) |
|
392 { |
|
393 LbtGlobal::RequestComplete(aMessage,KErrNotFound); |
|
394 break; |
|
395 } |
|
396 for(TInt i=0;i<iAOOArray.Count();i++) |
|
397 { |
|
398 if((iAOOArray[i]->GetSecureId()==aMessage.SecureId()) && |
|
399 (iAOOArray[i]->GetFunction()==ELbtCreateTrigger) && |
|
400 (iAOOArray[i]->GetSubSessionHandle()==aMessage.Int3())) |
|
401 { |
|
402 CLbtCreateTriggerAOOperation* createTriggerAOOperation= |
|
403 static_cast<CLbtCreateTriggerAOOperation*> |
|
404 (iAOOArray[i]); |
|
405 createTriggerAOOperation->CancelCreateTrigger(); |
|
406 LbtGlobal::RequestComplete(aMessage,KErrNone); |
|
407 return; |
|
408 } |
|
409 } |
|
410 LbtGlobal::RequestComplete(aMessage,KErrNotFound); |
|
411 break; |
|
412 } |
|
413 |
|
414 case ELbtCancelDeleteTriggers: |
|
415 { |
|
416 if(!iAOOArray.Count()) |
|
417 { |
|
418 LbtGlobal::RequestComplete(aMessage,KErrNotFound); |
|
419 break; |
|
420 } |
|
421 for(TInt i=0;i<iAOOArray.Count();i++) |
|
422 { |
|
423 if((iAOOArray[i]->GetSecureId()==aMessage.SecureId())&& |
|
424 (iAOOArray[i]->GetSubSessionHandle()==aMessage.Int3()) && |
|
425 (iAOOArray[i]->GetFunction()==ELbtDeleteTriggers)) |
|
426 { |
|
427 CLbtTriggerModifyAOOperation* triggerModifyAOOperation= |
|
428 static_cast<CLbtTriggerModifyAOOperation*> |
|
429 (iAOOArray[i]); |
|
430 triggerModifyAOOperation->CancelModifyOperation(); |
|
431 LbtGlobal::RequestComplete(aMessage,KErrNone); |
|
432 return; |
|
433 } |
|
434 } |
|
435 LbtGlobal::RequestComplete(aMessage,KErrNotFound); |
|
436 break; |
|
437 } |
|
438 case ELbtCancelSetTriggersState: |
|
439 { |
|
440 if(!iAOOArray.Count()) |
|
441 { |
|
442 LbtGlobal::RequestComplete(aMessage,KErrNotFound); |
|
443 break; |
|
444 } |
|
445 for(TInt i=0;i<iAOOArray.Count();i++) |
|
446 { |
|
447 if((iAOOArray[i]->GetSecureId()==aMessage.SecureId())&& |
|
448 (iAOOArray[i]->GetSubSessionHandle()==aMessage.Int3()) && |
|
449 (iAOOArray[i]->GetFunction()==ELbtSetTriggersState)) |
|
450 { |
|
451 CLbtTriggerModifyAOOperation* triggerModifyAOOperation= |
|
452 static_cast<CLbtTriggerModifyAOOperation*> |
|
453 (iAOOArray[i]); |
|
454 triggerModifyAOOperation->CancelModifyOperation(); |
|
455 LbtGlobal::RequestComplete(aMessage,KErrNone); |
|
456 return; |
|
457 } |
|
458 } |
|
459 LbtGlobal::RequestComplete(aMessage,KErrNotFound); |
|
460 break; |
|
461 } |
|
462 case ELbtCancelUpdateTrigger: |
|
463 { |
|
464 if(!iAOOArray.Count()) |
|
465 { |
|
466 LbtGlobal::RequestComplete(aMessage,KErrNotFound); |
|
467 break; |
|
468 } |
|
469 for(TInt i=0;i<iAOOArray.Count();i++) |
|
470 { |
|
471 if((iAOOArray[i]->GetSecureId()==aMessage.SecureId())&& |
|
472 (iAOOArray[i]->GetSubSessionHandle()==aMessage.Int3()) && |
|
473 (iAOOArray[i]->GetFunction()==ELbtUpdateTrigger )) |
|
474 { |
|
475 CLbtTriggerModifyAOOperation* triggerModifyAOOperation= |
|
476 static_cast<CLbtTriggerModifyAOOperation*> |
|
477 (iAOOArray[i]); |
|
478 triggerModifyAOOperation->CancelModifyOperation(); |
|
479 LbtGlobal::RequestComplete(aMessage,KErrNone); |
|
480 return; |
|
481 } |
|
482 } |
|
483 LbtGlobal::RequestComplete(aMessage,KErrNotFound); |
|
484 break; |
|
485 } |
|
486 |
|
487 case ELbtCancelListTriggerIds: |
|
488 { |
|
489 if(!iAOOArray.Count()) |
|
490 { |
|
491 LbtGlobal::RequestComplete(aMessage,KErrNotFound); |
|
492 break; |
|
493 } |
|
494 for(TInt i=0;i<iAOOArray.Count();i++) |
|
495 { |
|
496 if((iAOOArray[i]->GetSecureId()==aMessage.SecureId()) && |
|
497 (iAOOArray[i]->GetSubSessionHandle()==aMessage.Int3()) && |
|
498 (iAOOArray[i]->GetFunction()==ELbtGetListTriggerIdsSize)) |
|
499 { |
|
500 CLbtListAOOperation* listAOOperation= |
|
501 static_cast<CLbtListAOOperation*> |
|
502 (iAOOArray[i]); |
|
503 listAOOperation->CancelListOperation(); |
|
504 LbtGlobal::RequestComplete(aMessage,KErrNone); |
|
505 return; |
|
506 } |
|
507 } |
|
508 LbtGlobal::RequestComplete(aMessage,KErrNotFound); |
|
509 break; |
|
510 } |
|
511 case ELbtCancelGetTriggers: |
|
512 { |
|
513 if(!iAOOArray.Count()) |
|
514 { |
|
515 LbtGlobal::RequestComplete(aMessage,KErrNotFound); |
|
516 break; |
|
517 } |
|
518 for(TInt i=0;i<iAOOArray.Count();i++) |
|
519 { |
|
520 if((iAOOArray[i]->GetSecureId()==aMessage.SecureId()) && |
|
521 (iAOOArray[i]->GetSubSessionHandle()==aMessage.Int3()) && |
|
522 (iAOOArray[i]->GetFunction()==ELbtGetTriggersBufferSize)) |
|
523 { |
|
524 CLbtListAOOperation* listAOOperation= |
|
525 static_cast<CLbtListAOOperation*> |
|
526 (iAOOArray[i]); |
|
527 listAOOperation->CancelListOperation(); |
|
528 LbtGlobal::RequestComplete(aMessage,KErrNone); |
|
529 return; |
|
530 } |
|
531 } |
|
532 LbtGlobal::RequestComplete(aMessage,KErrNotFound); |
|
533 break; |
|
534 } |
|
535 |
|
536 case ELbtCancelAll: |
|
537 { |
|
538 RMessage2 message; |
|
539 while( !iNotificationMap->Retreive( message,aMessage.Int3(),aMessage.SecureId() ) ) |
|
540 { |
|
541 LbtGlobal::RequestComplete(message, KErrCancel); |
|
542 } |
|
543 if(!iAOOArray.Count()) |
|
544 { |
|
545 LbtGlobal::RequestComplete(aMessage,KErrNotFound); |
|
546 break; |
|
547 } |
|
548 for(TInt i=0;i<iAOOArray.Count();i++) |
|
549 { |
|
550 if(iAOOArray[i]->GetSecureId()==aMessage.SecureId() && |
|
551 (iAOOArray[i]->GetSubSessionHandle()==aMessage.Int3())) |
|
552 { |
|
553 switch(iAOOArray[i]->GetFunction()) |
|
554 { |
|
555 case ELbtCreateTrigger: |
|
556 { |
|
557 CLbtCreateTriggerAOOperation* createTriggerAOOperation= |
|
558 static_cast<CLbtCreateTriggerAOOperation*> |
|
559 (iAOOArray[i]); |
|
560 createTriggerAOOperation->CancelCreateTrigger(); |
|
561 break; |
|
562 } |
|
563 case ELbtDeleteTriggers: |
|
564 case ELbtSetTriggersState: |
|
565 case ELbtUpdateTrigger: |
|
566 { |
|
567 CLbtTriggerModifyAOOperation* triggerModifyAOOperation= |
|
568 static_cast<CLbtTriggerModifyAOOperation*> |
|
569 (iAOOArray[i]); |
|
570 triggerModifyAOOperation->CancelModifyOperation(); |
|
571 break; |
|
572 } |
|
573 case ELbtGetListTriggerIdsSize: |
|
574 case ELbtGetTriggersBufferSize: |
|
575 { |
|
576 CLbtListAOOperation* listAOOperation= |
|
577 static_cast<CLbtListAOOperation*> |
|
578 (iAOOArray[i]); |
|
579 listAOOperation->CancelListOperation(); |
|
580 break; |
|
581 } |
|
582 default: |
|
583 { |
|
584 break; |
|
585 } |
|
586 } |
|
587 } |
|
588 } |
|
589 LbtGlobal::RequestComplete(aMessage,KErrNone); |
|
590 break; |
|
591 } |
|
592 default: |
|
593 { |
|
594 break; |
|
595 } |
|
596 } |
|
597 } |
|
598 |
|
599 // --------------------------------------------------------------------------- |
|
600 // CLbtServerLogic::LoadOrUnloadStrategyPluginL |
|
601 // --------------------------------------------------------------------------- |
|
602 // |
|
603 void CLbtServerLogic::LoadOrUnloadStrategyPluginL() |
|
604 { |
|
605 FUNC_ENTER("CLbtServerLogic::LoadOrUnloadStrategyPluginL"); |
|
606 // Load stratergy if it is not already loaded and if there are valid |
|
607 // and enabled triggers in the system |
|
608 if(!iStratergyContainer->Stratergy() && // if stratergy not already loaded |
|
609 iContainer->GetCountOfEnabledAndValidTriggers() && // if there are enabled and valid triggers |
|
610 ( iSettingsManager->GetTriggeringMechanismState() == ETriggeringMechanismOn )&& |
|
611 !iBackupRestoreListener->IsBackupRestoreOperationInProgress()) // if backup or restore operation is not in progress |
|
612 { |
|
613 LBT_TRACE(KLbtLogVerbose|KLbtLogServerLogic,__FILE__, __LINE__, "Loading Strategy plugin"); |
|
614 iStratergyContainer->LoadStratergyL(this); |
|
615 iStratergyContainer->Stratergy()->StartSupervision(); |
|
616 iStrategyDynamicInfo.iLocationAcquisitionStatus = ELocationAcquisitionActive; |
|
617 NotifyTriggeringSystemStatusChange(); |
|
618 } |
|
619 |
|
620 else if(!iContainer->GetCountOfEnabledAndValidTriggers()) |
|
621 { |
|
622 // If there are no triggers in the system to be supervised then |
|
623 // unload stratergy |
|
624 LBT_TRACE(KLbtLogVerbose|KLbtLogServerLogic,__FILE__, __LINE__, "Unloading Strategy plugin"); |
|
625 iStratergyContainer->UnloadStratergy(); |
|
626 iStrategyDynamicInfo.iLocationAcquisitionStatus = ELocationAcquisitionInactive; |
|
627 NotifyTriggeringSystemStatusChange(); |
|
628 } |
|
629 } |
|
630 |
|
631 // --------------------------------------------------------------------------- |
|
632 // CLbtServerLogic::HandleSubSessionClosure |
|
633 // --------------------------------------------------------------------------- |
|
634 // |
|
635 void CLbtServerLogic::HandleSubSessionClosure(const TInt aSubSessionId, const CSession2* aSession) |
|
636 { |
|
637 FUNC_ENTER("CLbtServerLogic::HandleSubSessionClosure"); |
|
638 LBT_TRACE(KLbtLogVerbose|KLbtLogServerLogic,__FILE__, __LINE__, "HandleSubSessionClosure called"); |
|
639 // Since the sub-session is being closed remove all the messages |
|
640 // from the message array |
|
641 iNotificationMap->CompleteMessagesOfSubsession(aSession, aSubSessionId, KErrDisconnected); |
|
642 |
|
643 // Stop all the AOOperation object pertaining to the |
|
644 // sub-session that is being closed. |
|
645 for(TInt i = iAOOArray.Count() - 1; i >= 0 ; --i) |
|
646 { |
|
647 CLbtAOOperationBase* operation = iAOOArray[i]; |
|
648 if(operation->GetSubSessionHandle() == aSubSessionId && |
|
649 operation->GetSession() == aSession ) |
|
650 { |
|
651 iAOOArray.Remove(i); |
|
652 delete operation; |
|
653 } |
|
654 } |
|
655 } |
|
656 |
|
657 // --------------------------------------------------------------------------- |
|
658 // CLbtServerLogic::HandleSessionClosureL |
|
659 // --------------------------------------------------------------------------- |
|
660 // |
|
661 void CLbtServerLogic::HandleSessionClosureL(const TSecureId aSecureId) |
|
662 { |
|
663 FUNC_ENTER("CLbtServerLogic::HandleSessionClosureL"); |
|
664 LBT_TRACE(KLbtLogVerbose|KLbtLogServerLogic,__FILE__, __LINE__, "Session closed by client %x", aSecureId.iId ); |
|
665 // Inform container to delete all the sessions triggers of |
|
666 // the client with secure id aSecureId. |
|
667 CLbtContainerFilter* filter = CLbtContainerFilter::NewL(); |
|
668 CleanupStack::PushL(filter); |
|
669 filter->AddOwnerSidInFilterL(aSecureId); |
|
670 |
|
671 CLbtTriggerFilterByAttribute* filterByAttribute = |
|
672 CLbtTriggerFilterByAttribute::NewL(); |
|
673 CleanupStack::PushL(filterByAttribute); |
|
674 filterByAttribute->AddTriggerTypeL(CLbtTriggerEntry::ETypeSession); |
|
675 |
|
676 CLbtContainerUpdateFilter* containerFilter = |
|
677 CLbtContainerUpdateFilter::NewL(filterByAttribute, filter); |
|
678 CleanupStack::PushL(containerFilter); |
|
679 |
|
680 CLbtDeleteSessionTriggers* deleteSessionTriggers= |
|
681 CLbtDeleteSessionTriggers::NewL(*this,*iContainer,*iNotificationMap); |
|
682 iDeleteSessionTriggersArray.Append(deleteSessionTriggers); |
|
683 |
|
684 deleteSessionTriggers->DeleteSessionTriggers(containerFilter); |
|
685 iNotificationMap->RemoveAllClientMessages(aSecureId); |
|
686 CleanupStack::Pop(containerFilter); |
|
687 CleanupStack::Pop(filterByAttribute); |
|
688 CleanupStack::Pop(filter); |
|
689 } |
|
690 |
|
691 |
|
692 // --------------------------------------------------------------------------- |
|
693 // CLbtServerLogic::HandleDeleteSessionTriggersClosureL |
|
694 // --------------------------------------------------------------------------- |
|
695 // |
|
696 void CLbtServerLogic::HandleDeleteSessionTriggersClosureL(CLbtDeleteSessionTriggers* aDeleteSessionTriggers) |
|
697 { |
|
698 FUNC_ENTER("CLbtServerLogic::HandleDeleteSessionTriggersClosureL"); |
|
699 TInt index = iDeleteSessionTriggersArray.Find(aDeleteSessionTriggers); |
|
700 if(index != KErrNotFound) |
|
701 { |
|
702 iDeleteSessionTriggersArray.Remove(index); |
|
703 } |
|
704 delete aDeleteSessionTriggers; |
|
705 } |
|
706 |
|
707 // --------------------------------------------------------------------------- |
|
708 // CLbtServerLogic::HandleOperationClosureL |
|
709 // --------------------------------------------------------------------------- |
|
710 // |
|
711 void CLbtServerLogic::HandleOperationClosureL(CLbtAOOperationBase* aOperation, TInt aStatus) |
|
712 { |
|
713 FUNC_ENTER("CLbtServerLogic::HandleOperationClosureL"); |
|
714 switch(aOperation->GetFunction()) |
|
715 { |
|
716 case ELbtCreateTrigger: |
|
717 case ELbtUpdateTrigger: |
|
718 case ELbtSetTriggerState: |
|
719 case ELbtSetTriggersState: |
|
720 case ELbtDeleteTrigger: |
|
721 case ELbtDeleteTriggers: |
|
722 { |
|
723 LoadOrUnloadStrategyPluginL(); |
|
724 if(aStatus == KErrNone) |
|
725 { |
|
726 // Send the active object operation object and the notification type |
|
727 HandleNotificationOperationsL(aOperation, ELbtNotifyTriggerChangeEvent); |
|
728 } |
|
729 break; |
|
730 } |
|
731 default: |
|
732 { |
|
733 break; |
|
734 } |
|
735 } |
|
736 |
|
737 // Check which AOOperation object has notified. Delete the |
|
738 // object and remove it from the aooperation array. |
|
739 TInt index = iAOOArray.Find(aOperation); |
|
740 if(index != KErrNotFound) |
|
741 { |
|
742 iAOOArray.Remove(index); |
|
743 } |
|
744 delete aOperation; |
|
745 } |
|
746 |
|
747 // --------------------------------------------------------------------------- |
|
748 // CLbtServerLogic::HandleBackupRestoreOperationL |
|
749 // --------------------------------------------------------------------------- |
|
750 // |
|
751 void CLbtServerLogic::HandleBackupRestoreOperationL(TBRState aState) |
|
752 { |
|
753 FUNC_ENTER("CLbtServerLogic::HandleBackupRestoreOperationL"); |
|
754 if(aState == MLbtBackupRestoreObserver::EStarted) |
|
755 { |
|
756 // The logic to handle backup / restore operation is as follows. |
|
757 // 1. Cancel All outstanding requests from clients first. Since the AO |
|
758 // operations will be using container, this should be done first. |
|
759 // This will also close all pending IPC messages with KErrServerBusy. |
|
760 // 2. Then unload the strategy implementation. |
|
761 // 3. Delete the Container instance now. |
|
762 |
|
763 // Cancel all outstanding operations. |
|
764 CancelAllOperations(); |
|
765 |
|
766 // Delete all handlers that use server logics container instance |
|
767 delete iFireHandler; |
|
768 iFireHandler = NULL; |
|
769 |
|
770 delete iSimChangeHandler; |
|
771 iSimChangeHandler = NULL; |
|
772 |
|
773 delete iAppChangeHandler; |
|
774 iAppChangeHandler = NULL; |
|
775 |
|
776 delete iCleanupHandler; |
|
777 iCleanupHandler = NULL; |
|
778 |
|
779 // If backup or restore operation has started then unload strategy. |
|
780 iStratergyContainer->UnloadStratergy(); |
|
781 // Destroy the container instance. This will close the open Database |
|
782 // file so that it can be backed up or restored. |
|
783 CLbtContainer::Destroy(); |
|
784 iContainer = NULL; |
|
785 } |
|
786 else |
|
787 { |
|
788 // Backup and restore operation finished. |
|
789 |
|
790 // Load the Container First since it is required to determine whether |
|
791 // strategy should be loaded or not. |
|
792 iContainer = CLbtContainer::NewL(); |
|
793 |
|
794 // Load all handlers that use container same instance |
|
795 iFireHandler = CLbtTriggerFireHandler::NewL(*iNotificationMap, *iContainer); |
|
796 |
|
797 iCleanupHandler = CLbtCleanupHandler::NewL( *iContainer ); |
|
798 |
|
799 iSimChangeHandler = CLbtSimChangeHandler::NewL( *iContainer,*iCleanupHandler,*this ); |
|
800 iSimChangeHandler->StartToListenL(); |
|
801 |
|
802 iAppChangeHandler = CLbtAppChangeHandler::NewL(*iContainer, *iCleanupHandler,*this); |
|
803 iAppChangeHandler->StartListeningL(); |
|
804 |
|
805 // Load Strategy if there are triggers to be monitored. |
|
806 LoadOrUnloadStrategyPluginL(); |
|
807 } |
|
808 } |
|
809 |
|
810 |
|
811 // --------------------------------------------------------------------------- |
|
812 // CLbtServerLogic::TriggerFiredL |
|
813 // --------------------------------------------------------------------------- |
|
814 // |
|
815 void CLbtServerLogic::TriggerFiredL( CLbtGeoAreaBase::TGeoAreaType aAreaType, |
|
816 TLbtTriggerId aId, const TPositionInfo& aPosInfo ) |
|
817 { |
|
818 FUNC_ENTER("CLbtServerLogic::TriggerFiredL"); |
|
819 /** |
|
820 * Create the trigger fire handler. The trigger fire handler is an active |
|
821 * object and does the firing operation asynchronously since firing in |
|
822 * this function will block stratergy's normal operation |
|
823 */ |
|
824 TLbtTriggerFireInfo triggerFireInfo; |
|
825 triggerFireInfo.iAreaType = aAreaType; |
|
826 triggerFireInfo.iTriggerId = aId; |
|
827 triggerFireInfo.iFiredPositionInfo = aPosInfo; |
|
828 iFireHandler->FireTriggerL(triggerFireInfo); |
|
829 } |
|
830 |
|
831 // --------------------------------------------------------------------------- |
|
832 // CLbtServerLogic::SetTriggeringSupervisionDynamicInfo |
|
833 // --------------------------------------------------------------------------- |
|
834 // |
|
835 void CLbtServerLogic::SetTriggeringSupervisionDynamicInfo( |
|
836 const TLbtStrategySupervisionDynamicInfo& aStatus ) |
|
837 { |
|
838 FUNC_ENTER("CLbtServerLogic::SetTriggeringSupervisionDynamicInfo"); |
|
839 iStrategyDynamicInfo = aStatus; |
|
840 NotifyTriggeringSystemStatusChange(); |
|
841 } |
|
842 |
|
843 // --------------------------------------------------------------------------- |
|
844 // CLbtServerLogic::GetTriggeringSupervisionSettings |
|
845 // --------------------------------------------------------------------------- |
|
846 // |
|
847 void CLbtServerLogic::GetTriggeringSupervisionSettings( TLbtStrategyTriggeringSupervisionSettings& aSettings ) |
|
848 { |
|
849 FUNC_ENTER("CLbtServerLogic::GetTriggeringSupervisionSettings"); |
|
850 aSettings.iGpsTrackingModeInterval = iSettingsManager->GetMinimumUpdateInterval(); |
|
851 aSettings.iLocationRequestTimeout = iSettingsManager->GetLocationRequestTimeOut(); |
|
852 aSettings.iMaximumUserSpeed = iSettingsManager->GetMaximumUserSpeed(); |
|
853 aSettings.iMinimumLocationUpdateInterval = iSettingsManager->GetMinimumUpdateInterval(); |
|
854 aSettings.iMinimumLocationUpdateIntervalWithoutGps = iSettingsManager->GetMinimumUpdateIntervalOnGpsFailure(); |
|
855 aSettings.iPositioningTechnology = iSettingsManager->GetModuleId(); |
|
856 } |
|
857 |
|
858 // --------------------------------------------------------------------------- |
|
859 // CLbtServerLogic::ConstructL |
|
860 // --------------------------------------------------------------------------- |
|
861 // |
|
862 void CLbtServerLogic::ConstructL() |
|
863 { |
|
864 FUNC_ENTER("CLbtServerLogic::ConstructL"); |
|
865 iBackupRestoreListener = CLbtBackupRestoreListener::NewL(*this); |
|
866 iBackupRestoreListener->StartToListenL(); |
|
867 iContainer = CLbtContainer::NewL(); |
|
868 iStratergyContainer = CLbtStratergyContainer::NewL(); |
|
869 iSettingsManager = CLbtSettingsManager::NewL(); |
|
870 iNotificationMap = CLbtNotificationMap::NewL(); |
|
871 iFireHandler = CLbtTriggerFireHandler::NewL(*iNotificationMap, *iContainer); |
|
872 iStrategyDynamicInfo.iLocationAcquisitionStatus = ELocationAcquisitionNotReady; |
|
873 iCleanupHandler = CLbtCleanupHandler::NewL( *iContainer ); |
|
874 iSimChangeHandler = CLbtSimChangeHandler::NewL( *iContainer,*iCleanupHandler,*this ); |
|
875 iSimChangeHandler->StartToListenL(); |
|
876 // App change handler to handle application uninstallation and MMC card removal |
|
877 iAppChangeHandler = CLbtAppChangeHandler::NewL(*iContainer, *iCleanupHandler,*this); |
|
878 iAppChangeHandler->StartListeningL(); |
|
879 LoadOrUnloadStrategyPluginL(); |
|
880 User::LeaveIfError( iProperty.Attach(KPSUidLbtStatusInformation, |
|
881 KLbtLocationTriggeringSupervisionStatus, |
|
882 EOwnerThread) ); |
|
883 |
|
884 if( iSettingsManager->GetTriggeringMechanismState() == ETriggeringMechanismOff ) |
|
885 { |
|
886 // Change the status information to supervision not active |
|
887 iProperty.Set(KPSUidLbtStatusInformation, |
|
888 KLbtLocationTriggeringSupervisionStatus, |
|
889 ELbtLocationTriggeringSupervisionOff); |
|
890 } |
|
891 } |
|
892 |
|
893 // --------------------------------------------------------------------------- |
|
894 // CLbtServerLogic::CancelAllOperations |
|
895 // --------------------------------------------------------------------------- |
|
896 // |
|
897 void CLbtServerLogic::CancelAllOperations() |
|
898 { |
|
899 FUNC_ENTER("CLbtServerLogic::CancelAllOperations"); |
|
900 |
|
901 if(iNotificationMap) |
|
902 { |
|
903 // Inform all outstanding IPC messages that the server is busy with some other operation |
|
904 iNotificationMap->Reset(KErrServerBusy); |
|
905 } |
|
906 |
|
907 // Destroy all the AOO operation objects |
|
908 iAOOArray.ResetAndDestroy(); |
|
909 } |
|
910 |
|
911 // --------------------------------------------------------------------------- |
|
912 // CLbtServerLogic::RemoveFromNotificationMap |
|
913 // --------------------------------------------------------------------------- |
|
914 // |
|
915 TInt CLbtServerLogic::RemoveFromNotificationMap(const RMessage2& aMessage, TInt aServiceId) |
|
916 { |
|
917 FUNC_ENTER("CLbtServerLogic::RemoveFromNotificationMap"); |
|
918 RMessage2 msg; |
|
919 TInt retVal = iNotificationMap->Retreive(msg, |
|
920 aMessage.Int3(), |
|
921 aMessage.SecureId(), |
|
922 aServiceId, |
|
923 aMessage.Session()); |
|
924 if(retVal == KErrNone) |
|
925 { |
|
926 LbtGlobal::RequestComplete(msg, KErrCancel); |
|
927 } |
|
928 return retVal; |
|
929 } |
|
930 |
|
931 // --------------------------------------------------------------------------- |
|
932 // CLbtServerLogic::InsertIntoNotificationMapL |
|
933 // --------------------------------------------------------------------------- |
|
934 // |
|
935 void CLbtServerLogic::InsertIntoNotificationMapL( |
|
936 const RMessage2& aMessage, |
|
937 TSubSessionType aType) |
|
938 { |
|
939 FUNC_ENTER("CLbtServerLogic::InsertIntoNotificationMapL"); |
|
940 // Valid request. Insert in sorted order into to the message array |
|
941 iNotificationMap->InsertL(aMessage, aType); |
|
942 } |
|
943 |
|
944 // --------------------------------------------------------------------------- |
|
945 // CLbtServerLogic::ValidateChangeNotification |
|
946 // --------------------------------------------------------------------------- |
|
947 // |
|
948 TInt CLbtServerLogic::ValidateChangeNotification(const RMessage2& aMessage) |
|
949 { |
|
950 FUNC_ENTER("CLbtServerLogic::ValidateChangeNotification"); |
|
951 if( !aMessage.HasCapability(ECapabilityLocation) || |
|
952 !aMessage.HasCapability(ECapabilityReadDeviceData)|| |
|
953 !aMessage.HasCapability(ECapabilityReadUserData)) |
|
954 { |
|
955 return KErrPermissionDenied; |
|
956 } |
|
957 |
|
958 return KErrNone; |
|
959 } |
|
960 |
|
961 // --------------------------------------------------------------------------- |
|
962 // CLbtServerLogic::ValidateGeneralOperation |
|
963 // --------------------------------------------------------------------------- |
|
964 // |
|
965 TInt CLbtServerLogic::ValidateGeneralOperation(const RMessage2& aMessage) |
|
966 { |
|
967 FUNC_ENTER("CLbtServerLogic::ValidateGeneralOperation"); |
|
968 if( !aMessage.HasCapability(ECapabilityLocation)) |
|
969 { |
|
970 return KErrPermissionDenied; |
|
971 } |
|
972 |
|
973 return KErrNone; |
|
974 } |
|
975 |
|
976 // --------------------------------------------------------------------------- |
|
977 // CLbtServerLogic::ValidateCreateTriggerMessage |
|
978 // --------------------------------------------------------------------------- |
|
979 // |
|
980 TInt CLbtServerLogic::ValidateCreateTriggerMessage(const RMessage2& aMessage) |
|
981 { |
|
982 FUNC_ENTER("CLbtServerLogic::ValidateCreateTriggerMessage"); |
|
983 // The server should check for the following parameters |
|
984 // 1. capability checks for security. |
|
985 // 2. checks for the Trigger area, ie. radius. (ToDo) |
|
986 |
|
987 // Check if the requesting process has location and write user data capability |
|
988 // ToDo : check the required set of capabilities from req spec. |
|
989 if( !aMessage.HasCapability(ECapabilityLocation) || |
|
990 !aMessage.HasCapability(ECapabilityWriteUserData) ) |
|
991 { |
|
992 return KErrPermissionDenied; |
|
993 } |
|
994 |
|
995 return KErrNone; |
|
996 } |
|
997 // --------------------------------------------------------------------------- |
|
998 // CLbtServerLogic::ValidateGetTriggeringSysSetting |
|
999 // --------------------------------------------------------------------------- |
|
1000 // |
|
1001 TInt CLbtServerLogic::ValidateGetTriggeringSysSetting(const RMessage2& aMessage) |
|
1002 { |
|
1003 FUNC_ENTER("CLbtServerLogic::ValidateGetTriggeringSysSetting"); |
|
1004 if( !aMessage.HasCapability(ECapabilityLocation)|| |
|
1005 !aMessage.HasCapability(ECapabilityReadDeviceData)) |
|
1006 { |
|
1007 return KErrPermissionDenied; |
|
1008 } |
|
1009 |
|
1010 return KErrNone; |
|
1011 } |
|
1012 |
|
1013 // --------------------------------------------------------------------------- |
|
1014 // CLbtServerLogic::ValidateSetTriggeringSetting |
|
1015 // --------------------------------------------------------------------------- |
|
1016 // |
|
1017 TInt CLbtServerLogic::ValidateSetTriggeringSetting(const RMessage2& aMessage) |
|
1018 { |
|
1019 FUNC_ENTER("CLbtServerLogic::ValidateSetTriggeringSetting"); |
|
1020 if( !aMessage.HasCapability(ECapabilityLocation)|| |
|
1021 !aMessage.HasCapability(ECapabilityWriteDeviceData)) |
|
1022 { |
|
1023 return KErrPermissionDenied; |
|
1024 } |
|
1025 |
|
1026 return KErrNone; |
|
1027 } |
|
1028 |
|
1029 |
|
1030 // --------------------------------------------------------------------------- |
|
1031 // CLbtServerLogic::ValidateGetTriggeringSysStatus |
|
1032 // --------------------------------------------------------------------------- |
|
1033 // |
|
1034 TInt CLbtServerLogic::ValidateGetTriggeringSysStatus(const RMessage2& aMessage) |
|
1035 { |
|
1036 FUNC_ENTER("CLbtServerLogic::ValidateGetTriggeringSysStatus"); |
|
1037 if( !aMessage.HasCapability(ECapabilityLocation)|| |
|
1038 !aMessage.HasCapability(ECapabilityReadDeviceData)) |
|
1039 { |
|
1040 return KErrPermissionDenied; |
|
1041 } |
|
1042 |
|
1043 return KErrNone; |
|
1044 } |
|
1045 |
|
1046 |
|
1047 |
|
1048 // --------------------------------------------------------------------------- |
|
1049 // CLbtServerLogic::IsNotificationRequest |
|
1050 // --------------------------------------------------------------------------- |
|
1051 // |
|
1052 TBool CLbtServerLogic::IsNotificationRequest(TInt aServiceId) |
|
1053 { |
|
1054 FUNC_ENTER("CLbtServerLogic::IsNotificationRequest"); |
|
1055 if(aServiceId >= ELbtNotifyTriggerFired && |
|
1056 aServiceId <= ELbtNotifyTriggeringSysSettingChange) |
|
1057 { |
|
1058 return ETrue; |
|
1059 } |
|
1060 return EFalse; |
|
1061 } |
|
1062 |
|
1063 // --------------------------------------------------------------------------- |
|
1064 // CLbtServerLogic::HandleNotificationOperationsL |
|
1065 // --------------------------------------------------------------------------- |
|
1066 // |
|
1067 void CLbtServerLogic::HandleNotificationOperationsL( |
|
1068 CLbtAOOperationBase* aOperation, |
|
1069 TInt aServiceId) |
|
1070 { |
|
1071 FUNC_ENTER("CLbtServerLogic::HandleNotificationOperationsL"); |
|
1072 // This method handles all notifications. The IPC messsage has actually |
|
1073 // been compleated and hence the client side buffers should NOT be accessed |
|
1074 // through this message object. |
|
1075 |
|
1076 // First get the set of registered messages for notification for notification map |
|
1077 |
|
1078 // 2 types of operations |
|
1079 // 1. Client side -- Use the secureId in iMessage |
|
1080 // 2. Management Side -- Use the ownerSid retrieved by list triggers. |
|
1081 |
|
1082 // For each secureId now retrieve all messages for the same secureId and serviceId. |
|
1083 // Also retrieve all notif msgs from management API. |
|
1084 // respond to the pending messages. |
|
1085 |
|
1086 if ( aOperation->GetFunction() == ELbtCreateTrigger || |
|
1087 aOperation->GetClientType() == CLbtServerLogicBase::TLbtClientLibrary ) |
|
1088 { |
|
1089 HandleSingleNotificationOperationsL( aOperation, aServiceId ); |
|
1090 } |
|
1091 else |
|
1092 { |
|
1093 HandleMultipleNotificationOperationsL( aOperation, aServiceId ); |
|
1094 } |
|
1095 } |
|
1096 |
|
1097 // --------------------------------------------------------------------------- |
|
1098 // CLbtServerLogic::HandleSingleNotificationOperationsL |
|
1099 // --------------------------------------------------------------------------- |
|
1100 // |
|
1101 void CLbtServerLogic::HandleSingleNotificationOperationsL( |
|
1102 CLbtAOOperationBase* aOperation, |
|
1103 TInt aServiceId) |
|
1104 { |
|
1105 FUNC_ENTER("CLbtServerLogic::HandleSingleNotificationOperationsL"); |
|
1106 RArray<RMessage2> array; |
|
1107 RMessage2 message; |
|
1108 |
|
1109 RArray<TUid> managerUidArray =aOperation->GetManagerArray(); |
|
1110 for( TInt i=0;i<managerUidArray.Count();i++ ) |
|
1111 { |
|
1112 TSecureId secureId(managerUidArray[i]); |
|
1113 // Retrieve all client session notification messages. |
|
1114 while(!iNotificationMap->Retreive(message, secureId, aServiceId) ) |
|
1115 { |
|
1116 array.Append(message); |
|
1117 } |
|
1118 } |
|
1119 |
|
1120 // Retrieve all management notification messages. |
|
1121 while(!iNotificationMap->Retreive(message, |
|
1122 aServiceId, |
|
1123 CLbtServerLogicBase::TLbtManagementLibrary)) |
|
1124 { |
|
1125 array.Append(message); |
|
1126 } |
|
1127 |
|
1128 if(array.Count() == 0) |
|
1129 { |
|
1130 array.Close(); |
|
1131 return; |
|
1132 } |
|
1133 |
|
1134 // Populate the change event structure to send the information to the client based |
|
1135 // on the message for which the notification needs to be made |
|
1136 TLbtTriggerChangeEvent event; |
|
1137 |
|
1138 switch(aOperation->GetFunction()) |
|
1139 { |
|
1140 case ELbtCreateTrigger: |
|
1141 { |
|
1142 event.iEventType = ELbtTriggerChangeEventCreated; |
|
1143 // Get the trigger id from the create trigger AO object |
|
1144 CLbtCreateTriggerAOOperation* operation = |
|
1145 static_cast<CLbtCreateTriggerAOOperation*>(aOperation); |
|
1146 event.iTriggerId = operation->GetTriggerId(); |
|
1147 break; |
|
1148 } |
|
1149 case ELbtSetTriggerState: |
|
1150 case ELbtUpdateTrigger: |
|
1151 { |
|
1152 // Just one trigger has been updated |
|
1153 event.iEventType = ELbtTriggerChangeEventUpdated; |
|
1154 CLbtTriggerModifyAOOperation* operation = |
|
1155 static_cast<CLbtTriggerModifyAOOperation*>(aOperation); |
|
1156 event.iTriggerId = operation->GetTriggerId(); |
|
1157 break; |
|
1158 } |
|
1159 case ELbtDeleteTrigger: |
|
1160 { |
|
1161 event.iEventType = ELbtTriggerChangeEventDeleted; |
|
1162 CLbtTriggerModifyAOOperation* operation = |
|
1163 static_cast<CLbtTriggerModifyAOOperation*>(aOperation); |
|
1164 event.iTriggerId = operation->GetTriggerId(); |
|
1165 break; |
|
1166 } |
|
1167 case ELbtSetTriggersState: |
|
1168 case ELbtDeleteTriggers: |
|
1169 { |
|
1170 // Multiple triggers have been updated |
|
1171 event.iEventType = ELbtTriggerChangeEventMultiple; |
|
1172 break; |
|
1173 } |
|
1174 default: |
|
1175 { |
|
1176 break; |
|
1177 } |
|
1178 } |
|
1179 |
|
1180 // Respond with the change structure on all registered IPC's |
|
1181 for(TInt i=0;i<array.Count();++i) |
|
1182 { |
|
1183 TPckgBuf<TLbtTriggerChangeEvent> changeEvent(event); |
|
1184 if(LbtGlobal::Write(array[i], KParamChangeEvent, changeEvent) == KErrNone) |
|
1185 { |
|
1186 LbtGlobal::RequestComplete(array[i], KErrNone); |
|
1187 } |
|
1188 } |
|
1189 |
|
1190 array.Close(); |
|
1191 } |
|
1192 |
|
1193 // --------------------------------------------------------------------------- |
|
1194 // CLbtServerLogic::HandleMultipleNotificationOperationsL |
|
1195 // --------------------------------------------------------------------------- |
|
1196 // |
|
1197 void CLbtServerLogic::HandleMultipleNotificationOperationsL( |
|
1198 CLbtAOOperationBase* aOperation, |
|
1199 TInt aServiceId) |
|
1200 { |
|
1201 FUNC_ENTER("CLbtServerLogic::HandleMultipleNotificationOperationsL"); |
|
1202 CLbtTriggerModifyAOOperation* operation = |
|
1203 static_cast<CLbtTriggerModifyAOOperation*>(aOperation); |
|
1204 // list of triggers that were modified. |
|
1205 RPointerArray<CLbtContainerTriggerEntry>& list = |
|
1206 operation->GetUpdatedTriggerList(); |
|
1207 |
|
1208 RArray<RMessage2> array; |
|
1209 RMessage2 message; |
|
1210 TLbtTriggerChangeEvent event; |
|
1211 |
|
1212 // sort by SID the retrieved list of triggers that were modified. |
|
1213 TLinearOrder<CLbtContainerTriggerEntry> TriggerSidOrderPredicate(OrderTriggerEntryBySid); |
|
1214 list.Sort(TriggerSidOrderPredicate); |
|
1215 |
|
1216 TInt multipleOps = 0; |
|
1217 TInt totalTriggersModified = list.Count(); |
|
1218 |
|
1219 for( TInt i = totalTriggersModified - 1; i >= 0 ; --i ) |
|
1220 { |
|
1221 const TLbtTriggerId& id = list[i]->TriggerEntry()->Id(); |
|
1222 const TSecureId& sid = list[i]->ExtendedTriggerInfo()->OwnerSid(); |
|
1223 // Using ternary operator here to check if i is zero becoz then list[i -1] will |
|
1224 // be crossing the array boundary. |
|
1225 const TSecureId& prevSid = i ? list[i - 1]->ExtendedTriggerInfo()->OwnerSid() : TSecureId(0); |
|
1226 |
|
1227 if ( sid == prevSid ) |
|
1228 { |
|
1229 // The modification is on the same client as the previous one. |
|
1230 // Rather than sending the notification collate them into single event. |
|
1231 multipleOps++; |
|
1232 continue; |
|
1233 } |
|
1234 else |
|
1235 { |
|
1236 // The next trigger in list belongs to a different client. |
|
1237 // So reply back on the notification now. |
|
1238 // retrieve all notification messages of this client. |
|
1239 |
|
1240 while( !iNotificationMap->Retreive(message, sid, aServiceId) ) |
|
1241 { |
|
1242 array.Append(message); |
|
1243 } |
|
1244 |
|
1245 SetNotificationEventType(aOperation, event); |
|
1246 |
|
1247 if ( multipleOps ) |
|
1248 { |
|
1249 event.iEventType = ELbtTriggerChangeEventMultiple; |
|
1250 } |
|
1251 |
|
1252 event.iTriggerId = id; |
|
1253 // Respond with the change structure on all registered IPC's |
|
1254 for(TInt j = array.Count(); j ; --j) |
|
1255 { |
|
1256 TPckgBuf<TLbtTriggerChangeEvent> changeEvent(event); |
|
1257 if(LbtGlobal::Write(array[j - 1], KParamChangeEvent, changeEvent) == KErrNone) |
|
1258 { |
|
1259 LbtGlobal::RequestComplete(array[j - 1], KErrNone); |
|
1260 } |
|
1261 } |
|
1262 array.Close(); |
|
1263 |
|
1264 multipleOps = 0; |
|
1265 } |
|
1266 } |
|
1267 |
|
1268 // Retrieve all management Notification messages |
|
1269 // Retrieve all management notification messages. |
|
1270 while(!iNotificationMap->Retreive(message, |
|
1271 aServiceId, |
|
1272 CLbtServerLogicBase::TLbtManagementLibrary)) |
|
1273 { |
|
1274 array.Append(message); |
|
1275 } |
|
1276 |
|
1277 if ( totalTriggersModified > 1 ) |
|
1278 { |
|
1279 event.iEventType = ELbtTriggerChangeEventMultiple; |
|
1280 event.iTriggerId = 0; |
|
1281 } |
|
1282 |
|
1283 // Respond with the change structure on all registered IPC's |
|
1284 for(TInt j = array.Count(); j ; --j) |
|
1285 { |
|
1286 TPckgBuf<TLbtTriggerChangeEvent> changeEvent(event); |
|
1287 if(LbtGlobal::Write(array[j - 1], KParamChangeEvent, changeEvent) == KErrNone) |
|
1288 { |
|
1289 LbtGlobal::RequestComplete(array[j - 1], KErrNone); |
|
1290 } |
|
1291 } |
|
1292 array.Close(); |
|
1293 } |
|
1294 |
|
1295 |
|
1296 |
|
1297 void CLbtServerLogic::SetNotificationEventType( |
|
1298 CLbtAOOperationBase* aOperation, |
|
1299 TLbtTriggerChangeEvent& aEvent ) |
|
1300 { |
|
1301 FUNC_ENTER("CLbtServerLogic::SetNotificationEventType"); |
|
1302 switch(aOperation->GetFunction()) |
|
1303 { |
|
1304 case ELbtCreateTrigger: |
|
1305 { |
|
1306 aEvent.iEventType = ELbtTriggerChangeEventCreated; |
|
1307 break; |
|
1308 } |
|
1309 case ELbtSetTriggerState: |
|
1310 case ELbtUpdateTrigger: |
|
1311 { |
|
1312 // Just one trigger has been updated |
|
1313 aEvent.iEventType = ELbtTriggerChangeEventUpdated; |
|
1314 break; |
|
1315 } |
|
1316 case ELbtDeleteTrigger: |
|
1317 { |
|
1318 aEvent.iEventType = ELbtTriggerChangeEventDeleted; |
|
1319 break; |
|
1320 } |
|
1321 case ELbtSetTriggersState: |
|
1322 case ELbtDeleteTriggers: |
|
1323 default: |
|
1324 { |
|
1325 // Multiple triggers have been updated |
|
1326 aEvent.iEventType = ELbtTriggerChangeEventMultiple; |
|
1327 break; |
|
1328 } |
|
1329 } |
|
1330 } |
|
1331 |
|
1332 TInt CLbtServerLogic::GetTriggeringSystemSettings( |
|
1333 const RMessage2& aMessage, |
|
1334 TSubSessionType aClientType ) |
|
1335 { |
|
1336 FUNC_ENTER("CLbtServerLogic::GetTriggeringSystemSettings"); |
|
1337 // The request can be either through LT client API or LT management API. |
|
1338 // and the handling has to be slightly different depending on the client type. |
|
1339 switch ( aClientType ) |
|
1340 { |
|
1341 case TLbtManagementLibrary: |
|
1342 { |
|
1343 // This is the req from the LT client API, Hence return only |
|
1344 // the min trigger area and triggering engine state ( On/Off ). |
|
1345 TLbtTriggeringSystemManagementSettings settings; |
|
1346 |
|
1347 settings.SetMinimumTriggerAreaSize( |
|
1348 iSettingsManager->MinimumTriggeringArea()); |
|
1349 |
|
1350 TLbtTriggeringMechanismState state = |
|
1351 static_cast<TLbtTriggeringMechanismState>( |
|
1352 iSettingsManager->GetTriggeringMechanismState()); |
|
1353 settings.SetTriggeringMechanismState(state); |
|
1354 |
|
1355 settings.SetMinimumLocationUpdateInterval( |
|
1356 iSettingsManager->GetMinimumUpdateInterval() ); |
|
1357 |
|
1358 settings.SetMinimumLocationUpdateIntervalWhenGpsFails( |
|
1359 iSettingsManager->GetMinimumUpdateIntervalOnGpsFailure() ); |
|
1360 |
|
1361 settings.SetUsedPositioningModule( |
|
1362 iSettingsManager->GetModuleId() ); |
|
1363 |
|
1364 settings.SetMaximumUserSpeed( |
|
1365 iSettingsManager->GetMaximumUserSpeed() ); |
|
1366 |
|
1367 TPckg<TLbtTriggeringSystemManagementSettings> pckgSettings(settings); |
|
1368 return LbtGlobal::Write(aMessage, KParamSettings, pckgSettings); |
|
1369 } |
|
1370 |
|
1371 |
|
1372 case TLbtClientLibrary: |
|
1373 { |
|
1374 // This is the req from the LT client API, Hence return only |
|
1375 // the min trigger area and triggering engine state ( On/Off ). |
|
1376 TLbtTriggeringSystemSettings settings; |
|
1377 |
|
1378 settings.SetMinimumTriggerAreaSize( |
|
1379 iSettingsManager->MinimumTriggeringArea() ); |
|
1380 |
|
1381 TLbtTriggeringMechanismState state = |
|
1382 static_cast<TLbtTriggeringMechanismState>( |
|
1383 iSettingsManager->GetTriggeringMechanismState()); |
|
1384 |
|
1385 settings.SetTriggeringMechanismState(state); |
|
1386 |
|
1387 TPckg<TLbtTriggeringSystemSettings> pckgSettings(settings); |
|
1388 return LbtGlobal::Write(aMessage, KParamSettings, pckgSettings); |
|
1389 } |
|
1390 default : |
|
1391 // This is a bug in server implementation. There is no other |
|
1392 // session type as of now. Hence treating this as a LT API |
|
1393 // client. |
|
1394 |
|
1395 // Note : Fall through is intended |
|
1396 break; |
|
1397 |
|
1398 } |
|
1399 return KErrNotSupported; |
|
1400 } |
|
1401 |
|
1402 void CLbtServerLogic::GetTriggeringSysStatus( TLbtTriggeringSystemStatus& aSystemStatus ) |
|
1403 { |
|
1404 FUNC_ENTER("CLbtServerLogic::GetTriggeringSysStatus"); |
|
1405 aSystemStatus.iLocationAcquisitionStatus = iStrategyDynamicInfo.iLocationAcquisitionStatus; |
|
1406 |
|
1407 aSystemStatus.iPositioningMethod = iSettingsManager->GetModuleId(); |
|
1408 |
|
1409 //aSystemStatus.iPositioningMethodName |
|
1410 |
|
1411 TPosition position; |
|
1412 iStrategyDynamicInfo.iLatestAcquiredPosInfo.GetPosition( position ); |
|
1413 aSystemStatus.iLatestLocationUpdate = position.Time(); |
|
1414 } |
|
1415 |
|
1416 |
|
1417 void CLbtServerLogic::SetTriggeringSystemSettings( |
|
1418 TLbtTriggeringSystemManagementSettings& aSettings, |
|
1419 TLbtManagementSettingsMask aSettingsMask ) |
|
1420 { |
|
1421 FUNC_ENTER("CLbtServerLogic::SetTriggeringSystemSettings"); |
|
1422 if ( aSettingsMask & EMinimumLocationUpdateInterval ) |
|
1423 { |
|
1424 iSettingsManager->SetMinimumUpdateInterval( aSettings.MinimumLocationUpdateInterval() ); |
|
1425 } |
|
1426 if ( aSettingsMask & EMinimumLocationUpdateIntervalWhenGpsFails ) |
|
1427 { |
|
1428 iSettingsManager->SetMinimumUpdateIntervalOnGpsFailure( aSettings.MinimumLocationUpdateIntervalWhenGpsFails() ); |
|
1429 } |
|
1430 if ( aSettingsMask & EUsedPositioningmodule ) |
|
1431 { |
|
1432 iSettingsManager->SetModuleId( aSettings.UsedPositioningModule() ); |
|
1433 } |
|
1434 if ( aSettingsMask & EMaximumUserSpeed ) |
|
1435 { |
|
1436 iSettingsManager->SetMaximumUserSpeed( aSettings.MaximumUserSpeed() ); |
|
1437 } |
|
1438 if ( aSettingsMask & ETriggeringMechanismState ) |
|
1439 { |
|
1440 iSettingsManager->SetTriggeringMechanismState( aSettings.TriggeringMechanismState() ); |
|
1441 } |
|
1442 |
|
1443 |
|
1444 if( aSettings.TriggeringMechanismState() == ETriggeringMechanismOff ) |
|
1445 { |
|
1446 if( iStratergyContainer->Stratergy() ) |
|
1447 { |
|
1448 iStratergyContainer->UnloadStratergy(); |
|
1449 } |
|
1450 iStrategyDynamicInfo.iLocationAcquisitionStatus = ELocationAcquisitionOff; |
|
1451 |
|
1452 // Change the status information to supervision off |
|
1453 iProperty.Set(KPSUidLbtStatusInformation, |
|
1454 KLbtLocationTriggeringSupervisionStatus, |
|
1455 ELbtLocationTriggeringSupervisionOff); |
|
1456 |
|
1457 NotifyTriggeringSystemStatusChange(); |
|
1458 } |
|
1459 else |
|
1460 { |
|
1461 if(!iStratergyContainer->Stratergy() && |
|
1462 iContainer->GetCountOfEnabledAndValidTriggers() && |
|
1463 !iBackupRestoreListener->IsBackupRestoreOperationInProgress()) |
|
1464 { |
|
1465 TRAPD(error,iStratergyContainer->LoadStratergyL(this)); |
|
1466 if( KErrNone == error ) |
|
1467 { |
|
1468 iStratergyContainer->Stratergy()->StartSupervision(); |
|
1469 iStrategyDynamicInfo.iLocationAcquisitionStatus = ELocationAcquisitionActive; |
|
1470 NotifyTriggeringSystemStatusChange(); |
|
1471 } |
|
1472 } |
|
1473 else |
|
1474 { |
|
1475 // Change the status information to supervision off |
|
1476 iProperty.Set(KPSUidLbtStatusInformation, |
|
1477 KLbtLocationTriggeringSupervisionStatus, |
|
1478 ELbtLocationTriggeringSupervisionNotActive); |
|
1479 } |
|
1480 } |
|
1481 |
|
1482 // ToDo : the management header does not have this optimization level. Hence fix in the management lib |
|
1483 // iSettingsManager->SetOptimizationLevel( ); |
|
1484 |
|
1485 // Inform Strategy that the Triggering Engine Settings have changed. |
|
1486 // These settings values might affect the behaviour of the supervision algorithm. |
|
1487 CLbtStrategyBase* strategy = iStratergyContainer->Stratergy(); |
|
1488 if ( strategy ) |
|
1489 { |
|
1490 strategy->TriggeringSupervisionSettingsChanged(); |
|
1491 } |
|
1492 |
|
1493 //ToDo : we also need to notify clients that the triggering settings has changed. |
|
1494 NotifyTriggeringSystemSettingChange(aSettingsMask); |
|
1495 } |
|
1496 |
|
1497 void CLbtServerLogic::NotifyTriggeringSystemSettingChange(TLbtManagementSettingsMask aSettingsMask ) |
|
1498 { |
|
1499 FUNC_ENTER("CLbtServerLogic::NotifyTriggeringSystemSettingChange"); |
|
1500 RArray<RMessage2> messageArray; |
|
1501 RMessage2 message; |
|
1502 if((aSettingsMask & ETriggeringMechanismState)) |
|
1503 { |
|
1504 while( !iNotificationMap->Retreive(message,ELbtNotifyTriggeringSysSettingChange, |
|
1505 CLbtServerLogicBase::TLbtClientLibrary)) |
|
1506 { |
|
1507 messageArray.Append( message ); |
|
1508 } |
|
1509 if(messageArray.Count()) |
|
1510 { |
|
1511 TLbtTriggeringSystemSettings triggeringSystemSettings; |
|
1512 if(iSettingsManager->GetTriggeringMechanismState()==1) |
|
1513 { |
|
1514 triggeringSystemSettings.SetTriggeringMechanismState(ETriggeringMechanismOn); |
|
1515 } |
|
1516 else |
|
1517 { |
|
1518 triggeringSystemSettings.SetTriggeringMechanismState(ETriggeringMechanismOff); |
|
1519 } |
|
1520 triggeringSystemSettings.SetMinimumTriggerAreaSize( |
|
1521 iSettingsManager->MinimumTriggeringArea()); |
|
1522 TPckg<TLbtTriggeringSystemSettings> pckSystemSettings(triggeringSystemSettings); |
|
1523 for(TInt i=messageArray.Count();i>0;i--) |
|
1524 { |
|
1525 LbtGlobal::Write(messageArray[i-1],0,pckSystemSettings); |
|
1526 LbtGlobal::RequestComplete(messageArray[i-1],KErrNone); |
|
1527 } |
|
1528 } |
|
1529 } |
|
1530 messageArray.Reset(); |
|
1531 while( !iNotificationMap->Retreive(message,ELbtNotifyTriggeringSysSettingChange, |
|
1532 CLbtServerLogicBase::TLbtManagementLibrary)) |
|
1533 { |
|
1534 messageArray.Append( message ); |
|
1535 } |
|
1536 if(messageArray.Count()) |
|
1537 { |
|
1538 TLbtTriggeringSystemManagementSettings triggeringSystemManagementSettings; |
|
1539 if(iSettingsManager->GetTriggeringMechanismState()==1) |
|
1540 { |
|
1541 triggeringSystemManagementSettings.SetTriggeringMechanismState(ETriggeringMechanismOn); |
|
1542 } |
|
1543 else |
|
1544 { |
|
1545 triggeringSystemManagementSettings.SetTriggeringMechanismState(ETriggeringMechanismOff); |
|
1546 } |
|
1547 triggeringSystemManagementSettings.SetMinimumTriggerAreaSize( |
|
1548 iSettingsManager->MinimumTriggeringArea()); |
|
1549 triggeringSystemManagementSettings.SetMinimumLocationUpdateInterval( |
|
1550 iSettingsManager->GetMinimumUpdateInterval()); |
|
1551 triggeringSystemManagementSettings.SetMinimumLocationUpdateIntervalWhenGpsFails( |
|
1552 iSettingsManager->GetMinimumUpdateIntervalOnGpsFailure()); |
|
1553 triggeringSystemManagementSettings.SetUsedPositioningModule( |
|
1554 iSettingsManager->GetModuleId()); |
|
1555 triggeringSystemManagementSettings.SetMaximumUserSpeed( |
|
1556 iSettingsManager->GetMaximumUserSpeed()); |
|
1557 TPckg<TLbtTriggeringSystemManagementSettings> pckSystemManagementSettings( |
|
1558 triggeringSystemManagementSettings); |
|
1559 for(TInt i=messageArray.Count();i>0;i--) |
|
1560 { |
|
1561 LbtGlobal::Write(messageArray[i-1],0,pckSystemManagementSettings); |
|
1562 LbtGlobal::RequestComplete(messageArray[i-1],KErrNone); |
|
1563 } |
|
1564 } |
|
1565 messageArray.Close(); |
|
1566 } |
|
1567 |
|
1568 void CLbtServerLogic::NotifyTriggeringSystemStatusChange() |
|
1569 { |
|
1570 FUNC_ENTER("CLbtServerLogic::NotifyTriggeringSystemStatusChange"); |
|
1571 RArray<RMessage2> messageArray; |
|
1572 RMessage2 message; |
|
1573 |
|
1574 while( !iNotificationMap->Retreive(message,ELbtNotifyTriggeringSysStatusChange, |
|
1575 CLbtServerLogicBase::TLbtClientLibrary)) |
|
1576 { |
|
1577 messageArray.Append( message ); |
|
1578 } |
|
1579 if( messageArray.Count() ) |
|
1580 { |
|
1581 for(TInt i=messageArray.Count();i>0;i--) |
|
1582 { |
|
1583 LbtGlobal::RequestComplete(messageArray[i-1],KErrNotSupported); |
|
1584 } |
|
1585 messageArray.Reset(); |
|
1586 } |
|
1587 |
|
1588 while( !iNotificationMap->Retreive(message,ELbtNotifyTriggeringSysStatusChange, |
|
1589 CLbtServerLogicBase::TLbtManagementLibrary)) |
|
1590 { |
|
1591 messageArray.Append( message ); |
|
1592 } |
|
1593 if( messageArray.Count() ) |
|
1594 { |
|
1595 for(TInt i=messageArray.Count();i>0;i--) |
|
1596 { |
|
1597 LbtGlobal::RequestComplete(messageArray[i-1],KErrNone); |
|
1598 } |
|
1599 } |
|
1600 messageArray.Close(); |
|
1601 } |
|
1602 |
|
1603 // --------------------------------------------------------------------------- |
|
1604 // CLbtServerLogic::HandleTriggersChange |
|
1605 // --------------------------------------------------------------------------- |
|
1606 // |
|
1607 void CLbtServerLogic::HandleTriggersChange( RArray<TLbtTriggerId>& aTriggerIds, |
|
1608 RArray<TUid>& aManagerUids, |
|
1609 TLbtTriggerEventMask aEventMask ) |
|
1610 { |
|
1611 FUNC_ENTER("CLbtServerLogic::HandleContainerTriggerChange"); |
|
1612 RMessage2 message; |
|
1613 |
|
1614 TLbtTriggerChangeEvent event; |
|
1615 // If there is change in the single trigger, set the trigger id else |
|
1616 // update KLbtNullTriggerId for trigger id |
|
1617 if( aTriggerIds.Count() == 1) |
|
1618 { |
|
1619 event.iTriggerId = aTriggerIds[0]; |
|
1620 } |
|
1621 else |
|
1622 { |
|
1623 event.iTriggerId = KLbtNullTriggerId; |
|
1624 } |
|
1625 |
|
1626 // Check for type of notification |
|
1627 if( aEventMask & CLbtContainer::ELbtConTriggerDeleted && |
|
1628 aEventMask & CLbtContainer::ELbtConTriggerValidityFieldChanged ) |
|
1629 { |
|
1630 event.iEventType = ELbtTriggerChangeEventMultiple; |
|
1631 } |
|
1632 else if( aEventMask & CLbtContainer::ELbtConTriggerDeleted ) |
|
1633 { |
|
1634 event.iEventType = ELbtTriggerChangeEventDeleted; |
|
1635 } |
|
1636 else if ( aEventMask & CLbtContainer::ELbtConTriggerValidityFieldChanged ) |
|
1637 { |
|
1638 event.iEventType = ELbtTriggerChangeEventUpdated; |
|
1639 } |
|
1640 TPckgBuf<TLbtTriggerChangeEvent> changeEvent(event); |
|
1641 |
|
1642 for( TInt i=0;i<aManagerUids.Count();i++ ) |
|
1643 { |
|
1644 TSecureId secureId(aManagerUids[i]); |
|
1645 // Retrieve all client session trigger change notification messages. |
|
1646 while(!iNotificationMap->Retreive(message, secureId, ELbtNotifyTriggerChangeEvent) ) |
|
1647 { |
|
1648 if(LbtGlobal::Write(message, KParamChangeEvent, changeEvent) == KErrNone) |
|
1649 { |
|
1650 LbtGlobal::RequestComplete(message, KErrNone); |
|
1651 } |
|
1652 } |
|
1653 } |
|
1654 |
|
1655 // Retrieve all management library notification messages |
|
1656 while( !iNotificationMap->Retreive( message,ELbtNotifyTriggerChangeEvent, |
|
1657 CLbtServerLogicBase::TLbtManagementLibrary ) ) |
|
1658 { |
|
1659 if(LbtGlobal::Write(message, KParamChangeEvent, changeEvent) == KErrNone) |
|
1660 { |
|
1661 LbtGlobal::RequestComplete(message, KErrNone); |
|
1662 } |
|
1663 } |
|
1664 |
|
1665 |
|
1666 TRAP_IGNORE(LoadOrUnloadStrategyPluginL()); |
|
1667 } |
|
1668 // end of file |