예제 #1
0
    def accept(self, _openfileobj):

        self.state = self.states.CONNECTING

        for stream_type in self.si_handler.supported_streams:
            if stream_type in self.si_ft.feature.possible_streams:
                selected = stream_type
                break
        else:
            assert False

        self._fileobj = _openfileobj
        self.filepath = path(_openfileobj.name)

        si_ft = SI_FileTransfer(self.si_ft.sid)
        si_ft.feature = Feature(selected_stream = selected)
        si_ft.file = File()

        self.bytestream = b = self.si_handler.supported_streams[selected](self.stanza)
        #bind events here
        b.bind("stream_connected", self.transferring)
        b.bind("stream_closed", self.stream_closed)
        b.bind("stream_connect_failed", self.stream_connect_failed)
        b.bind("stream_data_recieved", self.incoming_data)
        b.bind("stream_error", self.stream_error)

        #wrap result in feature ns elem
        self.si_handler.send_accept(self.stanza, si_ft)
예제 #2
0
    def accept(self, _openfileobj):

        self.state = self.states.CONNECTING

        for stream_type in self.si_handler.supported_streams:
            if stream_type in self.si_ft.feature.possible_streams:
                selected = stream_type
                break
        else:
            assert False

        self._fileobj = _openfileobj
        self.filepath = path(_openfileobj.name)

        si_ft = SI_FileTransfer(self.si_ft.sid)
        si_ft.feature = Feature(selected_stream=selected)
        si_ft.file = File()

        self.bytestream = b = self.si_handler.supported_streams[selected](
            self.stanza)
        #bind events here
        b.bind("stream_connected", self.transferring)
        b.bind("stream_closed", self.stream_closed)
        b.bind("stream_connect_failed", self.stream_connect_failed)
        b.bind("stream_data_recieved", self.incoming_data)
        b.bind("stream_error", self.stream_error)

        #wrap result in feature ns elem
        self.si_handler.send_accept(self.stanza, si_ft)
예제 #3
0
    def send_offer(self):
        self.state = self.states.WAITING_FOR_BUDDY

        i = Iq(to_jid=self.jid, stanza_type='set')

        #CAS: id generator for streams
        si = SI_FileTransfer(self.sid)
        si.file = File(self.filestor.name, self.filestor.size)
        si.feature = Feature(possible_streams=supported_streams)
        si.as_xml(i.get_node())

        self.j.send_cb(i, success = self.handle_response,
                          error   = self.handle_error,
                          timeout = self.timed_out)
예제 #4
0
    def send_offer(self):
        self.state = self.states.WAITING_FOR_BUDDY

        i = Iq(to_jid=self.jid, stanza_type='set')

        #CAS: id generator for streams
        si = SI_FileTransfer(self.sid)
        si.file = File(self.filestor.name, self.filestor.size)
        si.feature = Feature(possible_streams=supported_streams)
        si.as_xml(i.get_node())

        self.j.send_cb(i,
                       success=self.handle_response,
                       error=self.handle_error,
                       timeout=self.timed_out)