Re: [Evolution] How to import tasks/appts non-interactively?



On Fri, 2003-10-03 at 19:38, Dan Winship wrote:
Here's the idea I came up with so far.  Assume one main Tasks folder and
one main Calendar folder.  Create two maildir folders for messages to
transform, such as "appts-from-email" and "tasks-from-email".  Drag any
emails you want into those folders.  Run my proposed script that reads
the messages and converts them into vCal/iCal files (perhaps from a rule
if possible or perhaps from cron every few minutes), and then import
those into the appropriate Evolution folders.  For appointments, set
them for the current hour, and then let the user move them to the
appropriate day/time.

Of course, it would be cooler to make an app that creates a window or
panel applet or something, which you can drag messages to and it will
convert them directly. :)

In Perl, I can handle (and have written) the part of reading the maildir
folder and transforming the messages into iCal format (extract only the
plain/text body, etc).  Here's where I am stuck: how do I get the iCal
data into Evolution?

You can't do it easily directly from perl. You'll need to write a C
program and use libcalclient (and beware that you'll have to rewrite it
for Evolution 2.0 because the API will be changing).

The source is in calendar/cal-client/ in the evolution source tree.
There is some documentation in the source files in the form of
gtk-doc-style comments. Basically you'll want to use cal_client_new() to
create a CalClient object, then cal_client_open_default_calendar() or
cal_client_open_default_tasks() to open the default calendar or tasks
folder with that client object. Then use cal_client_update_object() to
create the new appointment/task.

Well, ok, so cal_client_update_object() takes a CalComponent, so you'll
need to use libcal-util as well. There's no function to directly create
a CalComponent from an ical string, so you'll need to first create an
icalcomponent (using icalcomponent_new_from_string() in libical) and
then call cal_component_set_icalcomponent(). Or you could just build up
the CalComponent using the cal_component_set_* functions instead of
creating an icalendar string.

The client-test.c code in calendar/cal-client has some code you can use
as a starting point.

Alan, you might want to look at
http://rodrigo.gnome-db.org/projects/tv-icalendar/tv-icalendar.c, which
is a hack I did very similar to what you want to do. In this case it
reads a XML file, so you should be able to change it easily to suit your
needs.

cheers




[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]