epoc32/include/btcmtm.h
branchSymbian2
changeset 2 2fe1408b6811
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/epoc32/include/btcmtm.h	Tue Mar 16 16:12:26 2010 +0000
     1.3 @@ -0,0 +1,168 @@
     1.4 +// Copyright (c) 2004-2009 Nokia Corporation and/or its subsidiary(-ies).
     1.5 +// All rights reserved.
     1.6 +// This component and the accompanying materials are made available
     1.7 +// 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
     1.8 +// which accompanies this distribution, and is available
     1.9 +// at the URL "http://www.symbianfoundation.org/legal/licencesv10.html".
    1.10 +//
    1.11 +// Initial Contributors:
    1.12 +// Nokia Corporation - initial contribution.
    1.13 +//
    1.14 +// Contributors:
    1.15 +//
    1.16 +// Description:
    1.17 +//
    1.18 +
    1.19 +#ifndef __BTCMTM_H__
    1.20 +#define __BTCMTM_H__
    1.21 +
    1.22 +#include <obexclientmtm.h>
    1.23 +
    1.24 +
    1.25 +/* This defines the maximum length that the connection password can be for BlueTooth.  The PDU used for this
    1.26 +   has a payload of 16 bytes.
    1.27 +*/
    1.28 +#define KBlueToothObexPasswordLength 16
    1.29 +const TInt KBlueToothObexDeviceAddressLength = 6; 	// 6 byte device address
    1.30 +
    1.31 +extern const TUint8 KObexConnectionIDHeader;
    1.32 +
    1.33 +class CBtClientMtm : public CObexClientMtm
    1.34 +/**
    1.35 +Bluetooth Client MTM.
    1.36 +
    1.37 +Provides client-side functionality for bluetooth messaging. This is a thin implementation over the top of
    1.38 +CObexClientMtm.
    1.39 +
    1.40 +@publishedPartner
    1.41 +@released
    1.42 +*/
    1.43 +	{
    1.44 +public:
    1.45 +
    1.46 +	/**
    1.47 +	 * Canonical NewL factory function. 
    1.48 +	 *
    1.49 +	 * @param aRegisteredMtmDll Reference to registration data for MTM DLL.
    1.50 +	 * @param aMsvSession Reference to CMsvSession of the client requesting the object.	
    1.51 +	 * @return Pointer to a new, constructed CBtClientMtm
    1.52 +	 * @leave Leaves if no memory is available.
    1.53 +	 */
    1.54 +	IMPORT_C static CBtClientMtm* NewL(CRegisteredMtmDll& aRegisteredMtmDll, CMsvSession& aMsvSession);
    1.55 +
    1.56 +	/// Contains the timeout values for connect and put operations
    1.57 +	struct STimeouts
    1.58 +		{
    1.59 +		TInt iConnectTimeout; ///< Connection attempt timeout in microseconds
    1.60 +		TInt iPutTimeout;	  ///< Put attempt timeout in microseconds
    1.61 +		};
    1.62 +	
    1.63 +	/// Structure for parameter needed for sending via Bluetooth
    1.64 +	struct SBtcCmdSendParams
    1.65 +		{
    1.66 +		STimeouts iTimeouts; ///< Structure containing connect and put operation timeouts
    1.67 +		TInt iRemoteObexPort; ///< The value of the remote obex port
    1.68 +		TDesC* iConnectPassword; ///<password sent to the remote server for a client initiated obex authentication challenge
    1.69 +		};
    1.70 +		
    1.71 +	/// Internal version of SBtcCmdSendParams 
    1.72 +	struct SBtcCmdSendServerParams
    1.73 +		{
    1.74 +		STimeouts iTimeouts; ///< Structure containing connect and put operation timeouts
    1.75 +		TInt iRemoteObexPort; ///< The value of the remote obex port
    1.76 +		TBufC<KBlueToothObexPasswordLength> iConnectPassword; ///<password sent to the remote server for a client initiated obex authentication challenge 
    1.77 +		};
    1.78 +
    1.79 +	// --- RTTI functions ---
    1.80 +	
    1.81 +	/**
    1.82 +	 * Starts an asynchronous function as an active object. Only works for EBtcCmdSend.
    1.83 +	 *
    1.84 +	 * @param aFunctionId Identifier of the function to be invoked. Only supports EBtcCmdSend.
    1.85 +	 * @param aSelection Selction of message entries for the requested function to operate on.
    1.86 +	 * @param aParameter Buffer containing input and output parameters.
    1.87 +	 * @param aCompletionStatus Canonical TRequestStatus used for control of the active object.
    1.88 +	 * @return Pointer to a new asynchronously completing CMsvOperation. If failed, this is a completed operation with 
    1.89 +	 * status set to the relevant error code.
    1.90 +	 * @leave Leaves if no memory is available, or if the specified aFunctionId is unsupported.
    1.91 +	 */
    1.92 +
    1.93 +	virtual CMsvOperation* InvokeAsyncFunctionL(TInt aFunctionId,const CMsvEntrySelection& aSelection, TDes8& aParameter, TRequestStatus& aCompletionStatus); //aParameter should package up SBtcCmdSendParams
    1.94 +
    1.95 +	/**
    1.96 +	Add a Bluetooth addressee
    1.97 +
    1.98 +	@param anAddressee Addressee field of the following format
    1.99 +
   1.100 +
   1.101 +	_LIT(KTestAddressee1, "XXX:\1Password:\2AA:\3BB");
   1.102 +
   1.103 +	_LIT(KTestAddressee2, "XXX:\1Password:\2AA");
   1.104 +
   1.105 +	_LIT(KTestAddressee3, "XXX:\1Password");
   1.106 +
   1.107 +	_LIT(KTestAddressee4, "XXX");
   1.108 +
   1.109 +
   1.110 +	XXX		: BT device address (6 bytes)
   1.111 +	:\1		: Password tag sequence (4 bytes) [EBtClientMtmAddresseeFieldTypePassword]
   1.112 +	Password	: 0-16 characters (0-32 bytes)
   1.113 +	:\2		: Connection timeout tag sequence (4 bytes) [EBtClientMtmAddresseeFieldTypeConnectionTimeout]
   1.114 +	AA		: Connection timeout (1 TInt = 4 bytes) 
   1.115 +	:\3		: Put timeout tag sequence (4 bytes) [EBtClientMtmAddresseeFieldTypePutTimeout]
   1.116 +	BB		: Put timeout (1 TInt = 4 bytes)
   1.117 +	 
   1.118 +	@leave Leaves with KErrArgument if addresse badly formatted or corrupt.
   1.119 +	 */
   1.120 +	virtual void AddAddresseeL(const TDesC& anAddressee);
   1.121 +
   1.122 +private:
   1.123 +	/*
   1.124 +	 * Addressee field tags
   1.125 +	 * Note: The EAlternativeConnectTimeout exists because in an older version of
   1.126 +	 * the code, we were looking for the wrong field tag in the addressee field to
   1.127 +	 * get the connect timeout value. We should have been looking for the ETimeout value
   1.128 +	 * from this Enum, but instead we were incorrectly using a constant defined elsewhere.
   1.129 +	 * The incorrectly used constant had a value of 0x08. In order to remain backward
   1.130 +	 * compatible, we now look for both constants.
   1.131 +	 */
   1.132 +	enum TBtClientMtmAddresseeFieldType
   1.133 +		{
   1.134 +		EDeviceAddress,
   1.135 +		EPassword,
   1.136 +		ETimeout,
   1.137 +		EPutTimeout,
   1.138 +		EAlternativeConnectTimeout = 0x08
   1.139 +		};
   1.140 +	
   1.141 +	/**
   1.142 +	 * Constructor--not for use by client applications
   1.143 +	 *
   1.144 +	 * @param aRegisteredMtmDll Registration data for MTM DLL.
   1.145 +	 * @param aMsvSession CMsvSession of the client requesting the object. 
   1.146 +	 */
   1.147 +
   1.148 +	CBtClientMtm(CRegisteredMtmDll& aRegisteredMtmDll, CMsvSession& aMsvSession);
   1.149 +	
   1.150 +	/**
   1.151 +	 * Deletes the old header, then creates a new CBtHeader.
   1.152 +	 *
   1.153 +	 * @leave KErrXXX System-wide error codes if allocation fails
   1.154 +	 */
   1.155 +	
   1.156 +	virtual void InitialiseHeaderL();
   1.157 +	
   1.158 +	TBool ParseDestinationFieldL(TUint16 aFieldTag, TDes8& aField, TPtrC& aFieldList);
   1.159 +	void ParseDestinationL(const TDesC& aFieldsToParse, TDes8& aDeviceAddress, 
   1.160 +						 TDes16& aPassword, TInt& aConnectTimeout, TInt& aPutTimeout);
   1.161 +	void CreateMessageOperationL(CMsvOperation*& aOperation, 
   1.162 +		const CMsvEntrySelection& aSelection, TRequestStatus& aCompletionStatus);
   1.163 +
   1.164 +
   1.165 +#ifdef _DEBUG
   1.166 +	virtual void TestInvariant() const;
   1.167 +#endif //_DEBUG
   1.168 +	};
   1.169 +
   1.170 +
   1.171 +#endif // __BTCMTM_H__