|
1 /** |
|
2 * Copyright (c) 2005-2009 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: |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 |
|
20 /** |
|
21 @file |
|
22 @internalComponent |
|
23 @released |
|
24 */ |
|
25 |
|
26 #ifndef CCNTDBMANAGER_H |
|
27 #define CCNTDBMANAGER_H |
|
28 |
|
29 #include "persistencelayer.h" |
|
30 #include "CCntLowDiskManager.h" |
|
31 #include <e32base.h> |
|
32 |
|
33 |
|
34 enum TCntFileMode |
|
35 { |
|
36 ECntFileOpen, |
|
37 ECntFileCreate, |
|
38 ECntFileReplace |
|
39 }; |
|
40 |
|
41 class CPersistenceLayer; |
|
42 class CCntStateMachine; |
|
43 class CCntRequest; |
|
44 class CCntBackupRestoreAgent; |
|
45 class CIniFileManager; |
|
46 class CViewManager; |
|
47 |
|
48 |
|
49 /** |
|
50 Low disk threshold is set at 128Kb. Below this threshold only database |
|
51 operations which decrease the size of the database file are allowed. |
|
52 */ |
|
53 const TInt64 KLowDiskThreshold = 0x20000; |
|
54 |
|
55 |
|
56 /** |
|
57 The CCntDbManager class represents the most abstract level of access to the |
|
58 Contacts database. |
|
59 |
|
60 There is one CCntDbManager class per Contacts database. Multiple sessions |
|
61 (CCntSession objects) can be mapped to one CCntDbManager. |
|
62 |
|
63 Multiple instances of the CCntDbManager class are controlled by the one |
|
64 CCntDbManagerController instance (owned by CCntServer2). |
|
65 */ |
|
66 class CCntDbManager : public CBase, public MContactDbObserver, public MContactLowDiskObserver, public MIniFileManager |
|
67 { |
|
68 public: |
|
69 static CCntDbManager* NewLC(RFs& aFs, const TDesC& aCntFile, TCntFileMode aFileMode, CCntBackupRestoreAgent& aBackupRestoreAgent, CIniFileManager& aIniManager); |
|
70 virtual ~CCntDbManager(); |
|
71 |
|
72 void AddSession(); |
|
73 void RemoveSession(); |
|
74 TInt SessionCount() const; |
|
75 |
|
76 // Access methods. |
|
77 CPersistenceLayer& GetPersistenceLayer(); |
|
78 CCntStateMachine& StateMachineL(); |
|
79 CCntBackupRestoreAgent& BackupRestoreAgent(); |
|
80 CIniFileManager& IniFileManager(); |
|
81 CViewManager& ViewManagerL(); |
|
82 |
|
83 // Database file methods. |
|
84 const TDesC& CntFile(); |
|
85 TInt FileSizeL(); |
|
86 |
|
87 void RegisterDatabaseEventObserverL(MContactDbObserver& aObserver); |
|
88 void UnRegisterDatabaseEventObserver(MContactDbObserver& aObserver); |
|
89 |
|
90 // From MContactDbObserver. |
|
91 void HandleDatabaseEventL(TContactDbObserverEvent aEvent); |
|
92 void HandleBackupRestoreEventL(TContactDbObserverEvent aEvent); |
|
93 void HandleLowDiskL(TBool aLowDisk); |
|
94 |
|
95 void NotifyObserversL(const TContactDbObserverEvent aEvent); |
|
96 |
|
97 // Current item methods. |
|
98 void SetCurrentItemL(TContactItemId aContactId, TUint aConnectionId); |
|
99 TContactItemId CurrentItem() const; |
|
100 void RemoveCurrentItemL(TUint aConnectionId); |
|
101 void DeleteNotifyL(TContactItemId aContactId); |
|
102 |
|
103 // Speed dial methods. |
|
104 void GetSpeedDialContactIdAndPhoneNumberL(const TInt aSpeedDialIndex, TSpeedDialPhoneNumber& aPhoneNumber, TContactItemId& aContactId); |
|
105 TContactItemId SetSpeedDialIdForPositionL(const TInt aSpeedDialIndex, const TContactItemId aContactId, const TSpeedDialPhoneNumber& aPhoneNumber, TUint aConnectionId, TBool aSendNotification); |
|
106 CArrayFix<TInt>* SpeedDialIndicesForContactIdLC(TContactItemId aContactId); |
|
107 |
|
108 void SetCardTemplatePrefIdL(TContactItemId aCardTemplatePrefId, TInt aConnectionId); |
|
109 void RecreateSystemTemplateL(); |
|
110 |
|
111 private: |
|
112 void ConstructL(TCntFileMode aFileMode); |
|
113 CCntDbManager(RFs& aFs, const TDesC& aCntFile, CCntBackupRestoreAgent& aBackupRestoreAgent, CIniFileManager& aIniManager); |
|
114 |
|
115 // Access methods. |
|
116 CCntLowDiskManager& LowDiskManagerL(); |
|
117 |
|
118 private: |
|
119 CCntStateMachine* iStateMachine; |
|
120 CCntLowDiskManager* iLowDiskManager; |
|
121 CPersistenceLayer* iPersistenceLayer; |
|
122 CViewManager* iViewManager; |
|
123 |
|
124 RFs& iFs; |
|
125 TFileName iCntFile; |
|
126 |
|
127 CCntBackupRestoreAgent& iBackupRestoreAgent; |
|
128 CIniFileManager& iIniManager; |
|
129 |
|
130 TInt iSessionCount; |
|
131 |
|
132 // Array of registered database event observers. |
|
133 RPointerArray<MContactDbObserver> iObserverArray; |
|
134 }; |
|
135 |
|
136 |
|
137 #endif |