00001 #ifndef __sa_sensor_util_epoc_hpp__ 00002 #define __sa_sensor_util_epoc_hpp__ 00003 00004 #include "ac_app_context.h" 00005 #include "utils_cl2.h" 00006 00007 #include <e32base.h> 00008 00009 #include <glib.h> 00010 00011 // -------------------------------------------------- 00012 // xxx the following are experimental interfaces, not very nice yet 00013 // -------------------------------------------------- 00014 00015 NONSHARABLE_CLASS(CActiveRetry) : 00016 public CActive 00017 { 00018 00019 protected: 00020 CActiveRetry(TInt aPriority) : CActive(aPriority) 00021 { CActiveScheduler::Add(this); } 00022 00023 virtual ~CActiveRetry(); 00024 00025 protected: 00026 00027 TInt iNumScanFailures; // remember to reset this in subclasses 00028 00029 enum TRetryState { 00030 EInactive = 0, 00031 EDoingActual, 00032 ERetryWaiting 00033 }; 00034 00035 TRetryState iRetryState; 00036 00037 DEF_SESSION(RTimer, iRetryTimer); 00038 00039 protected: 00040 void TimerConstructL(); // make sure to invoke this in subclasses 00041 00042 virtual TInt MaxNumRetries() { return 100; } 00043 00044 virtual TInt BaseInterval() { return 10; } // seconds 00045 00046 virtual TTimeIntervalMicroSeconds32 WaitInterval(); 00047 00048 virtual void RunActualL() = 0; 00049 00050 virtual void MakeRequestActual() = 0; // remember SetActive() here 00051 00052 virtual void DoCancelActual() = 0; 00053 00054 void MakeRequest() { 00055 MakeRequestActual(); 00056 iRetryState = EDoingActual; 00057 } 00058 00059 void Retry(); 00060 00061 private: // CActive 00062 00063 virtual void RunL(); 00064 00065 virtual void DoCancel(); 00066 00067 }; 00068 00069 NONSHARABLE_CLASS(CActiveSensorG) : 00070 public CActiveRetry 00071 { 00072 protected: 00073 CActiveSensorG(TInt aPriority, ac_AppContext* aAppContext) : 00074 CActiveRetry(aPriority), iC(aAppContext) {} 00075 00076 public: 00077 // Produces a leave or a GError if starting fails. No harm calling 00078 // this if already started. 00079 gboolean StartL(GError** error); 00080 00081 // Stops observing for changes and logging them. No harm calling 00082 // this if already stopped. 00083 void Stop(); 00084 00085 protected: 00086 ac_AppContext* iC; 00087 }; 00088 00089 #endif /* __sa_sensor_util_epoc_hpp__ */
ContextLogger2—ContextLogger2 Logger Daemon Internals—Generated on Mon May 2 13:49:56 2011 by Doxygen 1.6.1