32
|
1 |
/*
|
|
2 |
* Copyright (c) 2002 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: Obex client
|
|
15 |
*
|
|
16 |
*/
|
|
17 |
|
|
18 |
|
|
19 |
|
|
20 |
#ifndef BT_SERVICE_CLIENT_H
|
|
21 |
#define BT_SERVICE_CLIENT_H
|
|
22 |
|
|
23 |
// INCLUDES
|
|
24 |
#include "BTSUPassKeyRequest.h"
|
|
25 |
|
|
26 |
#include <obex.h>
|
|
27 |
#include <obexheaders.h>
|
|
28 |
|
|
29 |
|
|
30 |
// FORWARD DECLARATION
|
|
31 |
class CBTSUPasskeyRequest;
|
|
32 |
class CBTConnectionTimer;
|
|
33 |
|
|
34 |
// CLASS DECLARATION
|
|
35 |
|
|
36 |
/**
|
|
37 |
* An interface used to inform about BT service client events.
|
|
38 |
*/
|
|
39 |
class MBTServiceClientObserver
|
|
40 |
{
|
|
41 |
public:
|
|
42 |
|
|
43 |
/**
|
|
44 |
* Informs the observer that a Connect operation has been completed.
|
|
45 |
* @param aStatus The status of the operation.
|
|
46 |
* @return None.
|
|
47 |
*/
|
|
48 |
virtual void ConnectCompleted( TInt aStatus ) = 0;
|
|
49 |
|
|
50 |
/**
|
|
51 |
* Informs the observer that a Put operation has been completed.
|
|
52 |
* @param aStatus The status of the operation.
|
|
53 |
* @param aPutResponse The response object.
|
|
54 |
* @return None.
|
|
55 |
*/
|
|
56 |
virtual void PutCompleted( TInt aStatus,const CObexHeaderSet* aPutResponse ) = 0;
|
|
57 |
|
|
58 |
/**
|
|
59 |
* Informs the observer that a Get operation has been completed.
|
|
60 |
* @param aStatus The status of the operation.
|
|
61 |
* @param aGetResponse The response object.
|
|
62 |
* @return None.
|
|
63 |
*/
|
|
64 |
virtual void GetCompleted( TInt aStatus, CObexBufObject* aGetResponse ) = 0;
|
|
65 |
|
|
66 |
/**
|
|
67 |
* Informs the observer that the client connection has been closed.
|
|
68 |
* @return None.
|
|
69 |
*/
|
|
70 |
virtual void ClientConnectionClosed() = 0;
|
|
71 |
|
|
72 |
/**
|
|
73 |
* Informs the observer that the client connect is timed out.
|
|
74 |
* @return None.
|
|
75 |
*/
|
|
76 |
virtual void ConnectTimedOut() = 0;
|
|
77 |
|
|
78 |
|
|
79 |
};
|
|
80 |
|
|
81 |
/**
|
|
82 |
* An interface used to inform about BT Connection timeout
|
|
83 |
*/
|
|
84 |
class MBTConTimeObserver
|
|
85 |
{
|
|
86 |
public:
|
|
87 |
/**
|
|
88 |
* Informs the observer that the client connec is timeouted
|
|
89 |
* @return None.
|
|
90 |
*/
|
|
91 |
virtual void ConnectionTimedOut()=0;
|
|
92 |
};
|
|
93 |
|
|
94 |
|
|
95 |
// CLASS DECLARATION
|
|
96 |
|
|
97 |
/**
|
|
98 |
* An interface used to ask client's progress status.
|
|
99 |
*/
|
|
100 |
class MBTServiceProgressGetter
|
|
101 |
{
|
|
102 |
public:
|
|
103 |
|
|
104 |
/**
|
|
105 |
* Returns the progess status of the service client.
|
|
106 |
* @return The number of bytes sent.
|
|
107 |
*/
|
|
108 |
virtual TInt GetProgressStatus() = 0;
|
|
109 |
};
|
|
110 |
|
|
111 |
// CLASS DECLARATION
|
|
112 |
|
|
113 |
/**
|
|
114 |
* An active object managing the Obex client.
|
|
115 |
*/
|
|
116 |
NONSHARABLE_CLASS (CBTServiceClient) : public CActive,
|
|
117 |
public MBTServiceProgressGetter,
|
|
118 |
public MObexAuthChallengeHandler,
|
|
119 |
public MBTConTimeObserver
|
|
120 |
|
|
121 |
{
|
|
122 |
public: // Constructors and destructor
|
|
123 |
|
|
124 |
/**
|
|
125 |
* Two-phased constructor.
|
|
126 |
* @param aObserver A pointer to the client observer.
|
|
127 |
* @param aRemoteDevice The address of the remote device.
|
|
128 |
* @param aRemotePort The port of the remote device.
|
|
129 |
* @param aHeaderList The headers to be associated with connect object.
|
|
130 |
* @return None.
|
|
131 |
*/
|
|
132 |
static CBTServiceClient* NewL( MBTServiceClientObserver* aObserver,
|
|
133 |
const TBTDevAddr& aRemoteDevice,
|
|
134 |
const TUint aRemotePort,
|
|
135 |
RArray<CObexHeader*> aHeaderList );
|
|
136 |
|
|
137 |
/**
|
|
138 |
* Destructor.
|
|
139 |
*/
|
|
140 |
virtual ~CBTServiceClient();
|
|
141 |
|
|
142 |
public: // New functions
|
|
143 |
|
|
144 |
/**
|
|
145 |
* Issues an Obex Get-request.
|
|
146 |
* @param aHeaderList The headers to be associated with the object.
|
|
147 |
* @param aFileName A filename of the Get Object.
|
|
148 |
* @return None.
|
|
149 |
*/
|
|
150 |
void GetObjectL( RArray<CObexHeader*>& aHeaderList,
|
|
151 |
const TDesC& aFileName = KNullDesC );
|
|
152 |
|
|
153 |
/**
|
|
154 |
* Issues an Obex Put-request.
|
|
155 |
* @param aHeaderList The headers to be associated with the object.
|
|
156 |
* @param aFileName A filename of the Put Object.
|
|
157 |
* @return None.
|
|
158 |
*/
|
|
159 |
void PutObjectL( RArray<CObexHeader*>& aHeaderList,
|
|
160 |
const TDesC& aFileName );
|
|
161 |
|
|
162 |
/**
|
|
163 |
* Issues an Obex Put-request.
|
|
164 |
* @param aHeaderList The headers to be associated with the object.
|
|
165 |
* @param aFile A filehandle of the Put Object.
|
|
166 |
* @return None.
|
|
167 |
*/
|
|
168 |
void PutObjectL( RArray<CObexHeader*>& aHeaderList,
|
|
169 |
RFile& );
|
|
170 |
|
|
171 |
/**
|
|
172 |
* Closes Obex Client connection.
|
|
173 |
* @param None.
|
|
174 |
* @return None.
|
|
175 |
*/
|
|
176 |
void CloseClientConnection();
|
|
177 |
|
|
178 |
/**
|
|
179 |
* Send abort command to remote device
|
|
180 |
* @param None.
|
|
181 |
* @return None.
|
|
182 |
*/
|
|
183 |
void Abort();
|
|
184 |
|
|
185 |
private: // Functions from base classes
|
|
186 |
|
|
187 |
/**
|
|
188 |
* From MBTServiceProgressGetter Returns the progess status.
|
|
189 |
* @return The number of bytes sent.
|
|
190 |
*/
|
|
191 |
TInt GetProgressStatus();
|
|
192 |
|
|
193 |
|
|
194 |
private: // Functions from base classes
|
|
195 |
|
|
196 |
/**
|
|
197 |
* From MObexAuthChallengeHandler The Obex Passkey is requested.
|
|
198 |
* @param aRealm The realm/challenge specified by the unit forcing
|
|
199 |
* the authentication.
|
|
200 |
* @return None.
|
|
201 |
*/
|
|
202 |
void GetUserPasswordL( const TDesC& aRealm );
|
|
203 |
|
|
204 |
/**
|
|
205 |
* From CActive Get's called when a request is cancelled.
|
|
206 |
* @param None.
|
|
207 |
* @return None.
|
|
208 |
*/
|
|
209 |
void DoCancel();
|
|
210 |
|
|
211 |
/**
|
|
212 |
* From CActive Get's called when a request is completed.
|
|
213 |
* @param None.
|
|
214 |
* @return None.
|
|
215 |
*/
|
|
216 |
void RunL();
|
|
217 |
|
|
218 |
/**
|
|
219 |
* From MBTConTimeObserver Get's called if bt connection is timed out.
|
|
220 |
* @param None.
|
|
221 |
* @return None.
|
|
222 |
*/
|
|
223 |
void ConnectionTimedOut();
|
|
224 |
|
|
225 |
private: // Data definitions
|
|
226 |
|
|
227 |
enum TBTServiceClientState
|
|
228 |
{
|
|
229 |
EBTSCliIdle,
|
|
230 |
EBTSCliConnecting,
|
|
231 |
EBTSCliPutting,
|
|
232 |
EBTSCliGetting,
|
|
233 |
EBTSCliDisconnecting
|
|
234 |
};
|
|
235 |
|
|
236 |
private:
|
|
237 |
|
|
238 |
/**
|
|
239 |
* C++ default constructor.
|
|
240 |
*/
|
|
241 |
CBTServiceClient( MBTServiceClientObserver* aObserver );
|
|
242 |
|
|
243 |
/**
|
|
244 |
* By default Symbian 2nd phase constructor is private.
|
|
245 |
*/
|
|
246 |
void ConstructL( const TBTDevAddr& aRemoteDevice,
|
|
247 |
const TUint aRemotePort,
|
|
248 |
RArray<CObexHeader*> aHeaderList );
|
|
249 |
|
|
250 |
private: // Data
|
|
251 |
|
|
252 |
TBTServiceClientState iClientState;
|
|
253 |
|
|
254 |
CObexClient* iClient;
|
|
255 |
CBufFlat* iObjectBuffer;
|
|
256 |
CObexBufObject* iGetObject;
|
|
257 |
CObexFileObject* iPutObject;
|
|
258 |
CObexNullObject* iConnectObject;
|
|
259 |
TInt iTotalBytesSent;
|
|
260 |
CBTSUPasskeyRequest* iPasskeyRequest;
|
|
261 |
CBufFlat *iBuffer;
|
|
262 |
CObexBufObject* iPutBufObject;
|
|
263 |
CBTConnectionTimer* iConnectionTimer;
|
|
264 |
// Not owned
|
|
265 |
//
|
|
266 |
MBTServiceClientObserver* iObserver;
|
|
267 |
};
|
|
268 |
|
|
269 |
#endif // BT_SERVICE_CLIENT_H
|
|
270 |
|
|
271 |
// End of File
|