powered by Jive Software

How to remove / unregister transport gateway registration from openfire?

Hi,

I am able to add transport / gateway registration in my openfire server using smack API. Now i want to use some api / code to remove / unregister transport, gateway registration from openfire.

Also how can i send this message bellow to my openfire server using smack to remove gateway from contacts?

what is the way to from xmpp message using smack API?

<iq type=‘set’ id=‘purple2d8c6b15’>
<query xmlns=‘jabber:iq:roster’>
<item jid=‘yahoo.xemon123’ subscription=‘remove’/>
</query>
</iq>

Regards,

samba

Hi,

Try this link - It worked for me.

shamalroy.info/2009/01/18/open-fire-im-gateway-in-run/

Regards

P G Patrudu.

    public boolean XMPPUnRegisterTransPort(XMPPConnection conn, String gateway,ZXMLStatus zStatus) throws XMPPException
    {
        boolean success = true;
        String newStatus = "";
        gateway = gateway.toLowerCase();
       
        try
        {
            Registration registration = new Registration();
            registration.setType(IQ.Type.SET);
            registration.setTo(gateway);
            registration.setFrom(conn.getUser());
       
            Map<String, String> map = new HashMap<String, String>();
            map.put("remove", "");
            registration.setAttributes(map);

            PacketCollector collector = conn.createPacketCollector(new PacketIDFilter(registration.getPacketID()));
            conn.sendPacket(registration);

            IQ response = (IQ) collector.nextResult(SmackConfiguration.getPacketReplyTimeout());
            collector.cancel();       
                                           
            if (response == null)
            {
                newStatus = "SERVER NOT RESPONDING";
                zStatus.SetStatus(newStatus);
               
                success = false;
            }
            if (response.getType() == IQ.Type.ERROR)
            {
                final XMPPError error = response.getError();
               
                int errorCode = 0;
               
                newStatus = "REMOVE REGISTRATION ERROR ";
               
                if (error != null)
                {
                    errorCode = error.getCode();                                      
                   
                    newStatus += "  (ERROR-DETAILS ["+ errorCode +":- ";
                    newStatus += getXMPPError(errorCode) +"]";                   
                }
               
                zStatus.SetStatus(newStatus);                                                                                                
                success = false;
            }
        }            
        catch (Exception e)
        {               
            newStatus = "REMOVE REGISTRATION ERROR <UNKNOWN ERROR>";
            zStatus.SetStatus(newStatus);
           
            success = false;               
        }
       
        newStatus = "GATEWAY REGISTRATION REMOVED SUCESSFULLY";
        zStatus.SetStatus(newStatus);
        return success;
    }

Hi,

You can remove registeration, simply by deleting the transport from contacts, using any client like SparkWeb (TESTED).
I think other clients like Spark, PSi etc are equally good (UNTESTED).

 I dont understand, why you are so particular about programmatical version for simple delete.
 I can understand the concern for Registration.

 By the way, Iam very busy. I will look into the code, when I get some time.

Regards,

P G Patrudu.

I am developing a XMPP client and using smack API