XDMSettingsUI/src/XDMPlugin.cpp
changeset 13 b7e70c0792e6
parent 12 e6a66db4e9d0
equal deleted inserted replaced
12:e6a66db4e9d0 13:b7e70c0792e6
    21 // Includes
    21 // Includes
    22 #include "XDMExternalInterface.h"
    22 #include "XDMExternalInterface.h"
    23 
    23 
    24 #include <aknViewAppUi.h>
    24 #include <aknViewAppUi.h>
    25 #include <StringLoader.h>
    25 #include <StringLoader.h>
    26 #include <GSPrivatePluginProviderIds.h>
       
    27 #include <eikmenub.h>
    26 #include <eikmenub.h>
    28 #include <aknlists.h>
    27 #include <aknlists.h>
    29 #include <aknPopup.h>
    28 #include <aknPopup.h>
    30 #include <XdmSettingsApi.h>
    29 #include <XdmSettingsApi.h>
    31 #include <AknQueryDialog.h>
    30 #include <AknQueryDialog.h>
    40 #include "XDMPluginSLContainer.h"
    39 #include "XDMPluginSLContainer.h"
    41 #include "XDMPlugin.hrh"
    40 #include "XDMPlugin.hrh"
    42 
    41 
    43 
    42 
    44 // Constants
    43 // Constants
    45 _LIT( KGSXDMPluginResourceFileName, "z:\\resource\\XDMPluginRsc.rsc" );
       
    46 
    44 
    47 #ifdef __SCALABLE_ICONS
    45 #ifdef __SCALABLE_ICONS
    48 // bitmap
    46 // bitmap
    49 _LIT( KGSXDMPluginIconFileName, "\\resource\\apps\\GSXDMplugin.mif");
       
    50 #else //__SCALABLE_ICONS
    47 #else //__SCALABLE_ICONS
    51 // svg file
    48 // svg file
    52 _LIT( KGSXDMPluginIconFileName, "\\resource\\apps\\GSXDMplugin.mbm");
    49 _LIT( KGSXDMPluginIconFileName, "\\resource\\apps\\GSXDMplugin.mbm");
    53 #endif //__SCALABLE_ICONS
    50 #endif //__SCALABLE_ICONS
    54 
    51 
    60 // Constructor
    57 // Constructor
    61 //
    58 //
    62 // ---------------------------------------------------------------------------
    59 // ---------------------------------------------------------------------------
    63 //
    60 //
    64 CXDMPlugin::CXDMPlugin( )
    61 CXDMPlugin::CXDMPlugin( )
    65     : iAppUi( CAknView::AppUi() ), iResources( *CCoeEnv::Static() )
    62     : iResources( *CCoeEnv::Static() )
    66     {
    63     {
    67     
    64     
    68     }
    65     }
    69 
    66 
    70 // ---------------------------------------------------------------------------
    67 // ---------------------------------------------------------------------------
    74 //
    71 //
    75 CXDMPlugin::~CXDMPlugin()
    72 CXDMPlugin::~CXDMPlugin()
    76     {
    73     {
    77     if (iCurrentContainer)
    74     if (iCurrentContainer)
    78         {
    75         {
    79         if(iAppUi)
       
    80         iAppUi->RemoveFromViewStack( *this, iCurrentContainer );
       
    81         iCurrentContainer = NULL;
       
    82         }
    76         }
    83 
    77 
    84     if( iMainListContainer )
    78     if( iMainListContainer )
    85         {
    79         {
    86         delete iMainListContainer;
    80         delete iMainListContainer;
   109     {
   103     {
   110     // To know if the plugin is loaded (for debugging)
   104     // To know if the plugin is loaded (for debugging)
   111     #ifdef _DEBUG
   105     #ifdef _DEBUG
   112     RDebug::Print(_L("[CXDMPlugin] ConstructL()" ));
   106     RDebug::Print(_L("[CXDMPlugin] ConstructL()" ));
   113     RDebug::Print( _L( "[CXDMPlugin] Loading resource from :" ) );
   107     RDebug::Print( _L( "[CXDMPlugin] Loading resource from :" ) );
   114     RDebug::Print( KGSXDMPluginResourceFileName );
       
   115     #endif
   108     #endif
   116     
       
   117     TFileName fileName( KGSXDMPluginResourceFileName );
       
   118     BaflUtils::NearestLanguageFile( iCoeEnv->FsSession(), fileName );
       
   119     iResources.OpenL( fileName );
       
   120     BaseConstructL( R_GS_XDM_MAIN_VIEW );
       
   121         
       
   122     }
   109     }
   123 
   110 
   124 // ---------------------------------------------------------------------------
   111 // ---------------------------------------------------------------------------
   125 // CXDMPlugin::NewL()
   112 // CXDMPlugin::NewL()
   126 // Static constructor
   113 // Static constructor
   149 // ---------------------------------------------------------------------------
   136 // ---------------------------------------------------------------------------
   150 void CXDMPlugin::HandleViewRectChange()
   137 void CXDMPlugin::HandleViewRectChange()
   151     {
   138     {
   152     if ( iMainListContainer->IsVisible() )
   139     if ( iMainListContainer->IsVisible() )
   153         {
   140         {
   154         iMainListContainer->SetRect( ClientRect() );
       
   155         }
   141         }
   156         
   142         
   157     if ( iSettingListContainer->IsVisible() )
   143     if ( iSettingListContainer->IsVisible() )
   158         {
   144         {
   159         iSettingListContainer->SetRect( ClientRect() );
       
   160         }
   145         }
   161     }
   146     }
   162 
   147 
   163 // ---------------------------------------------------------------------------
   148 // ---------------------------------------------------------------------------
   164 // CXDMPlugin::DoActivateL()
   149 // CXDMPlugin::DoActivateL()
   169                                   const TDesC8& /*aCustomMessage*/ )
   154                                   const TDesC8& /*aCustomMessage*/ )
   170     {
   155     {
   171     iPrevViewId = aPrevViewId;
   156     iPrevViewId = aPrevViewId;
   172     if (iCurrentContainer)
   157     if (iCurrentContainer)
   173         {
   158         {
   174         iAppUi->RemoveFromViewStack( *this, iCurrentContainer );
       
   175         iCurrentContainer = NULL;
   159         iCurrentContainer = NULL;
   176         }
   160         }
   177         
   161         
   178 
   162 
   179     if( iMainListContainer )
   163     if( iMainListContainer )
   184 
   168 
   185     if( iSettingListContainer )
   169     if( iSettingListContainer )
   186         {
   170         {
   187         delete iSettingListContainer;
   171         delete iSettingListContainer;
   188         iSettingListContainer = NULL;
   172         iSettingListContainer = NULL;
   189         }
       
   190 
       
   191     iMainListContainer = new( ELeave ) CXDMPluginContainer(this);
       
   192     iMainListContainer->SetMopParent(this);
       
   193     TRAPD( error, iMainListContainer->ConstructL( ClientRect() ) );
       
   194     if (error)
       
   195         {
       
   196         delete iMainListContainer;
       
   197         iMainListContainer = NULL;
       
   198         User::Leave( error );
       
   199         }
       
   200         
       
   201     iSettingListContainer = new( ELeave ) CXDMPluginSLContainer(this);
       
   202     iSettingListContainer->SetMopParent(this);
       
   203     TRAPD( error1, iSettingListContainer->ConstructL( ClientRect()));
       
   204     if (error1)
       
   205         {
       
   206         delete iSettingListContainer;
       
   207         iSettingListContainer = NULL;
       
   208         User::Leave( error1 );
       
   209         }
   173         }
   210 
   174 
   211     // switching control
   175     // switching control
   212     iSettingListContainer->MakeVisible(EFalse);    
   176     iSettingListContainer->MakeVisible(EFalse);    
   213     iCurrentContainer = iMainListContainer;
   177     iCurrentContainer = iMainListContainer;
   214     iAppUi->AddToViewStackL( *this, iCurrentContainer );
       
   215     UpdateMSK();
   178     UpdateMSK();
   216     }
   179     }
   217 
   180 
   218 // ---------------------------------------------------------------------------
   181 // ---------------------------------------------------------------------------
   219 // CXDMPlugin::DoDeactivate()
   182 // CXDMPlugin::DoDeactivate()
   223     {
   186     {
   224     // try to save settings if in settings list container
   187     // try to save settings if in settings list container
   225     TInt err;
   188     TInt err;
   226     if (iCurrentContainer == iSettingListContainer)
   189     if (iCurrentContainer == iSettingListContainer)
   227         TRAP(err, iSettingListContainer->SaveSettingsIfPossibleL());
   190         TRAP(err, iSettingListContainer->SaveSettingsIfPossibleL());
   228     if (iCurrentContainer)
       
   229         iAppUi->RemoveFromViewStack( *this, iCurrentContainer );
       
   230     iCurrentContainer = NULL;
   191     iCurrentContainer = NULL;
   231 
   192 
   232     if( iMainListContainer )
   193     if( iMainListContainer )
   233         {
   194         {
   234         delete iMainListContainer;
   195         delete iMainListContainer;
   275         case EGSXDMPluginCmdDelete:
   236         case EGSXDMPluginCmdDelete:
   276             iMainListContainer->DeleteSetProcedureL();
   237             iMainListContainer->DeleteSetProcedureL();
   277             UpdateMSK();
   238             UpdateMSK();
   278             break;
   239             break;
   279         case EAknCmdHelp:
   240         case EAknCmdHelp:
   280             HlpLauncher::LaunchHelpApplicationL(iEikonEnv->WsSession(), AppUi()->AppHelpContextL ());
       
   281             break;
   241             break;
   282         case EGSXDMPluginCmdExitFromSL:
   242         case EGSXDMPluginCmdExitFromSL:
   283             if (iCurrentContainer == iSettingListContainer)
   243             if (iCurrentContainer == iSettingListContainer)
   284                 {
   244                 {
   285                 if (iSettingListContainer->IsExitProcessingOKL())
   245                 if (iSettingListContainer->IsExitProcessingOKL())
   297             break;
   257             break;
   298         }
   258         }
   299     }
   259     }
   300 
   260 
   301 // ---------------------------------------------------------------------------
   261 // ---------------------------------------------------------------------------
   302 // CXDMPlugin::GetCaptionL()
       
   303 // ---------------------------------------------------------------------------
       
   304 //
       
   305 void CXDMPlugin::GetCaptionL( TDes& aCaption ) const
       
   306     {
       
   307     StringLoader::Load( aCaption, R_STR_XDM_SETTINGS );
       
   308     }
       
   309 
       
   310 // ---------------------------------------------------------------------------
       
   311 // CXDMPlugin::PluginProviderCategory()
       
   312 // ---------------------------------------------------------------------------
       
   313 //
       
   314 TInt CXDMPlugin::PluginProviderCategory() const
       
   315     {
       
   316     return KGSPluginProviderInternal;
       
   317     }
       
   318 
       
   319 // ---------------------------------------------------------------------------
       
   320 // CXDMPlugin::LoadSettingsViewL()
   262 // CXDMPlugin::LoadSettingsViewL()
   321 // ---------------------------------------------------------------------------
   263 // ---------------------------------------------------------------------------
   322 //
   264 //
   323 void CXDMPlugin::LoadSettingsViewL(TXDMSettingsViewType aType, TDesC& aXDMSetName)
   265 void CXDMPlugin::LoadSettingsViewL(TXDMSettingsViewType aType, TDesC& aXDMSetName)
   324     {
   266     {
   334             iSettingListContainer->PrepareNewXDMSetFromExistingL(aXDMSetName);
   276             iSettingListContainer->PrepareNewXDMSetFromExistingL(aXDMSetName);
   335             break;
   277             break;
   336         default:
   278         default:
   337             break;
   279             break;
   338         }
   280         }
   339     if (iCurrentContainer)
       
   340         iAppUi->RemoveFromViewStack( *this, iCurrentContainer );
       
   341     iCurrentContainer = iSettingListContainer;
   281     iCurrentContainer = iSettingListContainer;
   342     iAppUi->AddToViewStackL( *this, iCurrentContainer );
       
   343     iMainListContainer->MakeVisible(EFalse);
   282     iMainListContainer->MakeVisible(EFalse);
   344     iSettingListContainer->MakeVisible(ETrue);
   283     iSettingListContainer->MakeVisible(ETrue);
   345     UpdateMSK();
   284     UpdateMSK();
   346     }
   285     }
   347 
   286 
   351 //
   290 //
   352 void CXDMPlugin::LoadMainViewL()
   291 void CXDMPlugin::LoadMainViewL()
   353     {
   292     {
   354     TInt err(KErrNone);
   293     TInt err(KErrNone);
   355     TRAP(err,iMainListContainer->LoadSettingsListArrayL()); // update main container
   294     TRAP(err,iMainListContainer->LoadSettingsListArrayL()); // update main container
   356     if (iCurrentContainer)
       
   357         iAppUi->RemoveFromViewStack( *this, iCurrentContainer );
       
   358     iCurrentContainer = iMainListContainer;
   295     iCurrentContainer = iMainListContainer;
   359     iAppUi->AddToViewStackL( *this, iCurrentContainer );
       
   360     
   296     
   361     iMainListContainer->SetFocusIfExist(iSettingListContainer->GetCurrentSetName());
   297     iMainListContainer->SetFocusIfExist(iSettingListContainer->GetCurrentSetName());
   362     
   298     
   363     iSettingListContainer->MakeVisible(EFalse);  
   299     iSettingListContainer->MakeVisible(EFalse);  
   364     iMainListContainer->MakeVisible(ETrue);
   300     iMainListContainer->MakeVisible(ETrue);
   410 // CXDMPlugin::HandleResourceChangeManual()
   346 // CXDMPlugin::HandleResourceChangeManual()
   411 // ---------------------------------------------------------
   347 // ---------------------------------------------------------
   412 //
   348 //
   413 void CXDMPlugin::HandleResourceChangeManual(TInt aType)
   349 void CXDMPlugin::HandleResourceChangeManual(TInt aType)
   414     {
   350     {
   415     if (iMainListContainer)
   351     if ( iSettingListContainer )
   416         iSettingListContainer->HandleResourceChangeManual(aType);    
   352         iSettingListContainer->HandleResourceChangeManual(aType);    
   417     if (iSettingListContainer)
   353     if ( iMainListContainer )
   418         iMainListContainer->HandleResourceChangeManual(aType);
   354         iMainListContainer->HandleResourceChangeManual(aType);
   419     }
   355     }
   420     
   356     
   421 // ---------------------------------------------------------------------------
       
   422 // CXDMPlugin::CreateIconL
       
   423 // ---------------------------------------------------------------------------
       
   424 //
       
   425 CGulIcon* CXDMPlugin::CreateIconL( const TUid aIconType )
       
   426     {
       
   427     CGulIcon* icon;
       
   428        
       
   429     if( aIconType == KGSIconTypeLbxItem )
       
   430         {
       
   431         icon = AknsUtils::CreateGulIconL(
       
   432         AknsUtils::SkinInstance(), 
       
   433         KAknsIIDQgnPropSetConnXdm, 
       
   434         KGSXDMPluginIconFileName,
       
   435         EMbmGsxdmpluginQgn_prop_set_conn_xdm,
       
   436         EMbmGsxdmpluginQgn_prop_set_conn_xdm_mask);
       
   437         }
       
   438      else
       
   439         {
       
   440         icon = CGSPluginInterface::CreateIconL( aIconType );
       
   441         }
       
   442 
       
   443     return icon;
       
   444     }
       
   445     
   357     
   446 // ---------------------------------------------------------------------------
   358 // ---------------------------------------------------------------------------
   447 // CXDMPlugin::UpdateMSK()
   359 // CXDMPlugin::UpdateMSK()
   448 // ---------------------------------------------------------------------------
   360 // ---------------------------------------------------------------------------
   449 //
   361 //
   450 void CXDMPlugin::UpdateMSK()
   362 void CXDMPlugin::UpdateMSK()
   451     {
   363     {
   452     CEikCba* cba = static_cast< CEikCba* >( Cba()->ButtonGroup() );
       
   453     if(iCurrentContainer==iMainListContainer)
       
   454         {
       
   455         TBool showEdit = !(iMainListContainer->IsListEmpty());
       
   456         cba->SetCommandSetL(R_XDMUI_MAINVIEW_SOFTKEYS);
       
   457         cba->MakeCommandVisible( EGSXDMPluginCmdEdit, showEdit );
       
   458         }
       
   459     else if(iCurrentContainer==iSettingListContainer)
       
   460         {
       
   461         cba->SetCommandSetL(R_XDMUI_MAINVIEW_SOFTKEYS_SL);
       
   462         cba->MakeCommandVisible( EGSXDMPluginCmdChange, ETrue);
       
   463         }
       
   464     cba->DrawNow();
       
   465     }
   364     }
   466     
   365     
   467 // End of file
   366 // End of file
   468 
   367 
   469 
   368