simpsyconfigurator/src/simpsyuiappui.cpp
branchRCL_3
changeset 17 1fc85118c3ae
parent 16 8173571d354e
child 18 870918037e16
equal deleted inserted replaced
16:8173571d354e 17:1fc85118c3ae
     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:  Simulation PSY Configuration UI server application class.
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 // SYSTEM INCLUDES
       
    20 #include <eikenv.h>
       
    21 #include <eikapp.h>
       
    22 #include <aknenv.h>
       
    23 #include <AknForm.h>
       
    24 #include <AknWaitDialog.h>
       
    25 #include <StringLoader.h> // StringLoader
       
    26 #include <CAknFileSelectionDialog.h>
       
    27 #include <centralrepository.h>
       
    28 #include <lbspositioninfo.h>
       
    29 #include <simpsyui.rsg>
       
    30 #include <aknPopup.h>
       
    31 
       
    32 // USER INCLUDES
       
    33 #include "simpsyuiappui.h"
       
    34 #include "simpsyui.hrh"
       
    35 #include "simpsyuicontainer.h"
       
    36 #include "simpsyuiao.h"
       
    37 #include "simpsyfileselector.h"
       
    38 #include "SimulationPSYInternalCRKeys.h"
       
    39 
       
    40 
       
    41 // CONSTANT DEFINTIONS
       
    42 _LIT(KSelectDialogTitle, "Select file");
       
    43 	
       
    44 // ---------------------------------------------------------
       
    45 // CSimPsyUiAppUi::CSimPsyUiAppUi
       
    46 // ---------------------------------------------------------
       
    47 //
       
    48 CSimPsyUiAppUi::CSimPsyUiAppUi()
       
    49 	{
       
    50 	}
       
    51 
       
    52 // ---------------------------------------------------------
       
    53 // CSimPsyUiAppUi::~CSimPsyUiAppUi
       
    54 // ---------------------------------------------------------
       
    55 //
       
    56 CSimPsyUiAppUi::~CSimPsyUiAppUi()
       
    57 	{				
       
    58     if (iAppContainer)
       
    59         {
       
    60         RemoveFromStack(iAppContainer);
       
    61         delete iAppContainer;
       
    62         }
       
    63     
       
    64     if ( iWaitDialog )
       
    65         {
       
    66         TRAPD( err, iWaitDialog->ProcessFinishedL() );
       
    67         if (err != KErrNone)
       
    68     		{
       
    69 			delete iWaitDialog;
       
    70 			iWaitDialog = NULL;
       
    71 			}
       
    72 	    }
       
    73 	    	        
       
    74     delete iLocationRequestor;
       
    75     iLocationRequestor = NULL;        
       
    76 	}
       
    77 
       
    78 // ---------------------------------------------------------
       
    79 // void CSimPsyUiAppUi::ConstructL
       
    80 // ---------------------------------------------------------
       
    81 //
       
    82 void CSimPsyUiAppUi::ConstructL()
       
    83     {
       
    84     BaseConstructL( EAknEnableSkin | EAknEnableMSK );
       
    85     iAppContainer = new (ELeave) CSimPsyUiContainer ;
       
    86     iAppContainer->ConstructL( ClientRect() , this) ;
       
    87     AddToStackL( iAppContainer );
       
    88     
       
    89     iLocationRequestor = CSimPsyUiAO::NewL( *this );    
       
    90     }
       
    91 
       
    92 // ---------------------------------------------------------
       
    93 // void CSimPsyUiAppUi::DynInitMenuPaneL
       
    94 // ---------------------------------------------------------
       
    95 //	
       
    96 void CSimPsyUiAppUi::DynInitMenuPaneL(
       
    97     TInt /*aResourceId*/,CEikMenuPane* /*aMenuPane*/)
       
    98     {
       
    99     }
       
   100 
       
   101 // ---------------------------------------------------------
       
   102 // TKeyResponse CSimPsyUiAppUi::HandleKeyEventL
       
   103 // ---------------------------------------------------------
       
   104 //
       
   105 TKeyResponse CSimPsyUiAppUi::HandleKeyEventL(
       
   106     const TKeyEvent& /*aKeyEvent*/,TEventCode /*aType*/)
       
   107     {
       
   108     return EKeyWasNotConsumed;
       
   109     }
       
   110 
       
   111 // ---------------------------------------------------------
       
   112 // void CSimPsyUiAppUi::HandleCommandL
       
   113 // ---------------------------------------------------------
       
   114 //
       
   115 void CSimPsyUiAppUi::HandleCommandL( TInt aCommand )
       
   116     {
       
   117     switch ( aCommand )
       
   118         {
       
   119         case EAknSoftkeyExit:
       
   120         case EAknSoftkeyBack:  
       
   121         case EEikCmdExit:
       
   122             {
       
   123             PrepareToExit();
       
   124             Exit();
       
   125             break;
       
   126             }
       
   127         case EAknSoftkeySelect:
       
   128         case ESimCmdConfigFile:
       
   129         	{                
       
   130 			// Code for launching new SimPSY file selector			
       
   131     		CSimPsyFileSelector* fileSelector = new ( ELeave ) CSimPsyFileSelector();
       
   132 			CleanupStack::PushL( fileSelector );
       
   133 			    		
       
   134     		// Construct the popup with the list
       
   135     		CAknPopupList* popup = CAknPopupList::NewL( fileSelector, 
       
   136                                   						R_AVKON_SOFTKEYS_SELECT_CANCEL__SELECT,
       
   137                                   						AknPopupLayouts::EMenuGraphicWindow );
       
   138 			CleanupStack::PushL( popup );                                  						                                  						  
       
   139     		fileSelector->ConstructL( popup );
       
   140     	    popup->SetTitleL( KSelectDialogTitle );
       
   141     	    CleanupStack::Pop( popup );
       
   142     	    
       
   143     		// Display the pop-up and let user selection.                             
       
   144     		TInt popupOk = popup->ExecuteLD();
       
   145             if ( popupOk )
       
   146         		{          
       
   147         		HBufC* fileName = NULL;
       
   148         		TRAPD( error, fileName = fileSelector->SimulationFileNameL().AllocL());
       
   149         		if ( !error )
       
   150         		    {
       
   151             		CleanupStack::PushL( fileName );
       
   152             		
       
   153                     // The full filename with path is stored in the cenrep file.
       
   154     				RDebug::Print(_L("SimPsyConfigurator: Setting Cenrep Key\n"));
       
   155     				CRepository* repository = CRepository::NewLC( KCRUidSimulationPSY );
       
   156     				repository->Set( KCRKeySimPSYSimulationFile, *fileName );
       
   157     				CleanupStack::PopAndDestroy( repository );
       
   158     				
       
   159     				// Update the SimPsyConfigurator listbox
       
   160     				iAppContainer->UpdateListBox();
       
   161     				    				        		
       
   162             		CleanupStack::PopAndDestroy( fileName );        		    
       
   163         		    }
       
   164         		}
       
   165 			CleanupStack::PopAndDestroy( fileSelector );      			                
       
   166             break;       	
       
   167         	}
       
   168         case ESimCmdGetCurrentLocation:
       
   169         	{
       
   170 			
       
   171 	        // Obtain the Location information asynchrnously
       
   172 	        TRAPD( err, iLocationRequestor->GetCurrentLocationL()); 	        
       
   173 	        if( !err )
       
   174 	            {
       
   175 	            iWaitDialog = new(ELeave) CAknWaitDialog( NULL, ETrue );
       
   176 	            iWaitDialog->SetCallback( this );
       
   177 			    if ( !iWaitDialog->ExecuteLD( R_SIMPSYUI_REQUEST_LOCATION ) )
       
   178     				{
       
   179     				//Set iWaitDialog to NULL on pressing Cancel 
       
   180     				iWaitDialog = NULL;
       
   181     				iLocationRequestor->CancelLocationRequest();
       
   182     				} 
       
   183 	            }	         
       
   184             break;
       
   185         	}
       
   186         default:
       
   187             break;      
       
   188         }
       
   189     }	
       
   190 
       
   191 // ---------------------------------------------------------------------------
       
   192 // void CSimPsyUiAppUi::NotifyLocationRequestCompletedL
       
   193 // ---------------------------------------------------------------------------
       
   194 //
       
   195 void CSimPsyUiAppUi::NotifyLocationRequestCompletedL()
       
   196     {
       
   197     // Dismiss the wait note.	
       
   198     if ( iWaitDialog )
       
   199         {
       
   200         TRAPD( err, iWaitDialog->ProcessFinishedL() );
       
   201         if (err != KErrNone)
       
   202     		{
       
   203 			delete iWaitDialog;
       
   204 			iWaitDialog = NULL;
       
   205 			}
       
   206 	    }
       
   207     }
       
   208 
       
   209 // ---------------------------------------------------------------------------
       
   210 // void CSimPsyUiAppUi::DialogDismissedL
       
   211 // ---------------------------------------------------------------------------
       
   212 //
       
   213 void CSimPsyUiAppUi::DialogDismissedL( TInt aButtonId )
       
   214     {
       
   215     if( EEikBidCancel != aButtonId )
       
   216         {
       
   217         // Display the current Location information to the user
       
   218         iLocationRequestor->DisplayCurrentLocationL();
       
   219         }
       
   220     }
       
   221     
       
   222