Wednesday, 22 August 2012

Load External Scripts in PhoneGap for iPhone

To load external script files or to make calls to external hosts in a PhoneGap (Cordova) web application running on iOS devices, add a new property say Item 0 to the ExternalHosts with value * in the Phonegap.plist file.

Sunday, 19 August 2012

Closing Other Scratchbox Sessions

We can switch session in a scratchbox. If we get a message saying "You must close your other scratchbox sessions first", we can issue a killAll command to close the programs running on scratchbox.
sb-conf killall --signal=9 #9 or any other number
After that switch the session.

Install Maemo 5 SDK in Ubuntu

To develop native applications using C/C++ and GTK+ for Maemo, we need to install the Maemo 5 SDK and the development environment which include scratchbox, which is used for cross-compilation. The host environment here is Ubuntu 12.04 LTS 64bit. Scratchbox now supports 64bit platform.
1. First, we need to install scratchbox. For that add the scratchbox apt source url
deb hathor main
to /etc/apt/sources.list. We can use vim to do it or the following command.
sudo add-apt-repository "deb hathor main"
The above command will add deb-src link as well, which can be removed.
2. Update package list
sudo apt-get update
3. Install scratchbox and dependencies
sudo apt-get install scratchbox-core scratchbox-devkit-apt-https scratchbox-devkit-autotools-legacy scratchbox-devkit-debian-squeeze scratchbox-devkit-doctools scratchbox-devkit-git scratchbox-devkit-perl scratchbox-devkit-python-legacy scratchbox-devkit-qemu scratchbox-devkit-svn scratchbox-libs scratchbox-toolchain-cs2007q3-glibc2.5-arm7 scratchbox-toolchain-cs2007q3-glibc2.5-i486 scratchbox-toolchain-host-gcc
If dependency errors were encountered during installation, run the below command to auto resolve them
sudo apt-get install -f
4. Once scratchbox installation completes successfully, add the user to scratchbox.
sudo /scratchbox/sbin/sbox_adduser <yourUserName>
Logout and login. Now we will have a working scratchbox environment. We can test it by logging into scratchbox.
5. Download SDK setup script:
6. Since Hathor is based on Debian Squeeze, modify the install script to replace etch with squeeze.
sed -i -e 's/etch/squeeze/g'
7. Make the script executable and run it (as a normal user, outside scratchbox env).
chmod +x
8. In 'Package Selection' screen, choose "Runtime Environment + All Dev and Dbg packages" option. In 'Selection Summary' screen we will get
Installed Component: maemo-sdk-debug
x86 target name: FREMANTLE_X86
Armel target name: FREMANTLE_ARMEL
Overwrite existing targets: no
Proxy Server:
Alternative sources.list:
9. The SDK installation is not complete yet. After the successful completion of the above steps, we need to install Nokia-closed binaries for the target platform. To install Nokia binaries, we need to accept the EULA at the Nokia website.
10. Once we accept the EULA, we will get a token code and a source url with the token code to access the closed components of the SDK. The website says to not distribute or share the token code we get, and it is for personal use only.
The url will be of the format
deb fremantle/<theTokenCodeHere> nokia-binaries
11. Login to scratchbox.
12. Select target platform and install the closed binaries. First we will select ARM and then x86.
sb-conf select FREMANTLE_ARMEL
13. Add the source url obtained in step 10 to /etc/apt/sources.list in the scratchbox armel environment.
vim /etc/apt/sources.list  #and add the source url to the nokia binaries
14. Update the package's list.
apt-get update
15. Install the Nokia binaries.
fakeroot apt-get install nokia-binaries nokia-apps
16. Once the above installation completes, choose change the target env to x86 and install the binaries of the x86 platform as well.
sb-conf select FREMANTLE_X86
To install the binaries, repeat the above steps from 13 to 15. After installation logout of the scratchbox env.
With this the Maemo 5 SDK installation is complete and ready for development.
Happy Hacking!

Friday, 17 August 2012

Err: Dust.js - p.substr [undefined]

In android mobile browser, compiling a dust.js template caused the error "p.substr [undefined]". It worked fine in desktop browsers. The reason for the error was the closing of <input class="xyz" /> tag elements. Same in the case of img tag as well.
So writing the element like
<input type="hidden" name="someName" value="123">
<img src="pic.png" >
works fine.

Thursday, 9 August 2012

JQM: 'pageinit' & 'pagechange' Events

jQuery Mobile has many events associated with a page. Here we will discuss about the difference between 'pageinit' and 'pagechange' events. When a page is displayed for the first time 'pageinit' event will be fired. 'pagechange' event also fires here and for every page change. When we move from say page1 to page2 where page2 was not displayed before, 'pageinit' event will be fired. 'pagechange' event will also get fired since we changed the page from page1 to page2.

When we move from page2 to page1, where page1 was displayed previously, only 'pagechange' will be fired.