remotemgmt_plat/syncml_ds_error_reporting_api/tsrc/SyncStatusSpy/src/SyncStatusSpyAppUi.cpp
branchRCL_3
changeset 11 06f47423ecee
equal deleted inserted replaced
9:57a65a3a658c 11:06f47423ecee
       
     1 /*
       
     2 * Copyright (c) 2009 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 <eikmenub.h>
       
    20 #include <akncontext.h>
       
    21 #include <akntitle.h>
       
    22 #include <SyncStatusSpy.rsg>
       
    23 
       
    24 #include <bautils.h>				// BaflUtils
       
    25 #include <APGWGNAM.H> //CApaWindowGroupName
       
    26 #include <DataSyncInternalPSKeys.h>
       
    27 #include <NSmlConstants.h>
       
    28 #include <e32property.h>
       
    29 
       
    30 
       
    31 #include "SyncStatusSpyAppUi.h"
       
    32 #include "SyncStatusSpySettingItemList.h"
       
    33 #include "SyncStatusSpySettingItemList.hrh"
       
    34 
       
    35 #include "CenrepUtils.h"
       
    36 #include <apmstd.h> // TDataType
       
    37 
       
    38 /**
       
    39  * Construct the CSyncStatusSpyAppUi instance
       
    40  */ 
       
    41 CSyncStatusSpyAppUi::CSyncStatusSpyAppUi()
       
    42 	{
       
    43 	
       
    44 	}
       
    45 
       
    46 /** 
       
    47  * The appui's destructor removes the container from the control
       
    48  * stack and destroys it.
       
    49  */
       
    50 CSyncStatusSpyAppUi::~CSyncStatusSpyAppUi()
       
    51 	{
       
    52 	if ( iSyncStatusSpySettingItemList != NULL )
       
    53 		{
       
    54 		RemoveFromStack( iSyncStatusSpySettingItemList );
       
    55 		delete iSyncStatusSpySettingItemList;
       
    56 		iSyncStatusSpySettingItemList = NULL;
       
    57 		delete iSettings;
       
    58 		iSettings = NULL;
       
    59 		}
       
    60 	delete iDocHandler;
       
    61 	}
       
    62 
       
    63 /**
       
    64  * @brief Completes the second phase of Symbian object construction. 
       
    65  * Put initialization code that could leave here. 
       
    66  */ 
       
    67 void CSyncStatusSpyAppUi::ConstructL()
       
    68 	{
       
    69 	
       
    70 	BaseConstructL( EAknEnableSkin  | 
       
    71 					 EAknEnableMSK ); 
       
    72 	InitializeContainersL();
       
    73 
       
    74 	CCenrepUtils::CreateSyncLogDirL();
       
    75 	iDocHandler = CDocumentHandler::NewL();
       
    76 	
       
    77 	// security policies for P&S reading and writing
       
    78 	_LIT_SECURITY_POLICY_PASS( KNSmlPSWritePolicy ); // no checks done when writing
       
    79 	_LIT_SECURITY_POLICY_PASS( KNSmlPSReadPolicy ); // no checks done when reading
       
    80 		
       
    81 	// Define P&S data field for sync ON/OFF flag (may fail e.g. if exists already)
       
    82 	RProperty::Define( KPSUidDataSynchronizationInternalKeys, // category
       
    83                        KDataSyncStatus, // field
       
    84                        RProperty::EInt, // type
       
    85                        KNSmlPSReadPolicy, // read policy
       
    86                        KNSmlPSWritePolicy ); // write policy
       
    87 	}
       
    88 
       
    89 
       
    90 void CSyncStatusSpyAppUi::InitializeContainersL()
       
    91 	{
       
    92 	iSettings = CSyncStatusSpySettingItemListSettings::NewL();
       
    93 	iSyncStatusSpySettingItemList = new ( ELeave ) CSyncStatusSpySettingItemList( *iSettings, this );
       
    94 	iSyncStatusSpySettingItemList->SetMopParent( this );
       
    95 	iSyncStatusSpySettingItemList->ConstructFromResourceL( R_SYNC_STATUS_SPY_SETTING_ITEM_LIST_SYNC_STATUS_SPY_SETTING_ITEM_LIST );
       
    96 	iSyncStatusSpySettingItemList->ActivateL();
       
    97 	AddToStackL( iSyncStatusSpySettingItemList );
       
    98 	}
       
    99 
       
   100 
       
   101 /**
       
   102  * Handle a command for this appui (override)
       
   103  * @param aCommand command id to be handled
       
   104  */
       
   105 void CSyncStatusSpyAppUi::HandleCommandL( TInt aCommand )
       
   106 	{
       
   107 	_LIT( KPrivateFile,"C:\\logs\\Sync\\SyncStatus.txt" );
       
   108 	TBool commandHandled = EFalse;
       
   109 	
       
   110 	switch ( aCommand )
       
   111 		{ // code to dispatch to the AppUi's menu and CBA commands is generated here
       
   112 		case ESyncStatusSpyAppUiPublishMenuItemCommand:
       
   113 	        RProperty::Set( KPSUidDataSynchronizationInternalKeys,
       
   114 							KDataSyncStatus,
       
   115 							EDataSyncRunning12 );	
       
   116 	        
       
   117 	        // Set sync stopped to P&S
       
   118 	        RProperty::Set( KPSUidDataSynchronizationInternalKeys, KDataSyncStatus, EDataSyncNotRunning );
       
   119 	        commandHandled = ETrue;
       
   120 			break;
       
   121 		
       
   122 		case ESyncStatusSpyAppUiView_logMenuItemCommand:
       
   123 		    {
       
   124 		    TDataType  empty;
       
   125 			iDocHandler->OpenFileEmbeddedL( KPrivateFile, empty );
       
   126 			commandHandled = ETrue;
       
   127 		    }
       
   128 			break;
       
   129 			
       
   130 		case ESyncStatusSpyAppUiHideMenuItemCommand:
       
   131 		    { 
       
   132 		    TApaTask task(iEikonEnv->WsSession( ));
       
   133 			 task.SetWgId(CEikonEnv::Static()->RootWin().Identifier());
       
   134 			 task.SendToBackground(); 
       
   135 			 commandHandled = ETrue;
       
   136 		    }
       
   137 			break;
       
   138 			
       
   139 		case ESyncStatusSpyAppUiDelete_logMenuItemCommand:
       
   140 			CCenrepUtils::ClearSyncLogL();
       
   141 			commandHandled = ETrue;
       
   142 			break;
       
   143 			
       
   144 		default:
       
   145 			break;
       
   146 		}
       
   147 	
       
   148 		
       
   149 	if ( !commandHandled ) 
       
   150 		{
       
   151 		if ( aCommand == EAknSoftkeyExit || aCommand == EEikCmdExit )
       
   152 			{
       
   153 			Exit();
       
   154 			}
       
   155 		}
       
   156 	}
       
   157 
       
   158 /** 
       
   159  * Override of the HandleResourceChangeL virtual function
       
   160  */
       
   161 void CSyncStatusSpyAppUi::HandleResourceChangeL( TInt aType )
       
   162 	{
       
   163 	CAknAppUi::HandleResourceChangeL( aType );
       
   164 
       
   165 	}
       
   166 
       
   167 /** 
       
   168  * Override of the HandleForegroundEventL virtual function
       
   169  */
       
   170 void CSyncStatusSpyAppUi::HandleForegroundEventL(TBool aForeground)
       
   171 	{
       
   172 	// Call Base class method
       
   173 	CAknAppUi::HandleForegroundEventL(aForeground);
       
   174 
       
   175 	if(aForeground)
       
   176 		{
       
   177 		iSyncStatusSpySettingItemList->LoadSettingValuesL();
       
   178 		iSyncStatusSpySettingItemList->LoadSettingsL();
       
   179 		iSyncStatusSpySettingItemList->DrawDeferred();
       
   180         }
       
   181 	}