Merge branch 'master' of git://dev.laptop.org/sugar

This commit is contained in:
Tomeu Vizoso 2007-03-04 10:53:14 +01:00
commit 559d21d4d2
4 changed files with 41 additions and 9 deletions

View File

@ -141,7 +141,7 @@ class Buddy(DBusGObject):
def GetIcon(self):
if not self.props.icon:
return ""
return self.props.icon
return dbus.ByteArray(self.props.icon)
@dbus.service.method(_BUDDY_INTERFACE,
in_signature="", out_signature="ao")
@ -158,9 +158,7 @@ class Buddy(DBusGObject):
props['nick'] = self.props.nick
props['owner'] = self.props.owner
props['key'] = self.props.key
color = self.props.color
if color:
props['color'] = color
props['color'] = self.props.color
return props
# methods

View File

@ -96,6 +96,8 @@ class ServerPlugin(gobject.GObject):
self._conn = self._init_connection()
self._reconnect_id = 0
def _get_account_info(self):
account_info = {}
@ -210,7 +212,12 @@ class ServerPlugin(gobject.GObject):
# vcards are changed
#self._conn[CONN_INTERFACE_ALIASING].connect_to_signal('AliasesChanged', self._alias_changed_cb)
self._set_self_buddy_info()
try:
self._set_self_buddy_info()
except RuntimeError, e:
print e
self.cleanup()
return
# Request presence for everyone on the channel
self._conn[CONN_INTERFACE_PRESENCE].GetPresence(subscribe_handles)
@ -220,7 +227,11 @@ class ServerPlugin(gobject.GObject):
props = {}
props['color'] = profile.get_color().to_string()
props['key'] = profile.get_pubkey()
self._conn[CONN_INTERFACE_BUDDY_INFO].SetProperties(props)
try:
self._conn[CONN_INTERFACE_BUDDY_INFO].SetProperties(props)
except dbus.DBusException, e:
if str(e).find("Server does not support PEP") >= 0:
raise RuntimeError("Server does not support PEP")
name = profile.get_nick_name()
self_handle = self._conn[CONN_INTERFACE].GetSelfHandle()
@ -249,12 +260,14 @@ class ServerPlugin(gobject.GObject):
elif state == CONNECTION_STATUS_DISCONNECTED:
print 'disconnected: %r' % reason
self.emit('status', state, int(reason))
self._conn = None
if reason == CONNECTION_STATUS_REASON_AUTHENTICATION_FAILED:
# FIXME: handle connection failure; retry later?
pass
return False
def start(self):
print "Trying to connect..."
# If the connection is already connected query initial contacts
conn_status = self._conn[CONN_INTERFACE].GetStatus()
if conn_status == CONNECTION_STATUS_CONNECTED:
@ -265,9 +278,26 @@ class ServerPlugin(gobject.GObject):
elif conn_status == CONNECTION_STATUS_CONNECTING:
pass
else:
self._conn[CONN_INTERFACE].Connect()
self._conn[CONN_INTERFACE].Connect(reply_handler=self._connect_reply_cb,
error_handler=self._connect_error_cb)
def _connect_reply_cb(self):
if self._reconnect_id > 0:
gobject.source_remove(self._reconnect_id)
def _reconnect(self):
self._reconnect_id = 0
self.start()
return False
def _connect_error_cb(self, exception):
print "Connect error: %s" % exception
if not self._reconnect_id:
self._reconnect_id = gobject.timeout_add(10000, self._reconnect)
def cleanup(self):
if not self._conn:
return
self._conn[CONN_INTERFACE].Disconnect()
def _contact_offline(self, handle):
@ -280,6 +310,10 @@ class ServerPlugin(gobject.GObject):
except dbus.DBusException, e:
if str(e).startswith("org.freedesktop.DBus.Error.NoReply"):
raise InvalidBuddyError("couldn't get properties")
except KeyError, e:
if str(e) == "'%s'" % CONN_INTERFACE_BUDDY_INFO:
raise InvalidBuddyError("server doesn't support BuddyInfo interface")
if not props.has_key('color'):
raise InvalidBuddyError("no color")
if not props.has_key('key'):

View File

@ -36,7 +36,7 @@ class HardwareManager(object):
self._service = dbus.Interface(proxy, _HARDWARE_MANAGER_INTERFACE)
def set_display_mode(self, mode):
self._service.set_mode(mode)
self._service.set_display_mode(mode)
def set_display_brightness(self, level):
self._service.set_display_brightness(level)

View File

@ -548,7 +548,7 @@ class NMClient(gobject.GObject):
return
self._devices[device].set_state(DEVICE_STATE_INACTIVE)
def device_activation_failed_sig_handler(self, device):
def device_activation_failed_sig_handler(self, device, ssid=None):
logging.debug('DeviceActivationFailed for %s' % (device))
if not self._devices.has_key(device):
logging.debug('DeviceActivationFailed, device %s does not exist' % (device))