syncupdates.h
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 #ifndef TQSYNC_SYNCUPDATES_H
23 #define TQSYNC_SYNCUPDATES_H
24 
25 #include <libqopensync/member.h>
26 #include <libqopensync/result.h>
27 #include <libqopensync/syncchange.h>
28 #include <libqopensync/syncmapping.h>
29 
30 class OSyncMemberUpdate;
31 class OSyncChangeUpdate;
32 class OSyncMappingUpdate;
33 class OSyncEngineUpdate;
34 class OSyncMemberUpdate;
35 
36 namespace QSync {
37 
38 class SyncMemberUpdate
39 {
40  friend class CallbackHandler;
41 
42  public:
43  enum Type {
44  Connected,
45  SentChanges,
46  CommittedAll,
47  Disconnected,
48  ConnectError,
49  GetChangesError,
50  CommittedAllError,
51  SyncDoneError,
52  DisconnectedError
53  };
54 
55  SyncMemberUpdate();
56  SyncMemberUpdate( OSyncMemberUpdate* );
57  ~SyncMemberUpdate();
58 
59  Type type() const;
60  Result result() const;
61  Member member() const;
62 
63  private:
64  Type mType;
65  Result mResult;
66  Member mMember;
67 };
68 
69 class SyncChangeUpdate
70 {
71  friend class CallbackHandler;
72 
73  public:
74  enum Type {
75  Received = 1,
76  ReceivedInfo,
77  Sent,
78  WriteError,
79  ReceiveError
80  };
81 
82  SyncChangeUpdate();
83  SyncChangeUpdate( OSyncChangeUpdate* );
84  ~SyncChangeUpdate();
85 
86  Type type() const;
87  Result result() const;
88  SyncChange change() const;
89  int memberId() const;
90  int mappingId() const;
91 
92  private:
93  Type mType;
94  Result mResult;
95  SyncChange mChange;
96  int mMemberId;
97  int mMappingId;
98 };
99 
100 class SyncMappingUpdate
101 {
102  friend class CallbackHandler;
103 
104  public:
105  enum Type {
106  Solved = 1,
107  Synced,
108  WriteError
109  };
110 
111  SyncMappingUpdate();
112  SyncMappingUpdate( OSyncMappingUpdate*, OSyncEngine* );
113  ~SyncMappingUpdate();
114 
115  Type type() const;
116  Result result() const;
117  long long int winner() const;
118  SyncMapping mapping() const;
119 
120  private:
121  Type mType;
122  Result mResult;
123  long long int mWinner;
124  SyncMapping mMapping;
125 };
126 
127 class SyncEngineUpdate
128 {
129  friend class CallbackHandler;
130 
131  public:
132  enum Type {
133  EndPhaseConnected = 1,
134  EndPhaseRead,
135  EndPhaseWrite,
136  EndPhaseDisconnected,
137  Error,
138  SyncSuccessfull,
139  PrevUnclean,
140  EndConflicts
141  };
142 
143  SyncEngineUpdate();
144  SyncEngineUpdate( OSyncEngineUpdate* );
145  ~SyncEngineUpdate();
146 
147  Type type() const;
148  Result result() const;
149 
150  private:
151  Type mType;
152  Result mResult;
153 };
154 
155 }
156 
157 #endif