powered by Jive Software

Subscription request problem

Hi,

  1. connected to XMPP Server
  2. Added Message listener
  3. Added Presense listener
  4. Logged in to XMPP account
  5. Registered Yahoo, Gtalk Transport
  6. Added yahoo, gtalk transport to my contact
  7. logged in to yahoo, gtalk
  8. Now logged into yahoo messenger as different yahoo account
  9. Added the XMPP regostered yahoo account

But no subscription request is comming to presence listener? but after i logged out and logged in to XMPP i get the subscription but subscription is auto accepted. subscription mode is set to manual.

public Roster XMPPCreateRosterConfig(XMPPConnection connection, int subcriptionMode)
{
roster = connection.getRoster();
roster.setSubscriptionMode(SubscriptionMode.manual);
Roster.setDefaultSubscriptionMode(SubscriptionMode.manual);

        return roster;
    }

Below is the presence listener code

    public void XMPPAddPresenceListener(XMPPConnection connection, ZXML zxmlObj)
    {
           PacketFilter presenceFilter = new PacketTypeFilter (Presence.class);                                                                              
           PresenceListener listener = zxmlObj.new PresenceListener();              
          
           connection.addPacketListener(listener, presenceFilter);
    }   

public class PresenceListener implements PacketListener
{
public void processPacket(Packet packet)
{

            Presence presence = (Presence)packet;
            Presence.Type presenceType = presence.getType();
            Presence.Mode presenceMode = presence.getMode();
           
            System.out.println("GET FROM = " + presence.getFrom());
            System.out.println("GET FROM = " + presence.getType().toString());
           
            Object prop = packet.getProperty("status");                                            
            System.out.println("STATUS:- " + prop.toString());
            System.out.println(packet.getXmlns());
                           
            if(presenceType == Presence.Type.available)
            {
                if(presenceMode == Presence.Mode.available)
                {
                    System.out.println("Presence: < AVAILABLE >");
                }
                if(presenceMode == Presence.Mode.away)
                {   
                    System.out.println("Presence: < AWAY >");
                }
                if(presenceMode == Presence.Mode.chat)
                {                       
                    System.out.println("Presence: < CHAT >");
                }
                if(presenceMode == Presence.Mode.dnd)
                {                       
                    System.out.println("Presence: < DND >");
                }
                if(presenceMode == Presence.Mode.xa)
                {                       
                    System.out.println("Presence: < XA >");
                }
                                   
                System.out.println(packet.getFrom()+" is OnLine");
            }
            else if(presenceType == Presence.Type.unavailable) {
               
                System.out.println("unavailable");
            }
            else if(presenceType  == Presence.Type.subscribe) {
               
                System.out.println("subscribe");
            }             
            else if(presenceType == Presence.Type.subscribed) {
               
                System.out.println("subscribed");
            }
            else if(presenceType == Presence.Type.unsubscribe) {
               
                System.out.println("unsubscribe");
            }
            else if(presenceType == Presence.Type.unsubscribed) {
               
                System.out.println("unsubscribed");
            }              
        }
    }