epoc-btprox.hpp

Go to the documentation of this file.
00001 #ifndef __epoc_btprox_hpp__
00002 #define __epoc_btprox_hpp__
00003 
00004 #include "application_config.h"
00005 
00006 #if __BTPROX_ENABLED__
00007 
00008 #include "epoc-ao-gerror.hpp"
00009 #include "ld_log_db.h"
00010 #include "utils_cl2.h"
00011 
00012 #include <bt_sock.h>
00013 #include <e32base.h>
00014 #include <es_sock.h>
00015 
00016 #include <glib.h>
00017 
00018 NONSHARABLE_CLASS(CSensor_btprox) : public CActiveRunG
00019 {
00020  public:
00021 
00022   static CSensor_btprox* NewL(LogDb* aLogDb);
00023 
00024   virtual ~CSensor_btprox();
00025 
00026   gboolean StartL(GError** error);
00027 
00028   void Stop();
00029 
00030   void Reconfigure(const gchar* name, const gchar* value);
00031 
00032  private:
00033  
00034   CSensor_btprox(LogDb* aLogDb);
00035 
00036   void ConstructL();
00037 
00038   TBool EnsureBtInit();
00039   void TryBtInitL();
00040   void BtClose();
00041   void TryStartScanning();
00042   gboolean HandleScanEventL(TInt errCode, GError** error);
00043 
00044   void RefreshBaseScanIntervalSecs();
00045 
00046   // Three different ways internally to make an asynch. request.
00047   void SetTimer();
00048   void BtDiscover();
00049   void BtNext();
00050 
00051  private: // CActiveG
00052 
00053   virtual gboolean RunGL(GError** error);
00054   virtual void DoCancel();
00055   virtual const char* Description();
00056 
00057  private:
00058 
00059   enum TState {
00060     EInactive = 0, // StartL not invoked
00061     EScanWaiting, // BT init done, scan interval wait
00062     EDiscovering, // BT scan in progress
00063     ERetryWaiting // BT init not done, waiting before reinit attempt
00064   };
00065   TState iState;
00066 
00067   // owned, for now, can share once required by other sensors
00068   DEF_SESSION(RSocketServ, iSocketServ);
00069 
00070   DEF_SESSION(RHostResolver, iHostResolver);
00071   
00072   TInquirySockAddr iInquirySockAddr;
00073   TNameEntry iNameEntry;
00074 
00075   TInt iNumScanFailures;
00076 
00077   TInt iBaseScanIntervalSecs;
00078   
00079   GPtrArray* iResult;
00080   GPtrArray* iOldResult;
00081 
00082   DEF_SESSION(RTimer, iTimer);
00083 
00084   LogDb* iLogDb; // not owned
00085 };
00086 
00087 #endif // __BTPROX_ENABLED__
00088 
00089 #endif /* __epoc_btprox_hpp__ */
00090 
00091 /**
00092 
00093 epoc-btprox.hpp
00094 
00095 Copyright 2009 Helsinki Institute for Information Technology (HIIT)
00096 and the authors. All rights reserved.
00097 
00098 Authors: Tero Hasu <tero.hasu@hut.fi>
00099 
00100 Permission is hereby granted, free of charge, to any person
00101 obtaining a copy of this software and associated documentation files
00102 (the "Software"), to deal in the Software without restriction,
00103 including without limitation the rights to use, copy, modify, merge,
00104 publish, distribute, sublicense, and/or sell copies of the Software,
00105 and to permit persons to whom the Software is furnished to do so,
00106 subject to the following conditions:
00107 
00108 The above copyright notice and this permission notice shall be
00109 included in all copies or substantial portions of the Software.
00110 
00111 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
00112 EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
00113 MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
00114 NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
00115 BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
00116 ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
00117 CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
00118 SOFTWARE.
00119 
00120  **/

ContextLogger2—ContextLogger2 Logger Daemon Internals—Generated on Mon May 2 13:49:52 2011 by Doxygen 1.6.1