本文整理汇总了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));
}
示例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);
}
}
示例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);
}
示例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;
}