Archive for April 2009

Using Http library for the Palm OS

I was asked some time ago to look into the possibility of SSL communications with Palm OS phone based devices. The NetLib was already being used, but it did not have native support to communicate over SSL.

After a bit of searching, I decided to try to use the Http library that is provided on certain models of Palm OS devices (OS 5.x devices such as Centro, Treo, LifeDrive, and some Tungstens). The model was not an issue, as the customer was already using Treos, and the library seemed to have everything I needed to make a go of it.

The documentation seemed pretty thin on the Http library, about the only things I could find was some mention of the library in the PDF document Palm Developer Guide, Palm OS Platform Software and Hardware (Revision J, April 30, 2008), and an example program on using the library.

I downloaded the sample code provided by Palm, and with some small tests it seemed to work like gangbusters in both http and https mode. However, the first time I threw a real-world test at it, the code started erroring pretty quickly.

After much consternation, I finally tracked the problem down to the READ_CHUNK constant defined in the Peer.c file. By changing it to 32000 instead of 65535, it seemed to work much better.

The reason for this would appear to be that the READ_CHUNK constant is compared with and assigned to 32-bit integers, but this value is cast to a 16-bit integer when used in the NetLib calls, which was of course causing all sorts of wackiness.

Also, I quickly discovered that, since we were using a test SSL certificate, that the communications were failing early on in the initialization process. As a result, I had to set up a callback function that was used by HS_HTTPLibSetSSLServerCertConfirmProc. This callback in turn calls HS_HTTPLibServerCertConfirm and then just returns zero, which allows the invalid SSL certificate to be used.

iPhone application based on the “Utility Application” template and the “i” (info) button

So you have created an amazing iPhone application and based it on the Utility Application template in the iPhone SDK. This template gives you a main view and an alternate view that you can use for preferences or other information. This alternate view is seen by tapping on the info button (which is a round graphical “i”) ┬áin the bottom right corner of the main view.

The development is going like gangbusters, your application is looking real good. You have been developing and testing in the simulator and all is working fine.

But your world gets rocked when you put the application on an actual device. All of a sudden, no one can tap your “i” button, or it takes several tries to finally tap it to display the alternate view.

I feel your pain, as I found myself in the same exact situation.

Well I have found a solution. Apparently the bounding rectangle for the info button in the MainView.xib is pretty small, so I inserted the following code into the viewDidLoad method of RootViewController.m:

CGRect newInfoButtonRect = CGRectMake(infoButton.frame.origin.x - 20,
                            infoButton.frame.origin.y - 20,
                            infoButton.frame.size.width + 40,
                            infoButton.frame.size.height + 40);
[infoButton setFrame:newInfoButtonRect];

Now the info button works every single time.

But I cannot take the credit, here is the link that led me to this solution:

Problem with infoButton on Utility based app (link redacted)

Yet another software development blog

One thing that the internet doesn’t really need is a zillion and one software development blogs, one zillion software development blogs is just the right number.

However, I stumbled upon this Visual Basic .NET nugget at work one day and just couldn’t resist…

Private Function getCustomers() As Array
 
    'do something here
 
End Function

This blog is in honor of my discovery. Please stay tuned for lots more nuggets o’ gold, random thoughts, and sometimes maybe even problems I have run across and how they were solved.