aboutsummaryrefslogtreecommitdiff
path: root/backends/networking/browser
diff options
context:
space:
mode:
Diffstat (limited to 'backends/networking/browser')
-rw-r--r--backends/networking/browser/openurl-android.cpp35
-rw-r--r--backends/networking/browser/openurl-default.cpp36
-rw-r--r--backends/networking/browser/openurl-osx.cpp49
-rw-r--r--backends/networking/browser/openurl-posix.cpp77
-rw-r--r--backends/networking/browser/openurl-windows.cpp42
-rw-r--r--backends/networking/browser/openurl.h41
6 files changed, 280 insertions, 0 deletions
diff --git a/backends/networking/browser/openurl-android.cpp b/backends/networking/browser/openurl-android.cpp
new file mode 100644
index 0000000000..64e683238b
--- /dev/null
+++ b/backends/networking/browser/openurl-android.cpp
@@ -0,0 +1,35 @@
+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the legal property of its developers, whose names
+ * are too numerous to list here. Please refer to the COPYRIGHT
+ * file distributed with this source distribution.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ */
+
+#include "backends/networking/browser/openurl.h"
+#include "backends/platform/android/jni.h"
+
+namespace Networking {
+namespace Browser {
+
+bool openUrl(const Common::String &url) {
+ return JNI::openUrl(url.c_str());
+}
+
+} // End of namespace Browser
+} // End of namespace Networking
+
diff --git a/backends/networking/browser/openurl-default.cpp b/backends/networking/browser/openurl-default.cpp
new file mode 100644
index 0000000000..c430953196
--- /dev/null
+++ b/backends/networking/browser/openurl-default.cpp
@@ -0,0 +1,36 @@
+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the legal property of its developers, whose names
+ * are too numerous to list here. Please refer to the COPYRIGHT
+ * file distributed with this source distribution.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ */
+
+#include "backends/networking/browser/openurl.h"
+#include "common/textconsole.h"
+
+namespace Networking {
+namespace Browser {
+
+bool openUrl(const Common::String &url) {
+ warning("Networking::Browser::openUrl(): not implemented");
+ return false;
+}
+
+} // End of namespace Browser
+} // End of namespace Networking
+
diff --git a/backends/networking/browser/openurl-osx.cpp b/backends/networking/browser/openurl-osx.cpp
new file mode 100644
index 0000000000..8d786d7fd2
--- /dev/null
+++ b/backends/networking/browser/openurl-osx.cpp
@@ -0,0 +1,49 @@
+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the legal property of its developers, whose names
+ * are too numerous to list here. Please refer to the COPYRIGHT
+ * file distributed with this source distribution.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ */
+
+#define FORBIDDEN_SYMBOL_ALLOW_ALL
+
+#include "backends/networking/browser/openurl.h"
+#include <CoreFoundation/CFBundle.h>
+#include <ApplicationServices/ApplicationServices.h>
+
+namespace Networking {
+namespace Browser {
+
+using namespace std;
+
+bool openUrl(const Common::String &url) {
+ CFURLRef urlRef = CFURLCreateWithBytes (
+ NULL,
+ (UInt8*)url.c_str(),
+ url.size(),
+ kCFStringEncodingASCII,
+ NULL
+ );
+ int result = LSOpenCFURLRef(urlRef, 0);
+ CFRelease(urlRef);
+ return result == 0;
+}
+
+} // End of namespace Browser
+} // End of namespace Networking
+
diff --git a/backends/networking/browser/openurl-posix.cpp b/backends/networking/browser/openurl-posix.cpp
new file mode 100644
index 0000000000..429a379fcf
--- /dev/null
+++ b/backends/networking/browser/openurl-posix.cpp
@@ -0,0 +1,77 @@
+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the legal property of its developers, whose names
+ * are too numerous to list here. Please refer to the COPYRIGHT
+ * file distributed with this source distribution.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ */
+
+#define FORBIDDEN_SYMBOL_ALLOW_ALL
+
+#include "backends/networking/browser/openurl.h"
+#include "common/textconsole.h"
+#include <stdlib.h>
+
+namespace Networking {
+namespace Browser {
+
+namespace {
+bool launch(const Common::String client, const Common::String &url) {
+ // FIXME: system's input must be heavily escaped
+ // well, when url's specified by user
+ // it's OK now (urls are hardcoded somewhere in GUI)
+ Common::String cmd = client + " " + url;
+ return (system(cmd.c_str()) != -1);
+}
+}
+
+bool openUrl(const Common::String &url) {
+ // inspired by Qt's "qdesktopservices_x11.cpp"
+
+ // try "standards"
+ if (launch("xdg-open", url))
+ return true;
+ if (launch(getenv("DEFAULT_BROWSER"), url))
+ return true;
+ if (launch(getenv("BROWSER"), url))
+ return true;
+
+ // try desktop environment specific tools
+ if (launch("gnome-open", url)) // gnome
+ return true;
+ if (launch("kfmclient openURL", url)) // kde
+ return true;
+ if (launch("exo-open", url)) // xfce
+ return true;
+
+ // try browser names
+ if (launch("firefox", url))
+ return true;
+ if (launch("mozilla", url))
+ return true;
+ if (launch("netscape", url))
+ return true;
+ if (launch("opera", url))
+ return true;
+
+ warning("Networking::Browser::openUrl() (POSIX) failed to open URL");
+ return false;
+}
+
+} // End of namespace Browser
+} // End of namespace Networking
+
diff --git a/backends/networking/browser/openurl-windows.cpp b/backends/networking/browser/openurl-windows.cpp
new file mode 100644
index 0000000000..b78c9fa7ed
--- /dev/null
+++ b/backends/networking/browser/openurl-windows.cpp
@@ -0,0 +1,42 @@
+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the legal property of its developers, whose names
+ * are too numerous to list here. Please refer to the COPYRIGHT
+ * file distributed with this source distribution.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ */
+
+#include "backends/networking/browser/openurl.h"
+#include "common/textconsole.h"
+#include <windows.h>
+#include <shellapi.h>
+
+namespace Networking {
+namespace Browser {
+
+bool openUrl(const Common::String &url) {
+ const uint64 result = (uint64)ShellExecute(0, 0, /*(wchar_t*)nativeFilePath.utf16()*/url.c_str(), 0, 0, SW_SHOWNORMAL);
+ // ShellExecute returns a value greater than 32 if successful
+ if (result <= 32) {
+ warning("ShellExecute failed: error = %u", result);
+ return false;
+ }
+ return true;
+}
+
+} // End of namespace Browser
+} // End of namespace Networking
diff --git a/backends/networking/browser/openurl.h b/backends/networking/browser/openurl.h
new file mode 100644
index 0000000000..15b4bf385b
--- /dev/null
+++ b/backends/networking/browser/openurl.h
@@ -0,0 +1,41 @@
+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the legal property of its developers, whose names
+ * are too numerous to list here. Please refer to the COPYRIGHT
+ * file distributed with this source distribution.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ */
+
+#ifndef NETWORKING_BROWSER_OPENURL_H
+#define NETWORKING_BROWSER_OPENURL_H
+
+#include "common/str.h"
+
+namespace Networking {
+namespace Browser {
+
+/**
+ * Opens URL in default browser (if available on the target system).
+ *
+ * Returns true on success.
+ */
+bool openUrl(const Common::String &url);
+
+} // End of namespace Browser
+} // End of namespace Networking
+
+#endif /*NETWORKING_BROWSER_OPENURL_H*/