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 // etel driver factory |
|
15 // |
|
16 // |
|
17 |
|
18 /** |
|
19 @file |
|
20 @internalComponent |
|
21 */ |
|
22 |
|
23 #include <e32base.h> |
|
24 #include <etelmm.h> |
|
25 |
|
26 #include "cspudcontextelem.h" |
|
27 #include "ceteldriverfactory.h" |
|
28 #include "spudteldebuglogger.h" |
|
29 |
|
30 using namespace EtelDriver; |
|
31 |
|
32 /** |
|
33 @param aPdpFsmInterface - pdp fsm interface |
|
34 */ |
|
35 CEtelDriverFactory::CEtelDriverFactory (CPdpFsmInterface& aPdpFsmInterface) |
|
36 : iPdpFsmInterface(aPdpFsmInterface), |
|
37 iServiceChangeNotifier(iPacketService, iPdpFsmInterface) |
|
38 { |
|
39 SPUDTELVERBOSE_INFO_LOG(_L("CEtelDriverFactory::CEtelDriverFactory()")); |
|
40 } |
|
41 |
|
42 /** |
|
43 @param aPdpFsmInterface - pdp fsm interface |
|
44 */ |
|
45 CEtelDriverFactory* CEtelDriverFactory::NewL (CPdpFsmInterface& aPdpFsmInterface) |
|
46 { |
|
47 SPUDTEL_INFO_LOG(_L("CEtelDriverFactory::NewL()")); |
|
48 |
|
49 return new (ELeave) CEtelDriverFactory (aPdpFsmInterface); |
|
50 } |
|
51 |
|
52 CEtelDriverFactory::~CEtelDriverFactory() |
|
53 { |
|
54 SPUDTEL_FNLOG("CEtelDriverFactory::~CEtelDriverFactory()"); |
|
55 SPUDTEL_INFO_LOG(_L("CEtelDriverFactory::~CEtelDriverFactory()")); |
|
56 |
|
57 // cancel all notificators |
|
58 iServiceChangeNotifier.Cancel(); |
|
59 |
|
60 // cleanup array of CEtelDriverContext objs |
|
61 for (TInt i = 0; i < iContexts.Count(); i++ ) |
|
62 { |
|
63 delete iContexts[i]; |
|
64 } |
|
65 iContexts.Reset(); |
|
66 |
|
67 // common data cleanup... |
|
68 // sync operations only |
|
69 iPacketService.Close(); |
|
70 iPhone.Close(); |
|
71 |
|
72 iTelServer.UnloadPhoneModule(iPdpFsmInterface.TsyName()); |
|
73 |
|
74 iTelServer.Close(); // Phone module unloaded automatically |
|
75 |
|
76 iStrategies.Reset(); |
|
77 } |
|
78 |
|
79 /** |
|
80 Function obtains the info on the phone object implemented in the TSY |
|
81 |
|
82 Assumes aloadedTsyName has no ".TSY" appendage |
|
83 Finds the phone information for the TSY just loaded. |
|
84 Assumes just one phone in that TSY - or that every phone in it is equally useful. |
|
85 |
|
86 @param aTelServer - tel server |
|
87 @param aLoadedTsyName - name of the loaded Tsy. |
|
88 @param aInfo - information about the phone. |
|
89 */ |
|
90 static void GetPhoneInfoL(RTelServer& aTelServer, const TDesC& aLoadedTsyName, RTelServer::TPhoneInfo& aInfo) |
|
91 { |
|
92 // dev. note: leavescan reports an error in this method. |
|
93 // But there is no visible ground for it. |
|
94 SPUDTEL_FNLOG("GetPhoneInfoL()"); |
|
95 TInt count; |
|
96 User::LeaveIfError(aTelServer.EnumeratePhones(count)); |
|
97 if (count<=0) |
|
98 { |
|
99 User::Leave(KErrNotFound); |
|
100 } |
|
101 |
|
102 TBool found = EFalse; |
|
103 for (TInt i=0; i < count; i++) |
|
104 { |
|
105 TBuf<KCommsDbSvrMaxFieldLength> currentTsyName; |
|
106 User::LeaveIfError(aTelServer.GetTsyName(i,currentTsyName)); |
|
107 |
|
108 TInt r=currentTsyName.Locate('.'); |
|
109 if (r!=KErrNotFound) |
|
110 { |
|
111 currentTsyName.SetLength(r); |
|
112 } |
|
113 if (currentTsyName.CompareF(aLoadedTsyName)==KErrNone) |
|
114 { |
|
115 User::LeaveIfError(aTelServer.GetPhoneInfo(i,aInfo)); |
|
116 found = ETrue; |
|
117 break; |
|
118 } |
|
119 } |
|
120 |
|
121 if (!found) |
|
122 { |
|
123 User::Leave(KErrNotFound); |
|
124 } |
|
125 |
|
126 } |
|
127 |
|
128 /** initializes factory objects */ |
|
129 void CEtelDriverFactory::InitL() |
|
130 { |
|
131 SPUDTEL_FNLOG("CEtelDriverFactory::InitL()"); |
|
132 SPUDTEL_INFO_LOG(_L("Initializing Etel driver")); |
|
133 |
|
134 iStrategies[EOpenPhoneStrategy] = &iOpenStrategy; |
|
135 iStrategies[ESetQoSStrategy] = &iSetQoSStrategy; |
|
136 iStrategies[ESetTftStrategy] = &iSetTftStrategy; |
|
137 iStrategies[EChangeTftStrategy] = &iChangeTftStrategy; |
|
138 |
|
139 iStrategies[ECreate1ryPdpContextStrategy] = &iCreate1ryPdpContextStrategy; |
|
140 iStrategies[ECreate2ryPdpContextStrategy] = &iCreate2ryPdpContextStrategy; |
|
141 iStrategies[EActivatePdpStrategy] = &iActivatePdpStrategy; |
|
142 iStrategies[EGetNegQoSStrategy] = &iGetNegQoSStrategy; |
|
143 iStrategies[EModifyActiveStrategy] = &iModifyActivePdpStrategy; |
|
144 iStrategies[EContextDeleteStrategy] = &iContextDeleteStrategy; |
|
145 |
|
146 // initialization of operator to strategy id map |
|
147 iInputToStrategyMap[EOpenPhone] = EOpenPhoneStrategy; |
|
148 iInputToStrategyMap[ESetQoS] = ESetQoSStrategy; |
|
149 iInputToStrategyMap[ECreate1ryPdpContext] = ECreate1ryPdpContextStrategy; |
|
150 iInputToStrategyMap[ECreate2ryPdpContext] = ECreate2ryPdpContextStrategy; |
|
151 iInputToStrategyMap[ESetTft] = ESetTftStrategy; |
|
152 iInputToStrategyMap[EChangeTft] = EChangeTftStrategy; |
|
153 iInputToStrategyMap[EActivatePdp] = EActivatePdpStrategy; |
|
154 iInputToStrategyMap[ENegQoSGet] = EGetNegQoSStrategy; |
|
155 iInputToStrategyMap[EModifyActive] = EModifyActiveStrategy; |
|
156 iInputToStrategyMap[EContextDelete] = EContextDeleteStrategy; |
|
157 |
|
158 |
|
159 User::LeaveIfError (iTelServer.Connect()); |
|
160 User::LeaveIfError(iTelServer.LoadPhoneModule(iPdpFsmInterface.TsyName())); |
|
161 |
|
162 User::LeaveIfError(iTelServer.SetExtendedErrorGranularity(RTelServer::EErrorExtended)); |
|
163 |
|
164 RTelServer::TPhoneInfo phoneInfo; |
|
165 GetPhoneInfoL(iTelServer, iPdpFsmInterface.TsyName(), phoneInfo); |
|
166 User::LeaveIfError (iPhone.Open (iTelServer, phoneInfo.iName) ); |
|
167 User::LeaveIfError (iPacketService.Open (iPhone) ); |
|
168 |
|
169 // remaining async calls to phone are postponed to later async Input request |
|
170 |
|
171 iServiceChangeNotifier.Start(); |
|
172 } |
|
173 |
|
174 /** creates pdp by id |
|
175 dev. note: pdp context will NOT be opened during this call. |
|
176 |
|
177 @param aPdpId - id of a pdp context |
|
178 */ |
|
179 void CEtelDriverFactory::CreatePdpL (TContextId aPdpId) |
|
180 { |
|
181 SPUDTEL_FNLOG("CEtelDriverFactory::CreatePdpL()"); |
|
182 SPUDTELVERBOSE_INFO_LOG1(_L("pdp id : %d"), aPdpId); |
|
183 __ASSERT_ALWAYS((NULL == iContexts[aPdpId]), User::Panic(KTxtSpudTel, KErrArgument)); |
|
184 |
|
185 iContexts[aPdpId] = CSpudContextElem::NewL(aPdpId, *this, iPdpFsmInterface); |
|
186 } |
|
187 |
|
188 |
|
189 /** frees pdp context by id |
|
190 |
|
191 @param aPdpId - id of a pdp context |
|
192 */ |
|
193 void CEtelDriverFactory::FreePdp(TContextId aPdpId) |
|
194 { |
|
195 SPUDTELVERBOSE_INFO_LOG1(_L("Free pdp id : %d"), aPdpId); |
|
196 // the context has to be closed before a call to FreePdp |
|
197 __ASSERT_ALWAYS(!Context(aPdpId).PacketContext().SubSessionHandle(), User::Panic(KTxtSpudTel, KErrInUse)); |
|
198 |
|
199 delete iContexts[aPdpId]; |
|
200 iContexts[aPdpId] = NULL; |
|
201 } |
|
202 |
|
203 |
|
204 /** starts etel notifications for pdp context |
|
205 |
|
206 @param aPdpId - id of a pdp context |
|
207 */ |
|
208 void CEtelDriverFactory::StartPdpNotifications (TContextId aPdpId) |
|
209 { |
|
210 SPUDTELVERBOSE_INFO_LOG1(_L("StartPdpNotifications for pdp id : %d"), aPdpId); |
|
211 // sanity check |
|
212 ASSERT(iContexts[aPdpId]); |
|
213 |
|
214 iContexts[aPdpId]->Start(); |
|
215 } |
|
216 |
|
217 /** cancels etel notifications for aPdpId context |
|
218 |
|
219 @param aPdpId - id of a pdp context |
|
220 */ |
|
221 void CEtelDriverFactory::CancelPdpNotifications (TContextId aPdpId) |
|
222 { |
|
223 SPUDTELVERBOSE_INFO_LOG1(_L("CancelPdpNotifications for pdp id : %d"), aPdpId); |
|
224 // sanity check |
|
225 ASSERT(iContexts[aPdpId]); |
|
226 |
|
227 iContexts[aPdpId]->Cancel(); |
|
228 } |
|
229 |
|
230 /** cancels notifications for all pdp contexts */ |
|
231 void CEtelDriverFactory::CancelAllPdpNotifications() |
|
232 { |
|
233 SPUDTEL_INFO_LOG(_L("CancelAllPdpNotifications")); |
|
234 for(TContextId i = 0; i < static_cast<TContextId>(ContextCount()); i++) |
|
235 { |
|
236 CancelPdpNotifications (i); |
|
237 } |
|
238 } |
|
239 |
|
240 void CEtelDriverFactory::PdpStatusChangeNotifierCancel(TContextId aPdpId) |
|
241 { |
|
242 iContexts[aPdpId]->PdpStatusChangeNotifierCancel(); |
|
243 } |
|
244 |
|
245 void CEtelDriverFactory::QoSChangeNotifierCancel(TContextId aPdpId) |
|
246 { |
|
247 iContexts[aPdpId]->QoSChangeNotifierCancel(); |
|
248 } |
|
249 |
|
250 void CEtelDriverFactory::PdpConfigChangeNotifierCancel(TContextId aPdpId) |
|
251 { |
|
252 iContexts[aPdpId]->PdpConfigChangeNotifierCancel(); |
|
253 } |
|
254 |
|
255 TBool CEtelDriverFactory::HasContext(TContextId aId) const |
|
256 { |
|
257 return (iContexts[aId] != NULL); |
|
258 } |
|
259 |
|
260 |
|
261 /** context accessor |
|
262 |
|
263 @param aPdpId - id of a pdp context |
|
264 @return etel driver context |
|
265 */ |
|
266 CEtelDriverContext& CEtelDriverFactory::Context(TContextId aId) |
|
267 { |
|
268 // sanity check |
|
269 __ASSERT_ALWAYS(iContexts[aId], User::Panic(KTxtSpudTel, KErrBadHandle)); |
|
270 |
|
271 return *iContexts[aId]->iContext; |
|
272 } |
|
273 |
|
274 void CEtelDriverFactory::GetLastErrorCause(TContextId aPdpId, TInt& aLastErrorCause) |
|
275 { |
|
276 iContexts[aPdpId]->GetLastErrorCause(aLastErrorCause); |
|
277 } |
|