omads/omadsappui/AspSyncUtil/src/AspProfileDialog.cpp
changeset 0 dab8a81a92de
child 1 95fdac6ccb5c
equal deleted inserted replaced
-1:000000000000 0:dab8a81a92de
       
     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 
       
    20 // INCLUDE FILES
       
    21 
       
    22 #include "AspProfileDialog.h"
       
    23 #include "AspContentDialog.h"
       
    24 #include "AspSyncUtil.rh"
       
    25 #include "AspDebug.h"
       
    26 #include <csxhelp/ds.hlp.hrh>
       
    27 
       
    28 #include <aspsyncutil.mbg>  // for bitmap enumerations
       
    29 #include <AknIconArray.h>   // for GulArray
       
    30 #include <aknpasswordsettingpage.h>     // CAknAlphaPasswordSettingPage
       
    31 #include <ConnectionUiUtilities.h>      // CConnectionUiUtilities
       
    32 #include <featmgr.h>   // FeatureManager
       
    33 #include <cmdefconnvalues.h>
       
    34 #include <cmmanager.h>
       
    35 
       
    36 #include "AspSchedule.h"
       
    37 
       
    38 const TInt KMSKControlId( CEikButtonGroupContainer::EMiddleSoftkeyPosition );
       
    39 // ============================ MEMBER FUNCTIONS ===============================
       
    40 
       
    41 
       
    42 
       
    43 // -----------------------------------------------------------------------------
       
    44 // CAspProfileDialog::ShowDialogL
       
    45 // 
       
    46 // -----------------------------------------------------------------------------
       
    47 TBool CAspProfileDialog::ShowDialogL(const TAspParam& aParam)
       
    48 	{
       
    49 	CAspProfileDialog* dialog = CAspProfileDialog::NewL(aParam);
       
    50 
       
    51 	TBool ret = dialog->ExecuteLD(R_ASP_PROFILE_DIALOG);
       
    52 
       
    53     return ret;
       
    54 	}
       
    55 
       
    56 
       
    57 // -----------------------------------------------------------------------------
       
    58 // CAspProfileDialog::NewL
       
    59 //
       
    60 // -----------------------------------------------------------------------------
       
    61 CAspProfileDialog* CAspProfileDialog::NewL(const TAspParam& aParam)
       
    62     {
       
    63     FLOG( _L("CAspProfileDialog::NewL START") );
       
    64 
       
    65     CAspProfileDialog* self = new ( ELeave ) CAspProfileDialog(aParam);
       
    66     CleanupStack::PushL(self);
       
    67     self->ConstructL();
       
    68     CleanupStack::Pop(self);
       
    69 
       
    70     FLOG( _L("CAspProfileDialog::NewL END") );
       
    71     return self;
       
    72     }
       
    73 
       
    74 
       
    75 // -----------------------------------------------------------------------------
       
    76 // CAspProfileDialog::CAspProfileDialog
       
    77 // 
       
    78 // -----------------------------------------------------------------------------
       
    79 //
       
    80 CAspProfileDialog::CAspProfileDialog(const TAspParam& aParam)
       
    81 	{
       
    82     iSyncSession = aParam.iSyncSession;
       
    83     iApplicationId = aParam.iApplicationId;
       
    84     iProfile = aParam.iProfile;
       
    85     iContentList = aParam.iContentList;
       
    86     iProfileList = aParam.iProfileList;
       
    87     iEditMode = aParam.iMode;
       
    88     iMSKEmpty = EFalse;
       
    89        
       
    90 	__ASSERT_ALWAYS(iProfile, TUtil::Panic(KErrGeneral));
       
    91 	__ASSERT_ALWAYS(iContentList, TUtil::Panic(KErrGeneral));
       
    92 	__ASSERT_ALWAYS(iSyncSession, TUtil::Panic(KErrGeneral));
       
    93     }
       
    94 
       
    95 
       
    96 // -----------------------------------------------------------------------------
       
    97 // CAspProfileDialog::ConstructL
       
    98 //
       
    99 // -----------------------------------------------------------------------------
       
   100 //
       
   101 void CAspProfileDialog::ConstructL()
       
   102     {
       
   103     FLOG( _L("CAspProfileDialog::ConstructL START") );
       
   104 	
       
   105 	// contruct menu for our dialog
       
   106 	CAknDialog::ConstructL(R_ASP_PROFILE_DIALOG_MENU);
       
   107 
       
   108 	iResHandler = CAspResHandler::NewL();
       
   109 
       
   110 	iSettingList = new (ELeave) CArrayPtrFlat<CAspListItemData>(1);
       
   111 
       
   112     TAspParam param(KErrNotFound, iSyncSession);
       
   113 	iBearerHandler = CAspBearerHandler::NewL(param);
       
   114 	iApHandler = CAspAccessPointHandler::NewL(param);
       
   115 	
       
   116 	// get previous title so it can be restored
       
   117 	iSettingEnforcement = TUtil::SettingEnforcementState();
       
   118 	iStatusPaneHandler = CStatusPaneHandler::NewL(iAvkonAppUi);
       
   119 	iStatusPaneHandler->StoreOriginalTitleL();
       
   120 	
       
   121 	FLOG( _L("CAspProfileDialog::ConstructL END") );
       
   122     } 
       
   123 
       
   124 
       
   125 // ----------------------------------------------------------------------------
       
   126 // Destructor
       
   127 //
       
   128 // ----------------------------------------------------------------------------
       
   129 //
       
   130 CAspProfileDialog::~CAspProfileDialog()
       
   131     {
       
   132     FLOG( _L("CAspProfileDialog::~CAspProfileDialog START") );
       
   133 
       
   134 	delete iResHandler;
       
   135 	
       
   136 	if (iSettingList)
       
   137 		{
       
   138 		iSettingList->ResetAndDestroy();
       
   139 	    delete iSettingList;
       
   140 		}
       
   141 
       
   142 	delete iStatusPaneHandler;
       
   143 	delete iBearerHandler;
       
   144 	delete iApHandler;
       
   145 	
       
   146     if (iAvkonAppUi)
       
   147     	{
       
   148     	iAvkonAppUi->RemoveFromStack(this);
       
   149     	}
       
   150 
       
   151 	FLOG( _L("CAspProfileDialog::~CAspProfileDialog END") );
       
   152     }
       
   153 
       
   154 
       
   155 //------------------------------------------------------------------------------
       
   156 // CAspProfileDialog::ActivateL
       
   157 //
       
   158 // Called by system when dialog is activated.
       
   159 //------------------------------------------------------------------------------
       
   160 //
       
   161 void CAspProfileDialog::ActivateL()
       
   162 	{
       
   163     CAknDialog::ActivateL();
       
   164 
       
   165 	// this cannot be in ConstructL which is executed before dialog is launched
       
   166 	iAvkonAppUi->AddToStackL(this);
       
   167     }
       
   168 
       
   169 
       
   170 //------------------------------------------------------------------------------
       
   171 // CAspContentListDialog::GetHelpContext
       
   172 //
       
   173 //------------------------------------------------------------------------------
       
   174 //
       
   175 void CAspProfileDialog::GetHelpContext(TCoeHelpContext& aContext) const
       
   176 	{
       
   177 	aContext.iMajor = KUidSmlSyncApp;
       
   178 	aContext.iContext = KDS_HLP_SETTINGS;    
       
   179 	}
       
   180 
       
   181 
       
   182 // -----------------------------------------------------------------------------
       
   183 // CAspProfileDialog::HandleListBoxEventL
       
   184 // 
       
   185 // -----------------------------------------------------------------------------
       
   186 void CAspProfileDialog::HandleListBoxEventL(CEikListBox* /*aListBox*/,
       
   187                                             TListBoxEvent aEventType)
       
   188 	{
       
   189 	if( AknLayoutUtils::PenEnabled() )  
       
   190 	  {
       
   191 	   switch ( aEventType )
       
   192         {
       
   193          case EEventItemDoubleClicked:
       
   194               HandleOKL();
       
   195               break;
       
   196          case EEventEnterKeyPressed :
       
   197          case EEventItemClicked :
       
   198          case EEventItemDraggingActioned :
       
   199          case EEventPenDownOnItem :
       
   200         	  if(iEditMode != EDialogModeSettingEnforcement)
       
   201 				    {
       
   202 				    TRAPD(err ,CheckContentSettingL());//folder
       
   203 		         	User::LeaveIfError(err);
       
   204 				    }
       
   205               break;
       
   206          default:
       
   207               break;
       
   208         }
       
   209 		
       
   210 	  }
       
   211     
       
   212 	}
       
   213 
       
   214 // -----------------------------------------------------------------------------
       
   215 // CAspProfileDialog::PreLayoutDynInitL
       
   216 // 
       
   217 // -----------------------------------------------------------------------------
       
   218 //
       
   219 void CAspProfileDialog::PreLayoutDynInitL()
       
   220     {
       
   221     iSettingListBox = (CAknSettingStyleListBox*) ControlOrNull (EAspProfileDialogList);
       
   222     
       
   223    	__ASSERT_ALWAYS(iSettingListBox, TUtil::Panic(KErrGeneral));
       
   224     
       
   225 	iSettingListBox->SetListBoxObserver(this);
       
   226 	iSettingListBox->CreateScrollBarFrameL(ETrue);
       
   227 	iSettingListBox->ScrollBarFrame()->SetScrollBarVisibilityL(
       
   228 	                 CEikScrollBarFrame::EOn, CEikScrollBarFrame::EAuto);
       
   229 	
       
   230 	SetIconsL();
       
   231 	
       
   232 	// create array of setting items (iSettingList)
       
   233 	CreateSettingsListL();
       
   234 
       
   235 	// add setting headers into listbox
       
   236 	UpdateListBoxL(iSettingListBox, iSettingList);
       
   237 	
       
   238 	if (iEditMode == EDialogModeEditMandatory)
       
   239 		{
       
   240 		TInt index = CheckMandatoryFields();
       
   241 		if (index != KErrNotFound)
       
   242 			{
       
   243 			ListBox()->SetCurrentItemIndexAndDraw(index);
       
   244 			}
       
   245 		}
       
   246 	
       
   247 	TInt curIndex = ListBox()->CurrentItemIndex();
       
   248 		
       
   249 	CAspListItemData* curItem = GetItemForIndex(curIndex);
       
   250 	TBool isPCSuite = CAspProfile::IsPCSuiteProfile(iProfile);
       
   251     	
       
   252    	//if((isPCSuite && curItem->iHidden == EVisibilityReadOnly)
       
   253    	if(curItem->iHidden == EVisibilityReadOnly
       
   254    		|| iEditMode == EDialogModeSettingEnforcement)
       
   255    	{
       
   256    	   	 SetEmptyMiddleSoftKeyLabelL();
       
   257    	}
       
   258    	
       
   259 #ifdef RD_DSUI_TIMEDSYNC 
       
   260 	iStatusPaneHandler->SetTitleL(R_ASP_TITLE_PROFILE_SETTINGS);
       
   261 #else
       
   262     iProfile->GetName(iBuf);
       
   263     iStatusPaneHandler->SetTitleL(iBuf);
       
   264 #endif
       
   265 	iStatusPaneHandler->SetNaviPaneTitleL(KNullDesC);
       
   266     }
       
   267 
       
   268 
       
   269 // ----------------------------------------------------------------------------
       
   270 // CAspProfileDialog::SetMiddleSoftKeyLabelL
       
   271 //
       
   272 // ----------------------------------------------------------------------------
       
   273 //
       
   274 void CAspProfileDialog::SetEmptyMiddleSoftKeyLabelL()
       
   275     {
       
   276     ButtonGroupContainer().RemoveCommandFromStack(KMSKControlId,EAknSoftkeyOpen );
       
   277     HBufC* middleSKText = StringLoader::LoadLC( R_TEXT_SOFTKEY_EMPTY );
       
   278 
       
   279     ButtonGroupContainer().AddCommandToStackL(
       
   280         KMSKControlId,
       
   281         EAknSoftkeyEmpty,
       
   282         *middleSKText );
       
   283     iMSKEmpty= ETrue;
       
   284     CleanupStack::PopAndDestroy( middleSKText );
       
   285     }
       
   286 // ----------------------------------------------------------------------------
       
   287 // CAspProfileDialog::SetIconsL
       
   288 //
       
   289 // ----------------------------------------------------------------------------
       
   290 //
       
   291 void CAspProfileDialog::SetIconsL()
       
   292     {
       
   293     if (!iSettingListBox)
       
   294     	{
       
   295     	return;
       
   296     	}
       
   297  
       
   298  	TFileName bitmapName;
       
   299 	CAspResHandler::GetBitmapFileName(bitmapName);
       
   300 	CArrayPtr<CGulIcon>* icons = new (ELeave) CAknIconArray(KDefaultArraySize);
       
   301 	CleanupStack::PushL(icons);
       
   302 	
       
   303 	// Create the lock icon as the last icon in the table
       
   304 	CFbsBitmap* skinnedBitmap = NULL;
       
   305     CFbsBitmap* skinnedMask = NULL;
       
   306     
       
   307 	// Make the icon and put it in the array
       
   308     CGulIcon* icon = CGulIcon::NewL();
       
   309     CleanupStack::PushL(icon);
       
   310     icon->SetBitmapsOwnedExternally(EFalse);
       
   311 		
       
   312     MAknsSkinInstance* skin = AknsUtils::SkinInstance();
       
   313     // Create color icon
       
   314     AknsUtils::CreateColorIconL(skin,
       
   315 							    KAknsIIDQgnIndiSettProtectedAdd, 
       
   316 							    KAknsIIDQsnIconColors,
       
   317 							    EAknsCIQsnIconColorsCG13,
       
   318 							    skinnedBitmap, 
       
   319 							    skinnedMask,
       
   320 							    bitmapName,
       
   321 							    EMbmAspsyncutilQgn_indi_sett_protected_add, 
       
   322 							    EMbmAspsyncutilQgn_indi_sett_protected_add_mask,
       
   323 							    KRgbBlack
       
   324 							   );
       
   325 	
       
   326     icon->SetMask(skinnedMask);     // ownership transferred
       
   327     icon->SetBitmap(skinnedBitmap); // ownership transferred
       
   328     
       
   329 	icons->AppendL( icon );  
       
   330 
       
   331 	CleanupStack::Pop(icon); // icon
       
   332     // Create the lock icon for highlight
       
   333     skinnedBitmap = NULL;
       
   334     skinnedMask = NULL;
       
   335     
       
   336     // delete old icons
       
   337     CArrayPtr<CGulIcon>* arr =
       
   338 		iSettingListBox->ItemDrawer()->FormattedCellData()->IconArray();
       
   339     
       
   340     if (arr)
       
   341     	{
       
   342     	arr->ResetAndDestroy();
       
   343 	    delete arr;
       
   344 	    arr = NULL;
       
   345     	}
       
   346 
       
   347 	iSettingListBox->ItemDrawer()->FormattedCellData()->SetIconArrayL(icons);
       
   348 	CleanupStack::Pop(icons);
       
   349     }
       
   350 
       
   351 // -----------------------------------------------------------------------------
       
   352 // CAspProfileDialog::IconL
       
   353 // 
       
   354 // -----------------------------------------------------------------------------
       
   355 //
       
   356 CGulIcon* CAspProfileDialog::IconL(TAknsItemID aId, const TDesC& aFileName, TInt aFileIndex, TInt aFileMaskIndex)
       
   357 	{
       
   358     return TDialogUtil::CreateIconL(aId, aFileName, aFileIndex, aFileMaskIndex);
       
   359 	}
       
   360 
       
   361 
       
   362 //------------------------------------------------------------------------------
       
   363 // CAspProfileDialog::DynInitMenuPaneL
       
   364 //
       
   365 // Called by system before menu is shown.
       
   366 //------------------------------------------------------------------------------
       
   367 //
       
   368 void CAspProfileDialog::DynInitMenuPaneL(TInt /*aResourceID*/, CEikMenuPane* aMenuPane)
       
   369 	{
       
   370    
       
   371    	if (ListBox()->Model()->NumberOfItems() == 0) 
       
   372 		{
       
   373 		TDialogUtil::DeleteMenuItem(aMenuPane, EAspMenuCmdChange);
       
   374 		return;
       
   375 		}
       
   376 
       
   377 	CAspListItemData* item = GetItemForIndex(ListBox()->CurrentItemIndex());
       
   378 	if (item->iHidden == EVisibilityReadOnly)
       
   379 		{
       
   380 		TDialogUtil::DeleteMenuItem(aMenuPane, EAspMenuCmdChange);
       
   381 		}
       
   382 	
       
   383 	if (!FeatureManager::FeatureSupported(KFeatureIdHelp))
       
   384 		{
       
   385 		TDialogUtil::DeleteMenuItem(aMenuPane, EAknCmdHelp);
       
   386 		}
       
   387 	
       
   388     }
       
   389 
       
   390 
       
   391 //------------------------------------------------------------------------------
       
   392 // CAspProfileDialog::ProcessCommandL
       
   393 //
       
   394 // Handle commands from menu.
       
   395 //------------------------------------------------------------------------------
       
   396 //
       
   397 void CAspProfileDialog::ProcessCommandL(TInt aCommandId)
       
   398 	{
       
   399 	HideMenu();
       
   400 
       
   401 	switch (aCommandId)
       
   402 		{
       
   403 		case EAknCmdHelp:
       
   404 			{
       
   405 			TUtil::LaunchHelpAppL(iEikonEnv);
       
   406             break;
       
   407 			}
       
   408 
       
   409 		case EAspMenuCmdChange:
       
   410 		case EAspMenuCmdOpen:
       
   411 			{				
       
   412     		CAspListItemData* item = GetItemForIndex(ListBox()->CurrentItemIndex());
       
   413 
       
   414 			if (item->iItemType == CAspListItemData::ETypeListYesNo)
       
   415 				{
       
   416 				// open editor for Yes/No setting
       
   417 				if (EditSettingItemListL(*item))
       
   418 					{
       
   419 					SetVisibility();
       
   420 					UpdateListBoxL(ListBox(), iSettingList);
       
   421 					}
       
   422 				}				
       
   423 			else
       
   424 				{
       
   425 				HandleOKL();
       
   426 				}
       
   427 
       
   428 			break;
       
   429 			}
       
   430 		    
       
   431         case EAspMenuCmdExit:
       
   432         case EAknCmdExit:
       
   433         case EEikCmdExit:
       
   434 			{
       
   435 			// close dialog and exit calling application
       
   436 			iAvkonAppUi->ProcessCommandL(EAknCmdExit);
       
   437 			break;
       
   438 			}
       
   439 
       
   440 		default:			
       
   441 		    break;
       
   442 		}
       
   443 	}
       
   444 
       
   445 
       
   446 //------------------------------------------------------------------------------
       
   447 // CAspProfileDialog::OkToExitL
       
   448 //
       
   449 //------------------------------------------------------------------------------
       
   450 //
       
   451 TBool CAspProfileDialog::OkToExitL(TInt aButtonId)
       
   452 	{
       
   453 	if (aButtonId == EEikBidCancel)
       
   454 		{
       
   455 		// save silently and close dialog
       
   456 		
       
   457 		CheckSettingValues(aButtonId);
       
   458 
       
   459 		TRAP_IGNORE(SaveSettingsL());
       
   460 		return ETrue; // close dialog
       
   461 		}
       
   462 
       
   463 	if (aButtonId == EAknSoftkeyBack)
       
   464         {
       
   465         TBool ret = CheckSettingValues(aButtonId);
       
   466         if (!ret)
       
   467         	{
       
   468         	return EFalse; // leave dialog open
       
   469         	}
       
   470         	
       
   471 		TRAP_IGNORE(SaveSettingsL());
       
   472 		return ETrue; // close dialog
       
   473 		}
       
   474 		
       
   475 	if (aButtonId == EAknSoftkeyOpen || aButtonId == EAknSoftkeyEmpty)  // MSK
       
   476         {
       
   477 		CAspListItemData* item = GetItemForIndex(ListBox()->CurrentItemIndex());
       
   478 		if (item->iHidden == EVisibilityReadOnly)
       
   479 			{
       
   480     		if(iEditMode == EDialogModeSettingEnforcement)
       
   481     		{
       
   482     			TDialogUtil::ShowInformationNoteL(R_ASP_PROTECTED_SETTING);
       
   483     		}
       
   484      		else
       
   485      		{
       
   486 			TDialogUtil::ShowInformationNoteL(R_ASP_NOTE_READ_ONLY);
       
   487      		}
       
   488 			return EFalse;
       
   489 			}
       
   490 
       
   491         HandleOKL();
       
   492 		return EFalse;  // leave dialog open
       
   493 		}
       
   494 		
       
   495 	if (aButtonId == EAknSoftkeyOptions)	
       
   496 		{
       
   497 		if (iCommandSetId == R_ASP_CBA_OPTIONS_BACK_OPEN)
       
   498 			{
       
   499 			UpdateMenuL(R_ASP_PROFILE_CONTEXT_MENU);
       
   500 			}	
       
   501 		else 
       
   502 			{
       
   503 			UpdateMenuL(R_ASP_PROFILE_DIALOG_MENU);	
       
   504 			}
       
   505 		return EFalse;
       
   506 		}
       
   507 	return CAknDialog::OkToExitL(aButtonId);
       
   508 	}
       
   509 
       
   510 
       
   511 //------------------------------------------------------------------------------
       
   512 // CAspProfileDialog::CheckSettingValuesL
       
   513 //
       
   514 //------------------------------------------------------------------------------
       
   515 //
       
   516 TBool CAspProfileDialog::CheckSettingValuesL(TInt aButtonId)
       
   517 	{
       
   518     if (iEditMode == EDialogModeReadOnly || 
       
   519         iEditMode == EDialogModeSettingEnforcement)
       
   520     	{
       
   521     	return ETrue;
       
   522     	}
       
   523 	
       
   524 	if (aButtonId == EEikBidCancel)
       
   525 		{
       
   526 		TInt index = CheckUniqueServerId();
       
   527 		if (index != KErrNotFound)
       
   528 			{
       
   529 			Item(EAspServerId)->SetValueL(iOldServerId);
       
   530 			}
       
   531 
       
   532 		return ETrue;
       
   533 		}
       
   534 
       
   535 	TInt mandatoryIndex = CheckMandatoryFields();
       
   536 	if (mandatoryIndex != KErrNotFound)
       
   537 		{
       
   538 		if (!TDialogUtil::ShowConfirmationQueryL(R_ASP_EXIT_ANYWAY))
       
   539 			{
       
   540 			ListBox()->SetCurrentItemIndexAndDraw(mandatoryIndex);
       
   541 			return EFalse; // leave dialog open
       
   542 			}
       
   543 				
       
   544 	    TInt serverIdIndex = CheckUniqueServerId();
       
   545 	    if (serverIdIndex != KErrNotFound)
       
   546 	    	{
       
   547 	    	Item(EAspServerId)->SetValueL(iOldServerId);
       
   548 	    	}
       
   549 		}
       
   550 	else
       
   551 		{
       
   552 		TInt serverIdIndex = CheckUniqueServerId();
       
   553 	    if (serverIdIndex != KErrNotFound)
       
   554 		    {
       
   555 		    if (!TDialogUtil::ShowConfirmationQueryL(R_ASP_SERVER_ID_EXISTS))
       
   556 			    {
       
   557 			    ListBox()->SetCurrentItemIndexAndDraw(serverIdIndex);
       
   558 			    return EFalse; // leave dialog open
       
   559 			    }
       
   560 		    else
       
   561 			    {
       
   562 			    Item(EAspServerId)->SetValueL(iOldServerId);
       
   563 			    }
       
   564 		    }
       
   565 		}
       
   566 
       
   567     return ETrue;
       
   568 	}
       
   569 
       
   570 
       
   571 //------------------------------------------------------------------------------
       
   572 // CAspProfileDialog::CheckSettingValues
       
   573 //
       
   574 //------------------------------------------------------------------------------
       
   575 //
       
   576 TBool CAspProfileDialog::CheckSettingValues(TInt aButtonId)
       
   577 	{
       
   578 	TBool ret = EFalse;
       
   579 	
       
   580 	TRAPD(err, ret = CheckSettingValuesL(aButtonId));
       
   581 	if (err != KErrNone)
       
   582 		{
       
   583 		return ETrue;
       
   584 		}
       
   585 
       
   586 	return ret;
       
   587 	}
       
   588 
       
   589 
       
   590 // ----------------------------------------------------------------------------
       
   591 // CAspProfileDialog::OfferKeyEventL
       
   592 // 
       
   593 // ----------------------------------------------------------------------------
       
   594 //
       
   595 TKeyResponse CAspProfileDialog::OfferKeyEventL(const TKeyEvent& aKeyEvent,TEventCode aType)
       
   596 	{
       
   597 	if (aType == EEventKey)
       
   598 		{
       
   599 		switch (aKeyEvent.iCode)
       
   600 			{
       
   601 			case EKeyEnter:
       
   602 				{
       
   603 					HandleOKL();
       
   604 					return EKeyWasConsumed;
       
   605 				}
       
   606 			case EKeyEscape:  // framework calls this when dialog must shut down
       
   607 				{
       
   608 				return CAknDialog::OfferKeyEventL(aKeyEvent, aType);
       
   609         		}
       
   610 			case EKeyUpArrow:
       
   611 			case EKeyDownArrow:
       
   612 			    {
       
   613 			    	if(iEditMode != EDialogModeSettingEnforcement)
       
   614 				    {
       
   615 				    TRAPD(err ,CheckContentSettingL(aKeyEvent));//folder
       
   616 		         	User::LeaveIfError(err);
       
   617 				    }
       
   618 			    break;
       
   619 			    }
       
   620             default:
       
   621 				{
       
   622 			    break;
       
   623 				}
       
   624 			}
       
   625 		}
       
   626 
       
   627 	return CAknDialog::OfferKeyEventL( aKeyEvent, aType);
       
   628 	}
       
   629 
       
   630 // ---------------------------------------------------------------------------------------------
       
   631 // CAspProfileDialog::CheckContentSetting
       
   632 // modifies MSK and menu item depending on the item in the list box when touch events are handled
       
   633 // ----------------------------------------------------------------------------------------------
       
   634 //
       
   635 
       
   636 void CAspProfileDialog::CheckContentSettingL()
       
   637 {
       
   638 	TInt curIndex = ListBox()->CurrentItemIndex();
       
   639 	TInt count = iSettingList->Count();
       
   640 	CAspListItemData* lastItem = (*iSettingList)[--count];
       
   641 	
       
   642 
       
   643 		
       
   644 	CAspListItemData* curItem = GetItemForIndex(curIndex);
       
   645 	TBool isPCSuite = CAspProfile::IsPCSuiteProfile(iProfile);
       
   646 	if(isPCSuite && (curItem->iHidden == EVisibilityReadOnly))
       
   647 	{
       
   648    		SetEmptyMiddleSoftKeyLabelL();
       
   649    		return;
       
   650 	}
       
   651 	if(curItem->iItemId != EAspSyncContent)
       
   652 		{
       
   653 		if(iCommandSetId != R_ASP_CBA_OPTIONS_BACK_CHANGE || iMSKEmpty)
       
   654 			{
       
   655 			UpdateCbaL(R_ASP_CBA_OPTIONS_BACK_CHANGE);
       
   656 		
       
   657 			}
       
   658 		return;		
       
   659 		}
       
   660 	UpdateCbaL( R_ASP_CBA_OPTIONS_BACK_OPEN);
       
   661 
       
   662 }
       
   663 
       
   664 // ----------------------------------------------------------------------------
       
   665 // CAspProfileDialog::CheckContentSetting
       
   666 // modifies MSK depending on the item
       
   667 // ----------------------------------------------------------------------------
       
   668 //
       
   669 
       
   670 void CAspProfileDialog::CheckContentSettingL(const TKeyEvent& aKeyEvent)
       
   671 	{
       
   672 	
       
   673 	TInt curIndex = ListBox()->CurrentItemIndex();
       
   674 	TInt count = iSettingList->Count();
       
   675 	CAspListItemData* lastItem = (*iSettingList)[--count];
       
   676 	
       
   677 	switch (aKeyEvent.iCode)
       
   678 		{
       
   679 		case EKeyUpArrow:
       
   680 			{
       
   681 				if (curIndex)
       
   682 				{
       
   683 					curIndex--;
       
   684 				}
       
   685 				else
       
   686 				{
       
   687 				    curIndex = lastItem->iIndex;
       
   688 				}
       
   689 			break;
       
   690 			}
       
   691 		case EKeyDownArrow:
       
   692 			{
       
   693 				if (curIndex == lastItem->iIndex)
       
   694 				{
       
   695 				curIndex = 0;
       
   696 				}
       
   697 				else
       
   698 				{
       
   699 				curIndex++;
       
   700 				}
       
   701 			break;
       
   702 			}
       
   703 		}
       
   704 		
       
   705 	CAspListItemData* curItem = GetItemForIndex(curIndex);
       
   706 	if(curItem->iHidden == EVisibilityReadOnly)
       
   707 	{
       
   708    		SetEmptyMiddleSoftKeyLabelL();
       
   709    		return;
       
   710 	}
       
   711 	if(curItem->iItemId != EAspSyncContent)
       
   712 		{
       
   713 		if(iCommandSetId != R_ASP_CBA_OPTIONS_BACK_CHANGE || iMSKEmpty)
       
   714 			{
       
   715 			UpdateCbaL(R_ASP_CBA_OPTIONS_BACK_CHANGE);
       
   716 		
       
   717 			}
       
   718 		return;		
       
   719 		}
       
   720 	UpdateCbaL( R_ASP_CBA_OPTIONS_BACK_OPEN);
       
   721 
       
   722 	}
       
   723 
       
   724 // ----------------------------------------------------------------------------
       
   725 // CAspProfileDialog::HandleResourceChange
       
   726 // 
       
   727 // ----------------------------------------------------------------------------
       
   728 //
       
   729 void CAspProfileDialog::HandleResourceChange(TInt aType)
       
   730     {   
       
   731     if (aType == KEikDynamicLayoutVariantSwitch) //Handle change in layout orientation
       
   732         {
       
   733         TRect mainPaneRect;
       
   734         AknLayoutUtils::LayoutMetricsRect(AknLayoutUtils::EMainPane, mainPaneRect);
       
   735         SetRect(mainPaneRect);
       
   736         iSettingListBox->SetSize(mainPaneRect.Size());
       
   737         CCoeControl::HandleResourceChange(aType);
       
   738 		DrawDeferred();
       
   739 	    return;
       
   740 		}
       
   741 		
       
   742     if (aType == KAknsMessageSkinChange)
       
   743         {
       
   744         TRAP_IGNORE(SetIconsL());
       
   745         }
       
   746 		
       
   747     CCoeControl::HandleResourceChange(aType);
       
   748     }
       
   749 
       
   750 
       
   751 //------------------------------------------------------------------------------
       
   752 // CAspProfileDialog::CheckMandatoryFields
       
   753 //
       
   754 // Check that all mandatory fields are filled.
       
   755 //------------------------------------------------------------------------------
       
   756 //
       
   757 TInt CAspProfileDialog::CheckMandatoryFields()
       
   758 	{ 
       
   759 	TInt count = iSettingList->Count();
       
   760 	for (TInt i=0; i<count; i++)
       
   761 		{
       
   762 		CAspListItemData* item = (*iSettingList)[i];
       
   763 		
       
   764 		if (!CheckMandatoryContentFields(item))
       
   765 			{
       
   766 			return item->iIndex;
       
   767 			}
       
   768 			
       
   769 		if ( item->iMandatory && item->IsEmpty() && (item->iHidden == EVisibilityNormal) )
       
   770 			{
       
   771 			return item->iIndex;
       
   772 			}
       
   773 		}
       
   774 
       
   775     return KErrNotFound;
       
   776 	}
       
   777 
       
   778 
       
   779 //------------------------------------------------------------------------------
       
   780 // CAspProfileDialog::CheckUniqueServerId
       
   781 //
       
   782 //------------------------------------------------------------------------------
       
   783 //
       
   784 TInt CAspProfileDialog::CheckUniqueServerId()
       
   785 	{
       
   786 	TPtrC ptr = Item(EAspServerId)->Value();
       
   787 	
       
   788 	if (iOldServerId.Compare(ptr) == 0)
       
   789 		{
       
   790 		return KErrNotFound;  // server id has not changed
       
   791 		}
       
   792 	
       
   793 	if (!iProfileList)
       
   794 		{
       
   795 		return KErrNotFound;
       
   796 		}
       
   797 
       
   798 	TInt profileId = iProfile->ProfileId();
       
   799 
       
   800 	if (iProfileList->IsUniqueServerId(Item(EAspServerId)->Value(), profileId))
       
   801 		{
       
   802 		return KErrNotFound;
       
   803 		}
       
   804 		
       
   805 	return Item(EAspServerId)->iIndex;
       
   806 	}
       
   807 
       
   808 
       
   809 //------------------------------------------------------------------------------
       
   810 // CAspProfileDialog::CheckMandatoryContentFields
       
   811 //
       
   812 // Check that all mandatory fields are filled.
       
   813 //------------------------------------------------------------------------------
       
   814 //
       
   815 TBool CAspProfileDialog::CheckMandatoryContentFields(CAspListItemData* aListItem)
       
   816 	{
       
   817 	if (aListItem->iItemType != CAspListItemData::ETypeSyncContent)
       
   818 		{
       
   819 		return ETrue;
       
   820 		}
       
   821 		
       
   822 	TInt index = iContentList->FindTaskIndexForProvider(aListItem->iNumberData);
       
   823 	if (index == KErrNotFound)
       
   824 		{
       
   825 		return ETrue;
       
   826 		}
       
   827 		
       
   828 	TAspTaskItem& item = iContentList->TaskItem(index);
       
   829 	if (item.iEnabled && !item.iRemoteDatabaseDefined)
       
   830 		{
       
   831 		return EFalse;
       
   832 		}
       
   833 		
       
   834     return ETrue;
       
   835 	}
       
   836 
       
   837 
       
   838 //------------------------------------------------------------------------------
       
   839 // CAspProfileDialog::HandleOKL
       
   840 //
       
   841 //------------------------------------------------------------------------------
       
   842 //
       
   843 void CAspProfileDialog::HandleOKL()
       
   844 	{
       
   845 	CAspListItemData* item = GetItemForIndex(ListBox()->CurrentItemIndex());
       
   846 
       
   847 	if (item->iHidden == EVisibilityReadOnly)
       
   848 		{
       
   849 			if(iEditMode == EDialogModeSettingEnforcement)
       
   850       		{
       
   851     			TDialogUtil::ShowInformationNoteL(R_ASP_PROTECTED_SETTING);
       
   852     		}
       
   853      		else
       
   854      		{
       
   855 			TDialogUtil::ShowInformationNoteL(R_ASP_NOTE_READ_ONLY);
       
   856      		}
       
   857 		return;
       
   858 		}
       
   859 
       
   860 	if (EditSettingItemL(*item))
       
   861 		{
       
   862 		SetVisibility();
       
   863 		UpdateListBoxL(ListBox(), iSettingList);
       
   864 		}
       
   865 	}
       
   866 
       
   867 
       
   868 // ----------------------------------------------------------------------------
       
   869 // CAspProfileDialog::CreateSettingsListL
       
   870 // 
       
   871 // Function creates setting list array (iSettingsList).
       
   872 // Note: enum TAspConnectionSettings must match with string array
       
   873 // (R_ASP_CONNECTION_DIALOG_SETTING_ITEMS).
       
   874 // ----------------------------------------------------------------------------
       
   875 //
       
   876 void CAspProfileDialog::CreateSettingsListL()
       
   877 	{
       
   878 	// read setting headers from resource
       
   879 	CDesCArray* arr = iResHandler->ReadDesArrayLC(R_ASP_CONNECTION_DIALOG_SETTING_ITEMS);
       
   880 	
       
   881 	// add one CAspListItemData for each setting
       
   882 	AddItemL(EAspProfileName, arr);
       
   883 	AddItemL(EAspProtocolVersion, arr);
       
   884 	AddItemL(EAspServerId, arr);
       
   885 
       
   886 	AddItemL(EAspConnType, arr);
       
   887 	AddItemL(EAspAccessPoint,R_ASP_NETWORK_DESTINATION);
       
   888 	AddItemL(EAspHostAddress, arr);
       
   889 	AddItemL(EAspPort, arr);
       
   890 	AddItemL(EAspUsername, arr);
       
   891 	AddItemL(EAspPassword, arr);
       
   892 	
       
   893 #ifdef __SYNCML_DS_ALERT
       
   894 	AddItemL(EAspServerAlert, arr);
       
   895 #endif
       
   896 
       
   897 	AddItemL(EAspHttpsUsername, arr);
       
   898 	AddItemL(EAspHttpsPassword, arr);
       
   899 	
       
   900 	AddItemL(EAspSyncDirection, arr);
       
   901 	
       
   902 #ifndef	RD_DSUI_TIMEDSYNC 
       
   903 	AddContentItemsL();
       
   904 #endif
       
   905 
       
   906 	// write setting data into each CAspListItemData
       
   907 	TInt count=iSettingList->Count();
       
   908 	for (TInt i=0; i<count; i++)
       
   909 		{
       
   910 		InitSettingItemL((*iSettingList)[i]);
       
   911 		}
       
   912 
       
   913 	SetVisibility();  // find out what setting appear on UI
       
   914 
       
   915 	CleanupStack::PopAndDestroy(arr);
       
   916 	}
       
   917 
       
   918 
       
   919 // ----------------------------------------------------------------------------
       
   920 // CAspProfileDialog::AddItemL
       
   921 // 
       
   922 // ----------------------------------------------------------------------------
       
   923 //
       
   924 void CAspProfileDialog::AddItemL(TInt aItemId, CDesCArray* aHeaders)
       
   925 	{
       
   926     CAspListItemData* item = CAspListItemData::NewLC();
       
   927 	item->SetHeaderL((*aHeaders)[aItemId]);
       
   928 	item->iItemId = aItemId;
       
   929 	iSettingList->AppendL(item);
       
   930 	CleanupStack::Pop(item);
       
   931 	}
       
   932 
       
   933 
       
   934 // ----------------------------------------------------------------------------
       
   935 // CAspProfileDialog::AddItemL
       
   936 // 
       
   937 // ----------------------------------------------------------------------------
       
   938 //
       
   939 void CAspProfileDialog::AddItemL(TInt aItemId, TInt aResourceId)
       
   940 	{
       
   941     CAspListItemData* item = CAspListItemData::NewLC();
       
   942 	item->SetHeaderL(aResourceId);
       
   943 	item->iItemId = aItemId;
       
   944 	iSettingList->AppendL(item);
       
   945 	CleanupStack::Pop(item);
       
   946 	}
       
   947 
       
   948 
       
   949 // ----------------------------------------------------------------------------
       
   950 // CAspProfileDialog::AddContentItemsL
       
   951 // 
       
   952 // ----------------------------------------------------------------------------
       
   953 //
       
   954 void CAspProfileDialog::AddContentItemsL()
       
   955 	{
       
   956    	TInt count = iContentList->ProviderCount();
       
   957 
       
   958 	for (TInt i=0; i<count; i++)
       
   959 		{
       
   960 		TAspProviderItem& providerItem = iContentList->ProviderItem(i);
       
   961 		TInt appId = TUtil::AppIdFromProviderId(providerItem.iDataProviderId);
       
   962 		if (iApplicationId != EApplicationIdSync && iApplicationId != appId)
       
   963 			{
       
   964 			continue;
       
   965 			}
       
   966 				
       
   967 		HBufC* firstLine = CAspResHandler::GetContentSettingLC(
       
   968 		                                   providerItem.iDataProviderId,
       
   969 		                                   providerItem.iDisplayName);
       
   970 		
       
   971 	    CAspListItemData* item = CAspListItemData::NewLC();
       
   972     
       
   973     	item->SetHeaderL(firstLine->Des());
       
   974 	    item->iItemId = EAspSyncContent;
       
   975 	    item->iItemType = CAspListItemData::ETypeSyncContent;
       
   976 	    item->iNumberData = providerItem.iDataProviderId;
       
   977 	    iSettingList->AppendL(item);
       
   978 	    CleanupStack::Pop(item);
       
   979 	    
       
   980 	    CleanupStack::PopAndDestroy(firstLine);
       
   981     	}
       
   982 	}
       
   983 
       
   984 
       
   985 // ----------------------------------------------------------------------------
       
   986 // CAspProfileDialog::UpdateListBoxL
       
   987 // 
       
   988 // Add settings headers into listbox.
       
   989 // ----------------------------------------------------------------------------
       
   990 //
       
   991 void CAspProfileDialog::UpdateListBoxL(CEikTextListBox* aListBox,
       
   992                                        CAspSettingList* aItemList)
       
   993 	{
       
   994 	CDesCArray* arr = (CDesCArray*)aListBox->Model()->ItemTextArray();
       
   995 	arr->Reset();
       
   996 
       
   997 	TInt count = aItemList->Count();
       
   998 	for (TInt i=0; i<count; i++ )
       
   999 		{	
       
  1000 		CAspListItemData* item = (*aItemList)[i];
       
  1001 		TInt id = item->iItemId;
       
  1002 		
       
  1003 		TBool convert = ETrue;
       
  1004 	   TBool isPCSuite=CAspProfile::IsPCSuiteProfile(iProfile);
       
  1005        TBool readOnly = iProfile->DeleteAllowed();
       
  1006        if(isPCSuite && !readOnly||iSettingEnforcement)
       
  1007         {
       
  1008                 if(id==EAspAccessPoint || id==EAspSyncDirection ||id==EAspConnType)
       
  1009         	       convert = EFalse;//no number conversion
       
  1010         }
       
  1011        if(!isPCSuite &&!readOnly)
       
  1012        {
       
  1013                 if(id==EAspAccessPoint ||id==EAspConnType)
       
  1014         	       convert = EFalse;//no number conversion
       
  1015        }	
       
  1016 		if (id == EAspServerId || id == EAspHostAddress ||
       
  1017 	       id == EAspPort || id == EAspUsername || id == EAspHttpsUsername||iSettingEnforcement)
       
  1018 			{
       
  1019 			convert = EFalse; // no number conversion
       
  1020 			}
       
  1021 
       
  1022 		if (item->iHidden != EVisibilityHidden)
       
  1023 			{
       
  1024 			HBufC* hBuf = item->ListItemTextL(convert);
       
  1025 			CleanupStack::PushL(hBuf);
       
  1026 			
       
  1027 			arr->AppendL(hBuf->Des());
       
  1028 			
       
  1029 			// store listbox index (from zero up) into setting item 
       
  1030 			item->iIndex = arr->Count() - 1;
       
  1031 
       
  1032 			CleanupStack::PopAndDestroy(hBuf);
       
  1033 			}
       
  1034 		else
       
  1035 			{
       
  1036 			item->iIndex = KErrNotFound;
       
  1037 			}
       
  1038 		}
       
  1039 
       
  1040 	ListBox()->HandleItemAdditionL();
       
  1041 	}
       
  1042 
       
  1043 
       
  1044 // -----------------------------------------------------------------------------
       
  1045 // CAspProfileDialog::SetVisibility
       
  1046 // 
       
  1047 // -----------------------------------------------------------------------------
       
  1048 //
       
  1049 void CAspProfileDialog::SetVisibility()
       
  1050 	{
       
  1051     TBool isPCSuite = CAspProfile::IsPCSuiteProfile(iProfile);
       
  1052     
       
  1053     TBool readOnly = iProfile->DeleteAllowed();
       
  1054 	
       
  1055 	if (Item(EAspProtocolVersion)->iNumberData == EAspProtocol_1_1)
       
  1056 		{
       
  1057 		Item(EAspServerId)->iHidden = EVisibilityHidden;
       
  1058 		}
       
  1059 	else if (isPCSuite || !readOnly)
       
  1060 		{
       
  1061 		Item(EAspServerId)->iHidden = EVisibilityReadOnly;
       
  1062 		}
       
  1063 	else
       
  1064 		{
       
  1065 		Item(EAspServerId)->iHidden = EVisibilityNormal;
       
  1066 		}
       
  1067 	
       
  1068 	
       
  1069 	if (isPCSuite || !readOnly)
       
  1070 		{
       
  1071 		Item(EAspConnType)->iHidden = EVisibilityReadOnly;
       
  1072 		}
       
  1073 	else
       
  1074 		{
       
  1075 		Item(EAspConnType)->iHidden = EVisibilityNormal;
       
  1076 		}
       
  1077 
       
  1078 	if (isPCSuite || !readOnly)
       
  1079 		{
       
  1080 		Item(EAspHostAddress)->iHidden = EVisibilityReadOnly;
       
  1081 		}
       
  1082 	else
       
  1083 		{
       
  1084 		Item(EAspHostAddress)->iHidden = EVisibilityNormal;
       
  1085 		}
       
  1086 		
       
  1087 	if(isPCSuite)
       
  1088 	{
       
  1089 		Item(EAspSyncDirection)->iHidden = EVisibilityReadOnly;
       
  1090 	}
       
  1091 	else
       
  1092 	{
       
  1093 		Item(EAspSyncDirection)->iHidden = EVisibilityNormal;
       
  1094 	}
       
  1095     
       
  1096 		
       
  1097 
       
  1098 	if (iBearerHandler->SupportedBearerCount() == 1)
       
  1099 		{
       
  1100 		Item(EAspConnType)->iHidden = EVisibilityReadOnly;
       
  1101 		}
       
  1102 	
       
  1103     Item(EAspUsername)->iHidden = EVisibilityNormal;
       
  1104 	Item(EAspPassword)->iHidden = EVisibilityNormal;
       
  1105 
       
  1106 	if (Item(EAspConnType)->iNumberData != EAspBearerInternet)
       
  1107 		{
       
  1108 		Item(EAspAccessPoint)->iHidden = EVisibilityHidden;
       
  1109 		Item(EAspPort)->iHidden = EVisibilityHidden;
       
  1110 		Item(EAspHttpsUsername)->iHidden = EVisibilityHidden;
       
  1111 		Item(EAspHttpsPassword)->iHidden = EVisibilityHidden;
       
  1112     	}
       
  1113 	else
       
  1114 		{
       
  1115 		Item(EAspAccessPoint)->iHidden = EVisibilityNormal;
       
  1116 		Item(EAspPort)->iHidden = EVisibilityNormal;
       
  1117 		Item(EAspHttpsUsername)->iHidden = EVisibilityNormal;
       
  1118 		Item(EAspHttpsPassword)->iHidden = EVisibilityNormal;
       
  1119 		}
       
  1120 		
       
  1121 #ifdef __SYNCML_DS_ALERT
       
  1122     Item(EAspServerAlert)->iHidden = EVisibilityNormal;
       
  1123 #endif
       
  1124 	
       
  1125     if (iEditMode == EDialogModeReadOnly || 
       
  1126         iEditMode == EDialogModeSettingEnforcement)
       
  1127     	{
       
  1128     	SetAllReadOnly();
       
  1129     	}
       
  1130 	}
       
  1131 
       
  1132 
       
  1133 // -----------------------------------------------------------------------------
       
  1134 // CAspContentDialog::SetAllReadOnly
       
  1135 // 
       
  1136 // -----------------------------------------------------------------------------
       
  1137 //
       
  1138 void CAspProfileDialog::SetAllReadOnly()
       
  1139 	{
       
  1140 	TInt count = iSettingList->Count();
       
  1141 
       
  1142 	for (TInt i=0; i<count; i++ )
       
  1143 		{
       
  1144 		CAspListItemData* item = (*iSettingList)[i];
       
  1145 		if (item->iHidden != EVisibilityHidden)
       
  1146 			{
       
  1147 			item->iHidden = EVisibilityReadOnly;
       
  1148 			}
       
  1149 		}
       
  1150 	}
       
  1151 
       
  1152 
       
  1153 // -----------------------------------------------------------------------------
       
  1154 // CAspProfileDialog::InitSettingItemL
       
  1155 // 
       
  1156 // Constructs CAspListItemData for one connection setting.
       
  1157 // -----------------------------------------------------------------------------
       
  1158 //
       
  1159 void CAspProfileDialog::InitSettingItemL(CAspListItemData* aItem)
       
  1160 	{
       
  1161 	__ASSERT_ALWAYS(aItem, TUtil::Panic(KErrGeneral));	
       
  1162 	
       
  1163 	iBuf = KNullDesC;  // reset common buffer
       
  1164 	
       
  1165 	switch (aItem->iItemId)
       
  1166 		{
       
  1167 		case EAspProfileName:
       
  1168 			{
       
  1169 			iProfile->GetName(iBuf);
       
  1170 			aItem->SetValueL(iBuf);
       
  1171 			aItem->SetDisplayValueL(R_ASP_MUST_BE_DEFINED);
       
  1172 			
       
  1173 			aItem->iMaxLength = KAspMaxProfileNameLength;
       
  1174 			aItem->iLatinInput = EFalse;
       
  1175 			aItem->iItemType = CAspListItemData::ETypeText;
       
  1176 			aItem->iMandatory = ETrue;
       
  1177 			break;
       
  1178 			}
       
  1179 
       
  1180 		case EAspProtocolVersion:
       
  1181 			{
       
  1182 			CDesCArray* arr = iResHandler->ReadDesArrayLC(R_ASP_PROTOCOL_VERSION);
       
  1183     
       
  1184     		aItem->iNumberData = iProfile->ProtocolVersion();
       
  1185 			aItem->SetValueL((*arr)[aItem->iNumberData]);
       
  1186 				
       
  1187 			aItem->iResource = R_ASP_PROTOCOL_VERSION;
       
  1188 			aItem->iItemType = CAspListItemData::ETypeProtocolList;
       
  1189 			
       
  1190 			CleanupStack::PopAndDestroy(arr);
       
  1191 			break;
       
  1192 			}
       
  1193 
       
  1194 		case EAspServerId:
       
  1195 			{
       
  1196 			iProfile->GetServerId(iBuf);
       
  1197 			aItem->SetValueL(iBuf);
       
  1198 			if(TDialogUtil::IsPCSuiteDesC(iBuf))
       
  1199 			{
       
  1200 				aItem->SetDisplayValueL(R_ASP_PC_SUITE_PROFILE);	
       
  1201 			}
       
  1202 			else
       
  1203 			{
       
  1204 			aItem->SetDisplayValueL(R_ASP_SETTING_VALUE_NONE);
       
  1205 			}
       
  1206 
       
  1207 			aItem->iMaxLength = KAspMaxServerIdLength;
       
  1208 			aItem->iLatinInput = ETrue;
       
  1209 			aItem->iItemType = CAspListItemData::ETypeText;
       
  1210 			
       
  1211 			TUtil::StrCopy(iOldServerId, iBuf);
       
  1212 			break;
       
  1213 			}
       
  1214 		
       
  1215 		
       
  1216 		case EAspConnType:
       
  1217 			{
       
  1218 			aItem->iNumberData = iProfile->BearerType();
       
  1219 
       
  1220 			if (!iBearerHandler->IsSupported(aItem->iNumberData))
       
  1221 				{
       
  1222 				aItem->iNumberData = iBearerHandler->DefaultBearer();
       
  1223 				}
       
  1224 
       
  1225  			iBearerHandler->GetBearerName(iBuf, aItem->iNumberData);
       
  1226 			aItem->SetValueL(iBuf);
       
  1227 			aItem->iItemType = CAspListItemData::ETypeBearerList;
       
  1228 
       
  1229 			break;
       
  1230 			}
       
  1231 		
       
  1232 		case EAspAccessPoint:
       
  1233 			{
       
  1234 			TAspAccessPointItem item;
       
  1235 	        item.iUid = iProfile->AccessPointL();
       
  1236 	        TInt ret = iApHandler->GetInternetApInfo(item);
       
  1237 	        if (ret == KErrNone)
       
  1238 	        	{
       
  1239 	        	aItem->iNumberData = item.iUid;
       
  1240 	        	aItem->SetValueL(item.iName);
       
  1241 	        	aItem->iResource = R_ASP_NETWORK_CONNECTION;
       
  1242 	        	}
       
  1243 	        else
       
  1244 	        	{
       
  1245 	        	aItem->iNumberData = CAspAccessPointHandler::KDefaultConnection;	
       
  1246 	        	aItem->SetDisplayValueL(R_ASP_DEFAULT_CONNECTION);
       
  1247 	        	aItem->iResource = R_ASP_NETWORK_CONNECTION;
       
  1248 	        	}
       
  1249 	        aItem->iItemType = CAspListItemData::ETypeInternetAccessPoint;
       
  1250 			break;
       
  1251 			}
       
  1252 		
       
  1253 		case EAspHostAddress:
       
  1254 			{
       
  1255 			iProfile->GetHostAddress(iBuf, aItem->iNumberData);
       
  1256 			aItem->SetValueL(iBuf);
       
  1257 			if(TDialogUtil::IsPCSuiteDesC(iBuf))
       
  1258 			{
       
  1259 				aItem->SetDisplayValueL(R_ASP_PC_SUITE_PROFILE);	
       
  1260 	 		}
       
  1261 	        else
       
  1262 	        {
       
  1263 	        	aItem->SetDisplayValueL(R_ASP_MUST_BE_DEFINED);
       
  1264 	        }
       
  1265 			
       
  1266 			aItem->iMaxLength = KAspMaxURILength;
       
  1267 			aItem->iLatinInput = ETrue;
       
  1268 			aItem->iItemType = CAspListItemData::ETypeHostAddress;
       
  1269 			aItem->iMandatory = ETrue;
       
  1270 			
       
  1271 			break;
       
  1272 			}
       
  1273 		    
       
  1274 		case EAspPort:
       
  1275 			{
       
  1276 			iProfile->GetHostAddress(iBuf, aItem->iNumberData);
       
  1277 			if ( aItem->iNumberData > TURIParser::EMaxURIPortNumber || aItem->iNumberData < TURIParser::EMinURIPortNumber)
       
  1278   					 	aItem->iNumberData = TURIParser::EDefaultHttpPort;	
       
  1279 			aItem->SetValueL(aItem->iNumberData);
       
  1280 			
       
  1281 			aItem->iMaxLength = KBufSize16;
       
  1282 			aItem->iMaxValue = TURIParser::EMaxURIPortNumber;
       
  1283 			aItem->iMinValue = TURIParser::EMinURIPortNumber;
       
  1284 			aItem->iItemType = CAspListItemData::ETypeNumber;
       
  1285 			aItem->iLatinInput = ETrue;
       
  1286 			break;
       
  1287 			}
       
  1288 		    
       
  1289 		case EAspUsername:
       
  1290 			{
       
  1291 			iProfile->GetUserName(iBuf);
       
  1292 			aItem->SetValueL(iBuf);
       
  1293 			aItem->SetDisplayValueL(R_ASP_SETTING_VALUE_NONE);
       
  1294 
       
  1295 			aItem->iMaxLength = KAspMaxUsernameLength;
       
  1296 			aItem->iLatinInput = ETrue;
       
  1297 			aItem->iItemType = CAspListItemData::ETypeText;
       
  1298 			break;
       
  1299 			}
       
  1300 		    
       
  1301 		case EAspPassword:
       
  1302 			{
       
  1303 			iProfile->GetPassword(iBuf);
       
  1304 			aItem->SetValueL(iBuf);
       
  1305 			TUtil::Fill(iBuf, KSecretEditorMask, KSecretEditorMaskLength);
       
  1306 			aItem->SetDisplayValueL(iBuf);
       
  1307 
       
  1308 			aItem->iMaxLength = KAspMaxPasswordLength;
       
  1309 			aItem->iItemType = CAspListItemData::ETypeSecret;
       
  1310 			break;
       
  1311 			}
       
  1312 		
       
  1313 		case EAspHttpsUsername:
       
  1314 			{
       
  1315 			iProfile->GetHttpUserNameL(iBuf);
       
  1316 			aItem->SetValueL(iBuf);
       
  1317 			aItem->SetDisplayValueL(R_ASP_SETTING_VALUE_NONE);
       
  1318 
       
  1319 			aItem->iMaxLength = KAspMaxUsernameLength;
       
  1320 			aItem->iLatinInput = ETrue;
       
  1321 			aItem->iItemType = CAspListItemData::ETypeText;
       
  1322 			break;
       
  1323 			}
       
  1324 
       
  1325 		case EAspHttpsPassword:
       
  1326 			{
       
  1327 			iProfile->GetHttpPasswordL(iBuf);
       
  1328 			aItem->SetValueL(iBuf);
       
  1329 			TUtil::Fill(iBuf, KSecretEditorMask, KSecretEditorMaskLength);
       
  1330 			aItem->SetDisplayValueL(iBuf);
       
  1331 
       
  1332 			aItem->iMaxLength = KAspMaxPasswordLength;
       
  1333 			aItem->iItemType = CAspListItemData::ETypeSecret;
       
  1334 			break;
       
  1335 			}
       
  1336 		
       
  1337 		case EAspServerAlert:
       
  1338 			{
       
  1339 			CDesCArray* arr = iResHandler->ReadDesArrayLC(R_ASP_SERVER_ALERT_TYPE);
       
  1340 
       
  1341             aItem->iNumberData = iProfile->SASyncState();
       
  1342 			aItem->iResource = R_ASP_SERVER_ALERT_TYPE;
       
  1343 			aItem->SetValueL((*arr)[aItem->iNumberData]);
       
  1344 			aItem->iItemType = CAspListItemData::ETypeList;
       
  1345 			
       
  1346 			CleanupStack::PopAndDestroy(arr);
       
  1347 			break;
       
  1348 			}
       
  1349 			
       
  1350 		case EAspSyncDirection:
       
  1351 			{
       
  1352     		CDesCArray* arr;
       
  1353     		TBool isPCSuite = CAspProfile::IsPCSuiteProfile(iProfile);
       
  1354     		if(isPCSuite)
       
  1355 			 {
       
  1356 			 	
       
  1357 			    arr = iResHandler->ReadDesArrayLC(R_ASP_SYNC_PCSUITE_TYPE);
       
  1358     			aItem->iResource = R_ASP_SYNC_PCSUITE_TYPE;
       
  1359     			   		
       
  1360 			 }
       
  1361 			 else
       
  1362 			 {
       
  1363 			 	arr = iResHandler->ReadDesArrayLC(R_ASP_SYNC_TYPE);
       
  1364     			aItem->iResource =R_ASP_SYNC_TYPE ;
       
  1365     			   		
       
  1366 			 }
       
  1367     	
       
  1368     		aItem->iNumberData = iContentList->SyncDirection();
       
  1369 			aItem->SetValueL((*arr)[aItem->iNumberData]);
       
  1370 			aItem->iItemType = CAspListItemData::ETypeList;
       
  1371     		
       
  1372     		CleanupStack::PopAndDestroy(arr);
       
  1373 			break;
       
  1374 			}
       
  1375 			
       
  1376         
       
  1377         case EAspSyncContent:
       
  1378         	{
       
  1379         	break;
       
  1380         	}
       
  1381         	
       
  1382         default:
       
  1383            	__ASSERT_DEBUG(EFalse, TUtil::Panic(KErrGeneral));
       
  1384 			break;
       
  1385 		
       
  1386 		}
       
  1387 	}
       
  1388 
       
  1389 
       
  1390 // ----------------------------------------------------------------------------
       
  1391 // CAspProfileDialog::SaveSettingsL
       
  1392 // 
       
  1393 // ----------------------------------------------------------------------------
       
  1394 //
       
  1395 void CAspProfileDialog::SaveSettingsL()
       
  1396 	{
       
  1397     if (iEditMode == EDialogModeReadOnly || 
       
  1398         iEditMode == EDialogModeSettingEnforcement)
       
  1399     	{
       
  1400     	return;
       
  1401     	}
       
  1402 
       
  1403    	iBuf = KNullDesC;  // reset common buffer
       
  1404    	
       
  1405 	TInt count = iSettingList->Count();
       
  1406 	
       
  1407 	for (TInt i=0; i<count; i++)
       
  1408 		{
       
  1409 		CAspListItemData* item = (*iSettingList)[i];
       
  1410 		
       
  1411 		switch (item->iItemId)
       
  1412 			{
       
  1413 			case EAspProfileName:
       
  1414 			    iProfile->SetNameL(item->Value());
       
  1415 			    break;
       
  1416 
       
  1417 			case EAspProtocolVersion:
       
  1418 				iProfile->SetProtocolVersionL(item->iNumberData);
       
  1419 			    break;
       
  1420 
       
  1421 			case EAspServerId:
       
  1422 			    iProfile->SetServerIdL(item->Value());
       
  1423 			    break;
       
  1424 
       
  1425 			case EAspConnType:
       
  1426 				iProfile->SetBearerTypeL(item->iNumberData);
       
  1427 			    break;
       
  1428 
       
  1429 			case EAspAccessPoint:
       
  1430 				iProfile->SetAccessPointL(item->iNumberData);
       
  1431 			    break;
       
  1432 
       
  1433 			case EAspHostAddress:
       
  1434 				{
       
  1435 				iBuf = item->Value();
       
  1436 				TURIParser parser(iBuf);
       
  1437 				TInt portNumber = parser.Port();
       
  1438 	            if (!parser.IsValidPort(portNumber))
       
  1439 		            {
       
  1440 		            	if ( Item(EAspPort)->iNumberData > TURIParser::EMaxURIPortNumber || Item(EAspPort)->iNumberData < TURIParser::EMinURIPortNumber)
       
  1441   							    Item(EAspPort)->iNumberData = TURIParser::EDefaultHttpPort;	
       
  1442 				 		portNumber = Item(EAspPort)->iNumberData;    	
       
  1443 		            }
       
  1444 
       
  1445 				iProfile->SetHostAddressL(iBuf, portNumber);
       
  1446 				break;
       
  1447 				}
       
  1448 
       
  1449 			case EAspPort:
       
  1450 				break;  // port is included in host address
       
  1451 
       
  1452 			case EAspUsername:
       
  1453 				iProfile->SetUserNameL(item->Value());
       
  1454 			    break;
       
  1455 			
       
  1456 			case EAspPassword:
       
  1457 			    iProfile->SetPasswordL(item->Value());
       
  1458 			    break;
       
  1459 
       
  1460 			case EAspServerAlert:
       
  1461 				{
       
  1462 				iProfile->SetSASyncStateL(item->iNumberData);
       
  1463 			    break;
       
  1464 				}
       
  1465 
       
  1466 			case EAspHttpsUsername:
       
  1467 			    iProfile->SetHttpUserNameL(item->Value());
       
  1468 			    break;
       
  1469 
       
  1470 			case EAspHttpsPassword:
       
  1471 			    iProfile->SetHttpPasswordL(item->Value());
       
  1472 			    break;
       
  1473 			    
       
  1474 			case EAspSyncDirection:
       
  1475 				iContentList->ModifyTaskDirectionsL(item->iNumberData);
       
  1476 				break;
       
  1477 			    
       
  1478 			}
       
  1479 
       
  1480 		}
       
  1481 
       
  1482 	iProfile->Save();
       
  1483 	iContentList->UpdateLocalDatabaseL();
       
  1484 #ifdef RD_DSUI_TIMEDSYNC
       
  1485 	CheckAutoSyncSetttigsL();
       
  1486 #endif
       
  1487 	}
       
  1488 	
       
  1489 	
       
  1490 //------------------------------------------------------------------------------
       
  1491 // CAspProfileDialog::EditSettingItemL
       
  1492 //
       
  1493 // Calls setting editing functions. 
       
  1494 //------------------------------------------------------------------------------
       
  1495 //
       
  1496 TBool CAspProfileDialog::EditSettingItemL(CAspListItemData& aItem)
       
  1497 	{
       
  1498 	TInt ret = EFalse;
       
  1499 
       
  1500 #ifdef RD_DSUI_TIMEDSYNC 
       
  1501 	CAspSchedule* schedule = CAspSchedule::NewLC();
       
  1502 	if (schedule->IsAutoSyncEnabled())
       
  1503 		{
       
  1504 		TInt profileId = schedule->ProfileId();
       
  1505 		if (profileId == iProfile->ProfileId())
       
  1506 			{
       
  1507 			TDialogUtil::ShowInformationQueryL(R_ASP_NOTE_MODIFY_AUTO_SYNC_SETTINGS);
       
  1508 			}
       
  1509 		}
       
  1510     CleanupStack::PopAndDestroy(schedule);
       
  1511 #endif
       
  1512 
       
  1513 	switch (aItem.iItemType)
       
  1514 		{
       
  1515 		case CAspListItemData::ETypeInternetAccessPoint:
       
  1516 		    ret = EditSettingItemAccessPointL(aItem);
       
  1517 		    break;
       
  1518 			
       
  1519 		case CAspListItemData::ETypeText:
       
  1520 			ret = EditSettingItemTextL(aItem);
       
  1521 		    break;
       
  1522 
       
  1523 		case CAspListItemData::ETypeSecret:
       
  1524 			ret = EditSettingItemSecretL(aItem);
       
  1525 		    break;
       
  1526 
       
  1527 		case CAspListItemData::ETypeNumber:
       
  1528 			ret = EditSettingItemNumberL(aItem);
       
  1529 		    break;
       
  1530 
       
  1531 		case CAspListItemData::ETypeList:
       
  1532 			ret = EditSettingItemListL(aItem);
       
  1533 		    break;
       
  1534 		
       
  1535 		case CAspListItemData::ETypeBearerList:
       
  1536 			ret = EditSettingItemBearerListL(aItem);
       
  1537 		    break;
       
  1538 		    
       
  1539 		case CAspListItemData::ETypeProtocolList:
       
  1540 			ret = EditSettingItemProtocolListL(aItem);
       
  1541 		    break;
       
  1542 
       
  1543 		case CAspListItemData::ETypeListYesNo:
       
  1544 			ret = EditSettingItemYesNoL(aItem);
       
  1545 		    break;
       
  1546 
       
  1547 		case CAspListItemData::ETypeHostAddress:
       
  1548 			ret = EditSettingItemHostAddressL(aItem);
       
  1549 			break;
       
  1550 
       
  1551 		case CAspListItemData::ETypeSyncContent:
       
  1552 			ret = EditSettingItemSyncContentL(aItem);
       
  1553 			break;
       
  1554 
       
  1555 		default:
       
  1556 		    break;
       
  1557 		}
       
  1558 	
       
  1559 	return ret;
       
  1560 	}
       
  1561 
       
  1562 
       
  1563 //------------------------------------------------------------------------------
       
  1564 // CAspProfileDialog::EditSettingItemYesNoL
       
  1565 //
       
  1566 // Change Yes/No value without showing radio button editor.
       
  1567 //------------------------------------------------------------------------------
       
  1568 //
       
  1569 TBool CAspProfileDialog::EditSettingItemYesNoL(CAspListItemData& aItem)
       
  1570 	{
       
  1571 	CDesCArray* arr = iResHandler->ReadDesArrayLC(aItem.iResource);
       
  1572 	
       
  1573 	if (aItem.iNumberData == EAspSettingDisabled)
       
  1574 		{
       
  1575 		aItem.iNumberData = EAspSettingEnabled;
       
  1576 		}
       
  1577 	else
       
  1578 		{
       
  1579 		aItem.iNumberData = EAspSettingDisabled;
       
  1580 		}
       
  1581 	
       
  1582 	
       
  1583 	// store localized setting text (Yes/No)
       
  1584 	aItem.SetValueL( (*arr)[aItem.iNumberData] );
       
  1585 
       
  1586 	CleanupStack::PopAndDestroy(arr);
       
  1587 	return ETrue;
       
  1588 	}
       
  1589 
       
  1590 
       
  1591 //------------------------------------------------------------------------------
       
  1592 // CAspProfileDialog::EditSettingItemNumberL
       
  1593 //
       
  1594 //------------------------------------------------------------------------------
       
  1595 //
       
  1596 TBool CAspProfileDialog::EditSettingItemNumberL(CAspListItemData& aItem)
       
  1597 	{
       
  1598 	TBool ret = TDialogUtil::ShowIntegerEditorL(aItem.iNumberData, aItem.Header(), 
       
  1599 	                         aItem.iMinValue, aItem.iMaxValue, aItem.iLatinInput);
       
  1600 
       
  1601 	if (ret)
       
  1602 		{
       
  1603 		aItem.SetValueL(aItem.iNumberData);
       
  1604 		}
       
  1605 
       
  1606 	return ret;
       
  1607 	}
       
  1608 
       
  1609 
       
  1610 //------------------------------------------------------------------------------
       
  1611 // CAspProfileDialog::EditSettingItemSecretL
       
  1612 //
       
  1613 //------------------------------------------------------------------------------
       
  1614 //
       
  1615 TBool CAspProfileDialog::EditSettingItemSecretL(CAspListItemData& aItem)
       
  1616 	{
       
  1617 	TBuf<KBufSize64> newPassword;
       
  1618 	newPassword = aItem.Value();
       
  1619 	
       
  1620 	
       
  1621 	CAspAlphaPasswordSettingPageEditor* pwd = new (ELeave) CAspAlphaPasswordSettingPageEditor(
       
  1622 		                                R_ASP_SETTING_PASSWORD, newPassword, aItem.Value());
       
  1623 	
       
  1624 	CleanupStack::PushL(pwd);
       
  1625 	pwd->SetSettingTextL(aItem.Header()); 
       
  1626 	pwd->ConstructL();
       
  1627 	pwd->AlphaPasswordEditor()->SetMaxLength(aItem.iMaxLength);
       
  1628 	//pwd->AlphaPasswordEditor()->RevealSecretText(ETrue);  // pasi
       
  1629 	CleanupStack::Pop(pwd);
       
  1630 
       
  1631 	if (pwd->ExecuteLD(CAknSettingPage::EUpdateWhenChanged))
       
  1632 		{
       
  1633 		aItem.SetValueL(newPassword);
       
  1634 		return ETrue;
       
  1635 		}
       
  1636 	
       
  1637 	return EFalse;
       
  1638 	}
       
  1639 
       
  1640 
       
  1641 //------------------------------------------------------------------------------
       
  1642 // CAspProfileDialog::EditSettingItemTextL
       
  1643 //
       
  1644 // Edit text setting item.
       
  1645 //------------------------------------------------------------------------------
       
  1646 //
       
  1647 TBool CAspProfileDialog::EditSettingItemTextL(CAspListItemData& aItem)
       
  1648 	{
       
  1649 	TUtil::StrCopy(iBuf, aItem.Value());
       
  1650 	
       
  1651 	TInt len = iBuf.Length();
       
  1652 	if (len > aItem.iMaxLength)
       
  1653 		{
       
  1654 		iBuf.SetLength(aItem.iMaxLength);
       
  1655 		}
       
  1656 	
       
  1657     TBool ret = TDialogUtil::ShowTextEditorL(iBuf, aItem.Header(), 
       
  1658                              aItem.iMandatory, aItem.iLatinInput, aItem.iMaxLength);
       
  1659    	if (ret)
       
  1660 		{
       
  1661 		aItem.SetValueL(iBuf);
       
  1662 		}
       
  1663 		
       
  1664 	return ret;
       
  1665 	}
       
  1666 
       
  1667 
       
  1668 //------------------------------------------------------------------------------
       
  1669 // CAspProfileDialog::EditSettingItemHostAddressL
       
  1670 //
       
  1671 //------------------------------------------------------------------------------
       
  1672 //
       
  1673 TBool CAspProfileDialog::EditSettingItemHostAddressL(CAspListItemData& aItem)
       
  1674 	{
       
  1675 	_LIT(KHttpHeader, "http://");
       
  1676 	
       
  1677 	TBool httpHeaderUsed = EFalse;
       
  1678 	TInt bearer = Item(EAspConnType)->iNumberData;
       
  1679 	HBufC* hBuf = HBufC::NewLC(KBufSize255);
       
  1680 	TPtr ptr = hBuf->Des();
       
  1681 	TUtil::StrCopy(ptr, aItem.Value());
       
  1682 	if (TUtil::IsEmpty(aItem.Value()) && bearer == EAspBearerInternet)
       
  1683 		{
       
  1684 		aItem.SetValueL(KHttpHeader);
       
  1685 		httpHeaderUsed = ETrue;
       
  1686 		}
       
  1687 		
       
  1688 	TBool ret = EFalse;
       
  1689 	for(;;)
       
  1690 	{
       
  1691 	ret = EditSettingItemTextL(aItem);
       
  1692 	
       
  1693 	if (httpHeaderUsed && (aItem.Value().Compare(KHttpHeader) == 0))
       
  1694 		{
       
  1695 		aItem.SetValueL(KNullDesC);
       
  1696 		}
       
  1697 	
       
  1698 	
       
  1699 	if (ret)
       
  1700 		{
       
  1701 		if(bearer == EAspBearerInternet)
       
  1702 		{
       
  1703 			if (!TURIParser::IsValidUri(aItem.Value()))
       
  1704 			{			
       
  1705 			TDialogUtil::ShowInformationNoteL(R_ASP_LOG_ERR_URIINVALID);
       
  1706 			}
       
  1707 		else
       
  1708 			{
       
  1709 			TPtrC ptr = aItem.Value();
       
  1710 			TURIParser parser(ptr);
       
  1711 	        TInt portNumber = parser.Port();
       
  1712 	        if (parser.IsValidPort(portNumber))
       
  1713 		        {
       
  1714 		        Item(EAspPort)->iNumberData = portNumber;
       
  1715 		        Item(EAspPort)->SetValueL(portNumber);
       
  1716 		        }
       
  1717 		    break;    
       
  1718 			}	
       
  1719 		}
       
  1720 		else if(bearer == EAspBearerBlueTooth)
       
  1721 		{
       
  1722 			if (!TURIParser::IsValidBluetoothHostAddress(aItem.Value()))
       
  1723 		    {
       
  1724 		    TDialogUtil::ShowInformationNoteL(R_ASP_NOTE_INCORRECT_HOST_ADDRESS);
       
  1725 		   
       
  1726 		    }
       
  1727 		    else
       
  1728 		    {
       
  1729 		    	break;
       
  1730 		    }
       
  1731 			}
       
  1732 		}
       
  1733 	else if(!ret) 
       
  1734 		{
       
  1735 		aItem.SetValueL(ptr);
       
  1736 		break;	
       
  1737 		}
       
  1738 	else
       
  1739 		{
       
  1740 		 break;	
       
  1741 		}
       
  1742 	}
       
  1743 	CleanupStack::PopAndDestroy(); //hBuf
       
  1744 	return ret;
       
  1745 	}
       
  1746 
       
  1747 
       
  1748 //------------------------------------------------------------------------------
       
  1749 // CAspProfileDialog::EditSettingItemListL
       
  1750 //
       
  1751 //------------------------------------------------------------------------------
       
  1752 //
       
  1753 TBool CAspProfileDialog::EditSettingItemListL(CAspListItemData& aItem)
       
  1754 	{
       
  1755 	TInt curSelection = aItem.iNumberData;
       
  1756 	CDesCArray* arr = CAspResHandler::ReadDesArrayStaticLC(aItem.iResource);
       
  1757 	
       
  1758 	TBool ret = TDialogUtil::ShowListEditorL(arr, aItem.Header(), curSelection);
       
  1759 	if (ret)
       
  1760 		{
       
  1761 		aItem.iNumberData = curSelection; 
       
  1762 		aItem.SetValueL((*arr)[curSelection]);
       
  1763 		}
       
  1764 
       
  1765 	CleanupStack::PopAndDestroy(arr);
       
  1766 	return ret;
       
  1767 	}
       
  1768 
       
  1769 
       
  1770 //------------------------------------------------------------------------------
       
  1771 // CAspProfileDialog::EditSettingItemProtocolListL
       
  1772 //
       
  1773 //------------------------------------------------------------------------------
       
  1774 //
       
  1775 TBool CAspProfileDialog::EditSettingItemProtocolListL(CAspListItemData& aItem)
       
  1776 	{
       
  1777 #ifdef __SYNCML_DS_EMAIL   // KFeatureIdSyncMlDsEmail
       
  1778 	TInt oldSelection = aItem.iNumberData;
       
  1779 #endif
       
  1780 	
       
  1781 	TInt curSelection = aItem.iNumberData;
       
  1782 	CDesCArray* arr2 = iResHandler->ReadDesArrayLC(aItem.iResource);
       
  1783 	CDesCArray* arr = TUtil::NumberConversionLC(arr2);
       
  1784 	
       
  1785 	
       
  1786 	if (TDialogUtil::ShowListEditorL(arr, aItem.Header(), curSelection))
       
  1787 		{
       
  1788 		aItem.iNumberData = curSelection; 
       
  1789 		aItem.SetValueL((*arr)[curSelection]);
       
  1790 		
       
  1791 	    
       
  1792 #ifdef __SYNCML_DS_EMAIL   // KFeatureIdSyncMlDsEmail
       
  1793 
       
  1794 	    TBool emailSync = EFalse;
       
  1795 	    TInt id = iProfile->ApplicationId();
       
  1796 	    if (id == EApplicationIdSync || id == EApplicationIdEmail)
       
  1797 	    	{
       
  1798 	    	emailSync = ETrue;
       
  1799 	    	}
       
  1800 		
       
  1801 
       
  1802 #ifdef RD_DSUI_TIMEDSYNC
       
  1803 		if (curSelection == EAspProtocol_1_1 )
       
  1804 				{
       
  1805 				CAspSchedule* schedule = CAspSchedule::NewLC();
       
  1806 				TInt profileId = schedule->ProfileId();
       
  1807 				if (profileId == iProfile->ProfileId())
       
  1808 					{
       
  1809 					TInt selectedContentCnt = 0;
       
  1810 					TInt selectedContentIndex = 0;
       
  1811 					TInt emailIndex = iContentList->FindProviderIndex(KUidNSmlAdapterEMail.iUid);
       
  1812 					schedule->ContentSelectionInfo(selectedContentCnt, selectedContentIndex);
       
  1813 					if (selectedContentCnt == 1 && selectedContentIndex == emailIndex)
       
  1814 						{
       
  1815 						schedule->SetProfileId(KErrNotFound);
       
  1816 						schedule->SetContentEnabled(emailIndex, EFalse);
       
  1817 						schedule->SetSyncPeakSchedule(CAspSchedule::EIntervalManual);
       
  1818 						schedule->SetSyncOffPeakSchedule(CAspSchedule::EIntervalManual);
       
  1819 						schedule->SetSyncFrequency(CAspSchedule::EIntervalManual);
       
  1820 						schedule->UpdateSyncScheduleL();
       
  1821 						schedule->SaveL();
       
  1822 						}
       
  1823 					}
       
  1824 				CleanupStack::PopAndDestroy(schedule);
       
  1825 				}
       
  1826 #endif
       
  1827 		
       
  1828 #endif
       
  1829 		
       
  1830 		CleanupStack::PopAndDestroy(arr);
       
  1831 		CleanupStack::PopAndDestroy(arr2);
       
  1832 		return ETrue;
       
  1833 		}
       
  1834 
       
  1835 	CleanupStack::PopAndDestroy(arr);
       
  1836 	CleanupStack::PopAndDestroy(arr2);
       
  1837 	return EFalse;
       
  1838 	}
       
  1839 //------------------------------------------------------------------------------
       
  1840 // CAspProfileDialog::EditSettingItemAccessPointL
       
  1841 //
       
  1842 //------------------------------------------------------------------------------
       
  1843 //	
       
  1844 TBool CAspProfileDialog::EditSettingItemAccessPointL(CAspListItemData& aItem)
       
  1845 {
       
  1846 
       
  1847 	TBool ret;
       
  1848 	TInt selection = 0;
       
  1849 	TInt curSelection = aItem.iNumberData;
       
  1850 	CDesCArray* arr = CAspResHandler::ReadDesArrayStaticLC(aItem.iResource);
       
  1851 	if(curSelection < 0)
       
  1852 	{
       
  1853 		curSelection = 0;
       
  1854 	}
       
  1855 	else
       
  1856 	{
       
  1857 		curSelection = 1;
       
  1858 	}
       
  1859 	ret = TDialogUtil::ShowListEditorL(arr, aItem.Header(), curSelection);
       
  1860 	CleanupStack::PopAndDestroy(arr);
       
  1861 	if(!ret)
       
  1862 	{
       
  1863 		return EFalse;
       
  1864 	}
       
  1865 	if (curSelection == 0 )
       
  1866 		{
       
  1867 		aItem.iNumberData = CAspAccessPointHandler::KDefaultConnection;
       
  1868 		aItem.SetValueL(KNullDesC);
       
  1869 		aItem.SetDisplayValueL(R_ASP_DEFAULT_CONNECTION);
       
  1870 		selection = CAspAccessPointHandler::KDefaultConnection;
       
  1871 		}	
       
  1872 	if(selection == CAspAccessPointHandler::KDefaultConnection)
       
  1873 	{
       
  1874 	#ifdef RD_DSUI_TIMEDSYNC
       
  1875    	CAspSchedule* schedule = CAspSchedule::NewLC();
       
  1876 	TInt profileId = schedule->ProfileId();
       
  1877 	TInt enabled = schedule->IsAutoSyncEnabled();
       
  1878 	CleanupStack::PopAndDestroy(schedule);
       
  1879 	if(profileId == iProfile->ProfileId() && enabled)
       
  1880 		{
       
  1881 		TBool showQuery = ETrue;
       
  1882 			RCmManager cmmgr;
       
  1883 			cmmgr.OpenL();
       
  1884 			TCmDefConnValue defConnValue;
       
  1885 			cmmgr.ReadDefConnL(defConnValue);
       
  1886 			cmmgr.Close();
       
  1887 			if(defConnValue.iType == ECmDefConnDestination)
       
  1888 			{
       
  1889 				showQuery = EFalse;
       
  1890 			}
       
  1891 		if(showQuery)
       
  1892 		{
       
  1893 			HBufC* hBuf = CAspResHandler::ReadLC(R_ASP_QUERY_IAP_NO_ASK_ALWAYS);
       
  1894     		if (!TDialogUtil::ShowConfirmationQueryL(hBuf->Des()))
       
  1895 	 		{
       
  1896 	  	  		CleanupStack::PopAndDestroy(hBuf);
       
  1897 				return ETrue;// user selected "Always ask" option 
       
  1898     	}	
       
  1899 			CleanupStack::PopAndDestroy(hBuf);
       
  1900 		}
       
  1901 		else
       
  1902 		{
       
  1903 			return ETrue;
       
  1904 		}
       
  1905 			
       
  1906 		}
       
  1907 		else
       
  1908 		{
       
  1909 			return ETrue;
       
  1910 		}
       
  1911     	   	
       
  1912 	#else
       
  1913 		return ETrue;
       
  1914 	#endif
       
  1915 	}
       
  1916 	TAspAccessPointItem item;
       
  1917 	item.iUid2 = aItem.iNumberData;
       
  1918 	
       
  1919 	ret = iApHandler->ShowApSelectDialogL(item);
       
  1920 	
       
  1921 	if (ret == CAspAccessPointHandler::EAspDialogSelect)
       
  1922 		{
       
  1923 		aItem.iNumberData = item.iUid;
       
  1924 		aItem.SetValueL(item.iName);
       
  1925 		return ETrue;
       
  1926 		}
       
  1927 	else if (ret == CAspAccessPointHandler::EAspDialogExit)
       
  1928 		{
       
  1929 		ProcessCommandL(EAknCmdExit); // user has selected "Exit" from options menu
       
  1930 		}
       
  1931 	else
       
  1932 		{
       
  1933 		// user canceled ap selection
       
  1934 		return EFalse;
       
  1935 		}
       
  1936 		
       
  1937 	return EFalse;
       
  1938 }
       
  1939 
       
  1940 //------------------------------------------------------------------------------
       
  1941 // CAspProfileDialog::EditSettingItemBearerListL
       
  1942 //
       
  1943 //------------------------------------------------------------------------------
       
  1944 //
       
  1945 TBool CAspProfileDialog::EditSettingItemBearerListL(CAspListItemData& aItem)
       
  1946 	{
       
  1947 	CDesCArray* arr = iBearerHandler->BuildBearerListLC();
       
  1948 	if (arr->Count() == 0) 
       
  1949 		{
       
  1950 		User::Leave(KErrNotFound);
       
  1951 		}
       
  1952 
       
  1953 	TInt curSelection = iBearerHandler->ListIndexForBearer(aItem.iNumberData);
       
  1954 	if (curSelection == KErrNotFound)
       
  1955 		{
       
  1956 		User::Leave(KErrNotFound);
       
  1957 		}
       
  1958 
       
  1959 	if (TDialogUtil::ShowListEditorL(arr, aItem.Header(), curSelection))
       
  1960 		{
       
  1961 		aItem.iNumberData = iBearerHandler->BearerForListIndex(curSelection);
       
  1962        	aItem.SetValueL((*arr)[curSelection]);
       
  1963 		CleanupStack::PopAndDestroy(arr);
       
  1964 		return ETrue;
       
  1965 		}
       
  1966 	
       
  1967 	CleanupStack::PopAndDestroy(arr);
       
  1968 	return EFalse;
       
  1969 	}
       
  1970 
       
  1971 
       
  1972 
       
  1973 // -----------------------------------------------------------------------------
       
  1974 // CAspContentListDialog::EditSettingItemSyncContentL
       
  1975 //
       
  1976 // -----------------------------------------------------------------------------
       
  1977 //
       
  1978 TInt CAspProfileDialog::EditSettingItemSyncContentL(CAspListItemData& aItem)
       
  1979 	{
       
  1980  	TAspParam param(iApplicationId, iSyncSession);
       
  1981     param.iProfile = iProfile;
       
  1982     param.iDataProviderId = aItem.iNumberData;
       
  1983     param.iSyncTaskId = KErrNotFound;
       
  1984     param.iContentList = iContentList;
       
  1985 
       
  1986     CAspContentDialog::ShowDialogL(param);
       
  1987      
       
  1988     return ETrue;
       
  1989 	}
       
  1990 
       
  1991 
       
  1992 //-----------------------------------------------------------------------------
       
  1993 // CAspProfileDialog::GetItemForIndex
       
  1994 // 
       
  1995 // Find item in list position aIndex.
       
  1996 //-----------------------------------------------------------------------------
       
  1997 //
       
  1998 CAspListItemData* CAspProfileDialog::GetItemForIndex(TInt aIndex)
       
  1999 	{
       
  2000 	CAspListItemData* item = NULL;
       
  2001 	
       
  2002 	TInt count = iSettingList->Count();
       
  2003 	for (TInt i=0; i<count; i++)
       
  2004 		{
       
  2005 		CAspListItemData* temp = (*iSettingList)[i];
       
  2006 		if (temp->iIndex == aIndex)
       
  2007 			{
       
  2008 			item = temp;
       
  2009 			break;
       
  2010 			}
       
  2011 		}
       
  2012 
       
  2013 	__ASSERT_ALWAYS(item, TUtil::Panic(KErrGeneral));
       
  2014 
       
  2015     return item;
       
  2016 	}
       
  2017 
       
  2018 
       
  2019 //-----------------------------------------------------------------------------
       
  2020 // CAspProfileDialog::Item
       
  2021 // 
       
  2022 // Find item with aItemId (TAspConnectionSettingItem).
       
  2023 //-----------------------------------------------------------------------------
       
  2024 //
       
  2025 CAspListItemData* CAspProfileDialog::Item(TInt aItemId)
       
  2026 	{
       
  2027 	CAspListItemData* item = NULL;
       
  2028 
       
  2029 	TInt count = iSettingList->Count();
       
  2030 	for (TInt i=0; i<count; i++)
       
  2031 		{
       
  2032 		CAspListItemData* temp = (*iSettingList)[i];
       
  2033 		if (temp->iItemId == aItemId)
       
  2034 			{
       
  2035 			item = temp;
       
  2036 			break;
       
  2037 			}
       
  2038 		}
       
  2039 	
       
  2040 	__ASSERT_ALWAYS(item, TUtil::Panic(KErrGeneral));
       
  2041 
       
  2042     return item;
       
  2043 	}
       
  2044 
       
  2045 
       
  2046 // -----------------------------------------------------------------------------
       
  2047 // CAspProfileDialog::ListBox
       
  2048 // 
       
  2049 // -----------------------------------------------------------------------------
       
  2050 //
       
  2051 CAknSettingStyleListBox* CAspProfileDialog::ListBox()
       
  2052 	{
       
  2053 	return iSettingListBox;
       
  2054 	}
       
  2055 
       
  2056 
       
  2057 // -----------------------------------------------------------------------------
       
  2058 // CAspProfileDialog::UpdateCbaL
       
  2059 // 
       
  2060 // -----------------------------------------------------------------------------
       
  2061 //
       
  2062 void CAspProfileDialog::UpdateCbaL(TInt aResourceId)
       
  2063 	{
       
  2064 	CEikButtonGroupContainer& cba = ButtonGroupContainer();
       
  2065 	cba.SetCommandSetL(aResourceId);
       
  2066 	iCommandSetId = aResourceId;
       
  2067 	iMSKEmpty = EFalse;
       
  2068 	cba.DrawDeferred();
       
  2069 	}
       
  2070 
       
  2071 // -----------------------------------------------------------------------------
       
  2072 // CAspProfileDialog::UpdateMenuL
       
  2073 // 
       
  2074 // -----------------------------------------------------------------------------
       
  2075 //
       
  2076 
       
  2077 void CAspProfileDialog::UpdateMenuL(TInt aResource)
       
  2078 	{
       
  2079 	CEikMenuBar* menuBar = iMenuBar; // from CAknDialog
       
  2080 	menuBar->SetMenuTitleResourceId(aResource);
       
  2081 
       
  2082 	TRAPD(err, menuBar->TryDisplayMenuBarL());
       
  2083     		
       
  2084 	User::LeaveIfError(err);
       
  2085 	}
       
  2086 
       
  2087 // -----------------------------------------------------------------------------
       
  2088 // CAspProfileDialog::CheckAutoSyncSetttigsL
       
  2089 // 
       
  2090 // -----------------------------------------------------------------------------
       
  2091 //
       
  2092 void CAspProfileDialog::CheckAutoSyncSetttigsL()
       
  2093 	{
       
  2094 	CAspSchedule* schedule = CAspSchedule::NewLC();
       
  2095 	TInt profileId = schedule->ProfileId();
       
  2096 	if (profileId == iProfile->ProfileId())
       
  2097 			{
       
  2098 			if (iProfile->BearerType() != EAspBearerInternet)
       
  2099 				{
       
  2100 				schedule->SetProfileId(KErrNotFound);
       
  2101 				schedule->SetSyncPeakSchedule(CAspSchedule::EIntervalManual);
       
  2102 				schedule->SetSyncOffPeakSchedule(CAspSchedule::EIntervalManual);
       
  2103 				schedule->SetSyncFrequency(CAspSchedule::EIntervalManual);
       
  2104 				schedule->UpdateSyncScheduleL();
       
  2105 				schedule->SaveL();
       
  2106 				}
       
  2107 			else
       
  2108 				{
       
  2109 				schedule->UpdateProfileSettingsL();
       
  2110 				}
       
  2111 			}
       
  2112 	CleanupStack::PopAndDestroy(schedule);	
       
  2113 	}
       
  2114 	
       
  2115 //  End of File