Subversion Repositories Applications.papyrus

Rev

Rev 1318 | Details | Compare with Previous | Last modification | View Log | RSS feed

Rev Author Line No. Line
1318 alexandre_ 1
/*
2
	Copyright (c) 2004-2006, The Dojo Foundation
3
	All Rights Reserved.
4
 
5
	Licensed under the Academic Free License version 2.1 or above OR the
6
	modified BSD license. For more information on Dojo licensing, see:
7
 
8
		http://dojotoolkit.org/community/licensing.shtml
9
*/
10
 
1422 alexandre_ 11
 
12
 
1318 alexandre_ 13
dojo.provide("dojo.storage");
14
dojo.require("dojo.lang.*");
15
dojo.require("dojo.event.*");
16
dojo.storage = new function () {
17
};
18
dojo.declare("dojo.storage", null, {SUCCESS:"success", FAILED:"failed", PENDING:"pending", SIZE_NOT_AVAILABLE:"Size not available", SIZE_NO_LIMIT:"No size limit", namespace:"default", onHideSettingsUI:null, initialize:function () {
19
	dojo.unimplemented("dojo.storage.initialize");
20
}, isAvailable:function () {
21
	dojo.unimplemented("dojo.storage.isAvailable");
22
}, put:function (key, value, resultsHandler) {
23
	dojo.unimplemented("dojo.storage.put");
24
}, get:function (key) {
25
	dojo.unimplemented("dojo.storage.get");
26
}, hasKey:function (key) {
27
	return (this.get(key) != null);
28
}, getKeys:function () {
29
	dojo.unimplemented("dojo.storage.getKeys");
30
}, clear:function () {
31
	dojo.unimplemented("dojo.storage.clear");
32
}, remove:function (key) {
33
	dojo.unimplemented("dojo.storage.remove");
34
}, isPermanent:function () {
35
	dojo.unimplemented("dojo.storage.isPermanent");
36
}, getMaximumSize:function () {
37
	dojo.unimplemented("dojo.storage.getMaximumSize");
38
}, hasSettingsUI:function () {
39
	return false;
40
}, showSettingsUI:function () {
41
	dojo.unimplemented("dojo.storage.showSettingsUI");
42
}, hideSettingsUI:function () {
43
	dojo.unimplemented("dojo.storage.hideSettingsUI");
44
}, getType:function () {
45
	dojo.unimplemented("dojo.storage.getType");
46
}, isValidKey:function (keyName) {
47
	if ((keyName == null) || (typeof keyName == "undefined")) {
48
		return false;
49
	}
50
	return /^[0-9A-Za-z_]*$/.test(keyName);
51
}});
52
dojo.storage.manager = new function () {
53
	this.currentProvider = null;
54
	this.available = false;
55
	this._initialized = false;
56
	this._providers = [];
57
	this.namespace = "default";
58
	this.initialize = function () {
59
		this.autodetect();
60
	};
61
	this.register = function (name, instance) {
62
		this._providers[this._providers.length] = instance;
63
		this._providers[name] = instance;
64
	};
65
	this.setProvider = function (storageClass) {
66
	};
67
	this.autodetect = function () {
68
		if (this._initialized == true) {
69
			return;
70
		}
71
		var providerToUse = null;
72
		for (var i = 0; i < this._providers.length; i++) {
73
			providerToUse = this._providers[i];
74
			if (dojo.lang.isUndefined(djConfig["forceStorageProvider"]) == false && providerToUse.getType() == djConfig["forceStorageProvider"]) {
75
				providerToUse.isAvailable();
76
				break;
77
			} else {
78
				if (dojo.lang.isUndefined(djConfig["forceStorageProvider"]) == true && providerToUse.isAvailable()) {
79
					break;
80
				}
81
			}
82
		}
83
		if (providerToUse == null) {
84
			this._initialized = true;
85
			this.available = false;
86
			this.currentProvider = null;
87
			dojo.raise("No storage provider found for this platform");
88
		}
89
		this.currentProvider = providerToUse;
90
		for (var i in providerToUse) {
91
			dojo.storage[i] = providerToUse[i];
92
		}
93
		dojo.storage.manager = this;
94
		dojo.storage.initialize();
95
		this._initialized = true;
96
		this.available = true;
97
	};
98
	this.isAvailable = function () {
99
		return this.available;
100
	};
101
	this.isInitialized = function () {
102
		if (this.currentProvider.getType() == "dojo.storage.browser.FlashStorageProvider" && dojo.flash.ready == false) {
103
			return false;
104
		} else {
105
			return this._initialized;
106
		}
107
	};
108
	this.supportsProvider = function (storageClass) {
109
		try {
110
			var provider = eval("new " + storageClass + "()");
111
			var results = provider.isAvailable();
112
			if (results == null || typeof results == "undefined") {
113
				return false;
114
			}
115
			return results;
116
		}
117
		catch (exception) {
118
			return false;
119
		}
120
	};
121
	this.getProvider = function () {
122
		return this.currentProvider;
123
	};
124
	this.loaded = function () {
125
	};
126
};
127