summaryrefslogtreecommitdiff
path: root/shell/source/unix
diff options
context:
space:
mode:
authorJens-Heiner Rechtien <hr@openoffice.org>2004-05-10 12:08:30 +0000
committerJens-Heiner Rechtien <hr@openoffice.org>2004-05-10 12:08:30 +0000
commit3d5468a8590ff9b36ac16845782af118d07b7786 (patch)
treeb1a25cc0de333046e41959beb8ed5659bd215a48 /shell/source/unix
parent7ad3c9d7596e4208419c20629f349c4ad32946aa (diff)
INTEGRATION: CWS defaultbrowser (1.1.2); FILE ADDED
2004/04/27 07:59:44 obr 1.1.2.1: #i27120# new unix shell execute service implementation
Diffstat (limited to 'shell/source/unix')
-rwxr-xr-xshell/source/unix/misc/open-url.sh132
1 files changed, 132 insertions, 0 deletions
diff --git a/shell/source/unix/misc/open-url.sh b/shell/source/unix/misc/open-url.sh
new file mode 100755
index 000000000000..289b9f273cc3
--- /dev/null
+++ b/shell/source/unix/misc/open-url.sh
@@ -0,0 +1,132 @@
+#!/bin/sh
+
+# tries to locate the executable specified
+# as first parameter in the user's path.
+which() {
+ if [ ! -z "$1" ]; then
+ for i in `echo $PATH | sed -e 's/^:/.:/g' -e 's/:$/:./g' -e 's/::/:.:/g' -e 's/:/ /g'`; do
+ if [ -x "$i/$1" ]; then
+ echo "$i/$1"
+ break;
+ fi
+ done
+ fi
+}
+
+# checks for the original mozilla start script(s)
+# and restrict the "-remote" semantics to those.
+run_mozilla() {
+ if file "$1" | grep "script" > /dev/null && grep "NPL" "$1" > /dev/null; then
+ "$1" -remote 'ping()' 2>/dev/null >/dev/null
+ if [ $? -eq 2 ]; then
+ "$1" "$2" &
+ else
+ "$1" -remote "openURL($2, new-window)" &
+ fi
+ else
+ "$1" "$2" &
+ fi
+}
+
+# checks the browser value for a %s as defined in
+# http://www.catb.org/~esr/BROWSER/index.html
+run_browser() {
+ echo "$1|$2" | awk '
+{
+ FS="|";
+ $syscmd="";
+ if (index($1,"%s") > 0) {
+ $syscmd=sprintf($1,$2);
+ } else {
+ $syscmd=sprintf("%s \"%s\"",$1,$2);
+ }
+ system($syscmd " &");
+}' > /dev/null
+}
+
+# restore search path for dynamic loader to system defaults to
+# avoid version clashes of mozilla libraries shipped with OOo
+case `uname -s` in
+ AIX)
+ LIBPATH=$SYSTEM_LIBPATH
+ if [ -z "$LIBPATH" ]; then
+ unset LIBPATH SYSTEM_LIBPATH
+ else
+ export LIBPATH; unset SYSTEM_LIBPATH
+ fi
+ ;;
+
+ Darwin)
+ DYLD_LIBRARY_PATH=$SYSTEM_DYLD_LIBRARY_PATH
+ if [ -z "$DYLD_LIBRARY_PATH" ]; then
+ unset DYLD_LIBRARY_PATH SYSTEM_DYLD_LIBRARY_PATH
+ else
+ export DYLD_LIBRARY_PATH; unset SYSTEM_DYLD_LIBRARY_PATH
+ fi
+ ;;
+
+ HP-UX)
+ SHLIB_PATH=$SYSTEM_SHLIB_PATH
+ if [ -z "$SHLIB_PATH" ]; then
+ unset SHLIB_PATH SYSTEM_SHLIB_PATH
+ else
+ export SHLIB_PATH; unset SYSTEM_SHLIB_PATH
+ fi
+ ;;
+
+ IRIX*)
+ LD_LIBRARYN32_PATH=$SYSTEM_LD_LIBRARYN32_PATH
+ if [ -z "$LD_LIBRARYN32_PATH" ]; then
+ unset LD_LIBRARYN32_PATH SYSTEM_LD_LIBRARYN32_PATH
+ else
+ export LD_LIBRARYN32_PATH; unset $SYSTEM_LD_LIBRARYN32_PATH
+ fi
+ ;;
+
+ *)
+ LD_LIBRARY_PATH=$SYSTEM_LD_LIBRARY_PATH
+ if [ -z "$LD_LIBRARY_PATH" ]; then
+ unset LD_LIBRARY_PATH SYSTEM_LD_LIBRARY_PATH
+ else
+ export LD_LIBRARY_PATH; unset SYSTEM_LD_LIBRARY_PATH
+ fi
+ ;;
+esac
+
+# special handling for mailto: uris
+if echo $1 | grep '^mailto:' > /dev/null; then
+ # check $MAILER variable
+ if [ $MAILER ]; then
+ $MAILER $1 &
+ exit 0
+ else
+ # mozilla derivates may need -remote semantics
+ for i in mozilla netscape thunderbird; do
+ mailer=`which $i`
+ if [ ! -z $mailer ]; then
+ run_mozilla $mailer $1
+ exit 0
+ fi
+ done
+ # handle all non mozilla mail clients below
+ # ..
+ fi
+else
+ # check $BROWSER variable
+ if [ $BROWSER ]; then
+ $BROWSER $1 &
+ exit 0
+ else
+ # mozilla derivates may need -remote semantics
+ for i in mozilla netscape firefox; do
+ browser=`which $i`
+ if [ ! -z $browser ]; then
+ run_mozilla $browser $1
+ exit 0
+ fi
+ done
+ # handle all non mozilla browers below
+ # ..
+ fi
+fi
+exit 1