vpnui/vpnmanagementui/src/vpnmanagementuiserversettingsview.cpp
changeset 0 33413c0669b9
child 22 9f4e37332ce5
equal deleted inserted replaced
-1:000000000000 0:33413c0669b9
       
     1 /*
       
     2 * Copyright (c) 2003-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: 
       
    15 * Handles commands given through the UI for maintaining information 
       
    16 * of single policy server.
       
    17 *
       
    18 */
       
    19 
       
    20 // INCLUDE FILES
       
    21 #include <AknQueryDialog.h>
       
    22 #include <aknnotewrappers.h>
       
    23 #include <vpnmanagementuirsc.rsg>
       
    24 #include <ErrorUI.h>
       
    25 #include <sysutil.h>
       
    26 #include "vpnuiloader.h" 
       
    27 #include "vpnmanagementuiserversettingsview.h"
       
    28 #include "vpnmanagementuiserversettingscontainer.h" 
       
    29 #include "vpnmanagementui.hrh"
       
    30 
       
    31 #ifdef __SERIES60_HELP
       
    32 #include    <hlplch.h>   // For HlpLauncher 
       
    33 #endif //__SERIES60_HELP
       
    34 
       
    35 /** MSK control Id. */
       
    36 const TInt KVpnMSKControlId = 3;
       
    37 
       
    38 // ================= MEMBER FUNCTIONS =======================
       
    39 
       
    40 // ---------------------------------------------------------
       
    41 // CServerSettingsView::CServerSettingsView(CVpnUiLoader& aLoader)
       
    42 // Constructor
       
    43 // ---------------------------------------------------------
       
    44 //
       
    45 CServerSettingsView::CServerSettingsView( CVpnUiLoader& aLoader )
       
    46     : iLoader( aLoader )
       
    47     {
       
    48 	}
       
    49 
       
    50 // ---------------------------------------------------------
       
    51 // CServerSettingsView::~CServerSettingsView()
       
    52 // Destructor
       
    53 // ---------------------------------------------------------
       
    54 //
       
    55 CServerSettingsView::~CServerSettingsView()
       
    56     {
       
    57     if ( iContainer )
       
    58         {
       
    59         AppUi()->RemoveFromViewStack( *this, iContainer );
       
    60 	    delete iContainer;
       
    61         }
       
    62 	}
       
    63 
       
    64 // ---------------------------------------------------------
       
    65 // CServerSettingsView* CServerSettingsView::NewL(const TRect& /*aRect*/, 
       
    66 //      CVpnUiLoader& aLoader)
       
    67 // ---------------------------------------------------------
       
    68 //
       
    69 CServerSettingsView* CServerSettingsView::NewL(
       
    70     const TRect& /*aRect*/, CVpnUiLoader& aLoader)
       
    71     {
       
    72     CServerSettingsView* self = new (ELeave) CServerSettingsView(aLoader);
       
    73  	CleanupStack::PushL(self);
       
    74     self->ConstructL();
       
    75     CleanupStack::Pop();
       
    76     return self;
       
    77     }
       
    78 
       
    79 // ---------------------------------------------------------
       
    80 // CServerSettingsView* CServerSettingsView::NewLC(const TRect& /*aRect*/, 
       
    81 //	    CVpnUiLoader& aLoader)
       
    82 // ---------------------------------------------------------
       
    83 //
       
    84 CServerSettingsView* CServerSettingsView::NewLC(const TRect& /*aRect*/, 
       
    85     CVpnUiLoader& aLoader)
       
    86     {
       
    87     CServerSettingsView* self = new (ELeave) CServerSettingsView(aLoader);
       
    88     CleanupStack::PushL( self );
       
    89     self->ConstructL();
       
    90     return self;
       
    91     }
       
    92 
       
    93 // ---------------------------------------------------------
       
    94 // CServerSettingsView::ConstructL()
       
    95 // EPOC two-phased constructor
       
    96 // ---------------------------------------------------------
       
    97 //
       
    98 void CServerSettingsView::ConstructL()
       
    99     {
       
   100 	BaseConstructL( R_VPNMANAGEMENTUI_SERVER_PARAMETERS_VIEW );
       
   101 	}
       
   102 
       
   103 
       
   104 // ---------------------------------------------------------
       
   105 // CServerSettingsView::Id() const
       
   106 // Returns Trust view id
       
   107 // ---------------------------------------------------------
       
   108 //
       
   109 TUid CServerSettingsView::Id() const
       
   110     {
       
   111     return KVpnManagementUiParametersViewId;
       
   112     }
       
   113 
       
   114 // ---------------------------------------------------------
       
   115 // CServerSettingsView::HandleCommandL(TInt aCommand)
       
   116 // Handles Softkey and Options list commands
       
   117 // ---------------------------------------------------------
       
   118 //
       
   119 void CServerSettingsView::HandleCommandL( TInt /* aCommand */)
       
   120     {
       
   121     /*** NSSM support is discontinued.
       
   122          Code is kept in comments temporarily because similar UI functionality
       
   123          might be needed for another purpose.
       
   124     TBool ffs(EFalse);
       
   125     switch ( aCommand )
       
   126         {
       
   127         case EAknSoftkeyBack:
       
   128             {            
       
   129             //GET CURRENT ADDRESS
       
   130             ASSERT( iContainer );
       
   131             
       
   132             const TAcuApiServerDetails& serverDetails = iContainer->ServerDetailsL();
       
   133 
       
   134             ffs = iLoader.FFSSpaceBelowCriticalLevelL( ETrue, 0 );
       
   135             if (ffs)
       
   136     	        {
       
   137                 iLoader.iBackFromServerDefinition = ETrue;
       
   138    			    iLoader.ChangeViewL( KChangeViewPrevious );
       
   139 		        }
       
   140             else if(serverDetails.iServerUrl.Length()==0 || serverDetails.iSelection.iId==0)
       
   141                 {
       
   142                 TInt ret = CompleteSettingsL();
       
   143                 if (ret)
       
   144                     {
       
   145                     iLoader.iShowDefineQuery = EFalse;
       
   146                     iLoader.iBackFromServerDefinition = ETrue;
       
   147        			    iLoader.ChangeViewL( KChangeViewPrevious );
       
   148                     }
       
   149                 }
       
   150             else
       
   151                 {
       
   152                 TBool createServer = ETrue;
       
   153                 if(createServer)
       
   154                     {
       
   155                     //Creating a new VPN policy server
       
   156                     if( iContainer->ServerIndex() == -1)
       
   157                         {
       
   158 	                        int aResult = iLoader.AcuApiWrapperL().CreateServer(serverDetails);
       
   159 	                        if (aResult == KErrNone)
       
   160 		                        {
       
   161 		                        //Update iServerList of CAcuApiWrapper 
       
   162 		                        //After that we can call Synchronise server from 
       
   163 		                        //CVpnManagementUiPolicyContainer::ActivateL()
       
   164 		                        
       
   165 		                        iLoader.AcuApiWrapperL().ServerListL();
       
   166 		                        
       
   167 		                        iLoader.iNewServerDefinition = ETrue;
       
   168 		                        }
       
   169 		                    else
       
   170 		                    	{
       
   171 			                    iLoader.iShowDefineQuery = EFalse;
       
   172 			                    iLoader.iBackFromServerDefinition = ETrue;
       
   173 	                    		iLoader.iNewServerDefinition = EFalse;
       
   174 	    	    				createServer = EFalse;
       
   175 
       
   176 						    	CErrorUI* errorUi = CErrorUI::NewLC( *(CCoeEnv::Static()) );
       
   177 						        errorUi->ShowGlobalErrorNoteL( aResult );
       
   178 						        CleanupStack::PopAndDestroy();  // errorUi
       
   179 		                    	}
       
   180                         }
       
   181                     //Editing an existing policy server
       
   182                     else
       
   183                         {
       
   184                         iLoader.AcuApiWrapperL().SaveServerDetails(serverDetails);
       
   185                         }  
       
   186                     }
       
   187 
       
   188 			    iLoader.ChangeViewL( KChangeViewPrevious );
       
   189                 }
       
   190             break;
       
   191             }
       
   192 		case EAknCmdExit:
       
   193 			{
       
   194 			((CAknViewAppUi*)iAvkonAppUi)->HandleCommandL( EAknCmdExit );
       
   195 			break;
       
   196 			}
       
   197         case EVpnUiCmdChange:
       
   198             {
       
   199             ASSERT(iContainer);
       
   200             iContainer->ChangeSettingValueL();
       
   201             break;
       
   202             }
       
   203         #ifdef __SERIES60_HELP
       
   204         case EAknCmdHelp: 
       
   205             {
       
   206             HlpLauncher::LaunchHelpApplicationL( iEikonEnv->WsSession(), 
       
   207                 AppUi()->AppHelpContextL() );
       
   208             break;
       
   209             }
       
   210         #endif //__SERIES60_HELP
       
   211 
       
   212         default:
       
   213             {
       
   214             AppUi()->HandleCommandL( aCommand );
       
   215             break;
       
   216             }
       
   217         } ***/
       
   218     }
       
   219 
       
   220 // ---------------------------------------------------------
       
   221 // CServerSettingsView::HandleClientRectChange()
       
   222 // ---------------------------------------------------------
       
   223 //
       
   224 void CServerSettingsView::HandleClientRectChange()
       
   225     {
       
   226 	if ( iContainer )
       
   227 		{
       
   228 		iContainer->SetRect( ClientRect() );
       
   229 		}
       
   230     }
       
   231 
       
   232 // ---------------------------------------------------------
       
   233 // CServerSettingsView::DoActivateL()
       
   234 // Updates the view when opening it
       
   235 // ---------------------------------------------------------
       
   236 //
       
   237 void CServerSettingsView::DoActivateL(const TVwsViewId& /*aPrevViewId*/, 
       
   238     TUid aCustomMessageId, const TDesC8& /*aCustomMessage*/)
       
   239     {    
       
   240     __ASSERT_DEBUG(iContainer == NULL, User::Invariant());
       
   241             	    
       
   242     // aCustomMessageId contains index of the policy servers listbox
       
   243 	iContainer = CServerSettingsContainer::NewL( iLoader,
       
   244 	    static_cast<TInt> ( aCustomMessageId.iUid ) );
       
   245 	iContainer->SetMopParent( this );
       
   246     	
       
   247     iLoader.PushDefaultNaviPaneL();
       
   248 
       
   249 	((CAknViewAppUi*)iAvkonAppUi)->AddToStackL( *this, iContainer ); 
       
   250 		
       
   251     // Add MiddleSoftKey
       
   252    	CEikButtonGroupContainer* cbaGroup = Cba();
       
   253    	if (cbaGroup)
       
   254     	{
       
   255 	    HBufC* text = StringLoader::LoadLC(R_MSK_CHANGE); 
       
   256    		cbaGroup->AddCommandToStackL(KVpnMSKControlId, EVpnUiCmdChange, text->Des());
       
   257    		CleanupStack::PopAndDestroy(text);
       
   258     	}
       
   259     iContainer->ActivateL();	
       
   260 	}
       
   261 
       
   262 // ---------------------------------------------------------
       
   263 // CServerSettingsView::DoDeactivate()
       
   264 // ---------------------------------------------------------
       
   265 //
       
   266 void CServerSettingsView::DoDeactivate()
       
   267     {
       
   268     if ( iContainer )
       
   269         {
       
   270 		((CAknViewAppUi*)iAvkonAppUi)->RemoveFromViewStack( *this, iContainer );
       
   271 	    
       
   272 	    delete iContainer;
       
   273 		iContainer = NULL;
       
   274 		}
       
   275 	}
       
   276 
       
   277 
       
   278 TInt CServerSettingsView::CompleteSettingsL()
       
   279     {
       
   280     // compulsory field is empty, confirmation query
       
   281     HBufC* temp;
       
   282     temp = StringLoader::LoadLC( R_VPN_QUEST_INCOMPLETE_SERVER_DEF_DELETE );
       
   283     CAknQueryDialog* query = CAknQueryDialog::NewL( CAknQueryDialog::EConfirmationTone );
       
   284     TInt retval = query->ExecuteLD( R_CONFIRMATION_QUERY, *temp );
       
   285     CleanupStack::PopAndDestroy();  // temp
       
   286     return retval;
       
   287     }
       
   288 
       
   289 // End of File
       
   290