Commit 42fa4a104c84dcc6c4ab18b38a649b924ce860a9
1 parent
7838137b
Exists in
master
and in
5 other branches
Implementando chamadas via DBUS no módulo rexx para linux
Showing
8 changed files
with
345 additions
and
50 deletions
Show diff stats
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 | 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 | 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 | 166 | return lib3270_get_default_session_handle(); |
| 167 | -} | |
| 167 | + } | |
| 168 | + | |
| 169 | + | |
| 170 | + | ... | ... |
src/plugins/dbus3270/pw3270dbus.xml
| ... | ... | @@ -34,6 +34,16 @@ |
| 34 | 34 | <annotation name="org.freedesktop.DBus.GLib.Async" value="true"/> |
| 35 | 35 | <arg type="i" name="result" direction="out" /> |
| 36 | 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 | 47 | <method name="setTextAt"> |
| 38 | 48 | <annotation name="org.freedesktop.DBus.GLib.Async" value="true"/> |
| 39 | 49 | <arg type="i" name="row" direction="in" /> |
| ... | ... | @@ -45,6 +55,40 @@ |
| 45 | 55 | <arg type="i" name="row" direction="in" /> |
| 46 | 56 | <arg type="i" name="col" direction="in" /> |
| 47 | 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 | 91 | </method> |
| 92 | + | |
| 49 | 93 | </interface> |
| 50 | 94 | </node> | ... | ... |
src/plugins/dbus3270/service.h
| ... | ... | @@ -73,10 +73,21 @@ |
| 73 | 73 | H3270 * pw3270_dbus_get_session_handle(PW3270Dbus *object); |
| 74 | 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 | 84 | // Actions |
| 77 | 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 | 88 | void pw3270_dbus_set_text_at(PW3270Dbus *object, int row, int col, const gchar *text, DBusGMethodInvocation *context); |
| 79 | 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 | 92 | G_END_DECLS |
| 82 | 93 | ... | ... |
src/plugins/rx3270/local.cc
| ... | ... | @@ -30,12 +30,9 @@ |
| 30 | 30 | #include "rx3270.h" |
| 31 | 31 | #include <string.h> |
| 32 | 32 | |
| 33 | -#if defined WIN32 | |
| 34 | - #define REXX_DEFAULT_CHARSET "CP1252" | |
| 35 | -#else | |
| 33 | +#if !defined WIN32 | |
| 36 | 34 | #include <dlfcn.h> |
| 37 | 35 | #include <stdio.h> |
| 38 | - #define REXX_DEFAULT_CHARSET "UTF-8" | |
| 39 | 36 | #endif |
| 40 | 37 | |
| 41 | 38 | #ifdef HAVE_SYSLOG |
| ... | ... | @@ -120,11 +117,20 @@ |
| 120 | 117 | |
| 121 | 118 | /*--[ Implement ]------------------------------------------------------------------------------------*/ |
| 122 | 119 | |
| 123 | -rx3270::rx3270() | |
| 120 | +rx3270::rx3270(const char *local, const char *remote) | |
| 124 | 121 | { |
| 125 | 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 | 134 | #endif |
| 129 | 135 | |
| 130 | 136 | if(!defSession) | ... | ... |
src/plugins/rx3270/remote.cc
| ... | ... | @@ -40,6 +40,7 @@ |
| 40 | 40 | |
| 41 | 41 | #include <time.h> |
| 42 | 42 | #include <string.h> |
| 43 | + #include <ctype.h> | |
| 43 | 44 | |
| 44 | 45 | /*--[ Class definition ]-----------------------------------------------------------------------------*/ |
| 45 | 46 | |
| ... | ... | @@ -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 | 131 | remote::remote(const char *name) |
| 132 | +#endif // HAVE_DBUS | |
| 128 | 133 | { |
| 129 | 134 | #if defined(WIN32) |
| 130 | 135 | static DWORD dwMode = PIPE_READMODE_MESSAGE; |
| ... | ... | @@ -138,6 +143,8 @@ remote::remote(const char *name) |
| 138 | 143 | { |
| 139 | 144 | if(*ptr == ':') |
| 140 | 145 | *ptr = '_'; |
| 146 | + else | |
| 147 | + *ptr = tolower(*ptr); | |
| 141 | 148 | } |
| 142 | 149 | |
| 143 | 150 | snprintf(buffer,4095,"\\\\.\\pipe\\%s",str); |
| ... | ... | @@ -172,7 +179,12 @@ remote::remote(const char *name) |
| 172 | 179 | DBusError err; |
| 173 | 180 | int rc; |
| 174 | 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 | 189 | if(ptr) |
| 178 | 190 | { |
| ... | ... | @@ -200,11 +212,28 @@ remote::remote(const char *name) |
| 200 | 212 | strncpy(intf,prefix_dest,sz); |
| 201 | 213 | strncat(intf,str,sz); |
| 202 | 214 | |
| 203 | - | |
| 204 | 215 | } |
| 205 | 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 | 319 | |
| 291 | 320 | } |
| 292 | 321 | |
| 293 | -char * remote::query_string(const char *method) | |
| 322 | +char * get_string(DBusMessage * msg) | |
| 294 | 323 | { |
| 295 | 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 | 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 | 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 | 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 | 390 | #endif // HAVE_DBUS |
| 351 | 391 | |
| ... | ... | @@ -374,7 +414,7 @@ LIB3270_CSTATE remote::get_cstate(void) |
| 374 | 414 | |
| 375 | 415 | if(hPipe != INVALID_HANDLE_VALUE) |
| 376 | 416 | { |
| 377 | - | |
| 417 | + #warning Implementar | |
| 378 | 418 | } |
| 379 | 419 | |
| 380 | 420 | return (LIB3270_CSTATE) -1; |
| ... | ... | @@ -449,6 +489,20 @@ int remote::connect(const char *uri, bool wait) |
| 449 | 489 | |
| 450 | 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 | 506 | #endif |
| 453 | 507 | |
| 454 | 508 | return -1; |
| ... | ... | @@ -469,6 +523,8 @@ bool remote::is_connected(void) |
| 469 | 523 | |
| 470 | 524 | #elif defined(HAVE_DBUS) |
| 471 | 525 | |
| 526 | + return query_intval("isConnected") != 0; | |
| 527 | + | |
| 472 | 528 | #endif |
| 473 | 529 | |
| 474 | 530 | return false; |
| ... | ... | @@ -480,11 +536,13 @@ bool remote::is_ready(void) |
| 480 | 536 | |
| 481 | 537 | if(hPipe != INVALID_HANDLE_VALUE) |
| 482 | 538 | { |
| 483 | - | |
| 539 | + #warning Implementar | |
| 484 | 540 | } |
| 485 | 541 | |
| 486 | 542 | #elif defined(HAVE_DBUS) |
| 487 | 543 | |
| 544 | + return query_intval("isReady") != 0; | |
| 545 | + | |
| 488 | 546 | #endif |
| 489 | 547 | |
| 490 | 548 | return false; |
| ... | ... | @@ -564,6 +622,29 @@ int remote::wait_for_ready(int seconds) |
| 564 | 622 | |
| 565 | 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 | 648 | #endif |
| 568 | 649 | |
| 569 | 650 | return -1; |
| ... | ... | @@ -598,6 +679,19 @@ char * remote::get_text_at(int row, int col, size_t sz) |
| 598 | 679 | |
| 599 | 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 | 695 | #endif |
| 602 | 696 | |
| 603 | 697 | return NULL; |
| ... | ... | @@ -629,6 +723,16 @@ int remote::cmp_text_at(int row, int col, const char *text) |
| 629 | 723 | |
| 630 | 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 | 736 | #endif |
| 633 | 737 | |
| 634 | 738 | return 0; |
| ... | ... | @@ -659,6 +763,16 @@ int remote::set_text_at(int row, int col, const char *str) |
| 659 | 763 | |
| 660 | 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 | 776 | #endif |
| 663 | 777 | |
| 664 | 778 | return -1; |
| ... | ... | @@ -670,11 +784,21 @@ int remote::set_cursor_position(int row, int col) |
| 670 | 784 | |
| 671 | 785 | if(hPipe != INVALID_HANDLE_VALUE) |
| 672 | 786 | { |
| 673 | - | |
| 787 | + #warning Implementar | |
| 674 | 788 | } |
| 675 | 789 | |
| 676 | 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 | 802 | #endif |
| 679 | 803 | |
| 680 | 804 | return -1; |
| ... | ... | @@ -722,6 +846,15 @@ int remote::pfkey(int key) |
| 722 | 846 | |
| 723 | 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 | 858 | #endif |
| 726 | 859 | |
| 727 | 860 | return -1; |
| ... | ... | @@ -742,6 +875,15 @@ int remote::pakey(int key) |
| 742 | 875 | |
| 743 | 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 | 887 | #endif |
| 746 | 888 | |
| 747 | 889 | return -1; |
| ... | ... | @@ -758,6 +900,17 @@ void remote::set_toggle(LIB3270_TOGGLE ix, bool value) |
| 758 | 900 | |
| 759 | 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 | 914 | #endif |
| 762 | 915 | |
| 763 | 916 | } | ... | ... |
src/plugins/rx3270/rx3270.h
| ... | ... | @@ -56,6 +56,13 @@ |
| 56 | 56 | #include <iconv.h> |
| 57 | 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 | 66 | /*---[ Rexx entry points ]-----------------------------------------------------------------------------------*/ |
| 60 | 67 | |
| 61 | 68 | REXX_TYPED_ROUTINE_PROTOTYPE(rx3270version); |
| ... | ... | @@ -119,7 +126,8 @@ |
| 119 | 126 | |
| 120 | 127 | public: |
| 121 | 128 | |
| 122 | - rx3270(); | |
| 129 | + rx3270(const char *local = REXX_DEFAULT_CHARSET, const char *remote = "ISO-8859-1"); | |
| 130 | + | |
| 123 | 131 | virtual ~rx3270(); |
| 124 | 132 | |
| 125 | 133 | static rx3270 * create(const char *name = NULL); | ... | ... |
src/plugins/rx3270/sample/remote.rex
| ... | ... | @@ -4,7 +4,15 @@ use arg uri |
| 4 | 4 | host = .rx3270~new("pw3270:a") |
| 5 | 5 | |
| 6 | 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 | 17 | return 0 |
| 10 | 18 | ... | ... |