|
1 // Copyright (c) 2007-2009 Nokia Corporation and/or its subsidiary(-ies). |
|
2 // All rights reserved. |
|
3 // This component and the accompanying materials are made available |
|
4 // under the terms of "Eclipse Public License v1.0" |
|
5 // which accompanies this distribution, and is available |
|
6 // at the URL "http://www.eclipse.org/legal/epl-v10.html". |
|
7 // |
|
8 // Initial Contributors: |
|
9 // Nokia Corporation - initial contribution. |
|
10 // |
|
11 // Contributors: |
|
12 // |
|
13 // Description: |
|
14 // |
|
15 |
|
16 #include "ContactUtilitiesCollection.h" |
|
17 #ifdef SYMBIAN_ENABLE_SPLIT_HEADERS |
|
18 #include "cntdb_internal.h" |
|
19 #endif |
|
20 |
|
21 /** |
|
22 * Destructor |
|
23 */ |
|
24 CContactUtilitiesCollection::~CContactUtilitiesCollection() |
|
25 { |
|
26 } |
|
27 |
|
28 |
|
29 /** |
|
30 * Constructor |
|
31 */ |
|
32 CContactUtilitiesCollection* CContactUtilitiesCollection::NewL(CTestStep& aTestStep, CContactDatabase& aDb, CContactViewCollection& aViewCollection) |
|
33 { |
|
34 CContactUtilitiesCollection* self = new(ELeave) CContactUtilitiesCollection(aTestStep, aDb, aViewCollection); |
|
35 return self; |
|
36 } |
|
37 |
|
38 /** |
|
39 * Return database reference |
|
40 * @return CContactDatabase& |
|
41 */ |
|
42 CContactDatabase& CContactUtilitiesCollection::DatabaseReference() |
|
43 { |
|
44 return iDb; |
|
45 } |
|
46 |
|
47 /** |
|
48 * Return viewcollection reference |
|
49 * @return CContactViewCollection& |
|
50 */ |
|
51 CContactViewCollection& CContactUtilitiesCollection::ViewCollectionReference() |
|
52 { |
|
53 return iViewCollection; |
|
54 } |
|
55 |
|
56 |
|
57 /** |
|
58 * Constructor |
|
59 */ |
|
60 CContactUtilitiesCollection::CContactUtilitiesCollection(CTestStep& aTestStep, CContactDatabase& aDb, CContactViewCollection& aViewCollection) |
|
61 : iBaseTestStep(aTestStep), iDb(aDb), iViewCollection(aViewCollection) |
|
62 { |
|
63 } |
|
64 |
|
65 /** |
|
66 * Gets a reference to the base test step. This is needed to read from the ini file |
|
67 * @return CTestStep& |
|
68 */ |
|
69 CTestStep& CContactUtilitiesCollection::BaseTestStepReference() |
|
70 { |
|
71 return iBaseTestStep; |
|
72 } |
|
73 |
|
74 /** |
|
75 * Get the data required for the construction of the local view from the ini file and call the function |
|
76 * ConstructLocalViewL to construct a local view Object. |
|
77 * @param aSection ini section |
|
78 */ |
|
79 void CContactUtilitiesCollection::GetDataAndConstructLocalViewL(const TDesC& aSection) |
|
80 { |
|
81 TPtrC viewSortOrder; |
|
82 TPtrC viewPreferences; |
|
83 TPtrC localViewSortPlugin; |
|
84 TBool viewNotReady = EFalse; |
|
85 BaseTestStepReference().GetBoolFromConfig(aSection, KViewNotReady, viewNotReady); |
|
86 BaseTestStepReference().GetStringFromConfig(aSection, KViewSortOrder, viewSortOrder); |
|
87 BaseTestStepReference().GetStringFromConfig(aSection, KViewPreferences, viewPreferences); |
|
88 BaseTestStepReference().GetStringFromConfig(aSection, KLocalViewSortPlugin, localViewSortPlugin); |
|
89 |
|
90 // Construct the local view by passing the input data required for the construction |
|
91 ConstructLocalViewL(viewSortOrder, viewPreferences, localViewSortPlugin, viewNotReady); |
|
92 } |
|
93 |
|
94 /* |
|
95 * Allocate and construct a local view object based on the sortorder, view preferences, sortplug-in given from the |
|
96 * ini file |
|
97 * @param aSortOrder specifies the fields to use to sort the items in the view |
|
98 * @param aViewPreferences specifies the type of the contact item to be included in the view |
|
99 * @param aSortPlugin specifies a plug-in that will be used to compare view contacts when the view is sorted |
|
100 */ |
|
101 void CContactUtilitiesCollection::ConstructLocalViewL(const TDesC& aSortOrder, const TDesC& aViewPreferences, const TDesC& aSortPlugin, |
|
102 TBool aViewNotReady) |
|
103 { |
|
104 // Get Db and view collection reference |
|
105 CContactDatabase& cDb = DatabaseReference(); |
|
106 CContactViewCollection& cViewCollection = ViewCollectionReference(); |
|
107 // Construct a view event queue object |
|
108 CContactViewEventQueue* viewEventQueue = CContactViewEventQueue::NewL(); |
|
109 CleanupStack::PushL(viewEventQueue); |
|
110 |
|
111 TContactViewPreferences viewPreferences = ConvertStringToContactViewPreferencesL(aViewPreferences); |
|
112 RContactViewSortOrder sortOrder = ConvertStringToSortOrderL(aSortOrder); |
|
113 CContactLocalView* localView = NULL; |
|
114 // if sortplugin is specified in the ini, then create a local view object which contains sort plugin details. |
|
115 if ( aSortPlugin != KNullDesC() ) |
|
116 { |
|
117 HBufC8* sortPlugin = HBufC8::NewLC(aSortPlugin.Length()); |
|
118 sortPlugin->Des().Copy(aSortPlugin); |
|
119 TRAPD( err, localView = CContactLocalView::NewL(*viewEventQueue, cDb, sortOrder, viewPreferences, sortPlugin->Des())); |
|
120 if( err != KErrNone ) |
|
121 { |
|
122 BaseTestStepReference().ERR_PRINTF2(KErrSortPlugin, err); |
|
123 BaseTestStepReference().SetTestStepError(err); |
|
124 aViewNotReady = TRUE; |
|
125 } |
|
126 CleanupStack::Pop(sortPlugin); |
|
127 } |
|
128 else |
|
129 { |
|
130 localView = CContactLocalView::NewL(*viewEventQueue, cDb, sortOrder, viewPreferences); |
|
131 } |
|
132 |
|
133 CleanupStack::PushL(localView); |
|
134 if(!aViewNotReady) |
|
135 { |
|
136 WaitForViewReady(viewEventQueue); |
|
137 } |
|
138 if(localView!=NULL) |
|
139 { |
|
140 (cViewCollection.iArrayOfLocalViews).AppendL(localView); |
|
141 (cViewCollection.iArrayOfLocalViewEvents).AppendL(viewEventQueue); |
|
142 } |
|
143 CleanupStack::Pop(localView); |
|
144 CleanupStack::Pop(viewEventQueue); |
|
145 } |
|
146 |
|
147 /* |
|
148 * Get the data required for the construction of the remote view from the ini file and call the function |
|
149 * ConstructRemoteViewL to construct a remote view Object. |
|
150 * @param aSection ini section name |
|
151 */ |
|
152 void CContactUtilitiesCollection::GetDataAndConstructRemoteViewL(const TDesC& aSection) |
|
153 { |
|
154 TPtrC viewSortOrder; |
|
155 TPtrC viewPreferences; |
|
156 TPtrC remoteViewSortPlugin; |
|
157 TBool viewNotReady = EFalse; |
|
158 BaseTestStepReference().GetBoolFromConfig(aSection, KViewNotReady, viewNotReady); |
|
159 BaseTestStepReference().GetStringFromConfig(aSection, KViewSortOrder, viewSortOrder); |
|
160 BaseTestStepReference().GetStringFromConfig(aSection, KViewPreferences, viewPreferences); |
|
161 BaseTestStepReference().GetStringFromConfig(aSection, KRemoteViewSortPlugin, remoteViewSortPlugin); |
|
162 |
|
163 // Construct remote view by passing the data required for the construction |
|
164 ConstructRemoteViewL(viewSortOrder, viewPreferences, remoteViewSortPlugin, viewNotReady); |
|
165 } |
|
166 |
|
167 /* |
|
168 * Allocate and construct a remote view object based on the sortorder, view preferences, sortplug-in given from the |
|
169 * ini file |
|
170 * @param aSortOrder Specifies the fields to use to sort the items in the view |
|
171 * aram aViewPreferences Specifies the type of the contact item to be included in the view |
|
172 * aram aSortPlugin Specifies a plug-in that will be used to compare view contacts when the view is sorted |
|
173 */ |
|
174 void CContactUtilitiesCollection::ConstructRemoteViewL(const TDesC& aSortOrder, const TDesC& aViewPreferences, const TDesC& aSortPlugin, |
|
175 TBool aViewNotReady) |
|
176 { |
|
177 TContactViewPreferences viewPreferences = ConvertStringToContactViewPreferencesL(aViewPreferences); |
|
178 RContactViewSortOrder sortOrder = ConvertStringToSortOrderL(aSortOrder); |
|
179 CContactViewEventQueue* viewEventQueue = CContactViewEventQueue::NewL(); |
|
180 CleanupStack::PushL(viewEventQueue); |
|
181 |
|
182 CContactRemoteView* remoteView = NULL; |
|
183 |
|
184 CContactDatabase& cDb = DatabaseReference(); |
|
185 CContactViewCollection& cViewCollection = ViewCollectionReference(); |
|
186 if ( aSortPlugin != KNullDesC() ) |
|
187 { |
|
188 HBufC8* sortPlugin = HBufC8::NewLC(aSortPlugin.Length()); |
|
189 sortPlugin->Des().Copy(aSortPlugin); |
|
190 // Construct a remote view which contains sort plugin details. |
|
191 TRAPD( err, remoteView = CContactRemoteView::NewL(*viewEventQueue, cDb, sortOrder, viewPreferences, sortPlugin->Des())); |
|
192 CleanupStack::Pop(sortPlugin); |
|
193 if( err != KErrNone ) |
|
194 { |
|
195 BaseTestStepReference().ERR_PRINTF2(KErrSortPlugin, err); |
|
196 BaseTestStepReference().SetTestStepError(err); |
|
197 aViewNotReady = TRUE; |
|
198 } |
|
199 } |
|
200 else |
|
201 { |
|
202 remoteView = CContactRemoteView::NewL(*viewEventQueue, cDb, sortOrder, viewPreferences); |
|
203 } |
|
204 CleanupStack::PushL(remoteView); |
|
205 |
|
206 if(!aViewNotReady) |
|
207 { |
|
208 WaitForViewReady(viewEventQueue); |
|
209 } |
|
210 |
|
211 // Append the remote view and remote view events in the array which will be used for testing |
|
212 (cViewCollection.iArrayOfRemoteViewEvents).AppendL(viewEventQueue); |
|
213 (cViewCollection.iArrayOfRemoteViews).AppendL(remoteView); |
|
214 CleanupStack::Pop(remoteView); |
|
215 CleanupStack::Pop(viewEventQueue); |
|
216 } |
|
217 |
|
218 /* |
|
219 * Get the data required for the construction of the named remote view from the ini file and call the function |
|
220 * ConstructNamedRemoteView to construct a named remote view Object. |
|
221 * @param aSection ini section name |
|
222 */ |
|
223 void CContactUtilitiesCollection::GetDataAndConstructNamedRemoteViewL(const TDesC& aSection) |
|
224 { |
|
225 TPtrC name; |
|
226 TPtrC viewSortOrder; |
|
227 TPtrC viewPreferences; |
|
228 TPtrC namedViewSortPlugin; |
|
229 TBool viewNotReady = EFalse; |
|
230 BaseTestStepReference().GetBoolFromConfig(aSection, KViewNotReady, viewNotReady); |
|
231 BaseTestStepReference().GetStringFromConfig(aSection, KNamedRemoteViewName, name); |
|
232 BaseTestStepReference().GetStringFromConfig(aSection, KViewSortOrder, viewSortOrder); |
|
233 BaseTestStepReference().GetStringFromConfig(aSection, KViewPreferences, viewPreferences); |
|
234 BaseTestStepReference().GetStringFromConfig(aSection, KNamedViewSortPlugin, namedViewSortPlugin); |
|
235 |
|
236 // Construct a named remote view by passing the data required for the construction |
|
237 ConstructNamedRemoteViewL(name, viewSortOrder, viewPreferences, namedViewSortPlugin, viewNotReady); |
|
238 } |
|
239 |
|
240 /* |
|
241 * Allocate and construct a named remote view object based on the name, sortorder, view preferences, sortplug-in given from the |
|
242 * ini file |
|
243 * @param aName The name of the view object in the server |
|
244 * @param aSortOrder specifies the fields to use to sort the items in the view |
|
245 * @param aViewPreferences specifies the type of the contact item to be included in the view |
|
246 * @param aSortPlugin specifies a plug-in that will be used to compare view contacts when the view is sorted |
|
247 */ |
|
248 void CContactUtilitiesCollection::ConstructNamedRemoteViewL(const TDesC& aName, const TDesC& aSortOrder, const TDesC& aViewPreferences, |
|
249 const TDesC& aSortPlugin, TBool aViewNotReady) |
|
250 { |
|
251 TContactViewPreferences viewPreferences = ConvertStringToContactViewPreferencesL(aViewPreferences); |
|
252 RContactViewSortOrder sortOrder = ConvertStringToSortOrderL(aSortOrder); |
|
253 CContactViewEventQueue* viewEventQueue = CContactViewEventQueue::NewL(); |
|
254 CleanupStack::PushL(viewEventQueue); |
|
255 HBufC* name = HBufC::NewLC(aName.Length()); |
|
256 name->Des().Copy(aName); |
|
257 CContactNamedRemoteView* namedRemoteView = NULL; |
|
258 |
|
259 CContactDatabase& cDb = DatabaseReference(); |
|
260 CContactViewCollection& cViewCollection = ViewCollectionReference(); |
|
261 |
|
262 if ( aSortPlugin != KNullDesC() ) |
|
263 { |
|
264 HBufC8* sortPlugin = HBufC8::NewLC(aSortPlugin.Length()); |
|
265 sortPlugin->Des().Copy(aSortPlugin); |
|
266 // Construct a named remote view which contains sort plug-in details |
|
267 TRAPD( err, namedRemoteView = CContactNamedRemoteView::NewL(*viewEventQueue, name->Des(), cDb, sortOrder, viewPreferences, sortPlugin->Des())); |
|
268 CleanupStack::PopAndDestroy(sortPlugin); |
|
269 if( err != KErrNone ) |
|
270 { |
|
271 BaseTestStepReference().ERR_PRINTF2(KErrSortPlugin, err); |
|
272 BaseTestStepReference().SetTestStepError(err); |
|
273 aViewNotReady = TRUE; |
|
274 } |
|
275 } |
|
276 else |
|
277 { |
|
278 namedRemoteView = CContactNamedRemoteView::NewL(*viewEventQueue, name->Des(), cDb, sortOrder, viewPreferences); |
|
279 } |
|
280 CleanupStack::PushL(namedRemoteView); |
|
281 |
|
282 // If aViewNotReady is set to true then the view is not ready |
|
283 if(!aViewNotReady) |
|
284 { |
|
285 WaitForViewReady(viewEventQueue); |
|
286 } |
|
287 if(namedRemoteView != NULL) |
|
288 { |
|
289 (cViewCollection.iArrayOfNamedRemoteViewEvents).AppendL(viewEventQueue); |
|
290 // append the named remote view and named remote view events to the array which will be used for testing |
|
291 (cViewCollection.iArrayOfNamedRemoteViews).AppendL(namedRemoteView); |
|
292 } |
|
293 CleanupStack::Pop(namedRemoteView); |
|
294 CleanupStack::PopAndDestroy(name); |
|
295 CleanupStack::Pop(viewEventQueue); |
|
296 |
|
297 } |
|
298 |
|
299 /* |
|
300 * Get the data required for the construction of the find view from the ini file and call the function |
|
301 * ConstructFindView to construct a find view Object. |
|
302 * @param aSection ini section name |
|
303 */ |
|
304 void CContactUtilitiesCollection::GetDataAndConstructFindViewL(const TDesC& aSection) |
|
305 { |
|
306 TPtrC searchWords; |
|
307 TPtrC searchType; |
|
308 TBool viewNotReady = EFalse; |
|
309 BaseTestStepReference().GetBoolFromConfig(aSection, KViewNotReady, viewNotReady); |
|
310 BaseTestStepReference().GetStringFromConfig(aSection, KSearchWords, searchWords); |
|
311 BaseTestStepReference().GetStringFromConfig(aSection, KSearchType, searchType); |
|
312 |
|
313 // Get the underlying required view for the construction of find view |
|
314 CContactViewBase* viewBase = GetDesiredView(aSection); |
|
315 |
|
316 // Construct a find view by passing the data required for the construction |
|
317 ConstructFindViewL(searchWords, searchType, viewBase, viewNotReady); |
|
318 } |
|
319 |
|
320 /* |
|
321 * Allocate and constructs a find view object based on the search words and the search type given from the |
|
322 * ini file |
|
323 * @param aSearchWords The search terms |
|
324 * @param aSortPlugin specifies a plug-in that will be used to compare view contacts when the view is sorted |
|
325 * @param aSearchType The search type |
|
326 * @param aViewBase underlying view |
|
327 */ |
|
328 void CContactUtilitiesCollection::ConstructFindViewL(const TDesC& aSearchWords, const TDesC& aSearchType, |
|
329 CContactViewBase* aViewBase, TBool aViewNotReady) |
|
330 { |
|
331 RArray<TPtrC> searchList; |
|
332 CleanupClosePushL(searchList); |
|
333 TokenizeStringL(aSearchWords, searchList); |
|
334 |
|
335 // allocate an array to store the search words |
|
336 CPtrCArray* findWords = new(ELeave) CPtrCArray(3); |
|
337 CleanupStack::PushL(findWords); |
|
338 for ( TInt i = 0; i < searchList.Count(); ++i ) |
|
339 { |
|
340 findWords->AppendL(searchList[i]); |
|
341 } |
|
342 |
|
343 CContactViewBase::TSearchType searchType = GetSearchType(aSearchType); |
|
344 // Construct an view event queue object |
|
345 CContactViewEventQueue* viewEventQueue = CContactViewEventQueue::NewL(); |
|
346 CleanupStack::PushL(viewEventQueue); |
|
347 CContactFindView* findView; |
|
348 CContactDatabase& cDb = DatabaseReference(); |
|
349 CContactViewCollection& cViewCollection = ViewCollectionReference(); |
|
350 if ( aSearchType != KNullDesC() ) |
|
351 { |
|
352 // Construct a find view which contains search type |
|
353 findView = CContactFindView::NewL(cDb, *aViewBase, *viewEventQueue, findWords, searchType); |
|
354 } |
|
355 else |
|
356 { |
|
357 findView = CContactFindView::NewL(cDb, *aViewBase, *viewEventQueue, findWords); |
|
358 } |
|
359 CleanupStack::PushL(findView); |
|
360 |
|
361 // If aViewNotReady is set to true then the view is not ready |
|
362 if(!aViewNotReady) |
|
363 { |
|
364 WaitForViewReady(viewEventQueue); |
|
365 } |
|
366 |
|
367 // appends the find view and find view events to the array which will be used for testing |
|
368 if(findView != NULL) |
|
369 { |
|
370 (cViewCollection.iArrayOfFindViewEvents).AppendL(viewEventQueue); |
|
371 (cViewCollection.iArrayOfFindViews).AppendL(findView); |
|
372 } |
|
373 CleanupStack::Pop(findView); |
|
374 CleanupStack::Pop(viewEventQueue); |
|
375 CleanupStack::PopAndDestroy(findWords); |
|
376 CleanupStack::PopAndDestroy(&searchList); |
|
377 } |
|
378 |
|
379 /* |
|
380 * Get the data required for the construction of the local view from the ini file and call the function |
|
381 * ConstructGroupView to construct a group view Object. |
|
382 * @param aSection ini section name |
|
383 */ |
|
384 void CContactUtilitiesCollection::GetDataAndConstructGroupViewL(const TDesC& aSection) |
|
385 { |
|
386 TPtrC groupType; |
|
387 TPtrC groupName; |
|
388 TInt groupId = -1; |
|
389 TBool viewNotReady = EFalse; |
|
390 TInt groupViewVersion = 0; |
|
391 BaseTestStepReference().GetBoolFromConfig(aSection, KViewNotReady, viewNotReady); |
|
392 BaseTestStepReference().GetStringFromConfig(aSection, KGroupType, groupType); |
|
393 BaseTestStepReference().GetStringFromConfig(aSection, KGroupName, groupName); |
|
394 BaseTestStepReference().GetIntFromConfig(aSection, KGroupId, groupId); |
|
395 BaseTestStepReference().GetIntFromConfig(aSection, KGroupVersion, groupViewVersion); |
|
396 |
|
397 // Get the underlying view for the construction of group view |
|
398 CContactViewBase* viewBase = GetDesiredView(aSection); |
|
399 |
|
400 // Construct the group view by passing the data required for the construction |
|
401 ConstructGroupViewL(groupType, groupName, groupId, viewBase, viewNotReady, groupViewVersion); |
|
402 } |
|
403 |
|
404 /* |
|
405 * Allocate and construct a group view object based on the grouptype, groupid and groupname given from the |
|
406 * ini file |
|
407 * @param aGroupType The group Type |
|
408 * @param aGroupName the group name |
|
409 * @param aGroupId The Id of the contact group |
|
410 * @param aViewBase underlying view |
|
411 */ |
|
412 void CContactUtilitiesCollection::ConstructGroupViewL(const TDesC& aGroupType, const TDesC& aGroupName, const TInt& aGroupId, |
|
413 CContactViewBase* aViewBase, TBool aViewNotReady, TInt& aGroupViewVersion) |
|
414 { |
|
415 // Get the group type required for the construction of group view |
|
416 CContactGroupView::TGroupType groupType = GetGroupType(aGroupType); |
|
417 CContactViewEventQueue* viewEventQueue = CContactViewEventQueue::NewL(); |
|
418 CleanupStack::PushL(viewEventQueue); |
|
419 CContactGroupView* groupView = NULL; |
|
420 CContactDatabase& cDb = DatabaseReference(); |
|
421 CContactViewCollection& cViewCollection = ViewCollectionReference(); |
|
422 //Construct a group view using version 1 |
|
423 if(aGroupViewVersion == 1) |
|
424 { |
|
425 if( aGroupName != KNullDesC() ) |
|
426 { |
|
427 // Construct a group view which contains the details of group name |
|
428 TRAPD(err, groupView = CContactGroupView::NewL(cDb, *aViewBase, *viewEventQueue, aGroupName, groupType)); |
|
429 if( err != KErrNone) |
|
430 { |
|
431 BaseTestStepReference().SetTestStepError(err); |
|
432 BaseTestStepReference().SetTestStepResult(EFail); |
|
433 aViewNotReady = ETrue; |
|
434 } |
|
435 } |
|
436 if(aGroupId > 0) |
|
437 { |
|
438 TRAPD(err, groupView = CContactGroupView::NewL(cDb, *aViewBase, *viewEventQueue, aGroupId, groupType)); |
|
439 if( err != KErrNone) |
|
440 { |
|
441 BaseTestStepReference().SetTestStepError(err); |
|
442 BaseTestStepReference().SetTestStepResult(EFail); |
|
443 aViewNotReady = ETrue; |
|
444 } |
|
445 } |
|
446 } |
|
447 else |
|
448 {//Construct a group view using version 2 |
|
449 if( aGroupName != KNullDesC() ) |
|
450 { |
|
451 // Construct a group view which contains the details of group name |
|
452 TRAPD(err, groupView =CContactGroupView::NewL(*aViewBase, cDb, *viewEventQueue, aGroupName, groupType)); |
|
453 if( err != KErrNone) |
|
454 { |
|
455 BaseTestStepReference().SetTestStepError(err); |
|
456 BaseTestStepReference().SetTestStepResult(EFail); |
|
457 aViewNotReady = ETrue; |
|
458 } |
|
459 } |
|
460 if(aGroupId > 0) |
|
461 { |
|
462 TRAPD(err, groupView = CContactGroupView::NewL(*aViewBase, cDb, *viewEventQueue, aGroupId, groupType)); |
|
463 if( err != KErrNone) |
|
464 { |
|
465 BaseTestStepReference().SetTestStepError(err); |
|
466 BaseTestStepReference().SetTestStepResult(EFail); |
|
467 aViewNotReady = ETrue; |
|
468 } |
|
469 } |
|
470 |
|
471 } |
|
472 |
|
473 CleanupStack::PushL(groupView); |
|
474 |
|
475 if(!aViewNotReady) |
|
476 { |
|
477 WaitForViewReady(viewEventQueue); |
|
478 } |
|
479 // append the group view to the array which will be used for multiple view access tests |
|
480 if( groupView != NULL ) |
|
481 { |
|
482 (cViewCollection.iArrayOfGroupViews).AppendL(groupView); |
|
483 (cViewCollection.iArrayOfGroupViewEvents).AppendL(viewEventQueue); |
|
484 } |
|
485 CleanupStack::Pop(groupView); |
|
486 CleanupStack::Pop(viewEventQueue); |
|
487 } |
|
488 |
|
489 /* |
|
490 * Get the data required for the construction of the local view from the ini file and call the function |
|
491 * ConstructFilteredView to construct a filtered view Object. |
|
492 * @param aSection ini section name |
|
493 */ |
|
494 void CContactUtilitiesCollection::GetDataAndConstructFilteredViewL(const TDesC& aSection) |
|
495 { |
|
496 TPtrC viewFilter; |
|
497 TBool viewNotReady = EFalse; |
|
498 BaseTestStepReference().GetBoolFromConfig(aSection, KViewNotReady, viewNotReady); |
|
499 BaseTestStepReference().GetStringFromConfig(aSection, KViewFilter, viewFilter); |
|
500 // Get the underlying view required for the construction of filtered view |
|
501 CContactViewBase* viewBase = GetDesiredView(aSection); |
|
502 |
|
503 // construct the filtered view by passing the data required for the construction |
|
504 ConstructFilteredViewL(viewFilter, viewBase, viewNotReady); |
|
505 } |
|
506 |
|
507 /* |
|
508 * Allocate and constructs a filter view object based on the filter type given from the |
|
509 * ini file |
|
510 * @param aViewFilter The filter to use. |
|
511 * @param aViewBase underlying view |
|
512 */ |
|
513 void CContactUtilitiesCollection::ConstructFilteredViewL(const TDesC& aViewFilter, CContactViewBase* aViewBase, TBool aViewNotReady) |
|
514 { |
|
515 // Get the filter type required for the construction of filtered view |
|
516 CContactDatabase::TContactViewFilter viewFilter = GetContactViewFilterL(aViewFilter); |
|
517 CContactViewEventQueue* viewEventQueue = CContactViewEventQueue::NewL(); |
|
518 CleanupStack::PushL(viewEventQueue); |
|
519 CContactDatabase& cDb = DatabaseReference(); |
|
520 CContactViewCollection& cViewCollection = ViewCollectionReference(); |
|
521 CContactFilteredView* filteredView = CContactFilteredView::NewL(*viewEventQueue, cDb, *aViewBase, viewFilter); |
|
522 CleanupStack::PushL(filteredView); |
|
523 |
|
524 if(!aViewNotReady) |
|
525 { |
|
526 WaitForViewReady(viewEventQueue); |
|
527 } |
|
528 // append the filtered view and its events to the array which will be used for testing |
|
529 if(filteredView !=NULL) |
|
530 { |
|
531 (cViewCollection.iArrayOfFilteredViews).AppendL(filteredView); |
|
532 (cViewCollection.iArrayOfFilteredViewEvents).AppendL(viewEventQueue); |
|
533 } |
|
534 CleanupStack::Pop(filteredView); |
|
535 CleanupStack::Pop(viewEventQueue); |
|
536 } |
|
537 |
|
538 /* |
|
539 * Get the data required for the construction of the local view from the ini file and call the function |
|
540 * ConstructConcatenatedView to construct a concatenated view Object. |
|
541 * @param aSection ini section |
|
542 */ |
|
543 void CContactUtilitiesCollection::ConstructConcatenatedViewL(const TDesC& aSection) |
|
544 { |
|
545 // Get the component views required for the construction of concatenated views |
|
546 RPointerArray<CContactViewBase>& arrayOfViews = GetComponentViewsL(aSection); |
|
547 CleanupClosePushL(arrayOfViews); |
|
548 CContactViewEventQueue* viewEventQueue = CContactViewEventQueue::NewL(); |
|
549 CleanupStack::PushL(viewEventQueue); |
|
550 |
|
551 CContactDatabase& cDb = DatabaseReference(); |
|
552 CContactViewCollection& cViewCollection = ViewCollectionReference(); |
|
553 |
|
554 CContactConcatenatedView* concatenatedView = CContactConcatenatedView::NewL(*viewEventQueue, cDb, arrayOfViews); |
|
555 CleanupStack::PushL(concatenatedView); |
|
556 |
|
557 TBool viewNotReady = EFalse; |
|
558 BaseTestStepReference().GetBoolFromConfig(aSection, KViewNotReady, viewNotReady); |
|
559 |
|
560 if(!viewNotReady) |
|
561 { |
|
562 WaitForViewReady(viewEventQueue); |
|
563 } |
|
564 if(concatenatedView != NULL) |
|
565 { |
|
566 // append the concatenated view to the array which will be used for multiple view access tests |
|
567 (cViewCollection.iArrayOfConcatenatedViews).AppendL(concatenatedView); |
|
568 (cViewCollection.iArrayOfConcatenatedViewEvents).AppendL(viewEventQueue); |
|
569 } |
|
570 CleanupStack::Pop(concatenatedView); |
|
571 CleanupStack::Pop(viewEventQueue); |
|
572 CleanupStack::PopAndDestroy(&arrayOfViews); |
|
573 |
|
574 } |
|
575 |
|
576 /* |
|
577 * Get the data required for the construction of the local view from the ini file and call the function |
|
578 * ConstructSubView to construct a sub view Object. |
|
579 * @param aSection ini section name |
|
580 */ |
|
581 void CContactUtilitiesCollection::GetDataAndConstructSubViewL(const TDesC& aSection) |
|
582 { |
|
583 TPtrC lowerBoundary; |
|
584 TPtrC higherBoundary; |
|
585 TPtrC boundary; |
|
586 TBool viewNotReady = EFalse; |
|
587 BaseTestStepReference().GetBoolFromConfig(aSection, KViewNotReady, viewNotReady); |
|
588 BaseTestStepReference().GetStringFromConfig(aSection, KLowerBoundary, lowerBoundary); |
|
589 BaseTestStepReference().GetStringFromConfig(aSection, KHigherBoundary, higherBoundary); |
|
590 BaseTestStepReference().GetStringFromConfig(aSection, KBoundary, boundary); |
|
591 |
|
592 // Get the underlying view required for the construction of the sub view |
|
593 CContactViewBase* viewBase = GetDesiredView(aSection); |
|
594 // Construct the sub view by passing the data from the ini file |
|
595 ConstructSubViewL(lowerBoundary, higherBoundary, boundary, viewBase, viewNotReady); |
|
596 } |
|
597 |
|
598 /* |
|
599 * Allocate and constructs a sub view object based on the lower and higher boundary specified in the |
|
600 * ini file |
|
601 * @param aLowerBoundary A string containing the sub view's lower boundary criteria |
|
602 * @param aHigherBoundary A string containing the sub view's higher boundary criteria |
|
603 * @param aBoundary A string containing the sub-view criteria |
|
604 * @param aViewBase underlying view |
|
605 */ |
|
606 void CContactUtilitiesCollection::ConstructSubViewL(const TDesC& aLowerBoundary, const TDesC& aHigherBoundary, const TDesC& aBoundary, |
|
607 CContactViewBase* aViewBase, TBool aViewNotReady) |
|
608 { |
|
609 CContactViewEventQueue* viewEventQueue = CContactViewEventQueue::NewL(); |
|
610 CleanupStack::PushL(viewEventQueue); |
|
611 CContactSubView* subView; |
|
612 CContactDatabase& cDb = DatabaseReference(); |
|
613 CContactViewCollection& cViewCollection = ViewCollectionReference(); |
|
614 |
|
615 if ( aLowerBoundary != KNullDesC() || aHigherBoundary != KNullDesC() ) |
|
616 { |
|
617 // Construct a sub view which contains both the higher and lower boundary |
|
618 subView = CContactSubView::NewL(*viewEventQueue, cDb, *aViewBase, aLowerBoundary, aHigherBoundary); |
|
619 } |
|
620 else |
|
621 { |
|
622 subView = CContactSubView::NewL(*viewEventQueue, cDb, *aViewBase, aBoundary); |
|
623 } |
|
624 CleanupStack::PushL(subView); |
|
625 |
|
626 if(!aViewNotReady) |
|
627 { |
|
628 WaitForViewReady(viewEventQueue); |
|
629 } |
|
630 if(subView != NULL) |
|
631 { |
|
632 // append the sub view to the array which will be used for multiple view access tests |
|
633 (cViewCollection.iArrayOfSubViews).AppendL(subView); |
|
634 (cViewCollection.iArrayOfSubViewEvents).AppendL(viewEventQueue); |
|
635 } |
|
636 CleanupStack::Pop(subView); |
|
637 CleanupStack::Pop(viewEventQueue); |
|
638 } |
|
639 |
|
640 |
|
641 /* |
|
642 * Get the underlying view type and index required for the views like find view, filtered view, group view, |
|
643 * and sub view from the ini file and get the view of the specified type for that particular index |
|
644 * @param aSection ini section |
|
645 * @return CContactViewBase* |
|
646 */ |
|
647 CContactViewBase* CContactUtilitiesCollection::GetDesiredView(const TDesC& aSection) |
|
648 { |
|
649 TPtrC viewBase; |
|
650 TInt index = -1; |
|
651 BaseTestStepReference().GetStringFromConfig(aSection, KViewBase, viewBase); |
|
652 BaseTestStepReference().GetIntFromConfig(aSection, KIndexOfViews, index); |
|
653 |
|
654 CContactViewCollection& cViewCollection = ViewCollectionReference(); |
|
655 CContactViewBase* contactViewBase = NULL; |
|
656 // Based on the view type specified in the ini file, get the underlying view for the specified index |
|
657 if ( viewBase.Compare(KLocalView) == 0 ) |
|
658 { |
|
659 contactViewBase = cViewCollection.GetDesiredLocalView(index); |
|
660 } |
|
661 else if ( viewBase.Compare(KRemoteView) == 0 ) |
|
662 { |
|
663 contactViewBase = cViewCollection.GetDesiredRemoteView(index); |
|
664 } |
|
665 else if ( viewBase.Compare(KNamedRemoteView) == 0 ) |
|
666 { |
|
667 contactViewBase = cViewCollection.GetDesiredNamedRemoteView(index); |
|
668 } |
|
669 else if ( viewBase.Compare(KFindView) == 0 ) |
|
670 { |
|
671 contactViewBase = cViewCollection.GetDesiredFindView(index); |
|
672 } |
|
673 else if ( viewBase.Compare(KFilteredView) == 0 ) |
|
674 { |
|
675 contactViewBase = cViewCollection.GetDesiredFilteredView(index); |
|
676 } |
|
677 else if ( viewBase.Compare(KGroupView) == 0 ) |
|
678 { |
|
679 contactViewBase = cViewCollection.GetDesiredGroupView(index); |
|
680 } |
|
681 else if ( viewBase.Compare(KConcatenatedView) == 0 ) |
|
682 { |
|
683 contactViewBase= cViewCollection.GetDesiredConcatenatedView(index); |
|
684 } |
|
685 else if ( viewBase.Compare(KSubView) == 0 ) |
|
686 { |
|
687 contactViewBase = cViewCollection.GetDesiredSubView(index); |
|
688 } |
|
689 return contactViewBase; |
|
690 } |
|
691 |
|
692 /* |
|
693 * Get the component views required for construction of the concatenated view. The component views can be of any view |
|
694 * type like local view, remote view, named remote view, find view, filtered view, group view and sub view |
|
695 * @param aSection ini section |
|
696 * @return RPointerArray<CContactViewBase>& |
|
697 */ |
|
698 RPointerArray<CContactViewBase>& CContactUtilitiesCollection::GetComponentViewsL(const TDesC& aSection) |
|
699 { |
|
700 TPtrC componentViews; |
|
701 BaseTestStepReference().GetStringFromConfig(aSection, KComponentViews, componentViews); |
|
702 CContactViewCollection& cViewCollection = ViewCollectionReference(); |
|
703 TBuf<KMaxLengthString> field; |
|
704 field.Zero(); |
|
705 field.Append(KIndexOfView); |
|
706 TInt indexOfView = -1; |
|
707 |
|
708 RArray<TPtrC> views; |
|
709 CleanupClosePushL(views); |
|
710 TokenizeStringL(componentViews, views); |
|
711 // Iterate through the list of component views given in the ini file |
|
712 for ( TInt i = 0; i < views.Count(); ++i ) |
|
713 { |
|
714 field.AppendNum(i); |
|
715 BaseTestStepReference().GetIntFromConfig(aSection, field, indexOfView); |
|
716 CContactViewBase* viewBase; |
|
717 // Append the view in the array iArrayofViewBase which is of type CContactViewBase |
|
718 if ( views[i].Compare(KLocalView) == 0 ) |
|
719 { |
|
720 viewBase = cViewCollection.GetDesiredLocalView(indexOfView); |
|
721 (cViewCollection.iArrayOfViewBase).AppendL(viewBase); |
|
722 } |
|
723 else if ( views[i].Compare(KRemoteView) == 0 ) |
|
724 { |
|
725 viewBase = cViewCollection.GetDesiredRemoteView(indexOfView); |
|
726 (cViewCollection.iArrayOfViewBase).AppendL(viewBase); |
|
727 } |
|
728 else if ( views[i].Compare(KNamedRemoteView) == 0 ) |
|
729 { |
|
730 viewBase = cViewCollection.GetDesiredNamedRemoteView(indexOfView); |
|
731 (cViewCollection.iArrayOfViewBase).AppendL(viewBase); |
|
732 } |
|
733 else if ( views[i].Compare(KFindView) == 0 ) |
|
734 { |
|
735 viewBase = cViewCollection.GetDesiredFindView(indexOfView); |
|
736 (cViewCollection.iArrayOfViewBase).AppendL(viewBase); |
|
737 } |
|
738 else if ( views[i].Compare(KFilteredView) == 0 ) |
|
739 { |
|
740 viewBase = cViewCollection.GetDesiredFilteredView(indexOfView); |
|
741 (cViewCollection.iArrayOfViewBase).AppendL(viewBase); |
|
742 } |
|
743 else if ( views[i].Compare(KGroupView) == 0 ) |
|
744 { |
|
745 viewBase = cViewCollection.GetDesiredGroupView(indexOfView); |
|
746 (cViewCollection.iArrayOfViewBase).AppendL(viewBase); |
|
747 } |
|
748 else if ( views[i].Compare(KConcatenatedView) == 0 ) |
|
749 { |
|
750 viewBase = cViewCollection.GetDesiredConcatenatedView(indexOfView); |
|
751 (cViewCollection.iArrayOfViewBase).AppendL(viewBase); |
|
752 } |
|
753 else if ( views[i].Compare(KSubView) == 0 ) |
|
754 { |
|
755 viewBase = cViewCollection.GetDesiredSubView(indexOfView); |
|
756 (cViewCollection.iArrayOfViewBase).AppendL(viewBase); |
|
757 } |
|
758 } |
|
759 CleanupStack::PopAndDestroy(&views); |
|
760 return (cViewCollection.iArrayOfViewBase); |
|
761 } |
|
762 |
|
763 /* |
|
764 * Delete the database based on the boolean variable set in the ini file |
|
765 * @param aDeleteDataBase Boolean value that decides to delete the database |
|
766 * @param aDbName database name |
|
767 */ |
|
768 void CContactUtilitiesCollection::DeleteDataBase(TBool aDeleteDataBase, const TDesC& aDbName) |
|
769 { |
|
770 // If aDeleteDataBase is set to true, then delete the database |
|
771 if ( aDeleteDataBase ) |
|
772 { |
|
773 TRAPD(err, CContactDatabase::DeleteDatabaseL(aDbName) ); |
|
774 if ( err != KErrNone ) |
|
775 { |
|
776 BaseTestStepReference().ERR_PRINTF1(KErrInDeleteDataBase); |
|
777 BaseTestStepReference().SetTestStepError(err); |
|
778 BaseTestStepReference().SetTestStepResult(EFail); |
|
779 } |
|
780 } |
|
781 } |
|
782 |
|
783 /* |
|
784 * Convert the string of type uid which is used for the construction of the views. Commonly used sort fields are only supported |
|
785 * if more is required, can be added in the loop. |
|
786 * @param aSortOrder sort order passed in the ini file |
|
787 * @return RContactViewSortOrder |
|
788 */ |
|
789 RContactViewSortOrder CContactUtilitiesCollection::ConvertStringToSortOrderL(const TDesC& aSortOrderString) |
|
790 { |
|
791 RContactViewSortOrder sortOrder; |
|
792 RArray<TPtrC> sortOrderList; |
|
793 CleanupClosePushL(sortOrderList); |
|
794 TokenizeStringL(aSortOrderString, sortOrderList); |
|
795 |
|
796 for ( TInt i = 0; i < sortOrderList.Count(); ++i ) |
|
797 { |
|
798 TUid uid = GetContactFieldType(sortOrderList[i]); |
|
799 sortOrder.AppendL(uid); |
|
800 } |
|
801 |
|
802 CleanupStack::PopAndDestroy(&sortOrderList); |
|
803 return sortOrder; |
|
804 } |
|
805 |
|
806 /** |
|
807 * Retrieve the contact field uid information based on the contact field information specified in string format |
|
808 * @param aContactFieldString - Contact field information in String format |
|
809 * @return TUid - The contact field information in uid format |
|
810 */ |
|
811 |
|
812 TUid CContactUtilitiesCollection::GetContactFieldType(const TDesC& aContactFieldString) |
|
813 { |
|
814 |
|
815 _LIT(KAddress, "Address"); |
|
816 _LIT(KPostOffice, "PostOffice"); |
|
817 _LIT(KExtendedAddress, "ExtendedAddress"); |
|
818 _LIT(KLocality, "Locality"); |
|
819 _LIT(KRegion, "Region"); |
|
820 _LIT(KPostCode, "PostCode"); |
|
821 _LIT(KCountry, "Country"); |
|
822 _LIT(KCompanyName, "CompanyName"); |
|
823 _LIT(KCompanyNamePronunciation, "CompanyNamePronunciation"); |
|
824 _LIT(KPhoneNumber, "PhoneNumber"); |
|
825 _LIT(KGivenName, "GivenName"); |
|
826 _LIT(KFamilyName, "FamilyName"); |
|
827 _LIT(KGivenNamePronunciation, "GivenNamePronunciation"); |
|
828 _LIT(KFamilyNamePronunciation, "FamilyNamePronunciation"); |
|
829 _LIT(KAdditionalName, "AdditionalName"); |
|
830 _LIT(KSuffixName, "SuffixName"); |
|
831 _LIT(KPrefixName, "PrefixName"); |
|
832 _LIT(KHidden, "Hidden"); |
|
833 _LIT(KEMail, "EMail"); |
|
834 _LIT(KMsg, "Msg"); |
|
835 _LIT(KSms, "Sms"); |
|
836 _LIT(KFax, "Fax"); |
|
837 _LIT(KNote, "Note"); |
|
838 _LIT(KBirthday, "Birthday"); |
|
839 _LIT(KUrl, "Url"); |
|
840 _LIT(KPicture, "Picture"); |
|
841 _LIT(KRingTone, "RingTone"); |
|
842 _LIT(KDTMF, "DTMF"); |
|
843 _LIT(KVoiceDialField, "VoiceDialField"); |
|
844 _LIT(KJobTitle, "JobTitle"); |
|
845 _LIT(KICCSlot, "ICCSlot"); |
|
846 _LIT(KICCPhonebook, "ICCPhonebook"); |
|
847 _LIT(KICCGroup, "ICCGroup"); |
|
848 _LIT(KIMAddress, "IMAddress"); |
|
849 _LIT(KSecondName, "SecondName"); |
|
850 _LIT(KSIPID, "SIPID"); |
|
851 _LIT(KAssistant, "Assistant"); |
|
852 _LIT(KAnniversary, "Anniversary"); |
|
853 _LIT(KSpouse, "Spouse"); |
|
854 _LIT(KChildren, "Children"); |
|
855 _LIT(KClass, "Class"); |
|
856 _LIT(KDepartmentName, "DepartmentName"); |
|
857 |
|
858 TUid uid; |
|
859 |
|
860 if ( aContactFieldString.Compare(KAddress) == 0) |
|
861 { |
|
862 uid = KUidContactFieldAddress; |
|
863 } |
|
864 else if ( aContactFieldString.Compare(KPostOffice) == 0) |
|
865 { |
|
866 uid = KUidContactFieldPostOffice; |
|
867 } |
|
868 else if ( aContactFieldString.Compare(KExtendedAddress) == 0) |
|
869 { |
|
870 uid = KUidContactFieldExtendedAddress; |
|
871 } |
|
872 else if ( aContactFieldString.Compare(KLocality) == 0) |
|
873 { |
|
874 uid = KUidContactFieldLocality; |
|
875 } |
|
876 else if ( aContactFieldString.Compare(KRegion) == 0) |
|
877 { |
|
878 uid = KUidContactFieldRegion; |
|
879 } |
|
880 else if ( aContactFieldString.Compare(KPostCode) == 0) |
|
881 { |
|
882 uid = KUidContactFieldPostcode; |
|
883 } |
|
884 else if ( aContactFieldString.Compare(KCountry) == 0) |
|
885 { |
|
886 uid = KUidContactFieldCountry; |
|
887 } |
|
888 else if ( aContactFieldString.Compare(KCompanyName) == 0) |
|
889 { |
|
890 uid = KUidContactFieldCompanyName; |
|
891 } |
|
892 else if ( aContactFieldString.Compare(KCompanyNamePronunciation) == 0) |
|
893 { |
|
894 uid = KUidContactFieldCompanyNamePronunciation; |
|
895 } |
|
896 else if ( aContactFieldString.Compare(KPhoneNumber) == 0) |
|
897 { |
|
898 uid = KUidContactFieldPhoneNumber; |
|
899 } |
|
900 else if ( aContactFieldString.Compare(KGivenName) == 0) |
|
901 { |
|
902 uid = KUidContactFieldGivenName; |
|
903 } |
|
904 else if ( aContactFieldString.Compare(KFamilyName) == 0) |
|
905 { |
|
906 uid = KUidContactFieldFamilyName; |
|
907 } |
|
908 else if ( aContactFieldString.Compare(KGivenNamePronunciation) == 0) |
|
909 { |
|
910 uid = KUidContactFieldGivenNamePronunciation; |
|
911 } |
|
912 else if ( aContactFieldString.Compare(KFamilyNamePronunciation) == 0) |
|
913 { |
|
914 uid = KUidContactFieldFamilyNamePronunciation; |
|
915 } |
|
916 else if ( aContactFieldString.Compare(KAdditionalName) == 0) |
|
917 { |
|
918 uid = KUidContactFieldAdditionalName; |
|
919 } |
|
920 else if ( aContactFieldString.Compare(KSuffixName) == 0) |
|
921 { |
|
922 uid = KUidContactFieldSuffixName; |
|
923 } |
|
924 else if ( aContactFieldString.Compare(KPrefixName) == 0) |
|
925 { |
|
926 uid = KUidContactFieldPrefixName; |
|
927 } |
|
928 else if ( aContactFieldString.Compare(KHidden) == 0) |
|
929 { |
|
930 uid = KUidContactFieldHidden; |
|
931 } |
|
932 else if ( aContactFieldString.Compare(KEMail) == 0) |
|
933 { |
|
934 uid = KUidContactFieldEMail; |
|
935 } |
|
936 else if ( aContactFieldString.Compare(KMsg) == 0) |
|
937 { |
|
938 uid = KUidContactFieldMsg; |
|
939 } |
|
940 else if ( aContactFieldString.Compare(KSms) == 0) |
|
941 { |
|
942 uid = KUidContactFieldSms; |
|
943 } |
|
944 else if ( aContactFieldString.Compare(KFax) == 0) |
|
945 { |
|
946 uid = KUidContactFieldFax; |
|
947 } |
|
948 else if ( aContactFieldString.Compare(KNote) == 0) |
|
949 { |
|
950 uid = KUidContactFieldNote; |
|
951 } |
|
952 else if ( aContactFieldString.Compare(KBirthday) == 0) |
|
953 { |
|
954 uid = KUidContactFieldBirthday; |
|
955 } |
|
956 else if ( aContactFieldString.Compare(KUrl) == 0) |
|
957 { |
|
958 uid = KUidContactFieldUrl; |
|
959 } |
|
960 else if ( aContactFieldString.Compare(KPicture) == 0) |
|
961 { |
|
962 uid = KUidContactFieldPicture; |
|
963 } |
|
964 else if ( aContactFieldString.Compare(KRingTone) == 0) |
|
965 { |
|
966 uid = KUidContactFieldRingTone; |
|
967 } |
|
968 else if ( aContactFieldString.Compare(KDTMF) == 0) |
|
969 { |
|
970 uid = KUidContactFieldDTMF; |
|
971 } |
|
972 else if ( aContactFieldString.Compare(KVoiceDialField) == 0) |
|
973 { |
|
974 uid = KUidContactsVoiceDialField; |
|
975 } |
|
976 else if ( aContactFieldString.Compare(KJobTitle) == 0) |
|
977 { |
|
978 uid = KUidContactFieldJobTitle; |
|
979 } |
|
980 else if ( aContactFieldString.Compare(KICCSlot) == 0) |
|
981 { |
|
982 uid = KUidContactFieldICCSlot; |
|
983 } |
|
984 else if ( aContactFieldString.Compare(KICCPhonebook) == 0) |
|
985 { |
|
986 uid = KUidContactFieldICCPhonebook; |
|
987 } |
|
988 else if ( aContactFieldString.Compare(KICCGroup) == 0) |
|
989 { |
|
990 uid = KUidContactFieldICCGroup; |
|
991 } |
|
992 else if ( aContactFieldString.Compare(KIMAddress) == 0) |
|
993 { |
|
994 uid = KUidContactFieldIMAddress; |
|
995 } |
|
996 else if ( aContactFieldString.Compare(KSecondName) == 0) |
|
997 { |
|
998 uid = KUidContactFieldSecondName; |
|
999 } |
|
1000 else if ( aContactFieldString.Compare(KSIPID) == 0) |
|
1001 { |
|
1002 uid = KUidContactFieldSIPID; |
|
1003 } |
|
1004 else if ( aContactFieldString.Compare(KAssistant) == 0) |
|
1005 { |
|
1006 uid = KUidContactFieldAssistant; |
|
1007 } |
|
1008 else if ( aContactFieldString.Compare(KAnniversary) == 0) |
|
1009 { |
|
1010 uid = KUidContactFieldAnniversary; |
|
1011 } |
|
1012 else if ( aContactFieldString.Compare(KSpouse) == 0) |
|
1013 { |
|
1014 uid = KUidContactFieldSpouse; |
|
1015 } |
|
1016 else if ( aContactFieldString.Compare(KChildren) == 0) |
|
1017 { |
|
1018 uid = KUidContactFieldChildren; |
|
1019 } |
|
1020 else if ( aContactFieldString.Compare(KClass) == 0) |
|
1021 { |
|
1022 uid = KUidContactFieldClass; |
|
1023 } |
|
1024 else if ( aContactFieldString.Compare(KDepartmentName) == 0) |
|
1025 { |
|
1026 uid = KUidContactFieldDepartmentName; |
|
1027 } |
|
1028 else |
|
1029 { |
|
1030 uid = KUidContactFieldNone; |
|
1031 } |
|
1032 |
|
1033 return uid; |
|
1034 } |
|
1035 |
|
1036 /* |
|
1037 * Get the view preferences from the ini and convert it of type TContactViewPreferences |
|
1038 * @param aViewPreferences viewPreferences passed from the ini file |
|
1039 * @return TContactViewPreferences |
|
1040 */ |
|
1041 TContactViewPreferences CContactUtilitiesCollection::ConvertStringToContactViewPreferencesL(const TDesC& aViewPreferences) |
|
1042 { |
|
1043 _LIT(KContactsOnly, "contactsonly"); |
|
1044 _LIT(KGroupsOnly, "groupsonly"); |
|
1045 _LIT(KContactsAndGroups, "contactsandgroups"); |
|
1046 _LIT(KIgnoreUnsorted, "ignoreunsorted"); |
|
1047 _LIT(KUnsortedAtbeginning, "EUnsortedAtBeginning"); |
|
1048 _LIT(KUnsortedAtEnd, "EUnsortedAtEnd"); |
|
1049 _LIT(KSingleWhiteSpace, "ESingleWhiteSpaceIsEmptyField"); |
|
1050 _LIT(KICCEntries, "EICCEntriesOnly"); |
|
1051 _LIT(KICCEntriesAndContacts, "EICCEntriesAndContacts"); |
|
1052 |
|
1053 TUint viewPreferences = 0x00000000; |
|
1054 |
|
1055 RArray<TPtrC> list; |
|
1056 CleanupClosePushL(list); |
|
1057 TokenizeStringL(aViewPreferences, list); |
|
1058 |
|
1059 for(TInt i = 0; i < list.Count(); ++i) |
|
1060 { |
|
1061 if( list[i] == KContactsOnly) |
|
1062 { |
|
1063 viewPreferences |= EContactsOnly; |
|
1064 } |
|
1065 else if(list[i] == KGroupsOnly) |
|
1066 { |
|
1067 viewPreferences |= EGroupsOnly; |
|
1068 } |
|
1069 else if(list[i] == KContactsAndGroups) |
|
1070 { |
|
1071 viewPreferences |= EContactAndGroups; |
|
1072 } |
|
1073 else if(list[i] == KIgnoreUnsorted) |
|
1074 { |
|
1075 viewPreferences |= EIgnoreUnSorted; |
|
1076 } |
|
1077 else if(list[i] == KUnsortedAtbeginning) |
|
1078 { |
|
1079 viewPreferences |= EUnSortedAtBeginning; |
|
1080 } |
|
1081 else if(list[i] == KUnsortedAtEnd) |
|
1082 { |
|
1083 viewPreferences |= EUnSortedAtEnd; |
|
1084 } |
|
1085 else if(list[i] == KSingleWhiteSpace) |
|
1086 { |
|
1087 viewPreferences |= ESingleWhiteSpaceIsEmptyField; |
|
1088 } |
|
1089 else if(list[i] == KICCEntries) |
|
1090 { |
|
1091 viewPreferences |= EICCEntriesOnly; |
|
1092 } |
|
1093 else if(list[i] == KICCEntriesAndContacts) |
|
1094 { |
|
1095 viewPreferences |= EICCEntriesAndContacts; |
|
1096 } |
|
1097 } |
|
1098 CleanupStack::PopAndDestroy(&list); |
|
1099 return (TContactViewPreferences)viewPreferences; |
|
1100 } |
|
1101 |
|
1102 /* |
|
1103 * Converts the string of type TSearchType which is used for view construction |
|
1104 * @param aSearchType The search type |
|
1105 * @return CContactViewBase::TSearchType |
|
1106 */ |
|
1107 CContactViewBase::TSearchType CContactUtilitiesCollection::GetSearchType(const TDesC& aSearchType) |
|
1108 { |
|
1109 _LIT(KPrefixSearch, "EPrefixSearch"); |
|
1110 |
|
1111 CContactViewBase::TSearchType searchType = CContactViewBase::EFullSearch; |
|
1112 |
|
1113 if(aSearchType.Compare(KPrefixSearch) == 0 ) |
|
1114 { |
|
1115 searchType = CContactViewBase::EPrefixSearch; |
|
1116 } |
|
1117 |
|
1118 return searchType; |
|
1119 } |
|
1120 |
|
1121 /* |
|
1122 * Converts the string of type TGroupType which is used for view construction |
|
1123 * @param aGroupType The group type |
|
1124 * @return ContactViewBase::TGroupType |
|
1125 */ |
|
1126 CContactGroupView::TGroupType CContactUtilitiesCollection::GetGroupType(const TDesC& aGroupType) |
|
1127 { |
|
1128 _LIT(KShowContactsInGroup, "EShowContactsInGroup"); |
|
1129 _LIT(KShowContactsNotInGroup, "EShowContactsNotInGroup"); |
|
1130 |
|
1131 CContactGroupView::TGroupType groupType = CContactGroupView::EShowContactsNotInAnyGroup; |
|
1132 |
|
1133 if ( aGroupType.Compare(KShowContactsInGroup) == 0 ) |
|
1134 { |
|
1135 groupType = CContactGroupView::EShowContactsInGroup; |
|
1136 } |
|
1137 else if ( aGroupType.Compare(KShowContactsNotInGroup) == 0 ) |
|
1138 { |
|
1139 groupType = CContactGroupView::EShowContactsNotInGroup; |
|
1140 } |
|
1141 |
|
1142 return groupType; |
|
1143 } |
|
1144 |
|
1145 /* |
|
1146 * converts the string of type TContactViewFilter which is used for construction of the views |
|
1147 * @param aFilter The filter to use |
|
1148 * @return CContactDataBase::TContactViewFilter |
|
1149 */ |
|
1150 CContactDatabase::TContactViewFilter CContactUtilitiesCollection::GetContactViewFilterL(const TDesC& aFilter) |
|
1151 { |
|
1152 _LIT(KUnFiltered, "UnFiltered"); |
|
1153 _LIT(KMailable, "Mailable"); |
|
1154 _LIT(KSmsable, "Smsable"); |
|
1155 _LIT(KLandLine, "LandLine"); |
|
1156 _LIT(KFaxable, "Faxable"); |
|
1157 _LIT(KPhonable, "Phonable"); |
|
1158 _LIT(KWork, "Work"); |
|
1159 _LIT(KHome, "Home"); |
|
1160 _LIT(KRingTone, "RingTone"); |
|
1161 _LIT(KVoiceDial, "VoiceDial"); |
|
1162 _LIT(KIMAddress, "IMAddress"); |
|
1163 _LIT(KWirelessVillage, "WirelessVillage"); |
|
1164 _LIT(KCustomFilter1, "CustomFilter1"); |
|
1165 _LIT(KCustomFilter2, "CustomFilter2"); |
|
1166 _LIT(KCustomFilter3, "CustomFilter3"); |
|
1167 _LIT(KCustomFilter4, "CustomFilter4"); |
|
1168 |
|
1169 TUint viewFilter = 0x0; |
|
1170 |
|
1171 RArray<TPtrC> list; |
|
1172 CleanupClosePushL(list); |
|
1173 TokenizeStringL(aFilter, list); |
|
1174 |
|
1175 for(TInt i = 0; i < list.Count(); ++i) |
|
1176 { |
|
1177 if( list[i] == KUnFiltered) |
|
1178 { |
|
1179 viewFilter |= CContactDatabase::EUnfiltered; |
|
1180 } |
|
1181 else if(list[i] == KMailable) |
|
1182 { |
|
1183 viewFilter |= CContactDatabase::EMailable; |
|
1184 } |
|
1185 else if(list[i] == KSmsable) |
|
1186 { |
|
1187 viewFilter |= CContactDatabase::ESmsable; |
|
1188 } |
|
1189 else if(list[i] == KLandLine) |
|
1190 { |
|
1191 viewFilter |= CContactDatabase::ELandLine; |
|
1192 } |
|
1193 else if(list[i] == KFaxable) |
|
1194 { |
|
1195 viewFilter |= CContactDatabase::EFaxable; |
|
1196 } |
|
1197 else if(list[i] == KPhonable) |
|
1198 { |
|
1199 viewFilter |= CContactDatabase::EPhonable; |
|
1200 } |
|
1201 else if(list[i] == KWork) |
|
1202 { |
|
1203 viewFilter |= CContactDatabase::EWork; |
|
1204 } |
|
1205 else if(list[i] == KHome) |
|
1206 { |
|
1207 viewFilter |= CContactDatabase::EHome; |
|
1208 } |
|
1209 else if(list[i] == KRingTone) |
|
1210 { |
|
1211 viewFilter |= CContactDatabase::ERingTone; |
|
1212 } |
|
1213 else if(list[i] == KVoiceDial) |
|
1214 { |
|
1215 viewFilter |= CContactDatabase::EVoiceDial; |
|
1216 } |
|
1217 else if(list[i] == KIMAddress) |
|
1218 { |
|
1219 viewFilter |= CContactDatabase::EIMAddress; |
|
1220 } |
|
1221 else if(list[i] == KWirelessVillage) |
|
1222 { |
|
1223 viewFilter |= CContactDatabase::EWirelessVillage; |
|
1224 } |
|
1225 else if(list[i] == KCustomFilter1) |
|
1226 { |
|
1227 viewFilter |= CContactDatabase::ECustomFilter1; |
|
1228 } |
|
1229 else if(list[i] == KCustomFilter2) |
|
1230 { |
|
1231 viewFilter |= CContactDatabase::ECustomFilter2; |
|
1232 } |
|
1233 else if(list[i] == KCustomFilter3) |
|
1234 { |
|
1235 viewFilter |= CContactDatabase::ECustomFilter3; |
|
1236 } |
|
1237 else if(list[i] == KCustomFilter4) |
|
1238 { |
|
1239 viewFilter |= CContactDatabase::ECustomFilter4; |
|
1240 } |
|
1241 } |
|
1242 |
|
1243 CleanupStack::PopAndDestroy(); //list |
|
1244 return (CContactDatabase::TContactViewFilter)viewFilter; |
|
1245 } |
|
1246 |
|
1247 /* |
|
1248 * Construct different types of views like local view, remote view, named remote view, find view, filtered view, |
|
1249 * group view, concatenated view and sub view based on the list of views specified in the ini file and append the views |
|
1250 * to their corresponding view array |
|
1251 * @param aSections ini sections |
|
1252 */ |
|
1253 void CContactUtilitiesCollection::ConstructViewsL(RArray<TPtrC> aSections) |
|
1254 { |
|
1255 // Iterating through the sections listed in the field listOfViews. |
|
1256 for ( TInt i = 0; i < aSections.Count(); ++i ) |
|
1257 { |
|
1258 TPtrC iniSection = aSections[i]; |
|
1259 TPtrC viewType; |
|
1260 BaseTestStepReference().GetStringFromConfig(iniSection, KViewType, viewType); |
|
1261 TPtrC allocTest; |
|
1262 BaseTestStepReference().GetStringFromConfig(iniSection, KAllocTest, allocTest); |
|
1263 |
|
1264 |
|
1265 if ( allocTest != KNullDesC() ) |
|
1266 { |
|
1267 OOMTestForViewsL(iniSection, viewType, allocTest); |
|
1268 } |
|
1269 else |
|
1270 { |
|
1271 if ( viewType.Compare(KLocalView) == 0 ) |
|
1272 { |
|
1273 // Construct Local view based on the data defined in the ini section i.e aSections[i] |
|
1274 GetDataAndConstructLocalViewL(iniSection); |
|
1275 } |
|
1276 if ( viewType.Compare(KRemoteView) == 0 ) |
|
1277 { |
|
1278 // Construct remote view based on the data defined in the ini section i.e aSections[i] |
|
1279 GetDataAndConstructRemoteViewL(iniSection); |
|
1280 } |
|
1281 if ( viewType.Compare(KNamedRemoteView) == 0 ) |
|
1282 { |
|
1283 // Construct named remote view based on the data defined in the ini section i.e aSections[i] |
|
1284 GetDataAndConstructNamedRemoteViewL(iniSection); |
|
1285 } |
|
1286 if ( viewType.Compare(KGroupView) == 0 ) |
|
1287 { |
|
1288 // Construct group view based on the data defined in the ini section i.e aSections[i] |
|
1289 GetDataAndConstructGroupViewL(iniSection); |
|
1290 } |
|
1291 if ( viewType.Compare(KFindView) == 0 ) |
|
1292 { |
|
1293 // Construct find view based on the data defined in the ini section i.e aSections[i] |
|
1294 GetDataAndConstructFindViewL(iniSection); |
|
1295 } |
|
1296 if ( viewType.Compare(KFilteredView) == 0 ) |
|
1297 { |
|
1298 // Construct filtered view based on the data defined in the ini section i.e aSections[i] |
|
1299 GetDataAndConstructFilteredViewL(iniSection); |
|
1300 } |
|
1301 if ( viewType.Compare(KConcatenatedView) == 0 ) |
|
1302 { |
|
1303 // Construct concatenated view based on the data defined in the ini section i.e aSections[i] |
|
1304 ConstructConcatenatedViewL(iniSection); |
|
1305 } |
|
1306 if ( viewType.Compare(KSubView) == 0 ) |
|
1307 { |
|
1308 // Construct sub view based on the data defined in the ini section i.e aSections[i] |
|
1309 GetDataAndConstructSubViewL(iniSection); |
|
1310 } |
|
1311 } |
|
1312 } |
|
1313 } |
|
1314 |
|
1315 /** |
|
1316 * Parses a comma separated string and constructs a list out of the values |
|
1317 * @param aString input string |
|
1318 * @param aList Array of seperated strings |
|
1319 * @param aSeparator , |
|
1320 */ |
|
1321 void CContactUtilitiesCollection::TokenizeStringL(const TDesC& aString, RArray<TPtrC>& aList, TChar aSeparator) |
|
1322 { |
|
1323 TLex lexer(aString); |
|
1324 |
|
1325 while(!lexer.Eos()) |
|
1326 { |
|
1327 lexer.SkipSpaceAndMark(); |
|
1328 |
|
1329 while(!lexer.Eos() && lexer.Get() != aSeparator) |
|
1330 { |
|
1331 } |
|
1332 |
|
1333 if(!lexer.Eos()) |
|
1334 { |
|
1335 lexer.UnGet(); // Do not include trailing ',' |
|
1336 } |
|
1337 aList.AppendL(lexer.MarkedToken()); |
|
1338 lexer.Inc(); |
|
1339 } |
|
1340 } |
|
1341 |
|
1342 /* |
|
1343 * OOM testing of views |
|
1344 * @param aSection ini section |
|
1345 * @param aViewType view type |
|
1346 * @param aAllocTest OOM test |
|
1347 */ |
|
1348 void CContactUtilitiesCollection::CreateViewUnderOOMConditionL(const TDesC& aSection, const TDesC& aViewType, const TDesC& aAllocTest) |
|
1349 { |
|
1350 if ( aViewType.Compare(KGroupView) == 0 && aAllocTest.Compare(KGroupView) == 0 ) |
|
1351 { |
|
1352 // Construct group view based on the data defined in the ini section i.e aSections[i] |
|
1353 GetDataAndConstructGroupViewL(aSection); |
|
1354 } |
|
1355 else if ( aViewType.Compare(KFindView) == 0 && aAllocTest.Compare(KFindView) == 0 ) |
|
1356 { |
|
1357 // Construct find view based on the data defined in the ini section i.e aSections[i] |
|
1358 GetDataAndConstructFindViewL(aSection); |
|
1359 } |
|
1360 else if ( aViewType.Compare(KFilteredView) == 0 && aAllocTest.Compare(KFilteredView) == 0 ) |
|
1361 { |
|
1362 // Construct filtered view based on the data defined in the ini section i.e aSections[i] |
|
1363 GetDataAndConstructFilteredViewL(aSection); |
|
1364 } |
|
1365 else if ( aViewType.Compare(KSubView) == 0 && aAllocTest.Compare(KSubView) == 0 ) |
|
1366 { |
|
1367 // Construct sub view based on the data defined in the ini section i.e aSections[i] |
|
1368 GetDataAndConstructSubViewL(aSection); |
|
1369 } |
|
1370 } |
|
1371 |
|
1372 /* |
|
1373 * Construct the views in the OOM loop |
|
1374 * @param aSortOrder specifies the fields to use to sort the items in the view |
|
1375 * @param aViewPreferences specifies the type of the contact item to be included in the view |
|
1376 * @param aSortPlugin specifies a plug-in that will be used to compare view contacts when the view is sorted |
|
1377 */ |
|
1378 void CContactUtilitiesCollection::OOMTestForViewsL(const TDesC& aSection, const TDesC& aViewType, const TDesC& aAllocTest) |
|
1379 { |
|
1380 TInt tryCount = 1; |
|
1381 for ( ;; ) |
|
1382 { |
|
1383 __UHEAP_SETFAIL(RHeap::EFailNext, tryCount); |
|
1384 |
|
1385 TRAPD(err, CreateViewUnderOOMConditionL(aSection, aViewType, aAllocTest)); |
|
1386 |
|
1387 if ( err == KErrNone ) |
|
1388 { |
|
1389 __UHEAP_RESET; |
|
1390 BaseTestStepReference().INFO_PRINTF1(_L("Memory allocation testing for View is done")); |
|
1391 break; |
|
1392 } |
|
1393 if ( err != KErrNoMemory ) |
|
1394 BaseTestStepReference().SetTestStepResult(EFail); |
|
1395 __UHEAP_SETFAIL(RHeap::ENone, 0); |
|
1396 tryCount++; |
|
1397 } |
|
1398 BaseTestStepReference().INFO_PRINTF2(_L("TRYCOUNT %d"), tryCount); |
|
1399 } |
|
1400 |
|
1401 |
|
1402 // CContactViewCollection |
|
1403 |
|
1404 CContactViewCollection* CContactViewCollection::NewL() |
|
1405 { |
|
1406 CContactViewCollection* self = new(ELeave) CContactViewCollection(); |
|
1407 return self; |
|
1408 } |
|
1409 |
|
1410 CContactViewCollection::CContactViewCollection() |
|
1411 { |
|
1412 } |
|
1413 |
|
1414 CContactViewCollection::~CContactViewCollection() |
|
1415 { |
|
1416 CloseLocalViewAndEventQueue(); |
|
1417 CloseRemoteViewAndEventQueue(); |
|
1418 CloseNamedRemoteViewAndEventQueue(); |
|
1419 CloseFindViewAndEventQueue(); |
|
1420 CloseFilteredViewAndEventQueue(); |
|
1421 CloseGroupViewAndEventQueue(); |
|
1422 CloseConcatenatedViewAndEventQueue(); |
|
1423 CloseSubViewAndEventQueue(); |
|
1424 iArrayOfViewBase.Close(); |
|
1425 iArrayViewEvents.Close(); |
|
1426 } |
|
1427 |
|
1428 /* |
|
1429 * Close the localvieweventqueue and localviewarray |
|
1430 */ |
|
1431 void CContactViewCollection::CloseLocalViewAndEventQueue() |
|
1432 { |
|
1433 for ( TInt i = 0; i < iArrayOfLocalViews.Count(); ++i ) |
|
1434 { |
|
1435 if (iArrayOfLocalViews.Count() > 0 && iArrayOfLocalViewEvents.Count() > 0) |
|
1436 { |
|
1437 iArrayOfLocalViews[i]->Close(*iArrayOfLocalViewEvents[i]); |
|
1438 delete iArrayOfLocalViewEvents[i]; |
|
1439 } |
|
1440 } |
|
1441 iArrayOfLocalViews.Close(); |
|
1442 } |
|
1443 |
|
1444 /* |
|
1445 * Close the RemoteView And its EventQueue |
|
1446 */ |
|
1447 void CContactViewCollection::CloseRemoteViewAndEventQueue() |
|
1448 { |
|
1449 for ( TInt i = 0; i < iArrayOfRemoteViews.Count(); ++i ) |
|
1450 { |
|
1451 if (iArrayOfRemoteViews.Count() > 0 && iArrayOfRemoteViewEvents.Count() > 0) |
|
1452 iArrayOfRemoteViews[i]->Close(*iArrayOfRemoteViewEvents[i]); |
|
1453 delete iArrayOfRemoteViewEvents[i]; |
|
1454 } |
|
1455 iArrayOfRemoteViews.Close(); |
|
1456 } |
|
1457 |
|
1458 /* |
|
1459 * Close the NamedRemoteView And its EventQueue |
|
1460 */ |
|
1461 void CContactViewCollection::CloseNamedRemoteViewAndEventQueue() |
|
1462 { |
|
1463 for ( TInt i = 0; i < iArrayOfNamedRemoteViews.Count(); ++i ) |
|
1464 { |
|
1465 if (iArrayOfNamedRemoteViews.Count() > 0 && iArrayOfNamedRemoteViewEvents.Count() > 0) |
|
1466 iArrayOfNamedRemoteViews[i]->Close(*iArrayOfNamedRemoteViewEvents[i]); |
|
1467 delete iArrayOfNamedRemoteViewEvents[i]; |
|
1468 } |
|
1469 iArrayOfNamedRemoteViews.Close(); |
|
1470 } |
|
1471 |
|
1472 /* |
|
1473 * Close the FindView And its EventQueue |
|
1474 */ |
|
1475 void CContactViewCollection::CloseFindViewAndEventQueue() |
|
1476 { |
|
1477 for ( TInt i = 0; i < iArrayOfFindViews.Count(); ++i ) |
|
1478 { |
|
1479 if (iArrayOfFindViews.Count() > 0 && iArrayOfFindViewEvents.Count() > 0) |
|
1480 iArrayOfFindViews[i]->Close(*iArrayOfFindViewEvents[i]); |
|
1481 delete iArrayOfFindViewEvents[i]; |
|
1482 } |
|
1483 iArrayOfFindViews.Close(); |
|
1484 } |
|
1485 |
|
1486 /* |
|
1487 * Close the FilteredView And its EventQueue |
|
1488 */ |
|
1489 void CContactViewCollection::CloseFilteredViewAndEventQueue() |
|
1490 { |
|
1491 for ( TInt i = 0; i < iArrayOfFilteredViews.Count(); ++i ) |
|
1492 { |
|
1493 if (iArrayOfFilteredViews.Count() > 0 && iArrayOfFilteredViewEvents.Count() > 0) |
|
1494 iArrayOfFilteredViews[i]->Close(*iArrayOfFilteredViewEvents[i]); |
|
1495 delete iArrayOfFilteredViewEvents[i]; |
|
1496 } |
|
1497 iArrayOfFilteredViews.Close(); |
|
1498 } |
|
1499 |
|
1500 /* |
|
1501 * Close the GroupView And its EventQueue |
|
1502 */ |
|
1503 void CContactViewCollection::CloseGroupViewAndEventQueue() |
|
1504 { |
|
1505 for ( TInt i = 0; i < iArrayOfGroupViews.Count(); ++i ) |
|
1506 { |
|
1507 if (iArrayOfGroupViews[i]) |
|
1508 iArrayOfGroupViews[i]->Close(*iArrayOfGroupViewEvents[i]); |
|
1509 delete iArrayOfGroupViewEvents[i]; |
|
1510 } |
|
1511 iArrayOfGroupViews.Close(); |
|
1512 } |
|
1513 |
|
1514 /* |
|
1515 * Close the ConcatenatedView And its EventQueue |
|
1516 */ |
|
1517 void CContactViewCollection::CloseConcatenatedViewAndEventQueue() |
|
1518 { |
|
1519 for ( TInt i = 0; i < iArrayOfConcatenatedViews.Count(); ++i ) |
|
1520 { |
|
1521 if (iArrayOfConcatenatedViews.Count() > 0 && iArrayOfConcatenatedViewEvents.Count() > 0) |
|
1522 iArrayOfConcatenatedViews[i]->Close(*iArrayOfConcatenatedViewEvents[i]); |
|
1523 delete iArrayOfConcatenatedViewEvents[i]; |
|
1524 } |
|
1525 iArrayOfConcatenatedViews.Close(); |
|
1526 } |
|
1527 |
|
1528 /* |
|
1529 * Close the SubView And its EventQueue |
|
1530 */ |
|
1531 void CContactViewCollection::CloseSubViewAndEventQueue() |
|
1532 { |
|
1533 for ( TInt i = 0; i < iArrayOfSubViews.Count(); ++i ) |
|
1534 { |
|
1535 if (iArrayOfSubViews.Count() > 0 && iArrayOfSubViewEvents.Count() > 0) |
|
1536 iArrayOfSubViews[i]->Close(*iArrayOfSubViewEvents[i]); |
|
1537 delete iArrayOfSubViewEvents[i]; |
|
1538 } |
|
1539 iArrayOfSubViews.Close(); |
|
1540 } |
|
1541 /* |
|
1542 * retrieve the local view array |
|
1543 * @return RPointerArray<CContactLocalView>& |
|
1544 */ |
|
1545 RPointerArray<CContactLocalView>& CContactViewCollection::GetLocalViewArray() |
|
1546 { |
|
1547 return iArrayOfLocalViews; |
|
1548 } |
|
1549 |
|
1550 /* |
|
1551 * retrieve the remote view array |
|
1552 * @return RPointerArray<CContactRemoteView>& |
|
1553 */ |
|
1554 RPointerArray<CContactRemoteView>& CContactViewCollection::GetRemoteViewArray() |
|
1555 { |
|
1556 return iArrayOfRemoteViews; |
|
1557 } |
|
1558 |
|
1559 /* |
|
1560 * retrieve the named remote view array |
|
1561 * @return RPointerArray<CContactNamedRemoteView>& |
|
1562 */ |
|
1563 RPointerArray<CContactNamedRemoteView>& CContactViewCollection::GetNamedRemoteViewArray() |
|
1564 { |
|
1565 return iArrayOfNamedRemoteViews; |
|
1566 } |
|
1567 |
|
1568 /* |
|
1569 * retrieve the find view array |
|
1570 * @return RPointerArray<CContactFindView>& |
|
1571 */ |
|
1572 RPointerArray<CContactFindView>& CContactViewCollection::GetFindViewArray() |
|
1573 { |
|
1574 return iArrayOfFindViews; |
|
1575 } |
|
1576 |
|
1577 /* |
|
1578 * retrieve the group view array |
|
1579 * @return RPointerArray<CContactGroupView>& |
|
1580 */ |
|
1581 RPointerArray<CContactGroupView>& CContactViewCollection::GetGroupViewArray() |
|
1582 { |
|
1583 return iArrayOfGroupViews; |
|
1584 } |
|
1585 |
|
1586 /* |
|
1587 * retrieve the filtered view array |
|
1588 * @return RPointerArray<CContactFilteredView>& |
|
1589 */ |
|
1590 RPointerArray<CContactFilteredView>& CContactViewCollection::GetFilteredViewArray() |
|
1591 { |
|
1592 return iArrayOfFilteredViews; |
|
1593 } |
|
1594 |
|
1595 /* |
|
1596 * retrieve the concatenated view array |
|
1597 * @return RPointerArray<CContactConcatenatedView>& |
|
1598 */ |
|
1599 RPointerArray<CContactConcatenatedView>& CContactViewCollection::GetConcatenatedViewArray() |
|
1600 { |
|
1601 return iArrayOfConcatenatedViews; |
|
1602 } |
|
1603 |
|
1604 /* |
|
1605 * retrieve the sub view array |
|
1606 * @return RPointerArray<CContactSubView>& |
|
1607 */ |
|
1608 RPointerArray<CContactSubView>& CContactViewCollection::GetSubViewArray() |
|
1609 { |
|
1610 return iArrayOfSubViews; |
|
1611 } |
|
1612 |
|
1613 /* |
|
1614 * retrieve the component view array |
|
1615 * @return RPointerArray<CContactViewBase>& |
|
1616 */ |
|
1617 RPointerArray<CContactViewBase>& CContactViewCollection::GetComponentViews() |
|
1618 { |
|
1619 return iArrayOfViewBase; |
|
1620 } |
|
1621 |
|
1622 /* |
|
1623 * retrieve the view events array |
|
1624 * @param aTypeOfView type of the view events array to be retrieved |
|
1625 * @return RPointerArray<CContactViewEventQueue>& |
|
1626 */ |
|
1627 RPointerArray<CContactViewEventQueue>& CContactViewCollection::GetContactViewEventsQueueL(const TDesC& aTypeOfView) |
|
1628 { |
|
1629 if ( aTypeOfView.Compare(KLocalView) == 0 ) |
|
1630 { |
|
1631 for ( TInt i = 0; i < iArrayOfLocalViewEvents.Count(); ++i ) |
|
1632 { |
|
1633 iArrayViewEvents.AppendL(iArrayOfLocalViewEvents[i]); |
|
1634 } |
|
1635 } |
|
1636 else if ( aTypeOfView.Compare(KRemoteView) == 0 ) |
|
1637 { |
|
1638 for ( TInt i = 0; i < iArrayOfRemoteViewEvents.Count(); ++i ) |
|
1639 { |
|
1640 iArrayViewEvents.AppendL(iArrayOfRemoteViewEvents[i]); |
|
1641 } |
|
1642 } |
|
1643 else if ( aTypeOfView.Compare(KNamedRemoteView) == 0 ) |
|
1644 { |
|
1645 for ( TInt i = 0; i < iArrayOfNamedRemoteViewEvents.Count(); ++i ) |
|
1646 { |
|
1647 iArrayViewEvents.AppendL(iArrayOfNamedRemoteViewEvents[i]); |
|
1648 } |
|
1649 } |
|
1650 else if ( aTypeOfView.Compare(KFindView) == 0 ) |
|
1651 { |
|
1652 for ( TInt i = 0; i < iArrayOfFindViewEvents.Count(); ++i ) |
|
1653 { |
|
1654 iArrayViewEvents.AppendL(iArrayOfFindViewEvents[i]); |
|
1655 } |
|
1656 } |
|
1657 else if ( aTypeOfView.Compare(KFilteredView) == 0 ) |
|
1658 { |
|
1659 for ( TInt i = 0; i < iArrayOfFilteredViewEvents.Count(); ++i ) |
|
1660 { |
|
1661 iArrayViewEvents.AppendL(iArrayOfFilteredViewEvents[i]); |
|
1662 } |
|
1663 } |
|
1664 else if ( aTypeOfView.Compare(KGroupView) == 0 ) |
|
1665 { |
|
1666 for ( TInt i = 0; i < iArrayOfGroupViewEvents.Count(); ++i ) |
|
1667 { |
|
1668 iArrayViewEvents.AppendL(iArrayOfGroupViewEvents[i]); |
|
1669 } |
|
1670 } |
|
1671 else if ( aTypeOfView.Compare(KConcatenatedView) == 0 ) |
|
1672 { |
|
1673 for ( TInt i = 0; i < iArrayOfConcatenatedViewEvents.Count(); ++i ) |
|
1674 { |
|
1675 iArrayViewEvents.AppendL(iArrayOfConcatenatedViewEvents[i]); |
|
1676 } |
|
1677 } |
|
1678 else if ( aTypeOfView.Compare(KSubView) == 0 ) |
|
1679 { |
|
1680 for ( TInt i = 0; i < iArrayOfSubViewEvents.Count(); ++i ) |
|
1681 { |
|
1682 iArrayViewEvents.AppendL(iArrayOfSubViewEvents[i]); |
|
1683 } |
|
1684 } |
|
1685 return iArrayViewEvents; |
|
1686 } |
|
1687 |
|
1688 /* |
|
1689 * Get the desired local view located at the specified index in the array iArrayOfLocalViews |
|
1690 * @param aIndexOfView index of the view |
|
1691 * @return CContactLocalView |
|
1692 */ |
|
1693 CContactLocalView* CContactViewCollection::GetDesiredLocalView(TInt aIndexOfView) |
|
1694 { |
|
1695 RPointerArray<CContactLocalView>& localViewArray = GetLocalViewArray(); |
|
1696 CContactLocalView* localView = NULL; |
|
1697 for ( TInt i = 0; i < localViewArray.Count(); ++i ) |
|
1698 { |
|
1699 if ( i == (aIndexOfView - 1) ) |
|
1700 { |
|
1701 localView = localViewArray[i]; |
|
1702 } |
|
1703 } |
|
1704 return localView; |
|
1705 } |
|
1706 |
|
1707 /* |
|
1708 * Get the desired remote view located at the specified index in the array iArrayOfRemoteViews |
|
1709 * @param aIndexOfView index of the view |
|
1710 * @return CContactRemoteView |
|
1711 */ |
|
1712 CContactRemoteView* CContactViewCollection::GetDesiredRemoteView(TInt aIndexOfView) |
|
1713 { |
|
1714 RPointerArray<CContactRemoteView>& remoteViewArray = GetRemoteViewArray(); |
|
1715 CContactRemoteView* remoteView = NULL; |
|
1716 for ( TInt i = 0; i < remoteViewArray.Count(); ++i ) |
|
1717 { |
|
1718 if ( i == (aIndexOfView - 1) ) |
|
1719 { |
|
1720 remoteView = remoteViewArray[i]; |
|
1721 } |
|
1722 } |
|
1723 return remoteView; |
|
1724 } |
|
1725 |
|
1726 /* |
|
1727 * Get the desired named remote view located at the specified index in the array iArrayOfNamedRemoteViews |
|
1728 * @param aIndexOfView index of the view |
|
1729 * @return CContactNamedRemoteView |
|
1730 */ |
|
1731 CContactNamedRemoteView* CContactViewCollection::GetDesiredNamedRemoteView(TInt aIndexOfView) |
|
1732 { |
|
1733 RPointerArray<CContactNamedRemoteView>& namedRemoteViewArray = GetNamedRemoteViewArray(); |
|
1734 CContactNamedRemoteView* namedRemoteView = NULL; |
|
1735 for ( TInt i = 0; i < namedRemoteViewArray.Count(); ++i ) |
|
1736 { |
|
1737 if ( i == (aIndexOfView - 1) ) |
|
1738 { |
|
1739 namedRemoteView = namedRemoteViewArray[i]; |
|
1740 } |
|
1741 } |
|
1742 return namedRemoteView; |
|
1743 } |
|
1744 |
|
1745 /* |
|
1746 * Get the desired find view located at the specified index in the array iArrayOfFindViews |
|
1747 * @param aIndexOfView index of the view |
|
1748 * @return CContactFindView |
|
1749 */ |
|
1750 CContactFindView* CContactViewCollection::GetDesiredFindView(TInt aIndexOfView) |
|
1751 { |
|
1752 RPointerArray<CContactFindView>& findViewArray = GetFindViewArray(); |
|
1753 CContactFindView* findView = NULL; |
|
1754 for ( TInt i = 0; i < findViewArray.Count(); ++i ) |
|
1755 { |
|
1756 if ( i == (aIndexOfView - 1) ) |
|
1757 { |
|
1758 findView = findViewArray[i]; |
|
1759 } |
|
1760 } |
|
1761 return findView; |
|
1762 } |
|
1763 |
|
1764 /* |
|
1765 * Get the desired filtered view located at the specified index in the array iArrayOfFilteredViews |
|
1766 * @param aIndexOfView index of the view |
|
1767 * @return CContactFilteredView |
|
1768 */ |
|
1769 CContactFilteredView* CContactViewCollection::GetDesiredFilteredView(TInt aIndexOfView) |
|
1770 { |
|
1771 RPointerArray<CContactFilteredView>& filteredViewArray = GetFilteredViewArray(); |
|
1772 CContactFilteredView* filteredView = NULL; |
|
1773 for ( TInt i = 0; i < filteredViewArray.Count(); ++i ) |
|
1774 { |
|
1775 if ( i == (aIndexOfView - 1) ) |
|
1776 { |
|
1777 filteredView = filteredViewArray[i]; |
|
1778 } |
|
1779 } |
|
1780 return filteredView; |
|
1781 } |
|
1782 |
|
1783 /* |
|
1784 * Get the desired group view located at the specified index in the array iArrayOfGroupViews |
|
1785 * @param aIndexOfView index of the view |
|
1786 * @return CContactGroupView |
|
1787 */ |
|
1788 CContactGroupView* CContactViewCollection::GetDesiredGroupView(TInt aIndexOfView) |
|
1789 { |
|
1790 RPointerArray<CContactGroupView>& groupViewArray = GetGroupViewArray(); |
|
1791 CContactGroupView* groupView = NULL; |
|
1792 for ( TInt i = 0; i < groupViewArray.Count(); ++i ) |
|
1793 { |
|
1794 if ( i == (aIndexOfView - 1) ) |
|
1795 { |
|
1796 groupView = groupViewArray[i]; |
|
1797 } |
|
1798 } |
|
1799 return groupView; |
|
1800 } |
|
1801 |
|
1802 /* |
|
1803 * Get the desired concatenated view located at the specified index in the array iArrayOfConcatenatedViews |
|
1804 * @param aIndexOfView index of the view |
|
1805 * @return CContactConcatenatedView |
|
1806 */ |
|
1807 CContactConcatenatedView* CContactViewCollection::GetDesiredConcatenatedView(TInt aIndexOfView) |
|
1808 { |
|
1809 RPointerArray<CContactConcatenatedView>& concatenatedViewArray = GetConcatenatedViewArray(); |
|
1810 CContactConcatenatedView* concatenatedView = NULL; |
|
1811 for ( TInt i = 0; i < concatenatedViewArray.Count(); ++i ) |
|
1812 { |
|
1813 if ( i == (aIndexOfView - 1) ) |
|
1814 { |
|
1815 concatenatedView = concatenatedViewArray[i]; |
|
1816 } |
|
1817 } |
|
1818 return concatenatedView; |
|
1819 } |
|
1820 |
|
1821 /* |
|
1822 * Get the desired sub view located at the specified index in the array iArrayOfSubViews |
|
1823 * @param aIndexOfView index of the view |
|
1824 * @return CContactSubView |
|
1825 */ |
|
1826 CContactSubView* CContactViewCollection::GetDesiredSubView(TInt aIndexOfView) |
|
1827 { |
|
1828 RPointerArray<CContactSubView>& subViewArray = GetSubViewArray(); |
|
1829 CContactSubView* subView = NULL; |
|
1830 for ( TInt i = 0; i < subViewArray.Count(); ++i ) |
|
1831 { |
|
1832 if ( i == (aIndexOfView - 1) ) |
|
1833 { |
|
1834 subView = subViewArray[i]; |
|
1835 } |
|
1836 } |
|
1837 return subView; |
|
1838 } |
|
1839 |
|
1840 /* |
|
1841 * Get the desired sub view located at the specified index in the array iArrayOfSubViews |
|
1842 * @param indexOfView index of the view |
|
1843 * @param aTypeOfView type of the view |
|
1844 * @return CContactViewEventQueue* |
|
1845 */ |
|
1846 CContactViewEventQueue* CContactViewCollection::GetDesiredViewEventL(TInt aIndexOfView, const TDesC& aTypeOfView) |
|
1847 { |
|
1848 RPointerArray<CContactViewEventQueue>& viewEventsQueue = GetContactViewEventsQueueL(aTypeOfView); |
|
1849 CContactViewEventQueue* viewEvent = NULL; |
|
1850 for ( TInt i = 0; i < viewEventsQueue.Count(); ++i ) |
|
1851 { |
|
1852 if ( i == (aIndexOfView - 1) ) |
|
1853 { |
|
1854 viewEvent = viewEventsQueue[i]; |
|
1855 } |
|
1856 } |
|
1857 return viewEvent; |
|
1858 } |
|
1859 |
|
1860 |
|
1861 // CContactViewTest |
|
1862 |
|
1863 CContactViewApiTest::CContactViewApiTest(CTestStep* aTestStep) |
|
1864 : iTestStep(aTestStep) |
|
1865 { |
|
1866 } |
|
1867 |
|
1868 /** |
|
1869 * Constructor |
|
1870 */ |
|
1871 CContactViewApiTest* CContactViewApiTest::NewL(CTestStep* aTestStep) |
|
1872 { |
|
1873 CContactViewApiTest* self = new(ELeave) CContactViewApiTest(aTestStep); |
|
1874 return self; |
|
1875 } |
|
1876 |
|
1877 /** |
|
1878 * Destructor |
|
1879 */ |
|
1880 CContactViewApiTest::~CContactViewApiTest() |
|
1881 { |
|
1882 iFsSession.Close(); |
|
1883 } |
|
1884 |
|
1885 |
|
1886 CTestStep& CContactViewApiTest::TestStepReference() |
|
1887 { |
|
1888 return *iTestStep; |
|
1889 } |
|
1890 |
|
1891 /* |
|
1892 * Get the data required to test the AtL() API |
|
1893 * @param aSection ini section |
|
1894 * @return index |
|
1895 */ |
|
1896 TInt CContactViewApiTest::GetAtLApiDataFromIni(const TDesC& aSection) |
|
1897 { |
|
1898 TInt index = -1; |
|
1899 TestStepReference().GetIntFromConfig(aSection, KAtLIndex, index); |
|
1900 return index; |
|
1901 } |
|
1902 |
|
1903 /* |
|
1904 * Pass the index of the contact item and get the contact item id |
|
1905 * @param aIndex index of the contact item id |
|
1906 * @param aView desired view |
|
1907 * @param aErrorCondition diskfull or not ready |
|
1908 * @return TContactItemId |
|
1909 */ |
|
1910 TContactItemId CContactViewApiTest::AtL(TInt aIndex, CContactViewBase* aView, const TDesC& aErrorCondition) |
|
1911 { |
|
1912 TContactItemId contactItemId = 0; |
|
1913 // Accessing the view when it is in disk full condition |
|
1914 if ( aErrorCondition != KNullDesC() ) |
|
1915 { |
|
1916 #ifdef __DEBUG |
|
1917 SetFsErrorConditionL(aErrorCondition, KFsAccessCount); |
|
1918 #endif |
|
1919 TRAPD(err, contactItemId = aView->AtL(aIndex) ); |
|
1920 TPtrC errorCondition; |
|
1921 errorCondition.Set(_L("ErrorNone")); |
|
1922 #ifdef __DEBUG |
|
1923 SetFsErrorConditionL(errorCondition); |
|
1924 #endif |
|
1925 ValidateErrorCondition(err, aErrorCondition); |
|
1926 } |
|
1927 else |
|
1928 { |
|
1929 TRAPD(err, contactItemId = aView->AtL(aIndex) ); |
|
1930 if ( err != KErrNone ) |
|
1931 { |
|
1932 contactItemId = -1; |
|
1933 TestStepReference().SetTestStepError(err); |
|
1934 TestStepReference().SetTestStepResult(EFail); |
|
1935 } |
|
1936 } |
|
1937 return contactItemId; |
|
1938 } |
|
1939 |
|
1940 /* |
|
1941 * Change the sortorder of the view |
|
1942 * @return index |
|
1943 */ |
|
1944 void CContactViewApiTest::TestChangeSortOrderL(const TDesC& aSection, CContactUtilitiesCollection* aContactUtility) |
|
1945 { |
|
1946 CContactNamedRemoteView* namedRemoteview = NULL; |
|
1947 TInt index = -1; |
|
1948 TestStepReference().GetIntFromConfig(aSection, KIndexOfViews, index); |
|
1949 CContactViewCollection& viewCollection = aContactUtility->ViewCollectionReference(); |
|
1950 namedRemoteview = viewCollection.GetDesiredNamedRemoteView(index); |
|
1951 TPtrC viewSortOrder; |
|
1952 TestStepReference().GetStringFromConfig(aSection, KViewSortOrder, viewSortOrder); |
|
1953 RContactViewSortOrder sortOrder = aContactUtility->ConvertStringToSortOrderL(viewSortOrder); |
|
1954 namedRemoteview->ChangeSortOrderL(sortOrder); |
|
1955 User::After(10 * 1000000); |
|
1956 } |
|
1957 |
|
1958 |
|
1959 |
|
1960 /* |
|
1961 * Get the data required to test the ContactAtL() API |
|
1962 * @param aSection ini section |
|
1963 * @return index |
|
1964 */ |
|
1965 TInt CContactViewApiTest::GetContactAtLApiDataFromIni(const TDesC& aSection) |
|
1966 { |
|
1967 TInt index = -1; |
|
1968 TestStepReference().GetIntFromConfig(aSection, KAtLIndex, index); |
|
1969 return index; |
|
1970 } |
|
1971 |
|
1972 /* |
|
1973 * Pass the index and get the contact item |
|
1974 * @param aIndex index of the contact item in the view |
|
1975 * @param aView desired view |
|
1976 * @return CViewContact |
|
1977 */ |
|
1978 CViewContact* CContactViewApiTest::ContactAtL(TInt aIndex, CContactViewBase* aView) |
|
1979 { |
|
1980 CViewContact* viewContact = NULL; |
|
1981 TRAPD(err, viewContact = CViewContact::NewL(aView->ContactAtL(aIndex))); |
|
1982 if(err != KErrNone) |
|
1983 { |
|
1984 viewContact = NULL; |
|
1985 TestStepReference().SetTestStepError(err); |
|
1986 TestStepReference().SetTestStepResult(EFail); |
|
1987 } |
|
1988 return viewContact; |
|
1989 } |
|
1990 |
|
1991 /* |
|
1992 * Get the data required for the FindL() API |
|
1993 * @param aSection ini section |
|
1994 * @return TInt contactItemId |
|
1995 */ |
|
1996 TInt CContactViewApiTest::GetFindLApiDataFromIni(const TPtrC& aSection) |
|
1997 { |
|
1998 TInt contactItemId = -1; |
|
1999 TestStepReference().GetIntFromConfig(aSection, KContactItemId, contactItemId); |
|
2000 return contactItemId; |
|
2001 } |
|
2002 |
|
2003 /* |
|
2004 * Pass the contact item id and find the index of the contact item id |
|
2005 * @param aSection ini section |
|
2006 * @param aView desired view |
|
2007 * @param aErrorCondition diskfull or not ready |
|
2008 * @return index of the contact item id |
|
2009 */ |
|
2010 TInt CContactViewApiTest::FindL(TContactItemId aId, CContactViewBase* aView, const TDesC& aErrorCondition) |
|
2011 { |
|
2012 TInt index(-1); |
|
2013 // Accessing the view when it is in disk full condition |
|
2014 if ( aErrorCondition != KNullDesC() ) |
|
2015 { |
|
2016 #ifdef __DEBUG |
|
2017 SetFsErrorConditionL(aErrorCondition, KFsAccessCount); |
|
2018 #endif |
|
2019 TRAPD( err, index = aView->FindL(aId)); |
|
2020 TPtrC errorCondition; |
|
2021 errorCondition.Set(_L("ErrorNone")); |
|
2022 #ifdef __DEBUG |
|
2023 SetFsErrorConditionL(errorCondition); |
|
2024 #endif |
|
2025 ValidateErrorCondition(err, aErrorCondition); |
|
2026 } |
|
2027 else |
|
2028 { |
|
2029 TRAPD( err, index = aView->FindL(aId)); |
|
2030 if ( err != KErrNone ) |
|
2031 { |
|
2032 TestStepReference().SetTestStepError(err); |
|
2033 TestStepReference().SetTestStepResult(EFail); |
|
2034 } |
|
2035 } |
|
2036 return index; |
|
2037 } |
|
2038 |
|
2039 /* |
|
2040 * Get the fields required for testing AllFieldsLC() from the ini file |
|
2041 * @param aSection ini section |
|
2042 * @param aView desired view |
|
2043 * @return HBufC* contact item fields |
|
2044 */ |
|
2045 HBufC* CContactViewApiTest::GetAllFieldsLDataFromIniL(const TDesC& aSection, CContactViewBase* aView) |
|
2046 { |
|
2047 TInt index = -1; |
|
2048 TPtrC fieldSeparator; |
|
2049 TestStepReference().GetIntFromConfig(aSection, KIndex, index); |
|
2050 TestStepReference().GetStringFromConfig(aSection, KFieldSeparator, fieldSeparator); |
|
2051 |
|
2052 return (GetAllFieldsL(index, fieldSeparator, aView)); |
|
2053 } |
|
2054 |
|
2055 /* |
|
2056 * Get all the fields of the contact item located at the specified index |
|
2057 * @param aIndex retrieved index |
|
2058 * @param aSeparator separator to separate the fields |
|
2059 * @param aView desired view |
|
2060 * @return HBufC* contact item fields |
|
2061 */ |
|
2062 HBufC* CContactViewApiTest::GetAllFieldsL(TInt aIndex, const TDesC &aSeparator, CContactViewBase* aView) |
|
2063 { |
|
2064 HBufC* contactFields = NULL; |
|
2065 contactFields = aView->AllFieldsLC(aIndex, aSeparator); |
|
2066 if(contactFields!= NULL) |
|
2067 { |
|
2068 CleanupStack::Pop(contactFields); |
|
2069 } |
|
2070 return (contactFields); |
|
2071 } |
|
2072 |
|
2073 /* |
|
2074 * Get the sort order of the contact view |
|
2075 * @param aView desired view |
|
2076 * @param aErrorCondition diskfull or not ready |
|
2077 * @return RContactViewSortOrder sortOrder |
|
2078 */ |
|
2079 RContactViewSortOrder CContactViewApiTest::GetSortOrderL(CContactViewBase* aView, const TDesC& aErrorCondition) |
|
2080 { |
|
2081 RContactViewSortOrder viewSortOrder; |
|
2082 // Accessing the view when it is in disk full condition |
|
2083 if ( aErrorCondition != KNullDesC() ) |
|
2084 { |
|
2085 #ifdef __DEBUG |
|
2086 SetFsErrorConditionL(aErrorCondition, KFsAccessCount); |
|
2087 #endif |
|
2088 TRAPD( err, viewSortOrder = aView->SortOrderL()); |
|
2089 TPtrC errorCondition; |
|
2090 errorCondition.Set(_L("ErrorNone")); |
|
2091 #ifdef __DEBUG |
|
2092 SetFsErrorConditionL(errorCondition); |
|
2093 #endif |
|
2094 ValidateErrorCondition(err, aErrorCondition); |
|
2095 } |
|
2096 else |
|
2097 { |
|
2098 TRAPD( err, viewSortOrder = aView->SortOrderL()); |
|
2099 if ( err != KErrNone ) |
|
2100 { |
|
2101 TestStepReference().SetTestStepError(err); |
|
2102 TestStepReference().SetTestStepResult(EFail); |
|
2103 } |
|
2104 } |
|
2105 return viewSortOrder; |
|
2106 } |
|
2107 |
|
2108 /* |
|
2109 * Get the contact view preferences of the current view |
|
2110 * @param aView desired view |
|
2111 * @return TContactViewPreferences |
|
2112 */ |
|
2113 TContactViewPreferences CContactViewApiTest::ContactViewPreferences(CContactViewBase* aView) |
|
2114 { |
|
2115 return (aView->ContactViewPreferences()); |
|
2116 } |
|
2117 |
|
2118 /* |
|
2119 * Refine the find view by passing new set of search words or append characters to the existing search words |
|
2120 * @param aSearchWords refined search words |
|
2121 * @param aView desired view |
|
2122 * @param aContactUtility utility pointer |
|
2123 */ |
|
2124 void CContactViewApiTest::RefineFindViewL(const TDesC& aSearchWords, CContactFindView* aView, CContactUtilitiesCollection* aContactUtility) |
|
2125 { |
|
2126 RArray<TPtrC> searchStrings; |
|
2127 CleanupClosePushL(searchStrings); |
|
2128 aContactUtility->TokenizeStringL(aSearchWords, searchStrings); |
|
2129 |
|
2130 // Search words to refine the find view |
|
2131 CPtrCArray* findWords = new(ELeave) CPtrCArray(3); |
|
2132 CleanupStack::PushL(findWords); |
|
2133 for ( TInt i = 0; i < searchStrings.Count(); ++i ) |
|
2134 { |
|
2135 findWords->AppendL(searchStrings[i]); |
|
2136 } |
|
2137 |
|
2138 // Refine the find view with the new find words |
|
2139 TRAPD( err, aView->RefineFindViewL(findWords) ); |
|
2140 if ( err != KErrNone ) |
|
2141 { |
|
2142 TestStepReference().ERR_PRINTF1(KErrInRefineFindView); |
|
2143 TestStepReference().SetTestStepError(err); |
|
2144 TestStepReference().SetTestStepResult(EFail); |
|
2145 } |
|
2146 CleanupStack::PopAndDestroy(findWords); |
|
2147 CleanupStack::PopAndDestroy(&searchStrings); |
|
2148 } |
|
2149 |
|
2150 /* |
|
2151 * Get the contacts matching the specified criteria |
|
2152 * @param aSearchWords Criteria to search |
|
2153 * @param aView desired view |
|
2154 * @param aContactUtility utility pointer |
|
2155 * @return RPointerArray<CViewContact> |
|
2156 */ |
|
2157 RPointerArray<CViewContact> CContactViewApiTest::GetContactsMatchingCriteriaL(const TDesC& aSearchWords, CContactViewBase* aView, |
|
2158 CContactUtilitiesCollection* aContactUtility, const TDesC& aErrorCondition) |
|
2159 { |
|
2160 RArray<TPtrC> searchStrings; |
|
2161 CleanupClosePushL(searchStrings); |
|
2162 aContactUtility->TokenizeStringL(aSearchWords, searchStrings); |
|
2163 |
|
2164 // Append the search strings in the array which is required to pass in the API |
|
2165 CPtrCArray* findWords = new(ELeave) CPtrCArray(3); |
|
2166 CleanupStack::PushL(findWords); |
|
2167 for ( TInt i = 0; i < searchStrings.Count(); ++i ) |
|
2168 { |
|
2169 findWords->AppendL(searchStrings[i]); |
|
2170 } |
|
2171 |
|
2172 // get the contacts matching the findwords and return the matched contacts in the array |
|
2173 RPointerArray<CViewContact> matchedContacts; |
|
2174 if ( aErrorCondition != KNullDesC() ) |
|
2175 { |
|
2176 #ifdef __DEBUG |
|
2177 SetFsErrorConditionL(aErrorCondition, KFsAccessCount); |
|
2178 #endif |
|
2179 TRAPD( err, aView->ContactsMatchingCriteriaL(*findWords, matchedContacts) ); |
|
2180 TPtrC errorCondition; |
|
2181 errorCondition.Set(_L("ErrorNone")); |
|
2182 #ifdef __DEBUG |
|
2183 SetFsErrorConditionL(errorCondition); |
|
2184 #endif |
|
2185 ValidateErrorCondition(err, aErrorCondition); |
|
2186 } |
|
2187 else |
|
2188 { |
|
2189 TRAPD( err, aView->ContactsMatchingCriteriaL(*findWords, matchedContacts) ); |
|
2190 if ( err != KErrNone ) |
|
2191 { |
|
2192 TestStepReference().SetTestStepError(err); |
|
2193 TestStepReference().SetTestStepResult(EFail); |
|
2194 } |
|
2195 } |
|
2196 CleanupStack::PopAndDestroy(findWords); |
|
2197 CleanupStack::PopAndDestroy(&searchStrings); |
|
2198 return matchedContacts; |
|
2199 } |
|
2200 |
|
2201 /* |
|
2202 * Get the contacts where the search words matches the prefix of the contacts |
|
2203 * @param aSearchWords Criteria to search |
|
2204 * @param aView desired view |
|
2205 * @param aContactUtility utility pointer |
|
2206 * @return RPointerArray<CViewContact> |
|
2207 */ |
|
2208 RPointerArray<CViewContact> CContactViewApiTest::GetContactsMatchingPrefixL(const TDesC& aSearchWords, CContactViewBase* aView, |
|
2209 CContactUtilitiesCollection* aContactUtility, const TDesC& aErrorCondition) |
|
2210 { |
|
2211 RArray<TPtrC> searchStrings; |
|
2212 CleanupClosePushL(searchStrings); |
|
2213 aContactUtility->TokenizeStringL(aSearchWords, searchStrings); |
|
2214 // Append the search strings in the array which is required to pass in the ini file |
|
2215 CPtrCArray* findWords = new(ELeave) CPtrCArray(3); |
|
2216 CleanupStack::PushL(findWords); |
|
2217 for ( TInt i = 0; i < searchStrings.Count(); ++i ) |
|
2218 { |
|
2219 findWords->AppendL(searchStrings[i]); |
|
2220 } |
|
2221 // Get the contacts where the search words matches the prefix and return the matched contacts in the array |
|
2222 RPointerArray<CViewContact> matchedContacts; |
|
2223 if ( aErrorCondition != KNullDesC() ) |
|
2224 { |
|
2225 #ifdef __DEBUG |
|
2226 SetFsErrorConditionL(aErrorCondition, KFsAccessCount); |
|
2227 #endif |
|
2228 TRAPD( err, aView->ContactsMatchingPrefixL(*findWords, matchedContacts) ); |
|
2229 TPtrC errorCondition; |
|
2230 errorCondition.Set(_L("ErrorNone")); |
|
2231 #ifdef __DEBUG |
|
2232 SetFsErrorConditionL(errorCondition); |
|
2233 #endif |
|
2234 ValidateErrorCondition(err, aErrorCondition); |
|
2235 } |
|
2236 else |
|
2237 { |
|
2238 TRAPD( err, aView->ContactsMatchingPrefixL(*findWords, matchedContacts) ); |
|
2239 if ( err != KErrNone ) |
|
2240 { |
|
2241 TestStepReference().SetTestStepError(err); |
|
2242 TestStepReference().SetTestStepResult(EFail); |
|
2243 } |
|
2244 } |
|
2245 CleanupStack::PopAndDestroy(findWords); |
|
2246 CleanupStack::PopAndDestroy(&searchStrings); |
|
2247 return matchedContacts; |
|
2248 } |
|
2249 |
|
2250 |
|
2251 /** Based on the error condition, call the respective validate function |
|
2252 * @param aErr actual error code -- KErrDiskFull/KErrNotReady |
|
2253 * @param aErrorCondition expected error --- KErrDiskFull/KErrNotReady |
|
2254 */ |
|
2255 void CContactViewApiTest::ValidateErrorCondition(TInt aErr, const TDesC& aErrorCondition) |
|
2256 { |
|
2257 if ( aErrorCondition.Compare(KDiskFull) == 0 ) |
|
2258 { |
|
2259 ValidateResult(aErr, KErrDiskFull); |
|
2260 } |
|
2261 else |
|
2262 { |
|
2263 if ( aErrorCondition.Compare(KDiskNotReady) == 0 ) |
|
2264 { |
|
2265 ValidateResult(aErr, KErrNotReady); |
|
2266 } |
|
2267 else |
|
2268 { |
|
2269 ValidateResult(aErr, KErrNone); |
|
2270 } |
|
2271 } |
|
2272 } |
|
2273 |
|
2274 /** Validate and set the TestStep result to EFail, if required |
|
2275 * @param aActualResult - actual result |
|
2276 * @param aDesiredResult - desired result |
|
2277 */ |
|
2278 void CContactViewApiTest::ValidateResult(TInt aActualResult, TInt aDesiredResult) |
|
2279 { |
|
2280 if(aActualResult != aDesiredResult) |
|
2281 { |
|
2282 |
|
2283 TestStepReference().ERR_PRINTF3(KError, aActualResult, aDesiredResult); |
|
2284 TestStepReference().SetTestStepResult(EFail); |
|
2285 } |
|
2286 } |
|
2287 |
|
2288 #ifdef _DEBUG |
|
2289 /** |
|
2290 * Set the error condition to the file system |
|
2291 * @param aErrorCondition KDiskFull or KDiskNotReady |
|
2292 * @param aCount count |
|
2293 */ |
|
2294 void CContactViewApiTest::SetFsErrorConditionL(const TDesC& aErrorCondition, TInt aCount) |
|
2295 { |
|
2296 RFs& fs = GetFsSessionL(); |
|
2297 TInt res; |
|
2298 if ( aErrorCondition.Compare(KDiskFull) == 0 ) |
|
2299 { |
|
2300 res = fs.SetErrorCondition(KErrDiskFull, aCount); |
|
2301 |
|
2302 } |
|
2303 else if ( aErrorCondition.Compare(KDiskNotReady) == 0 ) |
|
2304 { |
|
2305 res = fs.SetErrorCondition(KErrNotReady, aCount); |
|
2306 } |
|
2307 else if ( aErrorCondition.Compare(KErrorNone) == 0 ) |
|
2308 { |
|
2309 res = fs.SetErrorCondition(0, aCount); |
|
2310 } |
|
2311 if(res != KErrNone) |
|
2312 { |
|
2313 TestStepReference().SetTestStepError(res); |
|
2314 TestStepReference().SetTestStepResult(EFail); |
|
2315 } |
|
2316 } |
|
2317 #endif |
|
2318 |
|
2319 /* |
|
2320 * Create a session with the file server |
|
2321 * @return RFs& file session |
|
2322 */ |
|
2323 RFs& CContactViewApiTest::GetFsSessionL() |
|
2324 { |
|
2325 User::LeaveIfError(iFsSession.Connect()); |
|
2326 return iFsSession; |
|
2327 } |
|
2328 |
|
2329 |
|
2330 /** |
|
2331 * CContactViewValidation |
|
2332 */ |
|
2333 |
|
2334 CContactViewValidation::CContactViewValidation(CTestStep* aTestStep) |
|
2335 : iTestStep(aTestStep) |
|
2336 { |
|
2337 } |
|
2338 |
|
2339 /* |
|
2340 * Destructor |
|
2341 */ |
|
2342 CContactViewValidation::~CContactViewValidation() |
|
2343 { |
|
2344 } |
|
2345 |
|
2346 /* |
|
2347 * Returns the test step reference |
|
2348 * @return CTestStep& |
|
2349 */ |
|
2350 CTestStep& CContactViewValidation::TestStepReference() |
|
2351 { |
|
2352 return *iTestStep; |
|
2353 } |
|
2354 |
|
2355 /* |
|
2356 * Validate the Contact item id returned by the AtL() API with the expected contact item id |
|
2357 * @param aContactItemId retrieved contact item id from the API |
|
2358 * @param aSection ini section |
|
2359 */ |
|
2360 void CContactViewValidation::ValidateAtLApi(TContactItemId aContactItemId, const TDesC& aSection) |
|
2361 { |
|
2362 TInt desiredContactItemId = -1; |
|
2363 TestStepReference().GetIntFromConfig(aSection, KDesiredContactItemId, desiredContactItemId); |
|
2364 if ( desiredContactItemId != aContactItemId ) |
|
2365 { |
|
2366 TestStepReference().ERR_PRINTF3(KErrExpectedAndRetrivedContactItemId, desiredContactItemId, aContactItemId); |
|
2367 TestStepReference().SetTestStepResult(EFail); |
|
2368 } |
|
2369 } |
|
2370 |
|
2371 /* |
|
2372 * Validate the Contact item id returned by the AtL() API with the expected contact item id |
|
2373 * @param aViewContact retrieved contact item |
|
2374 * @param aSection ini section |
|
2375 */ |
|
2376 void CContactViewValidation::ValidateContactAtLApi(CViewContact* aViewContact, const TDesC& aSection) |
|
2377 { |
|
2378 TInt desiredContactId = -1; |
|
2379 TestStepReference().GetIntFromConfig(aSection, KDesiredContactId, desiredContactId); |
|
2380 |
|
2381 if ( aViewContact->Id() != desiredContactId ) |
|
2382 { |
|
2383 TestStepReference().ERR_PRINTF1(KErrInContactType); |
|
2384 TestStepReference().SetTestStepResult(EFail); |
|
2385 } |
|
2386 } |
|
2387 |
|
2388 /* |
|
2389 * Validate count with the expectedCount |
|
2390 * @param aSection ini section |
|
2391 * @param aCount retrieved count from the API |
|
2392 */ |
|
2393 void CContactViewValidation::ValidateCountL(const TDesC& aSection, TInt aCount) |
|
2394 { |
|
2395 TInt desiredCount = -1; |
|
2396 TestStepReference().GetIntFromConfig(aSection, KDesiredCount, desiredCount); |
|
2397 if ( aCount != desiredCount ) |
|
2398 { |
|
2399 TestStepReference().ERR_PRINTF3(KErrExpectedAndRetrievedCount, desiredCount, aCount); |
|
2400 TestStepReference().SetTestStepResult(EFail); |
|
2401 } |
|
2402 } |
|
2403 |
|
2404 /* |
|
2405 * Validate the index returned by FindL() API with the expected Index |
|
2406 * @param aSection ini section |
|
2407 * @param aIndex retrieved index |
|
2408 */ |
|
2409 void CContactViewValidation::ValidateFindL(const TDesC& aSection, TInt aIndex) |
|
2410 { |
|
2411 TInt desiredIndex = -1; |
|
2412 TestStepReference().GetIntFromConfig(aSection, KDesiredIndex, desiredIndex); |
|
2413 if ( aIndex != desiredIndex ) |
|
2414 { |
|
2415 TestStepReference().ERR_PRINTF3(KErrExpectedAndRetrievedIndex, desiredIndex, aIndex); |
|
2416 TestStepReference().SetTestStepResult(EFail); |
|
2417 } |
|
2418 } |
|
2419 |
|
2420 /* |
|
2421 * Validate all the fields of the contact item and compare it the with the expected fields |
|
2422 * @param aSection ini section |
|
2423 * @param retrievedField fields retrieved by the API |
|
2424 * @param aView deisred view |
|
2425 */ |
|
2426 void CContactViewValidation::ValidateAllFieldsL(const TDesC& aSection, RArray<TPtrC> aRetrievedField, CContactViewBase* aView, |
|
2427 CContactViewApiTest* aViewApiTest) |
|
2428 { |
|
2429 TInt index = -1; |
|
2430 TestStepReference().GetIntFromConfig(aSection, KIndex, index); |
|
2431 // Get the contact item located at the specified index in the view |
|
2432 CViewContact* viewContact = aViewApiTest->ContactAtL(index, aView); |
|
2433 // Count the number of fields for the contact item |
|
2434 TInt count = viewContact->FieldCount(); |
|
2435 TPtrC field; |
|
2436 for ( TInt i = 0; i < count; ++i ) |
|
2437 { |
|
2438 //retrieve the fields one by one by specifying the position |
|
2439 field.Set(viewContact->Field(i)); |
|
2440 // Compare the fields retrived by AllFieldsLC() and ContactAtL() API's and log the result |
|
2441 if ( aRetrievedField[i] != field ) |
|
2442 { |
|
2443 TestStepReference().ERR_PRINTF3(KErrExpectedAndRetrievedFields, &field, &aRetrievedField[i]); |
|
2444 TestStepReference().SetTestStepResult(EFail); |
|
2445 } |
|
2446 } |
|
2447 } |
|
2448 |
|
2449 /* |
|
2450 * Validate the view preferences with the expected view preferences |
|
2451 * @param aSection ini section |
|
2452 * @param viewPreferences retrieved view preferences |
|
2453 */ |
|
2454 void CContactViewValidation::ValidateViewPreferencesL(const TDesC& aSection, TContactViewPreferences& aViewPreferences, |
|
2455 CContactUtilitiesCollection* aContactUtility) |
|
2456 { |
|
2457 TPtrC viewPreferences1; |
|
2458 TestStepReference().GetStringFromConfig(aSection, KViewPreferences, viewPreferences1); |
|
2459 TContactViewPreferences expectedViewPreferences = aContactUtility->ConvertStringToContactViewPreferencesL(viewPreferences1); |
|
2460 if ( expectedViewPreferences != aViewPreferences) |
|
2461 { |
|
2462 TestStepReference().ERR_PRINTF3(KErrExpectedAndRetrievedViewPreferences, expectedViewPreferences, aViewPreferences); |
|
2463 TestStepReference().SetTestStepResult(EFail); |
|
2464 } |
|
2465 } |
|
2466 |
|
2467 /* |
|
2468 * Validate the uid's of the expected and retrieved sort order |
|
2469 * @param aUid retrieved Uid from the API |
|
2470 * @param aExpecteUid expectedUid passed from the ini file |
|
2471 */ |
|
2472 void CContactViewValidation::ValidateSortOrderL(const TUid& aUid, const TUid& aExpectedUid) |
|
2473 { |
|
2474 if ( aUid != aExpectedUid ) |
|
2475 { |
|
2476 TestStepReference().ERR_PRINTF3(KErrExpectedAndRetrievedUid, aUid, aExpectedUid); |
|
2477 TestStepReference().SetTestStepResult(EFail); |
|
2478 } |
|
2479 } |
|
2480 |
|
2481 /* |
|
2482 * Imports contacts from a VCF file into specified database file |
|
2483 * @param aSection ini section |
|
2484 * @param aImportFileName file to be imported |
|
2485 * @param aDb reference to the pointed of CContactDatabase |
|
2486 */ |
|
2487 void CContactUtilitiesCollection::ImportVcardContactsL(const TPtrC& aImportFileName, TBool aPbapBased) |
|
2488 { |
|
2489 // Get the version of the VCard parser to be used |
|
2490 TUid pluginUid; |
|
2491 pluginUid.iUid = KUidVCardConvDefaultImpl; // Supports version 2.1 and 3.0 |
|
2492 |
|
2493 |
|
2494 if( aPbapBased ) |
|
2495 { |
|
2496 pluginUid.iUid = KUidPBAPVCardConvImpl; // used only when the vCard has pbap specific properties |
|
2497 } |
|
2498 |
|
2499 // Connect to file system |
|
2500 RFs fsSession; |
|
2501 User::LeaveIfError(fsSession.Connect()); |
|
2502 CleanupClosePushL(fsSession); |
|
2503 RFileReadStream readStream; |
|
2504 CleanupClosePushL(readStream); |
|
2505 |
|
2506 // Open the the file from which the contact data has to be imported |
|
2507 User::LeaveIfError(readStream.Open(fsSession, aImportFileName, EFileRead)); |
|
2508 |
|
2509 CArrayPtr<CContactItem>* item = NULL; |
|
2510 TBool success = EFalse; |
|
2511 CContactDatabase& cDb = DatabaseReference(); |
|
2512 FOREVER |
|
2513 { |
|
2514 TRAPD( err, item = cDb.ImportContactsL(pluginUid, readStream, success, CContactDatabase::EImportSingleContact) ); |
|
2515 if( success == EFalse ) // success will set to false, if there are issues during import operation |
|
2516 { // or all the contacts in the vcf file are imported |
|
2517 break; |
|
2518 } |
|
2519 if ( err != KErrNone ) |
|
2520 { |
|
2521 _LIT(KErrInImportContacts, "Error in importcontacts"); |
|
2522 BaseTestStepReference().ERR_PRINTF1(KErrInImportContacts); |
|
2523 } |
|
2524 |
|
2525 if( item->Count() ) |
|
2526 { |
|
2527 item->ResetAndDestroy(); |
|
2528 } |
|
2529 } |
|
2530 |
|
2531 CleanupStack::PopAndDestroy(); // readStream |
|
2532 CleanupStack::PopAndDestroy(); // fsSession |
|
2533 } |
|
2534 |
|
2535 /* |
|
2536 * Get the desired view observer |
|
2537 * @param aTypeOfView Type of view like local, Remote, NamedRemote etc. |
|
2538 * @param aViewIndex Index of the view |
|
2539 * @return CContactViewEventQueue returns a reference to the desired view observer |
|
2540 */ |
|
2541 CContactViewEventQueue& CContactViewCollection::GetDesiredViewObserver(const TDesC& aTypeOfView, const TInt aViewIndex) |
|
2542 { |
|
2543 CContactViewEventQueue* viewEventQueue = NULL; |
|
2544 |
|
2545 if ( aTypeOfView.Compare(KLocalView) == 0 ) |
|
2546 { |
|
2547 viewEventQueue = iArrayOfLocalViewEvents[aViewIndex]; |
|
2548 } |
|
2549 else if ( aTypeOfView.Compare(KRemoteView) == 0 ) |
|
2550 { |
|
2551 viewEventQueue = iArrayOfRemoteViewEvents[aViewIndex]; |
|
2552 } |
|
2553 else if ( aTypeOfView.Compare(KNamedRemoteView) == 0 ) |
|
2554 { |
|
2555 viewEventQueue = iArrayOfNamedRemoteViewEvents[aViewIndex]; |
|
2556 } |
|
2557 else if ( aTypeOfView.Compare(KFindView) == 0 ) |
|
2558 { |
|
2559 viewEventQueue = iArrayOfFindViewEvents[aViewIndex]; |
|
2560 } |
|
2561 else if ( aTypeOfView.Compare(KFilteredView) == 0 ) |
|
2562 { |
|
2563 viewEventQueue = iArrayOfFilteredViewEvents[aViewIndex]; |
|
2564 } |
|
2565 else if ( aTypeOfView.Compare(KGroupView) == 0 ) |
|
2566 { |
|
2567 viewEventQueue = iArrayOfGroupViewEvents[aViewIndex]; |
|
2568 } |
|
2569 else if ( aTypeOfView.Compare(KConcatenatedView) == 0 ) |
|
2570 { |
|
2571 viewEventQueue = iArrayOfConcatenatedViewEvents[aViewIndex]; |
|
2572 } |
|
2573 else if ( aTypeOfView.Compare(KSubView) == 0 ) |
|
2574 { |
|
2575 viewEventQueue = iArrayOfSubViewEvents[aViewIndex]; |
|
2576 } |
|
2577 return *viewEventQueue; |
|
2578 } |
|
2579 |
|
2580 /* |
|
2581 * Get the desired view |
|
2582 * @param aTypeOfView Type of view like local, Remote, NamedRemote etc. |
|
2583 * @param aViewIndex Index of the view |
|
2584 * @return CContactViewBase return the pointer of desired view |
|
2585 */ |
|
2586 CContactViewBase* CContactViewCollection::GetDesiredView(const TDesC& aTypeOfView, const TInt aViewIndex) |
|
2587 { |
|
2588 CContactViewBase* desiredView = NULL; |
|
2589 |
|
2590 if ( aTypeOfView.Compare(KLocalView) == 0 ) |
|
2591 { |
|
2592 desiredView = iArrayOfLocalViews[aViewIndex]; |
|
2593 } |
|
2594 else if ( aTypeOfView.Compare(KRemoteView) == 0 ) |
|
2595 { |
|
2596 desiredView = iArrayOfRemoteViews[aViewIndex]; |
|
2597 } |
|
2598 else if ( aTypeOfView.Compare(KNamedRemoteView) == 0 ) |
|
2599 { |
|
2600 desiredView = iArrayOfNamedRemoteViews[aViewIndex]; |
|
2601 } |
|
2602 else if ( aTypeOfView.Compare(KFindView) == 0 ) |
|
2603 { |
|
2604 desiredView = iArrayOfFindViews[aViewIndex]; |
|
2605 } |
|
2606 else if ( aTypeOfView.Compare(KFilteredView) == 0 ) |
|
2607 { |
|
2608 desiredView = iArrayOfFilteredViews[aViewIndex]; |
|
2609 } |
|
2610 else if ( aTypeOfView.Compare(KGroupView) == 0 ) |
|
2611 { |
|
2612 desiredView = iArrayOfGroupViews[aViewIndex]; |
|
2613 } |
|
2614 else if ( aTypeOfView.Compare(KConcatenatedView) == 0 ) |
|
2615 { |
|
2616 desiredView = iArrayOfConcatenatedViews[aViewIndex]; |
|
2617 } |
|
2618 else if ( aTypeOfView.Compare(KSubView) == 0 ) |
|
2619 { |
|
2620 desiredView = iArrayOfSubViews[aViewIndex]; |
|
2621 } |
|
2622 return desiredView; |
|
2623 } |
|
2624 |
|
2625 /* |
|
2626 * Construct the desired views based on data from the ini file |
|
2627 */ |
|
2628 void CContactUtilitiesCollection::ConstructViewsL() |
|
2629 { |
|
2630 TPtrC listOfViews; |
|
2631 BaseTestStepReference().GetStringFromConfig(BaseTestStepReference().ConfigSection(), SharedConstants::KListOfViews, listOfViews); |
|
2632 RArray<TPtrC> sections; |
|
2633 CleanupClosePushL(sections); |
|
2634 TokenizeStringL(listOfViews, sections); |
|
2635 ConstructViewsL(sections); |
|
2636 CleanupStack::PopAndDestroy(§ions); |
|
2637 } |
|
2638 |
|
2639 /* |
|
2640 * Wait for view to ready |
|
2641 * @param aViewEventQueue used to queued the events. |
|
2642 */ |
|
2643 void CContactUtilitiesCollection::WaitForViewReady(CContactViewEventQueue*& aViewEventQueue) |
|
2644 { |
|
2645 TContactViewEvent event; |
|
2646 // wait for the event to get ready |
|
2647 TBool eventReady = aViewEventQueue->ListenForEvent(KEventWaitTime, event); |
|
2648 __ASSERT_ALWAYS(eventReady, User::Invariant()); |
|
2649 ASSERT(event.iEventType == TContactViewEvent::EReady); |
|
2650 } |
|
2651 |
|
2652 /* |
|
2653 * Retrieve the desired contact view observer from the view collection |
|
2654 * @param aTestStepReference - Reference to current test step, used to read data from the ini file |
|
2655 */ |
|
2656 CContactViewEventQueue& CContactViewCollection::RetrieveDesiredViewObserverL( |
|
2657 CTestStep& aTestStepReference) |
|
2658 |
|
2659 { |
|
2660 TInt desiredViewIndex = 0; |
|
2661 _LIT(KDesiredViewIndex, "DesiredViewIndex"); |
|
2662 aTestStepReference.GetIntFromConfig(aTestStepReference.ConfigSection(), KDesiredViewIndex, desiredViewIndex); |
|
2663 |
|
2664 TPtrC desiredViewType; |
|
2665 _LIT(KDesiredViewType, "DesiredViewType"); |
|
2666 aTestStepReference.GetStringFromConfig(aTestStepReference.ConfigSection(), KDesiredViewType, desiredViewType); |
|
2667 |
|
2668 return(GetDesiredViewObserver(desiredViewType, desiredViewIndex)); |
|
2669 } |
|
2670 |
|
2671 /* |
|
2672 * Imports contacts into database |
|
2673 */ |
|
2674 void CContactUtilitiesCollection::ImportContactsL() |
|
2675 { |
|
2676 // File from where contacts must be imported |
|
2677 TPtrC importFileName; |
|
2678 TBool filePresent; |
|
2679 filePresent = BaseTestStepReference().GetStringFromConfig(BaseTestStepReference().ConfigSection(), SharedConstants::KFileToBeImported, importFileName); |
|
2680 |
|
2681 TBool pbapBased = EFalse; |
|
2682 BaseTestStepReference().GetBoolFromConfig(BaseTestStepReference().ConfigSection(), SharedConstants::KVCardVersionPBAP, pbapBased); |
|
2683 if(filePresent) |
|
2684 { |
|
2685 ImportVcardContactsL(importFileName, pbapBased); |
|
2686 } |
|
2687 } |
|
2688 |