1 /* |
|
2 * Copyright (c) 2002 Nokia Corporation and/or its subsidiary(-ies). |
|
3 * All rights reserved. |
|
4 * This component and the accompanying materials are made available |
|
5 * under the terms of "Eclipse Public License v1.0" |
|
6 * which accompanies this distribution, and is available |
|
7 * at the URL "http://www.eclipse.org/legal/epl-v10.html". |
|
8 * |
|
9 * Initial Contributors: |
|
10 * Nokia Corporation - initial contribution. |
|
11 * |
|
12 * Contributors: |
|
13 * |
|
14 * Description: Class stores data for one accesspoint |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 |
|
20 // INCLUDE FILES |
|
21 |
|
22 #include "CWPAPAccesspointItem.h" // Own header |
|
23 |
|
24 #include <CWPCharacteristic.h> |
|
25 #include <CWPParameter.h> |
|
26 #include <CWPAdapter.h> |
|
27 |
|
28 |
|
29 #include <bldvariant.hrh> |
|
30 #include <featmgr.h> // Feature manager |
|
31 #include <CWPAdapter.h> // Leave code for protected |
|
32 #include "CWPAPItemBase.h" |
|
33 #include "CWPAPNapdef.h" |
|
34 #include "WPAPAdapter.pan" |
|
35 #include "ProvisioningDebug.h" |
|
36 #include <cmconnectionmethodext.h> |
|
37 #include <cmmanagerext.h> |
|
38 #include <cmpluginpacketdatadef.h> |
|
39 #include <cmpluginwlandef.h> |
|
40 |
|
41 // ============================ MEMBER FUNCTIONS =============================== |
|
42 |
|
43 // ----------------------------------------------------------------------------- |
|
44 // CWPAPAccesspointItem::NewLC |
|
45 // ----------------------------------------------------------------------------- |
|
46 CWPAPAccesspointItem* CWPAPAccesspointItem::NewLC( |
|
47 const TDesC& aDefaultName, |
|
48 CWPAPItemBase* aLogicalProxy, |
|
49 CWPAPItemBase* aPhysicalProxy, |
|
50 CWPAPItemBase* aNapdef, |
|
51 CWPCharacteristic& aCharacteristic ) |
|
52 { |
|
53 CWPAPAccesspointItem* self = |
|
54 new(ELeave) CWPAPAccesspointItem( aDefaultName, |
|
55 aLogicalProxy, |
|
56 aPhysicalProxy, |
|
57 aNapdef, |
|
58 aCharacteristic ); |
|
59 CleanupStack::PushL( self ); |
|
60 self->ConstructL(); |
|
61 return self; |
|
62 } |
|
63 |
|
64 // ----------------------------------------------------------------------------- |
|
65 // Destructor |
|
66 // ----------------------------------------------------------------------------- |
|
67 CWPAPAccesspointItem::~CWPAPAccesspointItem() |
|
68 { |
|
69 } |
|
70 |
|
71 // ----------------------------------------------------------------------------- |
|
72 // CWPAPAccesspointItem::Name |
|
73 // ----------------------------------------------------------------------------- |
|
74 // |
|
75 const TDesC& CWPAPAccesspointItem::Name() const |
|
76 { |
|
77 if ( iLogicalProxy && iLogicalProxy->Name() != KNullDesC ) |
|
78 { |
|
79 return iLogicalProxy->Name(); |
|
80 } |
|
81 else if( iPhysicalProxy && iPhysicalProxy->Name() != KNullDesC ) |
|
82 { |
|
83 return iPhysicalProxy->Name(); |
|
84 } |
|
85 else if( iNapdef && iNapdef->Name() != KNullDesC ) |
|
86 { |
|
87 return iNapdef->Name(); |
|
88 } |
|
89 else |
|
90 { |
|
91 return iDefaultName; |
|
92 } |
|
93 } |
|
94 // ----------------------------------------------------------------------------- |
|
95 // CWPAPAccesspointItem::NapDef |
|
96 // ----------------------------------------------------------------------------- |
|
97 // |
|
98 CWPAPItemBase* CWPAPAccesspointItem::NapDef() |
|
99 { |
|
100 return iNapdef; |
|
101 } |
|
102 |
|
103 |
|
104 // ----------------------------------------------------------------------------- |
|
105 // CWPAPAccesspointItem::SetCMManager |
|
106 // ----------------------------------------------------------------------------- |
|
107 // |
|
108 void CWPAPAccesspointItem::SetCMManager( RCmManagerExt* aCm ) |
|
109 { |
|
110 iCmManager = aCm; |
|
111 } |
|
112 |
|
113 // ----------------------------------------------------------------------------- |
|
114 // CWPAPAccesspointItem::Characteristic |
|
115 // ----------------------------------------------------------------------------- |
|
116 // |
|
117 TInt CWPAPAccesspointItem::Characteristic() |
|
118 { |
|
119 return iCharacteristic.Type(); |
|
120 } |
|
121 |
|
122 |
|
123 // ----------------------------------------------------------------------------- |
|
124 // CWPAPAccesspointItem::SaveL |
|
125 // ----------------------------------------------------------------------------- |
|
126 // |
|
127 TUint32 CWPAPAccesspointItem::SaveL( CCommsDatabase& aCommsDb ) |
|
128 { |
|
129 FLOG( _L( "[AccessPointAdapter] CWPAPAccesspointItem::SaveL:" ) ); |
|
130 |
|
131 if ( FeatureManager::FeatureSupported( KFeatureIdSettingsProtection ) ) |
|
132 { |
|
133 // This protection check is no longer needed since CMManager |
|
134 // initiates the transactions to the database |
|
135 /*if( CApProtHandler::IsTableProtectedL( &aCommsDb ) ) |
|
136 { |
|
137 // Table protected -> leave with specific code. |
|
138 User::Leave( EWPAccessPointsProtected ); |
|
139 }*/ |
|
140 } |
|
141 |
|
142 TUint32 iap = 0; |
|
143 TRAPD( err,iap = StoreL( aCommsDb ) ); |
|
144 if( err == KErrLocked ) |
|
145 { |
|
146 err = EWPCommsDBLocked; |
|
147 } |
|
148 User::LeaveIfError( err ); |
|
149 return iap; |
|
150 } |
|
151 |
|
152 // ----------------------------------------------------------------------------- |
|
153 // CWPAPAccesspointItem::StoreL |
|
154 // ----------------------------------------------------------------------------- |
|
155 // |
|
156 TUint32 CWPAPAccesspointItem::StoreL( CCommsDatabase& aCommsDb ) |
|
157 { |
|
158 FLOG( _L( "[AccessPointAdapter] CWPAPAccesspointItem::StoreL:" ) ); |
|
159 |
|
160 // CMManager |
|
161 // Create the cmIten, give the bearer as parameter if it is available |
|
162 RCmConnectionMethodExt cmItem; |
|
163 TBool created = EFalse; |
|
164 TUint bearer; |
|
165 TInt err(KErrNone); |
|
166 |
|
167 // If the NapDef object exists and the bearer is defined, then we can |
|
168 // create the connection method using the bearer |
|
169 if ( iNapdef != NULL ) |
|
170 { |
|
171 bearer = static_cast<CWPAPNapdef*>(iNapdef)->Bearer(); |
|
172 if ( bearer != 0 ) |
|
173 { |
|
174 cmItem = iCmManager->CreateConnectionMethodL(bearer); |
|
175 created = ETrue; |
|
176 } |
|
177 } |
|
178 |
|
179 // If the bearer id is not known we will use packet data |
|
180 if ( !created) |
|
181 { |
|
182 cmItem = iCmManager->CreateConnectionMethodL(KUidPacketDataBearerType); |
|
183 } |
|
184 // Create the connection method into the DB |
|
185 TRAP( err,cmItem.UpdateL() ); |
|
186 // Leave if the creation fails for some reason |
|
187 if(err!=KErrNone) |
|
188 { |
|
189 User::Leave(err); |
|
190 } |
|
191 |
|
192 if( iNapdef ) |
|
193 { |
|
194 FLOG( _L( "[AccessPointAdapter] CWPAPAccesspointItem::StoreL: napdef" ) ); |
|
195 |
|
196 // CMManager |
|
197 TRAP (err, iNapdef->AddDataL( cmItem )); |
|
198 TRAP ( err,cmItem.UpdateL() ); |
|
199 // Leave if the update of the parameters fails |
|
200 if(err!=KErrNone) |
|
201 { |
|
202 User::Leave(err); |
|
203 } |
|
204 } |
|
205 |
|
206 if( iLogicalProxy ) |
|
207 { |
|
208 FLOG( _L( "[AccessPointAdapter] CWPAPAccesspointItem::StoreL: logicalproxy" ) ); |
|
209 // CMManager |
|
210 iLogicalProxy->AddDataL( cmItem ); |
|
211 TRAP( err,cmItem.UpdateL() ); |
|
212 // Leave if the update of the parameters fails |
|
213 if(err!=KErrNone) |
|
214 { |
|
215 User::Leave(err); |
|
216 } |
|
217 } |
|
218 |
|
219 if( iPhysicalProxy ) |
|
220 { |
|
221 FLOG( _L( "[AccessPointAdapter] CWPAPAccesspointItem::StoreL: physicalproxy" ) ); |
|
222 // CMManager |
|
223 iPhysicalProxy->AddDataL( cmItem ); |
|
224 TRAP( err,cmItem.UpdateL() ); |
|
225 // Leave if the update of the parameters fails |
|
226 if(err!=KErrNone) |
|
227 { |
|
228 User::Leave(err); |
|
229 } |
|
230 } |
|
231 |
|
232 FLOG( _L( "[AccessPointAdapter] CWPAPAccesspointItem::StoreL: cmItem.UpdateL" ) ); |
|
233 |
|
234 // CMManager |
|
235 iUid = cmItem.GetIntAttributeL( CMManager::ECmWapId ); |
|
236 |
|
237 TInt test( KErrNone ); |
|
238 // Update parameter data to CM |
|
239 TRAP( test,cmItem.UpdateL() ); |
|
240 FTRACE(RDebug::Print(_L("[AccessPointAdapter] CWPAPAccesspointItem::StoreL: UpdateL err: %d"), test )); |
|
241 |
|
242 TUint32 cmId = cmItem.GetIntAttributeL( CMManager::ECmId ); |
|
243 cmItem.Close(); |
|
244 |
|
245 if( iNapdef ) |
|
246 { |
|
247 iNapdef->UpdateLingerL(iUid()); |
|
248 } |
|
249 |
|
250 |
|
251 FLOG( _L( "[AccessPointAdapter] CWPAPAccesspointItem::StoreL: SaveWlanDataL" ) ); |
|
252 if( iNapdef ) |
|
253 { |
|
254 // Give CMManager pointer and save WLAN data |
|
255 static_cast<CWPAPNapdef*>(iNapdef)->SetCMManager( iCmManager ); |
|
256 iNapdef->SaveWlanDataL( cmId, aCommsDb ); |
|
257 } |
|
258 |
|
259 |
|
260 TInt i( 0 ); |
|
261 TPtrC8 data( iCharacteristic.Data(i) ); |
|
262 while( data != KNullDesC8 ) |
|
263 { |
|
264 i++; |
|
265 data.Set( iCharacteristic.Data(i) ); |
|
266 } |
|
267 |
|
268 iCharacteristic.SetDataL( iUid, i ); |
|
269 |
|
270 FLOG( _L( "[AccessPointAdapter] CWPAPAccesspointItem::StoreL: done" ) ); |
|
271 return iUid(); |
|
272 } |
|
273 |
|
274 // ----------------------------------------------------------------------------- |
|
275 // CWPAPAccesspointItem::Uid |
|
276 // ----------------------------------------------------------------------------- |
|
277 // |
|
278 const TDesC8& CWPAPAccesspointItem::Uid() const |
|
279 { |
|
280 return iUid; |
|
281 } |
|
282 |
|
283 // ----------------------------------------------------------------------------- |
|
284 // CWPAPAccesspointItem::DeleteUidData |
|
285 // ----------------------------------------------------------------------------- |
|
286 // |
|
287 void CWPAPAccesspointItem::DeleteUidData() const |
|
288 { |
|
289 iCharacteristic.DeleteAllData(); |
|
290 } |
|
291 |
|
292 // ----------------------------------------------------------------------------- |
|
293 // CWPAPAccesspointItem::CWPAPAccesspointItem |
|
294 // C++ default constructor can NOT contain any code, that |
|
295 // might leave. |
|
296 // ----------------------------------------------------------------------------- |
|
297 // |
|
298 CWPAPAccesspointItem::CWPAPAccesspointItem( const TDesC& aDefaultName, |
|
299 CWPAPItemBase* aLogicalProxy, |
|
300 CWPAPItemBase* aPhysicalProxy, |
|
301 CWPAPItemBase* aNapdef, |
|
302 CWPCharacteristic& aCharacteristic ) |
|
303 : iDefaultName( aDefaultName ), |
|
304 iNapdef( aNapdef ), |
|
305 iPhysicalProxy( aPhysicalProxy ), |
|
306 iLogicalProxy( aLogicalProxy ), |
|
307 iCharacteristic( aCharacteristic ) |
|
308 { |
|
309 } |
|
310 |
|
311 // ----------------------------------------------------------------------------- |
|
312 // CWPAPAccesspointItem::ConstructL |
|
313 // Symbian 2nd phase constructor can leave. |
|
314 // ----------------------------------------------------------------------------- |
|
315 // |
|
316 void CWPAPAccesspointItem::ConstructL() |
|
317 { |
|
318 } |
|
319 |
|
320 // End of File |
|