Ramblings on Technology, Gaming, and Life in General

Menu

Programming via clever hack

I picked up an HP Touchpad shortly after the firesale back in 2011, and have been using it as my daily driver ever since – I even picked up a Pre 3 a little later to replace my aging iPhone 4. Suffice it to say, I’m a big fan of the webOS operating system, even though it’s been a while since it was updated.

Of course, with no new hardware on the horizon, and no official updates coming down the pipe for these devices, (although LG is still working hard on developing Open webOS), developers have left for greener pastures, and apps and services have slowly stopped working. One of the main things that I use my devices for is consuming RSS feeds. Until it was shut down, I used Google reader, and one of the best Google Reader apps for webOS: Feeder. After it shut down, we were kind of in a bind, as many Google Reader alternatives sprang up, but no apps supported them, and the developer had left for greener pastures.

So, as a developer, what am I to do but roll my own? Fortunately, Feeder had been open sourced when the developer finished with it, so I forked it and have been working on “FeedSpider” ever since, adding support for The Old Reader and InoReader. But that’s not the clever hack. Both applications cloned the Google Reader API (mostly) and allowed support for simple authentication using ajax calls, so adding support was pretty easy.

Where the clever hack comes in is when dealing with Feedly. Feedly is the largest of the Google Reader successors, and just opened their API up to the public fairly recently. What makes this challenging is that Feedly uses OAuth for authentication, which webOS does not support very well. Fortunately, somebody else already came up with a clever hack for that, which, in short, captures the OAuth authorization code from the browser when it redirects to redirect uri and allows the app to use it. The library mostly works for Feedly, but not quite.

My contribution to the clever hacks list is two-fold. There is a bug in webOS on tablets that causes it not to pop up the keyboard when using a webview inside an app. (Works fine on phones, and I need to use this method to keep support for old devices) that I had to hack around by manually causing the keyboard to pop up then you go to the Twitter, WordPress and Google OAuth providers. I did that by watching for the urlChanged event and acting accordingly.

The more interesting part of the hack was that Feedly forces you to register your redirect URI with them, and will only let you use the one that you registered. Since I’m currently in sandbox mode, they gave me two options, http://localhost, or urn:ietf:wg:oauth:2.0:oob. Localhost won’t work on a webOS device. The browser will just time out. It never actually tries to do the redirect in a way such that I can catch it. The other one will try to do the redirect, but, it generates a “MIME type not supported error.” Here’s the fun bit – this raises a “Mojo.Event.webViewMimeNotSupported” event, which returns the URL that it is trying to redirect to. So, I catch the event, feed it to the filter and get the OAuth code, allowing me to log in, and we’re in business! (Yes this means that I am making good progress on Feedly support and hope to deliver it as a Christmas gift).

This is one of the fun parts for developing for poorly supported operating systems – there’s always a clever hack that will let you do what you want to do, even if the path is a little roundabout at times.