From fc25275fa30ef776634b21cd6fb8b49227945237 Mon Sep 17 00:00:00 2001 From: perry.werneck@gmail.com Date: Wed, 28 Aug 2013 13:17:11 +0000 Subject: [PATCH] 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 | 2 +- pw3270.cbp | 2 ++ src/classlib/local.cc | 24 +++++++++++++++++++----- src/classlib/remote.cc | 15 +++++++++++++++ src/classlib/session.cc | 15 +++++++++------ src/classlib/testprogram.cc | 14 +++++++++++--- src/include/lib3270.h | 4 +++- src/include/lib3270/charset.h | 5 +++-- src/include/pw3270/class.h | 24 +++++++++++++----------- src/lib3270/charset.c | 8 +++++++- src/lib3270/html.c | 2 +- src/lib3270/macros.c | 2 +- src/plugins/dbus3270/gobject.c | 28 ++++++++++++++++++++++------ src/plugins/dbus3270/pw3270dbus.xml | 14 ++++++++++++++ src/plugins/dbus3270/service.h | 4 ++++ src/plugins/dbus3270/test.sh | 9 +++++++++ src/plugins/rx3270/pluginmain.cc | 24 ++++++++++++++++++++++-- src/plugins/rx3270/rexx_methods.cc | 21 +++++++++++++++++++++ src/plugins/rx3270/rx3270.cls | 4 ++++ src/plugins/rx3270/rx3270.h | 3 +++ src/plugins/rx3270/rxapimain.cc | 4 ++++ src/plugins/rx3270/sample/charset.rex | 12 ++++++++++++ src/pw3270/actions.c | 2 +- src/pw3270/main.c | 2 +- src/pw3270/v3270/accessible.c | 6 +++--- src/pw3270/v3270/draw.c | 2 +- src/pw3270/v3270/keyboard.c | 4 ++-- src/pw3270/v3270/selection.c | 14 +++++++------- src/pw3270/v3270/widget.c | 2 +- 29 files changed, 216 insertions(+), 56 deletions(-) create mode 100644 src/plugins/rx3270/sample/charset.rex diff --git a/android/jni/misc.cpp b/android/jni/misc.cpp index 22b9c49..d427fb4 100644 --- a/android/jni/misc.cpp +++ b/android/jni/misc.cpp @@ -42,7 +42,7 @@ JNIEXPORT jstring JNICALL Java_br_com_bb_pw3270_lib3270_getRevision(JNIEnv *env, JNIEXPORT jstring JNICALL Java_br_com_bb_pw3270_lib3270_getEncoding(JNIEnv *env, jobject obj) { - return env->NewStringUTF(lib3270_get_charset(lib3270_get_default_session_handle())); + return env->NewStringUTF(lib3270_get_display_charset(lib3270_get_default_session_handle())); } JNIEXPORT void JNICALL Java_br_com_bb_pw3270_lib3270_setToggle(JNIEnv *env, jobject obj, jstring name, jboolean state) diff --git a/pw3270.cbp b/pw3270.cbp index 8e46beb..0a9245d 100644 --- a/pw3270.cbp +++ b/pw3270.cbp @@ -71,6 +71,7 @@ + @@ -298,6 +299,7 @@ + diff --git a/src/classlib/local.cc b/src/classlib/local.cc index 53a5362..88e2848 100644 --- a/src/classlib/local.cc +++ b/src/classlib/local.cc @@ -302,7 +302,9 @@ int (*_get_next_unprotected)(H3270 *hSession, int baddr0); void (*_popup_va)(H3270 *session, LIB3270_NOTIFY id , const char *title, const char *message, const char *fmt, va_list); void * (*_free)(void *); - const char * (*_get_charset)(H3270 *hSession); + const char * (*_get_display_charset)(H3270 *hSession); + int (*_set_host_charset)(H3270 *hSession, const char *name); + const char * (*_get_host_charset)(H3270 *hSession); public: @@ -349,7 +351,9 @@ { (void **) & _get_next_unprotected, "lib3270_get_next_unprotected" }, { (void **) & _popup_va, "lib3270_popup_va" }, { (void **) & _free, "lib3270_free" }, - { (void **) & _get_charset, "lib3270_get_charset" }, + { (void **) & _get_display_charset, "lib3270_get_display_charset" }, + { (void **) & _set_host_charset, "lib3270_set_host_charset" }, + { (void **) & _get_host_charset, "lib3270_get_host_charset" }, }; @@ -371,7 +375,7 @@ set_trace_handler(tracehandler); this->hSession = lib3270_new(""); - set_charset(); + set_display_charset(); } @@ -542,9 +546,19 @@ return 0; } - const char * get_charset(void) + string * get_display_charset(void) { - return _get_charset(hSession); + return new string(_get_display_charset(hSession)); + } + + int set_host_charset(const char *charset) + { + return _set_host_charset(hSession,charset); + } + + string * get_host_charset(void) + { + return new string(_get_host_charset(hSession)); } }; diff --git a/src/classlib/remote.cc b/src/classlib/remote.cc index c8b9629..f68db2b 100644 --- a/src/classlib/remote.cc +++ b/src/classlib/remote.cc @@ -997,6 +997,21 @@ return query_intval("setClipboard", DBUS_TYPE_STRING, &text, DBUS_TYPE_INVALID); } + int set_host_charset(const char *charset) + { + return query_intval("setHostCharset", DBUS_TYPE_STRING, &charset, DBUS_TYPE_INVALID); + } + + string * get_host_charset(void) + { + return query_string("getHostCharset"); + } + + string * get_display_charset(void) + { + return query_string("getDisplayCharset"); + } + int popup_dialog(LIB3270_NOTIFY id , const char *title, const char *message, const char *fmt, ...) { DBusMessage * msg = dbus_message_new_method_call( this->dest, // Destination diff --git a/src/classlib/session.cc b/src/classlib/session.cc index f032b33..2c526e0 100644 --- a/src/classlib/session.cc +++ b/src/classlib/session.cc @@ -121,9 +121,10 @@ } // Object settings - void session::set_charset(const char *remote, const char *local) + void session::set_display_charset(const char *remote, const char *local) { #ifdef HAVE_ICONV + string *display_charset = this->get_display_charset(); if(this->conv2Local != (iconv_t) (-1)) iconv_close(this->conv2Local); @@ -132,7 +133,7 @@ iconv_close(this->conv2Host); if(!remote) - remote = this->get_charset(); + remote = display_charset->c_str(); if(strcmp(local,remote)) { @@ -144,22 +145,24 @@ { conv2Local = conv2Host = (iconv_t)(-1); } + + delete display_charset; #endif } - const char * session::get_charset(void) + string * session::get_display_charset(void) { - return "ISO-8859-1"; + return new string("ISO-8859-1"); } // 3270 methods - string session::get_version(void) + const string session::get_version(void) { return string(PACKAGE_VERSION); } - string session::get_revision(void) + const string session::get_revision(void) { return string(PACKAGE_REVISION); } diff --git a/src/classlib/testprogram.cc b/src/classlib/testprogram.cc index 5a2e498..a6b766a 100644 --- a/src/classlib/testprogram.cc +++ b/src/classlib/testprogram.cc @@ -37,7 +37,8 @@ int main(int numpar, char *param[]) { - session *session = session::start(); + string *s; + session *session = session::start("pw3270:a"); cout << "pw3270 version: " << session->get_version() << endl; cout << "pw3270 revision: " << session->get_revision() << endl << endl; @@ -47,8 +48,15 @@ else cout << "\tDisconnected" << endl; - cout << "\tSession state: " << session->get_cstate() << endl; - cout << "\tCharset: " << session->get_charset() << endl; + cout << "\tSession state: " << session->get_cstate() << endl; + + s = session->get_display_charset(); + cout << "\tDisplay charset: " << s->c_str() << endl; + delete s; + + s = session->get_host_charset(); + cout << "\tHost charset: " << s->c_str() << endl; + delete s; delete session; return 0; diff --git a/src/include/lib3270.h b/src/include/lib3270.h index fa26f2b..2e987a9 100644 --- a/src/include/lib3270.h +++ b/src/include/lib3270.h @@ -788,7 +788,9 @@ * @return String with current encoding. * */ - LIB3270_EXPORT const char * lib3270_get_charset(H3270 *session); + LIB3270_EXPORT const char * lib3270_get_display_charset(H3270 *session); + + #define lib3270_get_charset(s) lib3270_get_display_charset(s) LIB3270_EXPORT const char * lib3270_get_default_charset(void); diff --git a/src/include/lib3270/charset.h b/src/include/lib3270/charset.h index c605377..0ef4f42 100644 --- a/src/include/lib3270/charset.h +++ b/src/include/lib3270/charset.h @@ -56,7 +56,8 @@ BOTH } lib3270_remap_scope; - LIB3270_EXPORT int lib3270_set_host_charset(H3270 *hSession, const char *name); - LIB3270_EXPORT void lib3270_remap(H3270 *hSession, unsigned short ebc, unsigned short iso, lib3270_remap_scope scope, unsigned char one_way); + LIB3270_EXPORT int lib3270_set_host_charset(H3270 *hSession, const char *name); + LIB3270_EXPORT const char * lib3270_get_host_charset(H3270 *hSession); + LIB3270_EXPORT void lib3270_remap(H3270 *hSession, unsigned short ebc, unsigned short iso, lib3270_remap_scope scope, unsigned char one_way); #endif // LIB3270_CHARSET_H_INCLUDED diff --git a/src/include/pw3270/class.h b/src/include/pw3270/class.h index 85f4802..b2e27e7 100644 --- a/src/include/pw3270/class.h +++ b/src/include/pw3270/class.h @@ -101,28 +101,30 @@ static session * get_default(void); static void set_plugin(session * (*factory)(const char *name)); -#ifdef WIN32 - void set_charset(const char *remote = 0, const char *local = "CP1252"); -#else - void set_charset(const char *remote = 0, const char *local = "UTF-8"); -#endif // WIN32 - - - // Log management void log(const char *fmt, ...); void logva(const char *fmt, va_list args); // Information - virtual string get_version(void); - virtual string get_revision(void); - virtual const char * get_charset(void); + virtual const string get_version(void); + virtual const string get_revision(void); virtual bool is_connected(void) = 0; virtual bool is_ready(void) = 0; virtual LIB3270_CSTATE get_cstate(void) = 0; + // charset +#ifdef WIN32 + void set_display_charset(const char *remote = 0, const char *local = "CP1252"); +#else + void set_display_charset(const char *remote = 0, const char *local = "UTF-8"); +#endif // WIN32 + + virtual int set_host_charset(const char *charset) = 0; + virtual string * get_host_charset(void) = 0; + virtual string * get_display_charset(void); + // Connection & Network virtual int connect(const char *uri, bool wait = true) = 0; virtual int disconnect(void) = 0; diff --git a/src/lib3270/charset.c b/src/lib3270/charset.c index f6aa31b..5ec92c6 100644 --- a/src/lib3270/charset.c +++ b/src/lib3270/charset.c @@ -300,12 +300,18 @@ LIB3270_EXPORT const char * lib3270_get_default_charset(void) return "ISO-8859-1"; } -LIB3270_EXPORT const char * lib3270_get_charset(H3270 *hSession) +LIB3270_EXPORT const char * lib3270_get_display_charset(H3270 *hSession) { CHECK_SESSION_HANDLE(hSession); return hSession->charset.display ? hSession->charset.display : "ISO-8859-1"; } +LIB3270_EXPORT const char * lib3270_get_host_charset(H3270 *hSession) +{ + CHECK_SESSION_HANDLE(hSession); + return hSession->charset.host; +} + LIB3270_ACTION( charsettable ) { static const char * hChars = "0123456789ABCDEF"; diff --git a/src/lib3270/html.c b/src/lib3270/html.c index 15e0a62..aee2a6d 100644 --- a/src/lib3270/html.c +++ b/src/lib3270/html.c @@ -244,7 +244,7 @@ if(option & LIB3270_HTML_OPTION_HEADERS) { - char *txt = xs_buffer(element_text[HTML_ELEMENT_HEADER],lib3270_get_charset(session),html_color[0]); + char *txt = xs_buffer(element_text[HTML_ELEMENT_HEADER],lib3270_get_display_charset(session),html_color[0]); append_string(&info,txt); lib3270_free(txt); } diff --git a/src/lib3270/macros.c b/src/lib3270/macros.c index 5631162..30112dc 100644 --- a/src/lib3270/macros.c +++ b/src/lib3270/macros.c @@ -88,7 +88,7 @@ LIB3270_MACRO( encoding ) { - return strdup(lib3270_get_charset(hSession)); + return strdup(lib3270_get_display_charset(hSession)); } LIB3270_MACRO( get ) diff --git a/src/plugins/dbus3270/gobject.c b/src/plugins/dbus3270/gobject.c index a8518c0..235f56b 100644 --- a/src/plugins/dbus3270/gobject.c +++ b/src/plugins/dbus3270/gobject.c @@ -44,6 +44,7 @@ #include #include #include +#include #include "service.h" @@ -191,7 +192,7 @@ void pw3270_dbus_get_screen_contents(PW3270Dbus *object, DBusGMethodInvocation * text = lib3270_get_text(hSession,0,-1); - utftext = g_convert_with_fallback(text,-1,"UTF-8",lib3270_get_charset(hSession),"?",NULL,NULL,NULL); + utftext = g_convert_with_fallback(text,-1,"UTF-8",lib3270_get_display_charset(hSession),"?",NULL,NULL,NULL); lib3270_free(text); @@ -218,7 +219,7 @@ void pw3270_dbus_set_text_at(PW3270Dbus *object, int row, int col, const gchar * if(pw3270_dbus_check_valid_state(object,context)) return; - text = g_convert_with_fallback(utftext,-1,lib3270_get_charset(hSession),"UTF-8","?",NULL,NULL,NULL); + text = g_convert_with_fallback(utftext,-1,lib3270_get_display_charset(hSession),"UTF-8","?",NULL,NULL,NULL); dbus_g_method_return(context,lib3270_set_string_at(hSession,row,col,(const unsigned char *) text)); @@ -234,7 +235,7 @@ void pw3270_dbus_input(PW3270Dbus *object, const gchar *utftext, DBusGMethodInvo if(pw3270_dbus_check_valid_state(object,context)) return; - text = g_convert_with_fallback(utftext,-1,lib3270_get_charset(hSession),"UTF-8","?",NULL,NULL,NULL); + text = g_convert_with_fallback(utftext,-1,lib3270_get_display_charset(hSession),"UTF-8","?",NULL,NULL,NULL); dbus_g_method_return(context,lib3270_emulate_input(hSession,(const char *) text,-1,1)); @@ -260,7 +261,7 @@ void pw3270_dbus_get_text_at(PW3270Dbus *object, int row, int col, int len, DBus } else { - gchar * utftext = g_convert_with_fallback(text,-1,"UTF-8",lib3270_get_charset(hSession),"?",NULL,NULL,NULL); + gchar * utftext = g_convert_with_fallback(text,-1,"UTF-8",lib3270_get_display_charset(hSession),"?",NULL,NULL,NULL); lib3270_free(text); @@ -288,7 +289,7 @@ void pw3270_dbus_get_text_at(PW3270Dbus *object, int row, int col, int len, DBus } else { - gchar * utftext = g_convert_with_fallback(text,-1,"UTF-8",lib3270_get_charset(hSession),"?",NULL,NULL,NULL); + gchar * utftext = g_convert_with_fallback(text,-1,"UTF-8",lib3270_get_display_charset(hSession),"?",NULL,NULL,NULL); lib3270_free(text); @@ -356,7 +357,7 @@ void pw3270_dbus_cmp_text_at(PW3270Dbus *object, int row, int col, const gchar * if(pw3270_dbus_check_valid_state(object,context)) return; - text = g_convert_with_fallback(utftext,-1,lib3270_get_charset(hSession),"UTF-8","?",NULL,NULL,NULL); + text = g_convert_with_fallback(utftext,-1,lib3270_get_display_charset(hSession),"UTF-8","?",NULL,NULL,NULL); dbus_g_method_return(context,lib3270_cmp_text_at(hSession,row,col,text)); @@ -452,3 +453,18 @@ void pw3270_dbus_show_popup(PW3270Dbus *object, int id, const gchar *title, cons lib3270_popup_dialog(pw3270_dbus_get_session_handle(object), (LIB3270_NOTIFY) id , title, msg, "%s", text); dbus_g_method_return(context,0); } + +void pw3270_dbus_get_host_charset(PW3270Dbus *object, DBusGMethodInvocation *context) +{ + dbus_g_method_return(context,lib3270_get_host_charset(pw3270_dbus_get_session_handle(object))); +} + +void pw3270_dbus_get_display_charset(PW3270Dbus *object, DBusGMethodInvocation *context) +{ + dbus_g_method_return(context,lib3270_get_display_charset(pw3270_dbus_get_session_handle(object))); +} + +void pw3270_dbus_set_host_charset(PW3270Dbus *object, const gchar *charset, DBusGMethodInvocation *context) +{ + dbus_g_method_return(context,lib3270_set_host_charset(pw3270_dbus_get_session_handle(object),charset)); +} diff --git a/src/plugins/dbus3270/pw3270dbus.xml b/src/plugins/dbus3270/pw3270dbus.xml index 6c9ca10..7192562 100644 --- a/src/plugins/dbus3270/pw3270dbus.xml +++ b/src/plugins/dbus3270/pw3270dbus.xml @@ -149,6 +149,20 @@ + + + + + + + + + + + + + + diff --git a/src/plugins/dbus3270/service.h b/src/plugins/dbus3270/service.h index 926cdf4..1ddd84a 100644 --- a/src/plugins/dbus3270/service.h +++ b/src/plugins/dbus3270/service.h @@ -106,6 +106,10 @@ void pw3270_dbus_set_clipboard(PW3270Dbus *object, const gchar *text, DBusGMethodInvocation *context); void pw3270_dbus_get_clipboard(PW3270Dbus *object, DBusGMethodInvocation *context); + void pw3270_dbus_get_display_charset(PW3270Dbus *object, DBusGMethodInvocation *context); + void pw3270_dbus_get_host_charset(PW3270Dbus *object, DBusGMethodInvocation *context); + void pw3270_dbus_set_host_charset(PW3270Dbus *object, const gchar *charset, DBusGMethodInvocation *context); + G_END_DECLS #endif // _PW3270_DBUS_SERVICE_H diff --git a/src/plugins/dbus3270/test.sh b/src/plugins/dbus3270/test.sh index f56aa6b..15e85e7 100755 --- a/src/plugins/dbus3270/test.sh +++ b/src/plugins/dbus3270/test.sh @@ -45,6 +45,15 @@ run_command() dbus-send --session --print-reply --dest=$DEST.$SESSION $BPATH $DEST.isConnected ;; + hostcharset) + dbus-send --session --print-reply --dest=$DEST.$SESSION $BPATH $DEST.getHostCharset + ;; + + displaycharset) + dbus-send --session --print-reply --dest=$DEST.$SESSION $BPATH $DEST.getDisplayCharset + ;; + + *) echo "Comando $1 desconhecido" ;; diff --git a/src/plugins/rx3270/pluginmain.cc b/src/plugins/rx3270/pluginmain.cc index f3f737d..b1f4263 100644 --- a/src/plugins/rx3270/pluginmain.cc +++ b/src/plugins/rx3270/pluginmain.cc @@ -49,6 +49,7 @@ #include #include #include + #include #include /*--[ Globals ]--------------------------------------------------------------------------------------*/ @@ -84,7 +85,7 @@ void free(void *ptr); - string get_version(void); + const string get_version(void); LIB3270_CSTATE get_cstate(void); int disconnect(void); int connect(const char *uri, bool wait = true); @@ -126,6 +127,10 @@ int popup_dialog(LIB3270_NOTIFY id , const char *title, const char *message, const char *fmt, ...); string * file_chooser_dialog(GtkFileChooserAction action, const char *title, const char *extension, const char *filename); + int set_host_charset(const char *charset); + string * get_host_charset(void); + string * get_display_charset(void); + int quit(void); protected: @@ -502,7 +507,7 @@ extern "C" } - string plugin::get_version(void) + const string plugin::get_version(void) { return string(lib3270_get_version()); } @@ -723,3 +728,18 @@ int plugin::quit(void) gtk_main_quit(); return 0; } + +int plugin::set_host_charset(const char *charset) +{ + return lib3270_set_host_charset(hSession,charset); +} + +string * plugin::get_host_charset(void) +{ + return new string(lib3270_get_host_charset(hSession)); +} + +string * plugin::get_display_charset(void) +{ + return new string(lib3270_get_display_charset(hSession)); +} diff --git a/src/plugins/rx3270/rexx_methods.cc b/src/plugins/rx3270/rexx_methods.cc index b656594..2518f63 100644 --- a/src/plugins/rx3270/rexx_methods.cc +++ b/src/plugins/rx3270/rexx_methods.cc @@ -578,3 +578,24 @@ RexxMethod5(RexxStringObject, rx3270_method_get_filename, CSELF, sessionPtr, CST return context->String(""); } +RexxMethod2(int, rx3270_method_set_host_charset, CSELF, sessionPtr, CSTRING, text) +{ + return ((session *) sessionPtr)->set_host_charset(text); +} + +RexxMethod1(RexxStringObject, rx3270_method_get_host_charset, CSELF, sessionPtr) +{ + string * ret = ((session *) sessionPtr)->get_host_charset(); + RexxStringObject obj = context->String(ret->c_str()); + delete ret; + return obj; +} + +RexxMethod1(RexxStringObject, rx3270_method_get_display_charset, CSELF, sessionPtr) +{ + string * ret = ((session *) sessionPtr)->get_display_charset(); + RexxStringObject obj = context->String(ret->c_str()); + delete ret; + return obj; +} + diff --git a/src/plugins/rx3270/rx3270.cls b/src/plugins/rx3270/rx3270.cls index 235bcc0..5cdbe5d 100644 --- a/src/plugins/rx3270/rx3270.cls +++ b/src/plugins/rx3270/rx3270.cls @@ -87,6 +87,10 @@ ::METHOD POPUP EXTERNAL "LIBRARY rx3270 rx3270_method_popup" ::METHOD GETFILENAME EXTERNAL "LIBRARY rx3270 rx3270_method_get_filename" +::METHOD GETDISPLAYCHARSET EXTERNAL "LIBRARY rx3270 rx3270_method_get_display_charset" +::METHOD GETHOSTCHARSET EXTERNAL "LIBRARY rx3270 rx3270_method_get_host_charset" +::METHOD SETHOSTCHARSET EXTERNAL "LIBRARY rx3270 rx3270_method_set_host_charset" + ::method waitForStringAt use arg row, col, key, timeout if datatype(timeout) <> "NUM" diff --git a/src/plugins/rx3270/rx3270.h b/src/plugins/rx3270/rx3270.h index ecae8bf..c22cdf0 100644 --- a/src/plugins/rx3270/rx3270.h +++ b/src/plugins/rx3270/rx3270.h @@ -124,6 +124,9 @@ REXX_METHOD_PROTOTYPE(rx3270_method_get_cursor_addr); REXX_METHOD_PROTOTYPE(rx3270_method_set_cursor_addr); REXX_METHOD_PROTOTYPE(rx3270_method_input_text); + REXX_METHOD_PROTOTYPE(rx3270_method_get_display_charset); + REXX_METHOD_PROTOTYPE(rx3270_method_get_host_charset); + REXX_METHOD_PROTOTYPE(rx3270_method_set_host_charset); /*---[ Globals ]---------------------------------------------------------------------------------------------*/ diff --git a/src/plugins/rx3270/rxapimain.cc b/src/plugins/rx3270/rxapimain.cc index 173c3dc..9e7ace2 100644 --- a/src/plugins/rx3270/rxapimain.cc +++ b/src/plugins/rx3270/rxapimain.cc @@ -164,6 +164,10 @@ RexxMethodEntry rx3270_methods[] = REXX_METHOD(rx3270_method_set_cursor_addr, rx3270_method_set_cursor_addr ), REXX_METHOD(rx3270_method_input_text, rx3270_method_input_text ), + REXX_METHOD(rx3270_method_get_display_charset, rx3270_method_get_display_charset ), + REXX_METHOD(rx3270_method_get_host_charset, rx3270_method_get_host_charset ), + REXX_METHOD(rx3270_method_set_host_charset, rx3270_method_set_host_charset ), + REXX_LAST_METHOD() }; diff --git a/src/plugins/rx3270/sample/charset.rex b/src/plugins/rx3270/sample/charset.rex new file mode 100644 index 0000000..559e905 --- /dev/null +++ b/src/plugins/rx3270/sample/charset.rex @@ -0,0 +1,12 @@ +/* + * Sample rexx code to get host charset + */ + + host = .rx3270~new("") + + say "Display charset: "||host~getDisplayCharset() + say "Host charset: "||host~getHostCharset() + + return 0 + +::requires "rx3270.cls" diff --git a/src/pw3270/actions.c b/src/pw3270/actions.c index 5ade997..4222729 100644 --- a/src/pw3270/actions.c +++ b/src/pw3270/actions.c @@ -219,7 +219,7 @@ static void copy_as_html_action(GtkAction *action, GtkWidget *widget) trace_action(action,widget); text = lib3270_get_as_html(session,LIB3270_HTML_OPTION_ALL|LIB3270_HTML_OPTION_FORM); - utf = g_convert(text, -1, "UTF-8", lib3270_get_charset(session), NULL, NULL, NULL); + utf = g_convert(text, -1, "UTF-8", lib3270_get_display_charset(session), NULL, NULL, NULL); lib3270_free(text); gtk_clipboard_set_text(clipboard,utf,-1); diff --git a/src/pw3270/main.c b/src/pw3270/main.c index 7d311a3..943d7bb 100644 --- a/src/pw3270/main.c +++ b/src/pw3270/main.c @@ -308,7 +308,7 @@ static void g_trace(H3270 *hSession, const char *fmt, va_list args) else { // No trace file, open standard window - gchar * utftext = g_convert_with_fallback(ptr,-1,"UTF-8",lib3270_get_charset(hSession),"?",NULL,NULL,NULL); + gchar * utftext = g_convert_with_fallback(ptr,-1,"UTF-8",lib3270_get_display_charset(hSession),"?",NULL,NULL,NULL); if(!trace_window) { diff --git a/src/pw3270/v3270/accessible.c b/src/pw3270/v3270/accessible.c index 2a749ec..d8ae7b8 100644 --- a/src/pw3270/v3270/accessible.c +++ b/src/pw3270/v3270/accessible.c @@ -195,7 +195,7 @@ static gunichar v3270_accessible_get_character_at_offset(AtkText *atk_text, gint gchar * utfstring = g_convert_with_fallback( text, -1, "UTF-8", - lib3270_get_charset(host), + lib3270_get_display_charset(host), " ", NULL, &bytes_written, @@ -390,7 +390,7 @@ static gchar * v3270_accessible_get_text_at_offset(AtkText *atk_text, gint offse gchar * utfchar = g_convert_with_fallback( text, -1, "UTF-8", - lib3270_get_charset(host), + lib3270_get_display_charset(host), " ", NULL, &bytes_written, @@ -433,7 +433,7 @@ static gchar * v3270_accessible_get_text(AtkText *atk_text, gint start_pos, gint gsize bytes_written; GError * error = NULL; - utftext = g_convert_with_fallback(text,-1,"UTF-8",lib3270_get_charset(host)," ",NULL,&bytes_written, &error); + utftext = g_convert_with_fallback(text,-1,"UTF-8",lib3270_get_display_charset(host)," ",NULL,&bytes_written, &error); if(error) { diff --git a/src/pw3270/v3270/draw.c b/src/pw3270/v3270/draw.c index 406b9b7..488aad7 100644 --- a/src/pw3270/v3270/draw.c +++ b/src/pw3270/v3270/draw.c @@ -275,7 +275,7 @@ void v3270_draw_char(cairo_t *cr, unsigned char chr, unsigned short attr, H3270 } else if(chr) { - gchar *utf = g_convert((char *) &chr, 1, "UTF-8", lib3270_get_charset(session), NULL, NULL, NULL); + gchar *utf = g_convert((char *) &chr, 1, "UTF-8", lib3270_get_display_charset(session), NULL, NULL, NULL); if(utf) { diff --git a/src/pw3270/v3270/keyboard.c b/src/pw3270/v3270/keyboard.c index 471d18f..61a6f99 100644 --- a/src/pw3270/v3270/keyboard.c +++ b/src/pw3270/v3270/keyboard.c @@ -247,7 +247,7 @@ host = GTK_V3270(widget)->host; - utf = g_convert((char *) str, -1, lib3270_get_charset(host), "UTF-8", NULL, NULL, NULL); + utf = g_convert((char *) str, -1, lib3270_get_display_charset(host), "UTF-8", NULL, NULL, NULL); if(utf) { @@ -259,7 +259,7 @@ void v3270_key_commit(GtkIMContext *imcontext, gchar *str, v3270 *widget) { - gchar *utf = g_convert((char *) str, -1, lib3270_get_charset(widget->host), "UTF-8", NULL, NULL, NULL); + gchar *utf = g_convert((char *) str, -1, lib3270_get_display_charset(widget->host), "UTF-8", NULL, NULL, NULL); if(utf) { diff --git a/src/pw3270/v3270/selection.c b/src/pw3270/v3270/selection.c index cfaf05e..c0ea9a7 100644 --- a/src/pw3270/v3270/selection.c +++ b/src/pw3270/v3270/selection.c @@ -70,7 +70,7 @@ static void clipboard_get(GtkClipboard *clipboard, GtkSelectionData *selection, } else { - gchar * text = g_convert(widget->selection.text, -1, "UTF-8", lib3270_get_charset(widget->host), NULL, NULL, NULL); + gchar * text = g_convert(widget->selection.text, -1, "UTF-8", lib3270_get_display_charset(widget->host), NULL, NULL, NULL); gtk_selection_data_set_text(selection,text,-1); g_free(text); } @@ -104,7 +104,7 @@ gchar * v3270_get_text(GtkWidget *widget, int offset, int len) if(!str) return NULL; - text = g_convert(str, -1, "UTF-8", lib3270_get_charset(terminal->host), NULL, NULL, NULL); + text = g_convert(str, -1, "UTF-8", lib3270_get_display_charset(terminal->host), NULL, NULL, NULL); lib3270_free(str); return text; @@ -226,7 +226,7 @@ gchar * v3270_get_selected(GtkWidget *widget, gboolean cut) text = update_selected_text(widget,cut); if(text) - return g_convert(text, -1, "UTF-8", lib3270_get_charset(GTK_V3270(widget)->host), NULL, NULL, NULL); + return g_convert(text, -1, "UTF-8", lib3270_get_display_charset(GTK_V3270(widget)->host), NULL, NULL, NULL); return NULL; } @@ -242,7 +242,7 @@ gchar * v3270_get_copy(GtkWidget *widget) text = update_selected_text(widget,FALSE); if(text) - return g_convert(text, -1, "UTF-8", lib3270_get_charset(GTK_V3270(widget)->host), NULL, NULL, NULL); + return g_convert(text, -1, "UTF-8", lib3270_get_display_charset(GTK_V3270(widget)->host), NULL, NULL, NULL); return NULL; } @@ -266,7 +266,7 @@ void v3270_set_copy(GtkWidget *widget, const gchar *text) /* Received text, replace the selection buffer */ terminal->table = 0; - isotext = g_convert(text, -1, lib3270_get_charset(terminal->host), "UTF-8", NULL, NULL, NULL); + isotext = g_convert(text, -1, lib3270_get_display_charset(terminal->host), "UTF-8", NULL, NULL, NULL); if(!isotext) { @@ -350,7 +350,7 @@ void v3270_paste_string(GtkWidget *widget, const gchar *text, const gchar *encod { gchar * buffer = NULL; H3270 * session = v3270_get_session(widget); - const gchar * charset = lib3270_get_charset(session); + const gchar * charset = lib3270_get_display_charset(session); gboolean next; if(!text) @@ -504,7 +504,7 @@ gchar * v3270_get_region(GtkWidget *widget, gint start_pos, gint end_pos, gboole if(!str) return NULL; - utftext = g_convert(str, -1, "UTF-8", lib3270_get_charset(GTK_V3270(widget)->host), NULL, NULL, NULL); + utftext = g_convert(str, -1, "UTF-8", lib3270_get_display_charset(GTK_V3270(widget)->host), NULL, NULL, NULL); lib3270_free(str); diff --git a/src/pw3270/v3270/widget.c b/src/pw3270/v3270/widget.c index b234a9d..a87ec64 100644 --- a/src/pw3270/v3270/widget.c +++ b/src/pw3270/v3270/widget.c @@ -765,7 +765,7 @@ static void changed(H3270 *session, int offset, int len) gchar * utfchar = g_convert_with_fallback( text, -1, "UTF-8", - lib3270_get_charset(session), + lib3270_get_display_charset(session), " ", NULL, &bytes_written, -- libgit2 0.21.2