Author: xor
Date: 2008-10-29 19:40:37 +0000 (Wed, 29 Oct 2008)
New Revision: 23186
Modified:
trunk/plugins/FMSPlugin/FMSBoard.java
trunk/plugins/FMSPlugin/FMSMessage.java
trunk/plugins/FMSPlugin/WoT/FMSMessageManagerWoT.java
trunk/plugins/FMSPlugin/WoT/FMSMessageWoT.java
Log:
More implementation, begin implementing threads instead of just plain messages
without replies, I forgot about that in the beginning.
Modified: trunk/plugins/FMSPlugin/FMSBoard.java
===================================================================
--- trunk/plugins/FMSPlugin/FMSBoard.java 2008-10-29 19:39:28 UTC (rev
23185)
+++ trunk/plugins/FMSPlugin/FMSBoard.java 2008-10-29 19:40:37 UTC (rev
23186)
@@ -79,8 +79,27 @@
return;
}
- mMessages.add(newMessage);
+ if(newMessage.getParentURI() == null) {
+ mMessages.add(newMessage);
+ // FIXME: link children to the thread
+ }
+ else
+ {
+ FreenetURI parentURI = newMessage.getParentURI();
+ FMSMessage parentMessage =
mMessageManager.get(parentURI);
+ if(parentMessage == null) {
+ mMessages.add(newMessage);
+ /* FIXME: The MessageManager should try to
download the parent message if it's poster has enough trust.
+ * If it is programmed to do that, it will
check its Hashtable whether the parent message already exists.
+ * We also do that here, therefore, when
implementing parent message downloading, please do the Hashtable checking only
once.
+ */
+ return;
+ } else {
+ parentMessage.addChild(newMessage);
+ }
+ }
}
+
/**
* Get all messages in the board. The view is specified to the
FMSOwnIdentity displaying it, therefore you have to pass one as parameter.
Modified: trunk/plugins/FMSPlugin/FMSMessage.java
===================================================================
--- trunk/plugins/FMSPlugin/FMSMessage.java 2008-10-29 19:39:28 UTC (rev
23185)
+++ trunk/plugins/FMSPlugin/FMSMessage.java 2008-10-29 19:40:37 UTC (rev
23186)
@@ -13,7 +13,9 @@
import freenet.keys.FreenetURI;
import freenet.support.IndexableUpdatableSortedLinkedListItem;
+import freenet.support.UpdatableSortedLinkedList;
import freenet.support.UpdatableSortedLinkedListItemImpl;
+import freenet.support.UpdatableSortedLinkedListKilledException;
/**
* @author saces, xor
@@ -52,6 +54,11 @@
*/
private final ArrayList<FreenetURI> mAttachments;
+ /**
+ * The replies to this messages.
+ */
+ private UpdatableSortedLinkedList mChildren = new
UpdatableSortedLinkedList();
+
public FMSMessage(FreenetURI newURI, FreenetURI newParentURI,
Set<FMSBoard> newBoards, FMSIdentity newAuthor, String newTitle, Date newDate,
String newText, List<FreenetURI> newAttachments) {
if (newURI == null || newBoards == null || newAuthor == null)
throw new IllegalArgumentException();
@@ -83,6 +90,10 @@
return mURI;
}
+ public FreenetURI getParentURI() {
+ return mParentURI;
+ }
+
/**
* Get an iterator of the boards to which this message was posted.
* The boards are returned in alphabetical order.
@@ -125,6 +136,19 @@
public ArrayList<FreenetURI> getAttachments() {
return mAttachments;
}
+
+ public synchronized void addChild(FMSMessage newChild) throws
UpdatableSortedLinkedListKilledException {
+ if(mChildren.contains(newChild)) {
+ assert(false); // TODO: check whether this should be
allowed to happen.
+ return;
+ }
+
+ mChildren.add(newChild);
+ }
+
+ public synchronized Iterator<FMSMessage> childrenIterator() {
+ return mChildren.iterator();
+ }
/**
* Compare by Date to the other FMSMessage.
Modified: trunk/plugins/FMSPlugin/WoT/FMSMessageManagerWoT.java
===================================================================
--- trunk/plugins/FMSPlugin/WoT/FMSMessageManagerWoT.java 2008-10-29
19:39:28 UTC (rev 23185)
+++ trunk/plugins/FMSPlugin/WoT/FMSMessageManagerWoT.java 2008-10-29
19:40:37 UTC (rev 23186)
@@ -36,6 +36,10 @@
private Hashtable<FreenetURI, FMSMessageWoT> mMessages = new
Hashtable<FreenetURI, FMSMessageWoT>();
private ArrayList<FMSOwnIdentityWoT> mOwnIdentites = new
ArrayList<FMSOwnIdentityWoT>();
+
+ public FMSMessage get(FreenetURI uri) {
+ return mMessages.get(uri);
+ }
public synchronized FMSBoard getBoardByName(String name) {
return (FMSBoard)mBoards.get(name);
@@ -50,7 +54,7 @@
}
private synchronized void onMessageReceived(String newMessageData)
throws UpdatableSortedLinkedListKilledException {
- FMSMessageWoT newMessage = new FMSMessageWoT(null, null, null,
null, null, null, null);
+ FMSMessageWoT newMessage = new FMSMessageWoT(null, null, null,
null, null, null, null, null);
String boardName = "";
String boardDescription = "";
FMSBoard board = getBoardByName(boardName);
Modified: trunk/plugins/FMSPlugin/WoT/FMSMessageWoT.java
===================================================================
--- trunk/plugins/FMSPlugin/WoT/FMSMessageWoT.java 2008-10-29 19:39:28 UTC
(rev 23185)
+++ trunk/plugins/FMSPlugin/WoT/FMSMessageWoT.java 2008-10-29 19:40:37 UTC
(rev 23186)
@@ -21,9 +21,11 @@
*/
public class FMSMessageWoT extends FMSMessage {
- public FMSMessageWoT(FreenetURI newURI, Set<FMSBoard> newBoards,
FMSIdentity newAuthor, String newTitle, Date newDate, String newText,
- List<FreenetURI> newAttachments) {
- super(newURI, newBoards, newAuthor, newTitle, newDate, newText,
newAttachments);
+ public FMSMessageWoT(FreenetURI newURI, FreenetURI newParentURI,
Set<FMSBoard> newBoards, FMSIdentity newAuthor, String newTitle,
+ Date newDate, String newText, List<FreenetURI>
newAttachments) {
+ super(newURI, newParentURI, newBoards, newAuthor, newTitle,
newDate, newText, newAttachments);
// TODO Auto-generated constructor stub
}
+
+
}