examples/ForumNokia/ThreadExample/src/threadappui.cpp

00001 /*
00002 * ============================================================================
00003 *  Name     : CThreadAppUi from CThreadAppUi.h
00004 *  Part of  : Thread
00005 *  Created  : 04.02.2005 by Forum Nokia
00006 *  Version  : 1.0
00007 *  Copyright: Nokia Corporation
00008 * ============================================================================
00009 */
00010 
00011 // INCLUDES
00012 #include <avkon.hrh>
00013 #include <aknnotewrappers.h> 
00014 
00015 #include "Thread.pan"
00016 #include "ThreadAppUi.h"
00017 #include "ThreadAppView.h"
00018 #include "Thread.hrh"
00019 #include "ThreadEngine.h"
00020 
00021 // ----------------------------------------------------------------------------
00022 // CThreadAppUi::ConstructL()
00023 //
00024 // Standard EPOC 2nd phase constructor
00025 // ----------------------------------------------------------------------------
00026 void CThreadAppUi::ConstructL()
00027     {
00028     BaseConstructL(CAknAppUi::EAknEnableSkin);
00029     iAppView = CThreadAppView::NewL(ClientRect());
00030     iAppView->SetMopParent(this);
00031     // add view to control stack
00032     AddToStackL(iAppView);
00033         
00034     // create new watchdog for threads
00035     iThreadEngine = CThreadEngine::NewL(iAppView);
00036     }
00037 
00038 // ----------------------------------------------------------------------------
00039 // CThreadAppUi::CThreadAppUi()  
00040 //
00041 // constructor
00042 // ----------------------------------------------------------------------------
00043 CThreadAppUi::CThreadAppUi()                              
00044     {
00045     // No implementation required
00046     }
00047 
00048 // ----------------------------------------------------------------------------
00049 // CThreadAppUi::~CThreadAppUi()
00050 //
00051 // destructor
00052 // ----------------------------------------------------------------------------
00053 CThreadAppUi::~CThreadAppUi()
00054     {
00055     if ( iThreadEngine )
00056         {
00057         delete iThreadEngine;
00058         }
00059 
00060     if ( iAppView )
00061         {
00062         iEikonEnv->RemoveFromStack(iAppView);
00063         delete iAppView;
00064         }
00065     }
00066 
00067 // ----------------------------------------------------------------------------
00068 // CThreadAppUi::HandleCommandL(TInt aCommand)
00069 //
00070 // takes care of command handling
00071 // ----------------------------------------------------------------------------
00072 void CThreadAppUi::HandleCommandL(TInt aCommand)
00073     {
00074     switch(aCommand)
00075         {
00076         case EEikCmdExit:
00077         case EAknSoftkeyExit:
00078             Exit();
00079             break;
00080 
00081         case EThreadKillCommand1:
00082             {
00083             // kill thread1
00084             iThreadEngine->KillThread(1);
00085             }
00086             break;
00087 
00088         case EThreadKillCommand2:
00089             {
00090             // kill thread2
00091             iThreadEngine->KillThread(2);       
00092             }
00093             break;
00094 
00095         case EThreadKillCommand3:
00096             {
00097             // kill  thread3
00098             iThreadEngine->KillThread(3);
00099             }
00100             break;
00101 
00102         case EThreadStartCommand:
00103             {
00104             // start all threads
00105             iThreadEngine->StartL();
00106             }
00107             break;
00108 
00109         default:
00110             Panic(EThreadUi);
00111             break;
00112         }
00113     }
00114 

Generated by  doxygen 1.6.2