Commit a6c60ba3bd5d7b1f363574ad2b90ae1c29ff5da2
1 parent
a3fdfc93
Exists in
master
and in
5 other branches
Adding trace support on rexx plugin
Showing
6 changed files
with
157 additions
and
34 deletions
Show diff stats
Makefile.in
| @@ -311,6 +311,7 @@ install-sdk: | @@ -311,6 +311,7 @@ install-sdk: | ||
| 311 | 311 | ||
| 312 | @$(MKDIR) $(DESTDIR)$(includedir)/pw3270 | 312 | @$(MKDIR) $(DESTDIR)$(includedir)/pw3270 |
| 313 | @$(INSTALL_DATA) src/include/pw3270/v3270.h $(DESTDIR)/$(includedir)/pw3270 | 313 | @$(INSTALL_DATA) src/include/pw3270/v3270.h $(DESTDIR)/$(includedir)/pw3270 |
| 314 | + @$(INSTALL_DATA) src/include/pw3270/trace.h $(DESTDIR)/$(includedir)/pw3270 | ||
| 314 | @$(INSTALL_DATA) src/include/pw3270.h $(DESTDIR)/$(includedir) | 315 | @$(INSTALL_DATA) src/include/pw3270.h $(DESTDIR)/$(includedir) |
| 315 | 316 | ||
| 316 | @$(MKDIR) $(DESTDIR)/$(libdir)/pkgconfig | 317 | @$(MKDIR) $(DESTDIR)/$(libdir)/pkgconfig |
src/include/pw3270/trace.h
| @@ -53,6 +53,7 @@ | @@ -53,6 +53,7 @@ | ||
| 53 | LIB3270_EXPORT void pw3270_trace_vprintf(GtkWidget *widget, const char *fmt, va_list args); | 53 | LIB3270_EXPORT void pw3270_trace_vprintf(GtkWidget *widget, const char *fmt, va_list args); |
| 54 | LIB3270_EXPORT void pw3270_trace_printf(GtkWidget *widget, const char *fmt, ... ); | 54 | LIB3270_EXPORT void pw3270_trace_printf(GtkWidget *widget, const char *fmt, ... ); |
| 55 | LIB3270_EXPORT gchar * pw3270_trace_get_command(GtkWidget *widget); | 55 | LIB3270_EXPORT gchar * pw3270_trace_get_command(GtkWidget *widget); |
| 56 | + LIB3270_EXPORT void pw3270_trace_set_destroy_on_close(GtkWidget *widget,gboolean on); | ||
| 56 | 57 | ||
| 57 | G_END_DECLS | 58 | G_END_DECLS |
| 58 | 59 |
src/plugins/rx3270/pluginmain.cc
| @@ -45,6 +45,7 @@ | @@ -45,6 +45,7 @@ | ||
| 45 | #include <pw3270.h> | 45 | #include <pw3270.h> |
| 46 | #include <pw3270/plugin.h> | 46 | #include <pw3270/plugin.h> |
| 47 | #include <pw3270/v3270.h> | 47 | #include <pw3270/v3270.h> |
| 48 | + #include <pw3270/trace.h> | ||
| 48 | #include <lib3270/actions.h> | 49 | #include <lib3270/actions.h> |
| 49 | #include <lib3270/log.h> | 50 | #include <lib3270/log.h> |
| 50 | #include <pw3270/class.h> | 51 | #include <pw3270/class.h> |
| @@ -65,6 +66,7 @@ | @@ -65,6 +66,7 @@ | ||
| 65 | { | 66 | { |
| 66 | GtkAction * action; | 67 | GtkAction * action; |
| 67 | GtkWidget * widget; | 68 | GtkWidget * widget; |
| 69 | + GtkWidget * trace; | ||
| 68 | const gchar * filename; | 70 | const gchar * filename; |
| 69 | }; | 71 | }; |
| 70 | 72 | ||
| @@ -135,42 +137,134 @@ | @@ -135,42 +137,134 @@ | ||
| 135 | 137 | ||
| 136 | /*--[ Running rexx scripts ]---------------------------------------------------------------------------------*/ | 138 | /*--[ Running rexx scripts ]---------------------------------------------------------------------------------*/ |
| 137 | 139 | ||
| 140 | + static void trace_cleanup(GtkWidget *widget, gpointer dunno) | ||
| 141 | + { | ||
| 142 | + rexx_application_data *data = (rexx_application_data *) g_object_get_data(G_OBJECT(widget),"rexx_app_data"); | ||
| 143 | + | ||
| 144 | + trace("%s: data=%p",__FUNCTION__,data); | ||
| 145 | + | ||
| 146 | + if(data) | ||
| 147 | + data->trace = NULL; | ||
| 148 | + | ||
| 149 | + } | ||
| 150 | + | ||
| 151 | + static GtkWidget * get_trace_window(rexx_application_data *data) | ||
| 152 | + { | ||
| 153 | + if(data->trace) | ||
| 154 | + return data->trace; | ||
| 155 | + | ||
| 156 | + data->trace = pw3270_trace_new(); | ||
| 157 | + g_signal_connect(G_OBJECT(data->trace), "destroy",G_CALLBACK(trace_cleanup), NULL); | ||
| 158 | + | ||
| 159 | + pw3270_trace_set_destroy_on_close(data->trace,TRUE); | ||
| 160 | + | ||
| 161 | + g_object_set_data(G_OBJECT(data->trace),"rexx_app_data",data); | ||
| 162 | + | ||
| 163 | + gtk_window_set_title(GTK_WINDOW(data->trace),_("Rexx trace")); | ||
| 164 | + | ||
| 165 | + gtk_window_set_transient_for(GTK_WINDOW(data->trace),GTK_WINDOW(gtk_widget_get_toplevel(data->widget))); | ||
| 166 | + gtk_window_set_destroy_with_parent(GTK_WINDOW(data->trace),TRUE); | ||
| 167 | + | ||
| 168 | + | ||
| 169 | + gtk_window_set_default_size(GTK_WINDOW(data->trace),590,430); | ||
| 170 | + gtk_widget_show_all(data->trace); | ||
| 171 | + return data->trace; | ||
| 172 | + } | ||
| 173 | + | ||
| 174 | + static void read_line(struct rexx_application_data *data, PRXSTRING Retstr) | ||
| 175 | + { | ||
| 176 | + gchar *value = pw3270_trace_get_command(get_trace_window(data)); | ||
| 177 | + | ||
| 178 | + if(value) | ||
| 179 | + { | ||
| 180 | + if(strlen(value) > (RXAUTOBUFLEN-1)) | ||
| 181 | + { | ||
| 182 | + Retstr->strptr = (char *) RexxAllocateMemory(strlen(value)+1); | ||
| 183 | + strcpy(Retstr->strptr,value); | ||
| 184 | + } | ||
| 185 | + else | ||
| 186 | + { | ||
| 187 | + g_snprintf(Retstr->strptr,RXAUTOBUFLEN-1,"%s",value); | ||
| 188 | + } | ||
| 189 | + g_free(value); | ||
| 190 | + } | ||
| 191 | + else | ||
| 192 | + { | ||
| 193 | + *Retstr->strptr = 0; | ||
| 194 | + } | ||
| 195 | + | ||
| 196 | + Retstr->strlength = strlen(Retstr->strptr); | ||
| 197 | + | ||
| 198 | + } | ||
| 199 | + | ||
| 138 | static int REXXENTRY Rexx_IO_exit(RexxExitContext *context, int exitnumber, int subfunction, PEXIT parmBlock) | 200 | static int REXXENTRY Rexx_IO_exit(RexxExitContext *context, int exitnumber, int subfunction, PEXIT parmBlock) |
| 139 | { | 201 | { |
| 140 | - trace("%s call with ExitNumber: %d Subfunction: %d",__FUNCTION__,(int) exitnumber, (int) subfunction); | 202 | +// trace("%s call with ExitNumber: %d Subfunction: %d",__FUNCTION__,(int) exitnumber, (int) subfunction); |
| 141 | 203 | ||
| 142 | - if(subfunction == RXSIOSAY) | 204 | + switch(subfunction) |
| 143 | { | 205 | { |
| 144 | - GtkWidget *dialog = gtk_message_dialog_new( GTK_WINDOW(gtk_widget_get_toplevel(((struct rexx_application_data * )context->GetApplicationData())->widget)), | ||
| 145 | - GTK_DIALOG_DESTROY_WITH_PARENT, | ||
| 146 | - GTK_MESSAGE_INFO, | ||
| 147 | - GTK_BUTTONS_OK_CANCEL, | ||
| 148 | - "%s", (((RXSIOSAY_PARM *) parmBlock)->rxsio_string).strptr ); | 206 | + case RXSIOSAY: // SAY a line to STDOUT |
| 207 | + { | ||
| 208 | + struct rexx_application_data *data = (struct rexx_application_data *) context->GetApplicationData(); | ||
| 149 | 209 | ||
| 150 | - gtk_window_set_title(GTK_WINDOW(dialog), _( "Script message" ) ); | 210 | + GtkWidget *dialog = gtk_message_dialog_new( GTK_WINDOW(gtk_widget_get_toplevel(data->widget)), |
| 211 | + GTK_DIALOG_DESTROY_WITH_PARENT, | ||
| 212 | + GTK_MESSAGE_INFO, | ||
| 213 | + GTK_BUTTONS_OK_CANCEL, | ||
| 214 | + "%s", (((RXSIOSAY_PARM *) parmBlock)->rxsio_string).strptr ); | ||
| 151 | 215 | ||
| 152 | - if(gtk_dialog_run(GTK_DIALOG (dialog)) == GTK_RESPONSE_CANCEL) | ||
| 153 | - context->RaiseException0(Rexx_Error_Program_interrupted); | 216 | + gtk_window_set_title(GTK_WINDOW(dialog), _( "Script message" ) ); |
| 154 | 217 | ||
| 155 | - gtk_widget_destroy(dialog); | 218 | + if(data->trace) |
| 219 | + pw3270_trace_printf(data->trace,"%s\n",(((RXSIOSAY_PARM *) parmBlock)->rxsio_string).strptr); | ||
| 220 | + | ||
| 221 | + if(gtk_dialog_run(GTK_DIALOG (dialog)) == GTK_RESPONSE_CANCEL) | ||
| 222 | + context->RaiseException0(Rexx_Error_Program_interrupted); | ||
| 223 | + | ||
| 224 | + gtk_widget_destroy(dialog); | ||
| 225 | + } | ||
| 226 | + break; | ||
| 227 | + | ||
| 228 | + case RXSIOTRC: // Trace output | ||
| 229 | + { | ||
| 230 | + struct rexx_application_data *data = (struct rexx_application_data *) context->GetApplicationData(); | ||
| 231 | + lib3270_write_log(NULL, "rx3270", "%s", (((RXSIOTRC_PARM *) parmBlock)->rxsio_string).strptr); | ||
| 232 | + pw3270_trace_printf(get_trace_window(data),"%s\n",(((RXSIOTRC_PARM *) parmBlock)->rxsio_string).strptr); | ||
| 233 | + } | ||
| 234 | + break; | ||
| 235 | + | ||
| 236 | + case RXSIOTRD: // Read from char stream | ||
| 237 | + read_line((struct rexx_application_data *) context->GetApplicationData(), & (((RXSIODTR_PARM *) parmBlock)->rxsiodtr_retc) ); | ||
| 238 | + break; | ||
| 239 | + | ||
| 240 | + case RXSIODTR: // DEBUG read from char stream | ||
| 241 | + read_line((struct rexx_application_data *) context->GetApplicationData(), & (((RXSIODTR_PARM *) parmBlock)->rxsiodtr_retc) ); | ||
| 242 | + break; | ||
| 243 | + | ||
| 244 | + default: | ||
| 245 | + return RXEXIT_NOT_HANDLED; | ||
| 156 | 246 | ||
| 157 | - return RXEXIT_HANDLED; | ||
| 158 | } | 247 | } |
| 159 | 248 | ||
| 160 | - return RXEXIT_NOT_HANDLED; | 249 | + return RXEXIT_HANDLED; |
| 161 | } | 250 | } |
| 162 | 251 | ||
| 163 | static void call_rexx_script(GtkAction *action, GtkWidget *widget, const gchar *filename) | 252 | static void call_rexx_script(GtkAction *action, GtkWidget *widget, const gchar *filename) |
| 164 | { | 253 | { |
| 165 | const gchar * args = (const gchar *) g_object_get_data(G_OBJECT(action),"args"); | 254 | const gchar * args = (const gchar *) g_object_get_data(G_OBJECT(action),"args"); |
| 166 | 255 | ||
| 167 | - struct rexx_application_data appdata = { action, widget, filename }; | 256 | + struct rexx_application_data appdata; |
| 168 | 257 | ||
| 169 | RexxInstance * instance; | 258 | RexxInstance * instance; |
| 170 | RexxThreadContext * threadContext; | 259 | RexxThreadContext * threadContext; |
| 171 | RexxOption options[25]; | 260 | RexxOption options[25]; |
| 172 | RexxContextExit exits[2]; | 261 | RexxContextExit exits[2]; |
| 173 | 262 | ||
| 263 | + memset(&appdata,0,sizeof(appdata)); | ||
| 264 | + appdata.action = action; | ||
| 265 | + appdata.widget = widget; | ||
| 266 | + appdata.filename = filename; | ||
| 267 | + | ||
| 174 | memset(options,0,sizeof(options)); | 268 | memset(options,0,sizeof(options)); |
| 175 | memset(exits,0,sizeof(exits)); | 269 | memset(exits,0,sizeof(exits)); |
| 176 | 270 | ||
| @@ -185,9 +279,6 @@ | @@ -185,9 +279,6 @@ | ||
| 185 | options[1].optionName = APPLICATION_DATA; | 279 | options[1].optionName = APPLICATION_DATA; |
| 186 | options[1].option = (void *) &appdata; | 280 | options[1].option = (void *) &appdata; |
| 187 | 281 | ||
| 188 | -// options[0].optionName = LOAD_REQUIRED_LIBRARY; | ||
| 189 | -// options[0].option = "rx3270"; | ||
| 190 | - | ||
| 191 | rx3270_set_package_option(&options[2]); | 282 | rx3270_set_package_option(&options[2]); |
| 192 | 283 | ||
| 193 | options[3].optionName = EXTERNAL_CALL_PATH; | 284 | options[3].optionName = EXTERNAL_CALL_PATH; |
| @@ -277,6 +368,12 @@ | @@ -277,6 +368,12 @@ | ||
| 277 | 368 | ||
| 278 | instance->Terminate(); | 369 | instance->Terminate(); |
| 279 | 370 | ||
| 371 | + if(appdata.trace) | ||
| 372 | + { | ||
| 373 | + pw3270_trace_printf(appdata.trace,"%s","** Rexx script ends\n"); | ||
| 374 | + g_object_set_data(G_OBJECT(appdata.trace),"rexx_app_data",NULL); | ||
| 375 | + } | ||
| 376 | + | ||
| 280 | trace("%s ends",__FUNCTION__); | 377 | trace("%s ends",__FUNCTION__); |
| 281 | } | 378 | } |
| 282 | 379 |
src/plugins/rx3270/rxapimain.cc
| @@ -190,9 +190,6 @@ LIB3270_EXPORT void rx3270_set_package_option(RexxOption *option) | @@ -190,9 +190,6 @@ LIB3270_EXPORT void rx3270_set_package_option(RexxOption *option) | ||
| 190 | { | 190 | { |
| 191 | static const RexxLibraryPackage package = { "rx3270", &rx3270_package_entry }; | 191 | static const RexxLibraryPackage package = { "rx3270", &rx3270_package_entry }; |
| 192 | 192 | ||
| 193 | -// package.registeredName = "rx3270"; | ||
| 194 | -// package.table = ; | ||
| 195 | - | ||
| 196 | option->optionName = REGISTER_LIBRARY; | 193 | option->optionName = REGISTER_LIBRARY; |
| 197 | option->option = (void *) &package; | 194 | option->option = (void *) &package; |
| 198 | 195 |
src/plugins/rx3270/sample/clipboard.rex
src/pw3270/trace.c
| @@ -55,7 +55,8 @@ | @@ -55,7 +55,8 @@ | ||
| 55 | GtkWidget * entry; | 55 | GtkWidget * entry; |
| 56 | GtkWidget * button; | 56 | GtkWidget * button; |
| 57 | gchar **line; | 57 | gchar **line; |
| 58 | - gboolean * enabled; | 58 | + gboolean * enabled; |
| 59 | + gboolean destroy_on_close; | ||
| 59 | }; | 60 | }; |
| 60 | 61 | ||
| 61 | const GtkWindowClass * pw3270_trace_get_parent_class(void); | 62 | const GtkWindowClass * pw3270_trace_get_parent_class(void); |
| @@ -77,16 +78,20 @@ | @@ -77,16 +78,20 @@ | ||
| 77 | pw3270_trace * hwnd = PW3270_TRACE(window); | 78 | pw3270_trace * hwnd = PW3270_TRACE(window); |
| 78 | 79 | ||
| 79 | trace("%s",__FUNCTION__); | 80 | trace("%s",__FUNCTION__); |
| 81 | + | ||
| 82 | + if(hwnd->enabled) | ||
| 83 | + { | ||
| 84 | + if(*hwnd->line) | ||
| 85 | + g_free(*hwnd->line); | ||
| 80 | 86 | ||
| 81 | - if(*hwnd->line) | ||
| 82 | - g_free(*hwnd->line); | 87 | + *hwnd->line = g_strdup(gtk_entry_get_text(GTK_ENTRY(hwnd->entry))); |
| 83 | 88 | ||
| 84 | - *hwnd->line = g_strdup(gtk_entry_get_text(GTK_ENTRY(hwnd->entry))); | 89 | + gtk_widget_set_sensitive(hwnd->entry,FALSE); |
| 90 | + gtk_widget_set_sensitive(hwnd->button,FALSE); | ||
| 85 | 91 | ||
| 86 | - gtk_widget_set_sensitive(hwnd->entry,FALSE); | ||
| 87 | - gtk_widget_set_sensitive(hwnd->button,FALSE); | 92 | + *hwnd->enabled = FALSE; |
| 93 | + } | ||
| 88 | 94 | ||
| 89 | - *hwnd->enabled = FALSE; | ||
| 90 | } | 95 | } |
| 91 | 96 | ||
| 92 | #if GTK_CHECK_VERSION(3,0,0) | 97 | #if GTK_CHECK_VERSION(3,0,0) |
| @@ -96,9 +101,12 @@ static void destroy(GtkObject *widget) | @@ -96,9 +101,12 @@ static void destroy(GtkObject *widget) | ||
| 96 | #endif | 101 | #endif |
| 97 | { | 102 | { |
| 98 | pw3270_trace * hwnd = PW3270_TRACE(widget); | 103 | pw3270_trace * hwnd = PW3270_TRACE(widget); |
| 99 | - | ||
| 100 | - hwnd->line = NULL; | ||
| 101 | - *hwnd->enabled = FALSE; | 104 | + |
| 105 | + if(hwnd->line) | ||
| 106 | + *hwnd->line = NULL; | ||
| 107 | + | ||
| 108 | + if(hwnd->enabled) | ||
| 109 | + *hwnd->enabled = FALSE; | ||
| 102 | 110 | ||
| 103 | #if GTK_CHECK_VERSION(3,0,0) | 111 | #if GTK_CHECK_VERSION(3,0,0) |
| 104 | GTK_WIDGET_CLASS(pw3270_trace_parent_class)->destroy(widget); | 112 | GTK_WIDGET_CLASS(pw3270_trace_parent_class)->destroy(widget); |
| @@ -110,10 +118,19 @@ static void destroy(GtkObject *widget) | @@ -110,10 +118,19 @@ static void destroy(GtkObject *widget) | ||
| 110 | 118 | ||
| 111 | static gboolean delete_event(GtkWidget *widget, GdkEventAny *event) | 119 | static gboolean delete_event(GtkWidget *widget, GdkEventAny *event) |
| 112 | { | 120 | { |
| 113 | - pw3270_trace * hwnd = PW3270_TRACE(widget); | ||
| 114 | - trace("%s",__FUNCTION__); | ||
| 115 | - hwnd->line = NULL; | ||
| 116 | - *hwnd->enabled = FALSE; | 121 | + pw3270_trace * hwnd = PW3270_TRACE(widget); |
| 122 | + | ||
| 123 | + trace("%s destroy=%s",__FUNCTION__,hwnd->destroy_on_close ? "Yes" : "No"); | ||
| 124 | + | ||
| 125 | + if(hwnd->line) | ||
| 126 | + *hwnd->line = NULL; | ||
| 127 | + | ||
| 128 | + if(hwnd->enabled) | ||
| 129 | + *hwnd->enabled = FALSE; | ||
| 130 | + | ||
| 131 | + if(hwnd->destroy_on_close) | ||
| 132 | + return FALSE; | ||
| 133 | + | ||
| 117 | gtk_widget_hide(widget); | 134 | gtk_widget_hide(widget); |
| 118 | return TRUE; | 135 | return TRUE; |
| 119 | } | 136 | } |
| @@ -242,6 +259,14 @@ static void destroy(GtkObject *widget) | @@ -242,6 +259,14 @@ static void destroy(GtkObject *widget) | ||
| 242 | { | 259 | { |
| 243 | gtk_main_iteration(); | 260 | gtk_main_iteration(); |
| 244 | } | 261 | } |
| 262 | + | ||
| 263 | + hwnd->line = NULL; | ||
| 264 | + hwnd->enabled = NULL; | ||
| 245 | 265 | ||
| 246 | return line; | 266 | return line; |
| 247 | } | 267 | } |
| 268 | + | ||
| 269 | + LIB3270_EXPORT void pw3270_trace_set_destroy_on_close(GtkWidget *widget,gboolean on) | ||
| 270 | + { | ||
| 271 | + PW3270_TRACE(widget)->destroy_on_close = on; | ||
| 272 | + } |