examples/ForumNokia/AudioStreamExample/src/AudioStreamAppUi.cpp

00001 /*
00002  * Copyright (c) 2008-2010 Nokia Corporation and/or its subsidiary(-ies). All rights reserved.
00003  *    
00004  * Redistribution and use in source and binary forms, with or without
00005  * modification, are permitted provided that the following conditions are met:
00006  *    
00007  *  * Redistributions of source code must retain the above copyright notice, this
00008  *    list of conditions and the following disclaimer.
00009  *  * Redistributions in binary form must reproduce the above copyright notice,
00010  *    this list of conditions and the following disclaimer in the documentation
00011  *    and/or other materials provided with the distribution.
00012  *  * Neither the name of Nokia Corporation nor the names of its contributors
00013  *    may be used to endorse or promote products derived from this software
00014  *    without specific prior written permission.
00015  *    
00016  *    THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
00017  *    AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
00018  *    IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
00019  *    DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
00020  *    FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
00021  *    DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
00022  *    SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
00023  *    CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
00024  *    OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
00025  *    OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
00026  *    
00027  *    Description:  
00028  */
00029 
00030 // INCLUDE FILES
00031 #include <avkon.hrh>
00032 #include <eikmenup.h>
00033 
00034 #include "AudioStreamAppUi.h"
00035 #include "AudioStreamView.h" 
00036 #include <AudioStream.rsg>
00037 #include "AudioStream.hrh"
00038 
00039 #include "AudioStreamEngine.h"
00040 
00041 
00042 // ----------------------------------------------------------------------------
00043 // CAudioStreamAppUi::ConstructL()
00044 //
00045 // standard EPOC 2nd phase constructor
00046 // ----------------------------------------------------------------------------
00047 void CAudioStreamAppUi::ConstructL()
00048     {
00049     BaseConstructL(EAknEnableSkin);
00050 
00051     iEngine = CAudioStreamEngine::NewL( this ); 
00052     // pass the handle of CAudioStreamEngine to CAudioStreamView so the 
00053     // view can use the engine
00054     iView = CAudioStreamView::NewL(ClientRect(), iEngine);
00055     iView->SetMopParent( this );
00056     // add view to control stack
00057     AddToStackL( iView );   
00058     }
00059 
00060 // ----------------------------------------------------------------------------
00061 // CAudioStreamAppUi::~CAudioStreamAppUi()
00062 //
00063 // destructor
00064 // ----------------------------------------------------------------------------
00065 CAudioStreamAppUi::~CAudioStreamAppUi()
00066     {
00067     // remove view from control stack
00068     RemoveFromStack( iView );
00069     delete iView;
00070     
00071     delete iEngine;
00072     }
00073 
00074 // ----------------------------------------------------------------------------
00075 // CAudioStreamAppUi::DynInitMenuPaneL(TInt aResourceId,
00076 //     CEikMenuPane* aMenuPane)
00077 //
00078 // this function is called by the EIKON framework just before it displays
00079 // a menu pane. Its default implementation is empty, and by overriding it,
00080 // the application can set the state of menu items dynamically according
00081 // to the state of application data.
00082 // ----------------------------------------------------------------------------
00083 void CAudioStreamAppUi::DynInitMenuPaneL(
00084     TInt /*aResourceId*/, CEikMenuPane* /*aMenuPane*/)
00085     {
00086     }
00087 
00088 // ----------------------------------------------------------------------------
00089 // CAudioStreamAppUi::HandleKeyEventL(
00090 //     const TKeyEvent& aKeyEvent,TEventCode /*aType*/)
00091 //
00092 // takes care of key event handling
00093 // ----------------------------------------------------------------------------
00094 TKeyResponse CAudioStreamAppUi::HandleKeyEventL(
00095     const TKeyEvent& /*aKeyEvent*/,TEventCode /*aType*/)
00096     {
00097     return EKeyWasNotConsumed;
00098     }
00099 
00100 // ----------------------------------------------------------------------------
00101 // CAudioStreamAppUi::HandleCommandL(TInt aCommand)
00102 //
00103 // takes care of command handling
00104 // ----------------------------------------------------------------------------
00105 void CAudioStreamAppUi::HandleCommandL(TInt aCommand)
00106     {
00107     switch ( aCommand )
00108         {
00109         case EAknSoftkeyExit:
00110         case EEikCmdExit:
00111             {
00112             Exit();
00113             break;
00114             }
00115         case EAudioStreamCmdPlay:
00116             {
00117             iEngine->Play();
00118             break;
00119             }
00120         case EAudioStreamCmdRecord:
00121             {
00122             iEngine->Record();
00123             break;
00124             }
00125         case EAudioStreamCmdStop:
00126             {
00127             iEngine->Stop();
00128             break;
00129             }
00130         case EAudioStreamCmdLoad:
00131             {
00132             iEngine->LoadAudioFileL();
00133             break;
00134             }
00135         case EAudioStreamCmdSave:
00136             {
00137             iEngine->SaveAudioFileL();
00138             break;
00139             }
00140         case EAudioStreamCmdPcm:
00141             {
00142             iEngine->SetEncodingL(EFalse);
00143             break;
00144             }
00145         case EAudioStreamCmdAmr:
00146             {
00147             iEngine->SetEncodingL(ETrue);
00148             break;
00149             }
00150         default:
00151             break;      
00152         }
00153     }
00154 
00155 
00156 // ----------------------------------------------------------------------------
00157 // CAudioStreamView* CAudioStreamAppUi::GetView()
00158 //
00159 // returns a reference to application view
00160 // ----------------------------------------------------------------------------
00161 CAudioStreamView* CAudioStreamAppUi::GetView() const
00162     {
00163     return iView;
00164     }
00165 
00166 
00167 // End of File  
00168 

Generated by  doxygen 1.6.2