0
|
1 |
/*
|
|
2 |
* Copyright (c) 2005-2009 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:
|
|
15 |
*
|
|
16 |
*/
|
|
17 |
|
|
18 |
|
|
19 |
|
|
20 |
/********************************************************************************
|
|
21 |
*
|
|
22 |
* Stat interfaces
|
|
23 |
*
|
|
24 |
********************************************************************************/
|
|
25 |
#ifndef __MSTATAPITRANSPORT_H__
|
|
26 |
#define __MSTATAPITRANSPORT_H__
|
|
27 |
|
|
28 |
/********************************************************************************
|
|
29 |
*
|
|
30 |
* System Includes
|
|
31 |
*
|
|
32 |
********************************************************************************/
|
|
33 |
#include <e32std.h>
|
|
34 |
#include <f32file.h>
|
|
35 |
|
|
36 |
/********************************************************************************
|
|
37 |
*
|
|
38 |
* Types
|
|
39 |
*
|
|
40 |
********************************************************************************/
|
|
41 |
enum TTransportResult {
|
|
42 |
KSTErrSuccess,
|
|
43 |
KSTErrAsynchronous,
|
|
44 |
KSTErrGeneralFailure,
|
|
45 |
KSTErrReadFailure,
|
|
46 |
KSTErrWriteFailure,
|
|
47 |
KSTErrConnectFailure,
|
|
48 |
KSTErrUnexpectedFragmentCommand,
|
|
49 |
KSTErrResyncCommand
|
|
50 |
};
|
|
51 |
|
|
52 |
enum TCommStatus {
|
|
53 |
EIdle,
|
|
54 |
EInitialising,
|
|
55 |
EInitialised,
|
|
56 |
EConnecting,
|
|
57 |
EConnected,
|
|
58 |
EDisconnecting,
|
|
59 |
EDisconnected,
|
|
60 |
EReleasing,
|
|
61 |
ESendPending,
|
|
62 |
EReceivePending,
|
|
63 |
ELast
|
|
64 |
};
|
|
65 |
|
|
66 |
enum TReadWriteStatus {
|
|
67 |
ENoRW,
|
|
68 |
EWritePending,
|
|
69 |
EReadPending
|
|
70 |
};
|
|
71 |
|
|
72 |
enum TStatConnectType {
|
|
73 |
ETCPIP,
|
|
74 |
ESerial,
|
|
75 |
EInfrared,
|
|
76 |
EBluetooth,
|
|
77 |
EUsb,
|
|
78 |
// ...
|
|
79 |
ENumConnectTypes,
|
|
80 |
};
|
|
81 |
|
|
82 |
/********************************************************************************
|
|
83 |
*
|
|
84 |
* MNotifyStatTransport - callback interface given to network on transport
|
|
85 |
*
|
|
86 |
********************************************************************************/
|
|
87 |
class MNotifyStatTransport
|
|
88 |
{
|
|
89 |
public:
|
|
90 |
virtual void HandleInitialise( TInt aResult ) = 0;
|
|
91 |
virtual void HandleConnect( TInt aResult ) = 0;
|
|
92 |
virtual void HandleSend( TInt aResult ) = 0;
|
|
93 |
virtual void HandleReceive( TInt aResult, TDesC8 *aData, TUint aDataLength ) = 0;
|
|
94 |
virtual void HandleDisconnect( TInt aResult ) = 0;
|
|
95 |
virtual void HandleRelease( TInt aResult ) = 0;
|
|
96 |
virtual void HandleError( TInt aError, void *aErrorData ) = 0;
|
|
97 |
virtual void HandleInfo( const TDesC *aInfo ) = 0;
|
|
98 |
};
|
|
99 |
|
|
100 |
/********************************************************************************
|
|
101 |
*
|
|
102 |
* MDataSupplier - interface to contain a data buffer and means for users
|
|
103 |
* to access the data through this object.
|
|
104 |
* Its purpose is to prevent the need for many data buffers
|
|
105 |
* to be created by each object that needs data (instead
|
|
106 |
* one instance of this interface will be passed), and also
|
|
107 |
* it will hide from the user certain implementations such
|
|
108 |
* as reading data from a file when more data is needed
|
|
109 |
* (this prevents the need to read all the data from a
|
|
110 |
* file at one time).
|
|
111 |
* For STAT the purpose of this is to buffer data sent from
|
|
112 |
* the device to the PC. The data is buffered when it is
|
|
113 |
* sent to the PC.
|
|
114 |
*
|
|
115 |
********************************************************************************/
|
|
116 |
class MDataSupplier
|
|
117 |
{
|
|
118 |
public:
|
|
119 |
// Destroy this object.
|
|
120 |
// After this call the memory is deleted and any pointers to
|
|
121 |
// the object become invalid.
|
|
122 |
virtual void Delete( void ) = 0;
|
|
123 |
|
|
124 |
// Return the total size of the data available through
|
|
125 |
// this data supplier.
|
|
126 |
// The return value is one of the standard error codes:
|
|
127 |
// KErrNone
|
|
128 |
virtual TInt GetTotalSize( TInt &aTotalSize ) = 0;
|
|
129 |
// Return the size of the data that is remaining in this
|
|
130 |
// data supplier.
|
|
131 |
// The return value is one of the standard error codes:
|
|
132 |
// KErrNone
|
|
133 |
virtual TInt GetRemainingSize( TInt &aRemainingSize ) = 0;
|
|
134 |
|
|
135 |
// Set data in this data supplier object.
|
|
136 |
// The nature of the source data buffer and the
|
|
137 |
// storage used will be implementation specific to
|
|
138 |
// derived classes.
|
|
139 |
// The return value is one of the standard error codes:
|
|
140 |
// KErrNone
|
|
141 |
// KErrNoMemory
|
|
142 |
// KErrNotFound
|
|
143 |
virtual TInt SetData( const TDesC8 &aSource ) = 0;
|
|
144 |
|
|
145 |
// Retreives data from this data supplier and copies it to
|
|
146 |
// the supplied buffer.
|
|
147 |
// The implementattion will be specific to derived classes
|
|
148 |
// but should ensure that if the user wants all data then it
|
|
149 |
// should be available in one call.
|
|
150 |
// If the length requested was more than the data remaining
|
|
151 |
// the return value will indicate success and the out
|
|
152 |
// parameter aActuallyCopied will hold the number of bytes
|
|
153 |
// copied.
|
|
154 |
// The return value is one of the standard error codes:
|
|
155 |
// KErrNone
|
|
156 |
// KErrNoMemory
|
|
157 |
// KErrNotFound
|
|
158 |
virtual TInt GetData( HBufC8 &aDestination, TInt aLengthToCopy,
|
|
159 |
TInt &aActuallyCopied ) = 0;
|
|
160 |
|
|
161 |
protected:
|
|
162 |
MDataSupplier( void ) {;}
|
|
163 |
virtual ~MDataSupplier( ) {;}
|
|
164 |
};
|
|
165 |
|
|
166 |
/********************************************************************************
|
|
167 |
*
|
|
168 |
* MDataConsumer - interface to contain a data buffer and means for users
|
|
169 |
* to access the data through this object.
|
|
170 |
* Its purpose is to prevent the need for many data buffers
|
|
171 |
* to be created by each object that needs data (instead
|
|
172 |
* one instance of this interface will be passed), and also
|
|
173 |
* it will hide from the user certain implementations such
|
|
174 |
* as reading data from a file when more data is needed
|
|
175 |
* (this prevents the need to read all the data from a
|
|
176 |
* file at one time).
|
|
177 |
* For STAT the purpose of this is to buffer recevied from
|
|
178 |
* the PC to the device. The data is buffered when it is
|
|
179 |
* received on the device.
|
|
180 |
*
|
|
181 |
********************************************************************************/
|
|
182 |
class MDataConsumer
|
|
183 |
{
|
|
184 |
public:
|
|
185 |
// Destroy this object.
|
|
186 |
// After this call the memory is deleted and any pointers to
|
|
187 |
// the object become invalid.
|
|
188 |
virtual void Delete( void ) = 0;
|
|
189 |
|
|
190 |
// Return the total size of the data available through
|
|
191 |
// this data supplier.
|
|
192 |
// The return value is one of the standard error codes:
|
|
193 |
// KErrNone
|
|
194 |
virtual TInt GetTotalSize( TInt &aTotalSize ) = 0;
|
|
195 |
|
|
196 |
// Add data in this data consumer object.
|
|
197 |
// The nature of the source data buffer and the
|
|
198 |
// storage used will be implementation specific to
|
|
199 |
// derived classes.
|
|
200 |
// The return value is one of the standard error codes:
|
|
201 |
// KErrNone
|
|
202 |
// KErrNoMemory
|
|
203 |
// KErrNotFound
|
|
204 |
virtual TInt AddData( const TDesC8 &aSource ) = 0;
|
|
205 |
|
|
206 |
// Retreives data from this data consumer and copies it to
|
|
207 |
// the supplied buffer.
|
|
208 |
// The return value is one of the standard error codes:
|
|
209 |
// KErrNone
|
|
210 |
// KErrNoMemory
|
|
211 |
// KErrNotFound
|
|
212 |
virtual TInt GetData( HBufC8 &aDestination ) = 0;
|
|
213 |
|
|
214 |
// Retreives data from the data consumer as a
|
|
215 |
// descriptor. The data is not copied.
|
|
216 |
virtual operator const TDesC8&( void ) const = 0;
|
|
217 |
|
|
218 |
// Retreives data from this data consumer and copies it to
|
|
219 |
// the supplied buffer.
|
|
220 |
// The return value is one of the standard error codes:
|
|
221 |
// KErrNone
|
|
222 |
// KErrNoMemory
|
|
223 |
// KErrNotFound
|
|
224 |
virtual TInt SaveData( const TDesC &filePath ) = 0;
|
|
225 |
|
|
226 |
protected:
|
|
227 |
MDataConsumer( void ) {;}
|
|
228 |
virtual ~MDataConsumer( ) {;}
|
|
229 |
};
|
|
230 |
|
|
231 |
/********************************************************************************
|
|
232 |
*
|
|
233 |
* MNotifyLogMessage - callback interface to allow callers to log messages
|
|
234 |
*
|
|
235 |
********************************************************************************/
|
|
236 |
class MNotifyLogMessage
|
|
237 |
{
|
|
238 |
public:
|
|
239 |
virtual TInt Init(RFs &fsSession, TPtrC16 filename, CConsoleBase* console) = 0;
|
|
240 |
virtual void Msg(TPtrC16 text, ...) = 0;
|
|
241 |
virtual TBool IsInitialised() const = 0;
|
|
242 |
virtual void CloseFile() = 0;
|
|
243 |
};
|
|
244 |
|
|
245 |
/********************************************************************************
|
|
246 |
*
|
|
247 |
* MNotifyStatEngine - callback interface given to transport on engine
|
|
248 |
*
|
|
249 |
********************************************************************************/
|
|
250 |
class MNotifyStatEngine
|
|
251 |
{
|
|
252 |
public:
|
|
253 |
virtual void HandleInitialise( TInt aResult ) = 0;
|
|
254 |
virtual void HandleConnect( TInt aResult ) = 0;
|
|
255 |
virtual void HandleSend( TInt aResult ) = 0;
|
|
256 |
virtual void HandleReceive( TInt aResult, const TUint aCommand,
|
|
257 |
MDataConsumer *const aDataConsumer ) = 0;
|
|
258 |
virtual void HandleDisconnect( TInt aResult ) = 0;
|
|
259 |
virtual void HandleRelease( TInt aResult ) = 0;
|
|
260 |
virtual void HandleError( TInt aError, void *aErrorData ) = 0;
|
|
261 |
virtual void HandleInfo( const TDesC *aInfo ) = 0;
|
|
262 |
|
|
263 |
};
|
|
264 |
|
|
265 |
/********************************************************************************
|
|
266 |
*
|
|
267 |
* MNotifyStatController - callback interface given to engine on controller
|
|
268 |
*
|
|
269 |
********************************************************************************/
|
|
270 |
class MNotifyStatController
|
|
271 |
{
|
|
272 |
public:
|
|
273 |
virtual void HandleStatusChange( TCommStatus aNewStatus ) = 0;
|
|
274 |
virtual void HandleError( TInt aError, void *aErrorData ) = 0;
|
|
275 |
virtual void HandleInfo( const TDesC *aInfo ) = 0;
|
|
276 |
};
|
|
277 |
|
|
278 |
/********************************************************************************
|
|
279 |
*
|
|
280 |
* MNotifyUI - callback interface given to the controller on the UI
|
|
281 |
*
|
|
282 |
********************************************************************************/
|
|
283 |
class MNotifyUI
|
|
284 |
{
|
|
285 |
public:
|
|
286 |
virtual void HandleStatusChange( TInt aSessionId, TCommStatus aNewStatus ) = 0;
|
|
287 |
virtual void HandleError( TInt aError, void *aErrorData ) = 0;
|
|
288 |
virtual void HandleInfo( const TDesC *aInfo ) = 0;
|
|
289 |
};
|
|
290 |
|
|
291 |
/********************************************************************************
|
|
292 |
*
|
|
293 |
* MStatApiNetwork - network interface called by transport layer
|
|
294 |
*
|
|
295 |
********************************************************************************/
|
|
296 |
class MStatNetwork
|
|
297 |
{
|
|
298 |
public:
|
|
299 |
virtual TInt GetPacketSize() = 0;
|
|
300 |
virtual TInt InitialiseL( MNotifyStatTransport *transport ) = 0;
|
|
301 |
virtual TInt ConnectL( TDesC *aRemoteHost ) = 0;
|
|
302 |
virtual TInt RequestSend( TDesC8 *aData, const TUint aLength ) = 0;
|
|
303 |
virtual TInt RequestReceive( TUint aByteCount ) = 0;
|
|
304 |
virtual TInt Disconnect( void ) = 0;
|
|
305 |
virtual TInt Release( void ) = 0;
|
|
306 |
virtual TText8 *Error( void ) = 0;
|
|
307 |
virtual TUint NtoHl( TUint aValue ) const = 0 ;
|
|
308 |
virtual TUint HtoNl( TUint aValue ) const = 0;
|
|
309 |
};
|
|
310 |
|
|
311 |
/********************************************************************************
|
|
312 |
*
|
|
313 |
* MStatApiTransport - transport interface called by engine
|
|
314 |
*
|
|
315 |
********************************************************************************/
|
|
316 |
class MStatApiTransport
|
|
317 |
{
|
|
318 |
public:
|
|
319 |
virtual TInt InitialiseL() = 0;
|
|
320 |
virtual TInt ConnectL( TDesC *aRemoteHost ) = 0;
|
|
321 |
virtual TInt RequestSend( const TUint aCommand, MDataSupplier *const aDataSupplier) = 0;
|
|
322 |
virtual TInt RequestReceive( void ) = 0;
|
|
323 |
virtual TInt Disconnect( void ) = 0;
|
|
324 |
virtual TInt Release( void ) = 0;
|
|
325 |
virtual TText8 *Error( void ) = 0;
|
|
326 |
};
|
|
327 |
|
|
328 |
/********************************************************************************
|
|
329 |
*
|
|
330 |
* MStatEngine - engine interface called by controller
|
|
331 |
*
|
|
332 |
********************************************************************************/
|
|
333 |
class MStatEngine
|
|
334 |
{
|
|
335 |
public:
|
|
336 |
virtual void StartEngine( MStatApiTransport *aStatTransport, TStatConnectType iConnectType, TDesC *aRemoteHost) = 0;
|
|
337 |
virtual void StopEngine() = 0;
|
|
338 |
};
|
|
339 |
|
|
340 |
/********************************************************************************
|
|
341 |
*
|
|
342 |
* MStatController - controller interface to app ui
|
|
343 |
*
|
|
344 |
********************************************************************************/
|
|
345 |
class MStatController
|
|
346 |
{
|
|
347 |
public:
|
|
348 |
virtual TInt StartSession( TStatConnectType aConnectType, TDesC *aConnectParams, MNotifyUI *aUI, RFs *const aSession, MNotifyLogMessage *const iMsg ) = 0;
|
|
349 |
virtual TInt StopSession( TInt aSessionId ) = 0;
|
|
350 |
virtual TInt SessionStatus( TInt aSessionId ) = 0;
|
|
351 |
};
|
|
352 |
|
|
353 |
#endif //__MSTATAPITRANSPORT_H__
|