Java Code Examples for org.jivesoftware.smack.roster.Roster#removeEntry()
The following examples show how to use
org.jivesoftware.smack.roster.Roster#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: RosterManager.java From mangosta-android with Apache License 2.0 | 6 votes |
public void removeContact(String jidString) throws SmackException.NotLoggedInException, InterruptedException, SmackException.NotConnectedException, XMPPException.XMPPErrorException, SmackException.NoResponseException, XmppStringprepException { Roster roster = Roster.getInstanceFor(XMPPSession.getInstance().getXMPPConnection()); if (!roster.isLoaded()) { roster.reloadAndWait(); } BareJid jid = JidCreate.bareFrom(jidString); roster.removeEntry(roster.getEntry(jid)); Presence presence = new Presence(Presence.Type.unsubscribe); presence.setTo(JidCreate.from(jidString)); XMPPSession.getInstance().sendStanza(presence); }
Example 2
Source File: Client.java From desktopclient-java with GNU General Public License v3.0 | 6 votes |
public boolean removeFromRoster(JID jid) { if (!this.isConnected()) { LOGGER.info("not connected"); return false; } Roster roster = Roster.getInstanceFor(mConn); RosterEntry entry = roster.getEntry(jid.toBareSmack()); if (entry == null) { LOGGER.info("can't find roster entry for jid: "+jid); return true; } try { // blocking roster.removeEntry(entry); } catch (SmackException.NotLoggedInException | SmackException.NoResponseException | XMPPException.XMPPErrorException | SmackException.NotConnectedException | InterruptedException ex) { LOGGER.log(Level.WARNING, "can't remove contact from roster", ex); return false; } return true; }
Example 3
Source File: RosterManager.java From mangosta-android with Apache License 2.0 | 5 votes |
public void removeAllContacts() throws SmackException.NotLoggedInException, InterruptedException, SmackException.NotConnectedException, XMPPException.XMPPErrorException, SmackException.NoResponseException { Roster roster = Roster.getInstanceFor(XMPPSession.getInstance().getXMPPConnection()); if (!roster.isLoaded()) { roster.reloadAndWait(); } for (RosterEntry entry : roster.getEntries()) { roster.removeEntry(entry); Presence presence = new Presence(Presence.Type.unsubscribe); presence.setTo(entry.getJid()); XMPPSession.getInstance().sendStanza(presence); } }
Example 4
Source File: OmemoManagerSetupHelper.java From Smack with Apache License 2.0 | 5 votes |
public static void cleanUpRoster(OmemoManager omemoManager) { Roster roster = Roster.getInstanceFor(omemoManager.getConnection()); for (RosterEntry r : roster.getEntries()) { try { roster.removeEntry(r); } catch (InterruptedException | SmackException.NoResponseException | SmackException.NotConnectedException | XMPPException.XMPPErrorException | SmackException.NotLoggedInException e) { // Silent } } }
Example 5
Source File: IntegrationTestRosterUtil.java From Smack with Apache License 2.0 | 5 votes |
private static void notInRoster(XMPPConnection c1, XMPPConnection c2) throws NotLoggedInException, NoResponseException, XMPPErrorException, NotConnectedException, InterruptedException { Roster roster = Roster.getInstanceFor(c1); RosterEntry c2Entry = roster.getEntry(c2.getUser().asBareJid()); if (c2Entry == null) { return; } roster.removeEntry(c2Entry); }
Example 6
Source File: UriManager.java From Spark with Apache License 2.0 | 5 votes |
/** * Handles the ?remove URI * * @param uri * the decoded uri * @throws Exception */ public void handleRemove(URI uri) throws Exception { // xmpp:[email protected]?remove BareJid jid; try { jid = JidCreate.bareFrom(retrieveJID(uri)); } catch (XmppStringprepException e) { throw new IllegalStateException(e); } Roster roster = Roster.getInstanceFor( SparkManager.getConnection() ); RosterEntry entry = roster.getEntry(jid); roster.removeEntry(entry); }
Example 7
Source File: ContactList.java From Spark with Apache License 2.0 | 5 votes |
private void removeContactFromRoster(ContactItem item) { Roster roster = Roster.getInstanceFor( SparkManager.getConnection() ); RosterEntry entry = roster.getEntry(item.getJid().asBareJid()); if (entry != null) { try { roster.removeEntry(entry); } catch (XMPPException | SmackException | InterruptedException e) { Log.warning("Unable to remove roster entry.", e); } } }