Add Launch{Browser,Market,Email} support on Linux

Modern Linux desktop should implement a xdg-open program, that should open an
URL on the default desktop program.

The documentation of xdg-open says that we should supply xdg-open script on
our installation script for fallback purposes, but I don't think this is
really necessary: anyone using a reasonable recently DE on Linux should have
xdg-utils installed.
This commit is contained in:
Thiago Kenji Okada committed 2013-10-30 19:48:12 -02:00
1 parent 398137422c
commit a8fbcb6165
1 file changed
+10
+10
View File
@@ -11,6 +11,7 @@
#else
#include <pwd.h>
#include <unistd.h>
#include <stdlib.h>
#endif
#include <string>
@@ -228,6 +229,9 @@ void LaunchBrowser(const char *url)
{
#ifdef _WIN32
ShellExecute(NULL, "open", url, NULL, NULL, SW_SHOWNORMAL);
#elif __linux__
std::string command = std::string("xdg-open ") + url;
system(command.c_str());
#else
ILOG("Would have gone to %s but LaunchBrowser is not implemented on this platform", url);
#endif
@@ -237,6 +241,9 @@ void LaunchMarket(const char *url)
{
#ifdef _WIN32
ShellExecute(NULL, "open", url, NULL, NULL, SW_SHOWNORMAL);
#elif __linux__
std::string command = std::string("xdg-open ") + url;
system(command.c_str());
#else
ILOG("Would have gone to %s but LaunchMarket is not implemented on this platform", url);
#endif
@@ -246,6 +253,9 @@ void LaunchEmail(const char *email_address)
{
#ifdef _WIN32
ShellExecute(NULL, "open", (std::string("mailto:") + email_address).c_str(), NULL, NULL, SW_SHOWNORMAL);
#elif __linux__
std::string command = std::string("xdg-open mailto:") + email_address;
system(command.c_str());
#else
ILOG("Would have opened your email client for %s but LaunchEmail is not implemented on this platform", email_address);
#endif