|
1 /* |
|
2 * Copyright (c) 2003-2005 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: Implements API for consumer application to access Application |
|
15 * Interworking Framework. |
|
16 * |
|
17 */ |
|
18 |
|
19 |
|
20 |
|
21 |
|
22 #include <eikenv.h> |
|
23 #include <aiwservicehandler.rsg> |
|
24 #include <EIKON.HRH> |
|
25 #include "AiwMenuBinding.h" |
|
26 #include "AiwServiceHandlerImpl.h" |
|
27 #include "AiwMenu.h" |
|
28 #include "AiwUids.hrh" |
|
29 #include "AiwCommon.hrh" |
|
30 #include "AiwMenuSlot.hrh" |
|
31 #include "AiwEcomMonitor.h" |
|
32 #include "AiwTlsData.h" |
|
33 #include "data_caging_path_literals.hrh" |
|
34 |
|
35 // CONSTANTS |
|
36 // Max number of empty menu resource slots. |
|
37 const TInt KMaxMenuResources = 16; |
|
38 |
|
39 // This value tells how many times consumer can call InitializeMenuPaneL() without |
|
40 // closing the Options-menu. |
|
41 const TInt KMaxPaneIds = KMaxMenuResources; |
|
42 |
|
43 // The range reserved for individual menu pane. |
|
44 const TInt KIndividualMenuPaneIdRange = 10000; |
|
45 |
|
46 // The whole range that is reserved to all menu panes. Currently value is 170 000. |
|
47 const TInt KMenuPaneCommandRange = (KMaxMenuResources + 1) * KIndividualMenuPaneIdRange; |
|
48 |
|
49 _LIT(KAiwResourceFile, "AiwServiceHandler.rSC"); |
|
50 _LIT(KAiwZDrive, "z:"); |
|
51 |
|
52 const TInt KMaxMenuTitleSize = 100; |
|
53 |
|
54 // Command id space reserved for single placeholder. |
|
55 const TInt KPlaceholderCmdIdRange = 200; |
|
56 |
|
57 void Cleanup(TAny* aAny); |
|
58 void InterestCleanup(TAny* aAny); |
|
59 void IntArrayCleanup(TAny* aAny); |
|
60 void FilteredCleanup(TAny* aAny); |
|
61 |
|
62 |
|
63 // |
|
64 // AiwServiceHandler |
|
65 // |
|
66 |
|
67 CAiwServiceHandlerImpl* CAiwServiceHandlerImpl::NewL() |
|
68 { |
|
69 CAiwServiceHandlerImpl* handler = new (ELeave) CAiwServiceHandlerImpl(); |
|
70 CleanupStack::PushL( handler ); |
|
71 handler->ConstructL(); |
|
72 CleanupStack::Pop(); // handler |
|
73 return handler; |
|
74 } |
|
75 |
|
76 |
|
77 |
|
78 CAiwServiceHandlerImpl::CAiwServiceHandlerImpl() |
|
79 { |
|
80 // Nothing to do here. |
|
81 } |
|
82 |
|
83 |
|
84 |
|
85 void CAiwServiceHandlerImpl::ConstructL() |
|
86 { |
|
87 TFileName resFile; |
|
88 |
|
89 TCallBack callBack(SynchronizeCallBack, this); |
|
90 iEcomMonitor = CAiwEcomMonitor::NewL(callBack); |
|
91 |
|
92 resFile.Copy(KAiwZDrive); |
|
93 resFile.Append(KDC_RESOURCE_FILES_DIR); |
|
94 resFile.Append(KAiwResourceFile); |
|
95 |
|
96 iCoeEnv = CCoeEnv::Static(); |
|
97 |
|
98 // A Service Handler instance can be created also when CCoeEnv is not |
|
99 // available (e.g. from server applications). In this case, the methods |
|
100 // needing CCoeEnv/CEikonEnv will leave with KErrNotSupported. |
|
101 if(iCoeEnv) |
|
102 { |
|
103 iResourceOffset = iCoeEnv->AddResourceFileL(resFile); |
|
104 } |
|
105 |
|
106 // CAiwTlsData has a reference count so each OpenL call |
|
107 // must have a matching Close call (done in destructor). |
|
108 // OpenL is called only here, the TLS data object can be |
|
109 // referenced by calling CAiwTlsData::Instance(). |
|
110 CAiwTlsData* data = CAiwTlsData::OpenL(); |
|
111 iTlsDataOpened = ETrue; |
|
112 |
|
113 // CEikMenuPane informs all menu launch observers |
|
114 // when an options menu is launched. |
|
115 data->AddMenuLaunchObserverL( this ); |
|
116 } |
|
117 |
|
118 |
|
119 |
|
120 CAiwServiceHandlerImpl::~CAiwServiceHandlerImpl() |
|
121 { |
|
122 if (iResourceOffset && iCoeEnv) |
|
123 { |
|
124 iCoeEnv->DeleteResourceFile(iResourceOffset); |
|
125 } |
|
126 Reset(); |
|
127 |
|
128 delete iEcomMonitor; |
|
129 |
|
130 if ( iTlsDataOpened ) |
|
131 { |
|
132 CAiwTlsData* data = CAiwTlsData::Instance(); |
|
133 data->RemoveMenuLaunchObserver( this ); |
|
134 CAiwTlsData::Close(); |
|
135 } |
|
136 } |
|
137 |
|
138 |
|
139 |
|
140 void CAiwServiceHandlerImpl::Reset() |
|
141 { |
|
142 iInterestList.ResetAndDestroy(); |
|
143 iMenuBindings.ResetAndDestroy(); |
|
144 iBaseBindings.ResetAndDestroy(); |
|
145 iProviders.ResetAndDestroy(); |
|
146 |
|
147 iLastInitialized.Reset(); |
|
148 |
|
149 iMenuPanes.ResetAndDestroy(); |
|
150 |
|
151 delete iInParams; |
|
152 iInParams = NULL; |
|
153 delete iOutParams; |
|
154 iOutParams = NULL; |
|
155 } |
|
156 |
|
157 |
|
158 |
|
159 void CAiwServiceHandlerImpl::ListProvidersForCriteriaL(RArray<TInt>& aResult, |
|
160 CAiwCriteriaItem& aItem) |
|
161 { |
|
162 TInt i; |
|
163 |
|
164 for (i = 0; i < iProviders.Count(); i++) |
|
165 { |
|
166 if (iProviders[i]->HasCriteria(aItem)) |
|
167 { |
|
168 User::LeaveIfError(aResult.Append(iProviders[i]->ImplementationUid().iUid)); |
|
169 } |
|
170 } |
|
171 } |
|
172 |
|
173 |
|
174 |
|
175 TInt CAiwServiceHandlerImpl::NbrOfProviders(const CAiwCriteriaItem* aCriteria) |
|
176 { |
|
177 if(!aCriteria) |
|
178 { |
|
179 return 0; |
|
180 } |
|
181 |
|
182 TInt i, j; |
|
183 |
|
184 for (i = 0; i < iBaseBindings.Count(); i++) |
|
185 { |
|
186 for (j = 0; j < iBaseBindings[i]->Interest().Count(); j++) |
|
187 { |
|
188 if ((*iBaseBindings[i]->Interest()[j]) == (*aCriteria)) |
|
189 { |
|
190 return iBaseBindings[i]->NumberOfProviders(); |
|
191 } |
|
192 } |
|
193 } |
|
194 |
|
195 for (i = 0; i < iMenuBindings.Count(); i++) |
|
196 { |
|
197 for (j = 0; j < iMenuBindings[i]->Interest().Count(); j++) |
|
198 { |
|
199 if ((*iMenuBindings[i]->Interest()[j]) == (*aCriteria)) |
|
200 { |
|
201 return iMenuBindings[i]->NumberOfProviders(); |
|
202 } |
|
203 } |
|
204 } |
|
205 |
|
206 return 0; |
|
207 } |
|
208 |
|
209 |
|
210 |
|
211 void CAiwServiceHandlerImpl::AttachL(TInt aInterestResourceId) |
|
212 { |
|
213 // CCoeEnv/CEikonEnv needs to be accessible. |
|
214 if(!iCoeEnv) |
|
215 { |
|
216 User::Leave(KErrNotSupported); |
|
217 } |
|
218 |
|
219 RCriteriaArray interest, filtered; |
|
220 |
|
221 CleanupStack::PushL( TCleanupItem( InterestCleanup, &interest ) ); |
|
222 CleanupStack::PushL( TCleanupItem( FilteredCleanup, &filtered ) ); |
|
223 |
|
224 TResourceReader reader; |
|
225 iCoeEnv->CreateResourceReaderLC(reader, aInterestResourceId); |
|
226 ReadInterestListL(reader, interest); |
|
227 CleanupStack::PopAndDestroy(); // reader |
|
228 |
|
229 FilterInterestListL(interest, filtered); |
|
230 |
|
231 DoAttachL(filtered); |
|
232 |
|
233 filtered.Reset(); |
|
234 |
|
235 CleanupStack::Pop(); // filtered |
|
236 CleanupStack::Pop(); // interest |
|
237 } |
|
238 |
|
239 |
|
240 |
|
241 void CAiwServiceHandlerImpl::AttachL(const RCriteriaArray& aInterest) |
|
242 { |
|
243 RCriteriaArray interest, filtered; |
|
244 |
|
245 CleanupStack::PushL( TCleanupItem( InterestCleanup, &interest ) ); |
|
246 CleanupStack::PushL( TCleanupItem( FilteredCleanup, &filtered ) ); |
|
247 |
|
248 for(TInt i = 0; i < aInterest.Count(); i++) |
|
249 { |
|
250 CAiwCriteriaItem* item = CAiwCriteriaItem::NewLC(); |
|
251 |
|
252 item->SetId( aInterest[i]->Id() ); |
|
253 item->SetServiceCmd( aInterest[i]->ServiceCmd() ); |
|
254 item->SetContentTypeL( aInterest[i]->ContentType() ); |
|
255 item->SetServiceClass( aInterest[i]->ServiceClass() ); |
|
256 item->SetOptions( aInterest[i]->Options() ); |
|
257 item->SetDefaultProvider( (aInterest[i]->DefaultProvider()).iUid ); |
|
258 item->SetMaxProviders( aInterest[i]->MaxProviders() ); |
|
259 |
|
260 User::LeaveIfError(interest.Append(item)); |
|
261 CleanupStack::Pop(item); |
|
262 } |
|
263 |
|
264 FilterInterestListL(interest, filtered); |
|
265 |
|
266 DoAttachL(filtered); |
|
267 |
|
268 filtered.Reset(); |
|
269 |
|
270 CleanupStack::Pop(); // filtered |
|
271 CleanupStack::Pop(); // interest |
|
272 } |
|
273 |
|
274 |
|
275 |
|
276 void CAiwServiceHandlerImpl::DoAttachL(const RCriteriaArray& aInterest) |
|
277 { |
|
278 CAiwBinding* bind; |
|
279 for (TInt i = 0; i < aInterest.Count(); i++) |
|
280 { |
|
281 bind = CAiwBinding::NewLC(); |
|
282 |
|
283 if (ResolveProvidersL(bind, aInterest[i])) |
|
284 { |
|
285 User::LeaveIfError(iBaseBindings.Append( bind )); |
|
286 CleanupStack::Pop(); // bind |
|
287 bind->AddCriteriaL(aInterest[i]); |
|
288 |
|
289 // Initialise providers. |
|
290 for (TInt k = 0; k < bind->NumberOfProviders(); k++) |
|
291 { |
|
292 // Trap the initialisation. If not done, a leaving provider |
|
293 // could prevent the initialisation of other providers. |
|
294 TRAPD(err, bind->BaseProvider(k)->InitialiseL(*this, bind->Interest())); |
|
295 if(err) |
|
296 { |
|
297 #ifdef _DEBUG |
|
298 RDebug::Print(_L("AIW PROVIDER ERROR: CAiwServiceIfBase::InitialiseL() failed, leave code:%d"), err); |
|
299 #endif |
|
300 } |
|
301 } |
|
302 } |
|
303 else |
|
304 { |
|
305 CleanupStack::PopAndDestroy(); // bind |
|
306 } |
|
307 } |
|
308 } |
|
309 |
|
310 |
|
311 void CAiwServiceHandlerImpl::GetInterest(RCriteriaArray& aInterest) |
|
312 { |
|
313 for (TInt i = 0; i < iInterestList.Count(); i++) |
|
314 { |
|
315 if (aInterest.Append(iInterestList[i]) != KErrNone) |
|
316 { |
|
317 return; |
|
318 } |
|
319 } |
|
320 } |
|
321 |
|
322 |
|
323 |
|
324 void CAiwServiceHandlerImpl::DetachL(const RCriteriaArray& aInterest) |
|
325 { |
|
326 // First, remove relevant criteria items from relevat base bindings. |
|
327 for (TInt i = 0; i < aInterest.Count(); i++) |
|
328 { |
|
329 for (TInt j = 0; j < iBaseBindings.Count(); j++) |
|
330 { |
|
331 TInt index = iBaseBindings[j]->HasCriteriaItem(*aInterest[i]); |
|
332 if (index != KErrNotFound) |
|
333 { |
|
334 iBaseBindings[j]->RemoveCriteria(index); |
|
335 } |
|
336 } |
|
337 } |
|
338 |
|
339 // Second pass removes empty bindings. |
|
340 for (TInt i = 0; i < iBaseBindings.Count(); i++) |
|
341 { |
|
342 if (iBaseBindings[i]->Interest().Count() == 0) |
|
343 { |
|
344 delete iBaseBindings[i]; |
|
345 iBaseBindings.Remove(i); |
|
346 i--; |
|
347 } |
|
348 } |
|
349 |
|
350 // Then check if there were left obselete criteria items and remove them. |
|
351 RemoveObsoleteCriteriaItems(); |
|
352 |
|
353 // Finally check if there were left obselete providers and remove them. |
|
354 RemoveObsoleteProviders(); |
|
355 } |
|
356 |
|
357 |
|
358 |
|
359 void CAiwServiceHandlerImpl::DetachL(TInt aInterestResourceId) |
|
360 { |
|
361 // CCoeEnv/CEikonEnv needs to be accessible. |
|
362 if(!iCoeEnv) |
|
363 { |
|
364 User::Leave(KErrNotSupported); |
|
365 } |
|
366 |
|
367 RCriteriaArray interest; |
|
368 |
|
369 CleanupStack::PushL( TCleanupItem( InterestCleanup, &interest ) ); |
|
370 |
|
371 TResourceReader reader; |
|
372 iCoeEnv->CreateResourceReaderLC(reader, aInterestResourceId); |
|
373 ReadInterestListL(reader, interest); |
|
374 CleanupStack::PopAndDestroy(); // reader |
|
375 |
|
376 DetachL( interest ); |
|
377 |
|
378 interest.ResetAndDestroy(); |
|
379 CleanupStack::Pop(); // interest |
|
380 } |
|
381 |
|
382 |
|
383 const CAiwCriteriaItem* CAiwServiceHandlerImpl::GetCriteria(TInt aId) |
|
384 { |
|
385 for (TInt i = 0; i < iInterestList.Count(); i++) |
|
386 { |
|
387 if (iInterestList[i]->Id() == aId) |
|
388 { |
|
389 return iInterestList[i]; |
|
390 } |
|
391 } |
|
392 |
|
393 return NULL; |
|
394 } |
|
395 |
|
396 TInt CAiwServiceHandlerImpl::NumAlreadyInitializedPaneIdsL() const |
|
397 { |
|
398 TInt ret = 0; |
|
399 TInt paneIds[KMaxPaneIds] = {0}; |
|
400 TBool found = EFalse; |
|
401 |
|
402 for (TInt i = 0; i < iLastInitialized.Count(); i++) |
|
403 { |
|
404 found = EFalse; |
|
405 |
|
406 for (TInt j = 0; j < ret; j++) |
|
407 { |
|
408 if (iLastInitialized[i]->MenuResourceId() == paneIds[j]) |
|
409 { |
|
410 found = ETrue; |
|
411 break; |
|
412 } |
|
413 } |
|
414 |
|
415 if (!found) |
|
416 { |
|
417 // Create new item. |
|
418 if (ret >= KMaxPaneIds) |
|
419 { |
|
420 #ifdef _DEBUG |
|
421 RDebug::Print(_L("ERROR: OVERFLOW in CAiwServiceHandlerImpl::NumAlreadyInitializedPaneIdsL()")); |
|
422 #endif |
|
423 User::Leave(KErrOverflow); |
|
424 } |
|
425 paneIds[ret] = iLastInitialized[i]->MenuResourceId(); |
|
426 ret++; |
|
427 } |
|
428 } |
|
429 return ret; |
|
430 } |
|
431 |
|
432 void CAiwServiceHandlerImpl::InitializeMenuPaneL( |
|
433 CEikMenuPane& aMenuPane, |
|
434 TInt aMenuResourceId, |
|
435 TInt aBaseMenuCmdId, |
|
436 const CAiwGenericParamList& aInParamList) |
|
437 { |
|
438 InitializeMenuPaneL(aMenuPane, aMenuResourceId, aBaseMenuCmdId, |
|
439 aInParamList, EFalse, EFalse); |
|
440 } |
|
441 |
|
442 void CAiwServiceHandlerImpl::InitializeMenuPaneL( |
|
443 CEikMenuPane& aMenuPane, |
|
444 TInt aMenuResourceId, |
|
445 TInt aBaseMenuCmdId, |
|
446 const CAiwGenericParamList& aInParamList, |
|
447 TBool aUseSubmenuTextsIfAvailable) |
|
448 { |
|
449 InitializeMenuPaneL(aMenuPane, aMenuResourceId, aBaseMenuCmdId, aInParamList, aUseSubmenuTextsIfAvailable, EFalse); |
|
450 } |
|
451 |
|
452 |
|
453 void CAiwServiceHandlerImpl::InitializeMenuPaneL( |
|
454 CEikMenuPane& aMenuPane, |
|
455 TInt aMenuResourceId, |
|
456 TInt aBaseMenuCmdId, |
|
457 const CAiwGenericParamList& aInParamList, |
|
458 TBool aUseSubmenuTextsIfAvailable, |
|
459 TBool aSetAsItemSpecific) |
|
460 { |
|
461 // CCoeEnv/CEikonEnv needs to be accessible. |
|
462 if(!iCoeEnv) |
|
463 { |
|
464 User::Leave(KErrNotSupported); |
|
465 } |
|
466 |
|
467 if (!iMenuBindings.Count()) |
|
468 { |
|
469 // Either no menu is attached to interest or menu was attached but |
|
470 // it didn't contain any placeholders for criteria items. So |
|
471 // nothing to do, get out. |
|
472 return; |
|
473 } |
|
474 |
|
475 TInt index; |
|
476 TInt slotcmd; |
|
477 TBuf <KMaxMenuTitleSize> subTitle; |
|
478 TBool titleLocked; |
|
479 TInt paneOffset = NumAlreadyInitializedPaneIdsL() * KIndividualMenuPaneIdRange; |
|
480 |
|
481 iSubmenuCmd = aBaseMenuCmdId + KMenuPaneCommandRange; |
|
482 slotcmd = SlotItemCmd(aMenuPane); |
|
483 if (slotcmd >= 0) |
|
484 { |
|
485 // aMenuPane is aiw submenu. At this point it is empty and we must |
|
486 // copy provider menu items to it. |
|
487 CAiwMenuPane* aiwPane = MenuPaneForSlotCmd(slotcmd); |
|
488 if (aiwPane) |
|
489 { |
|
490 CopyMenuItemsL(aiwPane, aMenuPane, 0, ETrue, aSetAsItemSpecific); |
|
491 aMenuPane.DeleteMenuItem(slotcmd); |
|
492 iSubmenu = aiwPane; |
|
493 } |
|
494 } |
|
495 else |
|
496 { |
|
497 iSubmenu = NULL; |
|
498 |
|
499 const TInt bindcount = iMenuBindings.Count(); |
|
500 for (TInt i = 0; i < bindcount; i++) |
|
501 { |
|
502 if ((iMenuBindings[i]->MenuId() == aMenuResourceId) && |
|
503 (aMenuPane.MenuItemExists(iMenuBindings[i]->MenuCmd(), index))) |
|
504 { |
|
505 CAiwMenuPane* aiwPane = iMenuBindings[i]->MenuPane(); |
|
506 TInt menuResourceId = -1; |
|
507 if(aiwPane) |
|
508 { |
|
509 // An AIW menu pane already exists (this means that a normal |
|
510 // non-AIW submenu with AIW items has been opened more than once). |
|
511 // In this case we use the existing resource slot id. |
|
512 menuResourceId = aiwPane->ResourceSlotId(); |
|
513 paneOffset = aiwPane->PaneOffset(); |
|
514 DeleteAiwMenuPane(aiwPane); |
|
515 aiwPane = NULL; |
|
516 } |
|
517 aiwPane = CreateEmptyAiwMenuPaneL(aBaseMenuCmdId, menuResourceId); |
|
518 CleanupStack::PushL(aiwPane); |
|
519 aiwPane->SetPaneOffset(paneOffset); |
|
520 paneOffset += KPlaceholderCmdIdRange; |
|
521 iMenuBindings[i]->SetMenuPane(aiwPane); |
|
522 |
|
523 // Clean previous service commands from list. |
|
524 CAiwGenericParamList& list = const_cast<CAiwGenericParamList&>(aInParamList); |
|
525 while (list.Remove(EGenericParamServiceCommand)) |
|
526 { |
|
527 // Intentionally left empty. |
|
528 } |
|
529 |
|
530 // Add service commands for current placeholder. |
|
531 const TInt icount = iMenuBindings[i]->Interest().Count(); |
|
532 for (TInt k = 0; k < icount; k++) |
|
533 { |
|
534 list.AppendL(TAiwGenericParam(EGenericParamServiceCommand, |
|
535 TAiwVariant(iMenuBindings[i]->Interest()[k]->ServiceCmd()))); |
|
536 } |
|
537 |
|
538 // Loop from last entry to first entry always inserting to same index. |
|
539 // Default provider is the first item in list, so if there is a default |
|
540 // provider defined, it will be the first one to appear in menus. |
|
541 for (TInt j = iMenuBindings[i]->NumberOfProviders() - 1; j >= 0; j--) |
|
542 { |
|
543 aiwPane->SetInitializingOwner(iMenuBindings[i]->MenuProvider(j)); |
|
544 iMenuBindings[i]->MenuProvider(j)->InitializeMenuPaneHookL(aiwPane, |
|
545 0, 0, aInParamList); |
|
546 } |
|
547 |
|
548 GetSubmenuTitle(aiwPane->MenuPane(), subTitle); |
|
549 |
|
550 TAiwPlaceholderType phtype = PlaceholderType(aMenuPane, |
|
551 iMenuBindings[i]->MenuCmd(), titleLocked); |
|
552 |
|
553 if ((phtype == EAiwPlaceholderCascade) || |
|
554 (phtype == EAiwPlaceholderIntelligentCascade)) |
|
555 { |
|
556 if (aiwPane->MenuPane().NumberOfItemsInPane() == 1) |
|
557 { |
|
558 // Remove placeholder item. |
|
559 aMenuPane.DeleteMenuItem(iMenuBindings[i]->MenuCmd()); |
|
560 CleanupStack::PopAndDestroy(); // aiwPane |
|
561 continue; |
|
562 } |
|
563 else if ((aiwPane->MenuPane().NumberOfItemsInPane() == 2) && |
|
564 (phtype == EAiwPlaceholderIntelligentCascade)) |
|
565 { |
|
566 UnCascadeL(aMenuPane, iMenuBindings[i]->MenuCmd(), *aiwPane, aSetAsItemSpecific); |
|
567 User::LeaveIfError(iLastInitialized.Append(aiwPane)); |
|
568 } |
|
569 else |
|
570 { |
|
571 if (titleLocked) |
|
572 { |
|
573 subTitle.Zero(); |
|
574 } |
|
575 ConvertPlaceholderL(aMenuPane, iMenuBindings[i]->MenuCmd(), *aiwPane, |
|
576 subTitle, aSetAsItemSpecific); |
|
577 } |
|
578 } |
|
579 else |
|
580 { |
|
581 // Remove placeholder item. |
|
582 aMenuPane.DeleteMenuItem(iMenuBindings[i]->MenuCmd()); |
|
583 |
|
584 // Copy menu items to actual menu pane |
|
585 CopyMenuItemsL(aiwPane, aMenuPane, index, aUseSubmenuTextsIfAvailable, aSetAsItemSpecific); |
|
586 |
|
587 User::LeaveIfError(iLastInitialized.Append(aiwPane)); |
|
588 } |
|
589 aiwPane->SetMenuResourceId(aMenuResourceId); |
|
590 User::LeaveIfError(iMenuPanes.Append(aiwPane)); |
|
591 CleanupStack::Pop(); // aiwPane |
|
592 } |
|
593 } |
|
594 } |
|
595 } |
|
596 |
|
597 |
|
598 TInt CAiwServiceHandlerImpl::ServiceCmdByMenuCmd(TInt aMenuCmdId) const |
|
599 { |
|
600 for (TInt i = 0; i < iMenuBindings.Count(); i++) |
|
601 { |
|
602 if ((IsInLastInitialized(iMenuBindings[i]->MenuPane())) && |
|
603 (iMenuBindings[i]->MenuPane()->IsCmdInRange(KPlaceholderCmdIdRange, aMenuCmdId))) |
|
604 { |
|
605 return iMenuBindings[i]->MenuPane()->ServiceCmdId(aMenuCmdId); |
|
606 } |
|
607 } |
|
608 |
|
609 return 0; |
|
610 } |
|
611 |
|
612 |
|
613 |
|
614 void CAiwServiceHandlerImpl::ExecuteMenuCmdL( |
|
615 TInt aMenuCmdId, |
|
616 const CAiwGenericParamList& aInParamList, |
|
617 CAiwGenericParamList& aOutParamList, |
|
618 TUint aCmdOptions, |
|
619 MAiwNotifyCallback* aCallback) |
|
620 { |
|
621 // CCoeEnv/CEikonEnv needs to be accessible. |
|
622 if(!iCoeEnv) |
|
623 { |
|
624 User::Leave(KErrNotSupported); |
|
625 } |
|
626 |
|
627 if (!iMenuBindings.Count()) |
|
628 { |
|
629 return; |
|
630 } |
|
631 |
|
632 // Handle real menu providers. |
|
633 for (TInt i = 0; i < iMenuBindings.Count(); i++) |
|
634 { |
|
635 CAiwMenuPane* menuPane = iMenuBindings[i]->MenuPane(); |
|
636 |
|
637 if (IsInLastInitialized(menuPane)) |
|
638 { |
|
639 for (TInt j = 0; j < iMenuBindings[i]->NumberOfProviders(); j++) |
|
640 { |
|
641 if ((menuPane->IsCmdInRange(KPlaceholderCmdIdRange, aMenuCmdId)) && |
|
642 (menuPane->CommandOwner(aMenuCmdId) == iMenuBindings[i]->MenuProvider(j))) |
|
643 { |
|
644 iMenuBindings[i]->MenuProvider(j)->HandleMenuCmdHookL( |
|
645 menuPane, |
|
646 aMenuCmdId, |
|
647 aInParamList, |
|
648 aOutParamList, |
|
649 aCmdOptions, |
|
650 aCallback); |
|
651 return; |
|
652 } |
|
653 } |
|
654 } |
|
655 } |
|
656 } |
|
657 |
|
658 |
|
659 |
|
660 void CAiwServiceHandlerImpl::AttachMenuL(TInt aMenuResourceId, TInt aInterestResourceId) |
|
661 { |
|
662 // CCoeEnv/CEikonEnv needs to be accessible. |
|
663 if(!iCoeEnv) |
|
664 { |
|
665 User::Leave(KErrNotSupported); |
|
666 } |
|
667 |
|
668 RCriteriaArray interest, filtered; |
|
669 TResourceReader reader; |
|
670 |
|
671 CleanupStack::PushL( TCleanupItem( InterestCleanup, &interest ) ); |
|
672 CleanupStack::PushL( TCleanupItem( FilteredCleanup, &filtered ) ); |
|
673 iCoeEnv->CreateResourceReaderLC(reader, aInterestResourceId); |
|
674 ReadInterestListL(reader, interest); |
|
675 CleanupStack::PopAndDestroy(); // reader |
|
676 FilterInterestListL(interest, filtered); |
|
677 |
|
678 iCoeEnv->CreateResourceReaderLC(reader, aMenuResourceId); |
|
679 DoAttachMenuL(reader, aMenuResourceId, filtered); |
|
680 filtered.Reset(); |
|
681 CleanupStack::PopAndDestroy(); // reader |
|
682 CleanupStack::Pop(); // filtered |
|
683 CleanupStack::Pop(); // interest |
|
684 } |
|
685 |
|
686 |
|
687 |
|
688 void CAiwServiceHandlerImpl::AttachMenuL(TInt aMenuResourceId, TResourceReader& aReader) |
|
689 { |
|
690 // CCoeEnv/CEikonEnv needs to be accessible. |
|
691 if(!iCoeEnv) |
|
692 { |
|
693 User::Leave(KErrNotSupported); |
|
694 } |
|
695 |
|
696 RCriteriaArray interest, filtered; |
|
697 TResourceReader reader; |
|
698 |
|
699 CleanupStack::PushL( TCleanupItem( InterestCleanup, &interest ) ); |
|
700 CleanupStack::PushL( TCleanupItem( FilteredCleanup, &filtered ) ); |
|
701 ReadInterestListL(aReader, interest); |
|
702 FilterInterestListL(interest, filtered); |
|
703 |
|
704 iCoeEnv->CreateResourceReaderLC(reader, aMenuResourceId); |
|
705 DoAttachMenuL(reader, aMenuResourceId, filtered); |
|
706 filtered.Reset(); |
|
707 CleanupStack::PopAndDestroy(); // reader |
|
708 CleanupStack::Pop(); // filtered |
|
709 CleanupStack::Pop(); // interest |
|
710 } |
|
711 |
|
712 |
|
713 void CAiwServiceHandlerImpl::AttachMenuL(TInt aMenuResourceId, const RCriteriaArray& aInterest) |
|
714 { |
|
715 // CCoeEnv/CEikonEnv needs to be accessible. |
|
716 if(!iCoeEnv) |
|
717 { |
|
718 User::Leave(KErrNotSupported); |
|
719 } |
|
720 |
|
721 RCriteriaArray interest, filtered; |
|
722 TResourceReader reader; |
|
723 |
|
724 CleanupStack::PushL( TCleanupItem( InterestCleanup, &interest ) ); |
|
725 CleanupStack::PushL( TCleanupItem( FilteredCleanup, &filtered ) ); |
|
726 |
|
727 for(TInt i = 0; i < aInterest.Count(); i++) |
|
728 { |
|
729 CAiwCriteriaItem* item = CAiwCriteriaItem::NewLC(); |
|
730 |
|
731 item->SetId( aInterest[i]->Id() ); |
|
732 item->SetServiceCmd( aInterest[i]->ServiceCmd() ); |
|
733 item->SetContentTypeL( aInterest[i]->ContentType() ); |
|
734 item->SetServiceClass( aInterest[i]->ServiceClass() ); |
|
735 item->SetOptions( aInterest[i]->Options() ); |
|
736 item->SetDefaultProvider( (aInterest[i]->DefaultProvider()).iUid ); |
|
737 item->SetMaxProviders( aInterest[i]->MaxProviders() ); |
|
738 |
|
739 User::LeaveIfError(interest.Append(item)); |
|
740 CleanupStack::Pop(item); |
|
741 } |
|
742 |
|
743 FilterInterestListL(interest, filtered); |
|
744 |
|
745 iCoeEnv->CreateResourceReaderLC(reader, aMenuResourceId); |
|
746 DoAttachMenuL(reader, aMenuResourceId, filtered); |
|
747 filtered.Reset(); |
|
748 CleanupStack::PopAndDestroy(); // reader |
|
749 CleanupStack::Pop(); // filtered |
|
750 CleanupStack::Pop(); // interest |
|
751 } |
|
752 |
|
753 |
|
754 void CAiwServiceHandlerImpl::DoAttachMenuL(TResourceReader& aReader, TInt aMenuId, |
|
755 RCriteriaArray& aInterest) |
|
756 { |
|
757 TInt menuCmd; |
|
758 TInt count = aReader.ReadInt16(); |
|
759 TBool bound; |
|
760 |
|
761 for (TInt i = 0; i < count; i++) |
|
762 { |
|
763 menuCmd = aReader.ReadInt32(); |
|
764 CAiwMenuBinding* bind = NULL; |
|
765 bound = EFalse; |
|
766 |
|
767 for (TInt j = 0; j < aInterest.Count(); j++) |
|
768 { |
|
769 if (aInterest[j]->Id() == menuCmd) |
|
770 { |
|
771 if (!bind) |
|
772 { |
|
773 bind = AlreadyBound(aMenuId, menuCmd, i); |
|
774 if (!bind) |
|
775 { |
|
776 bind = CAiwMenuBinding::NewLC(i, aMenuId); |
|
777 bind->SetMenuCmd( menuCmd ); |
|
778 } |
|
779 else |
|
780 { |
|
781 bound = ETrue; |
|
782 } |
|
783 } |
|
784 |
|
785 if (bind->HasCriteriaItem(*(aInterest[j])) == KErrNotFound) |
|
786 { |
|
787 ResolveProvidersL(bind, aInterest[j]); |
|
788 bind->AddCriteriaL(aInterest[j]); |
|
789 } |
|
790 } |
|
791 } |
|
792 |
|
793 // Initialise providers. |
|
794 if (bind) |
|
795 { |
|
796 for (TInt k = 0; k < bind->NumberOfProviders(); k++) |
|
797 { |
|
798 TRAPD(err, bind->MenuProvider(k)->InitialiseL(*this, bind->Interest())); |
|
799 if(err) |
|
800 { |
|
801 #ifdef _DEBUG |
|
802 RDebug::Print(_L("AIW PROVIDER ERROR: CAiwServiceIfMenu::InitialiseL() failed, leave code:%d"), err); |
|
803 #endif |
|
804 // The provider failed to initialise. |
|
805 // Remove the failed provider from this menu binding. |
|
806 CAiwServiceIfMenu* provider = bind->MenuProvider(k); |
|
807 TInt implUid = provider->ImplementationUid().iUid; |
|
808 bind->RemoveProvider(implUid); |
|
809 |
|
810 // Remove the failed provider also from other menu bindings. |
|
811 for (TInt m = 0; m < iMenuBindings.Count(); m++) |
|
812 { |
|
813 iMenuBindings[m]->RemoveProvider(implUid); |
|
814 } |
|
815 |
|
816 // Then remove provider from the owner list and delete it. |
|
817 for (TInt m = 0; m < iProviders.Count(); m++) |
|
818 { |
|
819 if (iProviders[m]->ImplementationUid().iUid == implUid) |
|
820 { |
|
821 delete iProviders[m]; |
|
822 iProviders.Remove(m); |
|
823 m--; |
|
824 } |
|
825 } |
|
826 } |
|
827 } |
|
828 if (!bound) |
|
829 { |
|
830 User::LeaveIfError(iMenuBindings.Append( bind )); |
|
831 CleanupStack::Pop(); // bind |
|
832 } |
|
833 } |
|
834 SkipMenuFields(aReader); // Jump to next menu item |
|
835 } |
|
836 } |
|
837 |
|
838 |
|
839 void CAiwServiceHandlerImpl::ReadInterestL(RCriteriaArray& aInterest, TInt aInterestResourceId) |
|
840 { |
|
841 CleanupStack::PushL( TCleanupItem( InterestCleanup, &aInterest ) ); |
|
842 TResourceReader reader; |
|
843 iCoeEnv->CreateResourceReaderLC(reader, aInterestResourceId); |
|
844 ReadInterestListL(reader, aInterest); |
|
845 CleanupStack::PopAndDestroy(); // reader |
|
846 CleanupStack::Pop(&aInterest); |
|
847 } |
|
848 |
|
849 |
|
850 void CAiwServiceHandlerImpl::DetachMenu(TInt aMenuResourceId, TInt aInterestResourceId) |
|
851 { |
|
852 // If interest resource id is null, then detach all items in the given menu. |
|
853 if (!aInterestResourceId) |
|
854 { |
|
855 DoDetachMenu(aMenuResourceId); |
|
856 } |
|
857 else |
|
858 { |
|
859 // CCoeEnv/CEikonEnv needs to be accessible. |
|
860 if(!iCoeEnv) |
|
861 { |
|
862 // We cannot leave because this is a non-leaving method. |
|
863 return; |
|
864 } |
|
865 |
|
866 RCriteriaArray interest; |
|
867 TRAPD(err, ReadInterestL(interest, aInterestResourceId)); |
|
868 if (err) |
|
869 { |
|
870 return; |
|
871 } |
|
872 |
|
873 DoDetachMenu(aMenuResourceId, interest); |
|
874 |
|
875 interest.ResetAndDestroy(); |
|
876 } |
|
877 } |
|
878 |
|
879 |
|
880 void CAiwServiceHandlerImpl::DoDetachMenu(TInt aMenuResourceId) |
|
881 { |
|
882 // First, delete the relevant menu bindings. |
|
883 for (TInt i = 0; i < iMenuBindings.Count(); i++) |
|
884 { |
|
885 if (iMenuBindings[i]->MenuId() == aMenuResourceId) |
|
886 { |
|
887 delete iMenuBindings[i]; |
|
888 iMenuBindings.Remove(i); |
|
889 i--; |
|
890 } |
|
891 } |
|
892 |
|
893 // Then check if there were left obselete criteria items and remove them. |
|
894 RemoveObsoleteCriteriaItems(); |
|
895 |
|
896 // Finally check if there were left obselete providers and remove them. |
|
897 RemoveObsoleteProviders(); |
|
898 } |
|
899 |
|
900 |
|
901 void CAiwServiceHandlerImpl::DoDetachMenu(TInt aMenuResourceId, RCriteriaArray& aInterest) |
|
902 { |
|
903 // First, remove relevant criteria items from relevant menu bindings. |
|
904 for (TInt i = 0; i < iMenuBindings.Count(); i++) |
|
905 { |
|
906 if (iMenuBindings[i]->MenuId() == aMenuResourceId) |
|
907 { |
|
908 for (TInt j = 0; j < aInterest.Count(); j++) |
|
909 { |
|
910 TInt index = iMenuBindings[i]->HasCriteriaItem(*aInterest[j]); |
|
911 if (index != KErrNotFound) |
|
912 { |
|
913 iMenuBindings[i]->RemoveCriteria(index); |
|
914 } |
|
915 } |
|
916 } |
|
917 } |
|
918 |
|
919 // Second pass removes empty bindings. |
|
920 for (TInt i = 0; i < iMenuBindings.Count(); i++) |
|
921 { |
|
922 if (iMenuBindings[i]->Interest().Count() == 0) |
|
923 { |
|
924 delete iMenuBindings[i]; |
|
925 iMenuBindings.Remove(i); |
|
926 i--; |
|
927 } |
|
928 } |
|
929 |
|
930 // Then check if there were left obselete criteria items and remove them. |
|
931 RemoveObsoleteCriteriaItems(); |
|
932 |
|
933 // Finally check if there were left obselete providers and remove them. |
|
934 RemoveObsoleteProviders(); |
|
935 } |
|
936 |
|
937 |
|
938 void CAiwServiceHandlerImpl::RemoveObsoleteCriteriaItems() |
|
939 { |
|
940 for (TInt i = 0; i < iInterestList.Count(); i++) |
|
941 { |
|
942 CAiwCriteriaItem* criteria = iInterestList[i]; |
|
943 TBool found = EFalse; |
|
944 |
|
945 // Loop through base bindings. |
|
946 for (TInt j = 0; j < iBaseBindings.Count(); j++) |
|
947 { |
|
948 if (iBaseBindings[j]->HasCriteriaItem(*criteria) != KErrNotFound) |
|
949 { |
|
950 found = ETrue; |
|
951 break; |
|
952 } |
|
953 } |
|
954 |
|
955 // If still not found, loop through menu bindings. |
|
956 if (!found) |
|
957 { |
|
958 for (TInt j = 0; j < iMenuBindings.Count(); j++) |
|
959 { |
|
960 if (iMenuBindings[j]->HasCriteriaItem(*criteria) != KErrNotFound) |
|
961 { |
|
962 found = ETrue; |
|
963 break; |
|
964 } |
|
965 } |
|
966 } |
|
967 |
|
968 // Criteria item can be deleted if it was not found. |
|
969 if (!found) |
|
970 { |
|
971 delete iInterestList[i]; |
|
972 iInterestList.Remove(i); |
|
973 i--; |
|
974 } |
|
975 } |
|
976 } |
|
977 |
|
978 |
|
979 void CAiwServiceHandlerImpl::RemoveObsoleteProviders() |
|
980 { |
|
981 for (TInt i = 0; i < iProviders.Count(); i++) |
|
982 { |
|
983 CAiwServiceIfBase* provider = iProviders[i]; |
|
984 TBool found = EFalse; |
|
985 |
|
986 // Loop through base bindings. |
|
987 for (TInt j = 0; j < iBaseBindings.Count(); j++) |
|
988 { |
|
989 if (iBaseBindings[j]->HasProvider(provider)) |
|
990 { |
|
991 found = ETrue; |
|
992 break; |
|
993 } |
|
994 } |
|
995 |
|
996 // If still not found, loop through menu bindings. |
|
997 if (!found) |
|
998 { |
|
999 for (TInt j = 0; j < iMenuBindings.Count(); j++) |
|
1000 { |
|
1001 if (iMenuBindings[j]->HasProvider(provider)) |
|
1002 { |
|
1003 found = ETrue; |
|
1004 break; |
|
1005 } |
|
1006 } |
|
1007 } |
|
1008 |
|
1009 // Criteria item can be deleted if it was not found. |
|
1010 if (!found) |
|
1011 { |
|
1012 delete iProviders[i]; |
|
1013 iProviders.Remove(i); |
|
1014 i--; |
|
1015 } |
|
1016 } |
|
1017 } |
|
1018 |
|
1019 |
|
1020 TBool CAiwServiceHandlerImpl::IsSubMenuEmpty(TInt aSubMenuId) |
|
1021 { |
|
1022 for (TInt i = 0; i < iMenuBindings.Count(); i++) |
|
1023 { |
|
1024 if (iMenuBindings[i]->MenuId() == aSubMenuId) |
|
1025 { |
|
1026 if (iMenuBindings[i]->NumberOfProviders() > 0) |
|
1027 { |
|
1028 return EFalse; |
|
1029 } |
|
1030 |
|
1031 return ETrue; |
|
1032 } |
|
1033 } |
|
1034 |
|
1035 return EFalse; |
|
1036 } |
|
1037 |
|
1038 |
|
1039 |
|
1040 |
|
1041 CAiwMenuBinding* CAiwServiceHandlerImpl::AlreadyBound(TInt aMenuId, TInt aMenuCmd, |
|
1042 TInt aMenuItemIndex) const |
|
1043 { |
|
1044 for (TInt i = 0; i < iMenuBindings.Count(); i++) |
|
1045 { |
|
1046 if ((iMenuBindings[i]->MenuId() == aMenuId) && |
|
1047 (iMenuBindings[i]->MenuCmd() == aMenuCmd) && |
|
1048 (iMenuBindings[i]->MenuItemIndex() == aMenuItemIndex)) |
|
1049 { |
|
1050 return iMenuBindings[i]; |
|
1051 } |
|
1052 } |
|
1053 |
|
1054 return NULL; |
|
1055 } |
|
1056 |
|
1057 |
|
1058 void CAiwServiceHandlerImpl::ExecuteServiceCmdL( |
|
1059 const TInt& aCmdId, |
|
1060 const CAiwGenericParamList& aInParamList, |
|
1061 CAiwGenericParamList& aOutParamList, |
|
1062 TUint aCmdOptions, |
|
1063 MAiwNotifyCallback* aCallback) |
|
1064 { |
|
1065 for (TInt i = 0; i < iBaseBindings.Count(); i++) |
|
1066 { |
|
1067 if(iBaseBindings[i]->HasServiceCmd(aCmdId)) |
|
1068 { |
|
1069 for (TInt j = 0; j < iBaseBindings[i]->NumberOfProviders(); j++) |
|
1070 { |
|
1071 iBaseBindings[i]->BaseProvider(j)->HandleServiceCmdL( |
|
1072 aCmdId, |
|
1073 aInParamList, |
|
1074 aOutParamList, |
|
1075 aCmdOptions, |
|
1076 aCallback); |
|
1077 } |
|
1078 } |
|
1079 } |
|
1080 } |
|
1081 |
|
1082 |
|
1083 |
|
1084 void CAiwServiceHandlerImpl::ReadInterestListL(TResourceReader& aReader, |
|
1085 RPointerArray<CAiwCriteriaItem>& aResult) |
|
1086 { |
|
1087 const TInt count = aReader.ReadInt16(); |
|
1088 for (TInt ii = 0; ii < count; ++ii) |
|
1089 { |
|
1090 CAiwCriteriaItem* item = CAiwCriteriaItem::NewLC(); |
|
1091 item->ReadFromResoureL( aReader ); |
|
1092 User::LeaveIfError(aResult.Append(item)); |
|
1093 CleanupStack::Pop(); // item |
|
1094 } |
|
1095 } |
|
1096 |
|
1097 |
|
1098 TInt CAiwServiceHandlerImpl::ResolveProvidersL(CAiwBinding* aBinding, CAiwCriteriaItem* aItem) |
|
1099 { |
|
1100 RImplInfoPtrArray infoArray; |
|
1101 TInt result = 0; |
|
1102 |
|
1103 CleanupStack::PushL( TCleanupItem( Cleanup, &infoArray ) ); |
|
1104 |
|
1105 iEcomMonitor->ListImplemetationsL(infoArray, aItem); |
|
1106 |
|
1107 FilterInfoArray(infoArray, aItem); |
|
1108 |
|
1109 // First resolve for providers already in memory. |
|
1110 TInt i; |
|
1111 for (i = 0; i < iProviders.Count(); i++) |
|
1112 { |
|
1113 if (iProviders[i]->Match(aItem)) |
|
1114 { |
|
1115 aBinding->AddProviderL((CAiwServiceIfBase*)iProviders[i], |
|
1116 iProviders[i]->ImplementationUid() == aItem->DefaultProvider()); |
|
1117 result++; |
|
1118 } |
|
1119 } |
|
1120 |
|
1121 // If cached providers were found, then it means that all the matching |
|
1122 // providers must be already in memory. No need to query from ECom framework. |
|
1123 if (!result) |
|
1124 { |
|
1125 for (i = 0; i < infoArray.Count(); i++) |
|
1126 { |
|
1127 if ((aItem->Options() & AIW_OPTIONS_ROM_ONLY) && (infoArray[i]->RomBased() == EFalse)) |
|
1128 { |
|
1129 continue; |
|
1130 } |
|
1131 |
|
1132 CAiwServiceIfBase* iface = NULL; |
|
1133 TRAP_IGNORE( iface = iEcomMonitor->CreateImplementationL( |
|
1134 infoArray[i]->ImplementationUid()) ); |
|
1135 |
|
1136 if (iface) |
|
1137 { |
|
1138 if (!IsCached(iface)) |
|
1139 { |
|
1140 CleanupStack::PushL(iface); |
|
1141 result++; |
|
1142 iface->AddCriteria(aItem); |
|
1143 User::LeaveIfError(iProviders.Append( iface )); |
|
1144 CleanupStack::Pop(iface); |
|
1145 |
|
1146 aBinding->AddProviderL(iface, |
|
1147 infoArray[i]->ImplementationUid() == aItem->DefaultProvider()); |
|
1148 } |
|
1149 else |
|
1150 { |
|
1151 delete iface; |
|
1152 iface = NULL; |
|
1153 } |
|
1154 } |
|
1155 } |
|
1156 } |
|
1157 |
|
1158 CleanupStack::PopAndDestroy(); // infoArray |
|
1159 |
|
1160 return result; |
|
1161 } |
|
1162 |
|
1163 |
|
1164 |
|
1165 void CAiwServiceHandlerImpl::FilterInfoArray(RImplInfoPtrArray& aArray, CAiwCriteriaItem* aItem) |
|
1166 { |
|
1167 if (aItem->MaxProviders() <= 0) |
|
1168 { |
|
1169 aArray.ResetAndDestroy(); |
|
1170 } |
|
1171 else |
|
1172 { |
|
1173 while (aArray.Count() > aItem->MaxProviders()) |
|
1174 { |
|
1175 // Skip default provider. |
|
1176 if (aArray[0]->ImplementationUid() == aItem->DefaultProvider()) |
|
1177 { |
|
1178 delete aArray[1]; |
|
1179 aArray.Remove(1); |
|
1180 } |
|
1181 else |
|
1182 { |
|
1183 delete aArray[0]; |
|
1184 aArray.Remove(0); |
|
1185 } |
|
1186 } |
|
1187 } |
|
1188 } |
|
1189 |
|
1190 |
|
1191 |
|
1192 TBool CAiwServiceHandlerImpl::IsCached(CAiwServiceIfBase* /*aProvider*/) |
|
1193 { |
|
1194 return EFalse; |
|
1195 } |
|
1196 |
|
1197 |
|
1198 CAiwGenericParamList& CAiwServiceHandlerImpl::InParamListL() |
|
1199 { |
|
1200 if (!iInParams) |
|
1201 { |
|
1202 iInParams = CAiwGenericParamList::NewL(); |
|
1203 } |
|
1204 iInParams->Reset(); |
|
1205 return *iInParams; |
|
1206 } |
|
1207 |
|
1208 |
|
1209 |
|
1210 CAiwGenericParamList& CAiwServiceHandlerImpl::OutParamListL() |
|
1211 { |
|
1212 if (!iOutParams) |
|
1213 { |
|
1214 iOutParams = CAiwGenericParamList::NewL(); |
|
1215 } |
|
1216 iOutParams->Reset(); |
|
1217 return *iOutParams; |
|
1218 } |
|
1219 |
|
1220 |
|
1221 |
|
1222 TBool CAiwServiceHandlerImpl::IsInLastInitialized(CAiwMenuPane* aiwPane) const |
|
1223 { |
|
1224 if (aiwPane) |
|
1225 { |
|
1226 if (iSubmenu == aiwPane) |
|
1227 { |
|
1228 return ETrue; |
|
1229 } |
|
1230 |
|
1231 for (TInt i = 0; i < iLastInitialized.Count(); i++) |
|
1232 { |
|
1233 if (iLastInitialized[i] == aiwPane) |
|
1234 { |
|
1235 return ETrue; |
|
1236 } |
|
1237 } |
|
1238 } |
|
1239 |
|
1240 return EFalse; |
|
1241 } |
|
1242 |
|
1243 |
|
1244 TInt CAiwServiceHandlerImpl::HandleNotifyL( |
|
1245 TInt /*aCmdId*/, |
|
1246 TInt /*aEventId*/, |
|
1247 CAiwGenericParamList& /*aEventParamList*/, |
|
1248 const CAiwGenericParamList& /*aInParamList*/) |
|
1249 { |
|
1250 return KErrNone; |
|
1251 } |
|
1252 |
|
1253 |
|
1254 // CEikMenuPane::ConstructFromresourceL is defined as 'protected' so |
|
1255 // we have to use a wrapper class for accessing it. |
|
1256 class CAiwMenuResource : public CEikMenuPane |
|
1257 { |
|
1258 public: |
|
1259 CAiwMenuResource() : CEikMenuPane(NULL) {} |
|
1260 CAiwMenuResource(MEikMenuObserver* aObserver) : CEikMenuPane(aObserver) {} |
|
1261 |
|
1262 void CreateL(TResourceReader& aReader) |
|
1263 { |
|
1264 ConstructFromResourceL(aReader); |
|
1265 } |
|
1266 }; |
|
1267 |
|
1268 |
|
1269 CAiwMenuPane* CAiwServiceHandlerImpl::CreateEmptyAiwMenuPaneL(TInt aBaseMenuCmdId, |
|
1270 TInt aResourceId) |
|
1271 { |
|
1272 CAiwMenuPane* result = NULL; |
|
1273 TResourceReader reader; |
|
1274 |
|
1275 TInt id; |
|
1276 if(aResourceId >= 0) |
|
1277 { |
|
1278 // Use existing id. |
|
1279 id = aResourceId; |
|
1280 } |
|
1281 else |
|
1282 { |
|
1283 // Create new id. |
|
1284 id = ResourceIdForNextFreeSlot(); |
|
1285 if (id < 0) |
|
1286 { |
|
1287 User::Leave(KErrOverflow); |
|
1288 } |
|
1289 } |
|
1290 iCoeEnv->CreateResourceReaderLC(reader, id); |
|
1291 |
|
1292 CAiwMenuResource* pane = new (ELeave) CAiwMenuResource(this); |
|
1293 CleanupStack::PushL(pane); |
|
1294 pane->ConstructL(NULL); |
|
1295 pane->CreateL(reader); |
|
1296 |
|
1297 result = new (ELeave) CAiwMenuPane(*pane, aBaseMenuCmdId); |
|
1298 |
|
1299 CleanupStack::Pop(pane); |
|
1300 CleanupStack::PopAndDestroy(); // reader |
|
1301 |
|
1302 result->SetResourceSlotId( id ); |
|
1303 |
|
1304 return result; |
|
1305 } |
|
1306 |
|
1307 |
|
1308 void CAiwServiceHandlerImpl::DeleteAiwMenuPane(CAiwMenuPane* aAiwPane) |
|
1309 { |
|
1310 delete aAiwPane->iMenuPane; |
|
1311 aAiwPane->iMenuPane = NULL; |
|
1312 |
|
1313 // Reset iIdMap and extraText. |
|
1314 for(TInt i = 0; i < aAiwPane->iIdMap.Count(); i++) |
|
1315 { |
|
1316 aAiwPane->iIdMap[i].extraText.Close(); |
|
1317 } |
|
1318 aAiwPane->iIdMap.Reset(); |
|
1319 |
|
1320 // Remove the aiw menu pane from iMenuPanes array. |
|
1321 for(TInt i = 0; i < iMenuPanes.Count(); i++) |
|
1322 { |
|
1323 if(iMenuPanes[i] == aAiwPane) |
|
1324 { |
|
1325 iMenuPanes.Remove(i); |
|
1326 break; |
|
1327 } |
|
1328 } |
|
1329 |
|
1330 // Remove the aiw menu pane from iMenuLastInitialized array. |
|
1331 for(TInt i = 0; i < iLastInitialized.Count(); i++) |
|
1332 { |
|
1333 if(iLastInitialized[i] == aAiwPane) |
|
1334 { |
|
1335 iLastInitialized.Remove(i); |
|
1336 break; |
|
1337 } |
|
1338 } |
|
1339 |
|
1340 delete aAiwPane; |
|
1341 aAiwPane = NULL; |
|
1342 } |
|
1343 |
|
1344 const TInt resourceSlotIds[KMaxMenuResources] = |
|
1345 { |
|
1346 R_AIW_EMPTY_MENU_0, |
|
1347 R_AIW_EMPTY_MENU_1, |
|
1348 R_AIW_EMPTY_MENU_2, |
|
1349 R_AIW_EMPTY_MENU_3, |
|
1350 R_AIW_EMPTY_MENU_4, |
|
1351 R_AIW_EMPTY_MENU_5, |
|
1352 R_AIW_EMPTY_MENU_6, |
|
1353 R_AIW_EMPTY_MENU_7, |
|
1354 R_AIW_EMPTY_MENU_8, |
|
1355 R_AIW_EMPTY_MENU_9, |
|
1356 R_AIW_EMPTY_MENU_10, |
|
1357 R_AIW_EMPTY_MENU_11, |
|
1358 R_AIW_EMPTY_MENU_12, |
|
1359 R_AIW_EMPTY_MENU_13, |
|
1360 R_AIW_EMPTY_MENU_14, |
|
1361 R_AIW_EMPTY_MENU_15 |
|
1362 }; |
|
1363 |
|
1364 |
|
1365 TInt CAiwServiceHandlerImpl::ResourceIdForNextFreeSlot() |
|
1366 { |
|
1367 if (iNextFreeSlot < KMaxMenuResources) |
|
1368 { |
|
1369 return resourceSlotIds[iNextFreeSlot++]; |
|
1370 } |
|
1371 |
|
1372 return -1; |
|
1373 } |
|
1374 |
|
1375 |
|
1376 void CAiwServiceHandlerImpl::SetEmphasis(CCoeControl* /*aMenuControl*/,TBool /*aEmphasis*/) |
|
1377 { |
|
1378 } |
|
1379 |
|
1380 |
|
1381 void CAiwServiceHandlerImpl::ProcessCommandL(TInt /*aCommandId*/) |
|
1382 { |
|
1383 } |
|
1384 |
|
1385 |
|
1386 void Cleanup( TAny* aAny ) |
|
1387 { |
|
1388 RImplInfoPtrArray* implArray = |
|
1389 reinterpret_cast< RImplInfoPtrArray*> ( aAny ); |
|
1390 implArray->ResetAndDestroy(); |
|
1391 implArray->Close(); |
|
1392 } |
|
1393 |
|
1394 |
|
1395 void InterestCleanup( TAny* aAny ) |
|
1396 { |
|
1397 RPointerArray<CAiwCriteriaItem>* interestArray = |
|
1398 reinterpret_cast<RPointerArray<CAiwCriteriaItem>*> ( aAny ); |
|
1399 |
|
1400 interestArray->ResetAndDestroy(); |
|
1401 } |
|
1402 |
|
1403 void FilteredCleanup( TAny* aAny ) |
|
1404 { |
|
1405 RPointerArray<CAiwCriteriaItem>* filteredArray = |
|
1406 reinterpret_cast<RPointerArray<CAiwCriteriaItem>*> ( aAny ); |
|
1407 |
|
1408 filteredArray->Reset(); |
|
1409 } |
|
1410 |
|
1411 |
|
1412 void IntArrayCleanup(TAny* aAny) |
|
1413 { |
|
1414 RArray<TInt>* intArray = |
|
1415 reinterpret_cast<RArray<TInt>*> ( aAny ); |
|
1416 |
|
1417 intArray->Close(); |
|
1418 } |
|
1419 |
|
1420 |
|
1421 void CAiwServiceHandlerImpl::CopyMenuItemsL(CAiwMenuPane* aSource, CEikMenuPane& aDest, |
|
1422 TInt aStartIndex, TBool aIsSubmenu, TBool aSetAsItemSpecific) |
|
1423 { |
|
1424 TInt cmdId; |
|
1425 TInt inPos = aStartIndex; |
|
1426 |
|
1427 for (TInt i = 0; i < aSource->MenuPane().NumberOfItemsInPane(); i++) |
|
1428 { |
|
1429 cmdId = aSource->FindCmdId(i); |
|
1430 if (cmdId >= 0) |
|
1431 { |
|
1432 CEikMenuPaneItem::SData itemData = aSource->MenuPane().ItemData(cmdId); |
|
1433 |
|
1434 // The menu item might include alternative texts for a main menu level |
|
1435 // and for submenu. Use submenu string if it is intended so. |
|
1436 if(aIsSubmenu) |
|
1437 { |
|
1438 const TDesC& extraText = aSource->ExtraText(cmdId); |
|
1439 if(extraText.Length()) |
|
1440 { |
|
1441 itemData.iText.Zero(); |
|
1442 itemData.iText.Append(extraText); |
|
1443 } |
|
1444 } |
|
1445 |
|
1446 if ( aSetAsItemSpecific ) |
|
1447 { |
|
1448 itemData.iFlags |= EEikMenuItemSpecific; |
|
1449 } |
|
1450 |
|
1451 aDest.InsertMenuItemL(itemData, inPos++); |
|
1452 } |
|
1453 } |
|
1454 } |
|
1455 |
|
1456 |
|
1457 |
|
1458 TInt CAiwServiceHandlerImpl::SlotItemCmd(CEikMenuPane& aPane) |
|
1459 { |
|
1460 TInt index; |
|
1461 |
|
1462 for (TInt i = 0; i < KMaxMenuResources; i++) |
|
1463 { |
|
1464 if (aPane.MenuItemExists(EAiwMenuSlotBase + i, index)) |
|
1465 { |
|
1466 return EAiwMenuSlotBase + i; |
|
1467 } |
|
1468 } |
|
1469 |
|
1470 return -1; |
|
1471 } |
|
1472 |
|
1473 |
|
1474 |
|
1475 CAiwMenuPane* CAiwServiceHandlerImpl::MenuPaneForSlotCmd(TInt aCmdId) |
|
1476 { |
|
1477 TInt index = aCmdId - EAiwMenuSlotBase; |
|
1478 |
|
1479 if (index < KMaxMenuResources) |
|
1480 { |
|
1481 TInt resId = resourceSlotIds[index]; |
|
1482 for (TInt i = 0; i < iMenuPanes.Count(); i++) |
|
1483 { |
|
1484 if (iMenuPanes[i]->ResourceSlotId() == resId) |
|
1485 { |
|
1486 return iMenuPanes[i]; |
|
1487 } |
|
1488 } |
|
1489 } |
|
1490 |
|
1491 return NULL; |
|
1492 } |
|
1493 |
|
1494 |
|
1495 |
|
1496 CAiwServiceHandlerImpl::TAiwPlaceholderType CAiwServiceHandlerImpl::PlaceholderType( |
|
1497 CEikMenuPane& aPane, TInt aCmd, TBool& aTitleLocked) |
|
1498 { |
|
1499 CEikMenuPaneItem::SData& itemData = aPane.ItemData(aCmd); |
|
1500 |
|
1501 aTitleLocked = EFalse; |
|
1502 |
|
1503 if ((itemData.iCascadeId & AIW_CASCADE_ID) == AIW_CASCADE_ID) |
|
1504 { |
|
1505 if (itemData.iCascadeId & AIW_LOCK_SUBMENU_TITLE) |
|
1506 { |
|
1507 aTitleLocked = ETrue; |
|
1508 } |
|
1509 return EAiwPlaceholderCascade; |
|
1510 } |
|
1511 else if ((itemData.iCascadeId & AIW_INTELLIGENT_CASCADE_ID) == AIW_INTELLIGENT_CASCADE_ID) |
|
1512 { |
|
1513 if (itemData.iCascadeId & AIW_LOCK_SUBMENU_TITLE) |
|
1514 { |
|
1515 aTitleLocked = ETrue; |
|
1516 } |
|
1517 return EAiwPlaceholderIntelligentCascade; |
|
1518 } |
|
1519 |
|
1520 return EAiwPlaceholderNormal; |
|
1521 } |
|
1522 |
|
1523 |
|
1524 void CAiwServiceHandlerImpl::ConvertPlaceholderL(CEikMenuPane& aPane, TInt aCmd, |
|
1525 CAiwMenuPane& aAiwPane, const TDesC& aTitle, TBool aSetAsItemSpecific) |
|
1526 { |
|
1527 CEikMenuPaneItem::SData itemData = aPane.ItemData(aCmd); |
|
1528 TInt index; |
|
1529 |
|
1530 // Remenber index. |
|
1531 aPane.MenuItemExists(aCmd, index); |
|
1532 |
|
1533 // Remove placeholder item. |
|
1534 aPane.DeleteMenuItem(aCmd); |
|
1535 |
|
1536 // Replace aiw cascade id with actual menu resource id. |
|
1537 itemData.iCascadeId = aAiwPane.iResourceSlotId; |
|
1538 |
|
1539 if (aTitle.Length()) |
|
1540 { |
|
1541 itemData.iText.Copy(aTitle); |
|
1542 } |
|
1543 |
|
1544 // Set unused dynamic cmd id. |
|
1545 itemData.iCommandId = iSubmenuCmd++; |
|
1546 |
|
1547 if ( aSetAsItemSpecific ) |
|
1548 { |
|
1549 itemData.iFlags |= EEikMenuItemSpecific; |
|
1550 } |
|
1551 |
|
1552 // Insert cascade item. |
|
1553 aPane.InsertMenuItemL(itemData, index); |
|
1554 } |
|
1555 |
|
1556 |
|
1557 void CAiwServiceHandlerImpl::UnCascadeL(CEikMenuPane& aPane, TInt aCmd, |
|
1558 CAiwMenuPane& aAiwPane, TBool aSetAsItemSpecific) |
|
1559 { |
|
1560 CEikMenuPaneItem::SData itemData = aAiwPane.MenuPane().ItemData(aAiwPane.FindCmdId(0)); |
|
1561 TInt index; |
|
1562 |
|
1563 // Remenber index. |
|
1564 aPane.MenuItemExists(aCmd, index); |
|
1565 |
|
1566 // Remove placeholder item. |
|
1567 aPane.DeleteMenuItem(aCmd); |
|
1568 |
|
1569 // Uncascade |
|
1570 itemData.iCascadeId = 0; |
|
1571 |
|
1572 if ( aSetAsItemSpecific ) |
|
1573 { |
|
1574 itemData.iFlags |= EEikMenuItemSpecific; |
|
1575 } |
|
1576 |
|
1577 // Insert cascade item. |
|
1578 aPane.InsertMenuItemL(itemData, index); |
|
1579 } |
|
1580 |
|
1581 |
|
1582 |
|
1583 void CAiwServiceHandlerImpl::SkipMenuFields(TResourceReader& aReader) |
|
1584 { |
|
1585 aReader.ReadInt32(); // Skip cascade id |
|
1586 aReader.ReadInt32(); // Skip flags |
|
1587 aReader.ReadTPtrC(); // Skip text |
|
1588 aReader.ReadTPtrC(); // Skip extra text |
|
1589 aReader.ReadTPtrC(); // Skip bmpfile. |
|
1590 aReader.ReadInt16(); // Skip bmpid. |
|
1591 aReader.ReadInt16(); // Skip bmpmask. |
|
1592 aReader.ReadInt32(); // Skip extension. |
|
1593 } |
|
1594 |
|
1595 |
|
1596 TBool CAiwServiceHandlerImpl::IsAiwMenu(TInt aMenuResourceId) |
|
1597 { |
|
1598 TInt i; |
|
1599 |
|
1600 // First check if this is aiw submenu id |
|
1601 for (i = 0; i < KMaxMenuResources; i++) |
|
1602 { |
|
1603 if (aMenuResourceId == resourceSlotIds[i]) |
|
1604 { |
|
1605 return ETrue; |
|
1606 } |
|
1607 } |
|
1608 |
|
1609 // Then check if this menu is among attached menus. |
|
1610 for (i = 0; i < iMenuBindings.Count(); i++) |
|
1611 { |
|
1612 if (iMenuBindings[i]->MenuId() == aMenuResourceId) |
|
1613 { |
|
1614 return ETrue; |
|
1615 } |
|
1616 } |
|
1617 |
|
1618 return EFalse; |
|
1619 } |
|
1620 |
|
1621 |
|
1622 |
|
1623 TBool CAiwServiceHandlerImpl::HandleSubmenuL(CEikMenuPane& aPane) |
|
1624 { |
|
1625 TInt slotcmd = SlotItemCmd(aPane); |
|
1626 if (slotcmd >= 0) |
|
1627 { |
|
1628 // aPane is aiw submenu. At this point it is empty and we must |
|
1629 // copy provider menu items to it. |
|
1630 CAiwMenuPane* aiwPane = MenuPaneForSlotCmd(slotcmd); |
|
1631 if (aiwPane) |
|
1632 { |
|
1633 CopyMenuItemsL(aiwPane, aPane, 0, ETrue, EFalse); |
|
1634 aPane.DeleteMenuItem(slotcmd); |
|
1635 iSubmenu = aiwPane; |
|
1636 return ETrue; |
|
1637 } |
|
1638 } |
|
1639 |
|
1640 return EFalse; |
|
1641 } |
|
1642 |
|
1643 |
|
1644 |
|
1645 TBool CAiwServiceHandlerImpl::GetSubmenuTitle(CEikMenuPane& aPane, TDes& aResult) |
|
1646 { |
|
1647 TInt index; |
|
1648 |
|
1649 aResult.Zero(); |
|
1650 while (aPane.MenuItemExists(AIW_SUBMENU_TITLE, index)) |
|
1651 { |
|
1652 CEikMenuPaneItem::SData& itemData = aPane.ItemData(AIW_SUBMENU_TITLE); |
|
1653 if (aResult.Length() == 0) |
|
1654 { |
|
1655 aResult.Copy(itemData.iText); |
|
1656 } |
|
1657 aPane.DeleteMenuItem(AIW_SUBMENU_TITLE); |
|
1658 return ETrue; |
|
1659 } |
|
1660 |
|
1661 return EFalse; |
|
1662 } |
|
1663 |
|
1664 |
|
1665 |
|
1666 CAiwCriteriaItem* CAiwServiceHandlerImpl::ConvertCriteriaItemPointerL(CAiwCriteriaItem* aCandidate) |
|
1667 { |
|
1668 for (TInt i = 0; i < iInterestList.Count(); i++) |
|
1669 { |
|
1670 if ((*iInterestList[i]) == (*aCandidate)) |
|
1671 { |
|
1672 // Already in list, aCandidate is not needed. |
|
1673 delete aCandidate; |
|
1674 return iInterestList[i]; |
|
1675 } |
|
1676 } |
|
1677 |
|
1678 CleanupStack::PushL(aCandidate); |
|
1679 User::LeaveIfError(iInterestList.Append(aCandidate)); |
|
1680 CleanupStack::Pop(); // aCandidate |
|
1681 |
|
1682 return aCandidate; |
|
1683 } |
|
1684 |
|
1685 |
|
1686 |
|
1687 void CAiwServiceHandlerImpl::FilterInterestListL(RPointerArray<CAiwCriteriaItem>& aOriginal, |
|
1688 RPointerArray<CAiwCriteriaItem>& aFiltered) |
|
1689 { |
|
1690 CAiwCriteriaItem* item; |
|
1691 |
|
1692 while (aOriginal.Count() > 0) |
|
1693 { |
|
1694 item = aOriginal[0]; |
|
1695 aOriginal.Remove(0); |
|
1696 item = ConvertCriteriaItemPointerL(item); |
|
1697 User::LeaveIfError(aFiltered.Append(item)); |
|
1698 } |
|
1699 aOriginal.Reset(); |
|
1700 } |
|
1701 |
|
1702 |
|
1703 |
|
1704 void CAiwServiceHandlerImpl::RemoveProvider(TInt aImplUid) |
|
1705 { |
|
1706 TInt i; |
|
1707 |
|
1708 // First go through bindings and remove all the |
|
1709 // references to given provider. |
|
1710 for (i = 0; i < iBaseBindings.Count(); i++) |
|
1711 { |
|
1712 iBaseBindings[i]->RemoveProvider(aImplUid); |
|
1713 } |
|
1714 |
|
1715 for (i = 0; i < iMenuBindings.Count(); i++) |
|
1716 { |
|
1717 iMenuBindings[i]->RemoveProvider(aImplUid); |
|
1718 } |
|
1719 |
|
1720 // Then remove provider from the owner list and delete it. |
|
1721 for (i = 0; i < iProviders.Count(); i++) |
|
1722 { |
|
1723 if (iProviders[i]->ImplementationUid().iUid == aImplUid) |
|
1724 { |
|
1725 delete iProviders[i]; |
|
1726 iProviders.Remove(i); |
|
1727 i--; |
|
1728 } |
|
1729 } |
|
1730 } |
|
1731 |
|
1732 |
|
1733 void CAiwServiceHandlerImpl::AddProviderL(TUid aImplUid, CAiwCriteriaItem* aItem) |
|
1734 { |
|
1735 TInt i; |
|
1736 CAiwServiceIfBase* iface = iEcomMonitor->CreateImplementationL(aImplUid); |
|
1737 |
|
1738 if (iface) |
|
1739 { |
|
1740 CleanupStack::PushL(iface); |
|
1741 iface->AddCriteria(aItem); |
|
1742 User::LeaveIfError(iProviders.Append( iface )); |
|
1743 CleanupStack::Pop(iface); |
|
1744 |
|
1745 for (i = 0; i < iBaseBindings.Count(); i++) |
|
1746 { |
|
1747 if (iBaseBindings[i]->HasCriteriaItem(*aItem) != KErrNotFound) |
|
1748 { |
|
1749 iBaseBindings[i]->AddProviderL(iface, aImplUid == aItem->DefaultProvider()); |
|
1750 iface->InitialiseL(*this, iBaseBindings[i]->Interest()); |
|
1751 } |
|
1752 } |
|
1753 |
|
1754 for (i = 0; i < iMenuBindings.Count(); i++) |
|
1755 { |
|
1756 if (iMenuBindings[i]->HasCriteriaItem(*aItem) != KErrNotFound) |
|
1757 { |
|
1758 iMenuBindings[i]->AddProviderL(iface, aImplUid == aItem->DefaultProvider()); |
|
1759 iface->InitialiseL(*this, iMenuBindings[i]->Interest()); |
|
1760 } |
|
1761 } |
|
1762 } |
|
1763 } |
|
1764 |
|
1765 |
|
1766 |
|
1767 TInt CAiwServiceHandlerImpl::SynchronizeCallBack(TAny* aImpl) |
|
1768 { |
|
1769 CAiwServiceHandlerImpl* impl = reinterpret_cast<CAiwServiceHandlerImpl*>(aImpl); |
|
1770 TRAPD(err, impl->SynchronizeDbL()); |
|
1771 return err; |
|
1772 } |
|
1773 |
|
1774 |
|
1775 |
|
1776 void CAiwServiceHandlerImpl::SynchronizeDbL() |
|
1777 { |
|
1778 TInt i; |
|
1779 RArray<TInt> providers; |
|
1780 RImplInfoPtrArray infoArray; |
|
1781 |
|
1782 CleanupStack::PushL( TCleanupItem( IntArrayCleanup, &providers ) ); |
|
1783 CleanupStack::PushL( TCleanupItem( Cleanup, &infoArray ) ); |
|
1784 |
|
1785 for (i = 0; i < iInterestList.Count(); i++) |
|
1786 { |
|
1787 if (iInterestList[i]->RomOnly()) // Rom-only criterias can be skipped. |
|
1788 { |
|
1789 continue; |
|
1790 } |
|
1791 |
|
1792 providers.Reset(); |
|
1793 infoArray.ResetAndDestroy(); |
|
1794 ListProvidersForCriteriaL(providers, *(iInterestList[i])); |
|
1795 iEcomMonitor->ListImplemetationsL(infoArray, iInterestList[i]); |
|
1796 HandleRemovedProviders(providers, infoArray); |
|
1797 HandleNewProvidersL(providers, infoArray, iInterestList[i]); |
|
1798 } |
|
1799 |
|
1800 CleanupStack::PopAndDestroy(2); // providers, infoArray |
|
1801 } |
|
1802 |
|
1803 |
|
1804 void CAiwServiceHandlerImpl::HandleRemovedProviders(RArray<TInt>& aInMemory, |
|
1805 RImplInfoPtrArray& aInSystem) |
|
1806 { |
|
1807 TInt i, j; |
|
1808 |
|
1809 for (i = 0; i < aInMemory.Count(); i++) |
|
1810 { |
|
1811 for (j = 0; j < aInSystem.Count(); j++) |
|
1812 { |
|
1813 if (aInSystem[j]->ImplementationUid().iUid == aInMemory[i]) |
|
1814 { |
|
1815 break; |
|
1816 } |
|
1817 } |
|
1818 if (j >= aInSystem.Count()) // Was removed from system. |
|
1819 { |
|
1820 RemoveProvider(aInMemory[i]); |
|
1821 } |
|
1822 } |
|
1823 } |
|
1824 |
|
1825 |
|
1826 void CAiwServiceHandlerImpl::HandleNewProvidersL(RArray<TInt>& aInMemory, |
|
1827 RImplInfoPtrArray& aInSystem, CAiwCriteriaItem* aItem) |
|
1828 { |
|
1829 TInt i; |
|
1830 |
|
1831 for (i = 0; i < aInSystem.Count(); i++) |
|
1832 { |
|
1833 if (aInMemory.Find(aInSystem[i]->ImplementationUid().iUid) == KErrNotFound) |
|
1834 { |
|
1835 AddProviderL(aInSystem[i]->ImplementationUid(), aItem); |
|
1836 } |
|
1837 } |
|
1838 } |
|
1839 |
|
1840 void CAiwServiceHandlerImpl::MenuLaunched() |
|
1841 { |
|
1842 ClearMenuPaneArray(); |
|
1843 iNextFreeSlot = 0; |
|
1844 iLastInitialized.Reset(); |
|
1845 |
|
1846 // Reset the iMenuPane pointers from iMenuBindings. |
|
1847 for(TInt i = 0; i < iMenuBindings.Count(); i++) |
|
1848 { |
|
1849 iMenuBindings[i]->SetMenuPane(NULL); |
|
1850 } |
|
1851 } |
|
1852 |
|
1853 // End of file |