Search in sources :

Example 1 with Roster

use of org.jivesoftware.smack.Roster in project Smack by igniterealtime.

the class ConnectionUtils method becomeFriends.

public static void becomeFriends(XMPPConnection con0, XMPPConnection con1) throws XMPPException {
    Roster r0 = con0.getRoster();
    Roster r1 = con1.getRoster();
    r0.setSubscriptionMode(Roster.SubscriptionMode.accept_all);
    r1.setSubscriptionMode(Roster.SubscriptionMode.accept_all);
    r0.createEntry(con1.getUser(), "u2", null);
    r1.createEntry(con0.getUser(), "u1", null);
}
Also used : Roster(org.jivesoftware.smack.Roster)

Example 2 with Roster

use of org.jivesoftware.smack.Roster in project intellij-plugins by JetBrains.

the class JabberSyncUserMessage method send.

public boolean send(User user) {
    final JabberTransport jabberTransport = JabberTransport.getInstance();
    if (jabberTransport != null && jabberTransport.isOnline()) {
        final Roster roster = jabberTransport.getFacade().getConnection().getRoster();
        final RosterEntry userEntry = roster.getEntry(myEvent.getUser().getName());
        if (userEntry != null) {
            jabberTransport.runIngnoringUserEvents(() -> processEvent(jabberTransport.getFacade(), userEntry));
        }
        return true;
    }
    return false;
}
Also used : Roster(org.jivesoftware.smack.Roster) RosterEntry(org.jivesoftware.smack.RosterEntry)

Example 3 with Roster

use of org.jivesoftware.smack.Roster in project intellij-plugins by JetBrains.

the class JabberFacade_ConnectionTest method testAddUsers.

public void testAddUsers() throws Exception {
    createGoodAccount(myUser, myFacade);
    final String bob = "bob@jabber.org";
    String self = myFacade.getConnection().getUser();
    myFacade.addUsers("someGroup", Arrays.asList(self, bob));
    final Roster roster = myFacade.getConnection().getRoster();
    new WaitFor(500) {

        @Override
        protected boolean condition() {
            return roster.contains(bob);
        }
    };
    assertTrue("User should be added to the Roster", roster.contains(bob));
    assertFalse("Self should not be added to the Roster", roster.contains(self));
    new WaitFor(200) {

        @Override
        protected boolean condition() {
            return roster.getEntry(bob).getGroups().size() > 0;
        }
    };
    assertEquals("Bad Group", "someGroup", roster.getEntry(bob).getGroups().iterator().next().getName());
}
Also used : Roster(org.jivesoftware.smack.Roster) WaitFor(jetbrains.communicator.util.WaitFor)

Aggregations

Roster (org.jivesoftware.smack.Roster)3 WaitFor (jetbrains.communicator.util.WaitFor)1 RosterEntry (org.jivesoftware.smack.RosterEntry)1