Commit 7a2e724f authored by mossroy's avatar mossroy

Merge branch 'master' of https://github.com/Trim/qtmoko-ics2qtcal

Conflicts:
	README.txt
parents cb8e1c3d cc6fffe3
# Ignore saved file and test files
*~
*.ics
*.tmp
This program transfers the content of ical files (.ics) into the calendar application of QtMoko.
What about qtmoko-ics2qtcal ?
-----------------------------
This program transfers the content of ical files (.ics) into the [QtMoko's calendar](http://qtmoko.sourceforge.net).
It has been reported to work on a Google Calendar private URL, an Office Online calendar and with Davical calendar.
It currently does not have any user-interface, and is written with a mix of Perl and shell script.
We aren't expert in those languages : the code can probably be improved (suggestions and help are welcome!)
It currently does not have any user-interface (but will have soon see Trim/getcal repo), and is written with a mix of Perl and shell script.
We aren't expert in those languages : the code can probably be improved (suggestions and help are welcome!) and the ical RFC isn't completed (but feature demands and bug reports are welcome).
How can I use it ?
------------------
It can run on a standard computer, or on the phone itself.
In current version, it downloads one ore several .ics files through HTTP(S), and stores their content into the SQLite database (/home/root/Applications/Qtopia/qtopia_db.sqlite , __replacing__ existing appointments).
It also creates the Note files for each appointment description, in the directory where they are expected : /home/root/Applications/Annotator/
In current version, it downloads one ore several .ics files through HTTP(S), and stores their content into the SQLite database (/home/root/Applications/Qtopia/qtopia_db.sqlite , __replacing__ and removing existing appointments).
It also creates the Note files for each appointment description, in the directory where they are expected by QtMoko : /home/root/Applications/Annotator/
Usage on QtMoko (tested on v52):
- Copy all the files in a directory of your phone (you can use git clone if you've install git or download zip file)
### Usage on QtMoko (tested on v52):
- Copy all the files in a directory of your phone (you can use git clone if you've install git or [download zip file](https://www.adorsaz.ch/public/downloads/qtmoko-ics2qtcal/))
- Install the necessary Perl packages by running install_dependencies.sh on the phone
- Run the script sync4ics2openmoko.sh [-u user] [-p password] [-s serverurl] fileurl1 fileurl2 ...
The optional user/password is given to the HTTP server if it needs authentication
Examples :
#### Examples
- sync4ics2openmoko.sh (will parse all local files with extension .ics)
- sync4ics2openmoko.sh -u 'myuser' -p 'mypassword' -s https://myserver/mypath/ myfile1 myfile2 myfile3
- sync4ics2openmoko.sh -u 'myuser' -p 'mypassword' -s https://myserver/ mypath1/myfile1 mypath1/myfile2 anotherpath/myfile3
Usage on a standard computer (tested on Ubuntu 10.04 and 12.04) : same steps, except that you need to use remotesync4ics2openmoko.sh instead
### Usage on Desktop
Usage on a standard computer (tested on Ubuntu 10.04) : same steps, except that you need to use remotesync4ics2openmoko.sh instead and connect your phone with IP 192.168.0.202.
How does it work ?
------------------
* ics2qtcal.pl is where the hard job is done. This script has several options and you can use it alone
* sync4ics2openmoko.sh and remotesync4ics2openmoko.sh automate the operations described above. They are targeted on my own usage, but you can modify them if you wish.
Sources
-------
ics2qtcal.pl is where the hard job is done. This script has several options and you can use it alone
sync4ics2openmoko.sh and remotesync4ics2openmoko.sh automate the operations described above. They are targeted on my own usage, but you can modify them if you wish.
* Idea taken from [openmoko wiki](http://wiki.openmoko.org/wiki/PIM_Storage#Import.2FExport_of_Calendar_Data_for_PIM-Storage) by Niebert
* [Original application](http://mossroy.free.fr/ics2qtcal/) from Mossroy
* Some code inspired or copied from [cpan](http://cpansearch.perl.org/src/BSDZ/Tie-iCal-0.14/samples/outlooksync.pl)
* The [iCal RFC](http://www.faqs.org/rfcs/rfc2445.html) implementation is quite incomplete in this script, but it covers the most common options
Suggestions/bugs
----------------
Idea taken from http://wiki.openmoko.org/wiki/PIM_Storage#Import.2FExport_of_Calendar_Data_for_PIM-Storage by Niebert.
Original application from Mossroy : http://mossroy.free.fr/ics2qtcal/
Some code inspired or copied from http://cpansearch.perl.org/src/BSDZ/Tie-iCal-0.14/samples/outlooksync.pl .
The iCal RFC implementation (http://www.faqs.org/rfcs/rfc2445.html) is quite incomplete in this script, but it covers the most common options
Please send any suggestion/bug report to mossroy.mossroy AT gmail DOT com , adrien AT adorsaz DOT ch or use github tools
You can give small donations through [our Flattr](https://flattr.com/thing/104780/ics2qtcal-Perl-script-to-synchronize-ics-files-with-QtMoko-calendar-on-a-FreeRunner)
Please send any suggestion/bug report to adrien AT adorsaz DOT ch or mossroy AT free FOT fr
License
-------
License :
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, version 3 of the License.
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, version 3 of the License.
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.
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.
......@@ -27,6 +27,18 @@ v0.7 (2013-02-07)
- Fix repetition rules for last Qtmoko (v52)
- Replace depreciated feature Date::Ical by DateTime library as first one will be removed from next debian stable
v0.7.2 (2013-02-20)
- Remove some assumptions to retrieve date and timezone
- Fix bugs with recurence manipulation
- Fix some bugs with script invokations
v0.7.3 (2013-05-31)
- remove ics2qtcal.sh to improve execution time on OpenMoko
- use variables in shell scripts
- work in /tmp
- don't purge automatically database to be able to use the script in graphical application (see Trim/getcal)
- use Tie::iCal as proposed in documentation
TODO for next versions :
- add attendees to the event descriptions
- handle event categories
......
This diff is collapsed.
#!/bin/sh
# Interpret command line options
while getopts v option
do case "$option" in
v) verbose="-v";;
[?]) print >&2 "Usage: $0 [-v] file sqlite_file"
exit 1;;
esac
done
shift `expr $OPTIND`
icsfile="$1"
caldb="$2"
if [ -n $icsfile ] || [ -n $caldb ]; then
echo "Creating temporary copy of $icsfile with valid lines into db $caldb"
# Create a copy and remove X-MOZ-LASTACK lines that are not understood by Tie::iCal
grep -v X-MOZ-LASTACK "${icsfile}" >"${icsfile}.tmp"
# Normalize line endings to unix format (line feed only)
sed -e 's/\r$//g' "${icsfile}.tmp" >"${icsfile}-2.tmp"
echo "Processing file $icsfile"
perl ics2qtcal.pl "$verbose" --ical "${icsfile}-2.tmp" --qtopiadb "$caldb" --notesdirectory "./Annotator-tmp"
echo "Deleting temporary files"
rm ./${icsfile}.tmp
rm ./${icsfile}-2.tmp
else
echo "ERROR : unable to treat empty files ! Command was (without options) : \n"
echo "$0 $*"
fi
apt-get install libdbd-sqlite3-perl libtie-ical-perl libdatetime-format-ical-perl perl-doc
apt-get install libdbd-sqlite3-perl libtie-ical-perl libdatetime-format-ical-perl
......@@ -12,8 +12,22 @@ do case "$option" in
done
shift `expr $OPTIND - 1`
# Work in tmpdir
mytmp="/tmp/ics2qtcal-`date +%H%M%S`"
mkdir $mytmp
cd $mytmp
# Main configuration
icaldb="/home/root/Applications/Qtopia/qtopia_db.sqlite"
tmpnotes="./Annotator-tmp"
notes="/home/root/Applications/Annotator/"
# Remote configuration
REMOTE_USER='root'
REMOTE_IP='192.168.0.202'
echo "Fetching qtopia_db.sqlite from FreeRunner"
scp root@192.168.0.202:/home/root/Applications/Qtopia/qtopia_db.sqlite .
scp ${REMOTE_USER}@${REMOTE_IP}:${icaldb} .
echo "Fetching files"
for fileurl in $*
......@@ -29,25 +43,33 @@ done
echo "Making a backup copy of qtopia_db"
cp qtopia_db.sqlite qtobia_db.sqlite.bak
echo "Deleting appointments of qtopia_db"
perl deleteqtcalappointments.pl qtopia_db.sqlite
#echo "Deleting appointments of qtopia_db"
#perl deleteqtcalappointments.pl qtopia_db.sqlite
echo "Deleting temporary Notes files from a previous execution"
rm ./Annotator-tmp/*
mkdir -p Annotator-tmp
rm ${tmpnotes}/*
mkdir -p ${tmpnotes}
echo "Transferring events to qtopia_db"
for filename in ./*.ics
do
./ics2qtcal.sh "$verbose" "$filename" ./qtopia_db.sqlite
if [ -n "$verbose" ] ; then
./ics2qtcal.sh -v "$filename" ${icaldb}
else
./ics2qtcal.sh "$filename" ${icaldb}
fi
done;
echo "Transferring qtopia_db.sqlite back to the FreeRunner"
scp qtopia_db.sqlite root@192.168.0.202:/home/root/Applications/Qtopia/
scp qtopia_db.sqlite ${REMOTE_USER}@${REMOTE_IP}:/home/root/Applications/Qtopia/
echo "Removing existing Note files on the FreeRunner"
ssh root@192.168.0.202 "rm -f /home/root/Applications/Annotator/0-*"
ssh ${REMOTE_USER}@${REMOTE_IP} "rm -f ${notes}0-*"
echo "Transferring Note files to the FreeRunner"
scp -q Annotator-tmp/* root@192.168.0.202:/home/root/Applications/Annotator/
scp -q Annotator-tmp/* ${REMOTE_USER}@${REMOTE_IP}:${notes}
echo "Removing *.ics local files"
rm *.ics
echo "Done"
......@@ -12,8 +12,17 @@ do case "$option" in
done
shift `expr $OPTIND - 1`
# Work in tmpdir
mytmp="/tmp/ics2qtcal-`date +%H%M%S`"
mkdir $mytmp
cd $mytmp
icaldb="/home/root/Applications/Qtopia/qtopia_db.sqlite"
tmpnotes="./Annotator-tmp"
notes="/home/root/Applications/Annotator/"
echo "Creating a backup copy of qtopia_db.sqlite"
cp /home/root/Applications/Qtopia/qtopia_db.sqlite ./qtopia_db.sqlite.bak
cp "$icaldb" ./qtopia_db.sqlite.bak
echo "Fetching files"
for fileurl in $*
......@@ -22,25 +31,40 @@ do
if [ -z "$server" ]; then
wget --no-check-certificate --user="$user" --password="$password" "$fileurl" -O "`basename ${fileurl%%.ics}`_`date +%Y%m%d_%H%M%S`.ics"
else
wget --no-check-certificate --user="$user" --password="$password" "${server}/${fileurl}" -O "`basename ${fileurl%%.ics}`_`date +%Y%m%d_%H%M%S`.ics"
wget --no-check-certificate --user="$user" --password="$password" ${server}/${fileurl} -O "`basename ${fileurl%%.ics}`_`date +%Y%m%d_%H%M%S`.ics"
fi
done
echo "Deleting appointments of qtopia_db"
perl deleteqtcalappointments.pl /home/root/Applications/Qtopia/qtopia_db.sqlite
#echo "Deleting appointments of qtopia_db"
#perl deleteqtcalappointments.pl "$icaldb"
echo "Deleting temporary Notes files from a previous execution"
rm ./Annotator-tmp/*
mkdir -p Annotator-tmp
rm "${tmpnotes}"/*
mkdir -p "${tmpnotes}"
echo "Transferring events to qtopia_db"
for filename in ./*.ics
do
./ics2qtcal.sh "$verbose" "$filename" /home/root/Applications/Qtopia/qtopia_db.sqlite
echo "Creating temporary copy of $filename with valid lines into db $caldb"
# Create a copy and remove X-MOZ-LASTACK lines that are not understood by Tie::iCal
# FIXME Check if really needed with latest scripts
grep -v X-MOZ-LASTACK "${filename}" > "${filename}.tmp"
if [ -n "$verbose" ] ; then
ics2qtcal.pl -- -v --ical "${filename}.tmp" --qtopiadb "$icaldb" --notesdirectory "$tmpnotes"
else
ics2qtcal.pl -- --ical "${filename}.tmp" --qtopiadb "$icaldb" --notesdirectory "$tmpnotes"
fi
done;
echo "Removing existing Note files"
rm -f /home/root/Applications/Annotator/0-*
rm -f "${notes}"/0-*
echo "Copying Note files"
cp ./Annotator-tmp/* /home/root/Applications/Annotator/
cp "${tmpnotes}"/* "${notes}"
echo "Removing *.ics local files and *.ics.tmp temporary files"
rm *.ics
rm *.ics.tmp
echo "Done"
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment