From 4db62cf9807f4ec11a7c8c8c91875080c90f0ec1 Mon Sep 17 00:00:00 2001 From: Denys Vlasenko Date: Wed, 9 Mar 2011 16:43:27 +0100 Subject: gui-wizard-gtk: add load_event_config_data() to wizard Signed-off-by: Denys Vlasenko --- src/gui-wizard-gtk/wizard.c | 4 ++++ src/lib/event_config.c | 7 +++++-- src/lib/event_xml_parser.c | 2 +- src/lib/run_event.c | 32 ++++++++++++++++---------------- 4 files changed, 26 insertions(+), 19 deletions(-) diff --git a/src/gui-wizard-gtk/wizard.c b/src/gui-wizard-gtk/wizard.c index 1845787e..156d05f0 100644 --- a/src/gui-wizard-gtk/wizard.c +++ b/src/gui-wizard-gtk/wizard.c @@ -678,6 +678,10 @@ static void start_event_run(const char *event_name, if (!locked) return; /* user refused to steal, or write error, etc... */ + /* Load /etc/abrt/events/foo.{conf,xml} stuff */ + load_event_config_data(); +//TODO: load overrides from keyring? Load ~/.abrt/events/foo.conf? + GList *env_list = export_event_config(event_name); if (spawn_next_command(state, g_dump_dir_name, event_name) < 0) { diff --git a/src/lib/event_config.c b/src/lib/event_config.c index 4f8e8679..a79ee40c 100644 --- a/src/lib/event_config.c +++ b/src/lib/event_config.c @@ -43,6 +43,7 @@ void free_event_config(event_config_t *p) void load_event_config_data(void) { free_event_config_data(); + DIR *dir = opendir(EVENTS_DIR); if (!dir) return; @@ -70,7 +71,8 @@ void load_event_config_data(void) *ext = '\0'; event_config_t *event_config = get_event_config(dent->d_name); - if (!event_config) + bool new_config = (!event_config); + if (new_config) event_config = new_event_config(); if (xml) @@ -110,7 +112,8 @@ void load_event_config_data(void) free(fullname); - g_hash_table_replace(g_event_config_list, xstrdup(dent->d_name), event_config); + if (new_config) + g_hash_table_replace(g_event_config_list, xstrdup(dent->d_name), event_config); } } diff --git a/src/lib/event_xml_parser.c b/src/lib/event_xml_parser.c index 5f1974fd..be4a9e09 100644 --- a/src/lib/event_xml_parser.c +++ b/src/lib/event_xml_parser.c @@ -37,7 +37,7 @@ static void start_element(GMarkupParseContext *context, if (in_option == 0) { in_option = 1; - event_option_t *option = xzalloc(sizeof(*option)); + event_option_t *option = new_event_option(); //we need to prepend, so ui->options always points to the last created option VERB2 log("adding option"); ui->options = g_list_prepend(ui->options, option); diff --git a/src/lib/run_event.c b/src/lib/run_event.c index 3d2b3a22..45facffd 100644 --- a/src/lib/run_event.c +++ b/src/lib/run_event.c @@ -93,7 +93,7 @@ static GList *load_event_config(GList *list, if (*p == '\0' || *p == '#') goto next_line; /* empty or comment line, skip */ - VERB3 log("%s: line '%s'", __func__, p); + //VERB3 log("%s: line '%s'", __func__, p); if (strncmp(p, "include", strlen("include")) == 0 && isblank(p[strlen("include")])) { @@ -117,15 +117,15 @@ static GList *load_event_config(GList *list, glob_t globbuf; memset(&globbuf, 0, sizeof(globbuf)); - VERB3 log("%s: globbing '%s'", __func__, name_to_glob); + //VERB3 log("%s: globbing '%s'", __func__, name_to_glob); glob(name_to_glob, 0, NULL, &globbuf); free(name_to_glob); char **name = globbuf.gl_pathv; if (name) while (*name) { - VERB3 log("%s: recursing into '%s'", __func__, *name); + //VERB3 log("%s: recursing into '%s'", __func__, *name); list = load_event_config(list, dump_dir_name, event, *name); - VERB3 log("%s: returned from '%s'", __func__, *name); + //VERB3 log("%s: returned from '%s'", __func__, *name); name++; } globfree(&globbuf); @@ -174,10 +174,10 @@ static GList *load_event_config(GList *list, /* Does VAL match? */ if (strcmp(real_val, line_val) != 0) { - VERB3 log("var '%s': '%.*s'!='%s', skipping line", - p, - (int)(strchrnul(real_val, '\n') - real_val), real_val, - line_val); + //VERB3 log("var '%s': '%.*s'!='%s', skipping line", + // p, + // (int)(strchrnul(real_val, '\n') - real_val), real_val, + // line_val); free(malloced_val); goto next_line; /* no */ } @@ -400,7 +400,7 @@ static int list_possible_events_helper(struct strbuf *result, if (*p == '\0' || *p == '#') goto next_line; /* empty or comment line, skip */ - VERB3 log("%s: line '%s'", __func__, p); + //VERB3 log("%s: line '%s'", __func__, p); if (strncmp(p, "include", strlen("include")) == 0 && isblank(p[strlen("include")])) { @@ -424,15 +424,15 @@ static int list_possible_events_helper(struct strbuf *result, glob_t globbuf; memset(&globbuf, 0, sizeof(globbuf)); - VERB3 log("%s: globbing '%s'", __func__, name_to_glob); + //VERB3 log("%s: globbing '%s'", __func__, name_to_glob); glob(name_to_glob, 0, NULL, &globbuf); free(name_to_glob); char **name = globbuf.gl_pathv; if (name) while (*name) { - VERB3 log("%s: recursing into '%s'", __func__, *name); + //VERB3 log("%s: recursing into '%s'", __func__, *name); error = list_possible_events_helper(result, dd, dump_dir_name, pfx, *name); - VERB3 log("%s: returned from '%s'", __func__, *name); + //VERB3 log("%s: returned from '%s'", __func__, *name); if (error) break; name++; @@ -484,10 +484,10 @@ static int list_possible_events_helper(struct strbuf *result, /* Does VAL match? */ if (strcmp(real_val, line_val) != 0) { - VERB3 log("var '%s': '%.*s'!='%s', skipping line", - p, - (int)(strchrnul(real_val, '\n') - real_val), real_val, - line_val); + //VERB3 log("var '%s': '%.*s'!='%s', skipping line", + // p, + // (int)(strchrnul(real_val, '\n') - real_val), real_val, + // line_val); free(real_val); goto next_line; /* no */ } -- cgit