[telepathy-pinocchio/master] Implement the Contacts interface
Marco Barisione
marco at barisione.org
Mon Aug 10 14:08:13 PDT 2009
---
pinocchio/connection/__init__.py | 5 ++-
pinocchio/connection/contacts.py | 68 ++++++++++++++++++++++++++++++++++++++
2 files changed, 72 insertions(+), 1 deletions(-)
create mode 100644 pinocchio/connection/contacts.py
diff --git a/pinocchio/connection/__init__.py b/pinocchio/connection/__init__.py
index 2d3d03b..bb6aa4d 100644
--- a/pinocchio/connection/__init__.py
+++ b/pinocchio/connection/__init__.py
@@ -28,13 +28,15 @@ from avatars import *
from capabilities import *
from presence import *
from simple_presence import *
+from contacts import *
class Connection(tp.server.Connection,
aliasing.Aliasing,
avatars.Avatars,
capabilities.Capabilities,
presence.Presence,
- simple_presence.SimplePresence):
+ simple_presence.SimplePresence,
+ contacts.Contacts):
"""Representation of a virtual connection."""
_CONTACT_LIST_NAMES = ('subscribe', 'publish', 'hide', 'allow', 'deny')
@@ -54,6 +56,7 @@ class Connection(tp.server.Connection,
capabilities.Capabilities.__init__(self)
presence.Presence.__init__(self)
simple_presence.SimplePresence.__init__(self)
+ contacts.Contacts.__init__(self)
# accept the default alias, etc. (including the required, though empty,
# avatar)
diff --git a/pinocchio/connection/contacts.py b/pinocchio/connection/contacts.py
new file mode 100644
index 0000000..f3e5197
--- /dev/null
+++ b/pinocchio/connection/contacts.py
@@ -0,0 +1,68 @@
+# telepathy-pinocchio - dummy Telepathy connection manager for instrumentation
+#
+# Copyright (C) 2008-2009 Nokia Corporation
+# Copyright (C) 2008-2009 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
+# version 2.1 as published by the Free Software Foundation.
+#
+# 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 St, Fifth Floor, Boston, MA
+# 02110-1301 USA
+
+import mimetypes
+import dbus.service
+
+import telepathy as tp
+
+import pinocchio as pin
+
+class Contacts(tp.server.ConnectionInterfaceContacts):
+ """Contacts interface for a Telepathy Connection."""
+
+ def __init__(self):
+ tp.server.ConnectionInterfaceContacts.__init__(self)
+
+ def get_interfaces():
+ return [tp.CONN_INTERFACE,
+ tp.CONNECTION_INTERFACE_ALIASING,
+ tp.CONNECTION_INTERFACE_AVATARS,
+ tp.CONNECTION_INTERFACE_SIMPLE_PRESENCE]
+
+ print self._implement_property_get
+ self._implement_property_get(tp.CONNECTION_INTERFACE_CONTACTS,
+ {'ContactAttributeInterfaces': get_interfaces})
+
+ def GetContactAttributes(self, handles, interfaces, hold):
+ interfaces = list(interfaces)
+
+ all_attrs = {}
+
+ for handle_id in handles:
+ self.check_handle (tp.constants.HANDLE_TYPE_CONTACT, handle_id)
+
+ handle_obj = self._handles[tp.constants.HANDLE_TYPE_CONTACT,
+ handle_id]
+
+ attrs = {}
+ attrs[tp.CONN_INTERFACE + '/contact-id'] = handle_obj.get_name()
+ if tp.CONNECTION_INTERFACE_ALIASING in interfaces:
+ attrs[tp.CONNECTION_INTERFACE_ALIASING + '/alias'] = \
+ handle_obj.get_alias()
+ if tp.CONNECTION_INTERFACE_AVATARS in interfaces:
+ attrs[tp.CONNECTION_INTERFACE_AVATARS + '/token'] = \
+ handle_obj.get_avatar_token()
+ if tp.CONNECTION_INTERFACE_SIMPLE_PRESENCE in interfaces:
+ attrs[tp.CONNECTION_INTERFACE_SIMPLE_PRESENCE + '/presence'] = \
+ handle_obj.get_simple_presence()
+
+ all_attrs[handle_id] = attrs
+
+ return all_attrs
--
1.5.6.5
More information about the telepathy-commits
mailing list