|
1 /** |
|
2 * Copyright (c) 2007-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 __PPLCONTACTITEMMANAGER_H__ |
|
27 #define __PPLCONTACTITEMMANAGER_H__ |
|
28 |
|
29 #include <e32base.h> |
|
30 #include <sqldb.h> |
|
31 #include "cntsqlprovider.h" |
|
32 #include "clplcontactproperties.h" |
|
33 #include "persistencelayer.h" |
|
34 #include "rpplicccontactstore.h" |
|
35 |
|
36 class CPplTableBase; |
|
37 class CPplPreferencesPersistor; |
|
38 |
|
39 /** |
|
40 The CPplContactItemManager implements the MLplPersistenceBroker. |
|
41 |
|
42 MLplPersistenceBroker is a public interface responsible for carrying out the |
|
43 basic crud operations (Create, Read, Update, Delete). It is exposed to the users |
|
44 of Persistence Layer making the CPplContactItemManager an entry point for these |
|
45 operations. |
|
46 |
|
47 CPplContactItemManager is responsible to forward the Create, Delete and Update calls |
|
48 to the CPplTableBase based object representing actual tables in the contact database. |
|
49 CPplContactItemManager holds the knowledge of the database structure: how many tables |
|
50 and what tables compose the contact database. |
|
51 |
|
52 The Read operation is managed inside CPplContactItemManager and not passed to the table |
|
53 classes. |
|
54 */ |
|
55 NONSHARABLE_CLASS(CPplContactItemManager): public CBase, public MLplPersistenceBroker, public MLplFieldMatcher |
|
56 { |
|
57 public: |
|
58 static CPplContactItemManager* NewL(RSqlDatabase& aDatabase, MLplTransactionManager& aTransactionManager, CLplContactProperties& aContactProperties, RPplIccContactStore& aIccContactStore); |
|
59 ~CPplContactItemManager(); |
|
60 TContactItemId CreateL(CContactItem& aItem, TUint aSessionId); |
|
61 CContactItem* ReadLC(TContactItemId aItemId, const CContactItemViewDef& aView, TInt aInfoToRead, TUint aSessionId, TBool aIccOpenCheck = EFalse) const; |
|
62 void UpdateL(CContactItem& aItem, TUint aSessionId, TBool aSpeeDailUpdate = EFalse); |
|
63 CContactItem* DeleteLC(TContactItemId aItemId, TUint aSessionId, TCntSendEventAction aEventType); |
|
64 void ChangeTypeL(TContactItemId aItemId, TUid aNewType); |
|
65 void SetConnectionId(TInt aConnectionId); |
|
66 void CreateTablesL(); |
|
67 CContactIdArray* MatchPhoneNumberL(const TDesC& aNumber, TInt aMatchLengthFromRight); |
|
68 TBool IsDatabaseEmptyL(); |
|
69 CPplPreferencesPersistor& PreferencesPersitor(); |
|
70 CContactIdArray* GroupIdListL(); |
|
71 CContactIdArray& CardTemplateIdsL(); |
|
72 TContactItemId OwnCardIdL(); |
|
73 void SetOwnCardIdL(TContactItemId aId); |
|
74 TInt CardTemplatePrefIdL() const; |
|
75 void SetCardTemplatePrefIdL(TInt aCardTemplatePrefId); |
|
76 |
|
77 private: |
|
78 CPplContactItemManager(RSqlDatabase& aDatabase, MLplTransactionManager& aTransactionManager, CLplContactProperties& aContactProperties, RPplIccContactStore& aIccContactStore); |
|
79 void ConstructL(); |
|
80 static void CleanupOperationRollbackL(TAny* aDatabase); |
|
81 |
|
82 void StartTransactionL(TUint aSessionId); |
|
83 void CommitTransactionL(); |
|
84 |
|
85 TInt NameFieldIndex(const CContactItemField& aNameField) const; |
|
86 void DeleteInLowDiskConditionL(CPplTableBase* aTable, CContactItem* aContactItem); |
|
87 |
|
88 private: |
|
89 RSqlDatabase& iDatabase; // CPplContactItemManager does not own the RSqlDatabase object |
|
90 MLplTransactionManager& iTransactionManager; |
|
91 TUint iSessionId; |
|
92 CCntSqlStatement* iSelectStatement; |
|
93 CLplContactProperties& iContactProperties; |
|
94 CPplTableBase* iContactTable; |
|
95 CPplTableBase* iGroupTable; |
|
96 CPplTableBase* iCommAddrTable; |
|
97 CPplPreferencesPersistor* iPreferencePersistor; |
|
98 RPplIccContactStore& iIccContactStore; |
|
99 }; |
|
100 |
|
101 #endif // __PPLCONTACTITEMMANAGER_H__ |