send RIE stanza as an IQ if user is online and supports RIE. Fixes #7289
This commit is contained in:
		
							parent
							
								
									577c7221f6
								
							
						
					
					
						commit
						e59c4bbfad
					
				
					 2 changed files with 22 additions and 13 deletions
				
			
		| 
						 | 
				
			
			@ -1879,26 +1879,30 @@ class Connection(CommonConnection, ConnectionHandlers):
 | 
			
		|||
            form_node=obj.form_node, original_message=obj.original_message,
 | 
			
		||||
            delayed=obj.delayed, attention=obj.attention, callback=cb)
 | 
			
		||||
 | 
			
		||||
    def send_contacts(self, contacts, jid):
 | 
			
		||||
    def send_contacts(self, contacts, fjid, type_='message'):
 | 
			
		||||
        """
 | 
			
		||||
        Send contacts with RosterX (Xep-0144)
 | 
			
		||||
        """
 | 
			
		||||
        if not gajim.account_is_connected(self.name):
 | 
			
		||||
            return
 | 
			
		||||
        if len(contacts) == 1:
 | 
			
		||||
            msg = _('Sent contact: "%s" (%s)') % (contacts[0].get_full_jid(),
 | 
			
		||||
        if type_ == 'message':
 | 
			
		||||
            if len(contacts) == 1:
 | 
			
		||||
                msg = _('Sent contact: "%s" (%s)') % (contacts[0].get_full_jid(),
 | 
			
		||||
                    contacts[0].get_shown_name())
 | 
			
		||||
        else:
 | 
			
		||||
            msg = _('Sent contacts:')
 | 
			
		||||
            for contact in contacts:
 | 
			
		||||
                msg += '\n "%s" (%s)' % (contact.get_full_jid(),
 | 
			
		||||
            else:
 | 
			
		||||
                msg = _('Sent contacts:')
 | 
			
		||||
                for contact in contacts:
 | 
			
		||||
                    msg += '\n "%s" (%s)' % (contact.get_full_jid(),
 | 
			
		||||
                        contact.get_shown_name())
 | 
			
		||||
        msg_iq = nbxmpp.Message(to=jid, body=msg)
 | 
			
		||||
        x = msg_iq.addChild(name='x', namespace=nbxmpp.NS_ROSTERX)
 | 
			
		||||
            stanza = nbxmpp.Message(to=gajim.get_jid_without_resource(fjid),
 | 
			
		||||
                body=msg)
 | 
			
		||||
        elif type_ == 'iq':
 | 
			
		||||
            stanza = nbxmpp.Iq(to=fjid, typ='set')
 | 
			
		||||
        x = stanza.addChild(name='x', namespace=nbxmpp.NS_ROSTERX)
 | 
			
		||||
        for contact in contacts:
 | 
			
		||||
            x.addChild(name='item', attrs={'action': 'add', 'jid': contact.jid,
 | 
			
		||||
                    'name': contact.get_shown_name()})
 | 
			
		||||
        self.connection.send(msg_iq)
 | 
			
		||||
                'name': contact.get_shown_name()})
 | 
			
		||||
        self.connection.send(stanza)
 | 
			
		||||
 | 
			
		||||
    def send_stanza(self, stanza):
 | 
			
		||||
        """
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -72,7 +72,7 @@ from common import dbus_support
 | 
			
		|||
if dbus_support.supported:
 | 
			
		||||
    import dbus
 | 
			
		||||
 | 
			
		||||
from nbxmpp.protocol import NS_FILE
 | 
			
		||||
from nbxmpp.protocol import NS_FILE, NS_ROSTERX
 | 
			
		||||
from common.pep import MOODS, ACTIVITIES
 | 
			
		||||
 | 
			
		||||
#(icon, name, type, jid, account, editable, second pixbuf)
 | 
			
		||||
| 
						 | 
				
			
			@ -4529,7 +4529,12 @@ class RosterWindow:
 | 
			
		|||
 | 
			
		||||
    def on_drop_rosterx(self, widget, account_source, c_source, account_dest,
 | 
			
		||||
    c_dest, was_big_brother, context, etime):
 | 
			
		||||
        gajim.connections[account_dest].send_contacts([c_source], c_dest.jid)
 | 
			
		||||
        type_ = 'message'
 | 
			
		||||
        if c_dest.show not in ('offline', 'error') and c_dest.supports(
 | 
			
		||||
        NS_ROSTERX):
 | 
			
		||||
            type_ = 'iq'
 | 
			
		||||
        gajim.connections[account_dest].send_contacts([c_source],
 | 
			
		||||
             c_dest.get_full_jid(), type_=type_)
 | 
			
		||||
 | 
			
		||||
    def on_drop_in_contact(self, widget, account_source, c_source, account_dest,
 | 
			
		||||
    c_dest, was_big_brother, context, etime):
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
	Add table
		
		Reference in a new issue