Java Code Examples for org.jivesoftware.smack.roster.RosterGroup#removeEntry()
The following examples show how to use
org.jivesoftware.smack.roster.RosterGroup#removeEntry() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: ContactList.java From Spark with Apache License 2.0 | 6 votes |
/** * 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); } } }
Example 2
Source File: XmppConnection.java From Zom-Android-XMPP with GNU General Public License v3.0 | 4 votes |
@Override protected void doRemoveContactFromListAsync(Contact contact, ContactList list) { // FIXME synchronize this to executor thread if (mConnection == null) return; String address = contact.getAddress().getAddress(); //otherwise, send unsub message and delete from local contact database org.jivesoftware.smack.packet.Presence presence = new org.jivesoftware.smack.packet.Presence( org.jivesoftware.smack.packet.Presence.Type.unsubscribe); presence.setTo(address); sendPacket(presence); presence = new org.jivesoftware.smack.packet.Presence( org.jivesoftware.smack.packet.Presence.Type.unsubscribed); presence.setTo(address); sendPacket(presence); try { RosterEntry entry = mRoster.getEntry(JidCreate.bareFrom(address)); RosterGroup group = mRoster.getGroup(list.getName()); if (entry != null) { if (group == null) { debug(TAG, "could not find group " + list.getName() + " in roster"); if (mRoster != null) mRoster.removeEntry(entry); } else { group.removeEntry(entry); entry = mRoster.getEntry(JidCreate.bareFrom(address)); // Remove from Roster if this is the last group if (entry != null && entry.getGroups().size() <= 1) mRoster.removeEntry(entry); } } } catch (Exception e) { debug(TAG, "remove entry failed: " + e.getMessage()); throw new RuntimeException(e); } notifyContactListUpdated(list, ContactListListener.LIST_CONTACT_REMOVED, contact); }
Example 3
Source File: ContactGroupTransferHandler.java From Spark with Apache License 2.0 | 4 votes |
public boolean removeContactItem(ContactGroup contactGroup, ContactItem item) { if (contactGroup.isSharedGroup()) { return false; } if (contactGroup.isUnfiledGroup()) { contactGroup.removeContactItem(item); contactGroup.fireContactGroupUpdated(); return true; } // Remove entry from Roster Group Roster roster = Roster.getInstanceFor( SparkManager.getConnection() ); RosterEntry entry = roster.getEntry(item.getJid().asBareJid()); RosterGroup rosterGroup = null; for (RosterGroup group : roster.getGroups()) { if (group.getName().equals(contactGroup.getGroupName())) { try { rosterGroup = group; group.removeEntry(entry); } catch (XMPPException | SmackException | InterruptedException e1) { return false; } } } if (rosterGroup == null) { return false; } if (!rosterGroup.contains(entry)) { contactGroup.removeContactItem(item); contactGroup.fireContactGroupUpdated(); //Updating group title return true; } return false; }
Example 4
Source File: ContactListAssistantPlugin.java From Spark with Apache License 2.0 | 4 votes |
public boolean removeContactItem(ContactGroup contactGroup, ContactItem item) { if (contactGroup.isSharedGroup()) { return false; } if (contactGroup.isUnfiledGroup()) { contactGroup.removeContactItem(item); contactGroup.fireContactGroupUpdated(); return true; } // Remove entry from Roster Group Roster roster = Roster.getInstanceFor( SparkManager.getConnection() ); RosterEntry entry = roster.getEntry(item.getJid().asBareJid()); RosterGroup rosterGroup = null; for (RosterGroup group : roster.getGroups()) { if (group.getName().equals(contactGroup.getGroupName())) { try { rosterGroup = group; group.removeEntry(entry); } catch (XMPPException | SmackException | InterruptedException e1) { return false; } } } if (rosterGroup == null) { return false; } if (!rosterGroup.contains(entry)) { contactGroup.removeContactItem(item); contactGroup.fireContactGroupUpdated(); //Updating group title return true; } return false; }