homesync/contentmanager/homesyncgsplugin/src/mssettingsview.cpp
branchIOP_Improvements
changeset 40 08b5eae9f9ff
parent 39 6369bfd1b60d
child 41 b4d83ea1d6e2
equal deleted inserted replaced
39:6369bfd1b60d 40:08b5eae9f9ff
     1 /*
       
     2 * Copyright (c) 2009 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:  CMSSettingsView class implementation
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 #include <msgspluginsrc.rsg>
       
    20 #include <hlplch.h>
       
    21 #include <GSFWViewUIDs.h>
       
    22 #include <aknnavide.h>
       
    23 #include <StringLoader.h>
       
    24 #include <msgsplugin.mbg>
       
    25 #include <akntitle.h>
       
    26 
       
    27 #include "cmcommonutils.h"
       
    28 #include "msconstants.h"
       
    29 #include "mssettingitemlist.h"
       
    30 #include "msgspluginuids.h"
       
    31 #include "mssettingsview.h"
       
    32 #include "msengine.h"
       
    33 #include "msdebug.h"
       
    34 
       
    35 // CONSTANTS
       
    36 _LIT( KMediaservantRscFile, "\\resource\\msgspluginsrc.rsc" );
       
    37 _LIT( KMSGSMifFileName, "\\resource\\apps\\msgsplugin.mif" );
       
    38 
       
    39 // --------------------------------------------------------------------------
       
    40 // Two phased constructor.
       
    41 // --------------------------------------------------------------------------
       
    42 //
       
    43 CMSSettingsView* CMSSettingsView::NewL()
       
    44     {
       
    45     LOG(_L("[MediaServant]\t CMSSettingsView::NewL"));
       
    46 
       
    47     CMSSettingsView* self = CMSSettingsView::NewLC();
       
    48     CleanupStack::Pop( self );
       
    49     return self;
       
    50     }
       
    51 
       
    52 // --------------------------------------------------------------------------
       
    53 // Two phased constructor.
       
    54 // --------------------------------------------------------------------------
       
    55 //
       
    56 CMSSettingsView* CMSSettingsView::NewLC()
       
    57     {
       
    58     LOG(_L("[MediaServant]\t CMSSettingsView::NewLC"));
       
    59 
       
    60     CMSSettingsView* self = new ( ELeave ) CMSSettingsView();
       
    61     CleanupStack::PushL( self );
       
    62     self->ConstructL();
       
    63     return self;
       
    64     }
       
    65 	
       
    66 // --------------------------------------------------------------------------
       
    67 // CMSSettingsView::CMSSettingsView()
       
    68 // --------------------------------------------------------------------------
       
    69 //
       
    70 CMSSettingsView::CMSSettingsView()
       
    71     {
       
    72     LOG(_L("[MediaServant]\t CMSSettingsView::CMSSettingsView"));
       
    73     }
       
    74 
       
    75 // --------------------------------------------------------------------------
       
    76 // CMSSettingsView::ConstructL()
       
    77 // --------------------------------------------------------------------------
       
    78 //
       
    79 void CMSSettingsView::ConstructL()
       
    80     {
       
    81     LOG(_L("[MediaServant]\t CMSSettingsView::ConstructL"));
       
    82 
       
    83     iCoeEnv = CEikonEnv::Static();    
       
    84     // Load resource file
       
    85     iResFileOffset = CmCommonUtils::LoadResourceFileL(
       
    86                                         KMediaservantRscFile(),
       
    87                                         *iCoeEnv );
       
    88     
       
    89     BaseConstructL( R_MS_SETTINGS_VIEW );
       
    90     }
       
    91 
       
    92 // --------------------------------------------------------------------------
       
    93 // CMSSettingsView::~CMSSettingsView()
       
    94 // --------------------------------------------------------------------------
       
    95 //
       
    96 CMSSettingsView::~CMSSettingsView()
       
    97     {
       
    98     LOG(_L("[MediaServant]\t CMSMainView::~CMSSettingsView"));
       
    99     
       
   100     ClearCurrentNaviPaneText();
       
   101     
       
   102     if ( iResFileOffset )
       
   103         {
       
   104         iCoeEnv->DeleteResourceFile( iResFileOffset );
       
   105         }
       
   106   
       
   107     DoDeactivate();
       
   108     }
       
   109     
       
   110 // --------------------------------------------------------------------------
       
   111 // TUid CMSSettingsView::Id()
       
   112 // --------------------------------------------------------------------------
       
   113 //
       
   114 TUid CMSSettingsView::Id() const
       
   115     {
       
   116     LOG(_L("[MediaServant]\t CMSSettingsView::Id"));
       
   117 
       
   118     return KMSGSImplementationUid;
       
   119     }
       
   120 
       
   121 // --------------------------------------------------------------------------
       
   122 // CMSSettingsView::HandleCommandL(TInt aCommand)
       
   123 // --------------------------------------------------------------------------
       
   124 //
       
   125 void CMSSettingsView::HandleCommandL( TInt aCommand )
       
   126     {
       
   127     TRACE(Print(_L("[MediaServant]\t CMSSettingsView::\
       
   128 HandleCommandL command = %d"), aCommand ));
       
   129 
       
   130     switch ( aCommand )
       
   131         {
       
   132         case EAknCmdOpen:
       
   133             {
       
   134             iSettingItemList->OpenSelectedListboxItemL();
       
   135             break;
       
   136             }
       
   137         case EAknSoftkeyBack:
       
   138             {
       
   139             TCmServerState state;
       
   140             iSettingItemList->MSEngine()->ServerState( state );
       
   141             if ( state != ECmServerStateIdle )
       
   142                 {
       
   143                 iSettingItemList->MSEngine()->StopOperation();
       
   144                 }            
       
   145 
       
   146             CAknView* activeView = AppUi()->View( KMSMainViewId );
       
   147             CAknView* activeView2 = AppUi()->View( KGSMainViewUid );            
       
   148             
       
   149             if ( activeView )
       
   150                 {                
       
   151                 AppUi()->ActivateLocalViewL( KMSMainViewId );
       
   152                 }
       
   153             else if ( activeView2 )
       
   154                 {
       
   155                 AppUi()->ActivateLocalViewL( KGSAppsPluginUid );
       
   156                 }
       
   157             else
       
   158                 {
       
   159                 LOG(_L("[MediaServant]\t CMSSettingsView::HandleCommandL \
       
   160                 parent view not found"));
       
   161                 }
       
   162             
       
   163             break;
       
   164             }
       
   165         case EAknCmdHelp :
       
   166             {
       
   167             TRAP_IGNORE( HlpLauncher::LaunchHelpApplicationL(
       
   168                         iEikonEnv->WsSession(),
       
   169             iEikonEnv->EikAppUi()->AppHelpContextL() ));
       
   170             break;
       
   171             }
       
   172         default:
       
   173             {
       
   174             AppUi()->HandleCommandL( aCommand );
       
   175             break;
       
   176             }
       
   177         }
       
   178     }
       
   179 
       
   180 // --------------------------------------------------------------------------
       
   181 // CMSSettingsView::DoActivateL(...)
       
   182 // --------------------------------------------------------------------------
       
   183 //
       
   184 void CMSSettingsView::DoActivateL(
       
   185    const TVwsViewId& /*aPrevViewId*/, TUid /*aCustomMessageId*/,
       
   186    const TDesC8& /*aCustomMessage*/ )
       
   187     {
       
   188     LOG(_L("[MediaServant]\t CMSSettingsView::DoActivateL"));
       
   189 
       
   190     // Set title pane text to default
       
   191     SetTitlePaneTextL( R_MS_GS_SETTINGS_VIEW_TITLE );
       
   192 
       
   193     if ( !iSettingItemList )
       
   194         {
       
   195         // create settings screen
       
   196         iSettingItemList = CMSSettingItemList::NewL( R_MS_GENERAL_SETTINGS,
       
   197                                                      *this );
       
   198         iSettingItemList->SetMopParent( this );
       
   199 
       
   200         // now control receives keyboard events
       
   201         AppUi()->AddToStackL( *this, iSettingItemList );
       
   202         iSettingItemList->ActivateL();
       
   203 
       
   204         }
       
   205    }
       
   206 
       
   207 // --------------------------------------------------------------------------
       
   208 // CMSSettingsView::DoDeactivate()
       
   209 // --------------------------------------------------------------------------
       
   210 //
       
   211 void CMSSettingsView::DoDeactivate()
       
   212     {
       
   213     LOG(_L("[MediaServant]\t CMSSettingsView::DoDeactivate"));
       
   214 
       
   215     if ( iSettingItemList )
       
   216         {
       
   217         AppUi()->RemoveFromStack( iSettingItemList );
       
   218         }
       
   219 
       
   220     delete iSettingItemList; // Deletes the container class object.
       
   221     iSettingItemList = NULL;
       
   222     }
       
   223     
       
   224 // --------------------------------------------------------------------------
       
   225 // Method for getting caption of this plugin. 
       
   226 // --------------------------------------------------------------------------
       
   227 //
       
   228 void CMSSettingsView::GetCaptionL( TDes& aCaption ) const
       
   229     {
       
   230     LOG(_L("[MediaServant]\t CMSSettingsView::GetCaptionL"));
       
   231     
       
   232     HBufC* pluginText = StringLoader::LoadLC( R_MS_GS_PLUGIN_TEXT );
       
   233     aCaption.Copy( *pluginText );
       
   234     CleanupStack::PopAndDestroy( pluginText );
       
   235     }
       
   236 
       
   237 // --------------------------------------------------------------------------
       
   238 // Creates a new icon of desired type.
       
   239 // --------------------------------------------------------------------------
       
   240 //
       
   241 CGulIcon* CMSSettingsView::CreateIconL( const TUid /*aIconType*/ )
       
   242     {
       
   243     LOG(_L("[MediaServant]\t CMSSettingsView::CreateIconL"));
       
   244 
       
   245     MAknsSkinInstance* skin = AknsUtils::SkinInstance();
       
   246     TFileName iconsPath( AknIconUtils::AvkonIconFileName() );
       
   247     
       
   248     CFbsBitmap* bitmap = NULL;
       
   249     CFbsBitmap* mask = NULL;
       
   250 
       
   251     AknsUtils::CreateIconLC( skin,
       
   252                              KAknsIIDDefault,
       
   253                              bitmap,
       
   254                              mask,
       
   255                              KMSGSMifFileName,
       
   256                              EMbmMsgspluginQgn_mserv_app_menu_icon,
       
   257                              EMbmMsgspluginQgn_mserv_app_menu_icon_mask );
       
   258 
       
   259     CGulIcon* icon = CGulIcon::NewL(bitmap, mask);
       
   260     CleanupStack::Pop(mask);
       
   261     CleanupStack::Pop(bitmap);
       
   262     bitmap = NULL;
       
   263     mask = NULL;
       
   264 
       
   265     return icon;
       
   266     }
       
   267 
       
   268 // --------------------------------------------------------------------------
       
   269 // CMSSettingsView::SetNavigationPaneTextL()
       
   270 // Sets navigation pane text.
       
   271 // --------------------------------------------------------------------------
       
   272 //
       
   273 void CMSSettingsView::SetNavigationPaneTextL(const TDesC& aText )
       
   274     {
       
   275     LOG(_L("[MediaServant]\t CMSSettingsView::SetNavigationPaneTextL"));
       
   276 
       
   277     // old decorator is popped and deleted
       
   278     ClearCurrentNaviPaneText();
       
   279 
       
   280     if ( !iNaviPane )
       
   281         {
       
   282         iNaviPane = static_cast<CAknNavigationControlContainer*>
       
   283             ( StatusPane()->ControlL( TUid::Uid( EEikStatusPaneUidNavi ) ) );
       
   284                 // ownership of decorator is transfered to application
       
   285         }
       
   286 
       
   287     iNaviDecorator = iNaviPane->CreateNavigationLabelL( aText );
       
   288     iNaviPane->PushL( *iNaviDecorator );
       
   289     }
       
   290 
       
   291 // --------------------------------------------------------------------------
       
   292 // CMSSettingsView::ClearCurrentNaviPaneText()
       
   293 // Clears navi pane text.
       
   294 // --------------------------------------------------------------------------
       
   295 //
       
   296 void CMSSettingsView::ClearCurrentNaviPaneText()
       
   297     {
       
   298     LOG(_L("[MediaServant]\t CMSSettingsView::ClearCurrentNaviPaneText"));
       
   299 
       
   300     if ( iNaviDecorator )
       
   301         {
       
   302         iNaviPane->Pop( iNaviDecorator );
       
   303         delete iNaviDecorator;
       
   304         iNaviDecorator = NULL;
       
   305         }
       
   306     }
       
   307 
       
   308 // --------------------------------------------------------------------------
       
   309 // CMSSettingsView::SetTitlePaneTextL()
       
   310 // Sets text to title pane.
       
   311 // --------------------------------------------------------------------------
       
   312 void CMSSettingsView::SetTitlePaneTextL( TInt aResourceId )
       
   313     {
       
   314     LOG(_L("[MediaServant]\t CMSSettingsView::SetTitlePaneTextL"));
       
   315 
       
   316     // Fetches pointer to the default title pane control.
       
   317     CAknTitlePane* titlePane = static_cast<CAknTitlePane*>(
       
   318         StatusPane()->ControlL( TUid::Uid( EEikStatusPaneUidTitle ) ) );
       
   319 
       
   320     // Makes and sets text which is used title pane.
       
   321     if ( aResourceId == KMSDefaultTitleId )
       
   322         {
       
   323         titlePane->SetTextToDefaultL();
       
   324         }
       
   325     else
       
   326         {
       
   327         TBuf<KMSTitleBufLength> titleText( 0 );
       
   328         iCoeEnv->ReadResourceL( titleText, aResourceId );
       
   329         titlePane->SetTextL( titleText );
       
   330         }
       
   331     }
       
   332 
       
   333 // End of File