from handle import Handle
from properties import DBusProperties
-from telepathy._generated.Connection import Connection as _Connection
+from _generated.Connection import Connection as _Connection
_BAD = re.compile(r'(?:^[0-9])|(?:[^A-Za-z0-9])')
self._interfaces = set()
DBusProperties.__init__(self)
- self._implement_property_get(CONN_INTERFACE,
- {'SelfHandle': lambda: dbus.UInt32(self.GetSelfHandle())})
+ self._implement_property_get(CONN_INTERFACE, {
+ 'SelfHandle': lambda: dbus.UInt32(self.GetSelfHandle()),
+ 'Interfaces': lambda: dbus.Array(self.GetInterfaces(), signature='s'),
+ 'Status': lambda: dbus.UInt32(self.GetStatus())
+ })
self._proto = proto
def set_self_handle(self, handle):
self._self_handle = handle
- def get_channel_path(self):
- ret = '%s/channel%d' % (self._object_path, self._next_channel_id)
- self._next_channel_id += 1
+ def get_channel_path(self, suffix):
+ if not suffix:
+ ret = '%s/channel%d' % (self._object_path, self._next_channel_id)
+ self._next_channel_id += 1
+ else:
+ ret = '%s/%s' % (self._object_path, suffix)
return ret
def add_channels(self, channels, signal=True):
self.check_connected()
ret = []
for channel in self._channels:
- chan = (channel._object_path, channel._type, channel._get_handle_type(), channel._handle)
+ chan = (channel._object_path, channel._type, channel._handle.get_type(), channel._handle.get_id())
ret.append(chan)
return ret
-from telepathy._generated.Connection_Interface_Aliasing \
+from _generated.Connection_Interface_Aliasing \
import ConnectionInterfaceAliasing
-from telepathy._generated.Connection_Interface_Avatars \
+from _generated.Connection_Interface_Avatars \
import ConnectionInterfaceAvatars
-from telepathy._generated.Connection_Interface_Capabilities \
+from _generated.Connection_Interface_Capabilities \
import ConnectionInterfaceCapabilities \
as _ConnectionInterfaceCapabilities
# return all my capabilities
return [(ctype, caps[1]) for ctype, caps in my_caps.iteritems()]
-from telepathy._generated.Connection_Interface_Requests \
+from _generated.Connection_Interface_Requests \
import ConnectionInterfaceRequests \
as _ConnectionInterfaceRequests
# Allow TargetHandleType to be missing, but not to be otherwise broken.
check_valid_type_if_exists('TargetHandleType',
- lambda p: p > 0 and p < (2**32)-1)
+ lambda p: p >= 0 and p <= LAST_HANDLE_TYPE)
# Allow TargetType to be missing, but not to be otherwise broken.
check_valid_type_if_exists('TargetHandle',
target_id = props.get(CHANNEL_INTERFACE + '.TargetID', None)
# Handle type 0 cannot have a handle.
- if target_handle_type == HANDLE_TYPE_NONE and target_handle != None:
+ if target_handle_type == HANDLE_TYPE_NONE and target_handle not in (None, 0):
raise InvalidArgument('When TargetHandleType is NONE, ' +
- 'TargetHandle must be omitted')
+ 'TargetHandle must be omitted or 0')
# Handle type 0 cannot have a TargetID.
if target_handle_type == HANDLE_TYPE_NONE and target_id != None:
self.signal_new_channels([channel])
-from telepathy._generated.Connection_Interface_Presence \
+from _generated.Connection_Interface_Presence \
import ConnectionInterfacePresence
-from telepathy._generated.Connection_Interface_Simple_Presence \
+from _generated.Connection_Interface_Simple_Presence \
import ConnectionInterfaceSimplePresence
-from telepathy._generated.Connection_Interface_Contacts \
+from _generated.Connection_Interface_Contacts \
import ConnectionInterfaceContacts