kitchensync
group.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 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