kitchensync
group.h00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022 #ifndef QSYNC_GROUP_H
00023 #define QSYNC_GROUP_H
00024
00025 #include <qdatetime.h>
00026 #include <qstringlist.h>
00027
00028 #include <libqopensync/filter.h>
00029 #include <libqopensync/member.h>
00030
00031 class OSyncGroup;
00032
00033 namespace QSync {
00034
00038 class GroupConfig
00039 {
00040 friend class Group;
00041
00042 public:
00043 GroupConfig();
00044
00045 QStringList activeObjectTypes() const;
00046 void setActiveObjectTypes( const QStringList &objectTypes );
00047
00048 private:
00049 OSyncGroup *mGroup;
00050 };
00051
00052
00053 class Group
00054 {
00055 friend class Engine;
00056 friend class Environment;
00057
00058 public:
00059 enum LockType
00060 {
00061 LockOk,
00062 Locked,
00063 LockStale
00064 };
00065
00066 Group();
00067 ~Group();
00068
00072 bool isValid() const;
00073
00074 class Iterator
00075 {
00076 friend class Group;
00077
00078 public:
00079 Iterator( Group *group )
00080 : mGroup( group ), mPos( -1 )
00081 {
00082 }
00083
00084 Iterator( const Iterator &it )
00085 {
00086 mGroup = it.mGroup;
00087 mPos = it.mPos;
00088 }
00089
00090 Member operator*()
00091 {
00092 return mGroup->memberAt( mPos );
00093 }
00094
00095 Iterator &operator++() { mPos++; return *this; }
00096 Iterator &operator++( int ) { mPos++; return *this; }
00097 Iterator &operator--() { mPos--; return *this; }
00098 Iterator &operator--( int ) { mPos--; return *this; }
00099 bool operator==( const Iterator &it ) { return mGroup == it.mGroup && mPos == it.mPos; }
00100 bool operator!=( const Iterator &it ) { return mGroup == it.mGroup && mPos != it.mPos; }
00101
00102 private:
00103 Group *mGroup;
00104 int mPos;
00105 };
00106
00111 Iterator begin();
00112
00117 Iterator end();
00118
00122 void setName( const QString &name );
00123
00127 QString name() const;
00128
00132 void setLastSynchronization( const QDateTime &dateTime );
00133
00137 QDateTime lastSynchronization() const;
00138
00144 LockType lock();
00145
00151 void unlock( bool removeFile = true );
00152
00158 Member addMember();
00159
00163 void removeMember( const Member &member );
00164
00168 int memberCount() const;
00169
00173 Member memberAt( int pos ) const;
00174
00178 int filterCount() const;
00179
00183 Filter filterAt( int pos );
00184
00189 void setObjectTypeEnabled( const QString &objectType, bool enabled );
00190
00195 bool isObjectTypeEnabled( const QString &objectType ) const;
00196
00200 Result save();
00201
00207 GroupConfig config() const;
00208
00209 bool operator==( const Group &group ) const { return mGroup == group.mGroup; }
00210
00211 private:
00212 OSyncGroup *mGroup;
00213 };
00214
00215 }
00216
00217 #endif
|