1 // Copyright (c) 2004-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 the License "Symbian Foundation License v1.0" to Symbian Foundation members and "Symbian Foundation End User License Agreement v1.0" to non-members
5 // which accompanies this distribution, and is available
6 // at the URL "http://www.symbianfoundation.org/legal/licencesv10.html".
8 // Initial Contributors:
9 // Nokia Corporation - initial contribution.
19 #include <obexclientmtm.h>
22 /* This defines the maximum length that the connection password can be for BlueTooth. The PDU used for this
23 has a payload of 16 bytes.
25 #define KBlueToothObexPasswordLength 16
26 const TInt KBlueToothObexDeviceAddressLength = 6; // 6 byte device address
28 extern const TUint8 KObexConnectionIDHeader;
30 class CBtClientMtm : public CObexClientMtm
34 Provides client-side functionality for bluetooth messaging. This is a thin implementation over the top of
44 * Canonical NewL factory function.
46 * @param aRegisteredMtmDll Reference to registration data for MTM DLL.
47 * @param aMsvSession Reference to CMsvSession of the client requesting the object.
48 * @return Pointer to a new, constructed CBtClientMtm
49 * @leave Leaves if no memory is available.
51 IMPORT_C static CBtClientMtm* NewL(CRegisteredMtmDll& aRegisteredMtmDll, CMsvSession& aMsvSession);
53 /// Contains the timeout values for connect and put operations
56 TInt iConnectTimeout; ///< Connection attempt timeout in microseconds
57 TInt iPutTimeout; ///< Put attempt timeout in microseconds
60 /// Structure for parameter needed for sending via Bluetooth
61 struct SBtcCmdSendParams
63 STimeouts iTimeouts; ///< Structure containing connect and put operation timeouts
64 TInt iRemoteObexPort; ///< The value of the remote obex port
65 TDesC* iConnectPassword; ///<password sent to the remote server for a client initiated obex authentication challenge
68 /// Internal version of SBtcCmdSendParams
69 struct SBtcCmdSendServerParams
71 STimeouts iTimeouts; ///< Structure containing connect and put operation timeouts
72 TInt iRemoteObexPort; ///< The value of the remote obex port
73 TBufC<KBlueToothObexPasswordLength> iConnectPassword; ///<password sent to the remote server for a client initiated obex authentication challenge
76 // --- RTTI functions ---
79 * Starts an asynchronous function as an active object. Only works for EBtcCmdSend.
81 * @param aFunctionId Identifier of the function to be invoked. Only supports EBtcCmdSend.
82 * @param aSelection Selction of message entries for the requested function to operate on.
83 * @param aParameter Buffer containing input and output parameters.
84 * @param aCompletionStatus Canonical TRequestStatus used for control of the active object.
85 * @return Pointer to a new asynchronously completing CMsvOperation. If failed, this is a completed operation with
86 * status set to the relevant error code.
87 * @leave Leaves if no memory is available, or if the specified aFunctionId is unsupported.
90 virtual CMsvOperation* InvokeAsyncFunctionL(TInt aFunctionId,const CMsvEntrySelection& aSelection, TDes8& aParameter, TRequestStatus& aCompletionStatus); //aParameter should package up SBtcCmdSendParams
93 Add a Bluetooth addressee
95 @param anAddressee Addressee field of the following format
98 _LIT(KTestAddressee1, "XXX:\1Password:\2AA:\3BB");
100 _LIT(KTestAddressee2, "XXX:\1Password:\2AA");
102 _LIT(KTestAddressee3, "XXX:\1Password");
104 _LIT(KTestAddressee4, "XXX");
107 XXX : BT device address (6 bytes)
108 :\1 : Password tag sequence (4 bytes) [EBtClientMtmAddresseeFieldTypePassword]
109 Password : 0-16 characters (0-32 bytes)
110 :\2 : Connection timeout tag sequence (4 bytes) [EBtClientMtmAddresseeFieldTypeConnectionTimeout]
111 AA : Connection timeout (1 TInt = 4 bytes)
112 :\3 : Put timeout tag sequence (4 bytes) [EBtClientMtmAddresseeFieldTypePutTimeout]
113 BB : Put timeout (1 TInt = 4 bytes)
115 @leave Leaves with KErrArgument if addresse badly formatted or corrupt.
117 virtual void AddAddresseeL(const TDesC& anAddressee);
121 * Addressee field tags
122 * Note: The EAlternativeConnectTimeout exists because in an older version of
123 * the code, we were looking for the wrong field tag in the addressee field to
124 * get the connect timeout value. We should have been looking for the ETimeout value
125 * from this Enum, but instead we were incorrectly using a constant defined elsewhere.
126 * The incorrectly used constant had a value of 0x08. In order to remain backward
127 * compatible, we now look for both constants.
129 enum TBtClientMtmAddresseeFieldType
135 EAlternativeConnectTimeout = 0x08
139 * Constructor--not for use by client applications
141 * @param aRegisteredMtmDll Registration data for MTM DLL.
142 * @param aMsvSession CMsvSession of the client requesting the object.
145 CBtClientMtm(CRegisteredMtmDll& aRegisteredMtmDll, CMsvSession& aMsvSession);
148 * Deletes the old header, then creates a new CBtHeader.
150 * @leave KErrXXX System-wide error codes if allocation fails
153 virtual void InitialiseHeaderL();
155 TBool ParseDestinationFieldL(TUint16 aFieldTag, TDes8& aField, TPtrC& aFieldList);
156 void ParseDestinationL(const TDesC& aFieldsToParse, TDes8& aDeviceAddress,
157 TDes16& aPassword, TInt& aConnectTimeout, TInt& aPutTimeout);
158 void CreateMessageOperationL(CMsvOperation*& aOperation,
159 const CMsvEntrySelection& aSelection, TRequestStatus& aCompletionStatus);
163 virtual void TestInvariant() const;
168 #endif // __BTCMTM_H__