Example usage for com.google.gwt.gears.client Factory getPermission

List of usage examples for com.google.gwt.gears.client Factory getPermission

Introduction

In this page you can find the example usage for com.google.gwt.gears.client Factory getPermission.

Prototype

public native boolean getPermission() ;

Source Link

Document

Lets a site manually trigger the Gears security dialog, without UI customizations.

Usage

From source file:de.lilawelt.zmachine.client.storage.GearsAdapterReal.java

License:Open Source License

public boolean Initialize() throws StorageException {
    if (initialized)
        return true;

    Factory f = Factory.getInstance();
    if (f == null)
        throw new StorageException("Gears could not be initialized");

    if ((!f.hasPermission()) && (!f.getPermission()))
        throw new StorageException("Sorry, this site may not access your gears installation");

    Log.debug("Trying gears init...");

    // Create the database if it doesn't exist.
    try {// ww w .  j  ava2 s . com
        db = f.createDatabase();
        db.open("textadventure-saves");
        // The 'int' type will store up to 8 byte ints depending on the magnitude of the 
        // value added.
        db.execute(
                "create table if not exists saves (savename text, gameuid text, savedate date, savedata blob)");
    } catch (GearsException e) {
        throw new StorageException(
                "Sorry, an error was encountered while initializing gears: " + e.getMessage());
    }

    Log.debug("Dine with gears init");

    initialized = true;
    return true;
}