diff --git a/LifeBlogger.iws b/LifeBlogger.iws
index f5d9ce2..4756a4e 100644
--- a/LifeBlogger.iws
+++ b/LifeBlogger.iws
@@ -71,7 +71,7 @@
-
+
@@ -112,10 +112,10 @@
-
+
-
+
@@ -131,7 +131,7 @@
-
+
@@ -149,14 +149,14 @@
-
+
-
+
@@ -165,21 +165,21 @@
-
+
-
+
-
+
@@ -188,7 +188,7 @@
-
+
@@ -209,14 +209,14 @@
-
+
-
+
@@ -243,20 +243,6 @@
-
-
-
-
-
-
-
-
-
-
-
-
@@ -271,12 +257,19 @@
-
-
-
-
-
+
+
+
+
+
+
+
+
+
+
@@ -285,6 +278,13 @@
+
+
+
+
+
+
+
@@ -301,14 +301,14 @@
-
-
+
+
@@ -364,7 +364,7 @@
-
+
@@ -514,13 +514,6 @@
-
-
-
-
-
-
-
@@ -532,7 +525,7 @@
-
+
@@ -548,30 +541,46 @@
-
+
-
-
+
+
+
+
-
+
-
+
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
-
+
@@ -580,20 +589,11 @@
-
+
-
-
-
-
-
-
-
-
-
diff --git a/src/net/thauvin/lifeblogger/LifeBlogger.java b/src/net/thauvin/lifeblogger/LifeBlogger.java
index 639f225..cb962ca 100644
--- a/src/net/thauvin/lifeblogger/LifeBlogger.java
+++ b/src/net/thauvin/lifeblogger/LifeBlogger.java
@@ -72,7 +72,7 @@ public class LifeBlogger extends Thinlet
System.getProperty("user.home") + File.separator + ReleaseInfo.getProject() + ".properties";
private static final String JDBC_PREFIX = "jdbc:sqlite:/";
private static final String DATABASE = "\\DataBase\\NokiaLifeblogDataBase.db";
- private static final String DEFAULT_ACTION = "ftp";
+ private static final String DEFAULT_ACTION = "mw";
private final Properties _prefs = new Properties();
private File _homeDir = new File(System.getProperty("user.home") + "\\My Documents\\NokiaLifeblogData");
private String _action;
@@ -482,47 +482,7 @@ public class LifeBlogger extends Thinlet
public final void post(Object dialog, Object blogPanel)
throws IOException
{
- final String host = getString(find(blogPanel, "host"), "text");
- final String blogID = getString(find(blogPanel, "blogid"), "text");
- final String login = getString(find(blogPanel, "login"), "text");
- final String password = getString(find(blogPanel, "password"), "text");
- final String entry = getString(find(blogPanel, "entry"), "text");
-
- if (host.length() <= 0)
- {
- alert("Please specify a XML-RPC URL.");
- }
- else if (login.length() <= 0)
- {
- alert("Please specify a login name.");
- }
- else if (password.length() <= 0)
- {
- alert("Please specify a password.");
- }
- else if (entry.length() <= 0)
- {
- alert("Please specify a post entry.");
- }
- else if (blogID.length() <= 0)
- {
- alert("Please specify a blog ID.");
- }
- else
- {
- _prefs.put("blog-host", host);
- _prefs.put("blog-login", login);
- _prefs.put("blog-password", Base64.encodeBytes(password.getBytes(), Base64.DONT_BREAK_LINES));
- _prefs.put("blog-id", blogID);
-
- savePrefs();
-
- closeDialog(dialog);
-
- final LifePost post =
- new LifePost(this, host, blogID, login, password, getString(find(blogPanel, "entry"), "text"));
- post.start();
- }
+ post(dialog, blogPanel, false);
}
/**
@@ -621,6 +581,20 @@ public class LifeBlogger extends Thinlet
}
}
+ /**
+ * Preforms the publish to blog action.
+ *
+ * @param dialog The post dialog,
+ * @param blogPanel The panel contaning the post data.
+ *
+ * @throws IOException If an error occurs while performing the action.
+ */
+ public final void publish(Object dialog, Object blogPanel)
+ throws IOException
+ {
+ post(dialog, blogPanel, true);
+ }
+
/**
* Toggles the given button based on the specified table selection.
*
@@ -684,6 +658,61 @@ public class LifeBlogger extends Thinlet
}
}
+ /**
+ * Preforms the post/publish to blog action.
+ *
+ * @param dialog The post dialog,
+ * @param blogPanel The panel contaning the post data.
+ * @param publish Set to true
to publish the post, false
otherwise.
+ *
+ * @throws IOException If an error occurs while performing the action.
+ */
+ private void post(Object dialog, Object blogPanel, boolean publish)
+ throws IOException
+ {
+ final String host = getString(find(blogPanel, "host"), "text");
+ final String blogID = getString(find(blogPanel, "blogid"), "text");
+ final String login = getString(find(blogPanel, "login"), "text");
+ final String password = getString(find(blogPanel, "password"), "text");
+ final String entry = getString(find(blogPanel, "entry"), "text");
+
+ if (host.length() <= 0)
+ {
+ alert("Please specify a XML-RPC URL.");
+ }
+ else if (login.length() <= 0)
+ {
+ alert("Please specify a login name.");
+ }
+ else if (password.length() <= 0)
+ {
+ alert("Please specify a password.");
+ }
+ else if (entry.length() <= 0)
+ {
+ alert("Please specify a post entry.");
+ }
+ else if (blogID.length() <= 0)
+ {
+ alert("Please specify a blog ID.");
+ }
+ else
+ {
+ _prefs.put("blog-host", host);
+ _prefs.put("blog-login", login);
+ _prefs.put("blog-password", Base64.encodeBytes(password.getBytes(), Base64.DONT_BREAK_LINES));
+ _prefs.put("blog-id", blogID);
+
+ savePrefs();
+
+ closeDialog(dialog);
+
+ final LifePost post =
+ new LifePost(this, host, blogID, login, password, getString(find(blogPanel, "entry"), "text"), publish);
+ post.start();
+ }
+ }
+
// Displays an alert.
private void alert(String message)
{
@@ -778,7 +807,7 @@ public class LifeBlogger extends Thinlet
putProperty(find(mw, "file"), "mtype", mimeType);
setString(find(mw, "filename"), "text", file.substring(file.lastIndexOf('\\') + 1));
setString(find(mw, "host"), "text", _prefs.getProperty("mw-host", ""));
- setString(find(mw, "login"), "text", _prefs.getProperty("mw-login", "anonymous"));
+ setString(find(mw, "login"), "text", _prefs.getProperty("mw-login", ""));
setString(find(mw, "password"), "text", new String(Base64.decode(_prefs.getProperty("mw-password", ""))));
setString(find(mw, "blogid"), "text", _prefs.getProperty("mw-id", ""));
add(mw);
diff --git a/src/net/thauvin/lifeblogger/LifePost.java b/src/net/thauvin/lifeblogger/LifePost.java
index 80d3372..28d67d2 100644
--- a/src/net/thauvin/lifeblogger/LifePost.java
+++ b/src/net/thauvin/lifeblogger/LifePost.java
@@ -56,6 +56,7 @@ public class LifePost extends LifeAction
{
private final String _blogEntry;
private final String _blogID;
+ private final boolean _publish;
/**
* Creates a new LifePost object.
@@ -66,16 +67,19 @@ public class LifePost extends LifeAction
* @param login The MetaWeblog login username.
* @param password The MetaWeblog login password.
* @param blogEntry The blog entry.
+ * @param publish DOCUMENT ME!
*
* @throws IOException If an error occurs while creating the object.
*/
- public LifePost(LifeBlogger thinlet, String url, String blogID, String login, String password, String blogEntry)
+ public LifePost(LifeBlogger thinlet, String url, String blogID, String login, String password, String blogEntry,
+ boolean publish)
throws IOException
{
super(thinlet, url, login, password);
_blogEntry = blogEntry;
_blogID = blogID;
+ _publish = publish;
}
/**
@@ -104,7 +108,9 @@ public class LifePost extends LifeAction
.append(getPassword())
.append("")
.append(textToXML(_blogEntry))
- .append("false");
+ .append("")
+ .append(String.valueOf(_publish))
+ .append("");
final URLConnection urlConn = url.openConnection();
urlConn.setDoInput(true);
urlConn.setDoOutput(true);
@@ -118,7 +124,6 @@ public class LifePost extends LifeAction
dos.close();
//System.out.println(request);
-
final LifeRPCResponse xmlrpc = new LifeRPCResponse(urlConn.getInputStream());
if (xmlrpc.isValidResponse())
@@ -166,7 +171,7 @@ public class LifePost extends LifeAction
}
// High/Low-ASCII character
- else if (ch >= 128 || ch < 32)
+ else if ((ch >= 128) || (ch < 32))
{
c = (int) ch;
@@ -195,11 +200,11 @@ public class LifePost extends LifeAction
// Loop thru each characters of the text
for (int i = 0; i < text.length(); i++)
{
- // Convert character to HTML/XML
+ // Convert character to XML
html.append(charToXML(text.charAt(i)));
}
- // Return HTML/XML string
+ // Return XML string
return html.toString();
}
}
diff --git a/src/net/thauvin/lifeblogger/post.xml b/src/net/thauvin/lifeblogger/post.xml
index 2b71bcb..42c3da8 100644
--- a/src/net/thauvin/lifeblogger/post.xml
+++ b/src/net/thauvin/lifeblogger/post.xml
@@ -10,6 +10,7 @@
-
+
+
\ No newline at end of file