diff options
author | Denys Vlasenko <vda.linux@googlemail.com> | 2010-01-15 16:04:27 +0100 |
---|---|---|
committer | Denys Vlasenko <vda.linux@googlemail.com> | 2010-01-15 16:04:27 +0100 |
commit | 494ed25390a3c1fa831ca594b77135eb5f18fba8 (patch) | |
tree | 1bd60ff9e7ebd75350d534254f57e53fcf93718d /src/Gui | |
parent | 03878806007c7f94914bc1fd09e48310e48f5b2f (diff) | |
download | abrt-494ed25390a3c1fa831ca594b77135eb5f18fba8.tar.gz abrt-494ed25390a3c1fa831ca594b77135eb5f18fba8.tar.xz abrt-494ed25390a3c1fa831ca594b77135eb5f18fba8.zip |
GUI: better code for plugin settings overriding; better logging; fixed "not reported" display bug
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
Diffstat (limited to 'src/Gui')
-rw-r--r-- | src/Gui/ABRTPlugin.py | 4 | ||||
-rw-r--r-- | src/Gui/CCMainWindow.py | 31 | ||||
-rw-r--r-- | src/Gui/ConfBackend.py | 64 |
3 files changed, 73 insertions, 26 deletions
diff --git a/src/Gui/ABRTPlugin.py b/src/Gui/ABRTPlugin.py index 5fb551d4..320c81ca 100644 --- a/src/Gui/ABRTPlugin.py +++ b/src/Gui/ABRTPlugin.py @@ -11,14 +11,14 @@ Email Description """ from abrt_utils import _, log, log1, log2 -from ConfBackend import ConfBackendGnomeKeyring, ConfBackendInitError +from ConfBackend import getCurrentConfBackend, ConfBackendInitError class PluginSettings(dict): def __init__(self): dict.__init__(self) self.client_side_conf = None try: - self.client_side_conf = ConfBackendGnomeKeyring() + self.client_side_conf = getCurrentConfBackend() except ConfBackendInitError, e: print e pass diff --git a/src/Gui/CCMainWindow.py b/src/Gui/CCMainWindow.py index 0bc00e5b..5ffc0277 100644 --- a/src/Gui/CCMainWindow.py +++ b/src/Gui/CCMainWindow.py @@ -18,7 +18,7 @@ try: except Exception, ex: rpm = None -from ConfBackend import ConfBackendGnomeKeyring, ConfBackendInitError +from ConfBackend import getCurrentConfBackend, ConfBackendInitError import CCDBusBackend from CC_gui_functions import * from CCDumpList import getDumpList, DumpList @@ -234,9 +234,11 @@ class MainWindow(): # it is not informative (no URL to the report) for message in dump.getMessage().split('\n'): if message: - if "http" in message[0:5] or "file:///"[0:8] in message: - message = "<a href=\"%s\">%s</a>" % (message, message) + #Doesn't work (far too easy to make it worse, not better): + #if "http" in message[0:5] or "file:///"[0:8] in message: + # message = "<a href=\"%s\">%s</a>" % (message, message) report_label += "%s\n" % message + log2("setting markup '%s'", report_label) self.wTree.get_widget("lReported").set_markup(report_label) else: self.wTree.get_widget("lReported").set_markup(_("<b>Not reported!</b>")) @@ -298,17 +300,20 @@ class MainWindow(): try: self.pBarWindow.show_all() self.timer = gobject.timeout_add(100, self.progress_update_cb) - reporters_settings = {} - # self.pluginlist = getPluginInfoList(self.ccdaemon, refresh=True) - # don't force refresh! - self.pluginlist = getPluginInfoList(self.ccdaemon) - for plugin in self.pluginlist.getReporterPlugins(): - reporters_settings[str(plugin)] = plugin.Settings - # TODO: this way, we don't need to talk to daemon in order to get - # all plugin settings: - #reporters_settings2 = ConfBackendGnomeKeyring().load_all() - #log1("reporters_settings2:%s", str(reporters_settings2)) + # Old way: it needs to talk to daemon + #reporters_settings = {} + ## self.pluginlist = getPluginInfoList(self.ccdaemon, refresh=True) + ## don't force refresh! + #self.pluginlist = getPluginInfoList(self.ccdaemon) + #for plugin in self.pluginlist.getReporterPlugins(): + # reporters_settings[str(plugin)] = plugin.Settings + reporters_settings = getCurrentConfBackend().load_all() + log2("Report(result,settings):") + log2(" result:%s", str(result)) + # Careful, this will print reporters_settings["Password"] too + log2(" settings:%s", str(reporters_settings)) self.ccdaemon.Report(result, reporters_settings) + log2("Report() returned") #self.hydrate() except Exception, e: gui_error_message(_("Reporting failed!\n%s" % e)) diff --git a/src/Gui/ConfBackend.py b/src/Gui/ConfBackend.py index fa1d663f..0d47760d 100644 --- a/src/Gui/ConfBackend.py +++ b/src/Gui/ConfBackend.py @@ -4,8 +4,6 @@ from abrt_utils import _, log, log1, log2 # http://library.gnome.org/devel/gnome-keyring/stable/ # Python bindings are in gnome-python2-desktop package -#FIXME: add some backend factory - try: import gnomekeyring as gkey except ImportError, e: @@ -49,13 +47,14 @@ class ConfBackend(object): # # Example: Key "abrt:Bugzilla" with bugzilla password as value, and with attributes: # +# Application: abrt # AbrtPluginInfo: Bugzilla # NoSSLVerify: yes # Login: user@host.com # BugzillaURL: https://host.with.bz.com/ # -# The attribute "AbrtPluginInfo" is special, it is used for retrieving -# the key via keyring API find_items_sync() function. +# Attributes "Application" and "AbrtPluginInfo" are special, they are used +# for efficient key retrieval via keyring API find_items_sync() function. g_default_key_ring = None @@ -66,7 +65,7 @@ class ConfBackendGnomeKeyring(ConfBackend): ConfBackend.__init__(self) if g_default_key_ring: return - if not gkey.is_available(): + if not gkey or not gkey.is_available(): raise ConfBackendInitError(_("Can't connect to Gnome Keyring daemon")) try: g_default_key_ring = gkey.get_default_keyring_sync() @@ -77,9 +76,8 @@ class ConfBackendGnomeKeyring(ConfBackend): def save(self, name, settings): settings_tmp = settings.copy() - settings_tmp["AbrtPluginInfo"] = name # old way settings_tmp["Application"] = "abrt" - settings_tmp["AbrtPluginName"] = name + settings_tmp["AbrtPluginInfo"] = name # delete all keyring items containg "AbrtPluginInfo":"<plugin_name>", # so we always have only 1 item per plugin @@ -144,6 +142,37 @@ class ConfBackendGnomeKeyring(ConfBackend): def load_all(self): retval = {} item_list = {} + + # UGLY compat cludge for users who has saved items without "Application" attr + # (abrt <= 1.0.3 was saving those) + item_ids = gkey.list_item_ids_sync(g_default_key_ring) + log2("all keyring item ids:%s", item_ids) + for item_id in item_ids: + info = gkey.item_get_info_sync(g_default_key_ring, item_id) + attrs = gkey.item_get_attributes_sync(g_default_key_ring, item_id) + log2("keyring item %s: attrs:%s", item_id, str(attrs)) + if "AbrtPluginInfo" in attrs: + if not "Application" in attrs: + log2("updating old-style keyring item") + attrs["Application"] = "abrt" + try: + gkey.item_set_attributes_sync(g_default_key_ring, item_id, attrs) + except: + log2("error updating old-style keyring item") + plugin_name = attrs["AbrtPluginInfo"] + # If plugin has a "Password" setting, we handle it specially: in keyring, + # it is stored as item.secret, not as one of attributes + if info.get_secret(): + attrs["Password"] = info.get_secret() + # avoiding sending useless duplicate info over dbus... + del attrs["AbrtPluginInfo"] + try: + del attrs["Application"] + except: + pass + retval[plugin_name] = attrs; + # end of UGLY compat cludge + try: log2("looking for keyring items with 'Application:abrt' attr") item_list = gkey.find_items_sync(gkey.ITEM_GENERIC_SECRET, { "Application": "abrt" }) @@ -165,15 +194,28 @@ class ConfBackendGnomeKeyring(ConfBackend): item.keyring, item.item_id, str(item.attributes) #, item.secret, info.get_display_name() ) attrs = item.attributes.copy() - if "AbrtPluginName" in attrs: - plugin_name = attrs["AbrtPluginName"] + if "AbrtPluginInfo" in attrs: + plugin_name = attrs["AbrtPluginInfo"] # If plugin has a "Password" setting, we handle it specially: in keyring, # it is stored as item.secret, not as one of attributes if item.secret: attrs["Password"] = item.secret # avoiding sending useless duplicate info over dbus... - del attrs["Application"] del attrs["AbrtPluginInfo"] - del attrs["AbrtPluginName"] + try: + del attrs["Application"] + except: + pass retval[plugin_name] = attrs; return retval + + +# Rudimentary backend factory + +currentConfBackend = None + +def getCurrentConfBackend(): + global currentConfBackend + if not currentConfBackend: + currentConfBackend = ConfBackendGnomeKeyring() + return currentConfBackend |