diff options
| author | Huang Peng <shawn.p.huang@gmail.com> | 2008-10-04 08:51:39 +0800 |
|---|---|---|
| committer | Huang Peng <shawn.p.huang@gmail.com> | 2008-10-04 08:51:39 +0800 |
| commit | 397ff9ca92a2eaf8469b757243813849804f9290 (patch) | |
| tree | b3fa22baa1a1a4ae1450d81120552b323d74ae1b | |
| parent | d362fe98b9b428e21324a32e922529c8f9ac3837 (diff) | |
| download | ibus-397ff9ca92a2eaf8469b757243813849804f9290.tar.gz ibus-397ff9ca92a2eaf8469b757243813849804f9290.tar.xz ibus-397ff9ca92a2eaf8469b757243813849804f9290.zip | |
WIP.
| -rw-r--r-- | daemon/_dbus.py | 41 | ||||
| -rw-r--r-- | daemon/config.py | 5 | ||||
| -rw-r--r-- | gconf/config.py | 2 | ||||
| -rw-r--r-- | ibus/bus.py | 11 | ||||
| -rw-r--r-- | ibus/common.py | 8 | ||||
| -rw-r--r-- | ibus/config.py | 2 |
6 files changed, 35 insertions, 34 deletions
diff --git a/daemon/_dbus.py b/daemon/_dbus.py index 9a738ed..1b007a0 100644 --- a/daemon/_dbus.py +++ b/daemon/_dbus.py @@ -47,19 +47,31 @@ class MatchRule: except: raise ibus.IBusException("Parse match rule failed\n%s" % rule) + def __cmp_bus_name(self, dbusobj, a, b): + if a == None or b == None: + return a == b + a_is_unique = a.startswith(":") + b_is_unique = b.startswith(":") + if a_is_unique == b_is_unique: + return a == b + else: + try: + if not a_is_unique: + a = dbusobj.get_name_owner(a).get_unique_name() + if not b_is_unique: + b = dbusobj.get_name_owner(b).get_unique_name() + return a == b + except: + return False + def match_message(self, dbusobj, message): - if self.__type == 'signale' and message.get_type() != 4: + if self.__type == 'signal' and message.get_type() != 4: return False + if self.__sender: - if self.__sender.startswith(":"): - sender = self.__sender - else: - try: - sender = dbusobj.get_name_owner(self.__sender).get_unique_name() - except: - return False - if sender != message.get_sender(): + if not self.__cmp_bus_name(dbusobj, self.__sender, message.get_sender()): return False + if self.__interface and self.__interface != message.get_interface(): return False @@ -70,14 +82,7 @@ class MatchRule: return False if self.__destination: - if self.__destination.startswith(":"): - dest = self.__destination - else: - try: - dest = dbusobj.get_name_owner(self.__destination).get_unique_name() - except: - return False - if dest != message.get_destination(): + if not self.__cmp_bus_name(dbusobj, self.__destination, message.get_destination()): return False args = message.get_args_list() for i, arg in self.__args: @@ -206,7 +211,7 @@ class DBusReal(ibus.Object): if message.get_type() != 4: # Is not signal raise ibus.IBusException("Message without destination") self.dispatch_dbus_signal(message) - return Trye + return True if not dest.startswith(":"): raise ibus.IBusException("Destination of message must be an unique name") diff --git a/daemon/config.py b/daemon/config.py index 319e533..7403276 100644 --- a/daemon/config.py +++ b/daemon/config.py @@ -67,10 +67,7 @@ class Config(ibus.Object): if message.is_signal(ibus.IBUS_CONFIG_IFACE, "ValueChanged"): args = message.get_args_list() self.emit("value-changed", args[0], args[1], args[2]) - else: - return False - ibusconn.stop_emission("dbus-signal") - return True + return False gobject.type_register(Config) diff --git a/gconf/config.py b/gconf/config.py index 8ec0d5f..72e329a 100644 --- a/gconf/config.py +++ b/gconf/config.py @@ -66,6 +66,8 @@ class Config(ibus.ConfigBase): super(Config, self).do_destroy() def __to_py_value(self, value): + if value == None: + return None if value.type == gconf.VALUE_STRING: return unicode(value.get_string(), "utf-8") if value.type == gconf.VALUE_INT: diff --git a/ibus/bus.py b/ibus/bus.py index b189257..6bb21c8 100644 --- a/ibus/bus.py +++ b/ibus/bus.py @@ -108,7 +108,7 @@ class Bus(ibus.Object): "config-value-changed" : ( gobject.SIGNAL_RUN_FIRST, gobject.TYPE_NONE, - (gobject.TYPE_STRING, gobject.TYPE_PYOBJECT) + (gobject.TYPE_STRING, gobject.TYPE_STRING, gobject.TYPE_PYOBJECT) ), "config-reloaded" : ( gobject.SIGNAL_RUN_FIRST, @@ -352,13 +352,10 @@ class Bus(ibus.Object): retval = dbus.lowlevel.HANDLER_RESULT_HANDLED # Config signals - elif message.is_signal(ibus.IBUS_IFACE, "ConfigValueChanged"): + elif message.is_signal(ibus.IBUS_CONFIG_IFACE, "ValueChanged"): args = message.get_args_list() - key, value = args[0:2] - self.emit("config-value-changed", key, value) - retval = dbus.lowlevel.HANDLER_RESULT_HANDLED - elif message.is_signal(ibus.IBUS_IFACE, "ConfigReloaded"): - self.emit("config-reloaded") + section, name, value = args[0:3] + self.emit("config-value-changed", section, name, value) retval = dbus.lowlevel.HANDLER_RESULT_HANDLED # DBUS Disconnected signal diff --git a/ibus/common.py b/ibus/common.py index 7180acb..f410ac2 100644 --- a/ibus/common.py +++ b/ibus/common.py @@ -70,10 +70,10 @@ IBUS_IFACE = "org.freedesktop.IBus" IBUS_PATH = "/org/freedesktop/IBus" IBUS_NAME = "org.freedesktop.IBus" -IBUS_CONFIG_IFACE = "org.freedesktop.IBus.Config" -IBUS_ENGINE_FACTORY_IFACE = "org.freedesktop.IBus.EngineFactory" -IBUS_ENGINE_IFACE = "org.freedesktop.IBus.Engine" -IBUS_PANEL_IFACE = "org.freedesktop.IBus.Panel" +IBUS_CONFIG_IFACE = "org.freedesktop.ibus.Config" +IBUS_ENGINE_FACTORY_IFACE = "org.freedesktop.ibus.EngineFactory" +IBUS_ENGINE_IFACE = "org.freedesktop.ibus.Engine" +IBUS_PANEL_IFACE = "org.freedesktop.ibus.Panel" def default_reply_handler( *args): pass diff --git a/ibus/config.py b/ibus/config.py index 7001e52..24b4edc 100644 --- a/ibus/config.py +++ b/ibus/config.py @@ -56,7 +56,7 @@ class ConfigProxy(interface.IConfig): return self.__config.get_value(section, name) def SetValue(self, section, name, value): - return self.__config.set_value(section, name, name) + return self.__config.set_value(section, name, value) def Destroy(self): self.__config.destroy() |
