summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLouis-Francis Ratté-Boulianne <louis-francis.ratte-boulianne@collabora.co.uk>2010-11-24 16:13:17 -0500
committerLouis-Francis Ratté-Boulianne <louis-francis.ratte-boulianne@collabora.co.uk>2010-12-03 10:55:45 -0500
commit4c7bb566a3ee29a46b73fff77e83cfc85962ce28 (patch)
tree9fbe4ac6cead3cb443b68468fa53b52871940750
parent42b43c5b9cf4b3776bc243664ce5e4b0c95f2589 (diff)
Add immutable properties to Protocol
Immutable properties handling has been moved to DBusProperties so Channel can use them as well.
-rw-r--r--src/server/channel.py26
-rw-r--r--src/server/conn.py13
-rw-r--r--src/server/connmgr.py5
-rw-r--r--src/server/properties.py12
-rw-r--r--src/server/protocol.py12
5 files changed, 40 insertions, 28 deletions
diff --git a/src/server/channel.py b/src/server/channel.py
index 7cc0b3a..eb9a560 100644
--- a/src/server/channel.py
+++ b/src/server/channel.py
@@ -65,8 +65,6 @@ class Channel(_Channel, DBusProperties):
self._type = props[CHANNEL_INTERFACE + '.ChannelType']
self._requested = props[CHANNEL_INTERFACE + '.Requested']
- self._immutable_properties = dict()
-
tht = props.get(CHANNEL_INTERFACE + '.TargetHandleType', HANDLE_TYPE_NONE)
if tht == HANDLE_TYPE_NONE:
@@ -87,7 +85,7 @@ class Channel(_Channel, DBusProperties):
'TargetID': lambda: dbus.String(self._handle.get_name()),
'Requested': lambda: self._requested})
- self._add_immutables({
+ self._add_immutable_properties({
'ChannelType': CHANNEL_INTERFACE,
'TargetHandle': CHANNEL_INTERFACE,
'Interfaces': CHANNEL_INTERFACE,
@@ -97,16 +95,8 @@ class Channel(_Channel, DBusProperties):
})
def _add_immutables(self, props):
- self._immutable_properties.update(props)
-
- def get_props(self):
- """Despite its name, this function actually only returns immutable channel
- properties."""
- props = dict()
- for prop, iface in self._immutable_properties.items():
- props[iface + '.' + prop] = \
- self._prop_getters[iface][prop]()
- return props
+ #backward compatibility
+ self._add_immutable_properties(props)
@dbus.service.method(CHANNEL_INTERFACE, in_signature='', out_signature='')
def Close(self):
@@ -212,7 +202,7 @@ class ChannelTypeRoomList(Channel, _ChannelTypeRoomListIface):
self._listing_rooms = False
self._rooms = {}
- self._add_immutables({'Server': CHANNEL_TYPE_ROOM_LIST})
+ self._add_immutable_properties({'Server': CHANNEL_TYPE_ROOM_LIST})
@dbus.service.method(CHANNEL_TYPE_ROOM_LIST, in_signature='', out_signature='b')
def GetListingRooms(self):
@@ -314,11 +304,10 @@ from telepathy._generated.Channel_Interface_Chat_State \
from telepathy._generated.Channel_Interface_Conference \
import ChannelInterfaceConference as _ChannelInterfaceConference
-class ChannelInterfaceConference(_ChannelInterfaceConference, DBusProperties):
+class ChannelInterfaceConference(_ChannelInterfaceConference):
def __init__(self):
_ChannelInterfaceConference.__init__(self)
- DBusProperties.__init__(self)
self._conference_channels = set()
self._conference_initial_channels = set()
@@ -349,7 +338,7 @@ class ChannelInterfaceConference(_ChannelInterfaceConference, DBusProperties):
})
# Immutable conference properties
- self._add_immutables({
+ self._add_immutable_properties({
'InitialChannels': CHANNEL_INTERFACE_CONFERENCE,
'InitialInviteeIDs': CHANNEL_INTERFACE_CONFERENCE,
'InitialInviteeHandles': CHANNEL_INTERFACE_CONFERENCE,
@@ -362,11 +351,10 @@ from telepathy._generated.Channel_Interface_DTMF import ChannelInterfaceDTMF
from telepathy._generated.Channel_Interface_Group \
import ChannelInterfaceGroup as _ChannelInterfaceGroup
-class ChannelInterfaceGroup(_ChannelInterfaceGroup, DBusProperties):
+class ChannelInterfaceGroup(_ChannelInterfaceGroup):
def __init__(self):
_ChannelInterfaceGroup.__init__(self)
- DBusProperties.__init__(self)
self._implement_property_get(CHANNEL_INTERFACE_GROUP,
{'GroupFlags': lambda: dbus.UInt32(self.GetGroupFlags()),
diff --git a/src/server/conn.py b/src/server/conn.py
index 6686913..979d473 100644
--- a/src/server/conn.py
+++ b/src/server/conn.py
@@ -226,12 +226,12 @@ class Connection(_Connection, DBusProperties):
self.signal_new_channels(signal_channels)
def signal_new_channels(self, channels):
- self.NewChannels([(channel._object_path, channel.get_props())
- for channel in channels])
+ self.NewChannels([(channel._object_path,
+ channel.get_immutable_properties()) for channel in channels])
# Now NewChannel needs to be called for each new channel.
for channel in channels:
- props = channel.get_props()
+ props = channel.get_immutable_properties()
target_handle_type = props[CHANNEL_INTERFACE + '.TargetHandleType']
target_handle = props[CHANNEL_INTERFACE + '.TargetHandle']
@@ -471,7 +471,8 @@ class ConnectionInterfaceRequests(
signature='(a{sv}as)')})
def _get_channels(self):
- return [(c._object_path, c.get_props()) for c in self._channels]
+ return [(c._object_path, c.get_immutable_properties()) \
+ for c in self._channels]
def _check_basic_properties(self, props):
# ChannelType must be present and must be a string.
@@ -582,7 +583,7 @@ class ConnectionInterfaceRequests(
channel = self._channel_manager.create_channel_for_props(props, signal=False)
- returnedProps = channel.get_props()
+ returnedProps = channel.get_immutable_properties()
_success(channel._object_path, returnedProps)
# CreateChannel MUST return *before* NewChannels is emitted.
@@ -600,7 +601,7 @@ class ConnectionInterfaceRequests(
channel = self._channel_manager.channel_for_props(props, signal=False)
- returnedProps = channel.get_props()
+ returnedProps = channel.get_immutable_properties()
_success(yours, channel._object_path, returnedProps)
self.signal_new_channels([channel])
diff --git a/src/server/connmgr.py b/src/server/connmgr.py
index b490834..0b2dc9e 100644
--- a/src/server/connmgr.py
+++ b/src/server/connmgr.py
@@ -21,8 +21,7 @@ import dbus
import dbus.service
from telepathy.errors import NotImplemented
-from telepathy.interfaces import (CONN_MGR_INTERFACE,
- PROTOCOL)
+from telepathy.interfaces import (CONN_MGR_INTERFACE)
from telepathy.server.properties import DBusProperties
from telepathy._generated.Connection_Manager \
@@ -107,5 +106,5 @@ class ConnectionManager(_ConnectionManager, DBusProperties):
def _protocol_properties(self):
properties = {}
for name, protocol in self._protocols.items():
- properties[name] = protocol.GetAll(PROTOCOL)
+ properties[name] = protocol.get_immutable_properties()
return properties
diff --git a/src/server/properties.py b/src/server/properties.py
index 65faaed..25caaa0 100644
--- a/src/server/properties.py
+++ b/src/server/properties.py
@@ -33,6 +33,9 @@ class DBusProperties(dbus.service.Interface):
self._interfaces.add(dbus.PROPERTIES_IFACE)
+ if not getattr(self, '_immutable_properties', None):
+ self._immutable_properties = dict()
+
if not getattr(self, '_prop_getters', None):
self._prop_getters = {}
self._prop_setters = {}
@@ -43,6 +46,15 @@ class DBusProperties(dbus.service.Interface):
def _implement_property_set(self, iface, dict):
self._prop_setters.setdefault(iface, {}).update(dict)
+ def _add_immutable_properties(self, props):
+ self._immutable_properties.update(props)
+
+ def get_immutable_properties(self):
+ props = dict()
+ for prop, iface in self._immutable_properties.items():
+ props[iface + '.' + prop] = self._prop_getters[iface][prop]()
+ return props
+
@dbus.service.method(dbus_interface=dbus.PROPERTIES_IFACE, in_signature='ss', out_signature='v')
def Get(self, interface_name, property_name):
if interface_name in self._prop_getters \
diff --git a/src/server/protocol.py b/src/server/protocol.py
index 6235434..809f4b2 100644
--- a/src/server/protocol.py
+++ b/src/server/protocol.py
@@ -67,6 +67,16 @@ class Protocol(_Protocol, DBusProperties):
'Parameters': lambda: self.parameters
})
+ self._add_immutable_properties({
+ 'EnglishName': PROTOCOL,
+ 'Icon': PROTOCOL,
+ 'VCardField': PROTOCOL,
+ 'Interfaces': PROTOCOL,
+ 'ConnectionInterfaces': PROTOCOL,
+ 'RequestableChannelClasses': PROTOCOL,
+ 'Parameters': PROTOCOL
+ })
+
@property
def english_name(self):
return dbus.String(self._english_name)
@@ -175,6 +185,8 @@ class ProtocolInterfacePresence(_ProtocolInterfacePresence):
_ProtocolInterfacePresence.__init__(self)
self._implement_property_get(PROTOCOL_INTERFACE_PRESENCE, {
'Statuses': lambda: self.statuses})
+ self._add_immutable_properties({
+ 'Statuses': PROTOCOL_INTERFACE_PRESENCE})
@property
def statuses(self):