5
« on: December 28, 2006, 01:08:15 am »
modified Meanies bluetooth-gui script to work for Tree!Exploreer Plus Send-To functionality
#!/bin/sh
#
######################################################################
APPNAME="OBEX GUI"
BNAME=`basename $0`
BLUECONTROL=/etc/pcmcia/bluetooth
BTLIST=/etc/bluetooth/devices
BTDEV=/etc/bluetooth/device
SUDO=`which sudo`
sFile=$1
init()
{
export QSHDLG_APP=$BNAME$1
INPUT=/var/spool/qshdlg/input_${QSHDLG_APP}
OUTPUT=/var/spool/qshdlg/output_${QSHDLG_APP}
CONTROL=/var/spool/qshdlg/control_${QSHDLG_APP}
}
get_device()
{
if [ -f $BTDEV ] && [ "$DEVICE" = "" ]; then
DEVICE=`cat $BTDEV`
fi
}
init dc
qshdlg custom -C "message,reply" -A -f lcfont -t "$APPNAME : control" -v "Scan,Start,Stop" &
while [ ! -p $CONTROL ]
do
echo >/dev/null
done
if [ "`hciconfig`" = "" ]; then
echo "Bluetooth service is not started" > $OUTPUT
else
echo "Bluetooth service is running" > $OUTPUT
if [ -f $BTLIST ]; then
for NODE in `grep ':' $BTLIST`
do
if [ "$NODE" != "Scanning" ] && [ "$NODE" != "..." ]; then
if [ "`echo $NODE |grep ':'`" != "" ]; then
NODEADDRESS=$NODE
else
echo 'item(QString)' "$NODEADDRESS---[$NODE]" > $CONTROL
FOUND=1
fi
fi
done
if [ "$FOUND" = "1" ]; then
echo 'showSelect()' > $CONTROL
echo "Please select Bluetooth device" > $OUTPUT
fi
fi
fi
while read RET < $INPUT
do
case $RET in
Start)
if [ "`hciconfig`" != "" ]; then
echo "stopping Bluetooth service..." > $OUTPUT
$SUDO $BLUECONTROL stop
CARDID=`cardctl ident 0 |grep manfid|cut -d: -f2 2>/dev/null`
if [ "$CARDID" != "" ] && [ "`grep $CARDID /etc/pcmcia/bluetooth.conf 2>/dev/null`" != "" ]; then
$SUDO cardctl eject 0
fi
fi
if [ "`cardctl status 0|grep 'no card'`" != "" ]; then
echo "inserting card..." > $OUTPUT
$SUDO cardctl insert 0
fi
if [ "`cardctl status 0|grep suspended`" != "" ]; then
echo "resuming card..." > $OUTPUT
$SUDO cardctl resume 0
fi
echo "starting Bluetooth service..." > $OUTPUT
if [ "`hciconfig`" = "" ]; then
echo "Bluetooth started" > $OUTPUT
$SUDO $BLUECONTROL start
else
echo "Bluetooth failed to start" > $OUTPUT
fi
;;
Stop)
echo "stopping Bluetooth service..." > $OUTPUT
$SUDO $BLUECONTROL stop
CARDID=`cardctl ident 0 |grep manfid|cut -d: -f2 2>/dev/null`
if [ "$CARDID" != "" ] && [ "`grep $CARDID /etc/pcmcia/bluetooth.conf 2>/dev/null`" != "" ]; then
$SUDO cardctl eject 0
fi
if [ "`hciconfig`" = "" ]; then
echo "Bluetooth stopped" > $OUTPUT
else
echo "Bluetooth failed to stop" > $OUTPUT
fi
;;
Scan)
if [ "`hciconfig`" = "" ]; then
echo "Cannot scan. Bluetooth is not enabled." > $OUTPUT
else
echo "Scanning for Bluetooth devices..." > $OUTPUT
FOUND=0
for NODE in `hcitool scan | $SUDO tee $BTLIST`
do
if [ "$NODE" != "Scanning" ] && [ "$NODE" != "..." ]; then
if [ "`echo $NODE |grep ':'`" != "" ]; then
NODEADDRESS=$NODE
else
echo 'item(QString)' "$NODEADDRESS---[$NODE]" > $CONTROL
FOUND=1
fi
fi
done
if [ "$FOUND" = "1" ]; then
echo 'showSelect()' > $CONTROL
echo "Please select Bluetooth device" > $OUTPUT
else
echo "No Bluetooth device found" > $OUTPUT
fi
fi
;;
*)
if [ "`echo $RET|grep ':'`" != "" ]; then
DEVICE=`echo $RET|cut -d- -f1`
echo "selected device is $DEVICE" |tee $OUTPUT
get_device
echo "Connecting to Device..." > $OUTPUT
if [ -f /etc/bluetooth/obex ]; then
OFTP=`cat /etc/bluetooth/obex`
else
OFTP=`sdptool search FTP|grep Channel|cut -d: -f2`
fi
echo 'Connected' > $OUTPUT
echo "transferring $sFile ..." > $OUTPUT
obextool push $sFile $DEVICE $OFTP
echo "Transfer Complete" > $OUTPUT
$SUDO touch $BTDEV
$SUDO chown zaurus:qpe $BTDEV
echo $DEVICE > $BTDEV
else
echo "nothing selected" |tee $OUTPUT
fi
echo 'reject()' > $CONTROL
;;
esac
done
make sure to add a command in Tree!Explorer Plus Send-to
select command, then the name of this script "obex-gui %1 &", no quotes. Then you should be able to liong tap->send to->obex-gui. The dialog box pops-up select the device and press ok. thanks to Meanie for the original bluetooth-gui script.