diff options
| author | Denys Vlasenko <vda.linux@googlemail.com> | 2010-03-02 14:13:26 +0100 |
|---|---|---|
| committer | Denys Vlasenko <vda.linux@googlemail.com> | 2010-03-02 14:13:26 +0100 |
| commit | 06edc0f42e6d3b92d06b04a96848152bc680c3ba (patch) | |
| tree | 5d5228213de80d80e83675ec15150f358ce4ab5a | |
| parent | c52972c8a37e125b8f6ba7470ae1d1fab3896c2b (diff) | |
| download | abrt-06edc0f42e6d3b92d06b04a96848152bc680c3ba.tar.gz abrt-06edc0f42e6d3b92d06b04a96848152bc680c3ba.tar.xz abrt-06edc0f42e6d3b92d06b04a96848152bc680c3ba.zip | |
save reporters' results to abrt_vNN_reportresult table too
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
| -rw-r--r-- | lib/Plugins/SQLite3.cpp | 41 | ||||
| -rw-r--r-- | lib/Plugins/SQLite3.h | 4 | ||||
| -rw-r--r-- | lib/Utils/Database.h | 4 | ||||
| -rw-r--r-- | src/Daemon/MiddleWare.cpp | 12 |
4 files changed, 56 insertions, 5 deletions
diff --git a/lib/Plugins/SQLite3.cpp b/lib/Plugins/SQLite3.cpp index b2be21a..5819b98 100644 --- a/lib/Plugins/SQLite3.cpp +++ b/lib/Plugins/SQLite3.cpp @@ -147,7 +147,7 @@ static void get_table(vector_database_rows_t& pTable, sqlite3_free_table(table); } -static void execute_sql(sqlite3 *db, const char *fmt, ...) +static int execute_sql(sqlite3 *db, const char *fmt, ...) { va_list p; va_start(p, fmt); @@ -163,8 +163,11 @@ static void execute_sql(sqlite3 *db, const char *fmt, ...) sqlite3_free(err); throw CABRTException(EXCEP_PLUGIN, errstr.c_str()); } - VERB2 log("%d rows affected by SQL:%s", sqlite3_changes(db), sql); + int affected = sqlite3_changes(db); + VERB2 log("%d rows affected by SQL:%s", affected, sql); free(sql); + + return affected; } static bool exists_uuid_uid(sqlite3 *db, const char *pUUID, const char *pUID) @@ -481,9 +484,6 @@ void CSQLite3::DeleteRows_by_dir(const char *dump_dir) void CSQLite3::SetReported(const char *pUUID, const char *pUID, const char *pMessage) { -// string escaped_msg = sql_escape(pMessage); -//#define pMessage pMessage_must_not_be_used_below - if (!is_string_safe(pUUID) || !is_string_safe(pUID) || !is_string_safe(pMessage) @@ -528,6 +528,37 @@ void CSQLite3::SetReported(const char *pUUID, const char *pUID, const char *pMes } } +void CSQLite3::SetReportedPerReporter(const char *pUUID, + const char *pUID, + const char *reporter, + const char *pMessage) +{ + if (!is_string_safe(pUUID) + || !is_string_safe(pUID) + || !is_string_safe(reporter) + || !is_string_safe(pMessage) + ) { + return; + } + + int affected_rows = execute_sql(m_pDB, + "UPDATE "ABRT_REPRESULT_TABLE + " SET "COL_MESSAGE"='%s'" + " WHERE "COL_UUID"='%s' AND "COL_UID"='%s' AND "COL_REPORTER"='%s'", + pMessage, + pUUID, pUID, reporter + ); + if (!affected_rows) + { + execute_sql(m_pDB, + "INSERT INTO "ABRT_REPRESULT_TABLE + " ("COL_UUID","COL_UID","COL_REPORTER","COL_MESSAGE")" + " VALUES ('%s','%s','%s','%s');", + pUUID, pUID, reporter, pMessage + ); + } +} + vector_database_rows_t CSQLite3::GetUIDData(const char *pUID) { vector_database_rows_t table; diff --git a/lib/Plugins/SQLite3.h b/lib/Plugins/SQLite3.h index d4b321a..94cb042 100644 --- a/lib/Plugins/SQLite3.h +++ b/lib/Plugins/SQLite3.h @@ -45,6 +45,10 @@ class CSQLite3 : public CDatabase virtual void DeleteRow(const char *pUUID, const char *pUID); virtual void DeleteRows_by_dir(const char *dump_dir); virtual void SetReported(const char *pUUID, const char *pUID, const char *pMessage); + virtual void SetReportedPerReporter(const char *pUUID, + const char *pUID, + const char *reporter, + const char *pMessage); virtual vector_database_rows_t GetUIDData(const char *pUID); virtual database_row_t GetRow(const char *pUUID, const char *pUID); diff --git a/lib/Utils/Database.h b/lib/Utils/Database.h index ed4ef0c..6d7613b 100644 --- a/lib/Utils/Database.h +++ b/lib/Utils/Database.h @@ -95,6 +95,10 @@ class CDatabase : public CPlugin virtual void SetReported(const char *pUUID, const char *pUID, const char *pMessage) = 0; + virtual void SetReportedPerReporter(const char *pUUID, + const char *pUID, + const char *reporter, + const char *pMessage) = 0; /** * A method, which gets all rows which belongs to particular user. * If the user is root, then all rows are returned. If there are no diff --git a/src/Daemon/MiddleWare.cpp b/src/Daemon/MiddleWare.cpp index 6c3c58a..16b86da 100644 --- a/src/Daemon/MiddleWare.cpp +++ b/src/Daemon/MiddleWare.cpp @@ -28,6 +28,7 @@ #include "CommLayerInner.h" #include "MiddleWare.h" +using namespace std; /** * An instance of CPluginManager. When MiddleWare wants to do something @@ -528,6 +529,17 @@ report_status_t Report(const map_crash_data_t& client_report, { CDatabase* database = g_pPluginManager->GetDatabase(g_settings_sDatabase.c_str()); database->Connect(); + report_status_t::iterator ret_it = ret.begin(); + while (ret_it != ret.end()) + { + const string &plugin_name = ret_it->first; + const vector_string_t &v = ret_it->second; + if (v[REPORT_STATUS_IDX_FLAG] == "1") + { + database->SetReportedPerReporter(UUID, UID, plugin_name.c_str(), v[REPORT_STATUS_IDX_MSG].c_str()); + } + ret_it++; + } database->SetReported(UUID, UID, message.c_str()); database->DisConnect(); } |
