idlefw/plugins/mcsplugin/settings/src/mcspluginsettingscontainer.cpp
branchRCL_3
changeset 17 cb506ec2d869
parent 16 b276298d5729
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".
    13 *
    13 *
    14 * Description:  Shortcut settings plug-in container.
    14 * Description:  Shortcut settings plug-in container.
    15 *
    15 *
    16 */
    16 */
    17 
    17 
    18 
       
    19 #include <aknlists.h>
       
    20 #include <AknWaitDialog.h>
       
    21 #include <aknnotewrappers.h>
    18 #include <aknnotewrappers.h>
    22 #include <eikbtgpc.h>
    19 #include <aknlistquerydialog.h>
    23 #include <gslistbox.h>
    20 #include <e32cmn.h>
    24 #include <gsfwviewuids.h>
       
    25 #include <aknradiobuttonsettingpage.h>
    21 #include <aknradiobuttonsettingpage.h>
    26 #include <akntextsettingpage.h>
       
    27 #include <centralrepository.h>
       
    28 #include <StringLoader.h>
    22 #include <StringLoader.h>
    29 
       
    30 #include <csxhelp/ai.hlp.hrh>
    23 #include <csxhelp/ai.hlp.hrh>
    31 #include <hlplch.h>
    24 #include <hlplch.h>
    32 
    25 #include <activefavouritesdbnotifier.h>
    33 // For CActiveFavouritesDbNotifier
       
    34 #include <activefavouritesdbnotifier.h> 
       
    35 #include <mcspluginsettingsres.rsg>
    26 #include <mcspluginsettingsres.rsg>
    36 
    27 
    37 #include "mcspluginsettingscontainer.h"
    28 #include "mcspluginsettingscontainer.h"
    38 #include "mcspluginsettingsmodel.h"
    29 #include "mcspluginsettingsmodel.h"
       
    30 #include "mcspluginsettingsapplist.h"
    39 #include "mcspluginsettingsbkmlist.h"
    31 #include "mcspluginsettingsbkmlist.h"
    40 #include "mcspluginsettings.hrh"
    32 #include "mcspluginsettings.hrh"
    41 #include "mcspluginuids.hrh"
    33 #include "mcspluginuids.hrh"
    42 
    34 
    43 _LIT( KMyMenuData, "matrixmenudata" );
    35 _LIT( KMyMenuData, "matrixmenudata" );
    59 void CMCSPluginSettingsContainer::ConstructL( const TRect& aRect )
    51 void CMCSPluginSettingsContainer::ConstructL( const TRect& aRect )
    60     {
    52     {
    61     iListBox = new (ELeave) CAknSettingStyleListBox;
    53     iListBox = new (ELeave) CAknSettingStyleListBox;
    62     BaseConstructL(aRect, R_AI_MCS_SETTINGS_VIEW_TITLE, NULL);
    54     BaseConstructL(aRect, R_AI_MCS_SETTINGS_VIEW_TITLE, NULL);
    63     StartObservingL();
    55     StartObservingL();
    64     CheckMiddleSoftkeyLabelL();
    56     CheckMiddleSoftkeyLabel();
    65     }
    57     }
    66 
    58 
    67 // ---------------------------------------------------------------------------
    59 // ---------------------------------------------------------------------------
    68 // Tells the settings container to start observing for changes
    60 // Tells the settings container to start observing for changes
    69 // ---------------------------------------------------------------------------
    61 // ---------------------------------------------------------------------------
    86     TInt err = iNotifier.Open( iMenu ); 
    78     TInt err = iNotifier.Open( iMenu ); 
    87     if ( err == KErrNone )
    79     if ( err == KErrNone )
    88         {
    80         {
    89         iNotifyWatcher = CMCSPluginWatcher::NewL( CMCSPluginWatcher::ENotify );
    81         iNotifyWatcher = CMCSPluginWatcher::NewL( CMCSPluginWatcher::ENotify );
    90         iNotifier.Notify( 0,
    82         iNotifier.Notify( 0,
    91             RMenuNotifier::EItemsAddedRemoved | 
    83             RMenuNotifier::EItemsAddedRemoved,
    92             RMenuNotifier::EItemsReordered |
       
    93             RMenuNotifier::EItemAttributeChanged,
       
    94         iNotifyWatcher->iStatus );
    84         iNotifyWatcher->iStatus );
    95         iNotifyWatcher->WatchNotify( this );
    85         iNotifyWatcher->WatchNotify( this );
    96         }
    86         }
    97     }
    87     }
    98 
    88 
   236     HlpLauncher::LaunchHelpApplicationL( CCoeEnv::Static()->WsSession(), array );
   226     HlpLauncher::LaunchHelpApplicationL( CCoeEnv::Static()->WsSession(), array );
   237     CleanupStack::Pop( array );
   227     CleanupStack::Pop( array );
   238 }
   228 }
   239 
   229 
   240 // ---------------------------------------------------------------------------
   230 // ---------------------------------------------------------------------------
   241 // Helper method which indicates if the Applist or Bkmlist is showing
       
   242 // ---------------------------------------------------------------------------
       
   243 //
       
   244 TBool CMCSPluginSettingsContainer::IsChangeDialogShowing()
       
   245 {
       
   246     return ( iAppListDialog || iBkmListDialog );
       
   247 }
       
   248 
       
   249 // ---------------------------------------------------------------------------
       
   250 // Method for closing change dialog (app or bkm) if it is beeing shown
   231 // Method for closing change dialog (app or bkm) if it is beeing shown
   251 // ---------------------------------------------------------------------------
   232 // ---------------------------------------------------------------------------
   252 //
   233 //
   253 void CMCSPluginSettingsContainer::CloseChangeDialog()
   234 void CMCSPluginSettingsContainer::CloseChangeDialog()
   254 {
   235 {
   290     {
   271     {
   291         iListBox->HandleItemAdditionL();
   272         iListBox->HandleItemAdditionL();
   292     }
   273     }
   293 
   274 
   294     iListBox->SetCurrentItemIndex( aIndex );
   275     iListBox->SetCurrentItemIndex( aIndex );
   295     CheckMiddleSoftkeyLabelL();
   276     CheckMiddleSoftkeyLabel();
   296 }
   277 }
   297 
   278 
   298 // ---------------------------------------------------------------------------
   279 // ---------------------------------------------------------------------------
   299 // From class MMsvSessionObserver.
   280 // From class MMsvSessionObserver.
   300 // Handles an event from the message server.
   281 // Handles an event from the message server.
   312         // fall-through intended here
   293         // fall-through intended here
   313     case EMsvEntriesDeleted:
   294     case EMsvEntriesDeleted:
   314         // fall-through intended here
   295         // fall-through intended here
   315     case EMsvEntriesChanged:
   296     case EMsvEntriesChanged:
   316         {
   297         {
   317         if ( IsChangeDialogShowing() )
       
   318             {
       
   319             CloseChangeDialog();
       
   320             }
       
   321         iModel->UpdateAppListL();
   298         iModel->UpdateAppListL();
   322         }
   299         }
   323         break;
   300         break;
   324     default:
   301     default:
   325         break;
   302         break;
   333 //
   310 //
   334 void CMCSPluginSettingsContainer::ConstructListBoxL(TInt /*aResLbxId*/)
   311 void CMCSPluginSettingsContainer::ConstructListBoxL(TInt /*aResLbxId*/)
   335 {
   312 {
   336 	iListBox->ConstructL(this, EAknListBoxSelectionList);
   313 	iListBox->ConstructL(this, EAknListBoxSelectionList);
   337     // Set empty listbox's text.
   314     // Set empty listbox's text.
   338 	if (iModel->MdcaCount() == 0)
   315     iListBox->View()->SetListEmptyTextL(KNullDesC);
   339 		{
       
   340 		HBufC* text = iCoeEnv->AllocReadResourceLC(R_AI_MCS_SETTINGS_TXT_ALL_FIXED);
       
   341 		iListBox->View()->SetListEmptyTextL(*text);
       
   342 		CleanupStack::PopAndDestroy(text);
       
   343 		}
       
   344 	else
       
   345 		{
       
   346 		 iListBox->View()->SetListEmptyTextL(KNullDesC);  
       
   347 		}
       
   348     iListBox->Model()->SetItemTextArray(iModel);
   316     iListBox->Model()->SetItemTextArray(iModel);
   349     iListBox->Model()->SetOwnershipType(ELbmDoesNotOwnItemArray);
   317     iListBox->Model()->SetOwnershipType(ELbmDoesNotOwnItemArray);
   350 }
   318 }
   351 
   319 
   352 // ---------------------------------------------------------------------------
   320 // ---------------------------------------------------------------------------
   353 // Chandles a setting change command to select application from a list.
   321 // Handles a setting change command to select application from a list.
   354 // ---------------------------------------------------------------------------
   322 // ---------------------------------------------------------------------------
   355 //
   323 //
   356 TBool CMCSPluginSettingsContainer::HandleAppListChangeCommandL( const TInt& aIndex,
   324 TBool CMCSPluginSettingsContainer::HandleAppListChangeCommandL( const TInt& aIndex,
   357                                                                 const TInt& aSettingIndex )
   325                                                                 const TInt& aSettingIndex )
   358 {
   326 {
   370     iAppListDialog->ConstructL();
   338     iAppListDialog->ConstructL();
   371 
   339 
   372     if (iAppListDialog->ExecuteLD(CAknSettingPage::EUpdateWhenChanged) &&
   340     if (iAppListDialog->ExecuteLD(CAknSettingPage::EUpdateWhenChanged) &&
   373         index != oldIndex)
   341         index != oldIndex)
   374         {
   342         {
   375         changed = iModel->ReplaceItemL( iListBox->CurrentItemIndex(), index , EApplication );
   343         changed = iModel->ReplaceItemL( aSettingIndex, index , EApplication );
   376         }
   344         }
   377 
   345 
   378     CleanupStack::PopAndDestroy( title );
   346     CleanupStack::PopAndDestroy( title );
   379     iAppListDialog = NULL;
   347     iAppListDialog = NULL;
   380 
   348 
   401     iBkmListDialog->ConstructL();
   369     iBkmListDialog->ConstructL();
   402 
   370 
   403     if (iBkmListDialog->ExecuteLD(CAknSettingPage::EUpdateWhenChanged) &&
   371     if (iBkmListDialog->ExecuteLD(CAknSettingPage::EUpdateWhenChanged) &&
   404         index != oldIndex)
   372         index != oldIndex)
   405         {
   373         {
   406         changed = iModel->ReplaceItemL( iListBox->CurrentItemIndex(), index , EBookmark );
   374         changed = iModel->ReplaceItemL( aSettingIndex, index , EBookmark );
   407         }
   375         }
   408 
   376 
   409     CleanupStack::PopAndDestroy( title );
   377     CleanupStack::PopAndDestroy( title );
   410     iBkmListDialog = NULL;
   378     iBkmListDialog = NULL;
   411     return changed;
   379     return changed;
   449 
   417 
   450 // ---------------------------------------------------------------------------
   418 // ---------------------------------------------------------------------------
   451 // Checks if there is a need to update the middle softkey label.
   419 // Checks if there is a need to update the middle softkey label.
   452 // ---------------------------------------------------------------------------
   420 // ---------------------------------------------------------------------------
   453 //
   421 //
   454 void CMCSPluginSettingsContainer::CheckMiddleSoftkeyLabelL()
   422 void CMCSPluginSettingsContainer::CheckMiddleSoftkeyLabel()
   455 {
   423 {
   456     CEikButtonGroupContainer* cba = CEikButtonGroupContainer::Current();
   424     CEikButtonGroupContainer* cba = CEikButtonGroupContainer::Current();
   457     if (cba)
   425     if (cba)
   458     {
   426     {
   459         cba->MakeCommandVisible(EAiScutSettingsCmdChange, (iModel->MdcaCount() != 0));
   427         cba->MakeCommandVisible(EAiScutSettingsCmdChange, (iModel->MdcaCount() != 0));
   473             // fall-through intended here
   441             // fall-through intended here
   474         case RDbNotifier::ERecover  :
   442         case RDbNotifier::ERecover  :
   475             // fall-through intended here
   443             // fall-through intended here
   476         case RDbNotifier::ERollback :
   444         case RDbNotifier::ERollback :
   477             {
   445             {
   478             if ( IsChangeDialogShowing() )
   446             CloseChangeDialog();
   479                 {
       
   480                 CloseChangeDialog();
       
   481                 }
       
   482             iModel->UpdateBkmListL();
   447             iModel->UpdateBkmListL();
   483             }
   448             }
   484             break;
   449             break;
   485         default:
   450         default:
   486             break;
   451             break;
   492 // Handles matrix menu event.
   457 // Handles matrix menu event.
   493 // -----------------------------------------------------------------------------
   458 // -----------------------------------------------------------------------------
   494 //
   459 //
   495 void CMCSPluginSettingsContainer::HandleNotifyL()
   460 void CMCSPluginSettingsContainer::HandleNotifyL()
   496     {
   461     {
   497     if ( IsChangeDialogShowing() )
   462     CloseChangeDialog();
   498         {
   463 
   499         CloseChangeDialog();
       
   500         }
       
   501     iModel->UpdateAppListL();
   464     iModel->UpdateAppListL();
       
   465     ResetCurrentListL(0);
   502     
   466     
   503     // Notification must be activated again
   467     // Notification must be activated again
   504     iNotifyWatcher->Cancel();
   468     iNotifyWatcher->Cancel();
   505     iNotifier.Notify( 0,
   469     iNotifier.Notify( 0,
   506         RMenuNotifier::EItemsAddedRemoved | 
   470         RMenuNotifier::EItemsAddedRemoved,
   507         RMenuNotifier::EItemsReordered |
       
   508         RMenuNotifier::EItemAttributeChanged,
       
   509         iNotifyWatcher->iStatus );
   471         iNotifyWatcher->iStatus );
   510     iNotifyWatcher->WatchNotify( this );
   472     iNotifyWatcher->WatchNotify( this );
   511     }
   473     }
   512 
   474 
   513 // End of File.
   475 // End of File.