本文整理汇总了Java中org.jivesoftware.smack.RosterEntry.getType方法的典型用法代码示例。如果您正苦于以下问题:Java RosterEntry.getType方法的具体用法?Java RosterEntry.getType怎么用?Java RosterEntry.getType使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.jivesoftware.smack.RosterEntry
的用法示例。
在下文中一共展示了RosterEntry.getType方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: updateUserPresence
import org.jivesoftware.smack.RosterEntry; //导入方法依赖的package包/类
/**
* Updates the users presence.
*
* @param presence the user to update.
* @throws Exception if there is a problem while updating the user's presence.
*/
private synchronized void updateUserPresence(Presence presence) throws Exception {
if (presence.getError() != null) {
// We ignore this.
return;
}
final Roster roster = SparkManager.getConnection().getRoster();
final String bareJID = StringUtils.parseBareAddress(presence.getFrom());
RosterEntry entry = roster.getEntry(bareJID);
boolean isPending = entry != null && (entry.getType() == RosterPacket.ItemType.none || entry.getType() == RosterPacket.ItemType.from)
&& RosterPacket.ItemStatus.SUBSCRIPTION_PENDING == entry.getStatus();
// If online, check to see if they are in the offline group.
// If so, remove from offline group and add to all groups they
// belong to.
if (presence.getType() == Presence.Type.available && offlineGroup.getContactItemByJID(bareJID) != null || (presence.getFrom().indexOf("workgroup.") != -1)) {
changeOfflineToOnline(bareJID, entry, presence);
}
else if (presence.getType() == Presence.Type.available) {
updateContactItemsPresence(presence, entry, bareJID);
}
else if (presence.getType() == Presence.Type.unavailable && !isPending) {
// If not available, move to offline group.
Presence rosterPresence = PresenceManager.getPresence(bareJID);
if (!rosterPresence.isAvailable()) {
moveToOfflineGroup(presence, bareJID);
}
else {
updateContactItemsPresence(rosterPresence, entry, bareJID);
}
}
}
示例2: addUser
import org.jivesoftware.smack.RosterEntry; //导入方法依赖的package包/类
/**
* Adds a single user to the ContactList.
*
* @param entry the <code>RosterEntry</code> of the the user.
*/
private void addUser(RosterEntry entry) {
ContactItem newContactItem = UIComponentRegistry.createContactItem(entry.getName(), null, entry.getUser());
if (entry.getType() == RosterPacket.ItemType.none || entry.getType() == RosterPacket.ItemType.from) {
// Ignore, since the new user is pending to be added.
for (RosterGroup group : entry.getGroups()) {
ContactGroup contactGroup = getContactGroup(group.getName());
if (contactGroup == null) {
contactGroup = addContactGroup(group.getName());
}
boolean isPending = entry.getType() == RosterPacket.ItemType.none || entry.getType() == RosterPacket.ItemType.from
&& RosterPacket.ItemStatus.SUBSCRIPTION_PENDING == entry.getStatus();
if (isPending) {
contactGroup.setVisible(true);
}
contactGroup.addContactItem(newContactItem);
}
return;
}
else {
moveToOffline(newContactItem);
}
// Update users icon
Presence presence = SparkManager.getConnection().getRoster().getPresence(entry.getUser());
try {
updateUserPresence(presence);
}
catch (Exception e) {
Log.error(e);
}
}