71 // ----------------------------------------------------------------------------- |
60 // ----------------------------------------------------------------------------- |
72 // CCommsDatEnforcement::~CCommsDatEnforcement() |
61 // CCommsDatEnforcement::~CCommsDatEnforcement() |
73 // ----------------------------------------------------------------------------- |
62 // ----------------------------------------------------------------------------- |
74 // |
63 // |
75 CCommsDatEnforcement::~CCommsDatEnforcement() |
64 CCommsDatEnforcement::~CCommsDatEnforcement() |
76 { |
65 { |
77 RDEBUG("CCommsDatEnforcement::~CCommsDatEnforcement()"); |
66 RDEBUG("CCommsDatEnforcement::~CCommsDatEnforcement()"); |
78 |
67 |
79 if( iSession ) |
68 iCentRepServer.Close(); |
80 { |
69 iDMUtil.Close(); |
81 iSession->Close(); |
70 } |
82 delete iSession; |
|
83 } |
|
84 |
|
85 iMaskList.Close(); |
|
86 iTableList.Close(); |
|
87 iCommsDatEnforcement.Close(); |
|
88 iCentRepServer.Close(); |
|
89 iDMUtil.Close(); |
|
90 } |
|
91 |
71 |
92 |
72 |
93 // ----------------------------------------------------------------------------- |
73 // ----------------------------------------------------------------------------- |
94 // CCommsDatEnforcement::ConstructL() |
74 // CCommsDatEnforcement::ConstructL() |
95 // ----------------------------------------------------------------------------- |
75 // ----------------------------------------------------------------------------- |
96 // |
76 // |
97 void CCommsDatEnforcement::ConstructL() |
77 void CCommsDatEnforcement::ConstructL() |
98 { |
78 { |
99 RDEBUG("CCommsDatEnforcement::ConstructL()"); |
79 RDEBUG("CCommsDatEnforcement::ConstructL()"); |
100 //no implementation needed |
80 //no implementation needed |
101 iSession = CMDBSession::NewL( CMDBSession::LatestVersion() ); |
81 } |
102 } |
|
103 |
82 |
104 // ----------------------------------------------------------------------------- |
83 // ----------------------------------------------------------------------------- |
105 // CCommsDatEnforcement::NewL() |
84 // CCommsDatEnforcement::NewL() |
106 // ----------------------------------------------------------------------------- |
85 // ----------------------------------------------------------------------------- |
107 // |
86 // |
108 CCommsDatEnforcement* CCommsDatEnforcement::NewL( const TDesC8& aEnforcementId ) |
87 CCommsDatEnforcement* CCommsDatEnforcement::NewL(const TDesC8& aEnforcementId) |
109 { |
88 { |
110 RDEBUG("CCommsDatEnforcement::NewL()"); |
89 RDEBUG("CCommsDatEnforcement::NewL()"); |
111 CCommsDatEnforcement* self = 0; |
90 CCommsDatEnforcement* self = 0; |
112 |
91 |
113 if( aEnforcementId == PolicyLanguage::Constants::EAPEnforcementPolicy ) |
92 |
114 { |
93 if (aEnforcementId == PolicyLanguage::Constants::EAPEnforcementPolicy) |
115 RDEBUG(" -> EAPEnforcementPolicy"); |
94 { |
|
95 RDEBUG(" -> EAPEnforcementPolicy"); |
116 self = new ( ELeave ) CCommsDatEnforcement(); |
96 self = new ( ELeave ) CCommsDatEnforcement(); |
117 self->ConstructL(); |
97 self->ConstructL(); |
118 CleanupStack::PushL( self ); |
98 self->iSettingType = EAPEnforcement; |
119 self->iMaskList.AppendL( KCDTIdWAPAccessPointRecord ); |
99 } |
120 self->iTableList.AppendL( TPtrC(KCDTypeNameWAPAccessPoint )); |
100 |
121 self->iMaskList.AppendL( KCDTIdWAPSMSBearerRecord ); |
101 else if (aEnforcementId |
122 self->iTableList.AppendL( TPtrC(KCDTypeNameWAPSMSBearer) ); |
102 == PolicyLanguage::Constants::EWLANEnforcementPolicy) |
123 self->iMaskList.AppendL( KCDTIdWAPIPBearerRecord ); |
103 { |
124 self->iTableList.AppendL( TPtrC(KCDTypeNameWAPIPBearer) ); |
104 RDEBUG(" -> EWLANEnforcementPolicy"); |
125 self->iMaskList.AppendL( KCDTIdIAPRecord ); |
|
126 self->iTableList.AppendL( TPtrC(KCDTypeNameIAP) ); |
|
127 self->iSettingType = EAPEnforcement; |
|
128 CleanupStack::Pop( self ); |
|
129 } |
|
130 else if( aEnforcementId == PolicyLanguage::Constants::EWLANEnforcementPolicy ) |
|
131 { |
|
132 RDEBUG(" -> EWLANEnforcementPolicy"); |
|
133 self = new ( ELeave ) CCommsDatEnforcement(); |
105 self = new ( ELeave ) CCommsDatEnforcement(); |
134 self->ConstructL(); |
106 self->ConstructL(); |
135 CleanupStack::PushL( self ); |
107 self->iSettingType = EWLANEnforcement; |
136 self->iMaskList.AppendL( KWLANServiceExtRecord ); |
108 } |
137 self->iTableList.AppendL( KWLANServiceExtTable ); |
|
138 |
|
139 TUint32 wlanServiceTableId = self->GetRecordIdL( KWLANServiceTable ); |
|
140 self->iMaskList.AppendL( wlanServiceTableId ); |
|
141 self->iTableList.AppendL( KWLANServiceTable ); |
|
142 |
|
143 TUint32 wlanDeviceTableId = self->GetRecordIdL( KWLANDeviceTable ); |
|
144 self->iMaskList.AppendL( wlanDeviceTableId ); |
|
145 self->iTableList.AppendL( KWLANDeviceTable ); |
|
146 |
|
147 TUint32 wlanSSIDTableId = self->GetRecordIdL( KWLANSecondarySSID ); |
|
148 self->iMaskList.AppendL( wlanSSIDTableId ); |
|
149 self->iTableList.AppendL( KWLANSecondarySSID ); |
|
150 |
|
151 TUint32 wlanDestinationNetworkTableId = self->GetRecordIdL( KDestinationNetwork ); |
|
152 self->iMaskList.AppendL( wlanDestinationNetworkTableId ); |
|
153 self->iTableList.AppendL( KDestinationNetwork ); |
|
154 |
|
155 self->iSettingType = EWLANEnforcement; |
|
156 CleanupStack::Pop( self ); |
|
157 } |
|
158 |
109 |
159 return self; |
110 return self; |
160 } |
111 } |
161 |
112 |
162 |
113 |
163 // ----------------------------------------------------------------------------- |
114 // ----------------------------------------------------------------------------- |
164 // CCommsDatEnforcement::ValidEnforcementElement() |
115 // CCommsDatEnforcement::ValidEnforcementElement() |
165 // ----------------------------------------------------------------------------- |
116 // ----------------------------------------------------------------------------- |
166 // |
117 // |
167 TBool CCommsDatEnforcement::ValidEnforcementElement( const TDesC8& aEnforcementId ) |
118 TBool CCommsDatEnforcement::ValidEnforcementElement( |
168 { |
119 const TDesC8& aEnforcementId) |
169 RDEBUG("CCommsDatEnforcement::ValidEnforcementElement()"); |
120 { |
170 if ( aEnforcementId == PolicyLanguage::Constants::EAPEnforcementPolicy ) |
121 RDEBUG("CCommsDatEnforcement::ValidEnforcementElement()"); |
171 { |
122 if (aEnforcementId == PolicyLanguage::Constants::EAPEnforcementPolicy |
172 RDEBUG(" -> valid EAPEnforcementPolicy"); |
123 || aEnforcementId |
173 return ETrue; |
124 == PolicyLanguage::Constants::EWLANEnforcementPolicy) |
174 } |
125 { |
175 else if ( aEnforcementId == PolicyLanguage::Constants::EWLANEnforcementPolicy ) |
126 RDEBUG(" -> valid EnforcementPolicy"); |
176 { |
127 return ETrue; |
177 RDEBUG(" -> valid EWLANEnforcementPolicy"); |
128 } |
178 return ETrue; |
129 |
179 } |
130 return EFalse; |
|
131 } |
|
132 |
180 |
133 |
181 return EFalse; |
|
182 } |
|
183 |
|
184 |
|
185 // ----------------------------------------------------------------------------- |
134 // ----------------------------------------------------------------------------- |
186 // CCommsDatEnforcement::InitEnforcement() |
135 // CCommsDatEnforcement::InitEnforcement() |
187 // ----------------------------------------------------------------------------- |
136 // ----------------------------------------------------------------------------- |
188 // |
137 // |
189 void CCommsDatEnforcement::InitEnforcementL( TRequestStatus& aRequestStatus ) |
138 void CCommsDatEnforcement::InitEnforcementL(TRequestStatus& aRequestStatus) |
190 { |
139 { |
191 RDEBUG("CCommsDatEnforcement::InitEnforcementL()"); |
140 RDEBUG("CCommsDatEnforcement::InitEnforcementL()"); |
192 //set restore flag |
141 |
193 if ( iAccessControlList->Count() ) |
142 RDEBUG_2("CCommsDatEnforcement@@iInitState %d )", iInitState ); |
194 { |
143 //set restore flag |
195 iRestore = EFalse; |
144 if (iAccessControlList->Count()) |
196 } |
145 { |
197 else |
146 iRestore = EFalse; |
198 { |
147 } |
199 iRestore = ETrue; |
148 else |
200 iInitState++; |
149 { |
201 } |
150 iRestore = ETrue; |
202 |
151 iInitState++; |
203 //in first phase open connections to centreptool |
152 } |
204 if ( iInitState == 0 || iRestore ) |
153 |
205 { |
154 //in first phase open connections to centreptool |
206 RDEBUG(" -> Opening connections ... "); |
155 if (iInitState == 0 || iRestore) |
207 User::LeaveIfError( iCentRepServer.Connect() ); |
156 { |
208 User::LeaveIfError( iCommsDatEnforcement.Open( TCommsDatRepository , iCentRepServer ) ); |
157 RDEBUG(" -> Opening connections ... "); |
209 User::LeaveIfError( iDMUtil.Connect()); |
158 User::LeaveIfError(iCentRepServer.Connect()); |
210 RDEBUG(" -> Opening connections ... DONE!"); |
159 User::LeaveIfError(iDMUtil.Connect()); |
211 } |
160 RDEBUG(" -> Opening connections ... DONE!"); |
212 |
161 } |
213 //init each session in own cycle.... |
162 |
214 switch ( iInitState ) |
163 //init each session in own cycle.... |
215 { |
164 switch (iInitState) |
216 case 0: |
165 { |
217 { |
166 case 0: |
218 RDEBUG("CCommsDatEnforcement: Protect AP tables ... "); |
167 { |
219 CCommsDatabaseProtect* dbprotect = CCommsDatabaseProtect::NewL(); |
168 //Protect the destinations |
220 |
169 SetProtectionL(EProtLevel1); |
221 //add protection for GS |
170 |
222 for ( TInt i( 0 ); i < iTableList.Count(); i++ ) |
171 |
223 { |
172 //compelete request |
224 TInt err = dbprotect->ProtectTable( iTableList[ i ] ); |
173 TRequestStatus * status = &aRequestStatus; |
225 RDEBUG_2("CCommsDatEnforcement: Protection status %d", err ); |
174 User::RequestComplete(status, KErrNone); |
226 } |
175 } |
227 |
176 break; |
228 delete dbprotect; |
177 case 1: |
229 dbprotect = NULL; |
178 { |
230 |
179 RDEBUG("CCommsDatEnforcement:InitEnforcementL Case 1"); |
231 // enable all WLAN AP locks |
180 |
232 if(iSettingType == EWLANEnforcement) |
181 TRequestStatus * status = &aRequestStatus; |
233 { |
182 User::RequestComplete(status, KErrNone); |
234 LockWLANAccessPointsL( ETrue ); |
183 } |
235 } |
184 break; |
236 |
185 default: |
237 //compelete request |
186 { |
238 TRequestStatus * status = &aRequestStatus; |
187 RDEBUG("**** CCommsDatEnforcement PANIC, invalid switch-case!"); |
239 User::RequestComplete( status, KErrNone ); |
188 User::Panic(KCommsDatEnformentPanic, KErrAbort); |
240 } |
189 } |
241 break; |
190 break; |
242 case 1: |
191 } |
243 { |
192 |
244 RDEBUG("CCommsDatEnforcement: Init commsDat enforcement session"); |
193 iInitState++; |
245 iCommsDatEnforcement.InitSession( aRequestStatus ); |
194 } |
246 } |
|
247 break; |
|
248 default: |
|
249 { |
|
250 RDEBUG("**** CCommsDatEnforcement PANIC, invalid switch-case!"); |
|
251 User::Panic( KCommsDatEnformentPanic, KErrAbort ); |
|
252 } |
|
253 break; |
|
254 } |
|
255 |
|
256 iInitState++; |
|
257 } |
|
258 |
195 |
259 |
196 |
260 // ----------------------------------------------------------------------------- |
197 // ----------------------------------------------------------------------------- |
261 // CCommsDatEnforcement::InitReady() |
198 // CCommsDatEnforcement::InitReady() |
262 // ----------------------------------------------------------------------------- |
199 // ----------------------------------------------------------------------------- |
270 |
207 |
271 // ----------------------------------------------------------------------------- |
208 // ----------------------------------------------------------------------------- |
272 // CCommsDatEnforcement::InitReady() |
209 // CCommsDatEnforcement::InitReady() |
273 // ----------------------------------------------------------------------------- |
210 // ----------------------------------------------------------------------------- |
274 // |
211 // |
275 void CCommsDatEnforcement::DoEnforcementL( TRequestStatus& aRequestStatus ) |
212 void CCommsDatEnforcement::DoEnforcementL(TRequestStatus& aRequestStatus) |
276 { |
213 { |
277 RDEBUG("CCommsDatEnforcement::DoEnforcementL()"); |
214 RDEBUG("CCommsDatEnforcement::DoEnforcementL()"); |
278 if( !iRestore ) |
215 if (!iRestore) |
279 { |
216 { |
280 //if there any number subject which have exclusively right for setting, give access only for DM client |
217 CPolicyStorage::PolicyStorage()->ActivateEnforcementFlagL( |
281 for ( TInt i( 0 ); i < iMaskList.Count(); i++ ) |
218 iSettingType); |
282 { |
219 |
283 RDEBUG_3(" making enforcement: %d/%d", i, iMaskList.Count() ); |
220 //ACL... |
284 User::LeaveIfError( iCommsDatEnforcement.SetSIDWRForMask( iMaskList[ i ], KCDMaskRecordType, KDMClientUiD)); |
221 RDEBUG(" making ACL modifications for enforcement ... "); |
285 User::LeaveIfError( iCommsDatEnforcement.RemoveBackupFlagForMask( iMaskList[ i ], KCDMaskRecordType)); |
222 User::LeaveIfError(iDMUtil.SetMngSessionCertificate( |
286 CPolicyStorage::PolicyStorage()->ActivateEnforcementFlagL( iSettingType ); |
223 SessionCertificate())); |
287 } |
224 User::LeaveIfError(iDMUtil.AddACLForNode(KAPURI, EForChildrens, |
288 |
225 EACLDelete)); |
289 //ACL... |
226 User::LeaveIfError(iDMUtil.AddACLForNode(KAPURI, EForNode, EACLGet)); |
290 RDEBUG(" making ACL modifications for enforcement ... "); |
227 User::LeaveIfError(iDMUtil.SetACLForNode(KAPURI, EForNode, EACLAdd)); |
291 User::LeaveIfError( iDMUtil.SetMngSessionCertificate( SessionCertificate() ) ); |
228 RDEBUG(" making ACL modifications for enforcement ... DONE!"); |
292 User::LeaveIfError( iDMUtil.AddACLForNode( KAPURI, EForChildrens, EACLDelete ) ); |
229 } |
293 User::LeaveIfError( iDMUtil.AddACLForNode( KAPURI, EForNode, EACLGet ) ); |
230 else |
294 User::LeaveIfError( iDMUtil.SetACLForNode( KAPURI, EForNode, EACLAdd ) ); |
231 { |
295 RDEBUG(" making ACL modifications for enforcement ... DONE!"); |
232 //Unprotect the destinations |
296 } |
233 SetProtectionL(EProtLevel0); |
297 else |
234 |
298 { |
235 |
299 //Clear default settings |
236 CPolicyStorage::PolicyStorage()->DeactivateEnforcementFlagL( |
300 for ( TInt i( 0 ); i < iMaskList.Count(); i++ ) |
237 iSettingType); |
301 { |
|
302 RDEBUG_3(" clearing default settings: %d/%d", i, iMaskList.Count() ); |
|
303 User::LeaveIfError( iCommsDatEnforcement.RestoreMask( iMaskList[ i ], KCDMaskRecordType )); |
|
304 User::LeaveIfError( iCommsDatEnforcement.RestoreBackupFlagForMask( iMaskList[ i ], KCDMaskRecordType)); |
|
305 CPolicyStorage::PolicyStorage()->DeactivateEnforcementFlagL( iSettingType ); |
|
306 } |
|
307 |
238 |
308 //ACL... |
239 //ACL... |
309 RDEBUG(" removing ACL modifications for enforcement ... "); |
240 RDEBUG(" removing ACL modifications for enforcement ... "); |
310 User::LeaveIfError( iDMUtil.RemoveACL( KAPURI, ETrue ) ); |
241 User::LeaveIfError( iDMUtil.RemoveACL( KAPURI, ETrue ) ); |
311 RDEBUG(" removing ACL modifications for enforcement ... DONE!"); |
242 RDEBUG(" removing ACL modifications for enforcement ... DONE!"); |
329 |
260 |
330 // ----------------------------------------------------------------------------- |
261 // ----------------------------------------------------------------------------- |
331 // CCommsDatEnforcement::FinishEnforcementL() |
262 // CCommsDatEnforcement::FinishEnforcementL() |
332 // ----------------------------------------------------------------------------- |
263 // ----------------------------------------------------------------------------- |
333 // |
264 // |
334 void CCommsDatEnforcement::FinishEnforcementL( TBool aFlushSettings) |
265 void CCommsDatEnforcement::FinishEnforcementL(TBool aFlushSettings) |
335 { |
266 { |
336 RDEBUG("CCommsDatEnforcement::FinishEnforcementL()"); |
267 RDEBUG("CCommsDatEnforcement::FinishEnforcementL()"); |
337 //Close sessions |
268 //Close sessions |
338 if( aFlushSettings ) |
269 if (aFlushSettings) |
339 { |
270 { |
340 iCommsDatEnforcement.Flush(); |
271 iDMUtil.Flush(); |
341 iDMUtil.Flush(); |
272 } |
342 } |
273 |
343 |
274 //Close centrep server... |
344 iCommsDatEnforcement.Close(); |
275 iCentRepServer.Close(); |
345 |
276 |
346 //Close centrep server... |
277 iDMUtil.Close(); |
347 iCentRepServer.Close(); |
278 } |
348 |
279 |
349 iDMUtil.Close(); |
|
350 |
|
351 |
|
352 if( iRestore && aFlushSettings ) |
|
353 { |
|
354 RDEBUG("PolicyEngineServer: Remove AP table Protection"); |
|
355 |
|
356 CCommsDatabaseProtect* dbprotect = CCommsDatabaseProtect::NewL(); |
|
357 CleanupStack::PushL( dbprotect ); |
|
358 |
|
359 TRAP_IGNORE( LockWLANAccessPointsL( EFalse ) ); |
|
360 //remove protection for GS |
|
361 for ( TInt i( 0 ); i < iTableList.Count(); i++ ) |
|
362 { |
|
363 TInt err = dbprotect->UnProtectTable( iTableList[ i ] ); |
|
364 RDEBUG_2("PolicyEngineServer: Protection status %d", err ); |
|
365 } |
|
366 //Condition when AP + WLAN are enforced and AP is being removed |
|
367 //GS should still show lock icons for WLANs |
|
368 RDbRowSet::TAccess checkAccessType = RDbRowSet::EReadOnly ; |
|
369 TRAP_IGNORE( checkAccessType = dbprotect->GetTableAccessL(TPtrC(WLAN_SERVICE))); |
|
370 switch(checkAccessType) |
|
371 { |
|
372 case RDbRowSet::EReadOnly : |
|
373 TRAP_IGNORE(LockWLANAccessPointsL( ETrue )); |
|
374 default : break; |
|
375 } |
|
376 CleanupStack::PopAndDestroy( dbprotect ); |
|
377 } |
|
378 } |
|
379 |
|
380 // ----------------------------------------------------------------------------- |
280 // ----------------------------------------------------------------------------- |
381 // CCommsDatEnforcement::AccessRightList() |
281 // CCommsDatEnforcement::AccessRightList() |
382 // ----------------------------------------------------------------------------- |
282 // ----------------------------------------------------------------------------- |
383 // |
283 // |
384 void CCommsDatEnforcement::AccessRightList( RAccessControlList& aAccessControlList) |
284 void CCommsDatEnforcement::AccessRightList( |
385 { |
285 RAccessControlList& aAccessControlList) |
386 RDEBUG("CCommsDatEnforcement::AccessRightList()"); |
286 { |
387 iAccessControlList = &aAccessControlList; |
287 RDEBUG("CCommsDatEnforcement::AccessRightList()"); |
388 } |
288 iAccessControlList = &aAccessControlList; |
|
289 } |
389 |
290 |
390 |
291 |
391 // ----------------------------------------------------------------------------- |
292 // ----------------------------------------------------------------------------- |
392 // CCommsDatEnforcement::ResetEnforcementL() |
293 // CCommsDatEnforcement::ResetEnforcementL() |
393 // ----------------------------------------------------------------------------- |
294 // ----------------------------------------------------------------------------- |
394 // |
295 // |
395 void CCommsDatEnforcement::ResetEnforcementL() |
296 void CCommsDatEnforcement::ResetEnforcementL() |
396 { |
297 { |
397 RDEBUG("CCommsDatEnforcement::ResetEnforcementL()"); |
298 RDEBUG("CCommsDatEnforcement::ResetEnforcementL()"); |
398 |
299 |
399 User::LeaveIfError( iCentRepServer.Connect() ); |
300 User::LeaveIfError(iCentRepServer.Connect()); |
400 User::LeaveIfError( iCommsDatEnforcement.Open( TCommsDatRepository , iCentRepServer ) ); |
301 User::LeaveIfError(iDMUtil.Connect()); |
401 User::LeaveIfError( iDMUtil.Connect()); |
302 |
402 |
303 //ACL... |
403 TRequestStatus request; |
304 User::LeaveIfError(iDMUtil.RemoveACL(KAPURI, ETrue)); |
404 iCommsDatEnforcement.InitSession( request ); |
305 |
405 User::WaitForRequest( request); |
306 iCentRepServer.Close(); |
406 |
307 iDMUtil.Close(); |
407 for ( TInt i( 0 ); i < iMaskList.Count(); i++ ) |
308 } |
408 { |
309 |
409 User::LeaveIfError( iCommsDatEnforcement.RestoreMask( iMaskList[ i ], KCDMaskRecordType )); |
310 |
410 User::LeaveIfError( iCommsDatEnforcement.RestoreBackupFlagForMask( iMaskList[ i ], KCDMaskRecordType)); |
311 |
411 } |
312 // ----------------------------------------------------------------------------- |
412 |
313 // CCommsDatEnforcement::SetProtectionL() |
413 //ACL... |
314 // Sets Protection level to all the destinations |
414 User::LeaveIfError( iDMUtil.RemoveACL( KAPURI, ETrue ) ); |
315 // ----------------------------------------------------------------------------- |
415 |
316 // |
416 |
317 void CCommsDatEnforcement::SetProtectionL(TProtectionLevel aProtLevel) |
417 iCommsDatEnforcement.Flush(); |
318 { |
418 iCommsDatEnforcement.Close(); |
319 RDEBUG("CCommsDatEnforcement::SetProtectionL() Start"); |
419 iCentRepServer.Close(); |
320 |
420 iDMUtil.Close(); |
321 RCmManagerExt cmm; |
421 } |
322 cmm.OpenL(); |
422 |
323 CleanupClosePushL(cmm); |
423 |
324 |
424 // ----------------------------------------------------------------------------- |
325 RArray<TUint32> destinations; |
425 // CCommsDatEnforcement::LockWLANAccessPointsL() |
326 cmm.AllDestinationsL(destinations); |
426 // ----------------------------------------------------------------------------- |
327 CleanupClosePushL(destinations); |
427 // |
328 TInt destcount = destinations.Count(); |
428 void CCommsDatEnforcement::LockWLANAccessPointsL( TBool aLockValue ) |
329 |
429 { |
330 RCmDestinationExt destination; |
430 RDEBUG_2("CCommsDatEnforcement::LockAccessPoint( %d )", aLockValue ); |
331 |
431 |
332 //Set the Protection level for all the destinations |
432 //Get WLAN service table and get ServiceID--> which is nothing but IAP ID and lock that record |
333 for (TInt i = 0; i < destcount; i++) |
433 |
334 { |
434 //TBool ret = EFalse; |
335 TInt err = KErrNone; |
435 TUint32 apIAPID = 0; |
336 TInt retries = 1; |
436 |
337 // Retry, at the max, 10 times, if transaction fails due to KErrLocked |
437 CCommsDbTableView* checkView; |
338 // This is not an optimal solution for this problem, but, due to limitations |
438 CCommsDatabase* commsDataBase = CCommsDatabase::NewL(); |
339 // from CMManager, after a lot of Development and testing effort, below code |
439 CleanupStack::PushL( commsDataBase ); |
340 // is found out to be a working one for most of the cases |
440 checkView = commsDataBase->OpenTableLC(TPtrC(IAP)); |
341 do |
441 RDEBUG(" -> After opening IAP table "); |
342 { |
442 TBuf<KCommsDbSvrMaxFieldLength> serviceType; |
343 if (retries > 1) |
443 TInt error = checkView->GotoFirstRecord(); |
344 { |
444 RDEBUG(" -> After going to first record "); |
345 User::After( KDelayBeforeProtection); |
445 while (error == KErrNone) |
346 } |
446 { |
347 |
447 RDEBUG(" -> KERRNONE "); |
348 RDEBUG_2( |
448 // Get the ID and check for service type |
349 "CCommsDatEnforcement::SetProtectionL() DestinationL Retry No. %d", |
449 checkView->ReadTextL(TPtrC(IAP_SERVICE_TYPE), serviceType); |
350 retries); |
450 if(serviceType == TPtrC(LAN_SERVICE)) |
351 TRAP(err, destination = cmm.DestinationL(destinations[i])); |
451 { |
352 retries++; |
452 checkView->ReadUintL(TPtrC(COMMDB_ID), apIAPID); |
353 } |
453 RDEBUG_2(" ->found %d WLAN AP. being protected or unprotected", apIAPID ); |
354 while (err == KErrLocked && retries <= KMaxProtectionRetries); |
454 if(aLockValue) |
355 RDEBUG_2( |
455 { |
356 "CCommsDatEnforcement::SetProtectionL() DestinationL error is %d", |
456 ((CCommsDbProtectTableView*)checkView)->ProtectRecord(); |
357 err); |
457 RDEBUG(" -> WLAN AP protected successfully!"); |
358 |
458 } |
359 if ((err != KErrNone && err != KErrLocked) || (err == KErrLocked |
459 else |
360 && retries > KMaxProtectionRetries)) |
460 { |
361 { |
461 ((CCommsDbProtectTableView*)checkView)->UnprotectRecord(); |
362 User::Leave(err); |
462 RDEBUG(" -> WLAN AP UN protected successfully!"); |
363 } |
463 } |
364 |
464 |
365 CleanupClosePushL(destination); |
465 } |
366 |
466 error = checkView->GotoNextRecord(); |
367 RDEBUG("CCommsDatEnforcement::SetProtectionL() SetProtectionL Start"); |
467 |
368 destination.SetProtectionL(aProtLevel); |
468 } |
369 RDEBUG("CCommsDatEnforcement::SetProtectionL() SetProtectionL End"); |
469 CleanupStack::PopAndDestroy(); // checkView |
370 //Connection Methods are not getting unlocked, eventhough the destinations are unlocked |
470 |
371 // Unlocking the Connecting Methods in the destination |
471 CleanupStack::PopAndDestroy( commsDataBase ); |
372 if (aProtLevel == EProtLevel0) |
472 |
373 { |
473 |
374 SetCMProtectionL(destination, EProtLevel0); |
474 } |
375 } |
475 |
376 RDEBUG("CCommsDatEnforcement::SetProtectionL() UpdateL Start"); |
476 |
377 |
477 // ----------------------------------------------------------------------------- |
378 err = KErrNone; |
478 // CCommsDatEnforcement::GetRecordId() |
379 retries = 1; |
479 // ----------------------------------------------------------------------------- |
380 do |
480 // |
381 { |
481 TUint32 CCommsDatEnforcement::GetRecordIdL( const TDesC& aTableName ) |
382 if (retries > 1) |
482 { |
383 { |
483 RDEBUG_2("looking rentrep record id for table: %S", &aTableName ); |
384 User::After( KDelayBeforeProtection); |
484 TMDBElementId tableRecordId = 0; |
385 } |
485 CMDBGenericRecord* tempUserDefinedRecord = static_cast<CMDBGenericRecord*>(CCDRecordBase::RecordFactoryL(0)); |
386 RDEBUG_2( |
486 CleanupStack::PushL(tempUserDefinedRecord); |
387 "CCommsDatEnforcement::SetProtectionL() UpdateL Retry No. %d", |
|
388 retries); |
|
389 TRAP(err, destination.UpdateL()); |
|
390 retries++; |
|
391 } |
|
392 while (err == KErrLocked && retries <= KMaxProtectionRetries); |
|
393 RDEBUG_2( |
|
394 "CCommsDatEnforcement::SetProtectionL() UpdateL error is %d", |
|
395 err); |
|
396 |
|
397 if ((err != KErrNone && err != KErrLocked) || (err == KErrLocked |
|
398 && retries > KMaxProtectionRetries)) |
|
399 { |
|
400 User::Leave(err); |
|
401 } |
|
402 RDEBUG("CCommsDatEnforcement::SetProtectionL() UpdateL End"); |
|
403 CleanupStack::PopAndDestroy(); |
|
404 } |
|
405 |
|
406 CleanupStack::PopAndDestroy(2); |
|
407 RDEBUG("CCommsDatEnforcement::SetProtectionL() End"); |
|
408 |
|
409 } |
487 |
410 |
488 tempUserDefinedRecord->InitializeL(aTableName, NULL); |
411 |
489 tempUserDefinedRecord->LoadL(*iSession); |
412 |
490 |
413 // ----------------------------------------------------------------------------- |
491 // Get the Id that we're interested in... |
414 // CCommsDatEnforcement::SetCMProtectionL() |
492 tableRecordId = tempUserDefinedRecord->TableId(); |
415 // Sets Protection level to all the Connection Methods in the destination |
493 RDEBUG_2(" found tableRecordId: %08x", tableRecordId ); |
416 // ----------------------------------------------------------------------------- |
494 CleanupStack::PopAndDestroy(tempUserDefinedRecord); |
417 // |
495 |
418 void CCommsDatEnforcement::SetCMProtectionL(RCmDestinationExt& aDestination, |
496 // ..and validate it. |
419 TProtectionLevel aProtLevel) |
497 if ((tableRecordId & KCDMaskShowRecordType) < KCDInitialUDefRecordType) |
420 { |
498 { |
421 RDEBUG("CCommsDatEnforcement::SetCMProtectionL() Start"); |
499 RDEBUG("Error validating tableRecordId"); |
422 TInt APSNAPCount = aDestination.ConnectionMethodCount(); |
500 User::Leave(KErrNotFound); |
423 |
501 } |
424 RCmConnectionMethodExt connection; |
502 |
425 |
503 return tableRecordId; |
426 if (APSNAPCount) |
504 } |
427 { |
505 |
428 for (TInt j = 0; j < APSNAPCount; j++) |
|
429 { |
|
430 connection = aDestination.ConnectionMethodL(j); |
|
431 CleanupClosePushL(connection); |
|
432 if (aProtLevel == EProtLevel0) |
|
433 { |
|
434 connection.SetBoolAttributeL(ECmProtected, EFalse); |
|
435 } |
|
436 else if (aProtLevel == EProtLevel1 || aProtLevel == EProtLevel3) |
|
437 { |
|
438 connection.SetBoolAttributeL(ECmProtected, ETrue); |
|
439 } |
|
440 CleanupStack::PopAndDestroy(); |
|
441 } |
|
442 |
|
443 } |
|
444 RDEBUG("CCommsDatEnforcement::SetCMProtectionL() End"); |
|
445 } |
|
446 |
|
447 |