syncmlfw/common/obex/obexclient/inc/NSmlObexClient.h
changeset 0 b497e44ab2fc
child 54 085438c28042
equal deleted inserted replaced
-1:000000000000 0:b497e44ab2fc
       
     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:  SyncML Obex client
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 #ifndef __NSMLOBEXCLIENT_H__
       
    20 #define __NSMLOBEXCLIENT_H__
       
    21 
       
    22 #include <e32base.h>
       
    23 #include <e32std.h>
       
    24 #include <obex.h>
       
    25 
       
    26 #include "nsmltransport.h"
       
    27 #include "Obexsearcherobserver.h"
       
    28 #include "Btconninfo.h"
       
    29 
       
    30 const TUint16 KNSmlObexClientGranularity = 1024;
       
    31 const TUint16 KNameLen = 256;
       
    32 
       
    33 _LIT8( ObexName, "SyncML Obex" );
       
    34 
       
    35 
       
    36 #ifndef __NSMLOBEXCLIENT_PAN__
       
    37 #define __NSMLOBEXCLIENT_PAN__
       
    38 
       
    39 
       
    40 /** CNsmlObexClient panic codes */
       
    41 enum TNSmlObexClientPanics 
       
    42     {
       
    43     EBTObjectExchangeBasicUi = 1,
       
    44     EBTObjectExchangeReceiverInvalidState,
       
    45     EBTObjectExchangeSenderExists,
       
    46     EBTObjectExchangeReceiverExists,
       
    47     EBTObjectExchangeSenderInvalidState,
       
    48     EBTObjectExchangeNoSender,
       
    49     EBTObjectExchangeAddMessage,
       
    50     EBTObjectExchangeNextRecordRequestComplete,
       
    51     EBTObjectExchangeAttributeRequestResult,
       
    52     EBTObjectExchangeAttributeRequestComplete,
       
    53     EBTObjectExchangeInvalidControlIndex,
       
    54     EBTObjectExchangeProtocolRead,
       
    55     EBTObjectExchangeAttributeRequest,
       
    56     EBTObjectExchangeSdpRecordDelete,
       
    57     EBTObjectExchangeUnexpectedState,
       
    58     EBTObjectExchangeUnexpectedLogicState
       
    59     };
       
    60 
       
    61 inline void Panic(TNSmlObexClientPanics aReason)
       
    62     { 
       
    63     User::Panic(_L("NSMLOBEXCLIENT"), aReason);
       
    64     }
       
    65 
       
    66 #endif // __NSMLOBEXCLIENT_PAN__
       
    67 
       
    68 
       
    69 
       
    70 class CNSmlObexServiceSearcher;
       
    71 class CObexSearcherBase;
       
    72 class MExtBTSearcherObserver;
       
    73 //class T_CNsmlObexClient;	//For testing purposes
       
    74 
       
    75 class CNsmlObexClient : public CActive, public MObexSearcherObserver
       
    76     {
       
    77 public:
       
    78 // 	friend T_CNsmlObexClient;	//For testing purposes
       
    79 
       
    80 	CNsmlObexClient();
       
    81     static CNsmlObexClient* NewL();        
       
    82 	virtual void ConstructL ( const TDesC8& aName );
       
    83     virtual ~CNsmlObexClient();
       
    84 
       
    85 	virtual void ConnectL( TNSmlObexTransport aTransport,TBool aServerAlerted, TDesC8& aMimeType, TRequestStatus &aStatus );
       
    86 	virtual void CloseCommunicationL( TRequestStatus &aStatus );
       
    87 	virtual void ReceiveDataL( TPtr8& aStartPtr, TRequestStatus &aStatus );
       
    88 	virtual void SendDataL( TDesC8& aStartPtr, TBool /*aFinalPacket*/, TRequestStatus &aStatus );
       
    89 	virtual void SetBTConnInfo( const TBTDevAddr aBTDevAddr, const TUUID aUid );
       
    90 	virtual void SetExtObserver( MExtBTSearcherObserver* aExtObserver );
       
    91 
       
    92 	virtual TBool IsBusy();
       
    93 public:
       
    94 	TRequestStatus* iAgentStatus;
       
    95 
       
    96 protected:    // from CActive
       
    97     void DoCancel();
       
    98     void RunL();
       
    99 
       
   100 protected:		//from MObexSearcherObserver
       
   101     void HandleDeviceFoundL();
       
   102     void HandleDeviceErrorL( TInt aErr );
       
   103     void HandleServiceFoundL();
       
   104     void HandleServiceErrorL( TInt aErr );
       
   105 
       
   106 
       
   107 private:
       
   108     void ConnectToServerL();
       
   109 	void StopL();
       
   110 	void DisconnectL();
       
   111     TBool IsConnected();
       
   112     void ErrorConversion( const TInt aError, TInt& aErrCode );
       
   113     
       
   114 private:
       
   115 
       
   116     enum TState 
       
   117         {
       
   118 		EDisconnected,
       
   119         EGettingConnection,
       
   120         EWaitingToSend,
       
   121 		EWaitingToReceive,
       
   122         EDisconnecting,
       
   123 		EConnectionFailed
       
   124         };
       
   125 
       
   126     /*! @var iState the state of the active object, determines behaviour within the RunL method. */
       
   127     TState iState;
       
   128 
       
   129 	CObexSearcherBase*				iObexSearcher;
       
   130 	MExtBTSearcherObserver*			iExtObserver;
       
   131 	TBTConnInfo						iBTConnInfo;
       
   132 
       
   133     CObexClient*					iClient;
       
   134     CObexBufObject*					iCurrObject;
       
   135 	HBufC8*							iMimeType;
       
   136 	TInt							iDocumentLength;
       
   137 	CBufFlat*						iDataBuf;
       
   138 	TPtr8							iDataPtr;
       
   139     };
       
   140 
       
   141 	IMPORT_C CNsmlObexClient* CreateCNsmlObexClientL();
       
   142 	typedef CNsmlObexClient* (*TNSmlCreateObexClientFunc) ();   
       
   143 
       
   144 #endif 
       
   145