--- mozilla/build/unix/run-mozilla.sh.run-mozilla 2003-12-15 20:27:28 +0300 +++ mozilla/build/unix/run-mozilla.sh 2004-07-08 02:14:22 +0400 @@ -69,6 +69,10 @@ MOZ_DEFAULT_NAME="./${cmdname}-bin" MOZ_APPRUNNER_NAME="./mozilla-bin" MOZ_VIEWER_NAME="./viewer" MOZ_PROGRAM="" +MOZ_CLIENT_PROGRAM="${MOZ_DIST_BIN}/mozilla-xremote-client" + +ALREADY_RUNNING="" +RUNS="" exitcode=0 # @@ -155,6 +159,68 @@ moz_get_debugger() return 0 } ########################################################################## +check_running() { + #$MOZ_CLIENT_PROGRAM 'ping()' 2>/dev/null >/dev/null + RETURN_VAL=$(pidof $MOZ_PROGRAM) + if [ -z "$RETURN_VAL" ]; then + echo 0 + return 0 + else + echo 1 + return 1 + fi +} +########################################################################## +open_mail() { + if [ "${ALREADY_RUNNING}" -eq "1" ]; then + RUNS="$MOZ_CLIENT_PROGRAM xfeDoCommand(openInbox)" + else + RUNS="$MOZ_PROGRAM $*" + fi +} +########################################################################## +open_compose() { + if [ "${ALREADY_RUNNING}" -eq "1" ]; then + RUNS="$MOZ_CLIENT_PROGRAM xfeDoCommand(composeMessage)" + else + RUNS="$MOZ_PROGRAM $*" + fi +} +########################################################################## +open_browser() { + # If there is no command line argument at all then try to open a new + # window in an already running instance. + if [ "${ALREADY_RUNNING}" -eq "1" ] && [ -z "$1" ]; then + RUNS="$MOZ_CLIENT_PROGRAM xfeDoCommand(openBrowser)" + fi + + if [ "${ALREADY_RUNNING}" -eq "1" ] && [ -z "$RUNS" ]; then + echo $1 | grep -e '^-' 2>/dev/null > /dev/null + RETURN_VAL=$? + [ "${RETURN_VAL}" -eq "0" ] && RUNS="$prog ${1+"$@"}" + + # check to make sure that the command contains at least a :/ in it. + if [ -z "$RUNS" ]; then + echo $1 | grep -e ':/' 2>/dev/null > /dev/null + RETURN_VAL=$? + if [ "$RETURN_VAL" -eq "1" ]; then + # if it doesn't begin with a '/' and it exists when the pwd is + # prepended to it then append the full path + opt=$1 + echo $opt | grep -e '^/' 2>/dev/null > /dev/null + RETURN_VAL=$? + if [ "${RETURN_VAL}" -ne "0" ] && [ -e "$(pwd)/$opt" ]; then + opt="$(pwd)/$opt" + fi + RUNS="$MOZ_CLIENT_PROGRAM openurl($opt)" + else + # just pass it off if it looks like a url + RUNS="$MOZ_CLIENT_PROGRAM openurl($1,new-tab)" + fi + fi + fi +} +########################################################################## moz_run_program() { prog=$MOZ_PROGRAM @@ -191,7 +257,20 @@ moz_run_program() ## ## Run the program ## - "$prog" ${1+"$@"} + ALREADY_RUNNING=$(check_running) + RUNS= + + if [ "$1" = "-mail" ]; then + open_mail ${1+"$@"} + elif [ "$1" = "-compose" ]; then + open_compose ${1+"$@"} + else + open_browser $* + fi + + [ -n "$RUNS" ] || RUNS="$prog ${1+"$@"}" + + $RUNS exitcode=$? if [ "$DEBUG_CORE_FILES" ] then