# Path: telepathy/errors.py

# 
# Path: telepathy/interfaces.py
# CONN_MGR_INTERFACE = CONNECTION_MANAGER
# CONN_INTERFACE = CONNECTION
# CHANNEL_INTERFACE = CHANNEL
# CHANNEL_HANDLER_INTERFACE = CHANNEL_HANDLER
# CONN_INTERFACE_ALIASING = CONNECTION_INTERFACE_ALIASING
# CONN_INTERFACE_AVATARS = CONNECTION_INTERFACE_AVATARS
# CONN_INTERFACE_CAPABILITIES = CONNECTION_INTERFACE_CAPABILITIES
# CONN_INTERFACE_PRESENCE = CONNECTION_INTERFACE_PRESENCE
# CONN_INTERFACE_RENAMING = CONNECTION_INTERFACE_RENAMING
# 
# Path: telepathy/constants.py
# CONNECTION_HANDLE_TYPE_NONE = HANDLE_TYPE_NONE
# CONNECTION_HANDLE_TYPE_CONTACT = HANDLE_TYPE_CONTACT
# CONNECTION_HANDLE_TYPE_ROOM = HANDLE_TYPE_ROOM
# CONNECTION_HANDLE_TYPE_LIST = HANDLE_TYPE_LIST
# CONNECTION_HANDLE_TYPE_USER_CONTACT_GROUP = HANDLE_TYPE_GROUP
# 
# Path: telepathy/server/handle.py
# class NoneHandle(Handle):
#     def __init__(self):
#         Handle.__init__(self, 0, HANDLE_TYPE_NONE, '')


import warnings
from telepathy.errors import NotImplemented
from telepathy.interfaces import (CHANNEL_INTERFACE,
                                  CHANNEL_TYPE_CONTACT_LIST)
from telepathy.constants import HANDLE_TYPE_NONE
from telepathy.server.handle import NoneHandle
            handle = self._conn._handles[target_handle_type, target_handle]

        return (type, requested, handle)

    def existing_channel(self, props):
        """ Return a channel corresponding to theses properties if such
        one exists, otherwhise return None. Default implementation will
        return the last created channel of the same kind identified by
        handle and type.
        Connection Manager should subclass this function
        to implement more appropriate behaviour. """

        type, _, handle = self._get_type_requested_handle(props)

        if type in self._channels:
            if handle in self._channels[type]:
                if len(self._channels[type][handle]) > 0:
                    return self._channels[type][handle][-1]

        return None

    def channel_exists(self, props):
        """ Return True if channel exist with theses props, False otherwhise"""
        return self.existing_channel(props) != None

    def create_channel_for_props(self, props, signal=True, **args):
        """Create a new channel with theses properties"""
        type, _, handle = self._get_type_requested_handle(props)

        if type not in self._requestable_channels:

# Path: telepathy/errors.py

# 
# Path: telepathy/interfaces.py
# CONN_MGR_INTERFACE = CONNECTION_MANAGER
# CONN_INTERFACE = CONNECTION
# CHANNEL_INTERFACE = CHANNEL
# CHANNEL_HANDLER_INTERFACE = CHANNEL_HANDLER
# CONN_INTERFACE_ALIASING = CONNECTION_INTERFACE_ALIASING
# CONN_INTERFACE_AVATARS = CONNECTION_INTERFACE_AVATARS
# CONN_INTERFACE_CAPABILITIES = CONNECTION_INTERFACE_CAPABILITIES
# CONN_INTERFACE_PRESENCE = CONNECTION_INTERFACE_PRESENCE
# CONN_INTERFACE_RENAMING = CONNECTION_INTERFACE_RENAMING
# 
# Path: telepathy/constants.py
# CONNECTION_HANDLE_TYPE_NONE = HANDLE_TYPE_NONE
# CONNECTION_HANDLE_TYPE_CONTACT = HANDLE_TYPE_CONTACT
# CONNECTION_HANDLE_TYPE_ROOM = HANDLE_TYPE_ROOM
# CONNECTION_HANDLE_TYPE_LIST = HANDLE_TYPE_LIST
# CONNECTION_HANDLE_TYPE_USER_CONTACT_GROUP = HANDLE_TYPE_GROUP
# 
# Path: telepathy/server/handle.py
# class NoneHandle(Handle):
#     def __init__(self):
#         Handle.__init__(self, 0, HANDLE_TYPE_NONE, '')


# Path: telepathy/server/channelmanager.py
import warnings
from telepathy.errors import NotImplemented
from telepathy.interfaces import (CHANNEL_INTERFACE,
                                  CHANNEL_TYPE_CONTACT_LIST)
from telepathy.constants import HANDLE_TYPE_NONE
from telepathy.server.handle import NoneHandle

            handle = self._conn._handles[target_handle_type, target_handle]

        return (type, requested, handle)

    def existing_channel(self, props):
        """ Return a channel corresponding to theses properties if such
        one exists, otherwhise return None. Default implementation will
        return the last created channel of the same kind identified by
        handle and type.
        Connection Manager should subclass this function
        to implement more appropriate behaviour. """

        type, _, handle = self._get_type_requested_handle(props)

        if type in self._channels:
            if handle in self._channels[type]:
                if len(self._channels[type][handle]) > 0:
                    return self._channels[type][handle][-1]

        return None

    def channel_exists(self, props):
        """ Return True if channel exist with theses props, False otherwhise"""
        return self.existing_channel(props) != None

    def create_channel_for_props(self, props, signal=True, **args):
        """Create a new channel with theses properties"""
        type, _, handle = self._get_type_requested_handle(props)

        if type not in self._requestable_channels:

            raise NotImplemented('Unknown channel type "%s"' % type)