Commit 2d55eeba9ad84a7d4c0ba213b0165ece47f299bf
1 parent
7c499d47
Exists in
master
and in
3 other branches
Working on IPC module.
Showing
5 changed files
with
36 additions
and
17 deletions
Show diff stats
src/include/lib3270++.h
@@ -202,7 +202,7 @@ | @@ -202,7 +202,7 @@ | ||
202 | virtual void disconnect() = 0; | 202 | virtual void disconnect() = 0; |
203 | 203 | ||
204 | // Wait for session state. | 204 | // Wait for session state. |
205 | - virtual void waitForReady(time_t timeout = DEFAULT_TIMEOUT) throw() = 0; | 205 | + virtual void waitForReady(time_t timeout = DEFAULT_TIMEOUT) = 0; |
206 | 206 | ||
207 | // Gets | 207 | // Gets |
208 | virtual std::string toString(int baddr = 0, size_t len = -1, char lf = '\n') const = 0; | 208 | virtual std::string toString(int baddr = 0, size_t len = -1, char lf = '\n') const = 0; |
src/lib3270++/ipc/session.cc
@@ -55,18 +55,22 @@ | @@ -55,18 +55,22 @@ | ||
55 | } | 55 | } |
56 | 56 | ||
57 | // Wait for session state. | 57 | // Wait for session state. |
58 | - void IPC::Session::waitForReady(time_t timeout) throw() { | 58 | + void IPC::Session::waitForReady(time_t timeout) { |
59 | 59 | ||
60 | int rc; | 60 | int rc; |
61 | - Request request(*this,"waitForReady"); | ||
62 | 61 | ||
63 | time_t end = time(nullptr) + timeout; | 62 | time_t end = time(nullptr) + timeout; |
64 | 63 | ||
65 | while(time(nullptr) < end) { | 64 | while(time(nullptr) < end) { |
66 | 65 | ||
67 | - request.call(); | 66 | + debug("Running waitForReady request..."); |
68 | 67 | ||
69 | - request.pop(rc); | 68 | + Request(*this,"waitForReady") |
69 | + .push(1) | ||
70 | + .call() | ||
71 | + .pop(rc); | ||
72 | + | ||
73 | + debug("Wait for ready returned ",rc); | ||
70 | 74 | ||
71 | if(rc == 0) | 75 | if(rc == 0) |
72 | return; | 76 | return; |
src/lib3270++/linux/request.cc
@@ -146,6 +146,11 @@ | @@ -146,6 +146,11 @@ | ||
146 | return *this; | 146 | return *this; |
147 | } | 147 | } |
148 | 148 | ||
149 | + IPC::Request & IPC::Request::push(int32_t arg) { | ||
150 | + dbus_message_append_args(this->msg.out,DBUS_TYPE_INT32,&arg,DBUS_TYPE_INVALID); | ||
151 | + return *this; | ||
152 | + } | ||
153 | + | ||
149 | IPC::Request & IPC::Request::pop(std::string &value) { | 154 | IPC::Request & IPC::Request::pop(std::string &value) { |
150 | 155 | ||
151 | const char * str = ""; | 156 | const char * str = ""; |
src/lib3270++/private.h
@@ -295,6 +295,7 @@ | @@ -295,6 +295,7 @@ | ||
295 | 295 | ||
296 | // Push values | 296 | // Push values |
297 | Request & push(const char *arg); | 297 | Request & push(const char *arg); |
298 | + Request & push(int32_t arg); | ||
298 | 299 | ||
299 | // Pop values | 300 | // Pop values |
300 | Request & pop(std::string &value); | 301 | Request & pop(std::string &value); |
@@ -331,7 +332,7 @@ | @@ -331,7 +332,7 @@ | ||
331 | void disconnect() override; | 332 | void disconnect() override; |
332 | 333 | ||
333 | // Wait for session state. | 334 | // Wait for session state. |
334 | - void waitForReady(time_t timeout = 5) throw() override; | 335 | + void waitForReady(time_t timeout = 5) override; |
335 | 336 | ||
336 | // Get properties. | 337 | // Get properties. |
337 | void getProperty(const char *name, int &value) const override; | 338 | void getProperty(const char *name, int &value) const override; |
src/lib3270++/testprogram/testprogram.cc
@@ -47,22 +47,31 @@ | @@ -47,22 +47,31 @@ | ||
47 | 47 | ||
48 | TN3270::Host host{"pw3270:a"}; | 48 | TN3270::Host host{"pw3270:a"}; |
49 | 49 | ||
50 | - cout | ||
51 | - << "Version: " << host.getVersion() | ||
52 | - << "\tRevision: " << host.getRevision() | ||
53 | - << std::endl; | 50 | + try { |
54 | 51 | ||
55 | - cout | ||
56 | - << "Connection state is " << host.getConnectionState() | ||
57 | - << "\tProgram message is " << host.getProgramMessage() | ||
58 | - << std::endl; | 52 | + cout |
53 | + << "Version: " << host.getVersion() | ||
54 | + << "\tRevision: " << host.getRevision() | ||
55 | + << std::endl; | ||
59 | 56 | ||
60 | - // host.connect(getenv("LIB3270_DEFAULT_HOST")); | 57 | + cout |
58 | + << "Connection state is " << host.getConnectionState() | ||
59 | + << "\tProgram message is " << host.getProgramMessage() | ||
60 | + << std::endl; | ||
61 | + | ||
62 | + // host.connect(getenv("LIB3270_DEFAULT_HOST")); | ||
63 | + | ||
64 | + if(host) { | ||
65 | + cout << host << endl; | ||
66 | + } | ||
67 | + | ||
68 | + } catch(const std::exception &e) { | ||
69 | + | ||
70 | + cerr << std::endl << e.what() << std::endl << std::endl; | ||
61 | 71 | ||
62 | - if(host) { | ||
63 | - cout << host << endl; | ||
64 | } | 72 | } |
65 | 73 | ||
74 | + | ||
66 | return 0; | 75 | return 0; |
67 | } | 76 | } |
68 | 77 |