kitchensync
syncupdates.cpp
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 #include <osengine/engine.h> 00023 00024 #include "syncupdates.h" 00025 00026 using namespace QSync; 00027 00028 SyncMemberUpdate::SyncMemberUpdate() 00029 { 00030 } 00031 00032 SyncMemberUpdate::SyncMemberUpdate( OSyncMemberUpdate *update ) 00033 { 00034 switch ( update->type ) { 00035 case MEMBER_CONNECTED: 00036 mType = Connected; 00037 break; 00038 case MEMBER_SENT_CHANGES: 00039 mType = SentChanges; 00040 break; 00041 case MEMBER_COMMITTED_ALL: 00042 mType = CommittedAll; 00043 break; 00044 case MEMBER_DISCONNECTED: 00045 mType = Disconnected; 00046 break; 00047 case MEMBER_CONNECT_ERROR: 00048 mType = ConnectError; 00049 break; 00050 case MEMBER_GET_CHANGES_ERROR: 00051 mType = GetChangesError; 00052 break; 00053 case MEMBER_COMMITTED_ALL_ERROR: 00054 mType = CommittedAllError; 00055 break; 00056 case MEMBER_SYNC_DONE_ERROR: 00057 mType = SyncDoneError; 00058 break; 00059 case MEMBER_DISCONNECT_ERROR: 00060 mType = DisconnectedError; 00061 break; 00062 } 00063 00064 if ( update->error ) 00065 mResult = Result( &(update->error) ); 00066 00067 mMember.mMember = update->member; 00068 } 00069 00070 SyncMemberUpdate::~SyncMemberUpdate() 00071 { 00072 } 00073 00074 SyncMemberUpdate::Type SyncMemberUpdate::type() const 00075 { 00076 return mType; 00077 } 00078 00079 Result SyncMemberUpdate::result() const 00080 { 00081 return mResult; 00082 } 00083 00084 Member SyncMemberUpdate::member() const 00085 { 00086 return mMember; 00087 } 00088 00089 00090 SyncChangeUpdate::SyncChangeUpdate() 00091 { 00092 } 00093 00094 SyncChangeUpdate::SyncChangeUpdate( OSyncChangeUpdate *update ) 00095 { 00096 switch ( update->type ) { 00097 case CHANGE_RECEIVED: 00098 mType = Received; 00099 break; 00100 case CHANGE_RECEIVED_INFO: 00101 mType = ReceivedInfo; 00102 break; 00103 case CHANGE_SENT: 00104 mType = Sent; 00105 break; 00106 case CHANGE_WRITE_ERROR: 00107 mType = WriteError; 00108 break; 00109 case CHANGE_RECV_ERROR: 00110 mType = ReceiveError; 00111 break; 00112 } 00113 00114 if ( update->error ) 00115 mResult = Result( &(update->error) ); 00116 00117 mChange = SyncChange( update->change ); 00118 mMemberId = update->member_id; 00119 mMappingId = update->mapping_id; 00120 } 00121 00122 SyncChangeUpdate::~SyncChangeUpdate() 00123 { 00124 } 00125 00126 SyncChangeUpdate::Type SyncChangeUpdate::type() const 00127 { 00128 return mType; 00129 } 00130 00131 Result SyncChangeUpdate::result() const 00132 { 00133 return mResult; 00134 } 00135 00136 SyncChange SyncChangeUpdate::change() const 00137 { 00138 return mChange; 00139 } 00140 00141 int SyncChangeUpdate::memberId() const 00142 { 00143 return mMemberId; 00144 } 00145 00146 int SyncChangeUpdate::mappingId() const 00147 { 00148 return mMappingId; 00149 } 00150 00151 SyncMappingUpdate::SyncMappingUpdate() 00152 { 00153 } 00154 00155 SyncMappingUpdate::SyncMappingUpdate( OSyncMappingUpdate *update, OSyncEngine *engine ) 00156 { 00157 switch ( update->type ) { 00158 case MAPPING_SOLVED: 00159 mType = Solved; 00160 break; 00161 case MAPPING_SYNCED: 00162 mType = Synced; 00163 break; 00164 case MAPPING_WRITE_ERROR: 00165 mType = WriteError; 00166 break; 00167 } 00168 00169 if ( update->error ) 00170 mResult = Result( &(update->error) ); 00171 00172 mWinner = update->winner; 00173 mMapping.mEngine = engine; 00174 mMapping.mMapping = update->mapping; 00175 } 00176 00177 SyncMappingUpdate::~SyncMappingUpdate() 00178 { 00179 } 00180 00181 SyncMappingUpdate::Type SyncMappingUpdate::type() const 00182 { 00183 return mType; 00184 } 00185 00186 Result SyncMappingUpdate::result() const 00187 { 00188 return mResult; 00189 } 00190 00191 long long int SyncMappingUpdate::winner() const 00192 { 00193 return mWinner; 00194 } 00195 00196 SyncMapping SyncMappingUpdate::mapping() const 00197 { 00198 return mMapping; 00199 } 00200 00201 SyncEngineUpdate::SyncEngineUpdate() 00202 { 00203 } 00204 00205 SyncEngineUpdate::SyncEngineUpdate( OSyncEngineUpdate *update ) 00206 { 00207 switch ( update->type ) { 00208 case ENG_ENDPHASE_CON: 00209 mType = EndPhaseConnected; 00210 break; 00211 case ENG_ENDPHASE_READ: 00212 mType = EndPhaseRead; 00213 break; 00214 case ENG_ENDPHASE_WRITE: 00215 mType = EndPhaseWrite; 00216 break; 00217 case ENG_ENDPHASE_DISCON: 00218 mType = EndPhaseDisconnected; 00219 break; 00220 case ENG_ERROR: 00221 mType = Error; 00222 break; 00223 case ENG_SYNC_SUCCESSFULL: 00224 mType = SyncSuccessfull; 00225 break; 00226 case ENG_PREV_UNCLEAN: 00227 mType = PrevUnclean; 00228 break; 00229 case ENG_END_CONFLICTS: 00230 mType = EndConflicts; 00231 break; 00232 } 00233 00234 if ( update->error ) 00235 mResult = Result( &(update->error) ); 00236 } 00237 00238 SyncEngineUpdate::~SyncEngineUpdate() 00239 { 00240 } 00241 00242 SyncEngineUpdate::Type SyncEngineUpdate::type() const 00243 { 00244 return mType; 00245 } 00246 00247 Result SyncEngineUpdate::result() const 00248 { 00249 return mResult; 00250 } 00251