epoc32/include/app/CPbkContactEngine.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 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: 
williamr@4
    15
*     Represents a connection to the Phonebook contact database
williamr@4
    16
*
williamr@4
    17
*/
williamr@4
    18
williamr@4
    19
williamr@4
    20
#ifndef __CPBKCONTACTENGINE_H__
williamr@4
    21
#define __CPBKCONTACTENGINE_H__
williamr@4
    22
williamr@4
    23
//  INCLUDES
williamr@4
    24
#include <e32base.h>        // CBase
williamr@4
    25
#include <cntdef.h>         // TContactItemId
williamr@4
    26
#include <cntdbobs.h>       // MContactDbObserver
williamr@4
    27
#include <f32file.h>        // RFs
williamr@4
    28
#include "PbkFields.hrh"    // TPbkFieldId
williamr@4
    29
williamr@4
    30
williamr@4
    31
// FORWARD DECLARATIONS
williamr@4
    32
class CContactDatabase;
williamr@4
    33
class MIdleFindObserver;
williamr@4
    34
class MPbkContactDbObserver;
williamr@4
    35
class CContactGroup;
williamr@4
    36
class CPbkFieldsInfo;
williamr@4
    37
class CPbkContactItem;
williamr@4
    38
class CPbkContactIter;
williamr@4
    39
class CPbkContactChangeNotifier;
williamr@4
    40
class CPbkIdleFinder;
williamr@4
    41
class MPbkCompressUi;
williamr@4
    42
class CPbkConstants;
williamr@4
    43
class MPbkContactNameFormat;
williamr@4
    44
class MPbkFieldDataArray;
williamr@4
    45
class CContactViewBase;
williamr@4
    46
class CContactItem;
williamr@4
    47
class RSharedDataClient;
williamr@4
    48
class TResourceReader;
williamr@4
    49
class CPbkEngineExtension;
williamr@4
    50
class CPbkSortOrderManager;
williamr@4
    51
class CPbkSINDHandlerInterface;
williamr@4
    52
williamr@4
    53
williamr@4
    54
// CLASS DECLARATION
williamr@4
    55
williamr@4
    56
/**
williamr@4
    57
 * The main entrypoint to the Phonebook contact engine. The Phonebook
williamr@4
    58
 * contact engine builds on top of the Symbian Contacts model and
williamr@4
    59
 * implements platform specific functionality and policies that can be 
williamr@4
    60
 * reused and followed by clients to implement functionality that is
williamr@4
    61
 * better integrated to the platform functionality. Functionality like
williamr@4
    62
 * contact field typing is implemented by this engine. 
williamr@4
    63
 */
williamr@4
    64
class   CPbkContactEngine :
williamr@4
    65
        public CBase,
williamr@4
    66
        private MContactDbObserver
williamr@4
    67
    {
williamr@4
    68
    public: // Constructors and destructor
williamr@4
    69
        /**
williamr@4
    70
         * Creates a new Phonebook engine object and connects to the default
williamr@4
    71
         * contact database. If the default database does not exist it is
williamr@4
    72
         * created.
williamr@4
    73
         *
williamr@4
    74
         * @param aFs   An open file server connection. If !=NULL aFs is used
williamr@4
    75
         *              instead of a locally created RFs connection. aFs must
williamr@4
    76
         *              remain connected for the lifetime of the returned
williamr@4
    77
         *              object.
williamr@4
    78
         * @return A new instance of this class.
williamr@4
    79
         * @exception KErrCorrupt if the database is corrupted.
williamr@4
    80
         */
williamr@4
    81
		IMPORT_C static CPbkContactEngine* NewL(RFs* aFs=NULL);
williamr@4
    82
williamr@4
    83
        /**
williamr@4
    84
         * @internal
williamr@4
    85
         * TESTING ONLY
williamr@4
    86
         * Creates a new engine object and connects it to a specified
williamr@4
    87
         * database file. If the database file does not exist it is created.
williamr@4
    88
         *
williamr@4
    89
         * @param aFileName The database filename.
williamr@4
    90
         * @param aReplace  If ETrue replaces exisiting file with an empty one.
williamr@4
    91
         *                  PLEASE NOTE: all data in the existing file
williamr@4
    92
         *                  will be lost!
williamr@4
    93
         * @param aFs   An open file server connection. If !=NULL aFs is used
williamr@4
    94
         *              instead of a locally created RFs connection. aFs must
williamr@4
    95
         *              remain connected for the lifetime of the returned
williamr@4
    96
         *              object.
williamr@4
    97
         * @return A new instance of this class.
williamr@4
    98
         * @exception KErrCorrupt if the database is corrupted.
williamr@4
    99
         * @deprecated
williamr@4
   100
         */
williamr@4
   101
		IMPORT_C static CPbkContactEngine* NewL
williamr@4
   102
            (const TDesC& aFileName, TBool aReplace=EFalse, RFs* aFs=NULL);
williamr@4
   103
williamr@4
   104
        /**
williamr@4
   105
         * Replaces the default contact database and connects to it. See
williamr@4
   106
         * Symbian Contacs model documentation for CContactDatabase::ReplaceL
williamr@4
   107
         * for possible leave codes.
williamr@4
   108
         * PLEASE NOTE: all data in the existing database will be lost!
williamr@4
   109
         *
williamr@4
   110
         * @param aFs   An open file server connection. If !=NULL aFs is used
williamr@4
   111
         *              instead of a locally created RFs connection. aFs must
williamr@4
   112
         *              remain connected for the lifetime of the returned
williamr@4
   113
         *              object.
williamr@4
   114
         * @return A new instance of this class.
williamr@4
   115
         * @see CContactDatabase::ReplaceL
williamr@4
   116
         */
williamr@4
   117
        IMPORT_C static CPbkContactEngine* ReplaceL(RFs* aFs=NULL);
williamr@4
   118
williamr@4
   119
        /**
williamr@4
   120
		* Destructor. Destroys this object and closes the contact database
williamr@4
   121
		* connection. REComSession::FinalClose() is called. Notice that
williamr@4
   122
		* FinalClose -call releases resource handles of already destroyed ECom
williamr@4
   123
		* plugins also outside CPbkContactEngine. See REComSession
williamr@4
   124
		* documentation.
williamr@4
   125
		*/
williamr@4
   126
		~CPbkContactEngine();
williamr@4
   127
williamr@4
   128
    public: // Accessors
williamr@4
   129
        /**
williamr@4
   130
         * Returns the global Phonebook engine instance, NULL if no instance
williamr@4
   131
         * created yet.
williamr@4
   132
         * Note1: Uses thread local storage (TLS), which is slow. Cache the
williamr@4
   133
         * returned pointer if it is used more than one time!
williamr@4
   134
         * Note2: Only the first engine instance created in calling thread can
williamr@4
   135
         * be accessed with this function.
williamr@4
   136
         * @return  Global Phonebook engine instance.
williamr@4
   137
         */
williamr@4
   138
        IMPORT_C static CPbkContactEngine* Static();
williamr@4
   139
williamr@4
   140
        /**
williamr@4
   141
         * Returns the underlying CContactDatabase object. Use only if this class's API
williamr@4
   142
         * is not enough for your purposes.
williamr@4
   143
         *
williamr@4
   144
         * @return The underlying Symbian Contacts model CContactDatabase instance.
williamr@4
   145
         * @see CContactDatabase
williamr@4
   146
         */
williamr@4
   147
        IMPORT_C CContactDatabase& Database();
williamr@4
   148
williamr@4
   149
        /**
williamr@4
   150
         * Returns the field type info array.
williamr@4
   151
         * @return  All the Phonebook field types.
williamr@4
   152
         * @see CPbkFieldsInfo
williamr@4
   153
         */
williamr@4
   154
        IMPORT_C const CPbkFieldsInfo& FieldsInfo();
williamr@4
   155
williamr@4
   156
        /**
williamr@4
   157
         * Returns an open file server session.
williamr@4
   158
         * @return  A handle to a file server session.
williamr@4
   159
         */
williamr@4
   160
        IMPORT_C RFs& FsSession() const;
williamr@4
   161
williamr@4
   162
    public:  // Creating contacts
williamr@4
   163
        /**
williamr@4
   164
         * Returns a new contact card with default fields.
williamr@4
   165
         * @return  A new empty contact item object.
williamr@4
   166
         */
williamr@4
   167
        IMPORT_C CPbkContactItem* CreateEmptyContactL();
williamr@4
   168
williamr@4
   169
         /**
williamr@4
   170
          * Adds a new contact to the contact database.
williamr@4
   171
          *
williamr@4
   172
          * @param aContact         The new contact item to add.
williamr@4
   173
          * @param aImmediateNotify Send notification to observers immediately.
williamr@4
   174
          *                         NOTE: send immediately will result in
williamr@4
   175
          *                         observers (MPbkContactDbObserver) receiving
williamr@4
   176
          *                         the event twice!
williamr@4
   177
          * @return The id of the new contact item.
williamr@4
   178
          * @see CContactDatabase::AddNewContactL
williamr@4
   179
          */
williamr@4
   180
        IMPORT_C TContactItemId AddNewContactL
williamr@4
   181
            (CPbkContactItem& aContact, TBool aImmediateNotify=EFalse);
williamr@4
   182
williamr@4
   183
        /**
williamr@4
   184
         * Duplicates a contact in the database.
williamr@4
   185
         *
williamr@4
   186
         * @param aId               Id of the contact to duplicate.
williamr@4
   187
         * @param aImmediateNotify  Send notification to observers immediately.
williamr@4
   188
         *                          NOTE: send immediately will result in
williamr@4
   189
         *                          observers (MPbkContactDbObserver) receiving
williamr@4
   190
         *                          the event twice!
williamr@4
   191
         * @return  Contact id of the new duplicate.
williamr@4
   192
         */
williamr@4
   193
        IMPORT_C TContactItemId DuplicateContactL
williamr@4
   194
            (TContactItemId aId, TBool aImmediateNotify=EFalse);
williamr@4
   195
williamr@4
   196
    public:  // Reading contacts
williamr@4
   197
        /**
williamr@4
   198
         * Reads a contact and returns a phonebook contact item.
williamr@4
   199
         *
williamr@4
   200
         * @param aContactId Contact item id to be read.
williamr@4
   201
         * @param aFieldTypes   Array of types of fields to read in, all
williamr@4
   202
         *                      fields are read if NULL (which is default).
williamr@4
   203
         *                      NOTE: when using this parameter ReadContactL
williamr@4
   204
         *                      may return more fields than expected; for example
williamr@4
   205
         *                      if aFieldTypes contains any phonenumber the
williamr@4
   206
         *                      method may return all phone number fields
williamr@4
   207
         *                      of the contact.
williamr@4
   208
         * @return A new Phonebook contact item.
williamr@4
   209
         * @see CContactDatabase::ReadContactL
williamr@4
   210
         */
williamr@4
   211
        IMPORT_C CPbkContactItem* ReadContactL
williamr@4
   212
            (TContactItemId aContactId, const CPbkFieldIdArray* aFieldTypes=NULL);
williamr@4
   213
williamr@4
   214
        /**
williamr@4
   215
         * Same as ReadContactL, but leaves the returned contact item
williamr@4
   216
         * on the cleanup stack.
williamr@4
   217
         *
williamr@4
   218
         * @param aContactId Contact item id to be read.
williamr@4
   219
         * @param aFieldTypes   Array of types of fields to read in, all
williamr@4
   220
         *                      fields are read if NULL (which is default).
williamr@4
   221
         *                      NOTE: when using this parameter ReadContactL
williamr@4
   222
         *                      may return more fields than expected; for example
williamr@4
   223
         *                      if aFieldTypes contains any phonenumber the
williamr@4
   224
         *                      method may return all phone number fields
williamr@4
   225
         *                      of the contact.
williamr@4
   226
         * @return A new Phonebook contact item.
williamr@4
   227
         */
williamr@4
   228
        IMPORT_C CPbkContactItem* ReadContactLC
williamr@4
   229
            (TContactItemId aContactId, const CPbkFieldIdArray* aFieldTypes=NULL);
williamr@4
   230
williamr@4
   231
        /**
williamr@4
   232
         * Same as ReadContactLC but reads only minimal information. See
williamr@4
   233
         * Symbian Contacts Model documentation for definition of "minimal" in this
williamr@4
   234
         * case.
williamr@4
   235
         *
williamr@4
   236
         * @param aContactId Contact item id to be read.
williamr@4
   237
         * @return A new phonebook contact item. Leaves the item on the cleanup stack.
williamr@4
   238
         * @see CContactDatabase::ReadMinimalContactL
williamr@4
   239
         */
williamr@4
   240
        IMPORT_C CPbkContactItem* ReadMinimalContactLC(TContactItemId aContactId);
williamr@4
   241
williamr@4
   242
        /**
williamr@4
   243
         * Returns a Phonebook contact iterator.
williamr@4
   244
         * @param aUseMinimalRead   If ETrue the iterator will use the Symbian
williamr@4
   245
         * Contacts model CContactDatabase::ReadMinimalContactL, EFalse will read 
williamr@4
   246
         * all the contact fields. Default behaviour is to read all fields.
williamr@4
   247
         * @see CPbkContactIter::NewL.
williamr@4
   248
         * @see CContactDatabase::ReadMinimalContactL
williamr@4
   249
         */
williamr@4
   250
        IMPORT_C CPbkContactIter* CreateContactIteratorLC
williamr@4
   251
            (TBool aUseMinimalRead=EFalse);
williamr@4
   252
williamr@4
   253
    public:  // Modifying contacts
williamr@4
   254
        /**
williamr@4
   255
         * Opens a contact and returns a phonebook contact item.
williamr@4
   256
         * @param aContactId Contact item id to be opened.
williamr@4
   257
         * @return A Phonebook contact item that is marked as open in the database.
williamr@4
   258
         * @see CContactDatabase::OpenContactL
williamr@4
   259
         */
williamr@4
   260
        IMPORT_C CPbkContactItem* OpenContactL(TContactItemId aContactId);
williamr@4
   261
williamr@4
   262
        /**
williamr@4
   263
         * Same as OpenContactL, but leaves a lock record AND the opened
williamr@4
   264
         * contact object on the cleanup stack.
williamr@4
   265
         * Use CleanupStack::PopAndDestroy(2) to close the contact and destroy
williamr@4
   266
         * the returned object. First pop pops the contact object and second
williamr@4
   267
         * the lock object.
williamr@4
   268
         * @param aContactId    Contact item id to open.
williamr@4
   269
         * @return A Phonebook contact item that is marked as open in the database.
williamr@4
   270
         * @see CContactDatabase::OpenContactLX
williamr@4
   271
         */
williamr@4
   272
        IMPORT_C CPbkContactItem* OpenContactLCX(TContactItemId aContactId);
williamr@4
   273
williamr@4
   274
        /**
williamr@4
   275
         * Commit changes to a previously opened contact item into the contact
williamr@4
   276
         * database.
williamr@4
   277
         *
williamr@4
   278
         * @param aContact          Contact item to be updated in the database.
williamr@4
   279
         * @param aImmediateNotify  Send notification to observers immediately.
williamr@4
   280
         *                          NOTE: send immediately will result in
williamr@4
   281
         *                          observers (MPbkContactDbObserver) receiving
williamr@4
   282
         *                          the event twice!
williamr@4
   283
         * @see CContactDatabase::CommitContactL
williamr@4
   284
         */
williamr@4
   285
        IMPORT_C void CommitContactL
williamr@4
   286
            (CPbkContactItem& aContact, TBool aImmediateNotify=EFalse);
williamr@4
   287
williamr@4
   288
        /**
williamr@4
   289
         * Closes a previously opened contact item without saving changes.
williamr@4
   290
         * @param aContactId Contact item to be closed.
williamr@4
   291
         * @see CContactDatabase::CloseContactL
williamr@4
   292
         */
williamr@4
   293
    	IMPORT_C void CloseContactL(TContactItemId aContactId);
williamr@4
   294
williamr@4
   295
    public:  // Deleting contacts
williamr@4
   296
        /**
williamr@4
   297
         * Deletes a contact item from the database.
williamr@4
   298
         * @param aContactId    Contact item to be deleted.
williamr@4
   299
         * @param aImmediateNotify  Send notification to observers immediately.
williamr@4
   300
         *                          NOTE: send immediately will result in
williamr@4
   301
         *                          observers (MPbkContactDbObserver) receiving
williamr@4
   302
         *                          the event twice!
williamr@4
   303
         * @see CContactDatabase::DeleteContactL
williamr@4
   304
         */
williamr@4
   305
    	IMPORT_C void DeleteContactL
williamr@4
   306
            (TContactItemId aContactId, TBool aImmediateNotify=EFalse);
williamr@4
   307
williamr@4
   308
        /**
williamr@4
   309
         * Deletes multiple contact items from the database.
williamr@4
   310
         * @param aContactIds    Contact items to be deleted.
williamr@4
   311
         * @param aImmediateNotify  Send notification to observers immediately.
williamr@4
   312
         *                          NOTE: send immediately will result in
williamr@4
   313
         *                          observers (MPbkContactDbObserver) receiving
williamr@4
   314
         *                          the event twice!
williamr@4
   315
         * @see CContactDatabase::DeleteContactsL
williamr@4
   316
         */
williamr@4
   317
    	IMPORT_C void DeleteContactsL
williamr@4
   318
            (const CContactIdArray& aContactIds, TBool aImmediateNotify=EFalse);
williamr@4
   319
williamr@4
   320
        /**
williamr@4
   321
         * Deletes multiple contacts from the database in an active object
williamr@4
   322
         * -driven asynchronous background process.
williamr@4
   323
         *
williamr@4
   324
         * @param aContactIds   Contacts to delete.
williamr@4
   325
         */
williamr@4
   326
        IMPORT_C void DeleteContactsOnBackgroundL
williamr@4
   327
            (const CContactIdArray& aContactIds);
williamr@4
   328
williamr@4
   329
    public:  // Contact groups
williamr@4
   330
        /**
williamr@4
   331
         * Creates a new contact group.
williamr@4
   332
         *
williamr@4
   333
         * @param aGroupLabel   Group name.
williamr@4
   334
         * @param aInTransaction    See Symbian Contacts Model documentation
williamr@4
   335
         * for CContactDatabase::CreateContactGroupL documentation.
williamr@4
   336
         * @see CContactDatabase::CreateContactGroupL
williamr@4
   337
         */
williamr@4
   338
        IMPORT_C CContactGroup* CreateContactGroupL
williamr@4
   339
            (const TDesC& aGroupLabel,TBool aInTransaction=EFalse);
williamr@4
   340
williamr@4
   341
        /**
williamr@4
   342
         * Adds a Contact to a group.
williamr@4
   343
         *
williamr@4
   344
         * @param aItemId   Contact to be added to group.
williamr@4
   345
         * @param aGroupId  Group where the contact will be added to.
williamr@4
   346
         * @see CContactDatabase::AddContactToGroupL
williamr@4
   347
         */
williamr@4
   348
    	IMPORT_C void AddContactToGroupL
williamr@4
   349
            (TContactItemId aItemId, TContactItemId aGroupId);
williamr@4
   350
williamr@4
   351
        /**
williamr@4
   352
         * Removes a contact from a group
williamr@4
   353
         *
williamr@4
   354
         * @param aItemId   Contact to be removed from group.
williamr@4
   355
         * @param aGroupId  Group where the contact will be removed from.
williamr@4
   356
         * @see CContactDatabase::RemoveContactFromGroupL
williamr@4
   357
         */
williamr@4
   358
    	IMPORT_C void RemoveContactFromGroupL
williamr@4
   359
            (TContactItemId aItemId, TContactItemId aGroupId);
williamr@4
   360
williamr@4
   361
        /**
williamr@4
   362
         * Reads a Contact group.
williamr@4
   363
         *
williamr@4
   364
         * @param aId Group id.
williamr@4
   365
         * @return Contact group object.
williamr@4
   366
         * @see CContactDatabase::ReadContactL
williamr@4
   367
         */
williamr@4
   368
        IMPORT_C CContactGroup* ReadContactGroupL(TContactItemId aId);
williamr@4
   369
williamr@4
   370
        /**
williamr@4
   371
         * Opens a Contact group for modification.
williamr@4
   372
         *
williamr@4
   373
         * @param aId Groups id
williamr@4
   374
         * @return Contact group object.
williamr@4
   375
         * @see CContactDatabase::OpenContactL
williamr@4
   376
         */
williamr@4
   377
        IMPORT_C CContactGroup* OpenContactGroupL(TContactItemId aId);
williamr@4
   378
williamr@4
   379
        /**
williamr@4
   380
         * Opens a Contact group for modification. Pushes the returned
williamr@4
   381
         * contact group object and a lock item on the cleanup stack.
williamr@4
   382
         *
williamr@4
   383
         * @param aId Groups id
williamr@4
   384
         * @return Contact group object.
williamr@4
   385
         * @see CContactDatabase::OpenContactLX
williamr@4
   386
         */
williamr@4
   387
        IMPORT_C CContactGroup* OpenContactGroupLCX(TContactItemId aId);
williamr@4
   388
williamr@4
   389
        /**
williamr@4
   390
         * Commits changes to a contact group to the database.
williamr@4
   391
         *
williamr@4
   392
         * @param aId Groups id
williamr@4
   393
         * @param aImmediateNotify  Send notification to observers immediately.
williamr@4
   394
         *                          NOTE: send immediately will result in
williamr@4
   395
         *                          observers (MPbkContactDbObserver) receiving
williamr@4
   396
         *                          the event twice!
williamr@4
   397
         * @see CContactDatabase::CommitContactL
williamr@4
   398
         */
williamr@4
   399
        IMPORT_C void CommitContactGroupL(CContactGroup& aGroup, TBool aImmediateNotify=EFalse);
williamr@4
   400
williamr@4
   401
        /**
williamr@4
   402
         * Deletes a contact group from the database.
williamr@4
   403
         * @param aContactId    Contact group to be deleted.
williamr@4
   404
         * @param aImmediateNotify  Send notification to observers immediately.
williamr@4
   405
         *                          NOTE: send immediately will result in
williamr@4
   406
         *                          observers (MPbkContactDbObserver) receiving
williamr@4
   407
         *                          the event twice!
williamr@4
   408
         * @see CContactDatabase::DeleteContactL
williamr@4
   409
         */
williamr@4
   410
        IMPORT_C void DeleteContactGroupL
williamr@4
   411
            (TContactItemId aContactId, TBool aImmediateNotify=EFalse);
williamr@4
   412
williamr@4
   413
    public:  // Speed dials
williamr@4
   414
        /**
williamr@4
   415
         * Sets a speed dial to a contact field.
williamr@4
   416
         *
williamr@4
   417
         * @param aItem         Contact item to add speed dial to.
williamr@4
   418
         * @param aFieldIndex   Field index to add Speed dial to.
williamr@4
   419
         * @param aSpeedDialPosition    Speed dial position number to set to
williamr@4
   420
         *                              the field.
williamr@4
   421
         * @see CContactDatabase::SetFieldAsSpeedDialL
williamr@4
   422
         */
williamr@4
   423
        IMPORT_C void SetFieldAsSpeedDialL
williamr@4
   424
            (CPbkContactItem& aItem, TInt aFieldIndex, TInt aSpeedDialPosition);
williamr@4
   425
williamr@4
   426
        /**
williamr@4
   427
         * Returns a speed dial contact.
williamr@4
   428
         *
williamr@4
   429
         * @param   aSpeedDialPosition  Speed dial position number.
williamr@4
   430
         * @param   aPhoneNumber        Phone number
williamr@4
   431
         * @see CContactDatabase::GetSpeedDialFieldL.
williamr@4
   432
         */
williamr@4
   433
      	IMPORT_C TContactItemId GetSpeedDialFieldL
williamr@4
   434
            (TInt aSpeedDialPosition, TDes& aPhoneNumber) const;
williamr@4
   435
williamr@4
   436
        /**
williamr@4
   437
         * Removes a speed dial from a contact.
williamr@4
   438
         *
williamr@4
   439
         * @param   aContactId  Contact item to remove the speed dial from.
williamr@4
   440
         * @param   aSpeedDialPosition  Speed dial position number to remove.
williamr@4
   441
         * @see CContactDatabase::RemoveSpeedDialFieldL.
williamr@4
   442
         */
williamr@4
   443
    	IMPORT_C void RemoveSpeedDialFieldL
williamr@4
   444
            (TContactItemId aContactId, TInt aSpeedDialPosition);
williamr@4
   445
williamr@4
   446
        /**
williamr@4
   447
         * Returns ETrue if this field has been assigned a speed dial position.
williamr@4
   448
         *
williamr@4
   449
         * @param aItem contact Item to check for speed dial.
williamr@4
   450
         * @param aFieldIndex   Index of the field to check. This is an index
williamr@4
   451
         *                      into aItem.CardFields().
williamr@4
   452
         * @return  ETrue if Speed dial exitst, EFalse if not.
williamr@4
   453
         */
williamr@4
   454
        IMPORT_C TBool IsSpeedDialAssigned
williamr@4
   455
            (const CPbkContactItem& aItem, TInt aFieldIndex) const;
williamr@4
   456
williamr@4
   457
    public:  // Contact views
williamr@4
   458
        /**
williamr@4
   459
         * Returns a contact view object containing all the contacts in the
williamr@4
   460
         * database.
williamr@4
   461
         *
williamr@4
   462
         * @return  Contact view containing all the contacts in the database.
williamr@4
   463
         * @see CContactViewBase
williamr@4
   464
         */
williamr@4
   465
        IMPORT_C CContactViewBase& AllContactsView();
williamr@4
   466
williamr@4
   467
        /**
williamr@4
   468
         * Returns a contact view object containing all the groups in the
williamr@4
   469
         * database.
williamr@4
   470
         *
williamr@4
   471
         * @return  Contact view containing all the groups in the database.
williamr@4
   472
         * @see CContactViewBase
williamr@4
   473
         */
williamr@4
   474
        IMPORT_C CContactViewBase& AllGroupsViewL();
williamr@4
   475
williamr@4
   476
        /**
williamr@4
   477
         * Returns a contact view object containing all the contacts in the
williamr@4
   478
         * database that match a filter.
williamr@4
   479
         *
williamr@4
   480
         * @param aFilter   Use CContactDatabase::TContactViewFilter.
williamr@4
   481
         * @see CContactViewBase
williamr@4
   482
         */
williamr@4
   483
        IMPORT_C CContactViewBase& FilteredContactsViewL(TInt aFilter);
williamr@4
   484
williamr@4
   485
    public:  // Events
williamr@4
   486
        /**
williamr@4
   487
         * Creates and returns a new CPbkContactChangeNotifier for the
williamr@4
   488
         * default contact database. The returned object attaches aObserver
williamr@4
   489
         * to this engine instance as long as the object exists.
williamr@4
   490
         *
williamr@4
   491
         * @param aObserver Observer to attach to this object.
williamr@4
   492
         * @return  New CPbkContactChangeNotifier object. Caller is responsible
williamr@4
   493
         *          of the object.
williamr@4
   494
         * @see CPbkContactChangeNotifier
williamr@4
   495
         * @see MPbkContactDbObserver
williamr@4
   496
         */
williamr@4
   497
        IMPORT_C CPbkContactChangeNotifier* CreateContactChangeNotifierL
williamr@4
   498
            (MPbkContactDbObserver* aObserver);
williamr@4
   499
williamr@4
   500
    public:  // Contact name formatting
williamr@4
   501
        /**
williamr@4
   502
         * Gets a title text for a contact or localised text for unnamed
williamr@4
   503
         * contact if contact contains no title.
williamr@4
   504
         *
williamr@4
   505
         * @param   aItem   Contact item for which to make the title.
williamr@4
   506
         * @return  A buffer containing the title or unnamed text if no title
williamr@4
   507
         *          can be generated. Caller is responsible of deleting the
williamr@4
   508
         *          returned buffer.
williamr@4
   509
         */
williamr@4
   510
        IMPORT_C HBufC* GetContactTitleL(const CPbkContactItem& aItem) const;
williamr@4
   511
williamr@4
   512
        /**
williamr@4
   513
         * Similar to GetContactTitleL but returns NULL if contact contains no
williamr@4
   514
         * title. Uses the MPbkFieldDataArray interface to access the field 
williamr@4
   515
         * content.
williamr@4
   516
         * @param aContactData  The contact field data array.
williamr@4
   517
         * @return  Contact title, NULL if field array did not contain any fields
williamr@4
   518
         * used to for constructing contact titles.
williamr@4
   519
         * @see CPbkContactEngine::GetContactTitleL
williamr@4
   520
         */
williamr@4
   521
        IMPORT_C HBufC* GetContactTitleOrNullL
williamr@4
   522
            (const MPbkFieldDataArray& aContactData);
williamr@4
   523
williamr@4
   524
        /**
williamr@4
   525
         * Returns ETrue if field is one of the fields used in building the
williamr@4
   526
         * contact title.
williamr@4
   527
         *
williamr@4
   528
         * @param aFieldId  The id of the field.
williamr@4
   529
         * @return  ETrue if aFieldId is type of a field used to build contact
williamr@4
   530
         *          titles.
williamr@4
   531
         * @see GetContactTitleL
williamr@4
   532
         * @see GetContactTitleOrNullL
williamr@4
   533
         */
williamr@4
   534
        IMPORT_C TBool IsTitleField(TPbkFieldId aFieldId) const;
williamr@4
   535
williamr@4
   536
        /**
williamr@4
   537
         * @internal
williamr@4
   538
         * Returns the contact name formatter.
williamr@4
   539
         *
williamr@4
   540
         * @see MPbkContactNameFormat
williamr@4
   541
         * @deprecated
williamr@4
   542
         */
williamr@4
   543
        IMPORT_C MPbkContactNameFormat& ContactNameFormat() const;
williamr@4
   544
williamr@4
   545
        /**
williamr@4
   546
         * Returns the localised title text to use for unnamed contacts.
williamr@4
   547
         * @return  Localised title text to use for unnamed contacts.
williamr@4
   548
         */
williamr@4
   549
        IMPORT_C const TDesC& UnnamedTitle() const;
williamr@4
   550
williamr@4
   551
    public: // Searching
williamr@4
   552
        /**
williamr@4
   553
         * Call-through for new Phone number matching function in 6.2 version
williamr@4
   554
         * of class CContactDatabase. If you don't need any other functionality
williamr@4
   555
         * from CPbkContactEngine than this consider using the CContactDatabase
williamr@4
   556
         * API directly. See Symbian Contacts Model documentation for 
williamr@4
   557
         * CContactDatabase::MatchPhoneNumberL use.
williamr@4
   558
         *
williamr@4
   559
         * @see CContactDatabase::MatchPhoneNumberL(const TDesC&,const TInt)
williamr@4
   560
         */
williamr@4
   561
        IMPORT_C CContactIdArray* MatchPhoneNumberL
williamr@4
   562
            (const TDesC& aNumber, const TInt aMatchLengthFromRight);
williamr@4
   563
williamr@4
   564
        /**
williamr@4
   565
         * Searches all contacts in the database for aText.
williamr@4
   566
         *
williamr@4
   567
         * @param aText         Text to search.
williamr@4
   568
         * @param aFieldTypes   Phonebook fields types to <i>at least</i>
williamr@4
   569
         *                      include in the search. If NULL searches all
williamr@4
   570
         *                      fields.<br>
williamr@4
   571
         *                      <b>PLEASE NOTE:</b> The find matches in most
williamr@4
   572
         *                      cases also other fields than those specified
williamr@4
   573
         *                      in aFieldTypes. Always loop through the
williamr@4
   574
         *                      returned contacts to check match in the
williamr@4
   575
         *                      required fields.
williamr@4
   576
         * @return Array of matching contact IDs.
williamr@4
   577
         * @see CContactDatabase::FindLC.
williamr@4
   578
         */
williamr@4
   579
        IMPORT_C CContactIdArray* FindLC
williamr@4
   580
            (const TDesC& aText, const CPbkFieldIdArray* aFieldTypes=NULL);
williamr@4
   581
williamr@4
   582
        /**
williamr@4
   583
         * Searches all contacts in the database for aText asynchronously.
williamr@4
   584
         *
williamr@4
   585
         * @param aText         Text to search.
williamr@4
   586
         * @param aFieldTypes   Phonebook fields types to <i>at least</i>
williamr@4
   587
         *                      include in the search. If NULL searches all
williamr@4
   588
         *                      fields.<br>
williamr@4
   589
         *                      <b>PLEASE NOTE:</b> The find matches in most
williamr@4
   590
         *                      cases also other fields than those specified
williamr@4
   591
         *                      in aFieldTypes. Always loop through the
williamr@4
   592
         *                      returned contacts to check match in the
williamr@4
   593
         *                      required fields.
williamr@4
   594
         * @param  aObserver    Observer for this operation.
williamr@4
   595
         * @return  CPbkIdleFinder object which is used to access the find
williamr@4
   596
         *          results when complete. Deleting this object will cancel
williamr@4
   597
         *          this asyncronous find operation.
williamr@4
   598
         * @see CContactDatabase::FindAsyncL.
williamr@4
   599
         * @see CPbkIdleFinder
williamr@4
   600
         */
williamr@4
   601
	    IMPORT_C CPbkIdleFinder* FindAsyncL(
williamr@4
   602
            const TDesC& aText,
williamr@4
   603
            const CPbkFieldIdArray* aFieldTypes=NULL,
williamr@4
   604
            MIdleFindObserver *aObserver=NULL);
williamr@4
   605
williamr@4
   606
    public:  // Phonebook internal API
williamr@4
   607
        /**
williamr@4
   608
         * @internal
williamr@4
   609
         * Sets the compression UI for this engine.
williamr@4
   610
         * To be called by Phonebook only!
williamr@4
   611
         *
williamr@4
   612
         * @see MPbkCompressUi
williamr@4
   613
         * @see CheckCompress
williamr@4
   614
         * @see CancelCompress
williamr@4
   615
         * @deprecated
williamr@4
   616
         */
williamr@4
   617
        IMPORT_C void SetCompressUi(MPbkCompressUi* aCompressiUi);
williamr@4
   618
williamr@4
   619
        /**
williamr@4
   620
         * @internal
williamr@4
   621
         * Checks if the contact database needs a compression.
williamr@4
   622
         * To be called by Phonebook only!
williamr@4
   623
         *
williamr@4
   624
         * @see SetCompressUi
williamr@4
   625
         * @see CompressL
williamr@4
   626
         * @see CancelCompress
williamr@4
   627
         * @deprecated
williamr@4
   628
         */
williamr@4
   629
        IMPORT_C TBool CheckCompress();
williamr@4
   630
williamr@4
   631
        /**
williamr@4
   632
         * @internal
williamr@4
   633
         * Compresses the database if necessary. To be called by Phonebook only.
williamr@4
   634
         *
williamr@4
   635
         * @see SetCompressUi
williamr@4
   636
         * @see CancelCompress
williamr@4
   637
         * @deprecated
williamr@4
   638
         */
williamr@4
   639
        IMPORT_C void CompressL();
williamr@4
   640
williamr@4
   641
        /**
williamr@4
   642
         * @internal
williamr@4
   643
         * Call to cancel any ongoing database compression started with
williamr@4
   644
         * CheckCompressL(). Calls PbkCompressCanceled() for any registered
williamr@4
   645
         * compression UI. To be called by Phonebook only.
williamr@4
   646
         *
williamr@4
   647
         * @see SetCompressUi
williamr@4
   648
         * @see CheckCompress
williamr@4
   649
         * @deprecated
williamr@4
   650
         */
williamr@4
   651
        IMPORT_C void CancelCompress();
williamr@4
   652
williamr@4
   653
        /**
williamr@4
   654
         * @internal
williamr@4
   655
         * Checks current file system space and amount of wasted space in
williamr@4
   656
         * Phonebook's database. Compresses the database synchronously if
williamr@4
   657
         * Phonebook's database can be made smaller by compression. If file
williamr@4
   658
         * system space is still under critical level after compression,
williamr@4
   659
         * leaves with KErrDiskFull.
williamr@4
   660
         *
williamr@4
   661
         * @exception KErrDiskFull if file system is out of space.
williamr@4
   662
         * @deprecated
williamr@4
   663
         */
williamr@4
   664
        IMPORT_C void CheckFileSystemSpaceAndCompressL();
williamr@4
   665
williamr@4
   666
		/**
williamr@4
   667
		 * @internal
williamr@4
   668
		 * Phonebook name ordering information.
williamr@4
   669
         * @deprecated
williamr@4
   670
		 */
williamr@4
   671
		enum TPbkNameOrder
williamr@4
   672
			{
williamr@4
   673
			EPbkNameOrderLastNameFirstName = 0, /// Last name then first name order
williamr@4
   674
			EPbkNameOrderFirstNameLastName, /// First name then last name order
williamr@4
   675
			EPbkNameOrderNotDefined /// undefined name order
williamr@4
   676
			};
williamr@4
   677
williamr@4
   678
		/**
williamr@4
   679
		 * @internal
williamr@4
   680
		 * Sets name display order.
williamr@4
   681
		 * @param aNameOrder The ordering to use
williamr@4
   682
         * @deprecated
williamr@4
   683
		 */
williamr@4
   684
		IMPORT_C void SetNameDisplayOrderL(TPbkNameOrder aNameOrder);
williamr@4
   685
williamr@4
   686
		/**
williamr@4
   687
		 * @internal
williamr@4
   688
		 * Gets name display order.
williamr@4
   689
		 * @return The name ordering in use
williamr@4
   690
         * @deprecated
williamr@4
   691
		 */
williamr@4
   692
		IMPORT_C TPbkNameOrder NameDisplayOrderL();
williamr@4
   693
williamr@4
   694
		/**
williamr@4
   695
		 * @internal
williamr@4
   696
		 * Returns the phonebook constants object.
williamr@4
   697
         * @return Phonebook constants manager
williamr@4
   698
         * @deprecated
williamr@4
   699
		 */
williamr@4
   700
		IMPORT_C CPbkConstants* Constants();
williamr@4
   701
williamr@4
   702
        /**
williamr@4
   703
         * @internal
williamr@4
   704
         * Returns the sort order manager of the engine.
williamr@4
   705
         */
williamr@4
   706
        const CPbkSortOrderManager& SortOrderManager() const;
williamr@4
   707
williamr@4
   708
williamr@4
   709
		/**
williamr@4
   710
		 * @internal
williamr@4
   711
		 * Sets whether a separator character is shown between
williamr@4
   712
		 * last and first names.
williamr@4
   713
		 * @param aSeparator This parameter should contain the character to be
williamr@4
   714
		 *	      used as separator. If value is 0 then separator will not be
williamr@4
   715
		 * 	      used between names.
williamr@4
   716
		 */
williamr@4
   717
		IMPORT_C void SetNameSeparatorL(TChar aSeparator);
williamr@4
   718
williamr@4
   719
        /**
williamr@4
   720
		 * @internal
williamr@4
   721
		 * Return info on whether separator character is used between last
williamr@4
   722
		 * and first names.
williamr@4
   723
		 * @return The separator character. Empty (value 0) if there is no
williamr@4
   724
         *         separator.
williamr@4
   725
		 */
williamr@4
   726
		IMPORT_C TChar NameSeparator() const;
williamr@4
   727
williamr@4
   728
williamr@4
   729
williamr@4
   730
    private:  // from MContactDbObserver
williamr@4
   731
        void HandleDatabaseEventL(TContactDbObserverEvent aEvent);
williamr@4
   732
williamr@4
   733
    private:  // Interface for CPbkContactChangeNotifier
williamr@4
   734
        friend class CPbkContactChangeNotifier;
williamr@4
   735
        void AddObserverL(MPbkContactDbObserver* aObserver);
williamr@4
   736
        void RemoveObserver(MPbkContactDbObserver* aObserver);
williamr@4
   737
        void SendEventToAllObservers(const TContactDbObserverEvent& aEvent);
williamr@4
   738
williamr@4
   739
    private:  // Implementation
williamr@4
   740
		CPbkContactEngine();
williamr@4
   741
		void ConstructL(const TDesC* aFileName, TBool aReplace, RFs* aFs);
williamr@4
   742
        void ConnectFsL(RFs* aRfs);
williamr@4
   743
        void ReadResourcesL(TBool& aSettingsVisibility);
williamr@4
   744
        void CreateDbConnectionL(const TDesC* aFileName, 
williamr@4
   745
                                 TBool aReplace, 
williamr@4
   746
                                 TInt& aDbOpenError,
williamr@4
   747
                                 TBool aSettingsVisible);
williamr@4
   748
        void SendImmidiateEventToAllObservers(
williamr@4
   749
            TContactDbObserverEventType aEventType,
williamr@4
   750
            TContactItemId aContactId, TBool aSendEvent);
williamr@4
   751
        void doDeleteContactL(TContactItemId aContactId);
williamr@4
   752
        class CContactDbConnection;
williamr@4
   753
        friend class CContactDbConnection;
williamr@4
   754
		friend class CPbkSharedDataObserver;
williamr@4
   755
williamr@4
   756
    private:  // Data
williamr@4
   757
        /// Ref: file server connection
williamr@4
   758
        RFs iFs;
williamr@4
   759
        /// Own: file server connection
williamr@4
   760
        RFs iOwnFs;
williamr@4
   761
        /// Own: Contact database connection object.
williamr@4
   762
		CContactDbConnection* iDbConnection;
williamr@4
   763
        /// Own: Observer array
williamr@4
   764
        CArrayPtr<MPbkContactDbObserver>* iObservers;
williamr@4
   765
        /// Own: fields info array.
williamr@4
   766
        CPbkFieldsInfo* iPbkFieldsInfo;
williamr@4
   767
        /// Own: Phonebook constants
williamr@4
   768
        CPbkConstants* iPbkConstants;
williamr@4
   769
        /// Own: shared data client
williamr@4
   770
        RSharedDataClient* iSharedDataClient;
williamr@4
   771
        /// Own: maximum free space required to delete a contact from the DB
williamr@4
   772
        TInt iFreeSpaceRequiredToDelete;
williamr@4
   773
        /// Own: Engine extension interface
williamr@4
   774
        CPbkEngineExtension* iExtension;
williamr@4
   775
        /// Is separator used between first- and last-names of contacts
williamr@4
   776
        TBool iUseSeparator;
williamr@4
   777
        /// The separator to be used between first- and last-names of contacts
williamr@4
   778
        TChar iSeparator;
williamr@4
   779
        /// CPbkSINDHandler instance identifier key.
williamr@4
   780
        TUid iDtorIDKey;
williamr@4
   781
        /// Own: SIND Handler
williamr@4
   782
        CPbkSINDHandlerInterface* iSINDHandler;
williamr@4
   783
williamr@4
   784
williamr@4
   785
williamr@4
   786
    };
williamr@4
   787
williamr@4
   788
#endif   // __CPBKCONTACTENGINE_H__
williamr@4
   789
williamr@4
   790
// End of File