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