epoc32/include/app/spdiacontrol.h
author William Roberts <williamr@symbian.org>
Wed, 31 Mar 2010 12:33:34 +0100
branchSymbian3
changeset 4 837f303aceeb
parent 2 2fe1408b6811
permissions -rw-r--r--
Current Symbian^3 public API header files (from PDK 3.0.h)
This is the epoc32/include tree with the "platform" subtrees removed, and
all but a selected few mbg and rsg files removed.
     1 /*
     2 * Copyright (c) 2002 - 2005 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 #ifndef SPDIACONTROL_H
    23 #define SPDIACONTROL_H
    24 
    25 // INCLUDES
    26 #include <coecntrl.h>
    27 #include <TPbkContactItemField.h>
    28 #include <aknutils.h>
    29 #include <MPbkContactDbObserver.h>
    30 #include <MPbkThumbnailOperationObservers.h>
    31 
    32 // FORWARD DECLARATIONS
    33 class CAknGrid;
    34 class CGulIcon;
    35 class CEikonEnv;
    36 class TSpdiaIndexData;
    37 class CPbkContactEngine;
    38 class RPbkViewResourceFile;
    39 class CEikStatusPane;
    40 class CPAlbImageData;
    41 class CSpdiaGridDlg;
    42 class CPbkContactChangeNotifier;
    43 class CPbkSingleItemFetchDlg;
    44 class CAknQueryDialog;
    45 
    46 class CPAlbImageFactory;
    47 class CPbkThumbnailManager;
    48 
    49 class CAknsBasicBackgroundControlContext;
    50 #include <AknsConstants.h>
    51 
    52 // CLASS DECLARATION
    53 
    54 /**
    55 *  A utility that provides services to both the Speeddial and PhoneBook
    56 *  applications for getting and setting speeddial number configuration.
    57 *
    58 *  @lib SpdCtrl.DLL
    59 *  @deprecated
    60 *  @since
    61 */
    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
    67     {
    68     public:     // SpdiaControl APIs
    69         /**
    70         * Creates a new instace of this class.
    71         */
    72         IMPORT_C static CSpdiaControl* NewL();
    73 
    74         /**
    75         * Creates a new instace of this class.
    76         *
    77         * @param aPbkEngine     reference of CPbkContactEngine.
    78         */
    79         IMPORT_C static CSpdiaControl* NewL(
    80                                 CPbkContactEngine& aPbkEngine);
    81 
    82         /**
    83         * Puts a query on the screen asking for '...Assign it now'.
    84         * When the user goes through, it will assign speed dial.
    85         *
    86         * @param aLocation      a location to assign speed dial.
    87         * @param aStatusPane    not used.
    88         * @reutn    ETrue if success.
    89         */
    90         IMPORT_C TBool AssignDialNumberL(TInt aLocation,
    91                             CEikStatusPane* aStatusPane = NULL);
    92 
    93         /**
    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().
    98         *
    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.
   102         */
   103         IMPORT_C TInt ExecuteLD(TContactItemId aId, TInt aFieldIdx);
   104 
   105         /**
   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.
   110         */
   111         IMPORT_C void Cancel();
   112 
   113         /**
   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.
   119         *
   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.
   124         */
   125         IMPORT_C TBool DialNumberL(TInt aLocation, TDes& aPhoneNumber,
   126                             CEikStatusPane* aStatusPane = NULL);
   127 
   128     private:  // Constructors
   129         /**
   130         * C++ default constructor.
   131         */
   132         CSpdiaControl();
   133 
   134         /**
   135         * C++ constructor.
   136         */
   137         CSpdiaControl(CPbkContactEngine* aPbkEngine);
   138         
   139         /**
   140         * Gets actual size of thumbnial to be drawn.
   141         * @return  size of thumbnail.
   142         */
   143         TSize GetThumbnailSize();
   144 
   145     public:  // Destructor
   146 
   147         /**
   148         * Destructor.
   149         */
   150         IMPORT_C virtual ~CSpdiaControl();
   151 
   152     public:     // New function
   153         /**
   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.
   157         *
   158         * @param aNumber    reference of phone number.
   159         * @retunr   EFalse if user cancel or failed.
   160         */
   161         IMPORT_C TBool VoiceMailL(TDes& aNumber);
   162 
   163         /**
   164         * Returns the owned Phone Book Engine.
   165         */
   166         IMPORT_C CPbkContactEngine* PbkEngine() const;
   167 
   168         /**
   169         * The value converted into the index of an array from
   170         * the location of speeddial is returned.
   171         *
   172         * @param aDial      a location of speed dial.
   173         * @return   the index of a speeddial index data, if not found -1
   174         */
   175         IMPORT_C TInt Index(TInt aDial) const;
   176 
   177         /**
   178         * The value converted into the the location of speeddial
   179         * from index of an array is returned.
   180         *
   181         * @param aIndex     a index of array.
   182         * @return   location of speed dial(1-9), if not found -1
   183         */
   184         IMPORT_C TInt Number(TInt aIndex) const;
   185 
   186         /**
   187         * Returns the phone book contact item's id.
   188         *
   189         * @param aIndex     a index of array.
   190         * @return   a contact item's id, if not found -1
   191         */
   192         IMPORT_C TContactItemId ContactId(TInt aIndex) const;
   193 
   194         /**
   195         * Returns the phone number of a speed dial contact.
   196         * Note: A character invalid as a phone number is removed.
   197         *
   198         * @param aDial      a location of speeddial.
   199         * @return   phone number
   200         */
   201         IMPORT_C const TDesC& PhoneDialNumber(TInt aDial) const;
   202 
   203         /**
   204         * Returns the phone number of a speed dial contact.
   205         * Note: left and right spaces are removed.
   206         *
   207         * @param aIndex     a index of array.
   208         */
   209         IMPORT_C const TDesC& PhoneNumber(TInt aIndex) const;
   210 
   211     public:   // SpeedDial internal API
   212         /**
   213         * Gets a title text from contact item's id.
   214         * Note:  calls CPbkContactItem::GetContactTitleOrNullL()
   215         *              or CPbkContactEngine::UnnamedTitle()
   216         *
   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.
   221         */
   222         IMPORT_C HBufC* ContactTitleL(TContactItemId aCid, TBool aUnnamed);
   223 
   224         /**
   225         * Returns the icon index of a grid array.
   226         *
   227         * @param aIndex     a index of array.
   228         */
   229         IMPORT_C TInt IconIndex(TInt aIndex) const;
   230 
   231         /**
   232         * Returns the thumbnail index of a grid array.
   233         *
   234         * @param aIndex     a index of array.
   235         */
   236         IMPORT_C TInt ThumbIndex(TInt aIndex) const;
   237 
   238         /**
   239         * Returns the array of icons
   240         */
   241         IMPORT_C CArrayPtr<CGulIcon>* IconArray() const;
   242 
   243         /**
   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
   246         *       will be set up.
   247         * Note: CreateDataL() is used if App to be used is except SD.
   248         *
   249         * @param aGrid      the grid to set up
   250         * @param aIndex     (TInt) if <-1, All values are set up.
   251         */
   252         IMPORT_C TBool CreateGridDataL(CAknGrid* aGrid, TBool aIndex);
   253 
   254         /**
   255         * Assigns the index data at the index in the phone book's contact entry.
   256         *
   257         * @param aIndex     a index of array.
   258         */
   259         IMPORT_C TBool AssignDialIndexL(TInt aIndex);
   260 
   261         /**
   262         * Removes a speed dial from the phone book's contact entry.
   263         *
   264         * @param aIndex         a index of array.
   265         * @param aConfirmation  when remove, confirm is displayed.
   266         * @reutn    ETrue if success
   267         */
   268         IMPORT_C TBool RemoveDialIndexL(TInt aIndex,
   269                             TBool aConfirmation = ETrue);
   270         /**
   271         * deprecated - do not use
   272         */
   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);
   279 
   280         /**
   281         * The position which a shadow draws is set up.
   282         *
   283         * @param aRect
   284         */
   285         IMPORT_C void SetLayout(const TRect& aRect);
   286 
   287         /**
   288         * deprecated - do not use
   289         */
   290         IMPORT_C TInt Size() const;
   291 
   292         /**
   293         * Returns the position of voice mail box
   294         */
   295         IMPORT_C TInt VMBoxPosition() const;
   296 
   297         /**
   298         * Returns the icon index of grid array.
   299         */
   300         IMPORT_C TInt SpdIconIndex(TInt aIndex) const;
   301 
   302         /**
   303         * Returns type of the phone number.
   304         */
   305         IMPORT_C TInt NumberType(TInt aIndex) const;
   306 		/**
   307         * Build ver 2.6 . Deletes the old icon array.
   308         */
   309 		IMPORT_C void DeleteIconArray();
   310 		/**
   311         * Build ver 2.6 .  Reloads the new skin icons
   312         */
   313 		IMPORT_C void ReloadIconArray();
   314 		
   315 		IMPORT_C TInt VoiceMailType();
   316 		/**
   317         * Returns last error.
   318         */
   319 		IMPORT_C TInt GetSpdCtrlLastError();
   320 		/**
   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.
   324         */
   325        IMPORT_C  TBool CheckingIfPopUpNeeded();
   326 		
   327 	private:
   328 		/**
   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.
   332         */
   333 		TBool CheckingIfPopUpNeededL();
   334 		
   335 		/**
   336         * Build ver 2.6 .  Reloads the new skin icons
   337         */
   338 		 void ReloadIconArrayL();
   339 		
   340     public:
   341         /**
   342         * Creates a grid itemArray.
   343         * Note: It calls, when using a grid except SDM.
   344         *
   345         * @param aGrid      the grid to set up
   346         * @param aUpdate    updates in an event.
   347         */
   348         TBool CreateDataL(const CAknGrid& aGrid);
   349 
   350         /**
   351         * Thumbnail's shadow is drawn.
   352         *
   353         * @param aGc    window gc
   354         */
   355         void DrawShadow(CWindowGc& aGc) const;
   356 
   357     private:    // Functions from base classes
   358         // from MpblThumbnailOperation
   359         /**
   360         * Called when thumbnail loading is completed.
   361         *
   362         * @param aOperation    the completed operation.
   363         * @param aBitmap       The loaded bitmap. Callee is responsible of
   364         *                      the bitmap.
   365         */
   366         void PbkThumbnailGetComplete(MPbkThumbnailOperation& aOperation,
   367                                      CFbsBitmap* aBitmap);
   368 
   369         /**
   370         * Called if the thumbnail loading fails.
   371         *
   372         * @param aOperation     the failed operation.
   373         * @param aError         error code of the failure.
   374         */
   375         void PbkThumbnailGetFailed
   376             (MPbkThumbnailOperation& aOperation, TInt aError);
   377 
   378         /**
   379         * Passes skin information when needed.
   380         **/
   381         TTypeUid::Ptr MopSupplyObject(TTypeUid aId);
   382 
   383     private:
   384     	 
   385         /**
   386         * Called when thumbnail loading is completed.
   387         *
   388         * @param aOperation    the completed operation.
   389         * @param aBitmap       The loaded bitmap. Callee is responsible of
   390         *                      the bitmap.
   391         */
   392     	 void PbkThumbnailGetCompleteL(MPbkThumbnailOperation& aOperation,
   393                                      CFbsBitmap* aBitmap);
   394 
   395     private:  // from CCoeControl
   396         /**
   397          * Draw this control
   398          */
   399         void Draw(const TRect& aRect) const;
   400 
   401         /**
   402          * Set size for the skin background context.
   403          */
   404         void SizeChanged();
   405 
   406     private:
   407         /**
   408         * From MContactDbObserver, Handles an event of type aEventType.
   409         */
   410         void HandleDatabaseEventL(TContactDbObserverEvent aEvent);
   411 
   412     private:    // functions
   413         /**
   414         * Constructor
   415         */
   416         void ConstructL();
   417 
   418         /**
   419         * Index data are initialized.
   420         */
   421         void InitIndexDataL();
   422 
   423         /**
   424         * Updates data set to match index of the owned index data array.
   425         */
   426         TBool UpdateIndexDataL(TInt aIndex);
   427 
   428         /**
   429         * Searches icon of grid array for a match.
   430         *
   431         * @param aId     phone book icon id to match to.
   432         * @return   the matching index, -1 if not found.
   433         */
   434         TInt FindIconIndex(TInt aId) const;
   435 
   436         /**
   437         * Returns the thumbnail type.
   438         *
   439         * @param aIndex     a index of array.
   440         */
   441         TInt ThumbType(TInt aIndex) const;
   442 
   443         /**
   444         * Returns the thumbnail size.
   445         *
   446         * @param aIndex     a index of array.
   447         */
   448         TSize ThumbSize(TInt aIndex) const;
   449 
   450         /**
   451         * Set phonebook contact itmes'id.
   452         *
   453         * @param aIndex     a index of array.
   454         * @param aCid       phone book contact item's id.
   455         */
   456         void SetContactId(TInt aIndex, TContactItemId aCid);  // not referenced...
   457 
   458         /**
   459         * The position on the array that a grid uses from
   460         * an item and a phone number is returned.
   461         *
   462         * @param aItem      contacd item
   463         * @param aDial      phone number
   464         */
   465         TInt IconPositionL(const CPbkContactItem& aItem, TInt aDial, TInt& aFieldId);
   466 
   467         /**
   468         * An icon array is created and set.
   469         *
   470         * @retunr   if need loadthumbL ETrue
   471         */
   472         TInt SetIconArrayL(CArrayPtrFlat<CGulIcon>* aArray);
   473 
   474         /**
   475         * Gets Item's descriptor for Grid.
   476         *
   477         * @param aIndex     a index of array.
   478         * @param aSdmData   reference to the data currently used.
   479         * @return   a buffer containing the descriptor text.
   480         */
   481         HBufC* ItemDescriptorLC(TInt aIndex, const TSpdiaIndexData& aSdmData);
   482 
   483         /**
   484         * Creates Item's descriptor for Grid.
   485         *
   486         * @param aSdmData   reference to the data currently used.
   487         * @returen  a buffer containing the descriptor text.
   488         */
   489         HBufC* CreateItemDescriptorLC(const TSpdiaIndexData& aSdmData);
   490 
   491         /**
   492         * A descriptor is added to a text.
   493         *
   494         * @param aSdmData   reference to the data currently used.
   495         * @param aText      the text for storing
   496         */
   497         void AppendTextL(const TSpdiaIndexData& aSdmData, TPtr& aText);
   498 
   499         /**
   500         * Searches contact item's fiels of this contact for a match.
   501         *
   502         * @param aItem      contact item to search.
   503         * @param aFieldId   field id to search.
   504         * @return   first field matching aFieldId, NULL if none found.
   505         */
   506         TPbkContactItemField* FindFieldL(CPbkContactItem& aItem,
   507                                     TPbkFieldId aFieldId);
   508 
   509         /**
   510         * The descriptor for thumbnail is added.
   511         *
   512         * @param aSdmData           reference to the data currently used.
   513         * @param aText
   514         * @param aFixedLocation
   515         */
   516         void AppendThumbnail(const TSpdiaIndexData& aSdmData,
   517                             TPtr& aText,
   518                             TBool aFixedLocation);
   519 
   520         /**
   521         * Returns the type from a size of thumbnail.
   522         *
   523         * @param aSize  a thumbnail size
   524         */
   525         TInt ConvThumbType(const TSize& aSize) const;
   526 
   527         /**
   528         * Operations to a CPbkThumbnailManager are set.
   529         * Note: call GetThumbnailAsyncL().
   530         */
   531         void SetOperationsL();
   532 
   533         /**
   534         * The data of items are added to an array.
   535         *
   536         * @param aArray
   537         */
   538         void SetItemDataL(CDesCArray& aArray);
   539 
   540         /**
   541         * Assigns the index data at aDial in the phone book's contact entry
   542         *
   543         * @param aId
   544         * @param aDial
   545         */
   546         void AssignDialL(TContactItemId aId, TInt aFieldIdx, TInt aDial);
   547 
   548         /**
   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.
   552         *
   553         * @return   ETrue   Below critical level
   554         */
   555         TBool CheckSpaceBelowCriticalLevelL();
   556 
   557         /**
   558         * Does it have a thumbnail operation object to match?
   559         *
   560         * @param aOperation     a thumbnail operation object to match to.
   561         * @return   index of speeddial index data array.
   562         */
   563         TInt HasOperation(const MPbkThumbnailOperation& aOperation);
   564 
   565         /**
   566         * A text array that a grid has is erased.
   567         */
   568         void ResetArray();
   569 
   570         /**
   571         * Speeddial index data is set by the data of parameters.
   572         *
   573         * @param aIndex     a index of array.
   574         * @param aSdmData   reference to the data currently used.
   575         */
   576         void SetIndexDataL(TInt aIndex, TSpdiaIndexData& aSdmData);
   577 
   578         /**
   579         * Speeddial index data is changed by the data of parameters.
   580         *
   581         * @param aIndex     a index of array.
   582         * @param aSdmData   reference to the data currently used.
   583         */
   584         void ChangeIndexDataL(TInt aIndex, const TSpdiaIndexData& aSdmData);
   585 
   586         /**
   587         * Creates icon data for SDM control data by the data of parameters.
   588         *
   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
   592         */
   593         TBool CreateIndexIconL(TInt aIndex, TSpdiaIndexData& aSdmData,
   594                             TBool aSetUpdateThumb);
   595 
   596 	    
   597 		private:
   598 			//code added for build ver 2.6
   599 			void InitializeArray();
   600 
   601     private:    // Data
   602         // The type of the caller application.
   603         enum TGridUse
   604             {
   605             EGridUse,               // SpeedDial
   606             EGridUseAndUpdate,      // PhoneBook
   607             EGridNoUse              // PhoneClient
   608             };
   609         CPbkContactEngine* iEngine;                 // owned by this
   610         TBool iExEngine;                            // engine owned flags
   611         TGridUse iGridUsed;
   612 
   613         TInt iSdmCount;                             // Grid cell count(Row * col)
   614 
   615         CArrayFixFlat<TSpdiaIndexData>* iSdmArray;  // owned by this
   616         CArrayFixFlat<TAknLayoutRect>* iShadowLayout;     // owned by this
   617 
   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
   623 
   624         /// Own: thumbnail manager
   625         CPbkThumbnailManager* iManager;
   626         /// Own: factory for scaling to Thumbnails
   627         CPAlbImageFactory* iThumbFactory;
   628 
   629         CAknGrid* iGrid;
   630         TInt    iFileOffset;
   631         CArrayPtrFlat<CGulIcon>* iIconArray;
   632 
   633         CAknsBasicBackgroundControlContext* iBgContext;
   634 	
   635         // Variable used to know if the popup dialog has to be shown
   636         // according to the release.
   637         TBool iBooleanVarForAddingDialogVariation;
   638 
   639         //Code added for build ver 2.6.
   640         RArray<TAknsItemID>*iDialSkinBmp;
   641         RArray<TAknsItemID>*iSkinIcons;
   642         RArray<TInt>*iIcons;
   643         RArray<TInt>*iIconsId;
   644         RArray<TInt>*iIconsMask;
   645         TAknLayoutRect icellLayout[KArraySize];
   646         TBuf<254> iBmpPath;
   647         TBuf<254> iRscPath;
   648         TInt iType;
   649         TInt iError;
   650         TBool iPopupDialog;
   651         CAknQueryDialog* iSaveChangesDialog;
   652         TBool iSaveDlg;
   653 
   654         // Record the current index before swtich to Speeddial if needed. 
   655         TInt iFocusedGrid;   
   656         
   657         TInt iIconsCount;
   658         TInt iIconsIdCount;
   659         TInt iIconsMaskCount;
   660     };
   661 
   662 #endif // SPDIACONTROL_H
   663 
   664 // End of File
   665