Author: xor
Date: 2008-10-29 14:15:30 +0000 (Wed, 29 Oct 2008)
New Revision: 23168

Modified:
   trunk/plugins/FMSPlugin/FMSBoard.java
   trunk/plugins/FMSPlugin/FMSIdentity.java
   trunk/plugins/FMSPlugin/FMSMessage.java
   trunk/plugins/FMSPlugin/FMSMessageManager.java
   trunk/plugins/FMSPlugin/FMSOwnIdentity.java
Log:
Lots of interface changes.

Modified: trunk/plugins/FMSPlugin/FMSBoard.java
===================================================================
--- trunk/plugins/FMSPlugin/FMSBoard.java       2008-10-29 01:11:15 UTC (rev 
23167)
+++ trunk/plugins/FMSPlugin/FMSBoard.java       2008-10-29 14:15:30 UTC (rev 
23168)
@@ -7,6 +7,7 @@
 import java.util.Hashtable;
 import java.util.Iterator;
 import java.util.LinkedList;
+import java.util.ListIterator;
 import java.util.NoSuchElementException;

 import freenet.keys.FreenetURI;
@@ -22,7 +23,8 @@
         * FIXME: We need a datastructure which is a HashTable and a LinkedList 
which is sorted by Date of the messages.
         * java.util.LinkedHashSet is the right thing but it does not provide 
sorting. 
         */
-       private final Hashtable<FreenetURI, FMSMessage> mMessages = new 
HashTable<FreenetURI, FMSMessage>();
+       private final Hashtable<FreenetURI, FMSMessage> mMessages = new 
Hashtable<FreenetURI, FMSMessage>();
+       /* FIXME: Use UpdatableSortedLinkedList<FMSMessage> as soon as it is 
implemented */
        private final LinkedList<FMSMessage> mMessagesSorted = new 
LinkedList<FMSMessage>();
        private final FMSMessageManager mMessageManager;
        private final String mName;
@@ -61,6 +63,18 @@
        public String getName() {
                return mName;
        }
+       
+       public void addMessage(FMSMessage newMessage) {
+               if(mMessages.put(newMessage.getURI(), newMessage) != null) {
+                       /* The message was already stored */
+                       assert(false); /* TODO: Add logging. I don't know 
whether this should happen. */
+                       return;
+               }
+               
+               /* FIXME: As soon as mMessagesSorted is implemented uncomment 
this
+               mMessagesSorted.put(newMessage);
+               */ 
+       }

        /**
         * Get all messages in the board. The view is specified to the 
FMSOwnIdentity displaying it, therefore you have to pass one as parameter.
@@ -92,7 +106,7 @@
                                throw new UnsupportedOperationException();
                        }

-               }
+               };
        }

 }

Modified: trunk/plugins/FMSPlugin/FMSIdentity.java
===================================================================
--- trunk/plugins/FMSPlugin/FMSIdentity.java    2008-10-29 01:11:15 UTC (rev 
23167)
+++ trunk/plugins/FMSPlugin/FMSIdentity.java    2008-10-29 14:15:30 UTC (rev 
23168)
@@ -4,6 +4,7 @@
 package plugins.FMSPlugin;

 import java.util.Date;
+import java.util.Iterator;

 import freenet.keys.FreenetURI;


Modified: trunk/plugins/FMSPlugin/FMSMessage.java
===================================================================
--- trunk/plugins/FMSPlugin/FMSMessage.java     2008-10-29 01:11:15 UTC (rev 
23167)
+++ trunk/plugins/FMSPlugin/FMSMessage.java     2008-10-29 14:15:30 UTC (rev 
23168)
@@ -4,7 +4,9 @@
 package plugins.FMSPlugin;

 import java.util.Date;
+import java.util.Iterator;
 import java.util.List;
+import java.util.SortedSet;

 import freenet.keys.FreenetURI;

@@ -16,6 +18,8 @@

        public final FreenetURI mURI;

+       public final SortedSet<FMSBoard> mBoards; 
+       
        public final FMSIdentity mAuthor;

        public final String mTitle;
@@ -25,8 +29,9 @@
         */
        public final Date mDate;

-       public FMSMessage(FreenetURI newURI, FMSIdentity newAuthor, String 
newTitle, Date newDate) {
+       public FMSMessage(FreenetURI newURI, SortedSet<FMSBoard> newBoards, 
FMSIdentity newAuthor, String newTitle, Date newDate) {
                mURI = newURI;
+               mBoards = newBoards;
                mAuthor = newAuthor;
                mTitle = newTitle;
                mDate = newDate; // TODO: Check out whether Date provides a 
function for getting the timezone and throw an Exception if not UTC.
@@ -39,6 +44,10 @@
        public FreenetURI getURI() {
                return mURI;
        }
+       
+       public Iterator<FMSBoard> getBoardIterator() {
+               return mBoards.iterator();
+       }

        /**
         * Get the author of the message.

Modified: trunk/plugins/FMSPlugin/FMSMessageManager.java
===================================================================
--- trunk/plugins/FMSPlugin/FMSMessageManager.java      2008-10-29 01:11:15 UTC 
(rev 23167)
+++ trunk/plugins/FMSPlugin/FMSMessageManager.java      2008-10-29 14:15:30 UTC 
(rev 23168)
@@ -9,17 +9,14 @@
  * @author xor
  *
  */
-public abstract class FMSMessageManager {
-
-       private FMSIdentityManager mIdentityManager;
+public interface FMSMessageManager {

-       public FMSMessageManager(FMSIdentityManager newIdentityManager) {
-               mIdentityManager = newIdentityManager;
-       }
+       public FMSBoard getBoardByName(String name);

-       public abstract FMSBoard getBoardByName(String name);  
-       
-       public abstract Iterator<FMSBoard> boardIterator(FMSOwnIdentity 
identity);
-       
-       public abstract Iterator<FMSMessage> messageIterator(FMSOwnIdentity 
identity);
+       /**
+        * Get an iterator of boards which the identity could subscribe to.
+        * @param identity
+        * @return
+        */
+       public Iterator<FMSBoard> boardIterator(FMSOwnIdentity identity);
 }

Modified: trunk/plugins/FMSPlugin/FMSOwnIdentity.java
===================================================================
--- trunk/plugins/FMSPlugin/FMSOwnIdentity.java 2008-10-29 01:11:15 UTC (rev 
23167)
+++ trunk/plugins/FMSPlugin/FMSOwnIdentity.java 2008-10-29 14:15:30 UTC (rev 
23168)
@@ -4,6 +4,8 @@
 package plugins.FMSPlugin;

 import java.util.Date;
+import java.util.Iterator;
+
 import freenet.keys.FreenetURI;

 /**
@@ -16,22 +18,13 @@

        public Date getLastInsert();

-       /*
-       public final void exportXML(OutputStream out) throws IOException {
-               Writer w = new BufferedWriter(new OutputStreamWriter(out));
-               w.write("<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n");
-               w.write("<Identity\n");
-               w.write("\t<Name><![CDATA[");
-               XMLUtils.writeEsc(w, getNickName());
-               w.write("]]></Name>\n");
-               
-               w.write("\t<SingleUse>false</SingleUse>\n");
-               w.write("\t<PublishTrustList>false</PublishTrustList>\n");
-               w.write("\t<PublishBoardList>false</PublishBoardList>\n");
-
-               w.write("<Identity\n");
-               w.flush();
-               w.close();
-       }
-       */
+       public boolean wantsMessagesFrom(FMSIdentity identity);
+       
+       public void postMessage(FMSMessage message);
+       
+       public void subscribeToBoard(FMSBoard board);
+       
+       public void unsubscribeFromBoard(FMSBoard board);
+       
+       public Iterator<FMSBoard> subscribedBoardsIterator();
 }


Reply via email to