當前位置: 首頁>>代碼示例>>Java>>正文


Java Presence.getMode方法代碼示例

本文整理匯總了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;
}
 
開發者ID:victoryckl,項目名稱:XmppTest,代碼行數:16,代碼來源:SmackImpl.java

示例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;
}
 
開發者ID:huihoo,項目名稱:olat,代碼行數:19,代碼來源:InstantMessagingClient.java

示例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;
}
 
開發者ID:misty-rain,項目名稱:smartedu,代碼行數:16,代碼來源:SmackImpl.java

示例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;
}
 
開發者ID:kontalk,項目名稱:androidclient,代碼行數:51,代碼來源:PresenceListener.java

示例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);
}
 
開發者ID:ShadiNachat,項目名稱:Chatting-App-,代碼行數:46,代碼來源:PresenceListener.java


注:本文中的org.jivesoftware.smack.packet.Presence.getMode方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。