fix baseline build (old cairo) - 'cairo_rectangle_int_t' does not name a type
[LibreOffice.git] / shell / source / unix / misc / senddoc.sh
bloba6425462c70d0e2bb8a79761050dbf835f6d56f2
1 #!/bin/sh
3 # This file is part of the LibreOffice project.
5 # This Source Code Form is subject to the terms of the Mozilla Public
6 # License, v. 2.0. If a copy of the MPL was not distributed with this
7 # file, You can obtain one at http://mozilla.org/MPL/2.0/.
9 # This file incorporates work covered by the following license notice:
11 # Licensed to the Apache Software Foundation (ASF) under one or more
12 # contributor license agreements. See the NOTICE file distributed
13 # with this work for additional information regarding copyright
14 # ownership. The ASF licenses this file to you under the Apache
15 # License, Version 2.0 (the "License"); you may not use this file
16 # except in compliance with the License. You may obtain a copy of
17 # the License at http://www.apache.org/licenses/LICENSE-2.0 .
20 URI_ENCODE=`dirname "$0"`/uri-encode
21 FOPTS=""
22 sd_platform=`uname -s`
24 # linux file utility needs -L option to resolve symlinks
25 if [ "$sd_platform" = "Linux" ] ; then
26 FOPTS="-L"
29 # do not confuse the system mail clients with OOo and Java libraries
30 case $sd_platform in
31 AIX)
32 unset LIBPATH
35 unset LD_LIBRARY_PATH
37 esac
39 # tries to locate the executable specified
40 # as first parameter in the user's path.
41 which() {
42 if [ ! -z "$1" ]; then
43 for i in `echo $PATH | sed -e 's/^:/.:/g' -e 's/:$/:./g' -e 's/::/:.:/g' -e 's/:/ /g'`; do
44 if [ -x "$i/$1" -a ! -d "$i/$1" ]; then
45 echo "$i/$1"
46 break;
48 done
52 # checks for the original mozilla start script(s)
53 # and restrict the "-remote" semantics to those.
54 run_mozilla() {
55 # find mozilla script in PATH if necessary
56 if [ "`basename $1`" = "$1" ]; then
57 moz=`which $1`
58 else
59 moz=$1
62 if file $FOPTS "$moz" | grep "script" > /dev/null && grep "[NM]PL" "$moz" > /dev/null; then
63 "$moz" -remote 'ping()' 2>/dev/null >/dev/null
64 if [ $? -eq 2 ]; then
65 "$1" -compose "$2" &
66 else
67 "$1" -remote "xfeDoCommand(composeMessage,$2)" &
69 else
70 "$1" -compose "$2" &
74 if [ "$1" = "--mailclient" ]; then
75 shift
76 MAILER=$1
77 shift
80 # autodetect mail client from executable name
81 case `basename "$MAILER" | sed 's/-.*$//'` in
83 iceape | mozilla | netscape | seamonkey | icedove | thunderbird)
85 while [ "$1" != "" ]; do
86 case $1 in
87 --to)
88 TO=${TO:-}${TO:+,}$2
89 shift
91 --cc)
92 CC=${CC:-}${CC:+,}$2
93 shift
95 --bcc)
96 BCC=${BCC:-}${BCC:+,}$2
97 shift
99 --subject)
100 SUBJECT=$2
101 shift
103 --body)
104 BODY=$2
105 shift
107 --attach)
108 ATTACH=${ATTACH:-}${ATTACH:+,}`echo "file://$2" | "${URI_ENCODE}"`
109 shift
113 esac
114 shift;
115 done
117 if [ "$TO" != "" ]; then
118 COMMAND=${COMMAND:-}${COMMAND:+,}to=\'${TO}\'
120 if [ "$CC" != "" ]; then
121 COMMAND=${COMMAND:-}${COMMAND:+,}cc=\'${CC}\'
123 if [ "$BCC" != "" ]; then
124 COMMAND=${COMMAND:-}${COMMAND:+,}bcc=\'${BCC}\'
126 if [ "$SUBJECT" != "" ]; then
127 COMMAND=${COMMAND:-}${COMMAND:+,}subject=\'${SUBJECT}\'
129 if [ "$BODY" != "" ]; then
130 COMMAND=${COMMAND:-}${COMMAND:+,}body=\'${BODY}\'
132 if [ "$ATTACH" != "" ]; then
133 COMMAND=${COMMAND:-}${COMMAND:+,}attachment=\'${ATTACH}\'
136 run_mozilla "$MAILER" "$COMMAND"
139 kmail)
141 while [ "$1" != "" ]; do
142 case $1 in
143 --to)
144 TO="${TO:-}${TO:+,}$2"
145 shift
147 --cc)
148 CC="${CC:-}${CC:+,}$2"
149 shift
151 --bcc)
152 BCC="${BCC:-}${BCC:+,}$2"
153 shift
155 --subject)
156 SUBJECT="$2"
157 shift
159 --body)
160 BODY="$2"
161 shift
163 --from)
164 FROM="$2"
165 shift
167 --attach)
168 ATTACH="${ATTACH:-}${ATTACH:+ }--attach "`echo "file://$2" | "${URI_ENCODE}"`
169 shift
173 esac
174 shift;
175 done
177 ${MAILER} --composer \
178 ${CC:+--cc} ${CC:+"${CC}"} \
179 ${BCC:+--bcc} ${BCC:+"${BCC}"} \
180 ${SUBJECT:+--subject} ${SUBJECT:+"${SUBJECT}"} \
181 ${BODY:+--body} ${BODY:+"${BODY}"} \
182 ${FROM:+--header} ${FROM:+"From: ${FROM}"} \
183 ${ATTACH:+${ATTACH}} \
184 ${TO:+"${TO}"}
187 mutt)
189 while [ "$1" != "" ]; do
190 case $1 in
191 --from)
192 FROM="$2"
193 shift
195 --to)
196 TO="${TO:-}${TO:+,}$2"
197 shift
199 --cc)
200 CC="${CC:-}${CC:+,}$2"
201 shift
203 --bcc)
204 BCC="${BCC:-}${BCC:+,}$2"
205 shift
207 --subject)
208 SUBJECT="$2"
209 shift
211 --body)
212 TEMPLATE="`basename $0`.mutt.XXXXXXXX"
213 BODY=`mktemp -q -t ${TEMPLATE}`
214 echo "$2" > $BODY
215 shift
217 --attach)
218 ATTACH="$2"
219 shift
223 esac
224 shift;
225 done
227 x-terminal-emulator -e ${MAILER} \
228 ${FROM:+-e} ${FROM:+"set from=\"${FROM}\""} \
229 ${CC:+-c} ${CC:+"${CC}"} \
230 ${BCC:+-b} ${BCC:+"${BCC}"} \
231 ${SUBJECT:+-s} ${SUBJECT:+"${SUBJECT}"} \
232 ${BODY:+-i} ${BODY:+"${BODY}"} \
233 ${ATTACH:+-a} ${ATTACH:+"${ATTACH}"} \
234 ${TO:+"${TO}"} &
235 rm -f $BODY
238 evolution | gnome | xdg) # NB. shortened from the dash on
240 while [ "$1" != "" ]; do
241 case $1 in
242 --to)
243 if [ "${TO}" != "" ]; then
244 MAILTO="${MAILTO:-}${MAILTO:+&}to=$2"
245 else
246 TO="$2"
248 shift
250 --cc)
251 MAILTO="${MAILTO:-}${MAILTO:+&}cc="`echo "$2" | "${URI_ENCODE}"`
252 shift
254 --bcc)
255 MAILTO="${MAILTO:-}${MAILTO:+&}bcc="`echo "$2" | "${URI_ENCODE}"`
256 shift
258 --subject)
259 MAILTO="${MAILTO:-}${MAILTO:+&}subject"=`echo "$2" | "${URI_ENCODE}"`
260 shift
262 --body)
263 MAILTO="${MAILTO:-}${MAILTO:+&}body="`echo "$2" | "${URI_ENCODE}"`
264 shift
266 --attach)
267 MAILTO="${MAILTO:-}${MAILTO:+&}attach="`echo "file://$2" | "${URI_ENCODE}"`
268 shift
272 esac
273 shift;
274 done
276 MAILTO="mailto:${TO}?${MAILTO}"
277 ${MAILER} "${MAILTO}" &
280 groupwise)
282 while [ "$1" != "" ]; do
283 case $1 in
284 --to)
285 if [ "${TO}" != "" ]; then
286 MAILTO="${MAILTO:-}${MAILTO:+&}to=$2"
287 else
288 TO="$2"
290 shift
292 --cc)
293 MAILTO="${MAILTO:-}${MAILTO:+&}cc="`echo "$2" | "${URI_ENCODE}"`
294 shift
296 --bcc)
297 MAILTO="${MAILTO:-}${MAILTO:+&}bcc="`echo "$2" | "${URI_ENCODE}"`
298 shift
300 --subject)
301 MAILTO="${MAILTO:-}${MAILTO:+&}subject"=`echo "$2" | "${URI_ENCODE}"`
302 shift
304 --body)
305 MAILTO="${MAILTO:-}${MAILTO:+&}body="`echo "$2" | "${URI_ENCODE}"`
306 shift
308 --attach)
309 MAILTO="${MAILTO:-}${MAILTO:+&}attachment="`echo "file://$2" | "${URI_ENCODE}"`
310 shift
314 esac
315 shift;
316 done
318 MAILTO="mailto:${TO}?${MAILTO}"
319 ${MAILER} "${MAILTO}" &
322 dtmail)
324 while [ "$1" != "" ]; do
325 case $1 in
326 --to)
327 TO=${TO:-}${TO:+,}$2
328 shift
330 --attach)
331 ATTACH="$2"
332 shift
336 esac
337 shift;
338 done
340 ${MAILER} ${TO:+-T} ${TO:-} ${ATTACH:+-a} ${ATTACH:+"${ATTACH}"}
343 sylpheed | claws)
345 while [ "$1" != "" ]; do
346 case $1 in
347 --to)
348 TO=${TO:-}${TO:+,}$2
349 shift
351 --attach)
352 ATTACH="${ATTACH:-}${ATTACH:+ }$2"
353 shift
357 esac
358 shift;
359 done
361 ${MAILER} ${TO:+--compose} "${TO:-}" ${ATTACH:+--attach} "${ATTACH:-}"
364 Mail | Thunderbird | *.app )
366 while [ "$1" != "" ]; do
367 case $1 in
368 --attach)
369 #i95688# fix filenames containing accented chars, whatever alien
370 ATTACH="${ATTACH:-}${ATTACH:+ }"`echo "file://$2" | "${URI_ENCODE}"`
371 shift
375 esac
376 shift;
377 done
378 /usr/bin/open -a "${MAILER}" ${ATTACH}
383 # LO is configured to use something we do not recognize, or is not configured.
384 # Try to be smart, and send the mail anyway, if we have the
385 # possibility to do so.
387 if [ -n "$DESKTOP_LAUNCH" ]; then
388 # http://lists.freedesktop.org/pipermail/xdg/2004-August/002873.html
389 MAILER=${DESKTOP_LAUNCH}
390 elif [ -n "$KDE_FULL_SESSION" -a -x /usr/bin/kde-open ] ; then
391 MAILER=/usr/bin/kde-open
392 elif [ -n "$GNOME_DESKTOP_SESSION_ID" -a -x /usr/bin/gnome-open ] ; then
393 MAILER=/usr/bin/gnome-open
394 elif [ -x /usr/bin/xdg-open ] ; then
395 MAILER=/usr/bin/xdg-open
396 else
397 echo "Unsupported mail client: `basename $MAILER | sed 's/-.*^//'`"
398 exit 2
401 while [ "$1" != "" ]; do
402 case $1 in
403 --to)
404 if [ "${TO}" != "" ]; then
405 MAILTO="${MAILTO:-}${MAILTO:+&}to=$2"
406 else
407 TO="$2"
409 shift
411 --cc)
412 MAILTO="${MAILTO:-}${MAILTO:+&}cc="`echo "$2" | "${URI_ENCODE}"`
413 shift
415 --bcc)
416 MAILTO="${MAILTO:-}${MAILTO:+&}bcc="`echo "$2" | "${URI_ENCODE}"`
417 shift
419 --subject)
420 MAILTO="${MAILTO:-}${MAILTO:+&}subject"=`echo "$2" | "${URI_ENCODE}"`
421 shift
423 --body)
424 MAILTO="${MAILTO:-}${MAILTO:+&}body="`echo "$2" | "${URI_ENCODE}"`
425 shift
427 --attach)
428 MAILTO="${MAILTO:-}${MAILTO:+&}attachment="`echo "file://$2" | "${URI_ENCODE}"`
429 shift
433 esac
434 shift;
435 done
437 MAILTO="mailto:${TO}?${MAILTO}"
438 ${MAILER} "${MAILTO}" &
440 esac