use of org.jivesoftware.smackx.caps.packet.CapsExtension in project xabber-android by redsolution.
the class CapabilitiesManager method onPresenceChanged.
public void onPresenceChanged(final String account, final Presence presence) {
final String user = Jid.getStringPrep(presence.getFrom());
if (user == null)
return;
if (presence.getType() == Presence.Type.error)
return;
if (presence.getType() == Presence.Type.unavailable) {
userCapabilities.remove(account, user);
return;
}
LogManager.i(this, "onPresenceChanged " + user);
for (ExtensionElement packetExtension : presence.getExtensions()) {
if (packetExtension instanceof CapsExtension) {
CapsExtension capsExtension = (CapsExtension) packetExtension;
if (capsExtension.getNode() == null || capsExtension.getVer() == null) {
continue;
}
Capability capability = new Capability(account, user, capsExtension.getHash(), capsExtension.getNode(), capsExtension.getVer());
if (capability.equals(userCapabilities.get(account, user))) {
continue;
}
userCapabilities.put(account, user, capability);
ClientInfo clientInfo = clientInformations.get(capability);
if (clientInfo == null || clientInfo == INVALID_CLIENT_INFO) {
request(account, presence.getFrom(), capability);
}
}
}
}
use of org.jivesoftware.smackx.caps.packet.CapsExtension in project Smack by igniterealtime.
the class CapsExtensionProviderTest method parseTest.
@Test
public void parseTest() throws Exception {
// @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);
}
Aggregations