diff --git a/src/plugins/rx3270/exception.cc b/src/plugins/rx3270/exception.cc index 71400ba..25b35b8 100644 --- a/src/plugins/rx3270/exception.cc +++ b/src/plugins/rx3270/exception.cc @@ -98,3 +98,7 @@ void rx3270::exception::RaiseException(RexxCallContext *context) ); } +const char * rx3270::exception::what() const throw() +{ + return this->msg; +} diff --git a/src/plugins/rx3270/local.cc b/src/plugins/rx3270/local.cc index ee8f337..3086d21 100644 --- a/src/plugins/rx3270/local.cc +++ b/src/plugins/rx3270/local.cc @@ -330,7 +330,7 @@ dynamic::dynamic() FreeLibrary(kernel); if(!hModule) - return; + throw exception("Can't load %s",dllname); #else @@ -339,8 +339,7 @@ dynamic::dynamic() hModule = dlopen("lib3270.so." PACKAGE_VERSION, RTLD_NOW); if(!hModule) { - fprintf(stderr,"Can't load lib3270\n%s\n",dlerror()); - fflush(stderr); + throw exception("Can't load lib3270: %s",dlerror()); return; } @@ -358,10 +357,10 @@ dynamic::dynamic() if(!*call[f].entry) { #ifndef WIN32 - fprintf(stderr,"Can't load lib3270::%s\n%s\n",call[f].name,dlerror()); - fflush(stderr); + throw exception("Error \"%s\" loading lib3270::%s",dlerror(),call[f].name); dlclose(hModule); #else + throw exception("Error loading lib3270::%s",call[f].name); FreeLibrary(hModule); #endif // !WIN32 hModule = NULL; diff --git a/src/plugins/rx3270/remote.cc b/src/plugins/rx3270/remote.cc index 47d12d2..3b8af45 100644 --- a/src/plugins/rx3270/remote.cc +++ b/src/plugins/rx3270/remote.cc @@ -170,7 +170,7 @@ remote::remote(const char *name) if(!WaitNamedPipe(buffer,NMPWAIT_USE_DEFAULT_WAIT)) { - throw exception("%s","Invalid service instance"); + throw exception("Invalid service instance: %s",name); return; } @@ -178,7 +178,7 @@ remote::remote(const char *name) if(hPipe == INVALID_HANDLE_VALUE) { - throw exception("%s","Can´t create service pipe"); + throw exception("Can´t create service pipe %s",buffer); return; } @@ -312,6 +312,15 @@ remote::remote(const char *name) trace("%s: Using DBUS name %s",__FUNCTION__,busname); + DBusMessage * msg = create_message("setScript"); + + if(msg) + { + const char * id = "r"; + static const dbus_int32_t flag = 1; + dbus_message_append_args(msg, DBUS_TYPE_STRING, &id, DBUS_TYPE_INT32, &flag, DBUS_TYPE_INVALID); + get_intval(call(msg)); + } #else @@ -327,6 +336,21 @@ remote::~remote() #elif defined(HAVE_DBUS) + try + { + DBusMessage * msg = create_message("setScript"); + if(msg) + { + const char * id = "r"; + static const dbus_int32_t flag = 0; + dbus_message_append_args(msg, DBUS_TYPE_STRING, &id, DBUS_TYPE_INT32, &flag, DBUS_TYPE_INVALID); + get_intval(call(msg)); + } + } + catch(rx3270::exception e) + { + } + free(dest); free(path); free(intf); diff --git a/src/plugins/rx3270/rx3270.h b/src/plugins/rx3270/rx3270.h index 20061e4..9e70433 100644 --- a/src/plugins/rx3270/rx3270.h +++ b/src/plugins/rx3270/rx3270.h @@ -64,6 +64,7 @@ #define REXX_DEFAULT_CHARSET "UTF-8" #endif // WIN32 +#include /*---[ Rexx entry points ]-----------------------------------------------------------------------------------*/ @@ -144,7 +145,7 @@ public: - class exception + class exception : public std::exception { public: exception(int code, const char *fmt, ...); @@ -156,6 +157,8 @@ void RaiseException(RexxMethodContext *context); void RaiseException(RexxCallContext *context); + virtual const char * what() const throw(); + private: int code; char msg[4096]; @@ -186,7 +189,6 @@ virtual char * get_revision(void); virtual LIB3270_CSTATE get_cstate(void) = 0; - virtual int connect(const char *uri, bool wait = true) = 0; virtual int disconnect(void) = 0; virtual bool is_connected(void) = 0; diff --git a/src/plugins/rx3270/sample/clipboard.rex b/src/plugins/rx3270/sample/clipboard.rex index 1a8fdf6..e4a4e3c 100644 --- a/src/plugins/rx3270/sample/clipboard.rex +++ b/src/plugins/rx3270/sample/clipboard.rex @@ -5,8 +5,6 @@ * */ -trace "?R" - host = .rx3270~new("pw3270:a") if host~connected() = 0 then -- libgit2 0.21.2