1 // Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). |
|
2 // All rights reserved. |
|
3 // This component and the accompanying materials are made available |
|
4 // under the terms of "Eclipse Public License v1.0" |
|
5 // which accompanies this distribution, and is available |
|
6 // at the URL "http://www.eclipse.org/legal/epl-v10.html". |
|
7 // |
|
8 // Initial Contributors: |
|
9 // Nokia Corporation - initial contribution. |
|
10 // |
|
11 // Contributors: |
|
12 // |
|
13 // Description: |
|
14 // |
|
15 |
|
16 /** |
|
17 @file |
|
18 @internalTechnology |
|
19 */ |
|
20 |
|
21 #ifndef CMEDIASYNCDATABASE_H |
|
22 #define CMEDIASYNCDATABASE_H |
|
23 |
|
24 #include <d32dbms.h> |
|
25 #include <comms-infras/commsdebugutility.h> |
|
26 #include <mdesession.h> |
|
27 #include <mdccommon.h> |
|
28 #include <comms-infras/commsdebugutility.h> |
|
29 |
|
30 class CMediaSyncDataWriter; |
|
31 class CMdESession; |
|
32 |
|
33 class CMediaSyncDatabase : public CBase |
|
34 { |
|
35 public: |
|
36 static CMediaSyncDatabase* NewL(RFs& aFs); |
|
37 ~CMediaSyncDatabase(); |
|
38 |
|
39 /** |
|
40 * Save MDS notification to database |
|
41 * |
|
42 * @param aObjectIdArray array of changed object id |
|
43 * @param aChangeType type of change related with this changed object |
|
44 * |
|
45 */ |
|
46 void SaveNotificationsL(const RArray<TItemId>& aObjectIdArray, TObserverNotificationType aType, CMdESession& aSession); |
|
47 |
|
48 /** |
|
49 * Save MDS notification to database |
|
50 * |
|
51 * @param aObjectIdArray object IDs which are set to present statect |
|
52 * @param aPresent state: ETrue - present or EFales - not present |
|
53 * |
|
54 */ |
|
55 void SaveNotificationsL(const RArray<TItemId>& aObjectIdArray, TBool aPresent, CMdESession& aSession); |
|
56 |
|
57 /** |
|
58 * Delete all notification record from database |
|
59 * |
|
60 */ |
|
61 void RemoveAllNotificationsL(); |
|
62 |
|
63 /** |
|
64 * Delete specific notificaion by object id |
|
65 * |
|
66 * @param aObjectId changed object id |
|
67 * |
|
68 */ |
|
69 TBool RemoveNotificationL(TItemId aObjectId, TUint aType); |
|
70 |
|
71 /** |
|
72 * Get notification record from database |
|
73 * |
|
74 * @param aResulWriter on return contains serialized results |
|
75 * @param aIsFinished flag indicate whether all record has been fetched |
|
76 */ |
|
77 void FetchNotificationsL(CMediaSyncDataWriter& aResulWriter, TInt aMaxtFetchCount, TBool& aIsFinished); |
|
78 |
|
79 /** |
|
80 * Rollback the current transaction |
|
81 */ |
|
82 void Rollback(); |
|
83 |
|
84 /** |
|
85 * Check whether DB file is corrupt |
|
86 */ |
|
87 inline TBool IsMssDbCorrupt() { return iDbCorrupt; } |
|
88 |
|
89 /** |
|
90 * Clear DB corrupt flag |
|
91 */ |
|
92 inline void ClearMssDbCorrupt() { iDbCorrupt = EFalse; } |
|
93 |
|
94 private: |
|
95 CMediaSyncDatabase(RFs& aFs); |
|
96 void ConstructL(); |
|
97 void CreateTableL(const TDesC& aDbFile); |
|
98 void CreateTabIndexL(); |
|
99 |
|
100 void SaveAddNotificationsL(const RArray<TItemId>& aObjectIdArray, CMdESession& aSession); |
|
101 void SaveAndCheckWithUriL(const RArray<TItemId>& aObjectIdArray, TUint aType, CMdESession& aSession); |
|
102 void SaveWithoutUriL(const RArray<TItemId>& aObjectIdArray, TUint aType); |
|
103 void CompactDatabase(); |
|
104 |
|
105 TBool UpdateUriColumnL(TItemId aObjectId, TUint aType, const TDesC& aUri); |
|
106 TBool OptimizeL(TItemId aObjectId, TUint aType, const TDesC& aUri); |
|
107 inline TBool OptimizeL(TItemId aObjectId, TUint aType); |
|
108 |
|
109 static void RollbackTable(TAny* aTable); |
|
110 |
|
111 private: |
|
112 /** |
|
113 FLOGGER debug trace member variable. |
|
114 */ |
|
115 __FLOG_DECLARATION_MEMBER_MUTABLE; |
|
116 |
|
117 RFs& iFs; |
|
118 RDbNamedDatabase iDatabase; |
|
119 RDbTable iBatched; |
|
120 TBool iDbCorrupt;// flag that indicate whether database is corrupt |
|
121 TBool iSavePosition; |
|
122 TDbBookmark iBookmark; |
|
123 TInt iCompactCounter; |
|
124 }; |
|
125 |
|
126 #endif /*CMEDIASYNCDATABASE_H*/ |
|