voipplugins/accountcreationplugin/src/acpproviderlistview.cpp
branchRCL_3
changeset 21 f742655b05bf
parent 20 65a3ef1d5bd0
child 22 d38647835c2e
equal deleted inserted replaced
20:65a3ef1d5bd0 21:f742655b05bf
     1 /*
       
     2 * Copyright (c) 2007-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:  Implements CAcpProviderListView methods
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 #include <eikenv.h>
       
    20 #include <aknlists.h>
       
    21 #include <akntitle.h>
       
    22 #include <aknViewAppUi.h>
       
    23 #include <StringLoader.h>
       
    24 #include <apgcli.h>
       
    25 #include <apgtask.h>
       
    26 #include <centralrepository.h>
       
    27 #include <accountcreationplugin.rsg>
       
    28 #include <spnotifychange.h>
       
    29 #include <spsettings.h>
       
    30 #include <spentry.h>
       
    31 #include <spproperty.h>
       
    32 #include <AknQueryDialog.h>
       
    33 #include <crcseprofileregistry.h>
       
    34 #include <crcseprofileentry.h>
       
    35 #include <CxSPViewData.h>
       
    36 #include <featmgr.h>
       
    37 #include <hlplch.h>
       
    38 
       
    39 #include "acptimer.h"
       
    40 #include "acpdialog.h"
       
    41 #include "acpproviderlistview.h"
       
    42 #include "acpproviderspecificview.h"
       
    43 #include "acpproviderlistcontainer.h"
       
    44 #include "accountcreationpluginlogger.h"
       
    45 #include "acpcontroller.h"
       
    46 #include "maccountcreationpluginobserver.h"
       
    47 #include "accountcreationpluginconstants.h"
       
    48 #include "accountcreationplugin.hrh"
       
    49 
       
    50 // Constants for launching Help.
       
    51 _LIT( KVOIP_HLP_SERVCATALOG, "VOIP_HLP_SERVCATALOG" );
       
    52 const TUid KHelpUid = { 0x1020E566 };
       
    53 
       
    54 // Cleanup function for RCSE arrays.
       
    55 void CleanupResetAndDestroy( TAny* aPtr )
       
    56     {
       
    57     RPointerArray<CRCSEProfileEntry>* entries =
       
    58         static_cast<RPointerArray<CRCSEProfileEntry>*>( aPtr );
       
    59         
       
    60     entries->ResetAndDestroy();
       
    61     }
       
    62 
       
    63 // ---------------------------------------------------------------------------
       
    64 // CAcpProviderListView::CAcpProviderListView
       
    65 // ---------------------------------------------------------------------------
       
    66 //
       
    67 CAcpProviderListView::CAcpProviderListView(
       
    68     MAccountCreationPluginObserver& aObserver, TBool aLaunchedFromAI,
       
    69             CEikonEnv& aEikEnv )
       
    70     : iObserver( aObserver ), iLaunchedFromAI( aLaunchedFromAI ), 
       
    71     iEikEnv( aEikEnv )
       
    72     {
       
    73     }
       
    74 
       
    75 // ---------------------------------------------------------------------------
       
    76 // CAcpProviderListView::ConstructL
       
    77 // ---------------------------------------------------------------------------
       
    78 //
       
    79 void CAcpProviderListView::ConstructL()
       
    80     {
       
    81     ACPLOG( "CAcpProviderListView::ConstructL begin" );
       
    82  
       
    83     iUi = static_cast<CAknViewAppUi*> ( static_cast<CAknAppUi*> 
       
    84         ( iEikEnv.EikAppUi() ) );
       
    85 
       
    86     BaseConstructL( R_ACP_PROVIDER_LIST_VIEW );
       
    87 
       
    88     iController = CAcpController::NewL( *this );
       
    89     iDialog = CAcpDialog::NewL( *this );
       
    90     iTimer = CAcpTimer::NewL( *this );
       
    91     iServiceName = HBufC::NewL( 0 );
       
    92     
       
    93     // Get list of services.
       
    94     iSpSettings = CSPSettings::NewL();
       
    95     iSpSettings->FindServiceIdsL( iServiceIds );
       
    96     
       
    97     // Get tab view ids
       
    98     User::LeaveIfError( iXspViewServices.Open() );
       
    99     
       
   100     TInt err( KErrNone );
       
   101     TInt tabViewCount( 0 );
       
   102     
       
   103     err = iXspViewServices.GetViewCount( tabViewCount );
       
   104     
       
   105     for( TInt i( 0 ) ; i < tabViewCount && !err ; i++ )
       
   106         {
       
   107         TInt bufferLength( 0 );
       
   108         err = iXspViewServices.GetPackedViewDataBufferLength(
       
   109                 i, bufferLength );
       
   110         
       
   111         ACPLOG( "CAcpProviderListView::ConstructL 6" );
       
   112         
       
   113         if( !err && bufferLength > 0 )
       
   114             {
       
   115             HBufC8* packed = HBufC8::NewLC( bufferLength );
       
   116             TPtr8 packedPtr = packed->Des();
       
   117             
       
   118             err = iXspViewServices.GetPackedViewData( i, packedPtr );
       
   119             
       
   120             if( !err )
       
   121                 {     
       
   122                 CxSPViewData* viewData = CxSPViewData::NewL( *packed );
       
   123                 CleanupStack::PushL( viewData );
       
   124                 
       
   125                 ACPLOG2( "  --> VIEW ID: %d", viewData->OriginalViewId() );
       
   126                 
       
   127                 iTabViewIds.AppendL( viewData->OriginalViewId() );
       
   128                 CleanupStack::PopAndDestroy( viewData );    
       
   129                 }                                               
       
   130             CleanupStack::PopAndDestroy( packed );
       
   131             }
       
   132         }
       
   133     
       
   134     iXspViewServices.Close();
       
   135     
       
   136     ACPLOG( "CAcpProviderListView::ConstructL end" );
       
   137     }
       
   138 
       
   139 // ---------------------------------------------------------------------------
       
   140 // CAcpProviderListView::NewL
       
   141 // ---------------------------------------------------------------------------
       
   142 //      
       
   143 CAcpProviderListView* CAcpProviderListView::NewL( 
       
   144     MAccountCreationPluginObserver& aObserver, TBool aLaunchedFromAI,
       
   145 	        CEikonEnv& aEikEnv )
       
   146     {    
       
   147     CAcpProviderListView* self = CAcpProviderListView::NewLC( aObserver,
       
   148             aLaunchedFromAI, aEikEnv );
       
   149     CleanupStack::Pop( self );
       
   150     return self;
       
   151     }
       
   152 
       
   153 // ---------------------------------------------------------------------------
       
   154 // CAcpProviderListView::NewLC
       
   155 // ---------------------------------------------------------------------------
       
   156 //
       
   157 CAcpProviderListView* CAcpProviderListView::NewLC(
       
   158     MAccountCreationPluginObserver& aObserver, TBool aLaunchedFromAI,
       
   159 	        CEikonEnv& aEikEnv )
       
   160     {    
       
   161     CAcpProviderListView* self = 
       
   162         new ( ELeave ) CAcpProviderListView( aObserver, aLaunchedFromAI,
       
   163 		                                     aEikEnv );
       
   164     CleanupStack::PushL( self );
       
   165     self->ConstructL();
       
   166     return self;
       
   167     }
       
   168 
       
   169 // ---------------------------------------------------------------------------
       
   170 // CAcpProviderListView::~CAcpProviderListView
       
   171 // ---------------------------------------------------------------------------
       
   172 //
       
   173 CAcpProviderListView::~CAcpProviderListView()
       
   174     {
       
   175     ACPLOG( "CAcpProviderListView::~CAcpProviderListView begin" );
       
   176 
       
   177     // Delete container.
       
   178     if ( iContainer && iUi )
       
   179         {
       
   180         iUi->RemoveFromViewStack( *this, iContainer );
       
   181         delete iContainer;
       
   182         }
       
   183 
       
   184     delete iDialog;
       
   185     delete iController;
       
   186     delete iTimer;
       
   187     delete iSpSettings;
       
   188     iServiceIds.Close();    
       
   189     delete iServiceName;
       
   190     
       
   191     iTabViewIds.Close();
       
   192     iXspViewServices.Close();
       
   193     
       
   194     ACPLOG( "CAcpProviderListView::~CAcpProviderListView end" );
       
   195     }         
       
   196 
       
   197 // ---------------------------------------------------------------------------
       
   198 // CAcpProviderListView::ProvisioningL
       
   199 // ---------------------------------------------------------------------------
       
   200 //
       
   201 void CAcpProviderListView::ProvisioningL()
       
   202     {
       
   203     ACPLOG( "CAcpProviderListView::ProvisioningL begin" );
       
   204     
       
   205     TInt index = iController->ActiveIndex();
       
   206     TPtrC8 sisUrl = iController->ProviderSisUrlFromIndexL( index );
       
   207     
       
   208     // Save service name.
       
   209     delete iServiceName;
       
   210     iServiceName = NULL;
       
   211     iServiceName = iController->ProviderNameFromIndexL( index ).AllocL();
       
   212 
       
   213 	if ( sisUrl.Length() )
       
   214         {
       
   215         // Install sis package.
       
   216         ACPLOG( " - Fetching sis file" );
       
   217         
       
   218         iDialog->LaunchWaitNoteL( R_ACP_DOWNLOADING_PROVIDER_TEXT,
       
   219             *iServiceName );
       
   220         
       
   221         iController->FetchSisFileFromNetworkL( sisUrl );
       
   222         }
       
   223     // No sis url, get wbxml content instead.
       
   224     else
       
   225         {
       
   226         ACPLOG( " - Fetching wbxml content" );
       
   227 
       
   228         TBuf8<KMaxUrlLength> activationUrl;
       
   229 
       
   230         // Get activation URL. Insert session id if needed.
       
   231         if ( iController->SessionId().Length() )
       
   232             {
       
   233             // Change http://address?param=value to
       
   234             //        http://adress;jsessionid=[sessionid]?param=value
       
   235 
       
   236             TPtrC8 provActUrl = iController->
       
   237                 ProviderActivationUrlFromIndexL( index );
       
   238             
       
   239             if ( KErrNotFound == provActUrl.Find( KSessionId ) )
       
   240                 {
       
   241                 // Find ? and insert the session id part before it.
       
   242                 TInt qmIndex = provActUrl.Find( KQuestionMark8 );
       
   243                 if ( KErrNotFound != qmIndex )
       
   244                     {
       
   245                     activationUrl.Append( provActUrl.Mid( 0, qmIndex ) );
       
   246                     activationUrl.Append( KSessionId );
       
   247                     activationUrl.Append( iController->SessionId() );
       
   248                     activationUrl.Append( provActUrl.Mid( qmIndex ) );
       
   249                     }
       
   250                 }
       
   251             else
       
   252                 {
       
   253                 activationUrl.Append( provActUrl );
       
   254                 }
       
   255             }
       
   256         else
       
   257             {
       
   258             // Error. Can't download settings without a session id.
       
   259             TRAP_IGNORE( iDialog->ShowGlobalNoteL(
       
   260                 R_ACP_DOWNLOAD_FAILED, *iServiceName ) );
       
   261             
       
   262             iUi->ActivateLocalViewL( KProviderListViewId ); 
       
   263             return;
       
   264             }
       
   265 
       
   266         iDialog->LaunchWaitNoteL( R_ACP_DOWNLOADING_PROVIDER_TEXT,
       
   267             *iServiceName );
       
   268         
       
   269         iController->FetchActionFileL( activationUrl );
       
   270         }
       
   271 
       
   272     // Activate provider list view.
       
   273     iUi->ActivateLocalViewL( KProviderListViewId ); 
       
   274     }
       
   275 
       
   276 // ---------------------------------------------------------------------------
       
   277 // CAcpProviderListView::DownloadProviderListL
       
   278 // Starts provider list download.
       
   279 // ---------------------------------------------------------------------------
       
   280 // 
       
   281 void CAcpProviderListView::DownloadProviderListL()
       
   282     {
       
   283     iDialog->LaunchWaitNoteL( R_ACP_WAIT_NOTE_TEXT );
       
   284     iConnectingToServer = ETrue;
       
   285     iController->FetchProviderListFromNetworkL();
       
   286     }
       
   287 
       
   288 // ---------------------------------------------------------------------------
       
   289 // CAcpProviderListView::SetTitlePaneTextL
       
   290 // For changing text to the title pane.
       
   291 // ---------------------------------------------------------------------------
       
   292 // 
       
   293 void CAcpProviderListView::SetTitlePaneTextL() const
       
   294     {
       
   295     // Get handle to title pane.
       
   296     CEikStatusPane* statusPane = iEikonEnv->AppUiFactory()->StatusPane();
       
   297     if ( statusPane )
       
   298         {
       
   299         CAknTitlePane* titlePane =
       
   300             static_cast<CAknTitlePane*>( statusPane->ControlL(
       
   301                 TUid::Uid( EEikStatusPaneUidTitle ) ) );
       
   302 
       
   303         // Set title pane text from resouces.   
       
   304         HBufC* titleText = StringLoader::LoadLC( R_ACP_PROVIDER_LIST_TITLE );
       
   305         titlePane->SetTextL( titleText->Des() );
       
   306 
       
   307         CleanupStack::PopAndDestroy( titleText );
       
   308         }
       
   309     }
       
   310 
       
   311 // ---------------------------------------------------------------------------
       
   312 // CAcpProviderListView::Id
       
   313 // From class CAknView.
       
   314 // ---------------------------------------------------------------------------
       
   315 //
       
   316 TUid CAcpProviderListView::Id() const
       
   317     {
       
   318     return KProviderListViewId;
       
   319     }
       
   320 
       
   321 // ---------------------------------------------------------------------------
       
   322 // CAcpProviderListView::DoActivateL
       
   323 // From class CAknView.
       
   324 // ---------------------------------------------------------------------------
       
   325 //
       
   326 void CAcpProviderListView::DoActivateL( 
       
   327     const TVwsViewId& /*aPrevViewId*/, 
       
   328     TUid /*aCustomMessageId*/,
       
   329     const TDesC8& /*aCustomMessage*/ )
       
   330     {
       
   331     ACPLOG( "CAcpProviderListView::DoActivateL begin" );
       
   332 
       
   333     // Create container when view is activated.
       
   334     if ( !iContainer )
       
   335         {
       
   336         iContainer = CAcpProviderListContainer::NewL(
       
   337             *iController, ClientRect() );
       
   338         iContainer->SetMopParent( this );
       
   339         iUi->AddToStackL( *this, iContainer );
       
   340         iContainer->ListBox()->SetListBoxObserver( this );
       
   341         }
       
   342 
       
   343     SetTitlePaneTextL();
       
   344     
       
   345     iContainer->AddProvidersToListboxL();
       
   346 
       
   347     ACPLOG( "CAcpProviderListView::DoActivateL end" );
       
   348     }
       
   349 
       
   350 // ---------------------------------------------------------------------------
       
   351 // CAcpProviderListView::DoDeactivate()
       
   352 // From class CAknView.
       
   353 // ---------------------------------------------------------------------------
       
   354 //
       
   355 void CAcpProviderListView::DoDeactivate()
       
   356     {
       
   357     ACPLOG( "CAcpProviderListView::DoDeactivate begin" );
       
   358     
       
   359     // Delete container when view is deactivated.
       
   360     if ( iContainer )
       
   361         {
       
   362         iUi->RemoveFromViewStack( *this, iContainer );
       
   363         delete iContainer;
       
   364         iContainer = NULL;
       
   365         }
       
   366 
       
   367     ACPLOG( "CAcpProviderListView::DoDeactivate" );
       
   368     }
       
   369 
       
   370 // ---------------------------------------------------------------------------
       
   371 // CAcpProviderListView::HandleCommandL
       
   372 // From class CAknView.
       
   373 // ---------------------------------------------------------------------------
       
   374 //
       
   375 void CAcpProviderListView::HandleCommandL( TInt aCommand )
       
   376     {
       
   377     ACPLOG2( "CAcpProviderListView::HandleCommandL: cmd=%d", aCommand );
       
   378 
       
   379     TInt index = iContainer->CurrentItemIndex();
       
   380 
       
   381     ACPLOG2( " - index=%d", index );
       
   382 
       
   383     iController->SaveActiveIndex( index );
       
   384 
       
   385     switch ( aCommand )
       
   386         {
       
   387         case EAknSoftkeySelect:
       
   388             {
       
   389             ACPLOG( " - View details" );
       
   390             if ( KErrNotFound != index )
       
   391                 {
       
   392                 HandleListBoxSelectionL();
       
   393                 }
       
   394             }
       
   395             break;
       
   396 
       
   397         case EAcpDownload:
       
   398             {
       
   399             ACPLOG( " - Download" );          
       
   400             ProvisioningL();
       
   401             }
       
   402             break;
       
   403 
       
   404         case EAcpRefresh:
       
   405             {
       
   406             ACPLOG( " - Refresh" );
       
   407             iContainer->ResetListBox();
       
   408             iDialog->LaunchWaitNoteL( R_ACP_WAIT_NOTE_TEXT );
       
   409             iController->FetchProviderListFromNetworkL();
       
   410             }
       
   411             break;
       
   412             
       
   413         case EAcpHelp:
       
   414             {
       
   415             ACPLOG( " - Help" );
       
   416             FeatureManager::InitializeLibL();
       
   417             if ( FeatureManager::FeatureSupported( KFeatureIdHelp ) )
       
   418                 {
       
   419                 // Launch help.
       
   420                 CArrayFixFlat<TCoeHelpContext>* array = 
       
   421                     new (ELeave) CArrayFixFlat<TCoeHelpContext>( 1 );  
       
   422                 CleanupStack::PushL( array ); 
       
   423 
       
   424                 array->AppendL( TCoeHelpContext( KHelpUid,
       
   425                     KVOIP_HLP_SERVCATALOG ) );
       
   426                 
       
   427                 HlpLauncher::LaunchHelpApplicationL(
       
   428                     iEikonEnv->WsSession(), array );
       
   429                 
       
   430                 CleanupStack::Pop( array ); // Ownership passed.
       
   431                 }
       
   432             FeatureManager::UnInitializeLib();
       
   433             }
       
   434             break;
       
   435 
       
   436         case EAknSoftkeyBack:
       
   437         case EEikCmdExit:
       
   438         case EAknSoftkeyExit:
       
   439             {
       
   440             ACPLOG( " - Exit" );
       
   441             if ( iLaunchedFromAI )
       
   442                 {
       
   443                 AppUi()->HandleCommandL( EEikCmdExit );
       
   444                 }
       
   445             else
       
   446                 {
       
   447                 iObserver.NotifyAiwEventL( KErrNone );
       
   448                 }
       
   449             }
       
   450             break;
       
   451 
       
   452         default:
       
   453             break;
       
   454         }
       
   455 
       
   456     ACPLOG( "CAcpProviderListView::HandleCommandL end" );
       
   457     }
       
   458 
       
   459 // ---------------------------------------------------------------------------
       
   460 // CAcpProviderListView::HandleListBoxEventL
       
   461 // From MEikListBoxObserver
       
   462 // ---------------------------------------------------------------------------
       
   463 //
       
   464 void CAcpProviderListView::HandleListBoxEventL( 
       
   465     CEikListBox* /*aListBox*/, TListBoxEvent aEventType )
       
   466     {
       
   467     switch ( aEventType )
       
   468         {
       
   469         case EEventEnterKeyPressed:
       
   470         case EEventItemSingleClicked:
       
   471             HandleCommandL( EAknSoftkeySelect );
       
   472             break;
       
   473         default:
       
   474            break;
       
   475         }
       
   476     }
       
   477 
       
   478 // ---------------------------------------------------------------------------
       
   479 // CAcpProviderListView::HandleListBoxSelectionL
       
   480 // From MEikListBoxObserver
       
   481 // ---------------------------------------------------------------------------
       
   482 //
       
   483 void CAcpProviderListView::HandleListBoxSelectionL() 
       
   484     {
       
   485     // Set active list index to controller before activating next view.
       
   486     ACPLOG( "CAcpProviderListView::HandleListBoxSelectionL" );
       
   487 
       
   488     // Create provider specific view and activate it.
       
   489     if ( NULL == iProviderSpecificView )
       
   490         {
       
   491         iProviderSpecificView = 
       
   492             CAcpProviderSpecificView::NewL( *iController, *this );
       
   493         iUi->AddViewL( iProviderSpecificView ); // Ownership is transferred.
       
   494         }
       
   495     iUi->ActivateLocalViewL( iProviderSpecificView->Id() );
       
   496     }
       
   497 
       
   498 // ---------------------------------------------------------------------------
       
   499 // CAcpProviderListView::DynInitMenuPaneL
       
   500 // From MEikListBoxObserver
       
   501 // ---------------------------------------------------------------------------
       
   502 //
       
   503 void CAcpProviderListView::DynInitMenuPaneL( 
       
   504     TInt aResourceId, CEikMenuPane* aMenuPane )
       
   505     {
       
   506     ACPLOG( "CAcpProviderListView::DynInitMenuPaneL begin" );
       
   507 
       
   508     if ( R_ACP_PROVIDER_LIST_MENU == aResourceId &&
       
   509         iController->CountOfProviders() == 0 )  
       
   510         {
       
   511         aMenuPane->SetItemDimmed( EAknSoftkeySelect, ETrue );
       
   512         aMenuPane->SetItemDimmed( EAcpDownload, ETrue );
       
   513         }
       
   514 
       
   515     ACPLOG( "CAcpProviderListView::DynInitMenuPaneL end" );
       
   516     }
       
   517 
       
   518 // ---------------------------------------------------------------------------
       
   519 // CAcpProviderListContainer::DialogDismissed
       
   520 // From MAcpDialogObserver.
       
   521 // ---------------------------------------------------------------------------
       
   522 //
       
   523 void CAcpProviderListView::DialogDismissedL( TInt aError )
       
   524     {
       
   525     ACPLOG2( "CAcpProviderListView::DialogDismissed (%d)", aError );
       
   526 
       
   527     iDialog->DestroyWaitNote();
       
   528 
       
   529     if ( KErrNotFound == aError ) // Canceled.
       
   530         {
       
   531         iController->CancelHttpRequest();
       
   532         }
       
   533     
       
   534     // If launched from active idle.
       
   535     if ( iLaunchedFromAI )
       
   536         {
       
   537         ACPLOG( "CAcpProviderListView::DialogDismissed - EXIT" );
       
   538         
       
   539         AppUi()->HandleCommandL( EEikCmdExit );
       
   540         }
       
   541     }
       
   542 
       
   543 // ---------------------------------------------------------------------------
       
   544 // CAcpProviderListContainer::NotifyProviderListReady
       
   545 // From MAcpControllerObserver.
       
   546 // ---------------------------------------------------------------------------
       
   547 //
       
   548 void CAcpProviderListView::NotifyProviderListReady( TInt aError )
       
   549     {
       
   550     ACPLOG2( 
       
   551         "CAcpProviderListView::NotifyProviderListReady: err=%d", aError );
       
   552 
       
   553     // Always remove wait dialog from screen.
       
   554     iDialog->DestroyWaitNote();
       
   555 
       
   556     if ( KErrNone == aError )
       
   557         {
       
   558         // List loaded, it's ok to activate the view now.
       
   559         TRAP_IGNORE( iUi->ActivateLocalViewL( Id() ) );
       
   560         
       
   561         if ( iContainer )
       
   562             {
       
   563             TRAP_IGNORE( iContainer->AddProvidersToListboxL() );
       
   564             }
       
   565         }
       
   566     else if ( KErrCancel == aError )
       
   567         {
       
   568         // No action needed.
       
   569         }
       
   570     else
       
   571         {
       
   572         if ( iConnectingToServer )
       
   573             {
       
   574             // Failed connecting to NSA server.
       
   575             TRAP_IGNORE( iDialog->ShowGlobalNoteL( R_ACP_CONNECTION_FAILED ) );
       
   576             }
       
   577         else
       
   578             {
       
   579             // Failed downloading SIS/wbxml file.
       
   580             TRAP_IGNORE( iDialog->ShowGlobalNoteL( R_ACP_DOWNLOAD_FAILED,
       
   581                 *iServiceName ) );
       
   582             }
       
   583         }
       
   584     
       
   585     // Launched from active idle.
       
   586     if ( KErrNone != aError && iLaunchedFromAI )
       
   587         {
       
   588         ACPLOG( " - Launched from AI, exit." );
       
   589         TRAP_IGNORE( AppUi()->ProcessCommandL( EAknCmdExit ) );
       
   590         }
       
   591     
       
   592     iConnectingToServer = EFalse;
       
   593     }
       
   594 
       
   595 // ---------------------------------------------------------------------------
       
   596 // CAcpQueryView::NotifyDownloadingCompleted
       
   597 // From MAcpControllerObserver.
       
   598 // ---------------------------------------------------------------------------
       
   599 //
       
   600 void CAcpProviderListView::NotifyDownloadingCompleted( TInt aError )
       
   601     {
       
   602     ACPLOG( "CAcpProviderListView::NotifyDownloadingCompleted - IN" );
       
   603     
       
   604     // Destroy wait note if timer is not active
       
   605     if ( !iTimer->IsActive() )
       
   606         {
       
   607         iDialog->DestroyWaitNote();
       
   608         }
       
   609     
       
   610     // Show error note if needed.
       
   611     if ( KErrNone != aError )
       
   612         {
       
   613         TRAP_IGNORE( iDialog->ShowGlobalNoteL( R_ACP_DOWNLOAD_FAILED,
       
   614             *iServiceName ) );
       
   615         } 
       
   616     
       
   617     ACPLOG( "CAcpProviderListView::NotifyDownloadingCompleted - OUT" );
       
   618     }
       
   619 
       
   620 // ---------------------------------------------------------------------------
       
   621 // CAcpQueryView::NotifyDownloadingSISCompleted
       
   622 // From MAcpControllerObserver.
       
   623 // ---------------------------------------------------------------------------
       
   624 //
       
   625 void CAcpProviderListView::NotifyDownloadingSISCompleted( TDesC& aFileName )
       
   626     {
       
   627     ACPLOG( "CAcpProviderListView::NotifyDownloadingSISCompleted - IN" );
       
   628     
       
   629     iTimer->StopTimer();
       
   630     iDialog->DestroyWaitNote();
       
   631     iObserver.NotifySISDownloaded( aFileName );
       
   632     
       
   633     ACPLOG( "CAcpProviderListView::NotifyDownloadingSISCompleted - OUT" );
       
   634     }
       
   635 
       
   636 // ---------------------------------------------------------------------------
       
   637 // CAcpQueryView::NotifyProvisioningCompleted
       
   638 // From MAcpControllerObserver.
       
   639 // ---------------------------------------------------------------------------
       
   640 //
       
   641 void CAcpProviderListView::NotifyProvisioningCompleted()
       
   642     {
       
   643     ACPLOG( "CAcpProviderListView::NotifyProvisioningCompleted" );
       
   644 
       
   645     // Keep dialog in screen for additional time to give tab time
       
   646     // to shut down phonebook before attempting to open it again.
       
   647     iTimer->StartTimer(  CAcpTimer::EPhonebookStartupDelayTimer );
       
   648     }
       
   649 
       
   650 // ---------------------------------------------------------------------------
       
   651 // CAcpQueryView::DoNotifyProvisioningCompletedL
       
   652 // Informs that service settings have been saved.
       
   653 // ---------------------------------------------------------------------------
       
   654 //
       
   655 void CAcpProviderListView::DoNotifyProvisioningCompletedL()
       
   656     {
       
   657     ACPLOG( "CAcpProviderListView::DoNotifyProvisioningCompletedL begin" );
       
   658             
       
   659     ACPLOG( "   --> get new service id" );
       
   660     
       
   661     // Get service id of the newly provisioned service.
       
   662     RArray<TServiceId> newServiceIds;
       
   663     CleanupClosePushL( newServiceIds );
       
   664     iSpSettings->FindServiceIdsL( newServiceIds );
       
   665     
       
   666     TServiceId serviceId( 0 );
       
   667     for ( TInt i = 0; i < newServiceIds.Count(); i++ )
       
   668         {
       
   669         if ( KErrNotFound == iServiceIds.Find( newServiceIds[i] ) )
       
   670             {
       
   671             ACPLOG( "   --> new service id found" );
       
   672             
       
   673             serviceId = newServiceIds[i];
       
   674             break;
       
   675             }
       
   676         }
       
   677     
       
   678     CleanupStack::PopAndDestroy( &newServiceIds );
       
   679     
       
   680     if ( !serviceId )
       
   681         {
       
   682         ACPLOG( " - no new service id found" );
       
   683         // Remove wait note and leave
       
   684         iDialog->DestroyWaitNote();
       
   685         User::Leave( KErrNotFound );
       
   686         }
       
   687     
       
   688     // Get new view id
       
   689     TInt err( KErrNone );
       
   690     TInt tabViewCount( 0 );
       
   691     TInt newTabViewId( 0 );
       
   692     RArray<TInt32> tabViewIds;
       
   693     CleanupClosePushL( tabViewIds );
       
   694     
       
   695     ACPLOG( " - open view services" );
       
   696     
       
   697     err = iXspViewServices.Open();
       
   698     
       
   699     ACPLOG2( " - open view services ERR=%d", err );
       
   700          
       
   701     err = iXspViewServices.GetViewCount( tabViewCount );
       
   702     
       
   703     ACPLOG2( " - get view count: %d", tabViewCount );
       
   704         
       
   705     for( TInt i( 0 ) ; i < tabViewCount && !err ; i++ )
       
   706         {
       
   707         TInt bufferLength( 0 );
       
   708         err = iXspViewServices.GetPackedViewDataBufferLength(
       
   709                 i, bufferLength );
       
   710             
       
   711         if( !err && bufferLength > 0 )
       
   712             {
       
   713             HBufC8* packed = HBufC8::NewLC( bufferLength );
       
   714             TPtr8 packedPtr = packed->Des();
       
   715                 
       
   716             err = iXspViewServices.GetPackedViewData( i, packedPtr );
       
   717                 
       
   718             if( !err )
       
   719                 {     
       
   720                 CxSPViewData* viewData = CxSPViewData::NewL( *packed );
       
   721                 CleanupStack::PushL( viewData );
       
   722                     
       
   723                 ACPLOG2( "  --> VIEW ID: %d", viewData->OriginalViewId() );
       
   724                     
       
   725                 tabViewIds.AppendL( viewData->OriginalViewId() );
       
   726                 CleanupStack::PopAndDestroy( viewData );    
       
   727                 }                                               
       
   728             CleanupStack::PopAndDestroy( packed );
       
   729             }
       
   730         }
       
   731     
       
   732     for ( TInt i = 0; i < tabViewIds.Count(); i++ )
       
   733         {
       
   734         if ( KErrNotFound == iTabViewIds.Find( tabViewIds[ i ] ) )
       
   735             {
       
   736             ACPLOG( "   --> new tab view id found" );
       
   737                 
       
   738             newTabViewId = tabViewIds[ i ];
       
   739             break;
       
   740             }
       
   741         }
       
   742     
       
   743     CleanupStack::PopAndDestroy( &tabViewIds );
       
   744     
       
   745     if ( !newTabViewId )
       
   746         {
       
   747         ACPLOG( " - no new tab view id found" );
       
   748         // Remove wait note and leave
       
   749         iDialog->DestroyWaitNote();
       
   750         User::Leave( KErrNotFound );
       
   751         }
       
   752      
       
   753     // Save account creation URL for the service.
       
   754     SaveAccountCreationUrlL( serviceId );
       
   755                
       
   756     // Remove wait note
       
   757     iDialog->DestroyWaitNote();
       
   758     
       
   759     // Show message query that informs service is installed
       
   760     if ( iLaunchedFromAI )
       
   761         {
       
   762         // If service installation was started from service widget
       
   763         // in homescreen.       
       
   764         iDialog->ShowMessageQueryL( 
       
   765             R_ACP_SERVICE_INSTALLED_FROM_WIDGET_NOTE,
       
   766             *iServiceName );
       
   767         }
       
   768     else
       
   769         {
       
   770         iDialog->ShowGlobalNoteL( 
       
   771             R_ACP_SERVICE_INSTALLED_NOTE,
       
   772             *iServiceName );
       
   773         }
       
   774          
       
   775     err = iXspViewServices.Activate( KPhoneBookTabUid.iUid, newTabViewId );
       
   776     
       
   777     ACPLOG2( " - activate phonebook tab ERR=%d", err );
       
   778     User::LeaveIfError( err );
       
   779     
       
   780     iXspViewServices.Close();
       
   781     
       
   782     ACPLOG( "CAcpProviderListView::DoNotifyProvisioningCompletedL end" );
       
   783     }
       
   784 
       
   785 // ---------------------------------------------------------------------------
       
   786 // CAcpProviderListView::SaveAccountCreationUrlL
       
   787 // For saving account creation url to rcse.
       
   788 // ---------------------------------------------------------------------------
       
   789 // 
       
   790 void CAcpProviderListView::SaveAccountCreationUrlL( TUint aServiceId )
       
   791     {
       
   792     TBuf8<KMaxUrlLength> creationUrl;
       
   793        
       
   794     // Get activation URL. Insert session id if needed.
       
   795     if ( iController->SessionId().Length() )
       
   796         {
       
   797         // Change http://address?param=value to
       
   798         //        http://adress;jsessionid=[sessionid]?param=value
       
   799 
       
   800         TPtrC8 provCreUrl = iController->
       
   801             ProviderCreationUrlFromIndexL( iController->ActiveIndex() );
       
   802            
       
   803         if ( KErrNotFound == provCreUrl.Find( KSessionId ) )
       
   804             {
       
   805             // Find ? and insert the session id part before it.
       
   806             TInt qmIndex = provCreUrl.Find( KQuestionMark8 );
       
   807             if ( KErrNotFound != qmIndex )
       
   808                 {
       
   809                 creationUrl.Append( provCreUrl.Mid( 0, qmIndex ) );
       
   810                 creationUrl.Append( KSessionId );
       
   811                 creationUrl.Append( iController->SessionId() );
       
   812                 creationUrl.Append( provCreUrl.Mid( qmIndex ) );
       
   813                 }
       
   814             }
       
   815         else
       
   816             {
       
   817             creationUrl.Copy( provCreUrl );
       
   818             }
       
   819         }
       
   820        
       
   821     CRCSEProfileRegistry* rcseRegistry = CRCSEProfileRegistry::NewLC();
       
   822     RPointerArray<CRCSEProfileEntry> entries;
       
   823     CleanupStack::PushL( TCleanupItem( CleanupResetAndDestroy, &entries ) );
       
   824        
       
   825     rcseRegistry->FindByServiceIdL( aServiceId, entries );
       
   826     if ( entries.Count() )
       
   827         {
       
   828         CRCSEProfileEntry* entry = entries[0];
       
   829         entry->iAccountCreationUrl.Copy( creationUrl );
       
   830            
       
   831         rcseRegistry->UpdateL( entry->iId, *entry );
       
   832         }
       
   833     else
       
   834         {
       
   835         User::Leave( KErrNotFound );
       
   836         }
       
   837        
       
   838     CleanupStack::PopAndDestroy( 2, rcseRegistry );
       
   839     }
       
   840     
       
   841 // ---------------------------------------------------------------------------
       
   842 // From MAcpControllerObserver.
       
   843 // NotifySettingsSaved
       
   844 // ---------------------------------------------------------------------------
       
   845 //
       
   846 void CAcpProviderListView::NotifySettingsSaved()
       
   847     {
       
   848     ACPLOG( "CAcpProviderListView::NotifySettingsSaved" );
       
   849 
       
   850     if ( !iTimer->IsActive() || !iDialog->IsActive() )
       
   851         {
       
   852         // Close only if timer is not active, if active
       
   853         // message query is being shown. Closing will be done when user
       
   854         // dismissed query.
       
   855         
       
   856         ACPLOG( "CAcpProviderListView::NotifySettingsSaved - EXIT" );
       
   857         
       
   858         TRAP_IGNORE( AppUi()->ProcessCommandL( EAknCmdExit ) )
       
   859         }
       
   860     }
       
   861 
       
   862 // ---------------------------------------------------------------------------
       
   863 // From MAcpTimerObserver.
       
   864 // TimerExpired
       
   865 // ---------------------------------------------------------------------------
       
   866 //
       
   867 void CAcpProviderListView::TimerExpired()
       
   868     {
       
   869     ACPLOG( "CAcpProviderListView::TimerExpired" );
       
   870         
       
   871     // Handle provisioning completed
       
   872     TRAPD( err, DoNotifyProvisioningCompletedL() )
       
   873     
       
   874     if ( err )
       
   875         {
       
   876         ACPLOG2( "CAcpProviderListView::TimerExpired - ERR=%d", err );
       
   877         
       
   878         TRAP_IGNORE( AppUi()->ProcessCommandL( EAknCmdExit ) )
       
   879         }
       
   880     }
       
   881 
       
   882 // End of file.