mediasettings/mediasettingsapp/src/MPSettingsAppUi.cpp
branchRCL_3
changeset 8 ce5ada96ab30
parent 1 6711b85517b7
child 11 8970fbd719ec
equal deleted inserted replaced
6:7d91903f795f 8:ce5ada96ab30
    13 *
    13 *
    14 * Description:   Application UI class required by AVKON application architecture.*
    14 * Description:   Application UI class required by AVKON application architecture.*
    15 */
    15 */
    16 
    16 
    17 
    17 
    18 // Version : %version: 9 %
    18 // Version : %version: 11 %
    19 
    19 
    20 
    20 
    21 
    21 
    22 // INCLUDE FILES
    22 // INCLUDE FILES
    23 #include    <MediaSettings.rsg>
    23 #include    <MediaSettings.rsg>
    33 #include    "mediasettings.hrh"
    33 #include    "mediasettings.hrh"
    34 #include    "MPSettingsAppUi.h"
    34 #include    "MPSettingsAppUi.h"
    35 #include    "MPSettingsMainView.h"
    35 #include    "MPSettingsMainView.h"
    36 #include    "MPSettingsVideoView.h"
    36 #include    "MPSettingsVideoView.h"
    37 #include    "MPSettingsStreamingView.h"
    37 #include    "MPSettingsStreamingView.h"
    38 #include    "MPSettingsProxyView.h"
       
    39 #include    "MPSettingsNetworkView.h"
       
    40 #include    "MPSettingsConstants.h"
    38 #include    "MPSettingsConstants.h"
    41 #include    "MPSettingsPluginView.h"
    39 #include    "MPSettingsPluginView.h"
    42 #include    "MPSettingsAdvancedBwView.h"
    40 #include    "MPSettingsAdvancedBwView.h"
    43 #include    "MPSettingsDocument.h"    
    41 #include    "MPSettingsDocument.h"    
    44 #include    "mpsettingsmodel.h"
    42 #include    "mpsettingsmodel.h"
    45 #include    "MPSettingsModelForROP.h"
    43 #include    "MPSettingsModelForROP.h"
    46 #include    "mpxlog.h"
    44 #include    "mpxlog.h"
    47 #include    "feedsettingsview.h"
    45 
       
    46 #include    <centralrepository.h>
       
    47 #include    "MediaPlayerPrivateCRKeys.h"
       
    48 #include    "MediaPlayerVariant.hrh" 
    48 
    49 
    49 // CONSTANTS
    50 // CONSTANTS
    50 const TInt KMPSettViewIdArrayGranularity = 3;
    51 const TInt KMPSettViewIdArrayGranularity = 2;
    51 
    52 
    52 // ================= MEMBER FUNCTIONS =======================
    53 // ================= MEMBER FUNCTIONS =======================
    53 //
    54 //
    54 
    55 
    55 // -----------------------------------------------------------------------------
    56 // -----------------------------------------------------------------------------
    56 // CMPSettingsAppUi::CMPSettingsAppUi
    57 // CMPSettingsAppUi::CMPSettingsAppUi
    57 // C++ default constructor can NOT contain any code, that
    58 // C++ default constructor can NOT contain any code, that
    58 // might leave.
    59 // might leave.
    59 // -----------------------------------------------------------------------------
    60 // -----------------------------------------------------------------------------
    60 //
    61 //
    61 CMPSettingsAppUi::CMPSettingsAppUi() : iConstructAsGsPlugin(EFalse)
    62 CMPSettingsAppUi::CMPSettingsAppUi()
    62     {
    63     {
    63     MPX_DEBUG1(_L("#MS# CMPSettingsAppUi::CMPSettingsAppUi()"));
    64     MPX_DEBUG1(_L("#MS# CMPSettingsAppUi::CMPSettingsAppUi()"));
    64     }
    65     }
    65 
    66 
    66 // ----------------------------------------------------------
    67 // ----------------------------------------------------------
    75     BaseConstructL( EAknEnableSkin | EAknEnableMSK | EAknSingleClickCompatible ); 
    76     BaseConstructL( EAknEnableSkin | EAknEnableMSK | EAknSingleClickCompatible ); 
    76 
    77 
    77     // Sets up TLS, must be done before FeatureManager is used.
    78     // Sets up TLS, must be done before FeatureManager is used.
    78     FeatureManager::InitializeLibL();   
    79     FeatureManager::InitializeLibL();   
    79 
    80 
    80     CMPSettingsDocument* doc = static_cast<CMPSettingsDocument*>(static_cast<CEikAppUi*>
    81     iVideoViewAvailable =  VideoContrastIsSupportedL();
    81         (CEikonEnv::Static()->AppUi())->Document());
    82     
       
    83     CMPSettingsDocument* doc = static_cast<CMPSettingsDocument*>( Document() );
    82     iModel = doc->SettingsModel();
    84     iModel = doc->SettingsModel();
    83     iRopModel = static_cast<CMPSettingsModelForROP*>(iModel);
    85     iRopModel = static_cast<CMPSettingsModelForROP*>(iModel);
    84 
    86 
    85     // Fetch pointer to the default navi pane control
    87     // Fetch pointer to the default navi pane control
    86     CEikStatusPane* sp = StatusPane();
    88     CEikStatusPane* sp = StatusPane();
    88         (sp->ControlL(TUid::Uid(EEikStatusPaneUidNavi)));
    90         (sp->ControlL(TUid::Uid(EEikStatusPaneUidNavi)));
    89 
    91 
    90     // Construct navipane tabs 
    92     // Construct navipane tabs 
    91     iDecoratedTabGroup = iNaviPane->CreateTabGroupL(this);
    93     iDecoratedTabGroup = iNaviPane->CreateTabGroupL(this);
    92 
    94 
    93     // Construct tabs
    95     // Construct tabs if we have multiple views
    94     AddTabSettingsGroupL();
    96     if ( iVideoViewAvailable )
       
    97         {
       
    98         AddTabSettingsGroupL();
       
    99         }
    95 
   100 
    96     // Create vector which contains view id's for all setting folders. 
   101     // Create vector which contains view id's for all setting folders. 
    97     iViewIds = new(ELeave) CArrayFixFlat<TUid>(KMPSettViewIdArrayGranularity);
   102     iViewIds = new(ELeave) CArrayFixFlat<TUid>(KMPSettViewIdArrayGranularity);
    98     iViewIds->AppendL(KMPSettVideoViewId);
   103     if ( iVideoViewAvailable )
    99     iViewIds->AppendL(KMPSettStreamingViewId);
   104         {
   100     iViewIds->AppendL(KMPSettFeedsViewId);
   105         iViewIds->AppendL( KMPSettVideoViewId );
   101 
   106         }
   102     // * Create application views *
   107     iViewIds->AppendL( KMPSettStreamingViewId );
   103 
   108 
       
   109     // Create application views
   104     CAknView* view;  
   110     CAknView* view;  
   105 
   111     view = CMPSettingsMainView::NewLC( iViewIds, iRopModel, EFalse );
   106     view = CMPSettingsMainView::NewLC(iViewIds,iRopModel,iConstructAsGsPlugin);
       
   107     AddViewL(view);      // transfer ownership to CAknViewAppUi
   112     AddViewL(view);      // transfer ownership to CAknViewAppUi
   108     CleanupStack::Pop();    // view
   113     CleanupStack::Pop(); // view
   109 
   114 
   110     // iMainView is not owned, i.e. it is not deleted in the destructor ->
   115     // iMainView is not owned, i.e. it is not deleted in the destructor ->
   111     // main view cannot be directly creted to iMainView, as it's against the coding
   116     // main view cannot be directly creted to iMainView, as it's against the coding
   112     // conventions to place class' pointers to cleanup stack => static_cast.
   117     // conventions to place class' pointers to cleanup stack => static_cast.
   113     iMainView = static_cast<CMPSettingsMainView*>(view);
   118     iMainView = static_cast<CMPSettingsMainView*>(view);
   114 
   119 
   115     view = CMPSettingsVideoView::NewLC(iRopModel);
   120     if ( iVideoViewAvailable )
       
   121         {
       
   122         view = CMPSettingsVideoView::NewLC(iRopModel);
       
   123         AddViewL(view);      // transfer ownership to CAknViewAppUi
       
   124         CleanupStack::Pop(); // view
       
   125         }
       
   126     
       
   127     CMPSettingsStreamingView* streamingView = CMPSettingsStreamingView::NewLC(iRopModel);
       
   128     view = streamingView;
   116     AddViewL(view);      // transfer ownership to CAknViewAppUi
   129     AddViewL(view);      // transfer ownership to CAknViewAppUi
   117     CleanupStack::Pop();    // view
   130     CleanupStack::Pop(); // view 
   118 
   131 
   119     view = CMPSettingsStreamingView::NewLC(iRopModel);
   132     view = CMPSettingsAdvancedBwView::NewLC( iRopModel, EFalse );
   120     AddViewL(view);      // transfer ownership to CAknViewAppUi
   133     AddViewL(view);      // transfer ownership to CAknViewAppUi
   121     CleanupStack::Pop();    // view 
   134     CleanupStack::Pop(); // view 
   122 
       
   123     view = CVcxNsSettingsView::NewLC();
       
   124     AddViewL(view);      // transfer ownership to CAknViewAppUi
       
   125     CleanupStack::Pop();    // view 
       
   126     
       
   127     view = CMPSettingsProxyView::NewLC(iRopModel,iConstructAsGsPlugin);
       
   128     AddViewL(view);      // transfer ownership to CAknViewAppUi
       
   129     CleanupStack::Pop();    // view 
       
   130 
       
   131     view = CMPSettingsNetworkView::NewLC(iRopModel,iConstructAsGsPlugin);
       
   132     AddViewL(view);      // transfer ownership to CAknViewAppUi
       
   133     CleanupStack::Pop();    // view 
       
   134 
       
   135     view = CMPSettingsAdvancedBwView::NewLC(iRopModel,iConstructAsGsPlugin);
       
   136     AddViewL(view);      // transfer ownership to CAknViewAppUi
       
   137     CleanupStack::Pop();    // view 
       
   138 
       
   139 
   135 
   140     // Construct plug-in views (if any exists)
   136     // Construct plug-in views (if any exists)
   141     CMPSettingsPluginView::ListImplementationsL(iImplInfoArray);
   137     CMPSettingsPluginView::ListImplementationsL(iImplInfoArray);
   142     TInt count = iImplInfoArray.Count();
   138     TInt count = iImplInfoArray.Count();
   143 
   139 
   162         // Sort UID array to rising order
   158         // Sort UID array to rising order
   163         TKeyArrayFix sortKey(0, ECmpTUint);
   159         TKeyArrayFix sortKey(0, ECmpTUint);
   164         User::LeaveIfError(iViewIds->Sort(sortKey));
   160         User::LeaveIfError(iViewIds->Sort(sortKey));
   165         }
   161         }
   166  
   162  
   167     SetDefaultViewL(*iMainView);
   163     if ( iVideoViewAvailable && iMainView )
       
   164         {    
       
   165         SetDefaultViewL(*iMainView);
       
   166         }
       
   167     else if ( streamingView )
       
   168         {
       
   169         SetDefaultViewL(*streamingView);
       
   170         }
   168     }
   171     }
   169 
   172 
   170 // ----------------------------------------------------
   173 // ----------------------------------------------------
   171 // CMPSettingsAppUi::~CMPSettingsAppUi
   174 // CMPSettingsAppUi::~CMPSettingsAppUi
   172 // Destructor
   175 // Destructor
   174 // ----------------------------------------------------
   177 // ----------------------------------------------------
   175 //
   178 //
   176 CMPSettingsAppUi::~CMPSettingsAppUi()
   179 CMPSettingsAppUi::~CMPSettingsAppUi()
   177     {
   180     {
   178     MPX_DEBUG1(_L("#MS# CMPSettingsAppUi::~CMPSettingsAppUi()"));
   181     MPX_DEBUG1(_L("#MS# CMPSettingsAppUi::~CMPSettingsAppUi()"));
   179     if (iDecoratedTabGroup) 
   182 
   180         {
   183     delete iDecoratedTabGroup;
   181         delete iDecoratedTabGroup;
       
   182         }
       
   183 
   184 
   184     if (iDoorObserver)
   185     if (iDoorObserver)
   185         {
   186         {
   186         iDoorObserver->NotifyExit(MApaEmbeddedDocObserver::EEmpty);
   187         iDoorObserver->NotifyExit(MApaEmbeddedDocObserver::EEmpty);
   187         }
   188         }
   188 
   189 
   189     if (iViewIds) 
   190     delete iViewIds;
   190         {
       
   191         delete iViewIds;
       
   192         }
       
   193 
   191 
   194     iImplInfoArray.ResetAndDestroy();
   192     iImplInfoArray.ResetAndDestroy();
   195     FeatureManager::UnInitializeLib();
   193     FeatureManager::UnInitializeLib();
   196     }
   194     }
   197 
   195 
   231         {
   229         {
   232         AddTabSettingsGroupL();
   230         AddTabSettingsGroupL();
   233         }
   231         }
   234     }
   232     }
   235  
   233  
   236 
       
   237 // ----------------------------------------------------
   234 // ----------------------------------------------------
   238 // CMPSettingsAppUi::TabChangedL
   235 // CMPSettingsAppUi::TabChangedL
   239 // MAknTabObserver callback for handling tab changed event.
   236 // MAknTabObserver callback for handling tab changed event.
   240 // ----------------------------------------------------
   237 // ----------------------------------------------------
   241 //
   238 //
   272 // ----------------------------------------------------
   269 // ----------------------------------------------------
   273 //
   270 //
   274 void CMPSettingsAppUi::UpdateTabIndex()
   271 void CMPSettingsAppUi::UpdateTabIndex()
   275     {
   272     {
   276     MPX_DEBUG1(_L("#MS# CMPSettingsAppUi::UpdateTabIndex()"));
   273     MPX_DEBUG1(_L("#MS# CMPSettingsAppUi::UpdateTabIndex()"));
   277     iTabGroup->SetActiveTabByIndex(iMainView->ActiveFolder());
   274     if ( iTabGroup )
       
   275         {
       
   276         iTabGroup->SetActiveTabByIndex( iMainView->ActiveFolder() );
       
   277         }
   278     }
   278     }
   279 
   279 
   280 // ------------------------------------------------------------------------------
   280 // ------------------------------------------------------------------------------
   281 // CMPSettingsAppUi::DynInitMenuPaneL
   281 // CMPSettingsAppUi::DynInitMenuPaneL
   282 //  This function is called by the AVKON framework just before it displays
   282 //  This function is called by the AVKON framework just before it displays
   307         }
   307         }
   308 
   308 
   309     return iTabGroup->OfferKeyEventL(aKeyEvent, aType);
   309     return iTabGroup->OfferKeyEventL(aKeyEvent, aType);
   310     }
   310     }
   311 
   311 
   312 
       
   313 // ----------------------------------------------------
   312 // ----------------------------------------------------
   314 // CMPSettingsAppUi::AddTabSettingsGroupL()
   313 // CMPSettingsAppUi::AddTabSettingsGroupL()
   315 // (Re)create tab group with skin support
   314 // (Re)create tab group with skin support
   316 // ----------------------------------------------------
   315 // ----------------------------------------------------
   317 //
   316 //
   329         }
   328         }
   330 
   329 
   331     iTabGroup = static_cast<CAknTabGroup*>
   330     iTabGroup = static_cast<CAknTabGroup*>
   332         (iDecoratedTabGroup->DecoratedControl());
   331         (iDecoratedTabGroup->DecoratedControl());
   333 
   332 
   334     iTabGroup->SetTabFixedWidthL(KTabWidthWithThreeTabs);
   333     iTabGroup->SetTabFixedWidthL(KTabWidthWithTwoTabs);
   335 
   334 
   336     HBufC* mbmpath = StringLoader::LoadLC(R_MPSETT_ICON_MBM_FILE);
   335     HBufC* mbmpath = StringLoader::LoadLC(R_MPSETT_ICON_MBM_FILE);
   337 
   336 
   338     // This is done to ensure upgraded file is used first. 
   337     // This is done to ensure upgraded file is used first. 
   339     // If no upgraded file is found, default file in Z: drive will be used.
   338     // If no upgraded file is found, default file in Z: drive will be used.
   359     AddTabSettingsL(KAknsIIDQgnPropSetMpStreamTab3,
   358     AddTabSettingsL(KAknsIIDQgnPropSetMpStreamTab3,
   360         fileName,
   359         fileName,
   361         EMbmMediasettingsQgn_prop_set_mp_stream_tab2,
   360         EMbmMediasettingsQgn_prop_set_mp_stream_tab2,
   362         EMbmMediasettingsQgn_prop_set_mp_stream_tab2_mask,
   361         EMbmMediasettingsQgn_prop_set_mp_stream_tab2_mask,
   363         EMPViewStreamTab);
   362         EMPViewStreamTab);
   364 
       
   365     AddTabSettingsL(KAknsIIDQgnPropSetMpStreamTab3,
       
   366         fileName,
       
   367         EMbmMediasettingsQgn_prop_set_mp_video_tab3,
       
   368         EMbmMediasettingsQgn_prop_set_mp_video_tab3_mask,
       
   369         EMPViewFeedsTab);
       
   370     
   363     
   371     CleanupStack::PopAndDestroy();  // mbmpath
   364     CleanupStack::PopAndDestroy();  // mbmpath
   372 
   365 
   373     // return to previous view & update correct tab index
   366     // return to previous view & update correct tab index
   374     if (iPushed) 
   367     if (iPushed) 
   409     iTabGroup->AddTabL(aTabId, bitmap, mask);
   402     iTabGroup->AddTabL(aTabId, bitmap, mask);
   410     
   403     
   411     CleanupStack::Pop(2); // bitmap, mask
   404     CleanupStack::Pop(2); // bitmap, mask
   412     }
   405     }
   413 
   406 
       
   407 // ----------------------------------------------------
       
   408 // CMPSettingsAppUi::ActivateLocalViewL
       
   409 // ----------------------------------------------------
       
   410 //
       
   411 void CMPSettingsAppUi::ActivateLocalViewL( TUid aViewId )
       
   412     {
       
   413     if ( !iVideoViewAvailable && 
       
   414          aViewId == KMPSettMainViewId )
       
   415         {
       
   416         HandleCommandL( EEikCmdExit );
       
   417         }
       
   418     else 
       
   419         {
       
   420         CAknViewAppUi::ActivateLocalViewL( aViewId );
       
   421         }
       
   422     }
       
   423 
       
   424 // ----------------------------------------------------
       
   425 // CMPSettingsAppUi::VideoContrastIsSupportedL
       
   426 // ----------------------------------------------------
       
   427 //
       
   428 TBool CMPSettingsAppUi::VideoContrastIsSupportedL()
       
   429     {
       
   430     TInt flags = 0;
       
   431 
       
   432     CRepository* repository = CRepository::NewL( KCRUidMediaPlayerFeatures );
       
   433     repository->Get( KMPLocalVariation, flags );
       
   434     delete repository;
       
   435 
       
   436     return ( flags & KMediaPlayerVideoContrast );
       
   437     }
       
   438 
   414 // End of File  
   439 // End of File