Subversion Repositories Applications.papyrus

Rev

Go to most recent revision | Details | 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
 
11
dojo.provide("dojo.storage");
12
dojo.require("dojo.lang.*");
13
dojo.require("dojo.event.*");
14
dojo.storage = new function () {
15
};
16
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 () {
17
	dojo.unimplemented("dojo.storage.initialize");
18
}, isAvailable:function () {
19
	dojo.unimplemented("dojo.storage.isAvailable");
20
}, put:function (key, value, resultsHandler) {
21
	dojo.unimplemented("dojo.storage.put");
22
}, get:function (key) {
23
	dojo.unimplemented("dojo.storage.get");
24
}, hasKey:function (key) {
25
	return (this.get(key) != null);
26
}, getKeys:function () {
27
	dojo.unimplemented("dojo.storage.getKeys");
28
}, clear:function () {
29
	dojo.unimplemented("dojo.storage.clear");
30
}, remove:function (key) {
31
	dojo.unimplemented("dojo.storage.remove");
32
}, isPermanent:function () {
33
	dojo.unimplemented("dojo.storage.isPermanent");
34
}, getMaximumSize:function () {
35
	dojo.unimplemented("dojo.storage.getMaximumSize");
36
}, hasSettingsUI:function () {
37
	return false;
38
}, showSettingsUI:function () {
39
	dojo.unimplemented("dojo.storage.showSettingsUI");
40
}, hideSettingsUI:function () {
41
	dojo.unimplemented("dojo.storage.hideSettingsUI");
42
}, getType:function () {
43
	dojo.unimplemented("dojo.storage.getType");
44
}, isValidKey:function (keyName) {
45
	if ((keyName == null) || (typeof keyName == "undefined")) {
46
		return false;
47
	}
48
	return /^[0-9A-Za-z_]*$/.test(keyName);
49
}});
50
dojo.storage.manager = new function () {
51
	this.currentProvider = null;
52
	this.available = false;
53
	this._initialized = false;
54
	this._providers = [];
55
	this.namespace = "default";
56
	this.initialize = function () {
57
		this.autodetect();
58
	};
59
	this.register = function (name, instance) {
60
		this._providers[this._providers.length] = instance;
61
		this._providers[name] = instance;
62
	};
63
	this.setProvider = function (storageClass) {
64
	};
65
	this.autodetect = function () {
66
		if (this._initialized == true) {
67
			return;
68
		}
69
		var providerToUse = null;
70
		for (var i = 0; i < this._providers.length; i++) {
71
			providerToUse = this._providers[i];
72
			if (dojo.lang.isUndefined(djConfig["forceStorageProvider"]) == false && providerToUse.getType() == djConfig["forceStorageProvider"]) {
73
				providerToUse.isAvailable();
74
				break;
75
			} else {
76
				if (dojo.lang.isUndefined(djConfig["forceStorageProvider"]) == true && providerToUse.isAvailable()) {
77
					break;
78
				}
79
			}
80
		}
81
		if (providerToUse == null) {
82
			this._initialized = true;
83
			this.available = false;
84
			this.currentProvider = null;
85
			dojo.raise("No storage provider found for this platform");
86
		}
87
		this.currentProvider = providerToUse;
88
		for (var i in providerToUse) {
89
			dojo.storage[i] = providerToUse[i];
90
		}
91
		dojo.storage.manager = this;
92
		dojo.storage.initialize();
93
		this._initialized = true;
94
		this.available = true;
95
	};
96
	this.isAvailable = function () {
97
		return this.available;
98
	};
99
	this.isInitialized = function () {
100
		if (this.currentProvider.getType() == "dojo.storage.browser.FlashStorageProvider" && dojo.flash.ready == false) {
101
			return false;
102
		} else {
103
			return this._initialized;
104
		}
105
	};
106
	this.supportsProvider = function (storageClass) {
107
		try {
108
			var provider = eval("new " + storageClass + "()");
109
			var results = provider.isAvailable();
110
			if (results == null || typeof results == "undefined") {
111
				return false;
112
			}
113
			return results;
114
		}
115
		catch (exception) {
116
			return false;
117
		}
118
	};
119
	this.getProvider = function () {
120
		return this.currentProvider;
121
	};
122
	this.loaded = function () {
123
	};
124
};
125