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