/** * Returns a <code>ContactItem</code> by the users bare bareJID. * * @param bareJID the bareJID of the user. * @param searchInOffline should we search <code>ContactItem</code> in offline contacts * @return the ContactItem. */ public ContactItem getContactItemByJID(BareJid bareJID, boolean searchInOffline) { if (searchInOffline) { ContactItem item = getContactItemByJID(bareJID); if (item == null) { item = getOfflineContactItemByJID(bareJID); } return item; } return getContactItemByJID(bareJID); }
private boolean isContactItemInGroup(Collection<ContactItem> contactItems, ContactGroup group) { boolean contactInGroup = false; for (ContactItem ci : contactItems) { if (group.getContactItemByJID(ci.getJid(), true) != null) { contactInGroup = true; break; } } return contactInGroup; }
/** * Retrieve the ContactItem by it's jid. * * @param jid the JID of the user. * @return the "first" contact item found. */ public ContactItem getContactItemByJID(BareJid jid) { for (ContactGroup group : getContactGroups()) { ContactItem item = group.getContactItemByJID(jid); if (item != null) { return item; } } return null; }
/** * Selects the first user found with specified jid * @param jid, the Users JID */ public void setSelectedUser(BareJid jid) { for (ContactGroup group : getContactGroups()) { if (group.getContactItemByJID(jid) != null) { ContactItem item = group.getContactItemByJID(jid); group.getList().setSelectedValue(item, false); return; } } }
private void removeContactItem(BareJid jid) { for (ContactGroup group : new ArrayList<>( getContactGroups() )) { ContactItem item = group.getContactItemByJID(jid); group.removeOfflineContactItem(jid); if (item != null) { group.removeContactItem(item); checkGroup(group); } } }
/** * Updates the presence of one individual based on their JID. * * @param presence the users presence. * @param entry the roster entry being updated. * @param bareJID the bare jid of the user. */ private void updateContactItemsPresence(Presence presence, RosterEntry entry, BareJid bareJID) { for (ContactGroup group : groupList) { ContactItem item = group.getContactItemByJID(bareJID); if (item != null) { if (group == offlineGroup) { changeOfflineToOnline(bareJID, entry, presence); continue; } item.setPresence(presence); group.fireContactGroupUpdated(); } } }
/** * Returns a Collection of ContactItems in a ContactList. * * @param jid the users JID. * @return a Collection of <code>ContactItem</code> items. */ public Collection<ContactItem> getContactItemsByJID(Jid jid) { final BareJid bareJid = jid.asBareJid(); final List<ContactItem> list = new ArrayList<>(); for (ContactGroup group : getContactGroups()) { ContactItem item = group.getContactItemByJID(bareJid); if (item != null) { list.add(item); } } /** * We have to search ContactItems into offline contacts. * Standart getContactItemByJID() method search ContactItems only in OfflineGroup or into inline cantacts */ for( ContactGroup group : getContactGroups() ) { for (ContactItem offlineItem : group.getOfflineContacts() ) { if ( offlineItem != null && offlineItem.getJid().equals(bareJid) ) { if ( !list.contains(offlineItem) ) { list.add(offlineItem); } } } } return list; }
/** * Set an Icon for all ContactItems that match the given jid. * * @param jid the users jid. * @param icon the icon to use. */ public void setIconFor(Jid jid, Icon icon) { for (ContactGroup group : getContactGroups()) { ContactItem item = group.getContactItemByJID(jid.asBareJid()); if (item != null) { item.setIcon(icon); group.fireContactGroupUpdated(); } } }
for (ContactGroup grpItem : new ArrayList<>( groupList )) { final ContactGroup group = grpItem; final ContactItem item = group.getContactItemByJID(bareJID); if (item != null) { int numberOfMillisecondsInTheFuture = 3000; final ContactItem offlineItem = offlineGroup.getContactItemByJID(bareJID); if (offlineItem != null) { offlineItem.setPresence(presence);
/** * Sets the default settings for a ContactItem. * * @param jid the users jid. */ public void useDefaults(Jid jid) { for (ContactGroup group : getContactGroups()) { ContactItem item = group.getContactItemByJID(jid.asBareJid()); if (item != null) { item.updatePresenceIcon(item.getPresence()); group.fireContactGroupUpdated(); } } }
@Override public void doRun() { // Check to see if the user is offline, if so, move them to the offline group. Presence userPresence = PresenceManager.getPresence(bareJID); if (userPresence.isAvailable()) { return; } item.setPresence(presence); // Check for ContactItemHandler. group.removeContactItem(item); checkGroup(group); if (offlineGroup.getContactItemByJID(item.getJid()) == null) { moveToOffline(item); offlineGroup.fireContactGroupUpdated(); } } }, timeToRun);
ContactItem ci = cg.getContactItemByJID(user); if (ci != null) { ci.setAlias(newAlias);
ContactItem item = offlineGroup.getContactItemByJID(jid.asBareJid()); if (item == null) { item = contactGroup.getContactItemByJID(jid.asBareJid()); ContactItem itemFound = group.getContactItemByJID(jid.asBareJid()); if (itemFound != null && !unfiled && group != getUnfiledGroup() && group != offlineGroup) { if (!userGroupSet.contains(group.getGroupName())) { ContactItem unfiledItem = unfiledGrp.getContactItemByJID(jid.asBareJid()); if (unfiledItem != null) { ContactItem offlineItem = offlineGroup.getContactItemByJID(jid.asBareJid()); if (offlineItem != null) { if ((rosterEntry.getType() == RosterPacket.ItemType.none || rosterEntry.getType() == RosterPacket.ItemType.from)
for (ContactGroup cGroup : new ArrayList<>( getContactGroups() )) { if (cGroup.isSharedGroup()) { ContactItem it = cGroup.getContactItemByJID(item.getJid().asBareJid()); if (it != null) { isInSharedGroup = true;
/** * Removes a contact item from the group. * * @param item the ContactItem to remove. */ private void removeContactFromGroup(ContactItem item) { String groupName = item.getGroupName(); ContactGroup contactGroup = getContactGroup(groupName); Roster roster = Roster.getInstanceFor( SparkManager.getConnection() ); RosterEntry entry = roster.getEntry(item.getJid().asBareJid()); if (entry != null && contactGroup != offlineGroup) { try { RosterGroup rosterGroup = roster.getGroup(groupName); if (rosterGroup != null) { RosterEntry rosterEntry = rosterGroup.getEntry(entry.getJid()); if (rosterEntry != null) { rosterGroup.removeEntry(rosterEntry); } } contactGroup.removeContactItem(contactGroup.getContactItemByJID(item.getJid())); checkGroup(contactGroup); } catch (Exception e) { Log.error("Error removing user from contact list.", e); } } }
if (presence.getType() == Presence.Type.available && offlineGroup.getContactItemByJID(bareJID) != null || ( presence.getFrom().toString().contains( "workgroup." ) )) { changeOfflineToOnline(bareJID, entry, presence);
final ContactItem offlineItem = offlineGroup.getContactItemByJID(bareJID); if (contactGroup.getContactItemByJID(entry.getJid()) == null) { ContactItem offlineCurrentItem = contactGroup.getOfflineContactItemByJID(bareJID); if (unfiledGroup.getContactItemByJID(entry.getJid()) == null) {
if (contactGroup.getContactItemByJID(item.getJid().asBareJid(), true) != null) { return;
if (offlineGroup.getContactItemByJID(entry.getJid()) == null) { moveToOffline(contactItem);