|
1 /* |
|
2 * Copyright (c) 2007,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: Channel class of Orientation SSY |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 #ifndef __SSYCHANNEL_H__ |
|
20 #define __SSYCHANNEL_H__ |
|
21 |
|
22 // INCLUDES |
|
23 #include <ssychanneldataprovider.h> // ssy plugin API data provider |
|
24 #include <ssypropertyprovider.h> // ssy plugin API property provider |
|
25 #include <sensrvchannelinfo.h> // sensor server channelinfo |
|
26 #include <sensrvchanneldatatypes.h> // sensor server datatypes |
|
27 #include <sensrvorientationsensor.h> // sensor server datatypes |
|
28 |
|
29 // CONSTANTS |
|
30 enum TChannelState |
|
31 { |
|
32 EChannelIdle = 0x0001, |
|
33 EChannelOpening = 0x0002, |
|
34 EChannelOpen = 0x0004, |
|
35 EChannelClosing = 0x0008, |
|
36 EChannelListening = 0x0010, |
|
37 EChannelDataReceived = 0x0020, |
|
38 EChannelStopListening = 0x0040, |
|
39 EChannelForceBufferFilled = 0x0080, |
|
40 EChannelBufferFilled = 0x0100 |
|
41 }; |
|
42 |
|
43 const TInt KChannelCanBeOpened = EChannelIdle; |
|
44 |
|
45 const TInt KChannelCanBeListened = EChannelOpen; |
|
46 |
|
47 const TInt KChannelCanBeFilled = EChannelListening | |
|
48 EChannelDataReceived; |
|
49 |
|
50 const TInt KChannelCanBeStopped = EChannelListening | |
|
51 EChannelDataReceived | |
|
52 EChannelForceBufferFilled | |
|
53 EChannelBufferFilled; |
|
54 |
|
55 const TInt KChannelCanBeClosed = EChannelOpening | |
|
56 EChannelOpen | |
|
57 EChannelListening | |
|
58 EChannelDataReceived | |
|
59 EChannelStopListening | |
|
60 EChannelForceBufferFilled | |
|
61 EChannelBufferFilled; |
|
62 |
|
63 // FORWARD DECLARATIONS |
|
64 class CSSYProperty; |
|
65 class MSsyCallback; |
|
66 class CSSYOrientation; |
|
67 |
|
68 |
|
69 // CLASS DECLARATION |
|
70 |
|
71 /** |
|
72 * CSSYChannel channel class |
|
73 * |
|
74 * Channel class for orientation ssy. |
|
75 * |
|
76 * @lib orientationssy.lib |
|
77 * @since S60 5.0 |
|
78 */ |
|
79 NONSHARABLE_CLASS( CSSYChannel ) : public CActive, |
|
80 public MSsyChannelDataProvider, |
|
81 public MSsyPropertyProvider |
|
82 { |
|
83 public: |
|
84 |
|
85 /** |
|
86 * Two phase constructor. |
|
87 * |
|
88 * @param aProperty Properties of this channel |
|
89 * @param aCallBack Callback class from sensor server |
|
90 * @param aChannelInfo Informnation os this channel |
|
91 */ |
|
92 static CSSYChannel* NewL( CSSYProperty* aProperty, |
|
93 MSsyCallback* const aCallBack, |
|
94 const TSensrvChannelInfo& aChannelInfo ); |
|
95 |
|
96 /** |
|
97 * Destructor. |
|
98 */ |
|
99 virtual ~CSSYChannel(); |
|
100 |
|
101 /** |
|
102 * Issue a request into the active scheduler. |
|
103 */ |
|
104 void IssueRequest( TInt aError = KErrNone ); |
|
105 |
|
106 /** |
|
107 * Append data into the client buffer. |
|
108 * |
|
109 * @param aOrientationData Orientation channel data |
|
110 * @param aRotationData Rotation channel data |
|
111 * @return TBool True if appending data is successfull |
|
112 */ |
|
113 TBool AppendData( const TSensrvOrientationData& aOrientationData, |
|
114 const TSensrvRotationData& aRotationData ); |
|
115 |
|
116 /** |
|
117 * Open the channel. Called by the controller. |
|
118 * |
|
119 * @return KErrNone if channel is opened successfully |
|
120 */ |
|
121 TInt OpenChannel(); |
|
122 |
|
123 /** |
|
124 * Close the channel. Called by the controller. |
|
125 * |
|
126 * @return KErrNone if channel is closed successfully |
|
127 */ |
|
128 TInt CloseChannel(); |
|
129 |
|
130 /** |
|
131 * Return the channelId of the channel. |
|
132 * |
|
133 * @return Channel identifier of this channel |
|
134 */ |
|
135 TSensrvChannelId ChannelId(); |
|
136 |
|
137 /** |
|
138 * Set the channel id for the channel after getting it from the client. |
|
139 * Called by the controller. |
|
140 * |
|
141 * @param aChannelId New channel identifier of this channel |
|
142 */ |
|
143 void SetChannelId( const TSensrvChannelId aChannelId ); |
|
144 |
|
145 private: |
|
146 |
|
147 /** |
|
148 * From CActive. Cancels any pending request |
|
149 */ |
|
150 void DoCancel(); |
|
151 |
|
152 /** |
|
153 * From CActive. Handles completed request |
|
154 */ |
|
155 void RunL(); |
|
156 |
|
157 /** |
|
158 * From CActive. Handles errors |
|
159 */ |
|
160 TInt RunError( TInt aError ); |
|
161 |
|
162 /** |
|
163 * From MSsyChannelDataProvider. Starts asynchronous data listening. |
|
164 */ |
|
165 void StartChannelDataL( const TSensrvChannelId aChannelId, |
|
166 TUint8* aBuffer, TInt aCount ); |
|
167 /** |
|
168 * From MSsyChannelDataProvider. Stops asynchronous data listening. |
|
169 */ |
|
170 void StopChannelDataL( const TSensrvChannelId aChannelId ); |
|
171 |
|
172 /** |
|
173 * From MSsyChannelDataProvider. Forces SSY to call BufferFilled() |
|
174 * regardless of how many data items have been written to buffer. |
|
175 */ |
|
176 void ForceBufferFilledL( const TSensrvChannelId aChannelId ); |
|
177 |
|
178 |
|
179 /** |
|
180 * From MSsyChannelDataProvider. |
|
181 */ |
|
182 void GetChannelDataProviderInterfaceL( TUid aInterfaceUid, |
|
183 TAny*& aInterface ); |
|
184 /** |
|
185 * From MSsyPropertyProvider. Check if property value affects other sensor |
|
186 * channels already open. |
|
187 */ |
|
188 void CheckPropertyDependenciesL( const TSensrvChannelId aChannelId, |
|
189 const TSensrvProperty& aProperty, |
|
190 RSensrvChannelList& aAffectedChannels ); |
|
191 |
|
192 /** |
|
193 * From MSsyPropertyProvider. Set property for the channel. |
|
194 */ |
|
195 void SetPropertyL( const TSensrvChannelId aChannelId, |
|
196 const TSensrvProperty& aProperty ); |
|
197 |
|
198 /** |
|
199 * From MSsyPropertyProvider. Get property for the channel. |
|
200 */ |
|
201 void GetPropertyL( const TSensrvChannelId aChannelId, |
|
202 TSensrvProperty& aProperty ); |
|
203 |
|
204 /** |
|
205 * From MSsyPropertyProvider. Get all properties for the channel. |
|
206 */ |
|
207 void GetAllPropertiesL( const TSensrvChannelId aChannelId, |
|
208 RSensrvPropertyList& aChannelPropertyList ); |
|
209 |
|
210 /** |
|
211 * From MSsyPropertyProvider. Get all properties for the channel. |
|
212 */ |
|
213 void GetPropertyProviderInterfaceL( TUid aInterfaceUid, |
|
214 TAny*& aInterface ); |
|
215 |
|
216 /** |
|
217 * C++ constructor. |
|
218 */ |
|
219 CSSYChannel( CSSYProperty* aProperty, |
|
220 MSsyCallback* const aCallBack, |
|
221 const TSensrvChannelInfo& aChannelInfo ); |
|
222 |
|
223 /** |
|
224 * Symbian 2nd phase constructor. |
|
225 */ |
|
226 void ConstructL(); |
|
227 |
|
228 /** |
|
229 * Return the channelinfo of the channel. |
|
230 */ |
|
231 TSensrvChannelInfo& ChannelInfo(); |
|
232 |
|
233 /** |
|
234 * Set the state of the channel. |
|
235 */ |
|
236 void SetChannelState( const TChannelState aChannelState ); |
|
237 |
|
238 private: // data |
|
239 |
|
240 /** |
|
241 * Orientation handler. |
|
242 */ |
|
243 CSSYOrientation* iOrientationHandler; |
|
244 |
|
245 /** |
|
246 * Channel specific properties. |
|
247 */ |
|
248 CSSYProperty* iChannelProperties; |
|
249 |
|
250 /** |
|
251 * Sensor specific properties common for all the channels. |
|
252 */ |
|
253 CSSYProperty* iSensorProperties; |
|
254 |
|
255 /** |
|
256 * Ssy callback class. |
|
257 */ |
|
258 MSsyCallback* iCallback; |
|
259 |
|
260 /** |
|
261 * Channel state. |
|
262 */ |
|
263 TChannelState iChannelState; |
|
264 |
|
265 /** |
|
266 * Channelinfo. |
|
267 */ |
|
268 TSensrvChannelInfo iChannelInfo; |
|
269 |
|
270 /** |
|
271 * Receive buffer for data. |
|
272 */ |
|
273 TUint8* iBuffer; |
|
274 |
|
275 /** |
|
276 * Amount of data to be received. |
|
277 */ |
|
278 TInt iCount; |
|
279 |
|
280 /** |
|
281 * Amount of data that is currently received. |
|
282 */ |
|
283 TInt iCountReceived; |
|
284 |
|
285 /** |
|
286 * Pointer into the buffer where we are writing currently. |
|
287 */ |
|
288 TUint8* iWritePointer; |
|
289 |
|
290 }; |
|
291 |
|
292 #endif // __SSYCHANNEL_H__ |
|
293 |
|
294 // End of File |