summaryrefslogtreecommitdiffstats
path: root/src/Gui
diff options
context:
space:
mode:
authorDenys Vlasenko <vda.linux@googlemail.com>2010-01-14 23:06:00 +0100
committerDenys Vlasenko <vda.linux@googlemail.com>2010-01-14 23:06:00 +0100
commit1ff447ffaaa02cd0c46607f817c13328114145bc (patch)
treed18d75bcc77a2004f9a1b31062380e78cae647db /src/Gui
parentd3eb4278cc246e23b24c9a99eb0867ff6cbe0c0b (diff)
downloadabrt-1ff447ffaaa02cd0c46607f817c13328114145bc.tar.gz
abrt-1ff447ffaaa02cd0c46607f817c13328114145bc.tar.xz
abrt-1ff447ffaaa02cd0c46607f817c13328114145bc.zip
add code to make GUI -> daemon settings passing less weird. not enabled yet
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
Diffstat (limited to 'src/Gui')
-rw-r--r--src/Gui/CCDBusBackend.py2
-rw-r--r--src/Gui/CCMainWindow.py8
-rw-r--r--src/Gui/ConfBackend.py100
3 files changed, 87 insertions, 23 deletions
diff --git a/src/Gui/CCDBusBackend.py b/src/Gui/CCDBusBackend.py
index 1ec2d8a1..f4ef1040 100644
--- a/src/Gui/CCDBusBackend.py
+++ b/src/Gui/CCDBusBackend.py
@@ -40,7 +40,7 @@ class DBusManager(gobject.GObject):
if session:
try:
- app_proxy = session.get_object(APP_NAME,APP_PATH)
+ app_proxy = session.get_object(APP_NAME, APP_PATH)
app_iface = dbus.Interface(app_proxy, dbus_interface=APP_IFACE)
# app is running, so make it show it self
app_iface.show()
diff --git a/src/Gui/CCMainWindow.py b/src/Gui/CCMainWindow.py
index 432fd43b..0bc00e5b 100644
--- a/src/Gui/CCMainWindow.py
+++ b/src/Gui/CCMainWindow.py
@@ -18,6 +18,7 @@ try:
except Exception, ex:
rpm = None
+from ConfBackend import ConfBackendGnomeKeyring, ConfBackendInitError
import CCDBusBackend
from CC_gui_functions import *
from CCDumpList import getDumpList, DumpList
@@ -42,11 +43,10 @@ class MainWindow():
sys.exit()
except Exception, e:
# show error message if connection fails
- # FIXME add an option to start the daemon
gui_error_message("%s" % e)
sys.exit()
#Set the Glade file
- self.gladefile = "%s%sccgui.glade" % (sys.path[0],"/")
+ self.gladefile = "%s/ccgui.glade" % sys.path[0]
self.wTree = gtk.glade.XML(self.gladefile)
#Get the Main Window, and connect the "destroy" event
@@ -304,6 +304,10 @@ class MainWindow():
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))
self.ccdaemon.Report(result, reporters_settings)
#self.hydrate()
except Exception, e:
diff --git a/src/Gui/ConfBackend.py b/src/Gui/ConfBackend.py
index 08ceed56..fa1d663f 100644
--- a/src/Gui/ConfBackend.py
+++ b/src/Gui/ConfBackend.py
@@ -2,6 +2,7 @@ from abrt_utils import _, log, log1, log2
# Doc on Gnome keyring API:
# http://library.gnome.org/devel/gnome-keyring/stable/
+# Python bindings are in gnome-python2-desktop package
#FIXME: add some backend factory
@@ -56,14 +57,19 @@ class ConfBackend(object):
# The attribute "AbrtPluginInfo" is special, it is used for retrieving
# the key via keyring API find_items_sync() function.
+g_default_key_ring = None
class ConfBackendGnomeKeyring(ConfBackend):
def __init__(self):
+ global g_default_key_ring
+
ConfBackend.__init__(self)
+ if g_default_key_ring:
+ return
if not gkey.is_available():
raise ConfBackendInitError(_("Can't connect to Gnome Keyring daemon"))
try:
- self.default_key_ring = gkey.get_default_keyring_sync()
+ g_default_key_ring = gkey.get_default_keyring_sync()
except:
# could happen if keyring daemon is running, but we run gui under
# user who is not the owner of the running session - using su
@@ -71,31 +77,36 @@ class ConfBackendGnomeKeyring(ConfBackend):
def save(self, name, settings):
settings_tmp = settings.copy()
- settings_tmp["AbrtPluginInfo"] = name
- password = ""
+ settings_tmp["AbrtPluginInfo"] = name # old way
+ settings_tmp["Application"] = "abrt"
+ settings_tmp["AbrtPluginName"] = name
- item_list = []
+ # delete all keyring items containg "AbrtPluginInfo":"<plugin_name>",
+ # so we always have only 1 item per plugin
try:
- item_list = gkey.find_items_sync(gkey.ITEM_GENERIC_SECRET, {"AbrtPluginInfo":str(name)})
+ item_list = gkey.find_items_sync(gkey.ITEM_GENERIC_SECRET, { "AbrtPluginInfo": str(name) })
+ for item in item_list:
+ log2("found old keyring item: ring:'%s' item_id:%s attrs:%s", item.keyring, item.item_id, str(item.attributes))
+ log2("deleting it from keyring '%s'", g_default_key_ring)
+ gkey.item_delete_sync(g_default_key_ring, item.item_id)
except gkey.NoMatchError:
# nothing found
pass
except gkey.DeniedError:
raise ConfBackendSaveError(_("Access to gnome-keyring has been denied, plugins settings won't be saved."))
-
- # delete all items containg "AbrtPluginInfo":<plugin_name>, so we always have only 1 item per plugin
- for item in item_list:
- gkey.item_delete_sync(self.default_key_ring, item.item_id)
-
+ # if plugin has a "Password" setting, we handle it specially: in keyring,
+ # it is stored as item.secret, not as one of attributes
+ password = ""
if "Password" in settings_tmp:
password = settings_tmp["Password"]
del settings_tmp["Password"]
+ # store new settings for this plugin as one keyring item
try:
- gkey.item_create_sync(self.default_key_ring,
+ gkey.item_create_sync(g_default_key_ring,
gkey.ITEM_GENERIC_SECRET,
- "abrt:%s" % name,
- settings_tmp,
- password,
+ "abrt:%s" % name, # display_name
+ settings_tmp, # attrs
+ password, # secret
True)
except gkey.DeniedError, e:
raise ConfBackendSaveError(_("Access to gnome-keyring has been denied, plugins settings won't be saved."))
@@ -103,17 +114,66 @@ class ConfBackendGnomeKeyring(ConfBackend):
def load(self, name):
item_list = None
try:
+ log2("looking for keyring items with 'AbrtPluginInfo:%s' attr", str(name))
item_list = gkey.find_items_sync(gkey.ITEM_GENERIC_SECRET, {"AbrtPluginInfo":str(name)})
+ for item in item_list:
+ # gnome keyring is weeeeird. why display_name, type, mtime, ctime
+ # aren't available in find_items_sync() results? why we need to
+ # get them via additional call, item_get_info_sync()?
+ # internally, item has GNOME_KEYRING_TYPE_FOUND type,
+ # and info has GNOME_KEYRING_TYPE_ITEM_INFO type.
+ # why not use the same type for both?
+ #
+ # and worst of all, this information took four hours of googling...
+ #
+ #info = gkey.item_get_info_sync(item.keyring, item.item_id)
+ log2("found keyring item: ring:'%s' item_id:%s attrs:%s", # "secret:'%s' display_name:'%s'"
+ item.keyring, item.item_id, str(item.attributes) #, item.secret, info.get_display_name()
+ )
except gkey.NoMatchError:
# nothing found
pass
-
if item_list:
retval = item_list[0].attributes.copy()
retval["Password"] = item_list[0].secret
return retval
- else:
- return {}
- #for i in item_list:
- # for attr in i.attributes:
- # print attr, i.attributes[attr]
+ return {}
+
+ # This routine loads setting for all plugins. It doesn't need plugin name.
+ # Thus we can avoid talking to abrtd just in order to get plugin names.
+ def load_all(self):
+ retval = {}
+ item_list = {}
+ try:
+ log2("looking for keyring items with 'Application:abrt' attr")
+ item_list = gkey.find_items_sync(gkey.ITEM_GENERIC_SECRET, { "Application": "abrt" })
+ except gkey.NoMatchError:
+ # nothing found
+ pass
+ for item in item_list:
+ # gnome keyring is weeeeird. why display_name, type, mtime, ctime
+ # aren't available in find_items_sync() results? why we need to
+ # get them via additional call, item_get_info_sync()?
+ # internally, item has GNOME_KEYRING_TYPE_FOUND type,
+ # and info has GNOME_KEYRING_TYPE_ITEM_INFO type.
+ # why not use the same type for both?
+ #
+ # and worst of all, this information took four hours of googling...
+ #
+ #info = gkey.item_get_info_sync(item.keyring, item.item_id)
+ log2("found keyring item: ring:%s item_id:%s attrs:%s", # "secret:%s display_name:'%s'"
+ 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 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"]
+ retval[plugin_name] = attrs;
+ return retval