本文整理匯總了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;
}