00001 // This is like the "gps" sensor, but only scans after GSM cell ID 00002 // changes, and even so does not scan for too often. 00003 00004 #ifndef __epoc_cellpos_hpp__ 00005 #define __epoc_cellpos_hpp__ 00006 00007 #include "application_config.h" 00008 00009 #if __CELLPOS_ENABLED__ 00010 00011 #include "epoc-gps-observer.hpp" 00012 00013 #include "ac_app_context.h" 00014 #include "bb_blackboard.h" 00015 #include "epoc-ao-gerror.hpp" 00016 #include "ld_log_db.h" 00017 #include "ut_retry_epoc.hpp" 00018 #include "utils_cl2.h" 00019 00020 #include <e32std.h> 00021 #include <lbs.h> // link against lbs.lib 00022 #include <lbssatellite.h> 00023 00024 #include <glib.h> 00025 00026 class CPositioner_gps; 00027 class CPosModuleStatAo; 00028 00029 NONSHARABLE_CLASS(CSensor_cellpos) : 00030 public CBase, 00031 public MObserverPosMod, 00032 public MObserver_gps, 00033 public MRetryAoObserver, 00034 public bb::MObserver 00035 { 00036 public: 00037 static CSensor_cellpos* NewL(ac_AppContext* aAppContext); 00038 virtual ~CSensor_cellpos(); 00039 00040 private: 00041 CSensor_cellpos(ac_AppContext* aAppContext); 00042 void ConstructL(); 00043 00044 private: // MObserverPosMod 00045 virtual void PosModChangeL(); 00046 virtual void PosModErrorL(TInt errCode); 00047 virtual void PosModLeave(TInt errCode); 00048 virtual TBool PosModIsCurrent(TPositionModuleId id) const; 00049 00050 private: // MObserver_gps 00051 virtual gboolean PositionerEventL(GError** error); 00052 00053 private: // MRetryAoObserver 00054 virtual void RetryTimerExpired(CRetryAo* src, TInt errCode); 00055 00056 private: // bb::MObserver 00057 virtual void BbChangedL(bb::RHandle* self, enum bb_DataType dt, 00058 gpointer data, int len); 00059 00060 private: 00061 ac_AppContext* iAppContext; // not owned 00062 LogDb* iLogDb; // not owned 00063 00064 CPosModuleStatAo* iModuleAo; // owned 00065 00066 // Used for positioning when a suitable positioning module is 00067 // available. When nothing suitable is available, this is NULL. 00068 CPositioner_gps* iSatPositioner; // owned 00069 00070 CRetryAo* iRetryAo; // owned 00071 00072 bb::RHandle iCellChangeHandle; 00073 bb::RHandle iNetposChangeHandle; 00074 00075 TTime iLastScanTime; 00076 00077 enum TState { 00078 EInactive = 0, // not started 00079 EActive // asynchronous queries outstanding internally 00080 }; 00081 TState iState; 00082 00083 TPositionModuleId iModuleId; // current one, or KPositionNullModuleId 00084 00085 TBool iAllowAssisted; 00086 00087 TInt iMinScanRequestIntervalSecs; // config param 00088 TInt iSatelliteQueryTimeoutSecs; // config param 00089 TInt iDataMaxAgeSecs; // config param 00090 00091 private: 00092 void ReadConfig(); 00093 void CreateSpecifiedPositionerL(TPositionModuleId bestId); 00094 00095 public: 00096 void StartL(); 00097 void Stop(); 00098 TBool IsActive() const { return iState != EInactive; } 00099 void Reconfigure(const gchar* name, const gchar* value); 00100 }; 00101 00102 #endif // __CELLPOS_ENABLED__ 00103 00104 // -------------------------------------------------- 00105 // sensor array integration 00106 // -------------------------------------------------- 00107 00108 #if defined(SA_ARRAY_INTEGRATION) 00109 #if __CELLPOS_ENABLED__ 00110 #define DECLARE_SENSOR_cellpos CSensor_cellpos* iSensor_cellpos 00111 #define SENSOR_CELLPOS_DESTROY DELETE_Z(self->iSensor_cellpos) 00112 #define SENSOR_CELLPOS_CREATE sa_typical_symbian_sensor_create(self->iSensor_cellpos = CSensor_cellpos::NewL(self->ac), "cellpos sensor initialization") 00113 #define SENSOR_CELLPOS_START sa_trap_symbian_sensor_start(self->iSensor_cellpos, "failed to start cellpos scanning") 00114 #define SENSOR_CELLPOS_STOP { self->iSensor_cellpos->Stop(); } 00115 #define SENSOR_CELLPOS_IS_RUNNING (self->iSensor_cellpos->IsActive()) 00116 #define SENSOR_CELLPOS_RECONFIGURE(key,value) sa_typical_symbian_sensor_reconfigure(cellpos) 00117 #else 00118 #define DECLARE_SENSOR_cellpos 00119 #endif 00120 #endif /* SA_ARRAY_INTEGRATION */ 00121 00122 #endif /* __epoc_cellpos_hpp__ */ 00123 00124 /** 00125 00126 epoc-cellpos.hpp 00127 00128 Copyright 2009-2011 Helsinki Institute for Information Technology 00129 (HIIT) and the authors. All rights reserved. 00130 00131 Authors: Tero Hasu <tero.hasu@hut.fi> 00132 00133 Permission is hereby granted, free of charge, to any person 00134 obtaining a copy of this software and associated documentation files 00135 (the "Software"), to deal in the Software without restriction, 00136 including without limitation the rights to use, copy, modify, merge, 00137 publish, distribute, sublicense, and/or sell copies of the Software, 00138 and to permit persons to whom the Software is furnished to do so, 00139 subject to the following conditions: 00140 00141 The above copyright notice and this permission notice shall be 00142 included in all copies or substantial portions of the Software. 00143 00144 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 00145 EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 00146 MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 00147 NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS 00148 BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN 00149 ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 00150 CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 00151 SOFTWARE. 00152 00153 **/
ContextLogger2—ContextLogger2 Logger Daemon Internals—Generated on Mon May 2 13:49:52 2011 by Doxygen 1.6.1