Ejemplo n.º 1
0
 def _connect_error(self, sid, error, error_type, msg=None):
     """
     Called when there is an error establishing BS connection, or when
     connection is rejected
     """
     if not app.account_is_connected(self._account):
         return
     file_props = FilesProp.getFileProp(self._account, sid)
     if file_props is None:
         log.error('can not send iq error on failed transfer')
         return
     if file_props.type_ == 's':
         to = file_props.receiver
     else:
         to = file_props.sender
     iq = nbxmpp.Iq(to=to, typ='error')
     iq.setAttr('id', file_props.request_id)
     err = iq.setTag('error')
     err.setAttr('type', error_type)
     err.setTag(error, namespace=nbxmpp.NS_STANZAS)
     self._con.connection.send(iq)
     if msg:
         self.disconnect_transfer(file_props)
         file_props.error = -3
         from gajim.common.connection_handlers_events import \
             FileRequestErrorEvent
         app.nec.push_incoming_event(FileRequestErrorEvent(None,
             conn=self._con, jid=to, file_props=file_props, error_msg=msg))
Ejemplo n.º 2
0
    def _send_socks5_info(self, file_props):
        """
        Send iq for the present streamhosts and proxies
        """
        if not app.account_is_connected(self._account):
            return
        receiver = file_props.receiver
        sender = file_props.sender

        sha_str = helpers.get_auth_sha(file_props.sid, sender, receiver)
        file_props.sha_str = sha_str

        port = app.config.get('file_transfers_port')
        listener = app.socks5queue.start_listener(port, sha_str,
                self._result_socks5_sid, file_props)
        if not listener:
            file_props.error = -5
            from gajim.common.connection_handlers_events import FileRequestErrorEvent
            app.nec.push_incoming_event(FileRequestErrorEvent(None, conn=self._con,
                jid=receiver, file_props=file_props, error_msg=''))
            self._connect_error(file_props.sid, error='not-acceptable',
                error_type='modify')
        else:
            iq = nbxmpp.Iq(to=receiver, typ='set')
            file_props.request_id = 'id_' + file_props.sid
            iq.setID(file_props.request_id)
            query = iq.setTag('query', namespace=nbxmpp.NS_BYTESTREAM)
            query.setAttr('sid', file_props.sid)

            self._add_addiditional_streamhosts_to_query(query, file_props)
            self._add_local_ips_as_streamhosts_to_query(query, file_props)
            self._add_proxy_streamhosts_to_query(query, file_props)
            self._add_upnp_igd_as_streamhost_to_query(query, file_props, iq)
Ejemplo n.º 3
0
 def _bytestreamErrorCB(self, con, iq_obj):
     id_ = iq_obj.getAttr('id')
     frm = helpers.get_full_jid_from_iq(iq_obj)
     query = iq_obj.getTag('query')
     app.proxy65_manager.error_cb(frm, query)
     jid = helpers.get_jid_from_iq(iq_obj)
     id_ = id_[3:]
     file_props = FilesProp.getFilePropBySid(id_)
     if not file_props:
         return
     file_props.error = -4
     from gajim.common.connection_handlers_events import FileRequestErrorEvent
     app.nec.push_incoming_event(FileRequestErrorEvent(None, conn=self._con,
         jid=jid, file_props=file_props, error_msg=''))
     raise nbxmpp.NodeProcessed
Ejemplo n.º 4
0
 def _siErrorCB(self, con, iq_obj):
     si = iq_obj.getTag('si')
     profile = si.getAttr('profile')
     if profile != nbxmpp.NS_FILE:
         return
     file_props = FilesProp.getFileProp(self.name, iq_obj.getAttr('id'))
     if not file_props:
         return
     jid = self._ft_get_from(iq_obj)
     file_props.error = -3
     from gajim.common.connection_handlers_events import FileRequestErrorEvent
     app.nec.push_incoming_event(
         FileRequestErrorEvent(None,
                               conn=self,
                               jid=jid,
                               file_props=file_props,
                               error_msg=''))
     raise nbxmpp.NodeProcessed
Ejemplo n.º 5
0
 def stop_all_active_file_transfers(self, contact):
     """
     Stop all active transfer to or from the given contact
     """
     for file_props in FilesProp.getAllFileProp():
         if is_transfer_stopped(file_props):
             continue
         receiver_jid = file_props.receiver
         if contact.get_full_jid() == receiver_jid:
             file_props.error = -5
             self.remove_transfer(file_props)
             from gajim.common.connection_handlers_events import \
                 FileRequestErrorEvent
             app.nec.push_incoming_event(FileRequestErrorEvent(None,
                 conn=self._con, jid=contact.jid, file_props=file_props,
                 error_msg=''))
         sender_jid = file_props.sender
         if contact.get_full_jid() == sender_jid:
             file_props.error = -3
             self.remove_transfer(file_props)