21 #include <tqapplication.h>
23 #include <tqvaluelist.h>
25 #include <ksimpleconfig.h>
26 #include <kstandarddirs.h>
29 #include "distributionlist.h"
31 using namespace TDEABC;
34 const TQString &name ) :
35 mManager( manager ), mName( name )
59 TQValueList<Entry>::Iterator it;
60 for( it = mEntries.begin(); it != mEntries.end(); ++it ) {
61 if ( (*it).addressee.uid() == a.
uid() ) {
66 if ( ( (*it).email.isNull() && email.isEmpty() ) ||
67 ( (*it).email.isEmpty() && email.isNull() ) ||
68 ( (*it).email == email ) ) {
79 TQValueList<Entry>::Iterator it;
80 for( it = mEntries.begin(); it != mEntries.end(); ++it ) {
81 if ( (*it).addressee.uid() == a.
uid() && (*it).email == email ) {
82 mEntries.remove( it );
92 Entry::List::ConstIterator it;
93 for( it = mEntries.begin(); it != mEntries.end(); ++it ) {
98 if ( !email.isEmpty() ) {
99 emails.append( email );
111 typedef TQValueList< QPair<TQString, TQString> > MissingEntryList;
113 class DistributionListManager::DistributionListManagerPrivate
117 TQMap< TQString, MissingEntryList > mMissingEntries;
121 : d( new DistributionListManagerPrivate )
123 d->mAddressBook = ab;
124 mLists.setAutoDelete(
true );
138 for( list = mLists.first();
list; list = mLists.next() ) {
139 if ( list->
name() == name )
return list;
151 for( list = mLists.first();
list; list = mLists.next() ) {
153 mLists.remove( list );
166 for( list = mLists.first();
list; list = mLists.next() ) {
168 mLists.remove( list );
179 for( list = mLists.first();
list; list = mLists.next() ) {
180 names.append( list->
name() );
190 TQMap<TQString,TQString> entryMap = cfg.
entryMap(
"DistributionLists" );
191 cfg.
setGroup(
"DistributionLists" );
195 d->mMissingEntries.clear();
197 TQMap<TQString,TQString>::ConstIterator it;
198 for( it = entryMap.constBegin(); it != entryMap.constEnd(); ++it ) {
199 TQString name = it.key();
202 kdDebug(5700) <<
"DLM::load(): " << name <<
": " << value.join(
",") <<
endl;
206 MissingEntryList missingEntries;
207 TQStringList::ConstIterator entryIt = value.constBegin();
208 while( entryIt != value.constEnd() ) {
209 TQString
id = *entryIt++;
210 TQString email = *entryIt;
214 Addressee a = d->mAddressBook->findByUid(
id );
218 missingEntries.append( qMakePair(
id, email ) );
221 if ( entryIt == value.end() )
226 d->mMissingEntries.insert( name, missingEntries );
234 kdDebug(5700) <<
"DistListManager::save()" <<
endl;
239 cfg.
setGroup(
"DistributionLists" );
242 for( list = mLists.first();
list; list = mLists.next() ) {
246 const DistributionList::Entry::List entries = list->
entries();
247 DistributionList::Entry::List::ConstIterator it;
248 for( it = entries.begin(); it != entries.end(); ++it ) {
249 value.append( (*it).addressee.uid() );
250 value.append( (*it).email );
253 if ( d->mMissingEntries.find( list->
name() ) != d->mMissingEntries.end() ) {
254 const MissingEntryList missList = d->mMissingEntries[ list->
name() ];
255 MissingEntryList::ConstIterator missIt;
256 for ( missIt = missList.begin(); missIt != missList.end(); ++missIt ) {
257 value.append( (*missIt).first );
258 value.append( (*missIt).second );
272 DistributionListWatcher::DistributionListWatcher()
273 : TQObject( tqApp,
"DistributionListWatcher" )
275 mDirWatch =
new KDirWatch;
276 mDirWatch->addFile(
locateLocal(
"data",
"tdeabc/distlists" ) );
278 connect( mDirWatch, TQT_SIGNAL( dirty(
const TQString& ) ), TQT_SIGNAL( changed() ) );
279 mDirWatch->startScan();
282 DistributionListWatcher::~DistributionListWatcher()
290 kdWarning( !tqApp ) <<
"No TQApplication object available, you'll get a memleak!" <<
endl;
298 #include "distributionlist.moc"