sipplugins/sippsipsettingsui/src/sipsettlistsipprofsetview.cpp
changeset 0 307788aac0a8
child 4 dd3853b8dc3f
equal deleted inserted replaced
-1:000000000000 0:307788aac0a8
       
     1 /*
       
     2 * Copyright (c) 2005 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:  The setting view controller
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 // INCLUDE FILES
       
    20 #include    <gssipsettingspluginrsc.rsg> //GUI Resource
       
    21 #include    <uikon.hrh>
       
    22 #include    <aknViewAppUi.h>
       
    23 #include     <aknnotewrappers.h> 
       
    24 #include    <akntitle.h>
       
    25 #include    <hlplch.h>
       
    26 #include    <featmgr.h>
       
    27 #include    <stringloader.h>
       
    28 #include    "sipsettlistsipprofsetview.h"
       
    29 #include    "sipsettlistsipprofsetcontainer.h"
       
    30 #include    "sipsettlistsipprofsetmodel.h"
       
    31 #include    "viewid.h"
       
    32 #include    "sipsettingsplugin.h"
       
    33 #include    "gssippluginlogger.h"
       
    34 
       
    35 // CONSTANTS
       
    36 const TInt KStartIndex = 0;
       
    37 const TInt KProxyServerIndex = 8;      
       
    38 const TInt KRegistrarServerIndex = 9;
       
    39 
       
    40 // ============================ MEMBER FUNCTIONS ===============================
       
    41 
       
    42 // -----------------------------------------------------------------------------
       
    43 // CSIPSettListSIPProfSetView::CSIPSettListSIPProfSetView
       
    44 // C++ default constructor can NOT contain any code, that
       
    45 // might leave.
       
    46 // -----------------------------------------------------------------------------
       
    47 //
       
    48 CSIPSettListSIPProfSetView::CSIPSettListSIPProfSetView( 
       
    49     MGSSIPProfileHandler* aHandler ) :
       
    50     iView( NULL ),
       
    51     iHandler( aHandler )
       
    52     {
       
    53     __GSLOGSTRING("CSIPSettListSIPProfSetView::CSIPSettListSIPProfSetView" )
       
    54     }
       
    55 
       
    56 // -----------------------------------------------------------------------------
       
    57 // CSIPSettListSIPProfSetView::ConstructL
       
    58 // Symbian 2nd phase constructor can leave.
       
    59 // -----------------------------------------------------------------------------
       
    60 //
       
    61 void CSIPSettListSIPProfSetView::ConstructL()
       
    62     {   
       
    63     __GSLOGSTRING("CSIPSettListSIPProfSetView::ConstructL" )
       
    64     BaseConstructL( R_GS_SIP_PROFILE_SETTING_VIEW );
       
    65     }
       
    66 
       
    67 // -----------------------------------------------------------------------------
       
    68 // CSIPSettListSIPProfSetView::NewLC
       
    69 // Two-phased constructor.
       
    70 // -----------------------------------------------------------------------------
       
    71 //
       
    72 CSIPSettListSIPProfSetView* CSIPSettListSIPProfSetView::NewLC(
       
    73     MGSSIPProfileHandler* aHandler )
       
    74     {
       
    75     __GSLOGSTRING("CSIPSettListSIPProfSetView::NewLC" )
       
    76     CSIPSettListSIPProfSetView* self = 
       
    77         new ( ELeave ) CSIPSettListSIPProfSetView( aHandler );
       
    78     
       
    79     CleanupStack::PushL( self );
       
    80     self->ConstructL();    
       
    81 
       
    82     return self;
       
    83     }
       
    84 
       
    85     
       
    86 // Destructor
       
    87 CSIPSettListSIPProfSetView::~CSIPSettListSIPProfSetView()
       
    88     {
       
    89     __GSLOGSTRING("CSIPSettListSIPProfSetView::~CSIPSettListSIPProfSetView" )
       
    90     if ( iView )
       
    91         {
       
    92         AppUi()->RemoveFromViewStack( *this, iView );
       
    93         delete iView;
       
    94         }
       
    95 
       
    96     delete iModel;
       
    97     }
       
    98 
       
    99 // -----------------------------------------------------------------------------
       
   100 // CSIPSettListSIPProfSetView::Id
       
   101 // Returns the UID of the view
       
   102 // -----------------------------------------------------------------------------
       
   103 //
       
   104 TUid CSIPSettListSIPProfSetView::Id() const
       
   105     {    
       
   106     return KSettListSIPProfileSettingView;
       
   107     }
       
   108 
       
   109 // -----------------------------------------------------------------------------
       
   110 // CSIPSettListSIPProfSetView::BackToListViewL()
       
   111 // Returns back to the list view
       
   112 // -----------------------------------------------------------------------------
       
   113 //
       
   114 void CSIPSettListSIPProfSetView::BackToListViewL()
       
   115     {
       
   116     __GSLOGSTRING("CSIPSettListSIPProfSetView::BackToListViewL" )
       
   117     iView->StoreSettingsL();
       
   118     
       
   119     // Save profile.
       
   120     TRAPD( err, iModel->SaveProfileL() );
       
   121     
       
   122     if( err == KErrNone || err == KErrDiskFull )
       
   123         {
       
   124         AppUi()->ActivateLocalViewL( iPrevViewId.iViewUid );
       
   125         }
       
   126     else
       
   127         {
       
   128         User::LeaveIfError( err ); 
       
   129         }
       
   130     }
       
   131 
       
   132 // -----------------------------------------------------------------------------
       
   133 // CSIPSettListSIPProfSetView::SaveAllSettings
       
   134 // Saves new settings
       
   135 // -----------------------------------------------------------------------------
       
   136 //
       
   137 TInt CSIPSettListSIPProfSetView::SaveAllSettings()
       
   138     {
       
   139     __GSLOGSTRING("CSIPSettListSIPProfSetView::SaveAllSettings" )
       
   140     TRAPD( err, iView->StoreSettingsL(); iModel->SaveProfileL() );
       
   141     return err;
       
   142     }         
       
   143 
       
   144 // -----------------------------------------------------------------------------
       
   145 // CSIPSettListSIPProfSetView::ChangeSettingL
       
   146 // Edits active item
       
   147 // -----------------------------------------------------------------------------
       
   148 //
       
   149 void CSIPSettListSIPProfSetView::ChangeSettingL( TInt aCommand )
       
   150     {
       
   151     iView->EditCurrentListItemL( aCommand );        
       
   152     }
       
   153 
       
   154 // -----------------------------------------------------------------------------
       
   155 // CSIPSettListSIPProfSetView::HandleCommandL
       
   156 // Handles the user interaction
       
   157 // -----------------------------------------------------------------------------
       
   158 //
       
   159 void CSIPSettListSIPProfSetView::HandleCommandL( 
       
   160     TInt aCommand )
       
   161     {
       
   162     __GSLOGSTRING1("CSIPSettListSIPProfSetView::HandleCommandL aCommand: %d", aCommand)
       
   163     switch ( aCommand )
       
   164         {   
       
   165         // "Change" menu item ( same as "select" key press )
       
   166         case EGSMSKCmdAppChange:
       
   167         case EGSCmdAppChange:
       
   168             // Simulate key press
       
   169             ChangeSettingL( aCommand );
       
   170             break;
       
   171 
       
   172         // Saves settings (if modified) and returns to main view
       
   173         case EAknSoftkeyBack:
       
   174             BackToListViewL();
       
   175             break;
       
   176 
       
   177         case EGSCmdUpdateList:
       
   178             // Nothing to update, just here to prevent infinite loop
       
   179             break;
       
   180         
       
   181         // "Exit"
       
   182         case EEikCmdExit:
       
   183         case EAknCmdExit:
       
   184         case EAknSoftkeyExit:
       
   185             {
       
   186             TInt err = SaveAllSettings();
       
   187             if ( err == KErrNone || err == KErrDiskFull )
       
   188                 {
       
   189                 // Propagate the exit message to appui
       
   190                 AppUi()->HandleCommandL( aCommand );
       
   191                 }
       
   192             else
       
   193                 {
       
   194                 User::Leave( err );
       
   195                 }
       
   196             }
       
   197             break;
       
   198 
       
   199         case EAknCmdHelp:
       
   200             {
       
   201             if( FeatureManager::FeatureSupported( KFeatureIdHelp ) )
       
   202                 {
       
   203                 HlpLauncher::LaunchHelpApplicationL(
       
   204                     iEikonEnv->WsSession(), AppUi()->AppHelpContextL() );
       
   205                 }
       
   206             }
       
   207             break;
       
   208 
       
   209         default:
       
   210             AppUi()->HandleCommandL( aCommand );
       
   211             break;
       
   212         }
       
   213     }
       
   214 
       
   215 // -----------------------------------------------------------------------------
       
   216 // CSIPSettListSIPProfSetView::DoActivateL()
       
   217 // Activates the view, creates View and Model
       
   218 // -----------------------------------------------------------------------------
       
   219 //
       
   220 void CSIPSettListSIPProfSetView::DoActivateL( 
       
   221     const TVwsViewId& aPrevViewId,
       
   222     TUid /*aCustomMessageId*/, 
       
   223     const TDesC8& /*aCustomMessage*/ )
       
   224     {
       
   225     __GSLOGSTRING("CSIPSettListSIPProfSetView::DoActivateL " )
       
   226     __GSLOGSTRING("[GSSIPSettingsPlugin] CSIPSettListSIPProfSetView::DoActivateL()" )
       
   227     __GSLOGSTRING1("[GSSIPSettingsPlugin] Previous vied id: %d", aPrevViewId.iViewUid.iUid)
       
   228 
       
   229     if ( aPrevViewId.iViewUid == KGSSIPSettingsPluginUID )
       
   230         {
       
   231         iPrevViewId = aPrevViewId;
       
   232         }
       
   233 
       
   234     CEikStatusPane* sp = StatusPane();
       
   235     CAknTitlePane* title = static_cast<CAknTitlePane*>( 
       
   236         sp->ControlL( TUid::Uid( EEikStatusPaneUidTitle ) ) );
       
   237 
       
   238     int index = KStartIndex;
       
   239 
       
   240     if ( aPrevViewId.iViewUid == KSettListSIPProxyServerView )
       
   241         {
       
   242         index = KProxyServerIndex;
       
   243         }
       
   244     else if ( aPrevViewId.iViewUid == KSettListSIPRegistrarServerView )
       
   245         {
       
   246         index = KRegistrarServerIndex;
       
   247         }
       
   248     else
       
   249         {
       
   250         // Coming from Profile List view
       
   251         }
       
   252 
       
   253     iModel = CSIPSettListSIPProfSetModel::NewL( iHandler );
       
   254     iView = CSIPSettListSIPProfSetContainer::NewL(
       
   255         index, title, this, ClientRect(), *iModel );
       
   256     AppUi()->AddToViewStackL( *this, iView );
       
   257 
       
   258     // Change the text on the title pane
       
   259     HBufC* titleBuf = iModel->ProviderNameLC();    
       
   260     title->SetTextL( *titleBuf );
       
   261 
       
   262     CleanupStack::PopAndDestroy( titleBuf );
       
   263     }
       
   264         
       
   265 // -----------------------------------------------------------------------------
       
   266 // CSIPSettListSIPProfSetView::DoDeactivate()
       
   267 // Deactivates the view
       
   268 // -----------------------------------------------------------------------------
       
   269 //
       
   270 void CSIPSettListSIPProfSetView::DoDeactivate()
       
   271     {
       
   272     __GSLOGSTRING( "[GSSIPSettingsPlugin] CSIPSettListSIPProfSetView::DoDeactivate()" )
       
   273     AppUi()->RemoveFromViewStack( *this, iView );
       
   274     delete iView;
       
   275     iView = NULL;
       
   276 
       
   277     delete iModel;
       
   278     iModel = NULL;
       
   279     }
       
   280 
       
   281 // -----------------------------------------------------------------------------
       
   282 // CSIPSettListSIPProfSetView::DynInitMenuPaneL
       
   283 // Initializes the menu dynamically before it is shown to the user
       
   284 // -----------------------------------------------------------------------------
       
   285 //
       
   286 void CSIPSettListSIPProfSetView::DynInitMenuPaneL( 
       
   287     TInt aResourceId,
       
   288     CEikMenuPane* aMenuPane )
       
   289     {    
       
   290     __GSLOGSTRING("CSIPSettListSIPProfSetView::DynInitMenuPaneL" )      
       
   291     // Delete Help item if feature is not supported
       
   292     if( aResourceId == R_GS_SIP_PROFILE_SETTING_VIEW_MENU ) 
       
   293         {
       
   294         // iView might be NULL
       
   295         if( iView && iView->IfPointerEvent() )
       
   296             {
       
   297             aMenuPane->SetItemDimmed( EGSCmdAppChange, ETrue );
       
   298             }
       
   299         if( !FeatureManager::FeatureSupported( KFeatureIdHelp ) )
       
   300             {
       
   301             aMenuPane->DeleteMenuItem( EAknCmdHelp );
       
   302             }
       
   303         }  
       
   304     }
       
   305         
       
   306 //  End of File