Changed default from FTP to MetaWeblog.
Changed post action to publish.
This commit is contained in:
parent
45cf46a227
commit
1a8a73a643
4 changed files with 144 additions and 109 deletions
|
@ -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);
|
||||
|
|
|
@ -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();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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>
|
Loading…
Add table
Add a link
Reference in a new issue