summaryrefslogtreecommitdiffabout
path: root/kabc
Unidiff
Diffstat (limited to 'kabc') (more/less context) (ignore whitespace changes)
-rw-r--r--kabc/distributionlist.cpp4
-rw-r--r--kabc/distributionlist.h17
2 files changed, 8 insertions, 13 deletions
diff --git a/kabc/distributionlist.cpp b/kabc/distributionlist.cpp
index 1fb186e..d34ba0b 100644
--- a/kabc/distributionlist.cpp
+++ b/kabc/distributionlist.cpp
@@ -215,78 +215,78 @@ bool DistributionListManager::load()
215 } 215 }
216 216
217 return true; 217 return true;
218} 218}
219 219
220bool DistributionListManager::save() 220bool DistributionListManager::save()
221{ 221{
222 222
223 223
224 KSimpleConfig cfg( locateLocal( "data", "kabc/distlists" ) ); 224 KSimpleConfig cfg( locateLocal( "data", "kabc/distlists" ) );
225 225
226 cfg.deleteGroup( mAddressBook->identifier() ); 226 cfg.deleteGroup( mAddressBook->identifier() );
227 cfg.setGroup( mAddressBook->identifier() ); 227 cfg.setGroup( mAddressBook->identifier() );
228 228
229 DistributionList *list; 229 DistributionList *list;
230 for( list = mLists.first(); list; list = mLists.next() ) { 230 for( list = mLists.first(); list; list = mLists.next() ) {
231 kdDebug(5700) << " Saving '" << list->name() << "'" << endl; 231 kdDebug(5700) << " Saving '" << list->name() << "'" << endl;
232 QStringList value; 232 QStringList value;
233 DistributionList::Entry::List entries = list->entries(); 233 DistributionList::Entry::List entries = list->entries();
234 DistributionList::Entry::List::ConstIterator it; 234 DistributionList::Entry::List::ConstIterator it;
235 for( it = entries.begin(); it != entries.end(); ++it ) { 235 for( it = entries.begin(); it != entries.end(); ++it ) {
236 value.append( (*it).addressee.uid() ); 236 value.append( (*it).addressee.uid() );
237 if (( *it).email.isEmpty()) 237 if (( *it).email.isEmpty())
238 value.append( " " ); 238 value.append( " " );
239 else 239 else
240 value.append( (*it).email ); 240 value.append( (*it).email );
241 // qDebug("uid *%s* email *%s* ", (*it).addressee.uid().latin1(),(*it).email.latin1() ); 241 // qDebug("uid *%s* email *%s* ", (*it).addressee.uid().latin1(),(*it).email.latin1() );
242 } 242 }
243 cfg.writeEntry( list->name(), value ); 243 cfg.writeEntry( list->name(), value );
244 } 244 }
245 245
246//US for microKDE we have not yet sophisticated methods to load maps. 246//US for microKDE we have not yet sophisticated methods to load maps.
247// Because of that we store also a list of all distributionlists. 247// Because of that we store also a list of all distributionlists.
248 QStringList namelist; 248 QStringList namelist;
249 for( list = mLists.first(); list; list = mLists.next() ) { 249 for( list = mLists.first(); list; list = mLists.next() ) {
250 namelist.append( list->name() ); 250 namelist.append( list->name() );
251 } 251 }
252 cfg.writeEntry( "__Lists__List__", namelist ); 252 cfg.writeEntry( "__Lists__List__", namelist );
253 253
254 254
255 255
256 256
257 257
258 258
259 cfg.sync(); 259 cfg.sync();
260 260
261 return true; 261 return true;
262} 262}
263 263#if 0
264DistributionListWatcher* DistributionListWatcher::mSelf = 0; 264DistributionListWatcher* DistributionListWatcher::mSelf = 0;
265 265
266DistributionListWatcher::DistributionListWatcher() 266DistributionListWatcher::DistributionListWatcher()
267 : QObject( 0, "DistributionListWatcher" ) 267 : QObject( 0, "DistributionListWatcher" )
268{ 268{
269 269
270 mDirWatch = new KDirWatch; 270 mDirWatch = new KDirWatch;
271 mDirWatch->addFile( locateLocal( "data", "kabc/distlists" ) ); 271 mDirWatch->addFile( locateLocal( "data", "kabc/distlists" ) );
272 272
273 connect( mDirWatch, SIGNAL( dirty( const QString& ) ), SIGNAL( changed() ) ); 273 connect( mDirWatch, SIGNAL( dirty( const QString& ) ), SIGNAL( changed() ) );
274 mDirWatch->startScan(); 274 mDirWatch->startScan();
275} 275}
276 276
277DistributionListWatcher::~DistributionListWatcher() 277DistributionListWatcher::~DistributionListWatcher()
278{ 278{
279 delete mDirWatch; 279 delete mDirWatch;
280 mDirWatch = 0; 280 mDirWatch = 0;
281} 281}
282 282
283DistributionListWatcher *DistributionListWatcher::self() 283DistributionListWatcher *DistributionListWatcher::self()
284{ 284{
285 if ( !mSelf ) 285 if ( !mSelf )
286 mSelf = new DistributionListWatcher(); 286 mSelf = new DistributionListWatcher();
287 287
288 return mSelf; 288 return mSelf;
289} 289}
290 290#endif
291//US #include "distributionlist.moc" 291//US #include "distributionlist.moc"
292 292
diff --git a/kabc/distributionlist.h b/kabc/distributionlist.h
index 584f287..c81e543 100644
--- a/kabc/distributionlist.h
+++ b/kabc/distributionlist.h
@@ -1,72 +1,72 @@
1/* 1/*
2 This file is part of libkabc. 2 This file is part of libkabc.
3 Copyright (c) 2001 Cornelius Schumacher <schumacher@kde.org> 3 Copyright (c) 2001 Cornelius Schumacher <schumacher@kde.org>
4 4
5 This library is free software; you can redistribute it and/or 5 This library is free software; you can redistribute it and/or
6 modify it under the terms of the GNU Library General Public 6 modify it under the terms of the GNU Library General Public
7 License as published by the Free Software Foundation; either 7 License as published by the Free Software Foundation; either
8 version 2 of the License, or (at your option) any later version. 8 version 2 of the License, or (at your option) any later version.
9 9
10 This library is distributed in the hope that it will be useful, 10 This library is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of 11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 Library General Public License for more details. 13 Library General Public License for more details.
14 14
15 You should have received a copy of the GNU Library General Public License 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 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, 17 the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
18 Boston, MA 02111-1307, USA. 18 Boston, MA 02111-1307, USA.
19*/ 19*/
20 20
21#ifndef KABC_DISTRIBUTIONLIST_H 21#ifndef KABC_DISTRIBUTIONLIST_H
22#define KABC_DISTRIBUTIONLIST_H 22#define KABC_DISTRIBUTIONLIST_H
23 23
24#include <kdirwatch.h> 24//#include <kdirwatch.h>
25 25
26#include "addressbook.h" 26#include "addressbook.h"
27 27
28namespace KABC { 28namespace KABC {
29 29
30class DistributionListManager; 30class DistributionListManager;
31 31
32/** 32/**
33 @short Distribution list of email addresses 33 @short Distribution list of email addresses
34 34
35 This class represents a list of email addresses. Each email address is 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 36 associated with an address book entry. If the address book entry changes, the
37 entry in the distribution list is automatically updated. 37 entry in the distribution list is automatically updated.
38*/ 38*/
39class DistributionList 39class DistributionList
40{ 40{
41 public: 41 public:
42 /** 42 /**
43 @short Distribution List Entry 43 @short Distribution List Entry
44 44
45 This class represents an entry of a distribution list. It consists of an 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 46 addressee and an email address. If the email address is null, the
47 preferred email address of the addressee is used. 47 preferred email address of the addressee is used.
48 */ 48 */
49 struct Entry 49 struct Entry
50 { 50 {
51 typedef QValueList<Entry> List; 51 typedef QValueList<Entry> List;
52 52
53 Entry() {} 53 Entry() {}
54 Entry( const Addressee &_addressee, const QString &_email ) : 54 Entry( const Addressee &_addressee, const QString &_email ) :
55 addressee( _addressee ), email( _email ) {} 55 addressee( _addressee ), email( _email ) {}
56 56
57 Addressee addressee; 57 Addressee addressee;
58 QString email; 58 QString email;
59 }; 59 };
60 60
61 /** 61 /**
62 Create distribution list object. 62 Create distribution list object.
63 63
64 @param manager Managing object of this list. 64 @param manager Managing object of this list.
65 @param name Name of this list. 65 @param name Name of this list.
66 */ 66 */
67 DistributionList( DistributionListManager *manager, const QString &name ); 67 DistributionList( DistributionListManager *manager, const QString &name );
68 68
69 /** 69 /**
70 Destructor. 70 Destructor.
71 */ 71 */
72 ~DistributionList(); 72 ~DistributionList();
@@ -140,78 +140,73 @@ class DistributionListManager
140 /** 140 /**
141 Insert distribution list. If a list with this name already exists, nothing 141 Insert distribution list. If a list with this name already exists, nothing
142 happens. 142 happens.
143 */ 143 */
144 void insert( DistributionList * ); 144 void insert( DistributionList * );
145 145
146 /** 146 /**
147 Remove distribution list. If a list with this name doesn't exist, nothing 147 Remove distribution list. If a list with this name doesn't exist, nothing
148 happens. 148 happens.
149 */ 149 */
150 void remove( DistributionList * ); 150 void remove( DistributionList * );
151 151
152 /** 152 /**
153 Return names of all distribution lists managed by this manager. 153 Return names of all distribution lists managed by this manager.
154 */ 154 */
155 QStringList listNames(); 155 QStringList listNames();
156 156
157 /** 157 /**
158 Load distribution lists form disk. 158 Load distribution lists form disk.
159 */ 159 */
160 bool load(); 160 bool load();
161 161
162 /** 162 /**
163 Save distribution lists to disk. 163 Save distribution lists to disk.
164 */ 164 */
165 bool save(); 165 bool save();
166 166
167 private: 167 private:
168 AddressBook *mAddressBook; 168 AddressBook *mAddressBook;
169 169
170 QPtrList<DistributionList> mLists; 170 QPtrList<DistributionList> mLists;
171}; 171};
172 172
173/** 173/**
174 @short Watchdog for distribution lists 174 @short Watchdog for distribution lists
175 175
176 This class provides a @ref changed() signal that i emitted when the 176 This class provides a @ref changed() signal that i emitted when the
177 distribution lists has changed in some way. 177 distribution lists has changed in some way.
178 178
179 Exapmle: 179 Exapmle:
180 180
181 <pre> 181 <pre>
182 KABC::DistributionListWatcher *watchdog = KABC::DistributionListWatcher::self() 182 KABC::DistributionListWatcher *watchdog = KABC::DistributionListWatcher::self()
183 183
184 connect( watchdog, SIGNAL( changed() ), SLOT( doSomething() ) ); 184 connect( watchdog, SIGNAL( changed() ), SLOT( doSomething() ) );
185 </pre> 185 </pre>
186*/ 186*/
187 187
188/*
188class DistributionListWatcher : public QObject 189class DistributionListWatcher : public QObject
189{ 190{
190 Q_OBJECT 191 Q_OBJECT_XX
191 192
192 public: 193 public:
193 /** 194
194 * Returns the watcher object.
195 */
196 static DistributionListWatcher *self(); 195 static DistributionListWatcher *self();
197 196
198 197
199 signals: 198 signals:
200 /** 199
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(); 200 void changed();
206 201
207 protected: 202 protected:
208 DistributionListWatcher(); 203 DistributionListWatcher();
209 ~DistributionListWatcher(); 204 ~DistributionListWatcher();
210 205
211 private: 206 private:
212 static DistributionListWatcher* mSelf; 207 static DistributionListWatcher* mSelf;
213 KDirWatch *mDirWatch; 208 KDirWatch *mDirWatch;
214}; 209};
215 210*/
216} 211}
217#endif 212#endif