summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBrendan Shanks <bshanks@audiovox.com>2014-03-20 19:37:04 -0700
committerJustin Dickow <jjdickow@gmail.com>2014-03-20 22:39:19 -0400
commitb7b81b4d3c7f41b86fef574bfd64bd1db96d6aad (patch)
tree16dd5e4a0876fbaae7a1476d2aea0de399a67151
parent51f087897c1a3326d15cfede64737924cad2e9ac (diff)
downloadsmartdevicelink-b7b81b4d3c7f41b86fef574bfd64bd1db96d6aad.tar.gz
Mac: use system() and osascript to launch the web HMI in Chrome
-rw-r--r--SDL_Core/src/appMain/main.cc20
1 files changed, 20 insertions, 0 deletions
diff --git a/SDL_Core/src/appMain/main.cc b/SDL_Core/src/appMain/main.cc
index 522c3d70f..465f18d28 100644
--- a/SDL_Core/src/appMain/main.cc
+++ b/SDL_Core/src/appMain/main.cc
@@ -163,11 +163,31 @@ if (stat(hmi_link.c_str(), &sb) == -1) {
return false;
}
+#ifdef OS_MACOSX
+ // On Mac, use system() to call osascript to start Chrome
+ const char kCommand[] = "osascript -e 'tell application \"Google Chrome\" to open \"%s\"'";
+ char *cmd;
+
+ asprintf(&cmd, kCommand, hmi_link.c_str());
+
+ int ret = system(cmd);
+
+ free(cmd);
+
+ if (ret != 0)
+ LOG4CXX_ERROR(logger, "Error launching HTML5 HMI: is Google Chrome installed?");
+
+ return (ret ? false : true);
+#elif OS_LINUX
+ // On Linux, use Execute() to start the browser
std::string kBin = kBrowser;
const char* const kParams[4] = {kBrowserName, kBrowserParams,
hmi_link.c_str(), NULL};
return Execute(kBin, kParams);
+#else
+#error "Add a way to launch the web HMI on your platform"
+#endif
}
#endif // WEB_HMI