Browse Source

Having dedicate folder for shared stuff

master
David Lanzendörfer 1 month ago
parent
commit
1510592053
4 changed files with 171 additions and 0 deletions
  1. +11
    -0
      kde_pep_common/pep_wizard.cpp
  2. +13
    -0
      kde_pep_common/pep_wizard.h
  3. +129
    -0
      kde_pep_common/pephelpers.cpp
  4. +18
    -0
      kde_pep_common/pephelpers.h

+ 11
- 0
kde_pep_common/pep_wizard.cpp View File

@ -0,0 +1,11 @@
#include "pep_wizard.h"
#include <QIcon>
pEpWizard::pEpWizard(QWidget *parent)
: KAssistantDialog(parent)
{
QIcon::setThemeName(QStringLiteral("hicolor"));
setWindowTitle(QStringLiteral("p≡p Wizard"));
setWindowIcon(QIcon::fromTheme(QStringLiteral("akonadi-pep")));
}

+ 13
- 0
kde_pep_common/pep_wizard.h View File

@ -0,0 +1,13 @@
#pragma once
#include <KAssistantDialog>
class pEpWizard : public KAssistantDialog
{
Q_OBJECT
public:
pEpWizard(QWidget *parent);
};

+ 129
- 0
kde_pep_common/pephelpers.cpp View File

@ -0,0 +1,129 @@
#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
}

+ 18
- 0
kde_pep_common/pephelpers.h View File

@ -0,0 +1,18 @@
#pragma once
#include <MimeTreeParser/NodeHelper>
#include <KMime/Headers>
#include <KMime/Types>
#include <KMime/HeaderParsing>
#include <QStringLiteral>
#include <QByteArray>
#include <QRegularExpression>
#include <pEp/message.h>
namespace pEpKDE {
message* to_pEpMessage(KMime::Message::Ptr mMessage, PEP_msg_direction direction);
KMime::Message::Ptr to_mMessage(message *m);
void mboxlist_to_message(KMime::Types::Mailbox::List mboxlist, identity_list *peplist);
}

Loading…
Cancel
Save