Commit 4baf2f92f231b7f2832d4df5da5b17576559e4dd
1 parent
9d7f1cf3
Exists in
master
and in
5 other branches
Incluindo mais métodos na interface dbus
Showing
5 changed files
with
83 additions
and
1 deletions
Show diff stats
src/plugins/dbus3270/gobject.c
| @@ -34,12 +34,15 @@ | @@ -34,12 +34,15 @@ | ||
| 34 | */ | 34 | */ |
| 35 | 35 | ||
| 36 | #include <glib.h> | 36 | #include <glib.h> |
| 37 | +#include <gtk/gtk.h> | ||
| 37 | #include <dbus/dbus.h> | 38 | #include <dbus/dbus.h> |
| 38 | #include <dbus/dbus-glib-lowlevel.h> | 39 | #include <dbus/dbus-glib-lowlevel.h> |
| 39 | #include <dbus/dbus-glib.h> | 40 | #include <dbus/dbus-glib.h> |
| 40 | 41 | ||
| 41 | #include <lib3270/config.h> | 42 | #include <lib3270/config.h> |
| 42 | #include <lib3270.h> | 43 | #include <lib3270.h> |
| 44 | +#include <pw3270.h> | ||
| 45 | +#include <pw3270/v3270.h> | ||
| 43 | #include <lib3270/actions.h> | 46 | #include <lib3270/actions.h> |
| 44 | 47 | ||
| 45 | #include "service.h" | 48 | #include "service.h" |
| @@ -366,3 +369,41 @@ void pw3270_dbus_pa_key(PW3270Dbus *object, int key, DBusGMethodInvocation *cont | @@ -366,3 +369,41 @@ void pw3270_dbus_pa_key(PW3270Dbus *object, int key, DBusGMethodInvocation *cont | ||
| 366 | trace("%s object=%p context=%p",__FUNCTION__,object,context); | 369 | trace("%s object=%p context=%p",__FUNCTION__,object,context); |
| 367 | dbus_g_method_return(context,lib3270_get_next_unprotected(pw3270_dbus_get_session_handle(object),baddr)); | 370 | dbus_g_method_return(context,lib3270_get_next_unprotected(pw3270_dbus_get_session_handle(object),baddr)); |
| 368 | } | 371 | } |
| 372 | + | ||
| 373 | +void pw3270_dbus_get_clipboard(PW3270Dbus *object, int row, int col, int len, DBusGMethodInvocation *context) | ||
| 374 | +{ | ||
| 375 | + gchar *text; | ||
| 376 | + | ||
| 377 | + if(pw3270_dbus_check_valid_state(object,context)) | ||
| 378 | + return; | ||
| 379 | + | ||
| 380 | + text = gtk_clipboard_wait_for_text(gtk_widget_get_clipboard(pw3270_get_toplevel(),GDK_SELECTION_CLIPBOARD)); | ||
| 381 | + if(!text) | ||
| 382 | + { | ||
| 383 | + GError *error = pw3270_dbus_get_error_from_errno(ENOENT); | ||
| 384 | + dbus_g_method_return_error(context,error); | ||
| 385 | + g_error_free(error); | ||
| 386 | + } | ||
| 387 | + else | ||
| 388 | + { | ||
| 389 | + dbus_g_method_return(context,text); | ||
| 390 | + g_free(text); | ||
| 391 | + } | ||
| 392 | +} | ||
| 393 | + | ||
| 394 | +void pw3270_dbus_set_script(PW3270Dbus *object, const gchar *text, int mode, DBusGMethodInvocation *context) | ||
| 395 | +{ | ||
| 396 | + GtkWidget *widget = pw3270_get_terminal_widget(NULL); | ||
| 397 | + | ||
| 398 | + trace("%s object=%p context=%p",__FUNCTION__,object,context); | ||
| 399 | + | ||
| 400 | + if(!widget) | ||
| 401 | + { | ||
| 402 | + GError *error = pw3270_dbus_get_error_from_errno(EINVAL); | ||
| 403 | + dbus_g_method_return_error(context,error); | ||
| 404 | + g_error_free(error); | ||
| 405 | + return; | ||
| 406 | + } | ||
| 407 | + | ||
| 408 | + dbus_g_method_return(context,v3270_set_script(widget,*text,mode != 0)); | ||
| 409 | +} |
src/plugins/dbus3270/pw3270dbus.xml
| @@ -61,6 +61,10 @@ | @@ -61,6 +61,10 @@ | ||
| 61 | <arg type="i" name="len" direction="in" /> | 61 | <arg type="i" name="len" direction="in" /> |
| 62 | <arg type="s" name="text" direction="out" /> | 62 | <arg type="s" name="text" direction="out" /> |
| 63 | </method> | 63 | </method> |
| 64 | + <method name="getClipboard"> | ||
| 65 | + <annotation name="org.freedesktop.DBus.GLib.Async" value="true"/> | ||
| 66 | + <arg type="s" name="text" direction="out" /> | ||
| 67 | + </method> | ||
| 64 | <method name="isConnected"> | 68 | <method name="isConnected"> |
| 65 | <annotation name="org.freedesktop.DBus.GLib.Async" value="true"/> | 69 | <annotation name="org.freedesktop.DBus.GLib.Async" value="true"/> |
| 66 | <arg type="i" name="result" direction="out" /> | 70 | <arg type="i" name="result" direction="out" /> |
| @@ -121,5 +125,12 @@ | @@ -121,5 +125,12 @@ | ||
| 121 | <arg type="i" name="addr" direction="in" /> | 125 | <arg type="i" name="addr" direction="in" /> |
| 122 | <arg type="i" name="result" direction="out" /> | 126 | <arg type="i" name="result" direction="out" /> |
| 123 | </method> | 127 | </method> |
| 128 | + <method name="setScript"> | ||
| 129 | + <annotation name="org.freedesktop.DBus.GLib.Async" value="true"/> | ||
| 130 | + <arg type="s" name="id" direction="in" /> | ||
| 131 | + <arg type="i" name="status" direction="in" /> | ||
| 132 | + <arg type="i" name="result" direction="out" /> | ||
| 133 | + </method> | ||
| 124 | </interface> | 134 | </interface> |
| 135 | + | ||
| 125 | </node> | 136 | </node> |
src/plugins/dbus3270/service.h
| @@ -89,6 +89,8 @@ | @@ -89,6 +89,8 @@ | ||
| 89 | void pw3270_dbus_get_field_length(PW3270Dbus *object, int baddr, DBusGMethodInvocation *context); | 89 | void pw3270_dbus_get_field_length(PW3270Dbus *object, int baddr, DBusGMethodInvocation *context); |
| 90 | void pw3270_dbus_get_next_unprotected(PW3270Dbus *object, int baddr, DBusGMethodInvocation *context); | 90 | void pw3270_dbus_get_next_unprotected(PW3270Dbus *object, int baddr, DBusGMethodInvocation *context); |
| 91 | 91 | ||
| 92 | + void pw3270_dbus_set_script(PW3270Dbus *object, const gchar *text, int mode, DBusGMethodInvocation *context); | ||
| 93 | + | ||
| 92 | // Actions | 94 | // Actions |
| 93 | void pw3270_dbus_enter(PW3270Dbus *object, DBusGMethodInvocation *context); | 95 | void pw3270_dbus_enter(PW3270Dbus *object, DBusGMethodInvocation *context); |
| 94 | void pw3270_dbus_pf_key(PW3270Dbus *object, int key, DBusGMethodInvocation *context); | 96 | void pw3270_dbus_pf_key(PW3270Dbus *object, int key, DBusGMethodInvocation *context); |
| @@ -97,6 +99,7 @@ | @@ -97,6 +99,7 @@ | ||
| 97 | void pw3270_dbus_get_text_at(PW3270Dbus *object, int row, int col, int len, DBusGMethodInvocation *context); | 99 | void pw3270_dbus_get_text_at(PW3270Dbus *object, int row, int col, int len, DBusGMethodInvocation *context); |
| 98 | void pw3270_dbus_cmp_text_at(PW3270Dbus *object, int row, int col, const gchar *text, DBusGMethodInvocation *context); | 100 | void pw3270_dbus_cmp_text_at(PW3270Dbus *object, int row, int col, const gchar *text, DBusGMethodInvocation *context); |
| 99 | void pw3270_dbus_input(PW3270Dbus *object, const gchar *utftext, DBusGMethodInvocation *context); | 101 | void pw3270_dbus_input(PW3270Dbus *object, const gchar *utftext, DBusGMethodInvocation *context); |
| 102 | + void pw3270_dbus_get_clipboard(PW3270Dbus *object, int row, int col, int len, DBusGMethodInvocation *context); | ||
| 100 | 103 | ||
| 101 | G_END_DECLS | 104 | G_END_DECLS |
| 102 | 105 |
src/plugins/rx3270/remote.cc
| @@ -83,6 +83,9 @@ | @@ -83,6 +83,9 @@ | ||
| 83 | int get_field_len(int baddr = -1); | 83 | int get_field_len(int baddr = -1); |
| 84 | int get_next_unprotected(int baddr = -1); | 84 | int get_next_unprotected(int baddr = -1); |
| 85 | 85 | ||
| 86 | + char * get_clipboard(void); | ||
| 87 | + int set_clipboard(const char *text); | ||
| 88 | + | ||
| 86 | private: | 89 | private: |
| 87 | #if defined(WIN32) | 90 | #if defined(WIN32) |
| 88 | 91 | ||
| @@ -1159,3 +1162,27 @@ int remote::get_next_unprotected(int baddr) | @@ -1159,3 +1162,27 @@ int remote::get_next_unprotected(int baddr) | ||
| 1159 | 1162 | ||
| 1160 | return -1; | 1163 | return -1; |
| 1161 | } | 1164 | } |
| 1165 | + | ||
| 1166 | +int remote::set_clipboard(const char *text) | ||
| 1167 | +{ | ||
| 1168 | + return -1; | ||
| 1169 | +} | ||
| 1170 | + | ||
| 1171 | +char * remote::get_clipboard(void) | ||
| 1172 | +{ | ||
| 1173 | +#if defined(WIN32) | ||
| 1174 | + | ||
| 1175 | + return NULL; | ||
| 1176 | + | ||
| 1177 | +#elif defined(HAVE_DBUS) | ||
| 1178 | + | ||
| 1179 | + DBusMessage * msg = create_message("getClipboard"); | ||
| 1180 | + if(!msg) | ||
| 1181 | + return NULL; | ||
| 1182 | + | ||
| 1183 | + return get_string(call(msg)); | ||
| 1184 | + | ||
| 1185 | +#endif | ||
| 1186 | + | ||
| 1187 | + return NULL; | ||
| 1188 | +} |