powered by Jive Software

Contact list

Hi Guys,

Can some one tell me how to programmatically get the contact list of a user with openfire.

I have a plugin created that a user can add as a buddy, but now from the plugin i want to list out all its contacts. What method can cycle through the plugins contacts.

i currently use sessionManager.getSessions() but this returns everyone who is online with openfire.

Thanks

Mark

Hi Mark,

Getting the roster of a given user on Openfire can be accomplished using the following bit of code:

Roster roster = XMPPServer.getInstance().getRosterManager().getRoster("bob");
for (RosterItem item : roster.getRosterItems()) {
   //do something here...
}

Hope that helps,

Ryan

Hi

Ryan,

Thanks ill give it a go, and leave ya know if i get it working.

Best

mark

My Helga-Bot has a function “roster export”, maybe it will help you to take a look into my source.

cool thanks coolcat,

I thought the Helga bot used a database to persist its contact list, does the export roster export from the database or the openfire handled buddy list?

Best

Mark

Helga uses the RosterManager which ryang mentioned.

See CommandRoster.java, lines 794 - 1022

Yep looks good, ill give it a go.

One thing i dont really get is, at what point do you specify helga’s username is “bot”. So users can add bot@helga.server?

best

Mark

You can set the system property “plugin.helga.username” in openfire’s admin panel. In sourcecode this is done in HelgaUtil.java

ah yes i see it now, fair play to you Helga is quite the extensive bot.

Do you know if a gmail address can add Helga as a contact if the server is setup for server to server communication and port 5269 is open.

Just im also having a bit of trouble in this area (i also posted about it).

Thanks for your help so far anyway, Helga is a great plugin to llok at as an example.

Best

Mark

Helga does only support local users, sorry.

That is because such things like exporting the roster or manipulating shared groups can only be done for local users.

Yep thats cool, no prob.

I think i know why i was having trouble adding a bot to googletalk, adding bot@bot.servername does not allow googletalk find the server as when googletalk does a DNS lookup it would find @servername but can not find @bot.servername.

I think that bots library might be something to look at for me in the plugins.

Best

Mark