#!/bin/bash

# inopi su 11.7.2010 20.13.45 +0300
#
# Changes since ma 3.5.2010 17.12.35 +0300
#	- quote-wrapped directory name
#
# ma 3.5.2010 17.12.35 +0300: First release


# After pairing your phone, use `sdptool search FTP` to find out what to specify here.
PHONE_ADDRESS=00:00:00:00:00:00
PHONE_CHANNEL=0

# Where in the filesystem the contents of your phone will be at.
PHONE_DIRECTORY=/home/jani/Puhelin

# Where inside the phone's directory tree are the pictures.
PICTURES_DIRECTORY=E\:/Images/Kamera



test -x $PHONE_DIRECTORY || exit 1
obexfs -b $PHONE_ADDRESS -B $PHONE_CHANNEL $PHONE_DIRECTORY
test -x "${PHONE_DIRECTORY%%/}/${PICTURES_DIRECTORY%%/}" || { fusermount -uz $PHONE_DIRECTORY; exit 1; }
pushd "${PHONE_DIRECTORY%%/}/${PICTURES_DIRECTORY%%/}/"
TEMPORARY=`mktemp -d`
for m in `ls -t | head -n 2`
do
	cp -av "$m" ${TEMPORARY%%/}/
done
popd
f-spot --import file://$TEMPORARY > /dev/null 2>&1
rm -rf ${TEMPORARY}
fusermount -uz $PHONE_DIRECTORY