vpnui/vpnmanagementui/src/vpnmanagementuiview.cpp
branchRCL_3
changeset 41 e06095241a65
child 46 29c8f9bc68e1
equal deleted inserted replaced
40:473321461bba 41:e06095241a65
       
     1 /*
       
     2 * Copyright (c) 2005-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:   VPN management main view
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 
       
    20 // INCLUDE FILES
       
    21 #include <aknViewAppUi.h>
       
    22 #include <avkon.hrh>
       
    23 #include <vpnmanagementuirsc.rsg>
       
    24 #include <settingsinternalcrkeys.h>
       
    25 #include <centralrepository.h>
       
    26 #include <bautils.h>
       
    27 #include <vpnmanagementui.mbg>
       
    28 #include "vpnmanagementui.hrh"
       
    29 #include "vpnuiloader.h"
       
    30 #include "vpnmanagementuiview.h"
       
    31 #include "vpnmanagementuicontainer.h"
       
    32 #include "vpnmanagementuiviewid.h"
       
    33 #include "log_vpnmanagementui.h"
       
    34 
       
    35 /** MSK control Id. */
       
    36 const TInt KVpnMSKControlId = 3;
       
    37 
       
    38 
       
    39 // ROM folder
       
    40 
       
    41 // Name of the MBM file containing icons
       
    42 _LIT( KFileIcons, "vpnmanagementui.mbm");
       
    43 
       
    44 // Constants
       
    45 enum TVpnUiCommands 
       
    46     {
       
    47     KVpnUiPolicyViewListItemId,
       
    48     KVpnUiServerViewListItemId,
       
    49     KVpnUiLogViewListItemId
       
    50     };
       
    51 
       
    52 // ================= MEMBER FUNCTIONS =======================
       
    53 
       
    54 // ---------------------------------------------------------------------------
       
    55 // CVpnManagementUiView::CVpnManagementUiView()
       
    56 // ---------------------------------------------------------------------------
       
    57 //
       
    58 CVpnManagementUiView::CVpnManagementUiView()
       
    59     {
       
    60     }
       
    61 
       
    62 // ---------------------------------------------------------------------------
       
    63 // CVpnManagementUiView::~CVpnManagementUiView()
       
    64 // Destructor
       
    65 // ---------------------------------------------------------------------------
       
    66 //
       
    67 CVpnManagementUiView::~CVpnManagementUiView()
       
    68     {
       
    69     LOG_("CVpnManagementUiView::~CVpnManagementUiView entered");
       
    70     if ( iContainer )
       
    71         {
       
    72         AppUi()->RemoveFromViewStack(*this, iContainer);
       
    73         delete iContainer;
       
    74         }
       
    75     delete iLoader;
       
    76     LOG_("CVpnManagementUiView::~CVpnManagementUiView() exited");
       
    77     }
       
    78 
       
    79 
       
    80 // ---------------------------------------------------------------------------
       
    81 // CVpnManagementUiView::NewL()
       
    82 // ---------------------------------------------------------------------------
       
    83 //
       
    84 CVpnManagementUiView* CVpnManagementUiView::NewL()
       
    85     {
       
    86     LOG_("CVpnManagementUiView::NewL() entered");
       
    87     CVpnManagementUiView* self = NewLC();
       
    88     CleanupStack::Pop();
       
    89     LOG_("CVpnManagementUiView::NewL() exited");
       
    90     return self;
       
    91     }
       
    92 
       
    93 // ---------------------------------------------------------------------------
       
    94 // CVpnManagementUiView::NewLC()
       
    95 // ---------------------------------------------------------------------------
       
    96 //
       
    97 CVpnManagementUiView* CVpnManagementUiView::NewLC()
       
    98     {
       
    99     LOG_("CVpnManagementUiView::NewLC() entered"); 
       
   100     CVpnManagementUiView* self = new ( ELeave ) CVpnManagementUiView();
       
   101     CleanupStack::PushL( self );
       
   102     self->ConstructL();
       
   103     return self;
       
   104     }
       
   105 
       
   106 
       
   107 // ---------------------------------------------------------------------------
       
   108 // CVpnManagementUiView::ConstructL()
       
   109 // ---------------------------------------------------------------------------
       
   110 //
       
   111 void CVpnManagementUiView::ConstructL()
       
   112     {
       
   113     LOG_("CVpnManagementUiView::ConstructL() entered");
       
   114     iLoader = CVpnUiLoader::NewL(iAvkonViewAppUi->ClientRect(), 
       
   115                 KVpnManagementPluginUid, this );
       
   116     BaseConstructL( R_VPNUI_MANAGEMENT_VIEW );
       
   117     iLoader->ReleaseResource();
       
   118     LOG_("CVpnManagementUiView::ConstructL() exited");
       
   119     }
       
   120 
       
   121 // ---------------------------------------------------------------------------
       
   122 // void CVpnManagementUiView::GetCaptionL( TDes& aCaption ) const
       
   123 // ---------------------------------------------------------------------------
       
   124 void CVpnManagementUiView::GetCaptionL( TDes& aCaption ) const
       
   125     {
       
   126     LOG_("CVpnManagementUiView::GetCaptionL() entered");
       
   127     iLoader->AddResourceFileL();
       
   128     StringLoader::Load( aCaption, R_VPN_MANAGEMENT_TITLE_BUF );
       
   129     iLoader->ReleaseResource();
       
   130     LOG_("CVpnManagementUiView::GetCaptionL() exited");
       
   131     }
       
   132 
       
   133 // ---------------------------------------------------------------------------
       
   134 // TUid CVpnManagementUiView::Id()
       
   135 // ---------------------------------------------------------------------------
       
   136 //
       
   137 TUid CVpnManagementUiView::Id() const
       
   138     {
       
   139     LOG_("CVpnManagementUiView::Id called");
       
   140     return KVpnManagementPluginUid; 
       
   141     }
       
   142 
       
   143 // ---------------------------------------------------------------------------
       
   144 // CVpnManagementUiView::HandleCommandL()
       
   145 // Handles commands directed to this class.
       
   146 // ---------------------------------------------------------------------------
       
   147 //
       
   148 void CVpnManagementUiView::HandleCommandL(TInt aCommand)
       
   149     {   
       
   150     LOG_1("CVpnManagementUiView::HandleCommandL():%d", aCommand);
       
   151     switch ( aCommand )
       
   152         {
       
   153         case EAknSoftkeyBack:
       
   154             {
       
   155             iLoader->ChangeViewL( KChangeViewBack ); 
       
   156             break;
       
   157             }
       
   158         case EAknCmdExit:
       
   159             {
       
   160             ((CAknViewAppUi*)iAvkonAppUi)->HandleCommandL( EAknCmdExit );
       
   161             break;
       
   162             }
       
   163         case EVpnUiCmdOpen:
       
   164             {
       
   165             HandleListBoxSelectionL();
       
   166             break;
       
   167             }
       
   168 
       
   169         #ifdef __SERIES60_HELP
       
   170         case EAknCmdHelp: 
       
   171             {
       
   172             HlpLauncher::LaunchHelpApplicationL(
       
   173                 iEikonEnv->WsSession(), AppUi()->AppHelpContextL() );
       
   174             break;
       
   175             }
       
   176         #endif //__SERIES60_HELP
       
   177 
       
   178         default:
       
   179             {
       
   180             AppUi()->HandleCommandL( aCommand );
       
   181             break;
       
   182             }
       
   183         }
       
   184     }
       
   185        
       
   186 
       
   187 
       
   188 // ---------------------------------------------------------------------------
       
   189 // CVpnManagementUiView::HandleClientRectChange()
       
   190 // ---------------------------------------------------------------------------
       
   191 //
       
   192 void CVpnManagementUiView::HandleClientRectChange()
       
   193     {
       
   194     if ( iContainer )
       
   195         {
       
   196         iContainer->SetRect( ClientRect() );
       
   197         }
       
   198     }
       
   199 
       
   200 // ---------------------------------------------------------------------------
       
   201 // CVpnManagementUiView::DoActivateL()
       
   202 // ---------------------------------------------------------------------------
       
   203 //
       
   204 void CVpnManagementUiView::DoActivateL(
       
   205    const TVwsViewId& aPrevViewId,TUid /*aCustomMessageId*/,
       
   206    const TDesC8& /*aCustomMessage*/)
       
   207     {
       
   208     LOG_("CVpnManagementUiView::DoActivateL() entered");
       
   209     iLoader->AddResourceFileL(ETrue);
       
   210     if ( iLoader->GSViewId().iViewUid.iUid == 0 )
       
   211         {
       
   212         //must be prepared to application switch, so it stores
       
   213         //only the parent view (General Settings Main View)
       
   214         iLoader->SetGSViewId( aPrevViewId );
       
   215         
       
   216         }
       
   217     if ( iContainer )
       
   218         {
       
   219         ((CAknViewAppUi*)iAvkonAppUi)->RemoveFromViewStack( 
       
   220             *this, iContainer );
       
   221         }
       
   222     iContainer = new (ELeave) CVpnManagementUiContainer( 
       
   223         *this, *iLoader );
       
   224 
       
   225     iContainer->SetMopParent( this );
       
   226     iContainer->ConstructL( ClientRect() );
       
   227     iLoader->ActivateTitleL( KViewTitleManagementView );
       
   228     iLoader->PushDefaultNaviPaneL();
       
   229 
       
   230     ((CAknViewAppUi*)iAvkonAppUi)->AddToStackL( *this, iContainer );
       
   231     iContainer->DrawListBoxL( iCurrentItem, iTopItemIndex );
       
   232 
       
   233     //Listbox observer is set here, instead create listbox
       
   234     iContainer->iListBox->SetListBoxObserver(this);
       
   235     
       
   236     // Add MiddleSoftKey
       
   237    	CEikButtonGroupContainer* cbaGroup = Cba();
       
   238    	if (cbaGroup)
       
   239     	{
       
   240 	    HBufC* text = StringLoader::LoadLC(R_MSK_OPEN); 
       
   241    		cbaGroup->AddCommandToStackL(
       
   242    		    KVpnMSKControlId, EVpnUiCmdOpen, text->Des());
       
   243    		CleanupStack::PopAndDestroy(text);
       
   244     	}
       
   245     LOG_("CVpnManagementUiView::DoActivateL() exited");
       
   246     }
       
   247 
       
   248 // ---------------------------------------------------------------------------
       
   249 // CVpnManagementUiView::HandleCommandL()
       
   250 // ---------------------------------------------------------------------------
       
   251 //
       
   252 void CVpnManagementUiView::DoDeactivate()
       
   253     {
       
   254     LOG_("CVpnManagementUiView::DoDeactivate() entered");
       
   255     if ( iContainer )
       
   256         {
       
   257         AppUi()->RemoveFromViewStack( *this, iContainer );
       
   258         
       
   259         delete iContainer;
       
   260     	iContainer = NULL;
       
   261         }
       
   262     LOG_("CVpnManagementUiView::DoDeactivate() exited");
       
   263     }
       
   264 
       
   265 // ---------------------------------------------------------------------------
       
   266 //  CVpnManagementUiView::HandleListBoxEventL
       
   267 // ---------------------------------------------------------------------------
       
   268 
       
   269 void CVpnManagementUiView::HandleListBoxEventL(CEikListBox* /*aListBox*/, 
       
   270     TListBoxEvent aEventType)
       
   271     {
       
   272     switch (aEventType)
       
   273         {
       
   274         case EEventEnterKeyPressed:
       
   275         case EEventItemSingleClicked:
       
   276             HandleListBoxSelectionL();
       
   277             break;
       
   278         default:
       
   279            break;
       
   280         }
       
   281     }
       
   282 
       
   283 // ---------------------------------------------------------------------------
       
   284 // CVpnManagementUiView::HandleListBoxSelectionL()
       
   285 // ---------------------------------------------------------------------------
       
   286 //
       
   287 void CVpnManagementUiView::HandleListBoxSelectionL()
       
   288     {
       
   289     ASSERT(iContainer && iContainer->iListBox && iLoader);
       
   290     iCurrentItem = iContainer->iListBox->CurrentItemIndex();
       
   291     iTopItemIndex = iContainer->iListBox->TopItemIndex();
       
   292        switch (iCurrentItem)
       
   293         {
       
   294         case KVpnUiPolicyViewListItemId:
       
   295             iLoader->ChangeViewL(KChangeViewPolicy);            
       
   296             break;
       
   297 
       
   298         
       
   299         case KVpnUiServerViewListItemId:
       
   300             iLoader->ChangeViewL(KChangeViewServer);
       
   301             break;
       
   302         
       
   303 
       
   304         case KVpnUiLogViewListItemId:
       
   305             iLoader->ChangeViewL(KChangeViewLog);
       
   306             break;
       
   307         
       
   308         default:
       
   309             LOG_("CVpnManagementUiView::HandleListBoxSelectionL default");
       
   310             break;
       
   311         }
       
   312     }
       
   313 
       
   314 
       
   315 
       
   316 void CVpnManagementUiView::NotifySynchroniseServerCompleteL(TInt aResult)
       
   317     {
       
   318     if ( aResult != KErrNone)
       
   319            LOG_1("CVpnManagementUiView::NotifySynchroniseServerCompleteL:%d", aResult);
       
   320     }
       
   321 
       
   322 // ---------------------------------------------------------------------------
       
   323 // CVpnManagementUiView::HasBitmap
       
   324 // ---------------------------------------------------------------------------
       
   325 TBool CVpnManagementUiView::HasBitmap() const
       
   326     {
       
   327     LOG_("CVpnManagementUiView::HasBitmap() called");
       
   328     return EFalse;
       
   329     }
       
   330 
       
   331 // ---------------------------------------------------------------------------
       
   332 // CVpnManagementUiView::GetBitmapL
       
   333 // ---------------------------------------------------------------------------
       
   334 void CVpnManagementUiView::GetBitmapL( CFbsBitmap* /*aBitmap*/, 
       
   335                                      CFbsBitmap* /*aMask*/ ) const
       
   336     {
       
   337     LOG_("CVpnManagementUiView::GetBitmapL() entered");
       
   338     //no bitmap
       
   339     User::Leave( KErrNotFound );
       
   340     LOG_("CVpnManagementUiView::GetBitmapL() exited");
       
   341     }
       
   342     
       
   343 // ---------------------------------------------------------------------------
       
   344 // CVpnManagementUiView::PluginProviderCategory
       
   345 // ---------------------------------------------------------------------------
       
   346 TInt CVpnManagementUiView::PluginProviderCategory() const
       
   347     {
       
   348     LOG_("CVpnManagementUiView::PluginProviderCategory() called");
       
   349     return EGSPluginProviderOEM;
       
   350     }    
       
   351 
       
   352 // ---------------------------------------------------------------------------
       
   353 // CVpnManagementUiView::CreateIconL
       
   354 // ---------------------------------------------------------------------------    
       
   355 CGulIcon* CVpnManagementUiView::CreateIconL( const TUid aIconType )
       
   356     {
       
   357     LOG_("CVpnManagementUiView::CreateIconL() entered");
       
   358     
       
   359     TFileName iconsFileName;
       
   360     TFileName dllName;
       
   361     Dll::FileName(dllName);
       
   362     TBuf<2> drive = dllName.Left(2);
       
   363     iconsFileName.Insert(0, drive);
       
   364         
       
   365 
       
   366     iconsFileName.Append( KDC_APP_BITMAP_DIR );
       
   367     iconsFileName.Append( KFileIcons );
       
   368     
       
   369 	CGulIcon* icon;
       
   370        
       
   371     if( aIconType == KGSIconTypeLbxItem )
       
   372         {
       
   373         icon = AknsUtils::CreateGulIconL(
       
   374         AknsUtils::SkinInstance(), 
       
   375         KAknsIIDQgnPropSetConnVpn, 
       
   376         iconsFileName,
       
   377         EMbmVpnmanagementuiQgn_prop_set_conn_vpn,
       
   378         EMbmVpnmanagementuiQgn_prop_set_conn_vpn_mask );
       
   379         }
       
   380      else
       
   381         {
       
   382         icon = CGSPluginInterface::CreateIconL( aIconType );
       
   383         }
       
   384     LOG_("CVpnManagementUiView::CreateIconL() exited");
       
   385 	return icon;
       
   386 	} 
       
   387 
       
   388 // ---------------------------------------------------------------------------
       
   389 // CVpnManagementUiView::Visible
       
   390 // ---------------------------------------------------------------------------    
       
   391 TBool CVpnManagementUiView::Visible() const
       
   392     {
       
   393     LOG_("CVpnManagementUiView::Visible() entered");
       
   394     TInt vpnSupported( 0 );
       
   395     TInt readError(0);
       
   396     TRAPD(loadError,
       
   397         {        
       
   398         CRepository* repository = CRepository::NewL(KCRUidCommunicationSettings);
       
   399         readError = repository->Get(KSettingsVPNSupported, vpnSupported);
       
   400         delete repository;
       
   401         });
       
   402     LOG_1("CVpnManagementUiView::Visible():%d exited", vpnSupported);
       
   403     return (vpnSupported && !readError && !loadError) ? ETrue : EFalse;
       
   404     }
       
   405 
       
   406 // ---------------------------------------------------------------------------
       
   407 // CVpnManagementUiView::PluginUid
       
   408 // ---------------------------------------------------------------------------    
       
   409 TUid CVpnManagementUiView::PluginUid() const
       
   410     {
       
   411     LOG_("CVpnManagementUiView::PluginUid() called");
       
   412     return KVpnManagementPluginUid;
       
   413     }
       
   414 
       
   415 // End of File
       
   416