XDMSettingsUI/src/XDMPlugin.cpp
changeset 27 ada8ffed4752
parent 20 76bddcd072ba
child 29 0da3f27f7ab2
equal deleted inserted replaced
20:76bddcd072ba 27:ada8ffed4752
     1 /*
       
     2 * Copyright (c) 2005-2007 Nokia Corporation and/or its subsidiary(-ies).
       
     3 * All rights reserved.
       
     4 * This component and the accompanying materials are made available
       
     5 * under the terms of "Eclipse Public License v1.0"
       
     6 * which accompanies this distribution, and is available
       
     7 * at the URL "http://www.eclipse.org/legal/epl-v10.html".
       
     8 *
       
     9 * Initial Contributors:
       
    10 * Nokia Corporation - initial contribution.
       
    11 *
       
    12 * Contributors:
       
    13 *
       
    14 * Description:    XDMPlugin Implementation
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 
       
    20 
       
    21 // Includes
       
    22 #include "XDMExternalInterface.h"
       
    23 
       
    24 #include <aknViewAppUi.h>
       
    25 #include <StringLoader.h>
       
    26 #include <eikmenub.h>
       
    27 #include <aknlists.h>
       
    28 #include <aknPopup.h>
       
    29 #include <XdmSettingsApi.h>
       
    30 #include <AknQueryDialog.h>
       
    31 #include <featmgr.h>
       
    32 #include <hlplch.h>
       
    33 #include <csxhelp/xdm.hlp.hrh>
       
    34 #include <gsxdmplugin.mbg>
       
    35 #include <bautils.h>
       
    36 
       
    37 #include "XDMPlugin.h"
       
    38 #include "XDMPluginContainer.h"
       
    39 #include "XDMPluginSLContainer.h"
       
    40 #include "XDMPlugin.hrh"
       
    41 
       
    42 
       
    43 // Constants
       
    44 
       
    45 #ifdef __SCALABLE_ICONS
       
    46 // bitmap
       
    47 #else //__SCALABLE_ICONS
       
    48 // svg file
       
    49 _LIT( KGSXDMPluginIconFileName, "\\resource\\apps\\GSXDMplugin.mbm");
       
    50 #endif //__SCALABLE_ICONS
       
    51 
       
    52 
       
    53 // ========================= MEMBER FUNCTIONS ================================
       
    54 
       
    55 // ---------------------------------------------------------------------------
       
    56 // CXDMPlugin::CXDMPlugin()
       
    57 // Constructor
       
    58 //
       
    59 // ---------------------------------------------------------------------------
       
    60 //
       
    61 CXDMPlugin::CXDMPlugin( )
       
    62     : iResources( *CCoeEnv::Static() )
       
    63     {
       
    64     
       
    65     }
       
    66 
       
    67 // ---------------------------------------------------------------------------
       
    68 // CXDMPlugin::~CXDMPlugin()
       
    69 // Destructor
       
    70 // ---------------------------------------------------------------------------
       
    71 //
       
    72 CXDMPlugin::~CXDMPlugin()
       
    73     {
       
    74     if (iCurrentContainer)
       
    75         {
       
    76         }
       
    77 
       
    78     if( iMainListContainer )
       
    79         {
       
    80         delete iMainListContainer;
       
    81         iMainListContainer=NULL;
       
    82         }
       
    83         
       
    84     if (iSettingListContainer)
       
    85         {
       
    86         delete iSettingListContainer;
       
    87         iSettingListContainer=NULL;
       
    88         }
       
    89 
       
    90     iResources.Close();
       
    91     /** Nice to know when the plugin is cleaned up */
       
    92     #ifdef _DEBUG
       
    93     RDebug::Print( _L( "[CXDMPlugin] ~CXDMPlugin()" ) );
       
    94     #endif
       
    95     }
       
    96 
       
    97 // ---------------------------------------------------------------------------
       
    98 // CXDMPlugin::ConstructL()
       
    99 // Symbian OS two-phased constructor
       
   100 // ---------------------------------------------------------------------------
       
   101 //
       
   102 void CXDMPlugin::ConstructL()
       
   103     {
       
   104     // To know if the plugin is loaded (for debugging)
       
   105     #ifdef _DEBUG
       
   106     RDebug::Print(_L("[CXDMPlugin] ConstructL()" ));
       
   107     RDebug::Print( _L( "[CXDMPlugin] Loading resource from :" ) );
       
   108     #endif
       
   109     }
       
   110 
       
   111 // ---------------------------------------------------------------------------
       
   112 // CXDMPlugin::NewL()
       
   113 // Static constructor
       
   114 // ---------------------------------------------------------------------------
       
   115 //
       
   116 CXDMPlugin* CXDMPlugin::NewL( TAny* /*aInitParams*/ )
       
   117     {
       
   118     CXDMPlugin* self = new(ELeave) CXDMPlugin( );
       
   119     CleanupStack::PushL(self);
       
   120     self->ConstructL();
       
   121     CleanupStack::Pop(self);
       
   122     return self;
       
   123     }
       
   124 
       
   125 // ---------------------------------------------------------------------------
       
   126 // CXDMPlugin::Id() const
       
   127 // ---------------------------------------------------------------------------
       
   128 //
       
   129 TUid CXDMPlugin::Id() const
       
   130     {
       
   131     return KGSXDMPluginUid;
       
   132     }
       
   133 
       
   134 // ---------------------------------------------------------------------------
       
   135 // CXDMPlugin::HandleClientRectChange()
       
   136 // ---------------------------------------------------------------------------
       
   137 void CXDMPlugin::HandleViewRectChange()
       
   138     {
       
   139     if ( iMainListContainer->IsVisible() )
       
   140         {
       
   141         }
       
   142         
       
   143     if ( iSettingListContainer->IsVisible() )
       
   144         {
       
   145         }
       
   146     }
       
   147 
       
   148 // ---------------------------------------------------------------------------
       
   149 // CXDMPlugin::DoActivateL()
       
   150 // ---------------------------------------------------------------------------
       
   151 //
       
   152 void CXDMPlugin::DoActivateL( const TVwsViewId& aPrevViewId,
       
   153                                   TUid /*aCustomMessageId*/,
       
   154                                   const TDesC8& /*aCustomMessage*/ )
       
   155     {
       
   156     iPrevViewId = aPrevViewId;
       
   157     if (iCurrentContainer)
       
   158         {
       
   159         iCurrentContainer = NULL;
       
   160         }
       
   161         
       
   162 
       
   163     if( iMainListContainer )
       
   164         {
       
   165         delete iMainListContainer;
       
   166         iMainListContainer=NULL;
       
   167         }
       
   168 
       
   169     if( iSettingListContainer )
       
   170         {
       
   171         delete iSettingListContainer;
       
   172         iSettingListContainer = NULL;
       
   173         }
       
   174 
       
   175     // switching control
       
   176     iSettingListContainer->MakeVisible(EFalse);    
       
   177     iCurrentContainer = iMainListContainer;
       
   178     UpdateMSK();
       
   179     }
       
   180 
       
   181 // ---------------------------------------------------------------------------
       
   182 // CXDMPlugin::DoDeactivate()
       
   183 // ---------------------------------------------------------------------------
       
   184 //
       
   185 void CXDMPlugin::DoDeactivate()
       
   186     {
       
   187     // try to save settings if in settings list container
       
   188     TInt err;
       
   189     if (iCurrentContainer == iSettingListContainer)
       
   190         TRAP(err, iSettingListContainer->SaveSettingsIfPossibleL());
       
   191     iCurrentContainer = NULL;
       
   192 
       
   193     if( iMainListContainer )
       
   194         {
       
   195         delete iMainListContainer;
       
   196         iMainListContainer = NULL;
       
   197         }
       
   198         
       
   199     if( iSettingListContainer )
       
   200         {
       
   201         delete iSettingListContainer;
       
   202         iSettingListContainer = NULL;
       
   203         }
       
   204     }
       
   205 
       
   206 // ---------------------------------------------------------------------------
       
   207 // CXDMPlugin::HandleCommandL()
       
   208 // ---------------------------------------------------------------------------
       
   209 //
       
   210 void CXDMPlugin::HandleCommandL( TInt aCommand )
       
   211     {
       
   212     switch ( aCommand )
       
   213         {
       
   214         case EAknSoftkeyBack:
       
   215             if (iCurrentContainer == iSettingListContainer)
       
   216                 {
       
   217                 if (iSettingListContainer->IsExitProcessingOKL())
       
   218                     LoadMainViewL();    
       
   219                 }
       
   220             else 
       
   221                 iAppUi->ActivateLocalViewL( iPrevViewId.iViewUid );
       
   222             break;
       
   223         case EGSXDMPluginCmdChange:
       
   224             iSettingListContainer->EditCurrentItemL();                       
       
   225             break;
       
   226         case EGSXDMPluginCmdEdit:
       
   227             iMainListContainer->EditCurrentItemL();
       
   228             break;
       
   229         case EGSXDMPluginCmdNewExisting:
       
   230             if(iSettingListContainer->DisplayNewXDMSetOptionsL()) // if user ok
       
   231                 LoadSettingsViewL(ENewFromExisting, iSettingListContainer->GetCurrentSetName());
       
   232             break;
       
   233         case EGSXDMPluginCmdNewDefault:
       
   234             LoadSettingsViewL(ENewDefault, iSettingListContainer->GetCurrentSetName());
       
   235             break;
       
   236         case EGSXDMPluginCmdDelete:
       
   237             iMainListContainer->DeleteSetProcedureL();
       
   238             UpdateMSK();
       
   239             break;
       
   240         case EAknCmdHelp:
       
   241             break;
       
   242         case EGSXDMPluginCmdExitFromSL:
       
   243             if (iCurrentContainer == iSettingListContainer)
       
   244                 {
       
   245                 if (iSettingListContainer->IsExitProcessingOKL())
       
   246                     iAppUi->HandleCommandL( EAknCmdExit ); 
       
   247                 }
       
   248             break;
       
   249         case EAknCmdExit:
       
   250         case EEikCmdExit:
       
   251             if (iCurrentContainer == iSettingListContainer)
       
   252                 iSettingListContainer->SaveSettingsIfPossibleL();
       
   253             iAppUi->HandleCommandL( EAknCmdExit );
       
   254             break;    
       
   255         default:
       
   256             iAppUi->HandleCommandL( aCommand );
       
   257             break;
       
   258         }
       
   259     }
       
   260 
       
   261 // ---------------------------------------------------------------------------
       
   262 // CXDMPlugin::LoadSettingsViewL()
       
   263 // ---------------------------------------------------------------------------
       
   264 //
       
   265 void CXDMPlugin::LoadSettingsViewL(TXDMSettingsViewType aType, TDesC& aXDMSetName)
       
   266     {
       
   267     switch(aType)
       
   268         {
       
   269         case EEditExisting:
       
   270             iSettingListContainer->PrepareXDMSetForEditingL(aXDMSetName);
       
   271             break;
       
   272         case ENewDefault:
       
   273             iSettingListContainer->PrepareXDMSetNewDefaultL();
       
   274             break;
       
   275         case ENewFromExisting:
       
   276             iSettingListContainer->PrepareNewXDMSetFromExistingL(aXDMSetName);
       
   277             break;
       
   278         default:
       
   279             break;
       
   280         }
       
   281     iCurrentContainer = iSettingListContainer;
       
   282     iMainListContainer->MakeVisible(EFalse);
       
   283     iSettingListContainer->MakeVisible(ETrue);
       
   284     UpdateMSK();
       
   285     }
       
   286 
       
   287 // ---------------------------------------------------------------------------
       
   288 // CXDMPlugin::LoadMainViewL()
       
   289 // ---------------------------------------------------------------------------
       
   290 //
       
   291 void CXDMPlugin::LoadMainViewL()
       
   292     {
       
   293     TInt err(KErrNone);
       
   294     TRAP(err,iMainListContainer->LoadSettingsListArrayL()); // update main container
       
   295     iCurrentContainer = iMainListContainer;
       
   296     
       
   297     iMainListContainer->SetFocusIfExist(iSettingListContainer->GetCurrentSetName());
       
   298     
       
   299     iSettingListContainer->MakeVisible(EFalse);  
       
   300     iMainListContainer->MakeVisible(ETrue);
       
   301     UpdateMSK();
       
   302     }
       
   303     
       
   304 // ---------------------------------------------------------------------------
       
   305 // CXDMPlugin::DynInitMenuPaneL()
       
   306 // ---------------------------------------------------------------------------
       
   307 //
       
   308 void CXDMPlugin::DynInitMenuPaneL(TInt aResourceId,CEikMenuPane* aMenuPane)
       
   309     {
       
   310     if (!FeatureManager::FeatureSupported(KFeatureIdHelp))
       
   311     	{
       
   312     	aMenuPane->SetItemDimmed(EAknCmdHelp, ETrue);
       
   313     	}
       
   314     
       
   315     if (aResourceId == R_GS_XDM_SETTINGS_MAIN_MENU)
       
   316         {
       
   317         if (iCurrentContainer == iMainListContainer)
       
   318             {
       
   319             aMenuPane->SetItemDimmed(EGSXDMPluginCmdChange, ETrue);
       
   320             aMenuPane->SetItemDimmed(EGSXDMPluginCmdExitFromSL, ETrue);
       
   321             if (iMainListContainer->IsListEmpty())
       
   322                 {
       
   323                 aMenuPane->SetItemDimmed(EGSXDMPluginCmdEdit, ETrue);
       
   324                 aMenuPane->SetItemDimmed(EGSXDMPluginCmdDelete, ETrue);
       
   325                 }
       
   326             }
       
   327         else
       
   328             {
       
   329             aMenuPane->SetItemDimmed(EGSXDMPluginCmdEdit, ETrue);
       
   330             aMenuPane->SetItemDimmed(EGSXDMPluginCmdDelete, ETrue);
       
   331             aMenuPane->SetItemDimmed(EGSXDMPluginCmdNewSettings, ETrue);
       
   332             aMenuPane->SetItemDimmed(EAknCmdExit, ETrue);
       
   333             }
       
   334         }
       
   335     
       
   336     if (aResourceId == R_GS_XDM_NEW_SETTINGS_MENU)
       
   337         {
       
   338         if (iMainListContainer->IsListEmpty())
       
   339             {
       
   340             aMenuPane->SetItemDimmed(EGSXDMPluginCmdNewExisting, ETrue);
       
   341             }
       
   342         }
       
   343     }
       
   344 
       
   345 // ---------------------------------------------------------
       
   346 // CXDMPlugin::HandleResourceChangeManual()
       
   347 // ---------------------------------------------------------
       
   348 //
       
   349 void CXDMPlugin::HandleResourceChangeManual(TInt aType)
       
   350     {
       
   351     if ( iSettingListContainer )
       
   352         iSettingListContainer->HandleResourceChangeManual(aType);    
       
   353     if ( iMainListContainer )
       
   354         iMainListContainer->HandleResourceChangeManual(aType);
       
   355     }
       
   356     
       
   357     
       
   358 // ---------------------------------------------------------------------------
       
   359 // CXDMPlugin::UpdateMSK()
       
   360 // ---------------------------------------------------------------------------
       
   361 //
       
   362 void CXDMPlugin::UpdateMSK()
       
   363     {
       
   364     }
       
   365     
       
   366 // End of file
       
   367 
       
   368