Commit d3a3a087d4b6f111bd2724163e8b9069507578ed
1 parent
5949f2b7
Exists in
master
and in
3 other branches
Adding getter/setter request.
Showing
2 changed files
with
51 additions
and
7 deletions
Show diff stats
src/lib3270++/linux/request.cc
... | ... | @@ -44,16 +44,20 @@ |
44 | 44 | |
45 | 45 | namespace TN3270 { |
46 | 46 | |
47 | - IPC::Request::Request(Session &session, const char *method) { | |
48 | - | |
47 | + IPC::Request::Request(Session &session) { | |
49 | 48 | this->conn = session.conn; |
50 | 49 | this->msg.in = nullptr; |
50 | + this->msg.out = nullptr; | |
51 | + } | |
52 | + | |
53 | + IPC::Request::Request(Session &session, const char *method) : Request(session) { | |
51 | 54 | |
52 | - this->msg.out = dbus_message_new_method_call( session.name.c_str(), // Destination | |
53 | - session.path.c_str(), // Path | |
54 | - session.interface.c_str(), // Interface | |
55 | - method // method | |
56 | - ); | |
55 | + this->msg.out = dbus_message_new_method_call( | |
56 | + session.name.c_str(), // Destination | |
57 | + session.path.c_str(), // Path | |
58 | + session.interface.c_str(), // Interface | |
59 | + method // Method | |
60 | + ); | |
57 | 61 | |
58 | 62 | if(!msg.out) { |
59 | 63 | throw std::runtime_error("Can't create D-Bus Method Call"); |
... | ... | @@ -61,6 +65,38 @@ |
61 | 65 | |
62 | 66 | } |
63 | 67 | |
68 | + IPC::Request::Request(Session &session, const char *method, const char *property) : Request(session) { | |
69 | + | |
70 | + this->msg.out = dbus_message_new_method_call( | |
71 | + session.name.c_str(), // Destination | |
72 | + session.path.c_str(), // Path | |
73 | + "org.freedesktop.DBus.Properties", // Interface | |
74 | + method // Method | |
75 | + ); | |
76 | + | |
77 | + if(!msg.out) { | |
78 | + throw std::runtime_error("Can't create D-Bus Property Call"); | |
79 | + } | |
80 | + | |
81 | + // | |
82 | + // https://dbus.freedesktop.org/doc/dbus-specification.html#standard-interfaces-properties | |
83 | + // org.freedesktop.DBus.Properties.Get (in STRING interface_name, | |
84 | + // in STRING property_name, | |
85 | + // out VARIANT value); | |
86 | + // org.freedesktop.DBus.Properties.Set (in STRING interface_name, | |
87 | + // in STRING property_name, | |
88 | + // | |
89 | + const char *interface_name = session.interface.c_str(); | |
90 | + | |
91 | + dbus_message_append_args( | |
92 | + this->msg.out, | |
93 | + DBUS_TYPE_STRING,&interface_name, | |
94 | + DBUS_TYPE_STRING,&method, | |
95 | + DBUS_TYPE_INVALID | |
96 | + ); | |
97 | + | |
98 | + } | |
99 | + | |
64 | 100 | IPC::Request::~Request() { |
65 | 101 | if(msg.out) { |
66 | 102 | dbus_message_unref(msg.out); | ... | ... |
src/lib3270++/private.h
... | ... | @@ -240,8 +240,16 @@ |
240 | 240 | |
241 | 241 | #endif // _WIN32 |
242 | 242 | |
243 | + Request(Session &session); | |
244 | + | |
243 | 245 | public: |
246 | + | |
247 | + /// @brief Create a method call. | |
244 | 248 | Request(Session &session, const char *method); |
249 | + | |
250 | + /// @brief Create a get/set property call. | |
251 | + Request(Session &session, const char *method, const char *property); | |
252 | + | |
245 | 253 | ~Request(); |
246 | 254 | |
247 | 255 | Request & call(); | ... | ... |