Package plugins.Freetalk

Examples of plugins.Freetalk.MessageManager


        mMessageID = messageID;
  }

  public final void make() {
    try {
      MessageManager messageManager = mFreetalk.getMessageManager();
     
      synchronized(messageManager) {
        mMessage = messageManager.get(mMessageID);
       
        try {
          mBoard = messageManager.getSubscription(mOwnIdentity, mBoardName);
          mThread = mBoard.getThreadLink(mThreadID);
        }
        catch(NoSuchBoardException e) { }
        catch(NoSuchMessageException e) { }
       
View Full Code Here


  /**
   * Deletes all identities whose mLastReceivedFromWoT field does not match the ID of the last fetch (which is stored in mLast(Own)IdentityFetchID)
   */
  @SuppressWarnings("unchecked")
  private void garbageCollectIdentities(boolean ownIdentities) {
    final MessageManager messageManager = mFreetalk.getMessageManager();
    final PersistentTaskManager taskManager = mFreetalk.getTaskManager();
   
    synchronized(this) {
      // We must abort garbage collection if an identity fetch is in progress since the mLast(Own)IdentityFetchID which we use to delete
      // identities is updated AFTER the fetch has succeeded but the IDs which are stored in the identities are updated sequentially
View Full Code Here

   
    if((subscribe ^ unsubscribe) && mRequest.getMethod().equals("POST")) {
      String boardName = mRequest.getPartAsStringFailsafe("BoardName", Board.MAX_BOARDNAME_TEXT_LENGTH);
   
      try {
        MessageManager messageManager = mFreetalk.getMessageManager();
       
        if(subscribe) {
          SubscribedBoard board = messageManager.subscribeToBoard(mOwnIdentity, boardName);

          HTMLNode successBox = addContentBox(l10n().getString("SelectBoardsPage.SubscriptionSucceededBox.Header"));
                  l10n().addL10nSubstitution(
                          successBox.addChild("div"),
                          "SelectBoardsPage.SubscriptionSucceededBox.Text",
                          new String[] { "link", "boardname" },
                          new HTMLNode[] { HTMLNode.link(BoardPage.getURI(board)), HTMLNode.text(board.getName()) });
        }
        else if(unsubscribe) {
          messageManager.unsubscribeFromBoard(mOwnIdentity, boardName);
         
                    HTMLNode successBox = addContentBox(l10n().getString("SelectBoardsPage.UnsubscriptionSucceededBox.Header"));
                    l10n().addL10nSubstitution(
                        successBox.addChild("div"),
                        "SelectBoardsPage.UnsubscriptionSucceededBox.Text",
View Full Code Here

    row.addChild("th", l10n().getString("SelectBoardsPage.BoardTableHeader.Subscribe"));
    row.addChild("th", l10n().getString("SelectBoardsPage.BoardTableHeader.Unsubscribe"));
   
    DateFormat dateFormat = DateFormat.getInstance();
   
    MessageManager messageManager = mFreetalk.getMessageManager();
   
    final boolean languageFiltered = mRequest.isPartSet("BoardLanguage");   
    final String languageFilter = mRequest.getPartAsStringFailsafe("BoardLanguage", Board.MAX_BOARDNAME_TEXT_LENGTH);
    final ISO639_3.LanguageCode languageFilterCode = Board.getAllowedLanguages().get(languageFilter);
   
    synchronized(messageManager) {
      for(final Board board : messageManager.boardIteratorSortedByName()) {
        if(languageFiltered && board.getLanguage() != languageFilterCode)
          continue;
       
        row = boardsTable.addChild("tr", "id", board.getName());

        // Language
       
        row.addChild("td", "class", "language-cell", board.getLanguage().referenceName);
       
        // Name
       
        HTMLNode nameCell = row.addChild("th", "class", "name-cell");
       
        //.addChild(new HTMLNode("a", "href", Freetalk.PLUGIN_URI + "/SubscribeToBoard?identity=" + mOwnIdentity.getID() + "&name=" + board.getName(),
        //    board.getName()));

        // Description
        row.addChild("td", "class", "description-cell",  board.getDescription(mOwnIdentity));

        // First seen
        row.addChild("td", "class", "first-seen-cell", dateFormat.format(board.getFirstSeenDate()));
       
        // Latest message
        HTMLNode latestMessageCell = row.addChild("td", "class", "latest-message-cell");
       
        // Message count
        HTMLNode messageCountCell = row.addChild("td", "class", "message-count-cell");

        HTMLNode subscribeCell = row.addChild("td", new String[] { "align" }, new String[] { "center" });
        HTMLNode unsubscribeCell = row.addChild("td", new String[] { "align" }, new String[] { "center" });
       
        try {
          SubscribedBoard subscribedBoard = messageManager.getSubscription(mOwnIdentity, board.getName());
         
          // We are subscribed to that board so we can display some more information.
         
          nameCell.addChild(new HTMLNode("a", "href", BoardPage.getURI(board), board.getName()));
         
          try {
            latestMessageCell.addChild("#", dateFormat.format(subscribedBoard.getLatestMessage().getMessageDate()));
          } catch(NoSuchMessageException e) {
            latestMessageCell.addChild("#", "-");
          }
         
          messageCountCell.addChild("#", Integer.toString(subscribedBoard.messageCount()));
         
          HTMLNode unsubscribeForm = addFormChild(unsubscribeCell, Freetalk.PLUGIN_URI + "/SelectBoards" + "#" + board.getName(), "Unsubscribe");
          unsubscribeForm.addChild("input", new String[] {"type", "name", "value"}, new String[] { "hidden", "OwnIdentityID", mOwnIdentity.getID()});
          unsubscribeForm.addChild("input", new String[] {"type", "name", "value"}, new String[] { "hidden", "BoardName", board.getName()});
          if(languageFiltered) unsubscribeForm.addChild("input", new String[] {"type", "name", "value"}, new String[] { "hidden", "BoardLanguage", languageFilter});
          unsubscribeForm.addChild("input", new String[] {"type", "name", "value"}, new String[] { "submit", "Unsubscribe", l10n().getString("SelectBoardsPage.BoardTable.UnsubscribeButton") });
        } catch(NoSuchBoardException e) {
          // We are not subscribed to that board so we cannot fill all cells with information.
         
          nameCell.addChild(new HTMLNode("a", "href", NotFetchedMessagesPage.getURI(board), board.getName()));
         
          latestMessageCell.addChild("#", "-");
          messageCountCell.addChild("#", l10n().getString("Common.EstimationPrefix") + " " + messageManager.getDownloadableMessageCount(board));
         
          HTMLNode subscribeForm = addFormChild(subscribeCell, Freetalk.PLUGIN_URI + "/SelectBoards" + "#" + board.getName(), "Subscribe");
          subscribeForm.addChild("input", new String[] {"type", "name", "value"}, new String[] { "hidden", "OwnIdentityID", mOwnIdentity.getID()});
          subscribeForm.addChild("input", new String[] {"type", "name", "value"}, new String[] { "hidden", "BoardName", board.getName()});
          if(languageFiltered) subscribeForm.addChild("input", new String[] {"type", "name", "value"}, new String[] { "hidden", "BoardLanguage", languageFilter});
View Full Code Here

    checkedActivate(1);
   
    mNextProcessingTime = Long.MAX_VALUE;
    mDeleteTime = 0;
   
    final MessageManager messageManager = mFreetalk.getMessageManager();
   
    // TODO: Optimization: Use unsorted iterator, there is none right now.
    for(Board board : messageManager.boardIteratorSortedByName()) {
      try {
        messageManager.subscribeToBoard(getOwner(), board.getName()); // Does not throw if subscription exists.
      } catch(Exception e) {
        mNextProcessingTime = CurrentTimeUTC.getInMillis() + 10 * 60 * 1000;
        mDeleteTime = Long.MAX_VALUE;
      }
    }
View Full Code Here

    checkedActivate(1);
   
    mNextProcessingTime = Long.MAX_VALUE;
    mDeleteTime = 0;
   
    MessageManager messageManager = mFreetalk.getMessageManager();
   
    try {
      messageManager.getBoardByName(mBoardName);
    } catch(NoSuchBoardException e) {
      Logger.normal(this, "Not processing NewBoardTask: Board does not exist anymore: " + mBoardName);
      storeAndCommit();
      return;
    }
   
    Logger.normal(this, "Auto-Subscribing all own identities to the new board " + mBoardName  + " ...");
   
    for(OwnIdentity identity : mFreetalk.getIdentityManager().ownIdentityIterator()) {
      if(!identity.wantsAutoSubscribeToNewBoards())
        continue;
     
      try {
        messageManager.subscribeToBoard(identity, mBoardName); // Does not throw if subscription exists.
      } catch (Exception e) {
        Logger.error(this, "Auto-subscribing to board failed", e);
        mNextProcessingTime = CurrentTimeUTC.getInMillis() + 10 * 60 * 1000;
        mDeleteTime = Long.MAX_VALUE;
      }
View Full Code Here

      return;

    mWasHidden = false;
   
    try {
      MessageManager messageManager = mFreetalk.getMessageManager();
 
      // We must tell the user to solve puzzles if he as written a message ...
      if(messageManager.getOwnMessagesBy(getOwner()).size() > 0   // TODO: Optimization: Create & use get(Own)MessageCount() ...
        || messageManager.getMessagesBy(getOwner()).size() > 0) { // Also check for messages which are not stored as own messages anymore. 
       
        int minimumTrusterCount = mFreetalk.getConfig().getInt(Configuration.MINIMUM_TRUSTER_COUNT);
       
        // ... and if he has not received enough trust values.
        if(identityManager.getReceivedTrustsCount(mOwner) < minimumTrusterCount) {
View Full Code Here

TOP

Related Classes of plugins.Freetalk.MessageManager

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.