epoc-smsevent.hpp

Go to the documentation of this file.
00001 #ifndef __epoc_smsevent_hpp__
00002 #define __epoc_smsevent_hpp__
00003 
00004 #include "application_config.h"
00005 
00006 #if __SMSEVENT_ENABLED__
00007 
00008 #include "ac_app_context.h"
00009 #include "ut_sms_epoc.hpp"
00010 #include "utils_cl2.h"
00011 
00012 #include <e32base.h>
00013 
00014 #include <glib.h>
00015 
00016 /***koog 
00017 (require codegen/symbian-cxx)
00018 (ctor-defines/spec
00019  "CSensor_smsevent" ;; name
00020  "ac_AppContext* aAppContext" ;; args
00021  "iAppContext(aAppContext)" ;; inits
00022  "" ;; ctor
00023  #t ;; ConstructL
00024 )
00025  ***/
00026 #define CTOR_DECL_CSensor_smsevent  \
00027 public: static CSensor_smsevent* NewLC(ac_AppContext* aAppContext); \
00028 public: static CSensor_smsevent* NewL(ac_AppContext* aAppContext); \
00029 private: CSensor_smsevent(ac_AppContext* aAppContext); \
00030 private: void ConstructL();
00031 
00032 #define CTOR_IMPL_CSensor_smsevent  \
00033 CSensor_smsevent* CSensor_smsevent::NewLC(ac_AppContext* aAppContext) \
00034 { \
00035   CSensor_smsevent* obj = new (ELeave) CSensor_smsevent(aAppContext); \
00036   CleanupStack::PushL(obj); \
00037   obj->ConstructL(); \
00038   return obj; \
00039 } \
00040  \
00041 CSensor_smsevent* CSensor_smsevent::NewL(ac_AppContext* aAppContext) \
00042 { \
00043   CSensor_smsevent* obj = CSensor_smsevent::NewLC(aAppContext); \
00044   CleanupStack::Pop(obj); \
00045   return obj; \
00046 } \
00047  \
00048 CSensor_smsevent::CSensor_smsevent(ac_AppContext* aAppContext) : iAppContext(aAppContext) \
00049 {}
00050 /***end***/
00051 
00052 NONSHARABLE_CLASS(CSensor_smsevent) :
00053   public CBase,
00054   public i_handle_received_sms
00055 {
00056   CTOR_DECL_CSensor_smsevent;
00057 
00058  public:
00059   virtual ~CSensor_smsevent();
00060 
00061   // Produces a leave or a GError if starting fails. No harm calling
00062   // this if already started.
00063   gboolean StartL(GError** error);
00064 
00065   // Stops observing for changes and logging them. No harm calling
00066   // this if already stopped.
00067   void Stop();
00068 
00069   TBool IsActive() const { return (iSmsEventNotifier != NULL); }
00070 
00071  private: // i_handle_received_sms
00072   virtual void handle_reception(const TMsvId& entry_id, const TMsvId& folder_id, 
00073         const TDesC& sender, CRichText& body); 
00074   virtual void handle_sending(const TMsvId& entry_id, 
00075             const TDesC& sender, CRichText& body);
00076   virtual void handle_error(TInt aError);
00077   virtual void handle_close();
00078   
00079  private:
00080 
00081   void ActivateL();
00082 
00083   void Disactivate();
00084 
00085   void LogEvent(const char* evType, const TDesC& aTelNo, CRichText& aBody);
00086 
00087  private:
00088 
00089   ac_AppContext* iAppContext; // not owned
00090 
00091   CSmsEventNotifier* iSmsEventNotifier;
00092 
00093  private:
00094 
00095   LogDb* GetLogDb() const { return ac_LogDb(iAppContext); }
00096 
00097 };
00098 
00099 #endif // __SMSEVENT_ENABLED__
00100 
00101 // --------------------------------------------------
00102 // sensor array integration
00103 // --------------------------------------------------
00104 
00105 #if defined(SA_ARRAY_INTEGRATION)
00106 #if __SMSEVENT_ENABLED__
00107 #define DECLARE_SENSOR_smsevent CSensor_smsevent* iSensor_smsevent
00108 #define SENSOR_SMSEVENT_START sa_typical_symbian_sensor_start(self->iSensor_smsevent, "failed to start smsevent scanning")
00109 #define SENSOR_SMSEVENT_STOP { self->iSensor_smsevent->Stop(); }
00110 #define SENSOR_SMSEVENT_IS_RUNNING (self->iSensor_smsevent->IsActive())
00111 #define SENSOR_SMSEVENT_DESTROY { delete self->iSensor_smsevent; self->iSensor_smsevent = NULL; }
00112 #define SENSOR_SMSEVENT_CREATE sa_typical_symbian_sensor_create(self->iSensor_smsevent = CSensor_smsevent::NewL(self->ac), "smsevent sensor initialization")
00113 #define SENSOR_SMSEVENT_RECONFIGURE(key,value) sa_reconfigure_ignore_all_keys
00114 #else
00115 #define DECLARE_SENSOR_smsevent
00116 #endif
00117 #endif /* SA_ARRAY_INTEGRATION */
00118 
00119 #endif /* __epoc_smsevent_hpp__ */
00120 
00121 /**
00122 
00123 epoc-smsevent.hpp
00124 
00125 Copyright 2009 Helsinki Institute for Information Technology (HIIT)
00126 and the authors. All rights reserved.
00127 
00128 Authors: Tero Hasu <tero.hasu@hut.fi>
00129 
00130 Permission is hereby granted, free of charge, to any person
00131 obtaining a copy of this software and associated documentation files
00132 (the "Software"), to deal in the Software without restriction,
00133 including without limitation the rights to use, copy, modify, merge,
00134 publish, distribute, sublicense, and/or sell copies of the Software,
00135 and to permit persons to whom the Software is furnished to do so,
00136 subject to the following conditions:
00137 
00138 The above copyright notice and this permission notice shall be
00139 included in all copies or substantial portions of the Software.
00140 
00141 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
00142 EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
00143 MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
00144 NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
00145 BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
00146 ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
00147 CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
00148 SOFTWARE.
00149 
00150  **/

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