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

examples/ForumNokia/ThreadAndActiveObjectsEx/src/sharedintermediator.cpp

00001 /*
+00002  * Copyright © 2008 Nokia Corporation.
+00003  */
+00004 
+00005 
+00006 // INCLUDES
+00007 #include "SharedIntermediator.h"
+00008 #include "BluetoothInfo.h"
+00009 #include "Devicelistcontainer.h"
+00010 #include "BluetoothRefreshTimer.h"
+00011 #include "ThreadAOAppUi.h"
+00012 #include "btdiscoverer.h"
+00013 
+00014 //CONSTANTS
+00015 const TInt KRefreshTime = 20;
+00016 
+00017 // ----------------------------------------------------------------------------
+00018 // CSharedIntermediator::CSharedIntermediator(CDeviceListContainer*
+00019 //                                                 aDeviceListContainer)
+00020 //
+00021 // Constructor.
+00022 // ----------------------------------------------------------------------------
+00023 CSharedIntermediator::CSharedIntermediator(
+00024                         CDeviceListContainer* aDeviceListContainer)
+00025                         : iDeviceListContainer(aDeviceListContainer),
+00026                         iStopSearching(false),
+00027                         iBTRefreshTimer(NULL),
+00028                     iInititialRefreshTime( KRefreshTime )
+00029         {
+00030         }
+00031 
+00032 // ----------------------------------------------------------------------------
+00033 // CSharedIntermediator::~CSharedIntermediator()
+00034 //
+00035 // Destructor.
+00036 // ----------------------------------------------------------------------------
+00037 CSharedIntermediator::~CSharedIntermediator()
+00038         {
+00039         iMutex.Close();
+00040         if(     iBluetoothInfoArray )
+00041                 {
+00042                 iBluetoothInfoArray->Reset();
+00043                 }
+00044         delete iBluetoothInfoArray;
+00045         }
+00046 
+00047 CSharedIntermediator* CSharedIntermediator::NewL(CDeviceListContainer* aView)
+00048         {
+00049         CSharedIntermediator* self = CSharedIntermediator::NewLC(aView);
+00050         CleanupStack::Pop();
+00051         return self;
+00052         }
+00053 
+00054 CSharedIntermediator* CSharedIntermediator::NewLC(CDeviceListContainer* aView)
+00055         {
+00056         CSharedIntermediator* self = new (ELeave) CSharedIntermediator(aView);
+00057         CleanupStack::PushL(self);
+00058         self->ConstructL();
+00059         return self;
+00060         }
+00061 
+00062 // Standard Symbian OS 2nd phase constructor
+00063 void CSharedIntermediator::ConstructL()
+00064         {
+00065         iBluetoothInfoArray = new (ELeave) CArrayFixFlat <TBluetoothInfo>(1);   
+00066         iMutex.CreateLocal();   
+00067         }
+00068 
+00069 // ----------------------------------------------------------------------------
+00070 // CSharedIntermediator::AddBluetoothInfoL(TBluetoothInfo& btInfoElement)
+00071 //
+00072 // Add bluetooth info into bluetooth info array and add's new bluetooth
+00073 // device's name into UI's list box.
+00074 // ----------------------------------------------------------------------------
+00075 void CSharedIntermediator::AddBluetoothInfoL(TBluetoothInfo& aBtInfoElement)
+00076         {
+00077         iMutex.Wait();
+00078 
+00079     // Add new device data into array
+00080         iBluetoothInfoArray->AppendL(aBtInfoElement);   
+00081 
+00082         TBuf <KBTDeviceLength> deviceName;
+00083     aBtInfoElement.GetDeviceName(deviceName);
+00084     // Show new device name in the list box.
+00085         iDeviceListContainer->AddItemL(deviceName);
+00086 
+00087         iMutex.Signal();
+00088         }
+00089 
+00090 // ----------------------------------------------------------------------------
+00091 // CSharedIntermediator::ResetArray()
+00092 //
+00093 // Clears bluetooth info array.
+00094 // ----------------------------------------------------------------------------
+00095 void CSharedIntermediator::ResetArray()
+00096         {
+00097         iMutex.Wait();
+00098         iBluetoothInfoArray->Reset();
+00099         iMutex.Signal();
+00100         }
+00101 
+00102 // ----------------------------------------------------------------------------
+00103 // CSharedIntermediator::SetRefreshTimerInitlVal(TInt aRefreshTime)
+00104 //
+00105 // Set thread one's CBluetoothrefreshtimer initial value.
+00106 // ----------------------------------------------------------------------------
+00107 void CSharedIntermediator::SetRefreshTimerInitlVal(TInt aRefreshTime)
+00108         {
+00109         if ( aRefreshTime < KRefreshTimeMin )
+00110                 {
+00111                 aRefreshTime = KRefreshTimeDefault;
+00112                 }
+00113 
+00114         iInititialRefreshTime = aRefreshTime;
+00115         }
+00116 
+00117 // ----------------------------------------------------------------------------
+00118 // CSharedIntermediator::RefreshTimerInitlVal()
+00119 //
+00120 // Get thread one's CBluetoothrefreshtimer initial value.
+00121 // ----------------------------------------------------------------------------
+00122 TInt CSharedIntermediator::RefreshTimerInitlVal()
+00123         {
+00124         return iInititialRefreshTime;
+00125         }
+00126 
+00127 // ----------------------------------------------------------------------------
+00128 // CSharedIntermediator::GetAddress(TDes& aAddress, TInt aIndex)
+00129 //
+00130 // Get bluetooth device address from the bluetooth info array.
+00131 // ----------------------------------------------------------------------------
+00132 void CSharedIntermediator::GetAddress(TDes& aAddress, TInt aIndex)
+00133         { 
+00134         iMutex.Wait();
+00135         if ( aIndex < iBluetoothInfoArray->Count() )
+00136                 {
+00137                 TBluetoothInfo& tempBTInfo = iBluetoothInfoArray->At(aIndex);
+00138                 tempBTInfo.GetAddressHex(aAddress);
+00139                 }
+00140         iMutex.Signal();
+00141         }
+00142 
+00143 // ----------------------------------------------------------------------------
+00144 // CSharedIntermediator::SetStopSearching(bool aStopSearhing)
+00145 //
+00146 //  Set variable (iStopSearching), which tells to thread
+00147 //  that Activescheduler's wait loop should stop. After that thread cleans up
+00148 //  itself, the program is terminated "naturally".
+00149 // ----------------------------------------------------------------------------
+00150 void CSharedIntermediator::SetStopSearching(bool aStopSearhing)
+00151         {
+00152         iStopSearching = aStopSearhing;
+00153         }
+00154 
+00155 
+00156 // ----------------------------------------------------------------------------
+00157 // TBool CSharedIntermediator::StopSearching()
+00158 // 
+00159 // ---------------------------------------------------------------------------- 
+00160 TBool CSharedIntermediator::StopSearching()
+00161         {
+00162         return iStopSearching;
+00163         }
+00164 
+00165 // ----------------------------------------------------------------------------
+00166 // CSharedIntermediator::BTRefreshTimerPtr()
+00167 //
+00168 //  Get pointer to thread's bluetooth refresh timer. New refresh time is set
+00169 //  in main program. Refresh time is time that has passed after bluetooth
+00170 //  discovery is started again.
+00171 // ----------------------------------------------------------------------------
+00172 CBluetoothRefreshTimer* CSharedIntermediator::BTRefreshTimerPtr()
+00173         {
+00174         return iBTRefreshTimer;
+00175         }
+00176 
+00177 // ----------------------------------------------------------------------------
+00178 // CSharedIntermediator::SetBTRefreshTimerPtr(CBluetoothRefreshTimer* timer)
+00179 //
+00180 // Set pointer to thread's bluetooth refresh timer. New refresh time is set
+00181 // in the main program by the user.
+00182 // ----------------------------------------------------------------------------
+00183 void CSharedIntermediator::SetBTRefreshTimerPtr(CBluetoothRefreshTimer* aTimer)
+00184         {
+00185         iBTRefreshTimer = aTimer;
+00186         }
+00187 
+00188 // ----------------------------------------------------------------------------
+00189 // CSharedIntermediator::DeviceListContainer()
+00190 //
+00191 // Get pointer to listbox container. Function is used
+00192 // when CBTRefreshTimer clears the listbox.
+00193 // ----------------------------------------------------------------------------
+00194 CDeviceListContainer* CSharedIntermediator::DeviceListContainer()
+00195         {
+00196         return iDeviceListContainer;
+00197         }
+00198 
+
+
Generated by  + +doxygen 1.6.2
+ +