distributionlist.h
00001 /* 00002 This file is part of libkabc. 00003 Copyright (c) 2001 Cornelius Schumacher <schumacher@kde.org> 00004 00005 This library is free software; you can redistribute it and/or 00006 modify it under the terms of the GNU Library General Public 00007 License as published by the Free Software Foundation; either 00008 version 2 of the License, or (at your option) any later version. 00009 00010 This library is distributed in the hope that it will be useful, 00011 but WITHOUT ANY WARRANTY; without even the implied warranty of 00012 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 00013 Library General Public License for more details. 00014 00015 You should have received a copy of the GNU Library General Public License 00016 along with this library; see the file COPYING.LIB. If not, write to 00017 the Free Software Foundation, Inc., 59 Temple Place - Suite 330, 00018 Boston, MA 02111-1307, USA. 00019 */ 00020 00021 #ifndef KABC_DISTRIBUTIONLIST_H 00022 #define KABC_DISTRIBUTIONLIST_H 00023 00024 #include <kdirwatch.h> 00025 00026 #include "addressbook.h" 00027 00028 namespace KABC { 00029 00030 class DistributionListManager; 00031 00039 class DistributionList 00040 { 00041 public: 00049 struct Entry 00050 { 00051 typedef QValueList<Entry> List; 00052 00053 Entry() {} 00054 Entry( const Addressee &_addressee, const QString &_email ) : 00055 addressee( _addressee ), email( _email ) {} 00056 00057 Addressee addressee; 00058 QString email; 00059 }; 00060 00067 DistributionList( DistributionListManager *manager, const QString &name ); 00068 00072 ~DistributionList(); 00073 00078 void setName( const QString & ); 00079 00083 QString name() const; 00084 00089 void insertEntry( const Addressee &, const QString &email=QString::null ); 00090 00095 void removeEntry( const Addressee &, const QString &email=QString::null ); 00096 00101 QStringList emails() const; 00102 00107 Entry::List entries() const; 00108 00109 private: 00110 DistributionListManager *mManager; 00111 QString mName; 00112 00113 Entry::List mEntries; 00114 }; 00115 00122 class DistributionListManager 00123 { 00124 public: 00128 DistributionListManager( AddressBook * ); 00129 00133 ~DistributionListManager(); 00134 00138 DistributionList *list( const QString &name ); 00139 00144 void insert( DistributionList * ); 00145 00150 void remove( DistributionList * ); 00151 00155 QStringList listNames(); 00156 00160 bool load(); 00161 00165 bool save(); 00166 00167 private: 00168 AddressBook *mAddressBook; 00169 00170 QPtrList<DistributionList> mLists; 00171 }; 00172 00188 class DistributionListWatcher : public QObject 00189 { 00190 Q_OBJECT 00191 00192 public: 00196 static DistributionListWatcher *self(); 00197 00198 00199 signals: 00205 void changed(); 00206 00207 protected: 00208 DistributionListWatcher(); 00209 ~DistributionListWatcher(); 00210 00211 private: 00212 static DistributionListWatcher* mSelf; 00213 KDirWatch *mDirWatch; 00214 }; 00215 00216 } 00217 #endif