|
1 // ssyreferencechannel.h |
|
2 |
|
3 /* |
|
4 * Copyright (c) 2006-2009 Nokia Corporation and/or its subsidiary(-ies). |
|
5 * All rights reserved. |
|
6 * This component and the accompanying materials are made available |
|
7 * under the terms of "Eclipse Public License v1.0" |
|
8 * which accompanies this distribution, and is available |
|
9 * at the URL "http://www.eclipse.org/legal/epl-v10.html". |
|
10 * |
|
11 * Initial Contributors: |
|
12 * Nokia Corporation - initial contribution. |
|
13 * |
|
14 * Contributors: |
|
15 * |
|
16 * Description: |
|
17 * |
|
18 */ |
|
19 |
|
20 |
|
21 |
|
22 |
|
23 /** |
|
24 @file |
|
25 @internalComponent |
|
26 */ |
|
27 |
|
28 #ifndef SSYREFERENCECHANNEL_H |
|
29 #define SSYREFERENCECHANNEL_H |
|
30 |
|
31 #include <e32base.h> |
|
32 #include <sensors/sensrvtypes.h> |
|
33 #include "ssyreferenceconfig.h" |
|
34 |
|
35 class CSsyReferenceControl; |
|
36 class CSsyReferenceChannelDataProvider; |
|
37 class CSsyReferencePropertyProvider; |
|
38 class CSsyReferenceCmdHandler; |
|
39 |
|
40 /** |
|
41 * Main control class for SSY. Controls sensor basic functionality and provides mandatory |
|
42 * ECOM interface specific things. |
|
43 */ |
|
44 class CSsyReferenceChannel : public CBase |
|
45 { |
|
46 |
|
47 public: |
|
48 |
|
49 /** |
|
50 * Enumeration of the state of this channel |
|
51 */ |
|
52 enum TSsyReferenceChannelState |
|
53 { |
|
54 ESsyReferenceChannelIdle, // Channel created, not opened |
|
55 ESsyReferenceChannelOpening, // Processing channel opening |
|
56 ESsyReferenceChannelOpen, // Channel is open |
|
57 ESsyReferenceChannelReceiving, // Channel is receiving data |
|
58 ESsyReferenceChannelClosing // Processing channel closing. After this state is idle |
|
59 }; |
|
60 |
|
61 public: |
|
62 |
|
63 /** |
|
64 * Two-phase constructor |
|
65 * |
|
66 * @param[in] aSsyControl Reference to SSY control instance. |
|
67 * @param[in] aChannelInfo Information of this channel |
|
68 * @return Pointer to created CSsyReferenceControl object |
|
69 */ |
|
70 static CSsyReferenceChannel* NewL( CSsyReferenceControl& aSsyControl, TSensrvChannelInfo aChannelInfo ); |
|
71 |
|
72 /** |
|
73 * Virtual destructor |
|
74 */ |
|
75 virtual ~CSsyReferenceChannel(); |
|
76 |
|
77 /** |
|
78 * Request for SSY to open a sensor channel asynchronously. |
|
79 * Response to the request is delivered through MSsyCallback::ChannelOpened(). |
|
80 * Initilizes SSY (and the sensor) to be ready for other control commands via |
|
81 * data and property providers. Multiple OpenChannel()-requests can be |
|
82 * active for different channels at the same time. |
|
83 * |
|
84 * @return Symbian error code |
|
85 */ |
|
86 TInt OpenChannel(); |
|
87 |
|
88 /** |
|
89 * Request to close a sensor channel asynchronously. |
|
90 * Response to the request is delivered through MSsyCallback::ChannelClosed(). |
|
91 * Multiple CloseChannel()-requests can be active for different channels |
|
92 * at the same time. |
|
93 * |
|
94 * @return Symbian error code |
|
95 */ |
|
96 TInt CloseChannel(); |
|
97 |
|
98 /** |
|
99 * Returns ID of this channel |
|
100 */ |
|
101 TInt ChannelId(); |
|
102 |
|
103 /** |
|
104 * Handles response directed to this channel |
|
105 * |
|
106 * @param[in] aMessage Contains information of the response |
|
107 */ |
|
108 void ProcessResponse( TSsyReferenceMsg* aMessage ); |
|
109 |
|
110 /** |
|
111 * Updates the state of this channel |
|
112 * |
|
113 * @param[in] aNewState State to update this channel |
|
114 */ |
|
115 void UpdateState( const TSsyReferenceChannelState aNewState ); |
|
116 |
|
117 /** |
|
118 * Reference to SsyControl |
|
119 */ |
|
120 CSsyReferenceControl& SsyControl() const; |
|
121 |
|
122 /** |
|
123 * Reference to command handler |
|
124 */ |
|
125 CSsyReferenceCmdHandler& CommandHandler() const; |
|
126 |
|
127 /** |
|
128 * Search property of given property id from the channel properties and |
|
129 * returns reference to that. Leaves with KErrNotFound if property is not found |
|
130 * |
|
131 * @param[in] aPropertyId Property ID to locate |
|
132 * @param[in] aItemIndex Item index if this search conserns specific property |
|
133 * @param[in] aArrayIndex Indicates array index of property |
|
134 */ |
|
135 TSensrvProperty& FindPropertyL( const TSensrvPropertyId aPropertyId, |
|
136 TInt aItemIndex = KErrNotFound, |
|
137 TInt aArrayIndex = ESensrvSingleProperty ); |
|
138 |
|
139 /** |
|
140 * Search property of given property id from the channel properties and |
|
141 * update property values, if not read only |
|
142 * |
|
143 * @param[in] aProperty Property to find and update |
|
144 */ |
|
145 void FindAndUpdatePropertyL( const TSensrvProperty& aProperty ); |
|
146 |
|
147 |
|
148 /** |
|
149 * Copies properties to param PropertyList |
|
150 * |
|
151 * @param[in, out] aPropertyList List where to copy properties |
|
152 */ |
|
153 void GetProperties( RSensrvPropertyList& aPropertyList ); |
|
154 |
|
155 private: |
|
156 |
|
157 /** |
|
158 * C++ constructor. |
|
159 * |
|
160 * @param[in] aSsyControl Reference to SSY Control instance. |
|
161 * @param[in] aChannelInfo Information of this channel |
|
162 */ |
|
163 CSsyReferenceChannel( CSsyReferenceControl& aSsyControl, TSensrvChannelInfo aChannelInfo ); |
|
164 |
|
165 /** |
|
166 * Symbian 2nd phase constructor. |
|
167 */ |
|
168 void ConstructL(); |
|
169 |
|
170 /** |
|
171 * Handles response for OpenChannel and completes transaction by calling |
|
172 * MSsyCallback::ChannelOpened |
|
173 * |
|
174 * @param[in] aError Error code indicating the channel opening status |
|
175 */ |
|
176 void HandleOpenChannelRespL( const TInt aError ); |
|
177 |
|
178 /** |
|
179 * Handles response for CloseChannel and completes transaction by calling |
|
180 * MSsyCallback::ChannelClosed |
|
181 */ |
|
182 void HandleCloseChannelResp(); |
|
183 |
|
184 /** |
|
185 * Handles response for StartChannelData. Loops all channel data items and sends |
|
186 * each item to ChannelDataProvider |
|
187 */ |
|
188 void HandleDataReceivedResp(); |
|
189 |
|
190 private: // data |
|
191 |
|
192 /** |
|
193 * Reference to SSY Control to send responses to Sensor Server |
|
194 */ |
|
195 CSsyReferenceControl& iSsyControl; |
|
196 |
|
197 /** |
|
198 * Pointer to CSsyReferenceChannelDataProvider owned by this channel |
|
199 */ |
|
200 CSsyReferenceChannelDataProvider* iChannelDataProvider; |
|
201 |
|
202 /** |
|
203 * Pointer to CSsyReferencePropertyProvider owned by this channel |
|
204 */ |
|
205 CSsyReferencePropertyProvider* iChannelPropertyProvider; |
|
206 |
|
207 /** |
|
208 * Pointer to command handler |
|
209 */ |
|
210 CSsyReferenceCmdHandler* iCmdHandler; |
|
211 |
|
212 /** |
|
213 * Information of this channel |
|
214 */ |
|
215 TSensrvChannelInfo iChannelInfo; |
|
216 |
|
217 /** |
|
218 * State of this channel. See CSsyReferenceChannel::TSsyReferenceChannelState |
|
219 */ |
|
220 TInt iState; |
|
221 |
|
222 /** |
|
223 * Property list of this channel |
|
224 */ |
|
225 RSensrvPropertyList iProperties; |
|
226 }; |
|
227 |
|
228 #endif // SSYREFERENCECHANNEL_H |