Changed default from FTP to MetaWeblog.

Changed post action to publish.
This commit is contained in:
Erik C. Thauvin 2004-07-25 06:59:26 +00:00
parent 45cf46a227
commit 1a8a73a643
4 changed files with 144 additions and 109 deletions

View file

@ -71,7 +71,7 @@
<option name="PUT_FOCUS_INTO_COMMENT" value="true" />
<option name="SHOW_CHECKIN_OPTIONS" value="true" />
<option name="FORCE_NON_EMPTY_COMMENT" value="false" />
<option name="LAST_COMMIT_MESSAGE" value="Worked around Radio's lame XML encoding support." />
<option name="LAST_COMMIT_MESSAGE" value="Left a System.out.println(), oops." />
<option name="SAVE_LAST_COMMIT_MESSAGE" value="true" />
<option name="CHECKIN_DIALOG_SPLITTER_PROPORTION" value="0.8" />
<option name="OPTIMIZE_IMPORTS_BEFORE_PROJECT_COMMIT" value="false" />
@ -112,10 +112,10 @@
<option name="HIDE_WARNINGS" value="false" />
</component>
<component name="FileEditorManager" split-orientation="vertical" split-proportion="0.5">
<first-group selected-file="file://$PROJECT_DIR$/src/net/thauvin/lifeblogger/LifePost.java">
<first-group selected-file="file://$PROJECT_DIR$/src/net/thauvin/lifeblogger/LifeBlogger.java">
<entry file="file://$PROJECT_DIR$/src/net/thauvin/lifeblogger/post.xml" pinned="false">
<provider selected="true" editor-type-id="text-editor">
<state line="7" column="75" selection-start="534" selection-end="534" vertical-scroll-proportion="0.21834862">
<state line="13" column="78" selection-start="927" selection-end="927" vertical-scroll-proportion="0.40550458">
<folding />
</state>
</provider>
@ -131,7 +131,7 @@
</entry>
<entry file="file://$PROJECT_DIR$/src/net/thauvin/lifeblogger/LifeAction.java" pinned="false">
<provider selected="true" editor-type-id="text-editor">
<state line="50" column="11" selection-start="840" selection-end="840" vertical-scroll-proportion="1.0623853">
<state line="50" column="11" selection-start="840" selection-end="840" vertical-scroll-proportion="1.0220183">
<folding>
<element signature="imports" expanded="true" />
</folding>
@ -149,14 +149,14 @@
</entry>
<entry file="file://$PROJECT_DIR$/src/net/thauvin/lifeblogger/LifePost.java" pinned="false">
<provider selected="true" editor-type-id="text-editor">
<state line="119" column="14" selection-start="4738" selection-end="4738" vertical-scroll-proportion="0.5614679">
<state line="117" column="21" selection-start="4735" selection-end="4735" vertical-scroll-proportion="0.08256881">
<folding />
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/src/net/thauvin/lifeblogger/LifeRPCResponse.java" pinned="false">
<provider selected="true" editor-type-id="text-editor">
<state line="50" column="13" selection-start="1963" selection-end="1963" vertical-scroll-proportion="-2.3651376">
<state line="50" column="13" selection-start="1963" selection-end="1963" vertical-scroll-proportion="0.03119266">
<folding>
<element signature="imports" expanded="true" />
</folding>
@ -165,21 +165,21 @@
</entry>
<entry file="file://$PROJECT_DIR$/src/net/thauvin/lifeblogger/LifeFTP.java" pinned="false">
<provider selected="true" editor-type-id="text-editor">
<state line="132" column="71" selection-start="3917" selection-end="3917" vertical-scroll-proportion="1.0201834">
<state line="132" column="71" selection-start="3917" selection-end="3917" vertical-scroll-proportion="0.9798165">
<folding />
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/src/net/thauvin/lifeblogger/main.xml" pinned="false">
<provider selected="true" editor-type-id="text-editor">
<state line="8" column="60" selection-start="410" selection-end="410" vertical-scroll-proportion="0.24954128">
<state line="18" column="36" selection-start="882" selection-end="882" vertical-scroll-proportion="0.5614679">
<folding />
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/src/net/thauvin/lifeblogger/LifeBlogger.java" pinned="false">
<provider selected="true" editor-type-id="text-editor">
<state line="544" column="28" selection-start="13717" selection-end="13717" vertical-scroll-proportion="-6.187156">
<state line="669" column="11" selection-start="16595" selection-end="16595" vertical-scroll-proportion="0.055045873">
<folding>
<element signature="imports" expanded="true" />
</folding>
@ -188,7 +188,7 @@
</entry>
<entry file="file://$PROJECT_DIR$/src/net/thauvin/lifeblogger/ReleaseInfo.java" pinned="false">
<provider selected="true" editor-type-id="text-editor">
<state line="15" column="23" selection-start="413" selection-end="413" vertical-scroll-proportion="0.29174313">
<state line="15" column="23" selection-start="413" selection-end="413" vertical-scroll-proportion="0.30535713">
<folding />
</state>
</provider>
@ -209,14 +209,14 @@
<component name="J2EEProjectPane" />
<component name="NamedScopeManager" />
<component name="PackagesPane">
<expanded_node url="net.thauvin.lifeblogger" module="LifeBlogger" type="package" />
<expanded_node url="net" module="LifeBlogger" type="package" />
<expanded_node url="net.thauvin" module="LifeBlogger" type="package" />
<expanded_node url="" module="LifeBlogger" type="module" />
<expanded_node url="net.thauvin.lifeblogger" module="LifeBlogger" type="package" />
</component>
<component name="ProjectPane">
<expanded_node url="file://$PROJECT_DIR$" module="LifeBlogger" type="directory" />
<expanded_node url="" module="LifeBlogger" type="module" />
<expanded_node url="file://$PROJECT_DIR$" module="LifeBlogger" type="directory" />
</component>
<component name="ProjectView">
<navigator currentView="ProjectPane" splitterProportion="0.5">
@ -243,20 +243,6 @@
</component>
<component name="RunManager">
<activeType name="Application" />
<configuration selected="false" default="true" type="JUnit" factoryName="JUnit">
<module name="" />
<option name="PACKAGE_NAME" />
<option name="MAIN_CLASS_NAME" />
<option name="METHOD_NAME" />
<option name="TEST_OBJECT" />
<option name="VM_PARAMETERS" />
<option name="PARAMETERS" />
<option name="WORKING_DIRECTORY" value="$PROJECT_DIR$" />
<option name="ADDITIONAL_CLASS_PATH" />
<option name="TEST_SEARCH_SCOPE">
<value defaultName="wholeProject" />
</option>
</configuration>
<configuration selected="false" default="true" type="WebLogic Instance" factoryName="Local">
<option name="WORKING_DIRECTORY" />
<option name="HOST" value="localhost" />
@ -271,12 +257,19 @@
<option name="SERVER_NAME" value="myserver" />
<option name="DOMAIN_NAME" value="mydomain" />
</configuration>
<configuration selected="false" default="true" type="Application" factoryName="Application">
<option name="MAIN_CLASS_NAME" />
<option name="VM_PARAMETERS" />
<option name="PROGRAM_PARAMETERS" />
<option name="WORKING_DIRECTORY" value="$PROJECT_DIR$" />
<configuration selected="false" default="true" type="JUnit" factoryName="JUnit">
<module name="" />
<option name="PACKAGE_NAME" />
<option name="MAIN_CLASS_NAME" />
<option name="METHOD_NAME" />
<option name="TEST_OBJECT" />
<option name="VM_PARAMETERS" />
<option name="PARAMETERS" />
<option name="WORKING_DIRECTORY" value="$PROJECT_DIR$" />
<option name="ADDITIONAL_CLASS_PATH" />
<option name="TEST_SEARCH_SCOPE">
<value defaultName="wholeProject" />
</option>
</configuration>
<configuration selected="false" default="true" type="Remote" factoryName="Remote">
<option name="USE_SOCKET_TRANSPORT" value="true" />
@ -285,6 +278,13 @@
<option name="HOST" value="localhost" />
<option name="PORT" value="5005" />
</configuration>
<configuration selected="false" default="true" type="Application" factoryName="Application">
<option name="MAIN_CLASS_NAME" />
<option name="VM_PARAMETERS" />
<option name="PROGRAM_PARAMETERS" />
<option name="WORKING_DIRECTORY" value="$PROJECT_DIR$" />
<module name="" />
</configuration>
<configuration selected="false" default="true" type="Applet" factoryName="Applet">
<module name="" />
<option name="MAIN_CLASS_NAME" />
@ -301,14 +301,14 @@
<option name="PROGRAM_PARAMETERS" value="" />
<option name="WORKING_DIRECTORY" value="file://$PROJECT_DIR$" />
<module name="LifeBlogger" />
<RunnerSettings RunnerId="Run" />
<RunnerSettings RunnerId="Debug">
<option name="DEBUG_PORT" value="1127" />
<option name="TRANSPORT" value="0" />
<option name="LOCAL" value="false" />
</RunnerSettings>
<ConfigurationWrapper RunnerId="Run" />
<RunnerSettings RunnerId="Run" />
<ConfigurationWrapper RunnerId="Debug" />
<ConfigurationWrapper RunnerId="Run" />
</configuration>
</component>
<component name="SelectInManager" />
@ -364,7 +364,7 @@
<window_info id="CVS" active="false" anchor="bottom" auto_hide="false" internal_type="docked" type="docked" visible="false" weight="0.33024693" order="8" />
<window_info id="Regex" active="false" anchor="bottom" auto_hide="false" internal_type="docked" type="docked" visible="false" weight="0.33024693" order="9" />
<window_info id="TODO" active="false" anchor="bottom" auto_hide="false" internal_type="docked" type="docked" visible="false" weight="0.33" order="7" />
<window_info id="Project" active="true" anchor="left" auto_hide="false" internal_type="docked" type="docked" visible="true" weight="0.23265307" order="0" />
<window_info id="Project" active="true" anchor="left" auto_hide="false" internal_type="docked" type="docked" visible="true" weight="0.19489796" order="0" />
<window_info id="Find" active="false" anchor="bottom" auto_hide="false" internal_type="docked" type="docked" visible="false" weight="0.33024693" order="1" />
<window_info id="Structure" active="false" anchor="left" auto_hide="false" internal_type="docked" type="docked" visible="false" weight="0.25" order="1" />
<window_info id="Messages" active="false" anchor="bottom" auto_hide="false" internal_type="docked" type="docked" visible="false" weight="0.33024693" order="10" />
@ -514,13 +514,6 @@
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/src/net/thauvin/lifeblogger/post.xml">
<provider selected="true" editor-type-id="text-editor">
<state line="7" column="75" selection-start="534" selection-end="534" vertical-scroll-proportion="0.21834862">
<folding />
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/src/net/thauvin/lifeblogger/LifeBlog.java">
<provider selected="true" editor-type-id="text-editor">
<state line="52" column="22" selection-start="2083" selection-end="2083" vertical-scroll-proportion="0.5302752">
@ -532,7 +525,7 @@
</entry>
<entry file="file://$PROJECT_DIR$/src/net/thauvin/lifeblogger/LifeAction.java">
<provider selected="true" editor-type-id="text-editor">
<state line="50" column="11" selection-start="840" selection-end="840" vertical-scroll-proportion="1.0623853">
<state line="50" column="11" selection-start="840" selection-end="840" vertical-scroll-proportion="1.0220183">
<folding>
<element signature="imports" expanded="true" />
</folding>
@ -548,30 +541,46 @@
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/src/net/thauvin/lifeblogger/LifeFTP.java">
<entry file="file://$PROJECT_DIR$/src/net/thauvin/lifeblogger/LifeRPCResponse.java">
<provider selected="true" editor-type-id="text-editor">
<state line="132" column="71" selection-start="3917" selection-end="3917" vertical-scroll-proportion="1.0201834">
<folding />
<state line="50" column="13" selection-start="1963" selection-end="1963" vertical-scroll-proportion="0.03119266">
<folding>
<element signature="imports" expanded="true" />
</folding>
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/src/net/thauvin/lifeblogger/main.xml">
<entry file="file://$PROJECT_DIR$/src/net/thauvin/lifeblogger/LifeFTP.java">
<provider selected="true" editor-type-id="text-editor">
<state line="8" column="60" selection-start="410" selection-end="410" vertical-scroll-proportion="0.24954128">
<state line="132" column="71" selection-start="3917" selection-end="3917" vertical-scroll-proportion="0.9798165">
<folding />
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/src/net/thauvin/lifeblogger/ReleaseInfo.java">
<provider selected="true" editor-type-id="text-editor">
<state line="15" column="23" selection-start="413" selection-end="413" vertical-scroll-proportion="0.29174313">
<state line="15" column="23" selection-start="413" selection-end="413" vertical-scroll-proportion="0.30535713">
<folding />
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/src/net/thauvin/lifeblogger/post.xml">
<provider selected="true" editor-type-id="text-editor">
<state line="13" column="78" selection-start="927" selection-end="927" vertical-scroll-proportion="0.40550458">
<folding />
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/src/net/thauvin/lifeblogger/main.xml">
<provider selected="true" editor-type-id="text-editor">
<state line="18" column="36" selection-start="882" selection-end="882" vertical-scroll-proportion="0.5614679">
<folding />
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/src/net/thauvin/lifeblogger/LifeBlogger.java">
<provider selected="true" editor-type-id="text-editor">
<state line="544" column="28" selection-start="13717" selection-end="13717" vertical-scroll-proportion="-6.187156">
<state line="669" column="11" selection-start="16595" selection-end="16595" vertical-scroll-proportion="0.055045873">
<folding>
<element signature="imports" expanded="true" />
</folding>
@ -580,20 +589,11 @@
</entry>
<entry file="file://$PROJECT_DIR$/src/net/thauvin/lifeblogger/LifePost.java">
<provider selected="true" editor-type-id="text-editor">
<state line="119" column="14" selection-start="4738" selection-end="4738" vertical-scroll-proportion="0.5614679">
<state line="117" column="21" selection-start="4735" selection-end="4735" vertical-scroll-proportion="0.08256881">
<folding />
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/src/net/thauvin/lifeblogger/LifeRPCResponse.java">
<provider selected="true" editor-type-id="text-editor">
<state line="50" column="13" selection-start="1963" selection-end="1963" vertical-scroll-proportion="-2.3651376">
<folding>
<element signature="imports" expanded="true" />
</folding>
</state>
</provider>
</entry>
</component>
</project>

View file

@ -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 <code>true</code> to publish the post, <code>false</code> 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);

View file

@ -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("</string></value></param><param><value><string>")
.append(textToXML(_blogEntry))
.append("</string></value></param><param><value><boolean>false</boolean></value></param></params></methodCall>");
.append("</string></value></param><param><value><boolean>")
.append(String.valueOf(_publish))
.append("</boolean></value></param></params></methodCall>");
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();
}
}

View file

@ -10,6 +10,7 @@
</panel>
<panel columns="2" halign="right" gap="4">
<button name="cancelbtn" text="Cancel" icon="/icon/exit.gif" action="closeDialog(dialog)"/>
<button name="sendbtn" text="Post" icon="/icon/go.gif" action="post(dialog, blog)"/>
<!-- <button name="sendbtn" text="Post" icon="/icon/go.gif" action="post(dialog, blog)"/> -->
<button name="sendbtn" text="Post" icon="/icon/go.gif" action="publish(dialog, blog)"/>
</panel>
</dialog>