24
|
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 |
#include "PDPFSM.h"
|
|
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 |
iStrategies[ECreateMbmsPdpContextStrategy] = &iCreateMbmsPdpContextStrategy;
|
|
146 |
iStrategies[EActivateMbmsPdpStrategy] = &iActivateMbmsPdpStrategy;
|
|
147 |
iStrategies[ESessionUpdateStrategy] = &iMbmsSessionUpdateStragegy;
|
|
148 |
|
|
149 |
// initialization of operator to strategy id map
|
|
150 |
iInputToStrategyMap[EOpenPhone] = EOpenPhoneStrategy;
|
|
151 |
iInputToStrategyMap[ESetQoS] = ESetQoSStrategy;
|
|
152 |
iInputToStrategyMap[ECreate1ryPdpContext] = ECreate1ryPdpContextStrategy;
|
|
153 |
iInputToStrategyMap[ECreate2ryPdpContext] = ECreate2ryPdpContextStrategy;
|
|
154 |
iInputToStrategyMap[ESetTft] = ESetTftStrategy;
|
|
155 |
iInputToStrategyMap[EChangeTft] = EChangeTftStrategy;
|
|
156 |
iInputToStrategyMap[EActivatePdp] = EActivatePdpStrategy;
|
|
157 |
iInputToStrategyMap[ENegQoSGet] = EGetNegQoSStrategy;
|
|
158 |
iInputToStrategyMap[EModifyActive] = EModifyActiveStrategy;
|
|
159 |
iInputToStrategyMap[EContextDelete] = EContextDeleteStrategy;
|
|
160 |
iInputToStrategyMap[ECreateMbmsPdpContext] = ECreateMbmsPdpContextStrategy;
|
|
161 |
iInputToStrategyMap[EActivateMbmsPdp] = EActivateMbmsPdpStrategy;
|
|
162 |
iInputToStrategyMap[ESessionUpdate] = ESessionUpdateStrategy;
|
|
163 |
User::LeaveIfError (iTelServer.Connect());
|
|
164 |
User::LeaveIfError(iTelServer.LoadPhoneModule(iPdpFsmInterface.TsyName()));
|
|
165 |
|
|
166 |
User::LeaveIfError(iTelServer.SetExtendedErrorGranularity(RTelServer::EErrorExtended));
|
|
167 |
|
|
168 |
RTelServer::TPhoneInfo phoneInfo;
|
|
169 |
GetPhoneInfoL(iTelServer, iPdpFsmInterface.TsyName(), phoneInfo);
|
|
170 |
User::LeaveIfError (iPhone.Open (iTelServer, phoneInfo.iName) );
|
|
171 |
User::LeaveIfError (iPacketService.Open (iPhone) );
|
|
172 |
|
|
173 |
// remaining async calls to phone are postponed to later async Input request
|
|
174 |
|
|
175 |
iServiceChangeNotifier.Start();
|
|
176 |
}
|
|
177 |
|
|
178 |
/** creates pdp by id
|
|
179 |
dev. note: pdp context will NOT be opened during this call.
|
|
180 |
|
|
181 |
@param aPdpId - id of a pdp context
|
|
182 |
*/
|
|
183 |
void CEtelDriverFactory::CreatePdpL (TContextId aPdpId,SpudMan::TPdpContextType aContextType)
|
|
184 |
{
|
|
185 |
SPUDTEL_FNLOG("CEtelDriverFactory::CreatePdpL()");
|
|
186 |
SPUDTELVERBOSE_INFO_LOG1(_L("pdp id : %d"), aPdpId);
|
|
187 |
__ASSERT_ALWAYS((NULL == iContexts[aPdpId]), User::Panic(KTxtSpudTel, KErrArgument));
|
|
188 |
|
|
189 |
if (aContextType == SpudMan::EMbms)
|
|
190 |
{
|
|
191 |
iContexts[aPdpId]=CMbmsContextElem::NewL(aPdpId, *this, iPdpFsmInterface);
|
|
192 |
}
|
|
193 |
else
|
|
194 |
{
|
|
195 |
iContexts[aPdpId]=CSpudContextElem::NewL(aPdpId, *this, iPdpFsmInterface);
|
|
196 |
}
|
|
197 |
}
|
|
198 |
|
|
199 |
|
|
200 |
/** frees pdp context by id
|
|
201 |
|
|
202 |
@param aPdpId - id of a pdp context
|
|
203 |
*/
|
|
204 |
void CEtelDriverFactory::FreePdp(TContextId aPdpId)
|
|
205 |
{
|
|
206 |
|
|
207 |
SPUDTELVERBOSE_INFO_LOG1(_L("Free pdp id : %d"), aPdpId);
|
|
208 |
// In an OOM situation, this object may be cleaned up prior to establishment.
|
|
209 |
if (iContexts[aPdpId] != NULL)
|
|
210 |
{
|
|
211 |
// the context has to be closed before a call to FreePdp
|
|
212 |
__ASSERT_ALWAYS(!Context(aPdpId).PacketContext().SubSessionHandle(), User::Panic(KTxtSpudTel, KErrInUse));
|
|
213 |
delete iContexts[aPdpId];
|
|
214 |
iContexts[aPdpId] = NULL;
|
|
215 |
}
|
|
216 |
}
|
|
217 |
|
|
218 |
|
|
219 |
/** starts etel notifications for pdp context
|
|
220 |
|
|
221 |
@param aPdpId - id of a pdp context
|
|
222 |
*/
|
|
223 |
void CEtelDriverFactory::StartPdpNotifications (TContextId aPdpId)
|
|
224 |
{
|
|
225 |
SPUDTELVERBOSE_INFO_LOG1(_L("StartPdpNotifications for pdp id : %d"), aPdpId);
|
|
226 |
// sanity check
|
|
227 |
ASSERT(iContexts[aPdpId]);
|
|
228 |
|
|
229 |
iContexts[aPdpId]->Start();
|
|
230 |
}
|
|
231 |
|
|
232 |
/** cancels etel notifications for aPdpId context
|
|
233 |
|
|
234 |
@param aPdpId - id of a pdp context
|
|
235 |
*/
|
|
236 |
void CEtelDriverFactory::CancelPdpNotifications (TContextId aPdpId)
|
|
237 |
{
|
|
238 |
SPUDTELVERBOSE_INFO_LOG1(_L("CancelPdpNotifications for pdp id : %d"), aPdpId);
|
|
239 |
// sanity check
|
|
240 |
ASSERT(iContexts[aPdpId]);
|
|
241 |
|
|
242 |
iContexts[aPdpId]->Cancel();
|
|
243 |
}
|
|
244 |
|
|
245 |
/** cancels notifications for all pdp contexts */
|
|
246 |
void CEtelDriverFactory::CancelAllPdpNotifications()
|
|
247 |
{
|
|
248 |
SPUDTEL_INFO_LOG(_L("CancelAllPdpNotifications"));
|
|
249 |
for(TContextId i = 0; i < static_cast<TContextId>(ContextCount()); i++)
|
|
250 |
{
|
|
251 |
CancelPdpNotifications (i);
|
|
252 |
}
|
|
253 |
}
|
|
254 |
|
|
255 |
|
|
256 |
TBool CEtelDriverFactory::HasContext(TContextId aId) const
|
|
257 |
{
|
|
258 |
return (iContexts[aId] != NULL);
|
|
259 |
}
|
|
260 |
|
|
261 |
|
|
262 |
/** context accessor
|
|
263 |
|
|
264 |
@param aPdpId - id of a pdp context
|
|
265 |
@return etel driver context
|
|
266 |
*/
|
|
267 |
CEtelDriverContext& CEtelDriverFactory::Context(TContextId aId)
|
|
268 |
{
|
|
269 |
// sanity check
|
|
270 |
__ASSERT_ALWAYS(iContexts[aId], User::Panic(KTxtSpudTel, KErrBadHandle));
|
|
271 |
return *iContexts[aId]->iContext;
|
|
272 |
}
|