ipsservices/ipssossettings/src/ipssetgwizardadapter.cpp
branchRCL_3
changeset 18 6b8f3b30d0ec
parent 16 b5fbb9b25d57
equal deleted inserted replaced
17:67369d1b217f 18:6b8f3b30d0ec
    18 
    18 
    19 //INCLUDES
    19 //INCLUDES
    20 #include "emailtrace.h"
    20 #include "emailtrace.h"
    21 #include <e32base.h>
    21 #include <e32base.h>
    22 #include <SendUiConsts.h>
    22 #include <SendUiConsts.h>
    23 //<cmail>
       
    24 //#include <aplistitemlist.h>         // CApListItemList
       
    25 //#include <aplistitem.h>             // CApListItem
       
    26 //</cmail>
       
    27 #include <centralrepository.h>      // CRepository
    23 #include <centralrepository.h>      // CRepository
    28 #include <AlwaysOnlineManagerClient.h>
    24 #include <AlwaysOnlineManagerClient.h>
    29 #include <cmdestination.h> 
    25 #include <cmdestination.h> 
    30 
    26 
    31 #include "ipssetwizardadapter.h"
    27 #include "ipssetwizardadapter.h"
   129     iProviderOutgoingPort = 0;
   125     iProviderOutgoingPort = 0;
   130     iOperatorOutgoingServer.Zero();
   126     iOperatorOutgoingServer.Zero();
   131     iOperatorOutSecurityAuth = 0;
   127     iOperatorOutSecurityAuth = 0;
   132     iOperatorOutSecurityProtocol = 0;
   128     iOperatorOutSecurityProtocol = 0;
   133     iOperatorOutgoingPort = 0;
   129     iOperatorOutgoingPort = 0;
   134     //<cmail>
       
   135     iHiddenData = EFalse;
   130     iHiddenData = EFalse;
   136     //</cmail>
       
   137     iRecomendedAP.Zero();
   131     iRecomendedAP.Zero();
   138     iMailboxName.Zero();
   132     iMailboxName.Zero();
   139     }
   133     }
   140 
   134 
   141 // ---------------------------------------------------------------------------
   135 // ---------------------------------------------------------------------------
   142 // ---------------------------------------------------------------------------
   136 // ---------------------------------------------------------------------------
   143 void CIpsSetWizardAdapter::ReadWizardSettignsL()
   137 void CIpsSetWizardAdapter::ReadWizardSettignsL()
   144     {
   138     {
   145     FUNC_LOG;
   139     FUNC_LOG;
   146     ClearFields();
   140     ClearFields();
   147     
       
   148     //<cmail>
       
   149     
   141     
   150     TIpsSetUtilsTextPlain tempText;
   142     TIpsSetUtilsTextPlain tempText;
   151     TInt error = KErrNone;
   143     TInt error = KErrNone;
   152      
   144      
   153     error = GetIntFromCenRepL( ECRKAccountsConfigured, iAccountNumber );
   145     error = GetIntFromCenRepL( ECRKAccountsConfigured, iAccountNumber );
   293         tempText = KCRKPopImapMailboxNameDefault;
   285         tempText = KCRKPopImapMailboxNameDefault;
   294         }
   286         }
   295     ChangeUnicodePrintable( tempText, iMailboxName );
   287     ChangeUnicodePrintable( tempText, iMailboxName );
   296     
   288     
   297     EmptyWizardCenRep();
   289     EmptyWizardCenRep();
   298     //</cmail>
       
   299     
       
   300     } 
   290     } 
   301 // ---------------------------------------------------------------------------
   291 // ---------------------------------------------------------------------------
   302 // ---------------------------------------------------------------------------
   292 // ---------------------------------------------------------------------------
   303 TInt CIpsSetWizardAdapter::GetIntFromCenRepL( TIpsSetWizardSettings aSetting, 
   293 TInt CIpsSetWizardAdapter::GetIntFromCenRepL( TIpsSetWizardSettings aSetting, 
   304                                               TInt& aVariable )
   294                                               TInt& aVariable )
   305     {
   295     {
   306     FUNC_LOG;
   296     FUNC_LOG;
   307 	if ( &iWizardCenRep )
   297     if ( &iWizardCenRep )
   308 		{
   298         {
   309     	return iWizardCenRep.Get( aSetting, aVariable );
   299         return iWizardCenRep.Get( aSetting, aVariable );
   310 		}
   300         }
   311 	return KErrNone;
   301     return KErrNone;
   312     }
   302     }
   313         
   303         
   314         
   304         
   315 // ---------------------------------------------------------------------------
   305 // ---------------------------------------------------------------------------
   316 // ---------------------------------------------------------------------------
   306 // ---------------------------------------------------------------------------
   317 TInt CIpsSetWizardAdapter::GetTextFromCenRepL( TIpsSetWizardSettings aSetting, 
   307 TInt CIpsSetWizardAdapter::GetTextFromCenRepL( TIpsSetWizardSettings aSetting, 
   318                                  TIpsSetUtilsTextPlain& aVariable )
   308                                  TIpsSetUtilsTextPlain& aVariable )
   319     {
   309     {
   320     FUNC_LOG;
   310     FUNC_LOG;
   321 	if ( &iWizardCenRep )
   311     if ( &iWizardCenRep )
   322 		{
   312         {
   323     	return iWizardCenRep.Get( aSetting, aVariable );
   313         return iWizardCenRep.Get( aSetting, aVariable );
   324 		}
   314         }
   325 	return KErrNone;
   315     return KErrNone;
   326     }
   316     }
   327     
   317     
   328 // ---------------------------------------------------------------------------
   318 // ---------------------------------------------------------------------------
   329 // ---------------------------------------------------------------------------
   319 // ---------------------------------------------------------------------------
   330 void CIpsSetWizardAdapter::EmptyWizardCenRep()
   320 void CIpsSetWizardAdapter::EmptyWizardCenRep()
   331     {
   321     {
   332     FUNC_LOG;
   322     FUNC_LOG;
   333     // error is used in debug purposes
   323     if ( &iWizardCenRep )
   334     // <cmail>TInt error = KErrNone; Removed since it is not used.</cmail>
   324         {
   335 	if ( &iWizardCenRep )
   325         iWizardCenRep.Set( ECRKPopImapEmailAddressId, KNullDesC );
   336 		{
   326         iWizardCenRep.Set( ECRKPopImapUsernameId, KNullDesC );
   337 	    iWizardCenRep.Set( ECRKPopImapEmailAddressId, KNullDesC );
   327         iWizardCenRep.Set( ECRKPopImapPasswordId, KNullDesC );
   338 	    iWizardCenRep.Set( ECRKPopImapUsernameId, KNullDesC );
   328         iWizardCenRep.Set( ECRKPopImapIncomingServerId, KNullDesC );
   339 	    iWizardCenRep.Set( ECRKPopImapPasswordId, KNullDesC );
   329         iWizardCenRep.Set( 
   340 	    iWizardCenRep.Set( ECRKPopImapIncomingServerId, KNullDesC );
   330                 ECRKPopImapProtocolIndicatorId, KErrNotFound );
   341 	    iWizardCenRep.Set( 
   331         iWizardCenRep.Set( 
   342 	            ECRKPopImapProtocolIndicatorId, KErrNotFound );
   332                 ECRKPopImapIncomingSecurityAuthId, KErrNotFound );
   343 	    iWizardCenRep.Set( 
   333         iWizardCenRep.Set( 
   344 	            ECRKPopImapIncomingSecurityAuthId, KErrNotFound );
   334                 ECRKPopImapIncomingSecurityProtocolId, KErrNotFound );
   345 	    iWizardCenRep.Set( 
   335         iWizardCenRep.Set( ECRKPopImapIncomingPortId, KErrNotFound );
   346 	            ECRKPopImapIncomingSecurityProtocolId, KErrNotFound );
   336         iWizardCenRep.Set( ECRKPopImapOutgoingServerId, KNullDesC );
   347 	    iWizardCenRep.Set( ECRKPopImapIncomingPortId, KErrNotFound );
   337         iWizardCenRep.Set( 
   348 	    iWizardCenRep.Set( ECRKPopImapOutgoingServerId, KNullDesC );
   338                 ECRKPopImapOutgoingSecurityAuthId, KErrNotFound );
   349 	    iWizardCenRep.Set( 
   339         iWizardCenRep.Set( 
   350 	            ECRKPopImapOutgoingSecurityAuthId, KErrNotFound );
   340                 ECRKPopImapOutgoingSecurityProtocolId, KErrNotFound );
   351 	    iWizardCenRep.Set( 
   341         iWizardCenRep.Set( ECRKPopImapOutgoingPortId, KErrNotFound );
   352 	            ECRKPopImapOutgoingSecurityProtocolId, KErrNotFound );
   342         iWizardCenRep.Set( 
   353 	    iWizardCenRep.Set( ECRKPopImapOutgoingPortId, KErrNotFound );
   343                 ECRKPopImapOperatorOutgoingServerId, KNullDesC );
   354 	    iWizardCenRep.Set( 
   344         iWizardCenRep.Set( 
   355 	            ECRKPopImapOperatorOutgoingServerId, KNullDesC );
   345                 ECRKPopImapOperatorSecurityAuthId, KErrNotFound );
   356 	    iWizardCenRep.Set( 
   346         iWizardCenRep.Set( 
   357 	            ECRKPopImapOperatorSecurityAuthId, KErrNotFound );
   347                 ECRKPopImapOperatorSecurityProtocolId, KErrNotFound );
   358 	    iWizardCenRep.Set( 
   348         iWizardCenRep.Set( ECRKPopImapOperatorPortId, KErrNotFound );
   359 	            ECRKPopImapOperatorSecurityProtocolId, KErrNotFound );
   349         iWizardCenRep.Set( ECRKPopImapAccessPointId, KNullDesC );  
   360 	    iWizardCenRep.Set( ECRKPopImapOperatorPortId, KErrNotFound );
   350         iWizardCenRep.Set( ECRKPopImapMailboxName, KNullDesC );  
   361 	    iWizardCenRep.Set( ECRKPopImapAccessPointId, KNullDesC );  
   351         }
   362 	    iWizardCenRep.Set( ECRKPopImapMailboxName, KNullDesC );  
       
   363 		}
       
   364     
       
   365     }
   352     }
   366 
   353 
   367 // ---------------------------------------------------------------------------
   354 // ---------------------------------------------------------------------------
   368 // ---------------------------------------------------------------------------
   355 // ---------------------------------------------------------------------------
   369 void CIpsSetWizardAdapter::SetSettingsL( CIpsSetData& aSetData )
   356 void CIpsSetWizardAdapter::SetSettingsL( CIpsSetData& aSetData )
   374     TSecurityValue security;
   361     TSecurityValue security;
   375     
   362     
   376     aSetData.SetProtocol( 
   363     aSetData.SetProtocol( 
   377         (iProtocol == 0) ? KSenduiMtmPop3Uid : KSenduiMtmImap4Uid );
   364         (iProtocol == 0) ? KSenduiMtmPop3Uid : KSenduiMtmImap4Uid );
   378         
   365         
   379   //<cmail>
       
   380     if(iProtocol == 0)// KSenduiMtmPop3Uid - for Pop account- default is Headers Only
   366     if(iProtocol == 0)// KSenduiMtmPop3Uid - for Pop account- default is Headers Only
   381     	{
   367         {
   382         aSetData.SetDownloadSizeL( CIpsSetData::EHeaders,KIpsSetDataHeadersOnly);
   368         aSetData.SetDownloadSizeL( CIpsSetData::EHeaders,KIpsSetDataHeadersOnly);
   383         }
   369         }
   384     else 
   370     else 
   385     	{
   371         {
   386     	aSetData.SetDownloadSizeL( CIpsSetData::EHeadersPlus, KIpsSetDataDefaultDownloadSizeKb );
   372         aSetData.SetDownloadSizeL( CIpsSetData::EHeadersPlus, KIpsSetDataDefaultDownloadSizeKb );
   387 
   373 
   388     	TInt retImFolders = aSetData.RetrieveLimit(CIpsSetData::EImap4Folders); //TRetrieveLimit
   374         TInt retImFolders = aSetData.RetrieveLimit(CIpsSetData::EImap4Folders); //TRetrieveLimit
   389         if(retImFolders==-1)
   375         if(retImFolders==-1)
   390         	{
   376             {
   391             TInt retPopInbox = aSetData.RetrieveLimit(CIpsSetData::EPop3Limit); 
   377             TInt retPopInbox = aSetData.RetrieveLimit(CIpsSetData::EPop3Limit); 
   392            	TInt retImInbox  = aSetData.RetrieveLimit(CIpsSetData::EImap4Inbox); 
   378             TInt retImInbox  = aSetData.RetrieveLimit(CIpsSetData::EImap4Inbox); 
   393             aSetData.SetRetrieveLimit(retPopInbox,retImInbox,KImapDefFoldersRetrieve);
   379             aSetData.SetRetrieveLimit(retPopInbox,retImInbox,KImapDefFoldersRetrieve);
   394         	}
   380             }
   395         }
   381         }
   396     //</cmail>
       
   397     aSetData.SetEmailAddressL( iEmailAddress );
   382     aSetData.SetEmailAddressL( iEmailAddress );
   398     aSetData.SetUserNameL( iUsername, iUsername );
   383     aSetData.SetUserNameL( iUsername, iUsername );
   399     aSetData.SetUserPwdL( iPassword, iPassword );
   384     aSetData.SetUserPwdL( iPassword, iPassword );
   400     aSetData.SetMailServerL( iIncomingServer, iProviderOutgoingServer );
   385     aSetData.SetMailServerL( iIncomingServer, iProviderOutgoingServer );
   401     
   386     
   406                             iInIncomingPort, 
   391                             iInIncomingPort, 
   407                             iProviderOutgoingPort, 
   392                             iProviderOutgoingPort, 
   408                             security );
   393                             security );
   409     aSetData.SetPort( port.inport, port.outport );                             
   394     aSetData.SetPort( port.inport, port.outport );                             
   410     
   395     
   411     //<cmail>
       
   412     aSetData.SetDataHide( iHiddenData );
   396     aSetData.SetDataHide( iHiddenData );
   413     //</cmail>
       
   414     aSetData.SetMailboxName( CheckMailboxNamesL( iMailboxName ) );
   397     aSetData.SetMailboxName( CheckMailboxNamesL( iMailboxName ) );
   415     aSetData.SetUserAuthentication( CIpsSetData::EUseIncoming );
   398     aSetData.SetUserAuthentication( CIpsSetData::EUseIncoming );
   416 
   399 
   417     iap = SetIAPByNameL( iRecomendedAP );
   400     iap = SetIAPByNameL( iRecomendedAP );
   418     
   401     
   419     TBool setIAP = ETrue;
   402     TBool setIAP = ETrue;
   420 	//if IAP isn't set by SettingWizard, we try to get the SNAP.
   403 
       
   404     RCmManager cmmgr;
       
   405     cmmgr.OpenLC();
       
   406     TCmDefConnValue defConnValue;
       
   407     cmmgr.ReadDefConnL( defConnValue );
       
   408 
       
   409     //if IAP isn't set by SettingWizard, we try to get the SNAP.
   421     if ( iap.iIAP <= 0 )
   410     if ( iap.iIAP <= 0 )
   422         {
   411         {
   423         //Use SNAP when we got it and it does contain access point.
   412         //Use SNAP when we got it and it does contain access point.
   424         //For other situations as below, we set 'ask when need' or default IAP
   413         //For other situations as below, we set 'ask when need' or default IAP
   425         //1. defConnValue.iType == ECmDefConnAskOnce
   414         //1. defConnValue.iType == ECmDefConnAskOnce
   426         //2. Got SNAP, but it does not contain any acess point
   415         //2. Got SNAP, but it does not contain any access point
   427         //3. Got default IAP when defConnValue.iType == ECmDefConnConnectionMethod
   416         //3. Got default IAP when defConnValue.iType == ECmDefConnConnectionMethod
   428         iap.iDialogPref = ECommDbDialogPrefPrompt;
   417         iap.iDialogPref = ECommDbDialogPrefPrompt;
   429         iap.iIAP = 0;		 
   418         iap.iIAP = 0;        
   430 
   419 
   431         RCmManager cmmgr;
   420         //Check default connection is destination or connection method
   432         cmmgr.OpenLC();
       
   433         TCmDefConnValue defConnValue;
       
   434         cmmgr.ReadDefConnL( defConnValue );
       
   435 		//Check default connection is destination or connection method
       
   436         if ( defConnValue.iType == ECmDefConnDestination )
   421         if ( defConnValue.iType == ECmDefConnDestination )
   437             {
   422             {
   438             //Get SNAP from cmmgr
   423             //Get SNAP from cmmgr
   439             RCmDestination destination;
   424             RCmDestination destination;
   440             CleanupClosePushL( destination );
   425             CleanupClosePushL( destination );
   441             destination = cmmgr.DestinationL( defConnValue.iId );
   426             destination = cmmgr.DestinationL( defConnValue.iId );
   442 			//check if SNAP has IAPs
   427             //check if SNAP has IAPs
   443             if ( destination.ConnectionMethodCount() > 0 )
   428             if ( destination.ConnectionMethodCount() > 0 )
   444                 {
   429                 {
   445                 //if SNAP contain access point, we use SNAP
   430                 //if SNAP contain access point, we use SNAP
   446                 CImIAPPreferences* iapPref = CImIAPPreferences::NewLC();
   431                 CImIAPPreferences* iapPref = CImIAPPreferences::NewLC();
   447                 iapPref->SetSNAPL( defConnValue.iId );
   432                 iapPref->SetSNAPL( defConnValue.iId );
   448               
   433               
   449                 aSetData.SetIapL( *iapPref, *iapPref );
   434                 aSetData.SetIapL( *iapPref, *iapPref );
   450                 CleanupStack::PopAndDestroy( iapPref );
   435                 CleanupStack::PopAndDestroy( iapPref );
   451 				 
   436                  
   452                 setIAP = EFalse;
   437                 setIAP = EFalse;
   453                 }
   438                 }
   454                 CleanupStack::PopAndDestroy( &destination );			 
   439                 CleanupStack::PopAndDestroy( &destination );             
   455             }
   440             }
   456         else if( defConnValue.iType == ECmDefConnConnectionMethod ) 
   441         else if( defConnValue.iType == ECmDefConnConnectionMethod ) 
   457             {
   442             {
   458             iap.iDialogPref = ECommDbDialogPrefDoNotPrompt;
   443             iap.iDialogPref = ECommDbDialogPrefDoNotPrompt;
   459             iap.iIAP = defConnValue.iId;
   444             iap.iIAP = defConnValue.iId;
   460             }
   445             }
   461         CleanupStack::PopAndDestroy( &cmmgr );
   446         }
   462         }
   447     else
   463 		//If no valid IAP or destination, set zero.
   448         {
       
   449         // recommended IAP is defined
       
   450         // try setting SNAP that contains the IAP
       
   451         TBool found( EFalse );
       
   452         RArray< TUint32 > destArray;
       
   453         CleanupClosePushL( destArray );
       
   454      
       
   455         //Get list of all destinations
       
   456         cmmgr.AllDestinationsL( destArray );
       
   457      
       
   458         TInt arrayCount( destArray.Count() );
       
   459 
       
   460         CMManager::TSnapMetadataField metaFieldPurpose( CMManager::ESnapMetadataPurpose );
       
   461         CMManager::TSnapMetadataField metaFieldLocalized( CMManager::ESnapMetadataDestinationIsLocalised );
       
   462 
       
   463         //Traverse list of destinations
       
   464         for ( TInt i = 0; i < arrayCount && !found; ++i )
       
   465             {
       
   466             RCmDestination destination = cmmgr.DestinationL( destArray[ i ] );
       
   467             CleanupClosePushL( destination );
       
   468             
       
   469             TUint32  destinationPurpose = destination.MetadataL ( metaFieldPurpose );
       
   470             TUint32  destinationLocalized = destination.MetadataL ( metaFieldLocalized );
       
   471             
       
   472             TInt iapCount ( destination.ConnectionMethodCount() );
       
   473             if ( destinationPurpose == CMManager::ESnapPurposeInternet &&
       
   474                  destinationLocalized == CMManager::ELocalisedDestInternet && 
       
   475                  iapCount )
       
   476                 {
       
   477                 // found the Internet destination and it has at least one access point
       
   478                 for ( TInt c=0;c < iapCount && !found; c++ )
       
   479                     {
       
   480                     RCmConnectionMethod connMethod = destination.ConnectionMethodL( c );
       
   481                     CleanupClosePushL( connMethod );
       
   482                     
       
   483                     TUint32 iapId = connMethod.GetIntAttributeL( CMManager::ECmIapId );
       
   484                     HBufC* connName = connMethod.GetStringAttributeL( CMManager::ECmName );
       
   485                     CleanupStack::PushL( connName );
       
   486                     CleanupStack::PopAndDestroy( connName ); 
       
   487                     if ( iapId == iap.iIAP )
       
   488                         {
       
   489                         CImIAPPreferences* iapPref = CImIAPPreferences::NewLC();
       
   490                         INFO_1( "Setting SNAP %d by IAP", destination.Id() )
       
   491                         iapPref->SetSNAPL( destination.Id());
       
   492                         aSetData.SetIapL( *iapPref, *iapPref );   
       
   493                         found = ETrue;
       
   494                         setIAP = EFalse;
       
   495                         CleanupStack::PopAndDestroy( iapPref );
       
   496                         }
       
   497                     CleanupStack::PopAndDestroy( &connMethod ); 
       
   498                     }
       
   499                 }
       
   500             CleanupStack::PopAndDestroy( &destination );
       
   501             }
       
   502         CleanupStack::PopAndDestroy( &destArray );
       
   503         }    
       
   504 
       
   505         //If no valid IAP or destination, set zero.
   464         if ( setIAP )
   506         if ( setIAP )
   465             {
   507             {
   466             aSetData.SetIapL( iap, iap );		 		 
   508             INFO_1( "IAP is uncategorized, using IAP: %d", iap.iIAP )
   467             }
   509             aSetData.SetIapL( iap, iap );                
   468     // EIpsSetDataOutSecurityAuth
   510             }
   469     // EIpsSetDataOutSecurityAuth
   511     CleanupStack::PopAndDestroy( &cmmgr );
   470     }
   512     }
   471 
   513 
   472 // ---------------------------------------------------------------------------
   514 // ---------------------------------------------------------------------------
   473 // ---------------------------------------------------------------------------
   515 // ---------------------------------------------------------------------------
   474 TSecurityValue CIpsSetWizardAdapter::SetSecurityValues( 
   516 TSecurityValue CIpsSetWizardAdapter::SetSecurityValues( 
   568     TBuf<KWizardMaxUidValue> buf;
   610     TBuf<KWizardMaxUidValue> buf;
   569     CIpsSetUiItemAccessPoint* ipsSetAP = CIpsSetUiItemAccessPoint::NewLC();
   611     CIpsSetUiItemAccessPoint* ipsSetAP = CIpsSetUiItemAccessPoint::NewLC();
   570     //Initial IAP list
   612     //Initial IAP list
   571     ipsSetAP->InitializeSelectionL();
   613     ipsSetAP->InitializeSelectionL();
   572     
   614     
   573     //<cmail>
       
   574     iapcount = ipsSetAP->iIapList.Count();
   615     iapcount = ipsSetAP->iIapList.Count();
   575     //</cmail>
       
   576 
   616 
   577     //Set default AP to always ask
   617     //Set default AP to always ask
   578     iap.iDialogPref = ECommDbDialogPrefPrompt;
   618     iap.iDialogPref = ECommDbDialogPrefPrompt;
   579     iap.iIAP = 0;   
   619     iap.iIAP = 0;   
   580 
   620 
   581     //run through all found access points
   621     //run through all found access points
   582 	//<cmail>
       
   583     TBool found( EFalse );
   622     TBool found( EFalse );
   584     for( TInt i = 0;!found &&  i < iapcount; i++ )
   623     for( TInt i = 0;!found &&  i < iapcount; i++ )
   585         {
   624         {
   586         HBufC* name( ipsSetAP->AccessPointNameLC( i ) );
   625         HBufC* name( ipsSetAP->AccessPointNameLC( i ) );
   587         // If AP stored in cenrep key as UID value, we need to do
   626         // If AP stored in cenrep key as UID value, we need to do
   596             iap.iDialogPref = ECommDbDialogPrefDoNotPrompt;
   635             iap.iDialogPref = ECommDbDialogPrefDoNotPrompt;
   597             iap.iIAP = ipsSetAP->iIapList[i];
   636             iap.iIAP = ipsSetAP->iIapList[i];
   598             }
   637             }
   599         CleanupStack::PopAndDestroy( name );
   638         CleanupStack::PopAndDestroy( name );
   600         }
   639         }
   601 	//</cmail>
       
   602     CleanupStack::PopAndDestroy( ipsSetAP );
   640     CleanupStack::PopAndDestroy( ipsSetAP );
   603     return iap;
   641     return iap;
   604     }
   642     }
   605     
   643     
   606 // ---------------------------------------------------------------------------
   644 // ---------------------------------------------------------------------------
   619     RArray<TSmtpAccount> RIpsSmtpArray;        
   657     RArray<TSmtpAccount> RIpsSmtpArray;        
   620     accounts->GetSmtpAccountsL( RIpsSmtpArray );
   658     accounts->GetSmtpAccountsL( RIpsSmtpArray );
   621     accountcount = RIpsSmtpArray.Count();
   659     accountcount = RIpsSmtpArray.Count();
   622 
   660 
   623     //increase mailbox count
   661     //increase mailbox count
   624 	if ( &iWizardCenRep )
   662     if ( &iWizardCenRep )
   625 		{ 
   663         { 
   626     	iWizardCenRep.Set( ECRKAccountsConfigured, accountcount );
   664         iWizardCenRep.Set( ECRKAccountsConfigured, accountcount );
   627 		}
   665         }
   628     
   666     
   629     if( accountcount >= KMaxMailboxes && &iWizardCenRep )
   667     if( accountcount >= KMaxMailboxes && &iWizardCenRep )
   630         {
   668         {
   631         iWizardCenRep.Set( ECRKMaxAccountsReached, ETrue );
   669         iWizardCenRep.Set( ECRKMaxAccountsReached, ETrue );
   632         }
   670         }
   634     RIpsSmtpArray.Close();
   672     RIpsSmtpArray.Close();
   635     CleanupStack::PopAndDestroy( accounts );
   673     CleanupStack::PopAndDestroy( accounts );
   636     CleanupStack::PopAndDestroy( setManager );
   674     CleanupStack::PopAndDestroy( setManager );
   637     
   675     
   638     // notify ao about new mailbox
   676     // notify ao about new mailbox
   639 // <cmail> RD_IPS_AO_PLUGIN flag removed
       
   640     TInt mailboxId = KErrNotFound;
   677     TInt mailboxId = KErrNotFound;
   641     if ( aSetData.ExtendedSettings() )
   678     if ( aSetData.ExtendedSettings() )
   642         {
   679         {
   643         mailboxId = aSetData.ExtendedSettings()->MailboxId();
   680         mailboxId = aSetData.ExtendedSettings()->MailboxId();
   644         }
   681         }
   645     
   682     
   646     RAlwaysOnlineClientSession aosession; 
   683     RAlwaysOnlineClientSession aosession; 
   647     TInt err = aosession.Connect();
   684     TInt err = aosession.Connect();
       
   685     CleanupClosePushL( aosession );
   648     if ( mailboxId != KErrNotFound && err == KErrNone )
   686     if ( mailboxId != KErrNotFound && err == KErrNone )
   649         {
   687         {
   650         TPckgBuf<TMsvId> mboxBuf( mailboxId );
   688         TPckgBuf<TMsvId> mboxBuf( mailboxId );
   651         TRAP( err, aosession.RelayCommandL( 
   689         TRAP( err, aosession.RelayCommandL( 
   652                 EServerAPIEmailTurnOn, 
   690                 EServerAPIEmailTurnOn, 
   653                mboxBuf ) );
   691                mboxBuf ) );
   654         }
   692         }
   655     aosession.Close();
   693     CleanupStack::PopAndDestroy( &aosession );
   656 //#endif <cmail>
       
   657     }
   694     }
   658 
   695 
   659 // ---------------------------------------------------------------------------
   696 // ---------------------------------------------------------------------------
   660 // ---------------------------------------------------------------------------
   697 // ---------------------------------------------------------------------------
   661 TDes& CIpsSetWizardAdapter::CheckMailboxNamesL( TDes& aName )
   698 TDes& CIpsSetWizardAdapter::CheckMailboxNamesL( TDes& aName )
   675         TIpsSetUtilsTextPlain mailbox = 
   712         TIpsSetUtilsTextPlain mailbox = 
   676             RIpsSmtpArray[mailboxCount].iSmtpAccountName;    
   713             RIpsSmtpArray[mailboxCount].iSmtpAccountName;    
   677         
   714         
   678         if( !tempName.Compare( mailbox ) )
   715         if( !tempName.Compare( mailbox ) )
   679             {
   716             {
   680             //if mailboxname already exists increase value after name
   717             //if mailbox name already exists increase value after name
   681             tempName = aName;
   718             tempName = aName;
   682             endNumber++;
   719             endNumber++;
   683             tempName.AppendNum( endNumber );
   720             tempName.AppendNum( endNumber );
   684             //reset mailbox counter
   721             //reset mailbox counter
   685             mailboxCount = RIpsSmtpArray.Count();
   722             mailboxCount = RIpsSmtpArray.Count();