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". |
|
7 // |
|
8 // Initial Contributors: |
|
9 // Nokia Corporation - initial contribution. |
|
10 // |
|
11 // Contributors: |
|
12 // |
|
13 // Description: |
|
14 // |
|
15 |
|
16 #ifndef __BTCMTM_H__ |
|
17 #define __BTCMTM_H__ |
|
18 |
|
19 #include <obexclientmtm.h> |
|
20 |
|
21 |
|
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. |
|
24 */ |
|
25 #define KBlueToothObexPasswordLength 16 |
|
26 const TInt KBlueToothObexDeviceAddressLength = 6; // 6 byte device address |
|
27 |
|
28 extern const TUint8 KObexConnectionIDHeader; |
|
29 |
|
30 class CBtClientMtm : public CObexClientMtm |
|
31 /** |
|
32 Bluetooth Client MTM. |
|
33 |
|
34 Provides client-side functionality for bluetooth messaging. This is a thin implementation over the top of |
|
35 CObexClientMtm. |
|
36 |
|
37 @publishedPartner |
|
38 @released |
|
39 */ |
|
40 { |
|
41 public: |
|
42 |
|
43 /** |
|
44 * Canonical NewL factory function. |
|
45 * |
|
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. |
|
50 */ |
|
51 IMPORT_C static CBtClientMtm* NewL(CRegisteredMtmDll& aRegisteredMtmDll, CMsvSession& aMsvSession); |
|
52 |
|
53 /// Contains the timeout values for connect and put operations |
|
54 struct STimeouts |
|
55 { |
|
56 TInt iConnectTimeout; ///< Connection attempt timeout in microseconds |
|
57 TInt iPutTimeout; ///< Put attempt timeout in microseconds |
|
58 }; |
|
59 |
|
60 /// Structure for parameter needed for sending via Bluetooth |
|
61 struct SBtcCmdSendParams |
|
62 { |
|
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 |
|
66 }; |
|
67 |
|
68 /// Internal version of SBtcCmdSendParams |
|
69 struct SBtcCmdSendServerParams |
|
70 { |
|
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 |
|
74 }; |
|
75 |
|
76 // --- RTTI functions --- |
|
77 |
|
78 /** |
|
79 * Starts an asynchronous function as an active object. Only works for EBtcCmdSend. |
|
80 * |
|
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. |
|
88 */ |
|
89 |
|
90 virtual CMsvOperation* InvokeAsyncFunctionL(TInt aFunctionId,const CMsvEntrySelection& aSelection, TDes8& aParameter, TRequestStatus& aCompletionStatus); //aParameter should package up SBtcCmdSendParams |
|
91 |
|
92 /** |
|
93 Add a Bluetooth addressee |
|
94 |
|
95 @param anAddressee Addressee field of the following format |
|
96 |
|
97 |
|
98 _LIT(KTestAddressee1, "XXX:\1Password:\2AA:\3BB"); |
|
99 |
|
100 _LIT(KTestAddressee2, "XXX:\1Password:\2AA"); |
|
101 |
|
102 _LIT(KTestAddressee3, "XXX:\1Password"); |
|
103 |
|
104 _LIT(KTestAddressee4, "XXX"); |
|
105 |
|
106 |
|
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) |
|
114 |
|
115 @leave Leaves with KErrArgument if addresse badly formatted or corrupt. |
|
116 */ |
|
117 virtual void AddAddresseeL(const TDesC& anAddressee); |
|
118 |
|
119 private: |
|
120 /* |
|
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. |
|
128 */ |
|
129 enum TBtClientMtmAddresseeFieldType |
|
130 { |
|
131 EDeviceAddress, |
|
132 EPassword, |
|
133 ETimeout, |
|
134 EPutTimeout, |
|
135 EAlternativeConnectTimeout = 0x08 |
|
136 }; |
|
137 |
|
138 /** |
|
139 * Constructor--not for use by client applications |
|
140 * |
|
141 * @param aRegisteredMtmDll Registration data for MTM DLL. |
|
142 * @param aMsvSession CMsvSession of the client requesting the object. |
|
143 */ |
|
144 |
|
145 CBtClientMtm(CRegisteredMtmDll& aRegisteredMtmDll, CMsvSession& aMsvSession); |
|
146 |
|
147 /** |
|
148 * Deletes the old header, then creates a new CBtHeader. |
|
149 * |
|
150 * @leave KErrXXX System-wide error codes if allocation fails |
|
151 */ |
|
152 |
|
153 virtual void InitialiseHeaderL(); |
|
154 |
|
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); |
|
160 |
|
161 |
|
162 #ifdef _DEBUG |
|
163 virtual void TestInvariant() const; |
|
164 #endif //_DEBUG |
|
165 }; |
|
166 |
|
167 |
|
168 #endif // __BTCMTM_H__ |
|