omadm/omadmappui/src/NSmlDMSyncAppUi_nofota.cpp
changeset 0 3ce708148e4d
child 16 4eb398b07b07
equal deleted inserted replaced
-1:000000000000 0:3ce708148e4d
       
     1 /*
       
     2 * Copyright (c) 2005-2006 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:  Methods for Device Manager Application UI
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 #include <e32property.h>
       
    20 #include <APGWGNAM.H>
       
    21 #include <gsfwviewuids.h>
       
    22 #include "nsmldmsyncinternalpskeys.h"
       
    23 
       
    24 #include <aknnotewrappers.h>
       
    25 
       
    26 #include <aknnavide.h>
       
    27 #include <stringloader.h>
       
    28 #include <textresolver.h>
       
    29 
       
    30 #include "nsmldmsyncappui.h"
       
    31 #include "nsmldmsyncapp.h"
       
    32 #include "nsmldmsyncappengine.h"
       
    33 #include "nsmldmprofilesview.h"
       
    34 #include "nsmldmsyncdocument.h"
       
    35 #include "nsmldmdlgprofileview.h"
       
    36 #include "nsmldmsyncdebug.h"
       
    37 #include "nsmldmsyncdialog.h"
       
    38 #include "nsmldmsyncprofile.h"
       
    39 #include <nsmldmsync.rsg>
       
    40 #include <FeatMgr.h>
       
    41 
       
    42 #include <hlplch.h>
       
    43 #include <csxhelp/dm.hlp.hrh>
       
    44 
       
    45 
       
    46 // ============================ MEMBER FUNCTIONS ==============================
       
    47 //
       
    48 
       
    49 // -----------------------------------------------------------------------------
       
    50 // CNSmlDMSyncAppUi::ConstructL
       
    51 // Symbian 2nd phase constructor can leave.
       
    52 // -----------------------------------------------------------------------------
       
    53 //
       
    54 void CNSmlDMSyncAppUi::ConstructL()
       
    55     {
       
    56     FLOG( "[OMADM] CNSmlDMSyncAppUi::ConstructL()" );
       
    57 
       
    58     BaseConstructL( EAknEnableSkin | EAknEnableMSK );
       
    59     iSyncDocument = (CNSmlDMSyncDocument*) iDocument;
       
    60     iSyncAppEngine = iSyncDocument->AppEngine();
       
    61     iSyncAppEngine->RequestSyncStatus( this );
       
    62 
       
    63 	iNaviDecorator = 0;
       
    64 
       
    65     iProfilesView = new (ELeave) CNSmlDMProfilesView();
       
    66     iProfilesView->ConstructL(); // this );
       
    67     AddViewL( iProfilesView ); // Transfer ownership to CAknViewAppUi
       
    68     
       
    69     ActivateLocalViewL( iProfilesView->Id() );
       
    70 
       
    71 	iDialogUp       = 0;
       
    72 	iDestroyed      = 1;
       
    73 
       
    74     FLOG( "[OMADM] CNSmlDMSyncAppUi::ConstructL() completed" );
       
    75     }
       
    76 
       
    77 // ------------------------------------------------------------------------------
       
    78 // Destructor
       
    79 // ------------------------------------------------------------------------------
       
    80 
       
    81 CNSmlDMSyncAppUi::~CNSmlDMSyncAppUi()
       
    82     {
       
    83     FLOG( "[OMADM] ~CNSmlDMSyncAppUi()" );
       
    84 
       
    85 	delete iNaviDecorator;
       
    86 	if ( iDestroyed == 0 )
       
    87 		{
       
    88 		delete iAppView;
       
    89 		}
       
    90 	}
       
    91 
       
    92 
       
    93 
       
    94 // ------------------------------------------------------------------------------
       
    95 // CNSmlDMSyncAppUi::DynInitMenuPaneL
       
    96 // ------------------------------------------------------------------------------
       
    97 //
       
    98 void CNSmlDMSyncAppUi::DynInitMenuPaneL( TInt /*aResourceId*/,
       
    99                                          CEikMenuPane* /*aMenuPane*/ )
       
   100     {
       
   101     FLOG( "[OMADM] CNSmlDMSyncAppUi::DynInitMenuPaneL:" );
       
   102 	}
       
   103 
       
   104 // ------------------------------------------------------------------------------
       
   105 // CNSmlDMSyncAppUi::HandleKeyEventL
       
   106 // ------------------------------------------------------------------------------
       
   107 //
       
   108 TKeyResponse CNSmlDMSyncAppUi::HandleKeyEventL( const TKeyEvent& aKeyEvent,
       
   109                                             	TEventCode aType )
       
   110     {
       
   111     FLOG( "[OMADM] CNSmlDMSyncAppUi::HandleKeyEventL:" );
       
   112 
       
   113 	//EEventKeyDown ends settdialog
       
   114 	if ( iDialogUp != 0 ) 
       
   115 		{
       
   116 		return EKeyWasConsumed;
       
   117 		}
       
   118 	if ( aType == EEventKey )
       
   119 		{
       
   120 		switch ( aKeyEvent.iCode )
       
   121 			{
       
   122 			case EKeyUpArrow:
       
   123 				{
       
   124 				if ( !Synchronise() )
       
   125 					{
       
   126 					HandleUpScrollL();
       
   127 					}
       
   128 				}
       
   129 		    	break;
       
   130 
       
   131 			case EKeyDownArrow:
       
   132 				{
       
   133 				if ( !Synchronise() )
       
   134 					{
       
   135 					HandleDownScrollL();
       
   136 					}
       
   137 				}
       
   138 			    break;
       
   139 
       
   140 			case EKeyPhoneEnd:
       
   141 			case EKeyEscape:
       
   142 				{
       
   143 				if ( Synchronise() )
       
   144 					{
       
   145 					iSyncAppEngine->CancelSyncL();
       
   146 					}						
       
   147 				}
       
   148 			    break;
       
   149 			default:
       
   150       
       
   151 				return EKeyWasNotConsumed;		
       
   152 			}
       
   153 		}
       
   154     FLOG( "[OMADM] CNSmlDMSyncAppUi::HandleKeyEventL() completed" );
       
   155     return EKeyWasNotConsumed;
       
   156 	}
       
   157 
       
   158 // -----------------------------------------------------------------------------
       
   159 // CNSmlDMSyncAppUi::HandleCommandL
       
   160 // -----------------------------------------------------------------------------
       
   161 //
       
   162 void CNSmlDMSyncAppUi::HandleCommandL( TInt aCommand )
       
   163     {
       
   164     FTRACE( FPrint(
       
   165         _L("[OMADM] CNSmlDMSyncAppUi::HandleCommandL() command = 0x%x"),
       
   166         aCommand ) );
       
   167 
       
   168     iSyncDocument->DisableDbNotifications( ETrue );
       
   169 	iBusy = ETrue;
       
   170 
       
   171     switch ( aCommand )
       
   172         {
       
   173      case EAknCmdHelp:              //ENSmlMenuCmdMainHelp:
       
   174 		  	{
       
   175 			  	if (FeatureManager::FeatureSupported( KFeatureIdHelp ))
       
   176            {
       
   177                  HlpLauncher::LaunchHelpApplicationL( iEikonEnv->WsSession(), AppHelpContextL() );
       
   178 			           iBusy = EFalse;
       
   179 			     }    
       
   180 			 
       
   181 			
       
   182 			  }
       
   183     		break;
       
   184 		case EAknCmdExit:
       
   185         case EEikCmdExit:		// quit application
       
   186 			{
       
   187 			TInt value=-1;
       
   188             TInt r1=RProperty::Set(KPSUidNSmlDMSyncApp,KNSmlDMSyncUiLaunchKey,value);
       
   189 			Exit();
       
   190 			}
       
   191 		    break;
       
   192 		    
       
   193 		case ENSmlMenuCmdNewProfile:	// create new profile
       
   194 			{
       
   195 			if (TUtil::SettingEnforcementState())
       
   196 				{
       
   197 				ShowResourceErrorNoteL( R_QTN_DM_INFO_NOTE_LOCKED_SETTING );
       
   198 				break;
       
   199 				}
       
   200             HandleCommandNewProfileL();
       
   201 			}
       
   202 		    break;
       
   203 
       
   204 		case ENSmlMenuCmdEraseProfile:	// delete profile
       
   205 			{
       
   206 			if (TUtil::SettingEnforcementState())
       
   207 				{
       
   208 				ShowResourceErrorNoteL( R_QTN_DM_INFO_NOTE_LOCKED_SETTING );
       
   209 				break;
       
   210 				}
       
   211             HandleCommandEraseProfileL();
       
   212 			}
       
   213     		break;
       
   214 		
       
   215 		case ENSmlMenuCmdOpenLog:			// open syncronisation log view
       
   216 			{
       
   217 			CNSmlDMSyncDialog::ShowDialogL( 
       
   218             			      iSyncDocument->ProfileItem()->iProfileId,
       
   219 			                  iSyncAppEngine->Session() );
       
   220 			iBusy = EFalse;
       
   221 			}
       
   222 		    break;
       
   223 
       
   224 		case ENSmlMenuCmdOpenSettings:		// open profile for editing
       
   225 			{
       
   226 			if (TUtil::SettingEnforcementState())
       
   227 				{
       
   228 				ShowResourceErrorNoteL( R_QTN_DM_INFO_NOTE_LOCKED_SETTING );
       
   229 				break;
       
   230 				}
       
   231 			ShowEditProfileDialogL( ESmlEditProfile );
       
   232 			}
       
   233 		    break;
       
   234 		
       
   235 		case ENSmlMenuCmdStartSync:			// start synchronisation
       
   236 			{
       
   237             if ( ShowConfirmationNoteL( R_QTN_SML_CONF_STARTQUERY ) )
       
   238                 {
       
   239                 StartSyncL();
       
   240                 }
       
   241 			}
       
   242 		    break;
       
   243 		
       
   244 		default:
       
   245             break;      
       
   246         }
       
   247     iSyncDocument->DisableDbNotifications( EFalse );
       
   248     FLOG( "[OMADM] CNSmlDMSyncAppUi::HandleCommandL() completed" );
       
   249     }
       
   250 
       
   251 // -----------------------------------------------------------------------------
       
   252 // CNSmlDMSyncAppUi::HandleUpScrollL
       
   253 // -----------------------------------------------------------------------------
       
   254 //
       
   255 void CNSmlDMSyncAppUi::HandleUpScrollL()
       
   256 	{
       
   257     FLOG( "[OMADM] CNSmlDMSyncAppUi::HandleUpScrollL:" );
       
   258 	}
       
   259 
       
   260 // -----------------------------------------------------------------------------
       
   261 // CNSmlDMSyncAppUi::HandleDownScrollL
       
   262 // -----------------------------------------------------------------------------
       
   263 //
       
   264 void CNSmlDMSyncAppUi::HandleDownScrollL()
       
   265 	{
       
   266     FLOG( "[OMADM] CNSmlDMSyncAppUi::HandleDownScrollL:" );
       
   267 	}
       
   268 
       
   269 // -----------------------------------------------------------------------------
       
   270 // CNSmlDMSyncAppUi::ShowEditProfileDialogL
       
   271 // -----------------------------------------------------------------------------
       
   272 //
       
   273 void CNSmlDMSyncAppUi::ShowEditProfileDialogL( TNSmlEditMode aMode,
       
   274                                                TInt /*aStartUp*/)
       
   275 	{
       
   276     FLOG( "[OMADM] CNSmlDMSyncAppUi::ShowEditProfileDialogL:" );
       
   277 
       
   278 	TInt profileId( KErrNotFound );
       
   279 	if ( aMode != ESmlNewProfile )
       
   280 		{
       
   281 		profileId = iSyncDocument->ProfileItem()->iProfileId;
       
   282 		}
       
   283     
       
   284     iAppView = CNSmlDMDlgProfileView::NewL( 
       
   285                                     iSyncDocument,
       
   286 	                                aMode,
       
   287 	                                profileId );
       
   288 	  	                               
       
   289 	TRAPD( error, iAppView->ExecuteLD( R_NSML_SETTING_DIALOG ) );
       
   290 	if ( error != KErrNone )
       
   291 		{
       
   292 		ShowErrorNoteL( error );
       
   293 		}
       
   294 	else
       
   295 		{
       
   296 		iBusy = ETrue;
       
   297 		iActiveView = CNSmlDMSyncAppUi::SettingsView;
       
   298 		AddToStackL( iAppView );
       
   299 		}
       
   300 	}
       
   301 
       
   302 // -----------------------------------------------------------------------------
       
   303 // CNSmlDMSyncAppUi::ProcessCommandParametersL
       
   304 // -----------------------------------------------------------------------------
       
   305 //
       
   306 TBool CNSmlDMSyncAppUi::ProcessCommandParametersL( TApaCommand /*aCommand*/,
       
   307                                                    TFileName& aDocumentName,
       
   308                                                    const TDesC8& /*aTail*/ )
       
   309 	{
       
   310     FLOG( "[OMADM] CNSmlDMSyncAppUi::ProcessCommandParametersL:" );
       
   311 
       
   312 	 // This is to prevent dummy document creation
       
   313 	aDocumentName.Zero();
       
   314 	return EFalse;
       
   315 	}
       
   316 
       
   317 // -----------------------------------------------------------------------------
       
   318 // CNSmlDMSyncAppUi::StartSyncL
       
   319 // -----------------------------------------------------------------------------
       
   320 //
       
   321 void CNSmlDMSyncAppUi::StartSyncL(
       
   322     const TInt aProfileId, // = KErrNotFound
       
   323     const TBool /*aUseFotaProgressNote*/ )
       
   324 	{
       
   325     FTRACE( FPrint(
       
   326         _L("[OMADM] CNSmlDMSyncAppUi::StartSyncL() aProfileId = %d"),
       
   327         aProfileId ) );
       
   328 
       
   329 	if ( aProfileId == KErrNotFound )
       
   330 	    {
       
   331         iConfedProfileId = iSyncDocument->ProfileItem()->iProfileId;
       
   332 	    }
       
   333 	else
       
   334 	    {
       
   335 	    iConfedProfileId = aProfileId;
       
   336 	    }
       
   337 
       
   338     FTRACE( FPrint(
       
   339         _L("[OMADM] CNSmlDMSyncAppUi::StartSyncL() used profileId = %d"),
       
   340         iConfedProfileId ) );
       
   341         
       
   342 	CNSmlDMSyncProfile* profile = 
       
   343 	            iSyncAppEngine->OpenProfileL( iConfedProfileId, ESmlOpenReadWrite );
       
   344 
       
   345     TInt connectionBearer = profile->BearerType();
       
   346     
       
   347     TBuf<KNSmlMaxProfileNameLength> serverName;
       
   348     profile->GetName( serverName );
       
   349 	
       
   350 	if ( profile->SASyncState() == ESASyncStateDisable )
       
   351 		{
       
   352 		if ( ShowConfirmationNoteL( R_QTN_SML_CONF_ACTIVEQUERY ) )
       
   353 			{
       
   354 			profile->SetSASyncStateL( ESASyncStateEnable );
       
   355 			profile->SaveL();
       
   356 			}
       
   357 		else
       
   358 			{
       
   359 			iSyncAppEngine->CloseProfile();
       
   360 			return;
       
   361 			}
       
   362 		}
       
   363 
       
   364     iSyncAppEngine->CloseProfile();		
       
   365     
       
   366     // Since the FOTA is not supported, the simpler progress note
       
   367     // is also never used and the EFalse can be given as parameter.
       
   368     TRAPD( error, iSyncAppEngine->SynchronizeL( serverName, 
       
   369                                                 iConfedProfileId, 
       
   370                                                 connectionBearer,
       
   371                                                 EFalse ) );
       
   372 	
       
   373 	if (error == KErrNone)
       
   374 		{
       
   375 		iActiveView = CNSmlDMSyncAppUi::ProgressView;
       
   376 		}
       
   377 	else
       
   378 		{
       
   379 		ShowErrorNoteL( error );
       
   380 		iActiveView = CNSmlDMSyncAppUi::MainView;
       
   381 		}
       
   382 
       
   383     FTRACE( FPrint(
       
   384         _L("[OMADM] CNSmlDMSyncAppUi::StartSyncL() completed, error = %d"),
       
   385         error ) );
       
   386 	}
       
   387 
       
   388 // -----------------------------------------------------------------------------
       
   389 // CNSmlDMSyncAppUi::ChangeViewL
       
   390 // -----------------------------------------------------------------------------
       
   391 //
       
   392 void CNSmlDMSyncAppUi::ChangeViewL(TBool aRefresh)
       
   393 	{
       
   394     FLOG( "[OMADM] CNSmlDMSyncAppUi::ChangeViewL:" );
       
   395 
       
   396 	iActiveView = CNSmlDMSyncAppUi::MainView;
       
   397 	if ( aRefresh != EFalse )
       
   398 		{
       
   399 		iSyncDocument->RefreshProfileListL();
       
   400         iProfilesView->RefreshL();
       
   401 		}
       
   402 	CAknTitlePane* titlePane = 
       
   403 	    (CAknTitlePane*) StatusPane()->ControlL( TUid::Uid( EEikStatusPaneUidTitle ) );
       
   404 	HBufC* titleText = NULL;    
       
   405 
       
   406 	if ( iViewTitle )
       
   407 	{
       
   408 	titleText = iEikonEnv->AllocReadResourceLC( R_SML_APP_TITLE );
       
   409 	iViewTitle = 0;	
       
   410 	}
       
   411 	else
       
   412 	{
       
   413 	titleText = iEikonEnv->AllocReadResourceLC( R_SML_PROFILES_TITLE );	
       
   414 	}	
       
   415 	
       
   416 	titlePane->SetTextL( titleText->Des() );
       
   417 	CleanupStack::PopAndDestroy(titleText);
       
   418 	iBusy = EFalse;
       
   419 
       
   420     FLOG( "[OMADM] CNSmlDMSyncAppUi::ChangeViewL() completed" );
       
   421 	}
       
   422 
       
   423 // -----------------------------------------------------------------------------
       
   424 // CNSmlDMSyncAppUi::ShowErrorNoteL
       
   425 // -----------------------------------------------------------------------------
       
   426 //
       
   427 void CNSmlDMSyncAppUi::ShowErrorNoteL( TInt aError ) const
       
   428 	{
       
   429     FLOG( "[OMADM] CNSmlDMSyncAppUi::ShowErrorNoteL:" );
       
   430 
       
   431 	TBuf<KNSmlMaxTextLength256> errMsg;	
       
   432 	SetErrorMessageL( aError, errMsg );	
       
   433 	CAknInformationNote* queryDialog = new (ELeave) CAknInformationNote;
       
   434 	queryDialog->ExecuteLD( errMsg );
       
   435     FLOG( "[OMADM] CNSmlDMSyncAppUi::ShowErrorNoteL() completed" );
       
   436 	}
       
   437 
       
   438 // -----------------------------------------------------------------------------
       
   439 // CNSmlDMSyncAppUi::SetErrorMessageL
       
   440 // -----------------------------------------------------------------------------
       
   441 //
       
   442 void CNSmlDMSyncAppUi::SetErrorMessageL( TInt aError, TDes& aMsg ) const
       
   443 	{
       
   444     FLOG( "[OMADM] CNSmlDMSyncAppUi::SetErrorMessageL:" );
       
   445     CTextResolver* textResolver = CTextResolver::NewLC();
       
   446     
       
   447     aMsg.Append( textResolver->ResolveErrorString( aError,
       
   448 	                                         CTextResolver::ECtxNoCtx ) );
       
   449 	
       
   450 	CleanupStack::PopAndDestroy( textResolver );
       
   451 
       
   452 	HBufC* appTitle = iEikonEnv->AllocReadResourceLC( R_SML_APP_TITLE );
       
   453 	aMsg.Insert( 0, appTitle->Des() );
       
   454 	CleanupStack::PopAndDestroy( appTitle );
       
   455     FTRACE( FPrint(
       
   456         _L("[OMADM] CNSmlDMSyncAppUi::SetErrorMessageL() completed, aError = %d, aMsg ="),
       
   457         aError ) );
       
   458     FTRACE( FPrint(
       
   459         _L("[OMADM] \"%S\""),
       
   460         &aMsg ) );
       
   461 	}
       
   462 
       
   463 // -----------------------------------------------------------------------------
       
   464 // CNSmlDMSyncAppUi::HelpContextL
       
   465 // -----------------------------------------------------------------------------
       
   466 //
       
   467 
       
   468 CArrayFix<TCoeHelpContext>* CNSmlDMSyncAppUi::HelpContextL() const
       
   469 	{
       
   470 	CArrayFixFlat<TCoeHelpContext>* array = 
       
   471 	                            new (ELeave) CArrayFixFlat<TCoeHelpContext>(1);
       
   472 	array->AppendL( TCoeHelpContext( KUidSmlSyncApp, KDM_HLP_MAIN_VIEW ) );
       
   473 	array->AppendL( TCoeHelpContext( KUidSmlSyncApp, KFOTA_HLP_SETTINGS ) );
       
   474 	array->AppendL( TCoeHelpContext( KUidSmlSyncApp, KDM_HLP_SERVERS_VIEW ) );
       
   475 	array->AppendL( TCoeHelpContext( KUidSmlSyncApp, KDM_HLP_SETTINGS ) );
       
   476 	return array;
       
   477 	}
       
   478 
       
   479 
       
   480 // -----------------------------------------------------------------------------
       
   481 // CNSmlDMSyncAppUi::ShowResourceErrorNoteL
       
   482 // -----------------------------------------------------------------------------
       
   483 //
       
   484 void CNSmlDMSyncAppUi::ShowResourceErrorNoteL(TInt aResource) const
       
   485     {
       
   486     FLOG( "[OMADM] CNSmlDMSyncAppUi::ShowResourceErrorNoteL:" );
       
   487 
       
   488 	HBufC* errorText = iEikonEnv->AllocReadResourceLC( aResource );
       
   489 	CAknInformationNote* queryDialog = new (ELeave) CAknInformationNote;
       
   490 	queryDialog->ExecuteLD( errorText->Des() );
       
   491 	CleanupStack::PopAndDestroy( errorText );
       
   492 
       
   493     FLOG( "[OMADM] CNSmlDMSyncAppUi::ShowResourceErrorNoteL() completed" );
       
   494 	}
       
   495 
       
   496 // -----------------------------------------------------------------------------
       
   497 // CNSmlDMSyncAppUi::FotaModel
       
   498 // This function is included for header file compliance with the version that
       
   499 // implements the FOTA feature. Should not be created in any case and
       
   500 // therefore returns always NULL.
       
   501 // -----------------------------------------------------------------------------
       
   502 //
       
   503 CNSmlDMFotaModel* CNSmlDMSyncAppUi::FotaModel() const
       
   504     {
       
   505     return NULL;
       
   506     }
       
   507 
       
   508 // -----------------------------------------------------------------------------
       
   509 // CNSmlDMSyncAppUi::MarkFwUpdChangesStartL
       
   510 // This function is included for header file compliance with the version that
       
   511 // implements the FOTA feature. Does nothing here.
       
   512 // -----------------------------------------------------------------------------
       
   513 //
       
   514 void CNSmlDMSyncAppUi::MarkFwUpdChangesStartL()
       
   515     {
       
   516     }
       
   517 
       
   518 // -----------------------------------------------------------------------------
       
   519 // CNSmlDMSyncAppUi::FwUpdStatesChangedL
       
   520 // This function is included for header file compliance with the version that
       
   521 // implements the FOTA feature. Returns always EFalse.
       
   522 // -----------------------------------------------------------------------------
       
   523 //
       
   524 TBool CNSmlDMSyncAppUi::FwUpdStatesChangedL()
       
   525     {
       
   526     return EFalse;
       
   527     }
       
   528 
       
   529 // -----------------------------------------------------------------------------
       
   530 // CNSmlDMSyncAppUi::ShowConfirmationNoteL
       
   531 // -----------------------------------------------------------------------------
       
   532 //
       
   533 TBool CNSmlDMSyncAppUi::ShowConfirmationNoteL( TInt aResource ) const
       
   534     {
       
   535     FLOG( "[OMADM] CNSmlDMSyncAppUi::ShowConfirmationNoteL:" );
       
   536 
       
   537 	HBufC* queryText = iEikonEnv->AllocReadResourceLC( aResource );
       
   538 	CAknQueryDialog* queryDialog = new (ELeave) CAknQueryDialog();
       
   539 
       
   540 	TBool retValue = queryDialog->ExecuteLD( R_STARTQUERY_NOTE,
       
   541 	                                         queryText->Des() );
       
   542 	CleanupStack::PopAndDestroy( queryText );
       
   543     FTRACE( FPrint(
       
   544         _L("[OMADM] CNSmlDMSyncAppUi::ShowConfirmationNoteL() completed, retval = %d"),
       
   545         retValue ) );
       
   546 	return retValue;
       
   547 	}
       
   548 	
       
   549 // -----------------------------------------------------------------------------
       
   550 // CNSmlDMSyncAppUi::HandleCommandNewProfileL
       
   551 // -----------------------------------------------------------------------------
       
   552 //
       
   553 void CNSmlDMSyncAppUi::HandleCommandNewProfileL()
       
   554     {
       
   555     FLOG( "[OMADM] CNSmlDMSyncAppUi::HandleCommandNewProfileL:" );
       
   556     
       
   557 	if ( iSyncDocument->ProfileCount() != 0 )
       
   558 		{
       
   559 		HBufC* delQuery = StringLoader::LoadL( 
       
   560 		    R_QTN_SML_APPUI_COPY,
       
   561 		    iSyncDocument->ProfileItem()->iProfileName );
       
   562 		CleanupStack::PushL( delQuery );
       
   563 		
       
   564 		CAknQueryDialog* queryDialog = new (ELeave) CAknQueryDialog();
       
   565 		iDialogUp = 1;
       
   566 		
       
   567 		if ( queryDialog->ExecuteLD( R_STARTQUERY_NOTE, delQuery->Des() ) )  
       
   568 			{
       
   569 			iDialogUp = 0;
       
   570 			ShowEditProfileDialogL( ESmlCopyProfile );					
       
   571 			}
       
   572 		else
       
   573 			{
       
   574 			iDialogUp = 0;
       
   575 			ShowEditProfileDialogL( ESmlNewProfile );	
       
   576 			}
       
   577 		CleanupStack::PopAndDestroy( delQuery );
       
   578 		}
       
   579 	else
       
   580 		{
       
   581 		iDialogUp = 0;
       
   582 		ShowEditProfileDialogL( ESmlNewProfile );	
       
   583 		}
       
   584 	
       
   585     FLOG( "[OMADM] CNSmlDMSyncAppUi::HandleCommandNewProfileL() completed" );
       
   586     }
       
   587     
       
   588 // -----------------------------------------------------------------------------
       
   589 // CNSmlDMSyncAppUi::HandleCommandEraseProfileL
       
   590 // -----------------------------------------------------------------------------
       
   591 //
       
   592 void CNSmlDMSyncAppUi::HandleCommandEraseProfileL()
       
   593     {
       
   594     FLOG( "[OMADM] CNSmlDMSyncAppUi::HandleCommandEraseProfileL:" );
       
   595     
       
   596 	HBufC* delQuery = StringLoader::LoadL(
       
   597 	    R_SML_APPUI_NOTE_TEXT_DEL,
       
   598 	    iSyncDocument->ProfileItem()->iProfileName );
       
   599 	CleanupStack::PushL( delQuery );
       
   600 	
       
   601 	CAknQueryDialog* queryDialog = new (ELeave) CAknQueryDialog( );
       
   602 	iDialogUp = 1;
       
   603 
       
   604 	if ( queryDialog->ExecuteLD( R_STARTQUERY_NOTE, delQuery->Des() ) ) 
       
   605 		{
       
   606 		TInt index = 0;
       
   607 		TInt result = iSyncDocument->DeleteProfile( index );
       
   608 		if ( result == KErrNone )
       
   609 			{
       
   610             iProfilesView->RefreshL();
       
   611 			}
       
   612 		else
       
   613 			{
       
   614 			ShowErrorNoteL( result );
       
   615 			}
       
   616 		}
       
   617 	iDialogUp = 0;
       
   618 	iBusy = EFalse;
       
   619 	CleanupStack::PopAndDestroy( delQuery );
       
   620     FLOG( "[OMADM] CNSmlDMSyncAppUi::HandleCommandEraseProfileL() completed" );
       
   621     }
       
   622     
       
   623 // -----------------------------------------------------------------------------
       
   624 // CNSmlDMSyncAppUi::Synchronise
       
   625 // -----------------------------------------------------------------------------
       
   626 //
       
   627 TBool CNSmlDMSyncAppUi::Synchronise()
       
   628     {
       
   629     FLOG( "[OMADM] CNSmlDMSyncAppUi::Synchronise:" );
       
   630     return iSyncAppEngine->SyncRunning();
       
   631     }
       
   632     
       
   633 // -----------------------------------------------------------------------------
       
   634 // CNSmlDMSyncAppUi::SyncComplete
       
   635 // -----------------------------------------------------------------------------
       
   636 //
       
   637 void CNSmlDMSyncAppUi::SyncComplete( TNSmlStatus aStatus )
       
   638     {
       
   639     FLOG( "[OMADM] CNSmlDMSyncAppUi::SyncComplete()" );
       
   640 
       
   641     TRAP_IGNORE( iSyncDocument->RefreshProfileListL() );
       
   642     // The listbox should get at least an empty array in any case, so
       
   643     // the result checking is not needed.
       
   644     TRAP_IGNORE( iProfilesView->RefreshL() );
       
   645 
       
   646     TInt Value;
       
   647     TInt r=RProperty::Get(KUidSmlSyncApp,0,Value);    
       
   648     if ( iSyncDocument->IsServerAlertSync() && Value == 1) //for Server alert launch case    
       
   649         {
       
   650         FLOG(  "[OMADM] CNSmlDMSyncAppUi::SyncComplete: RunAppShutter" );
       
   651         CAknEnv::Static()->RunAppShutter();        
       
   652         }      
       
   653 
       
   654     }
       
   655 
       
   656 // -----------------------------------------------------------------------------
       
   657 // CNSmlDMSyncAppUi::CloseGs
       
   658 // -----------------------------------------------------------------------------
       
   659 //
       
   660 void CNSmlDMSyncAppUi::CloseGs()
       
   661     {    
       
   662     TApaTaskList taskList( CEikonEnv::Static()->WsSession() );
       
   663     TApaTask task(taskList.FindApp( KUidSmlSyncApp ) );
       
   664     task.SetWgId( CEikonEnv::Static()->RootWin().Identifier() ); 
       
   665     task.SendToBackground();
       
   666     CAknEnv::Static()->RunAppShutter();	
       
   667     }
       
   668 
       
   669 
       
   670 // -----------------------------------------------------------------------------
       
   671 // CNSmlDMSyncAppUi::ExitCallL
       
   672 // -----------------------------------------------------------------------------
       
   673 //
       
   674 void CNSmlDMSyncAppUi::ExitCallL( )
       
   675     {
       
   676     //Dummy Should not be used if fota disabled
       
   677     }
       
   678     
       
   679 // -----------------------------------------------------------------------------
       
   680 // CNSmlDMSyncAppUi::CheckFotaDlL
       
   681 // -----------------------------------------------------------------------------
       
   682 //
       
   683 void CNSmlDMSyncAppUi::CheckFotaDlL()
       
   684 	{
       
   685 	//Dummy Should not be used if fota disabled
       
   686 	}
       
   687 
       
   688 void CNSmlDMSyncAppUi::CheckAMDlL()
       
   689   {
       
   690   	
       
   691   	FLOG( "CNSmlDMSyncAppUi::CheckAMDlL : Start" );
       
   692   	const TUid KAppMgmtServerUid = {0x1020781C};
       
   693 	
       
   694             
       
   695             TInt silentoperation = 1;
       
   696         	RProperty::Get( KPSUidNSmlDMSyncApp,
       
   697                 				    KServerAlertType,
       
   698                     				silentoperation);
       
   699 	    
       
   700 	 	
       
   701 	 	const TUint KAMServerUIEnabled = 0x00001;
       
   702 	 	TInt newValue;
       
   703 		TInt err = RProperty::Get(KAppMgmtServerUid, KAMServerUIEnabled, newValue);
       
   704 		
       
   705 		if(!err && newValue && (silentoperation==KErrNotFound || silentoperation==1))
       
   706 		{
       
   707 	    FLOG( "CNSmlDMSyncAppUi::CheckAMDlL : Entered:" );
       
   708 	    
       
   709 	    if(silentoperation ==0)
       
   710 	    FLOG( "CNSmlDMSyncAppUi::CheckAMDlL :silentoperation ==0" );
       
   711 	    else
       
   712 	    FLOG( "CNSmlDMSyncAppUi::CheckAMDlL :silentoperation not equal to 0" );
       
   713 			
       
   714 			TApaTaskList taskList( CEikonEnv::Static()->WsSession() );
       
   715     		TApaTask task = taskList.FindApp(KAppMgmtServerUid );
       
   716     
       
   717     		if(task.Exists())
       
   718     		{
       
   719     		  FLOG( "CNSmlDMSyncAppUi::CheckAMDlL :task.Exists() : BringToForeground" );
       
   720         	task.BringToForeground();
       
   721         }      
       
   722      } 
       
   723   	
       
   724   }
       
   725 // End of File