cpbkcontactengine.h

Go to the documentation of this file.
00001 /*
00002 * ============================================================================
00003 *  Name     : CPbkContactEngine.h from PbkEng.dll
00004 *  Part of  : PbkEng.dll
00005 *
00006 *  Description:
00007 *     Represents a connection to the Phonebook contact database
00008 *  Version:
00009 *
00010 *  Copyright (C) 2002 Nokia Corporation.
00011 *  This material, including documentation and any related
00012 *  computer programs, is protected by copyright controlled by
00013 *  Nokia Corporation. All rights are reserved. Copying,
00014 *  including reproducing, storing,  adapting or translating, any
00015 *  or all of this material requires the prior written consent of
00016 *  Nokia Corporation. This material also contains confidential
00017 *  information which may not be disclosed to others without the
00018 *  prior written consent of Nokia Corporation.
00019 * ============================================================================
00020 */
00021 
00022 #ifndef __CPBKCONTACTENGINE_H__
00023 #define __CPBKCONTACTENGINE_H__
00024 
00025 //  INCLUDES
00026 #include <e32base.h>        // CBase
00027 #include <cntdef.h>         // TContactItemId
00028 #include <cntdbobs.h>       // MContactDbObserver
00029 #include <f32file.h>        // RFs
00030 #include "PbkFields.hrh"    // TPbkFieldId
00031 
00032 
00033 // FORWARD DECLARATIONS
00034 class CContactDatabase;
00035 class MIdleFindObserver;
00036 class MPbkContactDbObserver;
00037 class CContactGroup;
00038 class CPbkFieldsInfo;
00039 class CPbkContactItem;
00040 class CPbkContactIter;
00041 class CPbkContactChangeNotifier;
00042 class CPbkIdleFinder;
00043 class MPbkCompressUi;
00044 class CPbkConstants;
00045 class MPbkContactNameFormat;
00046 class MPbkFieldDataArray;
00047 class CContactViewBase;
00048 class CContactItem;
00049 class RSharedDataClient;
00050 class TResourceReader;
00051 class CPbkEngineExtension;
00052 class CPbkSortOrderManager;
00053 class CPbkSINDHandlerInterface;
00054 
00055 
00056 // CLASS DECLARATION
00057 
00066 class   CPbkContactEngine :
00067         public CBase,
00068         private MContactDbObserver
00069     {
00070     public: // Constructors and destructor
00083                 IMPORT_C static CPbkContactEngine* NewL(RFs* aFs=NULL);
00084 
00103                 IMPORT_C static CPbkContactEngine* NewL
00104             (const TDesC& aFileName, TBool aReplace=EFalse, RFs* aFs=NULL);
00105 
00119         IMPORT_C static CPbkContactEngine* ReplaceL(RFs* aFs=NULL);
00120 
00128                 ~CPbkContactEngine();
00129 
00130     public: // Accessors
00140         IMPORT_C static CPbkContactEngine* Static();
00141 
00149         IMPORT_C CContactDatabase& Database();
00150 
00156         IMPORT_C const CPbkFieldsInfo& FieldsInfo();
00157 
00162         IMPORT_C RFs& FsSession() const;
00163 
00164     public:  // Creating contacts
00169         IMPORT_C CPbkContactItem* CreateEmptyContactL();
00170 
00182         IMPORT_C TContactItemId AddNewContactL
00183             (CPbkContactItem& aContact, TBool aImmediateNotify=EFalse);
00184 
00195         IMPORT_C TContactItemId DuplicateContactL
00196             (TContactItemId aId, TBool aImmediateNotify=EFalse);
00197 
00198     public:  // Reading contacts
00213         IMPORT_C CPbkContactItem* ReadContactL
00214             (TContactItemId aContactId, const CPbkFieldIdArray* aFieldTypes=NULL);
00215 
00230         IMPORT_C CPbkContactItem* ReadContactLC
00231             (TContactItemId aContactId, const CPbkFieldIdArray* aFieldTypes=NULL);
00232 
00242         IMPORT_C CPbkContactItem* ReadMinimalContactLC(TContactItemId aContactId);
00243 
00252         IMPORT_C CPbkContactIter* CreateContactIteratorLC
00253             (TBool aUseMinimalRead=EFalse);
00254 
00255     public:  // Modifying contacts
00262         IMPORT_C CPbkContactItem* OpenContactL(TContactItemId aContactId);
00263 
00274         IMPORT_C CPbkContactItem* OpenContactLCX(TContactItemId aContactId);
00275 
00287         IMPORT_C void CommitContactL
00288             (CPbkContactItem& aContact, TBool aImmediateNotify=EFalse);
00289 
00295         IMPORT_C void CloseContactL(TContactItemId aContactId);
00296 
00297     public:  // Deleting contacts
00307         IMPORT_C void DeleteContactL
00308             (TContactItemId aContactId, TBool aImmediateNotify=EFalse);
00309 
00319         IMPORT_C void DeleteContactsL
00320             (const CContactIdArray& aContactIds, TBool aImmediateNotify=EFalse);
00321 
00328         IMPORT_C void DeleteContactsOnBackgroundL
00329             (const CContactIdArray& aContactIds);
00330 
00331     public:  // Contact groups
00340         IMPORT_C CContactGroup* CreateContactGroupL
00341             (const TDesC& aGroupLabel,TBool aInTransaction=EFalse);
00342 
00350         IMPORT_C void AddContactToGroupL
00351             (TContactItemId aItemId, TContactItemId aGroupId);
00352 
00360         IMPORT_C void RemoveContactFromGroupL
00361             (TContactItemId aItemId, TContactItemId aGroupId);
00362 
00370         IMPORT_C CContactGroup* ReadContactGroupL(TContactItemId aId);
00371 
00379         IMPORT_C CContactGroup* OpenContactGroupL(TContactItemId aId);
00380 
00389         IMPORT_C CContactGroup* OpenContactGroupLCX(TContactItemId aId);
00390 
00401         IMPORT_C void CommitContactGroupL(CContactGroup& aGroup, TBool aImmediateNotify=EFalse);
00402 
00412         IMPORT_C void DeleteContactGroupL
00413             (TContactItemId aContactId, TBool aImmediateNotify=EFalse);
00414 
00415     public:  // Speed dials
00425         IMPORT_C void SetFieldAsSpeedDialL
00426             (CPbkContactItem& aItem, TInt aFieldIndex, TInt aSpeedDialPosition);
00427 
00435         IMPORT_C TContactItemId GetSpeedDialFieldL
00436             (TInt aSpeedDialPosition, TDes& aPhoneNumber) const;
00437 
00445         IMPORT_C void RemoveSpeedDialFieldL
00446             (TContactItemId aContactId, TInt aSpeedDialPosition);
00447 
00456         IMPORT_C TBool IsSpeedDialAssigned
00457             (const CPbkContactItem& aItem, TInt aFieldIndex) const;
00458 
00459     public:  // Contact views
00467         IMPORT_C CContactViewBase& AllContactsView();
00468 
00476         IMPORT_C CContactViewBase& AllGroupsViewL();
00477 
00485         IMPORT_C CContactViewBase& FilteredContactsViewL(TInt aFilter);
00486 
00487     public:  // Events
00499         IMPORT_C CPbkContactChangeNotifier* CreateContactChangeNotifierL
00500             (MPbkContactDbObserver* aObserver);
00501 
00502     public:  // Contact name formatting
00512         IMPORT_C HBufC* GetContactTitleL(const CPbkContactItem& aItem) const;
00513 
00523         IMPORT_C HBufC* GetContactTitleOrNullL
00524             (const MPbkFieldDataArray& aContactData);
00525 
00536         IMPORT_C TBool IsTitleField(TPbkFieldId aFieldId) const;
00537 
00545         IMPORT_C MPbkContactNameFormat& ContactNameFormat() const;
00546 
00551         IMPORT_C const TDesC& UnnamedTitle() const;
00552 
00553     public: // Searching
00563         IMPORT_C CContactIdArray* MatchPhoneNumberL
00564             (const TDesC& aNumber, const TInt aMatchLengthFromRight);
00565 
00581         IMPORT_C CContactIdArray* FindLC
00582             (const TDesC& aText, const CPbkFieldIdArray* aFieldTypes=NULL);
00583 
00603             IMPORT_C CPbkIdleFinder* FindAsyncL(
00604             const TDesC& aText,
00605             const CPbkFieldIdArray* aFieldTypes=NULL,
00606             MIdleFindObserver *aObserver=NULL);
00607 
00608     public:  // Phonebook internal API
00619         IMPORT_C void SetCompressUi(MPbkCompressUi* aCompressiUi);
00620 
00631         IMPORT_C TBool CheckCompress();
00632 
00641         IMPORT_C void CompressL();
00642 
00653         IMPORT_C void CancelCompress();
00654 
00666         IMPORT_C void CheckFileSystemSpaceAndCompressL();
00667 
00673                 enum TPbkNameOrder
00674                         {
00675                         EPbkNameOrderLastNameFirstName = 0, 
00676                         EPbkNameOrderFirstNameLastName, 
00677                         EPbkNameOrderNotDefined 
00678                         };
00679 
00686                 IMPORT_C void SetNameDisplayOrderL(TPbkNameOrder aNameOrder);
00687 
00694                 IMPORT_C TPbkNameOrder NameDisplayOrderL();
00695 
00702                 IMPORT_C CPbkConstants* Constants();
00703 
00708         const CPbkSortOrderManager& SortOrderManager() const;
00709 
00710 
00719                 IMPORT_C void SetNameSeparatorL(TChar aSeparator);
00720 
00728                 IMPORT_C TChar NameSeparator() const;
00729 
00730 
00731 
00732     private:  // from MContactDbObserver
00733         void HandleDatabaseEventL(TContactDbObserverEvent aEvent);
00734 
00735     private:  // Interface for CPbkContactChangeNotifier
00736         friend class CPbkContactChangeNotifier;
00737         void AddObserverL(MPbkContactDbObserver* aObserver);
00738         void RemoveObserver(MPbkContactDbObserver* aObserver);
00739         void SendEventToAllObservers(const TContactDbObserverEvent& aEvent);
00740 
00741     private:  // Implementation
00742                 CPbkContactEngine();
00743                 void ConstructL(const TDesC* aFileName, TBool aReplace, RFs* aFs);
00744         void ConnectFsL(RFs* aRfs);
00745         void ReadResourcesL(TBool& aSettingsVisibility);
00746         void CreateDbConnectionL(const TDesC* aFileName, 
00747                                  TBool aReplace, 
00748                                  TInt& aDbOpenError,
00749                                  TBool aSettingsVisible);
00750         void SendImmidiateEventToAllObservers(
00751             TContactDbObserverEventType aEventType,
00752             TContactItemId aContactId, TBool aSendEvent);
00753         void doDeleteContactL(TContactItemId aContactId);
00754         class CContactDbConnection;
00755         friend class CContactDbConnection;
00756                 friend class CPbkSharedDataObserver;
00757 
00758     private:  // Data
00760         RFs iFs;
00762         RFs iOwnFs;
00764                 CContactDbConnection* iDbConnection;
00766         CArrayPtr<MPbkContactDbObserver>* iObservers;
00768         CPbkFieldsInfo* iPbkFieldsInfo;
00770         CPbkConstants* iPbkConstants;
00772         RSharedDataClient* iSharedDataClient;
00774         TInt iFreeSpaceRequiredToDelete;
00776         CPbkEngineExtension* iExtension;
00778         TBool iUseSeparator;
00780         TChar iSeparator;
00782         TUid iDtorIDKey;
00784         CPbkSINDHandlerInterface* iSINDHandler;
00785 
00786 
00787 
00788     };
00789 
00790 // __CPBKCONTACTENGINE_H__
00791 #endif
00792 
00793 // End of File

Copyright © Nokia Corporation 2001-2008
Back to top