summaryrefslogtreecommitdiffstats
path: root/kmail/distributionlistdialog.cpp
diff options
context:
space:
mode:
authortpearson <tpearson@283d02a7-25f6-0310-bc7c-ecb5cbfe19da>2010-09-01 00:37:02 +0000
committertpearson <tpearson@283d02a7-25f6-0310-bc7c-ecb5cbfe19da>2010-09-01 00:37:02 +0000
commitcc29364f06178f8f6b457384f2ec37a042bd9d43 (patch)
tree7c77a3184c698bbf9d98cef09fb1ba8124daceba /kmail/distributionlistdialog.cpp
parent4f6c584bacc8c3c694228f36ada3de77a76614a6 (diff)
downloadtdepim-cc29364f06178f8f6b457384f2ec37a042bd9d43.tar.gz
tdepim-cc29364f06178f8f6b457384f2ec37a042bd9d43.zip
* 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
Diffstat (limited to 'kmail/distributionlistdialog.cpp')
-rw-r--r--kmail/distributionlistdialog.cpp47
1 files changed, 31 insertions, 16 deletions
diff --git a/kmail/distributionlistdialog.cpp b/kmail/distributionlistdialog.cpp
index b591afd71..470518662 100644
--- a/kmail/distributionlistdialog.cpp
+++ b/kmail/distributionlistdialog.cpp
@@ -31,6 +31,7 @@
#ifdef KDEPIM_NEW_DISTRLISTS
#include <libkdepim/distributionlist.h>
#endif
+#include <libkdepim/kaddrbook.h>
#include <klistview.h>
#include <klocale.h>
@@ -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<DistributionListItem *>( 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();
+ }
}