williamr@2: // Copyright (c) 2003-2009 Nokia Corporation and/or its subsidiary(-ies). williamr@2: // All rights reserved. williamr@2: // This component and the accompanying materials are made available williamr@2: // 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: // which accompanies this distribution, and is available williamr@2: // at the URL "http://www.symbianfoundation.org/legal/licencesv10.html". williamr@2: // williamr@2: // Initial Contributors: williamr@2: // Nokia Corporation - initial contribution. williamr@2: // williamr@2: // Contributors: williamr@2: // williamr@2: // Description: williamr@2: // williamr@2: williamr@2: williamr@2: williamr@2: /** williamr@2: @file williamr@2: @publishedAll williamr@2: @released williamr@2: */ williamr@2: williamr@2: #ifndef __OBEXBASE_H williamr@2: #define __OBEXBASE_H williamr@2: williamr@2: #include williamr@2: #include williamr@2: williamr@2: class CObexTransportControllerBase; williamr@2: class TObexTransportInfo; williamr@2: class CObexPacket; williamr@2: class CObexNotifyHandlerBase; williamr@2: williamr@2: /** williamr@2: @publishedAll williamr@2: @released williamr@2: williamr@2: This class is the common base class for any object which wishes williamr@2: to use the Obex Server or Client. williamr@2: The class which owns a CObexClient or CObexServer must be provide an object williamr@2: derived from this class to handle the call from the Server/Client for a request williamr@2: for a Password. williamr@2: @see CObex::SetCallBack williamr@2: */ williamr@2: class MObexAuthChallengeHandler williamr@2: { williamr@2: public: williamr@2: /** williamr@2: Indicates that the server/client has received an Authentication challenge. The challenge williamr@2: can only be responded to once a password has been retrieved by some means and passed williamr@2: back to the calling class. The password is passed back via CObex::UserPasswordL williamr@2: @param aRealm This will contain the Realm specified by the unit forcing the williamr@2: Authentication, if no UserID was supplied then this parameter will be of zero length. williamr@2: */ williamr@2: virtual void GetUserPasswordL(const TDesC& aRealm) = 0; williamr@2: williamr@2: /** williamr@2: Returns a null aObject if the extension is not implemented, or a pointer to another interface if it is. williamr@2: @param aInterface UID of the interface to return williamr@2: @param aObject the container for another interface as specified by aInterface williamr@2: */ williamr@2: IMPORT_C virtual void MOACH_ExtensionInterfaceL(TUid aInterface, void*& aObject); williamr@2: }; williamr@2: williamr@2: /** williamr@2: This class is the common base class for CObexClient and CObexServer. It is williamr@2: an abstract class and cannot be instantiated in itself. However, it does williamr@2: contain user functionality common to both client and server connections. williamr@2: williamr@2: Provides the basic OBEX transport functionality (sending and receiving williamr@2: files) williamr@2: Client and server provide the more specialied APIs for williamr@2: - initiation or response to puts & gets williamr@2: - (possible) handling of more generalised 'objects' (prob. with data buffered through a file). williamr@2: williamr@2: This class is not designed for user derivation williamr@2: williamr@2: @publishedAll williamr@2: @released williamr@2: */ williamr@2: NONSHARABLE_CLASS(CObex) : public CBase, protected MObexNotify williamr@2: { williamr@2: public: williamr@2: /** williamr@2: Describes the information set or received in a SETPATH command. williamr@2: williamr@2: 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: 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: The iConstants variable is always set to zero as it is reserved. williamr@2: 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: if the directory to be set is C:\notes then iName is set to "notes"). williamr@2: If a name is not set then set CObex::TSetPathInfo::iNamePresent to false. williamr@2: */ williamr@2: NONSHARABLE_CLASS(TSetPathInfo) williamr@2: { williamr@2: public: williamr@2: IMPORT_C TSetPathInfo(); williamr@2: TSetPathInfo(const TObexSetPathData& aData); williamr@2: IMPORT_C TBool Parent() const; williamr@2: TUint8 iFlags; williamr@2: TUint8 iConstants; williamr@2: TBuf iName; williamr@2: /** Whether iName is present in this SETPATH info */ williamr@2: TBool iNamePresent; williamr@2: private: williamr@2: // This data padding has been added to help prevent future binary compatibility breaks williamr@2: // Neither iPadding1 nor iPadding2 have been zero'd because they are currently not used williamr@2: TUint32 iPadding1; williamr@2: TUint32 iPadding2; williamr@2: }; williamr@2: williamr@2: /** williamr@2: Current obex connection state williamr@2: In general, the further through the enum the values are, williamr@2: the further through the connection process the state machine williamr@2: will be. williamr@2: */ williamr@2: enum TConnectState williamr@2: { williamr@2: EConnIdle, /** Nothing is happening */ williamr@2: EConnTransport, /** Transport Link connected not yet established true Link */ williamr@2: EConnObex, /** full connection established */ williamr@2: ESimpleConnRequest, /** Connect without Auth has been sent by ClientReceived by Server */ williamr@2: EConnChallRxed, /** Server has issued a challenge, to a Client cionnect */ williamr@2: ESimpleConnChallIssued, /** Server, received Simple Connect but Server Challenge issued */ williamr@2: EChallConnRequested, /** Connect with Auth has been sent by Client/Received by Server */ williamr@2: EChallConnChallIssued, /** Server has sent a Challenge & Resp to a Client EChallConnRequest */ williamr@2: EWaitForFinalResponse, /** Client, waiting for final success/fail not chall-response expected williamr@2: Server, Waiting for final Resp fromm Client to Challenge */ williamr@2: EFinalResponseReceived, /** Server, the final response has been received */ williamr@2: EFinalChallRxed, /** Server, Client connect with challenge, Server responds with challenge, Client re-issued original/new challenge */ williamr@2: EWaitForUserInput, /** waiting for the user */ williamr@2: EDropLink /** drop the link */ williamr@2: }; williamr@2: williamr@2: /** williamr@2: The Obex operation currently being performed. williamr@2: */ williamr@2: enum TOperation williamr@2: { williamr@2: EOpConnect = 0x00, /** Connect */ williamr@2: EOpDisconnect = 0x01, /** Disconnect */ williamr@2: EOpPut = 0x02, /** Put */ williamr@2: EOpGet = 0x03, /** Get */ williamr@2: EOpSetPath = 0x05, /** SetPath */ williamr@2: EOpAbort = 0xFF, /** Abort - must fit in one pkt so final bit is always set */ williamr@2: EOpAbortNoFBit = 0x7F, /** Abort (internal, never transmitted) */ williamr@2: EOpGetResponse = 0xFD, /** Internal - not actually an obex operation. */ williamr@2: EOpIdle = 0xFE, /** Internal - not actually an obex operation. */ williamr@2: }; williamr@2: williamr@2: /** williamr@2: Flags to suppress the authentication elements of the authentication challenge header. williamr@2: */ williamr@2: enum TObexSuppressedAuthElements williamr@2: { williamr@2: EObexNoSuppressedAuthElements = 0x00, williamr@2: EObexSuppressChallengeOptionsAuthElement = 0x01, williamr@2: EObexSuppressRealmAuthElement = 0x02, williamr@2: EObexSuppressAllAuthElements = EObexSuppressChallengeOptionsAuthElement | EObexSuppressRealmAuthElement // Must be last williamr@2: }; williamr@2: williamr@2: virtual ~CObex(); williamr@2: IMPORT_C void SetCallBack(MObexAuthChallengeHandler& aCallBack); williamr@2: IMPORT_C TBool IsConnected() const; williamr@2: IMPORT_C TBool IsStrictPeer() const; williamr@2: IMPORT_C const TObexConnectInfo& LocalInfo() const; williamr@2: IMPORT_C TInt SetLocalWho(const TDesC8& aInfo); williamr@2: IMPORT_C const TObexConnectInfo& RemoteInfo() const; williamr@2: IMPORT_C void SuppressAuthenticationHeaderElements(TObexSuppressedAuthElements aSuppressedObexAuthElements); williamr@2: williamr@2: // Implementation of MObexNotify Interface williamr@2: /** williamr@2: @internalTechnology williamr@2: */ williamr@2: virtual void Process(CObexPacket& aPacket); williamr@2: /** williamr@2: @internalTechnology williamr@2: */ williamr@2: virtual void Error(TInt aError) ; williamr@2: /** Call back to start the obex session williamr@2: @internalTechnology williamr@2: */ williamr@2: virtual void TransportUp(); williamr@2: /** williamr@2: @internalTechnology williamr@2: */ williamr@2: virtual void TransportDown(TBool aForceTransportDeletion); williamr@2: williamr@2: virtual void UserPasswordL( const TDesC& aPassword) = 0; williamr@2: IMPORT_C void RemoteAddr(TSockAddr& anAddr); williamr@2: williamr@2: TConnectState GetConnectState() const; williamr@2: williamr@2: IMPORT_C TBool IsAuthenticating() const; williamr@2: williamr@2: protected: williamr@2: CObex(); williamr@2: virtual void ConstructL(TObexTransportInfo& aObexTransportInfo); williamr@2: virtual TInt ParseConnectPacket(CObexPacket& aPacket) = 0; williamr@2: void SetConnectState(TConnectState aNewState); williamr@2: IMPORT_C TConnectState ConnectState() const; // same as GetConnectState - has to be maintained here for BC williamr@2: virtual void OnPacketReceive(CObexPacket& aPacket) =0; williamr@2: virtual void OnError(TInt aError) =0; williamr@2: virtual void OnTransportUp() =0; williamr@2: virtual void OnTransportDown() =0; williamr@2: void ProcessChallengeL(const TObexInternalHeader& hdr); //process the received challenge williamr@2: void ProcessChallResponseL(const TObexInternalHeader& hdr); //process the response to challenge williamr@2: TInt GenerateChallenge(CObexPacket& aPacket); //generate a challenge williamr@2: void PrepareChallResponseL(const TDesC& aPassword); //generate a response a respose to challenge williamr@2: //after user Password input williamr@2: void ForcedTransportDown(); williamr@2: void ControlledTransportDown(); williamr@2: void RemoteInfoCleanup(); williamr@2: void CObex::CancelObexConnection(); williamr@2: protected: williamr@2: TConnectState iConnectState; williamr@2: CObexTransportControllerBase* iTransportController; williamr@2: TObexConnectInfo iLocalInfo; williamr@2: TObexConnectInfo iRemoteInfo; williamr@2: MObexAuthChallengeHandler* iCallBack; williamr@2: TNonce iOutgoingNonce; //nonce used when challenging williamr@2: TNonce iIncomingNonce; //nonce used when receiving a challenge williamr@2: HBufC8* iChallPassword; //password used when challenging williamr@2: HBufC8* iRespPassword; //password used when responding to a challenge williamr@2: HBufC8* iRxChallenge; williamr@2: TBuf8 iOutgoingChallResp;//response to the previously issued challenge williamr@2: //16 nonce, 16 digest resp, 20 UserID, 3*(tag+size) williamr@2: TBuf8 iIncomingChallResp;//response received from previous challenge williamr@2: TBuf8 iIncomingRequestDigest; williamr@2: HBufC* iRemoteUID; //UID of remote device williamr@2: HBufC* iRemoteRealm;//Realm of remote device williamr@2: CObexAuthenticator* iAuthEngine; williamr@2: TBool iChallenge; //to challenge or not to challenge? williamr@2: TBool iUserIDRequested; //does the challenge insist that a UserID is returned williamr@2: TBool iReserved; //released boolean now available for future use williamr@2: TOperation iCurrentOperation; williamr@2: CObexNotifyHandlerBase* iNotifyHandler; williamr@2: TUint iSuppressedObexAuthElements; williamr@2: }; williamr@2: williamr@2: #endif // __OBEXBASE_H