summaryrefslogtreecommitdiffabout
path: root/kabc/distributionlist.h
authorzautrix <zautrix>2004-06-26 19:01:18 (UTC)
committer zautrix <zautrix>2004-06-26 19:01:18 (UTC)
commitb9aad1f15dc600e4dbe4c62d3fcced6363188ba3 (patch) (unidiff)
tree2c3d4004fb21c72cba65793859f9bcd8ffd3a49c /kabc/distributionlist.h
downloadkdepimpi-b9aad1f15dc600e4dbe4c62d3fcced6363188ba3.zip
kdepimpi-b9aad1f15dc600e4dbe4c62d3fcced6363188ba3.tar.gz
kdepimpi-b9aad1f15dc600e4dbe4c62d3fcced6363188ba3.tar.bz2
Initial revision
Diffstat (limited to 'kabc/distributionlist.h') (more/less context) (ignore whitespace changes)
-rw-r--r--kabc/distributionlist.h219
1 files changed, 219 insertions, 0 deletions
diff --git a/kabc/distributionlist.h b/kabc/distributionlist.h
new file mode 100644
index 0000000..ccff487
--- a/dev/null
+++ b/kabc/distributionlist.h
@@ -0,0 +1,219 @@
1/*
2 This file is part of libkabc.
3 Copyright (c) 2001 Cornelius Schumacher <schumacher@kde.org>
4
5 This library is free software; you can redistribute it and/or
6 modify it under the terms of the GNU Library General Public
7 License as published by the Free Software Foundation; either
8 version 2 of the License, or (at your option) any later version.
9
10 This library is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 Library General Public License for more details.
14
15 You should have received a copy of the GNU Library General Public License
16 along with this library; see the file COPYING.LIB. If not, write to
17 the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
18 Boston, MA 02111-1307, USA.
19*/
20
21#ifndef KABC_DISTRIBUTIONLIST_H
22#define KABC_DISTRIBUTIONLIST_H
23
24#include <kdirwatch.h>
25
26#include "addressbook.h"
27
28namespace KABC {
29
30class DistributionListManager;
31
32/**
33 @short Distribution list of email addresses
34
35 This class represents a list of email addresses. Each email address is
36 associated with an address book entry. If the address book entry changes, the
37 entry in the distribution list is automatically updated.
38*/
39class DistributionList
40{
41 public:
42 /**
43 @short Distribution List Entry
44
45 This class represents an entry of a distribution list. It consists of an
46 addressee and an email address. If the email address is null, the
47 preferred email address of the addressee is used.
48 */
49 struct Entry
50 {
51 typedef QValueList<Entry> List;
52
53 Entry() {}
54 Entry( const Addressee &_addressee, const QString &_email ) :
55 addressee( _addressee ), email( _email ) {}
56
57 Addressee addressee;
58 QString email;
59 };
60
61 /**
62 Create distribution list object.
63
64 @param manager Managing object of this list.
65 @param name Name of this list.
66 */
67 DistributionList( DistributionListManager *manager, const QString &name );
68
69 /**
70 Destructor.
71 */
72 ~DistributionList();
73
74 /**
75 Set name of this list. The name is used as key by the
76 DistributinListManager.
77 */
78 void setName( const QString & );
79
80 /**
81 Get name of this list.
82 */
83 QString name() const;
84
85 /**
86 Insert an entry into this distribution list. If the entry already exists
87 nothing happens.
88 */
89 void insertEntry( const Addressee &, const QString &email=QString::null );
90
91 /**
92 Remove an entry from this distribution list. If the entry doesn't exist
93 nothing happens.
94 */
95 void removeEntry( const Addressee &, const QString &email=QString::null );
96
97 /**
98 Return list of email addresses, which belong to this distributon list.
99 These addresses can be directly used by e.g. a mail client.
100 */
101 QStringList emails() const;
102
103 /**
104 Return list of entries belonging to this distribution list. This function
105 is mainly useful for a distribution list editor.
106 */
107 Entry::List entries() const;
108
109 private:
110 DistributionListManager *mManager;
111 QString mName;
112
113 Entry::List mEntries;
114};
115
116/**
117 @short Manager of distribution lists
118
119 This class represents a collection of distribution lists, which are associated
120 with a given address book.
121*/
122class DistributionListManager
123{
124 public:
125 /**
126 Create manager for given address book.
127 */
128 DistributionListManager( AddressBook * );
129
130 /**
131 Destructor.
132 */
133 ~DistributionListManager();
134
135 /**
136 Return distribution list with given name.
137 */
138 DistributionList *list( const QString &name );
139
140 /**
141 Insert distribution list. If a list with this name already exists, nothing
142 happens.
143 */
144 void insert( DistributionList * );
145
146 /**
147 Remove distribution list. If a list with this name doesn't exist, nothing
148 happens.
149 */
150 void remove( DistributionList * );
151
152 /**
153 Return names of all distribution lists managed by this manager.
154 */
155 QStringList listNames();
156
157 /**
158 Load distribution lists form disk.
159 */
160 bool load();
161
162 /**
163 Save distribution lists to disk.
164 */
165 bool save();
166
167 private:
168 AddressBook *mAddressBook;
169
170 QPtrList<DistributionList> mLists;
171};
172
173/**
174 @short Watchdog for distribution lists
175
176 This class provides a @ref changed() signal that i emitted when the
177 distribution lists has changed in some way.
178
179 Exapmle:
180
181 <pre>
182 KABC::DistributionListWatcher *watchdog = KABC::DistributionListWatcher::self()
183
184 connect( watchdog, SIGNAL( changed() ), SLOT( doSomething() ) );
185 </pre>
186*/
187
188class DistributionListWatcher : public QObject
189{
190 Q_OBJECT
191
192 public:
193 /**
194 * Returns the watcher object.
195 */
196 static DistributionListWatcher *self();
197
198
199 signals:
200 /**
201 * This signal is emmitted whenever the distribution lists has
202 * changed (if a list was added or removed, when a list was
203 * renamed or the entries of the list changed).
204 */
205 void changed();
206
207 protected:
208 DistributionListWatcher();
209 ~DistributionListWatcher();
210
211 private:
212 static DistributionListWatcher* mSelf;
213#ifndef KAB_EMBEDDED
214 KDirWatch *mDirWatch;
215#endif //KAB_EMBEDDED
216};
217
218}
219#endif