diff options
author | Louis-Francis Ratté-Boulianne <louis-francis.ratte-boulianne@collabora.co.uk> | 2010-10-29 15:43:39 -0400 |
---|---|---|
committer | Louis-Francis Ratté-Boulianne <louis-francis.ratte-boulianne@collabora.co.uk> | 2010-12-03 10:55:44 -0500 |
commit | 42b43c5b9cf4b3776bc243664ce5e4b0c95f2589 (patch) | |
tree | 07f893c7c42fd9ab8502df078b314a2e973e7080 | |
parent | 5263eeceff83838e2a9dc889a95034b882bdbe1f (diff) |
Add default implementation of Protocol.Interface.Presence
Connection managers only have to populate _statuses attribute
-rw-r--r-- | src/server/protocol.py | 22 |
1 files changed, 21 insertions, 1 deletions
diff --git a/src/server/protocol.py b/src/server/protocol.py index fa20de4..6235434 100644 --- a/src/server/protocol.py +++ b/src/server/protocol.py @@ -23,7 +23,8 @@ from telepathy.constants import (CONN_MGR_PARAM_FLAG_REQUIRED, CONN_MGR_PARAM_FLAG_SECRET, CONN_MGR_PARAM_FLAG_HAS_DEFAULT) from telepathy.errors import InvalidArgument, NotImplemented -from telepathy.interfaces import PROTOCOL +from telepathy.interfaces import (PROTOCOL, + PROTOCOL_INTERFACE_PRESENCE) from telepathy.server.properties import DBusProperties from telepathy._generated.Protocol import Protocol as _Protocol @@ -159,3 +160,22 @@ class Protocol(_Protocol, DBusProperties): def create_connection(self, connection_manager, parameters): raise NotImplemented('no create_connection for %s' % self._proto) + + +from telepathy._generated.Protocol_Interface_Presence \ + import ProtocolInterfacePresence \ + as _ProtocolInterfacePresence + +class ProtocolInterfacePresence(_ProtocolInterfacePresence): + + """ Class members to override in CM implementations : """ + _statuses = {} # Simple Status Spec Map + + def __init__(self): + _ProtocolInterfacePresence.__init__(self) + self._implement_property_get(PROTOCOL_INTERFACE_PRESENCE, { + 'Statuses': lambda: self.statuses}) + + @property + def statuses(self): + return dbus.Dictionary(self._statuses, signature='s(ubb)') |