|
1 // Copyright (c) 2003-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 // Defines the Proxy SAP class |
|
15 // |
|
16 // |
|
17 |
|
18 #ifndef _PROXYSAP_H_ |
|
19 #define _PROXYSAP_H_ |
|
20 |
|
21 #include <bt_sock.h> |
|
22 #include <es_mbuf.h> |
|
23 #include "physicallinks.h" |
|
24 #include "notification.h" |
|
25 #include "btconsts.h" |
|
26 |
|
27 class CACLRawConduit; |
|
28 |
|
29 NONSHARABLE_CLASS(TRequestedLinkPolicy) |
|
30 /** |
|
31 Not to be confused with the TLinkPolicy - that's just for the HCI Command |
|
32 This is to store the preferences of the RBTBaseband within a Proxy SAP |
|
33 **/ |
|
34 { |
|
35 public: |
|
36 TRequestedLinkPolicy(TUint8 aSettings, TBool aSwitchAllowed); |
|
37 TBool IsModeAllowed(TBTLinkMode aMode) const; |
|
38 TBool IsSwitchAllowed() const; |
|
39 |
|
40 void SetModeAllowed(TBTLinkMode, TBool aAllowed); |
|
41 void SetSwitchAllowed(TBool aAllowed); |
|
42 |
|
43 TBool IsModeRequested(TBTLinkMode aMode) const; |
|
44 TBool IsAnyModeRequested() const; |
|
45 |
|
46 TInt SetModeRequested(TBTLinkMode aMode); |
|
47 |
|
48 TUint8 ModesAllowed() const; |
|
49 TUint8 CurrentModeRequest() const; |
|
50 |
|
51 private: |
|
52 TBool iSwitchAllowed; |
|
53 TUint8 iModesAllowed; |
|
54 TUint8 iCurrentModeRequest; |
|
55 }; |
|
56 |
|
57 |
|
58 NONSHARABLE_CLASS(TBTQueuedBasebandEventNotification) : public TBTBasebandEventNotification |
|
59 /** |
|
60 Extends via aggregation public TBTBasebandEventNotification class to make it queue-able |
|
61 **/ |
|
62 { |
|
63 public: |
|
64 TBTQueuedBasebandEventNotification(const TBTBasebandEventNotification& aEvent) |
|
65 : TBTBasebandEventNotification(aEvent) {}; |
|
66 |
|
67 public: |
|
68 TSglQueLink iLink; |
|
69 }; |
|
70 |
|
71 |
|
72 NONSHARABLE_CLASS(CBTProxySAP) : public CBTBasebandSAP |
|
73 /** |
|
74 Acts as the proxy to RBTBaseband - its MSocketNotify is a CSocket |
|
75 |
|
76 It is itself an MSocketNotify as this is an ideal way for the real SAP to talk to it |
|
77 **/ |
|
78 { |
|
79 friend class CACLRawConduit; |
|
80 public: |
|
81 static CBTProxySAP* NewLC(CPhysicalLinksManager& aConnectionMan, CPhysicalLink*); |
|
82 static CBTProxySAP* NewL(CPhysicalLinksManager& aConnectionMan, CPhysicalLink*); |
|
83 |
|
84 // from SAP - the proxy will not do all of these |
|
85 virtual void Start(); |
|
86 virtual void RemName(TSockAddr& anAddr) const ; |
|
87 virtual TInt SetRemName(TSockAddr& anAddr); |
|
88 virtual TInt GetOption(TUint level,TUint name,TDes8& anOption)const ; |
|
89 virtual void Ioctl(TUint level,TUint name,TDes8* anOption); |
|
90 virtual void CancelIoctl(TUint aLevel,TUint aName); |
|
91 virtual TInt SAPSetOption(TUint level,TUint name,const TDesC8 &anOption); |
|
92 virtual void ActiveOpen(); |
|
93 virtual void ActiveOpen(const TDesC8& aConnectionData); |
|
94 virtual TInt PassiveOpen(TUint aQueSize); |
|
95 virtual TInt PassiveOpen(TUint aQueSize,const TDesC8& aConnectionData); |
|
96 virtual void Shutdown(TCloseType aCloseType); |
|
97 virtual void Shutdown(TCloseType aCloseType,const TDesC8& aDisconnectionData); |
|
98 virtual void AutoBind(); |
|
99 virtual void IoctlComplete(TInt aErr, TUint aLevel, TUint aName, TDesC8* aBuf=NULL); |
|
100 |
|
101 TUint Write(const TDesC8& aDesc,TUint aOptions, TSockAddr* aAddr); |
|
102 void GetData(TDes8& aDesc,TUint options,TSockAddr* anAddr=NULL); |
|
103 |
|
104 void Timeout(TBasebandTimeout aTimeout); |
|
105 |
|
106 static TInt SignalConnectComplete(TAny* aCPhysicalLink);// async callback |
|
107 |
|
108 TBool IsModeRequested(TBTLinkMode aMode) const; |
|
109 TBool IsAnyModeChangeRequested() const; |
|
110 |
|
111 TUint8 GetRequestedModes() const; |
|
112 TUint8 GetAllowedModes() const; |
|
113 TBool IsRoleSwitchAllowed() const; |
|
114 TBool RequestedActiveMode() const; |
|
115 |
|
116 void DataReceived(); |
|
117 |
|
118 void TerminatePhysicalLinksComplete(); |
|
119 |
|
120 // from MPhysicalLinkObserver |
|
121 void PhysicalLinkChange(const TBTBasebandEventNotification & aEvent, CPhysicalLink& aPhysicalLink); |
|
122 |
|
123 void Error(TInt aError); |
|
124 void Disconnect(); |
|
125 |
|
126 ~CBTProxySAP(); |
|
127 public: |
|
128 TSglQueLink iQueueLink; |
|
129 TBTDblQueLink iPLMLink; |
|
130 |
|
131 private: |
|
132 CBTProxySAP(CPhysicalLinksManager& aConnectionMan, CPhysicalLink* aPhysicalSAP); |
|
133 void ConstructL(); |
|
134 TInt CreateRawConduit(); |
|
135 void AsyncCheckLinkUp(); |
|
136 |
|
137 TInt SetModeRequested(TBTLinkMode aMode); |
|
138 void SetBasebandNotificationOptions(TUint32 aOption); |
|
139 |
|
140 void PhysicalLinkUp(); |
|
141 void PhysicalLinkDown(); |
|
142 void PhysicalLinkError(TInt aError); |
|
143 |
|
144 void ClearBasebandEventQueue(); |
|
145 TBool CanCreatePhysicalLink(); |
|
146 void ClearPhysicalLink(); |
|
147 void SetNullBasebandState(TBTBasebandEventNotification & aEvent); |
|
148 |
|
149 #ifdef HOSTCONTROLLER_TO_HOST_FLOW_CONTROL |
|
150 void TryToFreeBuffers(); |
|
151 static TInt AsyncFreeBuffers(TAny* aCACLLink); |
|
152 CAsyncCallBack* iBufferFreeCallback; |
|
153 RArray<RMBufChain> iInboundBuffer; |
|
154 TInt iInboundPacketIndex; |
|
155 TInt iInboundBuffersFreed; |
|
156 #else |
|
157 // for no flow control |
|
158 RMBufPktQ iInboundBuffer; |
|
159 #endif |
|
160 |
|
161 private: |
|
162 enum TEventNotificationStatus |
|
163 { |
|
164 EDisabled, |
|
165 EEnabledCanSend, |
|
166 EEnabledOneShot, |
|
167 EEnabledQueuing, |
|
168 }; |
|
169 |
|
170 enum TTerminateStatus |
|
171 { |
|
172 ENone, |
|
173 ETerminatingAllLinks, |
|
174 ETerminatingSingleLink, |
|
175 }; |
|
176 |
|
177 CAsyncCallBack* iAsyncCallback; |
|
178 CACLRawConduit* iRawConduit; |
|
179 TRequestedLinkPolicy iRequestedLinkPolicy; |
|
180 TBool iRawConduitReady; |
|
181 TBool iNotifiedUp; |
|
182 TTerminateStatus iTerminating; |
|
183 TUint32 iBasebandNotifyOptions; |
|
184 TSglQue<TBTQueuedBasebandEventNotification> iEventNotificationQueue; |
|
185 TEventNotificationStatus iEventNotificationStatus; |
|
186 TBool iRequestedActiveMode; |
|
187 }; |
|
188 |
|
189 |
|
190 #endif //_PROXYSAP_H_ |