当前位置: 首页>>代码示例>>Java>>正文


Java CapsExtension类代码示例

本文整理汇总了Java中org.jivesoftware.smackx.caps.packet.CapsExtension的典型用法代码示例。如果您正苦于以下问题:Java CapsExtension类的具体用法?Java CapsExtension怎么用?Java CapsExtension使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


CapsExtension类属于org.jivesoftware.smackx.caps.packet包,在下文中一共展示了CapsExtension类的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: addCapsExtensionInfo

import org.jivesoftware.smackx.caps.packet.CapsExtension; //导入依赖的package包/类
private static void addCapsExtensionInfo(String from, CapsExtension capsExtension) {
    String capsExtensionHash = capsExtension.getHash();
    String hashInUppercase = capsExtensionHash.toUpperCase(Locale.US);
    // SUPPORTED_HASHES uses the format of MessageDigest, which is uppercase, e.g. "SHA-1" instead of "sha-1"
    if (!SUPPORTED_HASHES.containsKey(hashInUppercase))
        return;
    String hash = capsExtensionHash.toLowerCase(Locale.US);

    String node = capsExtension.getNode();
    String ver = capsExtension.getVer();

    JID_TO_NODEVER_CACHE.put(from, new NodeVerHash(node, ver, hash));
}
 
开发者ID:TTalkIM,项目名称:Smack,代码行数:14,代码来源:EntityCapsManager.java

示例2: parse

import org.jivesoftware.smackx.caps.packet.CapsExtension; //导入依赖的package包/类
public CapsExtension parse(XmlPullParser parser, int initialDepth) throws XmlPullParserException, IOException,
        SmackException {
    String hash = null;
    String version = null;
    String node = null;
    if (parser.getEventType() == XmlPullParser.START_TAG
            && parser.getName().equalsIgnoreCase(EntityCapsManager.ELEMENT)) {
        hash = parser.getAttributeValue(null, "hash");
        version = parser.getAttributeValue(null, "ver");
        node = parser.getAttributeValue(null, "node");
    } else {
        throw new SmackException("Malformed Caps element");
    }

    parser.next();

    if (!(parser.getEventType() == XmlPullParser.END_TAG
            && parser.getName().equalsIgnoreCase(EntityCapsManager.ELEMENT))) {
        throw new SmackException("Malformed nested Caps element");
    }

    if (hash != null && version != null && node != null) {
        return new CapsExtension(node, version, hash);
    } else {
        throw new SmackException("Caps elment with missing attributes. Attributes: hash=" + hash + " version="
                        + version + " node=" + node);
    }
}
 
开发者ID:TTalkIM,项目名称:Smack,代码行数:29,代码来源:CapsExtensionProvider.java

示例3: parseTest

import org.jivesoftware.smackx.caps.packet.CapsExtension; //导入依赖的package包/类
@Test
public void parseTest() throws XmlPullParserException, IOException, SmackException {
    // @formatter:off
    final String capsExtensionString =
        "<c xmlns='http://jabber.org/protocol/caps'"
        + " hash='sha-1'"
        + " node='http://foo.example.org/bar'"
        + " ver='QgayPKawpkPSDYmwt/WM94uA1u0='/>";
    // @formatter:on
    CapsExtension capsExtension = TestUtils.parseExtensionElement(capsExtensionString);
    assertNotNull(capsExtension);
}
 
开发者ID:TTalkIM,项目名称:Smack,代码行数:13,代码来源:CapsExtensionProviderTest.java

示例4: createPresence

import org.jivesoftware.smackx.caps.packet.CapsExtension; //导入依赖的package包/类
private Presence createPresence(Presence.Mode mode) {
    String status = Preferences.getStatusMessage();
    Presence p = new Presence(Presence.Type.available);
    if (!TextUtils.isEmpty(status))
        p.setStatus(status);
    if (mode != null)
        p.setMode(mode);

    // TODO find a place for this
    p.addExtension(new CapsExtension("http://www.kontalk.org/", "none", "sha-1"));

    return p;
}
 
开发者ID:kontalk,项目名称:androidclient,代码行数:14,代码来源:MessageCenterService.java


注:本文中的org.jivesoftware.smackx.caps.packet.CapsExtension类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。