epoc-keypress.hpp

Go to the documentation of this file.
00001 /**
00002  * ====================================================================
00003  * capturer.h
00004  * Copyright (c) 2006 Nokia Corporation
00005  *
00006  * Licensed under the Apache License, Version 2.0 (the "License");
00007  * you may not use this file except in compliance with the License.
00008  * You may obtain a copy of the License at
00009  *
00010  *     http://www.apache.org/licenses/LICENSE-2.0
00011  *
00012  * Unless required by applicable law or agreed to in writing, software
00013  * distributed under the License is distributed on an "AS IS" BASIS,
00014  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
00015  * See the License for the specific language governing permissions and
00016  * limitations under the License.
00017  * ====================================================================
00018  */
00019 
00020 // A small amount of the code is derived from CCapturer in PyS60,
00021 // hence the above license applies. Any changes made are Copyright
00022 // 2009 Helsinki Institute for Information Technology (HIIT) and Tero
00023 // Hasu <tero.hasu@hut.fi>, and are made available under the original
00024 // license.
00025 
00026 // Note that this keylogging implementation may interact badly with
00027 // some built-in functions on some devices. If you are going to have
00028 // the Jaiku keyevents anim DLL available, you may use the alternative
00029 // implementation, just define __HAVE_ANIM__ as true.
00030 
00031 #ifndef __epoc_keypress_hpp__
00032 #define __epoc_keypress_hpp__
00033 
00034 #include "application_config.h"
00035 
00036 #if __KEYPRESS_ENABLED__ && !__HAVE_ANIM__
00037 
00038 #include "epoc-ao-gerror.hpp"
00039 #include "ld_log_db.h"
00040 #include "utils_cl2.h"
00041 
00042 #include <w32std.h> // link against: ws32.lib
00043 #include <e32base.h>
00044 #include <apgwgnam.h>
00045 #include <coedef.h>
00046 
00047 #include <glib.h>
00048 
00049 // The implementation bears some similarity to that of the appfocus
00050 // sensor, since we must deal with window groups and the like.
00051 NONSHARABLE_CLASS(CSensor_keypress) : public CActiveRunG
00052 {
00053  public:
00054   static CSensor_keypress* NewL(LogDb* aLogDb);
00055 
00056   virtual ~CSensor_keypress();
00057 
00058   gboolean StartL(GError** error);
00059 
00060   void Stop();
00061 
00062  private:
00063   CSensor_keypress(LogDb* aLogDb);
00064 
00065   void ConstructL();
00066 
00067  private:
00068 
00069   // Makes next capture request.
00070   void MakeRequest(); // was StartCapturing
00071 
00072   void RequestAllKeys();
00073   void CancelAllKeys();
00074 
00075   // we want to capture all, do we need these?
00076   TInt32 SetKeyToBeCaptured(TInt32 keyCode);
00077   void RemoveKey(TInt32 keyId);
00078   
00079   virtual gboolean RunGL(GError** error);
00080 
00081   void DoCancel();
00082 
00083   virtual const char* Description();
00084 
00085   gboolean LogAndClear(GError** error);
00086 
00087  private:
00088 
00089   LogDb* iLogDb; // not owned
00090 
00091   // Not quite sure if we could share some of these with the appfocus
00092   // sensor. The issue of course being that it may not be possible to
00093   // make multiple simultaneous async requests via the same session
00094   // object.
00095   RWsSession* iSession;
00096   RWindowGroup* iWinGroup;
00097   CApaWindowGroupName* iWinGroupName;
00098 
00099   TInt32 iCaptureHandles[350];
00100   int iNumCaptureHandles;
00101 
00102 #define MAX_NUM_CAPTURED_KEYS 100
00103   // We should log and clear when the buffer is full, or when the
00104   // logger is stopped, whichever comes first.
00105   time_t iCapturedKeys[MAX_NUM_CAPTURED_KEYS];
00106   int iNumCapturedKeys;
00107   GString* iKeysText; // buffer for text to log
00108 };
00109 
00110 #endif // __KEYPRESS_ENABLED__ && !__HAVE_ANIM__
00111 
00112 #endif /* __epoc_keypress_hpp__ */

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