diff --git a/editor/kmcomposewin.cpp b/editor/kmcomposewin.cpp index 7c028e6a7..371322d9a 100644 --- a/editor/kmcomposewin.cpp +++ b/editor/kmcomposewin.cpp @@ -73,6 +73,7 @@ #include "messagecomposer/utils/util.h" +#include #include "agents/sendlateragent/sendlaterutil.h" #include "agents/sendlateragent/sendlaterdialog.h" #include "agents/sendlateragent/sendlaterinfo.h" @@ -175,6 +176,7 @@ #include #include #include +#include using Sonnet::DictionaryComboBox; using MailTransport::TransportManager; @@ -2333,6 +2335,15 @@ void KMComposeWin::slotFetchJob(KJob*job) QByteArray data = item.payloadData(); MessageComposer::Util::adaptVcard(data); addAttachment( attachmentName, KMime::Headers::CEbase64, QString(), data, item.mimeType().toLatin1() ); + } else if ( item.hasPayload() ) { + const KABC::ContactGroup group = item.payload(); + attachmentName = group.name() + QLatin1String( ".vcf" ); + Akonadi::ContactGroupExpandJob *expandJob = new Akonadi::ContactGroupExpandJob( group, this ); + expandJob->setProperty("groupName", attachmentName); + connect( expandJob, SIGNAL(result(KJob*)), this, SLOT(slotExpandGroupResult(KJob*)) ); + expandJob->start(); + + //TODO contact group } else { addAttachment( attachmentName, KMime::Headers::CEbase64, QString(), item.payloadData(), item.mimeType().toLatin1() ); } @@ -2340,6 +2351,21 @@ void KMComposeWin::slotFetchJob(KJob*job) } } +void KMComposeWin::slotExpandGroupResult(KJob *job) +{ + Akonadi::ContactGroupExpandJob *expandJob = qobject_cast( job ); + Q_ASSERT( expandJob ); + + const QString attachmentName = expandJob->property("groupName").toString(); + const QByteArray mimeType = "text/x-vcard"; + KABC::VCardConverter converter; + const QByteArray groupData = converter.createVCards(expandJob->contacts()); + if (!groupData.isEmpty()) { + addAttachment( attachmentName, KMime::Headers::CEbase64, QString(), groupData, mimeType ); + } +} + + QString KMComposeWin::addQuotesToText( const QString &inputText ) const { QString answer( inputText ); diff --git a/editor/kmcomposewin.h b/editor/kmcomposewin.h index 1ebf8d215..0ee005e66 100644 --- a/editor/kmcomposewin.h +++ b/editor/kmcomposewin.h @@ -448,6 +448,7 @@ private slots: void slotSendNowByShortcut(); void slotSnippetWidgetVisibilityChanged(bool b); void slotOverwriteModeWasChanged(bool state); + void slotExpandGroupResult(KJob *job); public: // kmcommand // FIXME we need to remove these, but they're pure virtual in Composer. void addAttach( KMime::Content *msgPart );