omads/omadsappui/AspSyncUtil/src/AspProfileWizardDialog.cpp
branchRCL_3
changeset 52 4f0867e42d62
equal deleted inserted replaced
51:8e7494275d3a 52:4f0867e42d62
       
     1 /*
       
     2 * Copyright (c) 2005 Nokia Corporation and/or its subsidiary(-ies). 
       
     3 * All rights reserved.
       
     4 * This component and the accompanying materials are made available
       
     5 * under the terms of "Eclipse Public License v1.0"
       
     6 * which accompanies this distribution, and is available
       
     7 * at the URL "http://www.eclipse.org/legal/epl-v10.html".
       
     8 *
       
     9 * Initial Contributors:
       
    10 * Nokia Corporation - initial contribution.
       
    11 *
       
    12 * Contributors:
       
    13 *
       
    14 * Description:  
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 // INCLUDE FILES
       
    20 #include <txtfrmat.h>
       
    21 #include <txtfmlyr.h>
       
    22 #include <gdi.h>
       
    23 // BackGround Context
       
    24 #include <AknsBasicBackgroundControlContext.h>
       
    25 
       
    26 #include "AspProfileWizardDialog.h"
       
    27 #include "AspUtil.h"
       
    28 #include "AspDialogUtil.h"
       
    29 #include "AspDebug.h"
       
    30 #include "AspSyncUtil.rh"
       
    31 
       
    32 #include <textresolver.h>
       
    33 #include <eikrted.h>  // CEikRichTextEditor
       
    34 
       
    35 
       
    36 // ============================ MEMBER FUNCTIONS ===============================
       
    37 
       
    38 
       
    39 /*******************************************************************************
       
    40  * class CAspTextSettingPage
       
    41  *******************************************************************************/
       
    42 
       
    43 
       
    44 //------------------------------------------------------------------------------
       
    45 // CAspTextSettingPage::CAspTextSettingPage
       
    46 // 
       
    47 //------------------------------------------------------------------------------
       
    48 //
       
    49 CAspTextSettingPage::CAspTextSettingPage(TInt aResourceID, TDes& aText,
       
    50                      TInt aTextSettingPageFlags, TAspSettingPageParam& aParam)
       
    51  : CAknTextSettingPage(aResourceID, aText, aTextSettingPageFlags), iParam(aParam)
       
    52 	{
       
    53 	}
       
    54 
       
    55 
       
    56 //------------------------------------------------------------------------------
       
    57 // Destructor
       
    58 // 
       
    59 //------------------------------------------------------------------------------
       
    60 //
       
    61 CAspTextSettingPage::~CAspTextSettingPage()
       
    62 	{
       
    63 	delete iNaviPaneHandler;
       
    64 	}
       
    65 
       
    66 
       
    67 // -----------------------------------------------------------------------------
       
    68 // CAspTextSettingPage::OKToExitL
       
    69 // 
       
    70 // -----------------------------------------------------------------------------
       
    71 //
       
    72 TBool CAspTextSettingPage::OkToExitL(TInt aButtonId)
       
    73 	{
       
    74 	 // command id set in ProcessCommandL
       
    75 	if (iParam.iCommandId == EAknSoftkeyOk || iParam.iCommandId == EEikBidSelect)
       
    76 		{
       
    77 		if (iParam.iObserver)
       
    78 			{
       
    79 			CEikEdwin* edwin = TextControl();
       
    80 			HBufC* hBuf = NULL;
       
    81 			TInt len = edwin->TextLength();
       
    82 			if (len == 0)
       
    83 				{
       
    84 				hBuf = HBufC::NewL(0);
       
    85 				}
       
    86 			else
       
    87 				{
       
    88 				hBuf = edwin->GetTextInHBufL();
       
    89 				}
       
    90 				
       
    91 			TBool ret = iParam.iObserver->CheckValidity(hBuf->Des(),
       
    92 			                                            iParam.iSettingType);
       
    93 			
       
    94 			delete hBuf;
       
    95 			return ret;
       
    96 			}
       
    97 		}
       
    98 
       
    99 	return  CAknTextSettingPage::OkToExitL(aButtonId);
       
   100 	}
       
   101 
       
   102 
       
   103 //------------------------------------------------------------------------------
       
   104 // CAspTextSettingPage::ProcessCommandL
       
   105 // 
       
   106 //------------------------------------------------------------------------------
       
   107 //
       
   108 void CAspTextSettingPage::ProcessCommandL(TInt aCommandId)
       
   109 	{
       
   110     iParam.iCommandId = aCommandId; // return command id to caller
       
   111     
       
   112     CAknTextSettingPage::ProcessCommandL(aCommandId);
       
   113 	}
       
   114 
       
   115 
       
   116 // ----------------------------------------------------------------------------
       
   117 // CIMSSettingsWizardEditTextPage::PostDisplayCheckL
       
   118 //
       
   119 // ----------------------------------------------------------------------------
       
   120 //
       
   121 TBool CAspTextSettingPage::PostDisplayCheckL()
       
   122     {
       
   123     // Set the text to navipane
       
   124     UpdateNaviPaneL();
       
   125 
       
   126     return ETrue;
       
   127     }
       
   128     
       
   129 // ----------------------------------------------------------------------------
       
   130 // CIMSSettingsWizardEditTextPage::UpdateIndicatorL
       
   131 //
       
   132 // ----------------------------------------------------------------------------
       
   133 //
       
   134 void CAspTextSettingPage::UpdateNaviPaneL()
       
   135     {
       
   136     
       
   137     if (!iNaviPaneHandler)
       
   138            {
       
   139            iNaviPaneHandler = new (ELeave) CAspNaviPaneHandler(
       
   140                                   iEikonEnv->AppUiFactory()->StatusPane());
       
   141            }
       
   142            
       
   143        iNaviPaneHandler->SetNaviPaneTitleL(iParam.iPageText);
       
   144     }
       
   145     
       
   146 
       
   147 // ----------------------------------------------------------------------------
       
   148 // CAspTextSettingPage::OfferKeyEventL
       
   149 //
       
   150 // ----------------------------------------------------------------------------
       
   151 //
       
   152 TKeyResponse CAspTextSettingPage::OfferKeyEventL(const TKeyEvent& aKeyEvent, 
       
   153                                                  TEventCode aType)
       
   154     {
       
   155     if(EKeyEnter == aKeyEvent.iCode)
       
   156     {
       
   157     	ProcessCommandL(EAknSoftkeyOk);
       
   158     	return EKeyWasConsumed;
       
   159     }
       
   160     if (aType == EEventKeyDown && iParam.iObserver)
       
   161         {
       
   162        	iParam.iObserver->HandleEditorEvent(
       
   163        	                  MAspEditorPageObserver::EKeyEvent, 0);
       
   164         }
       
   165         
       
   166     return CAknTextSettingPage::OfferKeyEventL(aKeyEvent, aType);
       
   167     }
       
   168 
       
   169 
       
   170 
       
   171 /*******************************************************************************
       
   172  * class CAspRadioButtonSettingPage
       
   173  *******************************************************************************/
       
   174 
       
   175 
       
   176 //------------------------------------------------------------------------------
       
   177 // CAspRadioButtonSettingPage::CAspRadioButtonSettingPage
       
   178 // 
       
   179 //------------------------------------------------------------------------------
       
   180 //
       
   181 CAspRadioButtonSettingPage::CAspRadioButtonSettingPage(TInt aResourceID,
       
   182                             TInt& aCurrentSelectionIndex,
       
   183                             const MDesCArray* aItemArray,
       
   184                             TAspSettingPageParam& aParam)
       
   185                             
       
   186  : CAknRadioButtonSettingPage(aResourceID, aCurrentSelectionIndex, aItemArray),
       
   187    iParam(aParam)
       
   188 	{
       
   189 	iItemArray = aItemArray;
       
   190 	}
       
   191 
       
   192 
       
   193 //------------------------------------------------------------------------------
       
   194 // Destructor
       
   195 // 
       
   196 //------------------------------------------------------------------------------
       
   197 //
       
   198 CAspRadioButtonSettingPage::~CAspRadioButtonSettingPage()
       
   199 	{
       
   200 	delete iNaviPaneHandler;
       
   201 	}
       
   202 
       
   203 
       
   204 //------------------------------------------------------------------------------
       
   205 // CAspRadioButtonSettingPage::ProcessCommandL
       
   206 //------------------------------------------------------------------------------
       
   207 //
       
   208 void CAspRadioButtonSettingPage::ProcessCommandL(TInt aCommandId)
       
   209 	{
       
   210     if (aCommandId == EAknSoftkeyOk || aCommandId == EEikBidSelect)
       
   211     	{
       
   212     	TInt index = ListBoxControl()->CurrentItemIndex();
       
   213     	TBuf<KBufSize> buf;
       
   214     	buf.Num(index);
       
   215     	TBool ret = iParam.iObserver->CheckValidity(buf, iParam.iSettingType);
       
   216     	}
       
   217     
       
   218     iParam.iCommandId = aCommandId; // return command id to caller
       
   219     
       
   220     CAknRadioButtonSettingPage::ProcessCommandL(aCommandId);
       
   221 	}
       
   222 
       
   223 
       
   224 // ----------------------------------------------------------------------------
       
   225 // CAspRadioButtonSettingPage::PostDisplayCheckL
       
   226 // ----------------------------------------------------------------------------
       
   227 //
       
   228 TBool CAspRadioButtonSettingPage::PostDisplayCheckL()
       
   229     {
       
   230     UpdateNaviPaneL();
       
   231 
       
   232     return ETrue;
       
   233     }
       
   234 
       
   235 
       
   236 // ----------------------------------------------------------------------------
       
   237 // CAspRadioButtonSettingPage::UpdateNaviPaneL
       
   238 // ----------------------------------------------------------------------------
       
   239 //
       
   240 void CAspRadioButtonSettingPage::UpdateNaviPaneL()
       
   241     {
       
   242     if (!iNaviPaneHandler)
       
   243     	{
       
   244     	iNaviPaneHandler = new (ELeave) CAspNaviPaneHandler(
       
   245     	                       iEikonEnv->AppUiFactory()->StatusPane());
       
   246     	}
       
   247     	
       
   248     iNaviPaneHandler->SetNaviPaneTitleL(iParam.iPageText);
       
   249     }
       
   250 
       
   251 //----------------------------------------------------------------------------
       
   252 //CAspRadioButtonSettingPage::HandleListBoxEventL
       
   253 //----------------------------------------------------------------------------
       
   254 //
       
   255 
       
   256 
       
   257 void CAspRadioButtonSettingPage::HandleListBoxEventL(CEikListBox* aListBox, TListBoxEvent aEventType)
       
   258 {
       
   259 
       
   260     TInt oldSelect = ListBoxControl()->CurrentItemIndex();
       
   261     CAknRadioButtonSettingPage::HandleListBoxEventL( aListBox, aEventType );
       
   262     if ( oldSelect != ListBoxControl()->CurrentItemIndex() )
       
   263 
       
   264     {
       
   265 
       
   266        TBuf<KBufSize> buf;
       
   267        buf.Num(oldSelect);
       
   268        TBool ret = iParam.iObserver->CheckValidity(buf, iParam.iSettingType);
       
   269     }
       
   270 }
       
   271 
       
   272 // ----------------------------------------------------------------------------
       
   273 // CAspRadioButtonSettingPage::OfferKeyEventL
       
   274 //
       
   275 // ----------------------------------------------------------------------------
       
   276 //
       
   277 TKeyResponse CAspRadioButtonSettingPage::OfferKeyEventL(const TKeyEvent& aKeyEvent, 
       
   278                                                  TEventCode aType)
       
   279     {
       
   280         if(EKeyEnter == aKeyEvent.iCode)
       
   281     {
       
   282     	ProcessCommandL(EAknSoftkeyOk);
       
   283     	return EKeyWasConsumed;
       
   284     }
       
   285     if (aType == EEventKeyDown && iParam.iObserver)
       
   286         {
       
   287        	iParam.iObserver->HandleEditorEvent(
       
   288                               MAspEditorPageObserver::EKeyEvent, 0);    
       
   289         }
       
   290         
       
   291     return CAknRadioButtonSettingPage::OfferKeyEventL(aKeyEvent, aType);
       
   292     }
       
   293 
       
   294 
       
   295 
       
   296 /*******************************************************************************
       
   297  * class CAspAlphaPasswordSettingPage
       
   298  *******************************************************************************/
       
   299 
       
   300 
       
   301 //------------------------------------------------------------------------------
       
   302 // CAspAlphaPasswordSettingPage::CAspAlphaPasswordSettingPage
       
   303 // 
       
   304 //------------------------------------------------------------------------------
       
   305 //
       
   306 CAspAlphaPasswordSettingPage::CAspAlphaPasswordSettingPage(TInt aResourceID,
       
   307                               TDes& aNewPassword, const TDesC& aOldPassword,
       
   308                               TAspSettingPageParam& aParam)
       
   309                               
       
   310  : CAknAlphaPasswordSettingPage(aResourceID, aNewPassword, aOldPassword),
       
   311    iParam(aParam)
       
   312 	{
       
   313 	}
       
   314 
       
   315 
       
   316 //------------------------------------------------------------------------------
       
   317 // Destructor
       
   318 // 
       
   319 //------------------------------------------------------------------------------
       
   320 //
       
   321 CAspAlphaPasswordSettingPage::~CAspAlphaPasswordSettingPage()
       
   322 	{
       
   323 	delete iNaviPaneHandler;
       
   324 	}
       
   325 
       
   326 
       
   327 //------------------------------------------------------------------------------
       
   328 // CAspAlphaPasswordSettingPage::ProcessCommandL
       
   329 // 
       
   330 //------------------------------------------------------------------------------
       
   331 //
       
   332 void CAspAlphaPasswordSettingPage::ProcessCommandL(TInt aCommandId)
       
   333 	{
       
   334     iParam.iCommandId = aCommandId; // return command id to caller
       
   335     
       
   336     CAknAlphaPasswordSettingPage::ProcessCommandL(aCommandId);
       
   337 	}
       
   338 
       
   339 
       
   340 // ----------------------------------------------------------------------------
       
   341 // CAspAlphaPasswordSettingPage::PostDisplayCheckL
       
   342 
       
   343 // ----------------------------------------------------------------------------
       
   344 //
       
   345 TBool CAspAlphaPasswordSettingPage::PostDisplayCheckL()
       
   346     {
       
   347     UpdateNaviPaneL();
       
   348 
       
   349     return ETrue;
       
   350     }
       
   351 
       
   352 // ----------------------------------------------------------------------------
       
   353 // CAspAlphaPasswordSettingPage::UpdateNaviPaneL
       
   354 //
       
   355 // ----------------------------------------------------------------------------
       
   356 //
       
   357 void CAspAlphaPasswordSettingPage::UpdateNaviPaneL()
       
   358     {
       
   359     
       
   360     if (!iNaviPaneHandler)
       
   361                {
       
   362                iNaviPaneHandler = new (ELeave) CAspNaviPaneHandler(
       
   363                                       iEikonEnv->AppUiFactory()->StatusPane());
       
   364                }
       
   365                
       
   366            iNaviPaneHandler->SetNaviPaneTitleL(iParam.iPageText);
       
   367     }
       
   368 
       
   369 
       
   370 // ----------------------------------------------------------------------------
       
   371 // CAspAlphaPasswordSettingPage::OfferKeyEventL
       
   372 //
       
   373 // ----------------------------------------------------------------------------
       
   374 //
       
   375 TKeyResponse CAspAlphaPasswordSettingPage::OfferKeyEventL(const TKeyEvent& aKeyEvent, 
       
   376                                                  TEventCode aType)
       
   377     {
       
   378     if (aType == EEventKeyDown && iParam.iObserver)
       
   379         {
       
   380        	iParam.iObserver->HandleEditorEvent(
       
   381                                 MAspEditorPageObserver::EKeyEvent, 0);    
       
   382         }
       
   383         
       
   384     return CAknAlphaPasswordSettingPage::OfferKeyEventL(aKeyEvent, aType);
       
   385     }
       
   386 
       
   387 
       
   388 /*******************************************************************************
       
   389  * class CAspCheckBoxSettingPage
       
   390  *******************************************************************************/
       
   391 
       
   392 
       
   393 //------------------------------------------------------------------------------
       
   394 // CAspCheckBoxSettingPage::CAspCheckBoxSettingPage
       
   395 // 
       
   396 //------------------------------------------------------------------------------
       
   397 //
       
   398 CAspCheckBoxSettingPage::CAspCheckBoxSettingPage(TInt aResourceID,
       
   399                    CSelectionItemList* aItemArray, TAspSettingPageParam& aParam)
       
   400                    
       
   401  : CAknCheckBoxSettingPage(aResourceID, aItemArray), iParam(aParam)
       
   402 	{
       
   403     iSelectionItemList = aItemArray;
       
   404 	}
       
   405 
       
   406 
       
   407 //------------------------------------------------------------------------------
       
   408 // Destructor
       
   409 // 
       
   410 //------------------------------------------------------------------------------
       
   411 //
       
   412 CAspCheckBoxSettingPage::~CAspCheckBoxSettingPage()
       
   413 	{
       
   414 	delete iNaviPaneHandler;
       
   415 	}
       
   416 
       
   417 
       
   418 //------------------------------------------------------------------------------
       
   419 // CAspCheckBoxSettingPage::ProcessCommandL
       
   420 // 
       
   421 //------------------------------------------------------------------------------
       
   422 //
       
   423 void CAspCheckBoxSettingPage::ProcessCommandL(TInt aCommandId)
       
   424 	{
       
   425     if (aCommandId == EAknSoftkeyMark)
       
   426     	{
       
   427         CAknSetStyleListBox* listbox = ListBoxControl();
       
   428         TInt index = listbox->CurrentItemIndex();
       
   429        	CSelectableItem* selectableItem = (*iSelectionItemList)[index];
       
   430        	TBuf<KBufSize> buf;
       
   431        	buf = selectableItem->ItemText();
       
   432        	
       
   433        	TBool ret = iParam.iObserver->CheckValidity(buf, iParam.iSettingType);
       
   434 			
       
   435        	if (ret)
       
   436        	
       
   437        		{
       
   438             CAknCheckBoxSettingPage::ProcessCommandL(aCommandId);
       
   439             return;
       
   440        		}
       
   441        	else
       
   442        		{
       
   443        		return;	
       
   444        		}
       
   445     	}
       
   446     
       
   447     	
       
   448     iParam.iCommandId = aCommandId; // return command id to caller
       
   449 
       
   450     CAknCheckBoxSettingPage::ProcessCommandL(aCommandId);
       
   451 	}
       
   452 
       
   453 
       
   454 // ----------------------------------------------------------------------------
       
   455 // CAspCheckBoxSettingPage::PostDisplayCheckL
       
   456 //
       
   457 // ----------------------------------------------------------------------------
       
   458 //
       
   459 TBool CAspCheckBoxSettingPage::PostDisplayCheckL()
       
   460     {
       
   461     UpdateNaviPaneL();
       
   462     
       
   463     iSelectionCount = ListBoxControl()->SelectionIndexes()->Count();
       
   464 
       
   465     return ETrue;
       
   466     }
       
   467 
       
   468 
       
   469 // ----------------------------------------------------------------------------
       
   470 // CAspCheckBoxSettingPage::UpdateNaviPaneL
       
   471 // ----------------------------------------------------------------------------
       
   472 //
       
   473 void CAspCheckBoxSettingPage::UpdateNaviPaneL()
       
   474     {
       
   475     if (!iNaviPaneHandler)
       
   476     	{
       
   477     	iNaviPaneHandler = new (ELeave) CAspNaviPaneHandler(
       
   478     	                       iEikonEnv->AppUiFactory()->StatusPane());
       
   479     	}
       
   480     	
       
   481     iNaviPaneHandler->SetNaviPaneTitleL(iParam.iPageText);
       
   482     }
       
   483 
       
   484 // ----------------------------------------------------------------------------
       
   485 // CAspCheckBoxSettingPage::OfferKeyEventL
       
   486 //
       
   487 // ----------------------------------------------------------------------------
       
   488 //
       
   489 TKeyResponse CAspCheckBoxSettingPage::OfferKeyEventL(const TKeyEvent& aKeyEvent, 
       
   490                                                  TEventCode aType)
       
   491     {
       
   492     if(EKeyEnter == aKeyEvent.iCode)
       
   493     {
       
   494     	ProcessCommandL(EAknSoftkeyMark);
       
   495     	return EKeyWasConsumed;
       
   496     }
       
   497    
       
   498     if (aType == EEventKeyDown && iParam.iObserver)
       
   499         {
       
   500        	iParam.iObserver->HandleEditorEvent(
       
   501                               MAspEditorPageObserver::EKeyEvent, 0);    
       
   502         }
       
   503 
       
   504     if (aType == EEventKeyUp && iParam.iObserver)
       
   505         {
       
   506 	    TInt count = ListBoxControl()->SelectionIndexes()->Count();
       
   507        	if (count != iSelectionCount)
       
   508        		{
       
   509        		iParam.iObserver->GetNavipaneText(iParam.iPageText, count);
       
   510        	    UpdateNaviPaneL();
       
   511        	    iSelectionCount = count;
       
   512        		}
       
   513         }
       
   514         
       
   515     return CAknCheckBoxSettingPage::OfferKeyEventL(aKeyEvent, aType);
       
   516     }
       
   517 // ----------------------------------------------------------------------------
       
   518 // CAspCheckBoxSettingPage::HandleListBoxEventL
       
   519 //
       
   520 // ----------------------------------------------------------------------------
       
   521 //
       
   522 
       
   523 				 
       
   524 void CAspCheckBoxSettingPage::HandleListBoxEventL(CEikListBox* aListBox, TListBoxEvent aEventType)
       
   525 {
       
   526 	TInt index;
       
   527 	CSelectableItem* selectableItem;
       
   528 	if( AknLayoutUtils::PenEnabled() )  
       
   529 	{
       
   530 	  	switch(aEventType)
       
   531 	
       
   532 		{   
       
   533 		  case EEventItemSingleClicked:
       
   534        		 	 index=aListBox->CurrentItemIndex();
       
   535        		 	 selectableItem = (*iSelectionItemList)[index];
       
   536        		 	 if(selectableItem->SelectionStatus())
       
   537        		 	 {
       
   538        		   		this->ProcessCommandL(EAknSoftkeyUnmark);	
       
   539        		 	 }
       
   540        		     else
       
   541        		     {
       
   542        			    this->ProcessCommandL(EAknSoftkeyMark);
       
   543        		     }
       
   544 		        break;
       
   545 	 	default:
       
   546 			    break;
       
   547 		}	
       
   548 	}
       
   549 
       
   550 }
       
   551 
       
   552 /*******************************************************************************
       
   553  * class CAspProfileWizardDialog
       
   554  *******************************************************************************/
       
   555 
       
   556 
       
   557 
       
   558 // -----------------------------------------------------------------------------
       
   559 // CAspProfileWizardDialog::ShowDialogL
       
   560 // 
       
   561 // -----------------------------------------------------------------------------
       
   562 //
       
   563 TBool CAspProfileWizardDialog::ShowDialogL(TAspParam& aParam)
       
   564 	{
       
   565     CAspProfileWizardDialog* dialog = CAspProfileWizardDialog::NewL(aParam);
       
   566 
       
   567 	TBool ret = dialog->ExecuteLD(R_ASP_PROFILE_WIZARD_DIALOG);
       
   568 
       
   569 	return ret;
       
   570 	}
       
   571 
       
   572 
       
   573 // -----------------------------------------------------------------------------
       
   574 // CAspProfileWizardDialog::NewL
       
   575 //
       
   576 // -----------------------------------------------------------------------------
       
   577 //
       
   578 CAspProfileWizardDialog* CAspProfileWizardDialog::NewL(TAspParam& aParam)
       
   579     {
       
   580     FLOG( _L("CAspProfileWizardDialog::NewL START") );
       
   581 
       
   582     CAspProfileWizardDialog* self = new (ELeave) CAspProfileWizardDialog(aParam);
       
   583     CleanupStack::PushL(self);
       
   584     self->ConstructL();
       
   585     CleanupStack::Pop(self);
       
   586 
       
   587     FLOG( _L("CAspProfileWizardDialog::NewL END") );
       
   588     return self;
       
   589     }
       
   590 
       
   591 
       
   592 // -----------------------------------------------------------------------------
       
   593 // CAspProfileWizardDialog::CAspProfileWizardDialog
       
   594 // 
       
   595 // -----------------------------------------------------------------------------
       
   596 //
       
   597 CAspProfileWizardDialog::CAspProfileWizardDialog(TAspParam& aParam) 
       
   598     {
       
   599     iSyncSession = aParam.iSyncSession;
       
   600 	iApplicationId = aParam.iApplicationId;
       
   601 	iDialogParam = &aParam;
       
   602 	
       
   603 	iBgContext = NULL;
       
   604 	iMoveBack = EFalse ;
       
   605 	__ASSERT_ALWAYS(iSyncSession, TUtil::Panic(KErrGeneral));
       
   606     }
       
   607 
       
   608 
       
   609 // -----------------------------------------------------------------------------
       
   610 // CAspProfileWizardDialog::ConstructL
       
   611 //
       
   612 // -----------------------------------------------------------------------------
       
   613 //
       
   614 void CAspProfileWizardDialog::ConstructL()
       
   615     {
       
   616     FLOG( _L("CAspProfileWizardDialog::ConstructL START") );
       
   617 
       
   618     if (iApplicationId == KErrNotFound)
       
   619     	{
       
   620     	User::Leave(KErrNotFound); // unknown caller app
       
   621     	}
       
   622 	
       
   623     TAspParam param2(KErrNotFound, iSyncSession);
       
   624 	iBearerHandler = CAspBearerHandler::NewL(param2);
       
   625 
       
   626 	iStatusPaneHandler = CStatusPaneHandler::NewL(iAvkonAppUi);
       
   627 	iStatusPaneHandler->StoreOriginalTitleL();
       
   628 	
       
   629 	CAspResHandler::ReadL(iNaviPaneTextFormat, R_ASP_WIZARD_PAGE_COUNTER);
       
   630 	
       
   631 	iActiveCaller = CAspActiveCaller::NewL(this);
       
   632 
       
   633 	TAspParam param(iApplicationId, iSyncSession);
       
   634 	iWizard = CAspProfileWizard::NewL(param);
       
   635 	SetDefaultValuesL();
       
   636 	
       
   637 	param.iApplicationId = EApplicationIdSync;
       
   638 	iProfileList = CAspProfileList::NewL	(param);
       
   639 	iProfileList->ReadAllProfilesL(CAspProfileList::ENoMandatoryCheck);
       
   640 	
       
   641 	iPopupNote = CAknInfoPopupNoteController::NewL();
       
   642 	
       
   643     if (iApplicationId == EApplicationIdEmail)
       
   644     	{
       
   645    	    CDesCArray* arr = iWizard->LocalDatabaseList(KUidNSmlAdapterEMail.iUid);
       
   646 	    if (!arr)
       
   647 		    {
       
   648 		    TDialogUtil::ShowErrorNoteL(R_ASP_NO_MAILBOXES);
       
   649 		    User::Leave(KErrNotFound); // no syncml mailbox
       
   650 		    }
       
   651 		
       
   652 	    if (arr->Count() == 0) 
       
   653 		    {
       
   654 		    TDialogUtil::ShowErrorNoteL(R_ASP_NO_MAILBOXES);
       
   655 		    User::Leave(KErrNotFound); // no syncml mailbox
       
   656 		    }
       
   657     	}
       
   658 
       
   659 	FLOG( _L("CAspProfileWizardDialog::ConstructL END") );
       
   660     } 
       
   661 
       
   662 
       
   663 // -----------------------------------------------------------------------------
       
   664 // Destructor
       
   665 //
       
   666 // -----------------------------------------------------------------------------
       
   667 //
       
   668 CAspProfileWizardDialog::~CAspProfileWizardDialog()
       
   669     {
       
   670     FLOG( _L("CAspProfileWizardDialog::~CAspProfileWizardDialog START") );
       
   671 
       
   672     if (iAvkonAppUi)
       
   673     	{
       
   674     	iAvkonAppUi->RemoveFromStack(this);
       
   675     	}
       
   676 
       
   677 	delete iWizard;
       
   678 	if(iTextEditorText)
       
   679 		{
       
   680 		delete iTextEditorText;
       
   681 		}
       
   682     delete iBearerHandler;
       
   683 	delete iStatusPaneHandler;
       
   684 	delete iActiveCaller;
       
   685 	delete iProfileList;
       
   686 	
       
   687 	if (iPopupNote)
       
   688 		{
       
   689     	iPopupNote->HideInfoPopupNote();
       
   690 	    delete iPopupNote;
       
   691 		}
       
   692 	
       
   693 	if (iBgContext)
       
   694 		{
       
   695 		delete iBgContext ;
       
   696 		iBgContext = NULL ;
       
   697 		}
       
   698 
       
   699 	
       
   700 	FLOG( _L("CAspProfileWizardDialog::~CAspProfileWizardDialog END") );
       
   701     }
       
   702 
       
   703 
       
   704 //------------------------------------------------------------------------------
       
   705 // CAspProfileWizardDialog::ActivateL (from CCoeControl)
       
   706 //
       
   707 // Called by system when dialog is activated.
       
   708 //------------------------------------------------------------------------------
       
   709 //
       
   710 void CAspProfileWizardDialog::ActivateL()
       
   711 	{
       
   712     FLOG( _L("CAspProfileWizardDialog::ActivateL START") );
       
   713     
       
   714     CAknDialog::ActivateL();
       
   715 
       
   716 	// this cannot be in ConstructL which is executed before dialog is launched
       
   717 	iAvkonAppUi->AddToStackL(this);
       
   718 	
       
   719     FLOG( _L("CAspProfileWizardDialog::ActivateL END") );
       
   720     }
       
   721 
       
   722 
       
   723 // -----------------------------------------------------------------------------
       
   724 // CAspProfileWizardDialog::OKToExitL
       
   725 // 
       
   726 // -----------------------------------------------------------------------------
       
   727 //
       
   728 TBool CAspProfileWizardDialog::OkToExitL(TInt aButtonId)
       
   729 	{
       
   730     FLOG( _L("CAspProfileWizardDialog::OkToExitL START") );
       
   731 	
       
   732 	iDialogParam->iReturnValue = KErrNotFound;
       
   733 	iDialogParam->iProfileId = KErrNotFound;
       
   734 
       
   735 	if (aButtonId == EEikBidOk)
       
   736 		{
       
   737 		if (iWizard->CurrentItemType() == CAspWizardItem::ETypeStart)
       
   738 			{
       
   739 			if (iTextEditorText)
       
   740    				{
       
   741    			 	delete iTextEditorText;
       
   742 				iTextEditorText = NULL;
       
   743 				}
       
   744     		TRect mainPane;
       
   745 			AknLayoutUtils::LayoutMetricsRect( AknLayoutUtils::EApplicationWindow, mainPane );
       
   746    	 		iTextEditor->SetRect(mainPane);
       
   747     		iTextEditor->SetTextL(iTextEditorText);
       
   748     		UpdateCbaL(R_ASP_CBA_NEXT_BACK_NEXT);
       
   749 		
       
   750 			iWizard->MoveToNext();
       
   751 			
       
   752 			// start wizard when this completes (in HandleActiveCallL)
       
   753 			iActiveCaller->Request();
       
   754 			 
       
   755 			FLOG( _L("CAspProfileWizardDialog::OkToExitL END") );
       
   756 			return EFalse;
       
   757 			}
       
   758 		else if (iWizard->CurrentItemType() == CAspWizardItem::ETypeEnd)
       
   759 			{
       
   760 			iDialogParam->iReturnValue = KErrNone;
       
   761 			iDialogParam->iProfileId = iWizard->CreatedProfileId();
       
   762 	        
       
   763 	        FLOG( _L("CAspProfileWizardDialog::OkToExitL END") );
       
   764 			return ETrue;
       
   765 			}
       
   766 		//Case of quick succession clicks on touch screen profile creation wizard
       
   767 		else
       
   768 			{
       
   769 			   return EFalse;	
       
   770 			}
       
   771 		}
       
   772 	//Case of quick succession backs on touch screen profile creation wizard
       
   773 	else if(aButtonId == EAknSoftkeyDone)
       
   774 	{
       
   775 		return EFalse;
       
   776 	}
       
   777 		
       
   778 		
       
   779 	
       
   780 	FLOG( _L("CAspProfileWizardDialog::OkToExitL END") );
       
   781 	return CAknDialog::OkToExitL(aButtonId);
       
   782 	}
       
   783 
       
   784 
       
   785 //------------------------------------------------------------------------------
       
   786 // CAspProfileWizardDialog::ProcessCommandL
       
   787 //
       
   788 //------------------------------------------------------------------------------
       
   789 //
       
   790 void CAspProfileWizardDialog::ProcessCommandL(TInt /*aCommandId*/)
       
   791 	{
       
   792 	}
       
   793 
       
   794 
       
   795 // ----------------------------------------------------------------------------
       
   796 // CAspProfileWizardDialog::OfferKeyEventL
       
   797 // 
       
   798 // ----------------------------------------------------------------------------
       
   799 //
       
   800 TKeyResponse CAspProfileWizardDialog::OfferKeyEventL(const TKeyEvent& aKeyEvent,TEventCode aType)
       
   801 	{
       
   802 	if (aType == EEventKey)
       
   803 		{
       
   804 		switch (aKeyEvent.iCode)
       
   805 			{
       
   806 			case EKeyEnter:
       
   807 			{
       
   808 			     TryExitL(EEikBidOk);
       
   809 			     return EKeyWasConsumed;
       
   810 			}
       
   811 			case EKeyOK:
       
   812 				{
       
   813 				break;
       
   814 				}
       
   815 
       
   816 			case EKeyEscape:  // framework calls this when dialog must shut down
       
   817 				{
       
   818 				return CAknDialog::OfferKeyEventL(aKeyEvent, aType);
       
   819         		}
       
   820 
       
   821             default:
       
   822 				{
       
   823 				//return iTextEditor->OfferKeyEventL(aKeyEvent, aType);
       
   824 			    break;
       
   825 				}
       
   826 			}
       
   827 		}
       
   828 
       
   829 	return CAknDialog::OfferKeyEventL( aKeyEvent, aType);
       
   830 	}
       
   831 
       
   832 
       
   833 // -----------------------------------------------------------------------------
       
   834 // CAspProfileWizardDialog::PreLayoutDynInitL
       
   835 //
       
   836 // Called by framework before dialog is shown.
       
   837 // -----------------------------------------------------------------------------
       
   838 //
       
   839 void CAspProfileWizardDialog::PreLayoutDynInitL()
       
   840     {
       
   841     FLOG( _L("CAspProfileWizardDialog::PreLayoutDynInitL START") );
       
   842    
       
   843     iTextEditor = (CEikRichTextEditor*) ControlOrNull (EAspProfileWizardDialogList);
       
   844     
       
   845     User::LeaveIfNull(iTextEditor);
       
   846    
       
   847     SetTextEditorTextL(R_ASP_SET_WIZARD_START);
       
   848     
       
   849 	TRect mainPane;
       
   850     AknLayoutUtils::LayoutMetricsRect(AknLayoutUtils::EMainPane, mainPane);        
       
   851     iTextEditor->SetRect(mainPane);
       
   852 	
       
   853 	SetBackgroundContextL ();
       
   854 	
       
   855     iStatusPaneHandler->SetNaviPaneTitleL(KNullDesC);
       
   856     iStatusPaneHandler->SetTitleL(R_ASP_SETTING_DIALOG_TITLE);
       
   857     
       
   858     FLOG( _L("CAspProfileWizardDialog::PreLayoutDynInitL END") );
       
   859 	}
       
   860 
       
   861 
       
   862 // ----------------------------------------------------------------------------
       
   863 // CAspProfileWizardDialog::HandleResourceChange
       
   864 // 
       
   865 // ----------------------------------------------------------------------------
       
   866 //
       
   867 void CAspProfileWizardDialog::HandleResourceChange(TInt aType)
       
   868     {   
       
   869     if (aType == KEikDynamicLayoutVariantSwitch) //Handle change in layout orientation
       
   870         {
       
   871         TRect mainPaneRect;
       
   872         AknLayoutUtils::LayoutMetricsRect(AknLayoutUtils::EMainPane, mainPaneRect);
       
   873         SetRect(mainPaneRect);
       
   874         iTextEditor->SetSize(mainPaneRect.Size());
       
   875         SetBackgroundContextL();
       
   876         CCoeControl::HandleResourceChange(aType);
       
   877 		DrawDeferred();
       
   878 	    return;
       
   879 		}
       
   880 	if (aType == KAknsMessageSkinChange)
       
   881 		{
       
   882 		// When skin changes, we need to update text color
       
   883 		TRAP_IGNORE(UpdateTextColorL());
       
   884 		}
       
   885 		
       
   886     CCoeControl::HandleResourceChange(aType);
       
   887     }
       
   888 
       
   889 
       
   890 // -----------------------------------------------------------------------------
       
   891 // CAspProfileWizardDialog::HandleActiveCallL (from MAspActiveCallerObserver)
       
   892 //
       
   893 // -----------------------------------------------------------------------------
       
   894 //
       
   895 void CAspProfileWizardDialog::HandleActiveCallL(TInt /*aCallId*/)
       
   896 	{
       
   897     FLOG( _L("CAspProfileWizardDialog::HandleActiveCallL START") );
       
   898 	
       
   899 	TInt err = RunWizard();
       
   900 	
       
   901 	if (err != KErrNone)
       
   902 		{
       
   903 		iWizard->DeleteProfile();
       
   904 		
       
   905 		ShowErrorNoteL(err);
       
   906 
       
   907         TryExitL(EEikBidCancel); // close profile wizard dialog
       
   908 		}
       
   909 
       
   910     FLOG( _L("CAspProfileWizardDialog::HandleActiveCallL END") );
       
   911 	}
       
   912 
       
   913 
       
   914 // -----------------------------------------------------------------------------
       
   915 // CAspProfileWizardDialog::RunWizard
       
   916 //
       
   917 // -----------------------------------------------------------------------------
       
   918 //
       
   919 TInt CAspProfileWizardDialog::RunWizard()
       
   920 	{
       
   921     FLOG( _L("CAspProfileWizardDialog::RunWizard START") );
       
   922     
       
   923     TRAPD(err, RunWizardL());
       
   924 	
       
   925 	HidePopupNote();
       
   926 	
       
   927 	if (err != KErrNone)
       
   928 		{
       
   929 		iWizard->MoveToStart();
       
   930 		FLOG( _L("### RunWizardL failed (%d) ###"), err );
       
   931 		}
       
   932 		
       
   933     FLOG( _L("CAspProfileWizardDialog::RunWizard END") );
       
   934 	return err;
       
   935 	}
       
   936 
       
   937 
       
   938 // -----------------------------------------------------------------------------
       
   939 // CAspProfileWizardDialog::RunWizardL
       
   940 //
       
   941 // -----------------------------------------------------------------------------
       
   942 //
       
   943 void CAspProfileWizardDialog::RunWizardL()
       
   944 	{
       
   945 	for (;;)
       
   946 		{
       
   947 		CAspWizardItem* item = iWizard->CurrentItem();
       
   948 	
       
   949 	    if (item->iSettingType == CAspWizardItem::ETypeEnd)
       
   950 		    {
       
   951 		    iMoveBack = ETrue ;
       
   952 		    iWizard->CreateProfileL();
       
   953 		    
       
   954 		    if (iApplicationId == EApplicationIdSync)
       
   955 		    	{
       
   956 		    	SetTextEditorTextL(R_ASP_SET_WIZARD_END);
       
   957 		        UpdateCbaL(R_ASP_CBA_ACTIVATE_LATER_ACTIVATE);
       
   958 		    	}
       
   959 		    else if (iApplicationId == EApplicationIdEmail)
       
   960 		    	{
       
   961 		    	SetTextEditorTextL(R_ASP_SET_WIZARD_END_EMAIL);
       
   962 		    	UpdateCbaL(R_AVKON_SOFTKEYS_OK_EMPTY);
       
   963 		    	}
       
   964 		    else
       
   965 		    	{
       
   966 		    	SetTextEditorTextL(R_ASP_SET_WIZARD_END_APP);
       
   967 		    	UpdateCbaL(R_AVKON_SOFTKEYS_OK_EMPTY);
       
   968 		    	}
       
   969 
       
   970 		    TBuf<KBufSize> buf;
       
   971 		    GetNaviPaneText(buf, item);
       
   972 		    iStatusPaneHandler->SetNaviPaneTitleL(buf);
       
   973 		    
       
   974 		    return; // return to wizard dialog view
       
   975 		    }
       
   976 		
       
   977 	    if (item->iSettingType == CAspWizardItem::ETypeStart)
       
   978 		    {
       
   979 		    iMoveBack = ETrue ;
       
   980 		    SetTextEditorTextL(R_ASP_SET_WIZARD_START);
       
   981 		    UpdateCbaL(R_ASP_CBA_START_CANCEL_START);
       
   982 		    return; // return to wizard dialog view
       
   983 		    }
       
   984 
       
   985 	    TInt ret = EditSettingItemL(item); // show setting editor
       
   986 	
       
   987 	    if (ret == EAknSoftkeyOk || ret == EEikBidSelect)
       
   988 		    {
       
   989 		    iMoveBack = EFalse ;
       
   990 		    iWizard->MoveToNext();
       
   991         	}
       
   992 	    else if (ret == EAknSoftkeyDone)
       
   993 		    {
       
   994 		    iMoveBack = ETrue ;
       
   995 		    iWizard->MoveToPrevious();
       
   996 			}
       
   997 	    else
       
   998 	        {
       
   999 	        iMoveBack = EFalse ;
       
  1000 	        iWizard->MoveToStart();
       
  1001 		    return; // probably system cancel - wizard must close
       
  1002 		    }
       
  1003 		}
       
  1004 	}
       
  1005 
       
  1006 
       
  1007 //------------------------------------------------------------------------------
       
  1008 // CAspProfileWizardDialog::EditSettingItemL
       
  1009 //
       
  1010 // Calls setting editing functions. 
       
  1011 //------------------------------------------------------------------------------
       
  1012 //
       
  1013 TInt CAspProfileWizardDialog::EditSettingItemL(CAspWizardItem* aItem)
       
  1014 	{
       
  1015 	TInt ret = EAknSoftkeyOk;
       
  1016 	
       
  1017 	ShowPopupNoteL(aItem->iPopupNoteResourceId, KMsToWaitBeforePopup);
       
  1018 	
       
  1019 	switch (aItem->iSettingType)
       
  1020 		{
       
  1021 		case CAspWizardItem::ETypeStart:
       
  1022 		    break;
       
  1023 			
       
  1024 		case CAspWizardItem::ETypeProfileName:
       
  1025 			ret = EditSettingItemProfileNameL(aItem);
       
  1026 		    break;
       
  1027 
       
  1028 		case CAspWizardItem::ETypeProtocolVersion:
       
  1029 			ret = EditSettingItemProtocolVersionL(aItem);
       
  1030 		    break;
       
  1031 
       
  1032 		case CAspWizardItem::ETypeHostAddress:
       
  1033 			ret = EditSettingItemHostAddressL(aItem);
       
  1034 		    break;
       
  1035 
       
  1036 		case CAspWizardItem::ETypeServerId:
       
  1037 			ret = EditSettingItemTextL(aItem);
       
  1038 		    break;
       
  1039 
       
  1040 		case CAspWizardItem::ETypeBearerType:
       
  1041 			ret = EditSettingItemBearerTypeL(aItem);
       
  1042 		    break;
       
  1043 
       
  1044 		case CAspWizardItem::ETypeUserName:
       
  1045 			ret = EditSettingItemTextL(aItem);
       
  1046 		    break;
       
  1047 		
       
  1048 		case CAspWizardItem::ETypePassword:
       
  1049 			ret = EditSettingItemSecretL(aItem);
       
  1050 		    break;
       
  1051 		    
       
  1052 		case CAspWizardItem::ETypeContentSelection:
       
  1053 			ret = EditSettingItemContentSelectionL(aItem);
       
  1054 		    break;
       
  1055 
       
  1056 		case CAspWizardItem::ETypeSyncContent:
       
  1057 	    	ret = EditSettingItemTextL(aItem);
       
  1058 		    break;
       
  1059 
       
  1060 		case CAspWizardItem::ETypeSyncContentLocalDatabase:
       
  1061 	    	ret = EditSettingItemLocalDatabaseL(aItem);
       
  1062 		    break;
       
  1063 
       
  1064 		case CAspWizardItem::ETypeEnd:
       
  1065 			break;
       
  1066 
       
  1067 		default:
       
  1068 		    break;
       
  1069 		}
       
  1070 
       
  1071 	HidePopupNote();
       
  1072 	
       
  1073 	return ret;
       
  1074 	}
       
  1075 
       
  1076 
       
  1077 //------------------------------------------------------------------------------
       
  1078 // CAspProfileWizardDialog::EditSettingItemTextL
       
  1079 //
       
  1080 // Edit text setting item.
       
  1081 //------------------------------------------------------------------------------
       
  1082 //
       
  1083 TInt CAspProfileWizardDialog::EditSettingItemTextL(CAspWizardItem* aItem)
       
  1084 	{
       
  1085 	TUtil::StrCopy(iBuf, aItem->Value());
       
  1086 	
       
  1087 	TInt flags(CAknTextSettingPage::EZeroLengthAllowed);
       
  1088 
       
  1089     TAspSettingPageParam param;
       
  1090     param.iCommandId = EAknSoftkeyOk;
       
  1091     GetNaviPaneText(param.iPageText, aItem);
       
  1092     param.iObserver = this;
       
  1093     param.iSettingType = aItem->iSettingType;
       
  1094     
       
  1095 	CAspTextSettingPage* dlg = new (ELeave) CAspTextSettingPage(
       
  1096 	                     R_ASP_SETTING_TEXT_NEXT_BACK, iBuf, flags, param);
       
  1097 	CleanupStack::PushL(dlg);
       
  1098 
       
  1099 	dlg->SetSettingTextL(aItem->Header()); 
       
  1100 	dlg->ConstructL();
       
  1101 	dlg->TextControl()->SetTextLimit(aItem->iMaxLength);
       
  1102 
       
  1103 	if (aItem->iLatinInput)
       
  1104 		{		
       
  1105 		dlg->TextControl()->SetAvkonWrap(ETrue);
       
  1106 		dlg->TextControl()->SetAknEditorCase(EAknEditorLowerCase);
       
  1107 		dlg->TextControl()->SetAknEditorFlags(EAknEditorFlagNoT9 |
       
  1108 		                                EAknEditorFlagLatinInputModesOnly);
       
  1109 		}
       
  1110 	
       
  1111 	CleanupStack::Pop(dlg);
       
  1112 
       
  1113     //
       
  1114 	// CAknTextSettingPage::ExecuteLD returns boolean. 
       
  1115 	// See CAknSettingPage::ProcessCommandL what softkey values map to
       
  1116 	// ETrue and EFalse.
       
  1117 	// Profile wizard editors return EAknSoftkeyDone for "Back" and 
       
  1118 	// EAknSoftkeyOk for "Next". Editors need "positive" ids for saving
       
  1119 	// setting values.
       
  1120 	//
       
  1121 	TInt ret = dlg->ExecuteLD(CAknSettingPage::EUpdateWhenChanged);
       
  1122    
       
  1123 
       
  1124     aItem->SetValueL(iBuf);
       
  1125     
       
  1126     return param.iCommandId;
       
  1127 	}
       
  1128 
       
  1129 
       
  1130 //------------------------------------------------------------------------------
       
  1131 // CAspProfileWizardDialog::EditSettingItemProtocolVersionL
       
  1132 //
       
  1133 //------------------------------------------------------------------------------
       
  1134 //
       
  1135 TBool CAspProfileWizardDialog::EditSettingItemProtocolVersionL(CAspWizardItem* aItem)
       
  1136 	{
       
  1137 	TInt curSelection = aItem->iNumber;
       
  1138 	CDesCArray* arr2 = CAspResHandler::ReadDesArrayStaticLC(R_ASP_PROTOCOL_VERSION);
       
  1139 	CDesCArray* arr = TUtil::NumberConversionLC(arr2);
       
  1140 	
       
  1141     TAspSettingPageParam param;
       
  1142     param.iCommandId = EAknSoftkeyOk;
       
  1143     GetNaviPaneText(param.iPageText, aItem);
       
  1144     param.iObserver = this;
       
  1145     param.iSettingType = aItem->iSettingType;
       
  1146 	
       
  1147 	CAspRadioButtonSettingPage* dlg = new (ELeave) CAspRadioButtonSettingPage(
       
  1148 	                                  R_ASP_SETTING_RADIO_NEXT_BACK, 
       
  1149 	                                  curSelection, arr, param);
       
  1150 	CleanupStack::PushL(dlg);
       
  1151 	dlg->SetSettingTextL(aItem->Header()); 
       
  1152 	CleanupStack::Pop(dlg);
       
  1153 
       
  1154 	dlg->ExecuteLD();
       
  1155 	
       
  1156 	aItem->iNumber = curSelection;
       
  1157    	aItem->SetValueL((*arr)[curSelection]);
       
  1158    	
       
  1159    	if (curSelection == EAspProtocol_1_1)
       
  1160    		{
       
  1161    		iWizard->SetContentEnabled(KUidNSmlAdapterEMail.iUid, EFalse);
       
  1162         iWizard->SetEnabled(CAspWizardItem::ETypeServerId, EFalse);
       
  1163    		}
       
  1164    	else
       
  1165    		{
       
  1166    		iWizard->SetEnabled(CAspWizardItem::ETypeServerId, ETrue);
       
  1167    		}
       
  1168 
       
  1169 	CleanupStack::PopAndDestroy(arr);
       
  1170 	CleanupStack::PopAndDestroy(arr2);
       
  1171    	return param.iCommandId;
       
  1172 	}
       
  1173 
       
  1174 
       
  1175 //------------------------------------------------------------------------------
       
  1176 // CAspProfileWizardDialog::EditSettingItemBearerTypeL
       
  1177 //
       
  1178 //------------------------------------------------------------------------------
       
  1179 //
       
  1180 TInt CAspProfileWizardDialog::EditSettingItemBearerTypeL(CAspWizardItem* aItem)
       
  1181 	{
       
  1182 	CDesCArray* arr = iBearerHandler->BuildBearerListLC();
       
  1183 	if (arr->Count() == 0) 
       
  1184 		{
       
  1185 		User::Leave(KErrNotFound);
       
  1186 		}
       
  1187 
       
  1188 	TInt curSelection = iBearerHandler->ListIndexForBearer(aItem->iNumber);
       
  1189 	if (curSelection == KErrNotFound)
       
  1190 		{
       
  1191 		User::Leave(KErrNotFound);
       
  1192 		}
       
  1193 
       
  1194 
       
  1195     TAspSettingPageParam param;
       
  1196     param.iCommandId = EAknSoftkeyOk;
       
  1197     GetNaviPaneText(param.iPageText, aItem);
       
  1198     param.iObserver = this;
       
  1199     param.iSettingType = aItem->iSettingType;
       
  1200 	
       
  1201 	CAspRadioButtonSettingPage* dlg = new (ELeave) CAspRadioButtonSettingPage(
       
  1202 	                                  R_ASP_SETTING_RADIO_NEXT_BACK, 
       
  1203 	                                  curSelection, arr, param);
       
  1204 	CleanupStack::PushL(dlg);
       
  1205 	dlg->SetSettingTextL(aItem->Header()); 
       
  1206 	CleanupStack::Pop(dlg);
       
  1207 
       
  1208 	dlg->ExecuteLD();
       
  1209 		
       
  1210 	aItem->iNumber = iBearerHandler->BearerForListIndex(curSelection);
       
  1211    	aItem->SetValueL((*arr)[curSelection]);
       
  1212 	
       
  1213 	CleanupStack::PopAndDestroy(arr);
       
  1214 		
       
  1215    	return param.iCommandId;
       
  1216 	}
       
  1217 
       
  1218 
       
  1219 //------------------------------------------------------------------------------
       
  1220 // CAspProfileWizardDialog::EditSettingItemLocalDatabaseL
       
  1221 //
       
  1222 //------------------------------------------------------------------------------
       
  1223 //
       
  1224 TInt CAspProfileWizardDialog::EditSettingItemLocalDatabaseL(CAspWizardItem* aItem)
       
  1225 	{
       
  1226 	CDesCArray* arr = iWizard->LocalDatabaseList(aItem->iSettingId);
       
  1227 	if (!arr)
       
  1228 		{
       
  1229 		User::Leave(KErrNotFound);
       
  1230 		}
       
  1231 		
       
  1232 	if (arr->Count() == 0) 
       
  1233 		{
       
  1234 		User::Leave(KErrNotFound);
       
  1235 		}
       
  1236 
       
  1237 	TInt curSelection = aItem->iNumber;
       
  1238 	if (curSelection < 0)
       
  1239 		{
       
  1240 		curSelection = 0;
       
  1241 		}
       
  1242 
       
  1243 
       
  1244     TAspSettingPageParam param;
       
  1245     param.iCommandId = EAknSoftkeyOk;
       
  1246     GetNaviPaneText(param.iPageText, aItem);
       
  1247     param.iObserver = this;
       
  1248     param.iSettingType = aItem->iSettingType;
       
  1249 	
       
  1250 	CAspRadioButtonSettingPage* dlg = new (ELeave) CAspRadioButtonSettingPage(
       
  1251 	                                  R_ASP_SETTING_RADIO_NEXT_BACK, 
       
  1252 	                                  curSelection, arr, param);
       
  1253 	CleanupStack::PushL(dlg);
       
  1254 	dlg->SetSettingTextL(aItem->Header()); 
       
  1255 	CleanupStack::Pop(dlg);
       
  1256 
       
  1257 	dlg->ExecuteLD();
       
  1258 		
       
  1259 	aItem->iNumber = curSelection;
       
  1260    	aItem->SetValueL((*arr)[curSelection]);
       
  1261 	
       
  1262    	return param.iCommandId;
       
  1263 	}
       
  1264 
       
  1265 
       
  1266 //------------------------------------------------------------------------------
       
  1267 // CAspProfileWizardDialog::EditSettingItemSecretL
       
  1268 //
       
  1269 //------------------------------------------------------------------------------
       
  1270 //
       
  1271 TInt CAspProfileWizardDialog::EditSettingItemSecretL(CAspWizardItem* aItem)
       
  1272 	{
       
  1273 	TBuf<KBufSize64> newPassword;
       
  1274 	TUtil::StrCopy(newPassword, aItem->Value());
       
  1275 	
       
  1276 	
       
  1277     TAspSettingPageParam param;
       
  1278     param.iCommandId = EAknSoftkeyOk;
       
  1279     GetNaviPaneText(param.iPageText, aItem);
       
  1280     param.iObserver = this;
       
  1281     param.iSettingType = aItem->iSettingType;
       
  1282 
       
  1283 	CAspAlphaPasswordSettingPage* pwd = new (ELeave) CAspAlphaPasswordSettingPage(
       
  1284 		     R_ASP_SETTING_PASSWORD_NEXT_BACK, newPassword, aItem->Value(), param);
       
  1285 
       
  1286 	CleanupStack::PushL(pwd);
       
  1287 	pwd->SetSettingTextL(aItem->Header()); 
       
  1288 	pwd->ConstructL();
       
  1289 	pwd->AlphaPasswordEditor()->SetMaxLength(aItem->iMaxLength);
       
  1290 	//pwd->AlphaPasswordEditor()->RevealSecretText(ETrue);
       
  1291 	CleanupStack::Pop(pwd);
       
  1292 
       
  1293 	TInt ret = pwd->ExecuteLD(CAknSettingPage::EUpdateWhenChanged);
       
  1294 		
       
  1295 	aItem->SetValueL(newPassword);
       
  1296    	
       
  1297    	return param.iCommandId;
       
  1298 	}
       
  1299 
       
  1300 
       
  1301 //------------------------------------------------------------------------------
       
  1302 // CAspProfileWizardDialog::EditSettingItemProfileNameL
       
  1303 //
       
  1304 //------------------------------------------------------------------------------
       
  1305 //
       
  1306 TInt CAspProfileWizardDialog::EditSettingItemProfileNameL(CAspWizardItem* aItem)
       
  1307 	{
       
  1308 	TInt commandId = EditSettingItemTextL(aItem);
       
  1309       	
       
  1310     return commandId;
       
  1311 	}
       
  1312 
       
  1313 
       
  1314 //------------------------------------------------------------------------------
       
  1315 // CAspProfileWizardDialog::EditSettingItemHostAddressL
       
  1316 //
       
  1317 //------------------------------------------------------------------------------
       
  1318 //
       
  1319 TInt CAspProfileWizardDialog::EditSettingItemHostAddressL(CAspWizardItem* aItem)
       
  1320 	{
       
  1321 	_LIT(KIPAddressRegX,"http://*");
       
  1322 	TInt bearer = iWizard->NumberValue(CAspWizardItem::ETypeBearerType);
       
  1323 	TPtrC ptr = aItem->Value();
       
  1324 	TPtrC httpHeader(KIPAddressRegX); 
       
  1325 	
       
  1326 	if (bearer == EAspBearerInternet)
       
  1327 		{
       
  1328 		   //If existing ptr is NOT an IP address
       
  1329 		   if(ptr.MatchC(httpHeader) == KErrNotFound)
       
  1330 		   {
       
  1331 				aItem->SetValueL(KHttpHeader);   	
       
  1332 		   }
       
  1333 		}
       
  1334 	else
       
  1335 		{
       
  1336 		    //If existing ptr is IP address
       
  1337 		    if(ptr.MatchC(httpHeader) != KErrNotFound)
       
  1338 		    {
       
  1339 		    	aItem->SetValueL(KNullDesC); 		
       
  1340 		    }
       
  1341 		}
       
  1342 	
       
  1343 	TInt commandId;
       
  1344 	while (ETrue)
       
  1345 		{
       
  1346 		commandId = EditSettingItemTextL(aItem);
       
  1347 		if (commandId == EAknSoftkeyOk && bearer == EAspBearerInternet)
       
  1348 			{
       
  1349 			if (!TURIParser::IsValidUri(aItem->Value()))
       
  1350 				{			
       
  1351 				TDialogUtil::ShowInformationNoteL(R_ASP_LOG_ERR_URIINVALID);
       
  1352 				}
       
  1353 			else
       
  1354 				{
       
  1355 				break;	
       
  1356 				}
       
  1357 			}
       
  1358 		else
       
  1359 			{
       
  1360 			break;	
       
  1361 			}
       
  1362 		}
       
  1363     return commandId;
       
  1364 	}
       
  1365 
       
  1366 
       
  1367 //------------------------------------------------------------------------------
       
  1368 // CAspProfileWizardDialog::EditSettingItemContentSelectionL
       
  1369 //
       
  1370 //------------------------------------------------------------------------------
       
  1371 //
       
  1372 TInt CAspProfileWizardDialog::EditSettingItemContentSelectionL(CAspWizardItem* aItem)
       
  1373 	{
       
  1374 	CAspSelectionItemList* list = new (ELeave) CAspSelectionItemList(1);
       
  1375 	CleanupStack::PushL(TCleanupItem(CAspSelectionItemList::Cleanup, list));
       
  1376 	
       
  1377 	iWizard->GetContentSelectionL(list);
       
  1378 	
       
  1379     TAspSettingPageParam param;
       
  1380     param.iCommandId = EAknSoftkeyOk;
       
  1381     GetNaviPaneText(param.iPageText, aItem);
       
  1382     param.iObserver = this;
       
  1383     param.iSettingType = aItem->iSettingType;
       
  1384 
       
  1385 	CAspCheckBoxSettingPage* dlg = new (ELeave) CAspCheckBoxSettingPage(
       
  1386 	                                   R_ASP_SETTING_CHECK_NEXT_BACK, list, param);
       
  1387 	
       
  1388    	CleanupStack::PushL(dlg);
       
  1389     dlg->SetSettingTextL(aItem->Header());
       
  1390 	CleanupStack::Pop(dlg);
       
  1391 
       
  1392     TBool ret = dlg->ExecuteLD(CAknSettingPage::EUpdateWhenChanged);
       
  1393     
       
  1394     iWizard->SetContentSelectionL(list);
       
  1395     
       
  1396 	CleanupStack::PopAndDestroy(list);
       
  1397 
       
  1398    	return param.iCommandId;
       
  1399 	}
       
  1400 
       
  1401 
       
  1402 //------------------------------------------------------------------------------
       
  1403 // CAspProfileWizardDialog::CheckValidity (from MAspEditorPageObserver)
       
  1404 //
       
  1405 //------------------------------------------------------------------------------
       
  1406 //
       
  1407 TBool CAspProfileWizardDialog::CheckValidity(const TDesC& aText, TInt aSettingType)
       
  1408 	{
       
  1409 	TInt ret = ETrue;
       
  1410 	
       
  1411 	TRAPD(err, ret = CheckValidityL(aText, aSettingType));
       
  1412 	
       
  1413 	if (err != KErrNone)
       
  1414 		{
       
  1415 		return ETrue;
       
  1416 		}
       
  1417 	
       
  1418 	return ret;
       
  1419 	}
       
  1420 	
       
  1421 
       
  1422 //------------------------------------------------------------------------------
       
  1423 // CAspProfileWizardDialog::CheckValidityL (from MAspEditorPageObserver)
       
  1424 //
       
  1425 //------------------------------------------------------------------------------
       
  1426 //
       
  1427 TBool CAspProfileWizardDialog::CheckValidityL(const TDesC& aText, TInt aSettingType)
       
  1428 	{
       
  1429 	if (aSettingType == CAspWizardItem::ETypeProfileName)
       
  1430 		{
       
  1431 	    if (TUtil::IsEmpty(aText))
       
  1432 		    {
       
  1433 		    TDialogUtil::ShowInformationNoteL(R_ASP_NOTE_PROFILE_NAME_MISSING);
       
  1434 		    return EFalse;
       
  1435 		    }
       
  1436 		}
       
  1437 		
       
  1438 	if (aSettingType == CAspWizardItem::ETypeSyncContent)
       
  1439 		{
       
  1440 	    if (TUtil::IsEmpty(aText))
       
  1441 		    {
       
  1442 		    CAspWizardItem* item = iWizard->CurrentItem();
       
  1443 		    if (item->iErrorNoteResourceId == R_ASP_NOTE_CONTACTS_DB_MISSING)
       
  1444 		    	{
       
  1445 		    	TDialogUtil::ShowInformationNoteL(R_ASP_NOTE_CONTACTS_DB_MISSING);
       
  1446 		    	return EFalse;
       
  1447 		    	}
       
  1448 		    else if (item->iErrorNoteResourceId == R_ASP_NOTE_CALENDAR_DB_MISSING)
       
  1449 		    	{	
       
  1450 		    	TDialogUtil::ShowInformationNoteL(R_ASP_NOTE_CALENDAR_DB_MISSING);
       
  1451 		    	return EFalse;
       
  1452 		    	}
       
  1453 		    else if (item->iErrorNoteResourceId == R_ASP_NOTE_NOTES_DB_MISSING)
       
  1454 		    	{
       
  1455 		    	TDialogUtil::ShowInformationNoteL(R_ASP_NOTE_NOTES_DB_MISSING);
       
  1456 		    	return EFalse;
       
  1457 		    	}
       
  1458 		    else if (item->iErrorNoteResourceId == R_ASP_NOTE_EMAIL_DB_MISSING)
       
  1459 		    	{
       
  1460 		    	TDialogUtil::ShowInformationNoteL(R_ASP_NOTE_EMAIL_DB_MISSING);
       
  1461 		    	return EFalse;
       
  1462 		    	} 
       
  1463 		    else if (item->iErrorNoteResourceId == R_ASP_NOTE_MMS_DATABASE_MISSING)
       
  1464 		    	{
       
  1465 		    	TDialogUtil::ShowInformationNoteL(R_ASP_NOTE_MMS_DATABASE_MISSING);
       
  1466 		    	return EFalse;
       
  1467 		    	} 
       
  1468 		    else if (item->iErrorNoteResourceId == R_ASP_NOTE_SMS_DATABASE_MISSING)
       
  1469 		        {
       
  1470 		        TDialogUtil::ShowInformationNoteL(R_ASP_NOTE_SMS_DATABASE_MISSING);
       
  1471 		        return EFalse;
       
  1472 		        } 
       
  1473 		    else if (item->iErrorNoteResourceId == R_ASP_NOTE_BKM_DATABASE_MISSING)
       
  1474 		    	{
       
  1475 		    	TDialogUtil::ShowInformationNoteL(R_ASP_NOTE_BKM_DATABASE_MISSING);
       
  1476 		    	return EFalse;
       
  1477 		    	} 
       
  1478 		    else
       
  1479 		    	{
       
  1480 		    	TDialogUtil::ShowInformationNoteL(R_ASP_NOTE_REMOTE_DATABASE_MISSING);
       
  1481 		    	return EFalse;
       
  1482     	    	}
       
  1483     	        	    
       
  1484     	    }
       
  1485 		}
       
  1486 
       
  1487 	if (aSettingType == CAspWizardItem::ETypeHostAddress)
       
  1488 		{
       
  1489 	    if (TUtil::IsEmpty(aText))
       
  1490 		    {
       
  1491 		    TDialogUtil::ShowInformationNoteL(R_ASP_NOTE_HOST_ADDRESS_MISSING);
       
  1492 		    return EFalse;
       
  1493 		    }
       
  1494 		TInt bearer = iWizard->NumberValue(CAspWizardItem::ETypeBearerType);
       
  1495 		if	(bearer == EAspBearerInternet)		    
       
  1496 			{
       
  1497 				if (!TURIParser::IsValidUri(aText))
       
  1498 			    {
       
  1499 			    TDialogUtil::ShowInformationNoteL(R_ASP_NOTE_INCORRECT_HOST_ADDRESS);
       
  1500 			    return EFalse;
       
  1501 			    }
       
  1502 			}
       
  1503 			else if (bearer == EAspBearerBlueTooth)
       
  1504 			{
       
  1505 				if (!TURIParser::IsValidBluetoothHostAddress(aText))
       
  1506 			    {
       
  1507 			    TDialogUtil::ShowInformationNoteL(R_ASP_NOTE_INCORRECT_HOST_ADDRESS);
       
  1508 			    return EFalse;
       
  1509 			    }
       
  1510 			}
       
  1511 		}
       
  1512     
       
  1513 	if (aSettingType == CAspWizardItem::ETypeServerId)
       
  1514 		{
       
  1515 	    if (!iProfileList->IsUniqueServerId(aText, KErrNotFound))
       
  1516 		    {
       
  1517 		    TDialogUtil::ShowInformationNoteL(R_ASP_NOTE_INCORRECT_SERVER_ID);
       
  1518 		    return EFalse;
       
  1519 		    }
       
  1520 		}
       
  1521 
       
  1522 	if (aSettingType == CAspWizardItem::ETypeContentSelection)
       
  1523 		{
       
  1524 		TInt adapterId = iWizard->ContentId(aText);
       
  1525 		if (adapterId == KUidNSmlAdapterEMail.iUid)
       
  1526 			{
       
  1527 		    TInt protocol = iWizard->NumberValue(CAspWizardItem::ETypeProtocolVersion);
       
  1528 		   	
       
  1529 		   	
       
  1530 		   	CDesCArray* arr = iWizard->LocalDatabaseList(KUidNSmlAdapterEMail.iUid);
       
  1531 	        if (!arr)
       
  1532 		        {
       
  1533 		        TDialogUtil::ShowErrorNoteL(R_ASP_NO_MAILBOXES);
       
  1534 		        return EFalse;  // no syncml mailbox
       
  1535 		        }
       
  1536 		
       
  1537 	        if (arr->Count() == 0) 
       
  1538 		        {
       
  1539 		        TDialogUtil::ShowErrorNoteL(R_ASP_NO_MAILBOXES);
       
  1540 		        return EFalse;   // no syncml mailbox
       
  1541 		        }
       
  1542 			}
       
  1543 		}
       
  1544 
       
  1545 	
       
  1546 
       
  1547 	return ETrue;
       
  1548 	}
       
  1549 
       
  1550 
       
  1551 //------------------------------------------------------------------------------
       
  1552 // CAspProfileWizardDialog::GetNavipaneText (from MAspEditorPageObserver)
       
  1553 //
       
  1554 //------------------------------------------------------------------------------
       
  1555 //
       
  1556 void CAspProfileWizardDialog::GetNavipaneText(TDes& aText, TInt aContentCount)
       
  1557 	{
       
  1558     CAspWizardItem* item = iWizard->CurrentItem();
       
  1559     
       
  1560     TInt total = iWizard->NumOfEnabledItems();
       
  1561     total--; // start page not included in page count
       
  1562     
       
  1563     TInt current = iWizard->NumOfCurrentItem(item);
       
  1564     current--; // start page not included in page count
       
  1565     
       
  1566     TInt enabledContentCount = iWizard->NumOfEnabledContentItems();
       
  1567     
       
  1568     total = total - enabledContentCount;
       
  1569     total = total + aContentCount;
       
  1570 
       
  1571     GetNaviPaneText(aText, current, total);
       
  1572 	}
       
  1573 
       
  1574 
       
  1575 //------------------------------------------------------------------------------
       
  1576 // CAspProfileWizardDialog::HandleEditorEvent (from MAspEditorPageObserver)
       
  1577 //
       
  1578 //------------------------------------------------------------------------------
       
  1579 //
       
  1580 void CAspProfileWizardDialog::HandleEditorEvent(TInt aEvent, TInt /*aValue*/)
       
  1581 	{
       
  1582 	if (aEvent == MAspEditorPageObserver::EKeyEvent)
       
  1583 		{
       
  1584 		HidePopupNote();
       
  1585 		TRAP_IGNORE( ShowPopupNoteL(KErrNotFound, KMsToWaitBeforeRePopup) );
       
  1586 		}
       
  1587 	}
       
  1588 	
       
  1589 
       
  1590 // -----------------------------------------------------------------------------
       
  1591 // CAspProfileWizardDialog::SetDefaultValuesL
       
  1592 // 
       
  1593 // -----------------------------------------------------------------------------
       
  1594 //
       
  1595 void CAspProfileWizardDialog::SetDefaultValuesL()
       
  1596 	{
       
  1597 	// use existing profile list for name creation
       
  1598 	if (iDialogParam->iProfileList)
       
  1599 		{
       
  1600 	    HBufC* hBuf = CAspProfile::GetNewProfileNameLC(
       
  1601 	                  iDialogParam->iProfileList, iApplicationId);
       
  1602 	    iWizard->SetStringValueL(hBuf->Des(), CAspWizardItem::ETypeProfileName);  
       
  1603 	    CleanupStack::PopAndDestroy(hBuf);
       
  1604 		}
       
  1605 	else
       
  1606 		{
       
  1607 		// create profile list for name creation
       
  1608 	    TAspParam param(EApplicationIdSync, iSyncSession);
       
  1609         CAspProfileList* list =  CAspProfileList::NewLC(param);
       
  1610 	    list->ReadAllProfilesL(CAspProfileList::EBasePropertiesOnly);
       
  1611 	
       
  1612 	    HBufC* hBuf = CAspProfile::GetNewProfileNameLC(list, iApplicationId);
       
  1613 	    iWizard->SetStringValueL(hBuf->Des(), CAspWizardItem::ETypeProfileName);
       
  1614 	    CleanupStack::PopAndDestroy(hBuf);
       
  1615 	
       
  1616 	    CleanupStack::PopAndDestroy(list);
       
  1617 		}
       
  1618 		
       
  1619 	if (iBearerHandler)
       
  1620 		{
       
  1621 		TInt bearerType = iBearerHandler->DefaultBearer();
       
  1622 		iWizard->SetNumberValue(bearerType, CAspWizardItem::ETypeBearerType);
       
  1623 		}
       
  1624 		
       
  1625 	TInt num = EAspProtocol_1_2;
       
  1626 	iWizard->SetNumberValue(num, CAspWizardItem::ETypeProtocolVersion);
       
  1627 	}
       
  1628 
       
  1629 
       
  1630 // -----------------------------------------------------------------------------
       
  1631 // CAspProfileWizardDialog::GetNaviPaneText
       
  1632 //
       
  1633 // Function constructs navi pane text. Text format is:
       
  1634 // "Page %0N/%1N"  (eg "Page 5/6")
       
  1635 // -----------------------------------------------------------------------------
       
  1636 //
       
  1637 void CAspProfileWizardDialog::GetNaviPaneText(TDes& aText, TInt aCurrent, TInt aFinal)
       
  1638 	{
       
  1639     TBuf <KBufSize> buf;
       
  1640     
       
  1641     // replace  %0N with aCurrent
       
  1642     StringLoader::Format(buf, iNaviPaneTextFormat, 0, aCurrent);
       
  1643     
       
  1644     // replace %1N with aFinal
       
  1645     StringLoader::Format(aText, buf, 1, aFinal);
       
  1646     
       
  1647     AknTextUtils::DisplayTextLanguageSpecificNumberConversion(aText);
       
  1648 	}
       
  1649 
       
  1650 
       
  1651 // -----------------------------------------------------------------------------
       
  1652 // CAspProfileWizardDialog::GetNaviPaneText
       
  1653 //
       
  1654 // -----------------------------------------------------------------------------
       
  1655 //
       
  1656 void CAspProfileWizardDialog::GetNaviPaneText(TDes& aText, CAspWizardItem* aItem)
       
  1657 	{
       
  1658     TInt total = iWizard->NumOfEnabledItems();
       
  1659     total--; // start page not included in page count
       
  1660     
       
  1661     TInt current = iWizard->NumOfCurrentItem(aItem);
       
  1662     current--; // start page not included in page count
       
  1663 
       
  1664     GetNaviPaneText(aText, current, total);
       
  1665 	}
       
  1666 
       
  1667 
       
  1668 // -----------------------------------------------------------------------------
       
  1669 // CAspProfileWizardDialog::UpdateCbaL
       
  1670 // 
       
  1671 // -----------------------------------------------------------------------------
       
  1672 //
       
  1673 void CAspProfileWizardDialog::UpdateCbaL(TInt aResourceId)
       
  1674     {
       
  1675     CEikButtonGroupContainer& cba = ButtonGroupContainer();
       
  1676     cba.SetCommandSetL(aResourceId);
       
  1677     cba.DrawDeferred();
       
  1678     }
       
  1679 
       
  1680 
       
  1681 // -----------------------------------------------------------------------------
       
  1682 // CAspProfileWizardDialog::SetTextEditorTextL
       
  1683 //
       
  1684 // -----------------------------------------------------------------------------
       
  1685 //
       
  1686 void CAspProfileWizardDialog::SetTextEditorTextL(TInt aResource)
       
  1687 	{
       
  1688 	if(iTextEditorText)
       
  1689 		{
       
  1690 		delete iTextEditorText;
       
  1691 		iTextEditorText = NULL;		
       
  1692 		}
       
  1693 	if (iMoveBack)
       
  1694 		{
       
  1695 		TRect mainPane;
       
  1696     	AknLayoutUtils::LayoutMetricsRect(AknLayoutUtils::EMainPane, mainPane);        
       
  1697     	iTextEditor->SetRect(mainPane);
       
  1698 		}
       
  1699 	iTextEditorText = CAspResHandler::ReadL(aResource);
       
  1700 	UpdateTextColorL() ;
       
  1701 	iTextEditor->SetTextL(iTextEditorText);
       
  1702 	}
       
  1703 
       
  1704 
       
  1705 // -----------------------------------------------------------------------------
       
  1706 // CAspProfileWizardDialog::ShowPopupNote
       
  1707 //
       
  1708 // -----------------------------------------------------------------------------
       
  1709 //
       
  1710 void CAspProfileWizardDialog::ShowPopupNoteL(TInt aResource, TInt aDelay) 
       
  1711     {
       
  1712     if (aResource != KErrNotFound)
       
  1713     	{
       
  1714     	HBufC* hBuf = CAspResHandler::ReadLC(aResource);    
       
  1715         iPopupNote->SetTextL(hBuf->Des());
       
  1716         CleanupStack::PopAndDestroy(hBuf);
       
  1717     	}
       
  1718     	
       
  1719     iPopupNote->SetTimePopupInView(KMsTimePopupInView);    
       
  1720     iPopupNote->SetTimeDelayBeforeShow(aDelay);
       
  1721     iPopupNote->ShowInfoPopupNote();    
       
  1722     }
       
  1723 
       
  1724 
       
  1725 // -----------------------------------------------------------------------------
       
  1726 // CAspProfileWizardDialog::HidePopupNote
       
  1727 //
       
  1728 // -----------------------------------------------------------------------------
       
  1729 //
       
  1730 void CAspProfileWizardDialog::HidePopupNote() 
       
  1731     {
       
  1732     iPopupNote->HideInfoPopupNote();
       
  1733     }
       
  1734 
       
  1735 
       
  1736 // -----------------------------------------------------------------------------
       
  1737 // CAspProfileWizardDialog::ShowErrorNoteL
       
  1738 //
       
  1739 // -----------------------------------------------------------------------------
       
  1740 //
       
  1741 void CAspProfileWizardDialog::ShowErrorNoteL(TInt aError)
       
  1742 	{
       
  1743 	if (aError == KErrNoMemory || aError == KErrDiskFull)
       
  1744 		{
       
  1745 		CTextResolver* tr = CTextResolver::NewLC();
       
  1746 		iBuf = tr->ResolveErrorString(aError, CTextResolver::ECtxNoCtxNoSeparator);
       
  1747      	CleanupStack::PopAndDestroy(tr);
       
  1748 		}
       
  1749 	else
       
  1750 		{
       
  1751 		CAspResHandler::ReadL(iBuf, R_ASP_LOG_ERR_PROFILE_WIZARD);
       
  1752 		}
       
  1753 		
       
  1754     TDialogUtil::ShowErrorNoteL(iBuf);
       
  1755 	}
       
  1756 
       
  1757 // -----------------------------------------------------------------------------
       
  1758 // CAspProfileWizardDialog::SetBackgroundContextL
       
  1759 //
       
  1760 // -----------------------------------------------------------------------------
       
  1761 //
       
  1762 void CAspProfileWizardDialog::SetBackgroundContextL( )
       
  1763 {
       
  1764 	TRect mainPane( 0,0,0,0 );
       
  1765 		
       
  1766 	AknLayoutUtils::LayoutMetricsRect( AknLayoutUtils::EScreen, mainPane );
       
  1767 	
       
  1768 	if (iBgContext)
       
  1769 		{
       
  1770 		delete iBgContext ;
       
  1771 		iBgContext = NULL ;
       
  1772 		}
       
  1773 	
       
  1774 	iBgContext = CAknsBasicBackgroundControlContext::NewL( 
       
  1775                         KAknsIIDQsnBgAreaMain, mainPane, EFalse );
       
  1776 		
       
  1777 	iTextEditor->SetSkinBackgroundControlContextL( iBgContext );                            
       
  1778 }
       
  1779 
       
  1780 
       
  1781 // -----------------------------------------------------------------------------
       
  1782 // CAspProfileWizardDialog::UpdateTextColorL
       
  1783 //
       
  1784 // -----------------------------------------------------------------------------
       
  1785 //
       
  1786 void CAspProfileWizardDialog::UpdateTextColorL() 
       
  1787 	{
       
  1788 	TRgb textColor( KRgbBlack );
       
  1789 	AknsUtils::GetCachedColor( AknsUtils::SkinInstance(), 
       
  1790 	                           textColor,
       
  1791 	                           KAknsIIDQsnTextColors,
       
  1792 	                           EAknsCIQsnTextColorsCG6 );
       
  1793 
       
  1794 
       
  1795 	const CFont* sysfont = AknLayoutUtils::FontFromId(EAknLogicalFontSecondaryFont); 
       
  1796 	TFontSpec sysfontspec = sysfont->FontSpecInTwips();
       
  1797 
       
  1798 	TCharFormat charFormat;
       
  1799 	TCharFormatMask charFormatMask;
       
  1800 	charFormat.iFontSpec = sysfontspec;
       
  1801 
       
  1802 	charFormat.iFontPresentation.iTextColor = textColor; 
       
  1803 	charFormatMask.SetAll();
       
  1804 	charFormatMask.SetAttrib( EAttFontHeight );
       
  1805 	charFormatMask.SetAttrib( EAttColor );
       
  1806 	CCharFormatLayer* formatLayer = CCharFormatLayer::NewL(charFormat, charFormatMask);
       
  1807 	iTextEditor->SetCharFormatLayer(formatLayer);
       
  1808 	}
       
  1809 
       
  1810 //  End of File