|
1 // Copyright (c) 2006-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 #ifndef __DSCDATABASE_H__ |
|
17 #define __DSCDATABASE_H__ |
|
18 |
|
19 #include <d32dbms.h> |
|
20 #include <dscstoredefs.h> |
|
21 |
|
22 |
|
23 |
|
24 extern const TInt KDscStoreMaxStringLength; |
|
25 |
|
26 class CDscItem; |
|
27 |
|
28 /** |
|
29 A database of DSC items |
|
30 |
|
31 @internalComponent |
|
32 @released |
|
33 */ |
|
34 class CDscDatabase: public CBase |
|
35 { |
|
36 public: |
|
37 static CDscDatabase* NewL(); |
|
38 ~CDscDatabase(); |
|
39 |
|
40 void CreateDscL(const TUid& aDscId, const TDesC& aDescription); |
|
41 void DeleteDscL(const TUid& aDscId); |
|
42 TBool DscExistsL(const TUid& aDscId) const; |
|
43 void GetDscDescriptionL(const TUid &aDscId, TDes& aDescription) const; |
|
44 |
|
45 void AddItemL(CDscItem& aItem, TDscPosition aPos); |
|
46 void ReadItemL(CDscItem& aItem); |
|
47 void DeleteItemL(const CDscItem& aItem); |
|
48 |
|
49 void UpdateItemL(const CDscItem& aItem); |
|
50 TBool ItemExistsL(const CDscItem& aItem) const; |
|
51 |
|
52 void EnumOpenLC(const TUid& aDscId); |
|
53 CDscItem* EnumReadNextL(); |
|
54 void EnumClose(); |
|
55 |
|
56 static TInt MaxStringLength(); |
|
57 |
|
58 private: |
|
59 CDscDatabase(); |
|
60 void ConstructL(); |
|
61 void CreateDatabaseL(const TDesC& aDatabaseName); |
|
62 void CreateTablesL(); |
|
63 |
|
64 void QueryItemL(RDbView& aView, const CDscItem& aItem) const; |
|
65 void ReadDscItemL(RDbRowSet& rowSet, CDscItem& aItem) const; |
|
66 TInt GetNextItemIdL(TDscPosition aPos, const TUid& aDscId) const; |
|
67 |
|
68 void Rollback(); |
|
69 void DatabaseBeginLC(); |
|
70 void DatabaseCommitL(); |
|
71 static void CleanupDatabaseRollback(TAny *aDatabase); |
|
72 static void CleanupEnumRollback(TAny *aDatabase); |
|
73 void EnumBeginLC(); |
|
74 TInt DeleteDb(); |
|
75 static void GetDatabaseNameL(TDes& aDatabaseName); |
|
76 |
|
77 private: |
|
78 RDbs iDbsSession; |
|
79 mutable RDbNamedDatabase iDatabase; |
|
80 RDbView iView; |
|
81 TBool iIsEnumOpened; |
|
82 }; |
|
83 |
|
84 #endif // __DSCDATABASE_H__ |