summaryrefslogtreecommitdiffstats
path: root/lib/Plugins/Bugzilla.cpp
diff options
context:
space:
mode:
authorJiri Moskovcak <jmoskovc@redhat.com>2010-01-21 21:20:33 +0100
committerJiri Moskovcak <jmoskovc@redhat.com>2010-01-21 21:20:33 +0100
commitce57d1299f6dadecb36c597e35c00de79d00c5f4 (patch)
tree0a900704b79558b4f1683debc9b36fd62b2f2c5b /lib/Plugins/Bugzilla.cpp
parentf750288769b23497ad5b57b1c50f683402c509f6 (diff)
parent4b54f9866f0dbdc859e300b0169b6ef504ee6c12 (diff)
downloadabrt-ce57d1299f6dadecb36c597e35c00de79d00c5f4.tar.gz
abrt-ce57d1299f6dadecb36c597e35c00de79d00c5f4.tar.xz
abrt-ce57d1299f6dadecb36c597e35c00de79d00c5f4.zip
Merge branch 'master' into rhel6
Conflicts: src/Daemon/abrt.conf
Diffstat (limited to 'lib/Plugins/Bugzilla.cpp')
-rw-r--r--lib/Plugins/Bugzilla.cpp92
1 files changed, 63 insertions, 29 deletions
diff --git a/lib/Plugins/Bugzilla.cpp b/lib/Plugins/Bugzilla.cpp
index f963eb9..0197a7b 100644
--- a/lib/Plugins/Bugzilla.cpp
+++ b/lib/Plugins/Bugzilla.cpp
@@ -11,7 +11,9 @@
# include <config.h>
#endif
-#define XML_RPC_SUFFIX "/xmlrpc.cgi"
+#define XML_RPC_SUFFIX "/xmlrpc.cgi"
+#define NEW_BUG -1
+#define MISSING_MEMBER -2
/*
* TODO: npajkovs: better deallocation of xmlrpc value
@@ -32,8 +34,8 @@ struct ctx: public abrt_xmlrpc_conn {
int32_t check_uuid_in_bugzilla(const char* component, const char* UUID);
bool check_cc_and_reporter(uint32_t bug_id, const char* login);
void add_plus_one_cc(uint32_t bug_id, const char* login);
- uint32_t new_bug(const map_crash_report_t& pCrashReport);
- void add_attachments(const char* bug_id_str, const map_crash_report_t& pCrashReport);
+ uint32_t new_bug(const map_crash_data_t& pCrashData);
+ void add_attachments(const char* bug_id_str, const map_crash_data_t& pCrashData);
};
void ctx::login(const char* login, const char* passwd)
@@ -123,6 +125,12 @@ bool ctx::check_cc_and_reporter(uint32_t bug_id, const char* login)
return true;
}
}
+ else
+ {
+ VERB3 log("Missing member 'reporter'");
+ xmlrpc_DECREF(result);
+ throw CABRTException(EXCEP_PLUGIN, _("Missing member 'bugs'"));
+ }
xmlrpc_value* cc_member = NULL;
xmlrpc_struct_find_value(&env, result, "cc", &cc_member);
@@ -169,6 +177,12 @@ bool ctx::check_cc_and_reporter(uint32_t bug_id, const char* login)
}
xmlrpc_DECREF(cc_member);
}
+ else
+ {
+ VERB3 log("Missing member 'bugs'");
+ xmlrpc_DECREF(result);
+ throw CABRTException(EXCEP_PLUGIN, _("Missing member 'cc'"));
+ }
xmlrpc_DECREF(result);
return false;
@@ -235,7 +249,7 @@ int32_t ctx::check_uuid_in_bugzilla(const char* component, const char* UUID)
{
xmlrpc_DECREF(result);
xmlrpc_DECREF(bugs_member);
- return -1;
+ return NEW_BUG;
}
xmlrpc_value* item = NULL;
@@ -270,30 +284,42 @@ int32_t ctx::check_uuid_in_bugzilla(const char* component, const char* UUID)
xmlrpc_DECREF(result);
return bug_id;
}
+ else
+ {
+ VERB3 log("Missing member 'bug_id'");
+ xmlrpc_DECREF(result);
+ throw CABRTException(EXCEP_PLUGIN, _("Missing member 'bug_id'"));
+ }
xmlrpc_DECREF(item);
xmlrpc_DECREF(bugs_member);
}
+ else
+ {
+ VERB3 log("Missing member 'bugs'");
+ xmlrpc_DECREF(result);
+ throw CABRTException(EXCEP_PLUGIN, _("Missing member 'bugs'"));
+ }
xmlrpc_DECREF(result);
- return -1;
+ return MISSING_MEMBER;
}
-uint32_t ctx::new_bug(const map_crash_report_t& pCrashReport)
+uint32_t ctx::new_bug(const map_crash_data_t& pCrashData)
{
xmlrpc_env env;
xmlrpc_env_init(&env);
- std::string package = pCrashReport.find(FILENAME_PACKAGE)->second[CD_CONTENT];
- std::string component = pCrashReport.find(FILENAME_COMPONENT)->second[CD_CONTENT];
- std::string release = pCrashReport.find(FILENAME_RELEASE)->second[CD_CONTENT];
- std::string arch = pCrashReport.find(FILENAME_ARCHITECTURE)->second[CD_CONTENT];
- std::string uuid = pCrashReport.find(CD_UUID)->second[CD_CONTENT];
+ const std::string& package = get_crash_data_item_content(pCrashData, FILENAME_PACKAGE);
+ 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_DUPHASH);
std::string summary = "[abrt] crash in " + package;
std::string status_whiteboard = "abrt_hash:" + uuid;
std::string description = "abrt "VERSION" detected a crash.\n\n";
- description += make_description_bz(pCrashReport);
+ description += make_description_bz(pCrashData);
std::string product;
std::string version;
@@ -346,28 +372,29 @@ uint32_t ctx::new_bug(const map_crash_report_t& pCrashReport)
return bug_id;
}
-void ctx::add_attachments(const char* bug_id_str, const map_crash_report_t& pCrashReport)
+void ctx::add_attachments(const char* bug_id_str, const map_crash_data_t& pCrashData)
{
xmlrpc_env env;
xmlrpc_env_init(&env);
xmlrpc_value* result = NULL;
- map_crash_report_t::const_iterator it = pCrashReport.begin();
- for (; it != pCrashReport.end(); it++)
+ map_crash_data_t::const_iterator it = pCrashData.begin();
+ for (; it != pCrashData.end(); it++)
{
- const std::string &filename = it->first;
+ const std::string &itemname = it->first;
const std::string &type = it->second[CD_TYPE];
const std::string &content = it->second[CD_CONTENT];
- if (type == CD_TXT && content.length() > CD_TEXT_ATT_SIZE)
- {
+ if (type == CD_TXT
+ && (content.length() > CD_TEXT_ATT_SIZE || itemname == FILENAME_BACKTRACE)
+ ) {
char *encoded64 = encode_base64(content.c_str(), content.length());
// fails only when you write query. when it's done it never fails.
xmlrpc_value* param = xmlrpc_build_value(&env, "(s{s:s,s:s,s:s,s:s})",
bug_id_str,
- "description", ("File: " + filename).c_str(),
- "filename", filename.c_str(),
+ "description", ("File: " + itemname).c_str(),
+ "filename", itemname.c_str(),
"contenttype", "text/plain",
"data", encoded64
);
@@ -404,7 +431,7 @@ CReporterBugzilla::CReporterBugzilla() :
CReporterBugzilla::~CReporterBugzilla()
{}
-std::string CReporterBugzilla::Report(const map_crash_report_t& pCrashReport,
+std::string CReporterBugzilla::Report(const map_crash_data_t& pCrashData,
const map_plugin_settings_t& pSettings,
const char *pArgs)
{
@@ -433,8 +460,8 @@ std::string CReporterBugzilla::Report(const map_crash_report_t& pCrashReport,
NoSSLVerify = m_bNoSSLVerify;
}
- std::string component = pCrashReport.find(FILENAME_COMPONENT)->second[CD_CONTENT];
- std::string uuid = pCrashReport.find(CD_UUID)->second[CD_CONTENT];
+ const std::string& component = get_crash_data_item_content(pCrashData, FILENAME_COMPONENT);
+ const std::string& uuid = get_crash_data_item_content(pCrashData, CD_DUPHASH);
try
{
ctx bz_server(BugzillaXMLRPC.c_str(), NoSSLVerify);
@@ -442,12 +469,13 @@ std::string CReporterBugzilla::Report(const map_crash_report_t& pCrashReport,
update_client(_("Checking for duplicates..."));
bug_id = bz_server.check_uuid_in_bugzilla(component.c_str(), uuid.c_str());
- update_client(_("Logging into bugzilla..."));
if ((Login == "") && (Password == ""))
{
VERB3 log("Empty login and password");
throw CABRTException(EXCEP_PLUGIN, _("Empty login and password. Please check Bugzilla.conf"));
}
+
+ update_client(_("Logging into bugzilla..."));
bz_server.login(Login.c_str(), Password.c_str());
if (bug_id > 0)
@@ -458,12 +486,14 @@ std::string CReporterBugzilla::Report(const map_crash_report_t& pCrashReport,
bz_server.add_plus_one_cc(bug_id, Login.c_str());
}
bz_server.logout();
- return BugzillaURL + "/show_bug.cgi?id=" + to_string(bug_id);
+ BugzillaURL += "/show_bug.cgi?id=";
+ BugzillaURL += to_string(bug_id);
+ return BugzillaURL;
}
update_client(_("Creating new bug..."));
- bug_id = bz_server.new_bug(pCrashReport);
- bz_server.add_attachments(to_string(bug_id).c_str(), pCrashReport);
+ bug_id = bz_server.new_bug(pCrashData);
+ bz_server.add_attachments(to_string(bug_id).c_str(), pCrashData);
update_client(_("Logging out..."));
bz_server.logout();
@@ -475,12 +505,16 @@ std::string CReporterBugzilla::Report(const map_crash_report_t& pCrashReport,
if (bug_id > 0)
{
- return BugzillaURL + "/show_bug.cgi?id=" + to_string(bug_id);
+ BugzillaURL += "/show_bug.cgi?id=";
+ BugzillaURL += to_string(bug_id);
+ return BugzillaURL;
}
- return BugzillaURL + "/show_bug.cgi?id=";
+ BugzillaURL += "/show_bug.cgi?id=";
+ return BugzillaURL;
}
+//todo: make static
map_plugin_settings_t CReporterBugzilla::parse_settings(const map_plugin_settings_t& pSettings)
{
map_plugin_settings_t plugin_settings;