MUC UserStatusListener no incoming ownershipGranted Event

Hi,

Server: openfire 3.10.2

Client: Smack 4.1.3

The UserStatusListener is not working. I expect the call of the method ownershipGranted().

Here is an code example:

@Test
public void testGroupChat() {

final String freddy = “freddy”;
final String dennisRoom = “dennisroom–007@” + GROUP_CHAT_SERVICE;
final XMPPTCPConnection xmppConnection2 = connect();

final AccountManager accountManager2 = createAccountManager(xmppConnection2);
try {

accountManager2.createAccount(freddy, freddy);

xmppConnection2.login(freddy, freddy, RESOURCE);
final MultiUserChatManager mucManager2 = MultiUserChatManager.getInstanceFor(xmppConnection2);
final MultiUserChat multiUserChat2 = mucManager2.getMultiUserChat(dennisRoom);

// user1 create chat
final MultiUserChatManager mucManager =

MultiUserChatManager.getInstanceFor(xmppConnection);
final MultiUserChat multiUserChat = mucManager.getMultiUserChat(dennisRoom);
// test user create a room.
multiUserChat.create(USER_NAME);
final Form answerForm = multiUserChat.getConfigurationForm().createAnswerForm();
//answerForm.setAnswer(“x-muc#roomconfig_reservednick”, true);
//answerForm.setAnswer(“muc#roomconfig_persistentroom”, true);
multiUserChat.sendConfigurationForm(answerForm);

multiUserChat.changeSubject(“Cooler Raum mit guter Unterhaltung…”);

final String freddyJid = this.createJID(freddy);

// join room.
multiUserChat2.join(freddy);

// TODO not working
multiUserChat2.addUserStatusListener(new DefaultUserStatusListener() {

@Override
public void ownershipGranted() {

// TODO no incoming event…
System.out.println(“ownership granted”);
}

});

// change owner.
// send event.

// TODO no incoming event to multiUserChat2
multiUserChat.grantOwnership(freddyJid);

Thread.sleep(120000);

} catch (Exception e) {

fail(e.getMessage());
} finally {

try {

accountManager2.deleteAccount();
} catch (Exception e) {

fail(e.getMessage());
}

xmppConnection2.disconnect();
}

}

I think the problem is in the MultiUserChat class. Because it take the same presence packets and compare the same affiliation status:

// Create a listener for all presence updates.
presenceListener = new StanzaListener() {

public void processPacket(Stanza packet) {

Presence presence = (Presence) packet;
String from = presence.getFrom();
String myRoomJID = MultiUserChat.this.room + “/” + nickname;
boolean isUserStatusModification = presence.getFrom().equals(myRoomJID);
switch (presence.getType()) {

case available:

Presence oldPresence = occupantsMap.put(from, presence);
if (oldPresence != null) {

// Get the previous occupant’s affiliation & role
MUCUser mucExtension = MUCUser.from(packet);
** MUCAffiliation oldAffiliation = mucExtension.getItem().getAffiliation();**
MUCRole oldRole = mucExtension.getItem().getRole();
// Get the new occupant’s affiliation & role
mucExtension = MUCUser.from(packet);
MUCAffiliation newAffiliation = mucExtension.getItem().getAffiliation()****;
MUCRole newRole = mucExtension.getItem().getRole();
// Fire role modification events
checkRoleModifications(oldRole, newRole, isUserStatusModification, from);
// Fire affiliation modification events
checkAffiliationModifications(

oldAffiliation,
newAffiliation,
isUserStatusModification,
from);
}

else {

// A new occupant has joined the room
if (!isUserStatusModification) {

for (ParticipantStatusListener listener : participantStatusListeners) {

listener.joined(from);
}

}

}

break;

Thanks for reporting. The first MUCUser.from should use oldPresence instead of packet.

Usually I would create an JIRA issue, scheduled to be resolved in 4.1.4 for this, but Ignite’s JIRA has been switched to read-only mode. Will do once it’s writeable again.

Tracked as [SMACK-693] MultiUserChat’s UserStatusListener is not getting triggered - Jive Software Open Source