epoc32/include/app/CVPbkContactManager.h
author William Roberts <williamr@symbian.org>
Wed, 31 Mar 2010 12:33:34 +0100
branchSymbian3
changeset 4 837f303aceeb
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.
williamr@4
     1
/*
williamr@4
     2
* Copyright (c) 2002-2007 Nokia Corporation and/or its subsidiary(-ies).
williamr@4
     3
* All rights reserved.
williamr@4
     4
* This component and the accompanying materials are made available
williamr@4
     5
* under the terms of "Eclipse Public License v1.0"
williamr@4
     6
* which accompanies this distribution, and is available
williamr@4
     7
* at the URL "http://www.eclipse.org/legal/epl-v10.html".
williamr@4
     8
*
williamr@4
     9
* Initial Contributors:
williamr@4
    10
* Nokia Corporation - initial contribution.
williamr@4
    11
*
williamr@4
    12
* Contributors:
williamr@4
    13
*
williamr@4
    14
* Description:  The contact manager for accessing different stores.
williamr@4
    15
*                Initialization: a client gives an array of store URIs (Virtual
williamr@4
    16
*                offers some URIs, see VPbkStoreUriLiterals.h) when creating
williamr@4
    17
*                a manager. The client uses store list to open all stores.
williamr@4
    18
*
williamr@4
    19
*/
williamr@4
    20
williamr@4
    21
williamr@4
    22
#ifndef CVPBKCONTACTMANAGER_H
williamr@4
    23
#define CVPBKCONTACTMANAGER_H
williamr@4
    24
williamr@4
    25
williamr@4
    26
// INCLUDES
williamr@4
    27
#include <e32base.h>
williamr@4
    28
#include <f32file.h>
williamr@4
    29
#include <bamdesca.h>
williamr@4
    30
#include <BADESCA.H> 
williamr@4
    31
williamr@4
    32
// FORWARD DECLARATIONS
williamr@4
    33
class MVPbkFieldTypeList;
williamr@4
    34
class MVPbkContactManagerObserver;
williamr@4
    35
class MVPbkContactStoreList;
williamr@4
    36
class CVPbkContactStoreList;
williamr@4
    37
class MVPbkStoreContact;
williamr@4
    38
class MVPbkContactLink;
williamr@4
    39
class MVPbkContactOperationBase;
williamr@4
    40
class MVPbkSingleContactOperationObserver;
williamr@4
    41
class MVPbkBatchOperationObserver;
williamr@4
    42
class MVPbkContactFindObserver;
williamr@4
    43
class MVPbkContactViewBase;
williamr@4
    44
class CVPbkContactViewDefinition;
williamr@4
    45
class MVPbkContactStore;
williamr@4
    46
class TVPbkContactStoreUriPtr;
williamr@4
    47
class CVPbkContactStoreDomainList;
williamr@4
    48
class MVPbkContactViewObserver;
williamr@4
    49
class MVPbkContactLinkArray;
williamr@4
    50
class MVPbkContactAttributeManager;
williamr@4
    51
class CVPbkContactStoreUriArray;
williamr@4
    52
class MVPbkContactFindFromStoresObserver;
williamr@4
    53
williamr@4
    54
// CLASS DECLARATIONS
williamr@4
    55
williamr@4
    56
/**
williamr@4
    57
 * Virtual Phonebook Contact Manager. Contact Manager is the root access point
williamr@4
    58
 * to Virtual Phonebook engine functionality. The client can specify the list
williamr@4
    59
 * of stores in the constructor he/she is interested in or load additional 
williamr@4
    60
 * plug-ins later on. In addition to loading the implementing plug-ins the 
williamr@4
    61
 * client must open the stores. Clients should share the contact manager 
williamr@4
    62
 * instance within their context, otherwise e.g. field types from two 
williamr@4
    63
 * different instances will not produce the matches as the matching is
williamr@4
    64
 * based on pointer comparison.
williamr@4
    65
 *
williamr@4
    66
 * Examples of absolute URI stores:
williamr@4
    67
 * Default contact database: "cntdb://contacts.cdb"
williamr@4
    68
 * LDAP store: "ldap://www.telnumbers.com/"
williamr@4
    69
 * The URI scheme name is used to resolve a store capable of supporting 
williamr@4
    70
 * this type of store. The actual store implementations are ECom plugins.
williamr@4
    71
 *
williamr@4
    72
 *  @lib VPbkEng.lib
williamr@4
    73
 */
williamr@4
    74
class CVPbkContactManager : public CBase
williamr@4
    75
    {
williamr@4
    76
    public:  // Constructors and destructor
williamr@4
    77
        /**
williamr@4
    78
         * Creates a contact manager instance and loads the plug-ins that can 
williamr@4
    79
         * handle the stores corresponding to the aURIList.
williamr@4
    80
         * @param aURIList  Universal Resource Identifier list of the stores 
williamr@4
    81
         *                  to be loaded initially. 
williamr@4
    82
         * @param aFs       File system handle. NULL opens a new connection.
williamr@4
    83
         * @return	Contact manager instance.
williamr@4
    84
         */
williamr@4
    85
        IMPORT_C static CVPbkContactManager* NewL(
williamr@4
    86
                const CVPbkContactStoreUriArray& aURIList,
williamr@4
    87
                RFs* aFs = NULL);
williamr@4
    88
                
williamr@4
    89
        /**
williamr@4
    90
         * Creates a contact manager instance and loads the plug-ins that can 
williamr@4
    91
         * handle the stores corresponding to the aURIList.
williamr@4
    92
         * @param aSecurityInfo Security info from caller to be passed for stores.
williamr@4
    93
         *                      Stores can check security info and deside
williamr@4
    94
         *                      if client can use service.
williamr@4
    95
         * @param aURIList      Universal Resource Identifier list of the stores 
williamr@4
    96
         *                      to be loaded initially. 
williamr@4
    97
         * @param aFs           File system handle. NULL opens a new connection.
williamr@4
    98
         * @return              Contact manager instance.
williamr@4
    99
         */
williamr@4
   100
        IMPORT_C static CVPbkContactManager* NewL(
williamr@4
   101
                TSecurityInfo aSecurityInfo,
williamr@4
   102
                const CVPbkContactStoreUriArray& aURIList,
williamr@4
   103
                RFs* aFs = NULL);
williamr@4
   104
williamr@4
   105
        /**
williamr@4
   106
         * Destructor.
williamr@4
   107
         */
williamr@4
   108
        ~CVPbkContactManager();
williamr@4
   109
williamr@4
   110
    public: // Interface
williamr@4
   111
        /**
williamr@4
   112
         * The contact manager owns a master list of field types that clients
williamr@4
   113
         * use. The store implementation then maps their native types
williamr@4
   114
         * to Virtual Phonebook types. Clients don't create field type objects
williamr@4
   115
         * themselves but use always references to types offered 
williamr@4
   116
         * by this function.
williamr@4
   117
         *
williamr@4
   118
         * @return The global list of field types.
williamr@4
   119
         */
williamr@4
   120
        IMPORT_C const MVPbkFieldTypeList& FieldTypes() const;
williamr@4
   121
williamr@4
   122
        /**
williamr@4
   123
         * The contact store list is used to handle a set of stores.
williamr@4
   124
         * After creation of manager the client can use the list to open
williamr@4
   125
         * all stores.
williamr@4
   126
         *
williamr@4
   127
         * @return The list of available contact stores.
williamr@4
   128
         */
williamr@4
   129
        IMPORT_C MVPbkContactStoreList& ContactStoresL();
williamr@4
   130
williamr@4
   131
        /**
williamr@4
   132
         * Loads a store plug-in for given URI and adds aURI 
williamr@4
   133
         * to the list of stores handled by this manager.
williamr@4
   134
         * If there is no store plug-in for the aURI then nothing changes.
williamr@4
   135
         *
williamr@4
   136
         * @param aURI the store URI to be loaded.
williamr@4
   137
         */
williamr@4
   138
        IMPORT_C void LoadContactStoreL(const TVPbkContactStoreUriPtr& aURI);
williamr@4
   139
williamr@4
   140
        /**
williamr@4
   141
         * Attribute manager is used for handling contact attributes like
williamr@4
   142
         * speed dialing or defaults.
williamr@4
   143
         *
williamr@4
   144
         * @returns The contact attribute manager.
williamr@4
   145
         */
williamr@4
   146
        IMPORT_C MVPbkContactAttributeManager& ContactAttributeManagerL();
williamr@4
   147
williamr@4
   148
        /**
williamr@4
   149
         * Creates a new contact view specified by the view definition.
williamr@4
   150
         * The view can not be used before it has notified the observer 
williamr@4
   151
         * that it is ready.
williamr@4
   152
         *
williamr@4
   153
         * @param aObserver the observer for view events.
williamr@4
   154
         * @param aViewDefinition Definition of the view to create
williamr@4
   155
         * @param aSortOrder a list of field types that defines fields
williamr@4
   156
         *        that are used in sorting. View contacts
williamr@4
   157
         *        have these fields. However, the store can have restrictions
williamr@4
   158
         *        for types that can be used in the sort order.
williamr@4
   159
         *        The sort order has no effect for shared views that have
williamr@4
   160
         *        already been created.
williamr@4
   161
         *
williamr@4
   162
         * @see CVPbkSortOrder
williamr@4
   163
         * @return Newly created view. 
williamr@4
   164
         *         If NULL CleanupStack pop is still needed
williamr@4
   165
         */
williamr@4
   166
        IMPORT_C MVPbkContactViewBase* CreateContactViewLC(
williamr@4
   167
                MVPbkContactViewObserver& aObserver,
williamr@4
   168
                const CVPbkContactViewDefinition& aViewDefinition, 
williamr@4
   169
                const MVPbkFieldTypeList& aSortOrder) const;
williamr@4
   170
williamr@4
   171
        /**
williamr@4
   172
         * Retrieves asynchronously a contact that is individualized by 
williamr@4
   173
         * a contact link. Delete the operation for canceling.
williamr@4
   174
         *
williamr@4
   175
         * @param aLink a link to the contact
williamr@4
   176
         * @param aObserver operation observer
williamr@4
   177
         * @return New handle to the operation
williamr@4
   178
         * @Asynchronous
williamr@4
   179
         */
williamr@4
   180
        IMPORT_C MVPbkContactOperationBase* RetrieveContactL(
williamr@4
   181
                const MVPbkContactLink& aLink,
williamr@4
   182
                MVPbkSingleContactOperationObserver& aObserver) const;
williamr@4
   183
        
williamr@4
   184
        /**
williamr@4
   185
         * Creates an array of links corresponding to a packaged link or links.
williamr@4
   186
         * Packed links have been obtained by packing a link or a link array
williamr@4
   187
         * and they can be used for example for IPC but not for saving links. 
williamr@4
   188
         * Loads the store plug-ins that are capable of creating the 
williamr@4
   189
         * appropriate links.
williamr@4
   190
         *
williamr@4
   191
         * @param aPackedLinks packed links
williamr@4
   192
         * @return A link array.
williamr@4
   193
         * @see MVPbkContactLink::PackLC
williamr@4
   194
         * @see MVPbkContactLinkArray::PackLC
williamr@4
   195
         */
williamr@4
   196
        IMPORT_C MVPbkContactLinkArray* CreateLinksLC(
williamr@4
   197
            const TDesC8& aPackedLinks) const;
williamr@4
   198
        
williamr@4
   199
        /**
williamr@4
   200
         * Internalizes a permanent link or links. An externalized link
williamr@4
   201
         * has been created using MVPbkStreamable interface from
williamr@4
   202
         * MVPbkContactLink.
williamr@4
   203
         * Loads the store plug-ins that are capable of creating the 
williamr@4
   204
         * appropriate links.
williamr@4
   205
         *
williamr@4
   206
         * @param aStream a stream that contains a link or links.
williamr@4
   207
         * @return A link array
williamr@4
   208
         * @see MVPbkContactLink::Streamable
williamr@4
   209
         */
williamr@4
   210
        IMPORT_C MVPbkContactLinkArray* CreateLinksLC(
williamr@4
   211
            RReadStream& aStream) const;
williamr@4
   212
            
williamr@4
   213
        /**
williamr@4
   214
         * Deletes contacts defined in link array asynchronously.
williamr@4
   215
         *
williamr@4
   216
         * @param aContactLinks Contacts to delete
williamr@4
   217
         * @param aObserver Operation observer
williamr@4
   218
         * @return New handle to the operation
williamr@4
   219
         */
williamr@4
   220
        IMPORT_C MVPbkContactOperationBase* DeleteContactsL(
williamr@4
   221
                const MVPbkContactLinkArray& aContactLinks, 
williamr@4
   222
                MVPbkBatchOperationObserver& aObserver);
williamr@4
   223
williamr@4
   224
        /**
williamr@4
   225
         * Commits all contacts in aContacts asynchronously.
williamr@4
   226
         *
williamr@4
   227
         * @see MVPbkStoreContact::CommitL
williamr@4
   228
         * @param aContacts Contacts to commit.
williamr@4
   229
         * @param aObserver Operation observer.
williamr@4
   230
         * @return New handle to the operation.
williamr@4
   231
         */
williamr@4
   232
        IMPORT_C MVPbkContactOperationBase* CommitContactsL(
williamr@4
   233
                const TArray<MVPbkStoreContact*>& aContacts, 
williamr@4
   234
                MVPbkBatchOperationObserver& aObserver);
williamr@4
   235
williamr@4
   236
        /**
williamr@4
   237
         * Copies all contacts in aContactLinks to aTargetStore asynchronously. 
williamr@4
   238
         * If aTargetStore is NULL, contacts are copied to the store where 
williamr@4
   239
         * they already are, ie. the contacts are duplicated.
williamr@4
   240
         *
williamr@4
   241
         * @param aContactLinks Array of contact links to duplicate.
williamr@4
   242
         * @param aTargetStore Target store to copy contacts to.
williamr@4
   243
         *                     If NULL this behaves like duplicate.
williamr@4
   244
         * @param aObserver Observer for the copying process.
williamr@4
   245
         * @return New handle to the operation.
williamr@4
   246
         */
williamr@4
   247
        IMPORT_C MVPbkContactOperationBase* CopyContactsL(
williamr@4
   248
                const MVPbkContactLinkArray& aContactLinks,
williamr@4
   249
                MVPbkContactStore* aTargetStore,
williamr@4
   250
                MVPbkBatchOperationObserver& aObserver);
williamr@4
   251
williamr@4
   252
        /**
williamr@4
   253
         * Searches the contact stores for a phone number using 
williamr@4
   254
         * defined amount of digits from the end of the number asynchronously.
williamr@4
   255
         * The store implementations determine, which field types are included 
williamr@4
   256
         * in the search. 
williamr@4
   257
         * 
williamr@4
   258
         * @param aPhoneNumber Phone number to search for.
williamr@4
   259
         * @param aMaxMatchDigits Maximum number of digits to match 
williamr@4
   260
         * 						  from the end of the number.
williamr@4
   261
         * @param aObserver Observer for the find process.
williamr@4
   262
         * @return New handle to the find operation.
williamr@4
   263
         */
williamr@4
   264
        IMPORT_C MVPbkContactOperationBase* MatchPhoneNumberL(
williamr@4
   265
                const TDesC& aPhoneNumber, 
williamr@4
   266
                TInt aMaxMatchDigits,
williamr@4
   267
                MVPbkContactFindObserver& aObserver);
williamr@4
   268
williamr@4
   269
        /**
williamr@4
   270
         * Searches the contact stores for a contact that contains
williamr@4
   271
         * the given string in one of the field defined by given 
williamr@4
   272
         * field type list asynchronously.
williamr@4
   273
         * NOTE: In some cases the find matches also other fields than 
williamr@4
   274
         *       those specified in aFieldTypes. Always loop through the
williamr@4
   275
         *       results to check match in the required fields.
williamr@4
   276
         *
williamr@4
   277
         * @param aSearchString String to search for.
williamr@4
   278
         * @param aFieldTypes List of field types that the search will include.
williamr@4
   279
         *                    a field type list: use CVPbkFieldTypeRefsList and
williamr@4
   280
         *                    append the types that are needed from 
williamr@4
   281
         *                    the master field type list (FieldTypes()) 
williamr@4
   282
         *                    to the reference list. Selection can be done
williamr@4
   283
         *                    in a dynamic way using CVPbkFieldTypeSelector or
williamr@4
   284
         *                    static way using resource ids of the field types.
williamr@4
   285
         * @param aObserver Observer for the find process.
williamr@4
   286
         * @return New handle to the find operation.
williamr@4
   287
         */
williamr@4
   288
        IMPORT_C MVPbkContactOperationBase* FindL(
williamr@4
   289
                const TDesC& aSearchString,
williamr@4
   290
                const MVPbkFieldTypeList& aFieldTypes,
williamr@4
   291
                MVPbkContactFindObserver& aObserver);
williamr@4
   292
        
williamr@4
   293
        /**
williamr@4
   294
         * Finds a string containing text that is stored in one or more 
williamr@4
   295
         * fields asynchronously. Client can give multiple find words. 
williamr@4
   296
         * All the words must match to separated data. E.g. if there are 
williamr@4
   297
         * two find words: "Jo" and "Jo" then field data "John Johnson" 
williamr@4
   298
         * matches but "John Doe" doesn't if the word parser uses
williamr@4
   299
         * white space as a word separator.
williamr@4
   300
         *
williamr@4
   301
         * NOTE: The accuracy of the results depends on the implementation 
williamr@4
   302
         * of the store to carry out the find operation. The performance 
williamr@4
   303
         * can also vary depending on the store. 
williamr@4
   304
         *
williamr@4
   305
         * @param aSearchStrings strings that are compared to field data.
williamr@4
   306
         * @param aFieldTypes types of the fields that are used. Constructing
williamr@4
   307
         *                    a fieldtype list: use CVPbkFieldTypeRefsList and
williamr@4
   308
         *                    append the types that are needed from 
williamr@4
   309
         *                    the master fieldtype list (FieldTypes()) 
williamr@4
   310
         *                    to the reference list. Selection can be done
williamr@4
   311
         *                    in a dynamic way using CVPbkFieldTypeSelector or
williamr@4
   312
         *                    static way using resource ids of the fieldtypes.
williamr@4
   313
         * 
williamr@4
   314
         * @param aObserver an observer for asynchronous operation.
williamr@4
   315
         * @param aWordParserCallBack a client implementation of word parser 
williamr@4
   316
         *                            function that separates the field data 
williamr@4
   317
         *                            into words. Parameter to function is 
williamr@4
   318
         *                            TVPbkWordParserParam.
williamr@4
   319
         * @return New handle to the find operation.
williamr@4
   320
         */
williamr@4
   321
        IMPORT_C MVPbkContactOperationBase* FindL(
williamr@4
   322
                const MDesC16Array& aSearchStrings, 
williamr@4
   323
                const MVPbkFieldTypeList& aFieldTypes, 
williamr@4
   324
                MVPbkContactFindFromStoresObserver& aObserver, 
williamr@4
   325
                const TCallBack& aWordParserCallBack );
williamr@4
   326
        
williamr@4
   327
        /**
williamr@4
   328
         * Compresses all stores asynchronously.
williamr@4
   329
         * NOTE: Not all stores are able to implement compression to their
williamr@4
   330
         * repositories.
williamr@4
   331
         * 
williamr@4
   332
         * @param aObserver Operation observer.
williamr@4
   333
         * @return New handle to the operation.
williamr@4
   334
         */
williamr@4
   335
        IMPORT_C MVPbkContactOperationBase* CompressStoresL(
williamr@4
   336
        		MVPbkBatchOperationObserver& aObserver);
williamr@4
   337
williamr@4
   338
        /**
williamr@4
   339
         * Returns the file server session of the contact manager.
williamr@4
   340
         * 
williamr@4
   341
         * @return File server session of the contact manager.
williamr@4
   342
         */
williamr@4
   343
        IMPORT_C RFs& FsSession();
williamr@4
   344
        
williamr@4
   345
        
williamr@4
   346
        /**
williamr@4
   347
         * Finds a string containing text that is stored in one or more 
williamr@4
   348
         * fields asynchronously. Client can give multiple find words. 
williamr@4
   349
         * All the words must match to separated data. E.g. if there are 
williamr@4
   350
         * two find words: "Jo" and "Jo" then field data "John Johnson" 
williamr@4
   351
         * matches but "John Doe" doesn't if the word parser uses
williamr@4
   352
         * white space as a word separator.
williamr@4
   353
         *
williamr@4
   354
         * NOTE: The accuracy of the results depends on the implementation 
williamr@4
   355
         * of the store to carry out the find operation. The performance 
williamr@4
   356
         * can also vary depending on the store. 
williamr@4
   357
         *
williamr@4
   358
         * @param aSearchStrings strings that are compared to field data.
williamr@4
   359
         * @param aFieldTypes types of the fields that are used. Constructing
williamr@4
   360
         *                    a fieldtype list: use CVPbkFieldTypeRefsList and
williamr@4
   361
         *                    append the types that are needed from 
williamr@4
   362
         *                    the master fieldtype list (FieldTypes()) 
williamr@4
   363
         *                    to the reference list. Selection can be done
williamr@4
   364
         *                    in a dynamic way using CVPbkFieldTypeSelector or
williamr@4
   365
         *                    static way using resource ids of the fieldtypes.
williamr@4
   366
         * 
williamr@4
   367
         * @param aObserver an observer for asynchronous operation.
williamr@4
   368
         * @param aWordParserCallBack a client implementation of word parser 
williamr@4
   369
         *                            function that separates the field data 
williamr@4
   370
         *                            into words. Parameter to function is 
williamr@4
   371
         *                            TVPbkWordParserParam.
williamr@4
   372
         * @param aStoreEntriesArray an array that lists the store entries
williamr@4
   373
         * @return New handle to the find operation or NULL if it could not be created.
williamr@4
   374
         */
williamr@4
   375
        IMPORT_C MVPbkContactOperationBase* FindL(
williamr@4
   376
                const MDesC16Array& aSearchStrings, 
williamr@4
   377
                const MVPbkFieldTypeList& aFieldTypes, 
williamr@4
   378
                MVPbkContactFindFromStoresObserver& aObserver, 
williamr@4
   379
                const TCallBack& aWordParserCallBack,
williamr@4
   380
                const CDesC16ArrayFlat& aStoreEntriesArray );
williamr@4
   381
williamr@4
   382
    private: // Implementation
williamr@4
   383
        CVPbkContactManager( TSecurityInfo aSecurityInfo, RFs* aFs );
williamr@4
   384
        void ConstructL(const CVPbkContactStoreUriArray& aURIList);
williamr@4
   385
        MVPbkContactStore* FindStore(const TVPbkContactStoreUriPtr& aURI) const;
williamr@4
   386
        MVPbkContactViewBase* CreateOptimizedCompositeViewLC(
williamr@4
   387
                MVPbkContactViewObserver& aObserver,
williamr@4
   388
                const CVPbkContactViewDefinition& aViewDefinition, 
williamr@4
   389
                const MVPbkFieldTypeList& aSortOrder) const;
williamr@4
   390
        MVPbkContactViewBase* CreateCompositeViewLC(
williamr@4
   391
                MVPbkContactViewObserver& aObserver,
williamr@4
   392
                const CVPbkContactViewDefinition& aViewDefinition, 
williamr@4
   393
                const MVPbkFieldTypeList& aSortOrder) const;
williamr@4
   394
williamr@4
   395
    private: // Data
williamr@4
   396
        /// Own: Security info for client.
williamr@4
   397
        TSecurityInfo iSecurityInfo;
williamr@4
   398
        /// Own: File system handle
williamr@4
   399
        RFs iFs;
williamr@4
   400
        /// Own: File system handle that is owned
williamr@4
   401
        RFs iOwnFs;
williamr@4
   402
        /// Own: Global Phonebook field types
williamr@4
   403
        MVPbkFieldTypeList* iFieldTypes;
williamr@4
   404
        /// Own: List of contact stores
williamr@4
   405
        CVPbkContactStoreDomainList* iContactStoreDomains;
williamr@4
   406
        /// Own: Contact attribute manager
williamr@4
   407
        MVPbkContactAttributeManager* iAttributeManager;
williamr@4
   408
        /// Own: an internal class for loading stores
williamr@4
   409
        class CContactStoreLoader;
williamr@4
   410
        CContactStoreLoader* iStoreLoader;
williamr@4
   411
    };
williamr@4
   412
williamr@4
   413
#endif  // CVPBKCONTACTMANAGER_H
williamr@4
   414
williamr@4
   415
// End of file