Commit fc25275fa30ef776634b21cd6fb8b49227945237

Authored by perry.werneck@gmail.com
1 parent d118d990

Extendendo tratamento de charset para a classe base para implementação de extens…

…ões, incluindo novos métodos no plugin rexx
android/jni/misc.cpp
... ... @@ -42,7 +42,7 @@ JNIEXPORT jstring JNICALL Java_br_com_bb_pw3270_lib3270_getRevision(JNIEnv *env,
42 42  
43 43 JNIEXPORT jstring JNICALL Java_br_com_bb_pw3270_lib3270_getEncoding(JNIEnv *env, jobject obj)
44 44 {
45   - return env->NewStringUTF(lib3270_get_charset(lib3270_get_default_session_handle()));
  45 + return env->NewStringUTF(lib3270_get_display_charset(lib3270_get_default_session_handle()));
46 46 }
47 47  
48 48 JNIEXPORT void JNICALL Java_br_com_bb_pw3270_lib3270_setToggle(JNIEnv *env, jobject obj, jstring name, jboolean state)
... ...
pw3270.cbp
... ... @@ -71,6 +71,7 @@
71 71 <Unit filename="src/include/lib3270.h" />
72 72 <Unit filename="src/include/lib3270/action_table.h" />
73 73 <Unit filename="src/include/lib3270/actions.h" />
  74 + <Unit filename="src/include/lib3270/charset.h" />
74 75 <Unit filename="src/include/lib3270/config.h.in" />
75 76 <Unit filename="src/include/lib3270/filetransfer.h" />
76 77 <Unit filename="src/include/lib3270/html.h" />
... ... @@ -298,6 +299,7 @@
298 299 <Unit filename="src/plugins/rx3270/rx3270.cls" />
299 300 <Unit filename="src/plugins/rx3270/rx3270.h" />
300 301 <Unit filename="src/plugins/rx3270/rxapimain.cc" />
  302 + <Unit filename="src/plugins/rx3270/sample/charset.rex" />
301 303 <Unit filename="src/plugins/rx3270/sample/clipboard.rex" />
302 304 <Unit filename="src/plugins/rx3270/sample/object.rex" />
303 305 <Unit filename="src/plugins/rx3270/sample/remote.rex" />
... ...
src/classlib/local.cc
... ... @@ -302,7 +302,9 @@
302 302 int (*_get_next_unprotected)(H3270 *hSession, int baddr0);
303 303 void (*_popup_va)(H3270 *session, LIB3270_NOTIFY id , const char *title, const char *message, const char *fmt, va_list);
304 304 void * (*_free)(void *);
305   - const char * (*_get_charset)(H3270 *hSession);
  305 + const char * (*_get_display_charset)(H3270 *hSession);
  306 + int (*_set_host_charset)(H3270 *hSession, const char *name);
  307 + const char * (*_get_host_charset)(H3270 *hSession);
306 308  
307 309 public:
308 310  
... ... @@ -349,7 +351,9 @@
349 351 { (void **) & _get_next_unprotected, "lib3270_get_next_unprotected" },
350 352 { (void **) & _popup_va, "lib3270_popup_va" },
351 353 { (void **) & _free, "lib3270_free" },
352   - { (void **) & _get_charset, "lib3270_get_charset" },
  354 + { (void **) & _get_display_charset, "lib3270_get_display_charset" },
  355 + { (void **) & _set_host_charset, "lib3270_set_host_charset" },
  356 + { (void **) & _get_host_charset, "lib3270_get_host_charset" },
353 357  
354 358 };
355 359  
... ... @@ -371,7 +375,7 @@
371 375 set_trace_handler(tracehandler);
372 376 this->hSession = lib3270_new("");
373 377  
374   - set_charset();
  378 + set_display_charset();
375 379  
376 380 }
377 381  
... ... @@ -542,9 +546,19 @@
542 546 return 0;
543 547 }
544 548  
545   - const char * get_charset(void)
  549 + string * get_display_charset(void)
546 550 {
547   - return _get_charset(hSession);
  551 + return new string(_get_display_charset(hSession));
  552 + }
  553 +
  554 + int set_host_charset(const char *charset)
  555 + {
  556 + return _set_host_charset(hSession,charset);
  557 + }
  558 +
  559 + string * get_host_charset(void)
  560 + {
  561 + return new string(_get_host_charset(hSession));
548 562 }
549 563  
550 564 };
... ...
src/classlib/remote.cc
... ... @@ -997,6 +997,21 @@
997 997 return query_intval("setClipboard", DBUS_TYPE_STRING, &text, DBUS_TYPE_INVALID);
998 998 }
999 999  
  1000 + int set_host_charset(const char *charset)
  1001 + {
  1002 + return query_intval("setHostCharset", DBUS_TYPE_STRING, &charset, DBUS_TYPE_INVALID);
  1003 + }
  1004 +
  1005 + string * get_host_charset(void)
  1006 + {
  1007 + return query_string("getHostCharset");
  1008 + }
  1009 +
  1010 + string * get_display_charset(void)
  1011 + {
  1012 + return query_string("getDisplayCharset");
  1013 + }
  1014 +
1000 1015 int popup_dialog(LIB3270_NOTIFY id , const char *title, const char *message, const char *fmt, ...)
1001 1016 {
1002 1017 DBusMessage * msg = dbus_message_new_method_call( this->dest, // Destination
... ...
src/classlib/session.cc
... ... @@ -121,9 +121,10 @@
121 121 }
122 122  
123 123 // Object settings
124   - void session::set_charset(const char *remote, const char *local)
  124 + void session::set_display_charset(const char *remote, const char *local)
125 125 {
126 126 #ifdef HAVE_ICONV
  127 + string *display_charset = this->get_display_charset();
127 128  
128 129 if(this->conv2Local != (iconv_t) (-1))
129 130 iconv_close(this->conv2Local);
... ... @@ -132,7 +133,7 @@
132 133 iconv_close(this->conv2Host);
133 134  
134 135 if(!remote)
135   - remote = this->get_charset();
  136 + remote = display_charset->c_str();
136 137  
137 138 if(strcmp(local,remote))
138 139 {
... ... @@ -144,22 +145,24 @@
144 145 {
145 146 conv2Local = conv2Host = (iconv_t)(-1);
146 147 }
  148 +
  149 + delete display_charset;
147 150 #endif
148 151  
149 152 }
150 153  
151   - const char * session::get_charset(void)
  154 + string * session::get_display_charset(void)
152 155 {
153   - return "ISO-8859-1";
  156 + return new string("ISO-8859-1");
154 157 }
155 158  
156 159 // 3270 methods
157   - string session::get_version(void)
  160 + const string session::get_version(void)
158 161 {
159 162 return string(PACKAGE_VERSION);
160 163 }
161 164  
162   - string session::get_revision(void)
  165 + const string session::get_revision(void)
163 166 {
164 167 return string(PACKAGE_REVISION);
165 168 }
... ...
src/classlib/testprogram.cc
... ... @@ -37,7 +37,8 @@
37 37  
38 38 int main(int numpar, char *param[])
39 39 {
40   - session *session = session::start();
  40 + string *s;
  41 + session *session = session::start("pw3270:a");
41 42  
42 43 cout << "pw3270 version: " << session->get_version() << endl;
43 44 cout << "pw3270 revision: " << session->get_revision() << endl << endl;
... ... @@ -47,8 +48,15 @@
47 48 else
48 49 cout << "\tDisconnected" << endl;
49 50  
50   - cout << "\tSession state: " << session->get_cstate() << endl;
51   - cout << "\tCharset: " << session->get_charset() << endl;
  51 + cout << "\tSession state: " << session->get_cstate() << endl;
  52 +
  53 + s = session->get_display_charset();
  54 + cout << "\tDisplay charset: " << s->c_str() << endl;
  55 + delete s;
  56 +
  57 + s = session->get_host_charset();
  58 + cout << "\tHost charset: " << s->c_str() << endl;
  59 + delete s;
52 60  
53 61 delete session;
54 62 return 0;
... ...
src/include/lib3270.h
... ... @@ -788,7 +788,9 @@
788 788 * @return String with current encoding.
789 789 *
790 790 */
791   - LIB3270_EXPORT const char * lib3270_get_charset(H3270 *session);
  791 + LIB3270_EXPORT const char * lib3270_get_display_charset(H3270 *session);
  792 +
  793 + #define lib3270_get_charset(s) lib3270_get_display_charset(s)
792 794  
793 795 LIB3270_EXPORT const char * lib3270_get_default_charset(void);
794 796  
... ...
src/include/lib3270/charset.h
... ... @@ -56,7 +56,8 @@
56 56 BOTH
57 57 } lib3270_remap_scope;
58 58  
59   - LIB3270_EXPORT int lib3270_set_host_charset(H3270 *hSession, const char *name);
60   - LIB3270_EXPORT void lib3270_remap(H3270 *hSession, unsigned short ebc, unsigned short iso, lib3270_remap_scope scope, unsigned char one_way);
  59 + LIB3270_EXPORT int lib3270_set_host_charset(H3270 *hSession, const char *name);
  60 + LIB3270_EXPORT const char * lib3270_get_host_charset(H3270 *hSession);
  61 + LIB3270_EXPORT void lib3270_remap(H3270 *hSession, unsigned short ebc, unsigned short iso, lib3270_remap_scope scope, unsigned char one_way);
61 62  
62 63 #endif // LIB3270_CHARSET_H_INCLUDED
... ...
src/include/pw3270/class.h
... ... @@ -101,28 +101,30 @@
101 101 static session * get_default(void);
102 102 static void set_plugin(session * (*factory)(const char *name));
103 103  
104   -#ifdef WIN32
105   - void set_charset(const char *remote = 0, const char *local = "CP1252");
106   -#else
107   - void set_charset(const char *remote = 0, const char *local = "UTF-8");
108   -#endif // WIN32
109   -
110   -
111   -
112 104 // Log management
113 105 void log(const char *fmt, ...);
114 106 void logva(const char *fmt, va_list args);
115 107  
116 108 // Information
117   - virtual string get_version(void);
118   - virtual string get_revision(void);
119   - virtual const char * get_charset(void);
  109 + virtual const string get_version(void);
  110 + virtual const string get_revision(void);
120 111  
121 112 virtual bool is_connected(void) = 0;
122 113 virtual bool is_ready(void) = 0;
123 114  
124 115 virtual LIB3270_CSTATE get_cstate(void) = 0;
125 116  
  117 + // charset
  118 +#ifdef WIN32
  119 + void set_display_charset(const char *remote = 0, const char *local = "CP1252");
  120 +#else
  121 + void set_display_charset(const char *remote = 0, const char *local = "UTF-8");
  122 +#endif // WIN32
  123 +
  124 + virtual int set_host_charset(const char *charset) = 0;
  125 + virtual string * get_host_charset(void) = 0;
  126 + virtual string * get_display_charset(void);
  127 +
126 128 // Connection & Network
127 129 virtual int connect(const char *uri, bool wait = true) = 0;
128 130 virtual int disconnect(void) = 0;
... ...
src/lib3270/charset.c
... ... @@ -300,12 +300,18 @@ LIB3270_EXPORT const char * lib3270_get_default_charset(void)
300 300 return "ISO-8859-1";
301 301 }
302 302  
303   -LIB3270_EXPORT const char * lib3270_get_charset(H3270 *hSession)
  303 +LIB3270_EXPORT const char * lib3270_get_display_charset(H3270 *hSession)
304 304 {
305 305 CHECK_SESSION_HANDLE(hSession);
306 306 return hSession->charset.display ? hSession->charset.display : "ISO-8859-1";
307 307 }
308 308  
  309 +LIB3270_EXPORT const char * lib3270_get_host_charset(H3270 *hSession)
  310 +{
  311 + CHECK_SESSION_HANDLE(hSession);
  312 + return hSession->charset.host;
  313 +}
  314 +
309 315 LIB3270_ACTION( charsettable )
310 316 {
311 317 static const char * hChars = "0123456789ABCDEF";
... ...
src/lib3270/html.c
... ... @@ -244,7 +244,7 @@
244 244  
245 245 if(option & LIB3270_HTML_OPTION_HEADERS)
246 246 {
247   - char *txt = xs_buffer(element_text[HTML_ELEMENT_HEADER],lib3270_get_charset(session),html_color[0]);
  247 + char *txt = xs_buffer(element_text[HTML_ELEMENT_HEADER],lib3270_get_display_charset(session),html_color[0]);
248 248 append_string(&info,txt);
249 249 lib3270_free(txt);
250 250 }
... ...
src/lib3270/macros.c
... ... @@ -88,7 +88,7 @@
88 88  
89 89 LIB3270_MACRO( encoding )
90 90 {
91   - return strdup(lib3270_get_charset(hSession));
  91 + return strdup(lib3270_get_display_charset(hSession));
92 92 }
93 93  
94 94 LIB3270_MACRO( get )
... ...
src/plugins/dbus3270/gobject.c
... ... @@ -44,6 +44,7 @@
44 44 #include <pw3270.h>
45 45 #include <pw3270/v3270.h>
46 46 #include <lib3270/actions.h>
  47 +#include <lib3270/charset.h>
47 48  
48 49 #include "service.h"
49 50  
... ... @@ -191,7 +192,7 @@ void pw3270_dbus_get_screen_contents(PW3270Dbus *object, DBusGMethodInvocation *
191 192  
192 193 text = lib3270_get_text(hSession,0,-1);
193 194  
194   - utftext = g_convert_with_fallback(text,-1,"UTF-8",lib3270_get_charset(hSession),"?",NULL,NULL,NULL);
  195 + utftext = g_convert_with_fallback(text,-1,"UTF-8",lib3270_get_display_charset(hSession),"?",NULL,NULL,NULL);
195 196  
196 197 lib3270_free(text);
197 198  
... ... @@ -218,7 +219,7 @@ void pw3270_dbus_set_text_at(PW3270Dbus *object, int row, int col, const gchar *
218 219 if(pw3270_dbus_check_valid_state(object,context))
219 220 return;
220 221  
221   - text = g_convert_with_fallback(utftext,-1,lib3270_get_charset(hSession),"UTF-8","?",NULL,NULL,NULL);
  222 + text = g_convert_with_fallback(utftext,-1,lib3270_get_display_charset(hSession),"UTF-8","?",NULL,NULL,NULL);
222 223  
223 224 dbus_g_method_return(context,lib3270_set_string_at(hSession,row,col,(const unsigned char *) text));
224 225  
... ... @@ -234,7 +235,7 @@ void pw3270_dbus_input(PW3270Dbus *object, const gchar *utftext, DBusGMethodInvo
234 235 if(pw3270_dbus_check_valid_state(object,context))
235 236 return;
236 237  
237   - text = g_convert_with_fallback(utftext,-1,lib3270_get_charset(hSession),"UTF-8","?",NULL,NULL,NULL);
  238 + text = g_convert_with_fallback(utftext,-1,lib3270_get_display_charset(hSession),"UTF-8","?",NULL,NULL,NULL);
238 239  
239 240 dbus_g_method_return(context,lib3270_emulate_input(hSession,(const char *) text,-1,1));
240 241  
... ... @@ -260,7 +261,7 @@ void pw3270_dbus_get_text_at(PW3270Dbus *object, int row, int col, int len, DBus
260 261 }
261 262 else
262 263 {
263   - gchar * utftext = g_convert_with_fallback(text,-1,"UTF-8",lib3270_get_charset(hSession),"?",NULL,NULL,NULL);
  264 + gchar * utftext = g_convert_with_fallback(text,-1,"UTF-8",lib3270_get_display_charset(hSession),"?",NULL,NULL,NULL);
264 265  
265 266 lib3270_free(text);
266 267  
... ... @@ -288,7 +289,7 @@ void pw3270_dbus_get_text_at(PW3270Dbus *object, int row, int col, int len, DBus
288 289 }
289 290 else
290 291 {
291   - gchar * utftext = g_convert_with_fallback(text,-1,"UTF-8",lib3270_get_charset(hSession),"?",NULL,NULL,NULL);
  292 + gchar * utftext = g_convert_with_fallback(text,-1,"UTF-8",lib3270_get_display_charset(hSession),"?",NULL,NULL,NULL);
292 293  
293 294 lib3270_free(text);
294 295  
... ... @@ -356,7 +357,7 @@ void pw3270_dbus_cmp_text_at(PW3270Dbus *object, int row, int col, const gchar *
356 357 if(pw3270_dbus_check_valid_state(object,context))
357 358 return;
358 359  
359   - text = g_convert_with_fallback(utftext,-1,lib3270_get_charset(hSession),"UTF-8","?",NULL,NULL,NULL);
  360 + text = g_convert_with_fallback(utftext,-1,lib3270_get_display_charset(hSession),"UTF-8","?",NULL,NULL,NULL);
360 361  
361 362 dbus_g_method_return(context,lib3270_cmp_text_at(hSession,row,col,text));
362 363  
... ... @@ -452,3 +453,18 @@ void pw3270_dbus_show_popup(PW3270Dbus *object, int id, const gchar *title, cons
452 453 lib3270_popup_dialog(pw3270_dbus_get_session_handle(object), (LIB3270_NOTIFY) id , title, msg, "%s", text);
453 454 dbus_g_method_return(context,0);
454 455 }
  456 +
  457 +void pw3270_dbus_get_host_charset(PW3270Dbus *object, DBusGMethodInvocation *context)
  458 +{
  459 + dbus_g_method_return(context,lib3270_get_host_charset(pw3270_dbus_get_session_handle(object)));
  460 +}
  461 +
  462 +void pw3270_dbus_get_display_charset(PW3270Dbus *object, DBusGMethodInvocation *context)
  463 +{
  464 + dbus_g_method_return(context,lib3270_get_display_charset(pw3270_dbus_get_session_handle(object)));
  465 +}
  466 +
  467 +void pw3270_dbus_set_host_charset(PW3270Dbus *object, const gchar *charset, DBusGMethodInvocation *context)
  468 +{
  469 + dbus_g_method_return(context,lib3270_set_host_charset(pw3270_dbus_get_session_handle(object),charset));
  470 +}
... ...
src/plugins/dbus3270/pw3270dbus.xml
... ... @@ -149,6 +149,20 @@
149 149 <arg type="s" name="msg" direction="in" />
150 150 <arg type="s" name="text" direction="in" />
151 151 </method>
  152 + <method name="getHostCharset">
  153 + <annotation name="org.freedesktop.DBus.GLib.Async" value="true"/>
  154 + <arg type="s" name="charset" direction="out" />
  155 + </method>
  156 + <method name="getDisplayCharset">
  157 + <annotation name="org.freedesktop.DBus.GLib.Async" value="true"/>
  158 + <arg type="s" name="charset" direction="out" />
  159 + </method>
  160 + <method name="setHostCharset">
  161 + <annotation name="org.freedesktop.DBus.GLib.Async" value="true"/>
  162 + <arg type="s" name="charset" direction="in" />
  163 + <arg type="i" name="result" direction="out" />
  164 + </method>
  165 +
152 166 </interface>
153 167  
154 168 </node>
... ...
src/plugins/dbus3270/service.h
... ... @@ -106,6 +106,10 @@
106 106 void pw3270_dbus_set_clipboard(PW3270Dbus *object, const gchar *text, DBusGMethodInvocation *context);
107 107 void pw3270_dbus_get_clipboard(PW3270Dbus *object, DBusGMethodInvocation *context);
108 108  
  109 + void pw3270_dbus_get_display_charset(PW3270Dbus *object, DBusGMethodInvocation *context);
  110 + void pw3270_dbus_get_host_charset(PW3270Dbus *object, DBusGMethodInvocation *context);
  111 + void pw3270_dbus_set_host_charset(PW3270Dbus *object, const gchar *charset, DBusGMethodInvocation *context);
  112 +
109 113 G_END_DECLS
110 114  
111 115 #endif // _PW3270_DBUS_SERVICE_H
... ...
src/plugins/dbus3270/test.sh
... ... @@ -45,6 +45,15 @@ run_command()
45 45 dbus-send --session --print-reply --dest=$DEST.$SESSION $BPATH $DEST.isConnected
46 46 ;;
47 47  
  48 + hostcharset)
  49 + dbus-send --session --print-reply --dest=$DEST.$SESSION $BPATH $DEST.getHostCharset
  50 + ;;
  51 +
  52 + displaycharset)
  53 + dbus-send --session --print-reply --dest=$DEST.$SESSION $BPATH $DEST.getDisplayCharset
  54 + ;;
  55 +
  56 +
48 57 *)
49 58 echo "Comando $1 desconhecido"
50 59 ;;
... ...
src/plugins/rx3270/pluginmain.cc
... ... @@ -49,6 +49,7 @@
49 49 #include <lib3270/actions.h>
50 50 #include <lib3270/log.h>
51 51 #include <lib3270/trace.h>
  52 + #include <lib3270/charset.h>
52 53 #include <pw3270/class.h>
53 54  
54 55 /*--[ Globals ]--------------------------------------------------------------------------------------*/
... ... @@ -84,7 +85,7 @@
84 85  
85 86 void free(void *ptr);
86 87  
87   - string get_version(void);
  88 + const string get_version(void);
88 89 LIB3270_CSTATE get_cstate(void);
89 90 int disconnect(void);
90 91 int connect(const char *uri, bool wait = true);
... ... @@ -126,6 +127,10 @@
126 127 int popup_dialog(LIB3270_NOTIFY id , const char *title, const char *message, const char *fmt, ...);
127 128 string * file_chooser_dialog(GtkFileChooserAction action, const char *title, const char *extension, const char *filename);
128 129  
  130 + int set_host_charset(const char *charset);
  131 + string * get_host_charset(void);
  132 + string * get_display_charset(void);
  133 +
129 134 int quit(void);
130 135  
131 136 protected:
... ... @@ -502,7 +507,7 @@ extern &quot;C&quot;
502 507 }
503 508  
504 509  
505   - string plugin::get_version(void)
  510 + const string plugin::get_version(void)
506 511 {
507 512 return string(lib3270_get_version());
508 513 }
... ... @@ -723,3 +728,18 @@ int plugin::quit(void)
723 728 gtk_main_quit();
724 729 return 0;
725 730 }
  731 +
  732 +int plugin::set_host_charset(const char *charset)
  733 +{
  734 + return lib3270_set_host_charset(hSession,charset);
  735 +}
  736 +
  737 +string * plugin::get_host_charset(void)
  738 +{
  739 + return new string(lib3270_get_host_charset(hSession));
  740 +}
  741 +
  742 +string * plugin::get_display_charset(void)
  743 +{
  744 + return new string(lib3270_get_display_charset(hSession));
  745 +}
... ...
src/plugins/rx3270/rexx_methods.cc
... ... @@ -578,3 +578,24 @@ RexxMethod5(RexxStringObject, rx3270_method_get_filename, CSELF, sessionPtr, CST
578 578 return context->String("");
579 579 }
580 580  
  581 +RexxMethod2(int, rx3270_method_set_host_charset, CSELF, sessionPtr, CSTRING, text)
  582 +{
  583 + return ((session *) sessionPtr)->set_host_charset(text);
  584 +}
  585 +
  586 +RexxMethod1(RexxStringObject, rx3270_method_get_host_charset, CSELF, sessionPtr)
  587 +{
  588 + string * ret = ((session *) sessionPtr)->get_host_charset();
  589 + RexxStringObject obj = context->String(ret->c_str());
  590 + delete ret;
  591 + return obj;
  592 +}
  593 +
  594 +RexxMethod1(RexxStringObject, rx3270_method_get_display_charset, CSELF, sessionPtr)
  595 +{
  596 + string * ret = ((session *) sessionPtr)->get_display_charset();
  597 + RexxStringObject obj = context->String(ret->c_str());
  598 + delete ret;
  599 + return obj;
  600 +}
  601 +
... ...
src/plugins/rx3270/rx3270.cls
... ... @@ -87,6 +87,10 @@
87 87 ::METHOD POPUP EXTERNAL "LIBRARY rx3270 rx3270_method_popup"
88 88 ::METHOD GETFILENAME EXTERNAL "LIBRARY rx3270 rx3270_method_get_filename"
89 89  
  90 +::METHOD GETDISPLAYCHARSET EXTERNAL "LIBRARY rx3270 rx3270_method_get_display_charset"
  91 +::METHOD GETHOSTCHARSET EXTERNAL "LIBRARY rx3270 rx3270_method_get_host_charset"
  92 +::METHOD SETHOSTCHARSET EXTERNAL "LIBRARY rx3270 rx3270_method_set_host_charset"
  93 +
90 94 ::method waitForStringAt
91 95 use arg row, col, key, timeout
92 96 if datatype(timeout) <> "NUM"
... ...
src/plugins/rx3270/rx3270.h
... ... @@ -124,6 +124,9 @@
124 124 REXX_METHOD_PROTOTYPE(rx3270_method_get_cursor_addr);
125 125 REXX_METHOD_PROTOTYPE(rx3270_method_set_cursor_addr);
126 126 REXX_METHOD_PROTOTYPE(rx3270_method_input_text);
  127 + REXX_METHOD_PROTOTYPE(rx3270_method_get_display_charset);
  128 + REXX_METHOD_PROTOTYPE(rx3270_method_get_host_charset);
  129 + REXX_METHOD_PROTOTYPE(rx3270_method_set_host_charset);
127 130  
128 131 /*---[ Globals ]---------------------------------------------------------------------------------------------*/
129 132  
... ...
src/plugins/rx3270/rxapimain.cc
... ... @@ -164,6 +164,10 @@ RexxMethodEntry rx3270_methods[] =
164 164 REXX_METHOD(rx3270_method_set_cursor_addr, rx3270_method_set_cursor_addr ),
165 165 REXX_METHOD(rx3270_method_input_text, rx3270_method_input_text ),
166 166  
  167 + REXX_METHOD(rx3270_method_get_display_charset, rx3270_method_get_display_charset ),
  168 + REXX_METHOD(rx3270_method_get_host_charset, rx3270_method_get_host_charset ),
  169 + REXX_METHOD(rx3270_method_set_host_charset, rx3270_method_set_host_charset ),
  170 +
167 171 REXX_LAST_METHOD()
168 172 };
169 173  
... ...
src/plugins/rx3270/sample/charset.rex 0 → 100644
... ... @@ -0,0 +1,12 @@
  1 +/*
  2 + * Sample rexx code to get host charset
  3 + */
  4 +
  5 + host = .rx3270~new("")
  6 +
  7 + say "Display charset: "||host~getDisplayCharset()
  8 + say "Host charset: "||host~getHostCharset()
  9 +
  10 + return 0
  11 +
  12 +::requires "rx3270.cls"
... ...
src/pw3270/actions.c
... ... @@ -219,7 +219,7 @@ static void copy_as_html_action(GtkAction *action, GtkWidget *widget)
219 219 trace_action(action,widget);
220 220  
221 221 text = lib3270_get_as_html(session,LIB3270_HTML_OPTION_ALL|LIB3270_HTML_OPTION_FORM);
222   - utf = g_convert(text, -1, "UTF-8", lib3270_get_charset(session), NULL, NULL, NULL);
  222 + utf = g_convert(text, -1, "UTF-8", lib3270_get_display_charset(session), NULL, NULL, NULL);
223 223 lib3270_free(text);
224 224  
225 225 gtk_clipboard_set_text(clipboard,utf,-1);
... ...
src/pw3270/main.c
... ... @@ -308,7 +308,7 @@ static void g_trace(H3270 *hSession, const char *fmt, va_list args)
308 308 else
309 309 {
310 310 // No trace file, open standard window
311   - gchar * utftext = g_convert_with_fallback(ptr,-1,"UTF-8",lib3270_get_charset(hSession),"?",NULL,NULL,NULL);
  311 + gchar * utftext = g_convert_with_fallback(ptr,-1,"UTF-8",lib3270_get_display_charset(hSession),"?",NULL,NULL,NULL);
312 312  
313 313 if(!trace_window)
314 314 {
... ...
src/pw3270/v3270/accessible.c
... ... @@ -195,7 +195,7 @@ static gunichar v3270_accessible_get_character_at_offset(AtkText *atk_text, gint
195 195 gchar * utfstring = g_convert_with_fallback( text,
196 196 -1,
197 197 "UTF-8",
198   - lib3270_get_charset(host),
  198 + lib3270_get_display_charset(host),
199 199 " ",
200 200 NULL,
201 201 &bytes_written,
... ... @@ -390,7 +390,7 @@ static gchar * v3270_accessible_get_text_at_offset(AtkText *atk_text, gint offse
390 390 gchar * utfchar = g_convert_with_fallback( text,
391 391 -1,
392 392 "UTF-8",
393   - lib3270_get_charset(host),
  393 + lib3270_get_display_charset(host),
394 394 " ",
395 395 NULL,
396 396 &bytes_written,
... ... @@ -433,7 +433,7 @@ static gchar * v3270_accessible_get_text(AtkText *atk_text, gint start_pos, gint
433 433 gsize bytes_written;
434 434 GError * error = NULL;
435 435  
436   - utftext = g_convert_with_fallback(text,-1,"UTF-8",lib3270_get_charset(host)," ",NULL,&bytes_written, &error);
  436 + utftext = g_convert_with_fallback(text,-1,"UTF-8",lib3270_get_display_charset(host)," ",NULL,&bytes_written, &error);
437 437  
438 438 if(error)
439 439 {
... ...
src/pw3270/v3270/draw.c
... ... @@ -275,7 +275,7 @@ void v3270_draw_char(cairo_t *cr, unsigned char chr, unsigned short attr, H3270
275 275 }
276 276 else if(chr)
277 277 {
278   - gchar *utf = g_convert((char *) &chr, 1, "UTF-8", lib3270_get_charset(session), NULL, NULL, NULL);
  278 + gchar *utf = g_convert((char *) &chr, 1, "UTF-8", lib3270_get_display_charset(session), NULL, NULL, NULL);
279 279  
280 280 if(utf)
281 281 {
... ...
src/pw3270/v3270/keyboard.c
... ... @@ -247,7 +247,7 @@
247 247  
248 248 host = GTK_V3270(widget)->host;
249 249  
250   - utf = g_convert((char *) str, -1, lib3270_get_charset(host), "UTF-8", NULL, NULL, NULL);
  250 + utf = g_convert((char *) str, -1, lib3270_get_display_charset(host), "UTF-8", NULL, NULL, NULL);
251 251  
252 252 if(utf)
253 253 {
... ... @@ -259,7 +259,7 @@
259 259  
260 260 void v3270_key_commit(GtkIMContext *imcontext, gchar *str, v3270 *widget)
261 261 {
262   - gchar *utf = g_convert((char *) str, -1, lib3270_get_charset(widget->host), "UTF-8", NULL, NULL, NULL);
  262 + gchar *utf = g_convert((char *) str, -1, lib3270_get_display_charset(widget->host), "UTF-8", NULL, NULL, NULL);
263 263  
264 264 if(utf)
265 265 {
... ...
src/pw3270/v3270/selection.c
... ... @@ -70,7 +70,7 @@ static void clipboard_get(GtkClipboard *clipboard, GtkSelectionData *selection,
70 70 }
71 71 else
72 72 {
73   - gchar * text = g_convert(widget->selection.text, -1, "UTF-8", lib3270_get_charset(widget->host), NULL, NULL, NULL);
  73 + gchar * text = g_convert(widget->selection.text, -1, "UTF-8", lib3270_get_display_charset(widget->host), NULL, NULL, NULL);
74 74 gtk_selection_data_set_text(selection,text,-1);
75 75 g_free(text);
76 76 }
... ... @@ -104,7 +104,7 @@ gchar * v3270_get_text(GtkWidget *widget, int offset, int len)
104 104 if(!str)
105 105 return NULL;
106 106  
107   - text = g_convert(str, -1, "UTF-8", lib3270_get_charset(terminal->host), NULL, NULL, NULL);
  107 + text = g_convert(str, -1, "UTF-8", lib3270_get_display_charset(terminal->host), NULL, NULL, NULL);
108 108  
109 109 lib3270_free(str);
110 110 return text;
... ... @@ -226,7 +226,7 @@ gchar * v3270_get_selected(GtkWidget *widget, gboolean cut)
226 226 text = update_selected_text(widget,cut);
227 227  
228 228 if(text)
229   - return g_convert(text, -1, "UTF-8", lib3270_get_charset(GTK_V3270(widget)->host), NULL, NULL, NULL);
  229 + return g_convert(text, -1, "UTF-8", lib3270_get_display_charset(GTK_V3270(widget)->host), NULL, NULL, NULL);
230 230  
231 231 return NULL;
232 232 }
... ... @@ -242,7 +242,7 @@ gchar * v3270_get_copy(GtkWidget *widget)
242 242 text = update_selected_text(widget,FALSE);
243 243  
244 244 if(text)
245   - return g_convert(text, -1, "UTF-8", lib3270_get_charset(GTK_V3270(widget)->host), NULL, NULL, NULL);
  245 + return g_convert(text, -1, "UTF-8", lib3270_get_display_charset(GTK_V3270(widget)->host), NULL, NULL, NULL);
246 246  
247 247 return NULL;
248 248 }
... ... @@ -266,7 +266,7 @@ void v3270_set_copy(GtkWidget *widget, const gchar *text)
266 266  
267 267 /* Received text, replace the selection buffer */
268 268 terminal->table = 0;
269   - isotext = g_convert(text, -1, lib3270_get_charset(terminal->host), "UTF-8", NULL, NULL, NULL);
  269 + isotext = g_convert(text, -1, lib3270_get_display_charset(terminal->host), "UTF-8", NULL, NULL, NULL);
270 270  
271 271 if(!isotext)
272 272 {
... ... @@ -350,7 +350,7 @@ void v3270_paste_string(GtkWidget *widget, const gchar *text, const gchar *encod
350 350 {
351 351 gchar * buffer = NULL;
352 352 H3270 * session = v3270_get_session(widget);
353   - const gchar * charset = lib3270_get_charset(session);
  353 + const gchar * charset = lib3270_get_display_charset(session);
354 354 gboolean next;
355 355  
356 356 if(!text)
... ... @@ -504,7 +504,7 @@ gchar * v3270_get_region(GtkWidget *widget, gint start_pos, gint end_pos, gboole
504 504 if(!str)
505 505 return NULL;
506 506  
507   - utftext = g_convert(str, -1, "UTF-8", lib3270_get_charset(GTK_V3270(widget)->host), NULL, NULL, NULL);
  507 + utftext = g_convert(str, -1, "UTF-8", lib3270_get_display_charset(GTK_V3270(widget)->host), NULL, NULL, NULL);
508 508  
509 509 lib3270_free(str);
510 510  
... ...
src/pw3270/v3270/widget.c
... ... @@ -765,7 +765,7 @@ static void changed(H3270 *session, int offset, int len)
765 765 gchar * utfchar = g_convert_with_fallback( text,
766 766 -1,
767 767 "UTF-8",
768   - lib3270_get_charset(session),
  768 + lib3270_get_display_charset(session),
769 769 " ",
770 770 NULL,
771 771 &bytes_written,
... ...