Java 类org.jivesoftware.smackx.carbons.packet.CarbonExtension 实例源码

项目:Smack    文件:CarbonManagerProvider.java   
@Override
public CarbonExtension parse(XmlPullParser parser, int initialDepth)
                throws SmackException, XmlPullParserException, IOException {
    Direction dir = Direction.valueOf(parser.getName());
    Forwarded fwd = null;

    boolean done = false;
    while (!done) {
        int eventType = parser.next();
        if (eventType == XmlPullParser.START_TAG && parser.getName().equals("forwarded")) {
            fwd = FORWARDED_PROVIDER.parse(parser);
        }
        else if (eventType == XmlPullParser.END_TAG && dir == Direction.valueOf(parser.getName()))
            done = true;
    }
    if (fwd == null)
        throw new SmackException("sent/received must contain exactly one <forwarded> tag");
    return new CarbonExtension(dir, fwd);
}
项目:Smack    文件:CarbonManager.java   
/**
 * Returns true if XMPP Carbons are supported by the server.
 * 
 * @return true if supported
 * @throws NotConnectedException 
 * @throws XMPPErrorException 
 * @throws NoResponseException 
 */
public boolean isSupportedByServer() throws NoResponseException, XMPPErrorException, NotConnectedException {
    return ServiceDiscoveryManager.getInstanceFor(connection()).serverSupportsFeature(CarbonExtension.NAMESPACE);
}