|
1 // Copyright (c) 2000-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 SDPCLIENT_H |
|
17 #define SDPCLIENT_H |
|
18 |
|
19 #include <es_prot.h> |
|
20 #include <bttypes.h> |
|
21 |
|
22 class CSdpPdu; |
|
23 class CSdpNetDbProvider; |
|
24 class CSdpProtocol; |
|
25 class CProtocolBase; |
|
26 class TUUID; |
|
27 |
|
28 /** |
|
29 Acts as the local SDP client Agent, for a given remote device. |
|
30 |
|
31 There is one of these per remote device. This class |
|
32 acts as an internal socket binding to a lower level SAP. Thus we |
|
33 derive from MSocketNotify so that the SAP can directly notify us of events. |
|
34 **/ |
|
35 NONSHARABLE_CLASS(CSdpClient) : public CBase, private MSocketNotify |
|
36 { |
|
37 friend class CSdpProtocol; |
|
38 public: |
|
39 // Create/destroy |
|
40 static CSdpClient* NewL(CSdpProtocol& aProt, CProtocolBase& aL2CAP); |
|
41 ~CSdpClient(); |
|
42 // Interface for the Protocol to request services |
|
43 void Open(TBTDevAddr& aAddr); |
|
44 void AddNetDbProvider(CSdpNetDbProvider& aNetDbProvider); |
|
45 void RemoveNetDbProvider(CSdpNetDbProvider& aNetDbProvider); |
|
46 |
|
47 // Interface for the NetDbProviders to request actions |
|
48 void ServiceSearchRequest(CSdpNetDbProvider& aNetDbProvider, |
|
49 TUint16 aMaxCount, const TUUID &aUUID, const TDesC8& aContState); |
|
50 void ServiceAttributeRequest(CSdpNetDbProvider& aNetDbProvider, |
|
51 TUint aRecordHandle, TUint16 aMaxLength, TBool aRange, |
|
52 TUint aAttribute, const TDesC8& aContState); |
|
53 void EncodedRequest(CSdpNetDbProvider& aNetDbProvider, |
|
54 TUint8 aPduRequestId, |
|
55 const TDesC8& aEncodedData); |
|
56 |
|
57 |
|
58 // From MSocketNotify |
|
59 void NewData(TUint aCount); |
|
60 void CanSend(); |
|
61 void ConnectComplete(); |
|
62 void ConnectComplete(const TDesC8& aConnectData); |
|
63 void ConnectComplete(CServProviderBase& aSSP); |
|
64 void ConnectComplete(CServProviderBase& aSSP,const TDesC8& aConnectData); |
|
65 void CanClose(TDelete aDelete=EDelete); |
|
66 void CanClose(const TDesC8& aDisconnectData,TDelete aDelete=EDelete); |
|
67 void Error(TInt aError,TUint aOperationMask=EErrorAllOperations); |
|
68 void Disconnect(void); |
|
69 void Disconnect(TDesC8& aDisconnectData); |
|
70 void IoctlComplete(TDesC8 *aBuf); |
|
71 void NoBearer(const TDesC8& /*aConnectionInf*/) {}; |
|
72 void Bearer(const TDesC8& /*aConnectionInf*/) {}; |
|
73 |
|
74 private: |
|
75 // Create/destroy |
|
76 CSdpClient(CSdpProtocol& aProtocol, CProtocolBase& aL2CAP); |
|
77 void ConstructL(); |
|
78 |
|
79 // Out & In PDU handling could be generalised in a CSDP base, which |
|
80 // the SDP client and server specialise as appropriate. |
|
81 |
|
82 // Processing incoming pdus |
|
83 void ParseNextPacket(); |
|
84 void HandlePDU(TUint8 aPduId, TUint16 aTransId, const TDesC8& aParams); |
|
85 void HandleErrorResponse(CSdpNetDbProvider* aNetDbProv, const TDesC8& aParams); |
|
86 void HandleServiceSearchResponse(CSdpNetDbProvider* aNetDbProv, const TDesC8& aParams); |
|
87 void HandleServiceAttributeResponse(CSdpNetDbProvider* aNetDbProv, const TDesC8& aParams); |
|
88 |
|
89 // Outgoing pdus |
|
90 CSdpPdu* NewPdu(CSdpNetDbProvider* aNetDb); |
|
91 TUint16 NextTransId(); |
|
92 |
|
93 void EnqueOutboundPdu(CSdpPdu& aPdu); |
|
94 void TryToSend(); |
|
95 |
|
96 // Hide these to make replacing with bitmask easier |
|
97 TBool ChannelUp() const; |
|
98 void ChannelUp(TBool aState); |
|
99 |
|
100 TBool RequestOutstanding() const; |
|
101 void RequestOutstanding(TBool aBool); // True if OK to send |
|
102 |
|
103 TBool L2CAPBlocked() const; |
|
104 void L2CAPBlocked(TBool aState); |
|
105 |
|
106 // Misc |
|
107 void CheckForIdle(TInt aTimeoutInSeconds); |
|
108 void CancelIdleTimer(); |
|
109 static TInt IdleTimerExpired(TAny* aPtr); |
|
110 |
|
111 private: |
|
112 // Data items |
|
113 TDblQue<CSdpNetDbProvider> iNetDbProviders; // NetDbProviders using this Client |
|
114 TDblQue<CSdpPdu> iOutboundQ; // PDUs to be sent |
|
115 CSdpProtocol& iProtocol; |
|
116 CProtocolBase& iL2CAP; |
|
117 CServProviderBase* iBoundSAP; |
|
118 TBTDevAddr iRemoteAddr; |
|
119 |
|
120 // Reassembly buffer |
|
121 HBufC8* iNextPacket; // Next packet coming up from L2CAP |
|
122 |
|
123 // Client state |
|
124 TBool iClientChannelUp; |
|
125 TBool iRequestOutstanding; // A request has been sent |
|
126 TBool iL2CAPSendBlocked; // Is L2CAP ok to send data? |
|
127 TUint16 iTransId; // Last used transaction ID for this client |
|
128 |
|
129 // Clean up stuff |
|
130 TDeltaTimerEntry iIdleTimerEntry; //< Idle timer, that kills us eventually |
|
131 TBool iIdleQueued; //< Idle timer is on Q. |
|
132 |
|
133 // Go on a Q |
|
134 TDblQueLink iLink; |
|
135 }; |
|
136 |
|
137 |
|
138 inline TBool CSdpClient::ChannelUp() const |
|
139 {return iClientChannelUp;} |
|
140 |
|
141 inline void CSdpClient::ChannelUp(TBool aState) |
|
142 {iClientChannelUp=aState;} |
|
143 |
|
144 inline TBool CSdpClient::RequestOutstanding() const |
|
145 {return iRequestOutstanding;} |
|
146 |
|
147 inline void CSdpClient::RequestOutstanding(TBool aBool) |
|
148 {iRequestOutstanding=aBool;} |
|
149 |
|
150 inline TBool CSdpClient::L2CAPBlocked() const |
|
151 {return iL2CAPSendBlocked;} |
|
152 |
|
153 inline void CSdpClient::L2CAPBlocked(TBool aState) |
|
154 {iL2CAPSendBlocked=aState;} |
|
155 |
|
156 |
|
157 |
|
158 #endif |