testexecfw/statsrv/device/source/statapi/src/stat_application.cpp
changeset 0 3e07fef1e154
equal deleted inserted replaced
-1:000000000000 0:3e07fef1e154
       
     1 /*
       
     2 * Copyright (c) 2005-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 
       
    20  /*************************************************************************
       
    21  *
       
    22  * System Includes
       
    23  *
       
    24  *************************************************************************/
       
    25 #include <e32std.h> 
       
    26 #include <eikstart.h> 
       
    27 
       
    28 /*************************************************************************
       
    29  *
       
    30  * Local Includes
       
    31  *
       
    32  *************************************************************************/
       
    33 #include <statgui.rsg>
       
    34 #include "stat_application.h"
       
    35 #include "stat_window.h"
       
    36 #ifdef SYMBIAN_DIST_SERIES60
       
    37 #include <avkon.hrh>
       
    38 #endif
       
    39 
       
    40 /*************************************************************************
       
    41  *
       
    42  * Definitions
       
    43  *
       
    44  *************************************************************************/
       
    45 const TUid KUidStat = { 0x10009B04 }; 
       
    46 #define IS_COMMAND_CHAR(c) ((c == 'A') || (c == 'C'))
       
    47 
       
    48 /*************************************************************************
       
    49  *
       
    50  * Prototypes
       
    51  *
       
    52  *************************************************************************/
       
    53 char *lstrchr( char *str, char chr );
       
    54 
       
    55 /*************************************************************************
       
    56  *
       
    57  * Application entry-point
       
    58  *
       
    59  *************************************************************************/
       
    60 LOCAL_C CApaApplication* NewApplication()
       
    61 {
       
    62 	return new CStatApplication;
       
    63 }
       
    64 
       
    65 GLDEF_C TInt E32Main()
       
    66 {
       
    67 	return EikStart::RunApplication(NewApplication);
       
    68 }
       
    69 
       
    70 
       
    71 /*************************************************************************
       
    72  *
       
    73  * Top-level Application Implementation
       
    74  *
       
    75  *************************************************************************/
       
    76 TUid CStatApplication::AppDllUid() const
       
    77 {
       
    78 	return KUidStat;
       
    79 }
       
    80 
       
    81 CApaDocument* CStatApplication::CreateDocumentL()
       
    82 {
       
    83 	return new (ELeave) CStatDocument(*this);
       
    84 }
       
    85 
       
    86 /*************************************************************************
       
    87  *
       
    88  * Document Class - no real work in this application
       
    89  *
       
    90  *************************************************************************/
       
    91 CStatDocument::CStatDocument(CEikApplication& aApp) : CEikDocument(aApp)
       
    92 {
       
    93 }
       
    94 
       
    95 CEikAppUi* CStatDocument::CreateAppUiL()
       
    96 {
       
    97 	return new(ELeave) CStatAppUi;
       
    98 }
       
    99 
       
   100 /*************************************************************************
       
   101  *
       
   102  * CStatAppUI
       
   103  *
       
   104  *************************************************************************/
       
   105 void CStatAppUi::ConstructL()
       
   106 {
       
   107     BaseConstructL();
       
   108 
       
   109 	// create the STAT controller
       
   110 	iController = CStatController::NewL(); 
       
   111 	iWindow = new(ELeave) CStatWindow();
       
   112 	iWindow->ConstructL( ClientRect(), iController );
       
   113 	iWindow->SetObserver( this );
       
   114 }
       
   115 
       
   116 CStatAppUi::~CStatAppUi()
       
   117 {
       
   118 	delete iWindow;
       
   119 	iWindow = NULL;
       
   120 	delete iController;
       
   121 	iController = NULL;
       
   122 }
       
   123 
       
   124 TKeyResponse CStatAppUi::HandleKeyEventL(const TKeyEvent& aKeyEvent,TEventCode aType)
       
   125 {
       
   126 	return iWindow->OfferKeyEventL( aKeyEvent, aType );
       
   127 }
       
   128 
       
   129 void CStatAppUi::HandleControlEventL( CCoeControl* /*aControl*/, TCoeEvent aEventType )
       
   130 {
       
   131 	if( aEventType == EEventRequestExit )
       
   132 		Exit();
       
   133 }
       
   134 
       
   135 void CStatAppUi::HandleCommandL( TInt aCommand )
       
   136 {
       
   137 	switch( aCommand ) {
       
   138 
       
   139 	case EStatCmdAction:
       
   140 		iWindow->HandleControlEventL( (CCoeControl*)KActionButton, MCoeControlObserver::EEventStateChanged );
       
   141 		break;
       
   142 	
       
   143 	case EAknSoftkeyExit:
       
   144 		iWindow->HandleControlEventL( (CCoeControl*)KExitButton, MCoeControlObserver::EEventStateChanged );
       
   145 		break;
       
   146 
       
   147 	case EStatCmdToggleLogging:
       
   148 		iWindow->HandleControlEventL( (CCoeControl*)KLogButton, MCoeControlObserver::EEventStateChanged );
       
   149 		break;
       
   150 	}
       
   151 }
       
   152 
       
   153 void CStatAppUi::HandleForegroundEventL( TBool aForeground )
       
   154 {
       
   155 	iWindow->SetForeground( aForeground );
       
   156 }
       
   157 
       
   158