Changeset 37
- Timestamp:
- 2007-01-23 06:17:31 (2 years ago)
- Files:
-
- trunk/components/filterManager.idl (modified) (2 diffs)
- trunk/components/filterManager.js (modified) (10 diffs)
- trunk/components/filterManager.xpt (modified) (previous)
- trunk/components/privacycontrol.js (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
trunk/components/filterManager.idl
r34 r37 48 48 attribute string label; 49 49 attribute string test; 50 [readonly] attribute string regex;50 attribute boolean isRegex; 51 51 attribute boolean active; 52 attribute boolean isRegex;53 52 attribute unsigned long type; 54 53 boolean match(in string test); 55 54 void save(); 56 55 void remove(); … … 64 63 void reload(); 65 64 66 nsISimpleEnumerator enumerate(); 65 nsISimpleEnumerator enumAll(); 66 nsISimpleEnumerator enumActive(in unsigned long type); 67 67 dtaIFilter getFilter(in string id); 68 69 boolean matchActive(in string test, in unsigned long type); 68 70 69 71 void create(in string label, in string test, in boolean active, in unsigned long type, in boolean regex); trunk/components/filterManager.js
r34 r37 35 35 * ***** END LICENSE BLOCK ***** */ 36 36 37 // Components.classes['@tn123.ath.cx/dtamod/filtermanager;1'].getService(Components.interfaces.dtaIFilterManager). count;37 // Components.classes['@tn123.ath.cx/dtamod/filtermanager;1'].getService(Components.interfaces.dtaIFilterManager).matchActive('hallo.jpg', 1); 38 38 39 39 const CC = Components.classes; 40 40 const CI = Components.interfaces; 41 41 const error = Components.utils.reportError; 42 43 function include(uri) { 44 CC["@mozilla.org/moz/jssubscript-loader;1"] 45 .getService(CI.mozIJSSubScriptLoader) 46 .loadSubScript(uri); 47 } 48 49 include("chrome://dta/content/common/regconvert.js"); 42 50 43 51 // no not create DTA_Filter yourself, managed by DTA_FilterManager … … 73 81 iid.equals(CI.nsISupports) 74 82 || iid.equals(CI.nsIClassInfo) 75 || iid.equals(CI. nsIDTAFilter)83 || iid.equals(CI.dtaIFilter) 76 84 ) { 77 85 return this; … … 120 128 this._modified = true; 121 129 }, 122 // exported123 get regex() {124 return this._regex;125 },126 130 127 131 // exported … … 168 172 169 173 _createRegex: function F_createRegex() { 170 // XXX174 this._regex = this._isRegex ? DTA_regToRegExp(this._test) : DTA_strToRegExp(this._test); 171 175 }, 172 176 … … 175 179 }, 176 180 181 match: function F_match(str) { 182 return str.search(this._regex) != -1; 183 }, 177 184 178 185 /** … … 237 244 this._filters = filters; 238 245 this._idx = 0; 246 this._filters.sort(function(a,b) { 247 if (a.defFilter && !b.defFilter) { 248 return -1; 249 } 250 else if (!a.defFilter && b.defFilter) { 251 return 1; 252 } 253 else if (a.defFilter) { 254 if (a.id < b.id) { 255 return -1; 256 } 257 return 1; 258 } 259 var i = a.label.toLower(), ii = b.label.toLower(); 260 return i < ii ? -1 : (i > ii ? 1 : 0); 261 }); 239 262 } 240 263 FilterEnumerator.prototype = { … … 356 379 }, 357 380 358 enum erate: function FM_enumerate() {381 enumAll: function FM_enumAll() { 359 382 var a = []; 360 383 for (x in this._filters) { … … 363 386 return new FilterEnumerator(a); 364 387 }, 388 enumActive: function FM_enumActive(type) { 389 var a = []; 390 for (x in this._filters) { 391 if (this._filters[x].active && this._filters[x].type & type) { 392 a.push(this._filters[x]); 393 } 394 } 395 return new FilterEnumerator(a); 396 }, 365 397 366 398 getFilter: function FM_getFilter(id) { … … 369 401 } 370 402 return null; 371 }, 403 }, 404 405 matchActive: function FM_matchActive(test, type) { 406 var e = this.enumActive(type); 407 // we're a friend :p 408 return e._filters.some(function(i) { return i.match(test); }); 409 }, 410 372 411 create: function FM_create(label, test, active, type, isRegex) { 373 412 … … 402 441 403 442 save: function FM_save() { 404 405 var e = this.enumerate(); 443 var e = this.enumAll(); 406 444 while (e.hasMoreElements()) { 407 445 var f = e.getNext(); trunk/components/privacycontrol.js
r6 r37 131 131 .getBranch('extensions.dta.'); 132 132 133 // add more if needed 134 const toClear = Array('directory', 'dropdown.directory-current', 'dropdown.directory-history'); 135 136 for (var i = 0; i < toClear.length; ++i) { 137 try { 138 prefs.clearUserPref(toClear[i]); 139 } catch (ex) {} 140 } 133 ['directory', 'filter'].forEach(function(e) { prefs.clearUserPref(e); }); 141 134 }, 142 135 … … 250 243 251 244 function NSGetModule(mgr, spec) { 245 dump("PC getModule"); 252 246 return module; 253 247 }
