powered by Jive Software

Getting a list of conference rooms

I’‘m trying to pull down a list of available conference rooms but I can’'t seem to get a hold of the information that I need via smack.

This is the packet that I’'m sending to the server:

Packet packet = new Packet() {

public String toXML() {

return “<iq type=’‘get’’ to=’’” +


“’’><query xmlns=’‘jabber:iq:browse’’/>”;



This is a closed system so I don’'t need to discover the name of the conference component. I know it will always be represented by PUBLICCONFERENCE(in my extended XMPPConnection class).

Here’'s the debug response:

<iq type=’‘result to=’‘myuser@server.com/resource’’ from=’‘conference.myserver.com’’><conference xmlns=’‘jabber:iq:browse’’ type=’‘public’’ name=’‘Conferencing Service’’><conference type=’‘public’’ jid=’‘someroom@conference.myserver.com’’ name=’’ (1)’’/>

The filter that I use to catch the response:

//PacketFilter to collect IQ packets from conference module

PacketFilter filter = new AndFilter(new PacketTypeFilter(IQ.class),

new PacketFilter() {

public boolean accept(Packet packet) {

IQ iq = (IQ)packet;

if(iq.getType() == IQ.Type.RESULT && (iq.getFrom() != null)) {

if(iq.getFrom().equalsIgnoreCase(connection.PUBLICCONFERENCE)) {

return true;


else { return false; }


else { return false; }




The problem is that smack seems only to show me part of the actual packet. When I catch the response and do:

IQ iqPacket = (IQ)packet;

System.out.println("XML: " + iqPacket.toXML() + “\n”);

I get:


So, how do I go about getting the portion between ? Isn’'t all contained in a single packet?

Thanks in advance.


Smack doesn’‘t use a full DOM (Document Object Model) to represent packets. Instead, it uses a much more light weight system. That only presents issues when you’'re doing trying to use custom packets like the conference packet you describe.

Smack 1.1 include new PacketProvider functionality that addresses this issue. It let’'s use parse packet extensions and also to parse IQ packets into particular types. So, you could create an IQProvider that parsed the incoming packet into a ConferenceReply object, etc.

There are a number of threads in this forum about the new functionality. I’'d also recommend downloading a daily build at http://www.jivesoftware.com/xmpp/smack/dailybuilds.jsp and then checking out the Javadocs.

We’'ll be happy to answer any questions you run into.



Thanks, I’'ll check it out.

Hi Matt,

Speaking of the daily builds, the page doesn’‘t show any downloads after May 18. I’‘ve been extrapolating the filenames to grab new ones but I though I’'d give you a heads up on it.

Take care,



Sorry about that. I cleared out the old builds so the new ones are showing up now.



Well, I upgraded to the latest version and created a class called Browse that looks like this:

import org.jivesoftware.smack.packet.*;

public class Browse extends IQ {

private String conference;

/** Creates a new instance of Browse */

public Browse() {



protected void setConference(String conf) {

this.conference = conf;


protected String getConference() {

return conference;



I created a smack.providers file and placed it in the application’'s Web-Inf directory. (This is a java applet by the way). smack.providers looks like:

<?xml version="1.0"?>




The only other change to the previous posting is that I added:

if(iqPacket instanceof Browse) {

System.out.println(“it worked!”);


to processPacket().

It looks like the provider is not being registered as this line never prints. I know that smack.providers is being read, however, because an error is thrown when I change “Browse” to some non-existent class.

As was the case previously, the info between the conference tags never appears.

Am I using the ProviderManager functionality correctly?

If I’'m extending IQ, I just need to create the entry in smack.providers and then add Get/Set methods for each element. Right?


hi; in reading this thread it appears that you are saying that the packet you are interested in breaking down for consumption is this packet:

<iq type=’‘result to=’‘myuser@server.com/resource’’ from=’‘conference.myserver.com’’><conference xmlns=’‘jabber:iq:browse’’ type=’‘public’’ name=’‘Conferencing Service’’><conference type=’‘public’’ jid=’‘someroom@conference.myserver.com’’ name=’’ (1)’’/>

if this is the case, your smack providers should be ‘‘conference’’ and not ‘‘query’’.

does this provide help?



That’'s exactly what I was doing wrong. I should have seen that.


I’‘ve been playing with this for a while but I’'m still not getting where I need to be.

Since modifying smack.providers I can get hold of the conference element and read all of it’‘s attributes, but then what? My goal is to include the conference elements inside the original server response and then return the whole thing back to the client. Basically, I wan’'t all of the information that the server returns.

I’‘m assuming that introspection won’'t work for this namespace. Is that correct?

I guess what I’'m confused about is how this is supposed to be handled via IQProvider and parseIQ(). parseIQ returns an IQ packet but how do I addresss it? (or should I even have to) The parser itself only contains info from the conference element.

Sorry if this is obvious but I’‘m not getting it. I’‘ve read over the source for PacketReader along with the Threads here but it hasn’'t helped. The time example in the javadocs is nice but it seems a bit simplistic.

Thanks for all the help.


Hi bjiggs,

The purpose of your “browse” class (and other iq handlers) is generally something to decode the XML of the packet and have methods to access that information. If it were an IQ type that you would use for both GET’‘s and SET’‘s you’'d have methods, etc to allow your program to create an instance for sending out as well (e.g. jabber:iq:version).

Smack will create an instance of your class, hand it the XML (or load attributes into it via reflection), and pass it along as if it were a regular packer.

The job of doing something with the decoded information really lies elsewhere in your application. Whatever ends up getting the packet would then access the “browse” info via methods from your class and display the results in a dialog, tree, etc.

Basically, your IQ handler classes are just like the existing classes in Smack: Message, Presence, RosterPacket…they are just your own additions for handling stuff that Smack doesn’'t handle natively.

Hope this is what you were looking for,


Sorry for this double post…

Matt, posting a message sends you to a “Invalid Login” page, even though you’'re already logged in.

Message was edited by: insurgent

Testing the forum.


Thank you for clearing things up. Everything clicked after I read your post. I finished the class this morning and it’'s working great.

I also went back and read the source for Packet and IQ and the design makes a lot more sense to me.