williamr@2
|
1 |
// Copyright (c) 2003-2009 Nokia Corporation and/or its subsidiary(-ies).
|
williamr@2
|
2 |
// All rights reserved.
|
williamr@2
|
3 |
// This component and the accompanying materials are made available
|
williamr@2
|
4 |
// under the terms of the License "Symbian Foundation License v1.0" to Symbian Foundation members and "Symbian Foundation End User License Agreement v1.0" to non-members
|
williamr@2
|
5 |
// which accompanies this distribution, and is available
|
williamr@2
|
6 |
// at the URL "http://www.symbianfoundation.org/legal/licencesv10.html".
|
williamr@2
|
7 |
//
|
williamr@2
|
8 |
// Initial Contributors:
|
williamr@2
|
9 |
// Nokia Corporation - initial contribution.
|
williamr@2
|
10 |
//
|
williamr@2
|
11 |
// Contributors:
|
williamr@2
|
12 |
//
|
williamr@2
|
13 |
// Description:
|
williamr@2
|
14 |
//
|
williamr@2
|
15 |
|
williamr@2
|
16 |
|
williamr@2
|
17 |
|
williamr@2
|
18 |
/**
|
williamr@2
|
19 |
@file
|
williamr@2
|
20 |
@publishedAll
|
williamr@2
|
21 |
@released
|
williamr@2
|
22 |
*/
|
williamr@2
|
23 |
|
williamr@2
|
24 |
#ifndef __OBEXBASE_H
|
williamr@2
|
25 |
#define __OBEXBASE_H
|
williamr@2
|
26 |
|
williamr@2
|
27 |
#include <obextypes.h>
|
williamr@2
|
28 |
#include <mobexnotify.h>
|
williamr@2
|
29 |
|
williamr@2
|
30 |
class CObexTransportControllerBase;
|
williamr@2
|
31 |
class TObexTransportInfo;
|
williamr@2
|
32 |
class CObexPacket;
|
williamr@2
|
33 |
class CObexNotifyHandlerBase;
|
williamr@2
|
34 |
|
williamr@2
|
35 |
/**
|
williamr@2
|
36 |
@publishedAll
|
williamr@2
|
37 |
@released
|
williamr@2
|
38 |
|
williamr@2
|
39 |
This class is the common base class for any object which wishes
|
williamr@2
|
40 |
to use the Obex Server or Client.
|
williamr@2
|
41 |
The class which owns a CObexClient or CObexServer must be provide an object
|
williamr@2
|
42 |
derived from this class to handle the call from the Server/Client for a request
|
williamr@2
|
43 |
for a Password.
|
williamr@2
|
44 |
@see CObex::SetCallBack
|
williamr@2
|
45 |
*/
|
williamr@2
|
46 |
class MObexAuthChallengeHandler
|
williamr@2
|
47 |
{
|
williamr@2
|
48 |
public:
|
williamr@2
|
49 |
/**
|
williamr@2
|
50 |
Indicates that the server/client has received an Authentication challenge. The challenge
|
williamr@2
|
51 |
can only be responded to once a password has been retrieved by some means and passed
|
williamr@2
|
52 |
back to the calling class. The password is passed back via CObex::UserPasswordL
|
williamr@2
|
53 |
@param aRealm This will contain the Realm specified by the unit forcing the
|
williamr@2
|
54 |
Authentication, if no UserID was supplied then this parameter will be of zero length.
|
williamr@2
|
55 |
*/
|
williamr@2
|
56 |
virtual void GetUserPasswordL(const TDesC& aRealm) = 0;
|
williamr@2
|
57 |
|
williamr@2
|
58 |
/**
|
williamr@2
|
59 |
Returns a null aObject if the extension is not implemented, or a pointer to another interface if it is.
|
williamr@2
|
60 |
@param aInterface UID of the interface to return
|
williamr@2
|
61 |
@param aObject the container for another interface as specified by aInterface
|
williamr@2
|
62 |
*/
|
williamr@2
|
63 |
IMPORT_C virtual void MOACH_ExtensionInterfaceL(TUid aInterface, void*& aObject);
|
williamr@2
|
64 |
};
|
williamr@2
|
65 |
|
williamr@2
|
66 |
/**
|
williamr@2
|
67 |
This class is the common base class for CObexClient and CObexServer. It is
|
williamr@2
|
68 |
an abstract class and cannot be instantiated in itself. However, it does
|
williamr@2
|
69 |
contain user functionality common to both client and server connections.
|
williamr@2
|
70 |
|
williamr@2
|
71 |
Provides the basic OBEX transport functionality (sending and receiving
|
williamr@2
|
72 |
files)
|
williamr@2
|
73 |
Client and server provide the more specialied APIs for
|
williamr@2
|
74 |
- initiation or response to puts & gets
|
williamr@2
|
75 |
- (possible) handling of more generalised 'objects' (prob. with data buffered through a file).
|
williamr@2
|
76 |
|
williamr@2
|
77 |
This class is not designed for user derivation
|
williamr@2
|
78 |
|
williamr@2
|
79 |
@publishedAll
|
williamr@2
|
80 |
@released
|
williamr@2
|
81 |
*/
|
williamr@2
|
82 |
NONSHARABLE_CLASS(CObex) : public CBase, protected MObexNotify
|
williamr@2
|
83 |
{
|
williamr@2
|
84 |
public:
|
williamr@2
|
85 |
/**
|
williamr@2
|
86 |
Describes the information set or received in a SETPATH command.
|
williamr@2
|
87 |
|
williamr@2
|
88 |
The first bit of iFlags, 0, can be set to indicate to the receiver of SETPATH to backup a level before applying the path name.
|
williamr@2
|
89 |
The second bit of iFlags, 1, can be set to indicate to the receiver of SETPATH to NOT create the directory if it doesn't exist.
|
williamr@2
|
90 |
The iConstants variable is always set to zero as it is reserved.
|
williamr@2
|
91 |
The iName variable indicates the directory to create or go to, and does not include the root directory of the receiver (i.e.
|
williamr@2
|
92 |
if the directory to be set is C:\notes then iName is set to "notes").
|
williamr@2
|
93 |
If a name is not set then set CObex::TSetPathInfo::iNamePresent to false.
|
williamr@2
|
94 |
*/
|
williamr@2
|
95 |
NONSHARABLE_CLASS(TSetPathInfo)
|
williamr@2
|
96 |
{
|
williamr@2
|
97 |
public:
|
williamr@2
|
98 |
IMPORT_C TSetPathInfo();
|
williamr@2
|
99 |
TSetPathInfo(const TObexSetPathData& aData);
|
williamr@2
|
100 |
IMPORT_C TBool Parent() const;
|
williamr@2
|
101 |
TUint8 iFlags;
|
williamr@2
|
102 |
TUint8 iConstants;
|
williamr@2
|
103 |
TBuf<KObexObjectDescriptionSize> iName;
|
williamr@2
|
104 |
/** Whether iName is present in this SETPATH info */
|
williamr@2
|
105 |
TBool iNamePresent;
|
williamr@2
|
106 |
private:
|
williamr@2
|
107 |
// This data padding has been added to help prevent future binary compatibility breaks
|
williamr@2
|
108 |
// Neither iPadding1 nor iPadding2 have been zero'd because they are currently not used
|
williamr@2
|
109 |
TUint32 iPadding1;
|
williamr@2
|
110 |
TUint32 iPadding2;
|
williamr@2
|
111 |
};
|
williamr@2
|
112 |
|
williamr@2
|
113 |
/**
|
williamr@2
|
114 |
Current obex connection state
|
williamr@2
|
115 |
In general, the further through the enum the values are,
|
williamr@2
|
116 |
the further through the connection process the state machine
|
williamr@2
|
117 |
will be.
|
williamr@2
|
118 |
*/
|
williamr@2
|
119 |
enum TConnectState
|
williamr@2
|
120 |
{
|
williamr@2
|
121 |
EConnIdle, /** Nothing is happening */
|
williamr@2
|
122 |
EConnTransport, /** Transport Link connected not yet established true Link */
|
williamr@2
|
123 |
EConnObex, /** full connection established */
|
williamr@2
|
124 |
ESimpleConnRequest, /** Connect without Auth has been sent by ClientReceived by Server */
|
williamr@2
|
125 |
EConnChallRxed, /** Server has issued a challenge, to a Client cionnect */
|
williamr@2
|
126 |
ESimpleConnChallIssued, /** Server, received Simple Connect but Server Challenge issued */
|
williamr@2
|
127 |
EChallConnRequested, /** Connect with Auth has been sent by Client/Received by Server */
|
williamr@2
|
128 |
EChallConnChallIssued, /** Server has sent a Challenge & Resp to a Client EChallConnRequest */
|
williamr@2
|
129 |
EWaitForFinalResponse, /** Client, waiting for final success/fail not chall-response expected
|
williamr@2
|
130 |
Server, Waiting for final Resp fromm Client to Challenge */
|
williamr@2
|
131 |
EFinalResponseReceived, /** Server, the final response has been received */
|
williamr@2
|
132 |
EFinalChallRxed, /** Server, Client connect with challenge, Server responds with challenge, Client re-issued original/new challenge */
|
williamr@2
|
133 |
EWaitForUserInput, /** waiting for the user */
|
williamr@2
|
134 |
EDropLink /** drop the link */
|
williamr@2
|
135 |
};
|
williamr@2
|
136 |
|
williamr@2
|
137 |
/**
|
williamr@2
|
138 |
The Obex operation currently being performed.
|
williamr@2
|
139 |
*/
|
williamr@2
|
140 |
enum TOperation
|
williamr@2
|
141 |
{
|
williamr@2
|
142 |
EOpConnect = 0x00, /** Connect */
|
williamr@2
|
143 |
EOpDisconnect = 0x01, /** Disconnect */
|
williamr@2
|
144 |
EOpPut = 0x02, /** Put */
|
williamr@2
|
145 |
EOpGet = 0x03, /** Get */
|
williamr@2
|
146 |
EOpSetPath = 0x05, /** SetPath */
|
williamr@2
|
147 |
EOpAbort = 0xFF, /** Abort - must fit in one pkt so final bit is always set */
|
williamr@2
|
148 |
EOpAbortNoFBit = 0x7F, /** Abort (internal, never transmitted) */
|
williamr@2
|
149 |
EOpGetResponse = 0xFD, /** Internal - not actually an obex operation. */
|
williamr@2
|
150 |
EOpIdle = 0xFE, /** Internal - not actually an obex operation. */
|
williamr@2
|
151 |
};
|
williamr@2
|
152 |
|
williamr@2
|
153 |
/**
|
williamr@2
|
154 |
Flags to suppress the authentication elements of the authentication challenge header.
|
williamr@2
|
155 |
*/
|
williamr@2
|
156 |
enum TObexSuppressedAuthElements
|
williamr@2
|
157 |
{
|
williamr@2
|
158 |
EObexNoSuppressedAuthElements = 0x00,
|
williamr@2
|
159 |
EObexSuppressChallengeOptionsAuthElement = 0x01,
|
williamr@2
|
160 |
EObexSuppressRealmAuthElement = 0x02,
|
williamr@2
|
161 |
EObexSuppressAllAuthElements = EObexSuppressChallengeOptionsAuthElement | EObexSuppressRealmAuthElement // Must be last
|
williamr@2
|
162 |
};
|
williamr@2
|
163 |
|
williamr@2
|
164 |
virtual ~CObex();
|
williamr@2
|
165 |
IMPORT_C void SetCallBack(MObexAuthChallengeHandler& aCallBack);
|
williamr@2
|
166 |
IMPORT_C TBool IsConnected() const;
|
williamr@2
|
167 |
IMPORT_C TBool IsStrictPeer() const;
|
williamr@2
|
168 |
IMPORT_C const TObexConnectInfo& LocalInfo() const;
|
williamr@2
|
169 |
IMPORT_C TInt SetLocalWho(const TDesC8& aInfo);
|
williamr@2
|
170 |
IMPORT_C const TObexConnectInfo& RemoteInfo() const;
|
williamr@2
|
171 |
IMPORT_C void SuppressAuthenticationHeaderElements(TObexSuppressedAuthElements aSuppressedObexAuthElements);
|
williamr@2
|
172 |
|
williamr@2
|
173 |
// Implementation of MObexNotify Interface
|
williamr@2
|
174 |
/**
|
williamr@2
|
175 |
@internalTechnology
|
williamr@2
|
176 |
*/
|
williamr@2
|
177 |
virtual void Process(CObexPacket& aPacket);
|
williamr@2
|
178 |
/**
|
williamr@2
|
179 |
@internalTechnology
|
williamr@2
|
180 |
*/
|
williamr@2
|
181 |
virtual void Error(TInt aError) ;
|
williamr@2
|
182 |
/** Call back to start the obex session
|
williamr@2
|
183 |
@internalTechnology
|
williamr@2
|
184 |
*/
|
williamr@2
|
185 |
virtual void TransportUp();
|
williamr@2
|
186 |
/**
|
williamr@2
|
187 |
@internalTechnology
|
williamr@2
|
188 |
*/
|
williamr@2
|
189 |
virtual void TransportDown(TBool aForceTransportDeletion);
|
williamr@2
|
190 |
|
williamr@2
|
191 |
virtual void UserPasswordL( const TDesC& aPassword) = 0;
|
williamr@2
|
192 |
IMPORT_C void RemoteAddr(TSockAddr& anAddr);
|
williamr@2
|
193 |
|
williamr@2
|
194 |
TConnectState GetConnectState() const;
|
williamr@2
|
195 |
|
williamr@2
|
196 |
IMPORT_C TBool IsAuthenticating() const;
|
williamr@2
|
197 |
|
williamr@2
|
198 |
protected:
|
williamr@2
|
199 |
CObex();
|
williamr@2
|
200 |
virtual void ConstructL(TObexTransportInfo& aObexTransportInfo);
|
williamr@2
|
201 |
virtual TInt ParseConnectPacket(CObexPacket& aPacket) = 0;
|
williamr@2
|
202 |
void SetConnectState(TConnectState aNewState);
|
williamr@2
|
203 |
IMPORT_C TConnectState ConnectState() const; // same as GetConnectState - has to be maintained here for BC
|
williamr@2
|
204 |
virtual void OnPacketReceive(CObexPacket& aPacket) =0;
|
williamr@2
|
205 |
virtual void OnError(TInt aError) =0;
|
williamr@2
|
206 |
virtual void OnTransportUp() =0;
|
williamr@2
|
207 |
virtual void OnTransportDown() =0;
|
williamr@2
|
208 |
void ProcessChallengeL(const TObexInternalHeader& hdr); //process the received challenge
|
williamr@2
|
209 |
void ProcessChallResponseL(const TObexInternalHeader& hdr); //process the response to challenge
|
williamr@2
|
210 |
TInt GenerateChallenge(CObexPacket& aPacket); //generate a challenge
|
williamr@2
|
211 |
void PrepareChallResponseL(const TDesC& aPassword); //generate a response a respose to challenge
|
williamr@2
|
212 |
//after user Password input
|
williamr@2
|
213 |
void ForcedTransportDown();
|
williamr@2
|
214 |
void ControlledTransportDown();
|
williamr@2
|
215 |
void RemoteInfoCleanup();
|
williamr@2
|
216 |
void CObex::CancelObexConnection();
|
williamr@2
|
217 |
protected:
|
williamr@2
|
218 |
TConnectState iConnectState;
|
williamr@2
|
219 |
CObexTransportControllerBase* iTransportController;
|
williamr@2
|
220 |
TObexConnectInfo iLocalInfo;
|
williamr@2
|
221 |
TObexConnectInfo iRemoteInfo;
|
williamr@2
|
222 |
MObexAuthChallengeHandler* iCallBack;
|
williamr@2
|
223 |
TNonce iOutgoingNonce; //nonce used when challenging
|
williamr@2
|
224 |
TNonce iIncomingNonce; //nonce used when receiving a challenge
|
williamr@2
|
225 |
HBufC8* iChallPassword; //password used when challenging
|
williamr@2
|
226 |
HBufC8* iRespPassword; //password used when responding to a challenge
|
williamr@2
|
227 |
HBufC8* iRxChallenge;
|
williamr@2
|
228 |
TBuf8<KChallResponseSize> iOutgoingChallResp;//response to the previously issued challenge
|
williamr@2
|
229 |
//16 nonce, 16 digest resp, 20 UserID, 3*(tag+size)
|
williamr@2
|
230 |
TBuf8<KChallResponseSize> iIncomingChallResp;//response received from previous challenge
|
williamr@2
|
231 |
TBuf8<KObexRespSize> iIncomingRequestDigest;
|
williamr@2
|
232 |
HBufC* iRemoteUID; //UID of remote device
|
williamr@2
|
233 |
HBufC* iRemoteRealm;//Realm of remote device
|
williamr@2
|
234 |
CObexAuthenticator* iAuthEngine;
|
williamr@2
|
235 |
TBool iChallenge; //to challenge or not to challenge?
|
williamr@2
|
236 |
TBool iUserIDRequested; //does the challenge insist that a UserID is returned
|
williamr@2
|
237 |
TBool iReserved; //released boolean now available for future use
|
williamr@2
|
238 |
TOperation iCurrentOperation;
|
williamr@2
|
239 |
CObexNotifyHandlerBase* iNotifyHandler;
|
williamr@2
|
240 |
TUint iSuppressedObexAuthElements;
|
williamr@2
|
241 |
};
|
williamr@2
|
242 |
|
williamr@2
|
243 |
#endif // __OBEXBASE_H
|