pnpmobileservices/pnpms/PnP/PnpProvisioningAppSrc/PnpProvisioningAppUi.cpp
changeset 0 3ce708148e4d
child 2 a5fecba4b1e4
equal deleted inserted replaced
-1:000000000000 0:3ce708148e4d
       
     1 /*
       
     2 * Copyright (c) 2004-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: Implementation of PnPMS components
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 
       
    20 // INCLUDE FILES
       
    21 #include <avkon.hrh>
       
    22 #include <apgcli.h>
       
    23 #include <textresolver.h>
       
    24 #include <rconnmon.h>
       
    25 #include <ApUtils.h>
       
    26 #include <PnpProvisioning.rsg>
       
    27 #include <BrowserUiSDKCRKeys.h>         // for KCRUidBrowser
       
    28 #include <AknGlobalNote.h>              // for CAknGlobalNote
       
    29 #include <AknGlobalConfirmationQuery.h> // for CAknGlobalConfirmationQuery
       
    30 
       
    31 #include "PnpProvisioningApp.h"
       
    32 #include "PnpProvisioningAppUi.h"
       
    33 #include "PnpProvisioningDocument.h"
       
    34 #include "pnpprovisioning.hrh"
       
    35 #include "PnpLogger.h"
       
    36 #include "cwaitdialogmonitor.h"
       
    37 
       
    38 
       
    39 _LIT( KQuestionMark, "?" );
       
    40 _LIT( KAmpersand, "&" );
       
    41 _LIT( KStatus, "Status=" );
       
    42 _LIT( KSpace, " " );
       
    43 
       
    44 const TUint KCallbackDelay = 1000000;
       
    45 
       
    46 
       
    47 
       
    48 // ================= MEMBER FUNCTIONS =======================
       
    49 //
       
    50 // ----------------------------------------------------------
       
    51 // CPnpProvisioningAppUi::ConstructL()
       
    52 // 
       
    53 // ----------------------------------------------------------
       
    54 //
       
    55 void CPnpProvisioningAppUi::ConstructL()
       
    56     {
       
    57     LOGSTRING( "CPnpProvisioningAppUi::ConstructL" );
       
    58     BaseConstructL( ENoScreenFurniture );
       
    59     //send to backround
       
    60     TApaTaskList taskList( CEikonEnv::Static()->WsSession() );
       
    61     TApaTask task = taskList.FindApp( KUidPnpProvisioning );
       
    62     task.SendToBackground();
       
    63     this->StatusPane()->MakeVisible( EFalse );
       
    64     HideApplicationFromFSW();
       
    65     
       
    66     CEikonEnv::Static()->AddForegroundObserverL( *this );
       
    67     
       
    68     // if service activation enabled allow automatic settings configuration instead
       
    69     // of showing confirmation notes
       
    70 
       
    71     TBool activationenabled = ServiceActivationEnabledL();
       
    72     
       
    73     if(!activationenabled)
       
    74     {
       
    75     HBufC* msgConfirmSave = CEikonEnv::Static()->AllocReadResourceLC(
       
    76             R_TEXT_QUERY); 
       
    77             
       
    78         CAknGlobalConfirmationQuery* query = CAknGlobalConfirmationQuery::NewL();
       
    79         CleanupStack::PushL( query );
       
    80         TRequestStatus statusSave;
       
    81         query->ShowConfirmationQueryL(
       
    82             statusSave, 
       
    83             *msgConfirmSave, 
       
    84             R_AVKON_SOFTKEYS_YES_NO__YES,
       
    85             R_QGN_NOTE_QUERY_ANIM);
       
    86             
       
    87         User::WaitForRequest( statusSave );
       
    88         CleanupStack::PopAndDestroy( 2 );
       
    89         
       
    90         if( statusSave != EAknSoftkeyYes )
       
    91             {
       
    92             LOGSTRING("User rejected");
       
    93             Exit();
       
    94             }
       
    95     }
       
    96     ResolveApL( iApInUse );
       
    97     
       
    98     ShowWaitNoteL();
       
    99 
       
   100     iPeriodic = CPeriodic::NewL( CActive::EPriorityStandard  );
       
   101     iPeriodic->Start( KCallbackDelay, KCallbackDelay, TCallBack(CPnpProvisioningAppUi::PeriodicCallback, this) );
       
   102     LOGSTRING( "CPnpProvisioningAppUi::ConstructL - done" );
       
   103     }
       
   104 
       
   105 // ----------------------------------------------------
       
   106 // CPnpProvisioningAppUi::~CPnpProvisioningAppUi()
       
   107 // Destructor
       
   108 // Frees reserved resources
       
   109 // ----------------------------------------------------
       
   110 //
       
   111 CPnpProvisioningAppUi::~CPnpProvisioningAppUi()
       
   112     {
       
   113     LOGSTRING( "~CPnpProvisioningAppUi" );
       
   114 
       
   115     // iPeriodic is deleted in the document's destructor
       
   116     if( iPeriodic )
       
   117         {
       
   118         iPeriodic->Cancel();
       
   119         delete iPeriodic;
       
   120         }
       
   121     if (iDoorObserver)
       
   122         {
       
   123         LOGSTRING( "calling iDoorObserver->NotifyExit" );
       
   124         iDoorObserver->NotifyExit(MApaEmbeddedDocObserver::ENoChanges);
       
   125         }
       
   126         
       
   127     if( iGlobalWaitNote )
       
   128         {
       
   129         delete iGlobalWaitNote;
       
   130         }
       
   131         
       
   132     if( iWaitDialogMonitor )
       
   133         {
       
   134         iWaitDialogMonitor->Cancel();
       
   135         delete iWaitDialogMonitor;
       
   136         }
       
   137     LOGSTRING( "~CPnpProvisioningAppUi done" );
       
   138    }
       
   139 
       
   140 // ------------------------------------------------------------------------------
       
   141 // CPnpProvisioningAppUi::DynInitMenuPaneL(TInt aResourceId,CEikMenuPane* aMenuPane)
       
   142 //  This function is called by the EIKON framework just before it displays
       
   143 //  a menu pane. Its default implementation is empty, and by overriding it,
       
   144 //  the application can set the state of menu items dynamically according
       
   145 //  to the state of application data.
       
   146 // ------------------------------------------------------------------------------
       
   147 //
       
   148 void CPnpProvisioningAppUi::DynInitMenuPaneL(
       
   149     TInt /*aResourceId*/,CEikMenuPane* /*aMenuPane*/)
       
   150     {
       
   151     }
       
   152 
       
   153 // ----------------------------------------------------
       
   154 // CPnpProvisioningAppUi::HandleKeyEventL(
       
   155 //     const TKeyEvent& aKeyEvent,TEventCode /*aType*/)
       
   156 // takes care of key event handling
       
   157 // ----------------------------------------------------
       
   158 //
       
   159 TKeyResponse CPnpProvisioningAppUi::HandleKeyEventL(
       
   160     const TKeyEvent& /*aKeyEvent*/,TEventCode /*aType*/)
       
   161     {
       
   162     return EKeyWasNotConsumed;
       
   163     }
       
   164 
       
   165 // ----------------------------------------------------
       
   166 // CPnpProvisioningAppUi::HandleCommandL(TInt aCommand)
       
   167 // takes care of command handling
       
   168 // ----------------------------------------------------
       
   169 //
       
   170 void CPnpProvisioningAppUi::HandleCommandL(TInt aCommand)
       
   171     {
       
   172     switch ( aCommand )
       
   173         {
       
   174         case EAknSoftkeyBack:
       
   175         case EEikCmdExit:
       
   176             {
       
   177             Exit();
       
   178             break;
       
   179             }
       
   180 
       
   181         default:
       
   182             break;      
       
   183         }
       
   184     }
       
   185     
       
   186 // -----------------------------------------------------------------------------
       
   187 // CPnpProvisioningAppUi::HandleGainingForeground
       
   188 //
       
   189 // -----------------------------------------------------------------------------
       
   190 //
       
   191 void CPnpProvisioningAppUi::HandleGainingForeground()
       
   192     {
       
   193     LOGSTRING( "CPnpProvisioningAppUi::HandleGainingForeground" );
       
   194     TApaTaskList taskList( CEikonEnv::Static()->WsSession() );
       
   195     TApaTask task = taskList.FindApp( KUidPnpProvisioning );
       
   196     if( task.Exists() )
       
   197         {
       
   198         task.SendToBackground();
       
   199         }
       
   200     }
       
   201     
       
   202 // -----------------------------------------------------------------------------
       
   203 // CPnpProvisioningAppUi::HandleLosingForeground
       
   204 //
       
   205 // (other items were commented in a header).
       
   206 // -----------------------------------------------------------------------------
       
   207 //
       
   208 void CPnpProvisioningAppUi::HandleLosingForeground()
       
   209     {
       
   210     LOGSTRING( "CPnpProvisioningAppUi::HandleLosingForeground" );
       
   211     }
       
   212 
       
   213 // ----------------------------------------------------
       
   214 // CPnpProvisioningAppUi::RedirectL
       
   215 // ----------------------------------------------------
       
   216 //
       
   217 void CPnpProvisioningAppUi::RedirectL( const TDesC& aUrl, THttpProvStates::TProvisioningStatus  aStatus )
       
   218     {
       
   219     // do the redirect thing
       
   220     LOGSTRING( "RedirectL" );
       
   221 
       
   222     // Parameters are separated by space
       
   223     // 1st parameter: type of the further parameters
       
   224     // 2nd parameter: URL or  the uid of bookmark/saved deck/pushed deck.
       
   225     // 3rd parameter: Access point Uid (in decimal format).
       
   226     // the 3rd parameter is optional, and only for specifying AP for URL-s
       
   227 
       
   228     HBufC* param = HBufC::NewLC( 300 );
       
   229     TPtr paramPtr = param->Des();
       
   230     paramPtr.Copy( _L( "4 " ) );
       
   231     
       
   232     
       
   233     paramPtr.Append( aUrl );
       
   234 
       
   235     // Assume there might already be parameters in the URL given
       
   236     if( aUrl.Find( KQuestionMark ) != KErrNotFound )
       
   237         {
       
   238         paramPtr.Append( KAmpersand );
       
   239         }
       
   240     else
       
   241         {
       
   242         paramPtr.Append( KQuestionMark );
       
   243         }
       
   244 
       
   245     paramPtr.Append( KStatus );
       
   246     paramPtr.AppendNum( (TInt) aStatus );
       
   247 
       
   248     // Only give a valid AP
       
   249     if( iApInUse != 0 )
       
   250         {
       
   251         paramPtr.Append( KSpace );
       
   252         paramPtr.AppendNumUC( iApInUse );
       
   253         }
       
   254 
       
   255 #ifdef _DEBUG
       
   256     LOGSTRING( "redirecting params:" );
       
   257     for( TInt i(0); i < paramPtr.Length(); i += 128 )
       
   258         {
       
   259         LOGTEXT( paramPtr .Right( paramPtr .Length() - i ) );
       
   260         }
       
   261 #endif
       
   262 
       
   263     TApaTaskList taskList( CEikonEnv::Static()->WsSession() );
       
   264     TApaTask task = taskList.FindApp( KCRUidBrowser );
       
   265     if ( task.Exists() )
       
   266         {
       
   267         LOGSTRING( "redirecting browser" );
       
   268         HBufC8* param8 = HBufC8::NewLC( param->Length() );
       
   269         param8->Des().Append( *param );
       
   270         task.SendMessage( TUid::Uid( 0 ), *param8 ); // Uid is not used
       
   271         //task.BringToForeground();     
       
   272         CleanupStack::PopAndDestroy( param8 );
       
   273         }
       
   274     else 
       
   275         {
       
   276         LOGSTRING( "Could not find browser" );
       
   277         RApaLsSession   appArcSession;
       
   278         User::LeaveIfError(appArcSession.Connect());    // connect to AppArc server
       
   279         TThreadId id;
       
   280         appArcSession.StartDocument( *param, KCRUidBrowser, id );
       
   281         appArcSession.Close();
       
   282         }
       
   283     CleanupStack::PopAndDestroy( param ); // param
       
   284     LOGSTRING( "calling Exit()" ); 
       
   285     Exit();
       
   286     }
       
   287 
       
   288 // ----------------------------------------------------
       
   289 // CPnpProvisioningAppUi::ResolveApL
       
   290 // ----------------------------------------------------
       
   291 //
       
   292 void CPnpProvisioningAppUi::ResolveApL( TUint32& aAp )
       
   293     {
       
   294     LOGSTRING("Trying to get AP used");
       
   295 
       
   296 
       
   297     // PnPProvisioning app might be started by browsing to a service using
       
   298     // PAOS filter 
       
   299     // -> OnlineSupport app that normally sets the AP to DB might not have been
       
   300     // used. It is also possible that the AP that OnlineSupport app used has
       
   301     // been removed.
       
   302 
       
   303     // So we try to use the AP currently in use first; if none is in use read the AP
       
   304     // from shared data / cenrep.
       
   305 
       
   306     RConnectionMonitor connMon;
       
   307     connMon.ConnectL();
       
   308     CleanupClosePushL( connMon );
       
   309     TUint connectionCount(0);
       
   310     TRequestStatus status( KRequestPending );
       
   311     connMon.GetConnectionCount( connectionCount, status );
       
   312     // No user interaction possible at this point so no need to make the call asynchronously
       
   313     User::WaitForRequest( status );
       
   314     LOGSTRING("Trying to get AP used - 2");
       
   315 
       
   316     for( TUint i(1); i <= connectionCount; i++ )
       
   317         {
       
   318         LOGSTRING("Trying to get AP used - 3");
       
   319         TUint connectionId(0);
       
   320         TUint subConnectionCount(0);
       
   321         TInt err = connMon.GetConnectionInfo( i, connectionId, subConnectionCount );
       
   322         if( err != KErrNone )
       
   323             {
       
   324             LOGSTRING2( "err %i", err );
       
   325             }
       
   326 
       
   327         LOGSTRING("Trying to get AP used - 4");
       
   328         TUint ap(0);
       
   329         TRequestStatus status2( KRequestPending );
       
   330         connMon.GetUintAttribute( connectionId, 0, KIAPId, ap, status2 );
       
   331         User::WaitForRequest( status2 );
       
   332         if( status2.Int() != KErrNone )
       
   333             {
       
   334             LOGSTRING2( "err %i", status2.Int() );
       
   335             }
       
   336         LOGSTRING("Trying to get AP used - 5");
       
   337         if( ap != 0 )
       
   338             {
       
   339             LOGSTRING2("Trying to get AP used - found: %i", ap );
       
   340 
       
   341             CCommsDatabase* commDb = CCommsDatabase::NewL( EDatabaseTypeIAP );
       
   342             CleanupStack::PushL( commDb );
       
   343             CApUtils* utils = CApUtils::NewLC( *commDb );
       
   344             //aAp = utils->WapIdFromIapIdL( ap );
       
   345             LOGSTRING2( "wap id: %i", aAp );
       
   346             
       
   347             // In some cases the connection has to be reset after saving
       
   348             // provisioned settings
       
   349             TInt err = connMon.SetBoolAttribute( 0, 0, KConnectionStopAll, ETrue );
       
   350             LOGSTRING2( "Connection stop error: %i", err );
       
   351             CleanupStack::PopAndDestroy( utils );
       
   352             CleanupStack::PopAndDestroy( commDb );
       
   353             CleanupStack::PopAndDestroy(); // connMon.Close()
       
   354             LOGSTRING("Trying to get AP used - done");
       
   355             return;
       
   356             }
       
   357         }
       
   358     CleanupStack::PopAndDestroy(); // connMon.Close()
       
   359     }
       
   360     
       
   361 // ----------------------------------------------------
       
   362 // CPnpProvisioningAppUi::DoExit()
       
   363 // exits app.
       
   364 // ----------------------------------------------------
       
   365 //
       
   366 void CPnpProvisioningAppUi::DoExit()
       
   367     {
       
   368     LOGSTRING( "DoExit" );
       
   369     Exit();
       
   370     }
       
   371 
       
   372 // ----------------------------------------------------
       
   373 // CPnpProvisioningAppUi::PeriodicCallback
       
   374 // ----------------------------------------------------
       
   375 //
       
   376 TInt CPnpProvisioningAppUi::PeriodicCallback( TAny* aPtr )
       
   377     {
       
   378     TRAPD( err, ( (CPnpProvisioningAppUi*)aPtr )->DoPeriodicCallbackL( aPtr ) );
       
   379     if( err != KErrNone )
       
   380         {
       
   381         LOGSTRING2( "Error in DoPeriodicCallBackL: %i", err );
       
   382         if( err == KLeaveExit )
       
   383             User::Leave( KLeaveExit );
       
   384         }
       
   385     return KErrNone;
       
   386     }
       
   387 
       
   388 // ----------------------------------------------------
       
   389 // CPnpProvisioningAppUi::DoPeriodicCallbackL
       
   390 // ----------------------------------------------------
       
   391 //
       
   392 void CPnpProvisioningAppUi::DoPeriodicCallbackL( TAny* aPtr )
       
   393     {
       
   394     LOGSTRING( "CPnpProvisioningAppUi::PeriodicCallback" );
       
   395 
       
   396     CPnpProvisioningAppUi* ui = (CPnpProvisioningAppUi*)aPtr;
       
   397     CPnpProvisioningDocument* document = (CPnpProvisioningDocument*)ui->Document();
       
   398     TInt leavestatus = KErrNone;
       
   399     TInt noRedirect = 0;
       
   400     THttpProvStates::TProvisioningStatus status = THttpProvStates::EStatusOk;
       
   401 
       
   402     LOGSTRING( "CPnpProvisioningAppUi::PeriodicCallback - Is doc ready?" );
       
   403 
       
   404     if( !(document->Ready()) )
       
   405         {
       
   406         LOGSTRING( "Document not ready yet" );
       
   407         User::Leave( KErrNotReady );
       
   408         }
       
   409 
       
   410     ui->iPeriodic->Cancel();
       
   411     // document->SetPeriodic( ui->iPeriodic );
       
   412     TRAP( leavestatus, status = document->SaveSettingsL() );
       
   413     if( leavestatus != KErrNone )
       
   414         {
       
   415         LOGSTRING2( "SaveSettingsL leave code: %i", leavestatus );
       
   416         
       
   417         if( leavestatus == THttpProvStates::EStatusRejected )
       
   418             {
       
   419             // user has cancelled
       
   420             ui->DoExit();
       
   421             }
       
   422         else
       
   423             {
       
   424             ui->ShowErrorNoteL();
       
   425             }
       
   426         }
       
   427 
       
   428     LOGSTRING( "CPnpProvisioningAppUi::PeriodicCallback - get report url" );
       
   429 
       
   430     // try to get the redirect url
       
   431     TBuf<512> url;
       
   432     TRAPD( err, url.Copy( document->GetReportUrlL().Left(512) ) );
       
   433     if( err != KErrNone )
       
   434         {
       
   435         LOGSTRING2( "no report url:%i", err );
       
   436         
       
   437         TerminateBrowserL(err, noRedirect);
       
   438         
       
   439         ui->DoExit();
       
   440         }
       
   441     else
       
   442         {
       
   443         if( status != THttpProvStates::EStatusOk )
       
   444             {
       
   445             LOGSTRING( "CPnpProvisioningAppUi::PeriodicCallback - do redirect" );
       
   446             
       
   447             TerminateBrowserL(KErrGeneral, noRedirect);
       
   448             if(noRedirect == 1)
       
   449             ui->DoExit();
       
   450             ui->RedirectL( url, status );
       
   451             }
       
   452         else if( leavestatus != KErrNone )
       
   453             {
       
   454             LOGSTRING( "CPnpProvisioningAppUi::PeriodicCallback - do redirect with leave status" );
       
   455             
       
   456             TerminateBrowserL(leavestatus, noRedirect);
       
   457             if(noRedirect == 1)
       
   458             ui->DoExit();
       
   459             
       
   460             ui->RedirectL( url, THttpProvStates::TProvisioningStatus( leavestatus ) );
       
   461             }
       
   462         else
       
   463             {
       
   464             LOGSTRING2( "Provisioning status: %i", status );
       
   465 
       
   466             // Since Plat sec there is no need to restart Browser after provisioning
       
   467             // has been done.
       
   468             // In some cases the connection has to be reset, though
       
   469             // (it is done in ResolveApL)
       
   470             LOGSTRING( "Making redirect" );
       
   471             
       
   472            //Before Making redirect check if application launched PNPMS.
       
   473            //If application has not launched PNPMS client then do redirect
       
   474            // otherwise call for Service Activation and launch choosen application
       
   475            // closing browser
       
   476            
       
   477         
       
   478           		TerminateBrowserL(KErrNone,noRedirect);
       
   479           		
       
   480 	    		if(noRedirect == 1)
       
   481             		  ui->DoExit();
       
   482 	    		
       
   483             
       
   484             ui->RedirectL( url, THttpProvStates::EStatusOk );
       
   485             }
       
   486         }
       
   487 
       
   488     LOGSTRING( "CPnpProvisioningAppUi::PeriodicCallback - done" );
       
   489     }
       
   490     
       
   491 //// ----------------------------------------------------
       
   492 // CPnpProvisioningAppUi::ServiceActivationEnabled()
       
   493 // ----------------------------------------------------
       
   494 //
       
   495 TBool CPnpProvisioningAppUi::ServiceActivationEnabledL()
       
   496 {
       
   497 	CPnpProvUtil *provUtil = CPnpProvUtil::NewLC();
       
   498 	TUint32 uidval = 0;
       
   499 	TRAPD(err, uidval = provUtil->GetApplicationUidL());
       
   500 		              
       
   501 	CleanupStack::PopAndDestroy();    //provutil     
       
   502 
       
   503 	if(uidval && !err)
       
   504         {
       
   505 	 	return ETrue;
       
   506 	}
       
   507 	
       
   508 	return EFalse;
       
   509 	
       
   510 }
       
   511 
       
   512 
       
   513 // ----------------------------------------------------
       
   514 // CPnpProvisioningAppUi::TerminateBrowserIfErrorL()
       
   515 // ----------------------------------------------------
       
   516 //
       
   517 
       
   518 void CPnpProvisioningAppUi::TerminateBrowserL(TInt aError, TInt& aNoRedirect)
       
   519 {
       
   520 	    // Terminate browser and launch choosen application based on status of
       
   521       // aNoRedirect status
       
   522       // If error status is KErrNone  the application is launched closing browser
       
   523       // If there are errors then terminate browser without launching application
       
   524 	
       
   525 	    	CPnpProvUtil *provUtil = CPnpProvUtil::NewLC();
       
   526         CPnpServiceActivation *serviceActivate = CPnpServiceActivation::NewLC();
       
   527     		TUint32 uidval = 0;
       
   528 		
       
   529 				TRAPD(err, uidval = provUtil->GetApplicationUidL());
       
   530                       
       
   531         if(uidval && !err)
       
   532         {
       
   533             if(aError == KErrNone)
       
   534             	TRAP_IGNORE(serviceActivate->LaunchApplicationL());
       
   535           	
       
   536           	TRAP_IGNORE(serviceActivate->KillBrowserL());
       
   537 						TRAP_IGNORE(provUtil -> SetApplicationUidL(0));
       
   538 			
       
   539 	   				// Interger value is required in case of handling multiple cases in redirection
       
   540 	   				// With current implementation only 2 values are supported 0 and 1
       
   541 	   				aNoRedirect = 1;	
       
   542 			
       
   543 			 	
       
   544         }
       
   545         
       
   546         CleanupStack::PopAndDestroy(2);
       
   547         
       
   548         
       
   549 }
       
   550 
       
   551 
       
   552 // ----------------------------------------------------
       
   553 // CPnpProvisioningAppUi::ShowErrorNoteL()
       
   554 // ----------------------------------------------------
       
   555 //
       
   556 void CPnpProvisioningAppUi::ShowErrorNoteL()
       
   557     {
       
   558     HBufC* msgTextSaved = CEikonEnv::Static()->
       
   559             AllocReadResourceLC( R_TEXT_CANNOT_SAVE ); 
       
   560 
       
   561     CAknGlobalNote* globalNote = CAknGlobalNote::NewL();
       
   562     CleanupStack::PushL( globalNote );
       
   563     globalNote->ShowNoteL( EAknGlobalErrorNote , *msgTextSaved );
       
   564     CleanupStack::PopAndDestroy( 2 );
       
   565     }
       
   566     
       
   567 // ----------------------------------------------------
       
   568 // CPnpProvisioningAppUi::ShowWaitNoteL()
       
   569 // ----------------------------------------------------
       
   570 //
       
   571 void CPnpProvisioningAppUi::ShowWaitNoteL()
       
   572     {
       
   573     HBufC* msgText = CEikonEnv::Static()->
       
   574         AllocReadResourceLC( R_TEXT_WAIT_SAVING ); 
       
   575 
       
   576     if (iWaitDialogMonitor)
       
   577         {
       
   578         iWaitDialogMonitor->Cancel();
       
   579         delete iWaitDialogMonitor;
       
   580         iWaitDialogMonitor = NULL;
       
   581         }
       
   582     // instantiate the active object CGlobalConfirmationObserver
       
   583     iWaitDialogMonitor = CWaitDialogMonitor::NewL( *this );
       
   584     
       
   585     // SetActive
       
   586     iWaitDialogMonitor->Start();
       
   587     
       
   588     if (!iGlobalWaitNote)
       
   589         {
       
   590         iGlobalWaitNote = CAknGlobalNote::NewL();
       
   591         }
       
   592 
       
   593      iGlobalWaitNote->SetSoftkeys( R_AVKON_SOFTKEYS_EMPTY);
       
   594     iGlobalWaitNote->ShowNoteL(
       
   595         iWaitDialogMonitor->iStatus,
       
   596         EAknGlobalWaitNote,
       
   597         *msgText );
       
   598     
       
   599     CleanupStack::PopAndDestroy( msgText );
       
   600     }
       
   601     
       
   602 // ----------------------------------------------------
       
   603 // CPnpProvisioningAppUi::WaitDialogDismissedL()
       
   604 // ----------------------------------------------------
       
   605 //
       
   606 void CPnpProvisioningAppUi::WaitDialogDismissedL( const TInt aStatusCode )
       
   607     {
       
   608     LOGSTRING2( "CPnpProvisioningAppUi::WaitDialogDismissedL aStatus is %i",aStatusCode );
       
   609     LOGSTRING2( "iWaitDialogMonitor->iStatus is %i" , iWaitDialogMonitor->iStatus.Int() );
       
   610     if( aStatusCode == EAknSoftkeyCancel || aStatusCode == EAknSoftkeyExit ||
       
   611     			aStatusCode == KErrCancel ) //End key results in KErrCancel
       
   612         {
       
   613         // user cancelled
       
   614         LOGSTRING( "CPnpProvisioningAppUi::WaitDialogDismissedL - user cancelled" );
       
   615         Exit();
       
   616         }
       
   617 //Handling End Key
       
   618     if(aStatusCode == EAknSoftkeyEmpty && iWaitDialogMonitor->iStatus == KErrCancel )
       
   619     	{
       
   620     	LOGSTRING( "End key or User cancel done, but DOc tries to close instead of RunL of iWaitDialogMonitor " );
       
   621     	//Exit();
       
   622     	iWaitDialogMonitor->Cancel();
       
   623     	User::Leave( THttpProvStates::EStatusRejected );
       
   624     	}
       
   625         
       
   626     if( iGlobalWaitNote )
       
   627         {
       
   628         delete iGlobalWaitNote;
       
   629         iGlobalWaitNote = NULL;
       
   630         }
       
   631         
       
   632     if( iWaitDialogMonitor )
       
   633         {
       
   634         iWaitDialogMonitor->Cancel();
       
   635         delete iWaitDialogMonitor;
       
   636         iWaitDialogMonitor = NULL;
       
   637         }
       
   638     }
       
   639 
       
   640 // End of File