Wednesday, April 16, 2008

Desktop API for Desktop icons

Few days back I tried the Desktop api of Gears. Its really cool option to access the applications by selecting desktop short cuts.

You could use "createShortcut" method and when you invoke it, a dialog will be prompted for user's permission. Once the download is successful, a folder "icons#desktop" will be created. To know about the file locations, refer url.

Initially I tried using icons of size 132x27 & 18x18, but got some error message. However when I tried downloading the icons of size 16x16 and 32x32, I was successful. Not sure if there was any issue with size or the icon itself.

Refer API:
http://code.google.com/apis /gears/upcoming/api_desktop .html

Sunday, April 6, 2008

Google Gears recent news:

Google Docs has introduced offline support for a small percentage of users and will make it available for all users in due course. As of now the offline support is only for Google Docs.

http://googledocs.blogspot.com/2008/03/bringing-cloud-with-you.html

You might be aware that Zoho Writer uses Gears for offline functionality.

On related notes refer an interesting post on online applications:

http://blogs.zoho.com/general/standardization-maturity-of-online-suites/

Picasa Web Albums could be viewed in Windows Mobile touchscreen devices and uses Gears for offline support.

http://googlephotos.blogspot.com/2008/03/more-good-news-for-mobile.html

You might be aware that my previous post was on launch of Gears for Windows Mobile with Zoho Writer and Buxfer applications.

Sunday, March 9, 2008

Gears on Mobile

On seeing the title if you think am going to discuss about shifting Gears in automobiles then am sorry!! Its about Google Gears support for Windows Mobile (WinMo) devices. If you have any web application that works in Windows Mobile, then you could look at the latest release of Google Gears for offline support. The current release supports Windows Mobile 5 & 6.

During the Gears for Mobile launch, two web applications have used Google Gears for their offline support.

Zoho Writer: An online word processor extended offline support for their Windows Mobile edition. To access the mobile version visit: http://mobile.zoho.com. The desktop/laptop (computer) version of Writer is available at http://writer.zoho.com.

Buxfer: A personal finance web application visit http://m.buxfer.com

There is no change in API for desktop and Mobile edtions. However if you are using old gears_init.js then you may have update with the latest one available @ http://code.google.com/apis/gears/gears_init.js

Fore more details:

http://googlemobile.blogspot.com/2008/03/shifting-google-gears-to-mobile.html
http://google-code-updates.blogspot.com/2008/03/power-up-your-mobile-web-applications.html
http://code.google.com/apis/gears/mobile.html

Google Gears API: ResourceStore Module

In this post you will find code snippet for ResourceStore of LocalServer Module.

function localserver()
{
var localserver = google.gears.factory.create('beta.localserver', '1.0');
var store = localserver.createStore('mystore');
store = localserver.openStore('mystore');
var files=['/images/myimage.gif']
var captureId=store.capture(files,callback);
}
function callback()
{
alert('files are captured');
}


Ensure that you have the gears_init.js file to use above methods. For other methods refer:

http://code.google.com/apis/gears/api_localserver.html
http://code.google.com/apis/gears/api_localserver.html#ResourceStore

Sunday, February 24, 2008

Google Gears API: LocalServer Module

Following my last post about Google Gears Database Module , here comes the LocalServer module.

LocalServer module allows you to store the HTTP resources locally. The resources could be images, html pages, css, JS files etc. For more details refer my post on Gears Modules.

There are two options in LocalServer to store the files:

1. ManagedResourceStore: The resources are cached based on a manifest file. Set of URLs of the resources has to mentioned in a manifest file with a version number of the manifest file. When ever the resource is modified, you need to change the version number specified in the manifest file. Gears will take care of updating the local store (resources stored locally) with the new version. This option is more handy when the resources are almost static or occasionally modified, and thus avoiding downloading the resources every time you go offline/online.

Note: You might have an array of resources of which only few might have been modified. Gears will download only the modified resource.

2. ResourceStore: Alternately you can store the resources through API (method calls) at will, using methods like capture(), copy(), remove() etc.

Well, selecting the option is purely based on the requirement and the type of resource. If the resource is almost static, then you could use the ManagedResourceStore option, however there are resources associated with UI themes which changes based on user's current settings, that could be captured using ResourceStore.

Fore more details refer: http://code.google.com/apis/gears/api_localserver.html

In my next post I'll explain ResourceStore module with sample code.

Friday, February 22, 2008

Google Gears New version 0.2 is now available

Gears team have released 0.2 version of Google Gears. For more details refer:
http://gearsblog.blogspot.com/2008/02/gears-02-released.html
http://gears.google.com/

Saturday, February 2, 2008

Google Gears API: Database Module

My last post was on initializing the Google Gears API which is indeed the first step to use the Gears API. Next comes the use of different modules. In this post I'll illustrate the usage of Database Module.

All the Gears Module has to be instantiated by using Gears Factory's create method. For more details refer below url:

http://code.google.com/apis/gears/api_factory.html

Also have a look at getBuildInfo() method, to get the Gears build info.You will get some thing like this - 0. 2.14.0;official;opt;linux;firefox

As explained in my Modules of Google Gears post, the Database module uses SQLLite database.

Here are few methods that could be useful. Ensure that you have followed the initialization steps.


function dbtest()
{
var db = google.gears.factory.create('beta.database', '1.0');
if(db)
{
db.open('dbtest');
db.execute('create table if not exists testtab (id int,name text)');
db.execute('insert into testtab values (?,?)' ,[1,'srikanth']);
var rs = db.execute('select id,name from testtab where id=(?)',[1]);
while(rs.isValidRow())
{
alert(rs.field(0) + ':' + rs.field(1));
rs.next();
}
rs.close();
db.execute('update testtab set name = (?) where id=(?)',['srikanthramu',1]);
rs=db.execute('select name from testtab where id=(?)',[1]);
while(rs.isValidRow())
{
alert(rs.fieldName(0)+':'+rs.field(0));
rs.next();
}
rs.close();//It is important to close the resultset before database object
db.close();
}
}


Refer below url for database module methods:
http://code.google.com/apis/gears/api_database.html

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.