diff --git a/src/lib3270++/linux/request.cc b/src/lib3270++/linux/request.cc index d012d1c..22c30a1 100644 --- a/src/lib3270++/linux/request.cc +++ b/src/lib3270++/linux/request.cc @@ -44,16 +44,20 @@ namespace TN3270 { - IPC::Request::Request(Session &session, const char *method) { - + IPC::Request::Request(Session &session) { this->conn = session.conn; this->msg.in = nullptr; + this->msg.out = nullptr; + } + + IPC::Request::Request(Session &session, const char *method) : Request(session) { - this->msg.out = dbus_message_new_method_call( session.name.c_str(), // Destination - session.path.c_str(), // Path - session.interface.c_str(), // Interface - method // method - ); + this->msg.out = dbus_message_new_method_call( + session.name.c_str(), // Destination + session.path.c_str(), // Path + session.interface.c_str(), // Interface + method // Method + ); if(!msg.out) { throw std::runtime_error("Can't create D-Bus Method Call"); @@ -61,6 +65,38 @@ } + IPC::Request::Request(Session &session, const char *method, const char *property) : Request(session) { + + this->msg.out = dbus_message_new_method_call( + session.name.c_str(), // Destination + session.path.c_str(), // Path + "org.freedesktop.DBus.Properties", // Interface + method // Method + ); + + if(!msg.out) { + throw std::runtime_error("Can't create D-Bus Property Call"); + } + + // + // https://dbus.freedesktop.org/doc/dbus-specification.html#standard-interfaces-properties + // org.freedesktop.DBus.Properties.Get (in STRING interface_name, + // in STRING property_name, + // out VARIANT value); + // org.freedesktop.DBus.Properties.Set (in STRING interface_name, + // in STRING property_name, + // + const char *interface_name = session.interface.c_str(); + + dbus_message_append_args( + this->msg.out, + DBUS_TYPE_STRING,&interface_name, + DBUS_TYPE_STRING,&method, + DBUS_TYPE_INVALID + ); + + } + IPC::Request::~Request() { if(msg.out) { dbus_message_unref(msg.out); diff --git a/src/lib3270++/private.h b/src/lib3270++/private.h index cb6c31a..7757d48 100644 --- a/src/lib3270++/private.h +++ b/src/lib3270++/private.h @@ -240,8 +240,16 @@ #endif // _WIN32 + Request(Session &session); + public: + + /// @brief Create a method call. Request(Session &session, const char *method); + + /// @brief Create a get/set property call. + Request(Session &session, const char *method, const char *property); + ~Request(); Request & call(); -- libgit2 0.21.2