|
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: Attribute list model implementation |
|
15 * |
|
16 */ |
|
17 |
|
18 // INCLUDE FILES |
|
19 #include "CPEngAttributeListModel.h" |
|
20 #include "MPEngPresenceAttrManager.h" |
|
21 #include "PEngListLibTools.h" |
|
22 #include <e32std.h> |
|
23 |
|
24 |
|
25 // ============================ MEMBER FUNCTIONS =============================== |
|
26 |
|
27 // ----------------------------------------------------------------------------- |
|
28 // CPEngAttributeListModel::CPEngAttributeListModel() |
|
29 // ----------------------------------------------------------------------------- |
|
30 // |
|
31 CPEngAttributeListModel::CPEngAttributeListModel( |
|
32 MPEngPresenceAttrManager* aAttributeManager ) |
|
33 : iAttributeManager( aAttributeManager ) |
|
34 { |
|
35 } |
|
36 |
|
37 |
|
38 // ----------------------------------------------------------------------------- |
|
39 // CPEngAttributeListModel::ConstructL() |
|
40 // ----------------------------------------------------------------------------- |
|
41 // |
|
42 void CPEngAttributeListModel::ConstructL( |
|
43 const RArray<TUint32>& aPresenceAttributes ) |
|
44 { |
|
45 TInt count ( aPresenceAttributes.Count() ); |
|
46 for ( TInt x ( 0 ) ; x < count ; x++ ) |
|
47 { |
|
48 User::LeaveIfError( iListOfAttributes.InsertInSignedKeyOrder( |
|
49 aPresenceAttributes[x] ) ); |
|
50 } |
|
51 } |
|
52 |
|
53 |
|
54 // ----------------------------------------------------------------------------- |
|
55 // CPEngAttributeListModel::NewL() |
|
56 // ----------------------------------------------------------------------------- |
|
57 // |
|
58 CPEngAttributeListModel* CPEngAttributeListModel::NewL( |
|
59 MPEngPresenceAttrManager* aAttributeManager ) |
|
60 { |
|
61 CPEngAttributeListModel* self = NewLC( aAttributeManager ); |
|
62 CleanupStack::Pop(); |
|
63 |
|
64 return self; |
|
65 } |
|
66 |
|
67 |
|
68 // ----------------------------------------------------------------------------- |
|
69 // CPEngAttributeListModel::NewL() |
|
70 // ----------------------------------------------------------------------------- |
|
71 // |
|
72 CPEngAttributeListModel* CPEngAttributeListModel::NewL( |
|
73 MPEngPresenceAttrManager* aAttributeManager, |
|
74 const RArray<TUint32>& aPresenceAttributes ) |
|
75 { |
|
76 CPEngAttributeListModel* self = NewLC( aAttributeManager, aPresenceAttributes ); |
|
77 CleanupStack::Pop(); |
|
78 |
|
79 return self; |
|
80 } |
|
81 |
|
82 |
|
83 // ----------------------------------------------------------------------------- |
|
84 // CPEngAttributeListModel::NewLC |
|
85 // ----------------------------------------------------------------------------- |
|
86 // |
|
87 CPEngAttributeListModel* CPEngAttributeListModel::NewLC( |
|
88 MPEngPresenceAttrManager* aAttributeManager ) |
|
89 { |
|
90 CPEngAttributeListModel* self = |
|
91 new( ELeave ) CPEngAttributeListModel ( aAttributeManager ); |
|
92 |
|
93 CleanupStack::PushL( self ); |
|
94 |
|
95 return self; |
|
96 } |
|
97 |
|
98 |
|
99 // ----------------------------------------------------------------------------- |
|
100 // CPEngAttributeListModel::NewLC() |
|
101 // ----------------------------------------------------------------------------- |
|
102 // |
|
103 CPEngAttributeListModel* CPEngAttributeListModel::NewLC( |
|
104 MPEngPresenceAttrManager* aAttributeManager, |
|
105 const RArray<TUint32>& aPresenceAttributes ) |
|
106 { |
|
107 CPEngAttributeListModel* self = new( ELeave ) |
|
108 CPEngAttributeListModel( aAttributeManager ); |
|
109 |
|
110 CleanupStack::PushL( self ); |
|
111 self->ConstructL( aPresenceAttributes ); |
|
112 |
|
113 return self; |
|
114 } |
|
115 |
|
116 |
|
117 // Destructor |
|
118 CPEngAttributeListModel::~CPEngAttributeListModel() |
|
119 { |
|
120 iListOfAttributes.Reset(); |
|
121 } |
|
122 |
|
123 |
|
124 // ============================================================================= |
|
125 // =============== From MPEngPresenceAttributeList ============================= |
|
126 // ============================================================================= |
|
127 |
|
128 // ----------------------------------------------------------------------------- |
|
129 // CPEngAttributeListModel::AddPresenceAttributeL() |
|
130 // ----------------------------------------------------------------------------- |
|
131 // |
|
132 void CPEngAttributeListModel::AddPresenceAttributeL( TUint32 aPresenceAttribute ) |
|
133 { |
|
134 // if answer is KErrNone attribute is known |
|
135 TInt err( iAttributeManager->ValidNetworkAttribute( aPresenceAttribute ) ); |
|
136 User::LeaveIfError( err ); |
|
137 |
|
138 // attribute is supported, add it to the array |
|
139 err = iListOfAttributes.InsertInSignedKeyOrder( aPresenceAttribute ); |
|
140 NListLibTools::LeaveIfMajorErrorL( err ); |
|
141 } |
|
142 |
|
143 // ----------------------------------------------------------------------------- |
|
144 // CPEngAttributeListModel::RemovePresenceAttribute() |
|
145 // ----------------------------------------------------------------------------- |
|
146 // |
|
147 TInt CPEngAttributeListModel::RemovePresenceAttribute( TUint32 aPresenceAttribute ) |
|
148 { |
|
149 TInt index ( iListOfAttributes.FindInSignedKeyOrder( aPresenceAttribute ) ); |
|
150 if ( index == KErrNotFound ) |
|
151 { |
|
152 // Presence Attribute was not found, nothing to remove |
|
153 return KErrNotFound; |
|
154 } |
|
155 |
|
156 // remove ID at found index |
|
157 iListOfAttributes.Remove( index ); |
|
158 return KErrNone; |
|
159 } |
|
160 |
|
161 // ----------------------------------------------------------------------------- |
|
162 // CPEngAttributeListModel::RemoveAllAttributes() |
|
163 // ----------------------------------------------------------------------------- |
|
164 // |
|
165 void CPEngAttributeListModel::RemoveAllAttributes() |
|
166 { |
|
167 iListOfAttributes.Reset(); |
|
168 } |
|
169 |
|
170 |
|
171 // ----------------------------------------------------------------------------- |
|
172 // CPEngAttributeListModel::ConfirmPresenceAttribute() |
|
173 // ----------------------------------------------------------------------------- |
|
174 // |
|
175 TInt CPEngAttributeListModel::ConfirmPresenceAttribute( |
|
176 TUint32 aPresenceAttribute ) const |
|
177 { |
|
178 return iAttributeManager->ValidNetworkAttribute( aPresenceAttribute ); |
|
179 } |
|
180 |
|
181 |
|
182 // ----------------------------------------------------------------------------- |
|
183 // CPEngAttributeListModel::ListOfAttributes() |
|
184 // ----------------------------------------------------------------------------- |
|
185 // |
|
186 TArray<TUint32> CPEngAttributeListModel::ListOfAttributes() const |
|
187 { |
|
188 return iListOfAttributes.Array(); |
|
189 } |
|
190 |
|
191 |
|
192 // ----------------------------------------------------------------------------- |
|
193 // CPEngAttributeListModel::Close() |
|
194 // ----------------------------------------------------------------------------- |
|
195 // |
|
196 void CPEngAttributeListModel::Close() |
|
197 { |
|
198 delete this; |
|
199 } |
|
200 |
|
201 |
|
202 // ----------------------------------------------------------------------------- |
|
203 // CPEngAttributeListModel::PresenceAttributes() |
|
204 // ----------------------------------------------------------------------------- |
|
205 // |
|
206 const RArray<TUint32>& CPEngAttributeListModel::PresenceAttributes() const |
|
207 { |
|
208 return iListOfAttributes; |
|
209 } |
|
210 |
|
211 |
|
212 // End of File |
|
213 |