|
1 /* |
|
2 * Copyright (c) 2008 Nokia Corporation and/or its subsidiary(-ies). |
|
3 * All rights reserved. |
|
4 * This component and the accompanying materials are made available |
|
5 * under the terms of "Eclipse Public License v1.0" |
|
6 * which accompanies this distribution, and is available |
|
7 * at the URL "http://www.eclipse.org/legal/epl-v10.html". |
|
8 * |
|
9 * Initial Contributors: |
|
10 * Nokia Corporation - initial contribution. |
|
11 * |
|
12 * Contributors: |
|
13 * |
|
14 * Description: Temporary listbox model. |
|
15 * |
|
16 */ |
|
17 |
|
18 #include <VPbkContactStoreUris.h> |
|
19 #include <VPbkUtils.h> |
|
20 #include <MVPbkBaseContactFieldCollection.h> |
|
21 #include <MVPbkBaseContactField.h> |
|
22 #include <MVPbkContactFieldTextData.h> |
|
23 #include <MVPbkContactFieldUriData.h> |
|
24 #include <MVPbkContactFieldDateTimeData.h> |
|
25 #include <MVPbkContactFieldData.h> |
|
26 #include <MVPbkContactLinkArray.h> |
|
27 #include <CVPbkContactManager.h> |
|
28 #include <MVPbkContactOperationBase.h> |
|
29 #include <MVPbkContactStoreProperties.h> |
|
30 #include <MVPbkContactStore.h> |
|
31 #include <MVPbkFieldType.h> |
|
32 #include <MVPbkStoreContact.h> |
|
33 #include <CVPbkTopContactManager.h> |
|
34 #include <MVPbkContactAttributeManager.h> |
|
35 #include <CVPbkSpeedDialAttribute.h> |
|
36 #include <CVPbkDefaultAttribute.h> |
|
37 #include <MVPbkStoreContactField2.h> |
|
38 |
|
39 #include <CPbk2StorePropertyArray.h> |
|
40 #include <MPbk2ContactNameFormatter.h> |
|
41 #include <MPbk2FieldProperty.h> |
|
42 #include <MPbk2FieldPropertyArray.h> |
|
43 #include <Pbk2FieldPropertiesFactory.h> |
|
44 #include <TPbk2StoreContactAnalyzer.h> |
|
45 |
|
46 #include "TPbk2ContactEditorParams.h" |
|
47 #include "CPbk2ContactEditorDlg.h" |
|
48 |
|
49 #include "CPbk2ServiceManager.h" |
|
50 #include "CPbk2FieldPropertyArray.h" |
|
51 #include "CPbk2PresentationContact.h" |
|
52 #include "CPbk2PresentationContactField.h" |
|
53 #include "CPbk2PresentationContactFieldCollection.h" |
|
54 #include "CPbk2StoreSpecificFieldPropertyArray.h" |
|
55 #include "CPbk2IconArray.h" |
|
56 #include <CPbk2UIExtensionManager.h> |
|
57 #include <CPbk2ApplicationServices.h> |
|
58 #include <Pbk2PresentationUtils.h> |
|
59 #include <Pbk2AddressTools.h> |
|
60 #include <TVPbkFieldTypeParameters.h> |
|
61 #include <TVPbkFieldVersitProperty.h> |
|
62 #include <StringLoader.h> |
|
63 |
|
64 #include <TPbk2AppIconId.h> |
|
65 |
|
66 #include <aknlists.h> |
|
67 |
|
68 #include <avkon.rsg> |
|
69 #include <VPbkEng.rsg> |
|
70 #include <Pbk2UIControls.rsg> |
|
71 |
|
72 #include "ccappdetailsviewlistboxmodel.h" |
|
73 #include "ccappdetailsviewdefs.h" |
|
74 #include <ccappdetailsviewpluginrsc.rsg> |
|
75 #include "ccappdetailsviewplugin.h" |
|
76 #include "ccappdetailsviewpluginuids.hrh" |
|
77 #include "ccappdetailsview.hrh" |
|
78 |
|
79 const TInt KCacheGranularity = 4; |
|
80 const TInt KBufferSize = 256; |
|
81 |
|
82 _LIT( KCharsToReplace, "\t" ); |
|
83 _LIT( KReplacementChars, " " ); |
|
84 |
|
85 const TText KReplacedChars = ' '; |
|
86 |
|
87 |
|
88 // ======== LOCAL FUNCTIONS ======== |
|
89 |
|
90 // Utility to check file existence without BAFL |
|
91 inline TBool FileExists(RFs& aFs, const TDesC& aFileName) |
|
92 { |
|
93 TEntry ignore; |
|
94 return (aFs.Entry(aFileName, ignore) == KErrNone); |
|
95 } |
|
96 |
|
97 // ======== MEMBER FUNCTIONS ======== |
|
98 |
|
99 // -------------------------------------------------------------------------- |
|
100 // CCCAppDetailsViewListBoxRow::CCCAppDetailsViewListBoxRow |
|
101 // -------------------------------------------------------------------------- |
|
102 // |
|
103 inline CCCAppDetailsViewListBoxRow::CCCAppDetailsViewListBoxRow() |
|
104 { |
|
105 } |
|
106 |
|
107 // -------------------------------------------------------------------------- |
|
108 // CCCAppDetailsViewListBoxRow::~CCCAppDetailsViewListBoxRow |
|
109 // -------------------------------------------------------------------------- |
|
110 // |
|
111 CCCAppDetailsViewListBoxRow::~CCCAppDetailsViewListBoxRow() |
|
112 { |
|
113 iColumns.ResetAndDestroy(); |
|
114 } |
|
115 |
|
116 // -------------------------------------------------------------------------- |
|
117 // CCCAppDetailsViewListBoxRow::NewL |
|
118 // -------------------------------------------------------------------------- |
|
119 // |
|
120 CCCAppDetailsViewListBoxRow* CCCAppDetailsViewListBoxRow::NewL() |
|
121 { |
|
122 return new(ELeave) CCCAppDetailsViewListBoxRow; |
|
123 } |
|
124 |
|
125 // -------------------------------------------------------------------------- |
|
126 // CCCAppDetailsViewListBoxRow::ColumnCount |
|
127 // -------------------------------------------------------------------------- |
|
128 // |
|
129 TInt CCCAppDetailsViewListBoxRow::ColumnCount() const |
|
130 { |
|
131 return iColumns.Count(); |
|
132 } |
|
133 |
|
134 // -------------------------------------------------------------------------- |
|
135 // CCCAppDetailsViewListBoxRow::At |
|
136 // -------------------------------------------------------------------------- |
|
137 // |
|
138 TPtrC CCCAppDetailsViewListBoxRow::At(TInt aColumnIndex) const |
|
139 { |
|
140 return *iColumns[aColumnIndex]; |
|
141 } |
|
142 |
|
143 // -------------------------------------------------------------------------- |
|
144 // CCCAppDetailsViewListBoxRow::AppendColumnL |
|
145 // -------------------------------------------------------------------------- |
|
146 // |
|
147 void CCCAppDetailsViewListBoxRow::AppendColumnL(const TDesC& aColumnText) |
|
148 { |
|
149 HBufC* buf = aColumnText.AllocLC(); |
|
150 User::LeaveIfError(iColumns.Append(buf)); |
|
151 CleanupStack::Pop(buf); |
|
152 } |
|
153 |
|
154 // -------------------------------------------------------------------------- |
|
155 // CCCAppDetailsViewListBoxRow::IsClipRequired |
|
156 // -------------------------------------------------------------------------- |
|
157 // |
|
158 TBool CCCAppDetailsViewListBoxRow::IsClipRequired() const |
|
159 { |
|
160 return iClipBeginning; |
|
161 } |
|
162 |
|
163 // -------------------------------------------------------------------------- |
|
164 // CCCAppDetailsViewListBoxRow::SetClipRequired |
|
165 // -------------------------------------------------------------------------- |
|
166 // |
|
167 void CCCAppDetailsViewListBoxRow::SetClipRequired(TBool aFlag) |
|
168 { |
|
169 iClipBeginning = aFlag; |
|
170 } |
|
171 |
|
172 // -------------------------------------------------------------------------- |
|
173 // CCCAppDetailsViewListBoxRow::TotalLength |
|
174 // -------------------------------------------------------------------------- |
|
175 // |
|
176 TInt CCCAppDetailsViewListBoxRow::TotalLength() const |
|
177 { |
|
178 TInt result = 0; |
|
179 const TInt count = iColumns.Count(); |
|
180 for (TInt i = 0; i < count; ++i) |
|
181 { |
|
182 result += At(i).Length(); |
|
183 } |
|
184 return result; |
|
185 } |
|
186 |
|
187 // -------------------------------------------------------------------------- |
|
188 // CCCAppDetailsViewListBoxRow::MaxColumnLength |
|
189 // -------------------------------------------------------------------------- |
|
190 // |
|
191 TInt CCCAppDetailsViewListBoxRow::MaxColumnLength() const |
|
192 { |
|
193 TInt result = 0; |
|
194 const TInt count = iColumns.Count(); |
|
195 for (TInt i = 0; i < count; ++i) |
|
196 { |
|
197 result = Max(result, At(i).Length()); |
|
198 } |
|
199 return result; |
|
200 } |
|
201 |
|
202 // --------------------------------------------------------------------------- |
|
203 // CCCAppDetailsViewListBoxModel::NewL |
|
204 // --------------------------------------------------------------------------- |
|
205 // |
|
206 CCCAppDetailsViewListBoxModel* CCCAppDetailsViewListBoxModel::NewL( |
|
207 CCoeEnv& aCoeEnv, |
|
208 CEikListBox& aListBox, |
|
209 CPbk2ApplicationServices* aApplicationServices, |
|
210 CPbk2IconArray& aIconArray, |
|
211 CCCAppDetailsViewPlugin& aPlugin) |
|
212 { |
|
213 CCCAppDetailsViewListBoxModel* self = |
|
214 new(ELeave) CCCAppDetailsViewListBoxModel( |
|
215 aCoeEnv, aListBox, aApplicationServices, aIconArray, |
|
216 aPlugin); |
|
217 CleanupStack::PushL(self); |
|
218 self->ConstructL(); |
|
219 CleanupStack::Pop(self); |
|
220 |
|
221 return self; |
|
222 } |
|
223 |
|
224 // --------------------------------------------------------------------------- |
|
225 // CCCAppDetailsViewListBoxModel::~CCCAppDetailsViewListBoxModel |
|
226 // --------------------------------------------------------------------------- |
|
227 // |
|
228 CCCAppDetailsViewListBoxModel::~CCCAppDetailsViewListBoxModel() |
|
229 { |
|
230 Cancel(); |
|
231 |
|
232 iRows.ResetAndDestroy(); |
|
233 delete iLineBuf; |
|
234 delete iColumnBuf; |
|
235 delete iLinks; |
|
236 delete iStoreContact; |
|
237 delete iPresentationContact; |
|
238 delete iSpecificFieldProperties; |
|
239 delete iFieldProperties; |
|
240 delete iRetrieveOperation; |
|
241 iInxToPresentationIdx.Close(); |
|
242 } |
|
243 |
|
244 // --------------------------------------------------------------------------- |
|
245 // CCCAppDetailsViewListBoxModel::CCCAppDetailsViewListBoxModel |
|
246 // --------------------------------------------------------------------------- |
|
247 // |
|
248 CCCAppDetailsViewListBoxModel::CCCAppDetailsViewListBoxModel( |
|
249 CCoeEnv& aCoeEnv, |
|
250 CEikListBox& aListBox, |
|
251 CPbk2ApplicationServices* aApplicationServices, |
|
252 CPbk2IconArray& aIconArray, |
|
253 CCCAppDetailsViewPlugin& aPlugin) |
|
254 : |
|
255 CActive(EPriorityStandard), |
|
256 iCoeEnv(aCoeEnv), |
|
257 iListBox(aListBox), |
|
258 iRows(KCacheGranularity), |
|
259 iAppServices(aApplicationServices), |
|
260 iIconArray(aIconArray), |
|
261 iCommand(ECCAppDetailsViewCommandNone), |
|
262 iIsEditingAborted(EFalse), |
|
263 iPlugin(aPlugin) |
|
264 { |
|
265 CActiveScheduler::Add(this); |
|
266 } |
|
267 |
|
268 // --------------------------------------------------------------------------- |
|
269 // CCCAppDetailsViewListBoxModel::ConstructL |
|
270 // --------------------------------------------------------------------------- |
|
271 // |
|
272 void CCCAppDetailsViewListBoxModel::ConstructL() |
|
273 { |
|
274 CCA_DP(KDetailsViewLogFile, CCA_L(">>> CCCAppDetailsViewListBoxModel::ConstructL()")); |
|
275 |
|
276 CCA_DP(KDetailsViewLogFile, CCA_L("iInitialFocusIndex = %d"), iInitialFocusIndex); |
|
277 |
|
278 iLineBuf = HBufC::NewL(KBufferSize); |
|
279 iColumnBuf = HBufC::NewL(KBufferSize); |
|
280 |
|
281 CCA_DP(KDetailsViewLogFile, CCA_L("<<< CCCAppDetailsViewListBoxModel::ConstructL()")); |
|
282 } |
|
283 |
|
284 // --------------------------------------------------------------------------- |
|
285 // CCCAppDetailsViewListBoxModel::SetLinks |
|
286 // --------------------------------------------------------------------------- |
|
287 // |
|
288 void CCCAppDetailsViewListBoxModel::SetLinks(MVPbkContactLinkArray* aLinks) |
|
289 { |
|
290 delete iLinks; |
|
291 iLinks = aLinks; |
|
292 //iCurrentLink is now invalid since it points to old iLinks array |
|
293 iCurrentLink = NULL; |
|
294 |
|
295 delete iRetrieveOperation; |
|
296 iRetrieveOperation = NULL; |
|
297 |
|
298 IssueRequest(); |
|
299 } |
|
300 |
|
301 // --------------------------------------------------------------------------- |
|
302 // CCCAppDetailsViewListBoxModel::Links |
|
303 // --------------------------------------------------------------------------- |
|
304 // |
|
305 MVPbkContactLinkArray* CCCAppDetailsViewListBoxModel::Links() const |
|
306 { |
|
307 return iLinks; |
|
308 } |
|
309 |
|
310 // --------------------------------------------------------------------------- |
|
311 // CCCAppDetailsViewListBoxModel::OpenEditorL |
|
312 // --------------------------------------------------------------------------- |
|
313 // |
|
314 void CCCAppDetailsViewListBoxModel::OpenEditorL() |
|
315 { |
|
316 if (iStoreContact) |
|
317 { |
|
318 iCommand = ECCAppDetailsViewCommandEdit; |
|
319 iStoreContact->LockL(*this); |
|
320 } |
|
321 } |
|
322 |
|
323 // --------------------------------------------------------------------------- |
|
324 // CCCAppDetailsViewListBoxModel::FocusedFieldIndex |
|
325 // --------------------------------------------------------------------------- |
|
326 // |
|
327 TInt CCCAppDetailsViewListBoxModel::FocusedFieldIndex() |
|
328 { |
|
329 TInt *index = iInxToPresentationIdx.Find(iListBox.CurrentItemIndex()); |
|
330 |
|
331 if (index && *index >= KErrNone) |
|
332 { |
|
333 return iPresentationContact->PresentationFields().StoreIndexOfField(*index); |
|
334 } |
|
335 else |
|
336 { |
|
337 return KErrNotFound; |
|
338 } |
|
339 } |
|
340 |
|
341 // --------------------------------------------------------------------------- |
|
342 // CCCAppDetailsViewListBoxModel::FocusedListIndex |
|
343 // --------------------------------------------------------------------------- |
|
344 // |
|
345 TInt CCCAppDetailsViewListBoxModel::FocusedListIndex() |
|
346 { |
|
347 return iListBox.CurrentItemIndex(); |
|
348 } |
|
349 |
|
350 // --------------------------------------------------------------------------- |
|
351 // CCCAppDetailsViewListBoxModel::SetFocusedListIndex |
|
352 // --------------------------------------------------------------------------- |
|
353 // |
|
354 void CCCAppDetailsViewListBoxModel::SetFocusedListIndex(TInt aIndex) |
|
355 { |
|
356 TInt items = iListBox.Model()->NumberOfItems(); |
|
357 |
|
358 if (aIndex >= items) |
|
359 { |
|
360 aIndex = items - 1; |
|
361 } |
|
362 if (aIndex < 0) |
|
363 { |
|
364 aIndex = 0; |
|
365 } |
|
366 |
|
367 CCA_DP(KDetailsViewLogFile, CCA_L(">>> CCCAppDetailsViewListBoxModel::SetFocusedListIndex( %d )"), aIndex); |
|
368 |
|
369 iListBox.SetCurrentItemIndexAndDraw(aIndex); |
|
370 } |
|
371 |
|
372 // --------------------------------------------------------------------------- |
|
373 // CCCAppDetailsViewListBoxModel::SetInitialFocusIndex |
|
374 // --------------------------------------------------------------------------- |
|
375 // |
|
376 void CCCAppDetailsViewListBoxModel::SetInitialFocusIndex(TInt aIndex) |
|
377 { |
|
378 CCA_DP(KDetailsViewLogFile, CCA_L(">>> CCCAppDetailsViewListBoxModel::SetInitialFocusIndex( %d )"), aIndex); |
|
379 |
|
380 if (aIndex >= 0) |
|
381 { |
|
382 iInitialFocusIndex = aIndex; |
|
383 } |
|
384 } |
|
385 |
|
386 // -------------------------------------------------------------------------- |
|
387 // CCCAppDetailsViewListBoxModel::FocusedFieldLC |
|
388 // -------------------------------------------------------------------------- |
|
389 // |
|
390 MVPbkBaseContactField* CCCAppDetailsViewListBoxModel::FocusedFieldLC() |
|
391 { |
|
392 const TInt listIndex = iListBox.CurrentItemIndex(); |
|
393 |
|
394 if (listIndex != KErrNotFound) |
|
395 { |
|
396 return FieldAtLC(listIndex); |
|
397 } |
|
398 |
|
399 return NULL; |
|
400 } |
|
401 |
|
402 // -------------------------------------------------------------------------- |
|
403 // CCCAppDetailsViewListBoxModel::StoreContact |
|
404 // -------------------------------------------------------------------------- |
|
405 // |
|
406 MVPbkStoreContact* CCCAppDetailsViewListBoxModel::StoreContact() |
|
407 { |
|
408 return iStoreContact; |
|
409 } |
|
410 |
|
411 // -------------------------------------------------------------------------- |
|
412 // CCCAppDetailsViewListBoxModel::GetContactTitleL |
|
413 // -------------------------------------------------------------------------- |
|
414 // |
|
415 HBufC* CCCAppDetailsViewListBoxModel::GetContactTitleL() |
|
416 { |
|
417 |
|
418 HBufC* title = iAppServices->NameFormatter().GetContactTitleL( |
|
419 iStoreContact->Fields(), |
|
420 MPbk2ContactNameFormatter::EPreserveLeadingSpaces | |
|
421 MPbk2ContactNameFormatter::EUseSeparator); |
|
422 |
|
423 return title; |
|
424 } |
|
425 |
|
426 // -------------------------------------------------------------------------- |
|
427 // CCCAppDetailsViewListBoxModel::IsFocusedFieldTypeL |
|
428 // -------------------------------------------------------------------------- |
|
429 // |
|
430 TBool CCCAppDetailsViewListBoxModel::IsFocusedFieldTypeL(TInt aSelectorResId) |
|
431 { |
|
432 TBool ret = EFalse; |
|
433 |
|
434 MVPbkBaseContactField* field = FocusedFieldLC(); |
|
435 |
|
436 if (field) |
|
437 { |
|
438 TPbk2StoreContactAnalyzer analyzer( |
|
439 iAppServices->ContactManager(), NULL); |
|
440 |
|
441 ret = analyzer.IsFieldTypeIncludedL(*field, aSelectorResId); |
|
442 |
|
443 CleanupStack::PopAndDestroy(field); |
|
444 } |
|
445 |
|
446 return ret; |
|
447 } |
|
448 |
|
449 // -------------------------------------------------------------------------- |
|
450 // CCCAppDetailsViewListBoxModel::HasContactFieldTypeL |
|
451 // -------------------------------------------------------------------------- |
|
452 // |
|
453 TBool CCCAppDetailsViewListBoxModel::HasContactFieldTypeL(TInt aSelectorResId) |
|
454 { |
|
455 TBool ret = EFalse; |
|
456 |
|
457 TPbk2StoreContactAnalyzer analyzer( |
|
458 iAppServices->ContactManager(), iStoreContact); |
|
459 |
|
460 ret = analyzer.HasFieldL(aSelectorResId); |
|
461 |
|
462 return (ret != KErrNotFound); |
|
463 } |
|
464 |
|
465 // -------------------------------------------------------------------------- |
|
466 // CCCAppDetailsViewListBoxModel::IsTopContact |
|
467 // -------------------------------------------------------------------------- |
|
468 // |
|
469 TBool CCCAppDetailsViewListBoxModel::IsTopContact() const |
|
470 { |
|
471 return CVPbkTopContactManager::IsTopContact(*iStoreContact); |
|
472 } |
|
473 |
|
474 // -------------------------------------------------------------------------- |
|
475 // CCCAppDetailsViewListBoxModel::IsReadOnlyContact |
|
476 // -------------------------------------------------------------------------- |
|
477 // |
|
478 TBool CCCAppDetailsViewListBoxModel::IsReadOnlyContact() const |
|
479 { |
|
480 return iStoreContact->ParentStore().StoreProperties().ReadOnly(); |
|
481 } |
|
482 |
|
483 // --------------------------------------------------------------------------- |
|
484 // CCCAppDetailsViewListBoxModel::IsSimContact |
|
485 // --------------------------------------------------------------------------- |
|
486 // |
|
487 TBool CCCAppDetailsViewListBoxModel::IsSimContact() const |
|
488 { |
|
489 TVPbkContactStoreUriPtr adnUri(VPbkContactStoreUris::SimGlobalAdnUri()); |
|
490 TVPbkContactStoreUriPtr fdnUri(VPbkContactStoreUris::SimGlobalFdnUri()); |
|
491 |
|
492 TVPbkContactStoreUriPtr uri = |
|
493 iStoreContact->ParentStore().StoreProperties().Uri(); |
|
494 |
|
495 return ( |
|
496 (uri.Compare(adnUri, |
|
497 TVPbkContactStoreUriPtr::EContactStoreUriAllComponents) == 0) |
|
498 || |
|
499 (uri.Compare(fdnUri, |
|
500 TVPbkContactStoreUriPtr::EContactStoreUriAllComponents) == 0) |
|
501 ); |
|
502 } |
|
503 |
|
504 // --------------------------------------------------------------------------- |
|
505 // CCCAppDetailsViewListBoxModel::IsSdnContact |
|
506 // --------------------------------------------------------------------------- |
|
507 // |
|
508 TBool CCCAppDetailsViewListBoxModel::IsSdnContact() const |
|
509 { |
|
510 TVPbkContactStoreUriPtr sdnUri(VPbkContactStoreUris::SimGlobalSdnUri()); |
|
511 |
|
512 TVPbkContactStoreUriPtr uri = |
|
513 iStoreContact->ParentStore().StoreProperties().Uri(); |
|
514 |
|
515 return (uri.Compare(sdnUri, |
|
516 TVPbkContactStoreUriPtr::EContactStoreUriAllComponents) == 0); |
|
517 } |
|
518 |
|
519 // -------------------------------------------------------------------------- |
|
520 // CCCAppDetailsViewListBoxModel::HasSpeedDialL |
|
521 // -------------------------------------------------------------------------- |
|
522 // |
|
523 TBool CCCAppDetailsViewListBoxModel::HasSpeedDialL(TInt aIndex) |
|
524 { |
|
525 TBool hasAttribute = EFalse; |
|
526 |
|
527 if (aIndex != KErrNotFound) |
|
528 { |
|
529 const MVPbkStoreContactField& field = |
|
530 iStoreContact->Fields().FieldAt(aIndex); |
|
531 |
|
532 hasAttribute = iAppServices->ContactManager().ContactAttributeManagerL(). |
|
533 HasFieldAttributeL(CVPbkSpeedDialAttribute::Uid(), field); |
|
534 } |
|
535 |
|
536 return hasAttribute; |
|
537 } |
|
538 |
|
539 // -------------------------------------------------------------------------- |
|
540 // CCCAppDetailsViewListBoxModel::HasDefaultsL |
|
541 // -------------------------------------------------------------------------- |
|
542 // |
|
543 TBool CCCAppDetailsViewListBoxModel::HasDefaultsL(TInt aIndex) |
|
544 { |
|
545 TBool hasAttribute = EFalse; |
|
546 |
|
547 if (aIndex != KErrNotFound) |
|
548 { |
|
549 const MVPbkStoreContactField& field = |
|
550 iStoreContact->Fields().FieldAt(aIndex); |
|
551 |
|
552 hasAttribute = iAppServices->ContactManager().ContactAttributeManagerL(). |
|
553 HasFieldAttributeL(CVPbkDefaultAttribute::Uid(), field); |
|
554 } |
|
555 |
|
556 return hasAttribute; |
|
557 } |
|
558 |
|
559 // --------------------------------------------------------------------------- |
|
560 // CCCAppDetailsViewListBoxModel::RunL |
|
561 // --------------------------------------------------------------------------- |
|
562 // |
|
563 void CCCAppDetailsViewListBoxModel::RunL() |
|
564 { |
|
565 TInt index = 0; |
|
566 |
|
567 if (iLinks && iCurrentLink) |
|
568 { |
|
569 index = iLinks->Find(*iCurrentLink) + 1; |
|
570 } |
|
571 |
|
572 if (iAppServices && iLinks && index < iLinks->Count()) |
|
573 { |
|
574 iCurrentLink = &iLinks->At(index); |
|
575 |
|
576 iRetrieveOperation = iAppServices->ContactManager().RetrieveContactL |
|
577 (*iCurrentLink, *this); |
|
578 } |
|
579 else |
|
580 { |
|
581 iCurrentLink = NULL; |
|
582 } |
|
583 } |
|
584 |
|
585 // --------------------------------------------------------------------------- |
|
586 // CCCAppDetailsViewListBoxModel::RunError |
|
587 // --------------------------------------------------------------------------- |
|
588 // |
|
589 TInt CCCAppDetailsViewListBoxModel::RunError(TInt aError) |
|
590 { |
|
591 return aError; |
|
592 } |
|
593 |
|
594 // --------------------------------------------------------------------------- |
|
595 // CCCAppDetailsViewListBoxModel::DoCancel |
|
596 // --------------------------------------------------------------------------- |
|
597 // |
|
598 void CCCAppDetailsViewListBoxModel::DoCancel() |
|
599 { |
|
600 } |
|
601 |
|
602 // -------------------------------------------------------------------------- |
|
603 // CCCAppDetailsViewListBoxModel::ContactOperationCompleted |
|
604 // -------------------------------------------------------------------------- |
|
605 // |
|
606 void CCCAppDetailsViewListBoxModel::ContactOperationCompleted( |
|
607 TContactOpResult /*aResult*/) |
|
608 { |
|
609 if (iCommand == ECCAppDetailsViewCommandEdit) |
|
610 { |
|
611 // open editing dialog |
|
612 TRAP_IGNORE(ExecuteEditorL()); |
|
613 |
|
614 iCommand = ECCAppDetailsViewCommandNone; |
|
615 } |
|
616 } |
|
617 |
|
618 // -------------------------------------------------------------------------- |
|
619 // CCCAppDetailsViewListBoxModel::ContactOperationFailed |
|
620 // -------------------------------------------------------------------------- |
|
621 // |
|
622 void CCCAppDetailsViewListBoxModel::ContactOperationFailed( |
|
623 TContactOp /*aOpCode*/, |
|
624 TInt /*aErrorCode*/, |
|
625 TBool /*aErrorNotified*/) |
|
626 { |
|
627 } |
|
628 |
|
629 // -------------------------------------------------------------------------- |
|
630 // CCCAppDetailsViewListBoxModel::ContactEditingComplete |
|
631 // -------------------------------------------------------------------------- |
|
632 // |
|
633 void CCCAppDetailsViewListBoxModel::ContactEditingComplete( |
|
634 MVPbkStoreContact* aEditedContact) |
|
635 { |
|
636 iStoreContact = aEditedContact; |
|
637 } |
|
638 |
|
639 // -------------------------------------------------------------------------- |
|
640 // CCCAppDetailsViewListBoxModel::ContactEditingDeletedContact |
|
641 // -------------------------------------------------------------------------- |
|
642 // |
|
643 void CCCAppDetailsViewListBoxModel::ContactEditingDeletedContact( |
|
644 MVPbkStoreContact* aEditedContact) |
|
645 { |
|
646 iStoreContact = aEditedContact; |
|
647 } |
|
648 |
|
649 // -------------------------------------------------------------------------- |
|
650 // CCCAppDetailsViewListBoxModel::ContactEditingAborted |
|
651 // -------------------------------------------------------------------------- |
|
652 // |
|
653 void CCCAppDetailsViewListBoxModel::ContactEditingAborted() |
|
654 { |
|
655 iIsEditingAborted = ETrue; |
|
656 } |
|
657 |
|
658 // --------------------------------------------------------------------------- |
|
659 // CCCAppDetailsViewListBoxModel::VPbkSingleContactOperationComplete |
|
660 // --------------------------------------------------------------------------- |
|
661 // |
|
662 void CCCAppDetailsViewListBoxModel::VPbkSingleContactOperationComplete( |
|
663 MVPbkContactOperationBase& /*aOperation*/, |
|
664 MVPbkStoreContact* aContact) |
|
665 { |
|
666 CCA_DP(KDetailsViewLogFile, CCA_L(">>> CCCAppDetailsViewListBoxModel::VPbkSingleContactOperationComplete()")); |
|
667 |
|
668 delete iRetrieveOperation; |
|
669 iRetrieveOperation = NULL; |
|
670 |
|
671 delete iStoreContact; |
|
672 iStoreContact = aContact; |
|
673 |
|
674 TRAP_IGNORE( |
|
675 CreatePresentationContactL(); |
|
676 AddDataL(); |
|
677 SetTitleL(); |
|
678 UpdateMSKinCbaL(); |
|
679 ); |
|
680 |
|
681 SetFocusedListIndex(iInitialFocusIndex); |
|
682 |
|
683 /*if (!iXspIdModifyState) |
|
684 { |
|
685 iXspIdModifyState++; |
|
686 switch (iXspIdModifyState) |
|
687 { |
|
688 case 1: |
|
689 aContact->LockL(*this); |
|
690 break; |
|
691 default: |
|
692 // Continue, the xspid is set now |
|
693 IssueRequest(); |
|
694 break; |
|
695 } |
|
696 } |
|
697 else*/ |
|
698 { |
|
699 IssueRequest(); |
|
700 } |
|
701 |
|
702 CCA_DP(KDetailsViewLogFile, CCA_L("<<< CCCAppDetailsViewListBoxModel::VPbkSingleContactOperationComplete()")); |
|
703 } |
|
704 |
|
705 // --------------------------------------------------------------------------- |
|
706 // CCCAppDetailsViewListBoxModel::VPbkSingleContactOperationFailed |
|
707 // --------------------------------------------------------------------------- |
|
708 // |
|
709 void CCCAppDetailsViewListBoxModel::VPbkSingleContactOperationFailed( |
|
710 MVPbkContactOperationBase& /*aOperation*/, |
|
711 TInt /*aError*/) |
|
712 { |
|
713 delete iRetrieveOperation; |
|
714 iRetrieveOperation = NULL; |
|
715 |
|
716 IssueRequest(); |
|
717 } |
|
718 |
|
719 // --------------------------------------------------------------------------- |
|
720 // CCCAppDetailsViewListBoxModel::MdcaCount |
|
721 // --------------------------------------------------------------------------- |
|
722 // |
|
723 TInt CCCAppDetailsViewListBoxModel::MdcaCount() const |
|
724 { |
|
725 return iRows.Count(); |
|
726 } |
|
727 |
|
728 // --------------------------------------------------------------------------- |
|
729 // CCCAppDetailsViewListBoxModel::MdcaPoint |
|
730 // --------------------------------------------------------------------------- |
|
731 // |
|
732 TPtrC CCCAppDetailsViewListBoxModel::MdcaPoint(TInt aIndex) const |
|
733 { |
|
734 const TText KSeparator = '\t'; |
|
735 TPtr rowText(iLineBuf->Des()); |
|
736 rowText.Zero(); |
|
737 |
|
738 const CCCAppDetailsViewListBoxRow& row = *iRows[aIndex]; |
|
739 const TInt columnCount = row.ColumnCount(); |
|
740 TInt fieldCount = iPresentationContact->PresentationFields().FieldCount(); |
|
741 |
|
742 for (TInt index = 0; index < columnCount; ++index) |
|
743 { |
|
744 TPtr columnText(iColumnBuf->Des()); |
|
745 columnText.Copy(row.At(index)); |
|
746 |
|
747 // Clip the column if required |
|
748 if (index == EContentColumn && row.IsClipRequired() && aIndex < fieldCount) |
|
749 { |
|
750 ClipFromBeginning(columnText, aIndex, index); |
|
751 } |
|
752 |
|
753 // Append the column and separator to the formatted row |
|
754 rowText.Append(columnText); |
|
755 rowText.Append(KSeparator); |
|
756 } |
|
757 |
|
758 return rowText; |
|
759 } |
|
760 |
|
761 // --------------------------------------------------------------------------- |
|
762 // CCCAppDetailsViewListBoxModel::IssueRequest |
|
763 // --------------------------------------------------------------------------- |
|
764 // |
|
765 void CCCAppDetailsViewListBoxModel::IssueRequest(TInt aError) |
|
766 { |
|
767 if (IsActive()) |
|
768 { |
|
769 return; |
|
770 } |
|
771 TRequestStatus* status = &iStatus; |
|
772 User::RequestComplete(status, aError); |
|
773 SetActive(); |
|
774 } |
|
775 |
|
776 // --------------------------------------------------------------------------- |
|
777 // CCCAppDetailsViewListBoxModel::CreatePresentationContactL |
|
778 // --------------------------------------------------------------------------- |
|
779 // |
|
780 void CCCAppDetailsViewListBoxModel::CreatePresentationContactL() |
|
781 { |
|
782 delete iSpecificFieldProperties; |
|
783 iSpecificFieldProperties = NULL; |
|
784 delete iFieldProperties; |
|
785 iFieldProperties = NULL; |
|
786 |
|
787 RFs& fsSession(iCoeEnv.FsSession()); |
|
788 |
|
789 const MVPbkContactStoreProperties& storeProperties = |
|
790 iStoreContact->ParentStore().StoreProperties(); |
|
791 const MVPbkFieldTypeList& supportedFieldTypes = |
|
792 storeProperties.SupportedFields(); |
|
793 |
|
794 CPbk2ServiceManager& servMan = iAppServices->ServiceManager(); |
|
795 |
|
796 iFieldProperties = |
|
797 CPbk2FieldPropertyArray::NewL(supportedFieldTypes, fsSession, &servMan); |
|
798 |
|
799 // Create a field property list of the supported |
|
800 // field types of the used store |
|
801 CPbk2StorePropertyArray& pbk2StoreProperties = iAppServices->StoreProperties(); |
|
802 |
|
803 iSpecificFieldProperties = CPbk2StoreSpecificFieldPropertyArray::NewL( |
|
804 *iFieldProperties, |
|
805 pbk2StoreProperties, |
|
806 supportedFieldTypes, |
|
807 iStoreContact->ParentStore()); |
|
808 |
|
809 delete iPresentationContact; |
|
810 iPresentationContact = NULL; |
|
811 |
|
812 iPresentationContact = |
|
813 CPbk2PresentationContact::NewL(*iStoreContact, *iSpecificFieldProperties); |
|
814 } |
|
815 |
|
816 // -------------------------------------------------------------------------- |
|
817 // CCCAppDetailsViewListBoxModel::AddDataL |
|
818 // -------------------------------------------------------------------------- |
|
819 // |
|
820 void CCCAppDetailsViewListBoxModel::AddDataL() |
|
821 { |
|
822 //CCA_DP(KDetailsViewLogFile, CCA_L(">>> CCCAppDetailsViewListBoxModel::AddDataL()")); |
|
823 |
|
824 iRows.ResetAndDestroy(); |
|
825 iInxToPresentationIdx.Close(); |
|
826 |
|
827 SetEmptyTextL(R_QTN_PHOB_NO_ITEMS); // in pbk2uicontrols.rsg |
|
828 |
|
829 TInt fieldCount = iPresentationContact->PresentationFields().FieldCount(); |
|
830 |
|
831 TBuf<KBufferSize> buffer; |
|
832 |
|
833 TVPbkFieldTypeParameters fieldParams; |
|
834 TInt listIdx = -1; |
|
835 |
|
836 for (TInt index = 0; index < fieldCount; index++) |
|
837 { |
|
838 CPbk2PresentationContactField& field = |
|
839 iPresentationContact->PresentationFields().At(index); |
|
840 |
|
841 // Get master field type list and match field's type against it |
|
842 const MVPbkFieldType* fieldType = VPbkUtils::MatchFieldType( |
|
843 iAppServices->ContactManager().FieldTypes(), field); |
|
844 |
|
845 // TODO: what about field.IsVisibleInDetailsView() ? |
|
846 |
|
847 if (field.IsEditable() && fieldType && !IsHiddenField(fieldType)) |
|
848 { |
|
849 TInt labelResId = 0; |
|
850 TVPbkFieldTypeName fieldTypeName = EVPbkVersitNameNone; |
|
851 TPbk2FieldGroupId groupId = EPbk2FieldGroupIdNone; |
|
852 TArray<TVPbkFieldVersitProperty> versitArr = fieldType->VersitProperties(); |
|
853 |
|
854 if (versitArr.Count()) |
|
855 { |
|
856 const TVPbkFieldVersitProperty& prop = versitArr[0]; |
|
857 |
|
858 if (prop.Name() == EVPbkVersitNameADR) |
|
859 { |
|
860 if (versitArr[0].Parameters().Contains(EVPbkVersitParamHOME)) |
|
861 { |
|
862 if (fieldParams.Contains(EVPbkVersitParamHOME)) |
|
863 { |
|
864 continue; |
|
865 } |
|
866 fieldParams.Add(EVPbkVersitParamHOME); |
|
867 labelResId = R_QTN_PHOB_LBL_ADDRESS_HOME; |
|
868 groupId = EPbk2FieldGroupIdHomeAddress; |
|
869 } |
|
870 else if (versitArr[0].Parameters().Contains(EVPbkVersitParamWORK)) |
|
871 { |
|
872 if (fieldParams.Contains(EVPbkVersitParamWORK)) |
|
873 { |
|
874 continue; |
|
875 } |
|
876 fieldParams.Add(EVPbkVersitParamWORK); |
|
877 labelResId = R_QTN_PHOB_LBL_ADDRESS_WORK; |
|
878 groupId = EPbk2FieldGroupIdCompanyAddress; |
|
879 } |
|
880 else |
|
881 { |
|
882 if (fieldParams.Contains(EVPbkVersitParamPREF)) |
|
883 { |
|
884 continue; |
|
885 } |
|
886 fieldParams.Add(EVPbkVersitParamPREF); |
|
887 labelResId = R_QTN_PHOB_LBL_ADDRESS; |
|
888 groupId = EPbk2FieldGroupIdPostalAddress; |
|
889 } |
|
890 fieldTypeName = EVPbkVersitNameADR; |
|
891 } |
|
892 } |
|
893 |
|
894 if (fieldTypeName == EVPbkVersitNameADR) |
|
895 { |
|
896 HBufC* label = StringLoader::LoadLC(labelResId); |
|
897 CCCAppDetailsViewListBoxRow* row = CCCAppDetailsViewListBoxRow::NewL(); |
|
898 CleanupStack::PushL(row); |
|
899 |
|
900 // add icon. |
|
901 buffer.Zero(); |
|
902 TInt iconIndex = 0; |
|
903 if (IsAddressValidated(groupId)) |
|
904 { |
|
905 TPbk2IconId iconId(TUid::Uid(KPbk2UID3), EPbk2qgn_prop_locev_map); |
|
906 iconIndex = iIconArray.FindIcon(iconId); |
|
907 buffer.AppendNum(iconIndex); |
|
908 } |
|
909 else |
|
910 { |
|
911 TPbk2IconId iconId(TUid::Uid(KPbk2UID3), EPbk2qgn_prop_pb_no_valid_lm); |
|
912 iconIndex = iIconArray.FindIcon(iconId); |
|
913 buffer.AppendNum(iconIndex); |
|
914 } |
|
915 row->AppendColumnL(buffer); |
|
916 |
|
917 // add label. |
|
918 row->AppendColumnL(*label); |
|
919 |
|
920 RBuf text; |
|
921 Pbk2AddressTools::GetAddressPreviewLC(*iStoreContact, groupId, text); |
|
922 |
|
923 row->AppendColumnL(text); |
|
924 CleanupStack::PopAndDestroy(&text); |
|
925 |
|
926 // Expand row formatting buffer if required |
|
927 ExpandBuffersL(row); |
|
928 |
|
929 // Add the row. |
|
930 iRows.AppendL(row); |
|
931 iInxToPresentationIdx.InsertL(++listIdx, index); |
|
932 CleanupStack::Pop(row); |
|
933 CleanupStack::PopAndDestroy(label); |
|
934 } |
|
935 else |
|
936 { |
|
937 HBufC* label = GetLabelLC(field); |
|
938 |
|
939 if (label->Length()) |
|
940 { |
|
941 TBool skipThisData(EFalse); |
|
942 CCCAppDetailsViewListBoxRow* row = CCCAppDetailsViewListBoxRow::NewL(); |
|
943 CleanupStack::PushL(row); |
|
944 |
|
945 const MVPbkContactFieldData& fieldData = field.FieldData(); |
|
946 |
|
947 // add icon. |
|
948 buffer.Zero(); |
|
949 TInt iconIndex = iIconArray.FindIcon(field.FieldProperty().IconId()); |
|
950 buffer.AppendNum(iconIndex); |
|
951 row->AppendColumnL(buffer); |
|
952 |
|
953 // add label. |
|
954 row->AppendColumnL(*label); |
|
955 |
|
956 // Add current index to Presentation Contact index array |
|
957 // to estimate the text is needed to clip or not. |
|
958 if(!skipThisData) |
|
959 { |
|
960 iInxToPresentationIdx.InsertL(++listIdx, index); |
|
961 } |
|
962 |
|
963 |
|
964 // add field content. |
|
965 switch (fieldData.DataType()) |
|
966 { |
|
967 case EVPbkFieldStorageTypeText: |
|
968 { |
|
969 TBool defaultTextSet = HandleTextTypeFieldL( |
|
970 index, |
|
971 fieldData, |
|
972 row, |
|
973 fieldType->FieldTypeResId()); |
|
974 //Don't show default ringtone |
|
975 if (defaultTextSet && |
|
976 fieldType->FieldTypeResId() == R_VPBK_FIELD_TYPE_RINGTONE) |
|
977 { |
|
978 skipThisData = ETrue; |
|
979 } |
|
980 } |
|
981 break; |
|
982 |
|
983 case EVPbkFieldStorageTypeDateTime: |
|
984 HandleDateTimeTypeFieldL(fieldData, row); |
|
985 break; |
|
986 |
|
987 case EVPbkFieldStorageTypeUri: |
|
988 HandleUriTypeFieldL(index, fieldData, row); |
|
989 break; |
|
990 |
|
991 default: |
|
992 break; |
|
993 } |
|
994 |
|
995 AddIconsToEndL(index, row); |
|
996 |
|
997 // Expand row formatting buffer if required |
|
998 ExpandBuffersL(row); |
|
999 |
|
1000 // Add the row if data ok to show to user. |
|
1001 if(!skipThisData) |
|
1002 { |
|
1003 iRows.AppendL(row); |
|
1004 CleanupStack::Pop(row); |
|
1005 } |
|
1006 else |
|
1007 { |
|
1008 CleanupStack::PopAndDestroy(row); |
|
1009 } |
|
1010 } |
|
1011 |
|
1012 CleanupStack::PopAndDestroy(label); |
|
1013 } |
|
1014 } |
|
1015 } // for |
|
1016 |
|
1017 iListBox.HandleItemAdditionL(); |
|
1018 |
|
1019 //CCA_DP(KDetailsViewLogFile, CCA_L("<<< CCCAppDetailsViewListBoxModel::AddDataL()")); |
|
1020 } |
|
1021 |
|
1022 // -------------------------------------------------------------------------- |
|
1023 // CCCAppDetailsViewListBoxModel::IsAddressValidated |
|
1024 // -------------------------------------------------------------------------- |
|
1025 // |
|
1026 TBool CCCAppDetailsViewListBoxModel::IsAddressValidated(TInt aGroupId) |
|
1027 { |
|
1028 CPbk2PresentationContactFieldCollection& fields = |
|
1029 iPresentationContact->PresentationFields(); |
|
1030 |
|
1031 for (TInt idx = 0; idx < fields.FieldCount(); idx++) |
|
1032 { |
|
1033 MVPbkStoreContactField& field = fields.FieldAt(idx); |
|
1034 TInt countProps = |
|
1035 field.BestMatchingFieldType()->VersitProperties().Count(); |
|
1036 TArray<TVPbkFieldVersitProperty> props = |
|
1037 field.BestMatchingFieldType()->VersitProperties(); |
|
1038 |
|
1039 for (TInt idx2 = 0; idx2 < countProps; idx2++) |
|
1040 { |
|
1041 if (props[idx2].Name() == EVPbkVersitNameGEO && |
|
1042 ((props[idx2].Parameters().Contains(EVPbkVersitParamHOME) && |
|
1043 aGroupId == EPbk2FieldGroupIdHomeAddress) || |
|
1044 (props[idx2].Parameters().Contains(EVPbkVersitParamWORK) && |
|
1045 aGroupId == EPbk2FieldGroupIdCompanyAddress) || |
|
1046 (!props[idx2].Parameters().Contains(EVPbkVersitParamHOME) && |
|
1047 !props[idx2].Parameters().Contains(EVPbkVersitParamWORK) && |
|
1048 aGroupId == EPbk2FieldGroupIdPostalAddress))) |
|
1049 { |
|
1050 return ETrue; |
|
1051 } |
|
1052 } |
|
1053 } |
|
1054 return EFalse; |
|
1055 } |
|
1056 |
|
1057 // -------------------------------------------------------------------------- |
|
1058 // CCCAppDetailsViewListBoxModel::IsHiddenField |
|
1059 // -------------------------------------------------------------------------- |
|
1060 // |
|
1061 TBool CCCAppDetailsViewListBoxModel::IsHiddenField( |
|
1062 const MVPbkFieldType* aFieldType) |
|
1063 { |
|
1064 TInt resId = aFieldType->FieldTypeResId(); |
|
1065 |
|
1066 return (resId == R_VPBK_FIELD_TYPE_SYNCCLASS); |
|
1067 } |
|
1068 |
|
1069 // --------------------------------------------------------------------------- |
|
1070 // CCCAppDetailsViewListBoxModel::FieldAtLC |
|
1071 // --------------------------------------------------------------------------- |
|
1072 // |
|
1073 MVPbkBaseContactField* CCCAppDetailsViewListBoxModel::FieldAtLC(TInt aIndex) |
|
1074 { |
|
1075 TInt *presentationIdx = iInxToPresentationIdx.Find(aIndex); |
|
1076 |
|
1077 if (!presentationIdx) |
|
1078 { |
|
1079 return NULL; |
|
1080 } |
|
1081 |
|
1082 TInt index = iPresentationContact->PresentationFields().StoreIndexOfField( |
|
1083 *presentationIdx); |
|
1084 |
|
1085 if (index != KErrNotFound) |
|
1086 { |
|
1087 // Use FieldAtLC to avoid the unvalidity of the field after new |
|
1088 // FieldAt call. |
|
1089 return iStoreContact->Fields().FieldAtLC(index); |
|
1090 } |
|
1091 |
|
1092 return NULL; |
|
1093 } |
|
1094 |
|
1095 // --------------------------------------------------------------------------- |
|
1096 // CCCAppDetailsViewListBoxModel::IsFieldTypeL |
|
1097 // --------------------------------------------------------------------------- |
|
1098 // |
|
1099 TBool CCCAppDetailsViewListBoxModel::IsFieldTypeL( |
|
1100 TInt aIndex, |
|
1101 TInt aSelectorResId) |
|
1102 { |
|
1103 TBool ret = EFalse; |
|
1104 |
|
1105 MVPbkBaseContactField* field = FieldAtLC(aIndex); |
|
1106 |
|
1107 if (field) |
|
1108 { |
|
1109 TPbk2StoreContactAnalyzer analyzer(iAppServices->ContactManager(), NULL); |
|
1110 |
|
1111 ret = analyzer.IsFieldTypeIncludedL(*field, aSelectorResId); |
|
1112 |
|
1113 CleanupStack::PopAndDestroy(field); |
|
1114 } |
|
1115 |
|
1116 return ret; |
|
1117 } |
|
1118 |
|
1119 // --------------------------------------------------------------------------- |
|
1120 // CCCAppDetailsViewListBoxModel::HandleTextTypeFieldL |
|
1121 // --------------------------------------------------------------------------- |
|
1122 // |
|
1123 TBool CCCAppDetailsViewListBoxModel::HandleTextTypeFieldL( |
|
1124 TInt aIndex, |
|
1125 const MVPbkContactFieldData& aFieldData, |
|
1126 CCCAppDetailsViewListBoxRow* aRow, |
|
1127 TInt aResId) |
|
1128 { |
|
1129 TBool defaultTextInserted(EFalse); |
|
1130 const TDesC& fieldText = |
|
1131 MVPbkContactFieldTextData::Cast(aFieldData).Text(); |
|
1132 |
|
1133 if (aResId == R_VPBK_FIELD_TYPE_CALLEROBJIMG || |
|
1134 aResId == R_VPBK_FIELD_TYPE_RINGTONE) |
|
1135 { |
|
1136 RFs& fsSession(iCoeEnv.FsSession()); |
|
1137 |
|
1138 if (FileExists(fsSession, fieldText)) |
|
1139 { |
|
1140 // parse path and show only filename. |
|
1141 HBufC* textBuf = HBufC::NewLC(fieldText.Length()); |
|
1142 TPtr text = textBuf->Des(); |
|
1143 text.Append(fieldText); |
|
1144 |
|
1145 TParsePtr parse(text); |
|
1146 TPtrC fileName(parse.Name()); |
|
1147 |
|
1148 aRow->AppendColumnL(fileName); |
|
1149 |
|
1150 CleanupStack::PopAndDestroy(textBuf); |
|
1151 } |
|
1152 else |
|
1153 { |
|
1154 defaultTextInserted = ETrue; |
|
1155 TInt textResId = R_QTN_PHOB_FIELD_DEFAULT_TONE; // in pbk2uicontrols.rsg |
|
1156 |
|
1157 if (aResId == R_VPBK_FIELD_TYPE_CALLEROBJIMG) |
|
1158 { |
|
1159 textResId = R_QTN_PHOB_FIELD_THUMBNAIL; // in pbk2uicontrols.rsg |
|
1160 } |
|
1161 |
|
1162 // cold filename (e.g mem card not present), show default text. |
|
1163 HBufC* defaultText = iCoeEnv.AllocReadResourceLC(textResId); |
|
1164 aRow->AppendColumnL(*defaultText); |
|
1165 CleanupStack::PopAndDestroy(defaultText); |
|
1166 } |
|
1167 } |
|
1168 else |
|
1169 { |
|
1170 TBool isNumberField = IsFieldTypeL(aIndex, R_DETAILSVIEW_PHONENUMBER_SELECTOR); |
|
1171 TBool isAddressField = IsFieldTypeL(aIndex, R_DETAILSVIEW_EL_ADDRESS_SELECTOR); |
|
1172 |
|
1173 if (isNumberField || isAddressField) |
|
1174 { |
|
1175 aRow->SetClipRequired(ETrue); |
|
1176 } |
|
1177 |
|
1178 TPtr columnBuf(iColumnBuf->Des()); |
|
1179 |
|
1180 columnBuf.Set(ExpandColumnBufferL(fieldText.Length())); |
|
1181 columnBuf.Zero(); |
|
1182 |
|
1183 // replace listbox separator characters. |
|
1184 Pbk2PresentationUtils::AppendAndReplaceChars( |
|
1185 columnBuf, fieldText, KCharsToReplace, KReplacementChars); |
|
1186 |
|
1187 // Replace characters that can not be displayed correctly. |
|
1188 Pbk2PresentationUtils::ReplaceNonGraphicCharacters(columnBuf, ' '); |
|
1189 |
|
1190 if ( isNumberField ) |
|
1191 { |
|
1192 AknTextUtils::LanguageSpecificNumberConversion( columnBuf ); |
|
1193 } |
|
1194 aRow->AppendColumnL(columnBuf); |
|
1195 } |
|
1196 return defaultTextInserted; |
|
1197 } |
|
1198 |
|
1199 // --------------------------------------------------------------------------- |
|
1200 // CCCAppDetailsViewListBoxModel::HandleDateTimeTypeFieldL |
|
1201 // --------------------------------------------------------------------------- |
|
1202 // |
|
1203 void CCCAppDetailsViewListBoxModel::HandleDateTimeTypeFieldL( |
|
1204 const MVPbkContactFieldData& aFieldData, |
|
1205 CCCAppDetailsViewListBoxRow* aRow) |
|
1206 { |
|
1207 TLocale locale; |
|
1208 TBuf<64> dateBuffer; |
|
1209 |
|
1210 const MVPbkContactFieldDateTimeData& date = |
|
1211 MVPbkContactFieldDateTimeData::Cast(aFieldData); |
|
1212 |
|
1213 TTime time(date.DateTime()); |
|
1214 |
|
1215 HBufC* dateFormat = iCoeEnv.AllocReadResourceLC( |
|
1216 R_QTN_DATE_USUAL_WITH_ZERO); // in avkon.rsg |
|
1217 time.FormatL(dateBuffer, *dateFormat, locale); |
|
1218 CleanupStack::PopAndDestroy(dateFormat); |
|
1219 |
|
1220 AknTextUtils::LanguageSpecificNumberConversion( dateBuffer ); |
|
1221 aRow->AppendColumnL(dateBuffer); |
|
1222 } |
|
1223 |
|
1224 // --------------------------------------------------------------------------- |
|
1225 // CCCAppDetailsViewListBoxModel::HandleUriTypeFieldL |
|
1226 // --------------------------------------------------------------------------- |
|
1227 // |
|
1228 void CCCAppDetailsViewListBoxModel::HandleUriTypeFieldL( |
|
1229 TInt /*aIndex*/, |
|
1230 const MVPbkContactFieldData& aFieldData, |
|
1231 CCCAppDetailsViewListBoxRow* aRow) |
|
1232 { |
|
1233 const MVPbkContactFieldUriData& uri = |
|
1234 MVPbkContactFieldUriData::Cast(aFieldData); |
|
1235 |
|
1236 HBufC* tempBuf = uri.Text().AllocLC(); |
|
1237 TPtr text = tempBuf->Des(); |
|
1238 // Replace characters that can not be displayed correctly. |
|
1239 Pbk2PresentationUtils::ReplaceNonGraphicCharacters( text, KReplacedChars ); |
|
1240 aRow->AppendColumnL(text); |
|
1241 CleanupStack::PopAndDestroy(tempBuf); |
|
1242 } |
|
1243 |
|
1244 // --------------------------------------------------------------------------- |
|
1245 // CCCAppDetailsViewListBoxModel::AddIconsToEndL |
|
1246 // --------------------------------------------------------------------------- |
|
1247 // |
|
1248 void CCCAppDetailsViewListBoxModel::AddIconsToEndL( |
|
1249 TInt aIndex, |
|
1250 CCCAppDetailsViewListBoxRow* aRow) |
|
1251 { |
|
1252 TBuf<KBufferSize> buffer; |
|
1253 TInt iconIndex = 0; |
|
1254 TInt storeIndex = iPresentationContact->PresentationFields(). |
|
1255 StoreIndexOfField(aIndex); |
|
1256 |
|
1257 if (HasDefaultsL(storeIndex)) |
|
1258 { |
|
1259 buffer.Zero(); |
|
1260 TPbk2IconId iconId( |
|
1261 TUid::Uid(KCCADetailsViewPluginImplmentationUid), |
|
1262 ECCAppDetailsViewQgn_indi_default_conn_add ); |
|
1263 iconIndex = iIconArray.FindIcon(iconId); |
|
1264 buffer.AppendNum(iconIndex); |
|
1265 aRow->AppendColumnL(buffer); |
|
1266 } |
|
1267 |
|
1268 // Check and add speed dial icon |
|
1269 MVPbkStoreContactField* storefield = |
|
1270 iStoreContact->Fields().FieldAtLC(storeIndex); |
|
1271 |
|
1272 if (storefield) |
|
1273 { |
|
1274 MVPbkStoreContactField2* fieldext = |
|
1275 reinterpret_cast<MVPbkStoreContactField2*> |
|
1276 (storefield->StoreContactFieldExtension |
|
1277 (KMVPbkStoreContactFieldExtension2Uid)); |
|
1278 |
|
1279 if (fieldext) |
|
1280 { |
|
1281 CArrayFix<TInt>* array = fieldext->SpeedDialIndexesL(); |
|
1282 |
|
1283 if (array) |
|
1284 { |
|
1285 CleanupStack::PushL(array); |
|
1286 |
|
1287 buffer.Zero(); |
|
1288 |
|
1289 // find speed dial key (1 to 9) and set correct icon |
|
1290 TInt key = 0; |
|
1291 TInt count = array->Count(); |
|
1292 if ( count >0 ) |
|
1293 { |
|
1294 key = (*array)[0]; |
|
1295 // Loop from end of array to find smallest key |
|
1296 // if more than one has been set to same field. |
|
1297 for ( TInt i = 1; i < count; i++ ) |
|
1298 { |
|
1299 if ( (*array)[i] < key ) |
|
1300 { |
|
1301 key = (*array)[i]; |
|
1302 } |
|
1303 } |
|
1304 } |
|
1305 |
|
1306 if (key > 0 && key <= 9) |
|
1307 { |
|
1308 // icon id ECCAppDetailsViewQgn_indi_qdial_one_add = 1 |
|
1309 // so icons from one to nine maps to key value. |
|
1310 TPbk2IconId iconId( |
|
1311 TUid::Uid(KCCADetailsViewPluginImplmentationUid), key); |
|
1312 iconIndex = iIconArray.FindIcon(iconId); |
|
1313 |
|
1314 buffer.AppendNum(iconIndex); |
|
1315 aRow->AppendColumnL(buffer); |
|
1316 } |
|
1317 |
|
1318 CleanupStack::PopAndDestroy(array); |
|
1319 } |
|
1320 } |
|
1321 |
|
1322 CleanupStack::PopAndDestroy(storefield); |
|
1323 } |
|
1324 } |
|
1325 |
|
1326 // -------------------------------------------------------------------------- |
|
1327 // CCCAppDetailsViewListBoxModel::ClipFromBeginning |
|
1328 // -------------------------------------------------------------------------- |
|
1329 // |
|
1330 TBool CCCAppDetailsViewListBoxModel::ClipFromBeginning( |
|
1331 TDes& aBuffer, |
|
1332 TInt aItemIndex, |
|
1333 TInt aSubCellNumber) const |
|
1334 { |
|
1335 CAknFormDoubleGraphicStyleListBox* listbox = |
|
1336 static_cast<CAknFormDoubleGraphicStyleListBox*>(&iListBox); |
|
1337 |
|
1338 return AknTextUtils::ClipToFit( |
|
1339 aBuffer, |
|
1340 AknTextUtils::EClipFromBeginning, |
|
1341 listbox, |
|
1342 aItemIndex, |
|
1343 aSubCellNumber); |
|
1344 } |
|
1345 |
|
1346 // -------------------------------------------------------------------------- |
|
1347 // CCCAppDetailsViewListBoxModel::ExpandBuffersL |
|
1348 // -------------------------------------------------------------------------- |
|
1349 // |
|
1350 void CCCAppDetailsViewListBoxModel::ExpandBuffersL( |
|
1351 CCCAppDetailsViewListBoxRow* aRow) |
|
1352 { |
|
1353 // Row formatting buffer |
|
1354 const TInt rowLength = aRow->TotalLength() + aRow->ColumnCount(); // for separator characters |
|
1355 |
|
1356 if (rowLength > iLineBuf->Des().MaxLength()) |
|
1357 { |
|
1358 iLineBuf = iLineBuf->ReAllocL(rowLength); |
|
1359 } |
|
1360 |
|
1361 ExpandColumnBufferL(aRow->MaxColumnLength()); |
|
1362 } |
|
1363 |
|
1364 // -------------------------------------------------------------------------- |
|
1365 // CCCAppDetailsViewListBoxModel::ExpandColumnBufferL |
|
1366 // -------------------------------------------------------------------------- |
|
1367 // |
|
1368 TPtr CCCAppDetailsViewListBoxModel::ExpandColumnBufferL(TInt aRequiredLength) |
|
1369 { |
|
1370 if (aRequiredLength > iColumnBuf->Des().MaxLength()) |
|
1371 { |
|
1372 iColumnBuf = iColumnBuf->ReAllocL(aRequiredLength); |
|
1373 } |
|
1374 |
|
1375 return (iColumnBuf->Des()); |
|
1376 } |
|
1377 |
|
1378 // -------------------------------------------------------------------------- |
|
1379 // CCCAppDetailsViewListBoxModel::ExecuteEditorL |
|
1380 // -------------------------------------------------------------------------- |
|
1381 // |
|
1382 void CCCAppDetailsViewListBoxModel::ExecuteEditorL() |
|
1383 { |
|
1384 // verify syncronization field existance and content |
|
1385 /* |
|
1386 VPbkUtils::VerifySyncronizationFieldL( |
|
1387 CCoeEnv::Static()->FsSession(), |
|
1388 iStoreContact->ParentStore().StoreProperties().SupportedFields(), |
|
1389 *iStoreContact); |
|
1390 */ |
|
1391 |
|
1392 // adjust focus |
|
1393 TPbk2ContactEditorParams params; |
|
1394 |
|
1395 params.iFocusedContactField = FocusedFieldLC(); |
|
1396 |
|
1397 // create and execute editing dialog |
|
1398 CPbk2ContactEditorDlg* dlg = |
|
1399 CPbk2ContactEditorDlg::NewL(params, iStoreContact, *this); |
|
1400 |
|
1401 iStoreContact = NULL; // ownership went to editor |
|
1402 dlg->ExecuteLD(); |
|
1403 |
|
1404 // clean after dialog execution |
|
1405 if (params.iFocusedContactField) |
|
1406 { |
|
1407 CleanupStack::PopAndDestroy(params.iFocusedContactField); |
|
1408 } |
|
1409 |
|
1410 // If editing has been aborted we don't set focused contact. |
|
1411 if (iStoreContact && !iIsEditingAborted) |
|
1412 { |
|
1413 // It is possible that the contact got changed while in edit |
|
1414 //iUiControl->SetFocusedFieldIndex(params.iFocusedIndex); |
|
1415 //iUiControl->SetFocusedContactL(*iStoreContact); |
|
1416 } |
|
1417 |
|
1418 // If contact got deleted in the editor, this call ensures |
|
1419 // that the contact info view is switched to the names list |
|
1420 //iUiControl->UpdateAfterCommandExecution(); |
|
1421 } |
|
1422 |
|
1423 // -------------------------------------------------------------------------- |
|
1424 // CCCAppDetailsViewListBoxModel::GetLabelLC |
|
1425 // -------------------------------------------------------------------------- |
|
1426 // |
|
1427 HBufC* CCCAppDetailsViewListBoxModel::GetLabelLC( |
|
1428 const CPbk2PresentationContactField& aField) |
|
1429 { |
|
1430 TPtr columnBuf(iColumnBuf->Des()); |
|
1431 columnBuf.Set(ExpandColumnBufferL(aField.FieldLabel().Length())); |
|
1432 columnBuf.Zero(); |
|
1433 |
|
1434 // replace listbox separator characters. |
|
1435 Pbk2PresentationUtils::AppendAndReplaceChars( |
|
1436 columnBuf, aField.FieldLabel(), KCharsToReplace, KReplacementChars); |
|
1437 |
|
1438 // Replace characters that can not be displayed correctly |
|
1439 Pbk2PresentationUtils::ReplaceNonGraphicCharacters(columnBuf, ' '); |
|
1440 |
|
1441 HBufC* data = HBufC::NewLC(columnBuf.Length()); |
|
1442 data->Des().Append(columnBuf); |
|
1443 |
|
1444 return data; |
|
1445 } |
|
1446 |
|
1447 // -------------------------------------------------------------------------- |
|
1448 // CCCAppDetailsViewListBoxModel::SetEmptyTextL |
|
1449 // Sets empty text for list box from given resource id. |
|
1450 // -------------------------------------------------------------------------- |
|
1451 // |
|
1452 void CCCAppDetailsViewListBoxModel::SetEmptyTextL(TInt aResourceId) |
|
1453 { |
|
1454 HBufC* text = iCoeEnv.AllocReadResourceLC(aResourceId); |
|
1455 iListBox.View()->SetListEmptyTextL(*text); |
|
1456 CleanupStack::PopAndDestroy(text); |
|
1457 } |
|
1458 |
|
1459 // -------------------------------------------------------------------------- |
|
1460 // CCCAppDetailsViewListBoxModel::SetTitleL |
|
1461 // Sets empty text for list box from given resource id. |
|
1462 // -------------------------------------------------------------------------- |
|
1463 // |
|
1464 void CCCAppDetailsViewListBoxModel::SetTitleL() |
|
1465 { |
|
1466 HBufC* title = GetContactTitleL(); |
|
1467 CleanupStack::PushL(title); |
|
1468 iPlugin.SetTitleL(*title); |
|
1469 CleanupStack::PopAndDestroy(); |
|
1470 } |
|
1471 |
|
1472 // -------------------------------------------------------------------------- |
|
1473 // CCCAppDetailsViewListBoxModel::IsContactEditable |
|
1474 // -------------------------------------------------------------------------- |
|
1475 // |
|
1476 TBool CCCAppDetailsViewListBoxModel::IsContactEditable() |
|
1477 { |
|
1478 return !(IsSdnContact() || IsReadOnlyContact()); |
|
1479 } |
|
1480 |
|
1481 // -------------------------------------------------------------------------- |
|
1482 // CCCAppDetailsViewListBoxModel::UpdateMSKinCbaL |
|
1483 // Sets empty MSK or MSK with text "Edit" when contact is editable. |
|
1484 // -------------------------------------------------------------------------- |
|
1485 // |
|
1486 void CCCAppDetailsViewListBoxModel::UpdateMSKinCbaL() |
|
1487 { |
|
1488 iPlugin.UpdateMSKinCbaL(IsContactEditable()); |
|
1489 } |
|
1490 |
|
1491 // -------------------------------------------------------------------------- |
|
1492 // CCCAppDetailsViewListBoxModel::HandleEditRequestL |
|
1493 // -------------------------------------------------------------------------- |
|
1494 // |
|
1495 void CCCAppDetailsViewListBoxModel::HandleEditRequestL() |
|
1496 { |
|
1497 if (iStoreContact != NULL && IsContactEditable()) |
|
1498 { |
|
1499 iPlugin.HandleEditRequestL(); |
|
1500 } |
|
1501 } |
|
1502 |
|
1503 // -------------------------------------------------------------------------- |
|
1504 // CCCAppDetailsViewListBoxModel::HandleDeleteRequestL |
|
1505 // -------------------------------------------------------------------------- |
|
1506 // |
|
1507 void CCCAppDetailsViewListBoxModel::HandleDeleteRequestL() |
|
1508 { |
|
1509 if ( iStoreContact != NULL && IsContactEditable() ) |
|
1510 { |
|
1511 iPlugin.HandleDeleteRequestL(); |
|
1512 } |
|
1513 } |
|
1514 |
|
1515 // -------------------------------------------------------------------------- |
|
1516 // CCCAppDetailsViewListBoxModel::IsFieldMapped |
|
1517 // -------------------------------------------------------------------------- |
|
1518 // |
|
1519 TBool CCCAppDetailsViewListBoxModel::IsFieldMapped() const |
|
1520 { |
|
1521 const TInt *index = iInxToPresentationIdx.Find(iListBox.CurrentItemIndex()); |
|
1522 if ( index && (*index >= KErrNone) && ( *index != iListBox.CurrentItemIndex())) |
|
1523 { |
|
1524 return ETrue; |
|
1525 } |
|
1526 else |
|
1527 { |
|
1528 return EFalse; |
|
1529 } |
|
1530 } |
|
1531 |
|
1532 // End of File |