|
1 /* |
|
2 * Copyright (c) 2002 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: A utility that provides services to both the Speeddial and |
|
15 * PhoneBook applications for getting and setting speeddial |
|
16 * number configuration. |
|
17 * |
|
18 */ |
|
19 |
|
20 |
|
21 |
|
22 |
|
23 |
|
24 |
|
25 |
|
26 // INCLUDE FILES |
|
27 #include <bldvariant.hrh> |
|
28 #include <gulicon.h> |
|
29 #include <akncontext.h> |
|
30 #include <akntitle.h> |
|
31 #include <aknQueryDialog.h> |
|
32 #include <Aknlists.h> |
|
33 #include <bautils.h> |
|
34 #include <aknnotedialog.h> |
|
35 #include <aknnotecontrol.h> |
|
36 #include <aknnotewrappers.h> |
|
37 #include <SysUtil.h> |
|
38 #include <ErrorUI.h> |
|
39 #include <VmNumber.h> |
|
40 #include <SharedDataClient.h> |
|
41 //#include <PhCltTypes.h> |
|
42 #include <CPbkContactEngine.h> // Phonebook Engine |
|
43 #include <CPbkContactItem.h> // Phonebook Contact |
|
44 #include <CPbkFieldInfo.h> // Phonebook Field |
|
45 #include <PAlbImageFactory.h> // Photoalbum |
|
46 #include <CPbkSingleItemFetchDlg.h> // Phonebook Single Entry Fetch API |
|
47 #include <CPbkContactChangeNotifier.h> |
|
48 #include <RPbkViewResourceFile.h> // Phonebook view dll resource file loader |
|
49 #include <StringLoader.h> |
|
50 |
|
51 #include <SpdCtrl.rsg> |
|
52 #include <SpdCtrl.mbg> |
|
53 #include <Avkon.mbg> |
|
54 #include <gdi.h> |
|
55 #include <akniconarray.h> |
|
56 #include <CPbkThumbnailManager.h> |
|
57 #include <PAlbSettings.h> |
|
58 |
|
59 #include "SpdiaGrid.h" |
|
60 #include "SpdiaGridDlg.h" |
|
61 |
|
62 #include "SpdiaIndexData.h" |
|
63 #include "SpdiaControl.h" |
|
64 #include "SpdiaControl.hrh" |
|
65 #include "Speeddial.laf" |
|
66 #include "SpdiaPanic.h" |
|
67 |
|
68 #include <AknsBasicBackgroundControlContext.h> |
|
69 #include <AknsDrawUtils.h> |
|
70 #include <Aknsutils.h> |
|
71 #include <AknIconUtils.h> |
|
72 #include <AppLayout.cdl.h> |
|
73 #include <data_caging_path_literals.hrh> |
|
74 #include <f32file.h> |
|
75 #include <FeatMgr.h> |
|
76 |
|
77 #include "Speeddial.hrh" |
|
78 |
|
79 // LOCAL CONSTANTS AND MACROS |
|
80 //This order is based on 'Standard field ids' (PbkFields.hrh) |
|
81 #ifdef __VOIP |
|
82 const TUint KIcons[10] = |
|
83 { |
|
84 EMbmAvkonQgn_prop_nrtyp_phone, |
|
85 EMbmAvkonQgn_prop_nrtyp_home, |
|
86 EMbmAvkonQgn_prop_nrtyp_work, |
|
87 EMbmAvkonQgn_prop_nrtyp_mobile, |
|
88 EMbmAvkonQgn_prop_nrtyp_video, |
|
89 EMbmAvkonQgn_prop_nrtyp_fax, |
|
90 EMbmAvkonQgn_prop_nrtyp_pager, |
|
91 EMbmAvkonQgn_prop_nrtyp_voip, |
|
92 EMbmAvkonQgn_prop_nrtyp_email, |
|
93 EMbmAvkonQgn_prop_nrtyp_address |
|
94 }; |
|
95 |
|
96 const TInt KIconsCount(8); |
|
97 |
|
98 const TUint KIconsId[8] = |
|
99 { |
|
100 EPbkqgn_prop_nrtyp_phone, |
|
101 EPbkqgn_prop_nrtyp_home, |
|
102 EPbkqgn_prop_nrtyp_work, |
|
103 EPbkqgn_prop_nrtyp_mobile, |
|
104 EPbkqgn_prop_nrtyp_video, |
|
105 EPbkqgn_prop_nrtyp_fax, |
|
106 EPbkqgn_prop_nrtyp_pager, |
|
107 EPbkqgn_prop_nrtyp_voip |
|
108 }; |
|
109 |
|
110 const TUint KIconsMask[8] = |
|
111 { |
|
112 EMbmAvkonQgn_prop_nrtyp_phone_mask, |
|
113 EMbmAvkonQgn_prop_nrtyp_home_mask, |
|
114 EMbmAvkonQgn_prop_nrtyp_work_mask, |
|
115 EMbmAvkonQgn_prop_nrtyp_mobile_mask, |
|
116 EMbmAvkonQgn_prop_nrtyp_video_mask, |
|
117 EMbmAvkonQgn_prop_nrtyp_fax_mask, |
|
118 EMbmAvkonQgn_prop_nrtyp_pager_mask, |
|
119 EMbmAvkonQgn_prop_nrtyp_voip_mask |
|
120 }; |
|
121 #else |
|
122 const TUint KIcons[9] = |
|
123 { |
|
124 EMbmAvkonQgn_prop_nrtyp_phone, |
|
125 EMbmAvkonQgn_prop_nrtyp_home, |
|
126 EMbmAvkonQgn_prop_nrtyp_work, |
|
127 EMbmAvkonQgn_prop_nrtyp_mobile, |
|
128 EMbmAvkonQgn_prop_nrtyp_video, |
|
129 EMbmAvkonQgn_prop_nrtyp_fax, |
|
130 EMbmAvkonQgn_prop_nrtyp_pager, |
|
131 EMbmAvkonQgn_prop_nrtyp_email, |
|
132 EMbmAvkonQgn_prop_nrtyp_address |
|
133 }; |
|
134 |
|
135 const TInt KIconsCount(7); |
|
136 |
|
137 const TUint KIconsId[7] = |
|
138 { |
|
139 EPbkqgn_prop_nrtyp_phone, |
|
140 EPbkqgn_prop_nrtyp_home, |
|
141 EPbkqgn_prop_nrtyp_work, |
|
142 EPbkqgn_prop_nrtyp_mobile, |
|
143 EPbkqgn_prop_nrtyp_video, |
|
144 EPbkqgn_prop_nrtyp_fax, |
|
145 EPbkqgn_prop_nrtyp_pager |
|
146 }; |
|
147 |
|
148 const TUint KIconsMask[7] = |
|
149 { |
|
150 EMbmAvkonQgn_prop_nrtyp_phone_mask, |
|
151 EMbmAvkonQgn_prop_nrtyp_home_mask, |
|
152 EMbmAvkonQgn_prop_nrtyp_work_mask, |
|
153 EMbmAvkonQgn_prop_nrtyp_mobile_mask, |
|
154 EMbmAvkonQgn_prop_nrtyp_video_mask, |
|
155 EMbmAvkonQgn_prop_nrtyp_fax_mask, |
|
156 EMbmAvkonQgn_prop_nrtyp_pager_mask |
|
157 }; |
|
158 #endif |
|
159 |
|
160 // const TUint KShortcutKey0('0'); // not referenced |
|
161 const TUint KDialBmp[9] = |
|
162 { |
|
163 //EMbmSpdctrlQgn_graf_quick_one, |
|
164 #ifdef __SCALABLE_ICONS |
|
165 EMbmSpdctrlQgn_menu_smsvo, |
|
166 #else |
|
167 EMbmSpdctrlQgn_menu_smsvo_lst, |
|
168 #endif |
|
169 EMbmSpdctrlQgn_graf_quick_two, |
|
170 EMbmSpdctrlQgn_graf_quick_three, |
|
171 EMbmSpdctrlQgn_graf_quick_four, |
|
172 EMbmSpdctrlQgn_graf_quick_five, |
|
173 EMbmSpdctrlQgn_graf_quick_six, |
|
174 EMbmSpdctrlQgn_graf_quick_seven, |
|
175 EMbmSpdctrlQgn_graf_quick_eight, |
|
176 EMbmSpdctrlQgn_graf_quick_nine |
|
177 }; |
|
178 |
|
179 const TUint KDialBmpMask[9] = |
|
180 { |
|
181 //EMbmSpdctrlQgn_graf_quick_one_mask_soft, |
|
182 #ifdef __SCALABLE_ICONS |
|
183 EMbmSpdctrlQgn_menu_smsvo_mask, |
|
184 #else |
|
185 EMbmSpdctrlQgn_menu_smsvo_lst_mask, |
|
186 #endif |
|
187 EMbmSpdctrlQgn_graf_quick_two_mask, |
|
188 EMbmSpdctrlQgn_graf_quick_three_mask, |
|
189 EMbmSpdctrlQgn_graf_quick_four_mask, |
|
190 EMbmSpdctrlQgn_graf_quick_five_mask, |
|
191 EMbmSpdctrlQgn_graf_quick_six_mask, |
|
192 EMbmSpdctrlQgn_graf_quick_seven_mask, |
|
193 EMbmSpdctrlQgn_graf_quick_eight_mask, |
|
194 EMbmSpdctrlQgn_graf_quick_nine_mask |
|
195 }; |
|
196 |
|
197 const TInt KCellRowCount(3); |
|
198 const TInt KCellColCount(3); |
|
199 const TInt KVoiceMail(0); |
|
200 const TInt KLayoutCount(5); |
|
201 const TInt KNullIndexData(-1); |
|
202 |
|
203 _LIT(KNullCell, "\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t%d\t"); |
|
204 _LIT(KDesTab, "\t"); |
|
205 _LIT(KDesTab2, "\t\t"); |
|
206 |
|
207 |
|
208 // --------------------------------------------------------- |
|
209 // E32Dll(TDllReason) |
|
210 // Entry point function for Symbian dll |
|
211 // Returns: KErrNone: No error |
|
212 // --------------------------------------------------------- |
|
213 // |
|
214 |
|
215 |
|
216 // ================= MEMBER FUNCTIONS ======================= |
|
217 |
|
218 // --------------------------------------------------------- |
|
219 // CSpdiaControl::NewL |
|
220 // |
|
221 // --------------------------------------------------------- |
|
222 // |
|
223 EXPORT_C CSpdiaControl* CSpdiaControl::NewL() |
|
224 { |
|
225 CSpdiaControl* self = new(ELeave) CSpdiaControl(); |
|
226 CleanupStack::PushL(self); |
|
227 self->ConstructL(); |
|
228 CleanupStack::Pop(); // self |
|
229 return self; |
|
230 } |
|
231 |
|
232 // --------------------------------------------------------- |
|
233 // CSpdiaControl::NewL |
|
234 // |
|
235 // --------------------------------------------------------- |
|
236 // |
|
237 EXPORT_C CSpdiaControl* CSpdiaControl::NewL(CPbkContactEngine& aPbkEngine) |
|
238 { |
|
239 CSpdiaControl* self = new(ELeave) CSpdiaControl(&aPbkEngine); |
|
240 CleanupStack::PushL(self); |
|
241 self->ConstructL(); |
|
242 CleanupStack::Pop(); // self |
|
243 return self; |
|
244 } |
|
245 |
|
246 // --------------------------------------------------------- |
|
247 // CSpdiaControl::AssignDialNumberL |
|
248 // Function called when assigning a speed dial |
|
249 // from the Idle state. |
|
250 // --------------------------------------------------------- |
|
251 // |
|
252 EXPORT_C TBool CSpdiaControl::AssignDialNumberL( |
|
253 TInt aLocation, CEikStatusPane* /*aStatusPane*/) |
|
254 { |
|
255 TBool result(EFalse); |
|
256 TInt index(Index(aLocation)); |
|
257 if (index != VMBoxPosition() && |
|
258 (aLocation > 0 && aLocation <= iSdmCount)) |
|
259 { |
|
260 result = ETrue; |
|
261 if (ContactId(index) == KNullContactId) |
|
262 { |
|
263 // Assign it now? |
|
264 iQueryDialog = CAknQueryDialog::NewL(CAknQueryDialog::ENoTone); |
|
265 TBool resDialog(EFalse); |
|
266 TRAPD(error, |
|
267 resDialog = iQueryDialog->ExecuteLD(R_SPDIA_QUERY_ASSIGN) ); |
|
268 iQueryDialog = NULL; |
|
269 User::LeaveIfError(error); |
|
270 if (!resDialog) |
|
271 { |
|
272 result = EFalse; |
|
273 } |
|
274 } |
|
275 |
|
276 if (result) |
|
277 { |
|
278 result = AssignDialIndexL(index); |
|
279 } |
|
280 } |
|
281 return result; |
|
282 } |
|
283 |
|
284 // --------------------------------------------------------- |
|
285 // CSpdiaControl::ExecuteLD |
|
286 // |
|
287 // --------------------------------------------------------- |
|
288 // |
|
289 EXPORT_C TInt CSpdiaControl::ExecuteLD( |
|
290 TContactItemId aId, TInt aFieldIdx) |
|
291 { |
|
292 // Live up to the "D" |
|
293 CleanupStack::PushL(this); |
|
294 |
|
295 // Create a CPbkFetchEntryDlg dialog |
|
296 TInt dial; |
|
297 iGridDlg = CSpdiaGridDlg::NewL(dial, *this); |
|
298 |
|
299 // Execute the CPbkFetchEntryDlg dialog |
|
300 TInt result(ETrue); |
|
301 TRAPD(error, result = iGridDlg->ExecuteLD(R_SPDIA_GRID_DIALOG)); |
|
302 iGridDlg = NULL; |
|
303 iIconArray = NULL; |
|
304 |
|
305 // Check errors |
|
306 User::LeaveIfError(error); |
|
307 |
|
308 if (result && !CheckSpaceBelowCriticalLevelL()) |
|
309 { |
|
310 AssignDialL(aId, aFieldIdx, dial); |
|
311 } |
|
312 |
|
313 // Cleanup and return |
|
314 CleanupStack::PopAndDestroy(); // this |
|
315 return (result); |
|
316 } |
|
317 |
|
318 // --------------------------------------------------------- |
|
319 // CSpdiaControl::Cancel |
|
320 // |
|
321 // --------------------------------------------------------- |
|
322 // |
|
323 EXPORT_C void CSpdiaControl::Cancel() |
|
324 { |
|
325 delete iPbkSingleItem; |
|
326 iPbkSingleItem = NULL; |
|
327 |
|
328 delete iQueryDialog; |
|
329 iQueryDialog = NULL; |
|
330 } |
|
331 |
|
332 // --------------------------------------------------------- |
|
333 // CSpdiaControl::DialNumberL |
|
334 // |
|
335 // --------------------------------------------------------- |
|
336 // |
|
337 EXPORT_C TBool CSpdiaControl::DialNumberL(TInt aLocation, |
|
338 TDes& aPhoneNumber, CEikStatusPane* /*aStatusPane*/) |
|
339 { |
|
340 TBool result(ETrue); |
|
341 TInt index(Index(aLocation)); |
|
342 if (index == VMBoxPosition()) |
|
343 { |
|
344 result = VoiceMailL(aPhoneNumber); |
|
345 } |
|
346 else |
|
347 { |
|
348 if (ContactId(index) == KNullContactId) |
|
349 { |
|
350 result = AssignDialNumberL(aLocation); |
|
351 } |
|
352 if (result) |
|
353 { |
|
354 aPhoneNumber = (*iSdmArray)[index].PhoneNumber(); |
|
355 } |
|
356 } |
|
357 return result; |
|
358 } |
|
359 |
|
360 // --------------------------------------------------------- |
|
361 // CSpdiaControl::CSpdiaControl |
|
362 // |
|
363 // --------------------------------------------------------- |
|
364 // |
|
365 CSpdiaControl::CSpdiaControl() |
|
366 { |
|
367 } |
|
368 // --------------------------------------------------------- |
|
369 // CSpdiaControl::InitializeArray |
|
370 // |
|
371 // --------------------------------------------------------- |
|
372 void CSpdiaControl::InitializeArray() |
|
373 { |
|
374 |
|
375 iDialSkinBmp->Append(KAknsIIDQgnMenuSmsvoLst); |
|
376 iDialSkinBmp->Append(KAknsIIDQgnGrafQuickTwo); |
|
377 iDialSkinBmp->Append(KAknsIIDQgnGrafQuickThree); |
|
378 iDialSkinBmp->Append(KAknsIIDQgnGrafQuickFour); |
|
379 iDialSkinBmp->Append(KAknsIIDQgnGrafQuickFive); |
|
380 iDialSkinBmp->Append(KAknsIIDQgnGrafQuickSix); |
|
381 iDialSkinBmp->Append(KAknsIIDQgnGrafQuickSeven); |
|
382 iDialSkinBmp->Append(KAknsIIDQgnGrafQuickEight); |
|
383 iDialSkinBmp->Append(KAknsIIDQgnGrafQuickNine); |
|
384 |
|
385 iSkinIcons->Append(KAknsIIDQgnPropNrtypPhone); |
|
386 iSkinIcons->Append(KAknsIIDQgnPropNrtypHome); |
|
387 iSkinIcons->Append(KAknsIIDQgnPropNrtypWork); |
|
388 iSkinIcons->Append(KAknsIIDQgnPropNrtypMobile); |
|
389 iSkinIcons->Append(KAknsIIDQgnPropNrtypVideo); |
|
390 iSkinIcons->Append(KAknsIIDQgnPropNrtypFax); |
|
391 iSkinIcons->Append(KAknsIIDQgnPropNrtypPager); |
|
392 if ( FeatureManager::FeatureSupported(KFeatureIdCommonVoip) ) |
|
393 { |
|
394 iSkinIcons->Append(KAknsIIDQgnPropNrtypVoip); |
|
395 } |
|
396 iSkinIcons->Append(KAknsIIDQgnPropNrtypEmail); |
|
397 iSkinIcons->Append(KAknsIIDQgnPropNrtypAddress); |
|
398 |
|
399 } |
|
400 // --------------------------------------------------------- |
|
401 // CSpdiaControl::CSpdiaControl |
|
402 // |
|
403 // --------------------------------------------------------- |
|
404 // |
|
405 CSpdiaControl::CSpdiaControl(CPbkContactEngine* aPbkEngine) |
|
406 : iEngine(aPbkEngine), iExEngine(ETrue) |
|
407 { |
|
408 } |
|
409 |
|
410 // --------------------------------------------------------- |
|
411 // CSpdiaControl::~CSpdiaControl |
|
412 // |
|
413 // --------------------------------------------------------- |
|
414 // |
|
415 EXPORT_C CSpdiaControl::~CSpdiaControl() |
|
416 { |
|
417 |
|
418 delete iThumbFactory; |
|
419 delete iManager; |
|
420 delete iShadowLayout; |
|
421 |
|
422 delete iPbkNotifier; |
|
423 if (iGridUsed == EGridNoUse) |
|
424 { |
|
425 if (iIconArray) |
|
426 { |
|
427 iIconArray->ResetAndDestroy(); |
|
428 delete iIconArray; |
|
429 } |
|
430 } |
|
431 if (!iExEngine) |
|
432 { |
|
433 delete iEngine; |
|
434 } |
|
435 |
|
436 ResetArray(); |
|
437 delete iSdmArray; |
|
438 |
|
439 delete iPbkSingleItem; |
|
440 delete iQueryDialog; |
|
441 |
|
442 if (iPbkResourceFile != NULL) |
|
443 { |
|
444 iPbkResourceFile->Close(); |
|
445 } |
|
446 delete iPbkResourceFile; |
|
447 |
|
448 if (iCoeEnv != NULL) |
|
449 { |
|
450 iCoeEnv->DeleteResourceFile(iFileOffset); |
|
451 } |
|
452 delete iBgContext; |
|
453 |
|
454 if(iDialSkinBmp != NULL) |
|
455 { |
|
456 iDialSkinBmp->Close(); |
|
457 } |
|
458 delete iDialSkinBmp; |
|
459 |
|
460 if(iSkinIcons != NULL) |
|
461 { |
|
462 iSkinIcons->Close(); |
|
463 } |
|
464 delete iSkinIcons; |
|
465 |
|
466 |
|
467 } |
|
468 |
|
469 // --------------------------------------------------------- |
|
470 // CSpdiaControl::VoiceMailL |
|
471 // |
|
472 // --------------------------------------------------------- |
|
473 // |
|
474 EXPORT_C TBool CSpdiaControl::VoiceMailL(TDes& aNumber) |
|
475 { |
|
476 TBool result(ETrue); |
|
477 |
|
478 RVmbxNumber vmbx; |
|
479 CleanupClosePushL(vmbx); // So that Close() is called if a leave happens. |
|
480 if (vmbx.Open() == KErrNone) |
|
481 { |
|
482 TInt err(vmbx.GetVmbxNumber(aNumber)); |
|
483 if (err != KErrNone) |
|
484 { |
|
485 if (err != KErrNotFound || |
|
486 !vmbx.QueryNumberL(EVmbxNotDefinedQuery, aNumber)) |
|
487 { |
|
488 result = EFalse; |
|
489 } |
|
490 } |
|
491 } |
|
492 CleanupStack::PopAndDestroy(); // It will call vmbx.Close() |
|
493 return result; |
|
494 } |
|
495 |
|
496 // --------------------------------------------------------- |
|
497 // CSpdiaControl::PbkEngine |
|
498 // phone book engine pointer |
|
499 // --------------------------------------------------------- |
|
500 // |
|
501 EXPORT_C CPbkContactEngine* CSpdiaControl::PbkEngine() const |
|
502 { |
|
503 return iEngine; |
|
504 } |
|
505 |
|
506 // --------------------------------------------------------- |
|
507 // CSpdiaControl::Index |
|
508 // |
|
509 // --------------------------------------------------------- |
|
510 // |
|
511 EXPORT_C TInt CSpdiaControl::Index(TInt aDial) const |
|
512 { |
|
513 return (aDial - 1); |
|
514 } |
|
515 |
|
516 // --------------------------------------------------------- |
|
517 // CSpdiaControl::Number |
|
518 // An interface for accessing index data array |
|
519 // --------------------------------------------------------- |
|
520 // |
|
521 EXPORT_C TInt CSpdiaControl::Number(TInt aIndex) const |
|
522 { |
|
523 return (*iSdmArray)[aIndex].Number(); |
|
524 } |
|
525 |
|
526 // --------------------------------------------------------- |
|
527 // CSpdiaControl::ContactId |
|
528 // An interface for accessing index data array |
|
529 // --------------------------------------------------------- |
|
530 // |
|
531 EXPORT_C TContactItemId CSpdiaControl::ContactId(TInt aIndex) const |
|
532 { |
|
533 return (*iSdmArray)[aIndex].ContactId(); |
|
534 } |
|
535 |
|
536 // --------------------------------------------------------- |
|
537 // CSpdiaControl::PhoneDialNumber |
|
538 // An interface for accessing index data array. |
|
539 // --------------------------------------------------------- |
|
540 // |
|
541 EXPORT_C const TDesC& CSpdiaControl::PhoneDialNumber(TInt aDial) const |
|
542 { |
|
543 return (*iSdmArray)[Index(aDial)].TelNumber(); |
|
544 } |
|
545 |
|
546 // --------------------------------------------------------- |
|
547 // CSpdiaControl::PhoneNumber |
|
548 // An interface for accessing index data array. |
|
549 // --------------------------------------------------------- |
|
550 // |
|
551 EXPORT_C const TDesC& CSpdiaControl::PhoneNumber(TInt aIndex) const |
|
552 { |
|
553 return (*iSdmArray)[aIndex].PhoneNumber(); |
|
554 } |
|
555 |
|
556 // --------------------------------------------------------- |
|
557 // CSpdiaControl::ContactTitleL |
|
558 // phone book access |
|
559 // --------------------------------------------------------- |
|
560 EXPORT_C HBufC* CSpdiaControl::ContactTitleL(TContactItemId aCid, TBool aUnnamed) |
|
561 { |
|
562 HBufC* title = NULL; |
|
563 if (aCid != KNullContactId) |
|
564 { |
|
565 CPbkContactItem* item = |
|
566 iEngine->ReadContactLC(aCid); |
|
567 if ((title = item->GetContactTitleOrNullL()) == NULL && aUnnamed) |
|
568 { |
|
569 title = iEngine->UnnamedTitle().AllocL(); |
|
570 } |
|
571 CleanupStack::PopAndDestroy(); // item |
|
572 } |
|
573 |
|
574 return title; |
|
575 } |
|
576 |
|
577 // --------------------------------------------------------- |
|
578 // CSpdiaControl::ThumbIndex |
|
579 // An interface for accessing index data array. |
|
580 // --------------------------------------------------------- |
|
581 // |
|
582 EXPORT_C TInt CSpdiaControl::ThumbIndex(TInt aIndex) const |
|
583 { |
|
584 return (*iSdmArray)[aIndex].ThumbIndex(); |
|
585 } |
|
586 |
|
587 // --------------------------------------------------------- |
|
588 // CSpdiaControl::IconIndex |
|
589 // An interface for accessing index data array. |
|
590 // --------------------------------------------------------- |
|
591 // |
|
592 EXPORT_C TInt CSpdiaControl::IconIndex(TInt aIndex) const |
|
593 { |
|
594 TInt index = (*iSdmArray)[aIndex].IconIndex(); |
|
595 if (index >= 0) |
|
596 { |
|
597 return KIconsMask[index - iSdmCount]; |
|
598 } |
|
599 return index; |
|
600 } |
|
601 |
|
602 // --------------------------------------------------------- |
|
603 // CSpdiaControl::NumberType |
|
604 // An interface for accessing phone number type. |
|
605 // Number types are defined in PbkFields.hrh. |
|
606 // --------------------------------------------------------- |
|
607 // |
|
608 EXPORT_C TInt CSpdiaControl::NumberType(TInt aIndex) const |
|
609 { |
|
610 return (*iSdmArray)[aIndex].FieldId(); |
|
611 } |
|
612 |
|
613 // --------------------------------------------------------- |
|
614 // CSpdiaControl::IconArray |
|
615 // An interface for accessing index data array. |
|
616 // --------------------------------------------------------- |
|
617 // |
|
618 EXPORT_C CArrayPtr<CGulIcon>* CSpdiaControl::IconArray() const |
|
619 { |
|
620 return iIconArray; |
|
621 } |
|
622 |
|
623 // --------------------------------------------------------- |
|
624 // CSpdiaControl::CreateGridDataL |
|
625 // |
|
626 // --------------------------------------------------------- |
|
627 // |
|
628 EXPORT_C TBool CSpdiaControl::CreateGridDataL( |
|
629 CAknGrid* aGrid, TBool aIndex) |
|
630 { |
|
631 iGrid = aGrid; |
|
632 if (iGridUsed == EGridNoUse) |
|
633 { |
|
634 iGridUsed = EGridUse; |
|
635 } |
|
636 |
|
637 // The specified index is updated. |
|
638 if (aIndex >= 0) |
|
639 { |
|
640 return UpdateIndexDataL(aIndex); |
|
641 } |
|
642 |
|
643 // All items are updated. |
|
644 CDesCArray* array = |
|
645 STATIC_CAST(CDesCArray*, aGrid->Model()->ItemTextArray()); |
|
646 array->Reset(); |
|
647 InitIndexDataL(); |
|
648 if (SetIconArrayL(iIconArray) > 0) |
|
649 { |
|
650 SetOperationsL(); |
|
651 } |
|
652 |
|
653 TKeyArrayFix key(TSpdiaIndexData::OffsetValue( |
|
654 TSpdiaIndexData::EIndex), ECmpTInt); |
|
655 iSdmArray->Sort(key); |
|
656 |
|
657 TRAPD(err, SetItemDataL(*array)); |
|
658 if (err) |
|
659 { |
|
660 array->Reset(); |
|
661 User::Leave(err); |
|
662 } |
|
663 |
|
664 CFormattedCellListBoxData* list = aGrid->ItemDrawer()->FormattedCellData(); |
|
665 if (list->IconArray() == NULL) |
|
666 { |
|
667 aGrid->ItemDrawer()->FormattedCellData()->SetIconArrayL(iIconArray); |
|
668 } |
|
669 |
|
670 return ETrue; |
|
671 } |
|
672 |
|
673 // --------------------------------------------------------- |
|
674 // CSpdiaControl::CheckingIfPopUpNeeded |
|
675 // Internal rutine to check if pop up has to be shown |
|
676 // to enable the One-Key-Dialling setting. |
|
677 // --------------------------------------------------------- |
|
678 // |
|
679 |
|
680 void CSpdiaControl::CheckingIfPopUpNeeded() |
|
681 { |
|
682 TRAP_IGNORE(CheckingIfPopUpNeededL()); |
|
683 } |
|
684 |
|
685 // --------------------------------------------------------- |
|
686 // CSpdiaControl::CheckingIfPopUpNeededL |
|
687 // Internal rutine to check if pop up has to be shown |
|
688 // to enable the One-Key-Dialling setting. |
|
689 // --------------------------------------------------------- |
|
690 // |
|
691 |
|
692 void CSpdiaControl::CheckingIfPopUpNeededL() |
|
693 { |
|
694 TBool gridEmpty( ETrue ); |
|
695 TInt gridIndex( 1 ); |
|
696 TInt value; |
|
697 |
|
698 RSharedDataClient SharedDataKey; |
|
699 User::LeaveIfError( SharedDataKey.Connect() ); |
|
700 User::LeaveIfError( SharedDataKey.Assign( KSDUidGeneralSettings ) ); |
|
701 SharedDataKey.GetInt( KGSOneKeyDialling, value ); |
|
702 |
|
703 if ( value == 0 ) |
|
704 { |
|
705 while ( ( gridIndex < 9 ) && gridEmpty ) |
|
706 { |
|
707 if ( CSpdiaControl::ContactId( gridIndex ) != KNullContactId ) |
|
708 { |
|
709 gridEmpty=EFalse; |
|
710 } |
|
711 ++gridIndex; |
|
712 } |
|
713 if ( gridEmpty ) |
|
714 { |
|
715 SharedDataKey.SetInt( KGSOneKeyDialling, 1 ); |
|
716 SharedDataKey.Flush(); |
|
717 } |
|
718 } |
|
719 SharedDataKey.Close(); |
|
720 } |
|
721 |
|
722 // --------------------------------------------------------- |
|
723 // CSpdiaControl::AssignDialIndexL |
|
724 // Function called when the access is done through |
|
725 // the speed dial application. |
|
726 // --------------------------------------------------------- |
|
727 // |
|
728 EXPORT_C TBool CSpdiaControl::AssignDialIndexL(TInt aIndex) |
|
729 { |
|
730 TBool result(EFalse); |
|
731 |
|
732 |
|
733 if (iBooleanVarForAddingDialogVariation) |
|
734 { |
|
735 CSpdiaControl::CheckingIfPopUpNeeded(); |
|
736 } |
|
737 else |
|
738 { // do nothing |
|
739 } |
|
740 |
|
741 // Contact id before selection is saved. |
|
742 TContactItemId id(ContactId(aIndex)); |
|
743 CContactViewBase& filteredView = |
|
744 iEngine->FilteredContactsViewL(CContactDatabase::EPhonable); |
|
745 |
|
746 CPbkSingleItemFetchDlg::TParams params; |
|
747 // The array of fieldId to display is made. |
|
748 CPbkFieldIdArray* fieldIds = new (ELeave) CPbkFieldIdArray(); |
|
749 CleanupStack::PushL(fieldIds); |
|
750 fieldIds->AppendL(EPbkFieldIdPhoneNumberStandard); |
|
751 fieldIds->AppendL(EPbkFieldIdPhoneNumberHome); |
|
752 fieldIds->AppendL(EPbkFieldIdPhoneNumberWork); |
|
753 fieldIds->AppendL(EPbkFieldIdPhoneNumberMobile); |
|
754 |
|
755 |
|
756 |
|
757 |
|
758 |
|
759 fieldIds->AppendL(EPbkFieldIdPhoneNumberVideo); |
|
760 |
|
761 |
|
762 |
|
763 |
|
764 |
|
765 fieldIds->AppendL(EPbkFieldIdFaxNumber); |
|
766 fieldIds->AppendL(EPbkFieldIdPagerNumber); |
|
767 if ( FeatureManager::FeatureSupported(KFeatureIdCommonVoip) ) |
|
768 { |
|
769 fieldIds->AppendL(EPbkFieldIdVOIP); |
|
770 } |
|
771 params.iFieldIdArray = fieldIds; |
|
772 params.iContactView = &filteredView; |
|
773 iPbkSingleItem = CPbkSingleItemFetchDlg::NewL(params, *iEngine); |
|
774 |
|
775 TRAPD(error, result = iPbkSingleItem->ExecuteLD()); |
|
776 iPbkSingleItem = NULL; |
|
777 User::LeaveIfError(error); |
|
778 |
|
779 CleanupStack::PushL(params.iContactItem); |
|
780 if (result && params.iContactItem != NULL) |
|
781 { |
|
782 result = ETrue; |
|
783 // It is already assigned from other applications. |
|
784 if (id == KNullContactId && ContactId(aIndex) != KNullContactId) |
|
785 { |
|
786 id = ContactId(aIndex); |
|
787 } |
|
788 |
|
789 if (result && !CheckSpaceBelowCriticalLevelL()) |
|
790 { |
|
791 if (id != KNullContactId) |
|
792 { |
|
793 RemoveDialIndexL(aIndex, EFalse); |
|
794 (*iSdmArray)[aIndex].SetContactId(KNullContactId); |
|
795 } |
|
796 |
|
797 CPbkContactItem* item = |
|
798 iEngine->OpenContactL(params.iContactItem->Id()); |
|
799 CleanupStack::PushL(item); |
|
800 |
|
801 TPhCltTelephoneNumber phonenumber; |
|
802 params.iContactItemField->GetTextL(phonenumber); |
|
803 CPbkFieldInfo& info = params.iContactItemField->FieldInfo(); |
|
804 |
|
805 CPbkFieldArray& array = item->CardFields(); |
|
806 for (TInt index(0); index < array.Count(); ++index) |
|
807 { |
|
808 if (array[index].ItemField().Id() == |
|
809 params.iContactItemField->ItemField().Id()) |
|
810 { |
|
811 iEngine->SetFieldAsSpeedDialL(*item, |
|
812 index, (*iSdmArray)[aIndex].Number()); |
|
813 (*iSdmArray)[aIndex].SetContactId(params.iContactItem->Id()); |
|
814 (*iSdmArray)[aIndex].SetPhoneNumber(phonenumber); |
|
815 (*iSdmArray)[aIndex].SetIconIndex(FindIconIndex(info.IconId())); |
|
816 (*iSdmArray)[aIndex].SetThumbIndex(aIndex, NULL); |
|
817 index = array.Count(); |
|
818 } |
|
819 } |
|
820 iEngine->CloseContactL(params.iContactItem->Id()); |
|
821 CleanupStack::PopAndDestroy(); // item |
|
822 } |
|
823 } |
|
824 CleanupStack::PopAndDestroy(2); // params.iContactItem, fieldIds |
|
825 |
|
826 return result; |
|
827 } |
|
828 |
|
829 // --------------------------------------------------------- |
|
830 // CSpdiaControl::RemoveDialIndexL |
|
831 // phone book access |
|
832 // --------------------------------------------------------- |
|
833 // |
|
834 EXPORT_C TBool CSpdiaControl::RemoveDialIndexL(TInt aIndex, TBool aConfirmation) |
|
835 { |
|
836 TBool release(ETrue); |
|
837 |
|
838 if (release) |
|
839 { |
|
840 TContactItemId cid((*iSdmArray)[aIndex].ContactId()); |
|
841 TInt pos((*iSdmArray)[aIndex].Number()); |
|
842 release = EFalse; |
|
843 if (cid != KNullContactId && (aIndex >= 0 && aIndex < iSdmCount)) |
|
844 { |
|
845 iEngine->RemoveSpeedDialFieldL(cid, pos); |
|
846 (*iSdmArray)[aIndex].SetContactId(KNullContactId); |
|
847 release = ETrue; |
|
848 } |
|
849 } |
|
850 return release; |
|
851 } |
|
852 |
|
853 // --------------------------------------------------------- |
|
854 // deprecated |
|
855 // |
|
856 // --------------------------------------------------------- |
|
857 // |
|
858 EXPORT_C TBool CSpdiaControl::AssignNumberL(TInt /*aIndex*/, |
|
859 CEikStatusPane* /*aStatusPane*/, |
|
860 CCoeControl* /*aContainer*/, |
|
861 TBool /*aConfirmation*/) |
|
862 { |
|
863 __ASSERT_DEBUG(0, Panic(ESdmPanicNotSupported)); |
|
864 return EFalse; |
|
865 } |
|
866 |
|
867 EXPORT_C void CSpdiaControl::ApplyCellSpdiaPaneStyleL( |
|
868 CAknGrid& /*aListBox*/, TSize& /*aSize*/) |
|
869 { |
|
870 __ASSERT_DEBUG(0, Panic(ESdmPanicNotSupported)); |
|
871 } |
|
872 |
|
873 EXPORT_C void CSpdiaControl::DrawShadow( |
|
874 CWindowGc& /*aGc*/, |
|
875 const TSize& /*aSize*/ ) |
|
876 { |
|
877 __ASSERT_DEBUG(0, Panic(ESdmPanicNotSupported)); |
|
878 } |
|
879 |
|
880 // --------------------------------------------------------- |
|
881 // CSpdiaContainer::SetLayout |
|
882 // |
|
883 // --------------------------------------------------------- |
|
884 // |
|
885 EXPORT_C void CSpdiaControl::SetLayout(const TRect& aRect) |
|
886 { |
|
887 |
|
888 TAknWindowLineLayout lScr = AknLayout::screen(); |
|
889 |
|
890 TAknLayoutRect lScrLayout; |
|
891 lScrLayout.LayoutRect(aRect,lScr); |
|
892 TRect lScrRect = lScrLayout.Rect(); |
|
893 |
|
894 TAknWindowLineLayout lCtrlPane = AknLayout::control_pane(lScrRect); |
|
895 |
|
896 TAknLayoutRect lCtrlLayout; |
|
897 lCtrlLayout.LayoutRect(aRect,lCtrlPane); |
|
898 |
|
899 SetRect(TRect( TPoint( lScrRect.iTl.iX,lScrRect.iTl.iY ), |
|
900 TSize( lScrRect.Width(, |
|
901 lScrRect.Height() - lCtrlLayout.Rect().Height() ) ) ); |
|
902 |
|
903 (*iShadowLayout)[CSpdiaGrid::EtnCIF90].LayoutRect( |
|
904 aRect,AppLayout::Cell_pane_elements__qdial__Line_1() |
|
905 ); |
|
906 (*iShadowLayout)[CSpdiaGrid::EtnCIF].LayoutRect( |
|
907 aRect,AppLayout::Cell_pane_elements__qdial__Line_4() |
|
908 ); |
|
909 (*iShadowLayout)[CSpdiaGrid::EtnVGA90].LayoutRect( |
|
910 aRect,AppLayout::Cell_pane_elements__qdial__Line_7() |
|
911 ); |
|
912 (*iShadowLayout)[CSpdiaGrid::EtnVGA].LayoutRect( |
|
913 aRect,AppLayout::Cell_pane_elements__qdial__Line_10() |
|
914 ); |
|
915 (*iShadowLayout)[CSpdiaGrid::EtnCOM].LayoutRect( |
|
916 aRect,AppLayout::Cell_pane_elements__qdial__Line_13() |
|
917 ); |
|
918 } |
|
919 |
|
920 // --------------------------------------------------------- |
|
921 // deprecated |
|
922 // |
|
923 // --------------------------------------------------------- |
|
924 // |
|
925 EXPORT_C TInt CSpdiaControl::Size() const |
|
926 { |
|
927 __ASSERT_DEBUG(0, Panic(ESdmPanicNotSupported)); |
|
928 return KCellRowCount; |
|
929 } |
|
930 |
|
931 // --------------------------------------------------------- |
|
932 // CSpdiaControl::VMBoxPosition |
|
933 // |
|
934 // --------------------------------------------------------- |
|
935 // |
|
936 EXPORT_C TInt CSpdiaControl::VMBoxPosition() const |
|
937 { |
|
938 return KVoiceMail; |
|
939 } |
|
940 |
|
941 // --------------------------------------------------------- |
|
942 // CSpdiaControl::SpdIconIndex |
|
943 // An interface for accessing index data array. |
|
944 // --------------------------------------------------------- |
|
945 // |
|
946 EXPORT_C TInt CSpdiaControl::SpdIconIndex(TInt aIndex) const |
|
947 { |
|
948 return (*iSdmArray)[aIndex].IconIndex(); |
|
949 } |
|
950 |
|
951 // --------------------------------------------------------- |
|
952 // CSpdiaControl::CreateDataL |
|
953 // Set grid used flag and calls CreateDataL. |
|
954 // --------------------------------------------------------- |
|
955 // |
|
956 TBool CSpdiaControl::CreateDataL(const CAknGrid& aGrid) |
|
957 { |
|
958 iGridUsed = EGridUseAndUpdate; |
|
959 |
|
960 return CreateGridDataL(CONST_CAST(CAknGrid*, &aGrid), KNullIndexData); |
|
961 } |
|
962 |
|
963 // -- private ---- |
|
964 |
|
965 // --------------------------------------------------------- |
|
966 // CSpdiaControl::PbkThumbnailGetComplete |
|
967 // |
|
968 // --------------------------------------------------------- |
|
969 // |
|
970 void CSpdiaControl::PbkThumbnailGetComplete |
|
971 (MPbkThumbnailOperation& aOperation, CFbsBitmap* aBitmap) |
|
972 { |
|
973 TRAP_IGNORE(PbkThumbnailGetCompleteL(aOperation, aBitmap)); |
|
974 } |
|
975 // --------------------------------------------------------- |
|
976 // CSpdiaControl::PbkThumbnailGetCompleteL |
|
977 // |
|
978 // --------------------------------------------------------- |
|
979 // |
|
980 void CSpdiaControl::PbkThumbnailGetCompleteL |
|
981 (MPbkThumbnailOperation& aOperation, CFbsBitmap* aBitmap) |
|
982 { |
|
983 |
|
984 TInt index(HasOperation(aOperation)); |
|
985 if (index != KNullIndexData) |
|
986 { |
|
987 TRAPD(err, iThumbFactory->CreateThumbnailFromBitmapL(*aBitmap)); |
|
988 if (err == KErrNone) |
|
989 { |
|
990 // set the scaled bitmap to the array of icons |
|
991 delete (*iIconArray)[index]; |
|
992 (*iIconArray)[index] = NULL; |
|
993 (*iIconArray)[index] = CGulIcon::NewL(aBitmap); |
|
994 // set the text array of grid |
|
995 (*iSdmArray)[index].SetThumbIndex(index, aBitmap); |
|
996 ChangeIndexDataL(index, (*iSdmArray)[index]); |
|
997 if ((*iSdmArray)[index].LastThumb()) |
|
998 { |
|
999 DrawNow(); |
|
1000 iGrid->DrawNow(); |
|
1001 } |
|
1002 } |
|
1003 else |
|
1004 { |
|
1005 delete aBitmap; |
|
1006 } |
|
1007 delete &aOperation; |
|
1008 (*iSdmArray)[index].SetOperation(NULL); |
|
1009 delete (*iSdmArray)[index].ContactItem(); |
|
1010 (*iSdmArray)[index].SetContactItem(NULL); |
|
1011 } |
|
1012 } |
|
1013 |
|
1014 // --------------------------------------------------------- |
|
1015 // CSpdiaControl::PbkThumbnailGetFailed |
|
1016 // |
|
1017 // --------------------------------------------------------- |
|
1018 // |
|
1019 void CSpdiaControl::PbkThumbnailGetFailed |
|
1020 (MPbkThumbnailOperation& aOperation, |
|
1021 TInt /*aError*/) |
|
1022 { |
|
1023 TInt index(HasOperation(aOperation)); |
|
1024 if (index != KNullIndexData) |
|
1025 { |
|
1026 delete &aOperation; |
|
1027 (*iSdmArray)[index].SetOperation(NULL); |
|
1028 delete (*iSdmArray)[index].ContactItem(); |
|
1029 (*iSdmArray)[index].SetContactItem(NULL); |
|
1030 } |
|
1031 } |
|
1032 |
|
1033 // --------------------------------------------------------- |
|
1034 // CSpdiaContainer::Draw |
|
1035 // |
|
1036 // --------------------------------------------------------- |
|
1037 // |
|
1038 void CSpdiaControl::Draw(const TRect& /*aRect*/) const |
|
1039 { |
|
1040 CWindowGc& gc = SystemGc(); |
|
1041 |
|
1042 AknsDrawUtils::Background( |
|
1043 AknsUtils::SkinInstance(), |
|
1044 AknsDrawUtils::ControlContext(this), |
|
1045 this, |
|
1046 gc, |
|
1047 Rect() ); |
|
1048 |
|
1049 DrawShadow(gc); |
|
1050 } |
|
1051 |
|
1052 // --------------------------------------------------------- |
|
1053 // CSpdiaContainer::HandleDatabaseEventL |
|
1054 // Handles an database event of type aEventType. |
|
1055 // --------------------------------------------------------- |
|
1056 // |
|
1057 void CSpdiaControl::HandleDatabaseEventL( |
|
1058 TContactDbObserverEvent /*aEvent*/) |
|
1059 { |
|
1060 // An update flag will be updated if the grid is used. |
|
1061 // Other than this, index data is updated. |
|
1062 if (iGridUsed != EGridUse) |
|
1063 { |
|
1064 InitIndexDataL(); |
|
1065 } |
|
1066 } |
|
1067 |
|
1068 // --------------------------------------------------------- |
|
1069 // CSpdiaControl::ConstructL |
|
1070 // |
|
1071 // --------------------------------------------------------- |
|
1072 // |
|
1073 void CSpdiaControl::ConstructL() |
|
1074 { |
|
1075 TInt tmp = 1; |
|
1076 |
|
1077 _LIT(KMbmFileName, "Z:spdctrl.mbm"); |
|
1078 _LIT(KRscFileName, "Z:spdctrl.rsc" ); |
|
1079 |
|
1080 TParse* fpMbm = new(ELeave) TParse (); |
|
1081 fpMbm->Set (KMbmFileName, &KDC_APP_BITMAP_DIR, NULL); |
|
1082 iBmpPath.Copy(fpMbm ->FullName()); |
|
1083 delete fpMbm; |
|
1084 fpMbm=NULL; |
|
1085 |
|
1086 TParse* fpRsc = new(ELeave) TParse (); |
|
1087 fpRsc->Set (KRscFileName, &KDC_RESOURCE_FILES_DIR, NULL); |
|
1088 iRscPath.Copy(fpRsc ->FullName()); |
|
1089 delete fpRsc; |
|
1090 fpRsc=NULL; |
|
1091 |
|
1092 RSharedDataClient sd; |
|
1093 User::LeaveIfError( sd.Connect() ); |
|
1094 CleanupClosePushL(sd); |
|
1095 User::LeaveIfError(sd.Assign(KSDUidSpeedDialLV)); |
|
1096 User::LeaveIfError(sd.GetInt(KSpeedDialLVFlags, tmp)); |
|
1097 |
|
1098 iBooleanVarForAddingDialogVariation = ( tmp == 1); |
|
1099 |
|
1100 CleanupStack::PopAndDestroy(); |
|
1101 |
|
1102 if (iEngine == NULL) |
|
1103 { |
|
1104 iEngine = CPbkContactEngine::NewL(); |
|
1105 } |
|
1106 iPbkNotifier = iEngine->CreateContactChangeNotifierL(this); |
|
1107 |
|
1108 iPbkResourceFile = new (ELeave) RPbkViewResourceFile(*iCoeEnv); |
|
1109 if (!iPbkResourceFile->IsOpen()) |
|
1110 { |
|
1111 iPbkResourceFile->OpenL(); |
|
1112 } |
|
1113 |
|
1114 TFileName fileName(iRscPath); |
|
1115 BaflUtils::NearestLanguageFile(iCoeEnv->FsSession(), fileName); |
|
1116 iFileOffset = iCoeEnv->AddResourceFileL(fileName); |
|
1117 |
|
1118 iSdmCount = KCellRowCount * KCellColCount; |
|
1119 iGridUsed = EGridNoUse; |
|
1120 |
|
1121 iIconArray = new (ELeave)CAknIconArray(iSdmCount); |
|
1122 iSdmArray = new (ELeave) CArrayFixFlat<TSpdiaIndexData> (iSdmCount); |
|
1123 |
|
1124 iDialSkinBmp = new (ELeave)RArray<TAknsItemID>(KArraySize); |
|
1125 iSkinIcons = new (ELeave)RArray<TAknsItemID>(KArraySize); |
|
1126 iShadowLayout = new (ELeave) CArrayFixFlat<TAknLayoutRect> (KLayoutCount); |
|
1127 for (TInt i(0); i < KLayoutCount; ++i) |
|
1128 { |
|
1129 TAknLayoutRect rect; |
|
1130 iShadowLayout->AppendL(rect); |
|
1131 } |
|
1132 |
|
1133 InitIndexDataL(); |
|
1134 |
|
1135 InitializeArray(); |
|
1136 |
|
1137 // create skin context |
|
1138 // Size is set in SizeChanged() |
|
1139 iBgContext = CAknsBasicBackgroundControlContext::NewL( |
|
1140 KAknsIIDQsnBgAreaMainQdial, |
|
1141 TRect(0,0,0,0), |
|
1142 EFalse ); |
|
1143 } |
|
1144 |
|
1145 // --------------------------------------------------------- |
|
1146 // CSpdiaControl::InitIndexDataL |
|
1147 // The SDM control data is initialized. |
|
1148 // --------------------------------------------------------- |
|
1149 // |
|
1150 void CSpdiaControl::InitIndexDataL() |
|
1151 { |
|
1152 // The dialog of grid is not closed. |
|
1153 if (iIconArray != NULL) |
|
1154 { |
|
1155 ResetArray(); |
|
1156 iSdmArray->Reset(); |
|
1157 for (TInt i(0); i < iSdmCount; ++i) |
|
1158 { |
|
1159 TSpdiaIndexData data; |
|
1160 SetIndexDataL(i, data); |
|
1161 iSdmArray->AppendL(data); |
|
1162 } |
|
1163 } |
|
1164 } |
|
1165 |
|
1166 // --------------------------------------------------------- |
|
1167 // CSpdiaControl::ThumbType |
|
1168 // An interface for accessing index data array. |
|
1169 // --------------------------------------------------------- |
|
1170 // |
|
1171 TInt CSpdiaControl::ThumbType(TInt aIndex) const |
|
1172 { |
|
1173 return ConvThumbType((*iSdmArray)[aIndex].ThumbSize()); |
|
1174 } |
|
1175 |
|
1176 // --------------------------------------------------------- |
|
1177 // CSpdiaControl::ThumbType |
|
1178 // An interface for accessing index data array. |
|
1179 // --------------------------------------------------------- |
|
1180 // |
|
1181 TSize CSpdiaControl::ThumbSize(TInt aIndex) const |
|
1182 { |
|
1183 return (*iSdmArray)[aIndex].ThumbSize(); |
|
1184 } |
|
1185 |
|
1186 // --------------------------------------------------------- |
|
1187 // CSpdiaControl::IconPositionL |
|
1188 // phone book access |
|
1189 // --------------------------------------------------------- |
|
1190 // |
|
1191 TInt CSpdiaControl::IconPositionL(const CPbkContactItem& aItem, TInt aDial, TInt& aFieldId) |
|
1192 { |
|
1193 TInt index(KNullIndexData); |
|
1194 CPbkFieldArray& fields = aItem.CardFields(); |
|
1195 for (TInt fieldIdx(0); index == KNullIndexData && |
|
1196 fieldIdx < fields.Count(); ++fieldIdx) |
|
1197 { |
|
1198 TPbkContactItemField& field = fields[fieldIdx]; |
|
1199 CArrayFix<TInt>* array = field.SpeedDialIndexesL(); |
|
1200 if (array) |
|
1201 { |
|
1202 for (TInt i(0); index < 0 && i < array->Count(); ++i) |
|
1203 { |
|
1204 if (aDial == (*array)[i]) |
|
1205 { |
|
1206 index = FindIconIndex(field.FieldInfo().IconId()); |
|
1207 aFieldId = field.FieldInfo().FieldId(); |
|
1208 } |
|
1209 } |
|
1210 delete array; |
|
1211 } |
|
1212 } |
|
1213 return index; |
|
1214 } |
|
1215 |
|
1216 // --------------------------------------------------------- |
|
1217 // CSpdiaControl::FindIconIndex |
|
1218 // |
|
1219 // --------------------------------------------------------- |
|
1220 // |
|
1221 TInt CSpdiaControl::FindIconIndex(TInt aId) const |
|
1222 { |
|
1223 TInt index(KNullIndexData); |
|
1224 for (TInt n(0); index == KNullIndexData && n < KIconsCount; ++n) |
|
1225 { |
|
1226 if (KIconsId[n] == (TUint)aId) |
|
1227 { |
|
1228 index = n + iSdmCount; |
|
1229 } |
|
1230 } |
|
1231 return index; |
|
1232 } |
|
1233 |
|
1234 // --------------------------------------------------------- |
|
1235 // CSpdiaControl::DeleteIconArray |
|
1236 // Deletes the old icons. |
|
1237 // --------------------------------------------------------- |
|
1238 EXPORT_C void CSpdiaControl::DeleteIconArray() |
|
1239 { |
|
1240 if(iIconArray) |
|
1241 { |
|
1242 iIconArray->ResetAndDestroy(); |
|
1243 delete iIconArray; |
|
1244 iIconArray = NULL; |
|
1245 } |
|
1246 } |
|
1247 // --------------------------------------------------------- |
|
1248 // CSpdiaControl::ReloadIconArray |
|
1249 // Reloads the new skin icons. |
|
1250 // --------------------------------------------------------- |
|
1251 EXPORT_C void CSpdiaControl::ReloadIconArray() |
|
1252 { |
|
1253 TRAP_IGNORE(ReloadIconArrayL()); |
|
1254 } |
|
1255 |
|
1256 // --------------------------------------------------------- |
|
1257 // CSpdiaControl::ReloadIconArrayL |
|
1258 // Reloads the new skin icons. |
|
1259 // --------------------------------------------------------- |
|
1260 void CSpdiaControl::ReloadIconArrayL() |
|
1261 { |
|
1262 if(NULL == iIconArray) |
|
1263 { |
|
1264 iIconArray = new (ELeave)CAknIconArray(iSdmCount); |
|
1265 } |
|
1266 SetIconArrayL(iIconArray); |
|
1267 } |
|
1268 |
|
1269 // --------------------------------------------------------- |
|
1270 // CSpdiaControl::SetIconArrayL |
|
1271 // |
|
1272 // --------------------------------------------------------- |
|
1273 // |
|
1274 TInt CSpdiaControl::SetIconArrayL(CArrayPtrFlat<CGulIcon>* aArray) |
|
1275 { |
|
1276 |
|
1277 CFbsBitmap* bitmap,*mask; |
|
1278 bitmap = NULL; |
|
1279 mask= NULL; |
|
1280 MAknsSkinInstance* skinInstance = AknsUtils::SkinInstance(); |
|
1281 if (!iManager) |
|
1282 { |
|
1283 iManager = CPbkThumbnailManager::NewL(*iEngine); |
|
1284 } |
|
1285 if (!iThumbFactory) |
|
1286 { |
|
1287 iThumbFactory = CPAlbImageFactory::NewL(NULL); |
|
1288 } |
|
1289 if(aArray!=NULL) |
|
1290 aArray->ResetAndDestroy(); |
|
1291 |
|
1292 TInt existThumb(0); |
|
1293 for (TInt index(0); index < iSdmArray->Count(); index++) |
|
1294 { |
|
1295 AknsUtils::CreateIconL(skinInstance, (*iDialSkinBmp)[index],bitmap,mask,iBmpPath,KDialBmp[index], KDialBmpMask[index] ); |
|
1296 CGulIcon* icon = CGulIcon::NewL(bitmap,mask); |
|
1297 CleanupStack::PushL(icon); |
|
1298 aArray->AppendL(icon); |
|
1299 |
|
1300 if (CreateIndexIconL(index, |
|
1301 (*iSdmArray)[index], existThumb > 0? EFalse: ETrue)) |
|
1302 { |
|
1303 ++existThumb; |
|
1304 } |
|
1305 CleanupStack::Pop(); // icon |
|
1306 } |
|
1307 |
|
1308 // Add icons |
|
1309 for (TInt i(0); i < KIconsCount; ++i) |
|
1310 { |
|
1311 AknsUtils::CreateIconL(skinInstance, (*iSkinIcons)[i],bitmap,mask,AknIconUtils::AvkonIconFileName(),KIcons[i], KIconsMask[i] ); |
|
1312 aArray->AppendL(CGulIcon::NewL(bitmap,mask)); |
|
1313 |
|
1314 } |
|
1315 |
|
1316 return existThumb; |
|
1317 } |
|
1318 |
|
1319 // --------------------------------------------------------- |
|
1320 // CSpdiaContainer::ItemDescriptorL |
|
1321 // |
|
1322 // --------------------------------------------------------- |
|
1323 // |
|
1324 HBufC* CSpdiaControl::ItemDescriptorLC(TInt aIndex, |
|
1325 const TSpdiaIndexData& aSdmData) |
|
1326 { |
|
1327 HBufC* des = NULL; |
|
1328 if (aSdmData.ContactId() != KNullContactId) |
|
1329 { |
|
1330 des = CreateItemDescriptorLC(aSdmData); |
|
1331 } |
|
1332 else |
|
1333 { |
|
1334 des = HBufC::NewLC(KNullCell.iTypeLength); |
|
1335 des->Des().Format(KNullCell, aIndex); |
|
1336 } |
|
1337 return des; |
|
1338 } |
|
1339 |
|
1340 // --------------------------------------------------------- |
|
1341 // CSpdiaContainer::CreateItemDescriptorL |
|
1342 // |
|
1343 // --------------------------------------------------------- |
|
1344 // |
|
1345 HBufC* CSpdiaControl::CreateItemDescriptorLC(const TSpdiaIndexData& aSdmData) |
|
1346 { |
|
1347 HBufC* des = HBufC::NewLC(KApaMaxAppCaption); |
|
1348 TPtr ptr(des->Des()); |
|
1349 |
|
1350 // thumb type |
|
1351 TInt type(CSpdiaGrid::EText); |
|
1352 if (aSdmData.ThumbIndex() >= 0) |
|
1353 { |
|
1354 type = ConvThumbType(aSdmData.ThumbSize()); |
|
1355 } |
|
1356 |
|
1357 // Text |
|
1358 if (type == CSpdiaGrid::EText) |
|
1359 { |
|
1360 ptr.Append(KDesTab); // 1 |
|
1361 if (aSdmData.IconIndex() >= 0) |
|
1362 { |
|
1363 ptr.AppendNum(aSdmData.IconIndex()); |
|
1364 } |
|
1365 AppendTextL(aSdmData, ptr); // 2,3,4 |
|
1366 } |
|
1367 else |
|
1368 { |
|
1369 // icon + text + text + text |
|
1370 ptr.Append(KDesTab2); // 1, 2 |
|
1371 ptr.Append(KDesTab2); // 2 |
|
1372 } |
|
1373 |
|
1374 // thumbnail 5-14 |
|
1375 for (TInt i(CSpdiaGrid::EtnCIF90); i <= CSpdiaGrid::EtnCOM; ++i) |
|
1376 { |
|
1377 AppendThumbnail(aSdmData, ptr, (type == i? ETrue: EFalse)); |
|
1378 } |
|
1379 |
|
1380 // number |
|
1381 ptr.Append(KDesTab); // 15 |
|
1382 // check |
|
1383 ptr.Append(KDesTab); // 16 |
|
1384 |
|
1385 return des; |
|
1386 } |
|
1387 |
|
1388 // --------------------------------------------------------- |
|
1389 // CSpdiaContainer::AppendTextL |
|
1390 // output Text1\tText2\tText3\t |
|
1391 // --------------------------------------------------------- |
|
1392 // |
|
1393 void CSpdiaControl::AppendTextL(const TSpdiaIndexData& aSdmData, TPtr& aText) |
|
1394 { |
|
1395 CPbkContactItem* item = iEngine->ReadContactLC(aSdmData.ContactId()); |
|
1396 if (item == NULL) |
|
1397 { |
|
1398 aText.Append(KDesTab2); |
|
1399 aText.Append(KDesTab2); |
|
1400 } |
|
1401 else |
|
1402 { |
|
1403 TPbkContactItemField* lastNameField = |
|
1404 FindFieldL(*item, EPbkFieldIdLastName); // Last Name |
|
1405 TPbkContactItemField* firstNameField = |
|
1406 FindFieldL(*item, EPbkFieldIdFirstName); // First Name |
|
1407 TPbkContactItemField* companyNameField = |
|
1408 FindFieldL(*item, EPbkFieldIdCompanyName); |
|
1409 |
|
1410 aText.Append(KDesTab); // 2 |
|
1411 if (!lastNameField && !firstNameField && !companyNameField) |
|
1412 { |
|
1413 aText.Append(aSdmData.PhoneNumber()); |
|
1414 aText.Append(KDesTab); // 3 |
|
1415 } |
|
1416 else if (!lastNameField && !firstNameField) |
|
1417 { |
|
1418 aText.Append(companyNameField->Text()); |
|
1419 aText.Append(KDesTab); // 3 |
|
1420 } |
|
1421 else |
|
1422 { |
|
1423 if (lastNameField) |
|
1424 { |
|
1425 aText.Append(lastNameField->Text()); |
|
1426 aText.Append(KDesTab); // 3 |
|
1427 } |
|
1428 if (firstNameField) |
|
1429 { |
|
1430 aText.Append(firstNameField->Text()); |
|
1431 } |
|
1432 if (!lastNameField) |
|
1433 { |
|
1434 aText.Append(KDesTab); // 3 |
|
1435 } |
|
1436 } |
|
1437 aText.Append(KDesTab); // 4 |
|
1438 } |
|
1439 CleanupStack::PopAndDestroy(); // item |
|
1440 } |
|
1441 |
|
1442 // --------------------------------------------------------- |
|
1443 // CSpdiaContainer::FindFieldL |
|
1444 // |
|
1445 // --------------------------------------------------------- |
|
1446 // |
|
1447 TPbkContactItemField* CSpdiaControl::FindFieldL( |
|
1448 CPbkContactItem& aItem, TPbkFieldId aFieldId) |
|
1449 { |
|
1450 TPbkContactItemField* field = aItem.FindField(aFieldId); |
|
1451 if (field) |
|
1452 { |
|
1453 HBufC* buf = field->Text().AllocL(); |
|
1454 buf->Des().Trim(); |
|
1455 if (buf->Des().Length() == 0) |
|
1456 { |
|
1457 field = NULL; |
|
1458 } |
|
1459 delete buf; |
|
1460 } |
|
1461 return field; |
|
1462 } |
|
1463 // --------------------------------------------------------- |
|
1464 // CSpdiaContainer::AppendThumbnail |
|
1465 // output \tThumbnail\ticon |
|
1466 // --------------------------------------------------------- |
|
1467 // |
|
1468 void CSpdiaControl::AppendThumbnail( |
|
1469 const TSpdiaIndexData& aSdmData, |
|
1470 TPtr& aText, |
|
1471 TBool aFixedLocation ) |
|
1472 { |
|
1473 if (!aFixedLocation) |
|
1474 { |
|
1475 aText.Append(KDesTab2); |
|
1476 return; |
|
1477 } |
|
1478 |
|
1479 aText.Append(KDesTab); |
|
1480 if (aSdmData.ThumbIndex() >= 0) |
|
1481 { |
|
1482 aText.AppendNum(aSdmData.ThumbIndex()); |
|
1483 } |
|
1484 |
|
1485 aText.Append(KDesTab); |
|
1486 if (aSdmData.IconIndex() >= 0) |
|
1487 { |
|
1488 aText.AppendNum(aSdmData.IconIndex()); |
|
1489 } |
|
1490 } |
|
1491 |
|
1492 // --------------------------------------------------------- |
|
1493 // CSpdiaContainer::ConvThumbType |
|
1494 // Returns |
|
1495 // EtnVGA : 640 x 480 40 x 30 VGA |
|
1496 // EtnVGA90: 480 x 640 30 x 40 VGA turned |
|
1497 // EtnCIF : 352 x 288 44 x 36 CIF |
|
1498 // EtnCIF90: 288 x 352 36 x 44 CIF turned |
|
1499 // EtnCOM : othre |
|
1500 // --------------------------------------------------------- |
|
1501 // |
|
1502 TInt CSpdiaControl::ConvThumbType(const TSize& aSize) const |
|
1503 { |
|
1504 // Scalable UI |
|
1505 TAknWindowLineLayout vga = AppLayout::Thumbnail_pop_up_window_elements_Line_1(); |
|
1506 TAknWindowLineLayout cif = AppLayout::Thumbnail_pop_up_window_elements_Line_3(); |
|
1507 TInt cifWidth; |
|
1508 TInt cifHeight; |
|
1509 TInt vgaWidth; |
|
1510 TInt vgaHeight; |
|
1511 TAknLayoutRect vgaRect; |
|
1512 TAknLayoutRect cifRect; |
|
1513 vgaRect.LayoutRect(Rect(),vga); |
|
1514 vgaWidth = vgaRect.Rect().Width(); |
|
1515 vgaHeight = vgaRect.Rect().Height(); |
|
1516 cifRect.LayoutRect(Rect() ,cif); |
|
1517 cifWidth = cifRect.Rect().Width(); |
|
1518 cifHeight = cifRect.Rect().Height(); |
|
1519 TInt type(CSpdiaGrid::EtnCOM); |
|
1520 |
|
1521 if (aSize.iWidth == cifHeight//SDM_TN_CIF_HEIGHT |
|
1522 && aSize.iHeight == cifWidth)// SDM_TN_CIF_WIDTH) |
|
1523 { |
|
1524 type = CSpdiaGrid::EtnCIF90; |
|
1525 } |
|
1526 else if (aSize.iWidth == cifWidth &&//SDM_TN_CIF_WIDTH && |
|
1527 aSize.iHeight == cifHeight)//SDM_TN_CIF_HEIGHT) |
|
1528 { |
|
1529 type = CSpdiaGrid::EtnCIF; |
|
1530 } |
|
1531 else if (aSize.iWidth == vgaHeight&&//SDM_TN_VGA_HEIGHT && |
|
1532 aSize.iHeight == vgaWidth)//SDM_TN_VGA_WIDTH) |
|
1533 { |
|
1534 type = CSpdiaGrid::EtnVGA90; |
|
1535 } |
|
1536 else if (aSize.iWidth == vgaWidth&&//SDM_TN_VGA_WIDTH && |
|
1537 aSize.iHeight == vgaHeight)//SDM_TN_VGA_HEIGHT) |
|
1538 { |
|
1539 type = CSpdiaGrid::EtnVGA; |
|
1540 } |
|
1541 |
|
1542 return type; |
|
1543 } |
|
1544 |
|
1545 |
|
1546 // --------------------------------------------------------- |
|
1547 // CSpdiaContainer::SetOperationsL |
|
1548 // |
|
1549 // --------------------------------------------------------- |
|
1550 // |
|
1551 void CSpdiaControl::SetOperationsL() |
|
1552 { |
|
1553 for (TInt index(iSdmArray->Count() -1); index > 0; --index) |
|
1554 { |
|
1555 TSpdiaIndexData& data = (*iSdmArray)[index]; |
|
1556 if (data.ContactItem() != NULL) |
|
1557 { |
|
1558 data.SetOperation( |
|
1559 iManager->GetThumbnailAsyncL(*this, *data.ContactItem())); |
|
1560 } |
|
1561 } |
|
1562 } |
|
1563 |
|
1564 // --------------------------------------------------------- |
|
1565 // CSpdiaContainer::SetItemDataL |
|
1566 // |
|
1567 // --------------------------------------------------------- |
|
1568 // |
|
1569 void CSpdiaControl::SetItemDataL(CDesCArray& aArray) |
|
1570 { |
|
1571 for (TInt loop(0); loop < iSdmCount; loop++) |
|
1572 { |
|
1573 TSpdiaIndexData& data = (*iSdmArray)[loop]; |
|
1574 |
|
1575 aArray.AppendL(ItemDescriptorLC(loop, data)->Des()); |
|
1576 CleanupStack::PopAndDestroy(); // des |
|
1577 } |
|
1578 } |
|
1579 |
|
1580 |
|
1581 // --------------------------------------------------------- |
|
1582 // CSpdiaContainer::AssignDialL |
|
1583 // Function called when assigning speed dial from phone book |
|
1584 // application |
|
1585 // --------------------------------------------------------- |
|
1586 // |
|
1587 void CSpdiaControl::AssignDialL(TContactItemId aId, TInt aFieldIdx, TInt aDial) |
|
1588 { |
|
1589 |
|
1590 if (iBooleanVarForAddingDialogVariation) |
|
1591 { |
|
1592 CSpdiaControl::CheckingIfPopUpNeeded(); |
|
1593 } |
|
1594 else |
|
1595 { // do nothing |
|
1596 } |
|
1597 |
|
1598 TInt index(Index(aDial)); |
|
1599 TPhCltTelephoneNumber phonenumber; |
|
1600 TContactItemId id(ContactId(index)); |
|
1601 if (id != KNullContactId) |
|
1602 { |
|
1603 RemoveDialIndexL(index, EFalse); |
|
1604 } |
|
1605 |
|
1606 CPbkContactItem* item = iEngine->OpenContactL(aId); |
|
1607 CleanupStack::PushL(item); |
|
1608 |
|
1609 CPbkFieldArray& fields = item->CardFields(); |
|
1610 TPbkContactItemField& field = fields[aFieldIdx]; |
|
1611 field.GetTextL(phonenumber); |
|
1612 phonenumber.Trim(); |
|
1613 iEngine->SetFieldAsSpeedDialL(*item, aFieldIdx, aDial); |
|
1614 iEngine->CloseContactL(aId); |
|
1615 CleanupStack::PopAndDestroy(); // item |
|
1616 |
|
1617 HBufC* prompt = |
|
1618 StringLoader::LoadLC(R_SPDIA_TEXT_KEY_ASSIGNED, aDial, iCoeEnv); |
|
1619 CAknConfirmationNote* note = new (ELeave)CAknConfirmationNote(); |
|
1620 note->ExecuteLD(*prompt); |
|
1621 |
|
1622 CleanupStack::PopAndDestroy(); // prompt |
|
1623 } |
|
1624 |
|
1625 // --------------------------------------------------------- |
|
1626 // CCalenNoteForm::CheckSpaceBelowCriticalLevelL |
|
1627 // Checks if the Flash File System storage will fall below |
|
1628 // Critical Level. Warning will be displayed if sotrage |
|
1629 // is below Critical Level. |
|
1630 // (other items were commented in a header). |
|
1631 // --------------------------------------------------------- |
|
1632 // |
|
1633 TBool CSpdiaControl::CheckSpaceBelowCriticalLevelL() |
|
1634 { |
|
1635 TBool retcode(EFalse); |
|
1636 |
|
1637 if (SysUtil::FFSSpaceBelowCriticalLevelL(&(iCoeEnv->FsSession()))) |
|
1638 { |
|
1639 CErrorUI* errorUi = CErrorUI::NewLC(); |
|
1640 errorUi->ShowGlobalErrorNoteL(KErrDiskFull); |
|
1641 CleanupStack::PopAndDestroy(); // errorUi |
|
1642 retcode = ETrue; |
|
1643 } |
|
1644 return retcode; |
|
1645 } |
|
1646 |
|
1647 // --------------------------------------------------------- |
|
1648 // CSpdiaContainer::HasOperation |
|
1649 // |
|
1650 // --------------------------------------------------------- |
|
1651 // |
|
1652 TInt CSpdiaControl::HasOperation(const MPbkThumbnailOperation& aOperation) |
|
1653 { |
|
1654 for (TInt index(0); index < iSdmArray->Count(); index++) |
|
1655 { |
|
1656 if ((*iSdmArray)[index].Operation() == &aOperation) |
|
1657 { |
|
1658 return index; |
|
1659 } |
|
1660 } |
|
1661 return KNullIndexData; |
|
1662 } |
|
1663 |
|
1664 // --------------------------------------------------------- |
|
1665 // CSpdiaContainer::ResetArray |
|
1666 // |
|
1667 // --------------------------------------------------------- |
|
1668 // |
|
1669 void CSpdiaControl::ResetArray() |
|
1670 { |
|
1671 for (TInt index(0); index < iSdmArray->Count(); index++) |
|
1672 { |
|
1673 delete (*iSdmArray)[index].ContactItem(); |
|
1674 delete (*iSdmArray)[index].Operation(); |
|
1675 } |
|
1676 } |
|
1677 |
|
1678 // --------------------------------------------------------- |
|
1679 // CSpdiaContainer::UpdateIndexDataL |
|
1680 // |
|
1681 // --------------------------------------------------------- |
|
1682 // |
|
1683 TBool CSpdiaControl::UpdateIndexDataL(TInt aIndex) |
|
1684 { |
|
1685 CFbsBitmap* bitmap,*mask; |
|
1686 bitmap = NULL; |
|
1687 mask= NULL; |
|
1688 MAknsSkinInstance* skinInstance = AknsUtils::SkinInstance(); |
|
1689 |
|
1690 |
|
1691 TSpdiaIndexData& data = (*iSdmArray)[aIndex]; |
|
1692 delete (*iIconArray)[aIndex]; |
|
1693 (*iIconArray)[aIndex] = NULL; |
|
1694 TFileName bmpPath(iBmpPath); |
|
1695 |
|
1696 AknsUtils::CreateIconL(skinInstance, (*iDialSkinBmp)[aIndex],bitmap,mask,bmpPath,KDialBmp[aIndex], KDialBmpMask[aIndex] ); |
|
1697 (*iIconArray)[aIndex] = CGulIcon::NewL(bitmap,mask); |
|
1698 |
|
1699 |
|
1700 |
|
1701 |
|
1702 data.ResetThumbIndex(); |
|
1703 if (CreateIndexIconL(aIndex, data, ETrue)) |
|
1704 { |
|
1705 data.SetOperation( |
|
1706 iManager->GetThumbnailAsyncL(*this, *data.ContactItem())); |
|
1707 } |
|
1708 else |
|
1709 { |
|
1710 ChangeIndexDataL(aIndex, data); |
|
1711 iGrid->DrawNow(); |
|
1712 } |
|
1713 return ETrue; |
|
1714 } |
|
1715 |
|
1716 // --------------------------------------------------------- |
|
1717 // CSpdiaContainer::SetIndexDataL |
|
1718 // phone book access |
|
1719 // --------------------------------------------------------- |
|
1720 // |
|
1721 void CSpdiaControl::SetIndexDataL(TInt aIndex, TSpdiaIndexData& aSdmData) |
|
1722 { |
|
1723 TPhCltTelephoneNumber phonenumber; |
|
1724 |
|
1725 aSdmData.SetIndex(aIndex); |
|
1726 aSdmData.SetPhoneNumber(KNullDesC); |
|
1727 aSdmData.SetNumber(aIndex + 1); |
|
1728 aSdmData.SetContactId(iEngine->GetSpeedDialFieldL( |
|
1729 aIndex + 1, phonenumber)); |
|
1730 if (aSdmData.ContactId() != KNullContactId) |
|
1731 { |
|
1732 phonenumber.Trim(); |
|
1733 if (phonenumber.Length() > 0) |
|
1734 { |
|
1735 aSdmData.SetPhoneNumber(phonenumber); |
|
1736 } |
|
1737 else |
|
1738 { |
|
1739 iEngine->RemoveSpeedDialFieldL(aSdmData.ContactId(), aIndex + 1); |
|
1740 aSdmData.SetContactId(KNullContactId); |
|
1741 } |
|
1742 } |
|
1743 } |
|
1744 |
|
1745 // --------------------------------------------------------- |
|
1746 // CSpdiaContainer::ChangeIndexDataL |
|
1747 // |
|
1748 // --------------------------------------------------------- |
|
1749 // |
|
1750 void CSpdiaControl::ChangeIndexDataL( |
|
1751 TInt aIndex, |
|
1752 const TSpdiaIndexData& aSdmData ) |
|
1753 { |
|
1754 CDesCArray* array = STATIC_CAST(CDesCArray*, |
|
1755 iGrid->Model()->ItemTextArray()); |
|
1756 HBufC* des = ItemDescriptorLC(aIndex, aSdmData); |
|
1757 array->Delete(aIndex); |
|
1758 array->InsertL(aIndex, *des); |
|
1759 CleanupStack::PopAndDestroy(); // des |
|
1760 } |
|
1761 |
|
1762 // --------------------------------------------------------- |
|
1763 // CSpdiaContainer::CreateIndexIconL |
|
1764 // |
|
1765 // --------------------------------------------------------- |
|
1766 // |
|
1767 TBool CSpdiaControl::CreateIndexIconL(TInt aIndex, |
|
1768 TSpdiaIndexData& aSdmData, TBool aSetUpdateThumb) |
|
1769 { |
|
1770 TBool existThumb(EFalse); |
|
1771 |
|
1772 if (aSdmData.ContactId() != KNullContactId) |
|
1773 { |
|
1774 CPbkContactItem* item = iEngine->ReadContactL(aSdmData.ContactId()); |
|
1775 TInt fieldId(EPbkFieldIdNone); |
|
1776 aSdmData.SetIconIndex(IconPositionL(*item, aIndex + 1, fieldId)); |
|
1777 aSdmData.SetFieldId( fieldId ); // set number type |
|
1778 |
|
1779 if (iManager->HasThumbnail(*item)) |
|
1780 { |
|
1781 existThumb = ETrue; |
|
1782 aSdmData.SetContactItem(item); |
|
1783 |
|
1784 if (aSetUpdateThumb) |
|
1785 { |
|
1786 aSdmData.SetLastThumb(ETrue); |
|
1787 } |
|
1788 aSdmData.SetThumbIndex(aIndex, NULL); |
|
1789 } |
|
1790 else |
|
1791 { |
|
1792 delete item; |
|
1793 } |
|
1794 } |
|
1795 return existThumb; |
|
1796 } |
|
1797 |
|
1798 // --------------------------------------------------------- |
|
1799 // CSpdiaContainer::DrawShadow |
|
1800 // |
|
1801 // --------------------------------------------------------- |
|
1802 // |
|
1803 void CSpdiaControl::DrawShadow(CWindowGc& aGc) const |
|
1804 { |
|
1805 //Scalable UI. |
|
1806 TAknWindowLineLayout area = AppLayout::cell_qdial_pane(0,0); |
|
1807 TAknLayoutRect areaLayout; |
|
1808 areaLayout.LayoutRect(Rect() ,area); |
|
1809 TInt width = areaLayout.Rect().Width(); |
|
1810 TInt height= areaLayout.Rect().Height(); |
|
1811 |
|
1812 TSize size(width, height); |
|
1813 aGc.SetPenColor(AKN_LAF_COLOR(SDM_TN_SHADOW_COROL)); |
|
1814 TInt count(iSdmArray->Count()); |
|
1815 |
|
1816 //Scalable UI |
|
1817 area = AppLayout::Speed_Dial_descendants_Line_1(); |
|
1818 areaLayout.LayoutRect(Rect() ,area); |
|
1819 TInt areaLayoutTopLeftX =areaLayout.Rect().iTl.iX; |
|
1820 TInt areaLayoutTopLeftY =areaLayout.Rect().iTl.iY; |
|
1821 |
|
1822 TRect rect(TPoint(areaLayoutTopLeftX, areaLayoutTopLeftY), size); |
|
1823 |
|
1824 for (TInt i(0); i < count; ++i) |
|
1825 { |
|
1826 if (ThumbIndex(i) >= 0) |
|
1827 { |
|
1828 TInt type(ThumbType(i)); |
|
1829 TRect rc((*iShadowLayout)[type].Rect()); |
|
1830 if (type == CSpdiaGrid::EtnCOM) |
|
1831 { |
|
1832 TSize image(ThumbSize(i)); |
|
1833 image.iWidth = Min(image.iWidth, rc.Width()); |
|
1834 image.iHeight = Min(image.iHeight, rc.Height()); |
|
1835 rc = TRect(TPoint(0,0), image); |
|
1836 TInt x(Max(0, (size.iWidth - image.iWidth) / 2) + 2); |
|
1837 TInt y(Max(0, (size.iHeight - image.iHeight) / 2) + 2); |
|
1838 rc.Move(x, y); |
|
1839 } |
|
1840 rc.Move(rect.iTl.iX, rect.iTl.iY); |
|
1841 aGc.DrawRect(rc); |
|
1842 } |
|
1843 rect.Move(size.iWidth, 0); |
|
1844 if (((i + 1)/ KCellColCount) * KCellRowCount == i + 1) |
|
1845 { |
|
1846 rect.Move(-(KCellColCount * size.iWidth), size.iHeight); |
|
1847 } |
|
1848 } |
|
1849 } |
|
1850 |
|
1851 // --------------------------------------------------------- |
|
1852 // CSpdiaControl::MopSupplyObject() |
|
1853 // Pass skin information if need. |
|
1854 // --------------------------------------------------------- |
|
1855 // |
|
1856 TTypeUid::Ptr CSpdiaControl::MopSupplyObject(TTypeUid aId) |
|
1857 { |
|
1858 if(aId.iUid == MAknsControlContext::ETypeId) |
|
1859 { |
|
1860 return MAknsControlContext::SupplyMopObject( aId, iBgContext ); |
|
1861 } |
|
1862 return CCoeControl::MopSupplyObject( aId ); |
|
1863 } |
|
1864 |
|
1865 // --------------------------------------------------------- |
|
1866 // CSpdiaControl::SizeChanged() |
|
1867 // --------------------------------------------------------- |
|
1868 // |
|
1869 void CSpdiaControl::SizeChanged() |
|
1870 { |
|
1871 iBgContext->SetRect( Rect() ); |
|
1872 } |
|
1873 |
|
1874 // --------------------------------------------------------- |
|
1875 // CSpdiaControl::VoiceMailTypeL |
|
1876 // |
|
1877 // --------------------------------------------------------- |
|
1878 // |
|
1879 EXPORT_C TInt CSpdiaControl::VoiceMailType() |
|
1880 { |
|
1881 return EVmbx; |
|
1882 } |
|
1883 // End of File |
|
1884 |