diff options
author | Krzysztof Klinikowski <kkszysiu@gmail.com> | 2011-05-07 20:22:52 +0200 |
---|---|---|
committer | Krzysztof Klinikowski <kkszysiu@gmail.com> | 2011-05-07 20:22:52 +0200 |
commit | d650a753b0a04409a5ffd977dd7e8672ecabc389 (patch) | |
tree | 5259e2c63a075bda45d7b3bc6e6704e693a00448 | |
parent | 8c64a8f6b0993f58a750d290389db0d8a13c54b2 (diff) |
Added ProtocolInterfaceAvatar interface.
-rw-r--r-- | sunshine/Protocol_Interface_Avatars.py | 65 | ||||
-rw-r--r-- | sunshine/protocol.py | 24 |
2 files changed, 70 insertions, 19 deletions
diff --git a/sunshine/Protocol_Interface_Avatars.py b/sunshine/Protocol_Interface_Avatars.py new file mode 100644 index 0000000..ce116d6 --- /dev/null +++ b/sunshine/Protocol_Interface_Avatars.py @@ -0,0 +1,65 @@ +# -*- coding: utf-8 -*- +# Generated from the Telepathy spec +"""Copyright © 2009-2010 Collabora Ltd. + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with this library; if not, write to the Free Software + Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA + 02110-1301, USA. + +""" + +import dbus.service + + +class ProtocolInterfaceAvatars(dbus.service.Interface): + """\ + An interface for protocols where it might be possible to set the + user's avatar, and the expected size limits and supported MIME types + are known before connecting. + + + If the avatar requirements cannot be discovered while offline, + it's impossible to avoid setting the Account's Avatar property to an unsupported avatar. + + + Each property on this interface SHOULD be cached in the + .manager file, using a key of the same name as the + property in the [Protocol proto] + group. All properties are encoded in ASCII decimal in the obvious + way, except for + SupportedAvatarMIMETypes which is + encoded as a sequence of strings each followed by a semicolon + (as for the "localestrings" type in the Desktop Entry + Specification). + + For instance, an XMPP connection manager might have this + .manager file: + +[Protocol jabber] +Interfaces=org.freedesktop.Telepathy.Protocol.Interface.Avatars; +param-account=s required +param-password=s required +SupportedAvatarMIMETypes=image/png;image/jpeg;image/gif; +MinimumAvatarHeight=32 +RecommendedAvatarHeight=64 +MaximumAvatarHeight=96 +MinimumAvatarWidth=32 +RecommendedAvatarWidth=64 +MaximumAvatarWidth=96 +MaximumAvatarBytes=8192 + + """ + + def __init__(self): + self._interfaces.add('org.freedesktop.Telepathy.Protocol.Interface.Avatars') diff --git a/sunshine/protocol.py b/sunshine/protocol.py index 25bc833..33bc765 100644 --- a/sunshine/protocol.py +++ b/sunshine/protocol.py @@ -24,12 +24,15 @@ import telepathy from sunshine.connection import SunshineConnection from sunshine.presence import SunshinePresenceMapping +from sunshine.Protocol_Interface_Avatars import ProtocolInterfaceAvatars + __all__ = ['SunshineProtocol'] logger = logging.getLogger('Sunshine.Protocol') class SunshineProtocol(telepathy.server.Protocol, - telepathy.server.ProtocolInterfacePresence): + telepathy.server.ProtocolInterfacePresence, + ProtocolInterfaceAvatars): _proto = "gadugadu" _vcard_field = "" @@ -78,24 +81,6 @@ class SunshineProtocol(telepathy.server.Protocol, telepathy.CHANNEL_INTERFACE + '.TargetHandleType': dbus.UInt32(telepathy.HANDLE_TYPE_LIST)}, [telepathy.CHANNEL_INTERFACE + '.TargetHandle', telepathy.CHANNEL_INTERFACE + '.TargetID']), - - #({telepathy.CHANNEL_INTERFACE + '.ChannelType': dbus.String(telepathy.CHANNEL_TYPE_STREAMED_MEDIA), - #telepathy.CHANNEL_INTERFACE + '.TargetHandleType': dbus.UInt32(telepathy.HANDLE_TYPE_CONTACT)}, - #[telepathy.CHANNEL_INTERFACE + '.TargetHandle', - #telepathy.CHANNEL_INTERFACE + '.TargetID', - #telepathy.CHANNEL_TYPE_STREAMED_MEDIA + '.InitialAudio', - #telepathy.CHANNEL_TYPE_STREAMED_MEDIA + '.InitialVideo']), - - #({telepathy.CHANNEL_INTERFACE + '.ChannelType': dbus.String(telepathy.CHANNEL_TYPE_FILE_TRANSFER), - #telepathy.CHANNEL_INTERFACE + '.TargetHandleType': dbus.UInt32(telepathy.HANDLE_TYPE_CONTACT)}, - #[telepathy.CHANNEL_INTERFACE + '.TargetHandle', - #telepathy.CHANNEL_INTERFACE + '.TargetID', - #telepathy.CHANNEL_TYPE_FILE_TRANSFER + '.ContentType', - #telepathy.CHANNEL_TYPE_FILE_TRANSFER + '.Filename', - #telepathy.CHANNEL_TYPE_FILE_TRANSFER + '.Size', - #telepathy.CHANNEL_TYPE_FILE_TRANSFER + '.ContentHash', - #telepathy.CHANNEL_TYPE_FILE_TRANSFER + '.Description', - #telepathy.CHANNEL_TYPE_FILE_TRANSFER + '.Date']) ] _supported_interfaces = [ @@ -132,6 +117,7 @@ class SunshineProtocol(telepathy.server.Protocol, def __init__(self, connection_manager): telepathy.server.Protocol.__init__(self, connection_manager, 'gadugadu') telepathy.server.ProtocolInterfacePresence.__init__(self) + ProtocolInterfaceAvatars.__init__(self) def create_connection(self, connection_manager, parameters): return SunshineConnection(self, connection_manager, parameters) |