DistributionList *DistributionListManager::list( const QString &name ) { DistributionList *list; for( list = mLists.first(); list; list = mLists.next() ) { if ( list->name() == name ) return list; } return 0; }
QStringList DistributionListManager::listNames() { QStringList names; DistributionList *list; for( list = mLists.first(); list; list = mLists.next() ) { names.append( list->name() ); } return names; }
void DistributionListManager::remove( DistributionList *l ) { if ( !l ) return; DistributionList *list; for( list = mLists.first(); list; list = mLists.next() ) { if ( list->name() == l->name() ) { mLists.remove( list ); return; } } }
void DistributionListManager::insert( DistributionList *l ) { if ( !l ) return; DistributionList *list; for( list = mLists.first(); list; list = mLists.next() ) { if ( list->name() == l->name() ) { mLists.remove( list ); break; } } mLists.append( l ); }
bool DistributionListManager::save() { kdDebug(5700) << "DistListManager::save()" << endl; KSimpleConfig cfg( locateLocal( "data", "kabc/distlists" ) ); cfg.deleteGroup( "DistributionLists" ); cfg.setGroup( "DistributionLists" ); DistributionList *list; for( list = mLists.first(); list; list = mLists.next() ) { kdDebug(5700) << " Saving '" << list->name() << "'" << endl; QStringList value; const DistributionList::Entry::List entries = list->entries(); DistributionList::Entry::List::ConstIterator it; for( it = entries.begin(); it != entries.end(); ++it ) { value.append( (*it).addressee.uid() ); value.append( (*it).email ); } if ( d->mMissingEntries.find( list->name() ) != d->mMissingEntries.end() ) { const MissingEntryList missList = d->mMissingEntries[ list->name() ]; MissingEntryList::ConstIterator missIt; for ( missIt = missList.begin(); missIt != missList.end(); ++missIt ) { value.append( (*missIt).first ); value.append( (*missIt).second ); } } cfg.writeEntry( list->name(), value ); } cfg.sync(); return true; }