obex/obexprotocol/obextransport/public/obextransportcontrollerbase.h
changeset 57 f6055a57ae18
parent 0 d0791faffa3f
equal deleted inserted replaced
54:4dc88a4ac6f4 57:f6055a57ae18
       
     1 // Copyright (c) 2005-2009 Nokia Corporation and/or its subsidiary(-ies).
       
     2 // All rights reserved.
       
     3 // This component and the accompanying materials are made available
       
     4 // under the terms of "Eclipse Public License v1.0"
       
     5 // which accompanies this distribution, and is available
       
     6 // at the URL "http://www.eclipse.org/legal/epl-v10.html".
       
     7 //
       
     8 // Initial Contributors:
       
     9 // Nokia Corporation - initial contribution.
       
    10 //
       
    11 // Contributors:
       
    12 //
       
    13 // Description:
       
    14 //
       
    15 
       
    16 #ifndef __OBEXTRANSPORTCONTROLLERBASE_H__
       
    17 #define __OBEXTRANSPORTCONTROLLERBASE_H__
       
    18 
       
    19 #include <e32base.h>
       
    20 #include <obex/transport/mobextransportnotify.h>
       
    21 #include <obex/transport/obexconnector.h>
       
    22 #include <obex/internal/obextransportconstants.h>
       
    23 #include <obex/transport/obextransport.hrh>
       
    24 #include <obextypes.h>
       
    25 
       
    26 class CObexPacket;
       
    27 class MObexNotifyExtend;
       
    28 class TSockAddr;
       
    29 class CObexActiveRW;
       
    30 class TObexTransportInfo;
       
    31 
       
    32 /**
       
    33 @file
       
    34 @publishedPartner
       
    35 @released
       
    36 */
       
    37 
       
    38 /**
       
    39 Interface UID for transport controllers.
       
    40 Transport controllers are instantiations of this interface.
       
    41 */
       
    42 const TInt KObexTransportControllerInterfaceUid = KObexTransportInterfaceUid;
       
    43 
       
    44 /**
       
    45 Abstraction for transport controller implementations. Defines an interface to 
       
    46 be used by Obex protocol layer as the facade to the transport layer.
       
    47 
       
    48 In a concrete transport controller's NewL, the following things must be done: 
       
    49 (a) CObexTransportControllerBase::iConnector must be assigned to a 
       
    50 CObexConnector-derived type. (This may be reliant on the TObexTransportInfo 
       
    51 object passed in at this time.) iConnector is owned by 
       
    52 CObexTransportControllerBase.
       
    53 (b) CObexTransportControllerBase::iTransportInfo must be assigned to a 
       
    54 persistent (i.e. heap-based) TObexTransportInfo or derived type. The derived 
       
    55 transport controller may cast the TObexTransportInfo given at construction 
       
    56 time to a known derived type and copy the data from it to the new instance on 
       
    57 the heap. Note that ownership of the given TObexTransportInfo *remains with 
       
    58 the client*. iTransportInfo is then owned by CObexTransportControllerBase.
       
    59 
       
    60 In a concrete transport controller's NewTransportL, two instances of types 
       
    61 derived from CObexActiveRW must be created, and stored in 
       
    62 CObexTransportControllerBase::iActiveReader and 
       
    63 CObexTransportControllerBase::iActiveWriter. CObexTransportControllerBase owns 
       
    64 these.
       
    65 */
       
    66 class CObexTransportControllerBase : public CBase, public MObexTransportNotify
       
    67 	{
       
    68 public:
       
    69 	IMPORT_C static CObexTransportControllerBase* NewL(TObexTransportInfo& aTransportInfo);
       
    70 	IMPORT_C ~CObexTransportControllerBase();
       
    71 	
       
    72 public:
       
    73 	IMPORT_C void SetOwner(MObexNotifyExtend& aOwner);
       
    74 
       
    75 	//delegated to activerw class
       
    76 	IMPORT_C CObexPacket& SendPacket () ;	//< Access packet buffers
       
    77 	IMPORT_C CObexPacket& ReceivePacket ();
       
    78 	IMPORT_C void Send ();						//< Actually carry out transfer
       
    79 	IMPORT_C void Send (TObexOpcode aOpcode);	//< Prepare and send a 3 byte packet
       
    80 	IMPORT_C void Receive ();
       
    81 	
       
    82 	IMPORT_C TBool IsWriteActive () const;				//< is the ActiveWriter busy
       
    83 	IMPORT_C TInt InsertLocalConnectInfo (CObexPacket &aPacket, TUint8 aVersion, TUint8 aFlags);
       
    84 	IMPORT_C TBool ExtractRemoteConnectInfo (CObexPacket &aPacket, TUint8& aVersion, TUint8& aFlags);
       
    85 	IMPORT_C void CancelTransfers();
       
    86 	
       
    87 	//delegated to connector class
       
    88 	IMPORT_C void ConnectL ();
       
    89 	IMPORT_C void CancelConnect();
       
    90 	IMPORT_C void AcceptConnectionL();
       
    91 	IMPORT_C void CancelAccept();
       
    92 	IMPORT_C TBool  BringTransportDown();
       
    93 	IMPORT_C void SignalTransportError();
       
    94 	
       
    95 	//public non-virtual methods to aid preventing bc/sc breaks when the client interface changes
       
    96 	IMPORT_C void RemoteAddr(TSockAddr& aAddr);
       
    97 	IMPORT_C TBool IsTransportRestartable() const;
       
    98 	IMPORT_C const TObexTransportInfo* TransportInfo() const;
       
    99 	
       
   100 protected:
       
   101 	IMPORT_C CObexTransportControllerBase();
       
   102 
       
   103 private:
       
   104 	void BaseConstructL();
       
   105 
       
   106 private: // implemented  by derived controller 
       
   107 	virtual void DoRemoteAddr(TSockAddr& aAddr)=0;
       
   108 	virtual TBool DoIsTransportRestartable() const = 0;
       
   109 	virtual void NewTransportL(TObexConnectionInfo& aInfo) = 0;
       
   110 	virtual TUint16 GetReceivePacketDataLimit() = 0;
       
   111 	
       
   112 protected: // from MObexTransportNotify
       
   113 	IMPORT_C virtual void DoProcess(CObexPacket &aPacket);
       
   114 	IMPORT_C virtual void DoError(TInt aError);
       
   115 	IMPORT_C virtual void DoTransportUp(TObexConnectionInfo& aInfo);
       
   116 	IMPORT_C virtual void DoSignalPacketProcessEvent(TObexPacketProcessEvent aEvent);
       
   117 	
       
   118 protected:	//Extension pattern
       
   119 	IMPORT_C virtual TAny* GetInterface(TUid aUid);
       
   120 	
       
   121 private: // utility
       
   122 	void DeleteTransport();
       
   123 	void ConstructPacketsL();
       
   124 	void InitialiseTransportL(TObexConnectionInfo& aInfo);
       
   125 	void TransportUpError(TInt aError);
       
   126 
       
   127 protected: // owned
       
   128 	CObexConnector* iConnector;
       
   129 	CObexActiveRW* iActiveReader;
       
   130 	CObexActiveRW* iActiveWriter;
       
   131 	TObexConnectionInfo iConnectionInfo;
       
   132 	TObexTransportInfo* iTransportInfo;
       
   133 
       
   134 private: // unowned
       
   135 	MObexNotifyExtend* iOwner;
       
   136 
       
   137 private: // owned 
       
   138 	CObexPacket* iReceivePacket;
       
   139 	CObexPacket* iSendPacket;
       
   140 	TAny* iFuture1;
       
   141 	// Instance identifier key
       
   142 	TUid iPrivateEComUID; 
       
   143 	};
       
   144 
       
   145 #endif // __OBEXTRANSPORTCONTROLLERBASE_H__