From 17248ec7bd9ffbce45e466db6f34fc9e1aaaecd1 Mon Sep 17 00:00:00 2001 From: Perry Werneck Date: Tue, 19 Feb 2019 11:27:10 -0300 Subject: [PATCH] Working on the new IPC API. --- ipc/session.cc | 25 +++++++++++++++++++++++-- linux/request.cc | 18 +++++++++++++++++- private.h | 5 ++++- 3 files changed, 44 insertions(+), 4 deletions(-) diff --git a/ipc/session.cc b/ipc/session.cc index 7322601..5617470 100644 --- a/ipc/session.cc +++ b/ipc/session.cc @@ -81,11 +81,32 @@ } std::string IPC::Session::toString(int baddr, size_t len, char lf) const { - throw std::system_error(EINVAL, std::system_category()); + + std::string rc; + + Request(*this,"getStringAtAddress") + .push((uint32_t) baddr) + .push((uint32_t) len) + .push((uint8_t) lf) + .call() + .pop(rc); + + return rc; } std::string IPC::Session::toString(int row, int col, size_t sz, char lf) const { - throw std::system_error(EINVAL, std::system_category()); + + std::string rc; + + Request(*this,"getStringAt") + .push((uint32_t) row) + .push((uint32_t) col) + .push((uint32_t) sz) + .push((uint8_t) lf) + .call() + .pop(rc); + + return rc; } ProgramMessage IPC::Session::getProgramMessage() const { diff --git a/linux/request.cc b/linux/request.cc index 3a2ba56..f7d7ea9 100644 --- a/linux/request.cc +++ b/linux/request.cc @@ -146,11 +146,27 @@ return *this; } - IPC::Request & IPC::Request::push(int32_t arg) { + IPC::Request & IPC::Request::push(const bool arg) { + dbus_message_append_args(this->msg.out,DBUS_TYPE_BOOLEAN,&arg,DBUS_TYPE_INVALID); + return *this; + } + + IPC::Request & IPC::Request::push(const uint8_t arg) { + dbus_message_append_args(this->msg.out,DBUS_TYPE_BYTE,&arg,DBUS_TYPE_INVALID); + return *this; + } + + IPC::Request & IPC::Request::push(const int32_t arg) { dbus_message_append_args(this->msg.out,DBUS_TYPE_INT32,&arg,DBUS_TYPE_INVALID); return *this; } + IPC::Request & IPC::Request::push(const uint32_t arg) { + dbus_message_append_args(this->msg.out,DBUS_TYPE_UINT32,&arg,DBUS_TYPE_INVALID); + return *this; + } + + IPC::Request & IPC::Request::pop(std::string &value) { const char * str = ""; diff --git a/private.h b/private.h index 0c81ad9..c970893 100644 --- a/private.h +++ b/private.h @@ -295,7 +295,10 @@ // Push values Request & push(const char *arg); - Request & push(int32_t arg); + Request & push(const bool arg); + Request & push(const int32_t arg); + Request & push(const uint32_t arg); + Request & push(const uint8_t arg); // Pop values Request & pop(std::string &value); -- libgit2 0.21.2