<?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>Slashdev &#187; BlackBerry</title>
	<atom:link href="http://www.slashdev.ca/category/blackberry/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.slashdev.ca</link>
	<description>Hardware, software, and just general tinkering</description>
	<lastBuildDate>Thu, 20 Oct 2011 09:55:11 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.2.1</generator>
		<item>
		<title>BlackBerry Push Service &#8211; Fail</title>
		<link>http://www.slashdev.ca/2011/02/01/blackberry-push-service-fail/</link>
		<comments>http://www.slashdev.ca/2011/02/01/blackberry-push-service-fail/#comments</comments>
		<pubDate>Tue, 01 Feb 2011 16:05:29 +0000</pubDate>
		<dc:creator>jiGGaK</dc:creator>
				<category><![CDATA[BlackBerry]]></category>
		<category><![CDATA[Rants]]></category>

		<guid isPermaLink="false">http://www.slashdev.ca/?p=382</guid>
		<description><![CDATA[This really is depressing. Being Canadian and all I really want to root for the home team. Moreover I hate polluting my blog with complaints about BlackBerry development. Alas, here we go again&#8230; Todays topic: BlackBerry Push Service. BlackBerry push can be routed through BlackBerry Internet Service or it can route through a BlackBerry Enterprise [...]]]></description>
			<content:encoded><![CDATA[<div id="attachment_387" class="wp-caption aligncenter" style="width: 510px"><img src="http://www.slashdev.ca/wp-content/uploads/2011/01/graph.png" alt="" title="graph" width="500" height="400" class="size-full wp-image-387" /><p class="wp-caption-text">Everyone loves graphs...</p></div>
<p>This really is depressing. Being Canadian and all I really want to root for the home team. Moreover I hate polluting my blog with complaints about BlackBerry development. Alas, here we go again&#8230;</p>
<p>Todays topic: <a href="http://www.blackberry.com/developers/pushservice">BlackBerry Push Service</a>. BlackBerry push can be routed through <em>BlackBerry Internet Service</em> or it can route through a <em>BlackBerry Enterprise Server</em>. The difference? BIS is the one you want to use if you are a developer targeting the consumer market at large. To route push notifications through BIS, you must <a href="https://www.blackberry.com/profile/?eventId=8121">request</a> to evaluate the push service. It also appears you must submit another request when you want to go live, but I haven&#8217;t made it that far.</p>
<p>This is where the problem lies. I have submitted three requests in the past two weeks with no response. Each time I submit one, I&#8217;m greeted with a friendly message:</p>
<blockquote><p><em>&#8220;Thank you, someone will contact you in <strong>two business days</strong>&#8220;</em></p></blockquote>
<p>Bottom line I can&#8217;t finish OR test my app without access to this service.</p>
<h2>What about the other guys?</h2>
<p>This is where it gets sad. The software I&#8217;m working on is also being developed in parallel for Android and iOS. So what does the process look like for the other platforms?</p>
<h3>Android</h3>
<p>The <a href="http://code.google.com/android/c2dm/">Android Cloud to Device Messaging</a> framework also requires developers to <a href="http://code.google.com/android/c2dm/">signup</a> to access the service. The difference being two seconds after you fill out the signup form you are ready to go!</p>
<p>Slightly off topic, but the C2DM API is extremely simple to use. It was a pleasure to work with since I could use basic Unix shell scripting to send requests to the service during testing.</p>
<h3>Apple</h3>
<p>After you register as an iOS developer (and you drop $100 US for the privilege), Apple gives you access to something called the <em>iOS Provisioning Portal</em> which is a web interface for generating all manor of certificates and mobile provisioning bits and bobs. In this portal access to the APNS (Apple Push Notification Service) can also be enabled with a few mouse clicks&#8230; instantly.</p>
<h2>So what have I done so far?</h2>
<p>Not wait on RIM, that&#8217;s for sure! In the last two weeks I have managed to completely finish the iOS and Android versions of my app including full push integration.</p>
<p>Let me say that again. In the time it&#8217;s taking RIM to <em>grant</em> me permission to write software that uses their services, I have created the same thing on competing platforms.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.slashdev.ca/2011/02/01/blackberry-push-service-fail/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Fixing Sigtool &#8211; Again</title>
		<link>http://www.slashdev.ca/2010/01/28/fixing-sigtool-again/</link>
		<comments>http://www.slashdev.ca/2010/01/28/fixing-sigtool-again/#comments</comments>
		<pubDate>Fri, 29 Jan 2010 03:40:56 +0000</pubDate>
		<dc:creator>jiGGaK</dc:creator>
				<category><![CDATA[BlackBerry]]></category>

		<guid isPermaLink="false">http://www.slashdev.ca/?p=298</guid>
		<description><![CDATA[A year or so ago I wrote out some instructions detailing how to make SignatureTool.jar work in Unix type systems. Soon after I got word that somewhere around JDE 4.6 or JDE 4.7, RIM actually fixed the mistake in the sigtool. Sadly they missed one. If you attempt to sign a .cod file larger than [...]]]></description>
			<content:encoded><![CDATA[<p>A year or so ago I wrote out some instructions detailing <a href="/2008/03/16/using-sigtool-in-linux/">how to make SignatureTool.jar work</a> in Unix type systems. Soon after I got word that somewhere around JDE 4.6 or JDE 4.7, RIM actually fixed the mistake in the sigtool.  Sadly they missed one.</p>
<p>If you attempt to sign a <tt>.cod</tt> file larger than 64KB (ie: contains sibling files or child files or whatever files) then you will likely get a file created in your current working directory that looks something like <tt>kd8m34jkf/my_lame_app-1.cod</tt>.  When you load the file to the device it will result in an error of some sort.  The fix for this is relatively simple.  Read on for the details.</p>
<p><span id="more-298"></span></p>
<h2>Edit class file</h2>
<p>Go back and read my <a href="/2008/03/16/using-sigtool-in-linux/">other post</a> for instructions on extracting the jar file and for packaging it up again.  I&#8217;m going to leave out some details here since they are covered previously.</p>
<p>Note: this is based on the SignatureTool.jar file from JDE 4.7.  I have not verified that this procedure is the same for other versions of the JDE.</p>
<p>We will use good old <a href="http://classeditor.sourceforge.net/">ClassEditor</a> again.  Open <tt>q.class</tt> and change string constant at index 253 from a back slash to a forward slash.</p>
<div id="attachment_307" class="wp-caption aligncenter" style="width: 410px"><a href="http://www.slashdev.ca/wp-content/uploads/2010/01/2010-01-28-233337_800x600_scrot.png"><img src="http://www.slashdev.ca/wp-content/uploads/2010/01/2010-01-28-233337_800x600_scrot-400x300.png" alt="Edit string constant at index 253 in q.class" title="2010-01-28-233337_800x600_scrot" width="400" height="300" class="size-medium wp-image-307" /></a><p class="wp-caption-text">Edit string constant at index 253 in q.class</p></div>
]]></content:encoded>
			<wfw:commentRss>http://www.slashdev.ca/2010/01/28/fixing-sigtool-again/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Signing Servers Down Again</title>
		<link>http://www.slashdev.ca/2010/01/28/signing-servers-down-again/</link>
		<comments>http://www.slashdev.ca/2010/01/28/signing-servers-down-again/#comments</comments>
		<pubDate>Fri, 29 Jan 2010 03:29:54 +0000</pubDate>
		<dc:creator>jiGGaK</dc:creator>
				<category><![CDATA[BlackBerry]]></category>
		<category><![CDATA[Rants]]></category>

		<guid isPermaLink="false">http://www.slashdev.ca/?p=292</guid>
		<description><![CDATA[It&#8217;s 10:00pm EST, Jan. 28th and RIM&#8217;s signing servers have been down for the last sixty minutes. This wouldn&#8217;t be such an issue if the rest of the BlackBerry development tool suite wasn&#8217;t such a steaming pile of crap! Quite literally the only component that works &#8211; is the compiler. The simulator doesn&#8217;t sim and [...]]]></description>
			<content:encoded><![CDATA[<p>It&#8217;s 10:00pm EST, Jan. 28th and RIM&#8217;s signing servers have been down for the last sixty minutes. This wouldn&#8217;t be such an issue if the rest of the BlackBerry development tool suite wasn&#8217;t such a steaming pile of crap!  Quite literally the only component that works &#8211; is the compiler.</p>
<p>The simulator doesn&#8217;t sim and the signing tool doesn&#8217;t sign.  These two issues cause a serious problem.</p>
<p>First the simulator.  If you take an OS 4.3.1 simulator and a device also running OS 4.3.1 the two will behave very differently in a few subtle, but important ways.  My gripe is localized to the <a href="http://www.blackberry.com/developers/docs/4.3.0api/javax/microedition/media/package-frame.html">mmapi</a> api (handles audio/video playback).  Long story short, the simulator can&#8217;t be trusted so we have to debug device/OS idiosyncrasies on the device itself.</p>
<p>But hold on a second.  The signing servers aren&#8217;t working so I <strong>can&#8217;t</strong> debug on the device in all it&#8217;s developer friendly glory with lack of usable debugger and lack of even something as simple as a means to read text written to <strong>freaking</strong> <a href="http://en.wikipedia.org/wiki/Standard_output">standard output</a>!</p>
<p>Thank you RIM!  Thank you for wasting my valuable time.  Thank you for reminding me that no amount of money can justify writing software for this platform any longer.</p>
<p>(10:30, signing servers still not working)</p>
]]></content:encoded>
			<wfw:commentRss>http://www.slashdev.ca/2010/01/28/signing-servers-down-again/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>A Notch in the Cross Platform Blackberry Development Belt</title>
		<link>http://www.slashdev.ca/2009/03/11/a-notch-in-the-cross-platform-blackberry-development-belt/</link>
		<comments>http://www.slashdev.ca/2009/03/11/a-notch-in-the-cross-platform-blackberry-development-belt/#comments</comments>
		<pubDate>Wed, 11 Mar 2009 14:03:06 +0000</pubDate>
		<dc:creator>jiGGaK</dc:creator>
				<category><![CDATA[BlackBerry]]></category>
		<category><![CDATA[Linux]]></category>

		<guid isPermaLink="false">http://www.slashdev.ca/?p=212</guid>
		<description><![CDATA[In a previous post I listed 4 key items needed for BlackBerry development: Rapc compiler Signature tool Simulator Javaloader At the time of writing the first two worked fine. The third, Simulator, is if&#8217;y at best. And the fourth was just not possible. Until now. In late December, a saviour by the name of Nicolas [...]]]></description>
			<content:encoded><![CDATA[<p>In a <a href="http://www.slashdev.ca/2008/04/03/blackberry-development-using-linux/">previous post</a> I listed 4 key items needed for BlackBerry development:</p>
<ol>
<li>Rapc compiler</li>
<li>Signature tool</li>
<li>Simulator</li>
<li>Javaloader</li>
</ol>
<p>At the time of writing the first two worked fine.  The third, Simulator, is <a href="http://www.slashdev.ca/2008/03/27/blackberry-simulator-in-linux-sort-of">if&#8217;y at best</a>.  And the fourth was just not possible.</p>
<p>Until now.  In late December, a saviour by the name of Nicolas Vivien dropped by the <a href="http://www.netdirect.ca/software/packages/barry/">barry</a> mailing list to let everyone know that he was hard at work on reverse engineering the Javaloader USB protocol.  Within a few weeks he had developed a proof of concept that enabled users to load cod files to the BlackBerry.</p>
<p>Since then several developers (including myself) have chipped in to implement all of the crucial aspects of the Javaloader needed for day-to-day use.</p>
<p><span id="more-212"></span></p>
<h2>Which Commands are Supported?</h2>
<ul>
<li>list modules on handheld, including siblings</li>
<li>get handheld info</li>
<li>load one or more cod files onto the handheld</li>
<li>save one or more cod files from the handheld</li>
<li>erase cod files from the handheld</li>
<li>dump the eventlog</li>
<li>clear the eventlog</li>
<li>get screenshot of the handheld and save as bmp</li>
<li>set time on the handheld</li>
<li>wipe the applications and/or file system on the handheld</li>
</ul>
<p>As you can see, most of the important stuff is already finished.  And more is being added all the time.</p>
<h2>I&#8217;ve Heard Enough&#8230; Gimme, Gimme, Gimme!</h2>
<p>The Javaloader is slated to be included in the next release of Barry; version 0.15.  If you would like to test it right now, you&#8217;ll need to compile from source or find a binary package for your OS/distro.</p>
<p>Here are some instructions for <a href="http://www.netdirect.ca/software/packages/barry/cvs.php">compiling from source</a>.  If you get stuck, someone on the <a href="http://sourceforge.net/mail/?group_id=153722">mailing list</a> might be able to lend a hand.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.slashdev.ca/2009/03/11/a-notch-in-the-cross-platform-blackberry-development-belt/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>MenuItem Demystified</title>
		<link>http://www.slashdev.ca/2008/05/07/menuitem-demystified/</link>
		<comments>http://www.slashdev.ca/2008/05/07/menuitem-demystified/#comments</comments>
		<pubDate>Wed, 07 May 2008 22:44:37 +0000</pubDate>
		<dc:creator>jiGGaK</dc:creator>
				<category><![CDATA[BlackBerry]]></category>

		<guid isPermaLink="false">http://www.slashdev.ca/?p=130</guid>
		<description><![CDATA[I&#8217;ve always been a bit confused as to what exactly the parameters to the MenuItem constructor do. Common practise for me, and others I assume, is to simply ignore the ordinal and priority parameters and override the Screen.makeMenu method to explicitly define order. While this is effective, it has a few caveats: makeMenu gets messy [...]]]></description>
			<content:encoded><![CDATA[<p>I&#8217;ve always been a bit confused as to what exactly the parameters to the <a href="http://www.blackberry.com/developers/docs/4.2api/net/rim/device/api/ui/MenuItem.html#MenuItem(java.lang.String,%20int,%20int)">MenuItem</a> constructor do.  Common practise for me, and others I assume, is to simply ignore the ordinal and priority parameters and override the <a href="http://www.blackberry.com/developers/docs/4.2api/net/rim/device/api/ui/Screen.html#makeMenu(net.rim.device.api.ui.component.Menu,%20int)">Screen.makeMenu</a> method to explicitly define order.</p>
<p>While this is effective, it has a few caveats:</p>
<ul>
<li>makeMenu gets messy</li>
<li>separators must be added explicitly</li>
<li>doesn&#8217;t play nice with context menu items added by framework</li>
</ul>
<p><span id="more-130"></span></p>
<h1>Well what does the API say?</h1>
<p>The obvious first place to look is the API documentation right?  OK, lets have a look at the class description and constructor parameters.</p>
<p><em>Each item has an ordinal specifying the sort order within the menu, and a priority specifying which one should be the default. A lower value indicates a higher priority.</em></p>
<ul>
<li>ordinal &#8211; Ordering parameter, lower values are placed closer to the top of the menu screen.</li>
<li>priority &#8211; The priority of the menu item. A lower value indicates a higher priority, conversely a higher value indicates a lower priority.</li>
</ul>
<p>Ordinal seems pretty straight forward.  But what relation (if any) does this have to separator placement?  And what if I want my menu items be placed <strong>below</strong> the context menu items of the fields on the screen?  What should my ordinal value be then?</p>
<p>The priority from what I can tell just determines the likelihood the menu item will be picked as the default.  Lower values indication higher priority and higher values a lower priority.</p>
<h1>Verdict</h1>
<p>Here&#8217;s a summary first, because the details are rather dry (skip them if you like):</p>
<ul>
<li>ordinal values < 10,000 are placed above context items</li>
<li>ordinal values >= to 300,000 are placed below context items</li>
<li>ordinal values with a difference larger than 100,000 have separators between them</li>
<li>use priority values >= 1000 play nice with context item priorities</li>
</ul>
<p>Using a basic sample containing a couple fields and a <a href="http://www.blackberry.com/developers/docs/4.2api/net/rim/device/api/ui/MenuItem.html#getPrefab(int)">prefab</a> save menu item, I printed the ordinal ordinal and priority of each menu item in the menu generated by the MainScreen class (see source code at the end of the article).</p>
<p>Field context menu items have an ordinal somewhere in the neighbourhood of 10,000 to 200,000.  The prefab menu item for save has an ordinal around 300,000.  And based on the ordinal from the save menu item, it&#8217;s probably safe to assume that to place your menu items below context items, 300,000 is the magic number.</p>
<p>To have separators automagically placed between menu items, simply use an ordinal value at least 100,000 greater than the previous menu item.</p>
<p>Context menu items seem to have a priority value in the range of 100 to 500.  The prefab menu item has a priority of 1000 so I&#8217;m guessing this is an appropriate value for most menu items.</p>
<h1>MainScreen &#8211; Cause I&#8217;m Lazy</h1>
<p>The <a href="http://www.blackberry.com/developers/docs/4.2api/net/rim/device/api/ui/container/MainScreen.html">MainScreen</a> class has a method <a href="http://www.blackberry.com/developers/docs/4.2api/net/rim/device/api/ui/container/MainScreen.html#addMenuItem(net.rim.device.api.ui.MenuItem)">addMenuItem</a>. The documentation for this method reads:</p>
<p><em>A main screen brings up a menu by default when Screen.onMenu(int) is invoked. If the makeMenu(net.rim.device.api.ui.component.Menu, int) method is not overridden, it will add these menu items to the menu. The close menu item is added by default.</em></p>
<p>So as long as the ordinal and priority values are set appropriately, you don&#8217;t need to bother with the makeMenu method override at all!  Right?</p>
<p>Well there is one gotcha; MainScreen adds <strong>all</strong> all of the menu items to the menu.  If you need to omit items from the menu resulting from the trackball press, then you will have to add these items exclusively in the makeMenu method.</p>

<div class="wp_syntax"><div class="code"><pre class="java" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">public</span> MyScreen<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
   addMenuItem<span style="color: #009900;">&#40;</span>_saveMenuItem<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
   <span style="color: #666666; font-style: italic;">// makeMenu will handle adding this now</span>
   <span style="color: #666666; font-style: italic;">//addMenuItem(_deleteMenuItem);</span>
<span style="color: #009900;">&#125;</span>
&nbsp;
<span style="color: #000000; font-weight: bold;">protected</span> <span style="color: #000066; font-weight: bold;">void</span> makeMenu<span style="color: #009900;">&#40;</span><span style="color: #003399;">Menu</span> menu, <span style="color: #000066; font-weight: bold;">int</span> instance<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
   <span style="color: #000000; font-weight: bold;">super</span>.<span style="color: #006633;">makeMenu</span><span style="color: #009900;">&#40;</span>menu, instance<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
   <span style="color: #666666; font-style: italic;">// add delete menu item when NOT making context menu (trackball-click)</span>
   <span style="color: #000000; font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span> instance <span style="color: #339933;">!=</span> <span style="color: #003399;">Menu</span>.<span style="color: #006633;">INSTANCE_CONTEXT</span> <span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
      menu.<span style="color: #006633;">add</span><span style="color: #009900;">&#40;</span>_deleteMenuItem<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
   <span style="color: #009900;">&#125;</span>
<span style="color: #009900;">&#125;</span></pre></div></div>

<h1>Sample Code</h1>

<div class="wp_syntax"><div class="code"><pre class="java" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">net.rim.device.api.ui.MenuItem</span><span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">net.rim.device.api.ui.UiApplication</span><span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">net.rim.device.api.ui.component.EditField</span><span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">net.rim.device.api.ui.component.Menu</span><span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">net.rim.device.api.ui.component.ObjectChoiceField</span><span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">net.rim.device.api.ui.container.MainScreen</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000000; font-weight: bold;">class</span> Hello <span style="color: #000000; font-weight: bold;">extends</span> UiApplication <span style="color: #009900;">&#123;</span>
   <span style="color: #000000; font-weight: bold;">public</span> Hello<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
      MainScreen screen <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> MainScreen<span style="color: #009900;">&#40;</span>MainScreen.<span style="color: #006633;">DEFAULT_MENU</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
         <span style="color: #000000; font-weight: bold;">protected</span> <span style="color: #000066; font-weight: bold;">void</span> makeMenu<span style="color: #009900;">&#40;</span><span style="color: #003399;">Menu</span> menu, <span style="color: #000066; font-weight: bold;">int</span> instance<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
            <span style="color: #000000; font-weight: bold;">super</span>.<span style="color: #006633;">makeMenu</span><span style="color: #009900;">&#40;</span>menu, instance<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
            <span style="color: #000000; font-weight: bold;">for</span> <span style="color: #009900;">&#40;</span><span style="color: #000066; font-weight: bold;">int</span> i<span style="color: #339933;">=</span><span style="color: #cc66cc;">0</span>, len<span style="color: #339933;">=</span>menu.<span style="color: #006633;">getSize</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> i<span style="color: #339933;">&lt;</span>len<span style="color: #339933;">;</span> i<span style="color: #339933;">++</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
               <span style="color: #003399;">MenuItem</span> item <span style="color: #339933;">=</span> menu.<span style="color: #006633;">getItem</span><span style="color: #009900;">&#40;</span>i<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
               <span style="color: #003399;">System</span>.<span style="color: #006633;">out</span>.<span style="color: #006633;">println</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;DEBUG &quot;</span> <span style="color: #339933;">+</span> item.<span style="color: #006633;">getOrdinal</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">+</span>
                     <span style="color: #0000ff;">&quot; &quot;</span> <span style="color: #339933;">+</span> item.<span style="color: #006633;">getPriority</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">+</span> <span style="color: #0000ff;">&quot; &quot;</span> <span style="color: #339933;">+</span> item<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
            <span style="color: #009900;">&#125;</span>
         <span style="color: #009900;">&#125;</span>
      <span style="color: #009900;">&#125;</span><span style="color: #339933;">;</span>
&nbsp;
      screen.<span style="color: #006633;">addMenuItem</span><span style="color: #009900;">&#40;</span><span style="color: #003399;">MenuItem</span>.<span style="color: #006633;">getPrefab</span><span style="color: #009900;">&#40;</span><span style="color: #003399;">MenuItem</span>.<span style="color: #006633;">SAVE_CLOSE</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
      screen.<span style="color: #006633;">add</span><span style="color: #009900;">&#40;</span><span style="color: #000000; font-weight: bold;">new</span> EditField<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;Edit: &quot;</span>, <span style="color: #0000ff;">&quot;&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
      screen.<span style="color: #006633;">add</span><span style="color: #009900;">&#40;</span><span style="color: #000000; font-weight: bold;">new</span> ObjectChoiceField<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;Choice: &quot;</span>, <span style="color: #000000; font-weight: bold;">new</span> <span style="color: #003399;">Object</span><span style="color: #009900;">&#91;</span><span style="color: #009900;">&#93;</span> <span style="color: #009900;">&#123;</span><span style="color: #0000ff;">&quot;1&quot;</span>, <span style="color: #0000ff;">&quot;2&quot;</span><span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
      pushScreen<span style="color: #009900;">&#40;</span>screen<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
   <span style="color: #009900;">&#125;</span>
&nbsp;
   <span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000000; font-weight: bold;">static</span> <span style="color: #000066; font-weight: bold;">void</span> main<span style="color: #009900;">&#40;</span><span style="color: #003399;">String</span><span style="color: #009900;">&#91;</span><span style="color: #009900;">&#93;</span> args<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
      <span style="color: #000000; font-weight: bold;">new</span> Hello<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>.<span style="color: #006633;">enterEventDispatcher</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
   <span style="color: #009900;">&#125;</span>
<span style="color: #009900;">&#125;</span></pre></div></div>

]]></content:encoded>
			<wfw:commentRss>http://www.slashdev.ca/2008/05/07/menuitem-demystified/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>Simulator in Linux &#8211; Slightly More Reliable</title>
		<link>http://www.slashdev.ca/2008/04/10/simulator-in-linux-slightly-more-reliable/</link>
		<comments>http://www.slashdev.ca/2008/04/10/simulator-in-linux-slightly-more-reliable/#comments</comments>
		<pubDate>Fri, 11 Apr 2008 03:20:38 +0000</pubDate>
		<dc:creator>jiGGaK</dc:creator>
				<category><![CDATA[BlackBerry]]></category>
		<category><![CDATA[Linux]]></category>

		<guid isPermaLink="false">http://www.slashdev.ca/2008/04/10/simulator-in-linux-slightly-more-reliable/</guid>
		<description><![CDATA[Debug session with eclipse in Linux Disclaimer: I am not an expert with wine nor have I ever claimed to be. But if you setup an override for the msxml dll it seems as though the BlackBerry simulator is a bit more reliable in Linux. In fact, the JDWP seems to actually work for debugging [...]]]></description>
			<content:encoded><![CDATA[<div class="imageframe imgalignleft" style="width:300px;"><a href="http://www.slashdev.ca/wp-content/uploads/2008/04/debug-blackberry-linux.png" title="Debug session with eclipse in Linux"><img src="http://www.slashdev.ca/wp-content/uploads/2008/04/debug-blackberry-linux.thumbnail.png" width="300" height="187" alt="Debug session with eclipse in Linux" /></a>
<div class="imagecaption">Debug session with eclipse in Linux</div>
</div>
<p>Disclaimer: I am not an expert with <a href="http://www.winehq.org">wine</a> nor have I ever claimed to be.  But if you setup an override for the msxml dll it seems as though the BlackBerry simulator is a bit more reliable in Linux.  In fact, the JDWP seems to actually work for debugging  your applications.</p>
<p><br style="clear: both;"/><br />
<span id="more-124"></span></p>
<h1>Fix JDWP</h1>
<p>First you need to fix the JDWP.  I outlined the steps required to do this in my last article about <a href="/2008/03/27/blackberry-simulator-in-linux-sort-of">running the simulator in Linux</a>.</p>
<h1>DLL Overrides</h1>
<p>Copy the DLL files from a Windows box.  Again, I actually have no idea what I&#8217;m doing so I just went and copied all the DLL&#8217;s named <strong><tt>msxml*</tt></strong> from <tt>C:\WINDOWS\system32</tt> to my local wine directory <tt>~/.wine/drive_c/windows/system32</tt>.  It&#8217;s probably not necessary to copy all of them, but I don&#8217;t think it will hurt anything either.</p>
<p>Start up <tt>winecfg</tt> and select the <em>Libraries</em> tab.  Type <em>msxml3</em> in the <em>New override for library:</em> field and click Add.</p>
<div style="text-align: center;">
<div class="imageframe imgaligncenter" style="width:219px;"><a href="http://www.slashdev.ca/wp-content/uploads/2008/04/winecfg-linux.png" title="Winecfg with dll override"><img src="http://www.slashdev.ca/wp-content/uploads/2008/04/winecfg-linux.thumbnail.png" width="219" height="300" alt="Winecfg with dll override" /></a>
<div class="imagecaption">Winecfg with dll override</div>
</div>
</div>
<p>Start the JDWP and connect to it from your favorite IDE and watch the madness ensue.  Now I have not tested this thoroughly but my first couple of tries seem to work well.  So well in fact that I might event be able to ditch the VM running windows for debugging.  As always, <a href="http://en.wiktionary.org/wiki/your_mileage_may_vary">YMMV</a>.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.slashdev.ca/2008/04/10/simulator-in-linux-slightly-more-reliable/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>BlackBerry Development Using Linux</title>
		<link>http://www.slashdev.ca/2008/04/03/blackberry-development-using-linux/</link>
		<comments>http://www.slashdev.ca/2008/04/03/blackberry-development-using-linux/#comments</comments>
		<pubDate>Thu, 03 Apr 2008 23:43:54 +0000</pubDate>
		<dc:creator>jiGGaK</dc:creator>
				<category><![CDATA[BlackBerry]]></category>
		<category><![CDATA[Linux]]></category>

		<guid isPermaLink="false">http://www.slashdev.ca/2008/04/03/blackberry-development-using-linux/</guid>
		<description><![CDATA[Now this process isn&#8217;t 100% ideal. If you are an experienced developer you probably already know you need four key components. Rapc compiler Signature tool Simulator Javaloader The first two components works fabulously in Linux. The second (signature tool) needs a kick in the pants to work (shame shame shame!). The third is hit or [...]]]></description>
			<content:encoded><![CDATA[<p>Now this process isn&#8217;t 100% ideal.  If you are an experienced developer you probably already know you need four key components.</p>
<ol>
<li>Rapc compiler</li>
<li>Signature tool</li>
<li>Simulator</li>
<li>Javaloader</li>
</ol>
<p>The first two components works fabulously in Linux.  The second (signature tool) needs a <a href="/2008/03/16/using-sigtool-in-linux">kick in the pants</a> to work (shame shame shame!).</p>
<p>The third is <a href="/2008/03/27/blackberry-simulator-in-linux-sort-of">hit or miss</a> when using <a href="http://www.winehq.org/">Wine</a>.  So a less painful option is to put windows in a virtual machine and run the simulator there (more on that later).</p>
<p>And the fourth I just can&#8217;t get past.  There is the <a href="http://sourceforge.net/projects/barry">barry project</a> which has made impressive progress in the last few months and lists javaloader support as on the roadmap for milestone 4.  RIM, if you have any sympathy for us non-windows users show these guys some love and <a href="https://lists.sourceforge.net/lists/listinfo/barry-devel">send them</a> some specs for heaven sakes!</p>
<p>This article presents the basics for compiling, signing, and debugging BlackBerry applications with Linux.</p>
<p><span id="more-113"></span></p>
<h1>Rapc Compiler</h1>
<p>First you need a copy of the JDE or the JDE components package.  In my last <a href="/2008/03/27/blackberry-simulator-in-linux-sort-of">article</a> I covered a method of extracting the install packages distributed by RIM, but if you have access to a Windows box copying the installed JDE works just fine too.</p>
<p>The rapc compiler needs two external commands:</p>
<ol>
<li>Java Compiler (javac)</li>
<li>Preverification Tool (preverify)</li>
</ol>
<p>Install the Sun JDK to get javac:</p>
<p><code>sudo apt-get install sun-java5-jdk</code></p>
<p>The preverify command can be obtained by downloading the <a href="http://java.sun.com/products/sjwtoolkit/download.html">Sun WTK</a>.</p>
<p><code>chmod +x sun_java_wireless_toolkit-2_5_2-linux.bin<br />
./sun_java_wireless_toolkit-2_5_2-linux.bin<br />
</code></p>
<p>For some reason this package complains it can&#8217;t find Java interpreter.  If this happens, the Java 5 JDK is located <tt>/usr/lib/jvm/java-1.5.0-sun/bin</tt> on Ubuntu.</p>
<p>Once extracted, unless you plan on doing vanilla J2ME development, you can copy the preverify tool and then delete the WTK.</p>
<p><code>mkdir ~/bin<br />
cp ~/lib/WTK2.5.2/bin/preverify* ~/bin<br />
rm -r ~/lib/WTK2.5.2<br />
</code></p>
<p>Don&#8217;t forget to put the <tt>~/bin</tt> directory in the execution path.  To have this set automatically each time you login, put this line in your <tt>~/.bash_profile</tt> file (create it if necessary).</p>
<p><code>export PATH=~/bin:$PATH</code></p>
<h1>Compile &#8220;Hello, World!&#8221;</h1>
<p>I&#8217;ll be using <a href="http://ant.apache.org/">Apache Ant</a> for building because it&#8217;s the common denominator when it comes to building Java projects (like it or not).  Most IDE&#8217;s have some level of support for running ant scripts.</p>
<p>Install ant:</p>
<p><code>sudo apt-get install ant</code></p>
<p>Download <a href="http://sourceforge.net/project/showfiles.php?group_id=195339">bb ant tools</a> and put it where ant can find it:</p>
<p><code>unzip bb-ant-tools-0.7-bin.zip<br />
mkdir -p ~/.ant/lib<br />
cp bb-ant-tools.jar ~/.ant/lib<br />
</code></p>
<p>Download the <a href="/download/hello.tar.gz">hello world</a> project and run <tt>"ant"</tt> in the project directory:</p>
<p><code>wget http://www.slashdev.ca/download/hello.tar.gz<br />
tar -xzf hello.tar.gz<br />
cd hello<br />
ant<br />
</code></p>
<p>Output from the ant should look something like this:</p>
<pre class="console">
josh@ubuntu:~/hello$ ant
Buildfile: build.xml

build:
    [mkdir] Created dir: /home/josh/hello/build
     [rapc] Compiling 1 source files to ca_slashdev_hello.cod

BUILD SUCCESSFUL
Total time: 1 second
</pre>
<h1>Signing</h1>
<p>To sign your cod files, follow my guide on how to <a href="/2008/03/16/using-sigtool-in-linux">fix the signature tool</a>.  Then just run the <em>sign</em> target in the build script.</p>
<p><code>ant sign</code></p>
]]></content:encoded>
			<wfw:commentRss>http://www.slashdev.ca/2008/04/03/blackberry-development-using-linux/feed/</wfw:commentRss>
		<slash:comments>25</slash:comments>
		</item>
		<item>
		<title>MDS Simulator&#8230; in Linux</title>
		<link>http://www.slashdev.ca/2008/04/03/mds-simulator-in-linux/</link>
		<comments>http://www.slashdev.ca/2008/04/03/mds-simulator-in-linux/#comments</comments>
		<pubDate>Thu, 03 Apr 2008 17:42:49 +0000</pubDate>
		<dc:creator>jiGGaK</dc:creator>
				<category><![CDATA[BlackBerry]]></category>
		<category><![CDATA[Linux]]></category>

		<guid isPermaLink="false">http://www.slashdev.ca/2008/04/03/mds-simulator-in-linux/</guid>
		<description><![CDATA[This was actually pretty trivial since the MDS simulator is pure Java, and a good portion of it is actually just Tomcat. Since Tomcat is not developed by RIM, the chances where pretty good that there where no hard coded backslash directory separators (no, I will never let that go) MDS simulator log output All [...]]]></description>
			<content:encoded><![CDATA[<p>This was actually pretty trivial since the MDS simulator is pure Java, and a good portion of it is actually just <a href="http://tomcat.apache.org/">Tomcat</a>.  Since <a href="http://tomcat.apache.org/">Tomcat</a> is not developed by RIM, the chances where pretty good that there where no hard coded <a href="/2008/03/16/using-sigtool-in-linux">backslash directory separators</a> (no, I will never let that go) <img src='http://www.slashdev.ca/wp-includes/images/smilies/icon_wink.gif' alt=';)' class='wp-smiley' /> </p>
<div style="text-align: center;">
<div class="imageframe imgaligncenter" style="width:400px;"><a href="http://www.slashdev.ca/wp-content/uploads/2008/04/screenshot-jde43-mds-linux.png" title="MDS simulator log output"><img src="http://www.slashdev.ca/wp-content/uploads/2008/04/screenshot-jde43-mds-linux.thumbnail.png" width="400" height="184" alt="MDS simulator log output" /></a>
<div class="imagecaption">MDS simulator log output</div>
</div>
</div>
<p>All you have to do is create a new script to replace the various batch files that ship with the MDS simulator.  Here is the replacement for run.bat</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #666666; font-style: italic;">#!/bin/bash</span>
&nbsp;
<span style="color: #000000; font-weight: bold;">for</span> i <span style="color: #000000; font-weight: bold;">in</span> classpath<span style="color: #000000; font-weight: bold;">/*</span> webserver<span style="color: #000000; font-weight: bold;">/</span>lib<span style="color: #000000; font-weight: bold;">/*</span>; <span style="color: #000000; font-weight: bold;">do</span>
  <span style="color: #007800;">MDS_CP</span>=<span style="color: #007800;">$i</span>:<span style="color: #800000;">${MDS_CP}</span>
<span style="color: #000000; font-weight: bold;">done</span>
&nbsp;
java <span style="color: #660033;">-classpath</span> <span style="color: #800000;">${MDS_CP}</span> <span style="color: #660033;">-Xmx512M</span> -DKeystore.Password=password \
   net.rim.application.ipproxyservice.IPProxyServiceApplication \
   -log.console.dump</pre></div></div>

<p>Don&#8217;t forget to set the execute permission:<br />
<code>chmod +x run.sh</code></p>
<p>To shutdown MDS, just hit <tt>&lt;ctrl&gt;+c</tt> in the terminal window to kill the process.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.slashdev.ca/2008/04/03/mds-simulator-in-linux/feed/</wfw:commentRss>
		<slash:comments>6</slash:comments>
		</item>
		<item>
		<title>BlackBerry Simulator in Linux &#8211; Sort of</title>
		<link>http://www.slashdev.ca/2008/03/27/blackberry-simulator-in-linux-sort-of/</link>
		<comments>http://www.slashdev.ca/2008/03/27/blackberry-simulator-in-linux-sort-of/#comments</comments>
		<pubDate>Thu, 27 Mar 2008 20:57:14 +0000</pubDate>
		<dc:creator>jiGGaK</dc:creator>
				<category><![CDATA[BlackBerry]]></category>
		<category><![CDATA[Linux]]></category>

		<guid isPermaLink="false">http://www.slashdev.ca/2008/03/27/blackberry-simulator-in-linux-sort-of/</guid>
		<description><![CDATA[8800 Simulator in Wine/Linux Call me crazy but I just can&#8217;t seem to accept that if you want to (or have to) write BlackBerry software you&#8217;re stuck with Windows. It bugs me. There is good news and bad news regarding the simulator. The good news is with a recent version of Wine you can actually [...]]]></description>
			<content:encoded><![CDATA[<div class="imageframe imgalignleft" style="width:112px;"><a href="http://www.slashdev.ca/wp-content/uploads/2008/03/screenshot-blackberry-8800-simulator.png" title="8800 Simulator in Wine/Linux"><img src="http://www.slashdev.ca/wp-content/uploads/2008/03/screenshot-blackberry-8800-simulator.thumbnail.png" width="112" height="200" alt="8800 Simulator in Wine/Linux" /></a>
<div class="imagecaption">8800 Simulator in Wine/Linux</div>
</div>
<p>Call me crazy but I just can&#8217;t seem to accept that if you want to (or have to) write BlackBerry software you&#8217;re stuck with Windows.  It bugs me.</p>
<p>There is good news and bad news regarding the simulator.  The good news is with a recent version of <a href="http://www.winehq.org/">Wine</a> you can actually get the BlackBerry simulator to run.  The bad news is that it&#8217;s a bit buggy, and debugging hardly works at all.</p>
<p><br style="clear:both;" /><br />
<span id="more-109"></span></p>
<h1>What to expect</h1>
<p>Your millage may vary!  Generally I find that the simulator is usable for most testing.  Attaching a debugger to it (via JDWP) just seems to cause the simulator to hang.  Mind you, I have a rather slow system (AMD XP 2500+) and I would love to hear about your experiences if you have a faster computer.</p>
<h1>Ingredients</h1>
<p><a href="http://www.winehq.org/">Wine</a> &#8211; You need the most recent version you can get your hands on.  The package in the Ubuntu repository won&#8217;t due.  So if you have installed this one, remove it and follow <a href="http://www.winehq.org/site/download-deb">these</a> instructions to get the latest and greatest.</p>
<p>For some reason until I performed the following steps, the simulator would always crash on startup:</p>
<ol>
<li><tt>rm -rf ~/.wine</tt></li>
<li>Start up <tt>winecfg</tt></li>
<li><strong>Applications</strong> tab &#8211; select <em>Windows 2000</em> from the dropdown list</li>
<li><strong>Audio</strong> tab &#8211; select <em>ALSA Driver</em> from the drivers list</li>
</ol>
<p>It should go without saying that you will need a copy of the <a href="http://na.blackberry.com/eng/developers/downloads/jde.jsp">JDE</a> or one of the <a href="http://na.blackberry.com/eng/developers/downloads/simulators.jsp">simulator</a> packages.  If you have access to a Windows box, just zip up the JDE or simulator and copy over.  Otherwise, there are a few tricks to extracting the contents of the setup package.</p>
<p>Extract the setup package:<br />
<code>wine BlackBerry_JDE_4.2.1.exe /extract:c:\\</code></p>
<p>Which extracts the files to <tt>~/.wine/drive_c/</tt></p>
<p>Use msiexec to install the package:<br />
<code>wine msiexec /a c:\\jde_installer.msi /qn</code></p>
<p>Which extracts the file to <tt>~/.wine/drive_c/Program Files/Research In Motion/BlackBerry JDE 4.2.1</tt>. This is a cumbersome path at best so move this somewhere more usable:<br />
<code>mv ~/.wine/drive_c/Program Files/Research In Motion/BlackBerry JDE 4.2.1 ~/lib/JDE4.2.1</code></p>
<p>Cleanup:<br />
<code>rm ~/.wine/drive_c/jde_*</code></p>
<h1>Run the simulator</h1>
<p>I created a shell script from one of the existing batch files for launching:<br />
<code>cat 8800.bat | dos2unix > 8800.sh<br />
gvim 8800.sh<br />
</code></p>
<p>Replace the <tt>@echo off</tt> with <tt>#!/bin/bash</tt> and insert the wine command before the fledge.exe.  Mine looks like this:</p>
<pre>
#!/bin/bash
wine fledge.exe /app=Jvm.dll /handheld=8800 /session=8800 \\
/app-param=DisableRegistration /app-param=JvmAlxConfigFile:8800.xml \\
/data-port=0x4d44 /data-port=0x4d4e /pin=0x2100000A
</pre>
<p>Set the execute permission:<br />
<code>chmod +x 8800.sh</code></p>
<p>Now just run it!<br />
<code>./8800.sh</code></p>
<p>Don&#8217;t give up if the first time you run it the thing crashes.  Give it a few tries.</p>
<h1>Debugger</h1>
<p>So you fancy yourself an adventurer do ya!?!  Well, good luck.</p>
<p>Thankfully, RIM hasn&#8217;t made the same mistake with JDWP as they did with the <a href="/2008/03/16/using-sigtool-in-linux">signature tool</a> but you will still have to modify a number of text files to convert the Windows path names to Unix ones.</p>
<p><code>cd ~/lib/JDE4.2.1/bin</code><br />
<code>cp SimPackage-JDE.rc SimPackage-JDE.orig<br />
cat SimPackage-JDE.orig | sed 's/\(Command.*\)=%/\1=wine %/' | sed 's/\\/\//g' > SimPackage-JDE.rc<br />
</code><br />
<code>cp FixedBuild.rc FixedBuild.orig<br />
cat FixedBuild.orig | sed 's/\(Command.*\)=%/\1=wine %/' | sed 's/\\/\//g' > FixedBuild.rc<br />
</code><br />
<code>cp DefaultBuild.rc DefaultBuild.orig<br />
cat DefaultBuild.orig | sed 's/\\/\//g' > DefaultBuild.rc<br />
</code></p>
<p>If you copied the JDE from a Windows box you might need to update other files.  You must also <strong>remove</strong> Settings.rc if it already exists.</p>
<p>Make sure you have the Sun Java Runtime installed by running <tt>java -version</tt>.  Now all that&#8217;s left is to start up the JDWP:<br />
<code>java -jar JDWP.jar</code></p>
<p>On startup, there will be an error message about RIMUsbJni.dll but you can safely ignore this. And that&#8217;s just about it; your JDWP client connects as usual (jdb, eclipse, netbeans).  Feel free to leave your successes/failures in the comments.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.slashdev.ca/2008/03/27/blackberry-simulator-in-linux-sort-of/feed/</wfw:commentRss>
		<slash:comments>31</slash:comments>
		</item>
		<item>
		<title>Using sigtool in Linux</title>
		<link>http://www.slashdev.ca/2008/03/16/using-sigtool-in-linux/</link>
		<comments>http://www.slashdev.ca/2008/03/16/using-sigtool-in-linux/#comments</comments>
		<pubDate>Sun, 16 Mar 2008 20:37:42 +0000</pubDate>
		<dc:creator>jiGGaK</dc:creator>
				<category><![CDATA[BlackBerry]]></category>
		<category><![CDATA[Linux]]></category>

		<guid isPermaLink="false">http://www.slashdev.ca/2008/03/16/using-sigtool-in-linux/</guid>
		<description><![CDATA[Being obsessive and all, I decided to sit down and figure out why the signature tool doesn&#8217;t seem to work in Linux. After all it&#8217;s a rather trivial Java application. I suspected from the start that the symptom was some sloppy programming on RIM&#8217;s part, hard coding Windows style path names and my suspicion was [...]]]></description>
			<content:encoded><![CDATA[<p>Being obsessive and all, I decided to sit down and figure out why the signature tool doesn&#8217;t seem to work in Linux.  After all it&#8217;s a rather trivial Java application.  I suspected from the start that the symptom was some sloppy programming on RIM&#8217;s part, hard coding Windows style path names and my suspicion was correct.  After modifying two class files and reassembling SignatureTool.jar the signature tool worked like a charm!</p>
<p>I don&#8217;t know what the legality is regarding redistribution of RIM&#8217;s development tools, specifically ones that have been modified so what follows is a description of the steps required to modify SignatureTool.jar to work in a Unix style file system (forward slash for directory separators).</p>
<p><span id="more-102"></span></p>
<h2>Get SignatureTool.jar and extract it</h2>
<p>It goes without saying that you will need the Java Runtime installed before starting.  I would recommend the Sun JRE.  In Ubuntu, you can install this by running <code>sudo apt-get sun-java5-jre</code></p>
<p>Grab a copy of the SignatureTool.jar and put it somewhere along with your .csk and .db files.  I am using SignatureTool.jar from version 4.3 of the JDE.  The remainder of this guide might be specific to this version as I will be editing constants and referring to them by index numbers.<br />
<code>~/lib/RIM43/bin/SignatureTool.jar<br />
~/lib/RIM43/bin/sigtool.csk<br />
~/lib/RIM43/bin/sigtool.db<br />
</code></p>
<p>Extract the SignatureTool.jar file into a temporary directory:<br />
<code>cd ~/lib/RIM43/bin<br />
mkdir tmp<br />
jar -xf SignatureTool.jar -C tmp<br />
</code></p>
<h2>Editing the class files</h2>
<p>Now I tried using a hex editor and a decompiler but by far the easiest method was to use a program called <a href="http://classeditor.sourceforge.net/">ClassEditor</a> to modify the two files in question.  Download the <a href="http://downloads.sourceforge.net/classeditor/ce2.23.tar.gz?modtime=1079827200&#038;big_mirror=0">binary release</a> and extract it, and run it with the command:<br />
<code>java -jar ce.jar</code></p>
<p>Open two class files extracted earlier: <em>q.class</em> and <em>ad.class</em>.  ClassEditor will look something like this:</p>
<div style="text-align: center;">
<div class="imageframe imgaligncenter" style="width:200px;"><a href="http://www.slashdev.ca/wp-content/uploads/2008/03/screenshot-classeditor-0.png" title="screenshot-classeditor-0.png"><img src="http://www.slashdev.ca/wp-content/uploads/2008/03/screenshot-classeditor-0.thumbnail.png" width="200" height="150" alt="screenshot-classeditor-0.png" /></a>
<div class="imagecaption">ClassEditor with q.class and ad.class</div>
</div>
</div>
<p>Start with q.class and select the <strong>Constant Pool</strong> tab.  In this file we need to change string constants containing just a single backslash character.  There are actually two constants in the pool but the first is just a reference to the second.  The string we want is at index 223.</p>
<div style="text-align: center;">
<div class="imageframe imgaligncenter" style="width:200px;"><a href="http://www.slashdev.ca/wp-content/uploads/2008/03/screenshot-classeditor-1.png" title="screenshot-classeditor-1.png"><img src="http://www.slashdev.ca/wp-content/uploads/2008/03/screenshot-classeditor-1.thumbnail.png" width="200" height="150" alt="screenshot-classeditor-1.png" /></a>
<div class="imagecaption">String constant at index 223</div>
</div>
</div>
<p>By default ClassEditor starts in read only mode so click the bright green <strong>Modify Mode(Off)</strong> button in the top right.  The fields in the details area are now editable.  Simply change the forward slash to a backslash and click Modify.  Click save and that&#8217;s it for q.class!</p>
<div style="text-align: center;">
<div class="imageframe imgaligncenter" style="width:200px;"><a href="http://www.slashdev.ca/wp-content/uploads/2008/03/screenshot-classeditor-2.png" title="screenshot-classeditor-2.png"><img src="http://www.slashdev.ca/wp-content/uploads/2008/03/screenshot-classeditor-2.thumbnail.png" width="200" height="150" alt="screenshot-classeditor-2.png" /></a>
<div class="imagecaption">String constant 223 modified</div>
</div>
</div>
<p>Select ad.class on left and locate constant 117, again in the <strong>Constant Pool</strong> tab.</p>
<div style="text-align: center;">
<div class="imageframe imgaligncenter" style="width:200px;"><a href="http://www.slashdev.ca/wp-content/uploads/2008/03/screenshot-classeditor-3.png" title="screenshot-classeditor-3.png"><img src="http://www.slashdev.ca/wp-content/uploads/2008/03/screenshot-classeditor-3.thumbnail.png" width="200" height="150" alt="screenshot-classeditor-3.png" /></a>
<div class="imagecaption">String constant at index 117</div>
</div>
</div>
<p>Change the value from <strong>\sigtool.set</strong> to <strong>/sigtool.set</strong> and click Modify.  Click save and that&#8217;s it for ad.class.</p>
<div style="text-align: center;">
<div class="imageframe imgaligncenter" style="width:200px;"><a href="http://www.slashdev.ca/wp-content/uploads/2008/03/screenshot-classeditor-4.png" title="screenshot-classeditor-4.png"><img src="http://www.slashdev.ca/wp-content/uploads/2008/03/screenshot-classeditor-4.thumbnail.png" width="200" height="150" alt="screenshot-classeditor-4.png" /></a>
<div class="imagecaption">String constant 117 modified</div>
</div>
</div>
<h2>Repack SignatureTool.jar and test</h2>
<p>To repack SignatureTool.jar just cd to the temporary directory where you extracted the jar and rejar the class files<br />
<code>cd ~/lib/RIM43/bin/tmp<br />
jar -cmf META-INF/MANIFEST.MF ../SignatureTool.jar *<br />
</code></p>
<p>Go up one directory and remove the temp directory<br />
<code>cd ..<br />
rm -rf tmp<br />
</code></p>
<p>To test that everything worked, just run the command<br />
<code>java -jar SignatureTool.jar</code></p>
<p>If should prompt you to locate a cod file.  Just cancel this and click the Properties button in the main signature tool window.  If you see a list of Registered Signers it worked!</p>
<div style="text-align: center;">
<div class="imageframe imgaligncenter" style="width:200px;"><a href="http://www.slashdev.ca/wp-content/uploads/2008/03/screenshot-properties.png" title="screenshot-properties.png"><img src="http://www.slashdev.ca/wp-content/uploads/2008/03/screenshot-properties.thumbnail.png" width="200" height="181" alt="screenshot-properties.png" /></a>
<div class="imagecaption">Properties windows with registered signers</div>
</div>
</div>
<h2>RIM are you listening?</h2>
<p>At the off chance that someone from RIM is reading this, please forward this to whoever maintains this tool:</p>
<ul>
<li>Locate class containing the string &#8220;\sigtool.set&#8221;</li>
<li>Change to java.io.File.separator + &#8220;sigtool.set&#8221;</li>
<li>Locate class containing the strings &#8220;\\&#8221; + &#8220;sigtool.db&#8221;</li>
<li>Change to java.io.File.separator + &#8220;sigtool.db&#8221;</li>
<li>Locate class containing the strings &#8220;\\&#8221; + &#8220;sigtool.csk&#8221;</li>
<li>Change to java.io.File.separator + &#8220;sigtool.csk&#8221;</li>
</ul>
<p>Thanks!</p>
]]></content:encoded>
			<wfw:commentRss>http://www.slashdev.ca/2008/03/16/using-sigtool-in-linux/feed/</wfw:commentRss>
		<slash:comments>36</slash:comments>
		</item>
	</channel>
</rss>

