examples/ForumNokia/ThreadAndActiveObjectsEx/src/listboxrefreshtimer.cpp

00001 /*
00002  * Copyright © 2008 Nokia Corporation.
00003  */
00004 
00005 
00006 // INCLUDES
00007 #include <e32base.h> 
00008 #include "aknnotewrappers.h"
00009 #include "DeviceListContainer.h"
00010 
00011 // Listbox screen update interval
00012 const TInt KSecond = 1000 * 1000;
00013 
00014 #include "ListboxRefreshTimer.h"
00015 
00016 // ----------------------------------------------------------------------------
00017 // CListboxRefreshTimer::CListboxRefreshTimer()
00018 //
00019 // Constructor.
00020 // ----------------------------------------------------------------------------
00021 CListboxRefreshTimer::CListboxRefreshTimer(CDeviceListContainer* aListBox)
00022         : CTimer(CActive::EPriorityStandard), iListbox(aListBox) 
00023         {
00024         }
00025 
00026 // ----------------------------------------------------------------------------
00027 // CListboxRefreshTimer::~CListboxRefreshTimer()
00028 //
00029 // Destructor.
00030 // ----------------------------------------------------------------------------
00031 CListboxRefreshTimer::~CListboxRefreshTimer()
00032         {
00033         Cancel();
00034         }
00035 
00036 
00037 CListboxRefreshTimer* CListboxRefreshTimer::NewL(
00038                                             CDeviceListContainer* aListBox )
00039         {
00040         CListboxRefreshTimer* self = CListboxRefreshTimer::NewLC(aListBox);
00041         CleanupStack::Pop(self);
00042         return self;
00043         }
00044 
00045 CListboxRefreshTimer* CListboxRefreshTimer::NewLC(
00046                                            CDeviceListContainer* aListBox )
00047         {
00048         CListboxRefreshTimer* self = new (ELeave) CListboxRefreshTimer(aListBox);
00049         CleanupStack::PushL(self);
00050         
00051         self->ConstructL();
00052         return self;
00053         }
00054 
00055 // Standard Symbian OS 2nd phase constructor
00056 void CListboxRefreshTimer::ConstructL()
00057         {
00058         CTimer::ConstructL();
00059         CActiveScheduler::Add(this);
00060         }
00061 
00062 // ----------------------------------------------------------------------------
00063 // CListboxRefreshTimer::StartL()
00064 //
00065 // Start updating the listbox.
00066 // ----------------------------------------------------------------------------
00067 void CListboxRefreshTimer::StartL()
00068         {
00069         After( KSecond );       
00070         }
00071 
00072 // ----------------------------------------------------------------------------
00073 // CListboxRefreshTimer::RunL()
00074 // ----------------------------------------------------------------------------
00075 void CListboxRefreshTimer::RunL()
00076         {
00077         // Update the listbox.
00078         iListbox->HandleChangedL();
00079         // Wait for a while and run the same function again 
00080         After( KSecond );
00081         }
00082 
00083 // ----------------------------------------------------------------------------
00084 // CListboxRefreshTimer::DoCancel()
00085 //
00086 // Cancel and stop the timer. 
00087 // ----------------------------------------------------------------------------
00088 void CListboxRefreshTimer::DoCancel()   
00089         {
00090         CTimer::DoCancel();
00091         }
00092 
00093 // ----------------------------------------------------------------------------
00094 // CListboxRefreshTimer::RunError(TInt)
00095 // ----------------------------------------------------------------------------
00096 TInt CListboxRefreshTimer::RunError(TInt)
00097         {
00098         return KErrNone;
00099         }
00100 

Generated by  doxygen 1.6.2