KDE PIM support for the p≡p engine
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 

129 lines
4.4 KiB

#include "pephelpers.h"
KMime::Message::Ptr pEpKDE::to_mMessage(message *m)
{
KMime::Message::Ptr mMessage;
if(!m) {
return mMessage;
}
mMessage->from()->from7BitString( QByteArray(m->from->address) );
mMessage->to()->from7BitString( QByteArray(m->to->ident->address) );
foreach ( KMime::Content *attachment, mMessage->contents() ) {
attachment->setContent(QByteArray("pEp"));
attachment->contentType()->setMimeType(QByteArray("text/plain"));
}
return mMessage;
}
void pEpKDE::mboxlist_to_message(KMime::Types::Mailbox::List mboxlist, identity_list* peplist)
{
KMime::Types::Mailbox mbox;
foreach ( mbox, mboxlist ) {
peplist = identity_list_add(peplist,
new_identity(
mbox.address().data(),
"",
mbox.address().split('@').at(0).data(),
mbox.name().toLatin1().data()
)
);
}
}
message* pEpKDE::to_pEpMessage(KMime::Message::Ptr mMessage, PEP_msg_direction direction)
{
KMime::Types::Mailbox mbox;
if(!mMessage)
return NULL;
message *m = new_message(direction);
if(!m)
return NULL;
m->longmsg = mMessage->decodedContent().data(),
m->longmsg_formatted = mMessage->decodedContent().data(),
mbox = mMessage->from()->mailboxes().at(0);
m->from = new_identity(
mbox.address().data(),
"",
mbox.address().split('@').at(0).data(),
mbox.name().toLatin1().data()
);
mboxlist_to_message( mMessage->to()->mailboxes(), m->to );
mboxlist_to_message( mMessage->cc()->mailboxes(), m->cc );
mboxlist_to_message( mMessage->bcc()->mailboxes(), m->bcc );
mboxlist_to_message( mMessage->replyTo()->mailboxes(), m->reply_to );
foreach ( KMime::Content *attachment, mMessage->contents() ) {
m->attachments = bloblist_add(
m->attachments,
attachment->decodedContent().data(),
attachment->size(),
attachment->contentType()->mimeType().data(),
MimeTreeParser::NodeHelper::fileName(attachment).toLatin1().data()
);
}
return m;
#if 0
m.id=""; // UTF-8 string of message ID
m.shortmsg=""; // UTF-8 string of short message
m.longmsg=""; // UTF-8 string of long message (plain)
m.longmsg_formatted=""; // UTF-8 string of long message (formatted)
bloblist_t attachments;
m.attachments=&attachments; // blobs with attachements
m.rawmsg_ref=""; // reference to raw message data
m.rawmsg_size=0; // size of raw message data
timestamp sent;
m.sent=&sent; // when the message is sent
timestamp recv;
m.recv=&recv; // when the message is received
pEp_identity from;
m.from=&from; // whom the message is from
identity_list to;
m.to=&to; // whom the message is to
pEp_identity recv_by;
m.recv_by=&recv_by; // via which identity the message is received
identity_list cc;
m.cc=&cc; // whom a CC is being sent
identity_list bcc;
m.bcc=&bcc; // whom a BCC is being sent
identity_list reply_to;
m.reply_to=&reply_to; // where a reply should go to
stringlist_t in_reply_to;
m.in_reply_to=&in_reply_to; // list of UTF-8 strings with MessageIDs of refering messages
/*
struct _message *refering_msg_ref; // reference to refering message
stringlist_t *references; // list of UTF-8 strings with references
struct _message_ref_list *refered_by; // list of references to messages being
// refered
stringlist_t *keywords; // list of UTF-8 strings with keywords
char *comments; // UTF-8 string with comments
stringpair_list_t *opt_fields; // optional fields
PEP_enc_format enc_format; // format of encrypted data
char* _sender_fpr; // INTERNAL USE ONLY - fingerprint of
// sending signer.
// (read_only to the outside)
*/
#endif
}