From 7f517eca0bf87b7b9b666e36aeb8cc219f3d80be Mon Sep 17 00:00:00 2001 From: Chris Birk Date: Thu, 17 Dec 2015 21:54:04 -0600 Subject: check for soffice before removing export paths --- src/node/handler/PadMessageHandler.js | 2 ++ src/node/utils/Settings.js | 35 +++++++++++++++++++++++++++++++++++ 2 files changed, 37 insertions(+) (limited to 'src/node') diff --git a/src/node/handler/PadMessageHandler.js b/src/node/handler/PadMessageHandler.js index bf8737fc..f48be604 100644 --- a/src/node/handler/PadMessageHandler.js +++ b/src/node/handler/PadMessageHandler.js @@ -1234,6 +1234,8 @@ function handleClientReady(client, message) "serverTimestamp": new Date().getTime(), "userId": author, "abiwordAvailable": settings.abiwordAvailable(), + "sofficeAvailable": settings.sofficeAvailable(), + "exportAvailable": settings.exportAvailable(), "plugins": { "plugins": plugins.plugins, "parts": plugins.parts, diff --git a/src/node/utils/Settings.js b/src/node/utils/Settings.js index 325a997a..b765670a 100644 --- a/src/node/utils/Settings.js +++ b/src/node/utils/Settings.js @@ -222,6 +222,27 @@ exports.abiwordAvailable = function() } }; +exports.sofficeAvailable = function () { + if(exports.soffice != null) { + return os.type().indexOf("Windows") != -1 ? "withoutPDF": "yes"; + } else { + return "no"; + } +}; + +exports.exportAvailable = function () { + var abiword = exports.abiwordAvailable(); + var soffice = exports.sofficeAvailable(); + + if(abiword == "no" && soffice == "no") { + return "no"; + } else if ((abiword == "withoutPDF" && soffice == "no") || (abiword == "no" && soffice == "withoutPDF")) { + return "withoutPDF"; + } else { + return "yes"; + } +}; + // Provide git version if available exports.getGitCommit = function() { var version = ""; @@ -375,6 +396,20 @@ exports.reloadSettings = function reloadSettings() { } } + if(exports.soffice) { + fs.exists(exports.soffice, function (exists) { + if(!exists) { + var sofficeError = "SOffice does not exist at this path, check your settings file"; + + if(!exports.suppressErrorsInPadText) { + exports.defaultPadText = exports.defaultPadText + "\nError: " + sofficeError + suppressDisableMsg; + } + console.error(sofficeError); + exports.soffice = null; + } + }); + } + if (!exports.sessionKey) { try { exports.sessionKey = fs.readFileSync("./SESSIONKEY.txt","utf8"); -- cgit v1.2.3