powered by Jive Software

Getting presence update after removing transport / gateway

I am doing as displayed below. I am removing gateway from roster after unregistration.after deleting msn/ gtalk / yahoo transports still getting presence from contacts from those gateways.

Am i doing any mistakes? what should i do?

public boolean XMPPUnRegisterTransPort(XMPPConnection conn, String gatewayID,ZXMLStatus zStatus) throws XMPPException
{
boolean success = true;
String newStatus = “”;
gatewayID = gatewayID.toLowerCase();

        if(roster == null)
        {
            Log.sendInfo("UNBALE TO REGISTER: NO ROSTER OBJECT <XMPPUnRegisterTransPort>");
            return false;
        }
       
        if(gatewayID.indexOf("skype") > -1)
        {
            success = XMPPHandleSkypeUnRegistration(conn, gatewayID);
           
            if(success == true)
            {                  

                newStatus = "RIM: FIRED SKYPE UN-REGISTRATION COMMAND SUCESSFULLY";
                zStatus.SetStatus(newStatus);
                return true;
            }
            else
            {                  
                newStatus = "RIM: UNABLE TO FIRE SKYPE UN-REGISTRATION COMMAND SUCESSFULLY";
                zStatus.SetStatus(newStatus);
                return false;
            }
        }
        else
        {
            Log.sendInfo("RIM: UNREGISTRATION NON SKYPE GATEWAYS <XMPPUnRegisterTransPort>");
                           
            try
            {
                Registration registration = new Registration();
                registration.setType(IQ.Type.SET);
                registration.setTo(gatewayID);
                registration.setFrom(conn.getUser());
               
                Log.sendInfo("RIM: <"+conn.getUser()+"<XMPPUnRegisterTransPort>");
       
                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)
                {
                    Log.sendError("RIM: SERVER NOT RESPONDING <XMPPUnRegisterTransPort>");
                    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;               
            }
       
            if(success == true)
            {
               
                newStatus = "GATEWAY REGISTRATION REMOVED SUCESSFULLY";
               
                if(roster.getEntry(gatewayID)!=null)
                {
                   
                    roster.removeEntry(roster.getEntry(gatewayID));
                }
               
               
                // Reject subscription requests.
                Presence presencePacket = new Presence(Presence.Type.unsubscribe);
                presencePacket.setTo(gatewayID);
                connection.sendPacket(presencePacket);
            }
           
            zStatus.SetStatus(newStatus);
            return success;
        }
    }

Packet pck = new Packet() {
public String toXML() {
return “”;
}
};

                pck.setFrom(conn.getUser());                   
                conn.sendPacket(pck);

Sending this packet solves presence problem but got connection is getting disconnected

I am sending the below packet for removing gateway registrations, is that correct? Because after sending that packet i got disconnected from the XMPP connection. I thought smack API roster.removeEntry() will do that automatically and i don’t need to send that packet manually.