Beispiel #1
0
 def start_whiteboard(self):
     conn = app.connections[self.chat_control.account]
     jingle = JingleSession(conn, weinitiate=True, jid=self.jid)
     self.sid = jingle.sid
     conn.get_module('Jingle')._sessions[jingle.sid] = jingle
     content = JingleWhiteboard(jingle)
     content.control = self
     jingle.add_content('xhtml', content)
     jingle.start_session()
Beispiel #2
0
 def start_audio(self, jid):
     if self.get_jingle_session(jid, media='audio'):
         return self.get_jingle_session(jid, media='audio').sid
     jingle = self.get_jingle_session(jid, media='video')
     if jingle:
         jingle.add_content('voice', JingleAudio(jingle))
     else:
         jingle = JingleSession(self._con, weinitiate=True, jid=jid)
         self._sessions[jingle.sid] = jingle
         jingle.add_content('voice', JingleAudio(jingle))
         jingle.start_session()
     return jingle.sid
Beispiel #3
0
 def start_video(self, jid, in_xid, out_xid):
     if self.get_jingle_session(jid, media='video'):
         return self.get_jingle_session(jid, media='video').sid
     jingle = self.get_jingle_session(jid, media='audio')
     if jingle:
         jingle.add_content(
             'video', JingleVideo(jingle, in_xid=in_xid, out_xid=out_xid))
     else:
         jingle = JingleSession(self, weinitiate=True, jid=jid)
         self._sessions[jingle.sid] = jingle
         jingle.add_content(
             'video', JingleVideo(jingle, in_xid=in_xid, out_xid=out_xid))
         jingle.start_session()
     return jingle.sid
Beispiel #4
0
    def start_file_transfer(self, jid, file_props, request=False):
        logger.info("start file transfer with file: %s", file_props)
        contact = app.contacts.get_contact_with_highest_priority(
            self._account, app.get_jid_without_resource(jid))
        if app.contacts.is_gc_contact(self._account, jid):
            gcc = jid.split('/')
            if len(gcc) == 2:
                contact = app.contacts.get_gc_contact(self._account,
                                                      gcc[0],
                                                      gcc[1])
        if contact is None:
            return None
        use_security = contact.supports(Namespace.JINGLE_XTLS)
        jingle = JingleSession(self._con,
                               weinitiate=True,
                               jid=jid,
                               werequest=request)
        # this is a file transfer
        jingle.session_type_ft = True
        self._sessions[jingle.sid] = jingle
        file_props.sid = jingle.sid

        if contact.supports(Namespace.JINGLE_BYTESTREAM):
            transport = JingleTransportSocks5()
        elif contact.supports(Namespace.JINGLE_IBB):
            transport = JingleTransportIBB()
        else:
            transport = None

        senders = 'initiator'
        if request:
            senders = 'responder'
        transfer = JingleFileTransfer(jingle,
                                      transport=transport,
                                      file_props=file_props,
                                      use_security=use_security,
                                      senders=senders)
        file_props.transport_sid = transport.sid
        file_props.algo = self.__hash_support(contact)
        jingle.add_content('file' + helpers.get_random_string(), transfer)
        jingle.start_session()
        return transfer.transport.sid
Beispiel #5
0
    def start_audio_video(self, jid):
        if self.get_jingle_session(jid, media='video'):
            return self.get_jingle_session(jid, media='video').sid
        audio_session = self.get_jingle_session(jid, media='audio')
        video_session = self.get_jingle_session(jid, media='video')
        if audio_session and video_session:
            return audio_session.sid
        if audio_session:
            video = JingleVideo(audio_session)
            audio_session.add_content('video', video)
            return audio_session.sid
        if video_session:
            audio = JingleAudio(video_session)
            video_session.add_content('audio', audio)
            return video_session.sid

        jingle_session = JingleSession(self._con, weinitiate=True, jid=jid)
        self._sessions[jingle_session.sid] = jingle_session
        audio = JingleAudio(jingle_session)
        video = JingleVideo(jingle_session)
        jingle_session.add_content('audio', audio)
        jingle_session.add_content('video', video)
        jingle_session.start_session()
        return jingle_session.sid