diff options
| author | Karel Klic <kklic@redhat.com> | 2009-11-19 10:14:27 +0100 |
|---|---|---|
| committer | Karel Klic <kklic@redhat.com> | 2009-11-19 10:14:27 +0100 |
| commit | bd60681c8227bc31ef0991e98a9a3e849032c924 (patch) | |
| tree | 5d4f3cf03d54ecb30ab863c7cc349bfcd232346c /src | |
| parent | 0ecc573a8ba79bca8e37809c41f92f0b629149e8 (diff) | |
| parent | 83aea71df4761ec10c0d947055e65102bcace489 (diff) | |
| download | abrt-bd60681c8227bc31ef0991e98a9a3e849032c924.tar.gz abrt-bd60681c8227bc31ef0991e98a9a3e849032c924.tar.xz abrt-bd60681c8227bc31ef0991e98a9a3e849032c924.zip | |
Merge branch 'master' of ssh://git.fedorahosted.org/git/abrt
Diffstat (limited to 'src')
| -rw-r--r-- | src/Applet/Applet.cpp | 9 | ||||
| -rw-r--r-- | src/Applet/CCApplet.cpp | 89 | ||||
| -rw-r--r-- | src/Applet/CCApplet.h | 22 | ||||
| -rw-r--r-- | src/Applet/Makefile.am | 1 | ||||
| -rw-r--r-- | src/CLI/CLI.cpp | 14 | ||||
| -rw-r--r-- | src/CLI/Makefile.am | 12 | ||||
| -rw-r--r-- | src/Daemon/CommLayerServerDBus.cpp | 2 | ||||
| -rw-r--r-- | src/Daemon/CrashWatcher.cpp | 2 | ||||
| -rw-r--r-- | src/Daemon/Daemon.cpp | 6 | ||||
| -rw-r--r-- | src/Daemon/MiddleWare.cpp | 51 | ||||
| -rw-r--r-- | src/Daemon/PluginManager.cpp | 179 | ||||
| -rw-r--r-- | src/Daemon/PluginManager.h | 34 | ||||
| -rw-r--r-- | src/Daemon/Settings.cpp | 62 | ||||
| -rwxr-xr-x | src/Daemon/abrt-debuginfo-install | 70 | ||||
| -rw-r--r-- | src/Daemon/abrt.conf | 7 | ||||
| -rw-r--r-- | src/Gui/CCMainWindow.py | 4 | ||||
| -rw-r--r-- | src/Gui/CCReporterDialog.py | 20 | ||||
| -rw-r--r-- | src/Gui/CC_gui_functions.py | 2 | ||||
| -rw-r--r-- | src/Gui/Makefile.am | 3 | ||||
| -rw-r--r-- | src/Gui/abrt.desktop.in (renamed from src/Gui/abrt.desktop) | 4 | ||||
| -rw-r--r-- | src/Gui/ccgui.glade | 1 | ||||
| -rw-r--r-- | src/Gui/report.glade | 2 | ||||
| -rw-r--r-- | src/Hooks/CCpp.cpp | 14 | ||||
| -rw-r--r-- | src/Hooks/abrt_exception_handler.py.in | 18 | ||||
| -rw-r--r-- | src/Hooks/sitecustomize.py | 4 |
25 files changed, 381 insertions, 251 deletions
diff --git a/src/Applet/Applet.cpp b/src/Applet/Applet.cpp index 2eed556..46278c6 100644 --- a/src/Applet/Applet.cpp +++ b/src/Applet/Applet.cpp @@ -134,10 +134,9 @@ static void NameOwnerChanged(DBusMessage* signal) return; } - if (new_owner[0]) - applet->Enable(_("ABRT service has been started")); - else - applet->Disable(_("ABRT service is not running")); +// hide icon if it's visible - as NM and don't show it, if it's not + if(!new_owner[0]) + applet->HideIcon(); } static DBusHandlerResult handle_message(DBusConnection* conn, DBusMessage* msg, void* user_data) @@ -202,7 +201,7 @@ int main(int argc, char** argv) default: error_msg_and_die( "Usage: abrt-applet [-v]\n" - "\nOptions:" + "\nOptions:" "\n\t-v\tVerbose" ); } diff --git a/src/Applet/CCApplet.cpp b/src/Applet/CCApplet.cpp index bae0cf8..e6a3cf0 100644 --- a/src/Applet/CCApplet.cpp +++ b/src/Applet/CCApplet.cpp @@ -108,9 +108,20 @@ You should have received a copy of the GNU General Public License along with thi CApplet::CApplet() { - m_pStatusIcon = gtk_status_icon_new_from_stock(GTK_STOCK_DIALOG_WARNING); m_bDaemonRunning = true; - + /* set-up icon buffers */ + m_iAnimator = 0; + m_iAnimationStage = ICON_DEFAULT; + m_bIconsLoaded = load_icons(); + /* - animation - */ + if(m_bIconsLoaded == true) + { + m_pStatusIcon = gtk_status_icon_new_from_pixbuf(icon_stages_buff[ICON_DEFAULT]); + } + else + { + m_pStatusIcon = gtk_status_icon_new_from_stock(GTK_STOCK_DIALOG_WARNING); + } notify_init("ABRT"); m_pNotification = notify_notification_new_with_status_icon("Warning", NULL, NULL, m_pStatusIcon); notify_notification_set_urgency(m_pNotification, NOTIFY_URGENCY_CRITICAL); @@ -186,7 +197,7 @@ void CApplet::CrashNotify(const char *format, ...) if (gtk_status_icon_is_embedded(m_pStatusIcon)) notify_notification_show(m_pNotification, &err); if (err != NULL) - g_print(err->message); + error_msg(err->message); } void CApplet::OnAppletActivate_CB(GtkStatusIcon *status_icon, gpointer user_data) @@ -215,7 +226,11 @@ void CApplet::OnMenuPopup_cb(GtkStatusIcon *status_icon, guint activate_time, gpointer user_data) { - if (((CApplet *)user_data)->m_pMenu != NULL) + CApplet *applet = (CApplet *)user_data; + /* stop the animation */ + applet->stop_animate_icon(); + + if (applet->m_pMenu != NULL) { gtk_menu_popup(GTK_MENU(((CApplet *)user_data)->m_pMenu), NULL, NULL, @@ -227,8 +242,9 @@ void CApplet::OnMenuPopup_cb(GtkStatusIcon *status_icon, void CApplet::ShowIcon() { gtk_status_icon_set_visible(m_pStatusIcon, true); - //Active wait for icon to be REALLY visible in status area - //while(!gtk_status_icon_is_embedded(m_pStatusIcon)) continue; + /* only animate if all icons are loaded, use the "gtk-warning" instead */ + if(m_bIconsLoaded) + animate_icon(); } void CApplet::onHide_cb(GtkMenuItem *menuitem, gpointer applet) @@ -243,10 +259,11 @@ void CApplet::onAbout_cb(GtkMenuItem *menuitem, gpointer dialog) gtk_widget_hide(GTK_WIDGET(dialog)); } -//void CApplet::HideIcon() -//{ -// gtk_status_icon_set_visible(m_pStatusIcon, false); -//} +void CApplet::HideIcon() +{ + gtk_status_icon_set_visible(m_pStatusIcon, false); + stop_animate_icon(); +} void CApplet::Disable(const char *reason) { @@ -279,6 +296,58 @@ void CApplet::Enable(const char *reason) ShowIcon(); } +gboolean CApplet::update_icon(void *user_data) +{ + CApplet* applet = (CApplet*)user_data; + if(applet->m_pStatusIcon && applet->m_iAnimationStage < ICON_STAGE_LAST){ + gtk_status_icon_set_from_pixbuf(applet->m_pStatusIcon, + applet->icon_stages_buff[applet->m_iAnimationStage++]); + } + else + error_msg("icon is null"); + if(applet->m_iAnimationStage == ICON_STAGE_LAST){ + applet->m_iAnimationStage = 0; + } + return true; +} + +void CApplet::animate_icon() +{ + if(m_iAnimator == 0) + { + m_iAnimator = g_timeout_add(100, update_icon, this); + } +} + +void CApplet::stop_animate_icon() +{ + /* animator should be 0 if icons are not loaded, so this should be safe */ + if(m_iAnimator != 0){ + g_source_remove(m_iAnimator); + gtk_status_icon_set_from_pixbuf(m_pStatusIcon, icon_stages_buff[ICON_DEFAULT]); + m_iAnimator = 0; + } +} + +bool CApplet::load_icons() +{ + int stage; + for(stage = ICON_DEFAULT; stage < ICON_STAGE_LAST; stage++) + { + char name[sizeof(ICON_DIR"/abrt%02d.png")]; + GError *error = NULL; + if(snprintf(name, sizeof(ICON_DIR"/abrt%02d.png"),ICON_DIR"/abrt%02d.png", stage) > 0){ + icon_stages_buff[stage] = gdk_pixbuf_new_from_file(name, &error); + if(error != NULL){ + error_msg("Can't load pixbuf from %s, animation is disabled!", name); + return false; + } + } + } + return true; +} + + //int CApplet::AddEvent(int pUUID, const std::string& pProgname) //{ // m_mapEvents[pUUID] = "pProgname"; diff --git a/src/Applet/CCApplet.h b/src/Applet/CCApplet.h index 5c42c36..538eda5 100644 --- a/src/Applet/CCApplet.h +++ b/src/Applet/CCApplet.h @@ -39,12 +39,28 @@ class CApplet NotifyNotification *m_pNotification; // std::map<int, std::string> m_mapEvents; bool m_bDaemonRunning; + int m_iAnimationStage; + guint m_iAnimator; + bool m_bIconsLoaded; + + enum ICON_STAGES + { + ICON_DEFAULT, + ICON_STAGE1, + ICON_STAGE2, + ICON_STAGE3, + ICON_STAGE4, + ICON_STAGE5, + /* this must be always the last */ + ICON_STAGE_LAST + } icon_stages; + GdkPixbuf *icon_stages_buff[ICON_STAGE_LAST]; public: CApplet(); ~CApplet(); void ShowIcon(); -// void HideIcon(); + void HideIcon(); //void DisableIcon(); // void BlinkIcon(bool pBlink); void SetIconTooltip(const char *format, ...); @@ -67,6 +83,10 @@ class CApplet gpointer user_data); static void onHide_cb(GtkMenuItem *menuitem, gpointer applet); static void onAbout_cb(GtkMenuItem *menuitem, gpointer applet); + static gboolean update_icon(void *data); + void animate_icon(); + void stop_animate_icon(); + bool load_icons(); }; #endif diff --git a/src/Applet/Makefile.am b/src/Applet/Makefile.am index d098044..6fca43a 100644 --- a/src/Applet/Makefile.am +++ b/src/Applet/Makefile.am @@ -15,6 +15,7 @@ abrt_applet_CPPFLAGS = \ -DDEBUG_DUMPS_DIR=\"$(DEBUG_DUMPS_DIR)\" \ -DPLUGINS_LIB_DIR=\"$(PLUGINS_LIB_DIR)\" \ -DPLUGINS_CONF_DIR=\"$(PLUGINS_CONF_DIR)\" \ + -DICON_DIR=\"${datadir}/icons/hicolor/48x48/apps\" \ $(GTK_CFLAGS) \ $(DBUS_CFLAGS) \ -D_GNU_SOURCE diff --git a/src/CLI/CLI.cpp b/src/CLI/CLI.cpp index edc8df0..9f2db3f 100644 --- a/src/CLI/CLI.cpp +++ b/src/CLI/CLI.cpp @@ -17,7 +17,6 @@ */ #include <getopt.h> #include "ABRTException.h" -#include "ABRTSocket.h" #include "abrtlib.h" #include "abrt_dbus.h" #include "DBusCommon.h" @@ -99,20 +98,19 @@ static const struct option longopts[] = }; /* Gets the program name from the first command line argument. */ -static char *progname(char *argv0) +static const char *progname(const char *argv0) { - char* name = strrchr(argv0, '/'); + const char* name = strrchr(argv0, '/'); if (name) return ++name; - else - return argv0; + return argv0; } /* Prints abrt-cli version and some help text. */ static void usage(char *argv0) { - char *name = progname(argv0); - printf("%s " VERSION "\n\n", name); + const char *name = progname(argv0); + printf("%s "VERSION"\n\n", name); /* Message has embedded tabs. */ printf(_("Usage: %s [OPTION]\n\n" @@ -167,7 +165,7 @@ int main(int argc, char** argv) return 1; case 'V': case OPT_VERSION: - printf("%s " VERSION "\n", progname(argv[0])); + printf("%s "VERSION"\n", progname(argv[0])); return 0; } if (c == -1) diff --git a/src/CLI/Makefile.am b/src/CLI/Makefile.am index dbeb1c3..e84d426 100644 --- a/src/CLI/Makefile.am +++ b/src/CLI/Makefile.am @@ -1,15 +1,11 @@ bin_PROGRAMS = abrt-cli +# removed: ABRTSocket.h ABRTSocket.cpp abrt_cli_SOURCES = \ CLI.cpp \ - ABRTSocket.h \ - ABRTSocket.cpp \ - run-command.h \ - run-command.cpp \ - report.h \ - report.cpp \ - dbus.h \ - dbus.cpp + run-command.h run-command.cpp \ + report.h report.cpp \ + dbus.h dbus.cpp abrt_cli_CPPFLAGS = \ -I$(srcdir)/../../inc \ diff --git a/src/Daemon/CommLayerServerDBus.cpp b/src/Daemon/CommLayerServerDBus.cpp index ed7e385..2c2ca3a 100644 --- a/src/Daemon/CommLayerServerDBus.cpp +++ b/src/Daemon/CommLayerServerDBus.cpp @@ -352,7 +352,7 @@ static int handle_GetPluginSettings(DBusMessage* call, DBusMessage* reply) long unix_uid = get_remote_uid(call); VERB1 log("got %s('%s') call from uid %ld", "GetPluginSettings", PluginName, unix_uid); - map_plugin_settings_t plugin_settings = g_pPluginManager->GetPluginSettings(PluginName, to_string(unix_uid)); + map_plugin_settings_t plugin_settings = g_pPluginManager->GetPluginSettings(PluginName, to_string(unix_uid).c_str()); DBusMessageIter iter; dbus_message_iter_init_append(reply, &iter); diff --git a/src/Daemon/CrashWatcher.cpp b/src/Daemon/CrashWatcher.cpp index e684277..f859515 100644 --- a/src/Daemon/CrashWatcher.cpp +++ b/src/Daemon/CrashWatcher.cpp @@ -113,7 +113,7 @@ map_crash_report_t GetJobResult(const char* pUUID, const char* pUID, int force) /* FIXME: starting from here, any shared data must be protected with a mutex. * For example, CreateCrashReport does: - * g_pPluginManager->GetDatabase(g_settings_sDatabase); + * g_pPluginManager->GetDatabase(g_settings_sDatabase.c_str()); * which is unsafe wrt concurrent updates to g_pPluginManager state. */ mw_result_t res = CreateCrashReport(pUUID, pUID, force, crashReport); diff --git a/src/Daemon/Daemon.cpp b/src/Daemon/Daemon.cpp index 53c44d3..087d537 100644 --- a/src/Daemon/Daemon.cpp +++ b/src/Daemon/Daemon.cpp @@ -223,7 +223,7 @@ static void SetUpMW() set_string_t::iterator it_p = g_settings_setEnabledPlugins.begin(); for (; it_p != g_settings_setEnabledPlugins.end(); it_p++) { - g_pPluginManager->RegisterPlugin(*it_p); + g_pPluginManager->RegisterPlugin(it_p->c_str()); } VERB1 log("Adding actions or reporters"); vector_pair_string_string_t::iterator it_ar = g_settings_vectorActionsAndReporters.begin(); @@ -685,9 +685,9 @@ static void sanitize_dump_dir_rights() /* 00777 bits are usual "rwxrwxrwx" access rights */ ensure_writable_dir(DEBUG_DUMPS_DIR, 0775, "abrt"); /* debuginfo cache */ - ensure_writable_dir(DEBUG_DUMPS_DIR"-di", 0755, "root"); + ensure_writable_dir(DEBUG_DUMPS_DIR"-di", 0755, "root"); /* temp dir */ - ensure_writable_dir(VAR_RUN"/abrt", 0755, "root"); + ensure_writable_dir(VAR_RUN"/abrt", 0755, "root"); } int main(int argc, char** argv) diff --git a/src/Daemon/MiddleWare.cpp b/src/Daemon/MiddleWare.cpp index 0bc358e..66bdea6 100644 --- a/src/Daemon/MiddleWare.cpp +++ b/src/Daemon/MiddleWare.cpp @@ -184,7 +184,7 @@ mw_result_t CreateCrashReport(const char *pUUID, database_row_t row; if (pUUID[0] != '\0') { - CDatabase* database = g_pPluginManager->GetDatabase(g_settings_sDatabase); + CDatabase* database = g_pPluginManager->GetDatabase(g_settings_sDatabase.c_str()); database->Connect(); row = database->GetUUIDData(pUUID, pUID); database->DisConnect(); @@ -278,17 +278,21 @@ void RunActionsAndReporters(const char *pDebugDumpDir) { try { - if (g_pPluginManager->GetPluginType(it_ar->first) == REPORTER) + VERB3 log("RunActionsAndReporters: checking %s", it_ar->first.c_str()); + plugin_type_t tp = g_pPluginManager->GetPluginType(it_ar->first.c_str()); + if (tp == REPORTER) { - CReporter* reporter = g_pPluginManager->GetReporter(it_ar->first); + CReporter* reporter = g_pPluginManager->GetReporter(it_ar->first.c_str()); map_crash_report_t crashReport; DebugDumpToCrashReport(pDebugDumpDir, crashReport); + VERB2 log("%s.Report(...)", it_ar->first.c_str()); reporter->Report(crashReport, plugin_settings, it_ar->second); } - else if (g_pPluginManager->GetPluginType(it_ar->first) == ACTION) + else if (tp == ACTION) { - CAction* action = g_pPluginManager->GetAction(it_ar->first); + CAction* action = g_pPluginManager->GetAction(it_ar->first.c_str()); + VERB2 log("%s.Run('%s','%s')", it_ar->first.c_str(), pDebugDumpDir, it_ar->second.c_str()); action->Run(pDebugDumpDir, it_ar->second.c_str()); } } @@ -375,27 +379,31 @@ report_status_t Report(const map_crash_report_t& pCrashReport, } } - // analyzer with package name (CCpp:xrog-x11-app) has higher priority + // analyzer with package name (CCpp:xorg-x11-app) has higher priority std::string key = analyzer + ":" + packageName; + map_analyzer_actions_and_reporters_t::iterator end = s_mapAnalyzerActionsAndReporters.end(); map_analyzer_actions_and_reporters_t::iterator keyPtr = s_mapAnalyzerActionsAndReporters.find(key); - if (keyPtr == s_mapAnalyzerActionsAndReporters.end()) + if (keyPtr == end) { // if there is no such settings, then try default analyzer keyPtr = s_mapAnalyzerActionsAndReporters.find(analyzer); + key = analyzer; } std::string message; - if (keyPtr != s_mapAnalyzerActionsAndReporters.end()) + if (keyPtr != end) { + VERB2 log("Found AnalyzerActionsAndReporters for '%s'", key.c_str()); + vector_pair_string_string_t::iterator it_r = keyPtr->second.begin(); for (; it_r != keyPtr->second.end(); it_r++) { std::string pluginName = it_r->first; try { - if (g_pPluginManager->GetPluginType(pluginName) == REPORTER) + if (g_pPluginManager->GetPluginType(pluginName.c_str()) == REPORTER) { - CReporter* reporter = g_pPluginManager->GetReporter(pluginName); + CReporter* reporter = g_pPluginManager->GetReporter(pluginName.c_str()); #if 0 /* Using ~user/.abrt/ is bad wrt security */ std::string home = ""; map_plugin_settings_t oldSettings; @@ -433,12 +441,12 @@ report_status_t Report(const map_crash_report_t& pCrashReport, { ret[pluginName].push_back("0"); ret[pluginName].push_back(e.what()); - update_client("Reporting via %s' was not successful: %s", pluginName.c_str(), e.what()); + update_client("Reporting via '%s' was not successful: %s", pluginName.c_str(), e.what()); } } } - CDatabase* database = g_pPluginManager->GetDatabase(g_settings_sDatabase); + CDatabase* database = g_pPluginManager->GetDatabase(g_settings_sDatabase.c_str()); database->Connect(); database->SetReported(UUID, UID, message); database->DisConnect(); @@ -456,7 +464,7 @@ void DeleteDebugDumpDir(const char *pDebugDumpDir) std::string DeleteCrashInfo(const char *pUUID, const char *pUID) { - CDatabase* database = g_pPluginManager->GetDatabase(g_settings_sDatabase); + CDatabase* database = g_pPluginManager->GetDatabase(g_settings_sDatabase.c_str()); database->Connect(); database_row_t row = database->GetUUIDData(pUUID, pUID); database->Delete(pUUID, pUID); @@ -476,7 +484,7 @@ std::string DeleteCrashInfo(const char *pUUID, static bool IsDebugDumpSaved(const char *pUID, const char *pDebugDumpDir) { - CDatabase* database = g_pPluginManager->GetDatabase(g_settings_sDatabase); + CDatabase* database = g_pPluginManager->GetDatabase(g_settings_sDatabase.c_str()); database->Connect(); vector_database_rows_t rows = database->GetUIDData(pUID); database->DisConnect(); @@ -604,9 +612,9 @@ static void RunAnalyzerActions(const char *pAnalyzer, const char *pDebugDumpDir) std::string pluginName = it_a->first; try { - if (g_pPluginManager->GetPluginType(pluginName) == ACTION) + if (g_pPluginManager->GetPluginType(pluginName.c_str()) == ACTION) { - CAction* action = g_pPluginManager->GetAction(pluginName); + CAction* action = g_pPluginManager->GetAction(pluginName.c_str()); action->Run(pDebugDumpDir, it_a->second.c_str()); } } @@ -635,7 +643,7 @@ static mw_result_t SaveDebugDumpToDatabase(const char *pUUID, const char *pDebugDumpDir, map_crash_info_t& pCrashInfo) { - CDatabase* database = g_pPluginManager->GetDatabase(g_settings_sDatabase); + CDatabase* database = g_pPluginManager->GetDatabase(g_settings_sDatabase.c_str()); database->Connect(); database->Insert(pUUID, pUID, pDebugDumpDir, pTime); database_row_t row = database->GetUUIDData(pUUID, pUID); @@ -657,7 +665,7 @@ static mw_result_t SaveDebugDumpToDatabase(const char *pUUID, std::string getDebugDumpDir(const char *pUUID, const char *pUID) { - CDatabase* database = g_pPluginManager->GetDatabase(g_settings_sDatabase); + CDatabase* database = g_pPluginManager->GetDatabase(g_settings_sDatabase.c_str()); database->Connect(); database_row_t row = database->GetUUIDData(pUUID, pUID); database->DisConnect(); @@ -712,7 +720,7 @@ mw_result_t GetCrashInfo(const char *pUUID, map_crash_info_t& pCrashInfo) { pCrashInfo.clear(); - CDatabase* database = g_pPluginManager->GetDatabase(g_settings_sDatabase); + CDatabase* database = g_pPluginManager->GetDatabase(g_settings_sDatabase.c_str()); database->Connect(); database_row_t row = database->GetUUIDData(pUUID, pUID); database->DisConnect(); @@ -757,14 +765,14 @@ mw_result_t GetCrashInfo(const char *pUUID, vector_pair_string_string_t GetUUIDsOfCrash(const char *pUID) { - CDatabase* database = g_pPluginManager->GetDatabase(g_settings_sDatabase); + CDatabase* database = g_pPluginManager->GetDatabase(g_settings_sDatabase.c_str()); vector_database_rows_t rows; database->Connect(); rows = database->GetUIDData(pUID); database->DisConnect(); vector_pair_string_string_t UUIDsUIDs; - int ii; + unsigned ii; for (ii = 0; ii < rows.size(); ii++) { UUIDsUIDs.push_back(make_pair(rows[ii].m_sUUID, rows[ii].m_sUID)); @@ -783,5 +791,6 @@ void AddAnalyzerActionOrReporter(const char *pAnalyzer, void AddActionOrReporter(const char *pActionOrReporter, const char *pArgs) { + VERB3 log("AddActionOrReporter('%s','%s')", pActionOrReporter, pArgs); s_vectorActionsAndReporters.push_back(make_pair(std::string(pActionOrReporter), std::string(pArgs))); } diff --git a/src/Daemon/PluginManager.cpp b/src/Daemon/PluginManager.cpp index 5b87151..3867ec9 100644 --- a/src/Daemon/PluginManager.cpp +++ b/src/Daemon/PluginManager.cpp @@ -30,7 +30,7 @@ /** * Text representation of plugin types. */ -static const char* const plugin_type_str[] = { +static const char *const plugin_type_str[] = { "Analyzer", "Action", "Reporter", @@ -38,61 +38,60 @@ static const char* const plugin_type_str[] = { }; -bool LoadPluginSettings(const std::string& pPath, map_plugin_settings_t& pSettings) +bool LoadPluginSettings(const char *pPath, map_plugin_settings_t& pSettings) { std::ifstream fIn; - fIn.open(pPath.c_str()); - if (fIn.is_open()) + fIn.open(pPath); + if (!fIn.is_open()) + return false; + + std::string line; + while (!fIn.eof()) { - std::string line; - while (!fIn.eof()) + getline(fIn, line); + + int ii; + bool is_value = false; + bool valid = false; + bool in_quote = false; + std::string key; + std::string value; + for (ii = 0; ii < line.length(); ii++) { - getline(fIn, line); - - int ii; - bool is_value = false; - bool valid = false; - bool in_quote = false; - std::string key = ""; - std::string value = ""; - for (ii = 0; ii < line.length(); ii++) + if (line[ii] == '\"') { - if (line[ii] == '\"') - { - in_quote = in_quote == true ? false : true; - } - if (isspace(line[ii]) && !in_quote) - { - continue; - } - if (line[ii] == '#' && !in_quote && key == "") - { - break; - } - if (line[ii] == '=' && !in_quote) - { - is_value = true; - continue; - } - if (!is_value) - { - key += line[ii]; - } - else - { - valid = true; - value += line[ii]; - } + in_quote = in_quote == true ? false : true; } - if (valid && !in_quote) + if (isspace(line[ii]) && !in_quote) { - pSettings[key] = value; + continue; + } + if (line[ii] == '#' && !in_quote && key == "") + { + break; + } + if (line[ii] == '=' && !in_quote) + { + is_value = true; + continue; + } + if (!is_value) + { + key += line[ii]; + } + else + { + valid = true; + value += line[ii]; } } - fIn.close(); - return true; + if (valid && !in_quote) + { + pSettings[key] = value; + } } - return false; + fIn.close(); + return true; } /** @@ -101,9 +100,9 @@ bool LoadPluginSettings(const std::string& pPath, map_plugin_settings_t& pSettin * @param settings Plugin's settings. * @return if it success it returns true, otherwise it returns false. */ -static bool SavePluginSettings(const std::string& pPath, const map_plugin_settings_t& pSettings) +static bool SavePluginSettings(const char *pPath, const map_plugin_settings_t& pSettings) { - FILE* fOut = fopen(pPath.c_str(), "w"); + FILE* fOut = fopen(pPath, "w"); if (fOut) { fprintf(fOut, "# Settings were written by abrt\n"); @@ -141,7 +140,7 @@ void CPluginManager::LoadPlugins() { name.erase(0, sizeof(PLUGINS_LIB_PREFIX) - 1); name.erase(name.length() - sizeof(PLUGINS_LIB_EXTENSION)); - LoadPlugin(name); + LoadPlugin(name.c_str()); } } } @@ -151,40 +150,39 @@ void CPluginManager::LoadPlugins() void CPluginManager::UnLoadPlugins() { - map_abrt_plugins_t::iterator it_p; - while ((it_p = m_mapABRTPlugins.begin()) != m_mapABRTPlugins.end()) + map_abrt_plugins_t::iterator it; + while ((it = m_mapABRTPlugins.begin()) != m_mapABRTPlugins.end()) { - std::string pluginName = it_p->first; - UnLoadPlugin(pluginName); + UnLoadPlugin(it->first.c_str()); } } -void CPluginManager::LoadPlugin(const std::string& pName) +void CPluginManager::LoadPlugin(const char *pName) { if (m_mapABRTPlugins.find(pName) == m_mapABRTPlugins.end()) { CABRTPlugin* abrtPlugin = NULL; try { - std::string libPath = PLUGINS_LIB_DIR"/"PLUGINS_LIB_PREFIX + pName + "."PLUGINS_LIB_EXTENSION; + std::string libPath = ssprintf(PLUGINS_LIB_DIR"/"PLUGINS_LIB_PREFIX"%s."PLUGINS_LIB_EXTENSION, pName); abrtPlugin = new CABRTPlugin(libPath.c_str()); if (abrtPlugin->GetMagicNumber() != PLUGINS_MAGIC_NUMBER || (abrtPlugin->GetType() < ANALYZER && abrtPlugin->GetType() > DATABASE)) { throw CABRTException(EXCEP_PLUGIN, "CPluginManager::LoadPlugin(): non-compatible plugin"); } - log("Plugin %s (%s) succesfully loaded", pName.c_str(), abrtPlugin->GetVersion()); + log("Plugin %s (%s) succesfully loaded", pName, abrtPlugin->GetVersion()); m_mapABRTPlugins[pName] = abrtPlugin; } catch (CABRTException& e) { delete abrtPlugin; - error_msg("Failed to load plugin %s: %s", pName.c_str(), e.what()); + error_msg("Failed to load plugin %s: %s", pName, e.what()); } } } -void CPluginManager::UnLoadPlugin(const std::string& pName) +void CPluginManager::UnLoadPlugin(const char *pName) { map_abrt_plugins_t::iterator abrt_plugin = m_mapABRTPlugins.find(pName); if (abrt_plugin != m_mapABRTPlugins.end()) @@ -192,11 +190,11 @@ void CPluginManager::UnLoadPlugin(const std::string& pName) UnRegisterPlugin(pName); delete abrt_plugin->second; m_mapABRTPlugins.erase(abrt_plugin); - log("Plugin %s successfully unloaded", pName.c_str()); + log("Plugin %s successfully unloaded", pName); } } -void CPluginManager::RegisterPlugin(const std::string& pName) +void CPluginManager::RegisterPlugin(const char *pName) { map_abrt_plugins_t::iterator abrt_plugin = m_mapABRTPlugins.find(pName); if (abrt_plugin != m_mapABRTPlugins.end()) @@ -206,7 +204,7 @@ void CPluginManager::RegisterPlugin(const std::string& pName) CPlugin* plugin = abrt_plugin->second->PluginNew(); map_plugin_settings_t pluginSettings; - LoadPluginSettings(PLUGINS_CONF_DIR"/" + pName + "."PLUGINS_CONF_EXTENSION, pluginSettings); + LoadPluginSettings(ssprintf(PLUGINS_CONF_DIR"/%s."PLUGINS_CONF_EXTENSION, pName).c_str(), pluginSettings); try { plugin->Init(); @@ -215,7 +213,7 @@ void CPluginManager::RegisterPlugin(const std::string& pName) catch (CABRTException& e) { log("Can't initialize plugin %s(%s): %s", - pName.c_str(), + pName, plugin_type_str[abrt_plugin->second->GetType()], e.what() ); @@ -223,13 +221,12 @@ void CPluginManager::RegisterPlugin(const std::string& pName) return; } m_mapPlugins[pName] = plugin; - log("Registered plugin %s(%s)", pName.c_str(), plugin_type_str[abrt_plugin->second->GetType()]); + log("Registered plugin %s(%s)", pName, plugin_type_str[abrt_plugin->second->GetType()]); } } } -void CPluginManager::RegisterPluginDBUS(const std::string& pName, - const char * pDBUSSender) +void CPluginManager::RegisterPluginDBUS(const char *pName, const char *pDBUSSender) { int polkit_result = polkit_check_authorization(pDBUSSender, "org.fedoraproject.abrt.change-daemon-settings"); @@ -242,7 +239,7 @@ void CPluginManager::RegisterPluginDBUS(const std::string& pName, } } -void CPluginManager::UnRegisterPlugin(const std::string& pName) +void CPluginManager::UnRegisterPlugin(const char *pName) { map_abrt_plugins_t::iterator abrt_plugin = m_mapABRTPlugins.find(pName); if (abrt_plugin != m_mapABRTPlugins.end()) @@ -253,13 +250,12 @@ void CPluginManager::UnRegisterPlugin(const std::string& pName) plugin->second->DeInit(); delete plugin->second; m_mapPlugins.erase(plugin); - log("UnRegistered plugin %s(%s)", pName.c_str(), plugin_type_str[abrt_plugin->second->GetType()]); + log("UnRegistered plugin %s(%s)", pName, plugin_type_str[abrt_plugin->second->GetType()]); } } } -void CPluginManager::UnRegisterPluginDBUS(const std::string& pName, - const char * pDBUSSender) +void CPluginManager::UnRegisterPluginDBUS(const char *pName, const char *pDBUSSender) { int polkit_result = polkit_check_authorization(pDBUSSender, "org.fedoraproject.abrt.change-daemon-settings"); @@ -273,77 +269,68 @@ void CPluginManager::UnRegisterPluginDBUS(const std::string& pName, } -CAnalyzer* CPluginManager::GetAnalyzer(const std::string& pName) +CAnalyzer* CPluginManager::GetAnalyzer(const char *pName) { map_plugins_t::iterator plugin = m_mapPlugins.find(pName); if (plugin == m_mapPlugins.end()) { - throw CABRTException(EXCEP_PLUGIN, "CPluginManager::GetAnalyzer():" - "Analyzer plugin: '"+pName+"' is not registered."); + throw CABRTException(EXCEP_PLUGIN, ssprintf("Plugin '%s' is not registered", pName)); } if (m_mapABRTPlugins[pName]->GetType() != ANALYZER) { - throw CABRTException(EXCEP_PLUGIN, "CPluginManager::GetAnalyzer():" - "Plugin: '"+pName+"' is not analyzer plugin."); + throw CABRTException(EXCEP_PLUGIN, ssprintf("Plugin '%s' is not an analyzer plugin", pName)); } return (CAnalyzer*)(plugin->second); } -CReporter* CPluginManager::GetReporter(const std::string& pName) +CReporter* CPluginManager::GetReporter(const char *pName) { map_plugins_t::iterator plugin = m_mapPlugins.find(pName); if (plugin == m_mapPlugins.end()) { - throw CABRTException(EXCEP_PLUGIN, "CPluginManager::GetReporter():" - "Reporter plugin: '"+pName+"' is not registered."); + throw CABRTException(EXCEP_PLUGIN, ssprintf("Plugin '%s' is not registered", pName)); } if (m_mapABRTPlugins[pName]->GetType() != REPORTER) { - throw CABRTException(EXCEP_PLUGIN, "CPluginManager::GetReporter():" - "Plugin: '"+pName+"' is not reporter plugin."); + throw CABRTException(EXCEP_PLUGIN, ssprintf("Plugin '%s' is not a reporter plugin", pName)); } return (CReporter*)(plugin->second); } -CAction* CPluginManager::GetAction(const std::string& pName) +CAction* CPluginManager::GetAction(const char *pName) { map_plugins_t::iterator plugin = m_mapPlugins.find(pName); if (plugin == m_mapPlugins.end()) { - throw CABRTException(EXCEP_PLUGIN, "CPluginManager::GetAction():" - "Action plugin: '"+pName+"' is not registered."); + throw CABRTException(EXCEP_PLUGIN, ssprintf("Plugin '%s' is not registered", pName)); } if (m_mapABRTPlugins[pName]->GetType() != ACTION) { - throw CABRTException(EXCEP_PLUGIN, "CPluginManager::GetAction():" - "Plugin: '"+pName+"' is not action plugin."); + throw CABRTException(EXCEP_PLUGIN, ssprintf("Plugin '%s' is not an action plugin", pName)); } return (CAction*)(plugin->second); } -CDatabase* CPluginManager::GetDatabase(const std::string& pName) +CDatabase* CPluginManager::GetDatabase(const char *pName) { map_plugins_t::iterator plugin = m_mapPlugins.find(pName); if (plugin == m_mapPlugins.end()) { - throw CABRTException(EXCEP_PLUGIN, "CPluginManager::GetDatabase():" - "Database plugin: '"+pName+"' is not registered."); + throw CABRTException(EXCEP_PLUGIN, ssprintf("Plugin '%s' is not registered", pName)); } if (m_mapABRTPlugins[pName]->GetType() != DATABASE) { - throw CABRTException(EXCEP_PLUGIN, "CPluginManager::GetDatabase():" - "Plugin: '"+pName+"' is not database plugin."); + throw CABRTException(EXCEP_PLUGIN, ssprintf("Plugin '%s' is not a database plugin", pName)); } return (CDatabase*)(plugin->second); } -plugin_type_t CPluginManager::GetPluginType(const std::string& pName) +plugin_type_t CPluginManager::GetPluginType(const char *pName) { map_plugins_t::iterator plugin = m_mapPlugins.find(pName); if (plugin == m_mapPlugins.end()) { - throw CABRTException(EXCEP_PLUGIN, "CPluginManager::GetPluginType():" - "Plugin: '"+pName+"' is not registered."); + throw CABRTException(EXCEP_PLUGIN, ssprintf("Plugin '%s' is not registered", pName)); } return m_mapABRTPlugins[pName]->GetType(); } @@ -370,8 +357,8 @@ vector_map_string_t CPluginManager::GetPluginsInfo() return ret; } -void CPluginManager::SetPluginSettings(const std::string& pName, - const std::string& pUID, +void CPluginManager::SetPluginSettings(const char *pName, + const char *pUID, const map_plugin_settings_t& pSettings) { map_abrt_plugins_t::iterator abrt_plugin = m_mapABRTPlugins.find(pName); @@ -444,8 +431,8 @@ void CPluginManager::SetPluginSettings(const std::string& pName, #endif } -map_plugin_settings_t CPluginManager::GetPluginSettings(const std::string& pName, - const std::string& pUID) +map_plugin_settings_t CPluginManager::GetPluginSettings(const char *pName, + const char *pUID) { map_plugin_settings_t ret; map_abrt_plugins_t::iterator abrt_plugin = m_mapABRTPlugins.find(pName); diff --git a/src/Daemon/PluginManager.h b/src/Daemon/PluginManager.h index d4914db..0d3400b 100644 --- a/src/Daemon/PluginManager.h +++ b/src/Daemon/PluginManager.h @@ -74,68 +74,66 @@ class CPluginManager * A method, which loads particular plugin. * @param pName A plugin name. */ - void LoadPlugin(const std::string& pName); + void LoadPlugin(const char *pName); /** * A method, which unloads particular plugin. * @param pName A plugin name. */ - void UnLoadPlugin(const std::string& pName); + void UnLoadPlugin(const char *pName); /** * A method, which registers particular plugin. * @param pName A plugin name. */ - void RegisterPlugin(const std::string& pName); + void RegisterPlugin(const char *pName); /** * A method, which unregister particular plugin. * @param pName A plugin name. */ - void UnRegisterPlugin(const std::string& pName); + void UnRegisterPlugin(const char *pName); /** * A method, which registers particular plugin, * called via DBUS * @param pName A plugin name. * @param pDBUSSender DBUS user identification */ - void RegisterPluginDBUS(const std::string& pName, - const char * pDBUSSender); + void RegisterPluginDBUS(const char *pName, const char *pDBUSSender); /** * A method, which unregister particular plugin, * called via DBUS * @param pName A plugin name. * @param pDBUSSender DBUS user identification */ - void UnRegisterPluginDBUS(const std::string& pName, - const char * pDBUSSender); + void UnRegisterPluginDBUS(const char *pName, const char *pDBUSSender); /** * A method, which returns instance of particular analyzer plugin. * @param pName A plugin name. * @return An analyzer plugin. */ - CAnalyzer* GetAnalyzer(const std::string& pName); + CAnalyzer* GetAnalyzer(const char *pName); /** * A method, which returns instance of particular reporter plugin. * @param pName A plugin name. * @return A reporter plugin. */ - CReporter* GetReporter(const std::string& pName); + CReporter* GetReporter(const char *pName); /** * A method, which returns instance of particular action plugin. * @param pName A plugin name. * @return An action plugin. */ - CAction* GetAction(const std::string& pName); + CAction* GetAction(const char *pName); /** * A method, which returns instance of particular database plugin. * @param pName A plugin name. * @return A database plugin. */ - CDatabase* GetDatabase(const std::string& pName); + CDatabase* GetDatabase(const char *pName); /** * A method, which returns type of particular plugin. * @param pName A plugin name. * @return A plugin type. */ - plugin_type_t GetPluginType(const std::string& pName); + plugin_type_t GetPluginType(const char *pName); /** * A method, which gets all plugins info (event those plugins which are * disabled). It can be send via DBus to GUI and displayed to an user. @@ -150,8 +148,8 @@ class CPluginManager * @param pUID An uid of user. * @param pSettings A plugin's settings. */ - void SetPluginSettings(const std::string& pName, - const std::string& pUID, + void SetPluginSettings(const char *pName, + const char *pUID, const map_plugin_settings_t& pSettings); /** * A method, which returns plugin's settings according to user. @@ -159,8 +157,8 @@ class CPluginManager * @param pUID An uid of user. * @return Plugin's settings accorting to user. */ - map_plugin_settings_t GetPluginSettings(const std::string& pName, - const std::string& pUID); + map_plugin_settings_t GetPluginSettings(const char *pName, + const char *pUID); }; /** @@ -170,6 +168,6 @@ class CPluginManager * @param settings A readed plugin's settings. * @return if it success it returns true, otherwise it returns false. */ -bool LoadPluginSettings(const std::string& pPath, +bool LoadPluginSettings(const char *pPath, map_plugin_settings_t& pSettings); #endif /*PLUGINMANAGER_H_*/ diff --git a/src/Daemon/Settings.cpp b/src/Daemon/Settings.cpp index cefd35a..327851f 100644 --- a/src/Daemon/Settings.cpp +++ b/src/Daemon/Settings.cpp @@ -78,8 +78,11 @@ static set_string_t ParseList(const char* pList) return set; } +/* (What format do we parse here?) */ static vector_pair_string_string_t ParseListWithArgs(const char *pValue) { + VERB3 log(" ParseListWithArgs(%s)", pValue); + vector_pair_string_string_t pluginsWithArgs; unsigned int ii; std::string item; @@ -88,39 +91,55 @@ static vector_pair_string_string_t ParseListWithArgs(const char *pValue) bool is_arg = false; for (ii = 0; pValue[ii]; ii++) { - if (pValue[ii] == '\"') + if (is_quote && pValue[ii] == '\\' && pValue[ii+1]) + { + item += pValue[ii]; + ii++; + item += pValue[ii]; + continue; + } + if (pValue[ii] == '"') { is_quote = !is_quote; item += pValue[ii]; + continue; + } + if (is_quote) + { + item += pValue[ii]; + continue; } - else if (pValue[ii] == '(' && !is_quote) + if (pValue[ii] == '(') { action = item; item = ""; is_arg = true; + continue; } - else if (pValue[ii] == ')' && is_arg && !is_quote) + if (pValue[ii] == ')' && is_arg) { + VERB3 log(" adding (%s,%s)", action.c_str(), item.c_str()); pluginsWithArgs.push_back(make_pair(action, item)); item = ""; is_arg = false; action = ""; + continue; } - else if (pValue[ii] == ',' && !is_quote && !is_arg) + if (pValue[ii] == ',' && !is_arg) { if (item != "") { + VERB3 log(" adding (%s,%s)", item.c_str(), ""); pluginsWithArgs.push_back(make_pair(item, "")); item = ""; } + continue; } - else - { - item += pValue[ii]; - } + item += pValue[ii]; } if (item != "") { + VERB3 log(" adding (%s,%s)", item.c_str(), ""); pluginsWithArgs.push_back(make_pair(item, "")); } return pluginsWithArgs; @@ -228,6 +247,7 @@ static void ParseAnalyzerActionsAndReporters() set_string_t::iterator it_keys = keys.begin(); for (; it_keys != keys.end(); it_keys++) { + VERB2 log("AnalyzerActionsAndReporters['%s']=...", it_keys->c_str()); g_settings_mapAnalyzerActionsAndReporters[*it_keys] = actionsAndReporters; } } @@ -254,42 +274,50 @@ void LoadSettings() std::string value; for (ii = 0; ii < line.length(); ii++) { + if (is_quote && line[ii] == '\\' && ii+1 < line.length()) + { + value += line[ii]; + ii++; + value += line[ii]; + continue; + } if (isspace(line[ii]) && !is_quote) { continue; } - else if (line[ii] == '#' && !is_quote && key == "") + if (line[ii] == '#' && !is_quote && key == "") { break; } - else if (line[ii] == '[' && !is_quote) + if (line[ii] == '[' && !is_quote) { is_section = true; section = ""; + continue; } - else if (line[ii] == '\"') + if (line[ii] == '"') { is_quote = !is_quote; value += line[ii]; + continue; } - else if (is_section) + if (is_section) { if (line[ii] == ']') { break; } section += line[ii]; + continue; } - else if (line[ii] == '=' && !is_quote) + if (line[ii] == '=' && !is_quote) { is_key = false; key = value; value = ""; + continue; } - else - { - value += line[ii]; - } + value += line[ii]; } if (!is_key && !is_quote) { diff --git a/src/Daemon/abrt-debuginfo-install b/src/Daemon/abrt-debuginfo-install index b3d7292..1763903 100755 --- a/src/Daemon/abrt-debuginfo-install +++ b/src/Daemon/abrt-debuginfo-install @@ -9,7 +9,7 @@ # - debuginfo-install aborts if yum lock is busy # - pk-debuginfo-install was observed to hang # -# Usage: abrt-debuginfo-install CORE TEMPDIR [CACHEDIR] +# Usage: abrt-debuginfo-install CORE TEMPDIR [CACHEDIR[:DEBUGINFODIR1:DEBUGINFODIR2...]] # If CACHEDIR is specified, debuginfos should be installed there. # If not, debuginfos should be installed into TEMPDIR. # @@ -60,7 +60,8 @@ core=$1 tempdir=$2 -cachedir=$3 +debuginfodirs="${3//:/ }" +cachedir="${3%%:*}" debug=false exec 2>&1 @@ -81,25 +82,39 @@ count_words() { } print_missing_build_ids() { + local build_id + local build_id1 + local build_id2 + local file + local d for build_id in $build_ids; do build_id1=${build_id:0:2} build_id2=${build_id:2} file="usr/lib/debug/.build-id/$build_id1/$build_id2.debug" test -f "/$file" && continue - test -f "$cachedir/$file" && continue + for d in $debuginfodirs; do + test -f "$d/$file" && continue 2 + done echo -n "$build_id " done } print_missing_debuginfos() { + local build_id + local build_id1 + local build_id2 + local file + local d for build_id in $build_ids; do build_id1=${build_id:0:2} build_id2=${build_id:2} file="usr/lib/debug/.build-id/$build_id1/$build_id2.debug" - if test x"$cachedir" != x"" && test x"$cachedir" != x"/" ; then - test -f "$cachedir/$file" && continue - fi test -f "/$file" && continue + if test x"$cachedir" != x""; then + for d in $debuginfodirs; do + test -f "$d/$file" && continue 2 + done + fi echo -n "/$file " done } @@ -162,6 +177,14 @@ print_package_names() { } download_packages() { + local pkg + local err + local file + local build_id + local build_id1 + local build_id2 + local d + ## Download with one command (too silent): ## Redirecting, since progress bar stuff only messes up our output ##yumdownloader --enablerepo='*debuginfo*' --quiet $packages >yumdownloader.OUT 2>&1 @@ -181,13 +204,13 @@ download_packages() { : $((i++)) done - for f in *.rpm; do + for file in *.rpm; do # Happens if no .rpm's were downloaded (yumdownloader problem) # In this case, $f is the literal "*.rpm" string - test -f "$f" || exit 2 - echo "Unpacking: $f" - echo "Processing: $f" >>unpack.OUT - rpm2cpio <"$f" 2>>unpack.OUT | cpio -id >>unpack.OUT 2>&1 + test -f "$file" || exit 2 + echo "Unpacking: $file" + echo "Processing: $file" >>unpack.OUT + rpm2cpio <"$file" 2>>unpack.OUT | cpio -id >>unpack.OUT 2>&1 done # Copy debuginfo files to cachedir @@ -198,15 +221,19 @@ download_packages() { file="usr/lib/debug/.build-id/$build_id1/$build_id2.debug" + # Do not copy it if it can be found in any of $debuginfodirs test -f "/$file" && continue - test x"$cachedir" != x"/" && test -f "$cachedir/$file" && continue + if test x"$cachedir" != x""; then + for d in $debuginfodirs; do + test -f "$d/$file" && continue 2 + done + fi if test -f "$file"; then - # file is one of those we just installed. - # Cache it if cachedir is specified. + # File is one of those we just installed, cache it. mkdir -p "$cachedir/usr/lib/debug/.build-id/$build_id1" # Note: this does not preserve symlinks. This is intentional - $debug && echo Copying2 "$file" to "$cachedir/$file" >&2 + $debug && echo Copying "$file" to "$cachedir/$file" >&2 cp --remove-destination "$file" "$cachedir/$file" continue fi @@ -253,17 +280,12 @@ $debug && echo "build_ids:$build_ids" # which usually causes yum to download updated filelists, # which in turn takes several minutes and annoys users. iter=0 -while true; do - : $((iter++)) - test $iter -gt 2 && break - +while test $((++iter)) -le 2; do # Analyze $build_ids and check which debuginfos are present missing_debuginfo_files=`print_missing_debuginfos` $debug && echo "missing_debuginfo_files:$missing_debuginfo_files" - if test x"$missing_debuginfo_files" = x""; then - break - fi + test x"$missing_debuginfo_files" = x"" && break # Map $missing_debuginfo_files to package names. # yum is run here. @@ -272,9 +294,7 @@ while true; do # yum may return "" here if it found no packages (say, if coredump # is from a new, unreleased package fresh from koji). - if test x"$packages" = x""; then - continue - fi + test x"$packages" = x"" && continue num_packages=`count_words $packages` echo "Downloading $num_packages packages" diff --git a/src/Daemon/abrt.conf b/src/Daemon/abrt.conf index e9845e5..028f582 100644 --- a/src/Daemon/abrt.conf +++ b/src/Daemon/abrt.conf @@ -10,20 +10,21 @@ OpenGPGPublicKeys = /etc/pki/rpm-gpg/RPM-GPG-KEY-fedora # Blacklisted packages BlackList = nspluginwrapper # Enabled plugins. There has to be exactly one database plugin -EnabledPlugins = SQLite3, CCpp, Logger, Kerneloops, KerneloopsScanner, KerneloopsReporter, Bugzilla, Python +EnabledPlugins = SQLite3, CCpp, Logger, Kerneloops, KerneloopsScanner, KerneloopsReporter, Bugzilla, Python, RunApp # Database Database = SQLite3 # Max size for crash storage [MiB] MaxCrashReportsSize = 1000 # Vector of actions and reporters which are activated immediately after a crash occurs -# ActionsAndReporters = Mailx("[abrt] new crash was detected") +#ActionsAndReporters = Mailx("[abrt] new crash was detected") +ActionsAndReporters = RunApp("test x\"`cat component`\" = x\"xorg-x11-server-Xorg\" && cp /var/log/Xorg.0.log .") # Reporters association with analyzers [ AnalyzerActionsAndReporters ] Kerneloops = KerneloopsReporter CCpp = Bugzilla, Logger Python = Bugzilla, Logger -# CCpp : xorg-x11-apps = RunApp("date", "RunApp") +#CCpp:xorg-x11-apps = RunApp("date", "date.txt") # Repeated calling of Action plugins [ Cron ] diff --git a/src/Gui/CCMainWindow.py b/src/Gui/CCMainWindow.py index 31ebb41..3ada6f2 100644 --- a/src/Gui/CCMainWindow.py +++ b/src/Gui/CCMainWindow.py @@ -325,7 +325,7 @@ class MainWindow(): try: self.ccdaemon.getReport(report["_MWUUID"][2], force=1) except Exception, e: - # FIXME #3 dbus.exceptions.DBusException: org.freedesktop.DBus.Error.NoReply: Did not receive a reply + # FIXME #3 dbus.exceptions.DBusException: org.freedesktop.DBus.Error.NoReply: Did not receive a reply # do this async and wait for yum to end with debuginfoinstal if self.timer: gobject.source_remove(self.timer) @@ -352,7 +352,7 @@ class MainWindow(): try: self.ccdaemon.getReport(dump.getUUID()) except Exception, e: - # FIXME #3 dbus.exceptions.DBusException: org.freedesktop.DBus.Error.NoReply: Did not receive a reply + # FIXME #3 dbus.exceptions.DBusException: org.freedesktop.DBus.Error.NoReply: Did not receive a reply # do this async and wait for yum to end with debuginfoinstal if self.timer: gobject.source_remove(self.timer) diff --git a/src/Gui/CCReporterDialog.py b/src/Gui/CCReporterDialog.py index 61e6552..5db0696 100644 --- a/src/Gui/CCReporterDialog.py +++ b/src/Gui/CCReporterDialog.py @@ -43,7 +43,7 @@ class ReporterDialog(): self.tvComment = self.wTree.get_widget("tvComment") self.tvComment.connect("focus-in-event", self.on_comment_focus_cb) self.comment_changed = False - + # "how to reproduce" textview self.tevHowToReproduce = self.wTree.get_widget("tevHowToReproduce") self.how_to_changed = False @@ -79,7 +79,6 @@ class ReporterDialog(): self.tvReport.insert_column(column,0) # connect the signals self.tvReport.connect_after("size-allocate", self.on_window_resize) - self.wTree.get_widget("bSend").connect("clicked", self.on_send_clicked) # start with the warning hidden, so it's not visible when there is no rating self.wTree.get_widget("ebErrors").hide() self.hydrate() @@ -88,10 +87,10 @@ class ReporterDialog(): def on_response(self, dialog, response_id, daemon ): # thu button has been pressed (probably) if response_id == gtk.RESPONSE_APPLY: - if not self.check_settings(daemon): + if not (self.check_settings(daemon) and self.check_report()): dialog.stop_emission("response") self.wTree.get_widget("bSend").stop_emission("clicked") - + def on_send_toggled(self, cell, path, model): model[path][3] = not model[path][3] @@ -229,7 +228,7 @@ class ReporterDialog(): else: ebErrors.hide() bSend.set_sensitive(True) - + if self.report[item][TYPE] != 's': # item name 0| value 1| editable? 2| toggled? 3| visible?(attachment)4 if self.report[item][EDITABLE] == 'y': @@ -263,8 +262,11 @@ class ReporterDialog(): else: del self.report["How to reproduce"] - def on_send_clicked(self, button): - #def on_apply_clicked(self, button, treeview): + def check_report(self): + # FIXME: what to do if user press "Not to send BT and then press cancel" + # it uncheck the backtrace and let him to edit it, and then user might + # not noticed, that he is not sending the BT, so should we warn user about this + # or check the BT automatically? attributes = ["item", "content", "editable", "send", "attachment"] for row in self.reportListStore: rowe = dict(zip(attributes, row)) @@ -273,8 +275,10 @@ class ReporterDialog(): "Do you really want to send <b>%s</b>?\n" % rowe["item"]), self.window) if result == gtk.RESPONSE_NO: row[attributes.index("send")] = False + if result in (gtk.RESPONSE_CANCEL, gtk.RESPONSE_DELETE_EVENT): + return False self.dehydrate() - self.window.response(gtk.RESPONSE_APPLY) + return True def run(self): result = self.window.run() diff --git a/src/Gui/CC_gui_functions.py b/src/Gui/CC_gui_functions.py index a2ad70f..bfc1318 100644 --- a/src/Gui/CC_gui_functions.py +++ b/src/Gui/CC_gui_functions.py @@ -143,7 +143,7 @@ def gui_question_dialog ( message, parent_dialog=None, gtk.DIALOG_MODAL|gtk.DIALOG_DESTROY_WITH_PARENT, message_type, gtk.BUTTONS_YES_NO, message ) - + dialog.add_button("gtk-cancel", gtk.RESPONSE_CANCEL) dialog.set_markup(message) if parent_dialog: dialog.set_position (gtk.WIN_POS_CENTER_ON_PARENT) diff --git a/src/Gui/Makefile.am b/src/Gui/Makefile.am index 87d996c..7f61bbc 100644 --- a/src/Gui/Makefile.am +++ b/src/Gui/Makefile.am @@ -22,6 +22,9 @@ pixmap_DATA = abrt.png CLEANFILES := $(notdir $(wildcard *~)) $(notdir $(wildcard *\#)) $(notdir $(wildcard \.\#*)) $(notdir $(wildcard *.pyc)) +abrt.desktop: + intltool-merge -d ../../po abrt.desktop.in abrt.desktop + install-exec-hook: for b in $(bin_SCRIPTS); do \ sed 's:/usr/share:$(datadir):g' -i $(DESTDIR)$(bindir)/$$b || exit $$?; \ diff --git a/src/Gui/abrt.desktop b/src/Gui/abrt.desktop.in index 5498a0a..99d7f8f 100644 --- a/src/Gui/abrt.desktop +++ b/src/Gui/abrt.desktop.in @@ -1,7 +1,7 @@ [Desktop Entry] Encoding=UTF-8 -Name=Automatic Bug Reporting Tool -Comment=View and report application crashes +_Name=Automatic Bug Reporting Tool +_Comment=View and report application crashes Exec=abrt-gui Icon=abrt Terminal=false diff --git a/src/Gui/ccgui.glade b/src/Gui/ccgui.glade index 8916377..e9fd96f 100644 --- a/src/Gui/ccgui.glade +++ b/src/Gui/ccgui.glade @@ -105,6 +105,7 @@ Zdenek Prikryl <zprikryl@redhat.com></property> <widget class="GtkWindow" id="main_window3"> <property name="title" translatable="yes">Automatic Bug Reporting Tool</property> <property name="window_position">center</property> + <property name="icon">/usr/share/pixmaps/abrt.png</property> <child> <widget class="GtkVBox" id="vbox4"> <property name="visible">True</property> diff --git a/src/Gui/report.glade b/src/Gui/report.glade index ce21acb..428c4ec 100644 --- a/src/Gui/report.glade +++ b/src/Gui/report.glade @@ -197,7 +197,7 @@ <child> <widget class="GtkButton" id="bSend"> <property name="label" translatable="yes">Send</property> - <property name="response_id">-5</property> + <property name="response_id">-10</property> <property name="visible">True</property> <property name="can_focus">True</property> <property name="receives_default">True</property> diff --git a/src/Hooks/CCpp.cpp b/src/Hooks/CCpp.cpp index 3ab8f40..2b75381 100644 --- a/src/Hooks/CCpp.cpp +++ b/src/Hooks/CCpp.cpp @@ -65,7 +65,7 @@ static char* get_cmdline(pid_t pid) if (len > 0) { /* In Linux, there is always one trailing NUL byte, - * prevent it from being replaced by space below. + * prevent it from being replaced by space below. */ if (cmdline[len - 1] == '\0') len--; @@ -164,22 +164,20 @@ int main(int argc, char** argv) try { - char* executable; - char* cmdline; - executable = get_executable(pid); - cmdline = get_cmdline(pid); - if (executable == NULL || cmdline == NULL) + char* executable = get_executable(pid); + if (executable == NULL) { - error_msg_and_die("can not get proc info for pid %u", (int)pid); + error_msg_and_die("can't read /proc/%u/exe link", (int)pid); } if (strstr(executable, "/abrt")) { /* free(executable); - why bother? */ - /* free(cmdline); */ error_msg_and_die("pid %u is '%s', not dumping it to avoid abrt recursion", (int)pid, executable); } + char* cmdline = get_cmdline(pid); /* never NULL */ + char path[PATH_MAX]; snprintf(path, sizeof(path), "%s/ccpp-%ld-%u", dddir, (long)time(NULL), (int)pid); diff --git a/src/Hooks/abrt_exception_handler.py.in b/src/Hooks/abrt_exception_handler.py.in index 5514f1a..c7f7253 100644 --- a/src/Hooks/abrt_exception_handler.py.in +++ b/src/Hooks/abrt_exception_handler.py.in @@ -46,8 +46,6 @@ import sys import os import syslog import subprocess -# abrt lib for saving debugdumps -import ABRTUtils __DUMPHASH = {} # FIXME: do length limits on obj dumps. @@ -108,7 +106,7 @@ def write_dump(pid, tb_uuid, tb): executable = "Exception raised from python shell" if sys.argv[0]: executable = os.path.abspath(sys.argv[0]) - + command = ["abrt-pyhook-helper"] command.append("--pid=%s" % pid) command.append("--executable=%s" % executable) @@ -180,12 +178,12 @@ def handleMyException((etype, value, tb)): # ignore uncaught ctrl-c if etype == KeyboardInterrupt: return sys.__excepthook__(etype, value, tb) - + try: import os.path from hashlib import md5 import traceback - + syslog.syslog("abrt: Pyhook: Detected unhandled exception in %s " % sys.argv[0]) elist = traceback.format_exception (etype, value, tb) tblast = traceback.extract_tb(tb, limit=None) @@ -199,20 +197,20 @@ def handleMyException((etype, value, tb)): ll.extend(tblast[:3]) ll[0] = os.path.basename(tblast[0]) tblast = ll - + m = md5() ntext = "" for t in tblast: ntext += str(t) + ":" m.update(str(t)) - + tb_uuid = str(m.hexdigest())[:8] text += tb_uuid + " " + ntext - + text += extxt[0] text += "\n" text += "".join(elist) - + trace = tb while trace.tb_next: trace = trace.tb_next @@ -223,7 +221,7 @@ def handleMyException((etype, value, tb)): text += "%s: %s\n" % (key, val) except: pass - + # add coredump saving write_dump(os.getpid(), tb_uuid, text) except: #silently ignore any error in this hook, to not interfere with the python scripts diff --git a/src/Hooks/sitecustomize.py b/src/Hooks/sitecustomize.py index 32a3747..5787c03 100644 --- a/src/Hooks/sitecustomize.py +++ b/src/Hooks/sitecustomize.py @@ -22,13 +22,13 @@ try: line = config.readline().lower().replace(' ','').strip('\n').split('=') conf[line[0]] = line[1] except: - # Ignore silently everything, because we don't want to bother user + # Ignore silently everything, because we don't want to bother user # if this hook doesn't work. pass if conf.has_key("enabled"): # Prevent abrt exception handler from running when the abrtd daemon is - # not active. + # not active. # abrtd sets the value to "no" when deactivated and vice versa. if conf["enabled"] == "yes": try: |
