sysanadatacapture/piprofiler/piprofiler/plugins/BUPplugin/inc/BupPlugin.h
changeset 2 6a82cd05fb1e
parent 1 3ff3fecb12fe
equal deleted inserted replaced
1:3ff3fecb12fe 2:6a82cd05fb1e
     1 /*
       
     2 * Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). 
       
     3 * All rights reserved.
       
     4 * This component and the accompanying materials are made available
       
     5 * under the terms of "Eclipse Public License v1.0"
       
     6 * which accompanies this distribution, and is available
       
     7 * at the URL "http://www.eclipse.org/legal/epl-v10.html".
       
     8 *
       
     9 * Initial Contributors:
       
    10 * Nokia Corporation - initial contribution.
       
    11 *
       
    12 * Contributors:
       
    13 *
       
    14 * Description:  
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 #ifndef PIPROFILER_BUPECOM_SAMPLER_H
       
    20 #define PIPROFILER_BUPECOM_SAMPLER_H
       
    21 
       
    22 #include <w32std.h>
       
    23 #include <StringLoader.h>
       
    24 #include <w32std.h>			// RWsSession
       
    25 #include <w32adll.h>		// RAnim DLL
       
    26 #include <e32std.h>
       
    27 #include <e32property.h>	// RProperty
       
    28 
       
    29 #include <piprofiler/ProfilerTraces.h>
       
    30 #include <piprofiler/ProfilerConfig.h>
       
    31 #include <piprofiler/ProfilerVersion.h>
       
    32 #include <piprofiler/SamplerPluginInterface.h>
       
    33 #include <piprofiler/ProfilerGenericClassesUsr.h>
       
    34 
       
    35 #include <data_caging_path_literals.hrh> // for KDC_SHARED_LIB_DIR
       
    36 
       
    37 // Button press&touch event Anim DLL interface
       
    38 #include "TouchEventClientDll.h"
       
    39 
       
    40 // caption definitions
       
    41 _LIT8(KBUPShortName, "bup");
       
    42 _LIT8(KBUPLongName, "Button and touch event capture");
       
    43 _LIT8(KBUPDescription, "Button and touch event sampler\nTracing button and touch screen events\nHW dep: N/A\nSW dep: S60 3.0\n");
       
    44 
       
    45 const TUid KProfilerKeyEventPropertyCat={0x2001E5AD};
       
    46 enum TProfilerKeyEventPropertyKeys
       
    47 	{
       
    48 	EProfilerKeyEventPropertySample = 7
       
    49 	};
       
    50 
       
    51 const TUid KGppPropertyCat={0x20201F70};
       
    52 enum TGppPropertyKeys
       
    53 	{
       
    54 	EGppPropertySyncSampleNumber
       
    55 	};
       
    56 
       
    57 
       
    58 static _LIT_SECURITY_POLICY_PASS(KAllowAllPolicy);
       
    59 static _LIT_SECURITY_POLICY_C1(KCapabilityNone, ECapability_None);
       
    60 
       
    61 _LIT(KDllName, "PIProfilerTouchEventAnim.DLL");	// animation server dll	on user disk
       
    62 
       
    63 /*
       
    64  *	
       
    65  *	BUP sampler definition
       
    66  *	
       
    67  */
       
    68 class CProfilerButtonListener;
       
    69 class CSamplerPluginInterface;
       
    70 
       
    71 class CBupPlugin : public CSamplerPluginInterface
       
    72 {
       
    73 public:	
       
    74 	static CBupPlugin* NewL(const TUid aImplementationUid, TAny* aInitParams);
       
    75 			~CBupPlugin();
       
    76 
       
    77 	void 	GetCaption( TDes& aCaption, TInt aType, TInt aSubId ) const;
       
    78 	TInt	ResetAndActivateL(CProfilerSampleStream& aStream);
       
    79 	TInt	StopSampling();
       
    80     TBool   Enabled() { return iEnabled; }
       
    81 						
       
    82 	TInt 	GetSamplerType();
       
    83 	
       
    84 	TInt	CreateFirstSample();
       
    85 
       
    86 	// no sub samplers, from CSamplerPluginInterface
       
    87 	TInt 	SubId(TUid /*aId*/) const {return KErrNotFound;}
       
    88 	TInt 	GetSubSamplers(TDes* /*aDes*/){return KErrNotFound;}
       
    89 	TInt 	GetSamplerUidByName(TDesC8& /*name*/){return KSamplerBupPluginUid.iUid;}
       
    90 	TInt 	GetSubCount(){return KErrNotFound;}
       
    91 	
       
    92 	void    GetAttributesL(CArrayFixFlat<TSamplerAttributes>* aAttributes);
       
    93     TInt    SetAttributesL(TSamplerAttributes aAttributes);
       
    94     void    InitiateSamplerAttributesL();
       
    95 	
       
    96     TInt    ConvertRawSettingsToAttributes(CDesC8ArrayFlat* aSingleSettingArray);
       
    97     
       
    98     TInt    DoSetSamplerSettings(CDesC8ArrayFlat* aAllSettings, TDesC8& aSamplerName, TInt aIndex);
       
    99     void    SaveSettingToAttributes(const TDesC8& aSetting, TInt aIndex);
       
   100     
       
   101 	TUid  Id(TInt aSubId) const;
       
   102 
       
   103 	void FillThisStreamBuffer(TBapBuf* nextFree,TRequestStatus& aStatus); 
       
   104 	
       
   105 private:
       
   106 			CBupPlugin();
       
   107 	void 	ConstructL();
       
   108 
       
   109 private:
       
   110 	TUint8					iVersion[20];
       
   111 	TPtr8					iVersionDescriptor;
       
   112 	
       
   113 	TInt 					iSamplerType;
       
   114 
       
   115 	CProfilerButtonListener* 	iButtonListener;
       
   116     CArrayFixFlat<TSamplerAttributes>* iSamplerAttributes;
       
   117 public:
       
   118 	TUint32* 				iSampleTime;
       
   119 };
       
   120 
       
   121 
       
   122 /*
       
   123 *
       
   124 *  Base class for all windows
       
   125 *
       
   126 */
       
   127 class CWsClient : public CActive
       
   128 	{
       
   129 	protected:
       
   130 		//construct
       
   131 		CWsClient();
       
   132 		CWsScreenDevice* iScreen;
       
   133 		RWsSession iWs;
       
   134 	public:
       
   135 		void ConstructL();
       
   136 		// destruct
       
   137 		~CWsClient();
       
   138 		// main window
       
   139 		virtual void ConstructMainWindowL();
       
   140 		// terminate cleanly
       
   141 		void Exit();
       
   142 		// active object protocol
       
   143 		void IssueRequest(); // request an event
       
   144 		void DoCancel(); // cancel the request
       
   145 		virtual TInt RunError(TInt aError) = 0;
       
   146 		virtual void RunL() = 0; // handle completed request
       
   147 		virtual void HandleKeyEventL (TKeyEvent& aKeyEvent) = 0;
       
   148 
       
   149 		RWindowGroup Group() {return iGroup;};
       
   150 
       
   151     private:
       
   152 		RWindowGroup    iGroup;
       
   153 		CWindowGc*      iGc;
       
   154 		friend class    CWindow; // needs to get at session
       
   155 		RProperty       iProperty;
       
   156 
       
   157 	};
       
   158 
       
   159 
       
   160 
       
   161 class CWindow;
       
   162 
       
   163 class CProfilerButtonListener : public CWsClient 
       
   164 {
       
   165 public:
       
   166 	static 	CProfilerButtonListener* NewL(CBupPlugin* aSamplerm);
       
   167 			~CProfilerButtonListener();
       
   168 private:
       
   169 			CProfilerButtonListener(CBupPlugin* aSampler);
       
   170 
       
   171 	
       
   172 public:
       
   173 	void 	ConstructMainWindowL();
       
   174 	void 	HandleKeyEventL (TKeyEvent& aKeyEvent);
       
   175 	void 	RunL();
       
   176 	TInt    RunError(TInt aError);
       
   177 	TInt 	StartL();
       
   178 	TInt	Stop();
       
   179 	
       
   180 private:
       
   181 	TUint8							iSample[8];
       
   182 
       
   183 	CBupPlugin*						iSampler;
       
   184 	RProfilerTouchEventAnim*			iAnim;
       
   185 	RAnimDll*						iAnimDll;
       
   186 	CWindow* 						iMainWindow;	// main window
       
   187 
       
   188 	TInt	 						iSampleStartTime;
       
   189 };
       
   190 
       
   191 
       
   192 
       
   193 /*
       
   194 *
       
   195 *  CWindow declaration
       
   196 *
       
   197 */
       
   198 class CWindow : public CBase
       
   199 	{
       
   200 	protected:
       
   201 		RWindow iWindow; 	// window server window
       
   202 		TRect iRect; 		// rectangle re owning window
       
   203 	public:
       
   204 		CWindow(CWsClient* aClient);
       
   205 		void ConstructL (const TRect& aRect, CWindow* aParent=0);
       
   206 		~CWindow();
       
   207 		// access
       
   208 		RWindow& Window(); // our own window
       
   209 		CWindowGc* SystemGc(); // system graphics context
       
   210 
       
   211 		CWsClient* Client() {return iClient;};
       
   212 	private:
       
   213 		CWsClient* iClient; // client including session and group
       
   214 	};
       
   215 
       
   216 
       
   217 #endif