#!/bin/sh

peer="w890i"
username="user"
password="user"
dataPath="${XDG_DATA_HOME}/syncevolution/${peer}"
devID="IMEI:012345678901234"
serverURL="http://localhost:9000/syncevolution"
macAddress="xx:xx:xx:xx:xx:xx"

configPhone()
{
    syncevolution --configure \
        --sync-property syncURL=obex-bt://${macAddress} \
        --sync-property enableWBXML=1 \
        --sync-property WebURL=${serverURL} \
        --sync-property PeerIsClient=1 \
        --sync-property username=${username} \
        --sync-property password=${password} \
        --sync-property remoteDeviceId=${devID} \
        --sync-property deviceId=${devID} \
        --template default \
        ${peer}

    for i in calendar addressbook todo memo; do
        syncevolution --configure \
            --source-property sync=two-way \
            --source-property uri=$i \
            --source-property evolutionsource=file://${dataPath}/$i \
            --source-property type=$(
            case $i in
                addressbook)
                    echo "file:text/vcard:3.0"
                ;;
                calendar)
                    echo "file:text/calendar:2.0"
                ;;
                todo)
                    echo "file:text/calendar:2.0"
                ;;
                memo)
                    echo "file:text/plain:1.0"
                ;;
            esac) \
            ${peer} $i;
    done
}

configPhone
