Last time we hacked up one of the built-in Palm webOS applications. Nothing very serious mind you, we simply changed the title of the Calculator application and ran it in the emulator to demonstrate our skills. That was simple and fun, so perhaps now you are intrigued by the webOS and might like to write your own application but perhaps wondering if:
A) you should bother?
B) just where to start?
Let’s address the first question: should you bother writing an application for Pre? Well, iPhone and BlackBerry are the market-share kings with Android poised for a strong Q3 as new devices are on the near horizon, so where is the opportunity with Pre? Does it have a chance? Well, the Palm Pre is a new device with a very small but growing market-share, and Palm has just introduced their second device, the Pixi. It is a “cute” device — it looks like a cross between the Pre, a BlackBerry and a Palm Centro on slim-fast. It is supposed to be aimed at a younger crowd that is interested in text messaging. Probably a smart move as texting (and other less edifying uses of phone-cameras…) is a dominant mobile application, and certainly so in the younger market demographic segments. Palm has released this device in time to be on the early side of holiday shopping — yes, the holiday season is just around the corner! The Palm webOS App Store is sparsely populated, but I think it is actually a good thing because an app doesn’t get lost there like in other app stores. If you have a good application idea, you’ve got a great chance for it to be seen by Palm Pre owners perusing the App Catalog. Big fish in a small(er) pond and all that. So, if you’re with me and interested in writing an app for webOS, welcome to the club!
Now, to the second question, where to start? You will want to start by registering as a developer at http://developer.palm.com. Download and install the latest SDK including Sun’s Virtual Box, Eclipse and all the trimmings you can read about on Palm’s site. Then you’ll peruse the online docs and getting started guides. You might try building the HelloWorld application or cruising through the sample code shipped with the SDK. All good things to do. But then comes the wall. You know there is something more that you want to know about the OS but the docs just don’t go broadly enough and they certainly don’t go deep enough. Not yet anyway. In time they will no doubt flesh out and become more valuable to developers, but for now we’ve got to come up with something else because we don’t know what we don’t know. Welcome to the bleeding edge.
We are going to work with the Emulator found in the Palm SDK. Before we proceed, make sure you’ve got the Palm SDK installed and you are able to run the Emulator. For our purposes here you will not need Eclipse but it is a good idea to get Eclipse and the webOS plug-in for Eclipse installed and operational. We’ll be using it in future articles. Here is a shot of the emultor running on my development laptop:
With the emulator running, we need to connect with an ssh client. Linux and MacOSX clients have a built-in ssh client. For Windows users, run the program named putty.exe which is found in the /bin sub-directory of the Palm SDK folder. On my machine it is found in c:\program files\palm\sdk\bin. Connect to at port 5522. Sign in as user root and just hit enter when prompted for a password:
Cool, we’ve found a js file which knows something about the appinfo.json file — the file is named framework.js. And here’s something new — there is a property of the “Mojo” class named appPath. I bet that is the full name to the application’s directory. We can find out by adding this line to one of our application’s source files:
Mojo.Log.info("Mojo.appPath is [" + Mojo.appPath + "]");
Continuing to sift through this file I found what I needed: Mojo.appInfo.version.
Yeah, but I don’t do vi and grep!
OK, so you’re not looking to live in the ssh emulator world? No problem, let’s bring those files back to the desktop of choice and we can look at them in notepad, print them out, try to load them into Safari/webkit or whatever other fun thing we might like to do. Before we get too excited with what we’ll do with the files on the desktop we’ve got to get them there to begin with. There may be other ways of accomplishing this task, but I’ll show you what I came up with. The first thing we want to do is zip up the files. We’re going to need to do this in few steps.
Now that we have our files compressed and ready for travel, we need to get the archive file to our desktop machine. Perhaps there is an ftp client lurking somewhere on the emulator. I didn’t find it, so we’re going to use the Secure Copy program, scp. This basically uses a protocol similar to SSH to copy a file securely. Here is the syntax I used to push the file to a Mac on my network:
You should be able to exercise this on any machine which has a secure shell server. Use your own credentials of course. If I knew more about scp I would share it with you — the short version is it works so give it a try. From here you can unzip the webos.tar.gz file with WinZip or with gunzip.
To extract the tar file, use tar -xf webos.tar. Be careful to not do this on your emulator — you don’t want to mess with your installation! WinZip on WinRAR will magically take care of all of this for you on Windows. From here you can run whatever kind of “Find in Files” search you might like.
I have found it helpful to poke around the files and then test something out by just printing it to the log with a call to Mojo.Log.info(). Of course, we now need to know where that shows up, so let’s take a quick look at how you see the log on webOS.
There are (at least) three ways to see logging statements made from our application.
From your ssh session, tail the file /var/log/messages. This will show messages from your applicaiton along with many other messages that may be confusing if you’re trying to pick up only your application.
tail -f /var/log/messages
From your ssh session, type log . This will “tail” the log and filter to only show you messages relevant for your application.
Set up our application for Debugging and run the Palm Inspector found in the SDK. Be sure to check the box “Inspectable” in the Run Configuration as seen below:
Until a new version of webOS documentation becomes available, enjoy your home-brew documentation. Be sure to keep your “documentation” up to date as you update the SDK. Happy Hacking — and see you at the App Store!
Fatal error: Call to undefined function aa_author_bios() in /opt/apache/dms/b2b/linux-mag.com/site/www/htdocs/wp-content/themes/linuxmag/single.php on line 62