Is finding a user's joined rooms supported?

Hi,

I’m trying to find the rooms a user currently occupies (has joined). I’m trying to use XEP-0045 discovery feature with node value of http://jabber.org/protocol/muc#rooms. (See http://xmpp.org/extensions/xep-0045.html#disco-occupant).

Does openfire support this feature? If not are there any other ways to obtain the information?

In my particular instance, I’m using the Smack API MultiUserChat.getJoinedRooms(). This generates the following packet:

<query xmlns="http://jabber.org/protocol/disco#items"

node=“http://jabber.org/protocol/muc#rooms”>

Openfire (3.6.2) then returns the following result:


<query xmlns=“http://jabber.org/protocol/disco#items

node=“http://jabber.org/protocol/muc#rooms”>

Basically, this empty packet is returned regardless of whether the user is in a room or not.

I’ve downloaded the openfire source and remote debugged it and it appears that the discovery packet doesn’t get processed at all - essentially if the user exists the packet just gets returned to the sender. As such, I have come to the conclusion that openfire simply doesn’t support muc#rooms.

Is this correct? If so, is there any work-around?

Cheers,

Andrew

For anyone interested, I’ve created a proof of concept plugin that implements muc#rooms. It’s only had rudimentary testing against 3.6.2, but seems ok thus far. Here’s the plugin body (full source is attached):

public class JoinedRoomsPlugin implements Plugin, PacketInterceptor {

private static final DocumentFactory FACTORY = DocumentFactory.getInstance();

private MultiUserChatService chatService;

public void initializePlugin(PluginManager manager, File pluginDirectory) {

    InterceptorManager.getInstance().addInterceptor(this);

    chatService = XMPPServer.getInstance().getMultiUserChatManager().getMultiUserChatService("con ference");

}

public void destroyPlugin() {

    InterceptorManager.getInstance().removeInterceptor(this);

}

public void interceptPacket(Packet packet, Session session, boolean incoming, boolean processed)

        throws PacketRejectedException {

    if (incoming || processed || !(packet instanceof IQ)) {

        return;

    }

    IQ iq = (IQ) packet;

    Element query = iq.getChildElement();

    // Only alter the result muc#rooms packet

    if (iq.getType() != IQ.Type.result || query == null

            || !"[http://jabber.org/protocol/muc#rooms](http://jabber.org/protocol/muc#rooms)".equals(query.attributeValue("node"))) {

        return;

    }

    // Search the rooms and items if the user matches

    for (MUCRoom room : chatService.getChatRooms()) {

        for (MUCRole role : room.getOccupants()) {

            if (role.getUserAddress().equals(iq.getFrom())) {

                addItem(query, room.getJID());

            }

        }

    }

    if (Log.isDebugEnabled()) {

        Log.debug("muc#rooms processed: " + packet.toXML());

    }

}

public void addItem(Element query, JID roomId) {

    Element item = FACTORY.createElement("item");

    item.addAttribute("jid", roomId.toString());

    query.add(item);

}

}
JoinedRoomsPlugin.java (2580 Bytes)