[LIBREPORT PATCH 1/3] typo fix
by Jiri Moskovcak
---
src/gui-wizard-gtk/wizard.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/src/gui-wizard-gtk/wizard.c b/src/gui-wizard-gtk/wizard.c
index 6ec3c04..9e7929c 100644
--- a/src/gui-wizard-gtk/wizard.c
+++ b/src/gui-wizard-gtk/wizard.c
@@ -2293,7 +2293,7 @@ static char *get_next_processed_event(GList **events_list)
*events_list = g_list_concat(expanded_list, *events_list);
else
{
- VERB2 log("No event was expanded, will continue continue with the next one.");
+ VERB2 log("No event was expanded, will continue with the next one.");
/* no expanded event try the next event */
return get_next_processed_event(events_list);
}
--
1.7.12.1
11 years, 7 months
[LIBREPORT PATCH] don't force the minimal rating trac#854
by Jiri Moskovcak
---
src/gui-wizard-gtk/wizard.c | 6 +++++-
src/lib/event_config.c | 1 -
2 files changed, 5 insertions(+), 2 deletions(-)
diff --git a/src/gui-wizard-gtk/wizard.c b/src/gui-wizard-gtk/wizard.c
index 6ec3c04..9a211e3 100644
--- a/src/gui-wizard-gtk/wizard.c
+++ b/src/gui-wizard-gtk/wizard.c
@@ -2293,7 +2293,7 @@ static char *get_next_processed_event(GList **events_list)
*events_list = g_list_concat(expanded_list, *events_list);
else
{
- VERB2 log("No event was expanded, will continue continue with the next one.");
+ VERB2 log("No event was expanded, will continue with the next one.");
/* no expanded event try the next event */
return get_next_processed_event(events_list);
}
@@ -2412,6 +2412,10 @@ static char *setup_next_processed_event(GList **events_list)
{
/* No next event, go to progress page and finish */
gtk_label_set_text(g_lbl_event_log, _("Processing finished."));
+ /* we don't know the result of the previous event here
+ * so at least hide the spinner, because we're obviously finished
+ */
+ gtk_widget_hide(GTK_WIDGET(g_spinner_event_log));
update_gui_on_finished_reporting();
return NULL;
}
diff --git a/src/lib/event_config.c b/src/lib/event_config.c
index fda79bc..e766470 100644
--- a/src/lib/event_config.c
+++ b/src/lib/event_config.c
@@ -29,7 +29,6 @@ event_option_t *new_event_option(void)
event_config_t *new_event_config(void)
{
event_config_t *e = xzalloc(sizeof(event_config_t));
- e->ec_minimal_rating = 3;
return e;
}
--
1.7.12.1
11 years, 7 months
[PATCH RFC] reporter-bz: make BZ comment format configurable
by Denys Vlasenko
Hi,
The patch compiles and works, but it's not meant to be committed as-is,
discussion is definitely needed.
--
vda
diff -urp libreport.7/libreport.spec.in libreport.9/libreport.spec.in
--- libreport.7/libreport.spec.in 2012-10-25 11:11:06.000000000 +0200
+++ libreport.9/libreport.spec.in 2012-11-07 13:24:46.573794037 +0100
@@ -362,6 +362,7 @@ gtk-update-icon-cache %{_datadir}/icons/
%files plugin-bugzilla
%defattr(-,root,root,-)
%config(noreplace) %{_sysconfdir}/libreport/plugins/bugzilla.conf
+%config(noreplace) %{_sysconfdir}/libreport/plugins/bugzilla_format.conf
%{_sysconfdir}/libreport/events/report_Bugzilla.xml
%config(noreplace) %{_sysconfdir}/libreport/events/report_Bugzilla.conf
%config(noreplace) %{_sysconfdir}/libreport/events.d/bugzilla_event.conf
diff -urp libreport.7/src/plugins/Makefile.am libreport.9/src/plugins/Makefile.am
--- libreport.7/src/plugins/Makefile.am 2012-10-04 13:13:34.000000000 +0200
+++ libreport.9/src/plugins/Makefile.am 2012-11-07 13:25:25.591878189 +0100
@@ -23,7 +23,7 @@ reportpluginsconfdir = $(REPORT_PLUGINS_
reporters_plugin_conf =
if BUILD_BUGZILLA
-reporters_plugin_conf += bugzilla.conf
+reporters_plugin_conf += bugzilla.conf bugzilla_format.conf
endif
dist_reportpluginsconf_DATA = $(reporters_plugin_conf) \
diff -urp libreport.7/src/plugins/reporter-bugzilla.c libreport.9/src/plugins/reporter-bugzilla.c
--- libreport.7/src/plugins/reporter-bugzilla.c 2012-11-05 22:34:53.885310748 +0100
+++ libreport.9/src/plugins/reporter-bugzilla.c 2012-11-07 13:48:46.787219126 +0100
@@ -21,6 +21,266 @@
#include "abrt_xmlrpc.h"
#include "rhbz.h"
+struct section_t {
+ char *name;
+ GList *items;
+};
+typedef struct section_t section_t;
+
+static
+GList* split_string_on_char(const char *str, char ch)
+{
+ GList *list = NULL;
+ for (;;)
+ {
+ const char *delim = strchrnul(str, ch);
+ list = g_list_prepend(list, xstrndup(str, delim - str));
+ if (*delim == '\0')
+ break;
+ str = delim + 1;
+ }
+ return g_list_reverse(list);
+}
+
+static
+GList* load_bzrep_conf_file(const char *path)
+{
+ FILE *fp = stdin;
+ if (strcmp(path, "-") != 0)
+ {
+ fp = fopen(path, "r");
+ if (!fp)
+ return NULL;
+ }
+
+ GList *sections = NULL;
+
+ char *line;
+ while ((line = xmalloc_fgetline(fp)) != NULL)
+ {
+ /* Skip comments and empty lines */
+ char first = *skip_whitespace(line);
+ if (first == '\0' || first == '#')
+ goto free_line;
+
+ /* We are reusing line buffer to form temporary
+ * "key\0values\0..." in its beginning
+ */
+ char *value = NULL;
+ char *src;
+ char *dst;
+ for (src = dst = line; *src; src++)
+ {
+ char c = *src;
+ /* did we reach the value list? */
+ if (!value && c == ':')
+ {
+ *dst++ = '\0'; /* terminate key */
+ value = dst; /* remember where value starts */
+ continue;
+ }
+ /* skip whitespace in value list */
+ if (value && isspace(c))
+ continue;
+ *dst++ = c; /* store next key or value char */
+ }
+
+ /* Skip broken lines */
+ if (!value)
+ goto free_line;
+
+ *dst = '\0'; /* terminate value */
+
+ GList *item_list = split_string_on_char(value, ',');
+
+ section_t *sec = xzalloc(sizeof(*sec));
+ sec->name = xstrdup(line);
+ sec->items = item_list;
+ sections = g_list_prepend(sections, sec);
+
+ free_line:
+ free(line);
+ }
+
+ if (fp != stdin)
+ fclose(fp);
+
+ return g_list_reverse(sections);
+}
+
+static
+bool is_explicit_or_forbidden(const char *name, GList *comment_fmt_spec)
+{
+ GList *l = comment_fmt_spec;
+ while (l)
+ {
+ section_t *sec = l->data;
+ GList *item = sec->items;
+ while (item)
+ {
+ const char *nm = item->data;
+ if (nm[0] == '-')
+ nm++;
+ if (strcmp(name, nm) == 0)
+ return true; /* we see "name" or "-name" */
+ item = item->next;
+ }
+ l = l->next;
+ }
+ return false;
+}
+
+static
+int append_item(struct strbuf *result, const char *item_name, problem_data_t *pd, GList *comment_fmt_spec)
+{
+ bool print_item_name = (strncmp(item_name, "%bare_", strlen("%bare_")) != 0);
+ if (!print_item_name)
+ item_name += strlen("%bare_");
+
+ if (item_name[0] != '%')
+ {
+ struct problem_item *item = problem_data_get_item_or_NULL(pd, item_name);
+ if (!item)
+ return 0; /* "I did not print anything" */
+ if (!(item->flags & CD_FLAG_TXT))
+ return 0; /* "I did not print anything" */
+
+ char *formatted = problem_item_format(item);
+ char *content = formatted ? formatted : item->content;
+ char *eol = strchrnul(content, '\n');
+ if (eol[0] == '\0' || eol[1] == '\0')
+ {
+ /* one-liner */
+ int pad = 16 - (strlen(item_name) + 2);
+ if (pad < 0)
+ pad = 0;
+ if (print_item_name)
+ strbuf_append_strf(result,
+ eol[0] == '\0' ? "%s: %*s%s\n" : "%s: %*s%s",
+ item_name, pad, "", content
+ );
+ else
+ strbuf_append_strf(result,
+ eol[0] == '\0' ? "%s\n" : "%s",
+ content
+ );
+ }
+ else
+ {
+ /* multi-line item */
+ if (print_item_name)
+ strbuf_append_strf(result, "%s:\n", item_name);
+ for (;;)
+ {
+ eol = strchrnul(content, '\n');
+ strbuf_append_strf(result,
+ /* For %bare_multiline_item, we don't want to print colons */
+ (print_item_name ? ":%.*s\n" : "%.*s\n"),
+ (int)(eol - content), content
+ );
+ if (eol[0] == '\0' || eol[1] == '\0')
+ break;
+ content = eol + 1;
+ }
+ }
+ free(formatted);
+ return 1; /* "I printed something" */
+ }
+
+ /* Special item name */
+ /* %oneline,%multiline,%text,%binary */
+ bool oneline = (strcmp(item_name+1, "oneline" ) == 0);
+ bool multiline = (strcmp(item_name+1, "multiline") == 0);
+ bool text = (strcmp(item_name+1, "text" ) == 0);
+// bool binary = (strcmp(item_name+1, "binary" ) == 0);
+ if (!oneline && !multiline && !text)
+ {
+ log("Unknown or unsupported element specifier '%s'", item_name);
+ return 0; /* "I did not print anything" */
+ }
+
+ int printed = 0;
+ {
+ /* Iterate over _sorted_ items */
+ GList *sorted_names = g_hash_table_get_keys(pd);
+ sorted_names = g_list_sort(sorted_names, (GCompareFunc)strcmp);
+
+ /* %text => do as if %oneline, then repeat as if %multiline */
+ if (text)
+ oneline = 1;
+ again: ;
+ GList *l = sorted_names;
+ while (l)
+ {
+ const char *name = l->data;
+ l = l->next;
+ struct problem_item *item = g_hash_table_lookup(pd, name);
+ if (!item)
+ continue; /* paranoia, won't happen */
+
+ if (!(item->flags & CD_FLAG_TXT))
+ continue;
+
+ if (is_explicit_or_forbidden(name, comment_fmt_spec))
+ continue;
+
+ char *formatted = problem_item_format(item);
+ char *content = formatted ? formatted : item->content;
+ char *eol = strchrnul(content, '\n');
+ bool is_oneline = (eol[0] == '\0' || eol[1] == '\0');
+ if (oneline == is_oneline)
+ printed |= append_item(result, name, pd, comment_fmt_spec);
+ free(formatted);
+ }
+ if (text && oneline)
+ {
+ /* %text, and we just did %oneline. Repeat as if %multiline */
+ oneline = 0;
+ /*multiline = 1; - not checked in fact, so why bother setting? */
+ goto again;
+ }
+
+ g_list_free(sorted_names); /* names themselves are not freed */
+
+ }
+ return printed;
+}
+
+static
+int generate_bz_comment(struct strbuf *result, problem_data_t *pd, GList *comment_fmt_spec)
+{
+ int printed = 0;
+ GList *l = comment_fmt_spec;
+ while (l)
+ {
+ struct strbuf *output = strbuf_new();
+ section_t *sec = l->data;
+ GList *item = sec->items;
+ while (item)
+ {
+ const char *str = item->data;
+ if (str[0] == '-') /* "-name", ignore it */
+ goto skip_item;
+ printed |= append_item(output, str, pd, comment_fmt_spec);
+ skip_item:
+ item = item->next;
+ }
+
+ if (output->len != 0)
+ {
+ strbuf_append_strf(result,
+ (result->len == 0 ? "%s:\n%s" : "\n%s:\n%s"),
+ sec->name,
+ output->buf
+ );
+ }
+ strbuf_free(output);
+
+ l = l->next;
+ }
+
+ return printed;
+}
struct bugzilla_struct {
const char *b_login;
@@ -103,12 +363,9 @@ int main(int argc, char **argv)
textdomain(PACKAGE);
#endif
- const char *dump_dir_name = ".";
- GList *conf_file = NULL;
-
/* Can't keep these strings/structs static: _() doesn't support that */
const char *program_usage_string = _(
- "\n& [-vbf] [-g GROUP-NAME]... [-c CONFFILE]... -d DIR"
+ "\n& [-vbf] [-g GROUP-NAME]... [-c CONFFILE]... [-F FMTFILE] -d DIR"
"\nor:"
"\n& [-v] [-c CONFFILE]... [-d DIR] -t[ID] FILE..."
"\nor:"
@@ -142,16 +399,21 @@ int main(int argc, char **argv)
"\nRecognized string parameters: BugzillaURL, Login, Password, OSRelease."
"\nRecognized boolean parameter (VALUE should be 1/0, yes/no): SSLVerify."
"\nParameters can be overridden via $Bugzilla_PARAM environment variables."
+ "\n"
+ "\nFMTFILE defaults to "CONF_DIR"/plugins/bugzilla_format.conf"
);
enum {
OPT_v = 1 << 0,
OPT_d = 1 << 1,
OPT_c = 1 << 2,
- OPT_t = 1 << 3,
- OPT_b = 1 << 4,
- OPT_f = 1 << 5,
+ OPT_F = 1 << 3,
+ OPT_t = 1 << 4,
+ OPT_b = 1 << 5,
+ OPT_f = 1 << 6,
};
-
+ const char *dump_dir_name = ".";
+ GList *conf_file = NULL;
+ const char *fmt_file = CONF_DIR"/plugins/bugzilla_format.conf";
char *ticket_no = NULL, *abrt_hash = NULL;
GList *group = NULL;
/* Keep enum above and order of options below in sync! */
@@ -159,6 +421,7 @@ int main(int argc, char **argv)
OPT__VERBOSE(&g_verbose),
OPT_STRING( 'd', NULL, &dump_dir_name , "DIR" , _("Problem directory")),
OPT_LIST( 'c', NULL, &conf_file , "FILE" , _("Configuration file (may be given many times)")),
+ OPT_STRING( 'F', NULL, &fmt_file , "FILE" , _("Formatting file")),
OPT_OPTSTRING('t', "ticket", &ticket_no , "ID" , _("Attach FILEs [to bug with this ID]")),
OPT_BOOL( 'b', NULL, NULL, _("When creating bug, attach binary files too")),
OPT_BOOL( 'f', NULL, NULL, _("Force reporting even if this problem is already reported")),
@@ -410,12 +673,18 @@ int main(int argc, char **argv)
/* Create new bug */
log(_("Creating a new bug"));
- char *aux_msg = crossver_id < 0 ? NULL :
- xasprintf("\nPotential duplicate: bug %u\n", crossver_id);
+ GList *comment_fmt_spec = load_bzrep_conf_file(fmt_file);
+
+ struct strbuf *bzcomment_buf = strbuf_new();
+ generate_bz_comment(bzcomment_buf, problem_data, comment_fmt_spec);
+ if (crossver_id >= 0)
+ strbuf_append_strf(bzcomment_buf, "\nPotential duplicate: bug %u\n", crossver_id);
+ char *bzcomment = strbuf_free_nobuf(bzcomment_buf);
int new_id = rhbz_new_bug(client, problem_data, rhbz.b_os_release,
- aux_msg,
- group);
- free(aux_msg);
+ bzcomment,
+ group
+ );
+ free(bzcomment);
log(_("Adding attachments to bug %i"), new_id);
char new_id_str[sizeof(int)*3 + 2];
diff -urp libreport.7/src/plugins/rhbz.c libreport.9/src/plugins/rhbz.c
--- libreport.7/src/plugins/rhbz.c 2012-11-01 13:30:04.560505828 +0100
+++ libreport.9/src/plugins/rhbz.c 2012-11-07 13:48:46.788219126 +0100
@@ -445,62 +445,6 @@ struct bug_info *rhbz_bug_info(struct ab
return bz;
}
-/*
- * Produces an optimal backtrace for bugzilla comment
- */
-char *rhbz_get_backtrace_info(problem_data_t *problem_data, size_t max_text_size)
-{
- const problem_item *item = problem_data_get_item_or_NULL(problem_data,
- FILENAME_BACKTRACE);
-
- if (!item)
- return NULL;
-
- char *truncated = NULL;
-
- if (strlen(item->content) >= max_text_size)
- {
- struct btp_location location;
- btp_location_init(&location);
-
- /* btp_backtrace_parse modifies the input parameter */
- char *content = item->content;
- struct btp_backtrace *backtrace = btp_backtrace_parse((const char **)&content, &location);
-
- if (!backtrace)
- {
- log(_("Can't parse backtrace"));
- return NULL;
- }
-
- /* Get optimized thread stack trace for 10 top most frames */
- struct btp_thread *thread = btp_backtrace_get_optimized_thread(backtrace, 10);
-
- btp_backtrace_free(backtrace);
-
- if (!thread)
- {
- log(_("Can't find crash thread"));
- return NULL;
- }
-
- /* Cannot be NULL, it dies on memory error */
- struct btp_strbuf *bt = btp_strbuf_new();
-
- btp_thread_append_to_str(thread, bt, true);
-
- btp_thread_free(thread);
-
- truncated = btp_strbuf_free_nobuf(bt);
- }
-
- char *bt = make_description_item_multiline(truncated ? "truncated backtrace" : FILENAME_BACKTRACE,
- truncated ? truncated : item->content);
- free(truncated);
-
- return bt;
-}
-
/******************************************************************************/
/* New bug logic:
* 1. 'Description of problem' is FILENAME_COMMENT
@@ -566,7 +510,7 @@ static const char *const g_not_attached_
int rhbz_new_bug(struct abrt_xmlrpc *ax,
problem_data_t *problem_data,
const char *release,
- const char *aux_msg,
+ const char *bzcomment,
GList *group)
{
func_entry();
@@ -600,8 +544,6 @@ int rhbz_new_bug(struct abrt_xmlrpc *ax,
FILENAME_ANALYZER);
const char *tainted_short = problem_data_get_content_or_NULL(problem_data,
FILENAME_TAINTED_SHORT);
- const char *comment = problem_data_get_content_or_NULL(problem_data,
- FILENAME_COMMENT);
struct strbuf *buf_summary = strbuf_new();
@@ -667,36 +609,6 @@ int rhbz_new_bug(struct abrt_xmlrpc *ax,
buf[3] = '\0';
}
- /* Generating of a description according to the RH bugzilla default format:
- * https://bugzilla.redhat.com/enter_bug.cgi?product=Fedora
- */
- struct strbuf *tmp_full_dsc = strbuf_new();
- if (comment)
- strbuf_append_strf(tmp_full_dsc, "Description of problem:\n%s\n\n", comment);
-
- /* the package file always contains 'kernel' string in case of kerneloops */
- /* it doesn't make sense to mess up a description with this useless information */
- if (package && !kerneloops)
- strbuf_append_strf(tmp_full_dsc, "Version-Release number of selected component:\n%s\n\n", package);
-
- char *bz_dsc = make_description(problem_data, (char**)g_excluded_items,
- CD_TEXT_ATT_SIZE_BZ, /*flags:*/ 0);
-
- strbuf_append_strf(tmp_full_dsc, "Additional info:\nlibreport_version: "VERSION"\n%s\n", bz_dsc);
- free(bz_dsc);
-
- char *backtrace = rhbz_get_backtrace_info(problem_data, CD_TEXT_ATT_SIZE_BZ);
- if (backtrace)
- {
- strbuf_append_str(tmp_full_dsc, backtrace);
- free(backtrace);
- }
-
- if (aux_msg)
- strbuf_append_str(tmp_full_dsc, aux_msg);
-
- char *full_dsc = strbuf_free_nobuf(tmp_full_dsc);
-
char *product = NULL;
char *version = NULL;
parse_release_for_bz(release, &product, &version);
@@ -712,7 +624,7 @@ int rhbz_new_bug(struct abrt_xmlrpc *ax,
"component", component,
"version", version,
"summary", summary,
- "description", full_dsc,
+ "description", bzcomment,
"status_whiteboard", status_whiteboard,
"platform", arch);
}
@@ -743,7 +655,7 @@ int rhbz_new_bug(struct abrt_xmlrpc *ax,
"component", component,
"version", version,
"summary", summary,
- "description", full_dsc,
+ "description", bzcomment,
"status_whiteboard", status_whiteboard,
"platform", arch,
"groups", xmlrpc_groups);
@@ -754,7 +666,6 @@ int rhbz_new_bug(struct abrt_xmlrpc *ax,
free(product);
free(version);
free(summary);
- free(full_dsc);
if (!result)
return -1;
11 years, 7 months
[ABRT PATCH 1/3] abrt-handle-event: forward event process requests to parrent
by Jakub Filak
- required by rhbz#873488
Signed-off-by: Jakub Filak <jfilak(a)redhat.com>
---
src/daemon/abrt-handle-event.c | 7 ++++++-
1 file changed, 6 insertions(+), 1 deletion(-)
diff --git a/src/daemon/abrt-handle-event.c b/src/daemon/abrt-handle-event.c
index 25dcfd7..29fbffd 100644
--- a/src/daemon/abrt-handle-event.c
+++ b/src/daemon/abrt-handle-event.c
@@ -287,13 +287,16 @@ int main(int argc, char **argv)
abrt_init(argv);
const char *program_usage_string = _(
- "& [-v] -e|--event EVENT DIR..."
+ "& [-v -i] -e|--event EVENT DIR..."
);
char *event_name = NULL;
+ bool interactive = false;
+
struct options program_options[] = {
OPT__VERBOSE(&g_verbose),
OPT_STRING('e', "event" , &event_name, "EVENT", _("Run EVENT on DIR")),
+ OPT_BOOL('i', "interactive" , &interactive, _("Communicate directly to the user")),
OPT_END()
};
@@ -323,6 +326,8 @@ int main(int argc, char **argv)
dd_close(dd);
struct run_event_state *run_state = new_run_event_state();
+ if (!interactive)
+ make_run_event_state_forwarding(run_state);
if (post_create)
run_state->post_run_callback = is_crash_a_dup;
run_state->logging_callback = do_log;
--
1.7.11.7
11 years, 7 months
[LIBREPORT PATCH] add support for forwarding of report client requests
by Jakub Filak
- required by rhbz#873488
Signed-off-by: Jakub Filak <jfilak(a)redhat.com>
---
src/include/run_event.h | 7 +++++
src/lib/run_event.c | 82 +++++++++++++++++++++++++++++++++++++++----------
2 files changed, 72 insertions(+), 17 deletions(-)
diff --git a/src/include/run_event.h b/src/include/run_event.h
index c5791f0..8678423 100644
--- a/src/include/run_event.h
+++ b/src/include/run_event.h
@@ -126,6 +126,13 @@ struct run_event_state {
struct run_event_state *new_run_event_state(void);
void free_run_event_state(struct run_event_state *state);
+/*
+ * Configure callbacks to forward requests
+ *
+ * @param state A valid run event state pointer
+ */
+void make_run_event_state_forwarding(struct run_event_state *state);
+
/* Asynchronous command execution */
/* Returns 0 if no commands found for this dump_dir_name+event, else >0 */
diff --git a/src/lib/run_event.c b/src/lib/run_event.c
index 9c16f75..7aff436 100644
--- a/src/lib/run_event.c
+++ b/src/lib/run_event.c
@@ -21,6 +21,8 @@
#include "client.h"
#include "internal_libreport.h"
+#define FORWARD_REPORT_REQUEST_PTR ((void *)(uintptr_t)2)
+
struct run_event_state *new_run_event_state()
{
struct run_event_state *state = xzalloc(sizeof(struct run_event_state));
@@ -46,6 +48,18 @@ void free_run_event_state(struct run_event_state *state)
}
}
+void make_run_event_state_forwarding(struct run_event_state *state)
+{
+ /* reset callbacks, just to be sure */
+ state->alert_callback = run_event_stdio_alert;
+ state->ask_callback = run_event_stdio_ask;
+ state->ask_yes_no_callback = run_event_stdio_ask_yes_no;
+ state->ask_yes_no_yesforever_callback= run_event_stdio_ask_yes_no_yesforever;
+ state->ask_password_callback = run_event_stdio_ask_password;
+
+ /* notify default callbacks */
+ state->interaction_param = FORWARD_REPORT_REQUEST_PTR;
+}
/* Asynchronous command execution */
@@ -508,13 +522,13 @@ int consume_event_command_output(struct run_event_state *state, const char *dump
key_end[0] = ' '; /* restore original message, not sure if it is necessary */
}
- response = xstrdup(ans ? "yes" : "no");
+ response = xstrdup(ans ? _("y") : _("N"));
}
/* wait for y/N response on the same line */
else if (prefixcmp(msg, REPORT_PREFIX_ASK_YES_NO) == 0)
{
const bool ans = state->ask_yes_no_callback(msg + sizeof(REPORT_PREFIX_ASK_YES_NO) - 1, state->interaction_param);
- response = xstrdup(ans ? "yes" : "no");
+ response = xstrdup(ans ? _("y") : _("N"));
}
/* wait for the string on the same line */
else if (prefixcmp(msg, REPORT_PREFIX_ASK) == 0)
@@ -675,13 +689,21 @@ char *list_possible_events(struct dump_dir *dd, const char *dump_dir_name, const
void run_event_stdio_alert(const char *msg, void *param)
{
- printf("%s\n", msg);
+ if (param == FORWARD_REPORT_REQUEST_PTR)
+ printf(REPORT_PREFIX_ALERT "%s\n", msg);
+ else
+ printf("%s\n", msg);
+
fflush(stdout);
}
-char *run_event_stdio_ask(const char *msg, void *param)
+static char *internal_ask(const char *msg, const char *prefix)
{
- printf("%s ", msg);
+ if (prefix == NULL)
+ printf("%s ", msg);
+ else
+ printf("%s%s\n", prefix, msg);
+
fflush(stdout);
char buf[256];
if (!fgets(buf, sizeof(buf), stdin))
@@ -692,26 +714,48 @@ char *run_event_stdio_ask(const char *msg, void *param)
return xstrdup(buf);
}
+char *run_event_stdio_ask(const char *msg, void *param)
+{
+ return internal_ask(msg, param == FORWARD_REPORT_REQUEST_PTR ? REPORT_PREFIX_ASK : NULL);
+}
+
int run_event_stdio_ask_yes_no(const char *msg, void *param)
{
- printf("%s [%s/%s] ", msg, _("y"), _("N"));
+ const char *yes = _("y");
+ const char *no = _("N");
+
+ if (param == FORWARD_REPORT_REQUEST_PTR)
+ printf(REPORT_PREFIX_ASK_YES_NO "%s\n", msg);
+ else
+ printf("%s [%s/%s] ", msg, yes, no);
+
fflush(stdout);
char buf[16];
if (!fgets(buf, sizeof(buf), stdin))
buf[0] = '\0';
- return buf[0] == 'y' && (buf[1] == '\n' || buf[1] == '\0');
+ return strncmp(yes, buf, strlen(yes)) == 0;
}
int run_event_stdio_ask_yes_no_yesforever(const char *msg, const char *key, void *param)
{
- const char *ask_result = get_user_setting(key);
+ const char *yes = _("y");
+ const char *no = _("N");
+ const char *forever = _("f");
- if (ask_result && string_to_bool(ask_result) == false)
- /* Do you want to be asked? -> No, I don't */
- return 1;
+ if (param == FORWARD_REPORT_REQUEST_PTR)
+ printf(REPORT_PREFIX_ASK_YES_NO_YESFOREVER "%s %s\n", key, msg);
+ else
+ {
+ const char *ask_result = get_user_setting(key);
+
+ if (ask_result && string_to_bool(ask_result) == false)
+ /* Do you want to be asked? -> No, I don't */
+ return 1;
+
+ printf("%s [%s/%s/%s] ", msg, yes, no, forever);
+ }
- printf("%s [%s/%s/%s] ", msg, _("y"), _("N"), _("f"));
fflush(stdout);
char buf[16];
if (!fgets(buf, sizeof(buf), stdin))
@@ -721,17 +765,21 @@ int run_event_stdio_ask_yes_no_yesforever(const char *msg, const char *key, void
if (endln)
endln[0] = '\0';
- /* Do you want to be asked for next time? */
- /* 'f' means 'yes forever' and it means 'no, dont' ask me again' */
- set_user_setting(key, strcmp(_("f"), buf) == 0 ? "no" : "yes");
+ if (param != FORWARD_REPORT_REQUEST_PTR)
+ {
+ /* Do you want to be asked for next time? */
+ /* 'f' means 'yes forever' and it means 'no, dont' ask me again' */
+ set_user_setting(key, strncmp(forever, buf, strlen(forever)) == 0 ? "no" : "yes");
+ }
- return strcmp(_("f"), buf) == 0 || strcmp(_("y"), buf) == 0;
+ return strncmp(forever, buf, strlen(forever)) == 0 || strncmp(yes, buf, strlen(yes)) == 0;
}
char *run_event_stdio_ask_password(const char *msg, void *param)
{
const bool changed = set_echo(false);
- char *const password = run_event_stdio_ask(msg, param);
+ char *const password = internal_ask(msg, param == FORWARD_REPORT_REQUEST_PTR
+ ? REPORT_PREFIX_ASK_PASSWORD : NULL);
if (changed)
set_echo(true);
--
1.7.11.7
11 years, 7 months
[LIBREPORT PATCH] hide the spinner when the event processing is finishes trac#852
by Jiri Moskovcak
---
src/gui-wizard-gtk/wizard.c | 13 +++++++++++++
src/gui-wizard-gtk/wizard.glade | 40 ++++++++++++++++++++++++++++++----------
2 files changed, 43 insertions(+), 10 deletions(-)
diff --git a/src/gui-wizard-gtk/wizard.c b/src/gui-wizard-gtk/wizard.c
index 20ae45e..6ec3c04 100644
--- a/src/gui-wizard-gtk/wizard.c
+++ b/src/gui-wizard-gtk/wizard.c
@@ -99,6 +99,8 @@ static gboolean g_warning_issued;
static GtkEventBox *g_ev_search_up;
static GtkEventBox *g_ev_search_down;
static GtkSpinner *g_spinner_event_log;
+static GtkImage *g_img_process_fail;
+static GtkImage *g_img_process_ok;
static GtkWidget *g_top_most_window;
@@ -1753,6 +1755,11 @@ static gboolean consume_cmd_output(GIOChannel *source, GIOCondition condition, g
/* Hide spinner and stop btn */
gtk_widget_hide(GTK_WIDGET(g_spinner_event_log));
+ if (retval != 0)
+ gtk_widget_show(GTK_WIDGET(g_img_process_fail));
+ else
+ gtk_widget_show(GTK_WIDGET(g_img_process_ok));
+
gtk_widget_hide(g_btn_stop);
/* Enable (un-gray out) navigation buttons */
gtk_widget_set_sensitive(g_btn_close, true);
@@ -1900,6 +1907,10 @@ static void start_event_run(const char *event_name,
append_to_textview(evd->tv_log, msg);
free(msg);
+ /* don't bother testing if they are visible, this is faster */
+ gtk_widget_hide(GTK_WIDGET(g_img_process_fail));
+ gtk_widget_hide(GTK_WIDGET(g_img_process_ok));
+
gtk_widget_show(GTK_WIDGET(g_spinner_event_log));
gtk_widget_show(g_btn_stop);
/* Disable (gray out) navigation buttons */
@@ -2884,6 +2895,8 @@ static void add_pages(void)
g_ev_search_up = GTK_EVENT_BOX( gtk_builder_get_object(g_builder, "ev_search_up"));
g_ev_search_down = GTK_EVENT_BOX( gtk_builder_get_object(g_builder, "ev_search_down"));
g_spinner_event_log = GTK_SPINNER( gtk_builder_get_object(g_builder, "spinner_event_log"));
+ g_img_process_ok = GTK_IMAGE( gtk_builder_get_object(g_builder, "img_process_ok"));
+ g_img_process_fail = GTK_IMAGE( gtk_builder_get_object(g_builder, "img_process_fail"));
gtk_widget_set_no_show_all(GTK_WIDGET(g_spinner_event_log), true);
diff --git a/src/gui-wizard-gtk/wizard.glade b/src/gui-wizard-gtk/wizard.glade
index 5632c54..53e215e 100644
--- a/src/gui-wizard-gtk/wizard.glade
+++ b/src/gui-wizard-gtk/wizard.glade
@@ -159,11 +159,9 @@
<child>
<object class="GtkCheckButton" id="cb_no_comment">
<property name="label" translatable="yes">I don't know what caused this problem</property>
- <property name="use_action_appearance">False</property>
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="receives_default">False</property>
- <property name="use_action_appearance">False</property>
<property name="xalign">0</property>
<property name="draw_indicator">True</property>
</object>
@@ -205,11 +203,9 @@
<child>
<object class="GtkButton" id="button_cfg1">
<property name="label">gtk-preferences</property>
- <property name="use_action_appearance">False</property>
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="receives_default">True</property>
- <property name="use_action_appearance">False</property>
<property name="use_underline">True</property>
<property name="use_stock">True</property>
<property name="image_position">right</property>
@@ -401,7 +397,7 @@
</object>
<packing>
<property name="x_options">GTK_FILL</property>
- <property name="y_options"></property>
+ <property name="y_options"/>
</packing>
</child>
<child>
@@ -445,11 +441,9 @@
<child>
<object class="GtkButton" id="btn_add_file">
<property name="label" translatable="yes">Attach a file</property>
- <property name="use_action_appearance">False</property>
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="receives_default">True</property>
- <property name="use_action_appearance">False</property>
</object>
<packing>
<property name="expand">False</property>
@@ -470,12 +464,10 @@
<child>
<object class="GtkCheckButton" id="cb_approve_bt">
<property name="label" translatable="yes">I reviewed the data and _agree with submitting it</property>
- <property name="use_action_appearance">False</property>
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="receives_default">False</property>
<property name="tooltip_text" translatable="yes">If you are reporting to a remote server, make sure you removed all private data (such as usernames and passwords). Backtrace, command line, environment variables are the typical items in need of examining.</property>
- <property name="use_action_appearance">False</property>
<property name="use_underline">True</property>
<property name="xalign">0</property>
<property name="draw_indicator">True</property>
@@ -515,6 +507,34 @@
</packing>
</child>
<child>
+ <object class="GtkImage" id="img_process_ok">
+ <property name="can_focus">False</property>
+ <property name="no_show_all">True</property>
+ <property name="stock">gtk-apply</property>
+ <property name="icon-size">1</property>
+ </object>
+ <packing>
+ <property name="expand">False</property>
+ <property name="fill">True</property>
+ <property name="padding">5</property>
+ <property name="position">1</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkImage" id="img_process_fail">
+ <property name="can_focus">False</property>
+ <property name="no_show_all">True</property>
+ <property name="stock">gtk-dialog-error</property>
+ <property name="icon-size">1</property>
+ </object>
+ <packing>
+ <property name="expand">False</property>
+ <property name="fill">True</property>
+ <property name="padding">5</property>
+ <property name="position">2</property>
+ </packing>
+ </child>
+ <child>
<object class="GtkLabel" id="lbl_event_log">
<property name="visible">True</property>
<property name="can_focus">False</property>
@@ -528,7 +548,7 @@
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
- <property name="position">1</property>
+ <property name="position">3</property>
</packing>
</child>
</object>
--
1.7.12.1
11 years, 7 months
[ABRT PATCH 1/4] enhance koops tainted flag parser
by Jakub Filak
- closes trac#813
Signed-off-by: Jakub Filak <jfilak(a)redhat.com>
---
src/lib/kernel.c | 39 ++++++++++++++++++++++++++++++++++++---
1 file changed, 36 insertions(+), 3 deletions(-)
diff --git a/src/lib/kernel.c b/src/lib/kernel.c
index e7526c1..cb398c3 100644
--- a/src/lib/kernel.c
+++ b/src/lib/kernel.c
@@ -556,13 +556,46 @@ static char *turn_off_flag(char *flags, char flag)
char *kernel_tainted_short(const char *kernel_bt)
{
- /* example of flags: |G B | */
+ /* example of flags: 'Tainted: G B ' */
char *tainted = strstr(kernel_bt, "Tainted: ");
if (!tainted)
return NULL;
- /* 12 == count of flags */
- char *tnt = xstrndup(tainted + strlen("Tainted: "), 12);
+ tainted += strlen("Tainted: ");
+ /* 13 == current count of known flags */
+ /* http://git.kernel.org/?p=linux/kernel/git/torvalds/linux.git;a=blob_plain... */
+ /* 26 the maximal sane count of flags because of alphabet limits */
+ unsigned sz = 26 + 1;
+ unsigned cnt = 0;
+ char *tnt = xmalloc(sz);
+
+ for (;;)
+ {
+ if (tainted[0] >= 'A' && tainted[0] <= 'Z')
+ {
+ if (cnt == sz - 1)
+ { /* this should not happen but */
+ /* I guess, it's a bit better approach then simple failure */
+ sz <<= 1;
+ tnt = xrealloc(tnt, sizeof(char) * sz);
+ }
+
+ tnt[cnt] = tainted[0];
+ ++cnt;
+ }
+ else if (tainted[0] != ' ')
+ break;
+
+ ++tainted;
+ }
+
+ if (cnt == 0)
+ {
+ free(tnt);
+ tnt = NULL;
+ }
+ else
+ tnt[cnt] = '\0';
return tnt;
}
--
1.7.11.7
11 years, 7 months