Merge branch 'master' of git://dev.laptop.org/sugar
This commit is contained in:
commit
559d21d4d2
@ -141,7 +141,7 @@ class Buddy(DBusGObject):
|
|||||||
def GetIcon(self):
|
def GetIcon(self):
|
||||||
if not self.props.icon:
|
if not self.props.icon:
|
||||||
return ""
|
return ""
|
||||||
return self.props.icon
|
return dbus.ByteArray(self.props.icon)
|
||||||
|
|
||||||
@dbus.service.method(_BUDDY_INTERFACE,
|
@dbus.service.method(_BUDDY_INTERFACE,
|
||||||
in_signature="", out_signature="ao")
|
in_signature="", out_signature="ao")
|
||||||
@ -158,9 +158,7 @@ class Buddy(DBusGObject):
|
|||||||
props['nick'] = self.props.nick
|
props['nick'] = self.props.nick
|
||||||
props['owner'] = self.props.owner
|
props['owner'] = self.props.owner
|
||||||
props['key'] = self.props.key
|
props['key'] = self.props.key
|
||||||
color = self.props.color
|
props['color'] = self.props.color
|
||||||
if color:
|
|
||||||
props['color'] = color
|
|
||||||
return props
|
return props
|
||||||
|
|
||||||
# methods
|
# methods
|
||||||
|
@ -96,6 +96,8 @@ class ServerPlugin(gobject.GObject):
|
|||||||
|
|
||||||
self._conn = self._init_connection()
|
self._conn = self._init_connection()
|
||||||
|
|
||||||
|
self._reconnect_id = 0
|
||||||
|
|
||||||
def _get_account_info(self):
|
def _get_account_info(self):
|
||||||
account_info = {}
|
account_info = {}
|
||||||
|
|
||||||
@ -210,7 +212,12 @@ class ServerPlugin(gobject.GObject):
|
|||||||
# vcards are changed
|
# vcards are changed
|
||||||
#self._conn[CONN_INTERFACE_ALIASING].connect_to_signal('AliasesChanged', self._alias_changed_cb)
|
#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
|
# Request presence for everyone on the channel
|
||||||
self._conn[CONN_INTERFACE_PRESENCE].GetPresence(subscribe_handles)
|
self._conn[CONN_INTERFACE_PRESENCE].GetPresence(subscribe_handles)
|
||||||
@ -220,7 +227,11 @@ class ServerPlugin(gobject.GObject):
|
|||||||
props = {}
|
props = {}
|
||||||
props['color'] = profile.get_color().to_string()
|
props['color'] = profile.get_color().to_string()
|
||||||
props['key'] = profile.get_pubkey()
|
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()
|
name = profile.get_nick_name()
|
||||||
self_handle = self._conn[CONN_INTERFACE].GetSelfHandle()
|
self_handle = self._conn[CONN_INTERFACE].GetSelfHandle()
|
||||||
@ -249,12 +260,14 @@ class ServerPlugin(gobject.GObject):
|
|||||||
elif state == CONNECTION_STATUS_DISCONNECTED:
|
elif state == CONNECTION_STATUS_DISCONNECTED:
|
||||||
print 'disconnected: %r' % reason
|
print 'disconnected: %r' % reason
|
||||||
self.emit('status', state, int(reason))
|
self.emit('status', state, int(reason))
|
||||||
|
self._conn = None
|
||||||
if reason == CONNECTION_STATUS_REASON_AUTHENTICATION_FAILED:
|
if reason == CONNECTION_STATUS_REASON_AUTHENTICATION_FAILED:
|
||||||
# FIXME: handle connection failure; retry later?
|
# FIXME: handle connection failure; retry later?
|
||||||
pass
|
pass
|
||||||
return False
|
return False
|
||||||
|
|
||||||
def start(self):
|
def start(self):
|
||||||
|
print "Trying to connect..."
|
||||||
# If the connection is already connected query initial contacts
|
# If the connection is already connected query initial contacts
|
||||||
conn_status = self._conn[CONN_INTERFACE].GetStatus()
|
conn_status = self._conn[CONN_INTERFACE].GetStatus()
|
||||||
if conn_status == CONNECTION_STATUS_CONNECTED:
|
if conn_status == CONNECTION_STATUS_CONNECTED:
|
||||||
@ -265,9 +278,26 @@ class ServerPlugin(gobject.GObject):
|
|||||||
elif conn_status == CONNECTION_STATUS_CONNECTING:
|
elif conn_status == CONNECTION_STATUS_CONNECTING:
|
||||||
pass
|
pass
|
||||||
else:
|
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):
|
def cleanup(self):
|
||||||
|
if not self._conn:
|
||||||
|
return
|
||||||
self._conn[CONN_INTERFACE].Disconnect()
|
self._conn[CONN_INTERFACE].Disconnect()
|
||||||
|
|
||||||
def _contact_offline(self, handle):
|
def _contact_offline(self, handle):
|
||||||
@ -280,6 +310,10 @@ class ServerPlugin(gobject.GObject):
|
|||||||
except dbus.DBusException, e:
|
except dbus.DBusException, e:
|
||||||
if str(e).startswith("org.freedesktop.DBus.Error.NoReply"):
|
if str(e).startswith("org.freedesktop.DBus.Error.NoReply"):
|
||||||
raise InvalidBuddyError("couldn't get properties")
|
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'):
|
if not props.has_key('color'):
|
||||||
raise InvalidBuddyError("no color")
|
raise InvalidBuddyError("no color")
|
||||||
if not props.has_key('key'):
|
if not props.has_key('key'):
|
||||||
|
@ -36,7 +36,7 @@ class HardwareManager(object):
|
|||||||
self._service = dbus.Interface(proxy, _HARDWARE_MANAGER_INTERFACE)
|
self._service = dbus.Interface(proxy, _HARDWARE_MANAGER_INTERFACE)
|
||||||
|
|
||||||
def set_display_mode(self, mode):
|
def set_display_mode(self, mode):
|
||||||
self._service.set_mode(mode)
|
self._service.set_display_mode(mode)
|
||||||
|
|
||||||
def set_display_brightness(self, level):
|
def set_display_brightness(self, level):
|
||||||
self._service.set_display_brightness(level)
|
self._service.set_display_brightness(level)
|
||||||
|
@ -548,7 +548,7 @@ class NMClient(gobject.GObject):
|
|||||||
return
|
return
|
||||||
self._devices[device].set_state(DEVICE_STATE_INACTIVE)
|
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))
|
logging.debug('DeviceActivationFailed for %s' % (device))
|
||||||
if not self._devices.has_key(device):
|
if not self._devices.has_key(device):
|
||||||
logging.debug('DeviceActivationFailed, device %s does not exist' % (device))
|
logging.debug('DeviceActivationFailed, device %s does not exist' % (device))
|
||||||
|
Loading…
Reference in New Issue
Block a user