powered by Jive Software

How to identify icq/msn/etc roster entries

HI all. Somebody know how to identify current transport for the RosterEntry?

For example if I have roster entry 55555@icq.jabber.ru how to determine that it is ICQ contact without parsing “icq” string from jid?

The only way to do it is by parsing icq from the JID.

Alex

You could also run service discovery on icq.jabber.ru

Does the disco items query report your contacts? I haven’'t used transports too extensivly so if it does that would be awesome

Alex

No, but it would tell you what kind of gateway icq.jabber.ru is

Ok. For “msn.jabber.ur” server returns 0 disco items and discovery info that it is a gateway with type “msn”. The problem is how Could I define which gateways installed on server? Because I don’'t know names of gateways for particular server. I need some functionality which returns me list of all gateway names and types (icq, msn, etc… ) and some relation between the gateway and contacts transfered from this gateway to roster

Message was edited by:

ArmenPolischuk

I think the biggest problem is to get list of gateways. Knowing gateway name I always could define if a contact owns to this gateway because gateway’'s name always included in contact jid

The way I am doing it is when a user logs on I am querying all the items connected to the server. I am checking for two things, a category of “gateway” and also i am checking the type. Which for each type of gateway is defined somewhere. So basicly you have type=aim is aol instant messenger and type=msn is microsoft messenger, etc. I then register those transports with a services manager class, which helps to encapsulate the information about the transport. So, one of the things it will no is the JID, so basicly everytime a contact is received by my client it checks to see if the domain of the contact is contained in my services manager. And if it is say, aim.server, the gateway can then retrieve the appopriate object for the contact to manage icons and such.

Hope that helps,

Alex

The way I am doing it is when a user logs on I am

querying all the items connected to the server. I am

checking for two things, a category of “gateway” and

also i am checking the type.

Could you show code fragment for that?

Sure, I call this when my client starts up:

connection.currentConnect - your XMPPConnection

CAT_GATEWAY - “gateway”

servicesMap:

aim - AIMGateway.class

msn -MSNGateway.class

public void discoverServices() throws XMPPException {

ServiceDiscoveryManager manager = ServiceDiscoveryManager

.getInstanceFor(connection.currentConnection);

DiscoverItems discoItems = manager

.discoverItems(connection.currentConnection.getServiceName());

DiscoverItems.Item item;

DiscoverInfo info;

DiscoverInfo.Identity identity;

Iterator it = discoItems.getItems();

while (it.hasNext()) {

item = (Item) it.next();

info = manager.discoverInfo(item.getEntityID());

Iterator itx = info.getIdentities();

while (itx.hasNext()) {

identity = (Identity) itx.next();

if (identity.getCategory().equalsIgnoreCase(CAT_GATEWAY)

&& servicesMap.containsKey(identity.getType())) {

initializeGateway(servicesMap.get(identity.getType()),

identity.getName(), info);

}

}

}

}

/code

Alex

Thanks a lot!