kill more version checking for dbus

This commit is contained in:
Nikos Kouremenos 2006-09-25 12:38:42 +00:00
parent ba10724e36
commit d356ddd92d
1 changed files with 5 additions and 17 deletions

View File

@ -51,13 +51,10 @@ def send_error(error_message):
try: try:
import dbus import dbus
except:
raise exceptions.DbusNotSupported
_version = getattr(dbus, 'version', (0, 20, 0))
if _version[1] >= 41:
import dbus.service import dbus.service
import dbus.glib import dbus.glib
except:
raise exceptions.DbusNotSupported
OBJ_PATH = '/org/gajim/dbus/RemoteObject' OBJ_PATH = '/org/gajim/dbus/RemoteObject'
INTERFACE = 'org.gajim.dbus.RemoteInterface' INTERFACE = 'org.gajim.dbus.RemoteInterface'
@ -320,14 +317,8 @@ class GajimRemote:
except: except:
raise exceptions.SessionBusNotPresent raise exceptions.SessionBusNotPresent
if _version[1] >= 30: obj = self.sbus.get_object(SERVICE, OBJ_PATH)
obj = self.sbus.get_object(SERVICE, OBJ_PATH) interface = dbus.Interface(obj, INTERFACE)
interface = dbus.Interface(obj, INTERFACE)
elif _version[1] < 30:
self.service = self.sbus.get_service(SERVICE)
interface = self.service.get_object(OBJ_PATH, INTERFACE)
else:
send_error(_('Unknown D-Bus version: %s') % _version[1])
# get the function asked # get the function asked
self.method = interface.__getattr__(self.command) self.method = interface.__getattr__(self.command)
@ -447,10 +438,7 @@ class GajimRemote:
''' calls self.method with arguments from sys.argv[2:] ''' ''' calls self.method with arguments from sys.argv[2:] '''
args = sys.argv[2:] args = sys.argv[2:]
args = [i.decode(PREFERRED_ENCODING) for i in sys.argv[2:]] args = [i.decode(PREFERRED_ENCODING) for i in sys.argv[2:]]
if _version[1] >= 41: args = [dbus.String(i) for i in args]
args = [dbus.String(i) for i in args]
else:
args = [i.encode('UTF-8') for i in sys.argv[2:]]
try: try:
res = self.method(*args) res = self.method(*args)
return res return res