Author: jflesch
Date: 2007-08-17 12:56:35 +0000 (Fri, 17 Aug 2007)
New Revision: 14739
Modified:
trunk/apps/Thaw/src/thaw/i18n/source.thaw_fr.properties
trunk/apps/Thaw/src/thaw/i18n/thaw.properties
trunk/apps/Thaw/src/thaw/i18n/thaw_fr.properties
trunk/apps/Thaw/src/thaw/plugins/miniFrost/DraftPanel.java
trunk/apps/Thaw/src/thaw/plugins/miniFrost/MessageTreeTable.java
trunk/apps/Thaw/src/thaw/plugins/miniFrost/frostKSK/KSKAttachment.java
trunk/apps/Thaw/src/thaw/plugins/miniFrost/frostKSK/KSKBoardAttachment.java
trunk/apps/Thaw/src/thaw/plugins/miniFrost/frostKSK/KSKDraft.java
trunk/apps/Thaw/src/thaw/plugins/miniFrost/frostKSK/KSKFileAttachment.java
trunk/apps/Thaw/src/thaw/plugins/miniFrost/frostKSK/KSKMessageParser.java
trunk/apps/Thaw/src/thaw/plugins/miniFrost/frostKSK/SSKBoard.java
trunk/apps/Thaw/src/thaw/plugins/miniFrost/interfaces/Draft.java
trunk/apps/Thaw/src/thaw/plugins/miniFrost/interfaces/Message.java
Log:
Display the message revision in advanced mode
Modified: trunk/apps/Thaw/src/thaw/i18n/source.thaw_fr.properties
===================================================================
--- trunk/apps/Thaw/src/thaw/i18n/source.thaw_fr.properties 2007-08-17
09:00:02 UTC (rev 14738)
+++ trunk/apps/Thaw/src/thaw/i18n/source.thaw_fr.properties 2007-08-17
12:56:35 UTC (rev 14739)
@@ -633,3 +633,6 @@
thaw.plugin.miniFrost.collision=Collision au moment de l'insertion d'un
message sur la board 'X'.\n Nouvel essai sur un nouveau slot.
thaw.plugin.miniFrost.outBox=[en cours d'envoi]
thaw.plugin.miniFrost.sentBox=[envoy?s]
+
+thaw.plugin.miniFrost.attachBoards=Attacher des boards
+thaw.plugin.miniFrost.attachFiles=Attacher des fichiers
Modified: trunk/apps/Thaw/src/thaw/i18n/thaw.properties
===================================================================
--- trunk/apps/Thaw/src/thaw/i18n/thaw.properties 2007-08-17 09:00:02 UTC
(rev 14738)
+++ trunk/apps/Thaw/src/thaw/i18n/thaw.properties 2007-08-17 12:56:35 UTC
(rev 14739)
@@ -650,3 +650,6 @@
thaw.plugin.miniFrost.collision=Collision while inserting a message for the
board 'X'.\n Will try with another slot.
thaw.plugin.miniFrost.outBox=[outbox]
thaw.plugin.miniFrost.sentBox=[sent]
+
+thaw.plugin.miniFrost.attachBoards=Attach board(s)
+thaw.plugin.miniFrost.attachFiles=Attach file(s)
Modified: trunk/apps/Thaw/src/thaw/i18n/thaw_fr.properties
===================================================================
--- trunk/apps/Thaw/src/thaw/i18n/thaw_fr.properties 2007-08-17 09:00:02 UTC
(rev 14738)
+++ trunk/apps/Thaw/src/thaw/i18n/thaw_fr.properties 2007-08-17 12:56:35 UTC
(rev 14739)
@@ -633,3 +633,6 @@
thaw.plugin.miniFrost.collision=Collision au moment de l'insertion d'un
message sur la board 'X'.\n Nouvel essai sur un nouveau slot.
thaw.plugin.miniFrost.outBox=[en cours d'envoi]
thaw.plugin.miniFrost.sentBox=[envoy\u00e9s]
+
+thaw.plugin.miniFrost.attachBoards=Attacher des boards
+thaw.plugin.miniFrost.attachFiles=Attacher des fichiers
Modified: trunk/apps/Thaw/src/thaw/plugins/miniFrost/DraftPanel.java
===================================================================
--- trunk/apps/Thaw/src/thaw/plugins/miniFrost/DraftPanel.java 2007-08-17
09:00:02 UTC (rev 14738)
+++ trunk/apps/Thaw/src/thaw/plugins/miniFrost/DraftPanel.java 2007-08-17
12:56:35 UTC (rev 14739)
@@ -11,6 +11,10 @@
import javax.swing.JScrollPane;
import javax.swing.JButton;
import javax.swing.JDialog;
+import javax.swing.JList;
+import javax.swing.JMenu;
+import javax.swing.JMenuItem;
+import javax.swing.JPopupMenu;
import java.util.Iterator;
import java.util.Vector;
@@ -24,8 +28,9 @@
import thaw.core.I18n;
import thaw.core.Logger;
+import thaw.gui.IconBox;
+
import thaw.plugins.signatures.Identity;
-
import thaw.plugins.miniFrost.interfaces.Draft;
@@ -46,6 +51,9 @@
private JButton extractButton;
+ private JButton addAttachment;
+ private JList attachmentList;
+
private JDialog dialog;
private final SimpleDateFormat gmtConverter;
@@ -80,7 +88,7 @@
textArea.setFont(textArea.getFont().deriveFont((float)13.5));
boardLabel = new JLabel("");
- extractButton = new JButton(thaw.gui.IconBox.minWindowNew);
+ extractButton = new JButton(IconBox.minWindowNew);
extractButton.setToolTipText(I18n.getMessage("thaw.plugin.miniFrost.newWindow"));
extractButton.addActionListener(this);
@@ -115,9 +123,23 @@
southPanel.add(sendButton);
southPanel.add(cancelButton);
- panel.add(northPanel, BorderLayout.NORTH );
- panel.add(new JScrollPane(textArea), BorderLayout.CENTER);
- panel.add(southPanel, BorderLayout.SOUTH );
+
+ JPanel centerPanel = new JPanel(new BorderLayout(3, 3));
+
+ JPanel southCenterPanel = new JPanel(new BorderLayout(3, 3));
+ addAttachment = new JButton(IconBox.attachment);
+ addAttachment.addActionListener(this);
+ attachmentList = new JList();
+
+ southCenterPanel.add(addAttachment, BorderLayout.WEST);
+ southCenterPanel.add(new JScrollPane(attachmentList),
BorderLayout.CENTER);
+
+ centerPanel.add(new JScrollPane(textArea), BorderLayout.CENTER);
+ centerPanel.add(southCenterPanel, BorderLayout.SOUTH);
+
+ panel.add(northPanel, BorderLayout.NORTH );
+ panel.add(centerPanel, BorderLayout.CENTER);
+ panel.add(southPanel, BorderLayout.SOUTH );
}
public DraftPanel(MiniFrostPanel mainPanel, JDialog dialog) {
@@ -156,10 +178,26 @@
textArea.setText(draft.getText());
+ /* attachments */
+ refreshAttachmentList();
+
refresh();
}
+ private void refreshAttachmentList() {
+ Vector v = null;
+
+ if (draft != null)
+ v = draft.getAttachments();
+
+ if (v == null)
+ v = new Vector();
+
+ attachmentList.setListData(v);
+ }
+
+
public void refresh() {
/* we don't want to erase by accident the current draft
* => we do nothing
@@ -219,8 +257,35 @@
}
+ private JMenuItem addBoard = null;
+ private JMenuItem addFile = null;
+
+
public void actionPerformed(ActionEvent e) {
- if (e.getSource() == extractButton) {
+ if (e.getSource() == addAttachment) {
+
+ JPopupMenu menu = new JPopupMenu();
+
+ menu.add((addBoard = new
JMenuItem(I18n.getMessage("thaw.plugin.miniFrost.attachBoards"))));
+ menu.add((addFile = new
JMenuItem(I18n.getMessage("thaw.plugin.miniFrost.attachFiles"))));
+
+ addBoard.addActionListener(this);
+ addFile.addActionListener(this);
+
+ menu.show(addAttachment,
+ addAttachment.getWidth()/2,
+ addAttachment.getHeight()/2);
+ return;
+
+ } else if (e.getSource() == addBoard) {
+
+ refreshAttachmentList();
+
+ } else if (e.getSource() == addFile) {
+
+ refreshAttachmentList();
+
+ } else if (e.getSource() == extractButton) {
fillInDraft();
JDialog newDialog = new
JDialog(mainPanel.getPluginCore().getCore().getMainWindow().getMainFrame(),
Modified: trunk/apps/Thaw/src/thaw/plugins/miniFrost/MessageTreeTable.java
===================================================================
--- trunk/apps/Thaw/src/thaw/plugins/miniFrost/MessageTreeTable.java
2007-08-17 09:00:02 UTC (rev 14738)
+++ trunk/apps/Thaw/src/thaw/plugins/miniFrost/MessageTreeTable.java
2007-08-17 12:56:35 UTC (rev 14739)
@@ -137,8 +137,8 @@
private JComboBox minTrustLevel;
private int minTrustLevelInt;
+ private boolean advancedMode;
-
/** for the thread tree **/
private MessageNodeTree messageNodeTree;
@@ -151,7 +151,9 @@
panel = new JPanel(new BorderLayout(5, 5));
+ advancedMode =
Boolean.valueOf(mainPanel.getConfig().getValue("advancedMode")).booleanValue();
+
/* Actions */
JPanel northPanel = new JPanel(new BorderLayout(20, 20));
@@ -594,6 +596,15 @@
if (value instanceof java.util.Date) {
value =
java.text.DateFormat.getDateTimeInstance().format((java.util.Date)value);
+
+ if (advancedMode) {
+ int rev = msg.getRev();
+
+ if (rev >= 0) {
+ value =
("("+Integer.toString(rev)+") "+
+ ((String)value));
+ }
+ }
}
if (author != null && author.getIdentity() != null)
Modified: trunk/apps/Thaw/src/thaw/plugins/miniFrost/frostKSK/KSKAttachment.java
===================================================================
--- trunk/apps/Thaw/src/thaw/plugins/miniFrost/frostKSK/KSKAttachment.java
2007-08-17 09:00:02 UTC (rev 14738)
+++ trunk/apps/Thaw/src/thaw/plugins/miniFrost/frostKSK/KSKAttachment.java
2007-08-17 12:56:35 UTC (rev 14739)
@@ -42,6 +42,11 @@
public abstract void insert(Hsqldb db, int messageId);
public abstract StringBuffer getSignedStr();
+ /**
+ * if isReady() return false, the draft will wait() on this attachment.
+ * so don't forget to notify it !
+ */
+ public abstract boolean isReady();
/* why ? nobody knows. */
public final static String[] CDATA_EXCEPTIONS = new String[] {
@@ -49,6 +54,15 @@
};
+ private boolean isCDATAException(String name) {
+ for (int j = 0; j < CDATA_EXCEPTIONS.length ; j++)
+ if (CDATA_EXCEPTIONS[j].equals(name))
+ return true;
+
+ return false;
+ }
+
+
public Element getXML(org.w3c.dom.Document doc) {
Element root = doc.createElement("Attachment");
root.setAttribute("type", getType());
@@ -67,12 +81,8 @@
for (int i = 0 ; i < properties.length ; i++) {
Element el = doc.createElement(properties[i]);
- boolean inCdata = true;
+ boolean inCdata = isCDATAException(properties[i]);
- for (int j = 0; j < CDATA_EXCEPTIONS.length ; j++)
- if (CDATA_EXCEPTIONS[j].equals(properties[i]))
- inCdata = false;
-
if (inCdata) {
CDATASection cdata =
doc.createCDATASection(values[i]);
el.appendChild(cdata);
Modified:
trunk/apps/Thaw/src/thaw/plugins/miniFrost/frostKSK/KSKBoardAttachment.java
===================================================================
--- trunk/apps/Thaw/src/thaw/plugins/miniFrost/frostKSK/KSKBoardAttachment.java
2007-08-17 09:00:02 UTC (rev 14738)
+++ trunk/apps/Thaw/src/thaw/plugins/miniFrost/frostKSK/KSKBoardAttachment.java
2007-08-17 12:56:35 UTC (rev 14739)
@@ -9,7 +9,9 @@
import thaw.core.Logger;
import thaw.fcp.FCPQueueManager;
+import thaw.plugins.miniFrost.interfaces.Board;
+
public class KSKBoardAttachment
extends KSKAttachment {
@@ -26,6 +28,17 @@
}
+ public KSKBoardAttachment(Board board) {
+ if (board instanceof KSKBoard) {
+ boardName = ((KSKBoard)board).getName();
+ }
+
+ if (board instanceof SSKBoard) {
+ publicKey = ((SSKBoard)board).getPublicKey();
+ privateKey = ((SSKBoard)board).getPrivateKey();
+ }
+ }
+
public KSKBoardAttachment(String boardName,
String publicKey,
String privateKey,
@@ -319,4 +332,9 @@
return true;
}
+
+
+ public boolean isReady() {
+ return true;
+ }
}
Modified: trunk/apps/Thaw/src/thaw/plugins/miniFrost/frostKSK/KSKDraft.java
===================================================================
--- trunk/apps/Thaw/src/thaw/plugins/miniFrost/frostKSK/KSKDraft.java
2007-08-17 09:00:02 UTC (rev 14738)
+++ trunk/apps/Thaw/src/thaw/plugins/miniFrost/frostKSK/KSKDraft.java
2007-08-17 12:56:35 UTC (rev 14739)
@@ -11,6 +11,7 @@
import thaw.core.Logger;
import thaw.plugins.miniFrost.interfaces.Board;
+import thaw.plugins.miniFrost.interfaces.Attachment;
import thaw.core.I18n;
@@ -26,10 +27,13 @@
private Identity identity;
private Date date;
+ private Vector attachments;
+
public KSKDraft(KSKBoard board, KSKMessage inReplyTo) {
this.board = board;
this.inReplyTo = inReplyTo;
+ attachments = null;
}
public String getSubject() {
@@ -95,27 +99,7 @@
this.date = date;
}
- public boolean addAttachment(java.io.File file) {
- return true;
- }
- public boolean addAttachment(Board board) {
- return true;
- }
-
- public boolean removeAttachment(java.io.File file) {
- return true;
- }
-
- public boolean removeAttachment(Board board) {
- return true;
- }
-
- public Vector getAttachments() {
- return null;
- }
-
-
private java.io.File fileToInsert;
private FCPQueueManager queueManager;
private int revUsed;
@@ -135,9 +119,14 @@
return posting;
}
+
+ private static boolean initialInsertion = false;
+
public void post(FCPQueueManager queueManager) {
this.queueManager = queueManager;
+ initialInsertion = false;
+
waiting = true;
posting = false;
notifyPlugin();
@@ -159,7 +148,7 @@
((identity != null) ?
identity.getPublicKey() :
null),
- null,
+
attachments,
identity);
fileToInsert = generator.generateXML();
@@ -199,9 +188,11 @@
private boolean isBoardUpToDateForToday() {
if (!board.isRefreshing()
- || board.getCurrentlyRefreshedDate() == null
- ||
(KSKBoard.getMidnight(board.getCurrentlyRefreshedDate()).getTime()
- < KSKBoard.getMidnight(date).getTime()) ) {
+ || (board.getCurrentlyRefreshedDate() != null
+ &&
(KSKBoard.getMidnight(board.getCurrentlyRefreshedDate()).getTime()
+ < KSKBoard.getMidnight(date).getTime()) )) {
+ Logger.info(this, "Board:
"+Long.toString(KSKBoard.getMidnight(board.getCurrentlyRefreshedDate()).getTime()));
+ Logger.info(this, "Draft:
"+KSKBoard.getMidnight(date).getTime());
return true;
}
return false;
@@ -211,13 +202,17 @@
public void update(Observable o, Object param) {
if (o instanceof Board) {
synchronized(board) {
+ /* just to be sure we don't insert the message
many times */
+ if (initialInsertion)
+ return;
+ initialInsertion = true;
+
if (fileToInsert == null ||
!isBoardUpToDateForToday())
return;
board.deleteObserver(this);
revUsed = board.getNextNonDownloadedRev(date,
-1);
+ startInsertion();
}
-
- startInsertion();
}
if (o instanceof FCPClientPut) {
@@ -282,4 +277,38 @@
public Board getBoard() {
return board;
}
+
+ public Vector getAttachments() {
+ return attachments;
+ }
+
+ public boolean addAttachment(java.io.File file) {
+ return addAttachment(new
KSKFileAttachment(board.getFactory().getCore().getQueueManager(),
+ file));
+ }
+
+ public boolean addAttachment(Board board) {
+ return addAttachment(new KSKBoardAttachment(board));
+ }
+
+ public boolean addAttachment(thaw.plugins.index.Index index) {
+ return false;
+ }
+
+ protected boolean addAttachment(KSKAttachment attachment) {
+ if (attachments == null)
+ attachments = new Vector();
+ attachments.add(attachment);
+
+ return true;
+ }
+
+ public boolean removeAttachment(Attachment attachment) {
+ if (attachments == null)
+ return false;
+
+ attachments.remove(attachment);
+
+ return false;
+ }
}
Modified:
trunk/apps/Thaw/src/thaw/plugins/miniFrost/frostKSK/KSKFileAttachment.java
===================================================================
--- trunk/apps/Thaw/src/thaw/plugins/miniFrost/frostKSK/KSKFileAttachment.java
2007-08-17 09:00:02 UTC (rev 14738)
+++ trunk/apps/Thaw/src/thaw/plugins/miniFrost/frostKSK/KSKFileAttachment.java
2007-08-17 12:56:35 UTC (rev 14739)
@@ -27,6 +27,13 @@
}
+ public KSKFileAttachment(FCPQueueManager queueManager, java.io.File
file) {
+ this.filename = file.getName();
+ this.size = file.length();
+ this.key = null;
+ computeKey(queueManager, file);
+ }
+
public KSKFileAttachment(String filename,
long size,
String key) {
@@ -46,6 +53,16 @@
}
+ public void computeKey(FCPQueueManager queueManager, java.io.File file)
{
+ /* TODO */
+ }
+
+ public boolean isReady() {
+ /* TODO */
+ return true;
+ }
+
+
public String getType() {
return "file";
}
@@ -111,7 +128,16 @@
}
public String toString() {
- return filename;
+ String name = null;
+
+ if (key != null)
+ name = FreenetURIHelper.getFilenameFromKey(key);
+ if (name == null)
+ name = filename;
+ if (name == null)
+ name = "null";
+
+ return name + "
("+thaw.gui.GUIHelper.getPrintableSize(size)+")";
}
public String getContainer() {
Modified:
trunk/apps/Thaw/src/thaw/plugins/miniFrost/frostKSK/KSKMessageParser.java
===================================================================
--- trunk/apps/Thaw/src/thaw/plugins/miniFrost/frostKSK/KSKMessageParser.java
2007-08-17 09:00:02 UTC (rev 14738)
+++ trunk/apps/Thaw/src/thaw/plugins/miniFrost/frostKSK/KSKMessageParser.java
2007-08-17 12:56:35 UTC (rev 14739)
@@ -115,11 +115,6 @@
private boolean alreadyInTheDb(Hsqldb db, String msgId) {
- if (msgId == null) {
- Logger.notice(this, "no message id => ignoring this
message by supposing it "
- +"already in the db");
- return true;
- }
try {
synchronized(db.dbLock) {
@@ -158,6 +153,11 @@
return false;
}
+ if (messageId == null) {
+ Logger.notice(this, "No message id, can't store.");
+ return false;
+ }
+
if (alreadyInTheDb(db, messageId)) {
Logger.notice(this, "We have already this id in the db
?!");
archived = true;
Modified: trunk/apps/Thaw/src/thaw/plugins/miniFrost/frostKSK/SSKBoard.java
===================================================================
--- trunk/apps/Thaw/src/thaw/plugins/miniFrost/frostKSK/SSKBoard.java
2007-08-17 09:00:02 UTC (rev 14738)
+++ trunk/apps/Thaw/src/thaw/plugins/miniFrost/frostKSK/SSKBoard.java
2007-08-17 12:56:35 UTC (rev 14739)
@@ -58,6 +58,10 @@
return privateKey;
}
+ protected String getPublicKey() {
+ return publicKey;
+ }
+
/**
* called by KSKDraft
*/
Modified: trunk/apps/Thaw/src/thaw/plugins/miniFrost/interfaces/Draft.java
===================================================================
--- trunk/apps/Thaw/src/thaw/plugins/miniFrost/interfaces/Draft.java
2007-08-17 09:00:02 UTC (rev 14738)
+++ trunk/apps/Thaw/src/thaw/plugins/miniFrost/interfaces/Draft.java
2007-08-17 12:56:35 UTC (rev 14739)
@@ -43,9 +43,14 @@
public boolean addAttachment(java.io.File file);
public boolean addAttachment(Board board);
- public boolean removeAttachment(java.io.File file);
- public boolean removeAttachment(Board board);
+ public boolean addAttachment(thaw.plugins.index.Index index);
+ public boolean removeAttachment(Attachment attachment);
+
+
+ /**
+ * @return can return null if none
+ */
public Vector getAttachments();
/**
Modified: trunk/apps/Thaw/src/thaw/plugins/miniFrost/interfaces/Message.java
===================================================================
--- trunk/apps/Thaw/src/thaw/plugins/miniFrost/interfaces/Message.java
2007-08-17 09:00:02 UTC (rev 14738)
+++ trunk/apps/Thaw/src/thaw/plugins/miniFrost/interfaces/Message.java
2007-08-17 12:56:35 UTC (rev 14739)
@@ -17,6 +17,9 @@
public Author getSender();
public java.util.Date getDate();
+ /**
+ * @return < 0 if must not be displayed
+ */
public int getRev();
public boolean isArchived();