Ejemplo n.º 1
0
    def __init__(self, session_manager, peer, peer_guid=None, euf_guid="",
            application_id=0, message=None):
        gobject.GObject.__init__(self)
        EventsDispatcher.__init__(self)
        Timer.__init__(self)
        self._session_manager = session_manager
        self._transport_manager = session_manager._transport_manager
        self._client = session_manager._client
        self._peer = peer
        self._peer_guid = peer_guid

        self._euf_guid = euf_guid
        self._application_id = application_id
        self._completed = False

        self._version = 1
        if self._client.profile.client_id.supports_p2pv2 and \
                peer.client_capabilities.supports_p2pv2:
            self._version = 2

        if message is not None:
            self._id = message.body.session_id
            self._call_id = message.call_id
            self._cseq = message.cseq
            self._branch = message.branch
            self._incoming = True
        else:
            self._id =  self._generate_id()
            self._call_id = "{%s}" % uuid.uuid4()
            self._cseq = 0
            self._branch = "{%s}" % uuid.uuid4()
            self._incoming = False

        self._session_manager._register_session(self)
Ejemplo n.º 2
0
    def __init__(self, session, name, direction, created):
        """Initialize the media stream.

           @param session: Session that contains this stream
           @type session: L{papyon.media.session.MediaSession}
           @param name: Stream name
           @type name: string
           @param direction: Stream direction
           @type direction: L{papyon.media.constants.MediaStreamDirection}
           @param created: Whether or not the stream has been requested by the client
           @type created: bool"""

        gobject.GObject.__init__(self)
        EventsDispatcher.__init__(self)
        self._session = weakref.ref(session)
        self._name = name
        self._active = False
        self._created = created
        self._direction = direction
        self._local_codecs = []
        self._local_codecs_prepared = False
        self._local_candidate_id = None
        self._local_candidates = []
        self._local_candidates_prepared = False
        self._remote_codecs = []
        self._remote_candidate_id = None
        self._remote_candidates = []
        self.relays = []
Ejemplo n.º 3
0
    def __init__(self, session, name, direction, created):
        """Initialize the media stream.

           @param session: Session that contains this stream
           @type session: L{papyon.media.session.MediaSession}
           @param name: Stream name
           @type name: string
           @param direction: Stream direction
           @type direction: L{papyon.media.constants.MediaStreamDirection}
           @param created: Whether or not the stream has been requested by the client
           @type created: bool"""

        gobject.GObject.__init__(self)
        EventsDispatcher.__init__(self)
        self._session = weakref.ref(session)
        self._name = name
        self._active = False
        self._created = created
        self._direction = direction
        self._local_codecs = []
        self._local_codecs_prepared = False
        self._local_candidate_id = None
        self._local_candidates = []
        self._local_candidates_prepared = False
        self._remote_codecs = []
        self._remote_candidate_id = None
        self._remote_candidates = []
        self.relays = []
Ejemplo n.º 4
0
    def __init__(self, server, proxies={}, transport_class=DirectConnection,
            version=15, client_type=msnp.ClientTypes.COMPUTER):
        """Initializer

            @param server: the Notification server to connect to.
            @type server: tuple(host, port)

            @param proxies: proxies that we can use to connect
            @type proxies: {type: string => L{gnet.proxy.ProxyInfos}}

            @param transport_class: the transport class to use for the network
                    connection
            @type transport_class: L{papyon.transport.BaseTransport}"""
        EventsDispatcher.__init__(self)

        self.__state = ClientState.CLOSED

        self._proxies = proxies
        self._transport_class = transport_class
        self._client_type = client_type

        self._transport = transport_class(server, ServerType.NOTIFICATION,
                self._proxies)
        self._protocol = msnp.NotificationProtocol(self, self._transport,
                self._proxies, version)

        self._switchboard_manager = SwitchboardManager(self)
        self._switchboard_manager.register_handler(SwitchboardConversation)

        self._p2p_session_manager = P2PSessionManager(self)
        self._webcam_handler = WebcamHandler(self)
        self._p2p_session_manager.register_handler(self._webcam_handler)

        self._call_manager = SIPConnectionManager(self, self._protocol)

        self._msn_object_store = MSNObjectStore(self)
        self._p2p_session_manager.register_handler(self._msn_object_store)

        self._ft_manager = FileTransferManager(self)
        self._p2p_session_manager.register_handler(self._ft_manager)

        self._external_conversations = {}

        self._sso = None
        self._profile = None
        self._address_book = None
        self._oim_box = None
        self._mailbox = None

        self.__die = False
        self.__connect_transport_signals()
        self.__connect_protocol_signals()
        self.__connect_switchboard_manager_signals()
        self.__connect_webcam_handler_signals()
        self.__connect_call_manager_signals()
        self.__connect_ft_manager_signals()
Ejemplo n.º 5
0
    def __init__(self, server, proxies={}, transport_class=DirectConnection,
            version=15, client_type=msnp.ClientTypes.COMPUTER):
        """Initializer

            @param server: the Notification server to connect to.
            @type server: tuple(host, port)

            @param proxies: proxies that we can use to connect
            @type proxies: {type: string => L{gnet.proxy.ProxyInfos}}

            @param transport_class: the transport class to use for the network
                    connection
            @type transport_class: L{papyon.transport.BaseTransport}"""
        EventsDispatcher.__init__(self)

        self.__state = ClientState.CLOSED

        self._proxies = proxies
        self._transport_class = transport_class
        self._client_type = client_type

        self._transport = transport_class(server, ServerType.NOTIFICATION,
                self._proxies)
        self._protocol = msnp.NotificationProtocol(self, self._transport,
                self._proxies, version)

        self._switchboard_manager = SwitchboardManager(self)
        self._switchboard_manager.register_handler(SwitchboardConversation)

        self._p2p_session_manager = P2PSessionManager(self)
        self._webcam_handler = WebcamHandler(self)
        self._p2p_session_manager.register_handler(self._webcam_handler)

        self._call_manager = SIPConnectionManager(self, self._protocol)

        self._msn_object_store = MSNObjectStore(self)
        self._p2p_session_manager.register_handler(self._msn_object_store)

        self._external_conversations = {}

        self._sso = None
        self._profile = None
        self._address_book = None
        self._oim_box = None
        self._mailbox = None

        self.__die = False
        self.__connect_transport_signals()
        self.__connect_protocol_signals()
        self.__connect_switchboard_manager_signals()
        self.__connect_webcam_handler_signals()
        self.__connect_call_manager_signals()
Ejemplo n.º 6
0
    def __init__(self, type):
        """Initialize the session

           @param type: Session type
           @type type: L{papyon.media.constants.MediaSessionType}
           @param msg_class: The session message class to use (e.g SDPMessage)
           @type msg_class: subclass of L{papyon.media.message.MediaSessionMessage}"""

        gobject.GObject.__init__(self)
        EventsDispatcher.__init__(self)
        self._type = type

        self._streams = []
        self._processing_message = False
        self._signals = {}
Ejemplo n.º 7
0
    def __init__(self, client, type):
        """Initialize the session

           @param client: Papyon client instance
           @type client: L{papyon.Client}
           @param type: Session type
           @type type: L{papyon.media.constants.MediaSessionType}"""

        gobject.GObject.__init__(self)
        EventsDispatcher.__init__(self)
        self._client = client
        self._type = type

        self._streams = []
        self._constructed_streams = []
        self._processing_message = False
        self._signals = {}
Ejemplo n.º 8
0
    def __init__(self, client, type):
        """Initialize the session

           @param client: Papyon client instance
           @type client: L{papyon.Client}
           @param type: Session type
           @type type: L{papyon.media.constants.MediaSessionType}"""

        gobject.GObject.__init__(self)
        EventsDispatcher.__init__(self)
        self._client = client
        self._type = type

        self._streams = []
        self._constructed_streams = []
        self._processing_message = False
        self._signals = {}
Ejemplo n.º 9
0
    def __init__(self, producer, session_manager, peer,
            euf_guid,  message=None):
        if producer:
            type = MediaSessionType.WEBCAM_SEND
        else:
            type = MediaSessionType.WEBCAM_RECV

        P2PSession.__init__(self, session_manager, peer, euf_guid,
                ApplicationID.WEBCAM, message)
        MediaCall.__init__(self, type)
        EventsDispatcher.__init__(self)

        self._producer = producer
        self._answered = False
        self._sent_syn = False
        self._session_id = self._generate_id(9999)
        self._xml_needed = False
Ejemplo n.º 10
0
    def __init__(self, producer, session_manager, peer, euf_guid, message=None):
        P2PSession.__init__(self, session_manager, peer, euf_guid, ApplicationID.WEBCAM)
        EventsDispatcher.__init__(self)

        self._producer = producer

        if message is not None:
            self._call_id = message.call_id
            self._cseq = message.cseq
            self._branch = message.branch
            self._id = message.body.session_id

        self._sent_syn = False
        self._local_candidates = None
        self._remote_candidates = None
        self._session_id = 0
        self._xml_needed = False
        self._session_manager._register_session(self)
Ejemplo n.º 11
0
    def __init__(self, connection, client, peer=None, invite=None, id=None):
        session_type = connection.tunneled and MediaSessionType.TUNNELED_SIP \
                or MediaSessionType.SIP
        SIPBaseCall.__init__(self, connection, client, id)
        MediaCall.__init__(self, session_type)
        EventsDispatcher.__init__(self)

        self._incoming = (id is not None)
        self._accepted = False
        self._rejected = False
        self._answer_sent = False
        self._early = False
        self._state = None
        self._relay_requested = False

        if peer is None and invite is not None:
            peer = self.parse_contact(invite)
        self._peer = peer
        self._invite = invite
Ejemplo n.º 12
0
    def __init__(self,
                 session_manager,
                 peer,
                 peer_guid=None,
                 euf_guid="",
                 application_id=0,
                 message=None):
        gobject.GObject.__init__(self)
        EventsDispatcher.__init__(self)
        Timer.__init__(self)
        self._session_manager = session_manager
        self._transport_manager = session_manager._transport_manager
        self._client = session_manager._client
        self._peer = peer
        self._peer_guid = peer_guid

        self._euf_guid = euf_guid
        self._application_id = application_id
        self._completed = False
        # data to be send if sending
        self._data = None

        self._version = 1
        if self._client.profile.client_id.supports_p2pv2 and \
                peer.client_capabilities.supports_p2pv2:
            self._version = 2

        if message is not None:
            self._id = message.body.session_id
            self._call_id = message.call_id
            self._cseq = message.cseq
            self._branch = message.branch
            self._incoming = True
        else:
            self._id = self._generate_id()
            self._call_id = "{%s}" % uuid.uuid4()
            self._cseq = 0
            self._branch = "{%s}" % uuid.uuid4()
            self._incoming = False

        self._session_manager._register_session(self)
Ejemplo n.º 13
0
    def __init__(self,
                 producer,
                 session_manager,
                 peer,
                 euf_guid,
                 message=None):
        if producer:
            type = MediaSessionType.WEBCAM_SEND
        else:
            type = MediaSessionType.WEBCAM_RECV

        P2PSession.__init__(self, session_manager, peer, euf_guid,
                            ApplicationID.WEBCAM, message)
        MediaCall.__init__(self, type)
        EventsDispatcher.__init__(self)

        self._producer = producer
        self._answered = False
        self._sent_syn = False
        self._session_id = self._generate_id(9999)
        self._xml_needed = False
Ejemplo n.º 14
0
    def __init__(self, client, core, id, peer=None, invite=None):
        gobject.GObject.__init__(self)
        MediaCall.__init__(self, client, MediaSessionType.TUNNELED_SIP)
        RTCActivity.__init__(self, client)
        EventsDispatcher.__init__(self)
        Timer.__init__(self)

        self._core = core
        self._id = id
        self._peer = peer
        self._invite = invite

        self._incoming = (invite is not None)
        self._ringing = False
        self._pending_invite = False
        self._pending_cancel = False

        self._dialogs = []
        self._handles = {}

        if self._incoming:
            self._build_from_invite(invite)
Ejemplo n.º 15
0
    def __init__(self, client):
        self._client = client
        ConversationInterface.__init__(self)
        EventsDispatcher.__init__(self)

        self.__last_received_msn_objects = {}
Ejemplo n.º 16
0
    def __init__(
        self, server, proxies={}, transport_class=DirectConnection, version=15, client_type=msnp.ClientTypes.COMPUTER
    ):
        """Initializer

            @param server: the Notification server to connect to.
            @type server: tuple(host, port)

            @param proxies: proxies that we can use to connect
            @type proxies: {type: string => L{gnet.proxy.ProxyInfos}}
            @note the key should be 'http', 'https' or 'direct'

            @param transport_class: the transport class to use for the network
                    connection
            @type transport_class: L{papyon.transport.BaseTransport}
            
            @param version: protocol version to use (MSNP15, MSNP18...)
            @type version: int
            
            @param client_type: type of client (computer, mobile, web...)
            @type client_type: L{ClientTypes<papyon.msnp.constants.ClientTypes>}"""

        EventsDispatcher.__init__(self)

        self.__state = ClientState.CLOSED

        self._proxies = proxies
        self._transport_class = transport_class
        self._client_type = client_type

        self._transport = transport_class(server, ServerType.NOTIFICATION, self._proxies)
        self._protocol = msnp.NotificationProtocol(self, self._transport, self._proxies, version)

        self._switchboard_manager = SwitchboardManager(self)
        self._switchboard_manager.register_handler_class(SwitchboardConversation)

        self._p2p_session_manager = P2PSessionManager(self)
        self._webcam_handler = WebcamHandler(self)
        self._p2p_session_manager.register_handler(self._webcam_handler)

        self._call_manager = SIPCallManager(self)
        self._rtc_activity_manager = RTCActivityManager(self, self._protocol)

        self._msn_object_store = MSNObjectStore(self)
        self._p2p_session_manager.register_handler(self._msn_object_store)

        self._ft_manager = FileTransferManager(self)
        self._p2p_session_manager.register_handler(self._ft_manager)

        self._external_conversations = {}

        self._sso = None
        self._profile = None
        self._address_book = None
        self._oim_box = None
        self._mailbox = None
        self._roaming = None
        self._turn_client = None

        self.__die = False
        self.__connect_transport_signals()
        self.__connect_protocol_signals()
        self.__connect_switchboard_manager_signals()
        self.__connect_webcam_handler_signals()
        self.__connect_call_manager_signals()
        self.__connect_ft_manager_signals()
Ejemplo n.º 17
0
    def __init__(self, client):
        self._client = client
        ConversationInterface.__init__(self)
        EventsDispatcher.__init__(self)

        self.__last_received_msn_objects = {}
Ejemplo n.º 18
0
    def __init__(self,
                 server,
                 proxies={},
                 transport_class=DirectConnection,
                 version=15,
                 client_type=msnp.ClientTypes.COMPUTER):
        """Initializer

            @param server: the Notification server to connect to.
            @type server: tuple(host, port)

            @param proxies: proxies that we can use to connect
            @type proxies: {type: string => L{gnet.proxy.ProxyInfos}}
            @note the key should be 'http', 'https' or 'direct'

            @param transport_class: the transport class to use for the network
                    connection
            @type transport_class: L{papyon.transport.BaseTransport}
            
            @param version: protocol version to use (MSNP15, MSNP18...)
            @type version: int
            
            @param client_type: type of client (computer, mobile, web...)
            @type client_type: L{ClientTypes<papyon.msnp.constants.ClientTypes>}"""

        EventsDispatcher.__init__(self)

        self.__state = ClientState.CLOSED

        self._proxies = proxies
        self._transport_class = transport_class
        self._client_type = client_type

        self._transport = transport_class(server, ServerType.NOTIFICATION,
                                          self._proxies)
        self._protocol = msnp.NotificationProtocol(self, self._transport,
                                                   self._proxies, version)

        self._switchboard_manager = SwitchboardManager(self)
        self._switchboard_manager.register_handler_class(
            SwitchboardConversation)

        self._p2p_session_manager = P2PSessionManager(self)
        self._webcam_handler = WebcamHandler(self)
        self._p2p_session_manager.register_handler(self._webcam_handler)

        self._call_manager = SIPCallManager(self)
        self._rtc_activity_manager = RTCActivityManager(self, self._protocol)

        self._msn_object_store = MSNObjectStore(self)
        self._p2p_session_manager.register_handler(self._msn_object_store)

        self._ft_manager = FileTransferManager(self)
        self._p2p_session_manager.register_handler(self._ft_manager)

        self._external_conversations = {}

        self._sso = None
        self._profile = None
        self._address_book = None
        self._oim_box = None
        self._mailbox = None
        self._roaming = None
        self._turn_client = None

        self.__keepalive_conversations = False

        self.__die = False
        self.__connect_transport_signals()
        self.__connect_protocol_signals()
        self.__connect_switchboard_manager_signals()
        self.__connect_webcam_handler_signals()
        self.__connect_call_manager_signals()
        self.__connect_ft_manager_signals()