Jiri Moskovcak jmoskovc@redhat.com writes:
On 05/04/2011 09:17 AM, Nikola Pajkovsky wrote:
Jiri Moskovcakjmoskovc@redhat.com writes:
On 05/03/2011 11:30 AM, Nikola Pajkovsky wrote:
Signed-off-by: Nikola Pajkovskynpajkovs@redhat.com
src/cli/report.c | 9 +++------ src/include/report/event_config.h | 1 + src/lib/event_xml_parser.c | 8 ++++++++ src/plugins/report_Bugzilla.xml.in | 1 + 4 files changed, 13 insertions(+), 6 deletions(-)
diff --git a/src/cli/report.c b/src/cli/report.c index 96bf006..049d304 100644 --- a/src/cli/report.c +++ b/src/cli/report.c @@ -769,17 +769,14 @@ int report(const char *dump_dir_name, int flags) continue; }
/* TODO: npajkovs; not implemented yet */
//const char *rating_required = get_map_string_item_or_NULL(single_plugin_settings, "RatingRequired");
//if (rating_required
//&& string_to_bool(rating_required) == true
if (rating< 3)
if (rating<= config->ec_minimal_rating) { puts(_("Reporting disabled because the backtrace is unusable")); const char *package = get_problem_item_content_or_NULL(problem_data, FILENAME_PACKAGE); if (package&& package[0])
printf(_("Please try to install debuginfo manually using the command: \"debuginfo-install %s\" and try again\n"), package);
printf(_("Please try to install debuginfo manually using the command: "
"\"debuginfo-install %s\" and try again\n"), package); plugins++; errors++;
diff --git a/src/include/report/event_config.h b/src/include/report/event_config.h index 5c898d9..1e0da81 100644 --- a/src/include/report/event_config.h +++ b/src/include/report/event_config.h @@ -72,6 +72,7 @@ typedef struct char *description; // "Report to..."/"Save to file". Should be one sentence, not long char *long_descr; // Long(er) explanation, if needed GList *options;
unsigned ec_minimal_rating; } event_config_t;
event_config_t *new_event_config(void);
diff --git a/src/lib/event_xml_parser.c b/src/lib/event_xml_parser.c index 17e8a72..52ac5a3 100644 --- a/src/lib/event_xml_parser.c +++ b/src/lib/event_xml_parser.c @@ -24,6 +24,7 @@ #define DESCRIPTION_ELEMENT "description" #define LONG_DESCR_ELEMENT "long-description" #define ALLOW_EMPTY_ELEMENT "allow-empty" +#define MINIMAL_RATING_ELEMENT "minimal-rating" #define NOTE_HTML_ELEMENT "note-html" #define OPTION_ELEMENT "option" //#define ACTION_ELEMENT "action" @@ -355,6 +356,13 @@ static void text(GMarkupParseContext *context, } return; }
if (strcmp(inner_element, MINIMAL_RATING_ELEMENT) == 0)
{
VERB2 log("minimal-rating:'%s'", text_copy);
ui->ec_minimal_rating = xatoi(text_copy);
- if this fails, the minimal rating is set to 0 and I'm not sure what
to do here (default value? refuse to report?)
if xatoi fails it dies. OTOH if minimal-rating is not found than minimal-rating is set to 0. Refuse to report how?
- ok, so it's even worse, xatoi calls exit() on error, which is
probably not a good thing to do in a library... so if I have:
<minimal-rating>foo</minimal-rating>
it will kill the whole application using this library.. or am I missing something?
Nope, you don't. But if someone is not clever enough and put the messy thing what do you want to do? I want to stop the app and say, that wrong number is used. Or do you want to log it and pretend that everything is ok and, let's say, we use default value instead?
return;
}
}} free(text_copy);
diff --git a/src/plugins/report_Bugzilla.xml.in b/src/plugins/report_Bugzilla.xml.in index 8a53f61..2f4e231 100644 --- a/src/plugins/report_Bugzilla.xml.in +++ b/src/plugins/report_Bugzilla.xml.in @@ -1,6 +1,7 @@
<?xml version="1.0" encoding="UTF-8" ?>
<event> <_name>Bugzilla</_name> +<minimal-rating>3</minimal-rating> <_description>Report to Bugzilla bug tracker</_description> <options> <option type="text" name="Bugzilla_BugzillaURL">
- the rest seems ok (except the fact we should have this in a library
and share the code in cli and gui...)
written in my TODO list