1 /* |
|
2 * ============================================================================ |
|
3 * Name : hgteleportdevicestate.h |
|
4 * Part of : Hg Teleport |
|
5 * Description : Device state (touch mode, screen orientation) handler |
|
6 * Version : %version: sa1spcx1#11 % |
|
7 * |
|
8 * Copyright © 2008 Nokia. All rights reserved. |
|
9 * This material, including documentation and any related computer |
|
10 * programs, is protected by copyright controlled by Nokia. All |
|
11 * rights are reserved. Copying, including reproducing, storing, |
|
12 * adapting or translating, any or all of this material requires the |
|
13 * prior written consent of Nokia. This material also contains |
|
14 * confidential information which may not be disclosed to others |
|
15 * without the prior written consent of Nokia. |
|
16 * ============================================================================ |
|
17 * Template version: 4.2 |
|
18 */ |
|
19 |
|
20 #ifndef HGTELEPORTDEVICESTATE_H_ |
|
21 #define HGTELEPORTDEVICESTATE_H_ |
|
22 |
|
23 #include <e32base.h> |
|
24 #include "hgteleportappui.h" |
|
25 #include "hgproplistener.h" |
|
26 |
|
27 /** |
|
28 * Interface for getting notifications about screen orientation |
|
29 * and/or touch state etc. changes. |
|
30 */ |
|
31 class MHgDeviceStateObserver |
|
32 { |
|
33 public: |
|
34 /** |
|
35 * Type of change. |
|
36 */ |
|
37 enum TChangeType |
|
38 { |
|
39 // screen orientation (portrait <=> landscape) has changed |
|
40 EOrientation = 0x01, |
|
41 // touch enabled/disabled status has changed |
|
42 ETouchState = 0x02, |
|
43 // skin has changed |
|
44 ESkin = 0x04, |
|
45 // input device mode change |
|
46 EDeviceType = 0x08, |
|
47 // all of the above |
|
48 EAny = 0xFF |
|
49 }; |
|
50 |
|
51 /** |
|
52 * Called when a change, to which the observer is registered, |
|
53 * has happened. |
|
54 */ |
|
55 virtual void HandleDeviceStateChanged( TChangeType aChangeType ) = 0; |
|
56 }; |
|
57 |
|
58 /** |
|
59 * Class for keeping track of screen orientation and touch enabled/disabled changes. |
|
60 */ |
|
61 class CHgTeleportDeviceState : |
|
62 public CBase, |
|
63 public MHgPropertyChangeObserver |
|
64 { |
|
65 public: |
|
66 /** |
|
67 * Enumeration for TouchState(). |
|
68 */ |
|
69 enum TTouchState |
|
70 { |
|
71 ETouchEnabled, |
|
72 ETouchDisabled |
|
73 }; |
|
74 |
|
75 /** |
|
76 * Enumeration for Orientation(). |
|
77 */ |
|
78 enum TOrientation |
|
79 { |
|
80 EPortrait, |
|
81 ELandscape |
|
82 }; |
|
83 |
|
84 /** |
|
85 * Enumeration for DeviceType(). |
|
86 */ |
|
87 enum TDeviceType |
|
88 { |
|
89 EHybrid = 0, |
|
90 EFullTouch = 1 |
|
91 }; |
|
92 |
|
93 /** |
|
94 * Creates a new instance. |
|
95 */ |
|
96 static CHgTeleportDeviceState* NewL(); |
|
97 |
|
98 /** |
|
99 * Destructor. |
|
100 */ |
|
101 ~CHgTeleportDeviceState(); |
|
102 |
|
103 /** |
|
104 * Returns the current state of touch awareness. |
|
105 */ |
|
106 TTouchState TouchState() const; |
|
107 |
|
108 /** |
|
109 * Returns the current screen orientation. |
|
110 */ |
|
111 TOrientation Orientation() const; |
|
112 |
|
113 /** |
|
114 * Returns the current device input type. |
|
115 */ |
|
116 TDeviceType DeviceType() const; |
|
117 |
|
118 /** |
|
119 * Registers an observer. |
|
120 * @param aObserver ref to observer |
|
121 * (same observer can be added several times with different mask if needed) |
|
122 * @param aMask bitmask composed from TChangeType values |
|
123 * (when to notify the observer) |
|
124 */ |
|
125 void AddObserverL( MHgDeviceStateObserver& aObserver, TInt aMask ); |
|
126 |
|
127 /** |
|
128 * Deregisters the given observer. |
|
129 * @param aObserver ref to observer |
|
130 */ |
|
131 void RemoveObserver( MHgDeviceStateObserver& aObserver ); |
|
132 |
|
133 /** |
|
134 * Called from appui. |
|
135 */ |
|
136 void HandleResourceChange( TInt aType ); |
|
137 |
|
138 //From MHgPropertyChangeObserver |
|
139 public: |
|
140 /** |
|
141 * Observer interface for getting notifications about a P&S property change. |
|
142 */ |
|
143 virtual void PropertyChanged( TUid aCategory, TUint aKey ); |
|
144 private: |
|
145 /** |
|
146 * Constructor. |
|
147 */ |
|
148 CHgTeleportDeviceState(); |
|
149 |
|
150 /** |
|
151 * Performs 2nd phase construction. |
|
152 */ |
|
153 void ConstructL(); |
|
154 |
|
155 /** |
|
156 * Checks if touch is enabled or not and performs |
|
157 * appropriate actions. |
|
158 */ |
|
159 void CheckTouchState(); |
|
160 |
|
161 /** |
|
162 * Checks the screen orientation and performs |
|
163 * appropriate actions. |
|
164 */ |
|
165 void CheckOrientation(); |
|
166 |
|
167 /** |
|
168 * Checks the device input type. |
|
169 */ |
|
170 void CheckDeviceType(); |
|
171 |
|
172 /** |
|
173 * Notifies all observers that are registered for the given type. |
|
174 */ |
|
175 void NotifyObservers( MHgDeviceStateObserver::TChangeType aType ); |
|
176 |
|
177 class SObserver; |
|
178 |
|
179 /** |
|
180 * Identity function to perform comparison between observer array items. |
|
181 */ |
|
182 static TBool ObserverIdentity( const SObserver& aA, const SObserver& aB ); |
|
183 |
|
184 private: |
|
185 /** |
|
186 * Current touch enabled/disabled state. |
|
187 */ |
|
188 TTouchState iTouchState; |
|
189 |
|
190 /** |
|
191 * Current screen orientation. |
|
192 */ |
|
193 TOrientation iOrientation; |
|
194 |
|
195 /** |
|
196 * Current the device input type. |
|
197 */ |
|
198 TDeviceType iDeviceType; |
|
199 |
|
200 /** |
|
201 * Observer array entry struct. |
|
202 */ |
|
203 struct SObserver |
|
204 { |
|
205 TInt iMask; |
|
206 MHgDeviceStateObserver* iObserver; // not owned |
|
207 SObserver( TInt aMask, MHgDeviceStateObserver* aObserver ) |
|
208 : iMask( aMask ), iObserver( aObserver ) { } |
|
209 }; |
|
210 |
|
211 /** |
|
212 * Observer array. |
|
213 */ |
|
214 RArray<SObserver> iObservers; |
|
215 |
|
216 /** |
|
217 * Counter to indicate that we have not yet returned |
|
218 * from a previous HandleResourceChange. |
|
219 */ |
|
220 TInt iResChangeActiveCount; |
|
221 |
|
222 /** |
|
223 * Flip status change observer. |
|
224 */ |
|
225 CHgPropertyListener* iFlipStatusObserver; |
|
226 }; |
|
227 |
|
228 #endif // HGTELEPORTDEVICESTATE_H_ |
|