Skip to content

TagSpaces is an offline, open source, document manager with tagging support

Mozilla new api implementation

Borislav Sapundzhievfc6b6a8b03e8
diff --git a/data/mozilla/ioutils.js b/data/mozilla/ioutils.js
index 25daeba24..86a263651 100644
--- a/data/mozilla/ioutils.js
+++ b/data/mozilla/ioutils.js
@@ -163,6 +163,10 @@ function scanDirectory(dirPath, index) {
exports.listDirectory = function listDirectory(dirPath, worker) {
console.log("Listing directory: " + dirPath);
try {
+ if(dirPath.indexOf("resource://") >=0) {
+ dirPath = require("sdk/url").toFilename(dirPath);
+ }
+
var dirList = filesIO.list(dirPath);
var anotatedDirList = [];
for (var i = 0; i < dirList.length; i++) {
diff --git a/data/mozilla/mozilla.api.js b/data/mozilla/mozilla.api.js
index eb50aa4c6..e2ab1ca8f 100644
--- a/data/mozilla/mozilla.api.js
+++ b/data/mozilla/mozilla.api.js
@@ -87,7 +87,7 @@ define(function(require, exports, module) {
console.error("File loading failed");
}
break;*/
- case "listDirectory":
+ /*case "listDirectory":
if(args[0]) {
args[0](message.content);
args = [];
@@ -98,7 +98,7 @@ define(function(require, exports, module) {
TSPOSTIO.errorOpeningPath();
}
}
- break;
+ break;*/
case "indexDirectory":
if (message.success) {
TSPOSTIO.createDirectoryIndex(message.content);
@@ -334,14 +334,14 @@ define(function(require, exports, module) {
var listDirectory = function(dirPath) {
console.log("Listing directory: " + dirPath);
- var event = document.createEvent('CustomEvent');
- event.initCustomEvent("addon-message", true, true, {
- "detail": {
- "command": "listDirectory",
- "path": dirPath
+ listDirectoryPromise(dirPath).then( function(success) {
+ TSPOSTIO.listDirectory(success);
+ },
+ function(error) {
+ console.warn("Error: " + error);
+ TSPOSTIO.errorOpeningPath();
}
- });
- document.documentElement.dispatchEvent(event);
+ );
};
var deleteElement = function(path) {
@@ -490,15 +490,15 @@ define(function(require, exports, module) {
}
var getDirectoryMetaInformation = function(dirPath, readyCallback) {
- args = [readyCallback];
- var event = document.createEvent('CustomEvent');
- event.initCustomEvent("addon-message", true, true, {
- "detail": {
- "command": "listDirectory",
- "path": dirPath
+ console.log("getDirectoryMetaInformation: " + dirPath);
+ listDirectoryPromise(dirPath).then( function(success) {
+ readyCallback(success);
+ },
+ function(error) {
+ console.warn("Error: " + error);
+ TSPOSTIO.errorOpeningPath();
}
- });
- document.documentElement.dispatchEvent(event);
+ );
};
exports.focusWindow = focusWindow;