mirror of
https://codeberg.org/Mercury-IM/Smack
synced 2024-11-22 06:12:05 +01:00
Add support for MUC Item Actor 'nick'
Fixes SMACK-691.
This commit is contained in:
parent
b18c6dac62
commit
b746e5caee
2 changed files with 29 additions and 8 deletions
|
@ -35,32 +35,33 @@ public class MUCItem implements NamedElement {
|
|||
private final MUCAffiliation affiliation;
|
||||
private final MUCRole role;
|
||||
private final Jid actor;
|
||||
private final Resourcepart actorNick;
|
||||
private final String reason;
|
||||
private final Jid jid;
|
||||
private final Resourcepart nick;
|
||||
|
||||
public MUCItem(MUCAffiliation affiliation) {
|
||||
this(affiliation, null, null, null, null, null);
|
||||
this(affiliation, null, null, null, null, null, null);
|
||||
}
|
||||
|
||||
public MUCItem(MUCRole role) {
|
||||
this(null, role, null, null, null, null);
|
||||
this(null, role, null, null, null, null, null);
|
||||
}
|
||||
|
||||
public MUCItem(MUCRole role, Resourcepart nick) {
|
||||
this(null, role, null, null, null, nick);
|
||||
this(null, role, null, null, null, nick, null);
|
||||
}
|
||||
|
||||
public MUCItem(MUCAffiliation affiliation, Jid jid, String reason) {
|
||||
this(affiliation, null, null, reason, jid, null);
|
||||
this(affiliation, null, null, reason, jid, null, null);
|
||||
}
|
||||
|
||||
public MUCItem(MUCAffiliation affiliation, Jid jid) {
|
||||
this(affiliation, null, null, null, jid, null);
|
||||
this(affiliation, null, null, null, jid, null, null);
|
||||
}
|
||||
|
||||
public MUCItem(MUCRole role, Resourcepart nick, String reason) {
|
||||
this(null, role, null, reason, null, nick);
|
||||
this(null, role, null, reason, null, nick, null);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -72,15 +73,17 @@ public class MUCItem implements NamedElement {
|
|||
* @param reason
|
||||
* @param jid
|
||||
* @param nick
|
||||
* @param actorNick
|
||||
*/
|
||||
public MUCItem(MUCAffiliation affiliation, MUCRole role, Jid actor,
|
||||
String reason, Jid jid, Resourcepart nick) {
|
||||
String reason, Jid jid, Resourcepart nick, Resourcepart actorNick) {
|
||||
this.affiliation = affiliation;
|
||||
this.role = role;
|
||||
this.actor = actor;
|
||||
this.reason = reason;
|
||||
this.jid = jid;
|
||||
this.nick = nick;
|
||||
this.actorNick = actorNick;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -92,6 +95,16 @@ public class MUCItem implements NamedElement {
|
|||
return actor;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the nickname of the actor.
|
||||
*
|
||||
* @return the nickname of the actor.
|
||||
* @since 4.2
|
||||
*/
|
||||
public Resourcepart getActorNick() {
|
||||
return actorNick;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the reason for the item child. The reason is optional and could be used to explain
|
||||
* the reason why a user (occupant) was kicked or banned.
|
||||
|
|
|
@ -37,6 +37,7 @@ public class MUCParserUtils {
|
|||
MUCRole role = MUCRole.fromString(parser.getAttributeValue("", "role"));
|
||||
Jid jid = ParserUtils.getJidAttribute(parser);
|
||||
Jid actor = null;
|
||||
Resourcepart actorNick = null;
|
||||
String reason = null;
|
||||
outerloop: while (true) {
|
||||
int eventType = parser.next();
|
||||
|
@ -46,6 +47,13 @@ public class MUCParserUtils {
|
|||
switch (name) {
|
||||
case "actor":
|
||||
actor = ParserUtils.getJidAttribute(parser);
|
||||
// TODO change to
|
||||
// actorNick = Resourcepart.from(parser.getAttributeValue("", "nick"));
|
||||
// once a newer version of JXMPP is used that supports from(null).
|
||||
String actorNickString = parser.getAttributeValue("", "nick");
|
||||
if (actorNickString != null) {
|
||||
actorNick = Resourcepart.from(actorNickString);
|
||||
}
|
||||
break;
|
||||
case "reason":
|
||||
reason = parser.nextText();
|
||||
|
@ -59,7 +67,7 @@ public class MUCParserUtils {
|
|||
break;
|
||||
}
|
||||
}
|
||||
return new MUCItem(affiliation, role, actor, reason, jid, nick);
|
||||
return new MUCItem(affiliation, role, actor, reason, jid, nick, actorNick);
|
||||
}
|
||||
|
||||
public static Destroy parseDestroy(XmlPullParser parser) throws XmlPullParserException, IOException {
|
||||
|
|
Loading…
Reference in a new issue