|
1 /* |
|
2 * Copyright (c) 2008 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: Implementation of the class CFscStoreContactSet. |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 // INCUDES |
|
20 #include "emailtrace.h" |
|
21 #include <e32std.h> |
|
22 #include "mfsccontactsetobserver.h" |
|
23 #include <MVPbkStoreContact.h> |
|
24 |
|
25 #include "cfscstorecontactset.h" |
|
26 |
|
27 // ======== LOCAL FUNCTIONS ======== |
|
28 |
|
29 // ======== MEMBER FUNCTIONS ======== |
|
30 |
|
31 // --------------------------------------------------------------------------- |
|
32 // Two-phased constructor. |
|
33 // --------------------------------------------------------------------------- |
|
34 // |
|
35 CFscStoreContactSet* CFscStoreContactSet::NewL( |
|
36 CVPbkContactManager& aVPbkContactManager, |
|
37 const RFscStoreContactList& aStoreContactList ) |
|
38 { |
|
39 FUNC_LOG; |
|
40 |
|
41 CFscStoreContactSet* self = |
|
42 new ( ELeave ) CFscStoreContactSet( aVPbkContactManager ); |
|
43 CleanupStack::PushL( self ); |
|
44 self->ConstructL( aStoreContactList ); |
|
45 CleanupStack::Pop( self ); |
|
46 |
|
47 return self; |
|
48 } |
|
49 |
|
50 // --------------------------------------------------------------------------- |
|
51 // Destructor. |
|
52 // --------------------------------------------------------------------------- |
|
53 // |
|
54 CFscStoreContactSet::~CFscStoreContactSet() |
|
55 { |
|
56 FUNC_LOG; |
|
57 } |
|
58 |
|
59 // --------------------------------------------------------------------------- |
|
60 // Contact count. |
|
61 // --------------------------------------------------------------------------- |
|
62 // |
|
63 TInt CFscStoreContactSet::ContactCount() const |
|
64 { |
|
65 FUNC_LOG; |
|
66 if ( iStoreContactList->Count() ) |
|
67 { |
|
68 MVPbkStoreContact* store = (*iStoreContactList)[0]; |
|
69 if ( !store->Group() ) |
|
70 { |
|
71 return iStoreContactList->Count(); |
|
72 } |
|
73 } |
|
74 return 0; |
|
75 } |
|
76 |
|
77 // --------------------------------------------------------------------------- |
|
78 // Group count. |
|
79 // --------------------------------------------------------------------------- |
|
80 // |
|
81 TInt CFscStoreContactSet::GroupCount() const |
|
82 { |
|
83 FUNC_LOG; |
|
84 if ( iStoreContactList->Count() ) |
|
85 { |
|
86 MVPbkStoreContact* store = (*iStoreContactList)[0]; |
|
87 if ( store->Group() ) |
|
88 { |
|
89 return iStoreContactList->Count(); |
|
90 } |
|
91 } |
|
92 return 0; |
|
93 } |
|
94 |
|
95 // --------------------------------------------------------------------------- |
|
96 // Checks if collection has next contact. |
|
97 // --------------------------------------------------------------------------- |
|
98 // |
|
99 TBool CFscStoreContactSet::HasNextContact() const |
|
100 { |
|
101 FUNC_LOG; |
|
102 TBool result = EFalse; |
|
103 |
|
104 if ( iCurrentStoreContact < iStoreContactList->Count() ) |
|
105 { |
|
106 if ( !(*iStoreContactList)[0]->Group() ) |
|
107 { |
|
108 result = ETrue; |
|
109 } |
|
110 } |
|
111 |
|
112 return result; |
|
113 } |
|
114 |
|
115 // --------------------------------------------------------------------------- |
|
116 // Checks if collection has next group. |
|
117 // Just for interface compatibility - always EFalse. |
|
118 // --------------------------------------------------------------------------- |
|
119 // |
|
120 TBool CFscStoreContactSet::HasNextGroup() const |
|
121 { |
|
122 FUNC_LOG; |
|
123 TBool result = EFalse; |
|
124 |
|
125 if ( iCurrentStoreContact < iStoreContactList->Count() ) |
|
126 { |
|
127 if ( (*iStoreContactList)[0]->Group() ) |
|
128 { |
|
129 result = ETrue; |
|
130 } |
|
131 } |
|
132 |
|
133 return result; |
|
134 } |
|
135 |
|
136 // --------------------------------------------------------------------------- |
|
137 // Sets the index to point to the first contact in the list. |
|
138 // --------------------------------------------------------------------------- |
|
139 // |
|
140 void CFscStoreContactSet::SetToFirstContact() |
|
141 { |
|
142 FUNC_LOG; |
|
143 iCurrentStoreContact = 0; |
|
144 } |
|
145 |
|
146 // --------------------------------------------------------------------------- |
|
147 // Sets the index to point to the first group in the list. |
|
148 // Just for interface compatibility. |
|
149 // --------------------------------------------------------------------------- |
|
150 // |
|
151 void CFscStoreContactSet::SetToFirstGroup() |
|
152 { |
|
153 FUNC_LOG; |
|
154 iCurrentStoreContact = 0; |
|
155 } |
|
156 |
|
157 // --------------------------------------------------------------------------- |
|
158 // Retrieves store contact. |
|
159 // --------------------------------------------------------------------------- |
|
160 // |
|
161 void CFscStoreContactSet::NextContactL( |
|
162 MFscContactSetObserver* aObserver ) |
|
163 { |
|
164 FUNC_LOG; |
|
165 if ( HasNextContact() ) |
|
166 { |
|
167 aObserver->NextContactComplete( |
|
168 (*iStoreContactList)[ iCurrentStoreContact++ ] ); |
|
169 } |
|
170 else |
|
171 { |
|
172 aObserver->NextContactFailed( KErrArgument ); |
|
173 } |
|
174 } |
|
175 |
|
176 // --------------------------------------------------------------------------- |
|
177 // Used for retrieving link for contact. |
|
178 // --------------------------------------------------------------------------- |
|
179 // |
|
180 MVPbkContactLink* CFscStoreContactSet::NextContactLinkL() |
|
181 { |
|
182 FUNC_LOG; |
|
183 return NULL; |
|
184 } |
|
185 |
|
186 // --------------------------------------------------------------------------- |
|
187 // Retrieves store contact for group. |
|
188 // Just for interface compatibility. |
|
189 // --------------------------------------------------------------------------- |
|
190 // |
|
191 void CFscStoreContactSet::NextGroupL( |
|
192 MFscContactSetObserver* aObserver ) |
|
193 { |
|
194 FUNC_LOG; |
|
195 if ( HasNextGroup() ) |
|
196 { |
|
197 aObserver->NextGroupComplete( |
|
198 (*iStoreContactList)[ iCurrentStoreContact++ ] ); |
|
199 } |
|
200 else |
|
201 { |
|
202 aObserver->NextGroupFailed( KErrArgument ); |
|
203 } |
|
204 } |
|
205 |
|
206 // --------------------------------------------------------------------------- |
|
207 // Used for retrieving link for group. |
|
208 // --------------------------------------------------------------------------- |
|
209 // |
|
210 MVPbkContactLink* CFscStoreContactSet::NextGroupLinkL() |
|
211 { |
|
212 FUNC_LOG; |
|
213 return NULL; |
|
214 } |
|
215 |
|
216 // --------------------------------------------------------------------------- |
|
217 // Cancel NextContactL method. |
|
218 // Just for interface compatibility. |
|
219 // --------------------------------------------------------------------------- |
|
220 // |
|
221 void CFscStoreContactSet::CancelNextContactL() |
|
222 { |
|
223 FUNC_LOG; |
|
224 } |
|
225 |
|
226 // --------------------------------------------------------------------------- |
|
227 // Cancel NextGroupL method. |
|
228 // Just for interface compatibility. |
|
229 // --------------------------------------------------------------------------- |
|
230 // |
|
231 void CFscStoreContactSet::CancelNextGroupL() |
|
232 { |
|
233 FUNC_LOG; |
|
234 } |
|
235 |
|
236 // --------------------------------------------------------------------------- |
|
237 // Called when the operation is completed. |
|
238 // Just for interface compatibility. |
|
239 // --------------------------------------------------------------------------- |
|
240 // |
|
241 void CFscStoreContactSet::VPbkSingleContactOperationComplete( |
|
242 MVPbkContactOperationBase& /*aOperation*/, |
|
243 MVPbkStoreContact* /*aContact*/ ) |
|
244 { |
|
245 FUNC_LOG; |
|
246 } |
|
247 |
|
248 // --------------------------------------------------------------------------- |
|
249 // Called if the operation fails. |
|
250 // Just for interface compatibility. |
|
251 // --------------------------------------------------------------------------- |
|
252 // |
|
253 void CFscStoreContactSet::VPbkSingleContactOperationFailed( |
|
254 MVPbkContactOperationBase& /*aOperation*/, TInt /*aError*/ ) |
|
255 { |
|
256 FUNC_LOG; |
|
257 } |
|
258 |
|
259 // --------------------------------------------------------------------------- |
|
260 // Constructor. |
|
261 // --------------------------------------------------------------------------- |
|
262 // |
|
263 CFscStoreContactSet::CFscStoreContactSet( |
|
264 CVPbkContactManager& aVPbkContactManager ) |
|
265 : CFscContactSet( aVPbkContactManager ) |
|
266 { |
|
267 FUNC_LOG; |
|
268 } |
|
269 |
|
270 // --------------------------------------------------------------------------- |
|
271 // Second phase constructor. |
|
272 // --------------------------------------------------------------------------- |
|
273 // |
|
274 void CFscStoreContactSet::ConstructL( |
|
275 const RFscStoreContactList& aStoreContactList ) |
|
276 { |
|
277 FUNC_LOG; |
|
278 iStoreContactList = &aStoreContactList; |
|
279 } |
|
280 |
|
281 // ======== GLOBAL FUNCTIONS ======== |
|
282 |