idlefw/plugins/mcsplugin/publisher/src/mcsplugindata.cpp
branchRCL_3
changeset 74 edd621764147
parent 64 b276298d5729
child 82 ace62b58f4b2
equal deleted inserted replaced
64:b276298d5729 74:edd621764147
    73 // ---------------------------------------------------------------------------
    73 // ---------------------------------------------------------------------------
    74 // Default constructor
    74 // Default constructor
    75 // ---------------------------------------------------------------------------
    75 // ---------------------------------------------------------------------------
    76 //
    76 //
    77 CMCSData::CMCSData()
    77 CMCSData::CMCSData()
       
    78     :iDirty( ETrue )
    78     {
    79     {
    79     }
    80     }
    80 
    81 
    81 // ---------------------------------------------------------------------------
    82 // ---------------------------------------------------------------------------
    82 // Destructor
    83 // Destructor
   227 void CMCSPluginData::UpdateDataL()
   228 void CMCSPluginData::UpdateDataL()
   228     {
   229     {
   229     RPointerArray<CItemMap> settings;
   230     RPointerArray<CItemMap> settings;
   230     CleanupResetAndDestroyPushL( settings );
   231     CleanupResetAndDestroyPushL( settings );
   231 
   232 
   232     iPluginSettings->GetSettingsL( iInstanceUid, settings );
   233     User::LeaveIfError( iPluginSettings->GetSettingsL( iInstanceUid, settings ) );
   233     TInt count = settings.Count();
   234     if ( settings.Count() <= 0 )
       
   235         {
       
   236         User::Leave( KErrNotFound );
       
   237         }
       
   238 
   234     TBool wasEmpty = !iData.Count();
   239     TBool wasEmpty = !iData.Count();
   235     
   240     
   236     for ( TInt i = 0; i < count; i++ )
   241     for ( TInt i = 0; i < settings.Count(); i++ )
   237        {
   242        {
   238         CItemMap* itemMap = settings[ i ];
   243         CItemMap* itemMap = settings[ i ];
       
   244         
       
   245         // get properties
   239         RPointerArray<HSPluginSettingsIf::CPropertyMap>& properties
   246         RPointerArray<HSPluginSettingsIf::CPropertyMap>& properties
   240             = itemMap->Properties();
   247             = itemMap->Properties();
       
   248         
   241         CMCSData* data = GetMenuDataL( properties );
   249         CMCSData* data = GetMenuDataL( properties );
   242 
   250         CleanupStack::PushL( data );
   243         if ( wasEmpty )
   251         if ( wasEmpty )
   244             {
   252             {
   245             // list of shortcut slot was empty
   253             // list of shortcut slot was empty
   246             // we append the shortcut data slots one-by-one to the list
   254             // we append the shortcut data slots one-by-one to the list            
   247             data->SetDirty( ETrue );
   255             data->SetDirty( ETrue );
   248             iData.AppendL( data );
   256             iData.AppendL( data );
       
   257             CleanupStack::Pop( data );
   249             }
   258             }
   250         else 
   259         else 
   251             {
   260             {
   252             // check for updates in existing shortcut data slot
   261             // check for updates in existing shortcut data slot
   253             // if menuitem id has changed, replace the item and 
   262             // if menuitem id has changed, replace the item and 
   254             // set as dirty
   263             // set as dirty
   255             TInt id = -1;
   264             TInt id( iData[ i ]->MenuItem().Id() );
   256             id = iData[ i ]->MenuItem().Id();
       
   257             
   265             
   258             if ( data->MenuItem().Id() != id )
   266             // id of all bookmarks is zero so name has to be check
       
   267             // in case of bookmark has changed
       
   268             if ( id >= 0 && ( data->MenuItem().Id() != id ||
       
   269                     ( id == 0 && data->Name().CompareF(
       
   270                             iData[ i ]->Name() ) != 0 ) ) )
   259                 {
   271                 {
   260                 data->SetDirty( ETrue );
   272                 data->SetDirty( ETrue );
   261                 CMCSData* oldData = iData[i];
   273                 CMCSData* oldData = iData[i];
   262                 iData.Remove( i );
   274                 iData.Remove( i );
   263                 delete oldData;
   275                 delete oldData;
       
   276                 
   264                 iData.InsertL( data, i );
   277                 iData.InsertL( data, i );
   265                 }
   278                 CleanupStack::Pop( data );
   266             }
   279                 }
   267         }
   280             else
   268 
   281                 {
       
   282                 CleanupStack::PopAndDestroy( data );
       
   283                 }
       
   284             }
       
   285         }
       
   286     
       
   287     // Leave if there isn't any data filled into array as there isn't
       
   288     // anything shortcut to publish on homescreen.
       
   289     if ( iData.Count() <= 0 ) 
       
   290         {
       
   291         User::Leave( KErrNotFound );
       
   292         }
       
   293     
   269     // Cleanup.
   294     // Cleanup.
   270     CleanupStack::PopAndDestroy(); // settings
   295     CleanupStack::PopAndDestroy(); // settings
   271     }
   296     }
   272 
   297 
   273 // ---------------------------------------------------------------------------
   298 // ---------------------------------------------------------------------------
   306 
   331 
   307 // ---------------------------------------------------------------------------
   332 // ---------------------------------------------------------------------------
   308 // Gets the menu item from engine using the setting properties as filter
   333 // Gets the menu item from engine using the setting properties as filter
   309 // ---------------------------------------------------------------------------
   334 // ---------------------------------------------------------------------------
   310 //
   335 //
   311 CMCSData* CMCSPluginData::GetMenuDataL( RPointerArray<HSPluginSettingsIf::CPropertyMap>& aProperties )
   336 CMCSData* CMCSPluginData::GetMenuDataL( 
   312     {
   337         RPointerArray<HSPluginSettingsIf::CPropertyMap>& aProperties )
       
   338     {
       
   339     if ( aProperties.Count() <= 0 )
       
   340 		{
       
   341 		User::Leave( KErrArgument );
       
   342 		}
       
   343 
   313     TPtrC8 type;
   344     TPtrC8 type;
   314     TPtrC8 uid;
   345 	TPtrC8 uid;
   315     TPtrC8 view;
   346 	TPtrC8 view;
   316     TPtrC8 param;
   347 	TPtrC8 param;
   317     
   348     
   318     // first we need to check the item type
   349     // first we need to check the item type
   319     for ( TInt i = 0; i < aProperties.Count(); i++ )
   350     for ( TInt i = 0; i < aProperties.Count(); i++ )
   320         {
   351         {
   321         if ( aProperties[i]->Name() == KProperNameType )
   352         if ( aProperties[i]->Name() == KProperNameType )
   493     
   524     
   494     iPluginSettings->GetSettingsL( iInstanceUid, settingItems );
   525     iPluginSettings->GetSettingsL( iInstanceUid, settingItems );
   495     if ( aIndex >= 0 && aIndex < settingItems.Count() )
   526     if ( aIndex >= 0 && aIndex < settingItems.Count() )
   496         {
   527         {
   497         CItemMap* itemMap = settingItems[ aIndex ];
   528         CItemMap* itemMap = settingItems[ aIndex ];
   498         RPointerArray<HSPluginSettingsIf::CPropertyMap> properties;
   529         
   499         properties = itemMap->Properties();
   530         // get properties
       
   531         RPointerArray<HSPluginSettingsIf::CPropertyMap>& properties
       
   532             = itemMap->Properties();
       
   533 
   500         for ( TInt i = 0; i < properties.Count(); i++ )
   534         for ( TInt i = 0; i < properties.Count(); i++ )
   501             {
   535             {
   502             if ( properties[ i ]->Name() == KProperNameType )
   536             if ( properties[ i ]->Name() == KProperNameType )
   503                 {
   537                 {
   504                 properties[ i ]->SetValueL( KProperValueAppl );
   538                 properties[ i ]->SetValueL( KProperValueAppl );