org.jivesoftware.smackx.bookmarks.BookmarkManager Java Examples

The following examples show how to use org.jivesoftware.smackx.bookmarks.BookmarkManager. 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: ConferenceServices.java    From Spark with Apache License 2.0 6 votes vote down vote up
/**
  * Load all bookmarked data.
  */
 public void loadConferenceBookmarks() {
 	final TimerTask bookmarkLoader = new TimerTask(){

@Override
public void run() {
	Collection<BookmarkedConference> bc = null;

             try {
                 while (bc == null) {
                     BookmarkManager manager = BookmarkManager.getBookmarkManager(SparkManager.getConnection());
                     bc = manager.getBookmarkedConferences();
                 }
             } catch (XMPPException | SmackException | InterruptedException error) {
                 Log.error(error);
             }
             bookmarksUI.loadUI();
             addBookmarksUI();
}
 		
 	};
 	TaskEngine.getInstance().schedule(bookmarkLoader, 500);
 }
 
Example #2
Source File: GetBookmarks.java    From jmeter-bzm-plugins with Apache License 2.0 5 votes vote down vote up
@Override
public SampleResult perform(JMeterXMPPSampler sampler, SampleResult res) throws Exception {
    BookmarkManager manager = BookmarkManager.getBookmarkManager(sampler.getXMPPConnection());
    Collection<BookmarkedConference> confs = manager.getBookmarkedConferences();
    StringBuilder text = new StringBuilder();
    for (BookmarkedConference room : confs) {
        text.append(room.getJid());
        text.append("\r\n");
    }
    res.setResponseData(text.toString().getBytes());
    return res;
}
 
Example #3
Source File: MultiUserChatLowLevelIntegrationTest.java    From Smack with Apache License 2.0 5 votes vote down vote up
@SmackIntegrationTest
public void testMucBookmarksAutojoin(AbstractXMPPConnection 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.getMucServiceDomains().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 deterministic 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();
}
 
Example #4
Source File: ConferenceUtils.java    From Spark with Apache License 2.0 4 votes vote down vote up
public static Collection<BookmarkedConference> retrieveBookmarkedConferences() throws XMPPException, SmackException, InterruptedException
{
    BookmarkManager manager = BookmarkManager.getBookmarkManager(SparkManager.getConnection());
    return manager.getBookmarkedConferences();
}