Commit 203516849d2ccd61eb3d51703a9b786c0e5a8da1

Authored by perry.werneck@gmail.com
1 parent 8996b7f3

Implementando método que faltava na interface dbus

src/classlib/remote.cc
... ... @@ -780,8 +780,17 @@
780 780 struct hllapi_packet_query_offset query = { HLLAPI_PACKET_GET_TEXT_AT_OFFSET, (unsigned short) baddr, (unsigned short) len };
781 781 return query_string(&query,sizeof(query),len);
782 782 #else
783   - #warning IMPLEMENTAR
784   - return NULL;
  783 + dbus_int32_t b = (dbus_int32_t) baddr;
  784 + dbus_int32_t l = (dbus_int32_t) len;
  785 +
  786 + DBusMessage * msg = create_message("getText");
  787 + if(!msg)
  788 + return NULL;
  789 +
  790 + trace("%s(%d,%d)",__FUNCTION__,b,l);
  791 + dbus_message_append_args(msg, DBUS_TYPE_INT32, &b, DBUS_TYPE_INT32, &l, DBUS_TYPE_INVALID);
  792 +
  793 + return get_string(call(msg));
785 794 #endif
786 795 }
787 796  
... ...
src/plugins/dbus3270/gobject.c
... ... @@ -268,9 +268,36 @@ void pw3270_dbus_get_text_at(PW3270Dbus *object, int row, int col, int len, DBus
268 268  
269 269 g_free(utftext);
270 270 }
  271 + }
271 272  
  273 + void pw3270_dbus_get_text(PW3270Dbus *object, int offset, int len, DBusGMethodInvocation *context)
  274 + {
  275 + gchar * text;
  276 + H3270 * hSession = pw3270_dbus_get_session_handle(object);
272 277  
273   -}
  278 + trace("%s object=%p context=%p",__FUNCTION__,object,context);
  279 + if(pw3270_dbus_check_valid_state(object,context))
  280 + return;
  281 +
  282 + text = lib3270_get_text(hSession,offset,len);
  283 + if(!text)
  284 + {
  285 + GError *error = pw3270_dbus_get_error_from_errno(errno);
  286 + dbus_g_method_return_error(context,error);
  287 + g_error_free(error);
  288 + }
  289 + else
  290 + {
  291 + gchar * utftext = g_convert_with_fallback(text,-1,"UTF-8",lib3270_get_charset(hSession),"?",NULL,NULL,NULL);
  292 +
  293 + lib3270_free(text);
  294 +
  295 + dbus_g_method_return(context,utftext);
  296 +
  297 + g_free(utftext);
  298 + }
  299 +
  300 + }
274 301  
275 302 void pw3270_dbus_is_connected(PW3270Dbus *object, DBusGMethodInvocation *context)
276 303 {
... ...
src/plugins/dbus3270/pw3270dbus.xml
... ... @@ -61,6 +61,12 @@
61 61 <arg type="i" name="len" direction="in" />
62 62 <arg type="s" name="text" direction="out" />
63 63 </method>
  64 + <method name="getText">
  65 + <annotation name="org.freedesktop.DBus.GLib.Async" value="true"/>
  66 + <arg type="i" name="addr" direction="in" />
  67 + <arg type="i" name="len" direction="in" />
  68 + <arg type="s" name="text" direction="out" />
  69 + </method>
64 70 <method name="setClipboard">
65 71 <annotation name="org.freedesktop.DBus.GLib.Async" value="true"/>
66 72 <arg type="s" name="text" direction="in" />
... ...
src/plugins/dbus3270/service.h
... ... @@ -97,6 +97,7 @@
97 97 void pw3270_dbus_pa_key(PW3270Dbus *object, int key, DBusGMethodInvocation *context);
98 98 void pw3270_dbus_set_text_at(PW3270Dbus *object, int row, int col, const gchar *text, DBusGMethodInvocation *context);
99 99 void pw3270_dbus_get_text_at(PW3270Dbus *object, int row, int col, int len, DBusGMethodInvocation *context);
  100 + void pw3270_dbus_get_text(PW3270Dbus *object, int offset, int len, DBusGMethodInvocation *context);
100 101 void pw3270_dbus_cmp_text_at(PW3270Dbus *object, int row, int col, const gchar *text, DBusGMethodInvocation *context);
101 102 void pw3270_dbus_input(PW3270Dbus *object, const gchar *utftext, DBusGMethodInvocation *context);
102 103  
... ...