vpnui/vpnmanagementui/src/vpnmanagementuipolicycontainer.cpp
branchRCL_3
changeset 38 9f4e37332ce5
parent 0 33413c0669b9
equal deleted inserted replaced
32:352850cbed81 38:9f4e37332ce5
    23 #include <ErrorUI.h>
    23 #include <ErrorUI.h>
    24 #include <vpnmanagementuirsc.rsg>
    24 #include <vpnmanagementuirsc.rsg>
    25 #include "vpnuiloader.h"
    25 #include "vpnuiloader.h"
    26 #include "vpnmanagementuipolicycontainer.h"
    26 #include "vpnmanagementuipolicycontainer.h"
    27 #include "vpnmanagementui.hrh"
    27 #include "vpnmanagementui.hrh"
    28 
    28 #include "vpnextapi.h"
    29 
    29 
    30 #ifdef __SERIES60_HELP
    30 #ifdef __SERIES60_HELP
    31 #include <csxhelp/vpn.hlp.hrh> // for help context of VPN Management UI
    31 #include <csxhelp/vpn.hlp.hrh> // for help context of VPN Management UI
    32 #endif //__SERIES60_HELP
    32 #endif //__SERIES60_HELP
    33 
    33 
    66     {
    66     {
    67 	CreateWindowL();
    67 	CreateWindowL();
    68     CreateListBoxL();
    68     CreateListBoxL();
    69     
    69     
    70     //Initialization
    70     //Initialization
    71     iShowWaitNote = EFalse;
    71 
    72     
    72     
    73     ShowPoliciesL();
    73     ShowPoliciesL();
    74 	SetRect( aRect );
    74 	SetRect( aRect );
    75     }
    75     }
    76 
    76 
    81 // ---------------------------------------------------------
    81 // ---------------------------------------------------------
    82 //
    82 //
    83 void CVpnManagementUiPolicyContainer::ActivateL()
    83 void CVpnManagementUiPolicyContainer::ActivateL()
    84     {
    84     {
    85     CCoeControl::ActivateL();
    85     CCoeControl::ActivateL();
    86     // put empty list checking & required actions here.
    86 
    87     /*** NSSM support is discontinued.
    87     }
    88          Code is kept in comments temporarily because similar UI functionality
    88 
    89          might be needed for another purpose.
    89 
    90     if (!iLoader.iBackFromServerDefinition)
       
    91         {
       
    92         PoliciesListEmptyL();
       
    93         }
       
    94     if (iLoader.iNewServerDefinition)
       
    95         {//Synchronise server query
       
    96             HBufC* temp;
       
    97             temp = StringLoader::LoadLC( R_VPN_QUEST_SYNCHRONISE_SERVER );
       
    98             CAknQueryDialog* query = CAknQueryDialog::NewL( CAknQueryDialog::EConfirmationTone );
       
    99             TInt retval = query->ExecuteLD( R_CONFIRMATION_QUERY, *temp );
       
   100             CleanupStack::PopAndDestroy();  // temp
       
   101             if ( retval )
       
   102                 {
       
   103                 //Show wait dialog
       
   104                 //ShowWaitNoteL(); called now from NotifyStepChangedL
       
   105                 iShowWaitNote = ETrue;
       
   106                 // Get selection neme for connecting via note
       
   107                 // and save it to the member variable of iLoader
       
   108                 iLoader.GetSelectionNameL( iLoader.iSelectionName );
       
   109                 
       
   110                 //Save server index for Connecting via note
       
   111                 iLoader.iCurrentServerIndex = 0;
       
   112                 //Synchronise server
       
   113                 iLoader.AcuApiWrapperL().SynchroniseServerL(0,this);
       
   114    
       
   115                 //Set iNewServerDefinition to false, because 
       
   116                 //we are now synchronised server
       
   117                 iLoader.iNewServerDefinition = EFalse;
       
   118                 }
       
   119         } ***/
       
   120     }
       
   121 
       
   122 void CVpnManagementUiPolicyContainer::PoliciesListEmptyL()
       
   123     {
       
   124     if (iListItemCount == 0)
       
   125         {
       
   126         //Set iNewServerDefinition to false, because
       
   127         //we don't want to show note
       
   128         //"new server defined synchronise now"
       
   129         iLoader.iNewServerDefinition = EFalse;
       
   130         // no policies installed, confirmation query
       
   131         HBufC* temp;
       
   132         temp = StringLoader::LoadLC( R_VPN_QUEST_DL_POLICIES_NOW );
       
   133         CAknQueryDialog* query = CAknQueryDialog::NewL( CAknQueryDialog::EConfirmationTone );
       
   134         TInt retval = query->ExecuteLD( R_CONFIRMATION_QUERY, *temp );
       
   135         CleanupStack::PopAndDestroy();  // temp
       
   136         if ( retval )
       
   137             { // start policy install procedure
       
   138             InstallPoliciesL();
       
   139             }
       
   140         }
       
   141     }
       
   142 
       
   143 void CVpnManagementUiPolicyContainer::InstallPoliciesL()
       
   144     {
       
   145     /*** NSSM support is discontinued.
       
   146          Code is kept in comments temporarily because similar UI functionality
       
   147          might be needed for another purpose.
       
   148     CArrayFix<TAcuApiServerListElem>* serverList = iLoader.AcuApiWrapperL().ServerListL();
       
   149     TInt serverCount = serverList->Count();
       
   150 
       
   151     //if policy servers defined show policy server list query
       
   152     if (serverCount > 0 )
       
   153         {
       
   154         TInt index = 0;
       
   155 	    CDesCArrayFlat *array = new(ELeave) CDesCArrayFlat(1);
       
   156 	    CleanupStack::PushL(array);
       
   157    
       
   158         for (TInt i = 0; i < serverCount; ++i)
       
   159             {
       
   160             TBuf<KAcuMaxServerNameLocalLth+2> serverName;
       
   161             serverName.Append(serverList->At(i).iServerNameLocal);
       
   162             array->AppendL(serverName);
       
   163             }
       
   164 	    CAknListQueryDialog* dlg = new (ELeave) CAknListQueryDialog(&index);
       
   165 	    dlg->PrepareLC( R_LIST_QUERY );
       
   166 	    dlg->SetItemTextArray(array);
       
   167 	    dlg->SetOwnershipType(ELbmDoesNotOwnItemArray);
       
   168 
       
   169 	    TInt queryOk = dlg->RunLD();
       
   170         if(queryOk == EAknSoftkeyOk || queryOk == EAknSoftkeySelect)
       
   171             {
       
   172             TBool selectionExists = iLoader.SelectionExistsL( index );
       
   173             
       
   174             if( selectionExists )
       
   175                 {
       
   176                 //Save server index for Connecting via note
       
   177                 iLoader.iCurrentServerIndex = index;
       
   178                 //Show wait dialog 
       
   179                 iShowWaitNote = ETrue;
       
   180                 // Get selection neme for connecting via note
       
   181                 // and save it to the member variable of iLoader
       
   182                 iLoader.GetSelectionNameL( iLoader.iSelectionName );
       
   183                
       
   184                 iLoader.AcuApiWrapperL().SynchroniseServerL( index, this );
       
   185                 }
       
   186             }
       
   187         CleanupStack::PopAndDestroy(); // array
       
   188 
       
   189         }
       
   190     else
       
   191         { ***/
       
   192         //No policy servers defined show define new policy
       
   193         //server conrirmation query
       
   194         HBufC* temp;
       
   195         temp = StringLoader::LoadLC( R_VPN_QUEST_DEFINE_NEW_SERVER );
       
   196         CAknQueryDialog* query = CAknQueryDialog::NewL( CAknQueryDialog::EConfirmationTone );
       
   197         TInt retval = query->ExecuteLD( R_CONFIRMATION_QUERY, *temp );
       
   198         CleanupStack::PopAndDestroy();  // temp
       
   199         if ( retval )
       
   200             {
       
   201             if (!SysUtil::FFSSpaceBelowCriticalLevelL(0, 0))
       
   202     	        {
       
   203 	            iLoader.iBackFromServerDefinition = ETrue;
       
   204 	            iLoader.ChangeViewL(KChangeViewSettings);
       
   205 	            }
       
   206 	        else
       
   207 		        {
       
   208 		    	CErrorUI* errorUi = CErrorUI::NewLC( *(CCoeEnv::Static()) );
       
   209 		        errorUi->ShowGlobalErrorNoteL( KErrDiskFull );
       
   210 		        CleanupStack::PopAndDestroy();  // errorUi
       
   211 		        }
       
   212             }
       
   213         // }
       
   214     }
       
   215 
       
   216 void CVpnManagementUiPolicyContainer::SynchroniseServerL()
       
   217     {
       
   218 /*NOT USED ANYMORE
       
   219     //Conrirmation query
       
   220     HBufC* temp;
       
   221     temp = StringLoader::LoadLC( R_VPN_QUEST_SYNCHRONISE_SERVER );
       
   222     CAknQueryDialog* query = CAknQueryDialog::NewL( CAknQueryDialog::EConfirmationTone );
       
   223     TInt retval = query->ExecuteLD( R_CONFIRMATION_QUERY, *temp );
       
   224     CleanupStack::PopAndDestroy();  // temp
       
   225     if ( retval )
       
   226         {
       
   227         TInt currentPosition = iListBox->CurrentItemIndex();
       
   228         iLoader.iAcuApiWrapper->SynchroniseServer(currentPosition, this);
       
   229         }
       
   230 */    
       
   231     }
       
   232 // ---------------------------------------------------------
    90 // ---------------------------------------------------------
   233 // CVpnManagementUiPolicyContainer::SizeChanged()
    91 // CVpnManagementUiPolicyContainer::SizeChanged()
   234 // Called by framework when the view size is changed
    92 // Called by framework when the view size is changed
   235 // ---------------------------------------------------------
    93 // ---------------------------------------------------------
   236 //
    94 //
   478         }
   336         }
   479 
   337 
   480 	iListBox->HandleItemAdditionL();
   338 	iListBox->HandleItemAdditionL();
   481     }
   339     }
   482 
   340 
   483 // ---------------------------------------------------------
   341 
   484 // CVpnManagementUiPolicyContainer:::UpdatePolicy
       
   485 // ---------------------------------------------------------
       
   486 //
       
   487 void CVpnManagementUiPolicyContainer::UpdatePolicyL(TVpnPolicyId /* aPolicyId */)
       
   488     {
       
   489     /*** NSSM support is discontinued.
       
   490              Code is kept in comments temporarily because similar UI functionality
       
   491              might be needed for another purpose.
       
   492     TBool selectionExists = iLoader.SelectionExistsL( 0 );
       
   493             
       
   494     if( selectionExists )
       
   495         {
       
   496         // Get selection name for connecting via note
       
   497         // and save it to the member variable of iLoader
       
   498         iLoader.GetSelectionNameL( iLoader.iSelectionName );
       
   499                
       
   500         iLoader.ShowWaitNoteL();
       
   501         TAcuContentId contentId;
       
   502         contentId.iContentId = aPolicyId;
       
   503         iLoader.AcuApiWrapperL().UpdatePolicyL( contentId, this );
       
   504         } ***/
       
   505     }
       
   506 
       
   507 
       
   508 void CVpnManagementUiPolicyContainer::NotifyUpdatePolicyCompleteL(
       
   509     TInt aResult)
       
   510     {
       
   511     if ( iLoader.iWaitDialog ) 
       
   512         {
       
   513         iLoader.DeleteWaitNoteL();//iWaitDialog->ProcessFinishedL(); // deletes the wait dialog
       
   514         }
       
   515 
       
   516     if (aResult == KErrNone)
       
   517         {
       
   518         //Confirmation note
       
   519         HBufC* string = StringLoader::LoadLC( R_VPN_CONF_POLICY_UPDATE_COMPLETE );
       
   520         CAknConfirmationNote* note = new ( ELeave ) CAknConfirmationNote( ETrue );
       
   521         note->ExecuteLD( *string );
       
   522         CleanupStack::PopAndDestroy( string );
       
   523         }
       
   524     /*** NSSM support is discontinued.
       
   525          Code is kept in comments temporarily because similar UI functionality
       
   526          might be needed for another purpose.
       
   527     else if (aResult == KAcuErrServerCertExpiredByPkiService)
       
   528         {
       
   529         //Show an information note
       
   530         HBufC* noteText;
       
   531         noteText = StringLoader::LoadLC( R_VPN_INFO_SERVER_CERT_EXPIRED );
       
   532         CAknInformationNote* note = new(ELeave)CAknInformationNote(ETrue);
       
   533         note->SetTimeout(CAknNoteDialog::ELongTimeout); //3sec
       
   534         note->ExecuteLD(noteText->Des());
       
   535         CleanupStack::PopAndDestroy();  // noteText
       
   536         } ***/
       
   537     else if (aResult == KErrDiskFull)
       
   538     	{
       
   539     	CErrorUI* errorUi = CErrorUI::NewLC( *(CCoeEnv::Static()) );
       
   540         errorUi->ShowGlobalErrorNoteL( KErrDiskFull );
       
   541         CleanupStack::PopAndDestroy();  // errorUi
       
   542     	}    
       
   543     else if (aResult == KErrCancel)
       
   544         {
       
   545         // No operation, i.e. don't show anything
       
   546         }
       
   547     else
       
   548         {
       
   549         //Show an information note
       
   550         HBufC* noteText;
       
   551         noteText = StringLoader::LoadLC( R_VPN_INFO_POLICY_DL_ERROR );
       
   552         CAknInformationNote* note = new(ELeave)CAknInformationNote(ETrue);
       
   553         note->SetTimeout(CAknNoteDialog::ELongTimeout); //3sec
       
   554         note->ExecuteLD(noteText->Des());
       
   555         CleanupStack::PopAndDestroy();  // noteText
       
   556         }
       
   557     }
       
   558 
       
   559 void CVpnManagementUiPolicyContainer::NotifySynchroniseServerCompleteL(TInt aResult)
       
   560     {
       
   561     //CloseWaitDialog();
       
   562 
       
   563     if ( iLoader.iWaitDialog ) 
       
   564         {
       
   565         iLoader.DeleteWaitNoteL();//iWaitDialog->ProcessFinishedL(); // deletes the wait dialog
       
   566         }
       
   567 
       
   568     if (aResult == KErrNone)
       
   569         {
       
   570         //Confirmation note
       
   571         HBufC* string = StringLoader::LoadLC( R_VPN_CONF_POLICY_SERVER_SYNC_OK );
       
   572         CAknConfirmationNote* note = new ( ELeave ) CAknConfirmationNote( ETrue );
       
   573         note->ExecuteLD( *string );
       
   574         CleanupStack::PopAndDestroy( string );
       
   575         }
       
   576     /*** NSSM support is discontinued.
       
   577          Code is kept in comments temporarily because similar UI functionality
       
   578          might be needed for another purpose.
       
   579     else if (aResult == KAcuErrServerCertExpiredByPkiService)
       
   580         {
       
   581         //Show an information note
       
   582         HBufC* noteText;
       
   583         noteText = StringLoader::LoadLC( R_VPN_INFO_SERVER_CERT_EXPIRED );
       
   584         CAknInformationNote* note = new(ELeave)CAknInformationNote(ETrue);
       
   585         note->SetTimeout(CAknNoteDialog::ELongTimeout); //3sec
       
   586         note->ExecuteLD(noteText->Des());
       
   587         CleanupStack::PopAndDestroy();  // noteText
       
   588         } ***/
       
   589     else if (aResult == KErrDiskFull)
       
   590     	{
       
   591     	CErrorUI* errorUi = CErrorUI::NewLC( *(CCoeEnv::Static()) );
       
   592         errorUi->ShowGlobalErrorNoteL( KErrDiskFull );
       
   593         CleanupStack::PopAndDestroy();  // errorUi
       
   594     	}
       
   595     else if (aResult == KErrCancel)
       
   596         {
       
   597         // No operation, i.e. don't show anything
       
   598         }
       
   599     else
       
   600         {
       
   601         //Show an information note
       
   602         HBufC* noteText;
       
   603         noteText = StringLoader::LoadLC( R_VPN_INFO_POLICY_SERVER_SYNC_ERROR );
       
   604         CAknInformationNote* note = new(ELeave)CAknInformationNote(ETrue);
       
   605         note->SetTimeout(CAknNoteDialog::ELongTimeout); //3sec
       
   606         note->ExecuteLD(noteText->Des());
       
   607         CleanupStack::PopAndDestroy();  // noteText
       
   608         }
       
   609 
       
   610     ShowPoliciesL();
       
   611     iParent.SetMiddleSoftKeyL(ETrue);
       
   612     }
       
   613 
       
   614 
       
   615 void CVpnManagementUiPolicyContainer::NotifyStepChangedL(TInt /*aResult*/)
       
   616     {
       
   617     if (iShowWaitNote)
       
   618         {
       
   619         iLoader.ShowWaitNoteL();
       
   620         iShowWaitNote = EFalse;
       
   621         }
       
   622     if ( iLoader.iWaitDialog ) 
       
   623         {
       
   624         iLoader.SetTextL();
       
   625         }
       
   626     }
       
   627 
   342 
   628 // ---------------------------------------------------------
   343 // ---------------------------------------------------------
   629 // CVpnManagementUiPolicyContainer::GetHelpContext
   344 // CVpnManagementUiPolicyContainer::GetHelpContext
   630 // This function is called when Help application is launched.  
   345 // This function is called when Help application is launched.  
   631 // (other items were commented in a header).
   346 // (other items were commented in a header).