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() ) {
111 typedef TQValueList< TQPair<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() ) {
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() ) {
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, TQ_SIGNAL( dirty(
const TQString& ) ), TQ_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"
TQString fullEmail(const TQString &email=TQString::null) const
Return email address including real name.
bool isEmpty() const
Return, if the address book entry is empty.
TQString uid() const
Return unique identifier.
Manager of distribution lists.
DistributionList * list(const TQString &name)
Return distribution list with given name.
~DistributionListManager()
Destructor.
bool load()
Load distribution lists form disk.
void insert(DistributionList *)
Insert distribution list.
bool save()
Save distribution lists to disk.
void remove(DistributionList *)
Remove distribution list.
TQStringList listNames()
Return names of all distribution lists managed by this manager.
DistributionListManager(AddressBook *)
Create manager for given address book.
Watchdog for distribution lists.
static DistributionListWatcher * self()
Returns the watcher object.
Distribution list of email addresses.
void setName(const TQString &)
Set name of this list.
~DistributionList()
Destructor.
void insertEntry(const Addressee &, const TQString &email=TQString::null)
Insert an entry into this distribution list.
DistributionList(DistributionListManager *manager, const TQString &name)
Create distribution list object.
void removeEntry(const Addressee &, const TQString &email=TQString::null)
Remove an entry from this distribution list.
TQString name() const
Get name of this list.
Entry::List entries() const
Return list of entries belonging to this distribution list.
TQStringList emails() const
Return list of email addresses, which belong to this distributon list.
bool deleteGroup(const TQString &group, bool bDeep=true, bool bGlobal=false)
int readListEntry(const TQString &pKey, TQStrList &list, char sep=',') const
void writeEntry(const TQString &pKey, const TQString &pValue, bool bPersistent=true, bool bGlobal=false, bool bNLS=false)
void setGroup(const TQString &group)
virtual TQMap< TQString, TQString > entryMap(const TQString &pGroup) const
kndbgstream & endl(kndbgstream &s)
kdbgstream kdWarning(int area=0)
kdbgstream kdDebug(int area=0)
TQString locateLocal(const char *type, const TQString &filename, const TDEInstance *instance=TDEGlobal::instance())
static data, shared by ALL addressee objects