examples/ForumNokia/AudioStreamExample/src/AudioStreamAppUi.cpp

00001 /*
00002  * Copyright � 2008 Nokia Corporation.
00003  */
00004 
00005 // INCLUDE FILES
00006 #include <avkon.hrh>
00007 #include <eikmenup.h>
00008 
00009 #include "AudioStreamAppUi.h"
00010 #include "AudioStreamView.h" 
00011 #include <AudioStream.rsg>
00012 #include "AudioStream.hrh"
00013 
00014 #include "AudioStreamEngine.h"
00015 
00016 
00017 // ----------------------------------------------------------------------------
00018 // CAudioStreamAppUi::ConstructL()
00019 //
00020 // standard EPOC 2nd phase constructor
00021 // ----------------------------------------------------------------------------
00022 void CAudioStreamAppUi::ConstructL()
00023     {
00024     BaseConstructL(EAknEnableSkin);
00025 
00026     iEngine = CAudioStreamEngine::NewL( this ); 
00027     // pass the handle of CAudioStreamEngine to CAudioStreamView so the 
00028     // view can use the engine
00029     iView = CAudioStreamView::NewL(ClientRect(), iEngine);
00030     iView->SetMopParent( this );
00031     // add view to control stack
00032     AddToStackL( iView );   
00033     }
00034 
00035 // ----------------------------------------------------------------------------
00036 // CAudioStreamAppUi::~CAudioStreamAppUi()
00037 //
00038 // destructor
00039 // ----------------------------------------------------------------------------
00040 CAudioStreamAppUi::~CAudioStreamAppUi()
00041     {
00042     // remove view from control stack
00043     RemoveFromStack( iView );
00044     delete iView;
00045     
00046     delete iEngine;
00047     }
00048 
00049 // ----------------------------------------------------------------------------
00050 // CAudioStreamAppUi::DynInitMenuPaneL(TInt aResourceId,
00051 //     CEikMenuPane* aMenuPane)
00052 //
00053 // this function is called by the EIKON framework just before it displays
00054 // a menu pane. Its default implementation is empty, and by overriding it,
00055 // the application can set the state of menu items dynamically according
00056 // to the state of application data.
00057 // ----------------------------------------------------------------------------
00058 void CAudioStreamAppUi::DynInitMenuPaneL(
00059     TInt /*aResourceId*/, CEikMenuPane* /*aMenuPane*/)
00060     {
00061     }
00062 
00063 // ----------------------------------------------------------------------------
00064 // CAudioStreamAppUi::HandleKeyEventL(
00065 //     const TKeyEvent& aKeyEvent,TEventCode /*aType*/)
00066 //
00067 // takes care of key event handling
00068 // ----------------------------------------------------------------------------
00069 TKeyResponse CAudioStreamAppUi::HandleKeyEventL(
00070     const TKeyEvent& /*aKeyEvent*/,TEventCode /*aType*/)
00071     {
00072     return EKeyWasNotConsumed;
00073     }
00074 
00075 // ----------------------------------------------------------------------------
00076 // CAudioStreamAppUi::HandleCommandL(TInt aCommand)
00077 //
00078 // takes care of command handling
00079 // ----------------------------------------------------------------------------
00080 void CAudioStreamAppUi::HandleCommandL(TInt aCommand)
00081     {
00082     switch ( aCommand )
00083         {
00084         case EAknSoftkeyExit:
00085         case EEikCmdExit:
00086             {
00087             Exit();
00088             break;
00089             }
00090         case EAudioStreamCmdPlay:
00091             {
00092             iEngine->Play();
00093             break;
00094             }
00095         case EAudioStreamCmdRecord:
00096             {
00097             iEngine->Record();
00098             break;
00099             }
00100         case EAudioStreamCmdStop:
00101             {
00102             iEngine->Stop();
00103             break;
00104             }
00105         case EAudioStreamCmdLoad:
00106             {
00107             iEngine->LoadAudioFileL();
00108             break;
00109             }
00110         case EAudioStreamCmdSave:
00111             {
00112             iEngine->SaveAudioFileL();
00113             break;
00114             }
00115         case EAudioStreamCmdPcm:
00116             {
00117             iEngine->SetEncodingL(EFalse);
00118             break;
00119             }
00120         case EAudioStreamCmdAmr:
00121             {
00122             iEngine->SetEncodingL(ETrue);
00123             break;
00124             }
00125         default:
00126             break;      
00127         }
00128     }
00129 
00130 
00131 // ----------------------------------------------------------------------------
00132 // CAudioStreamView* CAudioStreamAppUi::GetView()
00133 //
00134 // returns a reference to application view
00135 // ----------------------------------------------------------------------------
00136 CAudioStreamView* CAudioStreamAppUi::GetView() const
00137     {
00138     return iView;
00139     }
00140 
00141 
00142 // End of File  
00143 

Generated by  doxygen 1.6.2