Web   ·   Wiki   ·   Activities   ·   Blog   ·   Lists   ·   Chat   ·   Meeting   ·   Bugs   ·   Git   ·   Translate   ·   Archive   ·   People   ·   Donate
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSimon McVittie <simon.mcvittie@collabora.co.uk>2007-06-07 14:40:50 (GMT)
committer Simon McVittie <simon.mcvittie@collabora.co.uk>2007-06-07 14:40:50 (GMT)
commit81636d891f3ecaaa5dae82b80e84e98b67899b3a (patch)
treef3fceb1aca9e771a7c2cf52d52b58bd0a55187dd
parent3e402c75350ea4b7a6dd493d1edeeec74bdf792a (diff)
server_plugin: Fix setting self avatar. Make pychecker happier.
-rw-r--r--src/presenceservice.py7
-rw-r--r--src/server_plugin.py17
2 files changed, 12 insertions, 12 deletions
diff --git a/src/presenceservice.py b/src/presenceservice.py
index 5bcfd45..ae2b770 100644
--- a/src/presenceservice.py
+++ b/src/presenceservice.py
@@ -21,6 +21,7 @@ from weakref import WeakValueDictionary
import dbus
import dbus.service
import gobject
+from dbus.exceptions import DBusException
from dbus.gobject_service import ExportedGObject
from dbus.mainloop.glib import DBusGMainLoop
from telepathy.client import ManagerRegistry, Connection
@@ -45,9 +46,9 @@ _PRESENCE_PATH = "/org/laptop/Sugar/Presence"
_logger = logging.getLogger('s-p-s.presenceservice')
-class NotFoundError(dbus.DBusException):
+class NotFoundError(DBusException):
def __init__(self, msg):
- dbus.DBusException.__init__(self, msg)
+ DBusException.__init__(self, msg)
self._dbus_error_name = _PRESENCE_INTERFACE + '.NotFound'
class PresenceService(ExportedGObject):
@@ -499,7 +500,7 @@ class PresenceService(ExportedGObject):
def main(test_num=0, randomize=False):
loop = gobject.MainLoop()
- dbus_mainloop_wrapper = DBusGMainLoop(set_as_default=True)
+ DBusGMainLoop(set_as_default=True)
if test_num > 0:
from pstest import TestPresenceService
diff --git a/src/server_plugin.py b/src/server_plugin.py
index 14ad8a8..ea51f89 100644
--- a/src/server_plugin.py
+++ b/src/server_plugin.py
@@ -80,7 +80,6 @@ def _get_buddy_icon_at_size(icon, maxw, maxh, maxsize):
quality = 90
img_size = maxsize + 1
while img_size > maxsize:
- del data
data = [""]
pixbuf.save_to_callback(_buddy_icon_save_cb, "jpeg",
{"quality":"%d" % quality}, data)
@@ -89,7 +88,7 @@ def _get_buddy_icon_at_size(icon, maxw, maxh, maxsize):
del pixbuf
if img_size > maxsize:
- del data
+ data = [""]
raise RuntimeError("could not size image less than %d bytes" % maxsize)
return str(data[0])
@@ -292,7 +291,6 @@ class ServerPlugin(gobject.GObject):
# Search existing connections, if any, that we might be able to use
connections = Connection.get_connections()
- conn = None
for item in connections:
if not item.object_path.startswith(_OBJ_PATH_PREFIX):
continue
@@ -443,25 +441,26 @@ class ServerPlugin(gobject.GObject):
self._conn[CONN_INTERFACE_PRESENCE].RequestPresence(subscribe_handles)
return True
- def _set_self_avatar_cb(self, token):
- self._icon_cache.set_avatar(self._conn.object_path, hash, token)
-
def _set_self_avatar(self, icon_data=None):
if not icon_data:
icon_data = self._owner.props.icon
m = md5()
m.update(icon_data)
- hash = m.hexdigest()
+ digest = m.hexdigest()
self_handle = self._conn[CONN_INTERFACE].GetSelfHandle()
token = self._conn[CONN_INTERFACE_AVATARS].GetAvatarTokens(
[self_handle])[0]
- if self._icon_cache.check_avatar(self._conn.object_path, hash, token):
+ if self._icon_cache.check_avatar(self._conn.object_path, digest,
+ token):
# avatar is up to date
return
+ def set_self_avatar_cb(token):
+ self._icon_cache.set_avatar(self._conn.object_path, digest, token)
+
types, minw, minh, maxw, maxh, maxsize = \
self._conn[CONN_INTERFACE_AVATARS].GetAvatarRequirements()
if not "image/jpeg" in types:
@@ -471,7 +470,7 @@ class ServerPlugin(gobject.GObject):
img_data = _get_buddy_icon_at_size(icon_data, min(maxw, 96),
min(maxh, 96), maxsize)
self._conn[CONN_INTERFACE_AVATARS].SetAvatar(img_data, "image/jpeg",
- reply_handler=self._set_self_avatar_cb,
+ reply_handler=set_self_avatar_cb,
error_handler=lambda e: self._log_error_cb("setting avatar", e))
def _join_activity_channel_props_set_cb(self, activity_id, signal, handle,