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 INCL_SYNCSOURCEREPORT
00037 #define INCL_SYNCSOURCEREPORT
00038
00042 #include "base/fscapi.h"
00043 #include "base/Log.h"
00044 #include "base/util/utils.h"
00045 #include "spds/constants.h"
00046 #include "event/constants.h"
00047 #include "spds/ItemReport.h"
00048 #include "base/globalsdef.h"
00049
00050 BEGIN_NAMESPACE
00051
00052
00053
00054 #define HTTP_UPLOAD "upload"
00055 #define HTTP_DOWNLOAD "download"
00056
00057
00059 typedef enum SourceState{
00060 SOURCE_ACTIVE = 0,
00061 SOURCE_INACTIVE = 1,
00062 SOURCE_ERROR = 2,
00063 } SourceState;
00064
00065
00072 class SyncSourceReport {
00073
00074 private:
00075
00076
00077 int lastErrorCode;
00078
00079
00080 char* lastErrorMsg;
00081
00082
00083 char* sourceName;
00084
00085
00086
00087
00088
00089 SourceState state;
00090
00091
00092 ArrayList* clientAddItems;
00093 ArrayList* clientModItems;
00094 ArrayList* clientDelItems;
00095 ArrayList* clientDownloadedItems;
00096
00097
00098 ArrayList* serverAddItems;
00099 ArrayList* serverModItems;
00100 ArrayList* serverDelItems;
00101 ArrayList* serverUploadedItems;
00102
00103
00104
00105
00106 bool isSuccessful(const int status);
00107
00108
00109 void initialize();
00110
00111
00112
00113
00114
00115 void assign(const SyncSourceReport& ssr);
00116
00117
00118 public:
00119
00120 SyncSourceReport(const char* name = NULL);
00121 SyncSourceReport(SyncSourceReport& ssr);
00122 virtual ~SyncSourceReport();
00123
00125 int getLastErrorCode() const;
00126
00128 SourceState getState() const;
00129
00131 const char* getLastErrorMsg() const;
00132
00134 const char* getSourceName() const;
00135
00136 void setLastErrorCode(const int code);
00137 void setState (const SourceState s);
00138 void setLastErrorMsg (const char* msg);
00139 void setSourceName (const char* name);
00140
00145 bool checkState();
00146
00147
00156 ItemReport* getItemReport(const char* target, const char* command, int index);
00157
00158
00166 int getItemReportCount (const char* target, const char* command);
00167
00168 int getItemReportSuccessfulCount (const char* target, const char* command);
00169
00170 int getItemReportFailedCount (const char* target, const char* command);
00171
00172 int getItemReportAlreadyExistCount(const char* target, const char* command);
00173
00177 int getTotalSuccessfulCount();
00178
00191 void addItem(const char* target, const char* command, const WCHAR* ID, const int status, const WCHAR* statusMessage);
00192
00201 ArrayList* getList(const char* target, const char* command) const;
00202
00206 static const char* const targets[];
00207
00211 static const char* const commands[];
00212
00216 SyncSourceReport& operator = (const SyncSourceReport& ssr) {
00217 assign(ssr);
00218 return *this;
00219 }
00220 };
00221
00222
00223 END_NAMESPACE
00224
00227 #endif
00228