omads/omadsappui/AspSyncUtil/src/AspSettingDialog.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 // INCLUDE FILES
       
    20 #include <AknIconArray.h>   // for GulArray
       
    21 #include <aknconsts.h>      // for KAvkonBitmapFile
       
    22 
       
    23 #include "AspSettingDialog.h"
       
    24 #include "AspProfileDialog.h"
       
    25 #include "AspScheduleDialog.h"
       
    26 #include "AspSchedule.h"
       
    27 #include "AspDialogUtil.h"
       
    28 #include "AspLogDialog.h"
       
    29 #include "AspUtil.h"
       
    30 #include "AspProfileWizardDialog.h"
       
    31 #include "AspDebug.h"
       
    32 #include "AspSyncUtil.rh"
       
    33 #include "AspAdvanceSettingsDialog.h"
       
    34 
       
    35 #include <aknsettingitemlist.h>
       
    36 
       
    37 #include <csxhelp/ds.hlp.hrh>  // for help text ids
       
    38 
       
    39 #ifndef RD_DSUI_TIMEDSYNC 
       
    40 #include <avkon.mbg>
       
    41 #else
       
    42 #include "AspSettingViewDialog.h"
       
    43 #endif
       
    44 #include <DataSyncInternalPSKeys.h>
       
    45 #include "AspAutoSyncHandler.h"
       
    46 #include <featmgr.h>   // FeatureManager
       
    47 
       
    48 const TInt KMSKControlId( CEikButtonGroupContainer::EMiddleSoftkeyPosition );
       
    49 
       
    50 
       
    51 
       
    52 
       
    53 // ============================ MEMBER FUNCTIONS ===============================
       
    54 
       
    55 
       
    56 
       
    57 
       
    58 /******************************************************************************
       
    59  * class CAspSettingDialog
       
    60  ******************************************************************************/
       
    61 
       
    62 // -----------------------------------------------------------------------------
       
    63 // CAspSettingDialog::ShowDialogL
       
    64 // 
       
    65 // -----------------------------------------------------------------------------
       
    66 //
       
    67 TBool CAspSettingDialog::ShowDialogL(TAspParam& aParam)
       
    68 	{
       
    69     CAspSettingDialog* dialog = CAspSettingDialog::NewL(aParam);
       
    70 
       
    71 	TBool ret = dialog->ExecuteLD(R_ASP_SETTING_DIALOG);
       
    72 
       
    73 	return ret;
       
    74 	}
       
    75 
       
    76 
       
    77 // -----------------------------------------------------------------------------
       
    78 // CAspSettingDialog::NewL
       
    79 //
       
    80 // -----------------------------------------------------------------------------
       
    81 //
       
    82 CAspSettingDialog* CAspSettingDialog::NewL(TAspParam& aParam)
       
    83     {
       
    84     FLOG( _L("CAspSettingDialog::NewL START") );
       
    85 
       
    86     CAspSettingDialog* self = new (ELeave) CAspSettingDialog(aParam);
       
    87     CleanupStack::PushL(self);
       
    88     self->ConstructL();
       
    89     CleanupStack::Pop(self);
       
    90 
       
    91     FLOG( _L("CAspSettingDialog::NewL END") );
       
    92     return self;
       
    93     }
       
    94 
       
    95 
       
    96 // -----------------------------------------------------------------------------
       
    97 // CAspSettingDialog::CAspSettingDialog
       
    98 // 
       
    99 // -----------------------------------------------------------------------------
       
   100 //
       
   101 CAspSettingDialog::CAspSettingDialog(TAspParam& aParam) 
       
   102     {
       
   103 	iApplicationId = aParam.iApplicationId;
       
   104 	iSyncSession = aParam.iSyncSession;
       
   105 	iDialogMode = aParam.iMode;
       
   106 	
       
   107 	iCurrentProfileId = KErrNotFound;
       
   108 	iCurrentProfileName = KNullDesC;
       
   109 	
       
   110 	__ASSERT_ALWAYS(iSyncSession, TUtil::Panic(KErrGeneral));
       
   111     }
       
   112 
       
   113 
       
   114 // -----------------------------------------------------------------------------
       
   115 // CAspSettingDialog::ConstructL
       
   116 //
       
   117 // -----------------------------------------------------------------------------
       
   118 //
       
   119 void CAspSettingDialog::ConstructL()
       
   120     {
       
   121     FLOG( _L("CAspSettingDialog::ConstructL START") );
       
   122 
       
   123     CAknDialog::ConstructL(R_ASP_SETTING_DIALOG_MENU);
       
   124     
       
   125     iSettingEnforcement = TUtil::SettingEnforcementState();
       
   126 
       
   127 	TAspParam param(iApplicationId, iSyncSession);
       
   128 	iProfileList = CAspProfileList::NewL(param);
       
   129 	iProfileList->ReadAllProfilesL(CAspProfileList::ENoMandatoryCheck);
       
   130 	iProfileList->Sort();
       
   131 	
       
   132     param.iMode = CAspContentList::EInitDataProviders;
       
   133 	iContentList = CAspContentList::NewL(param);
       
   134 	
       
   135 	// get previous title so it can be restored
       
   136 	iStatusPaneHandler = CStatusPaneHandler::NewL(iAvkonAppUi);
       
   137 	iStatusPaneHandler->StoreOriginalTitleL();
       
   138 	
       
   139 #ifdef RD_DSUI_TIMEDSYNC 
       
   140 
       
   141     iTabHandler = new (ELeave) CAspTabbedNaviPaneHandler(iAvkonAppUi->StatusPane() ,this);
       
   142 	iUpdateTabGroup = ETrue;
       
   143 
       
   144 #else
       
   145 	// store current navi pane
       
   146 	iStatusPaneHandler->StoreNavipaneL();
       
   147 	
       
   148 #endif
       
   149 	
       
   150 	
       
   151 
       
   152 	iResHandler = CAspResHandler::NewL();
       
   153 
       
   154 	// start listening sync database events
       
   155 	iDbNotifier = CAspDbNotifier::NewL(param, this);
       
   156 	iDbNotifier->RequestL();
       
   157 	
       
   158 	iPopupNote = CAknInfoPopupNoteController::NewL();
       
   159     iBearerHandler = CAspBearerHandler::NewL(param);
       
   160 
       
   161 	SetCurrentProfileL();
       
   162 	
       
   163 	FLOG( _L("CAspSettingDialog::ConstructL END") );
       
   164     } 
       
   165 
       
   166 
       
   167 // -----------------------------------------------------------------------------
       
   168 // Destructor
       
   169 //
       
   170 // -----------------------------------------------------------------------------
       
   171 //
       
   172 CAspSettingDialog::~CAspSettingDialog()
       
   173     {
       
   174     FLOG( _L("CAspSettingDialog::~CAspSettingDialog START") );
       
   175 
       
   176 	delete iProfileList;
       
   177 	delete iContentList;
       
   178 	
       
   179 	delete iStatusPaneHandler;
       
   180 	delete iResHandler;
       
   181 	
       
   182 	delete iDbNotifier;
       
   183 	iDbNotifier = NULL;
       
   184 	
       
   185 	delete iSyncHandler;   // created when sync is started
       
   186 	
       
   187 	if (iAvkonAppUi)
       
   188 		{
       
   189 		iAvkonAppUi->RemoveFromStack(this);
       
   190 		}
       
   191 
       
   192 	if (iPopupNote)
       
   193 		{
       
   194     	iPopupNote->HideInfoPopupNote();
       
   195 	    delete iPopupNote;
       
   196 		}
       
   197 
       
   198 	delete iBearerHandler;
       
   199 
       
   200 #ifdef RD_DSUI_TIMEDSYNC
       
   201 
       
   202 	delete iTabHandler;
       
   203 #endif
       
   204 
       
   205 	FLOG( _L("CAspSettingDialog::~CAspSettingDialog END") );
       
   206     }
       
   207 
       
   208 
       
   209 //------------------------------------------------------------------------------
       
   210 // CAspSettingDialog::ActivateL (from CCoeControl)
       
   211 //
       
   212 // Called by system when dialog is activated
       
   213 //------------------------------------------------------------------------------
       
   214 //
       
   215 void CAspSettingDialog::ActivateL()
       
   216 	{
       
   217     CAknDialog::ActivateL();
       
   218 
       
   219 	// this cannot be in ConstructL which is executed before dialog is launched
       
   220 	iAvkonAppUi->AddToStackL(this);
       
   221     }
       
   222 
       
   223 
       
   224 //------------------------------------------------------------------------------
       
   225 // CAspSettingDialog::GetHelpContext
       
   226 //
       
   227 //
       
   228 //------------------------------------------------------------------------------
       
   229 //
       
   230 void CAspSettingDialog::GetHelpContext(TCoeHelpContext& aContext) const
       
   231 	{
       
   232 	aContext.iMajor = KUidSmlSyncApp;
       
   233 	aContext.iContext = KDS_HLP_MAIN_VIEW;    
       
   234 	}
       
   235 
       
   236 
       
   237 //------------------------------------------------------------------------------
       
   238 // CAspSettingDialog::ProcessCommandL
       
   239 //
       
   240 // Handle commands from menu.
       
   241 //------------------------------------------------------------------------------
       
   242 //
       
   243 void CAspSettingDialog::ProcessCommandL(TInt aCommandId)
       
   244 	{
       
   245 	TInt err = KErrNone;
       
   246 
       
   247     // prevent db notifications while processing menu command
       
   248 	//Notifier()->SetDisabled(ETrue);
       
   249 	TRAP(err, DoProcessCommandL(aCommandId));
       
   250 	//Notifier()->SetDisabled(EFalse);
       
   251 	
       
   252 	if (err != KErrNone)
       
   253 		{
       
   254 		iDbNotifier->CheckUpdateEventL();
       
   255 		FLOG( _L("### CAspSettingDialog::ProcessCommandL failed (%d) ###"), err );
       
   256 		User::Leave(err);
       
   257 		}
       
   258 	}
       
   259 
       
   260 
       
   261 //------------------------------------------------------------------------------
       
   262 // CAspSettingDialog::DoProcessCommandL
       
   263 //
       
   264 // Handle commands from menu.
       
   265 //------------------------------------------------------------------------------
       
   266 //
       
   267 void CAspSettingDialog::DoProcessCommandL(TInt aCommandId)
       
   268 	{
       
   269 	HideMenu();
       
   270 
       
   271 	switch (aCommandId)
       
   272 		{
       
   273         case EAspMenuCmdSync:
       
   274 			{
       
   275 			SyncProfileL();
       
   276 			break;
       
   277 			}
       
   278 		case EAspMenuCmdCopyFromServer:
       
   279 			{
       
   280 			CopyFromServerL();
       
   281 			break;
       
   282 			}
       
   283         case EAspMenuCmdChangeProfile:
       
   284 			{
       
   285 			ChangeProfileL();
       
   286 			break;
       
   287 			}
       
   288         case EAspMenuCmdEdit:
       
   289 			{
       
   290 			EditProfileL(EDialogModeEdit ,KErrNotFound);
       
   291 			break;
       
   292 			}
       
   293         case EAspMenuCmdNewSet:
       
   294 			{
       
   295 			CreateProfileL();
       
   296 			break;
       
   297 			}
       
   298 		case EAspMenuCmdDelete:
       
   299 			{
       
   300 			DeleteProfileL();
       
   301 	   		break;
       
   302 			}
       
   303 		case EAspMenuCmdViewLog:
       
   304 			{
       
   305 			ShowLogDialogL();
       
   306 			break;
       
   307 			}
       
   308 		case EAspMenuCmdAutoSync:
       
   309 			{
       
   310 			ShowAutoSyncDialogL();
       
   311 			break;
       
   312 			}
       
   313 		case EAspMenuCmdAdvanceSettings:
       
   314 		    {
       
   315 		    //CAspAdvanceSettingsDialog* dialog = CAspAdvanceSettingsDialog::NewL();
       
   316 		    //CleanupStack::PushL(dialog);
       
   317 		        
       
   318 		    CAspAdvanceSettingsDialog::ShowDialogL();
       
   319 		        
       
   320 		    //CleanupStack::PopAndDestroy(dialog);
       
   321 
       
   322 		    //ShowContextMenuL(R_ASP_ROAMING_SETTINGS_CONTEXT_MENU);
       
   323 		    break;
       
   324 		    }
       
   325         case EAspMenuCmdRoamingSettings:
       
   326             {
       
   327             ShowContextMenuL(R_ASP_ROAMING_SETTINGS_CONTEXT_MENU);
       
   328             break;
       
   329             }		
       
   330 
       
   331 		case EAspMenuCmdMark:
       
   332 		case EAspMenuCmdUnmark:
       
   333 			{
       
   334 			SaveSelectionL();
       
   335 			break;	
       
   336 			}
       
   337     case EAknCmdHelp:
       
   338 			{
       
   339             TUtil::LaunchHelpAppL(iEikonEnv);
       
   340 			break;
       
   341 		  }
       
   342 
       
   343         case EAspMenuCmdExit:
       
   344         case EAknCmdExit:
       
   345         case EEikCmdExit:
       
   346 			{
       
   347    		
       
   348             //
       
   349 			// Exit dialog
       
   350 			//
       
   351 			// CEikAppUi::ProcessCommandL starts CAknAppShutter that 
       
   352 			// closes all dialogs and finally calling application. Before 
       
   353 			// dialog is closed (deleted) it's OkToExitL(EEikBidCancel)
       
   354 			// is called. EEikBidCancel means OkToExitL must silently
       
   355 			// save and return ETrue.
       
   356 			//
       
   357 			iAvkonAppUi->ProcessCommandL(EAknCmdExit);
       
   358 
       
   359 			break;
       
   360 			}
       
   361 
       
   362 		default:
       
   363 			{
       
   364 			break;
       
   365 			}
       
   366 		}
       
   367 	}
       
   368 
       
   369 
       
   370 // -----------------------------------------------------------------------------
       
   371 // CAspSettingDialog::OkToExitL
       
   372 //
       
   373 // Called by framework before dialog is closed.
       
   374 // -----------------------------------------------------------------------------
       
   375 //
       
   376 TBool CAspSettingDialog::OkToExitL(TInt aButtonId)
       
   377     {
       
   378     
       
   379 	// Options/Exit, End key, Close key ('c')
       
   380 	if (aButtonId == EEikBidCancel)
       
   381 		{
       
   382 		// framework calls this when dialog must shut down
       
   383     	return ETrue;
       
   384 		}
       
   385 
       
   386 	// Back key (cba)
       
   387 	if (aButtonId == EAknSoftkeyBack)
       
   388         {
       
   389 		return ETrue;
       
   390 		}
       
   391 
       
   392     // Exit key (cba)
       
   393 	if (aButtonId == EAknSoftkeyExit)
       
   394         {
       
   395         if (iDialogMode == EModeDialogNoWait && iApplicationId == EApplicationIdSync)
       
   396         	{
       
   397             //  close sync app
       
   398         	iAvkonAppUi->ProcessCommandL(EAknCmdExit);
       
   399         	}
       
   400 
       
   401         return ETrue;
       
   402 		}
       
   403 		
       
   404 	if (aButtonId == EAknSoftkeyMark || aButtonId == EAknSoftkeyUnmark 
       
   405 		|| aButtonId == EAknSoftkeyOpen)  // MSK
       
   406         {
       
   407 
       
   408 		if (iProfileList->Count() == 0)
       
   409 			{
       
   410 			return EFalse;
       
   411 			}
       
   412         
       
   413         if (IsProfileLockedL(iCurrentProfileId))
       
   414         	{
       
   415         	TDialogUtil::ShowErrorNoteL(R_ASP_LOCKED_PROFILE);
       
   416 			CancelCheckboxEvent();
       
   417 			return EFalse;
       
   418 			}
       
   419         
       
   420         if (iSettingEnforcement)
       
   421 			{
       
   422 			TDialogUtil::ShowInformationNoteL(R_ASP_PROTECTED_SETTING);
       
   423 			return EFalse;  // leave dialog open;
       
   424 			}
       
   425         
       
   426         if (!CheckEmailSelection())
       
   427         	{
       
   428         	return EFalse;  // leave dialog open;
       
   429         	}
       
   430 				
       
   431 		TInt ret =  SaveCurrentProfile();
       
   432 		if (ret != KErrNone)
       
   433 			{
       
   434 			CancelCheckboxEvent();
       
   435 			}
       
   436 			
       
   437 		return EFalse;  // leave dialog open
       
   438 		}
       
   439 		
       
   440 
       
   441 	return CAknDialog::OkToExitL(aButtonId);
       
   442     }
       
   443 
       
   444 
       
   445 // ----------------------------------------------------------------------------
       
   446 // CAspSettingDialog::CancelMailBoxForEnterL
       
   447 // 
       
   448 // ----------------------------------------------------------------------------
       
   449 //
       
   450 
       
   451 void CAspSettingDialog::CancelMailBoxForEnterL()
       
   452 {
       
   453 	CListBoxView* view = iSettingListBox->View();
       
   454 	
       
   455     TInt index = view->CurrentItemIndex();
       
   456     TAspProviderItem& item = iContentList->ProviderItem(index);
       
   457     TBool selected = view->ItemIsSelected(index);
       
   458     
       
   459     if(selected)
       
   460     {
       
   461         view->DeselectItem(index);
       
   462     }
       
   463     else
       
   464     {
       
   465     	view->SelectItemL(index);
       
   466     }   
       
   467     
       
   468 }
       
   469 
       
   470 
       
   471 // ----------------------------------------------------------------------------
       
   472 // CAspSettingDialog::OfferKeyEventL
       
   473 // 
       
   474 // ----------------------------------------------------------------------------
       
   475 //
       
   476 TKeyResponse CAspSettingDialog::OfferKeyEventL(const TKeyEvent& aKeyEvent,TEventCode aType)
       
   477 	{
       
   478 	if (aType == EEventKey)
       
   479 		{
       
   480 		switch (aKeyEvent.iCode)
       
   481 			{
       
   482 			//case EKeyOK:
       
   483 			//	{
       
   484 			//	ShowContextMenuL(R_ASP_SETTING_DIALOG_CONTEXT_MENU);
       
   485 			//	return EKeyWasConsumed;
       
   486 			//	}
       
   487 			case EKeyEnter:
       
   488 			{
       
   489                    CancelMailBoxForEnterL();
       
   490                    OkToExitL(EAknSoftkeyOpen);
       
   491                    return EKeyWasConsumed;
       
   492 			}
       
   493 
       
   494 			case EKeyEscape:  // framework calls this when dialog must shut
       
   495 				{
       
   496 				return CAknDialog::OfferKeyEventL(aKeyEvent, aType);
       
   497         		}
       
   498         		
       
   499 			//case EStdKeyHome:
       
   500 			//	{
       
   501 			//	DeleteSelectedProfileL();
       
   502 			//	return EKeyWasConsumed;
       
   503 			//	}
       
   504 
       
   505 #ifdef RD_DSUI_TIMEDSYNC 
       
   506 
       
   507 			case EKeyLeftArrow:
       
   508 				{
       
   509 				SetPreviousProfileL();
       
   510 				return EKeyWasConsumed;
       
   511 				}
       
   512 
       
   513 			case EKeyRightArrow:
       
   514 				{
       
   515 				SetNextProfileL();
       
   516 				return EKeyWasConsumed;
       
   517 				}
       
   518 
       
   519 #endif
       
   520             default:
       
   521 			    break;
       
   522 			}
       
   523 		}
       
   524 
       
   525 	return CAknDialog::OfferKeyEventL( aKeyEvent, aType);
       
   526 	}
       
   527 
       
   528 
       
   529 // ----------------------------------------------------------------------------
       
   530 // CAspSettingDialog::HandleResourceChange
       
   531 // 
       
   532 // ----------------------------------------------------------------------------
       
   533 //
       
   534 
       
   535 void CAspSettingDialog::HandleResourceChange(TInt aType)
       
   536     {   
       
   537     if (aType == KEikDynamicLayoutVariantSwitch) //Handle change in layout orientation
       
   538         {
       
   539         TRect mainPaneRect;
       
   540         AknLayoutUtils::LayoutMetricsRect(AknLayoutUtils::EMainPane, mainPaneRect);
       
   541         SetRect(mainPaneRect);
       
   542         iSettingListBox->SetSize(mainPaneRect.Size());
       
   543         CCoeControl::HandleResourceChange(aType);
       
   544 		DrawDeferred();
       
   545 	    return;
       
   546 		}
       
   547 		
       
   548     if (aType == KAknsMessageSkinChange)
       
   549         {
       
   550         TRAP_IGNORE(SetIconsL());
       
   551         }
       
   552         
       
   553     CCoeControl::HandleResourceChange(aType);
       
   554     }
       
   555 
       
   556 /*
       
   557 void CAspSettingDialog::HandleResourceChange(TInt aType)
       
   558     {   
       
   559     if (aType == KEikDynamicLayoutVariantSwitch) //Handle change in layout orientation
       
   560         {
       
   561   
       
   562         TRect mainPaneRect;
       
   563         AknLayoutUtils::LayoutMetricsRect(AknLayoutUtils::EMainPane, mainPaneRect);
       
   564         TBuf<299> buf;
       
   565         buf.Format(_L("(%d,%d) (%d,%d)"), mainPaneRect.iTl.iX, mainPaneRect.iTl.iY, mainPaneRect.iBr.iX, mainPaneRect.iBr.iY);
       
   566 
       
   567         SetRect(mainPaneRect);
       
   568         iSettingListBox->HandleResourceChange(aType);
       
   569 		DrawNow();
       
   570   
       
   571         
       
   572         CAknDialog::HandleResourceChange(aType);
       
   573         
       
   574         TRect mainPaneRect;
       
   575         AknLayoutUtils::LayoutMetricsRect(AknLayoutUtils::EMainPane, mainPaneRect);
       
   576         SetRect(mainPaneRect);
       
   577         
       
   578         iSettingListBox->SetSize(mainPaneRect.Size());
       
   579         //iSettingListBox->HandleResourceChange(aType);
       
   580         CCoeControl::HandleResourceChange(aType);
       
   581 		DrawDeferred();
       
   582 		
       
   583 		
       
   584 	    return;
       
   585 		}
       
   586 		
       
   587     if (aType == KAknsMessageSkinChange)
       
   588         {
       
   589         TRAP_IGNORE(SetIconsL());
       
   590         }
       
   591         
       
   592     CCoeControl::HandleResourceChange(aType);
       
   593     }
       
   594 */
       
   595 
       
   596 // ----------------------------------------------------------------------------
       
   597 // CAspSettingDialog::SetIconsL
       
   598 //
       
   599 // ----------------------------------------------------------------------------
       
   600 //
       
   601 void CAspSettingDialog::SetIconsL()
       
   602     {
       
   603     if (!iSettingListBox)
       
   604     	{
       
   605     	return;
       
   606     	}
       
   607  
       
   608  	TFileName bitmapName;
       
   609 	CAspResHandler::GetBitmapFileName(bitmapName);
       
   610 	CArrayPtr<CGulIcon>* icons = new (ELeave) CAknIconArray(KDefaultArraySize);
       
   611 	CleanupStack::PushL(icons);
       
   612 	
       
   613 	// NOTE: icons must be appended in correct order (TAspSettingDialogIconIndex)
       
   614 	icons->AppendL(IconL(KAknsIIDQgnPropCheckboxOn, KAvkonBitmapFile, 
       
   615 	                     EMbmAvkonQgn_prop_checkbox_on,
       
   616 	                     EMbmAvkonQgn_prop_checkbox_on_mask));
       
   617 	                     
       
   618 	icons->AppendL(IconL(KAknsIIDQgnPropCheckboxOff, KAvkonBitmapFile,
       
   619 	                     EMbmAvkonQgn_prop_checkbox_off,
       
   620 	                     EMbmAvkonQgn_prop_checkbox_off_mask));
       
   621 	
       
   622     // delete old icons
       
   623     CArrayPtr<CGulIcon>* arr = iSettingListBox->ItemDrawer()->FormattedCellData()->IconArray();
       
   624     if (arr)
       
   625     	{
       
   626     	arr->ResetAndDestroy();
       
   627 	    delete arr;
       
   628 	    arr = NULL;
       
   629     	}
       
   630 
       
   631 	iSettingListBox->ItemDrawer()->FormattedCellData()->SetIconArrayL(icons);
       
   632 	CleanupStack::Pop(icons);
       
   633     }
       
   634 
       
   635 
       
   636 // ----------------------------------------------------------------------------
       
   637 // CAspSettingDialog::ShowContextMenuL
       
   638 // 
       
   639 // ----------------------------------------------------------------------------
       
   640 //
       
   641 void CAspSettingDialog::ShowContextMenuL(TInt aResource)
       
   642 	{
       
   643 	if (SyncRunning())
       
   644 		{
       
   645 		return;
       
   646 		}
       
   647 	
       
   648 	//
       
   649 	// Switch to Context specific options menu,
       
   650 	// Show it and switch back to main options menu.
       
   651 	// 
       
   652 	CEikMenuBar* menuBar = iMenuBar; // from CAknDialog
       
   653 	menuBar->SetMenuTitleResourceId(aResource);
       
   654 
       
   655 
       
   656 	// TRAP displaying of menu bar.
       
   657 	// If it fails, the correct resource is set back before leave.
       
   658 	TRAPD(err, menuBar->TryDisplayMenuBarL());
       
   659 	
       
   660 	menuBar->SetMenuTitleResourceId(R_ASP_SETTING_DIALOG_MENU);
       
   661 		
       
   662 	User::LeaveIfError(err);
       
   663 	}
       
   664 
       
   665 
       
   666 // -----------------------------------------------------------------------------
       
   667 // CAspSettingDialog::PostLayoutDynInitL
       
   668 //
       
   669 // Called by framework after dialog is shown.
       
   670 // -----------------------------------------------------------------------------
       
   671 //
       
   672 void CAspSettingDialog::PostLayoutDynInitL()
       
   673 	{
       
   674 	#ifdef RD_DSUI_TIMEDSYNC
       
   675 	ShowAutoSyncProfileInfo();
       
   676 	#else
       
   677   ShowCurrentProfileInfo();
       
   678   #endif
       
   679 	}
       
   680 	
       
   681 
       
   682 // -----------------------------------------------------------------------------
       
   683 // CAspSettingDialog::PreLayoutDynInitL
       
   684 //
       
   685 // Called by framework before dialog is shown.
       
   686 // -----------------------------------------------------------------------------
       
   687 //
       
   688 void CAspSettingDialog::PreLayoutDynInitL()
       
   689     {
       
   690     iSettingListBox = (CAknDoubleLargeStyleListBox*) ControlOrNull (EAspSettingDialogList);
       
   691     
       
   692    	__ASSERT_ALWAYS(iSettingListBox, TUtil::Panic(KErrGeneral));
       
   693 	
       
   694 	iSettingListBox->SetListBoxObserver(this);
       
   695 	iSettingListBox->CreateScrollBarFrameL(ETrue);
       
   696 	iSettingListBox->ScrollBarFrame()->SetScrollBarVisibilityL(
       
   697 	                 CEikScrollBarFrame::EOff, CEikScrollBarFrame::EAuto);
       
   698 	
       
   699 	SetIconsL();
       
   700 	UpdateListBoxL();
       
   701 
       
   702 #ifdef RD_DSUI_TIMEDSYNC 
       
   703 
       
   704 	UpdateTabsL();
       
   705 #else
       
   706 
       
   707 	UpdateNavipaneL(iCurrentProfileName);
       
   708 #endif
       
   709 
       
   710 	
       
   711 	iSettingListBox->UpdateScrollBarsL();
       
   712 	iSettingListBox->ScrollBarFrame()->MoveVertThumbTo(0);
       
   713 
       
   714 	iStatusPaneHandler->SetTitleL(R_ASP_SETTING_DIALOG_TITLE);
       
   715 
       
   716 	SetCurrentIndex();
       
   717 //#ifdef RD_DSUI_CP_INTEGRATION
       
   718 	TBool flag = CEikonEnv::Static()->StartedAsServerApp() ;
       
   719 	if (flag || iApplicationId != EApplicationIdSync)
       
   720 /*#else
       
   721 	if (iApplicationId != EApplicationIdSync)
       
   722 #endif */
       
   723 		{
       
   724 		UpdateCbaL(R_ASP_CBA_OPTIONS_BACK_MARK);
       
   725 		}
       
   726 		
       
   727 	if(iSettingEnforcement)
       
   728 	{
       
   729 		UpdateMiddleSoftKeyLabelL(EAknSoftkeyOpen,R_TEXT_SOFTKEY_EMPTY);	
       
   730    	}
       
   731 	}
       
   732 
       
   733 
       
   734 // -----------------------------------------------------------------------------
       
   735 // CAspSettingDialog::DynInitMenuPaneL
       
   736 //
       
   737 // Called by framework before menu is shown.
       
   738 // -----------------------------------------------------------------------------
       
   739 //
       
   740 void CAspSettingDialog::DynInitMenuPaneL(TInt aResourceID, 	CEikMenuPane* aMenuPane)
       
   741 	{
       
   742 	TInt menu1 = R_ASP_SETTING_DIALOG_MENU_PANE;
       
   743 	TInt menu2 = R_ASP_SETTING_DIALOG_CONTEXT_MENU_PANE;
       
   744 	
       
   745     if (aResourceID != menu1 && aResourceID != menu2)
       
   746 		{
       
   747 		return; // not one of our menus
       
   748 		}
       
   749 
       
   750 	if (aResourceID == R_ASP_SETTING_DIALOG_CONTEXT_MENU_PANE)
       
   751 		{
       
   752 		InitContextMenuL(aMenuPane); // separate handling for context menu
       
   753 		}
       
   754 	else
       
   755 		{
       
   756 		InitOptionsMenuL(aMenuPane);
       
   757 		}
       
   758 	}
       
   759 
       
   760 
       
   761 // -----------------------------------------------------------------------------
       
   762 // CAspSettingDialog::InitContextMenuL
       
   763 //
       
   764 // -----------------------------------------------------------------------------
       
   765 //
       
   766 void CAspSettingDialog::InitContextMenuL(CEikMenuPane* /*aMenuPane*/)
       
   767 	{
       
   768 	}
       
   769 
       
   770 
       
   771 // -----------------------------------------------------------------------------
       
   772 // CAspSettingDialog::InitOptionsMenuL
       
   773 //
       
   774 // -----------------------------------------------------------------------------
       
   775 //
       
   776 void CAspSettingDialog::InitOptionsMenuL(CEikMenuPane* aMenuPane)
       
   777 	{
       
   778 	TInt profileCount = iProfileList->Count();
       
   779 	TInt providerCount = iContentList->ProviderCount();
       
   780 	TInt deletableProfileCount = iProfileList->DeletableProfileCount();
       
   781 	
       
   782 	if (providerCount == 0)  // no data providers
       
   783 		{
       
   784 		TDialogUtil::DeleteMenuItem(aMenuPane, EAspMenuCmdSync);
       
   785 		TDialogUtil::DeleteMenuItem(aMenuPane, EAspMenuCmdNewSet);
       
   786 		TDialogUtil::DeleteMenuItem(aMenuPane, EAspMenuCmdEdit);
       
   787 		TDialogUtil::DeleteMenuItem(aMenuPane, EAspMenuCmdChangeProfile);
       
   788 		TDialogUtil::DeleteMenuItem(aMenuPane, EAspMenuCmdDelete);
       
   789 		TDialogUtil::DeleteMenuItem(aMenuPane, EAspMenuCmdAutoSync);
       
   790 		TDialogUtil::DeleteMenuItem(aMenuPane, EAspMenuCmdViewLog);
       
   791 		TDialogUtil::DeleteMenuItem(aMenuPane, EAspMenuCmdCopyFromServer);
       
   792 		return;
       
   793     	}
       
   794 	
       
   795 	
       
   796 	// Options/Sync
       
   797 	// Options/Copy all from server
       
   798 	if (iCurrentProfileId == KErrNotFound && profileCount > 0)
       
   799 		{
       
   800 		TDialogUtil::DeleteMenuItem(aMenuPane, EAspMenuCmdSync);
       
   801 		TDialogUtil::DeleteMenuItem(aMenuPane, EAspMenuCmdCopyFromServer);
       
   802 		}
       
   803 	if (iSettingEnforcement && profileCount == 0)
       
   804 		{
       
   805 		TDialogUtil::DeleteMenuItem(aMenuPane, EAspMenuCmdSync);
       
   806 		TDialogUtil::DeleteMenuItem(aMenuPane, EAspMenuCmdCopyFromServer);
       
   807 		}
       
   808 
       
   809 	if (iCurrentProfileId == KErrNotFound)
       
   810 		{
       
   811 		TDialogUtil::DeleteMenuItem(aMenuPane, EAspMenuCmdCopyFromServer);
       
   812 		}
       
   813 
       
   814 	// Options/Change
       
   815 	if (profileCount == 0)
       
   816 		{
       
   817 		TDialogUtil::DeleteMenuItem(aMenuPane, EAspMenuCmdChangeProfile);
       
   818 		TDialogUtil::DeleteMenuItem(aMenuPane, EAspMenuCmdMark);
       
   819 	    TDialogUtil::DeleteMenuItem(aMenuPane, EAspMenuCmdUnmark);	 
       
   820 		}
       
   821 	if (profileCount == 1 && iCurrentProfileId != KErrNotFound)
       
   822 		{
       
   823 		TDialogUtil::DeleteMenuItem(aMenuPane, EAspMenuCmdChangeProfile);
       
   824 		}
       
   825 	
       
   826 	// Options/Edit
       
   827 	if (iCurrentProfileId == KErrNotFound)
       
   828 		{
       
   829 		TDialogUtil::DeleteMenuItem(aMenuPane, EAspMenuCmdEdit);
       
   830 		}
       
   831 	
       
   832 	// Options/Auto sync
       
   833 	if (iCurrentProfileId == KErrNotFound)
       
   834 		{
       
   835 		TDialogUtil::DeleteMenuItem(aMenuPane, EAspMenuCmdAutoSync);
       
   836 		}
       
   837 
       
   838 	// Options/New
       
   839 	if (iSettingEnforcement)
       
   840 		{
       
   841 		TDialogUtil::DeleteMenuItem(aMenuPane, EAspMenuCmdNewSet);
       
   842 		TDialogUtil::DeleteMenuItem(aMenuPane, EAspMenuCmdMark);
       
   843 	    TDialogUtil::DeleteMenuItem(aMenuPane, EAspMenuCmdUnmark);	 
       
   844 		}
       
   845 
       
   846 	// Options/Delete   
       
   847    if (IsSyncOnGoingL(iCurrentProfileId) || iSettingEnforcement 
       
   848    										|| deletableProfileCount == 0)
       
   849     	{
       
   850     	TDialogUtil::DeleteMenuItem(aMenuPane, EAspMenuCmdDelete);
       
   851      	}
       
   852 	
       
   853 	// Options/View log
       
   854 	if (iCurrentProfileId == KErrNotFound)
       
   855 		{
       
   856 		TDialogUtil::DeleteMenuItem(aMenuPane, EAspMenuCmdViewLog);
       
   857 		}
       
   858 	
       
   859 	if (!FeatureManager::FeatureSupported(KFeatureIdHelp))
       
   860 		{
       
   861 		TDialogUtil::DeleteMenuItem(aMenuPane, EAknCmdHelp);
       
   862 		}
       
   863 		
       
   864 #ifdef RD_DSUI_TIMEDSYNC 
       
   865 	if(profileCount)
       
   866 		{
       
   867 	 	//Delete active profile
       
   868 	 	TAspParam param(iApplicationId, iSyncSession);
       
   869 	 	TAspProfileItem& currentProfile = CurrentProfileL();
       
   870 	 	if(!currentProfile.iDeleteAllowed)
       
   871 	 		{
       
   872 	    	TDialogUtil::DeleteMenuItem(aMenuPane, EAspMenuCmdDelete);
       
   873 			}
       
   874 	 	//Change profile option is removed
       
   875 	 	TDialogUtil::DeleteMenuItem(aMenuPane, EAspMenuCmdChangeProfile);
       
   876 	 	
       
   877 
       
   878 	 	CAspSchedule* schedule = CAspSchedule::NewLC();
       
   879 	 	TInt asProfileId = schedule->AutoSyncProfileId();
       
   880 	 	if (iCurrentProfileId == schedule->ProfileId()
       
   881 	 							&& asProfileId != KErrNotFound)
       
   882 			{
       
   883 			CAspProfile* asProfile = CAspProfile::NewLC(param);
       
   884 			asProfile->OpenL(asProfileId, CAspProfile::EOpenRead, CAspProfile::EAllProperties);
       
   885 			if (!asProfile->IsSynced() && !currentProfile.iSynced)
       
   886 				{
       
   887 				TDialogUtil::DeleteMenuItem(aMenuPane, EAspMenuCmdViewLog);
       
   888 				}
       
   889 			CleanupStack::PopAndDestroy(asProfile);
       
   890 			}
       
   891 	 	else
       
   892 			{
       
   893 			if (!currentProfile.iSynced)
       
   894 		    	{
       
   895 	        	TDialogUtil::DeleteMenuItem(aMenuPane, EAspMenuCmdViewLog);
       
   896 		    	}
       
   897 
       
   898 			}
       
   899 		 CleanupStack::PopAndDestroy(schedule);
       
   900 		}
       
   901 #else
       
   902 	 
       
   903 	 
       
   904 	 TAspProfileItem& profile = CurrentProfileL();
       
   905      if (!profile.iSynced)
       
   906 		 {
       
   907 	         iProfileList->ReadProfileL(iCurrentProfileId);
       
   908 	       }
       
   909 	  
       
   910 	   if (!profile.iSynced)
       
   911 	           {
       
   912 	     TDialogUtil::DeleteMenuItem(aMenuPane, EAspMenuCmdViewLog);
       
   913 		 }
       
   914 #endif
       
   915 if(!iSettingEnforcement)
       
   916 {
       
   917 	UpdateMarkMenuItem(aMenuPane);
       
   918 }
       
   919 #ifndef RD_DSUI_TIMEDSYNC
       
   920      TDialogUtil::DeleteMenuItem(aMenuPane, EAspMenuCmdAutoSync);
       
   921 #endif
       
   922 
       
   923 	}
       
   924 
       
   925 // -----------------------------------------------------------------------------
       
   926 // CAspSettingDialog::IsSyncOnGoing
       
   927 //
       
   928 // -----------------------------------------------------------------------------
       
   929 //
       
   930 TBool CAspSettingDialog::IsSyncOnGoingL(TInt aProfileId)
       
   931 	{
       
   932 	TInt currentJobId = CAspProfile::CurrentJob(iSyncSession);
       
   933 	if (currentJobId != KErrNotFound)
       
   934 			{
       
   935 			RSyncMLDataSyncJob syncJob;
       
   936 			syncJob.OpenL(*iSyncSession, currentJobId);
       
   937 			if (syncJob.Profile() == aProfileId)
       
   938 				{
       
   939 				syncJob.Close();
       
   940 				return ETrue;
       
   941 				}
       
   942 			syncJob.Close();
       
   943 			}
       
   944 	return EFalse;
       
   945 	}
       
   946 
       
   947 	
       
   948 #ifdef RD_DSUI_TIMEDSYNC 
       
   949 // -----------------------------------------------------------------------------
       
   950 // CAspSettingDialog::SetNextProfileL
       
   951 //
       
   952 // -----------------------------------------------------------------------------
       
   953 //
       
   954 void CAspSettingDialog::SetNextProfileL()
       
   955 	{
       
   956     FLOG( _L("CAspSettingDialog::SetNextProfileL START") );
       
   957 
       
   958 	if (iProfileList->Count() == 0)
       
   959 		{
       
   960 		return;
       
   961 		}
       
   962     
       
   963     TInt currentIndex = iProfileList->ListIndex(iCurrentProfileId);
       
   964     if (currentIndex == KErrNotFound)
       
   965     	{
       
   966     	FLOG( _L("CAspSettingDialog::SetNextProfileL END") );
       
   967     	
       
   968     	User::Leave(KErrNotFound);
       
   969     	}
       
   970     
       
   971     TInt newIndex = 0;
       
   972     TInt count = iProfileList->Count();
       
   973     if (currentIndex >= count-1)
       
   974         {
       
   975         newIndex = 0;
       
   976         }
       
   977     else
       
   978         {
       
   979         newIndex = currentIndex + 1;
       
   980         }
       
   981     TAspProfileItem& olditem = iProfileList->Item(currentIndex);        
       
   982     TAspProfileItem& item = iProfileList->Item(newIndex);
       
   983 
       
   984 	if (item.iProfileName.Compare(KAutoSyncProfileName) == 0)
       
   985 			{
       
   986 			if(newIndex >= count-1)
       
   987 				{
       
   988 				newIndex = 0;
       
   989 				}
       
   990 			else
       
   991 				{
       
   992 				newIndex++;
       
   993 				}
       
   994 			TAspProfileItem& newItem = iProfileList->Item(newIndex);
       
   995 			SetCurrentProfile(newItem.iProfileId);
       
   996 			}
       
   997 	else 
       
   998 		{
       
   999 		SetCurrentProfile(item.iProfileId);
       
  1000 		}
       
  1001 	
       
  1002 	//ShowCurrentProfileInfo();
       
  1003     UpdateListBoxL();
       
  1004 	//UpdateNavipaneL(iCurrentProfileName);
       
  1005     UpdateTabsL();
       
  1006         
       
  1007     FLOG( _L("CAspSettingDialog::SetNextProfileL END") );
       
  1008 	}
       
  1009 
       
  1010 
       
  1011 // -----------------------------------------------------------------------------
       
  1012 // CAspSettingDialog::SetPreviousProfileL
       
  1013 //
       
  1014 // -----------------------------------------------------------------------------
       
  1015 //
       
  1016 void CAspSettingDialog::SetPreviousProfileL()
       
  1017 	{
       
  1018     FLOG( _L("CAspSettingDialog::SetPreviousProfileL START") );
       
  1019 
       
  1020 	if (iProfileList->Count() == 0)
       
  1021 		{
       
  1022 		return;
       
  1023 		}
       
  1024     
       
  1025     TInt currentIndex = iProfileList->ListIndex(iCurrentProfileId);
       
  1026     if (currentIndex == KErrNotFound)
       
  1027     	{
       
  1028     	FLOG( _L("CAspSettingDialog::SetNextProfileL END") );
       
  1029     	
       
  1030     	User::Leave(KErrNotFound);
       
  1031     	}
       
  1032     
       
  1033     TInt newIndex = 0;
       
  1034     TInt count = iProfileList->Count();
       
  1035     if (currentIndex == 0)
       
  1036         {
       
  1037         newIndex = count - 1;
       
  1038         }
       
  1039     else
       
  1040         {
       
  1041         newIndex = currentIndex - 1;
       
  1042         }
       
  1043    
       
  1044     TAspProfileItem& item = iProfileList->Item(newIndex);
       
  1045 
       
  1046 	if (item.iProfileName.Compare(KAutoSyncProfileName) == 0)
       
  1047 		{
       
  1048 		if(newIndex == 0)
       
  1049 			{
       
  1050 				newIndex = count - 1;
       
  1051 			}
       
  1052 		else
       
  1053 			{
       
  1054 				newIndex--;
       
  1055 			}
       
  1056 			TAspProfileItem& newItem = iProfileList->Item(newIndex);
       
  1057 			SetCurrentProfile(newItem.iProfileId);
       
  1058 		}
       
  1059 	else
       
  1060 		{
       
  1061 		 SetCurrentProfile(item.iProfileId);	
       
  1062 		}
       
  1063 
       
  1064    
       
  1065 	//ShowCurrentProfileInfo();
       
  1066     UpdateListBoxL();
       
  1067 	//UpdateNavipaneL(iCurrentProfileName);
       
  1068 	UpdateTabsL();
       
  1069 
       
  1070     FLOG( _L("CAspSettingDialog::SetPreviousProfileL END") );
       
  1071 	}
       
  1072 
       
  1073 
       
  1074 // -----------------------------------------------------------------------------
       
  1075 // CAspSettingDialog::UpdateTabsL
       
  1076 //
       
  1077 // -----------------------------------------------------------------------------
       
  1078 //
       
  1079 void CAspSettingDialog::UpdateTabsL()
       
  1080 	{
       
  1081     FLOG( _L("CAspSettingDialog::UpdateTabsL START") );
       
  1082 
       
  1083 	TInt count = iProfileList->Count();
       
  1084 	if (count == 0)
       
  1085 		{
       
  1086 		//handle no profile condition
       
  1087 		iTabHandler->DeleteTabsL();
       
  1088 		_LIT(KEmpty, " ");
       
  1089 		TBuf<64> tabText(KEmpty);
       
  1090 		TInt profileId = KMaxProfileCount;
       
  1091 		iTabHandler->AddTabL(tabText, profileId);
       
  1092 		iTabHandler->SetActiveTabL(profileId);
       
  1093 		return;
       
  1094 		}
       
  1095 
       
  1096 	if (iTabHandler->TabIndex(iCurrentProfileId) == KErrNotFound)
       
  1097 		{
       
  1098 		iUpdateTabGroup = ETrue;
       
  1099 		}
       
  1100 	if (iUpdateTabGroup)
       
  1101 		{
       
  1102 		//update changed settings
       
  1103 	    iProfileList->ReadAllProfilesL(CAspProfileList::ENoMandatoryCheck);
       
  1104 		iProfileList->Sort();
       
  1105     	SetCurrentProfile(iCurrentProfileId);
       
  1106 		count = iProfileList->Count();
       
  1107 		iTabHandler->DeleteTabsL();
       
  1108         for (TInt i=0; i<count; i++)
       
  1109         	{
       
  1110         	TAspProfileItem& item = iProfileList->Item(i);
       
  1111 			iTabHandler->AddTabL(item.iProfileName, item.iProfileId);
       
  1112     		}
       
  1113     	iTabHandler->SetTabWidthL();
       
  1114 		iUpdateTabGroup = EFalse;		
       
  1115 		}
       
  1116 	if (iCurrentProfileId != KErrNotFound)
       
  1117 		{
       
  1118 		iTabHandler->SetTabTextL(iCurrentProfileName, iCurrentProfileId);	
       
  1119 		}
       
  1120 	CAspSchedule* schedule = CAspSchedule::NewLC();
       
  1121 	if (iCurrentProfileId == schedule->ProfileId()
       
  1122 							 && schedule->IsAutoSyncEnabled())
       
  1123 		{
       
  1124 		//show indicator icon for profile that has auto sync ON.
       
  1125 		_LIT(KSpace,"  ");
       
  1126 		TBuf<64> tabText;
       
  1127 		tabText.Append(KClockCharacter);//Unicode character U+F815 (clock)
       
  1128 		tabText.Append(KSpace);
       
  1129 		tabText.Append(iCurrentProfileName);
       
  1130 		iTabHandler->SetTabTextL(tabText, iCurrentProfileId);
       
  1131 		}
       
  1132 		
       
  1133 	if (iCurrentProfileId != KErrNotFound)
       
  1134         {
       
  1135         iTabHandler->SetActiveTabL(iCurrentProfileId);    
       
  1136         }
       
  1137 
       
  1138 	CleanupStack::PopAndDestroy(schedule);
       
  1139 	
       
  1140 	
       
  1141     FLOG( _L("CAspSettingDialog::UpdateTabsL END") );
       
  1142 	}
       
  1143 
       
  1144 #endif
       
  1145 // -----------------------------------------------------------------------------
       
  1146 // CAspSettingDialog::UpdateMarkMenuItem
       
  1147 //
       
  1148 // -----------------------------------------------------------------------------
       
  1149 //
       
  1150 
       
  1151 void CAspSettingDialog::UpdateMarkMenuItem(CEikMenuPane* aMenuPane)
       
  1152 	{
       
  1153 	
       
  1154 	CListBoxView* view = iSettingListBox->View();
       
  1155     
       
  1156     TInt index = view->CurrentItemIndex();
       
  1157     TBool mark = view->ItemIsSelected(index);
       
  1158 	
       
  1159 	aMenuPane->SetItemDimmed(EAspMenuCmdMark,mark);
       
  1160 	aMenuPane->SetItemDimmed(EAspMenuCmdUnmark,!mark);
       
  1161 		
       
  1162 	}
       
  1163 
       
  1164 // -----------------------------------------------------------------------------
       
  1165 // CAspSettingDialog::SaveSelection
       
  1166 // Update Mark/Unmark selected from menu 
       
  1167 // -----------------------------------------------------------------------------
       
  1168 //
       
  1169 void CAspSettingDialog::SaveSelectionL()
       
  1170 {
       
  1171     if (IsProfileLockedL(iCurrentProfileId))
       
  1172        	{
       
  1173        	TDialogUtil::ShowErrorNoteL(R_ASP_LOCKED_PROFILE);
       
  1174 		return;
       
  1175 		}
       
  1176        
       
  1177        if (iSettingEnforcement)
       
  1178 		{
       
  1179 		TDialogUtil::ShowInformationNoteL(R_ASP_PROTECTED_SETTING);
       
  1180 		return; 
       
  1181 		}
       
  1182 		
       
  1183 	//update check box & profile
       
  1184     CListBoxView* view = iSettingListBox->View();
       
  1185     
       
  1186     TInt index = view->CurrentItemIndex();
       
  1187     TBool selected = view->ItemIsSelected(index);
       
  1188     if (selected)
       
  1189     	{
       
  1190         view->DeselectItem(index);
       
  1191        	}
       
  1192     else
       
  1193     	{
       
  1194     	view->SelectItemL(index);
       
  1195     	}
       
  1196     iSettingListBox->SetCurrentItemIndex(index);
       
  1197     if (!CheckEmailSelection())
       
  1198        	{
       
  1199        	return; 
       
  1200        	}
       
  1201 	TInt ret =  SaveCurrentProfile();
       
  1202 	if (ret != KErrNone)
       
  1203 		{
       
  1204 		CancelCheckboxEvent();
       
  1205 		}
       
  1206 	
       
  1207 }
       
  1208 
       
  1209 
       
  1210 
       
  1211 // -----------------------------------------------------------------------------
       
  1212 // CAspSettingDialog::DoSetCurrentProfileL
       
  1213 //
       
  1214 // -----------------------------------------------------------------------------
       
  1215 //
       
  1216 void CAspSettingDialog::DoSetCurrentProfileL(TInt aProfileId)
       
  1217 	{
       
  1218     FLOG( _L("CAspSettingDialog::DoSetCurrentProfileL START") );
       
  1219     
       
  1220     iCurrentProfileId = KErrNotFound;
       
  1221     iCurrentProfileName = KNullDesC;
       
  1222     iContentList->RemoveAllTasks();
       
  1223     iProfileList->ReadAllProfilesL(CAspProfileList::ENoMandatoryCheck);
       
  1224 	iProfileList->Sort();
       
  1225 	
       
  1226 	if (iProfileList->Count() == 0)
       
  1227 		{
       
  1228 		return;
       
  1229 		}
       
  1230         
       
  1231     if (aProfileId == KErrNotFound)
       
  1232     	{
       
  1233     	FLOG( _L("CAspSettingDialog::DoSetCurrentProfileL END") );
       
  1234     	User::Leave(KErrNotFound);
       
  1235     	}
       
  1236     	
       
  1237     TInt index = iProfileList->ListIndex(aProfileId);
       
  1238     if (index == KErrNotFound)
       
  1239     	{
       
  1240     	FLOG( _L("### unknown profile (id=%d) ###"), aProfileId );
       
  1241     	FLOG( _L("CAspSettingDialog::DoSetCurrentProfileL END") );
       
  1242     	
       
  1243     	User::Leave(KErrNotFound);
       
  1244     	}
       
  1245     
       
  1246     TAspParam param(iApplicationId, iSyncSession);
       
  1247 	CAspProfile* profile = CAspProfile::NewLC(param);
       
  1248 	
       
  1249 	//if profile already locked ,open as read only
       
  1250 	if (IsProfileLockedL(aProfileId))
       
  1251 	{
       
  1252 	   profile->OpenL(aProfileId, CAspProfile::EOpenRead, CAspProfile::EAllProperties);
       
  1253     
       
  1254 	}
       
  1255 	else
       
  1256 	{
       
  1257 	   profile->OpenL(aProfileId, CAspProfile::EOpenReadWrite, CAspProfile::EAllProperties);
       
  1258 	}
       
  1259 	
       
  1260     iContentList->SetProfile(profile);
       
  1261     
       
  1262     // read sync tasks from database into content list
       
  1263     iContentList->InitAllTasksL();
       
  1264     if (IsProfileLockedL(aProfileId))
       
  1265     {
       
  1266     	iContentList->UpdateLocalDatabaseL();
       
  1267     }
       
  1268     
       
  1269     if (!iContentList->CheckTaskDirectionsL())
       
  1270        	{
       
  1271         if (!iSettingEnforcement)
       
  1272            	{
       
  1273            	iContentList->ModifyTaskDirectionsL(ESyncDirectionTwoWay);
       
  1274     	   	}
       
  1275     	   	
       
  1276     	FLOG( _L("### sync direction conflict ###") );
       
  1277     	}
       
  1278     
       
  1279     //check if mailbox exists
       
  1280     CDesCArray* localDataStores = new (ELeave) CDesCArrayFlat(KDefaultArraySize);
       
  1281 	CleanupStack::PushL(localDataStores);
       
  1282 	iContentList->GetLocalDatabaseList(KUidNSmlAdapterEMail.iUid, localDataStores);
       
  1283 
       
  1284     TInt num = profile->ProtocolVersion();
       
  1285     if (num == EAspProtocol_1_1 || localDataStores->Count() == 0)
       
  1286     	{
       
  1287     	TInt index = iContentList->FindTaskIdForProvider( KUidNSmlAdapterEMail.iUid);
       
  1288 		if (index != KErrNotFound)
       
  1289 			{
       
  1290 			TAspTaskItem emailItem = iContentList->ReadTaskItemL(profile->Profile(), index);
       
  1291 			if (emailItem.iEnabled)
       
  1292 				{
       
  1293 		    	iContentList->ModifyTaskIncludedL(KUidNSmlAdapterEMail.iUid, EFalse, KNullDesC);
       
  1294 				}
       
  1295 			}
       
  1296     	}
       
  1297 	CleanupStack::PopAndDestroy(localDataStores);
       
  1298 	
       
  1299     iContentList->SetProfile(NULL);
       
  1300     
       
  1301     iCurrentProfileId = aProfileId;
       
  1302     
       
  1303     profile->GetName(iCurrentProfileName);
       
  1304   	if (TUtil::IsEmpty(iCurrentProfileName))
       
  1305 		{
       
  1306 		CAspResHandler::ReadL(iCurrentProfileName, R_ASP_UNNAMED_SET);
       
  1307 		}
       
  1308 
       
  1309   
       
  1310     CleanupStack::PopAndDestroy(profile);
       
  1311     
       
  1312     FLOG( _L("CAspSettingDialog::DoSetCurrentProfileL END") );
       
  1313 	}
       
  1314 	
       
  1315 
       
  1316 // -----------------------------------------------------------------------------
       
  1317 // CAspSettingDialog::SetCurrentProfile
       
  1318 //
       
  1319 // -----------------------------------------------------------------------------
       
  1320 //
       
  1321 void CAspSettingDialog::SetCurrentProfile(TInt aProfileId)
       
  1322 	{
       
  1323 	if (iContentList->IsLocked())
       
  1324 		{
       
  1325 		return; // iContentList used by CAspProfileDialog
       
  1326 		}
       
  1327 		
       
  1328 	TInt err = KErrNone;
       
  1329 	TInt oldCurrentProfileId = iCurrentProfileId;
       
  1330 	
       
  1331 	TRAP(err, DoSetCurrentProfileL(aProfileId));
       
  1332 	
       
  1333 	iContentList->SetProfile(NULL);
       
  1334 	
       
  1335     if (err != KErrNone)
       
  1336     	{
       
  1337         iCurrentProfileId = KErrNotFound;
       
  1338         iCurrentProfileName = KNullDesC;
       
  1339         iContentList->RemoveAllTasks();
       
  1340        	}
       
  1341        	
       
  1342     if (err != KErrNone && oldCurrentProfileId != KErrNotFound)
       
  1343     	{
       
  1344    		// some error - try restoring old current profile
       
  1345    		TRAP(err, DoSetCurrentProfileL(oldCurrentProfileId));
       
  1346    		
       
  1347    		iContentList->SetProfile(NULL);
       
  1348 	
       
  1349 	    if (err != KErrNone)
       
  1350     	    {
       
  1351             iCurrentProfileId = KErrNotFound;
       
  1352     	    iCurrentProfileName = KNullDesC;
       
  1353             iContentList->RemoveAllTasks();
       
  1354     	    }
       
  1355     	}
       
  1356 	}
       
  1357 
       
  1358 
       
  1359 // -----------------------------------------------------------------------------
       
  1360 // CAspSettingDialog::SetCurrentProfile
       
  1361 //
       
  1362 // -----------------------------------------------------------------------------
       
  1363 //
       
  1364 void CAspSettingDialog::SetCurrentProfileL()
       
  1365 	{
       
  1366 
       
  1367 #ifdef RD_DSUI_TIMEDSYNC //display profiles in alphabetic order.
       
  1368 	TInt index = 0;
       
  1369 	if (!iProfileList->Count())
       
  1370 		{
       
  1371 		index = KErrNotFound;
       
  1372 		}
       
  1373 
       
  1374 #else
       
  1375 	TInt index = iProfileList->FindLastSyncedProfileIndexL();
       
  1376 
       
  1377 #endif
       
  1378 	if (index != KErrNotFound)
       
  1379 		{
       
  1380 		TAspProfileItem& item = iProfileList->Item(index);
       
  1381 		SetCurrentProfile(item.iProfileId);
       
  1382 		}
       
  1383 	else
       
  1384 		{
       
  1385 		SetCurrentProfile(KErrNotFound);
       
  1386 		}
       
  1387 	}
       
  1388 
       
  1389 
       
  1390 // -----------------------------------------------------------------------------
       
  1391 // CAspSettingDialog::CurrentProfileL
       
  1392 //
       
  1393 // -----------------------------------------------------------------------------
       
  1394 //
       
  1395 TAspProfileItem& CAspSettingDialog::CurrentProfileL()
       
  1396 	{
       
  1397 	TInt index = iProfileList->ListIndex(iCurrentProfileId);
       
  1398 	if (index == KErrNotFound)
       
  1399 		{
       
  1400 		User::Leave(KErrNotFound);
       
  1401 		}
       
  1402 		
       
  1403 	return iProfileList->Item(index);
       
  1404 	}
       
  1405 
       
  1406 
       
  1407 // -----------------------------------------------------------------------------
       
  1408 // CAspSettingDialog::HasCurrentProfile
       
  1409 //
       
  1410 // -----------------------------------------------------------------------------
       
  1411 //
       
  1412 TBool CAspSettingDialog::HasCurrentProfile()
       
  1413 	{
       
  1414 	TInt ret = ETrue;
       
  1415 	
       
  1416 	if (iCurrentProfileId == KErrNotFound)
       
  1417 		{
       
  1418 		ret = EFalse;
       
  1419 		}
       
  1420 		
       
  1421 	if (iProfileList->Count() == 0)
       
  1422 		{
       
  1423 		ret = EFalse;
       
  1424 		}
       
  1425 		
       
  1426 	if (ret)
       
  1427 		{
       
  1428 	    TInt index = iProfileList->ListIndex(iCurrentProfileId);	
       
  1429 	    
       
  1430 	    __ASSERT_DEBUG(index != KErrNotFound, TUtil::Panic(KErrGeneral));
       
  1431 		}
       
  1432 	
       
  1433 	return ret;
       
  1434 	}
       
  1435 
       
  1436 
       
  1437 // -----------------------------------------------------------------------------
       
  1438 // CAspSettingDialog::IsCurrentProfile
       
  1439 //
       
  1440 // -----------------------------------------------------------------------------
       
  1441 //
       
  1442 TBool CAspSettingDialog::IsCurrentProfile(TInt aProfileId)
       
  1443 	{
       
  1444 	if (aProfileId != KErrNotFound && aProfileId == iCurrentProfileId)
       
  1445 		{
       
  1446 		return ETrue;
       
  1447 		}
       
  1448 		
       
  1449 	return EFalse;
       
  1450 	}
       
  1451 
       
  1452 
       
  1453 // -----------------------------------------------------------------------------
       
  1454 // CAspSettingDialog::DoSaveCurrentProfileL
       
  1455 //
       
  1456 // -----------------------------------------------------------------------------
       
  1457 //
       
  1458 void CAspSettingDialog::DoSaveCurrentProfileL()
       
  1459 	{
       
  1460 	if (iSettingEnforcement)
       
  1461 		{
       
  1462 		return;  // read-only profile
       
  1463 		}
       
  1464 
       
  1465 	if (!HasCurrentProfile())
       
  1466 		{
       
  1467 		User::Leave(KErrNotFound);
       
  1468 		}
       
  1469 
       
  1470     TAspParam param(iApplicationId, iSyncSession);
       
  1471 	CAspProfile* profile = CAspProfile::NewLC(param);
       
  1472     profile->OpenL(iCurrentProfileId, CAspProfile::EOpenReadWrite, 
       
  1473                                       CAspProfile::EAllProperties);
       
  1474 
       
  1475 	iContentList->SetProfile(profile);
       
  1476 	// store selected sync tasks into database
       
  1477 	iContentList->IncludeTasks(iSettingListBox->SelectionIndexes());
       
  1478 	iContentList->SetProfile(NULL);
       
  1479 	
       
  1480 	CleanupStack::PopAndDestroy(profile);
       
  1481 	}
       
  1482 
       
  1483 
       
  1484 // -----------------------------------------------------------------------------
       
  1485 // CAspSettingDialog::SaveCurrentProfile
       
  1486 //
       
  1487 // -----------------------------------------------------------------------------
       
  1488 //
       
  1489 TInt CAspSettingDialog::SaveCurrentProfile()
       
  1490 	{
       
  1491 	TRAPD(err, DoSaveCurrentProfileL());
       
  1492 	
       
  1493 	iContentList->SetProfile(NULL);
       
  1494 	
       
  1495     if (err == KErrLocked)
       
  1496    		{
       
  1497         TRAP_IGNORE( TDialogUtil::ShowErrorNoteL(R_ASP_LOCKED_PROFILE) );
       
  1498         }
       
  1499 
       
  1500 	if (err != KErrNone)
       
  1501 		{
       
  1502 		FLOG( _L("### CAspSettingDialog::SaveCurrentProfile: err=%d ###"), err );
       
  1503     	}
       
  1504     	
       
  1505     return err;
       
  1506 	}
       
  1507 
       
  1508 
       
  1509 // -----------------------------------------------------------------------------
       
  1510 // CAspSettingDialog::EditProfileL
       
  1511 //
       
  1512 // -----------------------------------------------------------------------------
       
  1513 //
       
  1514 void CAspSettingDialog::EditProfileL(TInt aEditMode ,TInt aFocus)
       
  1515 	{
       
  1516 	if (iSettingEnforcement)
       
  1517 		{
       
  1518 		aEditMode = EDialogModeSettingEnforcement;
       
  1519 		}
       
  1520     
       
  1521     if (IsProfileLockedL(iCurrentProfileId))
       
  1522 		{
       
  1523 		TDialogUtil::ShowErrorNoteL(R_ASP_LOCKED_PROFILE);
       
  1524 		return;
       
  1525 		}
       
  1526 	TRAPD(err, DoEditProfileL(aEditMode ,aFocus));
       
  1527     iContentList->SetProfile(NULL);
       
  1528 	User::LeaveIfError(err);
       
  1529 
       
  1530 #ifdef RD_DSUI_TIMEDSYNC 
       
  1531 	iUpdateTabGroup = ETrue;
       
  1532 	UpdateTabsL();
       
  1533 #endif
       
  1534 
       
  1535 	}
       
  1536 
       
  1537 
       
  1538 // -----------------------------------------------------------------------------
       
  1539 // CAspSettingDialog::DoEditProfileL
       
  1540 //
       
  1541 // -----------------------------------------------------------------------------
       
  1542 //
       
  1543 void CAspSettingDialog::DoEditProfileL(TInt aEditMode, TInt aFocus)
       
  1544 	{
       
  1545 	if (!HasCurrentProfile())
       
  1546 		{
       
  1547 		return;
       
  1548 		}
       
  1549 		
       
  1550     TAspParam param(iApplicationId, iSyncSession);
       
  1551 	CAspProfile* profile = CAspProfile::NewLC(param);
       
  1552     
       
  1553     iContentList->SetProfile(profile);
       
  1554     
       
  1555     if (aEditMode == EDialogModeEdit || aEditMode == EDialogModeEditMandatory)
       
  1556     	{
       
  1557     	profile->OpenL(iCurrentProfileId, CAspProfile::EOpenReadWrite,
       
  1558                                           CAspProfile::EAllProperties);
       
  1559                                           
       
  1560     	}
       
  1561     else
       
  1562     	{
       
  1563     	profile->OpenL(iCurrentProfileId, CAspProfile::EOpenRead,
       
  1564                                           CAspProfile::EAllProperties);
       
  1565     	}
       
  1566 
       
  1567 		
       
  1568 	TAspParam param2(iApplicationId, iSyncSession);
       
  1569 	param2.iProfile = profile;
       
  1570 	param2.iMode = aEditMode;
       
  1571     param2.iContentList = iContentList;
       
  1572     param2.iProfileList = iProfileList;  // needed for unique server id check
       
  1573     param2.iDataProviderId = aFocus;
       
  1574  
       
  1575 #ifdef RD_DSUI_TIMEDSYNC 
       
  1576 	CAspSettingViewDialog::ShowDialogL(param2);
       
  1577 #else
       
  1578 	CAspProfileDialog::ShowDialogL(param2);
       
  1579 #endif
       
  1580 
       
  1581 	iContentList->SetProfile(NULL);
       
  1582 	CleanupStack::PopAndDestroy(profile);
       
  1583 	}
       
  1584 
       
  1585 
       
  1586 // -----------------------------------------------------------------------------
       
  1587 // CAspSettingDialog::CheckMandatoryDataL
       
  1588 //
       
  1589 // -----------------------------------------------------------------------------
       
  1590 //
       
  1591 TInt CAspSettingDialog::CheckMandatoryDataL()
       
  1592 	{
       
  1593 	TInt ret = EMandatoryOk;
       
  1594 	
       
  1595 	TRAPD(err, ret = DoCheckMandatoryDataL());
       
  1596 	
       
  1597 	User::LeaveIfError(err);
       
  1598 		
       
  1599 	return ret;
       
  1600 	}
       
  1601 
       
  1602 
       
  1603 // -----------------------------------------------------------------------------
       
  1604 // CAspSettingDialog::DoCheckMandatoryDataL
       
  1605 //
       
  1606 // -----------------------------------------------------------------------------
       
  1607 //
       
  1608 TInt CAspSettingDialog::DoCheckMandatoryDataL()
       
  1609 	{
       
  1610 	if (!HasCurrentProfile())
       
  1611 		{
       
  1612 		User::Leave(KErrNotFound);
       
  1613 		}
       
  1614 		
       
  1615     TAspParam param(iApplicationId, iSyncSession);
       
  1616 	CAspProfile* profile = CAspProfile::NewLC(param);
       
  1617     profile->OpenL(iCurrentProfileId, CAspProfile::EOpenRead,
       
  1618                                       CAspProfile::EAllProperties);
       
  1619     
       
  1620     
       
  1621     TInt mandatoryConnectionData = CAspProfile::CheckMandatoryConnData(profile);
       
  1622     CleanupStack::PopAndDestroy(profile);
       
  1623 	
       
  1624 	TInt contentCount = 0;
       
  1625 	TInt mandatoryContentData = iContentList->CheckMandatoryDataL(contentCount);
       
  1626 	
       
  1627 	if (mandatoryConnectionData != EMandatoryOk)
       
  1628 		{
       
  1629 		return mandatoryConnectionData;
       
  1630 		}
       
  1631 		
       
  1632 	return mandatoryContentData;
       
  1633 	}
       
  1634 
       
  1635 
       
  1636 // -----------------------------------------------------------------------------
       
  1637 // CAspSettingDialog::DeleteProfileL
       
  1638 //
       
  1639 // -----------------------------------------------------------------------------
       
  1640 //
       
  1641 void CAspSettingDialog::DeleteProfileL()
       
  1642     {
       
  1643 
       
  1644 #ifdef RD_DSUI_TIMEDSYNC 
       
  1645 	 TAspParam param(iApplicationId, iSyncSession);
       
  1646 	 CAspProfile* profile = CAspProfile::NewLC(param);
       
  1647      TRAPD(err,profile->OpenL(iCurrentProfileId, CAspProfile::EOpenReadWrite,
       
  1648                                       CAspProfile::EAllProperties));
       
  1649 
       
  1650 	 if (err == KErrLocked)
       
  1651    		{
       
  1652         TDialogUtil::ShowErrorNoteL(R_ASP_LOCKED_PROFILE);
       
  1653 		CleanupStack::PopAndDestroy(profile);
       
  1654 		return;
       
  1655 	 	}
       
  1656 	 CAspSchedule* schedule = CAspSchedule::NewLC();
       
  1657 	
       
  1658 	 TInt profileId = schedule->ProfileId();
       
  1659 	 if (profileId == iCurrentProfileId && schedule->IsAutoSyncEnabled())
       
  1660 	 	{
       
  1661 		HBufC* hBuf = CAspResHandler::ReadLC(R_ASP_DS_CONF_QUERY_DELETE_AUTO_SYNC_PROFILE);
       
  1662 		if (!TDialogUtil::ShowConfirmationQueryL(hBuf->Des()))
       
  1663 			{
       
  1664 			CleanupStack::PopAndDestroy(hBuf);
       
  1665 			CleanupStack::PopAndDestroy(schedule);
       
  1666 	        CleanupStack::PopAndDestroy(profile);
       
  1667 			return;
       
  1668 			}
       
  1669 		CleanupStack::PopAndDestroy(hBuf);
       
  1670 		schedule->SetProfileId(KErrNotFound);
       
  1671 		schedule->UpdateSyncScheduleL();
       
  1672 		schedule->SaveL();
       
  1673 		}
       
  1674 	 else
       
  1675 	 	{
       
  1676 		TBuf<KBufSize> profileName;
       
  1677 	 	profile->GetName(profileName);
       
  1678 	 	HBufC* hBuf1 = CAspResHandler::ReadLC(R_ASP_QUERY_COMMON_CONF_DELETE, profileName);
       
  1679 
       
  1680 	 	if (!TDialogUtil::ShowConfirmationQueryL(hBuf1->Des()))
       
  1681 		    {
       
  1682 			CleanupStack::PopAndDestroy(hBuf1);
       
  1683 			CleanupStack::PopAndDestroy(schedule);
       
  1684 			CleanupStack::PopAndDestroy(profile);
       
  1685 			return;
       
  1686 	 		}
       
  1687 		CleanupStack::PopAndDestroy(hBuf1);
       
  1688 	 	}
       
  1689 	CleanupStack::PopAndDestroy(schedule);
       
  1690 	CleanupStack::PopAndDestroy(profile);
       
  1691 	if (!IsSyncOnGoingL(iCurrentProfileId))
       
  1692 		{
       
  1693 		TRAPD (err1,iSyncSession->DeleteProfileL(iCurrentProfileId));
       
  1694 		
       
  1695 		if (err1 == KErrLocked)
       
  1696    			{
       
  1697        		TDialogUtil::ShowErrorNoteL(R_ASP_LOCKED_PROFILE);
       
  1698        		}
       
  1699     	User::LeaveIfError(err);
       
  1700 		}
       
  1701 	iUpdateTabGroup = ETrue;	
       
  1702 	SetPreviousProfileL();
       
  1703 	
       
  1704 	
       
  1705 #else
       
  1706 
       
  1707     TAspFilterInfo info;
       
  1708     info.iFilterType = TAspFilterInfo::EIncludeDeletableProfile;
       
  1709     CAspProfileList* filteredList = iProfileList->FilteredListL(info);
       
  1710     CleanupStack::PushL(filteredList);
       
  1711     
       
  1712 	TInt count = filteredList->Count();
       
  1713 	TInt err = KErrNone;
       
  1714 
       
  1715 	if (count == 1)
       
  1716 		{
       
  1717 		TAspProfileItem& profile = filteredList->Item(0);
       
  1718 
       
  1719 		HBufC* hBuf = CAspResHandler::ReadLC(R_ASP_CONFIRM_DELETE, profile.iProfileName);
       
  1720 	    if (TDialogUtil::ShowConfirmationQueryL(hBuf->Des()))
       
  1721 		    {
       
  1722 		    if (!IsSyncOnGoingL(profile.iProfileId))
       
  1723 		    	{
       
  1724 		    	TRAP(err, iSyncSession->DeleteProfileL(profile.iProfileId));
       
  1725 		    	}
       
  1726 		    }
       
  1727    		
       
  1728    		CleanupStack::PopAndDestroy(hBuf);
       
  1729     	}
       
  1730 	
       
  1731 	else if (count > 0)
       
  1732 		{
       
  1733 		TInt profileId = KErrNotFound;
       
  1734 	    if (TDialogUtil::ShowProfileQueryL(filteredList, profileId,
       
  1735 	                                       R_ASP_QUERY_TITLE_DELETE_PROFILE))
       
  1736 		    {
       
  1737 		    if (!IsSyncOnGoingL(profileId))
       
  1738 		    	{
       
  1739 		    	TRAP(err, iSyncSession->DeleteProfileL(profileId));
       
  1740 		    	}
       
  1741 		    }
       
  1742 		}
       
  1743 
       
  1744 	if (err == KErrLocked)
       
  1745    		{
       
  1746         TDialogUtil::ShowErrorNoteL(R_ASP_LOCKED_PROFILE);
       
  1747         }
       
  1748     User::LeaveIfError(err);
       
  1749     
       
  1750 	CleanupStack::PopAndDestroy(filteredList);
       
  1751 
       
  1752 #endif
       
  1753     }
       
  1754 
       
  1755 
       
  1756 // -----------------------------------------------------------------------------
       
  1757 // CAspSettingDialog::ShowLogDialogL
       
  1758 //
       
  1759 // -----------------------------------------------------------------------------
       
  1760 //
       
  1761 void CAspSettingDialog::ShowLogDialogL()
       
  1762     {
       
  1763     
       
  1764 	TAspParam param(iApplicationId, iSyncSession);
       
  1765 	TAspProfileItem& profile = CurrentProfileL();
       
  1766 	param.iProfileId = profile.iProfileId;
       
  1767 
       
  1768 #ifdef RD_DSUI_TIMEDSYNC 
       
  1769    	
       
  1770 	CAspSchedule* schedule = CAspSchedule::NewLC();
       
  1771 	if (iCurrentProfileId == schedule->ProfileId())
       
  1772 		{
       
  1773 		TInt asProfileId = schedule->AutoSyncProfileId();
       
  1774 		CAspProfile* asProfile = CAspProfile::NewLC(param);
       
  1775 		asProfile->OpenL(asProfileId, CAspProfile::EOpenRead, CAspProfile::EAllProperties);
       
  1776 
       
  1777 		/*if (asProfile->LastSync() > profile.iLastSync)
       
  1778 			{
       
  1779 			param.iProfileId = asProfileId;
       
  1780 			}*/	
       
  1781 		TTime now;
       
  1782 		now.HomeTime();
       
  1783 		if (profile.iLastSync == 0)
       
  1784 			{
       
  1785 			param.iProfileId = asProfileId;
       
  1786 			}
       
  1787 		else if ((asProfile->LastSync()< now && profile.iLastSync < now)
       
  1788 								|| (asProfile->LastSync() > now && profile.iLastSync > now))
       
  1789 			{
       
  1790 			if (asProfile->LastSync() > profile.iLastSync)
       
  1791 				{
       
  1792 				param.iProfileId = asProfileId;
       
  1793 				}
       
  1794 			}
       
  1795 		else if	((asProfile->LastSync()< now && profile.iLastSync > now))
       
  1796 			{
       
  1797 			param.iProfileId = asProfileId;
       
  1798 			}
       
  1799 		CleanupStack::PopAndDestroy(asProfile);
       
  1800 		}
       
  1801 	
       
  1802 	CleanupStack::PopAndDestroy(schedule);
       
  1803 		
       
  1804 #endif   
       
  1805 	
       
  1806 
       
  1807     CAspLogDialog* dialog = CAspLogDialog::NewL(param);
       
  1808     CleanupStack::PushL(dialog);
       
  1809         
       
  1810     dialog->ShowDialogL();
       
  1811         
       
  1812     CleanupStack::PopAndDestroy(dialog);
       
  1813     }
       
  1814 
       
  1815 
       
  1816 // -----------------------------------------------------------------------------
       
  1817 // CAspSettingDialog::ShowAutoSyncDialogL
       
  1818 //
       
  1819 // -----------------------------------------------------------------------------
       
  1820 //
       
  1821 void CAspSettingDialog::ShowAutoSyncDialogL()
       
  1822     {
       
  1823     
       
  1824     CAspSchedule* schedule = CAspSchedule::NewLC();
       
  1825 	if (schedule->IsAutoSyncEnabled())
       
  1826 		{
       
  1827 		TInt profileId = schedule->ProfileId();
       
  1828 		if(profileId != iCurrentProfileId && profileId != KErrNotFound)
       
  1829 			{
       
  1830 			if(!TDialogUtil::ShowConfirmationQueryL(R_ASP_QUERY_AUTO_SYNC_ON))
       
  1831 				{
       
  1832 				CleanupStack::PopAndDestroy(schedule);
       
  1833 				return ;
       
  1834 				}
       
  1835 			}
       
  1836 		}
       
  1837     CleanupStack::PopAndDestroy(schedule);
       
  1838 	
       
  1839 	TAspParam param(iApplicationId, iSyncSession);
       
  1840     param.iProfileList = iProfileList;
       
  1841 	param.iProfile = NULL;
       
  1842 	param.iContentList = iContentList;
       
  1843  	CAspScheduleDialog::ShowDialogL(param);
       
  1844 
       
  1845 #ifdef RD_DSUI_TIMEDSYNC 
       
  1846 	UpdateTabsL();
       
  1847 #endif
       
  1848 	
       
  1849     }
       
  1850 
       
  1851 
       
  1852 // -----------------------------------------------------------------------------
       
  1853 // CAspSettingDialog::ChangeProfileL
       
  1854 //
       
  1855 // -----------------------------------------------------------------------------
       
  1856 //
       
  1857 void CAspSettingDialog::ChangeProfileL()
       
  1858     {
       
  1859     if (iProfileList->Count() == 0)
       
  1860     	{
       
  1861     	return;
       
  1862     	}
       
  1863     	
       
  1864 	TInt profileId = KErrNotFound;
       
  1865 	if (TDialogUtil::ShowProfileQueryL(iProfileList, profileId, 
       
  1866 	                                   R_ASP_QUERY_TITLE_CHANGE_PROFILE))
       
  1867 		{
       
  1868 		if (profileId == iCurrentProfileId)
       
  1869 			{
       
  1870 			return;
       
  1871 			}
       
  1872 			
       
  1873 		SetCurrentProfile(profileId);
       
  1874 		//ShowCurrentProfileInfo();
       
  1875 		UpdateListBoxL();
       
  1876 		
       
  1877 #ifdef RD_DSUI_TIMEDSYNC //RD_DSUI_NO_TIMEDSYNC
       
  1878 
       
  1879 		UpdateTabsL();
       
  1880 #else
       
  1881 		UpdateNavipaneL(iCurrentProfileName);
       
  1882 #endif
       
  1883 		}
       
  1884     }
       
  1885 
       
  1886 
       
  1887 // -----------------------------------------------------------------------------
       
  1888 // CAspSettingDialog::CopyFromServerL
       
  1889 //
       
  1890 // -----------------------------------------------------------------------------
       
  1891 //
       
  1892 void CAspSettingDialog::CopyFromServerL()
       
  1893 	{
       
  1894 	if (!TDialogUtil::ShowConfirmationQueryL(R_ASP_COPY_FROM_SERVER))
       
  1895 		{
       
  1896 		return;
       
  1897 		}
       
  1898 
       
  1899 	TRAPD(err, DoSyncProfileL(ESyncDirectionRefreshFromServer));
       
  1900 	
       
  1901 	if (err == KErrLocked)
       
  1902 		{
       
  1903 		TDialogUtil::ShowErrorNoteL(R_ASP_LOCKED_PROFILE);
       
  1904 		}
       
  1905 	User::LeaveIfError(err);
       
  1906 	}
       
  1907 
       
  1908 
       
  1909 // -----------------------------------------------------------------------------
       
  1910 // CAspSettingDialog::SyncProfileL
       
  1911 //
       
  1912 // -----------------------------------------------------------------------------
       
  1913 //
       
  1914 void CAspSettingDialog::SyncProfileL()
       
  1915 	{
       
  1916 		
       
  1917 	if (IsProfileLockedL(iCurrentProfileId))
       
  1918 		{
       
  1919 		TDialogUtil::ShowErrorNoteL(R_ASP_LOCKED_PROFILE);
       
  1920 		return;
       
  1921 		}
       
  1922 	
       
  1923 	TRAPD(err, DoSyncProfileL(KErrNotFound));
       
  1924 	User::LeaveIfError(err);
       
  1925 	}
       
  1926 
       
  1927 
       
  1928 // -----------------------------------------------------------------------------
       
  1929 // CAspSettingDialog::DoSyncProfileL
       
  1930 //
       
  1931 // -----------------------------------------------------------------------------
       
  1932 //
       
  1933 void CAspSettingDialog::DoSyncProfileL(TInt aSyncType)
       
  1934 	{
       
  1935     __ASSERT_ALWAYS(iSyncSession, TUtil::Panic(KErrGeneral));
       
  1936     	
       
  1937 	if (iProfileList->Count() == 0)
       
  1938 		{
       
  1939 	    if (TDialogUtil::ShowConfirmationQueryL(R_ASP_QUERY_NO_PROFILES))
       
  1940 		    {
       
  1941 		    CreateProfileL();
       
  1942 		    }
       
  1943 		    
       
  1944 		return;
       
  1945     	}
       
  1946     
       
  1947     //check PS key
       
  1948     TInt keyVal = 0;//EDataSyncNotRunning
       
  1949     TInt err = RProperty::Get( KPSUidDataSynchronizationInternalKeys,
       
  1950                                  KDataSyncStatus,
       
  1951                                  keyVal );
       
  1952     if(err == KErrNone && keyVal)
       
  1953     	{
       
  1954     	TDialogUtil::ShowInformationNoteL(R_ASP_SYNC_ALREADY_RUNNING);
       
  1955 		return;
       
  1956     	}
       
  1957     
       
  1958 	
       
  1959 	if (CAspProfile::OtherSyncRunning(iSyncSession))
       
  1960 		{
       
  1961 		TDialogUtil::ShowInformationNoteL(R_ASP_SYNC_ALREADY_RUNNING);
       
  1962 		return;
       
  1963 		}
       
  1964 
       
  1965      // check that valid current profile exists
       
  1966     TInt mandatoryCheck = CheckMandatoryDataL();
       
  1967     
       
  1968  	if (mandatoryCheck == EMandatoryNoContent)
       
  1969 		{
       
  1970 		TDialogUtil::ShowErrorNoteL(R_ASP_ERR_NOCONTENT);
       
  1971 		return;
       
  1972         }
       
  1973 	else if (mandatoryCheck != EMandatoryOk)
       
  1974 		{
       
  1975         if (iSettingEnforcement)
       
  1976     	    {
       
  1977     	    TDialogUtil::ShowInformationNoteL(R_ASP_NOTE_TARM_MANDATORY_MISSING);
       
  1978     	    }    	
       
  1979 		else if (TDialogUtil::ShowConfirmationQueryL(R_ASP_QUERY_MANDATORY_MISSING))
       
  1980 			{
       
  1981 			TInt contentCount = 0;
       
  1982 			TInt incompleteContent = KErrNotFound;
       
  1983 			TInt taskIndex = KErrNotFound;
       
  1984 			if (iContentList->CheckMandatoryDataL(contentCount))
       
  1985 				{
       
  1986 				TInt count = iContentList->ProviderCount();
       
  1987 				for (TInt i=0; i<count; i++)
       
  1988 					{
       
  1989 					//data provider ids are sorted before task list creation ,so provider id has to be used
       
  1990 					//to get the correct position of item
       
  1991 					TAspProviderItem& providerItem = iContentList->ProviderItem(i);
       
  1992 					taskIndex = iContentList->FindTaskIndexForProvider(providerItem.iDataProviderId);
       
  1993 					if (taskIndex == KErrNotFound)
       
  1994 						{
       
  1995 						//task is not created
       
  1996 						continue;	
       
  1997 						}
       
  1998 					TAspTaskItem& task = iContentList->TaskItem(taskIndex);
       
  1999 					if (!task.iEnabled)
       
  2000 						{
       
  2001 						continue; // task not part of sync - no need to check remote data base
       
  2002 						}
       
  2003 					if (!task.iRemoteDatabaseDefined)
       
  2004 						{
       
  2005 						incompleteContent = task.iDataProviderId;
       
  2006 						break;
       
  2007 						}
       
  2008 					}
       
  2009 				}
       
  2010 			EditProfileL(EDialogModeEditMandatory ,incompleteContent);
       
  2011 			}
       
  2012 			
       
  2013 		return;
       
  2014         }
       
  2015 
       
  2016 
       
  2017 	if (!iSyncHandler)
       
  2018 		{
       
  2019     	TAspParam param(iApplicationId, NULL);
       
  2020 		iSyncHandler = CAspSyncHandler::NewL(param);
       
  2021 		}
       
  2022 	else
       
  2023 		{
       
  2024 		if (SyncRunning())
       
  2025 			{
       
  2026 			TDialogUtil::ShowInformationNoteL(R_ASP_SYNC_ALREADY_RUNNING);
       
  2027     		return;
       
  2028 			}
       
  2029 		}
       
  2030     	
       
  2031     iSyncHandler->SetObserver(this);
       
  2032 
       
  2033    	TAspSyncParam param(iApplicationId);
       
  2034 	param.iProfileId = iCurrentProfileId;
       
  2035 	if (aSyncType == ESyncDirectionRefreshFromServer)
       
  2036 		{
       
  2037 		param.iSyncDirection = aSyncType;
       
  2038 		}
       
  2039 
       
  2040 #ifdef RD_DSUI_TIMEDSYNC 
       
  2041 	DeleteAutoSyncHistory();
       
  2042 #endif
       
  2043 
       
  2044 	iSyncHandler->SynchronizeL(param);
       
  2045 	}
       
  2046 
       
  2047 // -----------------------------------------------------------------------------
       
  2048 // CAspSettingDialog::DeleteAutoSyncHistory
       
  2049 //
       
  2050 // -----------------------------------------------------------------------------
       
  2051 //
       
  2052 void CAspSettingDialog::DeleteAutoSyncHistory()
       
  2053 	{
       
  2054 	TAspParam param(iApplicationId, iSyncSession);
       
  2055 	CAspSchedule* schedule = CAspSchedule::NewLC();
       
  2056 	if (schedule->IsAutoSyncEnabled() && iCurrentProfileId == schedule->ProfileId())
       
  2057 		{
       
  2058 		TInt asProfileId = schedule->AutoSyncProfileId();
       
  2059 		CAspProfile* asProfile = CAspProfile::NewLC(param);
       
  2060 		asProfile->OpenL(asProfileId, CAspProfile::EOpenReadWrite, CAspProfile::EAllProperties);
       
  2061 		asProfile->DeleteHistory();
       
  2062 		CleanupStack::PopAndDestroy(asProfile);
       
  2063 		}
       
  2064 	CleanupStack::PopAndDestroy(schedule);
       
  2065 	}
       
  2066 
       
  2067 // -----------------------------------------------------------------------------
       
  2068 // CAspSettingDialog::CreateProfileL
       
  2069 //
       
  2070 // -----------------------------------------------------------------------------
       
  2071 //
       
  2072 void CAspSettingDialog::CreateProfileL()
       
  2073 	{
       
  2074 	TAspParam param(iApplicationId, iSyncSession);
       
  2075 	param.iProfileList = iProfileList;
       
  2076 	
       
  2077 	CAspProfileWizardDialog::ShowDialogL(param);
       
  2078 
       
  2079 #ifdef RD_DSUI_TIMEDSYNC 
       
  2080 	iUpdateTabGroup = ETrue;
       
  2081 #endif
       
  2082 
       
  2083 	if (param.iReturnValue == KErrNone && param.iProfileId != KErrNotFound)
       
  2084 		{
       
  2085 		SetCurrentProfile(param.iProfileId);
       
  2086 		UpdateListBoxL();
       
  2087 #ifdef RD_DSUI_TIMEDSYNC 
       
  2088 	
       
  2089 		UpdateTabsL();
       
  2090 #else
       
  2091 		UpdateNavipaneL(iCurrentProfileName);
       
  2092 #endif
       
  2093 		}
       
  2094 	}
       
  2095 
       
  2096 
       
  2097 // -----------------------------------------------------------------------------
       
  2098 // CAspSettingDialog::IconL
       
  2099 // 
       
  2100 // -----------------------------------------------------------------------------
       
  2101 //
       
  2102 CGulIcon* CAspSettingDialog::IconL(TAknsItemID aId, const TDesC& aFileName, TInt aFileIndex, TInt aFileMaskIndex)
       
  2103 	{
       
  2104     return TDialogUtil::CreateIconL(aId, aFileName, aFileIndex, aFileMaskIndex);
       
  2105 	}
       
  2106 
       
  2107 	
       
  2108 // -----------------------------------------------------------------------------
       
  2109 // CAspSettingDialog::UpdateListBoxL
       
  2110 //	
       
  2111 // -----------------------------------------------------------------------------
       
  2112 //
       
  2113 void CAspSettingDialog::UpdateListBoxL()
       
  2114 	{
       
  2115 	SetCurrentIndex();
       
  2116 	
       
  2117 	CAknDoubleLargeStyleListBox* listBox = ListBox();
       
  2118 	CDesCArray* items = (CDesCArray*) listBox->Model()->ItemTextArray();
       
  2119 	items->Reset();
       
  2120     listBox->ItemDrawer()->ClearAllPropertiesL();
       
  2121    
       
  2122 	TInt count = iContentList->ProviderCount();
       
  2123 
       
  2124 	for (TInt i=0; i<count; i++)
       
  2125 		{
       
  2126 		HBufC* firstLine = NULL;
       
  2127 		HBufC* secondLine = NULL;
       
  2128 				
       
  2129 		TAspProviderItem& providerItem = iContentList->ProviderItem(i);
       
  2130 		
       
  2131 		firstLine = CAspResHandler::GetContentNameLC(
       
  2132 		            providerItem.iDataProviderId, providerItem.iDisplayName);
       
  2133 		
       
  2134 		TInt index = iContentList->FindTaskIndexForProvider(providerItem.iDataProviderId);
       
  2135 		if (providerItem.iDataProviderId == KUidNSmlAdapterEMail.iUid )
       
  2136 		{
       
  2137 		
       
  2138 			if(!providerItem.iHasDefaultDataStore)
       
  2139 			{
       
  2140 			TInt providerListIndex = iContentList->FindProviderIndex(providerItem.iDataProviderId);
       
  2141 			
       
  2142 			CListBoxView* view = iSettingListBox->View();
       
  2143 
       
  2144 			view->DeselectItem(providerListIndex);
       
  2145 			}
       
  2146 		}
       
  2147 		if (index != KErrNotFound)
       
  2148 			{
       
  2149 			TAspTaskItem& task = iContentList->TaskItem(index);
       
  2150 	
       
  2151 		    if (task.iLastSync != 0) // task has been synchronised
       
  2152 			    {
       
  2153 			    secondLine = TUtil::SyncTimeLC(task.iLastSync);
       
  2154 			    }
       
  2155 		    else
       
  2156 			    {
       
  2157 			    secondLine = CAspResHandler::ReadLC(R_ASP_NOT_SYNCED);
       
  2158 			    }
       
  2159 			}
       
  2160 		else
       
  2161 			{
       
  2162 			secondLine = CAspResHandler::ReadLC(R_ASP_NOT_SYNCED);
       
  2163 			}
       
  2164 		
       
  2165 		
       
  2166 		TPtr ptr1 = firstLine->Des();
       
  2167 		AknTextUtils::DisplayTextLanguageSpecificNumberConversion(ptr1);
       
  2168 		TPtr ptr2 = secondLine->Des();
       
  2169         AknTextUtils::DisplayTextLanguageSpecificNumberConversion(ptr2);
       
  2170 
       
  2171 		HBufC* hBuf = NULL;
       
  2172 		hBuf = TDialogUtil::ConstructListBoxItemLC(firstLine->Des(), secondLine->Des(), 0);
       
  2173 
       
  2174 		items->AppendL(hBuf->Des());
       
  2175 		
       
  2176 		CleanupStack::PopAndDestroy(hBuf);
       
  2177 		CleanupStack::PopAndDestroy(secondLine);
       
  2178 		CleanupStack::PopAndDestroy(firstLine);
       
  2179 		}
       
  2180 
       
  2181 	listBox->HandleItemAdditionL();
       
  2182 	
       
  2183 	if (listBox->Model()->NumberOfItems() == 0)
       
  2184 		{
       
  2185 	    iStatusPaneHandler->SetNaviPaneTitle(KNullDesC);
       
  2186 		}
       
  2187 	else
       
  2188 		{
       
  2189 		UpdateContentSelectionL();
       
  2190 		
       
  2191 		TInt current = CurrentIndex();
       
  2192 		if (current != KErrNotFound)
       
  2193 			{
       
  2194 			ListBox()->SetCurrentItemIndexAndDraw(current);
       
  2195 			}
       
  2196 		}
       
  2197 	}
       
  2198 
       
  2199 
       
  2200 // -----------------------------------------------------------------------------
       
  2201 // CAspSettingDialog::UpdateContentSelectionL
       
  2202 //
       
  2203 // -----------------------------------------------------------------------------
       
  2204 //
       
  2205 void CAspSettingDialog::UpdateContentSelectionL()
       
  2206     {
       
  2207     // update selected task check boxes from current profile content list
       
  2208     CListBoxView::CSelectionIndexArray* arrayOfSelectionIndexes = NULL;
       
  2209     arrayOfSelectionIndexes = new (ELeave) CArrayFixFlat<TInt>(KDefaultArraySize);
       
  2210     CleanupStack::PushL(arrayOfSelectionIndexes);
       
  2211 
       
  2212 	if (HasCurrentProfile())
       
  2213 		{
       
  2214 		iContentList->GetIncludedProviders(arrayOfSelectionIndexes);
       
  2215 		}
       
  2216         
       
  2217     iSettingListBox->SetSelectionIndexesL(arrayOfSelectionIndexes);
       
  2218 
       
  2219     CleanupStack::PopAndDestroy(arrayOfSelectionIndexes);
       
  2220     }
       
  2221     
       
  2222 
       
  2223 // -----------------------------------------------------------------------------
       
  2224 // CAspSettingDialog::UpdateNavipaneL
       
  2225 //
       
  2226 // -----------------------------------------------------------------------------
       
  2227 //
       
  2228 void CAspSettingDialog::UpdateNavipaneL(const TDesC& aText)
       
  2229 	{
       
  2230 	if (iCurrentProfileName.Compare(aText) != 0)
       
  2231 		{
       
  2232 		TUtil::StrCopy(iCurrentProfileName, aText);
       
  2233 		}
       
  2234 		
       
  2235 	iStatusPaneHandler->SetNaviPaneTitleL(iCurrentProfileName);
       
  2236 	}
       
  2237 
       
  2238 
       
  2239 // -----------------------------------------------------------------------------
       
  2240 // CAspSettingDialog::HandleSyncEventL (from MAspSyncObserver)
       
  2241 //
       
  2242 // -----------------------------------------------------------------------------
       
  2243 //
       
  2244 void CAspSettingDialog::HandleSyncEventL(TInt /*aError*/, TInt aInfo1)
       
  2245 	{
       
  2246     iDbNotifier->CreateUpdateEventL(aInfo1, KErrNone);
       
  2247 	}
       
  2248 
       
  2249 
       
  2250 // -----------------------------------------------------------------------------
       
  2251 // CAspSettingDialog::HandleDbEventL (from MAspDbEventHandler)
       
  2252 //
       
  2253 // This function updates UI when it receives sync profile database
       
  2254 // events (see AspDbNotifier).
       
  2255 // -----------------------------------------------------------------------------
       
  2256 //
       
  2257 void CAspSettingDialog::HandleDbEventL(TAspDbEvent aEvent)
       
  2258 	{
       
  2259 	FLOG( _L("CAspSettingDialog::HandleDbEventL START") );
       
  2260 
       
  2261     switch (aEvent.iType)
       
  2262 		{
       
  2263 		case CAspDbNotifier::EClose:
       
  2264 			{
       
  2265 			
       
  2266 #ifdef _DEBUG			
       
  2267 			LogDatabaseEvent(aEvent);
       
  2268 #endif		
       
  2269 	
       
  2270 			TDialogUtil::ShowErrorNoteL(R_ASP_LOG_ERR_SERVERERROR);
       
  2271             iAvkonAppUi->ProcessCommandL(EAknCmdExit); //  close sync app
       
  2272 			break;
       
  2273 			}
       
  2274 		
       
  2275 		case CAspDbNotifier::EUpdate:
       
  2276 			{
       
  2277 			iProfileList->ReadProfileL(aEvent.iProfileId);
       
  2278 			iProfileList->Sort();
       
  2279       	    if (IsCurrentProfile(aEvent.iProfileId))
       
  2280             	{
       
  2281             	if (!iContentList->IsLocked())
       
  2282             		{
       
  2283             		SetCurrentProfile(aEvent.iProfileId);
       
  2284                     UpdateListBoxL();
       
  2285 #ifdef RD_DSUI_TIMEDSYNC 
       
  2286 					UpdateTabsL();
       
  2287 #else
       
  2288                     UpdateNavipaneL(iCurrentProfileName);
       
  2289 #endif               
       
  2290             		}
       
  2291             	}
       
  2292 			
       
  2293 #ifdef _DEBUG
       
  2294             LogDatabaseEvent(aEvent);
       
  2295 #endif
       
  2296 			
       
  2297 			break;
       
  2298 			}
       
  2299 
       
  2300 		case CAspDbNotifier::EDelete:
       
  2301 			{
       
  2302 
       
  2303 #ifdef _DEBUG
       
  2304             LogDatabaseEvent(aEvent);
       
  2305 #endif
       
  2306 
       
  2307             TInt index = iProfileList->ListIndex(aEvent.iProfileId);
       
  2308             if (index != KErrNotFound)
       
  2309             	{
       
  2310             	iProfileList->Remove(aEvent.iProfileId);
       
  2311             	if (IsCurrentProfile(aEvent.iProfileId))
       
  2312             		{
       
  2313             		if (!iContentList->IsLocked())
       
  2314             		    {
       
  2315             		    SetCurrentProfileL(); // set new current profile
       
  2316                         UpdateListBoxL();
       
  2317 #ifdef RD_DSUI_TIMEDSYNC 
       
  2318 					UpdateTabsL();
       
  2319 #else
       
  2320                     UpdateNavipaneL(iCurrentProfileName);
       
  2321 #endif            		 
       
  2322 						}
       
  2323             		}
       
  2324             	}
       
  2325 			break;
       
  2326 			}
       
  2327 
       
  2328 		case CAspDbNotifier::EUpdateAll:
       
  2329 			{
       
  2330 
       
  2331 #ifdef _DEBUG			
       
  2332 			LogDatabaseEvent(aEvent);
       
  2333 #endif
       
  2334 
       
  2335 			iProfileList->ReadAllProfilesL(CAspProfileList::ENoMandatoryCheck);
       
  2336 			iProfileList->Sort();
       
  2337            	if (!iContentList->IsLocked())
       
  2338             	{
       
  2339             	SetCurrentProfile(iCurrentProfileId); // set new current profile
       
  2340                 UpdateListBoxL();
       
  2341 #ifdef RD_DSUI_TIMEDSYNC 
       
  2342 					UpdateTabsL();
       
  2343 #else
       
  2344                     UpdateNavipaneL(iCurrentProfileName);
       
  2345 #endif         	
       
  2346 				}
       
  2347 
       
  2348 			break;
       
  2349 			}
       
  2350 
       
  2351 		default:
       
  2352 			break;
       
  2353 		}
       
  2354 		
       
  2355 	FLOG( _L("CAspSettingDialog::HandleDbEventL END") );
       
  2356 	}
       
  2357 // -----------------------------------------------------------------------------
       
  2358 // CAspSettingDialog::HandleOKL()
       
  2359 // 
       
  2360 // -----------------------------------------------------------------------------
       
  2361 //
       
  2362 
       
  2363 void CAspSettingDialog::HandleOKL()
       
  2364 {
       
  2365 	
       
  2366 	if (iProfileList->Count() == 0)
       
  2367 			{
       
  2368 			return;
       
  2369 			}
       
  2370         
       
  2371         if (IsProfileLockedL(iCurrentProfileId))
       
  2372         	{
       
  2373         	TDialogUtil::ShowErrorNoteL(R_ASP_LOCKED_PROFILE);
       
  2374 			CancelCheckboxEvent();
       
  2375 			return;
       
  2376 			}
       
  2377         
       
  2378         if (iSettingEnforcement)
       
  2379 			{
       
  2380 			CancelCheckboxEvent();
       
  2381 			TDialogUtil::ShowInformationNoteL(R_ASP_NOTE_MAIN_LOCKED);
       
  2382 			return ;  // leave dialog open;
       
  2383 			}
       
  2384         
       
  2385         if (!CheckEmailSelection())
       
  2386         	{
       
  2387         	return ;  // leave dialog open;
       
  2388         	}
       
  2389 				
       
  2390 		TInt ret =  SaveCurrentProfile();
       
  2391 		if (ret != KErrNone)
       
  2392 			{
       
  2393 			CancelCheckboxEvent();
       
  2394 			}
       
  2395 			
       
  2396 		return ;
       
  2397 }
       
  2398 // -----------------------------------------------------------------------------
       
  2399 // CAspSettingDialog::HandleListBoxEventL (from MEikListBoxObserver)
       
  2400 // 
       
  2401 // -----------------------------------------------------------------------------
       
  2402 //
       
  2403 void CAspSettingDialog::HandleListBoxEventL(CEikListBox* /*aListBox*/, TListBoxEvent aEventType)
       
  2404 	{
       
  2405 	   if( AknLayoutUtils::PenEnabled() )  
       
  2406 	   {
       
  2407 	   	 switch(aEventType)
       
  2408 		{
       
  2409 			case EEventItemClicked :
       
  2410 			     HandleOKL();
       
  2411 			     break;
       
  2412 			default:
       
  2413 			     break;
       
  2414 		}
       
  2415 	   }
       
  2416 	  
       
  2417     }
       
  2418 
       
  2419 // -----------------------------------------------------------------------------
       
  2420 // CAspSettingDialog::HandleActiveCallL (from MAspActiveCallerObserver)
       
  2421 //
       
  2422 // -----------------------------------------------------------------------------
       
  2423 //
       
  2424 void CAspSettingDialog::HandleActiveCallL(TInt /*aCallId*/)
       
  2425 	{
       
  2426 	}
       
  2427 
       
  2428 
       
  2429 // -----------------------------------------------------------------------------
       
  2430 // CAspSettingDialog::SetCurrentIndex
       
  2431 //
       
  2432 // -----------------------------------------------------------------------------
       
  2433 //
       
  2434 void CAspSettingDialog::SetCurrentIndex()
       
  2435 	{
       
  2436 	TInt count = ListBox()->Model()->NumberOfItems();
       
  2437 
       
  2438 	if (count == 0)
       
  2439 		{
       
  2440 		iCurrentListBoxIndex = KErrNotFound;  // empty list
       
  2441 		}
       
  2442 	else
       
  2443 		{
       
  2444 		iCurrentListBoxIndex = ListBox()->CurrentItemIndex();
       
  2445 		}
       
  2446 	}
       
  2447 
       
  2448 
       
  2449 // -----------------------------------------------------------------------------
       
  2450 // CAspSettingDialog::CurrentIndex
       
  2451 //
       
  2452 // -----------------------------------------------------------------------------
       
  2453 //
       
  2454 TInt CAspSettingDialog::CurrentIndex()
       
  2455 	{
       
  2456 	TInt count = ListBox()->Model()->NumberOfItems();
       
  2457 	
       
  2458 	if (count == 0)
       
  2459 		{
       
  2460 		iCurrentListBoxIndex = KErrNotFound;
       
  2461 		}
       
  2462 	else if (iCurrentListBoxIndex >= count)
       
  2463 		{
       
  2464 		iCurrentListBoxIndex = count-1; // last listbox item
       
  2465 		}
       
  2466 	else if (iCurrentListBoxIndex < 0)
       
  2467 		{
       
  2468 		iCurrentListBoxIndex = 0; // first listbox item
       
  2469 		}
       
  2470 		
       
  2471 	return iCurrentListBoxIndex;
       
  2472 	}
       
  2473 
       
  2474 
       
  2475 // -----------------------------------------------------------------------------
       
  2476 // CAspSettingDialog::ShowCurrentProfileInfoL
       
  2477 //
       
  2478 // -----------------------------------------------------------------------------
       
  2479 //
       
  2480 void CAspSettingDialog::ShowCurrentProfileInfoL()
       
  2481 	{
       
  2482 	TAspProfileItem& item = CurrentProfileL();
       
  2483 	TBuf<KBufSize> buf;
       
  2484     iBearerHandler->GetBearerName(buf, item.iBearer);
       
  2485     HBufC* hBuf = CAspResHandler::ReadProfileInfoTextLC(item.iProfileName, buf);
       
  2486     ShowPopupNoteL(hBuf->Des());
       
  2487     CleanupStack::PopAndDestroy(hBuf);
       
  2488 	}
       
  2489 
       
  2490 
       
  2491 // -----------------------------------------------------------------------------
       
  2492 // CAspSettingDialog::ShowCurrentProfileInfo
       
  2493 //
       
  2494 // -----------------------------------------------------------------------------
       
  2495 //
       
  2496 void CAspSettingDialog::ShowCurrentProfileInfo()
       
  2497 	{
       
  2498 	TRAP_IGNORE(ShowCurrentProfileInfoL());
       
  2499 	}
       
  2500 
       
  2501 
       
  2502 // -----------------------------------------------------------------------------
       
  2503 // CAspSettingDialog::ShowAutoSyncProfileInfoL
       
  2504 //
       
  2505 // -----------------------------------------------------------------------------
       
  2506 //
       
  2507 TBool CAspSettingDialog::ShowAutoSyncProfileInfo()
       
  2508 	{
       
  2509 	TBool ret = EFalse;
       
  2510 	
       
  2511 	TRAPD(err, ret = ShowAutoSyncProfileInfoL());
       
  2512 
       
  2513 #ifdef RD_DSUI_TIMEDSYNC
       
  2514 	UpdateTabsL();	
       
  2515 #endif
       
  2516 	
       
  2517 	if (err != KErrNone)
       
  2518 		{
       
  2519 		return EFalse;
       
  2520 		}
       
  2521 	return ret;
       
  2522 	}
       
  2523 
       
  2524 // -----------------------------------------------------------------------------
       
  2525 // CAspSettingDialog::ShowAutoSyncProfileInfoL
       
  2526 //
       
  2527 // -----------------------------------------------------------------------------
       
  2528 //
       
  2529 TBool CAspSettingDialog::ShowAutoSyncProfileInfoL()
       
  2530 	{
       
  2531 	CAspSchedule* schedule = CAspSchedule::NewLC();
       
  2532 	
       
  2533 	if (!schedule->CanSynchronizeL())
       
  2534     	{
       
  2535    	    CleanupStack::PopAndDestroy(schedule);
       
  2536 	    return EFalse;
       
  2537     	}
       
  2538 	
       
  2539 	TInt autoSyncError = schedule->Error();
       
  2540 	if (autoSyncError != KErrNone)
       
  2541 		{
       
  2542 
       
  2543 		TInt profileId = schedule->ProfileId();
       
  2544 		TInt asProfileId = schedule->AutoSyncProfileId();
       
  2545 		TAspParam param(iApplicationId, iSyncSession);
       
  2546 		CAspProfile* asProfile = CAspProfile::NewLC(param);
       
  2547 		asProfile->OpenL(asProfileId, CAspProfile::EOpenRead, CAspProfile::EAllProperties);
       
  2548 		CAspProfile* profile = CAspProfile::NewLC(param);
       
  2549 		profile->OpenL(profileId, CAspProfile::EOpenRead, CAspProfile::EAllProperties);
       
  2550 
       
  2551 		//display auto sync error query only if profile hasn't been manually synced after last auto sync
       
  2552 		if (asProfile->LastSync() >= profile->LastSync())
       
  2553 			{
       
  2554 			if (autoSyncError == CAspAutoSyncHandler::EOtherSyncRunning)
       
  2555 				{
       
  2556 				HBufC* hBuf = CAspResHandler::ReadLC(R_ASP_MANUAL_SYNC_OVERRIDE);
       
  2557 				_LIT(KEmpty, " ");
       
  2558 				TDialogUtil::ShowMessageQueryL(KEmpty, hBuf->Des());
       
  2559    	   			CleanupStack::PopAndDestroy(hBuf);
       
  2560 				}
       
  2561 			else
       
  2562 				{
       
  2563 				HBufC* hBuf = CAspResHandler::ReadLC(R_ASP_POPUP_AUTO_SYNC_ERROR);
       
  2564 				_LIT(KNewLine ,"\n");
       
  2565 				TBuf<KBufSize> buf(hBuf->Des());
       
  2566 				buf.Append(KNewLine);
       
  2567 				CAspResHandler::ReadL(iBuf, R_ASP_MAIN_AUTO_ERROR_LOG_LINK);
       
  2568 				buf.Append(iBuf);
       
  2569 				CleanupStack::PopAndDestroy(hBuf);
       
  2570 				hBuf = HBufC::NewLC(buf.Size());
       
  2571 				TPtr ptr(hBuf->Des());
       
  2572 				ptr = buf;
       
  2573 
       
  2574 			   	TDialogUtil::ShowAutoSyncMessageQueryL(hBuf->Des());
       
  2575 	   	   		CleanupStack::PopAndDestroy(hBuf);
       
  2576 				}
       
  2577 	  	    
       
  2578    	    	schedule->SetError(KErrNone);
       
  2579    	    	schedule->SaveL();
       
  2580 
       
  2581 			CleanupStack::PopAndDestroy(profile);
       
  2582 			CleanupStack::PopAndDestroy(asProfile);
       
  2583 			CleanupStack::PopAndDestroy(schedule);
       
  2584    	    	return ETrue;
       
  2585 			}
       
  2586 		
       
  2587 		CleanupStack::PopAndDestroy(profile);
       
  2588 		CleanupStack::PopAndDestroy(asProfile);
       
  2589 		
       
  2590 		schedule->SetError(KErrNone);
       
  2591    	    schedule->SaveL();
       
  2592 		}
       
  2593 
       
  2594     
       
  2595     TTime nextSync;
       
  2596     schedule->GetStartTimeL(nextSync ,ETrue);
       
  2597 
       
  2598     TInt profileIndex = iProfileList->ListIndex(schedule->ProfileId());
       
  2599     TAspProfileItem& item = iProfileList->Item(profileIndex); 
       
  2600     
       
  2601 	HBufC* hBuf1 = CAspResHandler::ReadAutoSyncInfoTextLC( item.iProfileName, nextSync);
       
  2602 	
       
  2603 	TDialogUtil::ShowInformationNoteL(hBuf1->Des());
       
  2604    	CleanupStack::PopAndDestroy(hBuf1);
       
  2605     CleanupStack::PopAndDestroy(schedule);
       
  2606 	return ETrue;
       
  2607 	}
       
  2608 
       
  2609 
       
  2610 // -----------------------------------------------------------------------------
       
  2611 // CAspSettingDialog::ShowPopupNote
       
  2612 //
       
  2613 // -----------------------------------------------------------------------------
       
  2614 //
       
  2615 void CAspSettingDialog::ShowPopupNoteL(const TDesC& aText) 
       
  2616     {
       
  2617     iPopupNote->SetTextL(aText);
       
  2618     iPopupNote->SetTimePopupInView(KSettingDialogPopupDisplayTime);    
       
  2619     iPopupNote->ShowInfoPopupNote();    
       
  2620     }
       
  2621 
       
  2622 
       
  2623 // -----------------------------------------------------------------------------
       
  2624 // CAspSettingDialog::Listbox
       
  2625 //
       
  2626 // -----------------------------------------------------------------------------
       
  2627 //
       
  2628 CAknDoubleLargeStyleListBox* CAspSettingDialog::ListBox()
       
  2629 	{
       
  2630 	__ASSERT_DEBUG(iSettingListBox, TUtil::Panic(KErrGeneral));
       
  2631 
       
  2632 	return iSettingListBox;
       
  2633 	}
       
  2634 
       
  2635 
       
  2636 // -----------------------------------------------------------------------------
       
  2637 // CAspSettingDialog::SyncRunning
       
  2638 //
       
  2639 // -----------------------------------------------------------------------------
       
  2640 //
       
  2641 TBool CAspSettingDialog::SyncRunning()
       
  2642 	{
       
  2643     if (!iSyncHandler)
       
  2644 		{
       
  2645 		return EFalse;
       
  2646 		}
       
  2647 
       
  2648 	if (iSyncHandler->SyncRunning())
       
  2649 		{
       
  2650 		return ETrue;
       
  2651 		}
       
  2652 
       
  2653 	return EFalse;
       
  2654 	}
       
  2655 
       
  2656 
       
  2657 // -----------------------------------------------------------------------------
       
  2658 // CAspSettingDialog::UpdateCbaL
       
  2659 // 
       
  2660 // -----------------------------------------------------------------------------
       
  2661 //
       
  2662 void CAspSettingDialog::UpdateCbaL(TInt aResourceId)
       
  2663     {
       
  2664     CEikButtonGroupContainer& cba = ButtonGroupContainer();
       
  2665     cba.SetCommandSetL(aResourceId);
       
  2666     cba.DrawDeferred();
       
  2667     }
       
  2668 
       
  2669 
       
  2670 // ----------------------------------------------------------------------------
       
  2671 // CAspSettingDialog::CancelCheckboxEvent
       
  2672 // 
       
  2673 // ----------------------------------------------------------------------------
       
  2674 //
       
  2675 void CAspSettingDialog::CancelCheckboxEventL()
       
  2676 	{
       
  2677 	CListBoxView* view = iSettingListBox->View();
       
  2678     
       
  2679     TInt index = view->CurrentItemIndex();
       
  2680     TBool selected = view->ItemIsSelected(index);
       
  2681     if (selected)
       
  2682        	{
       
  2683         view->DeselectItem(index);
       
  2684        	}
       
  2685     else
       
  2686     	{
       
  2687     	view->SelectItemL(index);
       
  2688     	}
       
  2689     	
       
  2690     iSettingListBox->SetCurrentItemIndex(index);
       
  2691     //view->SetCurrentItemIndex(index);
       
  2692 	}
       
  2693 
       
  2694 
       
  2695 // ----------------------------------------------------------------------------
       
  2696 // CAspSettingDialog::CancelCheckboxEvent
       
  2697 // 
       
  2698 // ----------------------------------------------------------------------------
       
  2699 //
       
  2700 void CAspSettingDialog::CancelCheckboxEvent()
       
  2701 	{
       
  2702 	TRAP_IGNORE(CancelCheckboxEventL());
       
  2703 	}
       
  2704 
       
  2705 
       
  2706 // ----------------------------------------------------------------------------
       
  2707 // CAspSettingDialog::CheckEmailSelection
       
  2708 // 
       
  2709 // ----------------------------------------------------------------------------
       
  2710 //
       
  2711 TBool CAspSettingDialog::CheckEmailSelection()
       
  2712 	{
       
  2713 	TBool ret = ETrue;
       
  2714 	
       
  2715 	TRAPD(err, ret = CheckEmailSelectionL());
       
  2716 	
       
  2717 	if (err != KErrNone)
       
  2718 		{
       
  2719 		return ETrue;
       
  2720 		}
       
  2721 	
       
  2722 	return ret;
       
  2723 	}
       
  2724 
       
  2725 
       
  2726 // ----------------------------------------------------------------------------
       
  2727 // CAspSettingDialog::CheckEmailSelectionL
       
  2728 // 
       
  2729 // ----------------------------------------------------------------------------
       
  2730 //
       
  2731 TBool CAspSettingDialog::CheckEmailSelectionL()
       
  2732 	{
       
  2733 	CListBoxView* view = iSettingListBox->View();
       
  2734 	
       
  2735     TInt index = view->CurrentItemIndex();
       
  2736     TAspProviderItem& item = iContentList->ProviderItem(index);
       
  2737     TBool selected = view->ItemIsSelected(index);
       
  2738     
       
  2739     if (item.iDataProviderId != KUidNSmlAdapterEMail.iUid)
       
  2740     	{
       
  2741     	return ETrue;
       
  2742     	}
       
  2743         
       
  2744     if (!selected)
       
  2745     	{
       
  2746     	return ETrue;
       
  2747     	}
       
  2748     
       
  2749     iContentList->UpdateDataProviderL(item.iDataProviderId);
       
  2750     if (!item.iHasDefaultDataStore)
       
  2751     	{
       
  2752     	CancelCheckboxEvent();
       
  2753     	TDialogUtil::ShowErrorNoteL(R_ASP_NO_MAILBOXES);
       
  2754     	return EFalse;
       
  2755     	}
       
  2756     	
       
  2757     if (HasCurrentProfile())
       
  2758     	{
       
  2759     	TAspParam param(iApplicationId, iSyncSession);
       
  2760 	    CAspProfile* profile = CAspProfile::NewLC(param);
       
  2761         profile->OpenL(iCurrentProfileId, CAspProfile::EOpenRead, CAspProfile::EAllProperties);
       
  2762       
       
  2763 	    TInt num = profile->ProtocolVersion();
       
  2764 	    CleanupStack::PopAndDestroy(profile);
       
  2765 
       
  2766     	}
       
  2767     
       
  2768     	
       
  2769     
       
  2770     return ETrue;
       
  2771 	}
       
  2772 
       
  2773 // ----------------------------------------------------------------------------
       
  2774 // CAspSettingDialog::IsProfileLockedL
       
  2775 // Checks if a particular profile is already opened
       
  2776 // ----------------------------------------------------------------------------
       
  2777 //
       
  2778 TBool CAspSettingDialog::IsProfileLockedL(TInt aProfileId)
       
  2779 {
       
  2780 	
       
  2781 	TAspParam param(iApplicationId, iSyncSession);
       
  2782 	CAspProfile* profile = CAspProfile::NewLC(param);
       
  2783 	
       
  2784 	
       
  2785 	TRAPD(err, profile->OpenL(aProfileId, CAspProfile::EOpenReadWrite,
       
  2786                                          CAspProfile::EAllProperties));
       
  2787                                          
       
  2788     
       
  2789 	if (err == KErrLocked)
       
  2790 		{
       
  2791 		CleanupStack::PopAndDestroy(profile);
       
  2792 		return ETrue;
       
  2793 		}
       
  2794 	else
       
  2795 		{
       
  2796 		CleanupStack::PopAndDestroy(profile);
       
  2797 		return EFalse;
       
  2798 		}
       
  2799 	
       
  2800 }
       
  2801 // ----------------------------------------------------------------------------
       
  2802 // CAspSettingDialog::UpdateMiddleSoftKeyLabelL
       
  2803 // Update the MSK Label
       
  2804 // ----------------------------------------------------------------------------
       
  2805 //
       
  2806 void CAspSettingDialog::UpdateMiddleSoftKeyLabelL(TInt aCommandId,TInt aResourceId)
       
  2807 {
       
  2808 	ButtonGroupContainer().RemoveCommandFromStack(KMSKControlId,aCommandId );
       
  2809 	HBufC* middleSKText = StringLoader::LoadLC( aResourceId );
       
  2810 
       
  2811 	ButtonGroupContainer().AddCommandToStackL(
       
  2812 	KMSKControlId,
       
  2813 	aCommandId,
       
  2814 	*middleSKText );
       
  2815 	CleanupStack::PopAndDestroy( middleSKText );
       
  2816 }
       
  2817 
       
  2818 #ifdef _DEBUG
       
  2819 
       
  2820 
       
  2821 // -----------------------------------------------------------------------------
       
  2822 // LogDatabaseEvent
       
  2823 //
       
  2824 // -----------------------------------------------------------------------------
       
  2825 //
       
  2826 void CAspSettingDialog::LogDatabaseEvent(TAspDbEvent aEvent)
       
  2827 	{
       
  2828 	TBuf<KBufSize> buf;
       
  2829 	
       
  2830     if (aEvent.iType == CAspDbNotifier::EClose)
       
  2831     	{
       
  2832     	FLOG( _L("### EClose: close setting dialog ###") );
       
  2833     	}
       
  2834     else if (aEvent.iType == CAspDbNotifier::EUpdate)
       
  2835     	{
       
  2836         TInt index = iProfileList->ListIndex(aEvent.iProfileId);
       
  2837         if (index != KErrNotFound)
       
  2838            	{
       
  2839            	TAspProfileItem& item = iProfileList->Item(index);
       
  2840             FTRACE( RDebug::Print(_L("EUpdate: %S (%d)"), &item.iProfileName, aEvent.iProfileId) );
       
  2841                
       
  2842             buf.Format(_L("EUpdate: %S"), &item.iProfileName);
       
  2843 		    TUtil::Print(buf);
       
  2844            	}
       
  2845         else
       
  2846           	{
       
  2847            	FTRACE( RDebug::Print(_L("### EUpdate: profile not found (%d) ###"), aEvent.iProfileId) );
       
  2848            	TUtil::Print(_L("EUpdate: profile not found"));
       
  2849            	}
       
  2850     	}
       
  2851     else if (aEvent.iType == CAspDbNotifier::EDelete)
       
  2852     	{
       
  2853         TInt index = iProfileList->ListIndex(aEvent.iProfileId);
       
  2854         if (index != KErrNotFound)
       
  2855            	{
       
  2856            	TAspProfileItem& item = iProfileList->Item(index);
       
  2857 		    FTRACE( RDebug::Print(_L("EDelete: %S (%d)"), &item.iProfileName, aEvent.iProfileId) );
       
  2858 
       
  2859             buf.Format(_L("EDelete: %S"), &item.iProfileName);
       
  2860 		    TUtil::Print(buf);
       
  2861            	}
       
  2862         else
       
  2863            	{
       
  2864            	FTRACE( RDebug::Print(_L("EDelete: profile not found (%d)"), aEvent.iProfileId) );
       
  2865            	TUtil::Print(_L("EDelete: profile not found"));
       
  2866            	}
       
  2867     	
       
  2868     	}
       
  2869     else if (aEvent.iType == CAspDbNotifier::EUpdateAll)
       
  2870     	{
       
  2871      	FLOG( _L("EUpdateAll: read all profiles") );
       
  2872      	TUtil::Print(_L("EUpdateAll: read all profiles"));
       
  2873     	}
       
  2874 	}
       
  2875 
       
  2876 
       
  2877 // -----------------------------------------------------------------------------
       
  2878 // TestL
       
  2879 //
       
  2880 // -----------------------------------------------------------------------------
       
  2881 //
       
  2882 void CAspSettingDialog::TestL()
       
  2883     {
       
  2884     TAspParam param(iApplicationId, iSyncSession);
       
  2885 	CAspProfile* profile = CAspProfile::NewLC(param);
       
  2886     profile->OpenL(iCurrentProfileId, CAspProfile::EOpenRead, CAspProfile::EAllProperties);
       
  2887       
       
  2888 	TBuf<128> buf; TBuf<128> buf2;
       
  2889 	profile->GetPassword(buf);
       
  2890 	TInt len = buf.Length();
       
  2891 	buf2.Format(_L("len = %d  text = %S"), len, &buf);
       
  2892 	TDialogUtil::ShowMessageQueryL(_L("huu"), buf2);
       
  2893     CleanupStack::PopAndDestroy(profile);
       
  2894     
       
  2895     /*
       
  2896     CListBoxView* view = iSettingListBox->View();
       
  2897     const CListBoxView::CSelectionIndexArray* arr = view->SelectionIndexes();
       
  2898     TBuf<128> buf; TBuf<128> buf2;
       
  2899     TInt count = arr->Count();
       
  2900     for (TInt i=0; i<count; i++)
       
  2901      	{
       
  2902        	buf2.Format(_L("%d "), (*arr)[i]);
       
  2903        	buf.Append(buf2);
       
  2904        	}
       
  2905     TDialogUtil::ShowMessageQueryL(_L("huu"), buf);
       
  2906     */
       
  2907     
       
  2908     /*
       
  2909     HBufC* hBuf = iResHandler->ReadProgressTextLC(_L("qwerty ggggggggggggggggggggggg"), CAspState::EPhaseSending);
       
  2910     TDialogUtil::ShowMessageQueryL(_L("huu"), hBuf->Des());
       
  2911     CleanupStack::PopAndDestroy(hBuf);
       
  2912     
       
  2913     hBuf = iResHandler->ReadProgressTextLC(_L("qwerty ggggggggggggggggggggggg"), CAspState::EPhaseReceiving);
       
  2914     TDialogUtil::ShowMessageQueryL(_L("huu"), hBuf->Des());
       
  2915     CleanupStack::PopAndDestroy(hBuf);
       
  2916 
       
  2917     hBuf = iResHandler->ReadProgressTextLC(_L("qwerty ggggggggggggggggggggggg"), 34);
       
  2918     TDialogUtil::ShowMessageQueryL(_L("huu"), hBuf->Des());
       
  2919     CleanupStack::PopAndDestroy(hBuf);
       
  2920     */
       
  2921     }
       
  2922 
       
  2923 
       
  2924 #endif
       
  2925 
       
  2926 
       
  2927 
       
  2928 
       
  2929 
       
  2930 //  End of File