Browse Source

Encapsulation works now

master
David Lanzendörfer 1 year ago
parent
commit
806e836df5
16 changed files with 240 additions and 42 deletions
  1. +2
    -2
      Makefile
  2. +80
    -0
      pep-client.h
  3. +18
    -9
      pep-introspect.xml
  4. +32
    -14
      pep-server-glue.h
  5. +7
    -12
      pep-server.cpp
  6. +9
    -5
      pep-server.h
  7. +5
    -0
      types/pEpDBusEncryptionFlags.cpp
  8. +13
    -0
      types/pEpDBusEncryptionFlags.h
  9. +6
    -0
      types/pEpDBusMessage.cpp
  10. +13
    -0
      types/pEpDBusMessage.h
  11. +6
    -0
      types/pEpDBusRating.cpp
  12. +13
    -0
      types/pEpDBusRating.h
  13. +5
    -0
      types/pEpDBusStatus.cpp
  14. +13
    -0
      types/pEpDBusStatus.h
  15. +5
    -0
      types/pEpDBusStringList.cpp
  16. +13
    -0
      types/pEpDBusStringList.h

+ 2
- 2
Makefile View File

@ -1,5 +1,5 @@
all:
#rm -f pepadaptop.h main
/usr/bin/dbusxx-xml2cpp pep-introspect.xml --adaptor=pep-server-glue.h
g++ -I/usr/include -I/usr/include/dbus-c++-1 -I. -ldbus-c++-1 pep-server.cpp -o main
/usr/bin/dbusxx-xml2cpp pep-introspect.xml --adaptor=pep-server-glue.h --proxy=pep-client.h
g++ -DNDEBUG -I/usr/include -I/usr/include/dbus-c++-1 -I. -Itypes -ldbus-c++-1 types/*.cpp pep-server.cpp -o main

+ 80
- 0
pep-client.h View File

@ -0,0 +1,80 @@
/*
* This file was automatically generated by dbusxx-xml2cpp; DO NOT EDIT!
*/
#ifndef __dbusxx__pep_client_h__PROXY_MARSHAL_H
#define __dbusxx__pep_client_h__PROXY_MARSHAL_H
#include <dbus-c++/dbus.h>
#include <cassert>
#include "pEpDBusMessage.h"
#include "pEpDBusStringList.h"
#include "pEpDBusRating.h"
#include "pEpDBusEncryptionFlags.h"
#include "pEpDBusStatus.h"
#include "pEpDBusMessage.h"
namespace security {
class pep_proxy
: public ::DBus::InterfaceProxy
{
public:
pep_proxy()
: ::DBus::InterfaceProxy("security.pep")
{
}
public:
/* properties exported by this interface */
public:
/* methods exported by this interface,
* this functions will invoke the corresponding methods on the remote objects
*/
void decryptMessage(const pEpDBusMessage& src, const pEpDBusStringList& keylist, const pEpDBusRating& rating, const pEpDBusEncryptionFlags& flags, pEpDBusStatus& status, pEpDBusMessage& dst)
{
::DBus::CallMessage call;
::DBus::MessageIter wi = call.writer();
::DBus::Variant _src;
_src << src;
wi << _src;
::DBus::Variant _keylist;
_keylist << keylist;
wi << _keylist;
::DBus::Variant _rating;
_rating << rating;
wi << _rating;
::DBus::Variant _flags;
_flags << flags;
wi << _flags;
call.member("decryptMessage");
::DBus::Message ret = invoke_method (call);
::DBus::MessageIter ri = ret.reader();
::DBus::Variant _status;
ri >> _status;
status << _status;
::DBus::Variant _dst;
ri >> _dst;
dst << _dst;
}
public:
/* signal handlers for this interface
*/
private:
/* unmarshalers (to unpack the DBus message before calling the actual signal handler)
*/
};
}
#endif //__dbusxx__pep_client_h__PROXY_MARSHAL_H

+ 18
- 9
pep-introspect.xml View File

@ -1,16 +1,25 @@
<?xml version="1.0" ?>
<node name="/security/pep/">
<interface name="security.pep">
<method name="decrypt_message">
<arg direction="in" name="status">
<annotation name="org.freedesktop.DBus.Object" value="PEP_STATUS" />
<method name="decryptMessage">
<arg direction="out" name="status" type="v">
<annotation name="org.freedesktop.DBus.Object" value="pEpDBusStatus" />
</arg>
<arg direction="out" name="dst" type="v">
<annotation name="org.freedesktop.DBus.Object" value="pEpDBusMessage" />
</arg>
<arg direction="in" name="src" type="v">
<annotation name="org.freedesktop.DBus.Object" value="pEpDBusMessage" />
</arg>
<arg direction="in" name="keylist" type="v">
<annotation name="org.freedesktop.DBus.Object" value="pEpDBusStringList" />
</arg>
<arg direction="in" name="rating" type="v">
<annotation name="org.freedesktop.DBus.Object" value="pEpDBusRating" />
</arg>
<arg direction="in" name="flags" type="v">
<annotation name="org.freedesktop.DBus.Object" value="pEpDBusEncryptionFlags" />
</arg>
<!--
<arg direction="in" type="b" name="src" />
<arg direction="out" type="b" name="dst" />
<arg direction="out" type="b" name="rating" />
<arg direction="out" type="(b)" name="flags" />
-->
</method>
</interface>
</node>

+ 32
- 14
pep-server-glue.h View File

@ -8,6 +8,12 @@
#include <dbus-c++/dbus.h>
#include <cassert>
#include "pEpDBusMessage.h"
#include "pEpDBusStringList.h"
#include "pEpDBusRating.h"
#include "pEpDBusEncryptionFlags.h"
#include "pEpDBusStatus.h"
#include "pEpDBusMessage.h"
namespace security {
@ -19,22 +25,24 @@ public:
pep_adaptor()
: ::DBus::InterfaceAdaptor("security.pep")
{
register_method(pep_adaptor, decrypt_message, _decrypt_message_stub);
register_method(pep_adaptor, decryptMessage, _decryptMessage_stub);
}
::DBus::IntrospectedInterface *introspect() const
{
static ::DBus::IntrospectedArgument decrypt_message_args[] =
static ::DBus::IntrospectedArgument decryptMessage_args[] =
{
{ "status", "i", false },
{ "message", "s", true },
{ "rating", "i", false },
{ "flags", "i", true },
{ "status", "v", false },
{ "dst", "v", false },
{ "src", "v", true },
{ "keylist", "v", true },
{ "rating", "v", true },
{ "flags", "v", true },
{ 0, 0, 0 }
};
static ::DBus::IntrospectedMethod pep_adaptor_methods[] =
{
{ "decrypt_message", decrypt_message_args },
{ "decryptMessage", decryptMessage_args },
{ 0, 0 }
};
static ::DBus::IntrospectedMethod pep_adaptor_signals[] =
@ -66,7 +74,7 @@ public:
/* methods exported by this interface,
* you will have to implement them in your ObjectAdaptor
*/
virtual void decrypt_message(const std::string& message, const int32_t& flags, int32_t& status, int32_t& rating) = 0;
virtual void decryptMessage(const pEpDBusMessage& src, const pEpDBusStringList& keylist, const pEpDBusRating& rating, const pEpDBusEncryptionFlags& flags, pEpDBusStatus& status, pEpDBusMessage& dst) = 0;
public:
@ -77,17 +85,27 @@ private:
/* unmarshalers (to unpack the DBus message before calling the actual interface method)
*/
::DBus::Message _decrypt_message_stub(const ::DBus::CallMessage &call)
::DBus::Message _decryptMessage_stub(const ::DBus::CallMessage &call)
{
::DBus::MessageIter ri = call.reader();
std::string argin1; ri >> argin1;
int32_t argin2; ri >> argin2;
int32_t argout1;
int32_t argout2;
decrypt_message(argin1, argin2, argout1, argout2);
::DBus::Variant argin1; ri >> argin1;
::DBus::Variant argin2; ri >> argin2;
::DBus::Variant argin3; ri >> argin3;
::DBus::Variant argin4; ri >> argin4;
pEpDBusMessage _argin1; _argin1 << argin1;
pEpDBusStringList _argin2; _argin2 << argin2;
pEpDBusRating _argin3; _argin3 << argin3;
pEpDBusEncryptionFlags _argin4; _argin4 << argin4;
::DBus::Variant argout1;
::DBus::Variant argout2;
pEpDBusStatus _argout1;
pEpDBusMessage _argout2;
decryptMessage(_argin1, _argin2, _argin3, _argin4, _argout1, _argout2);
::DBus::ReturnMessage reply(call);
::DBus::MessageIter wi = reply.writer();
argout1 << _argout1;
argout2 << _argout2;
wi << argout1;
wi << argout2;
return reply;


+ 7
- 12
pep-server.cpp View File

@ -28,22 +28,17 @@ void niam(int sig)
dispatcher.leave();
}
// Mesage API
void pEpServer::decrypt_message(const std::string& message, const int32_t& flags, int32_t& status, int32_t& rating)
/*void pEpServer::decryptMessage(const message& src, const PEP_rating& rating, const PEP_encrypt_flags_t& flags, PEP_STATUS& status, message& dst, stringlist_t& keylist)
{
std::cout << "Trying to decrypt the data" << std::endl;
std::cout << message << std::endl;
status = decrypt_message(
mSession,
message *src,
message **dst,
stringlist_t **keylist,
PEP_rating *rating,
PEP_decrypt_flags_t *flags
);
status = decrypt_message( mSession, (message*)&src, (message**)&dst, (stringlist_t**)&keylist, (PEP_rating*)rating, (PEP_encrypt_flags_t*)&flags );
//dbus_g_method_return( status );
}*/
void pEpServer::decryptMessage(const pEpDBusMessage& src, const pEpDBusStringList& keylist, const pEpDBusRating& rating,
const pEpDBusEncryptionFlags& flags, pEpDBusStatus& status, pEpDBusMessage& dst)
{
}
int main()
{
signal(SIGTERM, niam);


+ 9
- 5
pep-server.h View File

@ -1,11 +1,14 @@
#ifndef __DEMO_ASYNC_SERVER_H
#define __DEMO_ASYNC_SERVER_H
#ifndef PEP_DBUS_SERVER_H
#define PEP_DBUS_SERVER_H
#include <dbus-c++/dbus.h>
#include "pep-server-glue.h"
#include <pEp/message_cache.hh>
#include "pep-server-glue.h"
struct _pEpSession;
class pEpServer
: public security::pep_adaptor,
public DBus::IntrospectableAdaptor,
@ -16,10 +19,11 @@ public:
~pEpServer();
// Message API
void decrypt_message(const std::string& message, const int32_t& flags, int32_t& status, int32_t& rating) ;
void decryptMessage(const pEpDBusMessage& src, const pEpDBusStringList& keylist, const pEpDBusRating& rating,
const pEpDBusEncryptionFlags& flags, pEpDBusStatus& status, pEpDBusMessage& dst);
private:
PEP_SESSION mSession;
struct _pEpSession* mSession;
};


+ 5
- 0
types/pEpDBusEncryptionFlags.cpp View File

@ -0,0 +1,5 @@
#include "pEpDBusEncryptionFlags.h"
pEpDBusEncryptionFlags::pEpDBusEncryptionFlags() {}
DBus::Variant& operator<<(DBus::Variant&, const pEpDBusEncryptionFlags&) {}

+ 13
- 0
types/pEpDBusEncryptionFlags.h View File

@ -0,0 +1,13 @@
#ifndef PEP_DBUS_ENCRYPTION_FLAG_H
#define PEP_DBUS_ENCRYPTION_FLAG_H
#include <dbus-c++/types.h>
class pEpDBusEncryptionFlags : public DBus::Variant
{
public:
pEpDBusEncryptionFlags();
friend DBus::Variant& operator<<(DBus::Variant&, const pEpDBusEncryptionFlags&);
};
#endif

+ 6
- 0
types/pEpDBusMessage.cpp View File

@ -0,0 +1,6 @@
#include "pEpDBusMessage.h"
pEpDBusMessage::pEpDBusMessage() {}
DBus::Variant& operator<<(DBus::Variant&, const pEpDBusMessage&) {}

+ 13
- 0
types/pEpDBusMessage.h View File

@ -0,0 +1,13 @@
#ifndef PEP_DBUS_MESSAGE_H
#define PEP_DBUS_MESSAGE_H
#include <dbus-c++/types.h>
class pEpDBusMessage : public DBus::Variant
{
public:
pEpDBusMessage();
friend DBus::Variant& operator<<(DBus::Variant&, const pEpDBusMessage&);
};
#endif

+ 6
- 0
types/pEpDBusRating.cpp View File

@ -0,0 +1,6 @@
#include "pEpDBusRating.h"
pEpDBusRating::pEpDBusRating() {}
DBus::Variant& operator<<(DBus::Variant&, const pEpDBusRating&) {}

+ 13
- 0
types/pEpDBusRating.h View File

@ -0,0 +1,13 @@
#ifndef PEP_DBUS_RATING_H
#define PEP_DBUS_RATING_H
#include <dbus-c++/types.h>
class pEpDBusRating : public DBus::Variant
{
public:
pEpDBusRating();
friend DBus::Variant& operator<<(DBus::Variant&, const pEpDBusRating&);
};
#endif

+ 5
- 0
types/pEpDBusStatus.cpp View File

@ -0,0 +1,5 @@
#include "pEpDBusStatus.h"
pEpDBusStatus::pEpDBusStatus() {}
DBus::Variant& operator<<(DBus::Variant&, const pEpDBusStatus&) {}

+ 13
- 0
types/pEpDBusStatus.h View File

@ -0,0 +1,13 @@
#ifndef PEP_DBUS_STATUS_H
#define PEP_DBUS_STATUS_H
#include <dbus-c++/types.h>
class pEpDBusStatus : public DBus::Variant
{
public:
pEpDBusStatus();
friend DBus::Variant& operator<<(DBus::Variant&, const pEpDBusStatus&);
};
#endif

+ 5
- 0
types/pEpDBusStringList.cpp View File

@ -0,0 +1,5 @@
#include "pEpDBusStringList.h"
pEpDBusStringList::pEpDBusStringList() {}
DBus::Variant& operator<<(DBus::Variant&, const pEpDBusStringList&) {}

+ 13
- 0
types/pEpDBusStringList.h View File

@ -0,0 +1,13 @@
#ifndef PEP_DBUS_STRING_LIST_H
#define PEP_DBUS_STRING_LIST_H
#include <dbus-c++/types.h>
class pEpDBusStringList : public DBus::Variant
{
public:
pEpDBusStringList();
friend DBus::Variant& operator<<(DBus::Variant&, const pEpDBusStringList&);
};
#endif

Loading…
Cancel
Save