#!/bin/sh

# 
# Copyright 2005 Markus Amersdorfer <markus(dott)amersdorfer(att)gmx(dott).at>
# 
# This file 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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA,
# or see http://www.gnu.org/licenses/gpl.txt.
#
# OOo2sylpheed.sh	helper script to send documents from OpenOffice.org
#			to Sylpheed
# 

# This script is based on ideas from the corresponding Perl script
# "OOo2sylpheed" (see http://www.thewildbeast.co.uk/sylpheed/),
# which for some reason does not work in my environment ...
# Thanks to Paul Mangan!

# The parameters of OpenOffice.org's command
# look something like this:
#   /tmp/sv9pn.tmp/This%20is%20a%20test%20file.sxw

#######################################################################
# CONFIGURATION OPTIONS:
SYLPHEED_BINARY=/opt/sylpheed/bin/sylpheed
#######################################################################

# Get the file name:
ATTACHMENT_LOCATION=`echo "$@" | sed s@mailto:?attach=file:///@/@ | sed s/%20/" "/g`

# DEBUG:
#echo "$@" > /tmp/OOo-mail-parameters_DEBUG.txt
#echo $ATTACHMENT_LOCATION >> /tmp/OOo-mail-parameters_DEBUG.txt

# Launch sylpheed with this attachment:
"$SYLPHEED_BINARY" --attach "$ATTACHMENT_LOCATION"


