Commit 3dff46b8e9d4367acd4381709e267eb25d7bf99b
1 parent
9c22cccf
Exists in
master
and in
5 other branches
Implementando novo módulo de serviço.
Showing
4 changed files
with
21 additions
and
2 deletions
Show diff stats
src/include/pw3270cpp.h
@@ -144,6 +144,8 @@ | @@ -144,6 +144,8 @@ | ||
144 | static bool has_default(void); | 144 | static bool has_default(void); |
145 | static void set_plugin(session * (*factory)(const char *name)); | 145 | static void set_plugin(session * (*factory)(const char *name)); |
146 | 146 | ||
147 | + virtual string get_session_name(void) const; | ||
148 | + | ||
147 | // Log management | 149 | // Log management |
148 | void log(const char *fmt, ...); | 150 | void log(const char *fmt, ...); |
149 | void logva(const char *fmt, va_list args); | 151 | void logva(const char *fmt, va_list args); |
src/libpw3270cpp/service.cc
@@ -266,7 +266,11 @@ | @@ -266,7 +266,11 @@ | ||
266 | DBusError err; | 266 | DBusError err; |
267 | 267 | ||
268 | dbus_error_init(&err); | 268 | dbus_error_init(&err); |
269 | +#ifdef DEBUG | ||
269 | conn = dbus_bus_get(DBUS_BUS_SESSION, &err); | 270 | conn = dbus_bus_get(DBUS_BUS_SESSION, &err); |
271 | +#else | ||
272 | + conn = dbus_bus_get(DBUS_BUS_SYSTEM, &err); | ||
273 | +#endif | ||
270 | 274 | ||
271 | if(dbus_error_is_set(&err)) | 275 | if(dbus_error_is_set(&err)) |
272 | { | 276 | { |
@@ -305,6 +309,13 @@ | @@ -305,6 +309,13 @@ | ||
305 | 309 | ||
306 | } | 310 | } |
307 | 311 | ||
312 | + virtual string get_session_name(void) const | ||
313 | + { | ||
314 | + string rc = "service://"; | ||
315 | + rc += this->name; | ||
316 | + return rc; | ||
317 | + } | ||
318 | + | ||
308 | virtual bool is_connected(void) | 319 | virtual bool is_connected(void) |
309 | { | 320 | { |
310 | return getInteger("isConnected", DBUS_TYPE_STRING, &this->id, DBUS_TYPE_INVALID); | 321 | return getInteger("isConnected", DBUS_TYPE_STRING, &this->id, DBUS_TYPE_INVALID); |
src/libpw3270cpp/session.cc
@@ -692,7 +692,8 @@ | @@ -692,7 +692,8 @@ | ||
692 | int rows = get_height(); | 692 | int rows = get_height(); |
693 | int cols = get_width(); | 693 | int cols = get_width(); |
694 | 694 | ||
695 | - for(int r = 0; r < rows; r++) { | 695 | + for(int r = 0; r < rows; r++) |
696 | + { | ||
696 | rc += get_string_at(r+1,0,cols).c_str(); | 697 | rc += get_string_at(r+1,0,cols).c_str(); |
697 | rc += "\n"; | 698 | rc += "\n"; |
698 | } | 699 | } |
@@ -700,6 +701,10 @@ | @@ -700,6 +701,10 @@ | ||
700 | return rc; | 701 | return rc; |
701 | } | 702 | } |
702 | 703 | ||
704 | + string session::get_session_name(void) const | ||
705 | + { | ||
706 | + return string(); | ||
707 | + } | ||
703 | 708 | ||
704 | } | 709 | } |
705 | 710 |
src/libpw3270cpp/testprogram.cc
@@ -47,7 +47,8 @@ | @@ -47,7 +47,8 @@ | ||
47 | // session *session = session::start("new"); | 47 | // session *session = session::start("new"); |
48 | 48 | ||
49 | cout << "pw3270 version: " << session->get_version() << endl; | 49 | cout << "pw3270 version: " << session->get_version() << endl; |
50 | - cout << "pw3270 revision: " << session->get_revision() << endl << endl; | 50 | + cout << "pw3270 revision: " << session->get_revision() << endl; |
51 | + cout << "pw3270 session: " << session->get_session_name() << endl << endl; | ||
51 | 52 | ||
52 | if(session->is_connected()) | 53 | if(session->is_connected()) |
53 | cout << "\tConnected to host" << endl; | 54 | cout << "\tConnected to host" << endl; |