Add a color property and access to Buddy objects

This commit is contained in:
Dan Williams 2006-08-23 11:14:46 -04:00
parent e366753ab0
commit d334b6e3bd
3 changed files with 12 additions and 6 deletions

View File

@ -29,7 +29,9 @@ class ShellOwner(object):
def announce(self): def announce(self):
# Create and announce our presence # Create and announce our presence
self._service = self._pservice.register_service(self._nick, PRESENCE_SERVICE_TYPE) props = { 'color': "#deadbe" }
self._service = self._pservice.register_service(self._nick,
PRESENCE_SERVICE_TYPE, properties=props)
print "Owner '%s' using port %d" % (self._nick, self._service.get_port()) print "Owner '%s' using port %d" % (self._nick, self._service.get_port())
self._icon_stream = Stream.Stream.new_from_service(self._service) self._icon_stream = Stream.Stream.new_from_service(self._service)
self._icon_stream.register_reader_handler(self._handle_buddy_icon_request, "get_buddy_icon") self._icon_stream.register_reader_handler(self._handle_buddy_icon_request, "get_buddy_icon")
@ -39,8 +41,3 @@ class ShellOwner(object):
if self._icon: if self._icon:
return base64.b64encode(self._icon) return base64.b64encode(self._icon)
return "" return ""
def set_icon(self, icon):
"""Can only set icon in constructor for now."""
pass

View File

@ -74,6 +74,7 @@ class BuddyDBusHelper(dbus.service.Object):
props['name'] = self._parent.get_name() props['name'] = self._parent.get_name()
props['ip4_address'] = self._parent.get_address() props['ip4_address'] = self._parent.get_address()
props['owner'] = self._parent.is_owner() props['owner'] = self._parent.is_owner()
props['color'] = self._parent.get_color()
return props return props
@ -94,6 +95,7 @@ class Buddy(object):
self._nick_name = service.get_name() self._nick_name = service.get_name()
self._address = service.get_source_address() self._address = service.get_source_address()
self._color = None
self._valid = False self._valid = False
self._icon = None self._icon = None
self._icon_tries = 0 self._icon_tries = 0
@ -159,6 +161,7 @@ class Buddy(object):
self._valid = True self._valid = True
print 'Requesting buddy icon %s' % self._nick_name print 'Requesting buddy icon %s' % self._nick_name
self._request_buddy_icon(service) self._request_buddy_icon(service)
self._color = service.get_one_property('color')
if self._valid: if self._valid:
self._dbus_helper.ServiceAppeared(service.object_path()) self._dbus_helper.ServiceAppeared(service.object_path())
@ -243,6 +246,9 @@ class Buddy(object):
def get_name(self): def get_name(self):
return self._nick_name return self._nick_name
def get_color(self):
return self._color
def _set_icon(self, icon): def _set_icon(self, icon):
"""Can only set icon for other buddies. The Owner """Can only set icon for other buddies. The Owner
takes care of setting it's own icon.""" takes care of setting it's own icon."""

View File

@ -89,6 +89,9 @@ class Buddy(gobject.GObject):
def is_owner(self): def is_owner(self):
return self._properties['owner'] return self._properties['owner']
def get_color(self):
return self._properties['color']
def get_icon(self): def get_icon(self):
return self._buddy.getIcon() return self._buddy.getIcon()