diff options
author | Nikola Pajkovsky <npajkovs@redhat.com> | 2010-01-21 17:55:12 +0100 |
---|---|---|
committer | Nikola Pajkovsky <npajkovs@redhat.com> | 2010-01-21 17:55:12 +0100 |
commit | 6a332432509a6c7299d212b1bb769cf6dd054758 (patch) | |
tree | e935a2b4806f10fbb1b5ae448c7427d304f2c439 /lib | |
parent | 2afa768308a7f00f0f0d5c4a95f5b20e8c62ef39 (diff) | |
parent | 44d7d1e6acb25dc719838560b002514fc51b62c3 (diff) | |
download | abrt-6a332432509a6c7299d212b1bb769cf6dd054758.tar.gz abrt-6a332432509a6c7299d212b1bb769cf6dd054758.tar.xz abrt-6a332432509a6c7299d212b1bb769cf6dd054758.zip |
Merge branch 'master' into hotfix
Diffstat (limited to 'lib')
-rw-r--r-- | lib/Plugins/Bugzilla.cpp | 4 | ||||
-rw-r--r-- | lib/Plugins/Catcut.cpp | 2 | ||||
-rw-r--r-- | lib/Plugins/FileTransfer.cpp | 6 | ||||
-rw-r--r-- | lib/Plugins/Mailx.cpp | 20 | ||||
-rw-r--r-- | lib/Plugins/TicketUploader.h | 1 | ||||
-rw-r--r-- | lib/Utils/CrashTypes.cpp | 83 | ||||
-rw-r--r-- | lib/Utils/make_descr.cpp | 20 | ||||
-rw-r--r-- | lib/Utils/test.cpp | 8 |
8 files changed, 104 insertions, 40 deletions
diff --git a/lib/Plugins/Bugzilla.cpp b/lib/Plugins/Bugzilla.cpp index 5dc4298a..2fc2109a 100644 --- a/lib/Plugins/Bugzilla.cpp +++ b/lib/Plugins/Bugzilla.cpp @@ -297,7 +297,7 @@ uint32_t ctx::new_bug(const map_crash_data_t& pCrashData) const std::string& component = get_crash_data_item_content(pCrashData, FILENAME_COMPONENT); const std::string& release = get_crash_data_item_content(pCrashData, FILENAME_RELEASE); const std::string& arch = get_crash_data_item_content(pCrashData, FILENAME_ARCHITECTURE); - const std::string& uuid = get_crash_data_item_content(pCrashData, CD_UUID); + const std::string& uuid = get_crash_data_item_content(pCrashData, CD_DUPHASH); std::string summary = "[abrt] crash in " + package; std::string status_whiteboard = "abrt_hash:" + uuid; @@ -444,7 +444,7 @@ std::string CReporterBugzilla::Report(const map_crash_data_t& pCrashData, } const std::string& component = get_crash_data_item_content(pCrashData, FILENAME_COMPONENT); - const std::string& uuid = get_crash_data_item_content(pCrashData, CD_UUID); + const std::string& uuid = get_crash_data_item_content(pCrashData, CD_DUPHASH); try { ctx bz_server(BugzillaXMLRPC.c_str(), NoSSLVerify); diff --git a/lib/Plugins/Catcut.cpp b/lib/Plugins/Catcut.cpp index 1bc51f97..3580a3b4 100644 --- a/lib/Plugins/Catcut.cpp +++ b/lib/Plugins/Catcut.cpp @@ -272,7 +272,7 @@ ctx::new_bug(const char *auth_cookie, const map_crash_data_t& pCrashData) const string& component = get_crash_data_item_content(pCrashData, FILENAME_COMPONENT); const string& release = get_crash_data_item_content(pCrashData, FILENAME_RELEASE); const string& arch = get_crash_data_item_content(pCrashData, FILENAME_ARCHITECTURE); - const string& uuid = get_crash_data_item_content(pCrashData, CD_UUID); + const string& uuid = get_crash_data_item_content(pCrashData, CD_DUPHASH); string summary = "[abrt] crash in " + package; string status_whiteboard = "abrt_hash:" + uuid; diff --git a/lib/Plugins/FileTransfer.cpp b/lib/Plugins/FileTransfer.cpp index b08ecd51..e28fbbee 100644 --- a/lib/Plugins/FileTransfer.cpp +++ b/lib/Plugins/FileTransfer.cpp @@ -25,12 +25,6 @@ #include <iostream> #include <sstream> #include <fstream> -#include <stdio.h> -#include <string.h> -#include <dirent.h> -#include <sys/types.h> -#include <sys/stat.h> -#include <fcntl.h> #include <zip.h> #include <libtar.h> #include <bzlib.h> diff --git a/lib/Plugins/Mailx.cpp b/lib/Plugins/Mailx.cpp index ae8c2dc9..2ee96455 100644 --- a/lib/Plugins/Mailx.cpp +++ b/lib/Plugins/Mailx.cpp @@ -74,13 +74,13 @@ std::string CMailx::Report(const map_crash_data_t& pCrashData, args = append_str_to_vector(args, arg_size, MAILX_COMMAND); //TODO: move email body generation to make_descr.cpp - std::string binaryFiles, commonFiles, additionalFiles, UUIDFile; + std::string binaryFiles, commonFiles, additionalFiles, DUPHASHFile; map_crash_data_t::const_iterator it; for (it = pCrashData.begin(); it != pCrashData.end(); it++) { if (it->second[CD_TYPE] == CD_TXT) { - if (it->first != CD_UUID + if (it->first != CD_DUPHASH && it->first != FILENAME_ARCHITECTURE && it->first != FILENAME_KERNEL && it->first != FILENAME_PACKAGE @@ -90,12 +90,12 @@ std::string CMailx::Report(const map_crash_data_t& pCrashData, additionalFiles += it->second[CD_CONTENT]; additionalFiles += "\n\n"; } - else if (it->first == CD_UUID) + else if (it->first == CD_DUPHASH) { - UUIDFile += it->first; - UUIDFile += "\n-----\n"; - UUIDFile += it->second[CD_CONTENT]; - UUIDFile += "\n\n"; + DUPHASHFile += it->first; + DUPHASHFile += "\n-----\n"; + DUPHASHFile += it->second[CD_CONTENT]; + DUPHASHFile += "\n\n"; } else { @@ -117,9 +117,9 @@ std::string CMailx::Report(const map_crash_data_t& pCrashData, } } - std::string emailBody = "Duplicity check\n"; + std::string emailBody = "Duplicate check\n"; emailBody += "=====\n\n"; - emailBody += UUIDFile; + emailBody += DUPHASHFile; emailBody += "\nCommon information\n"; emailBody += "=====\n\n"; emailBody += commonFiles; @@ -135,7 +135,7 @@ std::string CMailx::Report(const map_crash_data_t& pCrashData, args = append_str_to_vector(args, arg_size, m_sEmailTo.c_str()); update_client(_("Sending an email...")); - const char *uid_str = get_crash_data_item_content(pCrashData, CD_MWUID).c_str(); + const char *uid_str = get_crash_data_item_content(pCrashData, FILENAME_UID).c_str(); exec_and_feed_input(xatoi_u(uid_str), emailBody.c_str(), args); while (*args) diff --git a/lib/Plugins/TicketUploader.h b/lib/Plugins/TicketUploader.h index fcc59f06..7a371a3a 100644 --- a/lib/Plugins/TicketUploader.h +++ b/lib/Plugins/TicketUploader.h @@ -27,7 +27,6 @@ #include "Plugin.h" #include "Reporter.h" -//#include "CrashTypes.h" class CTicketUploader : public CReporter { diff --git a/lib/Utils/CrashTypes.cpp b/lib/Utils/CrashTypes.cpp index 4824e507..4fc93337 100644 --- a/lib/Utils/CrashTypes.cpp +++ b/lib/Utils/CrashTypes.cpp @@ -20,6 +20,40 @@ #include "abrtlib.h" #include "CrashTypes.h" +const char *const must_have_files[] = { + FILENAME_ARCHITECTURE, + FILENAME_KERNEL , + FILENAME_PACKAGE , + FILENAME_COMPONENT , + FILENAME_RELEASE , + FILENAME_EXECUTABLE , + NULL +}; + +static const char *const editable_files[] = { + FILENAME_DESCRIPTION, + FILENAME_COMMENT , + FILENAME_REPRODUCE , + FILENAME_BACKTRACE , + NULL +}; + +static bool is_editable(const char *name, const char *const *v) +{ + while (*v) { + if (strcmp(*v, name) == 0) + return true; + v++; + } + return false; +} + +bool is_editable_file(const char *file_name) +{ + return is_editable(file_name, editable_files); +} + + void add_to_crash_data_ext(map_crash_data_t& pCrashData, const char *pItem, const char *pType, @@ -28,9 +62,10 @@ void add_to_crash_data_ext(map_crash_data_t& pCrashData, { map_crash_data_t::iterator it = pCrashData.find(pItem); if (it == pCrashData.end()) { - pCrashData[pItem].push_back(pType); - pCrashData[pItem].push_back(pEditable); - pCrashData[pItem].push_back(pContent); + vector_string_t& v = pCrashData[pItem]; /* create empty vector */ + v.push_back(pType); + v.push_back(pEditable); + v.push_back(pContent); return; } vector_string_t& v = it->second; @@ -48,14 +83,50 @@ void add_to_crash_data(map_crash_data_t& pCrashData, add_to_crash_data_ext(pCrashData, pItem, CD_TXT, CD_ISNOTEDITABLE, pContent); } -const std::string& get_crash_data_item_content(const map_crash_data_t& crash_data, const char *key) +static const std::string* helper_get_crash_data_item_content(const map_crash_data_t& crash_data, const char *key) { map_crash_data_t::const_iterator it = crash_data.find(key); if (it == crash_data.end()) { - error_msg_and_die("Error accessing crash data: no ['%s']", key); + return NULL; } if (it->second.size() <= CD_CONTENT) { + return NULL; + } + return &it->second[CD_CONTENT]; +} + +const std::string& get_crash_data_item_content(const map_crash_data_t& crash_data, const char *key) +{ + const std::string* sp = helper_get_crash_data_item_content(crash_data, key); + if (sp == NULL) { + if (crash_data.find(key) == crash_data.end()) + error_msg_and_die("Error accessing crash data: no ['%s']", key); error_msg_and_die("Error accessing crash data: no ['%s'][%d]", key, CD_CONTENT); } - return it->second[CD_CONTENT]; + return *sp; +} + +const char *get_crash_data_item_content_or_NULL(const map_crash_data_t& crash_data, const char *key) +{ + const std::string* sp = helper_get_crash_data_item_content(crash_data, key); + if (!sp) { + return NULL; + } + return sp->c_str(); +} + +void log_map_crash_data(const map_crash_data_t& data, const char *name) +{ + map_crash_data_t::const_iterator it = data.begin(); + while (it != data.end()) + { + ssize_t sz = it->second.size(); + log("%s[%s]:%s/%s/'%.20s'", + name, it->first.c_str(), + sz > 0 ? it->second[0].c_str() : "<NO [0]>", + sz > 1 ? it->second[1].c_str() : "<NO [1]>", + sz > 2 ? it->second[2].c_str() : "<NO [2]>" + ); + it++; + } } diff --git a/lib/Utils/make_descr.cpp b/lib/Utils/make_descr.cpp index e74e9b1d..a3ff5e24 100644 --- a/lib/Utils/make_descr.cpp +++ b/lib/Utils/make_descr.cpp @@ -58,13 +58,13 @@ string make_description_bz(const map_crash_data_t& pCrashData) map_crash_data_t::const_iterator end = pCrashData.end(); bool was_multiline = 0; - it = pCrashData.find(CD_REPRODUCE); + it = pCrashData.find(FILENAME_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 = pCrashData.find(CD_COMMENT); + it = pCrashData.find(FILENAME_COMMENT); if (it != end) { add_content(was_multiline, description, "Comment", it->second[CD_CONTENT].c_str()); @@ -80,11 +80,11 @@ string make_description_bz(const map_crash_data_t& pCrashData) { if (content.size() <= CD_TEXT_ATT_SIZE) { - if (filename != CD_UUID + if (filename != CD_DUPHASH && filename != FILENAME_ARCHITECTURE && filename != FILENAME_RELEASE - && filename != CD_REPRODUCE - && filename != CD_COMMENT + && filename != FILENAME_REPRODUCE + && filename != FILENAME_COMMENT ) { add_content(was_multiline, description, filename.c_str(), content.c_str()); } @@ -147,7 +147,7 @@ string make_description_catcut(const map_crash_data_t& pCrashData) map_crash_data_t::const_iterator it; string howToReproduce; - it = pCrashData.find(CD_REPRODUCE); + it = pCrashData.find(FILENAME_REPRODUCE); if (it != end) { howToReproduce = "\n\nHow to reproduce\n" @@ -155,7 +155,7 @@ string make_description_catcut(const map_crash_data_t& pCrashData) howToReproduce += it->second[CD_CONTENT]; } string comment; - it = pCrashData.find(CD_COMMENT); + it = pCrashData.find(FILENAME_COMMENT); if (it != end) { comment = "\n\nComment\n" @@ -178,11 +178,11 @@ string make_description_catcut(const map_crash_data_t& pCrashData) { if (content.length() <= CD_TEXT_ATT_SIZE) { - if (filename != CD_UUID + if (filename != CD_DUPHASH && filename != FILENAME_ARCHITECTURE && filename != FILENAME_RELEASE - && filename != CD_REPRODUCE - && filename != CD_COMMENT + && filename != FILENAME_REPRODUCE + && filename != FILENAME_COMMENT ) { pDescription += '\n'; pDescription += filename; diff --git a/lib/Utils/test.cpp b/lib/Utils/test.cpp index 160c107b..3711ef18 100644 --- a/lib/Utils/test.cpp +++ b/lib/Utils/test.cpp @@ -84,16 +84,16 @@ int main(int argc, char** argv) if (middleWare.SaveDebugDump(argv[1], crashInfo)) { std::cout << "Application Crashed! " << - crashInfo[CD_PACKAGE][CD_CONTENT] << ", " << - crashInfo[CD_EXECUTABLE][CD_CONTENT] << ", " << + crashInfo[FILENAME_PACKAGE][CD_CONTENT] << ", " << + crashInfo[FILENAME_EXECUTABLE][CD_CONTENT] << ", " << crashInfo[CD_COUNT][CD_CONTENT] << ", " << std::endl; /* Get Report, so user can change data (remove private stuff) * If we do not want user interaction, just send data immediately */ map_crash_data_t crashReport; - middleWare.CreateCrashReport(crashInfo[CD_UUID][CD_CONTENT], - crashInfo[CD_UID][CD_CONTENT], + middleWare.CreateCrashReport(crashInfo[CD_DUPHASH][CD_CONTENT], + crashInfo[FILENAME_UID][CD_CONTENT], crashReport); /* Report crash */ middleWare.Report(crashReport); |