mirror of
https://github.com/vanitasvitae/Smack.git
synced 2024-12-22 10:37:59 +01:00
Make MUC invitations 'from' value an EntityJid
instead of an EntityFullJid, because according to XEP-0045 § 7.8.1.: "The <room@service> itself MUST then add a 'from' address to the <invite/> element whose value is the bare JID, full JID, or occupant JID of the inviter …"
This commit is contained in:
parent
a4ae941a7c
commit
af1bde4fd0
6 changed files with 37 additions and 13 deletions
|
@ -1,6 +1,6 @@
|
|||
/**
|
||||
*
|
||||
* Copyright © 2014 Florian Schmaus
|
||||
* Copyright © 2014-2017 Florian Schmaus
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
|
@ -26,6 +26,7 @@ import java.util.Locale;
|
|||
import org.jivesoftware.smack.SmackException;
|
||||
import org.jxmpp.jid.EntityBareJid;
|
||||
import org.jxmpp.jid.EntityFullJid;
|
||||
import org.jxmpp.jid.EntityJid;
|
||||
import org.jxmpp.jid.Jid;
|
||||
import org.jxmpp.jid.impl.JidCreate;
|
||||
import org.jxmpp.jid.parts.Resourcepart;
|
||||
|
@ -98,6 +99,24 @@ public class ParserUtils {
|
|||
return JidCreate.entityFullFrom(jidString);
|
||||
}
|
||||
|
||||
public static EntityJid getEntityJidAttribute(XmlPullParser parser, String name) throws XmppStringprepException {
|
||||
final String jidString = parser.getAttributeValue("", name);
|
||||
if (jidString == null) {
|
||||
return null;
|
||||
}
|
||||
Jid jid = JidCreate.from(jidString);
|
||||
|
||||
if (!jid.hasLocalpart()) return null;
|
||||
|
||||
EntityFullJid fullJid = jid.asEntityFullJidIfPossible();
|
||||
if (fullJid != null) {
|
||||
return fullJid;
|
||||
}
|
||||
|
||||
EntityBareJid bareJid = jid.asEntityBareJidIfPossible();
|
||||
return bareJid;
|
||||
}
|
||||
|
||||
public static Resourcepart getResourcepartAttribute(XmlPullParser parser, String name) throws XmppStringprepException {
|
||||
final String resourcepartString = parser.getAttributeValue("", name);
|
||||
if (resourcepartString == null) {
|
||||
|
|
|
@ -20,7 +20,7 @@ package org.jivesoftware.smackx.muc;
|
|||
import org.jivesoftware.smack.XMPPConnection;
|
||||
import org.jivesoftware.smack.packet.Message;
|
||||
import org.jivesoftware.smackx.muc.packet.MUCUser;
|
||||
import org.jxmpp.jid.EntityFullJid;
|
||||
import org.jxmpp.jid.EntityJid;
|
||||
|
||||
/**
|
||||
* A listener that is fired anytime an invitation to join a MUC room is received.
|
||||
|
@ -43,7 +43,7 @@ public interface InvitationListener {
|
|||
* @param message the message used by the inviter to send the invitation.
|
||||
* @param invitation the raw invitation received with the message.
|
||||
*/
|
||||
public abstract void invitationReceived(XMPPConnection conn, MultiUserChat room, EntityFullJid inviter, String reason,
|
||||
public abstract void invitationReceived(XMPPConnection conn, MultiUserChat room, EntityJid inviter, String reason,
|
||||
String password, Message message, MUCUser.Invite invitation);
|
||||
|
||||
}
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
/**
|
||||
*
|
||||
* Copyright © 2014-2016 Florian Schmaus
|
||||
* Copyright © 2014-2017 Florian Schmaus
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
|
@ -55,7 +55,6 @@ import org.jivesoftware.smackx.muc.MultiUserChatException.NotAMucServiceExceptio
|
|||
import org.jivesoftware.smackx.muc.packet.MUCInitialPresence;
|
||||
import org.jivesoftware.smackx.muc.packet.MUCUser;
|
||||
import org.jxmpp.jid.EntityBareJid;
|
||||
import org.jxmpp.jid.EntityFullJid;
|
||||
import org.jxmpp.jid.DomainBareJid;
|
||||
import org.jxmpp.jid.Jid;
|
||||
import org.jxmpp.jid.parts.Resourcepart;
|
||||
|
@ -165,7 +164,7 @@ public final class MultiUserChatManager extends Manager {
|
|||
final MultiUserChat muc = getMultiUserChat(mucJid);
|
||||
final XMPPConnection connection = connection();
|
||||
final MUCUser.Invite invite = mucUser.getInvite();
|
||||
final EntityFullJid from = invite.getFrom();
|
||||
final EntityJid from = invite.getFrom();
|
||||
final String reason = invite.getReason();
|
||||
final String password = mucUser.getPassword();
|
||||
for (final InvitationListener listener : invitationsListeners) {
|
||||
|
|
|
@ -29,6 +29,7 @@ import org.jivesoftware.smack.packet.ExtensionElement;
|
|||
import org.jivesoftware.smack.util.XmlStringBuilder;
|
||||
import org.jxmpp.jid.EntityBareJid;
|
||||
import org.jxmpp.jid.EntityFullJid;
|
||||
import org.jxmpp.jid.EntityJid;
|
||||
|
||||
/**
|
||||
* Represents extended presence information about roles, affiliations, full JIDs,
|
||||
|
@ -247,7 +248,12 @@ public class MUCUser implements ExtensionElement {
|
|||
public static final String ELEMENT ="invite";
|
||||
|
||||
private final String reason;
|
||||
private final EntityFullJid from;
|
||||
|
||||
/**
|
||||
* From XEP-0045 § 7.8.2: "… whose value is the bare JID, full JID, or occupant JID of the inviter …"
|
||||
*/
|
||||
private final EntityJid from;
|
||||
|
||||
private final EntityBareJid to;
|
||||
|
||||
public Invite(String reason, EntityFullJid from) {
|
||||
|
@ -258,7 +264,7 @@ public class MUCUser implements ExtensionElement {
|
|||
this(reason, null, to);
|
||||
}
|
||||
|
||||
public Invite(String reason, EntityFullJid from, EntityBareJid to) {
|
||||
public Invite(String reason, EntityJid from, EntityBareJid to) {
|
||||
this.reason = reason;
|
||||
this.from = from;
|
||||
this.to = to;
|
||||
|
@ -270,7 +276,7 @@ public class MUCUser implements ExtensionElement {
|
|||
*
|
||||
* @return the room's occupant that sent the invitation.
|
||||
*/
|
||||
public EntityFullJid getFrom() {
|
||||
public EntityJid getFrom() {
|
||||
return from;
|
||||
}
|
||||
|
||||
|
|
|
@ -24,7 +24,7 @@ import org.jivesoftware.smack.provider.ExtensionElementProvider;
|
|||
import org.jivesoftware.smack.util.ParserUtils;
|
||||
import org.jivesoftware.smackx.muc.packet.MUCUser;
|
||||
import org.jxmpp.jid.EntityBareJid;
|
||||
import org.jxmpp.jid.EntityFullJid;
|
||||
import org.jxmpp.jid.EntityJid;
|
||||
import org.xmlpull.v1.XmlPullParser;
|
||||
import org.xmlpull.v1.XmlPullParserException;
|
||||
|
||||
|
@ -86,7 +86,7 @@ public class MUCUserProvider extends ExtensionElementProvider<MUCUser> {
|
|||
private static MUCUser.Invite parseInvite(XmlPullParser parser) throws XmlPullParserException, IOException {
|
||||
String reason = null;
|
||||
EntityBareJid to = ParserUtils.getBareJidAttribute(parser, "to");
|
||||
EntityFullJid from = ParserUtils.getFullJidAttribute(parser, "from");
|
||||
EntityJid from = ParserUtils.getEntityJidAttribute(parser, "from");
|
||||
|
||||
outerloop: while (true) {
|
||||
int eventType = parser.next();
|
||||
|
|
|
@ -58,7 +58,7 @@ import org.jivesoftware.smackx.workgroup.settings.WorkgroupProperties;
|
|||
import org.jivesoftware.smackx.xdata.Form;
|
||||
import org.jivesoftware.smackx.xdata.FormField;
|
||||
import org.jivesoftware.smackx.xdata.packet.DataForm;
|
||||
import org.jxmpp.jid.EntityFullJid;
|
||||
import org.jxmpp.jid.EntityJid;
|
||||
import org.jxmpp.jid.DomainBareJid;
|
||||
import org.jxmpp.jid.Jid;
|
||||
|
||||
|
@ -133,7 +133,7 @@ public class Workgroup {
|
|||
MultiUserChatManager.getInstanceFor(connection).addInvitationListener(
|
||||
new org.jivesoftware.smackx.muc.InvitationListener() {
|
||||
@Override
|
||||
public void invitationReceived(XMPPConnection conn, org.jivesoftware.smackx.muc.MultiUserChat room, EntityFullJid inviter,
|
||||
public void invitationReceived(XMPPConnection conn, org.jivesoftware.smackx.muc.MultiUserChat room, EntityJid inviter,
|
||||
String reason, String password, Message message, MUCUser.Invite invitation) {
|
||||
inQueue = false;
|
||||
queuePosition = -1;
|
||||
|
|
Loading…
Reference in a new issue