#!/bin/bash
# upload2phone - convert iCalendar file to vCal 1 subset and upload it to phone using gammu
# (c) 2005 Tero Karvinen http://www.iki.fi/karvinen/vcalone
# GNU General Public License GPL v2
# Requires: gammu, vcalone, bash

# TODO: error checking
# TODO: some questions to avoid overwriting phone's calendar and todo by mistake

ICS=korga.ics

if [ ! -z "$1" ]
then
	echo "usage: upload2phone";
	exit 1;
fi

if [ ! -e "$ICS" ]
then
	echo "$ICS does not exist!";
	echo "If you have downloaded calendar from phone (with 'downloadfromphone'), ";
	echo "edit your calendar with 'korganizer korga.vcs', save it (Save as ics iCalendar? yes).";
	echo "Then you can run 'upload2phone' again. ";
	exit 1;
fi

echo "OVERWRITING phone calendar with $ICS, press CTRL-C now to cancel.";
vcalone "$ICS" > upload2phone-tmp.vcs && echo "ALL" |gammu --restore upload2phone-tmp.vcs;
rm upload2phone-tmp.vcs;

#    This program 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., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
#
#    See also:
#    http://www.gnu.org/licenses/gpl.html

