vpnui/vpnmanagementui/src/vpnmanagementuilogview.cpp
changeset 0 33413c0669b9
equal deleted inserted replaced
-1:000000000000 0:33413c0669b9
       
     1 /*
       
     2 * Copyright (c) 2003 - 2006 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: Handles commands given through the UI for maintaining policies.
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 
       
    20 // INCLUDE FILES
       
    21 #include <aknmessagequerydialog.h>
       
    22 #include <aknnotewrappers.h>            // for warning & information notes
       
    23 #include <vpnmanagementuirsc.rsg>
       
    24 #include "vpnuiloader.h" 
       
    25 #include "vpnmanagementuilogview.h"
       
    26 #include "vpnmanagementuilogcontainer.h" 
       
    27 #include "vpnmanagementui.hrh"
       
    28 #ifdef __SERIES60_HELP
       
    29 #include    <hlplch.h>   // For HlpLauncher 
       
    30 #endif //__SERIES60_HELP
       
    31 
       
    32 /** MSK control Id. */
       
    33 const TInt KVpnMSKControlId = 3;
       
    34 
       
    35 // ================= MEMBER FUNCTIONS =======================
       
    36 
       
    37 // ---------------------------------------------------------
       
    38 // CVpnManagementUiLogView::CVpnManagementUiLogView(CVpnUiLoader& aLoader)
       
    39 // : iLoader(aLoader)
       
    40 // Constructor
       
    41 // ---------------------------------------------------------
       
    42 //
       
    43 CVpnManagementUiLogView::CVpnManagementUiLogView( CVpnUiLoader& aLoader )
       
    44 : iLoader(aLoader)
       
    45     {
       
    46     }
       
    47 
       
    48 // ---------------------------------------------------------
       
    49 // CVpnManagementUiLogView::~CVpnManagementUiLogView()
       
    50 // Destructor
       
    51 // ---------------------------------------------------------
       
    52 //
       
    53 CVpnManagementUiLogView::~CVpnManagementUiLogView()
       
    54     {
       
    55     if ( iLogContainer )
       
    56         {
       
    57         AppUi()->RemoveFromViewStack(*this, iLogContainer);
       
    58         delete iLogContainer;
       
    59         }
       
    60     }
       
    61 
       
    62 // ---------------------------------------------------------
       
    63 // CVpnManagementUiLogView* CVpnManagementUiLogView::NewL(
       
    64 //      const TRect& /*aRect*/, CVpnUiLoader& aLoader)
       
    65 // ---------------------------------------------------------
       
    66 //
       
    67 CVpnManagementUiLogView* CVpnManagementUiLogView::NewL(
       
    68     const TRect& /*aRect*/, CVpnUiLoader& aLoader )
       
    69     {
       
    70     CVpnManagementUiLogView* self = 
       
    71         new ( ELeave ) CVpnManagementUiLogView( aLoader );
       
    72     CleanupStack::PushL( self );
       
    73     self->ConstructL();
       
    74     CleanupStack::Pop();
       
    75     return self;
       
    76     }
       
    77 
       
    78 // ---------------------------------------------------------
       
    79 // CVpnManagementUiLogView* CVpnManagementUiLogView::NewLC(
       
    80 //  const TRect& /*aRect*/, CVpnUiLoader& aLoader)
       
    81 // ---------------------------------------------------------
       
    82 //
       
    83 CVpnManagementUiLogView* CVpnManagementUiLogView::NewLC(
       
    84     const TRect& /*aRect*/, CVpnUiLoader& aLoader )
       
    85     {
       
    86     CVpnManagementUiLogView* self = 
       
    87         new ( ELeave ) CVpnManagementUiLogView( aLoader );
       
    88     CleanupStack::PushL( self );
       
    89     self->ConstructL();
       
    90     return self;
       
    91     }
       
    92 
       
    93 // ---------------------------------------------------------
       
    94 // CVpnManagementUiLogView::ConstructL()
       
    95 // CVpnUiView::ConstructL(const TRect& aRect)
       
    96 // EPOC two-phased constructor
       
    97 // ---------------------------------------------------------
       
    98 //
       
    99 void CVpnManagementUiLogView::ConstructL() 
       
   100     {
       
   101     BaseConstructL( R_VPNUI_LOG_VIEW );
       
   102     }
       
   103 
       
   104 // ---------------------------------------------------------
       
   105 // CVpnManagementUiLogView::DynInitMenuPaneL(
       
   106 //      TInt aResourceId,CEikMenuPane* aMenuPane)
       
   107 // Updates Options list with correct items depending on 
       
   108 // whether the listbox is empty or if it has any marked items
       
   109 // ---------------------------------------------------------
       
   110 //
       
   111 void CVpnManagementUiLogView::DynInitMenuPaneL(TInt aResourceId, CEikMenuPane* aMenuPane)
       
   112     {
       
   113   
       
   114     if ( aResourceId == R_VPNUI_LOG_VIEW_MENU )
       
   115         {
       
   116         TInt currentItem = iLogContainer->iListBox->CurrentItemIndex();
       
   117 
       
   118         // the VPN log list is empty  all except Refresh, Help and Exit is dimmed
       
   119         if ( currentItem == -1 )
       
   120             {
       
   121             aMenuPane->SetItemDimmed( EVpnUiCmdLogDetails, ETrue );
       
   122             aMenuPane->SetItemDimmed( EVpnUiCmdClearLog, ETrue );
       
   123 //            aMenuPane->SetItemDimmed( EVpnUiCmdRefreshLog, ETrue );
       
   124             }
       
   125 
       
   126         }
       
   127     }
       
   128 
       
   129 // ---------------------------------------------------------
       
   130 // CVpnManagementUiLogView::Id() const
       
   131 // Returns Authority view id
       
   132 // ---------------------------------------------------------
       
   133 //
       
   134 TUid CVpnManagementUiLogView::Id() const
       
   135     {
       
   136     return KVpnManagementUiLogViewId;
       
   137     }
       
   138 
       
   139 // ---------------------------------------------------------
       
   140 // CVpnManagementUiLogView::HandleCommandL(TInt aCommand)
       
   141 // Handles Softkey and Options list commands
       
   142 // ---------------------------------------------------------
       
   143 //
       
   144 void CVpnManagementUiLogView::HandleCommandL( TInt aCommand )
       
   145     {
       
   146     switch ( aCommand )
       
   147         {
       
   148         case EAknSoftkeyBack:
       
   149             {
       
   150             iLoader.ChangeViewL( KChangeViewPrevious );
       
   151             break;
       
   152             }
       
   153         case EAknCmdExit:
       
   154             {
       
   155             ((CAknViewAppUi*)iAvkonAppUi)->HandleCommandL( EAknCmdExit );
       
   156             break;
       
   157             }
       
   158         
       
   159         case EVpnUiCmdRefreshLog:
       
   160             {
       
   161             iLogContainer->ShowLogsL();
       
   162             iLogContainer->DrawListBoxL( iCurrentPosition, iTopItem );
       
   163             break;
       
   164             }
       
   165 
       
   166         case EVpnUiCmdLogDetails:
       
   167             {
       
   168             iLogContainer->LogDetailsL(iLogContainer->iListBox->CurrentItemIndex());
       
   169             break;
       
   170             }
       
   171 
       
   172         case EVpnUiCmdClearLog:
       
   173             {
       
   174             iLogContainer->ClearLogL();
       
   175             break;
       
   176             }
       
   177 #ifdef __SERIES60_HELP
       
   178         case EAknCmdHelp: 
       
   179             {
       
   180             HlpLauncher::LaunchHelpApplicationL(
       
   181                 iEikonEnv->WsSession(), AppUi()->AppHelpContextL() );
       
   182             break;
       
   183             }
       
   184 #endif //__SERIES60_HELP
       
   185 
       
   186         default:
       
   187             {
       
   188             AppUi()->HandleCommandL( aCommand );
       
   189             break;
       
   190             }
       
   191         }
       
   192     }
       
   193 
       
   194 // ---------------------------------------------------------
       
   195 // CVpnManagementUiLogView::HandleClientRectChange()
       
   196 // ---------------------------------------------------------
       
   197 //
       
   198 void CVpnManagementUiLogView::HandleClientRectChange()
       
   199     {
       
   200     if ( iLogContainer )
       
   201         {
       
   202         iLogContainer->SetRect( ClientRect() );
       
   203         }
       
   204     }
       
   205 
       
   206 // ---------------------------------------------------------
       
   207 // CVpnManagementUiLogView::DoActivateL(const TVwsViewId& /*aPrevViewId*/,
       
   208 //      TUid /*aCustomMessageId*/, const TDesC8& /*aCustomMessage*/)
       
   209 // Updates the view when opening it
       
   210 // ---------------------------------------------------------
       
   211 //
       
   212 void CVpnManagementUiLogView::DoActivateL(
       
   213     const TVwsViewId& /*aPrevViewId*/,
       
   214     TUid /*aCustomMessageId*/, const TDesC8& /*aCustomMessage*/)
       
   215     {
       
   216     if ( iLogContainer )
       
   217         {
       
   218         ((CAknViewAppUi*)iAvkonAppUi)->RemoveFromViewStack( 
       
   219             *this, iLogContainer );
       
   220 	    }
       
   221     iLogContainer = new (ELeave) CVpnManagementUiLogContainer( 
       
   222         *this, iLoader );
       
   223 
       
   224     iLogContainer->SetMopParent( this );
       
   225     iLogContainer->ConstructL( ClientRect(), iCurrentPosition );
       
   226     iLoader.ActivateTitleL( KViewTitleLogView );
       
   227  
       
   228     iLoader.ActivateNaviTextL();
       
   229     iLoader.PushNaviPaneL();
       
   230 
       
   231     ((CAknViewAppUi*)iAvkonAppUi)->AddToStackL( *this, iLogContainer );
       
   232     iLogContainer->DrawListBoxL( iCurrentPosition, iTopItem );
       
   233     
       
   234     // Add MiddleSoftKey
       
   235  	SetMiddleSoftKeyL(EFalse);       
       
   236    }
       
   237 
       
   238 
       
   239 void CVpnManagementUiLogView::SetMiddleSoftKeyL(TBool aDrawNow)
       
   240     {
       
   241     if (iLogContainer->iListItemCount > 0)
       
   242     	{ 
       
   243 		SetMiddleSoftKeyLabelL(R_MSK_VPN_DETAILS, EVpnUiCmdLogDetails);
       
   244     	}
       
   245     else
       
   246     	{
       
   247     	SetMiddleSoftKeyLabelL(R_MSK_REFRESH_VPN_LOG, EVpnUiCmdRefreshLog);
       
   248     	}
       
   249 
       
   250     if (aDrawNow)
       
   251     	{
       
   252     	if (Cba())
       
   253     		Cba()->DrawNow();
       
   254     	}
       
   255 	}
       
   256     	
       
   257 
       
   258 void CVpnManagementUiLogView::SetMiddleSoftKeyLabelL(TInt aResourceId, TInt aCommandId)
       
   259     {
       
   260    	CEikButtonGroupContainer* cbaGroup = Cba();
       
   261    	if (cbaGroup)
       
   262     	{
       
   263 			cbaGroup->RemoveCommandFromStack(KVpnMSKControlId, EVpnUiCmdLogDetails);
       
   264 			cbaGroup->RemoveCommandFromStack(KVpnMSKControlId, EVpnUiCmdRefreshLog);
       
   265 		    HBufC* text = StringLoader::LoadLC(aResourceId); 
       
   266     		cbaGroup->AddCommandToStackL(KVpnMSKControlId, aCommandId, text->Des());
       
   267    		CleanupStack::PopAndDestroy(text);
       
   268     	}
       
   269     
       
   270    }
       
   271 
       
   272 // ---------------------------------------------------------
       
   273 // CVpnManagementUiLogView::DoDeactivate()
       
   274 // Saves focus position when closing view
       
   275 // ---------------------------------------------------------
       
   276 //
       
   277 void CVpnManagementUiLogView::DoDeactivate()
       
   278     {
       
   279     if ( iLogContainer )
       
   280         {
       
   281         iLoader.PopNaviPane();
       
   282         AppUi()->RemoveFromViewStack( *this, iLogContainer );
       
   283         
       
   284         delete iLogContainer;
       
   285         iLogContainer = NULL;
       
   286         }
       
   287     }
       
   288 
       
   289 // ---------------------------------------------------------
       
   290 // CVpnManagementUiLogView::Container()
       
   291 // Returns iLogContainer
       
   292 // ---------------------------------------------------------
       
   293 //
       
   294 CCoeControl* CVpnManagementUiLogView::Container()
       
   295     {
       
   296     return iLogContainer;
       
   297     }
       
   298 
       
   299 // End of File
       
   300