[sip-comm-cvs] CVS update: /sip-communicator/src/net/java/sip/communicator/impl/protocol/jabber/extensions/keepalive/KeepAliveEventProvider.java

emcho at dev.java.net emcho at dev.java.net
Tue May 15 13:52:36 CEST 2007


User: emcho   
Date: 2007-05-15 11:52:36+0000
Log:
 refactoring - moving version and keepalive jabber extensions to their own packages in impl.provider.jabber.extension

File Changes:

Directory: /sip-communicator/src/net/java/sip/communicator/impl/protocol/jabber/extensions/keepalive/
=====================================================================================================

File [added]: KeepAliveEventProvider.java
Url: https://sip-communicator.dev.java.net/source/browse/sip-communicator/src/net/java/sip/communicator/impl/protocol/jabber/extensions/keepalive/KeepAliveEventProvider.java?rev=1.1&content-type=text/vnd.viewcvs-markup
Added lines: 80
---------------
/*
 * SIP Communicator, the OpenSource Java VoIP and Instant Messaging client.
 *
 * Distributable under LGPL license.
 * See terms of license at gnu.org.
 */
package net.java.sip.communicator.impl.protocol.jabber.extensions.keepalive;

import org.jivesoftware.smack.packet.*;
import org.jivesoftware.smack.provider.*;
import org.xmlpull.v1.*;


/**
 * The KeepAliveEventProvider parses KeepAlive Event packets.
 *
 * @author Damian Minkov
 */
public class KeepAliveEventProvider
    implements IQProvider
{
    public static final String ELEMENT_NAME = "keepalive";
    public static final String NAMESPACE = "sip-communicator:iq:keepalive";

    /**
     * Creates a new KeepAliveEventProvider.
     * ProviderManager requires that every PacketExtensionProvider has a public,
     * no-argument constructor
     */
    public KeepAliveEventProvider()
    {}

    /**
     * Parses a KeepAliveEvent packet .
     *
     * @param parser an XML parser.
     * @return a new IQ instance.
     * @throws Exception if an error occurs parsing the XML.
     */
    public IQ parseIQ(XmlPullParser parser)
        throws Exception
    {
        KeepAliveEvent result = new KeepAliveEvent();

        boolean done = false;
        while (!done)
        {
            try
            {
                int eventType = parser.next();
                if(eventType == XmlPullParser.START_TAG)
                {
                    if(parser.getName().equals(KeepAliveEvent.
                                               SOURCE_PROVIDER_HASH))
                    {
                        result.setSrcProviderHash(Integer.parseInt(parser.
                            nextText()));
                    }
                    if(parser.getName().equals(KeepAliveEvent.SOURCE_OPSET_HASH))
                    {
                        result.setSrcOpSetHash(Integer.parseInt(parser.nextText()));
                    }
                }
                else if(eventType == XmlPullParser.END_TAG)
                {
                    if(parser.getName().equals(ELEMENT_NAME))
                    {
                        done = true;
                    }
                }
            }
            catch(NumberFormatException ex)
            {
                ex.printStackTrace();
            }
        }

        return result;
    }
}




---------------------------------------------------------------------
To unsubscribe, e-mail: cvs-unsubscribe at sip-communicator.dev.java.net
For additional commands, e-mail: cvs-help at sip-communicator.dev.java.net





More information about the commits mailing list