1 /* |
|
2 * Copyright (c) 2009-2010 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: |
|
15 * Session side object representing a destination. |
|
16 * |
|
17 */ |
|
18 |
|
19 |
|
20 #include <cmpluginbaseeng.h> |
|
21 #include <datamobilitycommsdattypes.h> |
|
22 #include <cmpluginembdestinationdef.h> |
|
23 |
|
24 #include "cmmdestinationinstance.h" |
|
25 #include "cmmsession.h" |
|
26 #include "cmmcache.h" |
|
27 #include "cmmconnmethodinstance.h" |
|
28 #include "cmmconnmethoditem.h" |
|
29 #include "cmmanagertextresolver.h" |
|
30 |
|
31 #include "OstTraceDefinitions.h" |
|
32 #ifdef OST_TRACE_COMPILER_IN_USE |
|
33 #include "cmmdestinationinstanceTraces.h" |
|
34 #endif |
|
35 |
|
36 |
|
37 // --------------------------------------------------------------------------- |
|
38 // Two phased construction. |
|
39 // --------------------------------------------------------------------------- |
|
40 // |
|
41 CCmmDestinationInstance* CCmmDestinationInstance::NewL( |
|
42 CCmmSession* aCmmSession, |
|
43 CCmmCache* aCache ) |
|
44 { |
|
45 OstTraceFunctionEntry0( CCMMDESTINATIONINSTANCE_NEWL_ENTRY ); |
|
46 |
|
47 CCmmDestinationInstance* self = CCmmDestinationInstance::NewLC( aCmmSession, aCache ); |
|
48 CleanupStack::Pop( self ); |
|
49 |
|
50 OstTraceFunctionExit0( CCMMDESTINATIONINSTANCE_NEWL_EXIT ); |
|
51 return self; |
|
52 } |
|
53 |
|
54 // --------------------------------------------------------------------------- |
|
55 // Two phased construction. |
|
56 // --------------------------------------------------------------------------- |
|
57 // |
|
58 CCmmDestinationInstance* CCmmDestinationInstance::NewLC( |
|
59 CCmmSession* aCmmSession, |
|
60 CCmmCache* aCache ) |
|
61 { |
|
62 OstTraceFunctionEntry0( CCMMDESTINATIONINSTANCE_NEWLC_ENTRY ); |
|
63 |
|
64 CCmmDestinationInstance* self = new( ELeave ) CCmmDestinationInstance( aCmmSession, aCache ); |
|
65 CleanupClosePushL( *self ); |
|
66 self->ConstructL(); |
|
67 |
|
68 OstTraceFunctionExit0( CCMMDESTINATIONINSTANCE_NEWLC_EXIT ); |
|
69 return self; |
|
70 } |
|
71 |
|
72 // --------------------------------------------------------------------------- |
|
73 // Destructor. |
|
74 // --------------------------------------------------------------------------- |
|
75 // |
|
76 CCmmDestinationInstance::~CCmmDestinationInstance() |
|
77 { |
|
78 OstTraceFunctionEntry0( CCMMDESTINATIONINSTANCE_CCMMDESTINATIONINSTANCE_ENTRY ); |
|
79 |
|
80 // Tell cache this handle is beeing closed. Cache will update it's own |
|
81 // bookkeeping accordingly. |
|
82 if ( iCache ) |
|
83 { |
|
84 iCache->CloseDestination( *this ); |
|
85 } |
|
86 delete iNetworkRecord; |
|
87 delete iDestApRecord; |
|
88 delete iMetadataRecord; |
|
89 |
|
90 iConnMethodItemArray.Close(); |
|
91 iConnMethodsToBeDeleted.Close(); |
|
92 |
|
93 OstTraceFunctionExit0( CCMMDESTINATIONINSTANCE_CCMMDESTINATIONINSTANCE_EXIT ); |
|
94 } |
|
95 |
|
96 // --------------------------------------------------------------------------- |
|
97 // Constructor. |
|
98 // --------------------------------------------------------------------------- |
|
99 // |
|
100 CCmmDestinationInstance::CCmmDestinationInstance( |
|
101 CCmmSession* aCmmSession, |
|
102 CCmmCache* aCache ) |
|
103 : |
|
104 iCmmSession( aCmmSession ), |
|
105 iCache( aCache ) |
|
106 { |
|
107 OstTraceFunctionEntry0( DUP1_CCMMDESTINATIONINSTANCE_CCMMDESTINATIONINSTANCE_ENTRY ); |
|
108 |
|
109 iNetworkRecord = NULL; |
|
110 iDestApRecord = NULL; |
|
111 iMetadataRecord = NULL; |
|
112 |
|
113 iNetworkRecordStatus = ECmmRecordStatusBlank; |
|
114 iDestApRecordStatus = ECmmRecordStatusBlank; |
|
115 iMetadataRecordStatus = ECmmRecordStatusBlank; |
|
116 |
|
117 iStatus = ECmmDestinationStatusChanged; |
|
118 iId = 0; |
|
119 iHandle = 0; |
|
120 |
|
121 iProtectionChanged = EFalse; |
|
122 iLastProtectionLevel = CMManager::EProtLevel0; |
|
123 iCurrentProtectionLevel = CMManager::EProtLevel0; |
|
124 |
|
125 OstTraceFunctionExit0( DUP1_CCMMDESTINATIONINSTANCE_CCMMDESTINATIONINSTANCE_EXIT ); |
|
126 } |
|
127 |
|
128 // --------------------------------------------------------------------------- |
|
129 // Second phase constructor. |
|
130 // --------------------------------------------------------------------------- |
|
131 // |
|
132 void CCmmDestinationInstance::ConstructL() |
|
133 { |
|
134 OstTraceFunctionEntry0( CCMMDESTINATIONINSTANCE_CONSTRUCTL_ENTRY ); |
|
135 OstTraceFunctionExit0( CCMMDESTINATIONINSTANCE_CONSTRUCTL_EXIT ); |
|
136 } |
|
137 |
|
138 // --------------------------------------------------------------------------- |
|
139 // Set the destination ID. |
|
140 // --------------------------------------------------------------------------- |
|
141 // |
|
142 void CCmmDestinationInstance::SetId( const TUint32 aId ) |
|
143 { |
|
144 OstTraceFunctionEntry0( CCMMDESTINATIONINSTANCE_SETID_ENTRY ); |
|
145 |
|
146 iId = aId; |
|
147 |
|
148 // If this is the real ID (not the temporary ID of a new unsaved destination), |
|
149 // write it also into network record. |
|
150 if ( aId > KCmmDestIdIntervalMin && aId < KCmmDestIdIntervalMax ) |
|
151 { |
|
152 iNetworkRecord->SetRecordId( aId - KCmDefaultDestinationAPTagId ); |
|
153 iDestApRecord->iRecordTag = aId; |
|
154 iDestApRecord->iCustomSelectionPolicy = ( aId - KCmDefaultDestinationAPTagId ); |
|
155 iMetadataRecord->iSNAP = aId; |
|
156 } |
|
157 |
|
158 OstTraceFunctionExit0( CCMMDESTINATIONINSTANCE_SETID_EXIT ); |
|
159 } |
|
160 |
|
161 // --------------------------------------------------------------------------- |
|
162 // Get the destination ID. |
|
163 // --------------------------------------------------------------------------- |
|
164 // |
|
165 TUint32 CCmmDestinationInstance::GetId() const |
|
166 { |
|
167 OstTraceFunctionEntry0( CCMMDESTINATIONINSTANCE_GETID_ENTRY ); |
|
168 OstTraceFunctionExit0( CCMMDESTINATIONINSTANCE_GETID_EXIT ); |
|
169 return iId; |
|
170 } |
|
171 |
|
172 // --------------------------------------------------------------------------- |
|
173 // Set the current status of this destination. |
|
174 // ECmmDestinationStatusValid: Contents in sync with database. |
|
175 // ECmmDestinationStatusChanged: Contents differ from database contents. |
|
176 // --------------------------------------------------------------------------- |
|
177 // |
|
178 void CCmmDestinationInstance::SetStatus( const TCmmDestinationStatus& aStatus ) |
|
179 { |
|
180 OstTraceFunctionEntry0( CCMMDESTINATIONINSTANCE_SETSTATUS_ENTRY ); |
|
181 |
|
182 switch ( aStatus ) |
|
183 { |
|
184 // Fallthrough intended |
|
185 case ECmmDestinationStatusValid: |
|
186 case ECmmDestinationStatusChanged: |
|
187 iStatus = aStatus; |
|
188 break; |
|
189 default: |
|
190 ASSERT(0); // Error, invalid status. |
|
191 break; |
|
192 } |
|
193 |
|
194 OstTraceFunctionExit0( CCMMDESTINATIONINSTANCE_SETSTATUS_EXIT ); |
|
195 } |
|
196 |
|
197 // --------------------------------------------------------------------------- |
|
198 // Gets the current status of this destination instance. |
|
199 // --------------------------------------------------------------------------- |
|
200 // |
|
201 TCmmDestinationStatus CCmmDestinationInstance::GetStatus() const |
|
202 { |
|
203 OstTraceFunctionEntry0( CCMMDESTINATIONINSTANCE_GETSTATUS_ENTRY ); |
|
204 OstTraceFunctionExit0( CCMMDESTINATIONINSTANCE_GETSTATUS_EXIT ); |
|
205 return iStatus; |
|
206 } |
|
207 |
|
208 // --------------------------------------------------------------------------- |
|
209 // Get handle ID. |
|
210 // --------------------------------------------------------------------------- |
|
211 // |
|
212 TInt CCmmDestinationInstance::GetHandle() const |
|
213 { |
|
214 return iHandle; |
|
215 } |
|
216 |
|
217 // --------------------------------------------------------------------------- |
|
218 // Set handle ID. |
|
219 // --------------------------------------------------------------------------- |
|
220 // |
|
221 void CCmmDestinationInstance::SetHandle( const TInt aHandle ) |
|
222 { |
|
223 iHandle = aHandle; |
|
224 } |
|
225 |
|
226 // --------------------------------------------------------------------------- |
|
227 // Set the record status for all records. |
|
228 // --------------------------------------------------------------------------- |
|
229 // |
|
230 void CCmmDestinationInstance::SetStatusForAllRecords( const TCmmRecordStatus& aStatus ) |
|
231 { |
|
232 OstTraceFunctionEntry0( CCMMDESTINATIONINSTANCE_SETSTATUSFORALLRECORDS_ENTRY ); |
|
233 |
|
234 iDestApRecordStatus = aStatus; |
|
235 iNetworkRecordStatus = aStatus; |
|
236 iMetadataRecordStatus = aStatus; |
|
237 |
|
238 OstTraceFunctionExit0( CCMMDESTINATIONINSTANCE_SETSTATUSFORALLRECORDS_EXIT ); |
|
239 } |
|
240 |
|
241 // --------------------------------------------------------------------------- |
|
242 // Get the destination element ID. |
|
243 // --------------------------------------------------------------------------- |
|
244 // |
|
245 TUint32 CCmmDestinationInstance::GetElementIdL() |
|
246 { |
|
247 OstTraceFunctionEntry0( CCMMDESTINATIONINSTANCE_GETELEMENTIDL_ENTRY ); |
|
248 |
|
249 LoadRecordIfMissingL( ECmmDestNetworkRecord ); |
|
250 |
|
251 if ( !iNetworkRecord ) |
|
252 { |
|
253 User::Leave( KErrCorrupt ); |
|
254 } |
|
255 |
|
256 OstTraceFunctionExit0( CCMMDESTINATIONINSTANCE_GETELEMENTIDL_EXIT ); |
|
257 return iNetworkRecord->ElementId() & KCDMaskShowField; |
|
258 } |
|
259 |
|
260 // --------------------------------------------------------------------------- |
|
261 // Get the destination access point record's record tag (destination ID). |
|
262 // --------------------------------------------------------------------------- |
|
263 // |
|
264 TUint32 CCmmDestinationInstance::GetRecordTagFromApRecordL() |
|
265 { |
|
266 OstTraceFunctionEntry0( CCMMDESTINATIONINSTANCE_GETRECORDTAGFROMAPRECORDL_ENTRY ); |
|
267 |
|
268 LoadRecordIfMissingL( ECmmDestApRecord ); |
|
269 |
|
270 if ( !iDestApRecord ) |
|
271 { |
|
272 User::Leave( KErrCorrupt ); |
|
273 } |
|
274 |
|
275 OstTraceFunctionExit0( CCMMDESTINATIONINSTANCE_GETRECORDTAGFROMAPRECORDL_EXIT ); |
|
276 return iDestApRecord->iRecordTag; |
|
277 } |
|
278 |
|
279 // --------------------------------------------------------------------------- |
|
280 // Sets a record pointer to the one given as parameter, Ownership is |
|
281 // transfered. Also deletes the previous pointer and sets the record status |
|
282 // to 'ECmmRecordStatusLoaded'. |
|
283 // --------------------------------------------------------------------------- |
|
284 // |
|
285 TInt CCmmDestinationInstance::SetRecordPointer( |
|
286 const TCmmDbRecords& aDestRecord, |
|
287 CommsDat::CCDRecordBase* aRecordPointer ) |
|
288 { |
|
289 OstTraceFunctionEntry0( CCMMDESTINATIONINSTANCE_SETRECORDPOINTER_ENTRY ); |
|
290 |
|
291 TInt ret( KErrNone ); |
|
292 switch ( aDestRecord ) |
|
293 { |
|
294 case ECmmDestNetworkRecord: |
|
295 { |
|
296 delete iNetworkRecord; |
|
297 iNetworkRecord = static_cast<CommsDat::CCDNetworkRecord*>( aRecordPointer ); |
|
298 iNetworkRecordStatus = ECmmRecordStatusLoaded; |
|
299 } |
|
300 break; |
|
301 case ECmmDestApRecord: |
|
302 { |
|
303 delete iDestApRecord; |
|
304 iDestApRecord = static_cast<CommsDat::CCDAccessPointRecord*>( aRecordPointer ); |
|
305 iDestApRecordStatus = ECmmRecordStatusLoaded; |
|
306 } |
|
307 break; |
|
308 case ECmmDestMetadataRecord: |
|
309 { |
|
310 delete iMetadataRecord; |
|
311 iMetadataRecord = static_cast<CCDSNAPMetadataRecord*>( aRecordPointer ); |
|
312 iMetadataRecordStatus = ECmmRecordStatusLoaded; |
|
313 } |
|
314 break; |
|
315 default: |
|
316 { |
|
317 ret = KErrNotFound; |
|
318 } |
|
319 break; |
|
320 } |
|
321 |
|
322 OstTraceFunctionExit0( CCMMDESTINATIONINSTANCE_SETRECORDPOINTER_EXIT ); |
|
323 return ret; |
|
324 } |
|
325 |
|
326 // --------------------------------------------------------------------------- |
|
327 // Gets a reference to the requested record pointer. |
|
328 // --------------------------------------------------------------------------- |
|
329 // |
|
330 TInt CCmmDestinationInstance::GetRecordPointer( |
|
331 const TCmmDbRecords& aDestRecord, |
|
332 CommsDat::CCDRecordBase*& aRecordPointer ) |
|
333 { |
|
334 OstTraceFunctionEntry0( CCMMDESTINATIONINSTANCE_GETRECORDPOINTER_ENTRY ); |
|
335 |
|
336 TInt ret( KErrNone ); |
|
337 aRecordPointer = NULL; |
|
338 switch ( aDestRecord ) |
|
339 { |
|
340 case ECmmDestNetworkRecord: |
|
341 { |
|
342 aRecordPointer = static_cast<CommsDat::CCDRecordBase*>( iNetworkRecord ); |
|
343 } |
|
344 break; |
|
345 case ECmmDestApRecord: |
|
346 { |
|
347 aRecordPointer = static_cast<CommsDat::CCDRecordBase*>( iDestApRecord ); |
|
348 } |
|
349 break; |
|
350 case ECmmDestMetadataRecord: |
|
351 { |
|
352 aRecordPointer = static_cast<CommsDat::CCDRecordBase*>( iMetadataRecord ); |
|
353 } |
|
354 break; |
|
355 default: |
|
356 { |
|
357 ASSERT( 0 ); |
|
358 ret = KErrNotFound; |
|
359 } |
|
360 break; |
|
361 } |
|
362 |
|
363 OstTraceFunctionExit0( CCMMDESTINATIONINSTANCE_GETRECORDPOINTER_EXIT ); |
|
364 return ret; |
|
365 } |
|
366 |
|
367 // --------------------------------------------------------------------------- |
|
368 // Save the contents of this destination into database. All connection methods |
|
369 // including embedded destination, that the client has open handles to, are |
|
370 // also updated. |
|
371 // --------------------------------------------------------------------------- |
|
372 // |
|
373 void CCmmDestinationInstance::UpdateL() |
|
374 { |
|
375 OstTraceFunctionEntry0( CCMMDESTINATIONINSTANCE_UPDATEL_ENTRY ); |
|
376 |
|
377 if ( AllMandatoryRecordsContainData() ) |
|
378 { |
|
379 // Check for metadata conflicts. |
|
380 if ( ConflictingMetadataFoundL() ) |
|
381 { |
|
382 OstTraceFunctionExit0( CCMMDESTINATIONINSTANCE_UPDATEL_EXIT ); |
|
383 |
|
384 User::Leave( KErrAlreadyExists ); |
|
385 } |
|
386 |
|
387 // Check that the destination name is still valid and not in use already. |
|
388 if ( iCache->DestinationExistsWithNameL( iNetworkRecord->iRecordName.GetL(), iId ) ) |
|
389 { |
|
390 OstTraceFunctionExit0( DUP1_CCMMDESTINATIONINSTANCE_UPDATEL_EXIT ); |
|
391 |
|
392 User::Leave( KErrAlreadyExists ); |
|
393 } |
|
394 |
|
395 iCache->UpdateDestinationL( *this ); |
|
396 } |
|
397 else |
|
398 { |
|
399 User::Leave( KErrCorrupt ); |
|
400 } |
|
401 |
|
402 OstTraceFunctionExit0( DUP2_CCMMDESTINATIONINSTANCE_UPDATEL_EXIT ); |
|
403 } |
|
404 |
|
405 // --------------------------------------------------------------------------- |
|
406 // Get the destination name. |
|
407 // --------------------------------------------------------------------------- |
|
408 // |
|
409 TDesC& CCmmDestinationInstance::GetDestinationNameL() |
|
410 { |
|
411 OstTraceFunctionEntry0( CCMMDESTINATIONINSTANCE_GETDESTINATIONNAMEL_ENTRY ); |
|
412 |
|
413 LoadRecordIfMissingL( ECmmDestNetworkRecord ); |
|
414 |
|
415 if ( !iNetworkRecord ) |
|
416 { |
|
417 OstTraceFunctionExit0( CCMMDESTINATIONINSTANCE_GETDESTINATIONNAMEL_EXIT ); |
|
418 |
|
419 User::Leave( KErrCorrupt ); |
|
420 } |
|
421 |
|
422 OstTraceFunctionExit0( DUP1_CCMMDESTINATIONINSTANCE_GETDESTINATIONNAMEL_EXIT ); |
|
423 return iNetworkRecord->iRecordName.GetL(); |
|
424 } |
|
425 |
|
426 // --------------------------------------------------------------------------- |
|
427 // Get the localised destination name. |
|
428 // --------------------------------------------------------------------------- |
|
429 // |
|
430 HBufC* CCmmDestinationInstance::GetLocalisedDestinationNameL() |
|
431 { |
|
432 OstTraceFunctionEntry0( CCMMDESTINATIONINSTANCE_GETLOCALISEDDESTINATIONNAMEL_ENTRY ); |
|
433 |
|
434 LoadRecordIfMissingL( ECmmDestNetworkRecord ); |
|
435 |
|
436 if ( !iNetworkRecord ) |
|
437 { |
|
438 User::Leave( KErrCorrupt ); |
|
439 } |
|
440 |
|
441 TUint32 purpose( 0 ); |
|
442 GetMetadataL( CMManager::ESnapMetadataPurpose, purpose ); |
|
443 HBufC* resolvedText( NULL ); |
|
444 TBool isLocalised( EFalse ); |
|
445 switch ( purpose ) |
|
446 { |
|
447 case CMManager::ESnapPurposeInternet: |
|
448 { |
|
449 _LIT( KDestinationTextId, "txt_occ_dblist_internet"); |
|
450 resolvedText = CCmManagerTextResolver::ResolveTextL( KDestinationTextId ); |
|
451 isLocalised = ETrue; |
|
452 } |
|
453 break; |
|
454 case CMManager::ESnapPurposeOperator: |
|
455 { |
|
456 _LIT( KDestinationTextId, "txt_occ_dblist_operator_services"); |
|
457 resolvedText = CCmManagerTextResolver::ResolveTextL( KDestinationTextId ); |
|
458 isLocalised = ETrue; |
|
459 } |
|
460 break; |
|
461 case CMManager::ESnapPurposeIntranet: |
|
462 { |
|
463 _LIT( KDestinationTextId, "txt_occ_dblist_intranet"); |
|
464 resolvedText = CCmManagerTextResolver::ResolveTextL( KDestinationTextId ); |
|
465 isLocalised = ETrue; |
|
466 } |
|
467 break; |
|
468 default: |
|
469 break; |
|
470 } |
|
471 |
|
472 // Not Internet, operator or intranet, or something went wrong. |
|
473 if ( !isLocalised || ( isLocalised && !resolvedText ) ) |
|
474 { |
|
475 resolvedText = TPtrC( iNetworkRecord->iRecordName ).AllocL(); |
|
476 } |
|
477 |
|
478 OstTraceFunctionExit0( CCMMDESTINATIONINSTANCE_GETLOCALISEDDESTINATIONNAMEL_EXIT ); |
|
479 return resolvedText; |
|
480 } |
|
481 |
|
482 // --------------------------------------------------------------------------- |
|
483 // Set the destination name. |
|
484 // --------------------------------------------------------------------------- |
|
485 // |
|
486 void CCmmDestinationInstance::SetDestinationNameL( const TDesC& aDestinationName ) |
|
487 { |
|
488 OstTraceFunctionEntry0( CCMMDESTINATIONINSTANCE_SETDESTINATIONNAMEL_ENTRY ); |
|
489 |
|
490 // Write action, load all records. |
|
491 LoadAllRecordsL(); |
|
492 |
|
493 iNetworkRecord->iRecordName.SetL( aDestinationName ); |
|
494 iDestApRecord->iRecordName.SetL( aDestinationName ); |
|
495 |
|
496 iNetworkRecordStatus = ECmmRecordStatusModified; |
|
497 iDestApRecordStatus = ECmmRecordStatusModified; |
|
498 iStatus = ECmmDestinationStatusChanged; |
|
499 |
|
500 OstTraceFunctionExit0( CCMMDESTINATIONINSTANCE_SETDESTINATIONNAMEL_EXIT ); |
|
501 } |
|
502 |
|
503 // --------------------------------------------------------------------------- |
|
504 // Get the destination icon. |
|
505 // --------------------------------------------------------------------------- |
|
506 // |
|
507 HBufC* CCmmDestinationInstance::GetDestinationIconL() |
|
508 { |
|
509 OstTraceFunctionEntry0( CCMMDESTINATIONINSTANCE_GETDESTINATIONICONL_ENTRY ); |
|
510 |
|
511 LoadRecordIfMissingL( ECmmDestMetadataRecord ); |
|
512 |
|
513 if ( !iMetadataRecord ) |
|
514 { |
|
515 User::Leave( KErrCorrupt ); |
|
516 } |
|
517 |
|
518 HBufC* icon( NULL ); |
|
519 icon = TPtrC( iMetadataRecord->iIconFileName ).AllocL(); |
|
520 |
|
521 OstTraceFunctionExit0( CCMMDESTINATIONINSTANCE_GETDESTINATIONICONL_EXIT ); |
|
522 return icon; |
|
523 } |
|
524 |
|
525 // --------------------------------------------------------------------------- |
|
526 // Set the destination icon. |
|
527 // --------------------------------------------------------------------------- |
|
528 // |
|
529 void CCmmDestinationInstance::SetDestinationIconL( const TDesC& aDestinationIcon ) |
|
530 { |
|
531 OstTraceFunctionEntry0( CCMMDESTINATIONINSTANCE_SETDESTINATIONICONL_ENTRY ); |
|
532 |
|
533 // Write action, load all records. |
|
534 LoadAllRecordsL(); |
|
535 |
|
536 iMetadataRecord->iIconFileName.SetL( aDestinationIcon ); |
|
537 |
|
538 iMetadataRecordStatus = ECmmRecordStatusModified; |
|
539 iStatus = ECmmDestinationStatusChanged; |
|
540 |
|
541 OstTraceFunctionExit0( CCMMDESTINATIONINSTANCE_SETDESTINATIONICONL_EXIT ); |
|
542 } |
|
543 |
|
544 // --------------------------------------------------------------------------- |
|
545 // Get metadata of specified type. |
|
546 // --------------------------------------------------------------------------- |
|
547 // |
|
548 void CCmmDestinationInstance::GetMetadataL( |
|
549 const CMManager::TSnapMetadataField& aMetadataField, |
|
550 TUint32& aMetadata ) |
|
551 { |
|
552 OstTraceFunctionEntry0( CCMMDESTINATIONINSTANCE_GETMETADATAL_ENTRY ); |
|
553 |
|
554 LoadRecordIfMissingL( ECmmDestMetadataRecord ); |
|
555 |
|
556 if ( !iMetadataRecord ) |
|
557 { |
|
558 User::Leave( KErrCorrupt ); |
|
559 } |
|
560 |
|
561 switch ( aMetadataField ) |
|
562 { |
|
563 case CMManager::ESnapMetadataInternet: |
|
564 aMetadata = ( TUint32 )( iMetadataRecord->iMetadata ) & |
|
565 CMManager::ESnapMetadataInternet; |
|
566 break; |
|
567 case CMManager::ESnapMetadataHighlight: |
|
568 aMetadata = ( TUint32 )( iMetadataRecord->iMetadata ) & |
|
569 CMManager::ESnapMetadataHighlight; |
|
570 break; |
|
571 case CMManager::ESnapMetadataHiddenAgent: |
|
572 aMetadata = ( TUint32 )( iMetadataRecord->iMetadata ) & |
|
573 CMManager::ESnapMetadataHiddenAgent; |
|
574 break; |
|
575 case CMManager::ESnapMetadataDestinationIsLocalised: |
|
576 aMetadata = ( ( TUint32 )( iMetadataRecord->iMetadata ) & |
|
577 CMManager::ESnapMetadataDestinationIsLocalised ) >> 4; |
|
578 break; |
|
579 case CMManager::ESnapMetadataPurpose: |
|
580 aMetadata = ( ( TUint32 )( iMetadataRecord->iMetadata ) & |
|
581 CMManager::ESnapMetadataPurpose ) >> 8; |
|
582 break; |
|
583 default: |
|
584 User::Leave( KErrArgument ); |
|
585 break; |
|
586 } |
|
587 |
|
588 OstTraceFunctionExit0( CCMMDESTINATIONINSTANCE_GETMETADATAL_EXIT ); |
|
589 } |
|
590 |
|
591 // --------------------------------------------------------------------------- |
|
592 // Set metadata of specified type. |
|
593 // --------------------------------------------------------------------------- |
|
594 // |
|
595 void CCmmDestinationInstance::SetMetadataL( |
|
596 const CMManager::TSnapMetadataField& aMetadataField, |
|
597 const TUint32 aMetadata ) |
|
598 { |
|
599 OstTraceFunctionEntry0( CCMMDESTINATIONINSTANCE_SETMETADATAL_ENTRY ); |
|
600 |
|
601 // Write action, load all records. |
|
602 LoadAllRecordsL(); |
|
603 |
|
604 switch ( aMetadataField ) |
|
605 { |
|
606 case CMManager::ESnapMetadataInternet: |
|
607 SetMetadataInternetL( aMetadata ); |
|
608 break; |
|
609 case CMManager::ESnapMetadataHighlight: |
|
610 SetMetadataHighlight( aMetadata ); |
|
611 break; |
|
612 case CMManager::ESnapMetadataHiddenAgent: |
|
613 SetMetadataHiddenAgentL( aMetadata ); |
|
614 break; |
|
615 case CMManager::ESnapMetadataDestinationIsLocalised: |
|
616 SetMetadataLocalizationL( aMetadata ); |
|
617 break; |
|
618 case CMManager::ESnapMetadataPurpose: |
|
619 SetMetadataPurposeL( aMetadata ); |
|
620 break; |
|
621 default: |
|
622 User::Leave( KErrArgument ); |
|
623 break; |
|
624 } |
|
625 |
|
626 iMetadataRecordStatus = ECmmRecordStatusModified; |
|
627 iStatus = ECmmDestinationStatusChanged; |
|
628 |
|
629 OstTraceFunctionExit0( CCMMDESTINATIONINSTANCE_SETMETADATAL_EXIT ); |
|
630 } |
|
631 |
|
632 // --------------------------------------------------------------------------- |
|
633 // Get destination protection level. |
|
634 // --------------------------------------------------------------------------- |
|
635 // |
|
636 void CCmmDestinationInstance::GetProtectionL( CMManager::TProtectionLevel& aProtectionLevel ) |
|
637 { |
|
638 OstTraceFunctionEntry0( CCMMDESTINATIONINSTANCE_GETPROTECTIONL_ENTRY ); |
|
639 |
|
640 LoadRecordIfMissingL( ECmmDestMetadataRecord ); |
|
641 |
|
642 if ( !iMetadataRecord ) |
|
643 { |
|
644 User::Leave( KErrCorrupt ); |
|
645 } |
|
646 |
|
647 TUint32 value = ( ( TUint32 )( iMetadataRecord->iMetadata ) & |
|
648 KDestProtectionLevelMask ) >> KBitsToShiftDestProtectionLevel; |
|
649 switch ( value ) |
|
650 { |
|
651 case CMManager::EProtLevel0: |
|
652 aProtectionLevel = CMManager::EProtLevel0; |
|
653 break; |
|
654 case CMManager::EProtLevel1: |
|
655 aProtectionLevel = CMManager::EProtLevel1; |
|
656 break; |
|
657 case CMManager::EProtLevel2: |
|
658 aProtectionLevel = CMManager::EProtLevel2; |
|
659 break; |
|
660 case CMManager::EProtLevel3: |
|
661 aProtectionLevel = CMManager::EProtLevel3; |
|
662 break; |
|
663 default: |
|
664 User::Leave( KErrCorrupt ); |
|
665 break; |
|
666 } |
|
667 |
|
668 OstTraceFunctionExit0( CCMMDESTINATIONINSTANCE_GETPROTECTIONL_EXIT ); |
|
669 } |
|
670 |
|
671 // --------------------------------------------------------------------------- |
|
672 // Set destination protection level. |
|
673 // --------------------------------------------------------------------------- |
|
674 // |
|
675 void CCmmDestinationInstance::SetProtectionL( |
|
676 CMManager::TProtectionLevel aProtectionLevel ) |
|
677 { |
|
678 OstTraceFunctionEntry0( CCMMDESTINATIONINSTANCE_SETPROTECTIONL_ENTRY ); |
|
679 |
|
680 // Write action, load all records. |
|
681 LoadAllRecordsL(); |
|
682 |
|
683 // Protection level is saved to CommsDat during update-call, so we need to |
|
684 // keep track of both the original value and the currently set new value. |
|
685 iCurrentProtectionLevel = aProtectionLevel; |
|
686 if ( !iProtectionChanged ) |
|
687 { |
|
688 GetProtectionL( iLastProtectionLevel ); |
|
689 } |
|
690 if ( aProtectionLevel == iLastProtectionLevel ) |
|
691 { |
|
692 iProtectionChanged = EFalse; |
|
693 } |
|
694 else |
|
695 { |
|
696 iProtectionChanged = ETrue; |
|
697 } |
|
698 |
|
699 // Read current metadata without protection bits. |
|
700 TUint32 currentMetadata = |
|
701 ( ( TUint32 )( iMetadataRecord->iMetadata ) & ( ~KDestProtectionLevelMask ) ); |
|
702 // Add new protection bits. |
|
703 iMetadataRecord->iMetadata = |
|
704 currentMetadata | ( aProtectionLevel << KBitsToShiftDestProtectionLevel ); |
|
705 |
|
706 iMetadataRecordStatus = ECmmRecordStatusModified; |
|
707 iStatus = ECmmDestinationStatusChanged; |
|
708 |
|
709 OstTraceFunctionExit0( CCMMDESTINATIONINSTANCE_SETPROTECTIONL_EXIT ); |
|
710 } |
|
711 |
|
712 // --------------------------------------------------------------------------- |
|
713 // Return true if protection level has been changed. |
|
714 // --------------------------------------------------------------------------- |
|
715 // |
|
716 TBool CCmmDestinationInstance::ProtectionChanged() |
|
717 { |
|
718 return iProtectionChanged; |
|
719 } |
|
720 |
|
721 // --------------------------------------------------------------------------- |
|
722 // Return the previous valid protection level of this connection method |
|
723 // instance. |
|
724 // --------------------------------------------------------------------------- |
|
725 // |
|
726 CMManager::TProtectionLevel CCmmDestinationInstance::LastProtectionLevel() |
|
727 { |
|
728 return iLastProtectionLevel; |
|
729 } |
|
730 |
|
731 // --------------------------------------------------------------------------- |
|
732 // Return the protection level currently set into this destination instance. |
|
733 // --------------------------------------------------------------------------- |
|
734 // |
|
735 CMManager::TProtectionLevel CCmmDestinationInstance::CurrentProtectionLevelL() |
|
736 { |
|
737 OstTraceFunctionEntry0( CCMMDESTINATIONINSTANCE_CURRENTPROTECTIONLEVELL_ENTRY ); |
|
738 |
|
739 CMManager::TProtectionLevel protLevel( iCurrentProtectionLevel ); |
|
740 if ( !iProtectionChanged ) |
|
741 { |
|
742 GetProtectionL( protLevel ); |
|
743 } |
|
744 |
|
745 OstTraceFunctionExit0( CCMMDESTINATIONINSTANCE_CURRENTPROTECTIONLEVELL_EXIT ); |
|
746 return protLevel; |
|
747 } |
|
748 |
|
749 // --------------------------------------------------------------------------- |
|
750 // Adds a connection method into this destination. Returns the index (priority) |
|
751 // in the connection method array where the connection method was added. |
|
752 // Embedded destinations can not be added with this method, use |
|
753 // AddEmbeddedDestinationL() instead. |
|
754 // --------------------------------------------------------------------------- |
|
755 // |
|
756 TInt CCmmDestinationInstance::AddConnMethodL( |
|
757 CCmmConnMethodInstance& aConnMethodInstance ) |
|
758 { |
|
759 OstTraceFunctionEntry0( CCMMDESTINATIONINSTANCE_ADDCONNMETHODL_ENTRY ); |
|
760 |
|
761 TUint32 connMethodId( aConnMethodInstance.GetId() ); |
|
762 |
|
763 // Check that the connection method is not an embedded destination. |
|
764 if ( aConnMethodInstance.IsEmbeddedDestination() ) |
|
765 { |
|
766 User::Leave( KErrArgument ); |
|
767 } |
|
768 |
|
769 // Check that the connection method is not already inside this destination. |
|
770 for ( TInt i = 0; i < iConnMethodItemArray.Count(); i++ ) |
|
771 { |
|
772 if ( connMethodId == iConnMethodItemArray[i].iId ) |
|
773 { |
|
774 User::Leave( KErrAlreadyExists ); |
|
775 } |
|
776 } |
|
777 |
|
778 // Remove the connection method from delete list, if found there. |
|
779 for ( TInt i = 0; i < iConnMethodsToBeDeleted.Count(); i++ ) |
|
780 { |
|
781 if ( connMethodId == iConnMethodsToBeDeleted[i] ) |
|
782 { |
|
783 iConnMethodsToBeDeleted.Remove( i ); |
|
784 break; |
|
785 } |
|
786 } |
|
787 |
|
788 // Get the priority value of this connection method according to bearer. |
|
789 TUint32 bearerType( aConnMethodInstance.GetBearerType() ); |
|
790 TUint bearerPriority( 0 ); |
|
791 iCache->BearerPriorityFromIapRecordL( |
|
792 ( CommsDat::CCDIAPRecord* )aConnMethodInstance.GetPluginDataInstance() |
|
793 ->iGenRecordArray[KIapRecordIndex], |
|
794 bearerPriority ); |
|
795 TCmmConnMethodItem item( connMethodId, bearerType, bearerPriority, 0 ); |
|
796 |
|
797 // Find out the correct position for the connection method inside this |
|
798 // destination. |
|
799 |
|
800 // If the destination contains 1 or more connection methods of the same |
|
801 // bearer type, position the new connection method after the last of these |
|
802 // connection methods. |
|
803 // If not, position the connection method before the first connection |
|
804 // method found that has an equal or greater bearer based priority. |
|
805 |
|
806 // The relevant connection method item count is the number of connection |
|
807 // methods excluding a possible embedded destination. |
|
808 TInt relevantCount = iConnMethodItemArray.Count(); |
|
809 if ( relevantCount > 0 && iConnMethodItemArray[ relevantCount - 1 ].IsEmbedded() ) |
|
810 { |
|
811 relevantCount--; |
|
812 } |
|
813 // The final position will be between 0 and relevantCount. |
|
814 TInt index( relevantCount ); |
|
815 |
|
816 TBool positionFound( EFalse ); |
|
817 TBool connMethodIsVirtual = aConnMethodInstance.GetBoolAttributeL( CMManager::ECmVirtual ); |
|
818 if ( connMethodIsVirtual ) |
|
819 { |
|
820 // Ask link information only if this is a virtual IAP. |
|
821 TUint32 linkedIapId = aConnMethodInstance.GetIntAttributeL( CMManager::ECmNextLayerIapId ); |
|
822 if ( linkedIapId == 0 ) |
|
823 { |
|
824 // If this is a virtual IAP that doesn't point to an IAP, position it at |
|
825 // the end of the list. |
|
826 item.iPriority = CMManager::KDataMobilitySelectionPolicyPriorityWildCard; |
|
827 index = relevantCount; |
|
828 positionFound = ETrue; |
|
829 } |
|
830 else |
|
831 { |
|
832 // If this is a virtual IAP that links to another IAP, position it |
|
833 // as if it was that IAP. |
|
834 TCmmConnMethodItem linkedItem; |
|
835 TInt err = iCache->GetConnMethodItem( linkedIapId, linkedItem ); |
|
836 if ( err ) |
|
837 { |
|
838 User::Leave( KErrArgument ); |
|
839 } |
|
840 if ( linkedItem.IsVirtual() ) |
|
841 { |
|
842 // This is a virtual IAP linking to another virtual IAP. |
|
843 index = relevantCount; |
|
844 positionFound = ETrue; |
|
845 } |
|
846 bearerType = linkedItem.iBearerType; |
|
847 bearerPriority = linkedItem.iBearerPriority; |
|
848 } |
|
849 } |
|
850 |
|
851 if ( !positionFound ) |
|
852 { |
|
853 // Search for any connection methods with the same bearer type. |
|
854 for ( TInt i = 0; i < relevantCount; i++ ) |
|
855 { |
|
856 if ( iConnMethodItemArray[i].iBearerType == bearerType ) |
|
857 { |
|
858 index = i + 1; |
|
859 positionFound = ETrue; |
|
860 // Don't break, need find last item. |
|
861 } |
|
862 } |
|
863 } |
|
864 if ( !positionFound ) |
|
865 { |
|
866 // No connection method found with the same bearer type. Position |
|
867 // the connection method according to bearer priority. |
|
868 for ( TInt i = 0; i < relevantCount; i++ ) |
|
869 { |
|
870 if ( iConnMethodItemArray[i].iBearerPriority >= bearerPriority ) |
|
871 { |
|
872 index = i; |
|
873 break; |
|
874 } |
|
875 } |
|
876 } |
|
877 |
|
878 // Add the connection method item into this destination at the correct |
|
879 // position (priority). |
|
880 iConnMethodItemArray.InsertL( item, index ); |
|
881 |
|
882 SetStatus( ECmmDestinationStatusChanged ); |
|
883 |
|
884 OstTraceFunctionExit0( CCMMDESTINATIONINSTANCE_ADDCONNMETHODL_EXIT ); |
|
885 return index; |
|
886 } |
|
887 |
|
888 // --------------------------------------------------------------------------- |
|
889 // Adds an embedded destination into this destination. Returns the index in |
|
890 // the connection method array where the connection method was added. |
|
891 // --------------------------------------------------------------------------- |
|
892 // |
|
893 TInt CCmmDestinationInstance::AddEmbeddedDestinationL( |
|
894 const CCmmDestinationInstance& aEmbeddedDestinationInstance ) |
|
895 { |
|
896 OstTraceFunctionEntry0( CCMMDESTINATIONINSTANCE_ADDEMBEDDEDDESTINATIONL_ENTRY ); |
|
897 |
|
898 TUint32 embeddedDestinationId( aEmbeddedDestinationInstance.GetId() ); |
|
899 |
|
900 // Check that not adding itself. |
|
901 if ( embeddedDestinationId == iId ) |
|
902 { |
|
903 User::Leave( KErrArgument ); |
|
904 } |
|
905 |
|
906 // Check that the embedded destination is not already an embedded |
|
907 // destination in this destination. |
|
908 if ( HasEmbeddedWithId( embeddedDestinationId ) ) |
|
909 { |
|
910 User::Leave( KErrAlreadyExists ); |
|
911 } |
|
912 |
|
913 // A destination can not be added into a destination that is itself an |
|
914 // embedded destination. |
|
915 if ( iCache->DestinationIsEmbedded( iId ) ) |
|
916 { |
|
917 User::Leave( KErrNotSupported ); |
|
918 } |
|
919 |
|
920 // A destination can not be added into a destination that already has an |
|
921 // embedded destination. |
|
922 if ( HasEmbedded() || iCache->DestinationHasEmbedded( iId ) ) |
|
923 { |
|
924 User::Leave( KErrNotSupported ); |
|
925 } |
|
926 |
|
927 // A destination that already has an embedded destination can not be added |
|
928 // into a destination. |
|
929 if ( aEmbeddedDestinationInstance.HasEmbedded() || |
|
930 iCache->DestinationHasEmbedded( embeddedDestinationId ) ) |
|
931 { |
|
932 User::Leave( KErrNotSupported ); |
|
933 } |
|
934 |
|
935 // Check session side destination instances for all clients. |
|
936 // - Check that any destination instance does not contain aDestinationId as |
|
937 // embedded destination. |
|
938 // - Check that any destination instance for aEmbeddedDestinationId does |
|
939 // not contain an embedded destination. |
|
940 if ( iCmmSession->EmbeddedDestinationConflictsFromAllSessions( iId, embeddedDestinationId ) ) |
|
941 { |
|
942 User::Leave( KErrAlreadyExists ); |
|
943 } |
|
944 |
|
945 // Add the embedded destination at the end of the connection method item array. |
|
946 TInt index = iConnMethodItemArray.Count(); |
|
947 TCmmConnMethodItem item( |
|
948 embeddedDestinationId, |
|
949 KUidEmbeddedDestination, |
|
950 CMManager::KDataMobilitySelectionPolicyPriorityWildCard, |
|
951 CMManager::KDataMobilitySelectionPolicyPriorityWildCard ); |
|
952 iConnMethodItemArray.AppendL( item ); |
|
953 |
|
954 SetStatus( ECmmDestinationStatusChanged ); |
|
955 |
|
956 OstTraceFunctionExit0( CCMMDESTINATIONINSTANCE_ADDEMBEDDEDDESTINATIONL_EXIT ); |
|
957 return index; |
|
958 } |
|
959 |
|
960 // --------------------------------------------------------------------------- |
|
961 // Delete a connection method that belongs to this destination. If the |
|
962 // connection method belongs to any other destination, it is only removed from |
|
963 // this destination and not deleted. Does not call update. |
|
964 // --------------------------------------------------------------------------- |
|
965 // |
|
966 void CCmmDestinationInstance::DeleteConnMethodFromDestinationL( |
|
967 const CCmmConnMethodInstance& aConnMethodInstance ) |
|
968 { |
|
969 OstTraceFunctionEntry0( CCMMDESTINATIONINSTANCE_DELETECONNMETHODFROMDESTINATIONL_ENTRY ); |
|
970 |
|
971 // Check that the connection method is inside this destination. |
|
972 TUint32 connMethodId( aConnMethodInstance.GetId() ); |
|
973 TInt index( KErrNotFound ); |
|
974 for ( TInt i = 0; i < iConnMethodItemArray.Count(); i++ ) |
|
975 { |
|
976 if ( connMethodId == iConnMethodItemArray[i].iId ) |
|
977 { |
|
978 index = i; |
|
979 break; |
|
980 } |
|
981 } |
|
982 if ( index < 0 ) |
|
983 { |
|
984 User::Leave( KErrArgument ); |
|
985 } |
|
986 |
|
987 // Check if the connection method removal is blocked by any virtual IAPs. |
|
988 if ( ConnMethodInDestinationButLocked( connMethodId ) ) |
|
989 { |
|
990 User::Leave( KErrLocked ); |
|
991 } |
|
992 |
|
993 // Check if any virtual IAP points to this connection method, thus blocking |
|
994 // the delete. |
|
995 if ( iCache->ConnMethodPointedToByVirtualIap( connMethodId ) ) |
|
996 { |
|
997 User::Leave( KErrLocked ); |
|
998 } |
|
999 |
|
1000 // Check that the connection method is not in use by an active connection. |
|
1001 if ( iCache->CheckIfCmConnected( connMethodId ) ) |
|
1002 { |
|
1003 User::Leave( KErrInUse ); |
|
1004 } |
|
1005 |
|
1006 // This will also remove an embedded destination. |
|
1007 iConnMethodItemArray.Remove( index ); |
|
1008 SetStatus( ECmmDestinationStatusChanged ); |
|
1009 |
|
1010 // If this connection method is an embedded destination, then removing it |
|
1011 // from this destination is enough. The destination is not deleted. |
|
1012 if ( !aConnMethodInstance.IsEmbeddedDestination() ) |
|
1013 { |
|
1014 // Add connection method to delete list only if not referenced from any |
|
1015 // other destination (in database or in any destination handles for the |
|
1016 // client currently beeing served). |
|
1017 if ( !iCache->ConnMethodInOtherDestination( connMethodId, iId ) && |
|
1018 !iCmmSession->ConnMethodInOtherDestination( connMethodId, iId ) ) |
|
1019 { |
|
1020 if ( iConnMethodsToBeDeleted.Find( connMethodId ) == KErrNotFound ) |
|
1021 { |
|
1022 iConnMethodsToBeDeleted.AppendL( connMethodId ); |
|
1023 } |
|
1024 } |
|
1025 } |
|
1026 |
|
1027 OstTraceFunctionExit0( CCMMDESTINATIONINSTANCE_DELETECONNMETHODFROMDESTINATIONL_EXIT ); |
|
1028 } |
|
1029 |
|
1030 // --------------------------------------------------------------------------- |
|
1031 // Remove a connection method from this destination. If the second attribute |
|
1032 // aTestIfConnected is false, the test to check if connection method is in use |
|
1033 // is skipped. In this case this should have been already tested by the caller. |
|
1034 // --------------------------------------------------------------------------- |
|
1035 // |
|
1036 void CCmmDestinationInstance::RemoveConnMethodFromDestinationL( |
|
1037 const CCmmConnMethodInstance& aConnMethodInstance, |
|
1038 const TBool aTestIfConnected ) |
|
1039 { |
|
1040 OstTraceFunctionEntry0( CCMMDESTINATIONINSTANCE_REMOVECONNMETHODFROMDESTINATIONL_ENTRY ); |
|
1041 |
|
1042 // Check that the connection method is inside this destination. |
|
1043 TUint32 connMethodId( aConnMethodInstance.GetId() ); |
|
1044 TInt index( KErrNotFound ); |
|
1045 for ( TInt i = 0; i < iConnMethodItemArray.Count(); i++ ) |
|
1046 { |
|
1047 if ( connMethodId == iConnMethodItemArray[i].iId ) |
|
1048 { |
|
1049 index = i; |
|
1050 break; |
|
1051 } |
|
1052 } |
|
1053 if ( index < 0 ) |
|
1054 { |
|
1055 User::Leave( KErrArgument ); |
|
1056 } |
|
1057 |
|
1058 // Check if the connection method removal is blocked by any virtual IAPs. |
|
1059 if ( ConnMethodInDestinationButLocked( connMethodId ) ) |
|
1060 { |
|
1061 User::Leave( KErrLocked ); |
|
1062 } |
|
1063 |
|
1064 if ( aTestIfConnected ) |
|
1065 { |
|
1066 // Check that the connection method is not in use by an active connection. |
|
1067 if ( iCache->CheckIfCmConnected( connMethodId ) ) |
|
1068 { |
|
1069 User::Leave( KErrInUse ); |
|
1070 } |
|
1071 } |
|
1072 |
|
1073 // This will also remove an embedded destination. |
|
1074 iConnMethodItemArray.Remove( index ); |
|
1075 SetStatus( ECmmDestinationStatusChanged ); |
|
1076 |
|
1077 OstTraceFunctionExit0( CCMMDESTINATIONINSTANCE_REMOVECONNMETHODFROMDESTINATIONL_EXIT ); |
|
1078 } |
|
1079 |
|
1080 // --------------------------------------------------------------------------- |
|
1081 // Modifies the priority of a connection method inside this destination. |
|
1082 // --------------------------------------------------------------------------- |
|
1083 // |
|
1084 void CCmmDestinationInstance::ModifyConnMethodPriorityL( |
|
1085 CCmmConnMethodInstance& aConnMethodInstance, |
|
1086 TUint aIndex ) |
|
1087 { |
|
1088 OstTraceFunctionEntry0( CCMMDESTINATIONINSTANCE_MODIFYCONNMETHODPRIORITYL_ENTRY ); |
|
1089 |
|
1090 // Check index range. |
|
1091 if ( aIndex >= iConnMethodItemArray.Count() ) |
|
1092 { |
|
1093 User::Leave( KErrArgument ); |
|
1094 } |
|
1095 |
|
1096 // Check if the connection method is in this destination. Also store the |
|
1097 // current index of the connection method. |
|
1098 TInt oldIndex( KErrNotFound ); |
|
1099 for ( TInt i = 0; i < iConnMethodItemArray.Count(); i++ ) |
|
1100 { |
|
1101 if ( iConnMethodItemArray[i].iId == aConnMethodInstance.GetId() ) |
|
1102 { |
|
1103 oldIndex = i; |
|
1104 break; |
|
1105 } |
|
1106 } |
|
1107 if ( oldIndex == KErrNotFound ) |
|
1108 { |
|
1109 User::Leave( KErrArgument ); |
|
1110 } |
|
1111 |
|
1112 // If connection method is an embedded destination, just return silently. |
|
1113 if ( aConnMethodInstance.IsEmbeddedDestination() ) |
|
1114 { |
|
1115 OstTraceFunctionExit0( CCMMDESTINATIONINSTANCE_MODIFYCONNMETHODPRIORITYL_EXIT ); |
|
1116 return; |
|
1117 } |
|
1118 |
|
1119 // If connection method is a virtual IAP linking to a destination, just return silently. |
|
1120 if ( aConnMethodInstance.GetBoolAttributeL( CMManager::ECmVirtual ) && |
|
1121 aConnMethodInstance.GetIntAttributeL( CMManager::ECmNextLayerIapId ) == 0 ) |
|
1122 { |
|
1123 OstTraceFunctionExit0( DUP1_CCMMDESTINATIONINSTANCE_MODIFYCONNMETHODPRIORITYL_EXIT ); |
|
1124 return; |
|
1125 } |
|
1126 |
|
1127 // If the given index points to any wildcard priority connection method, |
|
1128 // adjust it so it points to the last priority position. |
|
1129 TUint numberOfConnMethodsWithPriority( NumberOfConnMethodsWithPriority() ); |
|
1130 if ( aIndex >= numberOfConnMethodsWithPriority ) |
|
1131 { |
|
1132 if ( numberOfConnMethodsWithPriority == 0 ) |
|
1133 { |
|
1134 // Can't be 0, since aConnMethodInstance is not a wildcard IAP and |
|
1135 // is in the array. |
|
1136 ASSERT( 0 ); |
|
1137 User::Leave( KErrCorrupt ); |
|
1138 } |
|
1139 aIndex = numberOfConnMethodsWithPriority - 1; |
|
1140 } |
|
1141 |
|
1142 // Check if the priority is changing from current. |
|
1143 if ( oldIndex == aIndex ) |
|
1144 { |
|
1145 OstTraceFunctionExit0( DUP2_CCMMDESTINATIONINSTANCE_MODIFYCONNMETHODPRIORITYL_EXIT ); |
|
1146 return; |
|
1147 } |
|
1148 |
|
1149 // Change the location of the connection method to reflect the new priority. |
|
1150 TCmmConnMethodItem item = iConnMethodItemArray[oldIndex]; |
|
1151 iConnMethodItemArray.Remove( oldIndex ); |
|
1152 iConnMethodItemArray.InsertL( item, ( TInt )aIndex ); |
|
1153 |
|
1154 SetStatus( ECmmDestinationStatusChanged ); |
|
1155 |
|
1156 OstTraceFunctionExit0( DUP3_CCMMDESTINATIONINSTANCE_MODIFYCONNMETHODPRIORITYL_EXIT ); |
|
1157 } |
|
1158 |
|
1159 // --------------------------------------------------------------------------- |
|
1160 // Finds a connection method instance that belongs to the same session and |
|
1161 // matches the provided ID. Return NULL if no match is found. |
|
1162 // --------------------------------------------------------------------------- |
|
1163 // |
|
1164 CCmmConnMethodInstance* CCmmDestinationInstance::FindConnMethodInstanceFromSessionById( |
|
1165 const TUint32 aConnMethodId ) const |
|
1166 { |
|
1167 OstTraceFunctionEntry0( CCMMDESTINATIONINSTANCE_FINDCONNMETHODINSTANCEFROMSESSIONBYID_ENTRY ); |
|
1168 |
|
1169 CCmmConnMethodInstance* connMethodInstance = iCmmSession-> |
|
1170 FindConnMethodInstanceById( aConnMethodId ); |
|
1171 |
|
1172 OstTraceFunctionEntry0( CCMMDESTINATIONINSTANCE_FINDCONNMETHODINSTANCEFROMSESSIONBYID_EXIT ); |
|
1173 return connMethodInstance; |
|
1174 } |
|
1175 |
|
1176 // --------------------------------------------------------------------------- |
|
1177 // Finds a destination instance that belongs to the same session and matches |
|
1178 // the provided ID. Return NULL if no match is found. |
|
1179 // --------------------------------------------------------------------------- |
|
1180 // |
|
1181 CCmmDestinationInstance* CCmmDestinationInstance::FindDestinationInstanceFromSessionById( |
|
1182 const TUint32 aDestinationId ) const |
|
1183 { |
|
1184 OstTraceFunctionEntry0( CCMMDESTINATIONINSTANCE_FINDDESTINATIONINSTANCEFROMSESSIONBYID_ENTRY ); |
|
1185 |
|
1186 CCmmDestinationInstance* destInstance = |
|
1187 iCmmSession->FindDestinationInstanceById( aDestinationId ); |
|
1188 |
|
1189 OstTraceFunctionExit0( CCMMDESTINATIONINSTANCE_FINDDESTINATIONINSTANCEFROMSESSIONBYID_EXIT ); |
|
1190 return destInstance; |
|
1191 } |
|
1192 |
|
1193 // --------------------------------------------------------------------------- |
|
1194 // Check from all open destination handles in the same session if the given |
|
1195 // connection method is inside any of them. The given destination is skipped. |
|
1196 // --------------------------------------------------------------------------- |
|
1197 // |
|
1198 TBool CCmmDestinationInstance::ConnMethodInOtherDestinationInSession( |
|
1199 const TUint32 aConnMethodId, |
|
1200 const TUint32 aDestinationId ) const |
|
1201 { |
|
1202 OstTraceFunctionEntry0( CCMMDESTINATIONINSTANCE_CONNMETHODINOTHERDESTINATIONINSESSION_ENTRY ); |
|
1203 |
|
1204 TBool inOtherSession = iCmmSession-> |
|
1205 ConnMethodInOtherDestination( aConnMethodId, aDestinationId ); |
|
1206 |
|
1207 OstTraceFunctionExit0( CCMMDESTINATIONINSTANCE_CONNMETHODINOTHERDESTINATIONINSESSION_EXIT ); |
|
1208 return inOtherSession; |
|
1209 } |
|
1210 |
|
1211 // --------------------------------------------------------------------------- |
|
1212 // Check if the given connection method is in this destination. Include |
|
1213 // embedded destinations. |
|
1214 // --------------------------------------------------------------------------- |
|
1215 // |
|
1216 TBool CCmmDestinationInstance::ValidConnMethodIdInDestinationIncludeEmbedded( |
|
1217 const TUint32 aConnMethodId ) const |
|
1218 { |
|
1219 OstTraceFunctionEntry0( CCMMDESTINATIONINSTANCE_VALIDCONNMETHODIDINDESTINATIONINCLUDEEMBEDDED_ENTRY ); |
|
1220 |
|
1221 TBool validity( EFalse ); |
|
1222 if ( aConnMethodId > 0 ) |
|
1223 { |
|
1224 for ( TInt i = 0; i < iConnMethodItemArray.Count(); i++ ) |
|
1225 { |
|
1226 if ( iConnMethodItemArray[i].iId == aConnMethodId ) |
|
1227 { |
|
1228 validity = ETrue; |
|
1229 break; |
|
1230 } |
|
1231 } |
|
1232 } |
|
1233 |
|
1234 OstTraceFunctionExit0( CCMMDESTINATIONINSTANCE_VALIDCONNMETHODIDINDESTINATIONINCLUDEEMBEDDED_EXIT ); |
|
1235 return validity; |
|
1236 } |
|
1237 |
|
1238 // --------------------------------------------------------------------------- |
|
1239 // Check if the given connection method is inside this destination and if it |
|
1240 // is in a 'locked' status. A locked connection method can't be deleted nor |
|
1241 // removed from the destination. A connection method becomes locked if it is |
|
1242 // the only remaining connection method in a destination and a virtual IAP |
|
1243 // points into that destination. |
|
1244 // --------------------------------------------------------------------------- |
|
1245 // |
|
1246 TBool CCmmDestinationInstance::ConnMethodInDestinationButLocked( |
|
1247 const TUint32 aConnMethodId ) const |
|
1248 { |
|
1249 OstTraceFunctionEntry0( CCMMDESTINATIONINSTANCE_CONNMETHODINDESTINATIONBUTLOCKED_ENTRY ); |
|
1250 |
|
1251 TBool result( EFalse ); |
|
1252 if ( iConnMethodItemArray.Count() == 1 ) |
|
1253 { |
|
1254 if ( iConnMethodItemArray[0].iId == aConnMethodId ) |
|
1255 { |
|
1256 if ( iCache->DestinationPointedToByVirtualIap( iId ) ) |
|
1257 { |
|
1258 result = ETrue; |
|
1259 } |
|
1260 } |
|
1261 } |
|
1262 |
|
1263 OstTraceFunctionExit0( CCMMDESTINATIONINSTANCE_CONNMETHODINDESTINATIONBUTLOCKED_EXIT ); |
|
1264 return result; |
|
1265 } |
|
1266 |
|
1267 // --------------------------------------------------------------------------- |
|
1268 // Counts how many connection methods that require priority information are |
|
1269 // currently in this destination. This excludes any virtual IAPs that point to |
|
1270 // a destination or any embedded destinations from the count. Assumes the |
|
1271 // connection method array is in order so all wildcard priority IAPs are at the |
|
1272 // end of the list. |
|
1273 // --------------------------------------------------------------------------- |
|
1274 // |
|
1275 TUint CCmmDestinationInstance::NumberOfConnMethodsWithPriority() const |
|
1276 { |
|
1277 OstTraceFunctionEntry0( CCMMDESTINATIONINSTANCE_NUMBEROFCONNMETHODSWITHPRIORITY_ENTRY ); |
|
1278 |
|
1279 TUint count( iConnMethodItemArray.Count() ); |
|
1280 |
|
1281 for ( TUint i = 0; i < iConnMethodItemArray.Count(); i++ ) |
|
1282 { |
|
1283 if ( iConnMethodItemArray[i].IsEmbedded() || iConnMethodItemArray[i].iPriority == |
|
1284 CMManager::KDataMobilitySelectionPolicyPriorityWildCard ) |
|
1285 { |
|
1286 count--; |
|
1287 } |
|
1288 } |
|
1289 |
|
1290 OstTraceFunctionExit0( CCMMDESTINATIONINSTANCE_NUMBEROFCONNMETHODSWITHPRIORITY_EXIT ); |
|
1291 return count; |
|
1292 } |
|
1293 |
|
1294 // --------------------------------------------------------------------------- |
|
1295 // Check if this destination has an embedded destination. Checks the current |
|
1296 // (possibly unsaved) status of this destination handle, not the current status |
|
1297 // in database. |
|
1298 // --------------------------------------------------------------------------- |
|
1299 // |
|
1300 TBool CCmmDestinationInstance::HasEmbedded() const |
|
1301 { |
|
1302 OstTraceFunctionEntry0( CCMMDESTINATIONINSTANCE_HASEMBEDDED_ENTRY ); |
|
1303 |
|
1304 TBool result( EFalse ); |
|
1305 |
|
1306 // If there is an embedded destination, it will be at the very last |
|
1307 // position in the connection method item array. |
|
1308 TInt index = iConnMethodItemArray.Count() - 1; |
|
1309 if ( index >= 0 ) |
|
1310 { |
|
1311 if ( iConnMethodItemArray[index].IsEmbedded() ) |
|
1312 { |
|
1313 result = ETrue; |
|
1314 } |
|
1315 } |
|
1316 |
|
1317 OstTraceFunctionExit0( CCMMDESTINATIONINSTANCE_HASEMBEDDED_EXIT ); |
|
1318 return result; |
|
1319 } |
|
1320 |
|
1321 // --------------------------------------------------------------------------- |
|
1322 // Check if this destination has an embedded destination with the specified ID. |
|
1323 // Checks the current (possibly unsaved) status of this destination handle, not |
|
1324 // the current status in database. |
|
1325 // --------------------------------------------------------------------------- |
|
1326 // |
|
1327 TBool CCmmDestinationInstance::HasEmbeddedWithId( const TUint32 aDestinationId ) const |
|
1328 { |
|
1329 OstTraceFunctionEntry0( CCMMDESTINATIONINSTANCE_HASEMBEDDEDWITHID_ENTRY ); |
|
1330 |
|
1331 TBool result( EFalse ); |
|
1332 |
|
1333 // If there is an embedded destination, it will be at the very last |
|
1334 // position in the connection method item array. |
|
1335 TInt index = iConnMethodItemArray.Count() - 1; |
|
1336 if ( index >= 0 ) |
|
1337 { |
|
1338 // No need to check bearer, since ID will not match anyway if the last |
|
1339 // item is not an embedded destination. |
|
1340 if ( iConnMethodItemArray[index].iId == aDestinationId ) |
|
1341 { |
|
1342 result = ETrue; |
|
1343 } |
|
1344 } |
|
1345 |
|
1346 OstTraceFunctionExit0( CCMMDESTINATIONINSTANCE_HASEMBEDDEDWITHID_EXIT ); |
|
1347 return result; |
|
1348 } |
|
1349 |
|
1350 // --------------------------------------------------------------------------- |
|
1351 // After update/delete to database, refresh temporary ID to real ID if |
|
1352 // necessary and refresh status information for any related handles for |
|
1353 // all client sessions. |
|
1354 // --------------------------------------------------------------------------- |
|
1355 // |
|
1356 void CCmmDestinationInstance::RefreshHandlesForAllSessions( const TCmmIdStruct& aIdStruct ) |
|
1357 { |
|
1358 OstTraceFunctionEntry0( CCMMDESTINATIONINSTANCE_REFRESHHANDLESFORALLSESSIONS_ENTRY ); |
|
1359 |
|
1360 iCmmSession->RefreshHandlesForAllSessions( aIdStruct ); |
|
1361 |
|
1362 OstTraceFunctionExit0( CCMMDESTINATIONINSTANCE_REFRESHHANDLESFORALLSESSIONS_EXIT ); |
|
1363 } |
|
1364 |
|
1365 // --------------------------------------------------------------------------- |
|
1366 // If the destination contains a connection method with matching temporary ID, |
|
1367 // updates the ID to real ID. This is done after the connection method has been |
|
1368 // successfully saved into the database. |
|
1369 // --------------------------------------------------------------------------- |
|
1370 // |
|
1371 void CCmmDestinationInstance::RefreshConnMethodId( const TCmmIdStruct& aIdStruct ) |
|
1372 { |
|
1373 OstTraceFunctionEntry0( CCMMDESTINATIONINSTANCE_REFRESHCONNMETHODID_ENTRY ); |
|
1374 |
|
1375 for ( TInt i = 0; i < iConnMethodItemArray.Count(); i++ ) |
|
1376 { |
|
1377 if ( iConnMethodItemArray[i].iId == aIdStruct.iTemporaryId ) |
|
1378 { |
|
1379 iConnMethodItemArray[i].iId = aIdStruct.iRealId; |
|
1380 break; |
|
1381 } |
|
1382 } |
|
1383 |
|
1384 OstTraceFunctionExit0( CCMMDESTINATIONINSTANCE_REFRESHCONNMETHODID_EXIT ); |
|
1385 } |
|
1386 |
|
1387 // --------------------------------------------------------------------------- |
|
1388 // Called after this destination has been updated and database transaction has |
|
1389 // completed successfully. Sets the internal state of this destination instance |
|
1390 // to reflect the new valid state. |
|
1391 // --------------------------------------------------------------------------- |
|
1392 // |
|
1393 void CCmmDestinationInstance::UpdateSuccessful() |
|
1394 { |
|
1395 OstTraceFunctionEntry0( CCMMDESTINATIONINSTANCE_UPDATESUCCESSFUL_ENTRY ); |
|
1396 |
|
1397 SetStatus( ECmmDestinationStatusValid ); |
|
1398 SetStatusForAllRecords( ECmmRecordStatusLoaded ); |
|
1399 iConnMethodsToBeDeleted.Reset(); |
|
1400 iProtectionChanged = EFalse; |
|
1401 |
|
1402 OstTraceFunctionExit0( CCMMDESTINATIONINSTANCE_UPDATESUCCESSFUL_EXIT ); |
|
1403 } |
|
1404 |
|
1405 // --------------------------------------------------------------------------- |
|
1406 // Checks if all mandatory records contain data and are ready to be saved into |
|
1407 // database. |
|
1408 // --------------------------------------------------------------------------- |
|
1409 // |
|
1410 TBool CCmmDestinationInstance::AllMandatoryRecordsContainData() const |
|
1411 { |
|
1412 OstTraceFunctionEntry0( CCMMDESTINATIONINSTANCE_ALLMANDATORYRECORDSCONTAINDATA_ENTRY ); |
|
1413 |
|
1414 TBool result( ETrue ); |
|
1415 |
|
1416 if ( iNetworkRecordStatus != ECmmRecordStatusLoaded && |
|
1417 iNetworkRecordStatus != ECmmRecordStatusModified ) |
|
1418 { |
|
1419 result = EFalse; |
|
1420 } |
|
1421 if ( iDestApRecordStatus != ECmmRecordStatusLoaded && |
|
1422 iDestApRecordStatus != ECmmRecordStatusModified ) |
|
1423 { |
|
1424 result = EFalse; |
|
1425 } |
|
1426 if ( iMetadataRecordStatus != ECmmRecordStatusLoaded && |
|
1427 iMetadataRecordStatus != ECmmRecordStatusModified ) |
|
1428 { |
|
1429 result = EFalse; |
|
1430 } |
|
1431 if ( !iNetworkRecord || !iDestApRecord || !iMetadataRecord ) |
|
1432 { |
|
1433 result = EFalse; |
|
1434 } |
|
1435 |
|
1436 OstTraceFunctionExit0( CCMMDESTINATIONINSTANCE_ALLMANDATORYRECORDSCONTAINDATA_EXIT ); |
|
1437 return result; |
|
1438 } |
|
1439 |
|
1440 // --------------------------------------------------------------------------- |
|
1441 // Loads a requested type of record from database if it is not yet loaded. |
|
1442 // |
|
1443 // Currently all records are loaded when client opens a handle to a |
|
1444 // destination, but if future optimizations are added and records are only |
|
1445 // loaded when needed, the functionality of this method becomes essential. |
|
1446 // --------------------------------------------------------------------------- |
|
1447 // |
|
1448 void CCmmDestinationInstance::LoadRecordIfMissingL( TCmmDbRecords aRecordType ) |
|
1449 { |
|
1450 OstTraceFunctionEntry0( CCMMDESTINATIONINSTANCE_REFRESHRECORDL_ENTRY ); |
|
1451 |
|
1452 TCmmRecordStatus status( ECmmRecordStatusBlank ); |
|
1453 switch ( aRecordType ) |
|
1454 { |
|
1455 case ECmmDestNetworkRecord: |
|
1456 status = iNetworkRecordStatus; |
|
1457 break; |
|
1458 case ECmmDestApRecord: |
|
1459 status = iDestApRecordStatus; |
|
1460 break; |
|
1461 case ECmmDestMetadataRecord: |
|
1462 status = iMetadataRecordStatus; |
|
1463 break; |
|
1464 default: |
|
1465 User::Leave( KErrCorrupt ); // Error, unknown type. |
|
1466 break; |
|
1467 } |
|
1468 |
|
1469 switch ( status ) |
|
1470 { |
|
1471 // Fallthrough intended |
|
1472 case ECmmRecordStatusBlank: |
|
1473 iCache->LoadDestinationRecordL( *this, aRecordType ); |
|
1474 break; |
|
1475 case ECmmRecordStatusLoaded: |
|
1476 case ECmmRecordStatusModified: |
|
1477 // Record is up-to-date. |
|
1478 break; |
|
1479 case ECmmRecordStatusExpired: |
|
1480 case ECmmRecordStatusUnsaved: |
|
1481 default: |
|
1482 User::Leave( KErrCorrupt ); // Error, invalid or unknown status. |
|
1483 break; |
|
1484 } |
|
1485 |
|
1486 OstTraceFunctionExit0( CCMMDESTINATIONINSTANCE_REFRESHRECORDL_EXIT ); |
|
1487 } |
|
1488 |
|
1489 // --------------------------------------------------------------------------- |
|
1490 // Loads all records from database that are not up-to-date. |
|
1491 // Guarantees the record pointers are valid or leaves. |
|
1492 // --------------------------------------------------------------------------- |
|
1493 // |
|
1494 void CCmmDestinationInstance::LoadAllRecordsL() |
|
1495 { |
|
1496 OstTraceFunctionEntry0( CCMMDESTINATIONINSTANCE_LOADALLRECORDSL_ENTRY ); |
|
1497 |
|
1498 LoadRecordIfMissingL( ECmmDestNetworkRecord ); |
|
1499 LoadRecordIfMissingL( ECmmDestApRecord ); |
|
1500 LoadRecordIfMissingL( ECmmDestMetadataRecord ); |
|
1501 |
|
1502 if ( !iNetworkRecord || !iDestApRecord || !iMetadataRecord ) |
|
1503 { |
|
1504 User::Leave( KErrCorrupt ); |
|
1505 } |
|
1506 |
|
1507 OstTraceFunctionExit0( CCMMDESTINATIONINSTANCE_LOADALLRECORDSL_EXIT ); |
|
1508 } |
|
1509 |
|
1510 // --------------------------------------------------------------------------- |
|
1511 // Set metadata of type ESnapMetadataInternet. |
|
1512 // --------------------------------------------------------------------------- |
|
1513 // |
|
1514 void CCmmDestinationInstance::SetMetadataInternetL( const TUint32 aMetadata ) |
|
1515 { |
|
1516 OstTraceFunctionEntry0( CCMMDESTINATIONINSTANCE_SETMETADATAINTERNETL_ENTRY ); |
|
1517 |
|
1518 if ( aMetadata ) |
|
1519 { |
|
1520 if ( iCache->DestinationExistsWithMetadataLocalizedL( |
|
1521 *this, |
|
1522 CMManager::ELocalisedDestInternet ) ) |
|
1523 { |
|
1524 User::Leave( KErrAlreadyExists ); |
|
1525 } |
|
1526 // Clear ESnapMetadataHiddenAgent-bit. |
|
1527 TUint32 value = iMetadataRecord->iMetadata & ( ~CMManager::ESnapMetadataHiddenAgent ); |
|
1528 |
|
1529 // Set old ESnapMetadataInternet-bit. |
|
1530 value = value | CMManager::ESnapMetadataInternet; |
|
1531 |
|
1532 // Clear ESnapMetadataDestinationIsLocalised-bits. |
|
1533 value = value & ( ~CMManager::ESnapMetadataDestinationIsLocalised ); |
|
1534 // Set ELocalisedDestInternet-value. |
|
1535 iMetadataRecord->iMetadata = value | ( CMManager::ELocalisedDestInternet << 4 ); |
|
1536 value = value | ( CMManager::ELocalisedDestInternet << 4 ); |
|
1537 |
|
1538 // Clear ESnapMetadataPurpose-bits. |
|
1539 value = value & ( ~CMManager::ESnapMetadataPurpose ); |
|
1540 // Set ESnapPurposeInternet-value. |
|
1541 iMetadataRecord->iMetadata = value | ( CMManager::ESnapPurposeInternet << 8 ); |
|
1542 } |
|
1543 else |
|
1544 { |
|
1545 // Clear old ESnapMetadataInternet-bit, |
|
1546 // ESnapMetadataDestinationIsLocalised-bits and CMManager::ESnapMetadataPurpose-bits. |
|
1547 TUint32 temp = ~( CMManager::ESnapMetadataInternet | |
|
1548 CMManager::ESnapMetadataDestinationIsLocalised | |
|
1549 CMManager::ESnapMetadataPurpose ); |
|
1550 iMetadataRecord->iMetadata = iMetadataRecord->iMetadata & temp; |
|
1551 } |
|
1552 |
|
1553 OstTraceFunctionExit0( CCMMDESTINATIONINSTANCE_SETMETADATAINTERNETL_EXIT ); |
|
1554 } |
|
1555 |
|
1556 // --------------------------------------------------------------------------- |
|
1557 // Set metadata of type ESnapMetadataHighlight. |
|
1558 // --------------------------------------------------------------------------- |
|
1559 // |
|
1560 void CCmmDestinationInstance::SetMetadataHighlight( const TUint32 aMetadata ) |
|
1561 { |
|
1562 OstTraceFunctionEntry0( CCMMDESTINATIONINSTANCE_SETMETADATAHIGHLIGHTL_ENTRY ); |
|
1563 |
|
1564 // TODO: Old CmManager does not perform any duplicate checks when setting highlight. |
|
1565 // Now with single click this is not used anymore anyway. So I suggest we don't add any checks here. |
|
1566 if ( aMetadata ) |
|
1567 { |
|
1568 // Set ESnapMetadataHighlight-bit. |
|
1569 iMetadataRecord->iMetadata = |
|
1570 iMetadataRecord->iMetadata | CMManager::ESnapMetadataHighlight; |
|
1571 } |
|
1572 else |
|
1573 { |
|
1574 // Clear ESnapMetadataHighlight-bit. |
|
1575 iMetadataRecord->iMetadata = |
|
1576 iMetadataRecord->iMetadata & ( ~CMManager::ESnapMetadataHighlight ); |
|
1577 } |
|
1578 |
|
1579 OstTraceFunctionExit0( CCMMDESTINATIONINSTANCE_SETMETADATAHIGHLIGHTL_EXIT ); |
|
1580 } |
|
1581 |
|
1582 // --------------------------------------------------------------------------- |
|
1583 // Set metadata of type ESnapMetadataHiddenAgent. |
|
1584 // --------------------------------------------------------------------------- |
|
1585 // |
|
1586 void CCmmDestinationInstance::SetMetadataHiddenAgentL( const TUint32 aMetadata ) |
|
1587 { |
|
1588 OstTraceFunctionEntry0( CCMMDESTINATIONINSTANCE_SETMETADATAHIDDENAGENTL_ENTRY ); |
|
1589 |
|
1590 if ( aMetadata ) |
|
1591 { |
|
1592 TUint32 metadataInternet( iMetadataRecord->iMetadata & |
|
1593 CMManager::ESnapMetadataInternet ); |
|
1594 TUint32 metadataLocalized( ( iMetadataRecord->iMetadata & |
|
1595 CMManager::ESnapMetadataDestinationIsLocalised ) >> 4 ); |
|
1596 TUint32 metadataPurpose( ( iMetadataRecord->iMetadata & |
|
1597 CMManager::ESnapMetadataPurpose ) >> 8 ); |
|
1598 if ( metadataInternet || |
|
1599 ( metadataLocalized == CMManager::ELocalisedDestInternet ) || |
|
1600 ( metadataPurpose == CMManager::ESnapPurposeInternet ) ) |
|
1601 { |
|
1602 // Not allowed to set ESnapMetadataHiddenAgent if destination is |
|
1603 // localized or has purpose set. |
|
1604 User::Leave( KErrArgument ); |
|
1605 } |
|
1606 // Set ESnapMetadataHiddenAgent-bit. |
|
1607 iMetadataRecord->iMetadata = |
|
1608 iMetadataRecord->iMetadata | CMManager::ESnapMetadataHiddenAgent; |
|
1609 } |
|
1610 else |
|
1611 { |
|
1612 // Clear ESnapMetadataHiddenAgent-bit. |
|
1613 iMetadataRecord->iMetadata = |
|
1614 iMetadataRecord->iMetadata & ( ~CMManager::ESnapMetadataHiddenAgent ); |
|
1615 } |
|
1616 |
|
1617 OstTraceFunctionExit0( CCMMDESTINATIONINSTANCE_SETMETADATAHIDDENAGENTL_EXIT ); |
|
1618 } |
|
1619 |
|
1620 // --------------------------------------------------------------------------- |
|
1621 // Set metadata of type ESnapMetadataDestinationIsLocalised. |
|
1622 // --------------------------------------------------------------------------- |
|
1623 // |
|
1624 void CCmmDestinationInstance::SetMetadataLocalizationL( const TUint32 aMetadata ) |
|
1625 { |
|
1626 OstTraceFunctionEntry0( CCMMDESTINATIONINSTANCE_SETMETADATALOCALIZATIONL_ENTRY ); |
|
1627 |
|
1628 // Check that aMetadata is within valid range. |
|
1629 if ( aMetadata > CMManager::ELocalisedDestIntranet ) |
|
1630 { |
|
1631 User::Leave( KErrArgument ); |
|
1632 } |
|
1633 |
|
1634 TUint32 temp = ~( |
|
1635 CMManager::ESnapMetadataInternet | |
|
1636 CMManager::ESnapMetadataDestinationIsLocalised | |
|
1637 CMManager::ESnapMetadataPurpose ); |
|
1638 if ( aMetadata == CMManager::ENotLocalisedDest ) |
|
1639 { |
|
1640 // Clear old ESnapMetadataInternet-bit, |
|
1641 // ESnapMetadataDestinationIsLocalised-bits and ESnapMetadataPurpose-bits. |
|
1642 iMetadataRecord->iMetadata = iMetadataRecord->iMetadata & temp; |
|
1643 } |
|
1644 else |
|
1645 { |
|
1646 if ( iCache->DestinationExistsWithMetadataLocalizedL( *this, aMetadata ) ) |
|
1647 { |
|
1648 User::Leave( KErrAlreadyExists ); |
|
1649 } |
|
1650 |
|
1651 // Clear old ESnapMetadataInternet-bit, |
|
1652 // ESnapMetadataDestinationIsLocalised-bits and ESnapMetadataPurpose-bits. |
|
1653 TUint32 value = iMetadataRecord->iMetadata & temp; |
|
1654 switch ( aMetadata ) |
|
1655 { |
|
1656 case CMManager::ELocalisedDestInternet: |
|
1657 { |
|
1658 // Clear ESnapMetadataHiddenAgent-bit. |
|
1659 value = value & ( ~CMManager::ESnapMetadataHiddenAgent ); |
|
1660 // Set old ESnapMetadataInternet-bit. |
|
1661 value = value | CMManager::ESnapMetadataInternet; |
|
1662 // Set ESnapPurposeInternet-value. |
|
1663 value = value | ( CMManager::ESnapPurposeInternet << 8 ); |
|
1664 } |
|
1665 break; |
|
1666 case CMManager::ELocalisedDestWap: |
|
1667 { |
|
1668 // Set ESnapPurposeOperator-value. |
|
1669 value = value | ( CMManager::ESnapPurposeOperator << 8 ); |
|
1670 } |
|
1671 break; |
|
1672 case CMManager::ELocalisedDestMMS: |
|
1673 { |
|
1674 // Set ESnapMetadataHiddenAgent-bit. |
|
1675 value = value | CMManager::ESnapMetadataHiddenAgent; |
|
1676 // Set ESnapPurposeMMS-value. |
|
1677 value = value | ( CMManager::ESnapPurposeMMS << 8 ); |
|
1678 } |
|
1679 break; |
|
1680 case CMManager::ELocalisedDestIntranet: |
|
1681 { |
|
1682 // Set ESnapPurposeIntranet-value. |
|
1683 value = value | ( CMManager::ESnapPurposeIntranet << 8 ); |
|
1684 } |
|
1685 break; |
|
1686 default: |
|
1687 User::Leave( KErrArgument ); |
|
1688 break; |
|
1689 } |
|
1690 // Set ESnapMetadataDestinationIsLocalised-value. |
|
1691 iMetadataRecord->iMetadata = value | ( aMetadata << 4 ); |
|
1692 } |
|
1693 |
|
1694 OstTraceFunctionExit0( CCMMDESTINATIONINSTANCE_SETMETADATALOCALIZATIONL_EXIT ); |
|
1695 } |
|
1696 |
|
1697 // --------------------------------------------------------------------------- |
|
1698 // Set metadata of type ESnapMetadataPurpose. |
|
1699 // --------------------------------------------------------------------------- |
|
1700 // |
|
1701 void CCmmDestinationInstance::SetMetadataPurposeL( const TUint32 aMetadata ) |
|
1702 { |
|
1703 OstTraceFunctionEntry0( CCMMDESTINATIONINSTANCE_SETMETADATAPURPOSEL_ENTRY ); |
|
1704 |
|
1705 // Check that aMetadata is within valid range. |
|
1706 if ( aMetadata > CMManager::ESnapPurposeIntranet ) |
|
1707 { |
|
1708 User::Leave( KErrArgument ); |
|
1709 } |
|
1710 |
|
1711 TUint32 temp = ~( |
|
1712 CMManager::ESnapMetadataInternet | |
|
1713 CMManager::ESnapMetadataDestinationIsLocalised | |
|
1714 CMManager::ESnapMetadataPurpose ); |
|
1715 if ( aMetadata == CMManager::ESnapPurposeUnknown ) |
|
1716 { |
|
1717 // Clear old ESnapMetadataInternet-bit, |
|
1718 // ESnapMetadataDestinationIsLocalised-bits and ESnapMetadataPurpose-bits. |
|
1719 iMetadataRecord->iMetadata = iMetadataRecord->iMetadata & temp; |
|
1720 } |
|
1721 else |
|
1722 { |
|
1723 if ( iCache->DestinationExistsWithMetadataPurposeL( *this, aMetadata ) ) |
|
1724 { |
|
1725 User::Leave( KErrAlreadyExists ); |
|
1726 } |
|
1727 |
|
1728 // Clear old ESnapMetadataInternet-bit, |
|
1729 // ESnapMetadataDestinationIsLocalised-bits and ESnapMetadataPurpose-bits. |
|
1730 TUint32 value = iMetadataRecord->iMetadata & temp; |
|
1731 |
|
1732 switch ( aMetadata ) |
|
1733 { |
|
1734 case CMManager::ESnapPurposeInternet: |
|
1735 { |
|
1736 // Clear ESnapMetadataHiddenAgent-bit. |
|
1737 value = value & ( ~CMManager::ESnapMetadataHiddenAgent ); |
|
1738 // Set old ESnapMetadataInternet-bit. |
|
1739 value = value | CMManager::ESnapMetadataInternet; |
|
1740 // Set ELocalisedDestInternet-value. |
|
1741 value = value | ( CMManager::ELocalisedDestInternet << 4 ); |
|
1742 } |
|
1743 break; |
|
1744 case CMManager::ESnapPurposeOperator: |
|
1745 { |
|
1746 // Set ELocalisedDestWap-value. |
|
1747 value = value | ( CMManager::ELocalisedDestWap << 4 ); |
|
1748 } |
|
1749 break; |
|
1750 case CMManager::ESnapPurposeMMS: |
|
1751 { |
|
1752 // Set ESnapMetadataHiddenAgent-bit. |
|
1753 value = value | CMManager::ESnapMetadataHiddenAgent; |
|
1754 // Set ELocalisedDestMMS-value. |
|
1755 value = value | ( CMManager::ELocalisedDestMMS << 4 ); |
|
1756 } |
|
1757 break; |
|
1758 case CMManager::ESnapPurposeIntranet: |
|
1759 { |
|
1760 // Set ELocalisedDestIntranet-value. |
|
1761 value = value | ( CMManager::ELocalisedDestIntranet << 4 ); |
|
1762 } |
|
1763 break; |
|
1764 default: |
|
1765 User::Leave( KErrArgument ); |
|
1766 break; |
|
1767 } |
|
1768 // Set ESnapMetadataPurpose-value. |
|
1769 iMetadataRecord->iMetadata = value | ( aMetadata << 8 ); |
|
1770 } |
|
1771 |
|
1772 OstTraceFunctionExit0( CCMMDESTINATIONINSTANCE_SETMETADATAPURPOSEL_EXIT ); |
|
1773 } |
|
1774 |
|
1775 // --------------------------------------------------------------------------- |
|
1776 // Checks the current metadata for this destination, and verifies there is no |
|
1777 // other conflicting destinations in the database. |
|
1778 // --------------------------------------------------------------------------- |
|
1779 // |
|
1780 TBool CCmmDestinationInstance::ConflictingMetadataFoundL() |
|
1781 { |
|
1782 OstTraceFunctionEntry0( CCMMDESTINATIONINSTANCE_CONFLICTINGMETADATAFOUNDL_ENTRY ); |
|
1783 |
|
1784 TBool result( EFalse ); |
|
1785 TUint32 metadataInternet( iMetadataRecord->iMetadata & |
|
1786 CMManager::ESnapMetadataInternet ); |
|
1787 TUint32 metadataLocalized( ( iMetadataRecord->iMetadata & |
|
1788 CMManager::ESnapMetadataDestinationIsLocalised ) >> 4 ); |
|
1789 TUint32 metadataPurpose( ( iMetadataRecord->iMetadata & |
|
1790 CMManager::ESnapMetadataPurpose ) >> 8 ); |
|
1791 |
|
1792 if ( metadataPurpose ) |
|
1793 { |
|
1794 // Some metadata is set, need to check conflicts in database. |
|
1795 switch ( metadataPurpose ) |
|
1796 { |
|
1797 // Fallthrough intended. |
|
1798 case CMManager::ESnapPurposeInternet: |
|
1799 case CMManager::ESnapPurposeOperator: |
|
1800 case CMManager::ESnapPurposeMMS: |
|
1801 case CMManager::ESnapPurposeIntranet: |
|
1802 result = iCache->DestinationExistsWithMetadataPurposeL( |
|
1803 *this, |
|
1804 metadataPurpose ); |
|
1805 break; |
|
1806 default: |
|
1807 User::Leave( KErrCorrupt ); // Invalid metadata. |
|
1808 break; |
|
1809 } |
|
1810 } |
|
1811 else if ( metadataLocalized ) |
|
1812 { |
|
1813 // Error, metadataPurpose was not set. Continue anyway. |
|
1814 switch ( metadataLocalized ) |
|
1815 { |
|
1816 // Fallthrough intended. |
|
1817 case CMManager::ELocalisedDestInternet: |
|
1818 case CMManager::ELocalisedDestWap: |
|
1819 case CMManager::ELocalisedDestMMS: |
|
1820 case CMManager::ELocalisedDestIntranet: |
|
1821 result = iCache->DestinationExistsWithMetadataLocalizedL( |
|
1822 *this, |
|
1823 metadataLocalized ); |
|
1824 break; |
|
1825 default: |
|
1826 User::Leave( KErrCorrupt ); // Invalid metadata. |
|
1827 break; |
|
1828 } |
|
1829 } |
|
1830 else if ( metadataInternet ) |
|
1831 { |
|
1832 // Error, metadataPurpose and metadataLocalized was not set. Continue anyway. |
|
1833 result = iCache->DestinationExistsWithMetadataLocalizedL( |
|
1834 *this, |
|
1835 CMManager::ELocalisedDestInternet ); |
|
1836 } |
|
1837 |
|
1838 OstTraceFunctionExit0( CCMMDESTINATIONINSTANCE_CONFLICTINGMETADATAFOUNDL_EXIT ); |
|
1839 return result; |
|
1840 } |
|
1841 |
|
1842 // End of file |
|