|
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 "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 __BTCMTM_H__ |
|
17 #define __BTCMTM_H__ |
|
18 |
|
19 #include <obexclientmtm.h> |
|
20 |
|
21 #ifndef SYMBIAN_ENABLE_SPLIT_HEADERS |
|
22 #include "msvconsts.h" |
|
23 #endif |
|
24 |
|
25 |
|
26 /* This defines the maximum length that the connection password can be for BlueTooth. The PDU used for this |
|
27 has a payload of 16 bytes. |
|
28 */ |
|
29 #define KBlueToothObexPasswordLength 16 |
|
30 const TInt KBlueToothObexDeviceAddressLength = 6; // 6 byte device address |
|
31 |
|
32 extern const TUint8 KObexConnectionIDHeader; |
|
33 |
|
34 class CBtClientMtm : public CObexClientMtm |
|
35 /** |
|
36 Bluetooth Client MTM. |
|
37 |
|
38 Provides client-side functionality for bluetooth messaging. This is a thin implementation over the top of |
|
39 CObexClientMtm. |
|
40 |
|
41 @publishedPartner |
|
42 @released |
|
43 */ |
|
44 { |
|
45 public: |
|
46 |
|
47 /** |
|
48 * Canonical NewL factory function. |
|
49 * |
|
50 * @param aRegisteredMtmDll Reference to registration data for MTM DLL. |
|
51 * @param aMsvSession Reference to CMsvSession of the client requesting the object. |
|
52 * @return Pointer to a new, constructed CBtClientMtm |
|
53 * @leave Leaves if no memory is available. |
|
54 */ |
|
55 IMPORT_C static CBtClientMtm* NewL(CRegisteredMtmDll& aRegisteredMtmDll, CMsvSession& aMsvSession); |
|
56 |
|
57 // Contains the timeout values for connect and put operations |
|
58 struct STimeouts |
|
59 { |
|
60 TInt iConnectTimeout; //< Connection attempt timeout in microseconds |
|
61 TInt iPutTimeout; //< Put attempt timeout in microseconds |
|
62 }; |
|
63 |
|
64 // Structure for parameter needed for sending via Bluetooth |
|
65 struct SBtcCmdSendParams |
|
66 { |
|
67 STimeouts iTimeouts; //< Structure containing connect and put operation timeouts |
|
68 TInt iRemoteObexPort; //< The value of the remote obex port |
|
69 TDesC* iConnectPassword; //<password sent to the remote server for a client initiated obex authentication challenge |
|
70 }; |
|
71 |
|
72 // Internal version of SBtcCmdSendParams |
|
73 struct SBtcCmdSendServerParams |
|
74 { |
|
75 STimeouts iTimeouts; //< Structure containing connect and put operation timeouts |
|
76 TInt iRemoteObexPort; //< The value of the remote obex port |
|
77 TBufC<KBlueToothObexPasswordLength> iConnectPassword; //<password sent to the remote server for a client initiated obex authentication challenge |
|
78 }; |
|
79 |
|
80 // --- RTTI functions --- |
|
81 |
|
82 /** |
|
83 * Starts an asynchronous function as an active object. Only works for EBtcCmdSend. |
|
84 * |
|
85 * @param aFunctionId Identifier of the function to be invoked. Only supports EBtcCmdSend. |
|
86 * @param aSelection Selection of message entries for the requested function to operate on. |
|
87 * @param aParameter Buffer containing input and output parameters. |
|
88 * @param aCompletionStatus Canonical TRequestStatus used for control of the active object. |
|
89 * @return Pointer to a new asynchronously completing CMsvOperation. If failed, this is a completed operation with |
|
90 * status set to the relevant error code. |
|
91 * @leave Leaves if no memory is available, or if the specified aFunctionId is unsupported. |
|
92 */ |
|
93 |
|
94 virtual CMsvOperation* InvokeAsyncFunctionL(TInt aFunctionId,const CMsvEntrySelection& aSelection, TDes8& aParameter, TRequestStatus& aCompletionStatus); //aParameter should package up SBtcCmdSendParams |
|
95 |
|
96 /** |
|
97 Add a Bluetooth addressee |
|
98 |
|
99 @param anAddressee Addressee field of the following format |
|
100 |
|
101 |
|
102 _LIT(KTestAddressee1, "XXX:\1Password:\2AA:\3BB"); |
|
103 |
|
104 _LIT(KTestAddressee2, "XXX:\1Password:\2AA"); |
|
105 |
|
106 _LIT(KTestAddressee3, "XXX:\1Password"); |
|
107 |
|
108 _LIT(KTestAddressee4, "XXX"); |
|
109 |
|
110 |
|
111 XXX : BT device address (6 bytes) |
|
112 :\1 : Password tag sequence (4 bytes) [EBtClientMtmAddresseeFieldTypePassword] |
|
113 Password : 0-16 characters (0-32 bytes) |
|
114 :\2 : Connection timeout tag sequence (4 bytes) [EBtClientMtmAddresseeFieldTypeConnectionTimeout] |
|
115 AA : Connection timeout (1 TInt = 4 bytes) |
|
116 :\3 : Put timeout tag sequence (4 bytes) [EBtClientMtmAddresseeFieldTypePutTimeout] |
|
117 BB : Put timeout (1 TInt = 4 bytes) |
|
118 |
|
119 @leave Leaves with KErrArgument if addresse badly formatted or corrupt. |
|
120 */ |
|
121 virtual void AddAddresseeL(const TDesC& anAddressee); |
|
122 |
|
123 private: |
|
124 /* |
|
125 * Addressee field tags |
|
126 * Note: The EAlternativeConnectTimeout exists because in an older version of |
|
127 * the code, we were looking for the wrong field tag in the addressee field to |
|
128 * get the connect timeout value. We should have been looking for the ETimeout value |
|
129 * from this Enum, but instead we were incorrectly using a constant defined elsewhere. |
|
130 * The incorrectly used constant had a value of 0x08. In order to remain backward |
|
131 * compatible, we now look for both constants. |
|
132 */ |
|
133 enum TBtClientMtmAddresseeFieldType |
|
134 { |
|
135 EDeviceAddress, |
|
136 EPassword, |
|
137 ETimeout, |
|
138 EPutTimeout, |
|
139 EAlternativeConnectTimeout = 0x08 |
|
140 }; |
|
141 |
|
142 /** |
|
143 * Constructor--not for use by client applications |
|
144 * |
|
145 * @param aRegisteredMtmDll Registration data for MTM DLL. |
|
146 * @param aMsvSession CMsvSession of the client requesting the object. |
|
147 */ |
|
148 |
|
149 CBtClientMtm(CRegisteredMtmDll& aRegisteredMtmDll, CMsvSession& aMsvSession); |
|
150 |
|
151 /** |
|
152 * Deletes the old header, then creates a new CBtHeader. |
|
153 * |
|
154 * @leave KErrXXX System-wide error codes if allocation fails |
|
155 */ |
|
156 |
|
157 virtual void InitialiseHeaderL(); |
|
158 |
|
159 TBool ParseDestinationFieldL(TUint16 aFieldTag, TDes8& aField, TPtrC& aFieldList); |
|
160 void ParseDestinationL(const TDesC& aFieldsToParse, TDes8& aDeviceAddress, |
|
161 TDes16& aPassword, TInt& aConnectTimeout, TInt& aPutTimeout); |
|
162 void CreateMessageOperationL(CMsvOperation*& aOperation, |
|
163 const CMsvEntrySelection& aSelection, TRequestStatus& aCompletionStatus); |
|
164 |
|
165 |
|
166 #ifdef _DEBUG |
|
167 virtual void TestInvariant() const; |
|
168 #endif //_DEBUG |
|
169 }; |
|
170 |
|
171 |
|
172 #endif // __BTCMTM_H__ |
|
173 |