1 # -*- coding: utf-8 -*-
2 # Generated from the Telepathy spec
3 """Copyright (C) 2005-2008 Collabora Limited
4 Copyright (C) 2005-2008 Nokia Corporation
5 Copyright (C) 2006 INdT
7 This library is free software; you can redistribute it and/or
8 modify it under the terms of the GNU Lesser General Public
9 License as published by the Free Software Foundation; either
10 version 2.1 of the License, or (at your option) any later version.
12 This library is distributed in the hope that it will be useful,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 Lesser General Public License for more details.
17 You should have received a copy of the GNU Lesser General Public
18 License along with this library; if not, write to the Free Software
19 Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
26 class ConnectionInterfaceAvatars(dbus.service.Interface):
28 An interface for requesting avatars for contacts on a given connection,
29 receiving notification when avatars are changed, and publishing your own
32 Avatars are identified by a string, the Avatar_Token,
33 which represents a particular avatar. Tokens MUST be chosen by the
34 connection manager in such a way that the triple
35 (Connection_Manager_Name, Protocol,
36 Avatar_Token) uniquely identifies an avatar.
37 An empty token means that an avatar has not been set for this contact, and
38 a changed token implies the contact's avatar has changed, but the strings
39 should otherwise be considered opaque by clients.
41 A client should use GetKnownAvatarTokens
42 to request the tokens for the
43 avatars of all the contacts it is interested in when it connects. The
44 avatars can then be requested using
45 RequestAvatars for the contacts. Clients
46 should bind to the AvatarUpdated signal and
48 the avatar when a contacts' avatar token changes. Clients should cache the
49 token and data of each contact's avatar between connections, to avoid
50 repeatedly retrieving the same avatar.
52 To publish an avatar, a client should use
53 SetAvatar to provide an image which meets
54 the requirements returned by the
56 function. On some protocols the avatar is stored on the server, so setting
57 the avatar is persistent, but on others it is transferred via a peer to
58 peer mechanism, so needs to be set every connection. Hence, on every
59 connection, clients should inspect the avatar token of the connection's
60 self handle using GetKnownAvatarTokens; if
61 the self handle is not in the
62 returned map, the client should re-set the avatar. If the self handle's
63 avatar token is known, but the avatar has been changed locally since the
64 last connection, the client should upload the new avatar; if the avatar has
65 not changed locally, then the client should download the avatar from the
66 server if its token differs from the that of the local avatar.
68 To remove the published avatar on protocols which have persistent avatars,
69 a client should use the ClearAvatar method.
70 This method can safely be used even if there is no avatar for this
75 self._interfaces.add('org.freedesktop.Telepathy.Connection.Interface.Avatars')
77 @dbus.service.method('org.freedesktop.Telepathy.Connection.Interface.Avatars', in_signature='', out_signature='asqqqqu')
78 def GetAvatarRequirements(self):
80 Get the required format of avatars on this connection.
83 raise NotImplementedError
85 @dbus.service.method('org.freedesktop.Telepathy.Connection.Interface.Avatars', in_signature='au', out_signature='as')
86 def GetAvatarTokens(self, Contacts):
88 Get the unique tokens for all of the given contacts' avatars.
90 Using this method in new Telepathy clients is deprecated; use
91 GetKnownAvatarTokens instead.
94 raise NotImplementedError
96 @dbus.service.method('org.freedesktop.Telepathy.Connection.Interface.Avatars', in_signature='au', out_signature='a{us}')
97 def GetKnownAvatarTokens(self, Contacts):
99 Get the unique tokens for the given contacts' avatars. These tokens
100 can be persisted across connections, and should be used by the client
101 to check whether the avatars have been updated. For handles other than
102 the self handle, only tokens that are already known are returned; an
103 empty token means the given contact has no avatar. However, a CM must
104 always have the tokens for the self handle if one is set (even if it is
105 set to no avatar). On protocols where the avatar does not persist
106 between connections, a CM should omit the self handle from the returned
107 map until an avatar is explicitly set or cleared.
110 raise NotImplementedError
112 @dbus.service.method('org.freedesktop.Telepathy.Connection.Interface.Avatars', in_signature='u', out_signature='ays')
113 def RequestAvatar(self, Contact):
115 Request the avatar for a given contact. Using this method in new
116 Telepathy clients is deprecated; use RequestAvatars instead.
119 raise NotImplementedError
121 @dbus.service.method('org.freedesktop.Telepathy.Connection.Interface.Avatars', in_signature='au', out_signature='')
122 def RequestAvatars(self, Contacts):
124 Request avatars for a number of contacts. The
125 AvatarRetrieved signal is emitted for
126 each avatar retrieved. If the handles are valid but retrieving an
127 avatar fails (for any reason, including the contact not having an
128 avatar) the AvatarRetrieved signal is not emitted for that contact.
131 raise NotImplementedError
133 @dbus.service.method('org.freedesktop.Telepathy.Connection.Interface.Avatars', in_signature='ays', out_signature='s')
134 def SetAvatar(self, Avatar, MIME_Type):
136 Set a new avatar image for this connection. The avatar image must
137 respect the requirements obtained by
138 GetAvatarRequirements.
141 raise NotImplementedError
143 @dbus.service.method('org.freedesktop.Telepathy.Connection.Interface.Avatars', in_signature='', out_signature='')
144 def ClearAvatar(self):
146 Remove the avatar image for this connection.
149 raise NotImplementedError
151 @dbus.service.signal('org.freedesktop.Telepathy.Connection.Interface.Avatars', signature='us')
152 def AvatarUpdated(self, Contact, New_Avatar_Token):
154 Emitted when the avatar for a contact has been updated, or first
155 discovered on this connection. If the token differs from the token
156 associated with the client's cached avatar for this contact, the new
157 avatar should be requested with
163 @dbus.service.signal('org.freedesktop.Telepathy.Connection.Interface.Avatars', signature='usays')
164 def AvatarRetrieved(self, Contact, Token, Avatar, Type):
166 Emitted when the avatar for a contact has been retrieved.