Mercurial > libervia-backend
comparison frontends/src/bridge/DBus.py @ 587:952322b1d490
Remove trailing whitespaces.
author | Emmanuel Gil Peyrot <linkmauve@linkmauve.fr> |
---|---|
date | Fri, 18 Jan 2013 17:55:34 +0100 |
parents | ca13633d3b6b |
children | 1f160467f5de |
comparison
equal
deleted
inserted
replaced
586:6a718ede8be1 | 587:952322b1d490 |
---|---|
71 # We first check if we have an async call. We detect this in two ways: | 71 # We first check if we have an async call. We detect this in two ways: |
72 # - if we have the 'callback' and 'errback' keyword arguments | 72 # - if we have the 'callback' and 'errback' keyword arguments |
73 # - or if the last two arguments are callable | 73 # - or if the last two arguments are callable |
74 | 74 |
75 async = False | 75 async = False |
76 | 76 |
77 if kwargs: | 77 if kwargs: |
78 if 'callback' in kwargs and 'errback' in kwargs: | 78 if 'callback' in kwargs and 'errback' in kwargs: |
79 async = True | 79 async = True |
80 _callback = kwargs.pop('callback') | 80 _callback = kwargs.pop('callback') |
81 _errback = kwargs.pop('errback') | 81 _errback = kwargs.pop('errback') |
82 elif len(args)>=2 and callable(args[-1]) and callable(args[-2]): | 82 elif len(args)>=2 and callable(args[-1]) and callable(args[-2]): |
83 async = True | 83 async = True |
84 args = list(args) | 84 args = list(args) |
85 _errback = args.pop() | 85 _errback = args.pop() |
86 _callback = args.pop() | 86 _callback = args.pop() |
87 | 87 |
88 method = getattr(self.db_plugin_iface, name) | 88 method = getattr(self.db_plugin_iface, name) |
89 | 89 |
90 if async: | 90 if async: |
91 kwargs['reply_handler'] = _callback | 91 kwargs['reply_handler'] = _callback |
92 kwargs['error_handler'] = lambda err:_errback(err._dbus_error_name[len(const_ERROR_PREFIX)+1:]) | 92 kwargs['error_handler'] = lambda err:_errback(err._dbus_error_name[len(const_ERROR_PREFIX)+1:]) |
93 | 93 |
94 return method(*args, **kwargs) | 94 return method(*args, **kwargs) |
95 | 95 |
96 return getPluginMethod | 96 return getPluginMethod |
97 | 97 |
98 def addContact(self, entity_jid, profile_key="@DEFAULT@"): | 98 def addContact(self, entity_jid, profile_key="@DEFAULT@"): |
99 return self.db_core_iface.addContact(entity_jid, profile_key) | 99 return self.db_core_iface.addContact(entity_jid, profile_key) |
100 | 100 |
212 def updateContact(self, entity_jid, name, groups, profile_key="@DEFAULT@"): | 212 def updateContact(self, entity_jid, name, groups, profile_key="@DEFAULT@"): |
213 return self.db_core_iface.updateContact(entity_jid, name, groups, profile_key) | 213 return self.db_core_iface.updateContact(entity_jid, name, groups, profile_key) |
214 | 214 |
215 | 215 |
216 #methods from plugins | 216 #methods from plugins |
217 | 217 |
218 def joinMUC(self, room_jid, nick, options, profile_key): | 218 def joinMUC(self, room_jid, nick, options, profile_key): |
219 if options == None: | 219 if options == None: |
220 options = [('', '')] #XXX: we have to do this awful hack because python dbus need to guess the signature | 220 options = [('', '')] #XXX: we have to do this awful hack because python dbus need to guess the signature |
221 return self.db_plugin_iface.joinMUC(room_jid, nick, options, profile_key) | 221 return self.db_plugin_iface.joinMUC(room_jid, nick, options, profile_key) |
222 | 222 |
223 def gatewayRegister(self, action, target, data, profile_key): | 223 def gatewayRegister(self, action, target, data, profile_key): |
224 if data == None: | 224 if data == None: |
225 data = [('', '')] #XXX: we have to do this awful hack because python dbus need to guess the signature | 225 data = [('', '')] #XXX: we have to do this awful hack because python dbus need to guess the signature |
226 return self.db_plugin_iface.gatewayRegister(action, target, data, profile_key) | 226 return self.db_plugin_iface.gatewayRegister(action, target, data, profile_key) |