diff --git a/gajim/chat_control.py b/gajim/chat_control.py index f0acdb206c93295e79f2b6860b2043ecc6d7500d..a2756a525320d2f27a33af5029ce4b939fddb78b 100644 --- a/gajim/chat_control.py +++ b/gajim/chat_control.py @@ -36,7 +36,6 @@ from gi.repository import Gdk from nbxmpp.protocol import NS_XHTML_IM -from nbxmpp.protocol import NS_FILE from nbxmpp.protocol import NS_MUC from nbxmpp.protocol import NS_JINGLE_RTP_AUDIO from nbxmpp.protocol import NS_JINGLE_RTP_VIDEO @@ -313,10 +312,8 @@ def update_actions(self): online and con.get_module('HTTPUpload').available) # Send file (Jingle) - jingle_conditions = ( - (self.contact.supports(NS_FILE) or - self.contact.supports(NS_JINGLE_FILE_TRANSFER_5)) and - self.contact.show != 'offline') + jingle_support = self.contact.supports(NS_JINGLE_FILE_TRANSFER_5) + jingle_conditions = jingle_support and self.contact.show != 'offline' jingle = win.lookup_action('send-file-jingle-' + self.control_id) jingle.set_enabled(online and jingle_conditions) diff --git a/gajim/common/app.py b/gajim/common/app.py index 08b06c3620ab7d16b36909b6ad2b34044968f2d1..8a09158e7affb83cc482f206cd422c91e3fcc50a 100644 --- a/gajim/common/app.py +++ b/gajim/common/app.py @@ -148,7 +148,6 @@ gajim_common_features = [ nbxmpp.NS_BYTESTREAM, - nbxmpp.NS_FILE, nbxmpp.NS_MUC, nbxmpp.NS_COMMANDS, nbxmpp.NS_DISCO_INFO, diff --git a/gajim/common/connection_handlers_events.py b/gajim/common/connection_handlers_events.py index a3534fb0c0742b33b1ccd963483a00746be3af1a..186e528c37226e08a6c87e141cd6845c07d96d5c 100644 --- a/gajim/common/connection_handlers_events.py +++ b/gajim/common/connection_handlers_events.py @@ -21,7 +21,6 @@ import OpenSSL.crypto import nbxmpp -from nbxmpp.modules import dataforms from gajim.common import nec from gajim.common import helpers @@ -148,104 +147,65 @@ def generate(self): self.id_ = self.stanza.getID() self.fjid = self.conn.get_module('Bytestream')._ft_get_from(self.stanza) self.jid = app.get_jid_without_resource(self.fjid) - if self.jingle_content: - secu = self.jingle_content.getTag('security') - self.FT_content.use_security = bool(secu) - if secu: - fingerprint = secu.getTag('fingerprint') - if fingerprint: - self.FT_content.x509_fingerprint = fingerprint.getData() - if not self.FT_content.transport: - self.FT_content.transport = JingleTransportSocks5() - self.FT_content.transport.set_our_jid( - self.FT_content.session.ourjid) - self.FT_content.transport.set_connection( - self.FT_content.session.connection) - sid = self.stanza.getTag('jingle').getAttr('sid') - self.file_props = FilesProp.getNewFileProp(self.conn.name, sid) - self.file_props.transport_sid = self.FT_content.transport.sid - self.FT_content.file_props = self.file_props - self.FT_content.transport.set_file_props(self.file_props) - self.file_props.streamhosts.extend( - self.FT_content.transport.remote_candidates) - for host in self.file_props.streamhosts: - host['initiator'] = self.FT_content.session.initiator - host['target'] = self.FT_content.session.responder - self.file_props.session_type = 'jingle' - self.file_props.stream_methods = nbxmpp.NS_BYTESTREAM - desc = self.jingle_content.getTag('description') - if self.jingle_content.getAttr('creator') == 'initiator': - file_tag = desc.getTag('file') - self.file_props.sender = self.fjid - self.file_props.receiver = self.conn.get_module('Bytestream')._ft_get_our_jid() - else: - file_tag = desc.getTag('file') - h = file_tag.getTag('hash') - h = h.getData() if h else None - n = file_tag.getTag('name') - n = n.getData() if n else None - pjid = app.get_jid_without_resource(self.fjid) - file_info = self.conn.get_module('Jingle').get_file_info( - pjid, hash_=h, name=n, account=self.conn.name) - self.file_props.file_name = file_info['file-name'] - self.file_props.sender = self.conn.get_module('Bytestream')._ft_get_our_jid() - self.file_props.receiver = self.fjid - self.file_props.type_ = 's' - for child in file_tag.getChildren(): - name = child.getName() - val = child.getData() - if val is None: - continue - if name == 'name': - self.file_props.name = val - if name == 'size': - self.file_props.size = int(val) - if name == 'hash': - self.file_props.algo = child.getAttr('algo') - self.file_props.hash_ = val - if name == 'date': - self.file_props.date = val - else: - si = self.stanza.getTag('si') - self.file_props = FilesProp.getNewFileProp(self.conn.name, - si.getAttr('id')) - self.file_props.transport_sid = self.file_props.sid - profile = si.getAttr('profile') - if profile != nbxmpp.NS_FILE: - self.conn.get_module('Bytestream').send_file_rejection(self.file_props, code='400', - typ='profile') - raise nbxmpp.NodeProcessed - feature_tag = si.getTag('feature', namespace=nbxmpp.NS_FEATURE) - if not feature_tag: - return - form_tag = feature_tag.getTag('x', namespace=nbxmpp.NS_DATA) - if not form_tag: - return - self.dataform = dataforms.extend_form(node=form_tag) - for f in self.dataform.iter_fields(): - if f.var == 'stream-method' and f.type_ == 'list-single': - values = [o[1] for o in f.options] - self.file_props.stream_methods = ' '.join(values) - if nbxmpp.NS_BYTESTREAM in values or \ - nbxmpp.NS_IBB in values: - break - else: - self.conn.get_module('Bytestream').send_file_rejection(self.file_props, code='400', - typ='stream') - raise nbxmpp.NodeProcessed - file_tag = si.getTag('file') - for name, val in file_tag.getAttrs().items(): - if val is None: - continue - if name == 'name': - self.file_props.name = val - if name == 'size': - self.file_props.size = int(val) - mime_type = si.getAttr('mime-type') - if mime_type is not None: - self.file_props.mime_type = mime_type + if not self.jingle_content: + return + secu = self.jingle_content.getTag('security') + self.FT_content.use_security = bool(secu) + if secu: + fingerprint = secu.getTag('fingerprint') + if fingerprint: + self.FT_content.x509_fingerprint = fingerprint.getData() + if not self.FT_content.transport: + self.FT_content.transport = JingleTransportSocks5() + self.FT_content.transport.set_our_jid( + self.FT_content.session.ourjid) + self.FT_content.transport.set_connection( + self.FT_content.session.connection) + sid = self.stanza.getTag('jingle').getAttr('sid') + self.file_props = FilesProp.getNewFileProp(self.conn.name, sid) + self.file_props.transport_sid = self.FT_content.transport.sid + self.FT_content.file_props = self.file_props + self.FT_content.transport.set_file_props(self.file_props) + self.file_props.streamhosts.extend( + self.FT_content.transport.remote_candidates) + for host in self.file_props.streamhosts: + host['initiator'] = self.FT_content.session.initiator + host['target'] = self.FT_content.session.responder + self.file_props.session_type = 'jingle' + self.file_props.stream_methods = nbxmpp.NS_BYTESTREAM + desc = self.jingle_content.getTag('description') + if self.jingle_content.getAttr('creator') == 'initiator': + file_tag = desc.getTag('file') self.file_props.sender = self.fjid self.file_props.receiver = self.conn.get_module('Bytestream')._ft_get_our_jid() + else: + file_tag = desc.getTag('file') + h = file_tag.getTag('hash') + h = h.getData() if h else None + n = file_tag.getTag('name') + n = n.getData() if n else None + pjid = app.get_jid_without_resource(self.fjid) + file_info = self.conn.get_module('Jingle').get_file_info( + pjid, hash_=h, name=n, account=self.conn.name) + self.file_props.file_name = file_info['file-name'] + self.file_props.sender = self.conn.get_module('Bytestream')._ft_get_our_jid() + self.file_props.receiver = self.fjid + self.file_props.type_ = 's' + for child in file_tag.getChildren(): + name = child.getName() + val = child.getData() + if val is None: + continue + if name == 'name': + self.file_props.name = val + if name == 'size': + self.file_props.size = int(val) + if name == 'hash': + self.file_props.algo = child.getAttr('algo') + self.file_props.hash_ = val + if name == 'date': + self.file_props.date = val + self.file_props.request_id = self.id_ file_desc_tag = file_tag.getTag('desc') if file_desc_tag is not None: diff --git a/gajim/gui_menu_builder.py b/gajim/gui_menu_builder.py index bd9c8e9e78c51bce327960c26d7df91334ea75e0..04e2f01f55011cdf44ea840a222f35a3983b9f6f 100644 --- a/gajim/gui_menu_builder.py +++ b/gajim/gui_menu_builder.py @@ -15,7 +15,7 @@ # along with Gajim. If not, see <http://www.gnu.org/licenses/>. from gi.repository import Gtk, Gio, GLib -from nbxmpp.protocol import NS_COMMANDS, NS_FILE +from nbxmpp.protocol import NS_COMMANDS from nbxmpp.protocol import NS_JINGLE_FILE_TRANSFER_5, NS_CONFERENCE from gajim import gtkgui_helpers @@ -208,14 +208,17 @@ def get_contact_menu(contact, account, use_multiple_contacts=True, if len(contacts) > 1 and use_multiple_contacts: # several resources start_chat_menuitem.set_submenu(build_resources_submenu(contacts, account, app.interface.on_open_chat_window)) - send_file_menuitem.set_submenu(build_resources_submenu(contacts, - account, roster.on_send_file_menuitem_activate, cap=NS_FILE)) + send_file_menuitem.set_submenu(build_resources_submenu( + contacts, + account, + roster.on_send_file_menuitem_activate, + cap=NS_JINGLE_FILE_TRANSFER_5)) execute_command_menuitem.set_submenu(build_resources_submenu( contacts, account, roster.on_execute_command, cap=NS_COMMANDS)) else: start_chat_menuitem.connect('activate', app.interface.on_open_chat_window, contact, account) - if contact.supports(NS_FILE) or contact.supports(NS_JINGLE_FILE_TRANSFER_5): + if contact.supports(NS_JINGLE_FILE_TRANSFER_5): send_file_menuitem.set_sensitive(True) send_file_menuitem.connect('activate', roster.on_send_file_menuitem_activate, contact, account) diff --git a/gajim/roster_window.py b/gajim/roster_window.py index f3ccd4550889483527cc79fe0558b89e40afcfca..22763e4600491b10bd18b6980c4c72156c51d034 100644 --- a/gajim/roster_window.py +++ b/gajim/roster_window.py @@ -41,7 +41,9 @@ from gi.repository import GObject from gi.repository import GLib from gi.repository import Gio -from nbxmpp.protocol import NS_FILE, NS_ROSTERX, NS_CONFERENCE +from nbxmpp.protocol import NS_ROSTERX +from nbxmpp.protocol import NS_CONFERENCE +from nbxmpp.protocol import NS_JINGLE_FILE_TRANSFER_5 from nbxmpp.structs import MoodData from nbxmpp.structs import ActivityData @@ -4191,7 +4193,7 @@ def drag_data_received_data(self, treeview, context, x, y, selection, info, return c_dest = app.contacts.get_contact_with_highest_priority( account_dest, jid_dest) - if not c_dest.supports(NS_FILE): + if not c_dest.supports(NS_JINGLE_FILE_TRANSFER_5): return uri = data.strip() uri_splitted = uri.split() # we may have more than one file dropped