kitchensync

syncupdates.h

00001 /*
00002     This file is part of libqopensync.
00003 
00004     Copyright (c) 2005 Tobias Koenig <tokoe@kde.org>
00005 
00006     This library is free software; you can redistribute it and/or
00007     modify it under the terms of the GNU Library General Public
00008     License as published by the Free Software Foundation; either
00009     version 2 of the License, or (at your option) any later version.
00010 
00011     This library is distributed in the hope that it will be useful,
00012     but WITHOUT ANY WARRANTY; without even the implied warranty of
00013     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00014     Library General Public License for more details.
00015 
00016     You should have received a copy of the GNU Library General Public License
00017     along with this library; see the file COPYING.LIB.  If not, write to
00018     the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
00019     Boston, MA 02110-1301, USA.
00020 */
00021 
00022 #ifndef TQSYNC_SYNCUPDATES_H
00023 #define TQSYNC_SYNCUPDATES_H
00024 
00025 #include <libqopensync/member.h>
00026 #include <libqopensync/result.h>
00027 #include <libqopensync/syncchange.h>
00028 #include <libqopensync/syncmapping.h>
00029 
00030 class OSyncMemberUpdate;
00031 class OSyncChangeUpdate;
00032 class OSyncMappingUpdate;
00033 class OSyncEngineUpdate;
00034 class OSyncMemberUpdate;
00035 
00036 namespace QSync {
00037 
00038 class SyncMemberUpdate
00039 {
00040   friend class CallbackHandler;
00041 
00042   public:
00043     enum Type {
00044       Connected,
00045       SentChanges,
00046       CommittedAll,
00047       Disconnected,
00048       ConnectError,
00049       GetChangesError,
00050       CommittedAllError,
00051       SyncDoneError,
00052       DisconnectedError
00053     };
00054 
00055     SyncMemberUpdate();
00056     SyncMemberUpdate( OSyncMemberUpdate* );
00057     ~SyncMemberUpdate();
00058 
00059     Type type() const;
00060     Result result() const;
00061     Member member() const;
00062 
00063   private:
00064     Type mType;
00065     Result mResult;
00066     Member mMember;
00067 };
00068 
00069 class SyncChangeUpdate
00070 {
00071   friend class CallbackHandler;
00072 
00073   public:
00074     enum Type {
00075       Received = 1,
00076       ReceivedInfo,
00077       Sent,
00078       WriteError,
00079       ReceiveError
00080     };
00081 
00082     SyncChangeUpdate();
00083     SyncChangeUpdate( OSyncChangeUpdate* );
00084     ~SyncChangeUpdate();
00085 
00086     Type type() const;
00087     Result result() const;
00088     SyncChange change() const;
00089     int memberId() const;
00090     int mappingId() const;
00091 
00092   private:
00093     Type mType;
00094     Result mResult;
00095     SyncChange mChange;
00096     int mMemberId;
00097     int mMappingId;
00098 };
00099 
00100 class SyncMappingUpdate
00101 {
00102   friend class CallbackHandler;
00103 
00104   public:
00105     enum Type {
00106       Solved = 1,
00107       Synced,
00108       WriteError
00109     };
00110 
00111     SyncMappingUpdate();
00112     SyncMappingUpdate( OSyncMappingUpdate*, OSyncEngine* );
00113     ~SyncMappingUpdate();
00114 
00115     Type type() const;
00116     Result result() const;
00117     long long int winner() const;
00118     SyncMapping mapping() const;
00119 
00120   private:
00121     Type mType;
00122     Result mResult;
00123     long long int mWinner;
00124     SyncMapping mMapping;
00125 };
00126 
00127 class SyncEngineUpdate
00128 {
00129   friend class CallbackHandler;
00130 
00131   public:
00132     enum Type {
00133       EndPhaseConnected = 1,
00134       EndPhaseRead,
00135       EndPhaseWrite,
00136       EndPhaseDisconnected,
00137       Error,
00138       SyncSuccessfull,
00139       PrevUnclean,
00140       EndConflicts
00141     };
00142 
00143     SyncEngineUpdate();
00144     SyncEngineUpdate( OSyncEngineUpdate* );
00145     ~SyncEngineUpdate();
00146 
00147     Type type() const;
00148     Result result() const;
00149 
00150   private:
00151     Type mType;
00152     Result mResult;
00153 };
00154 
00155 }
00156 
00157 #endif