From 833f49cd6af894c8e3f323b4918acaae41229495 Mon Sep 17 00:00:00 2001 From: kervala Date: Sat, 21 Nov 2015 17:36:44 +0100 Subject: [PATCH] Changed: Give priority to xdg-open (if present) to open URLs under Linux --- code/nel/src/misc/common.cpp | 41 +++++++++++++++++++++++++----------- 1 file changed, 29 insertions(+), 12 deletions(-) diff --git a/code/nel/src/misc/common.cpp b/code/nel/src/misc/common.cpp index 83f1916d9..ceaae3d4b 100644 --- a/code/nel/src/misc/common.cpp +++ b/code/nel/src/misc/common.cpp @@ -1078,9 +1078,36 @@ static bool openDocWithExtension (const char *document, const char *ext) { return true; } +#elif defined(NL_OS_MAC) + return launchProgram("open", document); #else - // TODO: implement for Linux and Mac OS X - nlunreferenced(document); + std::string command = "/usr/bin/xdg-open"; + + if (!CFile::fileExists(command)) + { + if (strcmp(ext, "htm") == 0) + { + command = "/etc/alternatives/x-www-browser"; + + if (!CFile::fileExists(command)) + { + command.clear(); + } + } + else + { + command.clear(); + } + } + + if (command.empty()) + { + nlwarning("Unable to open %s", document); + return false; + } + + return launchProgram(command, document); + #endif // NL_OS_WINDOWS return false; @@ -1088,17 +1115,7 @@ static bool openDocWithExtension (const char *document, const char *ext) bool openURL (const char *url) { -#ifdef NL_OS_WINDOWS return openDocWithExtension(url, "htm"); -#elif defined(NL_OS_MAC) - return launchProgram("open", url); -#elif defined(NL_OS_UNIX) - return launchProgram("/etc/alternatives/x-www-browser", url); -#else - nlwarning("openURL() is not implemented for this OS"); -#endif // NL_OS_WINDOWS - - return false; } bool openDoc (const char *document)