[ABRT PATCH 1/2] abrt-applet: alerts only not reported problems
by Jakub Filak
- closes rhbz#884819
Signed-off-by: Jakub Filak <jfilak(a)redhat.com>
---
src/applet/applet.c | 22 ++++++++++++++--------
1 file changed, 14 insertions(+), 8 deletions(-)
diff --git a/src/applet/applet.c b/src/applet/applet.c
index 28ab62c..97cd4b1 100644
--- a/src/applet/applet.c
+++ b/src/applet/applet.c
@@ -1281,17 +1281,23 @@ int main(int argc, char** argv)
continue;
}
- problem_info_t *pi = problem_info_new();
- pi->problem_dir = xstrdup((char *)new_dirs->data);
- pi->message = build_message(dd_load_text(dd, FILENAME_COMPONENT));
+ char *reported_to = dd_load_text_ext(dd, FILENAME_REPORTED_TO,
+ DD_FAIL_QUIETLY_ENOENT | DD_LOAD_TEXT_RETURN_NULL_ON_FAILURE);
+ if (reported_to == NULL)
+ {
+ problem_info_t *pi = problem_info_new();
+ pi->problem_dir = xstrdup((char *)new_dirs->data);
+ pi->message = build_message(dd_load_text(dd, FILENAME_COMPONENT));
- /* Can't be foreign because if the problem is foreign then the
- * dd_opendir() call failed few lines above and the problem is ignored.
- * */
- pi->foreign = false;
+ /* Can't be foreign because if the problem is foreign then the
+ * dd_opendir() call failed few lines above and the problem is ignored.
+ * */
+ pi->foreign = false;
- notify_list = g_list_prepend(notify_list, pi);
+ notify_list = g_list_prepend(notify_list, pi);
+ }
+ free(reported_to);
dd_close(dd);
new_dirs = g_list_next(new_dirs);
--
1.7.11.7
11 years, 5 months
[LIBREPORT PATCH v2] show only workflows applicable to actual problem directory
by Jiri Moskovcak
---
libreport.spec.in | 4 ++--
po/POTFILES.in | 4 ++--
src/gui-wizard-gtk/wizard.c | 9 ++++++--
src/include/run_event.h | 8 +++++++
src/include/workflow.h | 1 +
src/lib/run_event.c | 23 ++++++++++++++++++++
src/lib/workflow.c | 41 ++++++++++++++++++++++++++++++++++++
src/workflows/Makefile.am | 8 +++----
src/workflows/report_Fedora.xml.in | 13 ------------
src/workflows/report_Upload.xml.in | 11 ----------
src/workflows/report_fedora.conf | 2 +-
src/workflows/workflow_Fedora.xml.in | 13 ++++++++++++
src/workflows/workflow_Upload.xml.in | 11 ++++++++++
13 files changed, 113 insertions(+), 35 deletions(-)
delete mode 100644 src/workflows/report_Fedora.xml.in
delete mode 100644 src/workflows/report_Upload.xml.in
create mode 100644 src/workflows/workflow_Fedora.xml.in
create mode 100644 src/workflows/workflow_Upload.xml.in
diff --git a/libreport.spec.in b/libreport.spec.in
index 78f690e..3c915f6 100644
--- a/libreport.spec.in
+++ b/libreport.spec.in
@@ -403,11 +403,11 @@ gtk-update-icon-cache %{_datadir}/icons/hicolor &>/dev/null || :
%{_bindir}/reporter-upload
%{_sysconfdir}/libreport/events/report_Uploader.xml
%config(noreplace) %{_sysconfdir}/libreport/events.d/uploader_event.conf
-%{_sysconfdir}/libreport/workflows/report_Upload.xml
+%{_sysconfdir}/libreport/workflows/workflow_Upload.xml
%files fedora
%defattr(-,root,root,-)
-%{_sysconfdir}/libreport/workflows/report_Fedora.xml
+%{_sysconfdir}/libreport/workflows/workflow_Fedora.xml
%config(noreplace) %{_sysconfdir}/libreport/workflows.d/report_fedora.conf
%changelog
diff --git a/po/POTFILES.in b/po/POTFILES.in
index 2dfe09e..b310941 100644
--- a/po/POTFILES.in
+++ b/po/POTFILES.in
@@ -40,5 +40,5 @@ src/plugins/report_uReport.xml.in
src/plugins/rhbz.c
src/plugins/ureport.c
src/report-newt/report-newt.c
-src/workflows/report_Fedora.xml.in
-src/workflows/report_Upload.xml.in
+src/workflows/workflow_Fedora.xml.in
+src/workflows/workflow_Upload.xml.in
diff --git a/src/gui-wizard-gtk/wizard.c b/src/gui-wizard-gtk/wizard.c
index 0891756..2907611 100644
--- a/src/gui-wizard-gtk/wizard.c
+++ b/src/gui-wizard-gtk/wizard.c
@@ -2464,10 +2464,15 @@ static void set_auto_event_chain(GtkButton *button, gpointer user_data)
static void add_workflow_buttons(GtkBox *box, GHashTable *workflows, GCallback func)
{
gtk_container_foreach(GTK_CONTAINER(box), &remove_child_widget, NULL);
- GList *keys = g_hash_table_get_keys(g_workflow_list);
+
+ GHashTable *workflow_table = load_workflow_config_data_from_list(
+ list_possible_events_glist(g_dump_dir_name, "workflow"),
+ WORKFLOWS_DIR);
+
+ GList *keys = g_hash_table_get_keys(workflow_table);
while(keys)
{
- workflow_t *w = g_hash_table_lookup(g_workflow_list, keys->data);
+ workflow_t *w = g_hash_table_lookup(workflow_table, keys->data);
char *btn_label = xasprintf("<b>%s</b>\n%s", wf_get_screen_name(w), wf_get_description(w));
GtkWidget *button = gtk_button_new_with_label(btn_label);
GList *children = gtk_container_get_children(GTK_CONTAINER(button));
diff --git a/src/include/run_event.h b/src/include/run_event.h
index bf94b5c..0afebc6 100644
--- a/src/include/run_event.h
+++ b/src/include/run_event.h
@@ -223,6 +223,14 @@ int run_event_stdio_ask_yes_no_yesforever(const char *msg, const char *key, void
*/
char *run_event_stdio_ask_password(const char *msg, void *param);
+/*
+ * Returns a list of possible events for given problem directory
+ *
+ * @param problem_dir_name the name of the problem directory
+ * @param pfx the prefix of the events "report", "workflow"
+ */
+GList *list_possible_events_glist(const char *problem_dir_name,
+ const char *pfx);
#ifdef __cplusplus
}
#endif
diff --git a/src/include/workflow.h b/src/include/workflow.h
index e60d6b5..db8c65d 100644
--- a/src/include/workflow.h
+++ b/src/include/workflow.h
@@ -43,5 +43,6 @@ void wf_set_screen_name(workflow_t *w, const char* screen_name);
void wf_set_description(workflow_t *w, const char* description);
void wf_set_long_desc(workflow_t *w, const char* long_desc);
void wf_add_event(workflow_t *w, event_config_t *ec);
+GHashTable *load_workflow_config_data_from_list(GList *wf_names, const char *path);
#endif
diff --git a/src/lib/run_event.c b/src/lib/run_event.c
index c8ccfa5..a60913e 100644
--- a/src/lib/run_event.c
+++ b/src/lib/run_event.c
@@ -684,6 +684,29 @@ char *list_possible_events(struct dump_dir *dd, const char *dump_dir_name, const
return strbuf_free_nobuf(result);
}
+GList *list_possible_events_glist(const char *problem_dir_name,
+ const char *pfx)
+{
+ struct dump_dir *dd = dd_opendir(problem_dir_name, DD_OPEN_READONLY);
+ GList *l = NULL;
+ char *events = list_possible_events(dd, problem_dir_name, pfx);
+ char *start = events;
+ char *end = strchr(events, '\n');
+
+ while(end)
+ {
+ *end = '\0';
+ l = g_list_append(l, xstrdup(start));
+ start = end + 1;
+ end = strchr(start, '\n');
+ }
+
+ dd_close(dd);
+ free(events);
+
+ return l;
+}
+
void run_event_stdio_alert(const char *msg, void *param)
{
alert(msg);
diff --git a/src/lib/workflow.c b/src/lib/workflow.c
index 1fba64c..35fa904 100644
--- a/src/lib/workflow.c
+++ b/src/lib/workflow.c
@@ -72,6 +72,47 @@ workflow_t *get_workflow(const char *name)
return g_hash_table_lookup(g_workflow_list, name);
}
+static gint file_obj_cmp(file_obj_t *file, const char *filename)
+{
+ gint cmp = strcmp(file->filename, filename);
+ return cmp;
+}
+
+static void load_workflow_config(const char *name,
+ GList *available_wfs,
+ GHashTable *wf_list)
+{
+ GList *wf_file = g_list_find_custom(available_wfs, name, (GCompareFunc)file_obj_cmp);
+ if (wf_file)
+ {
+ file_obj_t *file = (file_obj_t *)wf_file->data;
+ workflow_t *workflow = new_workflow(file->filename);
+ load_workflow_description_from_file(workflow, file->fullpath);
+ VERB1 log("Adding '%s' to workflows\n", file->filename);
+ g_hash_table_insert(wf_list, file->filename, workflow);
+ }
+}
+
+GHashTable *load_workflow_config_data_from_list(GList *wf_names,
+ const char *path)
+{
+ GList *wfs = wf_names;
+ GHashTable *wf_list = g_hash_table_new_full(
+ g_str_hash,
+ g_str_equal,
+ g_free,
+ (GDestroyNotify) free_workflow
+ );
+ GList *workflow_files = get_file_list(path, "xml");
+ while(wfs)
+ {
+ load_workflow_config((const char *)wfs->data, workflow_files, wf_list);
+ wfs = g_list_next(wfs);
+ }
+
+ return wf_list;
+}
+
GHashTable *load_workflow_config_data(const char *path)
{
if (g_workflow_list)
diff --git a/src/workflows/Makefile.am b/src/workflows/Makefile.am
index 3cd0797..98fa1a4 100644
--- a/src/workflows/Makefile.am
+++ b/src/workflows/Makefile.am
@@ -1,8 +1,8 @@
workflowsdir = $(WORKFLOWS_DIR)
dist_workflows_DATA = \
- report_Fedora.xml \
- report_Upload.xml
+ workflow_Fedora.xml \
+ workflow_Upload.xml
workflowsconfdir = $(WORKFLOWS_CONF_DIR)
@@ -12,5 +12,5 @@ dist_workflowsconf_DATA =\
@INTLTOOL_XML_RULE@
EXTRA_DIST = \
- report_Fedora.xml.in \
- report_Upload.xml.in
+ workflow_Fedora.xml.in \
+ workflow_Upload.xml.in
diff --git a/src/workflows/report_Fedora.xml.in b/src/workflows/report_Fedora.xml.in
deleted file mode 100644
index f9df177..0000000
--- a/src/workflows/report_Fedora.xml.in
+++ /dev/null
@@ -1,13 +0,0 @@
-<?xml version="1.0" encoding="UTF-8" ?>
-<workflow>
- <_name>Report to Fedora</_name>
- <_description>Process the report using the Fedora infrastructure</_description>
-
- <events>
- <event>report_uReport</event>
- <event>collect_*</event>
- <event>analyze_CCpp</event>
- <event>report_Bugzilla</event>
- <event>post_report</event>
- </events>
-</workflow>
diff --git a/src/workflows/report_Upload.xml.in b/src/workflows/report_Upload.xml.in
deleted file mode 100644
index 3965f99..0000000
--- a/src/workflows/report_Upload.xml.in
+++ /dev/null
@@ -1,11 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<workflow>
- <_name>Upload the problem data to a server</_name>
- <_description>Analyze the problem locally and upload the data via scp or ftp</_description>
-
- <events>
- <event>collect_*</event>
- <event>analyze_CCpp</event>
- <event>report_Uploader</event>
- </events>
-</workflow>
\ No newline at end of file
diff --git a/src/workflows/report_fedora.conf b/src/workflows/report_fedora.conf
index 9dd86ce..8c58f12 100644
--- a/src/workflows/report_fedora.conf
+++ b/src/workflows/report_fedora.conf
@@ -1,3 +1,3 @@
-EVENT=report_Fedora analyzer=CCpp
+EVENT=workflow_Fedora analyzer=CCpp
# this is just a meta event which consists of other events
# the list is defined in the xml file
diff --git a/src/workflows/workflow_Fedora.xml.in b/src/workflows/workflow_Fedora.xml.in
new file mode 100644
index 0000000..f9df177
--- /dev/null
+++ b/src/workflows/workflow_Fedora.xml.in
@@ -0,0 +1,13 @@
+<?xml version="1.0" encoding="UTF-8" ?>
+<workflow>
+ <_name>Report to Fedora</_name>
+ <_description>Process the report using the Fedora infrastructure</_description>
+
+ <events>
+ <event>report_uReport</event>
+ <event>collect_*</event>
+ <event>analyze_CCpp</event>
+ <event>report_Bugzilla</event>
+ <event>post_report</event>
+ </events>
+</workflow>
diff --git a/src/workflows/workflow_Upload.xml.in b/src/workflows/workflow_Upload.xml.in
new file mode 100644
index 0000000..3965f99
--- /dev/null
+++ b/src/workflows/workflow_Upload.xml.in
@@ -0,0 +1,11 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<workflow>
+ <_name>Upload the problem data to a server</_name>
+ <_description>Analyze the problem locally and upload the data via scp or ftp</_description>
+
+ <events>
+ <event>collect_*</event>
+ <event>analyze_CCpp</event>
+ <event>report_Uploader</event>
+ </events>
+</workflow>
\ No newline at end of file
--
1.8.0.1
11 years, 5 months
[ABRT PATCH] abrt-gui: fix 'Report problem with ABRT'
by Jakub Filak
Signed-off-by: Jakub Filak <jfilak(a)redhat.com>
---
src/gui-gtk/main.c | 134 ++++++++++++++++++++++++++++++++++++++++++++++-------
1 file changed, 118 insertions(+), 16 deletions(-)
diff --git a/src/gui-gtk/main.c b/src/gui-gtk/main.c
index 5179b6b..ad24ea6 100644
--- a/src/gui-gtk/main.c
+++ b/src/gui-gtk/main.c
@@ -70,7 +70,6 @@ static GtkTreePath *s_path_treeview;
static GtkTreePath *s_path_reported_treeview;
static GtkWidget *g_main_window;
-static GtkWidget *s_report_window;
enum
{
@@ -697,49 +696,152 @@ static void on_menu_help_cb(GtkMenuItem *menuitem, gpointer unused)
gtk_show_uri(NULL, help_uri, GDK_CURRENT_TIME, NULL);
}
+static void show_error_dialog(GtkWindow *wnd, const char *summary, const char *description)
+{
+ GtkWidget *dialog = gtk_message_dialog_new(wnd,
+ GTK_DIALOG_DESTROY_WITH_PARENT,
+ GTK_MESSAGE_ERROR,
+ GTK_BUTTONS_OK,
+ summary);
+
+ gtk_message_dialog_format_secondary_text(GTK_MESSAGE_DIALOG(dialog), description);
+
+ gtk_dialog_run(GTK_DIALOG(dialog));
+ gtk_widget_destroy (dialog);
+}
+
static void on_button_send_cb(GtkWidget *button, gpointer data)
{
- GtkTextView *tev = GTK_TEXT_VIEW(data);
+ GtkWidget *wnd_report = GTK_WIDGET(data);
+
+ /* Excpecting that the first child is Vertical Box with all the widgets */
+ GList *children = gtk_container_get_children(GTK_CONTAINER(wnd_report));
+ GtkContainer *vbox = GTK_CONTAINER(children->data);
+ g_list_free(children);
+
+ /* Expected content of the children list:
+ * Lable Summary
+ * Entry Summary
+ * TextView Description
+ * Button Send
+ */
+ children = gtk_container_get_children(vbox);
+
+ children = g_list_delete_link(children, children);
+ GtkEntry *txe_summary = GTK_ENTRY(children->data);
+
+ children = g_list_delete_link(children, children);
+ GtkTextView *tev = GTK_TEXT_VIEW(children->data);
+
+ g_list_free(children);
+
GtkTextBuffer *buf = gtk_text_view_get_buffer(tev);
GtkTextIter it_start;
GtkTextIter it_end;
gtk_text_buffer_get_start_iter(buf, &it_start);
gtk_text_buffer_get_end_iter(buf, &it_end);
- gchar *text = gtk_text_buffer_get_text(buf,
+ gchar *description = gtk_text_buffer_get_text(buf,
&it_start,
&it_end,
false);
- problem_data_t *pd = problem_data_new();
+ if (strlen(description) < 10)
+ {
+ show_error_dialog(GTK_WINDOW(wnd_report),
+ _("The description of problem is too short"),
+ _("In order to get more usefull reports we "
+ "do not accept reports with the description "
+ "shorter than 10 letters."));
+
+ gtk_widget_grab_focus(GTK_WIDGET(tev));
+
+ free(description);
+ return;
+ }
- if (text[0])
+ char *summary = xstrdup(gtk_entry_get_text(txe_summary));
+ if (strlen(summary) < 10)
{
- problem_data_add_text_noteditable(pd, "comment", text);
+ show_error_dialog(GTK_WINDOW(wnd_report),
+ _("The summary of problem is too short"),
+ _("In order to get more usefull reports we "
+ "do not accept reports with the summary "
+ "shorter than 10 letters."));
+
+ gtk_widget_grab_focus(GTK_WIDGET(txe_summary));
+ gtk_editable_set_position(GTK_EDITABLE(txe_summary), strlen(summary));
+
+ free(description);
+ free(summary);
+ return;
}
+
+ problem_data_t *pd = problem_data_new();
+ problem_data_add_text_noteditable(pd, FILENAME_COMMENT, description);
+ problem_data_add_text_noteditable(pd, FILENAME_REASON, summary);
+ problem_data_add_text_noteditable(pd, FILENAME_COMPONENT, "abrt");
+ char *version = xasprintf("abrt-%s", VERSION);
+ problem_data_add_text_noteditable(pd, FILENAME_PACKAGE, version);
+
+ /* Must be here because it computes FILENAME_DUPHASH from the content. */
+ problem_data_add_basics(pd);
+
/* why it doesn't want to hide before report ends? */
- gtk_widget_destroy(s_report_window);
+ gtk_widget_destroy(wnd_report);
report_problem_in_memory(pd, LIBREPORT_NOWAIT | LIBREPORT_GETPID);
+
+ free(version);
+ free(summary);
+ free(description);
problem_data_free(pd);
}
static void on_menu_report_cb(GtkMenuItem *menuitem, gpointer unused)
{
- s_report_window = gtk_window_new(GTK_WINDOW_TOPLEVEL);
- gtk_window_set_title(GTK_WINDOW(s_report_window), _("Problem description"));
- gtk_window_set_default_size(GTK_WINDOW(s_report_window), 400, 400);
+ GtkWidget *wnd_report = gtk_window_new(GTK_WINDOW_TOPLEVEL);
+ gtk_window_set_title(GTK_WINDOW(wnd_report), _("Problem description"));
+ gtk_window_set_default_size(GTK_WINDOW(wnd_report), 400, 400);
+
GtkWidget *vbox = gtk_box_new(GTK_ORIENTATION_VERTICAL, 0);
- GtkWidget *button_send = gtk_button_new_with_label(_("Send"));
+ gtk_widget_set_margin_top(vbox, 5);
+ gtk_widget_set_margin_left(vbox, 5);
+ gtk_widget_set_margin_right(vbox, 5);
+
+ GtkWidget *lbl_summary = GTK_WIDGET(gtk_label_new(_("Summary:")));
+ gtk_widget_set_halign(lbl_summary, GTK_ALIGN_START);
+ gtk_widget_set_margin_left(lbl_summary, 3);
+ gtk_widget_set_margin_right(lbl_summary, 3);
+
+ GtkWidget *txe_reason = GTK_WIDGET(gtk_entry_new());
+
GtkWidget *tev = gtk_text_view_new();
- g_signal_connect(button_send, "clicked", G_CALLBACK(on_button_send_cb), tev);
+ gtk_widget_set_margin_left(tev, 3);
+ gtk_widget_set_margin_right(tev, 3);
+ gtk_widget_set_can_focus(tev, TRUE);
+
+ GtkWidget *btn_send = gtk_button_new_with_label(_("_Send"));
+ gtk_button_set_use_underline(GTK_BUTTON(btn_send), TRUE);
+ g_signal_connect(btn_send, "clicked", G_CALLBACK(on_button_send_cb), wnd_report);
+
+ /* gtk_box_pack_start(box, widget, expand, fill, padding) */
+ gtk_box_pack_start(GTK_BOX(vbox), lbl_summary, FALSE, TRUE, 3);
+ gtk_box_pack_start(GTK_BOX(vbox), txe_reason, FALSE, TRUE, 3);
+ gtk_box_pack_start(GTK_BOX(vbox), tev, TRUE, TRUE, 5);
+ gtk_box_pack_start(GTK_BOX(vbox), btn_send, FALSE, TRUE, 3);
+
+ gtk_container_add(GTK_CONTAINER(wnd_report), vbox);
- gtk_box_pack_start(GTK_BOX(vbox), tev, true, true, 0);
- gtk_box_pack_start(GTK_BOX(vbox), button_send, false, false, 5);
+ gtk_widget_show_all(wnd_report);
- gtk_container_add(GTK_CONTAINER(s_report_window), vbox);
+ /* Sets text but text is selected :) */
+ gtk_entry_set_text(GTK_ENTRY(txe_reason), _("A problem with ABRT"));
+ /* Unselect text in txe_entry */
+ gtk_editable_set_position(GTK_EDITABLE(txe_reason), 0);
- gtk_widget_show_all(s_report_window);
+ /* Move focus to text view with description of problem */
+ gtk_widget_grab_focus(tev);
}
static void on_menu_about_cb(GtkMenuItem *menuitem, gpointer unused)
--
1.7.11.7
11 years, 5 months
[LIBREPORT PATCH] show only workflows applicable to actual problem directory
by Jiri Moskovcak
---
src/gui-wizard-gtk/wizard.c | 9 +++++++--
src/include/run_event.h | 8 ++++++++
src/include/workflow.h | 1 +
src/lib/run_event.c | 23 +++++++++++++++++++++++
src/lib/workflow.c | 41 +++++++++++++++++++++++++++++++++++++++++
5 files changed, 80 insertions(+), 2 deletions(-)
diff --git a/src/gui-wizard-gtk/wizard.c b/src/gui-wizard-gtk/wizard.c
index 0891756..2907611 100644
--- a/src/gui-wizard-gtk/wizard.c
+++ b/src/gui-wizard-gtk/wizard.c
@@ -2464,10 +2464,15 @@ static void set_auto_event_chain(GtkButton *button, gpointer user_data)
static void add_workflow_buttons(GtkBox *box, GHashTable *workflows, GCallback func)
{
gtk_container_foreach(GTK_CONTAINER(box), &remove_child_widget, NULL);
- GList *keys = g_hash_table_get_keys(g_workflow_list);
+
+ GHashTable *workflow_table = load_workflow_config_data_from_list(
+ list_possible_events_glist(g_dump_dir_name, "workflow"),
+ WORKFLOWS_DIR);
+
+ GList *keys = g_hash_table_get_keys(workflow_table);
while(keys)
{
- workflow_t *w = g_hash_table_lookup(g_workflow_list, keys->data);
+ workflow_t *w = g_hash_table_lookup(workflow_table, keys->data);
char *btn_label = xasprintf("<b>%s</b>\n%s", wf_get_screen_name(w), wf_get_description(w));
GtkWidget *button = gtk_button_new_with_label(btn_label);
GList *children = gtk_container_get_children(GTK_CONTAINER(button));
diff --git a/src/include/run_event.h b/src/include/run_event.h
index bf94b5c..0afebc6 100644
--- a/src/include/run_event.h
+++ b/src/include/run_event.h
@@ -223,6 +223,14 @@ int run_event_stdio_ask_yes_no_yesforever(const char *msg, const char *key, void
*/
char *run_event_stdio_ask_password(const char *msg, void *param);
+/*
+ * Returns a list of possible events for given problem directory
+ *
+ * @param problem_dir_name the name of the problem directory
+ * @param pfx the prefix of the events "report", "workflow"
+ */
+GList *list_possible_events_glist(const char *problem_dir_name,
+ const char *pfx);
#ifdef __cplusplus
}
#endif
diff --git a/src/include/workflow.h b/src/include/workflow.h
index e60d6b5..db8c65d 100644
--- a/src/include/workflow.h
+++ b/src/include/workflow.h
@@ -43,5 +43,6 @@ void wf_set_screen_name(workflow_t *w, const char* screen_name);
void wf_set_description(workflow_t *w, const char* description);
void wf_set_long_desc(workflow_t *w, const char* long_desc);
void wf_add_event(workflow_t *w, event_config_t *ec);
+GHashTable *load_workflow_config_data_from_list(GList *wf_names, const char *path);
#endif
diff --git a/src/lib/run_event.c b/src/lib/run_event.c
index c8ccfa5..a60913e 100644
--- a/src/lib/run_event.c
+++ b/src/lib/run_event.c
@@ -684,6 +684,29 @@ char *list_possible_events(struct dump_dir *dd, const char *dump_dir_name, const
return strbuf_free_nobuf(result);
}
+GList *list_possible_events_glist(const char *problem_dir_name,
+ const char *pfx)
+{
+ struct dump_dir *dd = dd_opendir(problem_dir_name, DD_OPEN_READONLY);
+ GList *l = NULL;
+ char *events = list_possible_events(dd, problem_dir_name, pfx);
+ char *start = events;
+ char *end = strchr(events, '\n');
+
+ while(end)
+ {
+ *end = '\0';
+ l = g_list_append(l, xstrdup(start));
+ start = end + 1;
+ end = strchr(start, '\n');
+ }
+
+ dd_close(dd);
+ free(events);
+
+ return l;
+}
+
void run_event_stdio_alert(const char *msg, void *param)
{
alert(msg);
diff --git a/src/lib/workflow.c b/src/lib/workflow.c
index 1fba64c..35fa904 100644
--- a/src/lib/workflow.c
+++ b/src/lib/workflow.c
@@ -72,6 +72,47 @@ workflow_t *get_workflow(const char *name)
return g_hash_table_lookup(g_workflow_list, name);
}
+static gint file_obj_cmp(file_obj_t *file, const char *filename)
+{
+ gint cmp = strcmp(file->filename, filename);
+ return cmp;
+}
+
+static void load_workflow_config(const char *name,
+ GList *available_wfs,
+ GHashTable *wf_list)
+{
+ GList *wf_file = g_list_find_custom(available_wfs, name, (GCompareFunc)file_obj_cmp);
+ if (wf_file)
+ {
+ file_obj_t *file = (file_obj_t *)wf_file->data;
+ workflow_t *workflow = new_workflow(file->filename);
+ load_workflow_description_from_file(workflow, file->fullpath);
+ VERB1 log("Adding '%s' to workflows\n", file->filename);
+ g_hash_table_insert(wf_list, file->filename, workflow);
+ }
+}
+
+GHashTable *load_workflow_config_data_from_list(GList *wf_names,
+ const char *path)
+{
+ GList *wfs = wf_names;
+ GHashTable *wf_list = g_hash_table_new_full(
+ g_str_hash,
+ g_str_equal,
+ g_free,
+ (GDestroyNotify) free_workflow
+ );
+ GList *workflow_files = get_file_list(path, "xml");
+ while(wfs)
+ {
+ load_workflow_config((const char *)wfs->data, workflow_files, wf_list);
+ wfs = g_list_next(wfs);
+ }
+
+ return wf_list;
+}
+
GHashTable *load_workflow_config_data(const char *path)
{
if (g_workflow_list)
--
1.8.0.1
11 years, 5 months
[LIBREPORT PATCH 1/3] remove new line from ask/ask_password responses
by Jakub Filak
Signed-off-by: Jakub Filak <jfilak(a)redhat.com>
---
src/lib/client.c | 8 +++++++-
1 file changed, 7 insertions(+), 1 deletion(-)
diff --git a/src/lib/client.c b/src/lib/client.c
index 9b2ee5c..d1ada22 100644
--- a/src/lib/client.c
+++ b/src/lib/client.c
@@ -129,7 +129,10 @@ char *ask(const char *question)
fflush(stdout);
- return xmalloc_fgets(stdin);
+ char *result = xmalloc_fgets(stdin);
+ strtrimch(result, '\n');
+
+ return result;
}
char *ask_password(const char *question)
@@ -142,7 +145,10 @@ char *ask_password(const char *question)
fflush(stdout);
bool changed = set_echo(false);
+
char *result = xmalloc_fgets(stdin);
+ strtrimch(result, '\n');
+
if (changed)
set_echo(true);
--
1.7.11.7
11 years, 5 months