Search in sources :

Example 1 with VCardUpdate

use of com.xabber.xmpp.avatar.VCardUpdate in project xabber-android by redsolution.

the class PresenceManager method sendVCardUpdatePresence.

public void sendVCardUpdatePresence(String account, String hash) throws NetworkException {
    final Presence presence = AccountManager.getInstance().getAccount(account).getPresence();
    final VCardUpdate vCardUpdate = new VCardUpdate();
    vCardUpdate.setPhotoHash(hash);
    presence.addExtension(vCardUpdate);
    ConnectionManager.getInstance().sendStanza(account, presence);
}
Also used : Presence(org.jivesoftware.smack.packet.Presence) VCardUpdate(com.xabber.xmpp.avatar.VCardUpdate)

Example 2 with VCardUpdate

use of com.xabber.xmpp.avatar.VCardUpdate in project xabber-android by redsolution.

the class AvatarManager method onPacket.

@Override
public void onPacket(ConnectionItem connection, String bareAddress, Stanza packet) {
    if (!(packet instanceof Presence) || bareAddress == null) {
        return;
    }
    if (!(connection instanceof AccountItem)) {
        return;
    }
    String account = ((AccountItem) connection).getAccount();
    Presence presence = (Presence) packet;
    if (presence.getType() == Presence.Type.error) {
        return;
    }
    for (ExtensionElement packetExtension : presence.getExtensions()) {
        if (packetExtension instanceof VCardUpdate) {
            VCardUpdate vCardUpdate = (VCardUpdate) packetExtension;
            if (vCardUpdate.isValid() && vCardUpdate.isPhotoReady()) {
                onPhotoReady(account, bareAddress, vCardUpdate);
            }
        }
    }
}
Also used : AccountItem(com.xabber.android.data.account.AccountItem) ExtensionElement(org.jivesoftware.smack.packet.ExtensionElement) Presence(org.jivesoftware.smack.packet.Presence) VCardUpdate(com.xabber.xmpp.avatar.VCardUpdate)

Aggregations

VCardUpdate (com.xabber.xmpp.avatar.VCardUpdate)2 Presence (org.jivesoftware.smack.packet.Presence)2 AccountItem (com.xabber.android.data.account.AccountItem)1 ExtensionElement (org.jivesoftware.smack.packet.ExtensionElement)1