locationsystemui/locationsysui/locsuplsettingsui/src/locsuplsessioneditor.cpp
changeset 0 667063e416a2
child 4 42de37ce7ce4
equal deleted inserted replaced
-1:000000000000 0:667063e416a2
       
     1 /*
       
     2 * Copyright (c) 2008 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:  Implements the CLocSUPLSessionEditor class
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 
       
    20 #include <aknappui.h>
       
    21 #include <AknIconArray.h>       // Icon Array
       
    22 #include <AknsUtils.h>
       
    23 #include <AknsSkinInstance.h>
       
    24 #include <akntitle.h>       	// CAknTitlePane
       
    25 #include <avkon.rsg>
       
    26 #include <avkon.hrh>
       
    27 #include <e32math.h>
       
    28 #include <eikapp.h>
       
    29 #include <eikaufty.h>
       
    30 #include <eikcapc.h>
       
    31 #include <eikedwin.h>
       
    32 #include <eikenv.h>
       
    33 #include <eikmenup.h>
       
    34 #include <eikmenub.h>
       
    35 #include <eikspane.h>       	// Status pane
       
    36 #include <barsread.h>           // For TResourceReader
       
    37 #include <bautils.h> 
       
    38 #include <AknQueryDialog.h>
       
    39 #include <data_caging_path_literals.hrh>
       
    40 #include <gulicon.h>            // Gul Icon
       
    41 #include <StringLoader.h>
       
    42 
       
    43 #include <epos_csuplsettingsconstants.h>
       
    44 #include <epos_csuplsettingparams.h>
       
    45 
       
    46 #include <locsuplsettingsui.rsg>
       
    47 #include "locsuplsettings.hrh"
       
    48 #include "locsuplsessioneditor.h"
       
    49 #include "locsuplsettingsuiengine.h"
       
    50 #include "locsupldebug.h"
       
    51 
       
    52 // Constants
       
    53 const TInt KMinToSecs = 60;
       
    54 const TInt KHrToSecs  = 3600;
       
    55 const TInt KdayToSecs = 86400;
       
    56 const TInt KRealWidth = 50;
       
    57 
       
    58 // ============================ LOCAL FUNCTIONS ===============================
       
    59 
       
    60 // ============================ MEMBER FUNCTIONS ===============================
       
    61 
       
    62 // -----------------------------------------------------------------------------
       
    63 // CLocSUPLSessionEditor::CLocSUPLSessionEditor
       
    64 // -----------------------------------------------------------------------------
       
    65 //
       
    66 CLocSUPLSessionEditor::CLocSUPLSessionEditor( 
       
    67                             CLocSUPLSettingsUiEngine&       aEngine,
       
    68         					TInt64 aSessionId
       
    69 		):iEngine( aEngine ), iSessionId( aSessionId )
       
    70     {  	
       
    71     }
       
    72 
       
    73 // -----------------------------------------------------------------------------
       
    74 // CLocSUPLSessionEditor::ConstructL
       
    75 // -----------------------------------------------------------------------------
       
    76 //
       
    77 void CLocSUPLSessionEditor::ConstructL()
       
    78     {
       
    79 	DEBUG( + CLocSUPLSessionEditor::ConstructL );
       
    80     CAknForm::ConstructL( R_SUPLSESSION_EDITOR_MENU_BAR );
       
    81 
       
    82     // Save original title
       
    83     CEikStatusPane* statusPane = iAvkonAppUi->StatusPane();
       
    84     iTitlePane = ( CAknTitlePane* ) statusPane->ControlL(
       
    85         TUid::Uid( EEikStatusPaneUidTitle ) );
       
    86     iOriginalTitle = iTitlePane->Text()->AllocL();
       
    87 
       
    88     iSessionName = HBufC::NewL( KMaxTriggerSessionNameLen ); 
       
    89     
       
    90     // Set Session Observer
       
    91     iEngine.SetSessionObserver( this );
       
    92 	
       
    93 	DEBUG( - CLocSUPLSessionEditor::ConstructL );
       
    94     }
       
    95 
       
    96 // -----------------------------------------------------------------------------
       
    97 // CLocSUPLSessionEditor::NewL
       
    98 // -----------------------------------------------------------------------------
       
    99 //
       
   100 CLocSUPLSessionEditor* CLocSUPLSessionEditor::NewL( 
       
   101                             CLocSUPLSettingsUiEngine&       aEngine,
       
   102         					TInt64 aSessionId
       
   103 		)
       
   104 	{	
       
   105     CLocSUPLSessionEditor* self = NewLC( aEngine, aSessionId );
       
   106 	CleanupStack::Pop( self );
       
   107 	return self;
       
   108 	}
       
   109 
       
   110 // -----------------------------------------------------------------------------
       
   111 // CLocSUPLSessionEditor::NewLC
       
   112 // -----------------------------------------------------------------------------
       
   113 //
       
   114 CLocSUPLSessionEditor* CLocSUPLSessionEditor::NewLC( 
       
   115                             CLocSUPLSettingsUiEngine&       aEngine,
       
   116         					TInt64 aSessionId
       
   117 		)
       
   118     {
       
   119     CLocSUPLSessionEditor* self = new ( ELeave ) 
       
   120     			CLocSUPLSessionEditor( aEngine, aSessionId );
       
   121     CleanupStack::PushL( self );
       
   122     self->ConstructL();
       
   123     return self;
       
   124     }
       
   125 
       
   126 // -----------------------------------------------------------------------------
       
   127 // CLocSUPLSessionEditor::~CLocSUPLSessionEditor
       
   128 // -----------------------------------------------------------------------------
       
   129 //
       
   130 CLocSUPLSessionEditor::~CLocSUPLSessionEditor()
       
   131     {
       
   132 	DEBUG( + CLocSUPLSessionEditor::~CLocSUPLSessionEditor );
       
   133 	
       
   134 	// Delete Buffer
       
   135 	delete iSessionName;
       
   136 
       
   137 	// Remove the Observer set
       
   138 	iEngine.RemoveSessionObserver();
       
   139 	
       
   140     // Restore title pane. Ownership of iTitlePane transferred.
       
   141     if ( iTitlePane && iOriginalTitle )
       
   142         {
       
   143         iTitlePane->SetText( iOriginalTitle );
       
   144         }
       
   145 	
       
   146 	DEBUG( - CLocSUPLSessionEditor::~CLocSUPLSessionEditor );	
       
   147     }
       
   148 
       
   149 // -----------------------------------------------------------------------------
       
   150 // CLocSUPLSessionEditor::DynInitMenuPaneL
       
   151 // -----------------------------------------------------------------------------
       
   152 //
       
   153 void CLocSUPLSessionEditor::DynInitMenuPaneL(
       
   154     TInt aResourceId,
       
   155     CEikMenuPane* aMenuPane )
       
   156     {
       
   157 	DEBUG( + CLocSUPLSessionEditor::DynInitMenuPaneL );
       
   158     CAknForm::DynInitMenuPaneL( aResourceId, aMenuPane );
       
   159 
       
   160     if ( aResourceId == R_AVKON_FORM_MENUPANE )
       
   161         {
       
   162         // We do not want to allow the user to modify our Form therefore
       
   163         // Disable the Label, Add, Delete, and Save Field
       
   164         aMenuPane->SetItemDimmed( EAknFormCmdLabel, ETrue );
       
   165         aMenuPane->SetItemDimmed( EAknFormCmdAdd, 	ETrue );
       
   166 		aMenuPane->SetItemDimmed( EAknFormCmdDelete,ETrue );
       
   167         aMenuPane->SetItemDimmed( EAknFormCmdSave, 	ETrue );
       
   168         aMenuPane->SetItemDimmed( EAknFormCmdEdit, 	ETrue );
       
   169 		
       
   170     	aMenuPane->SetItemDimmed( ELocSessionEditorTerminate, 	EFalse );	 	       			    	
       
   171         				
       
   172 		switch( IdOfFocusControl() )
       
   173 			{
       
   174 			case ELocSuplSessionNotificationStatus:
       
   175 				{
       
   176 				aMenuPane->SetItemDimmed( ELocSessionEditorChange, 	EFalse );
       
   177 				break;
       
   178 				}
       
   179 			case ELocSuplSessionType:
       
   180 			case ELocSuplSessionTimePeriod:
       
   181 			case ELocSuplSessionTriggerInterval:
       
   182 			case ELocSuplSessionOutstandingTrigger:
       
   183 			default:
       
   184 				{
       
   185 				aMenuPane->SetItemDimmed( ELocSessionEditorChange, 	ETrue );
       
   186 				break;
       
   187 				}
       
   188 			}			     
       
   189         }
       
   190 	DEBUG( - CLocSUPLSessionEditor::DynInitMenuPaneL );
       
   191     }
       
   192 
       
   193 // -----------------------------------------------------------------------------
       
   194 // CLocSUPLSessionEditor::ProcessCommandL
       
   195 // -----------------------------------------------------------------------------
       
   196 //
       
   197 void CLocSUPLSessionEditor::ProcessCommandL( TInt aCommandId )
       
   198 	{
       
   199 	DEBUG1( + CLocSUPLSessionEditor::ProcessCommandL aCommandId=%d, aCommandId );
       
   200 	CAknForm::ProcessCommandL( aCommandId );
       
   201 
       
   202 	switch ( aCommandId )
       
   203        	{
       
   204        	case ELocSessionEditorChange:
       
   205        		{
       
   206        		TBool status = ETrue;
       
   207             CAknPopupFieldText* notificationStatus =
       
   208                             (CAknPopupFieldText*)Control( ELocSuplSessionNotificationStatus );
       
   209             if(notificationStatus)
       
   210                 {          
       
   211                 if( notificationStatus->CurrentValueIndex() == 0 )
       
   212                     {
       
   213                     status = EFalse;
       
   214                     }
       
   215                 }
       
   216                   
       
   217        	    iEngine.ChangeNotificationStatusL( iSessionId, status );					
       
   218        		break;
       
   219        		}
       
   220        	case ELocSessionEditorTerminate:
       
   221        		{
       
   222        		if( DeleteConfirmationQueryL() )
       
   223        			{
       
   224        			iEngine.RemoveTriggerSessionL( iSessionId );
       
   225         		   // Return back to Session view
       
   226 	       		   TryExitL( EAknSoftkeyBack );
       
   227       			}       			
       
   228        		break;
       
   229        		}
       
   230        	case EAknCmdHelp:
       
   231        		{
       
   232        		break;
       
   233        		}
       
   234        	case EEikCmdExit:
       
   235        		{
       
   236        		// The Exit is handled by the Application UI
       
   237        		TryExitL( EEikCmdExit );
       
   238        		break;
       
   239        		}
       
   240 		default:
       
   241 			break;
       
   242        	}
       
   243 	DEBUG( - CLocSUPLSessionEditor::ProcessCommandL );
       
   244 	}
       
   245 	
       
   246 // -----------------------------------------------------------------------------
       
   247 // CLocSUPLSessionEditor::OfferKeyEventL
       
   248 // -----------------------------------------------------------------------------
       
   249 //
       
   250 TKeyResponse CLocSUPLSessionEditor::OfferKeyEventL( const TKeyEvent& aKeyEvent,
       
   251                                              TEventCode aType )
       
   252     {
       
   253 	DEBUG( CLocSUPLSessionEditor::OfferKeyEventL );
       
   254 	if ( aType == EEventKey )
       
   255 		{
       
   256 		if( aKeyEvent.iCode == EKeyBackspace )		
       
   257             {
       
   258         	ProcessCommandL( ELocSessionEditorTerminate );            	
       
   259         	return EKeyWasConsumed;
       
   260             }      
       
   261 
       
   262 		if ( aKeyEvent.iCode == EKeyEnter || aKeyEvent.iScanCode == EStdKeyEnter ) 
       
   263 			{
       
   264 		    if ( IdOfFocusControl() == ELocSuplSessionNotificationStatus )
       
   265 		    	{
       
   266 				ProcessCommandL( ELocSessionEditorChange );  	
       
   267         	    return EKeyWasConsumed;  	
       
   268 		    	}
       
   269 			}         
       
   270 		}
       
   271 		
       
   272     return CAknForm::OfferKeyEventL( aKeyEvent, aType );    
       
   273     }
       
   274     
       
   275 // ---------------------------------------------------------------------------
       
   276 // CLocSUPLSessionEditor ::OkToExitL()
       
   277 // ---------------------------------------------------------------------------
       
   278 //
       
   279 TBool CLocSUPLSessionEditor::OkToExitL( TInt aButtonId )
       
   280     {
       
   281 	DEBUG1( + CLocSUPLSessionEditor::OkToExitL aButtonId=%d, aButtonId );
       
   282     TBool retVal = EFalse;
       
   283     	
       
   284     switch( aButtonId )
       
   285         {
       
   286         case EAknSoftkeyChange:
       
   287         	{
       
   288         	ProcessCommandL( ELocSessionEditorChange );
       
   289         	break;
       
   290         	}
       
   291         case EAknSoftkeyOptions: //when LSK is pressed
       
   292             {
       
   293             //display menu specific to editor
       
   294             DisplayMenuL();
       
   295             break;
       
   296             }            
       
   297         case EAknSoftkeyBack: 
       
   298         case EEikCmdExit: 
       
   299             {
       
   300             //close editor            
       
   301             retVal = ETrue;
       
   302             break;
       
   303             }
       
   304         case ELocServerEditorNoCmd:
       
   305         default: // close editor in all other cases
       
   306             {
       
   307             break;
       
   308             }
       
   309         }
       
   310 	DEBUG1( - CLocSUPLSessionEditor::OkToExitL retVal=%d, retVal );
       
   311     return retVal;
       
   312     }
       
   313     
       
   314 // ---------------------------------------------------------------------------
       
   315 // CLocSUPLSessionEditor ::PreLayoutDynInitL()
       
   316 // ---------------------------------------------------------------------------
       
   317 //
       
   318 void CLocSUPLSessionEditor::PreLayoutDynInitL()
       
   319     {    
       
   320 	DEBUG( + CLocSUPLSessionEditor::PreLayoutDynInitL );
       
   321     CAknForm::PreLayoutDynInitL();
       
   322     
       
   323     //Load the values into the editor fields  
       
   324     LoadFormValuesFromDataL();
       
   325     
       
   326 	DEBUG( - CLocSUPLSessionEditor::PreLayoutDynInitL );
       
   327     }
       
   328 
       
   329 // ---------------------------------------------------------------------------
       
   330 // CLocSUPLSessionEditor ::PostLayoutDynInitL()
       
   331 // ---------------------------------------------------------------------------
       
   332 //
       
   333 void CLocSUPLSessionEditor::PostLayoutDynInitL()
       
   334     {
       
   335 	DEBUG( + CLocSUPLSessionEditor::PostLayoutDynInitL );
       
   336     CAknForm::PostLayoutDynInitL();   
       
   337 
       
   338     HandleMSKCaptionL();			    	
       
   339 	
       
   340 	DEBUG( - CLocSUPLSessionEditor::PostLayoutDynInitL );
       
   341     }
       
   342     
       
   343 // ---------------------------------------------------------------------------
       
   344 // CLocSUPLSessionEditor ::LineChangedL()
       
   345 // ---------------------------------------------------------------------------
       
   346 //
       
   347 void CLocSUPLSessionEditor::LineChangedL(TInt /*aControlId*/)
       
   348     {
       
   349     HandleMSKCaptionL(); 
       
   350     }
       
   351 
       
   352 // -----------------------------------------------------------------------------
       
   353 // CLocSUPLSessionEditor::ExecuteLD
       
   354 // -----------------------------------------------------------------------------
       
   355 //
       
   356 TInt CLocSUPLSessionEditor::ExecuteLD()
       
   357     {    
       
   358 	return CAknForm::ExecuteLD( R_SUPLSESSION_EDITOR_FORM_DIALOG );    	
       
   359     }
       
   360 
       
   361 // ---------------------------------------------------------------------------
       
   362 // CLocSUPLSessionEditor ::LoadFormValuesFromDataL()
       
   363 // Called when the form is executed and when the user chooses to discard changes
       
   364 // in QuerySaveChangesL (via  DoNotSaveFormDataL).
       
   365 // ---------------------------------------------------------------------------
       
   366 // 
       
   367 void CLocSUPLSessionEditor::LoadFormValuesFromDataL()
       
   368     {
       
   369 	DEBUG( + CLocSUPLSessionEditor::LoadFormValuesFromDataL );  
       
   370    	
       
   371     TUint64 outstandingTriggers = 0;
       
   372     TUint64 timeInterval = 0;
       
   373     TUint64 timePeriod = 0;
       
   374     TBool notificationPresent = EFalse;
       
   375     TBool triggerNotificationStatus = EFalse; 
       
   376     CTriggerParams::TTriggerType triggerType; 
       
   377     CTriggerParams::TRequestType requestType;
       
   378    	
       
   379     iSessionName->Des().Zero();
       
   380     
       
   381    	CTriggerParams *triggerParams = CTriggerParams::NewL();
       
   382    	CleanupStack::PushL( triggerParams );
       
   383    	
       
   384    	TInt err = KErrNone;
       
   385    	TRAP( err, iEngine.GetTriggerParamsL( iSessionId, triggerParams ) );
       
   386 	    		    
       
   387     if( !err )
       
   388         {
       
   389         triggerParams->Get(
       
   390 		    							iSessionId, 
       
   391 		    							iSessionName->Des(), 
       
   392 		    							notificationPresent, 
       
   393 		    							triggerNotificationStatus, 
       
   394 		    							triggerType,
       
   395 		    							requestType, 
       
   396 		    							outstandingTriggers, 
       
   397 		    							timeInterval);
       
   398     
       
   399         timePeriod = timeInterval * outstandingTriggers;
       
   400         }
       
   401     							
       
   402    	CleanupStack::PopAndDestroy( triggerParams );
       
   403    	
       
   404     // update the title pane caption
       
   405     if( !iSessionName->Length() )
       
   406         {
       
   407         HBufC* unknownString = StringLoader::LoadLC( R_LOC_SERVICES_TITLE_UNKNOWN ); 
       
   408         iSessionName->Des().Copy( *unknownString );
       
   409         CleanupStack::PopAndDestroy( unknownString );
       
   410         }
       
   411 
       
   412     ChangeTitlePaneTextL( *iSessionName ); 
       
   413 
       
   414     // Update the Editor Fields
       
   415     CAknPopupFieldText* notificationStatusPopupFieldText = 
       
   416     			( CAknPopupFieldText* ) Control( ELocSuplSessionNotificationStatus );
       
   417     if( notificationStatusPopupFieldText )
       
   418         {  
       
   419         if( triggerNotificationStatus  )
       
   420         	notificationStatusPopupFieldText->SetCurrentValueIndex( 0 );                  	
       
   421         else
       
   422         	notificationStatusPopupFieldText->SetCurrentValueIndex( 1 );    
       
   423         } 
       
   424 
       
   425     CAknPopupFieldText* typePopupFieldText = 
       
   426     			( CAknPopupFieldText* ) Control( ELocSuplSessionType );
       
   427     if( typePopupFieldText )
       
   428         {  
       
   429         typePopupFieldText->SetCurrentValueIndex( 0 );          
       
   430         }   
       
   431 
       
   432     CAknIntegerEdwin* outstandingTriggersEdwin = 
       
   433     			static_cast < CAknIntegerEdwin* > ( ControlOrNull( ELocSuplSessionOutstandingTrigger ) );           
       
   434     if( outstandingTriggersEdwin )
       
   435         { 
       
   436         outstandingTriggersEdwin->SetValueL( outstandingTriggers );
       
   437     	
       
   438     	outstandingTriggersEdwin->DrawNow();
       
   439         } 
       
   440    	
       
   441    	// Calculate the Time period
       
   442 	HBufC* periodString = NULL;
       
   443 	HBufC* intervalString = NULL;
       
   444 	GetTimeStringL( intervalString, timeInterval );
       
   445 	GetTimeStringL( periodString, timePeriod );
       
   446 	CleanupStack::PushL( periodString );
       
   447 	CleanupStack::PushL( intervalString );
       
   448 
       
   449     CEikEdwin* timePeriodEdwin = 
       
   450     			static_cast < CEikEdwin* > ( ControlOrNull( ELocSuplSessionTimePeriod ) );           
       
   451     if( timePeriodEdwin )
       
   452         { 
       
   453         timePeriodEdwin->SetTextL( periodString );
       
   454     	
       
   455     	timePeriodEdwin->DrawNow();
       
   456         }     
       
   457 
       
   458     CEikEdwin* timeIntervalEdwin = 
       
   459     			static_cast < CEikEdwin* > ( ControlOrNull( ELocSuplSessionTriggerInterval ) );           
       
   460     if( timeIntervalEdwin )
       
   461         { 
       
   462         timeIntervalEdwin->SetTextL( intervalString );
       
   463     	
       
   464     	timeIntervalEdwin->DrawNow();
       
   465         }                                 	
       
   466         
       
   467 	CleanupStack::PopAndDestroy( );	//	intervalString
       
   468 	CleanupStack::PopAndDestroy( );	//	periodString
       
   469 		
       
   470 	TBool menuShowing = MenuShowing();
       
   471 	if( menuShowing )
       
   472 	    HideMenu();
       
   473 	
       
   474     UpdatePageL( ETrue );
       
   475     
       
   476     if( menuShowing )
       
   477         DisplayMenuL();
       
   478 	DEBUG( - CLocSUPLSessionEditor::LoadFormValuesFromDataL );
       
   479     }
       
   480     
       
   481 // ---------------------------------------------------------------------------
       
   482 // CLocSUPLSessionEditor::ChangeTitlePaneTextL()
       
   483 // Set the Title Text
       
   484 // ---------------------------------------------------------------------------
       
   485 //
       
   486 void CLocSUPLSessionEditor::ChangeTitlePaneTextL( TDesC& aText )
       
   487     {
       
   488 	DEBUG( + CLocSUPLSessionEditor::ChangeTitlePaneTextL );
       
   489     // Obtain the title from the Status Pane
       
   490     CAknTitlePane* title = static_cast < CAknTitlePane* >( iEikonEnv->AppUiFactory()->
       
   491     	StatusPane()->ControlL( TUid::Uid( EEikStatusPaneUidTitle ) ) );
       
   492        
       
   493     // Set the Title's buffer    
       
   494     HBufC* buf = aText.AllocL();
       
   495     title->SetText( buf ); // Takes ownership of buf
       
   496     title->DrawNow();
       
   497 	DEBUG( - CLocSUPLSessionEditor::ChangeTitlePaneTextL );
       
   498     }     
       
   499 
       
   500 // ---------------------------------------------------------------------------
       
   501 // CLocSUPLSessionEditor::TogglePopupFieldControlL()
       
   502 // it toggles  value of popupfield control
       
   503 // ---------------------------------------------------------------------------
       
   504 //
       
   505 void CLocSUPLSessionEditor::TogglePopupFieldControlL( TInt aControlId )
       
   506     {
       
   507 	DEBUG( + CLocSUPLSessionEditor::TogglePopupFieldControlL );
       
   508     CAknPopupFieldText* popupFieldText =
       
   509                     		( CAknPopupFieldText* ) Control( aControlId );
       
   510                     		
       
   511 	if( popupFieldText )
       
   512 		{          
       
   513 		if( popupFieldText->CurrentValueIndex() == 0 )
       
   514 		  	popupFieldText->SetCurrentValueIndex( 1 );
       
   515 		else
       
   516 		  	popupFieldText->SetCurrentValueIndex( 0 );    
       
   517 
       
   518 		UpdatePageL( ETrue );
       
   519 		}
       
   520 	DEBUG( - CLocSUPLSessionEditor::TogglePopupFieldControlL );
       
   521     }
       
   522  
       
   523 // -----------------------------------------------------------------------------
       
   524 // CLocSUPLSessionEditor::HandleMSKCaptionL()
       
   525 // It changes caption of MSK key
       
   526 // -----------------------------------------------------------------------------
       
   527 //
       
   528 void CLocSUPLSessionEditor::HandleMSKCaptionL()
       
   529     {
       
   530 	DEBUG( + CLocSUPLSessionEditor::HandleMSKCaptionL );
       
   531     CEikButtonGroupContainer* cba = CEikButtonGroupContainer::Current();
       
   532     CleanupStack::PushL( cba );
       
   533     
       
   534     //attribute specific cba
       
   535 	switch ( IdOfFocusControl() )
       
   536        	{
       
   537 		case ELocSuplSessionNotificationStatus:
       
   538 			{
       
   539        		cba->SetCommandSetL( R_SUPLSESSION_EDITOR_OPTIONS_CHANGE_BACK );
       
   540 			break;
       
   541 			}
       
   542 		case ELocSuplSessionType:
       
   543 		case ELocSuplSessionTimePeriod:
       
   544 		case ELocSuplSessionTriggerInterval:
       
   545 		case ELocSuplSessionOutstandingTrigger:
       
   546 			{
       
   547        		cba->SetCommandSetL( R_SUPLSESSION_EDITOR_OPTIONS_NOMSK_BACK );
       
   548 			break;
       
   549 			}
       
   550 		default:
       
   551 			{
       
   552        		cba->SetCommandSetL( R_SUPLSESSION_EDITOR_OPTIONS_CHANGE_BACK );
       
   553 			break;
       
   554 			}
       
   555        	}	    	
       
   556     cba->DrawDeferred();    
       
   557     CleanupStack::Pop( cba );    
       
   558 	DEBUG( - CLocSUPLSessionEditor::HandleMSKCaptionL );
       
   559     }
       
   560 
       
   561 // -----------------------------------------------------------------------------
       
   562 // CLocSUPLSessionEditor::DeleteConfirmationQueryL
       
   563 // ----------------------------------------------------------------------------
       
   564 //
       
   565 TInt CLocSUPLSessionEditor::DeleteConfirmationQueryL()
       
   566     {    
       
   567     HBufC* noteText = NULL;    
       
   568     noteText = StringLoader::LoadLC( R_LOC_SUPL_QUERY_TERMINATE, *iSessionName, iEikonEnv );
       
   569     CAknQueryDialog* query = new( ELeave ) CAknQueryDialog( *noteText );    
       
   570     TInt ret = query->ExecuteLD( R_LOC_SUPL_DELETE_QUERY );
       
   571     CleanupStack::PopAndDestroy( noteText );   
       
   572     return ret;
       
   573     }
       
   574 	
       
   575 // -----------------------------------------------------------------------------
       
   576 // CLocSUPLSessionEditor::UpdateSessionL
       
   577 // Calls function to load the values into the editor fields  
       
   578 // ----------------------------------------------------------------------------
       
   579 //
       
   580 void CLocSUPLSessionEditor::UpdateSessionL( TUpdateType aType )
       
   581     {   	
       
   582     if( ESessionDeleted == aType )
       
   583         {
       
   584         TryExitL( EAknSoftkeyBack );
       
   585         }
       
   586     else
       
   587         {
       
   588         LoadFormValuesFromDataL();
       
   589         }
       
   590 	}
       
   591 	
       
   592 // -----------------------------------------------------------------------------
       
   593 // CLocSUPLSessionEditor::SessionId
       
   594 // Returns the session id
       
   595 // ----------------------------------------------------------------------------
       
   596 //
       
   597 TInt64 CLocSUPLSessionEditor::SessionId()
       
   598     {  
       
   599 	return iSessionId;
       
   600 	}
       
   601 	
       
   602 // -----------------------------------------------------------------------------
       
   603 // CLocSUPLSessionEditor::GetTimeStringL
       
   604 // -----------------------------------------------------------------------------
       
   605 //
       
   606 void CLocSUPLSessionEditor::GetTimeStringL(HBufC*& aTimeString, TUint aSeconds)
       
   607     {  
       
   608     TBuf<KRealWidth> tempString;
       
   609 
       
   610 	if( !aSeconds )
       
   611 		{
       
   612         tempString.Num(aSeconds);
       
   613         aTimeString = StringLoader::LoadL( R_LOC_SUPL_TRIGGER_TIME_MINUTES, tempString ); 
       
   614         return;
       
   615 		}
       
   616 		
       
   617 	TReal hrs = TReal(aSeconds)/KHrToSecs;
       
   618     TReal approxValue;
       
   619     TRealFormat fmt(KDefaultRealWidth, 2);
       
   620 	if( hrs < 1 )
       
   621 		{
       
   622 	    TReal mins = TReal(aSeconds)/KMinToSecs;
       
   623 		Math::Round( approxValue, mins, 2 );
       
   624         tempString.Num(approxValue, fmt);
       
   625         aTimeString = StringLoader::LoadL( R_LOC_SUPL_TRIGGER_TIME_MINUTES, tempString ); 
       
   626 		}
       
   627 	else if( hrs == 1 )
       
   628 		{
       
   629         aTimeString = StringLoader::LoadL( R_LOC_SUPL_TRIGGER_TIME_ONEHOUR ); 
       
   630 		}
       
   631 	else
       
   632 		{
       
   633 	    TReal days = TReal(aSeconds)/KdayToSecs;
       
   634     	if( days < 1 )
       
   635     		{
       
   636     		Math::Round( approxValue, hrs, 2 );
       
   637         	tempString.Num(approxValue, fmt);
       
   638             aTimeString = StringLoader::LoadL( R_LOC_SUPL_TRIGGER_TIME_HOURS, tempString ); 
       
   639     		}
       
   640     	else if( days == 1 )
       
   641     		{
       
   642             aTimeString = StringLoader::LoadL( R_LOC_SUPL_TRIGGER_TIME_ONEDAY ); 
       
   643     		}
       
   644     	else
       
   645     		{
       
   646     		Math::Round( approxValue, days, 2 );
       
   647         	tempString.Num(approxValue, fmt);
       
   648             aTimeString = StringLoader::LoadL( R_LOC_SUPL_TRIGGER_TIME_DAYS, tempString ); 
       
   649     		}
       
   650 		}
       
   651 	}
       
   652 
       
   653 // End of file