本文整理匯總了Java中org.jivesoftware.smack.packet.Presence.getMode方法的典型用法代碼示例。如果您正苦於以下問題:Java Presence.getMode方法的具體用法?Java Presence.getMode怎麽用?Java Presence.getMode使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類org.jivesoftware.smack.packet.Presence
的用法示例。
在下文中一共展示了Presence.getMode方法的5個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: getStatus
import org.jivesoftware.smack.packet.Presence; //導入方法依賴的package包/類
/**
* 獲取狀態
*
* @param presence
* @return
*/
private StatusMode getStatus(Presence presence) {
if (presence.getType() == Presence.Type.available) {
if (presence.getMode() != null) {
return StatusMode.valueOf(presence.getMode().name());
}
return StatusMode.available;
}
return StatusMode.offline;
}
示例2: getUserPresence
import org.jivesoftware.smack.packet.Presence; //導入方法依賴的package包/類
/**
* Used by Velocity renderer
*
* @param jid
* @return get a presence for a specific user
*/
protected String getUserPresence(final String jid) {
final Presence presence = connection.getRoster().getPresence(jid);
String imageName = "offline"; // default
// mode == null is equals available!!
if (presence.getMode() == null && presence.getType() == Presence.Type.available) {
imageName = Presence.Mode.available.toString();
}
if (presence.getMode() != null) {
imageName = presence.getMode().toString();
}
return imageName;
}
示例3: getStatus
import org.jivesoftware.smack.packet.Presence; //導入方法依賴的package包/類
/**
* 獲取當前狀態
*
* @param presence
* @return
*/
private StatusMode getStatus(Presence presence) {
if (presence.getType() == Presence.Type.available) {
if (presence.getMode() != null) {
return StatusMode.valueOf(presence.getMode().name());
}
return StatusMode.available;
}
return StatusMode.offline;
}
示例4: createIntent
import org.jivesoftware.smack.packet.Presence; //導入方法依賴的package包/類
public static Intent createIntent(Context ctx, Presence p, RosterEntry entry) {
Intent i = new Intent(ACTION_PRESENCE);
Presence.Type type = p.getType();
i.putExtra(EXTRA_TYPE, type != null ? type.name() : Presence.Type.available.name());
i.putExtra(EXTRA_PACKET_ID, p.getStanzaId());
i.putExtra(EXTRA_FROM, StringUtils.maybeToString(p.getFrom().toString()));
i.putExtra(EXTRA_TO, StringUtils.maybeToString(p.getTo()));
i.putExtra(EXTRA_STATUS, p.getStatus());
Presence.Mode mode = p.getMode();
i.putExtra(EXTRA_SHOW, mode != null ? mode.name() : Presence.Mode.available.name());
i.putExtra(EXTRA_PRIORITY, p.getPriority());
String jid = p.getFrom().asBareJid().toString();
long timestamp;
DelayInformation delay = p.getExtension(DelayInformation.ELEMENT, DelayInformation.NAMESPACE);
if (delay != null) {
timestamp = delay.getStamp().getTime();
}
else {
// try last seen from database
timestamp = UsersProvider.getLastSeen(ctx, jid);
if (timestamp < 0)
timestamp = System.currentTimeMillis();
}
i.putExtra(EXTRA_STAMP, timestamp);
// public key fingerprint
String fingerprint = PublicKeyPresence.getFingerprint(p);
if (fingerprint == null) {
// try untrusted fingerprint from database
fingerprint = Keyring.getFingerprint(ctx, jid, MyUsers.Keys.TRUST_UNKNOWN);
}
i.putExtra(EXTRA_FINGERPRINT, fingerprint);
// subscription information
if (entry != null) {
i.putExtra(EXTRA_ROSTER_NAME, entry.getName());
RosterPacket.ItemType subscriptionType = entry.getType();
i.putExtra(EXTRA_SUBSCRIBED_FROM, subscriptionType == RosterPacket.ItemType.both ||
subscriptionType == RosterPacket.ItemType.from);
i.putExtra(EXTRA_SUBSCRIBED_TO, subscriptionType == RosterPacket.ItemType.both ||
subscriptionType == RosterPacket.ItemType.to);
}
return i;
}
示例5: handlePresence
import org.jivesoftware.smack.packet.Presence; //導入方法依賴的package包/類
private void handlePresence(Presence p) {
Intent i = new Intent(ACTION_PRESENCE);
Presence.Type type = p.getType();
i.putExtra(EXTRA_TYPE, type != null ? type.name() : Presence.Type.available.name());
i.putExtra(EXTRA_PACKET_ID, p.getPacketID());
String from = p.getFrom();
String network = StringUtils.parseServer(from);
// our network - convert to userId
if (network.equalsIgnoreCase(getServer().getNetwork())) {
StringBuilder b = new StringBuilder();
b.append(StringUtils.parseName(from));
b.append(StringUtils.parseResource(from));
i.putExtra(EXTRA_FROM_USERID, b.toString());
}
i.putExtra(EXTRA_FROM, from);
i.putExtra(EXTRA_TO, p.getTo());
i.putExtra(EXTRA_STATUS, p.getStatus());
Presence.Mode mode = p.getMode();
i.putExtra(EXTRA_SHOW, mode != null ? mode.name() : Presence.Mode.available.name());
i.putExtra(EXTRA_PRIORITY, p.getPriority());
// getExtension doesn't work here
Iterator<PacketExtension> iter = p.getExtensions().iterator();
while (iter.hasNext()) {
PacketExtension _ext = iter.next();
if (_ext instanceof DelayInformation) {
DelayInformation delay = (DelayInformation) _ext;
i.putExtra(EXTRA_STAMP, delay.getStamp().getTime());
break;
}
}
// non-standard stanza group extension
PacketExtension ext = p.getExtension(StanzaGroupExtension.ELEMENT_NAME, StanzaGroupExtension.NAMESPACE);
if (ext != null && ext instanceof StanzaGroupExtension) {
StanzaGroupExtension g = (StanzaGroupExtension) ext;
i.putExtra(EXTRA_GROUP_ID, g.getId());
i.putExtra(EXTRA_GROUP_COUNT, g.getCount());
}
Log.v(MessageCenterService.TAG, "broadcasting presence: " + i);
sendBroadcast(i);
}