|
1 /* |
|
2 * Copyright (c) 2006 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: Data handler |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 #ifndef CSENSRVDATAHANDLER_H |
|
20 #define CSENSRVDATAHANDLER_H |
|
21 |
|
22 |
|
23 #include <e32base.h> |
|
24 |
|
25 #include "sensrvclient.h" |
|
26 |
|
27 |
|
28 class MSensrvDataHandlerObserver; |
|
29 |
|
30 /** |
|
31 * Data handler class |
|
32 * |
|
33 * @lib SensorClient.lib |
|
34 * @since S60 5.0 |
|
35 */ |
|
36 NONSHARABLE_CLASS( CSensrvDataHandler ) : public CActive |
|
37 { |
|
38 public: |
|
39 |
|
40 |
|
41 static CSensrvDataHandler* NewL( RSensrvClient& aSensrvClient, const TSensrvChannelInfo& aChannelInfo ); |
|
42 |
|
43 static CSensrvDataHandler* NewLC( RSensrvClient& aSensrvClient, const TSensrvChannelInfo& aChannelInfo ); |
|
44 |
|
45 virtual ~CSensrvDataHandler(); |
|
46 |
|
47 |
|
48 public: |
|
49 /** |
|
50 * Start data listening. Send request to server. |
|
51 * |
|
52 * @since S60 5.0 |
|
53 * @param aDataListener Data listener for channel. |
|
54 * @param aListeningParameters Listening parameters |
|
55 * @pararm aMaxBufferSize Maximum allowed buffer size |
|
56 */ |
|
57 void StartListeningL( MSensrvDataHandlerObserver* aDataListener, |
|
58 TSensrvStartListeningParameters aListeningParameters, |
|
59 TInt aMaxBufferSize ); |
|
60 |
|
61 /** |
|
62 * Get next data item. |
|
63 * |
|
64 * @since S60 5.0 |
|
65 * @param aDataPtr Reference to pointer data to be written |
|
66 * @return TInt KErrNotFound if data buffer is empty. |
|
67 */ |
|
68 TInt GetData( TDes8& aDataPtr ); |
|
69 |
|
70 |
|
71 protected: // From CActive |
|
72 |
|
73 void DoCancel(); |
|
74 void RunL(); |
|
75 TInt RunError(TInt aError); |
|
76 |
|
77 |
|
78 private: |
|
79 |
|
80 CSensrvDataHandler( RSensrvClient& aSensrvClient, const TSensrvChannelInfo& aChannelInfo ); |
|
81 |
|
82 void ConstructL(); |
|
83 |
|
84 /** |
|
85 * Create and send request to server |
|
86 */ |
|
87 void CreateAndSendRequest(); |
|
88 |
|
89 |
|
90 private: // data |
|
91 |
|
92 /** |
|
93 * Client |
|
94 */ |
|
95 RSensrvClient& iSensrvClient; |
|
96 |
|
97 /** |
|
98 * Data listener |
|
99 * Not own. |
|
100 */ |
|
101 MSensrvDataHandlerObserver* iDataObserver; |
|
102 |
|
103 /** |
|
104 * Data listening parameters |
|
105 */ |
|
106 TSensrvStartListeningParameters iListeningParameters; |
|
107 |
|
108 /** |
|
109 * Channel info |
|
110 */ |
|
111 TSensrvChannelInfo iChannelInfo; |
|
112 |
|
113 /** |
|
114 * Server write data to here |
|
115 * Own |
|
116 */ |
|
117 HBufC8* iWriteBuffer; |
|
118 |
|
119 /** |
|
120 * Pointer to iWriteBuffer data |
|
121 * Own |
|
122 */ |
|
123 TPtr8* iWriteBufferPtr; |
|
124 |
|
125 /** |
|
126 * Client read data from here |
|
127 * Own |
|
128 */ |
|
129 HBufC8* iReadBuffer; |
|
130 |
|
131 /** |
|
132 * Read buffer count |
|
133 */ |
|
134 TInt iReadBufferCount; |
|
135 |
|
136 /** |
|
137 * Counter for data getting |
|
138 */ |
|
139 TInt iGetDataCount; |
|
140 |
|
141 /** |
|
142 * Data count package |
|
143 */ |
|
144 TSensrvAsyncChannelDataCountsRetvalPckgBuf iDataCountsPckgBuf; |
|
145 |
|
146 /** |
|
147 * Error count |
|
148 */ |
|
149 TInt iErrorCount; |
|
150 |
|
151 }; |
|
152 |
|
153 |
|
154 |
|
155 #endif // CSENSRVDATAHANDLER_H |