Friday, January 25, 2008

Google Gears API: Initialization

After installing Google Gears you can start using the Gears API. The first step would be the initialization of Gears, done using gears_init.js file. This file has an anonymous function call that creates a GearsFactory() object based on the browser. Google strongly recommends the initialization using gears_init.js file. Developers can use "google.gears" and "window.google" to check whether Gears is installed and properly initialized.

Refer below url for more details:
http://code.google.com/apis/gears/design.html#detecting

The anonymous function will be called when gears_init.js file is loaded directly using a script tag. Due to this when a page that loads gears_init.js file is accessed in IE7, below message will be popedup:

"This website wants to run the following add-on: 'gears.dll' from 'Google Inc ......."

However you could avoid this by encapsulating the initialization block with in a named function.

Monday, January 14, 2008

Dojo Offline Tookit

Dojo Offline Toolkit (DOT) was ahead of Google in releasing a small download to enable web applications to work offline.

Initially DOT provided a web proxy that will be running in your machine. The UI resources will be cached locally by the proxy server. And to store the data DOT had 3 storage options: 1) Flash storage 2) SQLLite storage 3) File Storage provider.

Apart from the storage/cache options Dojo Offline Toolkit offered few utilities like: Dojo Offline Widgets (offline UI), Options to check the network availability etc.

Subsequent to the release of Google Gears, DOT was quick to move over Gears. You could find some interesting stuffs like Encrypt/Decrypt options, function to scan a page and identify the resources for offline etc.

For more details visit: http://dojotoolkit.org/offline

Saturday, January 12, 2008

Web application in offline mode

Why Offline Mode ? Well, read below:

Need: With more and more applications moving away from desktops, towards the web/internet and with the concepts like SAS (Software As Service), collaborative mode etc gaining significance, we are more dependent on the internet. Expecting all time (even while traveling) network connectivity in all places (like rural area) might be too optimistic thought. To bridge this gap web application vendors are forced to enable their web applications to work offline i.e with out being connected to the internet.

Solution: I could think of 2 ways to provide offline support to a web application.

  1. Providing a downloadable version of the application, so that users can install it in their machine and work locally. When required they can sync the local version with the online version.
    • Pros:
      • Almost all the features can be supported in the offline mode
      • Probably less code change required for an existing application. You might have to work only on the syncing aspect.
    • Cons:
      • The downloadable size could be more
      • More hard disk space is required
      • Product upgrading could be cumbersome
  2. Offline support through some kind of caching support through browser extension, proxy server etc
    • Pros:
      • Light weight component could be downloaded thus reducing the hard disk usage
      • New release/feature upgrading could be easy
    • Cons:
      • You might have to compromise on the features offered in the offline mode when compared to the online version

In my subsequent posts I would explain the second option with open source solutions like Dojo Offline toolkit and Google Gears.

Friday, January 11, 2008

Security Dialog

When ever Gear APIs are accessed by a web application, a security dialog is prompted, you could Allow/Deny.

To check the Allowed/Denied sites invoke Tools->Google Gears Settings.

Thursday, January 10, 2008

Installing/Uninstalling Google Gears:

Visit: http://gears.google.com/ page, download and install the GoogleGearsSetup.exe file. Ensure that you are connected to the internet during installation. Once installed RESTART the browser to use the Gears. To check whether Gears is installed invoke Tools -> Gears Gears Settings.

The current Gears version is 0.1.54.0

System Requirements:

Browser: IE 6+ and FF 1.5+. As on date FF3.0 beta is not supported, refer this forum post.

OS: Linux, Mac, Windows XP/Vista. Though Windows 2000 is not mentioned in the supported list, I tired installing Gears and was successful too. May be you can try in your environment.

For any issues during installation you could follow some useful threads from Gears forums (especially the sticky posts with error codes).

To uninstall refer http://code.google.com/apis/gears/install.html

Monday, January 7, 2008

Modules of Google Gears

When you think of offline (not connected to the network) support to web applications, you need to operate on the data/resources stored locally. Any developer who wants to provide offline capability to their applications needs to understand the Google Gears Modules, I've explained below the Gears modules based on the contents stored locally.

HTTP resources: These are mostly client/UI contents like HTML pages, css files, images, javascripts etc. Local Server Module (LSM) offers storing these resources locally. When HTTP requests are made, the browser checks if these resources are available locally, if so the local copy will be served, if not the browser will try to access the online resources. Application developers have to use the APIs in LSM to update the stored contents when they are modified in the online version.

Application/User specific data: Data varies from application to application i.e: Editor application has documents, Mail apps has messages/drafts, Feed Reader has feeds, news etc. Database Module (DM) offers SQLLite database system to store the data. You could open a database, create tables and perform CRUD (Create, Retrieve, Update and Delete) operations. Unlike LSM, DM does not have API to sync the modified data to the online version. Application developers have to take care of it.

Apart from the above two modules, there is WorkerPool Module to execute your javascript code in a separate processes.

Location of the locally stored resources/data through LSM and DM:

Fire Fox:

Linux:
/home/[username]/.mozilla/firefox/[.default]/Google Gears for Firefox/[website]/http_8080

Mac:
/Users/administrator/Library/Caches/Firefox/Profiles/[.default]/Google Gears for Firefox/[website]/http_80

Windows XP:
C:\Documents and Settings\[user]\Local Settings\Application Data\Mozilla\Firefox\Profiles\[.default]\Google Gears for Firefox\[website]\http_8080

Windows Vista:
C:\Users\[user]\AppData\Local\Mozilla\Firefox\Profiles\[.default]\Google Gears for Firefox\[website]\http_80

IE:

Windows XP:
C:\Documents and Settings\[user]\Local Settings\Application Data\Google\Google Gears for Internet Explorer\[
website]\http_8080

Windows Vista:
C:\Users\[usr]\AppData\LocalLow\Google\Google Gears for Internet Explorer\[
website]\http_80

For more details visit: http://code.google.com/apis/gears/

Friday, January 4, 2008

Welcome to GGears!!

Google Gears a browser extension, enables web apps to work offline. Does that sound innovative!! PC World found so. I've been using Gears for quite some time would like to share news, views, samples etc about Gears. Hope you find this interesting.

Have a great day.