From adbd6ec9ec36d5a4c45ee3d9c8854a7aca07a8a6 Mon Sep 17 00:00:00 2001 From: Perry Werneck Date: Wed, 4 Dec 2019 18:41:24 -0300 Subject: [PATCH] Setting local charset on the constructor because python is always UTF-8, even on windows. --- client/src/core/abstract.cc | 2 +- client/src/core/session.cc | 8 ++++---- client/src/core/windows/attribute.cc | 2 +- client/src/host/init.cc | 4 ++-- client/src/include/ipc-client-internals.h | 4 ++-- client/src/include/lib3270/ipc.h | 4 ++-- client/src/session/local/init.cc | 8 ++++---- client/src/session/local/private.h | 2 +- client/src/session/remote/linux/session.cc | 4 ++-- client/src/session/remote/private.h | 2 +- client/src/session/remote/tools.cc | 4 ++-- client/src/session/remote/windows/session.cc | 4 ++-- 12 files changed, 24 insertions(+), 24 deletions(-) diff --git a/client/src/core/abstract.cc b/client/src/core/abstract.cc index 333c931..8219db0 100644 --- a/client/src/core/abstract.cc +++ b/client/src/core/abstract.cc @@ -98,7 +98,7 @@ if(this->converter.host != (iconv_t) (-1)) iconv_close(converter.host); - if(strcmp(local,remote)) { + if(remote && strcmp(local,remote)) { // Local and remote charsets aren't the same, setup conversion converter.local = iconv_open(local, remote); diff --git a/client/src/core/session.cc b/client/src/core/session.cc index 7cf2370..ac43c2e 100644 --- a/client/src/core/session.cc +++ b/client/src/core/session.cc @@ -44,10 +44,10 @@ namespace TN3270 { - Session * Session::getInstance(const char *id) { + Session * Session::getInstance(const char *id, const char *charset) { if(!(id && *id)) { - return Local::getSessionInstance(); + return Local::getSessionInstance(charset); } if(*id == ':') { @@ -55,11 +55,11 @@ std::string name{LIB3270_STRINGIZE_VALUE_OF(PRODUCT_NAME)}; name += id; - return IPC::getSessionInstance(name.c_str()); + return IPC::getSessionInstance(name.c_str(), charset); } - return IPC::getSessionInstance(id); + return IPC::getSessionInstance(id, charset); } diff --git a/client/src/core/windows/attribute.cc b/client/src/core/windows/attribute.cc index f141386..83e020a 100644 --- a/client/src/core/windows/attribute.cc +++ b/client/src/core/windows/attribute.cc @@ -58,7 +58,7 @@ attributes.push_back((const LIB3270_PROPERTY *) prop); } - for(auto prop = lib3270_get_toggle_list(); prop->name; prop++) { + for(auto prop = lib3270_get_toggles(); prop->name; prop++) { attributes.push_back((const LIB3270_PROPERTY *) prop); } diff --git a/client/src/host/init.cc b/client/src/host/init.cc index 7543af0..0bcb2d9 100644 --- a/client/src/host/init.cc +++ b/client/src/host/init.cc @@ -40,12 +40,12 @@ /*---[ Implement ]----------------------------------------------------------------------------------*/ -TN3270::Host::Host(const char *id, const char *url, time_t timeout) { +TN3270::Host::Host(const char *id, const char *url, time_t timeout, const char *charset) { debug("Creating host id=\"", id); this->timeout = timeout; - this->session = Session::getInstance(id); + this->session = Session::getInstance(id, charset); if(url) { this->connect(url); } diff --git a/client/src/include/ipc-client-internals.h b/client/src/include/ipc-client-internals.h index e7ccbaa..c38df64 100644 --- a/client/src/include/ipc-client-internals.h +++ b/client/src/include/ipc-client-internals.h @@ -203,14 +203,14 @@ /// @brief lib3270 direct access objects (no IPC); namespace Local { - TN3270_PRIVATE Session * getSessionInstance(); + TN3270_PRIVATE Session * getSessionInstance(const char *charset = nullptr); } /// @brief IPC Based acess (Access an active instance of pw3270 or pw3270d) namespace IPC { - TN3270_PRIVATE TN3270::Session * getSessionInstance(const char *id); + TN3270_PRIVATE TN3270::Session * getSessionInstance(const char *id, const char *charset = nullptr); class Session; } diff --git a/client/src/include/lib3270/ipc.h b/client/src/include/lib3270/ipc.h index c070bc7..bdc5dd0 100644 --- a/client/src/include/lib3270/ipc.h +++ b/client/src/include/lib3270/ipc.h @@ -451,7 +451,7 @@ public: /// @brief Get an instance of the TN3270 session based on the supplied ID. - static Session * getInstance(const char *id = nullptr); + static Session * getInstance(const char *id = nullptr, const char *charset = nullptr); virtual ~Session(); // States @@ -675,7 +675,7 @@ */ public: - Host(const char *id = nullptr, const char *url = nullptr, time_t timeout = DEFAULT_TIMEOUT); + Host(const char *id = nullptr, const char *url = nullptr, time_t timeout = DEFAULT_TIMEOUT, const char *charset = nullptr); ~Host(); inline bool operator==(ConnectionState state) const noexcept { diff --git a/client/src/session/local/init.cc b/client/src/session/local/init.cc index 7119f32..88292cc 100644 --- a/client/src/session/local/init.cc +++ b/client/src/session/local/init.cc @@ -55,11 +55,11 @@ namespace TN3270 { - Session * Local::getSessionInstance() { - return new Local::Session(); + Session * Local::getSessionInstance(const char *charset) { + return new Local::Session(charset); } - Local::Session::Session() : Abstract::Session() { + Local::Session::Session(const char *charset) : Abstract::Session() { std::lock_guard lock(sync); @@ -67,7 +67,7 @@ lib3270_set_user_data(this->hSession,(void *) this); - setCharSet(); + this->setCharSet(charset); lib3270_set_popup_handler(this->hSession, popupHandler); diff --git a/client/src/session/local/private.h b/client/src/session/local/private.h index 8953a67..744cdd3 100644 --- a/client/src/session/local/private.h +++ b/client/src/session/local/private.h @@ -105,7 +105,7 @@ public: - Session(); + Session(const char *charset = nullptr); virtual ~Session(); // Actions diff --git a/client/src/session/remote/linux/session.cc b/client/src/session/remote/linux/session.cc index 07e73dd..075f540 100644 --- a/client/src/session/remote/linux/session.cc +++ b/client/src/session/remote/linux/session.cc @@ -60,7 +60,7 @@ namespace TN3270 { - IPC::Session::Session(const char *id) : Abstract::Session() { + IPC::Session::Session(const char *id, const char *charset) : Abstract::Session() { // Create D-Bus session. DBusError err; @@ -92,7 +92,7 @@ debug("D-Bus Object name=\"",this->name,"\" D-Bus Object path=\"",this->path,"\""); - setCharSet(); + setCharSet(charset); } diff --git a/client/src/session/remote/private.h b/client/src/session/remote/private.h index d66973d..ac344a7 100644 --- a/client/src/session/remote/private.h +++ b/client/src/session/remote/private.h @@ -104,7 +104,7 @@ public: - Session(const char *id); + Session(const char *id, const char *charset = nullptr); virtual ~Session(); // Actions diff --git a/client/src/session/remote/tools.cc b/client/src/session/remote/tools.cc index bc89b1e..92bd0eb 100644 --- a/client/src/session/remote/tools.cc +++ b/client/src/session/remote/tools.cc @@ -42,8 +42,8 @@ namespace TN3270 { - Session * IPC::getSessionInstance(const char *id) { - return new IPC::Session(id); + Session * IPC::getSessionInstance(const char *id, const char *charset) { + return new IPC::Session(id,charset); } diff --git a/client/src/session/remote/windows/session.cc b/client/src/session/remote/windows/session.cc index 42fdd9e..ebb2047 100644 --- a/client/src/session/remote/windows/session.cc +++ b/client/src/session/remote/windows/session.cc @@ -48,7 +48,7 @@ namespace TN3270 { - IPC::Session::Session(const char *id) : Abstract::Session() { + IPC::Session::Session(const char *id, const char *charset) : Abstract::Session() { const char *ptr = strchr(id,':'); @@ -86,7 +86,7 @@ throw std::runtime_error("Can't set IPC Channel mode"); } - setCharSet(); + this->setCharSet(charset); } IPC::Session::~Session() { -- libgit2 0.21.2