#!/bin/sh # # Synchronise phone and GPE # # --reset causes phone data to be deleted and sync starts again from GPE # # Directories work_dir="$HOME/phone/.work" tracedir="/var/tmp/log" # get the name of this script this=$0 reset=0 trace=0 file=0 filters="--filter-objtype note" # Get default address from gconf (first listed bluetooth device) address=$(gconftool --get /system/bluetooth/devices | cut -d , -f 1 | tr -d "[ ]") # Handle callbacks # (see EDITOR= line below) while [ $# -gt 0 ] do # Callback if [ "$1" = "--config-file" -a $# -eq 2 ] then echo "$work_dirFALSE" >$2 exit 0 elif [ "$1" = "--config-phone" -a $# -eq 2 ] then echo "" >$2 echo "2" >>$2 echo "$address" >>$2 echo "11" >>$2 # echo "PC Suite" >>$2 echo "1" >>$2 echo "1" >>$2 echo "1" >>$2 echo "contacts" >>$2 echo "calendar" >>$2 echo "notes" >>$2 echo "" >>$2 exit 0 elif [ "$1" = "--config-gpe" -a $# -eq 2 ] then echo "1" >$2 exit 0 elif [ "$1" = "--trace" ] then trace=1 shift elif [ "$1" = "--reset" ] then reset=1 shift elif [ "$1" = "--address" -a $# -ge 2 ] then address=$2 shift 2 elif [ "$1" = "--work-directory" -a $# -ge 2 ] then work_dir=$2 shift 2 elif [ "$1" = "--no-contacts" ] then filters="$filters --filter-objtype contact" shift elif [ "$1" = "--no-events" ] then filters="$filters --filter-objtype event" shift elif [ "$1" = "--no-todos" ] then filters="$filters --filter-objtype todo" shift elif [ "$1" = "--file" ] then file=1 shift elif [ "$1" = "--help" ] then echo "$0 [--help] [--trace] [--reset] [--no-contacts] [--no-events] [--address ] [--work-directory ] [--file]" echo " --reset deletes all data on phone and reloads from GPE" echo " --no-contacts filters out contacts" echo " --no-events filters out events" echo " --no-todos filters out todos" echo " --trace creates Opensync logs in $tracedir" echo " --address address defaults to $address" echo " --work-directory working directory defaults to $work_dir" echo " --file also synchronises items to files in the working directory (mainly for debugging)" exit 2 else echo "Invalid callback: ($#) $1" echo "For help use $0 --help" exit 1 fi done if [ $reset -ne 0 ] then ~/backup-phone --clear --address $address --work-directory $work_dir # Wait a few seconds for the bluetooth interface to go down before # we try to bring it up again sleep 3 read -p "Press OK on the phone and hit enter" ignored rm -rf $work_dir mkdir -p $work_dir # Create the synchronisation group msynctool --delgroup sync-phone-gpe msynctool --addgroup sync-phone-gpe msynctool --addmember sync-phone-gpe syncml-obex-client # In order to set the configuration we need to call back into this script # to do the work EDITOR="$this --config-phone" msynctool --configure sync-phone-gpe 1 msynctool --addmember sync-phone-gpe gpe-sync EDITOR="$this --config-gpe" msynctool --configure sync-phone-gpe 2 if [ $file -ne 0 ] then msynctool --addmember sync-phone-gpe file-sync EDITOR="$this --config-file" msynctool --configure sync-phone-gpe 3 fi fi if [ $trace -ne 0 ] then rm -rf $tracedir mkdir $tracedir export OSYNC_TRACE=$tracedir export SYNCML_TRACE=$tracedir export SYNCML_LOG=$tracedir fi sudo hciconfig hci0 up msynctool --sync sync-phone-gpe --conflict 2 $filters