|
1 /* |
|
2 * Copyright (c) 2008 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: Haptics status observer header file. |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 #ifndef HWRMHAPTICSSTATUSOBSERVER_H |
|
20 #define HWRMHAPTICSSTATUSOBSERVER_H |
|
21 |
|
22 #include <e32base.h> |
|
23 #include <hwrmhapticsobserver.h> |
|
24 #include "hwrmhapticsclientserver.h" |
|
25 |
|
26 class RHWRMHapticsGenericClient; |
|
27 class MHWRMHapticsActuatorObserver; |
|
28 |
|
29 /** |
|
30 * Active object for observing haptics status changes in the |
|
31 * haptics server. |
|
32 * |
|
33 * @lib hwrmhapticsclient.lib |
|
34 * @since S60 5.1 |
|
35 */ |
|
36 NONSHARABLE_CLASS( CHWRMHapticsStatusObserver ): public CActive |
|
37 { |
|
38 public: |
|
39 |
|
40 /** |
|
41 * Two-phased constructor. A newly created instance starts |
|
42 * immediately listening to status changes. |
|
43 * |
|
44 * @param aHapticsCallback Pointer to a haptics status callback instance. |
|
45 * If NULL, status values are not notified to the user of haptics client. |
|
46 * @param aActuatorCallback Pointer to a actuator status callback instance. |
|
47 * If NULL, status values are not notified to the user of haptics client. |
|
48 * @param aClient Open session to haptics server for status value |
|
49 * observation. |
|
50 * @return A pointer to a newly created instance. |
|
51 */ |
|
52 static CHWRMHapticsStatusObserver* NewL( |
|
53 MHWRMHapticsObserver* aHapticsCallback, |
|
54 MHWRMHapticsActuatorObserver* aActuatorCallback, |
|
55 RHWRMHapticsSession* aClient ); |
|
56 |
|
57 /** |
|
58 * Destructor. |
|
59 */ |
|
60 virtual ~CHWRMHapticsStatusObserver(); |
|
61 |
|
62 /** |
|
63 * Retrieves the current haptics status. |
|
64 * |
|
65 * @return THWRMHapticsStatus indicating the current haptics status. |
|
66 */ |
|
67 MHWRMHapticsObserver::THWRMHapticsStatus CurrentStatus() const; |
|
68 |
|
69 protected: |
|
70 |
|
71 /** |
|
72 * @see CActive |
|
73 */ |
|
74 virtual void RunL(); |
|
75 |
|
76 /** |
|
77 * @see CActive |
|
78 */ |
|
79 virtual TInt RunError(TInt aError); |
|
80 |
|
81 /** |
|
82 * @see CActive |
|
83 */ |
|
84 virtual void DoCancel(); |
|
85 |
|
86 private: |
|
87 |
|
88 /** |
|
89 * Constructor. |
|
90 * |
|
91 * @param aHapticsCallback Pointer to haptics status callback instance. |
|
92 * @param aActuatorCallback Pointer to actuator status callback instance. |
|
93 * @param aClient Open session to haptics server for status value |
|
94 * observation. |
|
95 */ |
|
96 CHWRMHapticsStatusObserver( MHWRMHapticsObserver* aHapticsCallback, |
|
97 MHWRMHapticsActuatorObserver* aActuatorCallback, |
|
98 RHWRMHapticsSession* aClient ); |
|
99 |
|
100 /** |
|
101 * By default Symbian 2nd phase constructor. |
|
102 */ |
|
103 void ConstructL(); |
|
104 |
|
105 /** |
|
106 * Activates this object and starts observation. |
|
107 */ |
|
108 void OrderNotification(); |
|
109 |
|
110 /** |
|
111 * Based on available callback instances, returns the type |
|
112 * of status notification, which should be used in notification |
|
113 * requests. |
|
114 * |
|
115 * @return Status type to be used in notification requests. |
|
116 */ |
|
117 THWRMHapticsStatusTypes NotificationStatusType() const; |
|
118 |
|
119 private: |
|
120 |
|
121 /** |
|
122 * Internal typedef for haptics status enumeration. |
|
123 */ |
|
124 typedef MHWRMHapticsObserver::THWRMHapticsStatus THapticsStatus; |
|
125 |
|
126 /** |
|
127 * Internal typedef for actuator event enumeration. |
|
128 */ |
|
129 typedef MHWRMHapticsActuatorObserver::THWRMActuatorEvents TActuatorStatus; |
|
130 |
|
131 private: |
|
132 /** |
|
133 * Haptics status callback instance. Not owned. |
|
134 */ |
|
135 MHWRMHapticsObserver* iHapticsCallback; |
|
136 |
|
137 /** |
|
138 * Actuator status callback instance. Not owned. |
|
139 */ |
|
140 MHWRMHapticsActuatorObserver* iActuatorCallback; |
|
141 |
|
142 /** |
|
143 * Connection to haptics server. Not owned. |
|
144 */ |
|
145 RHWRMHapticsSession* iClient; |
|
146 |
|
147 /** |
|
148 * Last haptics status received. |
|
149 */ |
|
150 THapticsStatus iHapticsStatus; |
|
151 |
|
152 /** |
|
153 * Last status value received from server. This value can be of |
|
154 * either THWRMHapticsStatus or THWRMActuatorEvents. |
|
155 */ |
|
156 TInt iLastStatus; |
|
157 |
|
158 /** |
|
159 * Indication of which type of status was received the last time. |
|
160 * Also used when sending notification request to indicate what type |
|
161 * of statuses should be notified. |
|
162 */ |
|
163 THWRMHapticsStatusTypes iStatusType; |
|
164 |
|
165 /** |
|
166 * Actuator type to which received actuator event is related to. |
|
167 */ |
|
168 THWRMLogicalActuators iActuator; |
|
169 |
|
170 /** |
|
171 * Status package for async calls. |
|
172 */ |
|
173 TPckg<TInt> iStatusPckg; |
|
174 |
|
175 /** |
|
176 * Status type package for async calls. |
|
177 */ |
|
178 TPckg<THWRMHapticsStatusTypes> iStatusTypePckg; |
|
179 |
|
180 /** |
|
181 * Actuator type package for async calls. |
|
182 */ |
|
183 TPckg<THWRMLogicalActuators> iActuatorPckg; |
|
184 }; |
|
185 |
|
186 #endif // HWRMHAPTICSSTATUSOBSERVER_H |
|
187 |
|
188 // End of File |