diff -r f345bda72bc4 -r 43e37759235e Symbian3/Examples/guid-6013a680-57f9-415b-8851-c4fa63356636/threadaoappui_8cpp_source.html --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Symbian3/Examples/guid-6013a680-57f9-415b-8851-c4fa63356636/threadaoappui_8cpp_source.html Tue Mar 30 16:16:55 2010 +0100 @@ -0,0 +1,205 @@ + + + + +TB9.2 Example Applications: examples/ForumNokia/ThreadAndActiveObjectsEx/src/threadaoappui.cpp Source File + + + + + +

examples/ForumNokia/ThreadAndActiveObjectsEx/src/threadaoappui.cpp

00001 /*
+00002  * Copyright © 2008 Nokia Corporation.
+00003  */
+00004 
+00005 
+00006 // INCLUDES
+00007 #include <avkon.hrh>
+00008 #include <aknnotewrappers.h> 
+00009 #include <ThreadAO.rsg>         // R_SET_REFRESH_TIME_DIALOG
+00010 
+00011 #include <btnotifierapi.h>
+00012 
+00013 #include "ThreadAO.pan"
+00014 #include "ThreadAOAppUi.h"
+00015 #include "ThreadAO.hrh"
+00016 #include "threadAOengine.h"
+00017 #include "DevicelistContainer.h"
+00018 #include "SharedIntermediator.h"
+00019 #include "BluetoothRefreshTimer.h"
+00020 
+00021 #include "ListboxRefreshTimer.h"
+00022 
+00023 // ----------------------------------------------------------------------------
+00024 // CThreadAOAppUi::ConstructL()
+00025 //
+00026 // Standard Symbian OS 2nd phase constructor. 
+00027 // ----------------------------------------------------------------------------
+00028 void CThreadAOAppUi::ConstructL()
+00029     {
+00030     BaseConstructL( CAknAppUi::EAknEnableSkin );
+00031 
+00032         // Create listbox container
+00033     iContainer = CDeviceListContainer::NewL(ClientRect());
+00034     iContainer->SetMopParent(this);
+00035 
+00036         // Add view to control stack
+00037         AddToStackL(iContainer);
+00038         iSMediator = CSharedIntermediator::NewL(iContainer);
+00039 
+00040         // Doesn't take ownership
+00041         iContainer->SetSMediator(iSMediator);
+00042 
+00043         // Listbox refresh timer. Needed because calling HandleItemAdditionL
+00044         // from thread1 doesn't seem to work.  
+00045         iTimer = CListboxRefreshTimer::NewL( iContainer );
+00046 
+00047         // Start refreshing the the listbox.
+00048         iTimer->StartL();
+00049 
+00050         // Create thread engine which creates thread1.
+00051         iThreadEngine = CThreadAOEngine::NewL(iSMediator);
+00052         }
+00053 
+00054 TBool CThreadAOAppUi::TurnBtOnL()
+00055     {
+00056     RNotifier notifier;
+00057     User::LeaveIfError( notifier.Connect() );
+00058     TPckgBuf<TBool> dummy(ETrue);
+00059     TPckgBuf<TBool> reply(ETrue);
+00060     TRequestStatus stat;
+00061 
+00062     notifier.StartNotifierAndGetResponse(stat, KPowerModeSettingNotifierUid, dummy, reply);
+00063     User::WaitForRequest(stat);
+00064 
+00065     notifier.CancelNotifier(KPowerModeSettingNotifierUid);
+00066     notifier.Close();
+00067     return reply();
+00068     }
+00069 
+00070 
+00071 // ----------------------------------------------------------------------------
+00072 // CThreadAOAppUi::CThreadAOAppUi()  
+00073 //
+00074 // Constructor.
+00075 // ----------------------------------------------------------------------------
+00076 CThreadAOAppUi::CThreadAOAppUi() : iThreadStarted(EFalse)                          
+00077     {
+00078     }
+00079 
+00080 // ----------------------------------------------------------------------------
+00081 // CThreadAOAppUi::~CThreadAOAppUi()
+00082 //
+00083 // Destructor.
+00084 // ----------------------------------------------------------------------------
+00085 CThreadAOAppUi::~CThreadAOAppUi()
+00086     {
+00087         delete iThreadEngine;
+00088 
+00089     if ( iContainer )
+00090         {
+00091         iEikonEnv->RemoveFromStack(iContainer);
+00092         delete iContainer;
+00093         }
+00094         
+00095         delete iTimer;
+00096 
+00097         delete iSMediator;
+00098         }
+00099 
+00100 // ----------------------------------------------------------------------------
+00101 // CThreadAOAppUi::HandleCommandL(TInt aCommand)
+00102 //
+00103 // Takes care of command handling.
+00104 // ----------------------------------------------------------------------------
+00105 void CThreadAOAppUi::HandleCommandL(TInt aCommand)
+00106     {
+00107     switch(aCommand)
+00108         {
+00109         case EEikCmdExit:
+00110         case EAknSoftkeyExit:
+00111                         {
+00112                         if (iThreadStarted)
+00113                                 {
+00114                                 // CThreadListener is responsible for exiting the program.
+00115                                 // The object is created in ThreadEngine CreateThreadsL().
+00116                                 // This is done because thread1 needs to cleanup before killing
+00117                                 // the thread.
+00118                                 iThreadEngine->Stop();
+00119                                 }
+00120                         else 
+00121                                 {
+00122                                 Exit();
+00123                                 }
+00124                         }
+00125             break;
+00126 
+00127                 case EThreadStartCommand:
+00128             {
+00129             if (!TurnBtOnL())
+00130                 {
+00131                 return;
+00132                 }
+00133 
+00134                         // start thread1 ( bluetooth discovery )
+00135                     if (!iThreadStarted)
+00136                                 {
+00137                                 iThreadEngine->StartL();
+00138                                 iThreadStarted = ETrue;
+00139                                 }
+00140             }
+00141             break;
+00142                 
+00143                 case EThreadSetRefreshTimeCommand:
+00144             {
+00145                         // Query a new refresh time and set the new value.
+00146                         if ( iThreadStarted )
+00147                                 {
+00148                                 TInt newRefreshTime = 0;
+00149                             CAknNumberQueryDialog* dlg = new (ELeave) 
+00150                            CAknNumberQueryDialog(newRefreshTime, CAknQueryDialog::ENoTone);
+00151                                 if ( dlg->ExecuteLD( R_SET_REFRESH_TIME_DIALOG ) )
+00152                                         {
+00153                                         iSMediator->BTRefreshTimerPtr()->SetRefreshTime(
+00154                                                                                   newRefreshTime );
+00155                                         }
+00156                                 }
+00157                         else 
+00158                                 // If threadOne hasn't been started, query a new refresh time
+00159                                 // and set refresh timer's initial value.
+00160                                 {
+00161                                 TInt newRefreshTime = 0;
+00162                             CAknNumberQueryDialog* dlg = new (ELeave) 
+00163                            CAknNumberQueryDialog(newRefreshTime, CAknQueryDialog::ENoTone);
+00164                                 if (dlg->ExecuteLD(R_SET_REFRESH_TIME_DIALOG))
+00165                                         {
+00166                                         iSMediator->SetRefreshTimerInitlVal( newRefreshTime );
+00167                                         }
+00168                                 }
+00169             }
+00170             break;
+00171 
+00172         default:
+00173             Panic(EThreadUi);
+00174             break;
+00175         }
+00176     }
+00177 
+00178 // ---------------------------------------------------------
+00179 // CThreadAOAppUi::HandleStatusPaneSizeChange()
+00180 // Called by framework when resource is changed.
+00181 // ---------------------------------------------------------
+00182 //
+00183 void CThreadAOAppUi::HandleStatusPaneSizeChange()
+00184         {
+00185         CAknAppUi::HandleStatusPaneSizeChange(); //call to upper class
+00186         iContainer->SetRect( ClientRect());
+00187         }
+00188 
+00189 
+
+
Generated by  + +doxygen 1.6.2
+ +