|
1 /* |
|
2 * Copyright (c) 2005 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: Tools for handling presence attribute models in arrays. |
|
15 * |
|
16 */ |
|
17 |
|
18 // INCLUDE FILES |
|
19 #include "PEngAttrModelHelper.h" |
|
20 #include "PresenceDebugPrint.h" |
|
21 |
|
22 #include <E32Std.h> |
|
23 #include <MPEngPresenceAttrModel2.h> |
|
24 |
|
25 |
|
26 |
|
27 |
|
28 // ============================ MEMBER FUNCTIONS =============================== |
|
29 |
|
30 // ----------------------------------------------------------------------------- |
|
31 // PEngAttrModelHelper::AddOrReplaceModelL() |
|
32 // ----------------------------------------------------------------------------- |
|
33 // |
|
34 void PEngAttrModelHelper::AddOrReplaceModelL( |
|
35 RPointerArray< MPEngPresenceAttrModel2 >& aModels, |
|
36 MPEngPresenceAttrModel2& aModel ) |
|
37 { |
|
38 const TInt modelCount = aModels.Count(); |
|
39 for ( TInt ix = 0; ix < modelCount; ix++ ) |
|
40 { |
|
41 MPEngPresenceAttrModel2* model = aModels[ ix ]; |
|
42 if ( ( model->Type() == aModel.Type() ) && |
|
43 ( model->PresenceID() == aModel.PresenceID() ) ) |
|
44 { |
|
45 //Matching model found ==> replace it |
|
46 delete model; |
|
47 aModels[ ix ] = &aModel; |
|
48 return; |
|
49 } |
|
50 } |
|
51 |
|
52 //no matching model found |
|
53 //Add the given one |
|
54 aModels.AppendL( &aModel ); |
|
55 } |
|
56 |
|
57 |
|
58 |
|
59 // ----------------------------------------------------------------------------- |
|
60 // PEngAttrModelHelper::MoveModelsL() |
|
61 // ----------------------------------------------------------------------------- |
|
62 // |
|
63 void PEngAttrModelHelper::MoveModelsL( |
|
64 RPointerArray< MPEngPresenceAttrModel2 >& aFrom, |
|
65 RPointerArray< MPEngPresenceAttrModel2 >& aTo ) |
|
66 |
|
67 { |
|
68 const TInt modelCount = aFrom.Count(); |
|
69 for ( TInt ix = 0; ix < modelCount; ix++ ) |
|
70 { |
|
71 MPEngPresenceAttrModel2* model = aFrom[ 0 ]; |
|
72 aTo.AppendL( model ); |
|
73 aFrom.Remove( 0 ); |
|
74 } |
|
75 } |
|
76 |
|
77 |
|
78 // ----------------------------------------------------------------------------- |
|
79 // PEngAttrModelHelper::HasDuplicateTypes() |
|
80 // ----------------------------------------------------------------------------- |
|
81 // |
|
82 TBool PEngAttrModelHelper::HasDuplicateTypes( |
|
83 RPointerArray< MPEngPresenceAttrModel2 >& aModels ) |
|
84 { |
|
85 //Check against duplicate types |
|
86 const TInt modelCount = aModels.Count(); |
|
87 for ( TInt ix = 0; ix < modelCount - 1; ix++ ) |
|
88 { |
|
89 for ( TInt jj( ix + 1 ); jj < modelCount; jj++ ) |
|
90 { |
|
91 if ( aModels[ ix ]->Type() == aModels[ jj ]->Type() ) |
|
92 { |
|
93 return ETrue; |
|
94 } |
|
95 } |
|
96 } |
|
97 |
|
98 return EFalse; |
|
99 } |
|
100 |
|
101 |
|
102 // End of File |
|
103 |