summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorZdenek Prikryl <zprikryl@redhat.com>2009-09-08 17:08:16 +0200
committerZdenek Prikryl <zprikryl@redhat.com>2009-09-08 17:08:16 +0200
commitf02e1d87d46aa6161d0cab5444e0abfa9624b78d (patch)
treecc1148c8ef544818a7995074e679a987ba325a44 /src
parent58d9dfde6ce788c5ffdfe5160d19aaeb8ac7b3a2 (diff)
parentff2627e7c597e50025ca4d91ff8168eec80f9054 (diff)
downloadabrt-f02e1d87d46aa6161d0cab5444e0abfa9624b78d.tar.gz
abrt-f02e1d87d46aa6161d0cab5444e0abfa9624b78d.tar.xz
abrt-f02e1d87d46aa6161d0cab5444e0abfa9624b78d.zip
Merge branch 'master' of git://git.fedorahosted.org/abrt
Diffstat (limited to 'src')
-rw-r--r--src/Daemon/CommLayerServer.h13
-rw-r--r--src/Daemon/CommLayerServerDBus.cpp134
-rw-r--r--src/Daemon/CommLayerServerDBus.h14
-rw-r--r--src/Daemon/CommLayerServerSocket.cpp11
-rw-r--r--src/Daemon/CommLayerServerSocket.h6
-rw-r--r--src/Daemon/CrashWatcher.cpp138
-rw-r--r--src/Daemon/CrashWatcher.h8
-rw-r--r--src/Daemon/Daemon.cpp34
-rw-r--r--src/Daemon/Daemon.h3
-rw-r--r--src/Daemon/MiddleWare.cpp22
-rw-r--r--src/Gui/ABRTPlugin.py3
-rw-r--r--src/Gui/CCDBusBackend.py14
-rw-r--r--src/Gui/CCMainWindow.py10
-rw-r--r--src/Gui/Makefile.am3
-rw-r--r--src/Gui/PluginList.py8
-rw-r--r--src/Gui/PluginsSettingsDialog.py161
-rw-r--r--src/Gui/SettingsDialog.py211
-rw-r--r--src/Gui/ccgui.glade7
-rw-r--r--src/Gui/settings.GtkBuilder260
19 files changed, 730 insertions, 330 deletions
diff --git a/src/Daemon/CommLayerServer.h b/src/Daemon/CommLayerServer.h
index 7e6f8d7..0b1027a 100644
--- a/src/Daemon/CommLayerServer.h
+++ b/src/Daemon/CommLayerServer.h
@@ -14,13 +14,12 @@ class CCommLayerServer {
/* just stubs to be called when not implemented in specific comm layer */
virtual void Crash(const std::string& progname, const std::string& uid) {}
- virtual void AnalyzeComplete(const map_crash_report_t& arg1) {}
- virtual void Error(const std::string& arg1) {}
- virtual void Update(const std::string& pMessage, uint64_t pJobID) {};
- virtual void Warning(const std::string& pMessage) {};
- virtual void JobDone(const char* pDest, uint64_t pJobID) = 0;
- virtual void JobStarted(const char* pDest, uint64_t pJobID) {};
- virtual void Warning(const std::string& pMessage, uint64_t pJobID) {};
+ virtual void JobDone(const char* pDest, const char* pUUID) = 0;
+ virtual void JobStarted(const char* pDest) {};
+
+ virtual void Error(const std::string& pMessage, const char* peer) {}
+ virtual void Update(const std::string& pMessage, const char* peer, uint64_t pJobID) {};
+ virtual void Warning(const std::string& pMessage, const char* peer, uint64_t pJobID) {};
};
#endif
diff --git a/src/Daemon/CommLayerServerDBus.cpp b/src/Daemon/CommLayerServerDBus.cpp
index c3cef3b..c6908f5 100644
--- a/src/Daemon/CommLayerServerDBus.cpp
+++ b/src/Daemon/CommLayerServerDBus.cpp
@@ -336,12 +336,15 @@ static inline int load_val(DBusMessageIter* iter, std::map<K,V>& val) { return
*/
/* helpers */
-static DBusMessage* new_signal_msg(const char* member)
+static DBusMessage* new_signal_msg(const char* member, const char* peer = NULL)
{
/* path, interface, member name */
DBusMessage* msg = dbus_message_new_signal(CC_DBUS_PATH, CC_DBUS_IFACE, member);
if (!msg)
die_out_of_memory();
+ /* Send unicast dbus signal if peer is known */
+ if (peer && !dbus_message_set_destination(msg, peer))
+ die_out_of_memory();
return msg;
}
static void send_flush_and_unref(DBusMessage* msg)
@@ -363,79 +366,61 @@ void CCommLayerServerDBus::Crash(const std::string& progname, const std::string&
DBUS_TYPE_STRING, &c_progname,
DBUS_TYPE_STRING, &c_uid,
DBUS_TYPE_INVALID);
+ VERB2 log("Sending signal Crash('%s','%s')", c_progname, c_uid);
send_flush_and_unref(msg);
}
-/* Notify the clients that creating a report has finished */
-void CCommLayerServerDBus::AnalyzeComplete(const map_crash_report_t& arg1)
+void CCommLayerServerDBus::JobStarted(const char* peer)
{
- DBusMessage* msg = new_signal_msg("AnalyzeComplete");
- DBusMessageIter out_iter;
- dbus_message_iter_init_append(msg, &out_iter);
- store_val(&out_iter, arg1);
- send_flush_and_unref(msg);
-}
-
-void CCommLayerServerDBus::JobDone(const char* pDest, uint64_t job_id)
-{
- DBusMessage* msg = new_signal_msg("JobDone");
- /* TODO: if (!dbus_message_set_destination(msg, pDest) die_out_of_memory(); */
+ DBusMessage* msg = new_signal_msg("JobStarted", peer);
+ uint64_t nJobID = uint64_t(pthread_self());
dbus_message_append_args(msg,
- DBUS_TYPE_STRING, &pDest, /* TODO: redundant parameter, remove from API */
- DBUS_TYPE_UINT64, &job_id,
+ DBUS_TYPE_STRING, &peer, /* TODO: redundant parameter, remove from API */
+ DBUS_TYPE_UINT64, &nJobID, /* TODO: redundant parameter, remove from API */
DBUS_TYPE_INVALID);
+ VERB2 log("Sending signal JobStarted('%s',%llx)", peer, (unsigned long long)nJobID);
send_flush_and_unref(msg);
}
-void CCommLayerServerDBus::JobStarted(const char* pDest, uint64_t job_id)
+void CCommLayerServerDBus::JobDone(const char* peer, const char* pUUID)
{
- DBusMessage* msg = new_signal_msg("JobStarted");
- /* TODO: if (!dbus_message_set_destination(msg, pDest) die_out_of_memory(); */
+ DBusMessage* msg = new_signal_msg("JobDone", peer);
dbus_message_append_args(msg,
- DBUS_TYPE_STRING, &pDest, /* TODO: redundant parameter, remove from API */
- DBUS_TYPE_UINT64, &job_id,
+ DBUS_TYPE_STRING, &peer, /* TODO: redundant parameter, remove from API */
+ DBUS_TYPE_STRING, &pUUID, /* TODO: redundant parameter, remove from API */
DBUS_TYPE_INVALID);
+ VERB2 log("Sending signal JobDone('%s','%s')", peer, pUUID);
send_flush_and_unref(msg);
}
-void CCommLayerServerDBus::Error(const std::string& arg1)
+void CCommLayerServerDBus::Error(const std::string& pMessage, const char* peer)
{
- DBusMessage* msg = new_signal_msg("Error");
- const char* c_arg1 = arg1.c_str();
- dbus_message_append_args(msg,
- DBUS_TYPE_STRING, &c_arg1,
- DBUS_TYPE_INVALID);
- send_flush_and_unref(msg);
-}
-
-void CCommLayerServerDBus::Update(const std::string& pMessage, uint64_t job_id)
-{
- DBusMessage* msg = new_signal_msg("Update");
+ DBusMessage* msg = new_signal_msg("Error", peer);
const char* c_message = pMessage.c_str();
dbus_message_append_args(msg,
DBUS_TYPE_STRING, &c_message,
- DBUS_TYPE_UINT64, &job_id,
DBUS_TYPE_INVALID);
send_flush_and_unref(msg);
}
-void CCommLayerServerDBus::Warning(const std::string& pMessage)
+void CCommLayerServerDBus::Update(const std::string& pMessage, const char* peer, uint64_t job_id)
{
- DBusMessage* msg = new_signal_msg("Warning");
+ DBusMessage* msg = new_signal_msg("Update", peer);
const char* c_message = pMessage.c_str();
dbus_message_append_args(msg,
DBUS_TYPE_STRING, &c_message,
+ DBUS_TYPE_UINT64, &job_id, /* TODO: redundant parameter, remove from API */
DBUS_TYPE_INVALID);
send_flush_and_unref(msg);
}
-void CCommLayerServerDBus::Warning(const std::string& pMessage, uint64_t job_id)
+void CCommLayerServerDBus::Warning(const std::string& pMessage, const char* peer, uint64_t job_id)
{
- DBusMessage* msg = new_signal_msg("Warning");
+ DBusMessage* msg = new_signal_msg("Warning", peer);
const char* c_message = pMessage.c_str();
dbus_message_append_args(msg,
DBUS_TYPE_STRING, &c_message,
- DBUS_TYPE_UINT64, &job_id,
+ DBUS_TYPE_UINT64, &job_id, /* TODO: redundant parameter, remove from API */
DBUS_TYPE_INVALID);
send_flush_and_unref(msg);
}
@@ -456,7 +441,7 @@ static long get_remote_uid(DBusMessage* call, const char** ppSender = NULL)
if (dbus_error_is_set(&err))
{
dbus_error_free(&err);
- error_msg("can't determine remore uid, assuming 0");
+ error_msg("Can't determine remote uid, assuming 0");
return 0;
}
return uid;
@@ -495,17 +480,47 @@ static int handle_CreateReport(DBusMessage* call, DBusMessage* reply)
const char* sender;
long unix_uid = get_remote_uid(call, &sender);
- VERB1 log("got %s('%s') call from uid %ld", "CreateReport", pUUID, unix_uid);
- uint64_t argout1 = CreateReport_t(pUUID, to_string(unix_uid).c_str(), sender);
+ VERB1 log("got %s('%s') call from sender '%s' uid %ld", "CreateReport", pUUID, sender, unix_uid);
+ if (CreateReportThread(pUUID, to_string(unix_uid).c_str(), sender) != 0)
+ return -1; /* can't create thread (err msg is already logged) */
dbus_message_append_args(reply,
- DBUS_TYPE_UINT64, &argout1,
+ DBUS_TYPE_STRING, &pUUID, /* redundant, eliminate from API */
DBUS_TYPE_INVALID);
send_flush_and_unref(reply);
return 0;
}
+static int handle_GetJobResult(DBusMessage* call, DBusMessage* reply)
+{
+ const char* pUUID;
+ DBusMessageIter in_iter;
+ if (!dbus_message_iter_init(call, &in_iter))
+ {
+ error_msg("dbus call %s: no parameters", "GetJobResult");
+ return -1;
+ }
+ int r = load_val(&in_iter, pUUID);
+ if (r != LAST_FIELD)
+ {
+ if (r == MORE_FIELDS)
+ error_msg("dbus call %s: extra parameters", "GetJobResult");
+ return -1;
+ }
+
+ long unix_uid = get_remote_uid(call);
+ VERB1 log("got %s('%s') call from uid %ld", "GetJobResult", pUUID, unix_uid);
+ map_crash_report_t report = GetJobResult(pUUID, to_string(unix_uid).c_str());
+
+ DBusMessageIter out_iter;
+ dbus_message_iter_init_append(reply, &out_iter);
+ store_val(&out_iter, report);
+
+ send_flush_and_unref(reply);
+ return 0;
+}
+
static int handle_Report(DBusMessage* call, DBusMessage* reply)
{
map_crash_report_t argin1;
@@ -577,35 +592,6 @@ static int handle_DeleteDebugDump(DBusMessage* call, DBusMessage* reply)
return 0;
}
-static int handle_GetJobResult(DBusMessage* call, DBusMessage* reply)
-{
- uint64_t job_id;
- DBusMessageIter in_iter;
- if (!dbus_message_iter_init(call, &in_iter))
- {
- error_msg("dbus call %s: no parameters", "GetJobResult");
- return -1;
- }
- int r = load_val(&in_iter, job_id);
- if (r != LAST_FIELD)
- {
- if (r == MORE_FIELDS)
- error_msg("dbus call %s: extra parameters", "GetJobResult");
- return -1;
- }
-
- long unix_uid = get_remote_uid(call);
- VERB1 log("got %s(%llx) call from uid %ld", "GetJobResult", (long long)job_id, unix_uid);
- map_crash_report_t report = GetJobResult(job_id, to_string(unix_uid));
-
- DBusMessageIter out_iter;
- dbus_message_iter_init_append(reply, &out_iter);
- store_val(&out_iter, report);
-
- send_flush_and_unref(reply);
- return 0;
-}
-
static int handle_GetPluginsInfo(DBusMessage* call, DBusMessage* reply)
{
vector_map_string_t plugins_info = g_pPluginManager->GetPluginsInfo();
@@ -885,6 +871,8 @@ static DBusHandlerResult message_received(DBusConnection *conn, DBusMessage *msg
const char* member = dbus_message_get_member(msg);
log("%s(method:'%s')", __func__, member);
+ set_client_name(dbus_message_get_sender(msg));
+
DBusMessage* reply = dbus_message_new_method_return(msg);
int r = -1;
if (strcmp(member, "GetCrashInfos") == 0)
@@ -931,6 +919,8 @@ static DBusHandlerResult message_received(DBusConnection *conn, DBusMessage *msg
}
}
+ set_client_name(NULL);
+
return DBUS_HANDLER_RESULT_HANDLED;
}
/* Callback: "DBusObjectPathVTable is unregistered (or its connection is freed)" */
diff --git a/src/Daemon/CommLayerServerDBus.h b/src/Daemon/CommLayerServerDBus.h
index 6ac702d..3a8822d 100644
--- a/src/Daemon/CommLayerServerDBus.h
+++ b/src/Daemon/CommLayerServerDBus.h
@@ -12,14 +12,12 @@ class CCommLayerServerDBus
/* DBus signal senders */
virtual void Crash(const std::string& progname, const std::string& uid);
- virtual void AnalyzeComplete(const map_crash_report_t& arg1);
- virtual void Error(const std::string& arg1);
- virtual void Update(const std::string& pMessage, uint64_t pJobID);
- //the job id should be enough in jobdone
- virtual void JobDone(const char* pDest, uint64_t pJobID);
- virtual void JobStarted(const char* pDest, uint64_t pJobID);
- virtual void Warning(const std::string& pMessage);
- virtual void Warning(const std::string& pMessage, uint64_t pJobID);
+ virtual void JobStarted(const char* pDest);
+ virtual void JobDone(const char* pDest, const char* pUUID);
+
+ virtual void Error(const std::string& pMessage, const char* peer);
+ virtual void Update(const std::string& pMessage, const char* peer, uint64_t pJobID);
+ virtual void Warning(const std::string& pMessage, const char* peer, uint64_t pJobID);
};
#endif
diff --git a/src/Daemon/CommLayerServerSocket.cpp b/src/Daemon/CommLayerServerSocket.cpp
index c88e0f3..8f1fd4f 100644
--- a/src/Daemon/CommLayerServerSocket.cpp
+++ b/src/Daemon/CommLayerServerSocket.cpp
@@ -148,7 +148,7 @@ void CCommLayerServerSocket::ProcessMessage(const std::string& pMessage, GIOChan
{
// std::string UUID = pMessage.substr(sizeof(MESSAGE_CREATE_REPORT) - 1);
// map_crash_report_t crashReport = CreateReport(UUID, UID);
-//use CreateReport_t instead of CreateReport?
+//use CreateReportThread instead of CreateReport?
// std::string message = MESSAGE_CREATE_REPORT + crash_report_to_string(crashReport);
// Send(message, pSource);
}
@@ -220,7 +220,7 @@ vector_crash_infos_t CCommLayerServerSocket::GetCrashInfos(const std::string &pS
return crashInfos;
}
-//reimplement as CreateReport_t(...)?
+//reimplement as CreateReportThread(...)?
//map_crash_report_t CCommLayerServerSocket::CreateReport(const std::string &pUUID,const std::string &pSender)
//{
// map_crash_report_t crashReport;
@@ -246,12 +246,7 @@ void CCommLayerServerSocket::Crash(const std::string& arg1)
//Send("(CRASH)New Crash Detected: " + arg1);
}
-void CCommLayerServerSocket::AnalyzeComplete(const map_crash_report_t& arg1)
-{
- //Send("(ANALYZE_COMPLETE)Analyze Complete.");
-}
-
-void CCommLayerServerSocket::Error(const std::string& arg1)
+void CCommLayerServerSocket::Error(const std::string& arg1, const char* peer)
{
//Send("(ERROR)Error: " + arg1);
}
diff --git a/src/Daemon/CommLayerServerSocket.h b/src/Daemon/CommLayerServerSocket.h
index bf5b2ff..0ee4701 100644
--- a/src/Daemon/CommLayerServerSocket.h
+++ b/src/Daemon/CommLayerServerSocket.h
@@ -31,7 +31,7 @@ class CCommLayerServerSocket : public CCommLayerServer
virtual bool DeleteDebugDump(const std::string& pUUID, const std::string& pSender);
virtual void Crash(const std::string& arg1);
- virtual void AnalyzeComplete(const map_crash_report_t& arg1);
- virtual void Error(const std::string& arg1);
- virtual void JobStarted(const char* pDest, uint64_t pJobID) {};
+ virtual void JobStarted(const char* pDest) {};
+
+ virtual void Error(const std::string& arg1, const char* peer);
};
diff --git a/src/Daemon/CrashWatcher.cpp b/src/Daemon/CrashWatcher.cpp
index 06afabd..6c4d654 100644
--- a/src/Daemon/CrashWatcher.cpp
+++ b/src/Daemon/CrashWatcher.cpp
@@ -24,19 +24,18 @@
#include "ABRTException.h"
#include "CrashWatcher.h"
-void CCrashWatcher::Status(const std::string& pMessage, uint64_t pJobID)
+void CCrashWatcher::Status(const std::string& pMessage, const char* peer, uint64_t pJobID)
{
- log("Update: %s", pMessage.c_str());
- //FIXME: send updates only to job owner
+ VERB1 log("Update('%s'): %s", peer, pMessage.c_str());
if (g_pCommLayer != NULL)
- g_pCommLayer->Update(pMessage, pJobID);
+ g_pCommLayer->Update(pMessage, peer, pJobID);
}
-void CCrashWatcher::Warning(const std::string& pMessage, uint64_t pJobID)
+void CCrashWatcher::Warning(const std::string& pMessage, const char* peer, uint64_t pJobID)
{
- log("Warning: %s", pMessage.c_str());
+ VERB1 log("Warning('%s'): %s", peer, pMessage.c_str());
if (g_pCommLayer != NULL)
- g_pCommLayer->Warning(pMessage, pJobID);
+ g_pCommLayer->Warning(pMessage, peer, pJobID);
}
CCrashWatcher::CCrashWatcher()
@@ -102,97 +101,129 @@ vector_crash_infos_t GetCrashInfos(const std::string &pUID)
return retval;
}
+/*
+ * "GetJobResult" is a bit of a misnomer.
+ * It actually _creates_ a_ report_ and returns the result.
+ * It is called in two cases:
+ * (1) by CreateReport dbus call -> CreateReportThread(), in the thread
+ * (2) by GetJobResult dbus call
+ * In the second case, it finishes quickly, because previous
+ * CreateReport dbus call already did all the processing, and we just retrieve
+ * the result from dump directory, which is fast.
+ */
+map_crash_report_t GetJobResult(const char* pUUID, const char* pUID)
+{
+ map_crash_info_t crashReport;
+
+ /* FIXME: starting from here, any shared data must be protected with a mutex.
+ * For example, CreateCrashReport does:
+ * g_pPluginManager->GetDatabase(g_settings_sDatabase);
+ * which is unsafe wrt concurrent updates to g_pPluginManager state.
+ */
+ mw_result_t res = CreateCrashReport(pUUID, pUID, crashReport);
+ switch (res)
+ {
+ case MW_OK:
+ break;
+ case MW_IN_DB_ERROR:
+ warn_client(std::string("Did not find crash with UUID ") + pUUID + " in database");
+ break;
+ case MW_PLUGIN_ERROR:
+ warn_client("Particular analyzer plugin isn't loaded or there is an error within plugin(s)");
+ break;
+ case MW_CORRUPTED:
+ case MW_FILE_ERROR:
+ default:
+ warn_client(std::string("Corrupted crash with UUID ") + pUUID + ", deleting");
+ std::string debugDumpDir = DeleteCrashInfo(pUUID, pUID);
+ DeleteDebugDumpDir(debugDumpDir);
+ break;
+ }
+ return crashReport;
+}
+
typedef struct thread_data_t {
pthread_t thread_id;
char* UUID;
char* UID;
- char* dest;
+ char* peer;
} thread_data_t;
-static void *create_report(void *arg)
+static void* create_report(void* arg)
{
thread_data_t *thread_data = (thread_data_t *) arg;
- map_crash_info_t crashReport;
- g_pCommLayer->JobStarted(thread_data->dest, uint64_t(thread_data->thread_id));
+ g_pCommLayer->JobStarted(thread_data->peer);
+
+ /* Client name is per-thread, need to set it */
+ set_client_name(thread_data->peer);
- log("Creating report...");
try
{
- mw_result_t res;
- res = CreateCrashReport(thread_data->UUID, thread_data->UID, crashReport);
- switch (res)
- {
- case MW_OK:
- break;
- case MW_IN_DB_ERROR:
- warn_client(std::string("Did not find crash with UUID ") + thread_data->UUID + " in database");
- break;
- case MW_PLUGIN_ERROR:
- warn_client(std::string("Particular analyzer plugin isn't loaded or there is an error within plugin(s)"));
- break;
- case MW_CORRUPTED:
- case MW_FILE_ERROR:
- default:
- warn_client(std::string("Corrupted crash with UUID ") + thread_data->UUID + ", deleting");
- std::string debugDumpDir = DeleteCrashInfo(thread_data->UUID, thread_data->UID);
- DeleteDebugDumpDir(debugDumpDir);
- break;
- }
- /* only one thread can write */
- pthread_mutex_lock(&g_pJobsMutex);
- g_pending_jobs[std::string(thread_data->UID)][uint64_t(thread_data->thread_id)] = crashReport;
- pthread_mutex_unlock(&g_pJobsMutex);
- g_pCommLayer->JobDone(thread_data->dest, uint64_t(thread_data->thread_id));
+ /* "GetJobResult" is a bit of a misnomer */
+ log("Creating report...");
+ map_crash_info_t crashReport = GetJobResult(thread_data->UUID, thread_data->UID);
+ g_pCommLayer->JobDone(thread_data->peer, thread_data->UUID);
}
catch (CABRTException& e)
{
if (e.type() == EXCEP_FATAL)
{
+ set_client_name(NULL);
/* free strduped strings */
free(thread_data->UUID);
free(thread_data->UID);
- free(thread_data->dest);
+ free(thread_data->peer);
free(thread_data);
throw e;
}
warn_client(e.what());
}
+ set_client_name(NULL);
+
/* free strduped strings */
free(thread_data->UUID);
free(thread_data->UID);
- free(thread_data->dest);
+ free(thread_data->peer);
free(thread_data);
/* Bogus value. pthreads require us to return void* */
return NULL;
}
-uint64_t CreateReport_t(const char* pUUID, const char* pUID, const char* pSender)
+int CreateReportThread(const char* pUUID, const char* pUID, const char* pSender)
{
thread_data_t *thread_data = (thread_data_t *)xzalloc(sizeof(thread_data_t));
thread_data->UUID = xstrdup(pUUID);
thread_data->UID = xstrdup(pUID);
- thread_data->dest = xstrdup(pSender);
- if (pthread_create(&thread_data->thread_id, NULL, create_report, (void *)thread_data) != 0)
+ thread_data->peer = xstrdup(pSender);
+//TODO: do we need this?
+//pthread_attr_t attr;
+//pthread_attr_init(&attr);
+//pthread_attr_setdetachstate(&attr, PTHREAD_CREATE_DETACHED);
+ int r = pthread_create(&thread_data->thread_id, NULL, create_report, thread_data);
+ if (r != 0)
{
free(thread_data->UUID);
free(thread_data->UID);
- free(thread_data->dest);
+ free(thread_data->peer);
free(thread_data);
/* The only reason this may happen is system-wide resource starvation,
- * or ulimit is exceeded (someoune floods us with CreateReport() dbus calls?)
+ * or ulimit is exceeded (someone floods us with CreateReport() dbus calls?)
*/
- error_msg("cannot create thread");
- return 0;
+ error_msg("Can't create thread");
+ }
+ else
+ {
+ VERB3 log("Thread %llx created", (unsigned long long)thread_data->thread_id);
}
- return uint64_t(thread_data->thread_id);
+//pthread_attr_destroy(&attr);
+ return r;
}
bool DeleteDebugDump(const std::string& pUUID, const std::string& pUID)
{
try
{
- std::string debugDumpDir;
- debugDumpDir = DeleteCrashInfo(pUUID, pUID);
+ std::string debugDumpDir = DeleteCrashInfo(pUUID, pUID);
DeleteDebugDumpDir(debugDumpDir);
}
catch (CABRTException& e)
@@ -207,12 +238,3 @@ bool DeleteDebugDump(const std::string& pUUID, const std::string& pUID)
}
return true;
}
-
-map_crash_report_t GetJobResult(uint64_t pJobID, const std::string& pSender)
-{
- /* FIXME: once we return the result, we should remove it from map to free memory
- - use some TTL to clean the memory even if client won't get it
- - if we don't find it in the cache we should try to ask MW to get it again??
- */
- return g_pending_jobs[pSender][pJobID];
-}
diff --git a/src/Daemon/CrashWatcher.h b/src/Daemon/CrashWatcher.h
index f35e100..00bb4d5 100644
--- a/src/Daemon/CrashWatcher.h
+++ b/src/Daemon/CrashWatcher.h
@@ -44,13 +44,13 @@ class CCrashWatcher
public:
/* Observer methods */
- virtual void Status(const std::string& pMessage, uint64_t pJobID=0);
- virtual void Warning(const std::string& pMessage, uint64_t pJobID=0);
+ virtual void Status(const std::string& pMessage, const char* peer, uint64_t pJobID);
+ virtual void Warning(const std::string& pMessage, const char* peer, uint64_t pJobID);
};
vector_crash_infos_t GetCrashInfos(const std::string &pUID);
-uint64_t CreateReport_t(const char* pUUID, const char* pUID, const char* pSender);
+int CreateReportThread(const char* pUUID, const char* pUID, const char* pSender);
+map_crash_report_t GetJobResult(const char* pUUID, const char* pUID);
bool DeleteDebugDump(const std::string& pUUID, const std::string& pUID);
-map_crash_report_t GetJobResult(uint64_t pJobID, const std::string& pSender);
#endif /*CRASHWATCHER_H_*/
diff --git a/src/Daemon/Daemon.cpp b/src/Daemon/Daemon.cpp
index fc28e8b..a7c9737 100644
--- a/src/Daemon/Daemon.cpp
+++ b/src/Daemon/Daemon.cpp
@@ -51,9 +51,12 @@
* - GetCrashInfos(): returns a vector_crash_infos_t (vector_map_vector_string_t)
* of crashes for given uid
* v[N]["executable"/"uid"/"kernel"/"backtrace"][N] = "contents"
- * - CreateReport(UUID): starts creating a report for /var/cache/abrt/DIR with this UUID
- * Returns job id (uint64)
- * - GetJobResult(job_id): returns map_crash_report_t (map_vector_string_t)
+ * - CreateReport(UUID): starts creating a report for /var/cache/abrt/DIR with this UUID.
+ * Returns job id (uint64).
+ * Emits JobStarted(client_dbus_ID,job_id) dbus signal.
+ * After it returns, when report creation thread has finished,
+ * JobDone(client_dbus_ID,UUID) dbus signal is emitted.
+ * - GetJobResult(UUID): returns map_crash_report_t (map_vector_string_t)
* - Report(map_crash_report_t (map_vector_string_t)):
* "Please report this crash": calls Report() of all registered reporter plugins
* Returns report_status_t (map_vector_string_t) - the status of each call
@@ -67,7 +70,20 @@
* - SetSettings(map_abrt_settings_t): returns void
*
* DBus signals we emit:
- * - ...
+ * - Crash(progname,uid) - a new crash occurred (new /var/cache/abrt/DIR is found)
+ * - JobStarted(client_dbus_ID,job_id) - see CreateReport above.
+ * Sent as unicast to the client which did CreateReport.
+ * - JobDone(client_dbus_ID,UUID) - see CreateReport above.
+ * Sent as unicast to the client which did CreateReport.
+ * - Error(msg)
+ * - Warning(msg[,job_id])
+ * - Update(msg,job_id)
+ *
+ * TODO:
+ * - Error/Warning/Update dbus signals must be unicast too
+ * - API does not really need JobStarted dbus signal at all, and JobDone signal
+ * does not need to pass any parameters - out clients never sent multiple
+ * CreateReport's.
*/
@@ -98,12 +114,7 @@ static GMainLoop* g_pMainloop;
int g_verbose;
CCommLayerServer* g_pCommLayer;
-/*
- * Map to cache the results from CreateReport_t
- * <UID, <job_id, result>>
- */
-std::map<const std::string, std::map<uint64_t, map_crash_report_t> > g_pending_jobs;
-/* mutex to protect g_pending_jobs */
+
pthread_mutex_t g_pJobsMutex;
@@ -503,7 +514,8 @@ static gboolean handle_event_cb(GIOChannel *gio, GIOCondition condition, gpointe
/* ignore lock files and such */
if (!(event->mask & IN_ISDIR))
{
- VERB3 log("File '%s' creation detected, ignoring", name);
+ // Happens all the time during normal run
+ //VERB3 log("File '%s' creation detected, ignoring", name);
continue;
}
diff --git a/src/Daemon/Daemon.h b/src/Daemon/Daemon.h
index 8fcce71..e03d983 100644
--- a/src/Daemon/Daemon.h
+++ b/src/Daemon/Daemon.h
@@ -49,9 +49,6 @@ extern CPluginManager* g_pPluginManager;
*/
extern set_string_t g_setBlackList;
-/* Map <UID, <job_id, result>> to cache the results from CreateReport_t() */
-extern std::map<const std::string, std::map<uint64_t, map_crash_report_t> > g_pending_jobs;
-/* Mutex to protect g_pending_jobs */
extern pthread_mutex_t g_pJobsMutex;
#endif
diff --git a/src/Daemon/MiddleWare.cpp b/src/Daemon/MiddleWare.cpp
index e6c9187..4f499d6 100644
--- a/src/Daemon/MiddleWare.cpp
+++ b/src/Daemon/MiddleWare.cpp
@@ -173,33 +173,42 @@ mw_result_t CreateCrashReport(const std::string& pUUID,
const std::string& pUID,
map_crash_report_t& pCrashReport)
{
- CDatabase* database = g_pPluginManager->GetDatabase(g_settings_sDatabase);
- database_row_t row;
- database->Connect();
- row = database->GetUUIDData(pUUID, pUID);
- database->DisConnect();
- CDebugDump dd;
+ VERB2 log("CreateCrashReport('%s','%',result)", pUUID.c_str(), pUID.c_str());
+ database_row_t row;
+ if (pUUID != "")
+ {
+ CDatabase* database = g_pPluginManager->GetDatabase(g_settings_sDatabase);
+ database->Connect();
+ row = database->GetUUIDData(pUUID, pUID);
+ database->DisConnect();
+ }
if (pUUID == "" || row.m_sUUID != pUUID)
{
warn_client("CreateCrashReport(): UUID '"+pUUID+"' is not in database.");
return MW_IN_DB_ERROR;
}
+ CDebugDump dd;
try
{
std::string analyzer;
std::string gUUID;
+ VERB3 log(" LoadText(FILENAME_ANALYZER,'%s')", row.m_sDebugDumpDir.c_str());
dd.Open(row.m_sDebugDumpDir);
dd.LoadText(FILENAME_ANALYZER, analyzer);
dd.Close();
+ VERB3 log(" CreateReport('%s')", analyzer.c_str());
CreateReport(analyzer, row.m_sDebugDumpDir);
gUUID = GetGlobalUUID(analyzer, row.m_sDebugDumpDir);
+ VERB3 log(" GetGlobalUUID:'%s'", gUUID.c_str());
+ VERB3 log(" RunAnalyzerActions");
RunAnalyzerActions(analyzer, row.m_sDebugDumpDir);
+ VERB3 log(" DebugDumpToCrashReport");
DebugDumpToCrashReport(row.m_sDebugDumpDir, pCrashReport);
add_crash_data_to_crash_report(pCrashReport, CD_UUID, CD_TXT, CD_ISNOTEDITABLE, gUUID);
@@ -245,7 +254,6 @@ void RunAction(const std::string& pActionDir,
warn_client("RunAction(): " + e.what());
update_client("Execution of '"+pPluginName+"' was not successful: " + e.what());
}
-
}
void RunActionsAndReporters(const std::string& pDebugDumpDir)
diff --git a/src/Gui/ABRTPlugin.py b/src/Gui/ABRTPlugin.py
index da9c9e5..4a94e67 100644
--- a/src/Gui/ABRTPlugin.py
+++ b/src/Gui/ABRTPlugin.py
@@ -57,4 +57,7 @@ class PluginInfo():
def __str__(self):
return self.Name
+
+ def __getitem__(self, item):
+ return self.__dict__[item]
diff --git a/src/Gui/CCDBusBackend.py b/src/Gui/CCDBusBackend.py
index b0230bd..01e5196 100644
--- a/src/Gui/CCDBusBackend.py
+++ b/src/Gui/CCDBusBackend.py
@@ -149,6 +149,7 @@ class DBusManager(gobject.GObject):
# new crash notify
self.proxy.connect_to_signal("Crash",self.crash_cb,dbus_interface=CC_IFACE)
# BT extracting complete
+#TODO: remove, abrtd does not emit AnalyzeComplete
self.acconnection = self.proxy.connect_to_signal("AnalyzeComplete",self.analyze_complete_cb,dbus_interface=CC_IFACE)
# Catch Errors
self.acconnection = self.proxy.connect_to_signal("Error",self.error_handler_cb,dbus_interface=CC_IFACE)
@@ -171,10 +172,10 @@ class DBusManager(gobject.GObject):
print "Started our job: %s" % job_id
self.addJob(job_id)
- def jobdone_cb(self, dest, job_id):
+ def jobdone_cb(self, dest, uuid):
if self.uniq_name == dest:
- print "Our job: %s is done." % job_id
- dump = self.cc.GetJobResult(job_id)
+ print "Our job for UUID %s is done." % uuid
+ dump = self.cc.GetJobResult(uuid)
if dump:
self.emit("analyze-complete", dump)
else:
@@ -219,7 +220,7 @@ class DBusManager(gobject.GObject):
#for i in settings.keys():
# print i
return settings
-
+
def registerPlugin(self, plugin_name):
return self.cc.RegisterPlugin(plugin_name)
@@ -229,3 +230,8 @@ class DBusManager(gobject.GObject):
def setPluginSettings(self, plugin_name, plugin_settings):
return self.cc.SetPluginSettings(plugin_name, plugin_settings)
+ def getSettings(self):
+ return self.cc.GetSettings()
+
+ def setSettings(self, settings):
+ return self.cc.SetSettings(settings)
diff --git a/src/Gui/CCMainWindow.py b/src/Gui/CCMainWindow.py
index e747256..4fe0775 100644
--- a/src/Gui/CCMainWindow.py
+++ b/src/Gui/CCMainWindow.py
@@ -11,6 +11,7 @@ import CCDBusBackend
from CC_gui_functions import *
from CCDumpList import getDumpList, DumpList
from CCReporterDialog import ReporterDialog
+from PluginsSettingsDialog import PluginsSettingsDialog
from SettingsDialog import SettingsDialog
from CCReport import Report
import ABRTExceptions
@@ -108,6 +109,7 @@ class MainWindow():
self.wTree.get_widget("miQuit").connect("activate", self.on_bQuit_clicked)
self.wTree.get_widget("miAbout").connect("activate", self.on_miAbout_clicked)
self.wTree.get_widget("miPreferences").connect("activate", self.on_miPreferences_clicked)
+ self.wTree.get_widget("miSettings").connect("activate", self.on_miSettings_clicked)
# connect handlers for daemon signals
self.ccdaemon.connect("crash", self.on_data_changed_cb, None)
self.ccdaemon.connect("analyze-complete", self.on_analyze_complete_cb, self.pBarWindow)
@@ -133,9 +135,15 @@ class MainWindow():
dialog.hide()
def on_miPreferences_clicked(self, widget):
- dialog = SettingsDialog(self.window,self.ccdaemon)
+ dialog = PluginsSettingsDialog(self.window,self.ccdaemon)
dialog.hydrate()
dialog.show()
+
+ def on_miSettings_clicked(self, widget):
+ dialog = SettingsDialog(self.window, self.ccdaemon)
+ dialog.hydrate()
+ dialog.show()
+ self.ccdaemon.getSettings()
def warning_cb(self, daemon, message=None):
# try to hide the progressbar, we dont really care if it was visible ..
diff --git a/src/Gui/Makefile.am b/src/Gui/Makefile.am
index 6435c1f..bacfaf4 100644
--- a/src/Gui/Makefile.am
+++ b/src/Gui/Makefile.am
@@ -5,7 +5,8 @@ bin_SCRIPTS = abrt-gui
PYTHON_FILES = CCDBusBackend.py CCDumpList.py CCDump.py CC_gui_functions.py \
CCReporterDialog.py CCReport.py abrt_utils.py \
CCMainWindow.py CellRenderers.py ABRTExceptions.py \
- SettingsDialog.py ABRTPlugin.py PluginList.py PluginSettingsUI.py
+ SettingsDialog.py ABRTPlugin.py PluginList.py PluginSettingsUI.py \
+ PluginsSettingsDialog.py
GLADE_FILES = ccgui.glade report.glade settings.GtkBuilder dialogs.GtkBuilder
diff --git a/src/Gui/PluginList.py b/src/Gui/PluginList.py
index 591096b..76bdf81 100644
--- a/src/Gui/PluginList.py
+++ b/src/Gui/PluginList.py
@@ -33,6 +33,14 @@ class PluginInfoList(list):
return
else:
print "db == None!"
+
+
+ def getEnabledPlugins(self):
+ return [x for x in self if x["Enabled"] == 'yes']
+
+ def getActionPlugins(self):
+ return [x for x in self if x["Enabled"] == 'yes' and x["Type"] == 'Action']
+
__PFList = None
diff --git a/src/Gui/PluginsSettingsDialog.py b/src/Gui/PluginsSettingsDialog.py
new file mode 100644
index 0000000..b56f9d7
--- /dev/null
+++ b/src/Gui/PluginsSettingsDialog.py
@@ -0,0 +1,161 @@
+import sys
+import gtk
+from PluginList import getPluginInfoList, PluginInfoList
+from CC_gui_functions import *
+from PluginSettingsUI import PluginSettingsUI
+from ABRTPlugin import PluginSettings, PluginInfo
+from abrt_utils import _
+
+class PluginsSettingsDialog:
+ def __init__(self, parent, daemon):
+ #print "Settings dialog init"
+ self.ccdaemon = daemon
+ self.builder = gtk.Builder()
+ builderfile = "%s%ssettings.GtkBuilder" % (sys.path[0],"/")
+ #print builderfile
+ try:
+ self.builder.add_from_file(builderfile)
+ except Exception, e:
+ print e
+ self.window = self.builder.get_object("wPluginsSettings")
+ if not self.window:
+ raise Exception(_("Can't load gui description for SettingsDialog!"))
+ #self.window.set_parent(parent)
+
+ self.pluginlist = self.builder.get_object("tvSettings")
+ # cell_text, toggle_active, toggle_visible, group_name_visible, color, plugin
+ self.pluginsListStore = gtk.TreeStore(str, bool, bool, bool, str, object)
+ # set filter
+ self.modelfilter = self.pluginsListStore.filter_new()
+ self.modelfilter.set_visible_func(self.filter_plugins, None)
+ self.pluginlist.set_model(self.modelfilter)
+ # ===============================================
+ columns = [None]*1
+ columns[0] = gtk.TreeViewColumn(_("Name"))
+
+ # create list
+ for column in columns:
+ n = self.pluginlist.append_column(column)
+ column.cell = gtk.CellRendererText()
+ column.gray_background = gtk.CellRendererText()
+ column.pack_start(column.cell, True)
+ column.pack_start(column.gray_background, True)
+ column.set_attributes(column.cell, markup=(n-1), visible=2)
+ column.set_attributes(column.gray_background, visible=3, cell_background=4)
+ column.set_resizable(True)
+
+ # toggle
+ group_name_renderer = gtk.CellRendererText()
+ toggle_renderer = gtk.CellRendererToggle()
+ toggle_renderer.set_property('activatable', True)
+ toggle_renderer.connect( 'toggled', self.on_enabled_toggled, self.pluginsListStore )
+ column = gtk.TreeViewColumn(_('Enabled'))
+ column.pack_start(toggle_renderer, True)
+ column.pack_start(group_name_renderer, True)
+ column.add_attribute( toggle_renderer, "active", 1)
+ column.add_attribute( toggle_renderer, "visible", 2)
+ column.add_attribute( group_name_renderer, "visible", 3)
+ column.add_attribute( group_name_renderer, "markup", 0)
+ column.add_attribute( group_name_renderer, "cell_background", 4)
+ self.pluginlist.insert_column(column, 0)
+
+ #connect signals
+ self.pluginlist.connect("cursor-changed", self.on_tvDumps_cursor_changed)
+ self.builder.get_object("bConfigurePlugin").connect("clicked", self.on_bConfigurePlugin_clicked, self.pluginlist)
+ self.builder.get_object("bClose").connect("clicked", self.on_bClose_clicked)
+ self.builder.get_object("bConfigurePlugin").set_sensitive(False)
+
+ def on_enabled_toggled(self,cell, path, model):
+ plugin = model[path][model.get_n_columns()-1]
+ if plugin:
+ if model[path][1]:
+ #print "self.ccdaemon.UnRegisterPlugin(%s)" % (plugin.getName())
+ self.ccdaemon.unRegisterPlugin(plugin.getName())
+ # FIXME: create class plugin and move this into method Plugin.Enable()
+ plugin.Enabled = "no"
+ plugin.Settings = None
+ else:
+ #print "self.ccdaemon.RegisterPlugin(%s)" % (model[path][model.get_n_columns()-1])
+ self.ccdaemon.registerPlugin(plugin.getName())
+ # FIXME: create class plugin and move this into method Plugin.Enable()
+ plugin.Enabled = "yes"
+ plugin.Settings = PluginSettings(self.ccdaemon.getPluginSettings(plugin.getName()))
+ model[path][1] = not model[path][1]
+
+ def filter_plugins(self, model, miter, data):
+ return True
+ def hydrate(self):
+ #print "settings hydrate"
+ self.pluginsListStore.clear()
+ try:
+ pluginlist = getPluginInfoList(self.ccdaemon, refresh=True)
+ except Exception, e:
+ print e
+ #gui_error_message("Error while loading plugins info, please check if abrt daemon is running\n %s" % e)
+ plugin_rows = {}
+ for plugin_type in PluginInfo.types.keys():
+ it = self.pluginsListStore.append(None, ["<b>%s</b>" % (PluginInfo.types[plugin_type]),0 , 0, 1,"gray", None])
+ plugin_rows[plugin_type] = it
+ for entry in pluginlist:
+ n = self.pluginsListStore.append(plugin_rows[entry.getType()],["<b>%s</b>\n%s" % (entry.getName(), entry.Description), entry.Enabled == "yes", 1, 0, "white", entry])
+ self.pluginlist.expand_all()
+
+ def dehydrate(self):
+ # we have nothing to save, plugin's does the work
+ pass
+
+ def show(self):
+ self.window.show()
+ #if result == gtk.RESPONSE_APPLY:
+ # self.dehydrate()
+ #self.window.destroy()
+ #return result
+
+ def on_bConfigurePlugin_clicked(self, button, pluginview):
+ pluginsListStore, path = pluginview.get_selection().get_selected_rows()
+ if not path:
+ self.builder.get_object("lDescription").set_label(_("Can't get plugin description"))
+ return
+ # this should work until we keep the row object in the last position
+ pluginfo = pluginsListStore.get_value(pluginsListStore.get_iter(path[0]), pluginsListStore.get_n_columns()-1)
+ if pluginfo:
+ try:
+ ui = PluginSettingsUI(pluginfo)
+ except Exception, e:
+ gui_error_message(_("Error while opening plugin settings UI: \n\n%s" % e))
+ return
+ ui.hydrate()
+ response = ui.run()
+ if response == gtk.RESPONSE_APPLY:
+ ui.dehydrate()
+ if pluginfo.Settings:
+ try:
+ self.ccdaemon.setPluginSettings(pluginfo.getName(), pluginfo.Settings)
+ except Exception, e:
+ gui_error_message(_("Can't save plugin settings:\n %s", e))
+ #for key, val in pluginfo.Settings.iteritems():
+ # print "%s:%s" % (key, val)
+ elif response == gtk.RESPONSE_CANCEL:
+ pass
+ else:
+ print _("unknown response from settings dialog")
+ ui.destroy()
+
+ def on_bClose_clicked(self, button):
+ self.window.destroy()
+
+ def on_tvDumps_cursor_changed(self, treeview):
+ pluginsListStore, path = treeview.get_selection().get_selected_rows()
+ if not path:
+ self.builder.get_object("lDescription").set_label("No description")
+ return
+ # this should work until we keep the row object in the last position
+ pluginfo = pluginsListStore.get_value(pluginsListStore.get_iter(path[0]), pluginsListStore.get_n_columns()-1)
+ if pluginfo:
+ self.builder.get_object("lPluginAuthor").set_text(pluginfo.Email)
+ self.builder.get_object("lPluginVersion").set_text(pluginfo.Version)
+ self.builder.get_object("lPluginWebSite").set_text(pluginfo.WWW)
+ self.builder.get_object("lPluginName").set_text(pluginfo.Name)
+ self.builder.get_object("lPluginDescription").set_text(pluginfo.Description)
+ # print (pluginfo.Enabled == "yes" and pluginfo.GTKBuilder != "")
+ self.builder.get_object("bConfigurePlugin").set_sensitive(pluginfo != None and pluginfo.Enabled == "yes" and pluginfo.GTKBuilder != "")
diff --git a/src/Gui/SettingsDialog.py b/src/Gui/SettingsDialog.py
index 79dfad7..a2ba1f0 100644
--- a/src/Gui/SettingsDialog.py
+++ b/src/Gui/SettingsDialog.py
@@ -2,160 +2,87 @@ import sys
import gtk
from PluginList import getPluginInfoList, PluginInfoList
from CC_gui_functions import *
-from PluginSettingsUI import PluginSettingsUI
+#from PluginSettingsUI import PluginSettingsUI
from ABRTPlugin import PluginSettings, PluginInfo
from abrt_utils import _
class SettingsDialog:
def __init__(self, parent, daemon):
- #print "Settings dialog init"
+ builderfile = "%s%ssettings.GtkBuilder" % (sys.path[0],"/")
self.ccdaemon = daemon
self.builder = gtk.Builder()
- builderfile = "%s%ssettings.GtkBuilder" % (sys.path[0],"/")
- #print builderfile
- try:
- self.builder.add_from_file(builderfile)
- except Exception, e:
- print e
- self.window = self.builder.get_object("wSettings")
- if not self.window:
- raise Exception(_("Can't load gui description for SettingsDialog!"))
- #self.window.set_parent(parent)
-
- self.pluginlist = self.builder.get_object("tvSettings")
- # cell_text, toggle_active, toggle_visible, group_name_visible, color, plugin
- self.pluginsListStore = gtk.TreeStore(str, bool, bool, bool, str, object)
- # set filter
- self.modelfilter = self.pluginsListStore.filter_new()
- self.modelfilter.set_visible_func(self.filter_plugins, None)
- self.pluginlist.set_model(self.modelfilter)
- # ===============================================
- columns = [None]*1
- columns[0] = gtk.TreeViewColumn(_("Name"))
-
- # create list
- for column in columns:
- n = self.pluginlist.append_column(column)
- column.cell = gtk.CellRendererText()
- column.gray_background = gtk.CellRendererText()
- column.pack_start(column.cell, True)
- column.pack_start(column.gray_background, True)
- column.set_attributes(column.cell, markup=(n-1), visible=2)
- column.set_attributes(column.gray_background, visible=3, cell_background=4)
- column.set_resizable(True)
-
- # toggle
- group_name_renderer = gtk.CellRendererText()
- toggle_renderer = gtk.CellRendererToggle()
- toggle_renderer.set_property('activatable', True)
- toggle_renderer.connect( 'toggled', self.on_enabled_toggled, self.pluginsListStore )
- column = gtk.TreeViewColumn(_('Enabled'))
- column.pack_start(toggle_renderer, True)
- column.pack_start(group_name_renderer, True)
- column.add_attribute( toggle_renderer, "active", 1)
- column.add_attribute( toggle_renderer, "visible", 2)
- column.add_attribute( group_name_renderer, "visible", 3)
- column.add_attribute( group_name_renderer, "markup", 0)
- column.add_attribute( group_name_renderer, "cell_background", 4)
- self.pluginlist.insert_column(column, 0)
-
- #connect signals
- self.pluginlist.connect("cursor-changed", self.on_tvDumps_cursor_changed)
- self.builder.get_object("bConfigurePlugin").connect("clicked", self.on_bConfigurePlugin_clicked, self.pluginlist)
- self.builder.get_object("bClose").connect("clicked", self.on_bClose_clicked)
- self.builder.get_object("bConfigurePlugin").set_sensitive(False)
-
- def on_enabled_toggled(self,cell, path, model):
- plugin = model[path][model.get_n_columns()-1]
- if plugin:
- if model[path][1]:
- #print "self.ccdaemon.UnRegisterPlugin(%s)" % (plugin.getName())
- self.ccdaemon.unRegisterPlugin(plugin.getName())
- # FIXME: create class plugin and move this into method Plugin.Enable()
- plugin.Enabled = "no"
- plugin.Settings = None
- else:
- #print "self.ccdaemon.RegisterPlugin(%s)" % (model[path][model.get_n_columns()-1])
- self.ccdaemon.registerPlugin(plugin.getName())
- # FIXME: create class plugin and move this into method Plugin.Enable()
- plugin.Enabled = "yes"
- plugin.Settings = PluginSettings(self.ccdaemon.getPluginSettings(plugin.getName()))
- model[path][1] = not model[path][1]
-
- def filter_plugins(self, model, miter, data):
+ self.builder.add_from_file(builderfile)
+ self.window = self.builder.get_object("wGlobalSettings")
+ print "GSD init"
+ self.builder.get_object("bSaveSettings").connect("clicked", self.on_ok_clicked)
+ self.builder.get_object("bAddCronJob").connect("clicked", self.on_bAddCronJob_clicked)
+
+ def filter_settings(self, model, miter, data):
return True
+
def hydrate(self):
- #print "settings hydrate"
- self.pluginsListStore.clear()
try:
- pluginlist = getPluginInfoList(self.ccdaemon, refresh=True)
+ self.settings = self.ccdaemon.getSettings()
except Exception, e:
+ # FIXME: this should be error gui message!
print e
- #gui_error_message("Error while loading plugins info, please check if abrt daemon is running\n %s" % e)
- plugin_rows = {}
- for plugin_type in PluginInfo.types.keys():
- it = self.pluginsListStore.append(None, ["<b>%s</b>" % (PluginInfo.types[plugin_type]),0 , 0, 1,"gray", None])
- plugin_rows[plugin_type] = it
- for entry in pluginlist:
- n = self.pluginsListStore.append(plugin_rows[entry.getType()],["<b>%s</b>\n%s" % (entry.getName(), entry.Description), entry.Enabled == "yes", 1, 0, "white", entry])
- self.pluginlist.expand_all()
-
+
+ # hydrate cron jobs:
+ for key,val in self.settings["Cron"].iteritems():
+ try:
+ self.pluginlist = getPluginInfoList(self.ccdaemon, refresh=True)
+ except Exception, e:
+ print e
+
+ hbox = gtk.HBox(homogeneous=True)
+ time = gtk.Entry()
+ plugins = gtk.ComboBox()
+ enabledPluginsListStore = gtk.ListStore(str, object)
+ cell = gtk.CellRendererText()
+ plugins.pack_start(cell)
+ plugins.add_attribute(cell, 'text', 0)
+ enabledPluginsListStore.append([_("Select a plugin"), None])
+ for plugin in self.pluginlist.getActionPlugins():
+ print "#", plugin.getName()
+ enabledPluginsListStore.append([plugin.getName(), plugin])
+ plugins.set_model(enabledPluginsListStore)
+ plugins.set_active(0)
+ hbox.pack_start(time,False)
+ hbox.pack_start(plugins,False)
+ self.builder.get_object("vbCronJobs").pack_start(hbox,False)
+ hbox.show_all()
+ #print "\t%s:%s" % (key,val)
+
+ def on_ok_clicked(self, button):
+ self.dehydrate()
+
+ def on_bAddCronJob_clicked(self, button):
+ hbox = gtk.HBox(homogeneous=True)
+ time = gtk.Entry()
+ plugins = gtk.ComboBox()
+ enabledPluginsListStore = gtk.ListStore(str, object)
+ cell = gtk.CellRendererText()
+ plugins.pack_start(cell)
+ plugins.add_attribute(cell, 'text', 0)
+ for plugin in self.pluginlist.getActionPlugins():
+ print "#", plugin.getName()
+ enabledPluginsListStore.append([plugin.getName(), plugin])
+ plugins.set_model(enabledPluginsListStore)
+ plugins.set_active(0)
+ hbox.pack_start(time,False)
+ hbox.pack_start(plugins,False)
+ self.builder.get_object("vbCronJobs").pack_start(hbox,False)
+ hbox.show_all()
+ print "add"
+
+ def on_cancel_clicked(self,button):
+ print "hide"
+ self.window.hide()
+
def dehydrate(self):
- # we have nothing to save, plugin's does the work
- pass
-
+ self.ccdaemon.setSettings(self.settings)
+ print "dehydrate"
+
def show(self):
+ print "show"
self.window.show()
- #if result == gtk.RESPONSE_APPLY:
- # self.dehydrate()
- #self.window.destroy()
- #return result
-
- def on_bConfigurePlugin_clicked(self, button, pluginview):
- pluginsListStore, path = pluginview.get_selection().get_selected_rows()
- if not path:
- self.builder.get_object("lDescription").set_label(_("Can't get plugin description"))
- return
- # this should work until we keep the row object in the last position
- pluginfo = pluginsListStore.get_value(pluginsListStore.get_iter(path[0]), pluginsListStore.get_n_columns()-1)
- if pluginfo:
- try:
- ui = PluginSettingsUI(pluginfo)
- except Exception, e:
- gui_error_message(_("Error while opening plugin settings UI: \n\n%s" % e))
- return
- ui.hydrate()
- response = ui.run()
- if response == gtk.RESPONSE_APPLY:
- ui.dehydrate()
- if pluginfo.Settings:
- try:
- self.ccdaemon.setPluginSettings(pluginfo.getName(), pluginfo.Settings)
- except Exception, e:
- gui_error_message(_("Can't save plugin settings:\n %s", e))
- #for key, val in pluginfo.Settings.iteritems():
- # print "%s:%s" % (key, val)
- elif response == gtk.RESPONSE_CANCEL:
- pass
- else:
- print _("unknown response from settings dialog")
- ui.destroy()
-
- def on_bClose_clicked(self, button):
- self.window.destroy()
-
- def on_tvDumps_cursor_changed(self, treeview):
- pluginsListStore, path = treeview.get_selection().get_selected_rows()
- if not path:
- self.builder.get_object("lDescription").set_label("No description")
- return
- # this should work until we keep the row object in the last position
- pluginfo = pluginsListStore.get_value(pluginsListStore.get_iter(path[0]), pluginsListStore.get_n_columns()-1)
- if pluginfo:
- self.builder.get_object("lPluginAuthor").set_text(pluginfo.Email)
- self.builder.get_object("lPluginVersion").set_text(pluginfo.Version)
- self.builder.get_object("lPluginWebSite").set_text(pluginfo.WWW)
- self.builder.get_object("lPluginName").set_text(pluginfo.Name)
- self.builder.get_object("lPluginDescription").set_text(pluginfo.Description)
- # print (pluginfo.Enabled == "yes" and pluginfo.GTKBuilder != "")
- self.builder.get_object("bConfigurePlugin").set_sensitive(pluginfo != None and pluginfo.Enabled == "yes" and pluginfo.GTKBuilder != "")
diff --git a/src/Gui/ccgui.glade b/src/Gui/ccgui.glade
index 7b8dd24..67bf6fa 100644
--- a/src/Gui/ccgui.glade
+++ b/src/Gui/ccgui.glade
@@ -148,6 +148,13 @@ Zdenek Prikryl &lt;zprikryl@redhat.com&gt;</property>
<property name="use_stock">True</property>
</widget>
</child>
+ <child>
+ <widget class="GtkMenuItem" id="miSettings">
+ <property name="visible">True</property>
+ <property name="label" translatable="yes">Global settings</property>
+ <property name="use_underline">True</property>
+ </widget>
+ </child>
</widget>
</child>
</widget>
diff --git a/src/Gui/settings.GtkBuilder b/src/Gui/settings.GtkBuilder
index 575b77c..676f390 100644
--- a/src/Gui/settings.GtkBuilder
+++ b/src/Gui/settings.GtkBuilder
@@ -2,7 +2,7 @@
<interface>
<requires lib="gtk+" version="2.14"/>
<!-- interface-naming-policy project-wide -->
- <object class="GtkWindow" id="wSettings">
+ <object class="GtkWindow" id="wPluginsSettings">
<property name="title" translatable="yes">Settings</property>
<property name="modal">True</property>
<property name="default_width">450</property>
@@ -214,4 +214,262 @@
</object>
</child>
</object>
+ <object class="GtkWindow" id="wGlobalSettings">
+ <property name="title" translatable="yes">Global Settings</property>
+ <property name="modal">True</property>
+ <property name="default_width">450</property>
+ <property name="default_height">400</property>
+ <child>
+ <object class="GtkVBox" id="gsvbox1">
+ <property name="visible">True</property>
+ <property name="orientation">vertical</property>
+ <child>
+ <object class="GtkNotebook" id="notebook1">
+ <property name="visible">True</property>
+ <property name="can_focus">True</property>
+ <child>
+ <object class="GtkTable" id="stable1">
+ <property name="visible">True</property>
+ <property name="n_rows">3</property>
+ <property name="n_columns">3</property>
+ <child>
+ <placeholder/>
+ </child>
+ <child>
+ <placeholder/>
+ </child>
+ <child>
+ <placeholder/>
+ </child>
+ <child>
+ <placeholder/>
+ </child>
+ <child>
+ <placeholder/>
+ </child>
+ <child>
+ <placeholder/>
+ </child>
+ <child>
+ <placeholder/>
+ </child>
+ <child>
+ <placeholder/>
+ </child>
+ <child>
+ <placeholder/>
+ </child>
+ </object>
+ </child>
+ <child type="tab">
+ <object class="GtkLabel" id="pCommon">
+ <property name="visible">True</property>
+ <property name="label" translatable="yes">Common</property>
+ </object>
+ <packing>
+ <property name="tab_fill">False</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkVBox" id="cron_vbox">
+ <property name="visible">True</property>
+ <property name="orientation">vertical</property>
+ <child>
+ <object class="GtkScrolledWindow" id="swCronJobs">
+ <property name="visible">True</property>
+ <property name="can_focus">True</property>
+ <property name="hscrollbar_policy">automatic</property>
+ <property name="vscrollbar_policy">automatic</property>
+ <child>
+ <object class="GtkViewport" id="vpCronJobs">
+ <property name="visible">True</property>
+ <property name="resize_mode">queue</property>
+ <child>
+ <object class="GtkVBox" id="vbCronJobs">
+ <property name="visible">True</property>
+ <property name="orientation">vertical</property>
+ <child>
+ <placeholder/>
+ </child>
+ </object>
+ </child>
+ </object>
+ </child>
+ </object>
+ <packing>
+ <property name="position">0</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkHBox" id="cron_add_button_hbox">
+ <property name="visible">True</property>
+ <property name="homogeneous">True</property>
+ <child>
+ <object class="GtkAlignment" id="add_alignment1">
+ <property name="visible">True</property>
+ <child>
+ <placeholder/>
+ </child>
+ </object>
+ <packing>
+ <property name="position">0</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkAlignment" id="add_alignment2">
+ <property name="visible">True</property>
+ <child>
+ <placeholder/>
+ </child>
+ </object>
+ <packing>
+ <property name="position">1</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkButton" id="bAddCronJob">
+ <property name="label" translatable="yes">gtk-add</property>
+ <property name="visible">True</property>
+ <property name="can_focus">True</property>
+ <property name="receives_default">True</property>
+ <property name="use_stock">True</property>
+ </object>
+ <packing>
+ <property name="position">2</property>
+ </packing>
+ </child>
+ </object>
+ <packing>
+ <property name="expand">False</property>
+ <property name="position">1</property>
+ </packing>
+ </child>
+ </object>
+ <packing>
+ <property name="position">1</property>
+ </packing>
+ </child>
+ <child type="tab">
+ <object class="GtkLabel" id="pCron">
+ <property name="visible">True</property>
+ <property name="label" translatable="yes">Cron</property>
+ </object>
+ <packing>
+ <property name="position">1</property>
+ <property name="tab_fill">False</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkTable" id="stable3">
+ <property name="visible">True</property>
+ <property name="n_rows">3</property>
+ <property name="n_columns">3</property>
+ <child>
+ <placeholder/>
+ </child>
+ <child>
+ <placeholder/>
+ </child>
+ <child>
+ <placeholder/>
+ </child>
+ <child>
+ <placeholder/>
+ </child>
+ <child>
+ <placeholder/>
+ </child>
+ <child>
+ <placeholder/>
+ </child>
+ <child>
+ <placeholder/>
+ </child>
+ <child>
+ <placeholder/>
+ </child>
+ <child>
+ <placeholder/>
+ </child>
+ </object>
+ <packing>
+ <property name="position">2</property>
+ </packing>
+ </child>
+ <child type="tab">
+ <object class="GtkLabel" id="pAnacre">
+ <property name="visible">True</property>
+ <property name="label" translatable="yes">Analyzers, Actions, Reporters</property>
+ </object>
+ <packing>
+ <property name="position">2</property>
+ <property name="tab_fill">False</property>
+ </packing>
+ </child>
+ </object>
+ <packing>
+ <property name="position">0</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkHBox" id="button_align_hbox">
+ <property name="visible">True</property>
+ <property name="homogeneous">True</property>
+ <child>
+ <object class="GtkAlignment" id=" button_alignment">
+ <property name="visible">True</property>
+ <child>
+ <placeholder/>
+ </child>
+ </object>
+ <packing>
+ <property name="position">0</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkHBox" id="shbox1">
+ <property name="visible">True</property>
+ <property name="spacing">14</property>
+ <property name="homogeneous">True</property>
+ <child>
+ <object class="GtkButton" id="bCancelSettings">
+ <property name="label" translatable="yes">gtk-cancel</property>
+ <property name="visible">True</property>
+ <property name="can_focus">True</property>
+ <property name="receives_default">True</property>
+ <property name="use_stock">True</property>
+ </object>
+ <packing>
+ <property name="expand">False</property>
+ <property name="position">0</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkButton" id="bSaveSettings">
+ <property name="label" translatable="yes">gtk-ok</property>
+ <property name="visible">True</property>
+ <property name="can_focus">True</property>
+ <property name="receives_default">True</property>
+ <property name="use_stock">True</property>
+ </object>
+ <packing>
+ <property name="expand">False</property>
+ <property name="position">1</property>
+ </packing>
+ </child>
+ </object>
+ <packing>
+ <property name="position">1</property>
+ </packing>
+ </child>
+ </object>
+ <packing>
+ <property name="expand">False</property>
+ <property name="fill">False</property>
+ <property name="position">1</property>
+ </packing>
+ </child>
+ </object>
+ </child>
+ </object>
</interface>