Index: verbosio/src/core/components/xeFileSearch.js =================================================================== RCS file: verbosio/src/core/components/xeFileSearch.js diff -N verbosio/src/core/components/xeFileSearch.js --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ verbosio/src/core/components/xeFileSearch.js 13 Feb 2007 07:23:13 -0000 @@ -0,0 +1,680 @@ +/* ***** BEGIN LICENSE BLOCK ***** + * Version: MPL 1.1/GPL 2.0/LGPL 2.1 + * + * The contents of this file are subject to the Mozilla Public License Version + * 1.1 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * http://www.mozilla.org/MPL/ + * + * Software distributed under the License is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License + * for the specific language governing rights and limitations under the + * License. + * + * The Original Code is Verbosio File Search Components. + * + * The Initial Developer of the Original Code is + * Alexander J. Vincent . + * Portions created by the Initial Developer are Copyright (C) 2007 + * the Initial Developer. All Rights Reserved. + * + * Contributor(s): + * + * Alternatively, the contents of this file may be used under the terms of + * either the GNU General Public License Version 2 or later (the "GPL"), or + * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), + * in which case the provisions of the GPL or the LGPL are applicable instead + * of those above. If you wish to allow use of your version of this file only + * under the terms of either the GPL or the LGPL, and not to allow others to + * use your version of this file under the terms of the MPL, indicate your + * decision by deleting the provisions above and replace them with the notice + * and other provisions required by the GPL or the LGPL. If you do not delete + * the provisions above, a recipient may use your version of this file under + * the terms of any one of the MPL, the GPL or the LGPL. + * + * ***** END LICENSE BLOCK ***** */ + +// Utility functions. +function ERROR_FAILURE() { + throw Components.results.NS_ERROR_FAILURE; +} + +function NOT_IMPLEMENTED() { + throw Components.results.NS_ERROR_NOT_IMPLEMENTED; +} + +function ERROR_ABORT() { + throw Components.results.NS_ERROR_ABORT; +} + +function NOT_INITIALIZED() { + throw Components.results.NS_ERROR_NOT_INITIALIZED; +} + +function ALREADY_INITIALIZED() { + throw Components.results.NS_ERROR_ALREADY_INITIALIZED; +} + +function NULL_POINTER() { + throw Components.results.NS_ERROR_NULL_POINTER; +} + +function INVALID_POINTER() { + throw Components.results.NS_ERROR_INVALID_POINTER; +} + +/** + * Wrap a JavaScript object for passing to components code. + */ +function ObjectWrapper(object) { + this.wrappedJSObject = object; +} + +const C_i = Components.interfaces; + +const mozIJSSubScriptLoader = C_i.mozIJSSubScriptLoader; +const nsIScriptError = C_i.nsIScriptError; +const nsIProgrammingLanguage = C_i.nsIProgrammingLanguage; +const nsISecurityCheckedComponent = C_i.nsISecurityCheckedComponent; +const nsIClassInfo = C_i.nsIClassInfo; +const nsIComponentRegistrar = C_i.nsIComponentRegistrar; +const nsIFactory = C_i.nsIFactory; +const nsIModule = C_i.nsIModule; +const nsISupports = C_i.nsISupports; + +var Module = { + factoriesByClassId: {}, + + constructorsArray: [], + + /** + * Add a factory and registration for a component constructor. + * + * @param aConstructor JavaScript function which constructs the component. + */ + addConstructor: function addConstructor(aConstructor) { + var cid = aConstructor.prototype.classID.toString(); + this.factoriesByClassId[cid] = { + createInstance: function createInstance(outer, iid) { + if (outer != null) + throw Components.results.NS_ERROR_NO_AGGREGATION; + return (new aConstructor()).QueryInterface(iid); + } + }; + + this.constructorsArray[this.constructorsArray.length] = aConstructor; + }, + + // nsIModule + registerSelf: function registerSelf(compMgr, fileSpec, location, type) { + compReg = compMgr.QueryInterface(nsIComponentRegistrar); + + for (var i = 0; i < this.constructorsArray.length; i++) { + var proto = this.constructorsArray[i].prototype; + compReg.registerFactoryLocation(proto.classID, + proto.classDescription, + proto.contractID, + fileSpec, + location, + type); + } + }, + + // nsIModule + getClassObject: function getClassObject(compMgr, aCID, aIID) { + if (!aIID.equals(nsIFactory)) { + throw Components.results.NS_ERROR_NOT_IMPLEMENTED; + } + + for (var prop in this.factoriesByClassId) { + if (aCID.equals(Components.ID(prop))) { + loadSubscripts(); + return this.factoriesByClassId[prop]; + } + } + throw Components.results.NS_ERROR_NO_INTERFACE; + }, + + // nsIModule + canUnload: function canUnload() { + return true; + }, + + // nsISupports + QueryInterface: function QueryInterface(aIID) { + if (aIID.equals(nsIModule) || + (aIID.equals(nsISupports))) + return this; + + throw Components.results.NS_ERROR_NO_INTERFACE; + } +}; + +function NSGetModule(compMgr, fileSpec) { + return Module; +} + +var subscriptsLoaded = false; +/** + * Load necessary scripts. + */ +function loadSubscripts() { + if (subscriptsLoaded) { + return; + } + var jsLoader = Components.classes["@mozilla.org/moz/jssubscript-loader;1"] + .getService(mozIJSSubScriptLoader); + jsLoader.loadSubScript("chrome://verbosio/content/tools/ecma-debug.js"); + jsLoader.loadSubScript("chrome://jslib/content/jslib.js"); + jsLoader.loadSubScript("chrome://jslib/content/io/io.js"); + subscriptsLoaded = true; +} + +/***************************************************************************** + * Base Enumerator Class * + *****************************************************************************/ + +function Enumerator() { +} +Enumerator.prototype = { + // nsISimpleEnumerator + hasMoreElements: function hasMoreElements() { + return (this._iteratorPosition < this._itemsList.length); + }, + + + // nsISimpleEnumerator + getNext: function getNext() { + if (!this.hasMoreElements()) { + ERROR_FAILURE(); + } + var type = this._itemsList[this._iteratorPosition]; + this._iteratorPosition++; + return type; + }, + + // nsISupports + QueryInterface: function QueryInterface(aIID) + { + if (aIID.equals(Components.interfaces.nsISimpleEnumerator) || + aIID.equals(Components.interfaces.nsISupports)) + return this; + + // Known interfaces we don't support. + if (aIID.equals(nsISecurityCheckedComponent) || + aIID.equals(nsIClassInfo)) { + return null; + } + + // Discover what interfaces we need + var i = Components.interfaces; + var found = false; + for (var prop in i) { + if (aIID.equals(i[prop])) { + found = true; + dump("QUERYINTERFACE Enumerator: " + prop + "\n"); + break; + } + } + if (!found) { + dump("QUERYINTERFACE Enumerator: Unknown\n"); + } + + return null; + } +} + +/***************************************************************************** + * File Search Service * + *****************************************************************************/ +const xeIFileSearchService = C_i.xeIFileSearchService; + +var readyToRun = false; + +function FileSearchService() +{ + this.searchCriteria = []; +} +FileSearchService.prototype = +{ + /** + * Search a directory for files and directories which match one criteria set. + * + * @param aBaseDir JSLib Dir object for the directory. + * @param aRecursive If true, search sub-directories as well. + * + * @return JSArray of xeIFileSearchResult objects. + */ + searchFiles: function searchFiles(aBaseDir, aRecursive) { + readyToRun = false; + assert(aBaseDir instanceof Dir, "Not a directory!"); + assert(aBaseDir.isDir(), "Not a directory!"); + + var files = aBaseDir.readDir(); + var results = []; + for (var i = 0; i < files.length; i++) { + var pass = (this.searchCriteria.length == 0) ? + new FileSearchResult(files[i].path) : + null; + var currentFile = files[i]; + var criteriaIndex = -1; + for (var j = 0; + (j < this.searchCriteria.length) && !pass; + j++) { + var criteria = this.searchCriteria[j]; + + var wrapper = new ObjectWrapper(currentFile); + try { + readyToRun = true; + pass = criteria.runTests(wrapper); + } catch (e) { + readyToRun = false; + throw e; + } + readyToRun = false; + + if (pass) { + criteriaIndex = j; + } + } + + if (pass) { + assert(pass instanceof xeIFileSearchResult, "Where'd it come from?"); + try { + readyToRun = true; + pass.setCriteriaIndex(criteriaIndex); + } catch (e) { + readyToRun = false; + throw e; + } + readyToRun = false; + results.push(pass); + } + + if (aRecursive && currentFile.isDir()) { + results = results.concat(this.searchFiles(currentFile, true)); + } + } + + return results; + }, + + // xeIFileSearchService + reset: function reset() { + this.searchCriteria = []; + }, + + // xeIFileSearchService + addCriteria: function addCriteria(aCriteria) { + if (!aCriteria) { + NULL_POINTER(); + } + this.searchCriteria[this.searchCriteria.length] = aCriteria; + }, + + // xeIFileSearchService + searchDirectory: function searchDirectory(aLocalPath, aRecursive) { + for (var i = 0; i < this.searchCriteria.length; i++) { + var criteria = this.searchCriteria[i]; + assert(criteria instanceof xeIFileSearchCriteria, i + " not valid!"); + } + + var baseDir = new Dir(aLocalPath); + var results = this.searchFiles(baseDir, aRecursive); + + var retval = new Enumerator(); + retval._iteratorPosition = 0; + retval._itemsList = results; + return retval; + }, + + // nsIClassInfo + getInterfaces: function getInterfaces(aCount) { + var interfaces = [xeIFileSearchService, + nsIClassInfo]; + aCount.value = interfaces.length; + return interfaces; + }, + + // nsIClassInfo + getHelperForLanguage: function getHelperForLanguage(aLanguage) { + return null; + }, + + // nsIClassInfo + classDescription: "File search service", + + // nsIClassInfo + classID: Components.ID("0dca4b97-60d0-4017-97e5-1075d7814900"), + + // nsIClassInfo + contractID: "@verbosio.mozdev.org/file-search/service;1", + + // nsIClassInfo + implementationLanguage: nsIProgrammingLanguage.JAVASCRIPT, + + // nsIClassInfo + flags: nsIClassInfo.SINGLETON, // service + + // nsISupports + QueryInterface: function QueryInterface(aIID) { + if (aIID.equals(xeIFileSearchService) || + aIID.equals(nsIClassInfo) || + aIID.equals(nsISupports)) + return this; + + // Discover what interfaces we need + var i = Components.interfaces; + var found = false; + for (var prop in i) { + if (aIID.equals(i[prop])) { + found = true; + dump("QUERYINTERFACE: FileSearchService " + prop + "\n"); + break; + } + } + if (!found) { + dump("QUERYINTERFACE: FileSearchService Unknown\n"); + } + return null; + } +}; + +Module.addConstructor(FileSearchService); + +/***************************************************************************** + * File Search Criteria * + *****************************************************************************/ +const xeIFileSearchCriteria = C_i.xeIFileSearchCriteria; + +function FileSearchCriteria() +{ + this.propertyFilters = []; + this.contentFilters = []; +} +FileSearchCriteria.prototype = +{ + // xeIFileSearchCriteria + runTests: function runTests(aFileWrapper) { + if (!readyToRun) { + ERROR_ABORT(); + } + var currentFile = aFileWrapper.wrappedJSObject; + var filter; + var filterResult; + var result = new FileSearchResult(currentFile.path); + var i; + for (i = 0; i < this.propertyFilters.length; i++) { + filter = this.propertyFilters[i]; + switch (typeof currentFile[filter.name]) { + case "undefined": + return null; + case "function": + filterResult = currentFile[filter.name]().toString(); + break; + default: + filterResult = currentFile[filter.name].toString(); + break; + } + + if (filterResult != filter.value) { + return null; + } + } + + // Run content filters last! File reading is more expensive. + if (this.contentFilters.length > 0) { + if (!currentFile.isFile()) { + return null; + } + currentFile.open("r"); + var contents = currentFile.read(); + result._fileContents = contents; + currentFile.close(); + + for (i = 0; i < this.contentFilters.length; i++) { + filter = this.contentFilters[i]; + filterResult = contents.indexOf(filter); + if (filterResult == -1) { + return null; + } + + // Advance to next line break. + var nextBreak = contents.indexOf("\n", filterResult); + var data = contents.substr(0, nextBreak).split("\n"); + result.setLine(filterResult, data[data.length - 1]); + } + } + + // If a file gets this far, it has passed all filtering. + return result; + }, + + // xeIFileSearchCriteria + filterProperty: function filterProperty(aName, aValue) { + if (!aName) { + NULL_POINTER(); + } + + this.propertyFilters.push({ + name: aName, + value: aValue + }); + }, + + // xeIFileSearchCriteria + filterContentsString: function filterContentsString(aRequiredContent) { + if (!aRequiredContent) { + NULL_POINTER(); + } + + this.contentFilters.push(aRequiredContent); + }, + + // nsIClassInfo + getInterfaces: function getInterfaces(aCount) { + var interfaces = [xeIFileSearchCriteria, + nsIClassInfo]; + aCount.value = interfaces.length; + return interfaces; + }, + + // nsIClassInfo + getHelperForLanguage: function getHelperForLanguage(aLanguage) { + return null; + }, + + // nsIClassInfo + classDescription: "File search criteria", + + // nsIClassInfo + classID: Components.ID("16b7a487-3248-4802-9e4a-12c75443c07c"), + + // nsIClassInfo + contractID: "@verbosio.mozdev.org/file-search/criteria;1", + + // nsIClassInfo + implementationLanguage: nsIProgrammingLanguage.JAVASCRIPT, + + // nsIClassInfo + flags: 0, + + // nsISupports + QueryInterface: function QueryInterface(aIID) { + if (aIID.equals(xeIFileSearchCriteria) || + aIID.equals(nsIClassInfo) || + aIID.equals(nsISupports)) + return this; + + // Discover what interfaces we need + var i = Components.interfaces; + var found = false; + for (var prop in i) { + if (aIID.equals(i[prop])) { + found = true; + dump("QUERYINTERFACE: FileSearchCriteria " + prop + "\n"); + break; + } + } + if (!found) { + dump("QUERYINTERFACE: FileSearchCriteria Unknown\n"); + } + return null; + } +}; + +Module.addConstructor(FileSearchCriteria); + +/***************************************************************************** + * File Search Result * + *****************************************************************************/ + +const xeIFileSearchResult = C_i.xeIFileSearchResult; + +function FileSearchResult(aPath) +{ + // xeIFileSearchResult + this.path = aPath; + + // xeIFileSearchResult + this.criteriaIndex = -1; + + this._lineNumbers = []; + this._fileContents = null; + this._lines = {}; +} +FileSearchResult.prototype = +{ + // xeIFileSearchResult + getLineNumbers: function getLineNumbers(aCount) { + aCount.value = this._lineNumbers.length; + return this._lineNumbers; + }, + + // xeIFileSearchResult + getLine: function getLine(aIndex) { + if (aIndex in this._lines) { + return this._lines[aIndex]; + } + INVALID_POINTER(); + return null; // silence a strict warning + }, + + // xeIFileSearchResult + setLine: function setLine(aIndex, aLine) { + if (!readyToRun) { + ERROR_ABORT(); + } + if (aIndex in this._lines) { + ALREADY_INITIALIZED(); + } + this._lineNumbers[this._lineNumbers.length] = aIndex; + this._lines[aIndex] = aLine; + }, + + // xeIFileSearchResult + setCriteriaIndex: function setCriteriaIndex(aIndex) { + if (!readyToRun) { + ERROR_ABORT(); + } + + this.criteriaIndex = aIndex; + }, + + // nsIClassInfo + getInterfaces: function getInterfaces(aCount) { + var interfaces = [xeIFileSearchResult, + nsIClassInfo]; + aCount.value = interfaces.length; + return interfaces; + }, + + // nsIClassInfo + getHelperForLanguage: function getHelperForLanguage(aLanguage) { + return null; + }, + + // nsIClassInfo + classDescription: "File search result", + + // nsIClassInfo + classID: Components.ID("cf354ee0-2e7d-455c-bbb3-16f79b30e60b"), + + // nsIClassInfo + contractID: "@verbosio.mozdev.org/file-search/result;1", + + // nsIClassInfo + implementationLanguage: nsIProgrammingLanguage.JAVASCRIPT, + + // nsIClassInfo + flags: 0, + + // nsISupports + QueryInterface: function QueryInterface(aIID) { + if (aIID.equals(xeIFileSearchResult) || + aIID.equals(nsIClassInfo) || + aIID.equals(nsISupports)) + return this; + + // Known interfaces we don't support. + if (aIID.equals(nsISecurityCheckedComponent)) { + return null; + } + + // Discover what interfaces we need + var i = Components.interfaces; + var found = false; + for (var prop in i) { + if (aIID.equals(i[prop])) { + found = true; + dump("QUERYINTERFACE: FileSearchResult " + prop + "\n"); + break; + } + } + if (!found) { + dump("QUERYINTERFACE: FileSearchResult Unknown\n"); + } + return null; + } +}; + +/***************************************************************************** + * Sample Test Code For Searching * + *****************************************************************************/ +/* +function runSearch(aLocalPath) { + const xeIFileSearchService = Components.interfaces.xeIFileSearchService; + const xeIFileSearchCriteria = Components.interfaces.xeIFileSearchCriteria; + const xeIFileSearchResult = Components.interfaces.xeIFileSearchResult; + + const fileSearch = Components.classes["@verbosio.mozdev.org/file-search/service;1"] + .getService(xeIFileSearchService); + fileSearch.reset(); + + var criteria = Components.classes["@verbosio.mozdev.org/file-search/criteria;1"] + .createInstance(xeIFileSearchCriteria); + criteria.filterProperty("isFile", "true"); + criteria.filterProperty("leaf", "chrome.manifest"); + + criteria.filterContentsString("content xml-inspector"); + + fileSearch.addCriteria(criteria); + + // nsISimpleEnumerator + var enumerator = fileSearch.searchDirectory(aLocalPath, true); + + while (enumerator.hasMoreElements()) { + var result = enumerator.getNext(); + if (!(result instanceof xeIFileSearchResult)) { + throw new Error("Not a search result?"); + } + dump(result.path + "(" + result.criteriaIndex + ")\n"); + var countObject = {}; + var lineNumbers = result.getLineNumbers(countObject); + for (var i = 0; i < countObject.value; i++) { + dump(" " + lineNumbers[i] + ":" + result.getLine(lineNumbers[i]) + "\n"); + } + dump("***\n\n"); + } +} + */ Index: verbosio/src/core/idl/xeIFileSearchCriteria.idl =================================================================== RCS file: verbosio/src/core/idl/xeIFileSearchCriteria.idl diff -N verbosio/src/core/idl/xeIFileSearchCriteria.idl --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ verbosio/src/core/idl/xeIFileSearchCriteria.idl 13 Feb 2007 07:23:19 -0000 @@ -0,0 +1,68 @@ +/* ***** BEGIN LICENSE BLOCK ***** + * Version: MPL 1.1/GPL 2.0/LGPL 2.1 + * + * The contents of this file are subject to the Mozilla Public License Version + * 1.1 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * http://www.mozilla.org/MPL/ + * + * Software distributed under the License is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License + * for the specific language governing rights and limitations under the + * License. + * + * The Original Code is Verbosio File Search Service. + * + * The Initial Developer of the Original Code is + * Alexander J. Vincent . + * Portions created by the Initial Developer are Copyright (C) 2007 + * the Initial Developer. All Rights Reserved. + * + * Contributor(s): + * + * Alternatively, the contents of this file may be used under the terms of + * either the GNU General Public License Version 2 or later (the "GPL"), or + * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), + * in which case the provisions of the GPL or the LGPL are applicable instead + * of those above. If you wish to allow use of your version of this file only + * under the terms of either the GPL or the LGPL, and not to allow others to + * use your version of this file under the terms of the MPL, indicate your + * decision by deleting the provisions above and replace them with the notice + * and other provisions required by the GPL or the LGPL. If you do not delete + * the provisions above, a recipient may use your version of this file under + * the terms of any one of the MPL, the GPL or the LGPL. + * + * ***** END LICENSE BLOCK ***** */ + +#include "nsISupports.idl" +#include "xeIFileSearchResult.idl" + +[scriptable, uuid(4136e149-5bfa-4de4-a995-64dbd61d64ef)] +interface xeIFileSearchCriteria : nsISupports +{ + /** + * Add a property to filter files and directories for. + * + * @param aName Name of the property to check. + * @param aValue Value which the property must match. + */ + void filterProperty(in ACString aName, in ACString aValue); + + /** + * Add a filter for a required string of content. + * + * @param aRequiredContent Value which the file must contain. + */ + void filterContentsString(in ACString aRequiredContent); + + /** + * Run criterial tests on a File or Dir object. + * + * @param aCurrentFile The file to test. + * + * @return xeIFileSearchResult object if test passes, or null otherwise. + * + * @note Do NOT call this method directly! Consider it off limits. + */ + xeIFileSearchResult runTests(in nsISupports aCurrentFile); +}; Index: verbosio/src/core/idl/xeIFileSearchResult.idl =================================================================== RCS file: verbosio/src/core/idl/xeIFileSearchResult.idl diff -N verbosio/src/core/idl/xeIFileSearchResult.idl --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ verbosio/src/core/idl/xeIFileSearchResult.idl 13 Feb 2007 07:23:19 -0000 @@ -0,0 +1,82 @@ +/* ***** BEGIN LICENSE BLOCK ***** + * Version: MPL 1.1/GPL 2.0/LGPL 2.1 + * + * The contents of this file are subject to the Mozilla Public License Version + * 1.1 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * http://www.mozilla.org/MPL/ + * + * Software distributed under the License is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License + * for the specific language governing rights and limitations under the + * License. + * + * The Original Code is Verbosio File Search Service. + * + * The Initial Developer of the Original Code is + * Alexander J. Vincent . + * Portions created by the Initial Developer are Copyright (C) 2007 + * the Initial Developer. All Rights Reserved. + * + * Contributor(s): + * + * Alternatively, the contents of this file may be used under the terms of + * either the GNU General Public License Version 2 or later (the "GPL"), or + * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), + * in which case the provisions of the GPL or the LGPL are applicable instead + * of those above. If you wish to allow use of your version of this file only + * under the terms of either the GPL or the LGPL, and not to allow others to + * use your version of this file under the terms of the MPL, indicate your + * decision by deleting the provisions above and replace them with the notice + * and other provisions required by the GPL or the LGPL. If you do not delete + * the provisions above, a recipient may use your version of this file under + * the terms of any one of the MPL, the GPL or the LGPL. + * + * ***** END LICENSE BLOCK ***** */ + +#include "nsISupports.idl" + +[scriptable, uuid(f448066b-5db3-47ca-bcfb-cafb235d8130)] +interface xeIFileSearchResult : nsISupports +{ + /** + * The local file path to the matched file. + */ + readonly attribute ACString path; + + /** + * Get the line numbers for a the result's content matches as an array. + */ + void getLineNumbers(out PRUint32 count, + [retval, array, size_is(count)] out PRUint32 lineNumbers); + + /** + * Get a source code line for a given line number which matched. + * + * @param aLineNumber The line number to look the line up with. + * + * @return String with the source code line. + */ + ACString getLine(in PRUint32 aLineNumber); + + /** + * Set a source code line for a given line number which matched. + * + * @param aLineNumber The line number to look the line up with. + * + * @return String with the source code line. + */ + void setLine(in PRUint32 aLineNumber, in ACString aLine); + + /** + * Get the index of the search service's criteria which this result matched. + */ + readonly attribute PRInt32 criteriaIndex; + + /** + * Set the index of the search service's criteria which this result matched. + * + * @param aIndex The index to set. + */ + void setCriteriaIndex(in PRInt32 aIndex); +}; Index: verbosio/src/core/idl/xeIFileSearchService.idl =================================================================== RCS file: verbosio/src/core/idl/xeIFileSearchService.idl diff -N verbosio/src/core/idl/xeIFileSearchService.idl --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ verbosio/src/core/idl/xeIFileSearchService.idl 13 Feb 2007 07:23:19 -0000 @@ -0,0 +1,63 @@ +/* ***** BEGIN LICENSE BLOCK ***** + * Version: MPL 1.1/GPL 2.0/LGPL 2.1 + * + * The contents of this file are subject to the Mozilla Public License Version + * 1.1 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * http://www.mozilla.org/MPL/ + * + * Software distributed under the License is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License + * for the specific language governing rights and limitations under the + * License. + * + * The Original Code is Verbosio File Search Service. + * + * The Initial Developer of the Original Code is + * Alexander J. Vincent . + * Portions created by the Initial Developer are Copyright (C) 2007 + * the Initial Developer. All Rights Reserved. + * + * Contributor(s): + * + * Alternatively, the contents of this file may be used under the terms of + * either the GNU General Public License Version 2 or later (the "GPL"), or + * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), + * in which case the provisions of the GPL or the LGPL are applicable instead + * of those above. If you wish to allow use of your version of this file only + * under the terms of either the GPL or the LGPL, and not to allow others to + * use your version of this file under the terms of the MPL, indicate your + * decision by deleting the provisions above and replace them with the notice + * and other provisions required by the GPL or the LGPL. If you do not delete + * the provisions above, a recipient may use your version of this file under + * the terms of any one of the MPL, the GPL or the LGPL. + * + * ***** END LICENSE BLOCK ***** */ + +#include "nsISupports.idl" +#include "nsISimpleEnumerator.idl" +#include "xeIFileSearchCriteria.idl" +#include "xeIFileSearchResult.idl" + +[scriptable, uuid(79ded7e0-6ef7-47a8-899a-e3e616911747)] +interface xeIFileSearchService : nsISupports +{ + /** + * Clear all search criteria. + */ + void reset(); + + /** + * Add a set of criteria for searching. + */ + void addCriteria(in xeIFileSearchCriteria criteria); + + /** + * Get all search results which match at least one criteria set. + * + * @param aLocalPath Local filesystem path to a directory. + * @param recursive True if the search should include subdirectories. + */ + nsISimpleEnumerator searchDirectory(in ACString aLocalPath, + in boolean recursive); +};