# HG changeset patch # User e085711 # Date 1315170194 -32400 # Node ID 8bdbed4c4505239b08d6586b9715127bd7a9bb00 # Parent c1d7d4fbcfb9003ff158613440de592b13ccf407 add template.txt diff -r c1d7d4fbcfb9 -r 8bdbed4c4505 .hgignore --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/.hgignore Mon Sep 05 06:03:14 2011 +0900 @@ -0,0 +1,6 @@ +syntax: glob +*.jar +GPATH +GRTAGS +GSYMS +GTAGS diff -r c1d7d4fbcfb9 -r 8bdbed4c4505 hades.cr.ie.u-ryukyu.ac.jp.html --- a/hades.cr.ie.u-ryukyu.ac.jp.html Sun Sep 04 20:39:14 2011 +0900 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,10 +0,0 @@ -hbpVNC desktop - - - - -
-University of the Ryukyu - - diff -r c1d7d4fbcfb9 -r 8bdbed4c4505 nw0811.st.ie.u-ryukyu.ac.jp.html --- a/nw0811.st.ie.u-ryukyu.ac.jp.html Sun Sep 04 20:39:14 2011 +0900 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,10 +0,0 @@ -hbpVNC desktop - - - - -
-University of the Ryukyu - - diff -r c1d7d4fbcfb9 -r 8bdbed4c4505 src/myVncProxy/ProxyVncCanvas.java --- a/src/myVncProxy/ProxyVncCanvas.java Sun Sep 04 20:39:14 2011 +0900 +++ b/src/myVncProxy/ProxyVncCanvas.java Mon Sep 05 06:03:14 2011 +0900 @@ -392,7 +392,7 @@ rfb.is.reset(); break; } - + if (statNumUpdates == viewer.debugStatsExcludeUpdates && !statsRestarted) { resetStats(); @@ -404,6 +404,7 @@ rfb.readFramebufferUpdate(); statNumUpdates++; +// System.out.println("NRects = "+ rfb.updateNRects); boolean cursorPosReceived = false; @@ -413,7 +414,9 @@ statNumTotalRects++; int rx = rfb.updateRectX, ry = rfb.updateRectY; int rw = rfb.updateRectW, rh = rfb.updateRectH; - +// System.out.println("rx = "+ rx + " ry = "+ry+"\nrw = "+rw+" rh = "+rh); +// System.out.println("encoding = "+ rfb.updateRectEncoding); + if (rfb.updateRectEncoding == rfb.EncodingLastRect) break; diff -r c1d7d4fbcfb9 -r 8bdbed4c4505 src/myVncProxy/RfbProto.java --- a/src/myVncProxy/RfbProto.java Sun Sep 04 20:39:14 2011 +0900 +++ b/src/myVncProxy/RfbProto.java Mon Sep 05 06:03:14 2011 +0900 @@ -1366,7 +1366,7 @@ } // FIXME: DataInputStream::skipBytes() is not guaranteed to skip - // exactly n bytes. Probably we don't want to use this method. + // exactly n bytes. Probably we don't want to use this method.f final int skipBytes(int n) throws IOException { int r = is.skipBytes(n); numBytesRead += r; diff -r c1d7d4fbcfb9 -r 8bdbed4c4505 src/myVncProxy/VncProxyService.java --- a/src/myVncProxy/VncProxyService.java Sun Sep 04 20:39:14 2011 +0900 +++ b/src/myVncProxy/VncProxyService.java Mon Sep 05 06:03:14 2011 +0900 @@ -131,6 +131,7 @@ try{ connectAndAuthenticate(); + doProtocolInitialisation(); }catch (NoRouteToHostException e) { fatalError("Network error: no route to server: " + host, e); } catch (UnknownHostException e) { @@ -149,6 +150,7 @@ client = new XmlRpc(blogId, wpUsername, wpPassword, url ); InetAddress addr = InetAddress.getLocalHost(); String add = new String(addr.getHostAddress()); + client.addDescription(rfb.desktopName); setStatusXmlRpc(client, title, add, rfb.acceptPort); client.editPost(); System.out.println("URL:\n" + client.getUrl() + "\n"); @@ -166,7 +168,7 @@ void setStatusXmlRpc(XmlRpc client, String title, String hostname, int port) { client.setTitle(title); String description = makeDescription(hostname, Integer.toString(port)); - client.setDescription(description); + client.addDescription(description); } String makeDescription(String hostname, String port) { @@ -187,7 +189,7 @@ try { // connectAndAuthenticate(); - doProtocolInitialisation(); +// doProtocolInitialisation(); /* htmlFile = new CreateHtmlFile(rfb, host, username); htmlFile.createHtml(); @@ -386,6 +388,7 @@ int preferredEncoding = options.preferredEncoding; if (preferredEncoding == -1) { long kbitsPerSecond = rfb.kbitsPerSecond(); +/* if (nEncodingsSaved < 1) { // Choose Tight or ZRLE encoding for the very first update. System.out.println("Using Tight/ZRLE encodings"); @@ -408,6 +411,7 @@ return; preferredEncoding = encodingsSaved[0]; } +*/ } else { // Auto encoder selection is not enabled. if (autoSelectOnly) @@ -423,19 +427,22 @@ if (options.useCopyRect) { encodings[nEncodings++] = RfbProto.EncodingCopyRect; } +/* if (preferredEncoding != RfbProto.EncodingTight) { encodings[nEncodings++] = RfbProto.EncodingTight; } - +*/ if (preferredEncoding != RfbProto.EncodingZRLE) { encodings[nEncodings++] = RfbProto.EncodingZRLE; } +/* if (preferredEncoding != RfbProto.EncodingHextile) { encodings[nEncodings++] = RfbProto.EncodingHextile; } if (preferredEncoding != RfbProto.EncodingZlib) { encodings[nEncodings++] = RfbProto.EncodingZlib; } +*/ if (preferredEncoding != RfbProto.EncodingCoRRE) { encodings[nEncodings++] = RfbProto.EncodingCoRRE; } diff -r c1d7d4fbcfb9 -r 8bdbed4c4505 src/myVncProxy/XmlRpc.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/myVncProxy/XmlRpc.java Mon Sep 05 06:03:14 2011 +0900 @@ -0,0 +1,183 @@ +package myVncProxy; + +import java.net.MalformedURLException; +import java.net.URL; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +import org.apache.xmlrpc.XmlRpcException; +import org.apache.xmlrpc.client.XmlRpcClient; +import org.apache.xmlrpc.client.XmlRpcClientConfigImpl; + +public class XmlRpc { + static final String META_WEBLOG_NEW_POST = "metaWeblog.newPost"; + static final String META_WEBLOG_EDIT_POST = "metaWeblog.editPost"; + static final String META_WEBLOG_GET_POST = "metaWeblog.getPost"; + + XmlRpcClient client; + XmlRpcClientConfigImpl config; + + String loginId, pw, postUrl; + String blogId; + String title = ""; + String description = ""; + ArrayList categories = new ArrayList(); + + XmlRpc(String blogId, String loginId, String pw, String url) throws MalformedURLException { + this.blogId = blogId; + this.loginId = loginId; + this.pw = pw; + postUrl = checkUrl(url); + client = createClient(postUrl); + } + String checkUrl(String url) { + String str; + if(url.endsWith("xmlrpc.php")){ + return url; + } else if(url.endsWith("/")) { + str = url + "xmlrpc.php"; + } else { + str = url + "/xmlrpc.php"; + } + return str; + } + XmlRpcClient createClient(String url) throws MalformedURLException { + config = new XmlRpcClientConfigImpl(); + config.setServerURL(new URL(url.trim())); + + XmlRpcClient c = new XmlRpcClient(); + c.setConfig(config); + + return c; + } + + String newPost() { + String result = post(META_WEBLOG_NEW_POST); + blogId = result; + return result; + } + String editPost() { + return post(META_WEBLOG_EDIT_POST); + } + + String post(String API) { + + String result = ""; + + Map contentParam = buildContent(); + List params = buildParam(contentParam); + + Object o = null; + try { + o = client.execute(API, params); + result = o.toString(); + } catch (XmlRpcException e) { + e.printStackTrace(); + } + return result; + } + + + protected void setTitle(String str) { + this.title = str; + } + protected void setDescription(String str) { + this.description = str; + } + protected void addDescription(String str) { + this.description += str; + } + protected void setCategories(String[] str) { + for(int i = 0; i < str.length; i ++) + categories.add(str[i]); + } + protected void addCategories(String str) { + categories.add(str); + } + + protected Map buildContent() { + Map content = new HashMap(); + + description = description.replaceAll("\n", "
"); + content.put("title", title); + content.put("categories", categories.toArray()); + content.put("description", description); + content.put("dateCreated", ""); + content.put("wp_slug", ""); + + return content; + } + + protected List buildParam(Map contentParam) { + List params = new ArrayList(); + + params.add(""); // appkey + params.add(blogId); + params.add(loginId); + params.add(pw); + params.add(contentParam);// content + params.add("1");// publish + + return params; + } + + String getUrl() { + List params = new ArrayList(); + + params.add(blogId); + params.add(loginId); + params.add(pw); + + Object result = null; + String str = "false"; + try { + result = weblog(params, META_WEBLOG_GET_POST); + Map map = (HashMap) result; + str = (String) map.get("link"); + } catch (XmlRpcException e) { + e.printStackTrace(); + } + return str; + } + + Object weblog(List params, String API) throws XmlRpcException { + Object o = null; + o = client.execute(API, params); + return o; + } + + public static void main(String[] args){ + if (args.length < 2) { + System.out.println("usage: program username password "); + System.exit(0); + } + String username = args[0]; + String password = args[1]; + + String blogId = "77"; +// String url = "http://single.cr.ie.u-ryukyu.ac.jp/wordpress/xmlrpc.php"; +// String url = "http://single.cr.ie.u-ryukyu.ac.jp/wordpress/"; + String url = "http://single.cr.ie.u-ryukyu.ac.jp/wordpress"; + + XmlRpc rpc; + try { + rpc = new XmlRpc(blogId, username, password, url ); + rpc.setTitle("xml-rpcを用いての投稿 @ java"); + rpc.setDescription("java からの投稿\nテスト\n"); + rpc.addDescription("addDescription()\n"); + rpc.addCategories("XML-RPC"); + + String res = rpc.newPost(); +// String res = rpc.editPost(); + String res2 = rpc.getUrl(); + System.out.println(res); + System.out.println(res2); + } catch (MalformedURLException e) { + e.printStackTrace(); + } + + } + +} diff -r c1d7d4fbcfb9 -r 8bdbed4c4505 template.txt --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/template.txt Mon Sep 05 06:03:14 2011 +0900 @@ -0,0 +1,7 @@ +-h hostname +-pn 5900 +-pw password +-w WordPressURL +-wu WPUsername +-wp WPPassword +-wb blogId \ No newline at end of file