Search in sources :

Example 11 with Resourcepart

use of org.jxmpp.jid.parts.Resourcepart in project Smack by igniterealtime.

the class MultiUserChatLowLevelIntegrationTest method testMucBookmarksAutojoin.

@SmackIntegrationTest
public void testMucBookmarksAutojoin(XMPPTCPConnection connection) throws InterruptedException, TestNotPossibleException, XMPPException, SmackException, IOException {
    final BookmarkManager bookmarkManager = BookmarkManager.getBookmarkManager(connection);
    if (!bookmarkManager.isSupported()) {
        throw new TestNotPossibleException("Private data storage not supported");
    }
    final MultiUserChatManager multiUserChatManager = MultiUserChatManager.getInstanceFor(connection);
    final Resourcepart mucNickname = Resourcepart.from("Nick-" + StringUtils.randomString(6));
    final String randomMucName = StringUtils.randomString(6);
    final DomainBareJid mucComponent = multiUserChatManager.getXMPPServiceDomains().get(0);
    final MultiUserChat muc = multiUserChatManager.getMultiUserChat(JidCreate.entityBareFrom(Localpart.from(randomMucName), mucComponent));
    MucCreateConfigFormHandle handle = muc.createOrJoin(mucNickname);
    if (handle != null) {
        handle.makeInstant();
    }
    muc.leave();
    bookmarkManager.addBookmarkedConference("Smack Inttest: " + testRunId, muc.getRoom(), true, mucNickname, null);
    connection.disconnect();
    connection.connect().login();
    // MucBookmarkAutojoinManager is also able to do its task automatically
    // after every login, it's not determinstic when this will be finished.
    // So we trigger it manually here.
    MucBookmarkAutojoinManager.getInstanceFor(connection).autojoinBookmarkedConferences();
    assertTrue(muc.isJoined());
    // If the test went well, leave the MUC
    muc.leave();
}
Also used : TestNotPossibleException(org.igniterealtime.smack.inttest.TestNotPossibleException) DomainBareJid(org.jxmpp.jid.DomainBareJid) MucCreateConfigFormHandle(org.jivesoftware.smackx.muc.MultiUserChat.MucCreateConfigFormHandle) BookmarkManager(org.jivesoftware.smackx.bookmarks.BookmarkManager) Resourcepart(org.jxmpp.jid.parts.Resourcepart) SmackIntegrationTest(org.igniterealtime.smack.inttest.SmackIntegrationTest)

Example 12 with Resourcepart

use of org.jxmpp.jid.parts.Resourcepart in project Smack by igniterealtime.

the class AbstractXMPPConnection method login.

/**
     * Logs in to the server using the strongest SASL mechanism supported by
     * the server. If more than the connection's default stanza(/packet) timeout elapses in each step of the 
     * authentication process without a response from the server, a
     * {@link SmackException.NoResponseException} will be thrown.
     * <p>
     * Before logging in (i.e. authenticate) to the server the connection must be connected
     * by calling {@link #connect}.
     * </p>
     * <p>
     * It is possible to log in without sending an initial available presence by using
     * {@link ConnectionConfiguration.Builder#setSendPresence(boolean)}.
     * Finally, if you want to not pass a password and instead use a more advanced mechanism
     * while using SASL then you may be interested in using
     * {@link ConnectionConfiguration.Builder#setCallbackHandler(javax.security.auth.callback.CallbackHandler)}.
     * For more advanced login settings see {@link ConnectionConfiguration}.
     * </p>
     * 
     * @throws XMPPException if an error occurs on the XMPP protocol level.
     * @throws SmackException if an error occurs somewhere else besides XMPP protocol level.
     * @throws IOException if an I/O error occurs during login.
     * @throws InterruptedException 
     */
public synchronized void login() throws XMPPException, SmackException, IOException, InterruptedException {
    // The previously used username, password and resource take over precedence over the
    // ones from the connection configuration
    CharSequence username = usedUsername != null ? usedUsername : config.getUsername();
    String password = usedPassword != null ? usedPassword : config.getPassword();
    Resourcepart resource = usedResource != null ? usedResource : config.getResource();
    login(username, password, resource);
}
Also used : Resourcepart(org.jxmpp.jid.parts.Resourcepart)

Aggregations

Resourcepart (org.jxmpp.jid.parts.Resourcepart)12 Presence (org.jivesoftware.smack.packet.Presence)7 Jid (org.jxmpp.jid.Jid)3 MucCreateConfigFormHandle (org.jivesoftware.smackx.muc.MultiUserChat.MucCreateConfigFormHandle)2 MUCItem (org.jivesoftware.smackx.muc.packet.MUCItem)2 EntityBareJid (org.jxmpp.jid.EntityBareJid)2 EntityFullJid (org.jxmpp.jid.EntityFullJid)2 ArrayList (java.util.ArrayList)1 HashMap (java.util.HashMap)1 Map (java.util.Map)1 SmackIntegrationTest (org.igniterealtime.smack.inttest.SmackIntegrationTest)1 TestNotPossibleException (org.igniterealtime.smack.inttest.TestNotPossibleException)1 NoResponseException (org.jivesoftware.smack.SmackException.NoResponseException)1 NotConnectedException (org.jivesoftware.smack.SmackException.NotConnectedException)1 XMPPConnection (org.jivesoftware.smack.XMPPConnection)1 XMPPErrorException (org.jivesoftware.smack.XMPPException.XMPPErrorException)1 Message (org.jivesoftware.smack.packet.Message)1 StandardExtensionElement (org.jivesoftware.smack.packet.StandardExtensionElement)1 BookmarkManager (org.jivesoftware.smackx.bookmarks.BookmarkManager)1 BookmarkedConference (org.jivesoftware.smackx.bookmarks.BookmarkedConference)1