speechsrv_plat/vas_api/inc/vascvpbkhandler.h
changeset 13 57b735022c18
parent 1 b13cd05eeb2f
equal deleted inserted replaced
1:b13cd05eeb2f 13:57b735022c18
     1 /*
       
     2 * Copyright (c) 2006 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:  Phonebook handler that uses Virtual phonebook to access phonebook data
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 #ifndef VASCVPBKHANDLER_H
       
    20 #define VASCVPBKHANDLER_H
       
    21 
       
    22 // INCLUDES
       
    23 #include <e32base.h>
       
    24 
       
    25 #include <cntdef.h> 
       
    26 
       
    27 #include <vpbkfieldtype.hrh>
       
    28 
       
    29 #include <mvpbkcontactstorelistobserver.h>
       
    30 #include <mvpbksinglecontactoperationobserver.h>
       
    31 #include <mvpbkcontactobserver.h>
       
    32 #include <mvpbkcontactattributemanager.h>
       
    33 #include <mvpbkbatchoperationobserver.h> 
       
    34 #include <mvpbkcontactviewobserver.h> 
       
    35 
       
    36 #include <vasmbasepbkhandler.h>
       
    37 #include <vasmcontactobserver.h>
       
    38 
       
    39 // CONSTANTS
       
    40 
       
    41 // DATA TYPES
       
    42 
       
    43 // FORWARD DECLARATIONS
       
    44 class CVPbkContactManager;
       
    45 class CVPbkContactIdConverter;
       
    46 class MVPbkContactOperationBase;
       
    47 class MVPbkStoreContact;
       
    48 class MVPbkStoreContactField;
       
    49 class MNssTag;
       
    50 class MVasContactObserver;
       
    51 
       
    52 // CLASS DECLARATION
       
    53 
       
    54 /**
       
    55 * Phonebook handler that uses Virtual phonebook to access phonebook data
       
    56 *
       
    57 * @since 3.2
       
    58 */
       
    59 class CVasVPbkHandler : public CBase,
       
    60                         public MVasBasePbkHandler,
       
    61                         public MVPbkContactStoreListObserver,
       
    62                         public MVPbkSingleContactOperationObserver,
       
    63                         public MVPbkContactObserver,
       
    64                         public MVPbkSetAttributeObserver,
       
    65                         public MVPbkBatchOperationObserver,
       
    66                         public MVPbkContactViewObserver
       
    67     {
       
    68     public:  // Constructors and destructor
       
    69    
       
    70         /**
       
    71         * Two-phased constructor.
       
    72         *
       
    73         * @since 3.2
       
    74         */
       
    75         IMPORT_C static CVasVPbkHandler* NewL();
       
    76         
       
    77         /**
       
    78         * Destructor.
       
    79         *
       
    80         * @since 3.2
       
    81         */
       
    82         IMPORT_C virtual ~CVasVPbkHandler();
       
    83 
       
    84     public: // New functions
       
    85 
       
    86         /**
       
    87         * Opens phonebook connection and contact stores
       
    88         *
       
    89         * @since 3.2
       
    90         */
       
    91         IMPORT_C void InitializeL();
       
    92         
       
    93         /**
       
    94         * Creates the contact change notifier and sets observer as a listener
       
    95         *
       
    96         * @since 3.2
       
    97         * @param aObserver Contact change listener
       
    98         */
       
    99         IMPORT_C void CreateContactObserverL( MVasContactObserver* aObserver );
       
   100         
       
   101         /**
       
   102         * Compresses database
       
   103         *
       
   104         * @since 3.2
       
   105         */
       
   106         IMPORT_C void CompressL();
       
   107         
       
   108         /**
       
   109         * Returns all contact ids from database
       
   110         *
       
   111         * @since 3.2
       
   112         * @return Contact id array
       
   113         */
       
   114         IMPORT_C CContactIdArray* ContactIdArrayLC();
       
   115         
       
   116         
       
   117         /**
       
   118         * Finds a contact from phonebook
       
   119         *
       
   120         * @since 3.2
       
   121         * @param aTag Tag that is used as a search parameter
       
   122         */
       
   123         IMPORT_C void FindContactL( MNssTag* aTag );
       
   124         
       
   125         /**
       
   126         * Finds a contact from phonebook
       
   127         *
       
   128         * @since 3.2
       
   129         * @param aContactId Id of the contact that should be found
       
   130         * @param aReadOnly ETrue if contact will not be edited else EFalse
       
   131         */
       
   132         IMPORT_C void FindContactL( TInt32 aContactId, TBool aReadOnly );
       
   133         
       
   134         /**
       
   135         * Closes contact with or without saving changes
       
   136         *
       
   137         * @since 3.2
       
   138         * @param aSaveChanges ETrue to save changes else EFalse
       
   139         */
       
   140         IMPORT_C void CloseContactL( TBool aSaveChanges );
       
   141         
       
   142         /**
       
   143         * Finds a field from contact
       
   144         *
       
   145         * @since 3.2
       
   146         * @param aTag Tag that is used as a search parameter
       
   147         */
       
   148         IMPORT_C void FindFieldL( MNssTag* aTag );
       
   149         
       
   150         /**
       
   151         * Finds a field from contact
       
   152         *
       
   153         * @since 3.2
       
   154         * @param aFieldId Field id that is used as a search parameter
       
   155         */
       
   156         IMPORT_C void FindFieldL( TInt aFieldId );
       
   157         
       
   158         /**
       
   159         * Finds a field from contact
       
   160         *
       
   161         * @since 3.2
       
   162         * @param aTag Tag that is used as a search parameter
       
   163         */
       
   164         IMPORT_C void FindContactFieldL( MNssTag* aTag );
       
   165         
       
   166         /**
       
   167         * Searches for a default field of a given type
       
   168         *
       
   169         * @param aCommandType Command type that is used as a select parameter
       
   170         *                     Must be one of TVasExtensionCommand types
       
   171         */
       
   172         IMPORT_C void FindDefaultContactFieldL( TInt aCommandType );
       
   173         
       
   174         /**
       
   175         * Changes current field's voice tag field status
       
   176         *
       
   177         * @since 3.2
       
   178         * @param aSet If ETrue field is set else field is removed
       
   179         */   
       
   180         IMPORT_C void ChangeVoiceTagFieldL( TBool aSet );
       
   181         
       
   182         /**
       
   183         * Returns the field label
       
   184         *
       
   185         * @since 3.2
       
   186         * @return Field label
       
   187         */
       
   188         IMPORT_C TPtrC LabelL();
       
   189         
       
   190         /**
       
   191         * Returns the field text
       
   192         *
       
   193         * @since 3.2
       
   194         * @return Field text
       
   195         */
       
   196         IMPORT_C TPtrC TextL();
       
   197         
       
   198         /**
       
   199         * Returns the field type
       
   200         *
       
   201         * @since 3.2
       
   202         * @return Field type
       
   203         */
       
   204         IMPORT_C TFieldType FieldTypeL();
       
   205         
       
   206         /**
       
   207         * Returns the field id
       
   208         *
       
   209         * @since 3.2
       
   210         * @return Field id
       
   211         */
       
   212         IMPORT_C TInt FieldIdL();
       
   213         
       
   214         /**
       
   215         * Returns information if current field is empty
       
   216         *
       
   217         * @since 3.2
       
   218         * @return ETrue if field is empty else EFalse
       
   219         */
       
   220         IMPORT_C TBool IsFieldEmptyL();
       
   221 
       
   222     public: // Functions from base classes
       
   223 
       
   224         /**
       
   225         * From MVPbkContactStoreListObserver
       
   226         * @see MVPbkContactStoreListObserver
       
   227         */
       
   228         void StoreReady( MVPbkContactStore& aContactStore );
       
   229 
       
   230         /**
       
   231         * From MVPbkContactStoreListObserver
       
   232         * @see MVPbkContactStoreListObserver
       
   233         */
       
   234         void StoreUnavailable( MVPbkContactStore& aContactStore, TInt aReason );
       
   235 
       
   236         /**
       
   237         * From MVPbkContactStoreListObserver
       
   238         * @see MVPbkContactStoreListObserver
       
   239         */
       
   240         void HandleStoreEventL( MVPbkContactStore& aContactStore,
       
   241                                 TVPbkContactStoreEvent aStoreEvent );
       
   242         
       
   243         /**
       
   244         * From MVPbkContactStoreListObserver
       
   245         * @see MVPbkContactStoreListObserver
       
   246         */
       
   247         void OpenComplete();
       
   248         
       
   249         /**
       
   250         * From MVPbkSingleContactOperationObserver
       
   251         * @see MVPbkSingleContactOperationObserver
       
   252         */
       
   253         void VPbkSingleContactOperationComplete( MVPbkContactOperationBase& aOperation,
       
   254                                                  MVPbkStoreContact* aContact );
       
   255                                                  
       
   256         /**
       
   257         * From MVPbkSingleContactOperationObserver
       
   258         * @see MVPbkSingleContactOperationObserver
       
   259         */                                         
       
   260         void VPbkSingleContactOperationFailed( MVPbkContactOperationBase& aOperation,
       
   261                                                TInt aError );
       
   262         
       
   263         /**
       
   264         * From MVPbkContactObserver
       
   265         * @see MVPbkContactObserver
       
   266         */                                         
       
   267         void ContactOperationCompleted( TContactOpResult aResult );
       
   268 
       
   269         /**
       
   270         * From MVPbkContactObserver
       
   271         * @see MVPbkContactObserver
       
   272         */  
       
   273         void ContactOperationFailed( TContactOp aOpCode, TInt aErrorCode, TBool aErrorNotified );
       
   274 
       
   275         /**
       
   276         * From MVPbkSetAttributeObserver
       
   277         * @see MVPbkSetAttributeObserver
       
   278         */                                       
       
   279         void AttributeOperationComplete( MVPbkContactOperationBase& aOperation ); 
       
   280         
       
   281         /**
       
   282         * From MVPbkSetAttributeObserver
       
   283         * @see MVPbkSetAttributeObserver
       
   284         */
       
   285         void AttributeOperationFailed( MVPbkContactOperationBase& aOperation, TInt aError );
       
   286         
       
   287         /**
       
   288         * From MVPbkBatchOperationObserver
       
   289         * @see MVPbkBatchOperationObserver
       
   290         */
       
   291         void StepComplete( MVPbkContactOperationBase& aOperation, TInt aStepSize );
       
   292         
       
   293         /**
       
   294         * From MVPbkBatchOperationObserver
       
   295         * @see MVPbkBatchOperationObserver
       
   296         */
       
   297         TBool StepFailed( MVPbkContactOperationBase& aOperation, TInt aStepSize, TInt aError );
       
   298         
       
   299         /**
       
   300         * From MVPbkBatchOperationObserver
       
   301         * @see MVPbkBatchOperationObserver
       
   302         */
       
   303         void OperationComplete( MVPbkContactOperationBase& aOperation );
       
   304         
       
   305         /**
       
   306         * From MVPbkContactViewObserver
       
   307         * @see MVPbkContactViewObserver
       
   308         */
       
   309         void ContactViewReady( MVPbkContactViewBase& aView );
       
   310         
       
   311         /**
       
   312         * From MVPbkContactViewObserver
       
   313         * @see MVPbkContactViewObserver
       
   314         */
       
   315         void ContactViewUnavailable( MVPbkContactViewBase& aView );
       
   316         
       
   317         /**
       
   318         * From MVPbkContactViewObserver
       
   319         * @see MVPbkContactViewObserver
       
   320         */
       
   321         void ContactAddedToView( MVPbkContactViewBase& aView, TInt aIndex, const MVPbkContactLink& aContactLink );
       
   322         
       
   323         /**
       
   324         * From MVPbkContactViewObserver
       
   325         * @see MVPbkContactViewObserver
       
   326         */
       
   327         void ContactRemovedFromView( MVPbkContactViewBase& aView, TInt aIndex, const MVPbkContactLink& aContactLink );
       
   328         
       
   329         /**
       
   330         * From MVPbkContactViewObserver
       
   331         * @see MVPbkContactViewObserver
       
   332         */
       
   333         void ContactViewError( MVPbkContactViewBase& aView, TInt aError, TBool aErrorNotified );
       
   334                 
       
   335     private:  // New functions
       
   336 
       
   337         /**
       
   338         * C++ default constructor.
       
   339         */
       
   340         CVasVPbkHandler();
       
   341 
       
   342         /**
       
   343         * By default constructor is private.
       
   344         */
       
   345         void ConstructL();
       
   346         
       
   347         /**
       
   348         * Selects default field type for the given tag
       
   349         *
       
   350         * @param aCommandType Command type that is used as a select parameter
       
   351         *                     Must be one of TVasExtensionCommand types
       
   352         * @return Default field type
       
   353         */
       
   354         TVPbkDefaultType SelectDefaultType( TInt aCommandType );
       
   355         
       
   356         /**
       
   357         * Checks if given field should be used
       
   358         *
       
   359         * @param aField Field that is checked
       
   360         * @param aCommandType Command type that is used as a select parameter
       
   361         *                     Must be one of TVasExtensionCommand types
       
   362         * @return ETrue if field is accepted else EFalse
       
   363         */
       
   364         TBool AcceptDefaultField( MVPbkStoreContactField& aField, TInt aCommandType );
       
   365         
       
   366         /**
       
   367         * Converts field id to old phonebook id
       
   368         *
       
   369         * @param aField Field to be converted
       
   370         * @return Old phonebook field id
       
   371         */
       
   372         TInt ConvertFieldId( MVPbkStoreContactField& aField );
       
   373         
       
   374         /**
       
   375         * Converts contact event type
       
   376         *
       
   377         * @param aEvent Event to be converted
       
   378         * @return Corresponding vas contact event
       
   379         */
       
   380         TVasContactEvent ConvertEvent( const TVPbkContactStoreEvent& aEvent );
       
   381         
       
   382         /**
       
   383         * Gets the priority of the given field
       
   384         *
       
   385         * @param aField Field which priority is returned
       
   386         * @return Field priority
       
   387         */
       
   388         TInt FieldPriority( MVPbkStoreContactField& aField );
       
   389 
       
   390     private:    // Data
       
   391 
       
   392         // Contact manager
       
   393         CVPbkContactManager*        iContactManager;
       
   394         
       
   395         // Contact id converter
       
   396         CVPbkContactIdConverter*    iConverter;
       
   397         
       
   398         // Current operation
       
   399         MVPbkContactOperationBase*  iOperation;
       
   400         
       
   401         // Found contact
       
   402         MVPbkStoreContact*          iContact;
       
   403         
       
   404         // Found field
       
   405         MVPbkStoreContactField*     iField;
       
   406         
       
   407         // Contact change observer
       
   408         MVasContactObserver*        iObserver;
       
   409         
       
   410         // For waiting callbacks
       
   411         CActiveSchedulerWait        iWait;
       
   412         
       
   413         // Possible error code
       
   414         TInt                        iError;
       
   415         
       
   416         // Is mms supported or not
       
   417         TBool                       iMMSSupported;
       
   418 
       
   419         };
       
   420 
       
   421 #endif      // VASCVPBKHANDLER_H
       
   422             
       
   423 // End of File