2007-10-23 07:11:59 +00:00
|
|
|
const ZOTERO_CONTRACTID = '@zotero.org/Zotero;1';
|
2006-10-02 23:15:27 +00:00
|
|
|
const ZOTERO_CLASSNAME = 'Zotero';
|
|
|
|
const ZOTERO_CID = Components.ID('{e4c61080-ec2d-11da-8ad9-0800200c9a66}');
|
2007-10-23 07:11:59 +00:00
|
|
|
const ZOTERO_IID = Components.interfaces.chnmIZoteroService; //unused
|
2006-05-27 00:20:27 +00:00
|
|
|
|
|
|
|
const Cc = Components.classes;
|
|
|
|
const Ci = Components.interfaces;
|
|
|
|
|
|
|
|
// Assign the global scope to a variable to passed via wrappedJSObject
|
2006-10-02 23:15:27 +00:00
|
|
|
var ZoteroWrapped = this;
|
2006-05-27 00:20:27 +00:00
|
|
|
|
|
|
|
|
|
|
|
/********************************************************************
|
|
|
|
* Include the core objects to be stored within XPCOM
|
|
|
|
*********************************************************************/
|
|
|
|
|
|
|
|
Cc["@mozilla.org/moz/jssubscript-loader;1"]
|
|
|
|
.getService(Ci.mozIJSSubScriptLoader)
|
2006-10-03 00:29:42 +00:00
|
|
|
.loadSubScript("chrome://zotero/content/xpcom/zotero.js");
|
2006-05-27 00:20:27 +00:00
|
|
|
|
|
|
|
Cc["@mozilla.org/moz/jssubscript-loader;1"]
|
|
|
|
.getService(Ci.mozIJSSubScriptLoader)
|
2006-10-03 00:29:42 +00:00
|
|
|
.loadSubScript("chrome://zotero/content/xpcom/db.js");
|
2006-05-27 00:20:27 +00:00
|
|
|
|
2006-06-07 01:02:59 +00:00
|
|
|
Cc["@mozilla.org/moz/jssubscript-loader;1"]
|
|
|
|
.getService(Ci.mozIJSSubScriptLoader)
|
2006-10-03 00:29:42 +00:00
|
|
|
.loadSubScript("chrome://zotero/content/xpcom/schema.js");
|
2006-06-07 01:02:59 +00:00
|
|
|
|
2006-05-27 00:20:27 +00:00
|
|
|
Cc["@mozilla.org/moz/jssubscript-loader;1"]
|
|
|
|
.getService(Ci.mozIJSSubScriptLoader)
|
2006-10-03 00:29:42 +00:00
|
|
|
.loadSubScript("chrome://zotero/content/xpcom/data_access.js");
|
2006-05-27 00:20:27 +00:00
|
|
|
|
2006-10-02 21:41:38 +00:00
|
|
|
Cc["@mozilla.org/moz/jssubscript-loader;1"]
|
|
|
|
.getService(Ci.mozIJSSubScriptLoader)
|
2006-10-03 00:29:42 +00:00
|
|
|
.loadSubScript("chrome://zotero/content/xpcom/attachments.js");
|
2006-10-02 21:41:38 +00:00
|
|
|
|
2006-06-01 20:03:53 +00:00
|
|
|
Cc["@mozilla.org/moz/jssubscript-loader;1"]
|
|
|
|
.getService(Ci.mozIJSSubScriptLoader)
|
2006-10-03 00:29:42 +00:00
|
|
|
.loadSubScript("chrome://zotero/content/xpcom/notifier.js");
|
2006-06-01 20:03:53 +00:00
|
|
|
|
2006-06-22 14:01:54 +00:00
|
|
|
Cc["@mozilla.org/moz/jssubscript-loader;1"]
|
|
|
|
.getService(Ci.mozIJSSubScriptLoader)
|
2006-10-03 00:29:42 +00:00
|
|
|
.loadSubScript("chrome://zotero/content/xpcom/history.js");
|
2006-06-22 14:01:54 +00:00
|
|
|
|
Closes #7, Add advanced search functionality to data layer
Implemented advanced/saved search architecture -- to use, you create a new search with var search = new Scholar.Search(), add conditions to it with addCondition(condition, operator, value), and run it with search(). The standard conditions with their respective operators can be retrieved with Scholar.SearchConditions.getStandardConditions(). Others are for special search flags and can be specified as follows (condition, operator, value):
'context', null, collectionIDToSearchWithin
'recursive', 'true'|'false' (as strings!--defaults to false if not specified, though, so should probably just be removed if not wanted), null
'joinMode', 'any'|'all', null
For standard conditions, currently only 'title' and the itemData fields are supported -- more coming soon.
Localized strings created for the standard search operators
API:
search.setName(name) -- must be called before save() on new searches
search.load(savedSearchID)
search.save() -- saves search to DB and returns a savedSearchID
search.addCondition(condition, operator, value)
search.updateCondition(searchConditionID, condition, operator, value)
search.removeCondition(searchConditionID)
search.getSearchCondition(searchConditionID) -- returns a specific search condition used in the search
search.getSearchConditions() -- returns search conditions used in the search
search.search() -- runs search and returns an array of item ids for results
search.getSQL() -- will be used by Dan for search-within-search
Scholar.Searches.getAll() -- returns an array of saved searches with 'id' and 'name', in alphabetical order
Scholar.Searches.erase(savedSearchID) -- deletes a given saved search from the DB
Scholar.SearchConditions.get(condition) -- get condition data (operators, etc.)
Scholar.SearchConditions.getStandardConditions() -- retrieve conditions for use in drop-down menu (as opposed to special search flags)
Scholar.SearchConditions.hasOperator() -- used by Dan for error-checking
2006-08-08 02:04:02 +00:00
|
|
|
Cc["@mozilla.org/moz/jssubscript-loader;1"]
|
|
|
|
.getService(Ci.mozIJSSubScriptLoader)
|
2006-10-03 00:29:42 +00:00
|
|
|
.loadSubScript("chrome://zotero/content/xpcom/search.js");
|
Closes #7, Add advanced search functionality to data layer
Implemented advanced/saved search architecture -- to use, you create a new search with var search = new Scholar.Search(), add conditions to it with addCondition(condition, operator, value), and run it with search(). The standard conditions with their respective operators can be retrieved with Scholar.SearchConditions.getStandardConditions(). Others are for special search flags and can be specified as follows (condition, operator, value):
'context', null, collectionIDToSearchWithin
'recursive', 'true'|'false' (as strings!--defaults to false if not specified, though, so should probably just be removed if not wanted), null
'joinMode', 'any'|'all', null
For standard conditions, currently only 'title' and the itemData fields are supported -- more coming soon.
Localized strings created for the standard search operators
API:
search.setName(name) -- must be called before save() on new searches
search.load(savedSearchID)
search.save() -- saves search to DB and returns a savedSearchID
search.addCondition(condition, operator, value)
search.updateCondition(searchConditionID, condition, operator, value)
search.removeCondition(searchConditionID)
search.getSearchCondition(searchConditionID) -- returns a specific search condition used in the search
search.getSearchConditions() -- returns search conditions used in the search
search.search() -- runs search and returns an array of item ids for results
search.getSQL() -- will be used by Dan for search-within-search
Scholar.Searches.getAll() -- returns an array of saved searches with 'id' and 'name', in alphabetical order
Scholar.Searches.erase(savedSearchID) -- deletes a given saved search from the DB
Scholar.SearchConditions.get(condition) -- get condition data (operators, etc.)
Scholar.SearchConditions.getStandardConditions() -- retrieve conditions for use in drop-down menu (as opposed to special search flags)
Scholar.SearchConditions.hasOperator() -- used by Dan for error-checking
2006-08-08 02:04:02 +00:00
|
|
|
|
2006-06-02 03:19:12 +00:00
|
|
|
Cc["@mozilla.org/moz/jssubscript-loader;1"]
|
|
|
|
.getService(Ci.mozIJSSubScriptLoader)
|
2006-10-03 00:29:42 +00:00
|
|
|
.loadSubScript("chrome://zotero/content/xpcom/ingester.js");
|
2006-06-29 00:56:50 +00:00
|
|
|
|
|
|
|
Cc["@mozilla.org/moz/jssubscript-loader;1"]
|
|
|
|
.getService(Ci.mozIJSSubScriptLoader)
|
2006-10-03 00:29:42 +00:00
|
|
|
.loadSubScript("chrome://zotero/content/xpcom/translate.js");
|
2006-06-26 14:46:57 +00:00
|
|
|
|
2006-07-22 01:25:46 +00:00
|
|
|
Cc["@mozilla.org/moz/jssubscript-loader;1"]
|
|
|
|
.getService(Ci.mozIJSSubScriptLoader)
|
2006-10-03 00:29:42 +00:00
|
|
|
.loadSubScript("chrome://zotero/content/xpcom/cite.js");
|
2006-07-22 01:25:46 +00:00
|
|
|
|
2007-10-23 07:11:59 +00:00
|
|
|
Cc["@mozilla.org/moz/jssubscript-loader;1"]
|
|
|
|
.getService(Ci.mozIJSSubScriptLoader)
|
|
|
|
.loadSubScript("chrome://zotero/content/xpcom/cite_compat.js");
|
|
|
|
|
|
|
|
Cc["@mozilla.org/moz/jssubscript-loader;1"]
|
|
|
|
.getService(Ci.mozIJSSubScriptLoader)
|
|
|
|
.loadSubScript("chrome://zotero/content/xpcom/quickCopy.js");
|
|
|
|
|
|
|
|
Cc["@mozilla.org/moz/jssubscript-loader;1"]
|
|
|
|
.getService(Ci.mozIJSSubScriptLoader)
|
|
|
|
.loadSubScript("chrome://zotero/content/xpcom/report.js");
|
|
|
|
|
|
|
|
Cc["@mozilla.org/moz/jssubscript-loader;1"]
|
|
|
|
.getService(Ci.mozIJSSubScriptLoader)
|
|
|
|
.loadSubScript("chrome://zotero/content/xpcom/timeline.js");
|
|
|
|
|
2006-06-26 14:46:57 +00:00
|
|
|
Cc["@mozilla.org/moz/jssubscript-loader;1"]
|
|
|
|
.getService(Ci.mozIJSSubScriptLoader)
|
2006-10-03 00:29:42 +00:00
|
|
|
.loadSubScript("chrome://zotero/content/xpcom/utilities.js");
|
2006-06-03 22:26:01 +00:00
|
|
|
|
2006-08-28 05:38:37 +00:00
|
|
|
Cc["@mozilla.org/moz/jssubscript-loader;1"]
|
|
|
|
.getService(Ci.mozIJSSubScriptLoader)
|
2006-10-03 00:29:42 +00:00
|
|
|
.loadSubScript("chrome://zotero/content/xpcom/integration.js");
|
2006-08-28 05:38:37 +00:00
|
|
|
|
2006-08-19 20:51:01 +00:00
|
|
|
Cc["@mozilla.org/moz/jssubscript-loader;1"]
|
|
|
|
.getService(Ci.mozIJSSubScriptLoader)
|
2006-10-03 00:29:42 +00:00
|
|
|
.loadSubScript("chrome://zotero/content/xpcom/file.js");
|
2006-08-19 20:51:01 +00:00
|
|
|
|
Fulltext search support
There are currently two types of fulltext searching: an SQL-based word index and a file scanner. They each have their advantages and drawbacks.
The word index is very fast to search and is currently used for the find-as-you-type quicksearch. However, indexing files takes some time, so we should probably offer a preference to turn it off ("Index attachment content for quicksearch" or something). There's also an issue with Chinese characters (which are indexed by character rather than word, since there are no spaces to go by, so a search for a word with common characters could produce erroneous results). The quicksearch doesn't use a left-bound index (since that would probably upset German speakers searching for "musik" in "nachtmusik," though I don't know for sure how they think of words) but still seems pretty fast.
* Note: There will be a potentially long delay when you start Firefox with this revision as it builds a fulltext word index of your existing items. We obviously need a notification/option for this. *
The file scanner, used in the Attachment Content condition of the search dialog, offers phrase searching as well as regex support (both case-sensitive and not, and defaulting to multiline). It doesn't require an index, though it should probably be optimized to use the word index, if available, for narrowing the results when not in regex mode. (It does only scan files that pass all the other search conditions, which speeds it up considerably for multi-condition searches, and skips non-text files unless instructed otherwise, but it's still relatively slow.)
Both convert HTML to text before searching (with the exception of the binary file scanning mode).
There are some issues with which files get indexed and which don't that we can't do much about and that will probably confuse users immensely. Dan C. suggested some sort of indicator (say, a green dot) to show which files are indexed.
Also added (very ugly) charset detection (anybody want to figure out getCharsetFromString(str)?), a setTimeout() replacement in the XPCOM service, an arrayToHash() method, and a new header to timedtextarea.xml, since it's really not copyright CHNM (it's really just a few lines off from the toolkit timed-textbox binding--I tried to change it to extend timed-textbox and just ignore Return keypress events so that we didn't need to duplicate the Mozilla code, but timed-textbox's reliance on html:input instead of html:textarea made things rather difficult).
To do:
- Pref/buttons to disable/clear/rebuild fulltext index
- Hidden prefs to set maximum file size to index/scan
- Don't index words of fewer than 3 non-Asian characters
- MRU cache for saved searches
- Use word index if available to narrow search scope of fulltext scanner
- Cache attachment info methods
- Show content excerpt in search results (at least in advanced search window, when it exists)
- Notification window (a la scraping) to show when indexing
- Indicator of indexed status
- Context menu option to index
- Indicator that a file scanning search is in progress, if possible
- Find other ways to make it index the NYT front page in under 10 seconds
- Probably fix lots of bugs, which you will likely start telling me about...now.
2006-09-21 00:10:29 +00:00
|
|
|
Cc["@mozilla.org/moz/jssubscript-loader;1"]
|
|
|
|
.getService(Ci.mozIJSSubScriptLoader)
|
2006-10-03 00:29:42 +00:00
|
|
|
.loadSubScript("chrome://zotero/content/xpcom/fulltext.js");
|
Fulltext search support
There are currently two types of fulltext searching: an SQL-based word index and a file scanner. They each have their advantages and drawbacks.
The word index is very fast to search and is currently used for the find-as-you-type quicksearch. However, indexing files takes some time, so we should probably offer a preference to turn it off ("Index attachment content for quicksearch" or something). There's also an issue with Chinese characters (which are indexed by character rather than word, since there are no spaces to go by, so a search for a word with common characters could produce erroneous results). The quicksearch doesn't use a left-bound index (since that would probably upset German speakers searching for "musik" in "nachtmusik," though I don't know for sure how they think of words) but still seems pretty fast.
* Note: There will be a potentially long delay when you start Firefox with this revision as it builds a fulltext word index of your existing items. We obviously need a notification/option for this. *
The file scanner, used in the Attachment Content condition of the search dialog, offers phrase searching as well as regex support (both case-sensitive and not, and defaulting to multiline). It doesn't require an index, though it should probably be optimized to use the word index, if available, for narrowing the results when not in regex mode. (It does only scan files that pass all the other search conditions, which speeds it up considerably for multi-condition searches, and skips non-text files unless instructed otherwise, but it's still relatively slow.)
Both convert HTML to text before searching (with the exception of the binary file scanning mode).
There are some issues with which files get indexed and which don't that we can't do much about and that will probably confuse users immensely. Dan C. suggested some sort of indicator (say, a green dot) to show which files are indexed.
Also added (very ugly) charset detection (anybody want to figure out getCharsetFromString(str)?), a setTimeout() replacement in the XPCOM service, an arrayToHash() method, and a new header to timedtextarea.xml, since it's really not copyright CHNM (it's really just a few lines off from the toolkit timed-textbox binding--I tried to change it to extend timed-textbox and just ignore Return keypress events so that we didn't need to duplicate the Mozilla code, but timed-textbox's reliance on html:input instead of html:textarea made things rather difficult).
To do:
- Pref/buttons to disable/clear/rebuild fulltext index
- Hidden prefs to set maximum file size to index/scan
- Don't index words of fewer than 3 non-Asian characters
- MRU cache for saved searches
- Use word index if available to narrow search scope of fulltext scanner
- Cache attachment info methods
- Show content excerpt in search results (at least in advanced search window, when it exists)
- Notification window (a la scraping) to show when indexing
- Indicator of indexed status
- Context menu option to index
- Indicator that a file scanning search is in progress, if possible
- Find other ways to make it index the NYT front page in under 10 seconds
- Probably fix lots of bugs, which you will likely start telling me about...now.
2006-09-21 00:10:29 +00:00
|
|
|
|
2006-08-19 20:51:01 +00:00
|
|
|
Cc["@mozilla.org/moz/jssubscript-loader;1"]
|
|
|
|
.getService(Ci.mozIJSSubScriptLoader)
|
2006-10-03 00:29:42 +00:00
|
|
|
.loadSubScript("chrome://zotero/content/xpcom/mime.js");
|
2006-08-19 20:51:01 +00:00
|
|
|
|
2006-08-25 19:15:03 +00:00
|
|
|
Cc["@mozilla.org/moz/jssubscript-loader;1"]
|
|
|
|
.getService(Ci.mozIJSSubScriptLoader)
|
2006-10-03 00:29:42 +00:00
|
|
|
.loadSubScript("chrome://zotero/content/xpcom/itemTreeView.js");
|
2006-08-25 19:15:03 +00:00
|
|
|
|
|
|
|
Cc["@mozilla.org/moz/jssubscript-loader;1"]
|
|
|
|
.getService(Ci.mozIJSSubScriptLoader)
|
2006-10-03 00:29:42 +00:00
|
|
|
.loadSubScript("chrome://zotero/content/xpcom/collectionTreeView.js");
|
2006-08-25 19:15:03 +00:00
|
|
|
|
2006-09-21 07:54:18 +00:00
|
|
|
Cc["@mozilla.org/moz/jssubscript-loader;1"]
|
|
|
|
.getService(Ci.mozIJSSubScriptLoader)
|
2006-10-03 00:29:42 +00:00
|
|
|
.loadSubScript("chrome://zotero/content/xpcom/progressWindow.js");
|
2006-09-21 07:54:18 +00:00
|
|
|
|
2007-10-23 07:11:59 +00:00
|
|
|
Cc["@mozilla.org/moz/jssubscript-loader;1"]
|
|
|
|
.getService(Ci.mozIJSSubScriptLoader)
|
|
|
|
.loadSubScript("chrome://zotero/content/xpcom/annotate.js");
|
|
|
|
|
2006-08-25 19:15:03 +00:00
|
|
|
Cc["@mozilla.org/moz/jssubscript-loader;1"]
|
|
|
|
.getService(Ci.mozIJSSubScriptLoader)
|
|
|
|
.loadSubScript("chrome://global/content/nsTransferable.js");
|
|
|
|
|
|
|
|
Cc["@mozilla.org/moz/jssubscript-loader;1"]
|
|
|
|
.getService(Ci.mozIJSSubScriptLoader)
|
|
|
|
.loadSubScript("chrome://global/content/nsDragAndDrop.js");
|
|
|
|
|
2006-05-27 00:20:27 +00:00
|
|
|
/********************************************************************/
|
|
|
|
|
|
|
|
|
2006-10-02 23:15:27 +00:00
|
|
|
// Initialize the Zotero service
|
2006-05-27 00:20:27 +00:00
|
|
|
//
|
2006-10-02 23:15:27 +00:00
|
|
|
// This runs when ZoteroService is first requested.
|
2006-05-27 00:20:27 +00:00
|
|
|
// Calls to other XPCOM components must be in here rather than in top-level
|
|
|
|
// code, as other components may not have yet been initialized.
|
|
|
|
function setupService(){
|
2006-10-02 23:15:27 +00:00
|
|
|
Zotero.init();
|
2006-05-27 00:20:27 +00:00
|
|
|
}
|
|
|
|
|
2006-10-02 23:15:27 +00:00
|
|
|
function ZoteroService(){
|
|
|
|
this.wrappedJSObject = ZoteroWrapped.Zotero;
|
2006-05-27 00:20:27 +00:00
|
|
|
setupService();
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Convenience method to replicate window.alert()
|
|
|
|
**/
|
|
|
|
function alert(msg){
|
|
|
|
Cc["@mozilla.org/embedcomp/prompt-service;1"]
|
|
|
|
.getService(Ci.nsIPromptService)
|
|
|
|
.alert(null, "", msg);
|
|
|
|
}
|
|
|
|
|
2006-06-01 21:57:12 +00:00
|
|
|
/**
|
|
|
|
* Convenience method to replicate window.confirm()
|
|
|
|
**/
|
|
|
|
function confirm(msg){
|
|
|
|
return Cc["@mozilla.org/embedcomp/prompt-service;1"]
|
|
|
|
.getService(Ci.nsIPromptService)
|
|
|
|
.confirm(null, "", msg);
|
|
|
|
}
|
2006-05-27 00:20:27 +00:00
|
|
|
|
Fulltext search support
There are currently two types of fulltext searching: an SQL-based word index and a file scanner. They each have their advantages and drawbacks.
The word index is very fast to search and is currently used for the find-as-you-type quicksearch. However, indexing files takes some time, so we should probably offer a preference to turn it off ("Index attachment content for quicksearch" or something). There's also an issue with Chinese characters (which are indexed by character rather than word, since there are no spaces to go by, so a search for a word with common characters could produce erroneous results). The quicksearch doesn't use a left-bound index (since that would probably upset German speakers searching for "musik" in "nachtmusik," though I don't know for sure how they think of words) but still seems pretty fast.
* Note: There will be a potentially long delay when you start Firefox with this revision as it builds a fulltext word index of your existing items. We obviously need a notification/option for this. *
The file scanner, used in the Attachment Content condition of the search dialog, offers phrase searching as well as regex support (both case-sensitive and not, and defaulting to multiline). It doesn't require an index, though it should probably be optimized to use the word index, if available, for narrowing the results when not in regex mode. (It does only scan files that pass all the other search conditions, which speeds it up considerably for multi-condition searches, and skips non-text files unless instructed otherwise, but it's still relatively slow.)
Both convert HTML to text before searching (with the exception of the binary file scanning mode).
There are some issues with which files get indexed and which don't that we can't do much about and that will probably confuse users immensely. Dan C. suggested some sort of indicator (say, a green dot) to show which files are indexed.
Also added (very ugly) charset detection (anybody want to figure out getCharsetFromString(str)?), a setTimeout() replacement in the XPCOM service, an arrayToHash() method, and a new header to timedtextarea.xml, since it's really not copyright CHNM (it's really just a few lines off from the toolkit timed-textbox binding--I tried to change it to extend timed-textbox and just ignore Return keypress events so that we didn't need to duplicate the Mozilla code, but timed-textbox's reliance on html:input instead of html:textarea made things rather difficult).
To do:
- Pref/buttons to disable/clear/rebuild fulltext index
- Hidden prefs to set maximum file size to index/scan
- Don't index words of fewer than 3 non-Asian characters
- MRU cache for saved searches
- Use word index if available to narrow search scope of fulltext scanner
- Cache attachment info methods
- Show content excerpt in search results (at least in advanced search window, when it exists)
- Notification window (a la scraping) to show when indexing
- Indicator of indexed status
- Context menu option to index
- Indicator that a file scanning search is in progress, if possible
- Find other ways to make it index the NYT front page in under 10 seconds
- Probably fix lots of bugs, which you will likely start telling me about...now.
2006-09-21 00:10:29 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Convenience method to replicate window.setTimeout()
|
|
|
|
**/
|
|
|
|
function setTimeout(func, ms){
|
|
|
|
var timer = Components.classes["@mozilla.org/timer;1"].
|
|
|
|
createInstance(Components.interfaces.nsITimer);
|
|
|
|
// {} implements nsITimerCallback
|
|
|
|
timer.initWithCallback({notify:func}, ms,
|
|
|
|
Components.interfaces.nsITimer.TYPE_ONE_SHOT);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2006-05-27 00:20:27 +00:00
|
|
|
//
|
|
|
|
// XPCOM goop
|
|
|
|
//
|
2006-10-02 23:15:27 +00:00
|
|
|
ZoteroService.prototype = {
|
2006-05-27 00:20:27 +00:00
|
|
|
QueryInterface: function(iid){
|
|
|
|
if (!iid.equals(Components.interfaces.nsISupports) &&
|
2007-10-23 07:11:59 +00:00
|
|
|
!iid.equals(ZOTERO_IID)){ // interface unused
|
2006-05-27 00:20:27 +00:00
|
|
|
throw Components.results.NS_ERROR_NO_INTERFACE;
|
|
|
|
}
|
|
|
|
return this;
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
|
2006-10-02 23:15:27 +00:00
|
|
|
var ZoteroFactory = {
|
2006-05-27 00:20:27 +00:00
|
|
|
createInstance: function(outer, iid){
|
|
|
|
if (outer != null){
|
|
|
|
throw Components.results.NS_ERROR_NO_AGGREGATION;
|
|
|
|
}
|
2006-10-02 23:15:27 +00:00
|
|
|
return new ZoteroService().QueryInterface(iid);
|
2006-05-27 00:20:27 +00:00
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
|
2006-10-02 23:15:27 +00:00
|
|
|
var ZoteroModule = {
|
2006-05-27 00:20:27 +00:00
|
|
|
_firstTime: true,
|
|
|
|
|
|
|
|
registerSelf: function(compMgr, fileSpec, location, type){
|
|
|
|
if (!this._firstTime){
|
|
|
|
throw Components.results.NS_ERROR_FACTORY_REGISTER_AGAIN;
|
|
|
|
}
|
|
|
|
this._firstTime = false;
|
|
|
|
|
|
|
|
compMgr =
|
|
|
|
compMgr.QueryInterface(Components.interfaces.nsIComponentRegistrar);
|
|
|
|
|
2006-10-02 23:15:27 +00:00
|
|
|
compMgr.registerFactoryLocation(ZOTERO_CID,
|
|
|
|
ZOTERO_CLASSNAME,
|
|
|
|
ZOTERO_CONTRACTID,
|
2006-05-27 00:20:27 +00:00
|
|
|
fileSpec,
|
|
|
|
location,
|
|
|
|
type);
|
|
|
|
},
|
|
|
|
|
|
|
|
unregisterSelf: function(compMgr, location, type){
|
|
|
|
compMgr =
|
|
|
|
compMgr.QueryInterface(Components.interfaces.nsIComponentRegistrar);
|
2006-10-02 23:15:27 +00:00
|
|
|
compMgr.unregisterFactoryLocation(ZOTERO_CID, location);
|
2006-05-27 00:20:27 +00:00
|
|
|
},
|
|
|
|
|
|
|
|
getClassObject: function(compMgr, cid, iid){
|
2006-10-02 23:15:27 +00:00
|
|
|
if (!cid.equals(ZOTERO_CID)){
|
2006-05-27 00:20:27 +00:00
|
|
|
throw Components.results.NS_ERROR_NO_INTERFACE;
|
|
|
|
}
|
|
|
|
if (!iid.equals(Components.interfaces.nsIFactory)){
|
|
|
|
throw Components.results.NS_ERROR_NOT_IMPLEMENTED;
|
|
|
|
}
|
2006-10-02 23:15:27 +00:00
|
|
|
return ZoteroFactory;
|
2006-05-27 00:20:27 +00:00
|
|
|
},
|
|
|
|
|
|
|
|
canUnload: function(compMgr){ return true; }
|
|
|
|
};
|
|
|
|
|
2006-10-02 23:15:27 +00:00
|
|
|
function NSGetModule(comMgr, fileSpec){ return ZoteroModule; }
|