So far the data is only saved, but not used.
Please review.
--
vda
diff -x '*.po' -d -urpN abrt.0/lib/Plugins/SQLite3.cpp abrt.1/lib/Plugins/SQLite3.cpp
--- abrt.0/lib/Plugins/SQLite3.cpp 2010-03-01 13:38:34.000000000 +0100
+++ abrt.1/lib/Plugins/SQLite3.cpp 2010-03-01 15:26:16.373774161 +0100
@@ -147,7 +147,7 @@ static void get_table(vector_database_ro
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, con
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 c
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 *p
}
}
+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 -x '*.po' -d -urpN abrt.0/lib/Plugins/SQLite3.h abrt.1/lib/Plugins/SQLite3.h
--- abrt.0/lib/Plugins/SQLite3.h 2010-02-07 23:11:00.000000000 +0100
+++ abrt.1/lib/Plugins/SQLite3.h 2010-03-01 13:50:33.172774222 +0100
@@ -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 -x '*.po' -d -urpN abrt.0/lib/Utils/Database.h abrt.1/lib/Utils/Database.h
--- abrt.0/lib/Utils/Database.h 2010-02-07 23:11:00.000000000 +0100
+++ abrt.1/lib/Utils/Database.h 2010-03-01 13:50:23.140777810 +0100
@@ -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 -x '*.po' -d -urpN abrt.0/src/Daemon/MiddleWare.cpp abrt.1/src/Daemon/MiddleWare.cpp
--- abrt.0/src/Daemon/MiddleWare.cpp 2010-02-17 16:05:34.000000000 +0100
+++ abrt.1/src/Daemon/MiddleWare.cpp 2010-03-01 15:19:09.591025341 +0100
@@ -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_d
{
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();
}