summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDenys Vlasenko <vda.linux@googlemail.com>2009-11-19 10:23:12 +0100
committerDenys Vlasenko <vda.linux@googlemail.com>2009-11-19 10:23:12 +0100
commitc18c9c5a0493bca0c978911460da67ef5e59b442 (patch)
treefc3e94ffddbc26bf27e9757b12d8e95fef280ac7
parent83aea71df4761ec10c0d947055e65102bcace489 (diff)
downloadabrt-c18c9c5a0493bca0c978911460da67ef5e59b442.tar.gz
abrt-c18c9c5a0493bca0c978911460da67ef5e59b442.tar.xz
abrt-c18c9c5a0493bca0c978911460da67ef5e59b442.zip
move Catcut's description generation to lib/Utils/make_descr.cpp
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
-rw-r--r--lib/Plugins/Catcut.cpp58
-rw-r--r--lib/Utils/Plugin.h9
-rw-r--r--lib/Utils/make_descr.cpp71
3 files changed, 78 insertions, 60 deletions
diff --git a/lib/Plugins/Catcut.cpp b/lib/Plugins/Catcut.cpp
index cf1d7d9c..e353cbed 100644
--- a/lib/Plugins/Catcut.cpp
+++ b/lib/Plugins/Catcut.cpp
@@ -9,65 +9,12 @@
#include "ABRTException.h"
#include "CommLayerInner.h"
#ifdef HAVE_CONFIG_H
- #include "config.h"
+# include "config.h"
#endif
using namespace std;
-//TODO: move to make_descr.cpp
-static void create_new_bug_description(const map_crash_report_t& pCrashReport, string& pDescription)
-{
- string howToReproduce;
- 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 "VERSION" detected a crash.\n" +
- howToReproduce +
- comment +
- "\n\nAdditional information\n"
- "======\n";
-
- map_crash_report_t::const_iterator it;
- for (it = pCrashReport.begin(); 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)
- {
- error_msg(_("Binary file %s will not be reported"), it->first.c_str());
- }
- }
-}
-
static int
put_stream(const char *pURL, FILE* f, size_t content_length)
{
@@ -324,8 +271,7 @@ ctx::new_bug(const char *auth_cookie, const map_crash_report_t& pCrashReport)
string summary = "[abrt] crash detected in " + package;
string status_whiteboard = "abrt_hash:" + uuid;
- string description;
- create_new_bug_description(pCrashReport, description);
+ string description = make_description_catcut(pCrashReport);
string product;
string version;
diff --git a/lib/Utils/Plugin.h b/lib/Utils/Plugin.h
index f93f7e7b..9447f453 100644
--- a/lib/Utils/Plugin.h
+++ b/lib/Utils/Plugin.h
@@ -26,13 +26,13 @@
#include "abrt_types.h"
#include "CrashTypes.h"
#if HAVE_CONFIG_H
- #include <config.h>
+# include <config.h>
#endif
#if ENABLE_NLS
- #include <libintl.h>
- #define _(S) gettext(S)
+# include <libintl.h>
+# define _(S) gettext(S)
#else
- #define _(S) (S)
+# define _(S) (S)
#endif
#define PLUGINS_MAGIC_NUMBER 6
@@ -121,5 +121,6 @@ typedef struct SPluginInfo
/* helper finctions */
std::string make_description_bz(const map_crash_report_t& pCrashReport);
std::string make_description_logger(const map_crash_report_t& pCrashReport);
+std::string make_description_catcut(const map_crash_report_t& pCrashReport);
#endif
diff --git a/lib/Utils/make_descr.cpp b/lib/Utils/make_descr.cpp
index 0c096143..46dd48c8 100644
--- a/lib/Utils/make_descr.cpp
+++ b/lib/Utils/make_descr.cpp
@@ -2,6 +2,15 @@
//#include "abrt_types.h"
#include "CrashTypes.h"
#include "DebugDump.h" /* FILENAME_ARCHITECTURE etc */
+#ifdef HAVE_CONFIG_H
+# include "config.h"
+#endif
+#if ENABLE_NLS
+# include <libintl.h>
+# define _(S) gettext(S)
+#else
+# define _(S) (S)
+#endif
using namespace std;
@@ -131,3 +140,65 @@ string make_description_logger(const map_crash_report_t& pCrashReport)
return description;
}
+
+/* This needs more work to make the result less ugly */
+string make_description_catcut(const map_crash_report_t& pCrashReport)
+{
+ map_crash_report_t::const_iterator end = pCrashReport.end();
+ map_crash_report_t::const_iterator it;
+
+ string howToReproduce;
+ it = pCrashReport.find(CD_REPRODUCE);
+ if (it != end)
+ {
+ howToReproduce = "\n\nHow to reproduce\n"
+ "-----\n";
+ howToReproduce += it->second[CD_CONTENT];
+ }
+ string comment;
+ it = pCrashReport.find(CD_COMMENT);
+ if (it != end)
+ {
+ comment = "\n\nComment\n"
+ "-----\n";
+ comment += it->second[CD_CONTENT];
+ }
+
+ string pDescription = "\nabrt "VERSION" detected a crash.\n";
+ pDescription += howToReproduce;
+ pDescription += comment;
+ pDescription += "\n\nAdditional information\n"
+ "======\n";
+
+ for (it = pCrashReport.begin(); it != 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';
+ pDescription += it->first;
+ pDescription += "\n-----\n";
+ pDescription += it->second[CD_CONTENT];
+ pDescription += "\n\n";
+ }
+ }
+ else if (it->second[CD_TYPE] == CD_ATT)
+ {
+ pDescription += "\n\nAttached files\n"
+ "----\n";
+ pDescription += it->first;
+ pDescription += '\n';
+ }
+ else if (it->second[CD_TYPE] == CD_BIN)
+ {
+ error_msg(_("Binary file %s will not be reported"), it->first.c_str());
+ }
+ }
+
+ return pDescription;
+}