support direct invitation (XEP-0249). Fixes #7581
This commit is contained in:
parent
349048d937
commit
5095bc6598
|
@ -1383,8 +1383,7 @@ class Connection(CommonConnection, ConnectionHandlers):
|
||||||
errnum = con.Connection.ssl_errnum
|
errnum = con.Connection.ssl_errnum
|
||||||
except AttributeError:
|
except AttributeError:
|
||||||
errnum = [] # we don't have an errnum
|
errnum = [] # we don't have an errnum
|
||||||
i = 0
|
for i, er in enumerate(errnum):
|
||||||
for er in errnum:
|
|
||||||
if er > 0 and str(er) not in gajim.config.get_per('accounts',
|
if er > 0 and str(er) not in gajim.config.get_per('accounts',
|
||||||
self.name, 'ignore_ssl_errors').split():
|
self.name, 'ignore_ssl_errors').split():
|
||||||
text = _('The authenticity of the %s certificate could be '
|
text = _('The authenticity of the %s certificate could be '
|
||||||
|
@ -1399,7 +1398,6 @@ class Connection(CommonConnection, ConnectionHandlers):
|
||||||
fingerprint=con.Connection.ssl_fingerprint_sha1[i],
|
fingerprint=con.Connection.ssl_fingerprint_sha1[i],
|
||||||
certificate=con.Connection.ssl_certificate[i]))
|
certificate=con.Connection.ssl_certificate[i]))
|
||||||
return True
|
return True
|
||||||
i += 1
|
|
||||||
if len(con.Connection.ssl_fingerprint_sha1):
|
if len(con.Connection.ssl_fingerprint_sha1):
|
||||||
saved_fingerprint = gajim.config.get_per('accounts', self.name,
|
saved_fingerprint = gajim.config.get_per('accounts', self.name,
|
||||||
'ssl_fingerprint_sha1')
|
'ssl_fingerprint_sha1')
|
||||||
|
@ -2846,6 +2844,19 @@ class Connection(CommonConnection, ConnectionHandlers):
|
||||||
"""
|
"""
|
||||||
Send invitation
|
Send invitation
|
||||||
"""
|
"""
|
||||||
|
contact = gajim.contacts.get_contact_from_full_jid(self.name, to)
|
||||||
|
if contact and contact.supports(nbxmpp.NS_CONFERENCE):
|
||||||
|
# send direct invite
|
||||||
|
message=nbxmpp.Message(to=to)
|
||||||
|
attrs = {'jid': room}
|
||||||
|
if reason:
|
||||||
|
attrs['reason'] = reason
|
||||||
|
if continue_tag:
|
||||||
|
attrs['continue'] = 'true'
|
||||||
|
c = message.addChild(name='x', attrs=attrs,
|
||||||
|
namespace=nbxmpp.NS_CONFERENCE)
|
||||||
|
self.connection.send(message)
|
||||||
|
return
|
||||||
message=nbxmpp.Message(to=room)
|
message=nbxmpp.Message(to=room)
|
||||||
c = message.addChild(name='x', namespace=nbxmpp.NS_MUC_USER)
|
c = message.addChild(name='x', namespace=nbxmpp.NS_MUC_USER)
|
||||||
c = c.addChild(name='invite', attrs={'to': to})
|
c = c.addChild(name='invite', attrs={'to': to})
|
||||||
|
|
|
@ -1077,10 +1077,15 @@ class MessageReceivedEvent(nec.NetworkIncomingEvent, HelperEvent):
|
||||||
self.invite_tag = None
|
self.invite_tag = None
|
||||||
self.decline_tag = None
|
self.decline_tag = None
|
||||||
if not self.enc_tag:
|
if not self.enc_tag:
|
||||||
|
# Direct invitation?
|
||||||
self.invite_tag = self.stanza.getTag('x',
|
self.invite_tag = self.stanza.getTag('x',
|
||||||
namespace=nbxmpp.NS_MUC_USER)
|
namespace=nbxmpp.NS_CONFERENCE)
|
||||||
if self.invite_tag and not self.invite_tag.getTag('invite'):
|
# Mediated invitation?
|
||||||
self.invite_tag = None
|
if not self.invite_tag:
|
||||||
|
self.invite_tag = self.stanza.getTag('x',
|
||||||
|
namespace=nbxmpp.NS_MUC_USER)
|
||||||
|
if self.invite_tag and not self.invite_tag.getTag('invite'):
|
||||||
|
self.invite_tag = None
|
||||||
|
|
||||||
self.decline_tag = self.stanza.getTag('x',
|
self.decline_tag = self.stanza.getTag('x',
|
||||||
namespace=nbxmpp.NS_MUC_USER)
|
namespace=nbxmpp.NS_MUC_USER)
|
||||||
|
@ -1193,25 +1198,47 @@ class GcInvitationReceivedEvent(nec.NetworkIncomingEvent):
|
||||||
base_network_events = []
|
base_network_events = []
|
||||||
|
|
||||||
def generate(self):
|
def generate(self):
|
||||||
self.room_jid = self.msg_obj.fjid
|
invite_tag = self.msg_obj.invite_tag
|
||||||
|
if invite_tag.getNamespace() == nbxmpp.NS_CONFERENCE:
|
||||||
|
# direct invitation
|
||||||
|
try:
|
||||||
|
self.room_jid = helpers.parse_jid(invite_tag.getAttr('jid'))
|
||||||
|
except helpers.InvalidFormat:
|
||||||
|
log.warn('Invalid JID: %s, ignoring it' % invite_tag.getAttr(
|
||||||
|
'jid'))
|
||||||
|
return
|
||||||
|
self.jid_from = self.msg_obj.fjid
|
||||||
|
self.reason = invite_tag.getAttr('reason')
|
||||||
|
self.password = invite_tag.getAttr('password')
|
||||||
|
self.is_continued = False
|
||||||
|
if invite_tag.getAttr('continue') == 'true':
|
||||||
|
self.is_continued = True
|
||||||
|
else
|
||||||
|
self.room_jid = self.msg_obj.fjid
|
||||||
|
item = self.msg_obj.invite_tag.getTag('invite')
|
||||||
|
try:
|
||||||
|
self.jid_from = helpers.parse_jid(item.getAttr('from'))
|
||||||
|
except helpers.InvalidFormat:
|
||||||
|
log.warning('Invalid JID: %s, ignoring it' % item.getAttr(
|
||||||
|
'from'))
|
||||||
|
return
|
||||||
|
|
||||||
item = self.msg_obj.invite_tag.getTag('invite')
|
self.reason = item.getTagData('reason')
|
||||||
try:
|
self.password = invite_tag.getTagData('password')
|
||||||
self.jid_from = helpers.parse_jid(item.getAttr('from'))
|
|
||||||
except helpers.InvalidFormat:
|
self.is_continued = False
|
||||||
log.warning('Invalid JID: %s, ignoring it' % item.getAttr('from'))
|
if item.getTag('continue'):
|
||||||
|
self.is_continued = True
|
||||||
|
|
||||||
|
if self.room_jid in gajim.gc_connected[self.conn.name] and \
|
||||||
|
gajim.gc_connected[self.conn.name][self.room_jid]:
|
||||||
|
# We are already in groupchat. Ignore invitation
|
||||||
return
|
return
|
||||||
jid = gajim.get_jid_without_resource(self.jid_from)
|
jid = gajim.get_jid_without_resource(self.jid_from)
|
||||||
if gajim.config.get_per('accounts', self.conn.name,
|
if gajim.config.get_per('accounts', self.conn.name,
|
||||||
'ignore_unknown_contacts') and not gajim.contacts.get_contacts(
|
'ignore_unknown_contacts') and not gajim.contacts.get_contacts(
|
||||||
self.conn.name, jid):
|
self.conn.name, jid):
|
||||||
return
|
return
|
||||||
self.reason = item.getTagData('reason')
|
|
||||||
self.password = self.msg_obj.invite_tag.getTagData('password')
|
|
||||||
|
|
||||||
self.is_continued = False
|
|
||||||
if item.getTag('continue'):
|
|
||||||
self.is_continued = True
|
|
||||||
|
|
||||||
return True
|
return True
|
||||||
|
|
||||||
|
|
|
@ -488,6 +488,7 @@ class Contacts():
|
||||||
for c in self._contacts[jid]:
|
for c in self._contacts[jid]:
|
||||||
if c.resource == resource:
|
if c.resource == resource:
|
||||||
return c
|
return c
|
||||||
|
return self._contacts[jid][0]
|
||||||
|
|
||||||
def iter_contacts(self):
|
def iter_contacts(self):
|
||||||
for jid in list(self._contacts.keys()):
|
for jid in list(self._contacts.keys()):
|
||||||
|
|
|
@ -212,7 +212,7 @@ gajim_common_features = [nbxmpp.NS_BYTESTREAM, nbxmpp.NS_SI, nbxmpp.NS_FILE,
|
||||||
nbxmpp.NS_SSN, nbxmpp.NS_MOOD, nbxmpp.NS_ACTIVITY, nbxmpp.NS_NICK,
|
nbxmpp.NS_SSN, nbxmpp.NS_MOOD, nbxmpp.NS_ACTIVITY, nbxmpp.NS_NICK,
|
||||||
nbxmpp.NS_ROSTERX, nbxmpp.NS_SECLABEL, nbxmpp.NS_HASHES,
|
nbxmpp.NS_ROSTERX, nbxmpp.NS_SECLABEL, nbxmpp.NS_HASHES,
|
||||||
nbxmpp.NS_HASHES_MD5, nbxmpp.NS_HASHES_SHA1, nbxmpp.NS_HASHES_SHA256,
|
nbxmpp.NS_HASHES_MD5, nbxmpp.NS_HASHES_SHA1, nbxmpp.NS_HASHES_SHA256,
|
||||||
nbxmpp.NS_HASHES_SHA512, nbxmpp.NS_CORRECT]
|
nbxmpp.NS_HASHES_SHA512, nbxmpp.NS_CORRECT, nbxmpp.NS_CONFERENCE]
|
||||||
|
|
||||||
# Optional features gajim supports per account
|
# Optional features gajim supports per account
|
||||||
gajim_optional_features = {}
|
gajim_optional_features = {}
|
||||||
|
|
|
@ -3335,7 +3335,7 @@ class RosterWindow:
|
||||||
break
|
break
|
||||||
|
|
||||||
def on_invite_to_room(self, widget, list_, room_jid, room_account,
|
def on_invite_to_room(self, widget, list_, room_jid, room_account,
|
||||||
resource=None):
|
resource=None):
|
||||||
"""
|
"""
|
||||||
Resource parameter MUST NOT be used if more than one contact in list
|
Resource parameter MUST NOT be used if more than one contact in list
|
||||||
"""
|
"""
|
||||||
|
|
Loading…
Reference in New Issue