//>>built define(["dijit","dojo","dojox","dojo/require!dojox/storage/manager,dojox/storage/Provider"],function(_1,_2,_3){ _2.provide("dojox.storage.AirDBStorageProvider"); _2.require("dojox.storage.manager"); _2.require("dojox.storage.Provider"); if(_2.isAIR){ (function(){ if(!_4){ var _4={}; } _4.File=window.runtime.flash.filesystem.File; _4.SQLConnection=window.runtime.flash.data.SQLConnection; _4.SQLStatement=window.runtime.flash.data.SQLStatement; _2.declare("dojox.storage.AirDBStorageProvider",[_3.storage.Provider],{DATABASE_FILE:"dojo.db",TABLE_NAME:"__DOJO_STORAGE",initialized:false,_db:null,initialize:function(){ this.initialized=false; try{ this._db=new _4.SQLConnection(); this._db.open(_4.File.applicationStorageDirectory.resolvePath(this.DATABASE_FILE)); this._sql("CREATE TABLE IF NOT EXISTS "+this.TABLE_NAME+"(namespace TEXT, key TEXT, value TEXT)"); this._sql("CREATE UNIQUE INDEX IF NOT EXISTS namespace_key_index ON "+this.TABLE_NAME+" (namespace, key)"); this.initialized=true; } catch(e){ } _3.storage.manager.loaded(); },_sql:function(_5,_6){ var _7=new _4.SQLStatement(); _7.sqlConnection=this._db; _7.text=_5; if(_6){ for(var _8 in _6){ _7.parameters[_8]=_6[_8]; } } _7.execute(); return _7.getResult(); },_beginTransaction:function(){ this._db.begin(); },_commitTransaction:function(){ this._db.commit(); },isAvailable:function(){ return true; },put:function(_9,_a,_b,_c){ if(this.isValidKey(_9)==false){ throw new Error("Invalid key given: "+_9); } _c=_c||this.DEFAULT_NAMESPACE; if(this.isValidKey(_c)==false){ throw new Error("Invalid namespace given: "+_c); } try{ this._sql("DELETE FROM "+this.TABLE_NAME+" WHERE namespace = :namespace AND key = :key",{":namespace":_c,":key":_9}); this._sql("INSERT INTO "+this.TABLE_NAME+" VALUES (:namespace, :key, :value)",{":namespace":_c,":key":_9,":value":_a}); } catch(e){ _b(this.FAILED,_9,e.toString()); return; } if(_b){ _b(this.SUCCESS,_9,null,_c); } },get:function(_d,_e){ if(this.isValidKey(_d)==false){ throw new Error("Invalid key given: "+_d); } _e=_e||this.DEFAULT_NAMESPACE; var _f=this._sql("SELECT * FROM "+this.TABLE_NAME+" WHERE namespace = :namespace AND key = :key",{":namespace":_e,":key":_d}); if(_f.data&&_f.data.length){ return _f.data[0].value; } return null; },getNamespaces:function(){ var _10=[this.DEFAULT_NAMESPACE]; var rs=this._sql("SELECT namespace FROM "+this.TABLE_NAME+" DESC GROUP BY namespace"); if(rs.data){ for(var i=0;i