idlefw/plugins/mcsplugin/settings/src/mcspluginsettingsmodel.cpp
branchRCL_3
changeset 17 cb506ec2d869
parent 16 b276298d5729
child 19 edd621764147
equal deleted inserted replaced
13:c2817bb2a55c 17:cb506ec2d869
     1 /*
     1 /*
     2 * Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
     2 * Copyright (c) 2009 - 2010 Nokia Corporation and/or its subsidiary(-ies).
     3 * All rights reserved.
     3 * All rights reserved.
     4 * This component and the accompanying materials are made available
     4 * This component and the accompanying materials are made available
     5 * under the terms of "Eclipse Public License v1.0"
     5 * under the terms of "Eclipse Public License v1.0"
     6 * which accompanies this distribution, and is available
     6 * which accompanies this distribution, and is available
     7 * at the URL "http://www.eclipse.org/legal/epl-v10.html".
     7 * at the URL "http://www.eclipse.org/legal/epl-v10.html".
    16 */
    16 */
    17 
    17 
    18 #include <eikenv.h>
    18 #include <eikenv.h>
    19 #include <itemmap.h>
    19 #include <itemmap.h>
    20 #include <mhomescreensettingsif.h>
    20 #include <mhomescreensettingsif.h>
    21 
       
    22 #include <aistrcnv.h>
    21 #include <aistrcnv.h>
    23 #include <StringLoader.h>
    22 #include <StringLoader.h>
    24 #include <uri16.h>
    23 #include <uri16.h>
    25 #include <mcspluginsettingsres.rsg>
    24 #include <mcspluginsettingsres.rsg>
    26 
    25 #include <mcsmenuitem.h>
    27 
    26 
    28 #include "mcspluginsettings.h"
       
    29 #include "mcspluginsettingsmodel.h"
    27 #include "mcspluginsettingsmodel.h"
       
    28 #include "mcspluginsettingsapplist.h"
       
    29 #include "mcspluginsettingsbkmlist.h"
    30 #include "mcspluginsettingscontainer.h"
    30 #include "mcspluginsettingscontainer.h"
    31 
    31 
    32 
       
    33 #include "debug.h"
       
    34 
       
    35 #include <mcsmenuitem.h>
       
    36 
    32 
    37 /**
    33 /**
    38  * Line format for the settings list box
    34  * Line format for the settings list box
    39  */
    35  */
    40 _LIT(KSettingListboxLineFormat, " \t%S\t\t%S");
    36 _LIT(KSettingListboxLineFormat, " \t%S\t\t%S");
    49 _LIT8( KProperNameLocked, "locked" );
    45 _LIT8( KProperNameLocked, "locked" );
    50 _LIT8( KProperValueFolder, "folder" );
    46 _LIT8( KProperValueFolder, "folder" );
    51 _LIT8( KProperValueSuite, "suite" );
    47 _LIT8( KProperValueSuite, "suite" );
    52 _LIT8( KProperValueBookmark, "bookmark" );
    48 _LIT8( KProperValueBookmark, "bookmark" );
    53 _LIT8( KProperValueAppl, "application" );
    49 _LIT8( KProperValueAppl, "application" );
       
    50 _LIT8( KProperValueMailbox, "mailbox" );
       
    51 _LIT( KMenuTypeMailbox, "menu:mailbox" );
    54 
    52 
    55 using namespace HSPluginSettingsIf;
    53 using namespace HSPluginSettingsIf;
       
    54 
       
    55 // ======== LOCAL FUNCTIONS ========
       
    56 
       
    57 // ----------------------------------------------------------------------------
       
    58 // CleanupResetAndDestroy()
       
    59 // ----------------------------------------------------------------------------
       
    60 //
       
    61 template<class T>
       
    62 static void CleanupResetAndDestroy( TAny* aObj )
       
    63     {
       
    64     if( aObj )
       
    65         {
       
    66         static_cast<T*>( aObj )->ResetAndDestroy();
       
    67         }
       
    68     }
       
    69 
       
    70 // ----------------------------------------------------------------------------
       
    71 // CleanupResetAndDestroyPushL
       
    72 // ----------------------------------------------------------------------------
       
    73 //
       
    74 template<class T>
       
    75 static void CleanupResetAndDestroyPushL(T& aArray)
       
    76     {
       
    77     CleanupStack::PushL( TCleanupItem( &CleanupResetAndDestroy<T>, &aArray ) );
       
    78     }
       
    79 
       
    80 // ======== MEMBER FUNCTIONS ========
    56 
    81 
    57 // -----------------------------------------------------------------------------
    82 // -----------------------------------------------------------------------------
    58 // Creates a formatted listbox line.
    83 // Creates a formatted listbox line.
    59 // -----------------------------------------------------------------------------
    84 // -----------------------------------------------------------------------------
    60 //
    85 //
   145 // ---------------------------------------------------------------------------
   170 // ---------------------------------------------------------------------------
   146 // Second phase construction
   171 // Second phase construction
   147 // ---------------------------------------------------------------------------
   172 // ---------------------------------------------------------------------------
   148 //
   173 //
   149 void CMCSPluginSettingsModel::ConstructL()
   174 void CMCSPluginSettingsModel::ConstructL()
   150 {
   175     {
   151     CHomescreenSettings::InitializeL( KAppUid );
   176     CHomescreenSettings::InitializeL( KAppUid );
   152     
   177     
   153     iPluginSettings = CHomescreenSettings::Instance();
   178     iPluginSettings = CHomescreenSettings::Instance();
   154     if( iPluginSettings == NULL )
   179     if( iPluginSettings == NULL )
   155         {
   180         {
   156         User::Leave( KErrUnknown );
   181         User::Leave( KErrUnknown );
   157         }
   182         }
   158     
   183     }
   159     iAppList = CMCSPluginSettingsAppList::NewL();
       
   160     iAppList->StartL();
       
   161     iBkmList = CMCSPluginSettingsBkmList::NewL();
       
   162 }
       
   163 
       
   164 
   184 
   165 // ---------------------------------------------------------------------------
   185 // ---------------------------------------------------------------------------
   166 // Gets the latest settings from HSPS and updates
   186 // Gets the latest settings from HSPS and updates
   167 // ---------------------------------------------------------------------------
   187 // ---------------------------------------------------------------------------
   168 //
   188 //
   169 void CMCSPluginSettingsModel::UpdateSettingsL( const TDesC8& aPluginId )
   189 void CMCSPluginSettingsModel::UpdateSettingsL()
   170     {
   190     {
   171     if( !iPlugin.Activated() )
   191     iSettings.Reset();
       
   192     if( !iPluginId )
   172         {
   193         {
   173         return;
   194         return;
   174         }
   195         }
   175     
   196     
   176     if( iPluginId )
   197     if (iContainer)
   177         {
   198         {
   178         delete iPluginId;
   199         iContainer->CloseChangeDialog();
   179         iPluginId = NULL;
   200         }
   180         }
   201     
   181     iPluginId = aPluginId.AllocL();    
       
   182     
       
   183     iSettings.Reset();
       
   184     RPointerArray<CItemMap> settingItems;
   202     RPointerArray<CItemMap> settingItems;
   185     CleanupClosePushL( settingItems );
   203     CleanupResetAndDestroyPushL( settingItems );
   186 
   204 
   187     iPluginSettings->GetSettingsL( *iPluginId, settingItems );
   205     iPluginSettings->GetSettingsL( *iPluginId, settingItems );
   188 
   206 
   189     TInt count = settingItems.Count();
   207     for ( TInt i = 0; i < settingItems.Count(); i++ )
   190     for ( TInt i = 0; i < count; i++ )
       
   191         {
   208         {
   192         CItemMap* itemMap = settingItems[i];
   209         CItemMap* itemMap = settingItems[i];
   193         RPointerArray<HSPluginSettingsIf::CPropertyMap> properties;
   210         RPointerArray<HSPluginSettingsIf::CPropertyMap> properties;
   194         properties = itemMap->Properties();
   211         properties = itemMap->Properties();
   195         TSettingItem item = ItemL( properties );
   212         TSettingItem item = ItemL( properties );
   196         iSettings.AppendL( item );
   213         iSettings.AppendL( item );
   197         }
   214         }
   198     CleanupStack::Pop( &settingItems );
   215     
   199     settingItems.ResetAndDestroy();
   216     CleanupStack::PopAndDestroy(); // settingItems
   200     }
   217     
   201 
   218     if (iContainer)
   202 // ---------------------------------------------------------------------------
   219         {
   203 // Gets the latest settings from HSPS and updates
   220         iContainer->ResetCurrentListL(0);
   204 // ---------------------------------------------------------------------------
   221         }
   205 //
       
   206 void CMCSPluginSettingsModel::UpdateSettingModelL( const TDesC8& aPluginId )
       
   207     {
       
   208     if( iPluginId )
       
   209         {
       
   210         delete iPluginId;
       
   211         iPluginId = NULL;
       
   212         }
       
   213     iPluginId = aPluginId.AllocL();
       
   214     
       
   215     iSettings.Reset();
       
   216     RPointerArray<CItemMap> settingItems;
       
   217     CleanupClosePushL( settingItems );
       
   218 
       
   219     iPluginSettings->GetSettingsL( *iPluginId, settingItems );
       
   220 
       
   221     TInt count = settingItems.Count();
       
   222     for ( TInt i = 0; i < count; i++ )
       
   223         {
       
   224         CItemMap* itemMap = settingItems[i];
       
   225         RPointerArray<HSPluginSettingsIf::CPropertyMap> properties;
       
   226         properties = itemMap->Properties();
       
   227         TSettingItem item = ItemL( properties );
       
   228         iSettings.AppendL( item );
       
   229         }
       
   230     CleanupStack::Pop( &settingItems );
       
   231     settingItems.ResetAndDestroy();
       
   232     }
   222     }
   233 
   223 
   234 // ---------------------------------------------------------------------------
   224 // ---------------------------------------------------------------------------
   235 // Tries to find menuitem which matches given HSPS entry
   225 // Tries to find menuitem which matches given HSPS entry
   236 // ---------------------------------------------------------------------------
   226 // ---------------------------------------------------------------------------
   239                  RPointerArray<HSPluginSettingsIf::CPropertyMap>& aProperties )
   229                  RPointerArray<HSPluginSettingsIf::CPropertyMap>& aProperties )
   240     {
   230     {
   241     TSettingItem setting = { KErrNotFound, EApplication , EFalse };
   231     TSettingItem setting = { KErrNotFound, EApplication , EFalse };
   242 
   232 
   243     TSettingType type = SettingTypeL( aProperties );
   233     TSettingType type = SettingTypeL( aProperties );
   244     if ( type == EApplication )
   234     if ( type == EApplication || type == EMailbox )
   245         {
   235         {
   246         setting = iAppList->FindItemL( aProperties );
   236         setting = iAppList->FindItemL( aProperties );
   247         }
   237         }
   248     else if ( type == EBookmark )
   238     else if ( type == EBookmark )
   249         {
   239         {
   305             }
   295             }
   306         }   
   296         }   
   307     
   297     
   308     return EFalse;
   298     return EFalse;
   309     }
   299     }
   310 
       
   311 
   300 
   312 // ---------------------------------------------------------------------------
   301 // ---------------------------------------------------------------------------
   313 // Saves menuitem to HSPS to the given shortcut index
   302 // Saves menuitem to HSPS to the given shortcut index
   314 // ---------------------------------------------------------------------------
   303 // ---------------------------------------------------------------------------
   315 //
   304 //
   318     {    
   307     {    
   319     if( !iPluginId )
   308     if( !iPluginId )
   320         {
   309         {
   321         return;
   310         return;
   322         }
   311         }
   323     
   312 
   324     RPointerArray<CItemMap> settingItems;
   313     RPointerArray<CItemMap> settingItems;    
   325     CleanupClosePushL( settingItems );
   314     CleanupResetAndDestroyPushL( settingItems );
   326     iPluginSettings->GetSettingsL( *iPluginId, settingItems );
   315     iPluginSettings->GetSettingsL( *iPluginId, settingItems );
       
   316 
   327     if ( aIndex >= 0 && aIndex < settingItems.Count() )
   317     if ( aIndex >= 0 && aIndex < settingItems.Count() )
   328         {
   318         {
   329         TBool exists( EFalse );
   319         TBool exists( EFalse );
   330         CItemMap* itemMap = settingItems[ aIndex ];
   320         CItemMap* itemMap = settingItems[ aIndex ];
   331         RPointerArray<HSPluginSettingsIf::CPropertyMap> properties;
   321         RPointerArray<HSPluginSettingsIf::CPropertyMap> properties;
   332         properties = itemMap->Properties();
   322         properties = itemMap->Properties();
       
   323         
       
   324         const TInt KGranularity = 6;
       
   325         CDesC8Array* propertiesList = new ( ELeave ) CDesC8ArrayFlat( KGranularity );
       
   326         CleanupStack::PushL( propertiesList );
       
   327         propertiesList->AppendL( KProperNameType );
       
   328         propertiesList->AppendL( KProperNameParam );
       
   329         propertiesList->AppendL( KProperNameUid );
       
   330         propertiesList->AppendL( KProperNameView );
       
   331         // skip KProperNameLocked property, attribute may be missing. results into
       
   332 		// leave with -1 when saving settings 
       
   333         
       
   334         // add missing properties
       
   335         for ( TInt i=0; i<propertiesList->Count(); i++ )
       
   336             {
       
   337             TBool found( EFalse );
       
   338             const TPtrC8 namePtr = propertiesList->MdcaPoint( i );
       
   339             for ( TInt j=0; j<properties.Count() && !found; j++ )
       
   340                 {
       
   341                 found = ( (namePtr == properties[ j ]->Name() ) ? ETrue : EFalse );
       
   342                 }
       
   343             if ( !found )
       
   344                 {
       
   345                 CPropertyMap* property = CPropertyMap::NewLC();
       
   346                 property->SetNameL( namePtr );
       
   347                 property->SetValueL( KNullDesC8 );
       
   348                 itemMap->AddPropertyMapL( property );
       
   349                 CleanupStack::Pop( property );
       
   350                 
       
   351                 // get updated list
       
   352                 properties = itemMap->Properties();
       
   353                 }
       
   354             }
       
   355         CleanupStack::PopAndDestroy( propertiesList );
       
   356 
   333         for ( TInt i = 0; i < properties.Count(); i++ )
   357         for ( TInt i = 0; i < properties.Count(); i++ )
   334             {
   358             {
   335             if ( properties[ i ]->Name() == KProperNameType )
   359             if ( properties[ i ]->Name() == KProperNameType )
   336                 {
   360                 {
   337                 TPtrC type = aMenuItem.Type();
   361                 TPtrC type = aMenuItem.Type();
   345                     }
   369                     }
   346                 else if ( type == KMenuTypeSuite )
   370                 else if ( type == KMenuTypeSuite )
   347                     {
   371                     {
   348                     properties[ i ]->SetValueL( KProperValueSuite );
   372                     properties[ i ]->SetValueL( KProperValueSuite );
   349                     }
   373                     }
       
   374                 else if( type == KMenuTypeMailbox )
       
   375                     {
       
   376                     properties[ i ]->SetValueL( KProperValueMailbox );
       
   377                     }
   350                 else
   378                 else
   351                     {
   379                     {
   352                     properties[ i ]->SetValueL( KProperValueAppl );
   380                     properties[ i ]->SetValueL( KProperValueAppl );
   353                     }
   381                     }
   354                 }
   382                 }
   355             else if ( properties[ i ]->Name() == KProperNameUid )
   383             else if ( properties[ i ]->Name() == KProperNameUid )
   356                 {
   384                 {
   357                 TPtrC uid = aMenuItem.GetAttributeL( KMenuAttrUid, exists );
   385                 TPtrC uid = aMenuItem.GetAttributeL( KMenuAttrUid, exists );
   358                 if ( exists )
   386                 if ( exists && uid.Length() > 0 )
   359                     {
   387                     {
   360                     HBufC8* uid8( NULL );
   388                     HBufC8* uid8( NULL );
   361                     uid8 = AiUtility::CopyToBufferL( uid8, uid );
   389                     uid8 = AiUtility::CopyToBufferL( uid8, uid );
   362                     CleanupStack::PushL( uid8 );
   390                     CleanupStack::PushL( uid8 );
   363                     properties[ i ]->SetValueL( *uid8 );
   391                     properties[ i ]->SetValueL( *uid8 );
   369                     }
   397                     }
   370                 }
   398                 }
   371             else if ( properties[ i ]->Name() == KProperNameView )
   399             else if ( properties[ i ]->Name() == KProperNameView )
   372                 {
   400                 {
   373                 TPtrC view = aMenuItem.GetAttributeL( KMenuAttrView, exists );
   401                 TPtrC view = aMenuItem.GetAttributeL( KMenuAttrView, exists );
   374                 if( exists )
   402                 if( exists && view.Length() > 0 )
   375                     {
   403                     {
   376                     HBufC8* view8( NULL );
   404                     HBufC8* view8( NULL );
   377                     view8 = AiUtility::CopyToBufferL( view8, view );
   405                     view8 = AiUtility::CopyToBufferL( view8, view );
   378                     CleanupStack::PushL( view8 );
   406                     CleanupStack::PushL( view8 );
   379                     properties[i]->SetValueL( *view8 );
   407                     properties[i]->SetValueL( *view8 );
   395                 if ( type == KMenuTypeFolder )
   423                 if ( type == KMenuTypeFolder )
   396                     {
   424                     {
   397                     isFolder = ETrue;
   425                     isFolder = ETrue;
   398                     }
   426                     }
   399 
   427 
   400                 if ( exists || isFolder )
   428                 if ( (exists && param.Length() > 0) || (isFolder) )
   401                     {
   429                     {
   402                     // the folder id is stored 
   430                     // the folder id is stored 
   403                     // in param attribute in HSPS
   431                     // in param attribute in HSPS
   404                     if ( isFolder )
   432                     if ( isFolder )
   405                         {
   433                         {
   420                     }
   448                     }
   421                 }
   449                 }
   422             else if ( properties[ i ]->Name() == KProperNameLocked )
   450             else if ( properties[ i ]->Name() == KProperNameLocked )
   423                 {
   451                 {
   424                 TPtrC locked = aMenuItem.GetAttributeL( KMenuAttrLocked, exists );
   452                 TPtrC locked = aMenuItem.GetAttributeL( KMenuAttrLocked, exists );
   425                 if ( exists )
   453                 if ( exists && locked.Length() > 0 )
   426                     {
   454                     {
   427                     HBufC8* locked8( NULL );
   455                     HBufC8* locked8( NULL );
   428                     locked8 = AiUtility::CopyToBufferL( locked8, locked );
   456                     locked8 = AiUtility::CopyToBufferL( locked8, locked );
   429                     CleanupStack::PushL( locked8 );
   457                     CleanupStack::PushL( locked8 );
   430                     properties[ i ]->SetValueL( *locked8 );
   458                     properties[ i ]->SetValueL( *locked8 );
   435                     properties[i]->SetValueL( KNullDesC8 );
   463                     properties[i]->SetValueL( KNullDesC8 );
   436                     }
   464                     }
   437                 }
   465                 }
   438             }
   466             }
   439         }
   467         }
       
   468 
   440     // ETrue tells that modified settings are stored also to plugin reference
   469     // ETrue tells that modified settings are stored also to plugin reference
   441     iPluginSettings->SetSettingsL( *iPluginId, settingItems, ETrue );
   470     User::LeaveIfError( iPluginSettings->SetSettingsL( *iPluginId, settingItems, ETrue ) );
   442     CleanupStack::Pop( &settingItems );
   471     CleanupStack::PopAndDestroy(); // settingItems
   443     settingItems.ResetAndDestroy();
       
   444 
       
   445     }
   472     }
   446 
   473 
   447 // ---------------------------------------------------------------------------
   474 // ---------------------------------------------------------------------------
   448 // Updates settings container.
   475 // Updates settings container.
   449 // ---------------------------------------------------------------------------
   476 // ---------------------------------------------------------------------------
   450 //
   477 //
   451 void CMCSPluginSettingsModel::UpdateSettingsContainerL( const TDesC8& aPluginId )
   478 void CMCSPluginSettingsModel::SetPluginIdL( const TDesC8& aPluginId )
   452 {
   479     {
   453     if (iContainer)
   480     delete iPluginId;
   454     {
   481     iPluginId = NULL;
   455         if (iContainer->IsChangeDialogShowing())
   482     iPluginId = aPluginId.AllocL();    
   456         {
   483     }
   457             iContainer->CloseChangeDialog();
       
   458         }
       
   459     }
       
   460 
       
   461     UpdateSettingsL( aPluginId );
       
   462 
       
   463     if (iContainer)
       
   464     {
       
   465         iContainer->ResetCurrentListL(0);
       
   466     }
       
   467 }
       
   468 
   484 
   469 // ---------------------------------------------------------------------------
   485 // ---------------------------------------------------------------------------
   470 // From MDesCArray
   486 // From MDesCArray
   471 // Returns the number of descriptor elements in a descriptor array.
   487 // Returns the number of descriptor elements in a descriptor array.
   472 // ---------------------------------------------------------------------------
   488 // ---------------------------------------------------------------------------
   480 // From MDesCArray
   496 // From MDesCArray
   481 // Indexes into a descriptor array.
   497 // Indexes into a descriptor array.
   482 // ---------------------------------------------------------------------------
   498 // ---------------------------------------------------------------------------
   483 //
   499 //
   484 TPtrC CMCSPluginSettingsModel::MdcaPoint( TInt aIndex ) const
   500 TPtrC CMCSPluginSettingsModel::MdcaPoint( TInt aIndex ) const
   485 {
   501     {
   486     if (aIndex < 0 || aIndex >= iSettings.Count())
   502     if (aIndex < 0 || aIndex >= iSettings.Count())
   487     {
   503         {
   488         TPtrC ret(KNullDesC);
   504         TPtrC ret(KNullDesC);
   489         return ret;
   505         return ret;
   490     }
   506         }
       
   507     
       
   508     TPtrC line( KNullDesC ); 
   491     if ( iSettings[aIndex].type == EApplication )
   509     if ( iSettings[aIndex].type == EApplication )
   492         {
   510         {
   493         // first, we need to check if the item is missing 
   511         // first, we need to check if the item is missing 
   494         // (application unistaled or mmc card removed)
   512         // (application uninstalled or mmc card removed)
   495         // If it is, we return "Undefined" application name instead
   513         // If it is, we return "Undefined" application name instead
   496         if ( iSettings[ aIndex ].id == KErrNotFound )
   514         if ( iSettings[ aIndex ].id == KErrNotFound )
   497             {
   515             {
   498             const TDesC& caption = iAppList->iUndefinedText->Des();
   516             const TDesC& caption = iAppList->UndefinedText();
   499             TPtrC line; 
       
   500             TRAP_IGNORE( line.Set( ListBoxLineL( caption, aIndex ) ) )
   517             TRAP_IGNORE( line.Set( ListBoxLineL( caption, aIndex ) ) )
   501             return line; 
       
   502             }
   518             }
   503         else
   519         else
   504             {
   520             {
   505             const TDesC& caption = iAppList->MdcaPoint( iSettings[ aIndex ].id );
   521             const TDesC& caption = iAppList->MdcaPoint( iSettings[ aIndex ].id );
   506             TPtrC line; 
       
   507             TRAP_IGNORE( line.Set( ListBoxLineL( caption, aIndex ) ) )
   522             TRAP_IGNORE( line.Set( ListBoxLineL( caption, aIndex ) ) )
   508             return line; 
       
   509             }
   523             }
   510         }
   524         }
   511     else
   525     else
   512         {
   526         {
   513         const TDesC& caption = iBkmList->MdcaPoint( iSettings[aIndex].id );
   527         const TDesC& caption = iBkmList->MdcaPoint( iSettings[aIndex].id );
   514         TPtrC line;
       
   515         TRAP_IGNORE( line.Set( ListBoxLineL( caption, aIndex ) ) )
   528         TRAP_IGNORE( line.Set( ListBoxLineL( caption, aIndex ) ) )
   516         return line;
   529         }
   517         }
   530 
   518 }
   531     return line;
       
   532     }
   519 
   533 
   520 // ---------------------------------------------------------------------------
   534 // ---------------------------------------------------------------------------
   521 // Returns a setting ID for the given index.
   535 // Returns a setting ID for the given index.
   522 // ---------------------------------------------------------------------------
   536 // ---------------------------------------------------------------------------
   523 //
   537 //
   553 //
   567 //
   554 TBool CMCSPluginSettingsModel::ReplaceItemL( const TInt& aSettingIndex, 
   568 TBool CMCSPluginSettingsModel::ReplaceItemL( const TInt& aSettingIndex, 
   555                                              TInt aId,
   569                                              TInt aId,
   556                                              TSettingType aType )
   570                                              TSettingType aType )
   557     {
   571     {
       
   572     TBool replaced( EFalse );
   558     if (aSettingIndex >= 0 && aSettingIndex < iSettings.Count())
   573     if (aSettingIndex >= 0 && aSettingIndex < iSettings.Count())
   559         {
   574         {
   560         TSettingItem oldItem = iSettings[ aSettingIndex ];
   575         CMenuItem* item( NULL );
   561         iSettings[ aSettingIndex ].id = aId;
       
   562         iSettings[ aSettingIndex ].type = aType;
       
   563 
       
   564         if ( aType == EApplication )
   576         if ( aType == EApplication )
   565             {
   577             {
   566             CMenuItem& item = iAppList->ItemL( aId );
   578             item = iAppList->ItemL( aId );
   567             SaveSettingsL( aSettingIndex, item );
       
   568             }
   579             }
   569          else
   580          else
   570             {
   581             {
   571             CMenuItem& item = iBkmList->ItemL( aId );
   582             item = iBkmList->ItemL( aId );
   572             SaveSettingsL( aSettingIndex, item );
       
   573             }
   583             }
   574         
   584         
   575         // Old setting type is bookmark. Remove bookmark item from MCS 
   585         if ( item )
   576         // if it was created in runtime.
   586             {
   577         if ( oldItem.type == EBookmark )
   587             SaveSettingsL( aSettingIndex, *item );
   578             {
   588             iSettings[ aSettingIndex ].id = aId;
   579                 iBkmList->RemoveMenuItemL( oldItem.id );
   589             iSettings[ aSettingIndex ].type = aType;
   580             }
   590             replaced = ETrue;
   581 
   591             }
   582         // Old setting type is application.
   592         }
   583         // Remove app item from MCS if it was created in runtime (mailbox).
   593     return replaced;
   584         if ( oldItem.type == EApplication )
       
   585             {
       
   586                 iAppList->RemoveMenuItemL( oldItem.id );
       
   587             }
       
   588 
       
   589         return ETrue;
       
   590         }
       
   591     return EFalse;
       
   592     }
   594     }
   593 
   595 
   594 // ---------------------------------------------------------------------------
   596 // ---------------------------------------------------------------------------
   595 // Sets a container
   597 // Sets a container
   596 // ---------------------------------------------------------------------------
   598 // ---------------------------------------------------------------------------
   620 
   622 
   621 // ---------------------------------------------------------------------------
   623 // ---------------------------------------------------------------------------
   622 // Updates application list
   624 // Updates application list
   623 // ---------------------------------------------------------------------------
   625 // ---------------------------------------------------------------------------
   624 //
   626 //
   625 void CMCSPluginSettingsModel::UpdateAppListL()
   627 void CMCSPluginSettingsModel::UpdateAppListL( TBool aUpdateSettings )
   626 {
   628     {
       
   629     if( !iAppList )
       
   630         {
       
   631         iAppList = CMCSPluginSettingsAppList::NewL();
       
   632         }
   627     iAppList->StartL();
   633     iAppList->StartL();
   628 }
   634     if ( aUpdateSettings )
       
   635         {
       
   636         UpdateSettingsL();
       
   637         }
       
   638     }
   629 
   639 
   630 // ---------------------------------------------------------------------------
   640 // ---------------------------------------------------------------------------
   631 // Updates bookmark list
   641 // Updates bookmark list
   632 // ---------------------------------------------------------------------------
   642 // ---------------------------------------------------------------------------
   633 //
   643 //
   634 void CMCSPluginSettingsModel::UpdateBkmListL()
   644 void CMCSPluginSettingsModel::UpdateBkmListL( TBool aUpdateSettings )
   635 {
   645     {
   636     delete iBkmList;
   646     delete iBkmList;
   637     iBkmList = NULL;
   647     iBkmList = NULL;
   638     iBkmList = CMCSPluginSettingsBkmList::NewL();
   648     iBkmList = CMCSPluginSettingsBkmList::NewL();
   639 }
   649     if ( aUpdateSettings )
       
   650         {
       
   651         UpdateSettingsL();
       
   652         }
       
   653     }
   640 
   654 
   641 // End of File.
   655 // End of File.