|
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: Part of SyncML Data Synchronization Plug In Adapter |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 #ifndef __BOOKMARKDATASTORE_H__ |
|
20 #define __BOOKMARKDATASTORE_H__ |
|
21 |
|
22 #include <SmlDataProvider.h> |
|
23 #include <favouritesdb.h> |
|
24 #include <nsmlchangefinder.h> |
|
25 |
|
26 #include <feedsserverclient.h> |
|
27 #include <feedsserverfolderitem.h> |
|
28 |
|
29 class CNSmlDataItemUidSet; |
|
30 class CFavouritesItem; |
|
31 class CBookmarkConversionUtil; |
|
32 class RFeedsServer; |
|
33 class CChangeFinder; |
|
34 class TSnapshotItem; |
|
35 |
|
36 class CBookmarkDataStore : public CSmlDataStore, |
|
37 public MFolderItemObserver, |
|
38 public MFeedsServerObserver |
|
39 { |
|
40 private: |
|
41 |
|
42 CBookmarkDataStore(); |
|
43 ~CBookmarkDataStore(); |
|
44 |
|
45 public: |
|
46 |
|
47 static CBookmarkDataStore* NewL(); |
|
48 static CBookmarkDataStore* NewLC(); |
|
49 void ConstructL(); |
|
50 |
|
51 // Transactions (optional) |
|
52 void DoBeginTransactionL(); |
|
53 void DoCommitTransactionL(TRequestStatus& aStatus); |
|
54 void DoRevertTransaction(TRequestStatus& aStatus); |
|
55 |
|
56 // Batching (optional) |
|
57 void DoBeginBatchL(); |
|
58 void DoCommitBatchL(RArray<TInt>& aResultArray, TRequestStatus& aStatus); |
|
59 void DoCancelBatch(); |
|
60 |
|
61 // Opens data store asynchronously |
|
62 void DoOpenL(const TDesC& aStoreName, MSmlSyncRelationship& aContext, TRequestStatus& aStatus); |
|
63 // Cancels current asynchronous request |
|
64 void DoCancelRequest(); |
|
65 // Returns the name of open database, empty if OpenL hasn't been called |
|
66 const TDesC& DoStoreName() const; |
|
67 // Sets remote server data format |
|
68 void DoSetRemoteStoreFormatL(const CSmlDataStoreFormat& aServerDataStoreFormat); |
|
69 // Sets the remote server maximum object size |
|
70 void DoSetRemoteMaxObjectSize(TInt aServerMaxObjectSize); |
|
71 // Returns maximum object size, reported by remote server |
|
72 TInt DoMaxObjectSize() const; |
|
73 |
|
74 // Opens item for reading |
|
75 void DoOpenItemL(TSmlDbItemUid aUid, TBool& aFieldChange, TInt& aSize, |
|
76 TSmlDbItemUid& aParent, TDes8& aMimeType, TDes8& aMimeVer, TRequestStatus& aStatus); |
|
77 // Initializes new item to data store |
|
78 void DoCreateItemL(TSmlDbItemUid& aUid, TInt aSize, TSmlDbItemUid aParent, |
|
79 const TDesC8& aMimeType, const TDesC8& aMimeVer, TRequestStatus& aStatus); |
|
80 // Initializes replace of item in data store |
|
81 void DoReplaceItemL(TSmlDbItemUid aUid, TInt aSize, TSmlDbItemUid aParent, |
|
82 TBool aFieldChange, TRequestStatus& aStatus); |
|
83 // Reads data from opened item |
|
84 void DoReadItemL(TDes8& aBuffer); |
|
85 // Writes data to created or replaced item |
|
86 void DoWriteItemL(const TDesC8& aData); |
|
87 // Commits the created or replaced item to database |
|
88 void DoCommitItemL(TRequestStatus& aStatus); |
|
89 // Closes the opened item |
|
90 void DoCloseItem(); |
|
91 // Moves item in the database |
|
92 void DoMoveItemL(TSmlDbItemUid aUid, TSmlDbItemUid aNewParent, TRequestStatus& aStatus); |
|
93 // Deletes item from the database |
|
94 void DoDeleteItemL(TSmlDbItemUid aUid, TRequestStatus& aStatus); |
|
95 // Soft deletes item (if supported by plugin adapter), can be equal to DoDeleteItemL |
|
96 void DoSoftDeleteItemL(TSmlDbItemUid aUid, TRequestStatus& aStatus); |
|
97 // Deletes all items from the database |
|
98 void DoDeleteAllItemsL(TRequestStatus& aStatus); |
|
99 |
|
100 // Returns, whether data store has history info. EFalse means slow sync |
|
101 TBool DoHasSyncHistory() const; |
|
102 // Returns ids of items, which are added after previous synchronization |
|
103 const MSmlDataItemUidSet& DoAddedItems() const; |
|
104 // Returns ids of items, which are deleted after previous synchronization |
|
105 const MSmlDataItemUidSet& DoDeletedItems() const; |
|
106 // Returns ids of items, which are soft-deleted after previous synchronization |
|
107 const MSmlDataItemUidSet& DoSoftDeletedItems() const; |
|
108 // Returns ids of items, which are modified after previous synchronization |
|
109 const MSmlDataItemUidSet& DoModifiedItems() const; |
|
110 // Returns ids of items, which are moved after previous synchronization |
|
111 const MSmlDataItemUidSet& DoMovedItems() const; |
|
112 // Resets change information of items (makes all items new from DS point of view) |
|
113 void DoResetChangeInfoL(TRequestStatus& aStatus); |
|
114 // Commits the changes, that are sent into the remote server |
|
115 void DoCommitChangeInfoL(TRequestStatus& aStatus, const MSmlDataItemUidSet& aItems); |
|
116 // Commits the changes, that are sent into the remote server |
|
117 void DoCommitChangeInfoL(TRequestStatus& aStatus); |
|
118 |
|
119 private: // From MFolderItemObserver |
|
120 void FolderItemRequestCompleted(TInt aStatus, CRequestHandler::TRequestHandlerType); |
|
121 void FolderItemChanged() {}; |
|
122 private: // From MFeedsServerObserver |
|
123 void UpdateAllProgress(TInt, TInt ) {}; |
|
124 void SettingsChanged( TInt ) {}; |
|
125 private: // From MConnectionObserver |
|
126 virtual void NetworkConnectionNeededL(TInt* /*aConnectionPtr*/, TInt& /*aSockSvrHandle*/, |
|
127 TBool& /*aNewConn*/, TApBearerType& /*aBearerType*/){}; |
|
128 private: |
|
129 void DoFolderItemRequestCompletedL( TInt aStatus ); |
|
130 void CreateRssItemL( TInt aRssParentUid, const TDesC& aName, const TDesC& aUrl, TBool aIsFolder ); |
|
131 void ReplaceRssItemL( TInt aRssItemUid, const TDesC& aNewName, const TDesC& aNewUrl ); |
|
132 void RssItemCreatedL(); |
|
133 void RssItemReplacedL( TBool& aMoveNeeded ); |
|
134 void RegisterSnapshotL(); |
|
135 void RegisterToSnapshotL( CArrayFixSeg<TSnapshotItem>* aSnapshot, TInt aFolderUid ); |
|
136 void RegisterRssFeedsToSnapshotL( CArrayFixSeg<TSnapshotItem>* aSnapshot, |
|
137 const CFolderItem& folder ); |
|
138 void AssignString( TDes8& aDestination, const TDesC8& aSource ); |
|
139 |
|
140 // Data store states |
|
141 enum TState |
|
142 { |
|
143 EClosed = 0, |
|
144 EOpenAndWaiting, |
|
145 EBookmarkOpen, |
|
146 EBookmarkCreating, |
|
147 EBookmarkUpdating, |
|
148 EBookmarkUpdatedAndMoving, |
|
149 EBookmarkMoving, |
|
150 EBookmarkDeleting, |
|
151 EBookmarkDeletingAll |
|
152 }; |
|
153 |
|
154 TState iCurrentState; |
|
155 |
|
156 RFs iRfs; |
|
157 RFavouritesSession iSession; |
|
158 RFavouritesDb iDb; |
|
159 TBool iDataBaseOpened; |
|
160 |
|
161 RFeedsServer iFeedsServer; |
|
162 RFolderItem iRootFolder; |
|
163 |
|
164 TRequestStatus* iCallerStatus; |
|
165 |
|
166 /** |
|
167 * Key that is used in sorting snapshot. |
|
168 */ |
|
169 const TKeyArrayFix iKey; |
|
170 |
|
171 /** |
|
172 * Change finder, used to determine db modifications. |
|
173 */ |
|
174 CChangeFinder* iChangeFinder; |
|
175 |
|
176 /** |
|
177 * Bookmark item converter, used to convert xml and vBookmark data. |
|
178 */ |
|
179 CBookmarkConversionUtil* iConverter; |
|
180 |
|
181 TInt* iCurrentItem; |
|
182 TInt iReplaceItem; |
|
183 TSnapshotItem* iMovedItem; |
|
184 |
|
185 CBufFlat* iDataBuffer; |
|
186 TInt iWriterPosition; |
|
187 TInt iReaderPosition; |
|
188 |
|
189 TBool iHasHistory; |
|
190 |
|
191 CNSmlDataItemUidSet* iNewItems; |
|
192 CNSmlDataItemUidSet* iDeletedItems; |
|
193 CNSmlDataItemUidSet* iSoftDeletedItems; |
|
194 CNSmlDataItemUidSet* iUpdatedItems; |
|
195 CNSmlDataItemUidSet* iMovedItems; |
|
196 |
|
197 CFavouritesItem::TType iMimeType; |
|
198 TInt iParentFolder; |
|
199 TFileName iNewItemName; |
|
200 |
|
201 CFavouritesItem* iItemToBeReplaced; |
|
202 |
|
203 }; |
|
204 |
|
205 #endif |