home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Minami 83
/
MINAMI83.iso
/
Extra
/
DivXInstaller.exe
/
$PLUGINSDIR
/
GoogleToolbarFirefox.msi
/
xpi
/
amulet-jslib
/
multi-querier.js
< prev
next >
Wrap
Text File
|
2006-08-07
|
2KB
|
74 lines
function PROT_MultiQuerier(tokens, tableName, callback) {
this.tokens_ = tokens;
this.tableName_ = tableName;
this.callback_ = callback;
this.dbservice_ = Cc["@google.com/dbupdateservice;1"]
.getService(Ci.GTBIDbUpdateService);
this.key_ = null;
}
PROT_MultiQuerier.prototype.run = function() {
if (this.tokens_.length == 0) {
this.callback_(false);
this.dbservice_ = null;
this.callback_ = null;
return;
}
this.key_ = this.tokens_.pop();
G_Debug(this, "Looking up " + this.key_ + " in " + this.tableName_);
this.dbservice_.exists(this.tableName_, this.key_,
BindToObject(this.resultCallback_, this));
}
PROT_MultiQuerier.prototype.resultCallback_ = function(value) {
if (this.checkValue_(value)) {
this.callback_(true)
this.dbservice_ = null;
this.callback_ = null;
} else {
this.run();
}
}
PROT_MultiQuerier.prototype.checkValue_ = function(value) {
throw "PROT_MultiQuerier is an abstract base class";
}
function PROT_ExistsMultiQuerier(tokens, tableName, callback) {
PROT_MultiQuerier.call(this, tokens, tableName, callback);
this.debugZone = "existsMultiQuerier";
}
PROT_ExistsMultiQuerier.inherits(PROT_MultiQuerier);
PROT_ExistsMultiQuerier.prototype.checkValue_ = function(value) {
return value.length > 0;
}
function PROT_EnchashMultiQuerier(tokens, tableName, callback, url) {
PROT_MultiQuerier.call(this, tokens, tableName, callback);
this.url_ = url;
this.enchashDecrypter_ = new PROT_EnchashDecrypter();
this.debugZone = "enchashMultiQuerier";
}
PROT_EnchashMultiQuerier.inherits(PROT_MultiQuerier);
PROT_EnchashMultiQuerier.prototype.run = function() {
if (this.tokens_.length == 0) {
this.callback_(false);
this.dbservice_ = null;
this.callback_ = null;
return;
}
var host = this.tokens_.pop();
this.key_ = host;
var lookupKey = this.enchashDecrypter_.getLookupKey(host);
this.dbservice_.exists(this.tableName_, lookupKey,
BindToObject(this.resultCallback_, this));
}
PROT_EnchashMultiQuerier.prototype.checkValue_ = function(encryptedValue) {
if (encryptedValue.length > 0) {
var decrypted = this.enchashDecrypter_.decryptData(encryptedValue,
this.key_);
var res = this.enchashDecrypter_.parseRegExps(decrypted);
for (var j = 0; j < res.length; j++) {
if (res[j].test(this.url_)) {
return true;
}
}
}
return false;
}