voiceui/voiceuivoicerecognition/src/vuicappui.cpp
changeset 13 57b735022c18
parent 1 b13cd05eeb2f
equal deleted inserted replaced
1:b13cd05eeb2f 13:57b735022c18
     1 /*
       
     2 * Copyright (c) 2007-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:  The Voice Recognition Application Ui
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 // INCLUDE FILES
       
    20 #include <featmgr.h>
       
    21 
       
    22 #include <e32property.h>
       
    23 #include <ScreensaverInternalPSKeys.h>
       
    24 #include <coreapplicationuisdomainpskeys.h>
       
    25 
       
    26 #include <vuivoicerecogdefs.h>
       
    27 
       
    28 #include "vuicappui.h"
       
    29 #include "vuicvoicerecogdialogimpl.h"
       
    30 
       
    31 #include "vuiccalldetector.h"
       
    32 #include "vuickeygrabber.h"
       
    33 #include "vuicfoldobserver.h"
       
    34 #include "vuicnotificationobserver.h"
       
    35 
       
    36 #include "rubydebug.h"
       
    37 
       
    38 // ================= MEMBER FUNCTIONS =======================
       
    39 //
       
    40 // ----------------------------------------------------------------------------
       
    41 // CAppUi::ConstructL()
       
    42 // ----------------------------------------------------------------------------
       
    43 //
       
    44 void CAppUi::ConstructL()
       
    45     {
       
    46     SetFullScreenApp( EFalse );
       
    47 
       
    48     BaseConstructL( EAknEnableSkin | EAknEnableMSK );
       
    49     
       
    50     // Sets up TLS, must be done before FeatureManager is used.
       
    51     FeatureManager::InitializeLibL();
       
    52     
       
    53     RProperty::Set( KPSUidScreenSaver, KScreenSaverAllowScreenSaver, 1 );
       
    54     RProperty::Set( KPSUidScreenSaver, KScreenSaverNoPowerSaveMode, 1 );
       
    55     RProperty::Set( KPSUidCoreApplicationUIs, KLightsControl, ELightsOn );
       
    56     
       
    57     iNotificationObserver = CNotificationObserver::NewL();
       
    58     
       
    59     iCallDetector = CCallDetector::NewL( this );
       
    60     iCallDetector->RequestNotification();
       
    61     
       
    62     iKeyGrabber = CKeyGrabber::NewL( this );
       
    63     
       
    64     if ( FeatureManager::FeatureSupported( KFeatureIdCoverDisplay ) )
       
    65 	    {
       
    66         iFoldObserver = CFoldObserver::NewL( this );
       
    67         }
       
    68     
       
    69     SetKeyEventFlags( CAknAppUiBase::EDisableSendKeyShort | CAknAppUiBase::EDisableSendKeyLong );
       
    70     
       
    71     iEikonEnv->SetAutoForwarding( ETrue );
       
    72     
       
    73     iRecognitionDialog = CVoiceRecognitionDialogImpl::NewL( this );
       
    74     
       
    75     iRecognitionDialog->ExecuteL();
       
    76     }
       
    77 
       
    78 // ----------------------------------------------------------------------------
       
    79 // CAppUi::~CAppUi()
       
    80 // Destructor
       
    81 // ----------------------------------------------------------------------------
       
    82 //
       
    83 CAppUi::~CAppUi() 
       
    84     {
       
    85     RProperty::Set( KPSUidScreenSaver, KScreenSaverNoPowerSaveMode, 0 );
       
    86     RProperty::Set( KPSUidScreenSaver, KScreenSaverAllowScreenSaver, 0 );
       
    87 
       
    88     FeatureManager::UnInitializeLib();
       
    89     
       
    90     delete iRecognitionDialog;
       
    91     
       
    92     delete iNotificationObserver;
       
    93     
       
    94     delete iKeyGrabber;
       
    95     delete iFoldObserver;
       
    96     
       
    97     if ( iCallDetector )
       
    98         {
       
    99         iCallDetector->Cancel();
       
   100         delete iCallDetector;
       
   101         }
       
   102     }
       
   103 
       
   104 // ----------------------------------------------------------------------------
       
   105 // CAppUi::DialogDismissed
       
   106 // ----------------------------------------------------------------------------
       
   107 //
       
   108 void CAppUi::DialogDismissed()
       
   109     {
       
   110     RUBY_DEBUG0( "CAppUi::DialogDismissed START" );
       
   111     
       
   112     TRAPD( error, HandleCommandL( EAknSoftkeyExit ) );
       
   113     if ( error != KErrNone )
       
   114         {
       
   115         Exit();
       
   116         }
       
   117     
       
   118     RUBY_DEBUG0( "CAppUi::DialogDismissed EXIT" );
       
   119     }
       
   120 
       
   121 // ----------------------------------------------------------------------------
       
   122 // CAppUi::DialogDismissedL
       
   123 // ----------------------------------------------------------------------------
       
   124 //    
       
   125 void CAppUi::CallDetectedL()
       
   126     {
       
   127     RUBY_DEBUG_BLOCK( "CAppUi::CallDetectedL" );
       
   128     
       
   129     HandleCommandL( EAknSoftkeyExit );
       
   130     }
       
   131 
       
   132 // ----------------------------------------------------------------------------
       
   133 // CAppUi::HandleKeypressL
       
   134 // ----------------------------------------------------------------------------
       
   135 //     
       
   136 void CAppUi::HandleKeypressL( TInt /*aSoftkey*/ )
       
   137     {
       
   138     RUBY_DEBUG_BLOCK( "CAppUi::HandleKeypressL" );
       
   139     
       
   140     HandleCommandL( EAknSoftkeyExit );
       
   141     }
       
   142 
       
   143 // ----------------------------------------------------------------------------
       
   144 // CAppUi::HandleCommandL
       
   145 // ----------------------------------------------------------------------------
       
   146 //
       
   147 void CAppUi::HandleCommandL( TInt aCommand )
       
   148     {
       
   149     RUBY_DEBUG_BLOCK( "CAppUi::HandleCommandL" );
       
   150     
       
   151     switch ( aCommand )
       
   152         {
       
   153         // Both exit commands should do the same thing
       
   154         case EEikCmdExit:
       
   155         case EAknSoftkeyExit:
       
   156             {
       
   157             Exit();
       
   158             break;
       
   159             }
       
   160             
       
   161         default:
       
   162             {
       
   163             CAknAppUi::HandleCommandL( aCommand );
       
   164             break;              
       
   165             }
       
   166         }
       
   167     }
       
   168 
       
   169 // -----------------------------------------------------------------------------
       
   170 // CAppUi::ProcessCommandParametersL
       
   171 // -----------------------------------------------------------------------------
       
   172 //         
       
   173 TBool CAppUi::ProcessCommandParametersL( CApaCommandLine& aCommandLine )
       
   174     {
       
   175     RUBY_DEBUG_BLOCK( "CAppUi::ProcessCommandParametersL" );
       
   176 
       
   177     TPtrC8 argumentPtr( aCommandLine.TailEnd() );
       
   178     
       
   179     if ( argumentPtr.Length() && !argumentPtr.Compare( KVoiceUiMode ) )
       
   180         {
       
   181         iEikonEnv->SetAutoForwarding( EFalse );
       
   182         iRecognitionDialog->SetOnlyCallsAllowed();
       
   183         }
       
   184 
       
   185     return ETrue;
       
   186     }
       
   187     
       
   188 // ----------------------------------------------------------------------------
       
   189 // CAppUi::PrepareToExit
       
   190 // ----------------------------------------------------------------------------
       
   191 //
       
   192 void CAppUi::PrepareToExit( )
       
   193     {
       
   194     RUBY_DEBUG0( "CAppUi::PrepareToExit START" );
       
   195 
       
   196     delete iRecognitionDialog;
       
   197     iRecognitionDialog = NULL;
       
   198     
       
   199     CAknAppUi::PrepareToExit();
       
   200     	 
       
   201 	RUBY_DEBUG0( "CAppUi::PrepareToExit Exit" );
       
   202     } 
       
   203 // End of File  
       
   204