|
1 /* |
|
2 * Copyright (c) 2004 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: Tracked Presence ID entry. |
|
15 * |
|
16 */ |
|
17 |
|
18 // INCLUDE FILES |
|
19 #include "CPEngTrackedPresenceIDEntry.h" |
|
20 |
|
21 #include <CPEngTrackedPresenceID2.h> |
|
22 #include <MPEngPresenceAttrModel2.h> |
|
23 #include <E32Std.h> |
|
24 |
|
25 |
|
26 |
|
27 // ============================ MEMBER FUNCTIONS =============================== |
|
28 |
|
29 // ----------------------------------------------------------------------------- |
|
30 // CPEngTrackedPresenceIDEntry::NewLC() |
|
31 // Two-phased constructor. |
|
32 // ----------------------------------------------------------------------------- |
|
33 // |
|
34 CPEngTrackedPresenceIDEntry* CPEngTrackedPresenceIDEntry::NewLC( |
|
35 const TDesC& aPresenceID, |
|
36 const TArray<TUint32>& aTypes, |
|
37 TInt aFilterFlag ) |
|
38 { |
|
39 CPEngTrackedPresenceIDEntry* self = new ( ELeave ) CPEngTrackedPresenceIDEntry; |
|
40 CleanupStack::PushL( self ); |
|
41 self->ConstructL( aPresenceID, aTypes, aFilterFlag ); |
|
42 return self; |
|
43 } |
|
44 |
|
45 |
|
46 // Destructor |
|
47 CPEngTrackedPresenceIDEntry::~CPEngTrackedPresenceIDEntry() |
|
48 { |
|
49 delete iInterface; |
|
50 delete iPresenceID; |
|
51 iTrackedAttributes.Close(); |
|
52 } |
|
53 |
|
54 |
|
55 // ----------------------------------------------------------------------------- |
|
56 // CPEngTrackedPresenceIDEntry::CPEngTrackedPresenceIDEntry |
|
57 // C++ default constructor can NOT contain any code, that |
|
58 // might leave. |
|
59 // ----------------------------------------------------------------------------- |
|
60 // |
|
61 CPEngTrackedPresenceIDEntry::CPEngTrackedPresenceIDEntry() |
|
62 : iAttributesChanged( EFalse ) |
|
63 { |
|
64 } |
|
65 |
|
66 |
|
67 // ----------------------------------------------------------------------------- |
|
68 // CPEngTrackedPresenceIDEntry::ConstructL() |
|
69 // Symbian OS constructor. |
|
70 // ----------------------------------------------------------------------------- |
|
71 // |
|
72 void CPEngTrackedPresenceIDEntry::ConstructL( const TDesC& aPresenceID, |
|
73 const TArray<TUint32>& aTypes, |
|
74 TInt aFilterFlag ) |
|
75 { |
|
76 iFilterFlag = aFilterFlag; |
|
77 iInterface = new ( ELeave ) CPEngTrackedPresenceID2( *this ); |
|
78 iPresenceID = aPresenceID.AllocL(); |
|
79 |
|
80 AddTrackedAttributesL( aTypes ); |
|
81 } |
|
82 |
|
83 |
|
84 // ----------------------------------------------------------------------------- |
|
85 // CPEngTrackedPresenceIDEntry::Interface() |
|
86 // ----------------------------------------------------------------------------- |
|
87 // |
|
88 CPEngTrackedPresenceID2& CPEngTrackedPresenceIDEntry::Interface() |
|
89 { |
|
90 return *iInterface; |
|
91 } |
|
92 |
|
93 |
|
94 // ----------------------------------------------------------------------------- |
|
95 // CPEngTrackedPresenceIDEntry::PresenceID() |
|
96 // Tracked presence ID. |
|
97 // ----------------------------------------------------------------------------- |
|
98 // |
|
99 TPtrC CPEngTrackedPresenceIDEntry::PresenceID() const |
|
100 { |
|
101 return *iPresenceID; |
|
102 } |
|
103 |
|
104 |
|
105 // ----------------------------------------------------------------------------- |
|
106 // CPEngTrackedPresenceIDEntry::Compare() |
|
107 // Tracked presence ID. |
|
108 // ----------------------------------------------------------------------------- |
|
109 // |
|
110 TInt CPEngTrackedPresenceIDEntry::Compare( const CPEngTrackedPresenceIDEntry& aLhs, |
|
111 const CPEngTrackedPresenceIDEntry& aRhs ) |
|
112 { |
|
113 return aLhs.PresenceID().Compare( aRhs.PresenceID() ); |
|
114 } |
|
115 |
|
116 |
|
117 |
|
118 // ----------------------------------------------------------------------------- |
|
119 // CPEngTrackedPresenceIDEntry::IsOnlyTrackedAttribute() |
|
120 // Tracked attributes. |
|
121 // ----------------------------------------------------------------------------- |
|
122 // |
|
123 TBool CPEngTrackedPresenceIDEntry::IsOnlyTrackedAttribute( TUint32 aType ) const |
|
124 { |
|
125 TBool result = EFalse; |
|
126 |
|
127 //Given attribute is only tracked attribute if |
|
128 // - there is just 1 tracked attribute |
|
129 // - and is is same as given |
|
130 if ( ( iTrackedAttributes.Count() == 1 ) && |
|
131 ( iTrackedAttributes[ 0 ] == aType ) ) |
|
132 { |
|
133 result = ETrue; |
|
134 } |
|
135 |
|
136 return result; |
|
137 } |
|
138 |
|
139 |
|
140 // ----------------------------------------------------------------------------- |
|
141 // CPEngTrackedPresenceIDEntry::TrackedAttributes() |
|
142 // Tracked attributes. |
|
143 // ----------------------------------------------------------------------------- |
|
144 // |
|
145 TBool CPEngTrackedPresenceIDEntry::AttributesTracked() const |
|
146 { |
|
147 return ( iTrackedAttributes.Count() != 0 ); |
|
148 } |
|
149 |
|
150 |
|
151 |
|
152 // ----------------------------------------------------------------------------- |
|
153 // CPEngTrackedPresenceIDEntry::AddTrackedAttributesL() |
|
154 // Tracked attributes. |
|
155 // ----------------------------------------------------------------------------- |
|
156 // |
|
157 void CPEngTrackedPresenceIDEntry::AddTrackedAttributesL( const TArray<TUint32>& aTypes ) |
|
158 { |
|
159 const TInt typeCount( aTypes.Count() ); |
|
160 for ( TInt typeIx = 0; typeIx < typeCount; typeIx++ ) |
|
161 { |
|
162 TUint32 attributeLookup( aTypes[ typeIx ] ); |
|
163 |
|
164 TInt index = KErrNotFound; |
|
165 TInt result = iTrackedAttributes.FindInUnsignedKeyOrder( attributeLookup, |
|
166 index ); |
|
167 if ( result == KErrNotFound ) |
|
168 { |
|
169 User::LeaveIfError( iTrackedAttributes.Insert( attributeLookup, index ) ); |
|
170 } |
|
171 } |
|
172 } |
|
173 |
|
174 |
|
175 |
|
176 // ----------------------------------------------------------------------------- |
|
177 // CPEngTrackedPresenceIDEntry::RemoveTrackedAttributes() |
|
178 // Tracked attributes. |
|
179 // ----------------------------------------------------------------------------- |
|
180 // |
|
181 void CPEngTrackedPresenceIDEntry::RemoveTrackedAttributes( const TArray<TUint32>& aTypes ) |
|
182 { |
|
183 const TInt typeCount( aTypes.Count() ); |
|
184 for ( TInt typeIx = 0; typeIx < typeCount; typeIx++ ) |
|
185 { |
|
186 TUint32 attributeLookup( aTypes[ typeIx ] ); |
|
187 |
|
188 TInt index = iTrackedAttributes.FindInUnsignedKeyOrder( attributeLookup ); |
|
189 if ( index != KErrNotFound ) |
|
190 { |
|
191 iTrackedAttributes.Remove( index ); |
|
192 } |
|
193 } |
|
194 |
|
195 |
|
196 if ( iTrackedAttributes.Count() == 0 ) |
|
197 { |
|
198 iAttributesChanged = EFalse; |
|
199 } |
|
200 } |
|
201 |
|
202 |
|
203 // ----------------------------------------------------------------------------- |
|
204 // CPEngTrackedPresenceIDEntry::TrackedAttributes() |
|
205 // Tracked attributes. |
|
206 // ----------------------------------------------------------------------------- |
|
207 // |
|
208 TArray<TUint32> CPEngTrackedPresenceIDEntry::TrackedAttributes() const |
|
209 { |
|
210 return TArray< TUint32 >( TrackedAttributesCount, |
|
211 TrackedAttributeAt, |
|
212 this ); |
|
213 } |
|
214 |
|
215 |
|
216 // ----------------------------------------------------------------------------- |
|
217 // CPEngTrackedPresenceIDEntry::NextTrackedAttribute() |
|
218 // Tracked attributes. |
|
219 // ----------------------------------------------------------------------------- |
|
220 // |
|
221 TUint32 CPEngTrackedPresenceIDEntry::NextTrackedAttribute( TInt& aIterIx ) const |
|
222 { |
|
223 TUint32 attribute = KPEngNullAttributeType; |
|
224 |
|
225 if ( iTrackedAttributes.Count() > aIterIx ) |
|
226 { |
|
227 attribute = iTrackedAttributes[ aIterIx ]; |
|
228 aIterIx++; |
|
229 } |
|
230 |
|
231 return attribute; |
|
232 } |
|
233 |
|
234 |
|
235 |
|
236 // ----------------------------------------------------------------------------- |
|
237 // CPEngTrackedPresenceIDEntry::SetFilterFlag() |
|
238 // Filter flags. |
|
239 // ----------------------------------------------------------------------------- |
|
240 // |
|
241 void CPEngTrackedPresenceIDEntry::SetFilterFlag( TInt aFlag ) |
|
242 { |
|
243 iFilterFlag = aFlag; |
|
244 } |
|
245 |
|
246 |
|
247 // ----------------------------------------------------------------------------- |
|
248 // CPEngTrackedPresenceIDEntry::FilterFlag() |
|
249 // Filter flags. |
|
250 // ----------------------------------------------------------------------------- |
|
251 // |
|
252 TInt CPEngTrackedPresenceIDEntry::FilterFlag() const |
|
253 { |
|
254 return iFilterFlag; |
|
255 } |
|
256 |
|
257 |
|
258 void CPEngTrackedPresenceIDEntry::MarkAllAttributesChanged() |
|
259 { |
|
260 iAttributesChanged = ETrue; |
|
261 } |
|
262 |
|
263 |
|
264 // ----------------------------------------------------------------------------- |
|
265 // CPEngTrackedPresenceIDEntry::ResetChangeMarks() |
|
266 // Attribute change marks. |
|
267 // ----------------------------------------------------------------------------- |
|
268 // |
|
269 void CPEngTrackedPresenceIDEntry::ResetChangeMarks() |
|
270 { |
|
271 iAttributesChanged = EFalse; |
|
272 } |
|
273 |
|
274 |
|
275 // ----------------------------------------------------------------------------- |
|
276 // CPEngTrackedPresenceIDEntry::AttributesChanged() |
|
277 // Attribute change marks. |
|
278 // ----------------------------------------------------------------------------- |
|
279 // |
|
280 TBool CPEngTrackedPresenceIDEntry::AttributesChanged() const |
|
281 { |
|
282 return iAttributesChanged; |
|
283 } |
|
284 |
|
285 |
|
286 // ----------------------------------------------------------------------------- |
|
287 // CPEngTrackedPresenceIDEntry::NextChangedAttribute() |
|
288 // Attribute change marks. |
|
289 // ----------------------------------------------------------------------------- |
|
290 // |
|
291 TUint32 CPEngTrackedPresenceIDEntry::NextChangedAttribute( TInt& aIterIx ) const |
|
292 { |
|
293 if ( iAttributesChanged ) |
|
294 { |
|
295 return NextTrackedAttribute( aIterIx ); |
|
296 } |
|
297 |
|
298 |
|
299 return KPEngNullAttributeType; |
|
300 } |
|
301 |
|
302 |
|
303 // ----------------------------------------------------------------------------- |
|
304 // CPEngTrackedPresenceIDEntry::TrackedAttributesCount() |
|
305 // ----------------------------------------------------------------------------- |
|
306 // |
|
307 TInt CPEngTrackedPresenceIDEntry::TrackedAttributesCount( const CBase* aThis ) |
|
308 { |
|
309 const CPEngTrackedPresenceIDEntry* self = |
|
310 static_cast< const CPEngTrackedPresenceIDEntry* > ( aThis ); |
|
311 |
|
312 return self->iTrackedAttributes.Count(); |
|
313 } |
|
314 |
|
315 |
|
316 // ----------------------------------------------------------------------------- |
|
317 // CPEngTrackedPresenceIDEntry::TrackedAttributeAt() |
|
318 // ----------------------------------------------------------------------------- |
|
319 // |
|
320 const TAny* CPEngTrackedPresenceIDEntry::TrackedAttributeAt( const CBase* aThis, |
|
321 TInt aIndex ) |
|
322 { |
|
323 const CPEngTrackedPresenceIDEntry* self = |
|
324 static_cast< const CPEngTrackedPresenceIDEntry* > ( aThis ); |
|
325 |
|
326 return &self->iTrackedAttributes[ aIndex ]; |
|
327 } |
|
328 |
|
329 |
|
330 // End of File |
|
331 |