start to use aliasing interface for nick
This commit is contained in:
parent
403c2abc5c
commit
065cd6bc20
@ -161,7 +161,7 @@ class Buddy(dbus.service.Object):
|
|||||||
def _set_color(self, color):
|
def _set_color(self, color):
|
||||||
self._color = color
|
self._color = color
|
||||||
|
|
||||||
def set_properties(self, prop):
|
def set_properties(self, properties):
|
||||||
if "name" in properties.keys():
|
if "name" in properties.keys():
|
||||||
self._set_name(properties["name"])
|
self._set_name(properties["name"])
|
||||||
if "color" in properties.keys():
|
if "color" in properties.keys():
|
||||||
|
@ -78,8 +78,9 @@ class PresenceService(dbus.service.Object):
|
|||||||
def _server_status_cb(self, plugin, status, reason):
|
def _server_status_cb(self, plugin, status, reason):
|
||||||
pass
|
pass
|
||||||
|
|
||||||
def _contact_online(self, tp, handle, key):
|
def _contact_online(self, tp, handle, props):
|
||||||
new_buddy = False
|
new_buddy = False
|
||||||
|
key = props['key']
|
||||||
buddy = self._buddies.get(key)
|
buddy = self._buddies.get(key)
|
||||||
|
|
||||||
if not buddy:
|
if not buddy:
|
||||||
@ -99,6 +100,7 @@ class PresenceService(dbus.service.Object):
|
|||||||
|
|
||||||
if new_buddy:
|
if new_buddy:
|
||||||
self.BuddyAppeared(buddy.object_path())
|
self.BuddyAppeared(buddy.object_path())
|
||||||
|
buddy.set_properties(props)
|
||||||
|
|
||||||
def _contact_offline(self, tp, handle):
|
def _contact_offline(self, tp, handle):
|
||||||
buddy = self._handles[tp].pop(handle)
|
buddy = self._handles[tp].pop(handle)
|
||||||
|
@ -194,10 +194,11 @@ class ServerPlugin(gobject.GObject):
|
|||||||
# hack
|
# hack
|
||||||
self._conn._valid_interfaces.add(CONN_INTERFACE_ALIASING)
|
self._conn._valid_interfaces.add(CONN_INTERFACE_ALIASING)
|
||||||
|
|
||||||
if CONN_INTERFACE_ALIASING in self._conn:
|
self._conn[CONN_INTERFACE_ALIASING].connect_to_signal('AliasesChanged', self._alias_changed_cb)
|
||||||
aliases = self._conn[CONN_INTERFACE_ALIASING].RequestAliases(subscribe_handles)
|
#if CONN_INTERFACE_ALIASING in self._conn:
|
||||||
else:
|
# aliases = self._conn[CONN_INTERFACE_ALIASING].RequestAliases(subscribe_handles)
|
||||||
aliases = self._conn[CONN_INTERFACE].InspectHandles(CONNECTION_HANDLE_TYPE_CONTACT, subscribe_handles)
|
#else:
|
||||||
|
# aliases = self._conn[CONN_INTERFACE].InspectHandles(CONNECTION_HANDLE_TYPE_CONTACT, subscribe_handles)
|
||||||
|
|
||||||
#for handle, alias in zip(subscribe_handles, aliases):
|
#for handle, alias in zip(subscribe_handles, aliases):
|
||||||
# print alias
|
# print alias
|
||||||
@ -225,9 +226,12 @@ 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()
|
||||||
props['nick'] = profile.get_nick_name()
|
|
||||||
self._conn[CONN_INTERFACE_BUDDY_INFO].SetProperties(props)
|
self._conn[CONN_INTERFACE_BUDDY_INFO].SetProperties(props)
|
||||||
|
|
||||||
|
name = profile.get_nick_name()
|
||||||
|
self_handle = self._conn[CONN_INTERFACE].GetSelfHandle()
|
||||||
|
self._conn[CONN_INTERFACE_ALIASING].SetAliases( {self_handle : name} )
|
||||||
|
|
||||||
types, minw, minh, maxw, maxh, maxsize = self._conn[CONN_INTERFACE_AVATARS].GetAvatarRequirements()
|
types, minw, minh, maxw, maxh, maxsize = self._conn[CONN_INTERFACE_AVATARS].GetAvatarRequirements()
|
||||||
if not "image/jpeg" in types:
|
if not "image/jpeg" in types:
|
||||||
print "server does not accept JPEG format avatars."
|
print "server does not accept JPEG format avatars."
|
||||||
@ -287,17 +291,17 @@ class ServerPlugin(gobject.GObject):
|
|||||||
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")
|
||||||
|
|
||||||
|
name = self._conn[CONN_INTERFACE_ALIASING].RequestAliases([handle])[0]
|
||||||
|
|
||||||
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('nick'):
|
|
||||||
raise InvalidBuddyError("no nick name")
|
|
||||||
if not props.has_key('key'):
|
if not props.has_key('key'):
|
||||||
raise InvalidBuddyError("no key")
|
raise InvalidBuddyError("no key")
|
||||||
|
if not name:
|
||||||
key = props['key']
|
raise InvalidBuddyError("no name")
|
||||||
|
|
||||||
self._online_contacts.add(handle)
|
self._online_contacts.add(handle)
|
||||||
self.emit("contact-online", handle, key)
|
self.emit("contact-online", handle, props)
|
||||||
|
|
||||||
def _presence_update_cb(self, presence):
|
def _presence_update_cb(self, presence):
|
||||||
for handle in presence:
|
for handle in presence:
|
||||||
@ -328,6 +332,14 @@ class ServerPlugin(gobject.GObject):
|
|||||||
|
|
||||||
self.emit("avatar-updated", handle, icon)
|
self.emit("avatar-updated", handle, icon)
|
||||||
|
|
||||||
|
def _alias_changed_cb(self, aliases):
|
||||||
|
print "alias changed cb"
|
||||||
|
for handle, alias in aliases:
|
||||||
|
name = self._conn[CONN_INTERFACE_ALIASING].RequestAliases([handle])[0]
|
||||||
|
print "new alias", handle, alias, name
|
||||||
|
prop = {'name': name}
|
||||||
|
self._properties_changed_cb(handle, prop)
|
||||||
|
|
||||||
def _properties_changed_cb(self, contact, properties):
|
def _properties_changed_cb(self, contact, properties):
|
||||||
self.emit("properties-changed", contact, properties)
|
self.emit("properties-changed", contact, properties)
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user