voiceui/pbkinfoviewimpl/inc/pbkinfoviewsindhandler.h
branchRCL_3
changeset 19 e36f3802f733
equal deleted inserted replaced
18:cad71a31b7fc 19:e36f3802f733
       
     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:  Used to fetch voice tags from vas db
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 #ifndef PBKINFOVIEWSINDHANDLER_H
       
    20 #define PBKINFOVIEWSINDHANDLER_H
       
    21 
       
    22 // INCLUDES
       
    23 #include <nssvasapi.h>
       
    24 #include <nssttsutility.h>
       
    25 
       
    26 // FORWARD DECLARATIONS
       
    27 class CPbkContactEngine;
       
    28 class CPbkContactItem;
       
    29 class TPbkContactItemField;
       
    30 class MVasBasePbkHandler;
       
    31 
       
    32 // CONSTANTS
       
    33 const TInt KMaxSegments = 6;
       
    34 
       
    35 // CLASS DECLARATION
       
    36 
       
    37 /**
       
    38  * Extension for Phonebook engine.
       
    39  */
       
    40 class CPbkInfoViewSindHandler : public CBase,
       
    41                                 public MNssGetContextClient,
       
    42                                 public MNssGetTagClient,
       
    43                                 public MNssPlayEventHandler,
       
    44                                 public MTtsClientUtilityObserver
       
    45     {
       
    46     public: // Constructor and destructor
       
    47         /**
       
    48          * Creates a new instance of CPbkSindHandler.
       
    49          * @param aContactId Contact id for the contact whose voice tags are to
       
    50          *        be fetched from vas db.
       
    51          */
       
    52         static CPbkInfoViewSindHandler* NewL( TInt aContactId );
       
    53         /**
       
    54          * Creates an instance that doesn't require CCoeEnv for STIF testing
       
    55          * purposes.
       
    56          * @param aContactId Contact id for the contact whose voice tags are to
       
    57          *        be fetched from vas db.
       
    58          */
       
    59         static CPbkInfoViewSindHandler* TestNewL( TInt aContactId );
       
    60         /**
       
    61          * Destructor.
       
    62          */
       
    63         ~CPbkInfoViewSindHandler();
       
    64         /**
       
    65          * Returns the number of voice tags for the contact.
       
    66          * @return TInt voice tag count.
       
    67          */
       
    68          TInt VoiceTagCount();
       
    69          /**
       
    70          * Returns a voice tag.
       
    71          * @param aIndex index for the voice tag.
       
    72          *        0 <= aIndex <= VoiceTagCount() - 1
       
    73          * @return TDesC& the voice tag
       
    74          */
       
    75          const TDesC& VoiceTagL( TInt aIndex );
       
    76          
       
    77          /**
       
    78          * Returns the label associated with a voice tag (mobile, home, etc).
       
    79          * @param aIndex index for the voice tag.
       
    80          *        0 <= aIndex <= VoiceTagCount() - 1
       
    81          * @return HBufC* the label 
       
    82          */
       
    83          HBufC* VoiceTagLabelLC( TInt aIndex );
       
    84          /**
       
    85          * Returns the phone number, e-mail address, etc. associated with a
       
    86          * voice tag.
       
    87          * @param aIndex index for the voice tag.
       
    88          *        0 <= aIndex <= VoiceTagCount() - 1
       
    89          * @return TPtrC the value
       
    90          */
       
    91          TPtrC VoiceTagValueL( TInt aIndex );
       
    92          /**
       
    93          * Returns the popup text associated with a voice tag.
       
    94          * @param aIndex index for the voice tag.
       
    95          *        0 <= aIndex <= VoiceTagCount() - 1
       
    96          * @return TDesC& popup text
       
    97          */
       
    98          TDesC& PopupTextL( TInt aIndex );
       
    99          /**
       
   100          * Plays a voice tag.
       
   101          * @param aIndex index for the voice tag.
       
   102          *        0 <= aIndex <= VoiceTagCount() - 1
       
   103          */
       
   104          void PlayVoiceCommandL( TInt aIndex );
       
   105          /**
       
   106          * Cancels voice tag playback.
       
   107          * @return TBool boolean value
       
   108          */
       
   109          void CancelPlaybackL();
       
   110          /**
       
   111          * Is voice tag playing ongoing.
       
   112          * @return TBool boolean value
       
   113          */
       
   114          TBool IsPlaying();
       
   115          /**
       
   116          * Returns an icon id for the contact field the voice tag is associated
       
   117          * with.
       
   118          * @param aIndex index for the voice tag.
       
   119          *        0 <= aIndex <= VoiceTagCount() - 1
       
   120          * @return TInt the icon id
       
   121          */
       
   122          TInt IconIdL( TInt aIndex );
       
   123 		 
       
   124          /**
       
   125          * Returns an field id that the voice tage is associated
       
   126          * @param aIndex index for the voice tag.
       
   127          *        0 <= aIndex <= VoiceTagCount() - 1
       
   128 		 * @return TInt field id
       
   129          */
       
   130          TInt FieldIdL( TInt aIndex );
       
   131          
       
   132          /**
       
   133          * Returns a tag label that the voice tage is associated
       
   134          * @param aIndex index for the voice tag.
       
   135          *        0 <= aIndex <= VoiceTagCount() - 1
       
   136          * @return TPtrC the tag label
       
   137          */
       
   138          TPtrC LabelL( TInt aIndex );
       
   139          
       
   140          /**
       
   141          * Calls CompareL and catches possible leaves
       
   142          */
       
   143          static TInt Compare( const MNssTag& aTag1, const MNssTag& aTag2 );
       
   144          
       
   145          /**
       
   146          * Compares two voice tags and decides which one should be displayed
       
   147          * first in info view list. Used in the sorting of voice tags.
       
   148          * @param aTag1 A voice tag
       
   149          * @param aTag2 A voice tag
       
   150          * @return TInt -1 if aTag1 should be displayed first, 1 if aTag2 should be 
       
   151                    displayed first, 0 otherwise.
       
   152          */
       
   153          static TInt CompareL( const MNssTag& aTag1, const MNssTag& aTag2 );
       
   154         
       
   155     public: // From MNssGetContextClient
       
   156     
       
   157         void GetContextCompleted( MNssContext* aContext, TInt aErrorCode );
       
   158         void GetContextListCompleted( MNssContextListArray* aContextList,
       
   159                                       TInt aErrorCode );
       
   160     
       
   161     public: // From MNssGetTagClient
       
   162     
       
   163         void GetTagListCompleted( MNssTagListArray* aTagList, TInt aErrorCode );
       
   164         
       
   165     public: // From MNssPlayEventHandler
       
   166         void HandlePlayComplete( TNssPlayResult aErrorCode );
       
   167         // Not implemented
       
   168         void HandlePlayStarted( TTimeIntervalMicroSeconds32 /*aDuration*/ ) {};
       
   169 
       
   170     public: // From MTtsClientUtilityObserver
       
   171         // Not implemented
       
   172         void MapcCustomCommandEvent( TInt /*aEvent*/, TInt /*aError*/ ) {};
       
   173         
       
   174         void MapcInitComplete(TInt /*aError*/, const TTimeIntervalMicroSeconds& /*aDuration*/) {};
       
   175         
       
   176         void MapcPlayComplete(TInt /*aError*/) {};
       
   177         
       
   178     private: // own methods:
       
   179         /**
       
   180         * Initialization.
       
   181         * @param aContactId Contact id for the contact whose voice tags are
       
   182         *         fetched from vas db.
       
   183         */
       
   184         void InitializeL( TInt aContactId );
       
   185         
       
   186         /**
       
   187         * Fetches voice tag list from vas db.
       
   188         * @param aContactId Contact id for the contact whose voice tags are
       
   189         *         fetched from vas db.
       
   190         */
       
   191         void CreateVoiceTagListL( TInt aContactId );
       
   192         
       
   193         /**
       
   194         * Creates an array for popups in info view list.
       
   195         */
       
   196         void CreatePopupArrayL();
       
   197         
       
   198         /**
       
   199         * Tries to find default contact item field.
       
   200         * @param aContactItem A contact item
       
   201         * @param aFieldId A field to search
       
   202         * @return TPbkContactItemField* Default field if found, otherwise NULL
       
   203         */
       
   204         static TPbkContactItemField* FindDefaultField( CPbkContactItem* aContactItem,
       
   205                                                        TInt aFieldId );
       
   206 
       
   207     private: // Implementation
       
   208         CPbkInfoViewSindHandler();
       
   209         void ConstructL( TInt aContactId );
       
   210         void TestConstructL( TInt aContactId );
       
   211         
       
   212     private: // Data
       
   213        
       
   214         // Vas databse manager
       
   215         CNssVASDBMgr* iVasDbManager;        
       
   216         // Nss context
       
   217         MNssContext* iContext;
       
   218         // Scheduler wait object
       
   219         CActiveSchedulerWait* iWait;
       
   220         // Context manager, does not take ownership
       
   221         MNssContextMgr* iContextManager;        
       
   222         // Tag manager, does not take ownership
       
   223         MNssTagMgr* iTagManager;
       
   224         // Error code received from observer call-back methods.
       
   225         TInt iErr;
       
   226         // Voice tag array
       
   227         RPointerArray<MNssTag> iTagArray;
       
   228         // Phonebook contact item
       
   229         CPbkContactItem* iPbkContactItem;
       
   230         // Phonebook engine
       
   231         CPbkContactEngine* iPbkEngine;
       
   232         // Phonebook contact item field for phone numbers etc, and icons.
       
   233         // Does not take ownership
       
   234         TPbkContactItemField* iPbkContactItemField;
       
   235         // Array for popups in info view list.
       
   236         RPointerArray<TDesC> iPopupArray;
       
   237         // Current voice tag form iTagArray being played
       
   238         TInt iPlaybackIndex;
       
   239          // For getting the phone numbers etc used in voice tags
       
   240         MVasBasePbkHandler* iPbkHandler;
       
   241         // TTS Utility
       
   242         CTtsUtility* iTts;
       
   243 
       
   244         //static TInt iContactId;
       
   245     };
       
   246 
       
   247 #endif  // __PBINFOVIEWKSINDHANDLER_H__
       
   248 
       
   249 // End of file