Browse Source

Implementing missing writer functions

Right now it segfaults, because some core elements aren't
implemented yet.
master
David Lanzendörfer 7 months ago
parent
commit
5323cc4981
14 changed files with 91 additions and 32 deletions
  1. +12
    -6
      CMakeLists.txt
  2. +1
    -1
      pep-client.cpp
  3. +6
    -5
      pep-client.h
  4. +8
    -3
      pep-introspect.xml
  5. +18
    -5
      pep-server.cpp
  6. +5
    -5
      pep-server.h
  7. +14
    -2
      tests.cpp
  8. +1
    -0
      types/pEpDBusEncryptionFlags.h
  9. +14
    -1
      types/pEpDBusMessage.cpp
  10. +7
    -2
      types/pEpDBusMessage.h
  11. +1
    -0
      types/pEpDBusRating.h
  12. +1
    -1
      types/pEpDBusStatus.cpp
  13. +2
    -1
      types/pEpDBusStatus.h
  14. +1
    -0
      types/pEpDBusStringList.h

+ 12
- 6
CMakeLists.txt View File

@ -4,23 +4,29 @@ include_directories(${PROJECT_SOURCE_DIR}/types)
add_subdirectory(types)
############################ Server glue ###########################
add_custom_command(
OUTPUT pep-server-glue.h
COMMAND /usr/bin/dbusxx-xml2cpp ${CMAKE_CURRENT_SOURCE_DIR}/pep-introspect.xml --adaptor=pep-server-glue.h
OUTPUT ${PROJECT_BINARY_DIR}/pep-server-glue.h
COMMAND /usr/bin/dbusxx-xml2cpp ${CMAKE_CURRENT_SOURCE_DIR}/pep-introspect.xml --adaptor=${PROJECT_BINARY_DIR}/pep-server-glue.h
DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/pep-introspect.xml
PRE_BUILD
VERBATIM
)
set_source_files_properties(${PROJECT_BINARY_DIR}/pep-server-glue.h PROPERTIES GENERATED TRUE)
#######################
############################ Client glue ###########################
add_custom_command(
OUTPUT pep-client-glue.h
COMMAND /usr/bin/dbusxx-xml2cpp ${CMAKE_CURRENT_SOURCE_DIR}/pep-introspect.xml --proxy=pep-client-glue.h
OUTPUT ${PROJECT_BINARY_DIR}/pep-client-glue.h
COMMAND /usr/bin/dbusxx-xml2cpp ${CMAKE_CURRENT_SOURCE_DIR}/pep-introspect.xml --proxy=${PROJECT_BINARY_DIR}/pep-client-glue.h
DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/pep-introspect.xml
PRE_BUILD
VERBATIM
)
set_source_files_properties(${PROJECT_BINARY_DIR}/pep-client-glue.h PROPERTIES GENERATED TRUE)
#######################
add_library(pEpDBusAdapterClient SHARED pep-client.cpp)
add_library(pEpDBusAdapterClient SHARED pep-client.cpp ${PROJECT_BINARY_DIR}/pep-client-glue.h)
target_link_libraries(pEpDBusAdapterClient
pEpDBusAdapterTypes
)
@ -29,7 +35,7 @@ set_target_properties(pEpDBusAdapterClient PROPERTIES
VISIBILITY_INLINES_HIDDEN 0
)
add_library(pEpDBusAdapterServer SHARED pep-server.cpp)
add_library(pEpDBusAdapterServer SHARED pep-server.cpp ${PROJECT_BINARY_DIR}/pep-server-glue.h)
target_link_libraries(pEpDBusAdapterServer
pEpDBusAdapterTypes
)


+ 1
- 1
pep-client.cpp View File

@ -1,6 +1,6 @@
#include <pep-client.h>
pEpClient::pEpClient(DBus::Connection &connection, const char *path, const char *name) : DBus::ObjectProxy(connection, path, name)
pEp::Client::Client(DBus::Connection &connection, const char *path, const char *name) : DBus::ObjectProxy(connection, path, name)
{
}

+ 6
- 5
pep-client.h View File

@ -3,16 +3,17 @@
#include <pep-client-glue.h>
class pEpClient :
namespace pEp {
class Client :
public security::pep_proxy,
public DBus::IntrospectableProxy,
public DBus::ObjectProxy
{
public:
pEpClient(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);
Client(DBus::Connection &connection, const char *path, const char *name);
/*void decrypt_message(const pEpDBusMessage& src, const pEpDBusStringList& keylist, const pEpDBusRating& rating,
const pEpDBusEncryptionFlags& flags, pEpDBusStatus& status, pEpDBusMessage& dst);*/
};
}
#endif

+ 8
- 3
pep-introspect.xml View File

@ -1,7 +1,12 @@
<?xml version="1.0" ?>
<node name="/security/pep/">
<interface name="security.pep">
<method name="decryptMessage">
<method name="send_test">
<arg direction="in" name="src" type="v">
<annotation name="org.freedesktop.DBus.Object" value="pEpDBusMessage" />
</arg>
</method>
<method name="decrypt_message">
<arg direction="out" name="status" type="v">
<annotation name="org.freedesktop.DBus.Object" value="pEpDBusStatus" />
</arg>
@ -20,6 +25,6 @@
<arg direction="in" name="flags" type="v">
<annotation name="org.freedesktop.DBus.Object" value="pEpDBusEncryptionFlags" />
</arg>
</method>
</interface>
</method>
</interface>
</node>

+ 18
- 5
pep-server.cpp View File

@ -2,13 +2,15 @@
#include <config.h>
#endif
#include "pep-server.h"
#include <unistd.h>
#include <stdlib.h>
#include <stdio.h>
#include <limits.h>
#include <pEp/message_cache.hh>
#include "pep-server.h"
static const char *ASYNC_SERVER_PATH = "/security/pep";
pEp::Server::Server(DBus::Connection &connection)
@ -16,12 +18,23 @@ pEp::Server::Server(DBus::Connection &connection)
{
}
pEp::Server::~Server() {};
pEp::Server::~Server()
{
}
void pEp::Server::decryptMessage(const pEpDBusMessage& src, const pEpDBusStringList& keylist, const pEpDBusRating& rating,
void pEp::Server::send_test(const pEpDBusMessage& src)
{
}
void pEp::Server::decrypt_message(const pEpDBusMessage& src, const pEpDBusStringList& keylist, const pEpDBusRating& rating,
const pEpDBusEncryptionFlags& flags, pEpDBusStatus& status, pEpDBusMessage& dst)
{
std::cout << "Trying to decrypt the data" << std::endl;
//status = decrypt_message( mSession, (message*)&src, (message**)&dst, (stringlist_t**)&keylist, (PEP_rating*)rating, (PEP_encrypt_flags_t*)&flags );
//status PEP_STATUS_OK;
status = PEP_STATUS_OK;
// message m = src;
// src = m;
//status = ::decrypt_message( mSession, src, dst, keylist, rating, flags ));
}

+ 5
- 5
pep-server.h View File

@ -3,8 +3,6 @@
#include <dbus-c++/dbus.h>
#include <pEp/message_cache.hh>
#include "pep-server-glue.h"
struct _pEpSession;
@ -16,12 +14,14 @@ class Server
public DBus::ObjectAdaptor
{
public:
Server(DBus::Connection &connection);
explicit Server(DBus::Connection &connection);
~Server();
// Message API
void decryptMessage(const pEpDBusMessage& src, const pEpDBusStringList& keylist, const pEpDBusRating& rating,
const pEpDBusEncryptionFlags& flags, pEpDBusStatus& status, pEpDBusMessage& dst);
void send_test(const pEpDBusMessage& src);
void decrypt_message(const pEpDBusMessage& src, const pEpDBusStringList& keylist, const pEpDBusRating& rating,
const pEpDBusEncryptionFlags& flags, pEpDBusStatus& status, pEpDBusMessage& dst);
private:
struct _pEpSession* mSession;


+ 14
- 2
tests.cpp View File

@ -6,8 +6,20 @@ int main()
{
DBus::default_dispatcher = &dispatcher;
DBus::Connection conn = DBus::Connection::SessionBus();
pEpClient server(conn, "/pep/security", "pep.security");
pEp::Client client(conn, "/pep/security", "pep.security");
message m;
pEpDBusMessage dm1(m);
pEp_identity from;
from.address="leviathan@libresilicon.com";
m.from=&from;
pEpDBusMessage src, dst;
pEpDBusStringList keylist;
pEpDBusRating rating;
pEpDBusEncryptionFlags flags;
pEpDBusStatus status;
src << m;
//client.decrypt_message(src,keylist,rating,flags,status,dst);
client.send_test(src);
dst >> m;
}

+ 1
- 0
types/pEpDBusEncryptionFlags.h View File

@ -7,6 +7,7 @@ class pEpDBusEncryptionFlags : public DBus::Variant
{
public:
pEpDBusEncryptionFlags();
std::string signature() { return "s"; }
friend DBus::Variant& operator<<(DBus::Variant&, const pEpDBusEncryptionFlags&);
};


+ 14
- 1
types/pEpDBusMessage.cpp View File

@ -5,7 +5,7 @@ pEpDBusMessage::pEpDBusMessage()
{
}
pEpDBusMessage::pEpDBusMessage(message &m)
pEpDBusMessage::pEpDBusMessage(message m)
{
}
@ -14,3 +14,16 @@ DBus::Variant& operator<<(DBus::Variant&, const pEpDBusMessage&)
DBus::Variant ret;
return ret;
}
message& pEpDBusMessage::operator >> (message&)
{
message m;
return m;
}
message& pEpDBusMessage::operator << (message&)
{
message m;
return m;
}

+ 7
- 2
types/pEpDBusMessage.h View File

@ -9,9 +9,14 @@ class pEpDBusMessage : public DBus::Variant
{
public:
explicit pEpDBusMessage();
explicit pEpDBusMessage(message&);
explicit pEpDBusMessage(message);
friend DBus::Variant& operator<<(DBus::Variant&, const pEpDBusMessage&);
message& operator >> (message&);
message& operator << (message&);
std::string signature() { return "s"; }
friend DBus::Variant& operator << (DBus::Variant&, const pEpDBusMessage&);
};
#endif

+ 1
- 0
types/pEpDBusRating.h View File

@ -7,6 +7,7 @@ class pEpDBusRating : public DBus::Variant
{
public:
pEpDBusRating();
std::string signature() { return "s"; }
friend DBus::Variant& operator<<(DBus::Variant&, const pEpDBusRating&);
};


+ 1
- 1
types/pEpDBusStatus.cpp View File

@ -4,7 +4,7 @@ pEpDBusStatus::pEpDBusStatus()
{
}
pEpDBusStatus::pEpDBusStatus(PEP_STATUS&)
pEpDBusStatus::pEpDBusStatus(PEP_STATUS)
{
}


+ 2
- 1
types/pEpDBusStatus.h View File

@ -9,8 +9,9 @@ class pEpDBusStatus : public DBus::Variant
{
public:
pEpDBusStatus();
pEpDBusStatus(PEP_STATUS&);
pEpDBusStatus(PEP_STATUS);
std::string signature() { return "s"; }
friend DBus::Variant& operator<<(DBus::Variant&, const pEpDBusStatus&);
};


+ 1
- 0
types/pEpDBusStringList.h View File

@ -7,6 +7,7 @@ class pEpDBusStringList : public DBus::Variant
{
public:
pEpDBusStringList();
std::string signature() { return "s"; }
friend DBus::Variant& operator<<(DBus::Variant&, const pEpDBusStringList&);
};


Loading…
Cancel
Save