summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorChristian Mollekopf <mollekopf@kolabsys.com>2015-05-07 17:01:37 +0200
committerChristian Mollekopf <mollekopf@kolabsys.com>2015-05-07 17:01:37 +0200
commit36e1279dedaa9cf4c6e215b7e5c3b24e4364abed (patch)
treed489c11a3f4127ae9fbc86f8ec3ef25771f2c985
parent572dd4e413f3b98196a2e9e0b1ad090e6f1daa01 (diff)
downloadlibkolab-36e1279dedaa9cf4c6e215b7e5c3b24e4364abed.tar.gz
Removed unused code from mimeutils
-rw-r--r--kolabformat/v2helpers.cpp21
-rw-r--r--kolabformat/v2helpers.h9
-rw-r--r--mime/mimeutils.cpp126
-rw-r--r--mime/mimeutils.h12
4 files changed, 32 insertions, 136 deletions
diff --git a/kolabformat/v2helpers.cpp b/kolabformat/v2helpers.cpp
index f7e7d0c..1a84c86 100644
--- a/kolabformat/v2helpers.cpp
+++ b/kolabformat/v2helpers.cpp
@@ -38,6 +38,27 @@
namespace Kolab {
+void getAttachments(KCalCore::Incidence::Ptr incidence, const QStringList &attachments, const KMime::Message::Ptr &mimeData)
+{
+ if (!incidence) {
+ Error() << "Invalid incidence";
+ return;
+ }
+ foreach (const QString &name, attachments) {
+ QByteArray type;
+ KMime::Content *content = Mime::findContentByName(mimeData, name, type);
+ if (!content) { // guard against malformed events with non-existent attachments
+ Warning() << "could not find attachment: "<< name.toUtf8() << type;
+ continue;
+ }
+ const QByteArray c = content->decodedContent().toBase64();
+ KCalCore::Attachment::Ptr attachment( new KCalCore::Attachment( c, QString::fromLatin1( type ) ) );
+ attachment->setLabel( name );
+ incidence->addAttachment(attachment);
+ Debug() << "ATTACHMENT NAME" << name << type;
+ }
+}
+
static QImage getPicture(const QString &pictureAttachmentName, const KMime::Message::Ptr &data, QByteArray &type)
{
if (!data) {
diff --git a/kolabformat/v2helpers.h b/kolabformat/v2helpers.h
index a6d1a61..ed92f8a 100644
--- a/kolabformat/v2helpers.h
+++ b/kolabformat/v2helpers.h
@@ -31,6 +31,11 @@
#include "kolabformat/errorhandler.h"
#include <kcontacts/contactgroup.h>
+#include <kcontacts/addressee.h>
+#include <kcalcore/incidence.h>
+#include <kcalcore/event.h>
+#include <kdatetime.h>
+#include <kmime/kmime_message.h>
#include <qdom.h>
#include <qbuffer.h>
@@ -59,6 +64,8 @@ static KCalPtr fromXML(const QByteArray &xmlData, QStringList &attachments)
return i;
}
+void getAttachments(KCalCore::Incidence::Ptr incidence, const QStringList &attachments, const KMime::Message::Ptr &mimeData);
+
template <typename IncidencePtr, typename Converter>
static inline IncidencePtr incidenceFromKolabImpl( const KMime::Message::Ptr &data, const QByteArray &mimetype, const QString &timezoneId )
{
@@ -71,7 +78,7 @@ static inline IncidencePtr incidenceFromKolabImpl( const KMime::Message::Ptr &da
QStringList attachments;
IncidencePtr ptr = fromXML<IncidencePtr, Converter>(xmlData, attachments); //TODO do we care about timezone?
- Mime::getAttachments(ptr, attachments, data);
+ getAttachments(ptr, attachments, data);
return ptr;
}
diff --git a/mime/mimeutils.cpp b/mime/mimeutils.cpp
index 7b22c29..3492912 100644
--- a/mime/mimeutils.cpp
+++ b/mime/mimeutils.cpp
@@ -19,7 +19,7 @@
#include <quuid.h>
#include <QtCore/qfile.h>
#include <qdom.h>
-#include <kcontacts/addressee.h>
+#include <kdatetime.h>
#include "kolabformat/kolabdefinitions.h"
#include "kolabformat/errorhandler.h"
#include <kolabformat.h>
@@ -115,77 +115,6 @@ KMime::Message::Ptr createMessage(const std::string &mimetype, const std::string
return createMessage(QByteArray(mimetype.c_str()), QByteArray(xKolabType.c_str()), QByteArray(xml.c_str()), v3, QByteArray(productId.data()), QByteArray(fromEmail.c_str()), QString::fromStdString(fromName), QString::fromStdString(subject));
}
-//TODO remove
-KMime::Message::Ptr createMessage(const KCalCore::Incidence::Ptr &incidencePtr, const QString &mimetype, const QString &xKolabType, const QByteArray &xml, bool v3, const QString &productId)
-{
- KMime::Message::Ptr message = createMessage( xKolabType.toLatin1(), v3, productId.toLatin1() );
- if (!incidencePtr) {
- Error() << "invalid incidence passed in";
- message->assemble();
- return message;
- }
- if ( incidencePtr->organizer() && !incidencePtr->organizer()->email().isEmpty()) {
- message->from()->addAddress( incidencePtr->organizer()->email().toUtf8(), incidencePtr->organizer()->name() );
- }
- message->subject()->fromUnicodeString( incidencePtr->uid(), "utf-8" );
-
- KMime::Content *content = createMainPart( mimetype.toLatin1(), xml );
- message->addContent( content );
-
- Q_FOREACH (KCalCore::Attachment::Ptr attachment, incidencePtr->attachments()) {
- //Serialize the attachment as attachment with uri, referencing the created mime-part
- if (v3 && !attachment->uri().contains("cid:")) {
- //onyl by url, skip
- continue;
- }
- message->addContent( createAttachmentPart(fromCid(attachment->uri()).toLatin1(), attachment->mimeType().toLatin1(), attachment->label(), attachment->decodedData() ) );
- }
-
- message->assemble();
- return message;
-}
-
-KMime::Message::Ptr createMessage(const KContacts::Addressee &contact, const QString &mimetype, const QString &xKolabType, const QByteArray &xml, bool v3, const QString &prodid)
-{
- KMime::Message::Ptr message = Mime::createMessage( xKolabType.toLatin1(), v3, prodid.toLatin1() );
- message->subject()->fromUnicodeString( contact.uid(), "utf-8" );
- message->from()->fromUnicodeString( contact.fullEmail(), "utf-8" );
-
- KMime::Content* content = Mime::createMainPart( mimetype.toLatin1(), xml );
- message->addContent( content );
-
-// TODO add pictures as separate mimeparts
-// if ( !contact.picture().isNull() ) {
-// QByteArray pic;
-// QBuffer buffer(&pic);
-// buffer.open(QIODevice::WriteOnly);
-// contact.picture().save(&buffer, "PNG");
-// buffer.close();
-//
-// content = Mime::createAttachmentPart(QByteArray(), "image/png", "kolab-picture.png", pic );
-// message->addContent(content);
-// }
-//
-// if ( !contact.logo().isNull() ) {
-// QByteArray pic;
-// QBuffer buffer(&pic);
-// buffer.open(QIODevice::WriteOnly);
-// contact.logo().save(&buffer, "PNG");
-// buffer.close();
-//
-// content = Mime::createAttachmentPart(QByteArray(), "image/png", "kolab-logo.png", pic );
-// message->addContent(content);
-// }
-//
-// if ( !contact.sound().isEmpty() ) {
-// content = Mime::createAttachmentPart(QByteArray(), "audio/unknown", "sound", contact.sound() );
-// message->addContent(content);
-// }
-
- message->assemble();
- return message;
-}
-
KMime::Message::Ptr createMessage(const QString &subject, const QString &mimetype, const QString &xKolabType, const QByteArray &xml, bool v3, const QString &prodid)
{
KMime::Message::Ptr message = createMessage( xKolabType.toLatin1(), v3, prodid.toLatin1() );
@@ -265,59 +194,6 @@ KMime::Content* createAttachmentPart(const QByteArray& cid, const QByteArray& mi
return content;
}
-void getAttachments(KCalCore::Incidence::Ptr incidence, const QStringList &attachments, const KMime::Message::Ptr &mimeData)
-{
- if (!incidence) {
- Error() << "Invalid incidence";
- return;
- }
-// qDebug() << "getting " << attachments.size() << "attachments";
-// qDebug() << mimeData->encodedContent();
- foreach (const QString &name, attachments) {
- QByteArray type;
- KMime::Content *content = findContentByName(mimeData, name, type);
- if (!content) { // guard against malformed events with non-existent attachments
- Warning() << "could not find attachment: "<< name.toUtf8() << type;
- continue;
- }
- const QByteArray c = content->decodedContent().toBase64();
-// Debug() << c;
- KCalCore::Attachment::Ptr attachment( new KCalCore::Attachment( c, QString::fromLatin1( type ) ) );
- attachment->setLabel( name );
- incidence->addAttachment(attachment);
- Debug() << "ATTACHMENT NAME" << name << type;
- }
-}
-
-void getAttachmentsById(KCalCore::Incidence::Ptr incidence, const KMime::Message::Ptr &mimeData)
-{
- if (!incidence) {
- Error() << "Invalid incidence";
- return;
- }
-// qDebug() << "getting " << attachments.size() << "attachments";
-// qDebug() << mimeData->encodedContent();
-
- foreach(KCalCore::Attachment::Ptr attachment, incidence->attachments()) {
- Debug() << attachment->uri();
- if (!attachment->uri().contains("cid:")) {
- continue;
- }
- //It's a referenced attachmant, extract it
- QByteArray type;
- QString name;
- KMime::Content *content = findContentById(mimeData, fromCid(attachment->uri()).toLatin1(), type, name);
- if (!content) { // guard against malformed events with non-existent attachments
- Error() << "could not find attachment: "<< name << type;
- continue;
- }
- attachment->setUri(QString());
- attachment->setData(content->decodedContent().toBase64());
- attachment->setMimeType(type);
- attachment->setLabel(name);
- }
-}
-
Kolab::Attachment getAttachment(const std::string &id, const KMime::Message::Ptr &mimeData)
{
if (!QString::fromStdString(id).contains("cid:")) {
diff --git a/mime/mimeutils.h b/mime/mimeutils.h
index b4916df..b397a89 100644
--- a/mime/mimeutils.h
+++ b/mime/mimeutils.h
@@ -20,10 +20,8 @@
#include "kolab_export.h"
-#include <kcalcore/incidence.h>
-#include <kcalcore/event.h>
#include <kmime/kmime_message.h>
-#include <kcontacts/addressee.h>
+
class QDomDocument;
namespace Kolab {
@@ -39,10 +37,6 @@ QList<QByteArray> getContentMimeTypeList(const KMime::Message::Ptr &data);
*
* Set the attachments listed in @param attachments on @param incidence from @param mimeData
*/
-//v2
-void getAttachments(KCalCore::Incidence::Ptr incidence, const QStringList &attachments, const KMime::Message::Ptr &mimeData);
-//v3
-void getAttachmentsById(KCalCore::Incidence::Ptr incidence, const KMime::Message::Ptr &mimeData);
Kolab::Attachment getAttachment(const std::string &id, const KMime::Message::Ptr &mimeData);
Kolab::Attachment getAttachmentByName(const QString &name, const KMime::Message::Ptr &mimeData);
@@ -52,12 +46,10 @@ KMime::Message::Ptr createMessage(const std::string &mimetype, const std::string
const std::string &fromEmail, const std::string &fromName, const std::string &subject);
///Generic serializing functions
-KMime::Message::Ptr createMessage(const KCalCore::Incidence::Ptr &incidencePtr, const QString &mimetype, const QString &xKolabType, const QByteArray &xml, bool v3, const QString &prodid);
-KMime::Message::Ptr createMessage(const KContacts::Addressee &contact, const QString &mimetype, const QString &xKolabType, const QByteArray &xml, bool v3, const QString &prodid);
KMime::Message::Ptr createMessage(const QString &subject, const QString &mimetype, const QString &xKolabType, const QByteArray &xml, bool v3, const QString &prodid);
+KMime::Message::Ptr createMessage(const QByteArray& mimeType, bool v3, const QByteArray &prodid);
KMime::Content* createExplanationPart();
-KMime::Message::Ptr createMessage(const QByteArray& mimeType, bool v3, const QByteArray &prodid);
KMime::Content* createMainPart(const QByteArray& mimeType, const QByteArray& decodedContent);
KMime::Content* createAttachmentPart(const QByteArray& cid, const QByteArray& mimeType, const QString& fileName, const QByteArray& decodedContent);
QString fromCid(const QString &cid);