Commit 42fa4a104c84dcc6c4ab18b38a649b924ce860a9

Authored by perry.werneck@gmail.com
1 parent 7838137b

Implementando chamadas via DBUS no módulo rexx para linux

src/plugins/dbus3270/gobject.c
@@ -252,3 +252,65 @@ void pw3270_dbus_get_text_at(PW3270Dbus *object, int row, int col, int len, DBus @@ -252,3 +252,65 @@ void pw3270_dbus_get_text_at(PW3270Dbus *object, int row, int col, int len, DBus
252 252
253 } 253 }
254 254
  255 + void pw3270_dbus_is_connected(PW3270Dbus *object, DBusGMethodInvocation *context)
  256 + {
  257 + trace("%s object=%p context=%p",__FUNCTION__,object,context);
  258 + dbus_g_method_return(context,lib3270_is_connected(pw3270_dbus_get_session_handle(object)));
  259 + }
  260 +
  261 + void pw3270_dbus_is_ready(PW3270Dbus *object, DBusGMethodInvocation *context)
  262 + {
  263 + trace("%s object=%p context=%p",__FUNCTION__,object,context);
  264 + dbus_g_method_return(context,lib3270_is_ready(pw3270_dbus_get_session_handle(object)));
  265 + }
  266 +
  267 + void pw3270_dbus_wait_for_ready(PW3270Dbus *object, int timeout, DBusGMethodInvocation *context)
  268 + {
  269 + trace("%s object=%p context=%p",__FUNCTION__,object,context);
  270 + dbus_g_method_return(context,lib3270_wait_for_ready(pw3270_dbus_get_session_handle(object),timeout));
  271 + }
  272 +
  273 + void pw3270_dbus_set_cursor_at(PW3270Dbus *object, int row, int col, DBusGMethodInvocation *context)
  274 + {
  275 + trace("%s object=%p context=%p",__FUNCTION__,object,context);
  276 + dbus_g_method_return(context,lib3270_set_cursor_position(pw3270_dbus_get_session_handle(object),row,col));
  277 + }
  278 +
  279 + void pw3270_dbus_set_toggle(PW3270Dbus *object, int id, int value, DBusGMethodInvocation *context)
  280 + {
  281 + trace("%s object=%p context=%p",__FUNCTION__,object,context);
  282 + lib3270_set_toggle(pw3270_dbus_get_session_handle(object),id,value);
  283 + dbus_g_method_return(context,0);
  284 + }
  285 +
  286 +void pw3270_dbus_cmp_text_at(PW3270Dbus *object, int row, int col, const gchar *utftext, DBusGMethodInvocation *context)
  287 +{
  288 + gchar * text;
  289 + H3270 * hSession = pw3270_dbus_get_session_handle(object);
  290 +
  291 + trace("%s object=%p context=%p",__FUNCTION__,object,context);
  292 + if(pw3270_dbus_check_valid_state(object,context))
  293 + return;
  294 +
  295 + text = g_convert_with_fallback(utftext,-1,lib3270_get_charset(hSession),"UTF-8","?",NULL,NULL,NULL);
  296 +
  297 + dbus_g_method_return(context,lib3270_cmp_text_at(hSession,row,col,text));
  298 +
  299 + g_free(text);
  300 +}
  301 +
  302 +void pw3270_dbus_pf_key(PW3270Dbus *object, int key, DBusGMethodInvocation *context)
  303 +{
  304 + trace("%s object=%p context=%p",__FUNCTION__,object,context);
  305 + if(pw3270_dbus_check_valid_state(object,context))
  306 + return;
  307 + dbus_g_method_return(context,lib3270_pfkey(pw3270_dbus_get_session_handle(object),key));
  308 +}
  309 +
  310 +void pw3270_dbus_pa_key(PW3270Dbus *object, int key, DBusGMethodInvocation *context)
  311 +{
  312 + trace("%s object=%p context=%p",__FUNCTION__,object,context);
  313 + if(pw3270_dbus_check_valid_state(object,context))
  314 + return;
  315 + dbus_g_method_return(context,lib3270_pakey(pw3270_dbus_get_session_handle(object),key));
  316 +}
src/plugins/dbus3270/main.c
@@ -161,7 +161,10 @@ @@ -161,7 +161,10 @@
161 dbus_g_method_return(context,0); 161 dbus_g_method_return(context,0);
162 } 162 }
163 163
164 -H3270 * pw3270_dbus_get_session_handle(PW3270Dbus *object)  
165 -{ 164 + H3270 * pw3270_dbus_get_session_handle(PW3270Dbus *object)
  165 + {
166 return lib3270_get_default_session_handle(); 166 return lib3270_get_default_session_handle();
167 -} 167 + }
  168 +
  169 +
  170 +
src/plugins/dbus3270/pw3270dbus.xml
@@ -34,6 +34,16 @@ @@ -34,6 +34,16 @@
34 <annotation name="org.freedesktop.DBus.GLib.Async" value="true"/> 34 <annotation name="org.freedesktop.DBus.GLib.Async" value="true"/>
35 <arg type="i" name="result" direction="out" /> 35 <arg type="i" name="result" direction="out" />
36 </method> 36 </method>
  37 + <method name="pfKey">
  38 + <annotation name="org.freedesktop.DBus.GLib.Async" value="true"/>
  39 + <arg type="i" name="key" direction="in" />
  40 + <arg type="i" name="result" direction="out" />
  41 + </method>
  42 + <method name="paKey">
  43 + <annotation name="org.freedesktop.DBus.GLib.Async" value="true"/>
  44 + <arg type="i" name="key" direction="in" />
  45 + <arg type="i" name="result" direction="out" />
  46 + </method>
37 <method name="setTextAt"> 47 <method name="setTextAt">
38 <annotation name="org.freedesktop.DBus.GLib.Async" value="true"/> 48 <annotation name="org.freedesktop.DBus.GLib.Async" value="true"/>
39 <arg type="i" name="row" direction="in" /> 49 <arg type="i" name="row" direction="in" />
@@ -45,6 +55,40 @@ @@ -45,6 +55,40 @@
45 <arg type="i" name="row" direction="in" /> 55 <arg type="i" name="row" direction="in" />
46 <arg type="i" name="col" direction="in" /> 56 <arg type="i" name="col" direction="in" />
47 <arg type="i" name="len" direction="in" /> 57 <arg type="i" name="len" direction="in" />
  58 + <arg type="s" name="text" direction="out" />
  59 + </method>
  60 + <method name="isConnected">
  61 + <annotation name="org.freedesktop.DBus.GLib.Async" value="true"/>
  62 + <arg type="i" name="result" direction="out" />
  63 + </method>
  64 + <method name="isReady">
  65 + <annotation name="org.freedesktop.DBus.GLib.Async" value="true"/>
  66 + <arg type="i" name="result" direction="out" />
  67 + </method>
  68 + <method name="waitForReady">
  69 + <annotation name="org.freedesktop.DBus.GLib.Async" value="true"/>
  70 + <arg type="i" name="timeout" direction="in" />
  71 + <arg type="i" name="result" direction="out" />
  72 + </method>
  73 + <method name="setCursorAt">
  74 + <annotation name="org.freedesktop.DBus.GLib.Async" value="true"/>
  75 + <arg type="i" name="row" direction="in" />
  76 + <arg type="i" name="col" direction="in" />
  77 + <arg type="i" name="result" direction="out" />
  78 + </method>
  79 + <method name="setToggle">
  80 + <annotation name="org.freedesktop.DBus.GLib.Async" value="true"/>
  81 + <arg type="i" name="id" direction="in" />
  82 + <arg type="i" name="value" direction="in" />
  83 + <arg type="i" name="result" direction="out" />
  84 + </method>
  85 + <method name="cmpTextAt">
  86 + <annotation name="org.freedesktop.DBus.GLib.Async" value="true"/>
  87 + <arg type="i" name="row" direction="in" />
  88 + <arg type="i" name="col" direction="in" />
  89 + <arg type="s" name="text" direction="in" />
  90 + <arg type="i" name="result" direction="out" />
48 </method> 91 </method>
  92 +
49 </interface> 93 </interface>
50 </node> 94 </node>
src/plugins/dbus3270/service.h
@@ -73,10 +73,21 @@ @@ -73,10 +73,21 @@
73 H3270 * pw3270_dbus_get_session_handle(PW3270Dbus *object); 73 H3270 * pw3270_dbus_get_session_handle(PW3270Dbus *object);
74 GError * pw3270_dbus_get_error_from_errno(int code); 74 GError * pw3270_dbus_get_error_from_errno(int code);
75 75
  76 + void pw3270_dbus_is_connected(PW3270Dbus *object, DBusGMethodInvocation *context);
  77 + void pw3270_dbus_is_ready(PW3270Dbus *object, DBusGMethodInvocation *context);
  78 +
  79 + void pw3270_dbus_set_cursor_at(PW3270Dbus *object, int row, int col, DBusGMethodInvocation *context);
  80 + void pw3270_dbus_set_toggle(PW3270Dbus *object, int id, int value, DBusGMethodInvocation *context);
  81 +
  82 + void pw3270_dbus_wait_for_ready(PW3270Dbus *object, int timeout, DBusGMethodInvocation *context);
  83 +
76 // Actions 84 // Actions
77 void pw3270_dbus_enter(PW3270Dbus *object, DBusGMethodInvocation *context); 85 void pw3270_dbus_enter(PW3270Dbus *object, DBusGMethodInvocation *context);
  86 + void pw3270_dbus_pf_key(PW3270Dbus *object, int key, DBusGMethodInvocation *context);
  87 + void pw3270_dbus_pa_key(PW3270Dbus *object, int key, DBusGMethodInvocation *context);
78 void pw3270_dbus_set_text_at(PW3270Dbus *object, int row, int col, const gchar *text, DBusGMethodInvocation *context); 88 void pw3270_dbus_set_text_at(PW3270Dbus *object, int row, int col, const gchar *text, DBusGMethodInvocation *context);
79 void pw3270_dbus_get_text_at(PW3270Dbus *object, int row, int col, int len, DBusGMethodInvocation *context); 89 void pw3270_dbus_get_text_at(PW3270Dbus *object, int row, int col, int len, DBusGMethodInvocation *context);
  90 + void pw3270_dbus_cmp_text_at(PW3270Dbus *object, int row, int col, const gchar *text, DBusGMethodInvocation *context);
80 91
81 G_END_DECLS 92 G_END_DECLS
82 93
src/plugins/rx3270/local.cc
@@ -30,12 +30,9 @@ @@ -30,12 +30,9 @@
30 #include "rx3270.h" 30 #include "rx3270.h"
31 #include <string.h> 31 #include <string.h>
32 32
33 -#if defined WIN32  
34 - #define REXX_DEFAULT_CHARSET "CP1252"  
35 -#else 33 +#if !defined WIN32
36 #include <dlfcn.h> 34 #include <dlfcn.h>
37 #include <stdio.h> 35 #include <stdio.h>
38 - #define REXX_DEFAULT_CHARSET "UTF-8"  
39 #endif 36 #endif
40 37
41 #ifdef HAVE_SYSLOG 38 #ifdef HAVE_SYSLOG
@@ -120,11 +117,20 @@ @@ -120,11 +117,20 @@
120 117
121 /*--[ Implement ]------------------------------------------------------------------------------------*/ 118 /*--[ Implement ]------------------------------------------------------------------------------------*/
122 119
123 -rx3270::rx3270() 120 +rx3270::rx3270(const char *local, const char *remote)
124 { 121 {
125 #ifdef HAVE_ICONV 122 #ifdef HAVE_ICONV
126 - this->conv2Local = iconv_open(REXX_DEFAULT_CHARSET, "ISO-8859-1");  
127 - this->conv2Host = iconv_open("ISO-8859-1",REXX_DEFAULT_CHARSET); 123 +
  124 + if(strcmp(local,remote))
  125 + {
  126 + // Local and remote charsets aren't the same, setup conversion
  127 + this->conv2Local = iconv_open(local, remote);
  128 + this->conv2Host = iconv_open(remote,local);
  129 + }
  130 + else
  131 + {
  132 + this->conv2Local = this->conv2Host = (iconv_t)(-1);
  133 + }
128 #endif 134 #endif
129 135
130 if(!defSession) 136 if(!defSession)
src/plugins/rx3270/remote.cc
@@ -40,6 +40,7 @@ @@ -40,6 +40,7 @@
40 40
41 #include <time.h> 41 #include <time.h>
42 #include <string.h> 42 #include <string.h>
  43 + #include <ctype.h>
43 44
44 /*--[ Class definition ]-----------------------------------------------------------------------------*/ 45 /*--[ Class definition ]-----------------------------------------------------------------------------*/
45 46
@@ -124,7 +125,11 @@ rx3270 * rx3270::create_remote(const char *name) @@ -124,7 +125,11 @@ rx3270 * rx3270::create_remote(const char *name)
124 } 125 }
125 126
126 127
  128 +#if defined(HAVE_DBUS)
  129 +remote::remote(const char *name) : rx3270(REXX_DEFAULT_CHARSET,"UTF-8")
  130 +#else
127 remote::remote(const char *name) 131 remote::remote(const char *name)
  132 +#endif // HAVE_DBUS
128 { 133 {
129 #if defined(WIN32) 134 #if defined(WIN32)
130 static DWORD dwMode = PIPE_READMODE_MESSAGE; 135 static DWORD dwMode = PIPE_READMODE_MESSAGE;
@@ -138,6 +143,8 @@ remote::remote(const char *name) @@ -138,6 +143,8 @@ remote::remote(const char *name)
138 { 143 {
139 if(*ptr == ':') 144 if(*ptr == ':')
140 *ptr = '_'; 145 *ptr = '_';
  146 + else
  147 + *ptr = tolower(*ptr);
141 } 148 }
142 149
143 snprintf(buffer,4095,"\\\\.\\pipe\\%s",str); 150 snprintf(buffer,4095,"\\\\.\\pipe\\%s",str);
@@ -172,7 +179,12 @@ remote::remote(const char *name) @@ -172,7 +179,12 @@ remote::remote(const char *name)
172 DBusError err; 179 DBusError err;
173 int rc; 180 int rc;
174 char * str = strdup(name); 181 char * str = strdup(name);
175 - char * ptr = strchr(str,':'); 182 + char * ptr;
  183 +
  184 + for(ptr=str;*ptr;ptr++)
  185 + *ptr = tolower(*ptr);
  186 +
  187 + ptr = strchr(str,':');
176 188
177 if(ptr) 189 if(ptr)
178 { 190 {
@@ -200,11 +212,28 @@ remote::remote(const char *name) @@ -200,11 +212,28 @@ remote::remote(const char *name)
200 strncpy(intf,prefix_dest,sz); 212 strncpy(intf,prefix_dest,sz);
201 strncat(intf,str,sz); 213 strncat(intf,str,sz);
202 214
203 -  
204 } 215 }
205 else 216 else
206 { 217 {
207 - exit(-1); 218 + size_t sz;
  219 +
  220 + // Build destination
  221 + sz = strlen(str)+strlen(prefix_dest)+2;
  222 + dest = (char *) malloc(sz+1);
  223 + strncpy(dest,prefix_dest,sz);
  224 + strncat(dest,str,sz);
  225 +
  226 + // Build path
  227 + sz = strlen(str)+strlen(prefix_path);
  228 + path = (char *) malloc(sz+1);
  229 + strncpy(path,prefix_path,sz);
  230 + strncat(path,str,sz);
  231 +
  232 + // Build intf
  233 + sz = strlen(str)+strlen(prefix_dest)+1;
  234 + intf = (char *) malloc(sz+1);
  235 + strncpy(intf,prefix_dest,sz);
  236 + strncat(intf,str,sz);
208 237
209 } 238 }
210 239
@@ -290,62 +319,73 @@ DBusMessage * remote::call(DBusMessage *msg) @@ -290,62 +319,73 @@ DBusMessage * remote::call(DBusMessage *msg)
290 319
291 } 320 }
292 321
293 -char * remote::query_string(const char *method) 322 +char * get_string(DBusMessage * msg)
294 { 323 {
295 char *rc = NULL; 324 char *rc = NULL;
296 -  
297 - if(conn) 325 + if(msg)
298 { 326 {
299 - DBusMessage * msg = call(create_message(method));  
300 - if(msg)  
301 - {  
302 - DBusMessageIter iter; 327 + DBusMessageIter iter;
303 328
304 - if(dbus_message_iter_init(msg, &iter)) 329 + if(dbus_message_iter_init(msg, &iter))
  330 + {
  331 + if(dbus_message_iter_get_arg_type(&iter) == DBUS_TYPE_STRING)
305 { 332 {
306 - if(dbus_message_iter_get_arg_type(&iter) == DBUS_TYPE_STRING)  
307 - {  
308 - const char * str;  
309 - dbus_message_iter_get_basic(&iter, &str);  
310 - rc = strdup(str);  
311 - } 333 + const char * str;
  334 + dbus_message_iter_get_basic(&iter, &str);
  335 + trace("Response: [%s]",str);
  336 + rc = strdup(str);
312 } 337 }
313 -  
314 - dbus_message_unref(msg); 338 +#ifdef DEBUG
  339 + else
  340 + {
  341 + trace("Arg type is %c, expecting %c",dbus_message_iter_get_arg_type(&iter),DBUS_TYPE_STRING);
  342 + }
  343 +#endif
315 } 344 }
316 - }  
317 345
  346 + dbus_message_unref(msg);
  347 + }
318 return rc; 348 return rc;
319 } 349 }
320 350
321 -int remote::query_intval(const char *method) 351 +char * remote::query_string(const char *method)
  352 +{
  353 + if(conn)
  354 + return get_string(call(create_message(method)));
  355 + return NULL;
  356 +}
  357 +
  358 +int get_intval(DBusMessage * msg)
322 { 359 {
323 int rc = -1; 360 int rc = -1;
324 361
325 - if(conn) 362 + if(msg)
326 { 363 {
327 - DBusMessage * msg = call(create_message(method));  
328 - if(msg)  
329 - {  
330 - DBusMessageIter iter; 364 + DBusMessageIter iter;
331 365
332 - if(dbus_message_iter_init(msg, &iter)) 366 + if(dbus_message_iter_init(msg, &iter))
  367 + {
  368 + if(dbus_message_iter_get_arg_type(&iter) == DBUS_TYPE_INT32)
333 { 369 {
334 - if(dbus_message_iter_get_arg_type(&iter) == DBUS_TYPE_INT32)  
335 - {  
336 - dbus_int32_t iSigned;  
337 - dbus_message_iter_get_basic(&iter, &iSigned);  
338 - rc = (int) iSigned;  
339 - } 370 + dbus_int32_t iSigned;
  371 + dbus_message_iter_get_basic(&iter, &iSigned);
  372 + rc = (int) iSigned;
340 } 373 }
341 -  
342 - dbus_message_unref(msg);  
343 } 374 }
  375 +
  376 + dbus_message_unref(msg);
344 } 377 }
345 378
346 return rc; 379 return rc;
347 } 380 }
348 381
  382 +int remote::query_intval(const char *method)
  383 +{
  384 + if(conn)
  385 + return get_intval(call(create_message(method)));
  386 + return -1;
  387 +}
  388 +
349 389
350 #endif // HAVE_DBUS 390 #endif // HAVE_DBUS
351 391
@@ -374,7 +414,7 @@ LIB3270_CSTATE remote::get_cstate(void) @@ -374,7 +414,7 @@ LIB3270_CSTATE remote::get_cstate(void)
374 414
375 if(hPipe != INVALID_HANDLE_VALUE) 415 if(hPipe != INVALID_HANDLE_VALUE)
376 { 416 {
377 - 417 + #warning Implementar
378 } 418 }
379 419
380 return (LIB3270_CSTATE) -1; 420 return (LIB3270_CSTATE) -1;
@@ -449,6 +489,20 @@ int remote::connect(const char *uri, bool wait) @@ -449,6 +489,20 @@ int remote::connect(const char *uri, bool wait)
449 489
450 #elif defined(HAVE_DBUS) 490 #elif defined(HAVE_DBUS)
451 491
  492 + int rc;
  493 + DBusMessage * msg = create_message("connect");
  494 + if(!msg)
  495 + return -1;
  496 +
  497 + dbus_message_append_args(msg, DBUS_TYPE_STRING, &uri, DBUS_TYPE_INVALID);
  498 +
  499 + rc = get_intval(call(msg));
  500 +
  501 + if(!rc && wait)
  502 + return wait_for_ready(120);
  503 +
  504 + return rc;
  505 +
452 #endif 506 #endif
453 507
454 return -1; 508 return -1;
@@ -469,6 +523,8 @@ bool remote::is_connected(void) @@ -469,6 +523,8 @@ bool remote::is_connected(void)
469 523
470 #elif defined(HAVE_DBUS) 524 #elif defined(HAVE_DBUS)
471 525
  526 + return query_intval("isConnected") != 0;
  527 +
472 #endif 528 #endif
473 529
474 return false; 530 return false;
@@ -480,11 +536,13 @@ bool remote::is_ready(void) @@ -480,11 +536,13 @@ bool remote::is_ready(void)
480 536
481 if(hPipe != INVALID_HANDLE_VALUE) 537 if(hPipe != INVALID_HANDLE_VALUE)
482 { 538 {
483 - 539 + #warning Implementar
484 } 540 }
485 541
486 #elif defined(HAVE_DBUS) 542 #elif defined(HAVE_DBUS)
487 543
  544 + return query_intval("isReady") != 0;
  545 +
488 #endif 546 #endif
489 547
490 return false; 548 return false;
@@ -564,6 +622,29 @@ int remote::wait_for_ready(int seconds) @@ -564,6 +622,29 @@ int remote::wait_for_ready(int seconds)
564 622
565 #elif defined(HAVE_DBUS) 623 #elif defined(HAVE_DBUS)
566 624
  625 + time_t end = time(0)+seconds;
  626 +
  627 + while(time(0) < end)
  628 + {
  629 + static const dbus_int32_t delay = 2;
  630 +
  631 + DBusMessage * msg = create_message("waitForReady");
  632 + int rc;
  633 +
  634 + if(!msg)
  635 + return -1;
  636 +
  637 + dbus_message_append_args(msg, DBUS_TYPE_INT32, &delay, DBUS_TYPE_INVALID);
  638 +
  639 + rc = get_intval(call(msg));
  640 + trace("waitForReady exits with rc=%d",rc);
  641 + if(rc != ETIMEDOUT)
  642 + return rc;
  643 + }
  644 +
  645 +
  646 + return ETIMEDOUT;
  647 +
567 #endif 648 #endif
568 649
569 return -1; 650 return -1;
@@ -598,6 +679,19 @@ char * remote::get_text_at(int row, int col, size_t sz) @@ -598,6 +679,19 @@ char * remote::get_text_at(int row, int col, size_t sz)
598 679
599 #elif defined(HAVE_DBUS) 680 #elif defined(HAVE_DBUS)
600 681
  682 + dbus_int32_t r = (dbus_int32_t) row;
  683 + dbus_int32_t c = (dbus_int32_t) col;
  684 + dbus_int32_t l = (dbus_int32_t) sz;
  685 +
  686 + DBusMessage * msg = create_message("getTextAt");
  687 + if(!msg)
  688 + return NULL;
  689 +
  690 + trace("%s(%d,%d,%d)",__FUNCTION__,r,c,l);
  691 + dbus_message_append_args(msg, DBUS_TYPE_INT32, &r, DBUS_TYPE_INT32, &c, DBUS_TYPE_INT32, &l, DBUS_TYPE_INVALID);
  692 +
  693 + return get_string(call(msg));
  694 +
601 #endif 695 #endif
602 696
603 return NULL; 697 return NULL;
@@ -629,6 +723,16 @@ int remote::cmp_text_at(int row, int col, const char *text) @@ -629,6 +723,16 @@ int remote::cmp_text_at(int row, int col, const char *text)
629 723
630 #elif defined(HAVE_DBUS) 724 #elif defined(HAVE_DBUS)
631 725
  726 + dbus_int32_t r = (dbus_int32_t) row;
  727 + dbus_int32_t c = (dbus_int32_t) col;
  728 +
  729 + DBusMessage * msg = create_message("cmpTextAt");
  730 + if(msg)
  731 + {
  732 + dbus_message_append_args(msg, DBUS_TYPE_INT32, &r, DBUS_TYPE_INT32, &c, DBUS_TYPE_STRING, &text, DBUS_TYPE_INVALID);
  733 + return get_intval(call(msg));
  734 + }
  735 +
632 #endif 736 #endif
633 737
634 return 0; 738 return 0;
@@ -659,6 +763,16 @@ int remote::set_text_at(int row, int col, const char *str) @@ -659,6 +763,16 @@ int remote::set_text_at(int row, int col, const char *str)
659 763
660 #elif defined(HAVE_DBUS) 764 #elif defined(HAVE_DBUS)
661 765
  766 + dbus_int32_t r = (dbus_int32_t) row;
  767 + dbus_int32_t c = (dbus_int32_t) col;
  768 +
  769 + DBusMessage * msg = create_message("setTextAt");
  770 + if(msg)
  771 + {
  772 + dbus_message_append_args(msg, DBUS_TYPE_INT32, &r, DBUS_TYPE_INT32, &c, DBUS_TYPE_STRING, &str, DBUS_TYPE_INVALID);
  773 + return get_intval(call(msg));
  774 + }
  775 +
662 #endif 776 #endif
663 777
664 return -1; 778 return -1;
@@ -670,11 +784,21 @@ int remote::set_cursor_position(int row, int col) @@ -670,11 +784,21 @@ int remote::set_cursor_position(int row, int col)
670 784
671 if(hPipe != INVALID_HANDLE_VALUE) 785 if(hPipe != INVALID_HANDLE_VALUE)
672 { 786 {
673 - 787 + #warning Implementar
674 } 788 }
675 789
676 #elif defined(HAVE_DBUS) 790 #elif defined(HAVE_DBUS)
677 791
  792 + dbus_int32_t r = (dbus_int32_t) row;
  793 + dbus_int32_t c = (dbus_int32_t) col;
  794 +
  795 + DBusMessage * msg = create_message("setCursorAt");
  796 + if(msg)
  797 + {
  798 + dbus_message_append_args(msg, DBUS_TYPE_INT32, &r, DBUS_TYPE_INT32, &c, DBUS_TYPE_INVALID);
  799 + return get_intval(call(msg));
  800 + }
  801 +
678 #endif 802 #endif
679 803
680 return -1; 804 return -1;
@@ -722,6 +846,15 @@ int remote::pfkey(int key) @@ -722,6 +846,15 @@ int remote::pfkey(int key)
722 846
723 #elif defined(HAVE_DBUS) 847 #elif defined(HAVE_DBUS)
724 848
  849 + dbus_int32_t k = (dbus_int32_t) key;
  850 +
  851 + DBusMessage * msg = create_message("pfKey");
  852 + if(msg)
  853 + {
  854 + dbus_message_append_args(msg, DBUS_TYPE_INT32, &k, DBUS_TYPE_INVALID);
  855 + return get_intval(call(msg));
  856 + }
  857 +
725 #endif 858 #endif
726 859
727 return -1; 860 return -1;
@@ -742,6 +875,15 @@ int remote::pakey(int key) @@ -742,6 +875,15 @@ int remote::pakey(int key)
742 875
743 #elif defined(HAVE_DBUS) 876 #elif defined(HAVE_DBUS)
744 877
  878 + dbus_int32_t k = (dbus_int32_t) key;
  879 +
  880 + DBusMessage * msg = create_message("paKey");
  881 + if(msg)
  882 + {
  883 + dbus_message_append_args(msg, DBUS_TYPE_INT32, &k, DBUS_TYPE_INVALID);
  884 + return get_intval(call(msg));
  885 + }
  886 +
745 #endif 887 #endif
746 888
747 return -1; 889 return -1;
@@ -758,6 +900,17 @@ void remote::set_toggle(LIB3270_TOGGLE ix, bool value) @@ -758,6 +900,17 @@ void remote::set_toggle(LIB3270_TOGGLE ix, bool value)
758 900
759 #elif defined(HAVE_DBUS) 901 #elif defined(HAVE_DBUS)
760 902
  903 + dbus_int32_t i = (dbus_int32_t) ix;
  904 + dbus_int32_t v = (dbus_int32_t) value;
  905 +
  906 + DBusMessage * msg = create_message("setToggle");
  907 + if(msg)
  908 + {
  909 + dbus_message_append_args(msg, DBUS_TYPE_INT32, &i, DBUS_TYPE_INT32, &v, DBUS_TYPE_INVALID);
  910 + get_intval(call(msg));
  911 + }
  912 +
  913 +
761 #endif 914 #endif
762 915
763 } 916 }
src/plugins/rx3270/rx3270.h
@@ -56,6 +56,13 @@ @@ -56,6 +56,13 @@
56 #include <iconv.h> 56 #include <iconv.h>
57 #endif // HAVE_ICONV 57 #endif // HAVE_ICONV
58 58
  59 +#ifdef WIN32
  60 + #define REXX_DEFAULT_CHARSET "CP1252"
  61 +#else
  62 + #define REXX_DEFAULT_CHARSET "UTF-8"
  63 +#endif // WIN32
  64 +
  65 +
59 /*---[ Rexx entry points ]-----------------------------------------------------------------------------------*/ 66 /*---[ Rexx entry points ]-----------------------------------------------------------------------------------*/
60 67
61 REXX_TYPED_ROUTINE_PROTOTYPE(rx3270version); 68 REXX_TYPED_ROUTINE_PROTOTYPE(rx3270version);
@@ -119,7 +126,8 @@ @@ -119,7 +126,8 @@
119 126
120 public: 127 public:
121 128
122 - rx3270(); 129 + rx3270(const char *local = REXX_DEFAULT_CHARSET, const char *remote = "ISO-8859-1");
  130 +
123 virtual ~rx3270(); 131 virtual ~rx3270();
124 132
125 static rx3270 * create(const char *name = NULL); 133 static rx3270 * create(const char *name = NULL);
src/plugins/rx3270/sample/remote.rex
@@ -4,7 +4,15 @@ use arg uri @@ -4,7 +4,15 @@ use arg uri
4 host = .rx3270~new("pw3270:a") 4 host = .rx3270~new("pw3270:a")
5 5
6 say "PW3270 version is "||host~revision() 6 say "PW3270 version is "||host~revision()
7 -say "Connections state is "||rx3270QueryCState() 7 +say "Connection state is "||host~connected()
  8 +say "Ready state is "||host~ready()
  9 +
  10 +if uri <> "URI"
  11 + then say "Connect rc="||host~connect(uri)
  12 +
  13 +say "Wait for ready is "||host~WaitForReady(60)
  14 +
  15 +say "Text[3,2,27]="||host~GetTextAt(3,2,27)
8 16
9 return 0 17 return 0
10 18