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);
}
}
}
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);
}
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);
}
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);
}
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;
}
Aggregations