|
1 /* |
|
2 * Copyright (c) 2002-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: CSysApKeyManagement class definition. |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 #ifndef SYSAPKEYMANAGEMENT_H |
|
20 #define SYSAPKEYMANAGEMENT_H |
|
21 |
|
22 // INCLUDES |
|
23 #include <sysapkeyhandlerplugininterface.h> |
|
24 |
|
25 // FORWARD DECLARATIONS |
|
26 class RWindowGroup; |
|
27 class MSysapCallback; |
|
28 |
|
29 // DATA TYPES |
|
30 |
|
31 /** |
|
32 * KeyManagement class for Sysap Key Event Framework |
|
33 * Handles Virtual KeyEvents with Plugins |
|
34 * |
|
35 * @since S60 3.0 |
|
36 */ |
|
37 class CSysApKeyManagement: public CBase |
|
38 { |
|
39 private: // data types |
|
40 class CSysApPluginInfo : public CBase |
|
41 { |
|
42 public: // construction |
|
43 |
|
44 /** |
|
45 * Constructor. |
|
46 * |
|
47 * @param aPluginUid UID of the plugin that this object represents |
|
48 */ |
|
49 CSysApPluginInfo( TUid aPluginUid ); |
|
50 |
|
51 /** |
|
52 * Destructor |
|
53 */ |
|
54 virtual ~CSysApPluginInfo(); |
|
55 |
|
56 private: |
|
57 /** |
|
58 * C++ default constructor. Prohibitten |
|
59 */ |
|
60 CSysApPluginInfo(); |
|
61 |
|
62 public: // data |
|
63 |
|
64 /** |
|
65 * UID of the plug-in, used with non-resident plugins. |
|
66 */ |
|
67 TUid iPluginUid; |
|
68 |
|
69 /** |
|
70 * Instantiated plugin, used only with resident plug-ins. |
|
71 * If NULL, the plug-in is interpreted to be non-resident. |
|
72 * Own. |
|
73 */ |
|
74 CSysapKeyHandlerPlugin* iPtrPlugin; |
|
75 |
|
76 /** |
|
77 * The keys handled by this plugin. |
|
78 */ |
|
79 RArray<TKeyEvent> iKeys; |
|
80 |
|
81 /** |
|
82 * Handles of the captured keys. |
|
83 */ |
|
84 RArray<TInt32> iKeyHandles; //Handles of keys when capturing them |
|
85 |
|
86 /** |
|
87 * Handles of the captured up and down events. |
|
88 */ |
|
89 RArray<TInt32> iUpAndDownKeyHandles; //Handles of keys when capturing them |
|
90 |
|
91 /** |
|
92 * Tells if the plugin is a key provider plugin (plugin version 2) |
|
93 */ |
|
94 TBool iIsKeyProvider; |
|
95 |
|
96 }; |
|
97 |
|
98 typedef RPointerArray<CSysApPluginInfo> RSysApPluginsArray; |
|
99 |
|
100 public: // Constructors and destructor |
|
101 |
|
102 /** |
|
103 * Default constructor |
|
104 * |
|
105 * @param aRootWindowGroup reference of the root window group |
|
106 * @param aSysApCallback reference to callback object |
|
107 * @return pointer to the constructed object |
|
108 */ |
|
109 static CSysApKeyManagement* NewL(RWindowGroup& aRootWindowGroup, MSysapCallback& aSysApCallback); |
|
110 |
|
111 /** |
|
112 * Destructor |
|
113 */ |
|
114 virtual ~CSysApKeyManagement(); |
|
115 |
|
116 public: // New functions |
|
117 |
|
118 /** |
|
119 * Handles key events |
|
120 * |
|
121 * @param aKeyEvent contains information about the key event |
|
122 * @param aType contains information about the type of the key event |
|
123 * @return response |
|
124 */ |
|
125 TKeyResponse HandleKeyEventL(const TKeyEvent& aKeyEvent, TEventCode aType ); |
|
126 |
|
127 |
|
128 private: // New functions |
|
129 |
|
130 /** |
|
131 * C++ default constructor. |
|
132 * |
|
133 * @param aRWindowGroup the root window group |
|
134 * @param aSysApCallback reference to callback object |
|
135 * @return void |
|
136 */ |
|
137 CSysApKeyManagement(RWindowGroup& aRWindowGroup, MSysapCallback& aSysApCallback); |
|
138 |
|
139 |
|
140 /** |
|
141 * 2nd phase constructor. |
|
142 * |
|
143 * @return void |
|
144 */ |
|
145 void ConstructL( ); |
|
146 |
|
147 /** |
|
148 * Registers in windows server for keys to capture. |
|
149 * |
|
150 * @return void |
|
151 */ |
|
152 void CaptureKeys(); |
|
153 |
|
154 /** |
|
155 * Unregisters in windows server for keys to capture. |
|
156 * |
|
157 * @return void |
|
158 */ |
|
159 void CancelCaptureKeys(); |
|
160 |
|
161 /** |
|
162 * Gets information of all suitable plugins |
|
163 * |
|
164 * @return void |
|
165 */ |
|
166 void GetPluginsL(); |
|
167 |
|
168 /** |
|
169 * Finds a key in plugins. Helper function. |
|
170 * |
|
171 * @param aKeycode key to find |
|
172 * @return index of key in array |
|
173 */ |
|
174 TInt FindKeyCode( TUint aKeycode ); |
|
175 |
|
176 /** |
|
177 * Finds a key scancode in plugins. Helper function. |
|
178 * |
|
179 * @param aScanCode key scancode to find |
|
180 * @return index of key in array |
|
181 */ |
|
182 TInt FindScanCode( TInt aScanCode ); |
|
183 |
|
184 /** |
|
185 * Get keys from text |
|
186 * |
|
187 * @param aLex reference to the object to be used, |
|
188 * @param aKeys reference to the array to be filled. |
|
189 * @return error code |
|
190 */ |
|
191 TInt GetKeys( TLex8& aLex, RArray<TKeyEvent>& aKeys ); |
|
192 |
|
193 /** |
|
194 * Check keys for duplicates and array emptiness |
|
195 * |
|
196 * @param aKeys reference to the array to be checked. |
|
197 * @return error code |
|
198 */ |
|
199 TInt CheckKeys( RArray<TKeyEvent>& aKeys ); |
|
200 |
|
201 private: // Data |
|
202 |
|
203 // Our window group from SysappUi |
|
204 RWindowGroup& iRootWindowGroup; |
|
205 |
|
206 // Reference to SysAp application callback |
|
207 MSysapCallback& iSysApCallback; |
|
208 |
|
209 /** |
|
210 * Key handler plugins managed by SysAp. |
|
211 */ |
|
212 RSysApPluginsArray iSysApPlugins; |
|
213 }; |
|
214 |
|
215 #endif //SYSAPKEYMANAGEMENT_H |
|
216 |