diff -r 502e5d91ad42 -r 15e4dd19031c idlefw/plugins/mcsplugin/settings/src/mcspluginsettingsmodel.cpp --- a/idlefw/plugins/mcsplugin/settings/src/mcspluginsettingsmodel.cpp Mon Mar 15 12:41:53 2010 +0200 +++ b/idlefw/plugins/mcsplugin/settings/src/mcspluginsettingsmodel.cpp Wed Mar 31 22:04:35 2010 +0300 @@ -1,5 +1,5 @@ /* -* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). +* Copyright (c) 2009 - 2010 Nokia Corporation and/or its subsidiary(-ies). * All rights reserved. * This component and the accompanying materials are made available * under the terms of "Eclipse Public License v1.0" @@ -18,22 +18,18 @@ #include #include #include - #include #include #include #include - +#include -#include "mcspluginsettings.h" #include "mcspluginsettingsmodel.h" +#include "mcspluginsettingsapplist.h" +#include "mcspluginsettingsbkmlist.h" #include "mcspluginsettingscontainer.h" -#include "debug.h" - -#include - /** * Line format for the settings list box */ @@ -51,6 +47,8 @@ _LIT8( KProperValueSuite, "suite" ); _LIT8( KProperValueBookmark, "bookmark" ); _LIT8( KProperValueAppl, "application" ); +_LIT8( KProperValueMailbox, "mailbox" ); +_LIT( KMenuTypeMailbox, "menu:mailbox" ); using namespace HSPluginSettingsIf; @@ -147,7 +145,7 @@ // --------------------------------------------------------------------------- // void CMCSPluginSettingsModel::ConstructL() -{ + { CHomescreenSettings::InitializeL( KAppUid ); iPluginSettings = CHomescreenSettings::Instance(); @@ -155,31 +153,24 @@ { User::Leave( KErrUnknown ); } - - iAppList = CMCSPluginSettingsAppList::NewL(); - iAppList->StartL(); - iBkmList = CMCSPluginSettingsBkmList::NewL(); -} - + } // --------------------------------------------------------------------------- // Gets the latest settings from HSPS and updates // --------------------------------------------------------------------------- // -void CMCSPluginSettingsModel::UpdateSettingsL( const TDesC8& aPluginId ) +void CMCSPluginSettingsModel::UpdateSettingsL() { - if( !iPlugin.Activated() ) + if( !iPluginId ) { return; } - if( iPluginId ) + if (iContainer) { - delete iPluginId; - iPluginId = NULL; + iContainer->CloseChangeDialog(); } - iPluginId = aPluginId.AllocL(); - + iSettings.Reset(); RPointerArray settingItems; CleanupClosePushL( settingItems ); @@ -197,38 +188,11 @@ } CleanupStack::Pop( &settingItems ); settingItems.ResetAndDestroy(); - } - -// --------------------------------------------------------------------------- -// Gets the latest settings from HSPS and updates -// --------------------------------------------------------------------------- -// -void CMCSPluginSettingsModel::UpdateSettingModelL( const TDesC8& aPluginId ) - { - if( iPluginId ) + + if (iContainer) { - delete iPluginId; - iPluginId = NULL; + iContainer->ResetCurrentListL(0); } - iPluginId = aPluginId.AllocL(); - - iSettings.Reset(); - RPointerArray settingItems; - CleanupClosePushL( settingItems ); - - iPluginSettings->GetSettingsL( *iPluginId, settingItems ); - - TInt count = settingItems.Count(); - for ( TInt i = 0; i < count; i++ ) - { - CItemMap* itemMap = settingItems[i]; - RPointerArray properties; - properties = itemMap->Properties(); - TSettingItem item = ItemL( properties ); - iSettings.AppendL( item ); - } - CleanupStack::Pop( &settingItems ); - settingItems.ResetAndDestroy(); } // --------------------------------------------------------------------------- @@ -241,7 +205,7 @@ TSettingItem setting = { KErrNotFound, EApplication , EFalse }; TSettingType type = SettingTypeL( aProperties ); - if ( type == EApplication ) + if ( type == EApplication || type == EMailbox ) { setting = iAppList->FindItemL( aProperties ); } @@ -308,7 +272,6 @@ return EFalse; } - // --------------------------------------------------------------------------- // Saves menuitem to HSPS to the given shortcut index // --------------------------------------------------------------------------- @@ -347,6 +310,10 @@ { properties[ i ]->SetValueL( KProperValueSuite ); } + else if( type == KMenuTypeMailbox ) + { + properties[ i ]->SetValueL( KProperValueMailbox ); + } else { properties[ i ]->SetValueL( KProperValueAppl ); @@ -448,24 +415,13 @@ // Updates settings container. // --------------------------------------------------------------------------- // -void CMCSPluginSettingsModel::UpdateSettingsContainerL( const TDesC8& aPluginId ) -{ - if (iContainer) +void CMCSPluginSettingsModel::SetPluginIdL( const TDesC8& aPluginId ) { - if (iContainer->IsChangeDialogShowing()) - { - iContainer->CloseChangeDialog(); - } + delete iPluginId; + iPluginId = NULL; + iPluginId = aPluginId.AllocL(); } - UpdateSettingsL( aPluginId ); - - if (iContainer) - { - iContainer->ResetCurrentListL(0); - } -} - // --------------------------------------------------------------------------- // From MDesCArray // Returns the number of descriptor elements in a descriptor array. @@ -491,11 +447,11 @@ if ( iSettings[aIndex].type == EApplication ) { // first, we need to check if the item is missing - // (application unistaled or mmc card removed) + // (application uninstalled or mmc card removed) // If it is, we return "Undefined" application name instead if ( iSettings[ aIndex ].id == KErrNotFound ) { - const TDesC& caption = iAppList->iUndefinedText->Des(); + const TDesC& caption = iAppList->UndefinedText(); TPtrC line; TRAP_IGNORE( line.Set( ListBoxLineL( caption, aIndex ) ) ) return line; @@ -557,35 +513,19 @@ { if (aSettingIndex >= 0 && aSettingIndex < iSettings.Count()) { - TSettingItem oldItem = iSettings[ aSettingIndex ]; iSettings[ aSettingIndex ].id = aId; iSettings[ aSettingIndex ].type = aType; if ( aType == EApplication ) { - CMenuItem& item = iAppList->ItemL( aId ); - SaveSettingsL( aSettingIndex, item ); + CMenuItem* item = iAppList->ItemL( aId ); + SaveSettingsL( aSettingIndex, *item ); } else { CMenuItem& item = iBkmList->ItemL( aId ); SaveSettingsL( aSettingIndex, item ); } - - // Old setting type is bookmark. Remove bookmark item from MCS - // if it was created in runtime. - if ( oldItem.type == EBookmark ) - { - iBkmList->RemoveMenuItemL( oldItem.id ); - } - - // Old setting type is application. - // Remove app item from MCS if it was created in runtime (mailbox). - if ( oldItem.type == EApplication ) - { - iAppList->RemoveMenuItemL( oldItem.id ); - } - return ETrue; } return EFalse; @@ -623,9 +563,13 @@ // --------------------------------------------------------------------------- // void CMCSPluginSettingsModel::UpdateAppListL() -{ + { + if( !iAppList ) + { + iAppList = CMCSPluginSettingsAppList::NewL(); + } iAppList->StartL(); -} + } // --------------------------------------------------------------------------- // Updates bookmark list