idlefw/plugins/wrtdataplugin/src/wrtdata.cpp
branchRCL_3
changeset 16 b276298d5729
parent 15 a0713522ab97
child 23 ace62b58f4b2
equal deleted inserted replaced
15:a0713522ab97 16:b276298d5729
    49 // ---------------------------------------------------------------------------
    49 // ---------------------------------------------------------------------------
    50 // Default constructor
    50 // Default constructor
    51 // ---------------------------------------------------------------------------
    51 // ---------------------------------------------------------------------------
    52 //
    52 //
    53 CWrtData::CWrtData()
    53 CWrtData::CWrtData()
       
    54     : iAppUid( KNullUid )
    54     {
    55     {
    55     }
    56     }
    56     
    57     
    57 // ---------------------------------------------------------------------------
    58 // ---------------------------------------------------------------------------
    58 // Symbian 2nd phase constructor can leave
    59 // Symbian 2nd phase constructor can leave
    59 // ---------------------------------------------------------------------------
    60 // ---------------------------------------------------------------------------
    60 //
    61 //
    61 void CWrtData::ConstructL(CWrtDataPlugin* aPlugin)
    62 void CWrtData::ConstructL(CWrtDataPlugin* aPlugin)
    62     { 
    63     { 
    63      iPlugin = aPlugin;
    64      iPlugin = aPlugin;
    64      iCommandName = HBufC8::NewL( KWRTContentValueMaxLength );
       
    65     }
    65     }
    66     
    66     
    67 // ---------------------------------------------------------------------------
    67 // ---------------------------------------------------------------------------
    68 // Destructor
    68 // Destructor
    69 // Deletes all data created to heap
    69 // Deletes all data created to heap
    70 // ---------------------------------------------------------------------------
    70 // ---------------------------------------------------------------------------
    71 //
    71 //
    72 CWrtData::~CWrtData()
    72 CWrtData::~CWrtData()
    73     {
    73     {
    74     if( iCommandName )
       
    75     	{
       
    76     	delete iCommandName;
       
    77     	iCommandName = NULL;
       
    78     	}
       
    79     if(iObserver)
    74     if(iObserver)
    80         {
    75         {      
    81         delete iObserver;
    76         delete iObserver;
    82         iObserver = NULL;
    77         iObserver = NULL;
    83         }
    78         }
    84     if( iInterface )
       
    85          {
       
    86          // This will also release all the registered observers
       
    87          iInterface->Close();
       
    88          iInterface = NULL;
       
    89          }
       
    90     if( iServiceHandler )
       
    91          {
       
    92          iServiceHandler->Reset();
       
    93          delete iServiceHandler;
       
    94          iServiceHandler = NULL;
       
    95          }
       
    96     if ( iContentId )
    79     if ( iContentId )
    97     	{
    80     	{
    98     	delete iContentId;
    81     	delete iContentId;
    99     	iContentId = NULL;
    82     	iContentId = NULL;
   100     	}
    83     	}
   101     iMenuItems.ResetAndDestroy();
       
   102     iMenuTriggers.ResetAndDestroy();
       
   103     // not owned
    84     // not owned
       
    85     iInterface = NULL;
       
    86     iServiceHandler = NULL;
   104     iCpsExecute = NULL;
    87     iCpsExecute = NULL;
   105     iPlugin = NULL;
    88     iPlugin = NULL;
   106     }
    89     }
   107 
    90 
   108 // ---------------------------------------------------------------------------
    91 // ---------------------------------------------------------------------------
   109 // CWrtData::ConfigureL
    92 // CWrtData::ConfigureL
   110 // ---------------------------------------------------------------------------
    93 // ---------------------------------------------------------------------------
   111 //
    94 //
   112 void CWrtData::ConfigureL(RAiSettingsItemArray& aConfigurations )
    95 void CWrtData::ConfigureL(RAiSettingsItemArray& aConfigurations )
   113     {
    96     {
   114     HBufC8* serviceName = HBufC8::NewLC( KWRTContentValueMaxLength );
       
   115     HBufC8* interfaceName = HBufC8::NewLC( KWRTContentValueMaxLength );
       
   116     
       
   117     // Interface name 
       
   118     RCriteriaArray criteriaArray;
       
   119     
       
   120     TInt count = aConfigurations.Count();
    97     TInt count = aConfigurations.Count();
   121    
    98     for(TInt i = 0; i<count; i++ )
   122     for(TInt i = 0;i<count;i++)
       
   123        {
    99        {
   124        MAiPluginConfigurationItem& confItem = ( aConfigurations[i] )->AiPluginConfigurationItem();
   100        MAiPluginConfigurationItem& confItem = ( aConfigurations[i] )->AiPluginConfigurationItem();
   125        // if owner is plugin then it (key,value) is for plugin configurations items
   101        // if owner is plugin then it (key,value) is for plugin configurations items
   126        if(confItem.Owner() == KPlugin())
   102        if(confItem.Owner() == KPlugin() && confItem.Name() == KPubData())
   127            {
   103            {
   128            if(confItem.Name() ==  KService())
   104            iContentId = confItem.Value().AllocL();
   129                {
   105 		   }
   130                serviceName->Des().Copy(confItem.Value());
       
   131                }
       
   132            else if( confItem.Name() == KInterface() )
       
   133                  {
       
   134                  interfaceName->Des().Copy(confItem.Value());
       
   135                  }
       
   136            else if( confItem.Name() == KCommand() )
       
   137                  {
       
   138                  iCommandName->Des().Copy(confItem.Value());
       
   139                  }
       
   140            else if( confItem.Name() == KMenuItem16() )
       
   141                  {
       
   142                  iMenuItems.AppendL( confItem.Value().AllocL() );
       
   143                  }
       
   144            else if( confItem.Name() == KPubData() )
       
   145 				  {
       
   146 				  iContentId = confItem.Value().AllocL();
       
   147 				  }
       
   148            }
       
   149        }
   106        }
   150     
   107     if( iContentId->Des().Length() == 0 ) 
   151     if( !( serviceName->Des().Length() >= 0 && interfaceName->Des().Length() >= 0  
       
   152             && iCommandName->Des().Length() >= 0 ) )
       
   153         {
   108         {
   154         // No service to offer without plugin configurations 
   109         // No service to offer without plugin configurations 
   155         User::Leave( KErrNotSupported );
   110         User::Leave( KErrNotSupported );
   156         }
   111         }
   157     
       
   158     iServiceHandler = CLiwServiceHandler::NewL(); 
       
   159 
       
   160     // for convenience keep pointers to Service Handler param lists 
       
   161     CLiwGenericParamList* inParamList  = &iServiceHandler->InParamListL();
       
   162     CLiwGenericParamList* outParamList = &iServiceHandler->OutParamListL();
       
   163 
       
   164     CLiwCriteriaItem* criteriaItem = CLiwCriteriaItem::NewLC( KLiwCmdAsStr, *interfaceName , *serviceName );
       
   165     criteriaItem->SetServiceClass( TUid::Uid( KLiwClassBase ) );
       
   166     criteriaArray.AppendL( criteriaItem );
       
   167 
       
   168 
       
   169     // attach Liw criteria
       
   170      iServiceHandler->AttachL( criteriaArray );
       
   171      iServiceHandler->ExecuteServiceCmdL( *criteriaItem, *inParamList, *outParamList );
       
   172 
       
   173      CleanupStack::PopAndDestroy(criteriaItem);
       
   174      criteriaArray.Reset();
       
   175 
       
   176     // extract CPS interface from output params
       
   177     TInt pos( 0 );
       
   178     outParamList->FindFirst( pos, *interfaceName );
       
   179     if( pos != KErrNotFound )
       
   180         {
       
   181         //iInterface is MLiwInterface*
       
   182         iInterface = (*outParamList)[pos].Value().AsInterface(); 
       
   183         User::LeaveIfNull( iInterface );
       
   184         }
       
   185     else
       
   186         {
       
   187         User::Leave( KErrNotFound );
       
   188         }
       
   189     inParamList->Reset();
       
   190     outParamList->Reset();
       
   191     CleanupStack::PopAndDestroy( interfaceName );
       
   192     CleanupStack::PopAndDestroy( serviceName );
       
   193 
       
   194 	//Gets the menu items from the publisher registry    
       
   195     GetMenuItemsL();
       
   196  
       
   197     iObserver = CWrtDataObserver::NewL( iInterface, this );   
   112     iObserver = CWrtDataObserver::NewL( iInterface, this );   
   198     }
       
   199 
       
   200 // ---------------------------------------------------------------------------
       
   201 // CWrtData::HasMenuItem
       
   202 // ---------------------------------------------------------------------------
       
   203 //
       
   204 TBool CWrtData::HasMenuItem(const TDesC16& aMenuItem )
       
   205     {
       
   206     TBool found = EFalse;
       
   207     for (TInt i = 0; i < iMenuItems.Count(); i++ )
       
   208         {
       
   209         if( aMenuItem == iMenuItems[i] )
       
   210             {
       
   211             found =  ETrue;
       
   212             break;
       
   213             }
       
   214         }
       
   215     return found;
       
   216     }
   113     }
   217 
   114 
   218 // ---------------------------------------------------------------------------
   115 // ---------------------------------------------------------------------------
   219 // CWrtData::RegisterL
   116 // CWrtData::RegisterL
   220 // ---------------------------------------------------------------------------
   117 // ---------------------------------------------------------------------------
   257     ReSendNotificationL( actions );
   154     ReSendNotificationL( actions );
   258     CleanupStack::PopAndDestroy( actions );
   155     CleanupStack::PopAndDestroy( actions );
   259     }
   156     }
   260 
   157 
   261 // ---------------------------------------------------------------------------
   158 // ---------------------------------------------------------------------------
       
   159 // CWrtData::PublishInitialDataL
       
   160 // ---------------------------------------------------------------------------
       
   161 //
       
   162 void CWrtData::PublishInitialDataL( MAiContentObserver* aObserver )
       
   163     {
       
   164     // Show loading animation
       
   165     iPlugin->ShowLoadingIcon( aObserver );
       
   166 
       
   167     TBuf<KWRTContentValueMaxLength> appName;
       
   168     TBuf<KWRTAppUidLenth> appUidStr;
       
   169     GetWidgetNameAndUidL( appName, appUidStr );
       
   170 
       
   171     // Publish widget's name
       
   172     if ( appName.Length() > 0 )
       
   173        {
       
   174        iPlugin->PublishTextL( aObserver, CWrtDataPlugin::EDefaultText, appName );
       
   175        }
       
   176 
       
   177     // Publish widget's apparc image. This might fail if there is application
       
   178     // list population ongoing in AppFW and then we have to try again later
       
   179     if ( ResolveUid ( appUidStr, iAppUid ) )
       
   180         {
       
   181         TRAPD( err, PublishDefaultImageL( aObserver ) );
       
   182         if ( KErrNone != err )
       
   183             {
       
   184             iPlugin->StartTimer();
       
   185             }
       
   186         }
       
   187     }
       
   188 
       
   189 // ---------------------------------------------------------------------------
   262 // CWrtData::PublishDefaultImageL
   190 // CWrtData::PublishDefaultImageL
   263 // ---------------------------------------------------------------------------
   191 // ---------------------------------------------------------------------------
   264 //
   192 //
   265 void CWrtData::PublishDefaultImageL( MAiContentObserver* aObserver )
   193 void CWrtData::PublishDefaultImageL( MAiContentObserver* aObserver )
   266     {
   194     {
   267     TBuf<KWRTAppUidLenth> appUidStr;
   195     // Publish widget's apparc image
   268     TBuf<KWRTContentValueMaxLength> appName;
   196     TInt handle = KErrNotFound;
   269     GetWidgetNameAndUidL( appName, appUidStr );
   197     TInt mask = KErrNotFound;
   270     
   198     // create icon from application UID
   271     TUid appUid;
   199     CreateIconFromUidL( handle, mask, iAppUid );
   272     if ( ResolveUid (appUidStr, appUid ) )
   200     // Publish apparc image 
   273         {
   201     iPlugin->PublishImageL( aObserver,
   274 #ifdef WRT_PREDEFINED_IMAGE         
   202                                 CWrtDataPlugin::EDefaultImage,
   275         RFs rfs;
   203                                 handle,
   276         User::LeaveIfError( rfs.Connect() );
   204                                 mask );
   277 
   205     }
   278         TFileName privatePath;
   206 
   279         rfs.PrivatePath(privatePath);
       
   280         privatePath.Insert(0,KDrive);
       
   281         privatePath.Append( KImgFolder );
       
   282       
       
   283         appUidStr.Copy( appUid.Name());
       
   284         appUidStr.Delete(0,1);
       
   285         appUidStr.Delete( appUidStr.Length() -1, 1);
       
   286         privatePath.Append (appUidStr );
       
   287         privatePath.Append ( KJPEG );
       
   288         if ( BaflUtils::FileExists(rfs,privatePath) )
       
   289             {
       
   290             // Publish predefined jpeg image
       
   291             iPlugin->PublishImageL( aObserver, CWrtDataPlugin::EImage1,privatePath);
       
   292             }
       
   293         else
       
   294             {
       
   295             privatePath.Delete( privatePath.Length() - 4 , 4);
       
   296             privatePath.Append( KPNG );
       
   297             if ( BaflUtils::FileExists(rfs,privatePath) )
       
   298                {
       
   299                // Publish predefined image
       
   300                iPlugin->PublishImageL( aObserver, CWrtDataPlugin::EImage1,privatePath);
       
   301                }
       
   302             else
       
   303                 {
       
   304 #endif                 
       
   305                 TInt handle = KErrNotFound;
       
   306                 TInt mask = KErrNotFound;
       
   307                 CreateIconFromUidL( handle, mask, appUid );
       
   308                 // Publish widget apparc image
       
   309                 iPlugin->PublishImageL( aObserver, CWrtDataPlugin::EDefaultImage,handle,mask);
       
   310                 if ( appName.Length() > 0)
       
   311                    {
       
   312                    // Publish Widget Name
       
   313                    iPlugin->PublishTextL( aObserver, CWrtDataPlugin::EDefaultText, appName);
       
   314                    }
       
   315 #ifdef WRT_PREDEFINED_IMAGE                
       
   316                 }
       
   317             }
       
   318         rfs.Close();
       
   319 #endif        
       
   320         }
       
   321     
       
   322     // Show loading animation
       
   323     iPlugin->ShowLoadingIcon(aObserver);
       
   324     }
       
   325 
   207 
   326 // ---------------------------------------------------------------------------
   208 // ---------------------------------------------------------------------------
   327 // CWrtData::PublishL
   209 // CWrtData::PublishL
   328 // ---------------------------------------------------------------------------
   210 // ---------------------------------------------------------------------------
   329 //
   211 //
   386    {
   268    {
   387    HBufC8* triggerName = HBufC8::NewLC( KWRTContentNameMaxLength );
   269    HBufC8* triggerName = HBufC8::NewLC( KWRTContentNameMaxLength );
   388   
   270   
   389    CLiwGenericParamList* inParamList  = &iServiceHandler->InParamListL();
   271    CLiwGenericParamList* inParamList  = &iServiceHandler->InParamListL();
   390    CLiwGenericParamList* outParamList = &iServiceHandler->OutParamListL();
   272    CLiwGenericParamList* outParamList = &iServiceHandler->OutParamListL();
   391    CLiwDefaultMap* filter = NULL;
   273 
       
   274    // use the first item configuration to create the filter
       
   275    CLiwDefaultMap* filter  = CreateFilterLC();
   392 
   276 
   393    triggerName->Des().Copy(aTrigger);
   277    triggerName->Des().Copy(aTrigger);
   394    if ( aObjectId == KPubData )
   278    if ( aObjectId == KPubData )
   395        {
   279        {
   396        // this trigger belongs to publisher registery.
   280        // this trigger belongs to publisher registery.
   397        // in such case it is assumed that all the items in the widgets
   281        // in such case it is assumed that all the items in the widgets
   398        // belongs to same publisher, type and id.
   282        // belongs to same publisher, type and id.
   399        TLiwGenericParam cptype( KType, TLiwVariant( KPubData ) );
   283        TLiwGenericParam cptype( KType, TLiwVariant( KPubData ) );
   400        inParamList->AppendL( cptype );
   284        inParamList->AppendL( cptype );
   401        cptype.Reset();
   285        cptype.Reset();
   402        // use the first item configuration to create the filter
       
   403        filter = CreateFilterLC();
       
   404        }
   286        }
   405    else
   287    else
   406        {
   288        {
   407        if ( aObjectId == KMenuItem16 )
   289         //append type to inparam list
   408            {
       
   409            TInt pos = KErrNotFound;
       
   410            for (TInt i = 0; i < iMenuItems.Count(); i++)
       
   411                {
       
   412                if ( aTrigger == iMenuItems[i] )
       
   413                    {
       
   414                    pos = i;
       
   415                    break;
       
   416                    }
       
   417                }
       
   418            if( pos == KErrNotFound )
       
   419                {
       
   420                // No such menu items
       
   421                CleanupStack::PopAndDestroy( triggerName );
       
   422                return; 
       
   423                }
       
   424               triggerName->Des().Copy( iMenuTriggers[pos]->Des() );
       
   425               filter = CreateFilterLC();
       
   426            }
       
   427        else
       
   428            {
       
   429            //Create filter criteria for requested entries in form of LIW map:
       
   430            filter = CreateFilterLC();
       
   431            }
       
   432        //append type to inparam list
       
   433        TLiwGenericParam cptype( KType, TLiwVariant( KCpData ) );
   290        TLiwGenericParam cptype( KType, TLiwVariant( KCpData ) );
   434        inParamList->AppendL( cptype );
   291        inParamList->AppendL( cptype );
   435        cptype.Reset();
   292        cptype.Reset();
   436        }
   293        }
   437 
   294 
   439    //append filter to input param
   296    //append filter to input param
   440     TLiwGenericParam item( KFilter, TLiwVariant( filter ) );
   297     TLiwGenericParam item( KFilter, TLiwVariant( filter ) );
   441     inParamList->AppendL( item );
   298     inParamList->AppendL( item );
   442     iInterface->ExecuteCmdL( KExecuteAction,  *inParamList, *outParamList );
   299     iInterface->ExecuteCmdL( KExecuteAction,  *inParamList, *outParamList );
   443     
   300     
       
   301     item.Reset();
   444     CleanupStack::PopAndDestroy( filter );
   302     CleanupStack::PopAndDestroy( filter );
   445     CleanupStack::PopAndDestroy( triggerName );
   303     CleanupStack::PopAndDestroy( triggerName );
   446     item.Reset();
   304     outParamList->Reset();
   447 
       
   448     inParamList->Reset();
   305     inParamList->Reset();
   449     outParamList->Reset();  
       
   450     
       
   451     }
   306     }
   452 
   307 
   453 // ---------------------------------------------------------------------------
   308 // ---------------------------------------------------------------------------
   454 // CWrtData::IsPluginActive
   309 // CWrtData::IsPluginActive
   455 // ---------------------------------------------------------------------------
   310 // ---------------------------------------------------------------------------
   489      inParamList->AppendL( item );
   344      inParamList->AppendL( item );
   490      
   345      
   491     // execute service.It is assumed that iInterface is already initiatedd
   346     // execute service.It is assumed that iInterface is already initiatedd
   492     if(iInterface)
   347     if(iInterface)
   493         {
   348         {
   494         iInterface->ExecuteCmdL( *iCommandName, *inParamList, *outParamList);
   349         iInterface->ExecuteCmdL( KGetList, *inParamList, *outParamList);
   495         }
   350         }
   496     else
   351     else
   497         {
   352         {
   498         User::Leave( KErrNotSupported );
   353         User::Leave( KErrNotSupported );
   499         }
   354         }
   544     CLiwDefaultMap* filter = CreateFilterLC();
   399     CLiwDefaultMap* filter = CreateFilterLC();
   545     // Add execute command triggers. Idle framework will execute 
   400     // Add execute command triggers. Idle framework will execute 
   546     iCpsExecute->AddCommand( iPluginId, KPubData, filter, aStatus );
   401     iCpsExecute->AddCommand( iPluginId, KPubData, filter, aStatus );
   547     CleanupStack::PopAndDestroy( filter );
   402     CleanupStack::PopAndDestroy( filter );
   548     }
   403     }
   549 
       
   550 // ---------------------------------------------------------------------------
       
   551 // CWrtData::GetMenuItemsL
       
   552 // ---------------------------------------------------------------------------
       
   553 //
       
   554 void CWrtData::GetMenuItemsL()
       
   555 	{
       
   556 	if(iInterface)
       
   557 		{
       
   558 		CLiwDefaultMap *outDataMap = CLiwDefaultMap::NewLC();
       
   559 		CLiwDefaultMap* filter = CreateFilterLC( );
       
   560 		//append filter to input param
       
   561         ExecuteCommandL( filter, outDataMap, KPubData  );
       
   562 		CleanupStack::PopAndDestroy( filter );
       
   563 		
       
   564 		TLiwVariant variant;
       
   565 		TInt pos = outDataMap->FindL( KMenuItems, variant ) ;
       
   566 		
       
   567 		if ( pos  )
       
   568 			{
       
   569 			CLiwDefaultMap *menuMap = CLiwDefaultMap::NewLC();
       
   570 			variant.Get( *menuMap );
       
   571 			for ( TInt i = 0; i < menuMap->Count(); i++)
       
   572 				{
       
   573 				menuMap->FindL(menuMap->AtL(i), variant );
       
   574 				HBufC8* value = HBufC8::NewL( KWRTContentValueMaxLength );
       
   575 				CleanupStack::PushL( value );
       
   576 				TPtr8 valPtr = value->Des();
       
   577 				variant.Get( valPtr);
       
   578 				if ( valPtr.Length() > 0 )
       
   579 					{
       
   580 					iMenuTriggers.AppendL( value );
       
   581 					CleanupStack::Pop( value );
       
   582 					HBufC16* triggerName = HBufC16::NewLC( KWRTContentNameMaxLength );
       
   583 				    triggerName->Des().Copy( menuMap->AtL(i) );
       
   584 					iMenuItems.AppendL( triggerName );
       
   585 					CleanupStack::Pop( triggerName );
       
   586 					}
       
   587 				else
       
   588 					{
       
   589 					CleanupStack::PopAndDestroy( value );	
       
   590 					}
       
   591 				variant.Reset();
       
   592 				}
       
   593 			CleanupStack::PopAndDestroy( menuMap );
       
   594 			}
       
   595 		variant.Reset();
       
   596 		CleanupStack::PopAndDestroy( outDataMap );
       
   597 		}
       
   598 	}
       
   599 
   404 
   600 // ---------------------------------------------------------------------------
   405 // ---------------------------------------------------------------------------
   601 // CWrtData::GetWidgetNameAndUidL
   406 // CWrtData::GetWidgetNameAndUidL
   602 // ---------------------------------------------------------------------------
   407 // ---------------------------------------------------------------------------
   603 //
   408 //
   668                 error = lex.Val( id );
   473                 error = lex.Val( id );
   669                 aUid.iUid = id;
   474                 aUid.iUid = id;
   670                 }
   475                 }
   671             }
   476             }
   672         }
   477         }
   673     return (error == KErrNone );
   478     return ( error == KErrNone );
   674     }
   479     }
   675 
   480 
   676 // ---------------------------------------------------------------------------
   481 // ---------------------------------------------------------------------------
   677 // CWrtData::CreateIconFromUidL
   482 // CWrtData::CreateIconFromUidL
   678 // ---------------------------------------------------------------------------
   483 // ---------------------------------------------------------------------------
   679 //
   484 //
   680 void CWrtData::CreateIconFromUidL(TInt& aHandle, TInt& aMaskHandle, const TUid& aAppUid ) 
   485 void CWrtData::CreateIconFromUidL( TInt& aHandle, TInt& aMaskHandle, const TUid& aAppUid ) 
   681     {
   486     {
   682     RApaLsSession lsSession;
   487     RApaLsSession lsSession;
   683     User::LeaveIfError( lsSession.Connect() );
   488     User::LeaveIfError( lsSession.Connect() );
   684     CleanupClosePushL( lsSession ); // lsSession (1)
   489     CleanupClosePushL( lsSession ); // lsSession (1)
   685     
   490     
   686     CArrayFixFlat<TSize>* sizeArray = new(ELeave) CArrayFixFlat<TSize>( 5 );
   491     CArrayFixFlat<TSize>* sizeArray = new(ELeave) CArrayFixFlat<TSize>( 5 );
   687     CleanupStack::PushL( sizeArray );
   492     CleanupStack::PushL( sizeArray );
   688     if ( KErrNone == lsSession.GetAppIconSizes(aAppUid, *sizeArray) )
   493 
   689         {
   494     User::LeaveIfError( lsSession.GetAppIconSizes( aAppUid, *sizeArray ) );
   690         if ( sizeArray->Count() ) 
   495 
   691             {
   496     if ( sizeArray->Count() ) 
   692             // There are other icon sizes
   497         {
   693             TInt idx = 0;
   498         // There are other icon sizes
   694             TInt size( sizeArray->At(idx).iWidth * sizeArray->At(idx).iHeight );
   499         TInt idx = 0;
   695             for ( TInt i = 1; i < sizeArray->Count(); i++ ) 
   500         TInt size( sizeArray->At(idx).iWidth * sizeArray->At(idx).iHeight );
       
   501         for ( TInt i = 1; i < sizeArray->Count(); i++ ) 
       
   502             {
       
   503             if ( ( sizeArray->At(i).iWidth * sizeArray->At(i).iHeight ) > size )
   696                 {
   504                 {
   697                 if ( ( sizeArray->At(i).iWidth * sizeArray->At(i).iHeight ) > size )
   505                 idx = i;
   698                     {
   506                 size =  sizeArray->At(idx).iWidth * sizeArray->At(idx).iHeight;
   699                     idx = i;
       
   700                     size =  sizeArray->At(idx).iWidth * sizeArray->At(idx).iHeight;
       
   701                     }
       
   702                 }
   507                 }
   703 
   508             }
   704             CApaMaskedBitmap* appBitMap = CApaMaskedBitmap::NewLC();
   509 
   705             if ( KErrNone == lsSession.GetAppIcon( aAppUid, sizeArray->At(idx),
   510         CApaMaskedBitmap* appBitMap = CApaMaskedBitmap::NewLC();
   706                     *appBitMap ) )
   511         User::LeaveIfError( lsSession.GetAppIcon( aAppUid, sizeArray->At(idx), *appBitMap ) );
   707                 {
   512         aHandle = appBitMap->Handle();
   708                 aHandle = appBitMap->Handle();
   513         aMaskHandle = appBitMap->Mask()->Handle();
   709                 aMaskHandle = appBitMap->Mask()->Handle();
   514         CleanupStack::PopAndDestroy( appBitMap );
   710                 }
   515         }
   711             CleanupStack::PopAndDestroy( appBitMap );
   516 
   712             }
       
   713         }
       
   714     CleanupStack::PopAndDestroy( sizeArray );
   517     CleanupStack::PopAndDestroy( sizeArray );
   715     CleanupStack::PopAndDestroy( &lsSession );
   518     CleanupStack::PopAndDestroy( &lsSession );
   716     }
   519     }
   717 
   520 
   718 
   521 
   752 //
   555 //
   753 void CWrtData::SetCommandBuffer(TAny* aAny, const TDesC8& aNameSpace )
   556 void CWrtData::SetCommandBuffer(TAny* aAny, const TDesC8& aNameSpace )
   754     {
   557     {
   755     iPluginId.Copy(aNameSpace);
   558     iPluginId.Copy(aNameSpace);
   756     iCpsExecute = reinterpret_cast <MAiCpsCommandBuffer* > ( aAny );
   559     iCpsExecute = reinterpret_cast <MAiCpsCommandBuffer* > ( aAny );
       
   560     if ( iCpsExecute )
       
   561         {
       
   562         iInterface = iCpsExecute->CpsInterface();
       
   563         iServiceHandler = iCpsExecute->ServiceHandler();
       
   564         }
   757     }
   565     }
   758 
   566 
   759 // End of file
   567 // End of file
   760 
   568