Commit 858ac02b8c181e738f9cfa6528748d74d95b1214
1 parent
74df497c
Exists in
master
and in
5 other branches
Incluindo excessões na extensão libreoffice
Showing
4 changed files
with
41 additions
and
14 deletions
Show diff stats
src/oxt/globals.hpp
| ... | ... | @@ -52,6 +52,8 @@ |
| 52 | 52 | namespace pw3270 |
| 53 | 53 | { |
| 54 | 54 | |
| 55 | + class uno_impl; | |
| 56 | + | |
| 55 | 57 | class session |
| 56 | 58 | { |
| 57 | 59 | public: |
| ... | ... | @@ -85,7 +87,7 @@ |
| 85 | 87 | class lib3270_session : public session |
| 86 | 88 | { |
| 87 | 89 | public: |
| 88 | - lib3270_session(); | |
| 90 | + lib3270_session(uno_impl *obj) throw( RuntimeException ); | |
| 89 | 91 | virtual ~lib3270_session(); |
| 90 | 92 | |
| 91 | 93 | virtual int get_revision(void); |
| ... | ... | @@ -136,7 +138,7 @@ |
| 136 | 138 | class ipc3270_session : public session |
| 137 | 139 | { |
| 138 | 140 | public: |
| 139 | - ipc3270_session(const char *name); | |
| 141 | + ipc3270_session(uno_impl *obj, const char *name) throw( RuntimeException ); | |
| 140 | 142 | virtual ~ipc3270_session(); |
| 141 | 143 | virtual int get_revision(void); |
| 142 | 144 | virtual LIB3270_MESSAGE get_state(void); |
| ... | ... | @@ -210,12 +212,12 @@ |
| 210 | 212 | virtual ::sal_Int16 SAL_CALL screenTrace( ::sal_Bool state ) throw (::com::sun::star::uno::RuntimeException); |
| 211 | 213 | virtual ::sal_Int16 SAL_CALL setSession( const ::rtl::OUString& name ) throw (::com::sun::star::uno::RuntimeException); |
| 212 | 214 | |
| 215 | + void failed(const char *fmt, ...) throw( ::com::sun::star::uno::RuntimeException ); | |
| 216 | + | |
| 213 | 217 | private: |
| 214 | 218 | |
| 215 | 219 | session *hSession; |
| 216 | 220 | |
| 217 | - | |
| 218 | - | |
| 219 | 221 | }; |
| 220 | 222 | |
| 221 | 223 | }; | ... | ... |
src/oxt/local.cxx
| ... | ... | @@ -96,7 +96,7 @@ |
| 96 | 96 | #endif // HAVE_SYSLOG |
| 97 | 97 | } |
| 98 | 98 | |
| 99 | - pw3270::lib3270_session::lib3270_session() | |
| 99 | + pw3270::lib3270_session::lib3270_session(uno_impl *obj) throw( RuntimeException ) | |
| 100 | 100 | { |
| 101 | 101 | struct _call |
| 102 | 102 | { |
| ... | ... | @@ -136,7 +136,7 @@ |
| 136 | 136 | |
| 137 | 137 | if(!hModule) |
| 138 | 138 | { |
| 139 | - log("%s","Error loading lib3270"); | |
| 139 | + obj->failed("%s","Can't load lib3270"); | |
| 140 | 140 | return; |
| 141 | 141 | } |
| 142 | 142 | |
| ... | ... | @@ -144,7 +144,7 @@ |
| 144 | 144 | { |
| 145 | 145 | *call[f].entry = (void *) osl_getAsciiFunctionSymbol(hModule,call[f].name); |
| 146 | 146 | if(!*call[f].entry) |
| 147 | - log("Error loading lib3270::%s",call[f].name); | |
| 147 | + obj->failed("Error loading lib3270::%s",call[f].name); | |
| 148 | 148 | } |
| 149 | 149 | |
| 150 | 150 | /* Get lib3270 session handle */ | ... | ... |
src/oxt/main.cxx
| ... | ... | @@ -30,6 +30,7 @@ |
| 30 | 30 | */ |
| 31 | 31 | |
| 32 | 32 | #include "globals.hpp" |
| 33 | +#include <string.h> | |
| 33 | 34 | |
| 34 | 35 | #ifdef HAVE_SYSLOG |
| 35 | 36 | #include <syslog.h> |
| ... | ... | @@ -218,7 +219,7 @@ Sequence< OUString > pw3270::uno_impl::getSupportedServiceNames() throw (Runtime |
| 218 | 219 | |
| 219 | 220 | pw3270::uno_impl::uno_impl( const Reference< XComponentContext > & xContext ) |
| 220 | 221 | { |
| 221 | - this->hSession = new lib3270_session(); | |
| 222 | + this->hSession = new lib3270_session(this); | |
| 222 | 223 | } |
| 223 | 224 | |
| 224 | 225 | pw3270::uno_impl::~uno_impl() |
| ... | ... | @@ -285,12 +286,35 @@ void pw3270::session::log(const char *fmt, const char *msg) |
| 285 | 286 | #endif // HAVE_SYSLOG |
| 286 | 287 | } |
| 287 | 288 | |
| 289 | +void pw3270::uno_impl::failed(const char *fmt, ...) throw( ::com::sun::star::uno::RuntimeException ) | |
| 290 | +{ | |
| 291 | + va_list arg_ptr; | |
| 292 | + char * msg = (char *) malloc(1024); | |
| 293 | + | |
| 294 | + va_start(arg_ptr, fmt); | |
| 295 | + vsnprintf(msg, 1023, fmt, arg_ptr); | |
| 296 | + va_end(arg_ptr); | |
| 297 | + | |
| 298 | +#ifdef HAVE_SYSLOG | |
| 299 | + openlog(PACKAGE_NAME, LOG_NDELAY, LOG_USER); | |
| 300 | + syslog(LOG_ERR,"%s",msg); | |
| 301 | + closelog(); | |
| 302 | +#endif // HAVE_SYSLOG | |
| 303 | + | |
| 304 | + ::rtl::OUString str = OUString(msg, strlen(msg), RTL_TEXTENCODING_UTF8, RTL_TEXTTOUNICODE_FLAGS_UNDEFINED_IGNORE); | |
| 305 | + | |
| 306 | + free(msg); | |
| 307 | + | |
| 308 | + throw Exception( str , *this ); | |
| 309 | + | |
| 310 | +} | |
| 311 | + | |
| 288 | 312 | ::sal_Int16 SAL_CALL pw3270::uno_impl::setSession( const ::rtl::OUString& name ) throw (::com::sun::star::uno::RuntimeException) |
| 289 | 313 | { |
| 290 | 314 | OString str = rtl::OUStringToOString( name , hSession->get_encoding() ); |
| 291 | 315 | |
| 292 | 316 | delete this->hSession; |
| 293 | - this->hSession = new ipc3270_session(str.getStr()); | |
| 317 | + this->hSession = new ipc3270_session(this,str.getStr()); | |
| 294 | 318 | |
| 295 | 319 | return 0; |
| 296 | 320 | } | ... | ... |
src/oxt/remote.cxx
| ... | ... | @@ -151,7 +151,7 @@ int pw3270::ipc3270_session::query_intval(const char *method) |
| 151 | 151 | #endif // HAVE_DBUS |
| 152 | 152 | |
| 153 | 153 | |
| 154 | -pw3270::ipc3270_session::ipc3270_session(const char *name) : pw3270::session() | |
| 154 | +pw3270::ipc3270_session::ipc3270_session(uno_impl *obj, const char *name) throw( RuntimeException ) : pw3270::session() | |
| 155 | 155 | { |
| 156 | 156 | #ifdef HAVE_DBUS |
| 157 | 157 | |
| ... | ... | @@ -226,13 +226,14 @@ pw3270::ipc3270_session::ipc3270_session(const char *name) : pw3270::session() |
| 226 | 226 | |
| 227 | 227 | if (dbus_error_is_set(&err)) |
| 228 | 228 | { |
| 229 | - log("DBUS Connection Error (%s)", err.message); | |
| 229 | + obj->failed("DBUS Connection Error (%s)", err.message); | |
| 230 | 230 | dbus_error_free(&err); |
| 231 | + return; | |
| 231 | 232 | } |
| 232 | 233 | |
| 233 | 234 | if(!conn) |
| 234 | 235 | { |
| 235 | - log("%s", "DBUS Connection failed"); | |
| 236 | + obj->failed("%s", "DBUS Connection failed"); | |
| 236 | 237 | return; |
| 237 | 238 | } |
| 238 | 239 | |
| ... | ... | @@ -240,7 +241,7 @@ pw3270::ipc3270_session::ipc3270_session(const char *name) : pw3270::session() |
| 240 | 241 | |
| 241 | 242 | if (dbus_error_is_set(&err)) |
| 242 | 243 | { |
| 243 | - log("Name Error (%s)", err.message); | |
| 244 | + obj->failed("DBUS Name Error (%s)", err.message); | |
| 244 | 245 | dbus_error_free(&err); |
| 245 | 246 | conn = NULL; |
| 246 | 247 | return; |
| ... | ... | @@ -248,7 +249,7 @@ pw3270::ipc3270_session::ipc3270_session(const char *name) : pw3270::session() |
| 248 | 249 | |
| 249 | 250 | if(rc != DBUS_REQUEST_NAME_REPLY_PRIMARY_OWNER) |
| 250 | 251 | { |
| 251 | - log("%s", "DBUS request name failed"); | |
| 252 | + obj->failed("%s", "DBUS request name failed"); | |
| 252 | 253 | conn = NULL; |
| 253 | 254 | return; |
| 254 | 255 | } | ... | ... |