summaryrefslogtreecommitdiff
path: root/shell/source/unix/misc
diff options
context:
space:
mode:
Diffstat (limited to 'shell/source/unix/misc')
-rwxr-xr-xshell/source/unix/misc/cde-open-url.sh13
-rw-r--r--shell/source/unix/misc/gnome-open-url.c146
-rw-r--r--shell/source/unix/misc/gnome-open-url.sh6
-rwxr-xr-xshell/source/unix/misc/kde-open-url.sh10
-rw-r--r--shell/source/unix/misc/makefile.mk90
-rw-r--r--shell/source/unix/misc/open-url.c172
-rw-r--r--shell/source/unix/misc/open-url.def1
-rwxr-xr-xshell/source/unix/misc/open-url.sh93
-rw-r--r--shell/source/unix/misc/senddoc.c204
-rw-r--r--shell/source/unix/misc/senddoc.def1
-rw-r--r--shell/source/unix/misc/senddoc.sh401
-rw-r--r--shell/source/unix/misc/uri-encode.c50
12 files changed, 1187 insertions, 0 deletions
diff --git a/shell/source/unix/misc/cde-open-url.sh b/shell/source/unix/misc/cde-open-url.sh
new file mode 100755
index 000000000000..c0c38145d6ee
--- /dev/null
+++ b/shell/source/unix/misc/cde-open-url.sh
@@ -0,0 +1,13 @@
+#!/bin/sh
+
+if [ -x /usr/bin/mktemp ]
+then
+ TMPFILE=`mktemp -t open-url.XXXXXX`
+else
+ DTTMPDIR=`xrdb -query | grep DtTmpDir`
+ TMPFILE=${DTTMPDIR:-$HOME/.dt/tmp}/open-url.$$
+fi
+
+if [ -z "$TMPFILE" ]; then exit 1; fi
+( echo "$1" > "$TMPFILE"; dtaction Open "$TMPFILE"; rm -f "$TMPFILE" ) &
+exit 0
diff --git a/shell/source/unix/misc/gnome-open-url.c b/shell/source/unix/misc/gnome-open-url.c
new file mode 100644
index 000000000000..3bd7a61e6546
--- /dev/null
+++ b/shell/source/unix/misc/gnome-open-url.c
@@ -0,0 +1,146 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org 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 Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+#include <stdlib.h>
+#include <stdio.h>
+#include <dlfcn.h>
+#include <string.h>
+#include <unistd.h>
+
+typedef int gboolean;
+typedef char gchar;
+typedef struct _GError GError;
+
+struct _GError
+{
+ int domain;
+ int code;
+ char *message;
+};
+
+typedef enum {
+ GNOME_VFS_OK
+} GnomeVFSResult;
+
+
+/*
+ * HACK: avoid error messages caused by not setting a GNOME program name
+ */
+
+gchar* gnome_gconf_get_gnome_libs_settings_relative (const gchar *subkey)
+{
+ void* handle = dlopen("libglib-2.0.so.0", RTLD_LAZY);
+
+ (void)subkey; /* avoid warning due to unused parameter */
+
+ if( NULL != handle )
+ {
+ gchar* (* g_strdup)(const gchar*) = (gchar* (*)(const gchar*)) dlsym(handle, "g_strdup");
+
+ if( NULL != g_strdup)
+ return g_strdup("/apps/gnome-settings/gnome-open-url");
+ }
+
+ return NULL;
+}
+
+/*
+ * Wrapper function which extracs gnome_url_show from libgnome
+ */
+
+gboolean gnome_url_show (const char *url, GError **error)
+{
+ void* handle = dlopen("libgnomevfs-2.so.0", RTLD_LAZY);
+ gboolean ret = 0;
+
+ (void)error; /* avoid warning due to unused parameter */
+
+ if( NULL != handle )
+ {
+ gboolean (* init) (void) =
+ (gboolean (*) (void)) dlsym(handle, "gnome_vfs_init");
+
+ if( NULL != init && init() )
+ {
+ GnomeVFSResult (* func) (const char *url) =
+ (GnomeVFSResult (*) (const char *)) dlsym(handle, "gnome_vfs_url_show");
+
+ if( NULL != func )
+ ret = (GNOME_VFS_OK == func(url));
+ }
+
+ dlclose(handle);
+ }
+
+ return ret;
+}
+
+/*
+ * The intended use of this tool is to pass the argument to
+ * the gnome_show_url function of libgnome2.
+ */
+
+int main(int argc, char *argv[] )
+{
+ GError *error = NULL;
+ char *fallback;
+ char *index;
+
+ if( argc != 2 )
+ {
+ fprintf( stderr, "Usage: gnome-open-url <uri>\n" );
+ return -1;
+ }
+
+ if( gnome_url_show(argv[1], &error) )
+ {
+ return 0;
+ }
+
+ /*
+ * launch open-url command by replacing gnome-open-url from
+ * the command line. This is the fallback when running on
+ * remote machines with no GNOME installed.
+ */
+
+ fallback = strdup(argv[0]);
+ index = strstr(fallback, "gnome-open-url");
+ if ( NULL != index )
+ {
+ char *args[3];
+ strncpy(index, "open-url", 9);
+ args[0] = fallback;
+ args[1] = argv[1];
+ args[2] = NULL;
+ return execv(fallback, args);
+ }
+
+ return -1;
+}
+
+
+
diff --git a/shell/source/unix/misc/gnome-open-url.sh b/shell/source/unix/misc/gnome-open-url.sh
new file mode 100644
index 000000000000..ab730d169a49
--- /dev/null
+++ b/shell/source/unix/misc/gnome-open-url.sh
@@ -0,0 +1,6 @@
+#!/bin/sh
+
+# use xdg-open or gnome-open if available
+xdg-open "$1" 2>/dev/null || gnome-open "$1" 2>/dev/null || "$0.bin" $1
+
+exit 0
diff --git a/shell/source/unix/misc/kde-open-url.sh b/shell/source/unix/misc/kde-open-url.sh
new file mode 100755
index 000000000000..fa05bdecbda4
--- /dev/null
+++ b/shell/source/unix/misc/kde-open-url.sh
@@ -0,0 +1,10 @@
+#!/bin/sh
+
+# special handling for mailto: uris
+if echo $1 | grep '^mailto:' > /dev/null; then
+ kmailservice "$1" &
+else
+ kfmclient openURL "$1" &
+fi
+
+exit 0
diff --git a/shell/source/unix/misc/makefile.mk b/shell/source/unix/misc/makefile.mk
new file mode 100644
index 000000000000..67fcc708c615
--- /dev/null
+++ b/shell/source/unix/misc/makefile.mk
@@ -0,0 +1,90 @@
+#*************************************************************************
+#
+# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+#
+# Copyright 2000, 2010 Oracle and/or its affiliates.
+#
+# OpenOffice.org - a multi-platform office productivity suite
+#
+# This file is part of OpenOffice.org.
+#
+# OpenOffice.org is free software: you can redistribute it and/or modify
+# it under the terms of the GNU Lesser General Public License version 3
+# only, as published by the Free Software Foundation.
+#
+# OpenOffice.org 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 Lesser General Public License version 3 for more details
+# (a copy is included in the LICENSE file that accompanied this code).
+#
+# You should have received a copy of the GNU Lesser General Public License
+# version 3 along with OpenOffice.org. If not, see
+# <http://www.openoffice.org/license.html>
+# for a copy of the LGPLv3 License.
+#
+#*************************************************************************
+
+PRJ=..$/..$/..
+PRJNAME=shell
+TARGET=misc
+
+LIBTARGET=NO
+TARGETTYPE=CUI
+NO_DEFAULT_STL=TRUE
+LIBSALCPPRT=$(0)
+
+# --- Settings -----------------------------------------------------
+
+.INCLUDE : settings.mk
+
+# --- Files --------------------------------------------------------
+
+SCRIPTFILES = \
+ $(BIN)$/senddoc \
+ $(BIN)$/open-url \
+ $(BIN)$/cde-open-url \
+ $(BIN)$/gnome-open-url \
+ $(BIN)$/kde-open-url
+
+.IF "$(GUI)" == "OS2"
+
+APP1TARGET = open-url
+APP1OBJS = \
+ $(OBJ)$/open-url.obj \
+ open-url.def
+APP1LIBS =
+
+APP2TARGET = senddoc
+APP2OBJS = \
+ $(OBJ)$/senddoc.obj \
+ senddoc.def
+APP2LIBS =
+APP2STDLIBS =
+
+.ELSE
+
+APP1TARGET = gnome-open-url.bin
+APP1OBJS = \
+ $(OBJ)$/gnome-open-url.obj
+APP1LIBS =
+.IF "$(OS)"!="FREEBSD" && "$(OS)"!="NETBSD"
+APP1STDLIBS=-ldl
+.ENDIF
+
+APP2TARGET = uri-encode
+APP2OBJS = $(OBJ)$/uri-encode.obj
+APP2LIBS =
+APP2STDLIBS =
+
+OBJFILES = $(APP1OBJS) $(APP2OBJS)
+.ENDIF
+
+# --- Targets ------------------------------------------------------
+
+.INCLUDE : target.mk
+
+ALLTAR : $(SCRIPTFILES) $(AWKFILES)
+
+$(SCRIPTFILES) : $$(@:f:+".sh")
+ @tr -d "\015" < $(@:f:+".sh") > $@
diff --git a/shell/source/unix/misc/open-url.c b/shell/source/unix/misc/open-url.c
new file mode 100644
index 000000000000..91f4aeaff398
--- /dev/null
+++ b/shell/source/unix/misc/open-url.c
@@ -0,0 +1,172 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org 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 Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+#include <stdlib.h>
+#include <stdio.h>
+#include <string.h>
+#include <unistd.h>
+#include <process.h>
+#include <time.h>
+
+#define INCL_DOS
+#define INCL_DOSERRORS
+#define INCL_PM
+#include <os2.h>
+
+// OOo uses popen() to start us, so we cannot show PM dialogs.
+// log message to disk.
+void logMessage( char* msg)
+{
+ PPIB pib;
+ CHAR szApplicationName[_MAX_PATH];
+ CHAR szDrive[_MAX_PATH];
+ CHAR szDir[_MAX_PATH];
+ CHAR szFileName[_MAX_PATH];
+ CHAR szExt[_MAX_PATH];
+ FILE* log;
+ time_t timeOfDay;
+ struct tm* localTime;
+
+ // get executable fullpath
+ DosGetInfoBlocks(NULL, &pib);
+ DosQueryModuleName(pib->pib_hmte, sizeof(szApplicationName), szApplicationName);
+ _splitpath( szApplicationName, szDrive, szDir, szFileName, szExt );
+ // log name
+ _makepath( szApplicationName, szDrive, szDir, szFileName, (".LOG") );
+ log = fopen( szApplicationName, "a");
+ if (!log)
+ return;
+ time( &timeOfDay);
+ localTime = localtime( &timeOfDay);
+ fprintf( log, "%04d/%02d/%02d %02d:%02d:%02d %s\n",
+ localTime->tm_year+1900, localTime->tm_mon+1, localTime->tm_mday,
+ localTime->tm_hour, localTime->tm_min, localTime->tm_sec, msg);
+ fclose( log);
+}
+
+// dump comand line arguments
+void dumpArgs( int argc, char *argv[] )
+{
+ int i;
+
+ logMessage( "Start of command line arguments dump:");
+ for( i=0; i<argc; i++)
+ logMessage( argv[i]);
+}
+
+/*
+ * The intended use of this tool is to pass the argument to
+ * the default URL exe.
+ */
+int main(int argc, char *argv[] )
+{
+ APIRET rc;
+ RESULTCODES result = {0};
+ char szAppFromINI[_MAX_PATH];
+ char szDirFromINI[_MAX_PATH];
+ char szCmdLine[1024];
+ char szFail[ _MAX_PATH];
+ ULONG ulSID;
+ PID pid;
+
+ // check parameters
+ if (argc != 2)
+ {
+ logMessage( "Usage: open-url <url>");
+ dumpArgs( argc, argv);
+ return -1;
+ }
+
+ // check configuration
+ rc = PrfQueryProfileString(HINI_USER, "WPURLDEFAULTSETTINGS",
+ "DefaultBrowserExe", "",
+ szAppFromINI, sizeof(szAppFromINI));
+ rc = PrfQueryProfileString(HINI_USER, "WPURLDEFAULTSETTINGS",
+ "DefaultWorkingDir", "",
+ szDirFromINI, sizeof(szDirFromINI));
+ if (*szAppFromINI == 0 || *szDirFromINI == 0)
+ {
+ logMessage( "Unable to find default url handler in USER.INI; exiting.");
+ dumpArgs( argc, argv);
+ return -1;
+ }
+
+ // get default parameter list
+ rc = PrfQueryProfileString(HINI_USER, "WPURLDEFAULTSETTINGS",
+ "DefaultParameters", "",
+ szCmdLine, sizeof(szCmdLine));
+ strcat( szCmdLine, " ");
+ strcat( szCmdLine, argv[1]);
+
+ // change default directory
+ _chdir( szDirFromINI);
+
+ // start default handler
+ STARTDATA SData;
+ CHAR szObjBuf[CCHMAXPATH];
+
+ SData.Length = sizeof(STARTDATA);
+ SData.Related = SSF_RELATED_INDEPENDENT;
+ SData.FgBg = (1) ? SSF_FGBG_FORE : SSF_FGBG_BACK;
+ SData.TraceOpt = SSF_TRACEOPT_NONE;
+
+ SData.PgmTitle = (PSZ)szAppFromINI;
+
+ SData.PgmName = (PSZ)szAppFromINI;
+ SData.PgmInputs = (PSZ)szCmdLine;
+
+ SData.TermQ = NULL;
+ SData.Environment = 0;
+ SData.InheritOpt = SSF_INHERTOPT_PARENT;
+ SData.SessionType = SSF_TYPE_PM;
+ SData.IconFile = 0;
+ SData.PgmHandle = 0;
+
+ SData.PgmControl = SSF_CONTROL_VISIBLE;
+
+ SData.InitXPos = 30;
+ SData.InitYPos = 40;
+ SData.InitXSize = 200;
+ SData.InitYSize = 140;
+ SData.Reserved = 0;
+ SData.ObjectBuffer = szFail;
+ SData.ObjectBuffLen = (ULONG)sizeof(szFail);
+
+ rc = DosStartSession( &SData, &ulSID, &pid);
+ // show error dialog in case of problems
+ if (rc != NO_ERROR && rc != ERROR_SMG_START_IN_BACKGROUND) {
+ char szMessage[ _MAX_PATH*2];
+ sprintf( szMessage, "Execution failed! rc: %d, failing module:%s", rc, szFail);
+ logMessage( szMessage);
+ dumpArgs( argc, argv);
+ return -1;
+ }
+
+ // ok
+ return 0;
+}
+
diff --git a/shell/source/unix/misc/open-url.def b/shell/source/unix/misc/open-url.def
new file mode 100644
index 000000000000..3a26831e2a65
--- /dev/null
+++ b/shell/source/unix/misc/open-url.def
@@ -0,0 +1 @@
+NAME open-url WINDOWAPI
diff --git a/shell/source/unix/misc/open-url.sh b/shell/source/unix/misc/open-url.sh
new file mode 100755
index 000000000000..449af5915ce8
--- /dev/null
+++ b/shell/source/unix/misc/open-url.sh
@@ -0,0 +1,93 @@
+#!/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" -a ! -d "$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
+}
+
+# special handling for mailto: uris
+if echo $1 | grep '^mailto:' > /dev/null; then
+ # check for xdg-email
+ mailer=`which xdg-email`
+ if [ ! -z "$mailer" ]; then
+ $mailer "$1" &
+ exit 0
+ fi
+ # check $MAILER variable
+ if [ ! -z "$MAILER" ]; then
+ $MAILER "$1" &
+ exit 0
+ fi
+ # mozilla derivates may need -remote semantics
+ for i in thunderbird mozilla netscape; do
+ mailer=`which $i`
+ if [ ! -z "$mailer" ]; then
+ run_mozilla "$mailer" "$1"
+ exit 0
+ fi
+ done
+ # handle all non mozilla mail clients below
+ # ..
+else
+ # check for xdg-open
+ browser=`which xdg-open`
+ if [ ! -z "$browser" ]; then
+ $browser "$1" &
+ exit 0
+ fi
+ # check $BROWSER variable
+ if [ ! -z "$BROWSER" ]; then
+ $BROWSER "$1" &
+ exit 0
+ fi
+ # mozilla derivates may need -remote semantics
+ for i in firefox mozilla netscape; do
+ browser=`which $i`
+ if [ ! -z "$browser" ]; then
+ run_mozilla "$browser" "$1"
+ exit 0
+ fi
+ done
+ # handle all non mozilla browers below
+ # ..
+fi
+exit 1
diff --git a/shell/source/unix/misc/senddoc.c b/shell/source/unix/misc/senddoc.c
new file mode 100644
index 000000000000..5a21ef1ec50f
--- /dev/null
+++ b/shell/source/unix/misc/senddoc.c
@@ -0,0 +1,204 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org 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 Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+#include <stdlib.h>
+#include <stdio.h>
+#include <string.h>
+#include <unistd.h>
+#include <process.h>
+#include <time.h>
+
+#define INCL_DOS
+#define INCL_DOSERRORS
+#define INCL_PM
+#include <os2.h>
+
+// OOo uses popen() to start us, so we cannot show PM dialogs.
+// log message to disk.
+void logMessage( char* msg)
+{
+ PPIB pib;
+ CHAR szApplicationName[_MAX_PATH];
+ CHAR szDrive[_MAX_PATH];
+ CHAR szDir[_MAX_PATH];
+ CHAR szFileName[_MAX_PATH];
+ CHAR szExt[_MAX_PATH];
+ FILE* log;
+ time_t timeOfDay;
+ struct tm* localTime;
+
+ // get executable fullpath
+ DosGetInfoBlocks(NULL, &pib);
+ DosQueryModuleName(pib->pib_hmte, sizeof(szApplicationName), szApplicationName);
+ _splitpath( szApplicationName, szDrive, szDir, szFileName, szExt );
+ // log name
+ _makepath( szApplicationName, szDrive, szDir, szFileName, (".LOG") );
+ log = fopen( szApplicationName, "a");
+ if (!log)
+ return;
+ time( &timeOfDay);
+ localTime = localtime( &timeOfDay);
+ fprintf( log, "%04d/%02d/%02d %02d:%02d:%02d %s\n",
+ localTime->tm_year+1900, localTime->tm_mon+1, localTime->tm_mday,
+ localTime->tm_hour, localTime->tm_min, localTime->tm_sec, msg);
+ fclose( log);
+}
+
+// dump comand line arguments
+void dumpArgs( int argc, char *argv[] )
+{
+ int i;
+
+ logMessage( "Start of command line arguments dump:");
+ for( i=0; i<argc; i++)
+ logMessage( argv[i]);
+}
+
+/*
+ * The intended use of this tool is to pass the argument to
+ * the default mail handler.
+ */
+int main(int argc, char *argv[] )
+{
+ APIRET rc;
+ RESULTCODES result = {0};
+ char szAppFromINI[_MAX_PATH];
+ char szDirFromINI[_MAX_PATH];
+ char szCmdLine[1024];
+ char szFail[ _MAX_PATH];
+ ULONG ulSID;
+ PID pid;
+ int i;
+ BOOL bMailClient = FALSE;
+
+ // check parameters
+ if (argc < 5)
+ {
+ logMessage( "Usage: senddoc --mailclient <client> --attach <uri>");
+ dumpArgs( argc, argv);
+ return -1;
+ }
+
+ // check configuration
+ rc = PrfQueryProfileString(HINI_USER, "WPURLDEFAULTSETTINGS",
+ "DefaultMailExe", "",
+ szAppFromINI, sizeof(szAppFromINI));
+ rc = PrfQueryProfileString(HINI_USER, "WPURLDEFAULTSETTINGS",
+ "DefaultMailWorkingDir", "",
+ szDirFromINI, sizeof(szDirFromINI));
+ if (*szAppFromINI == 0 || *szDirFromINI == 0)
+ {
+ logMessage( "Unable to find default mail handler in USER.INI; exiting.");
+ dumpArgs( argc, argv);
+ return -1;
+ }
+
+ // get default parameter list, at leat -compose is required
+ rc = PrfQueryProfileString(HINI_USER, "WPURLDEFAULTSETTINGS",
+ "DefaultMailParameters", "",
+ szCmdLine, sizeof(szCmdLine));
+ if (strstr( szCmdLine, "-compose") == 0)
+ strcat( szCmdLine, " -compose"); // add if missing!
+
+ // parse cmdline arguments
+ for( i=1; i<argc; i++)
+ {
+ if (!strcmp( argv[i], "--mailclient")) {
+ // we support only Thunderbird/Mozilla command line options, check exe name
+ if (strstr( argv[i+1], "thunderbird") == 0
+ && strstr( argv[i+1], "mozilla") == 0
+ && strstr( argv[i+1], "seamonkey") == 0)
+ {
+ logMessage( "Only Thunderbird/Mozilla is currently supported. Exiting.");
+ dumpArgs( argc, argv);
+ return -1;
+ }
+ // mail client found
+ bMailClient = TRUE;
+ i++;
+ } else if (!strcmp( argv[i], "--attach")) {
+ strcat( szCmdLine, " attachment=file://");
+ strcat( szCmdLine, argv[i+1]);
+ i++;
+ }
+ // ignore other options (BTW currently none)
+ }
+ if (bMailClient == FALSE)
+ {
+ logMessage( "No mail client specified. Exiting.");
+ dumpArgs( argc, argv);
+ return -1;
+ }
+
+ // change default directory
+ _chdir( szDirFromINI);
+
+ // start default handler
+ STARTDATA SData;
+ CHAR szObjBuf[CCHMAXPATH];
+
+ SData.Length = sizeof(STARTDATA);
+ SData.Related = SSF_RELATED_INDEPENDENT;
+ SData.FgBg = (1) ? SSF_FGBG_FORE : SSF_FGBG_BACK;
+ SData.TraceOpt = SSF_TRACEOPT_NONE;
+
+ SData.PgmTitle = (PSZ)szAppFromINI;
+
+ SData.PgmName = (PSZ)szAppFromINI;
+ SData.PgmInputs = (PSZ)szCmdLine;
+
+ SData.TermQ = NULL;
+ SData.Environment = 0;
+ SData.InheritOpt = SSF_INHERTOPT_PARENT;
+ SData.SessionType = SSF_TYPE_PM;
+ SData.IconFile = 0;
+ SData.PgmHandle = 0;
+
+ SData.PgmControl = SSF_CONTROL_VISIBLE;
+
+ SData.InitXPos = 30;
+ SData.InitYPos = 40;
+ SData.InitXSize = 200;
+ SData.InitYSize = 140;
+ SData.Reserved = 0;
+ SData.ObjectBuffer = szFail;
+ SData.ObjectBuffLen = (ULONG)sizeof(szFail);
+
+ rc = DosStartSession( &SData, &ulSID, &pid);
+ // show error dialog in case of problems
+ if (rc != NO_ERROR && rc != ERROR_SMG_START_IN_BACKGROUND) {
+ char szMessage[ _MAX_PATH*2];
+ sprintf( szMessage, "Execution failed! rc: %d, failing module:%s", rc, szFail);
+ logMessage( szMessage);
+ dumpArgs( argc, argv);
+ return -1;
+ }
+
+ // ok
+ return 0;
+}
+
diff --git a/shell/source/unix/misc/senddoc.def b/shell/source/unix/misc/senddoc.def
new file mode 100644
index 000000000000..0abf1553a4a9
--- /dev/null
+++ b/shell/source/unix/misc/senddoc.def
@@ -0,0 +1 @@
+NAME senddoc WINDOWAPI
diff --git a/shell/source/unix/misc/senddoc.sh b/shell/source/unix/misc/senddoc.sh
new file mode 100644
index 000000000000..3d2690379134
--- /dev/null
+++ b/shell/source/unix/misc/senddoc.sh
@@ -0,0 +1,401 @@
+#!/bin/sh
+URI_ENCODE="`dirname $0`/uri-encode"
+FOPTS=""
+
+# linux file utility needs -L option to resolve symlinks
+if [ "`uname -s`" = "Linux" ]
+then
+ FOPTS="-L"
+fi
+
+# do not confuse the system mail clients with OOo and Java libraries
+unset LD_LIBRARY_PATH
+
+# 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" -a ! -d "$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() {
+ # find mozilla script in PATH if necessary
+ if [ "`basename $1`" = "$1" ]; then
+ moz=`which $1`
+ else
+ moz=$1
+ fi
+
+ if file $FOPTS "$moz" | grep "script" > /dev/null && grep "[NM]PL" "$moz" > /dev/null; then
+ "$moz" -remote 'ping()' 2>/dev/null >/dev/null
+ if [ $? -eq 2 ]; then
+ "$1" -compose "$2" &
+ else
+ "$1" -remote "xfeDoCommand(composeMessage,$2)" &
+ fi
+ else
+ "$1" -compose "$2" &
+ fi
+}
+
+if [ "$1" = "--mailclient" ]; then
+ shift
+ MAILER=$1
+ shift
+fi
+
+# autodetect mail client from executable name
+case `basename "$MAILER" | sed 's/-.*$//'` in
+
+ iceape | mozilla | netscape | seamonkey | icedove | thunderbird)
+
+ while [ "$1" != "" ]; do
+ case $1 in
+ --to)
+ TO=${TO:-}${TO:+,}$2
+ shift
+ ;;
+ --cc)
+ CC=${CC:-}${CC:+,}$2
+ shift
+ ;;
+ --bcc)
+ BCC=${BCC:-}${BCC:+,}$2
+ shift
+ ;;
+ --subject)
+ SUBJECT=$2
+ shift
+ ;;
+ --body)
+ BODY=$2
+ shift
+ ;;
+ --attach)
+ ATTACH=${ATTACH:-}${ATTACH:+,}`echo "file://$2" | ${URI_ENCODE}`
+ shift
+ ;;
+ *)
+ ;;
+ esac
+ shift;
+ done
+
+ if [ "$TO" != "" ]; then
+ COMMAND=${COMMAND:-}${COMMAND:+,}to=${TO}
+ fi
+ if [ "$CC" != "" ]; then
+ COMMAND=${COMMAND:-}${COMMAND:+,}cc=${CC}
+ fi
+ if [ "$BCC" != "" ]; then
+ COMMAND=${COMMAND:-}${COMMAND:+,}bcc=${BCC}
+ fi
+ if [ "$SUBJECT" != "" ]; then
+ COMMAND=${COMMAND:-}${COMMAND:+,}subject=${SUBJECT}
+ fi
+ if [ "$BODY" != "" ]; then
+ COMMAND=${COMMAND:-}${COMMAND:+,}body=${BODY}
+ fi
+ if [ "$ATTACH" != "" ]; then
+ COMMAND=${COMMAND:-}${COMMAND:+,}attachment=${ATTACH}
+ fi
+
+ run_mozilla "$MAILER" "$COMMAND"
+ ;;
+
+ kmail)
+
+ while [ "$1" != "" ]; do
+ case $1 in
+ --to)
+ TO="${TO:-}${TO:+,}$2"
+ shift
+ ;;
+ --cc)
+ CC="${CC:-}${CC:+,}$2"
+ shift
+ ;;
+ --bcc)
+ BCC="${BCC:-}${BCC:+,}$2"
+ shift
+ ;;
+ --subject)
+ SUBJECT="$2"
+ shift
+ ;;
+ --body)
+ BODY="$2"
+ shift
+ ;;
+ --attach)
+ ATTACH="$2"
+ shift
+ ;;
+ *)
+ ;;
+ esac
+ shift;
+ done
+
+ ${MAILER} --composer ${CC:+--cc} ${CC:+"${CC}"} ${BCC:+--bcc} ${BCC:+"${BCC}"} \
+ ${SUBJECT:+--subject} ${SUBJECT:+"${SUBJECT}"} ${BODY:+--body} ${BODY:+"${BODY}"} \
+ ${ATTACH:+--attach} ${ATTACH:+"${ATTACH}"} ${TO:+"${TO}"}
+ ;;
+
+ mutt)
+
+ while [ "$1" != "" ]; do
+ case $1 in
+ --from)
+ FROM="$2"
+ shift
+ ;;
+ --to)
+ TO="${TO:-}${TO:+,}$2"
+ shift
+ ;;
+ --cc)
+ CC="${CC:-}${CC:+,}$2"
+ shift
+ ;;
+ --bcc)
+ BCC="${BCC:-}${BCC:+,}$2"
+ shift
+ ;;
+ --subject)
+ SUBJECT="$2"
+ shift
+ ;;
+ --body)
+ TEMPLATE="`basename $0`.mutt.XXXXXXXX"
+ BODY=`mktemp -q -t ${TEMPLATE}`
+ echo "$2" > $BODY
+ shift
+ ;;
+ --attach)
+ ATTACH="$2"
+ shift
+ ;;
+ *)
+ ;;
+ esac
+ shift;
+ done
+
+ x-terminal-emulator -e ${MAILER} \
+ ${FROM:+-e} ${FROM:+"set from=\"${FROM}\""} \
+ ${CC:+-c} ${CC:+"${CC}"} \
+ ${BCC:+-b} ${BCC:+"${BCC}"} \
+ ${SUBJECT:+-s} ${SUBJECT:+"${SUBJECT}"} \
+ ${BODY:+-i} ${BODY:+"${BODY}"} \
+ ${ATTACH:+-a} ${ATTACH:+"${ATTACH}"} \
+ ${TO:+"${TO}"} &
+ rm -f $BODY
+ ;;
+
+ evolution)
+
+ while [ "$1" != "" ]; do
+ case $1 in
+ --to)
+ if [ "${TO}" != "" ]; then
+ MAILTO="${MAILTO:-}${MAILTO:+&}to=$2"
+ else
+ TO="$2"
+ fi
+ shift
+ ;;
+ --cc)
+ MAILTO="${MAILTO:-}${MAILTO:+&}cc="`echo "$2" | ${URI_ENCODE}`
+ shift
+ ;;
+ --bcc)
+ MAILTO="${MAILTO:-}${MAILTO:+&}bcc="`echo "$2" | ${URI_ENCODE}`
+ shift
+ ;;
+ --subject)
+ MAILTO="${MAILTO:-}${MAILTO:+&}subject"=`echo "$2" | ${URI_ENCODE}`
+ shift
+ ;;
+ --body)
+ MAILTO="${MAILTO:-}${MAILTO:+&}body="`echo "$2" | ${URI_ENCODE}`
+ shift
+ ;;
+ --attach)
+ MAILTO="${MAILTO:-}${MAILTO:+&}attach="`echo "file://$2" | ${URI_ENCODE}`
+ shift
+ ;;
+ *)
+ ;;
+ esac
+ shift;
+ done
+
+ MAILTO="mailto:${TO}?${MAILTO}"
+ ${MAILER} "${MAILTO}" &
+ ;;
+
+ groupwise)
+
+ while [ "$1" != "" ]; do
+ case $1 in
+ --to)
+ if [ "${TO}" != "" ]; then
+ MAILTO="${MAILTO:-}${MAILTO:+&}to=$2"
+ else
+ TO="$2"
+ fi
+ shift
+ ;;
+ --cc)
+ MAILTO="${MAILTO:-}${MAILTO:+&}cc="`echo "$2" | ${URI_ENCODE}`
+ shift
+ ;;
+ --bcc)
+ MAILTO="${MAILTO:-}${MAILTO:+&}bcc="`echo "$2" | ${URI_ENCODE}`
+ shift
+ ;;
+ --subject)
+ MAILTO="${MAILTO:-}${MAILTO:+&}subject"=`echo "$2" | ${URI_ENCODE}`
+ shift
+ ;;
+ --body)
+ MAILTO="${MAILTO:-}${MAILTO:+&}body="`echo "$2" | ${URI_ENCODE}`
+ shift
+ ;;
+ --attach)
+ MAILTO="${MAILTO:-}${MAILTO:+&}attachment="`echo "file://$2" | ${URI_ENCODE}`
+ shift
+ ;;
+ *)
+ ;;
+ esac
+ shift;
+ done
+
+ MAILTO="mailto:${TO}?${MAILTO}"
+ ${MAILER} "${MAILTO}" &
+ ;;
+
+ dtmail)
+
+ while [ "$1" != "" ]; do
+ case $1 in
+ --to)
+ TO=${TO:-}${TO:+,}$2
+ shift
+ ;;
+ --attach)
+ ATTACH="$2"
+ shift
+ ;;
+ *)
+ ;;
+ esac
+ shift;
+ done
+
+ ${MAILER} ${TO:+-T} ${TO:-} ${ATTACH:+-a} ${ATTACH:+"${ATTACH}"}
+ ;;
+
+ sylpheed | claws)
+
+ while [ "$1" != "" ]; do
+ case $1 in
+ --to)
+ TO=${TO:-}${TO:+,}$2
+ shift
+ ;;
+ --attach)
+ ATTACH="${ATTACH:-}${ATTACH:+ }$2"
+ shift
+ ;;
+ *)
+ ;;
+ esac
+ shift;
+ done
+
+ ${MAILER} ${TO:+--compose} "${TO:-}" ${ATTACH:+--attach} "${ATTACH:-}"
+ ;;
+
+ Mail | Thunderbird | *.app )
+
+ while [ "$1" != "" ]; do
+ case $1 in
+ --attach)
+ #i95688# fix filenames containing accented chars, whatever alien
+ ATTACH="${ATTACH:-}${ATTACH:+ }"`echo "file://$2" | ${URI_ENCODE}`
+ shift
+ ;;
+ *)
+ ;;
+ esac
+ shift;
+ done
+ /usr/bin/open -a "${MAILER}" ${ATTACH}
+ ;;
+
+ "")
+
+ # DESKTOP_LAUNCH, see http://freedesktop.org/pipermail/xdg/2004-August/004489.html
+ if [ -n "$DESKTOP_LAUNCH" ]; then
+ while [ "$1" != "" ]; do
+ case $1 in
+ --to)
+ if [ "${TO}" != "" ]; then
+ MAILTO="${MAILTO:-}${MAILTO:+&}to=$2"
+ else
+ TO="$2"
+ fi
+ shift
+ ;;
+ --cc)
+ MAILTO="${MAILTO:-}${MAILTO:+&}cc="`echo "$2" | ${URI_ENCODE}`
+ shift
+ ;;
+ --bcc)
+ MAILTO="${MAILTO:-}${MAILTO:+&}bcc="`echo "$2" | ${URI_ENCODE}`
+ shift
+ ;;
+ --subject)
+ MAILTO="${MAILTO:-}${MAILTO:+&}subject="`echo "$2" | ${URI_ENCODE}`
+ shift
+ ;;
+ --body)
+ MAILTO="${MAILTO:-}${MAILTO:+&}body="`echo "$2" | ${URI_ENCODE}`
+ shift
+ ;;
+ --attach)
+ MAILTO="${MAILTO:-}${MAILTO:+&}attachment="`echo "$2" | ${URI_ENCODE}`
+ shift
+ ;;
+ *)
+ ;;
+ esac
+ shift;
+ done
+
+ MAILTO="mailto:${TO}?${MAILTO}"
+ ${DESKTOP_LAUNCH} "${MAILTO}" &
+ else
+ echo "Could not determine a mail client to use."
+ exit 2
+ fi
+ ;;
+
+ *)
+ echo "Unsupported mail client: `basename $MAILER | sed 's/-.*^//'`"
+ exit 2
+ ;;
+esac
+
+exit 0
diff --git a/shell/source/unix/misc/uri-encode.c b/shell/source/unix/misc/uri-encode.c
new file mode 100644
index 000000000000..e93bd61e6675
--- /dev/null
+++ b/shell/source/unix/misc/uri-encode.c
@@ -0,0 +1,50 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org 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 Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+#include <ctype.h>
+#include <errno.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+
+int main() {
+ for (;;) {
+ int c;
+ errno = 0;
+ c = getchar();
+ if (c == EOF) {
+ exit(errno == 0 ? EXIT_SUCCESS : EXIT_FAILURE);
+ } else if (isalnum(c) || strchr("!$'()*+,-.:=@_~/\n", c) != NULL) {
+ /* valid RFC 2396 pchar characters + '/' + newline */
+ if (putchar(c) == EOF) {
+ exit(EXIT_FAILURE);
+ }
+ } else if (printf("%%%02X", (unsigned char) (char) c) < 0) {
+ exit(EXIT_FAILURE);
+ }
+ }
+}