diff options
| author | Denys Vlasenko <vda.linux@googlemail.com> | 2009-10-30 17:46:26 +0100 |
|---|---|---|
| committer | Denys Vlasenko <vda.linux@googlemail.com> | 2009-10-30 17:46:26 +0100 |
| commit | 70e0330d6919b3e7e372e5cdd04282a51fe64788 (patch) | |
| tree | 1433a08aaddd14bd01c59acccd9080de9239e675 | |
| parent | 7ed940376e92f31dd7fb79720788d6b6f7425b43 (diff) | |
| download | abrt-70e0330d6919b3e7e372e5cdd04282a51fe64788.tar.gz abrt-70e0330d6919b3e7e372e5cdd04282a51fe64788.tar.xz abrt-70e0330d6919b3e7e372e5cdd04282a51fe64788.zip | |
lib/Plugins/Bugzilla: generate less sparse bug report comments
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
| -rw-r--r-- | lib/Plugins/Bugzilla.cpp | 52 | ||||
| -rw-r--r-- | lib/Utils/Makefile.am | 2 | ||||
| -rw-r--r-- | lib/Utils/Plugin.h | 20 | ||||
| -rw-r--r-- | lib/Utils/make_descr.cpp | 87 |
4 files changed, 101 insertions, 60 deletions
diff --git a/lib/Plugins/Bugzilla.cpp b/lib/Plugins/Bugzilla.cpp index d78c765..84c7934 100644 --- a/lib/Plugins/Bugzilla.cpp +++ b/lib/Plugins/Bugzilla.cpp @@ -267,56 +267,8 @@ static int32_t check_uuid_in_bugzilla(const char* component, const char* UUID) static void create_new_bug_description(const map_crash_report_t& pCrashReport, std::string& pDescription) { - std::string howToReproduce; - std::string comment; - - if (pCrashReport.find(CD_REPRODUCE) != pCrashReport.end()) - { - howToReproduce = "\n\nHow to reproduce\n" - "-----\n" + - pCrashReport.find(CD_REPRODUCE)->second[CD_CONTENT]; - } - if (pCrashReport.find(CD_COMMENT) != pCrashReport.end()) - { - comment = "\n\nComment\n" - "-----\n" + - pCrashReport.find(CD_COMMENT)->second[CD_CONTENT]; - } - pDescription = "\nabrt detected a crash.\n" + - howToReproduce + - comment + - "\n\nAdditional information\n" - "======\n"; - - map_crash_report_t::const_iterator it = pCrashReport.begin(); - for (; it != pCrashReport.end(); it++) - { - if (it->second[CD_TYPE] == CD_TXT) - { - if (it->first != CD_UUID && - it->first != FILENAME_ARCHITECTURE && - it->first != FILENAME_RELEASE && - it->first != CD_REPRODUCE && - it->first != CD_COMMENT) - { - pDescription += "\n" + it->first + "\n"; - pDescription += "-----\n"; - pDescription += it->second[CD_CONTENT] + "\n\n"; - } - } - else if (it->second[CD_TYPE] == CD_ATT) - { - pDescription += "\n\nAttached files\n" - "----\n"; - pDescription += it->first + "\n"; - } - else if (it->second[CD_TYPE] == CD_BIN) - { - std::string msg = ssprintf(_("Binary file %s will not be reported."), it->first.c_str()); - warn_client(msg); - //update_client(_("Binary file ")+it->first+_(" will not be reported.")); - } - } + pDescription = "abrt detected a crash.\n\n"; + pDescription += make_description_bz(pCrashReport); } static void get_product_and_version(const std::string& pRelease, diff --git a/lib/Utils/Makefile.am b/lib/Utils/Makefile.am index 3c51085..7823b4d 100644 --- a/lib/Utils/Makefile.am +++ b/lib/Utils/Makefile.am @@ -15,7 +15,7 @@ libABRTUtils_la_SOURCES = \ DebugDump.h DebugDump.cpp \ CommLayerInner.h CommLayerInner.cpp \ abrt_dbus.h abrt_dbus.cpp \ - Plugin.h Plugin.cpp \ + Plugin.h Plugin.cpp make_descr.cpp \ Polkit.h Polkit.cpp \ Action.h Database.h Reporter.h Analyzer.h \ Observer.h \ diff --git a/lib/Utils/Plugin.h b/lib/Utils/Plugin.h index 3929023..eabfa10 100644 --- a/lib/Utils/Plugin.h +++ b/lib/Utils/Plugin.h @@ -24,17 +24,10 @@ #define PLUGIN_H_ #include "abrt_types.h" - -#define PLUGINS_MAGIC_NUMBER 6 - -#define PLUGINS_CONF_EXTENSION "conf" -#define PLUGINS_LIB_EXTENSION "so" -#define PLUGINS_LIB_PREFIX "lib" - +#include "CrashTypes.h" #if HAVE_CONFIG_H #include <config.h> #endif - #if ENABLE_NLS #include <libintl.h> #define _(S) gettext(S) @@ -42,6 +35,12 @@ #define _(S) (S) #endif +#define PLUGINS_MAGIC_NUMBER 6 + +#define PLUGINS_CONF_EXTENSION "conf" +#define PLUGINS_LIB_EXTENSION "so" +#define PLUGINS_LIB_PREFIX "lib" + /** * An abstract class. The class defines a common plugin interface. If a plugin * has some settings, then a *Settings(*) method has to be written. @@ -115,4 +114,7 @@ typedef struct SPluginInfo PLUGINS_MAGIC_NUMBER,\ }; -#endif /* PLUGIN_H_ */ +/* helper finctions */ +std::string make_description_bz(const map_crash_report_t& pCrashReport); + +#endif diff --git a/lib/Utils/make_descr.cpp b/lib/Utils/make_descr.cpp new file mode 100644 index 0000000..8f1c861 --- /dev/null +++ b/lib/Utils/make_descr.cpp @@ -0,0 +1,87 @@ +#include "abrtlib.h" +//#include "abrt_types.h" +#include "CrashTypes.h" +#include "DebugDump.h" /* FILENAME_ARCHITECTURE etc */ + +using namespace std; + +static void add_content(bool &was_multiline, string& description, const char *header, const char *content) +{ + /* We separate multiline contents with emply line */ + if (was_multiline) + description += '\n'; + + description += header; + + while (content[0] == '\n') + content++; + + if (strchr(content, '\n') == NULL) + { + /* one string value, like OS release */ + description += ": "; + description += content; + description += '\n'; + was_multiline = 0; + } + else + { + /* multi-string value, like backtrace */ + description += "\n-----\n"; + description += content; + if (content[strlen(content) - 1] != '\n') + description += '\n'; + was_multiline = 1; + } +} + +string make_description_bz(const map_crash_report_t& pCrashReport) +{ + string description; + + map_crash_report_t::const_iterator it; + map_crash_report_t::const_iterator end = pCrashReport.end(); + + bool was_multiline = 0; + it = pCrashReport.find(CD_REPRODUCE); + if (it != end && it->second[CD_CONTENT] != "1.\n2.\n3.\n") + { + add_content(was_multiline, description, "How to reproduce", it->second[CD_CONTENT].c_str()); + } + + it = pCrashReport.find(CD_COMMENT); + if (it != end) + { + add_content(was_multiline, description, "Comment", it->second[CD_CONTENT].c_str()); + } + + it = pCrashReport.begin(); + for (; it != end; it++) + { + const string &filename = it->first; + const string &type = it->second[CD_TYPE]; + const string &content = it->second[CD_CONTENT]; + if (type == CD_TXT) + { + if (filename != CD_UUID + && filename != FILENAME_ARCHITECTURE + && filename != FILENAME_RELEASE + && filename != CD_REPRODUCE + && filename != CD_COMMENT + ) { + add_content(was_multiline, description, filename.c_str(), content.c_str()); + } + } + else if (type == CD_ATT) + { + add_content(was_multiline, description, "Attached file", filename.c_str()); + } + //else if (type == CD_BIN) + //{ + // string msg = ssprintf(_("Binary file %s is not reported"), filename.c_str()); + // warn_client(msg); + //} + } + + return description; +} |
