Browse Source

Fixing Variation methods

It's not crashing anymore.
Now I can shuffle the data forth and back over D-Bus!

Yeehaa!
master
David Lanzendörfer 1 year ago
parent
commit
2b19057dc1
4 changed files with 47 additions and 16 deletions
  1. +2
    -0
      pep-server.cpp
  2. +10
    -4
      tests.cpp
  3. +24
    -9
      types/pEpDBusMessage.cpp
  4. +11
    -3
      types/pEpDBusMessage.h

+ 2
- 0
pep-server.cpp View File

@ -22,6 +22,8 @@ pEp::Server::~Server()
void pEp::Server::send_test(const pEpDBusMessage& src)
{
message m;
m << src;
std::cout << "Got something" << std::endl;
return;
}


+ 10
- 4
tests.cpp View File

@ -13,15 +13,21 @@ int main()
from.address="leviathan@libresilicon.com";
m.from=&from;
pEpDBusMessage src, dst;
/*pEpDBusMessage src, dst;
pEpDBusStringList keylist;
pEpDBusRating rating;
pEpDBusEncryptionFlags flags;
pEpDBusStatus status;
src.clear();
src << m;
src.clear();*/
//client.decrypt_message(src,keylist,rating,flags,status,dst);
//dst >> m;
::DBus::MessageIter wi;
::DBus::Variant _src;
pEpDBusMessage src;
src << m;
client.send_test(src);
dst >> m;
return 0;
}

+ 24
- 9
types/pEpDBusMessage.cpp View File

@ -1,31 +1,46 @@
#include "pEpDBusMessage.h"
#include <iostream>
pEpDBusMessage::pEpDBusMessage()
pEpDBusMessage::pEpDBusMessage() : DBus::Variant::Variant()
{
writer().new_variant("s");
}
pEpDBusMessage::pEpDBusMessage(message m)
pEpDBusMessage::pEpDBusMessage(message m) : DBus::Variant::Variant()
{
writer().new_variant("s");
}
DBus::Variant& operator<<(DBus::Variant&, const pEpDBusMessage&)
DBus::Variant& operator>>(DBus::Variant &v, const pEpDBusMessage &m)
{
DBus::Variant ret;
// TODO Copy the writer over to the other variant
return ret;
DBus::MessageIter to = m.writer();
v.reader().copy_data(to);
return v;
}
DBus::Variant& operator<<(DBus::Variant &v, const pEpDBusMessage &m)
{
DBus::MessageIter to = v.writer();
m.reader().copy_data(to);
return v;
}
message& pEpDBusMessage::operator >> (message &m)
{
//m.from->address << reader();
m.from->address = writer().get_string();
return m;
}
DBus::Variant& pEpDBusMessage::operator << (DBus::Variant &v)
{
DBus::MessageIter to = writer();
v.reader().copy_data(to);
return v;
}
message& pEpDBusMessage::operator << (message &m)
{
writer().append_string("test");
//writer().append_string(m.from->address);
writer().append_string(m.from->address);
return m;
}

+ 11
- 3
types/pEpDBusMessage.h View File

@ -11,12 +11,20 @@ public:
explicit pEpDBusMessage();
explicit pEpDBusMessage(message);
message& operator >> (message&);
message& operator << (message&);
message& operator >> (message &m);
message& operator << (message &m);
const DBus::Signature signature() const { return "b"; }
DBus::Variant& operator << (DBus::Variant &v);
//const DBus::Signature signature() const;
friend DBus::Variant& operator << (DBus::Variant&, const pEpDBusMessage&);
friend DBus::Variant& operator >> (DBus::Variant&, const pEpDBusMessage&);
friend message& operator << (message &m, const pEpDBusMessage&) { return m; }
friend message& operator >> (message &m, const pEpDBusMessage&) { return m; }
//friend std::string operator << (DBus::Variant&, const pEpDBusMessage&);
};
#endif

Loading…
Cancel
Save