Browse Source

Managed to compile the interface

master
David Lanzendörfer 1 year ago
parent
commit
cf44d65f0e
7 changed files with 40 additions and 154 deletions
  1. +2
    -1
      messageviewerplugin/CMakeLists.txt
  2. +0
    -95
      messageviewerplugin/pepjob.cpp
  3. +0
    -41
      messageviewerplugin/pepjob.h
  4. +6
    -0
      messageviewerplugin/qpepclient.cpp
  5. +22
    -0
      messageviewerplugin/qpepclient.h
  6. +6
    -16
      messageviewerplugin/viewerpluginpepinterface.cpp
  7. +4
    -1
      messageviewerplugin/viewerpluginpepinterface.h

+ 2
- 1
messageviewerplugin/CMakeLists.txt View File

@ -1,7 +1,7 @@
set(messageviewer_pepplugin_SRCS
viewerpluginpep.cpp
viewerpluginpepinterface.cpp
pepjob.cpp
qpepclient.cpp
)
ecm_qt_declare_logging_category(messageviewer_pepplugin_SRCS HEADER pepplugin_debug.h IDENTIFIER CREATENOTEPLUGIN_LOG CATEGORY_NAME org.kde.pim.pepplugin
@ -22,5 +22,6 @@ target_link_libraries(messageviewer_pepplugin
KF5::IncidenceEditor
KF5::AkonadiWidgets
KF5::KontactInterface
dbus-c++-1
)

+ 0
- 95
messageviewerplugin/pepjob.cpp View File

@ -1,95 +0,0 @@
/*
SPDX-FileCopyrightText: 2014 Sandro Knauß <knauss@kolabsys.com>
SPDX-License-Identifier: GPL-2.0-only
*/
#include "pepjob.h"
#include "pepplugin_debug.h"
#include <Akonadi/KMime/MessageParts>
#include <AkonadiCore/RelationCreateJob>
#include <AkonadiCore/ItemCreateJob>
#include <AkonadiCore/ItemModifyJob>
#include <AkonadiCore/Relation>
#include <KMime/Message>
#include <QCoreApplication>
using namespace MessageViewer;
CreateNoteJob::CreateNoteJob(const KMime::Message::Ptr &notePtr, const Akonadi::Collection &collection, const Akonadi::Item &item, QObject *parent)
: KJob(parent)
, mItem(item)
, mCollection(collection)
, mNote(notePtr)
{
}
CreateNoteJob::~CreateNoteJob()
{
}
void CreateNoteJob::start()
{
mNote.setFrom(QCoreApplication::applicationName() + QLatin1Char(' ') + QCoreApplication::applicationVersion());
mNote.setLastModifiedDate(QDateTime::currentDateTimeUtc());
if (!mItem.relations().isEmpty()) {
Akonadi::Relation relation;
const auto relations = mItem.relations();
for (const Akonadi::Relation &r : relations) {
// assuming that GENERIC relations to emails are notes is a pretty horrific hack imo - aseigo
if (r.type() == Akonadi::Relation::GENERIC && r.right().mimeType() == Akonadi::NoteUtils::noteMimeType()) {
relation = r;
break;
}
}
if (relation.isValid()) {
Akonadi::Item item = relation.right();
item.setMimeType(Akonadi::NoteUtils::noteMimeType());
item.setPayload(mNote.message());
auto *modifyJob = new Akonadi::ItemModifyJob(item);
connect(modifyJob, &Akonadi::ItemModifyJob::result, this, &CreateNoteJob::noteUpdated);
return;
}
}
Akonadi::Item newNoteItem;
newNoteItem.setMimeType(Akonadi::NoteUtils::noteMimeType());
newNoteItem.setPayload(mNote.message());
auto *createJob = new Akonadi::ItemCreateJob(newNoteItem, mCollection);
connect(createJob, &Akonadi::ItemCreateJob::result, this, &CreateNoteJob::noteCreated);
}
void CreateNoteJob::noteCreated(KJob *job)
{
if (job->error()) {
qCWarning(CREATENOTEPLUGIN_LOG) << "Error during create new Note " << job->errorString();
setError(job->error());
setErrorText(job->errorText());
emitResult();
} else {
auto *createJob = static_cast<Akonadi::ItemCreateJob *>(job);
Akonadi::Relation relation(Akonadi::Relation::GENERIC, mItem, createJob->item());
auto *rJob = new Akonadi::RelationCreateJob(relation);
connect(rJob, &Akonadi::RelationCreateJob::result, this, &CreateNoteJob::relationCreated);
}
}
void CreateNoteJob::noteUpdated(KJob *job)
{
if (job->error()) {
setError(job->error());
setErrorText(job->errorText());
}
emitResult();
}
void CreateNoteJob::relationCreated(KJob *job)
{
if (job->error()) {
qCDebug(CREATENOTEPLUGIN_LOG) << "Error during create new Note " << job->errorString();
}
emitResult();
}

+ 0
- 41
messageviewerplugin/pepjob.h View File

@ -1,41 +0,0 @@
/*
SPDX-FileCopyrightText: 2014 Sandro Knauß <knauss@kolabsys.com>
SPDX-License-Identifier: GPL-2.0-only
*/
#ifndef CREATENOTEJOB_H
#define CREATENOTEJOB_H
#include <KJob>
#include <AkonadiCore/Item>
#include <AkonadiCore/Collection>
#include <Akonadi/Notes/NoteUtils>
#include <kmime/kmime_message.h>
#include <QObject>
namespace MessageViewer {
class CreateNoteJob : public KJob
{
Q_OBJECT
public:
explicit CreateNoteJob(const KMime::Message::Ptr &notePtr, const Akonadi::Collection &collection, const Akonadi::Item &item, QObject *parent = nullptr);
~CreateNoteJob() override;
void start() override;
private Q_SLOTS:
void noteCreated(KJob *job);
void noteUpdated(KJob *job);
void relationCreated(KJob *job);
private:
const Akonadi::Item mItem;
const Akonadi::Collection mCollection;
Akonadi::NoteUtils::NoteMessageWrapper mNote;
};
}
#endif

+ 6
- 0
messageviewerplugin/qpepclient.cpp View File

@ -0,0 +1,6 @@
#include "qpepclient.h"
QpEpClient::QpEpClient(DBus::Connection &connection, const char *path, const char *name) : DBus::ObjectProxy(connection, path, name)
{
}

+ 22
- 0
messageviewerplugin/qpepclient.h View File

@ -0,0 +1,22 @@
#ifndef Q_PEP_DBUS_CLIENT_H
#define Q_PEP_DBUS_CLIENT_H
#include <QObject>
#include "/home/leviathan/PEP/pEpDBusAdapter/pep-client.h"
class QpEpClient :
public QObject,
public security::pep_proxy,
public DBus::IntrospectableProxy,
public DBus::ObjectProxy
{
Q_OBJECT
public:
QpEpClient(DBus::Connection &connection, const char *path, const char *name);
void decryptMessage(const pEpDBusMessage& src, const pEpDBusStringList& keylist, const pEpDBusRating& rating,
const pEpDBusEncryptionFlags& flags, pEpDBusStatus& status, pEpDBusMessage& dst);
};
#endif

+ 6
- 16
messageviewerplugin/viewerpluginpepinterface.cpp View File

@ -5,8 +5,8 @@
*/
#include "viewerpluginpepinterface.h"
#include "pepjob.h"
#include "pepplugin_debug.h"
#include <KLocalizedString>
#include <KActionCollection>
@ -37,20 +37,12 @@ using namespace MessageViewer;
pEpViewerInterface::pEpViewerInterface(KActionCollection *ac, QWidget *parent)
: ViewerPluginInterface(parent)
{
QDBusInterface *pEpAgent = nullptr;
mStatusWidget = new QWidget(parent);
mStatusWidget->setFixedHeight(20);
parent->layout()->addWidget(mStatusWidget);
const QString service = Akonadi::ServerManager::self()->agentServiceName(Akonadi::ServerManager::Agent, QStringLiteral("pEpAgent"));
qDebug() << service;
m_pEpAgent = new QDBusInterface(
service,
QStringLiteral("/pEpAgent"),
QStringLiteral("org.freedesktop.Akonadi.Agent.pEpAgent"),
QDBusConnection::sessionBus()
);
DBus::Connection conn = DBus::Connection::SessionBus();
m_pEpDBusAdapter = new QpEpClient(conn, "pep.security", "/pep/security");
}
@ -90,10 +82,8 @@ void pEpViewerInterface::decryptMessage()
{
QByteArray type;
QByteArray pgpText;
if(!m_pEpAgent->isValid()) {
// We're not connected to the agent
qDebug() << "DBus not connected";
return;
if(!m_pEpDBusAdapter) {
}
foreach ( KMime::Content *attachment, mMessage->contents() ) {
type = attachment->contentType()->mimeType();
@ -110,7 +100,7 @@ void pEpViewerInterface::decryptMessage()
}
}
//mMessage->contentType()->setMimeType(QByteArray("text/plain"));
qDebug() << m_pEpAgent->call(QStringLiteral("decryptMessage"), pgpText);
//m_pEpDBusAdapter->decrypt_message();
}
void pEpViewerInterface::setMessage(const KMime::Message::Ptr &value)


+ 4
- 1
messageviewerplugin/viewerpluginpepinterface.h View File

@ -8,6 +8,9 @@
#define VIEWERPLUGINCREATENOTEINTERFACE_H
#include <MessageViewer/ViewerPluginInterface>
#include "qpepclient.h"
class KActionCollection;
class QLabel;
class QDBusInterface;
@ -31,7 +34,7 @@ public:
//Q_REQUIRED_RESULT MessageViewer::ViewerPluginInterface *createView(QWidget *parent, KActionCollection *ac);
private:
QDBusInterface *m_pEpAgent = nullptr;
QpEpClient *m_pEpDBusAdapter = nullptr;
bool isApEpMessage(KMime::Content *c);
void decryptMessage();


Loading…
Cancel
Save