Browse Source

Introduced helper functions

Additionally achieved finally a clean inheritance from DBus::Variants
through separating the Qt from the client class.
master
David Lanzendörfer 1 year ago
parent
commit
89461bdb3d
8 changed files with 83 additions and 63 deletions
  1. +5
    -2
      CMakeLists.txt
  2. +2
    -1
      messageviewerplugin/CMakeLists.txt
  3. +37
    -0
      messageviewerplugin/pephelpers.cpp
  4. +0
    -6
      messageviewerplugin/qpepclient.cpp
  5. +0
    -22
      messageviewerplugin/qpepclient.h
  6. +28
    -27
      messageviewerplugin/viewerpluginpepinterface.cpp
  7. +10
    -4
      messageviewerplugin/viewerpluginpepinterface.h
  8. +1
    -1
      pEpDBusAdapter

+ 5
- 2
CMakeLists.txt View File

@ -15,7 +15,7 @@ set(CMAKE_CXX_STANDARD_REQUIRED ON)
set(CMAKE_CXX_EXTENSIONS OFF)
set(CMAKE_VERBOSE_MAKEFILE ON)
set(CMAKE_VISIBILITY_INLINES_HIDDEN OFF)
set(CMAKE_CXX_FLAGS_RELEASE "-fexceptions")
set(CMAKE_CXX_FLAGS_RELEASE "-g -fexceptions")
set(CMAKE_CXX_FLAGS_DEBUG "-g -fexceptions")
set(PIM_VERSION "5.16.2")
@ -64,7 +64,7 @@ include(FindPkgConfig)
pkg_check_modules( dbus-c++-1 REQUIRED dbus-c++-1 )
include_directories(${dbus-c++-1_INCLUDE_DIRS})
include_directories("/home/leviathan/PEP/pEpDBusAdapter/types")
include_directories(${PROJECT_SOURCE_DIR})
find_package(KF5IncidenceEditor ${INCIDENCEEDITOR_LIB_VERSION} CONFIG REQUIRED)
find_package(Qt5 ${QT_REQUIRED_VERSION} CONFIG REQUIRED Gui Test)
@ -120,6 +120,9 @@ find_package(Grantlee5 ${GRANTLEE_MIN_VERSION} CONFIG REQUIRED)
add_subdirectory(icons)
add_subdirectory(pEpDBusAdapter)
include_directories(${PROJECT_BINARY_DIR}/pEpDBusAdapter)
include_directories(${PROJECT_SOURCE_DIR}/pEpDBusAdapter)
include_directories(${PROJECT_SOURCE_DIR}/pEpDBusAdapter/types)
add_subdirectory(akonadi_pep_agent)
add_subdirectory(messageviewerplugin)

+ 2
- 1
messageviewerplugin/CMakeLists.txt View File

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

+ 37
- 0
messageviewerplugin/pephelpers.cpp View File

@ -0,0 +1,37 @@
#include "viewerpluginpepinterface.h"
#include <pEp/message.h>
using namespace MessageViewer;
void pEpViewerInterface::convert_pEpMessage_to_mMessage(message m)
{
}
message pEpViewerInterface::convert_mMessage_to_pEpMessage()
{
message m;
pEp_identity from;
from.address=mMessage->from()->asUnicodeString().toLatin1().data();
m.from=&from;
return m;
/* QByteArray type;
QByteArray pgpText;
foreach ( KMime::Content *attachment, mMessage->contents() ) {
type = attachment->contentType()->mimeType();
if(type==QByteArray("application/octet-stream")) {
//attachment->setContent(QByteArray("pEp"));
//attachment->contentType()->setMimeType(QByteArray("text/plain"));
//mMessage->contents().removeOne(attachment);
pgpText=attachment->decodedContent();
} else if(type==QByteArray("application/pgp-encrypted")) {
//attachment->setContent(QByteArray("pEp"));
//attachment->contentType()->setMimeType(QByteArray("text/plain"));
} else {
qDebug() << type;
}
}*/
}

+ 0
- 6
messageviewerplugin/qpepclient.cpp View File

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

+ 0
- 22
messageviewerplugin/qpepclient.h View File

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

+ 28
- 27
messageviewerplugin/viewerpluginpepinterface.cpp View File

@ -32,6 +32,26 @@
#include <AkonadiCore/ServerManager>
// The pEp engine
#include <pEp/message.h>
// The pEp D-Bus binding
#include <pEpDBusAdapter/types/pEpDBusMessage.h>
#include <pEpDBusAdapter/types/pEpDBusStringList.h>
#include <pEpDBusAdapter/types/pEpDBusRating.h>
#include <pEpDBusAdapter/types/pEpDBusEncryptionFlags.h>
#include <pEpDBusAdapter/types/pEpDBusStatus.h>
#include <pEpDBusAdapter/pep-client.h>
DBus::BusDispatcher dispatcher;
pEp::Client *start_pEpClient()
{
DBus::default_dispatcher = &dispatcher;
DBus::Connection conn = DBus::Connection::SessionBus();
return new pEp::Client(conn, "/pep/security", "pep.security");
}
using namespace MessageViewer;
pEpViewerInterface::pEpViewerInterface(KActionCollection *ac, QWidget *parent)
@ -40,12 +60,9 @@ pEpViewerInterface::pEpViewerInterface(KActionCollection *ac, QWidget *parent)
mStatusWidget = new QWidget(parent);
mStatusWidget->setFixedHeight(20);
parent->layout()->addWidget(mStatusWidget);
DBus::Connection conn = DBus::Connection::SessionBus();
m_pEpDBusAdapter = new QpEpClient(conn, "pep.security", "/pep/security");
m_pEpDBusAdapter = ::start_pEpClient();
}
pEpViewerInterface::~pEpViewerInterface()
{
qDebug() << __FUNCTION__;
@ -80,33 +97,17 @@ bool pEpViewerInterface::isApEpMessage(KMime::Content *content)
void pEpViewerInterface::decryptMessage()
{
QByteArray type;
QByteArray pgpText;
if(!m_pEpDBusAdapter) {
}
foreach ( KMime::Content *attachment, mMessage->contents() ) {
type = attachment->contentType()->mimeType();
if(type==QByteArray("application/octet-stream")) {
//attachment->setContent(QByteArray("pEp"));
//attachment->contentType()->setMimeType(QByteArray("text/plain"));
//mMessage->contents().removeOne(attachment);
pgpText=attachment->decodedContent();
} else if(type==QByteArray("application/pgp-encrypted")) {
//attachment->setContent(QByteArray("pEp"));
//attachment->contentType()->setMimeType(QByteArray("text/plain"));
} else {
qDebug() << type;
}
}
//mMessage->contentType()->setMimeType(QByteArray("text/plain"));
pEpDBusMessage src;
message m = convert_mMessage_to_pEpMessage();
pEpDBusMessage src, dst;
pEpDBusStringList keylist;
pEpDBusRating rating;
pEpDBusEncryptionFlags flags;
pEpDBusStatus status;
pEpDBusMessage dst;
m_pEpDBusAdapter->decrypt_message(src,keylist,rating,flags,status,dst);
src << m;
//m_pEpDBusAdapter->decrypt_message(src,keylist,rating,flags,status,dst);
dst >> m;
convert_pEpMessage_to_mMessage(m);
//mMessage->contentType()->setMimeType(QByteArray("text/plain"));
}
void pEpViewerInterface::setMessage(const KMime::Message::Ptr &value)


+ 10
- 4
messageviewerplugin/viewerpluginpepinterface.h View File

@ -9,12 +9,15 @@
#include <MessageViewer/ViewerPluginInterface>
#include "qpepclient.h"
#include <pEp/message.h>
class KActionCollection;
class QLabel;
class QDBusInterface;
class QByteArray;
namespace pEp {
class Client;
}
namespace MessageViewer {
class pEpViewerInterface : public ViewerPluginInterface
@ -34,11 +37,14 @@ public:
//Q_REQUIRED_RESULT MessageViewer::ViewerPluginInterface *createView(QWidget *parent, KActionCollection *ac);
private:
QpEpClient *m_pEpDBusAdapter = nullptr;
bool isApEpMessage(KMime::Content *c);
// glue between Akonadi and pEp:
message convert_mMessage_to_pEpMessage();
void convert_pEpMessage_to_mMessage(message m);
void decryptMessage();
bool isApEpMessage(KMime::Content *c);
pEp::Client *m_pEpDBusAdapter = nullptr;
KMime::Message::Ptr mMessage;
Akonadi::Item mMessageItem;
QList<QAction *> mAction;


+ 1
- 1
pEpDBusAdapter

@ -1 +1 @@
Subproject commit 734d41fa32aefccca801431b2e0d77575e73d4b1
Subproject commit 5323cc498117e5c6b2e0d9d7aa513f7f3ef5103a

Loading…
Cancel
Save