applicationinterworkingfw/ServiceHandler/src/AiwServiceHandlerImpl.cpp
branchRCL_3
changeset 18 fcdfafb36fe7
parent 3 8ca85d2f0db7
child 19 aecbbf00d063
equal deleted inserted replaced
17:a1caeb42b3a3 18:fcdfafb36fe7
    29 #include "AiwCommon.hrh"
    29 #include "AiwCommon.hrh"
    30 #include "AiwMenuSlot.hrh"
    30 #include "AiwMenuSlot.hrh"
    31 #include "AiwEcomMonitor.h"
    31 #include "AiwEcomMonitor.h"
    32 #include "AiwTlsData.h"
    32 #include "AiwTlsData.h"
    33 #include "data_caging_path_literals.hrh"
    33 #include "data_caging_path_literals.hrh"
       
    34 #include "../../../uifw/inc/akntrace.h"
    34 
    35 
    35 // CONSTANTS
    36 // CONSTANTS
    36 // Max number of empty menu resource slots.
    37 // Max number of empty menu resource slots.
    37 const TInt KMaxMenuResources = 16;
    38 const TInt KMaxMenuResources = 16;
    38 
    39 
    64 // AiwServiceHandler
    65 // AiwServiceHandler
    65 //
    66 //
    66 
    67 
    67 CAiwServiceHandlerImpl* CAiwServiceHandlerImpl::NewL()
    68 CAiwServiceHandlerImpl* CAiwServiceHandlerImpl::NewL()
    68     {
    69     {
       
    70     _AKNTRACE_FUNC_ENTER;
       
    71     
    69     CAiwServiceHandlerImpl* handler = new (ELeave) CAiwServiceHandlerImpl();
    72     CAiwServiceHandlerImpl* handler = new (ELeave) CAiwServiceHandlerImpl();
    70     CleanupStack::PushL( handler );
    73     CleanupStack::PushL( handler );
    71     handler->ConstructL();
    74     handler->ConstructL();
    72     CleanupStack::Pop(); // handler
    75     CleanupStack::Pop(); // handler
       
    76     
       
    77     _AKNTRACE_FUNC_EXIT;
    73     return handler;
    78     return handler;
    74     }
    79     }
    75 
    80 
    76 
    81 
    77 
    82 
   117 
   122 
   118 
   123 
   119 
   124 
   120 CAiwServiceHandlerImpl::~CAiwServiceHandlerImpl()
   125 CAiwServiceHandlerImpl::~CAiwServiceHandlerImpl()
   121     {
   126     {
       
   127     _AKNTRACE_FUNC_ENTER;
       
   128     
   122     if (iResourceOffset && iCoeEnv)
   129     if (iResourceOffset && iCoeEnv)
   123         {
   130         {
   124         iCoeEnv->DeleteResourceFile(iResourceOffset);
   131         iCoeEnv->DeleteResourceFile(iResourceOffset);
   125         }
   132         }
   126     Reset();
   133     Reset();
   131         {
   138         {
   132         CAiwTlsData* data = CAiwTlsData::Instance();
   139         CAiwTlsData* data = CAiwTlsData::Instance();
   133         data->RemoveMenuLaunchObserver( this );
   140         data->RemoveMenuLaunchObserver( this );
   134         CAiwTlsData::Close();
   141         CAiwTlsData::Close();
   135         }
   142         }
       
   143     _AKNTRACE_FUNC_EXIT;
   136     }
   144     }
   137 
   145 
   138 
   146 
   139 
   147 
   140 void CAiwServiceHandlerImpl::Reset()
   148 void CAiwServiceHandlerImpl::Reset()
   141     {
   149     {
       
   150     _AKNTRACE_FUNC_ENTER;
       
   151     
       
   152     RProcess pro;
       
   153     AknTracePrint(_L("process name:%S"),&(pro.FileName()));
       
   154     
   142     iInterestList.ResetAndDestroy();
   155     iInterestList.ResetAndDestroy();
   143     iMenuBindings.ResetAndDestroy();
   156     iMenuBindings.ResetAndDestroy();
   144     iBaseBindings.ResetAndDestroy();
   157     iBaseBindings.ResetAndDestroy();
   145     iProviders.ResetAndDestroy();
   158     iProviders.ResetAndDestroy();
   146 
   159 
   150 
   163 
   151     delete iInParams;
   164     delete iInParams;
   152     iInParams = NULL;
   165     iInParams = NULL;
   153     delete iOutParams;
   166     delete iOutParams;
   154     iOutParams = NULL;
   167     iOutParams = NULL;
       
   168     
       
   169     _AKNTRACE_FUNC_EXIT;
   155     }
   170     }
   156 
   171 
   157 
   172 
   158 
   173 
   159 void CAiwServiceHandlerImpl::ListProvidersForCriteriaL(RArray<TInt>& aResult, 
   174 void CAiwServiceHandlerImpl::ListProvidersForCriteriaL(RArray<TInt>& aResult, 
   160     CAiwCriteriaItem& aItem)
   175     CAiwCriteriaItem& aItem)
   161     {
   176     {
       
   177     _AKNTRACE_FUNC_ENTER;
       
   178     
   162     TInt i;
   179     TInt i;
   163 
   180 
   164     for (i = 0; i < iProviders.Count(); i++)
   181     for (i = 0; i < iProviders.Count(); i++)
   165         {   
   182         {   
   166         if (iProviders[i]->HasCriteria(aItem))
   183         if (iProviders[i]->HasCriteria(aItem))
   167             {
   184             {
   168             User::LeaveIfError(aResult.Append(iProviders[i]->ImplementationUid().iUid));
   185             User::LeaveIfError(aResult.Append(iProviders[i]->ImplementationUid().iUid));
   169             }
   186             }
   170         }
   187         }
       
   188     
       
   189     _AKNTRACE_FUNC_EXIT;
   171     }
   190     }
   172 
   191 
   173 
   192 
   174 
   193 
   175 TInt CAiwServiceHandlerImpl::NbrOfProviders(const CAiwCriteriaItem* aCriteria)
   194 TInt CAiwServiceHandlerImpl::NbrOfProviders(const CAiwCriteriaItem* aCriteria)
   176     {
   195     {
       
   196     _AKNTRACE_FUNC_ENTER;
       
   197     
   177     if(!aCriteria)
   198     if(!aCriteria)
   178         {
   199         {
   179         return 0;
   200         return 0;
   180         }
   201         }
   181     
   202     
   201                 return iMenuBindings[i]->NumberOfProviders();
   222                 return iMenuBindings[i]->NumberOfProviders();
   202                 }
   223                 }
   203             }       
   224             }       
   204         }
   225         }
   205 
   226 
       
   227     _AKNTRACE_FUNC_EXIT;
   206     return 0;
   228     return 0;
   207     }
   229     }
   208 
   230 
   209 
   231 
   210 
   232 
   211 void CAiwServiceHandlerImpl::AttachL(TInt aInterestResourceId)
   233 void CAiwServiceHandlerImpl::AttachL(TInt aInterestResourceId)
   212     {
   234     {
       
   235     _AKNTRACE_FUNC_ENTER;
       
   236     _AKNTRACE("aInterestResourceId:%x",aInterestResourceId);
   213     // CCoeEnv/CEikonEnv needs to be accessible.
   237     // CCoeEnv/CEikonEnv needs to be accessible.
   214     if(!iCoeEnv)
   238     if(!iCoeEnv)
   215         {
   239         {
   216         User::Leave(KErrNotSupported);
   240         User::Leave(KErrNotSupported);
   217         }
   241         }
   232 
   256 
   233     filtered.Reset();
   257     filtered.Reset();
   234 
   258 
   235     CleanupStack::Pop(); // filtered
   259     CleanupStack::Pop(); // filtered
   236     CleanupStack::Pop(); // interest
   260     CleanupStack::Pop(); // interest
       
   261     
       
   262     _AKNTRACE_FUNC_EXIT;
   237     }
   263     }
   238 
   264 
   239 
   265 
   240 
   266 
   241 void CAiwServiceHandlerImpl::AttachL(const RCriteriaArray& aInterest)
   267 void CAiwServiceHandlerImpl::AttachL(const RCriteriaArray& aInterest)
   242     {
   268     {
       
   269     _AKNTRACE_FUNC_ENTER;
       
   270         
   243     RCriteriaArray interest, filtered;
   271     RCriteriaArray interest, filtered;
   244     
   272     
   245     CleanupStack::PushL( TCleanupItem( InterestCleanup, &interest ) );
   273     CleanupStack::PushL( TCleanupItem( InterestCleanup, &interest ) );
   246     CleanupStack::PushL( TCleanupItem( FilteredCleanup, &filtered ) );
   274     CleanupStack::PushL( TCleanupItem( FilteredCleanup, &filtered ) );
   247         
   275         
   255         item->SetServiceClass(     aInterest[i]->ServiceClass()          );
   283         item->SetServiceClass(     aInterest[i]->ServiceClass()          );
   256         item->SetOptions(          aInterest[i]->Options()               );
   284         item->SetOptions(          aInterest[i]->Options()               );
   257         item->SetDefaultProvider( (aInterest[i]->DefaultProvider()).iUid );
   285         item->SetDefaultProvider( (aInterest[i]->DefaultProvider()).iUid );
   258         item->SetMaxProviders(     aInterest[i]->MaxProviders()          );       
   286         item->SetMaxProviders(     aInterest[i]->MaxProviders()          );       
   259         
   287         
       
   288         _AKNTRACE("aInterest[i]->Id():%x",aInterest[i]->Id());
       
   289         _AKNTRACE("aInterest[i]->ServiceCmd():%x",aInterest[i]->ServiceCmd());
       
   290         _AKNTRACE("aInterest[i]->ServiceClass():%x",aInterest[i]->ServiceClass());
       
   291         _AKNTRACE("(aInterest[i]->DefaultProvider()).iUid:%x",(aInterest[i]->DefaultProvider()).iUid);
       
   292         _AKNTRACE("aInterest[i]->MaxProviders():%x",aInterest[i]->MaxProviders());
       
   293         
   260         User::LeaveIfError(interest.Append(item));
   294         User::LeaveIfError(interest.Append(item));
   261         CleanupStack::Pop(item); 
   295         CleanupStack::Pop(item); 
   262         }
   296         }
   263         
   297         
   264     FilterInterestListL(interest, filtered);        
   298     FilterInterestListL(interest, filtered);        
   267 
   301 
   268     filtered.Reset();
   302     filtered.Reset();
   269 
   303 
   270     CleanupStack::Pop(); // filtered
   304     CleanupStack::Pop(); // filtered
   271     CleanupStack::Pop(); // interest
   305     CleanupStack::Pop(); // interest
       
   306     
       
   307     _AKNTRACE_FUNC_EXIT;
   272     }
   308     }
   273 
   309 
   274 
   310 
   275 
   311 
   276 void CAiwServiceHandlerImpl::DoAttachL(const RCriteriaArray& aInterest)
   312 void CAiwServiceHandlerImpl::DoAttachL(const RCriteriaArray& aInterest)
   277     {
   313     {
       
   314     _AKNTRACE_FUNC_ENTER;
       
   315     
       
   316     RProcess pro;
       
   317     AknTracePrint(_L("process name:%S"),&(pro.FileName()));
   278     CAiwBinding* bind;
   318     CAiwBinding* bind;
   279     for (TInt i = 0; i < aInterest.Count(); i++)
   319     for (TInt i = 0; i < aInterest.Count(); i++)
   280         {
   320         {
   281         bind = CAiwBinding::NewLC();
   321         bind = CAiwBinding::NewLC();
   282         
   322         
   303         else
   343         else
   304             {
   344             {
   305             CleanupStack::PopAndDestroy(); // bind
   345             CleanupStack::PopAndDestroy(); // bind
   306             }
   346             }
   307         }
   347         }
       
   348     
       
   349     _AKNTRACE_FUNC_EXIT;
   308     }
   350     }
   309 
   351 
   310 
   352 
   311 void CAiwServiceHandlerImpl::GetInterest(RCriteriaArray& aInterest)
   353 void CAiwServiceHandlerImpl::GetInterest(RCriteriaArray& aInterest)
   312     {
   354     {
       
   355     _AKNTRACE_FUNC_ENTER;
       
   356     
   313     for (TInt i = 0; i < iInterestList.Count(); i++)
   357     for (TInt i = 0; i < iInterestList.Count(); i++)
   314         {
   358         {
   315         if (aInterest.Append(iInterestList[i]) != KErrNone)
   359         if (aInterest.Append(iInterestList[i]) != KErrNone)
   316             {
   360             {
   317             return;
   361             return;
   318             }
   362             }
   319         }
   363         }
       
   364     
       
   365     _AKNTRACE_FUNC_EXIT;
   320     }
   366     }
   321     
   367     
   322     
   368     
   323 
   369 
   324 void CAiwServiceHandlerImpl::DetachL(const RCriteriaArray& aInterest)
   370 void CAiwServiceHandlerImpl::DetachL(const RCriteriaArray& aInterest)
   325     {
   371     {
       
   372     _AKNTRACE_FUNC_ENTER;
       
   373     
   326     // First, remove relevant criteria items from relevat base bindings.
   374     // First, remove relevant criteria items from relevat base bindings.
   327     for (TInt i = 0; i < aInterest.Count(); i++)
   375     for (TInt i = 0; i < aInterest.Count(); i++)
   328         {
   376         {
   329         for (TInt j = 0; j < iBaseBindings.Count(); j++)
   377         for (TInt j = 0; j < iBaseBindings.Count(); j++)
   330             {
   378             {
   349 
   397 
   350     // Then check if there were left obselete criteria items and remove them.   
   398     // Then check if there were left obselete criteria items and remove them.   
   351     RemoveObsoleteCriteriaItems();
   399     RemoveObsoleteCriteriaItems();
   352     
   400     
   353     // Finally check if there were left obselete providers and remove them.
   401     // Finally check if there were left obselete providers and remove them.
   354     RemoveObsoleteProviders();        
   402     RemoveObsoleteProviders();      
       
   403     
       
   404     _AKNTRACE_FUNC_EXIT;
   355     }
   405     }
   356 
   406 
   357 
   407 
   358 
   408 
   359 void CAiwServiceHandlerImpl::DetachL(TInt aInterestResourceId)
   409 void CAiwServiceHandlerImpl::DetachL(TInt aInterestResourceId)
   360     { 
   410     { 
       
   411     _AKNTRACE_FUNC_ENTER;
       
   412     _AKNTRACE("aInterestResourceId:%x",aInterestResourceId);
       
   413     
   361     // CCoeEnv/CEikonEnv needs to be accessible.
   414     // CCoeEnv/CEikonEnv needs to be accessible.
   362     if(!iCoeEnv)
   415     if(!iCoeEnv)
   363         {
   416         {
   364         User::Leave(KErrNotSupported);
   417         User::Leave(KErrNotSupported);
   365         }
   418         }
   375 
   428 
   376     DetachL( interest );
   429     DetachL( interest );
   377 
   430 
   378     interest.ResetAndDestroy();
   431     interest.ResetAndDestroy();
   379     CleanupStack::Pop(); // interest
   432     CleanupStack::Pop(); // interest
       
   433     
       
   434     _AKNTRACE_FUNC_EXIT;
   380     }
   435     }
   381 
   436 
   382 
   437 
   383 const CAiwCriteriaItem* CAiwServiceHandlerImpl::GetCriteria(TInt aId)
   438 const CAiwCriteriaItem* CAiwServiceHandlerImpl::GetCriteria(TInt aId)
   384     {
   439     {
       
   440     _AKNTRACE_FUNC_ENTER;
   385     for (TInt i = 0; i < iInterestList.Count(); i++)
   441     for (TInt i = 0; i < iInterestList.Count(); i++)
   386         {
   442         {
   387         if (iInterestList[i]->Id() == aId)
   443         if (iInterestList[i]->Id() == aId)
   388             {
   444             {
   389             return iInterestList[i];
   445             return iInterestList[i];
   390             }
   446             }
   391         }
   447         }
   392 
   448     
       
   449     _AKNTRACE_FUNC_EXIT;
   393     return NULL;  
   450     return NULL;  
   394     }
   451     }
   395     
   452     
   396 TInt CAiwServiceHandlerImpl::NumAlreadyInitializedPaneIdsL() const
   453 TInt CAiwServiceHandlerImpl::NumAlreadyInitializedPaneIdsL() const
   397     {
   454     {
       
   455     _AKNTRACE_FUNC_ENTER;
       
   456     
   398     TInt ret = 0;
   457     TInt ret = 0;
   399     TInt paneIds[KMaxPaneIds] = {0};
   458     TInt paneIds[KMaxPaneIds] = {0};
   400     TBool found = EFalse;
   459     TBool found = EFalse;
   401     
   460     
   402     for (TInt i = 0; i < iLastInitialized.Count(); i++)
   461     for (TInt i = 0; i < iLastInitialized.Count(); i++)
   424                 }
   483                 }
   425             paneIds[ret] = iLastInitialized[i]->MenuResourceId();
   484             paneIds[ret] = iLastInitialized[i]->MenuResourceId();
   426             ret++;
   485             ret++;
   427             }                       
   486             }                       
   428         }
   487         }
       
   488     
       
   489     _AKNTRACE_FUNC_EXIT;
   429     return ret;         
   490     return ret;         
   430     }    
   491     }    
   431 
   492 
   432 void CAiwServiceHandlerImpl::InitializeMenuPaneL(
   493 void CAiwServiceHandlerImpl::InitializeMenuPaneL(
   433     CEikMenuPane& aMenuPane,
   494     CEikMenuPane& aMenuPane,
   434     TInt aMenuResourceId, 
   495     TInt aMenuResourceId, 
   435     TInt aBaseMenuCmdId,
   496     TInt aBaseMenuCmdId,
   436     const CAiwGenericParamList& aInParamList)
   497     const CAiwGenericParamList& aInParamList)
   437     {
   498     {
       
   499     _AKNTRACE_FUNC_ENTER;
       
   500     
   438     InitializeMenuPaneL(aMenuPane, aMenuResourceId, aBaseMenuCmdId, 
   501     InitializeMenuPaneL(aMenuPane, aMenuResourceId, aBaseMenuCmdId, 
   439         aInParamList, EFalse, EFalse);    
   502         aInParamList, EFalse, EFalse);    
       
   503     
       
   504     _AKNTRACE_FUNC_EXIT;
   440     }        
   505     }        
   441         
   506         
   442 void CAiwServiceHandlerImpl::InitializeMenuPaneL(
   507 void CAiwServiceHandlerImpl::InitializeMenuPaneL(
   443     CEikMenuPane& aMenuPane,
   508     CEikMenuPane& aMenuPane,
   444     TInt aMenuResourceId, 
   509     TInt aMenuResourceId, 
   445     TInt aBaseMenuCmdId,
   510     TInt aBaseMenuCmdId,
   446     const CAiwGenericParamList& aInParamList,
   511     const CAiwGenericParamList& aInParamList,
   447     TBool aUseSubmenuTextsIfAvailable)
   512     TBool aUseSubmenuTextsIfAvailable)
   448     {
   513     {
       
   514     _AKNTRACE_FUNC_ENTER;
       
   515     
   449     InitializeMenuPaneL(aMenuPane, aMenuResourceId, aBaseMenuCmdId, aInParamList, aUseSubmenuTextsIfAvailable, EFalse);
   516     InitializeMenuPaneL(aMenuPane, aMenuResourceId, aBaseMenuCmdId, aInParamList, aUseSubmenuTextsIfAvailable, EFalse);
       
   517     
       
   518     _AKNTRACE_FUNC_EXIT;
   450     }
   519     }
   451 
   520 
   452 
   521 
   453 void CAiwServiceHandlerImpl::InitializeMenuPaneL(
   522 void CAiwServiceHandlerImpl::InitializeMenuPaneL(
   454     CEikMenuPane& aMenuPane,
   523     CEikMenuPane& aMenuPane,
   456     TInt aBaseMenuCmdId,
   525     TInt aBaseMenuCmdId,
   457     const CAiwGenericParamList& aInParamList,
   526     const CAiwGenericParamList& aInParamList,
   458     TBool aUseSubmenuTextsIfAvailable,
   527     TBool aUseSubmenuTextsIfAvailable,
   459     TBool aSetAsItemSpecific)
   528     TBool aSetAsItemSpecific)
   460     {        
   529     {        
       
   530     _AKNTRACE_FUNC_ENTER;
       
   531     _AKNTRACE("aMenuPane:%x",&aMenuPane);
       
   532     _AKNTRACE("aMenuResourceId:%x",aMenuResourceId);
       
   533     _AKNTRACE("aBaseMenuCmdId:%x",aBaseMenuCmdId);
       
   534     _AKNTRACE("aUseSubmenuTextsIfAvailable:%x",aUseSubmenuTextsIfAvailable);
       
   535     _AKNTRACE("aSetAsItemSpecific:%x",aSetAsItemSpecific);
       
   536     
       
   537     TInt count = aInParamList.Count();
       
   538     for(TInt i=0;i<count;i++)
       
   539         {
       
   540         _AKNTRACE("i:%d, InParamList[i].SemanticId():%x",i,aInParamList[i].SemanticId());
       
   541         AknTracePrint(_L("i:%d, InParamList[i].Value():%S"),i,&(aInParamList[i].Value().AsDes()));
       
   542         
       
   543         }
   461     // CCoeEnv/CEikonEnv needs to be accessible.
   544     // CCoeEnv/CEikonEnv needs to be accessible.
   462     if(!iCoeEnv)
   545     if(!iCoeEnv)
   463         {
   546         {
   464         User::Leave(KErrNotSupported);
   547         User::Leave(KErrNotSupported);
   465         }
   548         }
   590                 User::LeaveIfError(iMenuPanes.Append(aiwPane));
   673                 User::LeaveIfError(iMenuPanes.Append(aiwPane));
   591                 CleanupStack::Pop(); // aiwPane
   674                 CleanupStack::Pop(); // aiwPane
   592                 }
   675                 }
   593             }
   676             }
   594         }
   677         }
       
   678     
       
   679     _AKNTRACE_FUNC_EXIT;
   595     }
   680     }
   596 
   681 
   597 
   682 
   598 TInt CAiwServiceHandlerImpl::ServiceCmdByMenuCmd(TInt aMenuCmdId) const
   683 TInt CAiwServiceHandlerImpl::ServiceCmdByMenuCmd(TInt aMenuCmdId) const
   599     {
   684     {
       
   685     _AKNTRACE_FUNC_ENTER;
       
   686     _AKNTRACE("aMenuCmdId:%x",aMenuCmdId);
       
   687     
   600     for (TInt i = 0; i < iMenuBindings.Count(); i++)
   688     for (TInt i = 0; i < iMenuBindings.Count(); i++)
   601         {
   689         {
   602         if ((IsInLastInitialized(iMenuBindings[i]->MenuPane())) &&
   690         if ((IsInLastInitialized(iMenuBindings[i]->MenuPane())) &&
   603             (iMenuBindings[i]->MenuPane()->IsCmdInRange(KPlaceholderCmdIdRange, aMenuCmdId)))
   691             (iMenuBindings[i]->MenuPane()->IsCmdInRange(KPlaceholderCmdIdRange, aMenuCmdId)))
   604             {
   692             {
   605             return iMenuBindings[i]->MenuPane()->ServiceCmdId(aMenuCmdId); 
   693             return iMenuBindings[i]->MenuPane()->ServiceCmdId(aMenuCmdId); 
   606             }
   694             }
   607         }
   695         }
   608 
   696 
       
   697     _AKNTRACE_FUNC_EXIT;
       
   698     
   609     return 0;   
   699     return 0;   
   610     }
   700     }
   611 
   701 
   612 
   702 
   613 
   703 
   616     const CAiwGenericParamList& aInParamList,
   706     const CAiwGenericParamList& aInParamList,
   617     CAiwGenericParamList& aOutParamList,
   707     CAiwGenericParamList& aOutParamList,
   618     TUint aCmdOptions,
   708     TUint aCmdOptions,
   619     MAiwNotifyCallback* aCallback)
   709     MAiwNotifyCallback* aCallback)
   620     {
   710     {
       
   711     _AKNTRACE_FUNC_ENTER;
       
   712     _AKNTRACE("aMenuCmdId:%x",aMenuCmdId);
       
   713      
       
   714     RProcess pro;
       
   715     AknTracePrint(_L("process name:%S"),&(pro.FileName()));
       
   716     
       
   717     TInt count = aInParamList.Count();
       
   718     for (TInt i = 0; i < count; i++)
       
   719         {
       
   720         _AKNTRACE("i:%d, InParamList[i].SemanticId():%x",i,aInParamList[i].SemanticId());
       
   721         AknTracePrint(_L("i:%d, InParamList[i].Value():%S"),i,&(aInParamList[i].Value().AsDes()));
       
   722 
       
   723         }
       
   724         
       
   725     count = iProviders.Count();
       
   726     for (TInt i = 0; i < count; i++)
       
   727         {
       
   728         AknTracePrint(_L("i:%d, iProviders[i]->ImplementationUid():%x"),i,iProviders[i]->ImplementationUid().iUid);
       
   729         AknTracePrint(_L("i:%d, iProviders[i]:%x"),i,iProviders[i]);
       
   730         }
       
   731     
   621     // CCoeEnv/CEikonEnv needs to be accessible.
   732     // CCoeEnv/CEikonEnv needs to be accessible.
   622     if(!iCoeEnv)
   733     if(!iCoeEnv)
   623         {
   734         {
   624         User::Leave(KErrNotSupported);
   735         User::Leave(KErrNotSupported);
   625         }
   736         }
   651                     return;
   762                     return;
   652                     }
   763                     }
   653                 }
   764                 }
   654             }
   765             }
   655         }
   766         }
       
   767     _AKNTRACE_FUNC_EXIT;
   656     }
   768     }
   657 
   769 
   658 
   770 
   659 
   771 
   660 void CAiwServiceHandlerImpl::AttachMenuL(TInt aMenuResourceId, TInt aInterestResourceId)
   772 void CAiwServiceHandlerImpl::AttachMenuL(TInt aMenuResourceId, TInt aInterestResourceId)
   661     {
   773     {
       
   774     _AKNTRACE_FUNC_ENTER;
       
   775     _AKNTRACE("aMenuResourceId:%x",aMenuResourceId);
       
   776     _AKNTRACE("aInterestResourceId:%x",aInterestResourceId);
       
   777     
   662     // CCoeEnv/CEikonEnv needs to be accessible.
   778     // CCoeEnv/CEikonEnv needs to be accessible.
   663     if(!iCoeEnv)
   779     if(!iCoeEnv)
   664         {
   780         {
   665         User::Leave(KErrNotSupported);
   781         User::Leave(KErrNotSupported);
   666         }
   782         }
   679     DoAttachMenuL(reader, aMenuResourceId, filtered);
   795     DoAttachMenuL(reader, aMenuResourceId, filtered);
   680     filtered.Reset();
   796     filtered.Reset();
   681     CleanupStack::PopAndDestroy(); // reader
   797     CleanupStack::PopAndDestroy(); // reader
   682     CleanupStack::Pop(); // filtered
   798     CleanupStack::Pop(); // filtered
   683     CleanupStack::Pop(); // interest
   799     CleanupStack::Pop(); // interest
       
   800     
       
   801     _AKNTRACE_FUNC_EXIT;
   684     }
   802     }
   685 
   803 
   686 
   804 
   687 
   805 
   688 void CAiwServiceHandlerImpl::AttachMenuL(TInt aMenuResourceId, TResourceReader& aReader)
   806 void CAiwServiceHandlerImpl::AttachMenuL(TInt aMenuResourceId, TResourceReader& aReader)
   689     {
   807     {
       
   808     _AKNTRACE_FUNC_ENTER;
       
   809     _AKNTRACE("aMenuResourceId:%x",aMenuResourceId);
       
   810         
   690     // CCoeEnv/CEikonEnv needs to be accessible.
   811     // CCoeEnv/CEikonEnv needs to be accessible.
   691     if(!iCoeEnv)
   812     if(!iCoeEnv)
   692         {
   813         {
   693         User::Leave(KErrNotSupported);
   814         User::Leave(KErrNotSupported);
   694         }
   815         }
   705     DoAttachMenuL(reader, aMenuResourceId, filtered);
   826     DoAttachMenuL(reader, aMenuResourceId, filtered);
   706     filtered.Reset();
   827     filtered.Reset();
   707     CleanupStack::PopAndDestroy(); // reader
   828     CleanupStack::PopAndDestroy(); // reader
   708     CleanupStack::Pop(); // filtered
   829     CleanupStack::Pop(); // filtered
   709     CleanupStack::Pop(); // interest
   830     CleanupStack::Pop(); // interest
       
   831     
       
   832     _AKNTRACE_FUNC_EXIT;
   710     }
   833     }
   711 
   834 
   712 
   835 
   713 void CAiwServiceHandlerImpl::AttachMenuL(TInt aMenuResourceId, const RCriteriaArray& aInterest)
   836 void CAiwServiceHandlerImpl::AttachMenuL(TInt aMenuResourceId, const RCriteriaArray& aInterest)
   714     {
   837     {
       
   838     _AKNTRACE_FUNC_ENTER;
       
   839     _AKNTRACE("aMenuResourceId:%x",aMenuResourceId);
       
   840         
   715     // CCoeEnv/CEikonEnv needs to be accessible.
   841     // CCoeEnv/CEikonEnv needs to be accessible.
   716     if(!iCoeEnv)
   842     if(!iCoeEnv)
   717         {
   843         {
   718         User::Leave(KErrNotSupported);
   844         User::Leave(KErrNotSupported);
   719         }    
   845         }    
   734         item->SetServiceClass(     aInterest[i]->ServiceClass()          );
   860         item->SetServiceClass(     aInterest[i]->ServiceClass()          );
   735         item->SetOptions(          aInterest[i]->Options()               );
   861         item->SetOptions(          aInterest[i]->Options()               );
   736         item->SetDefaultProvider( (aInterest[i]->DefaultProvider()).iUid );
   862         item->SetDefaultProvider( (aInterest[i]->DefaultProvider()).iUid );
   737         item->SetMaxProviders(     aInterest[i]->MaxProviders()          );       
   863         item->SetMaxProviders(     aInterest[i]->MaxProviders()          );       
   738         
   864         
       
   865         _AKNTRACE("aInterest[i]->Id():%x",aInterest[i]->Id());
       
   866         _AKNTRACE("aInterest[i]->ServiceCmd():%x",aInterest[i]->ServiceCmd());
       
   867         _AKNTRACE("aInterest[i]->ServiceClass():%x",aInterest[i]->ServiceClass());
       
   868         _AKNTRACE("(aInterest[i]->DefaultProvider()).iUid:%x",(aInterest[i]->DefaultProvider()).iUid);
       
   869         _AKNTRACE("aInterest[i]->MaxProviders():%x",aInterest[i]->MaxProviders());
       
   870         
   739         User::LeaveIfError(interest.Append(item));
   871         User::LeaveIfError(interest.Append(item));
   740         CleanupStack::Pop(item); 
   872         CleanupStack::Pop(item); 
   741         }
   873         }
   742         
   874         
   743     FilterInterestListL(interest, filtered);        
   875     FilterInterestListL(interest, filtered);        
   746     DoAttachMenuL(reader, aMenuResourceId, filtered);
   878     DoAttachMenuL(reader, aMenuResourceId, filtered);
   747     filtered.Reset();
   879     filtered.Reset();
   748     CleanupStack::PopAndDestroy(); // reader
   880     CleanupStack::PopAndDestroy(); // reader
   749     CleanupStack::Pop(); // filtered
   881     CleanupStack::Pop(); // filtered
   750     CleanupStack::Pop(); // interest    
   882     CleanupStack::Pop(); // interest    
       
   883     
       
   884     _AKNTRACE_FUNC_EXIT;
   751     }   
   885     }   
   752 
   886 
   753 
   887 
   754 void CAiwServiceHandlerImpl::DoAttachMenuL(TResourceReader& aReader, TInt aMenuId, 
   888 void CAiwServiceHandlerImpl::DoAttachMenuL(TResourceReader& aReader, TInt aMenuId, 
   755     RCriteriaArray& aInterest)
   889     RCriteriaArray& aInterest)
   756     {
   890     {
       
   891     _AKNTRACE_FUNC_ENTER;
       
   892     
       
   893     RProcess pro;
       
   894     AknTracePrint(_L("process name:%S"),&(pro.FileName()));
       
   895         
   757     TInt menuCmd;
   896     TInt menuCmd;
   758     TInt count = aReader.ReadInt16();
   897     TInt count = aReader.ReadInt16();
   759     TBool bound;
   898     TBool bound;
   760 
   899 
   761     for (TInt i = 0; i < count; i++)
   900     for (TInt i = 0; i < count; i++)
   831                 CleanupStack::Pop();  // bind                       
   970                 CleanupStack::Pop();  // bind                       
   832                 }
   971                 }
   833             }
   972             }
   834         SkipMenuFields(aReader);  // Jump to next menu item
   973         SkipMenuFields(aReader);  // Jump to next menu item
   835         }
   974         }
       
   975     
       
   976     _AKNTRACE_FUNC_EXIT;
   836     }
   977     }
   837 
   978 
   838 
   979 
   839 void CAiwServiceHandlerImpl::ReadInterestL(RCriteriaArray& aInterest, TInt aInterestResourceId)
   980 void CAiwServiceHandlerImpl::ReadInterestL(RCriteriaArray& aInterest, TInt aInterestResourceId)
   840     {
   981     {
   847     }
   988     }
   848 
   989 
   849 
   990 
   850 void CAiwServiceHandlerImpl::DetachMenu(TInt aMenuResourceId, TInt aInterestResourceId)
   991 void CAiwServiceHandlerImpl::DetachMenu(TInt aMenuResourceId, TInt aInterestResourceId)
   851     {
   992     {
       
   993     _AKNTRACE_FUNC_ENTER;
       
   994     _AKNTRACE("aMenuResourceId:%x",aMenuResourceId);
       
   995     _AKNTRACE("aInterestResourceId:%x",aInterestResourceId);
       
   996         
   852     // If interest resource id is null, then detach all items in the given menu.
   997     // If interest resource id is null, then detach all items in the given menu.
   853     if (!aInterestResourceId)
   998     if (!aInterestResourceId)
   854         {
   999         {
   855         DoDetachMenu(aMenuResourceId);        
  1000         DoDetachMenu(aMenuResourceId);        
   856         }
  1001         }
   872         
  1017         
   873         DoDetachMenu(aMenuResourceId, interest);
  1018         DoDetachMenu(aMenuResourceId, interest);
   874         
  1019         
   875         interest.ResetAndDestroy();
  1020         interest.ResetAndDestroy();
   876         }
  1021         }
       
  1022     
       
  1023     _AKNTRACE_FUNC_EXIT;
   877     }
  1024     }
   878         
  1025         
   879 
  1026 
   880 void CAiwServiceHandlerImpl::DoDetachMenu(TInt aMenuResourceId)
  1027 void CAiwServiceHandlerImpl::DoDetachMenu(TInt aMenuResourceId)
   881     {
  1028     {
       
  1029     _AKNTRACE_FUNC_ENTER;
       
  1030     _AKNTRACE("aMenuResourceId:%x",aMenuResourceId);
       
  1031         
   882     // First, delete the relevant menu bindings.
  1032     // First, delete the relevant menu bindings.
   883     for (TInt i = 0; i < iMenuBindings.Count(); i++)
  1033     for (TInt i = 0; i < iMenuBindings.Count(); i++)
   884         {
  1034         {
   885         if (iMenuBindings[i]->MenuId() == aMenuResourceId)
  1035         if (iMenuBindings[i]->MenuId() == aMenuResourceId)
   886             {
  1036             {
   893     // Then check if there were left obselete criteria items and remove them.   
  1043     // Then check if there were left obselete criteria items and remove them.   
   894     RemoveObsoleteCriteriaItems();
  1044     RemoveObsoleteCriteriaItems();
   895     
  1045     
   896     // Finally check if there were left obselete providers and remove them.
  1046     // Finally check if there were left obselete providers and remove them.
   897     RemoveObsoleteProviders();  
  1047     RemoveObsoleteProviders();  
       
  1048     
       
  1049     _AKNTRACE_FUNC_EXIT;
   898     }
  1050     }
   899 
  1051 
   900     
  1052     
   901 void CAiwServiceHandlerImpl::DoDetachMenu(TInt aMenuResourceId, RCriteriaArray& aInterest)
  1053 void CAiwServiceHandlerImpl::DoDetachMenu(TInt aMenuResourceId, RCriteriaArray& aInterest)
   902     {
  1054     {
       
  1055     _AKNTRACE_FUNC_ENTER;
       
  1056     _AKNTRACE("aMenuResourceId:%x",aMenuResourceId);
       
  1057     
   903     // First, remove relevant criteria items from relevant menu bindings.
  1058     // First, remove relevant criteria items from relevant menu bindings.
   904     for (TInt i = 0; i < iMenuBindings.Count(); i++)
  1059     for (TInt i = 0; i < iMenuBindings.Count(); i++)
   905         {
  1060         {
   906         if (iMenuBindings[i]->MenuId() == aMenuResourceId) 
  1061         if (iMenuBindings[i]->MenuId() == aMenuResourceId) 
   907             {
  1062             {
   929     
  1084     
   930     // Then check if there were left obselete criteria items and remove them.   
  1085     // Then check if there were left obselete criteria items and remove them.   
   931     RemoveObsoleteCriteriaItems();
  1086     RemoveObsoleteCriteriaItems();
   932     
  1087     
   933     // Finally check if there were left obselete providers and remove them.
  1088     // Finally check if there were left obselete providers and remove them.
   934     RemoveObsoleteProviders();        
  1089     RemoveObsoleteProviders();      
       
  1090     
       
  1091     _AKNTRACE_FUNC_EXIT;
   935     }    
  1092     }    
   936     
  1093     
   937     
  1094     
   938 void CAiwServiceHandlerImpl::RemoveObsoleteCriteriaItems()
  1095 void CAiwServiceHandlerImpl::RemoveObsoleteCriteriaItems()
   939     {
  1096     {
       
  1097     _AKNTRACE_FUNC_ENTER;
       
  1098     
   940     for (TInt i = 0; i < iInterestList.Count(); i++)
  1099     for (TInt i = 0; i < iInterestList.Count(); i++)
   941         {
  1100         {
   942         CAiwCriteriaItem* criteria = iInterestList[i];
  1101         CAiwCriteriaItem* criteria = iInterestList[i];
   943         TBool found = EFalse;
  1102         TBool found = EFalse;
   944         
  1103         
   971             delete iInterestList[i];
  1130             delete iInterestList[i];
   972             iInterestList.Remove(i);
  1131             iInterestList.Remove(i);
   973             i--;
  1132             i--;
   974             }
  1133             }
   975         }    
  1134         }    
       
  1135     
       
  1136     _AKNTRACE_FUNC_EXIT;
   976     }
  1137     }
   977     
  1138     
   978     
  1139     
   979 void CAiwServiceHandlerImpl::RemoveObsoleteProviders()
  1140 void CAiwServiceHandlerImpl::RemoveObsoleteProviders()
   980     {
  1141     {
       
  1142     _AKNTRACE_FUNC_ENTER;
       
  1143     
   981     for (TInt i = 0; i < iProviders.Count(); i++)
  1144     for (TInt i = 0; i < iProviders.Count(); i++)
   982         {
  1145         {
   983         CAiwServiceIfBase* provider = iProviders[i];
  1146         CAiwServiceIfBase* provider = iProviders[i];
   984         TBool found = EFalse;
  1147         TBool found = EFalse;
   985         
  1148         
  1012             delete iProviders[i];
  1175             delete iProviders[i];
  1013             iProviders.Remove(i);
  1176             iProviders.Remove(i);
  1014             i--;
  1177             i--;
  1015             }
  1178             }
  1016         }    
  1179         }    
       
  1180     _AKNTRACE_FUNC_EXIT;
  1017     }
  1181     }
  1018 
  1182 
  1019 
  1183 
  1020 TBool CAiwServiceHandlerImpl::IsSubMenuEmpty(TInt aSubMenuId)
  1184 TBool CAiwServiceHandlerImpl::IsSubMenuEmpty(TInt aSubMenuId)
  1021     {
  1185     {
       
  1186     _AKNTRACE_FUNC_ENTER;
       
  1187     _AKNTRACE("aSubMenuId:%d",aSubMenuId);
       
  1188   
  1022     for (TInt i = 0; i < iMenuBindings.Count(); i++)
  1189     for (TInt i = 0; i < iMenuBindings.Count(); i++)
  1023         {
  1190         {
  1024         if (iMenuBindings[i]->MenuId() == aSubMenuId)
  1191         if (iMenuBindings[i]->MenuId() == aSubMenuId)
  1025             {
  1192             {
  1026             if (iMenuBindings[i]->NumberOfProviders() > 0)
  1193             if (iMenuBindings[i]->NumberOfProviders() > 0)
  1027                 {
  1194                 {
       
  1195                 _AKNTRACE("return false");
       
  1196                 _AKNTRACE_FUNC_EXIT;
  1028                 return EFalse;
  1197                 return EFalse;
  1029                 }
  1198                 }
  1030 
  1199 
       
  1200             _AKNTRACE("return true");
       
  1201             _AKNTRACE_FUNC_EXIT;
  1031             return ETrue;
  1202             return ETrue;
  1032             }
  1203             }
  1033         }
  1204         }
  1034 
  1205     
       
  1206     _AKNTRACE_FUNC_EXIT;
  1035     return EFalse;
  1207     return EFalse;
  1036     }
  1208     }
  1037 
  1209 
  1038 
  1210 
  1039 
  1211 
  1040 
  1212 
  1041 CAiwMenuBinding* CAiwServiceHandlerImpl::AlreadyBound(TInt aMenuId, TInt aMenuCmd, 
  1213 CAiwMenuBinding* CAiwServiceHandlerImpl::AlreadyBound(TInt aMenuId, TInt aMenuCmd, 
  1042     TInt aMenuItemIndex) const
  1214     TInt aMenuItemIndex) const
  1043     {
  1215     {
       
  1216     _AKNTRACE_FUNC_ENTER;
       
  1217     
  1044     for (TInt i = 0; i < iMenuBindings.Count(); i++)
  1218     for (TInt i = 0; i < iMenuBindings.Count(); i++)
  1045         {
  1219         {
  1046         if ((iMenuBindings[i]->MenuId() == aMenuId) &&
  1220         if ((iMenuBindings[i]->MenuId() == aMenuId) &&
  1047             (iMenuBindings[i]->MenuCmd() == aMenuCmd) &&
  1221             (iMenuBindings[i]->MenuCmd() == aMenuCmd) &&
  1048             (iMenuBindings[i]->MenuItemIndex() == aMenuItemIndex))
  1222             (iMenuBindings[i]->MenuItemIndex() == aMenuItemIndex))
  1049             {
  1223             {
       
  1224             _AKNTRACE("iMenuBindings[i]:%x",iMenuBindings[i]);
       
  1225             _AKNTRACE_FUNC_EXIT;
  1050             return iMenuBindings[i];
  1226             return iMenuBindings[i];
  1051             }
  1227             }
  1052         }
  1228         }
  1053 
  1229 
       
  1230     _AKNTRACE_FUNC_EXIT;
  1054     return NULL;
  1231     return NULL;
  1055     }
  1232     }
  1056 
  1233 
  1057 
  1234 
  1058 void CAiwServiceHandlerImpl::ExecuteServiceCmdL(
  1235 void CAiwServiceHandlerImpl::ExecuteServiceCmdL(
  1060     const CAiwGenericParamList& aInParamList,
  1237     const CAiwGenericParamList& aInParamList,
  1061     CAiwGenericParamList& aOutParamList,
  1238     CAiwGenericParamList& aOutParamList,
  1062     TUint aCmdOptions,
  1239     TUint aCmdOptions,
  1063     MAiwNotifyCallback* aCallback)
  1240     MAiwNotifyCallback* aCallback)
  1064     {
  1241     {
       
  1242     _AKNTRACE_FUNC_ENTER;
       
  1243     _AKNTRACE("aCmdId:%x",aCmdId);
       
  1244     _AKNTRACE("aCmdOptions:%x",aCmdOptions);
       
  1245     
       
  1246     RProcess pro;
       
  1247     AknTracePrint(_L("process name:%S"),&(pro.FileName()));
       
  1248 
       
  1249     TInt count = aInParamList.Count();
       
  1250     for (TInt i = 0; i < count; i++)
       
  1251         {
       
  1252         _AKNTRACE("i:%d, InParamList[i].SemanticId():%x",i,aInParamList[i].SemanticId());
       
  1253         AknTracePrint(_L("i:%d, InParamList[i].Value():%S"),i,&(aInParamList[i].Value().AsDes()));
       
  1254 
       
  1255         }
       
  1256         
  1065     for (TInt i = 0; i < iBaseBindings.Count(); i++)
  1257     for (TInt i = 0; i < iBaseBindings.Count(); i++)
  1066         {
  1258         {
  1067         if(iBaseBindings[i]->HasServiceCmd(aCmdId))
  1259         if(iBaseBindings[i]->HasServiceCmd(aCmdId))
  1068             {
  1260             {
  1069             for (TInt j = 0; j < iBaseBindings[i]->NumberOfProviders(); j++)
  1261             for (TInt j = 0; j < iBaseBindings[i]->NumberOfProviders(); j++)
  1075                     aCmdOptions, 
  1267                     aCmdOptions, 
  1076                     aCallback);
  1268                     aCallback);
  1077                 }
  1269                 }
  1078             }
  1270             }
  1079         }
  1271         }
       
  1272     
       
  1273     _AKNTRACE_FUNC_EXIT;
  1080     }
  1274     }
  1081 
  1275 
  1082 
  1276 
  1083 
  1277 
  1084 void CAiwServiceHandlerImpl::ReadInterestListL(TResourceReader& aReader, 
  1278 void CAiwServiceHandlerImpl::ReadInterestListL(TResourceReader& aReader, 
  1085     RPointerArray<CAiwCriteriaItem>& aResult)  
  1279     RPointerArray<CAiwCriteriaItem>& aResult)  
  1086     {
  1280     {
       
  1281     _AKNTRACE_FUNC_ENTER;
       
  1282     
  1087     const TInt count = aReader.ReadInt16();
  1283     const TInt count = aReader.ReadInt16();
  1088     for (TInt ii = 0; ii < count; ++ii)
  1284     for (TInt ii = 0; ii < count; ++ii)
  1089         {
  1285         {
  1090         CAiwCriteriaItem* item = CAiwCriteriaItem::NewLC();
  1286         CAiwCriteriaItem* item = CAiwCriteriaItem::NewLC();
  1091         item->ReadFromResoureL( aReader );
  1287         item->ReadFromResoureL( aReader );
  1092         User::LeaveIfError(aResult.Append(item));
  1288         User::LeaveIfError(aResult.Append(item));
  1093         CleanupStack::Pop(); // item
  1289         CleanupStack::Pop(); // item
  1094         }
  1290         }
       
  1291     
       
  1292     _AKNTRACE_FUNC_EXIT;
  1095     }
  1293     }
  1096 
  1294 
  1097 
  1295 
  1098 TInt CAiwServiceHandlerImpl::ResolveProvidersL(CAiwBinding* aBinding, CAiwCriteriaItem* aItem)
  1296 TInt CAiwServiceHandlerImpl::ResolveProvidersL(CAiwBinding* aBinding, CAiwCriteriaItem* aItem)
  1099     {
  1297     {
       
  1298     _AKNTRACE_FUNC_ENTER;
       
  1299     
  1100     RImplInfoPtrArray infoArray;
  1300     RImplInfoPtrArray infoArray;
  1101     TInt result = 0;
  1301     TInt result = 0;
  1102 
  1302 
  1103     CleanupStack::PushL( TCleanupItem( Cleanup, &infoArray ) );
  1303     CleanupStack::PushL( TCleanupItem( Cleanup, &infoArray ) );
  1104 
  1304 
  1155             }
  1355             }
  1156         }
  1356         }
  1157 
  1357 
  1158     CleanupStack::PopAndDestroy(); // infoArray     
  1358     CleanupStack::PopAndDestroy(); // infoArray     
  1159 
  1359 
       
  1360     _AKNTRACE_FUNC_EXIT;
       
  1361     
  1160     return result;
  1362     return result;
  1161     }
  1363     }
  1162 
  1364 
  1163 
  1365 
  1164 
  1366 
  1165 void CAiwServiceHandlerImpl::FilterInfoArray(RImplInfoPtrArray& aArray, CAiwCriteriaItem* aItem)
  1367 void CAiwServiceHandlerImpl::FilterInfoArray(RImplInfoPtrArray& aArray, CAiwCriteriaItem* aItem)
  1166     {
  1368     {
       
  1369     _AKNTRACE_FUNC_ENTER;
       
  1370     
  1167     if (aItem->MaxProviders() <= 0)
  1371     if (aItem->MaxProviders() <= 0)
  1168         {
  1372         {
  1169         aArray.ResetAndDestroy();
  1373         aArray.ResetAndDestroy();
  1170         }
  1374         }
  1171     else
  1375     else
  1183                 delete aArray[0];
  1387                 delete aArray[0];
  1184                 aArray.Remove(0);               
  1388                 aArray.Remove(0);               
  1185                 }
  1389                 }
  1186             }
  1390             }
  1187         }
  1391         }
       
  1392     
       
  1393     _AKNTRACE_FUNC_EXIT;
  1188     }
  1394     }
  1189 
  1395 
  1190 
  1396 
  1191 
  1397 
  1192 TBool CAiwServiceHandlerImpl::IsCached(CAiwServiceIfBase* /*aProvider*/)
  1398 TBool CAiwServiceHandlerImpl::IsCached(CAiwServiceIfBase* /*aProvider*/)
  1219 
  1425 
  1220 
  1426 
  1221 
  1427 
  1222 TBool CAiwServiceHandlerImpl::IsInLastInitialized(CAiwMenuPane* aiwPane) const
  1428 TBool CAiwServiceHandlerImpl::IsInLastInitialized(CAiwMenuPane* aiwPane) const
  1223     {
  1429     {
       
  1430     _AKNTRACE_FUNC_ENTER;
  1224     if (aiwPane)
  1431     if (aiwPane)
  1225         {
  1432         {
  1226         if (iSubmenu == aiwPane)
  1433         if (iSubmenu == aiwPane)
  1227             {
  1434             {
  1228             return ETrue;       
  1435             return ETrue;       
  1235                 return ETrue;
  1442                 return ETrue;
  1236                 }
  1443                 }
  1237             }
  1444             }
  1238         }
  1445         }
  1239 
  1446 
       
  1447     _AKNTRACE_FUNC_EXIT;
  1240     return EFalse;
  1448     return EFalse;
  1241     }
  1449     }
  1242 
  1450 
  1243 
  1451 
  1244 TInt CAiwServiceHandlerImpl::HandleNotifyL(
  1452 TInt CAiwServiceHandlerImpl::HandleNotifyL(
  1267 
  1475 
  1268 
  1476 
  1269 CAiwMenuPane* CAiwServiceHandlerImpl::CreateEmptyAiwMenuPaneL(TInt aBaseMenuCmdId, 
  1477 CAiwMenuPane* CAiwServiceHandlerImpl::CreateEmptyAiwMenuPaneL(TInt aBaseMenuCmdId, 
  1270     TInt aResourceId)
  1478     TInt aResourceId)
  1271     {
  1479     {
       
  1480     _AKNTRACE_FUNC_ENTER;
       
  1481     
  1272     CAiwMenuPane* result = NULL;
  1482     CAiwMenuPane* result = NULL;
  1273     TResourceReader reader; 
  1483     TResourceReader reader; 
  1274     
  1484     
  1275     TInt id;
  1485     TInt id;
  1276     if(aResourceId >= 0)
  1486     if(aResourceId >= 0)
  1299     CleanupStack::Pop(pane);
  1509     CleanupStack::Pop(pane);
  1300     CleanupStack::PopAndDestroy(); // reader
  1510     CleanupStack::PopAndDestroy(); // reader
  1301     
  1511     
  1302     result->SetResourceSlotId( id );
  1512     result->SetResourceSlotId( id );
  1303     
  1513     
       
  1514     _AKNTRACE_FUNC_EXIT;
       
  1515     
  1304     return result;
  1516     return result;
  1305     }
  1517     }
  1306 
  1518 
  1307 
  1519 
  1308 void CAiwServiceHandlerImpl::DeleteAiwMenuPane(CAiwMenuPane* aAiwPane)
  1520 void CAiwServiceHandlerImpl::DeleteAiwMenuPane(CAiwMenuPane* aAiwPane)
  1309     {
  1521     {
       
  1522     _AKNTRACE_FUNC_ENTER;
       
  1523     
  1310     delete aAiwPane->iMenuPane;
  1524     delete aAiwPane->iMenuPane;
  1311     aAiwPane->iMenuPane = NULL;
  1525     aAiwPane->iMenuPane = NULL;
  1312 
  1526 
  1313     // Reset iIdMap and extraText.
  1527     // Reset iIdMap and extraText.
  1314     for(TInt i = 0; i < aAiwPane->iIdMap.Count(); i++)
  1528     for(TInt i = 0; i < aAiwPane->iIdMap.Count(); i++)
  1337             }
  1551             }
  1338         }                        
  1552         }                        
  1339     
  1553     
  1340     delete aAiwPane;
  1554     delete aAiwPane;
  1341     aAiwPane = NULL;    
  1555     aAiwPane = NULL;    
       
  1556     
       
  1557     _AKNTRACE_FUNC_EXIT;
  1342     }
  1558     }
  1343 
  1559 
  1344 const TInt resourceSlotIds[KMaxMenuResources] =
  1560 const TInt resourceSlotIds[KMaxMenuResources] =
  1345     {
  1561     {
  1346     R_AIW_EMPTY_MENU_0,
  1562     R_AIW_EMPTY_MENU_0,
  1362     };
  1578     };
  1363 
  1579 
  1364 
  1580 
  1365 TInt CAiwServiceHandlerImpl::ResourceIdForNextFreeSlot()
  1581 TInt CAiwServiceHandlerImpl::ResourceIdForNextFreeSlot()
  1366     {
  1582     {
       
  1583     _AKNTRACE_FUNC_ENTER;
       
  1584     
  1367     if (iNextFreeSlot < KMaxMenuResources)
  1585     if (iNextFreeSlot < KMaxMenuResources)
  1368         {
  1586         {
  1369         return resourceSlotIds[iNextFreeSlot++];
  1587         return resourceSlotIds[iNextFreeSlot++];
  1370         }
  1588         }
  1371 
  1589 
       
  1590     _AKNTRACE_FUNC_EXIT;
  1372     return -1;
  1591     return -1;
  1373     }
  1592     }
  1374 
  1593 
  1375 
  1594 
  1376 void CAiwServiceHandlerImpl::SetEmphasis(CCoeControl* /*aMenuControl*/,TBool /*aEmphasis*/)
  1595 void CAiwServiceHandlerImpl::SetEmphasis(CCoeControl* /*aMenuControl*/,TBool /*aEmphasis*/)
  1383     }
  1602     }
  1384 
  1603 
  1385 
  1604 
  1386 void Cleanup( TAny* aAny )
  1605 void Cleanup( TAny* aAny )
  1387     {
  1606     {
       
  1607     _AKNTRACE_FUNC_ENTER;
       
  1608     
  1388     RImplInfoPtrArray* implArray = 
  1609     RImplInfoPtrArray* implArray = 
  1389         reinterpret_cast< RImplInfoPtrArray*> ( aAny );
  1610         reinterpret_cast< RImplInfoPtrArray*> ( aAny );
  1390     implArray->ResetAndDestroy();
  1611     implArray->ResetAndDestroy();
  1391     implArray->Close();
  1612     implArray->Close();
       
  1613     
       
  1614     _AKNTRACE_FUNC_EXIT;
  1392     }
  1615     }
  1393 
  1616 
  1394 
  1617 
  1395 void InterestCleanup( TAny* aAny )
  1618 void InterestCleanup( TAny* aAny )
  1396     {
  1619     {
       
  1620     _AKNTRACE_FUNC_ENTER;
       
  1621     
  1397     RPointerArray<CAiwCriteriaItem>* interestArray = 
  1622     RPointerArray<CAiwCriteriaItem>* interestArray = 
  1398         reinterpret_cast<RPointerArray<CAiwCriteriaItem>*> ( aAny );
  1623         reinterpret_cast<RPointerArray<CAiwCriteriaItem>*> ( aAny );
  1399 
  1624 
  1400     interestArray->ResetAndDestroy();   
  1625     interestArray->ResetAndDestroy();
       
  1626     
       
  1627     _AKNTRACE_FUNC_EXIT;
  1401     }
  1628     }
  1402 
  1629 
  1403 void FilteredCleanup( TAny* aAny )
  1630 void FilteredCleanup( TAny* aAny )
  1404     {
  1631     {
       
  1632     _AKNTRACE_FUNC_ENTER;
       
  1633     
  1405     RPointerArray<CAiwCriteriaItem>* filteredArray = 
  1634     RPointerArray<CAiwCriteriaItem>* filteredArray = 
  1406         reinterpret_cast<RPointerArray<CAiwCriteriaItem>*> ( aAny );
  1635         reinterpret_cast<RPointerArray<CAiwCriteriaItem>*> ( aAny );
  1407 
  1636 
  1408     filteredArray->Reset();   
  1637     filteredArray->Reset();
       
  1638     
       
  1639     _AKNTRACE_FUNC_EXIT;
  1409     }
  1640     }
  1410 
  1641 
  1411 
  1642 
  1412 void IntArrayCleanup(TAny* aAny)
  1643 void IntArrayCleanup(TAny* aAny)
  1413     {
  1644     {
       
  1645     _AKNTRACE_FUNC_ENTER;
       
  1646     
  1414     RArray<TInt>* intArray = 
  1647     RArray<TInt>* intArray = 
  1415         reinterpret_cast<RArray<TInt>*> ( aAny );
  1648         reinterpret_cast<RArray<TInt>*> ( aAny );
  1416 
  1649 
  1417     intArray->Close();
  1650     intArray->Close();
       
  1651     
       
  1652     _AKNTRACE_FUNC_EXIT;
  1418     }
  1653     }
  1419 
  1654 
  1420 
  1655 
  1421 void CAiwServiceHandlerImpl::CopyMenuItemsL(CAiwMenuPane* aSource, CEikMenuPane& aDest, 
  1656 void CAiwServiceHandlerImpl::CopyMenuItemsL(CAiwMenuPane* aSource, CEikMenuPane& aDest, 
  1422     TInt aStartIndex, TBool aIsSubmenu, TBool aSetAsItemSpecific)
  1657     TInt aStartIndex, TBool aIsSubmenu, TBool aSetAsItemSpecific)
  1423     {
  1658     {
       
  1659     _AKNTRACE_FUNC_ENTER;
       
  1660     
  1424     TInt cmdId;
  1661     TInt cmdId;
  1425     TInt inPos = aStartIndex;
  1662     TInt inPos = aStartIndex;
  1426 
  1663 
  1427     for (TInt i = 0; i < aSource->MenuPane().NumberOfItemsInPane(); i++)
  1664     for (TInt i = 0; i < aSource->MenuPane().NumberOfItemsInPane(); i++)
  1428         {
  1665         {
  1449                 }
  1686                 }
  1450             
  1687             
  1451             aDest.InsertMenuItemL(itemData, inPos++);
  1688             aDest.InsertMenuItemL(itemData, inPos++);
  1452             }   
  1689             }   
  1453         }   
  1690         }   
       
  1691     
       
  1692     _AKNTRACE_FUNC_EXIT;
  1454     }
  1693     }
  1455 
  1694 
  1456 
  1695 
  1457 
  1696 
  1458 TInt CAiwServiceHandlerImpl::SlotItemCmd(CEikMenuPane& aPane)
  1697 TInt CAiwServiceHandlerImpl::SlotItemCmd(CEikMenuPane& aPane)
  1459     {
  1698     {
       
  1699     _AKNTRACE_FUNC_ENTER;
       
  1700     
  1460     TInt index;
  1701     TInt index;
  1461 
  1702 
  1462     for (TInt i = 0; i < KMaxMenuResources; i++)
  1703     for (TInt i = 0; i < KMaxMenuResources; i++)
  1463         {
  1704         {
  1464         if (aPane.MenuItemExists(EAiwMenuSlotBase + i, index))
  1705         if (aPane.MenuItemExists(EAiwMenuSlotBase + i, index))
  1465             {
  1706             {
  1466             return EAiwMenuSlotBase + i;
  1707             return EAiwMenuSlotBase + i;
  1467             }
  1708             }
  1468         }
  1709         }
  1469 
  1710 
       
  1711     _AKNTRACE_FUNC_EXIT;
  1470     return -1;
  1712     return -1;
  1471     }
  1713     }
  1472 
  1714 
  1473 
  1715 
  1474 
  1716 
  1475 CAiwMenuPane* CAiwServiceHandlerImpl::MenuPaneForSlotCmd(TInt aCmdId)
  1717 CAiwMenuPane* CAiwServiceHandlerImpl::MenuPaneForSlotCmd(TInt aCmdId)
  1476     {
  1718     {
       
  1719     _AKNTRACE_FUNC_ENTER;    
       
  1720 
  1477     TInt index = aCmdId - EAiwMenuSlotBase; 
  1721     TInt index = aCmdId - EAiwMenuSlotBase; 
  1478 
  1722 
  1479     if (index < KMaxMenuResources)
  1723     if (index < KMaxMenuResources)
  1480         {
  1724         {
  1481         TInt resId = resourceSlotIds[index];
  1725         TInt resId = resourceSlotIds[index];
  1486                 return iMenuPanes[i];
  1730                 return iMenuPanes[i];
  1487                 }
  1731                 }
  1488             }
  1732             }
  1489         }
  1733         }
  1490 
  1734 
       
  1735     _AKNTRACE_FUNC_EXIT;
       
  1736 
  1491     return NULL;
  1737     return NULL;
  1492     }
  1738     }
  1493 
  1739 
  1494 
  1740 
  1495 
  1741 
  1496 CAiwServiceHandlerImpl::TAiwPlaceholderType CAiwServiceHandlerImpl::PlaceholderType(
  1742 CAiwServiceHandlerImpl::TAiwPlaceholderType CAiwServiceHandlerImpl::PlaceholderType(
  1497     CEikMenuPane& aPane, TInt aCmd, TBool& aTitleLocked)
  1743     CEikMenuPane& aPane, TInt aCmd, TBool& aTitleLocked)
  1498     {
  1744     {
       
  1745     _AKNTRACE_FUNC_ENTER;
       
  1746     
  1499     CEikMenuPaneItem::SData& itemData = aPane.ItemData(aCmd);
  1747     CEikMenuPaneItem::SData& itemData = aPane.ItemData(aCmd);
  1500 
  1748     _AKNTRACE("itemData.iCascadeId:%x",itemData.iCascadeId);
       
  1749     
  1501     aTitleLocked = EFalse;
  1750     aTitleLocked = EFalse;
  1502 
  1751 
  1503     if ((itemData.iCascadeId & AIW_CASCADE_ID) == AIW_CASCADE_ID)
  1752     if ((itemData.iCascadeId & AIW_CASCADE_ID) == AIW_CASCADE_ID)
  1504         {
  1753         {
  1505         if (itemData.iCascadeId & AIW_LOCK_SUBMENU_TITLE)
  1754         if (itemData.iCascadeId & AIW_LOCK_SUBMENU_TITLE)
  1515             aTitleLocked = ETrue;
  1764             aTitleLocked = ETrue;
  1516             }
  1765             }
  1517         return EAiwPlaceholderIntelligentCascade;
  1766         return EAiwPlaceholderIntelligentCascade;
  1518         }
  1767         }
  1519 
  1768 
       
  1769     _AKNTRACE_FUNC_EXIT;
  1520     return EAiwPlaceholderNormal;
  1770     return EAiwPlaceholderNormal;
  1521     }
  1771     }
  1522 
  1772 
  1523 
  1773 
  1524 void CAiwServiceHandlerImpl::ConvertPlaceholderL(CEikMenuPane& aPane, TInt aCmd, 
  1774 void CAiwServiceHandlerImpl::ConvertPlaceholderL(CEikMenuPane& aPane, TInt aCmd, 
  1525     CAiwMenuPane& aAiwPane, const TDesC& aTitle, TBool aSetAsItemSpecific)
  1775     CAiwMenuPane& aAiwPane, const TDesC& aTitle, TBool aSetAsItemSpecific)
  1526     {
  1776     {
       
  1777     _AKNTRACE_FUNC_ENTER;
       
  1778     
  1527     CEikMenuPaneItem::SData itemData = aPane.ItemData(aCmd);
  1779     CEikMenuPaneItem::SData itemData = aPane.ItemData(aCmd);
  1528     TInt index;
  1780     TInt index;
  1529 
  1781 
  1530     // Remenber index.
  1782     // Remenber index.
  1531     aPane.MenuItemExists(aCmd, index);
  1783     aPane.MenuItemExists(aCmd, index);
  1549         itemData.iFlags |= EEikMenuItemSpecific;
  1801         itemData.iFlags |= EEikMenuItemSpecific;
  1550         }
  1802         }
  1551 
  1803 
  1552     // Insert cascade item.
  1804     // Insert cascade item.
  1553     aPane.InsertMenuItemL(itemData, index);
  1805     aPane.InsertMenuItemL(itemData, index);
       
  1806     
       
  1807     _AKNTRACE_FUNC_EXIT;
  1554     }
  1808     }
  1555 
  1809 
  1556 
  1810 
  1557 void CAiwServiceHandlerImpl::UnCascadeL(CEikMenuPane& aPane, TInt aCmd,
  1811 void CAiwServiceHandlerImpl::UnCascadeL(CEikMenuPane& aPane, TInt aCmd,
  1558     CAiwMenuPane& aAiwPane, TBool aSetAsItemSpecific)
  1812     CAiwMenuPane& aAiwPane, TBool aSetAsItemSpecific)
  1559     {
  1813     {
       
  1814     _AKNTRACE_FUNC_ENTER;
       
  1815     
  1560     CEikMenuPaneItem::SData itemData = aAiwPane.MenuPane().ItemData(aAiwPane.FindCmdId(0));
  1816     CEikMenuPaneItem::SData itemData = aAiwPane.MenuPane().ItemData(aAiwPane.FindCmdId(0));
  1561     TInt index;
  1817     TInt index;
  1562 
  1818 
  1563     // Remenber index.
  1819     // Remenber index.
  1564     aPane.MenuItemExists(aCmd, index);
  1820     aPane.MenuItemExists(aCmd, index);
  1574         itemData.iFlags |= EEikMenuItemSpecific;
  1830         itemData.iFlags |= EEikMenuItemSpecific;
  1575         }
  1831         }
  1576 
  1832 
  1577     // Insert cascade item.
  1833     // Insert cascade item.
  1578     aPane.InsertMenuItemL(itemData, index);     
  1834     aPane.InsertMenuItemL(itemData, index);     
       
  1835     
       
  1836     _AKNTRACE_FUNC_EXIT;
  1579     }
  1837     }
  1580 
  1838 
  1581 
  1839 
  1582 
  1840 
  1583 void CAiwServiceHandlerImpl::SkipMenuFields(TResourceReader& aReader)
  1841 void CAiwServiceHandlerImpl::SkipMenuFields(TResourceReader& aReader)
  1584     {
  1842     {
       
  1843     _AKNTRACE_FUNC_ENTER;
       
  1844     
  1585     aReader.ReadInt32(); // Skip cascade id
  1845     aReader.ReadInt32(); // Skip cascade id
  1586     aReader.ReadInt32(); // Skip flags
  1846     aReader.ReadInt32(); // Skip flags
  1587     aReader.ReadTPtrC(); // Skip text
  1847     aReader.ReadTPtrC(); // Skip text
  1588     aReader.ReadTPtrC(); // Skip extra text
  1848     aReader.ReadTPtrC(); // Skip extra text
  1589     aReader.ReadTPtrC(); // Skip bmpfile.
  1849     aReader.ReadTPtrC(); // Skip bmpfile.
  1590     aReader.ReadInt16(); // Skip bmpid.
  1850     aReader.ReadInt16(); // Skip bmpid.
  1591     aReader.ReadInt16(); // Skip bmpmask. 
  1851     aReader.ReadInt16(); // Skip bmpmask. 
  1592     aReader.ReadInt32(); // Skip extension.   
  1852     aReader.ReadInt32(); // Skip extension.   
       
  1853     
       
  1854     _AKNTRACE_FUNC_EXIT;
  1593     }
  1855     }
  1594 
  1856 
  1595 
  1857 
  1596 TBool CAiwServiceHandlerImpl::IsAiwMenu(TInt aMenuResourceId)
  1858 TBool CAiwServiceHandlerImpl::IsAiwMenu(TInt aMenuResourceId)
  1597     {
  1859     {
       
  1860     _AKNTRACE_FUNC_ENTER;
       
  1861     
  1598     TInt i;
  1862     TInt i;
  1599 
  1863 
  1600     // First check if this is aiw submenu id
  1864     // First check if this is aiw submenu id
  1601     for (i = 0; i < KMaxMenuResources; i++)
  1865     for (i = 0; i < KMaxMenuResources; i++)
  1602         {
  1866         {
  1613             {
  1877             {
  1614             return ETrue;
  1878             return ETrue;
  1615             }
  1879             }
  1616         }
  1880         }
  1617 
  1881 
       
  1882     _AKNTRACE_FUNC_EXIT;
       
  1883     
  1618     return EFalse;
  1884     return EFalse;
  1619     }
  1885     }
  1620 
  1886 
  1621 
  1887 
  1622 
  1888 
  1623 TBool CAiwServiceHandlerImpl::HandleSubmenuL(CEikMenuPane& aPane)
  1889 TBool CAiwServiceHandlerImpl::HandleSubmenuL(CEikMenuPane& aPane)
  1624     {
  1890     {
       
  1891     _AKNTRACE_FUNC_ENTER;
  1625     TInt slotcmd = SlotItemCmd(aPane);
  1892     TInt slotcmd = SlotItemCmd(aPane);
  1626     if (slotcmd >= 0)
  1893     if (slotcmd >= 0)
  1627         {
  1894         {
  1628         // aPane is aiw submenu. At this point it is empty and we must
  1895         // aPane is aiw submenu. At this point it is empty and we must
  1629         // copy provider menu items to it.
  1896         // copy provider menu items to it.
  1635             iSubmenu = aiwPane;     
  1902             iSubmenu = aiwPane;     
  1636             return ETrue;
  1903             return ETrue;
  1637             }
  1904             }
  1638         }
  1905         }
  1639 
  1906 
       
  1907     _AKNTRACE_FUNC_EXIT;
  1640     return EFalse;
  1908     return EFalse;
  1641     }
  1909     }
  1642 
  1910 
  1643 
  1911 
  1644 
  1912 
  1645 TBool CAiwServiceHandlerImpl::GetSubmenuTitle(CEikMenuPane& aPane, TDes& aResult)
  1913 TBool CAiwServiceHandlerImpl::GetSubmenuTitle(CEikMenuPane& aPane, TDes& aResult)
  1646     {
  1914     {
       
  1915     _AKNTRACE_FUNC_ENTER;
       
  1916     
  1647     TInt index;
  1917     TInt index;
  1648     
  1918     
  1649     aResult.Zero();
  1919     aResult.Zero();
  1650     while (aPane.MenuItemExists(AIW_SUBMENU_TITLE, index))
  1920     while (aPane.MenuItemExists(AIW_SUBMENU_TITLE, index))
  1651         {
  1921         {
  1655             aResult.Copy(itemData.iText);
  1925             aResult.Copy(itemData.iText);
  1656             }
  1926             }
  1657         aPane.DeleteMenuItem(AIW_SUBMENU_TITLE);
  1927         aPane.DeleteMenuItem(AIW_SUBMENU_TITLE);
  1658         return ETrue;
  1928         return ETrue;
  1659         }
  1929         }
  1660 
  1930   
       
  1931     _AKNTRACE_FUNC_EXIT;
  1661     return EFalse;
  1932     return EFalse;
  1662     }
  1933     }
  1663 
  1934 
  1664 
  1935 
  1665 
  1936 
  1685 
  1956 
  1686 
  1957 
  1687 void CAiwServiceHandlerImpl::FilterInterestListL(RPointerArray<CAiwCriteriaItem>& aOriginal,
  1958 void CAiwServiceHandlerImpl::FilterInterestListL(RPointerArray<CAiwCriteriaItem>& aOriginal,
  1688     RPointerArray<CAiwCriteriaItem>& aFiltered)
  1959     RPointerArray<CAiwCriteriaItem>& aFiltered)
  1689     {
  1960     {
       
  1961     _AKNTRACE_FUNC_ENTER;
       
  1962     
  1690     CAiwCriteriaItem* item;
  1963     CAiwCriteriaItem* item;
  1691 
  1964 
  1692     while (aOriginal.Count() > 0)
  1965     while (aOriginal.Count() > 0)
  1693         {
  1966         {
  1694         item = aOriginal[0];
  1967         item = aOriginal[0];
  1695         aOriginal.Remove(0);
  1968         aOriginal.Remove(0);
  1696         item = ConvertCriteriaItemPointerL(item);
  1969         item = ConvertCriteriaItemPointerL(item);
  1697         User::LeaveIfError(aFiltered.Append(item));
  1970         User::LeaveIfError(aFiltered.Append(item));
  1698         }
  1971         }
  1699     aOriginal.Reset();
  1972     aOriginal.Reset();
       
  1973    
       
  1974     _AKNTRACE_FUNC_EXIT;
  1700     }
  1975     }
  1701 
  1976 
  1702 
  1977 
  1703 
  1978 
  1704 void CAiwServiceHandlerImpl::RemoveProvider(TInt aImplUid)
  1979 void CAiwServiceHandlerImpl::RemoveProvider(TInt aImplUid)
  1705     {
  1980     {
       
  1981     _AKNTRACE_FUNC_ENTER;
       
  1982     
  1706     TInt i;
  1983     TInt i;
  1707 
  1984 
  1708     // First go through bindings and remove all the 
  1985     // First go through bindings and remove all the 
  1709     // references to given provider.
  1986     // references to given provider.
  1710     for (i = 0; i < iBaseBindings.Count(); i++)
  1987     for (i = 0; i < iBaseBindings.Count(); i++)
  1725             delete iProviders[i];
  2002             delete iProviders[i];
  1726             iProviders.Remove(i);
  2003             iProviders.Remove(i);
  1727             i--;
  2004             i--;
  1728             }
  2005             }
  1729         }
  2006         }
       
  2007     
       
  2008     _AKNTRACE_FUNC_EXIT;
  1730     }
  2009     }
  1731 
  2010 
  1732 
  2011 
  1733 void CAiwServiceHandlerImpl::AddProviderL(TUid aImplUid, CAiwCriteriaItem* aItem)
  2012 void CAiwServiceHandlerImpl::AddProviderL(TUid aImplUid, CAiwCriteriaItem* aItem)
  1734     {
  2013     {
       
  2014     _AKNTRACE_FUNC_ENTER;
       
  2015     _AKNTRACE("aImplUid:%x",aImplUid.iUid);
       
  2016     
  1735     TInt i;
  2017     TInt i;
  1736     CAiwServiceIfBase* iface = iEcomMonitor->CreateImplementationL(aImplUid);
  2018     CAiwServiceIfBase* iface = iEcomMonitor->CreateImplementationL(aImplUid);
  1737     
  2019     
  1738     if (iface)
  2020     if (iface)
  1739         {
  2021         {
  1758                 iMenuBindings[i]->AddProviderL(iface, aImplUid == aItem->DefaultProvider());
  2040                 iMenuBindings[i]->AddProviderL(iface, aImplUid == aItem->DefaultProvider());
  1759                 iface->InitialiseL(*this, iMenuBindings[i]->Interest());
  2041                 iface->InitialiseL(*this, iMenuBindings[i]->Interest());
  1760                 }               
  2042                 }               
  1761             }
  2043             }
  1762         }
  2044         }
       
  2045     
       
  2046     _AKNTRACE_FUNC_EXIT;
  1763     }
  2047     }
  1764 
  2048 
  1765 
  2049 
  1766 
  2050 
  1767 TInt CAiwServiceHandlerImpl::SynchronizeCallBack(TAny* aImpl)
  2051 TInt CAiwServiceHandlerImpl::SynchronizeCallBack(TAny* aImpl)
  1768     {
  2052     {
       
  2053     _AKNTRACE_FUNC_ENTER;
       
  2054     _AKNTRACE("aImpl:%x",aImpl);
       
  2055     
  1769     CAiwServiceHandlerImpl* impl = reinterpret_cast<CAiwServiceHandlerImpl*>(aImpl);
  2056     CAiwServiceHandlerImpl* impl = reinterpret_cast<CAiwServiceHandlerImpl*>(aImpl);
  1770     TRAPD(err, impl->SynchronizeDbL());
  2057     TRAPD(err, impl->SynchronizeDbL());
       
  2058     
       
  2059     _AKNTRACE_FUNC_EXIT;
       
  2060     
  1771     return err;
  2061     return err;
  1772     }
  2062     }
  1773 
  2063 
  1774 
  2064 
  1775 
  2065 
  1776 void CAiwServiceHandlerImpl::SynchronizeDbL()
  2066 void CAiwServiceHandlerImpl::SynchronizeDbL()
  1777     {
  2067     {
       
  2068     _AKNTRACE_FUNC_ENTER;
       
  2069     
  1778     TInt i;
  2070     TInt i;
  1779     RArray<TInt> providers;
  2071     RArray<TInt> providers;
  1780     RImplInfoPtrArray infoArray;
  2072     RImplInfoPtrArray infoArray;
  1781 
  2073 
  1782     CleanupStack::PushL( TCleanupItem( IntArrayCleanup, &providers ) );
  2074     CleanupStack::PushL( TCleanupItem( IntArrayCleanup, &providers ) );
  1796         HandleRemovedProviders(providers, infoArray);          
  2088         HandleRemovedProviders(providers, infoArray);          
  1797         HandleNewProvidersL(providers, infoArray, iInterestList[i]);        
  2089         HandleNewProvidersL(providers, infoArray, iInterestList[i]);        
  1798         }
  2090         }
  1799 
  2091 
  1800     CleanupStack::PopAndDestroy(2); // providers, infoArray
  2092     CleanupStack::PopAndDestroy(2); // providers, infoArray
       
  2093     
       
  2094     _AKNTRACE_FUNC_EXIT;
  1801     }
  2095     }
  1802 
  2096 
  1803 
  2097 
  1804 void CAiwServiceHandlerImpl::HandleRemovedProviders(RArray<TInt>& aInMemory, 
  2098 void CAiwServiceHandlerImpl::HandleRemovedProviders(RArray<TInt>& aInMemory, 
  1805     RImplInfoPtrArray& aInSystem)
  2099     RImplInfoPtrArray& aInSystem)
  1806     {
  2100     {
       
  2101     _AKNTRACE_FUNC_ENTER;
       
  2102     
  1807     TInt i, j;
  2103     TInt i, j;
  1808 
  2104 
  1809     for (i = 0; i < aInMemory.Count(); i++)
  2105     for (i = 0; i < aInMemory.Count(); i++)
  1810         {
  2106         {
  1811         for (j = 0; j < aInSystem.Count(); j++)
  2107         for (j = 0; j < aInSystem.Count(); j++)
  1818         if (j >= aInSystem.Count())  // Was removed from system.
  2114         if (j >= aInSystem.Count())  // Was removed from system.
  1819             {
  2115             {
  1820             RemoveProvider(aInMemory[i]);
  2116             RemoveProvider(aInMemory[i]);
  1821             }
  2117             }
  1822         }
  2118         }
       
  2119     
       
  2120     _AKNTRACE_FUNC_EXIT;
  1823     }
  2121     }
  1824 
  2122 
  1825 
  2123 
  1826 void CAiwServiceHandlerImpl::HandleNewProvidersL(RArray<TInt>& aInMemory, 
  2124 void CAiwServiceHandlerImpl::HandleNewProvidersL(RArray<TInt>& aInMemory, 
  1827     RImplInfoPtrArray& aInSystem, CAiwCriteriaItem* aItem)
  2125     RImplInfoPtrArray& aInSystem, CAiwCriteriaItem* aItem)
  1828     {
  2126     {
       
  2127     _AKNTRACE_FUNC_ENTER;
       
  2128     
  1829     TInt i;
  2129     TInt i;
  1830 
  2130 
  1831     for (i = 0; i < aInSystem.Count(); i++)
  2131     for (i = 0; i < aInSystem.Count(); i++)
  1832         {
  2132         {
  1833         if (aInMemory.Find(aInSystem[i]->ImplementationUid().iUid) == KErrNotFound)
  2133         if (aInMemory.Find(aInSystem[i]->ImplementationUid().iUid) == KErrNotFound)
  1834             {
  2134             {
  1835             AddProviderL(aInSystem[i]->ImplementationUid(), aItem);
  2135             AddProviderL(aInSystem[i]->ImplementationUid(), aItem);
  1836             }       
  2136             }       
  1837         }
  2137         }
       
  2138     
       
  2139     _AKNTRACE_FUNC_EXIT;
  1838     }
  2140     }
  1839     
  2141     
  1840 void CAiwServiceHandlerImpl::MenuLaunched()
  2142 void CAiwServiceHandlerImpl::MenuLaunched()
  1841     {  
  2143     {  
       
  2144     _AKNTRACE_FUNC_ENTER;
       
  2145     
  1842     ClearMenuPaneArray();
  2146     ClearMenuPaneArray();
  1843     iNextFreeSlot = 0;
  2147     iNextFreeSlot = 0;
  1844     iLastInitialized.Reset();
  2148     iLastInitialized.Reset();
  1845 
  2149 
  1846     // Reset the iMenuPane pointers from iMenuBindings.
  2150     // Reset the iMenuPane pointers from iMenuBindings.
  1847     for(TInt i = 0; i < iMenuBindings.Count(); i++)
  2151     for(TInt i = 0; i < iMenuBindings.Count(); i++)
  1848         {
  2152         {
  1849         iMenuBindings[i]->SetMenuPane(NULL);
  2153         iMenuBindings[i]->SetMenuPane(NULL);
  1850         }
  2154         }
       
  2155     
       
  2156     _AKNTRACE_FUNC_EXIT;
  1851     }
  2157     }
  1852 
  2158 
  1853 // End of file
  2159 // End of file