<?xml version="1.0" encoding="UTF-8"?>
<!-- generator="bbPress/1.1" -->
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
		>
	<channel>
		<title>WordPress for Android Forums &#187; Tag: rsd - Recent Posts</title>
		<link>http://android.forums.wordpress.org/tags/rsd</link>
		<description>Just another bbPress community</description>
		<language>android</language>
		<pubDate>Thu, 23 May 2013 11:48:07 +0000</pubDate>
		<generator>http://bbpress.org/?v=1.1</generator>
				<atom:link href="http://android.forums.wordpress.org/rss/tags/rsd" rel="self" type="application/rss+xml" />

		<item>
			<title>Dan on "Finding the RSD link"</title>
			<link>http://android.forums.wordpress.org/topic/finding-the-rsd-link#post-2400</link>
			<pubDate>Sun, 04 Dec 2011 19:50:01 +0000</pubDate>
			<dc:creator>Dan</dc:creator>
			<guid isPermaLink="false">2400@http://android.forums.wordpress.org/</guid>
			<description><![CDATA[<p>Yes, you should be able to log in with your .org account and create a ticket and attach the patch. If not, you can shoot the diff over to android at automattic dot com.</p>
<p>Signup is: <a href="http://wordpress.org/support/register.php" rel="nofollow">http://wordpress.org/support/register.php</a>
</p>]]></description>
					</item>
		<item>
			<title>gbrockhaus on "Finding the RSD link"</title>
			<link>http://android.forums.wordpress.org/topic/finding-the-rsd-link#post-2399</link>
			<pubDate>Sun, 04 Dec 2011 12:35:23 +0000</pubDate>
			<dc:creator>gbrockhaus</dc:creator>
			<guid isPermaLink="false">2399@http://android.forums.wordpress.org/</guid>
			<description><![CDATA[<p>I have to create another account for it? One Wordpress account, one for the forum and one for the tracker?<br />
To create an account for the tracker I have to go to wordpress.org. Perhaps I am blind but I can't find any "register" option there. Shouldn't it be my WP acc?
</p>]]></description>
					</item>
		<item>
			<title>Dan on "Finding the RSD link"</title>
			<link>http://android.forums.wordpress.org/topic/finding-the-rsd-link#post-2398</link>
			<pubDate>Sat, 03 Dec 2011 22:34:54 +0000</pubDate>
			<dc:creator>Dan</dc:creator>
			<guid isPermaLink="false">2398@http://android.forums.wordpress.org/</guid>
			<description><![CDATA[<p>Sure, patches are welcome. Can you attach a diff to a ticket at <a href="http://android.trac.wordpress.org?" rel="nofollow">http://android.trac.wordpress.org?</a>
</p>]]></description>
					</item>
		<item>
			<title>gbrockhaus on "Finding the RSD link"</title>
			<link>http://android.forums.wordpress.org/topic/finding-the-rsd-link#post-2397</link>
			<pubDate>Sat, 03 Dec 2011 21:32:00 +0000</pubDate>
			<dc:creator>gbrockhaus</dc:creator>
			<guid isPermaLink="false">2397@http://android.forums.wordpress.org/</guid>
			<description><![CDATA[<p>Hello guys.</p>
<p>At the moment I am testing the wp-android client on a blog, that is not a WP blog but XMLRPC capable. The client is not able to find the rsd link to the xml-rpc interface. The reason is: The XML parser you are using to find the link is failing. I don't know if the reason is, that my blog template is HTML5 or what it is..</p>
<p>Anyways: Using a XML parser for searching for RSD entries in a HTML page is "too big" in my opinion. XML parser consume *a lot* of memory, where it would be much easier to use regular expressions to find the link. RegExes are more failsafe and you don't need a parser at all, so it works for any HTML a browser can display but a XML parser don't think it's XML.</p>
<p>I added these changes to AddAcount.java</p>
<pre><code>//..
String rsdUrl = getRSDMetaTagHrefRegEx(blogURL);
if (rsdUrl ==null) rsdUrl = getRSDMetaTagHref(blogURL);
// ..</code></pre>
<pre><code>private static final Pattern rsdLink = Pattern.compile(&#34;&#60;link\\s*?rel=\&#34;EditURI\&#34;\\s*?type=\&#34;application/rsd\\+xml\&#34;\\s*?title=\&#34;RSD\&#34;\\s*?href=\&#34;(.*?)\&#34;\\s*?/&#62;&#34;, Pattern.CASE_INSENSITIVE &#124; Pattern.DOTALL);

	private String getRSDMetaTagHrefRegEx(String urlString) {
		InputStream in = getResponse(urlString);
		if (in!=null) {
			try {
				String html = convertStreamToString(in);
				Matcher matcher = rsdLink.matcher(html);
				if (matcher.find()) {
					String href = matcher.group(1);
					return href;
				}
			} catch (IOException e) {
				Log.e(&#34;wp_android&#34;, &#34;IOEX&#34;, e);
				return null;
			}
		}
		return null;
	}

	private String convertStreamToString(InputStream is) throws IOException {
		/*
		 * To convert the InputStream to String we use the Reader.read(char[]
		 * buffer) method. We iterate until the Reader return -1 which means
		 * there&#039;s no more data to read. We use the StringWriter class to
		 * produce the string.
		 */
		int bufSize = 8 * 1024;
		if (is != null) {
			Writer writer = new StringWriter();

			char[] buffer = new char[bufSize];
			try {
				InputStreamReader ireader = new InputStreamReader(is, &#34;UTF-8&#34;);
				Reader reader = new BufferedReader(ireader, bufSize);
				int n;
				while ((n = reader.read(buffer)) != -1) {
					writer.write(buffer, 0, n);
				}
				reader.close();
				ireader.close();
				return writer.toString();
			} catch (OutOfMemoryError ex) {
				Log.e(&#34;wp_android&#34;, &#34;Convert Stream: (out of memory)&#34;);
				writer.close();
				writer=null;
				System.gc();
				return &#34;&#34;;
			} finally {
				is.close();
			}
		} else {
			return &#34;&#34;;
		}
	}</code></pre>
<p>This works on my blog now, too.</p>
<p>And btw: You are very often assuming, that "everything is there". When parsing xml-rpc responses,  you are allways using value.toString(), not checking if value is null at that moment. That is effective but nasty IMHO. The client crashes easily without a useful explanation. Would be cool, if the client would be more "failsafe".</p>
<p>I would happily add some code I've done and I will do, if you are interested in this stuff. :)</p>
<p>Regards, Grischa
</p>]]></description>
					</item>

	</channel>
</rss>
