Author: dieppe
Date: 2008-02-17 18:35:20 +0000 (Sun, 17 Feb 2008)
New Revision: 18023
Added:
trunk/apps/thingamablog/src/net/sf/thingamablog/util/freenet/fcp/fcpManager.java
Modified:
trunk/apps/thingamablog/src/net/sf/thingamablog/TBGlobals.java
trunk/apps/thingamablog/src/net/sf/thingamablog/blog/TBWeblog.java
trunk/apps/thingamablog/src/net/sf/thingamablog/gui/app/TaskDialog.java
trunk/apps/thingamablog/src/net/sf/thingamablog/gui/properties/TBWizardDialog.java
trunk/apps/thingamablog/src/net/sf/thingamablog/xml/TBPersistFactory.java
Log:
Generate a pair of key automatically (doesn't insert yet);
Avoid a npe when deleting the last blog;
Modified: trunk/apps/thingamablog/src/net/sf/thingamablog/TBGlobals.java
===================================================================
--- trunk/apps/thingamablog/src/net/sf/thingamablog/TBGlobals.java
2008-02-17 03:42:35 UTC (rev 18022)
+++ trunk/apps/thingamablog/src/net/sf/thingamablog/TBGlobals.java
2008-02-17 18:35:20 UTC (rev 18023)
@@ -114,7 +114,7 @@
private static String socksPass = "";
//node properties
- private static String nodePort = "9184";
+ private static String nodePort = "9481";
private static String nodeHostname = "localhost";
//auto feed updater stuff
Modified: trunk/apps/thingamablog/src/net/sf/thingamablog/blog/TBWeblog.java
===================================================================
--- trunk/apps/thingamablog/src/net/sf/thingamablog/blog/TBWeblog.java
2008-02-17 03:42:35 UTC (rev 18022)
+++ trunk/apps/thingamablog/src/net/sf/thingamablog/blog/TBWeblog.java
2008-02-17 18:35:20 UTC (rev 18023)
@@ -93,6 +93,8 @@
private String type;
// If type == freenet, then insertURI is set to the insertURI of the
flog, else, set to null
private String insertURI;
+ // Number of the current edition (flog only)
+ private String edition="0";
//private Vector outdatedTopLevelPages = new Vector();
private Vector outdatedCategoryPages = new Vector();
@@ -1414,4 +1416,12 @@
public String getInsertUri() {
return this.insertURI;
}
+
+ public void setEdition(String edition){
+ this.edition=edition;
+ }
+
+ public String getEdition(){
+ return this.edition;
+ }
}
Modified:
trunk/apps/thingamablog/src/net/sf/thingamablog/gui/app/TaskDialog.java
===================================================================
--- trunk/apps/thingamablog/src/net/sf/thingamablog/gui/app/TaskDialog.java
2008-02-17 03:42:35 UTC (rev 18022)
+++ trunk/apps/thingamablog/src/net/sf/thingamablog/gui/app/TaskDialog.java
2008-02-17 18:35:20 UTC (rev 18023)
@@ -221,8 +221,8 @@
* @see
java.awt.event.ItemListener#itemStateChanged(java.awt.event.ItemEvent)
*/
public void itemStateChanged(ItemEvent e)
- {
- if(blogCombo.getItemCount() > 0)
+ {
+ if(blogCombo.getItemCount() > 1)
{
Weblog b = (Weblog)blogCombo.getSelectedItem();
cardLayout.show(cardPanel, b.getKey());
Modified:
trunk/apps/thingamablog/src/net/sf/thingamablog/gui/properties/TBWizardDialog.java
===================================================================
---
trunk/apps/thingamablog/src/net/sf/thingamablog/gui/properties/TBWizardDialog.java
2008-02-17 03:42:35 UTC (rev 18022)
+++
trunk/apps/thingamablog/src/net/sf/thingamablog/gui/properties/TBWizardDialog.java
2008-02-17 18:35:20 UTC (rev 18023)
@@ -47,11 +47,11 @@
import net.sf.thingamablog.gui.MultilineText;
import net.sf.thingamablog.gui.app.TemplateSelectionPanel;
import net.sf.thingamablog.gui.app.WeblogPreviewer;
+import net.sf.thingamablog.util.freenet.fcp.fcpManager;
-
/**
* @author Bob Tantlinger
*
@@ -118,7 +118,7 @@
wizPanel = new JPanel(wizLayout);
starterPanel = new StarterPanel();
- starterPanel.setBorder(new EmptyBorder(10, 10, 10, 10));
+ starterPanel.setBorder(new EmptyBorder(15, 10, 15, 10));
panels.add(starterPanel);
titlePanel = new TitleDescrPanel();
@@ -348,6 +348,7 @@
private JComboBox typeCombo = new JComboBox(TYPE);
private JButton generateKeyButton = new
JButton(i18n.str("generate_key"));
private JTextField insertUriField = new JTextField();
+ private fcpManager Manager = new fcpManager();
public StarterPanel()
{
@@ -435,7 +436,13 @@
weblog.setBlogUrls(path, url, arcUrl, mediaUrl);
weblog.setType(typeCombo.getSelectedItem().toString());
- weblog.setInsertURI(insertUriField.getText());
+ if(weblog.getType().equals("freenet")){
+ weblog.setInsertURI(insertUriField.getText());
+ weblog.setEdition("1");
+ } else {
+ weblog.setInsertURI("noflog");
+ weblog.setEdition("noflog");
+ }
}
private class TypeListener implements ActionListener {
@@ -450,7 +457,19 @@
} else if (e.getSource() instanceof JButton){
if(generateKeyButton.getText().equals(i18n.str("generate_key"))){
int port =
Integer.parseInt(TBGlobals.getProperty("NODE_PORT"));
- String hostname =
TBGlobals.getProperty("NODE_HOSTNAME");
+ String keys[]=new String[2];
+ String hostname =
TBGlobals.getProperty("NODE_HOSTNAME");
+ Manager.setNode(hostname,port);
+ try {
+ keys=Manager.generateKeyPair();
+ } catch (IOException ex) {
+
JOptionPane.showMessageDialog(TBWizardDialog.this,
+ hostname + " : " + port + " : " + ex,
i18n.str("key_generation_failure"), //$NON-NLS-1$ //$NON-NLS-2$
+ JOptionPane.ERROR_MESSAGE);
+ return;
+ }
+ insertUriField.setText(keys[0]);
+ urlField.setText(keys[1]);
generateKeyButton.setText(i18n.str("cancel"));
} else {
urlField.setText("");
Added:
trunk/apps/thingamablog/src/net/sf/thingamablog/util/freenet/fcp/fcpManager.java
===================================================================
---
trunk/apps/thingamablog/src/net/sf/thingamablog/util/freenet/fcp/fcpManager.java
(rev 0)
+++
trunk/apps/thingamablog/src/net/sf/thingamablog/util/freenet/fcp/fcpManager.java
2008-02-17 18:35:20 UTC (rev 18023)
@@ -0,0 +1,63 @@
+/*
+ * fcpManager.java
+ *
+ * Created on 17 f?vrier 2008, 12:41
+ *
+ * To change this template, choose Tools | Template Manager
+ * and open the template in the editor.
+ */
+
+package net.sf.thingamablog.util.freenet.fcp;
+
+import java.io.IOException;
+
+/**
+ * Copy of jSite's Freenet7Interface
+ * @author dieppe
+ */
+public class fcpManager {
+
+ private Node node;
+ private Connection connection;
+ int counter;
+
+ public void setNode(String hostname, int port){
+ this.node=new Node(hostname,port);
+ this.connection=new Connection(node,"Thingamablog :" + counter++);
+ }
+
+ public void setNode(String hostname){
+ this.node=new Node(hostname);
+ this.connection=new Connection(node,"Thingamablog :" + counter++);
+ }
+
+ public Connection getConnection(){
+ return this.connection;
+ }
+
+ public boolean isNodePresent() throws IOException {
+ if (!connection.isConnected()) {
+ return connection.connect();
+ }
+ return true;
+ }
+
+ public String[] generateKeyPair() throws IOException {
+ if (!isNodePresent()) {
+ return null;
+ }
+ GenerateSSK generateSSK = new GenerateSSK();
+ Client client = new Client(connection, generateSSK);
+ Message keypairMessage = client.readMessage();
+ return new String[] { keypairMessage.get("InsertURI"),
keypairMessage.get("RequestURI") };
+ }
+
+ public Node getNode() {
+ return node;
+ }
+
+ public boolean hasNode() {
+ return (node != null) && (connection != null);
+ }
+
+}
Modified:
trunk/apps/thingamablog/src/net/sf/thingamablog/xml/TBPersistFactory.java
===================================================================
--- trunk/apps/thingamablog/src/net/sf/thingamablog/xml/TBPersistFactory.java
2008-02-17 03:42:35 UTC (rev 18022)
+++ trunk/apps/thingamablog/src/net/sf/thingamablog/xml/TBPersistFactory.java
2008-02-17 18:35:20 UTC (rev 18023)
@@ -353,6 +353,7 @@
element.setAttribute("locale", blog.getLocale().toString());
element.setAttribute("publish_all", blog.isPublishAll() + "");
element.setAttribute("type", blog.getType());
+ element.setAttribute("edition", blog.getEdition());
Element outdatedArcs = new Element("OutdatedArchives");
ArchiveRange ar[] = blog.getOutdatedArchives();
@@ -592,6 +593,7 @@
tb.setPublishAll(element.getAttributeValue("publish_all",
"true").equals("true"));
tb.setType(element.getAttributeValue("type").toString());
tb.setInsertURI(element.getAttributeValue("insertURI"));
+ tb.setEdition(element.getAttributeValue("edition"));
int arcPolicy = TBWeblog.ARCHIVE_MONTHLY;
int dayInterval = 5;