Browse Source

Backup of the first work

Communication between KMail and this pEpAdapter service now works.
Next we've gotta implement the functions.
master
David Lanzendörfer 7 months ago
parent
commit
07ad6ac93b
6 changed files with 89 additions and 15 deletions
  1. +1
    -1
      Makefile
  2. +12
    -2
      pep-introspect.xml
  3. +29
    -0
      pep-introspect.xml.old
  4. +19
    -6
      pep-server-glue.h
  5. +17
    -4
      pep-server.cpp
  6. +11
    -2
      pep-server.h

+ 1
- 1
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/dbus-c++-1 -I. -ldbus-c++-1 pep-server.cpp -o main
g++ -I/usr/include -I/usr/include/dbus-c++-1 -I. -ldbus-c++-1 pep-server.cpp -o main

+ 12
- 2
pep-introspect.xml View File

@ -1,6 +1,16 @@
<?xml version="1.0" ?>
<node name="/security/pep/">
<interface name="security.pep">
<method name="hello" />
</interface>
<method name="decrypt_message">
<annotation name="org.qtproject.QtDBus.QtTypeName.Out0" value="PEP_STATUS"/>
<annotation name="org.qtproject.QtDBus.QtTypeName.In0" value="message*"/>
<annotation name="org.qtproject.QtDBus.QtTypeName.Out1" value="message**"/>
<!--<PEP_STATUS, In_Pep_Session, InOut<message*>, Out<message*>, InOutP<stringlist_t*>, Out<PEP_rating>, InOutP<PEP_decrypt_flags_t>>-->
<arg direction="out" type="(iiii)" name="status" />
<arg direction="in" type="(iiii)" name="src" />
<arg direction="out" type="(iiii)" name="dst" />
<arg direction="out" type="i" name="rating" />
<arg direction="in" type="i" name="flags" />
</method>
</interface>
</node>

+ 29
- 0
pep-introspect.xml.old View File

@ -0,0 +1,29 @@
<?xml version="1.0" ?>
<node name="/security/pep/">
<interface name="security.pep">
<method name="encrypt_message">
<!--<PEP_STATUS, In_Pep_Session, InOut<message*>, In<stringlist_t*>, Out<message*>, In<PEP_enc_format>, In<PEP_encrypt_flags_t>>-->
</method>
<method name="cache_encrypt_message">
<!--<PEP_STATUS, In_Pep_Session, InOut<message*>, In<stringlist_t*>, Out<message*>, In<PEP_enc_format>, In<PEP_encrypt_flags_t>>-->
</method>
<method name="encrypt_message_and_add_priv_key">
<!--<PEP_STATUS, In_Pep_Session, In<message*>, Out<message*>, In<c_string>, In<PEP_enc_format>, In<PEP_encrypt_flags_t>>-->
</method>
<method name="encrypt_message_for_self">
<!--<PEP_STATUS, In_Pep_Session, In<pEp_identity*>, In<message*>, In<stringlist_t*>, Out<message*>, In<PEP_enc_format>, In<PEP_encrypt_flags_t>>-->
</method>
<method name="cache_encrypt_message_for_self">
<!--<PEP_STATUS, In_Pep_Session, In<pEp_identity*>, In<message*>, In<stringlist_t*>, Out<message*>, In<PEP_enc_format>, In<PEP_encrypt_flags_t>>-->
</method>
<method name="decrypt_message">
<!--<PEP_STATUS, In_Pep_Session, InOut<message*>, Out<message*>, InOutP<stringlist_t*>, Out<PEP_rating>, InOutP<PEP_decrypt_flags_t>>-->
</method>
<method name="cache_decrypt_message">
<!--<PEP_STATUS, In_Pep_Session, InOut<message*>, Out<message*>, InOutP<stringlist_t*>, Out<PEP_rating>, InOutP<PEP_decrypt_flags_t>>-->
</method>
<method name="get_key_rating_for_user">
<!--<PEP_STATUS, In_Pep_Session, In<c_string>, In<c_string>, Out<PEP_rating>>-->
</method>
</interface>
</node>

+ 19
- 6
pep-server-glue.h View File

@ -19,18 +19,22 @@ public:
pep_adaptor()
: ::DBus::InterfaceAdaptor("security.pep")
{
register_method(pep_adaptor, Hello, _Hello_stub);
register_method(pep_adaptor, decrypt_message, _decrypt_message_stub);
}
::DBus::IntrospectedInterface *introspect() const
{
static ::DBus::IntrospectedArgument Hello_args[] =
static ::DBus::IntrospectedArgument decrypt_message_args[] =
{
{ "status", "i", false },
{ "message", "s", true },
{ "rating", "i", false },
{ "flags", "i", true },
{ 0, 0, 0 }
};
static ::DBus::IntrospectedMethod pep_adaptor_methods[] =
{
{ "Hello", Hello_args },
{ "decrypt_message", decrypt_message_args },
{ 0, 0 }
};
static ::DBus::IntrospectedMethod pep_adaptor_signals[] =
@ -62,7 +66,7 @@ public:
/* methods exported by this interface,
* you will have to implement them in your ObjectAdaptor
*/
virtual void Hello() = 0;
virtual void decrypt_message(const std::string& message, const int32_t& flags, int32_t& status, int32_t& rating) = 0;
public:
@ -73,10 +77,19 @@ private:
/* unmarshalers (to unpack the DBus message before calling the actual interface method)
*/
::DBus::Message _Hello_stub(const ::DBus::CallMessage &call)
::DBus::Message _decrypt_message_stub(const ::DBus::CallMessage &call)
{
Hello();
::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::ReturnMessage reply(call);
::DBus::MessageIter wi = reply.writer();
wi << argout1;
wi << argout2;
return reply;
}
};


+ 17
- 4
pep-server.cpp View File

@ -19,10 +19,7 @@ pEpServer::pEpServer(DBus::Connection &connection)
{
}
void pEpServer::hello()
{
std::cout << "Hello World" << std::endl;
}
pEpServer::~pEpServer() {};
DBus::BusDispatcher dispatcher;
@ -31,6 +28,22 @@ 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)
{
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
);
}
int main()
{
signal(SIGTERM, niam);


+ 11
- 2
pep-server.h View File

@ -4,14 +4,23 @@
#include <dbus-c++/dbus.h>
#include "pep-server-glue.h"
#include <pEp/message_cache.hh>
class pEpServer
: public security::pep_adaptor,
public DBus::IntrospectableAdaptor,
public DBus::ObjectAdaptor
{
public:
pEpServer(DBus::Connection &connection);
void hello();
pEpServer(DBus::Connection &connection);
~pEpServer();
// Message API
void decrypt_message(const std::string& message, const int32_t& flags, int32_t& status, int32_t& rating) ;
private:
PEP_SESSION mSession;
};
#endif//__DEMO_ASYNC_SERVER_H

Loading…
Cancel
Save