<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>2718.us blog &#187; asLJ</title>
	<atom:link href="http://2718.us/blog/category/programming/aslj/feed/" rel="self" type="application/rss+xml" />
	<link>http://2718.us/blog</link>
	<description>Miscellaneous Technological Geekery</description>
	<lastBuildDate>Tue, 18 May 2010 02:42:55 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0.4</generator>
		<item>
		<title>Open Source (BSD/MIT License)</title>
		<link>http://2718.us/blog/2009/09/06/open-source-bsd-license/</link>
		<comments>http://2718.us/blog/2009/09/06/open-source-bsd-license/#comments</comments>
		<pubDate>Sun, 06 Sep 2009 10:24:58 +0000</pubDate>
		<dc:creator>2718.us</dc:creator>
				<category><![CDATA[Mac OS X]]></category>
		<category><![CDATA[NCIDStatusBarMenu]]></category>
		<category><![CDATA[Programming]]></category>
		<category><![CDATA[asLJ]]></category>
		<category><![CDATA[bsd]]></category>
		<category><![CDATA[bsd license]]></category>
		<category><![CDATA[google code]]></category>
		<category><![CDATA[googlecode]]></category>
		<category><![CDATA[mit]]></category>
		<category><![CDATA[mit license]]></category>
		<category><![CDATA[ncid]]></category>
		<category><![CDATA[open source]]></category>
		<category><![CDATA[permissive]]></category>
		<category><![CDATA[permissive license]]></category>
		<category><![CDATA[YDDecode]]></category>
		<category><![CDATA[ydec]]></category>
		<category><![CDATA[ydecode]]></category>
		<category><![CDATA[yenc]]></category>

		<guid isPermaLink="false">http://2718.us/blog/?p=170</guid>
		<description><![CDATA[I&#8217;ve released a few things as open source recently, under BSD or MIT license, hosted at Google Code. asLJCore is the primary component of the LiveJournal client asLJ, managing all communication with the server. YDDecode is a Cocoa class wrapped around some public-domain C code for decoding data encoded with YEnc. NCIDStatusBarMenu is a utility [...]]]></description>
			<content:encoded><![CDATA[<p>I&#8217;ve released a few things as open source recently, under BSD or MIT license, hosted at Google Code.</p>
<ul>
<li><a href="http://asljcore.googlecode.com/">asLJCore</a> is the primary component of the LiveJournal client <a href="/asLJ/">asLJ</a>, managing all communication with the server.</li>
<li><a href="http://cocoa-ydec.googlecode.com/">YDDecode</a> is a Cocoa class wrapped around some public-domain C code for decoding data encoded with <a href="http://www.yenc.org/">YEnc</a>.</li>
<li><a href="http://ncidstatusbarmenu.googlecode.com/">NCIDStatusBarMenu</a> is a utility to help pull NCID-based callerID notifications and display them as Growl notifications (among other things).  I&#8217;d been meaning to update it for nearly 2 years with no success and the future isn&#8217;t looking much better, so I&#8217;m releasing the source instead.</li>
</ul>
<p>(My musings on licensing below the cut.)<span id="more-170"></span>Permissive BSD/MIT licenses because in writing asLJ among other things, I&#8217;ve had to work to find libraries, frameworks, components, classes, etc., that weren&#8217;t GPL-licensed so that I could continue to choose how I wanted to release my software.  I am also heavily influenced by the simplicity of the BSD and MIT licenses compared to the lengthy GPL (and while the LGPL ought to be workable for many libraries, I couldn&#8217;t quite wrap my head around the language of it&#8211;the LGPL is several paragraphs of modification to the GPL).</p>
<p>(The <a href="http://openbsd.org/lyrics.html#43">song lyrics and commentary for OpenBSD4.3</a> have a lot to do with how I feel about GPL versus BSD/MIT.)</p>
]]></content:encoded>
			<wfw:commentRss>http://2718.us/blog/2009/09/06/open-source-bsd-license/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>XML-RPC and Mac Programming, Revisited</title>
		<link>http://2718.us/blog/2009/04/26/xml-rpc-and-mac-programming-revisited/</link>
		<comments>http://2718.us/blog/2009/04/26/xml-rpc-and-mac-programming-revisited/#comments</comments>
		<pubDate>Sun, 26 Apr 2009 05:59:02 +0000</pubDate>
		<dc:creator>2718.us</dc:creator>
				<category><![CDATA[asLJ]]></category>
		<category><![CDATA[applescript]]></category>
		<category><![CDATA[objective c]]></category>
		<category><![CDATA[python]]></category>
		<category><![CDATA[unicode]]></category>
		<category><![CDATA[utf8]]></category>
		<category><![CDATA[xml-rpc]]></category>
		<category><![CDATA[xmlrpc]]></category>

		<guid isPermaLink="false">http://2718.us/blog/?p=139</guid>
		<description><![CDATA[I might have been wrong, or at least not entirely right, when I said that AppleScript&#8217;s XML-RPC was doing something screwy with UTF8-encoded responses to XML-RPC requests.  I&#8217;m not sure if it&#8217;s LiveJournal (and other sites based on their code), or if it&#8217;s something inherent in XML-RPC, but whether I make the XML-RPC calls in [...]]]></description>
			<content:encoded><![CDATA[<p>I might have been wrong, or at least not entirely right, when I said that <a href="http://2718.us/blog/2009/02/14/applescripts-xml-rpc-doesnt-get-along-with-utf8/">AppleScript&#8217;s XML-RPC was doing something screwy with UTF8-encoded responses to XML-RPC requests</a>.  I&#8217;m not sure if it&#8217;s LiveJournal (and other sites based on their code), or if it&#8217;s something inherent in XML-RPC, but whether I make the XML-RPC calls in AppleScript (with its built-in mechanism for calling XML-RPC), in Python (with xmlrpclib), or in Objective-C/Cocoa (using <a href="http://github.com/eczarny/xmlrpc/tree/2.0">the XML-RPC framework</a> from <a href="http://divisiblebyzero.com/">here</a>), things that I was expecting to be UTF8 strings were instead coming through as binary data that needed to be decoded.</p>
<p>Beyond that point, however, AppleScript was severely lacking in that the form in which that data was stored made it entirely unusable&#8211;AppleScript couldn&#8217;t convert it, couldn&#8217;t pass it off to an Objective-C method, etc.  As suggested in my previous post, there was a way around it, and messy though it was, I went about implementing that fix and by and large it worked (though it exposed another minor bug elsewhere).  But it really bothered me.</p>
<p>So I went back to looking at trying to integrate Python code into my tangled web of AppleScript and Objective-C, since XML-RPC is fairly easy in Python, though not quite as easy as in AppleScript.  And, eventually, I succeeded in integrating a class written in Python into the program (documentation on using the PyObjC bridge in this direction is woefully inadequate), using a less ineligant means of fixing the binary UTF8 data—</p>
<pre>unicode(theResult.data,'utf-8')</pre>
<p>(and Python also allowed me to generically recurse through the entire return structure, which wasn&#8217;t possible in Applescript).  Unfortunately, this version was <em>substantially</em> slower than the broken-Unicode version and not particularly any faster (perhaps slower) than the AppleScript-fixed Unicode version.</p>
<p>This led me to look for a way to do the XML-RPC stuff in Objective-C.  Now, mind you, the single thing that enabled me to even think about writing a client for LJ for Mac was seeing just how easy AppleScript XML-RPC calls were.  While I didn&#8217;t particularly want to try Python, the XML-RPC calls there weren&#8217;t that much harder.  But going to Objective-C for XML-RPC&#8230;  that&#8217;s a fundamental change in the program.  At least, to me.</p>
<p>I did a lot of Googling and found that there are actually a few XML-RPC frameworks for Objective-C/Cocoa (<a href="http://github.com/eczarny/xmlrpc/tree/2.0">the one I used by Eric Czarny</a>, <a href="http://ranchero.com/cocoa/xmlrpc/">the one from Brent Simmons</a>, <a href="http://www.mulle-kybernetik.com/software/XMLRPC/">the Mulle one</a>, <a href="http://www.padl.com/Research/XMLRPCObjC.html">XMLRPCObjC</a>, <a href="http://sope.opengroupware.org/en/docs/snippets/xmlrpc_client.html">SOPE</a>).  Supposedly, there&#8217;s a way to do it with Apple&#8217;s own Cocoa stuff, but the documentation is woefully inadequate (none of the frameworks have amazing and wonderful documentation, but Apple&#8217;s documentation is <em>bad</em>) and almost every mention of it that I found on mailing lists and discussion boards said it was broken.  In the end, my framework choice was largely dictated by licensing, though there were also some issues with usability and dependencies.  As with AppleScript and Python, the UTF8 strings weren&#8217;t coming through as strings, but as NSData objects, which are fairly easy to convert with</p>
<pre>[[NSString alloc] initWithData:theObject encoding:NSUTF8StringEncoding]</pre>
<p>Recursing through the entire returned structure wasn&#8217;t particularly any harder in Objective-C than in Python.</p>
<p>The best part is that the resulting client with Objective-C-based-XML-RPC feels <em>faster</em> than the non-Unicode AppleScript-based-XML-RPC client.  In vaguely-objective tests (determine a set of steps that constitute a test and record the total time for just the XML-RPC calls in those steps, run the test several times under each app, compare times), the new version is <em>measurably</em> faster than the old version.</p>
<p>Bottom lines: (1) expect a new version of <a href="http://2718.us/asLJ/">asLJ</a> in the next few days, as soon as I get feedback from my early testers; (2) expect another post or two about other things I&#8217;ve learned in rewriting the XML-RPC aspect of asLJ in Objective-C.</p>
]]></content:encoded>
			<wfw:commentRss>http://2718.us/blog/2009/04/26/xml-rpc-and-mac-programming-revisited/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>AppleScript&#8217;s XML-RPC Doesn&#8217;t Get Along with UTF8</title>
		<link>http://2718.us/blog/2009/02/14/applescripts-xml-rpc-doesnt-get-along-with-utf8/</link>
		<comments>http://2718.us/blog/2009/02/14/applescripts-xml-rpc-doesnt-get-along-with-utf8/#comments</comments>
		<pubDate>Sun, 15 Feb 2009 00:53:02 +0000</pubDate>
		<dc:creator>2718.us</dc:creator>
				<category><![CDATA[asLJ]]></category>
		<category><![CDATA[applescript]]></category>
		<category><![CDATA[data]]></category>
		<category><![CDATA[rdat]]></category>
		<category><![CDATA[unicode]]></category>
		<category><![CDATA[utf8]]></category>
		<category><![CDATA[xml-rpc]]></category>
		<category><![CDATA[xmlrpc]]></category>

		<guid isPermaLink="false">http://2718.us/blog/?p=131</guid>
		<description><![CDATA[While the ease of making XML-RPC calls in AppleScript is wonderful for, say, writing a LiveJournal Client in mostly AppleScript Studio, it seems to be doing something really messed up with UTF8 strings returned by the server—they come into AppleScript as raw data objects, which it seems can&#8217;t be cast into any other type and [...]]]></description>
			<content:encoded><![CDATA[<p>While the ease of making XML-RPC calls in AppleScript is wonderful for, say, writing <a href="http://2718.us/asLJ/">a LiveJournal Client</a> in mostly AppleScript Studio, it seems to be doing something really messed up with UTF8 strings returned by the server—they come into AppleScript as raw data objects, which it seems can&#8217;t be cast into any other type and can&#8217;t be passed easily into a Cocoa method to convert them.  The easiest way to properly decode them seems to be the following:</p>
<div class="geshi no applescript">
<ol>
<li class="li1">
<div class="de1"><span class="kw1">if</span> class <span class="kw1">of</span> theReturnedValue <span class="kw1">is</span> <span class="st0">&quot;data&quot;</span> <span class="kw1">then</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp;<span class="kw1">try</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp; <span class="coMULTI">(* this will fail on a data object and then we will pull the (hex) bytes out as text</span></div>
</li>
<li class="li1">
<div class="de1"><span class="coMULTI">&nbsp; and bring them back as a utf8 string object *)</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp; theReturnedValue <span class="kw3">as</span> text</div>
</li>
<li class="li1">
<div class="de1">&nbsp;<span class="kw1">on</span> <span class="kw1">error</span> errmess <span class="co1">&#8211; extract the data from the error message</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp; <span class="kw1">set</span> bytesString <span class="kw1">to</span> text <span class="br0">&#40;</span><span class="br0">&#40;</span>offset <span class="kw1">of</span> <span class="st0">&quot;«&quot;</span> <span class="kw1">in</span> errmess<span class="br0">&#41;</span> <span class="sy0">+</span> <span class="nu0">10</span><span class="br0">&#41;</span> <span class="kw2">thru</span> <span class="br0">&#40;</span><span class="br0">&#40;</span>offset <span class="kw1">of</span> <span class="st0">&quot;»&quot;</span> <span class="kw1">in</span> errmess<span class="br0">&#41;</span> <span class="sy0">-</span> <span class="nu0">1</span><span class="br0">&#41;</span> <span class="kw1">of</span> errmess</div>
</li>
<li class="li1">
<div class="de1">&nbsp; <span class="kw1">set</span> theReturnedValue <span class="kw1">to</span> <span class="br0">&#40;</span><span class="kw3">run</span> <span class="kw1">script</span> <span class="st0">&quot;«data utf8&quot;</span> <span class="sy0">&amp;</span> bytesString <span class="sy0">&amp;</span> <span class="st0">&quot;»&quot;</span><span class="br0">&#41;</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp;<span class="kw1">end</span> <span class="kw1">try</span></div>
</li>
<li class="li1">
<div class="de1"><span class="kw1">end</span> <span class="kw1">if</span></div>
</li>
</ol>
</div>
<p>This checks the class of the returned value and, if it&#8217;s a raw data object, attempts to cast it as text which raises an error, then extracts the string of hexadecimal values from the error message and puts it into a proper UTF8 object, making everything happy again.</p>
<p>If anyone wants to tell me I&#8217;m wrong and there&#8217;s a simpler fix, I&#8217;d love to hear it, since this is essentially unworkable.</p>
]]></content:encoded>
			<wfw:commentRss>http://2718.us/blog/2009/02/14/applescripts-xml-rpc-doesnt-get-along-with-utf8/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Dynamic URLs for XML-RPC Calls in AppleScript</title>
		<link>http://2718.us/blog/2009/02/12/dynamic-urls-for-xml-rpc-calls-in-applescript/</link>
		<comments>http://2718.us/blog/2009/02/12/dynamic-urls-for-xml-rpc-calls-in-applescript/#comments</comments>
		<pubDate>Thu, 12 Feb 2009 16:42:38 +0000</pubDate>
		<dc:creator>2718.us</dc:creator>
				<category><![CDATA[asLJ]]></category>
		<category><![CDATA[applescript]]></category>
		<category><![CDATA[applescript studio]]></category>
		<category><![CDATA[livejournal]]></category>
		<category><![CDATA[lj]]></category>
		<category><![CDATA[xml-rpc]]></category>
		<category><![CDATA[xmlrpc]]></category>

		<guid isPermaLink="false">http://2718.us/blog/?p=123</guid>
		<description><![CDATA[I started working on asLJ after I came across this. One of the problems that I quickly ran into was that the URLs in the tell application "&#60;url&#62;" to call xmlrpc ... bits had to be hard-coded. That is, AppleScript didn&#8217;t like it when I tried to assemble the URL string on the fly. It [...]]]></description>
			<content:encoded><![CDATA[<p>I started working on <a href="http://2718.us/asLJ/">asLJ</a> after I came across <a href="http://community.livejournal.com/applescript/18386.html">this</a>.  One of the problems that I quickly ran into was that the URLs in the
<pre>tell application "&lt;url&gt;" to call xmlrpc ...</pre>
<p> bits had to be hard-coded.  That is, AppleScript didn&#8217;t like it when I tried to assemble the URL string on the fly.  It took me a while to come up with a workaround, which should slightly impact the speed of the call, but doesn&#8217;t seem to make a noticeable difference.  Here&#8217;s my generic handler for making LJ-based server XML-RPC calls:</p>
<div class="geshi no applescript">
<div class="head">&#8211; make a LiveJournal-type XML-RPC call to serverString for the method methodName with the parameters in parameterArray</div>
<ol>
<li class="li1">
<div class="de1"><span class="kw1">on</span> callLJraw<span class="br0">&#40;</span>serverString, methodName, parameterArray<span class="br0">&#41;</span></div>
</li>
<li class="li1">
<div class="de1">    <span class="kw3">run</span> <span class="kw1">script</span> <span class="st0">&quot;on run {paramArray}</span></div>
</li>
<li class="li1">
<div class="de1"><span class="st0">                tell application <span class="es0">\&quot;</span>http://&quot;</span> <span class="sy0">&amp;</span> serverString <span class="sy0">&amp;</span> <span class="st0">&quot;/interface/xmlrpc<span class="es0">\&quot;</span> to call xmlrpc ¬</span></div>
</li>
<li class="li1">
<div class="de1"><span class="st0">                    {method name:<span class="es0">\&quot;</span>LJ.XMLRPC.<span class="es0">\&quot;</span> &amp; <span class="es0">\&quot;</span>&quot;</span> <span class="sy0">&amp;</span> methodName <span class="sy0">&amp;</span> <span class="st0">&quot;<span class="es0">\&quot;</span>, parameters:{paramArray}}</span></div>
</li>
<li class="li1">
<div class="de1"><span class="st0">            end run&quot;</span> <span class="kw1">with</span> parameters <span class="br0">&#123;</span>parameterArray<span class="br0">&#125;</span></div>
</li>
<li class="li1">
<div class="de1">    <span class="kw1">return</span> <span class="kw3">result</span></div>
</li>
<li class="li1">
<div class="de1"><span class="kw1">end</span> callLJraw</div>
</li>
</ol>
</div>
]]></content:encoded>
			<wfw:commentRss>http://2718.us/blog/2009/02/12/dynamic-urls-for-xml-rpc-calls-in-applescript/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>asLJ: a Mac OS X 10.5+ LiveJournal Client</title>
		<link>http://2718.us/blog/2009/02/09/aslj/</link>
		<comments>http://2718.us/blog/2009/02/09/aslj/#comments</comments>
		<pubDate>Mon, 09 Feb 2009 08:24:18 +0000</pubDate>
		<dc:creator>2718.us</dc:creator>
				<category><![CDATA[asLJ]]></category>
		<category><![CDATA[applescript]]></category>
		<category><![CDATA[applescript studio]]></category>
		<category><![CDATA[client]]></category>
		<category><![CDATA[cocoa]]></category>
		<category><![CDATA[keychain]]></category>
		<category><![CDATA[keychain.framework]]></category>
		<category><![CDATA[leopard]]></category>
		<category><![CDATA[livejournal]]></category>
		<category><![CDATA[livejournal client]]></category>
		<category><![CDATA[lj]]></category>
		<category><![CDATA[lj client]]></category>
		<category><![CDATA[mac]]></category>
		<category><![CDATA[Mac OS X]]></category>
		<category><![CDATA[macintosh]]></category>
		<category><![CDATA[objective c]]></category>
		<category><![CDATA[os x]]></category>
		<category><![CDATA[sparkle]]></category>
		<category><![CDATA[xcode]]></category>

		<guid isPermaLink="false">http://2718.us/blog/?p=121</guid>
		<description><![CDATA[asLJ is a new client for Macs running Leopard that easily handles multiple accounts on LiveJournal and other LJ-based sites and facilitates cross-posting across accounts. Release notes and download link are in aslj_client. The community for users is aslj_users. (As it is very LJ-centric, most of the information about it will be over at LJ, [...]]]></description>
			<content:encoded><![CDATA[<p>asLJ is a new client for Macs running Leopard that easily handles multiple accounts on LiveJournal and other LJ-based sites and facilitates cross-posting across accounts. Release notes and download link are in <span style="white-space: nowrap;"><a href="http://aslj-client.livejournal.com/profile"><img style="border: 0pt none; vertical-align: bottom; padding-right: 1px;" src="http://p-stat.livejournal.com/img/userinfo.gif" alt="[info]" width="17" height="17" /></a><a href="http://aslj-client.livejournal.com/"><strong>aslj_client</strong></a></span>.  The community for users is <span style="white-space: nowrap;"><a href="http://community.livejournal.com/aslj_users/profile"><img style="border: 0pt none; vertical-align: bottom; padding-right: 1px;" src="http://p-stat.livejournal.com/img/community.gif" alt="[info]" width="16" height="16" /></a><a href="http://community.livejournal.com/aslj_users/"><strong>aslj_users</strong></a></span>.</p>
<p>(As it is very LJ-centric, most of the information about it will be over at LJ, in the two places linked above, but there is a page for it <a href="http://2718.us/asLJ/">here</a>, as well.)</p>
]]></content:encoded>
			<wfw:commentRss>http://2718.us/blog/2009/02/09/aslj/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

