2 * Copyright (c) 2002 - 2005 Nokia Corporation and/or its subsidiary(-ies).
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".
9 * Initial Contributors:
10 * Nokia Corporation - initial contribution.
14 * Description: A utility that provides services to both the Speeddial and
15 * PhoneBook applications for getting and setting speeddial
16 * number configuration.
22 #ifndef SPDIACONTROL_H
23 #define SPDIACONTROL_H
27 #include <TPbkContactItemField.h>
29 #include <MPbkContactDbObserver.h>
30 #include <MPbkThumbnailOperationObservers.h>
32 // FORWARD DECLARATIONS
36 class TSpdiaIndexData;
37 class CPbkContactEngine;
38 class RPbkViewResourceFile;
42 class CPbkContactChangeNotifier;
43 class CPbkSingleItemFetchDlg;
44 class CAknQueryDialog;
46 class CPAlbImageFactory;
47 class CPbkThumbnailManager;
49 class CAknsBasicBackgroundControlContext;
50 #include <AknsConstants.h>
55 * A utility that provides services to both the Speeddial and PhoneBook
56 * applications for getting and setting speeddial number configuration.
62 // one line code added for build ver 2.6
63 const TInt KArraySize =9;
64 class CSpdiaControl : public CCoeControl,
65 public MPbkContactDbObserver,
66 private MPbkThumbnailGetObserver
68 public: // SpdiaControl APIs
70 * Creates a new instace of this class.
72 IMPORT_C static CSpdiaControl* NewL();
75 * Creates a new instace of this class.
77 * @param aPbkEngine reference of CPbkContactEngine.
79 IMPORT_C static CSpdiaControl* NewL(
80 CPbkContactEngine& aPbkEngine);
83 * Puts a query on the screen asking for '...Assign it now'.
84 * When the user goes through, it will assign speed dial.
86 * @param aLocation a location to assign speed dial.
87 * @param aStatusPane not used.
88 * @reutn ETrue if success.
90 IMPORT_C TBool AssignDialNumberL(TInt aLocation,
91 CEikStatusPane* aStatusPane = NULL);
94 * Runs the Speed Dial Selection Grid Dialog.
95 * If accepted sets speed dial key to aItem's aFieldId.
96 * Note: Calls CPbkContactEngine::SetFieldAsSpeedDialL().
97 * If necessary, calls CPbkContactEngine::RemoveSpeedDialFieldL().
99 * @param aId a contact item id. (Don't open)
100 * @param aFieldId index to aItems field set.
101 * @return nonzero if accepted, zero if canceled.
103 IMPORT_C TInt ExecuteLD(TContactItemId aId, TInt aFieldIdx);
106 * Cancels and dismisses this dialog. In other words makes
107 * ExecuteLD return just like cancel was pressed.
108 * Used when user switches a application and all modal
109 * dialogs are closed.
111 IMPORT_C void Cancel();
114 * The assigned number of the location is obtained.
115 * Note: Voice mail number will be returned if the location
116 * is the position of Voice mail.
117 * Note: If the location is empty, required dialog
118 * will be displayed and a location will be assigned.
120 * @param aLocation a location of speed dial.
121 * @param aPhonenumber reference of phonenumber.
122 * @param aStatusPane not used.
123 * @return EFalse if user cancel or failed.
125 IMPORT_C TBool DialNumberL(TInt aLocation, TDes& aPhoneNumber,
126 CEikStatusPane* aStatusPane = NULL);
128 private: // Constructors
130 * C++ default constructor.
137 CSpdiaControl(CPbkContactEngine* aPbkEngine);
140 * Gets actual size of thumbnial to be drawn.
141 * @return size of thumbnail.
143 TSize GetThumbnailSize();
145 public: // Destructor
150 IMPORT_C virtual ~CSpdiaControl();
152 public: // New function
154 * The number of voice mail returned, if voice mail is assigned.
155 * Note: If the location is empty, required dialog
156 * will be displayed and voice mail will be defined.
158 * @param aNumber reference of phone number.
159 * @retunr EFalse if user cancel or failed.
161 IMPORT_C TBool VoiceMailL(TDes& aNumber);
164 * Returns the owned Phone Book Engine.
166 IMPORT_C CPbkContactEngine* PbkEngine() const;
169 * The value converted into the index of an array from
170 * the location of speeddial is returned.
172 * @param aDial a location of speed dial.
173 * @return the index of a speeddial index data, if not found -1
175 IMPORT_C TInt Index(TInt aDial) const;
178 * The value converted into the the location of speeddial
179 * from index of an array is returned.
181 * @param aIndex a index of array.
182 * @return location of speed dial(1-9), if not found -1
184 IMPORT_C TInt Number(TInt aIndex) const;
187 * Returns the phone book contact item's id.
189 * @param aIndex a index of array.
190 * @return a contact item's id, if not found -1
192 IMPORT_C TContactItemId ContactId(TInt aIndex) const;
195 * Returns the phone number of a speed dial contact.
196 * Note: A character invalid as a phone number is removed.
198 * @param aDial a location of speeddial.
199 * @return phone number
201 IMPORT_C const TDesC& PhoneDialNumber(TInt aDial) const;
204 * Returns the phone number of a speed dial contact.
205 * Note: left and right spaces are removed.
207 * @param aIndex a index of array.
209 IMPORT_C const TDesC& PhoneNumber(TInt aIndex) const;
211 public: // SpeedDial internal API
213 * Gets a title text from contact item's id.
214 * Note: calls CPbkContactItem::GetContactTitleOrNullL()
215 * or CPbkContactEngine::UnnamedTitle()
217 * @param aCid contact item's id
218 * @param aUnnamed if title is empty, unname or NULL.
219 * @return a buffer containing the title. An unnametitle will
220 * be set if a title is empty.
222 IMPORT_C HBufC* ContactTitleL(TContactItemId aCid, TBool aUnnamed);
225 * Returns the icon index of a grid array.
227 * @param aIndex a index of array.
229 IMPORT_C TInt IconIndex(TInt aIndex) const;
232 * Returns the thumbnail index of a grid array.
234 * @param aIndex a index of array.
236 IMPORT_C TInt ThumbIndex(TInt aIndex) const;
239 * Returns the array of icons
241 IMPORT_C CArrayPtr<CGulIcon>* IconArray() const;
244 * Icons, thumbnails and text array for the grid are created.
245 * Note: If a aIndex parameter is set, only the data of the value
247 * Note: CreateDataL() is used if App to be used is except SD.
249 * @param aGrid the grid to set up
250 * @param aIndex (TInt) if <-1, All values are set up.
252 IMPORT_C TBool CreateGridDataL(CAknGrid* aGrid, TBool aIndex);
255 * Assigns the index data at the index in the phone book's contact entry.
257 * @param aIndex a index of array.
259 IMPORT_C TBool AssignDialIndexL(TInt aIndex);
262 * Removes a speed dial from the phone book's contact entry.
264 * @param aIndex a index of array.
265 * @param aConfirmation when remove, confirm is displayed.
266 * @reutn ETrue if success
268 IMPORT_C TBool RemoveDialIndexL(TInt aIndex,
269 TBool aConfirmation = ETrue);
271 * deprecated - do not use
273 IMPORT_C TBool AssignNumberL(TInt aIndex,
274 CEikStatusPane* aStatusPane,
275 CCoeControl* aContainer,
276 TBool aConfirmation);
277 IMPORT_C void ApplyCellSpdiaPaneStyleL(CAknGrid& aListBox, TSize& aSize);
278 IMPORT_C void DrawShadow(CWindowGc& aGc, const TSize& aSize);
281 * The position which a shadow draws is set up.
285 IMPORT_C void SetLayout(const TRect& aRect);
288 * deprecated - do not use
290 IMPORT_C TInt Size() const;
293 * Returns the position of voice mail box
295 IMPORT_C TInt VMBoxPosition() const;
298 * Returns the icon index of grid array.
300 IMPORT_C TInt SpdIconIndex(TInt aIndex) const;
303 * Returns type of the phone number.
305 IMPORT_C TInt NumberType(TInt aIndex) const;
307 * Build ver 2.6 . Deletes the old icon array.
309 IMPORT_C void DeleteIconArray();
311 * Build ver 2.6 . Reloads the new skin icons
313 IMPORT_C void ReloadIconArray();
315 IMPORT_C TInt VoiceMailType();
317 * Returns last error.
319 IMPORT_C TInt GetSpdCtrlLastError();
321 * Internal rutine to check if pop up has to be shown
322 * to enable the One-Key-Dialling setting.
323 * @return bool value of one key calling status on or off.
325 IMPORT_C TBool CheckingIfPopUpNeeded();
329 * Internal rutine to check if pop up has to be shown
330 * to enable the One-Key-Dialling setting.
331 * @return bool value of one key calling status on or off.
333 TBool CheckingIfPopUpNeededL();
336 * Build ver 2.6 . Reloads the new skin icons
338 void ReloadIconArrayL();
342 * Creates a grid itemArray.
343 * Note: It calls, when using a grid except SDM.
345 * @param aGrid the grid to set up
346 * @param aUpdate updates in an event.
348 TBool CreateDataL(const CAknGrid& aGrid);
351 * Thumbnail's shadow is drawn.
353 * @param aGc window gc
355 void DrawShadow(CWindowGc& aGc) const;
357 private: // Functions from base classes
358 // from MpblThumbnailOperation
360 * Called when thumbnail loading is completed.
362 * @param aOperation the completed operation.
363 * @param aBitmap The loaded bitmap. Callee is responsible of
366 void PbkThumbnailGetComplete(MPbkThumbnailOperation& aOperation,
367 CFbsBitmap* aBitmap);
370 * Called if the thumbnail loading fails.
372 * @param aOperation the failed operation.
373 * @param aError error code of the failure.
375 void PbkThumbnailGetFailed
376 (MPbkThumbnailOperation& aOperation, TInt aError);
379 * Passes skin information when needed.
381 TTypeUid::Ptr MopSupplyObject(TTypeUid aId);
386 * Called when thumbnail loading is completed.
388 * @param aOperation the completed operation.
389 * @param aBitmap The loaded bitmap. Callee is responsible of
392 void PbkThumbnailGetCompleteL(MPbkThumbnailOperation& aOperation,
393 CFbsBitmap* aBitmap);
395 private: // from CCoeControl
399 void Draw(const TRect& aRect) const;
402 * Set size for the skin background context.
408 * From MContactDbObserver, Handles an event of type aEventType.
410 void HandleDatabaseEventL(TContactDbObserverEvent aEvent);
412 private: // functions
419 * Index data are initialized.
421 void InitIndexDataL();
424 * Updates data set to match index of the owned index data array.
426 TBool UpdateIndexDataL(TInt aIndex);
429 * Searches icon of grid array for a match.
431 * @param aId phone book icon id to match to.
432 * @return the matching index, -1 if not found.
434 TInt FindIconIndex(TInt aId) const;
437 * Returns the thumbnail type.
439 * @param aIndex a index of array.
441 TInt ThumbType(TInt aIndex) const;
444 * Returns the thumbnail size.
446 * @param aIndex a index of array.
448 TSize ThumbSize(TInt aIndex) const;
451 * Set phonebook contact itmes'id.
453 * @param aIndex a index of array.
454 * @param aCid phone book contact item's id.
456 void SetContactId(TInt aIndex, TContactItemId aCid); // not referenced...
459 * The position on the array that a grid uses from
460 * an item and a phone number is returned.
462 * @param aItem contacd item
463 * @param aDial phone number
465 TInt IconPositionL(const CPbkContactItem& aItem, TInt aDial, TInt& aFieldId);
468 * An icon array is created and set.
470 * @retunr if need loadthumbL ETrue
472 TInt SetIconArrayL(CArrayPtrFlat<CGulIcon>* aArray);
475 * Gets Item's descriptor for Grid.
477 * @param aIndex a index of array.
478 * @param aSdmData reference to the data currently used.
479 * @return a buffer containing the descriptor text.
481 HBufC* ItemDescriptorLC(TInt aIndex, const TSpdiaIndexData& aSdmData);
484 * Creates Item's descriptor for Grid.
486 * @param aSdmData reference to the data currently used.
487 * @returen a buffer containing the descriptor text.
489 HBufC* CreateItemDescriptorLC(const TSpdiaIndexData& aSdmData);
492 * A descriptor is added to a text.
494 * @param aSdmData reference to the data currently used.
495 * @param aText the text for storing
497 void AppendTextL(const TSpdiaIndexData& aSdmData, TPtr& aText);
500 * Searches contact item's fiels of this contact for a match.
502 * @param aItem contact item to search.
503 * @param aFieldId field id to search.
504 * @return first field matching aFieldId, NULL if none found.
506 TPbkContactItemField* FindFieldL(CPbkContactItem& aItem,
507 TPbkFieldId aFieldId);
510 * The descriptor for thumbnail is added.
512 * @param aSdmData reference to the data currently used.
514 * @param aFixedLocation
516 void AppendThumbnail(const TSpdiaIndexData& aSdmData,
518 TBool aFixedLocation);
521 * Returns the type from a size of thumbnail.
523 * @param aSize a thumbnail size
525 TInt ConvThumbType(const TSize& aSize) const;
528 * Operations to a CPbkThumbnailManager are set.
529 * Note: call GetThumbnailAsyncL().
531 void SetOperationsL();
534 * The data of items are added to an array.
538 void SetItemDataL(CDesCArray& aArray);
541 * Assigns the index data at aDial in the phone book's contact entry
546 void AssignDialL(TContactItemId aId, TInt aFieldIdx, TInt aDial);
549 * Checks if the Flash File System storage will fall below
550 * Critical Level. Warning will be displayed if sotrage
551 * is below Critical Level.
553 * @return ETrue Below critical level
555 TBool CheckSpaceBelowCriticalLevelL();
558 * Does it have a thumbnail operation object to match?
560 * @param aOperation a thumbnail operation object to match to.
561 * @return index of speeddial index data array.
563 TInt HasOperation(const MPbkThumbnailOperation& aOperation);
566 * A text array that a grid has is erased.
571 * Speeddial index data is set by the data of parameters.
573 * @param aIndex a index of array.
574 * @param aSdmData reference to the data currently used.
576 void SetIndexDataL(TInt aIndex, TSpdiaIndexData& aSdmData);
579 * Speeddial index data is changed by the data of parameters.
581 * @param aIndex a index of array.
582 * @param aSdmData reference to the data currently used.
584 void ChangeIndexDataL(TInt aIndex, const TSpdiaIndexData& aSdmData);
587 * Creates icon data for SDM control data by the data of parameters.
589 * @param aIndex a index of array.
590 * @param aSdmData reference to the data currently used.
591 * @param aSetUpdateThumb thumbnail load start parameter set in index data
593 TBool CreateIndexIconL(TInt aIndex, TSpdiaIndexData& aSdmData,
594 TBool aSetUpdateThumb);
598 //code added for build ver 2.6
599 void InitializeArray();
602 // The type of the caller application.
605 EGridUse, // SpeedDial
606 EGridUseAndUpdate, // PhoneBook
607 EGridNoUse // PhoneClient
609 CPbkContactEngine* iEngine; // owned by this
610 TBool iExEngine; // engine owned flags
613 TInt iSdmCount; // Grid cell count(Row * col)
615 CArrayFixFlat<TSpdiaIndexData>* iSdmArray; // owned by this
616 CArrayFixFlat<TAknLayoutRect>* iShadowLayout; // owned by this
618 CPbkContactChangeNotifier* iPbkNotifier; // owned by this
619 CPbkSingleItemFetchDlg* iPbkSingleItem; // owned by this
620 CAknQueryDialog* iQueryDialog; // owned by this
621 RPbkViewResourceFile* iPbkResourceFile; // owned by this
622 CSpdiaGridDlg* iGridDlg; // owned by this
624 /// Own: thumbnail manager
625 CPbkThumbnailManager* iManager;
626 /// Own: factory for scaling to Thumbnails
627 CPAlbImageFactory* iThumbFactory;
631 CArrayPtrFlat<CGulIcon>* iIconArray;
633 CAknsBasicBackgroundControlContext* iBgContext;
635 // Variable used to know if the popup dialog has to be shown
636 // according to the release.
637 TBool iBooleanVarForAddingDialogVariation;
639 //Code added for build ver 2.6.
640 RArray<TAknsItemID>*iDialSkinBmp;
641 RArray<TAknsItemID>*iSkinIcons;
643 RArray<TInt>*iIconsId;
644 RArray<TInt>*iIconsMask;
645 TAknLayoutRect icellLayout[KArraySize];
651 CAknQueryDialog* iSaveChangesDialog;
654 // Record the current index before swtich to Speeddial if needed.
659 TInt iIconsMaskCount;
662 #endif // SPDIACONTROL_H