From b93f900fc6dcf65e2ab5d91a8f23a9a923584596 Mon Sep 17 00:00:00 2001 From: Perry Werneck Date: Fri, 10 Jan 2020 09:28:01 -0300 Subject: [PATCH] Adjusting gettext use. --- .gitignore | 1 + src/dialogs/popups.c | 40 ++++++++++++++-------------------------- src/filetransfer/activity.c | 708 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ src/filetransfer/tables.c | 345 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++----------------------------------------------------------------------------------------------------------------------------------------------------------------------------- src/filetransfer/worker.c | 9 ++++----- src/terminal/callbacks.c | 11 ----------- 6 files changed, 545 insertions(+), 569 deletions(-) diff --git a/.gitignore b/.gitignore index ad961ae..a4cf954 100644 --- a/.gitignore +++ b/.gitignore @@ -53,6 +53,7 @@ glade/v3270.xml *test.glade* ValgrindOut.xml *.crl +*.orig *.patch *.sh *.conf diff --git a/src/dialogs/popups.c b/src/dialogs/popups.c index 1eb65ab..c598898 100644 --- a/src/dialogs/popups.c +++ b/src/dialogs/popups.c @@ -34,8 +34,7 @@ /*--[ Implement ]------------------------------------------------------------------------------------*/ - void v3270_popup_message(GtkWidget *widget, LIB3270_NOTIFY type , const gchar *title, const gchar *message, const gchar *text) - { + void v3270_popup_message(GtkWidget *widget, LIB3270_NOTIFY type , const gchar *title, const gchar *message, const gchar *text) { GtkWidget * dialog; GtkWidget * toplevel = NULL; GtkMessageType msgtype = GTK_MESSAGE_WARNING; @@ -47,8 +46,7 @@ if(!GTK_IS_WINDOW(toplevel)) toplevel = NULL; - if(type == LIB3270_NOTIFY_CRITICAL) - { + if(type == LIB3270_NOTIFY_CRITICAL) { msgtype = GTK_MESSAGE_ERROR; buttons = GTK_BUTTONS_CLOSE; } @@ -56,18 +54,13 @@ if(!title) title = _( "Error" ); - if(message) - { + if(message) { dialog = gtk_message_dialog_new_with_markup(GTK_WINDOW(toplevel),GTK_DIALOG_MODAL|GTK_DIALOG_DESTROY_WITH_PARENT,msgtype,buttons,"%s",message); if(text && *text) gtk_message_dialog_format_secondary_markup(GTK_MESSAGE_DIALOG(dialog),"%s",text); - } - else if(text && *text) - { + } else if(text && *text) { dialog = gtk_message_dialog_new_with_markup(GTK_WINDOW(toplevel),GTK_DIALOG_MODAL|GTK_DIALOG_DESTROY_WITH_PARENT,msgtype,buttons,"%s",text); - } - else - { + } else { dialog = gtk_message_dialog_new_with_markup(GTK_WINDOW(toplevel),GTK_DIALOG_MODAL|GTK_DIALOG_DESTROY_WITH_PARENT,msgtype,buttons,"%s",title); } @@ -78,8 +71,7 @@ } - void v3270_error_popup(GtkWidget *widget, const gchar *title, const gchar *summary, const gchar *body) - { + void v3270_error_popup(GtkWidget *widget, const gchar *title, const gchar *summary, const gchar *body) { GtkWidget * dialog = gtk_message_dialog_new_with_markup( GTK_WINDOW(gtk_widget_get_toplevel(widget)), @@ -101,8 +93,7 @@ } - void v3270_popup_gerror(GtkWidget *widget, GError *error, const gchar *title, const gchar *fmt, ...) - { + void v3270_popup_gerror(GtkWidget *widget, GError *error, const gchar *title, const gchar *fmt, ...) { // Format message. va_list arg_ptr; @@ -133,12 +124,11 @@ } - GtkResponseType v3270_popup_toggleable_dialog(GtkWidget *widget, V3270_TOGGLEABLE_DIALOG id, const gchar *title, const gchar *summary, const gchar *body, const gchar *first_button_text, ...) - { + GtkResponseType v3270_popup_toggleable_dialog(GtkWidget *widget, V3270_TOGGLEABLE_DIALOG id, const gchar *title, const gchar *summary, const gchar *body, const gchar *first_button_text, ...) { + GtkResponseType response = GTK_V3270(widget)->responses[id]; - if(response == GTK_RESPONSE_NONE) - { + if(response == GTK_RESPONSE_NONE) { GtkWidget * dialog = gtk_message_dialog_new( GTK_WINDOW(gtk_widget_get_toplevel(widget)), @@ -174,8 +164,7 @@ 0 ); - if(first_button_text) - { + if(first_button_text) { // From https://github.com/GNOME/gtk/blob/master/gtk/gtkdialog.c va_list args; const gchar* text; @@ -184,8 +173,7 @@ va_start(args, first_button_text); text = first_button_text; - while(text) - { + while(text) { response_id = va_arg(args, gint); gtk_dialog_add_button(GTK_DIALOG(dialog), text, response_id); @@ -202,8 +190,8 @@ gtk_widget_show_all(dialog); response = gtk_dialog_run(GTK_DIALOG(dialog)); - if(gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(dont_ask))) - { + if(gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(dont_ask))) { + GTK_V3270(widget)->responses[id] = response; g_object_notify_by_pspec(G_OBJECT(widget), GTK_V3270_GET_CLASS(widget)->responses[id]); v3270_emit_save_settings(widget); diff --git a/src/filetransfer/activity.c b/src/filetransfer/activity.c index f84b2c5..a83f7cb 100644 --- a/src/filetransfer/activity.c +++ b/src/filetransfer/activity.c @@ -37,376 +37,376 @@ * */ - #include - #include - #include "private.h" - #include +#include +#include +#include "private.h" +#include /*--[ Widget definition ]----------------------------------------------------------------------------*/ - struct _V3270FTActivityClass - { - GObjectClass parent_class; +struct _V3270FTActivityClass +{ + GObjectClass parent_class; - }; +}; - struct _V3270FTActivity - { - GObject parent; +struct _V3270FTActivity +{ + GObject parent; - /// @brief Transfer options. - LIB3270_FT_OPTION options; + /// @brief Transfer options. + LIB3270_FT_OPTION options; - /// @brief Values. - guint values[LIB3270_FT_VALUE_COUNT]; + /// @brief Values. + guint values[LIB3270_FT_VALUE_COUNT]; - /// @brief File names - struct { - gchar * local; - gchar * remote; - } file; + /// @brief File names + struct { + gchar * local; + gchar * remote; + } file; - }; +}; - enum - { - PROP_0, - PROP_LOCAL, - PROP_REMOTE - }; +enum +{ + PROP_0, + PROP_LOCAL, + PROP_REMOTE +}; - G_DEFINE_TYPE(V3270FTActivity, V3270FTActivity, G_TYPE_INITIALLY_UNOWNED); +G_DEFINE_TYPE(V3270FTActivity, V3270FTActivity, G_TYPE_INITIALLY_UNOWNED); /*--[ Implement ]------------------------------------------------------------------------------------*/ - static void dispose(GObject *object) - { - debug("activity::%s(%p)",__FUNCTION__,object); - - V3270FTActivity * activity = G_V3270_FT_ACTIVITY(object); - - g_free(activity->file.local); - g_free(activity->file.remote); - - G_OBJECT_CLASS(V3270FTActivity_parent_class)->dispose(object); - - } - - static void set_property(GObject *object, guint prop_id, const GValue *value, GParamSpec G_GNUC_UNUSED(*pspec)) - { - switch(prop_id) - { - case PROP_LOCAL: - v3270_ft_activity_set_local_filename(object,g_value_get_string(value)); - break; - - case PROP_REMOTE: - v3270_ft_activity_set_remote_filename(object,g_value_get_string(value)); - break; - } - - } - - static void get_property(GObject *object, guint prop_id, GValue *value, GParamSpec G_GNUC_UNUSED(*pspec)) - { - switch(prop_id) - { - case PROP_LOCAL: - g_value_set_string(value,v3270_ft_activity_get_local_filename(object)); - break; - - case PROP_REMOTE: - g_value_set_string(value,v3270_ft_activity_get_remote_filename(object)); - break; - } - } - - static void V3270FTActivity_class_init(V3270FTActivityClass *klass) - { - G_OBJECT_CLASS(klass)->dispose = dispose; - - G_OBJECT_CLASS(klass)->set_property = set_property; - G_OBJECT_CLASS(klass)->get_property = get_property; - - g_object_class_install_property( - G_OBJECT_CLASS(klass), - PROP_LOCAL, - g_param_spec_string ("local", "Local", - _( "Full path of local file" ), - FALSE, G_PARAM_READWRITE)); - - g_object_class_install_property( - G_OBJECT_CLASS(klass), - PROP_LOCAL, - g_param_spec_string ("remote", "remote", - _( "Full path of remote file" ), - FALSE, G_PARAM_READWRITE)); - - } - - static void V3270FTActivity_init(V3270FTActivity *widget) - { - widget->values[LIB3270_FT_VALUE_LRECL] = 0; - widget->values[LIB3270_FT_VALUE_BLKSIZE] = 0; - widget->values[LIB3270_FT_VALUE_PRIMSPACE] = 0; - widget->values[LIB3270_FT_VALUE_SECSPACE] = 0; - widget->values[LIB3270_FT_VALUE_DFT] = 4096; - } - - /** - * v3270_ft_activity_new: - * - * Creates an empty file transfer activity. - * - * Returns: a new #V3270FTActivity. - */ - LIB3270_EXPORT GObject * v3270_ft_activity_new() - { - return g_object_new(G_TYPE_V3270_FT_ACTIVITY, NULL); - } - - LIB3270_EXPORT GObject * v3270_ft_activity_new_from_filename(const gchar *filename) - { - GObject *activity = g_object_new(G_TYPE_V3270_FT_ACTIVITY, NULL); - - // Set local filename - v3270_ft_activity_set_local_filename(activity,filename); +static void dispose(GObject *object) +{ + debug("activity::%s(%p)",__FUNCTION__,object); + + V3270FTActivity * activity = G_V3270_FT_ACTIVITY(object); + + g_free(activity->file.local); + g_free(activity->file.remote); + + G_OBJECT_CLASS(V3270FTActivity_parent_class)->dispose(object); + +} + +static void set_property(GObject *object, guint prop_id, const GValue *value, GParamSpec G_GNUC_UNUSED(*pspec)) +{ + switch(prop_id) + { + case PROP_LOCAL: + v3270_ft_activity_set_local_filename(object,g_value_get_string(value)); + break; + + case PROP_REMOTE: + v3270_ft_activity_set_remote_filename(object,g_value_get_string(value)); + break; + } + +} + +static void get_property(GObject *object, guint prop_id, GValue *value, GParamSpec G_GNUC_UNUSED(*pspec)) +{ + switch(prop_id) + { + case PROP_LOCAL: + g_value_set_string(value,v3270_ft_activity_get_local_filename(object)); + break; + + case PROP_REMOTE: + g_value_set_string(value,v3270_ft_activity_get_remote_filename(object)); + break; + } +} + +static void V3270FTActivity_class_init(V3270FTActivityClass *klass) +{ + G_OBJECT_CLASS(klass)->dispose = dispose; + + G_OBJECT_CLASS(klass)->set_property = set_property; + G_OBJECT_CLASS(klass)->get_property = get_property; + + g_object_class_install_property( + G_OBJECT_CLASS(klass), + PROP_LOCAL, + g_param_spec_string ("local", "Local", + _( "Full path of local file" ), + FALSE, G_PARAM_READWRITE)); + + g_object_class_install_property( + G_OBJECT_CLASS(klass), + PROP_LOCAL, + g_param_spec_string ("remote", "remote", + _( "Full path of remote file" ), + FALSE, G_PARAM_READWRITE)); + +} + +static void V3270FTActivity_init(V3270FTActivity *widget) +{ + widget->values[LIB3270_FT_VALUE_LRECL] = 0; + widget->values[LIB3270_FT_VALUE_BLKSIZE] = 0; + widget->values[LIB3270_FT_VALUE_PRIMSPACE] = 0; + widget->values[LIB3270_FT_VALUE_SECSPACE] = 0; + widget->values[LIB3270_FT_VALUE_DFT] = 4096; +} - // Set options - LIB3270_FT_OPTION options = LIB3270_FT_OPTION_SEND; - size_t ix; - - for(ix = 0; v3270_text_file_extensions[ix]; ix++) - { - if(g_str_has_suffix(filename,v3270_text_file_extensions[ix])) - { - options |= (LIB3270_FT_OPTION_ASCII|LIB3270_FT_OPTION_CRLF|LIB3270_FT_OPTION_REMAP); - break; - } - } - - v3270_ft_activity_set_options(activity,options); - - // Set remote filename - g_autofree gchar * basename = g_path_get_basename(filename); - v3270_ft_activity_set_remote_filename(activity,basename); +/** +* v3270_ft_activity_new: +* +* Creates an empty file transfer activity. +* +* Returns: a new #V3270FTActivity. +*/ +LIB3270_EXPORT GObject * v3270_ft_activity_new() +{ + return g_object_new(G_TYPE_V3270_FT_ACTIVITY, NULL); +} + +LIB3270_EXPORT GObject * v3270_ft_activity_new_from_filename(const gchar *filename) +{ + GObject *activity = g_object_new(G_TYPE_V3270_FT_ACTIVITY, NULL); + + // Set local filename + v3270_ft_activity_set_local_filename(activity,filename); + + // Set options + LIB3270_FT_OPTION options = LIB3270_FT_OPTION_SEND; + size_t ix; + + for(ix = 0; v3270_text_file_extensions[ix]; ix++) + { + if(g_str_has_suffix(filename,v3270_text_file_extensions[ix])) + { + options |= (LIB3270_FT_OPTION_ASCII|LIB3270_FT_OPTION_CRLF|LIB3270_FT_OPTION_REMAP); + break; + } + } + + v3270_ft_activity_set_options(activity,options); + + // Set remote filename + g_autofree gchar * basename = g_path_get_basename(filename); + v3270_ft_activity_set_remote_filename(activity,basename); + + return activity; +} - return activity; - } +/** +* v3270_ft_activity_get_local_filename: +* @object: a #V3270FTActivity +* +* Get the full path of the local file. +* +* Returns: the local file path. +*/ +LIB3270_EXPORT const gchar * v3270_ft_activity_get_local_filename(const GObject *object) +{ + const gchar *ptr = G_V3270_FT_ACTIVITY(object)->file.local; + return (ptr ? ptr : ""); +} - /** - * v3270_ft_activity_get_local_filename: - * @object: a #V3270FTActivity - * - * Get the full path of the local file. - * - * Returns: the local file path. - */ - LIB3270_EXPORT const gchar * v3270_ft_activity_get_local_filename(const GObject *object) - { - const gchar *ptr = G_V3270_FT_ACTIVITY(object)->file.local; - return (ptr ? ptr : ""); - } - - /** - * v3270_ft_activity_get_remote_filename: - * @object: a #V3270FTActivity - * - * Get the host file name. - * - * Returns: the host file name. - */ - LIB3270_EXPORT const gchar * v3270_ft_activity_get_remote_filename(const GObject *object) - { - const gchar *ptr = G_V3270_FT_ACTIVITY(object)->file.remote; - return(ptr ? ptr : ""); - } - - LIB3270_EXPORT void v3270_ft_activity_set_local_filename(GObject *object, const gchar *filename) - { - gchar **ptr = & G_V3270_FT_ACTIVITY(object)->file.local; - - g_free(*ptr); - *ptr = g_strdup(filename); - } - - LIB3270_EXPORT void v3270_ft_activity_set_remote_filename(GObject *object, const gchar *filename) - { - gchar **ptr = & G_V3270_FT_ACTIVITY(object)->file.remote; - - g_free(*ptr); - *ptr = g_strdup(filename); - } - - LIB3270_EXPORT void v3270_ft_activity_set_options(GObject * object, LIB3270_FT_OPTION options) - { - G_V3270_FT_ACTIVITY(object)->options = options; - } - - LIB3270_EXPORT LIB3270_FT_OPTION v3270_ft_activity_get_options(const GObject *object) - { - return G_V3270_FT_ACTIVITY(object)->options; - } - - guint v3270_ft_activity_get_value(const GObject * object, LIB3270_FT_VALUE id) - { - return G_V3270_FT_ACTIVITY(object)->values[id]; - } - - void v3270_ft_activity_set_value(GObject * object, LIB3270_FT_VALUE id, guint value) - { - G_V3270_FT_ACTIVITY(object)->values[id] = value; - } - - static void element_start(GMarkupParseContext G_GNUC_UNUSED(*context), const gchar *element_name, const gchar **names,const gchar **values, V3270FTActivity *activity, GError **error) - { - size_t ix; - - debug("%s(%s)",__FUNCTION__, element_name); - if(!g_ascii_strcasecmp(element_name,"file")) - { - const gchar *type; - const gchar *path; - - if(!g_markup_collect_attributes( - element_name,names,values,error, - G_MARKUP_COLLECT_STRING, "type", &type, - G_MARKUP_COLLECT_STRING, "path", &path, - G_MARKUP_COLLECT_INVALID - )) { - - return; - - } - - if(g_ascii_strcasecmp(type,"local") == 0) - v3270_ft_activity_set_local_filename(G_OBJECT(activity),path); - else if(g_ascii_strcasecmp(type,"remote") == 0) - v3270_ft_activity_set_remote_filename(G_OBJECT(activity),path); - - } - else if(!g_ascii_strcasecmp(element_name,"option")) - { - const gchar *name; - const gchar *value; - - if(!g_markup_collect_attributes( - element_name,names,values,error, - G_MARKUP_COLLECT_STRING, "name", &name, - G_MARKUP_COLLECT_STRING, "value", &value, - G_MARKUP_COLLECT_INVALID - )) { - - return; - - } - - debug("%s.%s(%s,%s)",__FUNCTION__, element_name, name, value); - - for(ix = 0; v3270_activity_list_options[ix].name; ix++) - { - if(! (g_ascii_strcasecmp(name,v3270_activity_list_options[ix].name) || g_ascii_strcasecmp(value,v3270_activity_list_options[ix].value)) ) - { - activity->options |= v3270_activity_list_options[ix].option; - debug("Setting option %s.%s(%08lx) =%08lx", v3270_activity_list_options[ix].name, v3270_activity_list_options[ix].value, (unsigned int) v3270_activity_list_options[ix].option,(unsigned int) activity->options) - break; - } - } - - } - else if(!g_ascii_strcasecmp(element_name,"parameter")) - { - const gchar *name; - const gchar *value; - - if(!g_markup_collect_attributes( - element_name,names,values,error, - G_MARKUP_COLLECT_STRING, "name", &name, - G_MARKUP_COLLECT_STRING, "value", &value, - G_MARKUP_COLLECT_INVALID - )) { - - return; - - } - - debug("%s.%s(%s)",__FUNCTION__, element_name, name, value); - - for(ix=0;ixvalues[ix] = atoi(value); - break; - } - } - - } - - } - - void v3270_ft_activity_set_from_context(GObject * activity, GMarkupParseContext * context) - { - static const GMarkupParser parser = { - (void (*)(GMarkupParseContext *, const gchar *, const gchar **, const gchar **, gpointer, GError **)) element_start, - (void (*)(GMarkupParseContext *, const gchar *, gpointer, GError **)) NULL, - (void (*)(GMarkupParseContext *, const gchar *, gsize, gpointer, GError **)) NULL, - (void (*)(GMarkupParseContext *, const gchar *, gsize, gpointer, GError **)) NULL, - (void (*)(GMarkupParseContext *, GError *, gpointer)) NULL - }; - - G_V3270_FT_ACTIVITY(activity)->options = 0; - - g_markup_parse_context_push(context,&parser,activity); - - } - - LIB3270_EXPORT H3270FT * v3270_ft_activity_begin_transfer(GObject * object, H3270 *hSession, const char **message) - { - V3270FTActivity * activity = G_V3270_FT_ACTIVITY(object); - - return lib3270_ft_new( - hSession, - activity->options, - activity->file.local, - activity->file.remote, - activity->values[LIB3270_FT_VALUE_LRECL], - activity->values[LIB3270_FT_VALUE_BLKSIZE], - activity->values[LIB3270_FT_VALUE_PRIMSPACE], - activity->values[LIB3270_FT_VALUE_SECSPACE], - activity->values[LIB3270_FT_VALUE_DFT], - message - ); - - } - - LIB3270_EXPORT void v3270_ft_activity_xml_encode(GObject *object, GString *str) - { - g_return_if_fail(G_IS_V3270_FT_ACTIVITY(object)); - - size_t ix; - V3270FTActivity * activity = G_V3270_FT_ACTIVITY(object); - - g_string_append_printf( - str, - "\t\n\t\t\n\t\t\n", - activity->file.local, - activity->file.remote - ); - - for(ix = 0; v3270_activity_list_options[ix].name; ix++) - { - if((activity->options & v3270_activity_list_options[ix].option) == v3270_activity_list_options[ix].option) - g_string_append_printf(str,"\t\t\n"); - - } +/** +* v3270_ft_activity_get_remote_filename: +* @object: a #V3270FTActivity +* +* Get the host file name. +* +* Returns: the host file name. +*/ +LIB3270_EXPORT const gchar * v3270_ft_activity_get_remote_filename(const GObject *object) +{ + const gchar *ptr = G_V3270_FT_ACTIVITY(object)->file.remote; + return(ptr ? ptr : ""); +} + +LIB3270_EXPORT void v3270_ft_activity_set_local_filename(GObject *object, const gchar *filename) +{ + gchar **ptr = & G_V3270_FT_ACTIVITY(object)->file.local; + + g_free(*ptr); + *ptr = g_strdup(filename); +} + +LIB3270_EXPORT void v3270_ft_activity_set_remote_filename(GObject *object, const gchar *filename) +{ + gchar **ptr = & G_V3270_FT_ACTIVITY(object)->file.remote; + + g_free(*ptr); + *ptr = g_strdup(filename); +} + +LIB3270_EXPORT void v3270_ft_activity_set_options(GObject * object, LIB3270_FT_OPTION options) +{ + G_V3270_FT_ACTIVITY(object)->options = options; +} + +LIB3270_EXPORT LIB3270_FT_OPTION v3270_ft_activity_get_options(const GObject *object) +{ + return G_V3270_FT_ACTIVITY(object)->options; +} + +guint v3270_ft_activity_get_value(const GObject * object, LIB3270_FT_VALUE id) +{ + return G_V3270_FT_ACTIVITY(object)->values[id]; +} + +void v3270_ft_activity_set_value(GObject * object, LIB3270_FT_VALUE id, guint value) +{ + G_V3270_FT_ACTIVITY(object)->values[id] = value; +} + +static void element_start(GMarkupParseContext G_GNUC_UNUSED(*context), const gchar *element_name, const gchar **names,const gchar **values, V3270FTActivity *activity, GError **error) +{ + size_t ix; + + debug("%s(%s)",__FUNCTION__, element_name); + if(!g_ascii_strcasecmp(element_name,"file")) + { + const gchar *type; + const gchar *path; + + if(!g_markup_collect_attributes( + element_name,names,values,error, + G_MARKUP_COLLECT_STRING, "type", &type, + G_MARKUP_COLLECT_STRING, "path", &path, + G_MARKUP_COLLECT_INVALID + )) { + + return; + + } + + if(g_ascii_strcasecmp(type,"local") == 0) + v3270_ft_activity_set_local_filename(G_OBJECT(activity),path); + else if(g_ascii_strcasecmp(type,"remote") == 0) + v3270_ft_activity_set_remote_filename(G_OBJECT(activity),path); + + } + else if(!g_ascii_strcasecmp(element_name,"option")) + { + const gchar *name; + const gchar *value; + + if(!g_markup_collect_attributes( + element_name,names,values,error, + G_MARKUP_COLLECT_STRING, "name", &name, + G_MARKUP_COLLECT_STRING, "value", &value, + G_MARKUP_COLLECT_INVALID + )) { + + return; + + } + + debug("%s.%s(%s,%s)",__FUNCTION__, element_name, name, value); + + for(ix = 0; v3270_activity_list_options[ix].name; ix++) + { + if(! (g_ascii_strcasecmp(name,v3270_activity_list_options[ix].name) || g_ascii_strcasecmp(value,v3270_activity_list_options[ix].value)) ) + { + activity->options |= v3270_activity_list_options[ix].option; + debug("Setting option %s.%s(%08lx) =%08lx", v3270_activity_list_options[ix].name, v3270_activity_list_options[ix].value, (unsigned int) v3270_activity_list_options[ix].option,(unsigned int) activity->options) + break; + } + } + + } + else if(!g_ascii_strcasecmp(element_name,"parameter")) + { + const gchar *name; + const gchar *value; + + if(!g_markup_collect_attributes( + element_name,names,values,error, + G_MARKUP_COLLECT_STRING, "name", &name, + G_MARKUP_COLLECT_STRING, "value", &value, + G_MARKUP_COLLECT_INVALID + )) { + + return; + + } + + debug("%s.%s(%s)",__FUNCTION__, element_name, name, value); + + for(ix=0; ixvalues[ix] = atoi(value); + break; + } + } + + } + +} + +void v3270_ft_activity_set_from_context(GObject * activity, GMarkupParseContext * context) +{ + static const GMarkupParser parser = { + (void (*)(GMarkupParseContext *, const gchar *, const gchar **, const gchar **, gpointer, GError **)) element_start, + (void (*)(GMarkupParseContext *, const gchar *, gpointer, GError **)) NULL, + (void (*)(GMarkupParseContext *, const gchar *, gsize, gpointer, GError **)) NULL, + (void (*)(GMarkupParseContext *, const gchar *, gsize, gpointer, GError **)) NULL, + (void (*)(GMarkupParseContext *, GError *, gpointer)) NULL + }; + + G_V3270_FT_ACTIVITY(activity)->options = 0; + + g_markup_parse_context_push(context,&parser,activity); + +} + +LIB3270_EXPORT H3270FT * v3270_ft_activity_begin_transfer(GObject * object, H3270 *hSession, const char **message) +{ + V3270FTActivity * activity = G_V3270_FT_ACTIVITY(object); + + return lib3270_ft_new( + hSession, + activity->options, + activity->file.local, + activity->file.remote, + activity->values[LIB3270_FT_VALUE_LRECL], + activity->values[LIB3270_FT_VALUE_BLKSIZE], + activity->values[LIB3270_FT_VALUE_PRIMSPACE], + activity->values[LIB3270_FT_VALUE_SECSPACE], + activity->values[LIB3270_FT_VALUE_DFT], + message + ); + +} + +LIB3270_EXPORT void v3270_ft_activity_xml_encode(GObject *object, GString *str) +{ + g_return_if_fail(G_IS_V3270_FT_ACTIVITY(object)); + + size_t ix; + V3270FTActivity * activity = G_V3270_FT_ACTIVITY(object); + + g_string_append_printf( + str, + "\t\n\t\t\n\t\t\n", + activity->file.local, + activity->file.remote + ); + + for(ix = 0; v3270_activity_list_options[ix].name; ix++) + { + if((activity->options & v3270_activity_list_options[ix].option) == v3270_activity_list_options[ix].option) + g_string_append_printf(str,"\t\t\n"); + +} diff --git a/src/filetransfer/tables.c b/src/filetransfer/tables.c index 2b6a07b..a95ea31 100644 --- a/src/filetransfer/tables.c +++ b/src/filetransfer/tables.c @@ -28,207 +28,206 @@ * */ - #include - #include "private.h" +#include +#include "private.h" /*--[ Globals ]--------------------------------------------------------------------------------------*/ const struct v3270ft_option ft_option[NUM_OPTIONS_WIDGETS] = { - // Transfer options - { - LIB3270_FT_OPTION_ASCII, - "ascii", - N_("_Text file"), - N_( "Check this if the file consists of character data only.") - }, - { - LIB3270_FT_OPTION_CRLF, - "crlf", - N_("_ASCII text"), + // Transfer options + { + LIB3270_FT_OPTION_ASCII, + "ascii", + N_("_Text file"), + N_( "Check this if the file consists of character data only.") + }, + { + LIB3270_FT_OPTION_CRLF, + "crlf", + N_("_ASCII text"), #ifdef _WIN32 - N_( "Following the convention for ASCII text files, CR/LF pairs are used to terminate records in the PC file, and a CTRL-Z (x'1A') marks the end of file.") + N_( "Following the convention for ASCII text files, CR/LF pairs are used to terminate records in the PC file, and a CTRL-Z (x'1A') marks the end of file.") #else - N_( "Following the convention for ASCII text files, LF is used to terminate records in the PC file.") + N_( "Following the convention for ASCII text files, LF is used to terminate records in the PC file.") #endif // _WIN32 - }, - { - LIB3270_FT_OPTION_APPEND, - "append", - N_("A_ppend to file"), - N_( "Appends the source file to the destination file.") - }, - { - LIB3270_FT_OPTION_REMAP, - "remap", - N_("Re_map ASCII Characters."), - N_("Remap the text to ensure maximum compatibility between the workstation's character set and encoding and the host's EBCDIC code page.") - }, - - // Record format - { - LIB3270_FT_RECORD_FORMAT_DEFAULT, - "recfm.default", - N_("Default"), - N_("Use host default record format.") - }, - { - LIB3270_FT_RECORD_FORMAT_FIXED, - "recfm.fixed", - N_("Fixed"), - N_("Creates a file with fixed-length records.") - }, - { - LIB3270_FT_RECORD_FORMAT_VARIABLE, - "recfm.variable", - N_("Variable"), - N_("Creates a file with variable-length records.") - }, - { - LIB3270_FT_RECORD_FORMAT_UNDEFINED, - "recfm.undefined", - N_("Undefined"), - N_("Creates a file with undefined-length records (TSO hosts only).") - }, - - // Space allocation units - { - LIB3270_FT_ALLOCATION_UNITS_DEFAULT, - "units.default", - N_("Default"), - NULL - }, - { - LIB3270_FT_ALLOCATION_UNITS_TRACKS, - "units.tracks", - N_("Tracks"), - NULL - }, - { - LIB3270_FT_ALLOCATION_UNITS_CYLINDERS, - "units.cylinders", - N_("Cylinders"), - NULL - }, - { - LIB3270_FT_ALLOCATION_UNITS_AVBLOCK, - "units.avblock", - N_("Avblock"), - NULL - }, + }, + { + LIB3270_FT_OPTION_APPEND, + "append", + N_("A_ppend to file"), + N_( "Appends the source file to the destination file.") + }, + { + LIB3270_FT_OPTION_REMAP, + "remap", + N_("Re_map ASCII Characters."), + N_("Remap the text to ensure maximum compatibility between the workstation's character set and encoding and the host's EBCDIC code page.") + }, + + // Record format + { + LIB3270_FT_RECORD_FORMAT_DEFAULT, + "recfm.default", + N_("Default"), + N_("Use host default record format.") + }, + { + LIB3270_FT_RECORD_FORMAT_FIXED, + "recfm.fixed", + N_("Fixed"), + N_("Creates a file with fixed-length records.") + }, + { + LIB3270_FT_RECORD_FORMAT_VARIABLE, + "recfm.variable", + N_("Variable"), + N_("Creates a file with variable-length records.") + }, + { + LIB3270_FT_RECORD_FORMAT_UNDEFINED, + "recfm.undefined", + N_("Undefined"), + N_("Creates a file with undefined-length records (TSO hosts only).") + }, + + // Space allocation units + { + LIB3270_FT_ALLOCATION_UNITS_DEFAULT, + "units.default", + N_("Default"), + NULL + }, + { + LIB3270_FT_ALLOCATION_UNITS_TRACKS, + "units.tracks", + N_("Tracks"), + NULL + }, + { + LIB3270_FT_ALLOCATION_UNITS_CYLINDERS, + "units.cylinders", + N_("Cylinders"), + NULL + }, + { + LIB3270_FT_ALLOCATION_UNITS_AVBLOCK, + "units.avblock", + N_("Avblock"), + NULL + }, }; const struct v3270ft_type ft_type[] = { - { - LIB3270_FT_OPTION_SEND, - "send", - "binary", - N_("Send file") - }, - { - LIB3270_FT_OPTION_RECEIVE, - "receive", - "binary", - N_("Receive file") - }, - { - LIB3270_FT_OPTION_SEND|LIB3270_FT_OPTION_ASCII|LIB3270_FT_OPTION_CRLF|LIB3270_FT_OPTION_REMAP, - "send", - "text", - N_("Send text file") - }, - { - LIB3270_FT_OPTION_RECEIVE|LIB3270_FT_OPTION_ASCII|LIB3270_FT_OPTION_CRLF|LIB3270_FT_OPTION_REMAP, - "receive", - "text", - N_("Receive text file") - } + { + LIB3270_FT_OPTION_SEND, + "send", + "binary", + N_("Send file") + }, + { + LIB3270_FT_OPTION_RECEIVE, + "receive", + "binary", + N_("Receive file") + }, + { + LIB3270_FT_OPTION_SEND|LIB3270_FT_OPTION_ASCII|LIB3270_FT_OPTION_CRLF|LIB3270_FT_OPTION_REMAP, + "send", + "text", + N_("Send text file") + }, + { + LIB3270_FT_OPTION_RECEIVE|LIB3270_FT_OPTION_ASCII|LIB3270_FT_OPTION_CRLF|LIB3270_FT_OPTION_REMAP, + "receive", + "text", + N_("Receive text file") + } }; const struct v3270ft_value ft_value[] = { - { - // LIB3270_FT_VALUE_LRECL - "lrecl", - 0, 32760, - N_( "Record Length" ), - N_( "Specifies the logical record length (n) for a data set consisting of fixed length records or the maximum logical record length for a data set consisting of variable length records." ) - }, - - - { - // LIB3270_FT_VALUE_BLKSIZE - "blksize", - 0,32760, - N_( "Block size" ), - N_( "Specifies the block size (n) for a new data set. For data sets containing fixed " \ - "length records, the block size must be a multiple of the record length. " \ - "For data sets containing variable length records, the block size must be " \ - "greater than or equal to the record length plus four bytes. The block size " \ - "must not exceed the track length of the device on which the data set resides." ) - }, - - { - // LIB3270_FT_VALUE_PRIMSPACE - "primary", - 0,99999, - N_( "Primary space" ), - N_( "Primary allocation for a file created on a TSO host.\nThe units are given by the space allocation units option." ) - }, - - { - // LIB3270_FT_VALUE_SECSPACE - "secondary", - 0,99999, - N_( "Secondary space" ), - N_( "Secondary allocation for a file created on a TSO host.\nThe units are given by the space allocation units option." ) - }, - - { - // LIB3270_FT_VALUE_DFT - "dft", - 0,99999, - N_( "DFT B_uffer size" ), - N_("Specifies the default buffer size for DFT IND$FILE file transfers.") - }, + { + // LIB3270_FT_VALUE_LRECL + "lrecl", + 0, 32760, + N_( "Record Length" ), + N_( "Specifies the logical record length (n) for a data set consisting of fixed length records or the maximum logical record length for a data set consisting of variable length records." ) + }, + + + { + // LIB3270_FT_VALUE_BLKSIZE + "blksize", + 0,32760, + N_( "Block size" ), + N_( "Specifies the block size (n) for a new data set. For data sets containing fixed " \ + "length records, the block size must be a multiple of the record length. " \ + "For data sets containing variable length records, the block size must be " \ + "greater than or equal to the record length plus four bytes. The block size " \ + "must not exceed the track length of the device on which the data set resides." ) + }, + + { + // LIB3270_FT_VALUE_PRIMSPACE + "primary", + 0,99999, + N_( "Primary space" ), + N_( "Primary allocation for a file created on a TSO host.\nThe units are given by the space allocation units option." ) + }, + + { + // LIB3270_FT_VALUE_SECSPACE + "secondary", + 0,99999, + N_( "Secondary space" ), + N_( "Secondary allocation for a file created on a TSO host.\nThe units are given by the space allocation units option." ) + }, + + { + // LIB3270_FT_VALUE_DFT + "dft", + 0,99999, + N_( "DFT B_uffer size" ), + N_("Specifies the default buffer size for DFT IND$FILE file transfers.") + }, }; const struct v3270_activity_list_option v3270_activity_list_options[] = { - { LIB3270_FT_OPTION_RECEIVE, "type", "receive" }, - { LIB3270_FT_OPTION_ASCII, "format", "ascii" }, - { LIB3270_FT_OPTION_CRLF, "format", "crlf" }, - { LIB3270_FT_OPTION_APPEND, "format", "append" }, - { LIB3270_FT_OPTION_REMAP, "format", "remap" }, - { LIB3270_FT_OPTION_UNIX, "file-format", "unix" }, - { LIB3270_FT_RECORD_FORMAT_FIXED, "record-format", "fixed" }, - { LIB3270_FT_RECORD_FORMAT_VARIABLE, "record-format", "variable" }, - { LIB3270_FT_RECORD_FORMAT_UNDEFINED, "record-format", "undefined" }, - { LIB3270_FT_ALLOCATION_UNITS_TRACKS, "units", "tracks" }, - { LIB3270_FT_ALLOCATION_UNITS_CYLINDERS, "units", "cylinders" }, - { LIB3270_FT_ALLOCATION_UNITS_AVBLOCK, "units", "avblock" }, - { 0, NULL, NULL } + { LIB3270_FT_OPTION_RECEIVE, "type", "receive" }, + { LIB3270_FT_OPTION_ASCII, "format", "ascii" }, + { LIB3270_FT_OPTION_CRLF, "format", "crlf" }, + { LIB3270_FT_OPTION_APPEND, "format", "append" }, + { LIB3270_FT_OPTION_REMAP, "format", "remap" }, + { LIB3270_FT_OPTION_UNIX, "file-format", "unix" }, + { LIB3270_FT_RECORD_FORMAT_FIXED, "record-format", "fixed" }, + { LIB3270_FT_RECORD_FORMAT_VARIABLE, "record-format", "variable" }, + { LIB3270_FT_RECORD_FORMAT_UNDEFINED, "record-format", "undefined" }, + { LIB3270_FT_ALLOCATION_UNITS_TRACKS, "units", "tracks" }, + { LIB3270_FT_ALLOCATION_UNITS_CYLINDERS, "units", "cylinders" }, + { LIB3270_FT_ALLOCATION_UNITS_AVBLOCK, "units", "avblock" }, + { 0, NULL, NULL } }; const struct v3270_ft_worker_field v3270_ft_worker_fields[PROGRESS_FIELD_COUNT] = { - { N_("Local:"), N_("Path and name of the local file") }, - { N_("Remote:"), N_("The name of the file in the host") }, - { N_("Total:"), N_("Total bytes to transfer") }, - { N_("Current:"), N_("Current transfer position") }, - { N_("Speed:"), N_("Transfer speed") }, - { N_("ETA:"), N_("Estimated transfer arrival") } + { N_("Local:"), N_("Path and name of the local file") }, + { N_("Remote:"), N_("The name of the file in the host") }, + { N_("Total:"), N_("Total bytes to transfer") }, + { N_("Current:"), N_("Current transfer position") }, + { N_("Speed:"), N_("Transfer speed") }, + { N_("ETA:"), N_("Estimated transfer arrival") } }; -const gchar * v3270_text_file_extensions[] = -{ - ".txt", - ".c", - ".h", - NULL +const gchar * v3270_text_file_extensions[] = { + ".txt", + ".c", + ".h", + NULL }; diff --git a/src/filetransfer/worker.c b/src/filetransfer/worker.c index c136925..c13108f 100644 --- a/src/filetransfer/worker.c +++ b/src/filetransfer/worker.c @@ -367,12 +367,11 @@ gtk_entry_set_text(cfg->worker->field[PROGRESS_FIELD_ETA],""); - const LIB3270_FT_MESSAGE * ftMessage = lib3270_translate_ft_message(cfg->msg); if(ftMessage) { - description = ftMessage->description; + description = dgettext(lib3270_get_translation_domain(),ftMessage->description); if(ftMessage->failed) cfg->signal = V3270_WORKER_TRANSFER_FAILED_SIGNAL; @@ -589,14 +588,14 @@ static gboolean do_timer(V3270FTWorker *worker) { if(!ft) { if(!message) - message = N_("Can't start file transfer session"); + message = _("Can't start file transfer session"); - gtk_progress_bar_set_text(worker->pbar,g_dgettext(PACKAGE_NAME,message)); + gtk_progress_bar_set_text(worker->pbar,message); pulse_stop(worker); // Emit "transfer failed" - g_signal_emit(GTK_WIDGET(widget),v3270_worker_signals[V3270_WORKER_TRANSFER_FAILED_SIGNAL], 0, g_dgettext(PACKAGE_NAME,message), NULL); + g_signal_emit(GTK_WIDGET(widget),v3270_worker_signals[V3270_WORKER_TRANSFER_FAILED_SIGNAL], 0, message, NULL); // Emit "no transfer" ft_state_changed(worker->hSession, LIB3270_FT_STATE_NONE, _("No transfer in progress"), widget); diff --git a/src/terminal/callbacks.c b/src/terminal/callbacks.c index 087cb00..772724b 100644 --- a/src/terminal/callbacks.c +++ b/src/terminal/callbacks.c @@ -45,17 +45,6 @@ #include #include -/** - * SECTION: v3270 - * @title: Virtual 3270 widget - * @short_description: The virtual 3270 terminal widget. - * - * Manages lib3270 callbacks. - * - */ - -/*--[ Widget definition ]----------------------------------------------------------------------------*/ - /*--[ Implement ]------------------------------------------------------------------------------------*/ static void set_timer(H3270 *session, unsigned char on) -- libgit2 0.21.2