Commit 4d99a85889712ca8b5f0428ab17bd5e89868da37
1 parent
5deea099
Exists in
master
and in
5 other branches
Incluindo método para obter a URL do host
Showing
11 changed files
with
74 additions
and
6 deletions
Show diff stats
src/classlib/local.cc
@@ -129,6 +129,7 @@ | @@ -129,6 +129,7 @@ | ||
129 | int (*_disconnect)(H3270 *h); | 129 | int (*_disconnect)(H3270 *h); |
130 | int (*_connect)(H3270 *h,int wait); | 130 | int (*_connect)(H3270 *h,int wait); |
131 | const char (*_set_url)(H3270 *h, const char *n); | 131 | const char (*_set_url)(H3270 *h, const char *n); |
132 | + const char * (*_get_url)(H3270 *h, char *str, int len); | ||
132 | int (*_is_connected)(H3270 *h); | 133 | int (*_is_connected)(H3270 *h); |
133 | void (*_main_iterate)(H3270 *h, int wait); | 134 | void (*_main_iterate)(H3270 *h, int wait); |
134 | int (*_wait)(H3270 *hSession, int seconds); | 135 | int (*_wait)(H3270 *hSession, int seconds); |
@@ -198,6 +199,7 @@ | @@ -198,6 +199,7 @@ | ||
198 | { (void **) & _disconnect, "lib3270_disconnect" }, | 199 | { (void **) & _disconnect, "lib3270_disconnect" }, |
199 | { (void **) & _connect, "lib3270_connect" }, | 200 | { (void **) & _connect, "lib3270_connect" }, |
200 | { (void **) & _set_url, "lib3270_set_url" }, | 201 | { (void **) & _set_url, "lib3270_set_url" }, |
202 | + { (void **) & _get_url, "lib3270_get_url" }, | ||
201 | { (void **) & _main_iterate, "lib3270_main_iterate" }, | 203 | { (void **) & _main_iterate, "lib3270_main_iterate" }, |
202 | { (void **) & _wait, "lib3270_wait" }, | 204 | { (void **) & _wait, "lib3270_wait" }, |
203 | { (void **) & _enter, "lib3270_enter" }, | 205 | { (void **) & _enter, "lib3270_enter" }, |
@@ -300,6 +302,12 @@ | @@ -300,6 +302,12 @@ | ||
300 | return (_set_url(hSession,uri) == 0); | 302 | return (_set_url(hSession,uri) == 0); |
301 | } | 303 | } |
302 | 304 | ||
305 | + string get_url() | ||
306 | + { | ||
307 | + char buffer[1024]; | ||
308 | + return string(_get_url(hSession,buffer,sizeof(buffer))); | ||
309 | + } | ||
310 | + | ||
303 | int disconnect(void) | 311 | int disconnect(void) |
304 | { | 312 | { |
305 | this->lock(); | 313 | this->lock(); |
src/classlib/remote.cc
@@ -56,6 +56,8 @@ | @@ -56,6 +56,8 @@ | ||
56 | #define HLLAPI_PACKET_GET_SSL_STATE "getSecureState" | 56 | #define HLLAPI_PACKET_GET_SSL_STATE "getSecureState" |
57 | #define HLLAPI_PACKET_IS_READY "isReady" | 57 | #define HLLAPI_PACKET_IS_READY "isReady" |
58 | #define HLLAPI_PACKET_DISCONNECT "disconnect" | 58 | #define HLLAPI_PACKET_DISCONNECT "disconnect" |
59 | + #define HLLAPI_PACKET_GET_HOST "getURL" | ||
60 | + #define HLLAPI_PACKET_SET_HOST "setURL" | ||
59 | #define HLLAPI_PACKET_GET_CURSOR "getCursorAddress" | 61 | #define HLLAPI_PACKET_GET_CURSOR "getCursorAddress" |
60 | #define HLLAPI_PACKET_GET_WIDTH "getScreenWidth" | 62 | #define HLLAPI_PACKET_GET_WIDTH "getScreenWidth" |
61 | #define HLLAPI_PACKET_GET_HEIGHT "getScreenHeight" | 63 | #define HLLAPI_PACKET_GET_HEIGHT "getScreenHeight" |
@@ -834,7 +836,7 @@ | @@ -834,7 +836,7 @@ | ||
834 | 836 | ||
835 | #elif defined(HAVE_DBUS) | 837 | #elif defined(HAVE_DBUS) |
836 | 838 | ||
837 | - rc = query_intval("setHost", DBUS_TYPE_STRING, &uri, DBUS_TYPE_INVALID); | 839 | + rc = query_intval(HLLAPI_PACKET_SET_HOST, DBUS_TYPE_STRING, &uri, DBUS_TYPE_INVALID); |
838 | 840 | ||
839 | #else | 841 | #else |
840 | 842 | ||
@@ -846,6 +848,21 @@ | @@ -846,6 +848,21 @@ | ||
846 | 848 | ||
847 | } | 849 | } |
848 | 850 | ||
851 | + string get_url() | ||
852 | + { | ||
853 | +#if defined(WIN32) | ||
854 | + | ||
855 | + struct hllapi_packet_query query = { HLLAPI_PACKET_GET_HOST }; | ||
856 | + return query_string(&query,sizeof(query),1024); | ||
857 | + | ||
858 | +#elif defined(HAVE_DBUS) | ||
859 | + | ||
860 | + return query_string(HLLAPI_PACKET_GET_HOST); | ||
861 | + | ||
862 | +#else | ||
863 | + return string(); | ||
864 | +#endif | ||
865 | + } | ||
849 | 866 | ||
850 | int wait_for_ready(int seconds) | 867 | int wait_for_ready(int seconds) |
851 | { | 868 | { |
src/include/lib3270.h
@@ -443,7 +443,7 @@ | @@ -443,7 +443,7 @@ | ||
443 | 443 | ||
444 | 444 | ||
445 | /** | 445 | /** |
446 | - * Get servic or port for the connect/reconnect operations. | 446 | + * Get service or port for the connect/reconnect operations. |
447 | * | 447 | * |
448 | * @param h Session handle. | 448 | * @param h Session handle. |
449 | * | 449 | * |
@@ -454,6 +454,8 @@ | @@ -454,6 +454,8 @@ | ||
454 | 454 | ||
455 | LIB3270_EXPORT void lib3270_set_srvcname(H3270 *h, const char *srvc); | 455 | LIB3270_EXPORT void lib3270_set_srvcname(H3270 *h, const char *srvc); |
456 | 456 | ||
457 | + LIB3270_EXPORT const char * lib3270_get_url(H3270 *h, char *buffer, int len); | ||
458 | + | ||
457 | /** | 459 | /** |
458 | * Get session options. | 460 | * Get session options. |
459 | * | 461 | * |
src/include/pw3270/class.h
@@ -166,7 +166,10 @@ | @@ -166,7 +166,10 @@ | ||
166 | int connect(const char *host, time_t wait = 0); | 166 | int connect(const char *host, time_t wait = 0); |
167 | int set_host(const char *host); | 167 | int set_host(const char *host); |
168 | virtual int connect(void) = 0; | 168 | virtual int connect(void) = 0; |
169 | + | ||
169 | virtual int set_url(const char *hostname) = 0; | 170 | virtual int set_url(const char *hostname) = 0; |
171 | + virtual string get_url() = 0; | ||
172 | + | ||
170 | virtual int disconnect(void) = 0; | 173 | virtual int disconnect(void) = 0; |
171 | virtual int wait_for_ready(int seconds) = 0; | 174 | virtual int wait_for_ready(int seconds) = 0; |
172 | virtual int wait(int seconds) = 0; | 175 | virtual int wait(int seconds) = 0; |
src/include/pw3270/ipcpackets.h
src/lib3270/host.c
@@ -219,6 +219,19 @@ static void update_host(H3270 *h) | @@ -219,6 +219,19 @@ static void update_host(H3270 *h) | ||
219 | 219 | ||
220 | } | 220 | } |
221 | 221 | ||
222 | +LIB3270_EXPORT const char * lib3270_get_url(H3270 *h, char *buffer, int len) | ||
223 | +{ | ||
224 | + CHECK_SESSION_HANDLE(h); | ||
225 | + | ||
226 | + snprintf(buffer,len,"%s://%s:%s", | ||
227 | + ((h->options & LIB3270_OPTION_SSL) == 0) ? "tn3270" : "tn3270s", | ||
228 | + h->host.current, | ||
229 | + h->host.srvc | ||
230 | + ); | ||
231 | + | ||
232 | + return buffer; | ||
233 | +} | ||
234 | + | ||
222 | LIB3270_EXPORT const char * lib3270_set_url(H3270 *h, const char *n) | 235 | LIB3270_EXPORT const char * lib3270_set_url(H3270 *h, const char *n) |
223 | { | 236 | { |
224 | CHECK_SESSION_HANDLE(h); | 237 | CHECK_SESSION_HANDLE(h); |
src/plugins/dbus3270/gobject.c
@@ -103,7 +103,7 @@ void pw3270_dbus_connect(PW3270Dbus *object, const gchar *uri, DBusGMethodInvoca | @@ -103,7 +103,7 @@ void pw3270_dbus_connect(PW3270Dbus *object, const gchar *uri, DBusGMethodInvoca | ||
103 | dbus_g_method_return(context,lib3270_connect(hSession,0)); | 103 | dbus_g_method_return(context,lib3270_connect(hSession,0)); |
104 | } | 104 | } |
105 | 105 | ||
106 | -void pw3270_dbus_set_host(PW3270Dbus *object, const gchar *uri, DBusGMethodInvocation *context) | 106 | +void pw3270_dbus_set_ur_l(PW3270Dbus *object, const gchar *uri, DBusGMethodInvocation *context) |
107 | { | 107 | { |
108 | trace("%s object=%p context=%p",__FUNCTION__,object,context); | 108 | trace("%s object=%p context=%p",__FUNCTION__,object,context); |
109 | 109 | ||
@@ -112,6 +112,17 @@ void pw3270_dbus_set_host(PW3270Dbus *object, const gchar *uri, DBusGMethodInvoc | @@ -112,6 +112,17 @@ void pw3270_dbus_set_host(PW3270Dbus *object, const gchar *uri, DBusGMethodInvoc | ||
112 | dbus_g_method_return(context,lib3270_set_url(pw3270_dbus_get_session_handle(PW3270_DBUS(object)),uri) == NULL); | 112 | dbus_g_method_return(context,lib3270_set_url(pw3270_dbus_get_session_handle(PW3270_DBUS(object)),uri) == NULL); |
113 | } | 113 | } |
114 | 114 | ||
115 | +void pw3270_dbus_get_ur_l(PW3270Dbus *object, DBusGMethodInvocation *context) | ||
116 | +{ | ||
117 | + char buffer[1024]; | ||
118 | + | ||
119 | + trace("%s object=%p context=%p",__FUNCTION__,object,context); | ||
120 | + | ||
121 | + lib3270_get_url(pw3270_dbus_get_session_handle(PW3270_DBUS(object)),buffer,sizeof(buffer)); | ||
122 | + dbus_g_method_return(context,buffer); | ||
123 | +} | ||
124 | + | ||
125 | + | ||
115 | void pw3270_dbus_disconnect(PW3270Dbus *object, DBusGMethodInvocation *context) | 126 | void pw3270_dbus_disconnect(PW3270Dbus *object, DBusGMethodInvocation *context) |
116 | { | 127 | { |
117 | trace("%s object=%p context=%p",__FUNCTION__,object,context); | 128 | trace("%s object=%p context=%p",__FUNCTION__,object,context); |
src/plugins/dbus3270/pw3270dbus.xml
@@ -14,11 +14,15 @@ | @@ -14,11 +14,15 @@ | ||
14 | <arg type="s" name="uri" direction="in" /> | 14 | <arg type="s" name="uri" direction="in" /> |
15 | <arg type="i" name="result" direction="out" /> | 15 | <arg type="i" name="result" direction="out" /> |
16 | </method> | 16 | </method> |
17 | - <method name="setHost"> | 17 | + <method name="setURL"> |
18 | <annotation name="org.freedesktop.DBus.GLib.Async" value="true"/> | 18 | <annotation name="org.freedesktop.DBus.GLib.Async" value="true"/> |
19 | <arg type="s" name="uri" direction="in" /> | 19 | <arg type="s" name="uri" direction="in" /> |
20 | <arg type="i" name="result" direction="out" /> | 20 | <arg type="i" name="result" direction="out" /> |
21 | </method> | 21 | </method> |
22 | + <method name="getURL"> | ||
23 | + <annotation name="org.freedesktop.DBus.GLib.Async" value="true"/> | ||
24 | + <arg type="s" name="uri" direction="out" /> | ||
25 | + </method> | ||
22 | <method name="disconnect"> | 26 | <method name="disconnect"> |
23 | <annotation name="org.freedesktop.DBus.GLib.Async" value="true"/> | 27 | <annotation name="org.freedesktop.DBus.GLib.Async" value="true"/> |
24 | <arg type="i" name="result" direction="out" /> | 28 | <arg type="i" name="result" direction="out" /> |
src/plugins/dbus3270/service.h
@@ -66,7 +66,8 @@ | @@ -66,7 +66,8 @@ | ||
66 | void pw3270_dbus_get_revision(PW3270Dbus *object, DBusGMethodInvocation *context); | 66 | void pw3270_dbus_get_revision(PW3270Dbus *object, DBusGMethodInvocation *context); |
67 | void pw3270_dbus_quit(PW3270Dbus *object, DBusGMethodInvocation *context); | 67 | void pw3270_dbus_quit(PW3270Dbus *object, DBusGMethodInvocation *context); |
68 | void pw3270_dbus_connect(PW3270Dbus *object, const gchar *uri, DBusGMethodInvocation *context); | 68 | void pw3270_dbus_connect(PW3270Dbus *object, const gchar *uri, DBusGMethodInvocation *context); |
69 | - void pw3270_dbus_set_host(PW3270Dbus *object, const gchar *uri, DBusGMethodInvocation *context); | 69 | + void pw3270_dbus_get_ur_l(PW3270Dbus *object, DBusGMethodInvocation *context); |
70 | + void pw3270_dbus_set_ur_l(PW3270Dbus *object, const gchar *uri, DBusGMethodInvocation *context); | ||
70 | void pw3270_dbus_disconnect(PW3270Dbus *object, DBusGMethodInvocation *context); | 71 | void pw3270_dbus_disconnect(PW3270Dbus *object, DBusGMethodInvocation *context); |
71 | 72 | ||
72 | void pw3270_dbus_get_message_id(PW3270Dbus *object, DBusGMethodInvocation *context); | 73 | void pw3270_dbus_get_message_id(PW3270Dbus *object, DBusGMethodInvocation *context); |
src/plugins/hllapi/pluginmain.c
@@ -219,6 +219,11 @@ | @@ -219,6 +219,11 @@ | ||
219 | ((struct hllapi_packet_text *) source->buffer)->text) != NULL); | 219 | ((struct hllapi_packet_text *) source->buffer)->text) != NULL); |
220 | break; | 220 | break; |
221 | 221 | ||
222 | + case HLLAPI_PACKET_GET_HOST: | ||
223 | +// send_text(source,lib3270_get_host(lib3270_get_default_session_handle(),((struct hllapi_packet_text *) source->buffer)->text),-1); | ||
224 | + #error Alocar buffer dinâmico | ||
225 | + break; | ||
226 | + | ||
222 | case HLLAPI_PACKET_DISCONNECT: | 227 | case HLLAPI_PACKET_DISCONNECT: |
223 | send_result(source,lib3270_disconnect(lib3270_get_default_session_handle())); | 228 | send_result(source,lib3270_disconnect(lib3270_get_default_session_handle())); |
224 | break; | 229 | break; |
src/pw3270/v3270/widget.c
@@ -767,9 +767,12 @@ static void ctlr_done(H3270 *session) | @@ -767,9 +767,12 @@ static void ctlr_done(H3270 *session) | ||
767 | 767 | ||
768 | static void update_connect(H3270 *session, unsigned char connected) | 768 | static void update_connect(H3270 *session, unsigned char connected) |
769 | { | 769 | { |
770 | +#ifdef DEBUG | ||
771 | + char dbg[1024]; | ||
772 | +#endif // DEBUG | ||
770 | v3270 *widget = GTK_V3270(lib3270_get_user_data(session)); | 773 | v3270 *widget = GTK_V3270(lib3270_get_user_data(session)); |
771 | 774 | ||
772 | - trace("%s - %s",__FUNCTION__,connected ? "Connected" : "Disconnected"); | 775 | + trace("%s - %s %s",__FUNCTION__,lib3270_get_url(session,dbg,sizeof(dbg)),connected ? "Connected" : "Disconnected"); |
773 | 776 | ||
774 | if(connected) | 777 | if(connected) |
775 | { | 778 | { |