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 | 34 | */ |
35 | 35 | |
36 | 36 | #include <glib.h> |
37 | +#include <gtk/gtk.h> | |
37 | 38 | #include <dbus/dbus.h> |
38 | 39 | #include <dbus/dbus-glib-lowlevel.h> |
39 | 40 | #include <dbus/dbus-glib.h> |
40 | 41 | |
41 | 42 | #include <lib3270/config.h> |
42 | 43 | #include <lib3270.h> |
44 | +#include <pw3270.h> | |
45 | +#include <pw3270/v3270.h> | |
43 | 46 | #include <lib3270/actions.h> |
44 | 47 | |
45 | 48 | #include "service.h" |
... | ... | @@ -366,3 +369,41 @@ void pw3270_dbus_pa_key(PW3270Dbus *object, int key, DBusGMethodInvocation *cont |
366 | 369 | trace("%s object=%p context=%p",__FUNCTION__,object,context); |
367 | 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 | 61 | <arg type="i" name="len" direction="in" /> |
62 | 62 | <arg type="s" name="text" direction="out" /> |
63 | 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 | 68 | <method name="isConnected"> |
65 | 69 | <annotation name="org.freedesktop.DBus.GLib.Async" value="true"/> |
66 | 70 | <arg type="i" name="result" direction="out" /> |
... | ... | @@ -121,5 +125,12 @@ |
121 | 125 | <arg type="i" name="addr" direction="in" /> |
122 | 126 | <arg type="i" name="result" direction="out" /> |
123 | 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 | 134 | </interface> |
135 | + | |
125 | 136 | </node> | ... | ... |
src/plugins/dbus3270/service.h
... | ... | @@ -89,6 +89,8 @@ |
89 | 89 | void pw3270_dbus_get_field_length(PW3270Dbus *object, int baddr, DBusGMethodInvocation *context); |
90 | 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 | 94 | // Actions |
93 | 95 | void pw3270_dbus_enter(PW3270Dbus *object, DBusGMethodInvocation *context); |
94 | 96 | void pw3270_dbus_pf_key(PW3270Dbus *object, int key, DBusGMethodInvocation *context); |
... | ... | @@ -97,6 +99,7 @@ |
97 | 99 | void pw3270_dbus_get_text_at(PW3270Dbus *object, int row, int col, int len, DBusGMethodInvocation *context); |
98 | 100 | void pw3270_dbus_cmp_text_at(PW3270Dbus *object, int row, int col, const gchar *text, DBusGMethodInvocation *context); |
99 | 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 | 104 | G_END_DECLS |
102 | 105 | ... | ... |
src/plugins/rx3270/remote.cc
... | ... | @@ -83,6 +83,9 @@ |
83 | 83 | int get_field_len(int baddr = -1); |
84 | 84 | int get_next_unprotected(int baddr = -1); |
85 | 85 | |
86 | + char * get_clipboard(void); | |
87 | + int set_clipboard(const char *text); | |
88 | + | |
86 | 89 | private: |
87 | 90 | #if defined(WIN32) |
88 | 91 | |
... | ... | @@ -1159,3 +1162,27 @@ int remote::get_next_unprotected(int baddr) |
1159 | 1162 | |
1160 | 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 | +} | ... | ... |