Author: jflesch
Date: 2007-12-16 15:44:47 +0000 (Sun, 16 Dec 2007)
New Revision: 16598

Modified:
   trunk/apps/Thaw/src/thaw/plugins/miniFrost/DraftPanel.java
   trunk/apps/Thaw/src/thaw/plugins/miniFrost/Frost.txt
   trunk/apps/Thaw/src/thaw/plugins/miniFrost/frostKSK/KSKBoard.java
   trunk/apps/Thaw/src/thaw/plugins/miniFrost/frostKSK/KSKDraft.java
   trunk/apps/Thaw/src/thaw/plugins/miniFrost/frostKSK/KSKMessageParser.java
Log:
MiniFrost: - Fix issue #1649 : Fill in the inReplyTo tag as it should ; - 
Replace message with invalid signature with remplacement messages

Modified: trunk/apps/Thaw/src/thaw/plugins/miniFrost/DraftPanel.java
===================================================================
--- trunk/apps/Thaw/src/thaw/plugins/miniFrost/DraftPanel.java  2007-12-16 
15:03:38 UTC (rev 16597)
+++ trunk/apps/Thaw/src/thaw/plugins/miniFrost/DraftPanel.java  2007-12-16 
15:44:47 UTC (rev 16598)
@@ -91,13 +91,16 @@

                authorBox = new JComboBox();
                authorBox.setEditable(true);
+               authorBox.setBackground(java.awt.Color.WHITE);

                subjectField = new JTextField("");
                subjectField.setEditable(true);
+               subjectField.setBackground(java.awt.Color.WHITE);

                /* recipient box */

                recipientBox = new JComboBox();
+               subjectField.setBackground(java.awt.Color.WHITE);

                /* content will be updated when setDraft() will be called 
                 * to take into consideration people marked as GOOD recently

Modified: trunk/apps/Thaw/src/thaw/plugins/miniFrost/Frost.txt
===================================================================
--- trunk/apps/Thaw/src/thaw/plugins/miniFrost/Frost.txt        2007-12-16 
15:03:38 UTC (rev 16597)
+++ trunk/apps/Thaw/src/thaw/plugins/miniFrost/Frost.txt        2007-12-16 
15:44:47 UTC (rev 16598)
@@ -62,8 +62,7 @@
        IDs are comma separated (no space).
        (Note : why not using xml tags instead of commas ?)

-       Atm, Thaw only provides the latest id (Frost seems to accept
-       it). In any case, Thaw will only use the latest id (to avoid a
+       Thaw only uses the latest id (to avoid a
        flooder sending messages with 20 false inReplyTo id per
        message & because it's easier to implement :)
  -->

Modified: trunk/apps/Thaw/src/thaw/plugins/miniFrost/frostKSK/KSKBoard.java
===================================================================
--- trunk/apps/Thaw/src/thaw/plugins/miniFrost/frostKSK/KSKBoard.java   
2007-12-16 15:03:38 UTC (rev 16597)
+++ trunk/apps/Thaw/src/thaw/plugins/miniFrost/frostKSK/KSKBoard.java   
2007-12-16 15:44:47 UTC (rev 16598)
@@ -745,7 +745,7 @@

        public void refresh(int maxDaysInThePast) {
                if (refreshing) {
-                       Logger.warning(this, "Already refreshing");
+                       Logger.notice(this, "Already refreshing");
                        return;
                }


Modified: trunk/apps/Thaw/src/thaw/plugins/miniFrost/frostKSK/KSKDraft.java
===================================================================
--- trunk/apps/Thaw/src/thaw/plugins/miniFrost/frostKSK/KSKDraft.java   
2007-12-16 15:03:38 UTC (rev 16597)
+++ trunk/apps/Thaw/src/thaw/plugins/miniFrost/frostKSK/KSKDraft.java   
2007-12-16 15:44:47 UTC (rev 16598)
@@ -217,7 +217,8 @@

        private void startInsertion() {
                /* we generate first the XML message */
-               KSKMessageParser generator = new KSKMessageParser( ((inReplyTo 
!= null) ? inReplyTo.getMsgId() : null),
+               KSKMessageParser generator = new 
KSKMessageParser(board.getFactory().getDb(),
+                                                                       
((inReplyTo != null) ? inReplyTo.getMsgId() : null),
                                                                          nick,
                                                                          
subject,
                                                                          date,
@@ -230,7 +231,7 @@
                                                                           
idLinePos,
                                                                           
idLineLen);

-               fileToInsert = generator.generateXML();
+               fileToInsert = generator.generateXML(board.getFactory().getDb() 
/* gruick */);


                waiting = false;

Modified: 
trunk/apps/Thaw/src/thaw/plugins/miniFrost/frostKSK/KSKMessageParser.java
===================================================================
--- trunk/apps/Thaw/src/thaw/plugins/miniFrost/frostKSK/KSKMessageParser.java   
2007-12-16 15:03:38 UTC (rev 16597)
+++ trunk/apps/Thaw/src/thaw/plugins/miniFrost/frostKSK/KSKMessageParser.java   
2007-12-16 15:44:47 UTC (rev 16598)
@@ -44,6 +44,7 @@

        private String messageId;
        private String inReplyTo;
+       private String inReplyToFull;
        private String from;
        private String subject;
        private String date;
@@ -68,7 +69,8 @@
        private static FrostCrypt frostCrypt;


-       public KSKMessageParser(String inReplyTo, /* msg id */
+       public KSKMessageParser(Hsqldb db,
+                               String inReplyTo, /* msg id */
                                String from,
                                String subject,
                                java.util.Date dateUtil,
@@ -103,6 +105,8 @@
                this.attachments = attachments;

                this.identity = identity;
+               
+               inReplyToFull = getFullInReplyTo(db, inReplyTo);

                if (frostCrypt == null)
                        frostCrypt = new FrostCrypt();
@@ -210,6 +214,7 @@

                                /* we search the message to this one answer */
                                if (inReplyTo != null) {
+                                       inReplyToFull = inReplyTo;
                                        String[] split = inReplyTo.split(",");
                                        inReplyTo = split[split.length-1];

@@ -335,8 +340,8 @@
                allContent.append(from).append(SIGNATURE_ELEMENTS_SEPARATOR);
                if (withMsgId)
                        
allContent.append(messageId).append(SIGNATURE_ELEMENTS_SEPARATOR);
-               if( inReplyTo != null && inReplyTo.length() > 0 ) {
-                       
allContent.append(inReplyTo).append(SIGNATURE_ELEMENTS_SEPARATOR);
+               if( inReplyToFull != null && inReplyToFull.length() > 0 ) {
+                       
allContent.append(inReplyToFull).append(SIGNATURE_ELEMENTS_SEPARATOR);
                }
                if( recipient != null && recipient.length() > 0 ) {
                        
allContent.append(recipient).append(SIGNATURE_ELEMENTS_SEPARATOR);
@@ -379,9 +384,10 @@

                if (!ret) {
                        Logger.notice(this, "Invalid signature !");
+                       return invalidMessage("Invalid signature");
                }

-               return ret;
+               return true;
        }


@@ -389,6 +395,7 @@
        protected boolean loadXMLElements(Element root) {
                messageId     = XMLTools.getChildElementsCDATAValue(root, 
"MessageId");
                inReplyTo     = XMLTools.getChildElementsCDATAValue(root, 
"InReplyTo");
+               inReplyToFull = inReplyTo;
                from          = XMLTools.getChildElementsCDATAValue(root, 
"From");
                subject       = XMLTools.getChildElementsCDATAValue(root, 
"Subject");
                date          = XMLTools.getChildElementsCDATAValue(root, 
"Date");
@@ -501,6 +508,8 @@
                /* (I'm still thinking that mixing up Boards & private messages 
is a BAD idea) */

                inReplyTo = null;
+               inReplyToFull = null;
+
                from = 
"["+I18n.getMessage("thaw.plugin.miniFrost.encrypted")+"]";
                subject = 
"["+I18n.getMessage("thaw.plugin.miniFrost.encryptedBody").replaceAll("X", 
recipient)+"]";

@@ -538,6 +547,7 @@
                /* the goal is to not download this message again */

                inReplyTo = null;
+               inReplyToFull = null;
                from = 
"["+I18n.getMessage("thaw.plugin.miniFrost.invalidMessage")+"]";
                subject = 
"["+I18n.getMessage("thaw.plugin.miniFrost.invalidMessage")+"]";

@@ -646,8 +656,49 @@
                return current;
        }

+       public String getFullInReplyTo(Hsqldb db, String inReplyTo) {
+               String lastId = inReplyTo;
+               
+               PreparedStatement st;
+               
+               try {
+                       st = db.getConnection().prepareStatement("SELECT 
inReplyToId FROM frostKSKMessages "+
+                                                                               
                        "WHERE msgId = ? LIMIT 1");
+               } catch(SQLException e) {
+                       Logger.error(this, "Can't get full inReplyTo String 
because: "+e.toString());
+                       return inReplyTo;
+               }
+               
+               while(lastId != null) {
+                       /* I don't remember if inReplyTo is correctly set, so 
we will
+                        * use inReplyToId to be safer
+                        */
+                       
+                       try {
+                               synchronized(db.dbLock) {
+                                                                       
+                                       st.setString(1, lastId);
+                                       
+                                       ResultSet set = st.executeQuery();
+                                       
+                                       if (set.next()) {
+                                               lastId = 
set.getString("inReplyToId");
+                                               
+                                               if (lastId != null)
+                                                       inReplyTo = lastId + 
","+inReplyTo;
+                                       } else
+                                               lastId = null;
+                               }                               
+                       } catch(SQLException e) {
+                               Logger.error(this, "Can't find message parent 
because : "+e.toString());
+                               lastId = null;
+                       }
+               }
+               
+               return inReplyTo;
+       }

-       public Element getXMLTree(Document doc) {
+       public Element getXMLTree(Hsqldb db, Document doc) {
                Element root = doc.createElement("FrostMessage");

                Element el;
@@ -655,7 +706,7 @@
                if ((el = makeText( doc, "client",    "Thaw 
"+thaw.core.Main.VERSION)) != null)
                        root.appendChild(el);
                if ((el = makeCDATA(doc, "MessageId", messageId)) != null)   
root.appendChild(el);
-               if ((el = makeCDATA(doc, "InReplyTo", inReplyTo)) != null)   
root.appendChild(el);
+               if ((el = makeCDATA(doc, "InReplyTo", inReplyToFull)) != null)  
 root.appendChild(el);
                if ((el = makeText( doc, "IdLinePos", idLinePos)) != null)   
root.appendChild(el);
                if ((el = makeText( doc, "IdLineLen", idLineLen)) != null)   
root.appendChild(el);
                if ((el = makeCDATA(doc, "From", from)) != null)             
root.appendChild(el);
@@ -736,7 +787,7 @@
        }


-       public File generateXML() {
+       public File generateXML(Hsqldb db) {
                File tmpFile;

                try {
@@ -749,7 +800,7 @@

                Document doc = XMLTools.createDomDocument();

-               doc.appendChild(getXMLTree(doc));
+               doc.appendChild(getXMLTree(db, doc));

                File clearMsg = (XMLTools.writeXmlFile(doc, tmpFile.getPath()) 
? tmpFile : null);



Reply via email to