idlefw/plugins/mcsplugin/settings/src/mcspluginsettingsmodel.cpp
branchRCL_3
changeset 18 bd874ee5e5e2
parent 9 d0529222e3f0
child 19 502e5d91ad42
equal deleted inserted replaced
9:d0529222e3f0 18:bd874ee5e5e2
    50 _LIT8( KProperValueFolder, "folder" );
    50 _LIT8( KProperValueFolder, "folder" );
    51 _LIT8( KProperValueSuite, "suite" );
    51 _LIT8( KProperValueSuite, "suite" );
    52 _LIT8( KProperValueBookmark, "bookmark" );
    52 _LIT8( KProperValueBookmark, "bookmark" );
    53 _LIT8( KProperValueAppl, "application" );
    53 _LIT8( KProperValueAppl, "application" );
    54 
    54 
    55 
       
    56 
       
    57 using namespace HSPluginSettingsIf;
    55 using namespace HSPluginSettingsIf;
    58 
    56 
    59 // -----------------------------------------------------------------------------
    57 // -----------------------------------------------------------------------------
    60 // Creates a formatted listbox line.
    58 // Creates a formatted listbox line.
    61 // -----------------------------------------------------------------------------
    59 // -----------------------------------------------------------------------------
   134 //
   132 //
   135 CMCSPluginSettingsModel::~CMCSPluginSettingsModel()
   133 CMCSPluginSettingsModel::~CMCSPluginSettingsModel()
   136 {
   134 {
   137     delete iAppList;
   135     delete iAppList;
   138     delete iBkmList;
   136     delete iBkmList;
   139     iSettings.Reset();
   137     iSettings.Reset();    
   140     delete iPluginSettings;
       
   141     delete iPluginId;
   138     delete iPluginId;
   142     delete iListBoxLine;
   139     delete iListBoxLine;
       
   140     
       
   141     CHomescreenSettings::UnInitialize();
       
   142     iPluginSettings = NULL;
   143 }
   143 }
   144 
   144 
   145 // ---------------------------------------------------------------------------
   145 // ---------------------------------------------------------------------------
   146 // Second phase construction
   146 // Second phase construction
   147 // ---------------------------------------------------------------------------
   147 // ---------------------------------------------------------------------------
   148 //
   148 //
   149 void CMCSPluginSettingsModel::ConstructL()
   149 void CMCSPluginSettingsModel::ConstructL()
   150 {
   150 {
       
   151     CHomescreenSettings::InitializeL( KAppUid );
       
   152     
       
   153     iPluginSettings = CHomescreenSettings::Instance();
       
   154     if( iPluginSettings == NULL )
       
   155         {
       
   156         User::Leave( KErrUnknown );
       
   157         }
       
   158     
   151     iAppList = CMCSPluginSettingsAppList::NewL();
   159     iAppList = CMCSPluginSettingsAppList::NewL();
   152     iAppList->StartL();
   160     iAppList->StartL();
   153     iBkmList = CMCSPluginSettingsBkmList::NewL();
   161     iBkmList = CMCSPluginSettingsBkmList::NewL();
   154 }
   162 }
   155 
   163 
   162     {
   170     {
   163     if( !iPlugin.Activated() )
   171     if( !iPlugin.Activated() )
   164         {
   172         {
   165         return;
   173         return;
   166         }
   174         }
   167     if( !iPluginSettings )
   175     
   168         {
   176     if( iPluginId )
   169         // AILaunch uid in decimal format
   177         {
   170         iPluginSettings = CHomescreenSettings::NewL( KAppUid, aPluginId, this );
   178         delete iPluginId;
   171         iPluginId = aPluginId.AllocL();
   179         iPluginId = NULL;
   172         }
   180         }
   173 
   181     iPluginId = aPluginId.AllocL();    
       
   182     
   174     iSettings.Reset();
   183     iSettings.Reset();
   175     RPointerArray<CItemMap> settingItems;
   184     RPointerArray<CItemMap> settingItems;
   176     CleanupClosePushL( settingItems );
   185     CleanupClosePushL( settingItems );
   177 
   186 
   178     iPluginSettings->GetSettingsL( *iPluginId, settingItems );
   187     iPluginSettings->GetSettingsL( *iPluginId, settingItems );
   189     CleanupStack::Pop( &settingItems );
   198     CleanupStack::Pop( &settingItems );
   190     settingItems.ResetAndDestroy();
   199     settingItems.ResetAndDestroy();
   191     }
   200     }
   192 
   201 
   193 // ---------------------------------------------------------------------------
   202 // ---------------------------------------------------------------------------
       
   203 // Gets the latest settings from HSPS and updates
       
   204 // ---------------------------------------------------------------------------
       
   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     }
       
   233 
       
   234 // ---------------------------------------------------------------------------
   194 // Tries to find menuitem which matches given HSPS entry
   235 // Tries to find menuitem which matches given HSPS entry
   195 // ---------------------------------------------------------------------------
   236 // ---------------------------------------------------------------------------
   196 //
   237 //
   197 TSettingItem CMCSPluginSettingsModel::ItemL( 
   238 TSettingItem CMCSPluginSettingsModel::ItemL( 
   198                  RPointerArray<HSPluginSettingsIf::CPropertyMap>& aProperties )
   239                  RPointerArray<HSPluginSettingsIf::CPropertyMap>& aProperties )
   272 // Saves menuitem to HSPS to the given shortcut index
   313 // Saves menuitem to HSPS to the given shortcut index
   273 // ---------------------------------------------------------------------------
   314 // ---------------------------------------------------------------------------
   274 //
   315 //
   275 void CMCSPluginSettingsModel::SaveSettingsL( const TInt& aIndex, 
   316 void CMCSPluginSettingsModel::SaveSettingsL( const TInt& aIndex, 
   276                                              CMenuItem& aMenuItem )
   317                                              CMenuItem& aMenuItem )
   277     {
   318     {    
   278 
   319     if( !iPluginId )
   279     if ( !iPluginSettings )
       
   280         {
   320         {
   281         return;
   321         return;
   282         }
   322         }
       
   323     
   283     RPointerArray<CItemMap> settingItems;
   324     RPointerArray<CItemMap> settingItems;
   284     CleanupClosePushL( settingItems );
   325     CleanupClosePushL( settingItems );
   285     iPluginSettings->GetSettingsL( *iPluginId, settingItems );
   326     iPluginSettings->GetSettingsL( *iPluginId, settingItems );
   286     if ( aIndex >= 0 && aIndex < settingItems.Count() )
   327     if ( aIndex >= 0 && aIndex < settingItems.Count() )
   287         {
   328         {
   424         iContainer->ResetCurrentListL(0);
   465         iContainer->ResetCurrentListL(0);
   425     }
   466     }
   426 }
   467 }
   427 
   468 
   428 // ---------------------------------------------------------------------------
   469 // ---------------------------------------------------------------------------
   429 // From MHomeScreenSettingsObserver - handler for HSPS setting change
       
   430 // ---------------------------------------------------------------------------
       
   431 //
       
   432 TInt CMCSPluginSettingsModel::SettingsChangedL( const TDesC8& /*aEvent*/,  
       
   433                                                 const TDesC8& /*aPluginName*/,
       
   434                                                 const TDesC8& /*aPluginUid*/, 
       
   435                                                 const TDesC8& /*aPluginId*/ )
       
   436     {
       
   437     return KErrNone;
       
   438     }
       
   439 
       
   440 // ---------------------------------------------------------------------------
       
   441 // From MDesCArray
   470 // From MDesCArray
   442 // Returns the number of descriptor elements in a descriptor array.
   471 // Returns the number of descriptor elements in a descriptor array.
   443 // ---------------------------------------------------------------------------
   472 // ---------------------------------------------------------------------------
   444 //
   473 //
   445 TInt CMCSPluginSettingsModel::MdcaCount() const
   474 TInt CMCSPluginSettingsModel::MdcaCount() const