syncupdates.cpp
1 /*
2  This file is part of libqopensync.
3 
4  Copyright (c) 2005 Tobias Koenig <tokoe@kde.org>
5 
6  This library is free software; you can redistribute it and/or
7  modify it under the terms of the GNU Library General Public
8  License as published by the Free Software Foundation; either
9  version 2 of the License, or (at your option) any later version.
10 
11  This library is distributed in the hope that it will be useful,
12  but WITHOUT ANY WARRANTY; without even the implied warranty of
13  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14  Library General Public License for more details.
15 
16  You should have received a copy of the GNU Library General Public License
17  along with this library; see the file COPYING.LIB. If not, write to
18  the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
19  Boston, MA 02110-1301, USA.
20 */
21 
22 #include <osengine/engine.h>
23 
24 #include "syncupdates.h"
25 
26 using namespace QSync;
27 
28 SyncMemberUpdate::SyncMemberUpdate()
29 {
30 }
31 
32 SyncMemberUpdate::SyncMemberUpdate( OSyncMemberUpdate *update )
33 {
34  switch ( update->type ) {
35  case MEMBER_CONNECTED:
36  mType = Connected;
37  break;
38  case MEMBER_SENT_CHANGES:
39  mType = SentChanges;
40  break;
41  case MEMBER_COMMITTED_ALL:
42  mType = CommittedAll;
43  break;
44  case MEMBER_DISCONNECTED:
45  mType = Disconnected;
46  break;
47  case MEMBER_CONNECT_ERROR:
48  mType = ConnectError;
49  break;
50  case MEMBER_GET_CHANGES_ERROR:
51  mType = GetChangesError;
52  break;
53  case MEMBER_COMMITTED_ALL_ERROR:
54  mType = CommittedAllError;
55  break;
56  case MEMBER_SYNC_DONE_ERROR:
57  mType = SyncDoneError;
58  break;
59  case MEMBER_DISCONNECT_ERROR:
60  mType = DisconnectedError;
61  break;
62  }
63 
64  if ( update->error )
65  mResult = Result( &(update->error) );
66 
67  mMember.mMember = update->member;
68 }
69 
70 SyncMemberUpdate::~SyncMemberUpdate()
71 {
72 }
73 
74 SyncMemberUpdate::Type SyncMemberUpdate::type() const
75 {
76  return mType;
77 }
78 
79 Result SyncMemberUpdate::result() const
80 {
81  return mResult;
82 }
83 
84 Member SyncMemberUpdate::member() const
85 {
86  return mMember;
87 }
88 
89 
90 SyncChangeUpdate::SyncChangeUpdate()
91 {
92 }
93 
94 SyncChangeUpdate::SyncChangeUpdate( OSyncChangeUpdate *update )
95 {
96  switch ( update->type ) {
97  case CHANGE_RECEIVED:
98  mType = Received;
99  break;
100  case CHANGE_RECEIVED_INFO:
101  mType = ReceivedInfo;
102  break;
103  case CHANGE_SENT:
104  mType = Sent;
105  break;
106  case CHANGE_WRITE_ERROR:
107  mType = WriteError;
108  break;
109  case CHANGE_RECV_ERROR:
110  mType = ReceiveError;
111  break;
112  }
113 
114  if ( update->error )
115  mResult = Result( &(update->error) );
116 
117  mChange = SyncChange( update->change );
118  mMemberId = update->member_id;
119  mMappingId = update->mapping_id;
120 }
121 
122 SyncChangeUpdate::~SyncChangeUpdate()
123 {
124 }
125 
126 SyncChangeUpdate::Type SyncChangeUpdate::type() const
127 {
128  return mType;
129 }
130 
131 Result SyncChangeUpdate::result() const
132 {
133  return mResult;
134 }
135 
136 SyncChange SyncChangeUpdate::change() const
137 {
138  return mChange;
139 }
140 
141 int SyncChangeUpdate::memberId() const
142 {
143  return mMemberId;
144 }
145 
146 int SyncChangeUpdate::mappingId() const
147 {
148  return mMappingId;
149 }
150 
151 SyncMappingUpdate::SyncMappingUpdate()
152 {
153 }
154 
155 SyncMappingUpdate::SyncMappingUpdate( OSyncMappingUpdate *update, OSyncEngine *engine )
156 {
157  switch ( update->type ) {
158  case MAPPING_SOLVED:
159  mType = Solved;
160  break;
161  case MAPPING_SYNCED:
162  mType = Synced;
163  break;
164  case MAPPING_WRITE_ERROR:
165  mType = WriteError;
166  break;
167  }
168 
169  if ( update->error )
170  mResult = Result( &(update->error) );
171 
172  mWinner = update->winner;
173  mMapping.mEngine = engine;
174  mMapping.mMapping = update->mapping;
175 }
176 
177 SyncMappingUpdate::~SyncMappingUpdate()
178 {
179 }
180 
181 SyncMappingUpdate::Type SyncMappingUpdate::type() const
182 {
183  return mType;
184 }
185 
186 Result SyncMappingUpdate::result() const
187 {
188  return mResult;
189 }
190 
191 long long int SyncMappingUpdate::winner() const
192 {
193  return mWinner;
194 }
195 
196 SyncMapping SyncMappingUpdate::mapping() const
197 {
198  return mMapping;
199 }
200 
201 SyncEngineUpdate::SyncEngineUpdate()
202 {
203 }
204 
205 SyncEngineUpdate::SyncEngineUpdate( OSyncEngineUpdate *update )
206 {
207  switch ( update->type ) {
208  case ENG_ENDPHASE_CON:
209  mType = EndPhaseConnected;
210  break;
211  case ENG_ENDPHASE_READ:
212  mType = EndPhaseRead;
213  break;
214  case ENG_ENDPHASE_WRITE:
215  mType = EndPhaseWrite;
216  break;
217  case ENG_ENDPHASE_DISCON:
218  mType = EndPhaseDisconnected;
219  break;
220  case ENG_ERROR:
221  mType = Error;
222  break;
223  case ENG_SYNC_SUCCESSFULL:
224  mType = SyncSuccessfull;
225  break;
226  case ENG_PREV_UNCLEAN:
227  mType = PrevUnclean;
228  break;
229  case ENG_END_CONFLICTS:
230  mType = EndConflicts;
231  break;
232  }
233 
234  if ( update->error )
235  mResult = Result( &(update->error) );
236 }
237 
238 SyncEngineUpdate::~SyncEngineUpdate()
239 {
240 }
241 
242 SyncEngineUpdate::Type SyncEngineUpdate::type() const
243 {
244  return mType;
245 }
246 
247 Result SyncEngineUpdate::result() const
248 {
249  return mResult;
250 }
251