|
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 // Defines the interface to the BCA interface |
|
15 // |
|
16 // |
|
17 |
|
18 /** |
|
19 @file |
|
20 */ |
|
21 |
|
22 #ifndef BCAIOCONTROLLER_H |
|
23 #define BCAIOCONTROLLER_H |
|
24 |
|
25 #include <e32base.h> |
|
26 #include <c32comm.h> |
|
27 #include <networking/bca.h> |
|
28 #include <networking/bcafactory.h> |
|
29 |
|
30 #include "BcaController.h" |
|
31 using namespace BasebandChannelAdaptation; |
|
32 |
|
33 class CBttLogger; |
|
34 class CSender; |
|
35 class CReceiver; |
|
36 class CBcaControl; |
|
37 |
|
38 /** |
|
39 |
|
40 @internalComponent |
|
41 */ |
|
42 void Panic(TRawIPNifPanic aPanic); |
|
43 |
|
44 /** |
|
45 |
|
46 @internalComponent |
|
47 */ |
|
48 typedef MBcaFactory* (*TNewBcaFactoryL)(); |
|
49 |
|
50 |
|
51 /** |
|
52 @internalComponent |
|
53 */ |
|
54 class CBcaIoController : public CBcaController |
|
55 { |
|
56 public: |
|
57 CBcaIoController(MControllerObserver& aObserver, CBttLogger* aTheLogger); |
|
58 static CBcaIoController* NewL(MControllerObserver& aObserver, CBttLogger* aTheLogger); |
|
59 void ConstructL(); |
|
60 ~CBcaIoController(); |
|
61 |
|
62 public: |
|
63 void StartL(); |
|
64 void Stop(TInt aError = KErrNone); |
|
65 |
|
66 public: // Process Down/Up stack data packets |
|
67 void BcaProcess(TDesC8& aPdu); |
|
68 void BcaSend(RMBufChain& aPdu); |
|
69 void BcaSendComplete(); |
|
70 |
|
71 public: |
|
72 inline CSender& Sender(); |
|
73 inline CReceiver& Receiver(); |
|
74 inline TUint Nsapi(); |
|
75 void SetBcaStackAndName(const TDesC& aBcaStack, const TDesC& aBcaName); |
|
76 inline TPtrC BcaStack()const; |
|
77 inline TPtrC BcaName()const; |
|
78 inline MBca* Bca(); |
|
79 inline void SetBca(MBca* aBca); |
|
80 inline void SetPort(const TDesC& aPortName); |
|
81 inline TPtrC Port() const; |
|
82 inline void SetIapId(TUint32 aIapId); |
|
83 inline TUint32 IapId(); |
|
84 TInt BcaSendBufferLength(); |
|
85 |
|
86 private: |
|
87 void InitialiseBcaL(); |
|
88 |
|
89 private: // Flow Control |
|
90 void ResumeSending(); |
|
91 |
|
92 private: // Unowned data. |
|
93 /** Pointer to the BCA */ |
|
94 MBca* iMBca; |
|
95 |
|
96 /** used to send data*/ |
|
97 CSender* iSender; |
|
98 /** used to receive data*/ |
|
99 CReceiver* iReceiver; |
|
100 /** used to load, open and close the BCA*/ |
|
101 CBcaControl* iLoader; |
|
102 /** IAP ID used to open CommDB*/ |
|
103 TUint32 iIapId; |
|
104 /** Bca name*/ |
|
105 TPtrC iBcaName; |
|
106 /** Bca Stack*/ |
|
107 TPtrC iBcaStack; |
|
108 /** CommPort Name*/ |
|
109 TPtrC iCommPort; |
|
110 }; |
|
111 |
|
112 inline CSender& CBcaIoController::Sender() |
|
113 /** |
|
114 * Returns reference to CSender object |
|
115 * |
|
116 * @return iSender The CSender reference |
|
117 */ |
|
118 { |
|
119 return *iSender; |
|
120 } |
|
121 |
|
122 inline CReceiver& CBcaIoController::Receiver() |
|
123 /** |
|
124 * Returns reference to CReceiver object |
|
125 * |
|
126 * @return iReceiver The CReceiver reference |
|
127 */ |
|
128 { |
|
129 return *iReceiver; |
|
130 } |
|
131 |
|
132 /** returns the BCA Stack*/ |
|
133 inline TPtrC CBcaIoController::BcaStack()const |
|
134 { |
|
135 return iBcaStack; |
|
136 } |
|
137 |
|
138 /** returns the BCA name*/ |
|
139 inline TPtrC CBcaIoController::BcaName()const |
|
140 { |
|
141 return iBcaName; |
|
142 } |
|
143 |
|
144 /** retrurns the BCA pointer.*/ |
|
145 inline MBca* CBcaIoController::Bca() |
|
146 { |
|
147 return iMBca; |
|
148 } |
|
149 /** sets the BCA pointer. |
|
150 |
|
151 * @param aBca BCA pointer. |
|
152 */ |
|
153 inline void CBcaIoController::SetBca(MBca* aBca) |
|
154 { |
|
155 iMBca = aBca; |
|
156 } |
|
157 |
|
158 /** sets the IAP ID |
|
159 |
|
160 * @param aIapId IAP ID to be set. |
|
161 */ |
|
162 inline void CBcaIoController::SetIapId(TUint32 aIapId) |
|
163 { |
|
164 iIapId = aIapId; |
|
165 } |
|
166 |
|
167 /** returns the IAP ID*/ |
|
168 inline TUint32 CBcaIoController::IapId() |
|
169 { |
|
170 return iIapId; |
|
171 } |
|
172 |
|
173 /** sets the port name |
|
174 |
|
175 * @param aPortName port name to be set. |
|
176 */ |
|
177 inline void CBcaIoController::SetPort(const TDesC& aPortName) |
|
178 { |
|
179 iCommPort.Set(aPortName); |
|
180 } |
|
181 |
|
182 /** returns the port name*/ |
|
183 inline TPtrC CBcaIoController::Port()const |
|
184 { |
|
185 return iCommPort; |
|
186 } |
|
187 |
|
188 /** class used to load, open and shutdown the BCA and also start and shutdown the NIF. |
|
189 @internalComponent |
|
190 */ |
|
191 class CBcaControl : public CActive |
|
192 { |
|
193 public: |
|
194 CBcaControl(CBcaIoController& aObserver, CBttLogger* aTheLogger); |
|
195 ~CBcaControl(); |
|
196 public: |
|
197 void StartLoadL(); |
|
198 void ShutdownBca(TInt aError); |
|
199 inline MBca* Bca(); |
|
200 protected: |
|
201 // Inherited from CActive. |
|
202 virtual void RunL(); |
|
203 virtual void DoCancel(); |
|
204 private: // Unowned data. |
|
205 CBcaIoController& iObserver; |
|
206 CBttLogger* iTheLogger; |
|
207 private: |
|
208 enum TBcaState |
|
209 { |
|
210 /** Bca ready to start */ |
|
211 EIdling, |
|
212 /** Bca to be closed*/ |
|
213 EClosing, |
|
214 /** Bca IAP is set*/ |
|
215 EIAPSet, |
|
216 /** Bca stack is set*/ |
|
217 EBcaStackSet |
|
218 }; |
|
219 |
|
220 private: |
|
221 |
|
222 /** BCA owned by NIF*/ |
|
223 MBca* iMBca; |
|
224 /** used to load library*/ |
|
225 TAutoClose<RLibrary> iBcaDll; |
|
226 /** BCA state*/ |
|
227 TBcaState iState; |
|
228 /** NIF shut down error*/ |
|
229 TInt iError; |
|
230 }; |
|
231 |
|
232 /** returns the BCA pointer. */ |
|
233 inline MBca* CBcaControl::Bca() |
|
234 { |
|
235 return iMBca; |
|
236 } |
|
237 |
|
238 #endif // BCAIOCONTROLLER_H |
|
239 |