Search in sources :

Example 46 with Presence

use of org.jivesoftware.smack.packet.Presence in project xabber-android by redsolution.

the class PresenceManager method onPacket.

@Override
public void onPacket(ConnectionItem connection, String bareAddress, Stanza stanza) {
    if (!(connection instanceof AccountItem)) {
        return;
    }
    if (!(stanza instanceof Presence)) {
        return;
    }
    Presence presence = (Presence) stanza;
    if (presence.getType() == Presence.Type.subscribe) {
        String account = ((AccountItem) connection).getAccount();
        // Subscription request
        HashSet<String> set = requestedSubscriptions.get(account);
        if (set != null && set.contains(bareAddress)) {
            try {
                acceptSubscription(account, bareAddress);
            } catch (NetworkException e) {
            }
            subscriptionRequestProvider.remove(account, bareAddress);
        } else {
            subscriptionRequestProvider.add(new SubscriptionRequest(account, bareAddress), null);
        }
    }
}
Also used : AccountItem(com.xabber.android.data.account.AccountItem) Presence(org.jivesoftware.smack.packet.Presence) NetworkException(com.xabber.android.data.NetworkException)

Example 47 with Presence

use of org.jivesoftware.smack.packet.Presence 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 48 with Presence

use of org.jivesoftware.smack.packet.Presence in project intellij-plugins by JetBrains.

the class JabberFacadeImpl method changeSubscription.

private void changeSubscription(String user, Presence.Type type) {
    Presence reply = new Presence(type);
    reply.setTo(user);
    myConnection.sendPacket(reply);
}
Also used : Presence(org.jivesoftware.smack.packet.Presence) UserPresence(jetbrains.communicator.core.users.UserPresence)

Example 49 with Presence

use of org.jivesoftware.smack.packet.Presence in project intellij-plugins by JetBrains.

the class JabberFacadeImpl method setOnlinePresence.

public void setOnlinePresence(UserPresence userPresence) {
    final Presence.Mode mode;
    String status = "";
    PresenceMode presenceMode = userPresence.getPresenceMode();
    switch(presenceMode) {
        case AWAY:
            mode = Presence.Mode.away;
            break;
        case EXTENDED_AWAY:
            mode = Presence.Mode.xa;
            break;
        case DND:
            mode = Presence.Mode.dnd;
            break;
        default:
            mode = Presence.Mode.available;
    }
    Presence presence = new Presence(Presence.Type.available, status, 0, mode);
    myConnection.sendPacket(presence);
}
Also used : PresenceMode(jetbrains.communicator.core.users.PresenceMode) Presence(org.jivesoftware.smack.packet.Presence) UserPresence(jetbrains.communicator.core.users.UserPresence)

Example 50 with Presence

use of org.jivesoftware.smack.packet.Presence in project intellij-plugins by JetBrains.

the class JabberTransport method getCurrentJabberID.

private String getCurrentJabberID(User user, RosterEntry rosterEntry) {
    Presence presence = _getPresence(user);
    String jabberId = null;
    if (presence != null) {
        jabberId = presence.getFrom();
    }
    if (jabberId == null)
        jabberId = rosterEntry.getUser();
    if (jabberId == null)
        jabberId = rosterEntry.getName();
    return jabberId;
}
Also used : Presence(org.jivesoftware.smack.packet.Presence)

Aggregations

Presence (org.jivesoftware.smack.packet.Presence)103 Message (org.jivesoftware.smack.packet.Message)21 Resourcepart (org.jxmpp.jid.parts.Resourcepart)12 Jid (org.jxmpp.jid.Jid)11 MessageTypeFilter (org.jivesoftware.smack.filter.MessageTypeFilter)10 AccountItem (com.xabber.android.data.account.AccountItem)9 UserJid (com.xabber.android.data.entity.UserJid)9 AccountJid (com.xabber.android.data.entity.AccountJid)7 StanzaCollector (org.jivesoftware.smack.StanzaCollector)7 AndFilter (org.jivesoftware.smack.filter.AndFilter)7 UserPresence (jetbrains.communicator.core.users.UserPresence)6 MUCUser (org.jivesoftware.smackx.muc.packet.MUCUser)6 BareJid (org.jxmpp.jid.BareJid)6 ClientInfo (com.xabber.android.data.extension.capability.ClientInfo)5 ArrayList (java.util.ArrayList)5 Date (java.util.Date)5 StanzaTypeFilter (org.jivesoftware.smack.filter.StanzaTypeFilter)5 MUCInitialPresence (org.jivesoftware.smackx.muc.packet.MUCInitialPresence)5 Test (org.junit.Test)5 EntityFullJid (org.jxmpp.jid.EntityFullJid)5