src/include/common/spds/SyncSourceReport.h

00001 /*
00002  * Funambol is a mobile platform developed by Funambol, Inc. 
00003  * Copyright (C) 2003 - 2007 Funambol, Inc.
00004  * 
00005  * This program is free software; you can redistribute it and/or modify it under
00006  * the terms of the GNU Affero General Public License version 3 as published by
00007  * the Free Software Foundation with the addition of the following permission 
00008  * added to Section 15 as permitted in Section 7(a): FOR ANY PART OF THE COVERED
00009  * WORK IN WHICH THE COPYRIGHT IS OWNED BY FUNAMBOL, FUNAMBOL DISCLAIMS THE 
00010  * WARRANTY OF NON INFRINGEMENT  OF THIRD PARTY RIGHTS.
00011  * 
00012  * This program is distributed in the hope that it will be useful, but WITHOUT
00013  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
00014  * FOR A PARTICULAR PURPOSE.  See the GNU General Public License for more
00015  * details.
00016  * 
00017  * You should have received a copy of the GNU Affero General Public License 
00018  * along with this program; if not, see http://www.gnu.org/licenses or write to
00019  * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
00020  * MA 02110-1301 USA.
00021  * 
00022  * You can contact Funambol, Inc. headquarters at 643 Bair Island Road, Suite 
00023  * 305, Redwood City, CA 94063, USA, or at email address info@funambol.com.
00024  * 
00025  * The interactive user interfaces in modified source and object code versions
00026  * of this program must display Appropriate Legal Notices, as required under
00027  * Section 5 of the GNU Affero General Public License version 3.
00028  * 
00029  * In accordance with Section 7(b) of the GNU Affero General Public License
00030  * version 3, these Appropriate Legal Notices must retain the display of the
00031  * "Powered by Funambol" logo. If the display of the logo is not reasonably 
00032  * feasible for technical reasons, the Appropriate Legal Notices must display
00033  * the words "Powered by Funambol".
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 
00049 
00051 typedef enum SourceState{
00052     SOURCE_ACTIVE       = 0,        
00053     SOURCE_INACTIVE     = 1,        
00054     SOURCE_ERROR        = 2,        
00055 } SourceState;
00056 
00057 
00064 class SyncSourceReport {
00065 
00066 private:
00067 
00068     // The error code of the last error occurred for this source.
00069     int         lastErrorCode;
00070 
00071     // The error message of the last error occurred for this source.
00072     char*       lastErrorMsg;
00073 
00074     // The source name.
00075     char*       sourceName;
00076 
00077     // The source state, possible values:
00078     // 0 = SOURCE_ACTIVE   -> used in synchronization
00079     // 1 = SOURCE_INACTIVE -> ignored in synchronization
00080     // 2 = SOURCE_ERROR    -> error occurred, will be skipped in sync
00081     SourceState state;
00082 
00083     // List of ItemReports for client modifications
00084     ArrayList*  clientAddItems;
00085     ArrayList*  clientModItems;
00086     ArrayList*  clientDelItems;
00087 
00088     // List of ItemReports for server modifications
00089     ArrayList*  serverAddItems;
00090     ArrayList*  serverModItems;
00091     ArrayList*  serverDelItems;
00092 
00093 
00094     // Return true if status is [200 <-> 299] (successful)
00095     bool isSuccessful(const int status);
00096 
00097     // Function to initialize members.
00098     void initialize();
00099 
00100     /*
00101      * Assign this object with the given SyncReport
00102      * @param sr the syncReport object
00103      */
00104     void assign(const SyncSourceReport& ssr);
00105 
00106 
00107 public:
00108 
00109     SyncSourceReport(const char* name = NULL);
00110     SyncSourceReport(SyncSourceReport& ssr);
00111     virtual ~SyncSourceReport();
00112 
00114     const int   getLastErrorCode() const;
00115 
00117     const SourceState   getState() const;
00118 
00120     const char*  getLastErrorMsg() const;
00121 
00123     const char*    getSourceName() const;
00124 
00125     void setLastErrorCode(const int code);
00126     void setState        (const SourceState s);
00127     void setLastErrorMsg (const char* msg);
00128     void setSourceName   (const char* name);
00129 
00134     bool checkState();
00135 
00136 
00145     ItemReport* getItemReport(const char* target, const char* command, int index);
00146 
00147 
00155     int getItemReportCount            (const char* target, const char* command);
00156     // Only for successful reports.
00157     int getItemReportSuccessfulCount  (const char* target, const char* command);
00158     // Only for failed reports.
00159     int getItemReportFailedCount      (const char* target, const char* command);
00160     // Only for code = 418 (ALREADY_EXIST)
00161     int getItemReportAlreadyExistCount(const char* target, const char* command);
00162 
00163 
00176     void addItem(const char* target, const char* command, const WCHAR* ID, const int status, const WCHAR* statusMessage);
00177 
00178 
00179 
00188     ArrayList* getList(const char* target, const char* command) const;
00189 
00193     static const char* const targets[];
00194 
00198     static const char* const commands[];
00199 
00203     SyncSourceReport& operator = (const SyncSourceReport& ssr) {
00204         assign(ssr);
00205         return *this;
00206     }
00207 };
00208 
00211 #endif
00212 

Generated on Mon Feb 4 09:50:47 2008 for Funambol Outlook Plug-in Library by  doxygen 1.5.2