1 /* |
|
2 * Copyright (c) 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 |
|
20 #ifndef __MEDIADATASTORE_H__ |
|
21 #define __MEDIADATASTORE_H__ |
|
22 |
|
23 // INCLUDES |
|
24 #include <smldataprovider.h> |
|
25 #include <mpxcollectionobserver.h> |
|
26 |
|
27 #include "mediadsproviderdefs.h" |
|
28 #include "changefinder.h" |
|
29 #include "mediamanager.h" |
|
30 #include "cmdemanager.h" |
|
31 |
|
32 // FORWARD DECLARATIONS |
|
33 class CNSmlDataItemUidSet; |
|
34 class MMPXHarvesterUtility; |
|
35 class MMPXCollectionUtility; |
|
36 class CMPXCollectionMediator; |
|
37 |
|
38 |
|
39 /** |
|
40 * @brief This class is derived from ECom Data Store plugin-interface (CSmlDataStore). |
|
41 * It performs the actual synchronization commands, which are received from |
|
42 * the DS engine. |
|
43 */ |
|
44 class CMediaDsDataStore : public CSmlDataStore, |
|
45 public MMediaManagerObserver, |
|
46 public MMdEManagerObserver |
|
47 { |
|
48 public: |
|
49 |
|
50 /** |
|
51 * Constructor |
|
52 * |
|
53 * @return CMediaDsDataStore* instance. |
|
54 */ |
|
55 static CMediaDsDataStore* NewLC( RFs& aFs ); |
|
56 |
|
57 /** |
|
58 * Destructor |
|
59 */ |
|
60 virtual ~CMediaDsDataStore(); |
|
61 |
|
62 protected: |
|
63 |
|
64 // Virtual functionality from CSmlDataStore, for comments see the CSmlDataStore header file |
|
65 virtual void DoOpenL(const TDesC& aStoreName, MSmlSyncRelationship& aContext, TRequestStatus& aStatus); |
|
66 virtual void DoCancelRequest(); |
|
67 virtual const TDesC& DoStoreName() const; |
|
68 virtual void DoBeginTransactionL(); |
|
69 virtual void DoCommitTransactionL(TRequestStatus& aStatus); |
|
70 virtual void DoRevertTransaction(TRequestStatus& aStatus); |
|
71 virtual void DoBeginBatchL(); |
|
72 virtual void DoCommitBatchL(RArray<TInt>& aResultArray, TRequestStatus& aStatus); |
|
73 virtual void DoCancelBatch(); |
|
74 virtual void DoSetRemoteStoreFormatL(const CSmlDataStoreFormat& aServerDataStoreFormat); |
|
75 virtual void DoSetRemoteMaxObjectSize(TInt aServerMaxObjectSize); |
|
76 virtual TInt DoMaxObjectSize() const; |
|
77 virtual void DoOpenItemL(TSmlDbItemUid aUid, TBool& aFieldChange, TInt& aSize, |
|
78 TSmlDbItemUid& aParent, TDes8& aMimeType, TDes8& aMimeVer, TRequestStatus& aStatus); |
|
79 virtual void DoCreateItemL(TSmlDbItemUid& aUid, TInt aSize, TSmlDbItemUid aParent, |
|
80 const TDesC8& aMimeType, const TDesC8& aMimeVer, TRequestStatus& aStatus); |
|
81 virtual void DoReplaceItemL(TSmlDbItemUid aUid, TInt aSize, TSmlDbItemUid aParent, |
|
82 TBool aFieldChange, TRequestStatus& aStatus); |
|
83 virtual void DoReadItemL(TDes8& aBuffer); |
|
84 virtual void DoWriteItemL(const TDesC8& aData); |
|
85 virtual void DoCommitItemL(TRequestStatus& aStatus); |
|
86 virtual void DoCloseItem(); |
|
87 virtual void DoMoveItemL(TSmlDbItemUid aUid, TSmlDbItemUid aNewParent, TRequestStatus& aStatus); |
|
88 virtual void DoDeleteItemL(TSmlDbItemUid aUid, TRequestStatus& aStatus); |
|
89 virtual void DoSoftDeleteItemL(TSmlDbItemUid aUid, TRequestStatus& aStatus); |
|
90 virtual void DoDeleteAllItemsL(TRequestStatus& aStatus); |
|
91 virtual TBool DoHasSyncHistory() const; |
|
92 virtual const MSmlDataItemUidSet& DoAddedItems() const; |
|
93 virtual const MSmlDataItemUidSet& DoDeletedItems() const; |
|
94 virtual const MSmlDataItemUidSet& DoSoftDeletedItems() const; |
|
95 virtual const MSmlDataItemUidSet& DoModifiedItems() const; |
|
96 virtual const MSmlDataItemUidSet& DoMovedItems() const; |
|
97 virtual void DoResetChangeInfoL(TRequestStatus& aStatus); |
|
98 virtual void DoCommitChangeInfoL(TRequestStatus& aStatus, const MSmlDataItemUidSet& aItems); |
|
99 virtual void DoCommitChangeInfoL(TRequestStatus& aStatus); |
|
100 |
|
101 protected: // from MMPXCollectionObserver |
|
102 void HandleCollectionMessage(CMPXMessage* aMsg, TInt /*aErr*/) ; |
|
103 void HandleOpenL(const CMPXMedia& aEntries, |
|
104 TInt aIndex,TBool aComplete,TInt aError); |
|
105 void HandleOpenL(const CMPXCollectionPlaylist& aPlaylist,TInt aError); |
|
106 void HandleCommandComplete(CMPXCommand* /*aCommandResult*/, |
|
107 TInt /*aError*/); |
|
108 void HandleCollectionMediaL(const CMPXMedia& aMedia, |
|
109 TInt aError); |
|
110 // from MMediaManagerObserver |
|
111 void RegisterAllPlayListsCompleted( TInt aError ); |
|
112 void RegisterAllSongsCompleted( TInt aError ); |
|
113 |
|
114 protected: // from MMdEManagerObserver |
|
115 void AlbumsReaded( TInt aError ); |
|
116 void AlbumReplaced( TInt aError ); |
|
117 |
|
118 private: |
|
119 |
|
120 /** |
|
121 * C++ Constructor. |
|
122 */ |
|
123 CMediaDsDataStore( RFs& aFs ); |
|
124 |
|
125 /** |
|
126 * 2nd-phase Constructor. |
|
127 * |
|
128 * @param aMsvSession IN: a session handle to message store |
|
129 */ |
|
130 void ConstructL(); |
|
131 |
|
132 /** |
|
133 * Registers snapshot to ChangeFinder. |
|
134 */ |
|
135 void RegisterSnapshotL(); |
|
136 |
|
137 void RegisterFoldersL( CSnapshotArray& aItemArray ); |
|
138 |
|
139 void FinalizeOpenStore(); |
|
140 |
|
141 inline TInt MapSyncIdToAlbumId( TSmlDbItemUid aSyncId ); |
|
142 inline TSmlDbItemUid MapAlbumIdToSyncId( TInt aAlbumId ); |
|
143 |
|
144 private: // Data members |
|
145 |
|
146 |
|
147 enum TState |
|
148 { |
|
149 EClosed = 0, |
|
150 EOpening, |
|
151 EOpenAndWaiting, |
|
152 EReplace, |
|
153 ECreatePlaylist |
|
154 }; |
|
155 |
|
156 /** |
|
157 * The state of the plugin. |
|
158 */ |
|
159 TState iCurrentState; |
|
160 |
|
161 /** |
|
162 * A flag indicating the existence of synchronization history. |
|
163 */ |
|
164 TBool iHasHistory; |
|
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 * The location for temporary data |
|
178 */ |
|
179 CBufFlat* iDataBuffer; |
|
180 |
|
181 /** |
|
182 * Current read position at the data chunk from MMS engine |
|
183 */ |
|
184 TInt iReadPosition; |
|
185 |
|
186 /** |
|
187 * Indicates wheter this was only status update |
|
188 */ |
|
189 TInt iWrittenDataLength; |
|
190 |
|
191 /** |
|
192 * Stores the currently active message id. |
|
193 */ |
|
194 TSmlDbItemUid iCurrentId; |
|
195 |
|
196 /** |
|
197 * Pointer to the variable, receiving the created Uid. |
|
198 */ |
|
199 TSmlDbItemUid* iCreatedUid; |
|
200 |
|
201 /** |
|
202 * Stores the parent id of currently active message. |
|
203 */ |
|
204 TSmlDbItemUid iParentId; |
|
205 |
|
206 /** |
|
207 * Used to get asynchronous return values. |
|
208 */ |
|
209 TRequestStatus* iCallerStatus; |
|
210 |
|
211 /** |
|
212 * Used to store new items. |
|
213 */ |
|
214 CNSmlDataItemUidSet* iNewItems; |
|
215 |
|
216 /** |
|
217 * Used to store deleted items. |
|
218 */ |
|
219 CNSmlDataItemUidSet* iDeletedItems; |
|
220 |
|
221 /** |
|
222 * Used to store updated items. |
|
223 */ |
|
224 CNSmlDataItemUidSet* iUpdatedItems; |
|
225 |
|
226 /** |
|
227 * Used to store moved items. |
|
228 */ |
|
229 CNSmlDataItemUidSet* iMovedItems; |
|
230 |
|
231 /** |
|
232 * Used to store soft-deleted items (not supported). |
|
233 */ |
|
234 CNSmlDataItemUidSet* iSoftDeletedItems; |
|
235 |
|
236 /** |
|
237 * Used to manage playlists and songs. |
|
238 */ |
|
239 CMediaManager* iMediaManager; |
|
240 TBool iMediaManagerReady; |
|
241 |
|
242 /** |
|
243 * Used to manage photo albums. |
|
244 */ |
|
245 CMdEManager* iMdEManager; |
|
246 TBool iMdEManagerReady; |
|
247 |
|
248 TInt iError; |
|
249 |
|
250 CMD5* iHasher; |
|
251 |
|
252 RFs& iFs; |
|
253 |
|
254 CSnapshotArray* iSnapshot; |
|
255 TSnapshotItem iItemInReplacement; |
|
256 }; |
|
257 |
|
258 #endif // __MEDIADATASTORE_H__ |
|