|
1 /* |
|
2 * Copyright (c) 2007 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: CTCChannel class declaration. |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 |
|
20 #ifndef TCCHANNEL_H |
|
21 #define TCCHANNEL_H |
|
22 |
|
23 // INCLUDES |
|
24 #include <e32base.h> |
|
25 #include <sensrvchannelinfo.h> |
|
26 #include <sensrvdatalistener.h> |
|
27 #include <ssypropertyprovider.h> |
|
28 #include <ssychanneldataprovider.h> |
|
29 #include <sensrvtypes.h> |
|
30 |
|
31 #include "tcstatepool.h" |
|
32 #include "tctransactionhandler.h" |
|
33 #include "tcstate.h" |
|
34 |
|
35 // FORWARD DECLARATIONS |
|
36 class MSsyCallback; |
|
37 |
|
38 // CLASS DECLARATION |
|
39 |
|
40 /** |
|
41 * Base class for a channel handler. Base class has the basic |
|
42 * implementation support for the state machine. |
|
43 * |
|
44 * Channel supports following states: |
|
45 * - Idle |
|
46 * - Open |
|
47 * - Listen data |
|
48 * - Buffer full |
|
49 * - Closing |
|
50 * |
|
51 * @lib None. |
|
52 * @since S60 5.0 |
|
53 */ |
|
54 NONSHARABLE_CLASS( CTCChannel ): public CActive, |
|
55 public MSsyPropertyProvider, |
|
56 public MSsyChannelDataProvider, |
|
57 public MTCStatePool, |
|
58 public MTCTransactionHandler |
|
59 { |
|
60 public: |
|
61 |
|
62 // Default C++ destructor |
|
63 ~CTCChannel(); |
|
64 |
|
65 public: // New methods |
|
66 |
|
67 /** |
|
68 * Updates correct channel ID received from sensor server. |
|
69 * |
|
70 * @param aId Channel ID. |
|
71 * @return None. |
|
72 */ |
|
73 virtual void SetChannelId( TSensrvChannelId aId ); |
|
74 |
|
75 /** |
|
76 * Returns channel ID. |
|
77 * |
|
78 * @return TSensrvChannelId. |
|
79 */ |
|
80 virtual TSensrvChannelId ChannelId() const; |
|
81 |
|
82 /** |
|
83 * Checks if the channel is supported. |
|
84 * |
|
85 * @param aInfo Sensor channel info. |
|
86 * @return ETrue if supported. |
|
87 */ |
|
88 virtual TBool ChannelSupported( const TSensrvChannelInfo& aInfo ); |
|
89 |
|
90 /** |
|
91 * Registers a channel supported by this channel instance. |
|
92 * |
|
93 * @param aChannels Channel list. |
|
94 * @return None. |
|
95 */ |
|
96 virtual void RegisterChannelL( RSensrvChannelInfoList& aChannels ) = 0; |
|
97 |
|
98 /** |
|
99 * Open the channel. |
|
100 */ |
|
101 virtual void OpenChannelL() = 0; |
|
102 |
|
103 /** |
|
104 * Close the channel. |
|
105 */ |
|
106 virtual void CloseChannelL() = 0; |
|
107 |
|
108 protected: // Methods from base classes |
|
109 |
|
110 // @see CActive |
|
111 void DoCancel(); |
|
112 |
|
113 // @see CActive |
|
114 TInt RunError( TInt aError ); |
|
115 |
|
116 // @see MTCStatePool |
|
117 CTCState* CurrentState() const; |
|
118 |
|
119 // @see MTCStatePool |
|
120 //CTCState* PreviousState() const; |
|
121 |
|
122 // @see MTCStatePool |
|
123 void ChangeStateL( TInt aStateId ); |
|
124 |
|
125 // @see MTCChannelTransaction |
|
126 //TBool ReadyForTransaction() const; |
|
127 |
|
128 // @see MTCChannelTransaction |
|
129 TUint8* DataBuffer() const; |
|
130 |
|
131 // @see MTCChannelTransaction |
|
132 TInt DataCount() const; |
|
133 |
|
134 protected: // New methods |
|
135 |
|
136 /** |
|
137 * Constructor |
|
138 */ |
|
139 void BaseConstructL(); |
|
140 |
|
141 /** |
|
142 * Finds a sensor channel. |
|
143 * |
|
144 * @param aChannelTypeId Channel type ID. |
|
145 * @param aLocation Location of the sensor. |
|
146 * @param aVendorId Sensor vendor ID. |
|
147 * @param aChannelInfo Found channel info. |
|
148 * @return ETrue if channel found. |
|
149 */ |
|
150 static TBool FindChannelL( const TSensrvChannelTypeId& aChannelTypeId, |
|
151 const TDesC8& aLocation, |
|
152 const TDesC8& aVendorId, |
|
153 TSensrvChannelInfo& aChannelInfo ); |
|
154 |
|
155 /** |
|
156 * Register a state. |
|
157 * Only the state with aStateId can be registered. |
|
158 * |
|
159 * @param aStateId State to register. |
|
160 * @param aStateArray Array where to add the state. |
|
161 */ |
|
162 virtual void RegisterStateL( CTCState::TCStateId aStateId, |
|
163 RStateArray& aStateArray ) = 0; |
|
164 |
|
165 /** |
|
166 * Forces the current transaction to be completed. |
|
167 * |
|
168 * @param aCode Completion code of the transaction. |
|
169 */ |
|
170 virtual void CompleteTransaction( TInt aCode ); |
|
171 |
|
172 protected: |
|
173 |
|
174 /** |
|
175 * Default C++ constructor. |
|
176 */ |
|
177 CTCChannel( MSsyCallback& aCallback ); |
|
178 |
|
179 private: // New methods |
|
180 |
|
181 // Completes pending request |
|
182 void CompleteSelf( TInt aCode ); |
|
183 |
|
184 protected: // Data for inherited channels |
|
185 |
|
186 /** Channel ID */ |
|
187 TSensrvChannelInfo iChannelInfo; |
|
188 |
|
189 /** SSY callback interface */ |
|
190 MSsyCallback& iCallback; |
|
191 |
|
192 /** Current transaction ID */ |
|
193 TTCTransactionId iCurrentTransactionId; |
|
194 |
|
195 /** Current transaction, not owned */ |
|
196 TTCTransaction* iCurrentTransaction; |
|
197 |
|
198 /** Data buffer, not owned */ |
|
199 TUint8* iData; |
|
200 |
|
201 /** Data buffer count */ |
|
202 TInt iCount; |
|
203 |
|
204 private: // Private data for base channel |
|
205 |
|
206 /** State pool */ |
|
207 RStateArray iStatePool; |
|
208 |
|
209 /** Current state pointer, not owned */ |
|
210 CTCState* iCurrentState; |
|
211 |
|
212 /** Previous state pointer, not owned */ |
|
213 CTCState* iPreviousState; |
|
214 }; |
|
215 |
|
216 /** Channel array */ |
|
217 typedef RPointerArray<CTCChannel> RChannelArray; |
|
218 |
|
219 #endif // TCCHANNEL_H |
|
220 |
|
221 // End of File |