From cc29364f06178f8f6b457384f2ec37a042bd9d43 Mon Sep 17 00:00:00 2001 From: tpearson Date: Wed, 1 Sep 2010 00:37:02 +0000 Subject: * Massive set of changes to bring in all fixes and enhancements from the Enterprise PIM branch * Ensured that the Trinity changes were applied on top of those enhancements, and any redundancy removed * Added journal read support to the CalDAV resource * Fixed CalDAV resource to use events URL for tasks and journals when separate URL checkbox unchecked git-svn-id: svn://anonsvn.kde.org/home/kde/branches/trinity/kdepim@1170461 283d02a7-25f6-0310-bc7c-ecb5cbfe19da --- kmail/distributionlistdialog.cpp | 47 ++++++++++++++++++++++++++-------------- 1 file changed, 31 insertions(+), 16 deletions(-) (limited to 'kmail/distributionlistdialog.cpp') diff --git a/kmail/distributionlistdialog.cpp b/kmail/distributionlistdialog.cpp index b591afd7..47051866 100644 --- a/kmail/distributionlistdialog.cpp +++ b/kmail/distributionlistdialog.cpp @@ -31,6 +31,7 @@ #ifdef KDEPIM_NEW_DISTRLISTS #include #endif +#include #include #include @@ -153,8 +154,6 @@ void DistributionListDialog::slotUser1() { bool isEmpty = true; - KABC::AddressBook *ab = KABC::StdAddressBook::self( true ); - TQListViewItem *i = mRecipientsList->firstChild(); while( i ) { DistributionListItem *item = static_cast( i ); @@ -188,6 +187,8 @@ void DistributionListDialog::slotUser1() return; } + KABC::AddressBook *ab = KABC::StdAddressBook::self( true ); + #ifdef KDEPIM_NEW_DISTRLISTS if ( !KPIM::DistributionList::findByName( ab, name ).isEmpty() ) { #else @@ -199,6 +200,18 @@ void DistributionListDialog::slotUser1() return; } + KABC::Resource* const resource = KAddrBookExternal::selectResourceForSaving( ab ); + if ( !resource ) + return; + + // Ask for a save ticket here, we use it for inserting the recipients into the addressbook and + // also for saving the addressbook, see https://issues.kolab.org/issue4281 + KABC::Ticket *ticket = ab->requestSaveTicket( resource ); + if ( !ticket ) { + kdWarning(5006) << "Unable to get save ticket!" << endl; + return; + } + #ifdef KDEPIM_NEW_DISTRLISTS KPIM::DistributionList dlist; dlist.setName( name ); @@ -209,7 +222,7 @@ void DistributionListDialog::slotUser1() if ( item->isOn() ) { kdDebug() << " " << item->addressee().fullEmail() << endl; if ( item->isTransient() ) { - ab->insertAddressee( item->addressee() ); + resource->insertAddressee( item->addressee() ); } if ( item->email() == item->addressee().preferredEmail() ) { dlist.insertEntry( item->addressee() ); @@ -220,7 +233,7 @@ void DistributionListDialog::slotUser1() i = i->nextSibling(); } - ab->insertAddressee( dlist ); + resource->insertAddressee( dlist ); #else KABC::DistributionList *dlist = new KABC::DistributionList( &manager, name ); i = mRecipientsList->firstChild(); @@ -229,7 +242,7 @@ void DistributionListDialog::slotUser1() if ( item->isOn() ) { kdDebug() << " " << item->addressee().fullEmail() << endl; if ( item->isTransient() ) { - ab->insertAddressee( item->addressee() ); + resource->insertAddressee( item->addressee() ); } if ( item->email() == item->addressee().preferredEmail() ) { dlist->insertEntry( item->addressee() ); @@ -241,21 +254,23 @@ void DistributionListDialog::slotUser1() } #endif - // FIXME: Ask the user which resource to save to instead of the default - bool saveError = true; - KABC::Ticket *ticket = ab->requestSaveTicket( 0 /*default resource */ ); - if ( ticket ) - if ( ab->save( ticket ) ) - saveError = false; - else - ab->releaseSaveTicket( ticket ); - - if ( saveError ) + if ( !ab->save( ticket ) ) { kdWarning(5006) << k_funcinfo << " Couldn't save new addresses in the distribution list just created to the address book" << endl; + ab->releaseSaveTicket( ticket ); + return; + } #ifndef KDEPIM_NEW_DISTRLISTS manager.save(); #endif - close(); + // Only accept when the dist list is really in the addressbook, since we can't detect if the + // user aborted saving in another way, since insertAddressee() lacks a return code. +#ifdef KDEPIM_NEW_DISTRLISTS + if ( !KPIM::DistributionList::findByName( ab, name ).isEmpty() ) { +#else + if ( manager.list( name ) ) { +#endif + accept(); + } } -- cgit v1.2.3