|
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 // PDP FSM factory implementation |
|
15 // |
|
16 // |
|
17 |
|
18 /** |
|
19 @file |
|
20 @internalComponent |
|
21 */ |
|
22 |
|
23 #include "cpdpfsmfactory.h" |
|
24 #include "spudfsmdebuglogger.h" |
|
25 |
|
26 // NewL |
|
27 CPdpFsmFactory* CPdpFsmFactory::NewL () |
|
28 { |
|
29 SPUDFSMVERBOSE_FNLOG("CPdpFsmFactory::NewL()"); |
|
30 |
|
31 return new (ELeave) CPdpFsmFactory (); |
|
32 } |
|
33 |
|
34 #if defined(__VC32__) |
|
35 #if (_MSC_VER >= 1200) |
|
36 #pragma warning(disable:4355) |
|
37 #endif |
|
38 #endif |
|
39 //Cpdpfsmfactory.cpp(22...) : warning C4355: 'this' : used in base member initializer list |
|
40 // these warnings are benign unless the designed usage of SpudFsm changes such that SpudFsm is used |
|
41 // as a base class to something else, in which case this code will have to change IFF the this pointer |
|
42 // passed is used in the states c'tor. Currently, the pointer is just stored. |
|
43 // In V9, e32def.h turns this warning off. |
|
44 |
|
45 CPdpFsmFactory::CPdpFsmFactory() |
|
46 : iStateInitialised (this), |
|
47 iStateOpeningPhone (this), |
|
48 iStateCreatingPrimary (this), |
|
49 iStateActivatingPrimary (this), |
|
50 iStateCreatingSecondary (this), |
|
51 iStateCreatedSecondary (this), |
|
52 iStateSettingQoS (this), |
|
53 iStateSettingTFT (this), |
|
54 iStateActivatingSecondary (this), |
|
55 iStateOpen (this), |
|
56 iStateChangingQoS (this), |
|
57 iStateChangingTFT (this), |
|
58 iStateGettingNegQoS (this), |
|
59 iStateModifyingActive (this), |
|
60 iStateSuspended (this), |
|
61 iStateClosing (this), |
|
62 iStateStopping (this), |
|
63 iStateCreatingMbms(this), |
|
64 iStateActivatingMbms(this), |
|
65 iStateCreatedMbms(this) |
|
66 { |
|
67 SPUDFSMVERBOSE_FNLOG("CPdpFsmFactory::CPdpFsmFactory()"); |
|
68 } |
|
69 |
|
70 |
|
71 CPdpFsmFactory::~CPdpFsmFactory() |
|
72 { |
|
73 SPUDFSMVERBOSE_FNLOG("CPdpFsmFactory::~CPdpFsmFactory()"); |
|
74 |
|
75 iContexts.DeleteAll(); |
|
76 iContexts.Reset(); |
|
77 |
|
78 delete iEtelDriverInput; |
|
79 } |
|
80 |
|
81 |
|
82 void CPdpFsmFactory::InitL(const TName& aTsyName, CPdpFsmInterface * aPdpFsmInterface) |
|
83 { |
|
84 SPUDFSMVERBOSE_FNLOG("CPdpFsmFactory::InitL()"); |
|
85 |
|
86 iPdpFsmInterface = aPdpFsmInterface; |
|
87 |
|
88 iTsyName = aTsyName; |
|
89 |
|
90 // lets kick off the ETelDriver first then we only alloc FSMs if it works |
|
91 // |
|
92 iEtelDriverInput = new (ELeave) REtelDriverInput; |
|
93 |
|
94 iEtelDriverInput->OpenL (*iPdpFsmInterface); |
|
95 |
|
96 // Only create PDP contexts if specifically requested. |
|
97 } |
|
98 |
|
99 |
|
100 void CPdpFsmFactory::Close (void) |
|
101 { |
|
102 SPUDFSMVERBOSE_FNLOG("CPdpFsmFactory::Close()"); |
|
103 iEtelDriverInput->Close(); |
|
104 } |
|
105 |
|
106 |
|
107 /** |
|
108 @return may return NULL if there is no PDP context with that Id |
|
109 */ |
|
110 CPdpFsm* CPdpFsmFactory::GetFsmContext (TContextId aPdpId) |
|
111 { |
|
112 SPUDFSMVERBOSE_FNLOG("CPdpFsmFactory::GetContext()"); |
|
113 |
|
114 return iContexts[aPdpId]; |
|
115 } |
|
116 |
|
117 |
|
118 const TName& CPdpFsmFactory::TsyName(void) |
|
119 { |
|
120 return iTsyName; |
|
121 } |
|
122 |
|
123 #ifndef SYMBIAN_NON_SEAMLESS_NETWORK_BEARER_MOBILITY |
|
124 TInt CPdpFsmFactory::NewFsmContext(TContextId aPdpId) |
|
125 #else |
|
126 TContextId CPdpFsmFactory::NewFsmContextL(MPdpFsmEventHandler& aPdpFsmEventHandler,SpudMan::TPdpContextType aContextType) |
|
127 #endif |
|
128 { |
|
129 SPUDFSMVERBOSE_FNLOG("CPdpFsmFactory::NewFsmContext()"); |
|
130 |
|
131 #ifndef SYMBIAN_NON_SEAMLESS_NETWORK_BEARER_MOBILITY |
|
132 TInt ret = KErrNone; |
|
133 ASSERT(ContextIdIsValid(aPdpId)); |
|
134 if (!HaveFsmContext(aPdpId)) |
|
135 { |
|
136 // Only ever called by non-leaving functions. We're going to have to trap at some point in the calling hierarchy... |
|
137 // |
|
138 TRAP(ret, |
|
139 CPdpFsm* p = CPdpFsm::NewL(aPdpId, this, iEtelDriverInput); |
|
140 iContexts[aPdpId] = p; |
|
141 ); |
|
142 } |
|
143 return ret; |
|
144 #else |
|
145 TInt i=0; |
|
146 while (i < KMaxPdpContexts && iContexts[i] != NULL) |
|
147 { |
|
148 i++; |
|
149 } |
|
150 if (i < KMaxPdpContexts) |
|
151 { |
|
152 CPdpFsm* p = CPdpFsm::NewL(i, this, iEtelDriverInput, aPdpFsmEventHandler, aContextType); |
|
153 iContexts[i] = p; |
|
154 iEtelDriverInput->CreatePdpL(i, aContextType); |
|
155 } |
|
156 return i; |
|
157 #endif |
|
158 } |
|
159 |
|
160 TInt CPdpFsmFactory::DeleteFsmContext(TContextId aPdpId) |
|
161 { |
|
162 SPUDFSMVERBOSE_FNLOG("CPdpFsmFactory::DeleteFsmContext()"); |
|
163 ASSERT(ContextIsValid(aPdpId)); |
|
164 |
|
165 delete iContexts[aPdpId]; |
|
166 iContexts[aPdpId] = NULL; |
|
167 |
|
168 return KErrNone; |
|
169 } |
|
170 |