00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036 #ifndef MEDIASOURCESYNC_H_
00037 #define MEDIASOURCESYNC_H_
00038
00039 #include "base/fscapi.h"
00040 #include "spds/constants.h"
00041 #include "spds/SyncItem.h"
00042 #include "spds/SyncMap.h"
00043 #include "spds/SyncStatus.h"
00044 #include "base/util/ItemContainer.h"
00045 #include "spds/FileData.h"
00046 #include "client/CacheSyncSource.h"
00047 #include "client/FileSyncSource.h"
00048 #include "http/HttpUploader.h"
00049 #include "client/MediaSyncSourceParams.h"
00050
00051 BEGIN_NAMESPACE
00052
00053
00064 class MediaSyncSource : public FileSyncSource
00065 {
00066
00067 public:
00068 MediaSyncSource(const WCHAR* wname,
00069 AbstractSyncSourceConfig* sc,
00070 const StringBuffer& aDir,
00071 MediaSyncSourceParams mediaParams);
00072
00073 ~MediaSyncSource();
00074
00080 int beginSync();
00081
00083 int insertItem(SyncItem& item);
00084
00086 int modifyItem(SyncItem& item);
00087
00089 int removeItem(SyncItem& item);
00090
00099 StringBuffer getItemSignature(StringBuffer& key);
00100
00108 virtual void fireClientTotalNumber(int number);
00109
00116 void setItemStatus(const WCHAR* wkey, int status, const char* command);
00117
00128 int endSync();
00129
00140 virtual bool isErrorCode(int code);
00141
00142
00143 protected:
00144
00146 MediaSyncSourceParams params;
00147
00149 StringBuffer filterDateString;
00150
00157 ArrayList LUIDsToSend;
00158
00166 KeyValueStore* LUIDMap;
00167
00174 virtual SyncItem* fillSyncItem(StringBuffer* key, const bool fillData = true);
00175
00186 virtual void getKeyAndSignature(SyncItem& item, KeyValuePair& kvp);
00187
00188
00197 SyncItem* getFirstItem();
00198
00208 virtual SyncItem* getFirstNewItem();
00209
00210
00224 virtual bool filterOutgoingItem(const StringBuffer& fullName, struct stat& st);
00225
00238 virtual bool dynamicFilterItem(const StringBuffer& fileName);
00239
00249 void dynamicFilterItems(Enumeration* itemKeys);
00250
00257 virtual int saveCache();
00258
00259
00264 StringBuffer getLUIDFromPath(const StringBuffer& path);
00265
00275 StringBuffer getPathFromLUID(const StringBuffer& luid);
00276
00283 void setSourceError(const int errorCode);
00284
00289 virtual HttpUploader* getHttpUploader() {
00290 return new HttpUploader();
00291 }
00292
00293 private:
00294
00301 KeyValueStore* configParams;
00302
00310 bool checkCacheValidity();
00311
00317 bool verifyNextLUIDValue();
00318
00326 bool refreshLUIDMap();
00327
00328
00333 const int readNextLUID();
00334
00341 void saveNextLUID(const int nextLUID);
00342
00343 };
00344
00345 END_NAMESPACE
00346
00347 #endif