21 #include <tqapplication.h>
23 #include <tqvaluelist.h>
25 #include <ksimpleconfig.h>
26 #include <kstandarddirs.h>
29 #include "distributionlist.h"
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();
200 TQStringList value = cfg.readListEntry( name );
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;
238 cfg.deleteGroup(
"DistributionLists" );
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 );
262 cfg.writeEntry( list->
name(), value );
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"
Watchdog for distribution lists.
TQString locateLocal(const char *type, const TQString &filename, const TDEInstance *instance=TDEGlobal::instance())
DistributionList(DistributionListManager *manager, const TQString &name)
Create distribution list object.
kdbgstream kdDebug(int area=0)
TQString fullEmail(const TQString &email=TQString::null) const
Return email address including real name.
Entry::List entries() const
Return list of entries belonging to this distribution list.
TQStringList listNames()
Return names of all distribution lists managed by this manager.
static data, shared by ALL addressee objects
TQString name() const
Get name of this list.
static DistributionListWatcher * self()
Returns the watcher object.
virtual TQMap< TQString, TQString > entryMap(const TQString &group) const =0
void removeEntry(const Addressee &, const TQString &email=TQString::null)
Remove an entry from this distribution list.
kdbgstream kdWarning(int area=0)
TQString uid() const
Return unique identifier.
bool save()
Save distribution lists to disk.
TQStringList emails() const
Return list of email addresses, which belong to this distributon list.
Distribution list of email addresses.
~DistributionList()
Destructor.
bool isEmpty() const
Return, if the address book entry is empty.
bool load()
Load distribution lists form disk.
void setName(const TQString &)
Set name of this list.
~DistributionListManager()
Destructor.
void remove(DistributionList *)
Remove distribution list.
DistributionList * list(const TQString &name)
Return distribution list with given name.
Manager of distribution lists.
DistributionListManager(AddressBook *)
Create manager for given address book.
void insert(DistributionList *)
Insert distribution list.
kndbgstream & endl(kndbgstream &s)
void insertEntry(const Addressee &, const TQString &email=TQString::null)
Insert an entry into this distribution list.