[d-feet] introspection: fix showing unique-name for services with a well-known name
- From: Thomas Bechtold <toabctl src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [d-feet] introspection: fix showing unique-name for services with a well-known name
- Date: Thu, 17 Oct 2013 18:51:19 +0000 (UTC)
commit 15a07d886999a949df93981a778bbb218e8e6260
Author: Aleksander Morgado <aleksander lanedo com>
Date: Thu Oct 10 19:12:48 2013 +0200
introspection: fix showing unique-name for services with a well-known name
https://bugzilla.gnome.org/show_bug.cgi?id=709835
src/dfeet/bus_watch.py | 50 +++++++++++++++++++++++++++++++++----------
src/dfeet/introspection.py | 12 ++++------
src/tests/tests.py | 2 +-
3 files changed, 44 insertions(+), 20 deletions(-)
---
diff --git a/src/dfeet/bus_watch.py b/src/dfeet/bus_watch.py
index cadad74..bcee717 100644
--- a/src/dfeet/bus_watch.py
+++ b/src/dfeet/bus_watch.py
@@ -10,9 +10,10 @@ from dfeet.wnck_utils import IconTable
class BusNameBox(Gtk.VBox):
"""class to represent a BusName (eg 'org.freedesktop.NetworkManager')"""
- def __init__(self, bus_name):
+ def __init__(self, bus_name, unique_name):
super(BusNameBox, self).__init__(spacing=5, expand=True)
self.__bus_name = bus_name
+ self.__unique_name = unique_name
self.__process_id = 0
self.__command_line = ''
self.__activatable = False
@@ -82,6 +83,10 @@ class BusNameBox(Gtk.VBox):
return self.__bus_name
@property
+ def unique_name(self):
+ return self.__unique_name
+
+ @property
def activatable(self):
return self.__activatable
@@ -193,8 +198,11 @@ class BusWatch(object):
row_childs = listbox_row.get_children()
bus_name_box = row_childs[0]
#add the introspection info to the left side
- self.__addr_info = AddressInfo(
- self.__data_dir, self.__bus_address, bus_name_box.bus_name, connection_is_bus=True)
+ self.__addr_info = AddressInfo(self.__data_dir,
+ self.__bus_address,
+ bus_name_box.bus_name,
+ bus_name_box.unique_name,
+ connection_is_bus=True)
self.box_bus.pack_end(self.__addr_info.introspect_box, True, True, 0)
self.box_bus.show_all()
@@ -208,13 +216,13 @@ class BusWatch(object):
if bus_name[0] == ':':
if not old_owner:
- bus_name_box = BusNameBox(bus_name)
+ bus_name_box = BusNameBox(bus_name, new_owner)
self.__listbox_add_bus_name(bus_name_box)
else:
self.__listbox_remove_bus_name(bus_name)
else:
if new_owner:
- bus_name_box = BusNameBox(bus_name)
+ bus_name_box = BusNameBox(bus_name, new_owner)
self.__listbox_add_bus_name(bus_name_box)
if old_owner:
self.__listbox_remove_bus_name(bus_name)
@@ -234,7 +242,7 @@ class BusWatch(object):
self.__listbox.remove(obj)
#if bus is activatable, add the bus name again
if bus_name in self.__activatable_names:
- bnb = BusNameBox(bus_name)
+ bnb = BusNameBox(bus_name, '')
self.__listbox_add_bus_name(bnb)
else:
print("can not remove busname '{0}'. busname not found".format(bus_name))
@@ -263,10 +271,30 @@ class BusWatch(object):
else:
bus_name_box.activatable = False
- def __list_names_handler(self, obj, names, userdata):
+ def __add_name(self, name, unique_name):
+ bus_name_box = BusNameBox(name, unique_name)
+ self.__listbox_add_bus_name(bus_name_box)
+
+ def __get_name_owner_cb(self, obj, unique_name, name):
+ self.__add_name(name, unique_name)
+
+ def __get_name_owner_error_cb(self, obj, error, name):
+ # no name owner, empty unique name
+ self.__add_name(name, '')
+
+ def __add_names(self, names):
for n in names:
- bus_name_box = BusNameBox(n)
- self.__listbox_add_bus_name(bus_name_box)
+ #unique names are added right away
+ if n[0] == ':':
+ self.__add_name(n, n)
+ else:
+ self.bus_proxy.GetNameOwner('(s)', n,
+ result_handler=self.__get_name_owner_cb,
+ error_handler=self.__get_name_owner_error_cb,
+ user_data=n)
+
+ def __list_names_handler(self, obj, names, userdata):
+ self.__add_names(names)
def __list_names_error_handler(self, obj, error, userdata):
print("error getting bus names: %s" % str(error))
@@ -275,9 +303,7 @@ class BusWatch(object):
#remember the activatable bus names
self.__activatable_names = act_names
#add all activatable bus names to the list
- for name in act_names:
- bnb = BusNameBox(name)
- self.__listbox_add_bus_name(bnb)
+ self.__add_names(act_names)
def __list_act_names_error_handler(self, obj, error, userdata):
self.__activatable_names = []
diff --git a/src/dfeet/introspection.py b/src/dfeet/introspection.py
index 43c62ec..1000b8f 100644
--- a/src/dfeet/introspection.py
+++ b/src/dfeet/introspection.py
@@ -25,7 +25,7 @@ class AddressInfo():
except:
pass
- def __init__(self, data_dir, address, name, connection_is_bus=True):
+ def __init__(self, data_dir, address, name, unique_name, connection_is_bus=True):
self.data_dir = data_dir
signal_dict = {
'treeview_row_activated_cb': self.__treeview_row_activated_cb,
@@ -34,7 +34,8 @@ class AddressInfo():
}
self.address = address # can be Gio.BusType.SYSTEM or Gio.BusType.SYSTEM or other address
- self.name = name # the bus name or None
+ self.name = name # the well-known name or None
+ self.unique_name = unique_name # the unique name or None
self.connection_is_bus = connection_is_bus # is it a bus or a p2p connection?
#setup UI
@@ -241,10 +242,7 @@ class AddressInfo():
self.__spinner.set_visible(False)
#update name, unique name, ...
self.__label_name.set_text(self.name)
- try:
- self.__label_unique_name.set_text(self.connection.get_unique_name())
- except:
- pass
+ self.__label_unique_name.set_text(self.unique_name)
self.introspect_box.show_all()
@@ -278,7 +276,7 @@ if __name__ == "__main__":
addr = p.addr
name = p.name
- ai = AddressInfo(addr, name, not p.p2p)
+ ai = AddressInfo(addr, name, None, not p.p2p)
win = Gtk.Window()
win.connect("delete-event", Gtk.main_quit)
win.set_default_size(1024, 768)
diff --git a/src/tests/tests.py b/src/tests/tests.py
index 0a6de47..65f243d 100755
--- a/src/tests/tests.py
+++ b/src/tests/tests.py
@@ -93,7 +93,7 @@ class AddressInfoTest(unittest.TestCase):
def test_bus(self):
"""introspect a name on the system bus"""
- ai = AddressInfo(DATA_DIR, self.bus.get_bus_address(), "org.freedesktop.DBus")
+ ai = AddressInfo(DATA_DIR, self.bus.get_bus_address(), None, "org.freedesktop.DBus")
@unittest.skip("TODO:peer to peer test not implemented")
def test_peer_to_peer(self):
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]