diff options
author | JP Rosevear <jpr@src.gnome.org> | 2003-11-07 13:52:24 +0800 |
---|---|---|
committer | JP Rosevear <jpr@src.gnome.org> | 2003-11-07 13:52:24 +0800 |
commit | 200606f92810d3de322e5ee96f8326e1a656f8bb (patch) | |
tree | da0dc27f5311128dcb6e7eb6400931e45743372e | |
parent | e5472b4cc9a4bb80b89437a16f8b77943ea35555 (diff) | |
download | gsoc2013-evolution-200606f92810d3de322e5ee96f8326e1a656f8bb.tar.gz gsoc2013-evolution-200606f92810d3de322e5ee96f8326e1a656f8bb.tar.zst gsoc2013-evolution-200606f92810d3de322e5ee96f8326e1a656f8bb.zip |
Various changes to merge in evolution-data-server reliance.
svn path=/trunk/; revision=23206
325 files changed, 3400 insertions, 63162 deletions
diff --git a/.cvsignore b/.cvsignore index b2049d1e8d..eaaccc4da7 100644 --- a/.cvsignore +++ b/.cvsignore @@ -26,6 +26,4 @@ stamp.h xml-i18n-* xlibtool xltmain.sh -evolution.spec intltool-* -*.pc @@ -1,3 +1,8 @@ +2003-11-07 JP Rosevear <jpr@ximian.com> + + * configure.in: pull in evolution-data-server stuff and remove + backends from output + 2003-10-31 JP Rosevear <jpr@ximian.com> * configure.in: set up vars and rules for versioning the .server diff --git a/Makefile.am b/Makefile.am index 93ea62ff7f..242191fced 100644 --- a/Makefile.am +++ b/Makefile.am @@ -5,9 +5,7 @@ changelogs = \ pkgconfigdir = $(libdir)/pkgconfig pkgconfig_DATA = \ camel.pc \ - evolution-shell.pc \ - evolution-addressbook.pc \ - evolution-calendar.pc + evolution-shell.pc EXTRA_DIST = \ AUTHORS \ @@ -31,7 +29,6 @@ endif SUBDIRS = \ data \ e-util \ - libical \ libversit \ a11y \ widgets \ @@ -47,7 +44,6 @@ SUBDIRS = \ ui \ default_user \ views \ - wombat \ tools \ help \ po diff --git a/a11y/ChangeLog b/a11y/ChangeLog index 8d3d11e3af..7b340c9241 100644 --- a/a11y/ChangeLog +++ b/a11y/ChangeLog @@ -1,3 +1,7 @@ +2003-11-07 JP Rosevear <jpr@ximian.com> + + * Reflect renaming of ECalView to ECalendarView + 2003-11-04 Bolian Yin <bolian.yin@sun.com> Fixes # 48509 diff --git a/a11y/calendar/ea-cal-view-event.c b/a11y/calendar/ea-cal-view-event.c index 80122375c3..0db3e91039 100644 --- a/a11y/calendar/ea-cal-view-event.c +++ b/a11y/calendar/ea-cal-view-event.c @@ -134,7 +134,7 @@ ea_cal_view_event_new (GObject *obj) { AtkObject *atk_obj = NULL; GObject *target_obj; - ECalView *cal_view; + ECalendarView *cal_view; g_return_val_if_fail (E_IS_TEXT (obj), NULL); cal_view = ea_calendar_helpers_get_cal_view_from (GNOME_CANVAS_ITEM (obj)); @@ -194,7 +194,7 @@ ea_cal_view_event_get_name (AtkObject *accessible) { AtkGObjectAccessible *atk_gobj; GObject *g_obj; - ECalViewEvent *event; + ECalendarViewEvent *event; gchar *tmp_name; gchar *new_name = g_strdup (""); const char *summary; @@ -273,7 +273,7 @@ ea_cal_view_event_get_parent (AtkObject *accessible) AtkGObjectAccessible *atk_gobj; GObject *g_obj; GnomeCanvasItem *canvas_item; - ECalView *cal_view; + ECalendarView *cal_view; g_return_val_if_fail (EA_IS_CAL_VIEW_EVENT (accessible), NULL); atk_gobj = ATK_GOBJECT_ACCESSIBLE (accessible); @@ -297,8 +297,8 @@ ea_cal_view_event_get_index_in_parent (AtkObject *accessible) { GObject *g_obj; GnomeCanvasItem *canvas_item; - ECalView *cal_view; - ECalViewEvent *cal_view_event; + ECalendarView *cal_view; + ECalendarViewEvent *cal_view_event; g_return_val_if_fail (EA_IS_CAL_VIEW_EVENT (accessible), -1); g_obj = atk_gobject_accessible_get_object (ATK_GOBJECT_ACCESSIBLE(accessible)); @@ -325,7 +325,7 @@ ea_cal_view_event_get_index_in_parent (AtkObject *accessible) --event_num) { day_view_event = &g_array_index (day_view->long_events, EDayViewEvent, event_num); - if (cal_view_event == (ECalViewEvent*)day_view_event) + if (cal_view_event == (ECalendarViewEvent*)day_view_event) return event_num; } @@ -336,7 +336,7 @@ ea_cal_view_event_get_index_in_parent (AtkObject *accessible) --event_num) { day_view_event = &g_array_index (day_view->events[day], EDayViewEvent, event_num); - if (cal_view_event == (ECalViewEvent*)day_view_event) + if (cal_view_event == (ECalendarViewEvent*)day_view_event) return num_before + event_num; } num_before += day_view->events[day]->len; @@ -350,7 +350,7 @@ ea_cal_view_event_get_index_in_parent (AtkObject *accessible) for (index = week_view->events->len - 1; index >= 0; --index) { week_view_event = &g_array_index (week_view->events, EWeekViewEvent, index); - if (cal_view_event == (ECalViewEvent*)week_view_event) + if (cal_view_event == (ECalendarViewEvent*)week_view_event) return index; } } @@ -383,7 +383,7 @@ ea_cal_view_get_extents (AtkComponent *component, GnomeCanvasItem *canvas_item; gint x_window, y_window; gint scroll_x, scroll_y; - ECalView *cal_view; + ECalendarView *cal_view; gint item_x, item_y, item_w, item_h; GtkWidget *canvas = NULL; diff --git a/a11y/calendar/ea-cal-view.c b/a11y/calendar/ea-cal-view.c index fe3c3de1cf..9b68d24f9f 100644 --- a/a11y/calendar/ea-cal-view.c +++ b/a11y/calendar/ea-cal-view.c @@ -36,10 +36,10 @@ static void ea_cal_view_class_init (EaCalViewClass *klass); static AtkObject* ea_cal_view_get_parent (AtkObject *accessible); static void ea_cal_view_real_initialize (AtkObject *accessible, gpointer data); -static void ea_cal_view_event_changed_cb (ECalView *cal_view, - ECalViewEvent *event, gpointer data); -static void ea_cal_view_event_added_cb (ECalView *cal_view, - ECalViewEvent *event, gpointer data); +static void ea_cal_view_event_changed_cb (ECalendarView *cal_view, + ECalendarViewEvent *event, gpointer data); +static void ea_cal_view_event_added_cb (ECalendarView *cal_view, + ECalendarViewEvent *event, gpointer data); static gboolean idle_dates_changed (gpointer data); static void ea_cal_view_dates_change_cb (GnomeCalendar *gcal, gpointer data); @@ -123,7 +123,7 @@ ea_cal_view_new (GtkWidget *widget) GObject *object; AtkObject *accessible; - g_return_val_if_fail (E_IS_CAL_VIEW (widget), NULL); + g_return_val_if_fail (E_IS_CALENDAR_VIEW (widget), NULL); object = g_object_new (EA_TYPE_CAL_VIEW, NULL); @@ -136,18 +136,18 @@ ea_cal_view_new (GtkWidget *widget) static void ea_cal_view_real_initialize (AtkObject *accessible, gpointer data) { - ECalView *cal_view; + ECalendarView *cal_view; GnomeCalendar *gcal; static AtkRole role = ATK_ROLE_INVALID; g_return_if_fail (EA_IS_CAL_VIEW (accessible)); - g_return_if_fail (E_IS_CAL_VIEW (data)); + g_return_if_fail (E_IS_CALENDAR_VIEW (data)); ATK_OBJECT_CLASS (parent_class)->initialize (accessible, data); if (role == ATK_ROLE_INVALID) role = atk_role_register ("Calendar View"); accessible->role = role; - cal_view = E_CAL_VIEW (data); + cal_view = E_CALENDAR_VIEW (data); /* add listener for event_changed, event_added * we don't need to listen on event_removed. When the e_text @@ -160,7 +160,7 @@ ea_cal_view_real_initialize (AtkObject *accessible, gpointer data) G_CALLBACK (ea_cal_view_event_added_cb), NULL); /* listen for date changes of calendar */ - gcal = e_cal_view_get_calendar (cal_view); + gcal = e_calendar_view_get_calendar (cal_view); if (gcal) g_signal_connect (gcal, "dates_shown_changed", @@ -171,29 +171,29 @@ ea_cal_view_real_initialize (AtkObject *accessible, gpointer data) static AtkObject* ea_cal_view_get_parent (AtkObject *accessible) { - ECalView *cal_view; + ECalendarView *cal_view; GnomeCalendar *gnomeCalendar; g_return_val_if_fail (EA_IS_CAL_VIEW (accessible), NULL); if (!GTK_ACCESSIBLE (accessible)->widget) return NULL; - cal_view = E_CAL_VIEW (GTK_ACCESSIBLE (accessible)->widget); + cal_view = E_CALENDAR_VIEW (GTK_ACCESSIBLE (accessible)->widget); - gnomeCalendar = e_cal_view_get_calendar (cal_view); + gnomeCalendar = e_calendar_view_get_calendar (cal_view); return gtk_widget_get_accessible (GTK_WIDGET(gnomeCalendar)); } static void -ea_cal_view_event_changed_cb (ECalView *cal_view, ECalViewEvent *event, +ea_cal_view_event_changed_cb (ECalendarView *cal_view, ECalendarViewEvent *event, gpointer data) { AtkObject *atk_obj; EaCalView *ea_cal_view; AtkObject *event_atk_obj = NULL; - g_return_if_fail (E_IS_CAL_VIEW (cal_view)); + g_return_if_fail (E_IS_CALENDAR_VIEW (cal_view)); atk_obj = gtk_widget_get_accessible (GTK_WIDGET(cal_view)); if (!EA_IS_CAL_VIEW (atk_obj)) @@ -225,7 +225,7 @@ ea_cal_view_event_changed_cb (ECalView *cal_view, ECalViewEvent *event, } static void -ea_cal_view_event_added_cb (ECalView *cal_view, ECalViewEvent *event, +ea_cal_view_event_added_cb (ECalendarView *cal_view, ECalendarViewEvent *event, gpointer data) { AtkObject *atk_obj; @@ -233,7 +233,7 @@ ea_cal_view_event_added_cb (ECalView *cal_view, ECalViewEvent *event, AtkObject *event_atk_obj = NULL; gint index; - g_return_if_fail (E_IS_CAL_VIEW (cal_view)); + g_return_if_fail (E_IS_CALENDAR_VIEW (cal_view)); atk_obj = gtk_widget_get_accessible (GTK_WIDGET(cal_view)); if (!EA_IS_CAL_VIEW (atk_obj)) @@ -327,7 +327,7 @@ action_interface_do_action (AtkAction *action, gint index) GtkWidget *widget; gboolean return_value = TRUE; time_t dtstart, dtend; - ECalView *cal_view; + ECalendarView *cal_view; widget = GTK_ACCESSIBLE (action)->widget; if (widget == NULL) @@ -339,33 +339,33 @@ action_interface_do_action (AtkAction *action, gint index) if (!GTK_WIDGET_IS_SENSITIVE (widget) || !GTK_WIDGET_VISIBLE (widget)) return FALSE; - cal_view = E_CAL_VIEW (widget); + cal_view = E_CALENDAR_VIEW (widget); switch (index) { case 0: /* New Appointment */ - e_cal_view_new_appointment (cal_view); + e_calendar_view_new_appointment (cal_view); break; case 1: /* New Event */ - e_cal_view_get_selected_time_range (cal_view, + e_calendar_view_get_selected_time_range (cal_view, &dtstart, &dtend); - e_cal_view_new_appointment_for (cal_view, + e_calendar_view_new_appointment_for (cal_view, dtstart, dtend, TRUE, FALSE); break; case 2: /* New Meeting */ - e_cal_view_get_selected_time_range (cal_view, + e_calendar_view_get_selected_time_range (cal_view, &dtstart, &dtend); - e_cal_view_new_appointment_for (cal_view, + e_calendar_view_new_appointment_for (cal_view, dtstart, dtend, FALSE, TRUE); break; case 3: /* Go to today */ break; - calendar_goto_today (e_cal_view_get_calendar (cal_view)); + calendar_goto_today (e_calendar_view_get_calendar (cal_view)); case 4: /* Go to date */ - goto_dialog (e_cal_view_get_calendar (cal_view)); + goto_dialog (e_calendar_view_get_calendar (cal_view)); break; default: return_value = FALSE; diff --git a/a11y/calendar/ea-calendar-helpers.c b/a11y/calendar/ea-calendar-helpers.c index e8b0d3aa9c..535265ebeb 100644 --- a/a11y/calendar/ea-calendar-helpers.c +++ b/a11y/calendar/ea-calendar-helpers.c @@ -63,7 +63,7 @@ ea_calendar_helpers_get_accessible_for (GnomeCanvasItem *canvas_item) * Get the cal view widget contains the canvas_item. * **/ -ECalView * +ECalendarView * ea_calendar_helpers_get_cal_view_from (GnomeCanvasItem *canvas_item) { GnomeCanvas *canvas; @@ -77,25 +77,25 @@ ea_calendar_helpers_get_cal_view_from (GnomeCanvasItem *canvas_item) /* parent of canvas_item->canvas is the EDayView or EWeekView widget */ canvas = canvas_item->canvas; view_widget = gtk_widget_get_parent (GTK_WIDGET(canvas)); - if (!view_widget || !E_IS_CAL_VIEW (view_widget)) + if (!view_widget || !E_IS_CALENDAR_VIEW (view_widget)) return NULL; - return E_CAL_VIEW (view_widget); + return E_CALENDAR_VIEW (view_widget); } /** * ea_calendar_helpers_get_cal_view_event_from * @canvas_item: the cavas_item (e_text) for the event - * @returns: the ECalViewEvent + * @returns: the ECalendarViewEvent * - * Get the ECalViewEvent for the canvas_item. + * Get the ECalendarViewEvent for the canvas_item. * **/ -ECalViewEvent * +ECalendarViewEvent * ea_calendar_helpers_get_cal_view_event_from (GnomeCanvasItem *canvas_item) { - ECalView *cal_view; + ECalendarView *cal_view; gboolean event_found; - ECalViewEvent *cal_view_event; + ECalendarViewEvent *cal_view_event; g_return_val_if_fail (E_IS_TEXT (canvas_item), NULL); @@ -122,7 +122,7 @@ ea_calendar_helpers_get_cal_view_event_from (GnomeCanvasItem *canvas_item) day_view_event = &g_array_index (day_view->events[event_day], EDayViewEvent, event_num); } - cal_view_event = (ECalViewEvent *) day_view_event; + cal_view_event = (ECalendarViewEvent *) day_view_event; } else if (E_IS_WEEK_VIEW (cal_view)) { gint event_num, span_num; @@ -138,7 +138,7 @@ ea_calendar_helpers_get_cal_view_event_from (GnomeCanvasItem *canvas_item) week_view_event = &g_array_index (week_view->events, EWeekViewEvent, event_num); - cal_view_event = (ECalViewEvent *)week_view_event; + cal_view_event = (ECalendarViewEvent *)week_view_event; } else { g_assert_not_reached (); diff --git a/a11y/calendar/ea-calendar-helpers.h b/a11y/calendar/ea-calendar-helpers.h index 3b7417a4c0..50d997d91d 100644 --- a/a11y/calendar/ea-calendar-helpers.h +++ b/a11y/calendar/ea-calendar-helpers.h @@ -34,10 +34,10 @@ AtkObject * ea_calendar_helpers_get_accessible_for (GnomeCanvasItem *canvas_item); -ECalView * +ECalendarView * ea_calendar_helpers_get_cal_view_from (GnomeCanvasItem *canvas_item); -ECalViewEvent * +ECalendarViewEvent * ea_calendar_helpers_get_cal_view_event_from (GnomeCanvasItem *canvas_item); #endif /* _EA_CALENDAR_HELPERS_H__ */ diff --git a/addressbook/ChangeLog b/addressbook/ChangeLog index a52ef2373f..1997df2897 100644 --- a/addressbook/ChangeLog +++ b/addressbook/ChangeLog @@ -1,3 +1,9 @@ +2003-11-07 JP Rosevear <jpr@ximian.com> + + * In the gui this is a search and replace commit for moving the + addressbook to evolution-data-server; it also deletes the old + backend files + 2003-11-05 Larry Ewing <lewing@ximian.com> * gui/widgets/e-addressbook-view.c (create_minicard_view): fix cast. diff --git a/addressbook/Makefile.am b/addressbook/Makefile.am index 7bbbce2434..d472f0033b 100644 --- a/addressbook/Makefile.am +++ b/addressbook/Makefile.am @@ -3,7 +3,7 @@ CONDUIT_SUBDIR=conduit endif SUBDIRS = \ - backend util printing gui $(CONDUIT_SUBDIR) + util printing gui $(CONDUIT_SUBDIR) EXTRA_DIST = \ ChangeLog.pre-1-4 diff --git a/addressbook/backend/Makefile.am b/addressbook/backend/Makefile.am deleted file mode 100644 index b2807b2480..0000000000 --- a/addressbook/backend/Makefile.am +++ /dev/null @@ -1 +0,0 @@ -SUBDIRS = idl ebook pas diff --git a/addressbook/backend/ebook/.cvsignore b/addressbook/backend/ebook/.cvsignore deleted file mode 100644 index 17250008f8..0000000000 --- a/addressbook/backend/ebook/.cvsignore +++ /dev/null @@ -1,26 +0,0 @@ -.deps -.libs -.pure -Makefile -Makefile.in -*.lo -*.la -addressbook-stubs.c -addressbook-skels.c -addressbook-common.c -addressbook.h -test-card -test-client -test-client-list -test-ebook -load-pine-addressbook -load-gnomecard-addressbook -evolution-vcard-importer -evolution-gnomecard-importer -evolution-ldif-importer -GNOME_Evolution_Addressbook_VCard_Importer.server -GNOME_Evolution_Addressbook_LDIF_Importer.server -GNOME_Evolution_Addressbook_VCard_Importer.server.in -GNOME_Evolution_Addressbook_LDIF_Importer.server.in -e-book-marshal.c -e-book-marshal.h diff --git a/addressbook/backend/ebook/GNOME_Evolution_Addressbook_LDIF_Importer.server.in.in b/addressbook/backend/ebook/GNOME_Evolution_Addressbook_LDIF_Importer.server.in.in deleted file mode 100644 index 392220d119..0000000000 --- a/addressbook/backend/ebook/GNOME_Evolution_Addressbook_LDIF_Importer.server.in.in +++ /dev/null @@ -1,29 +0,0 @@ -<oaf_info> - -<oaf_server iid="OAFIID:GNOME_Evolution_Addressbook_LDIF_ImporterFactory" - type="exe" - location="@LIBEXECDIR@/evolution-ldif-importer"> - - <oaf_attribute name="repo_ids" type="stringv"> - <item value="IDL:GNOME/ObjectFactory:1.0"/> - </oaf_attribute> - - <oaf_attribute name="name" type="string" - _value="Evolution LDIF importer"/> -</oaf_server> - -<oaf_server iid="OAFIID:GNOME_Evolution_Addressbook_LDIF_Importer" - type="factory" - location="OAFIID:GNOME_Evolution_Addressbook_LDIF_ImporterFactory"> - - <oaf_attribute name="repo_ids" type="stringv"> - <item value="IDL:GNOME/Evolution/Importer:1.0"/> - </oaf_attribute> - - <oaf_attribute name="evolution:menu_name" type="string" - _value="LDAP Data Interchange Format (.ldif)"/> - <oaf_attribute name="name" type="string" - _value="Evolution LDIF importer"/> -</oaf_server> - -</oaf_info> diff --git a/addressbook/backend/ebook/GNOME_Evolution_Addressbook_VCard_Importer.server.in.in b/addressbook/backend/ebook/GNOME_Evolution_Addressbook_VCard_Importer.server.in.in deleted file mode 100644 index b630d31bec..0000000000 --- a/addressbook/backend/ebook/GNOME_Evolution_Addressbook_VCard_Importer.server.in.in +++ /dev/null @@ -1,29 +0,0 @@ -<oaf_info> - -<oaf_server iid="OAFIID:GNOME_Evolution_Addressbook_VCard_ImporterFactory" - type="exe" - location="@LIBEXECDIR@/evolution-vcard-importer"> - - <oaf_attribute name="repo_ids" type="stringv"> - <item value="IDL:GNOME/ObjectFactory:1.0"/> - </oaf_attribute> - - <oaf_attribute name="name" type="string" - _value="Evolution VCard importer"/> -</oaf_server> - -<oaf_server iid="OAFIID:GNOME_Evolution_Addressbook_VCard_Importer" - type="factory" - location="OAFIID:GNOME_Evolution_Addressbook_VCard_ImporterFactory"> - - <oaf_attribute name="repo_ids" type="stringv"> - <item value="IDL:GNOME/Evolution/Importer:1.0"/> - </oaf_attribute> - - <oaf_attribute name="evolution:menu_name" type="string" - _value="VCard (.vcf, .gcrd)"/> - <oaf_attribute name="name" type="string" - _value="Evolution VCard Importer"/> -</oaf_server> - -</oaf_info> diff --git a/addressbook/backend/ebook/Makefile.am b/addressbook/backend/ebook/Makefile.am deleted file mode 100644 index e83e3e1411..0000000000 --- a/addressbook/backend/ebook/Makefile.am +++ /dev/null @@ -1,79 +0,0 @@ -# CORBA stuff - -SUBDIRS = . tests - -CORBA_ADDRESSBOOK_SOURCE_H = \ - addressbook.h -CORBA_ADDRESSBOOK_SOURCE_C = \ - addressbook-common.c \ - addressbook-stubs.c \ - addressbook-skels.c -CORBA_ADDRESSBOOK_IDL = $(srcdir)/../idl/addressbook.idl - -$(CORBA_ADDRESSBOOK_SOURCE_H): $(CORBA_ADDRESSBOOK_IDL) - $(ORBIT_IDL) -I $(srcdir) $(IDL_INCLUDES) $(CORBA_ADDRESSBOOK_IDL) - -$(CORBA_ADDRESSBOOK_SOURCE_C): $(CORBA_ADDRESSBOOK_SOURCE_H) - -CORBA_SOURCE_H = $(CORBA_ADDRESSBOOK_SOURCE_H) -CORBA_SOURCE_C = $(CORBA_ADDRESSBOOK_SOURCE_C) -CORBA_SOURCE = $(CORBA_SOURCE_H) $(CORBA_SOURCE_C) - - -# The component - -INCLUDES = \ - -DPREFIX=\"$(prefix)\" \ - -DSYSCONFDIR=\"$(sysconfdir)\" \ - -DDATADIR=\"$(datadir)\" \ - -DLIBDIR=\"$(libdir)\" \ - -DG_LOG_DOMAIN=\"EBook\" \ - -I$(top_srcdir) \ - -I$(top_srcdir)/addressbook/backend \ - -I$(top_srcdir)/addressbook/ename \ - -I$(top_builddir)/addressbook/backend \ - -I$(top_builddir)/addressbook/ename \ - -DG_DISABLE_DEPRECATED \ - -DLIBGNOME_DISABLE_DEPRECATED \ - $(EVOLUTION_ADDRESSBOOK_CFLAGS) - -privlib_LTLIBRARIES = libebook.la - -libebook_la_SOURCES = \ - $(CORBA_SOURCE) \ - addressbook.h \ - e-book-marshal.c \ - e-book-query.c \ - e-book-view-listener.c \ - e-book-view.c \ - e-book-listener.c \ - e-book.c \ - e-book-async.c \ - e-contact.c \ - e-vcard.c - -libebook_la_LIBADD = \ - $(top_builddir)/libversit/libversit.la \ - $(top_builddir)/e-util/ename/libename.la \ - $(top_builddir)/e-util/libeutil.la - -libebookincludedir = $(privincludedir)/ebook - -libebookinclude_HEADERS = \ - e-book-query.h \ - e-book-view-listener.h \ - e-book-view.h \ - e-book-types.h \ - e-book-listener.h \ - e-book.h \ - e-contact.h \ - e-vcard.h - -MARSHAL_GENERATED = e-book-marshal.c e-book-marshal.h -@EVO_MARSHAL_RULE@ - -BUILT_SOURCES = $(CORBA_SOURCE) $(MARSHAL_GENERATED) -CLEANFILES = $(BUILT_SOURCES) - -dist-hook: - cd $(distdir); rm -f $(BUILT_SOURCES) diff --git a/addressbook/backend/ebook/TODO b/addressbook/backend/ebook/TODO deleted file mode 100644 index a69703cd92..0000000000 --- a/addressbook/backend/ebook/TODO +++ /dev/null @@ -1,2 +0,0 @@ -* Make sure open_book_progress does not use the EBook op queue; make - sure it works. diff --git a/addressbook/backend/ebook/docs/rfc2047.txt b/addressbook/backend/ebook/docs/rfc2047.txt deleted file mode 100644 index ff9a744bf3..0000000000 --- a/addressbook/backend/ebook/docs/rfc2047.txt +++ /dev/null @@ -1,843 +0,0 @@ - - - - - - -Network Working Group K. Moore -Request for Comments: 2047 University of Tennessee -Obsoletes: 1521, 1522, 1590 November 1996 -Category: Standards Track - - - MIME (Multipurpose Internet Mail Extensions) Part Three: - Message Header Extensions for Non-ASCII Text - -Status of this Memo - - This document specifies an Internet standards track protocol for the - Internet community, and requests discussion and suggestions for - improvements. Please refer to the current edition of the "Internet - Official Protocol Standards" (STD 1) for the standardization state - and status of this protocol. Distribution of this memo is unlimited. - -Abstract - - STD 11, RFC 822, defines a message representation protocol specifying - considerable detail about US-ASCII message headers, and leaves the - message content, or message body, as flat US-ASCII text. This set of - documents, collectively called the Multipurpose Internet Mail - Extensions, or MIME, redefines the format of messages to allow for - - (1) textual message bodies in character sets other than US-ASCII, - - (2) an extensible set of different formats for non-textual message - bodies, - - (3) multi-part message bodies, and - - (4) textual header information in character sets other than US-ASCII. - - These documents are based on earlier work documented in RFC 934, STD - 11, and RFC 1049, but extends and revises them. Because RFC 822 said - so little about message bodies, these documents are largely - orthogonal to (rather than a revision of) RFC 822. - - This particular document is the third document in the series. It - describes extensions to RFC 822 to allow non-US-ASCII text data in - Internet mail header fields. - - - - - - - - - -Moore Standards Track [Page 1] - -RFC 2047 Message Header Extensions November 1996 - - - Other documents in this series include: - - + RFC 2045, which specifies the various headers used to describe - the structure of MIME messages. - - + RFC 2046, which defines the general structure of the MIME media - typing system and defines an initial set of media types, - - + RFC 2048, which specifies various IANA registration procedures - for MIME-related facilities, and - - + RFC 2049, which describes MIME conformance criteria and - provides some illustrative examples of MIME message formats, - acknowledgements, and the bibliography. - - These documents are revisions of RFCs 1521, 1522, and 1590, which - themselves were revisions of RFCs 1341 and 1342. An appendix in RFC - 2049 describes differences and changes from previous versions. - -1. Introduction - - RFC 2045 describes a mechanism for denoting textual body parts which - are coded in various character sets, as well as methods for encoding - such body parts as sequences of printable US-ASCII characters. This - memo describes similar techniques to allow the encoding of non-ASCII - text in various portions of a RFC 822 [2] message header, in a manner - which is unlikely to confuse existing message handling software. - - Like the encoding techniques described in RFC 2045, the techniques - outlined here were designed to allow the use of non-ASCII characters - in message headers in a way which is unlikely to be disturbed by the - quirks of existing Internet mail handling programs. In particular, - some mail relaying programs are known to (a) delete some message - header fields while retaining others, (b) rearrange the order of - addresses in To or Cc fields, (c) rearrange the (vertical) order of - header fields, and/or (d) "wrap" message headers at different places - than those in the original message. In addition, some mail reading - programs are known to have difficulty correctly parsing message - headers which, while legal according to RFC 822, make use of - backslash-quoting to "hide" special characters such as "<", ",", or - ":", or which exploit other infrequently-used features of that - specification. - - While it is unfortunate that these programs do not correctly - interpret RFC 822 headers, to "break" these programs would cause - severe operational problems for the Internet mail system. The - extensions described in this memo therefore do not rely on little- - used features of RFC 822. - - - -Moore Standards Track [Page 2] - -RFC 2047 Message Header Extensions November 1996 - - - Instead, certain sequences of "ordinary" printable ASCII characters - (known as "encoded-words") are reserved for use as encoded data. The - syntax of encoded-words is such that they are unlikely to - "accidentally" appear as normal text in message headers. - Furthermore, the characters used in encoded-words are restricted to - those which do not have special meanings in the context in which the - encoded-word appears. - - Generally, an "encoded-word" is a sequence of printable ASCII - characters that begins with "=?", ends with "?=", and has two "?"s in - between. It specifies a character set and an encoding method, and - also includes the original text encoded as graphic ASCII characters, - according to the rules for that encoding method. - - A mail composer that implements this specification will provide a - means of inputting non-ASCII text in header fields, but will - translate these fields (or appropriate portions of these fields) into - encoded-words before inserting them into the message header. - - A mail reader that implements this specification will recognize - encoded-words when they appear in certain portions of the message - header. Instead of displaying the encoded-word "as is", it will - reverse the encoding and display the original text in the designated - character set. - -NOTES - - This memo relies heavily on notation and terms defined RFC 822 and - RFC 2045. In particular, the syntax for the ABNF used in this memo - is defined in RFC 822, as well as many of the terminal or nonterminal - symbols from RFC 822 are used in the grammar for the header - extensions defined here. Among the symbols defined in RFC 822 and - referenced in this memo are: 'addr-spec', 'atom', 'CHAR', 'comment', - 'CTLs', 'ctext', 'linear-white-space', 'phrase', 'quoted-pair'. - 'quoted-string', 'SPACE', and 'word'. Successful implementation of - this protocol extension requires careful attention to the RFC 822 - definitions of these terms. - - When the term "ASCII" appears in this memo, it refers to the "7-Bit - American Standard Code for Information Interchange", ANSI X3.4-1986. - The MIME charset name for this character set is "US-ASCII". When not - specifically referring to the MIME charset name, this document uses - the term "ASCII", both for brevity and for consistency with RFC 822. - However, implementors are warned that the character set name must be - spelled "US-ASCII" in MIME message and body part headers. - - - - - - -Moore Standards Track [Page 3] - -RFC 2047 Message Header Extensions November 1996 - - - This memo specifies a protocol for the representation of non-ASCII - text in message headers. It specifically DOES NOT define any - translation between "8-bit headers" and pure ASCII headers, nor is - any such translation assumed to be possible. - -2. Syntax of encoded-words - - An 'encoded-word' is defined by the following ABNF grammar. The - notation of RFC 822 is used, with the exception that white space - characters MUST NOT appear between components of an 'encoded-word'. - - encoded-word = "=?" charset "?" encoding "?" encoded-text "?=" - - charset = token ; see section 3 - - encoding = token ; see section 4 - - token = 1*<Any CHAR except SPACE, CTLs, and especials> - - especials = "(" / ")" / "<" / ">" / "@" / "," / ";" / ":" / " - <"> / "/" / "[" / "]" / "?" / "." / "=" - - encoded-text = 1*<Any printable ASCII character other than "?" - or SPACE> - ; (but see "Use of encoded-words in message - ; headers", section 5) - - Both 'encoding' and 'charset' names are case-independent. Thus the - charset name "ISO-8859-1" is equivalent to "iso-8859-1", and the - encoding named "Q" may be spelled either "Q" or "q". - - An 'encoded-word' may not be more than 75 characters long, including - 'charset', 'encoding', 'encoded-text', and delimiters. If it is - desirable to encode more text than will fit in an 'encoded-word' of - 75 characters, multiple 'encoded-word's (separated by CRLF SPACE) may - be used. - - While there is no limit to the length of a multiple-line header - field, each line of a header field that contains one or more - 'encoded-word's is limited to 76 characters. - - The length restrictions are included both to ease interoperability - through internetwork mail gateways, and to impose a limit on the - amount of lookahead a header parser must employ (while looking for a - final ?= delimiter) before it can decide whether a token is an - "encoded-word" or something else. - - - - - -Moore Standards Track [Page 4] - -RFC 2047 Message Header Extensions November 1996 - - - IMPORTANT: 'encoded-word's are designed to be recognized as 'atom's - by an RFC 822 parser. As a consequence, unencoded white space - characters (such as SPACE and HTAB) are FORBIDDEN within an - 'encoded-word'. For example, the character sequence - - =?iso-8859-1?q?this is some text?= - - would be parsed as four 'atom's, rather than as a single 'atom' (by - an RFC 822 parser) or 'encoded-word' (by a parser which understands - 'encoded-words'). The correct way to encode the string "this is some - text" is to encode the SPACE characters as well, e.g. - - =?iso-8859-1?q?this=20is=20some=20text?= - - The characters which may appear in 'encoded-text' are further - restricted by the rules in section 5. - -3. Character sets - - The 'charset' portion of an 'encoded-word' specifies the character - set associated with the unencoded text. A 'charset' can be any of - the character set names allowed in an MIME "charset" parameter of a - "text/plain" body part, or any character set name registered with - IANA for use with the MIME text/plain content-type. - - Some character sets use code-switching techniques to switch between - "ASCII mode" and other modes. If unencoded text in an 'encoded-word' - contains a sequence which causes the charset interpreter to switch - out of ASCII mode, it MUST contain additional control codes such that - ASCII mode is again selected at the end of the 'encoded-word'. (This - rule applies separately to each 'encoded-word', including adjacent - 'encoded-word's within a single header field.) - - When there is a possibility of using more than one character set to - represent the text in an 'encoded-word', and in the absence of - private agreements between sender and recipients of a message, it is - recommended that members of the ISO-8859-* series be used in - preference to other character sets. - -4. Encodings - - Initially, the legal values for "encoding" are "Q" and "B". These - encodings are described below. The "Q" encoding is recommended for - use when most of the characters to be encoded are in the ASCII - character set; otherwise, the "B" encoding should be used. - Nevertheless, a mail reader which claims to recognize 'encoded-word's - MUST be able to accept either encoding for any character set which it - supports. - - - -Moore Standards Track [Page 5] - -RFC 2047 Message Header Extensions November 1996 - - - Only a subset of the printable ASCII characters may be used in - 'encoded-text'. Space and tab characters are not allowed, so that - the beginning and end of an 'encoded-word' are obvious. The "?" - character is used within an 'encoded-word' to separate the various - portions of the 'encoded-word' from one another, and thus cannot - appear in the 'encoded-text' portion. Other characters are also - illegal in certain contexts. For example, an 'encoded-word' in a - 'phrase' preceding an address in a From header field may not contain - any of the "specials" defined in RFC 822. Finally, certain other - characters are disallowed in some contexts, to ensure reliability for - messages that pass through internetwork mail gateways. - - The "B" encoding automatically meets these requirements. The "Q" - encoding allows a wide range of printable characters to be used in - non-critical locations in the message header (e.g., Subject), with - fewer characters available for use in other locations. - -4.1. The "B" encoding - - The "B" encoding is identical to the "BASE64" encoding defined by RFC - 2045. - -4.2. The "Q" encoding - - The "Q" encoding is similar to the "Quoted-Printable" content- - transfer-encoding defined in RFC 2045. It is designed to allow text - containing mostly ASCII characters to be decipherable on an ASCII - terminal without decoding. - - (1) Any 8-bit value may be represented by a "=" followed by two - hexadecimal digits. For example, if the character set in use - were ISO-8859-1, the "=" character would thus be encoded as - "=3D", and a SPACE by "=20". (Upper case should be used for - hexadecimal digits "A" through "F".) - - (2) The 8-bit hexadecimal value 20 (e.g., ISO-8859-1 SPACE) may be - represented as "_" (underscore, ASCII 95.). (This character may - not pass through some internetwork mail gateways, but its use - will greatly enhance readability of "Q" encoded data with mail - readers that do not support this encoding.) Note that the "_" - always represents hexadecimal 20, even if the SPACE character - occupies a different code position in the character set in use. - - (3) 8-bit values which correspond to printable ASCII characters other - than "=", "?", and "_" (underscore), MAY be represented as those - characters. (But see section 5 for restrictions.) In - particular, SPACE and TAB MUST NOT be represented as themselves - within encoded words. - - - -Moore Standards Track [Page 6] - -RFC 2047 Message Header Extensions November 1996 - - -5. Use of encoded-words in message headers - - An 'encoded-word' may appear in a message header or body part header - according to the following rules: - -(1) An 'encoded-word' may replace a 'text' token (as defined by RFC 822) - in any Subject or Comments header field, any extension message - header field, or any MIME body part field for which the field body - is defined as '*text'. An 'encoded-word' may also appear in any - user-defined ("X-") message or body part header field. - - Ordinary ASCII text and 'encoded-word's may appear together in the - same header field. However, an 'encoded-word' that appears in a - header field defined as '*text' MUST be separated from any adjacent - 'encoded-word' or 'text' by 'linear-white-space'. - -(2) An 'encoded-word' may appear within a 'comment' delimited by "(" and - ")", i.e., wherever a 'ctext' is allowed. More precisely, the RFC - 822 ABNF definition for 'comment' is amended as follows: - - comment = "(" *(ctext / quoted-pair / comment / encoded-word) ")" - - A "Q"-encoded 'encoded-word' which appears in a 'comment' MUST NOT - contain the characters "(", ")" or " - 'encoded-word' that appears in a 'comment' MUST be separated from - any adjacent 'encoded-word' or 'ctext' by 'linear-white-space'. - - It is important to note that 'comment's are only recognized inside - "structured" field bodies. In fields whose bodies are defined as - '*text', "(" and ")" are treated as ordinary characters rather than - comment delimiters, and rule (1) of this section applies. (See RFC - 822, sections 3.1.2 and 3.1.3) - -(3) As a replacement for a 'word' entity within a 'phrase', for example, - one that precedes an address in a From, To, or Cc header. The ABNF - definition for 'phrase' from RFC 822 thus becomes: - - phrase = 1*( encoded-word / word ) - - In this case the set of characters that may be used in a "Q"-encoded - 'encoded-word' is restricted to: <upper and lower case ASCII - letters, decimal digits, "!", "*", "+", "-", "/", "=", and "_" - (underscore, ASCII 95.)>. An 'encoded-word' that appears within a - 'phrase' MUST be separated from any adjacent 'word', 'text' or - 'special' by 'linear-white-space'. - - - - - - -Moore Standards Track [Page 7] - -RFC 2047 Message Header Extensions November 1996 - - - These are the ONLY locations where an 'encoded-word' may appear. In - particular: - - + An 'encoded-word' MUST NOT appear in any portion of an 'addr-spec'. - - + An 'encoded-word' MUST NOT appear within a 'quoted-string'. - - + An 'encoded-word' MUST NOT be used in a Received header field. - - + An 'encoded-word' MUST NOT be used in parameter of a MIME - Content-Type or Content-Disposition field, or in any structured - field body except within a 'comment' or 'phrase'. - - The 'encoded-text' in an 'encoded-word' must be self-contained; - 'encoded-text' MUST NOT be continued from one 'encoded-word' to - another. This implies that the 'encoded-text' portion of a "B" - 'encoded-word' will be a multiple of 4 characters long; for a "Q" - 'encoded-word', any "=" character that appears in the 'encoded-text' - portion will be followed by two hexadecimal characters. - - Each 'encoded-word' MUST encode an integral number of octets. The - 'encoded-text' in each 'encoded-word' must be well-formed according - to the encoding specified; the 'encoded-text' may not be continued in - the next 'encoded-word'. (For example, "=?charset?Q?=?= - =?charset?Q?AB?=" would be illegal, because the two hex digits "AB" - must follow the "=" in the same 'encoded-word'.) - - Each 'encoded-word' MUST represent an integral number of characters. - A multi-octet character may not be split across adjacent 'encoded- - word's. - - Only printable and white space character data should be encoded using - this scheme. However, since these encoding schemes allow the - encoding of arbitrary octet values, mail readers that implement this - decoding should also ensure that display of the decoded data on the - recipient's terminal will not cause unwanted side-effects. - - Use of these methods to encode non-textual data (e.g., pictures or - sounds) is not defined by this memo. Use of 'encoded-word's to - represent strings of purely ASCII characters is allowed, but - discouraged. In rare cases it may be necessary to encode ordinary - text that looks like an 'encoded-word'. - - - - - - - - - -Moore Standards Track [Page 8] - -RFC 2047 Message Header Extensions November 1996 - - -6. Support of 'encoded-word's by mail readers - -6.1. Recognition of 'encoded-word's in message headers - - A mail reader must parse the message and body part headers according - to the rules in RFC 822 to correctly recognize 'encoded-word's. - - 'encoded-word's are to be recognized as follows: - - (1) Any message or body part header field defined as '*text', or any - user-defined header field, should be parsed as follows: Beginning - at the start of the field-body and immediately following each - occurrence of 'linear-white-space', each sequence of up to 75 - printable characters (not containing any 'linear-white-space') - should be examined to see if it is an 'encoded-word' according to - the syntax rules in section 2. Any other sequence of printable - characters should be treated as ordinary ASCII text. - - (2) Any header field not defined as '*text' should be parsed - according to the syntax rules for that header field. However, - any 'word' that appears within a 'phrase' should be treated as an - 'encoded-word' if it meets the syntax rules in section 2. - Otherwise it should be treated as an ordinary 'word'. - - (3) Within a 'comment', any sequence of up to 75 printable characters - (not containing 'linear-white-space'), that meets the syntax - rules in section 2, should be treated as an 'encoded-word'. - Otherwise it should be treated as normal comment text. - - (4) A MIME-Version header field is NOT required to be present for - 'encoded-word's to be interpreted according to this - specification. One reason for this is that the mail reader is - not expected to parse the entire message header before displaying - lines that may contain 'encoded-word's. - -6.2. Display of 'encoded-word's - - Any 'encoded-word's so recognized are decoded, and if possible, the - resulting unencoded text is displayed in the original character set. - - NOTE: Decoding and display of encoded-words occurs *after* a - structured field body is parsed into tokens. It is therefore - possible to hide 'special' characters in encoded-words which, when - displayed, will be indistinguishable from 'special' characters in the - surrounding text. For this and other reasons, it is NOT generally - possible to translate a message header containing 'encoded-word's to - an unencoded form which can be parsed by an RFC 822 mail reader. - - - - -Moore Standards Track [Page 9] - -RFC 2047 Message Header Extensions November 1996 - - - When displaying a particular header field that contains multiple - 'encoded-word's, any 'linear-white-space' that separates a pair of - adjacent 'encoded-word's is ignored. (This is to allow the use of - multiple 'encoded-word's to represent long strings of unencoded text, - without having to separate 'encoded-word's where spaces occur in the - unencoded text.) - - In the event other encodings are defined in the future, and the mail - reader does not support the encoding used, it may either (a) display - the 'encoded-word' as ordinary text, or (b) substitute an appropriate - message indicating that the text could not be decoded. - - If the mail reader does not support the character set used, it may - (a) display the 'encoded-word' as ordinary text (i.e., as it appears - in the header), (b) make a "best effort" to display using such - characters as are available, or (c) substitute an appropriate message - indicating that the decoded text could not be displayed. - - If the character set being used employs code-switching techniques, - display of the encoded text implicitly begins in "ASCII mode". In - addition, the mail reader must ensure that the output device is once - again in "ASCII mode" after the 'encoded-word' is displayed. - -6.3. Mail reader handling of incorrectly formed 'encoded-word's - - It is possible that an 'encoded-word' that is legal according to the - syntax defined in section 2, is incorrectly formed according to the - rules for the encoding being used. For example: - - (1) An 'encoded-word' which contains characters which are not legal - for a particular encoding (for example, a "-" in the "B" - encoding, or a SPACE or HTAB in either the "B" or "Q" encoding), - is incorrectly formed. - - (2) Any 'encoded-word' which encodes a non-integral number of - characters or octets is incorrectly formed. - - A mail reader need not attempt to display the text associated with an - 'encoded-word' that is incorrectly formed. However, a mail reader - MUST NOT prevent the display or handling of a message because an - 'encoded-word' is incorrectly formed. - -7. Conformance - - A mail composing program claiming compliance with this specification - MUST ensure that any string of non-white-space printable ASCII - characters within a '*text' or '*ctext' that begins with "=?" and - ends with "?=" be a valid 'encoded-word'. ("begins" means: at the - - - -Moore Standards Track [Page 10] - -RFC 2047 Message Header Extensions November 1996 - - - start of the field-body, immediately following 'linear-white-space', - or immediately following a "(" for an 'encoded-word' within '*ctext'; - "ends" means: at the end of the field-body, immediately preceding - 'linear-white-space', or immediately preceding a ")" for an - 'encoded-word' within '*ctext'.) In addition, any 'word' within a - 'phrase' that begins with "=?" and ends with "?=" must be a valid - 'encoded-word'. - - A mail reading program claiming compliance with this specification - must be able to distinguish 'encoded-word's from 'text', 'ctext', or - 'word's, according to the rules in section 6, anytime they appear in - appropriate places in message headers. It must support both the "B" - and "Q" encodings for any character set which it supports. The - program must be able to display the unencoded text if the character - set is "US-ASCII". For the ISO-8859-* character sets, the mail - reading program must at least be able to display the characters which - are also in the ASCII set. - -8. Examples - - The following are examples of message headers containing 'encoded- - word's: - - From: =?US-ASCII?Q?Keith_Moore?= <moore@cs.utk.edu> - To: =?ISO-8859-1?Q?Keld_J=F8rn_Simonsen?= <keld@dkuug.dk> - CC: =?ISO-8859-1?Q?Andr=E9?= Pirard <PIRARD@vm1.ulg.ac.be> - Subject: =?ISO-8859-1?B?SWYgeW91IGNhbiByZWFkIHRoaXMgeW8=?= - =?ISO-8859-2?B?dSB1bmRlcnN0YW5kIHRoZSBleGFtcGxlLg==?= - - Note: In the first 'encoded-word' of the Subject field above, the - last "=" at the end of the 'encoded-text' is necessary because each - 'encoded-word' must be self-contained (the "=" character completes a - group of 4 base64 characters representing 2 octets). An additional - octet could have been encoded in the first 'encoded-word' (so that - the encoded-word would contain an exact multiple of 3 encoded - octets), except that the second 'encoded-word' uses a different - 'charset' than the first one. - - From: =?ISO-8859-1?Q?Olle_J=E4rnefors?= <ojarnef@admin.kth.se> - To: ietf-822@dimacs.rutgers.edu, ojarnef@admin.kth.se - Subject: Time for ISO 10646? - - To: Dave Crocker <dcrocker@mordor.stanford.edu> - Cc: ietf-822@dimacs.rutgers.edu, paf@comsol.se - From: =?ISO-8859-1?Q?Patrik_F=E4ltstr=F6m?= <paf@nada.kth.se> - Subject: Re: RFC-HDR care and feeding - - - - - -Moore Standards Track [Page 11] - -RFC 2047 Message Header Extensions November 1996 - - - From: Nathaniel Borenstein <nsb@thumper.bellcore.com> - (=?iso-8859-8?b?7eXs+SDv4SDp7Oj08A==?=) - To: Greg Vaudreuil <gvaudre@NRI.Reston.VA.US>, Ned Freed - <ned@innosoft.com>, Keith Moore <moore@cs.utk.edu> - Subject: Test of new header generator - MIME-Version: 1.0 - Content-type: text/plain; charset=ISO-8859-1 - - The following examples illustrate how text containing 'encoded-word's - which appear in a structured field body. The rules are slightly - different for fields defined as '*text' because "(" and ")" are not - recognized as 'comment' delimiters. [Section 5, paragraph (1)]. - - In each of the following examples, if the same sequence were to occur - in a '*text' field, the "displayed as" form would NOT be treated as - encoded words, but be identical to the "encoded form". This is - because each of the encoded-words in the following examples is - adjacent to a "(" or ")" character. - - encoded form displayed as - --------------------------------------------------------------------- - (=?ISO-8859-1?Q?a?=) (a) - - (=?ISO-8859-1?Q?a?= b) (a b) - - Within a 'comment', white space MUST appear between an - 'encoded-word' and surrounding text. [Section 5, - paragraph (2)]. However, white space is not needed between - the initial "(" that begins the 'comment', and the - 'encoded-word'. - - - (=?ISO-8859-1?Q?a?= =?ISO-8859-1?Q?b?=) (ab) - - White space between adjacent 'encoded-word's is not - displayed. - - (=?ISO-8859-1?Q?a?= =?ISO-8859-1?Q?b?=) (ab) - - Even multiple SPACEs between 'encoded-word's are ignored - for the purpose of display. - - (=?ISO-8859-1?Q?a?= (ab) - =?ISO-8859-1?Q?b?=) - - Any amount of linear-space-white between 'encoded-word's, - even if it includes a CRLF followed by one or more SPACEs, - is ignored for the purposes of display. - - - -Moore Standards Track [Page 12] - -RFC 2047 Message Header Extensions November 1996 - - - (=?ISO-8859-1?Q?a_b?=) (a b) - - In order to cause a SPACE to be displayed within a portion - of encoded text, the SPACE MUST be encoded as part of the - 'encoded-word'. - - (=?ISO-8859-1?Q?a?= =?ISO-8859-2?Q?_b?=) (a b) - - In order to cause a SPACE to be displayed between two strings - of encoded text, the SPACE MAY be encoded as part of one of - the 'encoded-word's. - -9. References - - [RFC 822] Crocker, D., "Standard for the Format of ARPA Internet Text - Messages", STD 11, RFC 822, UDEL, August 1982. - - [RFC 2049] Borenstein, N., and N. Freed, "Multipurpose Internet Mail - Extensions (MIME) Part Five: Conformance Criteria and Examples", - RFC 2049, November 1996. - - [RFC 2045] Borenstein, N., and N. Freed, "Multipurpose Internet Mail - Extensions (MIME) Part One: Format of Internet Message Bodies", - RFC 2045, November 1996. - - [RFC 2046] Borenstein N., and N. Freed, "Multipurpose Internet Mail - Extensions (MIME) Part Two: Media Types", RFC 2046, - November 1996. - - [RFC 2048] Freed, N., Klensin, J., and J. Postel, "Multipurpose - Internet Mail Extensions (MIME) Part Four: Registration - Procedures", RFC 2048, November 1996. - - - - - - - - - - - - - - - - - - - -Moore Standards Track [Page 13] - -RFC 2047 Message Header Extensions November 1996 - - -10. Security Considerations - - Security issues are not discussed in this memo. - -11. Acknowledgements - - The author wishes to thank Nathaniel Borenstein, Issac Chan, Lutz - Donnerhacke, Paul Eggert, Ned Freed, Andreas M. Kirchwitz, Olle - Jarnefors, Mike Rosin, Yutaka Sato, Bart Schaefer, and Kazuhiko - Yamamoto, for their helpful advice, insightful comments, and - illuminating questions in response to earlier versions of this - specification. - -12. Author's Address - - Keith Moore - University of Tennessee - 107 Ayres Hall - Knoxville TN 37996-1301 - - EMail: moore@cs.utk.edu - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -Moore Standards Track [Page 14] - -RFC 2047 Message Header Extensions November 1996 - - -Appendix - changes since RFC 1522 (in no particular order) - - + explicitly state that the MIME-Version is not requried to use - 'encoded-word's. - - + add explicit note that SPACEs and TABs are not allowed within - 'encoded-word's, explaining that an 'encoded-word' must look like an - 'atom' to an RFC822 parser.values, to be precise). - - + add examples from Olle Jarnefors (thanks!) which illustrate how - encoded-words with adjacent linear-white-space are displayed. - - + explicitly list terms defined in RFC822 and referenced in this memo - - + fix transcription typos that caused one or two lines and a couple of - characters to disappear in the resulting text, due to nroff quirks. - - + clarify that encoded-words are allowed in '*text' fields in both - RFC822 headers and MIME body part headers, but NOT as parameter - values. - - + clarify the requirement to switch back to ASCII within the encoded - portion of an 'encoded-word', for any charset that uses code switching - sequences. - - + add a note about 'encoded-word's being delimited by "(" and ")" - within a comment, but not in a *text (how bizarre!). - - + fix the Andre Pirard example to get rid of the trailing "_" after - the =E9. (no longer needed post-1342). - - + clarification: an 'encoded-word' may appear immediately following - the initial "(" or immediately before the final ")" that delimits a - comment, not just adjacent to "(" and ")" *within* *ctext. - - + add a note to explain that a "B" 'encoded-word' will always have a - multiple of 4 characters in the 'encoded-text' portion. - - + add note about the "=" in the examples - - + note that processing of 'encoded-word's occurs *after* parsing, and - some of the implications thereof. - - + explicitly state that you can't expect to translate between - 1522 and either vanilla 822 or so-called "8-bit headers". - - + explicitly state that 'encoded-word's are not valid within a - 'quoted-string'. - - - -Moore Standards Track [Page 15] - diff --git a/addressbook/backend/ebook/docs/rfc2425.txt b/addressbook/backend/ebook/docs/rfc2425.txt deleted file mode 100644 index 30fed9bc07..0000000000 --- a/addressbook/backend/ebook/docs/rfc2425.txt +++ /dev/null @@ -1,1851 +0,0 @@ - - - - - - -Network Working Group T. Howes -Request for Comments: 2425 M. Smith -Category: Standards Track Netscape Communications Corp. - F. Dawson - Lotus Development Corporation - September 1998 - - - A MIME Content-Type for Directory Information - -Status of this Memo - - This document specifies an Internet standards track protocol for the - Internet community, and requests discussion and suggestions for - improvements. Please refer to the current edition of the "Internet - Official Protocol Standards" (STD 1) for the standardization state - and status of this protocol. Distribution of this memo is unlimited. - -Copyright Notice - - Copyright (C) The Internet Society (1998). All Rights Reserved. - -1. Abstract - - This document defines a MIME Content-Type for holding directory - information. The definition is independent of any particular - directory service or protocol. The text/directory Content-Type is - defined for holding a variety of directory information, for example, - name, or email address, or logo. The text/directory Content-Type can - also be used as the root body part in a multipart/related Content- - Type for handling more complicated situations, especially those in - which non-textual information that already has a natural MIME - representation, for example, a photograph or sound, is to be - represented. - - The text/directory Content-Type defines a general framework and - format for holding directory information in a simple "type:value" - form. We refer to "type" in this context meaning a property or - attribute with which the value is associated. Mechanisms are defined - to specify alternate languages, encodings and other meta-information. - This document also defines the procedure by which particular formats, - called profiles, for carrying application-specific information within - a text/directory Content-Type can be defined and registered, and the - conventions such formats must follow. It is expected that other - documents will be produced that define such formats for various - applications (e.g., white pages). - - - - - -Howes, et. al. Standards Track [Page 1] - -RFC 2425 MIME Content-Type for Directory Information September 1998 - - - The key words "MUST", "MUST NOT", "REQUIRED", "SHALL", "SHALL NOT", - "SHOULD", "SHOULD NOT", "RECOMMENDED", "MAY" and "OPTIONAL" in this - document are to be interpreted as described in [RFC-2119]. - -2. Table of Contents - - Status of the Memo................................................ 1 - Copyright Notice.................................................. 1 - 1. Abstract...................................................... 1 - 2. Table of Contents............................................. 2 - 3. Need for a MIME Directory Type................................ 3 - 4. Overview...................................................... 4 - 5. The text/directory Content-Type............................... 4 - 5.1. MIME media type name........................................ 4 - 5.2. MIME subtype name........................................... 5 - 5.3. Required parameters......................................... 5 - 5.4. Optional parameters......................................... 5 - 5.5. Encoding considerations..................................... 5 - 5.6. Security considerations..................................... 6 - 5.7. Interoperability considerations............................. 6 - 5.8. Published specification..................................... 6 - 5.8.1. Line delimiting and folding............................... 6 - 5.8.2. ABNF content-type definition.............................. 7 - 5.8.3. Pre-defined Parameters.................................... 9 - 5.8.4. Pre-defined Value Types...................................11 - 5.9. Applications which use this media type......................14 - 5.10. Additional information.....................................14 - 5.11. Person & email address to contact for further information..14 - 5.12. Intended usage.............................................14 - 5.13. Author/Change controller...................................15 - 6. Predefined Types..............................................15 - 6.1. SOURCE Type Definition......................................15 - 6.2. NAME Type Definition........................................16 - 6.3. PROFILE Type Definition.....................................16 - 6.4. BEGIN Type Definition.......................................17 - 6.5. END Type Definition.........................................17 - 7. Use of the multipart/related Content-Type.....................18 - 8. Examples.......................................................18 - 8.1. Example 1...................................................19 - 8.2. Example 2...................................................19 - 8.3. Example 3...................................................20 - 8.4. Example 4...................................................21 - 9. Registration of new profiles..................................22 - 9.1. Define the profile..........................................22 - 9.2. Post the profile definition.................................23 - 9.3. Allow a comment period......................................23 - 9.4. Submit the profile for approval.............................23 - 10. Profile Change Control.......................................23 - - - -Howes, et. al. Standards Track [Page 2] - -RFC 2425 MIME Content-Type for Directory Information September 1998 - - - 11. Registration of new types....................................24 - 11.1. Define the type............................................24 - 11.2. Post the type definition...................................25 - 11.3. Allow a comment period.....................................25 - 11.4. Submit the type for approval...............................25 - 12. Type Change Control..........................................25 - 13. Registration of new parameters...............................26 - 13.1. Define the parameter.......................................26 - 13.2. Post the parameter definition..............................27 - 13.3. Allow a comment period.....................................27 - 13.4. Submit the parameter for approval..........................27 - 14. Parameter Change Control.....................................28 - 15. Registration of new value types..............................28 - 15.1. Define the value type......................................28 - 15.2. Post the value type definition.............................29 - 15.3. Allow a comment period.....................................29 - 15.4. Submit the value type for approval.........................29 - 16. Security Considerations......................................30 - 17. Acknowledgements..............................................30 - 18. References....................................................30 - 19. Authors' Addresses...........................................32 - 20. Full Copyright Statement......................................33 - -3. Need for a MIME Directory Type - - For purposes of this document, a directory is a special-purpose - database that contains typed information. A directory usually - supports both read and search of the information it contains, and can - support creation and modification of the information as well. - Directory information is usually accessed far more often than it is - updated. Directories can be local or global in scope. They can be - distributed or centralized. The information they contain can be - replicated, with weak or strong consistency requirements. - - There are several situations in which users of Internet mail might - wish to exchange directory information: the email analogy of a - "business card" exchange; the conveyance of directory information to - a user having only email access to the Internet; the provision of - machine-parseable address information when purchasing goods or - services over the Internet; etc. As MIME [RFC-2045, RFC-2046] is - used increasingly by other protocols, most notably HTTP, it can also - be useful for these protocols to carry directory information in MIME - format. Such a format, for example, could be used to represent URC - (uniform resource characteristics) information about resources on the - World Wide Web, or to provide a rudimentary directory service over - HTTP. - - - - - -Howes, et. al. Standards Track [Page 3] - -RFC 2425 MIME Content-Type for Directory Information September 1998 - - -4. Overview - - The scheme defined here for representing directory information in a - MIME Content-Type has two parts. First, the text/directory Content- - Type is defined for use in holding directory information within a - single body part, for example name, title, or email address. In its - simplest form, the format uses a "type:value" approach, which should - be easily parseable by existing MIME implementations and - understandable by users. More complicated situations can be - represented also. This document defines the general form the - information in the Content-Type should have, and the procedure by - which specific types and values (properties) for particular - applications can be defined. The framework is general enough to - handle information from any number of end directory services, - including LDAP [RFC-1777, RFC-1778], WHOIS++ [RFC-1835], and X.500 - [X500]. - - Directory entries can include far more than just textual information. - Some such information (e.g., an image or sound) overlaps with - predefined MIME Content-Types. In these cases it can be desirable to - include the information in its well-known MIME format. This situation - is handled by using a multipart/related Content-Type as defined in - [RFC-2112]. The root component of this type is a text/directory body - part specifying any in-line information, and for information - contained in other Content-Types, the Content-IDs (in URI form) of - those parts. - - In some applications, it can be useful to include a pointer (e.g, a - URI) to some directory information rather than the information - itself. This document defines a general mechanism for accomplishing - this. - -5. The text/directory Content-Type - - The text/directory Content-Type is used to hold basic directory - information and URIs referencing other information, including other - MIME body parts holding supplementary or non-textual directory - information, such as an image or sound. It is defined as follows, - using the MIME media type registration template from [RFC-2048]. - - To: ietf-types@uninett.no - Subject: Registration of MIME media type text/directory - -5.1. MIME media type name - - MIME media type name: text - - - - - -Howes, et. al. Standards Track [Page 4] - -RFC 2425 MIME Content-Type for Directory Information September 1998 - - -5.2. MIME subtype name - - MIME subtype name: directory - -5.3. Required parameters - - Required parameters: charset - - The "charset" parameter is as defined in [RFC-2046] for other body - parts. It is used to identify the default character set used within - the body part. - -5.4. Optional parameters - - Optional parameters: profile - - The "profile" parameter is used to convey the type(s) of entity(ies) - to which the directory information pertains and the likely set of - information associated with the entity(ies). It is intended only as a - guide to applications interpreting the information contained within - the body part. It SHOULD NOT be used to exclude or require particular - pieces of information unless a profile definition specifically calls - for this behavior. Unless specifically forbidden by a particular - profile definition, a text/directory content type can contain - arbitrary attribute/value pairs. - - The value of the "profile" parameter is defined as follows. Profile - names are case insensitive (i.e., the profile name "vCard" is the - same as "VCARD" and "vcard" and "vcArD"). - - profile = x-name / iana-token - - x-name = "x-" 1*(ALPHA / DIGIT / "-") - ; Names beginning with "x-" or "X-" are - ; reserved for experimental use not intended for released - ; products, or for use in bilateral agreements. - - iana-token = <a publicly-defined extension token, registered - with IANA, as specified in Section 9 of this - document> - -5.5. Encoding considerations - - The default encoding is 8bit. Otherwise, as specified by the - Content-Transfer-Encoding header field. - - - - - - -Howes, et. al. Standards Track [Page 5] - -RFC 2425 MIME Content-Type for Directory Information September 1998 - - -5.6. Security considerations - - Directory information can be public or it can be protected from - unauthorized access by the directory service in which it resides. - Once the information leaves its native service, there can be no - guarantee that the same care will be taken by all services handling - the information. Furthermore, this specification defines no access - control mechanism by which information can be protected, or by which - access control information can be conveyed. Note that the integrity - and privacy of a text/directory body part can be protected by - enclosing it within an appropriate MIME-based security mechanism. - -5.7. Interoperability considerations - - In order to make sense of directory information, applications must - share a common understanding of the types of information contained - within the Content-Type (the directory schema). This schema - information is not defined in this document, but rather in companion - documents (e.g., [MIME-VCARD]) that follow the requirements specified - in this document, or in bilateral agreements between communicating - parties. - -5.8. Published specification - - The text/directory Content-Type contains directory information, - typically pertaining to a single directory entity or group of - entities. The content consists of one or more lines in the format - given below. - -5.8.1. Line delimiting and folding - - Individual lines within the MIME text/directory Content Type body are - delimited by the [RFC-822] line break, which is a CRLF sequence - (ASCII decimal 13, followed by ASCII decimal 10). Long logical lines - of text can be split into a multiple-physical-line representation - using the following folding technique. - - A logical line MAY be continued on the next physical line anywhere - between two characters by inserting a CRLF immediately followed by a - single white space character (space, ASCII decimal 32, or horizontal - tab, ASCII decimal 9). At least one character must be present on the - folded line. Any sequence of CRLF followed immediately by a single - white space character is ignored (removed) when processing the - content type. For example the line: - - DESCRIPTION:This is a long description that exists on a long line. - - Can be represented as: - - - -Howes, et. al. Standards Track [Page 6] - -RFC 2425 MIME Content-Type for Directory Information September 1998 - - - DESCRIPTION:This is a long description - that exists on a long line. - - It could also be represented as: - - DESCRIPTION:This is a long descrip - tion that exists o - n a long line. - - The process of moving from this folded multiple-line representation - of a type definition to its single line representation is called - unfolding. Unfolding is accomplished by regarding CRLF immediately - followed by a white space character (namely HTAB ASCII decimal 9 or - SPACE ASCII decimal 32) as equivalent to no characters at all (i.e., - the CRLF and single white space character are removed). - -5.8.2. ABNF content-type definition - - The following ABNF uses the notation of RFC 2234, which also defines - CRLF, WSP, DQUOTE, VCHAR, ALPHA, and DIGIT. After the unfolding of - any folded lines as described above, the syntax for a line of this - content type is as follows: - - contentline = [group "."] name *(";" param) ":" value CRLF - ; When parsing a content line, folded lines MUST first - ; be unfolded according to the unfolding procedure - ; described above. - ; When generating a content line, lines longer than 75 - ; characters SHOULD be folded according to the folding - ; procedure described above. - - group = 1*(ALPHA / DIGIT / "-") - - name = x-name / iana-token - - iana-token = 1*(ALPHA / DIGIT / "-") - ; identifier registered with IANA - - x-name = "x-" 1*(ALPHA / DIGIT / "-") - ; Names that begin with "x-" or "X-" are - ; reserved for experimental use, not intended for released - ; products, or for use in bilateral agreements. - - param = param-name "=" param-value *("," param-value) - - param-name = x-name / iana-token - - param-value = ptext / quoted-string - - - -Howes, et. al. Standards Track [Page 7] - -RFC 2425 MIME Content-Type for Directory Information September 1998 - - - ptext = *SAFE-CHAR - - value = *VALUE-CHAR - / valuespec ; valuespec defined in section 5.8.4 - - quoted-string = DQUOTE *QSAFE-CHAR DQUOTE - - NON-ASCII = %x80-FF - ; use restricted by charset parameter - ; on outer MIME object (UTF-8 preferred) - - QSAFE-CHAR = WSP / %x21 / %x23-7E / NON-ASCII - ; Any character except CTLs, DQUOTE - - SAFE-CHAR = WSP / %x21 / %x23-2B / %x2D-39 / %x3C-7E / NON-ASCII - ; Any character except CTLs, DQUOTE, ";", ":", "," - - VALUE-CHAR = WSP / VCHAR / NON-ASCII - ; any textual character - - A line that begins with a white space character is a continuation of - the previous line, as described above. The white space character and - immediately preceeding CRLF should be discarded when reconstructing - the original line. Note that this line-folding convention differs - from that found in RFC 822, in that the sequence <CRLF><WSP> found - anywhere in the content indicates a continued line and should be - removed. - - Various type names and the format of the corresponding values are - defined as specified in Section 11. Specifications MAY impose - ordering on the type constructs within a body part, though none is - required by default. The various x-name constructs are used for - bilaterally-agreed upon type names, parameter names and parameter - values, or for use in experimental settings. - - Type names and parameter names are case insensitive (e.g., the type - name "fn" is the same as "FN" and "Fn"). Parameter values MAY be case - sensitive or case insensitive, depending on their definition. - - The group construct is used to group related attributes together. - The group name is a syntactic convention used to indicate that all - type names prefaced with the same group name SHOULD be grouped - together when displayed by an application. It has no other - significance. Implementations that do not understand or support - grouping MAY simply strip off any text before a "." to the left of - the type name and present the types and values as normal. - - - - - -Howes, et. al. Standards Track [Page 8] - -RFC 2425 MIME Content-Type for Directory Information September 1998 - - - Each attribute defined in the text/directory body MAY have multiple - values, if allowed in the definition of the profile in which the - attribute is used. The general rule for encoding multi-valued items - is to simply create a new content line for each value (including the - type name). However, it should be noted that some value types - support encoding multiple values in a single content line by - separating the values with a comma ",". This approach has been taken - for several of the content types defined below (date, time, integer, - float), for space-saving reasons. - -5.8.3. Pre-defined Parameters - - The following parameters and value types are defined for general use. - - predefined-param = encodingparm - / valuetypeparm - / languageparm - / contextparm - - encodingparm = "encoding" "=" encodingtype - - encodingtype = "b" ; from RFC 2047 - / iana-token ; registered as described in - ; section 15 of this document - - valuetypeparm = "value" "=" valuetype - - valuetype = "uri" ; genericurl from secion 5 of RFC 1738 - / "text" - / "date" - / "time" - / "date-time" ; date time - / "integer" - / "boolean" - / "float" - / x-name - / iana-token ; registered as described in - ; section 15 of this document - - languageparm = "language" "=" Language-Tag - ; Language-Tag is defined in section 2 of RFC 1766 - - contextparm = "context" "=" context - - context = x-name - / iana-token - - - - - -Howes, et. al. Standards Track [Page 9] - -RFC 2425 MIME Content-Type for Directory Information September 1998 - - - The "language" type parameter is used to identify data in multiple - languages. There is no concept of "default" language, except as - specified by any "Content-Language" MIME header parameter that is - present. The value of the "language" type parameter is a language - tag as defined in Section 2 of [RFC-1766]. - - The "context" type parameter is used to identify a context (e.g., a - protocol) used in interpreting the value. This is used, for example, - in the "source" type, defined below. - - The "encoding" type parameter is used to specify an alternate - encoding for a value. If the value contains a CRLF, it must be - encoded, since CRLF is used to separate lines in the content-type - itself. Currently, only the "b" encoding is supported. - - The "b" encoding can also be useful for binary values that are mixed - with other text information in the body part (e.g., a certificate). - Using a per-value "b" encoding in this case leaves the other - information in a more readable form. The encoded base 64 value can be - split across multiple physical lines in the content type by using the - line folding technique described above. - - The Content-Transfer-Encoding header field is used to specify the - encoding used for the body part as a whole. The "encoding" type - parameter is used to specify an encoding for a particular value - (e.g., a certificate). In this case, the Content-Transfer-Encoding - header might specify "8bit", while the one certificate value might - specify an encoding of "b" via an "encoding=b" type parameter. - - The Content-Transfer-Encoding and the encodings of individual types - given by the "encoding" type parameter are independent of one - another. When encoding a text/directory body part for transmission, - individual type encodings are performed first, then the entire body - part is encoded according to the Content-Transfer-Encoding. When - decoding a text/directory body part, the Content-Transfer-Encoding is - decoded first, and then any individual types with an "encoding" type - parameter are decoded. - - The "value" parameter is optional, and is used to identify the value - type (data type) and format of the value. The use of these - predefined formats is encouraged even if the value parameter is not - explicity used. By defining a standard set of value types and their - formats, existing parsing and processing code can be leveraged. - - Including the value type explicitly as part of each property provides - an extra hint to keep parsing simple and support more generalized - applications. For example a search engine would not have to know the - particular value types for all of the items for which it is - - - -Howes, et. al. Standards Track [Page 10] - -RFC 2425 MIME Content-Type for Directory Information September 1998 - - - searching. Because the value type is explicit in the definition, the - search engine could look for dates in any item type and provide - results that can still be interpreted. - -5.8.4. Pre-defined Value Types - - The format for values corresponding to the predefined valuetype - specifications given above are defined. - - valuespec = text-list - / genericurl ; from section 5 of RFC 1738 - / date-list - / time-list - / date-time-list - / boolean - / integer-list - / float-list - / iana-valuespec - - text-list = *TEXT-LIST-CHAR *("," *TEXT-LIST-CHAR) - - TEXT-LIST-CHAR = "\\" / "\," / "\n" - / <any VALUE-CHAR except , or \ or newline> - ; Backslashes, newlines, and commas must be encoded. - ; \n or \N can be used to encode a newline. - - date-list = date *("," date) - - time-list = time *("," time) - - date-time-list = date "T" time *("," date "T" time) - - boolean = "TRUE" / "FALSE" - - integer-list = integer *("," integer) - - integer = [sign] 1*DIGIT - - float-list = float *("," float) - - float = [sign] 1*DIGIT ["." 1*DIGIT] - - sign = "+" / "-" - - date = date-fullyear ["-"] date-month ["-"] date-mday - - date-fullyear = 4 DIGIT - - - - -Howes, et. al. Standards Track [Page 11] - -RFC 2425 MIME Content-Type for Directory Information September 1998 - - - date-month = 2 DIGIT ;01-12 - - date-mday = 2 DIGIT ;01-28, 01-29, 01-30, 01-31 - ;based on month/year - - time = time-hour [":"] time-minute [":"] time-second [time-secfrac] - [time-zone] - - time-hour = 2 DIGIT ;00-23 - - time-minute = 2 DIGIT ;00-59 - - time-second = 2 DIGIT ;00-60 (leap second) - - time-secfrac = "," 1*DIGIT - - time-zone = "Z" / time-numzone - - time-numzome = sign time-hour [":"] time-minute - - iana-valuespec = <a publicly-defined valuetype format, registered - with IANA, as defined in section 15 of this - document> - - Some specific notes on the value types and formats: - - "text": The "text" value type should be used to identify values that - contain human-readable text. The character set and language in which - the text is represented is controlled by the charset content-header - and the language type parameter and content-header. - - Examples for "text": - this is a text value - this is one value,this is another - this is a single value\, with a comma encoded - - A formatted text line break in a text value type MUST be represented - as the character sequence backslash (ASCII decimal 92) followed by a - Latin small letter n (ASCII decimal 110) or a Latin capital letter N - (ASCII decimal 78), that is "\n" or "\N". - - For example a multiple line DESCRIPTION value of: - - Mythical Manager - Hyjinx Software Division - BabsCo, Inc. - - could be represented as: - - - -Howes, et. al. Standards Track [Page 12] - -RFC 2425 MIME Content-Type for Directory Information September 1998 - - - DESCRIPTION:Mythical Manager\nHyjinx Software Division\n - BabsCo\, Inc.\n - - demonstrating the \n literal formatted line break technique, the - CRLF-followed-by-space line folding technique, and the backslash - escape technique. - - "uri": The "uri" value type should be used to identify values that - are referenced by a URI (including a Content-ID URI), instead of - encoded in-line. These value references might be used if the value is - too large, or otherwise undesirable to include directly. The format - for the URI is as defined in RFC 1738. - - Examples for "uri": - http://www.foobar.com/my/picture.jpg - ldap://ldap.foobar.com/cn=babs%20jensen - - "date", "time", and "date-time": Each of these value types is based - on a subset of the definitions in ISO 8601 standard. Profiles MAY - place further restrictions on "date" and "time" values. Multiple - "date" and "time" values can be specified using the comma-separated - notation, unless restricted by a profile. - - Examples for "date": - 1985-04-12 - 1996-08-05,1996-11-11 - 19850412 - - Examples for "time": - 10:22:00 - 102200 - 10:22:00.33 - 10:22:00.33Z - 10:22:33,11:22:00 - 10:22:00-08:00 - - Examples for "date-time": - 1996-10-22T14:00:00Z - 1996-08-11T12:34:56Z - 19960811T123456Z - 1996-10-22T14:00:00Z,1996-08-11T12:34:56Z - - "boolean": The "boolean" value type is used to express boolen values. - These values are case insensitive. - - Examples: TRUE - false - True - - - -Howes, et. al. Standards Track [Page 13] - -RFC 2425 MIME Content-Type for Directory Information September 1998 - - - "integer": The "integer" value type is used to express signed - integers in decimal format. If sign is not specified, the value is - assumed positive "+". Multiple "integer" values can be specified - using the comma-separated notation, unless restricted by a profile. - - Examples: 1234567890 - -1234556790 - +1234556790,432109876 - - "float": The "float" value type is used to express real numbers. If - sign is not specified, the value is assumed positive "+". Multiple - "float" values can be specified using the comma-separated notation, - unless restricted by a profile. - - Examples: 20.30 - 1000000.0000001 - 1.333,3.14 - -5.9. Applications which use this media type - - Applications which use this media type: Various - -5.10. Additional information - - Additional information: None - -5.11. Person & email address to contact for further information - - Tim Howes - Netscape Communications Corp. - 501 East Middlefield Rd. - Mountain View, CA 94041 - USA - howes@netscape.com - +1 415 937 3419 - -5.12. Intended usage - - Intended usage: COMMON - - - - - - - - - - - - -Howes, et. al. Standards Track [Page 14] - -RFC 2425 MIME Content-Type for Directory Information September 1998 - - -5.13. Author/Change controller - - Tim Howes - Netscape Communications Corp. - 501 East Middlefield Rd. - Mountain View, CA 94041 - USA - howes@netscape.com - +1 415 937 3419 - - Mark Smith - Netscape Communications Corp. - 501 East Middlefield Rd. - Mountain View, CA 94041 - USA - mcs@netscape.com - +1 415 937 3477 - - Frank Dawson - Lotus Development Corporation - 6544 Battleford Drive - Raleigh, NC 27613-3502 - USA - frank_dawson@lotus.com - +1-919-676-9515 - -6. Predefined Types - - The following types are generally useful regardless of the profile - being carried and are defined below using the text/directory MIME - type registration template defined in Section 11.1 of this document. - These types MAY be included in any profile, unless explicitly - forbidden in the profile definition. - -6.1. SOURCE Type Definition - - To: ietf-mime-direct@imc.org - Subject: Registration of text/directory MIME type SOURCE - - Type name: SOURCE - - Type purpose: To identify the source of directory information - contained in the content type. - - Type encoding: 8bit - - Type valuetype: uri - - - - -Howes, et. al. Standards Track [Page 15] - -RFC 2425 MIME Content-Type for Directory Information September 1998 - - - Type special notes: The SOURCE type is used to provide the means by - which applications knowledgable in the given directory service - protocol can obtain additional or more up-to-date information from - the directory service. It contains a URI as defined in [RFC-1738] - and/or other information referencing the directory entity or entities - to which the information pertains. When directory information is - available from more than one source, the sending entity can pick what - it considers to be the best source, or multiple SOURCE types can be - included. The interpretation of the value for a SOURCE type can - depend on the setting of the CONTEXT type parameter. The value of the - CONTEXT type parameter MUST be compatible with the value of the uri - prefix. - - Type example: - SOURCE;CONTEXT=LDAP:ldap://ldap.host/cn=Babs%20Jensen, - %20o=Babsco,%20c=US - -6.2. NAME Type Definition - - To: ietf-mime-direct@imc.org - Subject: Registration of text/directory MIME type NAME - - Type name: NAME - - Type purpose: To identify the displayable name of the directory - entity to which information in the content type pertains. - - Type encoding: 8bit - - Type valuetype: text - - Type special notes: The NAME type is used to convey the display name - of the entity to which the directory information pertains. - - Type example: - NAME:Babs Jensen's Contact Information - -6.3. PROFILE Type Definition - - To: ietf-mime-direct@imc.org - Subject: Registration of text/directory MIME type PROFILE - - Type name: PROFILE - - Type purpose: To identify the type of directory entity to which - information in the content type pertains. - - Type encoding: 8bit - - - -Howes, et. al. Standards Track [Page 16] - -RFC 2425 MIME Content-Type for Directory Information September 1998 - - - Type valuetype: A profile name, registered as described in Section 9 - of this document or bilaterally agreed upon as described in Section - 5. - - Type special notes: The PROFILE type is used to convey the type of - the entity to which the directory information in the rest of the body - part pertains. It should be the same as the "profile" header - parameter, if present. - - Type example: - PROFILE:vCard - -6.4. BEGIN Type Definition - - To: ietf-mime-direct@imc.org - Subject: Registration of text/directory MIME type BEGIN - - Type name: BEGIN - - Type purpose: To denote the beginning of a syntactic entity within a - text/directory content-type. - - Type encoding: 8bit - - Type valuetype: text, containing a profile name, registered as - described in Section 9 of this document or bilaterally-agreed upon as - described in Section 5. - - Type special notes: The BEGIN type is used in conjunction with the - END type to delimit a profile containing a related set of properties - within an text/directory content-type. This construct can be used - instead of or in addition to wrapping separate sets of information - inside additional MIME headers. It is provided for applications that - wish to define content that can contain multiple entities within the - same text/directory content-type or to define content that can be - identifiable outside of a MIME environment. - - Type example: - BEGIN:VCARD - -6.5. END Type Definition - - To: ietf-mime-direct@imc.org - Subject: Registration of text/directory MIME type END - - Type name: END - - - - - -Howes, et. al. Standards Track [Page 17] - -RFC 2425 MIME Content-Type for Directory Information September 1998 - - - Type purpose: To denote the end of a syntactic entity within a - text/directory content-type. - - Type encoding: 8bit - - Type valuetype: text, containing a profile name, registered as - described in Section 9 of this document or bilaterally-agreed upon as - described in Section 5. - - Type special notes: The END type is used in conjunction with the - BEGIN type to delimit a profile containing a related set of - properties within an text/directory content-type. This construct can - be used instead of or in addition to wrapping separate sets of - information inside additional MIME headers. It is provided for - applications that wish to define content that can contain multiple - entities within the same text/directory content-type or to define - content that can be identifiable outside of a MIME environment. - - Type example: - END: VCARD - -7. Use of the multipart/related Content-Type - - The multipart/related Content-Type can be used to hold directory - information comprised of both text and non-text information or - directory information that already has a natural MIME representation. - The root body part within the multipart/related body part is - specified as defined in [RFC-2112] by a "start" parameter, or it is - the first body part in the absence of such a parameter. The root - body part must have a Content-Type of "text/directory". This part - holds inline information and makes reference to subsequent body parts - holding additional text or non-text directory information via their - Content-ID URIs as explained in Section 5. - - The body parts referred to do not have to be in any particular order, - except as noted above for the root body part. - -8. Examples - - The following examples are for illustrative purposes only and are not - part of the definition. - - - - - - - - - - -Howes, et. al. Standards Track [Page 18] - -RFC 2425 MIME Content-Type for Directory Information September 1998 - - -8.1. Example 1 - - The first example illustrates simple use of the text/directory - Content-Type. Note that no "profile" parameter is given, so an - application may not know what kind of directory entity the - information applies to. Note also the use of both hypothetical - official and bilaterally agreed upon types. - - From: Whomever@wherever.com - To: Someone@somewhere.com - Subject: whatever - MIME-Version: 1.0 - Message-ID: <id1@host.net> - Content-Type: text/directory - Content-ID: <id2@host.com> - - cn:Babs Jensen - cn:Barbara J Jensen - sn:Jensen - email:babs@umich.edu - phone:+1 313 747-4454 - x-id:1234567890 - -8.2. Example 2 - - The next example illustrates the use of the Quoted-Printable transfer - encoding defined in [RFC 2045] to include non-ASCII character in some - of the information returned, and the use of the optional "name" and - "source" types. It also illustrates the use of an "encoding" type - parameter to encode a certificate value in "b". A "vCard" profile - [MIME- VCARD] is used for the example. - -Content-Type: text/directory; - charset="iso-8859-1"; - profile="vCard" -Content-ID: <id3@host.com> -Content-Transfer-Encoding: Quoted-Printable - -begin:VCARD -source:ldap://cn=3Dbjorn%20Jensen, o=3Duniversity%20of%20Michigan, c=3DUS -name:Bjorn Jensen -fn:Bj=F8rn Jensen -n:Jensen;Bj=F8rn -email;type=3Dinternet:bjorn@umich.edu -tel;type=3Dwork,voice,msg:+1 313 747-4454 -key;type=3Dx509;encoding=3DB:dGhpcyBjb3VsZCBiZSAKbXkgY2VydGlmaWNhdGUK -end:VCARD - - - - -Howes, et. al. Standards Track [Page 19] - -RFC 2425 MIME Content-Type for Directory Information September 1998 - - -8.3. Example 3 - - The next example illustrates the use of multi-valued type parameters, - the "language" type parameter, the "value" type parameter, folding of - long lines, the \n encoding for formatted lines, attribute grouping, - and the inline "b" encoding. A "vCard" profile [MIME-VCARD] is used - for the example. - -Content-Type: text/directory; profile="vcard"; charset=iso-8859-1 -Content-ID: <id3@host.com> -Content-Transfer-Encoding: Quoted-Printable - -begin:vcard -source:ldap://cn=3DMeister%20Berger,o=3DUniversitaet%20Goerlitz,c=3DDE -name:Meister Berger -fn:Meister Berger -n:Berger;Meister -bday;value=3Ddate:1963-09-21 -o:Universit=E6t G=F6rlitz -title:Mayor -title;language=3Dde;value=3Dtext:Burgermeister -note:The Mayor of the great city of - Goerlitz in the great country of Germany. -email;internet:mb@goerlitz.de -home.tel;type=3Dfax,voice,msg:+49 3581 123456 -home.label:Hufenshlagel 1234\n - 02828 Goerlitz\n - Deutschland -key;type=3DX509;encoding=3Db:MIICajCCAdOgAwIBAgICBEUwDQYJKoZIhvcNAQEEBQ - AwdzELMAkGA1UEBhMCVVMxLDAqBgNVBAoTI05ldHNjYXBlIENvbW11bmljYXRpb25zI - ENvcnBvcmF0aW9uMRwwGgYDVQQLExNJbmZvcm1hdGlvbiBTeXN0ZW1zMRwwGgYDVQQD - ExNyb290Y2EubmV0c2NhcGUuY29tMB4XDTk3MDYwNjE5NDc1OVoXDTk3MTIwMzE5NDc - 1OVowgYkxCzAJBgNVBAYTAlVTMSYwJAYDVQQKEx1OZXRzY2FwZSBDb21tdW5pY2F0aW - 9ucyBDb3JwLjEYMBYGA1UEAxMPVGltb3RoeSBBIEhvd2VzMSEwHwYJKoZIhvcNAQkBF - hJob3dlc0BuZXRzY2FwZS5jb20xFTATBgoJkiaJk/IsZAEBEwVob3dlczBcMA0GCSqG - SIb3DQEBAQUAA0sAMEgCQQC0JZf6wkg8pLMXHHCUvMfL5H6zjSk4vTTXZpYyrdN2dXc - oX49LKiOmgeJSzoiFKHtLOIboyludF90CgqcxtwKnAgMBAAGjNjA0MBEGCWCGSAGG+E - IBAQQEAwIAoDAfBgNVHSMEGDAWgBT84FToB/GV3jr3mcau+hUMbsQukjANBgkqhkiG9 - w0BAQQFAAOBgQBexv7o7mi3PLXadkmNP9LcIPmx93HGp0Kgyx1jIVMyNgsemeAwBM+M - SlhMfcpbTrONwNjZYW8vJDSoi//yrZlVt9bJbs7MNYZVsyF1unsqaln4/vy6Uawfg8V - UMk1U7jt8LYpo4YULU7UZHPYVUaSgVttImOHZIKi4hlPXBOhcUQ=3D=3D -end:vcard - - - - - - - - - -Howes, et. al. Standards Track [Page 20] - -RFC 2425 MIME Content-Type for Directory Information September 1998 - - -8.4. Example 4 - - The final example illustrates the use of the multipart/related - Content-Type to include non-textual directory data via the "uri" - encoding to refer to other body parts within the same message, or to - external values. Note that no "profile" parameter is given, so an - application may not know what kind of directory entity the - information applies to. Note also the use of both hypothetical - official and bilaterally agreed upon types. - -Content-Type: multipart/related; - boundary=woof; - type="text/directory"; - start="<id5@host.com>" -Content-ID: <id4@host.com> - ---woof -Content-Type: text/directory; charset="iso-8859-1" -Content-ID: <id5@host.com> -Content-Transfer-Encoding: Quoted-Printable - -source:ldap://cn=3DBjorn%20Jensen,o=3DUniversity%20of%20Michigan,c=3DUS -cn:Bj=F8rn Jensen -sn:Jensen -email:bjorn@umich.edu -image;value=3Duri:cid:id6@host.com -image;value=3Duri;format=3Djpeg:ftp://some.host/some/path.jpg -sound;value=3Duri:cid:id7@host.com -phone:+1 313 747-4454 - ---woof -Content-Type: image/jpeg -Content-ID: <id6@host.com> - -<...image data...> - ---woof -Content-Type: message/external-body; - name="myvoice.au"; - site="myhost.com"; - access-type=ANON-FTP; - directory="pub/myname"; - mode="image" - -Content-Type: audio/basic -Content-ID: <id7@host.com> - ---woof-- - - - -Howes, et. al. Standards Track [Page 21] - -RFC 2425 MIME Content-Type for Directory Information September 1998 - - -9. Registration of new profiles - - This section defines procedures by which new profiles are registered - with the IANA and made available to the Internet community. Note that - non-IANA profiles can be used by bilateral agreement, provided the - associated profile names follow the "X-" convention defined above. - - The procedures defined here are designed to allow public comment and - review of new profiles, while posing only a small impediment to the - definition of new profiles. - - Registration of a new profile is accomplished by the following steps. - -9.1. Define the profile - - A profile is defined by completing the following template. - - To: ietf-mime-direct@imc.org - Subject: Registration of text/directory MIME profile XXX - - Profile name: - - Profile purpose: - - Profile types: - - Profile special notes (optional): - - Intended usage: (one of COMMON, LIMITED USE or OBSOLETE) - - The explanation of what goes in each field in the template follows. - - Profile name: The name of the profile as it will appear in the - text/directory MIME Content-Type "profile" header parameter, or the - predefined "profile" type name. - - Profile purpose: The purpose of the profile (e.g., to represent - information about people, printers, documents, etc.). Give a short - but clear description. - - Profile types: The list of types associated with the profile. This - list of types is to be expected but not required in the profile, - unless otherwise noted in the profile definition. Other types not - mentioned in the profile definition MAY also be present. Note that - any new types referenced by the profile MUST be defined separately as - described in Section 10. - - - - - -Howes, et. al. Standards Track [Page 22] - -RFC 2425 MIME Content-Type for Directory Information September 1998 - - - Profile special notes: Any special notes about the profile, how it is - to be used, etc. This section of the template can also be used to - define an ordering on the types that appear in the Content-Type, if - such an ordering is required. - -9.2. Post the profile definition - - The profile description must be posted to the new profile discussion - list, ietf-mime-direct@imc.org - -9.3. Allow a comment period - - Discussion on the new profile must be allowed to take place on the - list for a minimum of two weeks. Consensus must be reached on the - profile before proceeding to step 4. - -9.4. Submit the profile for approval - - Once the two-week comment period has elapsed, and the proposer is - convinced consensus has been reached on the profile, the registration - application should be submitted to the Profile Reviewer for approval. - The Profile Reviewer is appointed by the Application Area Directors - and can either accept or reject the profile registration. An accepted - registration is passed on by the Profile Reviewer to the IANA for - inclusion in the official IANA profile registry. The registration may - be rejected for any of the following reasons. 1) Insufficient comment - period; 2) Consensus not reached; 3) Technical deficiencies raised on - the list or elsewhere have not been addressed. The Profile Reviewer's - decision to reject a profile can be appealed by the proposer to the - IESG, or the objections raised can be addressed by the proposer and - the profile resubmitted. - -10. Profile Change Control - - Existing profiles can be changed using the same process by which they - were registered. - - Define the change - - Post the change - - Allow a comment period - - Submit the changed profile for approval - - - - - - - -Howes, et. al. Standards Track [Page 23] - -RFC 2425 MIME Content-Type for Directory Information September 1998 - - - Note that the original author or any other interested party can - propose a change to an existing profile, but that such changes should - only be proposed when there are serious omissions or errors in the - published specification. The Profile Reviewer can object to a change - if it is not backwards compatible, but is not required to do so. - - Profile definitions can never be deleted from the IANA registry, but - profiles which are no longer believed to be useful can be declared - OBSOLETE by a change to their "intended use" field. - -11. Registration of new types - - This section defines procedures by which new types are registered - with the IANA. Note that non-IANA types can be used by bilateral - agreement, provided the associated types names follow the "X-" - convention defined above. - - The procedures defined here are designed to allow public comment and - review of new types, while posing only a small impediment to the - definition of new types. - - Registration of a new type is accomplished by the following steps. - -11.1. Define the type - - A type is defined by completing the following template. - - To: ietf-mime-direct@imc.org - Subject: Registration of text/directory MIME type XXX - - Type name: - - Type purpose: - - Type encoding: - - Type valuetype: - - Type special notes (optional): - - Intended usage: (one of COMMON, LIMITED USE or OBSOLETE) - - The meaning of each field in the template is as follows. - - Type name: The name of the type, as it will appear in the body of an - text/directory MIME Content-Type "type: value" line to the left of - the colon ":". - - - - -Howes, et. al. Standards Track [Page 24] - -RFC 2425 MIME Content-Type for Directory Information September 1998 - - - Type purpose: The purpose of the type (e.g., to represent a name, - postal address, IP address, etc.). Give a short but clear - description. - - Type encoding: The default encoding a value of the type must have in - the body of a text/directory MIME Content-Type. - - Type valuetype: The format a value of the type must have in the body - of a text/directory MIME Content-Type. This description must be - precise and must not violate the general encoding rules defined in - section 5 of this document. - - Type special notes: Any special notes about the type, how it is to be - used, etc. - -11.2. Post the type definition - - The type description must be posted to the new type discussion list, - ietf-mime-direct@imc.org - -11.3. Allow a comment period - - Discussion on the new type must be allowed to take place on the list - for a minimum of two weeks. Consensus must be reached on the type - before proceeding to step 4. - -11.4. Submit the type for approval - - Once the two-week comment period has elapsed, and the proposer is - convinced consensus has been reached on the type, the registration - application should be submitted to the Profile Reviewer for approval. - The Profile Reviewer is appointed by the Application Area Directors - and can either accept or reject the type registration. An accepted - registration is passed on by the Profile Reviewer to the IANA for - inclusion in the official IANA profile registry. The registration can - be rejected for any of the following reasons. 1) Insufficient comment - period; 2) Consensus not reached; 3) Technical deficiencies raised on - the list or elsewhere have not been addressed. The Profile - Reviewer's decision to reject a type can be appealed by the proposer - to the IESG, or the objections raised can be addressed by the - proposer and the type resubmitted. - - - - - - - - - - -Howes, et. al. Standards Track [Page 25] - -RFC 2425 MIME Content-Type for Directory Information September 1998 - - -12. Type Change Control - - Existing types can be changed using the same process by which they - were registered. - - Define the change - - Post the change - - Allow a comment period - - Submit the type for approval - - Note that the original author or any other interested party can - propose a change to an existing type, but that such changes should - only be proposed when there are serious omissions or errors in the - published specification. The Profile Reviewer can object to a change - if it is not backwards compatible, but is not required to do so. - - Type definitions can never be deleted from the IANA registry, but - types which are nolonger believed to be useful can be declared - OBSOLETE by a change to their "intended use" field. - -13. Registration of new parameters - - This section defines procedures by which new parameters are - registered with the IANA and made available to the Internet - community. Note that non-IANA parameters can be used by bilateral - agreement, provided the associated parameters names follow the "X-" - convention defined above. - - The procedures defined here are designed to allow public comment and - review of new parameters, while posing only a small impediment to the - definition of new parameters. - - Registration of a new parameter is accomplished by the following - steps. - -13.1. Define the parameter - - A parameter is defined by completing the following template. - - To: ietf-mime-direct@imc.org - Subject: Registration of text/directory MIME type parameter XXX - - Parameter name: - - Parameter purpose: - - - -Howes, et. al. Standards Track [Page 26] - -RFC 2425 MIME Content-Type for Directory Information September 1998 - - - Parameter values: - - Parameter special notes (optional): - - Intended usage: (one of COMMON, LIMITED USE or OBSOLETE) - - The explanation of what goes in each field in the template follows. - - Parameter name: The name of the parameter as it will appear in the - text/directory MIME Content-Type. - - Parameter purpose: The purpose of the parameter (e.g., to represent - the format of an image, type of a phone number, etc.). Give a short - but clear description. If defining a general paramemter like "format" - or "type" keep in mind that other applications might wish to extend - its use. - - Parameter values: The list or description of values associated with - the parameter. - - Parameter special notes: Any special notes about the parameter, how - it is to be used, etc. - -13.2. Post the parameter definition - - The parameter description must be posted to the new parameter - discussion list, ietf-mime-direct@imc.org - -13.3. Allow a comment period - - Discussion on the new parameter must be allowed to take place on the - list for a minimum of two weeks. Consensus must be reached on the - parameter before proceeding to step 4. - -13.4. Submit the parameter for approval - - Once the two-week comment period has elapsed, and the proposer is - convinced consensus has been reached on the parameter, the - registration application should be submitted to the Profile Reviewer - for approval. The Profile Reviewer is appointed by the Application - Area Directors and can either accept or reject the parameter - registration. An accepted registration is passed on by the Profile - Reviewer to the IANA for inclusion in the official IANA parameter - registry. The registration can be rejected for any of the following - reasons. 1) Insufficient comment period; 2) Consensus not reached; 3) - Technical deficiencies raised on the list or elsewhere have not been - addressed. The Profile Reviewer's decision to reject a profile can be - appealed by the proposer to the IESG, or the objections raised can be - - - -Howes, et. al. Standards Track [Page 27] - -RFC 2425 MIME Content-Type for Directory Information September 1998 - - - addressed by the proposer and the parameter registration resubmitted. - -14. Parameter Change Control - - Existing parameters can be changed using the same process by which - they were registered. - - Define the change - - Post the change - - Allow a comment period - - Submit the parameter for approval - - Note that the original author or any other interested party can - propose a change to an existing parameter, but that such changes - should only be proposed when there are serious omissions or errors in - the published specification. The Profile Reviewer can object to a - change if it is not backwards compatible, but is not required to do - so. - - Parameter definitions can never be deleted from the IANA registry, - but parameters which are nolonger believed to be useful can be - declared OBSOLETE by a change to their "intended use" field. - -15. Registration of new value types - - This section defines procedures by which new value types are - registered with the IANA and made available to the Internet - community. Note that non-IANA value types can be used by bilateral - agreement, provided the associated value types names follow the "X-" - convention defined above. - - The procedures defined here are designed to allow public comment and - review of new value types, while posing only a small impediment to - the definition of new value types. - - Registration of a new value types is accomplished by the following - steps. - -15.1. Define the value type - - A value type is defined by completing the following template. - - To: ietf-mime-direct@imc.org - Subject: Registration of text/directory MIME value type XXX - - - - -Howes, et. al. Standards Track [Page 28] - -RFC 2425 MIME Content-Type for Directory Information September 1998 - - - value type name: - - value type purpose: - - value type format: - - value type special notes (optional): - - Intended usage: (one of COMMON, LIMITED USE or OBSOLETE) - - The explanation of what goes in each field in the template follows. - - value type name: The name of the value type as it will appear in the - text/directory MIME Content-Type. - - value type purpose: The purpose of the value type. Give a short but - clear description. - - value type format: The definition of the format for the value, - usually using ABNF grammar. - - value type special notes: Any special notes about the value type, how - it is to be used, etc. - -15.2. Post the value type definition - - The value type description must be posted to the new value type - discussion list, ietf-mime-direct@imc.org - -15.3. Allow a comment period - - Discussion on the new value type must be allowed to take place on the - list for a minimum of two weeks. Consensus must be reached before - proceeding to step 4. - -15.4. Submit the value type for approval - - Once the two-week comment period has elapsed, and the proposer is - convinced consensus has been reached on the value type, the - registration application should be submitted to the Profile Reviewer - for approval. The Profile Reviewer is appointed by the Application - Area Directors and can either accept or reject the value type - registration. An accepted registration should be passed on by the - Profile Reviewer to the IANA for inclusion in the official IANA value - type registry. The registration can be rejected for any of the - following reasons. 1) Insufficient comment period; 2) Consensus not - reached; 3) Technical deficiencies raised on the list or elsewhere - have not been addressed. The Profile Reviewer's decision to reject a - - - -Howes, et. al. Standards Track [Page 29] - -RFC 2425 MIME Content-Type for Directory Information September 1998 - - - profile can be appealed by the proposer to the IESG, or the - objections raised can be addressed by the proposer and the value type - registration resubmitted. - -16. Security Considerations - - Internet mail is subject to many well known security attacks, - including monitoring, replay, and forgery. Care should be taken by - any directory service in allowing information to leave the scope of - the service itself, where any access controls can no longer be - guaranteed. Applications should also take care to display directory - data in a "safe" environment (e.g., PostScript-valued types). - -17. Acknowledgements - - The registration procedures defined here were shamelessly lifted from - the MIME registration RFC. - - The many valuable comments contributed by members of the IETF ASID - working group are gratefully acknowledged, as are the contributions - of the Versit Consortium. Chris Newman was especially helpful in - navigating the intricacies of ABNF lore. - -18. References - - [RFC-1777] Yeong, W., Howes, T., and S. Kille, "Lightweight - Directory Access Protocol", RFC 1777, March 1995. - - [RFC-1778] Howes, T., Kille, S., Yeong, W., and C. Robbins, "The - String Representation of Standard Attribute Syntaxes", - RFC 1778, March 1995. - - [RFC-822] Crocker, D., "Standard for the Format of ARPA Internet - Text Messages", STD 11, RFC 822, August 1982. - - [RFC-2045] Borenstein, N., and N. Freed, "Multipurpose Internet - Mail Extensions (MIME) Part One: Format of Internet - Message Bodies", RFC 2045, November 1996. - - [RFC-2046] Moore, K., "Multipurpose Internet Mail Extensions (MIME) - Part Two: Media Types", RFC 2046, November 1996. - - [RFC-2048] Freed, N., Klensin, J., and J. Postel, "Multipurpose - Internet Mail Extensions (MIME) Part Four: Registration - Procedures", RFC 2048, November 1996. - - [RFC-1766] Alvestrand, H., "Tags for the Identification of - Languages", RFC 1766, March 1995. - - - -Howes, et. al. Standards Track [Page 30] - -RFC 2425 MIME Content-Type for Directory Information September 1998 - - - [RFC-2112] Levinson, E., "The MIME Multipart/Related Content-type", - RFC 2112, March 1997. - - [X500] "Information Processing Systems - Open Systems - Interconnection - The Directory: Overview of Concepts, - Models and Services", ISO/IEC JTC 1/SC21, International - Standard 9594-1, 1988. - - [RFC-1835] Deutsch, P., Schoultz, R., Faltstrom, P., and C. Weider, - "Architecture of the WHOIS++ service", RFC 1835, August - 1995. - - [RFC-1738] Berners-Lee, T., Masinter, L., and M. McCahill, "Uniform - Resource Locators (URL)", RFC 1738, December 1994. - - [MIME-VCARD] Dawson, F., and T. Howes, "VCard MIME Directory - Profile", RFC 2426, September 1998. - - [VCARD] Internet Mail Consortium, "vCard - The Electronic - Business Card", Version 2.1, - http://www.imc.com/pdi/vcard-21.txt, September, 1996. - - [RFC-2119] Bradner, S., "Key words for use in RFCs to Indicate - Requirement Levels", BCP 14, RFC 2119, March 1997. - - [RFC-2234] Crocker, D., and P. Overell, "Augmented BNF for Syntax - Specifications: ABNF", RFC 2234, November 1997. - - - - - - - - - - - - - - - - - - - - - - - - -Howes, et. al. Standards Track [Page 31] - -RFC 2425 MIME Content-Type for Directory Information September 1998 - - -19. Authors' Addresses - - Tim Howes - Netscape Communications Corp. - 501 East Middlefield Rd. - Mountain View, CA 94041 - USA - - Phone: +1.415.937.3419 - EMail: howes@netscape.com - - - Mark Smith - Netscape Communications Corp. - 501 East Middlefield Rd. - Mountain View, CA 94041 - USA - - Phone: +1.415.937.3477 - EMail: mcs@netscape.com - - - Frank Dawson - Lotus Development Corporation - 6544 Battleford Drive - Raleigh, NC 27613 - USA - - Phone: +1-919-676-9515 - EMail: frank_dawson@lotus.com - - - - - - - - - - - - - - - - - - - - - -Howes, et. al. Standards Track [Page 32] - -RFC 2425 MIME Content-Type for Directory Information September 1998 - - -20. Full Copyright Statement - - Copyright (C) The Internet Society (1998). All Rights Reserved. - - This document and translations of it may be copied and furnished to - others, and derivative works that comment on or otherwise explain it - or assist in its implementation may be prepared, copied, published - and distributed, in whole or in part, without restriction of any - kind, provided that the above copyright notice and this paragraph are - included on all such copies and derivative works. However, this - document itself may not be modified in any way, such as by removing - the copyright notice or references to the Internet Society or other - Internet organizations, except as needed for the purpose of - developing Internet standards in which case the procedures for - copyrights defined in the Internet Standards process must be - followed, or as required to translate it into languages other than - English. - - The limited permissions granted above are perpetual and will not be - revoked by the Internet Society or its successors or assigns. - - This document and the information contained herein is provided on an - "AS IS" basis and THE INTERNET SOCIETY AND THE INTERNET ENGINEERING - TASK FORCE DISCLAIMS ALL WARRANTIES, EXPRESS OR IMPLIED, INCLUDING - BUT NOT LIMITED TO ANY WARRANTY THAT THE USE OF THE INFORMATION - HEREIN WILL NOT INFRINGE ANY RIGHTS OR ANY IMPLIED WARRANTIES OF - MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. - - - - - - - - - - - - - - - - - - - - - - - - -Howes, et. al. Standards Track [Page 33] - diff --git a/addressbook/backend/ebook/docs/rfc2426.txt b/addressbook/backend/ebook/docs/rfc2426.txt deleted file mode 100644 index a393a67c98..0000000000 --- a/addressbook/backend/ebook/docs/rfc2426.txt +++ /dev/null @@ -1,2355 +0,0 @@ - - - - - - -Network Working Group F. Dawson -Request for Comments: 2426 Lotus Development Corporation -Category: Standards Track T. Howes - Netscape Communications - September 1998 - - - vCard MIME Directory Profile - -Status of this Memo - - This document specifies an Internet standards track protocol for the - Internet community, and requests discussion and suggestions for - improvements. Please refer to the current edition of the "Internet - Official Protocol Standards" (STD 1) for the standardization state - and status of this protocol. Distribution of this memo is unlimited. - -Copyright Notice - - Copyright (C) The Internet Society (1998). All Rights Reserved. - -Abstract - - This memo defines the profile of the MIME Content-Type [MIME-DIR] for - directory information for a white-pages person object, based on a - vCard electronic business card. The profile definition is independent - of any particular directory service or protocol. The profile is - defined for representing and exchanging a variety of information - about an individual (e.g., formatted and structured name and delivery - addresses, email address, multiple telephone numbers, photograph, - logo, audio clips, etc.). The directory information used by this - profile is based on the attributes for the person object defined in - the X.520 and X.521 directory services recommendations. The profile - also provides the method for including a [VCARD] representation of a - white-pages directory entry within the MIME Content-Type defined by - the [MIME-DIR] document. - - The key words "MUST", "MUST NOT", "REQUIRED", "SHALL", "SHALL NOT", - "SHOULD", "SHOULD NOT", "RECOMMENDED", "MAY" and "OPTIONAL" in this - document are to be interpreted as described in [RFC 2119]. - - - - - - - - - - - -Dawson & Howes Standards Track [Page 1] - -RFC 2426 vCard MIME Directory Profile September 1998 - - -Table of Contents - - Overview.........................................................3 - 1. THE VCARD MIME DIRECTORY PROFILE REGISTRATION.................4 - 2. MIME DIRECTORY FEATURES.......................................5 - 2.1 PREDEFINED TYPE USAGE ......................................5 - 2.1.1 BEGIN and END Type ......................................5 - 2.1.2 NAME Type ...............................................5 - 2.1.3 PROFILE Type ............................................5 - 2.1.4 SOURCE Type .............................................5 - 2.2 PREDEFINED TYPE PARAMETER USAGE ............................6 - 2.3 PREDEFINED VALUE TYPE USAGE ................................6 - 2.4 EXTENSIONS TO THE PREDEFINED VALUE TYPES ...................6 - 2.4.1 BINARY ..................................................6 - 2.4.2 VCARD ...................................................6 - 2.4.3 PHONE-NUMBER ............................................7 - 2.4.4 UTC-OFFSET ..............................................7 - 2.5 STRUCTURED TYPE VALUES .....................................7 - 2.6 LINE DELIMITING AND FOLDING ................................8 - 3. VCARD PROFILE FEATURES........................................8 - 3.1 IDENTIFICATION TYPES .......................................8 - 3.1.1 FN Type Definition ......................................8 - 3.1.2 N Type Definition .......................................9 - 3.1.3 NICKNAME Type Definition ................................9 - 3.1.4 PHOTO Type Definition ..................................10 - 3.1.5 BDAY Type Definition ...................................11 - 3.2 DELIVERY ADDRESSING TYPES .................................11 - 3.2.1 ADR Type Definition ....................................11 - 3.2.2 LABEL Type Definition ..................................13 - 3.3 TELECOMMUNICATIONS ADDRESSING TYPES .......................13 - 3.3.1 TEL Type Definition ....................................14 - 3.3.2 EMAIL Type Definition ..................................15 - 3.3.3 MAILER Type Definition .................................15 - 3.4 GEOGRAPHICAL TYPES ........................................16 - 3.4.1 TZ Type Definition .....................................16 - 3.4.2 GEO Type Definition ....................................16 - 3.5 ORGANIZATIONAL TYPES ......................................17 - 3.5.1 TITLE Type Definition ..................................17 - 3.5.2 ROLE Type Definition ...................................18 - 3.5.3 LOGO Type Definition ...................................18 - 3.5.4 AGENT Type Definition ..................................19 - 3.5.5 ORG Type Definition ....................................20 - 3.6 EXPLANATORY TYPES .........................................20 - 3.6.1 CATEGORIES Type Definition .............................20 - 3.6.2 NOTE Type Definition ...................................21 - 3.6.3 PRODID Type Definition .................................21 - 3.6.4 REV Type Definition ....................................22 - 3.6.5 SORT-STRING Type Definition ............................22 - - - -Dawson & Howes Standards Track [Page 2] - -RFC 2426 vCard MIME Directory Profile September 1998 - - - 3.6.6 SOUND Type Definition ..................................23 - 3.6.7 UID Type Definition ....................................24 - 3.6.8 URL Type Definition ....................................25 - 3.6.9 VERSION Type Definition ................................25 - 3.7 SECURITY TYPES ............................................25 - 3.7.1 CLASS Type Definition ..................................26 - 3.7.2 KEY Type Definition ....................................26 - 3.8 EXTENDED TYPES ............................................27 - 4. FORMAL GRAMMAR...............................................27 - 5. DIFFERENCES FROM VCARD V2.1..................................37 - 6. ACKNOWLEDGEMENTS.............................................39 - 7. AUTHORS' ADDRESSES...........................................39 - 8. SECURITY CONSIDERATIONS......................................39 - 9. REFERENCES...................................................40 - 10. FULL COPYRIGHT STATEMENT....................................42 - -Overview - - The [MIME-DIR] document defines a MIME Content-Type for holding - different kinds of directory information. The directory information - can be based on any of a number of directory schemas. This document - defines a [MIME-DIR] usage profile for conveying directory - information based on one such schema; that of the white-pages type of - person object. - - The schema is based on the attributes for the person object defined - in the X.520 and X.521 directory services recommendations. The schema - has augmented the basic attributes defined in the X.500 series - recommendation in order to provide for an electronic representation - of the information commonly found on a paper business card. This - schema was first defined in the [VCARD] document. Hence, this [MIME- - DIR] profile is referred to as the vCard MIME Directory Profile. - - A directory entry based on this usage profile can include traditional - directory, white-pages information such as the distinguished name - used to uniquely identify the entry, a formatted representation of - the name used for user-interface or presentation purposes, both the - structured and presentation form of the delivery address, various - telephone numbers and organizational information associated with the - entry. In addition, traditional paper business card information such - as an image of an organizational logo or identify photograph can be - included in this person object. - - The vCard MIME Directory Profile also provides support for - representing other important information about the person associated - with the directory entry. For instance, the date of birth of the - person; an audio clip describing the pronunciation of the name - associated with the directory entry, or some other application of the - - - -Dawson & Howes Standards Track [Page 3] - -RFC 2426 vCard MIME Directory Profile September 1998 - - - digital sound; longitude and latitude geo-positioning information - related to the person associated with the directory entry; date and - time that the directory information was last updated; annotations - often written on a business card; Uniform Resource Locators (URL) for - a website; public key information. The profile also provides support - for non-standard extensions to the schema. This provides the - flexibility for implementations to augment the current capabilities - of the profile in a standardized way. More information about this - electronic business card format can be found in [VCARD]. - -1. The vCard Mime Directory Profile Registration - - This profile is identified by the following [MIME-DIR] registration - template information. Subsequent sections define the profile - definition. - - To: ietf-mime-directory@imc.org - - Subject: Registration of text/directory MIME profile VCARD - - Profile name: VCARD - - Profile purpose: To hold person object or white-pages type of - directory information. The person schema captured in the directory - entries is that commonly found in an electronic business card. - - Predefined MIME Directory value specifications used: uri, date, - date-time, float - - New value specifications: This profile places further constraints on - the [MIME-DIR] text value specification. In addition, it adds a - binary, phone-number, utc-offset and vcard value specifications. - - Predefined MIME Directory types used: SOURCE, NAME, PROFILE, BEGIN, - END. - - Predefined MIME Directory parameters used: ENCODING, VALUE, CHARSET, - LANGUAGE, CONTEXT. - - New types: FN, N, NICKNAME, PHOTO, BDAY, ADR, LABEL, TEL, EMAIL, - MAILER, TZ, GEO, TITLE, ROLE, LOGO, AGENT, ORG, CATEGORIES, NOTE, - PRODID, REV, SORT-STRING, SOUND, URL, UID, VERSION, CLASS, KEY - - New parameters: TYPE - - Profile special notes: The vCard object MUST contain the FN, N and - VERSION types. The type-grouping feature of [MIME-DIR] is supported - by this profile to group related vCard properties about a directory - - - -Dawson & Howes Standards Track [Page 4] - -RFC 2426 vCard MIME Directory Profile September 1998 - - - entry. For example, vCard properties describing WORK or HOME related - characteristics can be grouped with a unique group label. - - The profile permits the use of non-standard types (i.e., those - identified with the prefix string "X-") as a flexible method for - implementations to extend the functionality currently defined within - this profile. - -2. MIME Directory Features - - The vCard MIME Directory Profile makes use of many of the features - defined by [MIME-DIR]. The following sections either clarify or - extend the content-type definition of [MIME-DIR]. - -2.1 Predefined Type Usage - - The vCard MIME Directory Profile uses the following predefined types - from [MIME-DIR]. - -2.1.1 BEGIN and END Type - - The content entity MUST begin with the BEGIN type with a value of - "VCARD". The content entity MUST end with the END type with a value - of "VCARD". - -2.1.2 NAME Type - - If the NAME type is present, then its value is the displayable, - presentation text associated with the source for the vCard, as - specified in the SOURCE type. - -2.1.3 PROFILE Type - - If the PROFILE type is present, then its value MUST be "VCARD". - -2.1.4 SOURCE Type - - If the SOURCE type is present, then its value provides information - how to find the source for the vCard. - - - - - - - - - - - - -Dawson & Howes Standards Track [Page 5] - -RFC 2426 vCard MIME Directory Profile September 1998 - - -2.2 Predefined Type Parameter Usage - - The vCard MIME Directory Profile uses the following predefined type - parameters as defined by [MIME-DIR]. - - - LANGUAGE - - - ENCODING - - - VALUE - -2.3 Predefined VALUE Type Usage - - The predefined data type values specified in [MIME-DIR] MUST NOT be - repeated in COMMA separated value lists except within the N, - NICKNAME, ADR and CATEGORIES value types. - - The text value type defined in [MIME-DIR] is further restricted such - that any SEMI-COLON character (ASCII decimal 59) in the value MUST be - escaped with the BACKSLASH character (ASCII decimal 92). - -2.4 Extensions To The Predefined VALUE Types - - The predefined data type values specified in [MIME-DIR] have been - extended by the vCard profile to include a number of value types that - are specific to this profile. - -2.4.1 BINARY - - The "binary" value type specifies that the type value is inline, - encoded binary data. This value type can be specified in the PHOTO, - LOGO, SOUND, and KEY types. - - If inline encoded binary data is specified, the ENCODING type - parameter MUST be used to specify the encoding format. The binary - data MUST be encoded using the "B" encoding format. Long lines of - encoded binary data SHOULD BE folded to 75 characters using the - folding method defined in [MIME-DIR]. - - The value type is defined by the following notation: - - binary = <A "B" binary encoded string as defined by [RFC 2047].> - -2.4.2 VCARD - - The "vcard" value type specifies that the type value is another - vCard. This value type can be specified in the AGENT type. The value - type is defined by this specification. Since each of the type - - - -Dawson & Howes Standards Track [Page 6] - -RFC 2426 vCard MIME Directory Profile September 1998 - - - declarations with in the vcard value type are being specified within - a text value themselves, they MUST be terminated with the backslash - escape sequence "\n" or "\N", instead of the normal newline character - sequence CRLF. In addition, any COMMA character (ASCII decimal 44), - SEMI-COLON character (ASCII decimal 59) and COLON character (ASCII - decimal 58) MUST be escaped with the BACKSLASH character (ASCII - decimal 92). For example, with the AGENT type a value would be - specified as: - - AGENT:BEGIN:VCARD\nFN:Joe Friday\nTEL:+1-919-555-7878\n - TITLE:Area Administrator\, Assistant\n EMAIL\;TYPE=INTERN\n - ET:jfriday@host.com\nEND:VCARD\n - -2.4.3 PHONE-NUMBER - - The "phone-number" value type specifies that the type value is a - telephone number. This value type can be specified in the TEL type. - The value type is a text value that has the special semantics of a - telephone number as defined in [CCITT E.163] and [CCITT X.121]. - -2.4.4 UTC-OFFSET - - The "utc-offset" value type specifies that the type value is a signed - offset from UTC. This value type can be specified in the TZ type. - - The value type is an offset from Coordinated Universal Time (UTC). It - is specified as a positive or negative difference in units of hours - and minutes (e.g., +hh:mm). The time is specified as a 24-hour clock. - Hour values are from 00 to 23, and minute values are from 00 to 59. - Hour and minutes are 2-digits with high order zeroes required to - maintain digit count. The extended format for ISO 8601 UTC offsets - MUST be used. The extended format makes use of a colon character as a - separator of the hour and minute text fields. - - The value is defined by the following notation: - - time-hour = 2DIGIT ;00-23 - time-minute = 2DIGIT ;00-59 - utc-offset = ("+" / "-") time-hour ":" time-minute - -2.5 Structured Type Values - - Compound type values are delimited by a field delimiter, specified by - the SEMI-COLON character (ASCII decimal 59). A SEMI-COLON in a - component of a compound property value MUST be escaped with a - BACKSLASH character (ASCII decimal 92). - - - - - -Dawson & Howes Standards Track [Page 7] - -RFC 2426 vCard MIME Directory Profile September 1998 - - - Lists of values are delimited by a list delimiter, specified by the - COMMA character (ASCII decimal 44). A COMMA character in a value MUST - be escaped with a BACKSLASH character (ASCII decimal 92). - - This profile supports the type grouping mechanism defined in [MIME- - DIR]. Grouping of related types is a useful technique to communicate - common semantics concerning the properties of a vCard. - -2.6 Line Delimiting and Folding - - This profile supports the same line delimiting and folding methods - defined in [MIME-DIR]. Specifically, when parsing a content line, - folded lines must first be unfolded according to the unfolding - procedure described in [MIME-DIR]. After generating a content line, - lines longer than 75 characters SHOULD be folded according to the - folding procedure described in [MIME DIR]. - - Folding is done after any content encoding of a type value. Unfolding - is done before any decoding of a type value in a content line. - -3. vCard Profile Features - - The vCard MIME Directory Profile Type contains directory information, - typically pertaining to a single directory entry. The information is - described using an attribute schema that is tailored for capturing - personal contact information. The vCard can include attributes that - describe identification, delivery addressing, telecommunications - addressing, geographical, organizational, general explanatory and - security and access information about the particular object - associated with the vCard. - -3.1 Identification Types - - These types are used in the vCard profile to capture information - associated with the identification and naming of the person or - resource associated with the vCard. - -3.1.1 FN Type Definition - - To: ietf-mime-directory@imc.org - - Subject: Registration of text/directory MIME type FN - - Type name:FN - - Type purpose: To specify the formatted text corresponding to the name - of the object the vCard represents. - - - - -Dawson & Howes Standards Track [Page 8] - -RFC 2426 vCard MIME Directory Profile September 1998 - - - Type encoding: 8bit - - Type value: A single text value. - - Type special notes: This type is based on the semantics of the X.520 - Common Name attribute. The property MUST be present in the vCard - object. - - Type example: - - FN:Mr. John Q. Public\, Esq. - -3.1.2 N Type Definition - - To: ietf-mime-directory@imc.org - - Subject: Registration of text/directory MIME type N - - Type name: N - - Type purpose: To specify the components of the name of the object the - vCard represents. - - Type encoding: 8bit - - Type value: A single structured text value. Each component can have - multiple values. - - Type special note: The structured type value corresponds, in - sequence, to the Family Name, Given Name, Additional Names, Honorific - Prefixes, and Honorific Suffixes. The text components are separated - by the SEMI-COLON character (ASCII decimal 59). Individual text - components can include multiple text values (e.g., multiple - Additional Names) separated by the COMMA character (ASCII decimal - 44). This type is based on the semantics of the X.520 individual name - attributes. The property MUST be present in the vCard object. - - Type example: - - N:Public;John;Quinlan;Mr.;Esq. - - N:Stevenson;John;Philip,Paul;Dr.;Jr.,M.D.,A.C.P. - -3.1.3 NICKNAME Type Definition - - To: ietf-mime-directory@imc.org - - Subject: Registration of text/directory MIME type NICKNAME - - - -Dawson & Howes Standards Track [Page 9] - -RFC 2426 vCard MIME Directory Profile September 1998 - - - Type name: NICKNAME - - Type purpose: To specify the text corresponding to the nickname of - the object the vCard represents. - - Type encoding: 8bit - - Type value: One or more text values separated by a COMMA character - (ASCII decimal 44). - - Type special note: The nickname is the descriptive name given instead - of or in addition to the one belonging to a person, place, or thing. - It can also be used to specify a familiar form of a proper name - specified by the FN or N types. - - Type example: - - NICKNAME:Robbie - - NICKNAME:Jim,Jimmie - -3.1.4 PHOTO Type Definition - - To: ietf-mime-directory@imc.org - - Subject: Registration of text/directory MIME type PHOTO - - Type name: PHOTO - - Type purpose: To specify an image or photograph information that - annotates some aspect of the object the vCard represents. - - Type encoding: The encoding MUST be reset to "b" using the ENCODING - parameter in order to specify inline, encoded binary data. If the - value is referenced by a URI value, then the default encoding of 8bit - is used and no explicit ENCODING parameter is needed. - - Type value: A single value. The default is binary value. It can also - be reset to uri value. The uri value can be used to specify a value - outside of this MIME entity. - - Type special notes: The type can include the type parameter "TYPE" to - specify the graphic image format type. The TYPE parameter values MUST - be one of the IANA registered image formats or a non-standard image - format. - - - - - - -Dawson & Howes Standards Track [Page 10] - -RFC 2426 vCard MIME Directory Profile September 1998 - - - Type example: - - PHOTO;VALUE=uri:http://www.abc.com/pub/photos - /jqpublic.gif - - - PHOTO;ENCODING=b;TYPE=JPEG:MIICajCCAdOgAwIBAgICBEUwDQYJKoZIhvcN - AQEEBQAwdzELMAkGA1UEBhMCVVMxLDAqBgNVBAoTI05ldHNjYXBlIENvbW11bm - ljYXRpb25zIENvcnBvcmF0aW9uMRwwGgYDVQQLExNJbmZvcm1hdGlvbiBTeXN0 - <...remainder of "B" encoded binary data...> - -3.1.5 BDAY Type Definition - - To: ietf-mime-directory@imc.org - - Subject: Registration of text/directory MIME type BDAY - - Type name: BDAY - - Type purpose: To specify the birth date of the object the vCard - represents. - - Type encoding: 8bit - - Type value: The default is a single date value. It can also be reset - to a single date-time value. - - Type examples: - - BDAY:1996-04-15 - - BDAY:1953-10-15T23:10:00Z - - BDAY:1987-09-27T08:30:00-06:00 - -3.2 Delivery Addressing Types - - These types are concerned with information related to the delivery - addressing or label for the vCard object. - -3.2.1 ADR Type Definition - - To: ietf-mime-directory@imc.org - - Subject: Registration of text/directory MIME type ADR - - Type name: ADR - - - - -Dawson & Howes Standards Track [Page 11] - -RFC 2426 vCard MIME Directory Profile September 1998 - - - Type purpose: To specify the components of the delivery address for - the vCard object. - - Type encoding: 8bit - - Type value: A single structured text value, separated by the - SEMI-COLON character (ASCII decimal 59). - - Type special notes: The structured type value consists of a sequence - of address components. The component values MUST be specified in - their corresponding position. The structured type value corresponds, - in sequence, to the post office box; the extended address; the street - address; the locality (e.g., city); the region (e.g., state or - province); the postal code; the country name. When a component value - is missing, the associated component separator MUST still be - specified. - - The text components are separated by the SEMI-COLON character (ASCII - decimal 59). Where it makes semantic sense, individual text - components can include multiple text values (e.g., a "street" - component with multiple lines) separated by the COMMA character - (ASCII decimal 44). - - The type can include the type parameter "TYPE" to specify the - delivery address type. The TYPE parameter values can include "dom" to - indicate a domestic delivery address; "intl" to indicate an - international delivery address; "postal" to indicate a postal - delivery address; "parcel" to indicate a parcel delivery address; - "home" to indicate a delivery address for a residence; "work" to - indicate delivery address for a place of work; and "pref" to indicate - the preferred delivery address when more than one address is - specified. These type parameter values can be specified as a - parameter list (i.e., "TYPE=dom;TYPE=postal") or as a value list - (i.e., "TYPE=dom,postal"). This type is based on semantics of the - X.520 geographical and postal addressing attributes. The default is - "TYPE=intl,postal,parcel,work". The default can be overridden to some - other set of values by specifying one or more alternate values. For - example, the default can be reset to "TYPE=dom,postal,work,home" to - specify a domestic delivery address for postal delivery to a - residence that is also used for work. - - Type example: In this example the post office box and the extended - address are absent. - - ADR;TYPE=dom,home,postal,parcel:;;123 Main - Street;Any Town;CA;91921-1234 - - - - - -Dawson & Howes Standards Track [Page 12] - -RFC 2426 vCard MIME Directory Profile September 1998 - - -3.2.2 LABEL Type Definition - - To: ietf-mime-directory@imc.org - - Subject: Registration of text/directory MIME type LABEL - - Type name: LABEL - - Type purpose: To specify the formatted text corresponding to delivery - address of the object the vCard represents. - - Type encoding: 8bit - - Type value: A single text value. - - Type special notes: The type value is formatted text that can be used - to present a delivery address label for the vCard object. The type - can include the type parameter "TYPE" to specify delivery label type. - The TYPE parameter values can include "dom" to indicate a domestic - delivery label; "intl" to indicate an international delivery label; - "postal" to indicate a postal delivery label; "parcel" to indicate a - parcel delivery label; "home" to indicate a delivery label for a - residence; "work" to indicate delivery label for a place of work; and - "pref" to indicate the preferred delivery label when more than one - label is specified. These type parameter values can be specified as a - parameter list (i.e., "TYPE=dom;TYPE=postal") or as a value list - (i.e., "TYPE=dom,postal"). This type is based on semantics of the - X.520 geographical and postal addressing attributes. The default is - "TYPE=intl,postal,parcel,work". The default can be overridden to some - other set of values by specifying one or more alternate values. For - example, the default can be reset to "TYPE=intl,post,parcel,home" to - specify an international delivery label for both postal and parcel - delivery to a residential location. - - Type example: A multi-line address label. - - LABEL;TYPE=dom,home,postal,parcel:Mr.John Q. Public\, Esq.\n - Mail Drop: TNE QB\n123 Main Street\nAny Town\, CA 91921-1234 - \nU.S.A. - -3.3 Telecommunications Addressing Types - - These types are concerned with information associated with the - telecommunications addressing of the object the vCard represents. - - - - - - - -Dawson & Howes Standards Track [Page 13] - -RFC 2426 vCard MIME Directory Profile September 1998 - - -3.3.1 TEL Type Definition - - To: ietf-mime-directory@imc.org - - Subject: Registration of text/directory MIME type TEL - - Type name: TEL - - Type purpose: To specify the telephone number for telephony - communication with the object the vCard represents. - - Type encoding: 8bit - - Type value: A single phone-number value. - - Type special notes: The value of this type is specified in a - canonical form in order to specify an unambiguous representation of - the globally unique telephone endpoint. This type is based on the - X.500 Telephone Number attribute. - - The type can include the type parameter "TYPE" to specify intended - use for the telephone number. The TYPE parameter values can include: - "home" to indicate a telephone number associated with a residence, - "msg" to indicate the telephone number has voice messaging support, - "work" to indicate a telephone number associated with a place of - work, "pref" to indicate a preferred-use telephone number, "voice" to - indicate a voice telephone number, "fax" to indicate a facsimile - telephone number, "cell" to indicate a cellular telephone number, - "video" to indicate a video conferencing telephone number, "pager" to - indicate a paging device telephone number, "bbs" to indicate a - bulletin board system telephone number, "modem" to indicate a MODEM - connected telephone number, "car" to indicate a car-phone telephone - number, "isdn" to indicate an ISDN service telephone number, "pcs" to - indicate a personal communication services telephone number. The - default type is "voice". These type parameter values can be specified - as a parameter list (i.e., "TYPE=work;TYPE=voice") or as a value list - (i.e., "TYPE=work,voice"). The default can be overridden to another - set of values by specifying one or more alternate values. For - example, the default TYPE of "voice" can be reset to a WORK and HOME, - VOICE and FAX telephone number by the value list - "TYPE=work,home,voice,fax". - - Type example: - - TEL;TYPE=work,voice,pref,msg:+1-213-555-1234 - - - - - - -Dawson & Howes Standards Track [Page 14] - -RFC 2426 vCard MIME Directory Profile September 1998 - - -3.3.2 EMAIL Type Definition - - To: ietf-mime-directory@imc.org - - Subject: Registration of text/directory MIME type EMAIL - - Type name: EMAIL - - Type purpose: To specify the electronic mail address for - communication with the object the vCard represents. - - Type encoding: 8bit - - Type value: A single text value. - - Type special notes: The type can include the type parameter "TYPE" to - specify the format or preference of the electronic mail address. The - TYPE parameter values can include: "internet" to indicate an Internet - addressing type, "x400" to indicate a X.400 addressing type or "pref" - to indicate a preferred-use email address when more than one is - specified. Another IANA registered address type can also be - specified. The default email type is "internet". A non-standard value - can also be specified. - - Type example: - - EMAIL;TYPE=internet:jqpublic@xyz.dom1.com - - EMAIL;TYPE=internet:jdoe@isp.net - - EMAIL;TYPE=internet,pref:jane_doe@abc.com - -3.3.3 MAILER Type Definition - - To: ietf-mime-directory@imc.org - - Subject: Registration of text/directory MIME type MAILER - - Type name: MAILER - - Type purpose: To specify the type of electronic mail software that is - used by the individual associated with the vCard. - - Type encoding: 8bit - - Type value: A single text value. - - - - - -Dawson & Howes Standards Track [Page 15] - -RFC 2426 vCard MIME Directory Profile September 1998 - - - Type special notes: This information can provide assistance to a - correspondent regarding the type of data representation which can be - used, and how they can be packaged. This property is based on the - private MIME type X-Mailer that is generally implemented by MIME user - agent products. - - Type example: - - MAILER:PigeonMail 2.1 - -3.4 Geographical Types - - These types are concerned with information associated with - geographical positions or regions associated with the object the - vCard represents. - -3.4.1 TZ Type Definition - - To: ietf-mime-directory@imc.org - - Subject: Registration of text/directory MIME type TZ - - Type name: TZ - - Type purpose: To specify information related to the time zone of the - object the vCard represents. - - Type encoding: 8bit - - Type value: The default is a single utc-offset value. It can also be - reset to a single text value. - - Type special notes: The type value consists of a single value. - - Type examples: - - TZ:-05:00 - - TZ;VALUE=text:-05:00; EST; Raleigh/North America - ;This example has a single value, not a structure text value. - -3.4.2 GEO Type Definition - - To: ietf-mime-directory@imc.org - - Subject: Registration of text/directory MIME type GEO - - Type name: GEO - - - -Dawson & Howes Standards Track [Page 16] - -RFC 2426 vCard MIME Directory Profile September 1998 - - - Type purpose: To specify information related to the global - positioning of the object the vCard represents. - - Type encoding: 8bit - - Type value: A single structured value consisting of two float values - separated by the SEMI-COLON character (ASCII decimal 59). - - Type special notes: This type specifies information related to the - global position of the object associated with the vCard. The value - specifies latitude and longitude, in that order (i.e., "LAT LON" - ordering). The longitude represents the location east and west of the - prime meridian as a positive or negative real number, respectively. - The latitude represents the location north and south of the equator - as a positive or negative real number, respectively. The longitude - and latitude values MUST be specified as decimal degrees and should - be specified to six decimal places. This will allow for granularity - within a meter of the geographical position. The text components are - separated by the SEMI-COLON character (ASCII decimal 59). The simple - formula for converting degrees-minutes-seconds into decimal degrees - is: - - decimal = degrees + minutes/60 + seconds/3600. - - Type example: - - GEO:37.386013;-122.082932 - -3.5 Organizational Types - - These types are concerned with information associated with - characteristics of the organization or organizational units of the - object the vCard represents. - -3.5.1 TITLE Type Definition - - To: ietf-mime-directory@imc.org - - Subject: Registration of text/directory MIME type TITLE - - Type name: TITLE - - Type purpose: To specify the job title, functional position or - function of the object the vCard represents. - - Type encoding: 8bit - - Type value: A single text value. - - - -Dawson & Howes Standards Track [Page 17] - -RFC 2426 vCard MIME Directory Profile September 1998 - - - Type special notes: This type is based on the X.520 Title attribute. - - Type example: - - TITLE:Director\, Research and Development - -3.5.2 ROLE Type Definition - - To: ietf-mime-directory@imc.org - - Subject: Registration of text/directory MIME type ROLE - - Type name: ROLE - - Type purpose: To specify information concerning the role, occupation, - or business category of the object the vCard represents. - - Type encoding: 8bit - - Type value: A single text value. - - Type special notes: This type is based on the X.520 Business Category - explanatory attribute. This property is included as an organizational - type to avoid confusion with the semantics of the TITLE type and - incorrect usage of that type when the semantics of this type is - intended. - - Type example: - - ROLE:Programmer - -3.5.3 LOGO Type Definition - - To: ietf-mime-directory@imc.org - - Subject: Registration of text/directory MIME type LOGO - - Type name: LOGO - - Type purpose: To specify a graphic image of a logo associated with - the object the vCard represents. - - Type encoding: The encoding MUST be reset to "b" using the ENCODING - parameter in order to specify inline, encoded binary data. If the - value is referenced by a URI value, then the default encoding of 8bit - is used and no explicit ENCODING parameter is needed. - - - - - -Dawson & Howes Standards Track [Page 18] - -RFC 2426 vCard MIME Directory Profile September 1998 - - - Type value: A single value. The default is binary value. It can also - be reset to uri value. The uri value can be used to specify a value - outside of this MIME entity. - - Type special notes: The type can include the type parameter "TYPE" to - specify the graphic image format type. The TYPE parameter values MUST - be one of the IANA registered image formats or a non-standard image - format. - - Type example: - - LOGO;VALUE=uri:http://www.abc.com/pub/logos/abccorp.jpg - - LOGO;ENCODING=b;TYPE=JPEG:MIICajCCAdOgAwIBAgICBEUwDQYJKoZIhvcN - AQEEBQAwdzELMAkGA1UEBhMCVVMxLDAqBgNVBAoTI05ldHNjYXBlIENvbW11bm - ljYXRpb25zIENvcnBvcmF0aW9uMRwwGgYDVQQLExNJbmZvcm1hdGlvbiBTeXN0 - <...the remainder of "B" encoded binary data...> - -3.5.4 AGENT Type Definition - - To: ietf-mime-directory@imc.org - - Subject: Registration of text/directory MIME type AGENT - - Type name: AGENT - - Type purpose: To specify information about another person who will - act on behalf of the individual or resource associated with the - vCard. - - Type encoding: 8-bit - - Type value: The default is a single vcard value. It can also be reset - to either a single text or uri value. The text value can be used to - specify textual information. The uri value can be used to specify - information outside of this MIME entity. - - Type special notes: This type typically is used to specify an area - administrator, assistant, or secretary for the individual associated - with the vCard. A key characteristic of the Agent type is that it - represents somebody or something that is separately addressable. - - Type example: - - AGENT;VALUE=uri: - CID:JQPUBLIC.part3.960129T083020.xyzMail@host3.com - - - - - -Dawson & Howes Standards Track [Page 19] - -RFC 2426 vCard MIME Directory Profile September 1998 - - - AGENT:BEGIN:VCARD\nFN:Susan Thomas\nTEL:+1-919-555- - 1234\nEMAIL\;INTERNET:sthomas@host.com\nEND:VCARD\n - -3.5.5 ORG Type Definition - - To: ietf-mime-directory@imc.org - - Subject: Registration of text/directory MIME type ORG - - Type name: ORG - - Type purpose: To specify the organizational name and units associated - with the vCard. - - Type encoding: 8bit - - Type value: A single structured text value consisting of components - separated the SEMI-COLON character (ASCII decimal 59). - - Type special notes: The type is based on the X.520 Organization Name - and Organization Unit attributes. The type value is a structured type - consisting of the organization name, followed by one or more levels - of organizational unit names. - - Type example: A type value consisting of an organizational name, - organizational unit #1 name and organizational unit #2 name. - - ORG:ABC\, Inc.;North American Division;Marketing - -3.6 Explanatory Types - - These types are concerned with additional explanations, such as that - related to informational notes or revisions specific to the vCard. - -3.6.1 CATEGORIES Type Definition - - To: ietf-mime-directory@imc.org - - Subject: Registration of text/directory MIME type CATEGORIES - - Type name: CATEGORIES - - Type purpose: To specify application category information about the - vCard. - - Type encoding: 8bit - - - - - -Dawson & Howes Standards Track [Page 20] - -RFC 2426 vCard MIME Directory Profile September 1998 - - - Type value: One or more text values separated by a COMMA character - (ASCII decimal 44). - - Type example: - - CATEGORIES:TRAVEL AGENT - - CATEGORIES:INTERNET,IETF,INDUSTRY,INFORMATION TECHNOLOGY - -3.6.2 NOTE Type Definition - - To: ietf-mime-directory@imc.org - - Subject: Registration of text/directory MIME type NOTE - - Type name: NOTE - - Type purpose: To specify supplemental information or a comment that - is associated with the vCard. - - Type encoding: 8bit - - Type value: A single text value. - - Type special notes: The type is based on the X.520 Description - attribute. - - Type example: - - NOTE:This fax number is operational 0800 to 1715 - EST\, Mon-Fri. - -3.6.3 PRODID Type Definition - - To: ietf-mime-directory@imc.org - - Subject: Registration of text/directory MIME type PRODID - - Type name: PRODID - - Type purpose: To specify the identifier for the product that created - the vCard object. - - Type encoding: 8-bit - - Type value: A single text value. - - - - - -Dawson & Howes Standards Track [Page 21] - -RFC 2426 vCard MIME Directory Profile September 1998 - - - Type special notes: Implementations SHOULD use a method such as that - specified for Formal Public Identifiers in ISO 9070 to assure that - the text value is unique. - - Type example: - - PRODID:-//ONLINE DIRECTORY//NONSGML Version 1//EN - -3.6.4 REV Type Definition - - To: ietf-mime-directory@imc.org - - Subject: Registration of text/directory MIME type REV - - Type name: REV - - Type purpose: To specify revision information about the current - vCard. - - Type encoding: 8-bit - - Type value: The default is a single date-time value. Can also be - reset to a single date value. - - Type special notes: The value distinguishes the current revision of - the information in this vCard for other renditions of the - information. - - Type example: - - REV:1995-10-31T22:27:10Z - - REV:1997-11-15 - -3.6.5 SORT-STRING Type Definition - - To: ietf-mime-directory@imc.org - - Subject: Registration of text/directory MIME type SORT-STRING - - Type Name: SORT-STRING - - Type purpose: To specify the family name or given name text to be - used for national-language-specific sorting of the FN and N types. - - Type encoding: 8bit - - Type value: A single text value. - - - -Dawson & Howes Standards Track [Page 22] - -RFC 2426 vCard MIME Directory Profile September 1998 - - - Type special notes: The sort string is used to provide family name or - given name text that is to be used in locale- or national-language- - specific sorting of the formatted name and structured name types. - Without this information, sorting algorithms could incorrectly sort - this vCard within a sequence of sorted vCards. When this type is - present in a vCard, then this family name or given name value is used - for sorting the vCard. - - Type examples: For the case of family name sorting, the following - examples define common sort string usage with the FN and N types. - - FN:Rene van der Harten - N:van der Harten;Rene;J.;Sir;R.D.O.N. - SORT-STRING:Harten - - FN:Robert Pau Shou Chang - N:Pau;Shou Chang;Robert - SORT-STRING:Pau - - FN:Osamu Koura - N:Koura;Osamu - SORT-STRING:Koura - - FN:Oscar del Pozo - N:del Pozo Triscon;Oscar - SORT-STRING:Pozo - - FN:Chistine d'Aboville - N:d'Aboville;Christine - SORT-STRING:Aboville - -3.6.6 SOUND Type Definition - - To: ietf-mime-directory@imc.org - - Subject: Registration of text/directory MIME type SOUND - - Type name: SOUND - - Type purpose: To specify a digital sound content information that - annotates some aspect of the vCard. By default this type is used to - specify the proper pronunciation of the name type value of the vCard. - - Type encoding: The encoding MUST be reset to "b" using the ENCODING - parameter in order to specify inline, encoded binary data. If the - value is referenced by a URI value, then the default encoding of 8bit - is used and no explicit ENCODING parameter is needed. - - - - -Dawson & Howes Standards Track [Page 23] - -RFC 2426 vCard MIME Directory Profile September 1998 - - - Type value: A single value. The default is binary value. It can also - be reset to uri value. The uri value can be used to specify a value - outside of this MIME entity. - - Type special notes: The type can include the type parameter "TYPE" to - specify the audio format type. The TYPE parameter values MUST be one - of the IANA registered audio formats or a non-standard audio format. - - Type example: - - SOUND;TYPE=BASIC;VALUE=uri:CID:JOHNQPUBLIC.part8. - 19960229T080000.xyzMail@host1.com - - SOUND;TYPE=BASIC;ENCODING=b:MIICajCCAdOgAwIBAgICBEUwDQYJKoZIhvcN - AQEEBQAwdzELMAkGA1UEBhMCVVMxLDAqBgNVBAoTI05ldHNjYXBlIENvbW11bm - ljYXRpb25zIENvcnBvcmF0aW9uMRwwGgYDVQQLExNJbmZvcm1hdGlvbiBTeXN0 - <...the remainder of "B" encoded binary data...> - -3.6.7 UID Type Definition - - To: ietf-mime-directory@imc.org - - Subject: Registration of text/directory MIME type UID - - Type name: UID - - Type purpose: To specify a value that represents a globally unique - identifier corresponding to the individual or resource associated - with the vCard. - - Type encoding: 8bit - - Type value: A single text value. - - Type special notes: The type is used to uniquely identify the object - that the vCard represents. - - The type can include the type parameter "TYPE" to specify the format - of the identifier. The TYPE parameter value should be an IANA - registered identifier format. The value can also be a non-standard - format. - - Type example: - - UID:19950401-080045-40000F192713-0052 - - - - - - -Dawson & Howes Standards Track [Page 24] - -RFC 2426 vCard MIME Directory Profile September 1998 - - -3.6.8 URL Type Definition - - To: ietf-mime-directory@imc.org - - Subject: Registration of text/directory MIME type URL - - Type name: URL - - Type purpose: To specify a uniform resource locator associated with - the object that the vCard refers to. - - Type encoding: 8bit - - Type value: A single uri value. - - Type example: - - URL:http://www.swbyps.restaurant.french/~chezchic.html - -3.6.9 VERSION Type Definition - - To: ietf-mime-directory@imc.org - - Subject: Registration of text/directory MIME type VERSION - - Type name: VERSION - - Type purpose: To specify the version of the vCard specification used - to format this vCard. - - Type encoding: 8bit - - Type value: A single text value. - - Type special notes: The property MUST be present in the vCard object. - The value MUST be "3.0" if the vCard corresponds to this - specification. - - Type example: - - VERSION:3.0 - -3.7 Security Types - - These types are concerned with the security of communication pathways - or access to the vCard. - - - - - -Dawson & Howes Standards Track [Page 25] - -RFC 2426 vCard MIME Directory Profile September 1998 - - -3.7.1 CLASS Type Definition - - To: ietf-mime-directory@imc.org - - Subject: Registration of text/directory MIME type CLASS - - Type name: CLASS - - Type purpose: To specify the access classification for a vCard - object. - - Type encoding: 8bit - - Type value: A single text value. - - Type special notes: An access classification is only one component of - the general security model for a directory service. The - classification attribute provides a method of capturing the intent of - the owner for general access to information described by the vCard - object. - - Type examples: - - CLASS:PUBLIC - - CLASS:PRIVATE - - CLASS:CONFIDENTIAL - -3.7.2 KEY Type Definition - - To: ietf-mime-directory@imc.org - - Subject: Registration of text/directory MIME type KEY - - Type name: KEY - - Type purpose: To specify a public key or authentication certificate - associated with the object that the vCard represents. - - Type encoding: The encoding MUST be reset to "b" using the ENCODING - parameter in order to specify inline, encoded binary data. If the - value is a text value, then the default encoding of 8bit is used and - no explicit ENCODING parameter is needed. - - Type value: A single value. The default is binary. It can also be - reset to text value. The text value can be used to specify a text - key. - - - -Dawson & Howes Standards Track [Page 26] - -RFC 2426 vCard MIME Directory Profile September 1998 - - - Type special notes: The type can also include the type parameter TYPE - to specify the public key or authentication certificate format. The - parameter type should specify an IANA registered public key or - authentication certificate format. The parameter type can also - specify a non-standard format. - - Type example: - - KEY;ENCODING=b:MIICajCCAdOgAwIBAgICBEUwDQYJKoZIhvcNAQEEBQA - wdzELMAkGA1UEBhMCVVMxLDAqBgNVBAoTI05ldHNjYXBlIENbW11bmljYX - Rpb25zIENvcnBvcmF0aW9uMRwwGgYDVQQLExNJbmZvcm1hdGlvbiBTeXN0 - ZW1zMRwwGgYDVQQDExNyb290Y2EubmV0c2NhcGUuY29tMB4XDTk3MDYwNj - E5NDc1OVoXDTk3MTIwMzE5NDc1OVowgYkxCzAJBgNVBAYTAlVTMSYwJAYD - VQQKEx1OZXRzY2FwZSBDb21tdW5pY2F0aW9ucyBDb3JwLjEYMBYGA1UEAx - MPVGltb3RoeSBBIEhvd2VzMSEwHwYJKoZIhvcNAQkBFhJob3dlc0BuZXRz - Y2FwZS5jb20xFTATBgoJkiaJk/IsZAEBEwVob3dlczBcMA0GCSqGSIb3DQ - EBAQUAA0sAMEgCQQC0JZf6wkg8pLMXHHCUvMfL5H6zjSk4vTTXZpYyrdN2 - dXcoX49LKiOmgeJSzoiFKHtLOIboyludF90CgqcxtwKnAgMBAAGjNjA0MB - EGCWCGSAGG+EIBAQQEAwIAoDAfBgNVHSMEGDAWgBT84FToB/GV3jr3mcau - +hUMbsQukjANBgkqhkiG9w0BAQQFAAOBgQBexv7o7mi3PLXadkmNP9LcIP - mx93HGp0Kgyx1jIVMyNgsemeAwBM+MSlhMfcpbTrONwNjZYW8vJDSoi//y - rZlVt9bJbs7MNYZVsyF1unsqaln4/vy6Uawfg8VUMk1U7jt8LYpo4YULU7 - UZHPYVUaSgVttImOHZIKi4hlPXBOhcUQ== - -3.8 Extended Types - - The types defined by this document can be extended with private types - using the non-standard, private values mechanism defined in [RFC - 2045]. Non-standard, private types with a name starting with "X-" may - be defined bilaterally between two cooperating agents without outside - registration or standardization. - -4. Formal Grammar - - The following formal grammar is provided to assist developers in - building parsers for the vCard. - - This syntax is written according to the form described in RFC 2234, - but it references just this small subset of RFC 2234 literals: - - ;******************************************* - ; Commonly Used Literal Definition - ;******************************************* - - ALPHA = %x41-5A / %x61-7A - ; Latin Capital Letter A-Latin Capital Letter Z / - ; Latin Small Letter a-Latin Small Letter z - - - - -Dawson & Howes Standards Track [Page 27] - -RFC 2426 vCard MIME Directory Profile September 1998 - - - CHAR = %x01-7F - ; Any C0 Controls and Basic Latin, excluding NULL from - ; Code Charts, pages 7-6 through 7-9 in [UNICODE] - - CR = %x0D - ; Carriage Return - - LF = %0A - ; Line Feed - - CRLF = CR LF - ; Internet standard newline - - ;CTL = %x00-1F / %x7F - ; Controls. Not used, but referenced in comments. - - DIGIT = %x30-39 - ; Digit Zero-Digit Nine - - DQUOTE = %x22 - ; Quotation Mark - - HTAB = %x09 - ; Horizontal Tabulation - - SP = %x20 - ; space - - VCHAR = %x21-7E - ; Visible (printing) characters - - WSP = SP / HTAB - ; White Space - - ;******************************************* - ; Basic vCard Definition - ;******************************************* - - vcard_entity = 1*(vcard) - - vcard = [group "."] "BEGIN" ":" "VCARD" 1*CRLF - 1*(contentline) - ;A vCard object MUST include the VERSION, FN and N types. - [group "."] "END" ":" "VCARD" 1*CRLF - - contentline = [group "."] name *(";" param ) ":" value CRLF - ; When parsing a content line, folded lines must first - ; be unfolded according to the unfolding procedure - - - -Dawson & Howes Standards Track [Page 28] - -RFC 2426 vCard MIME Directory Profile September 1998 - - - ; described above. When generating a content line, lines - ; longer than 75 characters SHOULD be folded according to - ; the folding procedure described in [MIME DIR]. - - group = 1*(ALPHA / DIGIT / "-") - - name = iana-token / x-name - ; Parsing of the param and value is - ; based on the "name" or type identifier - ; as defined in ABNF sections below - - iana-token = 1*(ALPHA / DIGIT / "-") - ; vCard type or parameter identifier registered with IANA - - x-name = "X-" 1*(ALPHA / DIGIT / "-") - ; Reserved for non-standard use - - param = param-name "=" param-value *("," param-value) - - param-name = iana-token / x-name - - param-value = ptext / quoted-string - - ptext = *SAFE-CHAR - - value = *VALUE-CHAR - - quoted-string = DQUOTE QSAFE-CHAR DQUOTE - - NON-ASCII = %x80-FF - ; Use is restricted by CHARSET parameter - ; on outer MIME object (UTF-8 preferred) - - QSAFE-CHAR = WSP / %x21 / %x23-7E / NON-ASCII - ; Any character except CTLs, DQUOTE - - SAFE-CHAR = WSP / %x21 / %x23-2B / %x2D-39 / %x3C-7E / NON-ASCII - ; Any character except CTLs, DQUOTE, ";", ":", "," - - VALUE-CHAR = WSP / VCHAR / NON-ASCII - ; Any textual character - - ;******************************************* - ; vCard Type Definition - ; - ; Provides type-specific definitions for how the - ; "value" and "param" are defined. - ;******************************************* - - - -Dawson & Howes Standards Track [Page 29] - -RFC 2426 vCard MIME Directory Profile September 1998 - - - ;For name="NAME" - param = "" - ; No parameters allowed - - value = text-value - - ;For name="PROFILE" - param = "" - ; No parameters allowed - - value = text-value - ; Value MUST be the case insensitive value "VCARD - - ;For name="SOURCE" - param = source-param - ; No parameters allowed - - value = uri - - source-param = ("VALUE" "=" "uri") - / ("CONTEXT" "=" "word") - ; Parameter value specifies the protocol context - ; for the uri value. - / (x-name "=" *SAFE-CHAR) - - ;For name="FN" - ;This type MUST be included in a vCard object. - param = text-param - ; Text parameters allowed - - value = text-value - - ;For name="N" - ;This type MUST be included in a vCard object. - - param = text-param - ; Text parameters allowed - - value = n-value - - n-value = 0*4(text-value *("," text-value) ";") - text-value *("," text-value) - ; Family; Given; Middle; Prefix; Suffix. - ; Example: Public;John;Quincy,Adams;Reverend Dr. III - - ;For name="NICKNAME" - param = text-param - ; Text parameters allowed - - - -Dawson & Howes Standards Track [Page 30] - -RFC 2426 vCard MIME Directory Profile September 1998 - - - value = text-list - - ;For name="PHOTO" - param = img-inline-param - ; Only image parameters allowed - - param =/ img-refer-param - ; Only image parameters allowed - - value = img-inline-value - ; Value and parameter MUST match - - value =/ img-refer-value - ; Value and parameter MUST match - - ;For name="BDAY" - param = ("VALUE" "=" "date") - ; Only value parameter allowed - - param =/ ("VALUE" "=" "date-time") - ; Only value parameter allowed - - value = date-value - ; Value MUST match value type - - value =/ date-time-value - ; Value MUST match value type - - ;For name="ADR" - param = adr-param / text-param - ; Only adr and text parameters allowed - - value = adr-value - - ;For name="LABEL" - param = adr-param / text-param - ; Only adr and text parameters allowed - - value = text-value - - ;For name="TEL" - param = tel-param - ; Only tel parameters allowed - - value = phone-number-value - - tel-param = "TYPE" "=" tel-type *("," tel-type) - - - - -Dawson & Howes Standards Track [Page 31] - -RFC 2426 vCard MIME Directory Profile September 1998 - - - tel-type = "HOME" / "WORK" / "PREF" / "VOICE" / "FAX" / "MSG" - / "CELL" / "PAGER" / "BBS" / "MODEM" / "CAR" / "ISDN" - / "VIDEO" / "PCS" / iana-token / x-name - ; Values are case insensitive - - ;For name="EMAIL" - param = email-param - ; Only email parameters allowed - - value = text-value - - email-param = "TYPE" "=" email-type ["," "PREF"] - ; Value is case insensitive - - email-type = "INTERNET" / "X400" / iana-token / "X-" word - ; Values are case insensitive - - ;For name="MAILER" - param = text-param - ; Only text parameters allowed - - value = text-value - - ;For name="TZ" - param = "" - ; No parameters allowed - - value = utc-offset-value - - ;For name="GEO" - param = "" - ; No parameters allowed - - value = float-value ";" float-value - - ;For name="TITLE" - param = text-param - ; Only text parameters allowed - - value = text-value - - ;For name="ROLE" - param = text-param - ; Only text parameters allowed - - value = text-value - - ;For name="LOGO" - - - -Dawson & Howes Standards Track [Page 32] - -RFC 2426 vCard MIME Directory Profile September 1998 - - - param = img-inline-param / img-refer-param - ; Only image parameters allowed - - value = img-inline-value / img-refer-value - ; Value and parameter MUST match - - ;For name="AGENT" - param = agent-inline-param - - param =/ agent-refer-param - - value = agent-inline-value - ; Value and parameter MUST match - - value =/ agent-refer-value - ; Value and parameter MUST match - - agent-inline-param = "" - ; No parameters allowed - - agent-refer-param = "VALUE" "=" "uri" - ; Only value parameter allowed - - agent-inline-value = text-value - ; Value MUST be a valid vCard object - - agent-refer-value = uri - ; URI MUST refer to image content of given type - - ;For name="ORG" - - param = text-param - ; Only text parameters allowed - - value = org-value - - org-value = *(text-value ";") text-value - ; First is Organization Name, remainder are Organization Units. - - ;For name="CATEGORIES" - param = text-param - ; Only text parameters allowed - - value = text-list - - ;For name="NOTE" - param = text-param - ; Only text parameters allowed - - - -Dawson & Howes Standards Track [Page 33] - -RFC 2426 vCard MIME Directory Profile September 1998 - - - value = text-value - - ;For name="PRODID" - param = "" - ; No parameters allowed - - value = text-value - - ;For name="REV" - param = ["VALUE" =" "date-time"] - ; Only value parameters allowed. Values are case insensitive. - - param =/ "VALUE" =" "date" - ; Only value parameters allowed. Values are case insensitive. - - value = date-time-value - - value =/ date-value - - ;For name="SORT-STRING" - param = text-param - ; Only text parameters allowed - - value = text-value - - ;For name="SOUND" - param = snd-inline-param - ; Only sound parameters allowed - - param =/ snd-refer-param - ; Only sound parameters allowed - - value = snd-line-value - ; Value MUST match value type - - value =/ snd-refer-value - ; Value MUST match value type - - snd-inline-value = binary-value CRLF - ; Value MUST be "b" encoded audio content - - snd-inline-param = ("VALUE" "=" "binary"]) - / ("ENCODING" "=" "b") - / ("TYPE" "=" *SAFE-CHAR) - ; Value MUST be an IANA registered audio type - - snd-refer-value = uri - ; URI MUST refer to audio content of given type - - - -Dawson & Howes Standards Track [Page 34] - -RFC 2426 vCard MIME Directory Profile September 1998 - - - snd-refer-param = ("VALUE" "=" "uri") - / ("TYPE" "=" word) - ; Value MUST be an IANA registered audio type - - ;For name="UID" - param = "" - ; No parameters allowed - - value = text-value - - ;For name="URL" - param = "" - ; No parameters allowed - - value = uri - - ;For name="VERSION" - ;This type MUST be included in a vCard object. - param = "" - ; No parameters allowed - - value = text-value - ; Value MUST be "3.0" - - ;For name="CLASS" - param = "" - ; No parameters allowed - - value = "PUBLIC" / "PRIVATE" / "CONFIDENTIAL" - / iana-token / x-name - ; Value are case insensitive - - ;For name="KEY" - param = key-txt-param - ; Only value and type parameters allowed - - param =/ key-bin-param - ; Only value and type parameters allowed - - value = text-value - - value =/ binary-value - - key-txt-param = "TYPE" "=" keytype - - key-bin-param = ("TYPE" "=" keytype) - / ("ENCODING" "=" "b") - ; Value MUST be a "b" encoded key or certificate - - - -Dawson & Howes Standards Track [Page 35] - -RFC 2426 vCard MIME Directory Profile September 1998 - - - keytype = "X509" / "PGP" / iana-token / x-name - ; Values are case insensitive - - ;For name="X-" non-standard type - param = text-param / (x-name "=" param-value) - ; Only text or non-standard parameters allowed - - value = text-value - - ;******************************************* - ; vCard Commonly Used Parameter Definition - ;******************************************* - - text-param = ("VALUE" "=" "ptext") - / ("LANGUAGE" "=" langval) - / (x-name "=" param-value) - - langval = <a language string as defined in RFC 1766> - - img-inline-value = binary-value - ;Value MUST be "b" encoded image content - - img-inline-param - - img-inline-param = ("VALUE" "=" "binary") - / ("ENCODING" "=" "b") - / ("TYPE" "=" param-value - ;TYPE value MUST be an IANA registered image type - - img-refer-value = uri - ;URI MUST refer to image content of given type - - img-refer-param = ("VALUE" "=" "uri") - / ("TYPE" "=" param-value) - ;TYPE value MUST be an IANA registered image type - - adr-param = ("TYPE" "=" adr-type *("," adr-type)) - / (text-param) - - adr-type = "dom" / "intl" / "postal" / "parcel" / "home" - / "work" / "pref" / iana-type / x-name - - adr-value = 0*6(text-value ";") text-value - ; PO Box, Extended Address, Street, Locality, Region, Postal - ; Code, Country Name - - - - - - -Dawson & Howes Standards Track [Page 36] - -RFC 2426 vCard MIME Directory Profile September 1998 - - - ;******************************************* - ; vCard Type Value Definition - ;******************************************* - - text-value-list = 1*text-value *("," 1*text-value) - - text-value = *(SAFE-CHAR / ":" / DQUOTE / ESCAPED-CHAR) - - ESCAPED-CHAR = "\\" / "\;" / "\," / "\n" / "\N") - ; \\ encodes \, \n or \N encodes newline - ; \; encodes ;, \, encodes , - - binary-value = <A "b" encoded text value as defined in [RFC 2047]> - - date-value = <A single date value as defined in [MIME-DIR]> - - time-value = <A single time value as defined in [MIME-DIR]> - - date-time-value = <A single date-time value as defined in [MIME-DIR] - - float-value = <A single float value as defined in [MIME-DIR]> - - phone-number-value = <A single text value as defined in [CCITT - E.163] and [CCITT X.121]> - - uri-value = <A uri value as defined in [MIME-DIR]> - - utc-offset-value = ("+" / "-") time-hour ":" time-minute - time-hour = 2DIGIT ;00-23 - time-minute = 2DIGIT ;00-59 - -5. Differences From vCard v2.1 - - This specification has been reviewed by the IETF community. The - review process introduced a number of differences from the [VCARD] - version 2.1. These differences require that vCard objects conforming - to this specification have a different version number than a vCard - conforming to [VCARD]. The differences include the following: - - . The QUOTED-PRINTABLE inline encoding has been eliminated. - Only the "B" encoding of [RFC 2047] is an allowed value for - the ENCODING parameter. - - . The method for specifying CRLF character sequences in text - type values has been changed. The CRLF character sequence in - a text type value is specified with the backslash character - sequence "\n" or "\N". - - - - -Dawson & Howes Standards Track [Page 37] - -RFC 2426 vCard MIME Directory Profile September 1998 - - - . Any COMMA or SEMICOLON in a text type value must be backslash - escaped. - - . VERSION value corresponding to this specification MUST be - "3.0". - - . The [MIME-DIR] predefined types of SOURCE, NAME and PROFILE - are allowed. - - . The [MIME-DIR] VALUE type parameter for value data typing is - allowed. In addition, there are extensions made to these type - values for additional value types used in this specification. - - . The [VCARD] CHARSET type parameter has been eliminated. - Character set can only be specified on the CHARSET parameter - on the Content-Type MIME header field. - - . The [VCARD] support for non-significant WSP character has - been eliminated. - - . The "TYPE=" prefix to parameter values is required. In - [VCARD] this was optional. - - . LOGO, PHOTO and SOUND multimedia formats MUST be either IANA - registered types or non-standard types. - - . Inline binary content must be "B" encoded and folded. A blank - line after the encoded binary content is no longer required. - - . TEL values can be identified as personal communication - services telephone numbers with the PCS type parameter value. - - . The CATEGORIES, CLASS, NICKNAME, PRODID and SORT-STRING types - have been added. - - . The VERSION, N and FN types MUST be specified in a vCard. - This identifies the version of the specification that the - object was formatted to. It also assures that every vCard - will include both a structured and formatted name that can be - used to identify the object. - - - - - - - - - - - -Dawson & Howes Standards Track [Page 38] - -RFC 2426 vCard MIME Directory Profile September 1998 - - -6. Acknowledgements - - The many valuable comments contributed by members of the IETF ASID - working group are gratefully acknowledged, as are the contributions - by Roland Alden, Stephen Bartlett, Alec Dun, Patrik Faltstrom, Daniel - Gurney, Bruce Johnston, Daniel Klaussen, Pete Miller, Keith Moore, - Vinod Seraphin, Michelle Watkins. Chris Newman was especially helpful - in navigating the intricacies of ABNF lore. - -7. Authors' Addresses - - BEGIN:vCard - VERSION:3.0 - FN:Frank Dawson - ORG:Lotus Development Corporation - ADR;TYPE=WORK,POSTAL,PARCEL:;;6544 Battleford Drive - ;Raleigh;NC;27613-3502;U.S.A. - TEL;TYPE=VOICE,MSG,WORK:+1-919-676-9515 - TEL;TYPE=FAX,WORK:+1-919-676-9564 - EMAIL;TYPE=INTERNET,PREF:Frank_Dawson@Lotus.com - EMAIL;TYPE=INTERNET:fdawson@earthlink.net - URL:http://home.earthlink.net/~fdawson - END:vCard - - - BEGIN:vCard - VERSION:3.0 - FN:Tim Howes - ORG:Netscape Communications Corp. - ADR;TYPE=WORK:;;501 E. Middlefield Rd.;Mountain View; - CA; 94043;U.S.A. - TEL;TYPE=VOICE,MSG,WORK:+1-415-937-3419 - TEL;TYPE=FAX,WORK:+1-415-528-4164 - EMAIL;TYPE=INTERNET:howes@netscape.com - END:vCard - -8. Security Considerations - - vCards can carry cryptographic keys or certificates, as described in - Section 3.7.2. - - Section 3.7.1 specifies a desired security classification policy for - a particular vCard. That policy is not enforced in any way. - - The vCard objects have no inherent authentication or privacy, but can - easily be carried by any security mechanism that transfers MIME - objects with authentication or privacy. In cases where threats of - "spoofed" vCard information is a concern, the vCard SHOULD BE - - - -Dawson & Howes Standards Track [Page 39] - -RFC 2426 vCard MIME Directory Profile September 1998 - - - transported using one of these secure mechanisms. - - The information in a vCard may become out of date. In cases where the - vitality of data is important to an originator of a vCard, the "URL" - type described in section 3.6.8 SHOULD BE specified. In addition, the - "REV" type described in section 3.6.4 can be specified to indicate - the last time that the vCard data was updated. - -9. References - - [ISO 8601] ISO 8601:1988 - Data elements and interchange formats - - Information interchange - Representation of dates and - times - The International Organization for - Standardization, June, 1988. - - [ISO 8601 TC] ISO 8601, Technical Corrigendum 1 - Data elements and - interchange formats - Information interchange - - Representation of dates and times - The International - Organization for Standardization, May, 1991. - - [ISO 9070] ISO 9070, Information Processing - SGML support - facilities - Registration Procedures for Public Text - Owner Identifiers, April, 1991. - - [CCITT E.163] Recommendation E.163 - Numbering Plan for The - International Telephone Service, CCITT Blue Book, - Fascicle II.2, pp. 128-134, November, 1988. - - [CCITT X.121] Recommendation X.121 - International Numbering Plan for - Public Data Networks, CCITT Blue Book, Fascicle VIII.3, - pp. 317-332, November, 1988. - - [CCITT X.520] Recommendation X.520 - The Directory - Selected - Attribute Types, November 1988. - - [CCITT X.521] Recommendation X.521 - The Directory - Selected Object - Classes, November 1988. - - [MIME-DIR] Howes, T., Smith, M., and F. Dawson, "A MIME Content- - Type for Directory Information", RFC 2425, September - 1998. - - [RFC 1738] Berners-Lee, T., Masinter, L., and M. McCahill, - "Uniform Resource Locators (URL)", RFC 1738, December - 1994. - - [RFC 1766] Alvestrand, H., "Tags for the Identification of - Languages", RFC 1766, March 1995. - - - -Dawson & Howes Standards Track [Page 40] - -RFC 2426 vCard MIME Directory Profile September 1998 - - - [RFC 1872] Levinson, E., "The MIME Multipart/Related Content- - type", RFC 1872, December 1995. - - [RFC 2045] Freed, N., and N. Borenstein, "Multipurpose Internet - Mail Extensions (MIME) - Part One: Format of Internet - Message Bodies", RFC 2045, November 1996. - - [RFC 2046] Freed, N., and N. Borenstein, "Multipurpose Internet - Mail Extensions (MIME) - Part Two: Media Types", RFC - 2046, November 1996. - - [RFC 2047] Moore, K., "Multipurpose Internet Mail Extensions - (MIME) - Part Three: Message Header Extensions for - Non-ASCII Text", RFC 2047, November 1996. - - [RFC 2048] Freed, N., Klensin, J., and J. Postel, "Multipurpose - Internet Mail Extensions (MIME) - Part Four: - Registration Procedures", RFC 2048, January 1997. - - [RFC 2119] Bradner, S., "Key words for use in RFCs to Indicate - Requirement Levels", BCP 14, RFC 2119, March 1997. - - [RFC 2234] Crocker, D., and P. Overell, "Augmented BNF for Syntax - Specifications: ABNF", RFC 2234, November 1997. - - [UNICODE] "The Unicode Standard - Version 2.0", The Unicode - Consortium, July 1996. - - [VCARD] Internet Mail Consortium, "vCard - The Electronic - Business Card Version 2.1", - http://www.imc.org/pdi/vcard-21.txt, September 18, - 1996. - - - - - - - - - - - - - - - - - - - -Dawson & Howes Standards Track [Page 41] - -RFC 2426 vCard MIME Directory Profile September 1998 - - -10. Full Copyright Statement - - Copyright (C) The Internet Society (1998). All Rights Reserved. - - This document and translations of it may be copied and furnished to - others, and derivative works that comment on or otherwise explain it - or assist in its implementation may be prepared, copied, published - and distributed, in whole or in part, without restriction of any - kind, provided that the above copyright notice and this paragraph are - included on all such copies and derivative works. However, this - document itself may not be modified in any way, such as by removing - the copyright notice or references to the Internet Society or other - Internet organizations, except as needed for the purpose of - developing Internet standards in which case the procedures for - copyrights defined in the Internet Standards process must be - followed, or as required to translate it into languages other than - English. - - The limited permissions granted above are perpetual and will not be - revoked by the Internet Society or its successors or assigns. - - This document and the information contained herein is provided on an - "AS IS" basis and THE INTERNET SOCIETY AND THE INTERNET ENGINEERING - TASK FORCE DISCLAIMS ALL WARRANTIES, EXPRESS OR IMPLIED, INCLUDING - BUT NOT LIMITED TO ANY WARRANTY THAT THE USE OF THE INFORMATION - HEREIN WILL NOT INFRINGE ANY RIGHTS OR ANY IMPLIED WARRANTIES OF - MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. - - - - - - - - - - - - - - - - - - - - - - - - -Dawson & Howes Standards Track [Page 42] - diff --git a/addressbook/backend/ebook/docs/rfc2739.txt b/addressbook/backend/ebook/docs/rfc2739.txt deleted file mode 100644 index 5c1dbbcf77..0000000000 --- a/addressbook/backend/ebook/docs/rfc2739.txt +++ /dev/null @@ -1,899 +0,0 @@ - - - - - - -Network Working Group T. Small -Request for Comments: 2739 XpertSite.Com -Category: Standards Track D. Hennessy - ISOCOR - F. Dawson - Lotus - January 2000 - - - Calendar Attributes for vCard and LDAP - - -Status of this Memo - - This document specifies an Internet standards track protocol for the - Internet community, and requests discussion and suggestions for - improvements. Please refer to the current edition of the "Internet - Official Protocol Standards" (STD 1) for the standardization state - and status of this protocol. Distribution of this memo is unlimited. - -Copyright Notice - - Copyright (C) The Internet Society (2000). All Rights Reserved. - -Abstract - - When scheduling a calendar entity, such as an event, it is a - prerequisite that an organizer has the calendar address of each - attendee that will be invited to the event. Additionally, access to - an attendee's current "busy time" provides an a priori indication of - whether the attendee will be free to participate in the event. - - In order to meet these challenges, a calendar user agent (CUA) needs - a mechanism to locate (URI) individual user's calendar and free/busy - time. - - This memo defines three mechanisms for obtaining a URI to a user's - calendar and free/busy time. These include: - - - Manual transfer of the information; - - - Personal data exchange using the vCard format; and - - - Directory lookup using the LDAP protocol. - - - - - - - -Small, et al. Standards Track [Page 1] - -RFC 2739 Locating a Calendar User January 2000 - - -Table of Contents - - 1 CALENDARING AND SCHEDULING URIS...................................3 - 1.1 FREE/BUSY URI (FBURL) .........................................3 - 1.2 CALENDAR ACCESS URI (CAPURI) ..................................4 - 1.3 CALENDAR URI (CALURI) .........................................4 - 1.4 DEFAULT URIS ..................................................4 - 2 DISTRIBUTION......................................................4 - 2.1 MANUAL TRANSFER ...............................................5 - 2.2 PERSONAL DATA EXCHANGE USING A VCARD ..........................5 - 2.3 VCARD SCHEMA EXTENSIONS .......................................5 - 2.3.1 FBURL Property IANA Registration ...........................6 - 2.3.2 CALADRURI Property IANA Registration .......................7 - 2.3.3 CAPURI Property IANA Registration ......................... 8 - 2.3.4 CALURI Property IANA Registration ......................... 8 - 2.4 DIRECTORY LOOKUP USING THE LDAP V3 PROTOCOL .................. 9 - 2.4.1 LDAP Schema Extensions .................................... 9 - 2.4.2 Notation ..................................................10 - 2.4.3 Object Definitions ........................................10 - 2.4.3.1 calEntry ..............................................10 - 2.4.4 Attribute Definitions .....................................10 - 2.4.4.1 calCalURI .............................................10 - 2.4.4.2 calFBURL ..............................................10 - 2.4.4.3 calCAPURI .............................................11 - 2.4.4.4 calCalAdrURI ..........................................11 - 2.4.4.5 calOtherCalURIs .......................................11 - 2.4.4.6 calOtherFBURLs ........................................11 - 2.4.4.7 calOtherCAPURIs .......................................12 - 2.4.4.8 calOtherCalAdrURIs ....................................12 - 3 IANA Considerations..............................................12 - 4 Security Considerations..........................................12 - 5 Acknowledgments..................................................13 - 6 Authors' Addresses...............................................13 - 7 Bibliography.....................................................15 - 8 Full Copyright Statement.........................................16 - - - - - - - - - - - - - - - - -Small, et al. Standards Track [Page 2] - -RFC 2739 Locating a Calendar User January 2000 - - -1 Calendaring and Scheduling URIs - - This memo defines four classes of URIs. URIs are more useful if it is - understood what the URIs point to. Here is a brief description: - -1.1 Free/Busy URI (FBURL) - - The free/busy URI is defined to be a transport independent location - where a client can obtain information about when a user is busy. At - the present time, this URI only points to busy time data. Future - revisions of this specification may provide for the extended - capability of publishing free time data. - - If a calendaring and scheduling client (i.e., CUA) were to retrieve - data from this location using FTP or HTTP, it would get back an - iCalendar object [4] containing one or more "VFREEBUSY" calendar - components. If a MIME transport is being used, the response will be - contained within a "text/calendar" MIME body part as specified in the - iCalendar specification [4]. For example: - - BEGIN:VCALENDAR - VERSION:2.0 - PRODID:-//hacksw/handcal//NONSGML v1.0//EN - METHOD:PUBLISH - BEGIN:VFREEBUSY - ATTENDEE:MAILTO:jane_doe@host1.com - DTSTART:19971013T050000Z - DTEND:19971124T050000Z - DTSTAMP:19970901T083000Z - FREEBUSY:19971015T133000Z/19971015T180000Z - FREEBUSY:19971015T190000Z/19971015T220000Z - FBURL:http://www.host.com/calendar/busy/jdoe.ifb - END:VFREEBUSY - END:VCALENDAR - - The amount of busy time data pointed to by the FBURL will generally - be pre-determined; for example one month of busy time data. As a - guideline, it is recommended that the previous six weeks of busy time - data be published at the location associated with the FBURL. If this - URI points to a file resource, it is recommended that the file - extension be "ifb" to distinguish it from an arbitrary iCalendar - object (e.g., with the "ics" file extension). - - - - - - - - - -Small, et al. Standards Track [Page 3] - -RFC 2739 Locating a Calendar User January 2000 - - -1.2 Calendar Access URI (CAPURI) - - The Calendar Access URI is defined to be a protocol independent - location from which a calendaring and scheduling client (i.e., CUA) - can communicate with a user's entire calendar. - - The semantics for using this URI as an access protocol locator are - yet to be defined by the IETF CALSCH Working Group. This will be - addressed in the "Calendar Access Protocol" specification. - -1.3 Calendar URI (CALURI) - - The Calendar URI is defined to be a protocol independent location - from which a calendaring and scheduling client (i.e. CUA) can - retrieve an entire copy of a user's calendar. Retrieving data from - this URI obtains a published "snapshot" of the user's calendar. - - HTTP URI -- If the URI is an HTTP URI, then the content returned with - a GET should be a "text/calendar" MIME body part containing one or - more iCalendar object. - - FTP URI -- If the URI is an FTP URI, then the resource pointed to - should be a file with an "ics" file extension containing one or more - iCalendar objects. - -1.4 Default URIs - - There are many cases where a user may have more than one calendar. In - these cases, a user may have multiple URIs, each URI pointing to a - calendar or free/busy data. - - To make the case of multiple calendars simpler for clients, the - concept of the "default" calendar is introduced. A "default" calendar - is one that the user has designated as the calendar that other users - should look at when accessing the user's calendar, or retrieving the - user's free/busy time. - - The default calendar may, in fact, include rolled-up information from - all the user's other calendars. The other calendars may only exist - for organizational purposes. - -2 Distribution - - These four URIs provide valuable pointers to calendaring and - scheduling data that other users need in order to know when to - schedule meetings, etc. There are several possibilities on how users - can communicate these URIs to other users. The following section - outlines how these URIs can be distributed to other users. - - - -Small, et al. Standards Track [Page 4] - -RFC 2739 Locating a Calendar User January 2000 - - -2.1 Manual Transfer - - The simplest way to obtain these URIs is for a user to communicate - the URIs using some out-of-band mechanism such as verbally, or in an - e-mail message, or by printing these URIs on a paper business card. - - When using this mechanism, the user obtains these URIs using an out- - of-band mechanism and then enters these URIs into their calendaring - software manually. - -2.2 Personal Data Exchange Using A vCard - - A more sophisticated way to obtain these URIs is for users to publish - vCards containing these URIs. The vCard object can be transferred - between one another. Since many e-mail clients allow a user to - automatically include a vCard with every message that the user sends, - this provides a simple, transparent way for a user to distribute - their calendaring and scheduling URIs. - - On the receiving end, an e-mail client that provides an integrated - vCard database can provide a way to lookup calendaring URIs for users - whose vCards are stored locally. - -2.3 vCard Schema Extensions - - Since the vCard [3] specification doesn't specify how to encode - calendaring URIs in a vCard, this section is provided as an extension - to vCard which specifies how to encode calendaring URIs within a - vCard. - - Inside a vCard object, four new properties are defined: "CALURI", - "CAPURI", "CALADRURI", and "FBURL", as defined above. - - Any vCard can have one or more of these properties, each representing - a calendar or free/busy time that is associated with the user. - - One of these properties can be designated as the "default" by adding - the "PREF" parameter. - - - - - - - - - - - - - -Small, et al. Standards Track [Page 5] - -RFC 2739 Locating a Calendar User January 2000 - - - Here is a simple example of a vCard containing a "FBURL" and a - "CALURI". - - BEGIN:VCARD - VERSION:3.0 - N:Dun;Alec - FN:Alec Dun - ORG:Microsoft Corporation - ADR;WORK;POSTAL;PARCEL:;;One Microsoft Way; - Redmond;WA;98052-6399;USA - TEL;WORK;MSG:+1-206-936-4544 - TEL;WORK;FAX:+1-206-936-7329 - EMAIL;INTERNET:user@host1.com - CALADRURI;PREF:mailto:user@host1.com - CALURI;PREF:http://cal.host1.com/user/cal.ics - FBURL;PREF:http://cal.host1.com/user/fb.ifb - CALURI:http://cal.company.com/projectA/pjtA.ics - FBURL:http://cal.company.com/projectA/pjtAfb.ifb - END:VCARD - -2.3.1 FBURL Property IANA Registration - - To: ietf-mime-directory@imc.org - - Subject: Registration of FBURL type for text/directory MIME type - vCard profile. - - Type name: FBURL - - Type purpose: To specify the URI for a user's busy time in a vCard - object. - - Type encoding: 8bit - - Type value: A single URI value. - - Type special notes: Where multiple FBURL properties are specified, - the default FBURL property is indicated with the PREF parameter. The - FTP or HTTP type of URI points to an iCalendar object associated with - a snapshot of the last six weeks of the user's busy time data. If the - iCalendar object is represented as a file or document, it's file type - should be "ifb". - - Intended usage: Refer to section 1.1. - - - - - - - -Small, et al. Standards Track [Page 6] - -RFC 2739 Locating a Calendar User January 2000 - - - Type examples: - - FBURL;PREF:http://www.host1.com/busy/janedoe - FBURL:FTP://ftp.host.com/busy/project-a.ifb - -2.3.2 CALADRURI Property IANA Registration - - To: ietf-mime-directory@imc.org - - Subject: Registration of CALADRURI type for application/directory - MIME type vCard profile. - - Type name: CALADRURI - - Type purpose: To specify the location to which an event request - should be sent for the user. - - Type encoding: 8bit - - Type value: A single URI value. - - Type special notes: Where multiple CALADRURI properties are - specified, the default CALADRURI property is indicated with the PREF - parameter. - - Intended usage: Refer to section 1.2. - - Type examples: - - CALADRURI;PREF:mailto:janedoe@host.com - - - - - - - - - - - - - - - - - - - - - -Small, et al. Standards Track [Page 7] - -RFC 2739 Locating a Calendar User January 2000 - - -2.3.3 CAPURI Property IANA Registration - - To: ietf-mime-directory@imc.org - - Subject: Registration of CAPURI type for application/directory MIME - type vCard profile. - - Type name: CAPURI - - Type purpose: To specify a protocol independent location from which a - calendaring and scheduling client (i.e., CUA) can communicate with a - user's entire calendar. - - Type encoding: 8bit - - Type value: A single URI value. - - Type special notes: Where multiple CAPURI properties are specified, - the default CAPURI property is indicated with the PREF parameter. - - Intended usage: Refer to section 1.3. - -2.3.4 CALURI Property IANA Registration - - To: ietf-mime-directory@imc.org - - Subject: Registration of CALURI type for text/directory MIME type - vCard profile. - - Type name: CALURI - - Type purpose: To specify the URI for a user's calendar in a vCard - object. - - Type encoding: 8bit - - Type value type: A single URI value. - - Type special notes: Where multiple CALURI properties are specified, - the default CALURI property is indicated with the PREF parameter. The - property should contain a URI pointing to an iCalendar object - associated with a snapshot of the user's calendar store. If the - iCalendar object is represented as a file or document, it's file type - should be "ics". - - Intended usage: Refer to section 1.4. - - - - - -Small, et al. Standards Track [Page 8] - -RFC 2739 Locating a Calendar User January 2000 - - - Type examples: - - CALURI;PREF:http://cal.host1.com/calA - CALURI:ftp://ftp.host1.com/calA.ics - -2.4 Directory Lookup Using The LDAP v3 Protocol - - Another way to obtain these URIs is to look them up in a directory - using the LDAP protocol [1]. - - If a user's URIs can be found using directory lookup (i.e., searching - for one of the LDAP schema extensions defined below), they should, in - general, be considered "more up-to-date" than URIs in any vCards that - are stored locally. - -2.4.1 LDAP Schema Extensions - - In order to encode the calendaring URIs in the directory, the - following are defined: - - - One object class: - - - calEntry - - - Eight attributes: - - - calCalURI - - - calFBURL - - - calCAPURI - - - calCalAdrURI - - - calOtherCalURIs - - - calOtherFBURLs - - - calOtherCAPURIs - - - calOtherCalAdrURIs - - The calCalURI contains the URI to a snapshot of the user's entire - default calendar. The calFBURL contains the URI to the user's default - busy time data. The calCAPURI represents contains a URI that can be - used to communicate with the user's calendar. The calCalAdrURI - contains a URI that points to the location to which event requests - should be sent for that user. - - - -Small, et al. Standards Track [Page 9] - -RFC 2739 Locating a Calendar User January 2000 - - - The calOtherCalURIs is a multi-valued property containing URIs to - snapshots of other calendars that the user may have. The - calOtherFBURLs is a multi-valued property containing URIs to other - free/busy data that the user may have. The calOtherCAPURIs attribute - is a multi-valued property containing URIs to other calendars that - the user may have. The calOtherCalAdrURIs attribute is a multi-valued - property containing URIs to other locations that a user may want - event requests sent to. - - There is no predetermined order to the values in either multi-valued - property. - -2.4.2 Notation - - The notation used in this memo is the same as that used in [2]. - -2.4.3 Object Definitions - -2.4.3.1 calEntry - - The Calendar Entry is a class derived from "TOP" [2], which contains - the four calendaring attributes. - - (1.2.840.113556.1.5.87 - NAME 'calEntry' - TOP - AUXILIARY - MAY (calCalURI calFBURL calOtherCalURIs calOtherFBURLs calCAPURI - calOtherCAPURLs) - ) - -2.4.4 Attribute Definitions - -2.4.4.1 calCalURI - - (1.2.840.113556.1.4.478 - NAME 'calCalURI' - EQUALITY caseIgnoreMatch - SUBSTRING caseIgnoreMatch - SYNTAX 'IA5String' - USAGE userApplications - ) - -2.4.4.2 calFBURL - - (1.2.840.113556.1.4.479 - NAME 'calFBURL' - EQUALITY caseIgnoreMatch - - - -Small, et al. Standards Track [Page 10] - -RFC 2739 Locating a Calendar User January 2000 - - - SUBSTRING caseIgnoreMatch - SYNTAX 'IA5String' - USAGE userApplications - ) - -2.4.4.3 calCAPURI - - (1.2.840.113556.1.4.480 - NAME 'calCAPURI' - EQUALITY caseIgnoreMatch - SUBSTRING caseIgnoreMatch - SYNTAX 'IA5String' - USAGE userApplications - ) - -2.4.4.4 calCalAdrURI - - (1.2.840.113556.1.4.481 - NAME 'calCalAdrURI' - EQUALITY caseIgnoreMatch - SUBSTRING caseIgnoreMatch - SYNTAX 'IA5String' - USAGE userApplications - ) - -2.4.4.5 calOtherCalURIs - - (1.2.840.113556.1.4.482 - NAME 'calOtherCalURIs' - EQUALITY caseIgnoreMatch - SUBSTRING caseIgnoreMatch - SYNTAX 'IA5String' - MULTI-VALUE - USAGE userApplications - ) - -2.4.4.6 calOtherFBURLs - - (1.2.840.113556.1.4.483 - NAME 'calOtherFBURLs' - EQUALITY caseIgnoreMatch - SUBSTRING caseIgnoreMatch - SYNTAX 'IA5String' - MULTI-VALUE - USAGE userApplications - ) - - - - - -Small, et al. Standards Track [Page 11] - -RFC 2739 Locating a Calendar User January 2000 - - -2.4.4.7 calOtherCAPURIs - - (1.2.840.113556.1.4.484 - NAME 'calOtherCAPURIs' - EQUALITY caseIgnoreMatch - SUBSTRING caseIgnoreMatch - SYNTAX 'IA5String' - MULTI-VALUE - USAGE userApplications - ) - -2.4.4.8 calOtherCalAdrURIs - - (1.2.840.113556.1.4.485 - NAME 'calOtherCalAdrURIs' - EQUALITY caseIgnoreMatch - SUBSTRING caseIgnoreMatch - SYNTAX 'IA5String' - MULTI-VALUE - USAGE userApplications - ) - -3 IANA Considerations - - This memo defines IANA registered extensions to the attributes - defined by LDAP [1] and vCard [3]. - - IANA registration proposals for vCard are to be emailed to the - registration agent for the "text/directory" MIME content-type, - <MAILTO: ietf-mime-directory@imc.org> using the format defined in - [3]. - -4 Security Considerations - - Standard vCard and LDAP security rules and support apply for the - extensions described in this document, and there are no special - security issues for these extensions. - - Please note, though, that LDAP servers may permit anonymous clients - to refresh entries which they did not create. Servers are also - permitted to control a refresh access to an entry by requiring - clients to bind before issuing a RefreshRequest. This will have - implications on the server performance and scalability. - - Please also note, though, that vCard objects may have been created by - an entity other than that represented by the vCard. Recipients should - be certain of the source that generated the vCard. - - - - -Small, et al. Standards Track [Page 12] - -RFC 2739 Locating a Calendar User January 2000 - - - Also, care should be taken in making use of information obtained from - directory servers that has been supplied by client, as it may now be - out of date. In many networks, for example, IP addresses are - automatically assigned when a host connects to the network, and may - be reassigned if that host later disconnects. An IP address obtained - from the directory may no longer be assigned to the host that placed - the address in the directory. This issue is not specific to LDAP or - dynamic directories. - -5 Acknowledgments - - The authors wish to acknowledge the work of Alec Dun, who acted as an - author for the early drafts of this memo. In addition, this document - received input from the various participants in the IETF CALSCH - Working Group discussions. - -6 Authors' Addresses - - The following address information is provided in a vCard v3.0 [3], - Electronic Business Card, format. - - BEGIN:VCARD - VERSION:3.0 - N:Small;Tony - FN:Tony Small - ORG:XpertSite.Com - ADR;TYPE=WORK,POSTAL,PARCEL:;;4700 42nd Ave. SW, Suite 440; - Seattle;WA;98116;USA - TEL;TYPE=WORK,MSG:+1-206-937-9972 - TEL;TYPE=WORK,FAX:+1-206-936-7329 - EMAIL;TYPE=INTERNET:tony@xpertsite.com - CALADRURI:MAILTO:tony@xpertsite.com - END:VCARD - - BEGIN:VCARD - VERSION:3.0 - N:Hennessy;Denis - FN:Denis Hennessy - ORG:ISOCOR - ADR;TYPE=WORK,POSTAL,PARCEL:;;42-47 Lower Mount St; - Dublin 2;Ireland - TEL;TYPE=WORK,MSG:+353-1-676-0366 - TEL;TYPE=WORK,FAX:+353-1-676-0856 - EMAIL;TYPE=INTERNET:denis.hennessy@isocor.com - CALADRURI:MAILTO:denis.hennessy@isocor.com - END:VCARD - - - - - -Small, et al. Standards Track [Page 13] - -RFC 2739 Locating a Calendar User January 2000 - - - BEGIN:VCARD - VERSION:3.0 - N:Dawson;Frank - FN:Frank Dawson - ORG:Lotus Development Corporation - ADR;TYPE=WORK,POSTAL,PARCEL:;;6544 Battleford Drive; - Raleigh;NC;27613-3502;USA - TEL;TYPE=WORK,PREF:+1-617-693-8728 - TEL;TYPE=WORK,MSG:+1-919-676-9515 - TEL;TYPE=FAX:+1-617-693-8728 - EMAIL;TYPE=INTERNET,PREF:Frank_Dawson@Lotus.com - EMAIL;TYPE=INTERNET:fdawson@earthlink.net - CALADRURI;TYPE=PREF:MAILTO:Frank_Dawson@Lotus.com - CALADRURI:MAILTO:fdawson@earthlink.net - URL:http://home.earthlink.net/~fdawson - END:VCARD - - This memo is a result of the work of the Internet Engineering Task - Force Calendaring and scheduling Working Group. The chairman of that - working group is: - - BEGIN:VCARD - VERSION:3.0 - N:Egen;Pat - FN:Pat Egen - ORG:Engan Consulting - ADR;TYPE=WORK:;;803 Creek Overlook;Chattanooga;TN;37415;USA - TEL;TYPE=WORK,VOICE:423.875.2652 - TEL;TYPE=WORK,FAX:423.875.2017 - EMAIL:pregen@egenconsulting.com - URL:http://www.egenconsulting.com - CALADRURI:MAILTO:pregen@egenconsulting.com - END:VCARD - - - - - - - - - - - - - - - - - - -Small, et al. Standards Track [Page 14] - -RFC 2739 Locating a Calendar User January 2000 - - -7 Bibliography - - [1] Wahl, M., Howes, T. and S. Kille, "Lightweight Directory Access - Protocol (v3)", RFC 2251, December 1997. - - [2] Wahl, M., Coulbeck, A., Howes, T. and S. Kille, "Lightweight - Directory Access Protocol (v3): Attribute Syntax Definitions", - RFC 2252, December 1997. - - [3] Dawson, F. and T. Howes, "vCard MIME Directory Profile", RFC - 2426, September 1998. - - [4] Dawson, F. and D. Stenerson, "Internet Calendaring and Scheduling - Core Object Specification (iCalendar)", RFC 2445, November 1997. - - [5] Dawson, F. and S. Mansour, "iCalendar Message-Based - Interopability Protocal (iMIP)", RFC 2447, November 1997. - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -Small, et al. Standards Track [Page 15] - -RFC 2739 Locating a Calendar User January 2000 - - -8 Full Copyright Statement - - Copyright (C) The Internet Society (2000). All Rights Reserved. - - This document and translations of it may be copied and furnished to - others, and derivative works that comment on or otherwise explain it - or assist in its implementation may be prepared, copied, published - and distributed, in whole or in part, without restriction of any - kind, provided that the above copyright notice and this paragraph are - included on all such copies and derivative works. However, this - document itself may not be modified in any way, such as by removing - the copyright notice or references to the Internet Society or other - Internet organizations, except as needed for the purpose of - developing Internet standards in which case the procedures for - copyrights defined in the Internet Standards process must be - followed, or as required to translate it into languages other than - English. - - The limited permissions granted above are perpetual and will not be - revoked by the Internet Society or its successors or assigns. - - This document and the information contained herein is provided on an - "AS IS" basis and THE INTERNET SOCIETY AND THE INTERNET ENGINEERING - TASK FORCE DISCLAIMS ALL WARRANTIES, EXPRESS OR IMPLIED, INCLUDING - BUT NOT LIMITED TO ANY WARRANTY THAT THE USE OF THE INFORMATION - HEREIN WILL NOT INFRINGE ANY RIGHTS OR ANY IMPLIED WARRANTIES OF - MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. - -Acknowledgement - - Funding for the RFC Editor function is currently provided by the - Internet Society. - - - - - - - - - - - - - - - - - - - -Small, et al. Standards Track [Page 16] - diff --git a/addressbook/backend/ebook/docs/vcard-21.txt b/addressbook/backend/ebook/docs/vcard-21.txt deleted file mode 100644 index 64716ebf15..0000000000 --- a/addressbook/backend/ebook/docs/vcard-21.txt +++ /dev/null @@ -1,1544 +0,0 @@ -vCard -The Electronic Business Card -Version 2.1 - -A versit Consortium Specification -September 18, 1996 - - -Copyrights -© 1996, International Business Machines Corp., Lucent Technologies, Inc., and Siemens. All rights reserved. -Permission is granted to copy and distribute this publication provided that it is reproduced in its entirety without modification and includes the above copyright notice and this permission notice. -No licenses, express or implied, are granted with respect to any of the technology described in this publication. International Business Machines Corp., Lucent Technologies, Inc., and Siemens retain all their intellectual property rights in the technology described in this publication. -Even though International Business Machines Corp., Lucent Technologies, Inc., and Siemens have reviewed this specification, INTERNATIONAL BUSINESS MACHINES CORP., LUCENT TECHNOLOGIES, INC, AND SIEMENS, MAKE NO WARRANTY OR REPRESENTATION, EITHER EXPRESS OR IMPLIED, WITH RESPECT TO THIS PUBLICATION, ITS QUALITY OR ACCURACY, NONINFRINGEMENT, MERCHANTABILITY, OR FITNESS FOR A PARTICULAR PURPOSE. AS A RESULT, THIS SPECIFICATION IS DELIVERED "AS IS" AND THE READER ASSUMES THE ENTIRE RISK AS TO ITS QUALITY, ACCURACY OR SUITABILITY FOR ANY PARTICULAR PURPOSE.. -IN NO EVENT WILL INTERNATIONAL BUSINESS MACHINES CORP., LUCENT TECHNOLOGIES, INC, AND SIEMENS, BE LIABLE FOR DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES RESULTING FROM ANY DEFECT OR INACCURACY IN THIS PUBLICATION, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. -This publication is provided with RESTRICTED RIGHTS. Use, duplication, or disclosure by the Government are subject to restrictions set forth in DFARS 252.227-7013 or 48 CFR 52.227-19, as applicable. - - -Trademarks -versit, the versit logo, versitcard, vCard, and vCalendar are trademarks of Apple Computer, Inc., AT&T Corp., International Business Machines Corp., and Siemens. -Apple, is a trademarks of Apple Computer, Inc. registered in the U.S. and other countries. -AT&T and ATTMail are registered trademarks of AT&T Corp. -IBM, IBM Mail, and OS/2 are registered trademarks of International Business Machines Corporation. -America Online is a registered trademark of America Online, Inc. -CompuServe, CompuServe Information Services are registered trademarks of Compuserve Incorporated. -MCIMail is a registered trademark of MCI Communications Corporation. -Microsoft is a registered trademark, and Microsoft Windows is a trademark of Microsoft Corporation. -Prodigy is a registered trademark of Prodigy Services Company. -Unicode is a registered trademark of Unicode, Inc. - - -Contributors -Roland Alden -Greg Ames, Ames & Associates -Masanari Arai, Puma Technologies -Stephen W. Bartlett -Donal Carroll -Liang-Jye Chang, Starfish Software -Frank Dawson, IBM Corporation -Ken Dobson, IntelliLink Inc. -Scott Feldstein, Nimble Software, Inc. -Anik Ganguly, OnTime/Division of FTP Software. -Beijing Goo, Microsoft -Arvind K. Goyal, Lotus Development Corporation -Gary Hand, IBM Corporation -Tim Howes, Netscape Communications Corporation -Mark Joseph, Attachmate Corporation -Kerry Kelly, Now Software, Inc. -Phac Letuan, Apple Computer, Inc. -Pat Megowan, Counterpoint Sytems Foundry Inc. -Tohri Mori, IBM Japan/Salutation Consortium -Ravi Pandya, NetManage, Inc. -Geoff Ralston, Four11 Corporation -Steven Rummel, Lucent Technologies -Michael Santullo, Four11 Corporation -Vinod Seraphin, Lotus Development Corporation -Dexter Seely, Corex Technologies, Inc. -Vlad Shmunis, Ring Zero Systems Inc. -Dean Stevens, Now Software, Inc. -Michelle Watkins, Netscape Communications Corporation -Horst Widlewski, Siemens - - -Reference Information -The cited references contain provisions which, through reference in this specification, constitute provisions of this specification. At the time of publication, the indicated versions in the following references were valid. Parties to agreements based on this specification are encouraged to research the possibility of revised standards. -* ANSI X3.4-1977, Code for Information Interchange, American National Standards Institute, 1977. -* CCITT (ITU) Recommendation E.163, Numbering Plan for The International Telephone Service, CCITT Blue Book, Fascicle II.2, pp. 128-134, November, 1988. -* CCITT (ITU) Recommendation G.721, 32 kbit/s Adaptive Differential Pulse Code Modulation (ADPCM), CCITT Red Book, Fascicle III.4, November, 1988. -* CCITT (ITU) Recommendation X.121, International Numbering Plan for Public Data Networks, CCITT Blue Book, Fascicle VIII.3, pp. 317-332, November, 1988. -* CCITT (ITU) Recommendations X.500-X.521, Data Communication Networks: Directory, CCITT Blue Book, Fascicle VIII.8, November, 1988. -* CCITT Recommendation X.520, The Directory-Selected Attribute Types, 1988. -* CCITT Recommendation X.521, The Directory-Selected Object Classes, 1988. -* IETF RFC 1738, Universal Resource Locator, December 1994. -* IETF Network Working Group RFC 1766, Tags for the Identification of Languages, March 1995. -* IETF Network Working Group Draft, A MIME Content-Type for Directory Information, January 1996. Available from the University of Michigan, 535 W. William St., Ann Arbor, MI 48103-4943, FTP://ds.internic.net/Internet-Drafts/draft-ietf-asid-mime-direct-01.txt. -* IETF Network Working Group Draft, An Application/Directory MIME Content-Type Electronic Business Card Profile, May 1996. Available FTP://ds.internic.net/Internet-Drafts/draft-ietf-asid-mime-vcard-00.txt. -* IETF Network Working Group Draft, UTF-8, A Transformation Format of UNICODE and ISO 10646, July 1996. Available from FTP://ds.internic.net/Internet-Drafts/draft-yergeau-utf8-01.txt. -* ISO 639, Code for The Representation of names of languages, International Organization for Standardization, April, 1988. -* ISO 3166, Codes for The Representation of names of countries, International Organization for Standardization, December, 1993. -* ISO 8601, Data elements and interchange formats-Information interchange-Representation of dates and times, International Organization for Standardization, June, 1988. -* ISO 8601, Technical Corrigendum 1, Data elements and interchange formats-Information interchange-Representation of dates and times, International Organization for Standardization, May, 1991. -* ISO 8859-1, Information Processing-8-Bit single-byte coded graphic character sets-Part 1: Latin Alphabet No. 1, International Organization for Standardization, February, 1987. -* ISO 9070, Information Processing-SGML support facilities-Registration Procedures for Public Text Owner Identifiers, 1990-02-01.[DS1] -ï ISO/IEC 9070, Information TechnologyóSGML Support FacilitiesóRegistration Procedures for Public Text Owner Identifiers, Second Edition, International Organization for Standardization, April, 1991. -ï ISO/IEC 11180, Postal addressing, International Organization for Standardization, 1993. -ï Appleís Representation of a Canonical Static DeviceID in The Telephony Suite, version 1.0, Apple Computer, Inc., 1993. -* Microsoft TAPI in Microsoft Windows 3.1 Telephony Programmers' Guide, version 1.0, Microsoft Corporation, 1993. -* RFC1521, MIME (Multipurpose Internet Mail Extensions) Part One: Mechanisms for Specifying and Describing the Format of Internet Message Bodies, Network Working Group, September, 1993. -* The Unicode Standard, Version 1.1: Version 1.0, Volume 1 (ISBN 0-201-56788-1), version 1.0, volume 2 (ISBN 0-20-60845-6) and Unicode Technical Report #4, The Unicode Standard, version 1.1, The Unicode Consortium, October, 1991. Both references to be published by Addison-Wesley. - - -versit Update -versit is a multivendor development initiative of the communication and computer industries, founded by Apple, AT&T, IBM and Siemens. The versit parties believe that great potential exists in improving the nature of communications in the business world-permitting companies to better manage their quality, productivity, customer satisfaction and cost of operations, while expanding the market opportunities for a variety of product and service vendors. versit parties will jointly define and support open specifications that facilitate and promote the interoperability of advanced personal information and communication devices, networks and services. -The versit vision is to enable diverse communication and computing devices, applications and services from competing vendors to interoperate in all environments. Through developing a series of specifications for interoperability among diverse communications and computing devices, applications, networks and services, versit 's vision will become a reality. -versit 's primary development areas are in: -* Personal Data Interchange (PDI) -* Computer Telephone Integration (CTI) -* Conferencing and Messaging (C&M) -* Wired and Wireless connectivity -versit specifications are directed at both the decision makers and the implementation teams of: -* Equipment Manufacturers -* Independent Software Vendors -* Information Service Providers -* Online Service Providers -* Software Houses -* Users -versit specifications are made available to any interested party. In turn, versit encourages the support of our goals by soliciting feedback on versit specifications. - -All comments relating to versit or the material within this specification should be submitted to: -versit -(800) 803-6240 -+1 (201) 327-2803 (Outside USA) -pdi@versit.com -http://www.versit.com/pdi - - -Contents -Section 1 : Introduction -1.1 Overview -1.2 Scope -1.3 Contents -1.4 Definitions and Abbreviations -Section 2 : vCard Specificiation -2.1 Encoding Characteristics -2.1.1 vCard Object -2.1.2 Property -2.1.3 Delimiters -2.1.4 Grouping -2.1.4.1 vCard Grouping -2.1.4.2 Property Grouping -2.1.5 Encodings -2.1.6 Character Set -2.1.7 Language -2.1.8 Value Location -2.1.9 Binary Values -2.2 Identification Properties -2.2.1 Formatted Name -2.2.2 Name -2.2.3 Photograph -2.2.3.1 Photo Format Type -2.2.4 Birthdate -2.3 Delivery Addressing Properties -2.3.1 Delivery Address -2.3.1.1 Delivery Address Type -2.3.2 Delivery Label -2.3.2.1 Delivery Label Type -2.4 Telecommunications Addressing Properties -2.4.1 Telephone Number -2.4.1.1 Telephone Type -2.4.2 Electronic Mail -2.4.2.1 Electronic Mail Type -2.4.3 Mailer -2.4.4 Geographical Properties -2.4.5 Time Zone -2.4.6 Geographic Position -2.5 Organizational Properties -2.5.1 Title -2.5.2 Business Category -2.5.3 Logo -2.5.3.1 Logo Format Type -2.5.4 Agent -2.5.5 Organization Name and Organizational Unit -2.6 Explanatory Properties -2.6.1 Comment -2.6.2 Last Revision -2.6.3 Sound -2.6.3.1 Sound Digital Audio Type -2.6.4 Uniform Resource Locator -2.6.5 Unique Identifier -2.6.6 Version -2.7 Security Properties -2.7.1 Public Key -2.7.2 Key Type -2.8 Miscellaneous Properties -2.8.1 Extensions -2.9 Formal Definition -Section 3 : Internet Recommendations -3.1 Recommended Practice with SMTP/MIME -3.1.1 Text/Plain Content Type -3.1.2 Text/X-vCard Content Type -3.1.3 Application/Directory Content Type -3.2 Recommended Practice with HTTP/HTML -3.2.1 Form Element Usage -3.2.2 Mapping To INPUT Element Attribute Names -3.2.3 Example HTML Code -Section 4 : UI Support Recommendations -4.1 File System -4.2 Clipboard -4.3 Drag/Drop -Section 5 : Conformance - - - -Section 1 : Introduction -[DS2] -Personal Data Interchange (PDI) occurs every time two or more individuals communicate, in either a business or personal context, face-to-face, or across space and time. Such interchanges frequently include the exchange of informal information, such as business cards, telephone numbers, addresses, dates and times of appointments, etc. Augmenting PDI with electronics and telecommunications can help ensure that information is quickly and reliably communicated, stored, organized and easily located when needed. -Personal information, by nature, is complex and diverse. Currently, proprietary standards exist to structure some types of PDI information, but no single, open specification comprehensively addresses the needs of collecting and communicating PDI information across many common communication channels such as telephones, voice-mail, e-mail, and face-to-face meetings. versit is developing a comprehensive family of PDI technologies based on open specifications and interoperability agreements to help meet this technology need. -Overview -This specification defines a format for an electronic business card, or vCard. The format is suitable as an interchange format between applications or systems. The format is defined independent of the particular method used to transport it. The transport for this exchange might be a file system, point-to-point asynchronous communication, wired-network transport, or some form of unwired transport. -A vCard is a data stream consisting of one or more vCard objects. The individual vCard definitions can be identified and parsed within the datastream. The vCard data stream may exist as a persistent form in a file system, document management system, network connection between two network endpoints, or in any other digital transport that has an abstraction of a stream of bytes. -Conceptually, a vCard Writer creates vCard data streams and a vCard Reader interprets vCard data streams. The vCard Reader and Writer may be implemented as a single application or as separate applications. It is not the intent of this specification to define the implementation of these processes beyond some fundamental capabilities related to the format of the vCard data stream and a common set of conformance requirements . -This specification provides for a clear-text encoding that is intended to be based on the syntax used by the MIME specification (RFC 1521). -The encoding of this specification can be used in environments which are constrained to 7-bit transfer encodings, short line lengths, and low bandwidth. In addition, the encoding is simple in order to facilitate the implementation of reader and writer applications on small platforms, such as Personal Digital Assistants (PDA), cellular telephones, or alphanumeric pagers. -Scope -The vCard is intended to be used for exchanging information about people and resources. In today's business environment, this information is typically exchanged on business cards. It is appropriate, then that this specification define this information in terms of a paradigm based on an electronic business card object. -The ultimate destination for this information is often a collection of business cards, Rolodex® file, or electronic contact manager. Prior to the introduction of the vCard specification, users of such applications typically had to re-key the original information, often transcribing it from paper business cards. With the advent of the vCard specification, this information can be exchanged in an automated fashion. -The basis for the data types supported by this specification have their origin in openly defined, international standards and in additional capabilities based on enhancements suggested by the demonstration of the exchange of prototypical vCards using the Internet based World-Wide-Web, Infra-red data transport, and simultaneous voice and data (SVD) modems. -The "person" object defined by the CCITT X.500 Series Recommendation for Directory Services was the primary reference for the properties that are defined by this specification. Every attempt was made to make it possible to map the X.520/X.521 attributes and objects into and out of an instance of a vCard. The vCard specification has extended the capabilities that have been defined within the CCITT X.500 Series Recommendation to allow the exchange of additional information often recorded on business cards and electronic contact managers. For example, this specification provides support for exchanging graphic images representing company logos, photographs of individuals, geo-positioning information, and other extensions to properties defined by the X.500 Recommendation. -The specification of all date and time values are defined in terms of the ISO 8601 standard for representation of dates and times. ISO 8601 supersedes all other international standards defined at the time this specification was drafted. -The paradigm of an electronic business card is related to the concepts of an entry in a LAN/WAN directory or an electronic mail address book or distribution list. However, the requirements of the electronic business card go beyond the definitions of a "person" object found in either the CCITT X.500 Series Recommendation, network directory services, or electronic mail address book products. The vCard specification is needed to address the requirements for an interchange format for the "person" personal data type or object. -Personal data applications such as Personal Information Managers (PIM) often provide an import/export capability using Comma Separated Value (CSV) or Tab Delimited Files (TDF) formats. However, these solutions do not preserve the intent of the originating application. When a CSV and TDF format is used by a PIM, the meta-data or semantics of the originating object are only apparent to a similar version of the originating application. Exchange of data between such applications is another important application of an industry-standard specification for an electronic business card interchange format, such as the vCard specification. -Contents -This specification is separated into eight sections: -* "Section 1 : Introduction" introduces PDI and the vCard specification with an overview, scope statement and section on definitions and abbreviations. -* "Section 2 : vCard Specification" defines the semantics and syntax for the vCard. -* "Section 3 : Internet Recommendations" specifies a set of guidelines to facilitate the exchange of vCard objects over Internet protocols such as HTTP using HTML and SMTP using MIME. -* "Section 4 : UI Support Recommendations" specifies a set of guidelines to facilitate the exchange of vCard objects at the desktop user interface using the file system, clipboard and drag/drop capabilities of the operating system. -* "Section 5 : Conformance" defines minimum conformance requirements to consider while developing support for this vCard specification. -Definitions and Abbreviations -Definitions and abbreviations used within this specification follow. -Electronic Business Card: Also known as vCard. -FPI: Formal Public Identifier. A string expression that represents a public identifier for an object. FPI syntax is defined by ISO 9070. -GUID: Globally Unique IDentifier -Internet: A WAN connecting thousands of disparate networks in industry, education, government, and research. The Internet uses TCP/IP as the standard for transmitting information. -ISO: Organization for International Standardization; a worldwide federation of national standards bodies (ISO Member bodies). -MIME: Multipurpose Internet Mail Extensions, as defined in RFC1521. -PDA: Personal Digital Assistant computing device -PDI: Personal Data Interchange, a collaborative application area which involves the communication of data between people who have a business or personal relationship, but do not necessarily share a common computing infrastructure. -PIM: Personal Information Manager -RFC#### documents: Internet "Request For Comment" documents (i.e., RFC822, RFC1521, etc.). -URL: Uniform Resource Locator; a string expression that can represent any resource on the Internet or local system. RFC 1738 defines the syntax for an URL. -UTC: Universal Time Coordinated; also known as UCT, for Universal Coordinated Time. -vCard: The generic term for an electronic, virtual information card that can be transferred between computers, PDAs, or other electronic devices through telephone lines, or e-mail networks, or infrared links. How, when, why, and where vCard are used depends on the applications developed utilizing a vCard. -versitcard: a vCard. -WAN: Wide-Area Network - - -Section 2 : vCard Specificiation -[DS3] -This section defines the semantics and syntax for the vCard. -A vCard is a collection of one or more properties. A property is a uniquely named value. A set of properties can be grouped within a vCard. For example, the properties for a telephone number and comment can be grouped in order to preserve the coupling of the annotation with the telephone number. In addition to property groupings, a vC. versit is developing a comprehensive family of PDI technologies based on open specifications and interoperability agreements to help meet this technology need. -Overview -This specification defines a format for an electronic business card, or vCard. The format is suitable as an interchange format between applications or systems. The format is defined independent of the particular method used to transport it. The transport for this exchange might be a file system, point-to-point asynchronous communication, wired-network transport, or some form of unwired transport. -A vCard is a data stream consisting of one or more vCard objects. The individual vCard definitions can be identified and parsed within the datastream. The vCard data stream may exist as a persistent form in a file system, document management system, network connection between two network endpoints, or in any other digital transport that has an abstraction of a stream of bytes. -Conceptually, a vCard Writer creates vCard data streams and a vCard Reader interprets vCard data streams. The vCard Reader and Writer may be implemented as a single application or as separate applications. It is not the intent of this specification to define the implementation of these processes beyond some fundamental capabilities related to the format of the vCard data stream and a common set of conformance requirements . -This specification provides for a clear-text encoding that is intended to be based on the syntax used by the MIME specification (RFC 1521). -The encoding of this specification can be used in environments which are constrained to 7-bit transfer encodings, short line lengths, and low bandwidth. In addition, the encoding is simple in order to facilitate the implementation of reader and writer applications on small platforms, such as Personal Digital Assistants (PDA), cellular telephones, or alphanumeric pagers. -Scope -The vCard is intended to be used for exchanging information about people and resources. In today's business environment, this information is typically exchanged on business cards. It is appropriate, then that this specification define this information in terms of a paradigm based on an electronic business card object. -The ultimate destination for this information is often a collection of business cards, Rolodex® file, or electronic contact manager. Prior to the introduction of the vCard specification, users of such applications typically had to re-key the original information, often transcribing it from paper business cards. With the advent of the vCard specification, this information can be exchanged in an automated fashion. -The basis for the data types supported by this specification have their origin in openly defined, international standards and in additional capabilities based on enhancements suggested by the demonstration of the exchange of prototypical vCards using the Internet based World-Wide-Web, Infra-red data transport, and simultaneous voice and data (SVD) modems. -The "person" object defined by the CCITT X.500 Series Recommendation for Directory Services was the primary reference for the properties that are defined by this specification. Every attempt was made to make it possible to map the X.520/X.521 attributes and objects into and out of an instance of a vCard. The vCard specification has extended the capabilities that have been defined within the CCITT X.500 Series Recommendation to allow the exchange of additional information often recorded on business cards and electronic contact managers. For example, this specification provides support for exchanging graphic images representing company logos, photographs of individuals, geo-positioning information, and other extensions to properties defined by the X.500 Recommendation. -The specification of all date and time values are defined in terms of the ISO 8601 standard for representation of dates and times. ISO 8601 supersedes all other international standards defined at the time this specification was drafted. -The paradigm of an electronic business card is related to the concepts of aQuoted-Printable lines of text must also be limited to less than 76 characters. The 76 characters does not include the CRLF (RFC 822) line break sequence. For example a multiple line LABEL property value of: -123 Winding Way -Any Town, CA 12345 -USA -Would be represented in a Quoted-Printable encoding as: -LABEL;ENCODING=QUOTED-PRINTABLE:123 Winding Way=0D=0A= - Any Town, CA 12345=0D=0A= - USA -Property parameter substrings are delimited by a field delimiter, specified by the Semi-colon character (ASCII decimal 59). A Semi-colon in a property parameter value must be escaped with a Backslash character (ASCII 92). -Compound property values are property values that also make use of the Semi-colon, field delimiter to separate positional components of the value. For example, the Name property is made up of the Family Name, Given Name, etc. components. A Semi-colon in a component of a compound property value must be escaped with a Backslash character (ASCII 92). -Grouping -There are two forms of grouping or collections supported within the vCard. A collection of vCard objects can be grouped and a collection of properties within an individual vCard can be grouped. -vCard Grouping -The vCard data stream can consist of multiple vCard objects. The vCard data stream can, sequentially, contain one or more vCard objects., In addition, the vCard data stream can contain a property whose value is a nested vCard. In both of these cases, each vCard object will be delimited by the vCard Delimiters. The vCard Reader conforming to this specification must be able to parse and process any of these combinations of vCard Groupings. The support for vCard Grouping is optional for a vCard Writer conforming to this specification. -Property Grouping -A Property Grouping is the definition of a method for specifying a collection of related properties within a vCard object. There is no requirement on a vCard reader that it preserve the property group name. However, the vCard reader is required to preserve the grouping of the properties. -The Property Grouping is identified by a character string prefix to the property name; separated by the Period character (ASCII decimal 46). -The grouping of a comment property with a telephone property is shown in the following example: -A.TEL;HOME:+1-213-555-1234 -A.NOTE:This is my vacation home. -The vCard Reader conforming to this specification must be able to parse and process the property grouping. The support for Property Grouping is optional for a vCard Writer conforming to this specification. -Encodings -The default encoding for the vCard object is 7-Bit. The default encoding can be overridden for an individual property value by using the "ENCODING" property parameter. This parameter value can be either "BASE64", "QUOTED-PRINTABLE", or "8BIT". This parameter may be used on any property. -Some transports (e.g., MIME based electronic mail) may also provide an encoding property at the transport wrapper level. This property can be used in these cases for transporting a vCard data stream that has been defined using a default encoding other than 7-bit (e.g., 8-bit). -Character Set -The default character set is ASCII. The default character set can be overridden for an individual property value by using the "CHARSET" property parameter. This property parameter may be used on any property. However, the use of this parameter on some properties may not make sense. -Any character set registered with the Internet Assigned Numbers Authority (IANA) can be specified by this property parameter. For example, ISO 8859-8 or the Latin/Hebrew character set is specified by: -ADR;CHARSET=ISO-8859-8:... -Some transports (e.g., MIME based electronic mail) may also provide a character set property at the transport wrapper level. This property can be used in these cases for transporting a vCard data stream that has been defined using a default character set other than ASCII (e.g., UTF-8). -Language -The default language is "en-US" (US English). The default language can be overridden for an individual property value by using the "LANGUAGE" property parameter. The values for this property are a string consistent with RFC 1766, Tags for the Identification of Languages. This property parameter may be used on any property. However, the use of this parameter on some properties, such as PHOTO, LOGO, SOUND, TEL, may not make sense. Canadian French would be specified by this parameter by the following: -ADR;LANGUAGE=fr-CA:... -Value Location -The default location of the property value is inline with the property. However, for some properties, such as those that specify multimedia values, it is efficient to organize the property value as a separate entity (e.g., a file out on the network). The property parameter "VALUE" can be specified to override the "INLINE" location of the property value. In the case of the vCard being transported within a MIME email message, the property value can be specified as being located in a separate MIME entity with the "Content-ID" value, or "CID" for short. In this case, the property value is the Content-ID for the MIME entity containing the property value. In addition, the property value can be specified as being located out on the network within some Internet resource with the "URL" value. In this case, the property value is the Uniform Resource Locator for the Internet resource containing the property value. This property parameter may be used on any property. However, the use of this parameter on some properties may not make sense; for example the Version, Time Zone, Comment, Unique Identifier, properties . The following specifies a value not located inline with the vCard but out in the Internet: -PHOTO;VALUE=URL;TYPE=GIF:http://www.abc.com/dir_photos/my_photo.gif -SOUND;VALUE=CONTENT-ID:<jsmith.part3.960817T083000.xyzMail@host1.com -Binary Values -The vCard format supports inclusion of binary information, such as computer graphic images, digital audio, or video graphic images. The binary information may either be referenced with a Uniform Reference Locator (URL) or placed inline in the vCard as the value of a property. Inline binary information is included as a property value after being encoded into clear-text with a Base 64 (default) or Quoted-Printable encoding -Identification Properties -These property types are concerned with information associated with the identification and naming of the individual or resource associated with the vCard object. -Formatted Name -This property specifies the formatted name string associated with the vCard object. This is the way that the name is to be displayed. It can contain desired honorific prefixes, suffixes, titles, etc. For example, "Mr. John Q. Public, Jr.", Dr. Ann Tyler, or Hon. Judge Blackwell. This property is based on the semantics of the X.520 Common Name attribute. -This property is identified by the property name FN. The following is an example of the Formatted Name property: -FN:Mr. John Q. Public, Esq. -Support for this property is optional for vCard Writers conforming to this specification. -Name -This property specifies a structured representation of the name of the person, place or thing associated with the vCard object. -This property is identified by the property name N. This property is defined to encapsulate the individual components of an object's name. The property value consists of the components of the name specified as positional fields separated by the Field Delimiter character (ASCII decimal 59). The property value is a concatenation of the Family Name (first field), Given Name (second field), Additional Names (third field), Name Prefix (fourth field), and Name Suffix (fifth field) strings. The following is an example of the Name property for a person: -N:Public;John;Quinlan;Mr.;Esq. -The following is an example of the Name property for a resource or place: -N:Veni, Vidi, Vici;The Restaurant. -Support for this property is mandatory for vCard Writers conforming to this specification. All vCard data streams should include this property to facilitate a common property for collating and sorting of vCard objects. -Photograph -This property specifies an image or photograph of the individual associated with the vCard. -The property is identified by the property name PHOTO. For example, the following syntax is an example of a referenced image file: -PHOTO;VALUE=URL:file:///jqpublic.gif - The following example is the syntax for including an inline GIF image file, using the Base 64 encoding: -PHOTO;ENCODING=BASE64;TYPE=GIF: - R0lGODdhfgA4AOYAAAAAAK+vr62trVIxa6WlpZ+fnzEpCEpzlAha/0Kc74+PjyGM - SuecKRhrtX9/fzExORBSjCEYCGtra2NjYyF7nDGE50JrhAg51qWtOTl7vee1MWu1 - 50o5e3PO/3sxcwAx/4R7GBgQOcDAwFoAQt61hJyMGHuUSpRKIf8A/wAY54yMjHtz -... -Support for this property is optional for vCard Writers conforming to this specification. -Photo Format Type -This property parameter is provided to specify the graphics format for the Photo property value. The property parameter includes the following values: - -Description -Property Parameter Value - -TYPE= - - -Indicates Graphics Interchange Format -GIF - -Indicates ISO Computer Graphics Metafile -CGM - -Indicates MS Windows Metafile -WMF - -Indicates MS Windows Bitmap -BMP - -Indicates IBM PM Metafile -MET - -Indicates IBM PM Bitmap -PMB - -Indicates MS Windows DIB -DIB - -Indicates an Apple Picture format -PICT - -Indicates a Tagged Image File Format -TIFF - -Indicates Adobe PostScript format -PS - -Indicates Adobe Page Description Format -PDF - -Indicates ISO JPEG format -JPEG - -Indicates ISO MPEG format -MPEG - -Indicates ISO MPEG version 2 format -MPEG2 - -Indicates Intel AVI format -AVI - -Indicates Apple QuickTime format -QTIME - - -Birthdate -This property specifies the date of birth of the individual associated with the vCard. The value for this property is a calendar date in a complete representation consistent with ISO 8601. -This property is identified by the property name BDAY. The property value is a string conforming to the ISO 8601 calendar date, complete representation, in either basic or extended format. The following example is in the basic format of ISO 8601: -BDAY:19950415 -The following example is in the extended format of ISO 8601: -BDAY:1995-04-15 -Support for this property is optional for vCard Writers conforming to this specification. -Delivery Addressing Properties -Delivery Address -This property specifies a structured representation of the physical delivery address for the vCard object. The property is made up of components that are based on the X.500 Post Office Box attribute, the X.520 Street Address geographical attribute, the X.520 Locality Name geographical attribute, the X.520 State or Province Name geographical attribute, the X.520 Postal Code attribute, and the X.520 Country Name geographical attribute. -This property is identified by the property name ADR. The property value consists of components of the address specified as positional fields separated by the Field Delimiter character (ASCII decimal 59). The property value is a concatenation of the Post Office Address (first field) Extended Address (second field), Street (third field), Locality (fourth field), Region (fifth field), Postal Code (six field), and Country (seventh field) strings. An example of this property follows: -ADR;DOM;HOME:P.O. Box 101;Suite 101;123 Main Street;Any Town;CA;91921-1234; -Support for this property is optional for vCard Writers conforming to this specification. -Delivery Address Type -This property parameter specifies the sub-types of physical delivery that is associated with the delivery address. For example, the label may need to be differentiated for Home, Work, Parcel, Postal, Domestic, and International physical delivery. One or more sub-types can be specified for a given delivery address. -The property parameter can have one or more of the following values: - -Description -Property Parameter Value - -TYPE= - - -Indicates a domestic address -DOM - -Indicates an international address (Default) -INTL - -Indicates a postal delivery address (Default) -POSTAL - -Indicates a parcel delivery address (Default) -PARCEL - -Indicates a home delivery address -HOME - -Indicates a work delivery address (Default) -WORK - - -The default property parameter is overridden to some other set of values by specifying one or more alternate values. For example, the default of a delivery for INTL, WORK, POSTAL and PARCEL can be reset to DOM, POSTAL, WORK and HOME in the following example: -ADR;DOM;WORK;HOME;POSTAL:P.O. Box 101;;;Any Town;CA;91921-1234; -Delivery Label -This property specifies the addressing label for physical delivery to the person/object associated with the vCard. The property is intended to include the information necessary to create a formatted delivery address label. Typical information includes the name, street address, possibly a Post Office or mail drop, city, state or province, zip or postal code. An international delivery label would also include the country name. -This property is based on the semantics of the X.520 Postal Address attribute. This specification has added semantics to those defined by the X.500 Series standard for differentiating Home, Work, Parcel, Postal, Domestic, and International delivery label types. -This property is identified by the property name LABEL. This property specifies the formatted delivery address label for the vCard object. An example of a domestic delivery label follows: -LABEL;DOM;POSTAL;ENCODING=QUOTED-PRINTABLE:P. O. Box 456=0D=0A= -123 Main Street=0D=0A= -Any Town, CA 91921-1234 -An example of an international delivery label follows: -LABEL;INTL;PARCEL,ENCODING=QUOTED-PRINTABLE:Suite 101=0D=0A= -123 Main Street=0D=0A= -Any Town, CA 91921-1234=0D=0A= -U.S.A. -Support for this property is optional for vCard Writers conforming to this specification. A vCard Reader supporting this property and conforming to this specification should support a minimum of four lines of text for this property. -Delivery Label Type -This property parameter specifies the sub-types of physical delivery that is associated with the delivery label. For example, the label may need to be differentiated for Home, Work, Parcel, Postal, Domestic, and International physical delivery. One or more sub-types can be specified for a given delivery label. -The property parameter can have one or more of the following values: - -Description -Property Parameter Value - -TYPE= - - -Indicates a domestic address -DOM - -Indicates an international address (Default) -INTL - -Indicates a postal delivery address (Default) -POSTAL - -Indicates a parcel delivery address (Default) -PARCEL - -Indicates a home delivery address -HOME - -Indicates a work delivery address (Default) -WORK - - -The default property parameter is overridden to some other set of values by specifying one or more alternate values. For example, the default of a delivery for INTL, WORK, POSTAL and PARCEL can be reset to DOM and HOME in the following example: -LABEL;DOM;HOME,ENCODING=QUOTED-PRINTABLE:Suite 101=0D=0A= -123 Main Street=0D=0A= -Any Town, CA 91921-1234 -Telecommunications Addressing Properties -These property types are concerned with information associated with the telecommunications addressing of the vCard object. -Telephone Number -This property specifies the canonical number string for a telephone number for telephony communication with the vCard object. The value of this property is specified in a canonical form in order to specify an unambiguous representation of the globally unique telephony endpoint. This property is based on the X.520 Telephone Number attribute. -The canonical form cannot be dialed without first being transformed by a dialing algorithm. The dialing algorithm combines the canonical number string with knowledge of the local dialing procedures, in effect at the time of call placement to produce actual dialing instructions. The actual dialing algorithm is outside the scope of this specification. -Two important canonical forms allowed by this specification are: -* Apple Computer's Representation of a Canonical Static DeviceID in The Telephony Suite, version 1.0, -* Microsoft TAPI in the Microsoft Windows 3.1 Telephony Programmer's Guide, version 1.0. -Software which creates this property can store a string in these allowed formats. Dialing software should be prepared to parse numbers from either of the supported formats; as neither format is considered to be technically costly to support. -This property is identified by the property name TEL. An example of this property follows: -TEL;PREF;WORK;MSG;FAX:+1-800-555-1234 -Support for this property is optional for vCard Writers conforming to this specification. -Telephone Type -This property parameter specifies the sub-type of telephone that is associated with the telephone number (e.g., Home, Work, Cellular, Facsimile, Video, Modem, Message Service, or Preferred). One or more sub-type values can be specified for a given telephone number. -The property parameter can have one or more of the following values: - -Description -Property Parameter Value - -TYPE= - - -Indicates preferred number -PREF - -Indicates a work number -WORK - -Indicates a home number -HOME - -Indicates a voice number (Default) -VOICE - -Indicates a facsimile number -FAX - -Indicates a messaging service on the number -MSG - -Indicates a cellular number -CELL - -Indicates a pager number -PAGER - -Indicates a bulletin board service number -BBS - -Indicates a MODEM number -MODEM - -Indicates a car-phone number -CAR - -Indicates an ISDN number -ISDN - -Indicates a video-phone number -VIDEO - -The default property parameter is overridden to some other set of values by specifying one or more alternate values. For example, the default of a VOICE telephone number can be reset to a WORK and HOME, VOICE and FAX telephone number in the following example: -TEL;WORK;HOME;VOICE;FAX:+1-800-555-1234 -Electronic Mail -This property specifies the address for electronic mail communication with the vCard object. The address is in the form of a specific addressing type. For example, the Internet mail address for John Public might be "John.Public@abc.com" or the CompuServe Information Service address might be "71234,5678".This property is identified by the property name EMAIL. -An example of this property follows: -EMAIL;INTERNET:john.public@abc.com -Support for this property is optional for vCard Writers conforming to this specification. -Electronic Mail Type -This property parameter specifies the type of electronic mail address. The following are some example values for this property parameter: - -Description -Property Parameter Value - -TYPE= - - -Indicates America On-Line -AOL - -Indicates AppleLink -AppleLink - -Indicates AT&T Mail -ATTMail - -Indicates CompuServe Information Service -CIS - -Indicates eWorld -eWorld - -Indicates Internet SMTP (default) -INTERNET - -Indicates IBM Mail -IBMMail - -Indicates MCI Mail -MCIMail - -Indicates PowerShare -POWERSHARE - -Indicates Prodigy information service -PRODIGY - -Indicates Telex number -TLX - -Indicates X.400 service -X400 - - -Mailer -This property parameter specifies the type of electronic mail software that is in use by the individual associated with the vCard object. This information may provide assistance to a correspondent regarding the type of data representation which can be used, and how they may be packaged. This property parameter is based on currently accepted practices within the Internet MIME community with the "X-Mailer" header field. -This property is identified by the property name MAILER. Support for this property is optional for vCard Writers conforming to this specification. An example of this property follows: -MAILER:ccMail 2.2 -Geographical Properties -These property types are concerned with geographical positions or region information associated with the vCard object. -Time Zone -This property specifies information related to the standard time zone of the vCard object. The time zone is a string as specified in a manner consistent with ISO 8601. It is an offset from Coordinated Universal Time (UTC). An ISO 8601 UTC offset, in basic format, is specified as a positive or negative difference in units of hours and minutes (e.g., +hhmm). If minutes are zero, then they may be omitted and the format would be specified in units of hours (e.g., +hh). The time is specified as a 24-hour clock. Hour valult property parameter is overridden to some other set of values by specifying one or more alternate values. For example, the default of a delivery for INTL, WORK, POSTAL and PARCEL can be reset to DOM, POSTAL, WORK and HOME in the following example: -ADR;DOM;WORK;HOME;POSTAL:P.O. Box 101;;;Any Town;CA;91921-1234; -Delivery Label -This property specifies the addressing label for physical delivery to the person/object associated with the vCard. The property is intended to include the information necessary to create a formatted delivery address label. Typical information includes the name, street address, possibly a Post Office or mail drop, city, state or province, zip or postal code. An international delivery label would also include the country name. -This property is based on the semantics of the X.520 Postal Address attribute. This specification has added semantics to those defined by the X.500 Series standard for differentiating Home, Work, Parcel, Postal, Domestic, and International delivery label types. -This property is identified by the property name LABEL. This property specifies the formatted delivery address label for the vCard object. An example of a domestic delivery label follows: -LABEL;DOM;POSTAL;ENCODING=QUOTED-PRINTABLE:P. O. Box 456=0D=0A= -123 Main Street=0D=0A= -Any Town, CA 91921-1234 -An example of an international delivery label follows: -LABEL;INTL;PARCEL,ENCODING=QUOTED-PRINTABLE:Suite 101=0D=0A= -123 Main Street=0D=0A= -Any Town, CA 91921-1234=0D=0A= -U.S.A. -Support for this property is optional for vCard Writers conforming to this specification. A vCard Reader supporting this property and conforming to this specification should support a minimum of four lines of text for this property. -Delivery Label Type -This property parameter specifies the sub-types of physical delivery that is associated with the delivery label. For example, the label may need to be differentiated for Home, Work, Parcel, Postal, Domestic, and International physical delivery. One or more sub-types can be specified for a given delivery label. -The property parameter can have one or more of the following values: - -Description -Property Parameter Value - -TYPE= - - -Indicates a domestic address -DOM - -Indicates an international address (Default) -INTL - -Indicates a postal delivery address (Default) -POSTAL - -Indicates a parcel delivery address (Default) -PARCEL - -Indicates a home delivery address -HOME - -Indicates a work delivery address (Default) -WORK - - -The default property parameter is overridden to some other set of values by specifying one or more alternate values. For example, the default of a delivery for INTL, WORK, POSTAL and PARCEL can be reset to DOM and HOME in the following example: -LABEL;DOM;HOME,ENCODING=QUOTED-PRINTABLE:Suite 101=0D=0A= -123 Main Street=0D=0A= -Any Town, CA 91921-1234 -Telecommunications Addressing Properties -These property types are concerned with information associated with the telecommunications addressing of the vCard object. -Telephone Number -This property specifies the canonical number string for a telephone number for telephony communication with the vCard object. The value of this property is specified in a canonical form in order to specify an unambiguous representation of the globally unique telephony endpoint. This property is based on the X.520 Telephone Number attribute. -The canonical form cannot be dialed without first being transformed by a dialing algorithm. The dialing algorithm combines the canonical number string with knowledge of the local dialing procedures, in effect at the time of call placement to produce actual dialing instructions. The actual dialing algorithm is outside the scope of this specification. -Two important canonical forms allowed by this specification are: -* Apple Computer's Representation of a Canonical Static DeviceID in The Telephony Suite, version 1.0, -* Microsoft TAPI in the Microsoft Windows 3.1 Telephony Programmer's Guide, version 1.0. -Software which creates this property can store a string in these allowed formats. Dialing s - -Description -Property Parameter Value - -TYPE= - - -Indicates Graphics Interchange Format -GIF - -Indicates ISO Computer Graphics Metafile -CGM - -Indicates MS Windows Metafile -WMF - -Indicates MS Windows Bitmap -BMP - -Indicates IBM PM Metafile -MET - -Indicates IBM PM Bitmap -PMB - -Indicates MS Windows DIB -DIB - -Indicates an Apple Picture format -PICT - -Indicates Tagged Image File Format -TIFF - -Indicates Adobe Page Description Format -PDF - -Indicates Adobe PostScript -PS - -Indicates ISO JPEG format -JPEG - -Indicates ISO MPEG format -MPEG - -Indicates ISO MPEG version 2 format -MPEG2 - -Indicates Intel AVI format -AVI - -Indicates Apple QuickTime format -QTIME - - -Agent -This property specifies information about another person who will act on behalf of the vCard object. Typically this would be an area administrator, assistant, or secretary for the individual. A key characteristic of the Agent property is that it represents somebody or something which is separately addressable. For example, if all phone calls or e-mail messages are normally screened by an agent, this property may not be needed. On the other hand, if an agent can act as a proxy, and may otherwise need to be contacted separately, then an Agent property is useful. -This property is equivalent to nesting another vCard with the specified vCard. -This property is identified by the property name AGENT. The value of this property is a string containing another vCard object. An example of this property follows: -AGENT: -BEGIN:VCARD -VERSION:2.1 -N:Friday;Fred -TEL;WORK;VOICE:+1-213-555-1234 -TEL;WORK;FAX:+1-213-555-5678 -END:VCARD -Support for this property is optional for vCard Writers conforming to this specification. -Organization Name and Organizational Unit -This property specifies the name and optionally the unit(s) of the organization associated with the vCard object. This property is based on the X.520 Organization Name attribute and the X.520 Organization Unit attribute. For example, "The AB Corporation" and the "North American Division". -This property is identified by the property name ORG. This property is defined to encapsulate the Organization Name and Organization Unit properties as sub-properties. The property value consists of the components of the organization specified as positional fields separated by the Field Delimiter (ASCII decimal 59). The property value is a concatenation of the Organization Name (first field), Organizational Unit (second field) strings. Additional positional fields, if specified, contain additional Organizational Units. The following is an example of the Organization property: -ORG:ABC, Inc.;North American Division;Marketing -Support for this property is optional for vCard Writers conforming to this specification. -Explanatory Properties -These property types are concerned with additional explanations, such as that related to national language support, annotation, or encoding of binary information about the vCard object. -Comment -This property specifies supplemental information or a comment that is associated with the vCard. With the use of property grouping, the association can be limited to a group of properties. The property is based on the X.520 Description attribute. -This property is identified by the property name NOTE. An example of this property follows: -NOTE;ENCODING=QUOTED-PRINTABLE:This facsimile machine if operational= - 0830 to 1715 hours=0D=0A= -Monday through Friday. Call +1-213-555-1234 if you have problems=0D=0A= -with access to the machine. -Support for this property is optional for vCard Writers conforming to this specification. -Last Revision -This property specifies the combination of the calendar date and time of day of the last update to the vCard object. The property value is a character string conforming to the basic or extended format of ISO 8601. The value can either be in terms of local time or UTC. -This property is identified by the property name REV. Valid values for this property are a character string representing a combination of the calendar date and time of day conforming to the basic or extended format of ISO 8601. The time of day can be either local time or UTC. The following example is in the basic format and local time of ISO 8601: -REV:19951031T222710 -The following example is in the extended format and UTC time of ISO 8601: -REV:1995-10-31T22:27:10Z -Support for this property is optional for vCard Writers conforming to this specification. -Sound -This property specifies a sound annotation for the vCard object. By default, if this property is not grouped with other properties it specifies the pronunciation of the Formatted Name property of the vCard object. Such information may be in the form of a string of characters representing a phonetic sound or in the form of a digitized sound, or both; subject to the limitations imposed by the encoding used to communicate the vCard. -This property is identified by the property name SOUND. Valid values for this property are either a string representation, a reference to a digital audio representation, or an inline digital audio representation of the phonetic pronunciation of the Formatted Name property. The following example shows the string based phonetic representation: -SOUND:JON Q PUBLIK -The following example shows the digtial sound representation and URL based value: -SOUND;VALUE=URL:file///multimed/audio/jqpublic.wav -The following example shows the digtial sound representation and INLINE value: -SOUND;WAVE;BASE64: - UklGRhAsAABXQVZFZm10IBAAAAABAAEAESsAABErAAABAAgAZGF0YesrAACAg4eC - eXR4e3uAhoiIiYmKjIiDfnx5eX6CgoKEhYWDenV5fH6BhISGiIiDfHZ2eXt/hIiK - jY2IhH12d3Vyc3uDiIiFf3l7fn18eXl+houFf319fnyAgHl5eoCIiISChIeAfnt2 -... -Support for this property is optional for vCard Writers conforming to this specification. -Sound Digital Audio Type -This property parameteris provided to specify the type of the digital audio Pronunciation for the vCard object. The property parameter can have the following values: - -Description -Property Parameter Value - -TYPE= - - -Indicates Wave format -WAVE - -Indicates MIME basic audio type -PCM - -Indicates AIFF format -AIFF - - -Uniform Resource Locator -This property specifies a value that represents a Uniform Resource Locator (URL). An URL is a representation of an Internet location that can be used to obtain real-time information about the vCard object. Application of this property might be to specify the location of a publicly accessible directory where up-to-date or additional information on the individual or resource associated with a vCard can be found. -This property is identified by the property name URL. Valid values for this property are a string conforming to the IETF RFC 1738, Uniform Resource Locators. The following is an example of this property: -URL:http://abc.com/pub/directory/northam/jpublic.ecd -Support for this property is optional for vCard Writers conforming to this specification. -Unique Identifier -This property specifies a value that represents a persistent, globally unique identifier associated with the object. The property can be used as a mechanism to relate different vCard objects. Some examples of valid forms of unique identifiers would include ISO 9070 formal public identifiers (FPI), X.500 distinguished names, machine-generated "random" numbers with a statistically high likelihood of being globally unique and Uniform Resource Locators (URL). If an URL is specified, it is suggested that the URL reference a service which will produce an updated version of the vCard. -This property is identified by the property name UID. This property is provided to enable a vCard Reader and Writer to uniquely identify either a vCard object instance or properties within a vCard object. Valid values for this property are a unique character string. The following is an example of this property: -UID:19950401-080045-40000F192713-0052 -Support for this property is optional for vCard Writers conforming to this specification. -Version -This property specifies the identifier corresponding to the highest version number of the vCard Specification supported by the implementation that created the vCard object. The value of this property must be 2.1 to correspond to this specification.. -This property is identified by the property name VERSION. The following is an example of this property: -VERSION:2.1 -Support for this property is mandatory for implementations conforming to this specification. This property must appear within the vCard data stream. -Security Properties -These property types are concerned with the security of the information in the vCard object. -Public Key -This property specifies the public encryption key associated with the vCard object. -This property is identified by the property name KEY. Valid values for this property are a public key that conforms to a bilaterally agreed to representation. If the representation is a binary format, then the public key must be further encoded. The default format is clear-text. If a binary format is used, then it is specified by the property parameter. Support for this property is optional for vCard Writers conforming to this specification. -Key Type -This property parameter is provided to specify the type of the public key for the vCard object. The property parameter can have the following values: - -Description -Property Parameter Value - -TYPE= - - -Indicates a X.509 public key certificate type of key -X509 - -Indicates an IETF PGP type of key -PGP - -Miscellaneous Properties -Extensions -The vCard provides a ìstandard mechanism for doing non-standard thingsî. This extension support is provided for implementers to "push the envelope" on the existing version of the specification. Extension properties are specified by property and/or property parameter names that have the initial sub-string of X- (the two character sequence: Capital X character followed by the Dash character. It is recommended that vendors concatenate onto this sentinel an added short sub-string to identify the vendor. This will facilitate readability of the extensions and minimize possible collision of names between different vendors. For example, the following might be the ABC vendor's extension for a video-clip form of identification property: -X-ABC-VIDEO;MPEG2:http://lonestar.bubbas.org/billibob.mpg -or, the following example might be an extension for grouping vCard objects into a distribution list for the Design Work Group. -BEGIN:VCARD -VERSION:2.1 -X-DL;Design Work Group:List Item 1;List Item 2;List Item 3 -BEGIN:VCARD -UID:List Item 1 -N:John Smith -TEL:+1-213-555-1111 -END:VCARD -BEGIN:VCARD -UID:List Item 2 -N:I. M. Big -TEL:+1-213-555-9999 -END:VCARD -BEGIN:VCARD -UID:List Item 3 -N:Jane Doe -TEL:+1-213-555-5555 -END:VCARD -END:VCARD -At present, there is no registration authority for names of extension properties. -Support for this property is mandatory for implementations conforming to this specification. However, an implementation may not be able to act on the extension property. Conformance only requires that an implementation be able to parse vCard data streams with extensions. The implementation need not act on them. -Formal Definition -The following modified Backus-Naur Notation (BNF) is provided to assist developers in building parsers for the vCard. -This syntax is written according to the form described in RFC 822, but it references just this small subset of RFC 822 literals: - CR = <ASCII CR, carriage return> ; ( 15, 13.) - LF = <ASCII LF, linefeed> ; ( 12, 10.) - CRLF = CR LF - SPACE = <ASCII SP, space> ; ( 40, 32.) - HTAB = <ASCII HT, horizontal-tab> ; ( 11, 9.) -All literal property names are valid as upper, lower, or mixed case. -ws = 1*(SPACE / HTAB) - ; "whitespace," one or more spaces or tabs -wsls = 1*(SPACE / HTAB / CRLF) - ; whitespace with line separators -word = <any printable 7bit us-ascii except []=:., > -groups = groups "." word - / word -vcard_file = [wsls] vcard [wsls] -vcard = "BEGIN" [ws] ":" [ws] "VCARD" [ws] 1*CRLF - items *CRLF "END" [ws] ":" [ws] "VCARD" -items = items *CRLF item - / item - ; these may be "folded" -item = [groups "."] name - [params] ":" value CRLF - / [groups "."] "ADR" - [params] ":" addressparts CRLF - / [groups "."] "ORG" - [params] ":" orgparts CRLF - / [groups "."] "N" - [params] ":" nameparts CRLF - / [groups "."] "AGENT" - [params] ":" vcard CRLF - ; these may be "folded" -name = "LOGO" / "PHOTO" / "LABEL" / "FN" / "TITLE" - / "SOUND" / "VERSION" / "TEL" / "EMAIL" / "TZ" / "GEO" / "NOTE" - / "URL" / "BDAY" / "ROLE" / "REV" / "UID" / "KEY" - / "MAILER" / "X-" word - ; these may be "folded" -value = 7bit / quoted-printable / base64 -7bit = <7bit us-ascii printable chars, excluding CR LF> -8bit = <MIME RFC 1521 8-bit text> -quoted-printable = <MIME RFC 1521 quoted-printable text> -base64 = <MIME RFC 1521 base64 text> - ; the end of the text is marked with two CRLF sequences - ; this results in one blank line before the start of the next property -params = ";" [ws] paramlist -paramlist = paramlist [ws] ";" [ws] param - / param -param = "TYPE" [ws] "=" [ws] ptypeval - / "VALUE" [ws] "=" [ws] pvalueval - / "ENCODING" [ws] "=" [ws] pencodingval - / "CHARSET" [ws] "=" [ws] charsetval - / "LANGUAGE" [ws] "=" [ws] langval - / "X-" word [ws] "=" [ws] word - / knowntype -ptypeval = knowntype / "X-" word -pvalueval = "INLINE" / "URL" / "CONTENT-ID" / "CID" / "X-" word -pencodingval = "7BIT" / "8BIT" / "QUOTED-PRINTABLE" / "BASE64" / "X-" word -charsetval = <a character set string as defined in Section 7.1 of - RFC 1521> -langval = <a language string as defined in RFC 1766> -addressparts = 0*6(strnosemi ";") strnosemi - ; PO Box, Extended Addr, Street, Locality, Region, Postal Code, - Country Name -orgparts = *(strnosemi ";") strnosemi - ; First is Organization Name, remainder are Organization Units. -nameparts = 0*4(strnosemi ";") strnosemi - ; Family, Given, Middle, Prefix, Suffix. - ; Example:Public;John;Q.;Reverend Dr.;III, Esq. -strnosemi = *(*nonsemi ("\;" / "\" CRLF)) *nonsemi - ; To include a semicolon in this string, it must be escaped - ; with a "\" character. -nonsemi = <any non-control ASCII except ";"> -knowntype = "DOM" / "INTL" / "POSTAL" / "PARCEL" / "HOME" / "WORK" - / "PREF" / "VOICE" / "FAX" / "MSG" / "CELL" / "PAGER" - / "BBS" / "MODEM" / "CAR" / "ISDN" / "VIDEO" - / "AOL" / "APPLELINK" / "ATTMAIL" / "CIS" / "EWORLD" - / "INTERNET" / "IBMMAIL" / "MCIMAIL" - / "POWERSHARE" / "PRODIGY" / "TLX" / "X400" - / "GIF" / "CGM" / "WMF" / "BMP" / "MET" / "PMB" / "DIB" - / "PICT" / "TIFF" / "PDF" / "PS" / "JPEG" / "QTIME" - / "MPEG" / "MPEG2" / "AVI" - / "WAVE" / "AIFF" / "PCM" - / "X509" / "PGP" - - -Section 3 : Internet Recommendations -[DS4] 1 -Recommended Practice with SMTP/MIME -The vCard information can be transported through SMTP/MIME based electronic mail services. Interoperability of vCard information over SMTP/MIME transports can be better assured by following a common set of recommended practices for encapsulation of the vCard. -Text/Plain Content Type -Without any change to existing SMTP or MIME compliant user agents, a vCard can be included within Internet email messages. This might be the case for an existing, simple user agent such as a legacy SMTP mail system. While this approach provides for transport of vCards over SMTP services, it does not allow for the end user to take advantage of the full capabilities of either the vCard or Internet email (i.e., MIME) functionality. -The following demonstrates how a vCard can be included as an epilog to a SMTP message made up of a RFC 822 message. This may be an initial method for incorporating vCard objects into SMTP messages. -Date: Thr, 25 Jan 96 0932 EDT -From: john.smith@host.com -Subject: Re: RFC822 vCard Example -Sender: john.smith@host.com -To: smartin@host2.com -Message-ID: <JOHNSMITH.960125T091020.xyzMail@host3.com> - -Steve: Thanks for the call earlier today. I am unable to -use your material at this time. Please feel free to contact -me in the future. -BEGIN:VCARD -VERSION:2.1 -N:Smith;John;M.;Mr.;Esq. -TEL;WORK;VOICE;MSG:+1 (919) 555-1234 -TEL;WORK;FAX:+1 (919) 555-9876 -ADR;WORK;PARCEL;POSTAL;DOM:Suite 101;1 Central St.;Any Town;NC;27654 -END:VCARD -The following example demonstrates how a vCard can be included as a separate text/plain content portion within current MIME user agents. -Date: Fri, 26 Jan 1996 07:53:00 -0500 -From: smartin@host2.com -Subject: RE: Text/Plain MIME vCard Example -To: fdawson@VNET.IBM.COM -Mime-Version: 1.0 -Content-Type: multipart/mixed; boundary=vcard -Message-ID: <ABC-1.00-Note-martin-steve-0824475754> - ---vcard -Content-Type:text/plain; charset=us-ascii -Content-Transfer-Encoding: 7bit -John: I have looked over my material and feel that you may -have over looked a couple of appropriate pieces. Please give -me a call so that we can discuss further. ---vcard -Content-Type:text/plain; charset=us-ascii; name="MARTIN.VCF" - -BEGIN:VCARD -VERSION:2.1 -N:Martin;Stephen -TEL;HOME;VOICE:+1 (210) 555-1357 -TEL;HOME;FAX:+1 (210) 555-0864 -ADR;WORK;PARCEL;POSTAL;DOM:123 Cliff Ave.;Big Town;CA;97531 -END:VCARD ---vcard-- -Text/X-vCard Content Type -A vCard object may also be transferred in a (RFC 1521) MIME entity as a non-standard "text/x-vCard" content-type. This (RFC 1521) MIME type maybe useful in those cases where the MIME compliant messaging service does not yet support the "application/directory" and "multipart/related" MIME content-types and yet the specificity of a calendaring and scheduling media type is required. -The following example demonstrates how a vCard can be included as a separate non-standard text/x-vCard content portion within current MIME user agents. -Date: Fri, 26 Jan 1996 07:53:00 +0000 -From: smartin@host2.com -Subject: RE: Text/x-vCard MIME vCard Example -To: fdawson@VNET.IBM.COM -Mime-Version: 1.0 -Content-Type: multipart/mixed; boundary=vcard -Message-ID: <ABC-1.00-Note-martin-steve-0824475754> - ---vcard -Content-Type:text/plain; charset=us-ascii -Content-Transfer-Encoding: 7bit -John: I have looked over my material and feel that you may -have over looked a couple of appropriate pieces. Please give -me a call so that we can discuss further. ---vcard -Content-Type:text/x-vCard; charset=us-ascii; name="MARTIN.VCF" - -BEGIN:VCARD -VERSION:2.1N:Martin;Stephen -TEL;HOME;VOICE:+1 (210) 555-1357 -TEL;HOME;FAX:+1 (210) 555-0864 -ADR;WORK;PARCEL;POSTAL;DOM:123 Cliff Ave.;Big Town;CA;97531 -END:VCARD ---vcard-- -Application/Directory Content Type -The Internet Engineering Task Force (IETF) Access and Searching of Internet Directories (ASID) working group has produced an Internet Draft defining the "application/directory" MIME content type. The current draft name is draft-ietf-asid-mime-direct-01.txt. This specification is intended to be aligned with this work. Internet Drafts are working documents of an IETF working group, valid for at most six months, and should be considered "works in progress". -This MIME content type was designed to be used to transport directory information across MIME based electronic mail services. The internet draft is directly applicable to the exchange of business card data, such as that defined by the vCard specification. -The versit PDI Team has worked within the IETF ASID Working Group to draft an application/directory profile that registers the method for transporting a vCard as an application/directory Content-Type. The current draft name is draft-ietf-asid-mime-vcard-00.txt. This work is expected to be progressed to a Request For Comment after the publication of this version of the vCard specification. In the interim, the following guidelines are provided to describe how a vCard might be conveyed using the application/directory draft specification. -A vCard should be included in a MIME message that has a Content-Type header field value of "multipart/related". The vCard is included in the message as the primary body part. The position of the body part entity can also be specified with the "start=" parameter. This MIME body part entity has a Content-Type body part header field value of "application/directory" with a "profile" parameter value of "vcard". Any vCard binary information, such as a logo, picture, or digital audio pronunciation can be included inline within the vCard, as is specified by the vCard specification. Preferably, the binary information should be extracted from the vCard object and contained in the MIME message as secondary body part entities. The binary content in the secondary body part entities can be referenced from within the vCard object through the use of the "VALUE=" property parameter. In this latter case, the binary information should be transformed into a content type nominally supported by MIME user agents. For image content, this would be the Graphics Image Format (GIF) or Joint Picture Encoding Group (JPEG) formats. For audio content, this would be the 8-bit mu-law (PCM) format specified by the MIME specification. -The following example defines how this might be specified: -Date: Mon, 29 Jan 96 0830 EDT -From: john.smith@host.com -Subject: Re: MIME application/directory vCard Example -Sender: john.smith@host.com -To: smartin@host2.com -Message-ID: <JOHNSMITH.960129T083020.xyzMail@host3.com> -Content-Type: multipart/related; boundary="vcard"; - type=application/directory; - start=<JOHNSMITH.part1.960129T083020.xyzMail@host3.com> ---vcard -Content-Type: application/directory; charset=us-ascii; - source="file://versit.or2"; profile="vcard" -Content-ID: <<JOHNSMITH.part1.960129T083020.xyzMail@host3.com> -BEGIN:VCARD -VERSION:2.1 -N:Smith;John;M.;Mr.;Esq. -TEL;WORK;VOICE;MSG:+1 (919) 555-1234 -TEL;CELL:+1 (919) 554-6758 -TEL;WORK;FAX:+1 (919) 555-9876 -PHOTO;GIF;MIME:<<JOHNSMITH.part3.960129T083020.xyzMail@host3.com> -ADR;WORK;PARCEL;POSTAL;DOM:Suite 101;1 Central St.;Any Town;NC;27654 -END:VCARD ---vcard -Content-Type: text/plain; charset=us-ascii -Content-ID: <<JOHNSMITH.part2.960129T083020.xyzMail@host3.com> -Steve: -I am not in the office today. You may want to try -reaching me either on my cellular telephone or fax your -new ideas to my office. -Let's setup a face-to-face meeting later this week, after I review -your updated material. I am including a picture in my business card -data, since we have not met yet. --- John ---vcard -Content-Type: image/gif -Content-ID: <<JOHNSMITH.part3.960129T083020.xyzMail@host3.com> -...image data would go here... ---vcard-- -Recommended Practice with HTTP/HTML -A vCard object should be transferred over HTTP with the non-standard MIME type/subtype value of "text/x-vCard". The non-standard subtype should be used because the vCard has not been registered as a MIME media type with the IANA. -The vCard information can be captured with a FORM type of HTML document. Interoperability of of vCard information can be better assured by following a common set of recommended practices for mapping vCard information into and out of HTML documents. -Form Element Usage -The HTML FORM element is a useful method for capturing data intended for input into individual vCard property values. The following recommended practices are provided for such use. -Mapping To INPUT Element Attribute Names -An HTML form data set is a useful mechanism for capturing vCard data within the Internet WWW. The use of a consistent naming scheme for the name attributes within a form element will permit implementations to support automatic fill-in of forms with existing vCard data. In addition, such a consistent naming scheme will provide a greater assurance of interoperability between HTML based applications that use vCard data. -The following table provides a recommended mapping of vCard properties and name attributes within a form element. -Identification Properties -Description -Attribute Name -Comment - -Formatted Name -FN - - -Name -N -Individual components of name property are captured as separate input elements with the names N.Family, N.First, N.Middle, N.Prefix, N.Suffix. - -Photograph -PHOTO -Only the URL based specification is supported by this mapping. Value is the URL for the graphic. - -Photograph Format Type -PHOTO.Type -Where the value is one of the enumerated strings defined by the vCard specification. - -Birthdate -BDAY - - - -Delivery Addressing Properties -Description -Attribute Name -Comment - -Delivery Address -ADR -TYPE=TEXTAREA - -Address Type -ADR.x -TYPE=CHECKBOX. Separate input elements are used to capture the possible delivery types. The elements are named ADR.x, where x is one of the enumerated strings defined by the vCard specification. - -Delivery Label -LABEL - - -Label Type -LABEL.x -TYPE=CHECKBOX. Separate input elements are used to capture the possible delivery types. The elements are named LABEL.x, where x is one of the enumerated strings defined by the vCard specification. - - -Telecommunications Addressing Properties -Description -Attribute Name -Comment - -Telephone Number -TEL - - -Telephone Type -TEL.x -TYPE=CHECKBOX. Separate input elements are used to capture the possible telephone types. The elements are named TEL.x, where x is one of the enumerated strings defined by the vCard specification. - -Electronic Mail Address -EMAIL - - -Electronic Mail Address Type -EMAIL.Type -Selection option from a list of alternatives. - -Mailer -MAILER - - - -Geographical Properties -Description -Attribute Name -Comment - -Time Zone -TZ - - -Geographic Position -GEO - - - -Organizational Properties -Description -Attribute Name -Comment - -Title -TITLE - - -Business Category -ROLE - - -Logo -LOGO -Only the URL based specification is supported by this mapping. Value is the URL for the graphic. - -Logo Format Type -LOGO.Type -Where the value is one of the enumerated strings defined by the vCard specification. - -Agent - -Captured through a separate form element using the mapping defined in these tables. - -Organization -ORG -TYPE=TEXT. Separate input elements for the organizational name and unit. The name ORG.Name is used to capture the organizational name. The name ORG.UNIT is used to capture the organizational unit. If there are multiple organizational units, it is captured in a form with name attributes ORG.UNIT1, ORG.UNIT2, etc. - - -Explanatory Properties -Description -Attribute Name -Comment - -Comment -NOTE -TYPE=TEXT - -Last Revision -REV -A hidden field. - -Version -VERSION -A hidden field with the value set to the string ì2.1î. - -Language -LANG -A hidden field with the value set to the string associated with the default language used in the form (e.g., US-eng). - -Sound -SOUND -TYPE=TEXT - -Sound Type -N/A - - -Uniform Resource Locator -URL -TYPE=TEXT - -Unique Identifier -UID -TYPE=TEXT - -Binary Encoding -BE.x -Where x is one of the enumerated encoding types defined by the vCard specification. - - -Security Properties -Description -Attribute Name -Comment - -Public Key -KEY - - -Key Type -KEY.Type.x -Where x is one of the enumerated encoding types defined by the vCard specification. - -MISCELLANEOUS PROPERTIES - - - -Extensions -X-x -Where x is a string defined by the extension author. - - -Where multiple properties (e.g., telephone numbers) appear, a label prefix should be used. For example, telephone #1 might have a name attribute of ìA.TELî, telephone #2 might have a name attribute of ìB.TELî, etc. -Example HTML Code -The following HTML code is an example of the use of the mapping of INPUT element attributes names to vCard property names. The code can be used to capture input data for creating a vCard on a Web homepage. -<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML 2.0//EN"> -<head> -<title>Create Your Own Versitcard</title> -</head> -<IMG src="versit.gif"> -<h1>Create Your Own Versitcard</h1> -<P> Fill out this form and we'll -create a <b>Versitcard</b> for you and send it to the email address of your choice, -along with more information on the Versitcard format.</P> -<hr><!-- Identification And Organizational Properties --> -<FORM METHOD="POST" ACTION="/cgi-bin/vcard-maker"> -Formatted Name:<INPUT name="FN" type=text size=32 maxlength=64 -value=""><br> -Phoenetic Pronunciation:<INPUT name="SOUND" type=text size=32 maxlength=128 value=""><br> -Company Name:<INPUT name="ORG.Name" type=text size=32 maxlength=64 -value=""><br> -Company Unit:<INPUT name="ORG.Unit" type=text size=32 -maxlength=64 value=""><br> -Title:<INPUT name="TITLE" type=text size=32 maxlength=64 -value=""> -<hr><!-- Name Property Component Values --> -Family Name:<INPUT name="N.Family" type=text size=32 maxlength=64 -value=""><br> -Given Name:<INPUT name="N.Given" type=text size=32 -maxlength=64 value=""><br> -Middle Name:<INPUT name="N.Middle" type=type size=32 -maxlength=64 value=""><br> -Name Prefix:<INPUT name="N.Prefix" type=type size=32 -maxlength=64 value=""><br> -Name Suffix:<INPUT name="N.Suffix" type=type size=32 -maxlength=64 value=""><br> -<hr><!-- Delivery Addressing Properties --> -Delivery Label:<TEXTAREA name="LABEL" cols=64 ROWS=5> -</TEXTAREA><br><br> -Post Office Address:<INPUT name="ADR.POAddr" type=text size=32 -maxlength=64 value=""><br> -Extended Address:<INPUT name="ADR.ExtAddr" type=text size=32 -maxlength=64 value=""><br> -Street Address:<INPUT name="ADR.Street" type=text size=62 -maxlength=128 value=""><br> -City:<INPUT name="ADR.Locality" type=text size=16 maxlength=32 -value=""> -Region:<INPUT name="ADR.Region" type=text size=16 maxlength=32 -value=""> -Postal Code:<INPUT name="ADR.PostalCode" type=text size=16 maxlength=32 -value=""><br> -Country Name:<INPUT name="ADR.CountryName" type=text size=16 maxlength=32 value="USA"> -<INPUT type=checkbox name="ADR.Work" value=WORK checked>Work -<INPUT type=checkbox name="ADR.Home" value=HOME>Home -<INPUT type=checkbox name="ADR.Parcel" value=PARCEL checked>Parcel <INPUT type=checkbox name="ADR.Postal" value=POSTAL checked>Postal<br> -<hr><!-- Geographical Properties --> -TimeZone:<INPUT name="TZ" type=text size=3 maxlength=8 -value="-06"> -Location:<INPUT name="GEO" type=text size=16 maxlength=32 value=""><br> -<hr><!-- Telephony Addressing Properties --> -<!-- Telephone #1 --> -Telephone #1:<INPUT type=text name="A.TEL" size=20 maxlength=40 value="+1 (000) 000-0000"><br> -<INPUT type=checkbox name="A.TEL.Work" value=WORK checked>Work -<INPUT type=checkbox name="A.TEL.Home" value=HOME>Home -<INPUT type=checkbox name="A.TEL.Voice" value=VOICE checked>Voice -<INPUT type=checkbox name="A.TEL.Msg" value=MSG checked>Msg <INPUT type=checkbox name="A.TEL.Fax" value=FAX>Fax <INPUT type=checkbox name="A.TEL.Prefer" value=PREFER checked>Preferred<br> -<hr><!-- Telephone #2 --> -Telephone #2:<INPUT type=text name="B.TEL" size=20 maxlength=40 value="+1 (000) 000-0000"><br> -<INPUT type=checkbox name="B.TEL.Work" value=WORK checked>Work <INPUT type=checkbox name="B.TEL.Home" value=HOME>Home -<INPUT type=checkbox name="B.TEL.Voice" value=VOICE>Voice <INPUT type=checkbox name="B.TEL.Msg" value=MSG>Msg -<INPUT type=checkbox name="B.TEL.Fax" value=FAX checked>Fax -<INPUT type=checkbox name="B.TEL.Prefer" value=PREFER>Preferred<br> -<hr><!-- Telephone #3 --> -Telephone #3:<INPUT type=text name= "C.TEL" size=20 maxlength=40 value="+1 (000) 000-0000"><br> -<INPUT type=checkbox name="C.TEL.Work" value=WORK>Work -<INPUT type=checkbox name="C.TEL.Home" value=HOME checked>Home <INPUT type=checkbox name="C.TEL.Voice" value=VOICE checked>Voice <INPUT type=checkbox name="C.TEL.Msg" value=MSG checked>Msg -<INPUT type=checkbox name="C.TEL.Fax" value=FAX checked>Fax <INPUT type=checkbox name="D.Prefer" value=PREFER>Preferred<br> -<hr><!-- Email D --> -EmailAddress: <select name="D.EMAILTYPE"> -<option selected>INTERNET: -<option>CompuServe: -<option>AOL: -<option>Prodigy: -<option>eWorld: -<option>AppleLink: -<option>AppleTalk: -<option>PowerShare: -<option>IBMMail: -<option>ATTMail: -<option>MCIMail: -<option>X.400: -<option>TLX: -</select><INPUT type=text name="D.EMAIL" size=32 maxlength=64 value=""> -<INPUT type=checkbox name="D.EMAIL.Work" value=WORK checked>Work <INPUT type=checkbox name="D.EMAIL.Home" value=HOME checked>Home<br> -<hr><!-- End of vCard Input --> -Send my Versitcard to this <b>internet</b> email address: -<INPUT type=text name="SENDTOADDR" size=32 maxlength=64 value=""><br> Press <INPUT TYPE=SUBMIT value="Send"> to send the form now. Or, press <INPUT TYPE=RESET value="Reset"> to reset values to the form defaults. -</form> -</body> - - -Section 4 : UI Support Recommendations -[DS5] -When integrating vCard support into an application, an implementor needs to consider a number of user interface (UI) implications. Most appliss Type -ADR.x -TYPE=CHECKBOX. Separate input elements are used to capture the possible delivery types. The elements are named ADR.x, where x is one of the enumerated strings defined by the vCard specification. - -Delivery Label -LABEL - - -Label Type -LABEL.x -TYPE=CHECKBOX. Separate input elements are used to capture the possible delivery types. The elements are named LABEL.x, where x is one of the enumerated strings defined by the vCard specification. - - -Telecommunications Addressing Properties -Description -Attribute Name -Comment - -Telephone Number -TEL - - -Telephone Type -TEL.x -TYPE=CHECKBOX. Separate input elements are used to capture the possible telephone types. The elements are named TEL.x, where x is one of the enumerated strings defined by the vCard specification. - -Electronic Mail Address -EMAIL - - -Electronic Mail Address Type -EMAIL.Type -Selection option from a list of alternatives. - -Mailer -MAILER - - - -Geographical Properties -Description -Attribute Name -Comment - -Time Zone -TZ - - -Geographic Position -GEO - - - -Organizational Properties -Description -Attribute Name -Comment - -Title -TITLE - - -Business Category -ROLE - - -Logo -LOGO -Only the URL based specification is supported by this mapping. Value is the URL for the graphic. - -Logo Format Type -LOGO.Type -Where the value is one of the enumerated strings defined by the vCard specification. - -Agent - -Captured through a separate form element using the mapping defined in these tables. - -Organization -ORG -TYPE=TEXT. Separate input elements for the organizational name and unit. The name ORG.Name is used to capture the organizational name. The name ORG.UNIT is used to capture the organizational unit. If there are multiple organizational units, it is captured in a form with name attributes ORG.UNIT1, ORG.UNIT2, etc. - - -Explanatory Properties -Description -Attribute Name -Comment - -Comment -NOTE -TYPE=TEXT - -Last Revision -REV -A hidden field. - -Version -VERSION -A hidden field with the value set to the string ì2.1î. - -Language -LANG -A hidden field with the value set to the string associated with the default language used in the form (e.g., US-eng). - -Sound -SOUND -TYPE=TEXT - -Sound Type -N/A - - -Uniform Resource Locator -URL -TYPE=TEXT - -Unique Identifier -UID -TYPE=TEXT - -Binary Encoding -BE.x -Where x is one of the enumerated encoding types defined by the vCard specification. - - -Security Properties -Description -Attribute Name -Comment - -Public Key -KEY - - -Key Type -KEY.Type.x -Where x is one of the enumerated encoding types defined by the vCard specification. - -MISCELLANEOUS PROPERTIES - - - -Extensions -X-x -Where x is a string defined by the extension author. - - -Where multiple properties (e.g., telephone numbers) appear, a label prefix should be used. For example, telephone #1 might have a name attribute of ìA.TELî, telephone #2 might have a name attribute of ìB.TELî, etc. -Example HTML Code -The following HTML code is an example of the use of the mapping of INPUT element attributes names to vCard property names. The code can be used to capture input data for creating a vCard on a Web homepage. -<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML 2.0//EN"> -<head> -<title>Create Your Own Versitcard</title> -</head> -<IMG src="versit.gif"> -<h1>Create Your Own Versitcard</h1> -<P> Fill out this form and we'll -create a <b>Versitcard</b> for you and send it to the email address of your choice, -along with more information on the Versitcard format.</P> -<hr><!-- Identification And Organizational Properties --> -<FORM METHOD="POST" ACTION="/cgi-bin/vcard-maker"> -Formatted Name:<INPUT name="FN" type=text size=32 maxlength=64 -value=""><br> -Phoenetic Pronunciation:<INPUT name="SOUND" type=text size=32 maxlength=128 value=""><br> -Company Name:<INPUT name="ORG.Name" type=text size=32 maxlength=64 -value=""><br> -Company Unit:<INPUT name="ORG.Unit" type=text size=32 -maxlength=64 value=""><br> -Title:<INPUT name="TITLE" type=text size=32 maxlength=64 -value=""> -<hr><!-- Name Property Component Values --> -Family Name:<INPUT nies. -All forms of vCard Grouping must be able to be parsed and processed. -Property Grouping must be able to be parsed and processed. -Additionally, in order for a vCard Writer to conform to this specification it must meet the following additional criteria: -Must be able to send at least the Version, Formatted Name, Name, Address, Telephone, Email, and Mailer properties. - - -[DS1]This entry (merged from the ìTRIAL USE (TU)î document) appears to be a duplicate of the already-existing entry that follows, except for the publicaton/edition date. I would assume that itís OK to delete this item, but, Ö -[DS2]This entry/line in the section is assigned the style for the level 1 heading. This is done so that a section number can be given in the chapter title (style "chptr_title") and so that "heading 1" (more specifically, the format/heading numbering of the form "1. Overview") can be "skipped," and the appropriate form for the next-level of heading can be properly displayed (eg., "1.1 Overview"). It is, and must be, formatted as "hidden text" prior to pagination and/or printing. -[DS3]This entry/line in the section is assigned the style for the level 1 heading. This is done so that a section number can be given in the chapter title (style "chptr_title") and so that "heading 1" (more specifically, the format/heading numbering of the form "1. Overview") can be "skipped," and the appropriate form for the next-level of heading can be properly displayed (eg., "1.1 Overview"). It is, and must be, formatted as "hidden text" prior to pagination and/or printing. -[DS4]This entry/line in the section is assigned the style for the level 1 heading. This is done so that a section number can be given in the chapter title (style "chptr_title") and so that "heading 1" (more specifically, the format/heading numbering of the form "1. Overview") can be "skipped," and the appropriate form for the next-level of heading can be properly displayed (eg., "1.1 Overview"). It is, and must be, formatted as "hidden text" prior to pagination and/or printing. -[DS5]This entry/line in the section is assigned the style for the level 1 heading. This is done so that a section number can be given in the chapter title (style ìchptr_title") and so that "heading 1" (more specifically, the format/heading numbering of the form "1. Overview") can be "skipped," and the appropriate form for the next-level of heading can be properly displayed (eg., "1.1 Overview"). It is, and must be, formatted as "hidden text" prior to pagination and/or printing. -[DS6]This entry/line in the section is assigned the style for the level 1 heading. This is done so that a section number can be given in the chapter title (style ìchptr_title") and so that "heading 1" (more specifically, the format/heading numbering of the form "1. Overview") can be "skipped," and the appropriate form for the next-level of heading can be properly displayed (eg., "1.1 Overview"). It is, and must be, formatted as "hidden text" prior to pagination and/or printing. - - - - - - - -$paratext[Pr.Preface] - - - - - - - - -vi vCard Specification, Version 2.1 - - v - -versit Update vii - - - - - - - -36 vCard Specification, Version 2.1 - - xi - - - - - 39 - - diff --git a/addressbook/backend/ebook/e-book-async.c b/addressbook/backend/ebook/e-book-async.c deleted file mode 100644 index d21f22a739..0000000000 --- a/addressbook/backend/ebook/e-book-async.c +++ /dev/null @@ -1,1121 +0,0 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */ - -#include "ebook/e-book-async.h" - -static GThread *worker_thread; -static GAsyncQueue *to_worker_queue; -static GAsyncQueue *from_worker_queue; - -typedef struct _EBookMsg EBookMsg; - -typedef void (*EBookMsgHandler)(EBookMsg* msg); -typedef void (*EBookMsgDtor)(EBookMsg* msg); - -struct _EBookMsg { - EBookMsgHandler handler; - EBookMsgDtor dtor; -}; - -static gpointer -worker (gpointer data) -{ - while (TRUE) { - EBookMsg *msg = g_async_queue_pop (to_worker_queue); - msg->handler (msg); - msg->dtor (msg); - } - - return NULL; -} - -static gboolean -main_thread_check_for_response (gpointer data) -{ - EBookMsg *msg; - - while ((msg = g_async_queue_try_pop (from_worker_queue)) != NULL) { - msg->handler (msg); - msg->dtor (msg); - } - - return TRUE; -} - -static void -e_book_msg_init (EBookMsg *msg, EBookMsgHandler handler, EBookMsgDtor dtor) -{ - msg->handler = handler; - msg->dtor = dtor; -} - -static void -init_async() -{ - static gboolean init_done = FALSE; - if (!init_done) { - init_done = TRUE; - to_worker_queue = g_async_queue_new (); - from_worker_queue = g_async_queue_new (); - worker_thread = g_thread_create (worker, NULL, FALSE, NULL); - g_timeout_add (300, main_thread_check_for_response, NULL); - } -} - - - -typedef struct { - EBookMsg msg; - - EBook *book; - char *uri; - EBookCallback open_response; - gpointer closure; -} LoadUriMsg; - -typedef struct { - EBookMsg msg; - - EBook *book; - EBookStatus status; - EBookCallback open_response; - gpointer closure; -} LoadUriResponse; - -static void -_load_uri_response_handler (EBookMsg *msg) -{ - LoadUriResponse *resp = (LoadUriResponse*)msg; - - resp->open_response (resp->book, resp->status, resp->closure); -} - -static void -_load_uri_response_dtor (EBookMsg *msg) -{ - LoadUriResponse *resp = (LoadUriResponse*)msg; - - g_object_unref (resp->book); - g_free (resp); -} - -static void -_load_uri_handler (EBookMsg *msg) -{ - LoadUriMsg *uri_msg = (LoadUriMsg *)msg; - LoadUriResponse *response; - GError *error = NULL; - - response = g_new (LoadUriResponse, 1); - e_book_msg_init ((EBookMsg*)response, _load_uri_response_handler, _load_uri_response_dtor); - - response->status = E_BOOK_ERROR_OK; - if (!e_book_load_uri (uri_msg->book, uri_msg->uri, FALSE, &error)) { - response->status = error->code; - g_error_free (error); - } - - response->book = uri_msg->book; - response->open_response = uri_msg->open_response; - response->closure = uri_msg->closure; - - g_async_queue_push (from_worker_queue, response); -} - -static void -_load_uri_dtor (EBookMsg *msg) -{ - LoadUriMsg *uri_msg = (LoadUriMsg *)msg; - - g_free (uri_msg->uri); - g_free (uri_msg); -} - -void -e_book_async_load_uri (EBook *book, - const char *uri, - EBookCallback open_response, - gpointer closure) -{ - LoadUriMsg *msg; - - init_async (); - - msg = g_new (LoadUriMsg, 1); - e_book_msg_init ((EBookMsg*)msg, _load_uri_handler, _load_uri_dtor); - - msg->book = g_object_ref (book); - msg->uri = g_strdup (uri); - msg->open_response = open_response; - msg->closure = closure; - - g_async_queue_push (to_worker_queue, msg); -} - - -void -e_book_async_unload_uri (EBook *book) -{ - e_book_unload_uri (book, NULL); -} - - - - -typedef struct { - EBookMsg msg; - - EBookCallback open_response; - gpointer closure; -} DefaultBookMsg; - -typedef struct { - EBookMsg msg; - - EBook *book; - EBookStatus status; - EBookCallback open_response; - gpointer closure; -} DefaultBookResponse; - -static void -_default_book_response_handler (EBookMsg *msg) -{ - LoadUriResponse *resp = (LoadUriResponse*)msg; - - resp->open_response (resp->book, resp->status, resp->closure); -} - -static void -_default_book_response_dtor (EBookMsg *msg) -{ - LoadUriResponse *resp = (LoadUriResponse*)msg; - - g_object_unref (resp->book); - g_free (resp); -} - -static void -_default_book_handler (EBookMsg *msg) -{ - DefaultBookMsg *dfb_msg = (DefaultBookMsg *)msg; - DefaultBookResponse *response; - GError *error = NULL; - - response = g_new (DefaultBookResponse, 1); - e_book_msg_init ((EBookMsg*)response, _default_book_response_handler, _default_book_response_dtor); - - response->status = E_BOOK_ERROR_OK; - if (!e_book_get_default_addressbook (&response->book, &error)) { - response->status = error->code; - g_error_free (error); - } - - response->open_response = dfb_msg->open_response; - response->closure = dfb_msg->closure; - - g_async_queue_push (from_worker_queue, response); -} - -static void -_default_book_dtor (EBookMsg *msg) -{ - DefaultBookMsg *dfb_msg = (DefaultBookMsg *)msg; - - g_free (dfb_msg); -} - -void -e_book_async_get_default_addressbook (EBookCallback open_response, - gpointer closure) -{ - DefaultBookMsg *msg; - - init_async (); - - msg = g_new (DefaultBookMsg, 1); - e_book_msg_init ((EBookMsg*)msg, _default_book_handler, _default_book_dtor); - - msg->open_response = open_response; - msg->closure = closure; - - g_async_queue_push (to_worker_queue, msg); -} - - - -typedef struct { - EBookMsg msg; - - EBook *book; - EBookFieldsCallback cb; - gpointer closure; -} GetFieldsMsg; - -typedef struct { - EBookMsg msg; - - EBook *book; - EBookStatus status; - GList *fields; - EBookFieldsCallback cb; - gpointer closure; -} GetFieldsResponse; - -static void -_get_fields_response_handler (EBookMsg *msg) -{ - GetFieldsResponse *resp = (GetFieldsResponse*)msg; - GList *l; - EList *fields = e_list_new ((EListCopyFunc) g_strdup, - (EListFreeFunc) g_free, - NULL); - - for (l = resp->fields; l; l = l->next) - e_list_append (fields, l->data); - - if (resp->cb) - resp->cb (resp->book, resp->status, fields, resp->closure); - - g_object_unref (fields); -} - -static void -_get_fields_response_dtor (EBookMsg *msg) -{ - GetFieldsResponse *resp = (GetFieldsResponse*)msg; - - g_list_foreach (resp->fields, (GFunc)g_free, NULL); - g_list_free (resp->fields); - g_object_unref (resp->book); - g_free (resp); -} - -static void -_get_fields_handler (EBookMsg *msg) -{ - GetFieldsMsg *fields_msg = (GetFieldsMsg *)msg; - GetFieldsResponse *response; - GError *error = NULL; - - response = g_new (GetFieldsResponse, 1); - e_book_msg_init ((EBookMsg*)response, _get_fields_response_handler, _get_fields_response_dtor); - - response->status = E_BOOK_ERROR_OK; - if (!e_book_get_supported_fields (fields_msg->book, &response->fields, &error)) { - response->status = error->code; - g_error_free (error); - } - response->book = fields_msg->book; - response->cb = fields_msg->cb; - response->closure = fields_msg->closure; - - g_async_queue_push (from_worker_queue, response); -} - -guint -e_book_async_get_supported_fields (EBook *book, - EBookFieldsCallback cb, - gpointer closure) -{ - GetFieldsMsg *msg; - - init_async (); - - msg = g_new (GetFieldsMsg, 1); - e_book_msg_init ((EBookMsg*)msg, _get_fields_handler, (EBookMsgDtor)g_free); - - msg->book = g_object_ref (book); - msg->cb = cb; - msg->closure = closure; - - g_async_queue_push (to_worker_queue, msg); - - return 0; -} - - - -typedef struct { - EBookMsg msg; - - EBook *book; - EBookAuthMethodsCallback cb; - gpointer closure; -} GetMethodsMsg; - -typedef struct { - EBookMsg msg; - - EBook *book; - EBookStatus status; - GList *methods; - EBookAuthMethodsCallback cb; - gpointer closure; -} GetMethodsResponse; - -static void -_get_methods_response_handler (EBookMsg *msg) -{ - GetMethodsResponse *resp = (GetMethodsResponse*)msg; - GList *l; - EList *methods = e_list_new ((EListCopyFunc) g_strdup, - (EListFreeFunc) g_free, - NULL); - - for (l = resp->methods; l; l = l->next) - e_list_append (methods, l->data); - - if (resp->cb) - resp->cb (resp->book, resp->status, methods, resp->closure); - - g_object_unref (methods); -} - -static void -_get_methods_response_dtor (EBookMsg *msg) -{ - GetMethodsResponse *resp = (GetMethodsResponse*)msg; - - g_list_foreach (resp->methods, (GFunc)g_free, NULL); - g_list_free (resp->methods); - g_object_unref (resp->book); - g_free (resp); -} - -static void -_get_methods_handler (EBookMsg *msg) -{ - GetMethodsMsg *methods_msg = (GetMethodsMsg *)msg; - GetMethodsResponse *response; - GError *error = NULL; - - response = g_new (GetMethodsResponse, 1); - e_book_msg_init ((EBookMsg*)response, _get_methods_response_handler, _get_methods_response_dtor); - - response->status = E_BOOK_ERROR_OK; - if (!e_book_get_supported_auth_methods (methods_msg->book, &response->methods, &error)) { - response->status = error->code; - g_error_free (error); - } - - response->book = methods_msg->book; - response->cb = methods_msg->cb; - response->closure = methods_msg->closure; - - g_async_queue_push (from_worker_queue, response); -} - -guint -e_book_async_get_supported_auth_methods (EBook *book, - EBookAuthMethodsCallback cb, - gpointer closure) -{ - GetMethodsMsg *msg; - - init_async (); - - msg = g_new (GetMethodsMsg, 1); - e_book_msg_init ((EBookMsg*)msg, _get_methods_handler, (EBookMsgDtor)g_free); - - msg->book = g_object_ref (book); - msg->cb = cb; - msg->closure = closure; - - g_async_queue_push (to_worker_queue, msg); - - return 0; -} - - - -typedef struct { - EBookMsg msg; - - EBook *book; - char *user; - char *passwd; - char *auth_method; - EBookCallback cb; - gpointer closure; -} AuthUserMsg; - -typedef struct { - EBookMsg msg; - - EBook *book; - EBookStatus status; - EBookCallback cb; - gpointer closure; -} AuthUserResponse; - -static void -_auth_user_response_handler (EBookMsg *msg) -{ - AuthUserResponse *resp = (AuthUserResponse*)msg; - - if (resp->cb) - resp->cb (resp->book, resp->status, resp->closure); -} - -static void -_auth_user_response_dtor (EBookMsg *msg) -{ - AuthUserResponse *resp = (AuthUserResponse*)msg; - - g_object_unref (resp->book); - g_free (resp); -} - -static void -_auth_user_handler (EBookMsg *msg) -{ - AuthUserMsg *auth_msg = (AuthUserMsg *)msg; - AuthUserResponse *response; - GError *error = NULL; - - response = g_new (AuthUserResponse, 1); - e_book_msg_init ((EBookMsg*)response, _auth_user_response_handler, _auth_user_response_dtor); - - response->status = E_BOOK_ERROR_OK; - if (!e_book_authenticate_user (auth_msg->book, auth_msg->user, auth_msg->passwd, auth_msg->auth_method, &error)) { - response->status = error->code; - g_error_free (error); - } - response->book = auth_msg->book; - response->cb = auth_msg->cb; - response->closure = auth_msg->closure; - - g_async_queue_push (from_worker_queue, response); -} - -static void -_auth_user_dtor (EBookMsg *msg) -{ - AuthUserMsg *auth_msg = (AuthUserMsg *)msg; - - g_free (auth_msg->user); - g_free (auth_msg->passwd); - g_free (auth_msg->auth_method); - - g_free (auth_msg); -} - -/* User authentication. */ -void -e_book_async_authenticate_user (EBook *book, - const char *user, - const char *passwd, - const char *auth_method, - EBookCallback cb, - gpointer closure) -{ - AuthUserMsg *msg; - - init_async (); - - msg = g_new (AuthUserMsg, 1); - e_book_msg_init ((EBookMsg*)msg, _auth_user_handler, _auth_user_dtor); - - msg->book = g_object_ref (book); - msg->user = g_strdup (user); - msg->passwd = g_strdup (passwd); - msg->auth_method = g_strdup (auth_method); - msg->cb = cb; - msg->closure = closure; - - g_async_queue_push (to_worker_queue, msg); -} - - - -typedef struct { - EBookMsg msg; - - EBook *book; - char *id; - EBookContactCallback cb; - gpointer closure; -} GetContactMsg; - -typedef struct { - EBookMsg msg; - - EBook *book; - EContact *contact; - EBookStatus status; - EBookContactCallback cb; - gpointer closure; -} GetContactResponse; - -static void -_get_contact_response_handler (EBookMsg *msg) -{ - GetContactResponse *resp = (GetContactResponse*)msg; - - if (resp->cb) - resp->cb (resp->book, resp->status, resp->contact, resp->closure); -} - -static void -_get_contact_response_dtor (EBookMsg *msg) -{ - GetContactResponse *resp = (GetContactResponse*)msg; - - g_object_unref (resp->contact); - g_object_unref (resp->book); - g_free (resp); -} - -static void -_get_contact_handler (EBookMsg *msg) -{ - GetContactMsg *get_contact_msg = (GetContactMsg *)msg; - GetContactResponse *response; - GError *error = NULL; - - response = g_new (GetContactResponse, 1); - e_book_msg_init ((EBookMsg*)response, _get_contact_response_handler, _get_contact_response_dtor); - - response->status = E_BOOK_ERROR_OK; - if (!e_book_get_contact (get_contact_msg->book, get_contact_msg->id, &response->contact, &error)) { - response->status = error->code; - g_error_free (error); - } - response->book = get_contact_msg->book; - response->cb = get_contact_msg->cb; - response->closure = get_contact_msg->closure; - - g_async_queue_push (from_worker_queue, response); -} - -static void -_get_contact_dtor (EBookMsg *msg) -{ - GetContactMsg *get_contact_msg = (GetContactMsg *)msg; - - g_free (get_contact_msg->id); - g_free (get_contact_msg); -} - -/* Fetching contacts. */ -guint -e_book_async_get_contact (EBook *book, - const char *id, - EBookContactCallback cb, - gpointer closure) -{ - GetContactMsg *msg; - - init_async (); - - msg = g_new (GetContactMsg, 1); - e_book_msg_init ((EBookMsg*)msg, _get_contact_handler, _get_contact_dtor); - - msg->book = g_object_ref (book); - msg->id = g_strdup (id); - msg->cb = cb; - msg->closure = closure; - - g_async_queue_push (to_worker_queue, msg); - - return 0; -} - - - -/* Deleting cards. */ -gboolean -e_book_async_remove_contact (EBook *book, - EContact *contact, - EBookCallback cb, - gpointer closure) -{ - const char *id = e_contact_get_const (contact, E_CONTACT_UID); - - return e_book_async_remove_contact_by_id (book, id, cb, closure); -} - -gboolean -e_book_async_remove_contact_by_id (EBook *book, - const char *id, - EBookCallback cb, - gpointer closure) -{ - GList *list = g_list_append (NULL, g_strdup (id)); - - return e_book_async_remove_contacts (book, list, cb, closure); -} - - -typedef struct { - EBookMsg msg; - - EBook *book; - GList *id_list; - EBookCallback cb; - gpointer closure; -} RemoveContactsMsg; - -typedef struct { - EBookMsg msg; - - EBook *book; - EBookStatus status; - EBookCallback cb; - gpointer closure; -} RemoveContactsResponse; - -static void -_remove_contacts_response_handler (EBookMsg *msg) -{ - RemoveContactsResponse *resp = (RemoveContactsResponse*)msg; - - if (resp->cb) - resp->cb (resp->book, resp->status, resp->closure); -} - -static void -_remove_contacts_response_dtor (EBookMsg *msg) -{ - RemoveContactsResponse *resp = (RemoveContactsResponse*)msg; - - g_object_unref (resp->book); - g_free (resp); -} - -static void -_remove_contacts_handler (EBookMsg *msg) -{ - RemoveContactsMsg *remove_contacts_msg = (RemoveContactsMsg *)msg; - RemoveContactsResponse *response; - GError *error = NULL; - - response = g_new (RemoveContactsResponse, 1); - e_book_msg_init ((EBookMsg*)response, _remove_contacts_response_handler, _remove_contacts_response_dtor); - - response->status = E_BOOK_ERROR_OK; - if (!e_book_remove_contacts (remove_contacts_msg->book, remove_contacts_msg->id_list, &error)) { - response->status = error->code; - g_error_free (error); - } - response->book = remove_contacts_msg->book; - response->cb = remove_contacts_msg->cb; - response->closure = remove_contacts_msg->closure; - - g_async_queue_push (from_worker_queue, response); -} - -static void -_remove_contacts_dtor (EBookMsg *msg) -{ - RemoveContactsMsg *remove_contacts_msg = (RemoveContactsMsg *)msg; - - g_list_foreach (remove_contacts_msg->id_list, (GFunc)g_free, NULL); - g_list_free (remove_contacts_msg->id_list); - g_free (remove_contacts_msg); -} - -gboolean -e_book_async_remove_contacts (EBook *book, - GList *id_list, - EBookCallback cb, - gpointer closure) -{ - RemoveContactsMsg *msg; - GList *l; - init_async (); - - msg = g_new (RemoveContactsMsg, 1); - e_book_msg_init ((EBookMsg*)msg, _remove_contacts_handler, _remove_contacts_dtor); - - msg->book = g_object_ref (book); - msg->id_list = g_list_copy (id_list); - for (l = msg->id_list; l; l = l->next) - l->data = g_strdup (l->data); - msg->cb = cb; - msg->closure = closure; - - g_async_queue_push (to_worker_queue, msg); - - return 0; -} - - - -/* Adding contacts. */ -typedef struct { - EBookMsg msg; - - EBook *book; - EContact *contact; - EBookIdCallback cb; - gpointer closure; -} AddContactMsg; - -typedef struct { - EBookMsg msg; - - EBook *book; - char *id; - EBookStatus status; - EBookIdCallback cb; - gpointer closure; -} AddContactResponse; - -static void -_add_contact_response_handler (EBookMsg *msg) -{ - AddContactResponse *resp = (AddContactResponse*)msg; - - if (resp->cb) - resp->cb (resp->book, resp->status, resp->id, resp->closure); -} - -static void -_add_contact_response_dtor (EBookMsg *msg) -{ - AddContactResponse *resp = (AddContactResponse*)msg; - - g_object_unref (resp->book); - g_free (resp->id); - g_free (resp); -} - -static void -_add_contact_handler (EBookMsg *msg) -{ - AddContactMsg *add_contact_msg = (AddContactMsg *)msg; - AddContactResponse *response; - GError *error = NULL; - - response = g_new (AddContactResponse, 1); - e_book_msg_init ((EBookMsg*)response, _add_contact_response_handler, _add_contact_response_dtor); - - response->status = E_BOOK_ERROR_OK; - if (!e_book_add_contact (add_contact_msg->book, add_contact_msg->contact, &error)) { - response->status = error->code; - response->id = NULL; - g_error_free (error); - } - else { - response->id = e_contact_get (add_contact_msg->contact, E_CONTACT_UID); - } - response->book = add_contact_msg->book; - response->cb = add_contact_msg->cb; - response->closure = add_contact_msg->closure; - - g_async_queue_push (from_worker_queue, response); -} - -static void -_add_contact_dtor (EBookMsg *msg) -{ - AddContactMsg *add_contact_msg = (AddContactMsg *)msg; - - g_object_unref (add_contact_msg->contact); - g_free (add_contact_msg); -} - -gboolean -e_book_async_add_contact (EBook *book, - EContact *contact, - EBookIdCallback cb, - gpointer closure) -{ - AddContactMsg *msg; - - init_async (); - - msg = g_new (AddContactMsg, 1); - e_book_msg_init ((EBookMsg*)msg, _add_contact_handler, _add_contact_dtor); - - msg->book = g_object_ref (book); - msg->contact = g_object_ref (contact); /* XXX maybe we should _duplicate it here instead */ - msg->cb = cb; - msg->closure = closure; - - g_async_queue_push (to_worker_queue, msg); - - return TRUE; -} - - - -/* Modifying cards. */ -typedef struct { - EBookMsg msg; - - EBook *book; - EContact *contact; - EBookCallback cb; - gpointer closure; -} CommitContactMsg; - -typedef struct { - EBookMsg msg; - - EBook *book; - EBookStatus status; - EBookCallback cb; - gpointer closure; -} CommitContactResponse; - -static void -_commit_contact_response_handler (EBookMsg *msg) -{ - CommitContactResponse *resp = (CommitContactResponse*)msg; - - if (resp->cb) - resp->cb (resp->book, resp->status, resp->closure); -} - -static void -_commit_contact_response_dtor (EBookMsg *msg) -{ - CommitContactResponse *resp = (CommitContactResponse*)msg; - - g_object_unref (resp->book); - g_free (resp); -} - -static void -_commit_contact_handler (EBookMsg *msg) -{ - CommitContactMsg *commit_contact_msg = (CommitContactMsg *)msg; - CommitContactResponse *response; - GError *error = NULL; - - response = g_new (CommitContactResponse, 1); - e_book_msg_init ((EBookMsg*)response, _commit_contact_response_handler, _commit_contact_response_dtor); - - response->status = E_BOOK_ERROR_OK; - if (!e_book_commit_contact (commit_contact_msg->book, commit_contact_msg->contact, &error)) { - response->status = error->code; - g_error_free (error); - } - response->book = commit_contact_msg->book; - response->cb = commit_contact_msg->cb; - response->closure = commit_contact_msg->closure; - - g_async_queue_push (from_worker_queue, response); -} - -static void -_commit_contact_dtor (EBookMsg *msg) -{ - CommitContactMsg *commit_contact_msg = (CommitContactMsg *)msg; - - g_object_unref (commit_contact_msg->contact); - g_free (commit_contact_msg); -} - - -gboolean -e_book_async_commit_contact (EBook *book, - EContact *contact, - EBookCallback cb, - gpointer closure) -{ - CommitContactMsg *msg; - - init_async (); - - msg = g_new (CommitContactMsg, 1); - e_book_msg_init ((EBookMsg*)msg, _commit_contact_handler, _commit_contact_dtor); - - msg->book = g_object_ref (book); - msg->contact = g_object_ref (contact); /* XXX maybe we should _duplicate it here instead */ - msg->cb = cb; - msg->closure = closure; - - g_async_queue_push (to_worker_queue, msg); - - return TRUE; -} - - - -typedef struct { - EBookMsg msg; - - EBook *book; - EBookQuery *query; - EBookBookViewCallback cb; - gpointer closure; -} GetBookViewMsg; - -typedef struct { - EBookMsg msg; - - EBook *book; - EBookStatus status; - EBookView *book_view; - EBookBookViewCallback cb; - gpointer closure; -} GetBookViewResponse; - -static void -_get_book_view_response_handler (EBookMsg *msg) -{ - GetBookViewResponse *resp = (GetBookViewResponse*)msg; - - if (resp->cb) - resp->cb (resp->book, resp->status, resp->book_view, resp->closure); -} - -static void -_get_book_view_response_dtor (EBookMsg *msg) -{ - GetBookViewResponse *resp = (GetBookViewResponse*)msg; - - g_object_unref (resp->book); - g_object_unref (resp->book_view); - g_free (resp); -} - -static void -_get_book_view_handler (EBookMsg *msg) -{ - GetBookViewMsg *view_msg = (GetBookViewMsg *)msg; - GetBookViewResponse *response; - GError *error = NULL; - - response = g_new (GetBookViewResponse, 1); - e_book_msg_init ((EBookMsg*)response, _get_book_view_response_handler, _get_book_view_response_dtor); - - response->status = E_BOOK_ERROR_OK; - if (!e_book_get_book_view (view_msg->book, view_msg->query, NULL, -1, &response->book_view, &error)) { - response->status = error->code; - g_error_free (error); - } - response->book = view_msg->book; - response->cb = view_msg->cb; - response->closure = view_msg->closure; - - g_async_queue_push (from_worker_queue, response); -} - -static void -_get_book_view_dtor (EBookMsg *msg) -{ - GetBookViewMsg *view_msg = (GetBookViewMsg *)msg; - - e_book_query_unref (view_msg->query); - g_free (view_msg); -} - -guint -e_book_async_get_book_view (EBook *book, - const gchar *query, - EBookBookViewCallback cb, - gpointer closure) -{ - GetBookViewMsg *msg; - - init_async (); - - msg = g_new (GetBookViewMsg, 1); - e_book_msg_init ((EBookMsg*)msg, _get_book_view_handler, _get_book_view_dtor); - - msg->book = g_object_ref (book); - msg->query = e_book_query_from_string (query); - msg->cb = cb; - msg->closure = closure; - - g_async_queue_push (to_worker_queue, msg); - - return 0; -} - - - -typedef struct { - EBookMsg msg; - - EBook *book; - EBookQuery *query; - EBookContactsCallback cb; - gpointer closure; -} GetContactsMsg; - -typedef struct { - EBookMsg msg; - - EBook *book; - EBookStatus status; - GList *contacts; - EBookContactsCallback cb; - gpointer closure; -} GetContactsResponse; - -static void -_get_contacts_response_handler (EBookMsg *msg) -{ - GetContactsResponse *resp = (GetContactsResponse*)msg; - - if (resp->cb) - resp->cb (resp->book, resp->status, resp->contacts, resp->closure); -} - -static void -_get_contacts_response_dtor (EBookMsg *msg) -{ - GetContactsResponse *resp = (GetContactsResponse*)msg; - - g_object_unref (resp->book); - g_free (resp); -} - -static void -_get_contacts_handler (EBookMsg *msg) -{ - GetContactsMsg *view_msg = (GetContactsMsg *)msg; - GetContactsResponse *response; - GError *error = NULL; - - response = g_new (GetContactsResponse, 1); - e_book_msg_init ((EBookMsg*)response, _get_contacts_response_handler, _get_contacts_response_dtor); - - response->status = E_BOOK_ERROR_OK; - if (!e_book_get_contacts (view_msg->book, view_msg->query, &response->contacts, &error)) { - response->status = error->code; - g_error_free (error); - } - response->book = view_msg->book; - response->cb = view_msg->cb; - response->closure = view_msg->closure; - - g_async_queue_push (from_worker_queue, response); -} - -static void -_get_contacts_dtor (EBookMsg *msg) -{ - GetContactsMsg *view_msg = (GetContactsMsg *)msg; - - e_book_query_unref (view_msg->query); - g_free (view_msg); -} - -guint -e_book_async_get_contacts (EBook *book, - const gchar *query, - EBookContactsCallback cb, - gpointer closure) -{ - GetContactsMsg *msg; - - init_async (); - - msg = g_new (GetContactsMsg, 1); - e_book_msg_init ((EBookMsg*)msg, _get_contacts_handler, _get_contacts_dtor); - - msg->book = g_object_ref (book); - msg->query = e_book_query_from_string (query); - msg->cb = cb; - msg->closure = closure; - - g_async_queue_push (to_worker_queue, msg); - - return 0; -} diff --git a/addressbook/backend/ebook/e-book-async.h b/addressbook/backend/ebook/e-book-async.h deleted file mode 100644 index 097f3cff61..0000000000 --- a/addressbook/backend/ebook/e-book-async.h +++ /dev/null @@ -1,107 +0,0 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */ -/* - * The Evolution addressbook client object. - * - * Author: - * Chris Toshok (toshok@ximian.com) - * - * Copyright (C) 2003, Ximian, Inc. - */ - -#ifndef __E_BOOK_ASYNC_H__ -#define __E_BOOK_ASYNC_H__ - -#include <glib.h> -#include <glib-object.h> - -#include <e-util/e-list.h> -#include <ebook/e-contact.h> -#include <ebook/e-book.h> - -G_BEGIN_DECLS - -/* Callbacks for asynchronous functions. */ -typedef void (*EBookCallback) (EBook *book, EBookStatus status, gpointer closure); -typedef void (*EBookOpenProgressCallback) (EBook *book, - const char *status_message, - short percent, - gpointer closure); -typedef void (*EBookIdCallback) (EBook *book, EBookStatus status, const char *id, gpointer closure); -typedef void (*EBookContactCallback) (EBook *book, EBookStatus status, EContact *contact, gpointer closure); -typedef void (*EBookContactsCallback) (EBook *book, EBookStatus status, GList *contacts, gpointer closure); -typedef void (*EBookBookViewCallback) (EBook *book, EBookStatus status, EBookView *book_view, gpointer closure); -typedef void (*EBookFieldsCallback) (EBook *book, EBookStatus status, EList *fields, gpointer closure); -typedef void (*EBookAuthMethodsCallback) (EBook *book, EBookStatus status, EList *auth_methods, gpointer closure); - -void e_book_async_load_uri (EBook *book, - const char *uri, - EBookCallback open_response, - gpointer closure); - -void e_book_async_get_default_addressbook (EBookCallback open_response, - gpointer closure); - -void e_book_async_unload_uri (EBook *book); - -guint e_book_async_get_supported_fields (EBook *book, - EBookFieldsCallback cb, - gpointer closure); - -guint e_book_async_get_supported_auth_methods (EBook *book, - EBookAuthMethodsCallback cb, - gpointer closure); - -/* User authentication. */ -void e_book_async_authenticate_user (EBook *book, - const char *user, - const char *passwd, - const char *auth_method, - EBookCallback cb, - gpointer closure); - -/* Fetching cards. */ -guint e_book_async_get_contact (EBook *book, - const char *id, - EBookContactCallback cb, - gpointer closure); - -guint e_book_async_get_contacts (EBook *book, - const char *query, - EBookContactsCallback cb, - gpointer closure); - -/* Deleting cards. */ -gboolean e_book_async_remove_contact (EBook *book, - EContact *contact, - EBookCallback cb, - gpointer closure); -gboolean e_book_async_remove_contact_by_id (EBook *book, - const char *id, - EBookCallback cb, - gpointer closure); - -gboolean e_book_async_remove_contacts (EBook *book, - GList *id_list, - EBookCallback cb, - gpointer closure); - -/* Adding cards. */ -gboolean e_book_async_add_contact (EBook *book, - EContact *contact, - EBookIdCallback cb, - gpointer closure); - -/* Modifying cards. */ -gboolean e_book_async_commit_contact (EBook *book, - EContact *contact, - EBookCallback cb, - gpointer closure); - -guint e_book_async_get_book_view (EBook *book, - const gchar *query, /* XXX this needs to change to an EBookQuery */ - EBookBookViewCallback cb, - gpointer closure); - -G_END_DECLS - -#endif /* ! __E_BOOK_H__ */ diff --git a/addressbook/backend/ebook/e-book-listener.c b/addressbook/backend/ebook/e-book-listener.c deleted file mode 100644 index 26ed54d2ec..0000000000 --- a/addressbook/backend/ebook/e-book-listener.c +++ /dev/null @@ -1,394 +0,0 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */ -/* - * Exports the BookListener interface. Maintains a queue of messages - * which come in on the interface. - * - * Author: - * Nat Friedman (nat@ximian.com) - * - * Copyright 2000, Ximian, Inc. - */ - -#include <config.h> -#include <bonobo/bonobo-main.h> -#include "e-contact.h" -#include "e-book-listener.h" -#include "e-book-marshal.h" - -static EBookStatus e_book_listener_convert_status (GNOME_Evolution_Addressbook_CallStatus status); - -enum { - RESPONSE, - LAST_SIGNAL -}; - -static guint e_book_listener_signals [LAST_SIGNAL]; - -static BonoboObjectClass *parent_class; - -struct _EBookListenerPrivate { - guint stopped : 1; -}; - -static EBookStatus -e_book_listener_convert_status (const GNOME_Evolution_Addressbook_CallStatus status) -{ - switch (status) { - case GNOME_Evolution_Addressbook_Success: - return E_BOOK_ERROR_OK; - case GNOME_Evolution_Addressbook_RepositoryOffline: - return E_BOOK_ERROR_REPOSITORY_OFFLINE; - case GNOME_Evolution_Addressbook_PermissionDenied: - return E_BOOK_ERROR_PERMISSION_DENIED; - case GNOME_Evolution_Addressbook_ContactNotFound: - return E_BOOK_ERROR_CONTACT_NOT_FOUND; - case GNOME_Evolution_Addressbook_ContactIdAlreadyExists: - return E_BOOK_ERROR_CONTACT_ID_ALREADY_EXISTS; - case GNOME_Evolution_Addressbook_AuthenticationFailed: - return E_BOOK_ERROR_AUTHENTICATION_FAILED; - case GNOME_Evolution_Addressbook_AuthenticationRequired: - return E_BOOK_ERROR_AUTHENTICATION_REQUIRED; - case GNOME_Evolution_Addressbook_TLSNotAvailable: - return E_BOOK_ERROR_TLS_NOT_AVAILABLE; - case GNOME_Evolution_Addressbook_NoSuchBook: - return E_BOOK_ERROR_NO_SUCH_BOOK; - case GNOME_Evolution_Addressbook_OtherError: - default: - return E_BOOK_ERROR_OTHER_ERROR; - } -} - -static void -impl_BookListener_respond_create_contact (PortableServer_Servant servant, - const GNOME_Evolution_Addressbook_CallStatus status, - const CORBA_char* id, - CORBA_Environment *ev) -{ - EBookListener *listener = E_BOOK_LISTENER (bonobo_object (servant)); - EBookListenerResponse response; - - response.op = CreateContactResponse; - response.status = e_book_listener_convert_status (status); - response.id = g_strdup (id); - - g_signal_emit (listener, e_book_listener_signals [RESPONSE], 0, &response); - - g_free (response.id); -} - -static void -impl_BookListener_respond_remove_contacts (PortableServer_Servant servant, - const GNOME_Evolution_Addressbook_CallStatus status, - CORBA_Environment *ev) -{ - EBookListener *listener = E_BOOK_LISTENER (bonobo_object (servant)); - EBookListenerResponse response; - - response.op = RemoveContactResponse; - response.status = e_book_listener_convert_status (status); - - g_signal_emit (listener, e_book_listener_signals [RESPONSE], 0, &response); -} - -static void -impl_BookListener_respond_modify_contact (PortableServer_Servant servant, - const GNOME_Evolution_Addressbook_CallStatus status, - CORBA_Environment *ev) -{ - EBookListener *listener = E_BOOK_LISTENER (bonobo_object (servant)); - EBookListenerResponse response; - - response.op = ModifyContactResponse; - response.status = e_book_listener_convert_status (status); - - g_signal_emit (listener, e_book_listener_signals [RESPONSE], 0, &response); -} - -static void -impl_BookListener_respond_get_contact (PortableServer_Servant servant, - const GNOME_Evolution_Addressbook_CallStatus status, - const CORBA_char* card, - CORBA_Environment *ev) -{ - EBookListener *listener = E_BOOK_LISTENER (bonobo_object (servant)); - EBookListenerResponse response; - - response.op = GetContactResponse; - response.status = e_book_listener_convert_status (status); - response.vcard = g_strdup (card); - - g_signal_emit (listener, e_book_listener_signals [RESPONSE], 0, &response); - - g_free (response.vcard); -} - -static void -impl_BookListener_respond_get_contact_list (PortableServer_Servant servant, - const GNOME_Evolution_Addressbook_CallStatus status, - const GNOME_Evolution_Addressbook_stringlist *cards, - CORBA_Environment *ev) -{ - EBookListener *listener = E_BOOK_LISTENER (bonobo_object (servant)); - EBookListenerResponse response; - int i; - - if (listener->priv->stopped) - return; - - response.op = GetContactListResponse; - response.status = e_book_listener_convert_status (status); - response.list = NULL; - - for (i = 0; i < cards->_length; i ++) { - response.list = g_list_prepend (response.list, e_contact_new_from_vcard (cards->_buffer[i])); - } - - g_signal_emit (listener, e_book_listener_signals [RESPONSE], 0, &response); - - /* XXX free response.list? */ -} - -static void -impl_BookListener_respond_get_view (PortableServer_Servant servant, - const GNOME_Evolution_Addressbook_CallStatus status, - const GNOME_Evolution_Addressbook_BookView book_view, - CORBA_Environment *ev) -{ - EBookListener *listener = E_BOOK_LISTENER (bonobo_object (servant)); - EBookListenerResponse response; - - printf ("impl_BookListener_respond_get_view\n"); - - if (listener->priv->stopped) - return; - - response.op = GetBookViewResponse; - response.status = e_book_listener_convert_status (status); - response.book_view = bonobo_object_dup_ref (book_view, ev); - - g_signal_emit (listener, e_book_listener_signals [RESPONSE], 0, &response); -} - -static void -impl_BookListener_respond_get_changes (PortableServer_Servant servant, - const GNOME_Evolution_Addressbook_CallStatus status, - const GNOME_Evolution_Addressbook_BookChangeList *changes, - CORBA_Environment *ev) -{ - EBookListener *listener = E_BOOK_LISTENER (bonobo_object (servant)); - EBookListenerResponse response; - int i; - - response.op = GetChangesResponse; - response.status = e_book_listener_convert_status (status); - response.list = NULL; - - for (i = 0; i < changes->_length; i ++) { - EBookChange *change = g_new (EBookChange, 1); - GNOME_Evolution_Addressbook_BookChangeItem corba_change = changes->_buffer[i]; - - switch (corba_change.changeType) { - case GNOME_Evolution_Addressbook_ContactAdded: - change->change_type = E_BOOK_CHANGE_CARD_ADDED; - break; - case GNOME_Evolution_Addressbook_ContactDeleted: - change->change_type = E_BOOK_CHANGE_CARD_DELETED; - break; - case GNOME_Evolution_Addressbook_ContactModified: - change->change_type = E_BOOK_CHANGE_CARD_MODIFIED; - break; - } - change->contact = e_contact_new_from_vcard (corba_change.vcard); - - response.list = g_list_prepend (response.list, change); - } - - g_signal_emit (listener, e_book_listener_signals [RESPONSE], 0, &response); -} - -static void -impl_BookListener_respond_open_book (PortableServer_Servant servant, - const GNOME_Evolution_Addressbook_CallStatus status, - CORBA_Environment *ev) -{ - EBookListener *listener = E_BOOK_LISTENER (bonobo_object (servant)); - EBookListenerResponse response; - - response.op = OpenBookResponse; - response.status = e_book_listener_convert_status (status); - - g_signal_emit (listener, e_book_listener_signals [RESPONSE], 0, &response); -} - -static void -impl_BookListener_respond_remove_book (PortableServer_Servant servant, - const GNOME_Evolution_Addressbook_CallStatus status, - CORBA_Environment *ev) -{ - EBookListener *listener = E_BOOK_LISTENER (bonobo_object (servant)); - EBookListenerResponse response; - - response.op = RemoveBookResponse; - response.status = e_book_listener_convert_status (status); - - g_signal_emit (listener, e_book_listener_signals [RESPONSE], 0, &response); -} - -static void -impl_BookListener_respond_authentication_result (PortableServer_Servant servant, - const GNOME_Evolution_Addressbook_CallStatus status, - CORBA_Environment *ev) -{ - EBookListener *listener = E_BOOK_LISTENER (bonobo_object (servant)); - EBookListenerResponse response; - - response.op = AuthenticationResponse; - response.status = e_book_listener_convert_status (status); - - g_signal_emit (listener, e_book_listener_signals [RESPONSE], 0, &response); -} - -static void -impl_BookListener_respond_get_supported_fields (PortableServer_Servant servant, - const GNOME_Evolution_Addressbook_CallStatus status, - const GNOME_Evolution_Addressbook_stringlist *fields, - CORBA_Environment *ev) -{ - EBookListener *listener = E_BOOK_LISTENER (bonobo_object (servant)); - EBookListenerResponse response; - int i; - - response.op = GetSupportedFieldsResponse; - response.status = e_book_listener_convert_status (status); - response.list = NULL; - - for (i = 0; i < fields->_length; i ++) - response.list = g_list_prepend (response.list, g_strdup (fields->_buffer[i])); - - g_signal_emit (listener, e_book_listener_signals [RESPONSE], 0, &response); -} - -static void -impl_BookListener_respond_get_supported_auth_methods (PortableServer_Servant servant, - const GNOME_Evolution_Addressbook_CallStatus status, - const GNOME_Evolution_Addressbook_stringlist *auth_methods, - CORBA_Environment *ev) -{ - EBookListener *listener = E_BOOK_LISTENER (bonobo_object (servant)); - EBookListenerResponse response; - int i; - - response.op = GetSupportedAuthMethodsResponse; - response.status = e_book_listener_convert_status (status); - response.list = NULL; - - for (i = 0; i < auth_methods->_length; i ++) - response.list = g_list_prepend (response.list, g_strdup (auth_methods->_buffer[i])); - - g_signal_emit (listener, e_book_listener_signals [RESPONSE], 0, &response); -} - -static void -impl_BookListener_report_writable (PortableServer_Servant servant, - const CORBA_boolean writable, - CORBA_Environment *ev) -{ - EBookListener *listener = E_BOOK_LISTENER (bonobo_object (servant)); - EBookListenerResponse response; - - response.op = WritableStatusEvent; - response.writable = writable; - - g_signal_emit (listener, e_book_listener_signals [RESPONSE], 0, &response); -} - -static void -impl_BookListener_respond_progress (PortableServer_Servant servant, - const CORBA_char * message, - const CORBA_short percent, - CORBA_Environment *ev) -{ -} - -static void -e_book_listener_construct (EBookListener *listener) -{ - /* nothing to do here */ -} - -/** - * e_book_listener_new: - * @book: the #EBook for which the listener is to be bound - * - * Creates and returns a new #EBookListener for the book. - * - * Returns: a new #EBookListener - */ -EBookListener * -e_book_listener_new () -{ - EBookListener *listener; - - listener = g_object_new (E_TYPE_BOOK_LISTENER, - "poa", bonobo_poa_get_threaded (ORBIT_THREAD_HINT_PER_REQUEST, NULL), - NULL); - - e_book_listener_construct (listener); - - return listener; -} - -static void -e_book_listener_init (EBookListener *listener) -{ - listener->priv = g_new0 (EBookListenerPrivate, 1); -} - -void -e_book_listener_stop (EBookListener *listener) -{ - g_return_if_fail (E_IS_BOOK_LISTENER (listener)); - - listener->priv->stopped = TRUE; -} - -static void -e_book_listener_class_init (EBookListenerClass *klass) -{ - GObjectClass *object_class = G_OBJECT_CLASS (klass); - POA_GNOME_Evolution_Addressbook_BookListener__epv *epv; - - parent_class = g_type_class_ref (BONOBO_TYPE_OBJECT); - - e_book_listener_signals [RESPONSE] = - g_signal_new ("response", - G_OBJECT_CLASS_TYPE (object_class), - G_SIGNAL_RUN_LAST, - G_STRUCT_OFFSET (EBookListenerClass, response), - NULL, NULL, - e_book_marshal_NONE__POINTER, - G_TYPE_NONE, 1, - G_TYPE_POINTER); - - epv = &klass->epv; - epv->notifyProgress = impl_BookListener_respond_progress; - epv->notifyBookOpened = impl_BookListener_respond_open_book; - epv->notifyBookRemoved = impl_BookListener_respond_remove_book; - epv->notifyContactCreated = impl_BookListener_respond_create_contact; - epv->notifyContactsRemoved = impl_BookListener_respond_remove_contacts; - epv->notifyContactModified = impl_BookListener_respond_modify_contact; - epv->notifyAuthenticationResult = impl_BookListener_respond_authentication_result; - epv->notifySupportedFields = impl_BookListener_respond_get_supported_fields; - epv->notifySupportedAuthMethods = impl_BookListener_respond_get_supported_auth_methods; - epv->notifyContactRequested = impl_BookListener_respond_get_contact; - epv->notifyContactListRequested = impl_BookListener_respond_get_contact_list; - epv->notifyViewRequested = impl_BookListener_respond_get_view; - epv->notifyChangesRequested = impl_BookListener_respond_get_changes; - epv->notifyWritable = impl_BookListener_report_writable; -} - -BONOBO_TYPE_FUNC_FULL ( - EBookListener, - GNOME_Evolution_Addressbook_BookListener, - BONOBO_TYPE_OBJECT, - e_book_listener); diff --git a/addressbook/backend/ebook/e-book-listener.h b/addressbook/backend/ebook/e-book-listener.h deleted file mode 100644 index 4d1f0c0231..0000000000 --- a/addressbook/backend/ebook/e-book-listener.h +++ /dev/null @@ -1,112 +0,0 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */ -/* - * A client-side GObject which exposes the - * Evolution:BookListener interface. - * - * Author: - * Nat Friedman (nat@ximian.com) - * - * Copyright 2000, Ximian, Inc. - */ - -#ifndef __E_BOOK_LISTENER_H__ -#define __E_BOOK_LISTENER_H__ - -#include <bonobo/bonobo-object.h> -#include <ebook/addressbook.h> -#include <ebook/e-book-types.h> - -#define E_TYPE_BOOK_LISTENER (e_book_listener_get_type ()) -#define E_BOOK_LISTENER(o) (G_TYPE_CHECK_INSTANCE_CAST ((o), E_TYPE_BOOK_LISTENER, EBookListener)) -#define E_BOOK_LISTENER_CLASS(k) (G_TYPE_CHECK_CLASS_CAST((k), E_TYPE_BOOK_LISTENER, EBookListenerClass)) -#define E_IS_BOOK_LISTENER(o) (G_TYPE_CHECK_INSTANCE_TYPE ((o), E_TYPE_BOOK_LISTENER)) -#define E_IS_BOOK_LISTENER_CLASS(k) (G_TYPE_CHECK_CLASS_TYPE ((k), E_TYPE_BOOK_LISTENER)) -#define E_BOOK_LISTENER_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), E_TYPE_BOOK_LISTENER, EBookListenerClass)) - -G_BEGIN_DECLS - -typedef struct _EBookListener EBookListener; -typedef struct _EBookListenerClass EBookListenerClass; -typedef struct _EBookListenerPrivate EBookListenerPrivate; -typedef struct _EBookListenerResponse EBookListenerResponse; - -struct _EBookListener { - BonoboObject parent; - EBookListenerPrivate *priv; -}; - -struct _EBookListenerClass { - BonoboObjectClass parent; - - POA_GNOME_Evolution_Addressbook_BookListener__epv epv; - - /* - * Signals - */ - - void (*response) (EBookListener *listener, EBookListenerResponse *response); - - /* Padding for future expansion */ - void (*_ebook_reserved0) (void); - void (*_ebook_reserved1) (void); - void (*_ebook_reserved2) (void); - void (*_ebook_reserved3) (void); - void (*_ebook_reserved4) (void); -}; - -typedef enum { - /* Async responses */ - OpenBookResponse, - RemoveBookResponse, - CreateContactResponse, - RemoveContactResponse, - ModifyContactResponse, - GetContactResponse, - GetContactListResponse, - GetBookViewResponse, - GetChangesResponse, - AuthenticationResponse, - GetSupportedFieldsResponse, - GetSupportedAuthMethodsResponse, - - /* Async events */ - LinkStatusEvent, - WritableStatusEvent, - ProgressEvent, -} EBookListenerOperation; - -struct _EBookListenerResponse { - EBookListenerOperation op; - - /* For most Response notifications */ - EBookStatus status; - - /* For GetBookViewReponse */ - GNOME_Evolution_Addressbook_BookView book_view; - - /* For GetSupportedFields/GetSupportedAuthMethods */ - GList *list; - - /* For ProgressEvent */ - char *msg; - short percent; - - /* For LinkStatusEvent */ - gboolean connected; - - /* For WritableStatusEvent */ - gboolean writable; - - /* For Card[Added|Removed|Modified]Event */ - char *id; - char *vcard; -}; - - -EBookListener *e_book_listener_new (void); -GType e_book_listener_get_type (void); -void e_book_listener_stop (EBookListener *listener); - -G_END_DECLS - -#endif /* ! __E_BOOK_LISTENER_H__ */ diff --git a/addressbook/backend/ebook/e-book-marshal.list b/addressbook/backend/ebook/e-book-marshal.list deleted file mode 100644 index 680ea039a3..0000000000 --- a/addressbook/backend/ebook/e-book-marshal.list +++ /dev/null @@ -1,5 +0,0 @@ -NONE:NONE -NONE:BOOL -NONE:POINTER -NONE:STRING -NONE:INT diff --git a/addressbook/backend/ebook/e-book-query.c b/addressbook/backend/ebook/e-book-query.c deleted file mode 100644 index 16e325303c..0000000000 --- a/addressbook/backend/ebook/e-book-query.c +++ /dev/null @@ -1,524 +0,0 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */ - -#include <config.h> - -#include "e-book-query.h" -#include <e-util/e-sexp.h> - -#include <stdarg.h> -#include <string.h> - -typedef enum { - E_BOOK_QUERY_TYPE_AND, - E_BOOK_QUERY_TYPE_OR, - E_BOOK_QUERY_TYPE_NOT, - E_BOOK_QUERY_TYPE_FIELD_EXISTS, - E_BOOK_QUERY_TYPE_FIELD_TEST, - E_BOOK_QUERY_TYPE_ANY_FIELD_CONTAINS -} EBookQueryType; - -struct EBookQuery { - EBookQueryType type; - int ref_count; - - union { - struct { - guint nqs; - EBookQuery **qs; - } andor; - - struct { - EBookQuery *q; - } not; - - struct { - EBookQueryTest test; - EContactField field; - char *value; - } field_test; - - struct { - EContactField field; - } exist; - - struct { - char *value; - } any_field_contains; - } query; -}; - -static EBookQuery * -conjoin (EBookQueryType type, int nqs, EBookQuery **qs, gboolean unref) -{ - EBookQuery *ret = g_new0 (EBookQuery, 1); - int i; - - ret->type = type; - ret->query.andor.nqs = nqs; - ret->query.andor.qs = g_new (EBookQuery *, nqs); - for (i = 0; i < nqs; i++) { - ret->query.andor.qs[i] = qs[i]; - if (!unref) - e_book_query_ref (qs[i]); - } - - return ret; -} - -EBookQuery * -e_book_query_and (int nqs, EBookQuery **qs, gboolean unref) -{ - return conjoin (E_BOOK_QUERY_TYPE_AND, nqs, qs, unref); -} - -EBookQuery * -e_book_query_or (int nqs, EBookQuery **qs, gboolean unref) -{ - return conjoin (E_BOOK_QUERY_TYPE_OR, nqs, qs, unref); -} - -static EBookQuery * -conjoinv (EBookQueryType type, EBookQuery *q, va_list ap) -{ - EBookQuery *ret = g_new0 (EBookQuery, 1); - GPtrArray *qs; - - qs = g_ptr_array_new (); - while (q) { - g_ptr_array_add (qs, q); - q = va_arg (ap, EBookQuery *); - } - va_end (ap); - - ret->type = type; - ret->query.andor.nqs = qs->len; - ret->query.andor.qs = (EBookQuery **)qs->pdata; - g_ptr_array_free (qs, FALSE); - - return ret; -} - -EBookQuery * -e_book_query_andv (EBookQuery *q, ...) -{ - va_list ap; - - va_start (ap, q); - return conjoinv (E_BOOK_QUERY_TYPE_AND, q, ap); -} - -EBookQuery * -e_book_query_orv (EBookQuery *q, ...) -{ - va_list ap; - - va_start (ap, q); - return conjoinv (E_BOOK_QUERY_TYPE_OR, q, ap); -} - -EBookQuery * -e_book_query_not (EBookQuery *q, gboolean unref) -{ - EBookQuery *ret = g_new0 (EBookQuery, 1); - - ret->type = E_BOOK_QUERY_TYPE_NOT; - ret->query.not.q = q; - if (!unref) - e_book_query_ref (q); - - return ret; -} - -EBookQuery * -e_book_query_field_test (EContactField field, - EBookQueryTest test, - const char *value) -{ - EBookQuery *ret = g_new0 (EBookQuery, 1); - - ret->type = E_BOOK_QUERY_TYPE_FIELD_TEST; - ret->query.field_test.field = field; - ret->query.field_test.test = test; - ret->query.field_test.value = g_strdup (value); - - return ret; -} - -EBookQuery * -e_book_query_field_exists (EContactField field) -{ - EBookQuery *ret = g_new0 (EBookQuery, 1); - - ret->type = E_BOOK_QUERY_TYPE_FIELD_EXISTS; - ret->query.exist.field = field; - - return ret; -} - -EBookQuery * -e_book_query_any_field_contains (const char *value) -{ - EBookQuery *ret = g_new0 (EBookQuery, 1); - - ret->type = E_BOOK_QUERY_TYPE_ANY_FIELD_CONTAINS; - ret->query.any_field_contains.value = g_strdup (value); - - return ret; -} - -void -e_book_query_unref (EBookQuery *q) -{ - int i; - - if (q->ref_count--) - return; - - switch (q->type) { - case E_BOOK_QUERY_TYPE_AND: - case E_BOOK_QUERY_TYPE_OR: - for (i = 0; i < q->query.andor.nqs; i++) - e_book_query_unref (q->query.andor.qs[i]); - g_free (q->query.andor.qs); - break; - - case E_BOOK_QUERY_TYPE_NOT: - e_book_query_unref (q->query.not.q); - break; - - case E_BOOK_QUERY_TYPE_FIELD_TEST: - g_free (q->query.field_test.value); - break; - - case E_BOOK_QUERY_TYPE_ANY_FIELD_CONTAINS: - g_free (q->query.any_field_contains.value); - break; - - default: - break; - } - - g_free (q); -} - -void -e_book_query_ref (EBookQuery *q) -{ - q->ref_count++; -} - -static ESExpResult * -func_and(struct _ESExp *f, int argc, struct _ESExpResult **argv, void *data) -{ - GList **list = data; - ESExpResult *r; - EBookQuery **qs; - - if (argc > 0) { - int i; - - qs = g_new0(EBookQuery*, argc); - - for (i = 0; i < argc; i ++) { - GList *list_head = *list; - if (!list_head) - break; - qs[i] = list_head->data; - *list = g_list_remove_link(*list, list_head); - g_list_free_1(list_head); - } - - *list = g_list_prepend(*list, - e_book_query_and (argc, qs, TRUE)); - - g_free (qs); - } - - r = e_sexp_result_new(f, ESEXP_RES_BOOL); - r->value.bool = FALSE; - - return r; -} - -static ESExpResult * -func_or(struct _ESExp *f, int argc, struct _ESExpResult **argv, void *data) -{ - GList **list = data; - ESExpResult *r; - EBookQuery **qs; - - if (argc > 0) { - int i; - - qs = g_new0(EBookQuery*, argc); - - for (i = 0; i < argc; i ++) { - GList *list_head = *list; - if (!list_head) - break; - qs[i] = list_head->data; - *list = g_list_remove_link(*list, list_head); - g_list_free_1(list_head); - } - - *list = g_list_prepend(*list, - e_book_query_or (argc, qs, TRUE)); - - g_free (qs); - } - - r = e_sexp_result_new(f, ESEXP_RES_BOOL); - r->value.bool = FALSE; - - return r; -} - -static ESExpResult * -func_not(struct _ESExp *f, int argc, struct _ESExpResult **argv, void *data) -{ - GList **list = data; - ESExpResult *r; - - /* just replace the head of the list with the NOT of it. */ - if (argc > 0) { - EBookQuery *term = (*list)->data; - (*list)->data = e_book_query_not (term, TRUE); - } - - r = e_sexp_result_new(f, ESEXP_RES_BOOL); - r->value.bool = FALSE; - - return r; -} - -static ESExpResult * -func_contains(struct _ESExp *f, int argc, struct _ESExpResult **argv, void *data) -{ - GList **list = data; - ESExpResult *r; - - if (argc == 2 - && argv[0]->type == ESEXP_RES_STRING - && argv[1]->type == ESEXP_RES_STRING) { - char *propname = argv[0]->value.string; - char *str = argv[1]->value.string; - - if (!strcmp (propname, "x-evolution-any-field")) { - *list = g_list_prepend (*list, e_book_query_any_field_contains (str)); - } - else { - EContactField field = e_contact_field_id (propname); - - if (field) - *list = g_list_prepend (*list, e_book_query_field_test (field, - E_BOOK_QUERY_CONTAINS, - str)); - } - } - - r = e_sexp_result_new(f, ESEXP_RES_BOOL); - r->value.bool = FALSE; - - return r; -} - -static ESExpResult * -func_is(struct _ESExp *f, int argc, struct _ESExpResult **argv, void *data) -{ - GList **list = data; - ESExpResult *r; - - if (argc == 2 - && argv[0]->type == ESEXP_RES_STRING - && argv[1]->type == ESEXP_RES_STRING) { - char *propname = argv[0]->value.string; - char *str = argv[1]->value.string; - EContactField field = e_contact_field_id (propname); - - if (field) - *list = g_list_prepend (*list, e_book_query_field_test (field, - E_BOOK_QUERY_IS, - str)); - } - - r = e_sexp_result_new(f, ESEXP_RES_BOOL); - r->value.bool = FALSE; - - return r; -} - -static ESExpResult * -func_beginswith(struct _ESExp *f, int argc, struct _ESExpResult **argv, void *data) -{ - GList **list = data; - ESExpResult *r; - - if (argc == 2 - && argv[0]->type == ESEXP_RES_STRING - && argv[1]->type == ESEXP_RES_STRING) { - char *propname = argv[0]->value.string; - char *str = argv[1]->value.string; - EContactField field = e_contact_field_id (propname); - - if (field) - *list = g_list_prepend (*list, e_book_query_field_test (field, - E_BOOK_QUERY_BEGINS_WITH, - str)); - } - - r = e_sexp_result_new(f, ESEXP_RES_BOOL); - r->value.bool = FALSE; - - return r; -} - -static ESExpResult * -func_endswith(struct _ESExp *f, int argc, struct _ESExpResult **argv, void *data) -{ - GList **list = data; - ESExpResult *r; - - if (argc == 2 - && argv[0]->type == ESEXP_RES_STRING - && argv[1]->type == ESEXP_RES_STRING) { - char *propname = argv[0]->value.string; - char *str = argv[1]->value.string; - EContactField field = e_contact_field_id (propname); - - if (field) - *list = g_list_prepend (*list, e_book_query_field_test (field, - E_BOOK_QUERY_ENDS_WITH, - str)); - } - - r = e_sexp_result_new(f, ESEXP_RES_BOOL); - r->value.bool = FALSE; - - return r; -} - -/* 'builtin' functions */ -static struct { - char *name; - ESExpFunc *func; - int type; /* set to 1 if a function can perform shortcut evaluation, or - doesn't execute everything, 0 otherwise */ -} symbols[] = { - { "and", func_and, 0 }, - { "or", func_or, 0 }, - { "not", func_not, 0 }, - { "contains", func_contains, 0 }, - { "is", func_is, 0 }, - { "beginswith", func_beginswith, 0 }, - { "endswith", func_endswith, 0 }, -}; - -EBookQuery* -e_book_query_from_string (const char *query_string) -{ - ESExp *sexp; - ESExpResult *r; - EBookQuery *retval; - GList *list = NULL; - int i; - - sexp = e_sexp_new(); - - for(i=0;i<sizeof(symbols)/sizeof(symbols[0]);i++) { - if (symbols[i].type == 1) { - e_sexp_add_ifunction(sexp, 0, symbols[i].name, - (ESExpIFunc *)symbols[i].func, &list); - } else { - e_sexp_add_function(sexp, 0, symbols[i].name, - symbols[i].func, &list); - } - } - - e_sexp_input_text(sexp, query_string, strlen(query_string)); - e_sexp_parse(sexp); - - r = e_sexp_eval(sexp); - - e_sexp_result_free(sexp, r); - e_sexp_unref (sexp); - - if (list) { - if (list->next) { - g_warning ("conversion to EBookQuery"); - retval = NULL; - g_list_foreach (list, (GFunc)e_book_query_unref, NULL); - } - else { - retval = list->data; - } - } - else { - g_warning ("conversion to EBookQuery failed"); - retval = NULL; - } - - g_list_free (list); - return retval; -} - -char* -e_book_query_to_string (EBookQuery *q) -{ - GString *str = g_string_new ("("); - int i; - char *s = NULL; - - switch (q->type) { - case E_BOOK_QUERY_TYPE_AND: - g_string_append (str, "and "); - for (i = 0; i < q->query.andor.nqs; i ++) { - s = e_book_query_to_string (q->query.andor.qs[i]); - g_string_append (str, s); - g_free (s); - g_string_append_c (str, ' '); - } - break; - case E_BOOK_QUERY_TYPE_OR: - g_string_append (str, "or "); - for (i = 0; i < q->query.andor.nqs; i ++) { - s = e_book_query_to_string (q->query.andor.qs[i]); - g_string_append (str, s); - g_free (s); - g_string_append_c (str, ' '); - } - break; - case E_BOOK_QUERY_TYPE_NOT: - s = e_book_query_to_string (q->query.not.q); - g_string_append_printf (str, "not %s", s); - g_free (s); - break; - case E_BOOK_QUERY_TYPE_FIELD_EXISTS: - g_string_append_printf (str, "exists \"%s\"", e_contact_field_name (q->query.exist.field)); - break; - case E_BOOK_QUERY_TYPE_FIELD_TEST: - switch (q->query.field_test.test) { - case E_BOOK_QUERY_IS: s = "is"; break; - case E_BOOK_QUERY_CONTAINS: s = "contains"; break; - case E_BOOK_QUERY_BEGINS_WITH: s = "beginswith"; break; - case E_BOOK_QUERY_ENDS_WITH: s = "endswith"; break; - default: - g_assert_not_reached(); - break; - } - - /* XXX need to escape q->query.field_test.value */ - g_string_append_printf (str, "%s \"%s\" \"%s\"", - s, - e_contact_field_name (q->query.field_test.field), - q->query.field_test.value); - break; - case E_BOOK_QUERY_TYPE_ANY_FIELD_CONTAINS: - g_string_append_printf (str, "contains \"x-evolution-any-field\" \"%s\"", q->query.any_field_contains.value); - break; - } - - - g_string_append (str, ")"); - - return g_string_free (str, FALSE); -} diff --git a/addressbook/backend/ebook/e-book-query.h b/addressbook/backend/ebook/e-book-query.h deleted file mode 100644 index e36887f6f2..0000000000 --- a/addressbook/backend/ebook/e-book-query.h +++ /dev/null @@ -1,49 +0,0 @@ - -#ifndef __E_BOOK_QUERY_H__ -#define __E_BOOK_QUERY_H__ - -#include <ebook/e-contact.h> - -G_BEGIN_DECLS - -typedef struct EBookQuery EBookQuery; - -typedef enum { - E_BOOK_QUERY_IS, - E_BOOK_QUERY_CONTAINS, - E_BOOK_QUERY_BEGINS_WITH, - E_BOOK_QUERY_ENDS_WITH, - -#if notyet - E_BOOK_QUERY_LT, - E_BOOK_QUERY_LE, - E_BOOK_QUERY_GT, - E_BOOK_QUERY_GE, - E_BOOK_QUERY_EQ, -#endif -} EBookQueryTest; - -EBookQuery* e_book_query_from_string (const char *sexp); -char* e_book_query_to_string (EBookQuery *q); - -void e_book_query_ref (EBookQuery *q); -void e_book_query_unref (EBookQuery *q); - -EBookQuery* e_book_query_and (int nqs, EBookQuery **qs, gboolean unref); -EBookQuery* e_book_query_andv (EBookQuery *q, ...); -EBookQuery* e_book_query_or (int nqs, EBookQuery **qs, gboolean unref); -EBookQuery* e_book_query_orv (EBookQuery *q, ...); - -EBookQuery* e_book_query_not (EBookQuery *qs, gboolean unref); - -EBookQuery* e_book_query_field_exists (EContactField field); -EBookQuery* e_book_query_field_test (EContactField field, - EBookQueryTest test, - const char *value); - -/* a special any field contains query */ -EBookQuery* e_book_query_any_field_contains (const char *value); - -G_END_DECLS - -#endif /* __E_BOOK_QUERY_H__ */ diff --git a/addressbook/backend/ebook/e-book-types.h b/addressbook/backend/ebook/e-book-types.h deleted file mode 100644 index 9bbc66e622..0000000000 --- a/addressbook/backend/ebook/e-book-types.h +++ /dev/null @@ -1,68 +0,0 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */ -/* - * A client-side GObject which exposes the - * Evolution:BookListener interface. - * - * Author: - * Nat Friedman (nat@ximian.com) - * - * Copyright 2000, Ximian, Inc. - */ - -#ifndef __E_BOOK_TYPES_H__ -#define __E_BOOK_TYPES_H__ - -#include <glib.h> -#include <ebook/e-contact.h> - -G_BEGIN_DECLS - -#define E_BOOK_ERROR e_book_error_quark() - -GQuark e_book_error_quark (void) G_GNUC_CONST; - -typedef enum { - E_BOOK_ERROR_OK, - E_BOOK_ERROR_INVALID_ARG, - E_BOOK_ERROR_BUSY, - E_BOOK_ERROR_REPOSITORY_OFFLINE, - E_BOOK_ERROR_NO_SUCH_BOOK, - E_BOOK_ERROR_URI_NOT_LOADED, - E_BOOK_ERROR_URI_ALREADY_LOADED, - E_BOOK_ERROR_PERMISSION_DENIED, - E_BOOK_ERROR_CONTACT_NOT_FOUND, - E_BOOK_ERROR_CONTACT_ID_ALREADY_EXISTS, - E_BOOK_ERROR_PROTOCOL_NOT_SUPPORTED, - E_BOOK_ERROR_CANCELLED, - E_BOOK_ERROR_COULD_NOT_CANCEL, - E_BOOK_ERROR_AUTHENTICATION_FAILED, - E_BOOK_ERROR_AUTHENTICATION_REQUIRED, - E_BOOK_ERROR_TLS_NOT_AVAILABLE, - E_BOOK_ERROR_CORBA_EXCEPTION, - E_BOOK_ERROR_OTHER_ERROR -} EBookStatus; - - -typedef enum { - E_BOOK_VIEW_STATUS_OK, - E_BOOK_VIEW_STATUS_TIME_LIMIT_EXCEEDED, - E_BOOK_VIEW_STATUS_SIZE_LIMIT_EXCEEDED, - E_BOOK_VIEW_ERROR_INVALID_QUERY, - E_BOOK_VIEW_ERROR_QUERY_REFUSED, - E_BOOK_VIEW_ERROR_OTHER_ERROR -} EBookViewStatus; - -typedef enum { - E_BOOK_CHANGE_CARD_ADDED, - E_BOOK_CHANGE_CARD_DELETED, - E_BOOK_CHANGE_CARD_MODIFIED -} EBookChangeType; - -typedef struct { - EBookChangeType change_type; - EContact *contact; -} EBookChange; - -G_END_DECLS - -#endif /* ! __E_BOOK_TYPES_H__ */ diff --git a/addressbook/backend/ebook/e-book-view-listener.c b/addressbook/backend/ebook/e-book-view-listener.c deleted file mode 100644 index 3ab2ff2708..0000000000 --- a/addressbook/backend/ebook/e-book-view-listener.c +++ /dev/null @@ -1,314 +0,0 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */ -/* - * Exports the BookViewListener interface. Maintains a queue of messages - * which come in on the interface. - * - * Author: - * Nat Friedman (nat@ximian.com) - * - * Copyright 2000, Ximian, Inc. - */ - -#include <config.h> -#include <bonobo/bonobo-main.h> -#include "e-book-view-listener.h" -#include "e-book-view.h" -#include "e-contact.h" -#include "e-book-marshal.h" - -static EBookViewStatus e_book_view_listener_convert_status (GNOME_Evolution_Addressbook_CallStatus status); - -enum { - RESPONSE, - LAST_SIGNAL -}; - -static guint e_book_view_listener_signals [LAST_SIGNAL]; - -static BonoboObjectClass *parent_class; - -struct _EBookViewListenerPrivate { - guint stopped : 1; -}; - -static void -e_book_view_listener_queue_response (EBookViewListener *listener, - EBookViewListenerResponse *response) -{ - if (response == NULL) - return; - - if (listener->priv->stopped) { - /* Free response and return */ - g_list_foreach (response->ids, (GFunc)g_free, NULL); - g_list_free (response->ids); - g_list_foreach (response->contacts, (GFunc) g_object_unref, NULL); - g_list_free (response->contacts); - g_free (response->message); - g_free (response); - return; - } - - g_signal_emit (listener, e_book_view_listener_signals [RESPONSE], 0, response); -} - -/* Add, Remove, Modify */ -static void -e_book_view_listener_queue_status_event (EBookViewListener *listener, - EBookViewListenerOperation op, - EBookViewStatus status) -{ - EBookViewListenerResponse *resp; - - if (listener->priv->stopped) - return; - - resp = g_new0 (EBookViewListenerResponse, 1); - - resp->op = op; - resp->status = status; - - e_book_view_listener_queue_response (listener, resp); -} - -/* Add, Remove, Modify */ -static void -e_book_view_listener_queue_idlist_event (EBookViewListener *listener, - EBookViewListenerOperation op, - const GNOME_Evolution_Addressbook_ContactIdList *ids) -{ - EBookViewListenerResponse *resp; - int i; - - if (listener->priv->stopped) - return; - - resp = g_new0 (EBookViewListenerResponse, 1); - - resp->op = op; - resp->status = E_BOOK_VIEW_STATUS_OK; - - for (i = 0; i < ids->_length; i ++) { - resp->ids = g_list_prepend (resp->ids, g_strdup (ids->_buffer[i])); - } - - e_book_view_listener_queue_response (listener, resp); -} - -/* Add, Remove, Modify */ -static void -e_book_view_listener_queue_sequence_event (EBookViewListener *listener, - EBookViewListenerOperation op, - const GNOME_Evolution_Addressbook_VCardList *vcards) -{ - EBookViewListenerResponse *resp; - int i; - - if (listener->priv->stopped) - return; - - resp = g_new0 (EBookViewListenerResponse, 1); - - resp->op = op; - resp->status = E_BOOK_VIEW_STATUS_OK; - - for ( i = 0; i < vcards->_length; i++ ) { - resp->contacts = g_list_append(resp->contacts, e_contact_new_from_vcard (vcards->_buffer[i])); - } - - e_book_view_listener_queue_response (listener, resp); -} - -/* Status Message */ -static void -e_book_view_listener_queue_message_event (EBookViewListener *listener, - EBookViewListenerOperation op, - const char *message) -{ - EBookViewListenerResponse *resp; - - if (listener->priv->stopped) - return; - - resp = g_new0 (EBookViewListenerResponse, 1); - - resp->op = op; - resp->status = E_BOOK_VIEW_STATUS_OK; - resp->message = g_strdup(message); - - e_book_view_listener_queue_response (listener, resp); -} - -static void -impl_BookViewListener_notify_contacts_added (PortableServer_Servant servant, - const GNOME_Evolution_Addressbook_VCardList *vcards, - CORBA_Environment *ev) -{ - EBookViewListener *listener = E_BOOK_VIEW_LISTENER (bonobo_object (servant)); - - printf ("impl_BookViewListener_notify_contacts_added\n"); - - e_book_view_listener_queue_sequence_event ( - listener, ContactsAddedEvent, vcards); -} - -static void -impl_BookViewListener_notify_contacts_removed (PortableServer_Servant servant, - const GNOME_Evolution_Addressbook_ContactIdList *ids, - CORBA_Environment *ev) -{ - EBookViewListener *listener = E_BOOK_VIEW_LISTENER (bonobo_object (servant)); - - printf ("impl_BookViewListener_notify_contacts_removed\n"); - - e_book_view_listener_queue_idlist_event (listener, ContactsRemovedEvent, ids); -} - -static void -impl_BookViewListener_notify_contacts_changed (PortableServer_Servant servant, - const GNOME_Evolution_Addressbook_VCardList *vcards, - CORBA_Environment *ev) -{ - EBookViewListener *listener = E_BOOK_VIEW_LISTENER (bonobo_object (servant)); - - printf ("impl_BookViewListener_notify_contacts_changed\n"); - - e_book_view_listener_queue_sequence_event ( - listener, ContactsModifiedEvent, vcards); -} - -static void -impl_BookViewListener_notify_sequence_complete (PortableServer_Servant servant, - const GNOME_Evolution_Addressbook_CallStatus status, - CORBA_Environment *ev) -{ - EBookViewListener *listener = E_BOOK_VIEW_LISTENER (bonobo_object (servant)); - - printf ("impl_BookViewListener_notify_sequence_complete\n"); - - e_book_view_listener_queue_status_event (listener, SequenceCompleteEvent, - e_book_view_listener_convert_status (status)); -} - -static void -impl_BookViewListener_notify_progress (PortableServer_Servant servant, - const char *message, - const CORBA_short percent, - CORBA_Environment *ev) -{ - EBookViewListener *listener = E_BOOK_VIEW_LISTENER (bonobo_object (servant)); - - printf ("impl_BookViewListener_notify_progress\n"); - - e_book_view_listener_queue_message_event (listener, StatusMessageEvent, message); -} - -static EBookViewStatus -e_book_view_listener_convert_status (const GNOME_Evolution_Addressbook_CallStatus status) -{ - switch (status) { - case GNOME_Evolution_Addressbook_Success: - return E_BOOK_VIEW_STATUS_OK; - case GNOME_Evolution_Addressbook_SearchTimeLimitExceeded: - return E_BOOK_VIEW_STATUS_TIME_LIMIT_EXCEEDED; - case GNOME_Evolution_Addressbook_SearchSizeLimitExceeded: - return E_BOOK_VIEW_STATUS_SIZE_LIMIT_EXCEEDED; - case GNOME_Evolution_Addressbook_InvalidQuery: - return E_BOOK_VIEW_ERROR_INVALID_QUERY; - case GNOME_Evolution_Addressbook_QueryRefused: - return E_BOOK_VIEW_ERROR_QUERY_REFUSED; - case GNOME_Evolution_Addressbook_OtherError: - default: - return E_BOOK_VIEW_ERROR_OTHER_ERROR; - } -} - -static void -e_book_view_listener_construct (EBookViewListener *listener) -{ - /* nothing needed here */ -} - -/** - * e_book_view_listener_new: - * @book: the #EBookView for which the listener is to be bound - * - * Creates and returns a new #EBookViewListener for the book. - * - * Returns: a new #EBookViewListener - */ -EBookViewListener * -e_book_view_listener_new () -{ - EBookViewListener *listener; - - listener = g_object_new (E_TYPE_BOOK_VIEW_LISTENER, - "poa", bonobo_poa_get_threaded (ORBIT_THREAD_HINT_ALL_AT_IDLE, NULL), - NULL); - - e_book_view_listener_construct (listener); - - return listener; -} - -static void -e_book_view_listener_init (EBookViewListener *listener) -{ - listener->priv = g_new0 (EBookViewListenerPrivate, 1); - listener->priv->stopped = FALSE; -} - -void -e_book_view_listener_stop (EBookViewListener *listener) -{ - g_return_if_fail (E_IS_BOOK_VIEW_LISTENER (listener)); - listener->priv->stopped = TRUE; -} - -static void -e_book_view_listener_dispose (GObject *object) -{ - EBookViewListener *listener = E_BOOK_VIEW_LISTENER (object); - - if (listener->priv) { - g_free (listener->priv); - listener->priv = NULL; - } - - if (G_OBJECT_CLASS (parent_class)->dispose) - G_OBJECT_CLASS (parent_class)->dispose (object); -} - -static void -e_book_view_listener_class_init (EBookViewListenerClass *klass) -{ - GObjectClass *object_class = G_OBJECT_CLASS (klass); - POA_GNOME_Evolution_Addressbook_BookViewListener__epv *epv; - - parent_class = g_type_class_ref (BONOBO_TYPE_OBJECT); - - e_book_view_listener_signals [RESPONSE] = - g_signal_new ("response", - G_OBJECT_CLASS_TYPE (object_class), - G_SIGNAL_RUN_LAST, - G_STRUCT_OFFSET (EBookViewListenerClass, response), - NULL, NULL, - e_book_marshal_NONE__POINTER, - G_TYPE_NONE, - 1, G_TYPE_POINTER); - - object_class->dispose = e_book_view_listener_dispose; - - epv = &klass->epv; - epv->notifyContactsChanged = impl_BookViewListener_notify_contacts_changed; - epv->notifyContactsRemoved = impl_BookViewListener_notify_contacts_removed; - epv->notifyContactsAdded = impl_BookViewListener_notify_contacts_added; - epv->notifySequenceComplete = impl_BookViewListener_notify_sequence_complete; - epv->notifyProgress = impl_BookViewListener_notify_progress; -} - -BONOBO_TYPE_FUNC_FULL ( - EBookViewListener, - GNOME_Evolution_Addressbook_BookViewListener, - BONOBO_TYPE_OBJECT, - e_book_view_listener); diff --git a/addressbook/backend/ebook/e-book-view-listener.h b/addressbook/backend/ebook/e-book-view-listener.h deleted file mode 100644 index a68f25c337..0000000000 --- a/addressbook/backend/ebook/e-book-view-listener.h +++ /dev/null @@ -1,90 +0,0 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */ -/* - * A client-side GObject which exposes the - * Evolution:BookViewListener interface. - * - * Author: - * Nat Friedman (nat@ximian.com) - * - * Copyright 2000, Ximian, Inc. - */ - -#ifndef __E_BOOK_VIEW_LISTENER_H__ -#define __E_BOOK_VIEW_LISTENER_H__ - -#include <bonobo/bonobo-object.h> -#include <ebook/e-book-types.h> -#include <ebook/addressbook.h> - -#define E_TYPE_BOOK_VIEW_LISTENER (e_book_view_listener_get_type ()) -#define E_BOOK_VIEW_LISTENER(o) (G_TYPE_CHECK_INSTANCE_CAST ((o), E_TYPE_BOOK_VIEW_LISTENER, EBookViewListener)) -#define E_BOOK_VIEW_LISTENER_CLASS(k) (G_TYPE_CHECK_CLASS_CAST((k), E_TYPE_BOOK_VIEW_LISTENER, EBookViewListenerClass)) -#define E_IS_BOOK_VIEW_LISTENER(o) (G_TYPE_CHECK_INSTANCE_TYPE ((o), E_TYPE_BOOK_VIEW_LISTENER)) -#define E_IS_BOOK_VIEW_LISTENER_CLASS(k) (G_TYPE_CHECK_CLASS_TYPE ((k), E_TYPE_BOOK_VIEW_LISTENER)) -#define E_BOOK_VIEW_LISTENER_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), E_TYPE_BOOK_VIEW_LISTENER, EBookViewListenerClass)) - -G_BEGIN_DECLS - -typedef struct _EBookViewListener EBookViewListener; -typedef struct _EBookViewListenerClass EBookViewListenerClass; -typedef struct _EBookViewListenerPrivate EBookViewListenerPrivate; - -typedef struct _EBookViewListenerResponse EBookViewListenerResponse; - -struct _EBookViewListener { - BonoboObject parent; - EBookViewListenerPrivate *priv; -}; - -struct _EBookViewListenerClass { - BonoboObjectClass parent; - - POA_GNOME_Evolution_Addressbook_BookViewListener__epv epv; - - /* - * Signals - */ - void (*response) (EBookViewListener *listener, EBookViewListenerResponse *response); - - - /* Padding for future expansion */ - void (*_ebook_reserved0) (void); - void (*_ebook_reserved1) (void); - void (*_ebook_reserved2) (void); - void (*_ebook_reserved3) (void); - void (*_ebook_reserved4) (void); -}; - -typedef enum { - /* Async events */ - ContactsAddedEvent, - ContactsRemovedEvent, - ContactsModifiedEvent, - SequenceCompleteEvent, - StatusMessageEvent, -} EBookViewListenerOperation; - -struct _EBookViewListenerResponse { - EBookViewListenerOperation op; - - /* For SequenceComplete */ - EBookViewStatus status; - - /* For ContactsRemovedEvent */ - GList *ids; - - /* For Contact[sAdded|Modified]Event */ - GList *contacts; /* Of type EContact. */ - - /* For StatusMessageEvent */ - char *message; - -}; - -EBookViewListener *e_book_view_listener_new (void); -GType e_book_view_listener_get_type (void); -void e_book_view_listener_stop (EBookViewListener *listener); - -G_END_DECLS - -#endif /* ! __E_BOOK_VIEW_LISTENER_H__ */ diff --git a/addressbook/backend/ebook/e-book-view.c b/addressbook/backend/ebook/e-book-view.c deleted file mode 100644 index c36e87967c..0000000000 --- a/addressbook/backend/ebook/e-book-view.c +++ /dev/null @@ -1,353 +0,0 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */ -/* - * The Evolution addressbook client object. - * - * Author: - * Nat Friedman (nat@ximian.com) - * - * Copyright 1999, 2000, Ximian, Inc. - */ - -#include <config.h> - -#include "addressbook.h" -#include "e-book-view-listener.h" -#include "e-book-view.h" -#include "e-book.h" -#include "e-book-marshal.h" - -static GObjectClass *parent_class; - -struct _EBookViewPrivate { - GNOME_Evolution_Addressbook_BookView corba_book_view; - - EBook *book; - - EBookViewListener *listener; - - int response_id; -}; - -enum { - CONTACTS_CHANGED, - CONTACTS_REMOVED, - CONTACTS_ADDED, - SEQUENCE_COMPLETE, - STATUS_MESSAGE, - LAST_SIGNAL -}; - -static guint e_book_view_signals [LAST_SIGNAL]; - -static void -e_book_view_do_added_event (EBookView *book_view, - EBookViewListenerResponse *resp) -{ - g_signal_emit (book_view, e_book_view_signals [CONTACTS_ADDED], 0, - resp->contacts); - - g_list_foreach (resp->contacts, (GFunc) g_object_unref, NULL); - g_list_free (resp->contacts); -} - -static void -e_book_view_do_modified_event (EBookView *book_view, - EBookViewListenerResponse *resp) -{ - g_signal_emit (book_view, e_book_view_signals [CONTACTS_CHANGED], 0, - resp->contacts); - - g_list_foreach (resp->contacts, (GFunc) g_object_unref, NULL); - g_list_free (resp->contacts); -} - -static void -e_book_view_do_removed_event (EBookView *book_view, - EBookViewListenerResponse *resp) -{ - g_signal_emit (book_view, e_book_view_signals [CONTACTS_REMOVED], 0, - resp->ids); - - g_list_foreach (resp->ids, (GFunc) g_free, NULL); - g_list_free (resp->ids); -} - -static void -e_book_view_do_complete_event (EBookView *book_view, - EBookViewListenerResponse *resp) -{ - g_signal_emit (book_view, e_book_view_signals [SEQUENCE_COMPLETE], 0, - resp->status); -} - -static void -e_book_view_do_status_message_event (EBookView *book_view, - EBookViewListenerResponse *resp) -{ - g_signal_emit (book_view, e_book_view_signals [STATUS_MESSAGE], 0, - resp->message); - g_free(resp->message); -} - - -static void -e_book_view_handle_response (EBookViewListener *listener, EBookViewListenerResponse *resp, EBookView *book_view) -{ - if (resp == NULL) - return; - - switch (resp->op) { - case ContactsAddedEvent: - e_book_view_do_added_event (book_view, resp); - break; - case ContactsModifiedEvent: - e_book_view_do_modified_event (book_view, resp); - break; - case ContactsRemovedEvent: - e_book_view_do_removed_event (book_view, resp); - break; - case SequenceCompleteEvent: - e_book_view_do_complete_event (book_view, resp); - break; - case StatusMessageEvent: - e_book_view_do_status_message_event (book_view, resp); - break; - default: - g_error ("EBookView: Unknown operation %d in listener queue!\n", - resp->op); - break; - } - - g_free (resp); -} - -static gboolean -e_book_view_construct (EBookView *book_view, GNOME_Evolution_Addressbook_BookView corba_book_view, EBookViewListener *listener) -{ - CORBA_Environment ev; - g_return_val_if_fail (book_view != NULL, FALSE); - g_return_val_if_fail (E_IS_BOOK_VIEW (book_view), FALSE); - - /* - * Copy in the corba_book_view. - */ - CORBA_exception_init (&ev); - - book_view->priv->corba_book_view = bonobo_object_dup_ref(corba_book_view, &ev); - - if (ev._major != CORBA_NO_EXCEPTION) { - g_warning ("e_book_view_construct: Exception duplicating corba_book_view.\n"); - CORBA_exception_free (&ev); - book_view->priv->corba_book_view = NULL; - return FALSE; - } - - CORBA_exception_free (&ev); - - /* - * Create our local BookListener interface. - */ - book_view->priv->listener = listener; - book_view->priv->response_id = g_signal_connect (book_view->priv->listener, "response", - G_CALLBACK (e_book_view_handle_response), book_view); - - bonobo_object_ref(BONOBO_OBJECT(book_view->priv->listener)); - - return TRUE; -} - -/** - * e_book_view_new: - */ -EBookView * -e_book_view_new (GNOME_Evolution_Addressbook_BookView corba_book_view, EBookViewListener *listener) -{ - EBookView *book_view; - - book_view = g_object_new (E_TYPE_BOOK_VIEW, NULL); - - if (! e_book_view_construct (book_view, corba_book_view, listener)) { - g_object_unref (book_view); - return NULL; - } - - return book_view; -} - -void -e_book_view_set_book (EBookView *book_view, EBook *book) -{ - g_return_if_fail (book_view && E_IS_BOOK_VIEW (book_view)); - g_return_if_fail (book && E_IS_BOOK (book)); - g_return_if_fail (book_view->priv->book == NULL); - - book_view->priv->book = book; - g_object_ref (book); -} - -void -e_book_view_start (EBookView *book_view) -{ - CORBA_Environment ev; - - g_return_if_fail (book_view && E_IS_BOOK_VIEW (book_view)); - - CORBA_exception_init (&ev); - - GNOME_Evolution_Addressbook_BookView_start (book_view->priv->corba_book_view, &ev); - - if (ev._major != CORBA_NO_EXCEPTION) { - g_warning ("corba exception._major = %d\n", ev._major); - } -} - -void -e_book_view_stop (EBookView *book_view) -{ - CORBA_Environment ev; - - g_return_if_fail (book_view && E_IS_BOOK_VIEW (book_view)); - - CORBA_exception_init (&ev); - - GNOME_Evolution_Addressbook_BookView_stop (book_view->priv->corba_book_view, &ev); - - if (ev._major != CORBA_NO_EXCEPTION) { - g_warning ("corba exception._major = %d\n", ev._major); - } -} - -static void -e_book_view_init (EBookView *book_view) -{ - book_view->priv = g_new0 (EBookViewPrivate, 1); - book_view->priv->book = NULL; - book_view->priv->corba_book_view = CORBA_OBJECT_NIL; - book_view->priv->listener = NULL; - book_view->priv->response_id = 0; -} - -static void -e_book_view_dispose (GObject *object) -{ - EBookView *book_view = E_BOOK_VIEW (object); - CORBA_Environment ev; - - if (book_view->priv) { - if (book_view->priv->book) { - g_object_unref (book_view->priv->book); - } - - if (book_view->priv->corba_book_view) { - CORBA_exception_init (&ev); - - bonobo_object_release_unref (book_view->priv->corba_book_view, &ev); - - if (ev._major != CORBA_NO_EXCEPTION) { - g_warning ("EBookView: Exception while releasing BookView\n"); - } - - CORBA_exception_free (&ev); - } - - if (book_view->priv->listener) { - if (book_view->priv->response_id) - g_signal_handler_disconnect(book_view->priv->listener, - book_view->priv->response_id); - e_book_view_listener_stop (book_view->priv->listener); - bonobo_object_unref (BONOBO_OBJECT(book_view->priv->listener)); - } - - g_free (book_view->priv); - book_view->priv = NULL; - } - - G_OBJECT_CLASS(parent_class)->dispose (object); -} - -static void -e_book_view_class_init (EBookViewClass *klass) -{ - GObjectClass *object_class = G_OBJECT_CLASS (klass); - - parent_class = g_type_class_ref (G_TYPE_OBJECT); - - e_book_view_signals [CONTACTS_CHANGED] = - g_signal_new ("contacts_changed", - G_OBJECT_CLASS_TYPE (object_class), - G_SIGNAL_RUN_LAST, - G_STRUCT_OFFSET (EBookViewClass, contacts_changed), - NULL, NULL, - e_book_marshal_NONE__POINTER, - G_TYPE_NONE, 1, - G_TYPE_POINTER); - - e_book_view_signals [CONTACTS_ADDED] = - g_signal_new ("contacts_added", - G_OBJECT_CLASS_TYPE (object_class), - G_SIGNAL_RUN_LAST, - G_STRUCT_OFFSET (EBookViewClass, contacts_added), - NULL, NULL, - e_book_marshal_NONE__POINTER, - G_TYPE_NONE, 1, - G_TYPE_POINTER); - - e_book_view_signals [CONTACTS_REMOVED] = - g_signal_new ("contacts_removed", - G_OBJECT_CLASS_TYPE (object_class), - G_SIGNAL_RUN_LAST, - G_STRUCT_OFFSET (EBookViewClass, contacts_removed), - NULL, NULL, - e_book_marshal_NONE__POINTER, - G_TYPE_NONE, 1, - G_TYPE_POINTER); - - e_book_view_signals [SEQUENCE_COMPLETE] = - g_signal_new ("sequence_complete", - G_OBJECT_CLASS_TYPE (object_class), - G_SIGNAL_RUN_LAST, - G_STRUCT_OFFSET (EBookViewClass, sequence_complete), - NULL, NULL, - e_book_marshal_NONE__INT, - G_TYPE_NONE, 1, - G_TYPE_INT); - - e_book_view_signals [STATUS_MESSAGE] = - g_signal_new ("status_message", - G_OBJECT_CLASS_TYPE (object_class), - G_SIGNAL_RUN_LAST, - G_STRUCT_OFFSET (EBookViewClass, status_message), - NULL, NULL, - e_book_marshal_NONE__STRING, - G_TYPE_NONE, 1, - G_TYPE_STRING); - - object_class->dispose = e_book_view_dispose; -} - -/** - * e_book_view_get_type: - */ -GType -e_book_view_get_type (void) -{ - static GType type = 0; - - if (! type) { - GTypeInfo info = { - sizeof (EBookViewClass), - NULL, /* base_class_init */ - NULL, /* base_class_finalize */ - (GClassInitFunc) e_book_view_class_init, - NULL, /* class_finalize */ - NULL, /* class_data */ - sizeof (EBookView), - 0, /* n_preallocs */ - (GInstanceInitFunc) e_book_view_init - }; - - type = g_type_register_static (G_TYPE_OBJECT, "EBookView", &info, 0); - } - - return type; -} diff --git a/addressbook/backend/ebook/e-book-view.h b/addressbook/backend/ebook/e-book-view.h deleted file mode 100644 index 5b9768315b..0000000000 --- a/addressbook/backend/ebook/e-book-view.h +++ /dev/null @@ -1,70 +0,0 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */ -/* - * The Evolution addressbook client object. - * - * Author: - * Nat Friedman (nat@ximian.com) - * - * Copyright 1999, 2000, Ximian, Inc. - */ - -#ifndef __E_BOOK_VIEW_H__ -#define __E_BOOK_VIEW_H__ - -#include <glib.h> -#include <glib-object.h> -#include <ebook/e-book-view-listener.h> - -#define E_TYPE_BOOK_VIEW (e_book_view_get_type ()) -#define E_BOOK_VIEW(o) (G_TYPE_CHECK_INSTANCE_CAST ((o), E_TYPE_BOOK_VIEW, EBookView)) -#define E_BOOK_VIEW_CLASS(k) (G_TYPE_CHECK_CLASS_CAST((k), E_TYPE_BOOK_VIEW, EBookViewClass)) -#define E_IS_BOOK_VIEW(o) (G_TYPE_CHECK_INSTANCE_TYPE ((o), E_TYPE_BOOK_VIEW)) -#define E_IS_BOOK_VIEW_CLASS(k) (G_TYPE_CHECK_CLASS_TYPE ((k), E_TYPE_BOOK_VIEW)) -#define E_BOOK_VIEW_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), E_TYPE_BOOK_VIEW, EBookViewClass)) - -G_BEGIN_DECLS - -typedef struct _EBookView EBookView; -typedef struct _EBookViewClass EBookViewClass; -typedef struct _EBookViewPrivate EBookViewPrivate; - -struct _EBook; /* Forward reference */ - -struct _EBookView { - GObject parent; - EBookViewPrivate *priv; -}; - -struct _EBookViewClass { - GObjectClass parent; - - /* - * Signals. - */ - void (* contacts_changed) (EBookView *book_view, const GList *contacts); - void (* contacts_removed) (EBookView *book_view, const GList *ids); - void (* contacts_added) (EBookView *book_view, const GList *contacts); - void (* sequence_complete) (EBookView *book_view, EBookViewStatus status); - void (* status_message) (EBookView *book_view, const char *message); - - /* Padding for future expansion */ - void (*_ebook_reserved0) (void); - void (*_ebook_reserved1) (void); - void (*_ebook_reserved2) (void); - void (*_ebook_reserved3) (void); - void (*_ebook_reserved4) (void); -}; - -/* Creating a new addressbook. */ -EBookView *e_book_view_new (GNOME_Evolution_Addressbook_BookView corba_book_view, EBookViewListener *listener); - -GType e_book_view_get_type (void); - -void e_book_view_set_book (EBookView *book_view, struct _EBook *book); - -void e_book_view_start (EBookView *book_view); -void e_book_view_stop (EBookView *book_view); - -G_END_DECLS - -#endif /* ! __E_BOOK_VIEW_H__ */ diff --git a/addressbook/backend/ebook/e-book.c b/addressbook/backend/ebook/e-book.c deleted file mode 100644 index b551c8727b..0000000000 --- a/addressbook/backend/ebook/e-book.c +++ /dev/null @@ -1,2060 +0,0 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */ - -#include <config.h> - -#include <pthread.h> - -#include <string.h> - -#include "e-book.h" -#include "e-vcard.h" - -#include <bonobo-activation/bonobo-activation.h> - -#include <bonobo/bonobo-exception.h> -#include <bonobo/bonobo-main.h> - -#include <libgnome/gnome-i18n.h> - -#include "e-book-marshal.h" -#include "e-book-listener.h" -#include "addressbook.h" -#include "e-util/e-component-listener.h" -#include "e-util/e-msgport.h" - -static GObjectClass *parent_class; - -#define CARDSERVER_OAF_ID "OAFIID:GNOME_Evolution_Wombat_ServerFactory" - -#define e_return_error_if_fail(expr,error_code) G_STMT_START{ \ - if G_LIKELY(expr) { } else \ - { \ - g_log (G_LOG_DOMAIN, \ - G_LOG_LEVEL_CRITICAL, \ - "file %s: line %d (%s): assertion `%s' failed", \ - __FILE__, \ - __LINE__, \ - __PRETTY_FUNCTION__, \ - #expr); \ - g_set_error (error, E_BOOK_ERROR, (error_code), \ - "file %s: line %d (%s): assertion `%s' failed", \ - __FILE__, \ - __LINE__, \ - __PRETTY_FUNCTION__, \ - #expr); \ - return FALSE; \ - }; }G_STMT_END - -/* XXX we need a better error message here */ -#define E_BOOK_CHECK_STATUS(status,error) G_STMT_START{ \ - if ((status) == E_BOOK_ERROR_OK) { \ - return TRUE; \ - } \ - else { \ - g_set_error ((error), E_BOOK_ERROR, (status), "EBookStatus returned %d", (status)); \ - return FALSE; \ - } }G_STMT_END - -enum { - OPEN_PROGRESS, - WRITABLE_STATUS, - BACKEND_DIED, - LAST_SIGNAL -}; - -static guint e_book_signals [LAST_SIGNAL]; - -typedef struct { - EMutex *mutex; - pthread_cond_t cond; - EBookStatus status; - - char *id; - GList *list; - EContact *contact; - - EBookView *view; - EBookViewListener *listener; -} EBookOp; - -typedef enum { - E_BOOK_URI_NOT_LOADED, - E_BOOK_URI_LOADING, - E_BOOK_URI_LOADED -} EBookLoadState; - -struct _EBookPrivate { - GList *book_factories; - GList *iter; - - /* cached capabilites */ - char *cap; - gboolean cap_queried; - - /* cached writable status */ - gboolean writable; - - EBookListener *listener; - EComponentListener *comp_listener; - - GNOME_Evolution_Addressbook_Book corba_book; - - EBookLoadState load_state; - - - EBookOp *current_op; - - EMutex *mutex; - - gchar *uri; - - gulong listener_signal; - gulong died_signal; -}; - - -/* Error quark */ -GQuark -e_book_error_quark (void) -{ - static GQuark q = 0; - if (q == 0) - q = g_quark_from_static_string ("e-book-error-quark"); - - return q; -} - - - -/* EBookOp calls */ - -static EBookOp* -e_book_new_op (EBook *book) -{ - EBookOp *op = g_new0 (EBookOp, 1); - - op->mutex = e_mutex_new (E_MUTEX_SIMPLE); - pthread_cond_init (&op->cond, 0); - - book->priv->current_op = op; - - return op; -} - -static EBookOp* -e_book_get_op (EBook *book) -{ - if (!book->priv->current_op) { - g_warning ("unexpected response"); - return NULL; - } - - return book->priv->current_op; -} - -static void -e_book_op_free (EBookOp *op) -{ - /* XXX more stuff here */ - pthread_cond_destroy (&op->cond); - e_mutex_destroy (op->mutex); - g_free (op); -} - -static void -e_book_op_remove (EBook *book, - EBookOp *op) -{ - if (book->priv->current_op != op) - g_warning ("cannot remove op, it's not current"); - - book->priv->current_op = NULL; -} - -static void -e_book_clear_op (EBook *book, - EBookOp *op) -{ - e_book_op_remove (book, op); - e_mutex_unlock (op->mutex); - e_book_op_free (op); -} - - - -/** - * e_book_add_card: - * @book: an #EBook - * @contact: an #EContact - * - * adds @contact to @book. - * - * Return value: a #EBookStatus value. - **/ -gboolean -e_book_add_contact (EBook *book, - EContact *contact, - GError **error) -{ - EBookOp *our_op; - EBookStatus status; - CORBA_Environment ev; - char *vcard_str; - - printf ("e_book_add_contact\n"); - - e_return_error_if_fail (book && E_IS_BOOK (book), E_BOOK_ERROR_INVALID_ARG); - e_return_error_if_fail (contact && E_IS_CONTACT (contact), E_BOOK_ERROR_INVALID_ARG); - - e_mutex_lock (book->priv->mutex); - - if (book->priv->load_state != E_BOOK_URI_LOADED) { - e_mutex_unlock (book->priv->mutex); - g_set_error (error, E_BOOK_ERROR, E_BOOK_ERROR_URI_NOT_LOADED, - _("e_book_add_contact called on book before e_book_load_uri")); - return FALSE; - } - - if (book->priv->current_op != NULL) { - e_mutex_unlock (book->priv->mutex); - g_set_error (error, E_BOOK_ERROR, E_BOOK_ERROR_BUSY, - _("book busy")); - return FALSE; - } - - vcard_str = e_vcard_to_string (E_VCARD (contact), EVC_FORMAT_VCARD_30); - - our_op = e_book_new_op (book); - - e_mutex_lock (our_op->mutex); - - e_mutex_unlock (book->priv->mutex); - - CORBA_exception_init (&ev); - - /* will eventually end up calling e_book_response_add_contact */ - GNOME_Evolution_Addressbook_Book_addContact (book->priv->corba_book, - (const GNOME_Evolution_Addressbook_VCard) vcard_str, &ev); - - g_free (vcard_str); - - if (ev._major != CORBA_NO_EXCEPTION) { - - e_book_clear_op (book, our_op); - - CORBA_exception_free (&ev); - - g_set_error (error, E_BOOK_ERROR, E_BOOK_ERROR_CORBA_EXCEPTION, - _("Corba exception making Book::addContact call")); - return FALSE; - } - - CORBA_exception_free (&ev); - - /* wait for something to happen (both cancellation and a - successful response will notity us via our cv */ - e_mutex_cond_wait (&our_op->cond, our_op->mutex); - - status = our_op->status; - e_contact_set (contact, E_CONTACT_UID, our_op->id); - g_free (our_op->id); - - e_book_clear_op (book, our_op); - - E_BOOK_CHECK_STATUS (status, error); -} - -static void -e_book_response_add_contact (EBook *book, - EBookStatus status, - char *id) -{ - EBookOp *op; - - printf ("e_book_response_add_contact\n"); - - op = e_book_get_op (book); - - if (op == NULL) { - g_warning ("e_book_response_add_contact: Cannot find operation "); - return; - } - - e_mutex_lock (op->mutex); - - op->status = status; - op->id = g_strdup (id); - - pthread_cond_signal (&op->cond); - - e_mutex_unlock (op->mutex); -} - - - -/** - * e_book_commit_contact: - * @book: an #EBook - * @contact: an #EContact - * - * applies the changes made to @contact to the stored version in - * @book. - * - * Return value: a #EBookStatus value. - **/ -gboolean -e_book_commit_contact (EBook *book, - EContact *contact, - GError **error) -{ - EBookOp *our_op; - EBookStatus status; - CORBA_Environment ev; - char *vcard_str; - - e_return_error_if_fail (book && E_IS_BOOK (book), E_BOOK_ERROR_INVALID_ARG); - e_return_error_if_fail (contact && E_IS_CONTACT (contact), E_BOOK_ERROR_INVALID_ARG); - - e_mutex_lock (book->priv->mutex); - - if (book->priv->load_state != E_BOOK_URI_LOADED) { - e_mutex_unlock (book->priv->mutex); - g_set_error (error, E_BOOK_ERROR, E_BOOK_ERROR_URI_NOT_LOADED, - _("e_book_commit_contact called on book before e_book_load_uri")); - return FALSE; - } - - if (book->priv->current_op != NULL) { - e_mutex_unlock (book->priv->mutex); - g_set_error (error, E_BOOK_ERROR, E_BOOK_ERROR_BUSY, - _("book busy")); - return FALSE; - } - - vcard_str = e_vcard_to_string (E_VCARD (contact), EVC_FORMAT_VCARD_30); - - our_op = e_book_new_op (book); - - e_mutex_lock (our_op->mutex); - - e_mutex_unlock (book->priv->mutex); - - CORBA_exception_init (&ev); - - /* will eventually end up calling _e_book_response_generic */ - GNOME_Evolution_Addressbook_Book_modifyContact (book->priv->corba_book, - (const GNOME_Evolution_Addressbook_VCard) vcard_str, &ev); - - g_free (vcard_str); - - if (ev._major != CORBA_NO_EXCEPTION) { - - e_book_clear_op (book, our_op); - - CORBA_exception_free (&ev); - - g_set_error (error, E_BOOK_ERROR, E_BOOK_ERROR_CORBA_EXCEPTION, - _("Corba exception making Book::modifyContact call")); - return FALSE; - } - - CORBA_exception_free (&ev); - - /* wait for something to happen (both cancellation and a - successful response will notity us via our cv */ - e_mutex_cond_wait (&our_op->cond, our_op->mutex); - - status = our_op->status; - e_contact_set (contact, E_CONTACT_UID, our_op->id); - g_free (our_op->id); - - /* remove the op from the book's hash of operations */ - e_book_clear_op (book, our_op); - - E_BOOK_CHECK_STATUS (status, error); -} - - -/** - * e_book_get_supported_fields: - * @book: an #EBook - * @fields: a #GList - * - * queries @book for the list of fields it supports. mostly for use - * by the contact editor so it knows what fields to sensitize. - * - * Return value: a #EBookStatus value. - **/ -gboolean -e_book_get_supported_fields (EBook *book, - GList **fields, - GError **error) -{ - EBookOp *our_op; - EBookStatus status; - CORBA_Environment ev; - - e_return_error_if_fail (book && E_IS_BOOK (book), E_BOOK_ERROR_INVALID_ARG); - e_return_error_if_fail (fields, E_BOOK_ERROR_INVALID_ARG); - - e_mutex_lock (book->priv->mutex); - - if (book->priv->load_state != E_BOOK_URI_LOADED) { - e_mutex_unlock (book->priv->mutex); - g_set_error (error, E_BOOK_ERROR, E_BOOK_ERROR_URI_NOT_LOADED, - _("e_book_get_supported_fields on book before e_book_load_uri")); - return FALSE; - } - - if (book->priv->current_op != NULL) { - e_mutex_unlock (book->priv->mutex); - g_set_error (error, E_BOOK_ERROR, E_BOOK_ERROR_BUSY, - _("book busy")); - } - - our_op = e_book_new_op (book); - - e_mutex_lock (our_op->mutex); - - e_mutex_unlock (book->priv->mutex); - - CORBA_exception_init (&ev); - - /* will eventually end up calling - _e_book_response_get_supported_fields */ - GNOME_Evolution_Addressbook_Book_getSupportedFields(book->priv->corba_book, &ev); - - if (ev._major != CORBA_NO_EXCEPTION) { - - e_book_clear_op (book, our_op); - - CORBA_exception_free (&ev); - - g_set_error (error, E_BOOK_ERROR, E_BOOK_ERROR_CORBA_EXCEPTION, - _("Corba exception making Book::getSupportedFields call")); - return FALSE; - } - - - CORBA_exception_free (&ev); - - /* wait for something to happen (both cancellation and a - successful response will notity us via our cv */ - e_mutex_cond_wait (&our_op->cond, our_op->mutex); - - status = our_op->status; - *fields = our_op->list; - - e_book_clear_op (book, our_op); - - E_BOOK_CHECK_STATUS (status, error); -} - -static void -e_book_response_get_supported_fields (EBook *book, - EBookStatus status, - GList *fields) -{ - EBookOp *op; - - op = e_book_get_op (book); - - if (op == NULL) { - g_warning ("e_book_response_get_supported_fields: Cannot find operation "); - return; - } - - e_mutex_lock (op->mutex); - - op->status = status; - op->list = fields; - - pthread_cond_signal (&op->cond); - - e_mutex_unlock (op->mutex); -} - - -/** - * e_book_get_supported_auth_methods: - * @book: an #EBook - * @auth_methods: a #GList - * - * queries @book for the list of authentication methods it supports. - * - * Return value: a #EBookStatus value. - **/ -gboolean -e_book_get_supported_auth_methods (EBook *book, - GList **auth_methods, - GError **error) -{ - EBookOp *our_op; - EBookStatus status; - CORBA_Environment ev; - - e_return_error_if_fail (book && E_IS_BOOK (book), E_BOOK_ERROR_INVALID_ARG); - e_return_error_if_fail (auth_methods, E_BOOK_ERROR_INVALID_ARG); - - e_mutex_lock (book->priv->mutex); - - if (book->priv->load_state != E_BOOK_URI_LOADED) { - e_mutex_unlock (book->priv->mutex); - g_set_error (error, E_BOOK_ERROR, E_BOOK_ERROR_URI_NOT_LOADED, - _("e_book_get_supported_auth_methods on book before e_book_load_uri")); - return FALSE; - } - - if (book->priv->current_op != NULL) { - e_mutex_unlock (book->priv->mutex); - g_set_error (error, E_BOOK_ERROR, E_BOOK_ERROR_BUSY, - _("book busy")); - return FALSE; - } - - our_op = e_book_new_op (book); - - e_mutex_lock (our_op->mutex); - - e_mutex_unlock (book->priv->mutex); - - CORBA_exception_init (&ev); - - /* will eventually end up calling - e_book_response_get_supported_fields */ - GNOME_Evolution_Addressbook_Book_getSupportedAuthMethods(book->priv->corba_book, &ev); - - if (ev._major != CORBA_NO_EXCEPTION) { - - e_book_clear_op (book, our_op); - - CORBA_exception_free (&ev); - - g_set_error (error, E_BOOK_ERROR, E_BOOK_ERROR_CORBA_EXCEPTION, - _("Corba exception making Book::getSupportedAuthMethods call")); - return FALSE; - } - - - CORBA_exception_free (&ev); - - /* wait for something to happen (both cancellation and a - successful response will notity us via our cv */ - e_mutex_cond_wait (&our_op->cond, our_op->mutex); - - status = our_op->status; - *auth_methods = our_op->list; - - e_book_clear_op (book, our_op); - - E_BOOK_CHECK_STATUS (status, error); -} - -static void -e_book_response_get_supported_auth_methods (EBook *book, - EBookStatus status, - GList *auth_methods) -{ - EBookOp *op; - - op = e_book_get_op (book); - - if (op == NULL) { - g_warning ("e_book_response_get_supported_auth_methods: Cannot find operation "); - return; - } - - e_mutex_lock (op->mutex); - - op->status = status; - op->list = auth_methods; - - pthread_cond_signal (&op->cond); - - e_mutex_unlock (op->mutex); -} - - - -/** - * e_book_authenticate_user: - * @book: an #EBook - * @user: a string - * @passwd: a string - * @auth_method: a string - * - * authenticates @user with @passwd, using the auth method - * @auth_method. @auth_method must be one of the authentication - * methods returned using e_book_get_supported_auth_methods. - * - * Return value: a #EBookStatus value. - **/ -gboolean -e_book_authenticate_user (EBook *book, - const char *user, - const char *passwd, - const char *auth_method, - GError **error) -{ - EBookOp *our_op; - EBookStatus status; - CORBA_Environment ev; - - e_return_error_if_fail (book && E_IS_BOOK (book), E_BOOK_ERROR_INVALID_ARG); - e_return_error_if_fail (user, E_BOOK_ERROR_INVALID_ARG); - e_return_error_if_fail (passwd, E_BOOK_ERROR_INVALID_ARG); - e_return_error_if_fail (auth_method, E_BOOK_ERROR_INVALID_ARG); - - e_mutex_lock (book->priv->mutex); - - if (book->priv->load_state != E_BOOK_URI_LOADED) { - e_mutex_unlock (book->priv->mutex); - g_set_error (error, E_BOOK_ERROR, E_BOOK_ERROR_URI_NOT_LOADED, - _("e_book_authenticate_user on book before e_book_load_uri")); - return FALSE; - } - - if (book->priv->current_op != NULL) { - e_mutex_unlock (book->priv->mutex); - g_set_error (error, E_BOOK_ERROR, E_BOOK_ERROR_BUSY, - _("book busy")); - return FALSE; - } - - our_op = e_book_new_op (book); - - e_mutex_lock (our_op->mutex); - - e_mutex_unlock (book->priv->mutex); - - CORBA_exception_init (&ev); - - /* will eventually end up calling - e_book_response_generic */ - GNOME_Evolution_Addressbook_Book_authenticateUser (book->priv->corba_book, - user, passwd, - auth_method, - &ev); - - if (ev._major != CORBA_NO_EXCEPTION) { - - e_book_clear_op (book, our_op); - - CORBA_exception_free (&ev); - - g_set_error (error, E_BOOK_ERROR, E_BOOK_ERROR_CORBA_EXCEPTION, - _("Corba exception making Book::authenticateUser call")); - return FALSE; - } - - CORBA_exception_free (&ev); - - /* wait for something to happen (both cancellation and a - successful response will notity us via our cv */ - e_mutex_cond_wait (&our_op->cond, our_op->mutex); - - status = our_op->status; - - e_book_clear_op (book, our_op); - - E_BOOK_CHECK_STATUS (status, error); -} - - -/** - * e_book_get_contact: - * @book: an #EBook - * @id: a string - * @contact: an #EContact - * - * Fills in @contact with the contents of the vcard in @book - * corresponding to @id. - * - * Return value: a #EBookStatus value. - **/ -gboolean -e_book_get_contact (EBook *book, - const char *id, - EContact **contact, - GError **error) -{ - EBookOp *our_op; - EBookStatus status; - CORBA_Environment ev; - - e_return_error_if_fail (book && E_IS_BOOK (book), E_BOOK_ERROR_INVALID_ARG); - e_return_error_if_fail (id, E_BOOK_ERROR_INVALID_ARG); - e_return_error_if_fail (contact, E_BOOK_ERROR_INVALID_ARG); - - e_mutex_lock (book->priv->mutex); - - if (book->priv->load_state != E_BOOK_URI_LOADED) { - e_mutex_unlock (book->priv->mutex); - g_set_error (error, E_BOOK_ERROR, E_BOOK_ERROR_URI_NOT_LOADED, - _("e_book_get_contact on book before e_book_load_uri")); - return FALSE; - } - - if (book->priv->current_op != NULL) { - e_mutex_unlock (book->priv->mutex); - g_set_error (error, E_BOOK_ERROR, E_BOOK_ERROR_BUSY, - _("book busy")); - return FALSE; - } - - our_op = e_book_new_op (book); - - e_mutex_lock (our_op->mutex); - - e_mutex_unlock (book->priv->mutex); - - CORBA_exception_init (&ev); - - /* will eventually end up calling e_book_response_generic */ - GNOME_Evolution_Addressbook_Book_getContact (book->priv->corba_book, - (const GNOME_Evolution_Addressbook_VCard) id, &ev); - - if (ev._major != CORBA_NO_EXCEPTION) { - - e_book_clear_op (book, our_op); - - CORBA_exception_free (&ev); - - g_set_error (error, E_BOOK_ERROR, E_BOOK_ERROR_CORBA_EXCEPTION, - _("Corba exception making Book::getContact call")); - return FALSE; - } - - CORBA_exception_free (&ev); - - /* wait for something to happen (both cancellation and a - successful response will notity us via our cv */ - e_mutex_cond_wait (&our_op->cond, our_op->mutex); - - status = our_op->status; - *contact = our_op->contact; - - e_book_clear_op (book, our_op); - - E_BOOK_CHECK_STATUS (status, error); -} - -static void -e_book_response_get_contact (EBook *book, - EBookStatus status, - EContact *contact) -{ - EBookOp *op; - - printf ("e_book_response_get_contact\n"); - - op = e_book_get_op (book); - - if (op == NULL) { - g_warning ("e_book_response_get_contact: Cannot find operation "); - return; - } - - e_mutex_lock (op->mutex); - - op->status = status; - op->contact = contact; - - pthread_cond_signal (&op->cond); - - e_mutex_unlock (op->mutex); -} - - -/** - * e_book_remove_contact: - * @book: an #EBook - * @id: a string - * - * Removes the contact with id @id from @book. - * - * Return value: a #EBookStatus value. - **/ -gboolean -e_book_remove_contact (EBook *book, - const char *id, - GError **error) -{ - GList *list; - gboolean rv; - - e_return_error_if_fail (book && E_IS_BOOK (book), E_BOOK_ERROR_INVALID_ARG); - e_return_error_if_fail (id, E_BOOK_ERROR_INVALID_ARG); - - e_mutex_lock (book->priv->mutex); - - if (book->priv->load_state != E_BOOK_URI_LOADED) { - e_mutex_unlock (book->priv->mutex); - g_set_error (error, E_BOOK_ERROR, E_BOOK_ERROR_URI_NOT_LOADED, - _("e_book_remove_contact on book before e_book_load_uri")); - return FALSE; - } - - if (book->priv->current_op != NULL) { - e_mutex_unlock (book->priv->mutex); - g_set_error (error, E_BOOK_ERROR, E_BOOK_ERROR_BUSY, - _("book busy")); - return FALSE; - } - - e_mutex_lock (book->priv->mutex); - - list = g_list_append (NULL, (char*)id); - - rv = e_book_remove_contacts (book, list, error); - - return rv; -} - -/** - * e_book_remove_contacts: - * @book: an #EBook - * @ids: an #GList of const char *id's - * - * Removes the contacts with ids from the list @ids from @book. This is - * always more efficient than calling e_book_remove_contact_by_id if you - * have more than one id to remove, as some backends can implement it - * as a batch request. - * - * Return value: a #EBookStatus value. - **/ -gboolean -e_book_remove_contacts (EBook *book, - GList *ids, - GError **error) -{ - GNOME_Evolution_Addressbook_ContactIdList idlist; - CORBA_Environment ev; - GList *iter; - int num_ids, i; - EBookOp *our_op; - EBookStatus status; - - e_return_error_if_fail (book && E_IS_BOOK (book), E_BOOK_ERROR_INVALID_ARG); - e_return_error_if_fail (ids, E_BOOK_ERROR_INVALID_ARG); - - e_mutex_lock (book->priv->mutex); - - if (book->priv->load_state != E_BOOK_URI_LOADED) { - e_mutex_unlock (book->priv->mutex); - g_set_error (error, E_BOOK_ERROR, E_BOOK_ERROR_URI_NOT_LOADED, - _("e_book_remove_contacts on book before e_book_load_uri")); - return FALSE; - } - - if (book->priv->current_op != NULL) { - e_mutex_unlock (book->priv->mutex); - g_set_error (error, E_BOOK_ERROR, E_BOOK_ERROR_BUSY, - _("book busy")); - return FALSE; - } - - our_op = e_book_new_op (book); - - e_mutex_lock (our_op->mutex); - - e_mutex_unlock (book->priv->mutex); - - CORBA_exception_init (&ev); - - num_ids = g_list_length (ids); - idlist._buffer = CORBA_sequence_GNOME_Evolution_Addressbook_ContactId_allocbuf (num_ids); - idlist._maximum = num_ids; - idlist._length = num_ids; - - for (iter = ids, i = 0; iter; iter = iter->next) - idlist._buffer[i++] = CORBA_string_dup (iter->data); - - /* will eventually end up calling e_book_response_generic */ - GNOME_Evolution_Addressbook_Book_removeContacts (book->priv->corba_book, &idlist, &ev); - - CORBA_free(idlist._buffer); - - if (ev._major != CORBA_NO_EXCEPTION) { - - e_book_clear_op (book, our_op); - - CORBA_exception_free (&ev); - - g_set_error (error, E_BOOK_ERROR, E_BOOK_ERROR_CORBA_EXCEPTION, - _("Corba exception making Book::removeContacts call")); - return FALSE; - } - - CORBA_exception_free (&ev); - - /* wait for something to happen (both cancellation and a - successful response will notity us via our cv */ - e_mutex_cond_wait (&our_op->cond, our_op->mutex); - - status = our_op->status; - - e_book_clear_op (book, our_op); - - E_BOOK_CHECK_STATUS (status, error); -} - - -/** - * e_book_get_book_view: - * @book: an #EBook - * @query: an #EBookQuery - * @requested_fields a #GList containing the names of fields to return, or NULL for all - * @max_results the maximum number of contacts to show (or 0 for all) - * - * need docs here.. - * - * Return value: a #EBookStatus value. - **/ -gboolean -e_book_get_book_view (EBook *book, - EBookQuery *query, - GList *requested_fields, - int max_results, - EBookView **book_view, - GError **error) -{ - GNOME_Evolution_Addressbook_stringlist stringlist; - CORBA_Environment ev; - EBookOp *our_op; - EBookStatus status; - int num_fields, i; - GList *iter; - char *query_string; - - e_return_error_if_fail (book && E_IS_BOOK (book), E_BOOK_ERROR_INVALID_ARG); - e_return_error_if_fail (query, E_BOOK_ERROR_INVALID_ARG); - e_return_error_if_fail (book_view, E_BOOK_ERROR_INVALID_ARG); - - e_mutex_lock (book->priv->mutex); - - if (book->priv->load_state != E_BOOK_URI_LOADED) { - e_mutex_unlock (book->priv->mutex); - g_set_error (error, E_BOOK_ERROR, E_BOOK_ERROR_URI_NOT_LOADED, - _("e_book_get_book_view on book before e_book_load_uri")); - return FALSE; - } - - if (book->priv->current_op != NULL) { - e_mutex_unlock (book->priv->mutex); - g_set_error (error, E_BOOK_ERROR, E_BOOK_ERROR_BUSY, - _("book busy")); - return FALSE; - } - - our_op = e_book_new_op (book); - - e_mutex_lock (our_op->mutex); - - e_mutex_unlock (book->priv->mutex); - - CORBA_exception_init (&ev); - - our_op->listener = e_book_view_listener_new(); - - num_fields = g_list_length (requested_fields); - - stringlist._buffer = CORBA_sequence_CORBA_string_allocbuf (num_fields); - stringlist._maximum = num_fields; - stringlist._length = num_fields; - - for (i = 0, iter = requested_fields; iter; iter = iter->next, i ++) { - stringlist._buffer[i] = CORBA_string_dup ((char*)iter->data); - } - - query_string = e_book_query_to_string (query); - - /* will eventually end up calling e_book_response_get_book_view */ - GNOME_Evolution_Addressbook_Book_getBookView (book->priv->corba_book, - bonobo_object_corba_objref(BONOBO_OBJECT(our_op->listener)), - query_string, - &stringlist, max_results, &ev); - - CORBA_free(stringlist._buffer); - g_free (query_string); - - if (ev._major != CORBA_NO_EXCEPTION) { - - e_book_clear_op (book, our_op); - - CORBA_exception_free (&ev); - - g_warning ("corba exception._major = %d\n", ev._major); - - g_set_error (error, E_BOOK_ERROR, E_BOOK_ERROR_CORBA_EXCEPTION, - _("Corba exception making Book::getBookView call")); - return FALSE; - } - - CORBA_exception_free (&ev); - - /* wait for something to happen (both cancellation and a - successful response will notity us via our cv */ - e_mutex_cond_wait (&our_op->cond, our_op->mutex); - - status = our_op->status; - *book_view = our_op->view; - - e_book_clear_op (book, our_op); - - E_BOOK_CHECK_STATUS (status, error); -} - -static void -e_book_response_get_book_view (EBook *book, - EBookStatus status, - GNOME_Evolution_Addressbook_BookView corba_book_view) -{ - - EBookOp *op; - - printf ("e_book_response_get_book_view\n"); - - op = e_book_get_op (book); - - if (op == NULL) { - g_warning ("e_book_response_get_book_view: Cannot find operation "); - return; - } - - e_mutex_lock (op->mutex); - - op->status = status; - op->view = e_book_view_new (corba_book_view, op->listener); - - bonobo_object_ref(BONOBO_OBJECT(op->listener)); - - pthread_cond_signal (&op->cond); - - e_mutex_unlock (op->mutex); -} - - - -/** - * e_book_get_contacts: - * @book: an #EBook - * @query: an #EBookQuery - * - * need docs here.. - * - * Return value: a #EBookStatus value. - **/ -gboolean -e_book_get_contacts (EBook *book, - EBookQuery *query, - GList **contacts, - GError **error) -{ - CORBA_Environment ev; - EBookOp *our_op; - EBookStatus status; - char *query_string; - - e_return_error_if_fail (book && E_IS_BOOK (book), E_BOOK_ERROR_INVALID_ARG); - e_return_error_if_fail (query, E_BOOK_ERROR_INVALID_ARG); - e_return_error_if_fail (contacts, E_BOOK_ERROR_INVALID_ARG); - - e_mutex_lock (book->priv->mutex); - - if (book->priv->load_state != E_BOOK_URI_LOADED) { - e_mutex_unlock (book->priv->mutex); - g_set_error (error, E_BOOK_ERROR, E_BOOK_ERROR_URI_NOT_LOADED, - _("e_book_get_contacts on book before e_book_load_uri")); - return FALSE; - } - - if (book->priv->current_op != NULL) { - e_mutex_unlock (book->priv->mutex); - g_set_error (error, E_BOOK_ERROR, E_BOOK_ERROR_BUSY, - _("book busy")); - return FALSE; - } - - our_op = e_book_new_op (book); - - e_mutex_lock (our_op->mutex); - - e_mutex_unlock (book->priv->mutex); - - CORBA_exception_init (&ev); - - query_string = e_book_query_to_string (query); - - /* will eventually end up calling e_book_response_get_contacts */ - GNOME_Evolution_Addressbook_Book_getContactList (book->priv->corba_book, query_string, &ev); - - g_free (query_string); - - if (ev._major != CORBA_NO_EXCEPTION) { - - e_book_clear_op (book, our_op); - - CORBA_exception_free (&ev); - - g_warning ("corba exception._major = %d\n", ev._major); - - g_set_error (error, E_BOOK_ERROR, E_BOOK_ERROR_CORBA_EXCEPTION, - _("Corba exception making Book::getContactList call")); - return FALSE; - } - - CORBA_exception_free (&ev); - - /* wait for something to happen (both cancellation and a - successful response will notity us via our cv */ - e_mutex_cond_wait (&our_op->cond, our_op->mutex); - - status = our_op->status; - *contacts = our_op->list; - - e_book_clear_op (book, our_op); - - E_BOOK_CHECK_STATUS (status, error); -} - -static void -e_book_response_get_contacts (EBook *book, - EBookStatus status, - GList *contact_list) -{ - - EBookOp *op; - - op = e_book_get_op (book); - - if (op == NULL) { - g_warning ("e_book_response_get_contacts: Cannot find operation "); - return; - } - - e_mutex_lock (op->mutex); - - op->status = status; - op->list = contact_list; - - pthread_cond_signal (&op->cond); - - e_mutex_unlock (op->mutex); -} - - -gboolean -e_book_get_changes (EBook *book, - char *changeid, - GList **changes, - GError **error) -{ - CORBA_Environment ev; - EBookOp *our_op; - EBookStatus status; - - e_return_error_if_fail (book && E_IS_BOOK (book), E_BOOK_ERROR_INVALID_ARG); - e_return_error_if_fail (changeid, E_BOOK_ERROR_INVALID_ARG); - e_return_error_if_fail (changes, E_BOOK_ERROR_INVALID_ARG); - - e_mutex_lock (book->priv->mutex); - - if (book->priv->load_state != E_BOOK_URI_LOADED) { - e_mutex_unlock (book->priv->mutex); - g_set_error (error, E_BOOK_ERROR, E_BOOK_ERROR_URI_NOT_LOADED, - _("e_book_get_changes on book before e_book_load_uri")); - return FALSE; - } - - if (book->priv->current_op != NULL) { - e_mutex_unlock (book->priv->mutex); - g_set_error (error, E_BOOK_ERROR, E_BOOK_ERROR_BUSY, - _("book busy")); - return FALSE; - } - - our_op = e_book_new_op (book); - - e_mutex_lock (our_op->mutex); - - e_mutex_unlock (book->priv->mutex); - - CORBA_exception_init (&ev); - - /* will eventually end up calling e_book_response_get_changes */ - GNOME_Evolution_Addressbook_Book_getChanges (book->priv->corba_book, changeid, &ev); - - if (ev._major != CORBA_NO_EXCEPTION) { - - e_book_clear_op (book, our_op); - - CORBA_exception_free (&ev); - - g_warning ("corba exception._major = %d\n", ev._major); - - g_set_error (error, E_BOOK_ERROR, E_BOOK_ERROR_CORBA_EXCEPTION, - _("Corba exception making Book::getChanges call")); - return FALSE; - } - - CORBA_exception_free (&ev); - - /* wait for something to happen (both cancellation and a - successful response will notity us via our cv */ - e_mutex_cond_wait (&our_op->cond, our_op->mutex); - - status = our_op->status; - *changes = our_op->list; - - e_book_clear_op (book, our_op); - - E_BOOK_CHECK_STATUS (status, error); -} - -static void -e_book_response_get_changes (EBook *book, - EBookStatus status, - GList *change_list) -{ - - EBookOp *op; - - op = e_book_get_op (book); - - if (op == NULL) { - g_warning ("e_book_response_get_contacts: Cannot find operation "); - return; - } - - e_mutex_lock (op->mutex); - - op->status = status; - op->list = change_list; - - pthread_cond_signal (&op->cond); - - e_mutex_unlock (op->mutex); -} - -void -e_book_free_change_list (GList *change_list) -{ - GList *l; - for (l = change_list; l; l = l->next) { - EBookChange *change = l->data; - - g_object_unref (change->contact); - g_free (change); - } - - g_list_free (change_list); -} - - - -static void -e_book_response_generic (EBook *book, - EBookStatus status) -{ - EBookOp *op; - - op = e_book_get_op (book); - - if (op == NULL) { - g_warning ("e_book_response_generic: Cannot find operation "); - return; - } - - e_mutex_lock (op->mutex); - - op->status = status; - - pthread_cond_signal (&op->cond); - - e_mutex_unlock (op->mutex); -} - -/** - * e_book_cancel: - * @book: an #EBook - * - * Used to cancel an already running operation on @book. This - * function makes a synchronous CORBA to the backend telling it to - * cancel the operation. If the operation wasn't cancellable (either - * transiently or permanently) or had already comopleted on the wombat - * side, this function will return E_BOOK_STATUS_COULD_NOT_CANCEL, and - * the operation will continue uncancelled. If the operation could be - * cancelled, this function will return E_BOOK_ERROR_OK, and the - * blocked e_book function corresponding to current operation will - * return with a status of E_BOOK_STATUS_CANCELLED. - * - * Return value: a #EBookStatus value. - **/ -gboolean -e_book_cancel (EBook *book, - GError **error) -{ - EBookOp *op; - EBookStatus status; - gboolean rv; - CORBA_Environment ev; - - e_mutex_lock (book->priv->mutex); - - if (book->priv->current_op == NULL) { - e_mutex_unlock (book->priv->mutex); - g_set_error (error, E_BOOK_ERROR, E_BOOK_ERROR_COULD_NOT_CANCEL, - _("e_book_cancel: there is no current operation")); - return FALSE; - } - - op = book->priv->current_op; - - e_mutex_lock (op->mutex); - - e_mutex_unlock (book->priv->mutex); - - status = GNOME_Evolution_Addressbook_Book_cancelOperation(book->priv->corba_book, &ev); - - if (ev._major != CORBA_NO_EXCEPTION) { - - e_mutex_unlock (op->mutex); - - CORBA_exception_free (&ev); - - g_set_error (error, E_BOOK_ERROR, E_BOOK_ERROR_CORBA_EXCEPTION, - _("Corba exception making Book::cancelOperation call")); - return FALSE; - } - - CORBA_exception_free (&ev); - - if (status == E_BOOK_ERROR_OK) { - op->status = E_BOOK_ERROR_CANCELLED; - - pthread_cond_signal (&op->cond); - - rv = TRUE; - } - else { - g_set_error (error, E_BOOK_ERROR, E_BOOK_ERROR_COULD_NOT_CANCEL, - _("e_book_cancel: couldn't cancel")); - rv = FALSE; - } - - e_mutex_unlock (op->mutex); - - return rv; -} - -static void -e_book_response_open (EBook *book, - EBookStatus status) -{ - EBookOp *op; - - op = e_book_get_op (book); - - if (op == NULL) { - g_warning ("e_book_response_open: Cannot find operation "); - return; - } - - e_mutex_lock (op->mutex); - - op->status = status; - - pthread_cond_signal (&op->cond); - - e_mutex_unlock (op->mutex); -} - - - -gboolean -e_book_remove (EBook *book, - GError **error) -{ - CORBA_Environment ev; - EBookOp *our_op; - EBookStatus status; - - e_return_error_if_fail (book && E_IS_BOOK (book), E_BOOK_ERROR_INVALID_ARG); - - e_mutex_lock (book->priv->mutex); - - if (book->priv->load_state != E_BOOK_URI_LOADED) { - e_mutex_unlock (book->priv->mutex); - g_set_error (error, E_BOOK_ERROR, E_BOOK_ERROR_URI_NOT_LOADED, - _("e_book_remove on book before e_book_load_uri")); - return FALSE; - } - - if (book->priv->current_op != NULL) { - e_mutex_unlock (book->priv->mutex); - g_set_error (error, E_BOOK_ERROR, E_BOOK_ERROR_BUSY, - _("book busy")); - return FALSE; - } - - our_op = e_book_new_op (book); - - e_mutex_lock (our_op->mutex); - - e_mutex_unlock (book->priv->mutex); - - CORBA_exception_init (&ev); - - /* will eventually end up calling e_book_response_remove */ - GNOME_Evolution_Addressbook_Book_remove (book->priv->corba_book, &ev); - - if (ev._major != CORBA_NO_EXCEPTION) { - - e_book_clear_op (book, our_op); - - CORBA_exception_free (&ev); - - g_set_error (error, E_BOOK_ERROR, E_BOOK_ERROR_CORBA_EXCEPTION, - _("Corba exception making Book::remove call")); - return FALSE; - } - - CORBA_exception_free (&ev); - - /* wait for something to happen (both cancellation and a - successful response will notity us via our cv */ - e_mutex_cond_wait (&our_op->cond, our_op->mutex); - - status = our_op->status; - - e_book_clear_op (book, our_op); - - E_BOOK_CHECK_STATUS (status, error); -} - -static void -e_book_response_remove (EBook *book, - EBookStatus status) -{ - EBookOp *op; - - printf ("e_book_response_remove\n"); - - op = e_book_get_op (book); - - if (op == NULL) { - g_warning ("e_book_response_remove: Cannot find operation "); - return; - } - - e_mutex_lock (op->mutex); - - op->status = status; - - pthread_cond_signal (&op->cond); - - e_mutex_unlock (op->mutex); -} - - - -static void -e_book_handle_response (EBookListener *listener, EBookListenerResponse *resp, EBook *book) -{ - switch (resp->op) { - case CreateContactResponse: - e_book_response_add_contact (book, resp->status, resp->id); - break; - case RemoveContactResponse: - case ModifyContactResponse: - case AuthenticationResponse: - e_book_response_generic (book, resp->status); - break; - case GetContactResponse: { - EContact *contact = e_contact_new_from_vcard (resp->vcard); - e_book_response_get_contact (book, resp->status, contact); - break; - } - case GetContactListResponse: - e_book_response_get_contacts (book, resp->status, resp->list); - break; - case GetBookViewResponse: - e_book_response_get_book_view(book, resp->status, resp->book_view); - break; - case GetChangesResponse: - e_book_response_get_changes(book, resp->status, resp->list); - break; - case OpenBookResponse: - e_book_response_open (book, resp->status); - break; - case RemoveBookResponse: - e_book_response_remove (book, resp->status); - break; - case GetSupportedFieldsResponse: - e_book_response_get_supported_fields (book, resp->status, resp->list); - break; - case GetSupportedAuthMethodsResponse: - e_book_response_get_supported_auth_methods (book, resp->status, resp->list); - break; - case WritableStatusEvent: - book->priv->writable = resp->writable; - g_signal_emit (book, e_book_signals [WRITABLE_STATUS], 0, resp->writable); - break; - default: - g_error ("EBook: Unknown response code %d!\n", - resp->op); - } -} - - - -gboolean -e_book_unload_uri (EBook *book, - GError **error) -{ - CORBA_Environment ev; - - e_return_error_if_fail (book && E_IS_BOOK (book), E_BOOK_ERROR_INVALID_ARG); - e_return_error_if_fail (book->priv->load_state != E_BOOK_URI_NOT_LOADED, E_BOOK_ERROR_URI_NOT_LOADED); - - /* Release the remote GNOME_Evolution_Addressbook_Book in the PAS. */ - CORBA_exception_init (&ev); - - bonobo_object_release_unref (book->priv->corba_book, &ev); - if (ev._major != CORBA_NO_EXCEPTION) { - g_warning ("e_book_unload_uri: Exception releasing " - "remote book interface!\n"); - } - - CORBA_exception_free (&ev); - - e_book_listener_stop (book->priv->listener); - bonobo_object_unref (BONOBO_OBJECT (book->priv->listener)); - - book->priv->listener = NULL; - book->priv->load_state = E_BOOK_URI_NOT_LOADED; - g_free (book->priv->cap); - book->priv->cap = NULL; - book->priv->writable = FALSE; - - return TRUE; -} - - - -/** - * e_book_load_uri: - */ - -static void -backend_died_cb (EComponentListener *cl, gpointer user_data) -{ - EBook *book = user_data; - - book->priv->load_state = E_BOOK_URI_NOT_LOADED; - g_signal_emit (book, e_book_signals [BACKEND_DIED], 0); -} - -static GList * -activate_factories_for_uri (EBook *book, const char *uri) -{ - CORBA_Environment ev; - Bonobo_ServerInfoList *info_list = NULL; - int i; - char *protocol, *query, *colon; - GList *factories = NULL; - - colon = strchr (uri, ':'); - if (!colon) { - g_warning ("e_book_load_uri: Unable to determine protocol in the URI\n"); - return FALSE; - } - - protocol = g_strndup (uri, colon-uri); - query = g_strdup_printf ("repo_ids.has ('IDL:GNOME/Evolution/BookFactory:1.0')" - " AND addressbook:supported_protocols.has ('%s')", protocol - ); - - CORBA_exception_init (&ev); - - info_list = bonobo_activation_query (query, NULL, &ev); - - if (ev._major != CORBA_NO_EXCEPTION) { - g_warning ("Eeek! Cannot perform bonobo-activation query for book factories."); - CORBA_exception_free (&ev); - goto done; - return NULL; - } - - if (info_list->_length == 0) { - g_warning ("Can't find installed BookFactory that handles protocol '%s'.", protocol); - CORBA_exception_free (&ev); - goto done; - } - - CORBA_exception_free (&ev); - - for (i = 0; i < info_list->_length; i ++) { - const Bonobo_ServerInfo *info; - GNOME_Evolution_Addressbook_BookFactory factory; - - info = info_list->_buffer + i; - - factory = bonobo_activation_activate_from_id (info->iid, 0, NULL, NULL); - - if (factory == CORBA_OBJECT_NIL) - g_warning ("e_book_construct: Could not obtain a handle " - "to the Personal Addressbook Server with IID `%s'\n", info->iid); - else - factories = g_list_append (factories, factory); - } - - done: - if (info_list) - CORBA_free (info_list); - g_free (query); - g_free (protocol); - - return factories; -} - -gboolean -e_book_load_uri (EBook *book, - const char *uri, - gboolean only_if_exists, - GError **error) -{ - GList *factories; - GList *l; - gboolean rv = FALSE; - GNOME_Evolution_Addressbook_Book corba_book = CORBA_OBJECT_NIL; - - e_return_error_if_fail (book && E_IS_BOOK (book), E_BOOK_ERROR_INVALID_ARG); - e_return_error_if_fail (uri, E_BOOK_ERROR_INVALID_ARG); - - /* XXX this needs to happen while holding the book's lock i would think... */ - e_return_error_if_fail (book->priv->load_state == E_BOOK_URI_NOT_LOADED, E_BOOK_ERROR_URI_ALREADY_LOADED); - - /* try to find a list of factories that can handle the protocol */ - if (! (factories = activate_factories_for_uri (book, uri))) { - g_set_error (error, E_BOOK_ERROR, E_BOOK_ERROR_PROTOCOL_NOT_SUPPORTED, - _("e_book_load_uri: no factories available for uri `%s'"), uri); - return FALSE; - } - - - book->priv->load_state = E_BOOK_URI_LOADING; - - /* - * Create our local BookListener interface. - */ - book->priv->listener = e_book_listener_new (); - if (book->priv->listener == NULL) { - g_warning ("e_book_load_uri: Could not create EBookListener!\n"); - g_set_error (error, E_BOOK_ERROR, E_BOOK_ERROR_OTHER_ERROR, - _("e_book_load_uri: Could not create EBookListener")); - return FALSE; - } - book->priv->listener_signal = g_signal_connect (book->priv->listener, "response", - G_CALLBACK (e_book_handle_response), book); - - g_free (book->priv->uri); - book->priv->uri = g_strdup (uri); - - for (l = factories; l; l = l->next) { - GNOME_Evolution_Addressbook_BookFactory factory = l->data; - EBookOp *our_op; - CORBA_Environment ev; - EBookStatus status; - - our_op = e_book_new_op (book); - - e_mutex_lock (our_op->mutex); - - CORBA_exception_init (&ev); - - corba_book = GNOME_Evolution_Addressbook_BookFactory_getBook (factory, book->priv->uri, - bonobo_object_corba_objref (BONOBO_OBJECT (book->priv->listener)), - &ev); - - if (ev._major != CORBA_NO_EXCEPTION) { - e_book_clear_op (book, our_op); - - CORBA_exception_free (&ev); - continue; - } - - GNOME_Evolution_Addressbook_Book_open (corba_book, - only_if_exists, - &ev); - - if (ev._major != CORBA_NO_EXCEPTION) { - /* kill the listener so the book will die */ - g_signal_handler_disconnect (book->priv->listener, book->priv->listener_signal); - bonobo_object_unref (book->priv->listener); - book->priv->listener = NULL; - - e_book_clear_op (book, our_op); - - CORBA_exception_free (&ev); - continue; - } - - CORBA_exception_free (&ev); - - /* wait for something to happen (both cancellation and a - successful response will notity us via our cv */ - e_mutex_cond_wait (&our_op->cond, our_op->mutex); - - status = our_op->status; - - /* remove the op from the book's hash of operations */ - e_book_clear_op (book, our_op); - - if (status == E_BOOK_ERROR_CANCELLED - || status == E_BOOK_ERROR_OK) { - rv = TRUE; - break; - } - } - - /* free up the factories */ - for (l = factories; l; l = l->next) - CORBA_Object_release ((CORBA_Object)l->data, NULL); - - if (rv == TRUE) { - book->priv->corba_book = corba_book; - book->priv->load_state = E_BOOK_URI_LOADED; - book->priv->comp_listener = e_component_listener_new (book->priv->corba_book); - book->priv->died_signal = g_signal_connect (book->priv->comp_listener, "component_died", - G_CALLBACK (backend_died_cb), book); - return TRUE; - } - else { - g_set_error (error, E_BOOK_ERROR, E_BOOK_ERROR_PROTOCOL_NOT_SUPPORTED, - _("e_book_load_uri: no factories available for uri `%s'"), uri); - return FALSE; - } - - return rv; -} - -gboolean -e_book_load_local_addressbook (EBook *book, - GError **error) -{ - char *filename; - char *uri; - gboolean rv; - - filename = g_build_filename (g_get_home_dir(), - "evolution/local/Contacts", - NULL); - uri = g_strdup_printf ("file://%s", filename); - - g_free (filename); - - rv = e_book_load_uri (book, uri, TRUE, error); - - g_free (uri); - - return rv; -} - -const char * -e_book_get_uri (EBook *book) -{ - return book->priv->uri; -} - -const char * -e_book_get_static_capabilities (EBook *book, - GError **error) -{ - if (!book->priv->cap_queried) { - CORBA_Environment ev; - char *temp; - - CORBA_exception_init (&ev); - - if (book->priv->load_state != E_BOOK_URI_LOADED) { - g_warning ("e_book_unload_uri: No URI is loaded!\n"); - return g_strdup(""); - } - - temp = GNOME_Evolution_Addressbook_Book_getStaticCapabilities(book->priv->corba_book, &ev); - - if (ev._major != CORBA_NO_EXCEPTION) { - g_warning ("e_book_get_static_capabilities: Exception " - "during get_static_capabilities!\n"); - CORBA_exception_free (&ev); - return g_strdup(""); - } - - book->priv->cap = g_strdup(temp); - book->priv->cap_queried = TRUE; - - CORBA_free(temp); - - CORBA_exception_free (&ev); - } - - return book->priv->cap; -} - -gboolean -e_book_check_static_capability (EBook *book, - const char *cap) -{ - const char *caps = e_book_get_static_capabilities (book, NULL); - - /* XXX this is an inexact test but it works for our use */ - if (caps && strstr (caps, cap)) - return TRUE; - - return FALSE; -} - -gboolean -e_book_is_writable (EBook *book) -{ - return book->priv->writable; -} - - - - -gboolean -e_book_get_self (EContact **contact, EBook **book, GError **error) -{ - GError *e = NULL; - - if (!e_book_get_default_addressbook (book, &e)) { - g_propagate_error (error, e); - return FALSE; - } - -#if notyet - EBook *b; - char *self_uri, *self_uid; - - /* XXX get the setting for the self book and self uid from gconf */ - - b = e_book_new(); - if (! e_book_load_uri (b, self_uri, TRUE, error)) { - g_object_unref (b); - return FALSE; - } - - if (! e_book_get_contact (b, self_uid, - contact, error)) { - g_object_unref (b); - return FALSE; - } - - if (book) - *book = b; - else - g_object_unref (b); - return TRUE; -#endif -} - -gboolean -e_book_set_self (EBook *book, const char *id, GError **error) -{ -} - - - -gboolean -e_book_get_default_addressbook (EBook **book, GError **error) -{ - /* XXX for now just load the local ~/evolution/local/Contacts */ - char *path, *uri; - gboolean rv; - - *book = e_book_new (); - - path = g_build_filename (g_get_home_dir (), - "evolution/local/Contacts", - NULL); - uri = g_strdup_printf ("file://%s", path); - g_free (path); - - rv = e_book_load_uri (*book, uri, FALSE, error); - - g_free (uri); - - if (!rv) { - g_object_unref (*book); - *book = NULL; - } - - return rv; -#if notyet - EConfigListener *listener = e_config_listener_new (); - ESourceList *sources = ...; - ESource *default_source; - - default_source = e_source_list_peek_source_by_uid (sources, - "default_"); -#endif -} - -#if notyet -ESourceList* -e_book_get_addressbooks (GError **error) -{ -} -#endif - - -static void* -startup_mainloop (void *arg) -{ - bonobo_main(); - return NULL; -} - -/* one-time start up for libebook */ -static void -e_book_activate() -{ - static GStaticMutex e_book_lock = G_STATIC_MUTEX_INIT; - static gboolean activated = FALSE; - - g_static_mutex_lock (&e_book_lock); - if (!activated) { - pthread_t ebook_mainloop_thread; - activated = TRUE; - pthread_create(&ebook_mainloop_thread, NULL, startup_mainloop, NULL); - } - g_static_mutex_unlock (&e_book_lock); -} - - - -EBook* -e_book_new (void) -{ - e_book_activate (); - return g_object_new (E_TYPE_BOOK, NULL); -} - - -static void -e_book_init (EBook *book) -{ - book->priv = g_new0 (EBookPrivate, 1); - book->priv->load_state = E_BOOK_URI_NOT_LOADED; - book->priv->uri = NULL; - book->priv->mutex = e_mutex_new (E_MUTEX_REC); -} - -static void -e_book_dispose (GObject *object) -{ - EBook *book = E_BOOK (object); - - if (book->priv) { - CORBA_Environment ev; - GList *l; - - if (book->priv->comp_listener) { - g_signal_handler_disconnect (book->priv->comp_listener, book->priv->died_signal); - g_object_unref (book->priv->comp_listener); - book->priv->comp_listener = NULL; - } - - if (book->priv->load_state == E_BOOK_URI_LOADED) - e_book_unload_uri (book, NULL); - - CORBA_exception_init (&ev); - - for (l = book->priv->book_factories; l; l = l->next) { - CORBA_Object_release ((CORBA_Object)l->data, &ev); - if (ev._major != CORBA_NO_EXCEPTION) { - g_warning ("EBook: Exception while releasing BookFactory\n"); - - CORBA_exception_free (&ev); - CORBA_exception_init (&ev); - } - } - - CORBA_exception_free (&ev); - - if (book->priv->listener) { - g_signal_handler_disconnect (book->priv->listener, book->priv->listener_signal); - bonobo_object_unref (book->priv->listener); - book->priv->listener = NULL; - } - - g_free (book->priv->cap); - - g_free (book->priv->uri); - - g_free (book->priv); - book->priv = NULL; - } - - if (G_OBJECT_CLASS (parent_class)->dispose) - G_OBJECT_CLASS (parent_class)->dispose (object); -} - -static void -e_book_class_init (EBookClass *klass) -{ - GObjectClass *object_class = G_OBJECT_CLASS (klass); - - parent_class = g_type_class_ref (G_TYPE_OBJECT); - - e_book_signals [WRITABLE_STATUS] = - g_signal_new ("writable_status", - G_OBJECT_CLASS_TYPE (object_class), - G_SIGNAL_RUN_LAST, - G_STRUCT_OFFSET (EBookClass, writable_status), - NULL, NULL, - e_book_marshal_NONE__BOOL, - G_TYPE_NONE, 1, - G_TYPE_BOOLEAN); - - e_book_signals [BACKEND_DIED] = - g_signal_new ("backend_died", - G_OBJECT_CLASS_TYPE (object_class), - G_SIGNAL_RUN_LAST, - G_STRUCT_OFFSET (EBookClass, backend_died), - NULL, NULL, - e_book_marshal_NONE__NONE, - G_TYPE_NONE, 0); - - object_class->dispose = e_book_dispose; -} - -/** - * e_book_get_type: - */ -GType -e_book_get_type (void) -{ - static GType type = 0; - - if (! type) { - GTypeInfo info = { - sizeof (EBookClass), - NULL, /* base_class_init */ - NULL, /* base_class_finalize */ - (GClassInitFunc) e_book_class_init, - NULL, /* class_finalize */ - NULL, /* class_data */ - sizeof (EBook), - 0, /* n_preallocs */ - (GInstanceInitFunc) e_book_init - }; - - type = g_type_register_static (G_TYPE_OBJECT, "EBook", &info, 0); - } - - return type; -} diff --git a/addressbook/backend/ebook/e-book.h b/addressbook/backend/ebook/e-book.h deleted file mode 100644 index 1d2a4dc2d4..0000000000 --- a/addressbook/backend/ebook/e-book.h +++ /dev/null @@ -1,166 +0,0 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */ -/* - * The Evolution addressbook client object. - * - * Author: - * Chris Toshok (toshok@ximian.com) - * - * Copyright (C) 1999-2003, Ximian, Inc. - */ - -#ifndef __E_BOOK_H__ -#define __E_BOOK_H__ - -#include <glib.h> -#include <glib-object.h> - -#include <ebook/e-contact.h> -#include <ebook/e-book-query.h> -#include <ebook/e-book-view.h> -#include <ebook/e-book-types.h> -#if notyet -#include <e-util/e-source-list.h> -#endif - -#define E_TYPE_BOOK (e_book_get_type ()) -#define E_BOOK(o) (G_TYPE_CHECK_INSTANCE_CAST ((o), E_TYPE_BOOK, EBook)) -#define E_BOOK_CLASS(k) (G_TYPE_CHECK_CLASS_CAST ((k), E_TYPE_BOOK, EBookClass)) -#define E_IS_BOOK(o) (G_TYPE_CHECK_INSTANCE_TYPE ((o), E_TYPE_BOOK)) -#define E_IS_BOOK_CLASS(k) (G_TYPE_CHECK_CLASS_TYPE ((k), E_TYPE_BOOK)) -#define E_BOOK_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), E_TYPE_BOOK, EBookClass)) - -G_BEGIN_DECLS - -typedef struct _EBook EBook; -typedef struct _EBookClass EBookClass; -typedef struct _EBookPrivate EBookPrivate; - -struct _EBook { - GObject parent; - EBookPrivate *priv; -}; - -struct _EBookClass { - GObjectClass parent; - - /* - * Signals. - */ - void (* writable_status) (EBook *book, gboolean writable); - void (* backend_died) (EBook *book); - - /* Padding for future expansion */ - void (*_ebook_reserved0) (void); - void (*_ebook_reserved1) (void); - void (*_ebook_reserved2) (void); - void (*_ebook_reserved3) (void); - void (*_ebook_reserved4) (void); -}; - -/* Creating a new addressbook. */ -EBook *e_book_new (void); - -/* loading arbitrary addressbooks */ -gboolean e_book_load_uri (EBook *book, - const char *uri, - gboolean only_if_exists, - GError **error); - -gboolean e_book_unload_uri (EBook *book, - GError **error); - -gboolean e_book_remove (EBook *book, - GError **error); - -/* convenience function for loading the "local" contact folder */ -gboolean e_book_load_local_addressbook (EBook *book, - GError **error); - -gboolean e_book_get_supported_fields (EBook *book, - GList **fields, - GError **error); - -gboolean e_book_get_supported_auth_methods (EBook *book, - GList **auth_methods, - GError **error); - -/* User authentication. */ -gboolean e_book_authenticate_user (EBook *book, - const char *user, - const char *passwd, - const char *auth_method, - GError **error); - -/* Fetching contacts. */ -gboolean e_book_get_contact (EBook *book, - const char *id, - EContact **contact, - GError **error); - -/* Deleting contacts. */ -gboolean e_book_remove_contact (EBook *book, - const char *id, - GError **error); - -gboolean e_book_remove_contacts (EBook *book, - GList *id_list, - GError **error); - -/* Adding contacts. */ -gboolean e_book_add_contact (EBook *book, - EContact *contact, - GError **error); - -/* Modifying contacts. */ -gboolean e_book_commit_contact (EBook *book, - EContact *contact, - GError **error); - -/* Returns a live view of a query. */ -gboolean e_book_get_book_view (EBook *book, - EBookQuery *query, - GList *requested_fields, - int max_results, - EBookView **book_view, - GError **error); - -/* Returns a static snapshot of a query. */ -gboolean e_book_get_contacts (EBook *book, - EBookQuery *query, - GList **contacts, - GError **error); - -gboolean e_book_get_changes (EBook *book, - char *changeid, - GList **changes, - GError **error); - -void e_book_free_change_list (GList *change_list); - -const char *e_book_get_uri (EBook *book); - -const char *e_book_get_static_capabilities (EBook *book, - GError **error); -gboolean e_book_check_static_capability (EBook *book, - const char *cap); -gboolean e_book_is_writable (EBook *book); - -/* Cancel a pending operation. */ -gboolean e_book_cancel (EBook *book, - GError **error); - -/* Identity */ -gboolean e_book_get_self (EContact **contact, EBook **book, GError **error); -gboolean e_book_set_self (EBook *book, const char *id, GError **error); - -/* Addressbook Discovery */ -gboolean e_book_get_default_addressbook (EBook **book, GError **error); -#if notyet -gboolean e_book_get_addressbooks (ESourceList** addressbook_sources, GError **error); -#endif - -GType e_book_get_type (void); - -G_END_DECLS - -#endif /* ! __E_BOOK_H__ */ diff --git a/addressbook/backend/ebook/e-contact.c b/addressbook/backend/ebook/e-contact.c deleted file mode 100644 index ce92b31f71..0000000000 --- a/addressbook/backend/ebook/e-contact.c +++ /dev/null @@ -1,1288 +0,0 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */ -/* e-contact.c - * - * Copyright (C) 2003 Ximian, Inc. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of version 2 of the GNU General Public - * License as published by the Free Software Foundation. - * - * 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., 59 Temple Place - Suite 330, - * Boston, MA 02111-1307, USA. - * - * Author: Chris Toshok (toshok@ximian.com) - */ - -#include <glib.h> -#include <stdio.h> -#include <ctype.h> -#include <string.h> -#include <libgnome/gnome-i18n.h> -#include <libgnomevfs/gnome-vfs-mime-utils.h> -#include "e-contact.h" -#include "e-book.h" -#include "e-util/ename/e-name-western.h" - -struct _EContactPrivate { -}; - -#define E_CONTACT_FIELD_TYPE_STRING 0x00000001 /* used for simple single valued attributes */ -/*E_CONTACT_FIELD_TYPE_FLOAT*/ -#define E_CONTACT_FIELD_TYPE_LIST 0x00000002 /* used for multivalued single attributes - the elements are of type char* */ -#define E_CONTACT_FIELD_TYPE_MULTI 0x00000004 /* used for multivalued attributes - the elements are of type EVCardAttribute */ -#define E_CONTACT_FIELD_TYPE_STRUCT 0x00000008 /* used for structured types (N and ADR properties, in particular) */ -#define E_CONTACT_FIELD_TYPE_BOOLEAN 0x00000010 /* used for boolean types (WANTS_HTML) */ - -#define E_CONTACT_FIELD_TYPE_SYNTHETIC 0x10000000 /* used when there isn't a corresponding vcard field (such as email_1) */ -#define E_CONTACT_FIELD_TYPE_LIST_ELEM 0x20000000 /* used when a synthetic attribute is a numbered list element */ -#define E_CONTACT_FIELD_TYPE_MULTI_ELEM 0x40000000 /* used when we're looking for the nth attribute where more than 1 can be present in the vcard */ -#define E_CONTACT_FIELD_TYPE_ATTR_TYPE 0x80000000 /* used when a synthetic attribute is flagged with a TYPE= that we'll be looking for */ - -typedef struct { - guint32 t; - - EContactField field_id; - const char *vcard_field_name; - const char *field_name; /* non translated */ - const char *pretty_name; /* translated */ - - gboolean read_only; - - int list_elem; - const char *attr_type1; - const char *attr_type2; - - void* (*struct_getter)(EContact *contact, EVCardAttribute *attribute); - void (*struct_setter)(EContact *contact, EVCardAttribute *attribute, void *data); - -} EContactFieldInfo; - -static void* photo_getter (EContact *contact, EVCardAttribute *attr); -static void photo_setter (EContact *contact, EVCardAttribute *attr, void *data); -static void* fn_getter (EContact *contact, EVCardAttribute *attr); -static void fn_setter (EContact *contact, EVCardAttribute *attr, void *data); -static void* n_getter (EContact *contact, EVCardAttribute *attr); -static void n_setter (EContact *contact, EVCardAttribute *attr, void *data); -static void* adr_getter (EContact *contact, EVCardAttribute *attr); -static void adr_setter (EContact *contact, EVCardAttribute *attr, void *data); -static void* date_getter (EContact *contact, EVCardAttribute *attr); -static void date_setter (EContact *contact, EVCardAttribute *attr, void *data); - -#define STRING_FIELD(id,vc,n,pn,ro) { E_CONTACT_FIELD_TYPE_STRING, (id), (vc), (n), (pn), (ro) } -#define BOOLEAN_FIELD(id,vc,n,pn,ro) { E_CONTACT_FIELD_TYPE_BOOLEAN, (id), (vc), (n), (pn), (ro) } -#define LIST_FIELD(id,vc,n,pn,ro) { E_CONTACT_FIELD_TYPE_LIST, (id), (vc), (n), (pn), (ro) } -#define MULTI_LIST_FIELD(id,vc,n,pn,ro) { E_CONTACT_FIELD_TYPE_MULTI, (id), (vc), (n), (pn), (ro) } -#define STRUCT_FIELD(id,vc,n,pn,ro,get,set) { E_CONTACT_FIELD_TYPE_STRUCT, (id), (vc), (n), (pn), (ro), -1, NULL, NULL, (get), (set) } -#define LIST_ELEM_STR_FIELD(id,vc,n,pn,ro,nm) { E_CONTACT_FIELD_TYPE_LIST_ELEM | E_CONTACT_FIELD_TYPE_SYNTHETIC | E_CONTACT_FIELD_TYPE_STRING, (id), (vc), (n), (pn), (ro), (nm) } -#define MULTI_ELEM_STR_FIELD(id,vc,n,pn,ro,nm) { E_CONTACT_FIELD_TYPE_MULTI_ELEM | E_CONTACT_FIELD_TYPE_SYNTHETIC | E_CONTACT_FIELD_TYPE_STRING, (id), (vc), (n), (pn), (ro), (nm) } -#define ATTR_TYPE_STR_FIELD(id,vc,n,pn,ro,at1,nth) { E_CONTACT_FIELD_TYPE_ATTR_TYPE | E_CONTACT_FIELD_TYPE_SYNTHETIC | E_CONTACT_FIELD_TYPE_STRING, (id), (vc), (n), (pn), (ro), (nth), (at1), NULL } -#define ATTR2_TYPE_STR_FIELD(id,vc,n,pn,ro,at1,at2,nth) { E_CONTACT_FIELD_TYPE_ATTR_TYPE | E_CONTACT_FIELD_TYPE_SYNTHETIC | E_CONTACT_FIELD_TYPE_STRING, (id), (vc), (n), (pn), (ro), (nth), (at1), (at2) } -#define ATTR_TYPE_STRUCT_FIELD(id,vc,n,pn,ro,at,get,set) { E_CONTACT_FIELD_TYPE_ATTR_TYPE | E_CONTACT_FIELD_TYPE_SYNTHETIC | E_CONTACT_FIELD_TYPE_STRUCT, (id), (vc), (n), (pn), (ro), 0, (at), NULL, (get), (set) } - -static EContactFieldInfo field_info[] = { - STRING_FIELD (E_CONTACT_UID, EVC_UID, "id", N_("Unique ID"), FALSE), - STRING_FIELD (E_CONTACT_FILE_AS, EVC_X_FILE_AS, "file_as", N_("File As"), FALSE), - - /* Name fields */ - /* FN isn't really a structured field - we use a getter/setter - so we can set the N property (since evo 1.4 works fine with - vcards that don't even have a N attribute. *sigh*) */ - STRUCT_FIELD (E_CONTACT_FULL_NAME, EVC_FN, "full_name", N_("Full Name"), FALSE, fn_getter, fn_setter), - STRUCT_FIELD (E_CONTACT_NAME, EVC_N, "name", N_("Name"), FALSE, n_getter, n_setter), - LIST_ELEM_STR_FIELD (E_CONTACT_GIVEN_NAME, EVC_N, "given_name", N_("Given Name"), FALSE, 1), - LIST_ELEM_STR_FIELD (E_CONTACT_FAMILY_NAME, EVC_N, "family_name", N_("Family Name"), FALSE, 0), - STRING_FIELD (E_CONTACT_NICKNAME, EVC_NICKNAME, "nickname", N_("Nickname"), FALSE), - - /* Address fields */ - MULTI_LIST_FIELD (E_CONTACT_ADDRESS, EVC_ADR, "address", N_("Address List"), FALSE), - ATTR_TYPE_STRUCT_FIELD (E_CONTACT_ADDRESS_HOME, EVC_ADR, "address_home", N_("Home Address"), FALSE, "HOME", adr_getter, adr_setter), - ATTR_TYPE_STRUCT_FIELD (E_CONTACT_ADDRESS_WORK, EVC_ADR, "address_work", N_("Work Address"), FALSE, "WORK", adr_getter, adr_setter), - ATTR_TYPE_STRUCT_FIELD (E_CONTACT_ADDRESS_OTHER, EVC_ADR, "address_other", N_("Other Address"), FALSE, "OTHER", adr_getter, adr_setter), - - ATTR_TYPE_STR_FIELD (E_CONTACT_ADDRESS_LABEL_HOME, EVC_LABEL, "address_label_home", N_("Home Address Label"), FALSE, "HOME", 0), - ATTR_TYPE_STR_FIELD (E_CONTACT_ADDRESS_LABEL_WORK, EVC_LABEL, "address_label_work", N_("Work Address Label"), FALSE, "WORK", 0), - ATTR_TYPE_STR_FIELD (E_CONTACT_ADDRESS_LABEL_OTHER, EVC_LABEL, "address_label_other", N_("Other Address Label"), FALSE, "OTHER", 0), - - ATTR_TYPE_STR_FIELD (E_CONTACT_PHONE_ASSISTANT, EVC_TEL, "assistant_phone", N_("Assistant Phone"), FALSE, "X-EVOLUTION-ASSISTANT", 0), - ATTR2_TYPE_STR_FIELD (E_CONTACT_PHONE_BUSINESS, EVC_TEL, "business_phone", N_("Business Phone"), FALSE, "WORK", "VOICE", 0), - ATTR2_TYPE_STR_FIELD (E_CONTACT_PHONE_BUSINESS_2, EVC_TEL, "business_phone_2", N_("Business Phone 2"), FALSE, "WORK", "VOICE", 1), - ATTR2_TYPE_STR_FIELD (E_CONTACT_PHONE_BUSINESS_FAX, EVC_TEL, "business_fax", N_("Business Fax"), FALSE, "WORK", "FAX", 0), - ATTR_TYPE_STR_FIELD (E_CONTACT_PHONE_CALLBACK, EVC_TEL, "callback_phone", N_("Callback Phone"), FALSE, "X-EVOLUTION-CALLBACK", 0), - ATTR_TYPE_STR_FIELD (E_CONTACT_PHONE_CAR, EVC_TEL, "car_phone", N_("Car Phone"), FALSE, "CAR", 0), - ATTR2_TYPE_STR_FIELD (E_CONTACT_PHONE_COMPANY, EVC_TEL, "company_phone", N_("Company Phone"), FALSE, "WORK", "VOICE", 2), - ATTR2_TYPE_STR_FIELD (E_CONTACT_PHONE_HOME, EVC_TEL, "home_phone", N_("Home Phone"), FALSE, "HOME", "VOICE", 0), - ATTR2_TYPE_STR_FIELD (E_CONTACT_PHONE_HOME_2, EVC_TEL, "home_phone_2", N_("Home Phone 2"), FALSE, "HOME", "VOICE", 1), - ATTR2_TYPE_STR_FIELD (E_CONTACT_PHONE_HOME_FAX, EVC_TEL, "home_fax", N_("Home Fax"), FALSE, "HOME", "FAX", 0), - ATTR_TYPE_STR_FIELD (E_CONTACT_PHONE_ISDN, EVC_TEL, "isdn_phone", N_("ISDN"), FALSE, "ISDN", 0), - ATTR_TYPE_STR_FIELD (E_CONTACT_PHONE_MOBILE, EVC_TEL, "mobile_phone", N_("Mobile Phone"), FALSE, "CELL", 0), - ATTR_TYPE_STR_FIELD (E_CONTACT_PHONE_OTHER, EVC_TEL, "other_phone", N_("Other Phone"), FALSE, "VOICE", 0), /* XXX */ - ATTR_TYPE_STR_FIELD (E_CONTACT_PHONE_OTHER_FAX, EVC_TEL, "other_fax", N_("Other Fax"), FALSE, "FAX", 0), /* XXX */ - ATTR_TYPE_STR_FIELD (E_CONTACT_PHONE_PAGER, EVC_TEL, "pager", N_("Pager"), FALSE, "PAGER", 0), - ATTR_TYPE_STR_FIELD (E_CONTACT_PHONE_PRIMARY, EVC_TEL, "primary_phone", N_("Primary Phone"), FALSE, "PREF", 0), - ATTR_TYPE_STR_FIELD (E_CONTACT_PHONE_RADIO, EVC_TEL, "radio", N_("Radio"), FALSE, "X-EVOLUTION-RADIO", 0), - ATTR_TYPE_STR_FIELD (E_CONTACT_PHONE_TELEX, EVC_TEL, "telex", N_("Telex"), FALSE, "X-EVOLUTION-TELEX", 0), - ATTR_TYPE_STR_FIELD (E_CONTACT_PHONE_TTYTDD, EVC_TEL, "tty", N_("TTY"), FALSE, "X-EVOLUTION-TTYTDD", 0), - - /* Email fields */ - MULTI_LIST_FIELD (E_CONTACT_EMAIL, EVC_EMAIL, "email", N_("Email List"), FALSE), - MULTI_ELEM_STR_FIELD (E_CONTACT_EMAIL_1, EVC_EMAIL, "email_1", N_("Email 1"), FALSE, 0), - MULTI_ELEM_STR_FIELD (E_CONTACT_EMAIL_2, EVC_EMAIL, "email_2", N_("Email 2"), FALSE, 1), - MULTI_ELEM_STR_FIELD (E_CONTACT_EMAIL_3, EVC_EMAIL, "email_3", N_("Email 3"), FALSE, 2), - STRING_FIELD (E_CONTACT_MAILER, EVC_MAILER, "mailer", N_("Mailer"), FALSE), - BOOLEAN_FIELD (E_CONTACT_WANTS_HTML, EVC_X_WANTS_HTML, "wants_html", N_("Wants HTML Mail"), FALSE), - - /* Instant messaging fields */ - LIST_FIELD (E_CONTACT_IM_AIM, EVC_X_AIM, "im_aim", N_("AIM Screen Name List"), FALSE), - LIST_FIELD (E_CONTACT_IM_JABBER, EVC_X_JABBER, "im_jabber", N_("Jabber Id List"), FALSE), - LIST_FIELD (E_CONTACT_IM_YAHOO, EVC_X_YAHOO, "im_yahoo", N_("Yahoo! Screen Name List"), FALSE), - LIST_FIELD (E_CONTACT_IM_MSN, EVC_X_MSN, "im_msn", N_("MSN Screen Name List"), FALSE), - LIST_FIELD (E_CONTACT_IM_ICQ, EVC_X_ICQ, "im_icq", N_("ICQ Id List"), FALSE), - - /* Organizational fields */ - LIST_ELEM_STR_FIELD (E_CONTACT_ORG, EVC_ORG, "org", N_("Organization"), FALSE, 0), - LIST_ELEM_STR_FIELD (E_CONTACT_ORG_UNIT, EVC_ORG, "org_unit", N_("Organizational Unit"), FALSE, 1), - LIST_ELEM_STR_FIELD (E_CONTACT_OFFICE, EVC_ORG, "office", N_("Office"), FALSE, 2), - - STRING_FIELD (E_CONTACT_TITLE, EVC_TITLE, "title", N_("Title"), FALSE), - STRING_FIELD (E_CONTACT_ROLE, EVC_ROLE, "role", N_("Role"), FALSE), - STRING_FIELD (E_CONTACT_MANAGER, EVC_X_MANAGER, "manager", N_("Manager"), FALSE), - STRING_FIELD (E_CONTACT_ASSISTANT, EVC_X_ASSISTANT, "assistant", N_("Assistant"), FALSE), - - /* Web fields */ - STRING_FIELD (E_CONTACT_HOMEPAGE_URL, EVC_URL, "homepage_url", N_("Homepage URL"), FALSE), - STRING_FIELD (E_CONTACT_BLOG_URL, EVC_X_BLOG_URL, "blog_url", N_("Weblog URL"), FALSE), - - /* Photo/Logo */ - STRUCT_FIELD (E_CONTACT_PHOTO, EVC_PHOTO, "photo", N_("Photo"), FALSE, photo_getter, photo_setter), - STRUCT_FIELD (E_CONTACT_LOGO, EVC_LOGO, "logo", N_("Logo"), FALSE, photo_getter, photo_setter), - - /* Contact categories */ -#if notyet - LIST_FIELD (E_CONTACT_CATEGORY_LIST, EVC_CATEGORIES, "category_list", N_("Category List"), FALSE), - SYNTH_STR_FIELD (E_CONTACT_CATEGORIES, "categories", N_("Categories"), FALSE), -#else - STRING_FIELD (E_CONTACT_CATEGORIES, EVC_CATEGORIES, "categories", N_("Categories"), FALSE), -#endif - - /* Collaboration fields */ - STRING_FIELD (E_CONTACT_CALENDAR_URI, EVC_CALURI, "caluri", N_("Calendar URI"), FALSE), - STRING_FIELD (E_CONTACT_FREEBUSY_URL, EVC_FBURL, "fburl", N_("Free/Busy URL"), FALSE), - STRING_FIELD (E_CONTACT_ICS_CALENDAR, EVC_ICSCALENDAR, "icscalendar", N_("ICS Calendar"), FALSE), - - /* Misc fields */ - STRING_FIELD (E_CONTACT_SPOUSE, EVC_X_SPOUSE, "spouse", N_("Spouse's Name"), FALSE), - STRING_FIELD (E_CONTACT_NOTE, EVC_NOTE, "note", N_("Note"), FALSE), - - STRUCT_FIELD (E_CONTACT_BIRTH_DATE, EVC_BDAY, "birth_date", N_("Birth Date"), FALSE, date_getter, date_setter), - STRUCT_FIELD (E_CONTACT_ANNIVERSARY, EVC_BDAY, "anniversary", N_("Anniversary"), FALSE, date_getter, date_setter), - - BOOLEAN_FIELD (E_CONTACT_IS_LIST, EVC_X_LIST, "list", N_("List"), FALSE), - BOOLEAN_FIELD (E_CONTACT_LIST_SHOW_ADDRESSES, EVC_X_LIST_SHOW_ADDRESSES, "list_show_addresses", N_("List Show Addresses"), FALSE) -}; - -#undef LIST_ELEM_STR_FIELD -#undef STRING_FIELD -#undef SYNTH_STR_FIELD -#undef LIST_FIELD -#undef STRUCT_FIELD - -static GObjectClass *parent_class; - -static void e_contact_set_property (GObject *object, guint prop_id, const GValue *value, GParamSpec *pspec); -static void e_contact_get_property (GObject *object, guint prop_id, GValue *value, GParamSpec *pspec); - -static void -e_contact_dispose (GObject *object) -{ - EContact *ec = E_CONTACT (object); - - if (!ec->priv) - return; - - /* XXX free instance specific stuff */ - - g_free (ec->priv); - ec->priv = NULL; - - if (G_OBJECT_CLASS (parent_class)->dispose) - G_OBJECT_CLASS (parent_class)->dispose (object); -} - -static void -e_contact_class_init (EContactClass *klass) -{ - GObjectClass *object_class; - int i; - - object_class = G_OBJECT_CLASS(klass); - - parent_class = g_type_class_ref (E_TYPE_VCARD); - - object_class->dispose = e_contact_dispose; - object_class->set_property = e_contact_set_property; - object_class->get_property = e_contact_get_property; - - for (i = 0; i < G_N_ELEMENTS (field_info); i ++) { - GParamSpec *pspec = NULL; - if (field_info[i].t & E_CONTACT_FIELD_TYPE_STRING) - pspec = g_param_spec_string (field_info[i].field_name, - _(field_info[i].pretty_name), - "" /* XXX blurb */, - NULL, - field_info[i].read_only ? G_PARAM_READABLE : G_PARAM_READWRITE); - else if (field_info[i].t & E_CONTACT_FIELD_TYPE_BOOLEAN) - pspec = g_param_spec_boolean (field_info[i].field_name, - _(field_info[i].pretty_name), - "" /* XXX blurb */, - FALSE, - field_info[i].read_only ? G_PARAM_READABLE : G_PARAM_READWRITE); - else - pspec = g_param_spec_pointer (field_info[i].field_name, - _(field_info[i].pretty_name), - "" /* XXX blurb */, - field_info[i].read_only ? G_PARAM_READABLE : G_PARAM_READWRITE); - - g_object_class_install_property (object_class, field_info[i].field_id, - pspec); - } -} - -static void -e_contact_init (EContact *ec) -{ - ec->priv = g_new0 (EContactPrivate, 1); -} - -GType -e_contact_get_type (void) -{ - static GType contact_type = 0; - - if (!contact_type) { - static const GTypeInfo contact_info = { - sizeof (EContactClass), - NULL, /* base_init */ - NULL, /* base_finalize */ - (GClassInitFunc) e_contact_class_init, - NULL, /* class_finalize */ - NULL, /* class_data */ - sizeof (EContact), - 0, /* n_preallocs */ - (GInstanceInitFunc) e_contact_init, - }; - - contact_type = g_type_register_static (E_TYPE_VCARD, "EContact", &contact_info, 0); - } - - return contact_type; -} - -static EVCardAttribute* -e_contact_get_first_attr (EContact *contact, const char *attr_name) -{ - GList *attrs, *l; - - attrs = e_vcard_get_attributes (E_VCARD (contact)); - - for (l = attrs; l; l = l->next) { - EVCardAttribute *attr = l->data; - const char *name, *group; - - group = e_vcard_attribute_get_group (attr); - name = e_vcard_attribute_get_name (attr); - - /* all the attributes we care about should be in group "" */ - if ((!group || !*group) && !strcasecmp (name, attr_name)) - return attr; - } - - return NULL; -} - - - -static void* -photo_getter (EContact *contact, EVCardAttribute *attr) -{ - if (attr) { - GList *values = e_vcard_attribute_get_values_decoded (attr); - - if (values && values->data) { - GString *s = values->data; - EContactPhoto *photo = g_new (EContactPhoto, 1); - - photo->length = s->len; - photo->data = g_malloc (photo->length); - memcpy (photo->data, s->str, photo->length); - - return photo; - } - } - - return NULL; -} - -static void -photo_setter (EContact *contact, EVCardAttribute *attr, void *data) -{ - EContactPhoto *photo = data; - const char *mime_type; - char *image_type = "X-EVOLUTION-UNKNOWN"; - - e_vcard_attribute_add_param_with_value (attr, - e_vcard_attribute_param_new (EVC_ENCODING), - "b"); - - mime_type = gnome_vfs_get_mime_type_for_data (photo->data, photo->length); - if (!strcmp (mime_type, "image/gif")) - image_type = "GIF"; - else if (!strcmp (mime_type, "image/jpeg")) - image_type = "JPEG"; - else if (!strcmp (mime_type, "image/png")) - image_type = "PNG"; - else if (!strcmp (mime_type, "image/tiff")) - image_type = "TIFF"; - /* i have no idea what these last 2 are.. :) */ - else if (!strcmp (mime_type, "image/ief")) - image_type = "IEF"; - else if (!strcmp (mime_type, "image/cgm")) - image_type = "CGM"; - - e_vcard_attribute_add_param_with_value (attr, - e_vcard_attribute_param_new (EVC_TYPE), - image_type); - - printf ("adding photo of type `%s' of length %d\n", image_type, photo->length); - e_vcard_attribute_add_value_decoded (attr, photo->data, photo->length); -} - - -static void* -fn_getter (EContact *contact, EVCardAttribute *attr) -{ - if (attr) { - GList *p = e_vcard_attribute_get_values (attr); - - return g_strdup (p && p->data ? p->data : ""); - } - else - return NULL; -} - -static void -fn_setter (EContact *contact, EVCardAttribute *attr, void *data) -{ - e_vcard_attribute_add_value (attr, (char*)data); - - attr = e_contact_get_first_attr (contact, EVC_N); - if (!attr) { - EContactName *name = e_contact_name_from_string ((char*)data); - - attr = e_vcard_attribute_new (NULL, EVC_N); - e_vcard_add_attribute (E_VCARD (contact), attr); - - /* call the setter directly */ - n_setter (contact, attr, name); - - e_contact_name_free (name); - } -} - - - -static void* -n_getter (EContact *contact, EVCardAttribute *attr) -{ - EContactName *name = g_new0 (EContactName, 1); - if (attr) { - GList *p = e_vcard_attribute_get_values (attr); - - name->family = g_strdup (p && p->data ? p->data : ""); if (p) p = p->next; - name->given = g_strdup (p && p->data ? p->data : ""); if (p) p = p->next; - name->additional = g_strdup (p && p->data ? p->data : ""); if (p) p = p->next; - name->prefixes = g_strdup (p && p->data ? p->data : ""); if (p) p = p->next; - name->suffixes = g_strdup (p && p->data ? p->data : ""); - } - - return name; -} - -static void -n_setter (EContact *contact, EVCardAttribute *attr, void *data) -{ - EContactName *name = data; - - e_vcard_attribute_add_value (attr, name->family); - e_vcard_attribute_add_value (attr, name->given); - e_vcard_attribute_add_value (attr, name->additional); - e_vcard_attribute_add_value (attr, name->prefixes); - e_vcard_attribute_add_value (attr, name->suffixes); - - /* now find the attribute for FileAs. if it's not present, fill it in */ - attr = e_contact_get_first_attr (contact, EVC_X_FILE_AS); - if (!attr) { - char *strings[3], **stringptr; - char *string; - attr = e_vcard_attribute_new (NULL, EVC_X_FILE_AS); - e_vcard_add_attribute (E_VCARD (contact), attr); - - stringptr = strings; - if (name->family && *name->family) - *(stringptr++) = name->family; - if (name->given && *name->given) - *(stringptr++) = name->given; - *stringptr = NULL; - string = g_strjoinv(", ", strings); - - e_vcard_attribute_add_value (attr, string); - g_free (string); - } - -} - - - -static void* -adr_getter (EContact *contact, EVCardAttribute *attr) -{ - if (attr) { - GList *p = e_vcard_attribute_get_values (attr); - EContactAddress *addr = g_new (EContactAddress, 1); - - addr->po = g_strdup (p && p->data ? p->data : ""); if (p) p = p->next; - addr->ext = g_strdup (p && p->data ? p->data : ""); if (p) p = p->next; - addr->street = g_strdup (p && p->data ? p->data : ""); if (p) p = p->next; - addr->locality = g_strdup (p && p->data ? p->data : ""); if (p) p = p->next; - addr->region = g_strdup (p && p->data ? p->data : ""); if (p) p = p->next; - addr->code = g_strdup (p && p->data ? p->data : ""); if (p) p = p->next; - addr->country = g_strdup (p && p->data ? p->data : ""); if (p) p = p->next; - - return addr; - } - - return NULL; -} - -static void -adr_setter (EContact *contact, EVCardAttribute *attr, void *data) -{ - /* XXX */ - g_assert_not_reached (); -} - - - -static void* -date_getter (EContact *contact, EVCardAttribute *attr) -{ - if (attr) { - GList *p = e_vcard_attribute_get_values (attr); - EContactDate *date = e_contact_date_from_string (p && p->data ? (char*)p->data : ""); - - return date; - } - - return NULL; -} - -static void -date_setter (EContact *contact, EVCardAttribute *attr, void *data) -{ - EContactDate *date = data; - char *str = e_contact_date_to_string (date); - - e_vcard_attribute_add_value (attr, str); - g_free (str); -} - - - -/* Set_arg handler for the contact */ -static void -e_contact_set_property (GObject *object, - guint prop_id, - const GValue *value, - GParamSpec *pspec) -{ - EContact *contact = E_CONTACT (object); - int i; - EContactFieldInfo *info = NULL; - - if (prop_id < 1 || prop_id >= E_CONTACT_FIELD_LAST) { - G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); - return; - } - - - for (i = 0; i < G_N_ELEMENTS (field_info); i++) { - if (field_info[i].field_id == prop_id) { - info = &field_info[i]; - break; - } - } - - if (!info) { - g_warning ("unknown field %d", prop_id); - return; - } - - if (info->t & E_CONTACT_FIELD_TYPE_MULTI) { - GList *new_values = g_value_get_pointer (value); - GList *l; - - /* first we remove all attributes of the type we're - adding, then add new ones based on the values that - are passed in */ - e_vcard_remove_attributes (E_VCARD (contact), NULL, info->vcard_field_name); - - for (l = new_values; l; l = l->next) - e_vcard_add_attribute_with_value (E_VCARD (contact), - e_vcard_attribute_new (NULL, info->vcard_field_name), - (char*)l->data); - } - else if (info->t & E_CONTACT_FIELD_TYPE_SYNTHETIC) { - if (info->t & E_CONTACT_FIELD_TYPE_MULTI_ELEM) { - /* XXX this is kinda broken - we don't insert - insert padding elements if, e.g. the user - sets email 3 when email 1 and 2 don't - exist. But, if we *did* pad the lists we'd - end up with empty items in the vcard. I - dunno which is worse. */ - EVCardAttribute *attr = NULL; - gboolean found = FALSE; - int num_left = info->list_elem; - GList *attrs = e_vcard_get_attributes (E_VCARD (contact)); - GList *l; - - for (l = attrs; l; l = l->next) { - const char *name, *group; - - attr = l->data; - group = e_vcard_attribute_get_group (attr); - name = e_vcard_attribute_get_name (attr); - - /* all the attributes we care about should be in group "" */ - if ((!group || !*group) && !strcasecmp (name, info->vcard_field_name)) { - if (num_left-- == 0) { - found = TRUE; - break; - } - } - } - - if (found) { - /* we found it, overwrite it */ - e_vcard_attribute_remove_values (attr); - } - else { - /* we didn't find it - add a new attribute */ - attr = e_vcard_attribute_new (NULL, info->vcard_field_name); - e_vcard_add_attribute (E_VCARD (contact), attr); - } - - e_vcard_attribute_add_value (attr, g_value_get_string (value)); - } - else if (info->t & E_CONTACT_FIELD_TYPE_ATTR_TYPE) { - /* XXX this is kinda broken - we don't insert - insert padding elements if, e.g. the user - sets email 3 when email 1 and 2 don't - exist. But, if we *did* pad the lists we'd - end up with empty items in the vcard. I - dunno which is worse. */ - EVCardAttribute *attr = NULL; - gboolean found = FALSE; - int num_left = info->list_elem; - GList *attrs = e_vcard_get_attributes (E_VCARD (contact)); - GList *l; - const char *sval = g_value_get_string (value); - - for (l = attrs; l && !found; l = l->next) { - const char *name, *group; - gboolean found_needed1, found_needed2; - - if (!info->attr_type1) - found_needed1 = TRUE; - else - found_needed1 = FALSE; - - if (!info->attr_type2) - found_needed2 = TRUE; - else - found_needed2 = FALSE; - - attr = l->data; - group = e_vcard_attribute_get_group (attr); - name = e_vcard_attribute_get_name (attr); - - /* all the attributes we care about should be in group "" */ - if ((!group || !*group) && !strcasecmp (name, info->vcard_field_name)) { - GList *params; - - for (params = e_vcard_attribute_get_params (attr); params; params = params->next) { - EVCardAttributeParam *param = params->data; - const char *name = e_vcard_attribute_param_get_name (param); - - if (!strcasecmp (name, EVC_TYPE)) { - GList *values = e_vcard_attribute_param_get_values (param); - if (values && values->data) { - if (!found_needed1 && !strcasecmp ((char*)values->data, info->attr_type1)) - found_needed1 = TRUE; - else if (!found_needed2 && !strcasecmp ((char*)values->data, info->attr_type2)) - found_needed2 = TRUE; - } - } - - if (found_needed1 && found_needed2) { - if (num_left-- == 0) { - found = TRUE; - break; - } - } - } - } - } - - if (found) { - /* we found it, overwrite it */ - e_vcard_attribute_remove_values (attr); - } - else { - /* we didn't find it - add a new attribute */ - attr = e_vcard_attribute_new (NULL, info->vcard_field_name); - e_vcard_add_attribute (E_VCARD (contact), attr); - if (info->attr_type1) - e_vcard_attribute_add_param_with_value (attr, e_vcard_attribute_param_new (EVC_TYPE), - info->attr_type1); - if (info->attr_type2) - e_vcard_attribute_add_param_with_value (attr, e_vcard_attribute_param_new (EVC_TYPE), - info->attr_type2); - } - - if (sval && *sval) - e_vcard_attribute_add_value (attr, sval); - else - e_vcard_remove_attribute (E_VCARD (contact), attr); - } - else if (info->t & E_CONTACT_FIELD_TYPE_LIST_ELEM) { - EVCardAttribute *attr = e_contact_get_first_attr (contact, info->vcard_field_name); - GList *values; - GList *p; - const char *sval = g_value_get_string (value); - - if (!attr) { - if (!sval || !*sval) - return; - - printf ("adding new %s\n", info->vcard_field_name); - - attr = e_vcard_attribute_new (NULL, info->vcard_field_name); - e_vcard_add_attribute (E_VCARD (contact), attr); - } - - values = e_vcard_attribute_get_values (attr); - p = g_list_nth (values, info->list_elem); - - if (p) { - g_free (p->data); - p->data = g_strdup (g_value_get_string (value)); - } - else { - /* there weren't enough elements in the list, pad it */ - int count = info->list_elem - g_list_length (values); - - while (count--) - e_vcard_attribute_add_value (attr, ""); - - e_vcard_attribute_add_value (attr, g_value_get_string (value)); - } - - } - } - else if (info->t & E_CONTACT_FIELD_TYPE_BOOLEAN) { - EVCardAttribute *attr; - - /* first we search for an attribute we can overwrite */ - attr = e_contact_get_first_attr (contact, info->vcard_field_name); - if (attr) { - printf ("setting %s to `%s'\n", info->vcard_field_name, g_value_get_string (value)); - e_vcard_attribute_remove_values (attr); - e_vcard_attribute_add_value (attr, g_value_get_boolean (value) ? "TRUE" : "FALSE"); - } - else { - /* and if we don't find one we create a new attribute */ - e_vcard_add_attribute_with_value (E_VCARD (contact), - e_vcard_attribute_new (NULL, info->vcard_field_name), - g_value_get_boolean (value) ? "TRUE" : "FALSE"); - } - } - else if (info->t & E_CONTACT_FIELD_TYPE_STRING) { - EVCardAttribute *attr; - const char *sval = g_value_get_string (value); - - /* first we search for an attribute we can overwrite */ - attr = e_contact_get_first_attr (contact, info->vcard_field_name); - if (attr) { - printf ("setting %s to `%s'\n", info->vcard_field_name, sval); - e_vcard_attribute_remove_values (attr); - if (sval) - e_vcard_attribute_add_value (attr, sval); - } - else if (sval) { - /* and if we don't find one we create a new attribute */ - e_vcard_add_attribute_with_value (E_VCARD (contact), - e_vcard_attribute_new (NULL, info->vcard_field_name), - g_value_get_string (value)); - } - } - else if (info->t & E_CONTACT_FIELD_TYPE_STRUCT) { - EVCardAttribute *attr = e_contact_get_first_attr (contact, info->vcard_field_name); - void *data = g_value_get_pointer (value); - - if (attr) { - printf ("overwriting existing %s\n", info->vcard_field_name); - /* remove all existing values and parameters. - the setter will add the correct ones */ - e_vcard_attribute_remove_values (attr); - e_vcard_attribute_remove_params (attr); - } - else { - printf ("adding new %s\n", info->vcard_field_name); - attr = e_vcard_attribute_new (NULL, info->vcard_field_name); - - e_vcard_add_attribute (E_VCARD (contact), attr); - } - - info->struct_setter (contact, attr, data); - } - else { - g_warning ("unhandled attribute `%s'", info->vcard_field_name); - } -} - -static GList * -e_contact_get_email_list (EContact *contact) -{ - GList *rv = NULL; - GList *attrs, *l; - - attrs = e_vcard_get_attributes (E_VCARD (contact)); - - for (l = attrs; l; l = l->next) { - EVCardAttribute *attr = l->data; - const char *name, *group; - - group = e_vcard_attribute_get_group (attr); - name = e_vcard_attribute_get_name (attr); - - /* all the attributes we care about should be in group "" */ - if ((!group || !*group) && !strcasecmp (name, EVC_EMAIL)) { - GList *v = e_vcard_attribute_get_values (attr); - - rv = g_list_append (rv, v ? g_strdup (v->data) : NULL); - } - } - - return rv; -} - -static EVCardAttribute * -e_contact_find_attribute_with_types (EContact *contact, const char *attr_name, const char *type_needed1, const char *type_needed2, int nth) -{ - GList *l, *attrs; - gboolean found_needed1, found_needed2; - - attrs = e_vcard_get_attributes (E_VCARD (contact)); - - for (l = attrs; l; l = l->next) { - EVCardAttribute *attr = l->data; - const char *name, *group; - - if (!type_needed1) - found_needed1 = TRUE; - else - found_needed1 = FALSE; - - if (!type_needed2) - found_needed2 = TRUE; - else - found_needed2 = FALSE; - - group = e_vcard_attribute_get_group (attr); - name = e_vcard_attribute_get_name (attr); - - /* all the attributes we care about should be in group "" */ - if ((!group || !*group) && !strcasecmp (name, attr_name)) { - GList *params; - - for (params = e_vcard_attribute_get_params (attr); params; params = params->next) { - EVCardAttributeParam *param = params->data; - const char *name = e_vcard_attribute_param_get_name (param); - - if (!strcasecmp (name, EVC_TYPE)) { - GList *values = e_vcard_attribute_param_get_values (param); - if (values && values->data) { - if (!found_needed1 && !strcasecmp ((char*)values->data, type_needed1)) - found_needed1 = TRUE; - else if (!found_needed2 && !strcasecmp ((char*)values->data, type_needed2)) - found_needed2 = TRUE; - } - } - - if (found_needed1 && found_needed2) { - if (nth-- == 0) - return attr; - else - break; - } - } - } - } - - return NULL; -} - -static void -e_contact_get_property (GObject *object, - guint prop_id, - GValue *value, - GParamSpec *pspec) -{ - EContact *contact = E_CONTACT (object); - int i; - EContactFieldInfo *info = NULL; - - if (prop_id < 1 || prop_id >= E_CONTACT_FIELD_LAST) { - G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); - return; - } - - for (i = 0; i < G_N_ELEMENTS (field_info); i++) { - if (field_info[i].field_id == prop_id) { - info = &field_info[i]; - break; - } - } - - if (!info) { - g_warning ("unknown field %d", prop_id); - return; - } - else if (info->t & E_CONTACT_FIELD_TYPE_BOOLEAN) { - EVCardAttribute *attr = e_contact_get_first_attr (contact, info->vcard_field_name); - gboolean rv = FALSE; - - if (attr) { - GList *v = e_vcard_attribute_get_values (attr); - rv = v && v->data && !strcasecmp ((char*)v->data, "true"); - } - - g_value_set_boolean (value, rv); - } - else if (info->t & E_CONTACT_FIELD_TYPE_LIST) { - EVCardAttribute *attr = e_contact_get_first_attr (contact, info->vcard_field_name); - - if (attr) - g_value_set_pointer (value, e_vcard_attribute_get_values (attr)); - } - else if (info->t & E_CONTACT_FIELD_TYPE_LIST_ELEM) { - if (info->t & E_CONTACT_FIELD_TYPE_STRING) { - GList *attrs, *l; - - attrs = e_vcard_get_attributes (E_VCARD (contact)); - - for (l = attrs; l; l = l->next) { - EVCardAttribute *attr = l->data; - const char *name, *group; - - group = e_vcard_attribute_get_group (attr); - name = e_vcard_attribute_get_name (attr); - - /* all the attributes we care about should be in group "" */ - if ((!group || !*group) && !strcasecmp (name, info->vcard_field_name)) { - GList *v; - int count; - - v = e_vcard_attribute_get_values (attr); - count = info->list_elem; - - v = g_list_nth (v, info->list_elem); - - g_value_set_string (value, v ? v->data : NULL); - } - } - } - } - else if (info->t & E_CONTACT_FIELD_TYPE_MULTI_ELEM) { - if (info->t & E_CONTACT_FIELD_TYPE_STRING) { - GList *attrs, *l; - - attrs = e_vcard_get_attributes (E_VCARD (contact)); - - for (l = attrs; l; l = l->next) { - EVCardAttribute *attr = l->data; - const char *name, *group; - - group = e_vcard_attribute_get_group (attr); - name = e_vcard_attribute_get_name (attr); - - /* all the attributes we care about should be in group "" */ - if ((!group || !*group) && !strcasecmp (name, info->vcard_field_name)) { - GList *v; - int count; - - v = e_vcard_attribute_get_values (attr); - count = info->list_elem; - - v = g_list_nth (v, info->list_elem); - - g_value_set_string (value, v ? v->data : NULL); - } - } - } - } - else if (info->t & E_CONTACT_FIELD_TYPE_ATTR_TYPE) { - EVCardAttribute *attr = e_contact_find_attribute_with_types (contact, info->vcard_field_name, info->attr_type1, info->attr_type2, info->list_elem); - - if (info->t & E_CONTACT_FIELD_TYPE_STRING) { - if (attr) { - GList *p = e_vcard_attribute_get_values (attr); - char *rv = p->data; - - g_value_set_string (value, rv); - } - else { - g_value_set_string (value, NULL); - } - } - else { /* struct */ - gpointer rv = info->struct_getter (contact, attr); - - g_value_set_pointer (value, rv); - } - - } - else if (info->t & E_CONTACT_FIELD_TYPE_STRUCT) { - EVCardAttribute *attr = e_contact_get_first_attr (contact, info->vcard_field_name); - void *rv = NULL; - - if (attr) - rv = info->struct_getter (contact, attr); - - g_value_set_pointer (value, rv); - } - - else if (info->t & E_CONTACT_FIELD_TYPE_SYNTHETIC) { - switch (info->field_id) { - default: - g_warning ("unhandled synthetic field 0x%02x", info->field_id); - } - } - else { - GList *attrs, *l; - GList *rv = NULL; /* used for multi attribute lists */ - - attrs = e_vcard_get_attributes (E_VCARD (contact)); - - for (l = attrs; l; l = l->next) { - EVCardAttribute *attr = l->data; - const char *name, *group; - - group = e_vcard_attribute_get_group (attr); - name = e_vcard_attribute_get_name (attr); - - /* all the attributes we care about should be in group "" */ - if ((!group || !*group) && !strcasecmp (name, info->vcard_field_name)) { - GList *v; - v = e_vcard_attribute_get_values (attr); - - if (info->t & E_CONTACT_FIELD_TYPE_STRING) { - g_value_set_string (value, v ? v->data : NULL); - } - else { - rv = g_list_append (rv, v ? g_strdup (v->data) : NULL); - - g_value_set_pointer (value, rv); - } - } - } - } -} - - - -EContact* -e_contact_new (void) -{ - return e_contact_new_from_vcard (""); -} - -EContact* -e_contact_new_from_vcard (const char *vcard) -{ - EContact *contact = g_object_new (E_TYPE_CONTACT, NULL); - - e_vcard_construct (E_VCARD (contact), vcard); - - return contact; -} - -EContact* -e_contact_duplicate (EContact *contact) -{ - char *vcard = e_vcard_to_string (E_VCARD (contact), EVC_FORMAT_VCARD_30); - EContact *c = e_contact_new_from_vcard (vcard); - - g_free (vcard); - - return c; -} - -const char * -e_contact_field_name (EContactField field_id) -{ - int i; - - g_return_val_if_fail (field_id >= 1 && field_id <= E_CONTACT_FIELD_LAST, ""); - - for (i = 0; i < G_N_ELEMENTS (field_info); i ++) { - if (field_id == field_info[i].field_id) - return field_info[i].field_name; - } - - g_warning ("unknown field id %d", field_id); - return ""; -} - -const char * -e_contact_pretty_name (EContactField field_id) -{ - int i; - - g_return_val_if_fail (field_id >= 1 && field_id <= E_CONTACT_FIELD_LAST, ""); - - for (i = 0; i < G_N_ELEMENTS (field_info); i ++) { - if (field_id == field_info[i].field_id) - return _(field_info[i].pretty_name); - } - - g_warning ("unknown field id %d", field_id); - return ""; -} - -EContactField -e_contact_field_id (const char *field_name) -{ - int i; - - for (i = 0; i < G_N_ELEMENTS (field_info); i ++) { - if (!strcmp (field_info[i].field_name, field_name)) - return field_info[i].field_id; - } - - g_warning ("unknown field name `%s'", field_name); - return 0; -} - -gpointer -e_contact_get (EContact *contact, EContactField field_id) -{ - gpointer value; - - g_return_val_if_fail (contact && E_IS_CONTACT (contact), NULL); - g_return_val_if_fail (field_id >= 1 && field_id <= E_CONTACT_FIELD_LAST, NULL); - - g_object_get (contact, - e_contact_field_name (field_id), &value, - NULL); - - return value; -} - -/* XXX this won't work for structure/list types... */ -static void -free_const_data (gpointer data, GObject *where_object_was) -{ - g_free (data); -} - -const gpointer -e_contact_get_const (EContact *contact, EContactField field_id) -{ - gpointer value; - - g_return_val_if_fail (E_IS_CONTACT (contact), NULL); - g_return_val_if_fail (field_id >= 1 && field_id <= E_CONTACT_FIELD_LAST, NULL); - - value = e_contact_get (contact, field_id); - - g_object_weak_ref (G_OBJECT (contact), free_const_data, value); - - return value; -} - -void -e_contact_set (EContact *contact, EContactField field_id, gpointer value) -{ - printf ("e_contact_set (%p, %d, %p)\n", contact, field_id, value); - - g_return_if_fail (contact && E_IS_CONTACT (contact)); - g_return_if_fail (field_id >= 1 && field_id <= E_CONTACT_FIELD_LAST); - - g_object_set (contact, - e_contact_field_name (field_id), value, - NULL); -} - -EContactName* -e_contact_name_new () -{ - return g_new0 (EContactName, 1); -} - -char * -e_contact_name_to_string(const EContactName *name) -{ - char *strings[6], **stringptr = strings; - - g_return_val_if_fail (name != NULL, NULL); - - if (name->prefixes && *name->prefixes) - *(stringptr++) = name->prefixes; - if (name->given && *name->given) - *(stringptr++) = name->given; - if (name->additional && *name->additional) - *(stringptr++) = name->additional; - if (name->family && *name->family) - *(stringptr++) = name->family; - if (name->suffixes && *name->suffixes) - *(stringptr++) = name->suffixes; - *stringptr = NULL; - return g_strjoinv(" ", strings); -} - -EContactName* -e_contact_name_from_string (const char *name_str) -{ - EContactName *name = e_contact_name_new(); - ENameWestern *western = e_name_western_parse (name_str); - - name->prefixes = g_strdup (western->prefix); - name->given = g_strdup (western->first ); - name->additional = g_strdup (western->middle); - name->family = g_strdup (western->last ); - name->suffixes = g_strdup (western->suffix); - - e_name_western_free(western); - - return name; -} - -EContactName* -e_contact_name_copy (EContactName *n) -{ - EContactName *name = e_contact_name_new(); - - name->prefixes = g_strdup (n->prefixes); - name->given = g_strdup (n->given); - name->additional = g_strdup (n->additional); - name->family = g_strdup (n->family); - name->suffixes = g_strdup (n->suffixes); - - return name; -} - -void -e_contact_name_free (EContactName *name) -{ - if (!name) - return; - - g_free (name->family); - g_free (name->given); - g_free (name->additional); - g_free (name->prefixes); - g_free (name->suffixes); - - g_free (name); -} - -EContactDate* -e_contact_date_new (void) -{ - return g_new0 (EContactDate, 1); -} - -EContactDate* -e_contact_date_from_string (const char *str) -{ - EContactDate* date = e_contact_date_new(); - int length; - - length = strlen(str); - - if (length == 10 ) { - date->year = str[0] * 1000 + str[1] * 100 + str[2] * 10 + str[3] - '0' * 1111; - date->month = str[5] * 10 + str[6] - '0' * 11; - date->day = str[8] * 10 + str[9] - '0' * 11; - } else if ( length == 8 ) { - date->year = str[0] * 1000 + str[1] * 100 + str[2] * 10 + str[3] - '0' * 1111; - date->month = str[4] * 10 + str[5] - '0' * 11; - date->day = str[6] * 10 + str[7] - '0' * 11; - } - - return date; -} - -char * -e_contact_date_to_string (EContactDate *dt) -{ - if (dt) - return g_strdup_printf ("%04d-%02d-%02d", - CLAMP(dt->year, 1000, 9999), - CLAMP(dt->month, 1, 12), - CLAMP(dt->day, 1, 31)); - else - return NULL; -} - -void -e_contact_date_free (EContactDate *dt) -{ - g_free (dt); -} - - -void -e_contact_photo_free (EContactPhoto *photo) -{ - if (!photo) - return; - - g_free (photo->data); - g_free (photo); -} - -void -e_contact_address_free (EContactAddress *address) -{ - if (!address) - return; - - g_free (address->address_format); - g_free (address->po); - g_free (address->ext); - g_free (address->street); - g_free (address->locality); - g_free (address->region); - g_free (address->code); - g_free (address->country); - - g_free (address); -} diff --git a/addressbook/backend/ebook/e-contact.h b/addressbook/backend/ebook/e-contact.h deleted file mode 100644 index 21c0256ca9..0000000000 --- a/addressbook/backend/ebook/e-contact.h +++ /dev/null @@ -1,231 +0,0 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */ -/* - * Authors: - * Chris Toshok <toshok@ximian.com> - * - * Copyright (C) 2003 Ximian, Inc. - */ - -#ifndef __E_CONTACT_H__ -#define __E_CONTACT_H__ - -#include <time.h> -#include <glib-object.h> -#include <stdio.h> -#include <ebook/e-vcard.h> - -#define E_TYPE_CONTACT (e_contact_get_type ()) -#define E_CONTACT(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), E_TYPE_CONTACT, EContact)) -#define E_CONTACT_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), E_TYPE_CONTACT, EContactClass)) -#define E_IS_CONTACT(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), E_TYPE_CONTACT)) -#define E_IS_CONTACT_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), E_TYPE_CONTACT)) -#define E_CONTACT_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), E_TYPE_CONTACT, EContactClass)) - -typedef struct _EContact EContact; -typedef struct _EContactClass EContactClass; -typedef struct _EContactPrivate EContactPrivate; - -typedef enum { - - E_CONTACT_UID = 1, /* string field */ - E_CONTACT_FILE_AS, /* string field */ - - /* Name fields */ - E_CONTACT_FULL_NAME, /* string field */ - E_CONTACT_GIVEN_NAME, /* synthetic string field */ - E_CONTACT_FAMILY_NAME, /* synthetic string field */ - E_CONTACT_NICKNAME, /* string field */ - - /* Email fields */ - E_CONTACT_EMAIL_1, /* synthetic string field */ - E_CONTACT_EMAIL_2, /* synthetic string field */ - E_CONTACT_EMAIL_3, /* synthetic string field */ - - E_CONTACT_MAILER, /* string field */ - - /* Address Labels */ - E_CONTACT_ADDRESS_LABEL_HOME, /* synthetic string field */ - E_CONTACT_ADDRESS_LABEL_WORK, /* synthetic string field */ - E_CONTACT_ADDRESS_LABEL_OTHER, /* synthetic string field */ - - /* Phone fields */ - E_CONTACT_PHONE_ASSISTANT, - E_CONTACT_PHONE_BUSINESS, - E_CONTACT_PHONE_BUSINESS_2, - E_CONTACT_PHONE_BUSINESS_FAX, - E_CONTACT_PHONE_CALLBACK, - E_CONTACT_PHONE_CAR, - E_CONTACT_PHONE_COMPANY, - E_CONTACT_PHONE_HOME, - E_CONTACT_PHONE_HOME_2, - E_CONTACT_PHONE_HOME_FAX, - E_CONTACT_PHONE_ISDN, - E_CONTACT_PHONE_MOBILE, - E_CONTACT_PHONE_OTHER, - E_CONTACT_PHONE_OTHER_FAX, - E_CONTACT_PHONE_PAGER, - E_CONTACT_PHONE_PRIMARY, - E_CONTACT_PHONE_RADIO, - E_CONTACT_PHONE_TELEX, - E_CONTACT_PHONE_TTYTDD, - - /* Organizational fields */ - E_CONTACT_ORG, /* string field */ - E_CONTACT_ORG_UNIT, /* string field */ - E_CONTACT_OFFICE, /* string field */ - E_CONTACT_TITLE, /* string field */ - E_CONTACT_ROLE, /* string field */ - E_CONTACT_MANAGER, /* string field */ - E_CONTACT_ASSISTANT, /* string field */ - - /* Web fields */ - E_CONTACT_HOMEPAGE_URL, /* string field */ - E_CONTACT_BLOG_URL, /* string field */ - - /* Contact categories */ - E_CONTACT_CATEGORIES, /* string field */ - - /* Collaboration fields */ - E_CONTACT_CALENDAR_URI, /* string field */ - E_CONTACT_FREEBUSY_URL, /* string field */ - E_CONTACT_ICS_CALENDAR, /* string field */ - - /* misc fields */ - E_CONTACT_SPOUSE, /* string field */ - E_CONTACT_NOTE, /* string field */ - - /* fields used for describing contact lists. a contact list - is just a contact with _IS_LIST set to true. the members - are listed in the _EMAIL field. */ - E_CONTACT_IS_LIST, /* boolean field */ - E_CONTACT_LIST_SHOW_ADDRESSES, /* boolean field */ - - /* Instant Messaging fields */ - E_CONTACT_IM_AIM, /* Multi-valued */ - E_CONTACT_IM_JABBER, /* Multi-valued */ - E_CONTACT_IM_YAHOO, /* Multi-valued */ - E_CONTACT_IM_MSN, /* Multi-valued */ - E_CONTACT_IM_ICQ, /* Multi-valued */ - - /* Address fields */ - E_CONTACT_ADDRESS, /* Multi-valued structured (EContactAddress) */ - E_CONTACT_ADDRESS_HOME, /* synthetic structured field (EContactAddress) */ - E_CONTACT_ADDRESS_WORK, /* synthetic structured field (EContactAddress) */ - E_CONTACT_ADDRESS_OTHER, /* synthetic structured field (EContactAddress) */ - - E_CONTACT_CATEGORY_LIST, /* multi-valued */ - - /* Photo/Logo */ - E_CONTACT_PHOTO, /* structured field (EContactPhoto) */ - E_CONTACT_LOGO, /* structured field (EContactPhoto) */ - - E_CONTACT_NAME, /* structured field (EContactName) */ - E_CONTACT_EMAIL, /* Multi-valued */ - - E_CONTACT_WANTS_HTML, /* boolean field */ - - E_CONTACT_BIRTH_DATE, /* structured field (EContactDate) */ - E_CONTACT_ANNIVERSARY, /* structured field (EContactDate) */ - - /* Security Fields */ - E_CONTACT_X509_CERT, /* string field */ - E_CONTACT_X509_CERT_SHA1_FINGERPRINT, /* string field */ - - E_CONTACT_FIELD_LAST, - - /* useful constants */ - E_CONTACT_LAST_SIMPLE_STRING = E_CONTACT_NOTE, - E_CONTACT_FIRST_PHONE_ID = E_CONTACT_PHONE_ASSISTANT, - E_CONTACT_LAST_PHONE_ID = E_CONTACT_PHONE_TTYTDD, - E_CONTACT_FIRST_EMAIL_ID = E_CONTACT_EMAIL_1, - E_CONTACT_LAST_EMAIL_ID = E_CONTACT_EMAIL_3, - E_CONTACT_FIRST_ADDRESS_ID = E_CONTACT_ADDRESS_HOME, - E_CONTACT_LAST_ADDRESS_ID = E_CONTACT_ADDRESS_OTHER, - E_CONTACT_FIRST_LABEL_ID = E_CONTACT_ADDRESS_LABEL_HOME, - E_CONTACT_LAST_LABEL_ID = E_CONTACT_ADDRESS_LABEL_OTHER - -} EContactField; - -typedef struct { - char *family; - char *given; - char *additional; - char *prefixes; - char *suffixes; -} EContactName; - -typedef struct { - int length; - char *data; -} EContactPhoto; - -typedef struct { - char *address_format; /* the two letter country code that - determines the format/meaning of the - following fields */ - char *po; - char *ext; - char *street; - char *locality; - char *region; - char *code; - char *country; -} EContactAddress; - -typedef struct { - int year; - int month; - int day; -} EContactDate; - -struct _EContact { - EVCard parent; - - EContactPrivate *priv; -}; - -struct _EContactClass { - EVCardClass parent_class; - - /* Padding for future expansion */ - void (*_ebook_reserved0) (void); - void (*_ebook_reserved1) (void); - void (*_ebook_reserved2) (void); - void (*_ebook_reserved3) (void); - void (*_ebook_reserved4) (void); -}; - -GType e_contact_get_type (void); - -EContact* e_contact_new (void); -EContact* e_contact_new_from_vcard (const char *vcard); - -EContact* e_contact_duplicate (EContact *contact); - -gpointer e_contact_get (EContact *contact, EContactField field_id); -const gpointer e_contact_get_const (EContact *contact, EContactField field_id); -void e_contact_set (EContact *contact, EContactField field_id, gpointer value); - -/* misc functions for structured values */ -EContactDate *e_contact_date_new (void); -EContactDate *e_contact_date_from_string (const char *str); -char *e_contact_date_to_string (EContactDate *dt); - -EContactName *e_contact_name_new (void); -char *e_contact_name_to_string (const EContactName *name); -EContactName *e_contact_name_from_string (const char *name_str); -EContactName *e_contact_name_copy (EContactName *name); - - -/* destructors for structured values */ -void e_contact_date_free (EContactDate *date); -void e_contact_name_free (EContactName *name); -void e_contact_photo_free (EContactPhoto *photo); -void e_contact_address_free (EContactAddress *address); - - -const char* e_contact_field_name (EContactField field_id); -const char* e_contact_pretty_name (EContactField field_id); -EContactField e_contact_field_id (const char *field_name); - -#endif /* __E_CONTACT_H__ */ diff --git a/addressbook/backend/ebook/e-destination.c b/addressbook/backend/ebook/e-destination.c deleted file mode 100644 index b147489719..0000000000 --- a/addressbook/backend/ebook/e-destination.c +++ /dev/null @@ -1,1698 +0,0 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */ - -/* - * e-destination.c - * - * Copyright (C) 2001 Ximian, Inc. - * - * Developed by Jon Trowbridge <trow@ximian.com> - */ - -/* - * This program is free software; you can redistribute it and/or - * modify it under the terms of version 2 of the GNU General Public - * License as published by the Free Software Foundation. - * - * 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 - * USA. - */ - -#include <config.h> -#include "e-destination.h" - -#include <stdlib.h> -#include <ctype.h> -#include <string.h> -#include "e-book.h" -#include "e-book-marshal.h" -#include "e-book-util.h" -#include <gal/widgets/e-unicode.h> - -#include <glib.h> -#include <libxml/xmlmemory.h> -#include <camel/camel-internet-address.h> - -#define d(x) - -enum { - CHANGED, - CARDIFIED, - LAST_SIGNAL -}; - -guint e_destination_signals[LAST_SIGNAL] = { 0 }; - -struct _EDestinationPrivate { - gchar *raw; - - gchar *book_uri; - gchar *card_uid; - ECard *card; - gint card_email_num; - - ECard *old_card; - gint old_card_email_num; - gchar *old_textrep; - - gchar *name; - gchar *email; - gchar *addr; - gchar *textrep; - - GList *list_dests; - - guint html_mail_override : 1; - guint wants_html_mail : 1; - - guint show_addresses : 1; - - guint has_been_cardified : 1; - guint allow_cardify : 1; - guint cannot_cardify : 1; - guint auto_recipient : 1; - guint pending_cardification; - - guint pending_change : 1; - - EBook *cardify_book; - - gint freeze_count; -}; - -static void e_destination_clear_card (EDestination *); -static void e_destination_clear_strings (EDestination *); - -static GObjectClass *parent_class; - -static void -e_destination_dispose (GObject *obj) -{ - EDestination *dest = E_DESTINATION (obj); - - if (dest->priv) { - e_destination_clear (dest); - - if (dest->priv->old_card) - g_object_unref (dest->priv->old_card); - - if (dest->priv->cardify_book) - g_object_unref (dest->priv->cardify_book); - - g_free (dest->priv->old_textrep); - - g_free (dest->priv); - dest->priv = NULL; - } - - if (G_OBJECT_CLASS (parent_class)->dispose) - (* G_OBJECT_CLASS (parent_class)->dispose) (obj); -} - -static void -e_destination_class_init (EDestinationClass *klass) -{ - GObjectClass *object_class = G_OBJECT_CLASS (klass); - - parent_class = g_type_class_ref (G_TYPE_OBJECT); - - object_class->dispose = e_destination_dispose; - - e_destination_signals[CHANGED] = - g_signal_new ("changed", - G_OBJECT_CLASS_TYPE (object_class), - G_SIGNAL_RUN_LAST, - G_STRUCT_OFFSET (EDestinationClass, changed), - NULL, NULL, - e_book_marshal_NONE__NONE, - G_TYPE_NONE, 0); - - e_destination_signals[CARDIFIED] = - g_signal_new ("cardified", - G_OBJECT_CLASS_TYPE (object_class), - G_SIGNAL_RUN_LAST, - G_STRUCT_OFFSET (EDestinationClass, cardified), - NULL, NULL, - e_book_marshal_NONE__NONE, - G_TYPE_NONE, 0); -} - -static void -e_destination_init (EDestination *dest) -{ - dest->priv = g_new0 (struct _EDestinationPrivate, 1); - - dest->priv->allow_cardify = TRUE; - dest->priv->cannot_cardify = FALSE; - dest->priv->auto_recipient = FALSE; - dest->priv->pending_cardification = 0; -} - -GType -e_destination_get_type (void) -{ - static GType dest_type = 0; - - if (!dest_type) { - GTypeInfo dest_info = { - sizeof (EDestinationClass), - NULL, /* base_class_init */ - NULL, /* base_class_finalize */ - (GClassInitFunc) e_destination_class_init, - NULL, /* class_finalize */ - NULL, /* class_data */ - sizeof (EDestination), - 0, /* n_preallocs */ - (GInstanceInitFunc) e_destination_init - }; - - dest_type = g_type_register_static (G_TYPE_OBJECT, "EDestination", &dest_info, 0); - } - - return dest_type; -} - -EDestination * -e_destination_new (void) -{ - return g_object_new (E_TYPE_DESTINATION, NULL); -} - -static void -e_destination_freeze (EDestination *dest) -{ - g_return_if_fail (E_IS_DESTINATION (dest)); - g_return_if_fail (dest->priv->freeze_count >= 0); - - dest->priv->freeze_count++; -} - -static void -e_destination_thaw (EDestination *dest) -{ - g_return_if_fail (E_IS_DESTINATION (dest)); - g_return_if_fail (dest->priv->freeze_count > 0); - - dest->priv->freeze_count--; - if (dest->priv->freeze_count == 0 && dest->priv->pending_change) - e_destination_changed (dest); -} - -void -e_destination_changed (EDestination *dest) -{ - if (dest->priv->freeze_count == 0) { - g_signal_emit (dest, e_destination_signals[CHANGED], 0); - dest->priv->pending_change = FALSE; - dest->priv->cannot_cardify = FALSE; - - } else { - dest->priv->pending_change = TRUE; - } -} - -EDestination * -e_destination_copy (const EDestination *dest) -{ - EDestination *new_dest; - GList *iter; - - g_return_val_if_fail (dest && E_IS_DESTINATION (dest), NULL); - - new_dest = e_destination_new (); - - new_dest->priv->book_uri = g_strdup (dest->priv->book_uri); - new_dest->priv->card_uid = g_strdup (dest->priv->card_uid); - new_dest->priv->name = g_strdup (dest->priv->name); - new_dest->priv->email = g_strdup (dest->priv->email); - new_dest->priv->addr = g_strdup (dest->priv->addr); - new_dest->priv->card_email_num = dest->priv->card_email_num; - new_dest->priv->old_card_email_num = dest->priv->old_card_email_num; - new_dest->priv->old_textrep = g_strdup (dest->priv->old_textrep); - - new_dest->priv->card = dest->priv->card; - if (new_dest->priv->card) - g_object_ref (new_dest->priv->card); - - new_dest->priv->old_card = dest->priv->old_card; - if (new_dest->priv->old_card) - g_object_ref (new_dest->priv->old_card); - - new_dest->priv->html_mail_override = dest->priv->html_mail_override; - new_dest->priv->wants_html_mail = dest->priv->wants_html_mail; - - for (iter = dest->priv->list_dests; iter != NULL; iter = g_list_next (iter)) { - new_dest->priv->list_dests = g_list_append (new_dest->priv->list_dests, - e_destination_copy (E_DESTINATION (iter->data))); - } - - return new_dest; -} - -static void -e_destination_clear_card (EDestination *dest) -{ - if (dest->priv->card) { - if (dest->priv->old_card) - g_object_unref (dest->priv->old_card); - - dest->priv->old_card = dest->priv->card; - dest->priv->old_card_email_num = dest->priv->card_email_num; - - g_free (dest->priv->old_textrep); - dest->priv->old_textrep = g_strdup (e_destination_get_textrep (dest, FALSE)); - } - - g_free (dest->priv->book_uri); - dest->priv->book_uri = NULL; - g_free (dest->priv->card_uid); - dest->priv->card_uid = NULL; - - dest->priv->card = NULL; - dest->priv->card_email_num = -1; - - g_list_foreach (dest->priv->list_dests, (GFunc) g_object_unref, NULL); - g_list_free (dest->priv->list_dests); - dest->priv->list_dests = NULL; - - dest->priv->allow_cardify = TRUE; - dest->priv->cannot_cardify = FALSE; - - e_destination_cancel_cardify (dest); - - e_destination_changed (dest); -} - -static void -e_destination_clear_strings (EDestination *dest) -{ - g_free (dest->priv->raw); - dest->priv->raw = NULL; - - g_free (dest->priv->name); - dest->priv->name = NULL; - - g_free (dest->priv->email); - dest->priv->email = NULL; - - g_free (dest->priv->addr); - dest->priv->addr = NULL; - - g_free (dest->priv->textrep); - dest->priv->textrep = NULL; - - e_destination_changed (dest); -} - -void -e_destination_clear (EDestination *dest) -{ - g_return_if_fail (dest && E_IS_DESTINATION (dest)); - - e_destination_freeze (dest); - - e_destination_clear_card (dest); - e_destination_clear_strings (dest); - - e_destination_thaw (dest); -} - -static gboolean -nonempty (const gchar *s) -{ - gunichar c; - while (*s) { - c = g_utf8_get_char (s); - if (!g_unichar_isspace (c)) - return TRUE; - s = g_utf8_next_char (s); - } - return FALSE; -} - -gboolean -e_destination_is_empty (const EDestination *dest) - -{ - struct _EDestinationPrivate *p; - - g_return_val_if_fail (E_IS_DESTINATION (dest), TRUE); - - p = dest->priv; - - return !(p->card != NULL - || (p->book_uri && *p->book_uri) - || (p->card_uid && *p->card_uid) - || (p->raw && nonempty (p->raw)) - || (p->name && nonempty (p->name)) - || (p->email && nonempty (p->email)) - || (p->addr && nonempty (p->addr)) - || (p->list_dests != NULL)); -} - -gboolean -e_destination_is_valid (const EDestination *dest) -{ - const char *email; - - g_return_val_if_fail (E_IS_DESTINATION (dest), FALSE); - - if (e_destination_from_card (dest)) - return TRUE; - - email = e_destination_get_email (dest); - - /* FIXME: if we really wanted to get fancy here, we could - check to make sure that the address was valid according to - rfc822's addr-spec grammar. */ - - return email && *email && strchr (email, '@'); -} - -gboolean -e_destination_equal (const EDestination *a, const EDestination *b) -{ - const struct _EDestinationPrivate *pa, *pb; - const char *na, *nb; - - g_return_val_if_fail (E_IS_DESTINATION (a), FALSE); - g_return_val_if_fail (E_IS_DESTINATION (b), FALSE); - - if (a == b) - return TRUE; - - pa = a->priv; - pb = b->priv; - - /* Check equality of cards. */ - if (pa->card || pb->card) { - if (! (pa->card && pb->card)) - return FALSE; - - if (pa->card == pb->card || !strcmp (e_card_get_id (pa->card), e_card_get_id (pb->card))) - return TRUE; - - return FALSE; - } - - /* Just in case name returns NULL */ - na = e_destination_get_name (a); - nb = e_destination_get_name (b); - if ((na || nb) && !(na && nb && ! e_utf8_casefold_collate (na, nb))) - return FALSE; - - if (!g_ascii_strcasecmp (e_destination_get_email (a), e_destination_get_email (b))) - return TRUE; - else - return FALSE; -} - -void -e_destination_set_card (EDestination *dest, ECard *card, gint email_num) -{ - g_return_if_fail (dest && E_IS_DESTINATION (dest)); - g_return_if_fail (card && E_IS_CARD (card)); - - if (dest->priv->card != card || dest->priv->card_email_num != email_num) { - /* We have to freeze/thaw around these operations so that the 'changed' - signals don't cause the EDestination's internal state to be altered - before we can finish setting ->card && ->card_email_num. */ - e_destination_freeze (dest); - e_destination_clear (dest); - - dest->priv->card = card; - g_object_ref (dest->priv->card); - - dest->priv->card_email_num = email_num; - - e_destination_changed (dest); - e_destination_thaw (dest); - } -} - -void -e_destination_set_book_uri (EDestination *dest, const gchar *uri) -{ - g_return_if_fail (dest && E_IS_DESTINATION (dest)); - g_return_if_fail (uri != NULL); - - if (dest->priv->book_uri == NULL || strcmp (dest->priv->book_uri, uri)) { - g_free (dest->priv->book_uri); - dest->priv->book_uri = g_strdup (uri); - - /* If we already have a card, remove it unless it's uri matches the one - we just set. */ - if (dest->priv->card) { - EBook *book = e_card_get_book (dest->priv->card); - if ((!book) || strcmp (uri, e_book_get_uri (book))) { - g_object_unref (dest->priv->card); - dest->priv->card = NULL; - } - } - - e_destination_changed (dest); - } -} - -void -e_destination_set_card_uid (EDestination *dest, const gchar *uid, gint email_num) -{ - g_return_if_fail (dest && E_IS_DESTINATION (dest)); - g_return_if_fail (uid != NULL); - - if (dest->priv->card_uid == NULL - || strcmp (dest->priv->card_uid, uid) - || dest->priv->card_email_num != email_num) { - - g_free (dest->priv->card_uid); - dest->priv->card_uid = g_strdup (uid); - dest->priv->card_email_num = email_num; - - /* If we already have a card, remove it unless it's uri matches the one - we just set. */ - if (dest->priv->card && strcmp (uid, e_card_get_id (dest->priv->card))) { - g_object_unref (dest->priv->card); - dest->priv->card = NULL; - } - - e_destination_changed (dest); - } -} - -void -e_destination_set_name (EDestination *dest, const gchar *name) -{ - gboolean changed = FALSE; - - g_return_if_fail (E_IS_DESTINATION (dest)); - - if (name == NULL) { - if (dest->priv->name != NULL) { - g_free (dest->priv->name); - dest->priv->name = NULL; - changed = TRUE; - } - } else if (dest->priv->name == NULL || strcmp (dest->priv->name, name)) { - g_free (dest->priv->name); - dest->priv->name = g_strdup (name); - changed = TRUE; - } - - if (changed) { - g_free (dest->priv->addr); - dest->priv->addr = NULL; - g_free (dest->priv->textrep); - dest->priv->textrep = NULL; - e_destination_changed (dest); - } -} - -void -e_destination_set_email (EDestination *dest, const gchar *email) -{ - gboolean changed = FALSE; - - g_return_if_fail (E_IS_DESTINATION (dest)); - - if (email == NULL) { - if (dest->priv->email != NULL) { - g_free (dest->priv->addr); - dest->priv->addr = NULL; - changed = TRUE; - } - } else if (dest->priv->email == NULL || strcmp (dest->priv->email, email)) { - g_free (dest->priv->email); - dest->priv->email = g_strdup (email); - changed = TRUE; - } - - if (changed) { - g_free (dest->priv->addr); - dest->priv->addr = NULL; - g_free (dest->priv->textrep); - dest->priv->textrep = NULL; - e_destination_changed (dest); - } -} - -void -e_destination_set_html_mail_pref (EDestination *dest, gboolean x) -{ - g_return_if_fail (dest && E_IS_DESTINATION (dest)); - - dest->priv->html_mail_override = TRUE; - if (dest->priv->wants_html_mail != x) { - dest->priv->wants_html_mail = x; - e_destination_changed (dest); - } -} - -gboolean -e_destination_contains_card (const EDestination *dest) -{ - g_return_val_if_fail (dest && E_IS_DESTINATION (dest), FALSE); - return dest->priv->card != NULL; -} - -gboolean -e_destination_from_card (const EDestination *dest) -{ - g_return_val_if_fail (dest && E_IS_DESTINATION (dest), FALSE); - return dest->priv->card != NULL || dest->priv->book_uri != NULL || dest->priv->card_uid != NULL; -} - -gboolean -e_destination_is_auto_recipient (const EDestination *dest) -{ - g_return_val_if_fail (dest && E_IS_DESTINATION (dest), FALSE); - - return dest->priv->auto_recipient; -} - -void -e_destination_set_auto_recipient (EDestination *dest, gboolean value) -{ - g_return_if_fail (dest && E_IS_DESTINATION (dest)); - - dest->priv->auto_recipient = value; -} - -typedef struct _UseCard UseCard; -struct _UseCard { - EDestination *dest; - EDestinationCardCallback cb; - gpointer closure; -}; - -static void -use_card_cb (ECard *card, gpointer closure) -{ - UseCard *uc = (UseCard *) closure; - - if (card != NULL && uc->dest->priv->card == NULL) { - uc->dest->priv->card = card; - g_object_ref (uc->dest->priv->card); - e_destination_changed (uc->dest); - } - - if (uc->cb) { - uc->cb (uc->dest, uc->dest->priv->card, uc->closure); - } - - /* We held a copy of the destination during the callback. */ - g_object_unref (uc->dest); - g_free (uc); -} - -void -e_destination_use_card (EDestination *dest, EDestinationCardCallback cb, gpointer closure) -{ - g_return_if_fail (dest && E_IS_DESTINATION (dest)); - - if (dest->priv->card != NULL) { - if (cb) - cb (dest, dest->priv->card, closure); - } else if (dest->priv->book_uri != NULL && dest->priv->card_uid != NULL) { - UseCard *uc = g_new (UseCard, 1); - - uc->dest = dest; - /* Hold a reference to the destination during the callback. */ - g_object_ref (uc->dest); - uc->cb = cb; - uc->closure = closure; - e_card_load_uri (dest->priv->book_uri, dest->priv->card_uid, use_card_cb, uc); - } else { - if (cb) - cb (dest, NULL, closure); - } -} - -ECard * -e_destination_get_card (const EDestination *dest) -{ - g_return_val_if_fail (dest && E_IS_DESTINATION (dest), NULL); - - return dest->priv->card; -} - -const gchar * -e_destination_get_card_uid (const EDestination *dest) -{ - g_return_val_if_fail (dest && E_IS_DESTINATION (dest), NULL); - - if (dest->priv->card_uid) - return dest->priv->card_uid; - - if (dest->priv->card) - return e_card_get_id (dest->priv->card); - - return NULL; -} - -const gchar * -e_destination_get_book_uri (const EDestination *dest) -{ - g_return_val_if_fail (dest && E_IS_DESTINATION (dest), NULL); - - if (dest->priv->book_uri) - return dest->priv->book_uri; - - if (dest->priv->card) { - EBook *book = e_card_get_book (dest->priv->card); - - if (book) { - return e_book_get_uri (book); - } - } - - return NULL; -} - -gint -e_destination_get_email_num (const EDestination *dest) -{ - g_return_val_if_fail (dest && E_IS_DESTINATION (dest), -1); - - if (dest->priv->card == NULL && (dest->priv->book_uri == NULL || dest->priv->card_uid == NULL)) - return -1; - - return dest->priv->card_email_num; -} - -const gchar * -e_destination_get_name (const EDestination *dest) -{ - struct _EDestinationPrivate *priv; - - g_return_val_if_fail (dest && E_IS_DESTINATION (dest), NULL); - - priv = (struct _EDestinationPrivate *)dest->priv; /* cast out const */ - - if (priv->name == NULL) { - if (priv->card != NULL) { - priv->name = e_card_name_to_string (priv->card->name); - - if (priv->name == NULL || *priv->name == '\0') { - g_free (priv->name); - priv->name = g_strdup (priv->card->file_as); - } - - if (priv->name == NULL || *priv->name == '\0') { - g_free (priv->name); - if (e_card_evolution_list (priv->card)) - priv->name = g_strdup (_("Unnamed List")); - else - priv->name = g_strdup (e_destination_get_email (dest)); - } - } else if (priv->raw != NULL) { - CamelInternetAddress *addr = camel_internet_address_new (); - - if (camel_address_unformat (CAMEL_ADDRESS (addr), priv->raw)) { - const char *camel_name = NULL; - - camel_internet_address_get (addr, 0, &camel_name, NULL); - priv->name = g_strdup (camel_name); - } - - camel_object_unref (CAMEL_OBJECT (addr)); - } - } - - return priv->name; -} - -const gchar * -e_destination_get_email (const EDestination *dest) -{ - struct _EDestinationPrivate *priv; - - g_return_val_if_fail (dest && E_IS_DESTINATION (dest), NULL); - - priv = (struct _EDestinationPrivate *)dest->priv; /* cast out const */ - - if (priv->email == NULL) { - if (priv->card != NULL) { - /* Pull the address out of the card. */ - if (priv->card->email) { - EIterator *iter = e_list_get_iterator (priv->card->email); - int n = priv->card_email_num; - - if (n >= 0) { - while (n > 0) { - e_iterator_next (iter); - n--; - } - - if (e_iterator_is_valid (iter)) { - gconstpointer ptr = e_iterator_get (iter); - priv->email = g_strdup ((char *) ptr); - } - } - } - } else if (priv->raw != NULL) { - CamelInternetAddress *addr = camel_internet_address_new (); - - if (camel_address_unformat (CAMEL_ADDRESS (addr), priv->raw)) { - const gchar *camel_email = NULL; - camel_internet_address_get (addr, 0, NULL, &camel_email); - priv->email = g_strdup (camel_email); - } - - camel_object_unref (CAMEL_OBJECT (addr)); - } - - /* Force e-mail to be non-null... */ - if (priv->email == NULL) { - priv->email = g_strdup (""); - } - } - - return priv->email; -} - -const gchar * -e_destination_get_address (const EDestination *dest) -{ - struct _EDestinationPrivate *priv; - - g_return_val_if_fail (dest && E_IS_DESTINATION (dest), NULL); - - priv = (struct _EDestinationPrivate *)dest->priv; /* cast out const */ - - if (priv->addr == NULL) { - CamelInternetAddress *addr = camel_internet_address_new (); - - if (e_destination_is_evolution_list (dest)) { - GList *iter = dest->priv->list_dests; - - while (iter) { - EDestination *list_dest = E_DESTINATION (iter->data); - - if (!e_destination_is_empty (list_dest)) { - camel_internet_address_add (addr, - e_destination_get_name (list_dest), - e_destination_get_email (list_dest)); - } - iter = g_list_next (iter); - } - - priv->addr = camel_address_encode (CAMEL_ADDRESS (addr)); - } else if (priv->raw) { - - if (camel_address_unformat (CAMEL_ADDRESS (addr), priv->raw)) { - priv->addr = camel_address_encode (CAMEL_ADDRESS (addr)); - } - } else { - camel_internet_address_add (addr, - e_destination_get_name (dest), - e_destination_get_email (dest)); - - priv->addr = camel_address_encode (CAMEL_ADDRESS (addr)); - } - - camel_object_unref (CAMEL_OBJECT (addr)); - } - - return priv->addr; -} - -void -e_destination_set_raw (EDestination *dest, const gchar *raw) -{ - g_return_if_fail (E_IS_DESTINATION (dest)); - g_return_if_fail (raw != NULL); - - if (dest->priv->raw == NULL || strcmp (dest->priv->raw, raw)) { - e_destination_freeze (dest); - - e_destination_clear (dest); - dest->priv->raw = g_strdup (raw); - e_destination_changed (dest); - - e_destination_thaw (dest); - } -} - -const gchar * -e_destination_get_textrep (const EDestination *dest, gboolean include_email) -{ - const char *name, *email; - - g_return_val_if_fail (dest && E_IS_DESTINATION (dest), NULL); - - if (dest->priv->raw) - return dest->priv->raw; - - name = e_destination_get_name (dest); - email = e_destination_get_email (dest); - - if (e_destination_from_card (dest) && name != NULL && (!include_email || !email || !*email)) - return name; - - /* Make sure that our address gets quoted properly */ - if (name && email && dest->priv->textrep == NULL) { - CamelInternetAddress *addr = camel_internet_address_new (); - - camel_internet_address_add (addr, name, email); - g_free (dest->priv->textrep); - dest->priv->textrep = camel_address_format (CAMEL_ADDRESS (addr)); - camel_object_unref (CAMEL_OBJECT (addr)); - } - - if (dest->priv->textrep != NULL) - return dest->priv->textrep; - - if (email) - return email; - - return ""; -} - -gboolean -e_destination_is_evolution_list (const EDestination *dest) -{ - g_return_val_if_fail (dest && E_IS_DESTINATION (dest), FALSE); - - if (dest->priv->list_dests == NULL - && dest->priv->card != NULL - && dest->priv->card->email != NULL - && e_card_evolution_list (dest->priv->card)) { - - EIterator *iter = e_list_get_iterator (dest->priv->card->email); - - e_iterator_reset (iter); - while (e_iterator_is_valid (iter)) { - const char *dest_xml = (const char *) e_iterator_get (iter); - EDestination *list_dest = e_destination_import (dest_xml); - - if (list_dest) - dest->priv->list_dests = g_list_append (dest->priv->list_dests, list_dest); - e_iterator_next (iter); - } - } - - return dest->priv->list_dests != NULL; -} - -gboolean -e_destination_list_show_addresses (const EDestination *dest) -{ - g_return_val_if_fail (E_IS_DESTINATION (dest), FALSE); - - if (dest->priv->card != NULL) - return e_card_evolution_list_show_addresses (dest->priv->card); - - return dest->priv->show_addresses; -} - -gboolean -e_destination_get_html_mail_pref (const EDestination *dest) -{ - g_return_val_if_fail (dest && E_IS_DESTINATION (dest), FALSE); - - if (dest->priv->html_mail_override || dest->priv->card == NULL) - return dest->priv->wants_html_mail; - - return dest->priv->card->wants_html; -} - -gboolean -e_destination_allow_cardification (const EDestination *dest) -{ - g_return_val_if_fail (E_IS_DESTINATION (dest), FALSE); - - return dest->priv->allow_cardify; -} - -void -e_destination_set_allow_cardification (EDestination *dest, gboolean x) -{ - g_return_if_fail (E_IS_DESTINATION (dest)); - - dest->priv->allow_cardify = x; -} - -static void -set_cardify_book (EDestination *dest, EBook *book) -{ - if (dest->priv->cardify_book && dest->priv->cardify_book != book) { - g_object_unref (dest->priv->cardify_book); - } - - dest->priv->cardify_book = book; - - if (book) - g_object_ref (book); -} - -static void -name_and_email_simple_query_cb (EBook *book, EBookSimpleQueryStatus status, const GList *cards, gpointer closure) -{ - EDestination *dest = E_DESTINATION (closure); - - if (status == E_BOOK_SIMPLE_QUERY_STATUS_SUCCESS && g_list_length ((GList *) cards) == 1) { - ECard *card = E_CARD (cards->data); - const char *email = e_destination_get_email (dest); - int email_num = 0; - - if (e_destination_is_valid (dest) && email && *email) { - email_num = e_card_email_find_number (card, e_destination_get_email (dest)); - } - - if (email_num >= 0) { - const char *book_uri; - - book_uri = e_book_get_uri (book); - - dest->priv->has_been_cardified = TRUE; - e_destination_set_card (dest, card, email_num); - e_destination_set_book_uri (dest, book_uri); - g_signal_emit (dest, e_destination_signals[CARDIFIED], 0); - } - } - - if (!dest->priv->has_been_cardified) { - dest->priv->cannot_cardify = TRUE; - } - - g_object_unref (dest); /* drop the reference held by the query */ -} - - -static void -nickname_simple_query_cb (EBook *book, EBookSimpleQueryStatus status, const GList *cards, gpointer closure) -{ - EDestination *dest = E_DESTINATION (closure); - - if (status == E_BOOK_SIMPLE_QUERY_STATUS_SUCCESS) { - if (g_list_length ((GList *) cards) == 1) { - const char *book_uri; - - book_uri = e_book_get_uri (book); - - dest->priv->has_been_cardified = TRUE; - e_destination_set_card (dest, E_CARD (cards->data), 0); /* Uses primary e-mail by default. */ - e_destination_set_book_uri (dest, book_uri); - g_signal_emit (dest, e_destination_signals[CARDIFIED], 0); - - g_object_unref (dest); /* drop the reference held by the query */ - - } else { - /* We can only end up here if we don't look at all like an e-mail address, so - we do a name-only query on the textrep */ - - e_book_name_and_email_query (book, - e_destination_get_textrep (dest, FALSE), - NULL, - name_and_email_simple_query_cb, - dest); - } - } else { - /* Something went wrong with the query: drop our ref to the destination and return. */ - g_object_unref (dest); - } -} - -static void -launch_cardify_query (EDestination *dest) -{ - if (! e_destination_is_valid (dest)) { - /* If it doesn't look like an e-mail address, see if it is a nickname. */ - e_book_nickname_query (dest->priv->cardify_book, - e_destination_get_textrep (dest, FALSE), - nickname_simple_query_cb, - dest); - - } else { - e_book_name_and_email_query (dest->priv->cardify_book, - e_destination_get_name (dest), - e_destination_get_email (dest), - name_and_email_simple_query_cb, - dest); - } -} - -static void -use_default_book_cb (EBook *book, gpointer closure) -{ - EDestination *dest = E_DESTINATION (closure); - if (book != NULL && dest->priv->cardify_book == NULL) { - dest->priv->cardify_book = book; - g_object_ref (book); - } - - if (dest->priv->cardify_book) - launch_cardify_query (dest); - else - g_object_unref (dest); -} - - -static gboolean -e_destination_reverting_is_a_good_idea (EDestination *dest) -{ - const char *textrep; - int len, old_len; - - g_return_val_if_fail (E_IS_DESTINATION (dest), FALSE); - if (dest->priv->old_textrep == NULL) - return FALSE; - - textrep = e_destination_get_textrep (dest, FALSE); - - len = g_utf8_strlen (textrep, -1); - old_len = g_utf8_strlen (dest->priv->old_textrep, -1); - - if (len <= old_len/2) - return FALSE; - - return TRUE; -} - -void -e_destination_cardify (EDestination *dest, EBook *book) -{ - g_return_if_fail (E_IS_DESTINATION (dest)); - g_return_if_fail (book == NULL || E_IS_BOOK (book)); - - if (e_destination_is_evolution_list (dest)) - return; - - if (e_destination_contains_card (dest)) - return; - - if (!dest->priv->allow_cardify) - return; - - if (dest->priv->cannot_cardify) - return; - - e_destination_cancel_cardify (dest); - - /* In some cases, we can revert to the previous card. */ - if (!e_destination_is_valid (dest) - && e_destination_reverting_is_a_good_idea (dest) - && e_destination_revert (dest)) { - return; - } - - set_cardify_book (dest, book); - - /* Handle the case of an EDestination containing a card URL */ - if (e_destination_contains_card (dest)) { - e_destination_use_card (dest, NULL, NULL); - return; - } - - /* If we have a book ready, proceed. We hold a reference to ourselves - until our query is complete. */ - g_object_ref (dest); - if (dest->priv->cardify_book != NULL) { - launch_cardify_query (dest); - } else { - e_book_use_default_book (use_default_book_cb, dest); - } -} - -static int -do_cardify_delayed (gpointer ptr) -{ - EDestination *dest = E_DESTINATION (ptr); - - e_destination_cardify (dest, dest->priv->cardify_book); - return FALSE; -} - -void -e_destination_cardify_delayed (EDestination *dest, EBook *book, gint delay) -{ - g_return_if_fail (E_IS_DESTINATION (dest)); - g_return_if_fail (book == NULL || E_IS_BOOK (book)); - - if (delay < 0) - delay = 500; - - e_destination_cancel_cardify (dest); - - set_cardify_book (dest, book); - - dest->priv->pending_cardification = g_timeout_add (delay, do_cardify_delayed, dest); -} - -void -e_destination_cancel_cardify (EDestination *dest) -{ - g_return_if_fail (E_IS_DESTINATION (dest)); - - if (dest->priv->pending_cardification) { - g_source_remove (dest->priv->pending_cardification); - dest->priv->pending_cardification = 0; - } -} - -gboolean -e_destination_uncardify (EDestination *dest) -{ - char *email; - - g_return_val_if_fail (E_IS_DESTINATION (dest), FALSE); - - if (!e_destination_contains_card (dest)) - return FALSE; - - email = g_strdup (e_destination_get_email (dest)); - - if (email == NULL) - return FALSE; - - e_destination_freeze (dest); - e_destination_clear (dest); - e_destination_set_raw (dest, email); - g_free (email); - e_destination_thaw (dest); - - return TRUE; -} - -gboolean -e_destination_revert (EDestination *dest) -{ - g_return_val_if_fail (E_IS_DESTINATION (dest), FALSE); - - if (dest->priv->old_card) { - ECard *card; - int card_email_num; - - card = dest->priv->old_card; - card_email_num = dest->priv->old_card_email_num; - - dest->priv->old_card = NULL; - g_free (dest->priv->old_textrep); - dest->priv->old_textrep = NULL; - - e_destination_freeze (dest); - e_destination_clear (dest); - e_destination_set_card (dest, card, card_email_num); - e_destination_thaw (dest); - - return TRUE; - } - - return FALSE; -} - -/* - * Destination import/export - */ - -gchar * -e_destination_get_address_textv (EDestination **destv) -{ - int i, j, len = 0; - char **strv; - char *str; - - g_return_val_if_fail (destv, NULL); - - /* Q: Please tell me this is only for assertion - reasons. If this is considered to be ok behavior then you - shouldn't use g_return's. Just a reminder ;-) - - A: Yes, this is just an assertion. (Though it does find the - length of the vector in the process...) - */ - while (destv[len]) { - g_return_val_if_fail (E_IS_DESTINATION (destv[len]), NULL); - len++; - } - - strv = g_new0 (char *, len + 1); - for (i = 0, j = 0; destv[i]; i++) { - if (!e_destination_is_empty (destv[i])) { - const char *addr = e_destination_get_address (destv[i]); - strv[j++] = addr ? (char *) addr : ""; - } - } - - str = g_strjoinv (", ", strv); - - g_free (strv); - - return str; -} - -xmlNodePtr -e_destination_xml_encode (const EDestination *dest) -{ - xmlNodePtr dest_node; - const char *str; - - g_return_val_if_fail (dest && E_IS_DESTINATION (dest), NULL); - - dest_node = xmlNewNode (NULL, "destination"); - - str = e_destination_get_name (dest); - if (str) - xmlNewTextChild (dest_node, NULL, "name", str); - - if (!e_destination_is_evolution_list (dest)) { - str = e_destination_get_email (dest); - if (str) - xmlNewTextChild (dest_node, NULL, "email", str); - } else { - GList *iter = dest->priv->list_dests; - - while (iter) { - EDestination *list_dest = E_DESTINATION (iter->data); - xmlNodePtr list_node = xmlNewNode (NULL, "list_entry"); - - str = e_destination_get_name (list_dest); - if (str) - xmlNewTextChild (list_node, NULL, "name", str); - - str = e_destination_get_email (list_dest); - if (str) - xmlNewTextChild (list_node, NULL, "email", str); - - xmlAddChild (dest_node, list_node); - - iter = g_list_next (iter); - } - - xmlNewProp (dest_node, "is_list", "yes"); - xmlNewProp (dest_node, "show_addresses", - e_destination_list_show_addresses (dest) ? "yes" : "no"); - } - - str = e_destination_get_book_uri (dest); - if (str) { - xmlNewTextChild (dest_node, NULL, "book_uri", str); - } - - str = e_destination_get_card_uid (dest); - if (str) { - char buf[16]; - - xmlNodePtr uri_node = xmlNewTextChild (dest_node, NULL, "card_uid", str); - g_snprintf (buf, 16, "%d", e_destination_get_email_num (dest)); - xmlNewProp (uri_node, "email_num", buf); - } - - xmlNewProp (dest_node, "html_mail", e_destination_get_html_mail_pref (dest) ? "yes" : "no"); - - xmlNewProp (dest_node, "auto_recipient", - e_destination_is_auto_recipient (dest) ? "yes" : "no"); - - return dest_node; -} - -gboolean -e_destination_xml_decode (EDestination *dest, xmlNodePtr node) -{ - char *name = NULL, *email = NULL, *book_uri = NULL, *card_uid = NULL; - gboolean is_list = FALSE, show_addr = FALSE, auto_recip = FALSE; - gboolean html_mail = FALSE; - GList *list_dests = NULL; - int email_num = -1; - char *tmp; - - g_return_val_if_fail (dest && E_IS_DESTINATION (dest), FALSE); - g_return_val_if_fail (node != NULL, FALSE); - - if (strcmp (node->name, "destination")) - return FALSE; - - tmp = xmlGetProp (node, "html_mail"); - if (tmp) { - html_mail = !strcmp (tmp, "yes"); - xmlFree (tmp); - } - - tmp = xmlGetProp (node, "is_list"); - if (tmp) { - is_list = !strcmp (tmp, "yes"); - xmlFree (tmp); - } - - tmp = xmlGetProp (node, "show_addresses"); - if (tmp) { - show_addr = !strcmp (tmp, "yes"); - xmlFree (tmp); - } - - tmp = xmlGetProp (node, "auto_recipient"); - if (tmp) { - auto_recip = !strcmp (tmp, "yes"); - xmlFree (tmp); - } - - node = node->xmlChildrenNode; - while (node) { - if (!strcmp (node->name, "name")) { - tmp = xmlNodeGetContent (node); - g_free (name); - name = g_strdup (tmp); - xmlFree (tmp); - } else if (!is_list && !strcmp (node->name, "email")) { - tmp = xmlNodeGetContent (node); - g_free (email); - email = g_strdup (tmp); - xmlFree (tmp); - } else if (is_list && !strcmp (node->name, "list_entry")) { - xmlNodePtr subnode = node->xmlChildrenNode; - char *list_name = NULL, *list_email = NULL; - - while (subnode) { - if (!strcmp (subnode->name, "name")) { - tmp = xmlNodeGetContent (subnode); - g_free (list_name); - list_name = g_strdup (tmp); - xmlFree (tmp); - } else if (!strcmp (subnode->name, "email")) { - tmp = xmlNodeGetContent (subnode); - g_free (list_email); - list_email = g_strdup (tmp); - xmlFree (tmp); - } - - subnode = subnode->next; - } - - if (list_name || list_email) { - EDestination *list_dest = e_destination_new (); - - if (list_name) - e_destination_set_name (list_dest, list_name); - if (list_email) - e_destination_set_email (list_dest, list_email); - - g_free (list_name); - g_free (list_email); - - list_dests = g_list_append (list_dests, list_dest); - } - } else if (!strcmp (node->name, "book_uri")) { - tmp = xmlNodeGetContent (node); - g_free (book_uri); - book_uri = g_strdup (tmp); - xmlFree (tmp); - } else if (!strcmp (node->name, "card_uid")) { - tmp = xmlNodeGetContent (node); - g_free (card_uid); - card_uid = g_strdup (tmp); - xmlFree (tmp); - - tmp = xmlGetProp (node, "email_num"); - email_num = atoi (tmp); - xmlFree (tmp); - } - - node = node->next; - } - - e_destination_freeze (dest); - - e_destination_clear (dest); - - if (name) { - e_destination_set_name (dest, name); - g_free (name); - } - if (email) { - e_destination_set_email (dest, email); - g_free (email); - } - if (book_uri) { - e_destination_set_book_uri (dest, book_uri); - g_free (book_uri); - } - if (card_uid) { - e_destination_set_card_uid (dest, card_uid, email_num); - g_free (card_uid); - } - if (list_dests) - dest->priv->list_dests = list_dests; - - dest->priv->html_mail_override = TRUE; - dest->priv->wants_html_mail = html_mail; - - dest->priv->show_addresses = show_addr; - - dest->priv->auto_recipient = auto_recip; - - e_destination_thaw (dest); - - return TRUE; -} - -/* FIXME: Make utf-8 safe */ -static gchar * -null_terminate_and_remove_extra_whitespace (xmlChar *xml_in, gint size) -{ - gboolean skip_white = FALSE; - char *xml, *r, *w; - - if (xml_in == NULL || size <= 0) - return NULL; - - xml = g_strndup (xml_in, size); - r = w = xml; - - while (*r) { - if (*r == '\n' || *r == '\r') { - skip_white = TRUE; - } else { - gboolean is_space = isspace (*r); - - *w = *r; - - if (!(skip_white && is_space)) - w++; - if (!is_space) - skip_white = FALSE; - } - r++; - } - - *w = '\0'; - - return xml; -} - -gchar * -e_destination_export (const EDestination *dest) -{ - xmlNodePtr dest_node; - xmlDocPtr dest_doc; - xmlChar *buffer = NULL; - int size = -1; - char *str; - - g_return_val_if_fail (dest && E_IS_DESTINATION (dest), NULL); - - dest_node = e_destination_xml_encode (dest); - if (dest_node == NULL) - return NULL; - - dest_doc = xmlNewDoc (XML_DEFAULT_VERSION); - xmlDocSetRootElement (dest_doc, dest_node); - - xmlDocDumpMemory (dest_doc, &buffer, &size); - xmlFreeDoc (dest_doc); - - str = null_terminate_and_remove_extra_whitespace (buffer, size); - xmlFree (buffer); - - return str; -} - -EDestination * -e_destination_import (const gchar *str) -{ - EDestination *dest = NULL; - xmlDocPtr dest_doc; - - if (!(str && *str)) - return NULL; - - dest_doc = xmlParseMemory ((char *) str, strlen (str)); - if (dest_doc && dest_doc->xmlRootNode) { - dest = e_destination_new (); - if (! e_destination_xml_decode (dest, dest_doc->xmlRootNode)) { - g_object_unref (dest); - dest = NULL; - } - } - xmlFreeDoc (dest_doc); - - return dest; -} - -gchar * -e_destination_exportv (EDestination **destv) -{ - xmlDocPtr destv_doc; - xmlNodePtr destv_node; - xmlChar *buffer = NULL; - int i, size = -1; - char *str; - - if (destv == NULL || *destv == NULL) - return NULL; - - destv_doc = xmlNewDoc (XML_DEFAULT_VERSION); - destv_node = xmlNewNode (NULL, "destinations"); - xmlDocSetRootElement (destv_doc, destv_node); - - for (i = 0; destv[i]; i++) { - if (! e_destination_is_empty (destv[i])) { - xmlNodePtr dest_node = e_destination_xml_encode (destv[i]); - if (dest_node) - xmlAddChild (destv_node, dest_node); - } - } - - xmlDocDumpMemory (destv_doc, &buffer, &size); - xmlFreeDoc (destv_doc); - - str = null_terminate_and_remove_extra_whitespace (buffer, size); - xmlFree (buffer); - - return str; -} - -EDestination ** -e_destination_importv (const gchar *str) -{ - GPtrArray *dest_array = NULL; - xmlDocPtr destv_doc; - xmlNodePtr node; - EDestination **destv = NULL; - - if (!(str && *str)) - return NULL; - - destv_doc = xmlParseMemory ((char *)str, strlen (str)); - if (destv_doc == NULL) - return NULL; - - node = destv_doc->xmlRootNode; - - if (strcmp (node->name, "destinations")) - goto finished; - - node = node->xmlChildrenNode; - - dest_array = g_ptr_array_new (); - - while (node) { - EDestination *dest; - - dest = e_destination_new (); - if (e_destination_xml_decode (dest, node) && !e_destination_is_empty (dest)) { - g_ptr_array_add (dest_array, dest); - } else { - g_object_unref (dest); - } - - node = node->next; - } - - /* we need destv to be NULL terminated */ - g_ptr_array_add (dest_array, NULL); - - destv = (EDestination **) dest_array->pdata; - g_ptr_array_free (dest_array, FALSE); - - finished: - xmlFreeDoc (destv_doc); - - return destv; -} - -EDestination ** -e_destination_list_to_vector_sized (GList *list, int n) -{ - EDestination **destv; - int i = 0; - - if (n == -1) - n = g_list_length (list); - - if (n == 0) - return NULL; - - destv = g_new (EDestination *, n + 1); - while (list != NULL && i < n) { - destv[i] = E_DESTINATION (list->data); - list->data = NULL; - i++; - list = g_list_next (list); - } - destv[i] = NULL; - - return destv; -} - -EDestination ** -e_destination_list_to_vector (GList *list) -{ - return e_destination_list_to_vector_sized (list, -1); -} - -void -e_destination_freev (EDestination **destv) -{ - int i; - - if (destv) { - for (i = 0; destv[i] != NULL; ++i) { - g_object_unref (destv[i]); - } - g_free (destv); - } - -} - -static void -touch_cb (EBook *book, const gchar *addr, ECard *card, gpointer closure) -{ - if (book != NULL && card != NULL) { - e_card_touch (card); - d(g_message ("Use score for \"%s\" is now %f", addr, e_card_get_use_score (card))); - e_book_commit_card (book, card, NULL, NULL); - } -} - -void -e_destination_touch (EDestination *dest) -{ - const char *email; - - g_return_if_fail (dest && E_IS_DESTINATION (dest)); - - if (!e_destination_is_auto_recipient (dest)) { - email = e_destination_get_email (dest); - - if (email) - e_book_query_address_default (email, touch_cb, NULL); - } -} - -void -e_destination_touchv (EDestination **destv) -{ - int i; - - g_return_if_fail (destv != NULL); - - for (i = 0; destv[i] != NULL; ++i) { - e_destination_touch (destv[i]); - } -} diff --git a/addressbook/backend/ebook/e-vcard.c b/addressbook/backend/ebook/e-vcard.c deleted file mode 100644 index 5207d0fefe..0000000000 --- a/addressbook/backend/ebook/e-vcard.c +++ /dev/null @@ -1,1383 +0,0 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */ -/* e-vcard.c - * - * Copyright (C) 2003 Ximian, Inc. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of version 2 of the GNU General Public - * License as published by the Free Software Foundation. - * - * 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., 59 Temple Place - Suite 330, - * Boston, MA 02111-1307, USA. - * - * Author: Chris Toshok (toshok@ximian.com) - */ - -#include <glib.h> -#include <stdio.h> -#include <string.h> -#include <ctype.h> -#include "e-vcard.h" - -#define CRLF "\r\n" - -typedef enum { - EVC_ENCODING_RAW, /* no encoding */ - EVC_ENCODING_BASE64, /* base64 */ - EVC_ENCODING_QP /* quoted-printable */ -} EVCardEncoding; - -struct _EVCardPrivate { - GList *attributes; -}; - -struct _EVCardAttribute { - char *group; - char *name; - GList *params; /* EVCardParam */ - GList *values; - GList *decoded_values; - EVCardEncoding encoding; - gboolean encoding_set; -}; - -struct _EVCardAttributeParam { - char *name; - GList *values; /* GList of char*'s*/ -}; - -static GObjectClass *parent_class; - -static void _evc_base64_init(void); -static size_t _evc_base64_encode_step(unsigned char *in, size_t len, gboolean break_lines, unsigned char *out, int *state, int *save); -static size_t _evc_base64_decode_step(unsigned char *in, size_t len, unsigned char *out, int *state, unsigned int *save); -size_t _evc_base64_decode_simple (char *data, size_t len); -char *_evc_base64_encode_simple (const char *data, size_t len); - -static void -e_vcard_dispose (GObject *object) -{ - EVCard *evc = E_VCARD (object); - - if (!evc->priv) - return; - - g_list_foreach (evc->priv->attributes, (GFunc)e_vcard_attribute_free, NULL); - g_list_free (evc->priv->attributes); - - g_free (evc->priv); - evc->priv = NULL; - - if (G_OBJECT_CLASS (parent_class)->dispose) - G_OBJECT_CLASS (parent_class)->dispose (object); -} - -static void -e_vcard_class_init (EVCardClass *klass) -{ - GObjectClass *object_class; - - object_class = G_OBJECT_CLASS(klass); - - parent_class = g_type_class_ref (G_TYPE_OBJECT); - - object_class->dispose = e_vcard_dispose; - - _evc_base64_init(); -} - -static void -e_vcard_init (EVCard *evc) -{ - evc->priv = g_new0 (EVCardPrivate, 1); -} - -GType -e_vcard_get_type (void) -{ - static GType vcard_type = 0; - - if (!vcard_type) { - static const GTypeInfo vcard_info = { - sizeof (EVCardClass), - NULL, /* base_init */ - NULL, /* base_finalize */ - (GClassInitFunc) e_vcard_class_init, - NULL, /* class_finalize */ - NULL, /* class_data */ - sizeof (EVCard), - 0, /* n_preallocs */ - (GInstanceInitFunc) e_vcard_init, - }; - - vcard_type = g_type_register_static (G_TYPE_OBJECT, "EVCard", &vcard_info, 0); - } - - return vcard_type; -} - - - -static char* -fold_lines (char *buf) -{ - GString *str = g_string_new (""); - char *p = buf; - char *next, *next2; - - /* we're pretty liberal with line folding here. We handle - lines folded with \r\n<WS>... and \n\r<WS>... and - \n<WS>... We also turn single \r's and \n's not followed by - WS into \r\n's. */ - while (*p) { - if (*p == '\r' || *p == '\n') { - next = g_utf8_next_char (p); - if (*next == '\n' || *next == '\r') { - next2 = g_utf8_next_char (next); - if (*next2 == ' ' || *next2 == '\t') { - p = g_utf8_next_char (next2); - } - else { - str = g_string_append (str, CRLF); - p = g_utf8_next_char (next); - } - } - else if (*next == ' ' || *next == '\t') { - p = g_utf8_next_char (next); - } - else { - str = g_string_append (str, CRLF); - p = g_utf8_next_char (p); - } - } - else { - str = g_string_append_unichar (str, g_utf8_get_char (p)); - p = g_utf8_next_char (p); - } - } - - g_free (buf); - - return g_string_free (str, FALSE); -} - -/* skip forward until we hit the CRLF, or \0 */ -static void -skip_to_next_line (char **p) -{ - char *lp; - lp = *p; - - while (*lp != '\r' && *lp != '\0') - lp = g_utf8_next_char (lp); - - if (*lp == '\r') { - lp = g_utf8_next_char (lp); /* \n */ - lp = g_utf8_next_char (lp); /* start of the next line */ - } - - *p = lp; -} - -/* skip forward until we hit a character in @s, CRLF, or \0 */ -static void -skip_until (char **p, char *s) -{ - /* XXX write me plz k thx */ - g_assert_not_reached(); -} - -static void -read_attribute_value (EVCardAttribute *attr, char **p, gboolean quoted_printable) -{ - char *lp = *p; - GString *str; - - /* read in the value */ - str = g_string_new (""); - while (*lp != '\r' && *lp != '\0') { - if (*lp == '=' && quoted_printable) { - char a, b; - if ((a = *(++lp)) == '\0') break; - if ((b = *(++lp)) == '\0') break; - if (a == '\r' && b == '\n') { - /* it was a = at the end of the line, - * just ignore this and continue - * parsing on the next line. yay for - * 2 kinds of line folding - */ - } - else if (isalnum(a) && isalnum (b)) { - char c; - - a = tolower (a); - b = tolower (b); - - c = (((a>='a'?a-'a'+10:a-'0')&0x0f) << 4) - | ((b>='a'?b-'a'+10:b-'0')&0x0f); - - str = g_string_append_c (str, c); - } - /* silently consume malformed input, and - continue parsing */ - lp++; - } - else if (*lp == '\\') { - /* convert back to the non-escaped version of - the characters */ - lp = g_utf8_next_char(lp); - if (*lp == '\0') { - str = g_string_append_c (str, '\\'); - break; - } - switch (*lp) { - case 'n': str = g_string_append_c (str, '\n'); break; - case 'r': str = g_string_append_c (str, '\r'); break; - case ';': str = g_string_append_c (str, ';'); break; - case ',': str = g_string_append_c (str, ','); break; - case '\\': str = g_string_append_c (str, '\\'); break; - default: - g_warning ("invalid escape, passing it through"); - str = g_string_append_c (str, '\\'); - str = g_string_append_unichar (str, g_utf8_get_char(lp)); - break; - } - lp = g_utf8_next_char(lp); - } - else if (*lp == ';') { - e_vcard_attribute_add_value (attr, str->str); - g_string_assign (str, ""); - lp = g_utf8_next_char(lp); - } - else { - str = g_string_append_unichar (str, g_utf8_get_char (lp)); - lp = g_utf8_next_char(lp); - } - } - if (str) { - e_vcard_attribute_add_value (attr, str->str); - g_string_free (str, TRUE); - } - - if (*lp == '\r') { - lp = g_utf8_next_char (lp); /* \n */ - lp = g_utf8_next_char (lp); /* start of the next line */ - } - - *p = lp; -} - -static void -read_attribute_params (EVCardAttribute *attr, char **p, gboolean *quoted_printable) -{ - char *lp = *p; - GString *str; - EVCardAttributeParam *param = NULL; - - str = g_string_new (""); - while (*lp != '\0') { - /* accumulate until we hit the '=' or ';'. If we hit - * a '=' the string contains the parameter name. if - * we hit a ';' the string contains the parameter - * value and the name is either ENCODING (if value == - * QUOTED-PRINTABLE) or TYPE (in any other case.) - */ - if (*lp == '=') { - if (str->len > 0) { - param = e_vcard_attribute_param_new (str->str); - g_string_assign (str, ""); - lp = g_utf8_next_char (lp); - } - else { - skip_until (&lp, ":;"); - if (*lp == '\r') { - lp = g_utf8_next_char (lp); /* \n */ - lp = g_utf8_next_char (lp); /* start of the next line */ - break; - } - else if (*lp == ';') - lp = g_utf8_next_char (lp); - } - } - else if (*lp == ';' || *lp == ':' || *lp == ',') { - gboolean colon = (*lp == ':'); - gboolean comma = (*lp == ','); - - if (param) { - if (str->len > 0) { - e_vcard_attribute_param_add_value (param, str->str); - g_string_assign (str, ""); - if (!colon) - lp = g_utf8_next_char (lp); - } - else { - /* we've got a parameter of the form: - * PARAM=(.*,)?[:;] - * so what we do depends on if there are already values - * for the parameter. If there are, we just finish - * this parameter and skip past the offending character - * (unless it's the ':'). If there aren't values, we free - * the parameter then skip past the character. - */ - if (!param->values) { - e_vcard_attribute_param_free (param); - param = NULL; - } - } - - if (param - && !g_ascii_strcasecmp (param->name, "encoding") - && !g_ascii_strcasecmp (param->values->data, "quoted-printable")) { - *quoted_printable = TRUE; - e_vcard_attribute_param_free (param); - param = NULL; - } - } - else { - if (str->len > 0) { - char *param_name; - if (!g_ascii_strcasecmp (str->str, - "quoted-printable")) { - param_name = NULL; - *quoted_printable = TRUE; - } - else { - param_name = "TYPE"; - } - - if (param_name) { - param = e_vcard_attribute_param_new (param_name); - e_vcard_attribute_param_add_value (param, str->str); - } - g_string_assign (str, ""); - if (!colon) - lp = g_utf8_next_char (lp); - } - else { - /* XXX more here */ - g_assert_not_reached (); - } - } - if (param && !comma) { - e_vcard_attribute_add_param (attr, param); - param = NULL; - } - if (colon) - break; - } - else if (g_unichar_isalnum (g_utf8_get_char (lp)) || *lp == '-' || *lp == '_') { - str = g_string_append_unichar (str, g_utf8_get_char (lp)); - lp = g_utf8_next_char (lp); - } - else { - g_warning ("invalid character found in parameter spec"); - g_string_assign (str, ""); - skip_until (&lp, ":;"); - } - } - - if (str) - g_string_free (str, TRUE); - - *p = lp; -} - -/* reads an entire attribute from the input buffer, leaving p pointing - at the start of the next line (past the \r\n) */ -static EVCardAttribute* -read_attribute (char **p) -{ - char *attr_group = NULL; - char *attr_name = NULL; - EVCardAttribute *attr = NULL; - GString *str; - char *lp = *p; - gboolean is_qp = FALSE; - - /* first read in the group/name */ - str = g_string_new (""); - while (*lp != '\r' && *lp != '\0') { - if (*lp == ':' || *lp == ';') { - if (str->len != 0) { - /* we've got a name, break out to the value/attribute parsing */ - attr_name = g_string_free (str, FALSE); - break; - } - else { - /* a line of the form: - * (group.)?[:;] - * - * since we don't have an attribute - * name, skip to the end of the line - * and try again. - */ - g_string_free (str, TRUE); - *p = lp; - skip_to_next_line(p); - goto lose; - } - } - else if (*lp == '.') { - if (attr_group) { - g_warning ("extra `.' in attribute specification. ignoring extra group `%s'", - str->str); - g_string_free (str, TRUE); - str = g_string_new (""); - } - if (str->len != 0) { - attr_group = g_string_free (str, FALSE); - str = g_string_new (""); - } - } - else if (g_unichar_isalnum (g_utf8_get_char (lp)) || *lp == '-' || *lp == '_') { - str = g_string_append_unichar (str, g_utf8_get_char (lp)); - } - else { - g_warning ("invalid character found in attribute group/name"); - g_string_free (str, TRUE); - *p = lp; - skip_to_next_line(p); - goto lose; - } - - lp = g_utf8_next_char(lp); - } - - if (!attr_name) { - skip_to_next_line (p); - goto lose; - } - - attr = e_vcard_attribute_new (attr_group, attr_name); - g_free (attr_group); - g_free (attr_name); - - if (*lp == ';') { - /* skip past the ';' */ - lp = g_utf8_next_char(lp); - read_attribute_params (attr, &lp, &is_qp); - } - if (*lp == ':') { - /* skip past the ':' */ - lp = g_utf8_next_char(lp); - read_attribute_value (attr, &lp, is_qp); - } - - *p = lp; - - if (!attr->values) - goto lose; - - return attr; - lose: - if (attr) - e_vcard_attribute_free (attr); - return NULL; -} - -/* we try to be as forgiving as we possibly can here - this isn't a - * validator. Almost nothing is considered a fatal error. We always - * try to return *something*. - */ -static void -parse (EVCard *evc, const char *str) -{ - char *buf = g_strdup (str); - char *p, *end; - EVCardAttribute *attr; - - /* first validate the string is valid utf8 */ - if (!g_utf8_validate (buf, -1, (const char **)&end)) { - /* if the string isn't valid, we parse as much as we can from it */ - g_warning ("invalid utf8 passed to EVCard. Limping along."); - *end = '\0'; - } - -#if DEBUG_FOLDING - printf ("BEFORE FOLDING:\n"); - printf (str); -#endif - buf = fold_lines (buf); - -#if DEBUG_FOLDING - printf ("\n\nAFTER FOLDING:\n"); - printf (buf); -#endif - p = buf; - - attr = read_attribute (&p); - if (!attr || attr->group || g_ascii_strcasecmp (attr->name, "begin")) { - g_warning ("vcard began without a BEGIN:VCARD\n"); - } - if (attr) - e_vcard_attribute_free (attr); - - while (*p) { - EVCardAttribute *next_attr = read_attribute (&p); - - if (next_attr) { - if (g_ascii_strcasecmp (next_attr->name, "end")) - e_vcard_add_attribute (evc, next_attr); - attr = next_attr; - } - } - - if (!attr || attr->group || g_ascii_strcasecmp (attr->name, "end")) { - g_warning ("vcard ended without END:VCARD\n"); - } - - if (attr && !g_ascii_strcasecmp (attr->name, "end")) - e_vcard_attribute_free (attr); - - g_free (buf); -} - -static char* -escape_string (const char *s) -{ - GString *str = g_string_new (""); - const char *p; - - /* Escape a string as described in RFC2426, section 5 */ - for (p = s; p && *p; p++) { - switch (*p) { - case '\n': - str = g_string_append (str, "\\n"); - break; - case '\r': - if (*(p+1) == '\n') - p++; - str = g_string_append (str, "\\n"); - break; - case ';': - str = g_string_append (str, "\\;"); - break; - case ',': - str = g_string_append (str, "\\,"); - break; - case '\\': - str = g_string_append (str, "\\\\"); - break; - default: - str = g_string_append_c (str, *p); - break; - } - } - - return g_string_free (str, FALSE); -} - -#if notyet -static char* -unescape_string (const char *s) -{ - GString *str = g_string_new (""); - const char *p; - - /* Unescape a string as described in RFC2426, section 5 */ - for (p = s; *p; p++) { - if (*p == '\\') { - p++; - if (*p == '\0') { - str = g_string_append_c (str, '\\'); - break; - } - switch (*p) { - case 'n': str = g_string_append_c (str, '\n'); break; - case 'r': str = g_string_append_c (str, '\r'); break; - case ';': str = g_string_append_c (str, ';'); break; - case ',': str = g_string_append_c (str, ','); break; - case '\\': str = g_string_append_c (str, '\\'); break; - default: - g_warning ("invalid escape, passing it through"); - str = g_string_append_c (str, '\\'); - str = g_string_append_unichar (str, g_utf8_get_char(p)); - break; - } - } - } - - return g_string_free (str, FALSE); -} -#endif - -void -e_vcard_construct (EVCard *evc, const char *str) -{ - if (*str) - parse (evc, str); -} - -EVCard * -e_vcard_new () -{ - return e_vcard_new_from_string (""); -} - -EVCard * -e_vcard_new_from_string (const char *str) -{ - EVCard *evc; - - g_return_val_if_fail (str, NULL); - - evc = g_object_new (E_TYPE_VCARD, NULL); - - e_vcard_construct (evc, str); - - return evc; -} - -static char* -e_vcard_to_string_vcard_21 (EVCard *evc) -{ - g_warning ("need to implement e_vcard_to_string_vcard_21"); - return g_strdup (""); -} - -static char* -e_vcard_to_string_vcard_30 (EVCard *evc) -{ - GList *l; - GList *v; - - GString *str = g_string_new (""); - - str = g_string_append (str, "BEGIN:vCard" CRLF); - - for (l = evc->priv->attributes; l; l = l->next) { - GList *p; - EVCardAttribute *attr = l->data; - GString *attr_str = g_string_new (""); - int l; - - /* From rfc2425, 5.8.2 - * - * contentline = [group "."] name *(";" param) ":" value CRLF - */ - - if (attr->group) { - attr_str = g_string_append (attr_str, attr->group); - attr_str = g_string_append_c (attr_str, '.'); - } - attr_str = g_string_append (attr_str, attr->name); - - /* handle the parameters */ - for (p = attr->params; p; p = p->next) { - EVCardAttributeParam *param = p->data; - /* 5.8.2: - * param = param-name "=" param-value *("," param-value) - */ - attr_str = g_string_append_c (attr_str, ';'); - attr_str = g_string_append (attr_str, param->name); - if (param->values) { - attr_str = g_string_append_c (attr_str, '='); - for (v = param->values; v; v = v->next) { - char *value = v->data; - attr_str = g_string_append (attr_str, value); - if (v->next) - attr_str = g_string_append_c (attr_str, ','); - } - } - } - - attr_str = g_string_append_c (attr_str, ':'); - - for (v = attr->values; v; v = v->next) { - char *value = v->data; - char *escaped_value = NULL; - - escaped_value = escape_string (value); - - attr_str = g_string_append (attr_str, escaped_value); - if (v->next) - attr_str = g_string_append_c (attr_str, ';'); - - g_free (escaped_value); - } - - /* 5.8.2: - * When generating a content line, lines longer than 75 - * characters SHOULD be folded - */ - l = 0; - do { - if (attr_str->len - l > 75) { - l += 75; - attr_str = g_string_insert_len (attr_str, l, CRLF " ", sizeof (CRLF " ") - 1); - } - else - break; - } while (l < attr_str->len); - - attr_str = g_string_append (attr_str, CRLF); - - str = g_string_append (str, attr_str->str); - g_string_free (attr_str, TRUE); - } - - str = g_string_append (str, "END:vCard"); - - return g_string_free (str, FALSE); -} - -char* -e_vcard_to_string (EVCard *evc, EVCardFormat format) -{ - switch (format) { - case EVC_FORMAT_VCARD_21: - return e_vcard_to_string_vcard_21 (evc); - case EVC_FORMAT_VCARD_30: - return e_vcard_to_string_vcard_30 (evc); - default: - g_warning ("invalid format specifier passed to e_vcard_to_string"); - return g_strdup (""); - } -} - -void -e_vcard_dump_structure (EVCard *evc) -{ - GList *a; - GList *v; - int i; - - printf ("vCard\n"); - for (a = evc->priv->attributes; a; a = a->next) { - GList *p; - EVCardAttribute *attr = a->data; - printf ("+-- %s\n", attr->name); - if (attr->params) { - printf (" +- params=\n"); - - for (p = attr->params, i = 0; p; p = p->next, i++) { - EVCardAttributeParam *param = p->data; - printf (" | [%d] = %s", i,param->name); - printf ("("); - for (v = param->values; v; v = v->next) { - char *value = escape_string ((char*)v->data); - printf ("%s", value); - if (v->next) - printf (","); - g_free (value); - } - - printf (")\n"); - } - } - printf (" +- values=\n"); - for (v = attr->values, i = 0; v; v = v->next, i++) { - printf (" [%d] = `%s'\n", i, (char*)v->data); - } - } -} - - -EVCardAttribute* -e_vcard_attribute_new (const char *attr_group, const char *attr_name) -{ - EVCardAttribute *attr = g_new0 (EVCardAttribute, 1); - - attr->group = g_strdup (attr_group); - attr->name = g_strdup (attr_name); - - return attr; -} - -void -e_vcard_attribute_free (EVCardAttribute *attr) -{ - g_free (attr->group); - g_free (attr->name); - - e_vcard_attribute_remove_values (attr); - - e_vcard_attribute_remove_params (attr); - - g_free (attr); -} - -EVCardAttribute* -e_vcard_attribute_copy (EVCardAttribute *attr) -{ - EVCardAttribute *a = e_vcard_attribute_new (e_vcard_attribute_get_group (attr), - e_vcard_attribute_get_name (attr)); - GList *p; - - for (p = attr->values; p; p = p->next) - e_vcard_attribute_add_value (a, p->data); - - for (p = attr->params; p; p = p->next) - e_vcard_attribute_add_param (a, e_vcard_attribute_param_copy (p->data)); - - return a; -} - -void -e_vcard_remove_attributes (EVCard *evc, const char *attr_group, const char *attr_name) -{ - GList *attr; - - attr = evc->priv->attributes; - while (attr) { - GList *next_attr; - EVCardAttribute *a = attr->data; - - next_attr = attr->next; - - if (((!attr_group && !a->group) || !g_ascii_strcasecmp (attr_group, a->group)) && - ((!attr_name && !a->name) || !g_ascii_strcasecmp (attr_name, a->name))) { - - /* matches, remove/delete the attribute */ - evc->priv->attributes = g_list_remove_link (evc->priv->attributes, attr); - - e_vcard_attribute_free (a); - } - - attr = next_attr; - } -} - -void -e_vcard_remove_attribute (EVCard *evc, EVCardAttribute *attr) -{ - evc->priv->attributes = g_list_remove (evc->priv->attributes, attr); - e_vcard_attribute_free (attr); -} - -void -e_vcard_add_attribute (EVCard *evc, EVCardAttribute *attr) -{ - evc->priv->attributes = g_list_append (evc->priv->attributes, attr); -} - -void -e_vcard_add_attribute_with_value (EVCard *evcard, - EVCardAttribute *attr, const char *value) -{ - e_vcard_attribute_add_value (attr, value); - - e_vcard_add_attribute (evcard, attr); -} - -void -e_vcard_add_attribute_with_values (EVCard *evcard, EVCardAttribute *attr, ...) -{ - va_list ap; - char *v; - - va_start (ap, attr); - - while ((v = va_arg (ap, char*))) { - e_vcard_attribute_add_value (attr, v); - } - - va_end (ap); - - e_vcard_add_attribute (evcard, attr); -} - -void -e_vcard_attribute_add_value (EVCardAttribute *attr, const char *value) -{ - attr->values = g_list_append (attr->values, g_strdup (value)); -} - -void -e_vcard_attribute_add_value_decoded (EVCardAttribute *attr, const char *value, int len) -{ - switch (attr->encoding) { - case EVC_ENCODING_RAW: - g_warning ("can't add_value_decoded with an attribute using RAW encoding. you must set the ENCODING parameter first"); - break; - case EVC_ENCODING_BASE64: { - char *b64_data = _evc_base64_encode_simple (value, len); - GString *decoded = g_string_new_len (value, len); - - /* make sure the decoded list is up to date */ - e_vcard_attribute_get_values_decoded (attr); - - printf ("base64 encoded value: %s\n", b64_data); - printf ("original length: %d\n", len); - - attr->values = g_list_append (attr->values, b64_data); - attr->decoded_values = g_list_append (attr->decoded_values, decoded); - break; - } - case EVC_ENCODING_QP: - g_warning ("need to implement quoted printable decoding"); - break; - } -} - -void -e_vcard_attribute_add_values (EVCardAttribute *attr, - ...) -{ - va_list ap; - char *v; - - va_start (ap, attr); - - while ((v = va_arg (ap, char*))) { - e_vcard_attribute_add_value (attr, v); - } - - va_end (ap); -} - -static void -free_gstring (GString *str) -{ - g_string_free (str, TRUE); -} - -void -e_vcard_attribute_remove_values (EVCardAttribute *attr) -{ - g_list_foreach (attr->values, (GFunc)g_free, NULL); - g_list_free (attr->values); - g_list_foreach (attr->decoded_values, (GFunc)free_gstring, NULL); - g_list_free (attr->decoded_values); - attr->values = NULL; -} - -void -e_vcard_attribute_remove_params (EVCardAttribute *attr) -{ - g_list_foreach (attr->params, (GFunc)e_vcard_attribute_param_free, NULL); - g_list_free (attr->params); - attr->params = NULL; -} - -EVCardAttributeParam* -e_vcard_attribute_param_new (const char *name) -{ - EVCardAttributeParam *param = g_new0 (EVCardAttributeParam, 1); - param->name = g_strdup (name); - - return param; -} - -void -e_vcard_attribute_param_free (EVCardAttributeParam *param) -{ - g_free (param->name); - - e_vcard_attribute_param_remove_values (param); - - g_free (param); -} - -EVCardAttributeParam* -e_vcard_attribute_param_copy (EVCardAttributeParam *param) -{ - EVCardAttributeParam *p = e_vcard_attribute_param_new (e_vcard_attribute_param_get_name (param)); - GList *l; - - for (l = param->values; l; l = l->next) { - e_vcard_attribute_param_add_value (p, l->data); - } - - return p; -} - -void -e_vcard_attribute_add_param (EVCardAttribute *attr, - EVCardAttributeParam *param) -{ - attr->params = g_list_append (attr->params, param); - - /* we handle our special encoding stuff here */ - - if (!g_ascii_strcasecmp (param->name, EVC_ENCODING)) { - if (attr->encoding_set) { - g_warning ("ENCODING specified twice"); - return; - } - - if (param->values && param->values->data) { - if (!g_ascii_strcasecmp ((char*)param->values->data, "b")) - attr->encoding = EVC_ENCODING_BASE64; - else if (!g_ascii_strcasecmp ((char*)param->values->data, EVC_QUOTEDPRINTABLE)) - attr->encoding = EVC_ENCODING_QP; - else { - g_warning ("Unknown value `%s' for ENCODING parameter. values will be treated as raw", - (char*)param->values->data); - } - - attr->encoding_set = TRUE; - } - else { - g_warning ("ENCODING parameter added with no value"); - } - } -} - -void -e_vcard_attribute_param_add_value (EVCardAttributeParam *param, - const char *value) -{ - param->values = g_list_append (param->values, g_strdup (value)); -} - -void -e_vcard_attribute_param_add_values (EVCardAttributeParam *param, - ...) -{ - va_list ap; - char *v; - - va_start (ap, param); - - while ((v = va_arg (ap, char*))) { - e_vcard_attribute_param_add_value (param, v); - } - - va_end (ap); -} - -void -e_vcard_attribute_add_param_with_value (EVCardAttribute *attr, - EVCardAttributeParam *param, const char *value) -{ - e_vcard_attribute_param_add_value (param, value); - - e_vcard_attribute_add_param (attr, param); -} - -void -e_vcard_attribute_add_param_with_values (EVCardAttribute *attr, - EVCardAttributeParam *param, ...) -{ - va_list ap; - char *v; - - va_start (ap, param); - - while ((v = va_arg (ap, char*))) { - e_vcard_attribute_param_add_value (param, v); - } - - va_end (ap); - - e_vcard_attribute_add_param (attr, param); -} - -void -e_vcard_attribute_param_remove_values (EVCardAttributeParam *param) -{ - g_list_foreach (param->values, (GFunc)g_free, NULL); - g_list_free (param->values); - param->values = NULL; -} - -GList* -e_vcard_get_attributes (EVCard *evcard) -{ - return evcard->priv->attributes; -} - -const char* -e_vcard_attribute_get_group (EVCardAttribute *attr) -{ - return attr->group; -} - -const char* -e_vcard_attribute_get_name (EVCardAttribute *attr) -{ - return attr->name; -} - -GList* -e_vcard_attribute_get_values (EVCardAttribute *attr) -{ - return attr->values; -} - -GList* -e_vcard_attribute_get_values_decoded (EVCardAttribute *attr) -{ - if (!attr->decoded_values) { - GList *l; - switch (attr->encoding) { - case EVC_ENCODING_RAW: - for (l = attr->values; l; l = l->next) - attr->decoded_values = g_list_append (attr->decoded_values, g_string_new ((char*)l->data)); - break; - case EVC_ENCODING_BASE64: - for (l = attr->values; l; l = l->next) { - char *decoded = g_strdup ((char*)l->data); - int len = _evc_base64_decode_simple (decoded, strlen (decoded)); - attr->decoded_values = g_list_append (attr->decoded_values, g_string_new_len (decoded, len)); - g_free (decoded); - } - break; - case EVC_ENCODING_QP: - g_warning ("need to implement quoted printable decoding"); - break; - } - } - - return attr->decoded_values; -} - -GList* -e_vcard_attribute_get_params (EVCardAttribute *attr) -{ - return attr->params; -} - -const char* -e_vcard_attribute_param_get_name (EVCardAttributeParam *param) -{ - return param->name; -} - -GList* -e_vcard_attribute_param_get_values (EVCardAttributeParam *param) -{ - return param->values; -} - - - -/* encoding/decoding stuff ripped from camel-mime-utils.c */ - -static char *_evc_base64_alphabet = -"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"; - -static unsigned char _evc_base64_rank[256]; - -static void -_evc_base64_init(void) -{ - int i; - - memset(_evc_base64_rank, 0xff, sizeof(_evc_base64_rank)); - for (i=0;i<64;i++) { - _evc_base64_rank[(unsigned int)_evc_base64_alphabet[i]] = i; - } - _evc_base64_rank['='] = 0; -} - -/* call this when finished encoding everything, to - flush off the last little bit */ -static size_t -_evc_base64_encode_close(unsigned char *in, size_t inlen, gboolean break_lines, unsigned char *out, int *state, int *save) -{ - int c1, c2; - unsigned char *outptr = out; - - if (inlen>0) - outptr += _evc_base64_encode_step(in, inlen, break_lines, outptr, state, save); - - c1 = ((unsigned char *)save)[1]; - c2 = ((unsigned char *)save)[2]; - -#if 0 - d(printf("mode = %d\nc1 = %c\nc2 = %c\n", - (int)((char *)save)[0], - (int)((char *)save)[1], - (int)((char *)save)[2])); -#endif - - switch (((char *)save)[0]) { - case 2: - outptr[2] = _evc_base64_alphabet[ ( (c2 &0x0f) << 2 ) ]; - g_assert(outptr[2] != 0); - goto skip; - case 1: - outptr[2] = '='; - skip: - outptr[0] = _evc_base64_alphabet[ c1 >> 2 ]; - outptr[1] = _evc_base64_alphabet[ c2 >> 4 | ( (c1&0x3) << 4 )]; - outptr[3] = '='; - outptr += 4; - break; - } - if (break_lines) - *outptr++ = '\n'; - - *save = 0; - *state = 0; - - return outptr-out; -} - -/* - performs an 'encode step', only encodes blocks of 3 characters to the - output at a time, saves left-over state in state and save (initialise to - 0 on first invocation). -*/ -static size_t -_evc_base64_encode_step(unsigned char *in, size_t len, gboolean break_lines, unsigned char *out, int *state, int *save) -{ - register unsigned char *inptr, *outptr; - - if (len<=0) - return 0; - - inptr = in; - outptr = out; - -#if 0 - d(printf("we have %d chars, and %d saved chars\n", len, ((char *)save)[0])); -#endif - - if (len + ((char *)save)[0] > 2) { - unsigned char *inend = in+len-2; - register int c1, c2, c3; - register int already; - - already = *state; - - switch (((char *)save)[0]) { - case 1: c1 = ((unsigned char *)save)[1]; goto skip1; - case 2: c1 = ((unsigned char *)save)[1]; - c2 = ((unsigned char *)save)[2]; goto skip2; - } - - /* yes, we jump into the loop, no i'm not going to change it, it's beautiful! */ - while (inptr < inend) { - c1 = *inptr++; - skip1: - c2 = *inptr++; - skip2: - c3 = *inptr++; - *outptr++ = _evc_base64_alphabet[ c1 >> 2 ]; - *outptr++ = _evc_base64_alphabet[ c2 >> 4 | ( (c1&0x3) << 4 ) ]; - *outptr++ = _evc_base64_alphabet[ ( (c2 &0x0f) << 2 ) | (c3 >> 6) ]; - *outptr++ = _evc_base64_alphabet[ c3 & 0x3f ]; - /* this is a bit ugly ... */ - if (break_lines && (++already)>=19) { - *outptr++='\n'; - already = 0; - } - } - - ((char *)save)[0] = 0; - len = 2-(inptr-inend); - *state = already; - } - -#if 0 - d(printf("state = %d, len = %d\n", - (int)((char *)save)[0], - len)); -#endif - - if (len>0) { - register char *saveout; - - /* points to the slot for the next char to save */ - saveout = & (((char *)save)[1]) + ((char *)save)[0]; - - /* len can only be 0 1 or 2 */ - switch(len) { - case 2: *saveout++ = *inptr++; - case 1: *saveout++ = *inptr++; - } - ((char *)save)[0]+=len; - } - -#if 0 - d(printf("mode = %d\nc1 = %c\nc2 = %c\n", - (int)((char *)save)[0], - (int)((char *)save)[1], - (int)((char *)save)[2])); -#endif - - return outptr-out; -} - - -/** - * base64_decode_step: decode a chunk of base64 encoded data - * @in: input stream - * @len: max length of data to decode - * @out: output stream - * @state: holds the number of bits that are stored in @save - * @save: leftover bits that have not yet been decoded - * - * Decodes a chunk of base64 encoded data - **/ -static size_t -_evc_base64_decode_step(unsigned char *in, size_t len, unsigned char *out, int *state, unsigned int *save) -{ - register unsigned char *inptr, *outptr; - unsigned char *inend, c; - register unsigned int v; - int i; - - inend = in+len; - outptr = out; - - /* convert 4 base64 bytes to 3 normal bytes */ - v=*save; - i=*state; - inptr = in; - while (inptr<inend) { - c = _evc_base64_rank[*inptr++]; - if (c != 0xff) { - v = (v<<6) | c; - i++; - if (i==4) { - *outptr++ = v>>16; - *outptr++ = v>>8; - *outptr++ = v; - i=0; - } - } - } - - *save = v; - *state = i; - - /* quick scan back for '=' on the end somewhere */ - /* fortunately we can drop 1 output char for each trailing = (upto 2) */ - i=2; - while (inptr>in && i) { - inptr--; - if (_evc_base64_rank[*inptr] != 0xff) { - if (*inptr == '=' && outptr>out) - outptr--; - i--; - } - } - - /* if i!= 0 then there is a truncation error! */ - return outptr-out; -} - -char * -_evc_base64_encode_simple (const char *data, size_t len) -{ - unsigned char *out; - int state = 0, outlen; - unsigned int save = 0; - - out = g_malloc (len * 4 / 3 + 5); - outlen = _evc_base64_encode_close ((unsigned char *)data, len, FALSE, - out, &state, &save); - out[outlen] = '\0'; - return (char *)out; -} - -size_t -_evc_base64_decode_simple (char *data, size_t len) -{ - int state = 0; - unsigned int save = 0; - - return _evc_base64_decode_step ((unsigned char *)data, len, - (unsigned char *)data, &state, &save); -} diff --git a/addressbook/backend/ebook/e-vcard.h b/addressbook/backend/ebook/e-vcard.h deleted file mode 100644 index cedc2b4c70..0000000000 --- a/addressbook/backend/ebook/e-vcard.h +++ /dev/null @@ -1,165 +0,0 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */ -/* e-vcard.h - * - * Copyright (C) 2003 Ximian, Inc. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of version 2 of the GNU General Public - * License as published by the Free Software Foundation. - * - * 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., 59 Temple Place - Suite 330, - * Boston, MA 02111-1307, USA. - * - * Author: Chris Toshok (toshok@ximian.com) - */ - -#ifndef _EVCARD_H -#define _EVCARD_H - -#include <glib.h> -#include <glib-object.h> - -#define EVC_ADR "ADR" -#define EVC_BDAY "BDAY" -#define EVC_CALURI "CALURI" -#define EVC_CATEGORIES "CATEGORIES" -#define EVC_EMAIL "EMAIL" -#define EVC_ENCODING "ENCODING" -#define EVC_FBURL "FBURL" -#define EVC_FN "FN" -#define EVC_ICSCALENDAR "ICSCALENDAR" /* XXX should this be X-EVOLUTION-ICSCALENDAR? */ -#define EVC_LABEL "LABEL" -#define EVC_LOGO "LOGO" -#define EVC_MAILER "MAILER" -#define EVC_NICKNAME "NICKNAME" -#define EVC_N "N" -#define EVC_NOTE "NOTE" -#define EVC_ORG "ORG" -#define EVC_PHOTO "PHOTO" -#define EVC_PRODID "PRODID" -#define EVC_QUOTEDPRINTABLE "QUOTED-PRINTABLE" -#define EVC_REV "REV" -#define EVC_ROLE "ROLE" -#define EVC_TEL "TEL" -#define EVC_TITLE "TITLE" -#define EVC_TYPE "TYPE" -#define EVC_UID "UID" -#define EVC_URL "URL" -#define EVC_VALUE "VALUE" -#define EVC_VERSION "VERSION" - -#define EVC_X_AIM "X-AIM" -#define EVC_X_ANNIVERSARY "X-EVOLUTION-ANNIVERSARY" -#define EVC_X_ASSISTANT "X-EVOLUTION-ASSISTANT" -#define EVC_X_BIRTHDAY "X-EVOLUTION-BIRTHDAY" -#define EVC_X_BLOG_URL "X-EVOLUTION-BLOG-URL" -#define EVC_X_FILE_AS "X-EVOLUTION-FILE-AS" -#define EVC_X_ICQ "X-ICQ" -#define EVC_X_JABBER "X-JABBER" -#define EVC_X_LIST_SHOW_ADDRESSES "X-EVOLUTION-LIST-SHOW_ADDRESSES" -#define EVC_X_LIST "X-EVOLUTION-LIST" -#define EVC_X_MANAGER "X-EVOLUTION-MANAGER" -#define EVC_X_MSN "X-MSN" -#define EVC_X_SPOUSE "X-EVOLUTION-SPOUSE" -#define EVC_X_WANTS_HTML "X-MOZILLA-HTML" -#define EVC_X_WANTS_HTML "X-MOZILLA-HTML" -#define EVC_X_YAHOO "X-YAHOO" - -typedef enum { - EVC_FORMAT_VCARD_21, - EVC_FORMAT_VCARD_30 -} EVCardFormat; - -#define E_TYPE_VCARD (e_vcard_get_type ()) -#define E_VCARD(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), E_TYPE_VCARD, EVCard)) -#define E_VCARD_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), E_TYPE_VCARD, EVCardClass)) -#define E_IS_VCARD(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), E_TYPE_VCARD)) -#define E_IS_VCARD_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), E_TYPE_VCARD)) -#define E_VCARD_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), E_TYPE_VCARD, EVCardClass)) - -typedef struct _EVCard EVCard; -typedef struct _EVCardClass EVCardClass; -typedef struct _EVCardPrivate EVCardPrivate; -typedef struct _EVCardAttribute EVCardAttribute; -typedef struct _EVCardAttributeParam EVCardAttributeParam; - -struct _EVCard { - GObject parent; - - EVCardPrivate *priv; -}; - -struct _EVCardClass { - GObjectClass parent_class; - - /* Padding for future expansion */ - void (*_ebook_reserved0) (void); - void (*_ebook_reserved1) (void); - void (*_ebook_reserved2) (void); - void (*_ebook_reserved3) (void); - void (*_ebook_reserved4) (void); -}; - -GType e_vcard_get_type (void); - -void e_vcard_construct (EVCard *evc, const char *str); -EVCard* e_vcard_new (void); -EVCard* e_vcard_new_from_string (const char *str); - -char* e_vcard_to_string (EVCard *evc, EVCardFormat format); - -/* mostly for debugging */ -void e_vcard_dump_structure (EVCard *evc); - - -/* attributes */ -EVCardAttribute *e_vcard_attribute_new (const char *attr_group, const char *attr_name); -void e_vcard_attribute_free (EVCardAttribute *attr); -EVCardAttribute *e_vcard_attribute_copy (EVCardAttribute *attr); -void e_vcard_remove_attributes (EVCard *evcard, const char *attr_group, const char *attr_name); -void e_vcard_remove_attribute (EVCard *evcard, EVCardAttribute *attr); -void e_vcard_add_attribute (EVCard *evcard, EVCardAttribute *attr); -void e_vcard_add_attribute_with_value (EVCard *evcard, EVCardAttribute *attr, const char *value); -void e_vcard_add_attribute_with_values (EVCard *evcard, EVCardAttribute *attr, ...); -void e_vcard_attribute_add_value (EVCardAttribute *attr, const char *value); -void e_vcard_attribute_add_value_decoded (EVCardAttribute *attr, const char *value, int len); -void e_vcard_attribute_add_values (EVCardAttribute *attr, ...); -void e_vcard_attribute_remove_values (EVCardAttribute *attr); -void e_vcard_attribute_remove_params (EVCardAttribute *attr); - -/* attribute parameters */ -EVCardAttributeParam* e_vcard_attribute_param_new (const char *param_name); -void e_vcard_attribute_param_free (EVCardAttributeParam *param); -EVCardAttributeParam* e_vcard_attribute_param_copy (EVCardAttributeParam *param); -void e_vcard_attribute_add_param (EVCardAttribute *attr, EVCardAttributeParam *param); -void e_vcard_attribute_add_param_with_value (EVCardAttribute *attr, - EVCardAttributeParam *param, const char *value); -void e_vcard_attribute_add_param_with_values (EVCardAttribute *attr, - EVCardAttributeParam *param, ...); - -void e_vcard_attribute_param_add_value (EVCardAttributeParam *param, - const char *value); -void e_vcard_attribute_param_add_values (EVCardAttributeParam *param, - ...); -void e_vcard_attribute_param_remove_values (EVCardAttributeParam *param); - -/* EVCard* accessors. nothing returned from these functions should be - freed by the caller. */ -GList* e_vcard_get_attributes (EVCard *evcard); -const char* e_vcard_attribute_get_group (EVCardAttribute *attr); -const char* e_vcard_attribute_get_name (EVCardAttribute *attr); -GList* e_vcard_attribute_get_values (EVCardAttribute *attr); /* GList elements are of type char* */ -GList* e_vcard_attribute_get_values_decoded (EVCardAttribute *attr); /* GList elements are of type GString* */ - -GList* e_vcard_attribute_get_params (EVCardAttribute *attr); -const char* e_vcard_attribute_param_get_name (EVCardAttributeParam *param); -GList* e_vcard_attribute_param_get_values (EVCardAttributeParam *param); - -#endif /* _EVCARD_H */ diff --git a/addressbook/backend/ebook/evolution-ldif-importer.c b/addressbook/backend/ebook/evolution-ldif-importer.c deleted file mode 100644 index 559e591fdb..0000000000 --- a/addressbook/backend/ebook/evolution-ldif-importer.c +++ /dev/null @@ -1,592 +0,0 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */ - -/* - * LDIF importer. LDIF is the file format of an exported Netscape - * addressbook. - * - * Framework copied from evolution-gnomecard-importer.c - * - * Michael M. Morrison (mmorrison@kqcorp.com) - * - * Multi-line value support, mailing list support, base64 support, and - * various fixups: Chris Toshok (toshok@ximian.com) - */ - -#include <config.h> -#include <stdio.h> -#include <ctype.h> -#include <string.h> - -#include <e-book.h> -#include <e-book-util.h> -#include <e-card-simple.h> -#include <e-destination.h> - -#include <libgnome/gnome-init.h> -#include <bonobo/bonobo-generic-factory.h> -#include <bonobo/bonobo-main.h> - -#include <importer/evolution-importer.h> -#include <importer/GNOME_Evolution_Importer.h> - -#define COMPONENT_FACTORY_IID "OAFIID:GNOME_Evolution_Addressbook_LDIF_ImporterFactory" -#define COMPONENT_IID "OAFIID:GNOME_Evolution_Addressbook_LDIF_Importer" - -static GHashTable *dn_card_hash; - -typedef struct { - char *filename; - GList *cardlist; - GList *iterator; - EBook *book; - gboolean ready; -} LDIFImporter; - -static struct { - char *ldif_attribute; - ECardSimpleField simple_field; -#define FLAG_ADDRESS 0x01 - int flags; -} -ldif_fields[] = { - { "cn", E_CARD_SIMPLE_FIELD_FULL_NAME }, - { "mail", E_CARD_SIMPLE_FIELD_EMAIL }, -#if 0 - { "givenname", E_CARD_SIMPLE_FIELD_GIVEN_NAME }, -#endif - { "sn", E_CARD_SIMPLE_FIELD_FAMILY_NAME }, - { "xmozillanickname", E_CARD_SIMPLE_FIELD_NICKNAME }, - { "o", E_CARD_SIMPLE_FIELD_ORG }, - { "locality", 0, FLAG_ADDRESS}, - { "st", 0, FLAG_ADDRESS }, - { "streetaddress", 0, FLAG_ADDRESS }, - { "title", E_CARD_SIMPLE_FIELD_TITLE }, - { "postalcode", 0, FLAG_ADDRESS }, - { "countryname", 0, FLAG_ADDRESS }, - { "telephonenumber", E_CARD_SIMPLE_FIELD_PHONE_BUSINESS}, - { "homephone", E_CARD_SIMPLE_FIELD_PHONE_HOME }, - { "facsimiletelephonenumber", E_CARD_SIMPLE_FIELD_PHONE_BUSINESS_FAX }, - { "ou", E_CARD_SIMPLE_FIELD_ORG_UNIT }, - { "pagerphone", E_CARD_SIMPLE_FIELD_PHONE_PAGER }, - { "cellphone", E_CARD_SIMPLE_FIELD_PHONE_MOBILE }, - { "homeurl", E_CARD_SIMPLE_FIELD_URL }, - { "description", E_CARD_SIMPLE_FIELD_NOTE }, - { "xmozillausehtmlmail", E_CARD_SIMPLE_FIELD_WANTS_HTML } -}; -static int num_ldif_fields = sizeof(ldif_fields) / sizeof (ldif_fields[0]); - -static unsigned char base64_rank[256] = { - 255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255, - 255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255, - 255,255,255,255,255,255,255,255,255,255,255, 62,255,255,255, 63, - 52, 53, 54, 55, 56, 57, 58, 59, 60, 61,255,255,255, 0,255,255, - 255, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, - 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25,255,255,255,255,255, - 255, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, - 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51,255,255,255,255,255, - 255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255, - 255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255, - 255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255, - 255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255, - 255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255, - 255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255, - 255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255, - 255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255, -}; - -/** - * base64_decode_step: decode a chunk of base64 encoded data - * @in: input stream - * @len: max length of data to decode - * @out: output stream - * @state: holds the number of bits that are stored in @save - * @save: leftover bits that have not yet been decoded - * - * Decodes a chunk of base64 encoded data - **/ -static int -base64_decode_step(unsigned char *in, int len, unsigned char *out, int *state, unsigned int *save) -{ - register unsigned char *inptr, *outptr; - unsigned char *inend, c; - register unsigned int v; - int i; - - inend = in+len; - outptr = out; - - /* convert 4 base64 bytes to 3 normal bytes */ - v=*save; - i=*state; - inptr = in; - while (inptr<inend) { - c = base64_rank[*inptr++]; - if (c != 0xff) { - v = (v<<6) | c; - i++; - if (i==4) { - *outptr++ = v>>16; - *outptr++ = v>>8; - *outptr++ = v; - i=0; - } - } - } - - *save = v; - *state = i; - - /* quick scan back for '=' on the end somewhere */ - /* fortunately we can drop 1 output char for each trailing = (upto 2) */ - i=2; - while (inptr>in && i) { - inptr--; - if (base64_rank[*inptr] != 0xff) { - if (*inptr == '=') - outptr--; - i--; - } - } - - /* if i!= 0 then there is a truncation error! */ - return outptr-out; -} - -static int -base64_decode_simple (char *data, int len) -{ - int state = 0; - unsigned int save = 0; - - return base64_decode_step ((unsigned char *)data, len, - (unsigned char *)data, &state, &save); -} - -static GString * -getValue( char **src ) -{ - GString *dest = g_string_new(""); - char *s = *src; - gboolean need_base64 = (*s == ':'); - - copy_line: - while( *s != 0 && *s != '\n' && *s != '\r' ) - dest = g_string_append_c (dest, *s++); - - if (*s == '\r') s++; - if (*s == '\n') s++; - - /* check for continuation here */ - if (*s == ' ') { - s++; - goto copy_line; - } - - if (need_base64) { - int new_len; - /* it's base64 encoded */ - dest = g_string_erase (dest, 0, 2); - new_len = base64_decode_simple (dest->str, strlen (dest->str)); - dest = g_string_truncate (dest, new_len); - } - - *src = s; - - return dest; -} - -static gboolean -parseLine( ECardSimple *simple, ECardDeliveryAddress *address, char **buf ) -{ - char *ptr; - char *colon, *value; - gboolean field_handled; - GString *ldif_value; - - ptr = *buf; - - /* if the string is empty, return */ - if (*ptr == '\0') { - *buf = NULL; - return TRUE; - } - - /* skip comment lines */ - if (*ptr == '#') { - ptr = strchr (ptr, '\n'); - if (!ptr) - *buf = NULL; - else - *buf = ptr + 1; - return TRUE; - } - - /* first, check for a 'continuation' line */ - if( ptr[0] == ' ' && ptr[1] != '\n' ) { - g_warning ("unexpected continuation line"); - return FALSE; - } - - colon = (char *)strchr( ptr, ':' ); - if (colon) { - int i; - - *colon = 0; - value = colon + 1; - while ( isspace(*value) ) - value++; - - ldif_value = getValue(&value ); - - field_handled = FALSE; - for (i = 0; i < num_ldif_fields; i ++) { - if (!g_ascii_strcasecmp (ptr, ldif_fields[i].ldif_attribute)) { - if (ldif_fields[i].flags & FLAG_ADDRESS) { - if (!g_ascii_strcasecmp (ptr, "locality")) - address->city = g_strdup (ldif_value->str); - else if (!g_ascii_strcasecmp (ptr, "countryname")) - address->country = g_strdup (ldif_value->str); - else if (!g_ascii_strcasecmp (ptr, "postalcode")) - address->code = g_strdup (ldif_value->str); - else if (!g_ascii_strcasecmp (ptr, "st")) - address->region = g_strdup (ldif_value->str); - else if (!g_ascii_strcasecmp (ptr, "streetaddress")) - address->street = g_strdup (ldif_value->str); - } - else { - e_card_simple_set (simple, ldif_fields[i].simple_field, ldif_value->str); - printf ("set %s to %s\n", ptr, ldif_value->str); - } - field_handled = TRUE; - break; - } - } - - /* handle objectclass/dn/member out here */ - if (!field_handled) { - if (!g_ascii_strcasecmp (ptr, "dn")) - g_hash_table_insert (dn_card_hash, g_strdup(ldif_value->str), simple->card); - else if (!g_ascii_strcasecmp (ptr, "objectclass") && !g_ascii_strcasecmp (ldif_value->str, "groupofnames")) { - e_card_simple_set (simple, E_CARD_SIMPLE_FIELD_IS_LIST, "true"); - } - else if (!g_ascii_strcasecmp (ptr, "member")) { - EList *email; - g_object_get (simple->card, - "email", &email, - NULL); - e_list_append (email, ldif_value->str); - g_object_unref (email); - } - } - - /* put the colon back the way it was, just for kicks */ - *colon = ':'; - - g_string_free (ldif_value, TRUE); - } - else { - g_warning ("unrecognized entry %s", ptr); - return FALSE; - } - - *buf = value; - - return TRUE; -} - -static ECard * -getNextLDIFEntry( FILE *f ) -{ - ECard *card; - ECardAddrLabel *label; - ECardSimple *simple; - ECardDeliveryAddress *address; - GString *str; - char line[1024]; - char *buf; - - str = g_string_new (""); - /* read from the file until we get to a blank line (or eof) */ - while (!feof (f)) { - if (!fgets (line, sizeof(line), f)) - break; - if (line[0] == '\n' || (line[0] == '\r' && line[1] == '\n')) - break; - str = g_string_append (str, line); - } - - if (strlen (str->str) == 0) { - g_string_free (str, TRUE); - return NULL; - } - - /* now parse that entry */ - card = e_card_new (""); - simple = e_card_simple_new (card); - address = e_card_delivery_address_new (); - - buf = str->str; - while (buf) { - if (!parseLine (simple, address, &buf)) { - /* parsing error */ - g_object_unref (simple); - e_card_delivery_address_unref (address); - return NULL; - } - } - - - /* fill in the address */ - address->flags = E_CARD_ADDR_HOME; - - label = e_card_delivery_address_to_label (address); - e_card_delivery_address_unref (address); - - e_card_simple_set_address (simple, E_CARD_SIMPLE_ADDRESS_ID_HOME, label); - - e_card_address_label_unref (label); - - e_card_simple_sync_card (simple); - - g_string_free (str, TRUE); - - return card; -} - -static void -add_card_cb (EBook *book, EBookStatus status, const gchar *id, gpointer closure) -{ - ECard *card = E_CARD(closure); - char *vcard; - - e_card_set_id (card, id); - - vcard = e_card_get_vcard(card); - - g_print ("Saved card: %s\n", vcard); - g_free(vcard); -} - -static void -resolve_list_card (LDIFImporter *gci, ECard *card) -{ - EList *email; - EIterator *email_iter; - char *full_name; - - if (!e_card_evolution_list (card)) - return; - - g_object_get (card, - "email", &email, - "full_name", &full_name, - NULL); - - /* set file_as to full_name so we don't later try and figure - out a first/last name for the list. */ - if (full_name) { - g_object_set (card, - "file_as", full_name, - NULL); - g_free (full_name); - } - - email_iter = e_list_get_iterator (email); - while (e_iterator_is_valid (email_iter)) { - const char *dn = e_iterator_get (email_iter); - ECard *dn_card = g_hash_table_lookup (dn_card_hash, dn); - - /* break list chains here, since we don't support them just yet */ - if (dn_card && !e_card_evolution_list (dn_card)) { - EDestination *dest = e_destination_new (); - gchar *dest_xml; - e_destination_set_card (dest, dn_card, 0); /* Hard-wired for default e-mail, since netscape only exports 1 email address */ - dest_xml = e_destination_export (dest); - g_object_unref (dest); - if (dest_xml) { - e_iterator_set (email_iter, dest_xml); - g_free (dest_xml); - e_iterator_next (email_iter); - } - else { - e_iterator_delete (email_iter); - } - } - else { - e_iterator_delete (email_iter); - } - } - g_object_unref(email); -} - -static void -book_open_cb (EBook *book, EBookStatus status, gpointer closure) -{ - LDIFImporter *gci = (LDIFImporter *) closure; - GList * list = NULL; - GList * list_list = NULL; - FILE * file; - ECard *card; - - if(!( file = fopen( gci->filename, "r" ) )) { - g_warning("!!!Can't open .ldif file"); - return; - } - - dn_card_hash = g_hash_table_new (g_str_hash, g_str_equal); - - while ((card = getNextLDIFEntry (file))) { - - if (e_card_evolution_list (card)) - list_list = g_list_append (list_list, card); - else - list = g_list_append (list, card); - } - - fclose( file ); - - list = g_list_reverse( list ); - list_list = g_list_reverse (list_list); - list = g_list_concat (list, list_list); - - gci->cardlist = list; - gci->ready = TRUE; -} - -static void -ebook_open (LDIFImporter *gci, const char *uri) -{ - gci->book = e_book_new (); - - if (!gci->book) { - printf ("%s: %s(): Couldn't create EBook, bailing.\n", - __FILE__, - G_GNUC_FUNCTION); - return; - } - - e_book_load_address_book_by_uri (gci->book, uri, book_open_cb, gci); -} - -/* EvolutionImporter methods */ -static void -process_item_fn (EvolutionImporter *importer, - CORBA_Object listener, - void *closure, - CORBA_Environment *ev) -{ - LDIFImporter *gci = (LDIFImporter *) closure; - ECard *card; - - if (gci->iterator == NULL) - gci->iterator = gci->cardlist; - - if (gci->ready == FALSE) { - GNOME_Evolution_ImporterListener_notifyResult (listener, - GNOME_Evolution_ImporterListener_NOT_READY, - gci->iterator ? TRUE : FALSE, - ev); - return; - } - - if (gci->iterator == NULL) { - GNOME_Evolution_ImporterListener_notifyResult (listener, - GNOME_Evolution_ImporterListener_UNSUPPORTED_OPERATION, - FALSE, ev); - return; - } - - card = gci->iterator->data; - if (e_card_evolution_list (card)) - resolve_list_card (gci, card); - e_book_add_card (gci->book, card, add_card_cb, card); - - gci->iterator = gci->iterator->next; - - GNOME_Evolution_ImporterListener_notifyResult (listener, - GNOME_Evolution_ImporterListener_OK, - gci->iterator ? TRUE : FALSE, - ev); - if (ev->_major != CORBA_NO_EXCEPTION) { - g_warning ("Error notifying listeners."); - } - - return; -} - -static char *supported_extensions[2] = { - ".ldif", NULL -}; - -static gboolean -support_format_fn (EvolutionImporter *importer, - const char *filename, - void *closure) -{ - char *ext; - int i; - - ext = strrchr (filename, '.'); - if (ext == NULL) { - return FALSE; - } - - for (i = 0; supported_extensions[i] != NULL; i++) { - if (strcmp (supported_extensions[i], ext) == 0) - return TRUE; - } - - return FALSE; -} - -static void -importer_destroy_cb (gpointer data, - GObject *where_object_was) -{ - bonobo_main_quit (); -} - -static gboolean -load_file_fn (EvolutionImporter *importer, - const char *filename, - const char *uri, - const char *folder_type, - void *closure) -{ - LDIFImporter *gci; - - gci = (LDIFImporter *) closure; - gci->filename = g_strdup (filename); - gci->cardlist = NULL; - gci->iterator = NULL; - gci->ready = FALSE; - ebook_open (gci, uri); - - return TRUE; -} - -static BonoboObject * -factory_fn (BonoboGenericFactory *_factory, - const char *component_id, - void *closure) -{ - EvolutionImporter *importer; - LDIFImporter *gci; - - if (!strcmp (component_id, COMPONENT_IID)) { - gci = g_new (LDIFImporter, 1); - importer = evolution_importer_new (support_format_fn, load_file_fn, - process_item_fn, NULL, gci); - - g_object_weak_ref (G_OBJECT (importer), - importer_destroy_cb, gci); - - return BONOBO_OBJECT (importer); - } - else { - g_warning (COMPONENT_FACTORY_IID ": Don't know what to do with %s", component_id); - return NULL; - } -} - -BONOBO_ACTIVATION_FACTORY (COMPONENT_FACTORY_IID, "Evolution LDIF Importer Factory", VERSION, factory_fn, NULL); diff --git a/addressbook/backend/ebook/evolution-vcard-importer.c b/addressbook/backend/ebook/evolution-vcard-importer.c deleted file mode 100644 index c01c118cae..0000000000 --- a/addressbook/backend/ebook/evolution-vcard-importer.c +++ /dev/null @@ -1,214 +0,0 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */ -#include <config.h> -#include <stdio.h> -#include <string.h> - -#include <bonobo/bonobo-context.h> -#include <bonobo/bonobo-generic-factory.h> -#include <bonobo/bonobo-main.h> - -#include <e-book.h> -#include <e-book-util.h> - -#include <importer/evolution-importer.h> -#include <importer/GNOME_Evolution_Importer.h> - -#include <e-util/e-path.h> - -#define COMPONENT_FACTORY_IID "OAFIID:GNOME_Evolution_Addressbook_VCard_ImporterFactory" -#define COMPONENT_IID "OAFIID:GNOME_Evolution_Addressbook_VCard_Importer" - -typedef struct { - char *filename; - GList *cardlist; - GList *iterator; - EBook *book; - gboolean ready; -} VCardImporter; - -static void -add_card_cb (EBook *book, EBookStatus status, const gchar *id, gpointer closure) -{ - ECard *card = E_CARD(closure); - g_object_unref(card); -} - -static void -book_open_cb (EBook *book, EBookStatus status, gpointer closure) -{ - VCardImporter *gci = (VCardImporter *) closure; - - gci->cardlist = e_card_load_cards_from_file_with_default_charset(gci->filename, "ISO-8859-1"); - gci->ready = TRUE; -} - -static void -ebook_open (VCardImporter *gci, const char *uri) -{ - gci->book = e_book_new (); - - if (!gci->book) { - printf ("%s: %s(): Couldn't create EBook, bailing.\n", - __FILE__, - G_GNUC_FUNCTION); - return; - } - - e_book_load_address_book_by_uri (gci->book, uri, book_open_cb, gci); -} - -/* EvolutionImporter methods */ -static void -process_item_fn (EvolutionImporter *importer, - CORBA_Object listener, - void *closure, - CORBA_Environment *ev) -{ - VCardImporter *gci = (VCardImporter *) closure; - ECard *card; - - if (gci->iterator == NULL) - gci->iterator = gci->cardlist; - - if (gci->ready == FALSE) { - GNOME_Evolution_ImporterListener_notifyResult (listener, - GNOME_Evolution_ImporterListener_NOT_READY, - gci->iterator ? TRUE : FALSE, - ev); - return; - } - - if (gci->iterator == NULL) { - GNOME_Evolution_ImporterListener_notifyResult (listener, - GNOME_Evolution_ImporterListener_UNSUPPORTED_OPERATION, - FALSE, ev); - return; - } - - card = gci->iterator->data; - e_book_add_card (gci->book, card, add_card_cb, card); - - gci->iterator = gci->iterator->next; - - GNOME_Evolution_ImporterListener_notifyResult (listener, - GNOME_Evolution_ImporterListener_OK, - gci->iterator ? TRUE : FALSE, - ev); - if (ev->_major != CORBA_NO_EXCEPTION) { - g_warning ("Error notifying listeners."); - } - - return; -} - -static char *supported_extensions[3] = { - ".vcf", - ".gcrd", - NULL -}; - -/* Actually check the contents of this file */ -static gboolean -check_file_is_vcard (const char *filename) -{ - FILE *handle; - char line[4096]; - gboolean result; - - handle = fopen (filename, "r"); - if (handle == NULL) { - g_print ("\n"); - return FALSE; - } - - fgets (line, 4096, handle); - if (line == NULL) { - fclose (handle); - g_print ("\n"); - return FALSE; - } - - if (g_ascii_strncasecmp (line, "BEGIN:VCARD", 11) == 0) { - result = TRUE; - } else { - result = FALSE; - } - - fclose (handle); - return result; -} - -static gboolean -support_format_fn (EvolutionImporter *importer, - const char *filename, - void *closure) -{ - char *ext; - int i; - - ext = strrchr (filename, '.'); - if (ext == NULL) { - return check_file_is_vcard (filename); - } - for (i = 0; supported_extensions[i] != NULL; i++) { - if (g_ascii_strcasecmp (supported_extensions[i], ext) == 0) - return check_file_is_vcard (filename); - } - - return FALSE; -} - -static void -importer_destroy_cb (gpointer data, - GObject *where_object_was) -{ - bonobo_main_quit (); -} - -static gboolean -load_file_fn (EvolutionImporter *importer, - const char *filename, - const char *uri, - const char *folder_type, - void *closure) -{ - VCardImporter *gci; - - if (check_file_is_vcard (filename) == FALSE) { - return FALSE; - } - - gci = (VCardImporter *) closure; - gci->filename = g_strdup (filename); - gci->cardlist = NULL; - gci->iterator = NULL; - gci->ready = FALSE; - ebook_open (gci, uri); - - return TRUE; -} - -static BonoboObject * -factory_fn (BonoboGenericFactory *_factory, - const char *component_id, - void *closure) -{ - EvolutionImporter *importer; - VCardImporter *gci; - - if (!strcmp (component_id, COMPONENT_IID)) { - gci = g_new (VCardImporter, 1); - importer = evolution_importer_new (support_format_fn, load_file_fn, - process_item_fn, NULL, gci); - - g_object_weak_ref (G_OBJECT (importer), - importer_destroy_cb, gci); - return BONOBO_OBJECT (importer); - } - else { - g_warning (COMPONENT_FACTORY_IID ": Don't know what to do with %s", component_id); - return NULL; - } -} - -BONOBO_ACTIVATION_FACTORY (COMPONENT_FACTORY_IID, "Evolution VCard Importer Factory", VERSION, factory_fn, NULL); diff --git a/addressbook/backend/ebook/load-gnomecard-addressbook.c b/addressbook/backend/ebook/load-gnomecard-addressbook.c deleted file mode 100644 index f6fde225e0..0000000000 --- a/addressbook/backend/ebook/load-gnomecard-addressbook.c +++ /dev/null @@ -1,77 +0,0 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */ -#include <config.h> -#include <stdio.h> -#include <glib.h> - -#include <bonobo/bonobo-i18n.h> -#include <bonobo/bonobo-main.h> -#include <libgnome/gnome-init.h> - -#include "e-book.h" - -static void -add_card_cb (EBook *book, EBookStatus status, const gchar *id, gpointer closure) -{ - ECard *card = E_CARD(closure); - char *vcard = e_card_get_vcard_assume_utf8(card); - g_print ("Saved card: %s\n", vcard); - g_free(vcard); - g_object_unref(card); -} - -static void -book_open_cb (EBook *book, EBookStatus status, gpointer closure) -{ - GList *list = e_card_load_cards_from_file_with_default_charset("gnomecard.vcf", "ISO-8859-1"); - GList *iterator; - for (iterator = list; iterator; iterator = g_list_next(iterator)) { - ECard *card = iterator->data; - e_book_add_card(book, card, add_card_cb, card); - } - g_list_free(list); -} - -static gboolean -ebook_create (gpointer data) -{ - EBook *book; - gchar *path, *uri; - - book = e_book_new (); - - if (!book) { - printf ("%s: %s(): Couldn't create EBook, bailing.\n", - __FILE__, - G_GNUC_FUNCTION); - return FALSE; - } - - - path = g_build_filename (g_get_home_dir (), - "evolution/local/Contacts/addressbook.db", - NULL); - uri = g_strdup_printf ("file://%s", path); - g_free (path); - - e_book_load_uri (book, uri, book_open_cb, NULL); - g_free(uri); - - - return FALSE; -} - -int -main (int argc, char **argv) -{ - GnomeProgram *program; - - program = gnome_program_init ("load-gnomecard-addressbook", VERSION, LIBGNOME_MODULE, argc, argv, - GNOME_PROGRAM_STANDARD_PROPERTIES, - NULL); - - g_idle_add (ebook_create, NULL); - - bonobo_main (); - - return 0; -} diff --git a/addressbook/backend/ebook/load-pine-addressbook.c b/addressbook/backend/ebook/load-pine-addressbook.c deleted file mode 100644 index ece04bbdef..0000000000 --- a/addressbook/backend/ebook/load-pine-addressbook.c +++ /dev/null @@ -1,159 +0,0 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */ -#include <config.h> -#include <ctype.h> -#include <stdio.h> -#include <string.h> -#include <glib.h> -#include <bonobo/bonobo-i18n.h> -#include <bonobo/bonobo-main.h> -#include <libgnome/gnome-init.h> - -#include "e-book.h" - -static void -add_card_cb (EBook *book, EBookStatus status, const gchar *id, gpointer closure) -{ - ECard *card = E_CARD(closure); - char *vcard = e_card_get_vcard_assume_utf8(card); - g_print ("Saved card: %s\n", vcard); - g_free(vcard); - g_object_unref(card); -} - -static void -parse_line (EBook *book, char *line) -{ - char **strings; - ECardName *name; - ECard *card; - EList *list; - - card = e_card_new(""); - strings = g_strsplit(line, "\t", 3); - if (strings[0] && strings[1] && strings[2]) { - name = e_card_name_from_string(strings[1]); - g_object_set(card, - "nickname", strings[0], - "full_name", strings[1], - "name", name, - NULL); - g_object_get(card, - "email", &list, - NULL); - e_list_append(list, strings[2]); - e_book_add_card(book, card, add_card_cb, card); - g_object_unref(list); - } - g_strfreev(strings); -} - -static void -book_open_cb (EBook *book, EBookStatus status, gpointer closure) -{ - FILE *fp = fopen (".addressbook", "r"); - char line[2 * 1024]; - int which = 0; - char *lastline = NULL; - - if (!fp) { - g_warning ("Can't find .addressbook"); - return; - } - - while(fgets(line + which * 1024, 1024, fp)) { - int length; - char *thisline = line + which * 1024; - length = strlen(thisline); - if (thisline[length - 1] == '\n') - line[--length] = 0; - if (lastline && *thisline && isspace(*thisline)) { - char *temp; - while(*thisline && isspace(*thisline)) - thisline ++; - temp = lastline; - lastline = g_strdup_printf("%s%s", lastline, thisline); - g_free(temp); - continue; - } - if (lastline) { - parse_line (book, lastline); - g_free(lastline); - } - lastline = g_strdup(thisline); - } - - if (lastline) { - parse_line (book, lastline); - g_free(lastline); - } -} - -static gboolean -ebook_create (gpointer data) -{ - EBook *book; - gchar *path, *uri; - - book = e_book_new (); - - if (!book) { - printf ("%s: %s(): Couldn't create EBook, bailing.\n", - __FILE__, G_GNUC_FUNCTION); - return FALSE; - } - - - path = g_build_filename (g_get_home_dir (), - "evolution/local/Contacts/addressbook.db", - NULL); - - uri = g_strdup_printf ("file://%s", path); - g_free (path); - - e_book_load_uri (book, uri, book_open_cb, NULL); - g_free(uri); - - - return FALSE; -} - -#if 0 -static char * -read_file (char *name) -{ - int len; - char buff[65536]; - char line[1024]; - FILE *f; - - f = fopen (name, "r"); - if (f == NULL) - g_error ("Unable to open %s!\n", name); - - len = 0; - while (fgets (line, sizeof (line), f) != NULL) { - strcpy (buff + len, line); - len += strlen (line); - } - - fclose (f); - - return g_strdup (buff); -} -#endif - -int -main (int argc, char **argv) -{ - GnomeProgram *program; - - program = gnome_program_init ("load-pine-addressbook", VERSION, LIBGNOME_MODULE, argc, argv, - GNOME_PROGRAM_STANDARD_PROPERTIES, - NULL); - - g_idle_add (ebook_create, NULL); - - bonobo_main (); - - return 0; -} diff --git a/addressbook/backend/ebook/test-card.c b/addressbook/backend/ebook/test-card.c deleted file mode 100644 index 21806b0313..0000000000 --- a/addressbook/backend/ebook/test-card.c +++ /dev/null @@ -1,193 +0,0 @@ -#include <string.h> -#include "e-card.h" -#include <libgnome/gnome-init.h> - -#define TEST_VCARD \ -"BEGIN:VCARD\r\n" \ -"FN:Nat\r\n" \ -"N:Friedman;Nat;D;Mr.\r\n" \ -"ORG:Ximian, Inc.\r\n" \ -"TITLE:Head Geek\r\n" \ -"ROLE:Programmer/Executive\r\n" \ -"BDAY:1977-08-06\r\n" \ -"TEL;WORK:617 679 1984\r\n" \ -"TEL;CELL:123 456 7890\r\n" \ -"EMAIL;INTERNET:nat@nat.org\r\n" \ -"EMAIL;INTERNET:nat@ximian.com\r\n" \ -"ADR;WORK;POSTAL:P.O. Box 101;;;Any Town;CA;91921-1234;\r\n" \ -"ADR;HOME;POSTAL;INTL:P.O. Box 202;;;Any Town 2;MI;12344-4321;USA\r\n" \ -"END:VCARD\r\n" \ -"\r\n" - -static char * -read_file (char *name) -{ - int len; - char buff[65536]; - char line[1024]; - FILE *f; - - f = fopen (name, "r"); - if (f == NULL) - g_error ("Unable to open %s!\n", name); - - len = 0; - while (fgets (line, sizeof (line), f) != NULL) { - strcpy (buff + len, line); - len += strlen (line); - } - - fclose (f); - - return g_strdup (buff); -} - - - -int -main (int argc, char **argv) -{ - char *cardstr; - ECard *card; - - /* Fields */ - char *fname; - char *org; - char *org_unit; - char *title; - char *role; - char *nickname; - char *fburl; - ECardName *name; - EList *address; - EList *phone; - EList *email; - EList *arbitrary; - EIterator *iterator; - ECardDate *bday; - - gnome_program_init("test-card", "0.0", LIBGNOME_MODULE, argc, argv, NULL); - - cardstr = NULL; - if (argc == 2) - cardstr = read_file (argv [1]); - - if (cardstr == NULL) - cardstr = TEST_VCARD; -#if 0 - { - int i; - for ( i = 0; i < 100000; i++ ) { - card = e_card_new (cardstr); - - g_object_unref (card); - } - } -#endif - card = e_card_new_with_default_charset (cardstr, "ISO-8859-1"); - g_object_get(card, - "full_name", &fname, - "name", &name, - "address", &address, - "phone", &phone, - "email", &email, - "org", &org, - "org_unit", &org_unit, - "title", &title, - "role", &role, - "nickname", &nickname, - "fburl", &fburl, - "arbitrary", &arbitrary, - "birth_date", &bday, - NULL); - if ( fname ) { - printf("Name : %s\n", fname); - g_free(fname); - } - if ( name ) { - printf("Full Name:\n"); - if ( name->prefix ) - printf(" prefix : %s\n", name->prefix); - if ( name->given ) - printf(" given : %s\n", name->given); - if ( name->additional ) - printf(" additional : %s\n", name->additional); - if ( name->family ) - printf(" family : %s\n", name->family); - if ( name->suffix ) - printf(" suffix : %s\n", name->suffix); - } - if ( org ) { - printf("Company : %s\n", org); - } - if ( org_unit ) { - printf("Department : %s\n", org_unit); - } - if ( title ) { - printf("Title : %s\n", title); - } - if ( role ) { - printf("Profession : %s\n", role); - } - if ( nickname ) { - printf("Nickname : %s\n", nickname); - } - if ( fburl ) { - printf("Free Busy URL : %s\n", fburl); - } - if ( arbitrary ) { - iterator = e_list_get_iterator(arbitrary); - for (; e_iterator_is_valid(iterator); e_iterator_next(iterator)) { - ECardArbitrary *arbitrary = (ECardArbitrary *) e_iterator_get(iterator); - printf("Arbitrary : %s, %s\n", arbitrary->key, arbitrary->value); - } - g_object_unref(iterator); - } - if ( bday ) { - printf("BDay : %4d-%02d-%02d\n", bday->year, bday->month, bday->day); - } - if ( email ) { - iterator = e_list_get_iterator(address); - for (; e_iterator_is_valid(iterator); e_iterator_next(iterator)) { - printf("Email : %s\n", (char *) e_iterator_get(iterator)); - } - g_object_unref(iterator); - g_object_unref(email); - } - if ( phone ) { - iterator = e_list_get_iterator(address); - for (; e_iterator_is_valid(iterator); e_iterator_next(iterator)) { - ECardPhone *e_card_phone = (ECardPhone *) e_iterator_get(iterator); - printf("Phone ; %d : %s\n", e_card_phone->flags, e_card_phone->number); - } - g_object_unref(iterator); - g_object_unref(phone); - } - if ( address ) { - iterator = e_list_get_iterator(address); - for (; e_iterator_is_valid(iterator); e_iterator_next(iterator)) { - ECardDeliveryAddress *del_address = (ECardDeliveryAddress *) e_iterator_get(iterator); - printf("Address ; %d:\n", del_address->flags); - if ( del_address->po ) - printf(" Po : %s\n", del_address->po); - if ( del_address->ext ) - printf(" Ext : %s\n", del_address->ext); - if ( del_address->street ) - printf(" Street : %s\n", del_address->street); - if ( del_address->city ) - printf(" City : %s\n", del_address->city); - if ( del_address->region ) - printf(" Region : %s\n", del_address->region); - if ( del_address->code ) - printf(" Code : %s\n", del_address->code); - if ( del_address->country ) - printf(" Country : %s\n", del_address->country); - } - g_object_unref(iterator); - g_object_unref(address); - } - printf("%s", e_card_get_vcard_assume_utf8(card)); - g_object_unref (card); - - return 0; -} diff --git a/addressbook/backend/ebook/tests/.cvsignore b/addressbook/backend/ebook/tests/.cvsignore deleted file mode 100644 index 282522db03..0000000000 --- a/addressbook/backend/ebook/tests/.cvsignore +++ /dev/null @@ -1,2 +0,0 @@ -Makefile -Makefile.in diff --git a/addressbook/backend/ebook/tests/Makefile.am b/addressbook/backend/ebook/tests/Makefile.am deleted file mode 100644 index 444d692e22..0000000000 --- a/addressbook/backend/ebook/tests/Makefile.am +++ /dev/null @@ -1 +0,0 @@ -SUBDIRS=vcard ebook diff --git a/addressbook/backend/ebook/tests/ebook/.cvsignore b/addressbook/backend/ebook/tests/ebook/.cvsignore deleted file mode 100644 index 8dbec11b01..0000000000 --- a/addressbook/backend/ebook/tests/ebook/.cvsignore +++ /dev/null @@ -1,7 +0,0 @@ -Makefile -Makefile.in -test-date -test-ebook -test-changes -test-photo -test-string diff --git a/addressbook/backend/ebook/tests/ebook/Makefile.am b/addressbook/backend/ebook/tests/ebook/Makefile.am deleted file mode 100644 index 7147690482..0000000000 --- a/addressbook/backend/ebook/tests/ebook/Makefile.am +++ /dev/null @@ -1,12 +0,0 @@ - -TEST_LIBS=$(top_builddir)/addressbook/backend/ebook/libebook.la - -INCLUDES=-I$(srcdir)/../../.. @EVOLUTION_ADDRESSBOOK_CFLAGS@ - -noinst_PROGRAMS= test-changes test-date test-ebook test-photo test-string - -test_date_LDFLAGS=$(TEST_LIBS) -test_ebook_LDFLAGS=$(TEST_LIBS) -test_changes_LDFLAGS=$(TEST_LIBS) -test_photo_LDFLAGS=$(TEST_LIBS) -test_string_LDFLAGS=$(TEST_LIBS) diff --git a/addressbook/backend/ebook/tests/ebook/test-changes.c b/addressbook/backend/ebook/tests/ebook/test-changes.c deleted file mode 100644 index f1e65adaa0..0000000000 --- a/addressbook/backend/ebook/tests/ebook/test-changes.c +++ /dev/null @@ -1,89 +0,0 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */ - -#include "ebook/e-book.h" -#include <libgnome/gnome-init.h> -#include <bonobo/bonobo-main.h> -#include <stdlib.h> - -#define NEW_VCARD "BEGIN:VCARD\n\ -X-EVOLUTION-FILE-AS:Toshok, Chris\n\ -FN:Chris Toshok\n\ -EMAIL;INTERNET:toshok@ximian.com\n\ -ORG:Ximian, Inc.;\n\ -END:VCARD" - -static char file_template[]="file:///tmp/change-test-XXXXXX"; - -int -main (int argc, char **argv) -{ - EBook *book; - gboolean status; - EContact *contact; - GList *changes; - GError *error = NULL; - EBookChange *change; - - gnome_program_init("test-changes", "0.0", LIBGNOME_MODULE, argc, argv, NULL); - - if (bonobo_init (&argc, argv) == FALSE) - g_error ("Could not initialize Bonobo"); - - mktemp (file_template); - - /* create a temp addressbook in /tmp */ - book = e_book_new (); - - printf ("loading addressbook\n"); - if (!e_book_load_uri (book, file_template, FALSE, &error)) { - printf ("failed to open addressbook: `%s': %s\n", file_template, error->message); - exit(0); - } - - /* get an initial change set */ - if (!e_book_get_changes (book, "changeidtest", &changes, &error)) { - printf ("failed to get changes: %s\n", error->message); - exit(0); - } - - /* make a change to the book */ - contact = e_contact_new_from_vcard (NEW_VCARD); - if (!e_book_add_contact (book, contact, &error)) { - printf ("failed to add new contact: %s\n", error->message); - exit(0); - } - - /* get another change set */ - if (!e_book_get_changes (book, "changeidtest", &changes, &error)) { - printf ("failed to get second set of changes: %s\n", error->message); - exit(0); - } - - /* make sure that 1 change has occurred */ - if (g_list_length (changes) != 1) { - printf ("got back %d changes, was expecting 1\n", g_list_length (changes)); - exit(0); - } - - change = changes->data; - if (change->change_type != E_BOOK_CHANGE_CARD_ADDED) { - printf ("was expecting a CARD_ADDED change, but didn't get it.\n"); - exit(0); - } - - printf ("got changed vcard back: %s\n", e_contact_get_const (change->contact, E_CONTACT_UID)); - - e_book_free_change_list (changes); - - - if (!e_book_remove (book, &error)) { - printf ("failed to remove book; %s\n", error->message); - exit(0); - } - - g_object_unref (book); - - bonobo_main_quit(); - - return 0; -} diff --git a/addressbook/backend/ebook/tests/ebook/test-date.c b/addressbook/backend/ebook/tests/ebook/test-date.c deleted file mode 100644 index afe37cf224..0000000000 --- a/addressbook/backend/ebook/tests/ebook/test-date.c +++ /dev/null @@ -1,36 +0,0 @@ - -#include "ebook/e-book.h" -#include <libgnome/gnome-init.h> -#include <bonobo/bonobo-main.h> -#include <stdlib.h> - -int -main (int argc, char **argv) -{ - EContact *contact; - EContactDate date, *dp; - - gnome_program_init("test-string", "0.0", LIBGNOME_MODULE, argc, argv, NULL); - - if (bonobo_init (&argc, argv) == FALSE) - g_error ("Could not initialize Bonobo"); - - contact = e_contact_new (); - - date.year = 1999; - date.month = 3; - date.day = 3; - - e_contact_set (contact, E_CONTACT_BIRTH_DATE, &date); - - printf ("vcard = \n%s\n", e_vcard_to_string (E_VCARD (contact), EVC_FORMAT_VCARD_30)); - - dp = e_contact_get (contact, E_CONTACT_BIRTH_DATE); - - if (dp->year != date.year - || dp->month != date.month - || dp->day != date.day) - printf ("failed\n"); - else - printf ("passed\n"); -} diff --git a/addressbook/backend/ebook/tests/ebook/test-ebook.c b/addressbook/backend/ebook/tests/ebook/test-ebook.c deleted file mode 100644 index d78d9f3b6a..0000000000 --- a/addressbook/backend/ebook/tests/ebook/test-ebook.c +++ /dev/null @@ -1,110 +0,0 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */ - -#include "ebook/e-book.h" -#include <libgnome/gnome-init.h> -#include <bonobo/bonobo-main.h> -#include <stdlib.h> - -static void -print_email (EContact *contact) -{ - char *file_as = e_contact_get (contact, E_CONTACT_FILE_AS); - GList *emails, *e; - - printf ("Contact: %s\n", file_as); - printf ("Email addresses:\n"); - emails = e_contact_get (contact, E_CONTACT_EMAIL); - for (e = emails; e; e = e->next) { - EVCardAttribute *attr = e->data; - GList *values = e_vcard_attribute_get_values (attr); - printf ("\t%s\n", values && values->data ? (char*)values->data : ""); - e_vcard_attribute_free (attr); - } - g_list_free (emails); - - g_free (file_as); - - printf ("\n"); -} - -static void -print_all_emails (EBook *book) -{ - EBookQuery *query; - gboolean status; - GList *cards, *c; - - query = e_book_query_field_exists (E_CONTACT_FULL_NAME); - - status = e_book_get_contacts (book, query, &cards, NULL); - - e_book_query_unref (query); - - if (status == FALSE) { - printf ("error %d getting card list\n", status); - exit(0); - } - - for (c = cards; c; c = c->next) { - EContact *contact = E_CONTACT (c->data); - - print_email (contact); - - g_object_unref (contact); - } - g_list_free (cards); -} - -static void -print_one_email (EBook *book) -{ - EContact *contact; - GError *error = NULL; - - if (!e_book_get_contact (book, "pas-id-0002023", &contact, &error)) { - printf ("error %d getting card: %s\n", error->code, error->message); - g_clear_error (&error); - return; - } - - print_email (contact); - - g_object_unref (contact); -} - -int -main (int argc, char **argv) -{ - EBook *book; - gboolean status; - - gnome_program_init("test-ebook", "0.0", LIBGNOME_MODULE, argc, argv, NULL); - - if (bonobo_init (&argc, argv) == FALSE) - g_error ("Could not initialize Bonobo"); - - /* - ** the actual ebook foo - */ - - book = e_book_new (); - - printf ("loading addressbook\n"); - status = e_book_load_local_addressbook (book, NULL); - if (status == FALSE) { - printf ("failed to open local addressbook\n"); - exit(0); - } - - printf ("printing one contact\n"); - print_one_email (book); - - printf ("printing all contacts\n"); - print_all_emails (book); - - g_object_unref (book); - - bonobo_main_quit(); - - return 0; -} diff --git a/addressbook/backend/ebook/tests/ebook/test-photo.c b/addressbook/backend/ebook/tests/ebook/test-photo.c deleted file mode 100644 index cbd6817b37..0000000000 --- a/addressbook/backend/ebook/tests/ebook/test-photo.c +++ /dev/null @@ -1,59 +0,0 @@ - -#include "ebook/e-book.h" -#include <libgnome/gnome-init.h> -#include <bonobo/bonobo-main.h> -#include <stdlib.h> - -const char *photo_data = "/9j/4AAQSkZJRgABAQEARwBHAAD//gAXQ3JlYXRlZCB3aXRo\ -IFRoZSBHSU1Q/9sAQwAIBgYHBgUIBwcHCQkICgwUDQwLCwwZEhMPFB0aHx4dGhwcICQuJyAiLC\ -McHCg3KSwwMTQ0NB8nOT04MjwuMzQy/9sAQwEJCQkMCwwYDQ0YMiEcITIyMjIyMjIyMjIyMjIy\ -MjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIy/8AAEQgAMgAyAwEiAAIRAQMRAf\ -/EABsAAQACAwEBAAAAAAAAAAAAAAAHCAQFBgID/8QAMBAAAgEDAQYEBQQDAAAAAAAAAQIDAAQR\ -BQYSEyExQQdhcYEiI0JRkRQVMqFiguH/xAAaAQADAQEBAQAAAAAAAAAAAAAABAUCBgED/8QAIx\ -EAAgICAQQCAwAAAAAAAAAAAAECAwQRQRITITEUYQUiUf/aAAwDAQACEQMRAD8An+sHUtWtNKjV\ -rmQ7754cajLvjrgfbzPIdzWdVfds9pJb3XdQkMrcFZGj+HqY0bdVV9Tz/wBia+N9vbjvkaxMb5\ -E9N6SJB1HxLEEjJaWsUjD6QzSMPXdGB7E1zV74t63HINy1s4F7CWCTn77wrA0TY86jY3N1qsUk\ -6wxBxBDvYjLHkoUH4j3JP/a0V3s1CvF/QM9tKpw0THeU+TLkj8VLnmzT8y0n9FujBx5bioba/r\ -ZLWx3iPZ7RzLp95GtnqRGVTezHNjruH7/4n+67iqpq7Qi3uYWMMsNynfnE6sM8/Lr6VamFi0KM\ -epUE1Sx7XZHbI+fjxos1H0z3SlKYEjzISI2I64OKqsyu8sck2QYrmPjBvpIYg598Vauoh8VtlY\ -7JW2isoBwpPl6hGByZTyD+o6E+h7UtlVOcPHA/+PyI1Wal6Zp7vaC/06wnTTLtEeUDiKwzu4H8\ -vI9AM9Tiuctkng1Nnk1G5cOoYifB4nI/jB7VjWuoT21qPmwXUCHKlphHKvqG5N6g0/cLi/Rg88\ -FhbkbxlaUSu3kqpnn6kDzqGqbNdPB0XyK4/svZr9RVntL50GePdcKEDqzhVBx7sKtPpayppNos\ -xzKIlDHzxUFeG2zo2n2kivWhK6PpHwwoTnfk65J7kZyT9z5VYADAwKuYtfRA5zPv7tnjgUpSmR\ -EV8bq1hvbWW1uY1khlUo6MMhgeor7UoAje18FtmLe9eeQT3EXPcglkJRPbv71EWu7Dajp2o3MG\ -mlRCkjKQ30jPUe1WlrlNW0RptTleNB84DnjkD0P9VlxT4Nqck9pmn8JuFp2zo0cgCWFi2e7555\ -/NSHXLadso2m3sU0NxlV65HM+VdTW3rgwvsUpSvAFKUoAUxSlAClKUAKUpQB//2Q=="; - - -int -main (int argc, char **argv) -{ - EContact *contact; - EContactPhoto *photo, *new_photo; - - gnome_program_init("test-photo", "0.0", LIBGNOME_MODULE, argc, argv, NULL); - - if (bonobo_init (&argc, argv) == FALSE) - g_error ("Could not initialize Bonobo"); - - contact = e_contact_new (); - - photo = g_new (EContactPhoto, 1); - photo->data = g_strdup (photo_data); - photo->length = _evc_base64_decode_simple (photo->data, strlen (photo_data)); - - /* set the photo */ - e_contact_set (contact, E_CONTACT_PHOTO, photo); - - /* then get the photo */ - new_photo = e_contact_get (contact, E_CONTACT_PHOTO); - - /* and compare */ - if (new_photo->length != photo->length) - g_error ("photo lengths differ"); - - if (memcmp (new_photo->data, photo->data, photo->length)) - g_error ("photo data differs"); - - printf ("photo test passed\n"); -} diff --git a/addressbook/backend/ebook/tests/ebook/test-string.c b/addressbook/backend/ebook/tests/ebook/test-string.c deleted file mode 100644 index b7cdbb3720..0000000000 --- a/addressbook/backend/ebook/tests/ebook/test-string.c +++ /dev/null @@ -1,27 +0,0 @@ - -#include "ebook/e-book.h" -#include <libgnome/gnome-init.h> -#include <bonobo/bonobo-main.h> -#include <stdlib.h> - -#define TEST_ID "test-uid" - -int -main (int argc, char **argv) -{ - EContact *contact; - - gnome_program_init("test-string", "0.0", LIBGNOME_MODULE, argc, argv, NULL); - - if (bonobo_init (&argc, argv) == FALSE) - g_error ("Could not initialize Bonobo"); - - contact = e_contact_new (); - - e_contact_set (contact, E_CONTACT_UID, TEST_ID); - - if (!strcmp (e_contact_get_const (contact, E_CONTACT_UID), TEST_ID)) - printf ("passed\n"); - else - printf ("failed\n"); -} diff --git a/addressbook/backend/ebook/tests/vcard/.cvsignore b/addressbook/backend/ebook/tests/vcard/.cvsignore deleted file mode 100644 index 41d78c77a2..0000000000 --- a/addressbook/backend/ebook/tests/vcard/.cvsignore +++ /dev/null @@ -1,3 +0,0 @@ -Makefile -Makefile.in -dump-vcard diff --git a/addressbook/backend/ebook/tests/vcard/1.vcf b/addressbook/backend/ebook/tests/vcard/1.vcf deleted file mode 100644 index 308144c5f1..0000000000 --- a/addressbook/backend/ebook/tests/vcard/1.vcf +++ /dev/null @@ -1,12 +0,0 @@ -BEGIN:vCard -VERSION:3.0 -FN:Frank Dawson -ORG:Lotus Development Corporation -ADR;TYPE=WORK,POSTAL,PARCEL:;;6544 Battleford Drive - ;Raleigh;NC;27613-3502;U.S.A. -TEL;TYPE=VOICE,MSG,WORK:+1-919-676-9515 -TEL;TYPE=FAX,WORK:+1-919-676-9564 -EMAIL;TYPE=INTERNET,PREF:Frank_Dawson@Lotus.com -EMAIL;TYPE=INTERNET:fdawson@earthlink.net -URL:http://home.earthlink.net/~fdawson -END:vCard diff --git a/addressbook/backend/ebook/tests/vcard/10.vcf b/addressbook/backend/ebook/tests/vcard/10.vcf deleted file mode 100644 index 4bccbe9ffb..0000000000 --- a/addressbook/backend/ebook/tests/vcard/10.vcf +++ /dev/null @@ -1,12 +0,0 @@ -BEGIN:vCard -vCard.vCard.VERSION:3.0 -vCard.FN:Frank Dawson -vCard.ORG:Lotus Development Corporation -vCard.ADR;TYPE=WORK,POSTAL,PARCEL:;;6544 Battleford Drive - ;Raleigh;NC;27613-3502;U.S.A. -vCard.TEL;TYPE=VOICE,MSG,WORK:+1-919-676-9515 -vCard.TEL;TYPE=FAX,WORK:+1-919-676-9564 -vCard.EMAIL;TYPE=INTERNET,PREF:Frank_Dawson@Lotus.com -vCard.EMAIL;TYPE=INTERNET:fdawson@earthlink.net -vCard.URL:http://home.earthlink.net/~fdawson -END:vCard diff --git a/addressbook/backend/ebook/tests/vcard/2.vcf b/addressbook/backend/ebook/tests/vcard/2.vcf deleted file mode 100644 index bdf14ea1b7..0000000000 --- a/addressbook/backend/ebook/tests/vcard/2.vcf +++ /dev/null @@ -1,10 +0,0 @@ -BEGIN:vCard -VERSION:3.0 -FN:Tim Howes -ORG:Netscape Communications Corp. -ADR;TYPE=WORK:;;501 E. Middlefield Rd.;Mountain View; - CA; 94043;U.S.A. -TEL;TYPE=VOICE,MSG,WORK:+1-415-937-3419 -TEL;TYPE=FAX,WORK:+1-415-528-4164 -EMAIL;TYPE=INTERNET:howes@netscape.com -END:vCard diff --git a/addressbook/backend/ebook/tests/vcard/3.vcf b/addressbook/backend/ebook/tests/vcard/3.vcf deleted file mode 100644 index 3058716959..0000000000 --- a/addressbook/backend/ebook/tests/vcard/3.vcf +++ /dev/null @@ -1,13 +0,0 @@ -BEGIN:VCARD -VERSION:2.1 -X-EVOLUTION-FILE-AS:Friedman, Nat -FN:Nat -N:Friedman;Nat;D;Mr. -ADR;POSTAL;WORK:P.O. Box 101;;;Any Town;CA;91921-1234 -TEL;WORK:617 679 1984 -TEL;CELL:123 456 7890 -EMAIL;INTERNET:nat@nat.org -EMAIL;INTERNET:nat@ximian.com -BDAY:1977-08-06 -UID:pas-id-3E65886900000002 -END:VCARD diff --git a/addressbook/backend/ebook/tests/vcard/4.vcf b/addressbook/backend/ebook/tests/vcard/4.vcf deleted file mode 100644 index 46878f753b..0000000000 --- a/addressbook/backend/ebook/tests/vcard/4.vcf +++ /dev/null @@ -1,11 +0,0 @@ -BEGIN:VCARD -VERSION:2.1 -X-EVOLUTION-FILE-AS:address, canada -FN:canada address -N:address;canada -ADR;WORK:;;92 Main St. N.;Newmarket;ON;L3Y 4A1;Canada -ADR;HOME;PREF:;;92 Main St. N.;Newmarket;ON;L3Y 4A1;Canada -LABEL;QUOTED-PRINTABLE;WORK:92 Main St. N.=0ANewmarket, ON L3Y 4A1=0ACanada -LABEL;QUOTED-PRINTABLE;HOME;PREF:92 Main St. N.=0ANewmarket, ON L3Y 4A1=0ACanada -UID:pas-id-3E84C16E00000001 -END:VCARD diff --git a/addressbook/backend/ebook/tests/vcard/5.vcf b/addressbook/backend/ebook/tests/vcard/5.vcf deleted file mode 100644 index 51bbe207a6..0000000000 --- a/addressbook/backend/ebook/tests/vcard/5.vcf +++ /dev/null @@ -1,32 +0,0 @@ -BEGIN:VCARD -VERSION:2.1 -X-EVOLUTION-FILE-AS;CHARSET=UTF-8;QUOTED-PRINTABLE:=E5=8D=81=E5=9F=8E=E7=9B=AE=E7=AE=A1=E7=90=86=E5=A4=A7=E5=9E=8B=E7=9F=A5=E5= -=BA=A7 -FN;CHARSET=UTF-8;QUOTED-PRINTABLE:=E5=8D=81=E5=9F=8E=E7=9B=AE=E7=AE=A1=E7=90=86=E5=A4=A7=E5=9E=8B=E7=9F=A5=E5= -=BA=A7 -N;CHARSET=UTF-8:;å城目管ç†å¤§åž‹çŸ¥åº§ -ADR;WORK;PREF;QUOTED-PRINTABLE;CHARSET=UTF-8:;=E5=8D=81=E5=9F=8E=E7=9B=AE=E7=AE=A1=E7=90=86=E5=A4=A7=E5=9E=8B=E7=9F=A5=E5= -=BA=A7=0A=E5=8D=81=E5=9F=8E=E7=9B=AE=E7=AE=A1=E7=90=86=E5=A4=A7=E5=9E=8B=E7= -=9F=A5=E5=BA=A7=0A=E5=8D=81=E5=9F=8E=E7=9B=AE=E7=AE=A1=E7=90=86=E5=A4=A7=E5= -=9E=8B=E7=9F=A5=E5=BA=A7;=E5=8D=81=E5=9F=8E=E7=9B=AE=E7=AE=A1=E7=90=86=E5=A4=A7=E5=9E=8B=E7=9F=A5=E5= -=BA=A7 -LABEL;CHARSET=UTF-8;QUOTED-PRINTABLE;WORK;PREF:=E5=8D=81=E5=9F=8E=E7=9B=AE=E7=AE=A1=E7=90=86=E5=A4=A7=E5=9E=8B=E7=9F=A5=E5= -=BA=A7=0A=E5=8D=81=E5=9F=8E=E7=9B=AE=E7=AE=A1=E7=90=86=E5=A4=A7=E5=9E=8B=E7= -=9F=A5=E5=BA=A7=0A=E5=8D=81=E5=9F=8E=E7=9B=AE=E7=AE=A1=E7=90=86=E5=A4=A7=E5= -=9E=8B=E7=9F=A5=E5=BA=A7=0A=E5=8D=81=E5=9F=8E=E7=9B=AE=E7=AE=A1=E7=90=86=E5= -=A4=A7=E5=9E=8B=E7=9F=A5=E5=BA=A7 -TEL;CHARSET=UTF-8;QUOTED-PRINTABLE;WORK;VOICE:=E5=8D=81=E5=9F=8E=E7=9B=AE=E7=AE=A1=E7=90=86=E5=A4=A7=E5=9E=8B=E7=9F=A5=E5= -=BA=A7 -TEL;CHARSET=UTF-8;QUOTED-PRINTABLE;WORK;FAX:=E5=8D=81=E5=9F=8E=E7=9B=AE=E7=AE=A1=E7=90=86=E5=A4=A7=E5=9E=8B=E7=9F=A5=E5= -=BA=A7 -TEL;CHARSET=UTF-8;QUOTED-PRINTABLE;HOME:=E5=8D=81=E5=9F=8E=E7=9B=AE=E7=AE=A1=E7=90=86=E5=A4=A7=E5=9E=8B=E7=9F=A5=E5= -=BA=A7 -TEL;CHARSET=UTF-8;QUOTED-PRINTABLE;CELL:=E5=8D=81=E5=9F=8E=E7=9B=AE=E7=AE=A1=E7=90=86=E5=A4=A7=E5=9E=8B=E7=9F=A5=E5= -=BA=A7 -EMAIL;INTERNET:weird@weird.com -ORG;CHARSET=UTF-8:å城目管ç†å¤§åž‹çŸ¥åº§ -TITLE;CHARSET=UTF-8;QUOTED-PRINTABLE:=E5=8D=81=E5=9F=8E=E7=9B=AE=E7=AE=A1=E7=90=86=E5=A4=A7=E5=9E=8B=E7=9F=A5=E5= -=BA=A7 -UID:pas-id-3E52FE2E00000000 -END:VCARD - diff --git a/addressbook/backend/ebook/tests/vcard/6.vcf b/addressbook/backend/ebook/tests/vcard/6.vcf deleted file mode 100644 index e5e8310eb3..0000000000 --- a/addressbook/backend/ebook/tests/vcard/6.vcf +++ /dev/null @@ -1,12 +0,0 @@ -BEGIN:vCard -VERSION:3.0 -FN:Frank Dawson -ORG:Lotus Development Corporation -ADR;TYPE=WORK,:;;6544 Battleford Drive - ;Raleigh;NC;27613-3502;U.S.A. -TEL;TYPE=VOICE;MSG,WORK:+1-919-676-9515 -TEL;FAX,WORK:+1-919-676-9564 -EMAIL;TYPE=INTERNET,PREF:Frank_Dawson@Lotus.com -EMAIL;TYPE=INTERNET:fdawson@earthlink.net -URL:http://home.earthlink.net/~fdawson -END:vCard diff --git a/addressbook/backend/ebook/tests/vcard/7.vcf b/addressbook/backend/ebook/tests/vcard/7.vcf deleted file mode 100644 index fb88173032..0000000000 --- a/addressbook/backend/ebook/tests/vcard/7.vcf +++ /dev/null @@ -1,11 +0,0 @@ -VERSION:3.0 -FN:Frank Dawson -ORG:Lotus Development Corporation -ADR;TYPE=WORK,POSTAL,PARCEL:;;6544 Battleford Drive - ;Raleigh;NC;27613-3502;U.S.A. -TEL;TYPE=VOICE,MSG,WORK:+1-919-676-9515 -TEL;TYPE=FAX,WORK:+1-919-676-9564 -EMAIL;TYPE=INTERNET,PREF:Frank_Dawson@Lotus.com -EMAIL;TYPE=INTERNET:fdawson@earthlink.net -URL:http://home.earthlink.net/~fdawson -END:vCard diff --git a/addressbook/backend/ebook/tests/vcard/8.vcf b/addressbook/backend/ebook/tests/vcard/8.vcf deleted file mode 100644 index 172d1d2c68..0000000000 --- a/addressbook/backend/ebook/tests/vcard/8.vcf +++ /dev/null @@ -1,11 +0,0 @@ -BEGIN:vCard -VERSION:3.0 -FN:Frank Dawson -ORG:Lotus Development Corporation -ADR;TYPE=WORK,POSTAL,PARCEL:;;6544 Battleford Drive - ;Raleigh;NC;27613-3502;U.S.A. -TEL;TYPE=VOICE,MSG,WORK:+1-919-676-9515 -TEL;TYPE=FAX,WORK:+1-919-676-9564 -EMAIL;TYPE=INTERNET,PREF:Frank_Dawson@Lotus.com -EMAIL;TYPE=INTERNET:fdawson@earthlink.net -URL:http://home.earthlink.net/~fdawson diff --git a/addressbook/backend/ebook/tests/vcard/9.vcf b/addressbook/backend/ebook/tests/vcard/9.vcf deleted file mode 100644 index 7043ab8c13..0000000000 --- a/addressbook/backend/ebook/tests/vcard/9.vcf +++ /dev/null @@ -1,9 +0,0 @@ -BEGIN:vCard -VERSION:3.0 -FN:Frank Dawson -ORG:Lotus Development Corporation -ADR;TYPE=WORK,POSTAL,PARCEL:;;6544 Battleford Drive - ;Raleigh;NC;27613-3502;U.S.A. -TEL;TYPE=VOICE,MSG,WORK:+1-919-676-9515 -TEL;TYPE=FAX,WORK:+1-919-676-9564 -E diff --git a/addressbook/backend/ebook/tests/vcard/Makefile.am b/addressbook/backend/ebook/tests/vcard/Makefile.am deleted file mode 100644 index 7e57329e1d..0000000000 --- a/addressbook/backend/ebook/tests/vcard/Makefile.am +++ /dev/null @@ -1,8 +0,0 @@ - -TEST_LIBS=$(top_builddir)/addressbook/backend/ebook/libebook.la - -INCLUDES=-I$(srcdir)/../../.. @EVOLUTION_ADDRESSBOOK_CFLAGS@ - -noinst_PROGRAMS=dump-vcard - -dump_vcard_LDFLAGS=$(TEST_LIBS) diff --git a/addressbook/backend/ebook/tests/vcard/README b/addressbook/backend/ebook/tests/vcard/README deleted file mode 100644 index 06ae719c5e..0000000000 --- a/addressbook/backend/ebook/tests/vcard/README +++ /dev/null @@ -1,41 +0,0 @@ -This is the list of tests I've been using while writing e-vcard.c. -The parser is all handcrafted, and it's not a validating parser by any -stretch of the imagination. It tries very hard to deal with any -possible input (it'll even parse rfc822 mail headers and spit out -vCard-ish results.) - -Test : Description ----------------------- - -1.vcf : Frank Dawson's vCard from RFC 2426 (missing the required N - attribute.) - -2.vcf : Tim Howes's vCard from from RFC 2426 (missing the required N - attribute.) - -3.vcf : Nat's old vCard. - -4.vcf : A vCard containing a canadian address (quoted-printable - encoded attribute values.) - -5.vcf : A vCard containing utf8 characters quoted-printable encoded. - -6.vcf : A vCard with several errors in attribute parameters: - line 5: an missing parameter value (a , with nothing after it). - line 6: a missing parameter name when using multiple - values. (this may not be in violation of the rfc.) - line 7: a missing parameter name when using multiple - values. (this may not be in violation of the rfc.) - -7.vcf : A vCard missing its begin:vcard attribute, as well as missing - the required N attribute. - -8.vcf : A vCard missing its end: vcard attribute, as well as missing - the required N attribute. - -9.vcf : A vCard that ends (\0) in the middle of an attribute - name/group. - -10.vcf : A vCard with an attribute with more than 1 group specified. - ----------------------- diff --git a/addressbook/backend/ebook/tests/vcard/dump-vcard.c b/addressbook/backend/ebook/tests/vcard/dump-vcard.c deleted file mode 100644 index 907a00efa7..0000000000 --- a/addressbook/backend/ebook/tests/vcard/dump-vcard.c +++ /dev/null @@ -1,32 +0,0 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */ - -#include <stdio.h> -#include "ebook/e-vcard.h" - -FILE *fp; - -int -main(int argc, char **argv) -{ - EVCard *vcard; - GString *str = g_string_new (""); - - if (argc < 2) - return 0; - - g_type_init_with_debug_flags (G_TYPE_DEBUG_OBJECTS); - - fp = fopen (argv[1], "r"); - - while (!feof (fp)) { - char buf[1024]; - if (fgets (buf, sizeof(buf), fp)) - str = g_string_append (str, buf); - } - - vcard = e_vcard_new_from_string (str->str); - - e_vcard_dump_structure (vcard); - - return 0; -} diff --git a/addressbook/backend/idl/.cvsignore b/addressbook/backend/idl/.cvsignore deleted file mode 100644 index 09980ae6ba..0000000000 --- a/addressbook/backend/idl/.cvsignore +++ /dev/null @@ -1,6 +0,0 @@ -.deps -.libs -Makefile -Makefile.in -*.lo -*.la diff --git a/addressbook/backend/idl/Makefile.am b/addressbook/backend/idl/Makefile.am deleted file mode 100644 index e9f011975b..0000000000 --- a/addressbook/backend/idl/Makefile.am +++ /dev/null @@ -1,4 +0,0 @@ -idl_DATA = \ - addressbook.idl - -EXTRA_DIST = $(idl_DATA) diff --git a/addressbook/backend/idl/addressbook.idl b/addressbook/backend/idl/addressbook.idl deleted file mode 100644 index 193d1246ab..0000000000 --- a/addressbook/backend/idl/addressbook.idl +++ /dev/null @@ -1,187 +0,0 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */ -/* - * - * Author: - * Nat Friedman (nat@ximian.com) - * - * Copyright 2000, Ximian, Inc. - */ - -#include <Bonobo.idl> - -module GNOME { -module Evolution { -module Addressbook { - typedef string ContactId; - typedef string VCard; - typedef sequence<VCard> VCardList; - typedef sequence<ContactId> ContactIdList; - typedef sequence<string> stringlist; - - enum BookChangeType { - ContactAdded, - ContactModified, - ContactDeleted - }; - - struct BookChangeItem { - BookChangeType changeType; - VCard vcard; - }; - - typedef sequence<BookChangeItem> BookChangeList; - - enum CallStatus { - Success, - RepositoryOffline, - PermissionDenied, - ContactNotFound, - ContactIdAlreadyExists, - AuthenticationFailed, - AuthenticationRequired, - UnsupportedField, - UnsupportedAuthenticationMethod, - TLSNotAvailable, - NoSuchBook, - BookRemoved, - - /* These can be returned for successful searches, but - indicate the result set was truncated */ - SearchSizeLimitExceeded, - SearchTimeLimitExceeded, - - InvalidQuery, - QueryRefused, - - CouldNotCancel, - - OtherError - }; - - /* - * A book view is a live view of a book. It's either a view - * of all the contacts in the book or a view of a query. When - * created, it will get a series of notifyContactsAdded calls - * for all objects in the initial set. After that, it will - * get added, removed, or changed signals whenever the book - * changes (if it affects the set of viewed contacts.) - */ - interface BookViewListener : Bonobo::Unknown { - oneway void notifyContactsAdded (in VCardList vcards); - oneway void notifyContactsRemoved (in ContactIdList ids); - oneway void notifyContactsChanged (in VCardList vcards); - oneway void notifySequenceComplete (in CallStatus status); - oneway void notifyProgress (in string message, in short percent); - }; - - interface BookView : Bonobo::Unknown { - oneway void start (); - oneway void stop (); - }; - - interface Book : Bonobo::Unknown { - - /* - * Opening/creating addressbooks. - */ - oneway void open (in boolean only_if_exists); - - /* - * Removing addressbooks. - */ - oneway void remove (); - - /* - * Fetching contacts in the addresbook. - */ - oneway void getContact (in ContactId id); - - oneway void authenticateUser (in string user, in string passwd, - in string authMethod); - - /* - * Adding and deleting contacts in the book. - */ - oneway void addContact (in VCard vcard); - oneway void removeContacts (in ContactIdList Id); - - /* - * Modifying contacts in the addressbook. - */ - oneway void modifyContact (in VCard vcard); - - /* - * These two functions return a book view to the book - * listener. This is for people who want a live view - * of the addressbook. - */ - oneway void getBookView (in BookViewListener listener, in string query, - in stringlist requested_fields, in long max_results); - - oneway void getChanges (in string change_id); - - oneway void getContactList (in string query); - - oneway void getSupportedFields (); - - /* - * This function returns a list of strings - * representing the auth methods (e.g. SASL mechs) - * that a backend/server supports. - * - * Some examples are: - * - * "ldap/simple-email|By email Address" - * "sasl/CRAM-MD5|CRAM-MD5(SASL)" - * - * The format should be: - * - * <class>/<type>|<i18nized string> - * - * "i18nized string" is shown in the UI, and should be - * a user friendly representation of the auth method. - * - * in the case of SASL auth mechs, the text trailing - * the '/' should be the proper name of the mechanism, - * as it will be passed unchanged to the backend auth - * function (eg. ldap_sasl_bind) - */ - oneway void getSupportedAuthMethods (); - - string getStaticCapabilities (); - - string getName (); - - /* cancels the currently running operation, whatever - it is. */ - CallStatus cancelOperation (); - }; - - interface BookListener : Bonobo::Unknown { - - oneway void notifyContactCreated (in CallStatus status, in ContactId Id); - oneway void notifyContactsRemoved (in CallStatus status); - oneway void notifyContactModified (in CallStatus status); - oneway void notifyProgress (in string status_message, in short precent); - oneway void notifyBookOpened (in CallStatus status); - oneway void notifyBookRemoved (in CallStatus status); - oneway void notifyViewRequested (in CallStatus status, in BookView view); - oneway void notifyChangesRequested (in CallStatus status, in BookChangeList changes); - oneway void notifyContactRequested (in CallStatus status, in VCard vcard); - oneway void notifyContactListRequested (in CallStatus status, in stringlist contacts); - oneway void notifySupportedFields (in CallStatus status, in stringlist fields); - oneway void notifyAuthenticationResult (in CallStatus status); - oneway void notifySupportedAuthMethods (in CallStatus status, in stringlist auth_methods); - - oneway void notifyWritable (in boolean writable); - }; - - interface BookFactory : Bonobo::Unknown { - exception ProtocolNotSupported {}; - - Book getBook (in string uri, in BookListener listener) - raises (ProtocolNotSupported); - }; -}; -}; -}; diff --git a/addressbook/backend/pas/.cvsignore b/addressbook/backend/pas/.cvsignore deleted file mode 100644 index 6eb58802ec..0000000000 --- a/addressbook/backend/pas/.cvsignore +++ /dev/null @@ -1,13 +0,0 @@ -.deps -.libs -.pure -Makefile -Makefile.in -addressbook-stubs.c -addressbook-skels.c -addressbook-common.c -addressbook.h -*.lo -*.la -pas-marshal.c -pas-marshal.h
\ No newline at end of file diff --git a/addressbook/backend/pas/Makefile.am b/addressbook/backend/pas/Makefile.am deleted file mode 100644 index 269bb8656f..0000000000 --- a/addressbook/backend/pas/Makefile.am +++ /dev/null @@ -1,109 +0,0 @@ -CORBA_SOURCE_H = addressbook.h - -CORBA_SOURCE_C = \ - addressbook-common.c \ - addressbook-stubs.c \ - addressbook-skels.c - -CORBA_SOURCE = $(CORBA_SOURCE_H) $(CORBA_SOURCE_C) - -idls = \ - $(srcdir)/../idl/addressbook.idl - -$(CORBA_SOURCE_H): $(idls) - $(ORBIT_IDL) $(IDL_INCLUDES) -I $(srcdir) $(srcdir)/../idl/addressbook.idl - -$(CORBA_SOURCE_C): $(CORBA_SOURCE_H) - - -INCLUDES = \ - $(DB3_CFLAGS) \ - $(LDAP_CFLAGS) \ - -DG_LOG_DOMAIN=\"wombat-pas\" \ - -I$(top_srcdir) \ - -I$(top_srcdir)/addressbook/backend \ - -I$(top_builddir)/addressbook/backend \ - -DG_DISABLE_DEPRECATED \ - -DLIBGNOME_DISABLE_DEPRECATED \ - $(EVOLUTION_ADDRESSBOOK_CFLAGS) - -LDAP_SCHEMA = \ - evolutionperson.schema - -LDAP_BACKEND_FILES = \ - pas-backend-ldap.c \ - pas-backend-ldap.h - -if ENABLE_LDAP -LDAP_BACKEND = libpasldap.la -endif - -ldapschemadir = $(privdatadir) -ldapschema_DATA= $(LDAP_SCHEMA) - -privlib_LTLIBRARIES = libpas.la -noinst_LTLIBRARIES = libpasfile.la libpasvcf.la $(LDAP_BACKEND) - -pasincludedir = $(privincludedir)/pas - -pasinclude_HEADERS = \ - $(CORBA_SOURCE_H) \ - pas-book-factory.h \ - pas-book-view.h \ - pas-book.h \ - pas-backend-card-sexp.h \ - pas-backend.h \ - pas-backend-summary.h \ - pas-backend-sync.h \ - pas-types.h - -libpas_la_SOURCES = \ - $(pasinclude_HEADERS) \ - $(CORBA_SOURCE_C) \ - pas-book-factory.c \ - pas-book-view.c \ - pas-book.c \ - pas-backend-card-sexp.c \ - pas-backend.c \ - pas-backend-summary.c \ - pas-backend-sync.c \ - pas-marshal.c \ - ximian-vcard.h - -libpas_la_LIBADD = \ - $(top_builddir)/addressbook/backend/ebook/libebook.la - -libpasfile_la_SOURCES = \ - pas-backend-file.c \ - pas-backend-file.h - -libpasfile_la_LIBADD = \ - libpas.la \ - $(top_builddir)/e-util/libedb3util.la - -libpasvcf_la_SOURCES = \ - pas-backend-vcf.c \ - pas-backend-vcf.h - -libpasvcf_la_LIBADD = \ - libpas.la - -if ENABLE_LDAP -libpasldap_la_SOURCES = \ - $(LDAP_BACKEND_FILES) - -libpasldap_la_LIBADD = \ - libpas.la \ - $(LDAP_LIBS) -endif - -MARSHAL_GENERATED = pas-marshal.c pas-marshal.h -@EVO_MARSHAL_RULE@ - -BUILT_SOURCES = $(CORBA_SOURCE) $(MARSHAL_GENERATED) -CLEANFILES = $(BUILT_SOURCES) - -dist-hook: - cd $(distdir); rm -f $(BUILT_SOURCES) - -EXTRA_DIST = $(LDAP_BACKEND_FILES) $(LDAP_SCHEMA) pas-marshal.list diff --git a/addressbook/backend/pas/TODO b/addressbook/backend/pas/TODO deleted file mode 100644 index 0c77c1b200..0000000000 --- a/addressbook/backend/pas/TODO +++ /dev/null @@ -1,2 +0,0 @@ -* Implement pas_book_factory_activate -* Authentication
\ No newline at end of file diff --git a/addressbook/backend/pas/evolutionperson.schema b/addressbook/backend/pas/evolutionperson.schema deleted file mode 100644 index cc32a96262..0000000000 --- a/addressbook/backend/pas/evolutionperson.schema +++ /dev/null @@ -1,212 +0,0 @@ -# -# Depends upon -# Definition of an X.500 Attribute Type and an Object Class to Hold -# Uniform Resource Identifiers (URIs) [RFC2079] -# (core.schema) -# -# A Summary of the X.500(96) User Schema for use with LDAPv3 [RFC2256] -# (core.schema) -# -# The COSINE and Internet X.500 Schema [RFC1274] (cosine.schema) -# -# The Internet Organizational Person Schema (inetorgperson) -# -# OIDs are broken up into the following: -# 1.3.6.1.4.1.8506.1.? -# .1 Syntaxes -# .2 Attributes -# .3 Objectclasses - -# primaryPhone -attributetype ( 1.3.6.1.4.1.8506.1.2.1 - NAME 'primaryPhone' - DESC 'preferred phone number used to contact a person' - EQUALITY caseIgnoreMatch - SUBSTR caseIgnoreSubstringsMatch - SYNTAX 1.3.6.1.4.1.1466.115.121.1.15 - SINGLE-VALUE ) - -# carPhone -attributetype ( 1.3.6.1.4.1.8506.1.2.2 - NAME 'carPhone' - DESC 'car phone telephone number of the person' - EQUALITY telephoneNumberMatch - SUBSTR telephoneNumberSubstringsMatch - SYNTAX 1.3.6.1.4.1.1466.115.121.1.50 - SINGLE-VALUE ) - -attributetype ( 1.3.6.1.4.1.8506.1.2.3 - NAME ( 'homeFacsimileTelephoneNumber' 'homeFax' ) - SYNTAX 1.3.6.1.4.1.1466.115.121.1.22 ) - -attributetype ( 1.3.6.1.4.1.8506.1.2.4 - NAME 'otherPhone' - EQUALITY telephoneNumberMatch - SUBSTR telephoneNumberSubstringsMatch - SYNTAX 1.3.6.1.4.1.1466.115.121.1.50 ) - -attributetype ( 1.3.6.1.4.1.8506.1.2.5 - NAME 'businessRole' - EQUALITY caseIgnoreMatch - SUBSTR caseIgnoreSubstringsMatch - SYNTAX 1.3.6.1.4.1.1466.115.121.1.15 ) - -attributetype ( 1.3.6.1.4.1.8506.1.2.6 - NAME 'managerName' - SUP name ) - -attributetype ( 1.3.6.1.4.1.8506.1.2.7 - NAME 'assistantName' - SUP name ) - -# spouseName -# single valued (/me smirks) -attributetype ( 1.3.6.1.4.1.8506.1.2.8 - NAME 'spouseName' - SUP name - SINGLE-VALUE ) - -attributetype ( 1.3.6.1.4.1.8506.1.2.9 - NAME 'otherPostalAddress' - EQUALITY caseIgnoreListMatch - SUBSTR caseIgnoreListSubstringsMatch - SYNTAX 1.3.6.1.4.1.1466.115.121.1.41 ) - -attributetype ( 1.3.6.1.4.1.8506.1.2.10 - NAME ( 'mailer' 'mua' ) - EQUALITY caseIgnoreMatch - SUBSTR caseIgnoreSubstringsMatch - SYNTAX 1.3.6.1.4.1.1466.115.121.1.15{32} ) - -attributetype ( 1.3.6.1.4.1.8506.1.2.11 - NAME ( 'birthDate' 'dob' ) - EQUALITY caseIgnoreMatch - SUBSTR caseIgnoreSubstringsMatch - SYNTAX 1.3.6.1.4.1.1466.115.121.1.15{128} ) - -attributetype ( 1.3.6.1.4.1.8506.1.2.12 - NAME 'anniversary' - EQUALITY caseIgnoreMatch - SUBSTR caseIgnoreSubstringsMatch - SYNTAX 1.3.6.1.4.1.1466.115.121.1.15{128} ) - -attributetype ( 1.3.6.1.4.1.8506.1.2.13 - NAME 'note' - EQUALITY caseIgnoreMatch - SUBSTR caseIgnoreSubstringsMatch - SYNTAX 1.3.6.1.4.1.1466.115.121.1.15{1024} ) - -attributetype ( 1.3.6.1.4.1.8506.1.2.14 - NAME 'evolutionArbitrary' - EQUALITY caseIgnoreMatch - SUBSTR caseIgnoreSubstringsMatch - SYNTAX 1.3.6.1.4.1.1466.115.121.1.15{4096} ) - ) - -attributetype ( 1.3.6.1.4.1.8506.1.2.15 - NAME 'fileAs' - SUP name ) - -attributetype ( 1.3.6.1.4.1.8506.1.2.16 - NAME 'assistantPhone' - EQUALITY telephoneNumberMatch - SUBSTR telephoneNumberSubstringsMatch - SYNTAX 1.3.6.1.4.1.1466.115.121.1.50 ) - -attributetype ( 1.3.6.1.4.1.8506.1.2.17 - NAME 'companyPhone' - EQUALITY telephoneNumberMatch - SUBSTR telephoneNumberSubstringsMatch - SYNTAX 1.3.6.1.4.1.1466.115.121.1.50 ) - -attributetype ( 1.3.6.1.4.1.8506.1.2.18 - NAME 'callbackPhone' - EQUALITY telephoneNumberMatch - SUBSTR telephoneNumberSubstringsMatch - SYNTAX 1.3.6.1.4.1.1466.115.121.1.50 ) - -attributetype ( 1.3.6.1.4.1.8506.1.2.19 - NAME ( 'otherFacsimileTelephoneNumber' 'otherFax' ) - SYNTAX 1.3.6.1.4.1.1466.115.121.1.22 ) - -attributetype ( 1.3.6.1.4.1.8506.1.2.20 - NAME 'radio' - EQUALITY telephoneNumberMatch - SUBSTR telephoneNumberSubstringsMatch - SYNTAX 1.3.6.1.4.1.1466.115.121.1.50 ) - -attributetype ( 1.3.6.1.4.1.8506.1.2.21 - NAME 'telex' - EQUALITY telephoneNumberMatch - SUBSTR telephoneNumberSubstringsMatch - SYNTAX 1.3.6.1.4.1.1466.115.121.1.50 ) - -attributetype ( 1.3.6.1.4.1.8506.1.2.22 - NAME 'tty' - EQUALITY telephoneNumberMatch - SUBSTR telephoneNumberSubstringsMatch - SYNTAX 1.3.6.1.4.1.1466.115.121.1.50 ) - -# deprecated - use the multivalued category -attributetype ( 1.3.6.1.4.1.8506.1.2.23 - NAME 'categories' - EQUALITY caseIgnoreMatch - SUBSTR caseIgnoreSubstringsMatch - SYNTAX 1.3.6.1.4.1.1466.115.121.1.15{4096} ) - -attributetype ( 1.3.6.1.4.1.8506.1.2.24 - NAME 'contact' - EQUALITY distinguishedNameMatch - SYNTAX 1.3.6.1.4.1.1466.115.121.1.12 ) - -attributetype ( 1.3.6.1.4.1.8506.1.2.25 - NAME 'listName' - SUP name - SINGLE-VALUE ) - -# deprecated - use calEntry and its attributes from RFC 2739 -attributetype ( 1.3.6.1.4.1.8506.1.2.26 - NAME 'calendarURI' - EQUALITY caseExactIA5Match - SYNTAX 1.3.6.1.4.1.1466.115.121.1.26 - SINGLE-VALUE ) - -# deprecated - use calEntry and its attributes from RFC 2739 -attributetype ( 1.3.6.1.4.1.8506.1.2.27 - NAME 'freeBusyURI' - EQUALITY caseExactIA5Match - SYNTAX 1.3.6.1.4.1.1466.115.121.1.26 - SINGLE-VALUE ) - -attributetype ( 1.3.6.1.4.1.8506.1.2.28 - NAME 'category' - EQUALITY caseIgnoreMatch - SUBSTR caseIgnoreSubstringsMatch - SYNTAX 1.3.6.1.4.1.1466.115.121.1.15{4096} ) - - -# evolutionPerson -objectclass ( 1.3.6.1.4.1.8506.1.3.1 - NAME 'evolutionPerson' - DESC 'Objectclass geared to Evolution Usage' - SUP inetOrgPerson - STRUCTURAL - MAY ( - fileAs $ primaryPhone $ carPhone $ homeFacsimileTelephoneNumber $ - otherPhone $ businessRole $ managerName $ assistantName $ assistantPhone $ - otherPostalAddress $ mailer $ birthDate $ anniversary $ spouseName $ - note $ companyPhone $ callbackPhone $ otherFacsimileTelephoneNumber $ - radio $ telex $ tty $ categories $ category $ calendarURI $ freeBusyURI ) - ) - -# evolutionPersonList -objectclass ( 1.3.6.1.4.1.8506.1.3.2 - NAME 'evolutionPersonList' - DESC 'Objectclass geared to Evolution Contact Lists' - SUP top - STRUCTURAL - MUST ( - listName ) - MAY ( - mail $ contact ) - ) diff --git a/addressbook/backend/pas/pas-backend-card-sexp.c b/addressbook/backend/pas/pas-backend-card-sexp.c deleted file mode 100644 index 1ccb4f2433..0000000000 --- a/addressbook/backend/pas/pas-backend-card-sexp.c +++ /dev/null @@ -1,482 +0,0 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */ -/* - * pas-backend-card-sexp.c - * Copyright 1999, 2000, 2001, Ximian, Inc. - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Library General Public - * License, version 2, as published by the Free Software Foundation. - * - * This library 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 - * Library General Public License for more details. - * - * You should have received a copy of the GNU Library General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA - * 02111-1307, USA. - */ - -#include "pas-backend-card-sexp.h" - -#include <string.h> -#include <e-util/e-sexp.h> -#include <gal/widgets/e-unicode.h> - -static GObjectClass *parent_class; - -typedef struct _SearchContext SearchContext; - -struct _PASBackendCardSExpPrivate { - ESExp *search_sexp; - SearchContext *search_context; -}; - -struct _SearchContext { - EContact *contact; -}; - -static gboolean -compare_email (EContact *contact, const char *str, - char *(*compare)(const char*, const char*)) -{ - int i; - - for (i = E_CONTACT_EMAIL_1; i <= E_CONTACT_EMAIL_3; i ++) { - const char *email = e_contact_get_const (contact, i); - - if (email && compare(email, str)) - return TRUE; - } - - return FALSE; -} - -static gboolean -compare_phone (EContact *contact, const char *str, - char *(*compare)(const char*, const char*)) -{ - int i; - gboolean rv = FALSE; - - for (i = E_CONTACT_FIRST_PHONE_ID; i <= E_CONTACT_LAST_PHONE_ID; i ++) { - char *phone = e_contact_get (contact, i); - - rv = phone && compare(phone, str); - g_free (phone); - - if (rv) - break; - } - - return rv; -} - -static gboolean -compare_name (EContact *contact, const char *str, - char *(*compare)(const char*, const char*)) -{ - const char *name; - - name = e_contact_get_const (contact, E_CONTACT_FULL_NAME); - if (name && compare (name, str)) - return TRUE; - - name = e_contact_get_const (contact, E_CONTACT_FAMILY_NAME); - if (name && compare (name, str)) - return TRUE; - - return FALSE; -} - -static gboolean -compare_address (EContact *contact, const char *str, - char *(*compare)(const char*, const char*)) -{ - g_warning("address searching not implemented\n"); - return FALSE; -} - -static gboolean -compare_category (EContact *contact, const char *str, - char *(*compare)(const char*, const char*)) -{ - GList *categories; - GList *iterator; - gboolean ret_val = FALSE; - - categories = e_contact_get (contact, E_CONTACT_CATEGORY_LIST); - - for (iterator = categories; iterator; iterator = iterator->next) { - const char *category = iterator->data; - - if (compare(category, str)) { - ret_val = TRUE; - break; - } - } - - g_list_foreach (categories, (GFunc)g_free, NULL); - g_list_free (categories); - - return ret_val; -} - -static struct prop_info { - EContactField field_id; - const char *query_prop; -#define PROP_TYPE_NORMAL 0x01 -#define PROP_TYPE_LIST 0x02 - int prop_type; - gboolean (*list_compare)(EContact *contact, const char *str, - char *(*compare)(const char*, const char*)); - -} prop_info_table[] = { -#define NORMAL_PROP(f,q) {f, q, PROP_TYPE_NORMAL, NULL} -#define LIST_PROP(q,c) {0, q, PROP_TYPE_LIST, c} - - /* query prop, type, list compare function */ - NORMAL_PROP ( E_CONTACT_FILE_AS, "file_as" ), - LIST_PROP ( "full_name", compare_name), /* not really a list, but we need to compare both full and surname */ - NORMAL_PROP ( E_CONTACT_HOMEPAGE_URL, "url"), - NORMAL_PROP ( E_CONTACT_MAILER, "mailer"), - NORMAL_PROP ( E_CONTACT_ORG, "org"), - NORMAL_PROP ( E_CONTACT_ORG_UNIT, "org_unit"), - NORMAL_PROP ( E_CONTACT_OFFICE, "office"), - NORMAL_PROP ( E_CONTACT_TITLE, "title"), - NORMAL_PROP ( E_CONTACT_ROLE, "role"), - NORMAL_PROP ( E_CONTACT_MANAGER, "manager"), - NORMAL_PROP ( E_CONTACT_ASSISTANT, "assistant"), - NORMAL_PROP ( E_CONTACT_NICKNAME, "nickname"), - NORMAL_PROP ( E_CONTACT_SPOUSE, "spouse" ), - NORMAL_PROP ( E_CONTACT_NOTE, "note"), - NORMAL_PROP ( E_CONTACT_UID, "id"), - LIST_PROP ( "email", compare_email ), - LIST_PROP ( "phone", compare_phone ), - LIST_PROP ( "address", compare_address ), - LIST_PROP ( "category", compare_category ), -}; -static int num_prop_infos = sizeof(prop_info_table) / sizeof(prop_info_table[0]); - -static ESExpResult * -entry_compare(SearchContext *ctx, struct _ESExp *f, - int argc, struct _ESExpResult **argv, - char *(*compare)(const char*, const char*)) -{ - ESExpResult *r; - int truth = FALSE; - - if (argc == 2 - && argv[0]->type == ESEXP_RES_STRING - && argv[1]->type == ESEXP_RES_STRING) { - char *propname; - struct prop_info *info = NULL; - int i; - gboolean any_field; - - propname = argv[0]->value.string; - - any_field = !strcmp(propname, "x-evolution-any-field"); - for (i = 0; i < num_prop_infos; i ++) { - if (any_field - || !strcmp (prop_info_table[i].query_prop, propname)) { - info = &prop_info_table[i]; - - if (info->prop_type == PROP_TYPE_NORMAL) { - const char *prop = NULL; - /* straight string property matches */ - - prop = e_contact_get_const (ctx->contact, info->field_id); - - if (prop && compare(prop, argv[1]->value.string)) { - truth = TRUE; - } - if ((!prop) && compare("", argv[1]->value.string)) { - truth = TRUE; - } - } - else if (info->prop_type == PROP_TYPE_LIST) { - /* the special searches that match any of the list elements */ - truth = info->list_compare (ctx->contact, argv[1]->value.string, compare); - } - - /* if we're looking at all fields and find a match, - or if we're just looking at this one field, - break. */ - if ((any_field && truth) - || !any_field) - break; - } - } - - } - r = e_sexp_result_new(f, ESEXP_RES_BOOL); - r->value.bool = truth; - - return r; -} - -static ESExpResult * -func_contains(struct _ESExp *f, int argc, struct _ESExpResult **argv, void *data) -{ - SearchContext *ctx = data; - - return entry_compare (ctx, f, argc, argv, (char *(*)(const char*, const char*)) e_utf8_strstrcase); -} - -static char * -is_helper (const char *s1, const char *s2) -{ - if (!strcasecmp(s1, s2)) - return (char*)s1; - else - return NULL; -} - -static ESExpResult * -func_is(struct _ESExp *f, int argc, struct _ESExpResult **argv, void *data) -{ - SearchContext *ctx = data; - - return entry_compare (ctx, f, argc, argv, is_helper); -} - -static char * -endswith_helper (const char *s1, const char *s2) -{ - char *p; - if ((p = (char*)e_utf8_strstrcase(s1, s2)) - && (strlen(p) == strlen(s2))) - return p; - else - return NULL; -} - -static ESExpResult * -func_endswith(struct _ESExp *f, int argc, struct _ESExpResult **argv, void *data) -{ - SearchContext *ctx = data; - - return entry_compare (ctx, f, argc, argv, endswith_helper); -} - -static char * -beginswith_helper (const char *s1, const char *s2) -{ - char *p; - if ((p = (char*)e_utf8_strstrcase(s1, s2)) - && (p == s1)) - return p; - else - return NULL; -} - -static ESExpResult * -func_beginswith(struct _ESExp *f, int argc, struct _ESExpResult **argv, void *data) -{ - SearchContext *ctx = data; - - return entry_compare (ctx, f, argc, argv, beginswith_helper); -} - -static ESExpResult * -func_exists(struct _ESExp *f, int argc, struct _ESExpResult **argv, void *data) -{ - SearchContext *ctx = data; - ESExpResult *r; - int truth = FALSE; - - if (argc == 1 - && argv[0]->type == ESEXP_RES_STRING) { - char *propname; - struct prop_info *info = NULL; - int i; - - propname = argv[0]->value.string; - - for (i = 0; i < num_prop_infos; i ++) { - if (!strcmp (prop_info_table[i].query_prop, propname)) { - info = &prop_info_table[i]; - - if (info->prop_type == PROP_TYPE_NORMAL) { - const char *prop = NULL; - /* searches where the query's property - maps directly to an ecard property */ - - prop = e_contact_get_const (ctx->contact, info->field_id); - - if (prop && *prop) - truth = TRUE; - } - else if (info->prop_type == PROP_TYPE_LIST) { - /* the special searches that match any of the list elements */ - truth = info->list_compare (ctx->contact, "", (char *(*)(const char*, const char*)) e_utf8_strstrcase); - } - - break; - } - } - - } - r = e_sexp_result_new(f, ESEXP_RES_BOOL); - r->value.bool = truth; - - return r; -} - -/* 'builtin' functions */ -static struct { - char *name; - ESExpFunc *func; - int type; /* set to 1 if a function can perform shortcut evaluation, or - doesn't execute everything, 0 otherwise */ -} symbols[] = { - { "contains", func_contains, 0 }, - { "is", func_is, 0 }, - { "beginswith", func_beginswith, 0 }, - { "endswith", func_endswith, 0 }, - { "exists", func_exists, 0 }, -}; - -gboolean -pas_backend_card_sexp_match_contact (PASBackendCardSExp *sexp, EContact *contact) -{ - ESExpResult *r; - gboolean retval; - - if (!contact) { - g_warning ("null EContact passed to pas_backend_card_sexp_match_contact"); - return FALSE; - } - - sexp->priv->search_context->contact = g_object_ref (contact); - - r = e_sexp_eval(sexp->priv->search_sexp); - - retval = (r && r->type == ESEXP_RES_BOOL && r->value.bool); - - g_object_unref(sexp->priv->search_context->contact); - - e_sexp_result_free(sexp->priv->search_sexp, r); - - return retval; -} - -gboolean -pas_backend_card_sexp_match_vcard (PASBackendCardSExp *sexp, const char *vcard) -{ - EContact *contact; - gboolean retval; - - contact = e_contact_new_from_vcard (vcard); - - retval = pas_backend_card_sexp_match_contact (sexp, contact); - - g_object_unref(contact); - - return retval; -} - - - -/** - * pas_backend_card_sexp_new: - */ -PASBackendCardSExp * -pas_backend_card_sexp_new (const char *text) -{ - PASBackendCardSExp *sexp = g_object_new (PAS_TYPE_BACKEND_CARD_SEXP, NULL); - int esexp_error; - int i; - - sexp->priv->search_sexp = e_sexp_new(); - - for(i=0;i<sizeof(symbols)/sizeof(symbols[0]);i++) { - if (symbols[i].type == 1) { - e_sexp_add_ifunction(sexp->priv->search_sexp, 0, symbols[i].name, - (ESExpIFunc *)symbols[i].func, sexp->priv->search_context); - } - else { - e_sexp_add_function(sexp->priv->search_sexp, 0, symbols[i].name, - symbols[i].func, sexp->priv->search_context); - } - } - - e_sexp_input_text(sexp->priv->search_sexp, text, strlen(text)); - esexp_error = e_sexp_parse(sexp->priv->search_sexp); - - if (esexp_error == -1) { - g_object_unref (sexp); - sexp = NULL; - } - - return sexp; -} - -static void -pas_backend_card_sexp_dispose (GObject *object) -{ - PASBackendCardSExp *sexp = PAS_BACKEND_CARD_SEXP (object); - - if (sexp->priv) { - e_sexp_unref(sexp->priv->search_sexp); - - g_free (sexp->priv->search_context); - g_free (sexp->priv); - sexp->priv = NULL; - } - - if (G_OBJECT_CLASS (parent_class)->dispose) - G_OBJECT_CLASS (parent_class)->dispose (object); -} - -static void -pas_backend_card_sexp_class_init (PASBackendCardSExpClass *klass) -{ - GObjectClass *object_class = G_OBJECT_CLASS (klass); - - parent_class = g_type_class_peek_parent (klass); - - /* Set the virtual methods. */ - - object_class->dispose = pas_backend_card_sexp_dispose; -} - -static void -pas_backend_card_sexp_init (PASBackendCardSExp *sexp) -{ - PASBackendCardSExpPrivate *priv; - - priv = g_new0 (PASBackendCardSExpPrivate, 1); - - sexp->priv = priv; - priv->search_context = g_new (SearchContext, 1); -} - -/** - * pas_backend_card_sexp_get_type: - */ -GType -pas_backend_card_sexp_get_type (void) -{ - static GType type = 0; - - if (! type) { - GTypeInfo info = { - sizeof (PASBackendCardSExpClass), - NULL, /* base_class_init */ - NULL, /* base_class_finalize */ - (GClassInitFunc) pas_backend_card_sexp_class_init, - NULL, /* class_finalize */ - NULL, /* class_data */ - sizeof (PASBackendCardSExp), - 0, /* n_preallocs */ - (GInstanceInitFunc) pas_backend_card_sexp_init - }; - - type = g_type_register_static (G_TYPE_OBJECT, "PASBackendCardSExp", &info, 0); - } - - return type; -} diff --git a/addressbook/backend/pas/pas-backend-card-sexp.h b/addressbook/backend/pas/pas-backend-card-sexp.h deleted file mode 100644 index 7efb697fb0..0000000000 --- a/addressbook/backend/pas/pas-backend-card-sexp.h +++ /dev/null @@ -1,56 +0,0 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */ -/* - * pas-backend-card-sexp.h - * Copyright 2000, 2001, Ximian, Inc. - * - * Authors: - * Chris Lahey <clahey@ximian.com> - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Library General Public - * License, version 2, as published by the Free Software Foundation. - * - * This library 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 - * Library General Public License for more details. - * - * You should have received a copy of the GNU Library General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA - * 02111-1307, USA. - */ - -#ifndef __PAS_BACKEND_CARD_SEXP_H__ -#define __PAS_BACKEND_CARD_SEXP_H__ - -#include <glib.h> -#include <glib-object.h> -#include <ebook/e-contact.h> -#include <pas/pas-types.h> - -#define PAS_TYPE_BACKEND_CARD_SEXP (pas_backend_card_sexp_get_type ()) -#define PAS_BACKEND_CARD_SEXP(o) (G_TYPE_CHECK_INSTANCE_CAST ((o), PAS_TYPE_BACKEND_CARD_SEXP, PASBackendCardSExp)) -#define PAS_BACKEND_CARD_SEXP_CLASS(k) (G_TYPE_CHECK_CLASS_CAST((k), PAS_BACKEND_TYPE, PASBackendCardSExpClass)) -#define PAS_IS_BACKEND_CARD_SEXP(o) (G_TYPE_CHECK_INSTANCE_TYPE ((o), PAS_TYPE_BACKEND_CARD_SEXP)) -#define PAS_IS_BACKEND_CARD_SEXP_CLASS(k) (G_TYPE_CHECK_CLASS_TYPE ((k), PAS_TYPE_BACKEND_CARD_SEXP)) -#define PAS_BACKEND_CARD_SEXP_GET_CLASS(k) (G_TYPE_INSTANCE_GET_CLASS ((obj), PAS_TYPE_BACKEND_CARD_SEXP, PASBackendCardSExpClass)) - -typedef struct _PASBackendCardSExpPrivate PASBackendCardSExpPrivate; - -struct _PASBackendCardSExp { - GObject parent_object; - PASBackendCardSExpPrivate *priv; -}; - -struct _PASBackendCardSExpClass { - GObjectClass parent_class; -}; - -PASBackendCardSExp *pas_backend_card_sexp_new (const char *text); -GType pas_backend_card_sexp_get_type (void); - -gboolean pas_backend_card_sexp_match_vcard (PASBackendCardSExp *sexp, const char *vcard); -gboolean pas_backend_card_sexp_match_contact (PASBackendCardSExp *sexp, EContact *contact); - -#endif /* __PAS_BACKEND_CARD_SEXP_H__ */ diff --git a/addressbook/backend/pas/pas-backend-file.c b/addressbook/backend/pas/pas-backend-file.c deleted file mode 100644 index 73f1797320..0000000000 --- a/addressbook/backend/pas/pas-backend-file.c +++ /dev/null @@ -1,1169 +0,0 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */ -/* - * Author: - * Nat Friedman (nat@ximian.com) - * - * Copyright 2000, Ximian, Inc. - */ - -#include "config.h" -#include "pas-backend-file.h" -#include "pas-backend-card-sexp.h" -#include "pas-backend-summary.h" -#include "pas-book.h" -#include "pas-book-view.h" - -#include <stdio.h> -#include <string.h> -#include <unistd.h> -#include <fcntl.h> -#include <dirent.h> -#include <time.h> -#include <errno.h> -#include <db.h> -#include <sys/stat.h> - -#include <e-util/e-db3-utils.h> - -#if DB_VERSION_MAJOR != 3 || \ - DB_VERSION_MINOR != 1 || \ - DB_VERSION_PATCH != 17 -#error Including wrong DB3. Need libdb 3.1.17. -#endif - -#include <gal/util/e-util.h> -#include <gal/widgets/e-unicode.h> - -#include <ebook/e-contact.h> -#include <e-util/e-dbhash.h> -#include <e-util/e-db3-utils.h> -#include <libgnome/gnome-i18n.h> - -#define CHANGES_DB_SUFFIX ".changes.db" - -#define PAS_BACKEND_FILE_VERSION_NAME "PAS-DB-VERSION" -#define PAS_BACKEND_FILE_VERSION "0.2" - -#define PAS_ID_PREFIX "pas-id-" -#define SUMMARY_FLUSH_TIMEOUT 5000 - -static PASBackendSyncClass *pas_backend_file_parent_class; - -struct _PASBackendFilePrivate { - char *uri; - char *dirname; - char *filename; - char *summary_filename; - DB *file_db; - PASBackendSummary *summary; -}; - -static void -string_to_dbt(const char *str, DBT *dbt) -{ - memset (dbt, 0, sizeof (*dbt)); - dbt->data = (void*)str; - dbt->size = strlen (str) + 1; -} - -static void -build_summary (PASBackendFilePrivate *bfpriv) -{ - DB *db = bfpriv->file_db; - DBC *dbc; - int db_error; - DBT id_dbt, vcard_dbt; - - db_error = db->cursor (db, NULL, &dbc, 0); - - if (db_error != 0) { - g_warning ("build_summary: error building list\n"); - return; - } - - memset (&vcard_dbt, 0, sizeof (vcard_dbt)); - memset (&id_dbt, 0, sizeof (id_dbt)); - db_error = dbc->c_get(dbc, &id_dbt, &vcard_dbt, DB_FIRST); - - while (db_error == 0) { - - /* don't include the version in the list of cards */ - if (id_dbt.size != strlen(PAS_BACKEND_FILE_VERSION_NAME) + 1 - || strcmp (id_dbt.data, PAS_BACKEND_FILE_VERSION_NAME)) { - EContact *contact = e_contact_new_from_vcard (vcard_dbt.data); - pas_backend_summary_add_contact (bfpriv->summary, contact); - g_object_unref (contact); - } - - db_error = dbc->c_get(dbc, &id_dbt, &vcard_dbt, DB_NEXT); - - } -} - -static char * -pas_backend_file_create_unique_id (void) -{ - /* use a 32 counter and the 32 bit timestamp to make an id. - it's doubtful 2^32 id's will be created in a second, so we - should be okay. */ - static guint c = 0; - return g_strdup_printf (PAS_ID_PREFIX "%08lX%08X", time(NULL), c++); -} - -static EContact * -do_create(PASBackendFile *bf, - const char *vcard_req) -{ - DB *db = bf->priv->file_db; - DBT id_dbt, vcard_dbt; - int db_error; - char *id; - EContact *contact; - char *vcard; - - id = pas_backend_file_create_unique_id (); - - string_to_dbt (id, &id_dbt); - - contact = e_contact_new_from_vcard (vcard_req); - e_contact_set(contact, E_CONTACT_UID, id); - vcard = e_vcard_to_string (E_VCARD (contact), EVC_FORMAT_VCARD_30); - - string_to_dbt (vcard, &vcard_dbt); - - db_error = db->put (db, NULL, &id_dbt, &vcard_dbt, 0); - - g_free (vcard); - - if (0 == db_error) { - db_error = db->sync (db, 0); - if (db_error != 0) - g_warning ("db->sync failed.\n"); - } - else { - g_object_unref (contact); - contact = NULL; - } - - g_free (id); - return contact; -} - -static PASBackendSyncStatus -pas_backend_file_create_contact (PASBackendSync *backend, - PASBook *book, - const char *vcard, - EContact **contact) -{ - PASBackendFile *bf = PAS_BACKEND_FILE (backend); - - *contact = do_create (bf, vcard); - if (*contact) { - pas_backend_summary_add_contact (bf->priv->summary, *contact); - return GNOME_Evolution_Addressbook_Success; - } - else { - /* XXX need a different call status for this case, i - think */ - return GNOME_Evolution_Addressbook_ContactNotFound; - } -} - -static PASBackendSyncStatus -pas_backend_file_remove_contacts (PASBackendSync *backend, - PASBook *book, - GList *id_list, - GList **ids) -{ - PASBackendFile *bf = PAS_BACKEND_FILE (backend); - DB *db = bf->priv->file_db; - DBT id_dbt, vcard_dbt; - int db_error; - char *id; - GList *l; - GList *removed_cards = NULL; - GNOME_Evolution_Addressbook_CallStatus rv = GNOME_Evolution_Addressbook_Success; - - for (l = id_list; l; l = l->next) { - id = l->data; - - string_to_dbt (id, &id_dbt); - memset (&vcard_dbt, 0, sizeof (vcard_dbt)); - - db_error = db->get (db, NULL, &id_dbt, &vcard_dbt, 0); - if (0 != db_error) { - rv = GNOME_Evolution_Addressbook_ContactNotFound; - continue; - } - - db_error = db->del (db, NULL, &id_dbt, 0); - if (0 != db_error) { - rv = GNOME_Evolution_Addressbook_ContactNotFound; - continue; - } - - removed_cards = g_list_prepend (removed_cards, id); - } - - /* if we actually removed some, try to sync */ - if (removed_cards) { - db_error = db->sync (db, 0); - if (db_error != 0) - g_warning ("db->sync failed.\n"); - } - - *ids = removed_cards; - - for (l = removed_cards; l; l = l->next) { - char *id = l->data; - pas_backend_summary_remove_contact (bf->priv->summary, id); - } - - return rv; -} - -static PASBackendSyncStatus -pas_backend_file_modify_contact (PASBackendSync *backend, - PASBook *book, - const char *vcard, - EContact **contact) -{ - PASBackendFile *bf = PAS_BACKEND_FILE (backend); - DB *db = bf->priv->file_db; - DBT id_dbt, vcard_dbt; - int db_error; - char *id, *lookup_id; - - *contact = e_contact_new_from_vcard (vcard); - id = e_contact_get(*contact, E_CONTACT_UID); - - /* This is disgusting, but for a time cards were added with - ID's that are no longer used (they contained both the uri - and the id.) If we recognize it as a uri (file:///...) trim - off everything before the last '/', and use that as the - id.*/ - if (!strncmp (id, "file:///", strlen ("file:///"))) { - lookup_id = strrchr (id, '/') + 1; - } - else - lookup_id = id; - - string_to_dbt (lookup_id, &id_dbt); - memset (&vcard_dbt, 0, sizeof (vcard_dbt)); - - /* get the old ecard - the one that's presently in the db */ - db_error = db->get (db, NULL, &id_dbt, &vcard_dbt, 0); - if (0 != db_error) - return GNOME_Evolution_Addressbook_ContactNotFound; - - string_to_dbt (vcard, &vcard_dbt); - - db_error = db->put (db, NULL, &id_dbt, &vcard_dbt, 0); - - if (0 == db_error) { - db_error = db->sync (db, 0); - if (db_error != 0) - g_warning ("db->sync failed.\n"); - - pas_backend_summary_remove_contact (bf->priv->summary, id); - pas_backend_summary_add_contact (bf->priv->summary, *contact); - } - g_free (id); - - if (0 == db_error) - return GNOME_Evolution_Addressbook_Success; - else - return GNOME_Evolution_Addressbook_ContactNotFound; -} - -static PASBackendSyncStatus -pas_backend_file_get_contact (PASBackendSync *backend, - PASBook *book, - const char *id, - char **vcard) -{ - PASBackendFile *bf; - DB *db; - DBT id_dbt, vcard_dbt; - int db_error = 0; - - bf = PAS_BACKEND_FILE (pas_book_get_backend (book)); - db = bf->priv->file_db; - - string_to_dbt (id, &id_dbt); - memset (&vcard_dbt, 0, sizeof (vcard_dbt)); - - db_error = db->get (db, NULL, &id_dbt, &vcard_dbt, 0); - - if (db_error == 0) { - *vcard = g_strdup (vcard_dbt.data); - return GNOME_Evolution_Addressbook_Success; - } else { - *vcard = g_strdup (""); - return GNOME_Evolution_Addressbook_ContactNotFound; - } -} - -static PASBackendSyncStatus -pas_backend_file_get_contact_list (PASBackendSync *backend, - PASBook *book, - const char *query, - GList **contacts) -{ - PASBackendFile *bf = PAS_BACKEND_FILE (backend); - DB *db = bf->priv->file_db; - DBC *dbc; - int db_error; - DBT id_dbt, vcard_dbt; - PASBackendCardSExp *card_sexp = NULL; - gboolean search_needed; - const char *search = query; - GList *contact_list = NULL; - - printf ("pas_backend_file_get_contact_list (%s)\n", search); - - search_needed = TRUE; - - if (!strcmp (search, "(contains \"x-evolution-any-field\" \"\")")) - search_needed = FALSE; - - card_sexp = pas_backend_card_sexp_new (search); - if (!card_sexp) { - /* XXX this needs to be an invalid query error of some sort*/ - return GNOME_Evolution_Addressbook_ContactNotFound; - } - - db_error = db->cursor (db, NULL, &dbc, 0); - - if (db_error != 0) { - /* XXX this needs to be some CouldNotOpen error */ - return GNOME_Evolution_Addressbook_ContactNotFound; - } - - memset (&vcard_dbt, 0, sizeof (vcard_dbt)); - memset (&id_dbt, 0, sizeof (id_dbt)); - db_error = dbc->c_get(dbc, &id_dbt, &vcard_dbt, DB_FIRST); - - while (db_error == 0) { - - /* don't include the version in the list of cards */ - if (id_dbt.size != strlen(PAS_BACKEND_FILE_VERSION_NAME) + 1 - || strcmp (id_dbt.data, PAS_BACKEND_FILE_VERSION_NAME)) { - - if ((!search_needed) || (card_sexp != NULL && pas_backend_card_sexp_match_vcard (card_sexp, vcard_dbt.data))) { - contact_list = g_list_append (contact_list, g_strdup (vcard_dbt.data)); - } - } - - db_error = dbc->c_get(dbc, &id_dbt, &vcard_dbt, DB_NEXT); - - } - - *contacts = contact_list; - return db_error != DB_NOTFOUND - ? GNOME_Evolution_Addressbook_OtherError - : GNOME_Evolution_Addressbook_Success; -} - -typedef struct { - GMutex *mutex; - gboolean stopped; -} FileBackendSearchClosure; - -static void -pas_backend_file_start_book_view (PASBackend *backend, - PASBookView *book_view) -{ - FileBackendSearchClosure *closure = g_new0 (FileBackendSearchClosure, 1); - PASBackendFile *bf = PAS_BACKEND_FILE (backend); - const char *query; - DB *db; - DBT id_dbt, vcard_dbt; - int db_error; - gboolean stopped = FALSE; - - printf ("starting initial population of book view\n"); - - /* ref the book view because it'll be removed and unrefed - when/if it's stopped */ - g_object_ref (book_view); - - db = bf->priv->file_db; - query = pas_book_view_get_card_query (book_view); - - closure->mutex = g_mutex_new(); - closure->stopped = FALSE; - g_object_set_data (G_OBJECT (book_view), "PASBackendFile.BookView::closure", closure); - - if ( ! strcmp (query, "(contains \"x-evolution-any-field\" \"\")")) - pas_book_view_notify_status_message (book_view, _("Loading...")); - else - pas_book_view_notify_status_message (book_view, _("Searching...")); - - if (pas_backend_summary_is_summary_query (bf->priv->summary, query)) { - /* do a summary query */ - GPtrArray *ids = pas_backend_summary_search (bf->priv->summary, pas_book_view_get_card_query (book_view)); - int i; - - for (i = 0; i < ids->len; i ++) { - char *id = g_ptr_array_index (ids, i); - - g_mutex_lock (closure->mutex); - stopped = closure->stopped; - g_mutex_unlock (closure->mutex); - - if (stopped) { - g_mutex_free (closure->mutex); - g_free (closure); - break; - } - - string_to_dbt (id, &id_dbt); - memset (&vcard_dbt, 0, sizeof (vcard_dbt)); - - db_error = db->get (db, NULL, &id_dbt, &vcard_dbt, 0); - - if (db_error == 0) { - EContact *contact = e_contact_new_from_vcard (vcard_dbt.data); - pas_book_view_notify_update (book_view, contact); - g_object_unref (contact); - } - } - - g_ptr_array_free (ids, TRUE); - } - else { - /* iterate over the db and do the query there */ - DBC *dbc; - - memset (&id_dbt, 0, sizeof (id_dbt)); - memset (&vcard_dbt, 0, sizeof (vcard_dbt)); - - db_error = db->cursor (db, NULL, &dbc, 0); - - db_error = dbc->c_get(dbc, &id_dbt, &vcard_dbt, DB_FIRST); - while (db_error == 0) { - - g_mutex_lock (closure->mutex); - stopped = closure->stopped; - g_mutex_unlock (closure->mutex); - - if (stopped) { - g_mutex_free (closure->mutex); - g_free (closure); - break; - } - - /* don't include the version in the list of cards */ - if (strcmp (id_dbt.data, PAS_BACKEND_FILE_VERSION_NAME)) { - char *vcard_string = vcard_dbt.data; - EContact *contact = e_contact_new_from_vcard (vcard_string); - - /* notify_update will check if it matches for us */ - pas_book_view_notify_update (book_view, contact); - g_object_unref (contact); - } - - db_error = dbc->c_get(dbc, &id_dbt, &vcard_dbt, DB_NEXT); - } - - dbc->c_close (dbc); - - if (db_error != DB_NOTFOUND) - g_warning ("pas_backend_file_search: error building list\n"); - - } - - g_mutex_lock (closure->mutex); - stopped = closure->stopped; - g_mutex_unlock (closure->mutex); - if (!stopped) - pas_book_view_notify_complete (book_view, GNOME_Evolution_Addressbook_Success); - - g_mutex_free (closure->mutex); - g_free (closure); - - g_object_set_data (G_OBJECT (book_view), "PASBackendFile.BookView::closure", NULL); - - /* unref the */ - g_object_unref (book_view); - - printf ("finished initial population of book view\n"); -} - -static void -pas_backend_file_stop_book_view (PASBackend *backend, - PASBookView *book_view) -{ - FileBackendSearchClosure *closure = g_object_get_data (G_OBJECT (book_view), "PASBackendFile.BookView::closure"); - if (!closure) { - printf ("book view is already done populating\n"); - return; - } - - printf ("stopping book view!\n"); - g_mutex_lock (closure->mutex); - closure->stopped = TRUE; - g_mutex_lock (closure->mutex); -} - -typedef struct { - DB *db; - - GList *add_cards; - GList *add_ids; - GList *mod_cards; - GList *mod_ids; - GList *del_ids; - GList *del_cards; -} PASBackendFileChangeContext; - -static void -pas_backend_file_changes_foreach_key (const char *key, gpointer user_data) -{ - PASBackendFileChangeContext *ctx = user_data; - DB *db = ctx->db; - DBT id_dbt, vcard_dbt; - int db_error = 0; - - string_to_dbt (key, &id_dbt); - memset (&vcard_dbt, 0, sizeof (vcard_dbt)); - db_error = db->get (db, NULL, &id_dbt, &vcard_dbt, 0); - - if (db_error != 0) { - EContact *contact; - char *id = id_dbt.data; - char *vcard_string; - - contact = e_contact_new (); - e_contact_set (contact, E_CONTACT_UID, id); - - vcard_string = e_vcard_to_string (E_VCARD (contact), EVC_FORMAT_VCARD_30); - - ctx->del_ids = g_list_append (ctx->del_ids, - g_strdup (id)); - ctx->del_cards = g_list_append (ctx->del_cards, - vcard_string); - - g_object_unref (contact); - } -} - -static PASBackendSyncStatus -pas_backend_file_get_changes (PASBackendSync *backend, - PASBook *book, - const char *change_id, - GList **changes_out) -{ - PASBackendFile *bf = PAS_BACKEND_FILE (backend); - int db_error = 0; - DBT id_dbt, vcard_dbt; - char *filename; - EDbHash *ehash; - GList *i, *v; - DB *db = bf->priv->file_db; - DBC *dbc; - GList *changes = NULL; - PASBackendFileChangeContext ctx; - PASBackendSyncStatus result; - - memset (&id_dbt, 0, sizeof (id_dbt)); - memset (&vcard_dbt, 0, sizeof (vcard_dbt)); - - memset (&ctx, 0, sizeof (ctx)); - - ctx.db = db; - - /* Find the changed ids */ - filename = g_strdup_printf ("%s/%s" CHANGES_DB_SUFFIX, bf->priv->dirname, change_id); - ehash = e_dbhash_new (filename); - g_free (filename); - - db_error = db->cursor (db, NULL, &dbc, 0); - - if (db_error != 0) { - g_warning ("pas_backend_file_changes: error building list\n"); - } else { - db_error = dbc->c_get(dbc, &id_dbt, &vcard_dbt, DB_FIRST); - - while (db_error == 0) { - - /* don't include the version in the list of cards */ - if (id_dbt.size != strlen(PAS_BACKEND_FILE_VERSION_NAME) + 1 - || strcmp (id_dbt.data, PAS_BACKEND_FILE_VERSION_NAME)) { - EContact *contact; - char *id = id_dbt.data; - char *vcard_string; - - /* Remove fields the user can't change - * and can change without the rest of the - * card changing - */ - contact = e_contact_new_from_vcard (vcard_dbt.data); -#if notyet - g_object_set (card, "last_use", NULL, "use_score", 0.0, NULL); -#endif - vcard_string = e_vcard_to_string (E_VCARD (contact), EVC_FORMAT_VCARD_30); - g_object_unref (contact); - - /* check what type of change has occurred, if any */ - switch (e_dbhash_compare (ehash, id, vcard_string)) { - case E_DBHASH_STATUS_SAME: - break; - case E_DBHASH_STATUS_NOT_FOUND: - ctx.add_cards = g_list_append (ctx.add_cards, vcard_string); - ctx.add_ids = g_list_append (ctx.add_ids, g_strdup(id)); - break; - case E_DBHASH_STATUS_DIFFERENT: - ctx.mod_cards = g_list_append (ctx.mod_cards, vcard_string); - ctx.mod_ids = g_list_append (ctx.mod_ids, g_strdup(id)); - break; - } - } - - db_error = dbc->c_get(dbc, &id_dbt, &vcard_dbt, DB_NEXT); - } - dbc->c_close (dbc); - } - - e_dbhash_foreach_key (ehash, (EDbHashFunc)pas_backend_file_changes_foreach_key, &ctx); - - /* Send the changes */ - if (db_error != DB_NOTFOUND) { - g_warning ("pas_backend_file_changes: error building list\n"); - *changes_out = NULL; - result = GNOME_Evolution_Addressbook_OtherError; - } - else { - /* Update the hash and build our changes list */ - for (i = ctx.add_ids, v = ctx.add_cards; i != NULL; i = i->next, v = v->next){ - char *id = i->data; - char *vcard = v->data; - - e_dbhash_add (ehash, id, vcard); - changes = g_list_prepend (changes, - pas_backend_change_add_new (vcard)); - - g_free (i->data); - g_free (v->data); - } - for (i = ctx.mod_ids, v = ctx.mod_cards; i != NULL; i = i->next, v = v->next){ - char *id = i->data; - char *vcard = v->data; - - e_dbhash_add (ehash, id, vcard); - changes = g_list_prepend (changes, - pas_backend_change_modify_new (vcard)); - - g_free (i->data); - g_free (v->data); - } - for (i = ctx.del_ids, v = ctx.del_cards; i != NULL; i = i->next, v = v->next){ - char *id = i->data; - char *vcard = v->data; - - e_dbhash_remove (ehash, id); - - changes = g_list_prepend (changes, - pas_backend_change_delete_new (vcard)); - g_free (i->data); - g_free (v->data); - } - - e_dbhash_write (ehash); - - result = GNOME_Evolution_Addressbook_Success; - *changes_out = changes; - } - - e_dbhash_destroy (ehash); - - return GNOME_Evolution_Addressbook_Success; -} - -static char * -pas_backend_file_extract_path_from_uri (const char *uri) -{ - g_assert (strncasecmp (uri, "file://", 7) == 0); - - return g_strdup (uri + 7); -} - -static PASBackendSyncStatus -pas_backend_file_authenticate_user (PASBackendSync *backend, - PASBook *book, - const char *user, - const char *passwd, - const char *auth_method) -{ - return GNOME_Evolution_Addressbook_Success; -} - -static PASBackendSyncStatus -pas_backend_file_get_supported_fields (PASBackendSync *backend, - PASBook *book, - GList **fields_out) -{ - GList *fields = NULL; - int i; - - /* XXX we need a way to say "we support everything", since the - file backend does */ - for (i = 1; i < E_CONTACT_FIELD_LAST; i ++) - fields = g_list_append (fields, g_strdup (e_contact_field_name (i))); - - *fields_out = fields; - return GNOME_Evolution_Addressbook_Success; -} - -/* -** versions: -** -** 0.0 just a list of cards -** -** 0.1 same as 0.0, but with the version tag -** -** 0.2 not a real format upgrade, just a hack to fix broken ids caused -** by a bug in early betas, but we only need to convert them if -** the previous version is 0.1, since the bug existed after 0.1 -** came about. -*/ -static gboolean -pas_backend_file_upgrade_db (PASBackendFile *bf, char *old_version) -{ - DB *db = bf->priv->file_db; - int db_error; - DBT version_name_dbt, version_dbt; - - if (strcmp (old_version, "0.0") - && strcmp (old_version, "0.1")) { - g_warning ("unsupported version '%s' found in PAS backend file\n", - old_version); - return FALSE; - } - - if (!strcmp (old_version, "0.1")) { - /* we just loop through all the cards in the db, - giving them valid ids if they don't have them */ - DBT id_dbt, vcard_dbt; - DBC *dbc; - int card_failed = 0; - - db_error = db->cursor (db, NULL, &dbc, 0); - if (db_error != 0) { - g_warning ("unable to get cursor"); - return FALSE; - } - - memset (&id_dbt, 0, sizeof (id_dbt)); - memset (&vcard_dbt, 0, sizeof (vcard_dbt)); - - db_error = dbc->c_get(dbc, &id_dbt, &vcard_dbt, DB_FIRST); - - while (db_error == 0) { - if (id_dbt.size != strlen(PAS_BACKEND_FILE_VERSION_NAME) + 1 - || strcmp (id_dbt.data, PAS_BACKEND_FILE_VERSION_NAME)) { - EContact *contact; - - contact = e_contact_new_from_vcard (vcard_dbt.data); - - /* the cards we're looking for are - created with a normal id dbt, but - with the id field in the vcard set - to something that doesn't match. - so, we need to modify the card to - have the same id as the the dbt. */ - if (strcmp (id_dbt.data, e_contact_get_const (contact, E_CONTACT_UID))) { - char *vcard; - - e_contact_set (contact, E_CONTACT_UID, id_dbt.data); - - vcard = e_vcard_to_string (E_VCARD (contact), EVC_FORMAT_VCARD_30); - string_to_dbt (vcard, &vcard_dbt); - - db_error = db->put (db, NULL, - &id_dbt, &vcard_dbt, 0); - - g_free (vcard); - - if (db_error != 0) - card_failed++; - } - - g_object_unref (contact); - } - - db_error = dbc->c_get(dbc, &id_dbt, &vcard_dbt, DB_NEXT); - } - - if (card_failed) { - g_warning ("failed to update %d cards\n", card_failed); - return FALSE; - } - } - - string_to_dbt (PAS_BACKEND_FILE_VERSION_NAME, &version_name_dbt); - string_to_dbt (PAS_BACKEND_FILE_VERSION, &version_dbt); - - db_error = db->put (db, NULL, &version_name_dbt, &version_dbt, 0); - if (db_error == 0) - return TRUE; - else - return FALSE; -} - -static gboolean -pas_backend_file_maybe_upgrade_db (PASBackendFile *bf) -{ - DB *db = bf->priv->file_db; - DBT version_name_dbt, version_dbt; - int db_error; - char *version; - gboolean ret_val = TRUE; - - string_to_dbt (PAS_BACKEND_FILE_VERSION_NAME, &version_name_dbt); - memset (&version_dbt, 0, sizeof (version_dbt)); - - db_error = db->get (db, NULL, &version_name_dbt, &version_dbt, 0); - if (db_error == 0) { - /* success */ - version = g_strdup (version_dbt.data); - } - else { - /* key was not in file */ - version = g_strdup ("0.0"); - } - - if (strcmp (version, PAS_BACKEND_FILE_VERSION)) - ret_val = pas_backend_file_upgrade_db (bf, version); - - g_free (version); - - return ret_val; -} - -#include "ximian-vcard.h" - -static GNOME_Evolution_Addressbook_CallStatus -pas_backend_file_load_uri (PASBackend *backend, - const char *uri, - gboolean only_if_exists) -{ - PASBackendFile *bf = PAS_BACKEND_FILE (backend); - char *dirname, *filename; - gboolean writable = FALSE; - int db_error; - DB *db; - int major, minor, patch; - time_t db_mtime; - struct stat sb; - - g_free(bf->priv->uri); - bf->priv->uri = g_strdup (uri); - - db_version (&major, &minor, &patch); - - if (major != 3 || - minor != 1 || - patch != 17) { - g_warning ("Wrong version of libdb."); - return GNOME_Evolution_Addressbook_OtherError; - } - - dirname = pas_backend_file_extract_path_from_uri (uri); - filename = g_build_filename (dirname, "addressbook.db", NULL); - - db_error = e_db3_utils_maybe_recover (filename); - if (db_error != 0) - return GNOME_Evolution_Addressbook_OtherError; - - db_error = db_create (&db, NULL, 0); - if (db_error != 0) - return GNOME_Evolution_Addressbook_OtherError; - - db_error = db->open (db, filename, NULL, DB_HASH, 0, 0666); - - if (db_error == DB_OLD_VERSION) { - db_error = e_db3_utils_upgrade_format (filename); - - if (db_error != 0) - return GNOME_Evolution_Addressbook_OtherError; - - db_error = db->open (db, filename, NULL, DB_HASH, 0, 0666); - } - - bf->priv->file_db = db; - - if (db_error == 0) { - writable = TRUE; - } else { - db_error = db->open (db, filename, NULL, DB_HASH, DB_RDONLY, 0666); - - if (db_error != 0) { - int rv; - - /* the database didn't exist, so we create the - directory then the .db */ - rv = mkdir (dirname, 0777); - if (rv == -1 && errno != EEXIST) { - g_warning ("failed to make directory %s: %s", dirname, strerror (errno)); - if (errno == EACCES || errno == EPERM) - return GNOME_Evolution_Addressbook_PermissionDenied; - else - return GNOME_Evolution_Addressbook_OtherError; - } - - db_error = db->open (db, filename, NULL, DB_HASH, DB_CREATE, 0666); - - if (db_error == 0 && !only_if_exists) { - EContact *contact; - - contact = do_create(bf, XIMIAN_VCARD); - /* XXX check errors here */ - g_object_unref (contact); - - writable = TRUE; - } - } - } - - if (db_error != 0) { - bf->priv->file_db = NULL; - return GNOME_Evolution_Addressbook_OtherError; - } - - if (!pas_backend_file_maybe_upgrade_db (bf)) { - db->close (db, 0); - bf->priv->file_db = NULL; - return GNOME_Evolution_Addressbook_OtherError; - } - - g_free (bf->priv->dirname); - g_free (bf->priv->filename); - bf->priv->dirname = dirname; - bf->priv->filename = filename; - - if (stat (bf->priv->filename, &sb) == -1) { - db->close (db, 0); - bf->priv->file_db = NULL; - return GNOME_Evolution_Addressbook_OtherError; - } - db_mtime = sb.st_mtime; - - g_free (bf->priv->summary_filename); - bf->priv->summary_filename = g_strconcat (bf->priv->filename, ".summary", NULL); - bf->priv->summary = pas_backend_summary_new (bf->priv->summary_filename, SUMMARY_FLUSH_TIMEOUT); - - if (pas_backend_summary_is_up_to_date (bf->priv->summary, db_mtime) == FALSE - || pas_backend_summary_load (bf->priv->summary) == FALSE ) { - build_summary (bf->priv); - } - - pas_backend_set_is_loaded (backend, TRUE); - pas_backend_set_is_writable (backend, writable); - - return GNOME_Evolution_Addressbook_Success; -} - -static int -select_changes (const struct dirent *d) -{ - char *p; - - if (strlen (d->d_name) < strlen (CHANGES_DB_SUFFIX)) - return 0; - - p = strstr (d->d_name, CHANGES_DB_SUFFIX); - if (!p) - return 0; - - if (strlen (p) != strlen (CHANGES_DB_SUFFIX)) - return 0; - - return 1; -} - -static PASBackendSyncStatus -pas_backend_file_remove (PASBackendSync *backend, - PASBook *book) -{ - PASBackendFile *bf = PAS_BACKEND_FILE (backend); - struct dirent **namelist; - int n; - - if (-1 == unlink (bf->priv->filename)) { - if (errno == EACCES || errno == EPERM) - return GNOME_Evolution_Addressbook_PermissionDenied; - else - return GNOME_Evolution_Addressbook_OtherError; - } - - /* unref the summary before we remove the file so it's not written out again */ - g_object_unref (bf->priv->summary); - bf->priv->summary = NULL; - if (-1 == unlink (bf->priv->filename)) - g_warning ("failed to remove summary file `%s`: %s", bf->priv->summary_filename, strerror (errno)); - - /* scandir to select all the "*.changes.db" files, then remove them */ - n = scandir (bf->priv->dirname, - &namelist, select_changes, alphasort); - if (n < 0) { - g_warning ("scandir of directory `%s' failed: %s", bf->priv->dirname, strerror (errno)); - } - else { - while (n -- ) { - char *full_path = g_build_filename (bf->priv->dirname, namelist[n]->d_name, NULL); - if (-1 == unlink (full_path)) { - g_warning ("failed to remove change db `%s': %s", full_path, strerror (errno)); - } - g_free (full_path); - free (namelist[n]); - } - free (namelist); - } - - if (-1 == rmdir (bf->priv->dirname)) - g_warning ("failed to remove directory `%s`: %s", bf->priv->dirname, strerror (errno)); - - /* we may not have actually succeeded in removing the - backend's files/dirs, but there's nothing we can do about - it here.. the only time we should return failure is if we - failed to remove the actual data. a failure should mean - that the addressbook is still valid */ - return GNOME_Evolution_Addressbook_Success; -} - -static char * -pas_backend_file_get_static_capabilities (PASBackend *backend) -{ - return g_strdup("local,do-initial-query,bulk-removes"); -} - -static GNOME_Evolution_Addressbook_CallStatus -pas_backend_file_cancel_operation (PASBackend *backend, PASBook *book) -{ - return GNOME_Evolution_Addressbook_CouldNotCancel; -} - -static gboolean -pas_backend_file_construct (PASBackendFile *backend) -{ - g_assert (backend != NULL); - g_assert (PAS_IS_BACKEND_FILE (backend)); - - if (! pas_backend_construct (PAS_BACKEND (backend))) - return FALSE; - - return TRUE; -} - -/** - * pas_backend_file_new: - */ -PASBackend * -pas_backend_file_new (void) -{ - PASBackendFile *backend; - - backend = g_object_new (PAS_TYPE_BACKEND_FILE, NULL); - - if (! pas_backend_file_construct (backend)) { - g_object_unref (backend); - - return NULL; - } - - return PAS_BACKEND (backend); -} - -static void -pas_backend_file_dispose (GObject *object) -{ - PASBackendFile *bf; - - bf = PAS_BACKEND_FILE (object); - - if (bf->priv) { - if (bf->priv->summary) - g_object_unref(bf->priv->summary); - g_free (bf->priv->uri); - g_free (bf->priv->filename); - g_free (bf->priv->dirname); - g_free (bf->priv->summary_filename); - - g_free (bf->priv); - bf->priv = NULL; - } - - G_OBJECT_CLASS (pas_backend_file_parent_class)->dispose (object); -} - -static void -pas_backend_file_class_init (PASBackendFileClass *klass) -{ - GObjectClass *object_class = G_OBJECT_CLASS (klass); - PASBackendSyncClass *sync_class; - PASBackendClass *backend_class; - - pas_backend_file_parent_class = g_type_class_peek_parent (klass); - - sync_class = PAS_BACKEND_SYNC_CLASS (klass); - backend_class = PAS_BACKEND_CLASS (klass); - - /* Set the virtual methods. */ - backend_class->load_uri = pas_backend_file_load_uri; - backend_class->get_static_capabilities = pas_backend_file_get_static_capabilities; - backend_class->start_book_view = pas_backend_file_start_book_view; - backend_class->stop_book_view = pas_backend_file_stop_book_view; - backend_class->cancel_operation = pas_backend_file_cancel_operation; - - sync_class->remove_sync = pas_backend_file_remove; - sync_class->create_contact_sync = pas_backend_file_create_contact; - sync_class->remove_contacts_sync = pas_backend_file_remove_contacts; - sync_class->modify_contact_sync = pas_backend_file_modify_contact; - sync_class->get_contact_sync = pas_backend_file_get_contact; - sync_class->get_contact_list_sync = pas_backend_file_get_contact_list; - sync_class->get_changes_sync = pas_backend_file_get_changes; - sync_class->authenticate_user_sync = pas_backend_file_authenticate_user; - sync_class->get_supported_fields_sync = pas_backend_file_get_supported_fields; - - object_class->dispose = pas_backend_file_dispose; -} - -static void -pas_backend_file_init (PASBackendFile *backend) -{ - PASBackendFilePrivate *priv; - - priv = g_new0 (PASBackendFilePrivate, 1); - priv->uri = NULL; - - backend->priv = priv; -} - -/** - * pas_backend_file_get_type: - */ -GType -pas_backend_file_get_type (void) -{ - static GType type = 0; - - if (! type) { - GTypeInfo info = { - sizeof (PASBackendFileClass), - NULL, /* base_class_init */ - NULL, /* base_class_finalize */ - (GClassInitFunc) pas_backend_file_class_init, - NULL, /* class_finalize */ - NULL, /* class_data */ - sizeof (PASBackendFile), - 0, /* n_preallocs */ - (GInstanceInitFunc) pas_backend_file_init - }; - - type = g_type_register_static (PAS_TYPE_BACKEND_SYNC, "PASBackendFile", &info, 0); - } - - return type; -} diff --git a/addressbook/backend/pas/pas-backend-file.h b/addressbook/backend/pas/pas-backend-file.h deleted file mode 100644 index 6e1a77b119..0000000000 --- a/addressbook/backend/pas/pas-backend-file.h +++ /dev/null @@ -1,32 +0,0 @@ -/* - * Copyright 2000, Ximian, Inc. - */ - -#ifndef __PAS_BACKEND_FILE_H__ -#define __PAS_BACKEND_FILE_H__ - -#include "pas-backend-sync.h" - -#define PAS_TYPE_BACKEND_FILE (pas_backend_file_get_type ()) -#define PAS_BACKEND_FILE(o) (G_TYPE_CHECK_INSTANCE_CAST ((o), PAS_TYPE_BACKEND_FILE, PASBackendFile)) -#define PAS_BACKEND_FILE_CLASS(k) (G_TYPE_CHECK_CLASS_CAST((k), PAS_BACKEND_TYPE, PASBackendFileClass)) -#define PAS_IS_BACKEND_FILE(o) (G_TYPE_CHECK_INSTANCE_TYPE ((o), PAS_TYPE_BACKEND_FILE)) -#define PAS_IS_BACKEND_FILE_CLASS(k) (G_TYPE_CHECK_CLASS_TYPE ((k), PAS_TYPE_BACKEND_FILE)) -#define PAS_BACKEND_FILE_GET_CLASS(k) (G_TYPE_INSTANCE_GET_CLASS ((obj), PAS_TYPE_BACKEND_FILE, PASBackendFileClass)) - -typedef struct _PASBackendFilePrivate PASBackendFilePrivate; - -typedef struct { - PASBackendSync parent_object; - PASBackendFilePrivate *priv; -} PASBackendFile; - -typedef struct { - PASBackendSyncClass parent_class; -} PASBackendFileClass; - -PASBackend *pas_backend_file_new (void); -GType pas_backend_file_get_type (void); - -#endif /* ! __PAS_BACKEND_FILE_H__ */ - diff --git a/addressbook/backend/pas/pas-backend-ldap.c b/addressbook/backend/pas/pas-backend-ldap.c deleted file mode 100644 index d4aa4ea82d..0000000000 --- a/addressbook/backend/pas/pas-backend-ldap.c +++ /dev/null @@ -1,3206 +0,0 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */ -/* - * Author: - * Chris Toshok (toshok@ximian.com) - * - * Copyright 2000, Ximian, Inc. - */ - -#define DEBUG - -#include "config.h" -#include <fcntl.h> -#include <string.h> - -#ifdef DEBUG -#define LDAP_DEBUG -#define LDAP_DEBUG_ADD -#endif -#include <ldap.h> -#ifdef DEBUG -#undef LDAP_DEBUG -#endif - -#if LDAP_VENDOR_VERSION > 20000 -#define OPENLDAP2 -#else -#define OPENLDAP1 -#endif - -#ifdef OPENLDAP2 -#include <ldap_schema.h> -#endif - -#include <sys/time.h> - -#include <e-util/e-sexp.h> -#include <ebook/e-contact.h> -#include <libgnome/gnome-i18n.h> - -#include "pas-backend-ldap.h" -#include "pas-backend-card-sexp.h" -#include "pas-book.h" -#include "pas-book-view.h" - -#include <stdlib.h> - -/* this is broken currently, don't enable it */ -/*#define ENABLE_SASL_BINDS*/ - -typedef enum { - PAS_BACKEND_LDAP_TLS_NO, - PAS_BACKEND_LDAP_TLS_ALWAYS, - PAS_BACKEND_LDAP_TLS_WHEN_POSSIBLE, -} PASBackendLDAPUseTLS; - -/* interval for our poll_ldap timeout */ -#define LDAP_POLL_INTERVAL 20 - -/* timeout for ldap_result */ -#define LDAP_RESULT_TIMEOUT_MILLIS 10 - -#define TV_TO_MILLIS(timeval) ((timeval).tv_sec * 1000 + (timeval).tv_usec / 1000) - -/* the objectClasses we need */ -#define TOP "top" -#define PERSON "person" -#define ORGANIZATIONALPERSON "organizationalPerson" -#define INETORGPERSON "inetOrgPerson" -#define CALENTRY "calEntry" -#define EVOLUTIONPERSON "evolutionPerson" - -static gchar *query_prop_to_ldap(gchar *query_prop); - -static PASBackendClass *pas_backend_ldap_parent_class; -typedef struct _PASBackendLDAPCursorPrivate PASBackendLDAPCursorPrivate; -typedef struct _PASBackendLDAPBookView PASBackendLDAPBookView; -typedef struct LDAPOp LDAPOp; - - -struct _PASBackendLDAPPrivate { - char *uri; - gboolean connected; - - gchar *ldap_host; /* the hostname of the server */ - int ldap_port; /* the port of the server */ - char *schema_dn; /* the base dn for schema information */ - gchar *ldap_rootdn; /* the base dn of our searches */ - int ldap_scope; /* the scope used for searches */ - int ldap_limit; /* the search limit */ - int ldap_timeout; /* the search timeout */ - - gchar *auth_dn; - gchar *auth_passwd; - - gboolean ldap_v3; /* TRUE if the server supports protocol - revision 3 (necessary for TLS) */ - gboolean starttls; /* TRUE if the *library* supports - starttls. will be false if openssl - was not built into openldap. */ - PASBackendLDAPUseTLS use_tls; - - LDAP *ldap; - - GList *supported_fields; - GList *supported_auth_methods; - - /* whether or not there's support for the objectclass we need - to store all our additional fields */ - gboolean evolutionPersonSupported; - gboolean calEntrySupported; - gboolean evolutionPersonChecked; - - /* our operations */ - GHashTable *id_to_op; - int active_ops; - int poll_timeout; -}; - -struct _PASBackendLDAPCursorPrivate { - PASBackend *backend; - PASBook *book; - - GList *elements; - long num_elements; -}; - -struct _PASBackendLDAPBookView { - PASBookView *book_view; - PASBackendLDAPPrivate *blpriv; - gchar *search; - int limit; - - LDAPOp *search_op; -}; - -typedef void (*LDAPOpHandler)(LDAPOp *op, LDAPMessage *res); -typedef void (*LDAPOpDtor)(LDAPOp *op); - -struct LDAPOp { - LDAPOpHandler handler; - LDAPOpDtor dtor; - PASBackend *backend; - PASBook *book; - PASBookView *view; - int id; -}; - -static void ldap_op_add (LDAPOp *op, PASBackend *backend, PASBook *book, - PASBookView *view, int id, LDAPOpHandler handler, LDAPOpDtor dtor); -static void ldap_op_finished (LDAPOp *op); - -static gboolean poll_ldap (PASBackendLDAP *bl); - -static EContact *build_contact_from_entry (LDAP *ldap, LDAPMessage *e, GList **existing_objectclasses); - -static void email_populate (EContact *contact, char **values); -struct berval** email_ber (EContact *contact); -static gboolean email_compare (EContact *contact1, EContact *contact2); - -static void homephone_populate (EContact *contact, char **values); -struct berval** homephone_ber (EContact *contact); -static gboolean homephone_compare (EContact *contact1, EContact *contact2); - -static void business_populate (EContact *contact, char **values); -struct berval** business_ber (EContact *contact); -static gboolean business_compare (EContact *contact1, EContact *contact2); - -static void anniversary_populate (EContact *contact, char **values); -struct berval** anniversary_ber (EContact *contact); -static gboolean anniversary_compare (EContact *contact1, EContact *contact2); - -static void birthday_populate (EContact *contact, char **values); -struct berval** birthday_ber (EContact *contact); -static gboolean birthday_compare (EContact *contact1, EContact *contact2); - -static void category_populate (EContact *contact, char **values); -struct berval** category_ber (EContact *contact); -static gboolean category_compare (EContact *contact1, EContact *contact2); - -static void photo_populate (EContact *contact, struct berval **ber_values); - -struct prop_info { - EContactField field_id; - char *ldap_attr; -#define PROP_TYPE_STRING 0x01 -#define PROP_TYPE_COMPLEX 0x02 -#define PROP_TYPE_BINARY 0x04 -#define PROP_DN 0x08 -#define PROP_EVOLVE 0x10 -#define PROP_WRITE_ONLY 0x20 - int prop_type; - - /* the remaining items are only used for the TYPE_COMPLEX props */ - - /* used when reading from the ldap server populates EContact with the values in **values. */ - void (*populate_contact_func)(EContact *contact, char **values); - /* used when writing to an ldap server. returns a NULL terminated array of berval*'s */ - struct berval** (*ber_func)(EContact *contact); - /* used to compare list attributes */ - gboolean (*compare_func)(EContact *contact1, EContact *contact2); - - void (*binary_populate_contact_func)(EContact *contact, struct berval **ber_values); - -} prop_info[] = { - -#define BINARY_PROP(fid,a,ctor,ber,cmp) {fid, a, PROP_TYPE_BINARY, NULL, ber, cmp, ctor} -#define COMPLEX_PROP(fid,a,ctor,ber,cmp) {fid, a, PROP_TYPE_COMPLEX, ctor, ber, cmp} -#define E_COMPLEX_PROP(fid,a,ctor,ber,cmp) {fid, a, PROP_TYPE_COMPLEX | PROP_EVOLVE, ctor, ber, cmp} -#define STRING_PROP(fid,a) {fid, a, PROP_TYPE_STRING} -#define WRITE_ONLY_STRING_PROP(fid,a) {fid, a, PROP_TYPE_STRING | PROP_WRITE_ONLY} -#define E_STRING_PROP(fid,a) {fid, a, PROP_TYPE_STRING | PROP_EVOLVE} - - - /* name fields */ - STRING_PROP (E_CONTACT_FULL_NAME, "cn" ), - WRITE_ONLY_STRING_PROP (E_CONTACT_FAMILY_NAME, "sn" ), - - /* email addresses */ - COMPLEX_PROP (E_CONTACT_EMAIL, "mail", email_populate, email_ber, email_compare), - - /* phone numbers */ - E_STRING_PROP (E_CONTACT_PHONE_PRIMARY, "primaryPhone"), - COMPLEX_PROP (E_CONTACT_PHONE_BUSINESS, "telephoneNumber", business_populate, business_ber, business_compare), - COMPLEX_PROP (E_CONTACT_PHONE_HOME, "homePhone", homephone_populate, homephone_ber, homephone_compare), - STRING_PROP (E_CONTACT_PHONE_MOBILE, "mobile"), - E_STRING_PROP (E_CONTACT_PHONE_CAR, "carPhone"), - STRING_PROP (E_CONTACT_PHONE_BUSINESS_FAX, "facsimileTelephoneNumber"), - E_STRING_PROP (E_CONTACT_PHONE_HOME_FAX, "homeFacsimileTelephoneNumber"), - E_STRING_PROP (E_CONTACT_PHONE_OTHER, "otherPhone"), - E_STRING_PROP (E_CONTACT_PHONE_OTHER_FAX, "otherFacsimileTelephoneNumber"), - STRING_PROP (E_CONTACT_PHONE_ISDN, "internationaliSDNNumber"), - STRING_PROP (E_CONTACT_PHONE_PAGER, "pager"), - E_STRING_PROP (E_CONTACT_PHONE_RADIO, "radio"), - E_STRING_PROP (E_CONTACT_PHONE_TELEX, "telex"), - E_STRING_PROP (E_CONTACT_PHONE_ASSISTANT, "assistantPhone"), - E_STRING_PROP (E_CONTACT_PHONE_COMPANY, "companyPhone"), - E_STRING_PROP (E_CONTACT_PHONE_CALLBACK, "callbackPhone"), - E_STRING_PROP (E_CONTACT_PHONE_TTYTDD, "tty"), - - /* org information */ - STRING_PROP (E_CONTACT_ORG, "o"), - STRING_PROP (E_CONTACT_ORG_UNIT, "ou"), - STRING_PROP (E_CONTACT_OFFICE, "roomNumber"), - STRING_PROP (E_CONTACT_TITLE, "title"), - E_STRING_PROP (E_CONTACT_ROLE, "businessRole"), - E_STRING_PROP (E_CONTACT_MANAGER, "managerName"), - E_STRING_PROP (E_CONTACT_ASSISTANT, "assistantName"), - - /* addresses */ - STRING_PROP (E_CONTACT_ADDRESS_LABEL_WORK, "postalAddress"), - STRING_PROP (E_CONTACT_ADDRESS_LABEL_HOME, "homePostalAddress"), - E_STRING_PROP (E_CONTACT_ADDRESS_LABEL_OTHER, "otherPostalAddress"), - - /* photos */ - BINARY_PROP (E_CONTACT_PHOTO, "jpegPhoto", photo_populate, NULL/*XXX*/, NULL/*XXX*/), - - /* misc fields */ - STRING_PROP (E_CONTACT_HOMEPAGE_URL, "labeledURI"), - /* map nickname to displayName */ - STRING_PROP (E_CONTACT_NICKNAME, "displayName"), - E_STRING_PROP (E_CONTACT_SPOUSE, "spouseName"), - E_STRING_PROP (E_CONTACT_NOTE, "note"), - E_COMPLEX_PROP (E_CONTACT_ANNIVERSARY, "anniversary", anniversary_populate, anniversary_ber, anniversary_compare), - E_COMPLEX_PROP (E_CONTACT_BIRTH_DATE, "birthDate", birthday_populate, birthday_ber, birthday_compare), - E_STRING_PROP (E_CONTACT_MAILER, "mailer"), - - E_STRING_PROP (E_CONTACT_FILE_AS, "fileAs"), -#if notyet - E_COMPLEX_PROP (E_CONTACT_CATEGORIES, "category", category_populate, category_ber, category_compare), - - STRING_PROP (E_CONTACT_CALURI, "calCalURI"), - STRING_PROP (E_CONTACT_FBURL, "calFBURL"), - STRING_PROP (E_CONTACT_ICSCALENDAR, "icsCalendar"), -#endif - -#undef E_STRING_PROP -#undef STRING_PROP -#undef E_COMPLEX_PROP -#undef COMPLEX_PROP -}; - -static int num_prop_infos = sizeof(prop_info) / sizeof(prop_info[0]); - -#if 0 -static void -remove_view (int msgid, LDAPOp *op, PASBookView *view) -{ - if (op->view == view) - op->view = NULL; -} - -static void -view_destroy(gpointer data, GObject *where_object_was) -{ - PASBook *book = (PASBook *)data; - PASBackendLDAP *bl; - EIterator *iter; - - bl = PAS_BACKEND_LDAP(pas_book_get_backend(book)); - - iter = e_list_get_iterator (bl->priv->book_views); - - while (e_iterator_is_valid (iter)) { - PASBackendLDAPBookView *view = (PASBackendLDAPBookView*)e_iterator_get (iter); - - if (view->book_view == (PASBookView*)where_object_was) { - GNOME_Evolution_Addressbook_Book corba_book; - CORBA_Environment ev; - - /* if we have an active search, interrupt it */ - if (view->search_op) { - ldap_op_finished (view->search_op); - } - /* and remove us as the view for any other - operations that might be using us to spew - status messages to the gui */ - g_hash_table_foreach (bl->priv->id_to_op, (GHFunc)remove_view, view->book_view); - - /* free up the view structure */ - g_free (view->search); - g_free (view); - - /* and remove it from our list */ - e_iterator_delete (iter); - - /* unref the book now */ - corba_book = bonobo_object_corba_objref(BONOBO_OBJECT(book)); - - CORBA_exception_init(&ev); - - GNOME_Evolution_Addressbook_Book_unref(corba_book, &ev); - - if (ev._major != CORBA_NO_EXCEPTION) { - g_warning("view_destroy: Exception unreffing " - "corba book.\n"); - } - - CORBA_exception_free(&ev); - break; - } - - e_iterator_next (iter); - } - - g_object_unref (iter); - -} -#endif - -static void -book_view_notify_status (PASBookView *view, const char *status) -{ - if (!view) - return; - pas_book_view_notify_status_message (view, status); -} - -static PASBookView* -find_book_view (PASBackendLDAP *bl) -{ -#if 0 - EIterator *iter = e_list_get_iterator (bl->priv->book_views); - PASBookView *rv = NULL; - - if (e_iterator_is_valid (iter)) { - /* just always use the first book view */ - PASBackendLDAPBookView *v = (PASBackendLDAPBookView*)e_iterator_get(iter); - if (v) - rv = v->book_view; - } - - g_object_unref (iter); - - return rv; -#endif -} - -static void -add_to_supported_fields (PASBackendLDAP *bl, char **attrs, GHashTable *attr_hash) -{ - int i; - for (i = 0; attrs[i]; i ++) { - char *query_prop = g_hash_table_lookup (attr_hash, g_strdup (attrs[i])); - - if (query_prop) { - bl->priv->supported_fields = g_list_append (bl->priv->supported_fields, g_strdup (query_prop)); - - /* handle the list attributes here */ - if (!strcmp (query_prop, "email")) { - bl->priv->supported_fields = g_list_append (bl->priv->supported_fields, g_strdup ("email_2")); - bl->priv->supported_fields = g_list_append (bl->priv->supported_fields, g_strdup ("email_3")); - } - else if (!strcmp (query_prop, "business_phone")) { - bl->priv->supported_fields = g_list_append (bl->priv->supported_fields, g_strdup ("business_phone_2")); - } - else if (!strcmp (query_prop, "home_phone")) { - bl->priv->supported_fields = g_list_append (bl->priv->supported_fields, g_strdup ("home_phone_2")); - } - } - } -} - -static void -add_oc_attributes_to_supported_fields (PASBackendLDAP *bl, LDAPObjectClass *oc) -{ - int i; - GHashTable *attr_hash = g_hash_table_new (g_str_hash, g_str_equal); - - for (i = 0; i < num_prop_infos; i ++) - g_hash_table_insert (attr_hash, prop_info[i].ldap_attr, (char*)e_contact_field_name (prop_info[i].field_id)); - - if (oc->oc_at_oids_must) - add_to_supported_fields (bl, oc->oc_at_oids_must, attr_hash); - - if (oc->oc_at_oids_may) - add_to_supported_fields (bl, oc->oc_at_oids_may, attr_hash); - - g_hash_table_destroy (attr_hash); -} - -static void -check_schema_support (PASBackendLDAP *bl) -{ - char *attrs[2]; - LDAPMessage *resp; - LDAP *ldap = bl->priv->ldap; - struct timeval timeout; - - if (!bl->priv->schema_dn) - return; - - bl->priv->evolutionPersonChecked = TRUE; - - attrs[0] = "objectClasses"; - attrs[1] = NULL; - - timeout.tv_sec = 30; - timeout.tv_usec = 0; - - if (ldap_search_ext_s (ldap, bl->priv->schema_dn, LDAP_SCOPE_BASE, - "(objectClass=subschema)", attrs, 0, - NULL, NULL, &timeout, LDAP_NO_LIMIT, &resp) == LDAP_SUCCESS) { - char **values; - - values = ldap_get_values (ldap, resp, "objectClasses"); - - if (values) { - int i; - for (i = 0; values[i]; i ++) { - int j; - int code; - const char *err; - LDAPObjectClass *oc = ldap_str2objectclass (values[i], &code, &err, 0); - - if (!oc) - continue; - - for (j = 0; oc->oc_names[j]; j++) - if (!g_ascii_strcasecmp (oc->oc_names[j], EVOLUTIONPERSON)) { - g_print ("support found on ldap server for objectclass evolutionPerson\n"); - bl->priv->evolutionPersonSupported = TRUE; - - add_oc_attributes_to_supported_fields (bl, oc); - } - else if (!g_ascii_strcasecmp (oc->oc_names[j], CALENTRY)) { - g_print ("support found on ldap server for objectclass calEntry\n"); - bl->priv->calEntrySupported = TRUE; - add_oc_attributes_to_supported_fields (bl, oc); - } - else if (!g_ascii_strcasecmp (oc->oc_names[j], INETORGPERSON) - || !g_ascii_strcasecmp (oc->oc_names[j], ORGANIZATIONALPERSON) - || !g_ascii_strcasecmp (oc->oc_names[j], PERSON)) { - add_oc_attributes_to_supported_fields (bl, oc); - } - - ldap_objectclass_free (oc); - } - - ldap_value_free (values); - } - else { - /* the reason for this is so that if the user - ends up authenticating to the ldap server, - we will requery for the subschema values. - This makes it a bit more robust in the face - of draconian acl's that keep subschema - reads from working until the user is - authed. */ - if (!pas_backend_is_writable (PAS_BACKEND (bl))) { - g_warning ("subschema read returned nothing before successful auth"); - bl->priv->evolutionPersonChecked = FALSE; - } - else { - g_warning ("subschema read returned nothing after successful auth"); - } - } - - ldap_msgfree (resp); - } -} - -static void -get_ldap_library_info () -{ - LDAPAPIInfo info; - LDAP *ldap; - - if (LDAP_SUCCESS != ldap_create (&ldap)) { - g_warning ("couldn't create LDAP* for getting at the client lib api info"); - return; - } - - info.ldapai_info_version = LDAP_API_INFO_VERSION; - - if (LDAP_OPT_SUCCESS != ldap_get_option (ldap, LDAP_OPT_API_INFO, &info)) { - g_warning ("couldn't get ldap api info"); - } - else { - int i; - g_message ("libldap vendor/version: %s %2d.%02d.%02d", - info.ldapai_vendor_name, - info.ldapai_vendor_version / 10000, - (info.ldapai_vendor_version % 10000) / 1000, - info.ldapai_vendor_version % 1000); - - g_message ("extensions present:"); - /* yuck. we have to free these? */ - for (i = 0; info.ldapai_extensions[i]; i++) { - char *extension = info.ldapai_extensions[i]; - g_message (extension); - ldap_memfree (extension); - } - ldap_memfree (info.ldapai_extensions); - ldap_memfree (info.ldapai_vendor_name); - } - - ldap_unbind_ext_s (ldap, NULL, NULL); -} - -static int -query_ldap_root_dse (PASBackendLDAP *bl) -{ -#define MAX_DSE_ATTRS 20 - LDAP *ldap = bl->priv->ldap; - LDAPMessage *resp; - int ldap_error; - char *attrs[MAX_DSE_ATTRS], **values; - int i = 0; - struct timeval timeout; - - attrs[i++] = "supportedControl"; - attrs[i++] = "supportedExtension"; - attrs[i++] = "supportedFeatures"; - attrs[i++] = "supportedSASLMechanisms"; - attrs[i++] = "supportedLDAPVersion"; - attrs[i++] = "subschemaSubentry"; /* OpenLDAP's dn for schema information */ - attrs[i++] = "schemaNamingContext"; /* Active directory's dn for schema information */ - attrs[i] = NULL; - - timeout.tv_sec = 30; - timeout.tv_usec = 0; - - ldap_error = ldap_search_ext_s (ldap, - LDAP_ROOT_DSE, LDAP_SCOPE_BASE, - "(objectclass=*)", - attrs, 0, NULL, NULL, &timeout, LDAP_NO_LIMIT, &resp); - if (ldap_error != LDAP_SUCCESS) { - g_warning ("could not perform query on Root DSE (ldap_error 0x%02x)", ldap_error); - return ldap_error; - } - - values = ldap_get_values (ldap, resp, "supportedControl"); - if (values) { - for (i = 0; values[i]; i++) - g_message ("supported server control: %s", values[i]); - ldap_value_free (values); - } - - values = ldap_get_values (ldap, resp, "supportedExtension"); - if (values) { - for (i = 0; values[i]; i++) { - g_message ("supported server extension: %s", values[i]); - if (!strcmp (values[i], LDAP_EXOP_START_TLS)) { - g_message ("server reports LDAP_EXOP_START_TLS"); - } - } - ldap_value_free (values); - } - - values = ldap_get_values (ldap, resp, "supportedSASLMechanisms"); - if (values) { - char *auth_method; - if (bl->priv->supported_auth_methods) { - g_list_foreach (bl->priv->supported_auth_methods, (GFunc)g_free, NULL); - g_list_free (bl->priv->supported_auth_methods); - } - bl->priv->supported_auth_methods = NULL; - - auth_method = g_strdup_printf ("ldap/simple-binddn|%s", _("Using Distinguished Name (DN)")); - bl->priv->supported_auth_methods = g_list_append (bl->priv->supported_auth_methods, auth_method); - - auth_method = g_strdup_printf ("ldap/simple-email|%s", _("Using Email Address")); - bl->priv->supported_fields = g_list_append (bl->priv->supported_auth_methods, auth_method); - - for (i = 0; values[i]; i++) { - auth_method = g_strdup_printf ("sasl/%s|%s", values[i], values[i]); - bl->priv->supported_fields = g_list_append (bl->priv->supported_auth_methods, auth_method); - g_message ("supported SASL mechanism: %s", values[i]); - } - ldap_value_free (values); - } - - - values = ldap_get_values (ldap, resp, "subschemaSubentry"); - if (!values || !values[0]) { - if (values) ldap_value_free (values); - values = ldap_get_values (ldap, resp, "schemaNamingContext"); - } - if (values && values[0]) { - g_free (bl->priv->schema_dn); - bl->priv->schema_dn = g_strdup (values[0]); - } - else { - g_warning ("could not determine location of schema information on LDAP server"); - } - if (values) - ldap_value_free (values); - - ldap_msgfree (resp); - - return LDAP_SUCCESS; -} - -static GNOME_Evolution_Addressbook_CallStatus -pas_backend_ldap_connect (PASBackendLDAP *bl) -{ - PASBackendLDAPPrivate *blpriv = bl->priv; - - /* close connection first if it's open first */ - if (blpriv->ldap) - ldap_unbind_ext (blpriv->ldap, NULL, NULL); - - blpriv->ldap = ldap_init (blpriv->ldap_host, blpriv->ldap_port); -#if defined (DEBUG) && defined (LDAP_OPT_DEBUG_LEVEL) - { - int debug_level = 4; - ldap_set_option (blpriv->ldap, LDAP_OPT_DEBUG_LEVEL, &debug_level); - } -#endif - - if (NULL != blpriv->ldap) { - int ldap_error; - - if (bl->priv->use_tls != PAS_BACKEND_LDAP_TLS_NO) { - int protocol_version = LDAP_VERSION3; - ldap_error = ldap_set_option (blpriv->ldap, LDAP_OPT_PROTOCOL_VERSION, &protocol_version); - if (LDAP_OPT_SUCCESS != ldap_error) { - g_warning ("failed to set protocol version to LDAPv3"); - bl->priv->ldap_v3 = FALSE; - } - else - bl->priv->ldap_v3 = TRUE; - - if (!bl->priv->ldap_v3 && bl->priv->use_tls == PAS_BACKEND_LDAP_TLS_ALWAYS) { - g_message ("TLS not available (fatal version), v3 protocol could not be established (ldap_error 0x%02x)", ldap_error); - ldap_unbind (blpriv->ldap); - blpriv->ldap = NULL; - return GNOME_Evolution_Addressbook_TLSNotAvailable; - } - - if (bl->priv->ldap_port == LDAPS_PORT && bl->priv->use_tls == PAS_BACKEND_LDAP_TLS_ALWAYS) { - int tls_level = LDAP_OPT_X_TLS_HARD; - ldap_set_option (blpriv->ldap, LDAP_OPT_X_TLS, &tls_level); - } - else if (bl->priv->use_tls) { - ldap_error = ldap_start_tls_s (blpriv->ldap, NULL, NULL); - if (LDAP_SUCCESS != ldap_error) { - if (bl->priv->use_tls == PAS_BACKEND_LDAP_TLS_ALWAYS) { - g_message ("TLS not available (fatal version), (ldap_error 0x%02x)", ldap_error); - ldap_unbind (blpriv->ldap); - blpriv->ldap = NULL; - return GNOME_Evolution_Addressbook_TLSNotAvailable; - } - else { - g_message ("TLS not available (ldap_error 0x%02x)", ldap_error); - } - } - else - g_message ("TLS active"); - } - } - - /* bind anonymously initially, we'll actually - authenticate the user properly later (in - authenticate_user) if they've selected - authentication */ - ldap_error = ldap_simple_bind_s (blpriv->ldap, NULL, NULL); - if (ldap_error == LDAP_SERVER_DOWN) { - /* we only want this to be fatal if the server is down. */ - g_warning ("failed to bind anonymously while connecting (ldap_error 0x%02x)", ldap_error); - return GNOME_Evolution_Addressbook_RepositoryOffline; - } - - ldap_error = query_ldap_root_dse (bl); - /* query_ldap_root_dse will cause the actual - connect(), so any tcpip problems will show up - here */ - - /* we can't just check for LDAP_SUCCESS here since in - older servers (namely openldap1.x servers), there's - not a root DSE at all, so the query will fail with - LDAP_NO_SUCH_OBJECT. */ - if (ldap_error == LDAP_SUCCESS || LDAP_NAME_ERROR (ldap_error)) { - blpriv->connected = TRUE; - - /* check to see if evolutionPerson is supported, if we can (me - might not be able to if we can't authenticate. if we - can't, try again in auth_user.) */ - if (!bl->priv->evolutionPersonChecked) - check_schema_support (bl); - - pas_backend_set_is_loaded (PAS_BACKEND (bl), TRUE); - return GNOME_Evolution_Addressbook_Success; - } - else - g_warning ("Failed to perform root dse query anonymously, (ldap_error 0x%02x)", ldap_error); - } - - g_warning ("pas_backend_ldap_connect failed for " - "'ldap://%s:%d/%s'\n", - blpriv->ldap_host, - blpriv->ldap_port, - blpriv->ldap_rootdn ? blpriv->ldap_rootdn : ""); - blpriv->connected = FALSE; - return GNOME_Evolution_Addressbook_RepositoryOffline; -} - -static gboolean -pas_backend_ldap_reconnect (PASBackendLDAP *bl, PASBookView *book_view, int ldap_status) -{ - /* we need to reconnect if we were previously connected */ - if (bl->priv->connected && ldap_status == LDAP_SERVER_DOWN) { - GNOME_Evolution_Addressbook_CallStatus status; - int ldap_error = LDAP_SUCCESS; - - book_view_notify_status (book_view, _("Reconnecting to LDAP server...")); - - status = pas_backend_ldap_connect (bl); - - if (status != GNOME_Evolution_Addressbook_Success) { - book_view_notify_status (book_view, ""); - return FALSE; - } - - if (bl->priv->auth_dn) - ldap_error = ldap_simple_bind_s(bl->priv->ldap, - bl->priv->auth_dn, - bl->priv->auth_passwd); - book_view_notify_status (book_view, ""); - return (ldap_error == LDAP_SUCCESS); - } - else { - return FALSE; - } -} - -static void -ldap_op_add (LDAPOp *op, PASBackend *backend, - PASBook *book, PASBookView *view, - int id, - LDAPOpHandler handler, LDAPOpDtor dtor) -{ - PASBackendLDAP *bl = PAS_BACKEND_LDAP (backend); - - op->backend = backend; - op->book = book; - op->view = view; - op->id = id; - op->handler = handler; - op->dtor = dtor; - - if (g_hash_table_lookup (bl->priv->id_to_op, &op->id)) { - g_warning ("conflicting ldap msgid's"); - } - - g_hash_table_insert (bl->priv->id_to_op, - &op->id, op); - - bl->priv->active_ops ++; - - if (bl->priv->poll_timeout == -1) - bl->priv->poll_timeout = g_timeout_add (LDAP_POLL_INTERVAL, - (GSourceFunc) poll_ldap, - bl); -} - -static void -ldap_op_finished (LDAPOp *op) -{ - PASBackend *backend = op->backend; - PASBackendLDAP *bl = PAS_BACKEND_LDAP (backend); - - g_hash_table_remove (bl->priv->id_to_op, &op->id); - - /* should handle errors here */ - ldap_abandon (bl->priv->ldap, op->id); - - op->dtor (op); - - bl->priv->active_ops--; - - if (bl->priv->active_ops == 0) { - if (bl->priv->poll_timeout != -1) - g_source_remove (bl->priv->poll_timeout); - bl->priv->poll_timeout = -1; - } -} - -static void -ldap_op_change_id (LDAPOp *op, int msg_id) -{ - PASBackend *backend = op->backend; - PASBackendLDAP *bl = PAS_BACKEND_LDAP (backend); - - g_hash_table_remove (bl->priv->id_to_op, &op->id); - - op->id = msg_id; - - g_hash_table_insert (bl->priv->id_to_op, - &op->id, op); -} - -static int -ldap_error_to_response (int ldap_error) -{ - if (ldap_error == LDAP_SUCCESS) - return GNOME_Evolution_Addressbook_Success; - else if (LDAP_NAME_ERROR (ldap_error)) - return GNOME_Evolution_Addressbook_ContactNotFound; - else if (ldap_error == LDAP_INSUFFICIENT_ACCESS) - return GNOME_Evolution_Addressbook_PermissionDenied; - else if (ldap_error == LDAP_SERVER_DOWN) - return GNOME_Evolution_Addressbook_RepositoryOffline; - else if (ldap_error == LDAP_ALREADY_EXISTS) - return GNOME_Evolution_Addressbook_ContactIdAlreadyExists; - else - return GNOME_Evolution_Addressbook_OtherError; -} - - -static char * -create_dn_from_contact (EContact *contact, const char *root_dn) -{ - char *cn, *cn_part = NULL; - char *dn; - - cn = e_contact_get (contact, E_CONTACT_FULL_NAME); - if (cn) { - if (strchr (cn, ',')) { - /* need to escape commas */ - char *new_cn = g_malloc0 (strlen (cn) * 3 + 1); - int i, j; - - for (i = 0, j = 0; i < strlen (cn); i ++) { - if (cn[i] == ',') { - sprintf (new_cn + j, "%%%02X", cn[i]); - j += 3; - } - else { - new_cn[j++] = cn[i]; - } - } - cn_part = g_strdup_printf ("cn=%s", new_cn); - g_free (new_cn); - } - else { - cn_part = g_strdup_printf ("cn=%s", cn); - } - } - else { - cn_part = g_strdup (""); - } - - dn = g_strdup_printf ("%s%s%s", cn_part, - (root_dn && strlen(root_dn)) ? "," : "", - (root_dn && strlen(root_dn)) ? root_dn: ""); - - g_free (cn_part); - - g_print ("generated dn: %s\n", dn); - - return dn; -} - -static void -free_mods (GPtrArray *mods) -{ - int i = 0; - LDAPMod *mod; - - while ((mod = g_ptr_array_index (mods, i++))) { - int j; - g_free (mod->mod_type); - - if (mod->mod_op & LDAP_MOD_BVALUES) { - for (j = 0; mod->mod_bvalues[j]; j++) { - g_free (mod->mod_bvalues[j]->bv_val); - g_free (mod->mod_bvalues[j]); - } - } - else { - for (j = 0; mod->mod_values[j]; j++) - g_free (mod->mod_values[j]); - } - g_free (mod); - } - - g_ptr_array_free (mods, TRUE); -} - -static GPtrArray* -build_mods_from_contacts (PASBackendLDAP *bl, EContact *current, EContact *new, gboolean *new_dn_needed) -{ - gboolean adding = (current == NULL); - GPtrArray *result = g_ptr_array_new(); - int i; - - if (new_dn_needed) - *new_dn_needed = FALSE; - - /* we walk down the list of properties we can deal with (that - big table at the top of the file) */ - - for (i = 0; i < num_prop_infos; i ++) { - gboolean include; - gboolean new_prop_present = FALSE; - gboolean current_prop_present = FALSE; - struct berval** new_prop_bers = NULL; - char *new_prop = NULL; - char *current_prop = NULL; - - /* XXX if it's an evolutionPerson prop and the ldap - server doesn't support that objectclass, skip it. */ - if (prop_info[i].prop_type & PROP_EVOLVE && !bl->priv->evolutionPersonSupported) - continue; - - /* get the value for the new contact, and compare it to - the value in the current contact to see if we should - update it -- if adding is TRUE, short circuit the - check. */ - if (prop_info[i].prop_type & PROP_TYPE_STRING) { - new_prop = e_contact_get (new, prop_info[i].field_id); - new_prop_present = (new_prop != NULL); - } - else { - new_prop_bers = prop_info[i].ber_func (new); - new_prop_present = (new_prop_bers != NULL); - } - - /* need to set INCLUDE to true if the field needs to - show up in the ldap modify request */ - if (adding) { - /* if we're creating a new contact, include it if the - field is there at all */ - if (prop_info[i].prop_type & PROP_TYPE_STRING) - include = (new_prop_present && *new_prop); /* empty strings cause problems */ - else - include = new_prop_present; - } - else { - /* if we're modifying an existing contact, - include it if the current field value is - different than the new one, if it didn't - exist previously, or if it's been - removed. */ - if (prop_info[i].prop_type & PROP_TYPE_STRING) { - current_prop = e_contact_get (current, prop_info[i].field_id); - current_prop_present = (current_prop != NULL); - - if (new_prop && current_prop) - include = *new_prop && strcmp (new_prop, current_prop); - else - include = (!!new_prop != !!current_prop); - } - else { - int j; - struct berval **current_prop_bers = prop_info[i].ber_func (current); - - current_prop_present = (current_prop_bers != NULL); - - /* free up the current_prop_bers */ - if (current_prop_bers) { - for (j = 0; current_prop_bers[j]; j++) { - g_free (current_prop_bers[j]->bv_val); - g_free (current_prop_bers[j]); - } - g_free (current_prop_bers); - } - - include = !prop_info[i].compare_func (new, current); - } - } - - if (include) { - LDAPMod *mod = g_new (LDAPMod, 1); - - /* the included attribute has changed - we - need to update the dn if it's one of the - attributes we compute the dn from. */ - if (new_dn_needed) - *new_dn_needed |= prop_info[i].prop_type & PROP_DN; - - if (adding) { - mod->mod_op = LDAP_MOD_ADD; - } - else { - if (!new_prop_present) - mod->mod_op = LDAP_MOD_DELETE; - else if (!current_prop_present) - mod->mod_op = LDAP_MOD_ADD; - else - mod->mod_op = LDAP_MOD_REPLACE; - } - - mod->mod_type = g_strdup (prop_info[i].ldap_attr); - - if (prop_info[i].prop_type & PROP_TYPE_STRING) { - mod->mod_values = g_new (char*, 2); - mod->mod_values[0] = new_prop; - mod->mod_values[1] = NULL; - } - else { /* PROP_TYPE_COMPLEX */ - mod->mod_op |= LDAP_MOD_BVALUES; - mod->mod_bvalues = new_prop_bers; - } - - g_ptr_array_add (result, mod); - } - - } - - /* NULL terminate the list of modifications */ - g_ptr_array_add (result, NULL); - - return result; -} - -static void -add_objectclass_mod (PASBackendLDAP *bl, GPtrArray *mod_array, GList *existing_objectclasses) -{ -#define FIND_INSERT(oc) \ - if (!g_list_find_custom (existing_objectclasses, (oc), (GCompareFunc)g_ascii_strcasecmp)) \ - g_ptr_array_add (objectclasses, g_strdup ((oc))) -#define INSERT(oc) \ - g_ptr_array_add (objectclasses, g_strdup ((oc))) - - LDAPMod *objectclass_mod; - GPtrArray *objectclasses = g_ptr_array_new(); - - if (existing_objectclasses) { - objectclass_mod = g_new (LDAPMod, 1); - objectclass_mod->mod_op = LDAP_MOD_ADD; - objectclass_mod->mod_type = g_strdup ("objectClass"); - - /* yes, this is a linear search for each of our - objectclasses, but really, how many objectclasses - are there going to be in any sane ldap entry? */ - FIND_INSERT (TOP); - FIND_INSERT (PERSON); - FIND_INSERT (ORGANIZATIONALPERSON); - FIND_INSERT (INETORGPERSON); - if (bl->priv->calEntrySupported) - FIND_INSERT (CALENTRY); - if (bl->priv->evolutionPersonSupported) - FIND_INSERT (EVOLUTIONPERSON); - - if (objectclasses->len) { - g_ptr_array_add (objectclasses, NULL); - objectclass_mod->mod_values = (char**)objectclasses->pdata; - g_ptr_array_add (mod_array, objectclass_mod); - g_ptr_array_free (objectclasses, FALSE); - } - else { - g_ptr_array_free (objectclasses, TRUE); - g_free (objectclass_mod->mod_type); - g_free (objectclass_mod); - } - - } - else { - objectclass_mod = g_new (LDAPMod, 1); - objectclass_mod->mod_op = LDAP_MOD_ADD; - objectclass_mod->mod_type = g_strdup ("objectClass"); - - INSERT(TOP); - INSERT(PERSON); - INSERT(ORGANIZATIONALPERSON); - INSERT(INETORGPERSON); - if (bl->priv->calEntrySupported) - INSERT(CALENTRY); - if (bl->priv->evolutionPersonSupported) - INSERT(EVOLUTIONPERSON); - g_ptr_array_add (objectclasses, NULL); - objectclass_mod->mod_values = (char**)objectclasses->pdata; - g_ptr_array_add (mod_array, objectclass_mod); - g_ptr_array_free (objectclasses, FALSE); - } -} - -typedef struct { - LDAPOp op; - char *dn; - EContact *new_contact; -} LDAPCreateOp; - -static void -create_contact_handler (LDAPOp *op, LDAPMessage *res) -{ - LDAPCreateOp *create_op = (LDAPCreateOp*)op; - PASBackendLDAP *bl = PAS_BACKEND_LDAP (op->backend); - LDAP *ldap = bl->priv->ldap; - EContact *contact; - int ldap_error; - int response; - - if (LDAP_RES_ADD != ldap_msgtype (res)) { - g_warning ("incorrect msg type %d passed to create_contact_handler", ldap_msgtype (res)); - pas_book_respond_create (op->book, - GNOME_Evolution_Addressbook_OtherError, - NULL); - ldap_op_finished (op); - return; - } - - ldap_parse_result (ldap, res, &ldap_error, - NULL, NULL, NULL, NULL, 0); - - /* and lastly respond */ - response = ldap_error_to_response (ldap_error); - pas_book_respond_create (op->book, - response, - create_op->new_contact); - - ldap_op_finished (op); -} - -static void -create_contact_dtor (LDAPOp *op) -{ - LDAPCreateOp *create_op = (LDAPCreateOp*)op; - - g_free (create_op->dn); - g_object_unref (create_op->new_contact); - g_free (create_op); -} - -static void -pas_backend_ldap_process_create_contact (PASBackend *backend, - PASBook *book, - const char *vcard) -{ - LDAPCreateOp *create_op = g_new (LDAPCreateOp, 1); - PASBackendLDAP *bl = PAS_BACKEND_LDAP (backend); - PASBookView *book_view; - int create_contact_msgid; - int response; - int err; - GPtrArray *mod_array; - LDAPMod **ldap_mods; - LDAP *ldap; - - book_view = find_book_view (bl); - - printf ("vcard = %s\n", vcard); - - create_op->new_contact = e_contact_new_from_vcard (vcard); - - create_op->dn = create_dn_from_contact (create_op->new_contact, bl->priv->ldap_rootdn); - e_contact_set (create_op->new_contact, E_CONTACT_UID, create_op->dn); - - ldap = bl->priv->ldap; - - /* build our mods */ - mod_array = build_mods_from_contacts (bl, NULL, create_op->new_contact, NULL); - -#if 0 - if (!mod_array) { - /* there's an illegal field in there. report - UnsupportedAttribute back */ - pas_book_respond_create (book, - GNOME_Evolution_Addressbook_BookListener_UnsupportedField, - NULL); - - g_free (create_op->dn); - g_object_unref (create_op->new_contact); - g_free (create_op); - return; - } -#endif - - /* remove the NULL at the end */ - g_ptr_array_remove (mod_array, NULL); - - /* add our objectclass(es) */ - add_objectclass_mod (bl, mod_array, NULL); - - /* then put the NULL back */ - g_ptr_array_add (mod_array, NULL); - -#ifdef LDAP_DEBUG_ADD - { - int i; - printf ("Sending the following to the server as ADD\n"); - - for (i = 0; g_ptr_array_index(mod_array, i); i ++) { - LDAPMod *mod = g_ptr_array_index(mod_array, i); - if (mod->mod_op & LDAP_MOD_DELETE) - printf ("del "); - else if (mod->mod_op & LDAP_MOD_REPLACE) - printf ("rep "); - else - printf ("add "); - if (mod->mod_op & LDAP_MOD_BVALUES) - printf ("ber "); - else - printf (" "); - - printf (" %s:\n", mod->mod_type); - - if (mod->mod_op & LDAP_MOD_BVALUES) { - int j; - for (j = 0; mod->mod_bvalues[j] && mod->mod_bvalues[j]->bv_val; j++) - printf ("\t\t'%s'\n", mod->mod_bvalues[j]->bv_val); - } - else { - int j; - - for (j = 0; mod->mod_values[j]; j++) - printf ("\t\t'%s'\n", mod->mod_values[j]); - } - } - } -#endif - - ldap_mods = (LDAPMod**)mod_array->pdata; - - do { - book_view_notify_status (book_view, _("Adding contact to LDAP server...")); - - err = ldap_add_ext (ldap, create_op->dn, ldap_mods, - NULL, NULL, &create_contact_msgid); - - } while (pas_backend_ldap_reconnect (bl, book_view, err)); - - /* and clean up */ - free_mods (mod_array); - - if (LDAP_SUCCESS != err) { - response = ldap_error_to_response (err); - pas_book_respond_create (create_op->op.book, - response, - NULL); - create_contact_dtor ((LDAPOp*)create_op); - return; - } - else { - g_print ("ldap_add_ext returned %d\n", err); - ldap_op_add ((LDAPOp*)create_op, backend, book, - book_view, create_contact_msgid, - create_contact_handler, create_contact_dtor); - } -} - - -typedef struct { - LDAPOp op; - char *id; -} LDAPRemoveOp; - -static void -remove_contact_handler (LDAPOp *op, LDAPMessage *res) -{ - LDAPRemoveOp *remove_op = (LDAPRemoveOp*)op; - PASBackendLDAP *bl = PAS_BACKEND_LDAP (op->backend); - int ldap_error; - GList *ids = NULL; - - if (LDAP_RES_DELETE != ldap_msgtype (res)) { - g_warning ("incorrect msg type %d passed to remove_contact_handler", ldap_msgtype (res)); - pas_book_respond_remove_contacts (op->book, - GNOME_Evolution_Addressbook_OtherError, - NULL); - ldap_op_finished (op); - return; - } - - ldap_parse_result (bl->priv->ldap, res, &ldap_error, - NULL, NULL, NULL, NULL, 0); - - ids = g_list_append (ids, remove_op->id); - pas_book_respond_remove_contacts (remove_op->op.book, - ldap_error_to_response (ldap_error), - ids); - g_list_free (ids); -} - -static void -remove_contact_dtor (LDAPOp *op) -{ - LDAPRemoveOp *remove_op = (LDAPRemoveOp*)op; - - g_free (remove_op->id); - g_free (remove_op); -} - -static void -pas_backend_ldap_process_remove_contacts (PASBackend *backend, - PASBook *book, - GList *ids) -{ - LDAPRemoveOp *remove_op = g_new (LDAPRemoveOp, 1); - PASBackendLDAP *bl = PAS_BACKEND_LDAP (backend); - PASBookView *book_view; - int remove_msgid; - int ldap_error; - - book_view = find_book_view (bl); - - /* - ** since we didn't pass "bulk-removes" in our static - ** capabilities, we should only get 1 length lists here, so - ** the id we're deleting is the first and only id in the list. - */ - remove_op->id = g_strdup (ids->data); - - do { - book_view_notify_status (book_view, _("Removing contact from LDAP server...")); - - ldap_error = ldap_delete_ext (bl->priv->ldap, - remove_op->id, - NULL, NULL, &remove_msgid); - } while (pas_backend_ldap_reconnect (bl, book_view, ldap_error)); - - if (ldap_error != LDAP_SUCCESS) { - pas_book_respond_remove_contacts (remove_op->op.book, - ldap_error_to_response (ldap_error), - NULL); - remove_contact_dtor ((LDAPOp*)remove_op); - return; - } - else { - g_print ("ldap_delete_ext returned %d\n", ldap_error); - ldap_op_add ((LDAPOp*)remove_op, backend, book, - book_view, remove_msgid, - remove_contact_handler, remove_contact_dtor); - } -} - - -/* -** MODIFY -** -** The modification request is actually composed of 2 separate -** requests. Since we need to get a list of theexisting objectclasses -** used by the ldap server for the entry, and since the UI only sends -** us the current contact, we need to query the ldap server for the -** existing contact. -** -*/ - -typedef struct { - LDAPOp op; - const char *id; /* the id of the contact we're modifying */ - EContact *current_contact; - EContact *contact; - GList *existing_objectclasses; -} LDAPModifyOp; - -static void -modify_contact_modify_handler (LDAPOp *op, LDAPMessage *res) -{ - LDAPModifyOp *modify_op = (LDAPModifyOp*)op; - PASBackendLDAP *bl = PAS_BACKEND_LDAP (op->backend); - LDAP *ldap = bl->priv->ldap; - int ldap_error; - - if (LDAP_RES_MODIFY != ldap_msgtype (res)) { - g_warning ("incorrect msg type %d passed to modify_contact_handler", ldap_msgtype (res)); - pas_book_respond_modify (op->book, - GNOME_Evolution_Addressbook_OtherError, - NULL); - ldap_op_finished (op); - return; - } - - ldap_parse_result (ldap, res, &ldap_error, - NULL, NULL, NULL, NULL, 0); - - /* and lastly respond */ - pas_book_respond_modify (op->book, - ldap_error_to_response (ldap_error), - modify_op->contact); - ldap_op_finished (op); -} - -static void -modify_contact_search_handler (LDAPOp *op, LDAPMessage *res) -{ - LDAPModifyOp *modify_op = (LDAPModifyOp*)op; - PASBackendLDAP *bl = PAS_BACKEND_LDAP (op->backend); - LDAP *ldap = bl->priv->ldap; - int msg_type; - - /* if it's successful, we should get called with a - RES_SEARCH_ENTRY and a RES_SEARCH_RESULT. if it's - unsuccessful, we should only see a RES_SEARCH_RESULT */ - - msg_type = ldap_msgtype (res); - if (msg_type == LDAP_RES_SEARCH_ENTRY) { - LDAPMessage *e = ldap_first_entry(ldap, res); - - if (!e) { - g_warning ("uh, this shouldn't happen"); - pas_book_respond_modify (op->book, - GNOME_Evolution_Addressbook_OtherError, - NULL); - ldap_op_finished (op); - return; - } - - modify_op->current_contact = build_contact_from_entry (ldap, e, - &modify_op->existing_objectclasses); - } - else if (msg_type == LDAP_RES_SEARCH_RESULT) { - int ldap_error; - LDAPMod **ldap_mods; - GPtrArray *mod_array; - gboolean differences; - gboolean need_new_dn; - int modify_contact_msgid; - - /* grab the result code, and set up the actual modify - if it was successful */ - ldap_parse_result (bl->priv->ldap, res, &ldap_error, - NULL, NULL, NULL, NULL, 0); - - if (ldap_error != LDAP_SUCCESS) { - /* more here i'm sure */ - pas_book_respond_modify (op->book, - ldap_error_to_response (ldap_error), - NULL); - ldap_op_finished (op); - return; - } - - /* build our mods */ - mod_array = build_mods_from_contacts (bl, modify_op->current_contact, modify_op->contact, &need_new_dn); - differences = mod_array->len > 0; - - if (differences) { - /* remove the NULL at the end */ - g_ptr_array_remove (mod_array, NULL); - - /* add our objectclass(es), making sure - evolutionPerson is there if it's supported */ - add_objectclass_mod (bl, mod_array, modify_op->existing_objectclasses); - - /* then put the NULL back */ - g_ptr_array_add (mod_array, NULL); - - ldap_mods = (LDAPMod**)mod_array->pdata; - - /* actually perform the ldap modify */ - ldap_error = ldap_modify_ext (ldap, modify_op->id, ldap_mods, - NULL, NULL, &modify_contact_msgid); - - if (ldap_error == LDAP_SUCCESS) { - op->handler = modify_contact_modify_handler; - ldap_op_change_id ((LDAPOp*)modify_op, - modify_contact_msgid); - } - else { - g_warning ("ldap_modify_ext returned %d\n", ldap_error); - pas_book_respond_modify (op->book, - ldap_error_to_response (ldap_error), - NULL); - ldap_op_finished (op); - return; - } - } - - /* and clean up */ - free_mods (mod_array); - } - else { - g_warning ("unhandled result type %d returned", msg_type); - pas_book_respond_modify (op->book, - GNOME_Evolution_Addressbook_OtherError, - NULL); - ldap_op_finished (op); - } -} - -static void -modify_contact_dtor (LDAPOp *op) -{ - LDAPModifyOp *modify_op = (LDAPModifyOp*)op; - - g_list_foreach (modify_op->existing_objectclasses, (GFunc)g_free, NULL); - g_list_free (modify_op->existing_objectclasses); - if (modify_op->current_contact) - g_object_unref (modify_op->current_contact); - if (modify_op->contact) - g_object_unref (modify_op->contact); - g_free (modify_op); -} - -static void -pas_backend_ldap_process_modify_contact (PASBackend *backend, - PASBook *book, - const char *vcard) -{ - LDAPModifyOp *modify_op = g_new0 (LDAPModifyOp, 1); - PASBackendLDAP *bl = PAS_BACKEND_LDAP (backend); - int ldap_error; - LDAP *ldap; - int modify_contact_msgid; - PASBookView *book_view; - - book_view = find_book_view (bl); - - modify_op->contact = e_contact_new_from_vcard (vcard); - modify_op->id = e_contact_get_const (modify_op->contact, E_CONTACT_UID); - - ldap = bl->priv->ldap; - - book_view_notify_status (book_view, _("Modifying contact from LDAP server...")); - - do { - book_view_notify_status (book_view, _("Modifying contact from LDAP server...")); - - ldap_error = ldap_search_ext (ldap, modify_op->id, - LDAP_SCOPE_BASE, - "(objectclass=*)", - NULL, 0, NULL, NULL, - NULL, /* XXX timeout */ - 1, &modify_contact_msgid); - - } while (pas_backend_ldap_reconnect (bl, book_view, ldap_error)); - - if (ldap_error == LDAP_SUCCESS) { - ldap_op_add ((LDAPOp*)modify_op, backend, book, - book_view, modify_contact_msgid, - modify_contact_search_handler, modify_contact_dtor); - } - else { - g_warning ("ldap_search_ext returned %d\n", ldap_error); - pas_book_respond_modify (book, - GNOME_Evolution_Addressbook_OtherError, - NULL); - modify_contact_dtor ((LDAPOp*)modify_op); - } -} - - -typedef struct { - LDAPOp op; -} LDAPGetContactOp; - -static void -get_contact_handler (LDAPOp *op, LDAPMessage *res) -{ - PASBackendLDAP *bl = PAS_BACKEND_LDAP (op->backend); - int msg_type; - - /* the msg_type will be either SEARCH_ENTRY (if we're - successful) or SEARCH_RESULT (if we're not), so we finish - the op after either */ - msg_type = ldap_msgtype (res); - if (msg_type == LDAP_RES_SEARCH_ENTRY) { - LDAPMessage *e = ldap_first_entry(bl->priv->ldap, res); - EContact *contact; - char *vcard; - - if (!e) { - g_warning ("uh, this shouldn't happen"); - pas_book_respond_get_contact (op->book, - GNOME_Evolution_Addressbook_OtherError, - ""); - ldap_op_finished (op); - return; - } - - contact = build_contact_from_entry (bl->priv->ldap, e, NULL); - vcard = e_vcard_to_string (E_VCARD (contact), EVC_FORMAT_VCARD_30); - pas_book_respond_get_contact (op->book, - GNOME_Evolution_Addressbook_Success, - vcard); - g_free (vcard); - g_object_unref (contact); - ldap_op_finished (op); - } - else if (msg_type == LDAP_RES_SEARCH_RESULT) { - int ldap_error; - ldap_parse_result (bl->priv->ldap, res, &ldap_error, - NULL, NULL, NULL, NULL, 0); - pas_book_respond_get_contact (op->book, ldap_error_to_response (ldap_error), ""); - ldap_op_finished (op); - } - else { - g_warning ("unhandled result type %d returned", msg_type); - pas_book_respond_get_contact (op->book, GNOME_Evolution_Addressbook_OtherError, - ""); - ldap_op_finished (op); - } - -} - -static void -get_contact_dtor (LDAPOp *op) -{ - LDAPGetContactOp *get_contact_op = (LDAPGetContactOp*)op; - - g_free (get_contact_op); -} - -static void -pas_backend_ldap_process_get_contact (PASBackend *backend, - PASBook *book, - const char *id) -{ - LDAPGetContactOp *get_contact_op = g_new0 (LDAPGetContactOp, 1); - PASBackendLDAP *bl = PAS_BACKEND_LDAP (backend); - LDAP *ldap = bl->priv->ldap; - int get_contact_msgid; - PASBookView *book_view; - int ldap_error; - - book_view = find_book_view (bl); - - do { - ldap_error = ldap_search_ext (ldap, id, - LDAP_SCOPE_BASE, - "(objectclass=*)", - NULL, 0, NULL, NULL, - NULL, /* XXX timeout */ - 1, &get_contact_msgid); - } while (pas_backend_ldap_reconnect (bl, book_view, ldap_error)); - - if (ldap_error == LDAP_SUCCESS) { - ldap_op_add ((LDAPOp*)get_contact_op, backend, book, - book_view, get_contact_msgid, - get_contact_handler, get_contact_dtor); - } - else { - pas_book_respond_get_contact (book, - ldap_error_to_response (ldap_error), - ""); - get_contact_dtor ((LDAPOp*)get_contact_op); - } -} - - - -static EContactField email_ids[3] = { - E_CONTACT_EMAIL_1, - E_CONTACT_EMAIL_2, - E_CONTACT_EMAIL_3 -}; - -/* List property functions */ -static void -email_populate(EContact *contact, char **values) -{ - int i; - for (i = 0; values[i] && i < 3; i ++) - e_contact_set (contact, email_ids[i], values[i]); -} - -struct berval** -email_ber(EContact *contact) -{ - struct berval** result; - const char *emails[3]; - int i, j, num = 0; - - for (i = 0; i < 3; i ++) { - emails[i] = e_contact_get (contact, email_ids[i]); - if (emails[i]) - num++; - } - - if (num == 0) - return NULL; - - result = g_new (struct berval*, num + 1); - - for (i = 0; i < num; i ++) - result[i] = g_new (struct berval, 1); - - j = 0; - for (i = 0; i < 3; i ++) { - if (emails[i]) { - result[j]->bv_val = g_strdup (emails[i]); - result[j++]->bv_len = strlen (emails[i]); - } - } - - result[num] = NULL; - - return result; -} - -static gboolean -email_compare (EContact *contact1, EContact *contact2) -{ - const char *email1, *email2; - int i; - - for (i = 0; i < 3; i ++) { - gboolean equal; - email1 = e_contact_get_const (contact1, email_ids[i]); - email2 = e_contact_get_const (contact2, email_ids[i]); - - if (email1 && email2) - equal = !strcmp (email1, email2); - else - equal = (!!email1 == !!email2); - - if (!equal) - return equal; - } - - return TRUE; -} - -static void -homephone_populate(EContact *contact, char **values) -{ - if (values[0]) { - e_contact_set (contact, E_CONTACT_PHONE_HOME, values[0]); - if (values[1]) - e_contact_set (contact, E_CONTACT_PHONE_HOME_2, values[1]); - } -} - -struct berval** -homephone_ber(EContact *contact) -{ - struct berval** result; - const char *homephones[3]; - int i, j, num; - - num = 0; - if ((homephones[0] = e_contact_get (contact, E_CONTACT_PHONE_HOME))) - num++; - if ((homephones[1] = e_contact_get (contact, E_CONTACT_PHONE_HOME_2))) - num++; - - if (num == 0) - return NULL; - - result = g_new (struct berval*, num + 1); - - for (i = 0; i < num; i ++) - result[i] = g_new (struct berval, 1); - - j = 0; - for (i = 0; i < 2; i ++) { - if (homephones[i]) { - result[j]->bv_val = g_strdup (homephones[i]); - result[j++]->bv_len = strlen (homephones[i]); - } - } - - result[num] = NULL; - - return result; -} - -static gboolean -homephone_compare (EContact *contact1, EContact *contact2) -{ - int phone_ids[2] = { E_CONTACT_PHONE_HOME, E_CONTACT_PHONE_HOME_2 }; - const char *phone1, *phone2; - int i; - - for (i = 0; i < 2; i ++) { - gboolean equal; - phone1 = e_contact_get (contact1, phone_ids[i]); - phone2 = e_contact_get (contact2, phone_ids[i]); - - if (phone1 && phone2) - equal = !strcmp (phone1, phone2); - else - equal = (!!phone1 == !!phone2); - - if (!equal) - return equal; - } - - return TRUE; -} - -static void -business_populate(EContact *contact, char **values) -{ - if (values[0]) { - e_contact_set (contact, E_CONTACT_PHONE_BUSINESS, values[0]); - if (values[1]) - e_contact_set (contact, E_CONTACT_PHONE_BUSINESS_2, values[1]); - } -} - -struct berval** -business_ber(EContact *contact) -{ - struct berval** result; - const char *business_phones[3]; - int i, j, num; - - num = 0; - if ((business_phones[0] = e_contact_get (contact, E_CONTACT_PHONE_BUSINESS))) - num++; - if ((business_phones[1] = e_contact_get (contact, E_CONTACT_PHONE_BUSINESS_2))) - num++; - - if (num == 0) - return NULL; - - result = g_new (struct berval*, num + 1); - - for (i = 0; i < num; i ++) - result[i] = g_new (struct berval, 1); - - j = 0; - for (i = 0; i < 2; i ++) { - if (business_phones[i]) { - result[j]->bv_val = g_strdup (business_phones[i]); - result[j++]->bv_len = strlen (business_phones[i]); - } - } - - result[num] = NULL; - - return result; -} - -static gboolean -business_compare (EContact *contact1, EContact *contact2) -{ - int phone_ids[2] = { E_CONTACT_PHONE_BUSINESS, E_CONTACT_PHONE_BUSINESS_2 }; - const char *phone1, *phone2; - int i; - - for (i = 0; i < 2; i ++) { - gboolean equal; - phone1 = e_contact_get (contact1, phone_ids[i]); - phone2 = e_contact_get (contact2, phone_ids[i]); - - if (phone1 && phone2) - equal = !strcmp (phone1, phone2); - else - equal = (!!phone1 == !!phone2); - - if (!equal) - return equal; - } - - return TRUE; -} - -static void -anniversary_populate (EContact *contact, char **values) -{ - if (values[0]) { - EContactDate *dt = e_contact_date_from_string (values[0]); - e_contact_set (contact, E_CONTACT_ANNIVERSARY, &dt); - } -} - -struct berval** -anniversary_ber (EContact *contact) -{ - EContactDate *dt; - struct berval** result = NULL; - - dt = e_contact_get (contact, E_CONTACT_ANNIVERSARY); - - if (dt) { - char *anniversary; - - anniversary = e_contact_date_to_string (dt); - - result = g_new (struct berval*, 2); - result[0] = g_new (struct berval, 1); - result[0]->bv_val = anniversary; - result[0]->bv_len = strlen (anniversary); - - result[1] = NULL; - - e_contact_date_free (dt); - } - - return result; -} - -static gboolean -anniversary_compare (EContact *contact1, EContact *contact2) -{ - EContactDate *dt; - char *date1 = NULL, *date2 = NULL; - gboolean equal; - - dt = e_contact_get (contact1, E_CONTACT_ANNIVERSARY); - if (dt) { - date1 = e_contact_date_to_string (dt); - e_contact_date_free (dt); - } - - dt = e_contact_get (contact2, E_CONTACT_ANNIVERSARY); - if (dt) { - date2 = e_contact_date_to_string (dt); - e_contact_date_free (dt); - } - - if (date1 && date2) - equal = !strcmp (date1, date2); - else - equal = (!!date1 == !!date2); - - g_free (date1); - g_free (date2); - - return equal; -} - -static void -birthday_populate (EContact *contact, char **values) -{ - if (values[0]) { - EContactDate *dt = e_contact_date_from_string (values[0]); - e_contact_set (contact, E_CONTACT_BIRTH_DATE, dt); - e_contact_date_free (dt); - } -} - -struct berval** -birthday_ber (EContact *contact) -{ - EContactDate *dt; - struct berval** result = NULL; - - dt = e_contact_get (contact, E_CONTACT_BIRTH_DATE); - if (dt) { - char *birthday; - - birthday = e_contact_date_to_string (dt); - - result = g_new (struct berval*, 2); - result[0] = g_new (struct berval, 1); - result[0]->bv_val = birthday; - result[0]->bv_len = strlen (birthday); - - result[1] = NULL; - - e_contact_date_free (dt); - } - - return result; -} - -static gboolean -birthday_compare (EContact *contact1, EContact *contact2) -{ - EContactDate *dt; - char *date1 = NULL, *date2 = NULL; - gboolean equal; - - dt = e_contact_get (contact1, E_CONTACT_BIRTH_DATE); - if (dt) { - date1 = e_contact_date_to_string (dt); - e_contact_date_free (dt); - } - - dt = e_contact_get (contact2, E_CONTACT_BIRTH_DATE); - if (dt) { - date2 = e_contact_date_to_string (dt); - e_contact_date_free (dt); - } - - if (date1 && date2) - equal = !strcmp (date1, date2); - else - equal = (!!date1 == !!date2); - - g_free (date1); - g_free (date2); - - return equal; -} - -static void -category_populate (EContact *contact, char **values) -{ -#if notyet - int i; - EContact *ecard; - EList *categories; - - g_object_get (card, - "card", &ecard, - NULL); - - categories = e_list_new((EListCopyFunc) g_strdup, - (EListFreeFunc) g_free, - NULL); - - for (i = 0; values[i]; i++) - e_list_append (categories, values[i]); - - g_object_set (ecard, - "category_list", categories, - NULL); - - g_object_unref (categories); - - e_card_simple_sync_card (card); - g_object_unref (ecard); -#endif -} - -struct berval** -category_ber (EContact *contact) -{ -#if notyet - struct berval** result = NULL; - EList *categories; - EIterator *iterator; - EContact *ecard; - int i; - - g_object_get (card, - "card", &ecard, - NULL); - - g_object_get (ecard, - "category_list", &categories, - NULL); - - if (e_list_length (categories) != 0) { - result = g_new0 (struct berval*, e_list_length (categories) + 1); - - for (iterator = e_list_get_iterator(categories), i = 0; e_iterator_is_valid (iterator); - e_iterator_next (iterator), i++) { - const char *category = e_iterator_get (iterator); - - result[i] = g_new (struct berval, 1); - result[i]->bv_val = g_strdup (category); - result[i]->bv_len = strlen (category); - } - - g_object_unref (iterator); - } - - g_object_unref (categories); - g_object_unref (ecard); - return result; -#endif -} - -static gboolean -category_compare (EContact *contact1, EContact *contact2) -{ -#if notyet - char *categories1, *categories2; - gboolean equal; - - categories1 = e_card_simple_get (ecard1, E_CONTACT_CATEGORIES); - categories2 = e_card_simple_get (ecard2, E_CONTACT_CATEGORIES); - - equal = !strcmp (categories1, categories2); - - g_free (categories1); - g_free (categories2); - - return equal; -#endif -} - -static void -photo_populate (EContact *contact, struct berval **ber_values) -{ - if (ber_values && ber_values[0]) { - EContactPhoto photo; - photo.data = ber_values[0]->bv_val; - photo.length = ber_values[0]->bv_len; - - e_contact_set (contact, E_CONTACT_PHOTO, &photo); - } -} - -typedef struct { - GList *list; - PASBackendLDAP *bl; -} PASBackendLDAPSExpData; - -#define IS_RFC2254_CHAR(c) ((c) == '*' || (c) =='\\' || (c) == '(' || (c) == ')' || (c) == '\0') -static char * -rfc2254_escape(char *str) -{ - int i; - int len = strlen(str); - int newlen = 0; - - for (i = 0; i < len; i ++) { - if (IS_RFC2254_CHAR(str[i])) - newlen += 3; - else - newlen ++; - } - - if (len == newlen) { - return g_strdup (str); - } - else { - char *newstr = g_malloc0 (newlen + 1); - int j = 0; - for (i = 0; i < len; i ++) { - if (IS_RFC2254_CHAR(str[i])) { - sprintf (newstr + j, "\\%02x", str[i]); - j+= 3; - } - else { - newstr[j++] = str[i]; - } - } - return newstr; - } -} - -static ESExpResult * -func_and(struct _ESExp *f, int argc, struct _ESExpResult **argv, void *data) -{ - PASBackendLDAPSExpData *ldap_data = data; - ESExpResult *r; - char ** strings; - - if (argc > 0) { - int i; - - strings = g_new0(char*, argc+3); - strings[0] = g_strdup ("(&"); - strings[argc+3 - 2] = g_strdup (")"); - - for (i = 0; i < argc; i ++) { - GList *list_head = ldap_data->list; - if (!list_head) - break; - strings[argc - i] = list_head->data; - ldap_data->list = g_list_remove_link(list_head, list_head); - g_list_free_1(list_head); - } - - ldap_data->list = g_list_prepend(ldap_data->list, g_strjoinv(" ", strings)); - - for (i = 0 ; i < argc + 2; i ++) - g_free (strings[i]); - - g_free (strings); - } - - r = e_sexp_result_new(f, ESEXP_RES_BOOL); - r->value.bool = FALSE; - - return r; -} - -static ESExpResult * -func_or(struct _ESExp *f, int argc, struct _ESExpResult **argv, void *data) -{ - PASBackendLDAPSExpData *ldap_data = data; - ESExpResult *r; - char ** strings; - - if (argc > 0) { - int i; - - strings = g_new0(char*, argc+3); - strings[0] = g_strdup ("(|"); - strings[argc+3 - 2] = g_strdup (")"); - - for (i = 0; i < argc; i ++) { - GList *list_head = ldap_data->list; - if (!list_head) - break; - strings[argc - i] = list_head->data; - ldap_data->list = g_list_remove_link(list_head, list_head); - g_list_free_1(list_head); - } - - ldap_data->list = g_list_prepend(ldap_data->list, g_strjoinv(" ", strings)); - - for (i = 0 ; i < argc + 2; i ++) - g_free (strings[i]); - - g_free (strings); - } - - r = e_sexp_result_new(f, ESEXP_RES_BOOL); - r->value.bool = FALSE; - - return r; -} - -static ESExpResult * -func_not(struct _ESExp *f, int argc, struct _ESExpResult **argv, void *data) -{ - PASBackendLDAPSExpData *ldap_data = data; - ESExpResult *r; - - /* just replace the head of the list with the NOT of it. */ - if (argc > 0) { - char *term = ldap_data->list->data; - ldap_data->list->data = g_strdup_printf("(!%s)", term); - g_free (term); - } - - r = e_sexp_result_new(f, ESEXP_RES_BOOL); - r->value.bool = FALSE; - - return r; -} - -static ESExpResult * -func_contains(struct _ESExp *f, int argc, struct _ESExpResult **argv, void *data) -{ - PASBackendLDAPSExpData *ldap_data = data; - ESExpResult *r; - - if (argc == 2 - && argv[0]->type == ESEXP_RES_STRING - && argv[1]->type == ESEXP_RES_STRING) { - char *propname = argv[0]->value.string; - char *str = rfc2254_escape(argv[1]->value.string); - gboolean one_star = FALSE; - - if (strlen(str) == 0) - one_star = TRUE; - - if (!strcmp (propname, "x-evolution-any-field")) { - int i; - int query_length; - char *big_query; - char *match_str; - - match_str = g_strdup_printf("=*%s%s)", - str, one_star ? "" : "*"); - - query_length = 3; /* strlen ("(|") + strlen (")") */ - - for (i = 0; i < num_prop_infos; i ++) { - query_length += 1 /* strlen ("(") */ + strlen(prop_info[i].ldap_attr) + strlen (match_str); - } - - big_query = g_malloc0(query_length + 1); - strcat (big_query, "(|"); - for (i = 0; i < num_prop_infos; i ++) { - strcat (big_query, "("); - strcat (big_query, prop_info[i].ldap_attr); - strcat (big_query, match_str); - } - strcat (big_query, ")"); - - ldap_data->list = g_list_prepend(ldap_data->list, big_query); - - g_free (match_str); - } - else { - char *ldap_attr = query_prop_to_ldap(propname); - - if (ldap_attr) - ldap_data->list = g_list_prepend(ldap_data->list, - g_strdup_printf("(%s=*%s%s)", - ldap_attr, - str, - one_star ? "" : "*")); - } - - g_free (str); - } - - r = e_sexp_result_new(f, ESEXP_RES_BOOL); - r->value.bool = FALSE; - - return r; -} - -static ESExpResult * -func_is(struct _ESExp *f, int argc, struct _ESExpResult **argv, void *data) -{ - PASBackendLDAPSExpData *ldap_data = data; - ESExpResult *r; - - if (argc == 2 - && argv[0]->type == ESEXP_RES_STRING - && argv[1]->type == ESEXP_RES_STRING) { - char *propname = argv[0]->value.string; - char *str = rfc2254_escape(argv[1]->value.string); - char *ldap_attr = query_prop_to_ldap(propname); - - if (ldap_attr) - ldap_data->list = g_list_prepend(ldap_data->list, - g_strdup_printf("(%s=%s)", - ldap_attr, str)); - else { - g_warning ("unknown query property\n"); - /* we want something that'll always be false */ - ldap_data->list = g_list_prepend(ldap_data->list, - g_strdup("objectClass=MyBarnIsBiggerThanYourBarn")); - } - - g_free (str); - } - - r = e_sexp_result_new(f, ESEXP_RES_BOOL); - r->value.bool = FALSE; - - return r; -} - -static ESExpResult * -func_beginswith(struct _ESExp *f, int argc, struct _ESExpResult **argv, void *data) -{ - PASBackendLDAPSExpData *ldap_data = data; - ESExpResult *r; - - if (argc == 2 - && argv[0]->type == ESEXP_RES_STRING - && argv[1]->type == ESEXP_RES_STRING) { - char *propname = argv[0]->value.string; - char *str = rfc2254_escape(argv[1]->value.string); - char *ldap_attr = query_prop_to_ldap(propname); - - /* insert hack for fileAs queries, since we need to do - the right thing if the server supports them or not, - and for entries that have no fileAs attribute. */ - if (ldap_attr) { - if (!strcmp (propname, "full_name")) { - ldap_data->list = g_list_prepend(ldap_data->list, - g_strdup_printf( - "(|(cn=%s*)(sn=%s*))", - str, str)); - } - else if (!strcmp (ldap_attr, "fileAs")) { - if (ldap_data->bl->priv->evolutionPersonSupported) - ldap_data->list = g_list_prepend(ldap_data->list, - g_strdup_printf("(|(fileAs=%s*)(&(!(fileAs=*))(sn=%s*)))", - str, str)); - else - ldap_data->list = g_list_prepend(ldap_data->list, - g_strdup_printf("(sn=%s*)", str)); - } - else { - ldap_data->list = g_list_prepend(ldap_data->list, - g_strdup_printf("(%s=%s*)", - ldap_attr, - str)); - } - } - - g_free (str); - } - - r = e_sexp_result_new(f, ESEXP_RES_BOOL); - r->value.bool = FALSE; - - return r; -} - -static ESExpResult * -func_endswith(struct _ESExp *f, int argc, struct _ESExpResult **argv, void *data) -{ - PASBackendLDAPSExpData *ldap_data = data; - ESExpResult *r; - - if (argc == 2 - && argv[0]->type == ESEXP_RES_STRING - && argv[1]->type == ESEXP_RES_STRING) { - char *propname = argv[0]->value.string; - char *str = rfc2254_escape(argv[1]->value.string); - char *ldap_attr = query_prop_to_ldap(propname); - - if (ldap_attr) - ldap_data->list = g_list_prepend(ldap_data->list, - g_strdup_printf("(%s=*%s)", - ldap_attr, - str)); - g_free (str); - } - - r = e_sexp_result_new(f, ESEXP_RES_BOOL); - r->value.bool = FALSE; - - return r; -} - -static ESExpResult * -func_exists(struct _ESExp *f, int argc, struct _ESExpResult **argv, void *data) -{ - PASBackendLDAPSExpData *ldap_data = data; - ESExpResult *r; - - if (argc == 1 - && argv[0]->type == ESEXP_RES_STRING) { - char *propname = argv[0]->value.string; - - if (!strcmp (propname, "x-evolution-any-field")) { - int i; - int query_length; - char *big_query; - char *match_str; - - match_str = g_strdup("=*)"); - - query_length = 3; /* strlen ("(|") + strlen (")") */ - - for (i = 0; i < num_prop_infos; i ++) { - query_length += 1 /* strlen ("(") */ + strlen(prop_info[i].ldap_attr) + strlen (match_str); - } - - big_query = g_malloc0(query_length + 1); - strcat (big_query, "(|"); - for (i = 0; i < num_prop_infos; i ++) { - strcat (big_query, "("); - strcat (big_query, prop_info[i].ldap_attr); - strcat (big_query, match_str); - } - strcat (big_query, ")"); - - ldap_data->list = g_list_prepend(ldap_data->list, big_query); - - g_free (match_str); - } - else { - char *ldap_attr = query_prop_to_ldap(propname); - - if (ldap_attr) - ldap_data->list = g_list_prepend(ldap_data->list, - g_strdup_printf("(%s=*)", ldap_attr)); - } - } - - r = e_sexp_result_new(f, ESEXP_RES_BOOL); - r->value.bool = FALSE; - - return r; -} - -/* 'builtin' functions */ -static struct { - char *name; - ESExpFunc *func; - int type; /* set to 1 if a function can perform shortcut evaluation, or - doesn't execute everything, 0 otherwise */ -} symbols[] = { - { "and", func_and, 0 }, - { "or", func_or, 0 }, - { "not", func_not, 0 }, - { "contains", func_contains, 0 }, - { "is", func_is, 0 }, - { "beginswith", func_beginswith, 0 }, - { "endswith", func_endswith, 0 }, - { "exists", func_exists, 0 }, -}; - -static gchar * -pas_backend_ldap_build_query (PASBackendLDAP *bl, const char *query) -{ - ESExp *sexp; - ESExpResult *r; - gchar *retval; - PASBackendLDAPSExpData data; - int i; - - data.list = NULL; - data.bl = bl; - - sexp = e_sexp_new(); - - for(i=0;i<sizeof(symbols)/sizeof(symbols[0]);i++) { - if (symbols[i].type == 1) { - e_sexp_add_ifunction(sexp, 0, symbols[i].name, - (ESExpIFunc *)symbols[i].func, &data); - } else { - e_sexp_add_function(sexp, 0, symbols[i].name, - symbols[i].func, &data); - } - } - - e_sexp_input_text(sexp, query, strlen(query)); - e_sexp_parse(sexp); - - r = e_sexp_eval(sexp); - - e_sexp_result_free(sexp, r); - e_sexp_unref (sexp); - - if (data.list) { - if (data.list->next) { - g_warning ("conversion to ldap query string failed"); - retval = NULL; - g_list_foreach (data.list, (GFunc)g_free, NULL); - } - else { - retval = data.list->data; - } - } - else { - g_warning ("conversion to ldap query string failed"); - retval = NULL; - } - - g_list_free (data.list); - return retval; -} - -static gchar * -query_prop_to_ldap(gchar *query_prop) -{ - int i; - - for (i = 0; i < num_prop_infos; i ++) - if (!strcmp (query_prop, e_contact_field_name (prop_info[i].field_id))) - return prop_info[i].ldap_attr; - - return NULL; -} - - -typedef struct { - LDAPOp op; - PASBookView *view; - - /* used by search_handler to only send the status messages once */ - gboolean notified_receiving_results; -} LDAPSearchOp; - -static EContact * -build_contact_from_entry (LDAP *ldap, LDAPMessage *e, GList **existing_objectclasses) -{ - EContact *contact = e_contact_new (); - char *dn; - char *attr; - BerElement *ber = NULL; - - dn = ldap_get_dn(ldap, e); - e_contact_set (contact, E_CONTACT_UID, dn); - ldap_memfree (dn); - - for (attr = ldap_first_attribute (ldap, e, &ber); attr; - attr = ldap_next_attribute (ldap, e, ber)) { - int i; - struct prop_info *info = NULL; - char **values; - - if (existing_objectclasses && !g_ascii_strcasecmp (attr, "objectclass")) { - values = ldap_get_values (ldap, e, attr); - for (i = 0; values[i]; i ++) - *existing_objectclasses = g_list_append (*existing_objectclasses, g_strdup (values[i])); - - ldap_value_free (values); - } - else { - for (i = 0; i < num_prop_infos; i ++) - if (!g_ascii_strcasecmp (attr, prop_info[i].ldap_attr)) { - info = &prop_info[i]; - break; - } - - printf ("attr = %s, ", attr); - printf ("info = %p\n", info); - - if (info) { - if (info->prop_type & PROP_WRITE_ONLY) - continue; - - if (info->prop_type & PROP_TYPE_BINARY) { - struct berval **ber_values = ldap_get_values_len (ldap, e, attr); - - if (ber_values) { - info->binary_populate_contact_func (contact, ber_values); - - ldap_value_free_len (ber_values); - } - } - else { - values = ldap_get_values (ldap, e, attr); - - if (values) { - if (info->prop_type & PROP_TYPE_STRING) { - printf ("value = %s\n", values[0]); - /* if it's a normal property just set the string */ - if (values[0]) - e_contact_set (contact, info->field_id, values[0]); - } - else if (info->prop_type & PROP_TYPE_COMPLEX) { - /* if it's a list call the contact-populate function, - which calls g_object_set to set the property */ - info->populate_contact_func(contact, - values); - } - - ldap_value_free (values); - } - } - } - } - - ldap_memfree (attr); - } - - if (ber) - ber_free (ber, 0); - - return contact; -} - -static gboolean -poll_ldap (PASBackendLDAP *bl) -{ - LDAP *ldap = bl->priv->ldap; - int rc; - LDAPMessage *res; - struct timeval timeout; - - if (!bl->priv->active_ops) { - g_warning ("poll_ldap being called for backend with no active operations"); - return FALSE; - } - - timeout.tv_sec = 0; - timeout.tv_usec = LDAP_RESULT_TIMEOUT_MILLIS * 1000; - - rc = ldap_result (ldap, LDAP_RES_ANY, 0, &timeout, &res); - if (rc != 0) {/* rc == 0 means timeout exceeded */ - if (rc == -1) { - PASBookView *book_view = find_book_view (bl); - g_warning ("ldap_result returned -1, restarting ops"); - - pas_backend_ldap_reconnect (bl, book_view, LDAP_SERVER_DOWN); -#if 0 - if (bl->priv->connected) - restart_ops (bl); -#endif - } - else { - int msgid = ldap_msgid (res); - LDAPOp *op; - - op = g_hash_table_lookup (bl->priv->id_to_op, &msgid); - - if (op) - op->handler (op, res); - else - g_warning ("unknown operation, msgid = %d", msgid); - - ldap_msgfree(res); - } - } - - return TRUE; -} - -static void -ldap_search_handler (LDAPOp *op, LDAPMessage *res) -{ - LDAPSearchOp *search_op = (LDAPSearchOp*)op; - PASBookView *view = search_op->view; - PASBackendLDAP *bl = PAS_BACKEND_LDAP (op->backend); - LDAP *ldap = bl->priv->ldap; - LDAPMessage *e; - int msg_type; - - bonobo_object_dup_ref(bonobo_object_corba_objref(BONOBO_OBJECT(view)), NULL); - - if (!search_op->notified_receiving_results) { - search_op->notified_receiving_results = TRUE; - book_view_notify_status (op->view, _("Receiving LDAP search results...")); - } - - msg_type = ldap_msgtype (res); - if (msg_type == LDAP_RES_SEARCH_ENTRY) { - e = ldap_first_entry(ldap, res); - - while (NULL != e) { - EContact *contact = build_contact_from_entry (ldap, e, NULL); - - pas_book_view_notify_update (view, contact); - - g_object_unref (contact); - - e = ldap_next_entry(ldap, e); - } - } - else if (msg_type == LDAP_RES_SEARCH_RESULT) { - int ldap_error; - - ldap_parse_result (ldap, res, &ldap_error, - NULL, NULL, NULL, NULL, 0); - - g_warning ("search returned %d\n", ldap_error); - - if (ldap_error == LDAP_TIMELIMIT_EXCEEDED) - pas_book_view_notify_complete (search_op->op.view, GNOME_Evolution_Addressbook_SearchTimeLimitExceeded); - else if (ldap_error == LDAP_SIZELIMIT_EXCEEDED) - pas_book_view_notify_complete (search_op->op.view, GNOME_Evolution_Addressbook_SearchSizeLimitExceeded); - else if (ldap_error == LDAP_SUCCESS) - pas_book_view_notify_complete (search_op->op.view, GNOME_Evolution_Addressbook_Success); - else - pas_book_view_notify_complete (search_op->op.view, GNOME_Evolution_Addressbook_OtherError); - - ldap_op_finished (op); - } - else { - g_warning ("unhandled search result type %d returned", msg_type); - pas_book_view_notify_complete (search_op->op.view, GNOME_Evolution_Addressbook_OtherError); - ldap_op_finished (op); - } - - - bonobo_object_release_unref(bonobo_object_corba_objref(BONOBO_OBJECT(view)), NULL); -} - -static void -ldap_search_dtor (LDAPOp *op) -{ - LDAPSearchOp *search_op = (LDAPSearchOp*) op; - -#if notyet - /* unhook us from our PASBackendLDAPBookView */ - if (search_op->view) - search_op->view->search_op = NULL; -#endif - - g_free (search_op); -} - -static void -pas_backend_ldap_search (PASBackendLDAP *bl, - PASBook *book, - PASBookView *view) -{ - char *ldap_query; - - ldap_query = pas_backend_ldap_build_query (bl, pas_book_view_get_card_query (view)); - - if (ldap_query != NULL) { - LDAP *ldap = bl->priv->ldap; - int ldap_err; - int search_msgid; - - printf ("searching server using filter: %s\n", ldap_query); - - do { - book_view_notify_status (view, _("Searching...")); - - ldap_err = ldap_search_ext (ldap, bl->priv->ldap_rootdn, - bl->priv->ldap_scope, - ldap_query, - NULL, 0, - NULL, /* XXX */ - NULL, /* XXX */ - NULL, /* XXX timeout */ - 0 /* XXX we need this back in view->limit*/, &search_msgid); - } while (pas_backend_ldap_reconnect (bl, view, ldap_err)); - - g_free (ldap_query); - - if (ldap_err != LDAP_SUCCESS) { - book_view_notify_status (view, ldap_err2string(ldap_err)); - return; - } - else if (search_msgid == -1) { - book_view_notify_status (view, - _("Error performing search")); - return; - } - else { - LDAPSearchOp *op = g_new0 (LDAPSearchOp, 1); - - op->view = view; - -#if notyet - view->search_op = (LDAPOp*)op; -#endif - - ldap_op_add ((LDAPOp*)op, PAS_BACKEND(bl), book, view, - search_msgid, - ldap_search_handler, ldap_search_dtor); - - } - return; - } - else { - pas_book_view_notify_complete (view, - GNOME_Evolution_Addressbook_InvalidQuery); - return; - } - -} - -static void -pas_backend_ldap_process_start_book_view (PASBackend *backend, - PASBookView *view) -{ - PASBackendLDAP *bl = PAS_BACKEND_LDAP (backend); - - pas_backend_ldap_search (bl, NULL /* XXX ugh */, view); -} - -static void -pas_backend_ldap_process_stop_book_view (PASBackend *backend, - PASBookView *view) -{ - /* FIXME we don't stop them... */ -} - -static void -pas_backend_ldap_process_get_changes (PASBackend *backend, - PASBook *book, - const char *change_id) -{ - /* FIXME: implement */ -} - -#define LDAP_SIMPLE_PREFIX "ldap/simple-" -#define SASL_PREFIX "sasl/" - -static void -pas_backend_ldap_process_authenticate_user (PASBackend *backend, - PASBook *book, - const char *user, - const char *passwd, - const char *auth_method) -{ - PASBackendLDAP *bl = PAS_BACKEND_LDAP (backend); - int ldap_error; - char *dn = NULL; - - if (!strncasecmp (auth_method, LDAP_SIMPLE_PREFIX, strlen (LDAP_SIMPLE_PREFIX))) { - - if (!strcmp (auth_method, "ldap/simple-email")) { - LDAPMessage *res, *e; - char *query = g_strdup_printf ("(mail=%s)", user); - - ldap_error = ldap_search_s (bl->priv->ldap, - bl->priv->ldap_rootdn, - bl->priv->ldap_scope, - query, - NULL, 0, &res); - g_free (query); - - if (ldap_error == LDAP_SUCCESS) { - char *entry_dn; - - e = ldap_first_entry (bl->priv->ldap, res); - - entry_dn = ldap_get_dn (bl->priv->ldap, e); - dn = g_strdup(entry_dn); - - ldap_memfree (entry_dn); - ldap_msgfree (res); - } - else { - pas_book_respond_authenticate_user (book, - GNOME_Evolution_Addressbook_PermissionDenied); - return; - } - } - else if (!strcmp (auth_method, "ldap/simple-binddn")) { - dn = g_strdup (user); - } - - /* now authenticate against the DN we were either supplied or queried for */ - printf ("simple auth as %s\n", dn); - ldap_error = ldap_simple_bind_s(bl->priv->ldap, - dn, - passwd); - - pas_book_respond_authenticate_user (book, - ldap_error_to_response (ldap_error)); - } -#ifdef ENABLE_SASL_BINDS - else if (!strncasecmp (auth_method, SASL_PREFIX, strlen (SASL_PREFIX))) { - g_print ("sasl bind (mech = %s) as %s", auth_method + strlen (SASL_PREFIX), user); - ldap_error = ldap_sasl_bind_s (bl->priv->ldap, - NULL, - auth_method + strlen (SASL_PREFIX), - passwd, - NULL, - NULL, - NULL); - - if (ldap_error == LDAP_NOT_SUPPORTED) - pas_book_respond_authenticate_user (book, - GNOME_Evolution_Addressbook_UnsupportedAuthenticationMethod); - else - pas_book_respond_authenticate_user (book, - ldap_error_to_response (ldap_error)); - } -#endif - else { - pas_book_respond_authenticate_user (book, - GNOME_Evolution_Addressbook_UnsupportedAuthenticationMethod); - return; - } - - if (ldap_error == LDAP_SUCCESS) { - bl->priv->auth_dn = dn; - bl->priv->auth_passwd = g_strdup (passwd); - - pas_backend_set_is_writable (backend, TRUE); - - /* force a requery on the root dse since some ldap - servers are set up such that they don't report - anything (including the schema DN) until the user - is authenticated */ - if (!bl->priv->evolutionPersonChecked) { - ldap_error = query_ldap_root_dse (bl); - - if (LDAP_SUCCESS == ldap_error) { - if (!bl->priv->evolutionPersonChecked) - check_schema_support (bl); - } - else - g_warning ("Failed to perform root dse query after authenticating, (ldap_error 0x%02x)", ldap_error); - } - - pas_book_report_writable (book, TRUE); - } - -} - -static void -pas_backend_ldap_process_get_supported_fields (PASBackend *backend, - PASBook *book) - -{ - PASBackendLDAP *bl = PAS_BACKEND_LDAP (backend); - - pas_book_respond_get_supported_fields (book, - GNOME_Evolution_Addressbook_Success, - bl->priv->supported_fields); -} - -static void -pas_backend_ldap_process_get_supported_auth_methods (PASBackend *backend, - PASBook *book) - -{ - PASBackendLDAP *bl = PAS_BACKEND_LDAP (backend); - - pas_book_respond_get_supported_auth_methods (book, - GNOME_Evolution_Addressbook_Success, - bl->priv->supported_auth_methods); -} - -static GNOME_Evolution_Addressbook_CallStatus -pas_backend_ldap_load_uri (PASBackend *backend, - const char *uri, - gboolean only_if_exists) -{ - PASBackendLDAP *bl = PAS_BACKEND_LDAP (backend); - LDAPURLDesc *lud; - int ldap_error; - char **attributes; - int i; - int limit = 100; - int timeout = 60; /* 1 minute */ - - g_assert (bl->priv->connected == FALSE); - - attributes = g_strsplit (uri, ";", 0); - - if (attributes[0] == NULL) - return FALSE; - - for (i = 1; attributes[i]; i++) { - char *equals; - char *value; - int key_length; - equals = strchr (attributes[i], '='); - if (equals) { - key_length = equals - attributes[i]; - value = equals + 1; - } else { - key_length = strlen (attributes[i]); - value = NULL; - } - - if (key_length == strlen("limit") && !strncmp (attributes[i], "limit", key_length)) { - if (value) - limit = atoi(value); - } - else if (key_length == strlen("ssl") && !strncmp (attributes[i], "ssl", key_length)) { - if (value) { - if (!strncmp (value, "always", 6)) { - bl->priv->use_tls = PAS_BACKEND_LDAP_TLS_ALWAYS; - } - else if (!strncmp (value, "whenever_possible", 3)) { - bl->priv->use_tls = PAS_BACKEND_LDAP_TLS_WHEN_POSSIBLE; - } - else if (strncmp (value, "never", 5)) { - g_warning ("unhandled value for use_tls, not using it"); - } - } - else { - bl->priv->use_tls = PAS_BACKEND_LDAP_TLS_WHEN_POSSIBLE; - } - } - else if (key_length == strlen("timeout") && !strncmp (attributes[i], "timeout", key_length)) { - if (value) - timeout = atoi (value); - } - } - - ldap_error = ldap_url_parse ((char*)attributes[0], &lud); - g_strfreev (attributes); - - if (ldap_error == LDAP_SUCCESS) { - g_free(bl->priv->uri); - bl->priv->uri = g_strdup (uri); - bl->priv->ldap_host = g_strdup(lud->lud_host); - bl->priv->ldap_port = lud->lud_port; - /* if a port wasn't specified, default to LDAP_PORT */ - if (bl->priv->ldap_port == 0) - bl->priv->ldap_port = LDAP_PORT; - bl->priv->ldap_rootdn = g_strdup(lud->lud_dn); - bl->priv->ldap_limit = limit; - bl->priv->ldap_timeout = timeout; - bl->priv->ldap_scope = lud->lud_scope; - - ldap_free_urldesc(lud); - - return pas_backend_ldap_connect (bl); - } else - return GNOME_Evolution_Addressbook_OtherError; -} - -static char* -pas_backend_ldap_get_static_capabilities (PASBackend *backend) -{ - return g_strdup("net"); -} - -static gboolean -pas_backend_ldap_construct (PASBackendLDAP *backend) -{ - g_assert (backend != NULL); - g_assert (PAS_IS_BACKEND_LDAP (backend)); - - if (! pas_backend_construct (PAS_BACKEND (backend))) - return FALSE; - - return TRUE; -} - -/** - * pas_backend_ldap_new: - */ -PASBackend * -pas_backend_ldap_new (void) -{ - PASBackendLDAP *backend; - - backend = g_object_new (PAS_TYPE_BACKEND_LDAP, NULL); - - if (! pas_backend_ldap_construct (backend)) { - g_object_unref (backend); - - return NULL; - } - - return PAS_BACKEND (backend); -} - -static gboolean -call_dtor (int msgid, LDAPOp *op, gpointer data) -{ - ldap_abandon (PAS_BACKEND_LDAP(op->backend)->priv->ldap, op->id); - - op->dtor (op); - - return TRUE; -} - -static void -pas_backend_ldap_dispose (GObject *object) -{ - PASBackendLDAP *bl; - - bl = PAS_BACKEND_LDAP (object); - - if (bl->priv) { - g_hash_table_foreach_remove (bl->priv->id_to_op, (GHRFunc)call_dtor, NULL); - g_hash_table_destroy (bl->priv->id_to_op); - - if (bl->priv->poll_timeout != -1) { - printf ("removing timeout\n"); - g_source_remove (bl->priv->poll_timeout); - } - - if (bl->priv->supported_fields) { - g_list_foreach (bl->priv->supported_fields, (GFunc)g_free, NULL); - g_list_free (bl->priv->supported_fields); - } - - if (bl->priv->supported_auth_methods) { - g_list_foreach (bl->priv->supported_auth_methods, (GFunc)g_free, NULL); - g_list_free (bl->priv->supported_auth_methods); - } - - g_free (bl->priv->uri); - - g_free (bl->priv); - bl->priv = NULL; - } - - if (G_OBJECT_CLASS (pas_backend_ldap_parent_class)->dispose) - G_OBJECT_CLASS (pas_backend_ldap_parent_class)->dispose (object); -} - -static void -pas_backend_ldap_class_init (PASBackendLDAPClass *klass) -{ - GObjectClass *object_class = G_OBJECT_CLASS (klass); - PASBackendClass *parent_class; - - /* get client side information (extensions present in the library) */ - get_ldap_library_info (); - - pas_backend_ldap_parent_class = g_type_class_peek_parent (klass); - - parent_class = PAS_BACKEND_CLASS (klass); - - /* Set the virtual methods. */ - parent_class->load_uri = pas_backend_ldap_load_uri; - parent_class->get_static_capabilities = pas_backend_ldap_get_static_capabilities; - - parent_class->create_contact = pas_backend_ldap_process_create_contact; - parent_class->remove_contacts = pas_backend_ldap_process_remove_contacts; - parent_class->modify_contact = pas_backend_ldap_process_modify_contact; - parent_class->get_contact = pas_backend_ldap_process_get_contact; - parent_class->start_book_view = pas_backend_ldap_process_start_book_view; - parent_class->stop_book_view = pas_backend_ldap_process_stop_book_view; - parent_class->get_changes = pas_backend_ldap_process_get_changes; - parent_class->authenticate_user = pas_backend_ldap_process_authenticate_user; - parent_class->get_supported_fields = pas_backend_ldap_process_get_supported_fields; - parent_class->get_supported_auth_methods = pas_backend_ldap_process_get_supported_auth_methods; - - object_class->dispose = pas_backend_ldap_dispose; -} - -static void -pas_backend_ldap_init (PASBackendLDAP *backend) -{ - PASBackendLDAPPrivate *priv; - - priv = g_new0 (PASBackendLDAPPrivate, 1); - - priv->supported_fields = NULL; - priv->supported_auth_methods = NULL; - priv->ldap_limit = 100; - priv->id_to_op = g_hash_table_new (g_int_hash, g_int_equal); - priv->poll_timeout = -1; - - backend->priv = priv; -} - -/** - * pas_backend_ldap_get_type: - */ -GType -pas_backend_ldap_get_type (void) -{ - static GType type = 0; - - if (! type) { - GTypeInfo info = { - sizeof (PASBackendLDAPClass), - NULL, /* base_class_init */ - NULL, /* base_class_finalize */ - (GClassInitFunc) pas_backend_ldap_class_init, - NULL, /* class_finalize */ - NULL, /* class_data */ - sizeof (PASBackendLDAP), - 0, /* n_preallocs */ - (GInstanceInitFunc) pas_backend_ldap_init - }; - - type = g_type_register_static (PAS_TYPE_BACKEND, "PASBackendLDAP", &info, 0); - } - - return type; -} diff --git a/addressbook/backend/pas/pas-backend-ldap.h b/addressbook/backend/pas/pas-backend-ldap.h deleted file mode 100644 index ca04ee6a21..0000000000 --- a/addressbook/backend/pas/pas-backend-ldap.h +++ /dev/null @@ -1,32 +0,0 @@ -/* - * Copyright 2000, Ximian, Inc. - */ - -#ifndef __PAS_BACKEND_LDAP_H__ -#define __PAS_BACKEND_LDAP_H__ - -#include "pas-backend.h" - -#define PAS_TYPE_BACKEND_LDAP (pas_backend_ldap_get_type ()) -#define PAS_BACKEND_LDAP(o) (G_TYPE_CHECK_INSTANCE_CAST ((o), PAS_TYPE_BACKEND_LDAP, PASBackendLDAP)) -#define PAS_BACKEND_LDAP_CLASS(k) (G_TYPE_CHECK_CLASS_CAST((k), PAS_BACKEND_TYPE, PASBackendLDAPClass)) -#define PAS_IS_BACKEND_LDAP(o) (G_TYPE_CHECK_INSTANCE_TYPE ((o), PAS_TYPE_BACKEND_LDAP)) -#define PAS_IS_BACKEND_LDAP_CLASS(k) (G_TYPE_CHECK_CLASS_TYPE ((k), PAS_TYPE_BACKEND_LDAP)) -#define PAS_BACKEND_LDAP_GET_CLASS(k) (G_TYPE_INSTANCE_GET_CLASS ((obj), PAS_TYPE_BACKEND_LDAP, PASBackendLDAPClass)) - -typedef struct _PASBackendLDAPPrivate PASBackendLDAPPrivate; - -typedef struct { - PASBackend parent_object; - PASBackendLDAPPrivate *priv; -} PASBackendLDAP; - -typedef struct { - PASBackendClass parent_class; -} PASBackendLDAPClass; - -PASBackend *pas_backend_ldap_new (void); -GType pas_backend_ldap_get_type (void); - -#endif /* ! __PAS_BACKEND_LDAP_H__ */ - diff --git a/addressbook/backend/pas/pas-backend-summary.c b/addressbook/backend/pas/pas-backend-summary.c deleted file mode 100644 index 268a0c7062..0000000000 --- a/addressbook/backend/pas/pas-backend-summary.c +++ /dev/null @@ -1,1078 +0,0 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */ -/* - * pas-backend-summary.c - * Copyright 2000, 2001, Ximian, Inc. - * - * Authors: - * Chris Toshok <toshok@ximian.com> - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Library General Public - * License, version 2, as published by the Free Software Foundation. - * - * This library 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 - * Library General Public License for more details. - * - * You should have received a copy of the GNU Library General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA - * 02111-1307, USA. - */ - -#include "config.h" - -#include <string.h> -#include <sys/types.h> -#include <sys/stat.h> -#include <unistd.h> -#include <errno.h> - -#include <netinet/in.h> - -#include <gal/widgets/e-unicode.h> - -#include "ebook/e-contact.h" -#include "pas-backend-summary.h" -#include "e-util/e-sexp.h" - -static GObjectClass *parent_class; - -struct _PASBackendSummaryPrivate { - char *summary_path; - FILE *fp; - guint32 file_version; - time_t mtime; - gboolean upgraded; - gboolean dirty; - int flush_timeout_millis; - int flush_timeout; - GPtrArray *items; - GHashTable *id_to_item; - guint32 num_items; /* used only for loading */ -#ifdef SUMMARY_STATS - int size; -#endif -}; - -typedef struct { - char *id; - char *nickname; - char *full_name; - char *given_name; - char *surname; - char *file_as; - char *email_1; - char *email_2; - char *email_3; - gboolean wants_html; - gboolean wants_html_set; - gboolean list; - gboolean list_show_addresses; -} PASBackendSummaryItem; - -typedef struct { - /* these lengths do *not* including the terminating \0, as - it's not stored on disk. */ - guint16 id_len; - guint16 nickname_len; - guint16 full_name_len; /* version 3.0 field */ - guint16 given_name_len; - guint16 surname_len; - guint16 file_as_len; - guint16 email_1_len; - guint16 email_2_len; - guint16 email_3_len; - guint8 wants_html; - guint8 wants_html_set; - guint8 list; - guint8 list_show_addresses; -} PASBackendSummaryDiskItem; - -typedef struct { - guint32 file_version; - guint32 num_items; - guint32 summary_mtime; /* version 2.0 field */ -} PASBackendSummaryHeader; - -#define PAS_SUMMARY_MAGIC "PAS-SUMMARY" -#define PAS_SUMMARY_MAGIC_LEN 11 - -#define PAS_SUMMARY_FILE_VERSION_1_0 1000 -#define PAS_SUMMARY_FILE_VERSION_2_0 2000 -#define PAS_SUMMARY_FILE_VERSION_3_0 3000 -#define PAS_SUMMARY_FILE_VERSION_4_0 4000 - -#define PAS_SUMMARY_FILE_VERSION PAS_SUMMARY_FILE_VERSION_4_0 - -static void -free_summary_item (PASBackendSummaryItem *item) -{ - g_free (item->id); - g_free (item->nickname); - g_free (item->full_name); - g_free (item->given_name); - g_free (item->surname); - g_free (item->file_as); - g_free (item->email_1); - g_free (item->email_2); - g_free (item->email_3); - g_free (item); -} - -static void -clear_items (PASBackendSummary *summary) -{ - int i; - int num = summary->priv->items->len; - for (i = 0; i < num; i++) { - PASBackendSummaryItem *item = g_ptr_array_remove_index_fast (summary->priv->items, 0); - g_hash_table_remove (summary->priv->id_to_item, item->id); - free_summary_item (item); - } -} - -PASBackendSummary* -pas_backend_summary_new (const char *summary_path, int flush_timeout_millis) -{ - PASBackendSummary *summary = g_object_new (PAS_TYPE_BACKEND_SUMMARY, NULL); - - summary->priv->summary_path = g_strdup (summary_path); - summary->priv->flush_timeout_millis = flush_timeout_millis; - summary->priv->file_version = PAS_SUMMARY_FILE_VERSION_4_0; - - return summary; -} - -static void -pas_backend_summary_dispose (GObject *object) -{ - PASBackendSummary *summary = PAS_BACKEND_SUMMARY (object); - - if (summary->priv) { - if (summary->priv->dirty) - g_warning ("Destroying dirty summary"); - - if (summary->priv->flush_timeout) { - g_source_remove (summary->priv->flush_timeout); - summary->priv->flush_timeout = 0; - } - - if (summary->priv->fp) - fclose (summary->priv->fp); - - g_free (summary->priv->summary_path); - clear_items (summary); - g_ptr_array_free (summary->priv->items, TRUE); - - g_hash_table_destroy (summary->priv->id_to_item); - - g_free (summary->priv); - summary->priv = NULL; - } - - if (G_OBJECT_CLASS (parent_class)->dispose) - G_OBJECT_CLASS (parent_class)->dispose (object); -} - -static void -pas_backend_summary_class_init (PASBackendSummaryClass *klass) -{ - GObjectClass *object_class = G_OBJECT_CLASS (klass); - - parent_class = g_type_class_peek_parent (klass); - - /* Set the virtual methods. */ - - object_class->dispose = pas_backend_summary_dispose; -} - -static void -pas_backend_summary_init (PASBackendSummary *summary) -{ - PASBackendSummaryPrivate *priv; - - priv = g_new(PASBackendSummaryPrivate, 1); - - summary->priv = priv; - - priv->summary_path = NULL; - priv->fp = NULL; - priv->dirty = FALSE; - priv->upgraded = FALSE; - priv->items = g_ptr_array_new(); - priv->id_to_item = g_hash_table_new (g_str_hash, g_str_equal); - priv->flush_timeout_millis = 0; - priv->flush_timeout = 0; -#ifdef SUMMARY_STATS - priv->size = 0; -#endif -} - -/** - * pas_backend_summary_get_type: - */ -GType -pas_backend_summary_get_type (void) -{ - static GType type = 0; - - if (! type) { - GTypeInfo info = { - sizeof (PASBackendSummaryClass), - NULL, /* base_class_init */ - NULL, /* base_class_finalize */ - (GClassInitFunc) pas_backend_summary_class_init, - NULL, /* class_finalize */ - NULL, /* class_data */ - sizeof (PASBackendSummary), - 0, /* n_preallocs */ - (GInstanceInitFunc) pas_backend_summary_init - }; - - type = g_type_register_static (G_TYPE_OBJECT, "PASBackendSummary", &info, 0); - } - - return type; -} - - -static gboolean -pas_backend_summary_check_magic (PASBackendSummary *summary, FILE *fp) -{ - char buf [PAS_SUMMARY_MAGIC_LEN + 1]; - int rv; - - memset (buf, 0, sizeof (buf)); - - rv = fread (buf, PAS_SUMMARY_MAGIC_LEN, 1, fp); - if (rv != 1) - return FALSE; - if (strcmp (buf, PAS_SUMMARY_MAGIC)) - return FALSE; - - return TRUE; -} - -static gboolean -pas_backend_summary_load_header (PASBackendSummary *summary, FILE *fp, - PASBackendSummaryHeader *header) -{ - int rv; - - rv = fread (&header->file_version, sizeof (header->file_version), 1, fp); - if (rv != 1) - return FALSE; - - header->file_version = ntohl (header->file_version); - - if (header->file_version < PAS_SUMMARY_FILE_VERSION) { - return FALSE; /* this will cause the entire summary to be rebuilt */ - } - - rv = fread (&header->num_items, sizeof (header->num_items), 1, fp); - if (rv != 1) - return FALSE; - - header->num_items = ntohl (header->num_items); - - rv = fread (&header->summary_mtime, sizeof (header->summary_mtime), 1, fp); - if (rv != 1) - return FALSE; - header->summary_mtime = ntohl (header->summary_mtime); - - return TRUE; -} - -static char * -read_string (FILE *fp, int len) -{ - char *buf; - int rv; - - buf = g_new0 (char, len + 1); - - rv = fread (buf, len, 1, fp); - if (rv != 1) { - g_free (buf); - return NULL; - } - - return buf; -} - -static gboolean -pas_backend_summary_load_item (PASBackendSummary *summary, - PASBackendSummaryItem **new_item) -{ - PASBackendSummaryItem *item; - char *buf; - FILE *fp = summary->priv->fp; - - if (summary->priv->file_version >= PAS_SUMMARY_FILE_VERSION_4_0) { - PASBackendSummaryDiskItem disk_item; - int rv = fread (&disk_item, sizeof (disk_item), 1, fp); - if (rv != 1) - return FALSE; - - disk_item.id_len = ntohs (disk_item.id_len); - disk_item.nickname_len = ntohs (disk_item.nickname_len); - disk_item.full_name_len = ntohs (disk_item.full_name_len); - disk_item.given_name_len = ntohs (disk_item.given_name_len); - disk_item.surname_len = ntohs (disk_item.surname_len); - disk_item.file_as_len = ntohs (disk_item.file_as_len); - disk_item.email_1_len = ntohs (disk_item.email_1_len); - disk_item.email_2_len = ntohs (disk_item.email_2_len); - disk_item.email_3_len = ntohs (disk_item.email_3_len); - - item = g_new0 (PASBackendSummaryItem, 1); - - item->wants_html = disk_item.wants_html; - item->wants_html_set = disk_item.wants_html_set; - item->list = disk_item.list; - item->list_show_addresses = disk_item.list_show_addresses; - - if (disk_item.id_len) { - buf = read_string (fp, disk_item.id_len); - if (!buf) { - free_summary_item (item); - return FALSE; - } - item->id = buf; - } - - if (disk_item.nickname_len) { - buf = read_string (fp, disk_item.nickname_len); - if (!buf) { - free_summary_item (item); - return FALSE; - } - item->nickname = buf; - } - - if (disk_item.full_name_len) { - buf = read_string (fp, disk_item.full_name_len); - if (!buf) { - free_summary_item (item); - return FALSE; - } - item->full_name = buf; - } - - if (disk_item.given_name_len) { - buf = read_string (fp, disk_item.given_name_len); - if (!buf) { - free_summary_item (item); - return FALSE; - } - item->given_name = buf; - } - - if (disk_item.surname_len) { - buf = read_string (fp, disk_item.surname_len); - if (!buf) { - free_summary_item (item); - return FALSE; - } - item->surname = buf; - } - - if (disk_item.file_as_len) { - buf = read_string (fp, disk_item.file_as_len); - if (!buf) { - free_summary_item (item); - return FALSE; - } - item->file_as = buf; - } - - if (disk_item.email_1_len) { - buf = read_string (fp, disk_item.email_1_len); - if (!buf) { - free_summary_item (item); - return FALSE; - } - item->email_1 = buf; - } - - if (disk_item.email_2_len) { - buf = read_string (fp, disk_item.email_2_len); - if (!buf) { - free_summary_item (item); - return FALSE; - } - item->email_2 = buf; - } - - if (disk_item.email_3_len) { - buf = read_string (fp, disk_item.email_3_len); - if (!buf) { - free_summary_item (item); - return FALSE; - } - item->email_3 = buf; - } - - /* the only field that has to be there is the id */ - if (!item->id) { - free_summary_item (item); - return FALSE; - } - } - else { - /* unhandled file version */ - return FALSE; - } - - *new_item = item; - return TRUE; -} - -/* opens the file and loads the header */ -static gboolean -pas_backend_summary_open (PASBackendSummary *summary) -{ - FILE *fp; - PASBackendSummaryHeader header; - struct stat sb; - - if (summary->priv->fp) - return TRUE; - - if (stat (summary->priv->summary_path, &sb) == -1) { - /* if there's no summary present, look for the .new - file and rename it if it's there, and attempt to - load that */ - char *new_filename = g_strconcat (summary->priv->summary_path, ".new", NULL); - if (stat (new_filename, &sb) == -1) { - g_warning ("no summary present"); - g_free (new_filename); - return FALSE; - } - else { - rename (new_filename, summary->priv->summary_path); - g_free (new_filename); - } - } - - fp = fopen (summary->priv->summary_path, "r"); - if (!fp) { - g_warning ("failed to open summary file"); - return FALSE; - } - - if (!pas_backend_summary_check_magic (summary, fp)) { - g_warning ("file is not a valid summary file"); - fclose (fp); - return FALSE; - } - - if (!pas_backend_summary_load_header (summary, fp, &header)) { - g_warning ("failed to read summary header"); - fclose (fp); - return FALSE; - } - - summary->priv->num_items = header.num_items; - summary->priv->file_version = header.file_version; - summary->priv->mtime = header.summary_mtime; - summary->priv->fp = fp; - - return TRUE; -} - -gboolean -pas_backend_summary_load (PASBackendSummary *summary) -{ - PASBackendSummaryItem *new_item; - int i; - - if (!pas_backend_summary_open (summary)) - return FALSE; - - for (i = 0; i < summary->priv->num_items; i ++) { - if (!pas_backend_summary_load_item (summary, &new_item)) { - g_warning ("error while reading summary item"); - clear_items (summary); - fclose (summary->priv->fp); - summary->priv->fp = NULL; - summary->priv->dirty = FALSE; - return FALSE; - } - - g_ptr_array_add (summary->priv->items, new_item); - g_hash_table_insert (summary->priv->id_to_item, new_item->id, new_item); - } - - if (summary->priv->upgraded) { - pas_backend_summary_save (summary); - } - summary->priv->dirty = FALSE; - - return TRUE; -} - -static gboolean -pas_backend_summary_save_magic (FILE *fp) -{ - int rv; - rv = fwrite (PAS_SUMMARY_MAGIC, PAS_SUMMARY_MAGIC_LEN, 1, fp); - if (rv != 1) - return FALSE; - - return TRUE; -} - -static gboolean -pas_backend_summary_save_header (PASBackendSummary *summary, FILE *fp) -{ - PASBackendSummaryHeader header; - int rv; - - header.file_version = htonl (PAS_SUMMARY_FILE_VERSION); - header.num_items = htonl (summary->priv->items->len); - header.summary_mtime = htonl (time (NULL)); - - rv = fwrite (&header, sizeof (header), 1, fp); - if (rv != 1) - return FALSE; - - return TRUE; -} - -static gboolean -save_string (const char *str, FILE *fp) -{ - int rv; - - if (!str || !*str) - return TRUE; - - rv = fwrite (str, strlen (str), 1, fp); - return (rv == 1); -} - -static gboolean -pas_backend_summary_save_item (PASBackendSummary *summary, FILE *fp, PASBackendSummaryItem *item) -{ - PASBackendSummaryDiskItem disk_item; - int len; - int rv; - - len = item->id ? strlen (item->id) : 0; - disk_item.id_len = htons (len); - - len = item->nickname ? strlen (item->nickname) : 0; - disk_item.nickname_len = htons (len); - - len = item->given_name ? strlen (item->given_name) : 0; - disk_item.given_name_len = htons (len); - - len = item->full_name ? strlen (item->full_name) : 0; - disk_item.full_name_len = htons (len); - - len = item->surname ? strlen (item->surname) : 0; - disk_item.surname_len = htons (len); - - len = item->file_as ? strlen (item->file_as) : 0; - disk_item.file_as_len = htons (len); - - len = item->email_1 ? strlen (item->email_1) : 0; - disk_item.email_1_len = htons (len); - - len = item->email_2 ? strlen (item->email_2) : 0; - disk_item.email_2_len = htons (len); - - len = item->email_3 ? strlen (item->email_3) : 0; - disk_item.email_3_len = htons (len); - - disk_item.wants_html = item->wants_html; - disk_item.wants_html_set = item->wants_html_set; - disk_item.list = item->list; - disk_item.list_show_addresses = item->list_show_addresses; - - rv = fwrite (&disk_item, sizeof(disk_item), 1, fp); - if (rv != 1) - return FALSE; - - if (!save_string (item->id, fp)) - return FALSE; - if (!save_string (item->nickname, fp)) - return FALSE; - if (!save_string (item->full_name, fp)) - return FALSE; - if (!save_string (item->given_name, fp)) - return FALSE; - if (!save_string (item->surname, fp)) - return FALSE; - if (!save_string (item->file_as, fp)) - return FALSE; - if (!save_string (item->email_1, fp)) - return FALSE; - if (!save_string (item->email_2, fp)) - return FALSE; - if (!save_string (item->email_3, fp)) - return FALSE; - - return TRUE; -} - -gboolean -pas_backend_summary_save (PASBackendSummary *summary) -{ - struct stat sb; - FILE *fp = NULL; - char *new_filename = NULL; - int i; - - if (!summary->priv->dirty) - return TRUE; - - new_filename = g_strconcat (summary->priv->summary_path, ".new", NULL); - - fp = fopen (new_filename, "w"); - if (!fp) { - g_warning ("could not create new summary file"); - goto lose; - } - - if (!pas_backend_summary_save_magic (fp)) { - g_warning ("could not write magic to new summary file"); - goto lose; - } - - if (!pas_backend_summary_save_header (summary, fp)) { - g_warning ("could not write header to new summary file"); - goto lose; - } - - for (i = 0; i < summary->priv->items->len; i ++) { - PASBackendSummaryItem *item = g_ptr_array_index (summary->priv->items, i); - if (!pas_backend_summary_save_item (summary, fp, item)) { - g_warning ("failed to write an item to new summary file, errno = %d", errno); - goto lose; - } - } - - fclose (fp); - - /* if we have a queued flush, clear it (since we just flushed) */ - if (summary->priv->flush_timeout) { - g_source_remove (summary->priv->flush_timeout); - summary->priv->flush_timeout = 0; - } - - /* unlink the old summary and rename the new one */ - unlink (summary->priv->summary_path); - rename (new_filename, summary->priv->summary_path); - - g_free (new_filename); - - /* lastly, update the in memory mtime to that of the file */ - if (stat (summary->priv->summary_path, &sb) == -1) { - g_warning ("error stat'ing saved summary"); - } - else { - summary->priv->mtime = sb.st_mtime; - } - - return TRUE; - - lose: - if (fp) - fclose (fp); - if (new_filename) - unlink (new_filename); - g_free (new_filename); - return FALSE; -} - -void -pas_backend_summary_add_contact (PASBackendSummary *summary, EContact *contact) -{ - PASBackendSummaryItem *new_item; - - new_item = g_new0 (PASBackendSummaryItem, 1); - - new_item->id = e_contact_get (contact, E_CONTACT_UID); - new_item->nickname = e_contact_get (contact, E_CONTACT_NICKNAME); - new_item->full_name = e_contact_get (contact, E_CONTACT_FULL_NAME); - new_item->given_name = e_contact_get (contact, E_CONTACT_GIVEN_NAME); - new_item->surname = e_contact_get (contact, E_CONTACT_FAMILY_NAME); - new_item->file_as = e_contact_get (contact, E_CONTACT_FILE_AS); - new_item->email_1 = e_contact_get (contact, E_CONTACT_EMAIL_1); - new_item->email_2 = e_contact_get (contact, E_CONTACT_EMAIL_2); - new_item->email_3 = e_contact_get (contact, E_CONTACT_EMAIL_3); - new_item->list = GPOINTER_TO_INT (e_contact_get (contact, E_CONTACT_IS_LIST)); - new_item->list_show_addresses = GPOINTER_TO_INT (e_contact_get (contact, E_CONTACT_LIST_SHOW_ADDRESSES)); - new_item->wants_html = GPOINTER_TO_INT (e_contact_get (contact, E_CONTACT_WANTS_HTML)); - - g_ptr_array_add (summary->priv->items, new_item); - g_hash_table_insert (summary->priv->id_to_item, new_item->id, new_item); - -#ifdef SUMMARY_STATS - summary->priv->size += sizeof (PASBackendSummaryItem); - summary->priv->size += new_item->id ? strlen (new_item->id) : 0; - summary->priv->size += new_item->nickname ? strlen (new_item->nickname) : 0; - summary->priv->size += new_item->full_name ? strlen (new_item->full_name) : 0; - summary->priv->size += new_item->given_name ? strlen (new_item->given_name) : 0; - summary->priv->size += new_item->surname ? strlen (new_item->surname) : 0; - summary->priv->size += new_item->file_as ? strlen (new_item->file_as) : 0; - summary->priv->size += new_item->email_1 ? strlen (new_item->email_1) : 0; - summary->priv->size += new_item->email_2 ? strlen (new_item->email_2) : 0; - summary->priv->size += new_item->email_3 ? strlen (new_item->email_3) : 0; -#endif - pas_backend_summary_touch (summary); -} - -void -pas_backend_summary_remove_contact (PASBackendSummary *summary, const char *id) -{ - PASBackendSummaryItem *item = g_hash_table_lookup (summary->priv->id_to_item, id); - - if (item) { - g_ptr_array_remove (summary->priv->items, item); - g_hash_table_remove (summary->priv->id_to_item, id); - free_summary_item (item); - pas_backend_summary_touch (summary); - return; - } - - g_warning ("pas_backend_summary_remove_contact: unable to locate id `%s'", id); -} - -static gboolean -summary_flush_func (gpointer data) -{ - PASBackendSummary *summary = PAS_BACKEND_SUMMARY (data); - - if (!summary->priv->dirty) { - summary->priv->flush_timeout = 0; - return FALSE; - } - - if (!pas_backend_summary_save (summary)) { - /* this isn't fatal, as we can just either 1) flush - out with the next change, or 2) regen the summary - when we next load the uri */ - g_warning ("failed to flush summary file to disk"); - return TRUE; /* try again after the next timeout */ - } - - g_warning ("flushed summary to disk"); - - /* we only want this to execute once, so return FALSE and set - summary->flush_timeout to 0 */ - summary->priv->flush_timeout = 0; - return FALSE; -} - -void -pas_backend_summary_touch (PASBackendSummary *summary) -{ - summary->priv->dirty = TRUE; - if (!summary->priv->flush_timeout - && summary->priv->flush_timeout_millis) - summary->priv->flush_timeout = g_timeout_add (summary->priv->flush_timeout_millis, - summary_flush_func, summary); -} - -gboolean -pas_backend_summary_is_up_to_date (PASBackendSummary *summary, time_t t) -{ - if (!pas_backend_summary_open (summary)) - return FALSE; - else - return summary->priv->mtime >= t; -} - - -/* we only want to do summary queries if the query is over the set fields in the summary */ - -static ESExpResult * -func_check(struct _ESExp *f, int argc, struct _ESExpResult **argv, void *data) -{ - ESExpResult *r; - int truth = FALSE; - - if (argc == 2 - && argv[0]->type == ESEXP_RES_STRING - && argv[1]->type == ESEXP_RES_STRING) { - char *query_name = argv[0]->value.string; - - if (!strcmp (query_name, "nickname") || - !strcmp (query_name, "full_name") || - !strcmp (query_name, "file_as") || - !strcmp (query_name, "email")) { - truth = TRUE; - } - } - - r = e_sexp_result_new(f, ESEXP_RES_BOOL); - r->value.bool = truth; - - return r; -} - -/* 'builtin' functions */ -static struct { - char *name; - ESExpFunc *func; - int type; /* set to 1 if a function can perform shortcut evaluation, or - doesn't execute everything, 0 otherwise */ -} check_symbols[] = { - { "contains", func_check, 0 }, - { "is", func_check, 0 }, - { "beginswith", func_check, 0 }, - { "endswith", func_check, 0 }, -}; - -gboolean -pas_backend_summary_is_summary_query (PASBackendSummary *summary, const char *query) -{ - ESExp *sexp; - ESExpResult *r; - gboolean retval; - int i; - int esexp_error; - - sexp = e_sexp_new(); - - for(i=0;i<sizeof(check_symbols)/sizeof(check_symbols[0]);i++) { - if (check_symbols[i].type == 1) { - e_sexp_add_ifunction(sexp, 0, check_symbols[i].name, - (ESExpIFunc *)check_symbols[i].func, summary); - } else { - e_sexp_add_function(sexp, 0, check_symbols[i].name, - check_symbols[i].func, summary); - } - } - - e_sexp_input_text(sexp, query, strlen(query)); - esexp_error = e_sexp_parse(sexp); - - if (esexp_error == -1) { - return FALSE; - } - - r = e_sexp_eval(sexp); - - retval = (r && r->type == ESEXP_RES_BOOL && r->value.bool); - - e_sexp_result_free(sexp, r); - - e_sexp_unref (sexp); - - return retval; -} - - - -/* the actual query mechanics */ -static ESExpResult * -do_compare (PASBackendSummary *summary, struct _ESExp *f, int argc, - struct _ESExpResult **argv, - char *(*compare)(const char*, const char*)) -{ - GPtrArray *result = g_ptr_array_new (); - ESExpResult *r; - int i; - - if (argc == 2 - && argv[0]->type == ESEXP_RES_STRING - && argv[1]->type == ESEXP_RES_STRING) { - - for (i = 0; i < summary->priv->items->len; i ++) { - PASBackendSummaryItem *item = g_ptr_array_index (summary->priv->items, i); - if (!strcmp (argv[0]->value.string, "full_name")) { - char *given = item->given_name; - char *surname = item->surname; - if ((given && compare (given, argv[1]->value.string)) - || (surname && compare (surname, argv[1]->value.string))) - g_ptr_array_add (result, item->id); - } - else if (!strcmp (argv[0]->value.string, "email")) { - char *email_1 = item->email_1; - char *email_2 = item->email_2; - char *email_3 = item->email_3; - if ((email_1 && compare (email_1, argv[1]->value.string)) - || (email_2 && compare (email_2, argv[1]->value.string)) - || (email_3 && compare (email_3, argv[1]->value.string))) - g_ptr_array_add (result, item->id); - } - else if (!strcmp (argv[0]->value.string, "file_as")) { - char *file_as = item->file_as; - if (file_as && compare (file_as, argv[1]->value.string)) - g_ptr_array_add (result, item->id); - } - else if (!strcmp (argv[0]->value.string, "nickname")) { - char *nickname = item->nickname; - if (nickname && compare (nickname, argv[1]->value.string)) - g_ptr_array_add (result, item->id); - } - } - } - - r = e_sexp_result_new(f, ESEXP_RES_ARRAY_PTR); - r->value.ptrarray = result; - - return r; -} - -static ESExpResult * -func_contains(struct _ESExp *f, int argc, struct _ESExpResult **argv, void *data) -{ - PASBackendSummary *summary = data; - - return do_compare (summary, f, argc, argv, (char *(*)(const char*, const char*)) e_utf8_strstrcase); -} - -static char * -is_helper (const char *s1, const char *s2) -{ - if (!strcasecmp(s1, s2)) - return (char*)s1; - else - return NULL; -} - -static ESExpResult * -func_is(struct _ESExp *f, int argc, struct _ESExpResult **argv, void *data) -{ - PASBackendSummary *summary = data; - - return do_compare (summary, f, argc, argv, is_helper); -} - -static char * -endswith_helper (const char *s1, const char *s2) -{ - char *p; - if ((p = (char*)e_utf8_strstrcase(s1, s2)) - && (strlen(p) == strlen(s2))) - return p; - else - return NULL; -} - -static ESExpResult * -func_endswith(struct _ESExp *f, int argc, struct _ESExpResult **argv, void *data) -{ - PASBackendSummary *summary = data; - - return do_compare (summary, f, argc, argv, endswith_helper); -} - -static char * -beginswith_helper (const char *s1, const char *s2) -{ - char *p; - if ((p = (char*)e_utf8_strstrcase(s1, s2)) - && (p == s1)) - return p; - else - return NULL; -} - -static ESExpResult * -func_beginswith(struct _ESExp *f, int argc, struct _ESExpResult **argv, void *data) -{ - PASBackendSummary *summary = data; - - return do_compare (summary, f, argc, argv, beginswith_helper); -} - -/* 'builtin' functions */ -static struct { - char *name; - ESExpFunc *func; - int type; /* set to 1 if a function can perform shortcut evaluation, or - doesn't execute everything, 0 otherwise */ -} symbols[] = { - { "contains", func_contains, 0 }, - { "is", func_is, 0 }, - { "beginswith", func_beginswith, 0 }, - { "endswith", func_endswith, 0 }, -}; - -GPtrArray* -pas_backend_summary_search (PASBackendSummary *summary, const char *query) -{ - ESExp *sexp; - ESExpResult *r; - GPtrArray *retval = g_ptr_array_new(); - int i; - int esexp_error; - - sexp = e_sexp_new(); - - for(i=0;i<sizeof(symbols)/sizeof(symbols[0]);i++) { - if (symbols[i].type == 1) { - e_sexp_add_ifunction(sexp, 0, symbols[i].name, - (ESExpIFunc *)symbols[i].func, summary); - } else { - e_sexp_add_function(sexp, 0, symbols[i].name, - symbols[i].func, summary); - } - } - - e_sexp_input_text(sexp, query, strlen(query)); - esexp_error = e_sexp_parse(sexp); - - if (esexp_error == -1) { - return NULL; - } - - r = e_sexp_eval(sexp); - - if (r && r->type == ESEXP_RES_ARRAY_PTR && r->value.ptrarray) { - GPtrArray *ptrarray = r->value.ptrarray; - int i; - - for (i = 0; i < ptrarray->len; i ++) - g_ptr_array_add (retval, g_ptr_array_index (ptrarray, i)); - } - - e_sexp_result_free(sexp, r); - - e_sexp_unref (sexp); - - return retval; -} - -char* -pas_backend_summary_get_summary_vcard(PASBackendSummary *summary, const char *id) -{ - PASBackendSummaryItem *item = g_hash_table_lookup (summary->priv->id_to_item, id); - - if (item) { - EContact *contact = e_contact_new (); - char *vcard; - - e_contact_set (contact, E_CONTACT_UID, item->id); - e_contact_set (contact, E_CONTACT_FILE_AS, item->file_as); - e_contact_set (contact, E_CONTACT_GIVEN_NAME, item->given_name); - e_contact_set (contact, E_CONTACT_FAMILY_NAME, item->surname); - e_contact_set (contact, E_CONTACT_NICKNAME, item->nickname); - e_contact_set (contact, E_CONTACT_FULL_NAME, item->full_name); - e_contact_set (contact, E_CONTACT_EMAIL_1, item->email_1); - e_contact_set (contact, E_CONTACT_EMAIL_2, item->email_2); - e_contact_set (contact, E_CONTACT_EMAIL_3, item->email_3); - - e_contact_set (contact, E_CONTACT_IS_LIST, GINT_TO_POINTER (item->list)); - e_contact_set (contact, E_CONTACT_LIST_SHOW_ADDRESSES, GINT_TO_POINTER (item->list_show_addresses)); - e_contact_set (contact, E_CONTACT_WANTS_HTML, GINT_TO_POINTER (item->wants_html)); - - vcard = e_vcard_to_string (E_VCARD (contact), EVC_FORMAT_VCARD_30); - - g_object_unref (contact); - - return vcard; - } - else { - g_warning ("in unable to locate card `%s' in summary", id); - return NULL; - } -} - diff --git a/addressbook/backend/pas/pas-backend-summary.h b/addressbook/backend/pas/pas-backend-summary.h deleted file mode 100644 index bb07e0fb27..0000000000 --- a/addressbook/backend/pas/pas-backend-summary.h +++ /dev/null @@ -1,72 +0,0 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */ -/* - * pas-backend-summary.h - * Copyright 2000, 2001, Ximian, Inc. - * - * Authors: - * Chris Toshok <toshok@ximian.com> - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Library General Public - * License, version 2, as published by the Free Software Foundation. - * - * This library 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 - * Library General Public License for more details. - * - * You should have received a copy of the GNU Library General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA - * 02111-1307, USA. - */ - -#ifndef __PAS_BACKEND_SUMMARY_H__ -#define __PAS_BACKEND_SUMMARY_H__ - -#include <glib.h> -#include <glib-object.h> -#include <pas/pas-types.h> -#include <ebook/e-contact.h> - -#define PAS_TYPE_BACKEND_SUMMARY (pas_backend_summary_get_type ()) -#define PAS_BACKEND_SUMMARY(o) (G_TYPE_CHECK_INSTANCE_CAST ((o), PAS_TYPE_BACKEND_SUMMARY, PASBackendSummary)) -#define PAS_BACKEND_SUMMARY_CLASS(k) (G_TYPE_CHECK_CLASS_CAST((k), PAS_BACKEND_TYPE, PASBackendSummaryClass)) -#define PAS_IS_BACKEND_SUMMARY(o) (G_TYPE_CHECK_INSTANCE_TYPE ((o), PAS_TYPE_BACKEND_SUMMARY)) -#define PAS_IS_BACKEND_SUMMARY_CLASS(k) (G_TYPE_CHECK_CLASS_TYPE ((k), PAS_TYPE_BACKEND_SUMMARY)) -#define PAS_BACKEND_SUMMARY_GET_CLASS(k) (G_TYPE_INSTANCE_GET_CLASS ((obj), PAS_TYPE_BACKEND_SUMMARY, PASBackendSummaryClass)) - -typedef struct _PASBackendSummaryPrivate PASBackendSummaryPrivate; - -struct _PASBackendSummary{ - GObject parent_object; - PASBackendSummaryPrivate *priv; -}; - -struct _PASBackendSummaryClass{ - GObjectClass parent_class; -}; - -PASBackendSummary* pas_backend_summary_new (const char *summary_path, - int flush_timeout_millis); -GType pas_backend_summary_get_type (void); - -/* returns FALSE if the load fails for any reason (including that the - summary is out of date), TRUE if it succeeds */ -gboolean pas_backend_summary_load (PASBackendSummary *summary); -/* returns FALSE if the save fails, TRUE if it succeeds (or isn't required due to no changes) */ -gboolean pas_backend_summary_save (PASBackendSummary *summary); - -void pas_backend_summary_add_contact (PASBackendSummary *summary, EContact *contact); -void pas_backend_summary_remove_contact (PASBackendSummary *summary, const char *id); - -void pas_backend_summary_touch (PASBackendSummary *summary); - -/* returns TRUE if the summary's mtime is >= @t. */ -gboolean pas_backend_summary_is_up_to_date (PASBackendSummary *summary, time_t t); - -gboolean pas_backend_summary_is_summary_query (PASBackendSummary *summary, const char *query); -GPtrArray* pas_backend_summary_search (PASBackendSummary *summary, const char *query); -char* pas_backend_summary_get_summary_vcard (PASBackendSummary *summary, const char *id); - -#endif /* __PAS_BACKEND_SUMMARY_H__ */ diff --git a/addressbook/backend/pas/pas-backend-sync.c b/addressbook/backend/pas/pas-backend-sync.c deleted file mode 100644 index 45063eddc6..0000000000 --- a/addressbook/backend/pas/pas-backend-sync.c +++ /dev/null @@ -1,395 +0,0 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */ -/* - * Author: - * Chris Toshok (toshok@ximian.com) - * - * Copyright (C) 2003, Ximian, Inc. - */ - -#include <config.h> -#include "pas-backend-sync.h" -#include "pas-marshal.h" - -struct _PASBackendSyncPrivate { - int mumble; -}; - -static GObjectClass *parent_class; - -gboolean -pas_backend_sync_construct (PASBackendSync *backend) -{ - return TRUE; -} - -PASBackendSyncStatus -pas_backend_sync_create_contact (PASBackendSync *backend, - PASBook *book, - const char *vcard, - EContact **contact) -{ - g_return_val_if_fail (backend && PAS_IS_BACKEND_SYNC (backend), GNOME_Evolution_Addressbook_OtherError); - g_return_val_if_fail (book && PAS_IS_BOOK (book), GNOME_Evolution_Addressbook_OtherError); - g_return_val_if_fail (vcard, GNOME_Evolution_Addressbook_OtherError); - g_return_val_if_fail (contact, GNOME_Evolution_Addressbook_OtherError); - - g_assert (PAS_BACKEND_SYNC_GET_CLASS (backend)->create_contact_sync); - - return (* PAS_BACKEND_SYNC_GET_CLASS (backend)->create_contact_sync) (backend, book, vcard, contact); -} - -PASBackendSyncStatus -pas_backend_sync_remove (PASBackendSync *backend, - PASBook *book) -{ - g_return_val_if_fail (backend && PAS_IS_BACKEND_SYNC (backend), GNOME_Evolution_Addressbook_OtherError); - g_return_val_if_fail (book && PAS_IS_BOOK (book), GNOME_Evolution_Addressbook_OtherError); - - g_assert (PAS_BACKEND_SYNC_GET_CLASS (backend)->remove_sync); - - return (* PAS_BACKEND_SYNC_GET_CLASS (backend)->remove_sync) (backend, book); -} - -PASBackendSyncStatus -pas_backend_sync_remove_contacts (PASBackendSync *backend, - PASBook *book, - GList *id_list, - GList **removed_ids) -{ - g_return_val_if_fail (backend && PAS_IS_BACKEND_SYNC (backend), GNOME_Evolution_Addressbook_OtherError); - g_return_val_if_fail (book && PAS_IS_BOOK (book), GNOME_Evolution_Addressbook_OtherError); - g_return_val_if_fail (id_list, GNOME_Evolution_Addressbook_OtherError); - g_return_val_if_fail (removed_ids, GNOME_Evolution_Addressbook_OtherError); - - g_assert (PAS_BACKEND_SYNC_GET_CLASS (backend)->remove_contacts_sync); - - return (* PAS_BACKEND_SYNC_GET_CLASS (backend)->remove_contacts_sync) (backend, book, id_list, removed_ids); -} - -PASBackendSyncStatus -pas_backend_sync_modify_contact (PASBackendSync *backend, - PASBook *book, - const char *vcard, - EContact **contact) -{ - g_return_val_if_fail (backend && PAS_IS_BACKEND_SYNC (backend), GNOME_Evolution_Addressbook_OtherError); - g_return_val_if_fail (book && PAS_IS_BOOK (book), GNOME_Evolution_Addressbook_OtherError); - g_return_val_if_fail (vcard, GNOME_Evolution_Addressbook_OtherError); - g_return_val_if_fail (contact, GNOME_Evolution_Addressbook_OtherError); - - g_assert (PAS_BACKEND_SYNC_GET_CLASS (backend)->modify_contact_sync); - - return (* PAS_BACKEND_SYNC_GET_CLASS (backend)->modify_contact_sync) (backend, book, vcard, contact); -} - -PASBackendSyncStatus -pas_backend_sync_get_contact (PASBackendSync *backend, - PASBook *book, - const char *id, - char **vcard) -{ - g_return_val_if_fail (backend && PAS_IS_BACKEND_SYNC (backend), GNOME_Evolution_Addressbook_OtherError); - g_return_val_if_fail (book && PAS_IS_BOOK (book), GNOME_Evolution_Addressbook_OtherError); - g_return_val_if_fail (id, GNOME_Evolution_Addressbook_OtherError); - g_return_val_if_fail (vcard, GNOME_Evolution_Addressbook_OtherError); - - g_assert (PAS_BACKEND_SYNC_GET_CLASS (backend)->get_contact_sync); - - return (* PAS_BACKEND_SYNC_GET_CLASS (backend)->get_contact_sync) (backend, book, id, vcard); -} - -PASBackendSyncStatus -pas_backend_sync_get_contact_list (PASBackendSync *backend, - PASBook *book, - const char *query, - GList **contacts) -{ - g_return_val_if_fail (backend && PAS_IS_BACKEND_SYNC (backend), GNOME_Evolution_Addressbook_OtherError); - g_return_val_if_fail (book && PAS_IS_BOOK (book), GNOME_Evolution_Addressbook_OtherError); - g_return_val_if_fail (query, GNOME_Evolution_Addressbook_OtherError); - g_return_val_if_fail (contacts, GNOME_Evolution_Addressbook_OtherError); - - g_assert (PAS_BACKEND_SYNC_GET_CLASS (backend)->get_contact_list_sync); - - return (* PAS_BACKEND_SYNC_GET_CLASS (backend)->get_contact_list_sync) (backend, book, query, contacts); -} - -PASBackendSyncStatus -pas_backend_sync_get_changes (PASBackendSync *backend, - PASBook *book, - const char *change_id, - GList **changes) -{ - g_return_val_if_fail (backend && PAS_IS_BACKEND_SYNC (backend), GNOME_Evolution_Addressbook_OtherError); - g_return_val_if_fail (book && PAS_IS_BOOK (book), GNOME_Evolution_Addressbook_OtherError); - g_return_val_if_fail (change_id, GNOME_Evolution_Addressbook_OtherError); - g_return_val_if_fail (changes, GNOME_Evolution_Addressbook_OtherError); - - g_assert (PAS_BACKEND_SYNC_GET_CLASS (backend)->get_changes_sync); - - return (* PAS_BACKEND_SYNC_GET_CLASS (backend)->get_changes_sync) (backend, book, change_id, changes); -} - -PASBackendSyncStatus -pas_backend_sync_authenticate_user (PASBackendSync *backend, - PASBook *book, - const char *user, - const char *passwd, - const char *auth_method) -{ - g_return_val_if_fail (backend && PAS_IS_BACKEND_SYNC (backend), GNOME_Evolution_Addressbook_OtherError); - g_return_val_if_fail (book && PAS_IS_BOOK (book), GNOME_Evolution_Addressbook_OtherError); - g_return_val_if_fail (user && passwd && auth_method, GNOME_Evolution_Addressbook_OtherError); - - g_assert (PAS_BACKEND_SYNC_GET_CLASS (backend)->authenticate_user_sync); - - return (* PAS_BACKEND_SYNC_GET_CLASS (backend)->authenticate_user_sync) (backend, book, user, passwd, auth_method); -} - -PASBackendSyncStatus -pas_backend_sync_get_supported_fields (PASBackendSync *backend, - PASBook *book, - GList **fields) -{ - g_return_val_if_fail (backend && PAS_IS_BACKEND_SYNC (backend), GNOME_Evolution_Addressbook_OtherError); - g_return_val_if_fail (book && PAS_IS_BOOK (book), GNOME_Evolution_Addressbook_OtherError); - g_return_val_if_fail (fields, GNOME_Evolution_Addressbook_OtherError); - - g_assert (PAS_BACKEND_SYNC_GET_CLASS (backend)->get_supported_fields_sync); - - return (* PAS_BACKEND_SYNC_GET_CLASS (backend)->get_supported_fields_sync) (backend, book, fields); -} - -PASBackendSyncStatus -pas_backend_sync_get_supported_auth_methods (PASBackendSync *backend, - PASBook *book, - GList **methods) -{ - g_return_val_if_fail (backend && PAS_IS_BACKEND_SYNC (backend), GNOME_Evolution_Addressbook_OtherError); - g_return_val_if_fail (book && PAS_IS_BOOK (book), GNOME_Evolution_Addressbook_OtherError); - g_return_val_if_fail (methods, GNOME_Evolution_Addressbook_OtherError); - - g_assert (PAS_BACKEND_SYNC_GET_CLASS (backend)->get_supported_auth_methods_sync); - - return (* PAS_BACKEND_SYNC_GET_CLASS (backend)->get_supported_auth_methods_sync) (backend, book, methods); -} - -static void -_pas_backend_remove (PASBackend *backend, - PASBook *book) -{ - PASBackendSyncStatus status; - - status = pas_backend_sync_remove (PAS_BACKEND_SYNC (backend), book); - - pas_book_respond_remove (book, status); -} - -static void -_pas_backend_create_contact (PASBackend *backend, - PASBook *book, - const char *vcard) -{ - PASBackendSyncStatus status; - EContact *contact; - - status = pas_backend_sync_create_contact (PAS_BACKEND_SYNC (backend), book, vcard, &contact); - - pas_book_respond_create (book, status, contact); - - g_object_unref (contact); -} - -static void -_pas_backend_remove_contacts (PASBackend *backend, - PASBook *book, - GList *id_list) -{ - PASBackendSyncStatus status; - GList *ids = NULL; - - status = pas_backend_sync_remove_contacts (PAS_BACKEND_SYNC (backend), book, id_list, &ids); - - pas_book_respond_remove_contacts (book, status, ids); - - g_list_free (ids); -} - -static void -_pas_backend_modify_contact (PASBackend *backend, - PASBook *book, - const char *vcard) -{ - PASBackendSyncStatus status; - EContact *contact; - - status = pas_backend_sync_modify_contact (PAS_BACKEND_SYNC (backend), book, vcard, &contact); - - pas_book_respond_modify (book, status, contact); - - g_object_unref (contact); -} - -static void -_pas_backend_get_contact (PASBackend *backend, - PASBook *book, - const char *id) -{ - PASBackendSyncStatus status; - char *vcard; - - status = pas_backend_sync_get_contact (PAS_BACKEND_SYNC (backend), book, id, &vcard); - - pas_book_respond_get_contact (book, status, vcard); - - g_free (vcard); -} - -static void -_pas_backend_get_contact_list (PASBackend *backend, - PASBook *book, - const char *query) -{ - PASBackendSyncStatus status; - GList *cards = NULL; - - status = pas_backend_sync_get_contact_list (PAS_BACKEND_SYNC (backend), book, query, &cards); - - pas_book_respond_get_contact_list (book, status, cards); -} - -static void -_pas_backend_get_changes (PASBackend *backend, - PASBook *book, - const char *change_id) -{ - PASBackendSyncStatus status; - GList *changes = NULL; - - status = pas_backend_sync_get_changes (PAS_BACKEND_SYNC (backend), book, change_id, &changes); - - pas_book_respond_get_changes (book, status, changes); - - /* XXX free view? */ -} - -static void -_pas_backend_authenticate_user (PASBackend *backend, - PASBook *book, - const char *user, - const char *passwd, - const char *auth_method) -{ - PASBackendSyncStatus status; - - status = pas_backend_sync_authenticate_user (PAS_BACKEND_SYNC (backend), book, user, passwd, auth_method); - - pas_book_respond_authenticate_user (book, status); -} - -static void -_pas_backend_get_supported_fields (PASBackend *backend, - PASBook *book) -{ - PASBackendSyncStatus status; - GList *fields = NULL; - - status = pas_backend_sync_get_supported_fields (PAS_BACKEND_SYNC (backend), book, &fields); - - pas_book_respond_get_supported_fields (book, status, fields); - - g_list_foreach (fields, (GFunc)g_free, NULL); - g_list_free (fields); -} - -static void -_pas_backend_get_supported_auth_methods (PASBackend *backend, - PASBook *book) -{ - PASBackendSyncStatus status; - GList *methods = NULL; - - status = pas_backend_sync_get_supported_auth_methods (PAS_BACKEND_SYNC (backend), book, &methods); - - pas_book_respond_get_supported_auth_methods (book, status, methods); - - g_list_foreach (methods, (GFunc)g_free, NULL); - g_list_free (methods); -} - -static void -pas_backend_sync_init (PASBackendSync *backend) -{ - PASBackendSyncPrivate *priv; - - priv = g_new0 (PASBackendSyncPrivate, 1); - - backend->priv = priv; -} - -static void -pas_backend_sync_dispose (GObject *object) -{ - PASBackendSync *backend; - - backend = PAS_BACKEND_SYNC (object); - - if (backend->priv) { - g_free (backend->priv); - - backend->priv = NULL; - } - - G_OBJECT_CLASS (parent_class)->dispose (object); -} - -static void -pas_backend_sync_class_init (PASBackendSyncClass *klass) -{ - GObjectClass *object_class; - PASBackendClass *backend_class = PAS_BACKEND_CLASS (klass); - - parent_class = g_type_class_peek_parent (klass); - - object_class = (GObjectClass *) klass; - - backend_class->remove = _pas_backend_remove; - backend_class->create_contact = _pas_backend_create_contact; - backend_class->remove_contacts = _pas_backend_remove_contacts; - backend_class->modify_contact = _pas_backend_modify_contact; - backend_class->get_contact = _pas_backend_get_contact; - backend_class->get_contact_list = _pas_backend_get_contact_list; - backend_class->get_changes = _pas_backend_get_changes; - backend_class->authenticate_user = _pas_backend_authenticate_user; - backend_class->get_supported_fields = _pas_backend_get_supported_fields; - backend_class->get_supported_auth_methods = _pas_backend_get_supported_auth_methods; - - object_class->dispose = pas_backend_sync_dispose; -} - -/** - * pas_backend_get_type: - */ -GType -pas_backend_sync_get_type (void) -{ - static GType type = 0; - - if (! type) { - GTypeInfo info = { - sizeof (PASBackendSyncClass), - NULL, /* base_class_init */ - NULL, /* base_class_finalize */ - (GClassInitFunc) pas_backend_sync_class_init, - NULL, /* class_finalize */ - NULL, /* class_data */ - sizeof (PASBackendSync), - 0, /* n_preallocs */ - (GInstanceInitFunc) pas_backend_sync_init - }; - - type = g_type_register_static (PAS_TYPE_BACKEND, "PASBackendSync", &info, 0); - } - - return type; -} diff --git a/addressbook/backend/pas/pas-backend-sync.h b/addressbook/backend/pas/pas-backend-sync.h deleted file mode 100644 index 2e176d9f5d..0000000000 --- a/addressbook/backend/pas/pas-backend-sync.h +++ /dev/null @@ -1,81 +0,0 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */ -/* - */ - -#ifndef __PAS_BACKEND_SYNC_H__ -#define __PAS_BACKEND_SYNC_H__ - -#include <glib.h> -#include <pas/pas-types.h> -#include <pas/pas-backend.h> -#include <pas/addressbook.h> - -#define PAS_TYPE_BACKEND_SYNC (pas_backend_sync_get_type ()) -#define PAS_BACKEND_SYNC(o) (G_TYPE_CHECK_INSTANCE_CAST ((o), PAS_TYPE_BACKEND_SYNC, PASBackendSync)) -#define PAS_BACKEND_SYNC_CLASS(k) (G_TYPE_CHECK_CLASS_CAST((k), PAS_TYPE_BACKEND_SYNC, PASBackendSyncClass)) -#define PAS_IS_BACKEND_SYNC(o) (G_TYPE_CHECK_INSTANCE_TYPE ((o), PAS_TYPE_BACKEND_SYNC)) -#define PAS_IS_BACKEND_SYNC_CLASS(k) (G_TYPE_CHECK_CLASS_TYPE ((k), PAS_TYPE_BACKEND_SYNC)) -#define PAS_BACKEND_SYNC_GET_CLASS(k) (G_TYPE_INSTANCE_GET_CLASS ((k), PAS_TYPE_BACKEND_SYNC, PASBackendSyncClass)) - -typedef struct _PASBackendSyncPrivate PASBackendSyncPrivate; - -typedef GNOME_Evolution_Addressbook_CallStatus PASBackendSyncStatus; - -struct _PASBackendSync { - PASBackend parent_object; - PASBackendSyncPrivate *priv; -}; - -struct _PASBackendSyncClass { - PASBackendClass parent_class; - - /* Virtual methods */ - PASBackendSyncStatus (*remove_sync) (PASBackendSync *backend, PASBook *book); - PASBackendSyncStatus (*create_contact_sync) (PASBackendSync *backend, PASBook *book, - const char *vcard, EContact **contact); - PASBackendSyncStatus (*remove_contacts_sync) (PASBackendSync *backend, PASBook *book, - GList *id_list, GList **removed_ids); - PASBackendSyncStatus (*modify_contact_sync) (PASBackendSync *backend, PASBook *book, - const char *vcard, EContact **contact); - PASBackendSyncStatus (*get_contact_sync) (PASBackendSync *backend, PASBook *book, - const char *id, char **vcard); - PASBackendSyncStatus (*get_contact_list_sync) (PASBackendSync *backend, PASBook *book, - const char *query, GList **contacts); - PASBackendSyncStatus (*get_changes_sync) (PASBackendSync *backend, PASBook *book, - const char *change_id, GList **changes); - PASBackendSyncStatus (*authenticate_user_sync) (PASBackendSync *backend, PASBook *book, - const char *user, - const char *passwd, - const char *auth_method); - PASBackendSyncStatus (*get_supported_fields_sync) (PASBackendSync *backend, PASBook *book, - GList **fields); - PASBackendSyncStatus (*get_supported_auth_methods_sync) (PASBackendSync *backend, PASBook *book, - GList **methods); - - /* Padding for future expansion */ - void (*_pas_reserved0) (void); - void (*_pas_reserved1) (void); - void (*_pas_reserved2) (void); - void (*_pas_reserved3) (void); - void (*_pas_reserved4) (void); - -}; - -typedef PASBackendSync * (*PASBackendSyncFactoryFn) (void); - -gboolean pas_backend_sync_construct (PASBackendSync *backend); - -GType pas_backend_sync_get_type (void); - -PASBackendSyncStatus pas_backend_sync_remove (PASBackendSync *backend, PASBook *book); -PASBackendSyncStatus pas_backend_sync_create_contact (PASBackendSync *backend, PASBook *book, const char *vcard, EContact **contact); -PASBackendSyncStatus pas_backend_sync_remove_contacts (PASBackendSync *backend, PASBook *book, GList *id_list, GList **removed_ids); -PASBackendSyncStatus pas_backend_sync_modify_contact (PASBackendSync *backend, PASBook *book, const char *vcard, EContact **contact); -PASBackendSyncStatus pas_backend_sync_get_contact (PASBackendSync *backend, PASBook *book, const char *id, char **vcard); -PASBackendSyncStatus pas_backend_sync_get_contact_list (PASBackendSync *backend, PASBook *book, const char *query, GList **contacts); -PASBackendSyncStatus pas_backend_sync_get_changes (PASBackendSync *backend, PASBook *book, const char *change_id, GList **changes); -PASBackendSyncStatus pas_backend_sync_authenticate_user (PASBackendSync *backend, PASBook *book, const char *user, const char *passwd, const char *auth_method); -PASBackendSyncStatus pas_backend_sync_get_supported_fields (PASBackendSync *backend, PASBook *book, GList **fields); -PASBackendSyncStatus pas_backend_sync_get_supported_auth_methods (PASBackendSync *backend, PASBook *book, GList **methods); - -#endif /* ! __PAS_BACKEND_SYNC_H__ */ diff --git a/addressbook/backend/pas/pas-backend-vcf.c b/addressbook/backend/pas/pas-backend-vcf.c deleted file mode 100644 index e82fe04f56..0000000000 --- a/addressbook/backend/pas/pas-backend-vcf.c +++ /dev/null @@ -1,675 +0,0 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */ -/* - * Author: - * Chris Toshok (toshok@ximian.com) - * - * Copyright (C) 2003, Ximian, Inc. - */ - -#include "config.h" -#include "pas-backend-vcf.h" -#include "pas-backend-card-sexp.h" -#include "pas-book.h" -#include "pas-book-view.h" - -#include <stdio.h> -#include <string.h> -#include <unistd.h> -#include <errno.h> -#include <fcntl.h> -#include <time.h> -#include <sys/stat.h> - -#include <gal/util/e-util.h> -#include <gal/widgets/e-unicode.h> - -#include <ebook/e-contact.h> -#include <libgnome/gnome-i18n.h> - -#define PAS_ID_PREFIX "pas-id-" -#define FILE_FLUSH_TIMEOUT 5000 - -static PASBackendSyncClass *pas_backend_vcf_parent_class; -typedef struct _PASBackendVCFBookView PASBackendVCFBookView; -typedef struct _PASBackendVCFSearchContext PASBackendVCFSearchContext; - -struct _PASBackendVCFPrivate { - char *uri; - char *filename; - GMutex *mutex; - GHashTable *contacts; - gboolean dirty; - int flush_timeout_tag; -}; - -static char * -pas_backend_vcf_create_unique_id () -{ - /* use a 32 counter and the 32 bit timestamp to make an id. - it's doubtful 2^32 id's will be created in a second, so we - should be okay. */ - static guint c = 0; - return g_strdup_printf (PAS_ID_PREFIX "%08lX%08X", time(NULL), c++); -} - -typedef struct { - PASBackendVCF *bvcf; - PASBook *book; - PASBookView *view; -} VCFBackendSearchClosure; - -static void -free_search_closure (VCFBackendSearchClosure *closure) -{ - g_free (closure); -} - -static void -foreach_search_compare (char *id, char *vcard_string, VCFBackendSearchClosure *closure) -{ - EContact *contact; - - contact = e_contact_new_from_vcard (vcard_string); - pas_book_view_notify_update (closure->view, contact); - g_object_unref (contact); -} - -static gboolean -pas_backend_vcf_search_timeout (gpointer data) -{ - VCFBackendSearchClosure *closure = data; - - g_hash_table_foreach (closure->bvcf->priv->contacts, - (GHFunc)foreach_search_compare, - closure); - - pas_book_view_notify_complete (closure->view, GNOME_Evolution_Addressbook_Success); - - free_search_closure (closure); - - return FALSE; -} - - -static void -pas_backend_vcf_search (PASBackendVCF *bvcf, - PASBookView *book_view) -{ - const char *query = pas_book_view_get_card_query (book_view); - VCFBackendSearchClosure *closure = g_new0 (VCFBackendSearchClosure, 1); - - if ( ! strcmp (query, "(contains \"x-evolution-any-field\" \"\")")) - pas_book_view_notify_status_message (book_view, _("Loading...")); - else - pas_book_view_notify_status_message (book_view, _("Searching...")); - - closure->view = book_view; - closure->bvcf = bvcf; - - g_idle_add (pas_backend_vcf_search_timeout, closure); -} - -static void -insert_contact (PASBackendVCF *vcf, char *vcard) -{ - EContact *contact = e_contact_new_from_vcard (vcard); - char *id; - - id = e_contact_get (contact, E_CONTACT_UID); - if (id) - g_hash_table_insert (vcf->priv->contacts, - id, - e_vcard_to_string (E_VCARD (contact), EVC_FORMAT_VCARD_30)); -} - -static void -load_file (PASBackendVCF *vcf, int fd) -{ - FILE *fp; - GString *str; - char buf[1024]; - - fp = fdopen (fd, "r"); - if (!fp) { - g_warning ("failed to open `%s' for reading", vcf->priv->filename); - return; - } - - str = g_string_new (""); - - while (fgets (buf, sizeof (buf), fp)) { - if (!strcmp (buf, "\r\n")) { - /* if the string has accumulated some stuff, create a contact for it and start over */ - if (str->len) { - insert_contact (vcf, str->str); - g_string_assign (str, ""); - } - } - else { - g_string_append (str, buf); - } - } - if (str->len) { - insert_contact (vcf, str->str); - } - - g_string_free (str, TRUE); - - fclose (fp); -} - -static void -foreach_build_list (char *id, char *vcard_string, GList **list) -{ - *list = g_list_append (*list, vcard_string); -} - -static gboolean -save_file (PASBackendVCF *vcf) -{ - GList *vcards = NULL; - GList *l; - char *new_path; - int fd, rv; - - g_warning ("PASBackendVCF flushing file to disk"); - - g_mutex_lock (vcf->priv->mutex); - g_hash_table_foreach (vcf->priv->contacts, (GHFunc)foreach_build_list, &vcards); - - new_path = g_strdup_printf ("%s.new", vcf->priv->filename); - - fd = open (new_path, O_CREAT | O_TRUNC | O_WRONLY, 0666); - - for (l = vcards; l; l = l->next) { - char *vcard_str = l->data; - int len = strlen (vcard_str); - - rv = write (fd, vcard_str, len); - - if (rv < len) { - /* XXX */ - g_warning ("write failed. we need to handle short writes\n"); - close (fd); - unlink (new_path); - return FALSE; - } - - rv = write (fd, "\r\n\r\n", 4); - if (rv < 4) { - /* XXX */ - g_warning ("write failed. we need to handle short writes\n"); - close (fd); - unlink (new_path); - return FALSE; - } - } - - if (0 > rename (new_path, vcf->priv->filename)) { - g_warning ("Failed to rename %s: %s\n", vcf->priv->filename, strerror(errno)); - unlink (new_path); - return FALSE; - } - - g_list_free (vcards); - g_free (new_path); - - vcf->priv->dirty = FALSE; - - g_mutex_unlock (vcf->priv->mutex); - - return TRUE; -} - -static gboolean -vcf_flush_file (gpointer data) -{ - PASBackendVCF *bvcf = PAS_BACKEND_VCF (data); - - if (!bvcf->priv->dirty) { - bvcf->priv->flush_timeout_tag = 0; - return FALSE; - } - - if (!save_file (bvcf)) { - g_warning ("failed to flush the .vcf file to disk, will try again next timeout"); - return TRUE; - } - - bvcf->priv->flush_timeout_tag = 0; - return FALSE; -} - -static EContact * -do_create(PASBackendVCF *bvcf, - const char *vcard_req, - gboolean dirty_the_file) -{ - char *id; - EContact *contact; - char *vcard; - - /* at the very least we need the unique_id generation to be - protected by the lock, even if the actual vcard parsing - isn't. */ - g_mutex_lock (bvcf->priv->mutex); - id = pas_backend_vcf_create_unique_id (); - - contact = e_contact_new_from_vcard (vcard_req); - e_contact_set(contact, E_CONTACT_UID, id); - vcard = e_vcard_to_string (E_VCARD (contact), EVC_FORMAT_VCARD_30); - - g_hash_table_insert (bvcf->priv->contacts, id, vcard); - - if (dirty_the_file) { - bvcf->priv->dirty = TRUE; - - if (!bvcf->priv->flush_timeout_tag) - bvcf->priv->flush_timeout_tag = g_timeout_add (FILE_FLUSH_TIMEOUT, - vcf_flush_file, bvcf); - } - - g_mutex_unlock (bvcf->priv->mutex); - - return contact; -} - -static PASBackendSyncStatus -pas_backend_vcf_process_create_contact (PASBackendSync *backend, - PASBook *book, - const char *vcard, - EContact **contact) -{ - PASBackendVCF *bvcf = PAS_BACKEND_VCF (backend); - - *contact = do_create(bvcf, vcard, TRUE); - if (*contact) { - return GNOME_Evolution_Addressbook_Success; - } - else { - /* XXX need a different call status for this case, i - think */ - return GNOME_Evolution_Addressbook_ContactNotFound; - } -} - -static PASBackendSyncStatus -pas_backend_vcf_process_remove_contacts (PASBackendSync *backend, - PASBook *book, - GList *id_list, - GList **ids) -{ - /* FIXME: make this handle bulk deletes like the file backend does */ - PASBackendVCF *bvcf = PAS_BACKEND_VCF (backend); - char *id = id_list->data; - gboolean success; - - g_mutex_lock (bvcf->priv->mutex); - success = g_hash_table_remove (bvcf->priv->contacts, id); - - if (!success) { - g_mutex_unlock (bvcf->priv->mutex); - return GNOME_Evolution_Addressbook_ContactNotFound; - } - else { - bvcf->priv->dirty = TRUE; - if (!bvcf->priv->flush_timeout_tag) - bvcf->priv->flush_timeout_tag = g_timeout_add (FILE_FLUSH_TIMEOUT, - vcf_flush_file, bvcf); - g_mutex_unlock (bvcf->priv->mutex); - - *ids = g_list_append (*ids, id); - - return GNOME_Evolution_Addressbook_Success; - } -} - -static PASBackendSyncStatus -pas_backend_vcf_process_modify_contact (PASBackendSync *backend, - PASBook *book, - const char *vcard, - EContact **contact) -{ - PASBackendVCF *bvcf = PAS_BACKEND_VCF (backend); - char *old_id, *old_vcard_string; - const char *id; - gboolean success; - - /* create a new ecard from the request data */ - *contact = e_contact_new_from_vcard (vcard); - id = e_contact_get_const (*contact, E_CONTACT_UID); - - g_mutex_lock (bvcf->priv->mutex); - success = g_hash_table_lookup_extended (bvcf->priv->contacts, id, (gpointer)&old_id, (gpointer)&old_vcard_string); - - if (!success) { - g_mutex_unlock (bvcf->priv->mutex); - return GNOME_Evolution_Addressbook_ContactNotFound; - } - else { - g_hash_table_insert (bvcf->priv->contacts, old_id, g_strdup (vcard)); - bvcf->priv->dirty = TRUE; - if (!bvcf->priv->flush_timeout_tag) - bvcf->priv->flush_timeout_tag = g_timeout_add (FILE_FLUSH_TIMEOUT, - vcf_flush_file, bvcf); - g_mutex_unlock (bvcf->priv->mutex); - - g_free (old_vcard_string); - - return GNOME_Evolution_Addressbook_Success; - } -} - -static PASBackendSyncStatus -pas_backend_vcf_process_get_contact (PASBackendSync *backend, - PASBook *book, - const char *id, - char **vcard) -{ - PASBackendVCF *bvcf = PAS_BACKEND_VCF (backend); - char *v; - - v = g_hash_table_lookup (bvcf->priv->contacts, id); - - if (v) { - *vcard = g_strdup (v); - return GNOME_Evolution_Addressbook_Success; - } else { - *vcard = g_strdup (""); - return GNOME_Evolution_Addressbook_ContactNotFound; - } -} - - -typedef struct { - PASBackendVCF *bvcf; - gboolean search_needed; - PASBackendCardSExp *card_sexp; - GList *list; -} GetContactListClosure; - -static void -foreach_get_contact_compare (char *id, char *vcard_string, GetContactListClosure *closure) -{ - if ((!closure->search_needed) || pas_backend_card_sexp_match_vcard (closure->card_sexp, vcard_string)) { - closure->list = g_list_append (closure->list, g_strdup (vcard_string)); - } -} - -static PASBackendSyncStatus -pas_backend_vcf_process_get_contact_list (PASBackendSync *backend, - PASBook *book, - const char *query, - GList **contacts) -{ - PASBackendVCF *bvcf = PAS_BACKEND_VCF (backend); - const char *search = query; - GetContactListClosure closure; - - closure.bvcf = bvcf; - closure.search_needed = strcmp (search, "(contains \"x-evolution-any-field\" \"\")"); - closure.card_sexp = pas_backend_card_sexp_new (search); - closure.list = NULL; - - g_hash_table_foreach (bvcf->priv->contacts, (GHFunc)foreach_get_contact_compare, &closure); - - g_object_unref (closure.card_sexp); - - *contacts = closure.list; - return GNOME_Evolution_Addressbook_Success; -} - -static void -pas_backend_vcf_start_book_view (PASBackend *backend, - PASBookView *book_view) -{ - pas_backend_vcf_search (PAS_BACKEND_VCF (backend), book_view); -} - -static void -pas_backend_vcf_stop_book_view (PASBackend *backend, - PASBookView *book_view) -{ - /* XXX nothing here yet, and there should be. */ -} - -static char * -pas_backend_vcf_extract_path_from_uri (const char *uri) -{ - g_assert (strncasecmp (uri, "vcf://", 6) == 0); - - return g_strdup (uri + 6); -} - -static PASBackendSyncStatus -pas_backend_vcf_process_authenticate_user (PASBackendSync *backend, - PASBook *book, - const char *user, - const char *passwd, - const char *auth_method) -{ - return GNOME_Evolution_Addressbook_Success; -} - -static PASBackendSyncStatus -pas_backend_vcf_process_get_supported_fields (PASBackendSync *backend, - PASBook *book, - GList **fields_out) -{ - GList *fields = NULL; - int i; - - /* XXX we need a way to say "we support everything", since the - vcf backend does */ - for (i = 0; i < E_CONTACT_FIELD_LAST; i ++) - fields = g_list_append (fields, (char*)e_contact_field_name (i)); - - *fields_out = fields; - return GNOME_Evolution_Addressbook_Success; -} - -#include "ximian-vcard.h" - -static GNOME_Evolution_Addressbook_CallStatus -pas_backend_vcf_load_uri (PASBackend *backend, - const char *uri, - gboolean only_if_exists) -{ - PASBackendVCF *bvcf = PAS_BACKEND_VCF (backend); - char *dirname; - gboolean writable = FALSE; - int fd; - - g_free(bvcf->priv->uri); - bvcf->priv->uri = g_strdup (uri); - - dirname = pas_backend_vcf_extract_path_from_uri (uri); - bvcf->priv->filename = g_build_filename (dirname, "addressbook.vcf", NULL); - - fd = open (bvcf->priv->filename, O_RDWR); - - bvcf->priv->contacts = g_hash_table_new_full (g_str_hash, g_str_equal, - g_free, g_free); - - if (fd != -1) { - writable = TRUE; - } else { - fd = open (bvcf->priv->filename, O_RDONLY); - - if (fd == -1) { - fd = open (bvcf->priv->filename, O_CREAT, 0666); - - if (fd != -1 && !only_if_exists) { - EContact *contact; - - contact = do_create(bvcf, XIMIAN_VCARD, FALSE); - save_file (bvcf); - - /* XXX check errors here */ - g_object_unref (contact); - - writable = TRUE; - } - } - } - - if (fd == -1) { - g_warning ("Failed to open addressbook at uri `%s'", uri); - g_warning ("error == %s", strerror(errno)); - return GNOME_Evolution_Addressbook_OtherError; - } - - load_file (bvcf, fd); - - pas_backend_set_is_loaded (backend, TRUE); - pas_backend_set_is_writable (backend, writable); - - return GNOME_Evolution_Addressbook_Success; -} - -static char * -pas_backend_vcf_get_static_capabilities (PASBackend *backend) -{ - return g_strdup("local,do-initial-query"); -} - -static GNOME_Evolution_Addressbook_CallStatus -pas_backend_vcf_cancel_operation (PASBackend *backend, PASBook *book) -{ - return GNOME_Evolution_Addressbook_CouldNotCancel; -} - -static gboolean -pas_backend_vcf_construct (PASBackendVCF *backend) -{ - g_assert (backend != NULL); - g_assert (PAS_IS_BACKEND_VCF (backend)); - - if (! pas_backend_construct (PAS_BACKEND (backend))) - return FALSE; - - return TRUE; -} - -/** - * pas_backend_vcf_new: - */ -PASBackend * -pas_backend_vcf_new (void) -{ - PASBackendVCF *backend; - - backend = g_object_new (PAS_TYPE_BACKEND_VCF, NULL); - - if (! pas_backend_vcf_construct (backend)) { - g_object_unref (backend); - - return NULL; - } - - return PAS_BACKEND (backend); -} - -static void -pas_backend_vcf_dispose (GObject *object) -{ - PASBackendVCF *bvcf; - - bvcf = PAS_BACKEND_VCF (object); - - if (bvcf->priv) { - - g_mutex_lock (bvcf->priv->mutex); - - if (bvcf->priv->flush_timeout_tag) { - g_source_remove (bvcf->priv->flush_timeout_tag); - bvcf->priv->flush_timeout_tag = 0; - } - - if (bvcf->priv->dirty) - save_file (bvcf); - - g_hash_table_destroy (bvcf->priv->contacts); - - g_free (bvcf->priv->uri); - g_free (bvcf->priv->filename); - - g_mutex_unlock (bvcf->priv->mutex); - - g_mutex_free (bvcf->priv->mutex); - - g_free (bvcf->priv); - bvcf->priv = NULL; - } - - G_OBJECT_CLASS (pas_backend_vcf_parent_class)->dispose (object); -} - -static void -pas_backend_vcf_class_init (PASBackendVCFClass *klass) -{ - GObjectClass *object_class = G_OBJECT_CLASS (klass); - PASBackendSyncClass *sync_class; - PASBackendClass *backend_class; - - pas_backend_vcf_parent_class = g_type_class_peek_parent (klass); - - sync_class = PAS_BACKEND_SYNC_CLASS (klass); - backend_class = PAS_BACKEND_CLASS (klass); - - /* Set the virtual methods. */ - backend_class->load_uri = pas_backend_vcf_load_uri; - backend_class->get_static_capabilities = pas_backend_vcf_get_static_capabilities; - backend_class->start_book_view = pas_backend_vcf_start_book_view; - backend_class->stop_book_view = pas_backend_vcf_stop_book_view; - backend_class->cancel_operation = pas_backend_vcf_cancel_operation; - - sync_class->create_contact_sync = pas_backend_vcf_process_create_contact; - sync_class->remove_contacts_sync = pas_backend_vcf_process_remove_contacts; - sync_class->modify_contact_sync = pas_backend_vcf_process_modify_contact; - sync_class->get_contact_sync = pas_backend_vcf_process_get_contact; - sync_class->get_contact_list_sync = pas_backend_vcf_process_get_contact_list; - sync_class->authenticate_user_sync = pas_backend_vcf_process_authenticate_user; - sync_class->get_supported_fields_sync = pas_backend_vcf_process_get_supported_fields; - - object_class->dispose = pas_backend_vcf_dispose; -} - -static void -pas_backend_vcf_init (PASBackendVCF *backend) -{ - PASBackendVCFPrivate *priv; - - priv = g_new0 (PASBackendVCFPrivate, 1); - priv->uri = NULL; - priv->mutex = g_mutex_new(); - - backend->priv = priv; -} - -/** - * pas_backend_vcf_get_type: - */ -GType -pas_backend_vcf_get_type (void) -{ - static GType type = 0; - - if (! type) { - GTypeInfo info = { - sizeof (PASBackendVCFClass), - NULL, /* base_class_init */ - NULL, /* base_class_finalize */ - (GClassInitFunc) pas_backend_vcf_class_init, - NULL, /* class_finalize */ - NULL, /* class_data */ - sizeof (PASBackendVCF), - 0, /* n_preallocs */ - (GInstanceInitFunc) pas_backend_vcf_init - }; - - type = g_type_register_static (PAS_TYPE_BACKEND_SYNC, "PASBackendVCF", &info, 0); - } - - return type; -} diff --git a/addressbook/backend/pas/pas-backend-vcf.h b/addressbook/backend/pas/pas-backend-vcf.h deleted file mode 100644 index 81c872dcf1..0000000000 --- a/addressbook/backend/pas/pas-backend-vcf.h +++ /dev/null @@ -1,35 +0,0 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */ -/* - * Author: - * Chris Toshok (toshok@ximian.com) - * Copyright (C) 2003, Ximian, Inc. - */ - -#ifndef __PAS_BACKEND_VCF_H__ -#define __PAS_BACKEND_VCF_H__ - -#include "pas-backend-sync.h" - -#define PAS_TYPE_BACKEND_VCF (pas_backend_vcf_get_type ()) -#define PAS_BACKEND_VCF(o) (G_TYPE_CHECK_INSTANCE_CAST ((o), PAS_TYPE_BACKEND_VCF, PASBackendVCF)) -#define PAS_BACKEND_VCF_CLASS(k) (G_TYPE_CHECK_CLASS_CAST((k), PAS_BACKEND_TYPE, PASBackendVCFClass)) -#define PAS_IS_BACKEND_VCF(o) (G_TYPE_CHECK_INSTANCE_TYPE ((o), PAS_TYPE_BACKEND_VCF)) -#define PAS_IS_BACKEND_VCF_CLASS(k) (G_TYPE_CHECK_CLASS_TYPE ((k), PAS_TYPE_BACKEND_VCF)) -#define PAS_BACKEND_VCF_GET_CLASS(k) (G_TYPE_INSTANCE_GET_CLASS ((obj), PAS_TYPE_BACKEND_VCF, PASBackendVCFClass)) - -typedef struct _PASBackendVCFPrivate PASBackendVCFPrivate; - -typedef struct { - PASBackendSync parent_object; - PASBackendVCFPrivate *priv; -} PASBackendVCF; - -typedef struct { - PASBackendSyncClass parent_class; -} PASBackendVCFClass; - -PASBackend *pas_backend_vcf_new (void); -GType pas_backend_vcf_get_type (void); - -#endif /* ! __PAS_BACKEND_VCF_H__ */ - diff --git a/addressbook/backend/pas/pas-backend.c b/addressbook/backend/pas/pas-backend.c deleted file mode 100644 index a447d64851..0000000000 --- a/addressbook/backend/pas/pas-backend.c +++ /dev/null @@ -1,671 +0,0 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */ -/* - * Author: - * Nat Friedman (nat@ximian.com) - * - * Copyright 2000, Ximian, Inc. - */ - -#include <config.h> -#include <pthread.h> -#include "pas-book-view.h" -#include "pas-backend.h" -#include "pas-marshal.h" - -struct _PASBackendPrivate { - GMutex *open_mutex; - - GMutex *clients_mutex; - GList *clients; - - char *uri; - gboolean loaded, writable, removed; - - GMutex *views_mutex; - EList *views; -}; - -/* Signal IDs */ -enum { - LAST_CLIENT_GONE, - LAST_SIGNAL -}; - -static guint pas_backend_signals[LAST_SIGNAL]; - -static GObjectClass *parent_class; - -gboolean -pas_backend_construct (PASBackend *backend) -{ - return TRUE; -} - -GNOME_Evolution_Addressbook_CallStatus -pas_backend_load_uri (PASBackend *backend, - const char *uri, - gboolean only_if_exists) -{ - GNOME_Evolution_Addressbook_CallStatus status; - - g_return_val_if_fail (backend && PAS_IS_BACKEND (backend), FALSE); - g_return_val_if_fail (uri, FALSE); - g_return_val_if_fail (backend->priv->loaded == FALSE, FALSE); - - g_assert (PAS_BACKEND_GET_CLASS (backend)->load_uri); - - status = (* PAS_BACKEND_GET_CLASS (backend)->load_uri) (backend, uri, only_if_exists); - - if (status == GNOME_Evolution_Addressbook_Success) - backend->priv->uri = g_strdup (uri); - - return status; -} - -/** - * pas_backend_get_uri: - * @backend: An addressbook backend. - * - * Queries the URI that an addressbook backend is serving. - * - * Return value: URI for the backend. - **/ -const char * -pas_backend_get_uri (PASBackend *backend) -{ - g_return_val_if_fail (backend && PAS_IS_BACKEND (backend), NULL); - - return backend->priv->uri; -} - -void -pas_backend_open (PASBackend *backend, - PASBook *book, - gboolean only_if_exists) -{ - g_return_if_fail (backend && PAS_IS_BACKEND (backend)); - g_return_if_fail (book && PAS_IS_BOOK (book)); - - g_mutex_lock (backend->priv->open_mutex); - - if (backend->priv->loaded) { - pas_book_respond_open ( - book, GNOME_Evolution_Addressbook_Success); - - pas_book_report_writable (book, backend->priv->writable); - } else { - GNOME_Evolution_Addressbook_CallStatus status = - pas_backend_load_uri (backend, pas_book_get_uri (book), only_if_exists); - - pas_book_respond_open (book, status); - - if (status == GNOME_Evolution_Addressbook_Success) - pas_book_report_writable (book, backend->priv->writable); - } - - g_mutex_unlock (backend->priv->open_mutex); -} - -void -pas_backend_remove (PASBackend *backend, - PASBook *book) -{ - g_return_if_fail (backend && PAS_IS_BACKEND (backend)); - g_return_if_fail (book && PAS_IS_BOOK (book)); - - g_assert (PAS_BACKEND_GET_CLASS (backend)->remove); - - (* PAS_BACKEND_GET_CLASS (backend)->remove) (backend, book); -} - -void -pas_backend_create_contact (PASBackend *backend, - PASBook *book, - const char *vcard) -{ - g_return_if_fail (backend && PAS_IS_BACKEND (backend)); - g_return_if_fail (book && PAS_IS_BOOK (book)); - g_return_if_fail (vcard); - - g_assert (PAS_BACKEND_GET_CLASS (backend)->create_contact); - - (* PAS_BACKEND_GET_CLASS (backend)->create_contact) (backend, book, vcard); -} - -void -pas_backend_remove_contacts (PASBackend *backend, - PASBook *book, - GList *id_list) -{ - g_return_if_fail (backend && PAS_IS_BACKEND (backend)); - g_return_if_fail (book && PAS_IS_BOOK (book)); - g_return_if_fail (id_list); - - g_assert (PAS_BACKEND_GET_CLASS (backend)->remove_contacts); - - (* PAS_BACKEND_GET_CLASS (backend)->remove_contacts) (backend, book, id_list); -} - -void -pas_backend_modify_contact (PASBackend *backend, - PASBook *book, - const char *vcard) -{ - g_return_if_fail (backend && PAS_IS_BACKEND (backend)); - g_return_if_fail (book && PAS_IS_BOOK (book)); - g_return_if_fail (vcard); - - g_assert (PAS_BACKEND_GET_CLASS (backend)->modify_contact); - - (* PAS_BACKEND_GET_CLASS (backend)->modify_contact) (backend, book, vcard); -} - -void -pas_backend_get_contact (PASBackend *backend, - PASBook *book, - const char *id) -{ - g_return_if_fail (backend && PAS_IS_BACKEND (backend)); - g_return_if_fail (book && PAS_IS_BOOK (book)); - g_return_if_fail (id); - - g_assert (PAS_BACKEND_GET_CLASS (backend)->get_contact); - - (* PAS_BACKEND_GET_CLASS (backend)->get_contact) (backend, book, id); -} - -void -pas_backend_get_contact_list (PASBackend *backend, - PASBook *book, - const char *query) -{ - g_return_if_fail (backend && PAS_IS_BACKEND (backend)); - g_return_if_fail (book && PAS_IS_BOOK (book)); - g_return_if_fail (query); - - g_assert (PAS_BACKEND_GET_CLASS (backend)->get_contact_list); - - (* PAS_BACKEND_GET_CLASS (backend)->get_contact_list) (backend, book, query); -} - -void -pas_backend_start_book_view (PASBackend *backend, - PASBookView *book_view) -{ - g_return_if_fail (backend && PAS_IS_BACKEND (backend)); - g_return_if_fail (book_view && PAS_IS_BOOK_VIEW (book_view)); - - g_assert (PAS_BACKEND_GET_CLASS (backend)->start_book_view); - - (* PAS_BACKEND_GET_CLASS (backend)->start_book_view) (backend, book_view); -} - -void -pas_backend_stop_book_view (PASBackend *backend, - PASBookView *book_view) -{ - g_return_if_fail (backend && PAS_IS_BACKEND (backend)); - g_return_if_fail (book_view && PAS_IS_BOOK_VIEW (book_view)); - - g_assert (PAS_BACKEND_GET_CLASS (backend)->stop_book_view); - - (* PAS_BACKEND_GET_CLASS (backend)->stop_book_view) (backend, book_view); -} - -void -pas_backend_get_changes (PASBackend *backend, - PASBook *book, - const char *change_id) -{ - g_return_if_fail (backend && PAS_IS_BACKEND (backend)); - g_return_if_fail (book && PAS_IS_BOOK (book)); - g_return_if_fail (change_id); - - g_assert (PAS_BACKEND_GET_CLASS (backend)->get_changes); - - (* PAS_BACKEND_GET_CLASS (backend)->get_changes) (backend, book, change_id); -} - -void -pas_backend_authenticate_user (PASBackend *backend, - PASBook *book, - const char *user, - const char *passwd, - const char *auth_method) -{ - g_return_if_fail (backend && PAS_IS_BACKEND (backend)); - g_return_if_fail (book && PAS_IS_BOOK (book)); - g_return_if_fail (user && passwd && auth_method); - - g_assert (PAS_BACKEND_GET_CLASS (backend)->authenticate_user); - - (* PAS_BACKEND_GET_CLASS (backend)->authenticate_user) (backend, book, user, passwd, auth_method); -} - -void -pas_backend_get_supported_fields (PASBackend *backend, - PASBook *book) - -{ - g_return_if_fail (backend && PAS_IS_BACKEND (backend)); - g_return_if_fail (book && PAS_IS_BOOK (book)); - - g_assert (PAS_BACKEND_GET_CLASS (backend)->get_supported_fields); - - (* PAS_BACKEND_GET_CLASS (backend)->get_supported_fields) (backend, book); -} - -void -pas_backend_get_supported_auth_methods (PASBackend *backend, - PASBook *book) -{ - g_return_if_fail (backend && PAS_IS_BACKEND (backend)); - g_return_if_fail (book && PAS_IS_BOOK (book)); - - g_assert (PAS_BACKEND_GET_CLASS (backend)->get_supported_auth_methods); - - (* PAS_BACKEND_GET_CLASS (backend)->get_supported_auth_methods) (backend, book); -} - -GNOME_Evolution_Addressbook_CallStatus -pas_backend_cancel_operation (PASBackend *backend, - PASBook *book) -{ - g_return_val_if_fail (backend && PAS_IS_BACKEND (backend), GNOME_Evolution_Addressbook_OtherError); - g_return_val_if_fail (book && PAS_IS_BOOK (book), GNOME_Evolution_Addressbook_OtherError); - - g_assert (PAS_BACKEND_GET_CLASS (backend)->cancel_operation); - - return (* PAS_BACKEND_GET_CLASS (backend)->cancel_operation) (backend, book); -} - -static void -book_destroy_cb (gpointer data, GObject *where_book_was) -{ - PASBackend *backend = PAS_BACKEND (data); - - pas_backend_remove_client (backend, (PASBook *)where_book_was); -} - -static void -listener_died_cb (gpointer cnx, gpointer user_data) -{ - PASBook *book = PAS_BOOK (user_data); - - pas_backend_remove_client (pas_book_get_backend (book), book); -} - -static void -last_client_gone (PASBackend *backend) -{ - g_signal_emit (backend, pas_backend_signals[LAST_CLIENT_GONE], 0); -} - -EList* -pas_backend_get_book_views (PASBackend *backend) -{ - g_return_val_if_fail (backend && PAS_IS_BACKEND (backend), FALSE); - - return g_object_ref (backend->priv->views); -} - -void -pas_backend_add_book_view (PASBackend *backend, - PASBookView *view) -{ - g_mutex_lock (backend->priv->views_mutex); - - e_list_append (backend->priv->views, view); - - g_mutex_unlock (backend->priv->views_mutex); -} - -void -pas_backend_remove_book_view (PASBackend *backend, - PASBookView *view) -{ - g_mutex_lock (backend->priv->views_mutex); - - e_list_remove (backend->priv->views, view); - - g_mutex_unlock (backend->priv->views_mutex); -} - -/** - * pas_backend_add_client: - * @backend: An addressbook backend. - * @book: the corba object representing the client connection. - * - * Adds a client to an addressbook backend. - * - * Return value: TRUE on success, FALSE on failure to add the client. - */ -gboolean -pas_backend_add_client (PASBackend *backend, - PASBook *book) -{ - g_return_val_if_fail (backend && PAS_IS_BACKEND (backend), FALSE); - g_return_val_if_fail (book && PAS_IS_BOOK (book), FALSE); - - bonobo_object_set_immortal (BONOBO_OBJECT (book), TRUE); - - g_object_weak_ref (G_OBJECT (book), book_destroy_cb, backend); - - ORBit_small_listen_for_broken (pas_book_get_listener (book), G_CALLBACK (listener_died_cb), book); - - g_mutex_lock (backend->priv->clients_mutex); - backend->priv->clients = g_list_prepend (backend->priv->clients, book); - g_mutex_unlock (backend->priv->clients_mutex); - - return TRUE; -} - -void -pas_backend_remove_client (PASBackend *backend, - PASBook *book) -{ - /* XXX this needs a bit more thinking wrt the mutex - we - should be holding it when we check to see if clients is - NULL */ - - g_return_if_fail (backend && PAS_IS_BACKEND (backend)); - g_return_if_fail (book && PAS_IS_BOOK (book)); - - /* Disconnect */ - g_mutex_lock (backend->priv->clients_mutex); - backend->priv->clients = g_list_remove (backend->priv->clients, book); - g_mutex_unlock (backend->priv->clients_mutex); - - /* When all clients go away, notify the parent factory about it so that - * it may decide whether to kill the backend or not. - */ - if (!backend->priv->clients) - last_client_gone (backend); -} - -char * -pas_backend_get_static_capabilities (PASBackend *backend) -{ - g_return_val_if_fail (backend && PAS_IS_BACKEND (backend), NULL); - - g_assert (PAS_BACKEND_GET_CLASS (backend)->get_static_capabilities); - - return PAS_BACKEND_GET_CLASS (backend)->get_static_capabilities (backend); -} - -gboolean -pas_backend_is_loaded (PASBackend *backend) -{ - g_return_val_if_fail (backend && PAS_IS_BACKEND (backend), FALSE); - - return backend->priv->loaded; -} - -void -pas_backend_set_is_loaded (PASBackend *backend, gboolean is_loaded) -{ - g_return_if_fail (backend && PAS_IS_BACKEND (backend)); - - backend->priv->loaded = is_loaded; -} - -gboolean -pas_backend_is_writable (PASBackend *backend) -{ - g_return_val_if_fail (backend && PAS_IS_BACKEND (backend), FALSE); - - return backend->priv->writable; -} - -void -pas_backend_set_is_writable (PASBackend *backend, gboolean is_writable) -{ - g_return_if_fail (backend && PAS_IS_BACKEND (backend)); - - backend->priv->writable = is_writable; -} - -gboolean -pas_backend_is_removed (PASBackend *backend) -{ - g_return_val_if_fail (backend && PAS_IS_BACKEND (backend), FALSE); - - return backend->priv->removed; -} - -void -pas_backend_set_is_removed (PASBackend *backend, gboolean is_removed) -{ - g_return_if_fail (backend && PAS_IS_BACKEND (backend)); - - backend->priv->removed = is_removed; -} - - - -GNOME_Evolution_Addressbook_BookChangeItem* -pas_backend_change_add_new (const char *vcard) -{ - GNOME_Evolution_Addressbook_BookChangeItem* new_change = GNOME_Evolution_Addressbook_BookChangeItem__alloc(); - - new_change->changeType= GNOME_Evolution_Addressbook_ContactAdded; - new_change->vcard = CORBA_string_dup (vcard); - - return new_change; -} - -GNOME_Evolution_Addressbook_BookChangeItem* -pas_backend_change_modify_new (const char *vcard) -{ - GNOME_Evolution_Addressbook_BookChangeItem* new_change = GNOME_Evolution_Addressbook_BookChangeItem__alloc(); - - new_change->changeType= GNOME_Evolution_Addressbook_ContactModified; - new_change->vcard = CORBA_string_dup (vcard); - - return new_change; -} - -GNOME_Evolution_Addressbook_BookChangeItem* -pas_backend_change_delete_new (const char *vcard) -{ - GNOME_Evolution_Addressbook_BookChangeItem* new_change = GNOME_Evolution_Addressbook_BookChangeItem__alloc(); - - new_change->changeType= GNOME_Evolution_Addressbook_ContactDeleted; - new_change->vcard = CORBA_string_dup (vcard); - - return new_change; -} - - - -static void -pas_backend_foreach_view (PASBackend *backend, - void (*callback) (PASBookView *, gpointer), - gpointer user_data) -{ - EList *views; - PASBookView *view; - EIterator *iter; - - views = pas_backend_get_book_views (backend); - iter = e_list_get_iterator (views); - - while (e_iterator_is_valid (iter)) { - view = (PASBookView*)e_iterator_get (iter); - - bonobo_object_ref (view); - callback (view, user_data); - bonobo_object_unref (view); - - e_iterator_next (iter); - } - - g_object_unref (iter); - g_object_unref (views); -} - - -static void -view_notify_update (PASBookView *view, gpointer contact) -{ - pas_book_view_notify_update (view, contact); -} - -/** - * pas_backend_notify_update: - * @backend: an addressbook backend - * @contact: a new or modified contact - * - * Notifies all of @backend's book views about the new or modified - * contacts @contact. - * - * pas_book_respond_create() and pas_book_respond_modify() call this - * function for you. You only need to call this from your backend if - * contacts are created or modified by another (non-PAS-using) client. - **/ -void -pas_backend_notify_update (PASBackend *backend, EContact *contact) -{ - pas_backend_foreach_view (backend, view_notify_update, contact); -} - - -static void -view_notify_remove (PASBookView *view, gpointer id) -{ - pas_book_view_notify_remove (view, id); -} - -/** - * pas_backend_notify_remove: - * @backend: an addressbook backend - * @id: a contact id - * - * Notifies all of @backend's book views that the contact with UID - * @id has been removed. - * - * pas_book_respond_remove_contacts() calls this function for you. You - * only need to call this from your backend if contacts are removed by - * another (non-PAS-using) client. - **/ -void -pas_backend_notify_remove (PASBackend *backend, const char *id) -{ - pas_backend_foreach_view (backend, view_notify_remove, (gpointer)id); -} - - -static void -view_notify_complete (PASBookView *view, gpointer unused) -{ - pas_book_view_notify_complete (view, GNOME_Evolution_Addressbook_Success); -} - -/** - * pas_backend_notify_complete: - * @backend: an addressbook backend - * - * Notifies all of @backend's book views that the current set of - * notifications is complete; use this after a series of - * pas_backend_notify_update() and pas_backend_notify_remove() calls. - **/ -void -pas_backend_notify_complete (PASBackend *backend) -{ - pas_backend_foreach_view (backend, view_notify_complete, NULL); -} - - - -static void -pas_backend_init (PASBackend *backend) -{ - PASBackendPrivate *priv; - - priv = g_new0 (PASBackendPrivate, 1); - priv->uri = NULL; - priv->clients = NULL; - priv->views = e_list_new((EListCopyFunc) g_object_ref, (EListFreeFunc) g_object_unref, NULL); - priv->open_mutex = g_mutex_new (); - priv->clients_mutex = g_mutex_new (); - priv->views_mutex = g_mutex_new (); - - backend->priv = priv; -} - -static void -pas_backend_dispose (GObject *object) -{ - PASBackend *backend; - - backend = PAS_BACKEND (object); - - if (backend->priv) { - g_list_free (backend->priv->clients); - - if (backend->priv->uri) - g_free (backend->priv->uri); - - if (backend->priv->views) { - g_object_unref (backend->priv->views); - backend->priv->views = NULL; - } - - g_mutex_free (backend->priv->open_mutex); - g_mutex_free (backend->priv->clients_mutex); - g_mutex_free (backend->priv->views_mutex); - - g_free (backend->priv); - backend->priv = NULL; - } - - G_OBJECT_CLASS (parent_class)->dispose (object); -} - -static void -pas_backend_class_init (PASBackendClass *klass) -{ - GObjectClass *object_class; - - parent_class = g_type_class_peek_parent (klass); - - object_class = (GObjectClass *) klass; - - object_class->dispose = pas_backend_dispose; - - pas_backend_signals[LAST_CLIENT_GONE] = - g_signal_new ("last_client_gone", - G_OBJECT_CLASS_TYPE (object_class), - G_SIGNAL_RUN_FIRST, - G_STRUCT_OFFSET (PASBackendClass, last_client_gone), - NULL, NULL, - pas_marshal_NONE__NONE, - G_TYPE_NONE, 0); -} - -/** - * pas_backend_get_type: - */ -GType -pas_backend_get_type (void) -{ - static GType type = 0; - - if (! type) { - GTypeInfo info = { - sizeof (PASBackendClass), - NULL, /* base_class_init */ - NULL, /* base_class_finalize */ - (GClassInitFunc) pas_backend_class_init, - NULL, /* class_finalize */ - NULL, /* class_data */ - sizeof (PASBackend), - 0, /* n_preallocs */ - (GInstanceInitFunc) pas_backend_init - }; - - type = g_type_register_static (G_TYPE_OBJECT, "PASBackend", &info, 0); - } - - return type; -} diff --git a/addressbook/backend/pas/pas-backend.h b/addressbook/backend/pas/pas-backend.h deleted file mode 100644 index b71d438441..0000000000 --- a/addressbook/backend/pas/pas-backend.h +++ /dev/null @@ -1,173 +0,0 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */ -/* - * An abstract class which defines the API to a given backend. - * There will be one PASBackend object for every URI which is loaded. - * - * Two people will call into the PASBackend API: - * - * 1. The PASBookFactory, when it has been asked to load a book. - * It will create a new PASBackend if one is not already running - * for the requested URI. It will call pas_backend_add_client to - * add a new client to an existing PASBackend server. - * - * 2. A PASBook, when a client has requested an operation on the - * GNOME_Evolution_Addressbook_Book interface. - * - * Author: - * Nat Friedman (nat@ximian.com) - * - * Copyright 2000, Ximian, Inc. - */ - -#ifndef __PAS_BACKEND_H__ -#define __PAS_BACKEND_H__ - -#include <glib.h> -#include <glib-object.h> -#include <pas/addressbook.h> -#include <pas/pas-types.h> -#include <ebook/e-contact.h> - -#define PAS_TYPE_BACKEND (pas_backend_get_type ()) -#define PAS_BACKEND(o) (G_TYPE_CHECK_INSTANCE_CAST ((o), PAS_TYPE_BACKEND, PASBackend)) -#define PAS_BACKEND_CLASS(k) (G_TYPE_CHECK_CLASS_CAST((k), PAS_TYPE_BACKEND, PASBackendClass)) -#define PAS_IS_BACKEND(o) (G_TYPE_CHECK_INSTANCE_TYPE ((o), PAS_TYPE_BACKEND)) -#define PAS_IS_BACKEND_CLASS(k) (G_TYPE_CHECK_CLASS_TYPE ((k), PAS_TYPE_BACKEND)) -#define PAS_BACKEND_GET_CLASS(k) (G_TYPE_INSTANCE_GET_CLASS ((k), PAS_TYPE_BACKEND, PASBackendClass)) - -typedef struct _PASBackendPrivate PASBackendPrivate; - -#include <pas/pas-book.h> - -struct _PASBackend { - GObject parent_object; - PASBackendPrivate *priv; -}; - -struct _PASBackendClass { - GObjectClass parent_class; - - /* Virtual methods */ - GNOME_Evolution_Addressbook_CallStatus (*load_uri) (PASBackend *backend, const char *uri, gboolean only_if_exists); - void (*remove) (PASBackend *backend, PASBook *book); - char *(*get_static_capabilities) (PASBackend *backend); - - void (*create_contact) (PASBackend *backend, PASBook *book, const char *vcard); - void (*remove_contacts) (PASBackend *backend, PASBook *book, GList *id_list); - void (*modify_contact) (PASBackend *backend, PASBook *book, const char *vcard); - void (*get_contact) (PASBackend *backend, PASBook *book, const char *id); - void (*get_contact_list) (PASBackend *backend, PASBook *book, const char *query); - void (*start_book_view) (PASBackend *backend, PASBookView *book_view); - void (*stop_book_view) (PASBackend *backend, PASBookView *book_view); - void (*get_changes) (PASBackend *backend, PASBook *book, const char *change_id); - void (*authenticate_user) (PASBackend *backend, PASBook *book, const char *user, const char *passwd, const char *auth_method); - void (*get_supported_fields) (PASBackend *backend, PASBook *book); - void (*get_supported_auth_methods) (PASBackend *backend, PASBook *book); - GNOME_Evolution_Addressbook_CallStatus (*cancel_operation) (PASBackend *backend, PASBook *book); - - /* Notification signals */ - void (* last_client_gone) (PASBackend *backend); - - /* Padding for future expansion */ - void (*_pas_reserved0) (void); - void (*_pas_reserved1) (void); - void (*_pas_reserved2) (void); - void (*_pas_reserved3) (void); - void (*_pas_reserved4) (void); -}; - -typedef PASBackend * (*PASBackendFactoryFn) (void); - -gboolean pas_backend_construct (PASBackend *backend); - -GNOME_Evolution_Addressbook_CallStatus - pas_backend_load_uri (PASBackend *backend, - const char *uri, - gboolean only_if_exists); -const char *pas_backend_get_uri (PASBackend *backend); - -gboolean pas_backend_add_client (PASBackend *backend, - PASBook *book); -void pas_backend_remove_client (PASBackend *backend, - PASBook *book); -char *pas_backend_get_static_capabilities (PASBackend *backend); - -gboolean pas_backend_is_loaded (PASBackend *backend); - -gboolean pas_backend_is_writable (PASBackend *backend); - -gboolean pas_backend_is_removed (PASBackend *backend); - -void pas_backend_open (PASBackend *backend, - PASBook *book, - gboolean only_if_exists); -void pas_backend_remove (PASBackend *backend, - PASBook *book); -void pas_backend_create_contact (PASBackend *backend, - PASBook *book, - const char *vcard); -void pas_backend_remove_contacts (PASBackend *backend, - PASBook *book, - GList *id_list); -void pas_backend_modify_contact (PASBackend *backend, - PASBook *book, - const char *vcard); -void pas_backend_get_contact (PASBackend *backend, - PASBook *book, - const char *id); -void pas_backend_get_contact_list (PASBackend *backend, - PASBook *book, - const char *query); -void pas_backend_get_changes (PASBackend *backend, - PASBook *book, - const char *change_id); -void pas_backend_authenticate_user (PASBackend *backend, - PASBook *book, - const char *user, - const char *passwd, - const char *auth_method); -void pas_backend_get_supported_fields (PASBackend *backend, - PASBook *book); -void pas_backend_get_supported_auth_methods (PASBackend *backend, - PASBook *book); -GNOME_Evolution_Addressbook_CallStatus pas_backend_cancel_operation (PASBackend *backend, - PASBook *book); - -void pas_backend_start_book_view (PASBackend *backend, - PASBookView *view); -void pas_backend_stop_book_view (PASBackend *backend, - PASBookView *view); - -void pas_backend_add_book_view (PASBackend *backend, - PASBookView *view); - -void pas_backend_remove_book_view (PASBackend *backend, - PASBookView *view); - -EList *pas_backend_get_book_views (PASBackend *backend); - -void pas_backend_notify_update (PASBackend *backend, - EContact *contact); -void pas_backend_notify_remove (PASBackend *backend, - const char *id); -void pas_backend_notify_complete (PASBackend *backend); - - -GType pas_backend_get_type (void); - - -/* protected functions for subclasses */ -void pas_backend_set_is_loaded (PASBackend *backend, - gboolean is_loaded); -void pas_backend_set_is_writable (PASBackend *backend, - gboolean is_writable); -void pas_backend_set_is_removed (PASBackend *backend, - gboolean is_removed); - -/* useful for implementing _get_changes in backends */ -GNOME_Evolution_Addressbook_BookChangeItem* pas_backend_change_add_new (const char *vcard); -GNOME_Evolution_Addressbook_BookChangeItem* pas_backend_change_modify_new (const char *vcard); -GNOME_Evolution_Addressbook_BookChangeItem* pas_backend_change_delete_new (const char *id); - -#endif /* ! __PAS_BACKEND_H__ */ - diff --git a/addressbook/backend/pas/pas-book-factory.c b/addressbook/backend/pas/pas-book-factory.c deleted file mode 100644 index 34e97aa780..0000000000 --- a/addressbook/backend/pas/pas-book-factory.c +++ /dev/null @@ -1,471 +0,0 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */ -/* - * - * Author: - * Nat Friedman (nat@ximian.com) - * - * Copyright 2000, Ximian, Inc. - */ - -#include <config.h> -#include <pthread.h> -#include <string.h> - -#include "addressbook.h" -#include "pas-book-factory.h" -#include "pas-marshal.h" -#include <bonobo-activation/bonobo-activation.h> -#include <bonobo/bonobo-main.h> -#include <bonobo/bonobo-arg.h> - -#define DEFAULT_PAS_BOOK_FACTORY_OAF_ID "OAFIID:GNOME_Evolution_Wombat_ServerFactory" - -static BonoboObjectClass *pas_book_factory_parent_class; - -typedef struct { - char *uri; - GNOME_Evolution_Addressbook_BookListener listener; -} PASBookFactoryQueuedRequest; - -struct _PASBookFactoryPrivate { - GMutex *map_mutex; - - GHashTable *backends; - GHashTable *active_server_map; - - /* OAFIID of the factory */ - char *iid; - - /* Whether the factory has been registered with OAF yet */ - guint registered : 1; -}; - -/* Signal IDs */ -enum { - LAST_BOOK_GONE, - LAST_SIGNAL -}; - -static guint factory_signals[LAST_SIGNAL]; - -static char * -pas_book_factory_canonicalize_uri (const char *uri) -{ - /* FIXME: What do I do here? */ - - return g_strdup (uri); -} - -static char * -pas_book_factory_extract_proto_from_uri (const char *uri) -{ - char *proto; - char *p; - - p = strchr (uri, ':'); - - if (p == NULL) - return NULL; - - proto = g_malloc0 (p - uri + 1); - - strncpy (proto, uri, p - uri); - - return proto; -} - -/** - * pas_book_factory_register_backend: - * @factory: - * @proto: - * @backend: - */ -void -pas_book_factory_register_backend (PASBookFactory *factory, - const char *proto, - PASBackendFactoryFn backend) -{ - g_return_if_fail (factory != NULL); - g_return_if_fail (PAS_IS_BOOK_FACTORY (factory)); - g_return_if_fail (proto != NULL); - g_return_if_fail (backend != NULL); - - if (g_hash_table_lookup (factory->priv->backends, proto) != NULL) { - g_warning ("pas_book_factory_register_backend: " - "Proto \"%s\" already registered!\n", proto); - } - - g_hash_table_insert (factory->priv->backends, - g_strdup (proto), backend); -} - -/** - * pas_book_factory_get_n_backends: - * @factory: An addressbook factory. - * - * Queries the number of running addressbook backends in an addressbook factory. - * - * Return value: Number of running backends. - **/ -int -pas_book_factory_get_n_backends (PASBookFactory *factory) -{ - int n_backends; - - g_return_val_if_fail (factory != NULL, -1); - g_return_val_if_fail (PAS_IS_BOOK_FACTORY (factory), -1); - - g_mutex_lock (factory->priv->map_mutex); - n_backends = g_hash_table_size (factory->priv->active_server_map); - g_mutex_unlock (factory->priv->map_mutex); - - return n_backends; -} - -static void -dump_active_server_map_entry (gpointer key, gpointer value, gpointer data) -{ - char *uri; - PASBackend *backend; - - uri = key; - backend = PAS_BACKEND (value); - - g_message (" %s: %p", uri, backend); -} - -void -pas_book_factory_dump_active_backends (PASBookFactory *factory) -{ - g_message ("Active PAS backends"); - - g_mutex_lock (factory->priv->map_mutex); - g_hash_table_foreach (factory->priv->active_server_map, - dump_active_server_map_entry, - NULL); - g_mutex_unlock (factory->priv->map_mutex); -} - -/* Callback used when a backend loses its last connected client */ -static void -backend_last_client_gone_cb (PASBackend *backend, gpointer data) -{ - PASBookFactory *factory; - const char *uri; - - factory = PAS_BOOK_FACTORY (data); - - /* Remove the backend from the active server map */ - - uri = pas_backend_get_uri (backend); - if (uri) { - gpointer orig_key; - gboolean result; - char *orig_uri; - - g_mutex_lock (factory->priv->map_mutex); - - result = g_hash_table_lookup_extended (factory->priv->active_server_map, uri, - &orig_key, NULL); - g_assert (result != FALSE); - - orig_uri = orig_key; - - g_hash_table_remove (factory->priv->active_server_map, orig_uri); - g_free (orig_uri); - - g_object_unref (backend); - - g_mutex_unlock (factory->priv->map_mutex); - } - - if (g_hash_table_size (factory->priv->active_server_map) == 0) { - /* Notify upstream if there are no more backends */ - g_signal_emit (G_OBJECT (factory), factory_signals[LAST_BOOK_GONE], 0); - } -} - - - -static PASBackendFactoryFn -pas_book_factory_lookup_backend_factory (PASBookFactory *factory, - const char *uri) -{ - PASBackendFactoryFn backend_fn; - char *proto; - char *canonical_uri; - - g_assert (factory != NULL); - g_assert (PAS_IS_BOOK_FACTORY (factory)); - g_assert (uri != NULL); - - canonical_uri = pas_book_factory_canonicalize_uri (uri); - if (canonical_uri == NULL) - return NULL; - - proto = pas_book_factory_extract_proto_from_uri (canonical_uri); - if (proto == NULL) { - g_free (canonical_uri); - return NULL; - } - - backend_fn = g_hash_table_lookup (factory->priv->backends, proto); - - g_free (proto); - g_free (canonical_uri); - - return backend_fn; -} - -static PASBackend * -pas_book_factory_launch_backend (PASBookFactory *factory, - PASBackendFactoryFn backend_factory, - GNOME_Evolution_Addressbook_BookListener listener, - const char *uri) -{ - PASBackend *backend; - - backend = (* backend_factory) (); - if (!backend) - return NULL; - - g_hash_table_insert (factory->priv->active_server_map, - g_strdup (uri), - backend); - - g_signal_connect (backend, "last_client_gone", - G_CALLBACK (backend_last_client_gone_cb), - factory); - - return backend; -} - -static GNOME_Evolution_Addressbook_Book -impl_GNOME_Evolution_Addressbook_BookFactory_getBook (PortableServer_Servant servant, - const CORBA_char *uri, - const GNOME_Evolution_Addressbook_BookListener listener, - CORBA_Environment *ev) -{ - PASBookFactory *factory = PAS_BOOK_FACTORY (bonobo_object (servant)); - PASBackend *backend; - PASBook *book; - - printf ("impl_GNOME_Evolution_Addressbook_BookFactory_getBook\n"); - - /* Look up the backend and create one if needed */ - g_mutex_lock (factory->priv->map_mutex); - - backend = g_hash_table_lookup (factory->priv->active_server_map, uri); - - if (!backend) { - PASBackendFactoryFn backend_factory; - - backend_factory = pas_book_factory_lookup_backend_factory (factory, uri); - - if (backend_factory == NULL) { - CORBA_exception_set (ev, CORBA_USER_EXCEPTION, - ex_GNOME_Evolution_Addressbook_BookFactory_ProtocolNotSupported, - NULL); - - g_mutex_unlock (factory->priv->map_mutex); - - return CORBA_OBJECT_NIL; - } - - backend = pas_book_factory_launch_backend (factory, backend_factory, listener, uri); - } - - if (backend) { - GNOME_Evolution_Addressbook_BookListener listener_copy; - - listener_copy = bonobo_object_dup_ref (listener, NULL); - - g_mutex_unlock (factory->priv->map_mutex); - - book = pas_book_new (backend, uri, listener); - - pas_backend_add_client (backend, book); - - return bonobo_object_corba_objref (BONOBO_OBJECT (book)); - } - else { - /* probably need a more descriptive exception here */ - CORBA_exception_set (ev, CORBA_USER_EXCEPTION, - ex_GNOME_Evolution_Addressbook_BookFactory_ProtocolNotSupported, - NULL); - g_mutex_unlock (factory->priv->map_mutex); - - return CORBA_OBJECT_NIL; - } -} - -static void -pas_book_factory_construct (PASBookFactory *factory) -{ - /* nothing to do here.. */ -} - -/** - * pas_book_factory_new: - */ -PASBookFactory * -pas_book_factory_new (void) -{ - PASBookFactory *factory; - - factory = g_object_new (PAS_TYPE_BOOK_FACTORY, - "poa", bonobo_poa_get_threaded (ORBIT_THREAD_HINT_PER_REQUEST, NULL), - NULL); - - pas_book_factory_construct (factory); - - return factory; -} - -/** - * pas_book_factory_activate: - */ -gboolean -pas_book_factory_activate (PASBookFactory *factory, const char *iid) -{ - PASBookFactoryPrivate *priv; - Bonobo_RegistrationResult result; - char *tmp_iid; - - g_return_val_if_fail (factory != NULL, FALSE); - g_return_val_if_fail (PAS_IS_BOOK_FACTORY (factory), FALSE); - - priv = factory->priv; - - g_return_val_if_fail (!priv->registered, FALSE); - - /* if iid is NULL, use the default factory OAFIID */ - if (iid) - tmp_iid = g_strdup (iid); - else - tmp_iid = g_strdup (DEFAULT_PAS_BOOK_FACTORY_OAF_ID); - - result = bonobo_activation_active_server_register (tmp_iid, bonobo_object_corba_objref (BONOBO_OBJECT (factory))); - - switch (result) { - case Bonobo_ACTIVATION_REG_SUCCESS: - priv->registered = TRUE; - priv->iid = tmp_iid; - return TRUE; - case Bonobo_ACTIVATION_REG_NOT_LISTED: - g_message ("Error registering the PAS factory: not listed"); - break; - case Bonobo_ACTIVATION_REG_ALREADY_ACTIVE: - g_message ("Error registering the PAS factory: already active"); - break; - case Bonobo_ACTIVATION_REG_ERROR: - default: - g_message ("Error registering the PAS factory: generic error"); - break; - } - - g_free (tmp_iid); - return FALSE; -} - -static void -pas_book_factory_init (PASBookFactory *factory) -{ - factory->priv = g_new0 (PASBookFactoryPrivate, 1); - - factory->priv->map_mutex = g_mutex_new(); - factory->priv->active_server_map = g_hash_table_new (g_str_hash, g_str_equal); - factory->priv->backends = g_hash_table_new (g_str_hash, g_str_equal); - factory->priv->registered = FALSE; -} - -static void -free_active_server_map_entry (gpointer key, gpointer value, gpointer data) -{ - char *uri; - PASBackend *backend; - - uri = key; - g_free (uri); - - backend = PAS_BACKEND (value); - g_object_unref (backend); -} - -static void -remove_backends_entry (gpointer key, gpointer value, gpointer data) -{ - char *uri; - - uri = key; - g_free (uri); -} - -static void -pas_book_factory_dispose (GObject *object) -{ - PASBookFactory *factory = PAS_BOOK_FACTORY (object); - - if (factory->priv) { - PASBookFactoryPrivate *priv = factory->priv; - - g_mutex_free (priv->map_mutex); - - g_hash_table_foreach (priv->active_server_map, - free_active_server_map_entry, - NULL); - g_hash_table_destroy (priv->active_server_map); - priv->active_server_map = NULL; - - g_hash_table_foreach (priv->backends, - remove_backends_entry, - NULL); - g_hash_table_destroy (priv->backends); - priv->backends = NULL; - - if (priv->registered) { - bonobo_activation_active_server_unregister (priv->iid, - bonobo_object_corba_objref (BONOBO_OBJECT (factory))); - priv->registered = FALSE; - } - - g_free (priv->iid); - - g_free (priv); - factory->priv = NULL; - } - - if (G_OBJECT_CLASS (pas_book_factory_parent_class)->dispose) - G_OBJECT_CLASS (pas_book_factory_parent_class)->dispose (object); -} - -static void -pas_book_factory_class_init (PASBookFactoryClass *klass) -{ - GObjectClass *object_class = G_OBJECT_CLASS (klass); - POA_GNOME_Evolution_Addressbook_BookFactory__epv *epv; - - pas_book_factory_parent_class = g_type_class_peek_parent (klass); - - object_class->dispose = pas_book_factory_dispose; - - factory_signals[LAST_BOOK_GONE] = - g_signal_new ("last_book_gone", - G_OBJECT_CLASS_TYPE (object_class), - G_SIGNAL_RUN_FIRST, - G_STRUCT_OFFSET (PASBookFactoryClass, last_book_gone), - NULL, NULL, - pas_marshal_NONE__NONE, - G_TYPE_NONE, 0); - - - epv = &klass->epv; - - epv->getBook = impl_GNOME_Evolution_Addressbook_BookFactory_getBook; -} - -BONOBO_TYPE_FUNC_FULL ( - PASBookFactory, - GNOME_Evolution_Addressbook_BookFactory, - BONOBO_TYPE_OBJECT, - pas_book_factory); diff --git a/addressbook/backend/pas/pas-book-factory.h b/addressbook/backend/pas/pas-book-factory.h deleted file mode 100644 index 9d099a6f2c..0000000000 --- a/addressbook/backend/pas/pas-book-factory.h +++ /dev/null @@ -1,53 +0,0 @@ -/* - * Copyright 2000, Ximian, Inc. - */ - -#include <pas/pas-backend.h> -#include <bonobo/bonobo-object.h> - -#ifndef __PAS_BOOK_FACTORY_H__ -#define __PAS_BOOK_FACTORY_H__ - -G_BEGIN_DECLS - -#define PAS_TYPE_BOOK_FACTORY (pas_book_factory_get_type ()) -#define PAS_BOOK_FACTORY(o) (G_TYPE_CHECK_INSTANCE_CAST ((o), PAS_TYPE_BOOK_FACTORY, PASBookFactory)) -#define PAS_BOOK_FACTORY_CLASS(k) (G_TYPE_CHECK_CLASS_CAST((k), PAS_TYPE_BOOK_FACTORY, PASBookFactoryClass)) -#define PAS_IS_BOOK_FACTORY(o) (G_TYPE_CHECK_INSTANCE_TYPE ((o), PAS_TYPE_BOOK_FACTORY)) -#define PAS_IS_BOOK_FACTORY_CLASS(k) (G_TYPE_CHECK_CLASS_TYPE ((k), PAS_TYPE_BOOK_FACTORY)) -#define PAS_BOOK_FACTORY_GET_CLASS(k) (G_TYPE_INSTANCE_GET_CLASS ((obj), PAS_TYPE_BOOK_FACTORY, PASBookFactoryClass)) - -typedef struct _PASBookFactoryPrivate PASBookFactoryPrivate; - -typedef struct { - BonoboObject parent_object; - PASBookFactoryPrivate *priv; -} PASBookFactory; - -typedef struct { - BonoboObjectClass parent_class; - - POA_GNOME_Evolution_Addressbook_BookFactory__epv epv; - - /* Notification signals */ - - void (* last_book_gone) (PASBookFactory *factory); -} PASBookFactoryClass; - -PASBookFactory *pas_book_factory_new (void); - -void pas_book_factory_register_backend (PASBookFactory *factory, - const char *proto, - PASBackendFactoryFn backend_factory); - -int pas_book_factory_get_n_backends (PASBookFactory *factory); - -void pas_book_factory_dump_active_backends (PASBookFactory *factory); - -gboolean pas_book_factory_activate (PASBookFactory *factory, const char *iid); - -GType pas_book_factory_get_type (void); - -G_END_DECLS - -#endif /* ! __PAS_BOOK_FACTORY_H__ */ diff --git a/addressbook/backend/pas/pas-book-view.c b/addressbook/backend/pas/pas-book-view.c deleted file mode 100644 index afdfb1dacb..0000000000 --- a/addressbook/backend/pas/pas-book-view.c +++ /dev/null @@ -1,465 +0,0 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */ -/* - * pas-book-view.c - * - * Copyright 2000, Ximian, Inc. - */ - -#include <config.h> -#include <string.h> -#include <glib.h> -#include <bonobo/bonobo-main.h> -#include "pas-backend.h" -#include "pas-backend-card-sexp.h" -#include "pas-book-view.h" - -static BonoboObjectClass *pas_book_view_parent_class; - -struct _PASBookViewPrivate { - GNOME_Evolution_Addressbook_BookViewListener listener; - -#define INITIAL_THRESHOLD 20 -#define THRESHOLD_MAX 3000 - - GMutex *pending_mutex; - - CORBA_sequence_GNOME_Evolution_Addressbook_VCard adds; - int next_threshold; - int threshold_max; - - CORBA_sequence_GNOME_Evolution_Addressbook_VCard changes; - CORBA_sequence_GNOME_Evolution_Addressbook_ContactId removes; - - PASBackend *backend; - char *card_query; - PASBackendCardSExp *card_sexp; - GHashTable *ids; -}; - -static void -send_pending_adds (PASBookView *book_view, gboolean reset) -{ - CORBA_Environment ev; - CORBA_sequence_GNOME_Evolution_Addressbook_VCard *adds; - - adds = &book_view->priv->adds; - if (adds->_length == 0) - return; - - CORBA_exception_init (&ev); - - GNOME_Evolution_Addressbook_BookViewListener_notifyContactsAdded ( - book_view->priv->listener, adds, &ev); - - if (ev._major != CORBA_NO_EXCEPTION) { - g_warning ("send_pending_adds: Exception signaling BookViewListener!\n"); - } - - CORBA_exception_free (&ev); - - CORBA_free (adds->_buffer); - adds->_buffer = NULL; - adds->_maximum = 0; - adds->_length = 0; - - if (reset) - book_view->priv->next_threshold = INITIAL_THRESHOLD; -} - -static void -send_pending_changes (PASBookView *book_view) -{ - CORBA_Environment ev; - CORBA_sequence_GNOME_Evolution_Addressbook_VCard *changes; - - changes = &book_view->priv->changes; - if (changes->_length == 0) - return; - - CORBA_exception_init (&ev); - - GNOME_Evolution_Addressbook_BookViewListener_notifyContactsChanged ( - book_view->priv->listener, changes, &ev); - - if (ev._major != CORBA_NO_EXCEPTION) { - g_warning ("send_pending_changes: Exception signaling BookViewListener!\n"); - } - - CORBA_exception_free (&ev); - - CORBA_free (changes->_buffer); - changes->_buffer = NULL; - changes->_maximum = 0; - changes->_length = 0; -} - -static void -send_pending_removes (PASBookView *book_view) -{ - CORBA_Environment ev; - CORBA_sequence_GNOME_Evolution_Addressbook_VCard *removes; - - removes = &book_view->priv->removes; - if (removes->_length == 0) - return; - - CORBA_exception_init (&ev); - - GNOME_Evolution_Addressbook_BookViewListener_notifyContactsRemoved ( - book_view->priv->listener, removes, &ev); - - if (ev._major != CORBA_NO_EXCEPTION) { - g_warning ("send_pending_removes: Exception signaling BookViewListener!\n"); - } - - CORBA_exception_free (&ev); - - CORBA_free (removes->_buffer); - removes->_buffer = NULL; - removes->_maximum = 0; - removes->_length = 0; -} - -#define MAKE_REALLOC(type) \ -static void \ -CORBA_sequence_ ## type ## _realloc (CORBA_sequence_ ## type *seq, \ - CORBA_unsigned_long new_max) \ -{ \ - type *new_buf; \ - \ - new_buf = CORBA_sequence_ ## type ## _allocbuf (new_max); \ - memcpy (new_buf, seq->_buffer, seq->_maximum * sizeof (type)); \ - CORBA_free (seq->_buffer); \ - seq->_buffer = new_buf; \ - seq->_maximum = new_max; \ -} - -MAKE_REALLOC (GNOME_Evolution_Addressbook_VCard) -MAKE_REALLOC (GNOME_Evolution_Addressbook_ContactId) - -static void -notify_change (PASBookView *book_view, const char *vcard) -{ - CORBA_sequence_GNOME_Evolution_Addressbook_VCard *changes; - - send_pending_adds (book_view, TRUE); - send_pending_removes (book_view); - - changes = &book_view->priv->changes; - - if (changes->_length == changes->_maximum) { - CORBA_sequence_GNOME_Evolution_Addressbook_VCard_realloc ( - changes, 2 * (changes->_maximum + 1)); - } - - changes->_buffer[changes->_length++] = CORBA_string_dup (vcard); -} - -static void -notify_remove (PASBookView *book_view, const char *id) -{ - CORBA_sequence_GNOME_Evolution_Addressbook_ContactId *removes; - - send_pending_adds (book_view, TRUE); - send_pending_changes (book_view); - - removes = &book_view->priv->removes; - - if (removes->_length == removes->_maximum) { - CORBA_sequence_GNOME_Evolution_Addressbook_ContactId_realloc ( - removes, 2 * (removes->_maximum + 1)); - } - - removes->_buffer[removes->_length++] = CORBA_string_dup (id); - g_hash_table_remove (book_view->priv->ids, id); -} - -static void -notify_add (PASBookView *book_view, const char *id, const char *vcard) -{ - CORBA_sequence_GNOME_Evolution_Addressbook_VCard *adds; - PASBookViewPrivate *priv = book_view->priv; - - send_pending_changes (book_view); - send_pending_removes (book_view); - - adds = &priv->adds; - - if (adds->_length == adds->_maximum) { - send_pending_adds (book_view, FALSE); - - adds->_buffer = CORBA_sequence_GNOME_Evolution_Addressbook_VCard_allocbuf (priv->next_threshold); - adds->_maximum = priv->next_threshold; - - if (priv->next_threshold < priv->threshold_max) { - priv->next_threshold = MIN (2 * priv->next_threshold, - priv->threshold_max); - } - } - - adds->_buffer[adds->_length++] = CORBA_string_dup (vcard); - g_hash_table_insert (book_view->priv->ids, g_strdup (id), - GUINT_TO_POINTER (1)); -} - -/** - * pas_book_view_notify_update: - */ -void -pas_book_view_notify_update (PASBookView *book_view, - EContact *contact) -{ - gboolean currently_in_view, want_in_view; - const char *id; - char *vcard; - - g_mutex_lock (book_view->priv->pending_mutex); - - id = e_contact_get_const (contact, E_CONTACT_UID); - - currently_in_view = - g_hash_table_lookup (book_view->priv->ids, id) != NULL; - want_in_view = pas_backend_card_sexp_match_contact ( - book_view->priv->card_sexp, contact); - - if (want_in_view) { - vcard = e_vcard_to_string (E_VCARD (contact), - EVC_FORMAT_VCARD_30); - - if (currently_in_view) - notify_change (book_view, vcard); - else - notify_add (book_view, id, vcard); - - g_free (vcard); - } else { - if (currently_in_view) - pas_book_view_notify_remove (book_view, id); - /* else nothing; we're removing a card that wasn't there */ - } - - g_mutex_unlock (book_view->priv->pending_mutex); -} - -/** - * pas_book_view_notify_remove: - */ -void -pas_book_view_notify_remove (PASBookView *book_view, - const char *id) -{ - g_mutex_lock (book_view->priv->pending_mutex); - notify_remove (book_view, id); - g_mutex_unlock (book_view->priv->pending_mutex); -} - - -void -pas_book_view_notify_complete (PASBookView *book_view, - GNOME_Evolution_Addressbook_CallStatus status) -{ - CORBA_Environment ev; - - g_mutex_lock (book_view->priv->pending_mutex); - - send_pending_adds (book_view, TRUE); - send_pending_changes (book_view); - send_pending_removes (book_view); - - g_mutex_unlock (book_view->priv->pending_mutex); - - CORBA_exception_init (&ev); - - GNOME_Evolution_Addressbook_BookViewListener_notifySequenceComplete ( - book_view->priv->listener, status, &ev); - - if (ev._major != CORBA_NO_EXCEPTION) { - g_warning ("pas_book_view_notify_complete: Exception signaling BookViewListener!\n"); - } - - CORBA_exception_free (&ev); -} - -void -pas_book_view_notify_status_message (PASBookView *book_view, - const char *message) -{ - CORBA_Environment ev; - - CORBA_exception_init (&ev); - - GNOME_Evolution_Addressbook_BookViewListener_notifyProgress ( - book_view->priv->listener, message, 0, &ev); - - if (ev._major != CORBA_NO_EXCEPTION) { - g_warning ("pas_book_view_notify_status_message: Exception signaling BookViewListener!\n"); - } - - CORBA_exception_free (&ev); -} - -static void -pas_book_view_construct (PASBookView *book_view, - PASBackend *backend, - GNOME_Evolution_Addressbook_BookViewListener listener, - const char *card_query, - PASBackendCardSExp *card_sexp) -{ - PASBookViewPrivate *priv; - CORBA_Environment ev; - - g_return_if_fail (book_view != NULL); - g_return_if_fail (listener != CORBA_OBJECT_NIL); - - priv = book_view->priv; - - CORBA_exception_init (&ev); - - priv->listener = CORBA_Object_duplicate (listener, &ev); - if (ev._major != CORBA_NO_EXCEPTION) { - g_warning("Unable to duplicate listener object in pas-book-view.c\n"); - CORBA_exception_free (&ev); - return; - } - - CORBA_exception_free (&ev); - - priv->backend = backend; - priv->card_query = g_strdup (card_query); - priv->card_sexp = card_sexp; -} - -/** - * pas_book_view_new: - */ -static void -impl_GNOME_Evolution_Addressbook_BookView_start (PortableServer_Servant servant, - CORBA_Environment *ev) -{ - PASBookView *view = PAS_BOOK_VIEW (bonobo_object (servant)); - - pas_backend_start_book_view (pas_book_view_get_backend (view), view); -} - -static void -impl_GNOME_Evolution_Addressbook_BookView_stop (PortableServer_Servant servant, - CORBA_Environment *ev) -{ - PASBookView *view = PAS_BOOK_VIEW (bonobo_object (servant)); - - pas_backend_stop_book_view (pas_book_view_get_backend (view), view); -} - -/** - * pas_book_view_get_card_query - */ -const char* -pas_book_view_get_card_query (PASBookView *book_view) -{ - return book_view->priv->card_query; -} - -/** - * pas_book_view_get_card_sexp - */ -PASBackendCardSExp* -pas_book_view_get_card_sexp (PASBookView *book_view) -{ - return book_view->priv->card_sexp; -} - -PASBackend* -pas_book_view_get_backend (PASBookView *book_view) -{ - return book_view->priv->backend; -} - -GNOME_Evolution_Addressbook_BookViewListener -pas_book_view_get_listener (PASBookView *book_view) -{ - return book_view->priv->listener; -} - -/** - * pas_book_view_new: - */ -PASBookView * -pas_book_view_new (PASBackend *backend, - GNOME_Evolution_Addressbook_BookViewListener listener, - const char *card_query, - PASBackendCardSExp *card_sexp) -{ - PASBookView *book_view; - - book_view = g_object_new (PAS_TYPE_BOOK_VIEW, NULL); - - pas_book_view_construct (book_view, backend, listener, card_query, card_sexp); - - return book_view; -} - -static void -pas_book_view_dispose (GObject *object) -{ - PASBookView *book_view = PAS_BOOK_VIEW (object); - - if (book_view->priv) { - bonobo_object_release_unref (book_view->priv->listener, NULL); - - if (book_view->priv->adds._buffer) - CORBA_free (book_view->priv->adds._buffer); - if (book_view->priv->changes._buffer) - CORBA_free (book_view->priv->changes._buffer); - if (book_view->priv->removes._buffer) - CORBA_free (book_view->priv->removes._buffer); - - g_free (book_view->priv->card_query); - g_object_unref (book_view->priv->card_sexp); - - g_mutex_free (book_view->priv->pending_mutex); - book_view->priv->pending_mutex = NULL; - - g_free (book_view->priv); - book_view->priv = NULL; - } - - if (G_OBJECT_CLASS (pas_book_view_parent_class)->dispose) - G_OBJECT_CLASS (pas_book_view_parent_class)->dispose (object); -} - -static void -pas_book_view_class_init (PASBookViewClass *klass) -{ - GObjectClass *object_class = G_OBJECT_CLASS (klass); - POA_GNOME_Evolution_Addressbook_BookView__epv *epv; - - pas_book_view_parent_class = g_type_class_peek_parent (klass); - - object_class->dispose = pas_book_view_dispose; - - epv = &klass->epv; - - epv->start = impl_GNOME_Evolution_Addressbook_BookView_start; - epv->stop = impl_GNOME_Evolution_Addressbook_BookView_stop; - -} - -static void -pas_book_view_init (PASBookView *book_view) -{ - book_view->priv = g_new0 (PASBookViewPrivate, 1); - - book_view->priv->pending_mutex = g_mutex_new(); - - book_view->priv->next_threshold = INITIAL_THRESHOLD; - book_view->priv->threshold_max = THRESHOLD_MAX; - - book_view->priv->ids = g_hash_table_new_full (g_str_hash, g_str_equal, - g_free, NULL); -} - -BONOBO_TYPE_FUNC_FULL ( - PASBookView, - GNOME_Evolution_Addressbook_BookView, - BONOBO_TYPE_OBJECT, - pas_book_view); diff --git a/addressbook/backend/pas/pas-book-view.h b/addressbook/backend/pas/pas-book-view.h deleted file mode 100644 index 3b292d11db..0000000000 --- a/addressbook/backend/pas/pas-book-view.h +++ /dev/null @@ -1,64 +0,0 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */ -/* - * A wrapper object which exports the GNOME_Evolution_Addressbook_Book CORBA interface - * and which maintains a request queue. - * - * Author: - * Nat Friedman (nat@ximian.com) - * - * Copyright 2000, Ximian, Inc. - */ - -#ifndef __PAS_BOOK_VIEW_H__ -#define __PAS_BOOK_VIEW_H__ - -#include <bonobo/bonobo-object.h> -#include <pas/addressbook.h> -#include <glib.h> -#include <glib-object.h> -#include <pas/pas-types.h> -#include <ebook/e-contact.h> - -#define PAS_TYPE_BOOK_VIEW (pas_book_view_get_type ()) -#define PAS_BOOK_VIEW(o) (G_TYPE_CHECK_INSTANCE_CAST ((o), PAS_TYPE_BOOK_VIEW, PASBookView)) -#define PAS_BOOK_VIEW_CLASS(k) (G_TYPE_CHECK_CLASS_CAST((k), PAS_TYPE_BOOK_VIEW, PASBookViewClass)) -#define PAS_IS_BOOK_VIEW(o) (G_TYPE_CHECK_INSTANCE_TYPE ((o), PAS_TYPE_BOOK_VIEW)) -#define PAS_IS_BOOK_VIEW_CLASS(k) (G_TYPE_CHECK_CLASS_TYPE ((k), PAS_TYPE_BOOK_VIEW)) -#define PAS_BOOK_VIEW_GET_CLASS(k) (G_TYPE_INSTANCE_GET_CLASS ((obj), PAS_TYPE_BOOK_VIEW, PASBookView)) - -typedef struct _PASBookViewPrivate PASBookViewPrivate; - -struct _PASBookView { - BonoboObject parent_object; - PASBookViewPrivate *priv; -}; - -struct _PASBookViewClass { - BonoboObjectClass parent_class; - - POA_GNOME_Evolution_Addressbook_BookView__epv epv; -}; - - -PASBookView *pas_book_view_new (PASBackend *backend, - GNOME_Evolution_Addressbook_BookViewListener listener, - const char *card_query, - PASBackendCardSExp *card_sexp); - -const char* pas_book_view_get_card_query (PASBookView *book_view); -PASBackendCardSExp* pas_book_view_get_card_sexp (PASBookView *book_view); -PASBackend* pas_book_view_get_backend (PASBookView *book_view); -GNOME_Evolution_Addressbook_BookViewListener pas_book_view_get_listener (PASBookView *book_view); - -void pas_book_view_notify_update (PASBookView *book_view, - EContact *contact); -void pas_book_view_notify_remove (PASBookView *book_view, - const char *id); -void pas_book_view_notify_complete (PASBookView *book_view, - GNOME_Evolution_Addressbook_CallStatus); -void pas_book_view_notify_status_message (PASBookView *book_view, - const char *message); - -GType pas_book_view_get_type (void); - -#endif /* ! __PAS_BOOK_VIEW_H__ */ diff --git a/addressbook/backend/pas/pas-book.c b/addressbook/backend/pas/pas-book.c deleted file mode 100644 index 346b37ceed..0000000000 --- a/addressbook/backend/pas/pas-book.c +++ /dev/null @@ -1,770 +0,0 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */ -/* - * pas-book.c - * - * Copyright 2000, Ximian, Inc. - */ - -#include <config.h> -#include <bonobo/bonobo-main.h> -#include <bonobo/bonobo-arg.h> -#include "e-util/e-list.h" -#include "ebook/e-contact.h" -#include "pas-book-view.h" -#include "pas-backend.h" -#include "pas-backend-card-sexp.h" -#include "pas-marshal.h" - -static BonoboObjectClass *pas_book_parent_class; -POA_GNOME_Evolution_Addressbook_Book__vepv pas_book_vepv; - -struct _PASBookPrivate { - PASBackend *backend; - GNOME_Evolution_Addressbook_BookListener listener; - char *uri; -}; - -static void -impl_GNOME_Evolution_Addressbook_Book_open (PortableServer_Servant servant, - const CORBA_boolean only_if_exists, - CORBA_Environment *ev) -{ - PASBook *book = PAS_BOOK (bonobo_object (servant)); - - printf ("impl_GNOME_Evolution_Addressbook_Book_open\n"); - - pas_backend_open (pas_book_get_backend (book), book, only_if_exists); -} - -static void -impl_GNOME_Evolution_Addressbook_Book_remove (PortableServer_Servant servant, - CORBA_Environment *ev) -{ - PASBook *book = PAS_BOOK (bonobo_object (servant)); - - printf ("impl_GNOME_Evolution_Addressbook_Book_remove\n"); - - pas_backend_remove (pas_book_get_backend (book), book); -} - -static void -impl_GNOME_Evolution_Addressbook_Book_getContact (PortableServer_Servant servant, - const CORBA_char *id, - CORBA_Environment *ev) -{ - PASBook *book = PAS_BOOK (bonobo_object (servant)); - - printf ("impl_GNOME_Evolution_Addressbook_Book_getContact\n"); - - pas_backend_get_contact (pas_book_get_backend (book), book, id); -} - -static void -impl_GNOME_Evolution_Addressbook_Book_getContactList (PortableServer_Servant servant, - const CORBA_char *query, - CORBA_Environment *ev) -{ - PASBook *book = PAS_BOOK (bonobo_object (servant)); - - printf ("impl_GNOME_Evolution_Addressbook_Book_getContactList\n"); - - pas_backend_get_contact_list (pas_book_get_backend (book), book, query); -} - -static void -impl_GNOME_Evolution_Addressbook_Book_authenticateUser (PortableServer_Servant servant, - const char* user, - const char* passwd, - const char* auth_method, - CORBA_Environment *ev) -{ - PASBook *book = PAS_BOOK (bonobo_object (servant)); - - pas_backend_authenticate_user (pas_book_get_backend (book), book, - user, passwd, auth_method); -} - -static void -impl_GNOME_Evolution_Addressbook_Book_addContact (PortableServer_Servant servant, - const CORBA_char *vcard, - CORBA_Environment *ev) -{ - PASBook *book = PAS_BOOK (bonobo_object (servant)); - - pas_backend_create_contact (pas_book_get_backend (book), book, vcard); -} - -static void -impl_GNOME_Evolution_Addressbook_Book_removeContacts (PortableServer_Servant servant, - const GNOME_Evolution_Addressbook_ContactIdList *ids, - CORBA_Environment *ev) -{ - PASBook *book = PAS_BOOK (bonobo_object (servant)); - int i; - GList *id_list = NULL; - - for (i = 0; i < ids->_length; i ++) - id_list = g_list_append (id_list, ids->_buffer[i]); - - pas_backend_remove_contacts (pas_book_get_backend (book), book, id_list); - - g_list_free (id_list); -} - -static void -impl_GNOME_Evolution_Addressbook_Book_modifyContact (PortableServer_Servant servant, - const CORBA_char *vcard, - CORBA_Environment *ev) -{ - PASBook *book = PAS_BOOK (bonobo_object (servant)); - - pas_backend_modify_contact (pas_book_get_backend (book), book, vcard); -} - -static void -view_listener_died_cb (gpointer cnx, gpointer user_data) -{ - PASBookView *book_view = PAS_BOOK_VIEW (user_data); - - pas_backend_stop_book_view (pas_book_view_get_backend (book_view), book_view); - pas_backend_remove_book_view (pas_book_view_get_backend (book_view), book_view); -} - -static void -impl_GNOME_Evolution_Addressbook_Book_getBookView (PortableServer_Servant servant, - const GNOME_Evolution_Addressbook_BookViewListener listener, - const CORBA_char *search, - const GNOME_Evolution_Addressbook_stringlist* requested_fields, - const CORBA_long max_results, - CORBA_Environment *ev) -{ - PASBook *book = PAS_BOOK (bonobo_object (servant)); - PASBackend *backend = pas_book_get_backend (book); - PASBackendCardSExp *card_sexp; - PASBookView *view; - - g_warning ("impl_GNOME_Evolution_Addressbook_Book_getBookView (%s)\n", search); - - /* we handle this entirely here, since it doesn't require any - backend involvement now that we have pas_book_view_start to - actually kick off the search. */ - - card_sexp = pas_backend_card_sexp_new (search); - if (!card_sexp) { - pas_book_respond_get_book_view (book, GNOME_Evolution_Addressbook_InvalidQuery, NULL); - return; - } - - view = pas_book_view_new (backend, listener, search, card_sexp); - - if (!view) { - g_object_unref (card_sexp); - pas_book_respond_get_book_view (book, GNOME_Evolution_Addressbook_OtherError, NULL); - return; - } - - ORBit_small_listen_for_broken (pas_book_view_get_listener (view), G_CALLBACK (view_listener_died_cb), view); - - pas_backend_add_book_view (backend, view); - - pas_book_respond_get_book_view (book, GNOME_Evolution_Addressbook_Success, view); - - g_object_unref (view); -} - - -static void -impl_GNOME_Evolution_Addressbook_Book_getChanges (PortableServer_Servant servant, - const CORBA_char *change_id, - CORBA_Environment *ev) -{ - PASBook *book = PAS_BOOK (bonobo_object (servant)); - - pas_backend_get_changes (pas_book_get_backend (book), book, change_id); -} - -static char * -impl_GNOME_Evolution_Addressbook_Book_getStaticCapabilities (PortableServer_Servant servant, - CORBA_Environment *ev) -{ - PASBook *book = PAS_BOOK (bonobo_object (servant)); - char *temp; - char *ret_val; - - temp = pas_backend_get_static_capabilities (book->priv->backend); - ret_val = CORBA_string_dup(temp); - g_free(temp); - return ret_val; -} - -static void -impl_GNOME_Evolution_Addressbook_Book_getSupportedFields (PortableServer_Servant servant, - CORBA_Environment *ev) -{ - PASBook *book = PAS_BOOK (bonobo_object (servant)); - - pas_backend_get_supported_fields (pas_book_get_backend (book), book); -} - -static void -impl_GNOME_Evolution_Addressbook_Book_getSupportedAuthMethods (PortableServer_Servant servant, - CORBA_Environment *ev) -{ - PASBook *book = PAS_BOOK (bonobo_object (servant)); - - pas_backend_get_supported_auth_methods (pas_book_get_backend (book), book); -} - -static GNOME_Evolution_Addressbook_CallStatus -impl_GNOME_Evolution_Addressbook_Book_cancelOperation (PortableServer_Servant servant, - CORBA_Environment *ev) -{ - PASBook *book = PAS_BOOK (bonobo_object (servant)); - - return pas_backend_cancel_operation (pas_book_get_backend (book), book); -} - -/** - * pas_book_get_backend: - */ -PASBackend * -pas_book_get_backend (PASBook *book) -{ - g_return_val_if_fail (book && PAS_IS_BOOK (book), NULL); - - return book->priv->backend; -} - -GNOME_Evolution_Addressbook_BookListener -pas_book_get_listener (PASBook *book) -{ - g_return_val_if_fail (book && PAS_IS_BOOK (book), CORBA_OBJECT_NIL); - - return book->priv->listener; -} - -const char* -pas_book_get_uri (PASBook *book) -{ - return book->priv->uri; -} - -/** - * pas_book_respond_open: - */ -void -pas_book_respond_open (PASBook *book, - GNOME_Evolution_Addressbook_CallStatus status) -{ - CORBA_Environment ev; - - CORBA_exception_init (&ev); - GNOME_Evolution_Addressbook_BookListener_notifyBookOpened (book->priv->listener, status, &ev); - - if (ev._major != CORBA_NO_EXCEPTION) { - g_warning ("pas_book_respond_open: Exception " - "responding to BookListener!\n"); - } - - CORBA_exception_free (&ev); -} - -/** - * pas_book_respond_remove: - */ -void -pas_book_respond_remove (PASBook *book, - GNOME_Evolution_Addressbook_CallStatus status) -{ - CORBA_Environment ev; - - CORBA_exception_init (&ev); - GNOME_Evolution_Addressbook_BookListener_notifyBookRemoved (book->priv->listener, status, &ev); - - if (ev._major != CORBA_NO_EXCEPTION) { - g_warning ("pas_book_respond_remove: Exception " - "responding to BookListener!\n"); - } - - CORBA_exception_free (&ev); -} - -/** - * pas_book_respond_create: - */ -void -pas_book_respond_create (PASBook *book, - GNOME_Evolution_Addressbook_CallStatus status, - EContact *contact) -{ - CORBA_Environment ev; - - if (status == GNOME_Evolution_Addressbook_Success) { - pas_backend_notify_update (book->priv->backend, contact); - pas_backend_notify_complete (book->priv->backend); - } - - CORBA_exception_init (&ev); - - GNOME_Evolution_Addressbook_BookListener_notifyContactCreated ( - book->priv->listener, status, - e_contact_get_const (contact, E_CONTACT_UID), &ev); - - if (ev._major != CORBA_NO_EXCEPTION) { - g_warning ("pas_book_respond_create: Exception " - "responding to BookListener!\n"); - } - - CORBA_exception_free (&ev); -} - -/** - * pas_book_respond_remove_contacts: - */ -void -pas_book_respond_remove_contacts (PASBook *book, - GNOME_Evolution_Addressbook_CallStatus status, - GList *ids) -{ - CORBA_Environment ev; - GList *i; - - CORBA_exception_init (&ev); - - if (ids) { - for (i = ids; i; i = i->next) - pas_backend_notify_remove (book->priv->backend, i->data); - pas_backend_notify_complete (book->priv->backend); - } - - GNOME_Evolution_Addressbook_BookListener_notifyContactsRemoved ( - book->priv->listener, status, &ev); - - if (ev._major != CORBA_NO_EXCEPTION) { - g_warning ("pas_book_respond_remove: Exception " - "responding to BookListener!\n"); - } - - CORBA_exception_free (&ev); -} - -/** - * pas_book_respond_modify: - */ -void -pas_book_respond_modify (PASBook *book, - GNOME_Evolution_Addressbook_CallStatus status, - EContact *contact) -{ - CORBA_Environment ev; - - if (status == GNOME_Evolution_Addressbook_Success) { - pas_backend_notify_update (book->priv->backend, contact); - pas_backend_notify_complete (book->priv->backend); - } - - CORBA_exception_init (&ev); - - GNOME_Evolution_Addressbook_BookListener_notifyContactModified ( - book->priv->listener, status, &ev); - - if (ev._major != CORBA_NO_EXCEPTION) { - g_warning ("pas_book_respond_modify: Exception " - "responding to BookListener!\n"); - } - - CORBA_exception_free (&ev); -} - -/** - * pas_book_respond_authenticate_user: - */ -void -pas_book_respond_authenticate_user (PASBook *book, - GNOME_Evolution_Addressbook_CallStatus status) -{ - CORBA_Environment ev; - - CORBA_exception_init (&ev); - - GNOME_Evolution_Addressbook_BookListener_notifyAuthenticationResult ( - book->priv->listener, status, &ev); - - if (ev._major != CORBA_NO_EXCEPTION) { - g_warning ("pas_book_respond_authenticate_user: Exception " - "responding to BookListener!\n"); - } - - CORBA_exception_free (&ev); -} - -void -pas_book_respond_get_supported_fields (PASBook *book, - GNOME_Evolution_Addressbook_CallStatus status, - GList *fields) -{ - CORBA_Environment ev; - GNOME_Evolution_Addressbook_stringlist stringlist; - int num_fields; - int i; - GList *iter; - - CORBA_exception_init (&ev); - - num_fields = g_list_length (fields); - - stringlist._buffer = CORBA_sequence_CORBA_string_allocbuf (num_fields); - stringlist._maximum = num_fields; - stringlist._length = num_fields; - - for (i = 0, iter = fields; iter; iter = iter->next, i ++) { - stringlist._buffer[i] = CORBA_string_dup ((char*)iter->data); - } - - printf ("calling GNOME_Evolution_Addressbook_BookListener_notifySupportedFields\n"); - - GNOME_Evolution_Addressbook_BookListener_notifySupportedFields ( - book->priv->listener, status, - &stringlist, - &ev); - - CORBA_exception_free (&ev); - - CORBA_free(stringlist._buffer); -} - -void -pas_book_respond_get_supported_auth_methods (PASBook *book, - GNOME_Evolution_Addressbook_CallStatus status, - GList *auth_methods) -{ - CORBA_Environment ev; - GNOME_Evolution_Addressbook_stringlist stringlist; - int num_auth_methods; - GList *iter; - int i; - - CORBA_exception_init (&ev); - - num_auth_methods = g_list_length (auth_methods); - - stringlist._buffer = CORBA_sequence_CORBA_string_allocbuf (num_auth_methods); - stringlist._maximum = num_auth_methods; - stringlist._length = num_auth_methods; - - for (i = 0, iter = auth_methods; iter; iter = iter->next, i ++) { - stringlist._buffer[i] = CORBA_string_dup ((char*)iter->data); - } - - GNOME_Evolution_Addressbook_BookListener_notifySupportedAuthMethods ( - book->priv->listener, status, - &stringlist, - &ev); - - CORBA_exception_free (&ev); - - CORBA_free(stringlist._buffer); -} - -static void -view_destroy(gpointer data, GObject *where_object_was) -{ - PASBook *book = (PASBook *)data; - EIterator *iterator; - gboolean success = FALSE; - EList *views = pas_backend_get_book_views (book->priv->backend); - - for (iterator = e_list_get_iterator(views); - e_iterator_is_valid(iterator); - e_iterator_next(iterator)) { - const PASBookView *view = e_iterator_get(iterator); - if (view == (PASBookView*)where_object_was) { - e_iterator_delete(iterator); - success = TRUE; - break; - } - } - if (!success) - g_warning ("Failed to remove from book_views list"); - g_object_unref(iterator); - g_object_unref(views); -} - -/** - * pas_book_respond_get_book_view: - */ -void -pas_book_respond_get_book_view (PASBook *book, - GNOME_Evolution_Addressbook_CallStatus status, - PASBookView *book_view) -{ - CORBA_Environment ev; - CORBA_Object object = CORBA_OBJECT_NIL; - - printf ("pas_book_respond_get_book_view\n"); - - CORBA_exception_init (&ev); - - if (book_view) { - object = bonobo_object_corba_objref(BONOBO_OBJECT(book_view)); - - g_object_weak_ref (G_OBJECT (book_view), view_destroy, book); - } - - GNOME_Evolution_Addressbook_BookListener_notifyViewRequested ( - book->priv->listener, status, object, &ev); - - if (ev._major != CORBA_NO_EXCEPTION) { - g_warning ("pas_book_respond_get_book_view: Exception " - "responding to BookListener!\n"); - } - - CORBA_exception_free (&ev); -} - -/** - * pas_book_respond_get_contact: - */ -void -pas_book_respond_get_contact (PASBook *book, - GNOME_Evolution_Addressbook_CallStatus status, - char *vcard) -{ - CORBA_Environment ev; - - CORBA_exception_init (&ev); - - GNOME_Evolution_Addressbook_BookListener_notifyContactRequested (book->priv->listener, - status, - vcard, - &ev); - - if (ev._major != CORBA_NO_EXCEPTION) - g_message ("could not notify listener of get-contact response"); - - CORBA_exception_free (&ev); -} - -/** - * pas_book_respond_get_contact_list: - */ -void -pas_book_respond_get_contact_list (PASBook *book, - GNOME_Evolution_Addressbook_CallStatus status, - GList *card_list) -{ - CORBA_Environment ev; - GNOME_Evolution_Addressbook_stringlist stringlist; - int num_cards; - int i; - GList *l; - - CORBA_exception_init (&ev); - - num_cards = g_list_length (card_list); - - stringlist._buffer = CORBA_sequence_CORBA_string_allocbuf (num_cards); - stringlist._maximum = num_cards; - stringlist._length = num_cards; - - for (i = 0, l = card_list; l; l = l->next, i ++) - stringlist._buffer[i] = CORBA_string_dup (l->data); - - g_list_foreach (card_list, (GFunc)g_free, NULL); - g_list_free (card_list); - - - GNOME_Evolution_Addressbook_BookListener_notifyContactListRequested (book->priv->listener, - status, - &stringlist, - &ev); - - if (ev._major != CORBA_NO_EXCEPTION) - g_message ("could not notify listener of get-contact-list response"); - - CORBA_exception_free (&ev); - - CORBA_free(stringlist._buffer); -} - -/** - * pas_book_respond_get_changes: - */ -void -pas_book_respond_get_changes (PASBook *book, - GNOME_Evolution_Addressbook_CallStatus status, - GList *changes) -{ - CORBA_Environment ev; - GNOME_Evolution_Addressbook_BookChangeList changelist; - int num_changes; - int i; - GList *l; - - CORBA_exception_init (&ev); - - num_changes = g_list_length (changes); - - changelist._buffer = CORBA_sequence_GNOME_Evolution_Addressbook_BookChangeItem_allocbuf (num_changes); - changelist._maximum = num_changes; - changelist._length = num_changes; - - for (i = 0, l = changes; l; l = l->next, i ++) { - GNOME_Evolution_Addressbook_BookChangeItem *change = (GNOME_Evolution_Addressbook_BookChangeItem*)l->data; - changelist._buffer[i] = *change; - changelist._buffer[i].vcard = CORBA_string_dup (change->vcard); - } - - g_list_foreach (changes, (GFunc)CORBA_free, NULL); - g_list_free (changes); - - GNOME_Evolution_Addressbook_BookListener_notifyChangesRequested (book->priv->listener, - status, - &changelist, - &ev); - - if (ev._major != CORBA_NO_EXCEPTION) - g_message ("could not notify listener of get-changes response"); - - CORBA_exception_free (&ev); - - CORBA_free(changelist._buffer); -} - -/** - * pas_book_report_writable: - */ -void -pas_book_report_writable (PASBook *book, - gboolean writable) -{ - CORBA_Environment ev; - - CORBA_exception_init (&ev); - - GNOME_Evolution_Addressbook_BookListener_notifyWritable ( - book->priv->listener, (CORBA_boolean) writable, &ev); - - if (ev._major != CORBA_NO_EXCEPTION) { - g_warning ("pas_book_report_writable: Exception " - "responding to BookListener!\n"); - } - - CORBA_exception_free (&ev); -} - -static void -pas_book_construct (PASBook *book, - PASBackend *backend, - const char *uri, - GNOME_Evolution_Addressbook_BookListener listener) -{ - PASBookPrivate *priv; - CORBA_Environment ev; - - g_return_if_fail (book != NULL); - - priv = book->priv; - - CORBA_exception_init (&ev); - book->priv->listener = CORBA_Object_duplicate (listener, &ev); - - if (ev._major != CORBA_NO_EXCEPTION) { - g_message ("pas_book_construct(): could not duplicate the listener"); - CORBA_exception_free (&ev); - return; - } - - CORBA_exception_free (&ev); - - priv->backend = backend; - priv->uri = g_strdup (uri); - -} - -/** - * pas_book_new: - */ -PASBook * -pas_book_new (PASBackend *backend, - const char *uri, - GNOME_Evolution_Addressbook_BookListener listener) -{ - PASBook *book; - char *caps = pas_backend_get_static_capabilities (backend); - - book = g_object_new (PAS_TYPE_BOOK, - "poa", bonobo_poa_get_threaded (ORBIT_THREAD_HINT_PER_REQUEST, NULL), - NULL); - - pas_book_construct (book, backend, uri, listener); - - g_free (caps); - - return book; -} - -static void -pas_book_dispose (GObject *object) -{ - PASBook *book = PAS_BOOK (object); - - if (book->priv) { - CORBA_Environment ev; - - CORBA_exception_init (&ev); - CORBA_Object_release (book->priv->listener, &ev); - - if (ev._major != CORBA_NO_EXCEPTION) - g_message ("pas_book_construct(): could not release the listener"); - - CORBA_exception_free (&ev); - - g_free (book->priv->uri); - g_free (book->priv); - book->priv = NULL; - } - - if (G_OBJECT_CLASS (pas_book_parent_class)->dispose) - G_OBJECT_CLASS (pas_book_parent_class)->dispose (object); -} - -static void -pas_book_class_init (PASBookClass *klass) -{ - GObjectClass *object_class = G_OBJECT_CLASS (klass); - POA_GNOME_Evolution_Addressbook_Book__epv *epv; - - pas_book_parent_class = g_type_class_peek_parent (klass); - - object_class->dispose = pas_book_dispose; - - epv = &klass->epv; - - epv->open = impl_GNOME_Evolution_Addressbook_Book_open; - epv->remove = impl_GNOME_Evolution_Addressbook_Book_remove; - epv->getContact = impl_GNOME_Evolution_Addressbook_Book_getContact; - epv->getContactList = impl_GNOME_Evolution_Addressbook_Book_getContactList; - epv->authenticateUser = impl_GNOME_Evolution_Addressbook_Book_authenticateUser; - epv->addContact = impl_GNOME_Evolution_Addressbook_Book_addContact; - epv->removeContacts = impl_GNOME_Evolution_Addressbook_Book_removeContacts; - epv->modifyContact = impl_GNOME_Evolution_Addressbook_Book_modifyContact; - epv->getStaticCapabilities = impl_GNOME_Evolution_Addressbook_Book_getStaticCapabilities; - epv->getSupportedFields = impl_GNOME_Evolution_Addressbook_Book_getSupportedFields; - epv->getSupportedAuthMethods = impl_GNOME_Evolution_Addressbook_Book_getSupportedAuthMethods; - epv->getBookView = impl_GNOME_Evolution_Addressbook_Book_getBookView; - epv->getChanges = impl_GNOME_Evolution_Addressbook_Book_getChanges; - epv->cancelOperation = impl_GNOME_Evolution_Addressbook_Book_cancelOperation; -} - -static void -pas_book_init (PASBook *book) -{ - book->priv = g_new0 (PASBookPrivate, 1); -} - -BONOBO_TYPE_FUNC_FULL ( - PASBook, - GNOME_Evolution_Addressbook_Book, - BONOBO_TYPE_OBJECT, - pas_book); diff --git a/addressbook/backend/pas/pas-book.h b/addressbook/backend/pas/pas-book.h deleted file mode 100644 index 2cb84569c2..0000000000 --- a/addressbook/backend/pas/pas-book.h +++ /dev/null @@ -1,96 +0,0 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */ -/* - * A wrapper object which exports the GNOME_Evolution_Addressbook_Book CORBA interface - * and which maintains a request queue. - * - * Author: - * Nat Friedman (nat@ximian.com) - * - * Copyright 2000, Ximian, Inc. - */ - -#ifndef __PAS_BOOK_H__ -#define __PAS_BOOK_H__ - -#include <pas/addressbook.h> -#include <bonobo/bonobo-object.h> -#include "e-util/e-list.h" - -#include <pas/pas-types.h> - -#define PAS_TYPE_BOOK (pas_book_get_type ()) -#define PAS_BOOK(o) (G_TYPE_CHECK_INSTANCE_CAST ((o), PAS_TYPE_BOOK, PASBook)) -#define PAS_BOOK_CLASS(k) (G_TYPE_CHECK_CLASS_CAST((k), PAS_BOOK_FACTORY_TYPE, PASBookClass)) -#define PAS_IS_BOOK(o) (G_TYPE_CHECK_INSTANCE_TYPE ((o), PAS_TYPE_BOOK)) -#define PAS_IS_BOOK_CLASS(k) (G_TYPE_CHECK_CLASS_TYPE ((k), PAS_TYPE_BOOK)) -#define PAS_BOOK_GET_CLASS(k) (G_TYPE_INSTANCE_GET_CLASS ((obj), PAS_TYPE_BOOK, PASBookClass)) - -typedef struct _PASBookPrivate PASBookPrivate; - -struct _PASBook { - BonoboObject parent_object; - PASBookPrivate *priv; -}; - -struct _PASBookClass { - BonoboObjectClass parent_class; - - POA_GNOME_Evolution_Addressbook_Book__epv epv; - - /* Padding for future expansion */ - void (*_pas_reserved0) (void); - void (*_pas_reserved1) (void); - void (*_pas_reserved2) (void); - void (*_pas_reserved3) (void); - void (*_pas_reserved4) (void); -}; - - -PASBook *pas_book_new (PASBackend *backend, - const char *uri, - GNOME_Evolution_Addressbook_BookListener listener); -GNOME_Evolution_Addressbook_BookListener pas_book_get_listener (PASBook *book); -PASBackend *pas_book_get_backend (PASBook *book); -const char *pas_book_get_uri (PASBook *book); - -void pas_book_respond_open (PASBook *book, - GNOME_Evolution_Addressbook_CallStatus status); -void pas_book_respond_remove (PASBook *book, - GNOME_Evolution_Addressbook_CallStatus status); -void pas_book_respond_create (PASBook *book, - GNOME_Evolution_Addressbook_CallStatus status, - EContact *contact); -void pas_book_respond_remove_contacts (PASBook *book, - GNOME_Evolution_Addressbook_CallStatus status, - GList *ids); -void pas_book_respond_modify (PASBook *book, - GNOME_Evolution_Addressbook_CallStatus status, - EContact *contact); -void pas_book_respond_authenticate_user (PASBook *book, - GNOME_Evolution_Addressbook_CallStatus status); -void pas_book_respond_get_supported_fields (PASBook *book, - GNOME_Evolution_Addressbook_CallStatus status, - GList *fields); -void pas_book_respond_get_supported_auth_methods (PASBook *book, - GNOME_Evolution_Addressbook_CallStatus status, - GList *fields); - -void pas_book_respond_get_book_view (PASBook *book, - GNOME_Evolution_Addressbook_CallStatus status, - PASBookView *book_view); -void pas_book_respond_get_contact (PASBook *book, - GNOME_Evolution_Addressbook_CallStatus status, - char *vcard); -void pas_book_respond_get_contact_list (PASBook *book, - GNOME_Evolution_Addressbook_CallStatus status, - GList *cards); -void pas_book_respond_get_changes (PASBook *book, - GNOME_Evolution_Addressbook_CallStatus status, - GList *changes); - -void pas_book_report_writable (PASBook *book, - gboolean writable); - -GType pas_book_get_type (void); - -#endif /* ! __PAS_BOOK_H__ */ diff --git a/addressbook/backend/pas/pas-marshal.list b/addressbook/backend/pas/pas-marshal.list deleted file mode 100644 index 9d6744db44..0000000000 --- a/addressbook/backend/pas/pas-marshal.list +++ /dev/null @@ -1,2 +0,0 @@ -NONE:NONE -NONE:POINTER diff --git a/addressbook/backend/pas/pas-types.h b/addressbook/backend/pas/pas-types.h deleted file mode 100644 index 19611a4e23..0000000000 --- a/addressbook/backend/pas/pas-types.h +++ /dev/null @@ -1,32 +0,0 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */ -/* - * Blanket header containing the typedefs for object types used in the - * PAS stuff, so we can disentangle the #includes. - * - * Author: Chris Toshok <toshok@ximian.com> - * - * Copyright 2003, Ximian, Inc. - */ - -#ifndef __PAS_TYPES_H__ -#define __PAS_TYPES_H__ - -typedef struct _PASBookView PASBookView; -typedef struct _PASBookViewClass PASBookViewClass; - -typedef struct _PASBackendCardSExp PASBackendCardSExp; -typedef struct _PASBackendCardSExpClass PASBackendCardSExpClass; - -typedef struct _PASBackend PASBackend; -typedef struct _PASBackendClass PASBackendClass; - -typedef struct _PASBackendSummary PASBackendSummary; -typedef struct _PASBackendSummaryClass PASBackendSummaryClass; - -typedef struct _PASBackendSync PASBackendSync; -typedef struct _PASBackendSyncClass PASBackendSyncClass; - -typedef struct _PASBook PASBook; -typedef struct _PASBookClass PASBookClass; - -#endif /* __PAS_TYPES_H__ */ diff --git a/addressbook/backend/pas/ximian-vcard.h b/addressbook/backend/pas/ximian-vcard.h deleted file mode 100644 index 961a5cadb4..0000000000 --- a/addressbook/backend/pas/ximian-vcard.h +++ /dev/null @@ -1,81 +0,0 @@ -#define XIMIAN_VCARD \ -"BEGIN:VCARD\n" \ -"X-EVOLUTION-FILE-AS:Ximian\\, Inc.\n" \ -"ADR;TYPE=WORK:;Suite 3 West;401 Park Drive;Boston;MA;02215;USA\n" \ -"LABEL;TYPE=WORK:401 Park Drive\\nSuite 3 West\\nBoston\\, MA\\n02215\\nUSA\n" \ -"TEL;WORK;VOICE:(617) 375-3800\n" \ -"TEL;WORK;FAX:(617) 236-8630\n" \ -"EMAIL;INTERNET:hello@ximian.com\n" \ -"URL:http://www.ximian.com/\n" \ -"ORG:Ximian\\, Inc.;\n" \ -"NOTE:Welcome to the Ximian Addressbook.\n" \ -"PHOTO;ENCODING=b;TYPE=JPEG:/9j/4AAQSkZJRgABAQEARwBHAAD//gAXQ3JlYXRlZCB3aXRo\n" \ -" IFRoZSBHSU1Q/9sAQwAIBgYHBgUIBwcHCQkICgwUDQwLCwwZEhMPFB0aHx4dGhwcICQuJyAiLCM\n" \ -" cHCg3KSwwMTQ0NB8nOT04MjwuMzQy/9sAQwEJCQkMCwwYDQ0YMiEcITIyMjIyMjIyMjIyMjIyMj\n" \ -" IyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIy/8AAEQgAbgBkAwEiAAIRAQMRAf/EA\n" \ -" BwAAAIDAQEBAQAAAAAAAAAAAAAHBQYIBAMBAv/EAEYQAAEDAwEFBgMEBgQPAAAAAAECAwQABREG\n" \ -" BxIhMWETIkFRcYEUkaEIMkLBFSNSsbLRFmJydRgkMzY3Q0RGgpKTosLh8P/EABsBAQACAwEBAAA\n" \ -" AAAAAAAAAAAAEBQIDBgEH/8QALREAAQMCAwYGAgMAAAAAAAAAAQACAwQREiFRBRMiMUFhMnGBkb\n" \ -" HRBsEUofD/2gAMAwEAAhEDEQA/AH/RRRREVwXe9W2wwFzbpNZixkc1uqwPQeZ6CoHXevLfom1ds\n" \ -" 9h6a6D8PGCsFZHMk+CR4n86yzdbrqfaZqYBSnp0hRPZMoG62ynoOSR1Pua8Lg0XPJegX5Jv6k+0\n" \ -" bBjrWxp22LlkcBIlHs0HqEjiR64peT9umupqyWrhHhpP4WI6eHureNW7Tmw+DGaTI1FJVJdxksM\n" \ -" qKG09CrmfbFMCHpCw2xATDs8JrH4gykq+Z4mqifbMUZsxpd/QUllK53M2SCb2xa+bXvf0gcV0Uw\n" \ -" 0R/DVktH2hdUwlpFxjQrg1490tLPuOH0pvv2qE4jdchx1p8lNAj91Va87OtM3RCt+2Nx3Dyci/q\n" \ -" yPYcD7g1EZ+RR4rSMI9b/S2mhdbhKsmkdtWmNTuNxnXVW2cvgGZRASo+SV8j74PSmOlQUMpORWP\n" \ -" NU7MrjY0rlQFmdDTxOE4cQOo8R1Hyqe2Z7ZJ2m32bXfHnJVpJCUuqO8uP7+Kenh4eVXkFRFUMxx\n" \ -" G4UOSN0Zs4LU1FeEOWxOityYzqHWXEhSFoOQoHkQa963rBFFFFERUdfr1E09Y5d1mr3Y8ZsrV5n\n" \ -" yA6k4A6mpGkL9ojUym0W/TrLmAsGU+AeYBwgfPJ/4RREqrrcb1tJ1oUpBXLmObqUZ7rSByT0SkZ\n" \ -" J8zk1pHQmiLXo+zpbabC3SAp55Q7zyvM9PIUudiGmURbS7fpCMvzFFton8LSTxx6qH0FM7VV9VY\n" \ -" 9MzZ7aQt5tASw3+26ohKB/zEVSVFVvZzGMw02tqe/kpbI8LMR6/C/Xxq9QagfbbP+IW1QQ4Rycf\n" \ -" xncHRAIJ/rEfsmu2a9Fgsl2XIZjtj8bqwgfM1+9L2VFksESAV9o6hG886ebjqjvLWepUSarutdn\n" \ -" MXV+obRcZks/CwCQ5DKMpeBOTxzwzgA9KwfTtfxPOSB5GQUXc9pOjoC+zXe2HV5xiOC6PmkEfWp\n" \ -" xe6tAWghSVDIIOQRXxekNOx4b0WPZYLLTram19mwlJKSMHjjNUzQd2dZM7SNxczcLOsttqVzdYz\n" \ -" 3FewI9iKpK2mjMZdFe7ed9NfT9qZDI4OAd1Vkko50ndoui22kuXq2NBOO9JZSOH9sD9/z86c8gc\n" \ -" DUJNQlaFJUkKSoYII4EVGoKp9PIHt9e6lyRNlZhcqlsJ2guQpydL3F4mO7kw1KP3Fcyj0PEjrnz\n" \ -" rSAIIyOVYfvsJ3TGqlCKpTfYuJfjLHMDOR8jw9q2Foy+o1FpWBckY/XMpUoeRxxHsciu/jeJGB7\n" \ -" eRXPvaWuLT0U/RRRWaxQeVY82x3BVw2oXbJyhgoZR0AQM/UmthK+6fSsWbRQW9pV73x/tZPtwNE\n" \ -" Wj9Nw0WuwwIKQAGI6G/cAZ+tRW0lx5nTEW4Ntqdat9xjy5CEjJLSFZP5H2qaYdCkpUk5BGQa7Ap\n" \ -" DrSm3EpWhYKVJUMgg8wRXz+kqyyTG7VXUsV22Clrfc48+CzMiPIejvIC23EHIUDXNe79b7HbXbh\n" \ -" c5SI8ZvmtZ5nyA5k9BS7d0nfdMPuSdD3JtEZaitdom5Uznx3DzT6cPWkvq/V1611fGW5nZtBCgy\n" \ -" zFbXhtCycE5JxknxPhXR07RUeB3D11H+9lAfwcxmrrqLbxcHpikWGAw1FScByUkqWvrgEBPpxqi\n" \ -" ztdXWdqmNqIIjx7gykJUphJCXAM/eBJ5g4PQCmBZNiDKWEu364uF0jJYh4AT6qUDn2FVu6bPIkT\n" \ -" aTB08xKeMOU2H99eCtKRvZGQMZ7hwceNZxVGzsbmMzIBv5dfNeOjnsCdUwbTtKsV8nJgIccZkqw\n" \ -" lJcThDqvJJz8s4zUtLVzpc2vZZKt+qBIkyUKt0V0ONKSe+7g5SCPDr9Kv0tznXP1cNMyQfxnXBC\n" \ -" tqUyuB3gslftPjJLkGWB3u82o/Ij86bf2e7iqRoxyIpWfhpC0JHQ4V/5GlVtJcBt0RPiXif+00w\n" \ -" Ps5BQtNxP4TJP8Ka6rZZJpW37/Kq68ATlPeiiirBQ0HlWR9t9qVbtpEp/dwiY0h5J8Mgbp/h+ta\n" \ -" 4pM7fdKLumn2rxGbKn4BKl4HEtn73ywD7GiL7o28JuulLbKCsqLKUL/tJ7p+oqyIe4c6RGyzU4g\n" \ -" THLNJc3WpCt9gk8A54j3GPcdaZuoosy82V23QpaYpkEIdeIJKUeIAHieXPkTXA11DuassJsCefY\n" \ -" /SvYZN5FiGZU9edRwLDAXJny2mRukoStQBWQOQHjSjg7PYE7ZmzcZb7cG6KK5CZD6txOCcJQvPg\n" \ -" QAQfAn2q6RNOWi1D9J3R5dwlR2xmZPVv9mlI8ByTj59ar09Lm0jUIQl5Y0zAUMrQSPiXfHHpyz4\n" \ -" D1qTRvMQIieQAQXOtllfIDre/X2WqVmI8Qz6D9q0bP9SO37SrSpW8ZUVXw7q+YcKeSgeRyMZ65q\n" \ -" qammvWTalEv1yjOJtaWfh25CBvBOUkHPlxUeHlyq/MiPCitxorSGWG07qG0DASK45xZlx3GJDaH\n" \ -" WljCkLGQR6VGinY2ofIG8Lri2gOi37hxYG3zC+uT2HY6ZDbyFMrAUlwK7pB5HNRcp7nxqpzdN3G\n" \ -" CFQ7NObTa3nApcaSN/suOe4SDw6VK3O4swojsp9WGmxk9fIDrW4UzWkbt2K/v691vjec8YtZUTa\n" \ -" BL+IuMaIjiWWytXQn/wBD608tgtrVC0W2+tOFSFqd9icD6AVnmFFl6n1AhoAmRPdwcfgR4n2H7q\n" \ -" 2Ppi1N2exRojaQlKEBIHkAK7Gmi3MTWaLn6iTeSF+qmaKKK3rSiuedEanQ3I7qQpC0kEEZzXRRR\n" \ -" FjnaRoSVoq/KcYQv9HOr3mHB/qzz3SenhVi0ftAbnNNwLo6G5iQEodUcJd9fJX760ZqLTkHUdsd\n" \ -" hTWEOtuJwQoVl/XGyS7aakOPwGnJcDORujK0DqPH2qJV0cdUzC/0Oi3QTuhddqY84IuFukwnFFK\n" \ -" JDSmlEcwFDGR86ISI1tgtQ4jYaYaTuoSP/udJS1azvFoAZLnbsp4dm/klPQHmKs0faVEWkfEw32\n" \ -" 1f1CFj8q56XZNSwYG5t7fSt46yB5ucimM5L4c643pXWqU5tCteMpRKUfIIH86ipmvnnAUwoQSf2\n" \ -" 3lZ+g/nWEey5yfCtrquBo8Su0+4sQ46pEp1LTSeZUfoPOlnfr67fZKQlK0QkK/VtficV5nrXOkX\n" \ -" XUk9KQHp0gnghI7qPyAp1bOdkCmH2rneQHHxxQjHdb9OvWr2j2c2Didm74VZVVplGFuQXRsc2fO\n" \ -" Qgb1cmsSXQN1JH+TT4D+dPEAAADkK848duMylppISkDGBXrVkoCKKKKIiiqrrbX9m0JARIua1re\n" \ -" dJDMdoArcI58+AA8zVLsO26RqiS9Gsukpct5lHaKbTLaSrd8wFEZ9s0RN6vGRGZktlDqAoHzFKq\n" \ -" JtomzrPOuzGjZvwEBRTJfckttpbUOae9jJ5cBk8R514Wrbo7e489+3aTlvtQGTIkqElsdm2Mkq4\n" \ -" 4zyPKiKf1Hsj09flKdXEQh4/jR3VfMUvJ/2et1ZMOe8keSgFfyqz2LbfJ1M9IZs2kJsx2O0XnEN\n" \ -" yEAhA4ZwcZ58hxr7ZdtkvUS5SbTo2fJMRsuPkPoSG0jzKsDPPhz4HyoipDewC47+FXFWOjYH51Y\n" \ -" bTsAgtrSqc88/jwWrA+QxUlYtujupZ6oNo0nLlSUtqdKEyW04SMZOVYHiKjP8ACUt5/wB3pX/XT\n" \ -" /KiJnWLQ1nsTSURorad39lIFWZKUoThIAHSlNqDbLP0siKu96MnQ0ygSyVyGzvYxnlnB4jga87F\n" \ -" ttlamXJbs2j50xcZvtXUtyEZCfPB5+gyaIm9RSetm3J68RbhJgaSmPM25vtZaviW09knjxIOM8j\n" \ -" y8q7LHtzstwv/AOhrlBftkkudkFOLS43v5xgqSeHHx5daImrRX5QtK0hSTkGiiLMP2ho8wa1iSn\n" \ -" QoxVRQ20fAKClFQ9eIqq7LLJe7vreG7ZZCoZhqD8iZjustjnnwORkY8c+Wa1ZqbStt1PBMa4MId\n" \ -" Rz7wzg+dL8bEbA1vpa7RtK+CkpdWAfXjRFB7UpCNe6Kdm6NnJft1qluKuUJlvdKznPbYH3hzPXJ\n" \ -" PMGqZsk/zc2gf3G5/Cumc3sRsTO92Rcb3uB3XVjP1r4jYfYGwoN76QsYUEurGR5HjREudhUt2BP\n" \ -" 1TMYID0eyuuoJGRvJII+oq96I2iwtVz7rb7ZZWbalyzyJ9wKUjLsrKEkjH4cE8+Jz049bew+wNb\n" \ -" 3Z76N4YO66sZHlzob2H2Bkktb6CRglLqxkeXOiJZbAv9IMj+7X/wB6ag9lGnEaj17CRJA+BhZmy\n" \ -" lK+6EI44PQq3R6E06W9h9gZVvNb6FYxlLqwcfOhvYhYWt7s99G8MK3XVjI68aIo7UxgbR9IajhQ\n" \ -" 7/Du9yiSF3S3tMNrStlkAAt94DPDI4eJFUvYfNetqNYz4xAfjWZx5skZAUnJHD1FMVrYhYWVbzW\n" \ -" +2ojGUOrBx86EbD7A0FBvfRvDCt11YyPI8aIo23zdP6i2e621TaUJiXCfa1IucFPJt5KVnfHRWS\n" \ -" euPPNZ2YadfkNsspUp1aglCU8yTyrTSNh9gbCgjfSFjCgl1YyPI8al9PbItP2WamUywkuJ5KOVE\n" \ -" emeVEVw02ZH9H4YkEqdDYCifE4oqXbaS02lCRhIGBRRF//Z\n" \ -"END:VCARD" diff --git a/addressbook/conduit/Makefile.am b/addressbook/conduit/Makefile.am index ca6d7fab30..02df188703 100644 --- a/addressbook/conduit/Makefile.am +++ b/addressbook/conduit/Makefile.am @@ -18,9 +18,6 @@ libeaddress_conduit_la_SOURCES = \ libeaddress_conduit_la_LDFLAGS = -module -avoid-version libeaddress_conduit_la_LIBADD = \ $(top_builddir)/e-util/libeutil.la \ - $(top_builddir)/addressbook/backend/ebook/libebook.la \ - $(top_builddir)/e-util/ename/libename.la \ - $(top_builddir)/libversit/libversit.la \ $(top_builddir)/e-util/libeconduit.la \ $(top_builddir)/camel/libcamel.la \ $(EVOLUTION_ADDRESSBOOK_CONDUIT_LIBS) diff --git a/addressbook/conduit/address-conduit.c b/addressbook/conduit/address-conduit.c index a85dda4587..5d6530fd85 100644 --- a/addressbook/conduit/address-conduit.c +++ b/addressbook/conduit/address-conduit.c @@ -31,7 +31,7 @@ #include <pi-socket.h> #include <pi-dlp.h> #include <pi-address.h> -#include <ebook/e-book.h> +#include <libebook/e-book.h> #include <gpilotd/gnome-pilot-conduit.h> #include <gpilotd/gnome-pilot-conduit-sync-abs.h> #include <libgpilotdCM/gnome-pilot-conduit-management.h> diff --git a/addressbook/gui/component/Makefile.am b/addressbook/gui/component/Makefile.am index 458e8edbd7..0d6b6e2461 100644 --- a/addressbook/gui/component/Makefile.am +++ b/addressbook/gui/component/Makefile.am @@ -54,7 +54,6 @@ libevolution_addressbook_la_LIBADD = \ $(top_builddir)/addressbook/gui/search/libeaddressbooksearch.la \ $(top_builddir)/filter/libfilter.la \ $(top_builddir)/addressbook/util/libeabutil.la \ - $(top_builddir)/addressbook/backend/ebook/libebook.la \ $(top_builddir)/addressbook/gui/contact-editor/libecontacteditor.la \ $(top_builddir)/addressbook/gui/contact-list-editor/libecontactlisteditor.la \ $(top_builddir)/widgets/misc/libemiscwidgets.la \ diff --git a/addressbook/gui/component/addressbook.c b/addressbook/gui/component/addressbook.c index 32c5ab1288..ddf7b8616a 100644 --- a/addressbook/gui/component/addressbook.c +++ b/addressbook/gui/component/addressbook.c @@ -53,7 +53,7 @@ #include "addressbook/printing/e-contact-print.h" #include "addressbook/util/eab-book-util.h" -#include <ebook/e-book-async.h> +#include <libebook/e-book-async.h> #include <widgets/misc/e-search-bar.h> #include <widgets/misc/e-filter-bar.h> diff --git a/addressbook/gui/component/addressbook.h b/addressbook/gui/component/addressbook.h index 573adbf38d..5e6ff05f64 100644 --- a/addressbook/gui/component/addressbook.h +++ b/addressbook/gui/component/addressbook.h @@ -5,7 +5,7 @@ #include <e-util/e-config-listener.h> #include <bonobo/bonobo-object.h> #include <bonobo/bonobo-moniker-util.h> -#include <ebook/e-book-async.h> +#include <libebook/e-book-async.h> /* use this instead of e_book_load_uri everywhere where you want the authentication to be handled for you. */ diff --git a/addressbook/gui/component/select-names/Makefile.am b/addressbook/gui/component/select-names/Makefile.am index f6d1fc6e5e..59ef7fc6b2 100644 --- a/addressbook/gui/component/select-names/Makefile.am +++ b/addressbook/gui/component/select-names/Makefile.am @@ -70,7 +70,6 @@ libeselectnames_la_SOURCES = \ e-select-names.h libeselectnames_la_LIBADD = \ - $(top_builddir)/addressbook/backend/ebook/libebook.la \ $(EVOLUTION_ADDRESSBOOK_LIBS) # We'll need these again when we split out the select names control diff --git a/addressbook/gui/component/select-names/e-select-names-completion.c b/addressbook/gui/component/select-names/e-select-names-completion.c index 7bfbfd2a5a..39b5f7a008 100644 --- a/addressbook/gui/component/select-names/e-select-names-completion.c +++ b/addressbook/gui/component/select-names/e-select-names-completion.c @@ -34,10 +34,10 @@ #include <gtk/gtksignal.h> +#include <libebook/e-contact.h> #include <addressbook/util/eab-book-util.h> #include <addressbook/util/eab-destination.h> #include <addressbook/gui/merging/eab-contact-compare.h> -#include <addressbook/backend/ebook/e-contact.h> typedef struct { EBook *book; diff --git a/addressbook/gui/component/select-names/e-select-names-completion.h b/addressbook/gui/component/select-names/e-select-names-completion.h index 435fe80041..4ad1f4fd52 100644 --- a/addressbook/gui/component/select-names/e-select-names-completion.h +++ b/addressbook/gui/component/select-names/e-select-names-completion.h @@ -28,7 +28,7 @@ #define E_SELECT_NAMES_COMPLETION_H #include <gal/e-text/e-completion.h> -#include <addressbook/backend/ebook/e-book-async.h> +#include <libebook/e-book-async.h> #include "e-select-names-text-model.h" G_BEGIN_DECLS diff --git a/addressbook/gui/component/select-names/e-select-names-model.c b/addressbook/gui/component/select-names/e-select-names-model.c index d95aebde5d..74bda7a74b 100644 --- a/addressbook/gui/component/select-names/e-select-names-model.c +++ b/addressbook/gui/component/select-names/e-select-names-model.c @@ -16,10 +16,9 @@ #include <gtk/gtksignal.h> #include <gal/util/e-util.h> - +#include <libebook/e-contact.h> #include "e-select-names-model.h" #include "e-select-names-marshal.h" -#include "addressbook/backend/ebook/e-contact.h" #define MAX_LENGTH 2047 diff --git a/addressbook/gui/component/select-names/e-select-names-model.h b/addressbook/gui/component/select-names/e-select-names-model.h index 41d5100f59..0d21ee86b3 100644 --- a/addressbook/gui/component/select-names/e-select-names-model.h +++ b/addressbook/gui/component/select-names/e-select-names-model.h @@ -15,7 +15,7 @@ #include <gtk/gtkobject.h> #include <stdio.h> #include <e-util/e-list.h> -#include <addressbook/backend/ebook/e-contact.h> +#include <libebook/e-contact.h> #include <addressbook/util/eab-destination.h> #define E_TYPE_SELECT_NAMES_MODEL (e_select_names_model_get_type ()) diff --git a/addressbook/gui/component/select-names/e-select-names-table-model.c b/addressbook/gui/component/select-names/e-select-names-table-model.c index 14261e9d80..aaa6936c8d 100644 --- a/addressbook/gui/component/select-names/e-select-names-table-model.c +++ b/addressbook/gui/component/select-names/e-select-names-table-model.c @@ -14,9 +14,8 @@ #include <gtk/gtksignal.h> #include <gal/util/e-util.h> #include <libgnome/gnome-i18n.h> - +#include <libebook/e-contact.h> #include "e-select-names-table-model.h" -#include "addressbook/backend/ebook/e-contact.h" /* Object argument IDs */ enum { diff --git a/addressbook/gui/component/select-names/e-select-names.c b/addressbook/gui/component/select-names/e-select-names.c index b50a6d0ca0..4423107fca 100644 --- a/addressbook/gui/component/select-names/e-select-names.c +++ b/addressbook/gui/component/select-names/e-select-names.c @@ -28,9 +28,10 @@ #include <gal/e-table/e-table-without.h> #include <gal/widgets/e-popup-menu.h> +#include <libebook/e-book-async.h> +#include <libebook/e-contact.h> #include <addressbook/gui/widgets/e-addressbook-model.h> #include <addressbook/gui/widgets/e-addressbook-table-adapter.h> -#include <addressbook/backend/ebook/e-book-async.h> #include <addressbook/util/eab-book-util.h> #include <addressbook/gui/component/addressbook-component.h> #include <addressbook/gui/component/addressbook-storage.h> @@ -39,7 +40,6 @@ #include <shell/evolution-folder-selector-button.h> #include "e-select-names.h" -#include <addressbook/backend/ebook/e-contact.h> #include "e-select-names-table-model.h" #include <gal/widgets/e-categories-master-list-option-menu.h> #include <gal/e-text/e-entry.h> diff --git a/addressbook/gui/contact-editor/e-contact-editor-address.h b/addressbook/gui/contact-editor/e-contact-editor-address.h index c20f020152..893a2ea2f7 100644 --- a/addressbook/gui/contact-editor/e-contact-editor-address.h +++ b/addressbook/gui/contact-editor/e-contact-editor-address.h @@ -22,7 +22,7 @@ #include <gtk/gtkdialog.h> #include <glade/glade.h> -#include <ebook/e-contact.h> +#include <libebook/e-contact.h> G_BEGIN_DECLS diff --git a/addressbook/gui/contact-editor/e-contact-editor-fullname.h b/addressbook/gui/contact-editor/e-contact-editor-fullname.h index 408fcffdc3..0b254c789c 100644 --- a/addressbook/gui/contact-editor/e-contact-editor-fullname.h +++ b/addressbook/gui/contact-editor/e-contact-editor-fullname.h @@ -22,7 +22,7 @@ #include <gtk/gtkdialog.h> #include <glade/glade.h> -#include <ebook/e-contact.h> +#include <libebook/e-contact.h> G_BEGIN_DECLS diff --git a/addressbook/gui/contact-editor/e-contact-editor.h b/addressbook/gui/contact-editor/e-contact-editor.h index efee496539..27baa9f0fc 100644 --- a/addressbook/gui/contact-editor/e-contact-editor.h +++ b/addressbook/gui/contact-editor/e-contact-editor.h @@ -25,8 +25,8 @@ #include <bonobo/bonobo-ui-component.h> #include <glade/glade.h> -#include "addressbook/backend/ebook/e-book-async.h" -#include "addressbook/backend/ebook/e-contact.h" +#include <libebook/e-book-async.h> +#include <libebook/e-contact.h> G_BEGIN_DECLS diff --git a/addressbook/gui/contact-editor/e-contact-quick-add.c b/addressbook/gui/contact-editor/e-contact-quick-add.c index 65b321c997..0f59c1145f 100644 --- a/addressbook/gui/contact-editor/e-contact-quick-add.c +++ b/addressbook/gui/contact-editor/e-contact-quick-add.c @@ -35,10 +35,10 @@ #include <gtk/gtkstock.h> #include <libgnome/gnome-i18n.h> #include <libgnomeui/gnome-app.h> +#include <libebook/e-book.h> +#include <libebook/e-contact.h> #include <addressbook/gui/component/addressbook.h> -#include <addressbook/backend/ebook/e-book.h> #include <addressbook/util/eab-book-util.h> -#include <addressbook/backend/ebook/e-contact.h> #include "e-contact-editor.h" #include "e-contact-quick-add.h" #include "eab-contact-merging.h" diff --git a/addressbook/gui/contact-editor/e-contact-quick-add.h b/addressbook/gui/contact-editor/e-contact-quick-add.h index ad98c73c23..a969211915 100644 --- a/addressbook/gui/contact-editor/e-contact-quick-add.h +++ b/addressbook/gui/contact-editor/e-contact-quick-add.h @@ -27,7 +27,7 @@ #ifndef __E_CONTACT_QUICK_ADD_H__ #define __E_CONTACT_QUICK_ADD_H__ -#include <addressbook/backend/ebook/e-contact.h> +#include <libebook/e-contact.h> typedef void (*EContactQuickAddCallback) (EContact *new_contact, gpointer closure); diff --git a/addressbook/gui/contact-list-editor/e-contact-list-editor.h b/addressbook/gui/contact-list-editor/e-contact-list-editor.h index 62334c17bf..52e78a6a23 100644 --- a/addressbook/gui/contact-list-editor/e-contact-list-editor.h +++ b/addressbook/gui/contact-list-editor/e-contact-list-editor.h @@ -26,8 +26,8 @@ #include <glade/glade.h> #include <gal/e-table/e-table-model.h> -#include "addressbook/backend/ebook/e-book-async.h" -#include "addressbook/backend/ebook/e-contact.h" +#include <libebook/e-book-async.h> +#include <libebook/e-contact.h> G_BEGIN_DECLS diff --git a/addressbook/gui/contact-list-editor/e-contact-list-model.h b/addressbook/gui/contact-list-editor/e-contact-list-model.h index 92d3d9bc60..504f31b9d8 100644 --- a/addressbook/gui/contact-list-editor/e-contact-list-model.h +++ b/addressbook/gui/contact-list-editor/e-contact-list-model.h @@ -4,8 +4,8 @@ #include <gtk/gtk.h> #include <gal/e-table/e-table-model.h> -#include "addressbook/backend/ebook/e-book-async.h" -#include "addressbook/backend/ebook/e-contact.h" +#include <libebook/e-book-async.h> +#include <libebook/e-contact.h> #include "addressbook/util/eab-destination.h" G_BEGIN_DECLS diff --git a/addressbook/gui/merging/eab-contact-compare.h b/addressbook/gui/merging/eab-contact-compare.h index 07a9cd7e35..4b97b3c698 100644 --- a/addressbook/gui/merging/eab-contact-compare.h +++ b/addressbook/gui/merging/eab-contact-compare.h @@ -28,8 +28,8 @@ #ifndef __EAB_CONTACT_COMPARE_H__ #define __EAB_CONTACT_COMPARE_H__ -#include "ebook/e-book.h" -#include "ebook/e-contact.h" +#include <libebook/e-book.h> +#include <libebook/e-contact.h> typedef enum { EAB_CONTACT_MATCH_NOT_APPLICABLE = 0, diff --git a/addressbook/gui/merging/eab-contact-merging.h b/addressbook/gui/merging/eab-contact-merging.h index 6011263f31..d6d60e57de 100644 --- a/addressbook/gui/merging/eab-contact-merging.h +++ b/addressbook/gui/merging/eab-contact-merging.h @@ -12,7 +12,7 @@ #ifndef __E_CONTACT_MERGING_H__ #define __E_CONTACT_MERGING_H__ -#include <addressbook/backend/ebook/e-book-async.h> +#include <libebook/e-book-async.h> G_BEGIN_DECLS diff --git a/addressbook/gui/search/e-addressbook-search-dialog.h b/addressbook/gui/search/e-addressbook-search-dialog.h index ef501766ea..8634074f69 100644 --- a/addressbook/gui/search/e-addressbook-search-dialog.h +++ b/addressbook/gui/search/e-addressbook-search-dialog.h @@ -21,7 +21,7 @@ #ifndef __EAB_SEARCH_DIALOG_H__ #define __EAB_SEARCH_DIALOG_H__ -#include <ebook/e-book.h> +#include <libebook/e-book.h> #include "addressbook/gui/widgets/e-addressbook-view.h" #include "filter/rule-context.h" diff --git a/addressbook/gui/widgets/e-addressbook-model.h b/addressbook/gui/widgets/e-addressbook-model.h index 35f9d0e87f..64ce6c3845 100644 --- a/addressbook/gui/widgets/e-addressbook-model.h +++ b/addressbook/gui/widgets/e-addressbook-model.h @@ -4,8 +4,8 @@ #include <glib.h> #include <glib-object.h> -#include "addressbook/backend/ebook/e-book-async.h" -#include "addressbook/backend/ebook/e-book-view.h" +#include <libebook/e-book-async.h> +#include <libebook/e-book-view.h> #define EAB_TYPE_MODEL (eab_model_get_type ()) #define EAB_MODEL(o) (G_TYPE_CHECK_INSTANCE_CAST ((o), EAB_TYPE_MODEL, EABModel)) diff --git a/addressbook/gui/widgets/e-addressbook-reflow-adapter.h b/addressbook/gui/widgets/e-addressbook-reflow-adapter.h index 9ba7d2cf2d..1321b27bb4 100644 --- a/addressbook/gui/widgets/e-addressbook-reflow-adapter.h +++ b/addressbook/gui/widgets/e-addressbook-reflow-adapter.h @@ -3,8 +3,8 @@ #define _E_ADDRESSBOOK_REFLOW_ADAPTER_H_ #include <gal/widgets/e-reflow-model.h> +#include <libebook/e-contact.h> #include "e-addressbook-model.h" -#include "addressbook/backend/ebook/e-contact.h" #define E_TYPE_ADDRESSBOOK_REFLOW_ADAPTER (e_addressbook_reflow_adapter_get_type ()) #define E_ADDRESSBOOK_REFLOW_ADAPTER(o) (G_TYPE_CHECK_INSTANCE_CAST ((o), E_TYPE_ADDRESSBOOK_REFLOW_ADAPTER, EAddressbookReflowAdapter)) diff --git a/addressbook/gui/widgets/e-addressbook-table-adapter.h b/addressbook/gui/widgets/e-addressbook-table-adapter.h index 6f4bfd2960..cf139e2bee 100644 --- a/addressbook/gui/widgets/e-addressbook-table-adapter.h +++ b/addressbook/gui/widgets/e-addressbook-table-adapter.h @@ -3,8 +3,8 @@ #define _EAB_TABLE_ADAPTER_H_ #include <gal/e-table/e-table-model.h> -#include "addressbook/backend/ebook/e-book.h" -#include "addressbook/backend/ebook/e-book-view.h" +#include <libebook/e-book.h> +#include <libebook/e-book-view.h> #define E_TYPE_AB_TABLE_ADAPTER (eab_table_adapter_get_type ()) #define EAB_TABLE_ADAPTER(o) (G_TYPE_CHECK_INSTANCE_CAST ((o), E_TYPE_AB_TABLE_ADAPTER, EAddressbookTableAdapter)) diff --git a/addressbook/gui/widgets/e-addressbook-view.h b/addressbook/gui/widgets/e-addressbook-view.h index 1573f682ed..f819704550 100644 --- a/addressbook/gui/widgets/e-addressbook-view.h +++ b/addressbook/gui/widgets/e-addressbook-view.h @@ -23,10 +23,10 @@ #include <gtk/gtkeventbox.h> #include <bonobo/bonobo-ui-component.h> #include <gal/menus/gal-view-instance.h> +#include <libebook/e-book.h> #include "e-addressbook-model.h" #include "eab-contact-display.h" #include "widgets/menus/gal-view-menus.h" -#include "addressbook/backend/ebook/e-book.h" G_BEGIN_DECLS diff --git a/addressbook/gui/widgets/e-minicard-view-widget.h b/addressbook/gui/widgets/e-minicard-view-widget.h index 4e2da4cedf..ef8401b88c 100644 --- a/addressbook/gui/widgets/e-minicard-view-widget.h +++ b/addressbook/gui/widgets/e-minicard-view-widget.h @@ -21,7 +21,7 @@ #define __E_MINICARD_VIEW_WIDGET_H__ #include <gal/widgets/e-canvas.h> -#include "addressbook/backend/ebook/e-book.h" +#include <libebook/e-book.h> #include "e-minicard-view.h" G_BEGIN_DECLS diff --git a/addressbook/gui/widgets/e-minicard-view.h b/addressbook/gui/widgets/e-minicard-view.h index afd432fd8e..2614b7577a 100644 --- a/addressbook/gui/widgets/e-minicard-view.h +++ b/addressbook/gui/widgets/e-minicard-view.h @@ -24,7 +24,7 @@ #include <gal/widgets/e-reflow.h> #include <gal/widgets/e-selection-model-simple.h> -#include "addressbook/backend/ebook/e-book.h" +#include <libebook/e-book.h> #include "e-addressbook-reflow-adapter.h" G_BEGIN_DECLS diff --git a/addressbook/gui/widgets/e-minicard.c b/addressbook/gui/widgets/e-minicard.c index f9aa893dc3..85060ce156 100644 --- a/addressbook/gui/widgets/e-minicard.c +++ b/addressbook/gui/widgets/e-minicard.c @@ -32,7 +32,7 @@ #include <gal/util/e-util.h> #include <gal/widgets/e-canvas-utils.h> #include <gal/widgets/e-canvas.h> -#include "addressbook/backend/ebook/e-book.h" +#include <libebook/e-book.h> #include "eab-marshal.h" #include "eab-gui-util.h" #include "e-minicard.h" diff --git a/addressbook/gui/widgets/e-minicard.h b/addressbook/gui/widgets/e-minicard.h index e4673fe4d9..2d0cfd8ed5 100644 --- a/addressbook/gui/widgets/e-minicard.h +++ b/addressbook/gui/widgets/e-minicard.h @@ -23,7 +23,7 @@ #include <gdk-pixbuf/gdk-pixbuf.h> #include "addressbook/gui/contact-editor/e-contact-editor.h" #include <libgnomecanvas/gnome-canvas.h> -#include "addressbook/backend/ebook/e-contact.h" +#include <libebook/e-contact.h> #ifdef __cplusplus extern "C" { diff --git a/addressbook/gui/widgets/eab-contact-display.h b/addressbook/gui/widgets/eab-contact-display.h index 83bad9ae64..e7f47031ce 100644 --- a/addressbook/gui/widgets/eab-contact-display.h +++ b/addressbook/gui/widgets/eab-contact-display.h @@ -25,7 +25,7 @@ #include <gtk/gtkvbox.h> #include <gtkhtml/gtkhtml.h> -#include <ebook/e-contact.h> +#include <libebook/e-contact.h> #define EAB_TYPE_CONTACT_DISPLAY (eab_contact_display_get_type ()) #define EAB_CONTACT_DISPLAY(o) (G_TYPE_CHECK_INSTANCE_CAST ((o), EAB_TYPE_CONTACT_DISPLAY, EABContactDisplay)) diff --git a/addressbook/gui/widgets/eab-gui-util.h b/addressbook/gui/widgets/eab-gui-util.h index 71a80bc7a6..24a0a78577 100644 --- a/addressbook/gui/widgets/eab-gui-util.h +++ b/addressbook/gui/widgets/eab-gui-util.h @@ -21,7 +21,7 @@ #define __E_ADDRESSBOOK_UTIL_H__ #include <gtk/gtkwindow.h> -#include "addressbook/backend/ebook/e-book.h" +#include <libebook/e-book.h> #include "addressbook/gui/contact-editor/e-contact-editor.h" #include "addressbook/gui/contact-list-editor/e-contact-list-editor.h" diff --git a/addressbook/gui/widgets/eab-popup-control.c b/addressbook/gui/widgets/eab-popup-control.c index e2d0299d6e..6e2ad6a603 100644 --- a/addressbook/gui/widgets/eab-popup-control.c +++ b/addressbook/gui/widgets/eab-popup-control.c @@ -37,7 +37,7 @@ #include <bonobo/bonobo-property-bag.h> #include <bonobo/bonobo-generic-factory.h> #include <gal/widgets/e-popup-menu.h> -#include <addressbook/backend/ebook/e-book-async.h> +#include <libebook/e-book-async.h> #include <addressbook/util/eab-book-util.h> #include <addressbook/gui/contact-editor/e-contact-editor.h> #include <addressbook/gui/contact-editor/e-contact-quick-add.h> diff --git a/addressbook/gui/widgets/eab-popup-control.h b/addressbook/gui/widgets/eab-popup-control.h index 4d223f02cb..2feb3ac7d0 100644 --- a/addressbook/gui/widgets/eab-popup-control.h +++ b/addressbook/gui/widgets/eab-popup-control.h @@ -28,10 +28,10 @@ #ifndef __EAB_POPUP_CONTROL_H__ #define __EAB_POPUP_CONTROL_H__ -#include <gtk/gtk.h> -#include <addressbook/backend/ebook/e-book-async.h> -#include <addressbook/backend/ebook/e-contact.h> #include <bonobo/bonobo-event-source.h> +#include <gtk/gtk.h> +#include <libebook/e-book-async.h> +#include <libebook/e-contact.h> G_BEGIN_DECLS diff --git a/addressbook/gui/widgets/eab-vcard-control.c b/addressbook/gui/widgets/eab-vcard-control.c index 82c5fd6032..8e4235d78e 100644 --- a/addressbook/gui/widgets/eab-vcard-control.c +++ b/addressbook/gui/widgets/eab-vcard-control.c @@ -33,10 +33,10 @@ #include <bonobo/bonobo-stream-client.h> #include <gal/util/e-util.h> +#include <libebook/e-book-async.h> +#include <libebook/e-contact.h> #include <addressbook/gui/component/addressbook.h> #include <addressbook/gui/widgets/eab-contact-display.h> -#include <addressbook/backend/ebook/e-book-async.h> -#include <addressbook/backend/ebook/e-contact.h> #include <addressbook/util/eab-book-util.h> #include "eab-vcard-control.h" diff --git a/addressbook/printing/Makefile.am b/addressbook/printing/Makefile.am index f9e9661890..8da93df0b8 100644 --- a/addressbook/printing/Makefile.am +++ b/addressbook/printing/Makefile.am @@ -40,7 +40,6 @@ contact_print_test_SOURCES = \ contact_print_test_LDADD = \ libecontactprint.la \ $(top_builddir)/addressbook/util/libeabutil.la \ - $(top_builddir)/addressbook/backend/ebook/libebook.la \ $(EVOLUTION_ADDRESSBOOK_LIBS) contact_print_style_editor_test_SOURCES = \ @@ -49,7 +48,6 @@ contact_print_style_editor_test_SOURCES = \ contact_print_style_editor_test_LDADD = \ libecontactprint.la \ $(top_builddir)/addressbook/util/libeabutil.la \ - $(top_builddir)/addressbook/backend/ebook/libebook.la \ $(EVOLUTION_ADDRESSBOOK_LIBS) diff --git a/addressbook/printing/e-contact-print-envelope.h b/addressbook/printing/e-contact-print-envelope.h index d9e24b1794..a7a8492638 100644 --- a/addressbook/printing/e-contact-print-envelope.h +++ b/addressbook/printing/e-contact-print-envelope.h @@ -22,8 +22,8 @@ #ifndef E_CONTACT_PRINT_ENVELOPE_H #define E_CONTACT_PRINT_ENVELOPE_H -#include <addressbook/backend/ebook/e-contact.h> #include <gtk/gtkwidget.h> +#include <libebook/e-contact.h> #include "e-contact-print-types.h" GtkWidget *e_contact_print_envelope_dialog_new(EContact *contact); diff --git a/addressbook/printing/e-contact-print.c b/addressbook/printing/e-contact-print.c index 0aa2e67900..1a9b83c62d 100644 --- a/addressbook/printing/e-contact-print.c +++ b/addressbook/printing/e-contact-print.c @@ -38,8 +38,8 @@ #include <libgnomeprint/gnome-print-job.h> #include <libgnomeprintui/gnome-print-dialog.h> #include <libgnomeprintui/gnome-print-job-preview.h> -#include <addressbook/backend/ebook/e-book-async.h> -#include <addressbook/backend/ebook/e-contact.h> +#include <libebook/e-book-async.h> +#include <libebook/e-contact.h> #include <addressbook/util/eab-destination.h> #define SCALE 5 diff --git a/addressbook/printing/e-contact-print.h b/addressbook/printing/e-contact-print.h index 8c2fbb6acb..4edc948082 100644 --- a/addressbook/printing/e-contact-print.h +++ b/addressbook/printing/e-contact-print.h @@ -24,8 +24,8 @@ #include <glib.h> #include <gtk/gtkwidget.h> -#include <addressbook/backend/ebook/e-book.h> -#include <addressbook/backend/ebook/e-contact.h> +#include <libebook/e-book.h> +#include <libebook/e-contact.h> #include "e-contact-print-types.h" GtkWidget *e_contact_print_dialog_new(EBook *book, char *query); diff --git a/addressbook/util/Makefile.am b/addressbook/util/Makefile.am index 51b6e7fc28..56aadd1153 100644 --- a/addressbook/util/Makefile.am +++ b/addressbook/util/Makefile.am @@ -19,16 +19,14 @@ INCLUDES = \ noinst_LTLIBRARIES = libeabutil.la libeabutil_la_SOURCES = \ - eab-marshal.c \ + eab-marshal.c \ eab-destination.c \ eab-destination.h \ eab-book-util.c \ eab-book-util.h -libeabutil_la_LIBADD = \ - $(top_builddir)/addressbook/backend/ebook/libebook.la \ - $(top_builddir)/camel/libcamel.la \ - $(top_builddir)/e-util/ename/libename.la \ +libeabutil_la_LIBADD = \ + $(top_builddir)/camel/libcamel.la \ $(top_builddir)/e-util/libeutil.la MARSHAL_GENERATED = eab-marshal.c eab-marshal.h diff --git a/addressbook/util/eab-book-util.h b/addressbook/util/eab-book-util.h index be5451b795..7fda98adf3 100644 --- a/addressbook/util/eab-book-util.h +++ b/addressbook/util/eab-book-util.h @@ -28,10 +28,10 @@ #ifndef __EAB_UTIL_H__ #define __EAB_UTIL_H__ -#include "ebook/e-book-async.h" -#include "e-util/e-config-listener.h" #include <bonobo/bonobo-object.h> #include <bonobo/bonobo-moniker-util.h> +#include <libebook/e-book-async.h> +#include "e-util/e-config-listener.h" G_BEGIN_DECLS diff --git a/addressbook/util/eab-destination.c b/addressbook/util/eab-destination.c index d83ad8563a..07557b1455 100644 --- a/addressbook/util/eab-destination.c +++ b/addressbook/util/eab-destination.c @@ -31,7 +31,7 @@ #include <stdlib.h> #include <ctype.h> #include <string.h> -#include "ebook/e-book.h" +#include <libebook/e-book.h> #include "eab-marshal.h" #include "eab-book-util.h" #include <gal/widgets/e-unicode.h> diff --git a/addressbook/util/eab-destination.h b/addressbook/util/eab-destination.h index 452d893e44..2c8e2abc11 100644 --- a/addressbook/util/eab-destination.h +++ b/addressbook/util/eab-destination.h @@ -30,8 +30,8 @@ #include <glib.h> #include <glib-object.h> -#include <ebook/e-contact.h> -#include <ebook/e-book.h> +#include <libebook/e-contact.h> +#include <libebook/e-book.h> #include <libxml/tree.h> #define EAB_TYPE_DESTINATION (eab_destination_get_type ()) diff --git a/calendar/ChangeLog b/calendar/ChangeLog index 41c4fdc1aa..d6d7a0e498 100644 --- a/calendar/ChangeLog +++ b/calendar/ChangeLog @@ -1,3 +1,10 @@ +2003-11-07 JP Rosevear <jpr@ximian.com> + + * In the gui this is a search and replace commit for moving the + calendar to evolution-data-server; it also deletes the old backend + files; e-cal-view was rename to e-calendar-view to remove name + conflict + 2003-11-05 JP Rosevear <jpr@ximian.com> * gui/migration.c: fix typo diff --git a/calendar/Makefile.am b/calendar/Makefile.am index 4b0426da91..76851cc008 100644 --- a/calendar/Makefile.am +++ b/calendar/Makefile.am @@ -4,7 +4,7 @@ else CONDUIT_DIR = endif -SUBDIRS = idl cal-util pcs cal-client gui importers $(CONDUIT_DIR) +SUBDIRS = idl gui importers $(CONDUIT_DIR) EXTRA_DIST = \ ChangeLog.pre-1-4 \ diff --git a/calendar/cal-client/.cvsignore b/calendar/cal-client/.cvsignore deleted file mode 100644 index f2aa4f92ae..0000000000 --- a/calendar/cal-client/.cvsignore +++ /dev/null @@ -1,17 +0,0 @@ -Makefile.in -.deps -.libs -.pure -Makefile -evolution-calendar-stubs.c -evolution-calendar-skels.c -evolution-calendar-common.c -evolution-calendar.h -evolution-calendar-common.lo -evolution-calendar-skels.lo -evolution-calendar-stubs.lo -cal-marshal.c -cal-marshal.h -*.lo -*.la -client-test diff --git a/calendar/cal-client/Makefile.am b/calendar/cal-client/Makefile.am deleted file mode 100644 index 9008c05940..0000000000 --- a/calendar/cal-client/Makefile.am +++ /dev/null @@ -1,86 +0,0 @@ -INCLUDES = \ - -DEVOLUTION_LOCALEDIR=\""$(localedir)"\" \ - -DG_LOG_DOMAIN=\"cal-client\" \ - -I$(top_srcdir)/calendar \ - -I$(srcdir) -I$(top_srcdir) \ - -I. \ - -I.. \ - -I$(top_builddir) \ - -I$(top_srcdir)/libical/src \ - $(EVOLUTION_CALENDAR_CFLAGS) - -AM_CFLAGS = \ - -DGTK_DISABLE_DEPRECATED=1 \ - -DGDK_DISABLE_DEPRECATED=1 \ - -DG_DISABLE_DEPRECATED=1 \ - -DGNOME_DISABLE_DEPRECATED=1 - -CORBA_GENERATED_C = \ - evolution-calendar-common.c \ - evolution-calendar-skels.c \ - evolution-calendar-stubs.c -CORBA_GENERATED_H = \ - evolution-calendar.h - -CORBA_GENERATED = $(CORBA_GENERATED_C) $(CORBA_GENERATED_H) - -idls = \ - $(srcdir)/../idl/evolution-calendar.idl - -idl_flags = $(IDL_INCLUDES) - -$(CORBA_GENERATED_H): $(idls) - $(ORBIT_IDL) $(idl_flags) $(srcdir)/../idl/evolution-calendar.idl -$(CORBA_GENERATED_C): $(CORBA_GENERATED_H) - -privlib_LTLIBRARIES = libcal-client.la - -libcal_clientincludedir = $(privincludedir)/cal-client - -libcal_client_la_SOURCES = \ - $(CORBA_GENERATED_C) \ - cal-client-types.c \ - cal-marshal.c \ - cal-marshal.h \ - cal-client.c \ - cal-listener.c \ - cal-listener.h \ - cal-query.c \ - query-listener.c \ - query-listener.h - -libcal_client_la_LIBADD = \ - $(top_builddir)/calendar/cal-util/libcal-util.la \ - $(top_builddir)/e-util/libeutil.la - -libcal_clientinclude_HEADERS = \ - $(CORBA_GENERATED_H) \ - cal-client-types.h \ - cal-client.h \ - cal-query.h - -# -# client-test program -# - -noinst_PROGRAMS = client-test - -client_test_SOURCES = \ - client-test.c - -client_test_INCLUDES = \ - $(INCLUDES) \ - -DG_LOG_DOMAIN=\"client-test\" - -client_test_LDADD = \ - libcal-client.la \ - $(EVOLUTION_CALENDAR_LIBS) - -MARSHAL_GENERATED = cal-marshal.c cal-marshal.h -@EVO_MARSHAL_RULE@ - -BUILT_SOURCES = $(CORBA_GENERATED) $(MARSHAL_GENERATED) -CLEANFILES = $(BUILT_SOURCES) - -dist-hook: - cd $(distdir); rm -f $(BUILT_SOURCES) diff --git a/calendar/cal-client/cal-client-types.c b/calendar/cal-client/cal-client-types.c deleted file mode 100644 index 36a524ec99..0000000000 --- a/calendar/cal-client/cal-client-types.c +++ /dev/null @@ -1,52 +0,0 @@ -/* Evolution calendar utilities and types - * - * Copyright (C) 2000 Ximian, Inc. - * Copyright (C) 2000 Ximian, Inc. - * - * Authors: Federico Mena-Quintero <federico@ximian.com> - * JP Rosevear <jpr@ximian.com> - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of version 2 of the GNU General Public - * License as published by the Free Software Foundation. - * - * 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA. - */ - -#include <config.h> -#include <stdlib.h> -#include "cal-client-types.h" - - - -/** - * cal_client_change_list_free: - * @list: List of #CalClientChange structures. - * - * Frees a list of #CalClientChange structures. - **/ -void -cal_client_change_list_free (GList *list) -{ - CalClientChange *c; - GList *l; - - for (l = list; l; l = l->next) { - c = l->data; - - g_assert (c != NULL); - g_assert (c->comp != NULL); - - g_object_unref (G_OBJECT (c->comp)); - g_free (c); - } - - g_list_free (list); -} diff --git a/calendar/cal-client/cal-client-types.h b/calendar/cal-client/cal-client-types.h deleted file mode 100644 index 925628337b..0000000000 --- a/calendar/cal-client/cal-client-types.h +++ /dev/null @@ -1,75 +0,0 @@ -/* Evolution calendar utilities and types - * - * Copyright (C) 2000 Ximian, Inc. - * Copyright (C) 2000 Ximian, Inc. - * - * Authors: Federico Mena-Quintero <federico@ximian.com> - * JP Rosevear <jpr@ximian.com> - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of version 2 of the GNU General Public - * License as published by the Free Software Foundation. - * - * 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA. - */ - -#ifndef CAL_CLIENT_TYPES_H -#define CAL_CLIENT_TYPES_H - -#include <cal-util/cal-component.h> - -G_BEGIN_DECLS - - - -#define E_CALENDAR_ERROR e_calendar_error_quark() - -GQuark e_calendar_error_quark (void) G_GNUC_CONST; - -typedef enum { - CAL_CLIENT_CHANGE_ADDED = 1 << 0, - CAL_CLIENT_CHANGE_MODIFIED = 1 << 1, - CAL_CLIENT_CHANGE_DELETED = 1 << 2 -} CalClientChangeType; - -typedef struct -{ - CalComponent *comp; - CalClientChangeType type; -} CalClientChange; - -typedef enum { - E_CALENDAR_STATUS_OK, - E_CALENDAR_STATUS_INVALID_ARG, - E_CALENDAR_STATUS_BUSY, - E_CALENDAR_STATUS_REPOSITORY_OFFLINE, - E_CALENDAR_STATUS_NO_SUCH_CALENDAR, - E_CALENDAR_STATUS_OBJECT_NOT_FOUND, - E_CALENDAR_STATUS_INVALID_OBJECT, - E_CALENDAR_STATUS_URI_NOT_LOADED, - E_CALENDAR_STATUS_URI_ALREADY_LOADED, - E_CALENDAR_STATUS_PERMISSION_DENIED, - E_CALENDAR_STATUS_CARD_NOT_FOUND, - E_CALENDAR_STATUS_CARD_ID_ALREADY_EXISTS, - E_CALENDAR_STATUS_PROTOCOL_NOT_SUPPORTED, - E_CALENDAR_STATUS_CANCELLED, - E_CALENDAR_STATUS_COULD_NOT_CANCEL, - E_CALENDAR_STATUS_AUTHENTICATION_FAILED, - E_CALENDAR_STATUS_AUTHENTICATION_REQUIRED, - E_CALENDAR_STATUS_CORBA_EXCEPTION, - E_CALENDAR_STATUS_OTHER_ERROR -} ECalendarStatus; - -void cal_client_change_list_free (GList *list); - -G_END_DECLS - -#endif - diff --git a/calendar/cal-client/cal-client.c b/calendar/cal-client/cal-client.c deleted file mode 100644 index f69567b90e..0000000000 --- a/calendar/cal-client/cal-client.c +++ /dev/null @@ -1,3823 +0,0 @@ -/* Evolution calendar client - * - * Copyright (C) 2001 Ximian, Inc. - * - * Author: Federico Mena-Quintero <federico@ximian.com> - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of version 2 of the GNU General Public - * License as published by the Free Software Foundation. - * - * 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA. - */ - -#ifdef HAVE_CONFIG_H -#include <config.h> -#endif - -#include <pthread.h> -#include <string.h> -#include <bonobo-activation/bonobo-activation.h> -#include <bonobo/bonobo-exception.h> -#include <bonobo/bonobo-i18n.h> -#include <libgnome/gnome-util.h> - -#include "e-util/e-component-listener.h" -#include "e-util/e-config-listener.h" -#include "e-util/e-url.h" -#include "e-util/e-msgport.h" -#include "cal-util/cal-util-marshal.h" -#include "cal-util/timeutil.h" -#include "cal-client.h" -#include "cal-listener.h" -#include "query-listener.h" - - - -typedef struct { - EMutex *mutex; - pthread_cond_t cond; - ECalendarStatus status; - - char *uid; - GList *list; - gboolean bool; - char *string; - - CalQuery *query; - QueryListener *listener; -} ECalendarOp; - -/* Private part of the CalClient structure */ -struct _CalClientPrivate { - /* Load state to avoid multiple loads */ - CalClientLoadState load_state; - - /* URI of the calendar that is being loaded or is already loaded, or - * NULL if we are not loaded. - */ - char *uri; - CalObjType type; - - ECalendarOp *current_op; - - EMutex *mutex; - - /* Email address associated with this calendar, or NULL */ - char *cal_address; - char *alarm_email_address; - char *ldap_attribute; - - /* Scheduling info */ - char *capabilities; - - /* The calendar factories we are contacting */ - GList *factories; - - /* Our calendar listener implementation */ - CalListener *listener; - - /* The calendar client interface object we are contacting */ - GNOME_Evolution_Calendar_Cal cal; - - /* The authentication function */ - CalClientAuthFunc auth_func; - gpointer auth_user_data; - - /* A cache of timezones retrieved from the server, to avoid getting - them repeatedly for each get_object() call. */ - GHashTable *timezones; - - /* The default timezone to use to resolve DATE and floating DATE-TIME - values. */ - icaltimezone *default_zone; - - /* The component listener to keep track of the lifetime of backends */ - EComponentListener *comp_listener; -}; - - - -/* Signal IDs */ -enum { - CAL_OPENED, - CAL_SET_MODE, - BACKEND_ERROR, - CATEGORIES_CHANGED, - FORGET_PASSWORD, - BACKEND_DIED, - LAST_SIGNAL -}; - -static void cal_client_get_object_timezones_cb (icalparameter *param, - void *data); - -static guint cal_client_signals[LAST_SIGNAL]; - -static GObjectClass *parent_class; - -#define E_CALENDAR_CHECK_STATUS(status,error) G_STMT_START{ \ - if ((status) == E_CALENDAR_STATUS_OK) { \ - return TRUE; \ - } \ - else { \ - const char *msg; \ - msg = cal_client_get_error_message ((status)); \ - g_set_error ((error), E_CALENDAR_ERROR, (status), msg, (status)); \ - return FALSE; \ - } }G_STMT_END - - - -/* Error quark */ -GQuark -e_calendar_error_quark (void) -{ - static GQuark q = 0; - if (q == 0) - q = g_quark_from_static_string ("e-calendar-error-quark"); - - return q; -} - -GType -cal_client_open_status_enum_get_type (void) -{ - static GType cal_client_open_status_enum_type = 0; - - if (!cal_client_open_status_enum_type) { - static GEnumValue values [] = { - { CAL_CLIENT_OPEN_SUCCESS, "CalClientOpenSuccess", "success" }, - { CAL_CLIENT_OPEN_ERROR, "CalClientOpenError", "error" }, - { CAL_CLIENT_OPEN_NOT_FOUND, "CalClientOpenNotFound", "not-found" }, - { CAL_CLIENT_OPEN_PERMISSION_DENIED, "CalClientOpenPermissionDenied", "denied" }, - { CAL_CLIENT_OPEN_METHOD_NOT_SUPPORTED, "CalClientOpenMethodNotSupported", "unsupported" }, - { -1, NULL, NULL } - }; - - cal_client_open_status_enum_type = g_enum_register_static ("CalClientOpenStatusEnum", values); - } - - return cal_client_open_status_enum_type; -} - -GType -cal_client_set_mode_status_enum_get_type (void) -{ - static GType cal_client_set_mode_status_enum_type = 0; - - if (!cal_client_set_mode_status_enum_type) { - static GEnumValue values [] = { - { CAL_CLIENT_SET_MODE_SUCCESS, "CalClientSetModeSuccess", "success" }, - { CAL_CLIENT_SET_MODE_ERROR, "CalClientSetModeError", "error" }, - { CAL_CLIENT_SET_MODE_NOT_SUPPORTED, "CalClientSetModeNotSupported", "unsupported" }, - { -1, NULL, NULL } - }; - - cal_client_set_mode_status_enum_type = - g_enum_register_static ("CalClientSetModeStatusEnum", values); - } - - return cal_client_set_mode_status_enum_type; -} - -GType -cal_mode_enum_get_type (void) -{ - static GType cal_mode_enum_type = 0; - - if (!cal_mode_enum_type) { - static GEnumValue values [] = { - { CAL_MODE_INVALID, "CalModeInvalid", "invalid" }, - { CAL_MODE_LOCAL, "CalModeLocal", "local" }, - { CAL_MODE_REMOTE, "CalModeRemote", "remote" }, - { CAL_MODE_ANY, "CalModeAny", "any" }, - { -1, NULL, NULL } - }; - - cal_mode_enum_type = g_enum_register_static ("CalModeEnum", values); - } - - return cal_mode_enum_type; -} - -/* EBookOp calls */ - -static ECalendarOp* -e_calendar_new_op (CalClient *client) -{ - ECalendarOp *op = g_new0 (ECalendarOp, 1); - - op->mutex = e_mutex_new (E_MUTEX_SIMPLE); - pthread_cond_init (&op->cond, 0); - - client->priv->current_op = op; - - return op; -} - -static ECalendarOp* -e_calendar_get_op (CalClient *client) -{ - if (!client->priv->current_op) { - g_warning (G_STRLOC ": Unexpected response"); - return NULL; - } - - return client->priv->current_op; -} - -static void -e_calendar_free_op (ECalendarOp *op) -{ - /* XXX more stuff here */ - pthread_cond_destroy (&op->cond); - e_mutex_destroy (op->mutex); - g_free (op); -} - -static void -e_calendar_remove_op (CalClient *client, ECalendarOp *op) -{ - if (client->priv->current_op != op) - g_warning (G_STRLOC ": Cannot remove op, it's not current"); - - client->priv->current_op = NULL; -} - -/* Gets rid of the factories that a client knows about */ -static void -destroy_factories (CalClient *client) -{ - CalClientPrivate *priv; - CORBA_Object factory; - CORBA_Environment ev; - int result; - GList *f; - - priv = client->priv; - - CORBA_exception_init (&ev); - - for (f = priv->factories; f; f = f->next) { - factory = f->data; - - result = CORBA_Object_is_nil (factory, &ev); - if (BONOBO_EX (&ev)) { - g_message ("destroy_factories(): could not see if a factory was nil"); - CORBA_exception_free (&ev); - - continue; - } - - if (result) - continue; - - CORBA_Object_release (factory, &ev); - if (BONOBO_EX (&ev)) { - g_message ("destroy_factories(): could not release a factory"); - CORBA_exception_free (&ev); - } - } - - g_list_free (priv->factories); - priv->factories = NULL; -} - -/* Gets rid of the calendar client interface object that a client knows about */ -static void -destroy_cal (CalClient *client) -{ - CalClientPrivate *priv; - CORBA_Environment ev; - int result; - - priv = client->priv; - - CORBA_exception_init (&ev); - result = CORBA_Object_is_nil (priv->cal, &ev); - if (BONOBO_EX (&ev)) { - g_message (G_STRLOC ": could not see if the " - "calendar client interface object was nil"); - priv->cal = CORBA_OBJECT_NIL; - CORBA_exception_free (&ev); - return; - } - CORBA_exception_free (&ev); - - if (result) - return; - - bonobo_object_release_unref (priv->cal, NULL); - priv->cal = CORBA_OBJECT_NIL; - -} - -static void -free_timezone (gpointer key, gpointer value, gpointer data) -{ - /* Note that the key comes from within the icaltimezone value, so we - don't free that. */ - icaltimezone_free (value, TRUE); -} - - - -static void -backend_died_cb (EComponentListener *cl, gpointer user_data) -{ - CalClientPrivate *priv; - CalClient *client = (CalClient *) user_data; - - g_return_if_fail (IS_CAL_CLIENT (client)); - - priv = client->priv; - priv->load_state = CAL_CLIENT_LOAD_NOT_LOADED; - g_signal_emit (G_OBJECT (client), cal_client_signals[BACKEND_DIED], 0); -} - -/* Signal handlers for the listener's signals */ -/* Handle the cal_opened notification from the listener */ - -static void -cal_read_only_cb (CalListener *listener, ECalendarStatus status, gboolean read_only, gpointer data) -{ - CalClient *client = data; - ECalendarOp *op; - - op = e_calendar_get_op (client); - - if (op == NULL) { - g_warning (G_STRLOC ": Cannot find operation "); - return; - } - - e_mutex_lock (op->mutex); - - op->status = status; - op->bool = read_only; - - pthread_cond_signal (&op->cond); - - e_mutex_unlock (op->mutex); -} - -static void -cal_cal_address_cb (CalListener *listener, ECalendarStatus status, const char *address, gpointer data) -{ - CalClient *client = data; - ECalendarOp *op; - - op = e_calendar_get_op (client); - - if (op == NULL) { - g_warning (G_STRLOC ": Cannot find operation "); - return; - } - - e_mutex_lock (op->mutex); - - op->status = status; - op->string = g_strdup (address); - - pthread_cond_signal (&op->cond); - - e_mutex_unlock (op->mutex); -} - -static void -cal_alarm_address_cb (CalListener *listener, ECalendarStatus status, const char *address, gpointer data) -{ - CalClient *client = data; - ECalendarOp *op; - - op = e_calendar_get_op (client); - - if (op == NULL) { - g_warning (G_STRLOC ": Cannot find operation "); - return; - } - - e_mutex_lock (op->mutex); - - op->status = status; - op->string = g_strdup (address); - - pthread_cond_signal (&op->cond); - - e_mutex_unlock (op->mutex); -} - -static void -cal_ldap_attribute_cb (CalListener *listener, ECalendarStatus status, const char *attribute, gpointer data) -{ - CalClient *client = data; - ECalendarOp *op; - - op = e_calendar_get_op (client); - - if (op == NULL) { - g_warning (G_STRLOC ": Cannot find operation "); - return; - } - - e_mutex_lock (op->mutex); - - op->status = status; - op->string = g_strdup (attribute); - - pthread_cond_signal (&op->cond); - - e_mutex_unlock (op->mutex); -} - -static void -cal_static_capabilities_cb (CalListener *listener, ECalendarStatus status, const char *capabilities, gpointer data) -{ - CalClient *client = data; - ECalendarOp *op; - - op = e_calendar_get_op (client); - - if (op == NULL) { - g_warning (G_STRLOC ": Cannot find operation "); - return; - } - - e_mutex_lock (op->mutex); - - op->status = status; - op->string = g_strdup (capabilities); - - pthread_cond_signal (&op->cond); - - e_mutex_unlock (op->mutex); -} - -static void -cal_opened_cb (CalListener *listener, ECalendarStatus status, gpointer data) -{ - CalClient *client = data; - ECalendarOp *op; - - op = e_calendar_get_op (client); - - if (op == NULL) { - g_warning (G_STRLOC ": Cannot find operation "); - return; - } - - e_mutex_lock (op->mutex); - - op->status = status; - - pthread_cond_signal (&op->cond); - - e_mutex_unlock (op->mutex); -} - -static void -cal_removed_cb (CalListener *listener, ECalendarStatus status, gpointer data) -{ - CalClient *client = data; - ECalendarOp *op; - - op = e_calendar_get_op (client); - - if (op == NULL) { - g_warning (G_STRLOC ": Cannot find operation "); - return; - } - - e_mutex_lock (op->mutex); - - op->status = status; - - pthread_cond_signal (&op->cond); - - e_mutex_unlock (op->mutex); -} - -static void -cal_object_created_cb (CalListener *listener, ECalendarStatus status, const char *uid, gpointer data) -{ - CalClient *client = data; - ECalendarOp *op; - - op = e_calendar_get_op (client); - - if (op == NULL) { - g_warning (G_STRLOC ": Cannot find operation "); - return; - } - - e_mutex_lock (op->mutex); - - op->status = status; - op->uid = g_strdup (uid); - - pthread_cond_signal (&op->cond); - - e_mutex_unlock (op->mutex); -} - -static void -cal_object_modified_cb (CalListener *listener, ECalendarStatus status, gpointer data) -{ - CalClient *client = data; - ECalendarOp *op; - - op = e_calendar_get_op (client); - - if (op == NULL) { - g_warning (G_STRLOC ": Cannot find operation "); - return; - } - - e_mutex_lock (op->mutex); - - op->status = status; - - pthread_cond_signal (&op->cond); - - e_mutex_unlock (op->mutex); -} - -static void -cal_object_removed_cb (CalListener *listener, ECalendarStatus status, gpointer data) -{ - CalClient *client = data; - ECalendarOp *op; - - op = e_calendar_get_op (client); - - if (op == NULL) { - g_warning (G_STRLOC ": Cannot find operation "); - return; - } - - e_mutex_lock (op->mutex); - - op->status = status; - - pthread_cond_signal (&op->cond); - - e_mutex_unlock (op->mutex); -} - -static void -cal_alarm_discarded_cb (CalListener *listener, ECalendarStatus status, gpointer data) -{ - CalClient *client = data; - ECalendarOp *op; - - op = e_calendar_get_op (client); - - if (op == NULL) { - g_warning (G_STRLOC ": Cannot find operation "); - return; - } - - e_mutex_lock (op->mutex); - - op->status = status; - - pthread_cond_signal (&op->cond); - - e_mutex_unlock (op->mutex); -} - -static void -cal_objects_received_cb (CalListener *listener, ECalendarStatus status, gpointer data) -{ - CalClient *client = data; - ECalendarOp *op; - - op = e_calendar_get_op (client); - - if (op == NULL) { - g_warning (G_STRLOC ": Cannot find operation "); - return; - } - - e_mutex_lock (op->mutex); - - op->status = status; - - pthread_cond_signal (&op->cond); - - e_mutex_unlock (op->mutex); -} - -static void -cal_objects_sent_cb (CalListener *listener, ECalendarStatus status, gpointer data) -{ - CalClient *client = data; - ECalendarOp *op; - - op = e_calendar_get_op (client); - - if (op == NULL) { - g_warning (G_STRLOC ": Cannot find operation "); - return; - } - - e_mutex_lock (op->mutex); - - op->status = status; - - pthread_cond_signal (&op->cond); - - e_mutex_unlock (op->mutex); -} - -static void -cal_default_object_requested_cb (CalListener *listener, ECalendarStatus status, const char *object, gpointer data) -{ - CalClient *client = data; - ECalendarOp *op; - - op = e_calendar_get_op (client); - - if (op == NULL) { - g_warning (G_STRLOC ": Cannot find operation "); - return; - } - - e_mutex_lock (op->mutex); - - op->status = status; - op->string = g_strdup (object); - - pthread_cond_signal (&op->cond); - - e_mutex_unlock (op->mutex); -} - -static void -cal_object_requested_cb (CalListener *listener, ECalendarStatus status, const char *object, gpointer data) -{ - CalClient *client = data; - ECalendarOp *op; - - op = e_calendar_get_op (client); - - if (op == NULL) { - g_warning (G_STRLOC ": Cannot find operation "); - return; - } - - e_mutex_lock (op->mutex); - - op->status = status; - op->string = g_strdup (object); - - pthread_cond_signal (&op->cond); - - e_mutex_unlock (op->mutex); -} - -static void -cal_object_list_cb (CalListener *listener, ECalendarStatus status, GList *objects, gpointer data) -{ - CalClient *client = data; - ECalendarOp *op; - GList *l; - - op = e_calendar_get_op (client); - - if (op == NULL) { - g_warning (G_STRLOC ": Cannot find operation "); - return; - } - - e_mutex_lock (op->mutex); - - op->status = status; - op->list = g_list_copy (objects); - - for (l = op->list; l; l = l->next) - l->data = icalcomponent_new_clone (l->data); - - pthread_cond_signal (&op->cond); - - e_mutex_unlock (op->mutex); -} - -static void -cal_get_timezone_cb (CalListener *listener, ECalendarStatus status, const char *object, gpointer data) -{ - CalClient *client = data; - ECalendarOp *op; - - op = e_calendar_get_op (client); - - if (op == NULL) { - g_warning (G_STRLOC ": Cannot find operation "); - return; - } - - e_mutex_lock (op->mutex); - - op->status = status; - op->string = g_strdup (object); - - pthread_cond_signal (&op->cond); - - e_mutex_unlock (op->mutex); - -} - -static void -cal_add_timezone_cb (CalListener *listener, ECalendarStatus status, const char *tzid, gpointer data) -{ - CalClient *client = data; - ECalendarOp *op; - - op = e_calendar_get_op (client); - - if (op == NULL) { - g_warning (G_STRLOC ": Cannot find operation "); - return; - } - - e_mutex_lock (op->mutex); - - op->status = status; - op->uid = g_strdup (tzid); - - pthread_cond_signal (&op->cond); - - e_mutex_unlock (op->mutex); - -} - -static void -cal_set_default_timezone_cb (CalListener *listener, ECalendarStatus status, gpointer data) -{ - CalClient *client = data; - ECalendarOp *op; - - op = e_calendar_get_op (client); - - if (op == NULL) { - g_warning (G_STRLOC ": Cannot find operation "); - return; - } - - e_mutex_lock (op->mutex); - - op->status = status; - - pthread_cond_signal (&op->cond); - - e_mutex_unlock (op->mutex); -} - -static void -cal_get_changes_cb (CalListener *listener, ECalendarStatus status, GList *changes, gpointer data) -{ - CalClient *client = data; - ECalendarOp *op; - GList *l; - - op = e_calendar_get_op (client); - - if (op == NULL) { - g_warning (G_STRLOC ": Cannot find operation "); - return; - } - - e_mutex_lock (op->mutex); - - op->status = status; - op->list = g_list_copy (changes); - - for (l = op->list; l; l = l->next) { - CalClientChange *ccc = l->data, *new_ccc; - - new_ccc = g_new (CalClientChange, 1); - new_ccc->comp = cal_component_clone (ccc->comp); - new_ccc->type = ccc->type; - - l->data = new_ccc; - } - - pthread_cond_signal (&op->cond); - - e_mutex_unlock (op->mutex); -} - -static void -cal_get_free_busy_cb (CalListener *listener, ECalendarStatus status, GList *freebusy, gpointer data) -{ - CalClient *client = data; - ECalendarOp *op; - GList *l; - - op = e_calendar_get_op (client); - - if (op == NULL) { - g_warning (G_STRLOC ": Cannot find operation "); - return; - } - - e_mutex_lock (op->mutex); - - op->status = status; - op->list = g_list_copy (freebusy); - - for (l = op->list; l; l = l->next) - l->data = cal_component_clone (l->data); - - pthread_cond_signal (&op->cond); - - e_mutex_unlock (op->mutex); -} - -static void -cal_query_cb (CalListener *listener, ECalendarStatus status, GNOME_Evolution_Calendar_Query query, gpointer data) -{ - CalClient *client = data; - ECalendarOp *op; - - op = e_calendar_get_op (client); - - if (op == NULL) { - g_warning (G_STRLOC ": Cannot find operation "); - return; - } - - e_mutex_lock (op->mutex); - - op->status = status; - op->query = cal_query_new (query, op->listener, client); - - pthread_cond_signal (&op->cond); - - e_mutex_unlock (op->mutex); -} - -/* Handle the cal_set_mode notification from the listener */ -static void -cal_set_mode_cb (CalListener *listener, - GNOME_Evolution_Calendar_Listener_SetModeStatus status, - GNOME_Evolution_Calendar_CalMode mode, - gpointer data) -{ - CalClient *client; - CalClientPrivate *priv; - CalClientSetModeStatus client_status; - - client = CAL_CLIENT (data); - priv = client->priv; - - client_status = CAL_CLIENT_OPEN_ERROR; - - switch (status) { - case GNOME_Evolution_Calendar_Listener_MODE_SET: - client_status = CAL_CLIENT_SET_MODE_SUCCESS; - break; - case GNOME_Evolution_Calendar_Listener_MODE_NOT_SET: - client_status = CAL_CLIENT_SET_MODE_ERROR; - break; - case GNOME_Evolution_Calendar_Listener_MODE_NOT_SUPPORTED: - client_status = CAL_CLIENT_SET_MODE_NOT_SUPPORTED; - break; - default: - g_assert_not_reached (); - } - - /* We are *not* inside a signal handler (this is just a simple callback - * called from the listener), so there is not a temporary reference to - * the client object. We ref() so that we can safely emit our own - * signal and clean up. - */ - - g_object_ref (G_OBJECT (client)); - - g_signal_emit (G_OBJECT (client), cal_client_signals[CAL_SET_MODE], - 0, client_status, mode); - - g_object_unref (G_OBJECT (client)); -} - -/* Handle the error_occurred signal from the listener */ -static void -backend_error_cb (CalListener *listener, const char *message, gpointer data) -{ - CalClient *client; - - client = CAL_CLIENT (data); - g_signal_emit (G_OBJECT (client), cal_client_signals[BACKEND_ERROR], 0, message); -} - -/* Handle the categories_changed signal from the listener */ -static void -categories_changed_cb (CalListener *listener, const GNOME_Evolution_Calendar_StringSeq *categories, - gpointer data) -{ - CalClient *client; - GPtrArray *cats; - int i; - - client = CAL_CLIENT (data); - - cats = g_ptr_array_new (); - g_ptr_array_set_size (cats, categories->_length); - - for (i = 0; i < categories->_length; i++) - cats->pdata[i] = categories->_buffer[i]; - - g_signal_emit (G_OBJECT (client), cal_client_signals[CATEGORIES_CHANGED], 0, cats); - - g_ptr_array_free (cats, TRUE); -} - - - -static gboolean -get_factories (const char *str_uri, GList **factories) -{ - GNOME_Evolution_Calendar_CalFactory factory; - Bonobo_ServerInfoList *servers; - EUri *uri; - char *query; - int i; - - - /* Determine the protocol and query for factory supporting that */ - uri = e_uri_new (str_uri); - if (!uri) { - g_warning (G_STRLOC ": Invalid uri string"); - - return FALSE; - } - - query = g_strdup_printf ("repo_ids.has ('IDL:GNOME/Evolution/Calendar/CalFactory:1.0')" - " AND calendar:supported_protocols.has ('%s')", uri->protocol); - - - servers = bonobo_activation_query (query, NULL, NULL); - - g_free (query); - e_uri_free (uri); - - if (!servers) { - g_warning (G_STRLOC ": Unable to query for calendar factories"); - - return FALSE; - } - - /* Try to activate the servers for the protocol */ - for (i = 0; i < servers->_length; i++) { - const Bonobo_ServerInfo *info; - - info = servers->_buffer + i; - - g_message (G_STRLOC ": Activating calendar factory (%s)", info->iid); - factory = bonobo_activation_activate_from_id (info->iid, 0, NULL, NULL); - - if (factory == CORBA_OBJECT_NIL) - g_warning (G_STRLOC ": Could not activate calendar factory (%s)", info->iid); - else - *factories = g_list_append (*factories, factory); - } - - CORBA_free (servers); - - return TRUE; -} - -/* Object initialization function for the calendar client */ -static void -cal_client_init (CalClient *client, CalClientClass *klass) -{ - CalClientPrivate *priv; - - priv = g_new0 (CalClientPrivate, 1); - client->priv = priv; - - priv->load_state = CAL_CLIENT_LOAD_NOT_LOADED; - priv->uri = NULL; - priv->mutex = e_mutex_new (E_MUTEX_REC); - priv->listener = cal_listener_new (cal_set_mode_cb, - backend_error_cb, - categories_changed_cb, - client); - - priv->cal_address = NULL; - priv->alarm_email_address = NULL; - priv->ldap_attribute = NULL; - priv->capabilities = FALSE; - priv->factories = NULL; - priv->timezones = g_hash_table_new (g_str_hash, g_str_equal); - priv->default_zone = icaltimezone_get_utc_timezone (); - priv->comp_listener = NULL; - - g_signal_connect (G_OBJECT (priv->listener), "read_only", G_CALLBACK (cal_read_only_cb), client); - g_signal_connect (G_OBJECT (priv->listener), "cal_address", G_CALLBACK (cal_cal_address_cb), client); - g_signal_connect (G_OBJECT (priv->listener), "alarm_address", G_CALLBACK (cal_alarm_address_cb), client); - g_signal_connect (G_OBJECT (priv->listener), "ldap_attribute", G_CALLBACK (cal_ldap_attribute_cb), client); - g_signal_connect (G_OBJECT (priv->listener), "static_capabilities", G_CALLBACK (cal_static_capabilities_cb), client); - g_signal_connect (G_OBJECT (priv->listener), "open", G_CALLBACK (cal_opened_cb), client); - g_signal_connect (G_OBJECT (priv->listener), "remove", G_CALLBACK (cal_removed_cb), client); - g_signal_connect (G_OBJECT (priv->listener), "create_object", G_CALLBACK (cal_object_created_cb), client); - g_signal_connect (G_OBJECT (priv->listener), "modify_object", G_CALLBACK (cal_object_modified_cb), client); - g_signal_connect (G_OBJECT (priv->listener), "remove_object", G_CALLBACK (cal_object_removed_cb), client); - g_signal_connect (G_OBJECT (priv->listener), "discard_alarm", G_CALLBACK (cal_alarm_discarded_cb), client); - g_signal_connect (G_OBJECT (priv->listener), "receive_objects", G_CALLBACK (cal_objects_received_cb), client); - g_signal_connect (G_OBJECT (priv->listener), "send_objects", G_CALLBACK (cal_objects_sent_cb), client); - g_signal_connect (G_OBJECT (priv->listener), "default_object", G_CALLBACK (cal_default_object_requested_cb), client); - g_signal_connect (G_OBJECT (priv->listener), "object", G_CALLBACK (cal_object_requested_cb), client); - g_signal_connect (G_OBJECT (priv->listener), "object_list", G_CALLBACK (cal_object_list_cb), client); - g_signal_connect (G_OBJECT (priv->listener), "get_timezone", G_CALLBACK (cal_get_timezone_cb), client); - g_signal_connect (G_OBJECT (priv->listener), "add_timezone", G_CALLBACK (cal_add_timezone_cb), client); - g_signal_connect (G_OBJECT (priv->listener), "set_default_timezone", G_CALLBACK (cal_set_default_timezone_cb), client); - g_signal_connect (G_OBJECT (priv->listener), "get_changes", G_CALLBACK (cal_get_changes_cb), client); - g_signal_connect (G_OBJECT (priv->listener), "get_free_busy", G_CALLBACK (cal_get_free_busy_cb), client); - g_signal_connect (G_OBJECT (priv->listener), "query", G_CALLBACK (cal_query_cb), client); -} - -/* Finalize handler for the calendar client */ -static void -cal_client_finalize (GObject *object) -{ - CalClient *client; - CalClientPrivate *priv; - - g_return_if_fail (object != NULL); - g_return_if_fail (IS_CAL_CLIENT (object)); - - client = CAL_CLIENT (object); - priv = client->priv; - - if (priv->listener) { - cal_listener_stop_notification (priv->listener); - bonobo_object_unref (priv->listener); - priv->listener = NULL; - } - - if (priv->comp_listener) { - g_signal_handlers_disconnect_matched (G_OBJECT (priv->comp_listener), - G_SIGNAL_MATCH_DATA, - 0, 0, NULL, NULL, - client); - g_object_unref (G_OBJECT (priv->comp_listener)); - priv->comp_listener = NULL; - } - - destroy_factories (client); - destroy_cal (client); - - priv->load_state = CAL_CLIENT_LOAD_NOT_LOADED; - - if (priv->uri) { - g_free (priv->uri); - priv->uri = NULL; - } - - if (priv->mutex) { - e_mutex_destroy (priv->mutex); - priv->mutex = NULL; - } - - if (priv->cal_address) { - g_free (priv->cal_address); - priv->cal_address = NULL; - } - if (priv->alarm_email_address) { - g_free (priv->alarm_email_address); - priv->alarm_email_address = NULL; - } - if (priv->ldap_attribute) { - g_free (priv->ldap_attribute); - priv->ldap_attribute = NULL; - } - if (priv->capabilities) { - g_free (priv->capabilities); - priv->capabilities = NULL; - } - - g_hash_table_foreach (priv->timezones, free_timezone, NULL); - g_hash_table_destroy (priv->timezones); - priv->timezones = NULL; - - g_free (priv); - client->priv = NULL; - - if (G_OBJECT_CLASS (parent_class)->finalize) - (* G_OBJECT_CLASS (parent_class)->finalize) (object); -} - -/* Class initialization function for the calendar client */ -static void -cal_client_class_init (CalClientClass *klass) -{ - GObjectClass *object_class; - - object_class = (GObjectClass *) klass; - - parent_class = g_type_class_peek_parent (klass); - - cal_client_signals[CAL_OPENED] = - g_signal_new ("cal_opened", - G_TYPE_FROM_CLASS (klass), - G_SIGNAL_RUN_FIRST, - G_STRUCT_OFFSET (CalClientClass, cal_opened), - NULL, NULL, - g_cclosure_marshal_VOID__ENUM, - G_TYPE_NONE, 1, - CAL_CLIENT_OPEN_STATUS_ENUM_TYPE); - cal_client_signals[CAL_SET_MODE] = - g_signal_new ("cal_set_mode", - G_TYPE_FROM_CLASS (klass), - G_SIGNAL_RUN_FIRST, - G_STRUCT_OFFSET (CalClientClass, cal_set_mode), - NULL, NULL, - cal_util_marshal_VOID__ENUM_ENUM, - G_TYPE_NONE, 2, - CAL_CLIENT_SET_MODE_STATUS_ENUM_TYPE, - CAL_MODE_ENUM_TYPE); - cal_client_signals[BACKEND_ERROR] = - g_signal_new ("backend_error", - G_TYPE_FROM_CLASS (klass), - G_SIGNAL_RUN_FIRST, - G_STRUCT_OFFSET (CalClientClass, backend_error), - NULL, NULL, - g_cclosure_marshal_VOID__STRING, - G_TYPE_NONE, 1, - G_TYPE_STRING); - cal_client_signals[CATEGORIES_CHANGED] = - g_signal_new ("categories_changed", - G_TYPE_FROM_CLASS (klass), - G_SIGNAL_RUN_FIRST, - G_STRUCT_OFFSET (CalClientClass, categories_changed), - NULL, NULL, - g_cclosure_marshal_VOID__POINTER, - G_TYPE_NONE, 1, - G_TYPE_POINTER); - cal_client_signals[FORGET_PASSWORD] = - g_signal_new ("forget_password", - G_TYPE_FROM_CLASS (klass), - G_SIGNAL_RUN_FIRST, - G_STRUCT_OFFSET (CalClientClass, forget_password), - NULL, NULL, - g_cclosure_marshal_VOID__STRING, - G_TYPE_NONE, 1, - G_TYPE_STRING); - cal_client_signals[BACKEND_DIED] = - g_signal_new ("backend_died", - G_TYPE_FROM_CLASS (klass), - G_SIGNAL_RUN_FIRST, - G_STRUCT_OFFSET (CalClientClass, backend_died), - NULL, NULL, - g_cclosure_marshal_VOID__VOID, - G_TYPE_NONE, 0); - - klass->cal_opened = NULL; - klass->categories_changed = NULL; - klass->forget_password = NULL; - klass->backend_died = NULL; - - object_class->finalize = cal_client_finalize; -} - -/** - * cal_client_get_type: - * - * Registers the #CalClient class if necessary, and returns the type ID assigned - * to it. - * - * Return value: The type ID of the #CalClient class. - **/ -GType -cal_client_get_type (void) -{ - static GType cal_client_type = 0; - - if (!cal_client_type) { - static GTypeInfo info = { - sizeof (CalClientClass), - (GBaseInitFunc) NULL, - (GBaseFinalizeFunc) NULL, - (GClassInitFunc) cal_client_class_init, - NULL, NULL, - sizeof (CalClient), - 0, - (GInstanceInitFunc) cal_client_init - }; - cal_client_type = g_type_register_static (G_TYPE_OBJECT, "CalClient", &info, 0); - } - - return cal_client_type; -} - - -static gboolean -fetch_corba_cal (CalClient *client, const char *str_uri, CalObjType type) -{ - CalClientPrivate *priv; - GList *f; - CORBA_Environment ev; - - priv = client->priv; - g_return_val_if_fail (priv->load_state == CAL_CLIENT_LOAD_NOT_LOADED, FALSE); - g_assert (priv->uri == NULL); - - g_return_val_if_fail (str_uri != NULL, FALSE); - - if (!get_factories (str_uri, &priv->factories)) - return FALSE; - - priv->uri = g_strdup (str_uri); - priv->type = type; - - for (f = priv->factories; f; f = f->next) { - GNOME_Evolution_Calendar_Cal cal; - - CORBA_exception_init (&ev); - - cal = GNOME_Evolution_Calendar_CalFactory_getCal (f->data, priv->uri, priv->type, - BONOBO_OBJREF (priv->listener), &ev); - if (BONOBO_EX (&ev)) - continue; - - priv->cal = cal; - - return TRUE; - } - - return FALSE; -} - -/** - * cal_client_new: - * - * Creates a new calendar client. It should be initialized by calling - * cal_client_open(). - * - * Return value: A newly-created calendar client, or NULL if the client could - * not be constructed because it could not contact the calendar server. - **/ -CalClient * -cal_client_new (const char *uri, CalObjType type) -{ - CalClient *client; - - client = g_object_new (CAL_CLIENT_TYPE, NULL); - - if (!fetch_corba_cal (client, uri, type)) { - g_object_unref (client); - - return NULL; - } - - return client; -} - -/** - * cal_client_set_auth_func - * @client: A calendar client. - * @func: The authentication function - * @data: User data to be used when calling the authentication function - * - * Associates the given authentication function with a calendar client. This - * function will be called any time the calendar server needs a password - * from the client. So, calendar clients should provide such authentication - * function, which, when called, should act accordingly (by showing a dialog - * box, for example, to ask the user for the password). - * - * The authentication function must have the following form: - * char * auth_func (CalClient *client, - * const gchar *prompt, - * const gchar *key, - * gpointer user_data) - */ -void -cal_client_set_auth_func (CalClient *client, CalClientAuthFunc func, gpointer data) -{ - g_return_if_fail (client != NULL); - g_return_if_fail (IS_CAL_CLIENT (client)); - - client->priv->auth_func = func; - client->priv->auth_user_data = data; -} - -/** - * cal_client_open - * @client: A calendar client. - * @str_uri: URI of calendar to open. - * @only_if_exists: FALSE if the calendar should be opened even if there - * was no storage for it, i.e. to create a new calendar or load an existing - * one if it already exists. TRUE if it should only try to load calendars - * that already exist. - * - * Makes a calendar client initiate a request to open a calendar. The calendar - * client will emit the "cal_opened" signal when the response from the server is - * received. - * - * Return value: TRUE on success, FALSE on failure to issue the open request. - **/ -gboolean -cal_client_open (CalClient *client, gboolean only_if_exists, GError **error) -{ - CalClientPrivate *priv; - CORBA_Environment ev; - ECalendarStatus status; - ECalendarOp *our_op; - - g_return_val_if_fail (client != NULL, FALSE); - g_return_val_if_fail (IS_CAL_CLIENT (client), FALSE); - - priv = client->priv; - - e_mutex_lock (client->priv->mutex); - - if (client->priv->current_op != NULL) { - e_mutex_unlock (client->priv->mutex); - E_CALENDAR_CHECK_STATUS (E_CALENDAR_STATUS_BUSY, error); - } - - our_op = e_calendar_new_op (client); - - e_mutex_lock (our_op->mutex); - - e_mutex_unlock (client->priv->mutex); - - CORBA_exception_init (&ev); - - priv->load_state = CAL_CLIENT_LOAD_LOADING; - - GNOME_Evolution_Calendar_Cal_open (priv->cal, only_if_exists, &ev); - if (BONOBO_EX (&ev)) { - e_calendar_remove_op (client, our_op); - e_mutex_unlock (our_op->mutex); - e_calendar_free_op (our_op); - - CORBA_exception_free (&ev); - - g_warning (G_STRLOC ": Unable to contact backend"); - - g_signal_emit (G_OBJECT (client), cal_client_signals[CAL_OPENED], 0, - E_CALENDAR_STATUS_CORBA_EXCEPTION); - E_CALENDAR_CHECK_STATUS (E_CALENDAR_STATUS_CORBA_EXCEPTION, error); - } - - CORBA_exception_free (&ev); - - /* wait for something to happen (both cancellation and a - successful response will notity us via our cv */ - e_mutex_cond_wait (&our_op->cond, our_op->mutex); - - status = our_op->status; - - e_calendar_remove_op (client, our_op); - e_mutex_unlock (our_op->mutex); - e_calendar_free_op (our_op); - - if (status == E_CALENDAR_STATUS_OK) - priv->load_state = CAL_CLIENT_LOAD_LOADED; - else - priv->load_state = CAL_CLIENT_LOAD_NOT_LOADED; - - g_signal_emit (G_OBJECT (client), cal_client_signals[CAL_OPENED], 0, status); - E_CALENDAR_CHECK_STATUS (status, error); -} - -typedef struct { - CalClient *client; - - gboolean exists; -} CalClientAsyncData; - -static gboolean -open_async (gpointer data) -{ - CalClientAsyncData *ccad = data; - GError *error = NULL; - - cal_client_open (ccad->client, ccad->exists, &error); - - g_clear_error (&error); - - g_object_unref (ccad); - g_free (ccad); - - return FALSE; -} - -void -cal_client_open_async (CalClient *client, gboolean only_if_exists) -{ - CalClientAsyncData *ccad; - - g_return_if_fail (client != NULL); - g_return_if_fail (IS_CAL_CLIENT (client)); - - ccad = g_new0 (CalClientAsyncData, 1); - ccad->client = g_object_ref (client); - ccad->exists = only_if_exists; - - /* FIXME This should really spawn a new thread */ - g_idle_add (open_async, ccad); -} - -gboolean -cal_client_remove_calendar (CalClient *client, GError **error) -{ - CalClientPrivate *priv; - CORBA_Environment ev; - ECalendarStatus status; - ECalendarOp *our_op; - - g_return_val_if_fail (client != NULL, FALSE); - g_return_val_if_fail (IS_CAL_CLIENT (client), FALSE); - - priv = client->priv; - - e_mutex_lock (client->priv->mutex); - - if (client->priv->current_op != NULL) { - e_mutex_unlock (client->priv->mutex); - E_CALENDAR_CHECK_STATUS (E_CALENDAR_STATUS_BUSY, error); - } - - our_op = e_calendar_new_op (client); - - e_mutex_lock (our_op->mutex); - - e_mutex_unlock (client->priv->mutex); - - - CORBA_exception_init (&ev); - - GNOME_Evolution_Calendar_Cal_remove (priv->cal, &ev); - if (BONOBO_EX (&ev)) { - e_calendar_remove_op (client, our_op); - e_mutex_unlock (our_op->mutex); - e_calendar_free_op (our_op); - - CORBA_exception_free (&ev); - - g_warning (G_STRLOC ": Unable to contact backend"); - - E_CALENDAR_CHECK_STATUS (E_CALENDAR_STATUS_CORBA_EXCEPTION, error); - } - - CORBA_exception_free (&ev); - - /* wait for something to happen (both cancellation and a - successful response will notity us via our cv */ - e_mutex_cond_wait (&our_op->cond, our_op->mutex); - - status = our_op->status; - - e_calendar_remove_op (client, our_op); - e_mutex_unlock (our_op->mutex); - e_calendar_free_op (our_op); - - E_CALENDAR_CHECK_STATUS (status, error); -} - -#if 0 -/* Builds an URI list out of a CORBA string sequence */ -static GList * -build_uri_list (GNOME_Evolution_Calendar_StringSeq *seq) -{ - GList *uris = NULL; - int i; - - for (i = 0; i < seq->_length; i++) - uris = g_list_prepend (uris, g_strdup (seq->_buffer[i])); - - return uris; -} -#endif - -/** - * cal_client_uri_list: - * @client: A calendar client - * @type: type of uri's to get - * - * - * Return value: A list of URI's open on the wombat - **/ -GList * -cal_client_uri_list (CalClient *client, CalMode mode) -{ -#if 0 - CalClientPrivate *priv; - GNOME_Evolution_Calendar_StringSeq *uri_seq; - GList *uris = NULL; - CORBA_Environment ev; - GList *f; - - g_return_val_if_fail (client != NULL, FALSE); - g_return_val_if_fail (IS_CAL_CLIENT (client), FALSE); - - priv = client->priv; - - for (f = priv->factories; f; f = f->next) { - CORBA_exception_init (&ev); - uri_seq = GNOME_Evolution_Calendar_CalFactory_uriList (f->data, mode, &ev); - - if (BONOBO_EX (&ev)) { - g_message ("cal_client_uri_list(): request failed"); - - /* free memory and return */ - g_list_foreach (uris, (GFunc) g_free, NULL); - g_list_free (uris); - uris = NULL; - break; - } - else { - uris = g_list_concat (uris, build_uri_list (uri_seq)); - CORBA_free (uri_seq); - } - - CORBA_exception_free (&ev); - } - - return uris; -#endif - - return NULL; -} - - -/** - * cal_client_get_load_state: - * @client: A calendar client. - * - * Queries the state of loading of a calendar client. - * - * Return value: A #CalClientLoadState value indicating whether the client has - * not been loaded with cal_client_open_calendar() yet, whether it is being - * loaded, or whether it is already loaded. - **/ -CalClientLoadState -cal_client_get_load_state (CalClient *client) -{ - CalClientPrivate *priv; - - g_return_val_if_fail (client != NULL, CAL_CLIENT_LOAD_NOT_LOADED); - g_return_val_if_fail (IS_CAL_CLIENT (client), CAL_CLIENT_LOAD_NOT_LOADED); - - priv = client->priv; - return priv->load_state; -} - -/** - * cal_client_get_uri: - * @client: A calendar client. - * - * Queries the URI that is open in a calendar client. - * - * Return value: The URI of the calendar that is already loaded or is being - * loaded, or NULL if the client has not started a load request yet. - **/ -const char * -cal_client_get_uri (CalClient *client) -{ - CalClientPrivate *priv; - - g_return_val_if_fail (client != NULL, NULL); - g_return_val_if_fail (IS_CAL_CLIENT (client), NULL); - - priv = client->priv; - return priv->uri; -} - -/** - * cal_client_is_read_only: - * @client: A calendar client. - * - * Queries whether the calendar client can perform modifications - * on the calendar or not. Whether the backend is read only or not - * is specified, on exit, in the @read_only argument. - * - * Return value: TRUE if the call was successful, FALSE if there was an error. - */ -gboolean -cal_client_is_read_only (CalClient *client, gboolean *read_only, GError **error) -{ - CalClientPrivate *priv; - CORBA_Environment ev; - ECalendarStatus status; - ECalendarOp *our_op; - - g_return_val_if_fail (client != NULL, FALSE); - g_return_val_if_fail (IS_CAL_CLIENT (client), FALSE); - - priv = client->priv; - - e_mutex_lock (client->priv->mutex); - - if (client->priv->load_state != CAL_CLIENT_LOAD_LOADED) { - e_mutex_unlock (client->priv->mutex); - E_CALENDAR_CHECK_STATUS (E_CALENDAR_STATUS_URI_NOT_LOADED, error); - } - - if (client->priv->current_op != NULL) { - e_mutex_unlock (client->priv->mutex); - E_CALENDAR_CHECK_STATUS (E_CALENDAR_STATUS_BUSY, error); - } - - our_op = e_calendar_new_op (client); - - e_mutex_lock (our_op->mutex); - - e_mutex_unlock (client->priv->mutex); - - - CORBA_exception_init (&ev); - - GNOME_Evolution_Calendar_Cal_isReadOnly (priv->cal, &ev); - if (BONOBO_EX (&ev)) { - e_calendar_remove_op (client, our_op); - e_mutex_unlock (our_op->mutex); - e_calendar_free_op (our_op); - - CORBA_exception_free (&ev); - - g_warning (G_STRLOC ": Unable to contact backend"); - - E_CALENDAR_CHECK_STATUS (E_CALENDAR_STATUS_CORBA_EXCEPTION, error); - } - - CORBA_exception_free (&ev); - - /* wait for something to happen (both cancellation and a - successful response will notity us via our cv */ - e_mutex_cond_wait (&our_op->cond, our_op->mutex); - - status = our_op->status; - *read_only = our_op->bool; - - e_calendar_remove_op (client, our_op); - e_mutex_unlock (our_op->mutex); - e_calendar_free_op (our_op); - - return status; -} - -/** - * cal_client_get_cal_address: - * @client: A calendar client. - * - * Queries the calendar address associated with a calendar client. - * - * Return value: The calendar address associated with the calendar that - * is loaded or being loaded, or %NULL if the client has not started a - * load request yet or the calendar has no associated email address. - **/ -gboolean -cal_client_get_cal_address (CalClient *client, char **cal_address, GError **error) -{ - CalClientPrivate *priv; - CORBA_Environment ev; - ECalendarStatus status; - ECalendarOp *our_op; - - g_return_val_if_fail (client != NULL, FALSE); - g_return_val_if_fail (IS_CAL_CLIENT (client), FALSE); - - priv = client->priv; - - e_mutex_lock (client->priv->mutex); - - if (client->priv->load_state != CAL_CLIENT_LOAD_LOADED) { - e_mutex_unlock (client->priv->mutex); - E_CALENDAR_CHECK_STATUS (E_CALENDAR_STATUS_URI_NOT_LOADED, error); - } - - if (client->priv->current_op != NULL) { - e_mutex_unlock (client->priv->mutex); - E_CALENDAR_CHECK_STATUS (E_CALENDAR_STATUS_BUSY, error); - } - - our_op = e_calendar_new_op (client); - - e_mutex_lock (our_op->mutex); - - e_mutex_unlock (client->priv->mutex); - - - CORBA_exception_init (&ev); - - GNOME_Evolution_Calendar_Cal_getCalAddress (priv->cal, &ev); - if (BONOBO_EX (&ev)) { - e_calendar_remove_op (client, our_op); - e_mutex_unlock (our_op->mutex); - e_calendar_free_op (our_op); - - CORBA_exception_free (&ev); - - g_warning (G_STRLOC ": Unable to contact backend"); - - E_CALENDAR_CHECK_STATUS (E_CALENDAR_STATUS_CORBA_EXCEPTION, error); - } - - CORBA_exception_free (&ev); - - /* wait for something to happen (both cancellation and a - successful response will notity us via our cv */ - e_mutex_cond_wait (&our_op->cond, our_op->mutex); - - status = our_op->status; - *cal_address = our_op->string; - - e_calendar_remove_op (client, our_op); - e_mutex_unlock (our_op->mutex); - e_calendar_free_op (our_op); - - E_CALENDAR_CHECK_STATUS (status, error); -} - -gboolean -cal_client_get_alarm_email_address (CalClient *client, char **alarm_address, GError **error) -{ - CalClientPrivate *priv; - CORBA_Environment ev; - ECalendarStatus status; - ECalendarOp *our_op; - - g_return_val_if_fail (client != NULL, FALSE); - g_return_val_if_fail (IS_CAL_CLIENT (client), FALSE); - - priv = client->priv; - - e_mutex_lock (client->priv->mutex); - - if (client->priv->load_state != CAL_CLIENT_LOAD_LOADED) { - e_mutex_unlock (client->priv->mutex); - E_CALENDAR_CHECK_STATUS (E_CALENDAR_STATUS_URI_NOT_LOADED, error); - } - - if (client->priv->current_op != NULL) { - e_mutex_unlock (client->priv->mutex); - E_CALENDAR_CHECK_STATUS (E_CALENDAR_STATUS_BUSY, error); - } - - our_op = e_calendar_new_op (client); - - e_mutex_lock (our_op->mutex); - - e_mutex_unlock (client->priv->mutex); - - - CORBA_exception_init (&ev); - - GNOME_Evolution_Calendar_Cal_getAlarmEmailAddress (priv->cal, &ev); - if (BONOBO_EX (&ev)) { - e_calendar_remove_op (client, our_op); - e_mutex_unlock (our_op->mutex); - e_calendar_free_op (our_op); - - CORBA_exception_free (&ev); - - g_warning (G_STRLOC ": Unable to contact backend"); - - E_CALENDAR_CHECK_STATUS (E_CALENDAR_STATUS_CORBA_EXCEPTION, error); - } - - CORBA_exception_free (&ev); - - /* wait for something to happen (both cancellation and a - successful response will notity us via our cv */ - e_mutex_cond_wait (&our_op->cond, our_op->mutex); - - status = our_op->status; - *alarm_address = our_op->string; - - e_calendar_remove_op (client, our_op); - e_mutex_unlock (our_op->mutex); - e_calendar_free_op (our_op); - - E_CALENDAR_CHECK_STATUS (status, error); -} - -gboolean -cal_client_get_ldap_attribute (CalClient *client, char **ldap_attribute, GError **error) -{ - CalClientPrivate *priv; - CORBA_Environment ev; - ECalendarStatus status; - ECalendarOp *our_op; - - g_return_val_if_fail (client != NULL, FALSE); - g_return_val_if_fail (IS_CAL_CLIENT (client), FALSE); - - priv = client->priv; - - e_mutex_lock (client->priv->mutex); - - if (client->priv->load_state != CAL_CLIENT_LOAD_LOADED) { - e_mutex_unlock (client->priv->mutex); - E_CALENDAR_CHECK_STATUS (E_CALENDAR_STATUS_URI_NOT_LOADED, error); - } - - if (client->priv->current_op != NULL) { - e_mutex_unlock (client->priv->mutex); - E_CALENDAR_CHECK_STATUS (E_CALENDAR_STATUS_BUSY, error); - } - - our_op = e_calendar_new_op (client); - - e_mutex_lock (our_op->mutex); - - e_mutex_unlock (client->priv->mutex); - - - CORBA_exception_init (&ev); - - GNOME_Evolution_Calendar_Cal_getLdapAttribute (priv->cal, &ev); - if (BONOBO_EX (&ev)) { - e_calendar_remove_op (client, our_op); - e_mutex_unlock (our_op->mutex); - e_calendar_free_op (our_op); - - CORBA_exception_free (&ev); - - g_warning (G_STRLOC ": Unable to contact backend"); - - E_CALENDAR_CHECK_STATUS (E_CALENDAR_STATUS_CORBA_EXCEPTION, error); - } - - CORBA_exception_free (&ev); - - /* wait for something to happen (both cancellation and a - successful response will notity us via our cv */ - e_mutex_cond_wait (&our_op->cond, our_op->mutex); - - status = our_op->status; - *ldap_attribute = our_op->string; - - e_calendar_remove_op (client, our_op); - e_mutex_unlock (our_op->mutex); - e_calendar_free_op (our_op); - - E_CALENDAR_CHECK_STATUS (status, error); -} - -static gboolean -load_static_capabilities (CalClient *client, GError **error) -{ - CalClientPrivate *priv; - CORBA_Environment ev; - ECalendarStatus status; - ECalendarOp *our_op; - char *cap; - - priv = client->priv; - - if (priv->capabilities) - E_CALENDAR_CHECK_STATUS (E_CALENDAR_STATUS_OK, error); - - e_mutex_lock (client->priv->mutex); - - if (client->priv->load_state != CAL_CLIENT_LOAD_LOADED) { - e_mutex_unlock (client->priv->mutex); - E_CALENDAR_CHECK_STATUS (E_CALENDAR_STATUS_URI_NOT_LOADED, error); - } - - if (client->priv->current_op != NULL) { - e_mutex_unlock (client->priv->mutex); - E_CALENDAR_CHECK_STATUS (E_CALENDAR_STATUS_BUSY, error); - } - - our_op = e_calendar_new_op (client); - - e_mutex_lock (our_op->mutex); - - e_mutex_unlock (client->priv->mutex); - - - CORBA_exception_init (&ev); - - GNOME_Evolution_Calendar_Cal_getStaticCapabilities (priv->cal, &ev); - if (BONOBO_EX (&ev)) { - e_calendar_remove_op (client, our_op); - e_mutex_unlock (our_op->mutex); - e_calendar_free_op (our_op); - - CORBA_exception_free (&ev); - - g_warning (G_STRLOC ": Unable to contact backend"); - - E_CALENDAR_CHECK_STATUS (E_CALENDAR_STATUS_CORBA_EXCEPTION, error); - } - - CORBA_exception_free (&ev); - - /* wait for something to happen (both cancellation and a - successful response will notity us via our cv */ - e_mutex_cond_wait (&our_op->cond, our_op->mutex); - - status = our_op->status; - cap = our_op->string; - - e_calendar_remove_op (client, our_op); - e_mutex_unlock (our_op->mutex); - e_calendar_free_op (our_op); - - E_CALENDAR_CHECK_STATUS (status, error); -} - -static gboolean -check_capability (CalClient *client, const char *cap) -{ - CalClientPrivate *priv; - - priv = client->priv; - - /* FIXME Check result */ - load_static_capabilities (client, NULL); - if (priv->capabilities && strstr (priv->capabilities, cap)) - return TRUE; - - return FALSE; -} - -gboolean -cal_client_get_one_alarm_only (CalClient *client) -{ - g_return_val_if_fail (client != NULL, FALSE); - g_return_val_if_fail (IS_CAL_CLIENT (client), FALSE); - - return check_capability (client, CAL_STATIC_CAPABILITY_ONE_ALARM_ONLY); -} - -gboolean -cal_client_get_organizer_must_attend (CalClient *client) -{ - g_return_val_if_fail (client != NULL, FALSE); - g_return_val_if_fail (IS_CAL_CLIENT (client), FALSE); - - return check_capability (client, CAL_STATIC_CAPABILITY_ORGANIZER_MUST_ATTEND); -} - -gboolean -cal_client_get_static_capability (CalClient *client, const char *cap) -{ - g_return_val_if_fail (client != NULL, FALSE); - g_return_val_if_fail (IS_CAL_CLIENT (client), FALSE); - - return check_capability (client, cap); -} - -gboolean -cal_client_get_save_schedules (CalClient *client) -{ - g_return_val_if_fail (client != NULL, FALSE); - g_return_val_if_fail (IS_CAL_CLIENT (client), FALSE); - - return check_capability (client, CAL_STATIC_CAPABILITY_SAVE_SCHEDULES); -} - -gboolean -cal_client_set_mode (CalClient *client, CalMode mode) -{ - CalClientPrivate *priv; - gboolean retval = TRUE; - CORBA_Environment ev; - - g_return_val_if_fail (client != NULL, -1); - g_return_val_if_fail (IS_CAL_CLIENT (client), -1); - - priv = client->priv; - g_return_val_if_fail (priv->load_state == CAL_CLIENT_LOAD_LOADED, -1); - - CORBA_exception_init (&ev); - GNOME_Evolution_Calendar_Cal_setMode (priv->cal, mode, &ev); - - if (BONOBO_EX (&ev)) - retval = FALSE; - - CORBA_exception_free (&ev); - - return retval; -} - - -/* This is used in the callback which fetches all the timezones needed for an - object. */ -typedef struct _CalClientGetTimezonesData CalClientGetTimezonesData; -struct _CalClientGetTimezonesData { - CalClient *client; - - /* This starts out at E_CALENDAR_STATUS_OK. If an error occurs this - contains the last error. */ - ECalendarStatus status; -}; - -gboolean -cal_client_get_default_object (CalClient *client, icalcomponent **icalcomp, GError **error) -{ - CalClientPrivate *priv; - CORBA_Environment ev; - ECalendarStatus status; - ECalendarOp *our_op; - - g_return_val_if_fail (client != NULL, FALSE); - g_return_val_if_fail (IS_CAL_CLIENT (client), FALSE); - - priv = client->priv; - - e_mutex_lock (client->priv->mutex); - - if (client->priv->load_state != CAL_CLIENT_LOAD_LOADED) { - e_mutex_unlock (client->priv->mutex); - E_CALENDAR_CHECK_STATUS (E_CALENDAR_STATUS_URI_NOT_LOADED, error); - } - - if (client->priv->current_op != NULL) { - e_mutex_unlock (client->priv->mutex); - E_CALENDAR_CHECK_STATUS (E_CALENDAR_STATUS_BUSY, error); - } - - our_op = e_calendar_new_op (client); - - e_mutex_lock (our_op->mutex); - - e_mutex_unlock (client->priv->mutex); - - CORBA_exception_init (&ev); - - GNOME_Evolution_Calendar_Cal_getDefaultObject (priv->cal, &ev); - if (BONOBO_EX (&ev)) { - e_calendar_remove_op (client, our_op); - e_mutex_unlock (our_op->mutex); - e_calendar_free_op (our_op); - - CORBA_exception_free (&ev); - - g_warning (G_STRLOC ": Unable to contact backend"); - - E_CALENDAR_CHECK_STATUS (E_CALENDAR_STATUS_CORBA_EXCEPTION, error); - } - - CORBA_exception_free (&ev); - - /* wait for something to happen (both cancellation and a - successful response will notity us via our cv */ - e_mutex_cond_wait (&our_op->cond, our_op->mutex); - - status = our_op->status; - *icalcomp = icalparser_parse_string (our_op->string); - g_free (our_op->string); - - if (!*icalcomp) { - status = E_CALENDAR_STATUS_INVALID_OBJECT; - } else { - CalClientGetTimezonesData cb_data; - - /* Now make sure we have all timezones needed for this object. - We do this to try to avoid any problems caused by getting a timezone - in the middle of other code. Any calls to ORBit result in a - recursive call of the GTK+ main loop, which can cause problems for - code that doesn't expect it. Currently GnomeCanvas has problems if - we try to get a timezone in the middle of a redraw, and there is a - resize pending, which leads to an assert failure and an abort. */ - cb_data.client = client; - cb_data.status = E_CALENDAR_STATUS_OK; - icalcomponent_foreach_tzid (*icalcomp, - cal_client_get_object_timezones_cb, - &cb_data); - - status = cb_data.status; - } - - e_calendar_remove_op (client, our_op); - e_mutex_unlock (our_op->mutex); - e_calendar_free_op (our_op); - - E_CALENDAR_CHECK_STATUS (status, error); -} - -/** - * cal_client_get_object: - * @client: A calendar client. - * @uid: Unique identifier for a calendar component. - * @icalcomp: Return value for the calendar component object. - * - * Queries a calendar for a calendar component object based on its unique - * identifier. - * - * Return value: Result code based on the status of the operation. - **/ -gboolean -cal_client_get_object (CalClient *client, const char *uid, const char *rid, icalcomponent **icalcomp, GError **error) -{ - - CalClientPrivate *priv; - CORBA_Environment ev; - ECalendarStatus status; - ECalendarOp *our_op; - - g_return_val_if_fail (client != NULL, FALSE); - g_return_val_if_fail (IS_CAL_CLIENT (client), FALSE); - - priv = client->priv; - - e_mutex_lock (client->priv->mutex); - - if (client->priv->load_state != CAL_CLIENT_LOAD_LOADED) { - e_mutex_unlock (client->priv->mutex); - E_CALENDAR_CHECK_STATUS (E_CALENDAR_STATUS_URI_NOT_LOADED, error); - } - - if (client->priv->current_op != NULL) { - e_mutex_unlock (client->priv->mutex); - E_CALENDAR_CHECK_STATUS (E_CALENDAR_STATUS_BUSY, error); - } - - our_op = e_calendar_new_op (client); - - e_mutex_lock (our_op->mutex); - - e_mutex_unlock (client->priv->mutex); - - CORBA_exception_init (&ev); - - GNOME_Evolution_Calendar_Cal_getObject (priv->cal, uid, rid ? rid : "", &ev); - if (BONOBO_EX (&ev)) { - e_calendar_remove_op (client, our_op); - e_mutex_unlock (our_op->mutex); - e_calendar_free_op (our_op); - - CORBA_exception_free (&ev); - - g_warning (G_STRLOC ": Unable to contact backend"); - - E_CALENDAR_CHECK_STATUS (E_CALENDAR_STATUS_CORBA_EXCEPTION, error); - } - - CORBA_exception_free (&ev); - - /* wait for something to happen (both cancellation and a - successful response will notity us via our cv */ - e_mutex_cond_wait (&our_op->cond, our_op->mutex); - - status = our_op->status; - *icalcomp = icalparser_parse_string (our_op->string); - g_free (our_op->string); - - if (status == E_CALENDAR_STATUS_OK && !*icalcomp) { - status = E_CALENDAR_STATUS_INVALID_OBJECT; - } else if (status == E_CALENDAR_STATUS_OK){ - CalClientGetTimezonesData cb_data; - - /* Now make sure we have all timezones needed for this object. - We do this to try to avoid any problems caused by getting a timezone - in the middle of other code. Any calls to ORBit result in a - recursive call of the GTK+ main loop, which can cause problems for - code that doesn't expect it. Currently GnomeCanvas has problems if - we try to get a timezone in the middle of a redraw, and there is a - resize pending, which leads to an assert failure and an abort. */ - cb_data.client = client; - cb_data.status = E_CALENDAR_STATUS_OK; - icalcomponent_foreach_tzid (*icalcomp, - cal_client_get_object_timezones_cb, - &cb_data); - - status = cb_data.status; - } - - e_calendar_remove_op (client, our_op); - e_mutex_unlock (our_op->mutex); - e_calendar_free_op (our_op); - - E_CALENDAR_CHECK_STATUS (status, error); -} - - -static void -cal_client_get_object_timezones_cb (icalparameter *param, - void *data) -{ - CalClientGetTimezonesData *cb_data = data; - const char *tzid; - icaltimezone *zone; - GError *error = NULL; - - tzid = icalparameter_get_tzid (param); - if (!tzid) { - cb_data->status = E_CALENDAR_STATUS_INVALID_OBJECT; - return; - } - - if (!cal_client_get_timezone (cb_data->client, tzid, &zone, &error)) - cb_data->status = error->code; - - g_clear_error (&error); -} - -/* Resolves TZIDs for the recurrence generator. */ -icaltimezone* -cal_client_resolve_tzid_cb (const char *tzid, gpointer data) -{ - CalClient *client; - icaltimezone *zone = NULL; - - g_return_val_if_fail (data != NULL, NULL); - g_return_val_if_fail (IS_CAL_CLIENT (data), NULL); - - client = CAL_CLIENT (data); - - /* FIXME: Handle errors. */ - cal_client_get_timezone (client, tzid, &zone, NULL); - - return zone; -} - -gboolean -cal_client_get_changes (CalClient *client, const char *change_id, GList **changes, GError **error) -{ - CORBA_Environment ev; - ECalendarOp *our_op; - ECalendarStatus status; - - g_return_val_if_fail (client != NULL, E_CALENDAR_STATUS_INVALID_ARG); - g_return_val_if_fail (IS_CAL_CLIENT (client), E_CALENDAR_STATUS_INVALID_ARG); - g_return_val_if_fail (change_id != NULL, E_CALENDAR_STATUS_INVALID_ARG); - - e_mutex_lock (client->priv->mutex); - - if (client->priv->load_state != CAL_CLIENT_LOAD_LOADED) { - e_mutex_unlock (client->priv->mutex); - E_CALENDAR_CHECK_STATUS (E_CALENDAR_STATUS_URI_NOT_LOADED, error); - } - - if (client->priv->current_op != NULL) { - e_mutex_unlock (client->priv->mutex); - E_CALENDAR_CHECK_STATUS (E_CALENDAR_STATUS_BUSY, error); - } - - our_op = e_calendar_new_op (client); - - e_mutex_lock (our_op->mutex); - - e_mutex_unlock (client->priv->mutex); - - CORBA_exception_init (&ev); - - GNOME_Evolution_Calendar_Cal_getChanges (client->priv->cal, change_id, &ev); - - if (BONOBO_EX (&ev)) { - e_calendar_remove_op (client, our_op); - e_mutex_unlock (our_op->mutex); - e_calendar_free_op (our_op); - - CORBA_exception_free (&ev); - - g_warning (G_STRLOC ": Unable to contact backend"); - - E_CALENDAR_CHECK_STATUS (E_CALENDAR_STATUS_CORBA_EXCEPTION, error); - } - - CORBA_exception_free (&ev); - - /* wait for something to happen (both cancellation and a - successful response will notity us via our cv */ - e_mutex_cond_wait (&our_op->cond, our_op->mutex); - - status = our_op->status; - *changes = our_op->list; - - e_calendar_remove_op (client, our_op); - e_mutex_unlock (our_op->mutex); - e_calendar_free_op (our_op); - - E_CALENDAR_CHECK_STATUS (status, error); -} - - -/** - * cal_client_get_object_list: - * @client: - * @query: - * - * - * - * Return value: - **/ -gboolean -cal_client_get_object_list (CalClient *client, const char *query, GList **objects, GError **error) -{ - CORBA_Environment ev; - ECalendarOp *our_op; - ECalendarStatus status; - - g_return_val_if_fail (client != NULL, E_CALENDAR_STATUS_INVALID_ARG); - g_return_val_if_fail (IS_CAL_CLIENT (client), E_CALENDAR_STATUS_INVALID_ARG); - g_return_val_if_fail (query != NULL, E_CALENDAR_STATUS_INVALID_ARG); - - e_mutex_lock (client->priv->mutex); - - if (client->priv->load_state != CAL_CLIENT_LOAD_LOADED) { - e_mutex_unlock (client->priv->mutex); - E_CALENDAR_CHECK_STATUS (E_CALENDAR_STATUS_URI_NOT_LOADED, error); - } - - if (client->priv->current_op != NULL) { - e_mutex_unlock (client->priv->mutex); - E_CALENDAR_CHECK_STATUS (E_CALENDAR_STATUS_BUSY, error); - } - - our_op = e_calendar_new_op (client); - - e_mutex_lock (our_op->mutex); - - e_mutex_unlock (client->priv->mutex); - - CORBA_exception_init (&ev); - - GNOME_Evolution_Calendar_Cal_getObjectList (client->priv->cal, query, &ev); - - if (BONOBO_EX (&ev)) { - e_calendar_remove_op (client, our_op); - e_mutex_unlock (our_op->mutex); - e_calendar_free_op (our_op); - - CORBA_exception_free (&ev); - - g_warning (G_STRLOC ": Unable to contact backend"); - - E_CALENDAR_CHECK_STATUS (E_CALENDAR_STATUS_CORBA_EXCEPTION, error); - } - - CORBA_exception_free (&ev); - - /* wait for something to happen (both cancellation and a - successful response will notity us via our cv */ - e_mutex_cond_wait (&our_op->cond, our_op->mutex); - - status = our_op->status; - *objects = our_op->list; - - e_calendar_remove_op (client, our_op); - e_mutex_unlock (our_op->mutex); - e_calendar_free_op (our_op); - - E_CALENDAR_CHECK_STATUS (status, error); -} - -gboolean -cal_client_get_object_list_as_comp (CalClient *client, const char *query, GList **objects, GError **error) -{ - GList *ical_objects = NULL; - GList *l; - - g_return_val_if_fail (client != NULL, E_CALENDAR_STATUS_INVALID_ARG); - g_return_val_if_fail (IS_CAL_CLIENT (client), E_CALENDAR_STATUS_INVALID_ARG); - g_return_val_if_fail (query != NULL, E_CALENDAR_STATUS_INVALID_ARG); - g_return_val_if_fail (objects != NULL, E_CALENDAR_STATUS_INVALID_ARG); - - if (!cal_client_get_object_list (client, query, &ical_objects, error)) - return FALSE; - - *objects = NULL; - for (l = ical_objects; l; l = l->next) { - CalComponent *comp; - - comp = cal_component_new (); - cal_component_set_icalcomponent (comp, l->data); - *objects = g_list_prepend (*objects, comp); - } - - g_list_free (ical_objects); - - return TRUE; -} - -void -cal_client_free_object_list (GList *objects) -{ - GList *l; - - for (l = objects; l; l = l->next) - icalcomponent_free (l->data); - - g_list_free (objects); -} - -/** - * cal_client_get_free_busy - * @client:: A calendar client. - * @users: List of users to retrieve free/busy information for. - * @start: Start time for query. - * @end: End time for query. - * - * Gets free/busy information from the calendar server. - * - * Returns: a GList of VFREEBUSY CalComponents - */ -gboolean -cal_client_get_free_busy (CalClient *client, GList *users, time_t start, time_t end, - GList **freebusy, GError **error) -{ - CORBA_Environment ev; - ECalendarOp *our_op; - ECalendarStatus status; - GNOME_Evolution_Calendar_UserList corba_users; - GList *l; - int i, len; - - g_return_val_if_fail (client != NULL, E_CALENDAR_STATUS_INVALID_ARG); - g_return_val_if_fail (IS_CAL_CLIENT (client), E_CALENDAR_STATUS_INVALID_ARG); - - e_mutex_lock (client->priv->mutex); - - if (client->priv->load_state != CAL_CLIENT_LOAD_LOADED) { - e_mutex_unlock (client->priv->mutex); - E_CALENDAR_CHECK_STATUS (E_CALENDAR_STATUS_URI_NOT_LOADED, error); - } - - if (client->priv->current_op != NULL) { - e_mutex_unlock (client->priv->mutex); - E_CALENDAR_CHECK_STATUS (E_CALENDAR_STATUS_BUSY, error); - } - - our_op = e_calendar_new_op (client); - - e_mutex_lock (our_op->mutex); - - e_mutex_unlock (client->priv->mutex); - - /* create the CORBA user list to be passed to the backend */ - len = g_list_length (users); - - corba_users._length = len; - corba_users._buffer = CORBA_sequence_GNOME_Evolution_Calendar_User_allocbuf (len); - - for (l = users, i = 0; l; l = l->next, i++) - corba_users._buffer[i] = CORBA_string_dup (l->data); - - CORBA_exception_init (&ev); - - GNOME_Evolution_Calendar_Cal_getFreeBusy (client->priv->cal, &corba_users, start, end, &ev); - - CORBA_free (corba_users._buffer); - - if (BONOBO_EX (&ev)) { - e_calendar_remove_op (client, our_op); - e_mutex_unlock (our_op->mutex); - e_calendar_free_op (our_op); - - CORBA_exception_free (&ev); - - g_warning (G_STRLOC ": Unable to contact backend"); - - E_CALENDAR_CHECK_STATUS (E_CALENDAR_STATUS_CORBA_EXCEPTION, error); - } - - CORBA_exception_free (&ev); - - /* wait for something to happen (both cancellation and a - successful response will notity us via our cv */ - e_mutex_cond_wait (&our_op->cond, our_op->mutex); - - status = our_op->status; - - *freebusy = NULL; - for (l = our_op->list; l; l = l->next) { - CalComponent *comp; - - icalcomponent *icalcomp; - icalcomponent_kind kind; - - icalcomp = icalparser_parse_string (l->data); - if (!icalcomp) - continue; - - kind = icalcomponent_isa (icalcomp); - if (kind == ICAL_VFREEBUSY_COMPONENT) { - comp = cal_component_new (); - if (!cal_component_set_icalcomponent (comp, icalcomp)) { - icalcomponent_free (icalcomp); - g_object_unref (G_OBJECT (comp)); - continue; - } - - *freebusy = g_list_append (*freebusy, comp); - } - else - icalcomponent_free (icalcomp); - } - - e_calendar_remove_op (client, our_op); - e_mutex_unlock (our_op->mutex); - e_calendar_free_op (our_op); - - E_CALENDAR_CHECK_STATUS (status, error); -} - -struct comp_instance { - CalComponent *comp; - time_t start; - time_t end; -}; - -/* Called from cal_recur_generate_instances(); adds an instance to the list */ -static gboolean -add_instance (CalComponent *comp, time_t start, time_t end, gpointer data) -{ - GList **list; - struct comp_instance *ci; - - list = data; - - ci = g_new (struct comp_instance, 1); - - ci->comp = comp; - g_object_ref (G_OBJECT (ci->comp)); - - ci->start = start; - ci->end = end; - - *list = g_list_prepend (*list, ci); - - return TRUE; -} - -/* Used from g_list_sort(); compares two struct comp_instance structures */ -static gint -compare_comp_instance (gconstpointer a, gconstpointer b) -{ - const struct comp_instance *cia, *cib; - time_t diff; - - cia = a; - cib = b; - - diff = cia->start - cib->start; - return (diff < 0) ? -1 : (diff > 0) ? 1 : 0; -} - -/** - * cal_client_generate_instances: - * @client: A calendar client. - * @type: Bitmask with types of objects to return. - * @start: Start time for query. - * @end: End time for query. - * @cb: Callback for each generated instance. - * @cb_data: Closure data for the callback. - * - * Does a combination of cal_client_get_object_list () and - * cal_recur_generate_instances(). - * - * The callback function should do a g_object_ref() of the calendar component - * it gets passed if it intends to keep it around. - **/ -void -cal_client_generate_instances (CalClient *client, CalObjType type, - time_t start, time_t end, - CalRecurInstanceFn cb, gpointer cb_data) -{ - CalClientPrivate *priv; - GList *objects; - GList *instances; - GList *l; - char *query; - - g_return_if_fail (client != NULL); - g_return_if_fail (IS_CAL_CLIENT (client)); - - priv = client->priv; - g_return_if_fail (priv->load_state == CAL_CLIENT_LOAD_LOADED); - - g_return_if_fail (start != -1 && end != -1); - g_return_if_fail (start <= end); - g_return_if_fail (cb != NULL); - - /* Generate objects */ - query = g_strdup_printf ("(occur-in-time-range? (%lu) (%lu))", start, end); - if (!cal_client_get_object_list (client, query, &objects, NULL)) { - g_free (query); - return; - } - g_free (query); - - instances = NULL; - - for (l = objects; l; l = l->next) { - CalComponent *comp; - - comp = l->data; - cal_recur_generate_instances (comp, start, end, add_instance, &instances, - cal_client_resolve_tzid_cb, client, - priv->default_zone); - g_object_unref (G_OBJECT (comp)); - } - - g_list_free (objects); - - /* Generate instances and spew them out */ - - instances = g_list_sort (instances, compare_comp_instance); - - for (l = instances; l; l = l->next) { - struct comp_instance *ci; - gboolean result; - - ci = l->data; - - result = (* cb) (ci->comp, ci->start, ci->end, cb_data); - - if (!result) - break; - } - - /* Clean up */ - - for (l = instances; l; l = l->next) { - struct comp_instance *ci; - - ci = l->data; - g_object_unref (G_OBJECT (ci->comp)); - g_free (ci); - } - - g_list_free (instances); -} - -/* Builds a list of CalComponentAlarms structures */ -static GSList * -build_component_alarms_list (CalClient *client, GList *object_list, time_t start, time_t end) -{ - GSList *comp_alarms; - GList *l; - - comp_alarms = NULL; - - for (l = object_list; l != NULL; l = l->next) { - CalComponent *comp; - CalComponentAlarms *alarms; - icalcomponent *icalcomp; - CalAlarmAction omit[] = {-1}; - - icalcomp = icalparser_parse_string (l->data); - if (!icalcomp) - continue; - - comp = cal_component_new (); - if (!cal_component_set_icalcomponent (comp, icalcomp)) { - icalcomponent_free (icalcomp); - g_object_unref (G_OBJECT (comp)); - continue; - } - - alarms = cal_util_generate_alarms_for_comp (comp, start, end, omit, cal_client_resolve_tzid_cb, - icalcomp, client->priv->default_zone); - if (alarms) - comp_alarms = g_slist_prepend (comp_alarms, alarms); - } - - return comp_alarms; -} - -/** - * cal_client_get_alarms_in_range: - * @client: A calendar client. - * @start: Start time for query. - * @end: End time for query. - * - * Queries a calendar for the alarms that trigger in the specified range of - * time. - * - * Return value: A list of #CalComponentAlarms structures. This should be freed - * using the cal_client_free_alarms() function, or by freeing each element - * separately with cal_component_alarms_free() and then freeing the list with - * g_slist_free(). - **/ -GSList * -cal_client_get_alarms_in_range (CalClient *client, time_t start, time_t end) -{ - CalClientPrivate *priv; - GSList *alarms; - char *sexp; - GList *object_list = NULL; - - g_return_val_if_fail (client != NULL, NULL); - g_return_val_if_fail (IS_CAL_CLIENT (client), NULL); - - priv = client->priv; - g_return_val_if_fail (priv->load_state == CAL_CLIENT_LOAD_LOADED, NULL); - - g_return_val_if_fail (start != -1 && end != -1, NULL); - g_return_val_if_fail (start <= end, NULL); - - /* build the query string */ - sexp = g_strdup ("(and (has-alarms? #t))"); - - /* execute the query on the server */ - if (!cal_client_get_object_list (client, sexp, &object_list, NULL)) { - g_free (sexp); - return NULL; - } - - alarms = build_component_alarms_list (client, object_list, start, end); - - g_list_foreach (object_list, (GFunc) g_free, NULL); - g_list_free (object_list); - g_free (sexp); - - return alarms; -} - -/** - * cal_client_free_alarms: - * @comp_alarms: A list of #CalComponentAlarms structures. - * - * Frees a list of #CalComponentAlarms structures as returned by - * cal_client_get_alarms_in_range(). - **/ -void -cal_client_free_alarms (GSList *comp_alarms) -{ - GSList *l; - - for (l = comp_alarms; l; l = l->next) { - CalComponentAlarms *alarms; - - alarms = l->data; - g_assert (alarms != NULL); - - cal_component_alarms_free (alarms); - } - - g_slist_free (comp_alarms); -} - -/** - * cal_client_get_alarms_for_object: - * @client: A calendar client. - * @uid: Unique identifier for a calendar component. - * @start: Start time for query. - * @end: End time for query. - * @alarms: Return value for the component's alarm instances. Will return NULL - * if no instances occur within the specified time range. This should be freed - * using the cal_component_alarms_free() function. - * - * Queries a calendar for the alarms of a particular object that trigger in the - * specified range of time. - * - * Return value: TRUE on success, FALSE if the object was not found. - **/ -gboolean -cal_client_get_alarms_for_object (CalClient *client, const char *uid, - time_t start, time_t end, - CalComponentAlarms **alarms) -{ - CalClientPrivate *priv; - icalcomponent *icalcomp; - CalComponent *comp; - CalAlarmAction omit[] = {-1}; - - g_return_val_if_fail (client != NULL, FALSE); - g_return_val_if_fail (IS_CAL_CLIENT (client), FALSE); - - priv = client->priv; - g_return_val_if_fail (priv->load_state == CAL_CLIENT_LOAD_LOADED, FALSE); - - g_return_val_if_fail (uid != NULL, FALSE); - g_return_val_if_fail (start != -1 && end != -1, FALSE); - g_return_val_if_fail (start <= end, FALSE); - g_return_val_if_fail (alarms != NULL, FALSE); - - *alarms = NULL; - - if (!cal_client_get_object (client, uid, NULL, &icalcomp, NULL)) - return FALSE; - if (!icalcomp) - return FALSE; - - comp = cal_component_new (); - if (!cal_component_set_icalcomponent (comp, icalcomp)) { - icalcomponent_free (icalcomp); - g_object_unref (G_OBJECT (comp)); - return FALSE; - } - - *alarms = cal_util_generate_alarms_for_comp (comp, start, end, omit, cal_client_resolve_tzid_cb, - icalcomp, priv->default_zone); - - return TRUE; -} - -/** - * cal_client_discard_alarm - * @client: A calendar client. - * @comp: The component to discard the alarm from. - * @auid: Unique identifier of the alarm to be discarded. - * - * Tells the calendar backend to get rid of the alarm identified by the - * @auid argument in @comp. Some backends might remove the alarm or - * update internal information about the alarm be discarded, or, like - * the file backend does, ignore the operation. - * - * Return value: a #CalClientResult value indicating the result of the - * operation. - */ -gboolean -cal_client_discard_alarm (CalClient *client, CalComponent *comp, const char *auid, GError **error) -{ - CalClientPrivate *priv; - CORBA_Environment ev; - ECalendarStatus status; - ECalendarOp *our_op; - const char *uid; - - g_return_val_if_fail (client != NULL, FALSE); - g_return_val_if_fail (IS_CAL_CLIENT (client), FALSE); - - priv = client->priv; - - e_mutex_lock (client->priv->mutex); - - if (client->priv->load_state != CAL_CLIENT_LOAD_LOADED) { - e_mutex_unlock (client->priv->mutex); - E_CALENDAR_CHECK_STATUS (E_CALENDAR_STATUS_URI_NOT_LOADED, error); - } - - if (client->priv->current_op != NULL) { - e_mutex_unlock (client->priv->mutex); - E_CALENDAR_CHECK_STATUS (E_CALENDAR_STATUS_BUSY, error); - } - - our_op = e_calendar_new_op (client); - - e_mutex_lock (our_op->mutex); - - e_mutex_unlock (client->priv->mutex); - - cal_component_get_uid (comp, &uid); - - CORBA_exception_init (&ev); - - GNOME_Evolution_Calendar_Cal_discardAlarm (priv->cal, uid, auid, &ev); - if (BONOBO_EX (&ev)) { - e_calendar_remove_op (client, our_op); - e_mutex_unlock (our_op->mutex); - e_calendar_free_op (our_op); - - CORBA_exception_free (&ev); - - g_warning (G_STRLOC ": Unable to contact backend"); - - E_CALENDAR_CHECK_STATUS (E_CALENDAR_STATUS_CORBA_EXCEPTION, error); - } - - CORBA_exception_free (&ev); - - /* wait for something to happen (both cancellation and a - successful response will notity us via our cv */ - e_mutex_cond_wait (&our_op->cond, our_op->mutex); - - status = our_op->status; - - e_calendar_remove_op (client, our_op); - e_mutex_unlock (our_op->mutex); - e_calendar_free_op (our_op); - - E_CALENDAR_CHECK_STATUS (status, error); -} - -typedef struct _ForeachTZIDCallbackData ForeachTZIDCallbackData; -struct _ForeachTZIDCallbackData { - CalClient *client; - GHashTable *timezone_hash; - gboolean include_all_timezones; - gboolean success; -}; - -/* This adds the VTIMEZONE given by the TZID parameter to the GHashTable in - data. */ -static void -foreach_tzid_callback (icalparameter *param, void *cbdata) -{ - ForeachTZIDCallbackData *data = cbdata; - CalClientPrivate *priv; - const char *tzid; - icaltimezone *zone; - icalcomponent *vtimezone_comp; - char *vtimezone_as_string; - - priv = data->client->priv; - - /* Get the TZID string from the parameter. */ - tzid = icalparameter_get_tzid (param); - if (!tzid) - return; - - /* Check if we've already added it to the GHashTable. */ - if (g_hash_table_lookup (data->timezone_hash, tzid)) - return; - - if (data->include_all_timezones) { - if (!cal_client_get_timezone (data->client, tzid, &zone, NULL)) { - data->success = FALSE; - return; - } - } else { - /* Check if it is in our cache. If it is, it must already be - on the server so return. */ - if (g_hash_table_lookup (priv->timezones, tzid)) - return; - - /* Check if it is a builtin timezone. If it isn't, return. */ - zone = icaltimezone_get_builtin_timezone_from_tzid (tzid); - if (!zone) - return; - } - - /* Convert it to a string and add it to the hash. */ - vtimezone_comp = icaltimezone_get_component (zone); - if (!vtimezone_comp) - return; - - vtimezone_as_string = icalcomponent_as_ical_string (vtimezone_comp); - - g_hash_table_insert (data->timezone_hash, (char*) tzid, - g_strdup (vtimezone_as_string)); -} - -/* This appends the value string to the GString given in data. */ -static void -append_timezone_string (gpointer key, gpointer value, gpointer data) -{ - GString *vcal_string = data; - - g_string_append (vcal_string, value); - g_free (value); -} - - -/* This simply frees the hash values. */ -static void -free_timezone_string (gpointer key, gpointer value, gpointer data) -{ - g_free (value); -} - - -/* This converts the VEVENT/VTODO to a string. If include_all_timezones is - TRUE, it includes all the VTIMEZONE components needed for the VEVENT/VTODO. - If not, it only includes builtin timezones that may not be on the server. - - To do that we check every TZID in the component to see if it is a builtin - timezone. If it is, we see if it it in our cache. If it is in our cache, - then we know the server already has it and we don't need to send it. - If it isn't in our cache, then we need to send it to the server. - If we need to send any timezones to the server, then we have to create a - complete VCALENDAR object, otherwise we can just send a single VEVENT/VTODO - as before. */ -static char* -cal_client_get_component_as_string_internal (CalClient *client, - icalcomponent *icalcomp, - gboolean include_all_timezones) -{ - GHashTable *timezone_hash; - GString *vcal_string; - int initial_vcal_string_len; - ForeachTZIDCallbackData cbdata; - char *obj_string; - CalClientPrivate *priv; - - priv = client->priv; - - timezone_hash = g_hash_table_new (g_str_hash, g_str_equal); - - /* Add any timezones needed to the hash. We use a hash since we only - want to add each timezone once at most. */ - cbdata.client = client; - cbdata.timezone_hash = timezone_hash; - cbdata.include_all_timezones = include_all_timezones; - cbdata.success = TRUE; - icalcomponent_foreach_tzid (icalcomp, foreach_tzid_callback, &cbdata); - if (!cbdata.success) { - g_hash_table_foreach (timezone_hash, free_timezone_string, - NULL); - return NULL; - } - - /* Create the start of a VCALENDAR, to add the VTIMEZONES to, - and remember its length so we know if any VTIMEZONEs get added. */ - vcal_string = g_string_new (NULL); - g_string_append (vcal_string, - "BEGIN:VCALENDAR\n" - "PRODID:-//Ximian//NONSGML Evolution Calendar//EN\n" - "VERSION:2.0\n" - "METHOD:PUBLISH\n"); - initial_vcal_string_len = vcal_string->len; - - /* Now concatenate all the timezone strings. This also frees the - timezone strings as it goes. */ - g_hash_table_foreach (timezone_hash, append_timezone_string, - vcal_string); - - /* Get the string for the VEVENT/VTODO. */ - obj_string = g_strdup (icalcomponent_as_ical_string (icalcomp)); - - /* If there were any timezones to send, create a complete VCALENDAR, - else just send the VEVENT/VTODO string. */ - if (!include_all_timezones - && vcal_string->len == initial_vcal_string_len) { - g_string_free (vcal_string, TRUE); - } else { - g_string_append (vcal_string, obj_string); - g_string_append (vcal_string, "END:VCALENDAR\n"); - g_free (obj_string); - obj_string = vcal_string->str; - g_string_free (vcal_string, FALSE); - } - - g_hash_table_destroy (timezone_hash); - - return obj_string; -} - -/** - * cal_client_get_component_as_string: - * @client: A calendar client. - * @icalcomp: A calendar component object. - * - * Gets a calendar component as an iCalendar string, with a toplevel - * VCALENDAR component and all VTIMEZONEs needed for the component. - * - * Return value: the component as a complete iCalendar string, or NULL on - * failure. The string should be freed after use. - **/ -char* -cal_client_get_component_as_string (CalClient *client, icalcomponent *icalcomp) -{ - return cal_client_get_component_as_string_internal (client, icalcomp, TRUE); -} - -gboolean -cal_client_create_object (CalClient *client, icalcomponent *icalcomp, char **uid, GError **error) -{ - CalClientPrivate *priv; - CORBA_Environment ev; - ECalendarStatus status; - ECalendarOp *our_op; - - g_return_val_if_fail (client != NULL, FALSE); - g_return_val_if_fail (IS_CAL_CLIENT (client), FALSE); - - priv = client->priv; - - e_mutex_lock (client->priv->mutex); - - if (client->priv->load_state != CAL_CLIENT_LOAD_LOADED) { - e_mutex_unlock (client->priv->mutex); - E_CALENDAR_CHECK_STATUS (E_CALENDAR_STATUS_URI_NOT_LOADED, error); - } - - if (client->priv->current_op != NULL) { - e_mutex_unlock (client->priv->mutex); - E_CALENDAR_CHECK_STATUS (E_CALENDAR_STATUS_BUSY, error); - } - - our_op = e_calendar_new_op (client); - - e_mutex_lock (our_op->mutex); - - e_mutex_unlock (client->priv->mutex); - - CORBA_exception_init (&ev); - - GNOME_Evolution_Calendar_Cal_createObject (priv->cal, icalcomponent_as_ical_string (icalcomp), &ev); - if (BONOBO_EX (&ev)) { - e_calendar_remove_op (client, our_op); - e_mutex_unlock (our_op->mutex); - e_calendar_free_op (our_op); - - CORBA_exception_free (&ev); - - g_warning (G_STRLOC ": Unable to contact backend"); - - E_CALENDAR_CHECK_STATUS (E_CALENDAR_STATUS_CORBA_EXCEPTION, error); - } - - CORBA_exception_free (&ev); - - /* wait for something to happen (both cancellation and a - successful response will notity us via our cv */ - e_mutex_cond_wait (&our_op->cond, our_op->mutex); - - status = our_op->status; - if (uid) - *uid = our_op->uid; - - e_calendar_remove_op (client, our_op); - e_mutex_unlock (our_op->mutex); - e_calendar_free_op (our_op); - - E_CALENDAR_CHECK_STATUS (status, error); -} - -gboolean -cal_client_modify_object (CalClient *client, icalcomponent *icalcomp, CalObjModType mod, GError **error) -{ - CalClientPrivate *priv; - CORBA_Environment ev; - ECalendarStatus status; - ECalendarOp *our_op; - - g_return_val_if_fail (client != NULL, FALSE); - g_return_val_if_fail (IS_CAL_CLIENT (client), FALSE); - g_return_val_if_fail (icalcomp != NULL, FALSE); - - priv = client->priv; - - e_mutex_lock (client->priv->mutex); - - if (client->priv->load_state != CAL_CLIENT_LOAD_LOADED) { - e_mutex_unlock (client->priv->mutex); - E_CALENDAR_CHECK_STATUS (E_CALENDAR_STATUS_URI_NOT_LOADED, error); - } - - if (client->priv->current_op != NULL) { - e_mutex_unlock (client->priv->mutex); - E_CALENDAR_CHECK_STATUS (E_CALENDAR_STATUS_BUSY, error); - } - - our_op = e_calendar_new_op (client); - - e_mutex_lock (our_op->mutex); - - e_mutex_unlock (client->priv->mutex); - - CORBA_exception_init (&ev); - - GNOME_Evolution_Calendar_Cal_modifyObject (priv->cal, icalcomponent_as_ical_string (icalcomp), mod, &ev); - if (BONOBO_EX (&ev)) { - e_calendar_remove_op (client, our_op); - e_mutex_unlock (our_op->mutex); - e_calendar_free_op (our_op); - - CORBA_exception_free (&ev); - - g_warning (G_STRLOC ": Unable to contact backend"); - - E_CALENDAR_CHECK_STATUS (E_CALENDAR_STATUS_CORBA_EXCEPTION, error); - } - - CORBA_exception_free (&ev); - - /* wait for something to happen (both cancellation and a - successful response will notity us via our cv */ - e_mutex_cond_wait (&our_op->cond, our_op->mutex); - - status = our_op->status; - - e_calendar_remove_op (client, our_op); - e_mutex_unlock (our_op->mutex); - e_calendar_free_op (our_op); - - E_CALENDAR_CHECK_STATUS (status, error); -} - -gboolean -cal_client_remove_object_with_mod (CalClient *client, const char *uid, - const char *rid, CalObjModType mod, GError **error) -{ - CalClientPrivate *priv; - CORBA_Environment ev; - ECalendarStatus status; - ECalendarOp *our_op; - - g_return_val_if_fail (client != NULL, FALSE); - g_return_val_if_fail (IS_CAL_CLIENT (client), FALSE); - - priv = client->priv; - - e_mutex_lock (client->priv->mutex); - - if (client->priv->load_state != CAL_CLIENT_LOAD_LOADED) { - e_mutex_unlock (client->priv->mutex); - E_CALENDAR_CHECK_STATUS (E_CALENDAR_STATUS_URI_NOT_LOADED, error); - } - - if (client->priv->current_op != NULL) { - e_mutex_unlock (client->priv->mutex); - E_CALENDAR_CHECK_STATUS (E_CALENDAR_STATUS_BUSY, error); - } - - our_op = e_calendar_new_op (client); - - e_mutex_lock (our_op->mutex); - - e_mutex_unlock (client->priv->mutex); - - - CORBA_exception_init (&ev); - - GNOME_Evolution_Calendar_Cal_removeObject (priv->cal, uid, rid ? rid : "", mod, &ev); - if (BONOBO_EX (&ev)) { - e_calendar_remove_op (client, our_op); - e_mutex_unlock (our_op->mutex); - e_calendar_free_op (our_op); - - CORBA_exception_free (&ev); - - g_warning (G_STRLOC ": Unable to contact backend"); - - E_CALENDAR_CHECK_STATUS (E_CALENDAR_STATUS_CORBA_EXCEPTION, error); - } - - CORBA_exception_free (&ev); - - /* wait for something to happen (both cancellation and a - successful response will notity us via our cv */ - e_mutex_cond_wait (&our_op->cond, our_op->mutex); - - status = our_op->status; - - e_calendar_remove_op (client, our_op); - e_mutex_unlock (our_op->mutex); - e_calendar_free_op (our_op); - - E_CALENDAR_CHECK_STATUS (status, error); -} - -/** - * cal_client_remove_object: - * @client: A calendar client. - * @uid: Unique identifier of the calendar component to remove. - * - * Asks a calendar to remove a component. If the server is able to remove the - * component, all clients will be notified and they will emit the "obj_removed" - * signal. - * - * Return value: a #CalClientResult value indicating the result of the - * operation. - **/ -gboolean -cal_client_remove_object (CalClient *client, const char *uid, GError **error) -{ - g_return_val_if_fail (client != NULL, FALSE); - g_return_val_if_fail (IS_CAL_CLIENT (client), FALSE); - - return cal_client_remove_object_with_mod (client, uid, NULL, CALOBJ_MOD_ALL, error); -} - -gboolean -cal_client_receive_objects (CalClient *client, icalcomponent *icalcomp, GError **error) -{ - CalClientPrivate *priv; - CORBA_Environment ev; - ECalendarStatus status; - ECalendarOp *our_op; - - g_return_val_if_fail (client != NULL, FALSE); - g_return_val_if_fail (IS_CAL_CLIENT (client), FALSE); - - priv = client->priv; - - e_mutex_lock (client->priv->mutex); - - if (client->priv->load_state != CAL_CLIENT_LOAD_LOADED) { - e_mutex_unlock (client->priv->mutex); - E_CALENDAR_CHECK_STATUS (E_CALENDAR_STATUS_URI_NOT_LOADED, error); - } - - if (client->priv->current_op != NULL) { - e_mutex_unlock (client->priv->mutex); - E_CALENDAR_CHECK_STATUS (E_CALENDAR_STATUS_BUSY, error); - } - - our_op = e_calendar_new_op (client); - - e_mutex_lock (our_op->mutex); - - e_mutex_unlock (client->priv->mutex); - - CORBA_exception_init (&ev); - - GNOME_Evolution_Calendar_Cal_receiveObjects (priv->cal, icalcomponent_as_ical_string (icalcomp), &ev); - if (BONOBO_EX (&ev)) { - e_calendar_remove_op (client, our_op); - e_mutex_unlock (our_op->mutex); - e_calendar_free_op (our_op); - - CORBA_exception_free (&ev); - - g_warning (G_STRLOC ": Unable to contact backend"); - - E_CALENDAR_CHECK_STATUS (E_CALENDAR_STATUS_CORBA_EXCEPTION, error); - } - - CORBA_exception_free (&ev); - - /* wait for something to happen (both cancellation and a - successful response will notity us via our cv */ - e_mutex_cond_wait (&our_op->cond, our_op->mutex); - - status = our_op->status; - - e_calendar_remove_op (client, our_op); - e_mutex_unlock (our_op->mutex); - e_calendar_free_op (our_op); - - E_CALENDAR_CHECK_STATUS (status, error); -} - -gboolean -cal_client_send_objects (CalClient *client, icalcomponent *icalcomp, GError **error) -{ - CalClientPrivate *priv; - CORBA_Environment ev; - ECalendarStatus status; - ECalendarOp *our_op; - - g_return_val_if_fail (client != NULL, FALSE); - g_return_val_if_fail (IS_CAL_CLIENT (client), FALSE); - - priv = client->priv; - - e_mutex_lock (client->priv->mutex); - - if (client->priv->load_state != CAL_CLIENT_LOAD_LOADED) { - e_mutex_unlock (client->priv->mutex); - E_CALENDAR_CHECK_STATUS (E_CALENDAR_STATUS_URI_NOT_LOADED, error); - } - - if (client->priv->current_op != NULL) { - e_mutex_unlock (client->priv->mutex); - E_CALENDAR_CHECK_STATUS (E_CALENDAR_STATUS_BUSY, error); - } - - our_op = e_calendar_new_op (client); - - e_mutex_lock (our_op->mutex); - - e_mutex_unlock (client->priv->mutex); - - CORBA_exception_init (&ev); - - GNOME_Evolution_Calendar_Cal_sendObjects (priv->cal, icalcomponent_as_ical_string (icalcomp), &ev); - if (BONOBO_EX (&ev)) { - e_calendar_remove_op (client, our_op); - e_mutex_unlock (our_op->mutex); - e_calendar_free_op (our_op); - - CORBA_exception_free (&ev); - - g_warning (G_STRLOC ": Unable to contact backend"); - - E_CALENDAR_CHECK_STATUS (E_CALENDAR_STATUS_CORBA_EXCEPTION, error); - } - - CORBA_exception_free (&ev); - - /* wait for something to happen (both cancellation and a - successful response will notity us via our cv */ - e_mutex_cond_wait (&our_op->cond, our_op->mutex); - - status = our_op->status; - - e_calendar_remove_op (client, our_op); - e_mutex_unlock (our_op->mutex); - e_calendar_free_op (our_op); - - E_CALENDAR_CHECK_STATUS (status, error); -} - -gboolean -cal_client_get_timezone (CalClient *client, const char *tzid, icaltimezone **zone, GError **error) -{ - CalClientPrivate *priv; - CORBA_Environment ev; - ECalendarStatus status; - ECalendarOp *our_op; - icalcomponent *icalcomp; - - g_return_val_if_fail (IS_CAL_CLIENT (client), FALSE); - g_return_val_if_fail (tzid != NULL, FALSE); - - priv = client->priv; - - e_mutex_lock (priv->mutex); - - if (client->priv->load_state != CAL_CLIENT_LOAD_LOADED) { - e_mutex_unlock (client->priv->mutex); - E_CALENDAR_CHECK_STATUS (E_CALENDAR_STATUS_URI_NOT_LOADED, error); - } - - if (client->priv->current_op != NULL) { - e_mutex_unlock (client->priv->mutex); - E_CALENDAR_CHECK_STATUS (E_CALENDAR_STATUS_BUSY, error); - } - - our_op = e_calendar_new_op (client); - - e_mutex_lock (our_op->mutex); - - e_mutex_unlock (priv->mutex); - - /* Check for well known zones and in the cache */ - *zone = NULL; - - /* If tzid is NULL or "" we return NULL, since it is a 'local time'. */ - if (!tzid || !tzid[0]) { - e_calendar_remove_op (client, our_op); - e_mutex_unlock (our_op->mutex); - e_calendar_free_op (our_op); - - E_CALENDAR_CHECK_STATUS (E_CALENDAR_STATUS_OK, error); - } - - /* If it is UTC, we return the special UTC timezone. */ - if (!strcmp (tzid, "UTC")) { - *zone = icaltimezone_get_utc_timezone (); - } else { - /* See if we already have it in the cache. */ - *zone = g_hash_table_lookup (priv->timezones, tzid); - } - - if (*zone) { - e_calendar_remove_op (client, our_op); - e_mutex_unlock (our_op->mutex); - e_calendar_free_op (our_op); - - E_CALENDAR_CHECK_STATUS (E_CALENDAR_STATUS_OK, error); - } - - /* call the backend */ - CORBA_exception_init (&ev); - - GNOME_Evolution_Calendar_Cal_getTimezone (priv->cal, tzid, &ev); - if (BONOBO_EX (&ev)) { - e_calendar_remove_op (client, our_op); - e_mutex_unlock (our_op->mutex); - e_calendar_free_op (our_op); - - CORBA_exception_free (&ev); - - g_warning (G_STRLOC ": Unable to contact backend"); - - E_CALENDAR_CHECK_STATUS (E_CALENDAR_STATUS_CORBA_EXCEPTION, error); - } - - CORBA_exception_free (&ev); - - /* wait for something to happen (both cancellation and a - successful response will notity us via our cv */ - e_mutex_cond_wait (&our_op->cond, our_op->mutex); - - status = our_op->status; - - icalcomp = icalparser_parse_string (our_op->string); - g_free (our_op->string); - - /* FIXME Invalid object status? */ - if (!icalcomp) { - e_calendar_remove_op (client, our_op); - e_mutex_unlock (our_op->mutex); - e_calendar_free_op (our_op); - - E_CALENDAR_CHECK_STATUS (E_CALENDAR_STATUS_OBJECT_NOT_FOUND, error); - } - - *zone = icaltimezone_new (); - if (!icaltimezone_set_component (*zone, icalcomp)) { - icaltimezone_free (*zone, 1); - - e_calendar_remove_op (client, our_op); - e_mutex_unlock (our_op->mutex); - e_calendar_free_op (our_op); - - E_CALENDAR_CHECK_STATUS (E_CALENDAR_STATUS_OBJECT_NOT_FOUND, error); - } - - /* Now add it to the cache, to avoid the server call in future. */ - g_hash_table_insert (priv->timezones, icaltimezone_get_tzid (*zone), *zone); - - e_calendar_remove_op (client, our_op); - e_mutex_unlock (our_op->mutex); - e_calendar_free_op (our_op); - - E_CALENDAR_CHECK_STATUS (status, error); -} - -/** - * cal_client_add_timezone - * @client: A calendar client. - * @izone: The timezone to add. - * @error: Placeholder for error information. - * - * Add a VTIMEZONE object to the given calendar. - * - * Returns: TRUE if successful, FALSE otherwise. - */ -gboolean -cal_client_add_timezone (CalClient *client, icaltimezone *izone, GError **error) -{ - CalClientPrivate *priv; - CORBA_Environment ev; - ECalendarStatus status; - ECalendarOp *our_op; - const char *tzobj; - - g_return_val_if_fail (IS_CAL_CLIENT (client), FALSE); - g_return_val_if_fail (izone != NULL, FALSE); - - priv = client->priv; - - e_mutex_lock (priv->mutex); - - if (client->priv->load_state != CAL_CLIENT_LOAD_LOADED) { - e_mutex_unlock (client->priv->mutex); - E_CALENDAR_CHECK_STATUS (E_CALENDAR_STATUS_URI_NOT_LOADED, error); - } - - if (client->priv->current_op != NULL) { - e_mutex_unlock (client->priv->mutex); - E_CALENDAR_CHECK_STATUS (E_CALENDAR_STATUS_BUSY, error); - } - - our_op = e_calendar_new_op (client); - - e_mutex_lock (our_op->mutex); - - e_mutex_unlock (priv->mutex); - - /* convert icaltimezone into a string */ - tzobj = icalcomponent_as_ical_string (icaltimezone_get_component (izone)); - - /* call the backend */ - CORBA_exception_init (&ev); - - GNOME_Evolution_Calendar_Cal_addTimezone (priv->cal, tzobj, &ev); - if (BONOBO_EX (&ev)) { - e_calendar_remove_op (client, our_op); - e_mutex_unlock (our_op->mutex); - e_calendar_free_op (our_op); - - CORBA_exception_free (&ev); - - g_warning (G_STRLOC ": Unable to contact backend"); - - E_CALENDAR_CHECK_STATUS (E_CALENDAR_STATUS_CORBA_EXCEPTION, error); - } - - CORBA_exception_free (&ev); - - /* wait for something to happen (both cancellation and a - successful response will notity us via our cv */ - e_mutex_cond_wait (&our_op->cond, our_op->mutex); - - status = our_op->status; - - e_calendar_remove_op (client, our_op); - e_mutex_unlock (our_op->mutex); - e_calendar_free_op (our_op); - - E_CALENDAR_CHECK_STATUS (status, error); -} - -/** - * cal_client_get_query: - * @client: A calendar client. - * @sexp: S-expression representing the query. - * - * Creates a live query object from a loaded calendar. - * - * Return value: A query object that will emit notification signals as calendar - * components are added and removed from the query in the server. - **/ -gboolean -cal_client_get_query (CalClient *client, const char *sexp, CalQuery **query, GError **error) -{ - CORBA_Environment ev; - ECalendarOp *our_op; - ECalendarStatus status; - - g_return_val_if_fail (client != NULL, E_CALENDAR_STATUS_INVALID_ARG); - g_return_val_if_fail (IS_CAL_CLIENT (client), E_CALENDAR_STATUS_INVALID_ARG); - g_return_val_if_fail (query != NULL, E_CALENDAR_STATUS_INVALID_ARG); - - e_mutex_lock (client->priv->mutex); - - if (client->priv->load_state != CAL_CLIENT_LOAD_LOADED) { - e_mutex_unlock (client->priv->mutex); - E_CALENDAR_CHECK_STATUS (E_CALENDAR_STATUS_URI_NOT_LOADED, error); - } - - if (client->priv->current_op != NULL) { - e_mutex_unlock (client->priv->mutex); - E_CALENDAR_CHECK_STATUS (E_CALENDAR_STATUS_BUSY, error); - } - - our_op = e_calendar_new_op (client); - - e_mutex_lock (our_op->mutex); - - e_mutex_unlock (client->priv->mutex); - - CORBA_exception_init (&ev); - - our_op->listener = query_listener_new (); - GNOME_Evolution_Calendar_Cal_getQuery (client->priv->cal, sexp, BONOBO_OBJREF (our_op->listener), &ev); - - if (BONOBO_EX (&ev)) { - e_calendar_remove_op (client, our_op); - e_mutex_unlock (our_op->mutex); - e_calendar_free_op (our_op); - - CORBA_exception_free (&ev); - - g_warning (G_STRLOC ": Unable to contact backend"); - - E_CALENDAR_CHECK_STATUS (E_CALENDAR_STATUS_CORBA_EXCEPTION, error); - } - - CORBA_exception_free (&ev); - - /* wait for something to happen (both cancellation and a - successful response will notity us via our cv */ - e_mutex_cond_wait (&our_op->cond, our_op->mutex); - - status = our_op->status; - *query = our_op->query; - - bonobo_object_unref (BONOBO_OBJECT (our_op->listener)); - - e_calendar_remove_op (client, our_op); - e_mutex_unlock (our_op->mutex); - e_calendar_free_op (our_op); - - E_CALENDAR_CHECK_STATUS (status, error); -} - - -/* This ensures that the given timezone is on the server. We use this to pass - the default timezone to the server, so it can resolve DATE and floating - DATE-TIME values into specific times. (Most of our IDL interface uses - time_t values to pass specific times from the server to the client.) */ -static gboolean -cal_client_ensure_timezone_on_server (CalClient *client, icaltimezone *zone, GError **error) -{ - CalClientPrivate *priv; - char *tzid; - icaltimezone *tmp_zone; - - priv = client->priv; - - /* FIXME This is highly broken since there is no locking */ - - /* If the zone is NULL or UTC we don't need to do anything. */ - if (!zone) - return TRUE; - - tzid = icaltimezone_get_tzid (zone); - - if (!strcmp (tzid, "UTC")) - return TRUE; - - /* See if we already have it in the cache. If we do, it must be on - the server already. */ - tmp_zone = g_hash_table_lookup (priv->timezones, tzid); - if (tmp_zone) - return TRUE; - - /* Now we have to send it to the server, in case it doesn't already - have it. */ - return cal_client_add_timezone (client, zone, error); -} - -gboolean -cal_client_set_default_timezone (CalClient *client, icaltimezone *zone, GError **error) -{ - CalClientPrivate *priv; - CORBA_Environment ev; - ECalendarStatus status; - ECalendarOp *our_op; - const char *tzid; - - g_return_val_if_fail (IS_CAL_CLIENT (client), FALSE); - g_return_val_if_fail (zone != NULL, FALSE); - - priv = client->priv; - - /* Make sure the server has the VTIMEZONE data. */ - if (!cal_client_ensure_timezone_on_server (client, zone, error)) - return FALSE; - - e_mutex_lock (priv->mutex); - - if (client->priv->load_state != CAL_CLIENT_LOAD_LOADED) { - e_mutex_unlock (client->priv->mutex); - E_CALENDAR_CHECK_STATUS (E_CALENDAR_STATUS_URI_NOT_LOADED, error); - } - - if (client->priv->current_op != NULL) { - e_mutex_unlock (client->priv->mutex); - E_CALENDAR_CHECK_STATUS (E_CALENDAR_STATUS_BUSY, error); - } - - our_op = e_calendar_new_op (client); - - e_mutex_lock (our_op->mutex); - - e_mutex_unlock (priv->mutex); - - /* FIXME Adding it to the server to change the tzid */ - tzid = icaltimezone_get_tzid (zone); - - /* call the backend */ - CORBA_exception_init (&ev); - - GNOME_Evolution_Calendar_Cal_setDefaultTimezone (priv->cal, tzid, &ev); - if (BONOBO_EX (&ev)) { - e_calendar_remove_op (client, our_op); - e_mutex_unlock (our_op->mutex); - e_calendar_free_op (our_op); - - CORBA_exception_free (&ev); - - g_warning (G_STRLOC ": Unable to contact backend"); - - E_CALENDAR_CHECK_STATUS (E_CALENDAR_STATUS_CORBA_EXCEPTION, error); - } - - CORBA_exception_free (&ev); - - /* wait for something to happen (both cancellation and a - successful response will notity us via our cv */ - e_mutex_cond_wait (&our_op->cond, our_op->mutex); - - status = our_op->status; - - e_calendar_remove_op (client, our_op); - e_mutex_unlock (our_op->mutex); - e_calendar_free_op (our_op); - - E_CALENDAR_CHECK_STATUS (status, error); -} - -/** - * cal_client_get_error_message - * @status: A status code. - * - * Get an error message for the given status code. - * - * Returns: the error message. - */ -const char * -cal_client_get_error_message (ECalendarStatus status) -{ - switch (status) { - case E_CALENDAR_STATUS_INVALID_ARG : - return _("Invalid argument"); - case E_CALENDAR_STATUS_BUSY : - return _("Backend is busy"); - case E_CALENDAR_STATUS_REPOSITORY_OFFLINE : - return _("Repository is offline"); - case E_CALENDAR_STATUS_NO_SUCH_CALENDAR : - return _("No such calendar"); - case E_CALENDAR_STATUS_OBJECT_NOT_FOUND : - return _("Object not found"); - case E_CALENDAR_STATUS_INVALID_OBJECT : - return _("Invalid object"); - case E_CALENDAR_STATUS_URI_NOT_LOADED : - return _("URI not loaded"); - case E_CALENDAR_STATUS_URI_ALREADY_LOADED : - return _("URI already loaded"); - case E_CALENDAR_STATUS_PERMISSION_DENIED : - return _("Permission denied"); - case E_CALENDAR_STATUS_CARD_NOT_FOUND : - return _("Object not found"); - case E_CALENDAR_STATUS_CARD_ID_ALREADY_EXISTS : - return _("Object ID already exists"); - case E_CALENDAR_STATUS_PROTOCOL_NOT_SUPPORTED : - return _("Protocol not supported"); - case E_CALENDAR_STATUS_CANCELLED : - return _("Operation has been cancelled"); - case E_CALENDAR_STATUS_COULD_NOT_CANCEL : - return _("Could not cancel operation"); - case E_CALENDAR_STATUS_AUTHENTICATION_FAILED : - return _("Authentication failed"); - case E_CALENDAR_STATUS_AUTHENTICATION_REQUIRED : - return _("Authentication required"); - case E_CALENDAR_STATUS_CORBA_EXCEPTION : - return _("A CORBA esception has occurred"); - case E_CALENDAR_STATUS_OTHER_ERROR : - return _("Unknown error"); - case E_CALENDAR_STATUS_OK : - return _("No error"); - } - - return NULL; -} diff --git a/calendar/cal-client/cal-client.h b/calendar/cal-client/cal-client.h deleted file mode 100644 index 9491c73fa3..0000000000 --- a/calendar/cal-client/cal-client.h +++ /dev/null @@ -1,212 +0,0 @@ -/* Evolution calendar client - * - * Copyright (C) 2001 Ximian, Inc. - * - * Author: Federico Mena-Quintero <federico@ximian.com> - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of version 2 of the GNU General Public - * License as published by the Free Software Foundation. - * - * 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA. - */ - -#ifndef CAL_CLIENT_H -#define CAL_CLIENT_H - -#include <glib-object.h> -#include <cal-util/cal-recur.h> -#include <cal-util/cal-util.h> -#include <cal-client/cal-query.h> -#include "cal-client-types.h" - -G_BEGIN_DECLS - - - -#define CAL_CLIENT_TYPE (cal_client_get_type ()) -#define CAL_CLIENT(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), CAL_CLIENT_TYPE, CalClient)) -#define CAL_CLIENT_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), CAL_CLIENT_TYPE, CalClientClass)) -#define IS_CAL_CLIENT(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), CAL_CLIENT_TYPE)) -#define IS_CAL_CLIENT_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), CAL_CLIENT_TYPE)) - -#define CAL_CLIENT_OPEN_STATUS_ENUM_TYPE (cal_client_open_status_enum_get_type ()) -#define CAL_CLIENT_REMOVE_STATUS_ENUM_TYPE (cal_client_remove_status_enum_get_type ()) -#define CAL_CLIENT_SET_MODE_STATUS_ENUM_TYPE (cal_client_set_mode_status_enum_get_type ()) -#define CAL_MODE_ENUM_TYPE (cal_mode_enum_get_type ()) - -typedef struct _CalClientClass CalClientClass; - -typedef struct _CalClientPrivate CalClientPrivate; - -/* Open status for the cal_opened signal */ -typedef enum { - CAL_CLIENT_OPEN_SUCCESS, - CAL_CLIENT_OPEN_ERROR, - CAL_CLIENT_OPEN_NOT_FOUND, - CAL_CLIENT_OPEN_PERMISSION_DENIED, - CAL_CLIENT_OPEN_METHOD_NOT_SUPPORTED -} CalClientOpenStatus; - -/* Set mode status for the cal_client_set_mode function */ -typedef enum { - CAL_CLIENT_SET_MODE_SUCCESS, - CAL_CLIENT_SET_MODE_ERROR, - CAL_CLIENT_SET_MODE_NOT_SUPPORTED -} CalClientSetModeStatus; - -/* Get status for the cal_client_get_object() function */ -typedef enum { - CAL_CLIENT_GET_SUCCESS, - CAL_CLIENT_GET_NOT_FOUND, - CAL_CLIENT_GET_SYNTAX_ERROR -} CalClientGetStatus; - -/* Status for update_object(s) and remove_object */ -typedef enum { - CAL_CLIENT_RESULT_SUCCESS, - CAL_CLIENT_RESULT_CORBA_ERROR, - CAL_CLIENT_RESULT_INVALID_OBJECT, - CAL_CLIENT_RESULT_NOT_FOUND, - CAL_CLIENT_RESULT_PERMISSION_DENIED -} CalClientResult; - -/* Whether the client is not loaded, is being loaded, or is already loaded */ -typedef enum { - CAL_CLIENT_LOAD_NOT_LOADED, - CAL_CLIENT_LOAD_LOADING, - CAL_CLIENT_LOAD_LOADED -} CalClientLoadState; - -struct _CalClient { - GObject object; - - /* Private data */ - CalClientPrivate *priv; -}; - -struct _CalClientClass { - GObjectClass parent_class; - - /* Notification signals */ - - void (* cal_opened) (CalClient *client, CalClientOpenStatus status); - void (* cal_set_mode) (CalClient *client, CalClientSetModeStatus status, CalMode mode); - - void (* backend_error) (CalClient *client, const char *message); - - void (* categories_changed) (CalClient *client, GPtrArray *categories); - - void (* forget_password) (CalClient *client, const char *key); - - void (* backend_died) (CalClient *client); -}; - -typedef gchar * (* CalClientAuthFunc) (CalClient *client, - const gchar *prompt, - const gchar *key, - gpointer user_data); - -GType cal_client_get_type (void); - -GType cal_client_open_status_enum_get_type (void); -GType cal_client_set_mode_status_enum_get_type (void); -GType cal_mode_enum_get_type (void); - -CalClient *cal_client_new (const char *uri, CalObjType type); - -void cal_client_set_auth_func (CalClient *client, CalClientAuthFunc func, gpointer data); - -gboolean cal_client_open (CalClient *client, gboolean only_if_exists, GError **error); -void cal_client_open_async (CalClient *client, gboolean only_if_exists); -gboolean cal_client_remove_calendar (CalClient *client, GError **error); - -GList *cal_client_uri_list (CalClient *client, CalMode mode); - -CalClientLoadState cal_client_get_load_state (CalClient *client); - -const char *cal_client_get_uri (CalClient *client); - -gboolean cal_client_is_read_only (CalClient *client, gboolean *read_only, GError **error); -gboolean cal_client_get_cal_address (CalClient *client, char **cal_address, GError **error); -gboolean cal_client_get_alarm_email_address (CalClient *client, char **alarm_address, GError **error); -gboolean cal_client_get_ldap_attribute (CalClient *client, char **ldap_attribute, GError **error); - -gboolean cal_client_get_one_alarm_only (CalClient *client); -gboolean cal_client_get_organizer_must_attend (CalClient *client); -gboolean cal_client_get_save_schedules (CalClient *client); -gboolean cal_client_get_static_capability (CalClient *client, const char *cap); - -gboolean cal_client_set_mode (CalClient *client, CalMode mode); - -gboolean cal_client_get_default_object (CalClient *client, - icalcomponent **icalcomp, GError **error); - -gboolean cal_client_get_object (CalClient *client, - const char *uid, - const char *rid, - icalcomponent **icalcomp, - GError **error); - -gboolean cal_client_get_changes (CalClient *client, const char *change_id, GList **changes, GError **error); - -gboolean cal_client_get_object_list (CalClient *client, const char *query, GList **objects, GError **error); -gboolean cal_client_get_object_list_as_comp (CalClient *client, const char *query, GList **objects, GError **error); -void cal_client_free_object_list (GList *objects); - -gboolean cal_client_get_free_busy (CalClient *client, GList *users, time_t start, time_t end, - GList **freebusy, GError **error); - -void cal_client_generate_instances (CalClient *client, CalObjType type, - time_t start, time_t end, - CalRecurInstanceFn cb, gpointer cb_data); - -GSList *cal_client_get_alarms_in_range (CalClient *client, time_t start, time_t end); - -void cal_client_free_alarms (GSList *comp_alarms); - -gboolean cal_client_get_alarms_for_object (CalClient *client, const char *uid, - time_t start, time_t end, - CalComponentAlarms **alarms); - -gboolean cal_client_create_object (CalClient *client, icalcomponent *icalcomp, char **uid, GError **error); -gboolean cal_client_modify_object (CalClient *client, icalcomponent *icalcomp, CalObjModType mod, GError **error); -gboolean cal_client_remove_object (CalClient *client, const char *uid, GError **error); -gboolean cal_client_remove_object_with_mod (CalClient *client, const char *uid, const char *rid, CalObjModType mod, GError **error); - -gboolean cal_client_discard_alarm (CalClient *client, CalComponent *comp, const char *auid, GError **error); - -gboolean cal_client_receive_objects (CalClient *client, icalcomponent *icalcomp, GError **error); -gboolean cal_client_send_objects (CalClient *client, icalcomponent *icalcomp, GError **error); - -gboolean cal_client_get_timezone (CalClient *client, const char *tzid, icaltimezone **zone, GError **error); -gboolean cal_client_add_timezone (CalClient *client, icaltimezone *izone, GError **error); -/* Sets the default timezone to use to resolve DATE and floating DATE-TIME - values. This will typically be from the user's timezone setting. Call this - before using any other functions. It will pass the default timezone on to - the server. Returns TRUE on success. */ -gboolean cal_client_set_default_timezone (CalClient *client, icaltimezone *zone, GError **error); - -gboolean cal_client_get_query (CalClient *client, const char *sexp, CalQuery **query, GError **error); - -/* Resolves TZIDs for the recurrence generator. */ -icaltimezone *cal_client_resolve_tzid_cb (const char *tzid, gpointer data); - -/* Returns a complete VCALENDAR for a VEVENT/VTODO including all VTIMEZONEs - used by the component. It also includes a 'METHOD:PUBLISH' property. */ -char* cal_client_get_component_as_string (CalClient *client, icalcomponent *icalcomp); - -const char * cal_client_get_error_message (ECalendarStatus status); - - - -G_END_DECLS - -#endif diff --git a/calendar/cal-client/cal-listener.c b/calendar/cal-client/cal-listener.c deleted file mode 100644 index ac04be7c07..0000000000 --- a/calendar/cal-client/cal-listener.c +++ /dev/null @@ -1,1025 +0,0 @@ -/* Evolution calendar listener - * - * Copyright (C) 2001 Ximian, Inc. - * - * Author: Federico Mena-Quintero <federico@ximian.com> - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of version 2 of the GNU General Public - * License as published by the Free Software Foundation. - * - * 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA. - */ - -#include <config.h> - -#include <bonobo/bonobo-main.h> -#include "cal-marshal.h" -#include "cal-listener.h" - - - -/* Private part of the CalListener structure */ -struct CalListenerPrivate { - /* Notification functions and their closure data */ - CalListenerCalSetModeFn cal_set_mode_fn; - CalListenerErrorOccurredFn error_occurred_fn; - CalListenerCategoriesChangedFn categories_changed_fn; - gpointer fn_data; - - /* Whether notification is desired */ - gboolean notify : 1; -}; - -/* Signal IDs */ -enum { - READ_ONLY, - CAL_ADDRESS, - ALARM_ADDRESS, - LDAP_ATTRIBUTE, - STATIC_CAPABILITIES, - OPEN, - REMOVE, - CREATE_OBJECT, - MODIFY_OBJECT, - REMOVE_OBJECT, - DISCARD_ALARM, - RECEIVE_OBJECTS, - SEND_OBJECTS, - DEFAULT_OBJECT, - OBJECT, - OBJECT_LIST, - GET_TIMEZONE, - ADD_TIMEZONE, - SET_DEFAULT_TIMEZONE, - GET_CHANGES, - GET_FREE_BUSY, - QUERY, - LAST_SIGNAL -}; - -static guint signals[LAST_SIGNAL] = { 0 }; - -static BonoboObjectClass *parent_class; - -static ECalendarStatus -convert_status (const GNOME_Evolution_Calendar_CallStatus status) -{ - switch (status) { - case GNOME_Evolution_Calendar_Success: - return E_CALENDAR_STATUS_OK; - case GNOME_Evolution_Calendar_RepositoryOffline: - return E_CALENDAR_STATUS_REPOSITORY_OFFLINE; - case GNOME_Evolution_Calendar_PermissionDenied: - return E_CALENDAR_STATUS_PERMISSION_DENIED; - case GNOME_Evolution_Calendar_ObjectNotFound: - return E_CALENDAR_STATUS_OBJECT_NOT_FOUND; - case GNOME_Evolution_Calendar_InvalidObject: - return E_CALENDAR_STATUS_INVALID_OBJECT; - case GNOME_Evolution_Calendar_CardIdAlreadyExists: - return E_CALENDAR_STATUS_CARD_ID_ALREADY_EXISTS; - case GNOME_Evolution_Calendar_AuthenticationFailed: - return E_CALENDAR_STATUS_AUTHENTICATION_FAILED; - case GNOME_Evolution_Calendar_AuthenticationRequired: - return E_CALENDAR_STATUS_AUTHENTICATION_REQUIRED; - case GNOME_Evolution_Calendar_OtherError: - default: - return E_CALENDAR_STATUS_OTHER_ERROR; - } -} - -static void -impl_notifyReadOnly (PortableServer_Servant servant, - GNOME_Evolution_Calendar_CallStatus status, - const CORBA_boolean read_only, - CORBA_Environment *ev) -{ - CalListener *listener; - CalListenerPrivate *priv; - - listener = CAL_LISTENER (bonobo_object_from_servant (servant)); - priv = listener->priv; - - if (!priv->notify) - return; - - g_signal_emit (G_OBJECT (listener), signals[READ_ONLY], 0, convert_status (status), read_only); -} - -static void -impl_notifyCalAddress (PortableServer_Servant servant, - GNOME_Evolution_Calendar_CallStatus status, - const CORBA_char *address, - CORBA_Environment *ev) -{ - CalListener *listener; - CalListenerPrivate *priv; - - listener = CAL_LISTENER (bonobo_object_from_servant (servant)); - priv = listener->priv; - - if (!priv->notify) - return; - - g_signal_emit (G_OBJECT (listener), signals[CAL_ADDRESS], 0, convert_status (status), address); -} - -static void -impl_notifyAlarmEmailAddress (PortableServer_Servant servant, - GNOME_Evolution_Calendar_CallStatus status, - const CORBA_char *address, - CORBA_Environment *ev) -{ - CalListener *listener; - CalListenerPrivate *priv; - - listener = CAL_LISTENER (bonobo_object_from_servant (servant)); - priv = listener->priv; - - if (!priv->notify) - return; - - g_signal_emit (G_OBJECT (listener), signals[ALARM_ADDRESS], 0, convert_status (status), address); -} - -static void -impl_notifyLDAPAttribute (PortableServer_Servant servant, - GNOME_Evolution_Calendar_CallStatus status, - const CORBA_char *ldap_attribute, - CORBA_Environment *ev) -{ - CalListener *listener; - CalListenerPrivate *priv; - - listener = CAL_LISTENER (bonobo_object_from_servant (servant)); - priv = listener->priv; - - if (!priv->notify) - return; - - g_signal_emit (G_OBJECT (listener), signals[LDAP_ATTRIBUTE], 0, convert_status (status), ldap_attribute); -} - -static void -impl_notifyStaticCapabilities (PortableServer_Servant servant, - GNOME_Evolution_Calendar_CallStatus status, - const CORBA_char *capabilities, - CORBA_Environment *ev) -{ - CalListener *listener; - CalListenerPrivate *priv; - - listener = CAL_LISTENER (bonobo_object_from_servant (servant)); - priv = listener->priv; - - if (!priv->notify) - return; - - g_signal_emit (G_OBJECT (listener), signals[STATIC_CAPABILITIES], 0, convert_status (status)); -} - -/* ::notifyCalOpened method */ -static void -impl_notifyCalOpened (PortableServer_Servant servant, - GNOME_Evolution_Calendar_CallStatus status, - CORBA_Environment *ev) -{ - CalListener *listener; - CalListenerPrivate *priv; - - listener = CAL_LISTENER (bonobo_object_from_servant (servant)); - priv = listener->priv; - - if (!priv->notify) - return; - - g_signal_emit (G_OBJECT (listener), signals[OPEN], 0, convert_status (status)); -} - -static void -impl_notifyCalRemoved (PortableServer_Servant servant, - GNOME_Evolution_Calendar_CallStatus status, - CORBA_Environment *ev) -{ - CalListener *listener; - CalListenerPrivate *priv; - - listener = CAL_LISTENER (bonobo_object_from_servant (servant)); - priv = listener->priv; - - if (!priv->notify) - return; - - g_signal_emit (G_OBJECT (listener), signals[REMOVE], 0, convert_status (status)); -} - -static void -impl_notifyObjectCreated (PortableServer_Servant servant, - GNOME_Evolution_Calendar_CallStatus status, - const CORBA_char *uid, - CORBA_Environment *ev) -{ - CalListener *listener; - CalListenerPrivate *priv; - - listener = CAL_LISTENER (bonobo_object_from_servant (servant)); - priv = listener->priv; - - if (!priv->notify) - return; - - g_signal_emit (G_OBJECT (listener), signals[CREATE_OBJECT], 0, convert_status (status), uid); -} - -static void -impl_notifyObjectModified (PortableServer_Servant servant, - GNOME_Evolution_Calendar_CallStatus status, - CORBA_Environment *ev) -{ - CalListener *listener; - CalListenerPrivate *priv; - - listener = CAL_LISTENER (bonobo_object_from_servant (servant)); - priv = listener->priv; - - if (!priv->notify) - return; - - g_signal_emit (G_OBJECT (listener), signals[MODIFY_OBJECT], 0, convert_status (status)); -} - -static void -impl_notifyObjectRemoved (PortableServer_Servant servant, - GNOME_Evolution_Calendar_CallStatus status, - CORBA_Environment *ev) -{ - CalListener *listener; - CalListenerPrivate *priv; - - listener = CAL_LISTENER (bonobo_object_from_servant (servant)); - priv = listener->priv; - - if (!priv->notify) - return; - - g_signal_emit (G_OBJECT (listener), signals[REMOVE_OBJECT], 0, convert_status (status)); -} - -static void -impl_notifyAlarmDiscarded (PortableServer_Servant servant, - GNOME_Evolution_Calendar_CallStatus status, - CORBA_Environment *ev) -{ - CalListener *listener; - CalListenerPrivate *priv; - - listener = CAL_LISTENER (bonobo_object_from_servant (servant)); - priv = listener->priv; - - if (!priv->notify) - return; - - g_signal_emit (G_OBJECT (listener), signals[DISCARD_ALARM], 0, convert_status (status)); -} - -static void -impl_notifyObjectsReceived (PortableServer_Servant servant, - GNOME_Evolution_Calendar_CallStatus status, - CORBA_Environment *ev) -{ - CalListener *listener; - CalListenerPrivate *priv; - - listener = CAL_LISTENER (bonobo_object_from_servant (servant)); - priv = listener->priv; - - if (!priv->notify) - return; - - g_signal_emit (G_OBJECT (listener), signals[RECEIVE_OBJECTS], 0, convert_status (status)); -} - -static void -impl_notifyObjectsSent (PortableServer_Servant servant, - GNOME_Evolution_Calendar_CallStatus status, - CORBA_Environment *ev) -{ - CalListener *listener; - CalListenerPrivate *priv; - - listener = CAL_LISTENER (bonobo_object_from_servant (servant)); - priv = listener->priv; - - if (!priv->notify) - return; - - g_signal_emit (G_OBJECT (listener), signals[SEND_OBJECTS], 0, convert_status (status)); -} - -static void -impl_notifyDefaultObjectRequested (PortableServer_Servant servant, - const GNOME_Evolution_Calendar_CallStatus status, - const CORBA_char *object, - CORBA_Environment *ev) -{ - CalListener *listener; - CalListenerPrivate *priv; - - listener = CAL_LISTENER (bonobo_object_from_servant (servant)); - priv = listener->priv; - - if (!priv->notify) - return; - - g_signal_emit (G_OBJECT (listener), signals[DEFAULT_OBJECT], 0, convert_status (status), object); -} - -static void -impl_notifyObjectRequested (PortableServer_Servant servant, - const GNOME_Evolution_Calendar_CallStatus status, - const CORBA_char *object, - CORBA_Environment *ev) -{ - CalListener *listener; - CalListenerPrivate *priv; - - listener = CAL_LISTENER (bonobo_object_from_servant (servant)); - priv = listener->priv; - - if (!priv->notify) - return; - - g_signal_emit (G_OBJECT (listener), signals[OBJECT], 0, convert_status (status), object); -} - -static GList * -build_object_list (const GNOME_Evolution_Calendar_stringlist *seq) -{ - GList *list; - int i; - - list = NULL; - for (i = 0; i < seq->_length; i++) { - icalcomponent *comp; - - comp = icalcomponent_new_from_string (seq->_buffer[i]); - if (!comp) - continue; - - list = g_list_prepend (list, comp); - } - - return list; -} - -static void -impl_notifyObjectListRequested (PortableServer_Servant servant, - const GNOME_Evolution_Calendar_CallStatus status, - const GNOME_Evolution_Calendar_stringlist *objects, - CORBA_Environment *ev) -{ - CalListener *listener; - CalListenerPrivate *priv; - GList *object_list, *l; - - listener = CAL_LISTENER (bonobo_object_from_servant (servant)); - priv = listener->priv; - - if (!priv->notify) - return; - - object_list = build_object_list (objects); - - g_signal_emit (G_OBJECT (listener), signals[OBJECT_LIST], 0, convert_status (status), object_list); - - for (l = object_list; l; l = l->next) - icalcomponent_free (l->data); - g_list_free (object_list); -} - -static void -impl_notifyTimezoneRequested (PortableServer_Servant servant, - const GNOME_Evolution_Calendar_CallStatus status, - const CORBA_char *object, - CORBA_Environment *ev) -{ - CalListener *listener; - CalListenerPrivate *priv; - - listener = CAL_LISTENER (bonobo_object_from_servant (servant)); - priv = listener->priv; - - if (!priv->notify) - return; - - g_signal_emit (G_OBJECT (listener), signals[GET_TIMEZONE], 0, convert_status (status), object); -} - -static void -impl_notifyTimezoneAdded (PortableServer_Servant servant, - const GNOME_Evolution_Calendar_CallStatus status, - const CORBA_char *tzid, - CORBA_Environment *ev) -{ - CalListener *listener; - CalListenerPrivate *priv; - - listener = CAL_LISTENER (bonobo_object_from_servant (servant)); - priv = listener->priv; - - if (!priv->notify) - return; - - g_signal_emit (G_OBJECT (listener), signals[ADD_TIMEZONE], 0, convert_status (status), tzid); -} - -static void -impl_notifyDefaultTimezoneSet (PortableServer_Servant servant, - const GNOME_Evolution_Calendar_CallStatus status, - CORBA_Environment *ev) -{ - CalListener *listener; - CalListenerPrivate *priv; - - listener = CAL_LISTENER (bonobo_object_from_servant (servant)); - priv = listener->priv; - - if (!priv->notify) - return; - - g_signal_emit (G_OBJECT (listener), signals[SET_DEFAULT_TIMEZONE], 0, convert_status (status)); -} - -static GList * -build_change_list (const GNOME_Evolution_Calendar_CalObjChangeSeq *seq) -{ - GList *list = NULL; - icalcomponent *icalcomp; - int i; - - /* Create the list in reverse order */ - for (i = 0; i < seq->_length; i++) { - GNOME_Evolution_Calendar_CalObjChange *corba_coc; - CalClientChange *ccc; - - corba_coc = &seq->_buffer[i]; - ccc = g_new (CalClientChange, 1); - - icalcomp = icalparser_parse_string (corba_coc->calobj); - if (!icalcomp) - continue; - - ccc->comp = cal_component_new (); - if (!cal_component_set_icalcomponent (ccc->comp, icalcomp)) { - icalcomponent_free (icalcomp); - g_object_unref (G_OBJECT (ccc->comp)); - continue; - } - ccc->type = corba_coc->type; - - list = g_list_prepend (list, ccc); - } - - list = g_list_reverse (list); - - return list; -} - -static void -impl_notifyChanges (PortableServer_Servant servant, - const GNOME_Evolution_Calendar_CallStatus status, - const GNOME_Evolution_Calendar_CalObjChangeSeq *seq, - CORBA_Environment *ev) -{ - CalListener *listener; - CalListenerPrivate *priv; - GList *changes, *l; - - listener = CAL_LISTENER (bonobo_object_from_servant (servant)); - priv = listener->priv; - - if (!priv->notify) - return; - - changes = build_change_list (seq); - - g_signal_emit (G_OBJECT (listener), signals[GET_CHANGES], 0, convert_status (status), changes); - - for (l = changes; l; l = l->next) - g_free (l->data); - g_list_free (changes); -} - -static GList * -build_free_busy_list (const GNOME_Evolution_Calendar_CalObjSeq *seq) -{ - GList *list = NULL; - int i; - - /* Create the list in reverse order */ - for (i = 0; i < seq->_length; i++) { - CalComponent *comp; - icalcomponent *icalcomp; - icalcomponent_kind kind; - - icalcomp = icalcomponent_new_from_string (seq->_buffer[i]); - if (!icalcomp) - continue; - - kind = icalcomponent_isa (icalcomp); - if (kind == ICAL_VFREEBUSY_COMPONENT) { - comp = cal_component_new (); - if (!cal_component_set_icalcomponent (comp, icalcomp)) { - icalcomponent_free (icalcomp); - g_object_unref (G_OBJECT (comp)); - continue; - } - - list = g_list_append (list, comp); - } else { - icalcomponent_free (icalcomp); - } - } - - return list; -} - -static void -impl_notifyFreeBusy (PortableServer_Servant servant, - const GNOME_Evolution_Calendar_CallStatus status, - const GNOME_Evolution_Calendar_CalObjSeq *seq, - CORBA_Environment *ev) -{ - CalListener *listener; - CalListenerPrivate *priv; - GList *freebusy, *l; - - listener = CAL_LISTENER (bonobo_object_from_servant (servant)); - priv = listener->priv; - - if (!priv->notify) - return; - - freebusy = build_free_busy_list (seq); - - g_signal_emit (G_OBJECT (listener), signals[GET_FREE_BUSY], 0, convert_status (status), freebusy); - - for (l = freebusy; l; l = l->next) - g_free (l->data); - g_list_free (freebusy); -} - -static void -impl_notifyQuery (PortableServer_Servant servant, - const GNOME_Evolution_Calendar_CallStatus status, - const GNOME_Evolution_Calendar_Query query, - CORBA_Environment *ev) -{ - CalListener *listener; - CalListenerPrivate *priv; - - listener = CAL_LISTENER (bonobo_object_from_servant (servant)); - priv = listener->priv; - - if (!priv->notify) - return; - - g_signal_emit (G_OBJECT (listener), signals[QUERY], 0, convert_status (status), query); -} - -/* ::notifyCalSetMode method */ -static void -impl_notifyCalSetMode (PortableServer_Servant servant, - GNOME_Evolution_Calendar_Listener_SetModeStatus status, - GNOME_Evolution_Calendar_CalMode mode, - CORBA_Environment *ev) -{ - CalListener *listener; - CalListenerPrivate *priv; - - listener = CAL_LISTENER (bonobo_object_from_servant (servant)); - priv = listener->priv; - - if (!priv->notify) - return; - - g_message ("notify_set_mode"); - - g_assert (priv->cal_set_mode_fn != NULL); - (* priv->cal_set_mode_fn) (listener, status, mode, priv->fn_data); -} - - -/* ::notifyErrorOccurred method */ -static void -impl_notifyErrorOccurred (PortableServer_Servant servant, - const CORBA_char *message, - CORBA_Environment *ev) -{ - CalListener *listener; - CalListenerPrivate *priv; - - listener = CAL_LISTENER (bonobo_object_from_servant (servant)); - priv = listener->priv; - - if (!priv->notify) - return; - - g_message ("notify_error"); - - g_assert (priv->error_occurred_fn != NULL); - (* priv->error_occurred_fn) (listener, message, priv->fn_data); -} - -/* ::notifyCategoriesChanged method */ -static void -impl_notifyCategoriesChanged (PortableServer_Servant servant, - const GNOME_Evolution_Calendar_StringSeq *categories, - CORBA_Environment *ev) -{ - CalListener *listener; - CalListenerPrivate *priv; - - listener = CAL_LISTENER (bonobo_object_from_servant (servant)); - priv = listener->priv; - - if (!priv->notify) - return; - - g_message ("notify_categories"); - - g_assert (priv->categories_changed_fn != NULL); - (* priv->categories_changed_fn) (listener, categories, priv->fn_data); -} - - - -/* Object initialization function for the calendar listener */ -static void -cal_listener_init (CalListener *listener, CalListenerClass *klass) -{ - CalListenerPrivate *priv; - - priv = g_new0 (CalListenerPrivate, 1); - listener->priv = priv; - - priv->error_occurred_fn = NULL; - priv->categories_changed_fn = NULL; - - priv->notify = TRUE; -} - -/* Finalize handler for the calendar listener */ -static void -cal_listener_finalize (GObject *object) -{ - CalListener *listener; - CalListenerPrivate *priv; - - g_return_if_fail (object != NULL); - g_return_if_fail (IS_CAL_LISTENER (object)); - - listener = CAL_LISTENER (object); - priv = listener->priv; - - priv->error_occurred_fn = NULL; - priv->categories_changed_fn = NULL; - priv->fn_data = NULL; - - priv->notify = FALSE; - - g_free (priv); - listener->priv = NULL; - - if (G_OBJECT_CLASS (parent_class)->finalize) - (* G_OBJECT_CLASS (parent_class)->finalize) (object); -} - -/* Class initialization function for the calendar listener */ -static void -cal_listener_class_init (CalListenerClass *klass) -{ - GObjectClass *object_class; - - object_class = (GObjectClass *) klass; - - parent_class = g_type_class_peek_parent (klass); - - klass->epv.notifyReadOnly = impl_notifyReadOnly; - klass->epv.notifyCalAddress = impl_notifyCalAddress; - klass->epv.notifyAlarmEmailAddress = impl_notifyAlarmEmailAddress; - klass->epv.notifyLDAPAttribute = impl_notifyLDAPAttribute; - klass->epv.notifyStaticCapabilities = impl_notifyStaticCapabilities; - klass->epv.notifyCalOpened = impl_notifyCalOpened; - klass->epv.notifyCalRemoved = impl_notifyCalRemoved; - klass->epv.notifyObjectCreated = impl_notifyObjectCreated; - klass->epv.notifyObjectModified = impl_notifyObjectModified; - klass->epv.notifyObjectRemoved = impl_notifyObjectRemoved; - klass->epv.notifyAlarmDiscarded = impl_notifyAlarmDiscarded; - klass->epv.notifyObjectsReceived = impl_notifyObjectsReceived; - klass->epv.notifyObjectsSent = impl_notifyObjectsSent; - klass->epv.notifyDefaultObjectRequested = impl_notifyDefaultObjectRequested; - klass->epv.notifyObjectRequested = impl_notifyObjectRequested; - klass->epv.notifyObjectListRequested = impl_notifyObjectListRequested; - klass->epv.notifyTimezoneRequested = impl_notifyTimezoneRequested; - klass->epv.notifyTimezoneAdded = impl_notifyTimezoneAdded; - klass->epv.notifyDefaultTimezoneSet = impl_notifyDefaultTimezoneSet; - klass->epv.notifyChanges = impl_notifyChanges; - klass->epv.notifyFreeBusy = impl_notifyFreeBusy; - klass->epv.notifyQuery = impl_notifyQuery; - klass->epv.notifyCalSetMode = impl_notifyCalSetMode; - klass->epv.notifyErrorOccurred = impl_notifyErrorOccurred; - klass->epv.notifyCategoriesChanged = impl_notifyCategoriesChanged; - - object_class->finalize = cal_listener_finalize; - - signals[READ_ONLY] = - g_signal_new ("read_only", - G_TYPE_FROM_CLASS (klass), - G_SIGNAL_RUN_LAST, - G_STRUCT_OFFSET (CalListenerClass, read_only), - NULL, NULL, - cal_marshal_VOID__INT_BOOLEAN, - G_TYPE_NONE, 2, G_TYPE_INT, G_TYPE_BOOLEAN); - signals[CAL_ADDRESS] = - g_signal_new ("cal_address", - G_TYPE_FROM_CLASS (klass), - G_SIGNAL_RUN_LAST, - G_STRUCT_OFFSET (CalListenerClass, cal_address), - NULL, NULL, - cal_marshal_VOID__INT_STRING, - G_TYPE_NONE, 2, G_TYPE_INT, G_TYPE_STRING); - signals[ALARM_ADDRESS] = - g_signal_new ("alarm_address", - G_TYPE_FROM_CLASS (klass), - G_SIGNAL_RUN_LAST, - G_STRUCT_OFFSET (CalListenerClass, alarm_address), - NULL, NULL, - cal_marshal_VOID__INT_STRING, - G_TYPE_NONE, 2, G_TYPE_INT, G_TYPE_STRING); - signals[LDAP_ATTRIBUTE] = - g_signal_new ("ldap_attribute", - G_TYPE_FROM_CLASS (klass), - G_SIGNAL_RUN_LAST, - G_STRUCT_OFFSET (CalListenerClass, ldap_attribute), - NULL, NULL, - cal_marshal_VOID__INT_STRING, - G_TYPE_NONE, 2, G_TYPE_INT, G_TYPE_STRING); - signals[STATIC_CAPABILITIES] = - g_signal_new ("static_capabilities", - G_TYPE_FROM_CLASS (klass), - G_SIGNAL_RUN_LAST, - G_STRUCT_OFFSET (CalListenerClass, static_capabilities), - NULL, NULL, - cal_marshal_VOID__INT_STRING, - G_TYPE_NONE, 2, G_TYPE_INT, G_TYPE_STRING); - signals[OPEN] = - g_signal_new ("open", - G_TYPE_FROM_CLASS (klass), - G_SIGNAL_RUN_LAST, - G_STRUCT_OFFSET (CalListenerClass, open), - NULL, NULL, - cal_marshal_VOID__INT, - G_TYPE_NONE, 1, G_TYPE_INT); - signals[REMOVE] = - g_signal_new ("remove", - G_TYPE_FROM_CLASS (klass), - G_SIGNAL_RUN_LAST, - G_STRUCT_OFFSET (CalListenerClass, remove), - NULL, NULL, - cal_marshal_VOID__INT, - G_TYPE_NONE, 1, G_TYPE_INT); - signals[CREATE_OBJECT] = - g_signal_new ("create_object", - G_TYPE_FROM_CLASS (klass), - G_SIGNAL_RUN_LAST, - G_STRUCT_OFFSET (CalListenerClass, create_object), - NULL, NULL, - cal_marshal_VOID__INT_STRING, - G_TYPE_NONE, 2, G_TYPE_INT, G_TYPE_STRING); - signals[MODIFY_OBJECT] = - g_signal_new ("modify_object", - G_TYPE_FROM_CLASS (klass), - G_SIGNAL_RUN_LAST, - G_STRUCT_OFFSET (CalListenerClass, modify_object), - NULL, NULL, - cal_marshal_VOID__INT, - G_TYPE_NONE, 1, G_TYPE_INT); - signals[REMOVE_OBJECT] = - g_signal_new ("remove_object", - G_TYPE_FROM_CLASS (klass), - G_SIGNAL_RUN_LAST, - G_STRUCT_OFFSET (CalListenerClass, remove_object), - NULL, NULL, - cal_marshal_VOID__INT, - G_TYPE_NONE, 1, G_TYPE_INT); - signals[DISCARD_ALARM] = - g_signal_new ("discard_alarm", - G_TYPE_FROM_CLASS (klass), - G_SIGNAL_RUN_LAST, - G_STRUCT_OFFSET (CalListenerClass, discard_alarm), - NULL, NULL, - cal_marshal_VOID__INT, - G_TYPE_NONE, 1, G_TYPE_INT); - signals[RECEIVE_OBJECTS] = - g_signal_new ("receive_objects", - G_TYPE_FROM_CLASS (klass), - G_SIGNAL_RUN_LAST, - G_STRUCT_OFFSET (CalListenerClass, receive_objects), - NULL, NULL, - cal_marshal_VOID__INT, - G_TYPE_NONE, 1, G_TYPE_INT); - signals[SEND_OBJECTS] = - g_signal_new ("send_objects", - G_TYPE_FROM_CLASS (klass), - G_SIGNAL_RUN_LAST, - G_STRUCT_OFFSET (CalListenerClass, send_objects), - NULL, NULL, - cal_marshal_VOID__INT, - G_TYPE_NONE, 1, G_TYPE_INT); - signals[DEFAULT_OBJECT] = - g_signal_new ("default_object", - G_TYPE_FROM_CLASS (klass), - G_SIGNAL_RUN_LAST, - G_STRUCT_OFFSET (CalListenerClass, default_object), - NULL, NULL, - cal_marshal_VOID__INT_STRING, - G_TYPE_NONE, 2, G_TYPE_INT, G_TYPE_STRING); - signals[OBJECT] = - g_signal_new ("object", - G_TYPE_FROM_CLASS (klass), - G_SIGNAL_RUN_LAST, - G_STRUCT_OFFSET (CalListenerClass, object), - NULL, NULL, - cal_marshal_VOID__INT_STRING, - G_TYPE_NONE, 2, G_TYPE_INT, G_TYPE_STRING); - signals[OBJECT_LIST] = - g_signal_new ("object_list", - G_TYPE_FROM_CLASS (klass), - G_SIGNAL_RUN_LAST, - G_STRUCT_OFFSET (CalListenerClass, object_list), - NULL, NULL, - cal_marshal_VOID__INT_POINTER, - G_TYPE_NONE, 2, G_TYPE_INT, G_TYPE_POINTER); - signals[GET_TIMEZONE] = - g_signal_new ("get_timezone", - G_TYPE_FROM_CLASS (klass), - G_SIGNAL_RUN_LAST, - G_STRUCT_OFFSET (CalListenerClass, get_timezone), - NULL, NULL, - cal_marshal_VOID__INT_STRING, - G_TYPE_NONE, 2, G_TYPE_INT, G_TYPE_STRING); - signals[ADD_TIMEZONE] = - g_signal_new ("add_timezone", - G_TYPE_FROM_CLASS (klass), - G_SIGNAL_RUN_LAST, - G_STRUCT_OFFSET (CalListenerClass, add_timezone), - NULL, NULL, - cal_marshal_VOID__INT_STRING, - G_TYPE_NONE, 2, G_TYPE_INT, G_TYPE_STRING); - signals[SET_DEFAULT_TIMEZONE] = - g_signal_new ("set_default_timezone", - G_TYPE_FROM_CLASS (klass), - G_SIGNAL_RUN_LAST, - G_STRUCT_OFFSET (CalListenerClass, set_default_timezone), - NULL, NULL, - cal_marshal_VOID__INT, - G_TYPE_NONE, 1, G_TYPE_INT); - signals[GET_CHANGES] = - g_signal_new ("get_changes", - G_TYPE_FROM_CLASS (klass), - G_SIGNAL_RUN_LAST, - G_STRUCT_OFFSET (CalListenerClass, get_changes), - NULL, NULL, - cal_marshal_VOID__INT_POINTER, - G_TYPE_NONE, 1, G_TYPE_INT, G_TYPE_POINTER); - signals[GET_FREE_BUSY] = - g_signal_new ("get_free_busy", - G_TYPE_FROM_CLASS (klass), - G_SIGNAL_RUN_LAST, - G_STRUCT_OFFSET (CalListenerClass, get_free_busy), - NULL, NULL, - cal_marshal_VOID__INT_POINTER, - G_TYPE_NONE, 1, G_TYPE_INT, G_TYPE_POINTER); - signals[QUERY] = - g_signal_new ("query", - G_TYPE_FROM_CLASS (klass), - G_SIGNAL_RUN_LAST, - G_STRUCT_OFFSET (CalListenerClass, query), - NULL, NULL, - cal_marshal_VOID__INT_POINTER, - G_TYPE_NONE, 2, G_TYPE_INT, G_TYPE_POINTER); -} - -BONOBO_TYPE_FUNC_FULL (CalListener, - GNOME_Evolution_Calendar_Listener, - BONOBO_TYPE_OBJECT, - cal_listener); - -/** - * cal_listener_construct: - * @listener: A calendar listener. - * @cal_opened_fn: Function that will be called to notify that a calendar was - * opened. - * @cal_removed_fn: Function that will be called to notify that a calendar was - * removed - * @error_occurred_fn: Function that will be called to notify errors. - * @categories_changed_fn: Function that will be called to notify that the list - * of categories that are present in the calendar's objects has changed. - * @fn_data: Closure data pointer that will be passed to the notification - * functions. - * - * Constructs a calendar listener by setting the callbacks that it will use for - * notification from the calendar server. - * - * Return value: the same object as the @listener argument. - **/ -CalListener * -cal_listener_construct (CalListener *listener, - CalListenerCalSetModeFn cal_set_mode_fn, - CalListenerErrorOccurredFn error_occurred_fn, - CalListenerCategoriesChangedFn categories_changed_fn, - gpointer fn_data) -{ - CalListenerPrivate *priv; - - g_return_val_if_fail (listener != NULL, NULL); - g_return_val_if_fail (IS_CAL_LISTENER (listener), NULL); - g_return_val_if_fail (cal_set_mode_fn != NULL, NULL); - g_return_val_if_fail (error_occurred_fn != NULL, NULL); - g_return_val_if_fail (categories_changed_fn != NULL, NULL); - - priv = listener->priv; - - priv->cal_set_mode_fn = cal_set_mode_fn; - priv->error_occurred_fn = error_occurred_fn; - priv->categories_changed_fn = categories_changed_fn; - priv->fn_data = fn_data; - - return listener; -} - -/** - * cal_listener_new: - * @cal_opened_fn: Function that will be called to notify that a calendar was - * opened. - * @error_occurred_fn: Function that will be called to notify errors. - * @categories_changed_fn: Function that will be called to notify that the list - * of categories that are present in the calendar's objects has changed. - * @fn_data: Closure data pointer that will be passed to the notification - * functions. - * - * Creates a new #CalListener object. - * - * Return value: A newly-created #CalListener object. - **/ -CalListener * -cal_listener_new (CalListenerCalSetModeFn cal_set_mode_fn, - CalListenerErrorOccurredFn error_occurred_fn, - CalListenerCategoriesChangedFn categories_changed_fn, - gpointer fn_data) -{ - CalListener *listener; - - g_return_val_if_fail (error_occurred_fn != NULL, NULL); - g_return_val_if_fail (categories_changed_fn != NULL, NULL); - - listener = g_object_new (CAL_LISTENER_TYPE, - "poa", bonobo_poa_get_threaded (ORBIT_THREAD_HINT_PER_REQUEST, NULL), - NULL); - - return cal_listener_construct (listener, - cal_set_mode_fn, - error_occurred_fn, - categories_changed_fn, - fn_data); -} - -/** - * cal_listener_stop_notification: - * @listener: A calendar listener. - * - * Informs a calendar listener that no further notification is desired. The - * callbacks specified when the listener was created will no longer be invoked - * after this function is called. - **/ -void -cal_listener_stop_notification (CalListener *listener) -{ - CalListenerPrivate *priv; - - g_return_if_fail (listener != NULL); - g_return_if_fail (IS_CAL_LISTENER (listener)); - - priv = listener->priv; - g_return_if_fail (priv->notify != FALSE); - - priv->notify = FALSE; -} diff --git a/calendar/cal-client/cal-listener.h b/calendar/cal-client/cal-listener.h deleted file mode 100644 index 1230104999..0000000000 --- a/calendar/cal-client/cal-listener.h +++ /dev/null @@ -1,120 +0,0 @@ -/* Evolution calendar listener - * - * Copyright (C) 2001 Ximian, Inc. - * - * Author: Federico Mena-Quintero <federico@ximian.com> - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of version 2 of the GNU General Public - * License as published by the Free Software Foundation. - * - * 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA. - */ - -#ifndef CAL_LISTENER_H -#define CAL_LISTENER_H - -#include <bonobo/bonobo-object.h> -#include "evolution-calendar.h" -#include "cal-client-types.h" - -G_BEGIN_DECLS - - - -#define CAL_LISTENER_TYPE (cal_listener_get_type ()) -#define CAL_LISTENER(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), CAL_LISTENER_TYPE, CalListener)) -#define CAL_LISTENER_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), CAL_LISTENER_TYPE, \ - CalListenerClass)) -#define IS_CAL_LISTENER(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), CAL_LISTENER_TYPE)) -#define IS_CAL_LISTENER_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), CAL_LISTENER_TYPE)) - -typedef struct CalListenerPrivate CalListenerPrivate; - -typedef struct { - BonoboObject xobject; - - /* Private data */ - CalListenerPrivate *priv; -} CalListener; - -typedef struct { - BonoboObjectClass parent_class; - - POA_GNOME_Evolution_Calendar_Listener__epv epv; - - /* Signals */ - void (*read_only) (CalListener *listener, ECalendarStatus status, gboolean read_only); - void (*cal_address) (CalListener *listener, ECalendarStatus status, const char *address); - void (*alarm_address) (CalListener *listener, ECalendarStatus status, const char *address); - void (*ldap_attribute) (CalListener *listener, ECalendarStatus status, const char *ldap_attribute); - void (*static_capabilities) (CalListener *listener, ECalendarStatus status, const char *capabilities); - - void (*open) (CalListener *listener, ECalendarStatus status); - void (*remove) (CalListener *listener, ECalendarStatus status); - - void (*create_object) (CalListener *listener, ECalendarStatus status, const char *id); - void (*modify_object) (CalListener *listener, ECalendarStatus status); - void (*remove_object) (CalListener *listener, ECalendarStatus status); - - void (*discard_alarm) (CalListener *listener, ECalendarStatus status); - - void (*receive_objects) (CalListener *listener, ECalendarStatus status); - void (*send_objects) (CalListener *listener, ECalendarStatus status); - - void (*default_object) (CalListener *listener, ECalendarStatus status, const char *object); - void (*object) (CalListener *listener, ECalendarStatus status, const char *object); - void (*object_list) (CalListener *listener, ECalendarStatus status, GList **objects); - - void (*get_timezone) (CalListener *listener, ECalendarStatus status, const char *object); - void (*add_timezone) (CalListener *listener, ECalendarStatus status, const char *tzid); - void (*set_default_timezone) (CalListener *listener, ECalendarStatus status, const char *tzid); - - void (*get_changes) (CalListener *listener, ECalendarStatus status, GList *changes); - void (*get_free_busy) (CalListener *listener, ECalendarStatus status, GList *freebusy); - - void (*query) (CalListener *listener, ECalendarStatus status, GNOME_Evolution_Calendar_Query query); -} CalListenerClass; - -/* Notification functions */ -typedef void (* CalListenerCalSetModeFn) (CalListener *listener, - GNOME_Evolution_Calendar_Listener_SetModeStatus status, - GNOME_Evolution_Calendar_CalMode mode, - gpointer data); - -typedef void (* CalListenerErrorOccurredFn) (CalListener *listener, - const char *message, - gpointer data); - -typedef void (* CalListenerCategoriesChangedFn) (CalListener *listener, - const GNOME_Evolution_Calendar_StringSeq *categories, - gpointer data); - - -GType cal_listener_get_type (void); - -CalListener *cal_listener_construct (CalListener *listener, - CalListenerCalSetModeFn cal_set_mode_fn, - CalListenerErrorOccurredFn error_occurred_fn, - CalListenerCategoriesChangedFn categories_changed_fn, - gpointer fn_data); - -CalListener *cal_listener_new (CalListenerCalSetModeFn cal_set_mode_fn, - CalListenerErrorOccurredFn error_occurred_fn, - CalListenerCategoriesChangedFn categories_changed_fn, - gpointer fn_data); - -void cal_listener_stop_notification (CalListener *listener); - - - -G_END_DECLS - -#endif diff --git a/calendar/cal-client/cal-marshal.list b/calendar/cal-client/cal-marshal.list deleted file mode 100644 index e0ca019669..0000000000 --- a/calendar/cal-client/cal-marshal.list +++ /dev/null @@ -1,6 +0,0 @@ -NONE:INT -NONE:POINTER -NONE:INT,STRING -NONE:INT,BOOL -NONE:INT,POINTER -NONE:STRING,INT diff --git a/calendar/cal-client/cal-query.c b/calendar/cal-client/cal-query.c deleted file mode 100644 index e77f5ad3e9..0000000000 --- a/calendar/cal-client/cal-query.c +++ /dev/null @@ -1,374 +0,0 @@ -/* Evolution calendar - Live query client object - * - * Copyright (C) 2001 Ximian, Inc. - * - * Author: Federico Mena-Quintero <federico@ximian.com> - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of version 2 of the GNU General Public - * License as published by the Free Software Foundation. - * - * 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA. - */ - -#ifdef HAVE_CONFIG_H -#include <config.h> -#endif - -#include <string.h> -#include <bonobo/bonobo-exception.h> -#include "cal-marshal.h" -#include "cal-client.h" -#include "cal-query.h" -#include "query-listener.h" - - - -/* Private part of the CalQuery structure */ -struct _CalQueryPrivate { - /* Handle to the query in the server */ - GNOME_Evolution_Calendar_Query query; - - /* Our query listener implementation */ - QueryListener *listener; - - /* The CalClient associated with this query */ - CalClient *client; -}; - -/* Property IDs */ -enum props { - PROP_0, - PROP_QUERY, - PROP_LISTENER, - PROP_CLIENT -}; - -/* Signal IDs */ -enum { - OBJECTS_ADDED, - OBJECTS_MODIFIED, - OBJECTS_REMOVED, - QUERY_PROGRESS, - QUERY_DONE, - LAST_SIGNAL -}; - -static guint signals[LAST_SIGNAL]; - -static GObjectClass *parent_class; - - - -static void -objects_added_cb (QueryListener *listener, GList *objects, gpointer data) -{ - CalQuery *query; - - query = CAL_QUERY (data); - - g_signal_emit (G_OBJECT (query), signals[OBJECTS_ADDED], 0, objects); -} - -static void -objects_modified_cb (QueryListener *listener, GList *objects, gpointer data) -{ - CalQuery *query; - - query = CAL_QUERY (data); - - g_signal_emit (G_OBJECT (query), signals[OBJECTS_MODIFIED], 0, objects); -} - -static void -objects_removed_cb (QueryListener *listener, GList *uids, gpointer data) -{ - CalQuery *query; - - query = CAL_QUERY (data); - - g_signal_emit (G_OBJECT (query), signals[OBJECTS_REMOVED], 0, uids); -} - -static void -query_progress_cb (QueryListener *listener, const char *message, int percent, gpointer data) -{ - CalQuery *query; - - query = CAL_QUERY (data); - - g_signal_emit (G_OBJECT (query), signals[QUERY_PROGRESS], 0, message, percent); -} - -static void -query_done_cb (QueryListener *listener, ECalendarStatus status, gpointer data) -{ - CalQuery *query; - - query = CAL_QUERY (data); - - g_signal_emit (G_OBJECT (query), signals[QUERY_DONE], 0, status); -} - -/* Object initialization function for the calendar query */ -static void -cal_query_init (CalQuery *query, CalQueryClass *klass) -{ - CalQueryPrivate *priv; - - priv = g_new0 (CalQueryPrivate, 1); - query->priv = priv; - - priv->listener = NULL; - priv->query = CORBA_OBJECT_NIL; -} - -static void -cal_query_set_property (GObject *object, guint property_id, const GValue *value, GParamSpec *pspec) -{ - CalQuery *query; - CalQueryPrivate *priv; - - query = CAL_QUERY (object); - priv = query->priv; - - switch (property_id) { - case PROP_QUERY: - priv->query = bonobo_object_dup_ref (g_value_get_pointer (value), NULL); - break; - case PROP_LISTENER: - priv->listener = bonobo_object_ref (g_value_get_pointer (value)); - - g_signal_connect (G_OBJECT (priv->listener), "objects_added", - G_CALLBACK (objects_added_cb), query); - g_signal_connect (G_OBJECT (priv->listener), "objects_modified", - G_CALLBACK (objects_modified_cb), query); - g_signal_connect (G_OBJECT (priv->listener), "objects_removed", - G_CALLBACK (objects_removed_cb), query); - g_signal_connect (G_OBJECT (priv->listener), "query_progress", - G_CALLBACK (query_progress_cb), query); - g_signal_connect (G_OBJECT (priv->listener), "query_done", - G_CALLBACK (query_done_cb), query); - break; - case PROP_CLIENT: - priv->client = CAL_CLIENT (g_value_dup_object (value)); - break; - default: - G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec); - break; - } -} - -static void -cal_query_get_property (GObject *object, guint property_id, GValue *value, GParamSpec *pspec) -{ - CalQuery *query; - CalQueryPrivate *priv; - - query = CAL_QUERY (object); - priv = query->priv; - - switch (property_id) { - case PROP_QUERY: - g_value_set_pointer (value, priv->query); - break; - case PROP_LISTENER: - g_value_set_pointer (value, priv->listener); - break; - case PROP_CLIENT: - g_value_set_object (value, priv->client); - break; - default: - G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec); - break; - } -} - - -/* Finalize handler for the calendar query */ -static void -cal_query_finalize (GObject *object) -{ - CalQuery *query; - CalQueryPrivate *priv; - - g_return_if_fail (object != NULL); - g_return_if_fail (IS_CAL_QUERY (object)); - - query = CAL_QUERY (object); - priv = query->priv; - - /* The server keeps a copy of the query listener, so we must unref it */ - g_signal_handlers_disconnect_matched (priv->listener, G_SIGNAL_MATCH_DATA, 0, 0, NULL, NULL, query); - bonobo_object_unref (BONOBO_OBJECT (priv->listener)); - - if (priv->query != CORBA_OBJECT_NIL) - bonobo_object_release_unref (priv->query, NULL); - - g_free (priv); - - if (G_OBJECT_CLASS (parent_class)->finalize) - (* G_OBJECT_CLASS (parent_class)->finalize) (object); -} - -/* Class initialization function for the calendar query */ -static void -cal_query_class_init (CalQueryClass *klass) -{ - GObjectClass *object_class; - GParamSpec *param; - - object_class = (GObjectClass *) klass; - - parent_class = g_type_class_peek_parent (klass); - - object_class->set_property = cal_query_set_property; - object_class->get_property = cal_query_get_property; - object_class->finalize = cal_query_finalize; - - param = g_param_spec_pointer ("query", NULL, NULL, - G_PARAM_READABLE | G_PARAM_WRITABLE | G_PARAM_CONSTRUCT_ONLY); - g_object_class_install_property (object_class, PROP_QUERY, param); - param = g_param_spec_pointer ("listener", NULL, NULL, - G_PARAM_READABLE | G_PARAM_WRITABLE | G_PARAM_CONSTRUCT_ONLY); - g_object_class_install_property (object_class, PROP_LISTENER, param); - param = g_param_spec_object ("client", NULL, NULL, CAL_CLIENT_TYPE, - G_PARAM_READABLE | G_PARAM_WRITABLE | G_PARAM_CONSTRUCT_ONLY); - g_object_class_install_property (object_class, PROP_CLIENT, param); - - signals[OBJECTS_ADDED] = - g_signal_new ("objects_added", - G_TYPE_FROM_CLASS (klass), - G_SIGNAL_RUN_FIRST, - G_STRUCT_OFFSET (CalQueryClass, objects_added), - NULL, NULL, - cal_marshal_VOID__POINTER, - G_TYPE_NONE, 1, G_TYPE_POINTER); - signals[OBJECTS_MODIFIED] = - g_signal_new ("objects_modified", - G_TYPE_FROM_CLASS (klass), - G_SIGNAL_RUN_FIRST, - G_STRUCT_OFFSET (CalQueryClass, objects_modified), - NULL, NULL, - cal_marshal_VOID__POINTER, - G_TYPE_NONE, 1, G_TYPE_POINTER); - signals[OBJECTS_REMOVED] = - g_signal_new ("objects_removed", - G_TYPE_FROM_CLASS (klass), - G_SIGNAL_RUN_FIRST, - G_STRUCT_OFFSET (CalQueryClass, objects_removed), - NULL, NULL, - cal_marshal_VOID__POINTER, - G_TYPE_NONE, 1, G_TYPE_POINTER); - signals[QUERY_PROGRESS] = - g_signal_new ("query_progress", - G_TYPE_FROM_CLASS (klass), - G_SIGNAL_RUN_FIRST, - G_STRUCT_OFFSET (CalQueryClass, query_progress), - NULL, NULL, - cal_marshal_VOID__POINTER, - G_TYPE_NONE, 2, G_TYPE_STRING, G_TYPE_INT); - signals[QUERY_DONE] = - g_signal_new ("query_done", - G_TYPE_FROM_CLASS (klass), - G_SIGNAL_RUN_FIRST, - G_STRUCT_OFFSET (CalQueryClass, query_done), - NULL, NULL, - cal_marshal_VOID__INT, - G_TYPE_NONE, 1, G_TYPE_INT); -} - -/** - * cal_query_get_type: - * - * Registers the #CalQuery class if necessary, and returns the type ID assigned - * to it. - * - * Return value: The type ID of the #CalQuery class. - **/ -GType -cal_query_get_type (void) -{ - static GType cal_query_type = 0; - - if (!cal_query_type) { - static GTypeInfo info = { - sizeof (CalQueryClass), - (GBaseInitFunc) NULL, - (GBaseFinalizeFunc) NULL, - (GClassInitFunc) cal_query_class_init, - NULL, NULL, - sizeof (CalQuery), - 0, - (GInstanceInitFunc) cal_query_init - }; - cal_query_type = g_type_register_static (G_TYPE_OBJECT, "CalQuery", &info, 0); - } - - return cal_query_type; -} - -/** - * cal_query_new: - * @client: Client from which the query is being created. - * @cal: Handle to an open calendar. - * @sexp: S-expression that defines the query. - * - * Creates a new query object by issuing the query creation request to the - * calendar server. - * - * Return value: A newly-created query object, or NULL if the request failed. - **/ -CalQuery * -cal_query_new (GNOME_Evolution_Calendar_Query corba_query, QueryListener *listener, CalClient *client) -{ - CalQuery *query; - - query = g_object_new (CAL_QUERY_TYPE, "query", corba_query, "listener", - listener, "client", client, NULL); - - return query; -} - -/** - * cal_query_get_client - * @query: A #CalQuery object. - * - * Get the #CalClient associated with this query. - * - * Returns: the associated client. - */ -CalClient * -cal_query_get_client (CalQuery *query) -{ - g_return_val_if_fail (IS_CAL_QUERY (query), NULL); - - return query->priv->client; -} - -void -cal_query_start (CalQuery *query) -{ - CalQueryPrivate *priv; - CORBA_Environment ev; - - g_return_if_fail (query != NULL); - g_return_if_fail (IS_CAL_QUERY (query)); - - priv = query->priv; - - CORBA_exception_init (&ev); - - GNOME_Evolution_Calendar_Query_start (priv->query, &ev); - if (BONOBO_EX (&ev)) - g_warning (G_STRLOC ": Unable to start query"); - - CORBA_exception_free (&ev); -} diff --git a/calendar/cal-client/cal-query.h b/calendar/cal-client/cal-query.h deleted file mode 100644 index 05390dd12a..0000000000 --- a/calendar/cal-client/cal-query.h +++ /dev/null @@ -1,69 +0,0 @@ -/* Evolution calendar - Live query client object - * - * Copyright (C) 2001 Ximian, Inc. - * - * Author: Federico Mena-Quintero <federico@ximian.com> - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of version 2 of the GNU General Public - * License as published by the Free Software Foundation. - * - * 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA. - */ - -#ifndef CAL_QUERY_H -#define CAL_QUERY_H - -#include <glib-object.h> -#include "cal-client-types.h" -#include "query-listener.h" -#include "evolution-calendar.h" - -G_BEGIN_DECLS - -typedef struct _CalClient CalClient; - - - -#define CAL_QUERY_TYPE (cal_query_get_type ()) -#define CAL_QUERY(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), CAL_QUERY_TYPE, CalQuery)) -#define CAL_QUERY_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), CAL_QUERY_TYPE, CalQueryClass)) -#define IS_CAL_QUERY(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), CAL_QUERY_TYPE)) -#define IS_CAL_QUERY_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), CAL_QUERY_TYPE)) - -typedef struct _CalQueryPrivate CalQueryPrivate; - -typedef struct { - GObject object; - - /* Private data */ - CalQueryPrivate *priv; -} CalQuery; - -typedef struct { - GObjectClass parent_class; - - /* Notification signals */ - void (* objects_added) (CalQuery *query, GList *objects); - void (* objects_modified) (CalQuery *query, GList *objects); - void (* objects_removed) (CalQuery *query, GList *uids); - void (* query_progress) (CalQuery *query, char *message, int percent); - void (* query_done) (CalQuery *query, ECalendarStatus status); -} CalQueryClass; - -GType cal_query_get_type (void); - -CalQuery *cal_query_new (GNOME_Evolution_Calendar_Query corba_query, QueryListener *listener, CalClient *client); -CalClient *cal_query_get_client (CalQuery *query); -void cal_query_start (CalQuery *query); - -G_END_DECLS - -#endif diff --git a/calendar/cal-client/client-test.c b/calendar/cal-client/client-test.c deleted file mode 100644 index 48763be50a..0000000000 --- a/calendar/cal-client/client-test.c +++ /dev/null @@ -1,218 +0,0 @@ -/* Evolution calendar client - test program - * - * Copyright (C) 2000 Ximian, Inc. - * Copyright (C) 2000 Ximian, Inc. - * - * Author: Federico Mena-Quintero <federico@ximian.com> - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of version 2 of the GNU General Public - * License as published by the Free Software Foundation. - * - * 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA. - */ - -#include <config.h> -#include <stdlib.h> -#include <bonobo-activation/bonobo-activation.h> -#include <bonobo/bonobo-i18n.h> -#include <bonobo/bonobo-main.h> -#include "cal-client.h" -#include "cal-util/cal-component.h" - -static CalClient *client1; -static CalClient *client2; - -/* Prints a message with a client identifier */ -static void -cl_printf (CalClient *client, const char *format, ...) -{ - va_list args; - - va_start (args, format); - printf ("Client %s: ", - client == client1 ? "1" : - client == client2 ? "2" : - "UNKNOWN"); - vprintf (format, args); - va_end (args); -} - -static void -objects_added_cb (GObject *object, GList *objects, gpointer data) -{ - GList *l; - - for (l = objects; l; l = l->next) - cl_printf (data, "Object added %s\n", icalcomponent_get_uid (l->data)); -} - -static void -objects_modified_cb (GObject *object, GList *objects, gpointer data) -{ - GList *l; - - for (l = objects; l; l = l->next) - cl_printf (data, "Object modified %s\n", icalcomponent_get_uid (l->data)); -} - -static void -objects_removed_cb (GObject *object, GList *objects, gpointer data) -{ - GList *l; - - for (l = objects; l; l = l->next) - cl_printf (data, "Object removed %s\n", icalcomponent_get_uid (l->data)); -} - -static void -query_done_cb (GObject *object, ECalendarStatus status, gpointer data) -{ - cl_printf (data, "Query done\n"); -} - -/* Lists the UIDs of objects in a calendar, called as an idle handler */ -static gboolean -list_uids (gpointer data) -{ - CalClient *client; - GList *objects = NULL; - GList *l; - - client = CAL_CLIENT (data); - - g_message ("Blah"); - - if (!cal_client_get_object_list (client, "(contains? \"any\" \"Test4\")", &objects, NULL)) - return FALSE; - - cl_printf (client, "UIDS: "); - - if (!objects) - printf ("none\n"); - else { - for (l = objects; l; l = l->next) { - const char *uid; - - uid = icalcomponent_get_uid (l->data); - printf ("`%s' ", uid); - } - - printf ("\n"); - - for (l = objects; l; l = l->next) { - printf ("------------------------------\n"); - printf ("%s", icalcomponent_as_ical_string (l->data)); - printf ("------------------------------\n"); - } - } - - cal_client_free_object_list (objects); - - g_object_unref (client); - - return FALSE; -} - -/* Callback used when a calendar is opened */ -static void -cal_opened_cb (CalClient *client, CalClientOpenStatus status, gpointer data) -{ - CalQuery *query; - - cl_printf (client, "Load/create %s\n", - ((status == CAL_CLIENT_OPEN_SUCCESS) ? "success" : - (status == CAL_CLIENT_OPEN_ERROR) ? "error" : - (status == CAL_CLIENT_OPEN_NOT_FOUND) ? "not found" : - (status == CAL_CLIENT_OPEN_METHOD_NOT_SUPPORTED) ? "method not supported" : - "unknown status value")); - - if (status == CAL_CLIENT_OPEN_SUCCESS) { - if (!cal_client_get_query (client, "(contains? \"any\" \"Test4\")", &query, NULL)) - g_warning (G_STRLOC ": Unable to obtain query"); - - g_signal_connect (G_OBJECT (query), "objects_added", - G_CALLBACK (objects_added_cb), client); - g_signal_connect (G_OBJECT (query), "objects_modified", - G_CALLBACK (objects_modified_cb), client); - g_signal_connect (G_OBJECT (query), "objects_removed", - G_CALLBACK (objects_removed_cb), client); - g_signal_connect (G_OBJECT (query), "query_done", - G_CALLBACK (query_done_cb), client); - - cal_query_start (query); - - g_idle_add (list_uids, client); - } - else - g_object_unref (client); -} - -/* Callback used when a client is destroyed */ -static void -client_destroy_cb (gpointer data, GObject *object) -{ - if (CAL_CLIENT (object) == client1) - client1 = NULL; - else if (CAL_CLIENT (object) == client2) - client2 = NULL; - else - g_assert_not_reached (); - - if (!client1 && !client2) - bonobo_main_quit (); -} - -/* Creates a calendar client and tries to load the specified URI into it */ -static void -create_client (CalClient **client, const char *uri, CalObjType type, gboolean only_if_exists) -{ - *client = cal_client_new (uri, type); - if (!*client) { - g_message (G_STRLOC ": could not create the client"); - exit (1); - } - - g_object_weak_ref (G_OBJECT (*client), client_destroy_cb, NULL); - - g_signal_connect (*client, "cal_opened", - G_CALLBACK (cal_opened_cb), - NULL); - - printf ("Calendar loading `%s'...\n", uri); - - if (!cal_client_open (*client, only_if_exists, NULL)) { - g_message (G_STRLOC ": failure when issuing calendar open request `%s'", - uri); - exit (1); - } -} - -int -main (int argc, char **argv) -{ - bindtextdomain (GETTEXT_PACKAGE, EVOLUTION_LOCALEDIR); - textdomain (GETTEXT_PACKAGE); - - g_type_init (); - bonobo_activation_init (argc, argv); - - if (!bonobo_init (&argc, argv)) { - g_message ("main(): could not initialize Bonobo"); - exit (1); - } - - create_client (&client1, "file:///home/gnome24-evolution-new-calendar/evolution/local/Calendar", - CALOBJ_TYPE_EVENT, FALSE); -// create_client (&client2, "file:///tmp/tasks", TRUE); - - bonobo_main (); - return 0; -} diff --git a/calendar/cal-client/query-listener.c b/calendar/cal-client/query-listener.c deleted file mode 100644 index 4c8cbb4fe5..0000000000 --- a/calendar/cal-client/query-listener.c +++ /dev/null @@ -1,304 +0,0 @@ -/* Evolution calendar - Live search query listener convenience object - * - * Copyright (C) 2001 Ximian, Inc. - * - * Author: Federico Mena-Quintero <federico@ximian.com> - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of version 2 of the GNU General Public - * License as published by the Free Software Foundation. - * - * 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA. - */ - -#ifdef HAVE_CONFIG_H -#include <config.h> -#endif - -#include "cal-marshal.h" -#include "query-listener.h" - - - -/* Private part of the QueryListener structure */ - -struct _QueryListenerPrivate { - int dummy; -}; - -/* Signal IDs */ -enum { - OBJECTS_ADDED, - OBJECTS_MODIFIED, - OBJECTS_REMOVED, - QUERY_PROGRESS, - QUERY_DONE, - LAST_SIGNAL -}; - -static guint signals[LAST_SIGNAL] = { 0 }; - -static BonoboObjectClass *parent_class; - -/* CORBA method implementations */ -/* FIXME This is duplicated from cal-listener.c */ -static ECalendarStatus -convert_status (const GNOME_Evolution_Calendar_CallStatus status) -{ - switch (status) { - case GNOME_Evolution_Calendar_Success: - return E_CALENDAR_STATUS_OK; - case GNOME_Evolution_Calendar_RepositoryOffline: - return E_CALENDAR_STATUS_REPOSITORY_OFFLINE; - case GNOME_Evolution_Calendar_PermissionDenied: - return E_CALENDAR_STATUS_PERMISSION_DENIED; - case GNOME_Evolution_Calendar_ObjectNotFound: - return E_CALENDAR_STATUS_OBJECT_NOT_FOUND; - case GNOME_Evolution_Calendar_CardIdAlreadyExists: - return E_CALENDAR_STATUS_CARD_ID_ALREADY_EXISTS; - case GNOME_Evolution_Calendar_AuthenticationFailed: - return E_CALENDAR_STATUS_AUTHENTICATION_FAILED; - case GNOME_Evolution_Calendar_AuthenticationRequired: - return E_CALENDAR_STATUS_AUTHENTICATION_REQUIRED; - case GNOME_Evolution_Calendar_OtherError: - default: - return E_CALENDAR_STATUS_OTHER_ERROR; - } -} - -/* FIXME This is duplicated from cal-listener.c */ -static GList * -build_object_list (const GNOME_Evolution_Calendar_stringlist *seq) -{ - GList *list; - int i; - - list = NULL; - for (i = 0; i < seq->_length; i++) { - icalcomponent *comp; - - comp = icalcomponent_new_from_string (seq->_buffer[i]); - if (!comp) - continue; - - list = g_list_prepend (list, comp); - } - - return list; -} - -static GList * -build_uid_list (const GNOME_Evolution_Calendar_CalObjUIDSeq *seq) -{ - GList *list; - int i; - - list = NULL; - for (i = 0; i < seq->_length; i++) - list = g_list_prepend (list, g_strdup (seq->_buffer[i])); - - return list; -} - -static void -impl_notifyObjectsAdded (PortableServer_Servant servant, - const GNOME_Evolution_Calendar_stringlist *objects, - CORBA_Environment *ev) -{ - QueryListener *ql; - QueryListenerPrivate *priv; - GList *object_list, *l; - - ql = QUERY_LISTENER (bonobo_object_from_servant (servant)); - priv = ql->priv; - - object_list = build_object_list (objects); - - g_signal_emit (G_OBJECT (ql), signals[OBJECTS_ADDED], 0, object_list); - - for (l = object_list; l; l = l->next) - icalcomponent_free (l->data); - g_list_free (object_list); -} - -static void -impl_notifyObjectsModified (PortableServer_Servant servant, - const GNOME_Evolution_Calendar_stringlist *objects, - CORBA_Environment *ev) -{ - QueryListener *ql; - QueryListenerPrivate *priv; - GList *object_list, *l; - - ql = QUERY_LISTENER (bonobo_object_from_servant (servant)); - priv = ql->priv; - - object_list = build_object_list (objects); - - g_signal_emit (G_OBJECT (ql), signals[OBJECTS_MODIFIED], 0, object_list); - - for (l = object_list; l; l = l->next) - icalcomponent_free (l->data); - g_list_free (object_list); -} - -static void -impl_notifyObjectsRemoved (PortableServer_Servant servant, - const GNOME_Evolution_Calendar_CalObjUIDSeq *uids, - CORBA_Environment *ev) -{ - QueryListener *ql; - QueryListenerPrivate *priv; - GList *uid_list, *l; - - ql = QUERY_LISTENER (bonobo_object_from_servant (servant)); - priv = ql->priv; - - uid_list = build_uid_list (uids); - - g_signal_emit (G_OBJECT (ql), signals[OBJECTS_REMOVED], 0, uid_list); - - for (l = uid_list; l; l = l->next) - g_free (l->data); - g_list_free (uid_list); -} - -static void -impl_notifyQueryProgress (PortableServer_Servant servant, - const CORBA_char *message, - const CORBA_short percent, - CORBA_Environment *ev) -{ - QueryListener *ql; - QueryListenerPrivate *priv; - - ql = QUERY_LISTENER (bonobo_object_from_servant (servant)); - priv = ql->priv; - - g_signal_emit (G_OBJECT (ql), signals[QUERY_PROGRESS], 0, message, percent); -} - -static void -impl_notifyQueryDone (PortableServer_Servant servant, - const GNOME_Evolution_Calendar_CallStatus status, - CORBA_Environment *ev) -{ - QueryListener *ql; - QueryListenerPrivate *priv; - - ql = QUERY_LISTENER (bonobo_object_from_servant (servant)); - priv = ql->priv; - - g_signal_emit (G_OBJECT (ql), signals[QUERY_DONE], 0, convert_status (status)); -} - -/* Object initialization function for the live search query listener */ -static void -query_listener_init (QueryListener *ql, QueryListenerClass *class) -{ - QueryListenerPrivate *priv; - - priv = g_new0 (QueryListenerPrivate, 1); - ql->priv = priv; -} - -/* Finalize handler for the live search query listener */ -static void -query_listener_finalize (GObject *object) -{ - QueryListener *ql; - QueryListenerPrivate *priv; - - g_return_if_fail (object != NULL); - g_return_if_fail (IS_QUERY_LISTENER (object)); - - ql = QUERY_LISTENER (object); - priv = ql->priv; - - g_free (priv); - - if (G_OBJECT_CLASS (parent_class)->finalize) - (* G_OBJECT_CLASS (parent_class)->finalize) (object); -} - -/* Class initialization function for the live search query listener */ -static void -query_listener_class_init (QueryListenerClass *klass) -{ - GObjectClass *object_class; - - object_class = (GObjectClass *) klass; - - parent_class = g_type_class_peek_parent (klass); - - object_class->finalize = query_listener_finalize; - - klass->epv.notifyObjectsAdded = impl_notifyObjectsAdded; - klass->epv.notifyObjectsModified = impl_notifyObjectsModified; - klass->epv.notifyObjectsRemoved = impl_notifyObjectsRemoved; - klass->epv.notifyQueryProgress = impl_notifyQueryProgress; - klass->epv.notifyQueryDone = impl_notifyQueryDone; - - signals[OBJECTS_ADDED] = - g_signal_new ("objects_added", - G_TYPE_FROM_CLASS (klass), - G_SIGNAL_RUN_FIRST, - G_STRUCT_OFFSET (QueryListenerClass, objects_added), - NULL, NULL, - cal_marshal_VOID__POINTER, - G_TYPE_NONE, 1, G_TYPE_POINTER); - signals[OBJECTS_MODIFIED] = - g_signal_new ("objects_modified", - G_TYPE_FROM_CLASS (klass), - G_SIGNAL_RUN_FIRST, - G_STRUCT_OFFSET (QueryListenerClass, objects_modified), - NULL, NULL, - cal_marshal_VOID__POINTER, - G_TYPE_NONE, 1, G_TYPE_POINTER); - signals[OBJECTS_REMOVED] = - g_signal_new ("objects_removed", - G_TYPE_FROM_CLASS (klass), - G_SIGNAL_RUN_FIRST, - G_STRUCT_OFFSET (QueryListenerClass, objects_removed), - NULL, NULL, - cal_marshal_VOID__POINTER, - G_TYPE_NONE, 1, G_TYPE_POINTER); - signals[QUERY_PROGRESS] = - g_signal_new ("query_progress", - G_TYPE_FROM_CLASS (klass), - G_SIGNAL_RUN_FIRST, - G_STRUCT_OFFSET (QueryListenerClass, query_progress), - NULL, NULL, - cal_marshal_VOID__POINTER, - G_TYPE_NONE, 2, G_TYPE_STRING, G_TYPE_INT); - signals[QUERY_DONE] = - g_signal_new ("query_done", - G_TYPE_FROM_CLASS (klass), - G_SIGNAL_RUN_FIRST, - G_STRUCT_OFFSET (QueryListenerClass, query_done), - NULL, NULL, - cal_marshal_VOID__INT, - G_TYPE_NONE, 1, G_TYPE_INT); -} - -BONOBO_TYPE_FUNC_FULL (QueryListener, - GNOME_Evolution_Calendar_QueryListener, - BONOBO_TYPE_OBJECT, - query_listener); - -QueryListener * -query_listener_new (void) -{ - QueryListener *ql; - - ql = g_object_new (QUERY_LISTENER_TYPE, NULL); - - return ql; -} diff --git a/calendar/cal-client/query-listener.h b/calendar/cal-client/query-listener.h deleted file mode 100644 index 6a204bbf77..0000000000 --- a/calendar/cal-client/query-listener.h +++ /dev/null @@ -1,69 +0,0 @@ -/* Evolution calendar - Live search query listener implementation - * - * Copyright (C) 2001 Ximian, Inc. - * - * Author: Federico Mena-Quintero <federico@ximian.com> - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of version 2 of the GNU General Public - * License as published by the Free Software Foundation. - * - * 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA. - */ - -#ifndef QUERY_LISTENER_H -#define QUERY_LISTENER_H - -#include <bonobo/bonobo-object.h> -#include "cal-client-types.h" -#include "evolution-calendar.h" - -G_BEGIN_DECLS - - - -#define QUERY_LISTENER_TYPE (query_listener_get_type ()) -#define QUERY_LISTENER(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), QUERY_LISTENER_TYPE, QueryListener)) -#define QUERY_LISTENER_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), QUERY_LISTENER_TYPE, \ - QueryListenerClass)) -#define IS_QUERY_LISTENER(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), QUERY_LISTENER_TYPE)) -#define IS_QUERY_LISTENER_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), QUERY_LISTENER_TYPE)) - -typedef struct _QueryListenerPrivate QueryListenerPrivate; - -typedef struct { - BonoboObject xobject; - - /* Private data */ - QueryListenerPrivate *priv; -} QueryListener; - -typedef struct { - BonoboObjectClass parent_class; - - POA_GNOME_Evolution_Calendar_QueryListener__epv epv; - - void (*objects_added) (QueryListener *listener, GList *objects); - void (*objects_modified) (QueryListener *listener, GList *objects); - void (*objects_removed) (QueryListener *listener, GList *uids); - void (*query_progress) (QueryListener *listener, const char *message, int percent); - void (*query_done) (QueryListener *listener, ECalendarStatus status); -} QueryListenerClass; - -/* Notification functions */ - -GType query_listener_get_type (void); -QueryListener *query_listener_new (void); - - - -G_END_DECLS - -#endif diff --git a/calendar/cal-client/test.ics b/calendar/cal-client/test.ics deleted file mode 100644 index 128251ee11..0000000000 --- a/calendar/cal-client/test.ics +++ /dev/null @@ -1,318 +0,0 @@ -BEGIN:VCALENDAR -VERSION:2.0 -PRODID:-//hacksw/handcal//NONSGML v1.0//EN - -BEGIN:VEVENT -DTSTART:19970714T170000Z -DTEND:19970715T035959Z -SUMMARY:Bastille Day Party -END:VEVENT - -BEGIN:VEVENT -UID:19970901T130000Z-123401@host.com -DTSTAMP:19970901T1300Z -DTSTART:19970903T163000Z -DTEND:19970903T190000Z -SUMMARY:Annual Employee Review -CLASS:PRIVATE -CATEGORIES:BUSINESS,HUMAN RESOURCES -END:VEVENT - -BEGIN:VEVENT -UID:19970901T130000Z-123402@host.com -DTSTAMP:19970901T1300Z -DTSTART:19970401T163000Z -DTEND:19970402T010000Z -SUMMARY:Laurel is in sensitivity awareness class. -CLASS:PUBLIC -CATEGORIES:BUSINESS,HUMAN RESOURCES -TRANSP:TRANSPARENT -END:VEVENT - -BEGIN:VEVENT -UID:19970901T130000Z-123403@host.com -DTSTAMP:19970901T1300Z -DTSTART:19971102 -SUMMARY:Our Blissful Anniversary -CLASS:CONFIDENTIAL -CATEGORIES:ANNIVERSARY,PERSONAL,SPECIAL OCCASION -RRULE:FREQ=YEARLY -END:VEVENT - -BEGIN:VTODO -UID:19970901T130000Z-123404@host.com -DTSTAMP:19970901T1300Z -DTSTART:19970415T133000Z -DUE:19970416T045959Z -SUMMARY:1996 Income Tax Preparation -CLASS:CONFIDENTIAL -CATEGORIES:FAMILY,FINANCE -PRIORITY:1 -STATUS:NEEDS-ACTION -END:VTODO - -BEGIN:VJOURNAL -UID:19970901T130000Z-123405@host.com -DTSTAMP:19970901T1300Z -DTSTART;VALUE=DATE:19970317 -SUMMARY:Staff meeting minutes -DESCRIPTION:1. Staff meeting: Participants include Joe\, Lisa - and Bob. Aurora project plans were reviewed. There is currently - no budget reserves for this project. Lisa will escalate to - management. Next meeting on Tuesday.\n - 2. Telephone Conference: ABC Corp. sales representative called - to discuss new printer. Promised to get us a demo by Friday.\n - 3. Henry Miller (Handsoff Insurance): Car was totaled by tree. - Is looking into a loaner car. 654-2323 (tel). -END:VJOURNAL - -BEGIN:VFREEBUSY -ORGANIZER:MAILTO:jane_doe@host1.com -ATTENDEE:MAILTO:john_public@host2.com -DTSTART:19971015T050000Z -DTEND:19971016T050000Z -DTSTAMP:19970901T083000Z -END:VFREEBUSY - -BEGIN:VFREEBUSY -ORGANIZER:MAILTO:jane_doe@host1.com -ATTENDEE:MAILTO:john_public@host2.com -DTSTAMP:19970901T100000Z -FREEBUSY;VALUE=PERIOD:19971015T050000Z/PT8H30M, - 19971015T160000Z/PT5H30M,19971015T223000Z/PT6H30M -URL:http://host2.com/pub/busy/jpublic-01.ifb -COMMENT:This iCalendar file contains busy time information for - the next three months. -END:VFREEBUSY - -BEGIN:VFREEBUSY -ORGANIZER:jsmith@host.com -DTSTART:19980313T141711Z -DTEND:19980410T141711Z -FREEBUSY:19980314T233000Z/19980315T003000Z -FREEBUSY:19980316T153000Z/19980316T163000Z -FREEBUSY:19980318T030000Z/19980318T040000Z -URL:http://www.host.com/calendar/busytime/jsmith.ifb -END:VFREEBUSY - -BEGIN:VTIMEZONE -TZID:US-Eastern -LAST-MODIFIED:19870101T000000Z -BEGIN:STANDARD -DTSTART:19971026T020000 -RDATE:19971026T020000 -TZOFFSETFROM:-0400 -TZOFFSETTO:-0500 -TZNAME:EST -END:STANDARD -BEGIN:DAYLIGHT -DTSTART:19971026T020000 -RDATE:19970406T020000 -TZOFFSETFROM:-0500 -TZOFFSETTO:-0400 -TZNAME:EDT -END:DAYLIGHT -END:VTIMEZONE - -BEGIN:VTIMEZONE -TZID:US-Eastern -LAST-MODIFIED:19870101T000000Z -TZURL:http://zones.stds_r_us.net/tz/US-Eastern -BEGIN:STANDARD -DTSTART:19671029T020000 -RRULE:FREQ=YEARLY;BYDAY=-1SU;BYMONTH=10 -TZOFFSETFROM:-0400 -TZOFFSETTO:-0500 -TZNAME:EST -END:STANDARD -BEGIN:DAYLIGHT -DTSTART:19870405T020000 -RRULE:FREQ=YEARLY;BYDAY=1SU;BYMONTH=4 -TZOFFSETFROM:-0500 -TZOFFSETTO:-0400 -TZNAME:EDT -END:DAYLIGHT -END:VTIMEZONE - -BEGIN:VTIMEZONE -TZID:US--Fictitious-Eastern -LAST-MODIFIED:19870101T000000Z -BEGIN:STANDARD -DTSTART:19671029T020000 -RRULE:FREQ=YEARLY;BYDAY=-1SU;BYMONTH=10 -TZOFFSETFROM:-0400 -TZOFFSETTO:-0500 -TZNAME:EST -END:STANDARD -BEGIN:DAYLIGHT -DTSTART:19870405T020000 -RRULE:FREQ=YEARLY;BYDAY=1SU;BYMONTH=4;UNTIL=19980404T070000Z -TZOFFSETFROM:-0500 -TZOFFSETTO:-0400 -TZNAME:EDT -END:DAYLIGHT -END:VTIMEZONE - -BEGIN:VTIMEZONE -TZID:US--Fictitious-Eastern -LAST-MODIFIED:19870101T000000Z -BEGIN:STANDARD -DTSTART:19671029T020000 -RRULE:FREQ=YEARLY;BYDAY=-1SU;BYMONTH=10 -TZOFFSETFROM:-0400 -TZOFFSETTO:-0500 -TZNAME:EST -END:STANDARD -BEGIN:DAYLIGHT -DTSTART:19870405T020000 -RRULE:FREQ=YEARLY;BYDAY=1SU;BYMONTH=4;UNTIL=19980404T070000Z -TZOFFSETFROM:-0500 -TZOFFSETTO:-0400 -TZNAME:EDT -END:DAYLIGHT -BEGIN:DAYLIGHT -DTSTART:19990424T020000 -RRULE:FREQ=YEARLY;BYDAY=-1SU;BYMONTH=4 -TZOFFSETFROM:-0500 -TZOFFSETTO:-0400 -TZNAME:EDT -END:DAYLIGHT -END:VTIMEZONE - -BEGIN:VALARM -TRIGGER;VALUE=DATE-TIME:19970317T133000Z -REPEAT:4 -DURATION:PT15M -ACTION:AUDIO -ATTACH;FMTTYPE=audio/basic:ftp://host.com/pub/sounds/bell-01.aud -END:VALARM -BEGIN:VALARM -TRIGGER:-PT30M -REPEAT:2 -DURATION:PT15M -ACTION:DISPLAY -DESCRIPTION:Breakfast meeting with executive\n - team at 8:30 AM EST. -END:VALARM - -BEGIN:VALARM -TRIGGER:-P2D -ACTION:EMAIL -ATTENDEE:MAILTO:john_doe@host.com -SUMMARY:*** REMINDER: SEND AGENDA FOR WEEKLY STAFF MEETING *** -DESCRIPTION:A draft agenda needs to be sent out to the attendees - to the weekly managers meeting (MGR-LIST). Attached is a - pointer the document template for the agenda file. -ATTACH;FMTTYPE=application/binary:http://host.com/templates/agen - da.doc -END:VALARM - -BEGIN:VALARM -TRIGGER;VALUE=DATE-TIME:19980101T050000Z -REPEAT:23 -DURATION:PT1H -ACTION:PROCEDURE -ATTACH;FMTTYPE=application/binary:ftp://host.com/novo- - procs/felizano.exe -END:VALARM - -BEGIN:VTIMEZONE -TZID:US-Eastern -BEGIN:STANDARD -DTSTART:19981025T020000 -RDATE:19981025T020000 -TZOFFSETFROM:-0400 -TZOFFSETTO:-0500 -TZNAME:EST -END:STANDARD -BEGIN:DAYLIGHT -DTSTART:19990404T020000 -RDATE:19990404T020000 -TZOFFSETFROM:-0500 -TZOFFSETTO:-0400 -TZNAME:EDT -END:DAYLIGHT -END:VTIMEZONE - -BEGIN:VEVENT -DTSTAMP:19980309T231000Z -UID:guid-1.host1.com -ORGANIZER;ROLE=CHAIR:MAILTO:mrbig@host.com -ATTENDEE;RSVP=TRUE;ROLE=REQ-PARTICIPANT;CUTYPE=GROUP: - MAILTO:employee-A@host.com -DESCRIPTION:Project XYZ Review Meeting -CATEGORIES:MEETING -CLASS:PUBLIC -CREATED:19980309T130000Z -SUMMARY:XYZ Project Review -DTSTART;TZID=US-Eastern:19980312T083000 -DTEND;TZID=US-Eastern:19980312T093000 -LOCATION:1CP Conference Room 4350 -END:VEVENT - -BEGIN:VEVENT -DTSTAMP:19970324T1200Z -SEQUENCE:0 -UID:uid3@host1.com -ORGANIZER:MAILTO:jdoe@host1.com -DTSTART:19970324T123000Z -DTEND:19970324T210000Z -CATEGORIES:MEETING,PROJECT -CLASS:PUBLIC -SUMMARY:Calendaring Interoperability Planning Meeting -DESCRIPTION:Discuss how we can test c&s interoperability\n - using iCalendar and other IETF standards. -LOCATION:LDB Lobby -ATTACH;FMTTYPE=application/postscript:ftp://xyzCorp.com/pub/ - conf/bkgrnd.ps -END:VEVENT - -BEGIN:VTODO -DTSTAMP:19980130T134500Z -SEQUENCE:2 -UID:uid4@host1.com -ORGANIZER:MAILTO:unclesam@us.gov -ATTENDEE;PARTSTAT=ACCEPTED:MAILTO:jqpublic@host.com -DUE:19980415T235959 -STATUS:NEEDS-ACTION -SUMMARY:Submit Income Taxes -BEGIN:VALARM -ACTION:AUDIO -TRIGGER:19980403T120000 -ATTACH;FMTTYPE=audio/basic:http://host.com/pub/audio- - files/ssbanner.aud -REPEAT:4 -DURATION:PT1H -END:VALARM -END:VTODO - -BEGIN:VJOURNAL -DTSTAMP:19970324T120000Z -UID:uid5@host1.com -ORGANIZER:MAILTO:jsmith@host.com -STATUS:DRAFT -CLASS:PUBLIC -CATEGORIES:Project Report, XYZ, Weekly Meeting -DESCRIPTION:Project xyz Review Meeting Minutes\n - Agenda\n1. Review of project version 1.0 requirements.\n2. - Definition - of project processes.\n3. Review of project schedule.\n - Participants: John Smith\, Jane Doe\, Jim Dandy\n-It was - decided that the requirements need to be signed off by - product marketing.\n-Project processes were accepted.\n - -Project schedule needs to account for scheduled holidays - and employee vacation time. Check with HR for specific - dates.\n-New schedule will be distributed by Friday.\n- - Next weeks meeting is cancelled. No meeting until 3/23. -END:VJOURNAL - -BEGIN:VFREEBUSY -ORGANIZER:MAILTO:jsmith@host.com -DTSTART:19980313T141711Z -DTEND:19980410T141711Z -FREEBUSY:19980314T233000Z/19980315T003000Z -FREEBUSY:19980316T153000Z/19980316T163000Z -FREEBUSY:19980318T030000Z/19980318T040000Z -URL:http://www.host.com/calendar/busytime/jsmith.ifb -END:VFREEBUSY -END:VCALENDAR diff --git a/calendar/cal-util/.cvsignore b/calendar/cal-util/.cvsignore deleted file mode 100644 index fdcaeeafc5..0000000000 --- a/calendar/cal-util/.cvsignore +++ /dev/null @@ -1,9 +0,0 @@ -.libs -Makefile.in -Makefile -.deps -*.lo -*.la -test-recur -cal-util-marshal.c -cal-util-marshal.h diff --git a/calendar/cal-util/Makefile.am b/calendar/cal-util/Makefile.am deleted file mode 100644 index 35bf23965b..0000000000 --- a/calendar/cal-util/Makefile.am +++ /dev/null @@ -1,58 +0,0 @@ -INCLUDES = \ - -DG_LOG_DOMAIN=\"cal-util\" \ - -I$(top_srcdir) \ - -I$(top_srcdir)/calendar \ - -I. \ - -I.. \ - -I$(top_builddir) \ - -I$(top_srcdir)/libical/src \ - $(EVOLUTION_CALENDAR_CFLAGS) - -AM_CFLAGS = \ - -DGTK_DISABLE_DEPRECATED=1 \ - -DGDK_DISABLE_DEPRECATED=1 \ - -DG_DISABLE_DEPRECATED=1 \ - -DGNOME_DISABLE_DEPRECATED=1 - -noinst_PROGRAMS = test-recur - -# -# cal util library -# - -privlib_LTLIBRARIES = libcal-util.la - -libcal_util_la_SOURCES = \ - cal-util-marshal.c \ - cal-util-marshal.h \ - cal-component.c \ - cal-recur.c \ - cal-util.c \ - timeutil.c - -libcal_util_la_LIBADD = \ - $(top_builddir)/libical/src/libical/libical-evolution.la - -libcal_utilincludedir = $(privincludedir)/cal-util - -libcal_utilinclude_HEADERS = \ - cal-component.h \ - cal-recur.h \ - cal-util.h \ - timeutil.h - -MARSHAL_GENERATED = cal-util-marshal.c cal-util-marshal.h -@EVO_MARSHAL_RULE@ - -BUILT_SOURCES = $(MARSHAL_GENERATED) -CLEANFILES = $(BUILT_SOURCES) - -test_recur_SOURCES = \ - test-recur.c - -test_recur_LDADD = \ - libcal-util.la \ - $(EVOLUTION_CALENDAR_LIBS) - -EXTRA_DIST = \ - cal-util-marshal.list diff --git a/calendar/cal-util/cal-component.c b/calendar/cal-util/cal-component.c deleted file mode 100644 index 22b9ee310f..0000000000 --- a/calendar/cal-util/cal-component.c +++ /dev/null @@ -1,5504 +0,0 @@ -/* Evolution calendar - iCalendar component object - * - * Copyright (C) 2000 Ximian, Inc. - * Copyright (C) 2000 Ximian, Inc. - * - * Author: Federico Mena-Quintero <federico@ximian.com> - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of version 2 of the GNU General Public - * License as published by the Free Software Foundation. - * - * 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA. - */ - -#include <config.h> -#include <string.h> -#include <stdlib.h> -#include <unistd.h> -#include <glib.h> -#include <libgnome/gnome-i18n.h> -#include "cal-component.h" -#include "timeutil.h" - - - -/* Extension property for alarm components so that we can reference them by UID */ -#define EVOLUTION_ALARM_UID_PROPERTY "X-EVOLUTION-ALARM-UID" - - -struct attendee { - icalproperty *prop; - icalparameter *cutype_param; - icalparameter *member_param; - icalparameter *role_param; - icalparameter *partstat_param; - icalparameter *rsvp_param; - icalparameter *delto_param; - icalparameter *delfrom_param; - icalparameter *sentby_param; - icalparameter *cn_param; - icalparameter *language_param; -}; - -/* Private part of the CalComponent structure */ -struct _CalComponentPrivate { - /* The icalcomponent we wrap */ - icalcomponent *icalcomp; - - /* Properties */ - - icalproperty *uid; - - icalproperty *status; - GSList *attendee_list; - - icalproperty *categories; - - icalproperty *classification; - - struct text { - icalproperty *prop; - icalparameter *altrep_param; - }; - - GSList *comment_list; /* list of struct text */ - - icalproperty *completed; - - GSList *contact_list; /* list of struct text */ - - icalproperty *created; - - GSList *description_list; /* list of struct text */ - - struct datetime { - icalproperty *prop; - icalparameter *tzid_param; - }; - - struct datetime dtstart; - struct datetime dtend; - - icalproperty *dtstamp; - - /* The DURATION property can be used instead of the VEVENT DTEND or - the VTODO DUE dates. We do not use it directly ourselves, but we - must be able to handle it from incoming data. If a DTEND or DUE - is requested, we convert the DURATION if necessary. If DTEND or - DUE is set, we remove any DURATION. */ - icalproperty *duration; - - struct datetime due; - - GSList *exdate_list; /* list of struct datetime */ - GSList *exrule_list; /* list of icalproperty objects */ - - struct organizer { - icalproperty *prop; - icalparameter *sentby_param; - icalparameter *cn_param; - icalparameter *language_param; - }; - - struct organizer organizer; - - icalproperty *geo; - icalproperty *last_modified; - icalproperty *percent; - icalproperty *priority; - - struct period { - icalproperty *prop; - icalparameter *value_param; - }; - - struct recur_id { - struct datetime recur_time; - - icalparameter *range_param; - }; - - struct recur_id recur_id; - - GSList *rdate_list; /* list of struct period */ - - GSList *rrule_list; /* list of icalproperty objects */ - - icalproperty *sequence; - - struct { - icalproperty *prop; - icalparameter *altrep_param; - } summary; - - icalproperty *transparency; - icalproperty *url; - icalproperty *location; - - /* Subcomponents */ - - GHashTable *alarm_uid_hash; - - /* Whether we should increment the sequence number when piping the - * object over the wire. - */ - guint need_sequence_inc : 1; -}; - -/* Private structure for alarms */ -struct _CalComponentAlarm { - /* Alarm icalcomponent we wrap */ - icalcomponent *icalcomp; - - /* Our extension UID property */ - icalproperty *uid; - - /* Properties */ - - icalproperty *action; - icalproperty *attach; /* FIXME: see scan_alarm_property() below */ - - struct { - icalproperty *prop; - icalparameter *altrep_param; - } description; - - icalproperty *duration; - icalproperty *repeat; - icalproperty *trigger; - - GSList *attendee_list; -}; - - - -static void cal_component_class_init (CalComponentClass *klass); -static void cal_component_init (CalComponent *comp, CalComponentClass *klass); -static void cal_component_finalize (GObject *object); - -static GObjectClass *parent_class; - - - -/** - * cal_component_get_type: - * - * Registers the #CalComponent class if necessary, and returns the type ID - * associated to it. - * - * Return value: The type ID of the #CalComponent class. - **/ -GType -cal_component_get_type (void) -{ - static GType cal_component_type = 0; - - if (!cal_component_type) { - static GTypeInfo info = { - sizeof (CalComponentClass), - (GBaseInitFunc) NULL, - (GBaseFinalizeFunc) NULL, - (GClassInitFunc) cal_component_class_init, - NULL, NULL, - sizeof (CalComponent), - 0, - (GInstanceInitFunc) cal_component_init - }; - cal_component_type = g_type_register_static (G_TYPE_OBJECT, "CalComponent", &info, 0); - } - - return cal_component_type; -} - -/* Class initialization function for the calendar component object */ -static void -cal_component_class_init (CalComponentClass *klass) -{ - GObjectClass *object_class; - - object_class = (GObjectClass *) klass; - - parent_class = g_type_class_peek_parent (klass); - - object_class->finalize = cal_component_finalize; -} - -/* Object initialization function for the calendar component object */ -static void -cal_component_init (CalComponent *comp, CalComponentClass *klass) -{ - CalComponentPrivate *priv; - - priv = g_new0 (CalComponentPrivate, 1); - comp->priv = priv; - - priv->alarm_uid_hash = g_hash_table_new (g_str_hash, g_str_equal); -} - -/* Does a simple g_free() of the elements of a GSList and then frees the list - * itself. Returns NULL. - */ -static GSList * -free_slist (GSList *slist) -{ - GSList *l; - - for (l = slist; l; l = l->next) - g_free (l->data); - - g_slist_free (slist); - return NULL; -} - -/* Used from g_hash_table_foreach_remove() to free the alarm UIDs hash table. - * We do not need to do anything to individual elements since we were storing - * the UID pointers inside the icalproperties themselves. - */ -static gboolean -free_alarm_cb (gpointer key, gpointer value, gpointer data) -{ - return TRUE; -} - -/* Frees the internal icalcomponent only if it does not have a parent. If it - * does, it means we don't own it and we shouldn't free it. - */ -static void -free_icalcomponent (CalComponent *comp, gboolean free) -{ - CalComponentPrivate *priv; - GSList *l; - - priv = comp->priv; - - if (!priv->icalcomp) - return; - - /* Free the icalcomponent */ - - if (free && icalcomponent_get_parent (priv->icalcomp) == NULL) { - icalcomponent_free (priv->icalcomp); - priv->icalcomp = NULL; - } - - /* Free the mappings */ - - priv->uid = NULL; - - priv->status = NULL; - - for (l = priv->attendee_list; l != NULL; l = l->next) - g_free (l->data); - g_slist_free (priv->attendee_list); - priv->attendee_list = NULL; - - priv->categories = NULL; - - priv->classification = NULL; - priv->comment_list = NULL; - priv->completed = NULL; - priv->contact_list = NULL; - priv->created = NULL; - - priv->description_list = free_slist (priv->description_list); - - priv->dtend.prop = NULL; - priv->dtend.tzid_param = NULL; - - priv->dtstamp = NULL; - - priv->dtstart.prop = NULL; - priv->dtstart.tzid_param = NULL; - - priv->due.prop = NULL; - priv->due.tzid_param = NULL; - - priv->duration = NULL; - - priv->exdate_list = free_slist (priv->exdate_list); - - g_slist_free (priv->exrule_list); - priv->exrule_list = NULL; - - priv->geo = NULL; - priv->last_modified = NULL; - priv->percent = NULL; - priv->priority = NULL; - - priv->rdate_list = free_slist (priv->rdate_list); - - g_slist_free (priv->rrule_list); - priv->rrule_list = NULL; - - priv->sequence = NULL; - - priv->summary.prop = NULL; - priv->summary.altrep_param = NULL; - - priv->transparency = NULL; - priv->url = NULL; - priv->location = NULL; - - /* Free the subcomponents */ - - g_hash_table_foreach_remove (priv->alarm_uid_hash, free_alarm_cb, NULL); - - /* Clean up */ - - priv->need_sequence_inc = FALSE; -} - -/* Finalize handler for the calendar component object */ -static void -cal_component_finalize (GObject *object) -{ - CalComponent *comp; - CalComponentPrivate *priv; - - g_return_if_fail (object != NULL); - g_return_if_fail (IS_CAL_COMPONENT (object)); - - comp = CAL_COMPONENT (object); - priv = comp->priv; - - free_icalcomponent (comp, TRUE); - g_hash_table_destroy (priv->alarm_uid_hash); - priv->alarm_uid_hash = NULL; - - g_free (priv); - comp->priv = NULL; - - if (G_OBJECT_CLASS (parent_class)->finalize) - (* G_OBJECT_CLASS (parent_class)->finalize) (object); -} - - - -/** - * cal_component_gen_uid: - * - * Generates a unique identifier suitable for calendar components. - * - * Return value: A unique identifier string. Every time this function is called - * a different string is returned. - **/ -char * -cal_component_gen_uid (void) -{ - char *iso, *ret; - static char *hostname; - time_t t = time (NULL); - static int serial; - - if (!hostname) { - static char buffer [512]; - - if ((gethostname (buffer, sizeof (buffer) - 1) == 0) && - (buffer [0] != 0)) - hostname = buffer; - else - hostname = "localhost"; - } - - iso = isodate_from_time_t (t); - ret = g_strdup_printf ("%s-%d-%d-%d-%d@%s", - iso, - getpid (), - getgid (), - getppid (), - serial++, - hostname); - g_free (iso); - - return ret; -} - -/** - * cal_component_new: - * - * Creates a new empty calendar component object. You should set it from an - * #icalcomponent structure by using cal_component_set_icalcomponent() or with a - * new empty component type by using cal_component_set_new_vtype(). - * - * Return value: A newly-created calendar component object. - **/ -CalComponent * -cal_component_new (void) -{ - return CAL_COMPONENT (g_object_new (CAL_COMPONENT_TYPE, NULL)); -} - -/** - * cal_component_clone: - * @comp: A calendar component object. - * - * Creates a new calendar component object by copying the information from - * another one. - * - * Return value: A newly-created calendar component with the same values as the - * original one. - **/ -CalComponent * -cal_component_clone (CalComponent *comp) -{ - CalComponentPrivate *priv; - CalComponent *new_comp; - icalcomponent *new_icalcomp; - - g_return_val_if_fail (comp != NULL, NULL); - g_return_val_if_fail (IS_CAL_COMPONENT (comp), NULL); - - priv = comp->priv; - g_return_val_if_fail (priv->need_sequence_inc == FALSE, NULL); - - new_comp = cal_component_new (); - - if (priv->icalcomp) { - new_icalcomp = icalcomponent_new_clone (priv->icalcomp); - cal_component_set_icalcomponent (new_comp, new_icalcomp); - } - - return new_comp; -} - -/* Scans an attendee property */ -static void -scan_attendee (GSList **attendee_list, icalproperty *prop) -{ - struct attendee *attendee; - - attendee = g_new (struct attendee, 1); - attendee->prop = prop; - - attendee->cutype_param = icalproperty_get_first_parameter (prop, ICAL_CUTYPE_PARAMETER); - attendee->member_param = icalproperty_get_first_parameter (prop, ICAL_MEMBER_PARAMETER); - attendee->role_param = icalproperty_get_first_parameter (prop, ICAL_ROLE_PARAMETER); - attendee->partstat_param = icalproperty_get_first_parameter (prop, ICAL_PARTSTAT_PARAMETER); - attendee->rsvp_param = icalproperty_get_first_parameter (prop, ICAL_RSVP_PARAMETER); - attendee->delto_param = icalproperty_get_first_parameter (prop, ICAL_DELEGATEDTO_PARAMETER); - attendee->delfrom_param = icalproperty_get_first_parameter (prop, ICAL_DELEGATEDFROM_PARAMETER); - attendee->sentby_param = icalproperty_get_first_parameter (prop, ICAL_SENTBY_PARAMETER); - attendee->cn_param = icalproperty_get_first_parameter (prop, ICAL_CN_PARAMETER); - attendee->language_param = icalproperty_get_first_parameter (prop, ICAL_LANGUAGE_PARAMETER); - - *attendee_list = g_slist_append (*attendee_list, attendee); -} - -/* Scans a date/time and timezone pair property */ -static void -scan_datetime (CalComponent *comp, struct datetime *datetime, icalproperty *prop) -{ - CalComponentPrivate *priv; - - priv = comp->priv; - - datetime->prop = prop; - datetime->tzid_param = icalproperty_get_first_parameter (prop, ICAL_TZID_PARAMETER); -} - -/* Scans an exception date property */ -static void -scan_exdate (CalComponent *comp, icalproperty *prop) -{ - CalComponentPrivate *priv; - struct datetime *dt; - - priv = comp->priv; - - dt = g_new (struct datetime, 1); - dt->prop = prop; - dt->tzid_param = icalproperty_get_first_parameter (prop, ICAL_TZID_PARAMETER); - - priv->exdate_list = g_slist_append (priv->exdate_list, dt); -} - -/* Scans and attendee property */ -static void -scan_organizer (CalComponent *comp, struct organizer *organizer, icalproperty *prop) -{ - organizer->prop = prop; - - organizer->sentby_param = icalproperty_get_first_parameter (prop, ICAL_SENTBY_PARAMETER); - organizer->cn_param = icalproperty_get_first_parameter (prop, ICAL_CN_PARAMETER); - organizer->language_param = icalproperty_get_first_parameter (prop, ICAL_LANGUAGE_PARAMETER); -} - -/* Scans an icalperiodtype property */ -static void -scan_period (CalComponent *comp, GSList **list, icalproperty *prop) -{ - struct period *period; - - period = g_new (struct period, 1); - period->prop = prop; - period->value_param = icalproperty_get_first_parameter (prop, ICAL_VALUE_PARAMETER); - - *list = g_slist_append (*list, period); -} - - -/* Scans an icalrecurtype property */ -static void -scan_recur_id (CalComponent *comp, struct recur_id *recur_id, icalproperty *prop) -{ - scan_datetime (comp, &recur_id->recur_time, prop); - - recur_id->range_param = icalproperty_get_first_parameter (prop, ICAL_RANGE_PARAMETER); -} - -/* Scans an icalrecurtype property */ -static void -scan_recur (CalComponent *comp, GSList **list, icalproperty *prop) -{ - *list = g_slist_append (*list, prop); -} - -/* Scans the summary property */ -static void -scan_summary (CalComponent *comp, icalproperty *prop) -{ - CalComponentPrivate *priv; - - priv = comp->priv; - - priv->summary.prop = prop; - priv->summary.altrep_param = icalproperty_get_first_parameter (prop, ICAL_ALTREP_PARAMETER); -} - -/* Scans a text (i.e. text + altrep) property */ -static void -scan_text (CalComponent *comp, GSList **text_list, icalproperty *prop) -{ - struct text *text; - - text = g_new (struct text, 1); - text->prop = prop; - text->altrep_param = icalproperty_get_first_parameter (prop, ICAL_ALTREP_PARAMETER); - - *text_list = g_slist_append (*text_list, text); -} - -/* Scans an icalproperty and adds its mapping to the component */ -static void -scan_property (CalComponent *comp, icalproperty *prop) -{ - CalComponentPrivate *priv; - icalproperty_kind kind; - - priv = comp->priv; - - kind = icalproperty_isa (prop); - - switch (kind) { - case ICAL_STATUS_PROPERTY: - priv->status = prop; - break; - - case ICAL_ATTENDEE_PROPERTY: - scan_attendee (&priv->attendee_list, prop); - break; - - case ICAL_CATEGORIES_PROPERTY: - priv->categories = prop; - break; - - case ICAL_CLASS_PROPERTY: - priv->classification = prop; - break; - - case ICAL_COMMENT_PROPERTY: - scan_text (comp, &priv->comment_list, prop); - break; - - case ICAL_COMPLETED_PROPERTY: - priv->completed = prop; - break; - - case ICAL_CONTACT_PROPERTY: - scan_text (comp, &priv->contact_list, prop); - break; - - case ICAL_CREATED_PROPERTY: - priv->created = prop; - break; - - case ICAL_DESCRIPTION_PROPERTY: - scan_text (comp, &priv->description_list, prop); - break; - - case ICAL_DTEND_PROPERTY: - scan_datetime (comp, &priv->dtend, prop); - break; - - case ICAL_DTSTAMP_PROPERTY: - priv->dtstamp = prop; - break; - - case ICAL_DTSTART_PROPERTY: - scan_datetime (comp, &priv->dtstart, prop); - break; - - case ICAL_DUE_PROPERTY: - scan_datetime (comp, &priv->due, prop); - break; - - case ICAL_DURATION_PROPERTY: - priv->duration = prop; - break; - - case ICAL_EXDATE_PROPERTY: - scan_exdate (comp, prop); - break; - - case ICAL_EXRULE_PROPERTY: - scan_recur (comp, &priv->exrule_list, prop); - break; - - case ICAL_GEO_PROPERTY: - priv->geo = prop; - break; - - case ICAL_LASTMODIFIED_PROPERTY: - priv->last_modified = prop; - break; - - case ICAL_ORGANIZER_PROPERTY: - scan_organizer (comp, &priv->organizer, prop); - break; - - case ICAL_PERCENTCOMPLETE_PROPERTY: - priv->percent = prop; - break; - - case ICAL_PRIORITY_PROPERTY: - priv->priority = prop; - break; - - case ICAL_RECURRENCEID_PROPERTY: - scan_recur_id (comp, &priv->recur_id, prop); - break; - - case ICAL_RDATE_PROPERTY: - scan_period (comp, &priv->rdate_list, prop); - break; - - case ICAL_RRULE_PROPERTY: - scan_recur (comp, &priv->rrule_list, prop); - break; - - case ICAL_SEQUENCE_PROPERTY: - priv->sequence = prop; - break; - - case ICAL_SUMMARY_PROPERTY: - scan_summary (comp, prop); - break; - - case ICAL_TRANSP_PROPERTY: - priv->transparency = prop; - break; - - case ICAL_UID_PROPERTY: - priv->uid = prop; - break; - - case ICAL_URL_PROPERTY: - priv->url = prop; - break; - - case ICAL_LOCATION_PROPERTY : - priv->location = prop; - break; - - default: - break; - } -} - -/* Gets our alarm UID string from a property that is known to contain it */ -static const char * -alarm_uid_from_prop (icalproperty *prop) -{ - const char *xstr; - - g_assert (icalproperty_isa (prop) == ICAL_X_PROPERTY); - - xstr = icalproperty_get_x (prop); - g_assert (xstr != NULL); - - return xstr; -} - -/* Sets our alarm UID extension property on an alarm component. Returns a - * pointer to the UID string inside the property itself. - */ -static const char * -set_alarm_uid (icalcomponent *alarm, const char *auid) -{ - icalproperty *prop; - const char *inprop_auid; - - /* Create the new property */ - - prop = icalproperty_new_x ((char *) auid); - icalproperty_set_x_name (prop, EVOLUTION_ALARM_UID_PROPERTY); - - icalcomponent_add_property (alarm, prop); - - inprop_auid = alarm_uid_from_prop (prop); - return inprop_auid; -} - -/* Removes any alarm UID extension properties from an alarm subcomponent */ -static void -remove_alarm_uid (icalcomponent *alarm) -{ - icalproperty *prop; - GSList *list, *l; - - list = NULL; - - for (prop = icalcomponent_get_first_property (alarm, ICAL_X_PROPERTY); - prop; - prop = icalcomponent_get_next_property (alarm, ICAL_X_PROPERTY)) { - const char *xname; - - xname = icalproperty_get_x_name (prop); - g_assert (xname != NULL); - - if (strcmp (xname, EVOLUTION_ALARM_UID_PROPERTY) == 0) - list = g_slist_prepend (list, prop); - } - - for (l = list; l; l = l->next) { - prop = l->data; - icalcomponent_remove_property (alarm, prop); - icalproperty_free (prop); - } - - g_slist_free (list); -} - -/* Adds an alarm subcomponent to the calendar component's mapping table. The - * actual UID with which it gets added may not be the same as the specified one; - * this function will change it if the table already had an alarm subcomponent - * with the specified UID. Returns the actual UID used. - */ -static const char * -add_alarm (CalComponent *comp, icalcomponent *alarm, const char *auid) -{ - CalComponentPrivate *priv; - icalcomponent *old_alarm; - - priv = comp->priv; - - /* First we see if we already have an alarm with the requested UID. In - * that case, we need to change the new UID to something else. This - * should never happen, but who knows. - */ - - old_alarm = g_hash_table_lookup (priv->alarm_uid_hash, auid); - if (old_alarm != NULL) { - char *new_auid; - - g_message ("add_alarm(): Got alarm with duplicated UID `%s', changing it...", auid); - - remove_alarm_uid (alarm); - - new_auid = cal_component_gen_uid (); - auid = set_alarm_uid (alarm, new_auid); - g_free (new_auid); - } - - g_hash_table_insert (priv->alarm_uid_hash, (char *) auid, alarm); - return auid; -} - -/* Scans an alarm subcomponent, adds an UID extension property to it (so that we - * can reference alarms by unique IDs), and adds its mapping to the component. */ -static void -scan_alarm (CalComponent *comp, icalcomponent *alarm) -{ - CalComponentPrivate *priv; - icalproperty *prop; - const char *auid; - char *new_auid; - - priv = comp->priv; - - for (prop = icalcomponent_get_first_property (alarm, ICAL_X_PROPERTY); - prop; - prop = icalcomponent_get_next_property (alarm, ICAL_X_PROPERTY)) { - const char *xname; - - xname = icalproperty_get_x_name (prop); - g_assert (xname != NULL); - - if (strcmp (xname, EVOLUTION_ALARM_UID_PROPERTY) == 0) { - auid = alarm_uid_from_prop (prop); - add_alarm (comp, alarm, auid); - return; - } - } - - /* The component has no alarm UID property, so we create one. */ - - new_auid = cal_component_gen_uid (); - auid = set_alarm_uid (alarm, new_auid); - g_free (new_auid); - - add_alarm (comp, alarm, auid); -} - -/* Scans an icalcomponent for its properties so that we can provide - * random-access to them. It also builds a hash table of the component's alarm - * subcomponents. - */ -static void -scan_icalcomponent (CalComponent *comp) -{ - CalComponentPrivate *priv; - icalproperty *prop; - icalcompiter iter; - - priv = comp->priv; - - g_assert (priv->icalcomp != NULL); - - /* Scan properties */ - - for (prop = icalcomponent_get_first_property (priv->icalcomp, ICAL_ANY_PROPERTY); - prop; - prop = icalcomponent_get_next_property (priv->icalcomp, ICAL_ANY_PROPERTY)) - scan_property (comp, prop); - - /* Scan subcomponents */ - - for (iter = icalcomponent_begin_component (priv->icalcomp, ICAL_VALARM_COMPONENT); - icalcompiter_deref (&iter) != NULL; - icalcompiter_next (&iter)) { - icalcomponent *subcomp; - - subcomp = icalcompiter_deref (&iter); - scan_alarm (comp, subcomp); - } -} - -/* Ensures that the mandatory calendar component properties (uid, dtstamp) do - * exist. If they don't exist, it creates them automatically. - */ -static void -ensure_mandatory_properties (CalComponent *comp) -{ - CalComponentPrivate *priv; - - priv = comp->priv; - g_assert (priv->icalcomp != NULL); - - if (!priv->uid) { - char *uid; - - uid = cal_component_gen_uid (); - priv->uid = icalproperty_new_uid (uid); - g_free (uid); - - icalcomponent_add_property (priv->icalcomp, priv->uid); - } - - if (!priv->dtstamp) { - struct icaltimetype t; - - t = icaltime_current_time_with_zone (icaltimezone_get_utc_timezone ()); - - priv->dtstamp = icalproperty_new_dtstamp (t); - icalcomponent_add_property (priv->icalcomp, priv->dtstamp); - } -} - -/** - * cal_component_set_new_vtype: - * @comp: A calendar component object. - * @type: Type of calendar component to create. - * - * Clears any existing component data from a calendar component object and - * creates a new #icalcomponent of the specified type for it. The only property - * that will be set in the new component will be its unique identifier. - **/ -void -cal_component_set_new_vtype (CalComponent *comp, CalComponentVType type) -{ - CalComponentPrivate *priv; - icalcomponent *icalcomp; - icalcomponent_kind kind; - - g_return_if_fail (comp != NULL); - g_return_if_fail (IS_CAL_COMPONENT (comp)); - - priv = comp->priv; - - free_icalcomponent (comp, TRUE); - - if (type == CAL_COMPONENT_NO_TYPE) - return; - - /* Figure out the kind and create the icalcomponent */ - - switch (type) { - case CAL_COMPONENT_EVENT: - kind = ICAL_VEVENT_COMPONENT; - break; - - case CAL_COMPONENT_TODO: - kind = ICAL_VTODO_COMPONENT; - break; - - case CAL_COMPONENT_JOURNAL: - kind = ICAL_VJOURNAL_COMPONENT; - break; - - case CAL_COMPONENT_FREEBUSY: - kind = ICAL_VFREEBUSY_COMPONENT; - break; - - case CAL_COMPONENT_TIMEZONE: - kind = ICAL_VTIMEZONE_COMPONENT; - break; - - default: - g_assert_not_reached (); - kind = ICAL_NO_COMPONENT; - } - - icalcomp = icalcomponent_new (kind); - if (!icalcomp) { - g_message ("cal_component_set_new_vtype(): Could not create the icalcomponent!"); - return; - } - - /* Scan the component to build our mapping table */ - - priv->icalcomp = icalcomp; - scan_icalcomponent (comp); - - /* Add missing stuff */ - - ensure_mandatory_properties (comp); -} - -/** - * cal_component_set_icalcomponent: - * @comp: A calendar component object. - * @icalcomp: An #icalcomponent. - * - * Sets the contents of a calendar component object from an #icalcomponent - * structure. If the @comp already had an #icalcomponent set into it, it will - * will be freed automatically if the #icalcomponent does not have a parent - * component itself. - * - * Supported component types are VEVENT, VTODO, VJOURNAL, VFREEBUSY, and VTIMEZONE. - * - * Return value: TRUE on success, FALSE if @icalcomp is an unsupported component - * type. - **/ -gboolean -cal_component_set_icalcomponent (CalComponent *comp, icalcomponent *icalcomp) -{ - CalComponentPrivate *priv; - icalcomponent_kind kind; - - g_return_val_if_fail (comp != NULL, FALSE); - g_return_val_if_fail (IS_CAL_COMPONENT (comp), FALSE); - - priv = comp->priv; - - if (priv->icalcomp == icalcomp) - return TRUE; - - free_icalcomponent (comp, TRUE); - - if (!icalcomp) { - priv->icalcomp = NULL; - return TRUE; - } - - kind = icalcomponent_isa (icalcomp); - - if (!(kind == ICAL_VEVENT_COMPONENT - || kind == ICAL_VTODO_COMPONENT - || kind == ICAL_VJOURNAL_COMPONENT - || kind == ICAL_VFREEBUSY_COMPONENT - || kind == ICAL_VTIMEZONE_COMPONENT)) - return FALSE; - - priv->icalcomp = icalcomp; - - scan_icalcomponent (comp); - ensure_mandatory_properties (comp); - - return TRUE; -} - -/** - * cal_component_get_icalcomponent: - * @comp: A calendar component object. - * - * Queries the #icalcomponent structure that a calendar component object is - * wrapping. - * - * Return value: An #icalcomponent structure, or NULL if the @comp has no - * #icalcomponent set to it. - **/ -icalcomponent * -cal_component_get_icalcomponent (CalComponent *comp) -{ - CalComponentPrivate *priv; - - g_return_val_if_fail (comp != NULL, NULL); - g_return_val_if_fail (IS_CAL_COMPONENT (comp), NULL); - - priv = comp->priv; - g_return_val_if_fail (priv->need_sequence_inc == FALSE, NULL); - - return priv->icalcomp; -} - -void -cal_component_rescan (CalComponent *comp) -{ - CalComponentPrivate *priv; - - g_return_if_fail (comp != NULL); - g_return_if_fail (IS_CAL_COMPONENT (comp)); - - priv = comp->priv; - - /* Clear everything out */ - free_icalcomponent (comp, FALSE); - - /* Rescan */ - scan_icalcomponent (comp); - ensure_mandatory_properties (comp); -} - -void -cal_component_strip_errors (CalComponent *comp) -{ - CalComponentPrivate *priv; - - g_return_if_fail (comp != NULL); - g_return_if_fail (IS_CAL_COMPONENT (comp)); - - priv = comp->priv; - - icalcomponent_strip_errors (priv->icalcomp); -} - -/** - * cal_component_get_vtype: - * @comp: A calendar component object. - * - * Queries the type of a calendar component object. - * - * Return value: The type of the component, as defined by RFC 2445. - **/ -CalComponentVType -cal_component_get_vtype (CalComponent *comp) -{ - CalComponentPrivate *priv; - icalcomponent_kind kind; - - g_return_val_if_fail (comp != NULL, CAL_COMPONENT_NO_TYPE); - g_return_val_if_fail (IS_CAL_COMPONENT (comp), CAL_COMPONENT_NO_TYPE); - - priv = comp->priv; - g_return_val_if_fail (priv->icalcomp != NULL, CAL_COMPONENT_NO_TYPE); - - kind = icalcomponent_isa (priv->icalcomp); - switch (kind) { - case ICAL_VEVENT_COMPONENT: - return CAL_COMPONENT_EVENT; - - case ICAL_VTODO_COMPONENT: - return CAL_COMPONENT_TODO; - - case ICAL_VJOURNAL_COMPONENT: - return CAL_COMPONENT_JOURNAL; - - case ICAL_VFREEBUSY_COMPONENT: - return CAL_COMPONENT_FREEBUSY; - - case ICAL_VTIMEZONE_COMPONENT: - return CAL_COMPONENT_TIMEZONE; - - default: - /* We should have been loaded with a supported type! */ - g_assert_not_reached (); - return CAL_COMPONENT_NO_TYPE; - } -} - -/** - * cal_component_get_as_string: - * @comp: A calendar component. - * - * Gets the iCalendar string representation of a calendar component. You should - * call cal_component_commit_sequence() before this function to ensure that the - * component's sequence number is consistent with the state of the object. - * - * Return value: String representation of the calendar component according to - * RFC 2445. - **/ -char * -cal_component_get_as_string (CalComponent *comp) -{ - CalComponentPrivate *priv; - char *str, *buf; - - g_return_val_if_fail (comp != NULL, NULL); - g_return_val_if_fail (IS_CAL_COMPONENT (comp), NULL); - - priv = comp->priv; - g_return_val_if_fail (priv->icalcomp != NULL, NULL); - - /* Ensure that the user has committed the new SEQUENCE */ - g_return_val_if_fail (priv->need_sequence_inc == FALSE, NULL); - - /* We dup the string; libical owns that memory */ - - str = icalcomponent_as_ical_string (priv->icalcomp); - - if (str) - buf = g_strdup (str); - else - buf = NULL; - - return buf; -} - -/* Used from g_hash_table_foreach(); ensures that an alarm subcomponent - * has the mandatory properties it needs. - */ -static void -ensure_alarm_properties_cb (gpointer key, gpointer value, gpointer data) -{ - CalComponent *comp; - CalComponentPrivate *priv; - icalcomponent *alarm; - icalproperty *prop; - enum icalproperty_action action; - const char *str; - - alarm = value; - - comp = CAL_COMPONENT (data); - priv = comp->priv; - - prop = icalcomponent_get_first_property (alarm, ICAL_ACTION_PROPERTY); - if (!prop) - return; - - action = icalproperty_get_action (prop); - - switch (action) { - case ICAL_ACTION_DISPLAY: - /* Ensure we have a DESCRIPTION property */ - prop = icalcomponent_get_first_property (alarm, ICAL_DESCRIPTION_PROPERTY); - if (prop) - break; - - if (!priv->summary.prop) - str = _("Untitled appointment"); - else - str = icalproperty_get_summary (priv->summary.prop); - - prop = icalproperty_new_description (str); - icalcomponent_add_property (alarm, prop); - - break; - - default: - break; - /* FIXME: add other action types here */ - } -} - -/* Ensures that alarm subcomponents have the mandatory properties they need, - * even when clients may not have set them properly. - */ -static void -ensure_alarm_properties (CalComponent *comp) -{ - CalComponentPrivate *priv; - - priv = comp->priv; - - g_hash_table_foreach (priv->alarm_uid_hash, ensure_alarm_properties_cb, comp); -} - -/** - * cal_component_commit_sequence: - * @comp: - * - * Increments the sequence number property in a calendar component object if it - * needs it. This needs to be done when any of a number of properties listed in - * RFC 2445 change values, such as the start and end dates of a component. - * - * This function must be called before calling cal_component_get_as_string() to - * ensure that the component is fully consistent. - **/ -void -cal_component_commit_sequence (CalComponent *comp) -{ - CalComponentPrivate *priv; - - g_return_if_fail (comp != NULL); - g_return_if_fail (IS_CAL_COMPONENT (comp)); - - priv = comp->priv; - g_return_if_fail (priv->icalcomp != NULL); - - ensure_alarm_properties (comp); - - if (!priv->need_sequence_inc) - return; - - if (priv->sequence) { - int seq; - - seq = icalproperty_get_sequence (priv->sequence); - icalproperty_set_sequence (priv->sequence, seq + 1); - } else { - /* The component had no SEQUENCE property, so assume that the - * default would have been zero. Since it needed incrementing - * anyways, we use a value of 1 here. - */ - priv->sequence = icalproperty_new_sequence (1); - icalcomponent_add_property (priv->icalcomp, priv->sequence); - } - - priv->need_sequence_inc = FALSE; -} - -void -cal_component_abort_sequence (CalComponent *comp) -{ - CalComponentPrivate *priv; - - g_return_if_fail (comp != NULL); - g_return_if_fail (IS_CAL_COMPONENT (comp)); - - priv = comp->priv; - - priv->need_sequence_inc = FALSE; -} - -/** - * cal_component_get_uid: - * @comp: A calendar component object. - * @uid: Return value for the UID string. - * - * Queries the unique identifier of a calendar component object. - **/ -void -cal_component_get_uid (CalComponent *comp, const char **uid) -{ - CalComponentPrivate *priv; - - g_return_if_fail (comp != NULL); - g_return_if_fail (IS_CAL_COMPONENT (comp)); - g_return_if_fail (uid != NULL); - - priv = comp->priv; - g_return_if_fail (priv->icalcomp != NULL); - - /* This MUST exist, since we ensured that it did */ - g_assert (priv->uid != NULL); - - *uid = icalproperty_get_uid (priv->uid); -} - -/** - * cal_component_set_uid: - * @comp: A calendar component object. - * @uid: Unique identifier. - * - * Sets the unique identifier string of a calendar component object. - **/ -void -cal_component_set_uid (CalComponent *comp, const char *uid) -{ - CalComponentPrivate *priv; - - g_return_if_fail (comp != NULL); - g_return_if_fail (IS_CAL_COMPONENT (comp)); - g_return_if_fail (uid != NULL); - - priv = comp->priv; - g_return_if_fail (priv->icalcomp != NULL); - - /* This MUST exist, since we ensured that it did */ - g_assert (priv->uid != NULL); - - icalproperty_set_uid (priv->uid, (char *) uid); -} - -/** - * cal_component_get_categories: - * @comp: A calendar component object. - * @categories: - * - * - **/ -void -cal_component_get_categories (CalComponent *comp, const char **categories) -{ - CalComponentPrivate *priv; - - g_return_if_fail (comp != NULL); - g_return_if_fail (IS_CAL_COMPONENT (comp)); - g_return_if_fail (categories != NULL); - - priv = comp->priv; - g_return_if_fail (priv->icalcomp != NULL); - - if (priv->categories) - *categories = icalproperty_get_categories (priv->categories); - else - *categories = NULL; -} - -/** - * cal_component_set_categories: - * @comp: A calendar component object. - * @categories: - * - * - **/ -void -cal_component_set_categories (CalComponent *comp, const char *categories) -{ - CalComponentPrivate *priv; - - g_return_if_fail (comp != NULL); - g_return_if_fail (IS_CAL_COMPONENT (comp)); - - priv = comp->priv; - g_return_if_fail (priv->icalcomp != NULL); - - if (!categories || !(*categories)) { - if (priv->categories) { - icalcomponent_remove_property (priv->icalcomp, priv->categories); - icalproperty_free (priv->categories); - priv->url = NULL; - } - - return; - } - - if (priv->categories) - icalproperty_set_categories (priv->categories, (char *) categories); - else { - priv->categories = icalproperty_new_categories ((char *) categories); - icalcomponent_add_property (priv->icalcomp, priv->categories); - } -} - - -/** - * cal_component_get_categories_list: - * @comp: A calendar component object. - * @categ_list: Return value for the list of strings, where each string is a - * category. This should be freed using cal_component_free_categories_list(). - * - * Queries the list of categories of a calendar component object. Each element - * in the returned categ_list is a string with the corresponding category. - **/ -void -cal_component_get_categories_list (CalComponent *comp, GSList **categ_list) -{ - CalComponentPrivate *priv; - const char *categories; - const char *p; - const char *cat_start; - char *str; - - g_return_if_fail (comp != NULL); - g_return_if_fail (IS_CAL_COMPONENT (comp)); - g_return_if_fail (categ_list != NULL); - - priv = comp->priv; - g_return_if_fail (priv->icalcomp != NULL); - - if (!priv->categories) { - *categ_list = NULL; - return; - } - - categories = icalproperty_get_categories (priv->categories); - g_assert (categories != NULL); - - cat_start = categories; - *categ_list = NULL; - - for (p = categories; *p; p++) - if (*p == ',') { - str = g_strndup (cat_start, p - cat_start); - *categ_list = g_slist_prepend (*categ_list, str); - - cat_start = p + 1; - } - - str = g_strndup (cat_start, p - cat_start); - *categ_list = g_slist_prepend (*categ_list, str); - - *categ_list = g_slist_reverse (*categ_list); -} - -/* Creates a comma-delimited string of categories */ -static char * -stringify_categories (GSList *categ_list) -{ - GString *s; - GSList *l; - char *str; - - s = g_string_new (NULL); - - for (l = categ_list; l; l = l->next) { - g_string_append (s, l->data); - - if (l->next != NULL) - g_string_append (s, ","); - } - - str = s->str; - g_string_free (s, FALSE); - - return str; -} - -/** - * cal_component_set_categories_list: - * @comp: A calendar component object. - * @categ_list: List of strings, one for each category. - * - * Sets the list of categories of a calendar component object. - **/ -void -cal_component_set_categories_list (CalComponent *comp, GSList *categ_list) -{ - CalComponentPrivate *priv; - char *categories_str; - - g_return_if_fail (comp != NULL); - g_return_if_fail (IS_CAL_COMPONENT (comp)); - - priv = comp->priv; - g_return_if_fail (priv->icalcomp != NULL); - - if (!categ_list) { - if (priv->categories) { - icalcomponent_remove_property (priv->icalcomp, priv->categories); - icalproperty_free (priv->categories); - } - - return; - } - - /* Create a single string of categories */ - categories_str = stringify_categories (categ_list); - - /* Set the categories */ - priv->categories = icalproperty_new_categories (categories_str); - g_free (categories_str); - - icalcomponent_add_property (priv->icalcomp, priv->categories); -} - -/** - * cal_component_get_classification: - * @comp: A calendar component object. - * @classif: Return value for the classification. - * - * Queries the classification of a calendar component object. If the - * classification property is not set on this component, this function returns - * #CAL_COMPONENT_CLASS_NONE. - **/ -void -cal_component_get_classification (CalComponent *comp, CalComponentClassification *classif) -{ - CalComponentPrivate *priv; - icalproperty_class class; - - g_return_if_fail (comp != NULL); - g_return_if_fail (IS_CAL_COMPONENT (comp)); - g_return_if_fail (classif != NULL); - - priv = comp->priv; - g_return_if_fail (priv->icalcomp != NULL); - - if (!priv->classification) { - *classif = CAL_COMPONENT_CLASS_NONE; - return; - } - - class = icalproperty_get_class (priv->classification); - - switch (class) - { - case ICAL_CLASS_PUBLIC: - *classif = CAL_COMPONENT_CLASS_PUBLIC; - break; - case ICAL_CLASS_PRIVATE: - *classif = CAL_COMPONENT_CLASS_PRIVATE; - break; - case ICAL_CLASS_CONFIDENTIAL: - *classif = CAL_COMPONENT_CLASS_CONFIDENTIAL; - break; - default: - *classif = CAL_COMPONENT_CLASS_UNKNOWN; - break; - } -} - -/** - * cal_component_set_classification: - * @comp: A calendar component object. - * @classif: Classification to use. - * - * Sets the classification property of a calendar component object. To unset - * the property, specify CAL_COMPONENT_CLASS_NONE for @classif. - **/ -void -cal_component_set_classification (CalComponent *comp, CalComponentClassification classif) -{ - CalComponentPrivate *priv; - icalproperty_class class; - - g_return_if_fail (comp != NULL); - g_return_if_fail (IS_CAL_COMPONENT (comp)); - g_return_if_fail (classif != CAL_COMPONENT_CLASS_UNKNOWN); - - priv = comp->priv; - g_return_if_fail (priv->icalcomp != NULL); - - if (classif == CAL_COMPONENT_CLASS_NONE) { - if (priv->classification) { - icalcomponent_remove_property (priv->icalcomp, priv->classification); - icalproperty_free (priv->classification); - priv->classification = NULL; - } - - return; - } - - switch (classif) { - case CAL_COMPONENT_CLASS_PUBLIC: - class = ICAL_CLASS_PUBLIC; - break; - - case CAL_COMPONENT_CLASS_PRIVATE: - class = ICAL_CLASS_PRIVATE; - break; - - case CAL_COMPONENT_CLASS_CONFIDENTIAL: - class = ICAL_CLASS_CONFIDENTIAL; - break; - - default: - g_assert_not_reached (); - class = ICAL_CLASS_NONE; - } - - if (priv->classification) - icalproperty_set_class (priv->classification, class); - else { - priv->classification = icalproperty_new_class (class); - icalcomponent_add_property (priv->icalcomp, priv->classification); - } -} - -/* Gets a text list value */ -static void -get_text_list (GSList *text_list, - const char *(* get_prop_func) (const icalproperty *prop), - GSList **tl) -{ - GSList *l; - - *tl = NULL; - - if (!text_list) - return; - - for (l = text_list; l; l = l->next) { - struct text *text; - CalComponentText *t; - - text = l->data; - g_assert (text->prop != NULL); - - t = g_new (CalComponentText, 1); - t->value = (* get_prop_func) (text->prop); - - if (text->altrep_param) - t->altrep = icalparameter_get_altrep (text->altrep_param); - else - t->altrep = NULL; - - *tl = g_slist_prepend (*tl, t); - } - - *tl = g_slist_reverse (*tl); -} - -/* Sets a text list value */ -static void -set_text_list (CalComponent *comp, - icalproperty *(* new_prop_func) (const char *value), - GSList **text_list, - GSList *tl) -{ - CalComponentPrivate *priv; - GSList *l; - - priv = comp->priv; - - /* Remove old texts */ - - for (l = *text_list; l; l = l->next) { - struct text *text; - - text = l->data; - g_assert (text->prop != NULL); - - icalcomponent_remove_property (priv->icalcomp, text->prop); - icalproperty_free (text->prop); - g_free (text); - } - - g_slist_free (*text_list); - *text_list = NULL; - - /* Add in new texts */ - - for (l = tl; l; l = l->next) { - CalComponentText *t; - struct text *text; - - t = l->data; - g_return_if_fail (t->value != NULL); - - text = g_new (struct text, 1); - - text->prop = (* new_prop_func) ((char *) t->value); - icalcomponent_add_property (priv->icalcomp, text->prop); - - if (t->altrep) { - text->altrep_param = icalparameter_new_altrep ((char *) t->altrep); - icalproperty_add_parameter (text->prop, text->altrep_param); - } else - text->altrep_param = NULL; - - *text_list = g_slist_prepend (*text_list, text); - } - - *text_list = g_slist_reverse (*text_list); -} - -/** - * cal_component_get_comment_list: - * @comp: A calendar component object. - * @text_list: Return value for the comment properties and their parameters, as - * a list of #CalComponentText structures. This should be freed using the - * cal_component_free_text_list() function. - * - * Queries the comment of a calendar component object. The comment property can - * appear several times inside a calendar component, and so a list of - * #CalComponentText is returned. - **/ -void -cal_component_get_comment_list (CalComponent *comp, GSList **text_list) -{ - CalComponentPrivate *priv; - - g_return_if_fail (comp != NULL); - g_return_if_fail (IS_CAL_COMPONENT (comp)); - g_return_if_fail (text_list != NULL); - - priv = comp->priv; - g_return_if_fail (priv->icalcomp != NULL); - - get_text_list (priv->comment_list, icalproperty_get_comment, text_list); -} - -/** - * cal_component_set_comment_list: - * @comp: A calendar component object. - * @text_list: List of #CalComponentText structures. - * - * Sets the comment of a calendar component object. The comment property can - * appear several times inside a calendar component, and so a list of - * #CalComponentText structures is used. - **/ -void -cal_component_set_comment_list (CalComponent *comp, GSList *text_list) -{ - CalComponentPrivate *priv; - - g_return_if_fail (comp != NULL); - g_return_if_fail (IS_CAL_COMPONENT (comp)); - - priv = comp->priv; - g_return_if_fail (priv->icalcomp != NULL); - - set_text_list (comp, icalproperty_new_comment, &priv->comment_list, text_list); -} - -/** - * cal_component_get_contact_list: - * @comp: A calendar component object. - * @text_list: Return value for the contact properties and their parameters, as - * a list of #CalComponentText structures. This should be freed using the - * cal_component_free_text_list() function. - * - * Queries the contact of a calendar component object. The contact property can - * appear several times inside a calendar component, and so a list of - * #CalComponentText is returned. - **/ -void -cal_component_get_contact_list (CalComponent *comp, GSList **text_list) -{ - CalComponentPrivate *priv; - - g_return_if_fail (comp != NULL); - g_return_if_fail (IS_CAL_COMPONENT (comp)); - g_return_if_fail (text_list != NULL); - - priv = comp->priv; - g_return_if_fail (priv->icalcomp != NULL); - - get_text_list (priv->contact_list, icalproperty_get_contact, text_list); -} - -/** - * cal_component_set_contact_list: - * @comp: A calendar component object. - * @text_list: List of #CalComponentText structures. - * - * Sets the contact of a calendar component object. The contact property can - * appear several times inside a calendar component, and so a list of - * #CalComponentText structures is used. - **/ -void -cal_component_set_contact_list (CalComponent *comp, GSList *text_list) -{ - CalComponentPrivate *priv; - - g_return_if_fail (comp != NULL); - g_return_if_fail (IS_CAL_COMPONENT (comp)); - - priv = comp->priv; - g_return_if_fail (priv->icalcomp != NULL); - - set_text_list (comp, icalproperty_new_contact, &priv->contact_list, text_list); -} - -/* Gets a struct icaltimetype value */ -static void -get_icaltimetype (icalproperty *prop, - struct icaltimetype (* get_prop_func) (const icalproperty *prop), - struct icaltimetype **t) -{ - if (!prop) { - *t = NULL; - return; - } - - *t = g_new (struct icaltimetype, 1); - **t = (* get_prop_func) (prop); -} - -/* Sets a struct icaltimetype value */ -static void -set_icaltimetype (CalComponent *comp, icalproperty **prop, - icalproperty *(* prop_new_func) (struct icaltimetype v), - void (* prop_set_func) (icalproperty *prop, struct icaltimetype v), - struct icaltimetype *t) -{ - CalComponentPrivate *priv; - - priv = comp->priv; - - if (!t) { - if (*prop) { - icalcomponent_remove_property (priv->icalcomp, *prop); - icalproperty_free (*prop); - *prop = NULL; - } - - return; - } - - if (*prop) - (* prop_set_func) (*prop, *t); - else { - *prop = (* prop_new_func) (*t); - icalcomponent_add_property (priv->icalcomp, *prop); - } -} - -/** - * cal_component_get_completed: - * @comp: A calendar component object. - * @t: Return value for the completion date. This should be freed using the - * cal_component_free_icaltimetype() function. - * - * Queries the date at which a calendar compoment object was completed. - **/ -void -cal_component_get_completed (CalComponent *comp, struct icaltimetype **t) -{ - CalComponentPrivate *priv; - - g_return_if_fail (comp != NULL); - g_return_if_fail (IS_CAL_COMPONENT (comp)); - g_return_if_fail (t != NULL); - - priv = comp->priv; - g_return_if_fail (priv->icalcomp != NULL); - - get_icaltimetype (priv->completed, icalproperty_get_completed, t); -} - -/** - * cal_component_set_completed: - * @comp: A calendar component object. - * @t: Value for the completion date. - * - * Sets the date at which a calendar component object was completed. - **/ -void -cal_component_set_completed (CalComponent *comp, struct icaltimetype *t) -{ - CalComponentPrivate *priv; - - g_return_if_fail (comp != NULL); - g_return_if_fail (IS_CAL_COMPONENT (comp)); - - priv = comp->priv; - g_return_if_fail (priv->icalcomp != NULL); - - set_icaltimetype (comp, &priv->completed, - icalproperty_new_completed, - icalproperty_set_completed, - t); -} - - -/** - * cal_component_get_created: - * @comp: A calendar component object. - * @t: Return value for the creation date. This should be freed using the - * cal_component_free_icaltimetype() function. - * - * Queries the date in which a calendar component object was created in the - * calendar store. - **/ -void -cal_component_get_created (CalComponent *comp, struct icaltimetype **t) -{ - CalComponentPrivate *priv; - - g_return_if_fail (comp != NULL); - g_return_if_fail (IS_CAL_COMPONENT (comp)); - g_return_if_fail (t != NULL); - - priv = comp->priv; - g_return_if_fail (priv->icalcomp != NULL); - - get_icaltimetype (priv->created, icalproperty_get_created, t); -} - -/** - * cal_component_set_created: - * @comp: A calendar component object. - * @t: Value for the creation date. - * - * Sets the date in which a calendar component object is created in the calendar - * store. This should only be used inside a calendar store application, i.e. - * not by calendar user agents. - **/ -void -cal_component_set_created (CalComponent *comp, struct icaltimetype *t) -{ - CalComponentPrivate *priv; - - g_return_if_fail (comp != NULL); - g_return_if_fail (IS_CAL_COMPONENT (comp)); - - priv = comp->priv; - g_return_if_fail (priv->icalcomp != NULL); - - set_icaltimetype (comp, &priv->created, - icalproperty_new_created, - icalproperty_set_created, - t); -} - -/** - * cal_component_get_description_list: - * @comp: A calendar component object. - * @text_list: Return value for the description properties and their parameters, - * as a list of #CalComponentText structures. This should be freed using the - * cal_component_free_text_list() function. - * - * Queries the description of a calendar component object. Journal components - * may have more than one description, and as such this function returns a list - * of #CalComponentText structures. All other types of components can have at - * most one description. - **/ -void -cal_component_get_description_list (CalComponent *comp, GSList **text_list) -{ - CalComponentPrivate *priv; - - g_return_if_fail (comp != NULL); - g_return_if_fail (IS_CAL_COMPONENT (comp)); - g_return_if_fail (text_list != NULL); - - priv = comp->priv; - g_return_if_fail (priv->icalcomp != NULL); - - get_text_list (priv->description_list, icalproperty_get_description, text_list); -} - -/** - * cal_component_set_description_list: - * @comp: A calendar component object. - * @text_list: List of #CalComponentSummary structures. - * - * Sets the description of a calendar component object. Journal components may - * have more than one description, and as such this function takes in a list of - * #CalComponentDescription structures. All other types of components can have - * at most one description. - **/ -void -cal_component_set_description_list (CalComponent *comp, GSList *text_list) -{ - CalComponentPrivate *priv; - - g_return_if_fail (comp != NULL); - g_return_if_fail (IS_CAL_COMPONENT (comp)); - - priv = comp->priv; - g_return_if_fail (priv->icalcomp != NULL); - - set_text_list (comp, icalproperty_new_description, &priv->description_list, text_list); -} - -/* Gets a date/time and timezone pair */ -static void -get_datetime (struct datetime *datetime, - struct icaltimetype (* get_prop_func) (const icalproperty *prop), - CalComponentDateTime *dt) -{ - if (datetime->prop) { - dt->value = g_new (struct icaltimetype, 1); - *dt->value = (* get_prop_func) (datetime->prop); - } else - dt->value = NULL; - - /* If the icaltimetype has is_utc set, we set "UTC" as the TZID. - This makes the timezone code simpler. */ - if (datetime->tzid_param) - dt->tzid = g_strdup (icalparameter_get_tzid (datetime->tzid_param)); - else if (dt->value && dt->value->is_utc) - dt->tzid = g_strdup ("UTC"); - else - dt->tzid = NULL; -} - -/* Sets a date/time and timezone pair */ -static void -set_datetime (CalComponent *comp, struct datetime *datetime, - icalproperty *(* prop_new_func) (struct icaltimetype v), - void (* prop_set_func) (icalproperty * prop, struct icaltimetype v), - CalComponentDateTime *dt) -{ - CalComponentPrivate *priv; - - priv = comp->priv; - - /* If we are setting the property to NULL (i.e. removing it), then - we remove it if it exists. */ - if (!dt) { - if (datetime->prop) { - icalcomponent_remove_property (priv->icalcomp, datetime->prop); - icalproperty_free (datetime->prop); - - datetime->prop = NULL; - datetime->tzid_param = NULL; - } - - return; - } - - g_return_if_fail (dt->value != NULL); - - /* If the TZID is set to "UTC", we set the is_utc flag. */ - if (dt->tzid && !strcmp (dt->tzid, "UTC")) - dt->value->is_utc = 1; - else - dt->value->is_utc = 0; - - if (datetime->prop) { - (* prop_set_func) (datetime->prop, *dt->value); - } else { - datetime->prop = (* prop_new_func) (*dt->value); - icalcomponent_add_property (priv->icalcomp, datetime->prop); - } - - /* If the TZID is set to "UTC", we don't want to save the TZID. */ - if (dt->tzid && strcmp (dt->tzid, "UTC")) { - g_assert (datetime->prop != NULL); - - if (datetime->tzid_param) { - icalparameter_set_tzid (datetime->tzid_param, (char *) dt->tzid); - } else { - datetime->tzid_param = icalparameter_new_tzid ((char *) dt->tzid); - icalproperty_add_parameter (datetime->prop, datetime->tzid_param); - } - } else if (datetime->tzid_param) { - icalproperty_remove_parameter (datetime->prop, ICAL_TZID_PARAMETER); - icalparameter_free (datetime->tzid_param); - datetime->tzid_param = NULL; - } -} - - -/* This tries to get the DTSTART + DURATION for a VEVENT or VTODO. In a - VEVENT this is used for the DTEND if no DTEND exists, In a VTOTO it is - used for the DUE date if DUE doesn't exist. */ -static void -cal_component_get_start_plus_duration (CalComponent *comp, - CalComponentDateTime *dt) -{ - CalComponentPrivate *priv; - struct icaldurationtype duration; - - priv = comp->priv; - - if (!priv->duration) - return; - - /* Get the DTSTART time. */ - get_datetime (&priv->dtstart, icalproperty_get_dtstart, dt); - if (!dt->value) - return; - - duration = icalproperty_get_duration (priv->duration); - - /* The DURATION shouldn't be negative, but just return DTSTART if it - is, i.e. assume it is 0. */ - if (duration.is_neg) - return; - - /* If DTSTART is a DATE value, then we need to check if the DURATION - includes any hours, minutes or seconds. If it does, we need to - make the DTEND/DUE a DATE-TIME value. */ - duration.days += duration.weeks * 7; - if (dt->value->is_date) { - if (duration.hours != 0 || duration.minutes != 0 - || duration.seconds != 0) { - dt->value->is_date = 0; - } - } - - /* Add on the DURATION. */ - icaltime_adjust (dt->value, duration.days, duration.hours, - duration.minutes, duration.seconds); -} - - -/** - * cal_component_get_dtend: - * @comp: A calendar component object. - * @dt: Return value for the date/time end. This should be freed with the - * cal_component_free_datetime() function. - * - * Queries the date/time end of a calendar component object. - **/ -void -cal_component_get_dtend (CalComponent *comp, CalComponentDateTime *dt) -{ - CalComponentPrivate *priv; - - g_return_if_fail (comp != NULL); - g_return_if_fail (IS_CAL_COMPONENT (comp)); - g_return_if_fail (dt != NULL); - - priv = comp->priv; - g_return_if_fail (priv->icalcomp != NULL); - - get_datetime (&priv->dtend, icalproperty_get_dtend, dt); - - /* If we don't have a DTEND property, then we try to get DTSTART - + DURATION. */ - if (!dt->value) - cal_component_get_start_plus_duration (comp, dt); -} - -/** - * cal_component_set_dtend: - * @comp: A calendar component object. - * @dt: End date/time. - * - * Sets the date/time end property of a calendar component object. - **/ -void -cal_component_set_dtend (CalComponent *comp, CalComponentDateTime *dt) -{ - CalComponentPrivate *priv; - - g_return_if_fail (comp != NULL); - g_return_if_fail (IS_CAL_COMPONENT (comp)); - - priv = comp->priv; - g_return_if_fail (priv->icalcomp != NULL); - - set_datetime (comp, &priv->dtend, - icalproperty_new_dtend, - icalproperty_set_dtend, - dt); - - /* Make sure we remove any existing DURATION property, as it can't be - used with a DTEND. If DTEND is set to NULL, i.e. removed, we also - want to remove any DURATION. */ - if (priv->duration) { - icalcomponent_remove_property (priv->icalcomp, priv->duration); - icalproperty_free (priv->duration); - priv->duration = NULL; - } - - priv->need_sequence_inc = TRUE; -} - -/** - * cal_component_get_dtstamp: - * @comp: A calendar component object. - * @t: A value for the date/timestamp. - * - * Queries the date/timestamp property of a calendar component object, which is - * the last time at which the object was modified by a calendar user agent. - **/ -void -cal_component_get_dtstamp (CalComponent *comp, struct icaltimetype *t) -{ - CalComponentPrivate *priv; - - g_return_if_fail (comp != NULL); - g_return_if_fail (IS_CAL_COMPONENT (comp)); - g_return_if_fail (t != NULL); - - priv = comp->priv; - g_return_if_fail (priv->icalcomp != NULL); - - /* This MUST exist, since we ensured that it did */ - g_assert (priv->dtstamp != NULL); - - *t = icalproperty_get_dtstamp (priv->dtstamp); -} - -/** - * cal_component_set_dtstamp: - * @comp: A calendar component object. - * @t: Date/timestamp value. - * - * Sets the date/timestamp of a calendar component object. This should be - * called whenever a calendar user agent makes a change to a component's - * properties. - **/ -void -cal_component_set_dtstamp (CalComponent *comp, struct icaltimetype *t) -{ - CalComponentPrivate *priv; - - g_return_if_fail (comp != NULL); - g_return_if_fail (IS_CAL_COMPONENT (comp)); - g_return_if_fail (t != NULL); - - priv = comp->priv; - g_return_if_fail (priv->icalcomp != NULL); - - /* This MUST exist, since we ensured that it did */ - g_assert (priv->dtstamp != NULL); - - icalproperty_set_dtstamp (priv->dtstamp, *t); -} - -/** - * cal_component_get_dtstart: - * @comp: A calendar component object. - * @dt: Return value for the date/time start. This should be freed with the - * cal_component_free_datetime() function. - * - * Queries the date/time start of a calendar component object. - **/ -void -cal_component_get_dtstart (CalComponent *comp, CalComponentDateTime *dt) -{ - CalComponentPrivate *priv; - - g_return_if_fail (comp != NULL); - g_return_if_fail (IS_CAL_COMPONENT (comp)); - g_return_if_fail (dt != NULL); - - priv = comp->priv; - g_return_if_fail (priv->icalcomp != NULL); - - get_datetime (&priv->dtstart, icalproperty_get_dtstart, dt); -} - -/** - * cal_component_set_dtstart: - * @comp: A calendar component object. - * @dt: Start date/time. - * - * Sets the date/time start property of a calendar component object. - **/ -void -cal_component_set_dtstart (CalComponent *comp, CalComponentDateTime *dt) -{ - CalComponentPrivate *priv; - - g_return_if_fail (comp != NULL); - g_return_if_fail (IS_CAL_COMPONENT (comp)); - - priv = comp->priv; - g_return_if_fail (priv->icalcomp != NULL); - - set_datetime (comp, &priv->dtstart, - icalproperty_new_dtstart, - icalproperty_set_dtstart, - dt); - - priv->need_sequence_inc = TRUE; -} - -/** - * cal_component_get_due: - * @comp: A calendar component object. - * @dt: Return value for the due date/time. This should be freed with the - * cal_component_free_datetime() function. - * - * Queries the due date/time of a calendar component object. - **/ -void -cal_component_get_due (CalComponent *comp, CalComponentDateTime *dt) -{ - CalComponentPrivate *priv; - - g_return_if_fail (comp != NULL); - g_return_if_fail (IS_CAL_COMPONENT (comp)); - g_return_if_fail (dt != NULL); - - priv = comp->priv; - g_return_if_fail (priv->icalcomp != NULL); - - get_datetime (&priv->due, icalproperty_get_due, dt); - - /* If we don't have a DTEND property, then we try to get DTSTART - + DURATION. */ - if (!dt->value) - cal_component_get_start_plus_duration (comp, dt); -} - -/** - * cal_component_set_due: - * @comp: A calendar component object. - * @dt: End date/time. - * - * Sets the due date/time property of a calendar component object. - **/ -void -cal_component_set_due (CalComponent *comp, CalComponentDateTime *dt) -{ - CalComponentPrivate *priv; - - g_return_if_fail (comp != NULL); - g_return_if_fail (IS_CAL_COMPONENT (comp)); - - priv = comp->priv; - g_return_if_fail (priv->icalcomp != NULL); - - set_datetime (comp, &priv->due, - icalproperty_new_due, - icalproperty_set_due, - dt); - - /* Make sure we remove any existing DURATION property, as it can't be - used with a DTEND. If DTEND is set to NULL, i.e. removed, we also - want to remove any DURATION. */ - if (priv->duration) { - icalcomponent_remove_property (priv->icalcomp, priv->duration); - icalproperty_free (priv->duration); - priv->duration = NULL; - } - - priv->need_sequence_inc = TRUE; -} - -/* Builds a list of CalComponentPeriod structures based on a list of icalproperties */ -static void -get_period_list (GSList *period_list, - struct icaldatetimeperiodtype (* get_prop_func) (const icalproperty *prop), - GSList **list) -{ - GSList *l; - - *list = NULL; - - if (!period_list) - return; - - for (l = period_list; l; l = l->next) { - struct period *period; - CalComponentPeriod *p; - struct icaldatetimeperiodtype ip; - - period = l->data; - g_assert (period->prop != NULL); - - p = g_new (CalComponentPeriod, 1); - - /* Get value parameter */ - - if (period->value_param) { - icalparameter_value value_type; - - value_type = icalparameter_get_value (period->value_param); - - if (value_type == ICAL_VALUE_DATE || value_type == ICAL_VALUE_DATETIME) - p->type = CAL_COMPONENT_PERIOD_DATETIME; - else if (value_type == ICAL_VALUE_DURATION) - p->type = CAL_COMPONENT_PERIOD_DURATION; - else { - g_message ("get_period_list(): Unknown value for period %d; " - "using DATETIME", value_type); - p->type = CAL_COMPONENT_PERIOD_DATETIME; - } - } else - p->type = CAL_COMPONENT_PERIOD_DATETIME; - - /* Get start and end/duration */ - - ip = (* get_prop_func) (period->prop); - - p->start = ip.period.start; - - if (p->type == CAL_COMPONENT_PERIOD_DATETIME) - p->u.end = ip.period.end; - else if (p->type == CAL_COMPONENT_PERIOD_DURATION) - p->u.duration = ip.period.duration; - else - g_assert_not_reached (); - - /* Put in list */ - - *list = g_slist_prepend (*list, p); - } - - *list = g_slist_reverse (*list); -} - -/* Sets a period list value */ -static void -set_period_list (CalComponent *comp, - icalproperty *(* new_prop_func) (struct icaldatetimeperiodtype period), - GSList **period_list, - GSList *pl) -{ - CalComponentPrivate *priv; - GSList *l; - - priv = comp->priv; - - /* Remove old periods */ - - for (l = *period_list; l; l = l->next) { - struct period *period; - - period = l->data; - g_assert (period->prop != NULL); - - icalcomponent_remove_property (priv->icalcomp, period->prop); - icalproperty_free (period->prop); - g_free (period); - } - - g_slist_free (*period_list); - *period_list = NULL; - - /* Add in new periods */ - - for (l = pl; l; l = l->next) { - CalComponentPeriod *p; - struct period *period; - struct icaldatetimeperiodtype ip; - icalparameter_value value_type; - - g_assert (l->data != NULL); - p = l->data; - - /* Create libical value */ - - ip.period.start = p->start; - - if (p->type == CAL_COMPONENT_PERIOD_DATETIME) { - value_type = ICAL_VALUE_DATETIME; - ip.period.end = p->u.end; - } else if (p->type == CAL_COMPONENT_PERIOD_DURATION) { - value_type = ICAL_VALUE_DURATION; - ip.period.duration = p->u.duration; - } else { - g_assert_not_reached (); - return; - } - - /* Create property */ - - period = g_new (struct period, 1); - - period->prop = (* new_prop_func) (ip); - period->value_param = icalparameter_new_value (value_type); - icalproperty_add_parameter (period->prop, period->value_param); - - /* Add to list */ - - *period_list = g_slist_prepend (*period_list, period); - } - - *period_list = g_slist_reverse (*period_list); -} - -/** - * cal_component_get_exdate_list: - * @comp: A calendar component object. - * @exdate_list: Return value for the list of exception dates, as a list of - * #CalComponentDateTime structures. This should be freed using the - * cal_component_free_exdate_list() function. - * - * Queries the list of exception date properties in a calendar component object. - **/ -void -cal_component_get_exdate_list (CalComponent *comp, GSList **exdate_list) -{ - CalComponentPrivate *priv; - GSList *l; - - g_return_if_fail (comp != NULL); - g_return_if_fail (IS_CAL_COMPONENT (comp)); - g_return_if_fail (exdate_list != NULL); - - priv = comp->priv; - g_return_if_fail (priv->icalcomp != NULL); - - *exdate_list = NULL; - - for (l = priv->exdate_list; l; l = l->next) { - struct datetime *dt; - CalComponentDateTime *cdt; - - dt = l->data; - - cdt = g_new (CalComponentDateTime, 1); - cdt->value = g_new (struct icaltimetype, 1); - - *cdt->value = icalproperty_get_exdate (dt->prop); - - if (dt->tzid_param) - cdt->tzid = g_strdup (icalparameter_get_tzid (dt->tzid_param)); - else - cdt->tzid = NULL; - - *exdate_list = g_slist_prepend (*exdate_list, cdt); - } - - *exdate_list = g_slist_reverse (*exdate_list); -} - -/** - * cal_component_set_exdate_list: - * @comp: A calendar component object. - * @exdate_list: List of #CalComponentDateTime structures. - * - * Sets the list of exception dates in a calendar component object. - **/ -void -cal_component_set_exdate_list (CalComponent *comp, GSList *exdate_list) -{ - CalComponentPrivate *priv; - GSList *l; - - g_return_if_fail (comp != NULL); - g_return_if_fail (IS_CAL_COMPONENT (comp)); - - priv = comp->priv; - g_return_if_fail (priv->icalcomp != NULL); - - /* Remove old exception dates */ - - for (l = priv->exdate_list; l; l = l->next) { - struct datetime *dt; - - dt = l->data; - - /* Removing the DATE or DATE-TIME property will also remove - any TZID parameter. */ - icalcomponent_remove_property (priv->icalcomp, dt->prop); - icalproperty_free (dt->prop); - g_free (dt); - } - - g_slist_free (priv->exdate_list); - priv->exdate_list = NULL; - - /* Add in new exception dates */ - - for (l = exdate_list; l; l = l->next) { - CalComponentDateTime *cdt; - struct datetime *dt; - - g_assert (l->data != NULL); - cdt = l->data; - - g_assert (cdt->value != NULL); - - dt = g_new (struct datetime, 1); - dt->prop = icalproperty_new_exdate (*cdt->value); - - if (cdt->tzid) { - dt->tzid_param = icalparameter_new_tzid ((char *) cdt->tzid); - icalproperty_add_parameter (dt->prop, dt->tzid_param); - } else - dt->tzid_param = NULL; - - icalcomponent_add_property (priv->icalcomp, dt->prop); - priv->exdate_list = g_slist_prepend (priv->exdate_list, dt); - } - - priv->exdate_list = g_slist_reverse (priv->exdate_list); - - priv->need_sequence_inc = TRUE; -} - -/** - * cal_component_has_exdates: - * @comp: A calendar component object. - * - * Queries whether a calendar component object has any exception dates defined - * for it. - * - * Return value: TRUE if the component has exception dates, FALSE otherwise. - **/ -gboolean -cal_component_has_exdates (CalComponent *comp) -{ - CalComponentPrivate *priv; - - g_return_val_if_fail (comp != NULL, FALSE); - g_return_val_if_fail (IS_CAL_COMPONENT (comp), FALSE); - - priv = comp->priv; - g_return_val_if_fail (priv->icalcomp != NULL, FALSE); - - return (priv->exdate_list != NULL); -} - -/* Gets a list of recurrence rules */ -static void -get_recur_list (GSList *recur_list, - struct icalrecurrencetype (* get_prop_func) (const icalproperty *prop), - GSList **list) -{ - GSList *l; - - *list = NULL; - - for (l = recur_list; l; l = l->next) { - icalproperty *prop; - struct icalrecurrencetype *r; - - prop = l->data; - - r = g_new (struct icalrecurrencetype, 1); - *r = (* get_prop_func) (prop); - - *list = g_slist_prepend (*list, r); - } - - *list = g_slist_reverse (*list); -} - -/* Sets a list of recurrence rules */ -static void -set_recur_list (CalComponent *comp, - icalproperty *(* new_prop_func) (struct icalrecurrencetype recur), - GSList **recur_list, - GSList *rl) -{ - CalComponentPrivate *priv; - GSList *l; - - priv = comp->priv; - - /* Remove old recurrences */ - - for (l = *recur_list; l; l = l->next) { - icalproperty *prop; - - prop = l->data; - icalcomponent_remove_property (priv->icalcomp, prop); - icalproperty_free (prop); - } - - g_slist_free (*recur_list); - *recur_list = NULL; - - /* Add in new recurrences */ - - for (l = rl; l; l = l->next) { - icalproperty *prop; - struct icalrecurrencetype *recur; - - g_assert (l->data != NULL); - recur = l->data; - - prop = (* new_prop_func) (*recur); - icalcomponent_add_property (priv->icalcomp, prop); - - *recur_list = g_slist_prepend (*recur_list, prop); - } - - *recur_list = g_slist_reverse (*recur_list); -} - -/** - * cal_component_get_exrule_list: - * @comp: A calendar component object. - * @recur_list: List of exception rules as struct #icalrecurrencetype - * structures. This should be freed using the cal_component_free_recur_list() - * function. - * - * Queries the list of exception rule properties of a calendar component - * object. - **/ -void -cal_component_get_exrule_list (CalComponent *comp, GSList **recur_list) -{ - CalComponentPrivate *priv; - - g_return_if_fail (comp != NULL); - g_return_if_fail (IS_CAL_COMPONENT (comp)); - g_return_if_fail (recur_list != NULL); - - priv = comp->priv; - g_return_if_fail (priv->icalcomp != NULL); - - get_recur_list (priv->exrule_list, icalproperty_get_exrule, recur_list); -} - -/** - * cal_component_get_exrule_property_list: - * @comp: A calendar component object. - * @recur_list: Returns a list of exception rule properties. - * - * Queries the list of exception rule properties of a calendar component object. - **/ -void -cal_component_get_exrule_property_list (CalComponent *comp, GSList **recur_list) -{ - CalComponentPrivate *priv; - - g_return_if_fail (comp != NULL); - g_return_if_fail (IS_CAL_COMPONENT (comp)); - g_return_if_fail (recur_list != NULL); - - priv = comp->priv; - g_return_if_fail (priv->icalcomp != NULL); - - *recur_list = priv->exrule_list; -} - -/** - * cal_component_set_exrule_list: - * @comp: A calendar component object. - * @recur_list: List of struct #icalrecurrencetype structures. - * - * Sets the list of exception rules in a calendar component object. - **/ -void -cal_component_set_exrule_list (CalComponent *comp, GSList *recur_list) -{ - CalComponentPrivate *priv; - - g_return_if_fail (comp != NULL); - g_return_if_fail (IS_CAL_COMPONENT (comp)); - - priv = comp->priv; - g_return_if_fail (priv->icalcomp != NULL); - - set_recur_list (comp, icalproperty_new_exrule, &priv->exrule_list, recur_list); - - priv->need_sequence_inc = TRUE; -} - -/** - * cal_component_has_exrules: - * @comp: A calendar component object. - * - * Queries whether a calendar component object has any exception rules defined - * for it. - * - * Return value: TRUE if the component has exception rules, FALSE otherwise. - **/ -gboolean -cal_component_has_exrules (CalComponent *comp) -{ - CalComponentPrivate *priv; - - g_return_val_if_fail (comp != NULL, FALSE); - g_return_val_if_fail (IS_CAL_COMPONENT (comp), FALSE); - - priv = comp->priv; - g_return_val_if_fail (priv->icalcomp != NULL, FALSE); - - return (priv->exrule_list != NULL); -} - -/** - * cal_component_has_exceptions: - * @comp: A calendar component object - * - * Queries whether a calendar component object has any exception dates - * or exception rules. - * - * Return value: TRUE if the component has exceptions, FALSE otherwise. - **/ -gboolean -cal_component_has_exceptions (CalComponent *comp) -{ - return cal_component_has_exdates (comp) || cal_component_has_exrules (comp); -} - -/** - * cal_component_get_geo: - * @comp: A calendar component object. - * @geo: Return value for the geographic position property. This should be - * freed using the cal_component_free_geo() function. - * - * Sets the geographic position property of a calendar component object. - **/ -void -cal_component_get_geo (CalComponent *comp, struct icalgeotype **geo) -{ - CalComponentPrivate *priv; - - g_return_if_fail (comp != NULL); - g_return_if_fail (IS_CAL_COMPONENT (comp)); - g_return_if_fail (geo != NULL); - - priv = comp->priv; - g_return_if_fail (priv->icalcomp != NULL); - - if (priv->geo) { - *geo = g_new (struct icalgeotype, 1); - **geo = icalproperty_get_geo (priv->geo); - } else - *geo = NULL; -} - -/** - * cal_component_set_geo: - * @comp: A calendar component object. - * @geo: Value for the geographic position property. - * - * Sets the geographic position property on a calendar component object. - **/ -void -cal_component_set_geo (CalComponent *comp, struct icalgeotype *geo) -{ - CalComponentPrivate *priv; - - g_return_if_fail (comp != NULL); - g_return_if_fail (IS_CAL_COMPONENT (comp)); - - priv = comp->priv; - g_return_if_fail (priv->icalcomp != NULL); - - if (!geo) { - if (priv->geo) { - icalcomponent_remove_property (priv->icalcomp, priv->geo); - icalproperty_free (priv->geo); - priv->geo = NULL; - } - - return; - } - - if (priv->geo) - icalproperty_set_geo (priv->geo, *geo); - else { - priv->geo = icalproperty_new_geo (*geo); - icalcomponent_add_property (priv->icalcomp, priv->geo); - } -} - -/** - * cal_component_get_last_modified: - * @comp: A calendar component object. - * @t: Return value for the last modified time value. - * - * Queries the time at which a calendar component object was last modified in - * the calendar store. - **/ -void -cal_component_get_last_modified (CalComponent *comp, struct icaltimetype **t) -{ - CalComponentPrivate *priv; - - g_return_if_fail (comp != NULL); - g_return_if_fail (IS_CAL_COMPONENT (comp)); - g_return_if_fail (t != NULL); - - priv = comp->priv; - g_return_if_fail (priv->icalcomp != NULL); - - get_icaltimetype (priv->last_modified, icalproperty_get_lastmodified, t); -} - -/** - * cal_component_set_last_modified: - * @comp: A calendar component object. - * @t: Value for the last time modified. - * - * Sets the time at which a calendar component object was last stored in the - * calendar store. This should not be called by plain calendar user agents. - **/ -void -cal_component_set_last_modified (CalComponent *comp, struct icaltimetype *t) -{ - CalComponentPrivate *priv; - - g_return_if_fail (comp != NULL); - g_return_if_fail (IS_CAL_COMPONENT (comp)); - - priv = comp->priv; - g_return_if_fail (priv->icalcomp != NULL); - - set_icaltimetype (comp, &priv->last_modified, - icalproperty_new_lastmodified, - icalproperty_set_lastmodified, - t); -} - -/** - * cal_component_get_organizer: - * @comp: A calendar component object - * @organizer: A value for the organizer - * - * Queries the organizer property of a calendar component object - **/ -void -cal_component_get_organizer (CalComponent *comp, CalComponentOrganizer *organizer) -{ - CalComponentPrivate *priv; - - g_return_if_fail (comp != NULL); - g_return_if_fail (IS_CAL_COMPONENT (comp)); - g_return_if_fail (organizer != NULL); - - priv = comp->priv; - g_return_if_fail (priv->icalcomp != NULL); - - if (priv->organizer.prop) - organizer->value = icalproperty_get_organizer (priv->organizer.prop); - else - organizer->value = NULL; - - if (priv->organizer.sentby_param) - organizer->sentby = icalparameter_get_sentby (priv->organizer.sentby_param); - else - organizer->sentby = NULL; - - if (priv->organizer.cn_param) - organizer->cn = icalparameter_get_sentby (priv->organizer.cn_param); - else - organizer->cn = NULL; - - if (priv->organizer.language_param) - organizer->language = icalparameter_get_sentby (priv->organizer.language_param); - else - organizer->language = NULL; - -} - -/** - * cal_component_set_organizer: - * @comp: A calendar component object. - * @organizer: Value for the organizer property - * - * Sets the organizer of a calendar component object - **/ -void -cal_component_set_organizer (CalComponent *comp, CalComponentOrganizer *organizer) -{ - CalComponentPrivate *priv; - - g_return_if_fail (comp != NULL); - g_return_if_fail (IS_CAL_COMPONENT (comp)); - - priv = comp->priv; - g_return_if_fail (priv->icalcomp != NULL); - - if (!organizer) { - if (priv->organizer.prop) { - icalcomponent_remove_property (priv->icalcomp, priv->organizer.prop); - icalproperty_free (priv->organizer.prop); - - priv->organizer.prop = NULL; - priv->organizer.sentby_param = NULL; - priv->organizer.cn_param = NULL; - priv->organizer.language_param = NULL; - } - - return; - } - - g_return_if_fail (organizer->value != NULL); - - if (priv->organizer.prop) - icalproperty_set_organizer (priv->organizer.prop, (char *) organizer->value); - else { - priv->organizer.prop = icalproperty_new_organizer ((char *) organizer->value); - icalcomponent_add_property (priv->icalcomp, priv->organizer.prop); - } - - if (organizer->sentby) { - g_assert (priv->organizer.prop != NULL); - - if (priv->organizer.sentby_param) - icalparameter_set_sentby (priv->organizer.sentby_param, - (char *) organizer->sentby); - else { - priv->organizer.sentby_param = icalparameter_new_sentby ( - (char *) organizer->sentby); - icalproperty_add_parameter (priv->organizer.prop, - priv->organizer.sentby_param); - } - } else if (priv->organizer.sentby_param) { - icalproperty_remove_parameter (priv->organizer.prop, ICAL_SENTBY_PARAMETER); - icalparameter_free (priv->organizer.sentby_param); - priv->organizer.sentby_param = NULL; - } - - if (organizer->cn) { - g_assert (priv->organizer.prop != NULL); - - if (priv->organizer.cn_param) - icalparameter_set_cn (priv->organizer.cn_param, - (char *) organizer->cn); - else { - priv->organizer.cn_param = icalparameter_new_cn ( - (char *) organizer->cn); - icalproperty_add_parameter (priv->organizer.prop, - priv->organizer.cn_param); - } - } else if (priv->organizer.cn_param) { - icalproperty_remove_parameter (priv->organizer.prop, ICAL_CN_PARAMETER); - icalparameter_free (priv->organizer.cn_param); - priv->organizer.cn_param = NULL; - } - - if (organizer->language) { - g_assert (priv->organizer.prop != NULL); - - if (priv->organizer.language_param) - icalparameter_set_language (priv->organizer.language_param, - (char *) organizer->language); - else { - priv->organizer.language_param = icalparameter_new_language ( - (char *) organizer->language); - icalproperty_add_parameter (priv->organizer.prop, - priv->organizer.language_param); - } - } else if (priv->organizer.language_param) { - icalproperty_remove_parameter (priv->organizer.prop, ICAL_LANGUAGE_PARAMETER); - icalparameter_free (priv->organizer.language_param); - priv->organizer.language_param = NULL; - } - - -} - - -/** - * cal_component_has_organizer: - * @comp: - * - * - * - * Return value: - **/ -gboolean -cal_component_has_organizer (CalComponent *comp) -{ - CalComponentPrivate *priv; - - g_return_val_if_fail (comp != NULL, FALSE); - g_return_val_if_fail (IS_CAL_COMPONENT (comp), FALSE); - - priv = comp->priv; - - return priv->organizer.prop != NULL; -} - -/** - * cal_component_get_percent: - * @comp: A calendar component object. - * @percent: Return value for the percent-complete property. This should be - * freed using the cal_component_free_percent() function. - * - * Queries the percent-complete property of a calendar component object. - **/ -void -cal_component_get_percent (CalComponent *comp, int **percent) -{ - CalComponentPrivate *priv; - - g_return_if_fail (comp != NULL); - g_return_if_fail (IS_CAL_COMPONENT (comp)); - g_return_if_fail (percent != NULL); - - priv = comp->priv; - g_return_if_fail (priv->icalcomp != NULL); - - if (priv->percent) { - *percent = g_new (int, 1); - **percent = icalproperty_get_percentcomplete (priv->percent); - } else - *percent = NULL; -} - -/** - * cal_component_set_percent: - * @comp: A calendar component object. - * @percent: Value for the percent-complete property. - * - * Sets the percent-complete property of a calendar component object. - **/ -void -cal_component_set_percent (CalComponent *comp, int *percent) -{ - CalComponentPrivate *priv; - - g_return_if_fail (comp != NULL); - g_return_if_fail (IS_CAL_COMPONENT (comp)); - - priv = comp->priv; - g_return_if_fail (priv->icalcomp != NULL); - - if (!percent) { - if (priv->percent) { - icalcomponent_remove_property (priv->icalcomp, priv->percent); - icalproperty_free (priv->percent); - priv->percent = NULL; - } - - return; - } - - g_return_if_fail (*percent >= 0 && *percent <= 100); - - if (priv->percent) - icalproperty_set_percentcomplete (priv->percent, *percent); - else { - priv->percent = icalproperty_new_percentcomplete (*percent); - icalcomponent_add_property (priv->icalcomp, priv->percent); - } -} - -/** - * cal_component_get_priority: - * @comp: A calendar component object. - * @priority: Return value for the priority property. This should be freed using - * the cal_component_free_priority() function. - * - * Queries the priority property of a calendar component object. - **/ -void -cal_component_get_priority (CalComponent *comp, int **priority) -{ - CalComponentPrivate *priv; - - g_return_if_fail (comp != NULL); - g_return_if_fail (IS_CAL_COMPONENT (comp)); - g_return_if_fail (priority != NULL); - - priv = comp->priv; - g_return_if_fail (priv->icalcomp != NULL); - - if (priv->priority) { - *priority = g_new (int, 1); - **priority = icalproperty_get_priority (priv->priority); - } else - *priority = NULL; -} - -/** - * cal_component_set_priority: - * @comp: A calendar component object. - * @priority: Value for the priority property. - * - * Sets the priority property of a calendar component object. - **/ -void -cal_component_set_priority (CalComponent *comp, int *priority) -{ - CalComponentPrivate *priv; - - g_return_if_fail (comp != NULL); - g_return_if_fail (IS_CAL_COMPONENT (comp)); - - priv = comp->priv; - g_return_if_fail (priv->icalcomp != NULL); - - if (!priority) { - if (priv->priority) { - icalcomponent_remove_property (priv->icalcomp, priv->priority); - icalproperty_free (priv->priority); - priv->priority = NULL; - } - - return; - } - - g_return_if_fail (*priority >= 0 && *priority <= 9); - - if (priv->priority) - icalproperty_set_priority (priv->priority, *priority); - else { - priv->priority = icalproperty_new_priority (*priority); - icalcomponent_add_property (priv->icalcomp, priv->priority); - } -} - -/** - * cal_component_get_recurid: - * @comp: A calendar component object. - * @recur_id: Return value for the recurrence id property - * - * Queries the recurrence id property of a calendar component object - **/ -void -cal_component_get_recurid (CalComponent *comp, CalComponentRange *recur_id) -{ - CalComponentPrivate *priv; - - g_return_if_fail (comp != NULL); - g_return_if_fail (IS_CAL_COMPONENT (comp)); - g_return_if_fail (recur_id != NULL); - - priv = comp->priv; - g_return_if_fail (priv->icalcomp != NULL); - - get_datetime (&priv->recur_id.recur_time, - icalproperty_get_recurrenceid, - &recur_id->datetime); -} - -/** - * cal_component_set_recurid: - * @comp: A calendar component object. - * @recur_id: Value for the recurrence id property. - * - * Sets the recurrence id property of a calendar component object. - **/ -void -cal_component_set_recurid (CalComponent *comp, CalComponentRange *recur_id) -{ - CalComponentPrivate *priv; - - g_return_if_fail (comp != NULL); - g_return_if_fail (IS_CAL_COMPONENT (comp)); - - priv = comp->priv; - g_return_if_fail (priv->icalcomp != NULL); - - set_datetime (comp, &priv->recur_id.recur_time, - icalproperty_new_recurrenceid, - icalproperty_set_recurrenceid, - recur_id ? &recur_id->datetime : NULL); -} - -/** - * cal_component_get_rdate_list: - * @comp: A calendar component object. - * @period_list: Return value for the list of recurrence dates, as a list of - * #CalComponentPeriod structures. This should be freed using the - * cal_component_free_period_list() function. - * - * Queries the list of recurrence date properties in a calendar component - * object. - **/ -void -cal_component_get_rdate_list (CalComponent *comp, GSList **period_list) -{ - CalComponentPrivate *priv; - - g_return_if_fail (comp != NULL); - g_return_if_fail (IS_CAL_COMPONENT (comp)); - g_return_if_fail (period_list != NULL); - - priv = comp->priv; - g_return_if_fail (priv->icalcomp != NULL); - - get_period_list (priv->rdate_list, icalproperty_get_rdate, period_list); -} - -/** - * cal_component_set_rdate_list: - * @comp: A calendar component object. - * @period_list: List of #CalComponentPeriod structures. - * - * Sets the list of recurrence dates in a calendar component object. - **/ -void -cal_component_set_rdate_list (CalComponent *comp, GSList *period_list) -{ - CalComponentPrivate *priv; - - g_return_if_fail (comp != NULL); - g_return_if_fail (IS_CAL_COMPONENT (comp)); - - priv = comp->priv; - g_return_if_fail (priv->icalcomp != NULL); - - set_period_list (comp, icalproperty_new_rdate, &priv->rdate_list, period_list); - - priv->need_sequence_inc = TRUE; -} - -/** - * cal_component_has_rdates: - * @comp: A calendar component object. - * - * Queries whether a calendar component object has any recurrence dates defined - * for it. - * - * Return value: TRUE if the component has recurrence dates, FALSE otherwise. - **/ -gboolean -cal_component_has_rdates (CalComponent *comp) -{ - CalComponentPrivate *priv; - - g_return_val_if_fail (comp != NULL, FALSE); - g_return_val_if_fail (IS_CAL_COMPONENT (comp), FALSE); - - priv = comp->priv; - g_return_val_if_fail (priv->icalcomp != NULL, FALSE); - - return (priv->rdate_list != NULL); -} - -/** - * cal_component_get_rrule_list: - * @comp: A calendar component object. - * @recur_list: List of recurrence rules as struct #icalrecurrencetype - * structures. This should be freed using the cal_component_free_recur_list() - * function. - * - * Queries the list of recurrence rule properties of a calendar component - * object. - **/ -void -cal_component_get_rrule_list (CalComponent *comp, GSList **recur_list) -{ - CalComponentPrivate *priv; - - g_return_if_fail (comp != NULL); - g_return_if_fail (IS_CAL_COMPONENT (comp)); - g_return_if_fail (recur_list != NULL); - - priv = comp->priv; - g_return_if_fail (priv->icalcomp != NULL); - - get_recur_list (priv->rrule_list, icalproperty_get_rrule, recur_list); -} - -/** - * cal_component_get_rrule_property_list: - * @comp: A calendar component object. - * @recur_list: Returns a list of recurrence rule properties. - * - * Queries a list of recurrence rule properties of a calendar component object. - **/ -void -cal_component_get_rrule_property_list (CalComponent *comp, GSList **recur_list) -{ - CalComponentPrivate *priv; - - g_return_if_fail (comp != NULL); - g_return_if_fail (IS_CAL_COMPONENT (comp)); - g_return_if_fail (recur_list != NULL); - - priv = comp->priv; - g_return_if_fail (priv->icalcomp != NULL); - - *recur_list = priv->rrule_list; -} - -/** - * cal_component_set_rrule_list: - * @comp: A calendar component object. - * @recur_list: List of struct #icalrecurrencetype structures. - * - * Sets the list of recurrence rules in a calendar component object. - **/ -void -cal_component_set_rrule_list (CalComponent *comp, GSList *recur_list) -{ - CalComponentPrivate *priv; - - g_return_if_fail (comp != NULL); - g_return_if_fail (IS_CAL_COMPONENT (comp)); - - priv = comp->priv; - g_return_if_fail (priv->icalcomp != NULL); - - set_recur_list (comp, icalproperty_new_rrule, &priv->rrule_list, recur_list); - - priv->need_sequence_inc = TRUE; -} - -/** - * cal_component_has_rrules: - * @comp: A calendar component object. - * - * Queries whether a calendar component object has any recurrence rules defined - * for it. - * - * Return value: TRUE if the component has recurrence rules, FALSE otherwise. - **/ -gboolean -cal_component_has_rrules (CalComponent *comp) -{ - CalComponentPrivate *priv; - - g_return_val_if_fail (comp != NULL, FALSE); - g_return_val_if_fail (IS_CAL_COMPONENT (comp), FALSE); - - priv = comp->priv; - g_return_val_if_fail (priv->icalcomp != NULL, FALSE); - - return (priv->rrule_list != NULL); -} - -/** - * cal_component_has_recurrences: - * @comp: A calendar component object - * - * Queries whether a calendar component object has any recurrence dates or - * recurrence rules. - * - * Return value: TRUE if the component has recurrences, FALSE otherwise. - **/ -gboolean -cal_component_has_recurrences (CalComponent *comp) -{ - return cal_component_has_rdates (comp) || cal_component_has_rrules (comp); -} - -/* Counts the elements in the by_xxx fields of an icalrecurrencetype */ -static int -count_by_xxx (short *field, int max_elements) -{ - int i; - - for (i = 0; i < max_elements; i++) - if (field[i] == ICAL_RECURRENCE_ARRAY_MAX) - break; - - return i; -} - -gboolean -cal_component_has_simple_recurrence (CalComponent *comp) -{ - GSList *rrule_list; - struct icalrecurrencetype *r; - int n_by_second, n_by_minute, n_by_hour; - int n_by_day, n_by_month_day, n_by_year_day; - int n_by_week_no, n_by_month, n_by_set_pos; - int len, i; - gboolean simple = FALSE; - - if (!cal_component_has_recurrences (comp)) - return TRUE; - - cal_component_get_rrule_list (comp, &rrule_list); - len = g_slist_length (rrule_list); - if (len > 1 - || cal_component_has_rdates (comp) - || cal_component_has_exrules (comp)) - goto cleanup; - - /* Down to one rule, so test that one */ - r = rrule_list->data; - - /* Any funky frequency? */ - if (r->freq == ICAL_SECONDLY_RECURRENCE - || r->freq == ICAL_MINUTELY_RECURRENCE - || r->freq == ICAL_HOURLY_RECURRENCE) - goto cleanup; - - /* Any funky BY_* */ -#define N_HAS_BY(field) (count_by_xxx (field, sizeof (field) / sizeof (field[0]))) - - n_by_second = N_HAS_BY (r->by_second); - n_by_minute = N_HAS_BY (r->by_minute); - n_by_hour = N_HAS_BY (r->by_hour); - n_by_day = N_HAS_BY (r->by_day); - n_by_month_day = N_HAS_BY (r->by_month_day); - n_by_year_day = N_HAS_BY (r->by_year_day); - n_by_week_no = N_HAS_BY (r->by_week_no); - n_by_month = N_HAS_BY (r->by_month); - n_by_set_pos = N_HAS_BY (r->by_set_pos); - - if (n_by_second != 0 - || n_by_minute != 0 - || n_by_hour != 0) - goto cleanup; - - switch (r->freq) { - case ICAL_DAILY_RECURRENCE: - if (n_by_day != 0 - || n_by_month_day != 0 - || n_by_year_day != 0 - || n_by_week_no != 0 - || n_by_month != 0 - || n_by_set_pos != 0) - goto cleanup; - - simple = TRUE; - break; - - case ICAL_WEEKLY_RECURRENCE: - if (n_by_month_day != 0 - || n_by_year_day != 0 - || n_by_week_no != 0 - || n_by_month != 0 - || n_by_set_pos != 0) - goto cleanup; - - for (i = 0; i < 8 && r->by_day[i] != ICAL_RECURRENCE_ARRAY_MAX; i++) { - int pos; - pos = icalrecurrencetype_day_position (r->by_day[i]); - - if (pos != 0) - goto cleanup; - } - - simple = TRUE; - break; - - case ICAL_MONTHLY_RECURRENCE: - if (n_by_year_day != 0 - || n_by_week_no != 0 - || n_by_month != 0 - || n_by_set_pos > 1) - goto cleanup; - - if (n_by_month_day == 1) { - int nth; - - if (n_by_set_pos != 0) - goto cleanup; - - nth = r->by_month_day[0]; - if (nth < 1 && nth != -1) - goto cleanup; - - simple = TRUE; - - } else if (n_by_day == 1) { - enum icalrecurrencetype_weekday weekday; - int pos; - - /* Outlook 2000 uses BYDAY=TU;BYSETPOS=2, and will not - accept BYDAY=2TU. So we now use the same as Outlook - by default. */ - - weekday = icalrecurrencetype_day_day_of_week (r->by_day[0]); - pos = icalrecurrencetype_day_position (r->by_day[0]); - - if (pos == 0) { - if (n_by_set_pos != 1) - goto cleanup; - pos = r->by_set_pos[0]; - } else if (pos < 0) { - goto cleanup; - } - - switch (weekday) { - case ICAL_MONDAY_WEEKDAY: - case ICAL_TUESDAY_WEEKDAY: - case ICAL_WEDNESDAY_WEEKDAY: - case ICAL_THURSDAY_WEEKDAY: - case ICAL_FRIDAY_WEEKDAY: - case ICAL_SATURDAY_WEEKDAY: - case ICAL_SUNDAY_WEEKDAY: - break; - - default: - goto cleanup; - } - } else { - goto cleanup; - } - - simple = TRUE; - break; - - case ICAL_YEARLY_RECURRENCE: - if (n_by_day != 0 - || n_by_month_day != 0 - || n_by_year_day != 0 - || n_by_week_no != 0 - || n_by_month != 0 - || n_by_set_pos != 0) - goto cleanup; - - simple = TRUE; - break; - - default: - goto cleanup; - } - - cleanup: - cal_component_free_recur_list (rrule_list); - - return simple; -} - -gboolean -cal_component_is_instance (CalComponent *comp) -{ - CalComponentPrivate *priv; - - g_return_val_if_fail (comp != NULL, FALSE); - g_return_val_if_fail (IS_CAL_COMPONENT (comp), FALSE); - - priv = comp->priv; - - return !(priv->recur_id.recur_time.prop == NULL); -} - -/** - * cal_component_get_sequence: - * @comp: A calendar component object. - * @sequence: Return value for the sequence number. This should be freed using - * cal_component_free_sequence(). - * - * Queries the sequence number of a calendar component object. - **/ -void -cal_component_get_sequence (CalComponent *comp, int **sequence) -{ - CalComponentPrivate *priv; - - g_return_if_fail (comp != NULL); - g_return_if_fail (IS_CAL_COMPONENT (comp)); - g_return_if_fail (sequence != NULL); - - priv = comp->priv; - g_return_if_fail (priv->icalcomp != NULL); - - if (!priv->sequence) { - *sequence = NULL; - return; - } - - *sequence = g_new (int, 1); - **sequence = icalproperty_get_sequence (priv->sequence); -} - -/** - * cal_component_set_sequence: - * @comp: A calendar component object. - * @sequence: Sequence number value. - * - * Sets the sequence number of a calendar component object. Normally this - * function should not be called, since the sequence number is incremented - * automatically at the proper times. - **/ -void -cal_component_set_sequence (CalComponent *comp, int *sequence) -{ - CalComponentPrivate *priv; - - g_return_if_fail (comp != NULL); - g_return_if_fail (IS_CAL_COMPONENT (comp)); - - priv = comp->priv; - g_return_if_fail (priv->icalcomp != NULL); - - priv->need_sequence_inc = FALSE; - - if (!sequence) { - if (priv->sequence) { - icalcomponent_remove_property (priv->icalcomp, priv->sequence); - icalproperty_free (priv->sequence); - priv->sequence = NULL; - } - - return; - } - - if (priv->sequence) - icalproperty_set_sequence (priv->sequence, *sequence); - else { - priv->sequence = icalproperty_new_sequence (*sequence); - icalcomponent_add_property (priv->icalcomp, priv->sequence); - } -} - -/** - * cal_component_get_status: - * @comp: A calendar component object. - * @status: Return value for the status value. It is set to #ICAL_STATUS_NONE - * if the component has no status property. - * - * Queries the status property of a calendar component object. - **/ -void -cal_component_get_status (CalComponent *comp, icalproperty_status *status) -{ - CalComponentPrivate *priv; - - g_return_if_fail (comp != NULL); - g_return_if_fail (IS_CAL_COMPONENT (comp)); - g_return_if_fail (status != NULL); - - priv = comp->priv; - g_return_if_fail (priv->icalcomp != NULL); - - if (!priv->status) { - *status = ICAL_STATUS_NONE; - return; - } - - *status = icalproperty_get_status (priv->status); -} - -/** - * cal_component_set_status: - * @comp: A calendar component object. - * @status: Status value. You should use #ICAL_STATUS_NONE if you want to unset - * this property. - * - * Sets the status property of a calendar component object. - **/ -void -cal_component_set_status (CalComponent *comp, icalproperty_status status) -{ - CalComponentPrivate *priv; - - g_return_if_fail (comp != NULL); - g_return_if_fail (IS_CAL_COMPONENT (comp)); - - priv = comp->priv; - g_return_if_fail (priv->icalcomp != NULL); - - priv->need_sequence_inc = TRUE; - - if (status == ICAL_STATUS_NONE) { - if (priv->status) { - icalcomponent_remove_property (priv->icalcomp, priv->status); - icalproperty_free (priv->status); - priv->status = NULL; - } - - return; - } - - if (priv->status) { - icalproperty_set_status (priv->status, status); - } else { - priv->status = icalproperty_new_status (status); - icalcomponent_add_property (priv->icalcomp, priv->status); - } -} - -/** - * cal_component_get_summary: - * @comp: A calendar component object. - * @summary: Return value for the summary property and its parameters. - * - * Queries the summary of a calendar component object. - **/ -void -cal_component_get_summary (CalComponent *comp, CalComponentText *summary) -{ - CalComponentPrivate *priv; - - g_return_if_fail (comp != NULL); - g_return_if_fail (IS_CAL_COMPONENT (comp)); - g_return_if_fail (summary != NULL); - - priv = comp->priv; - g_return_if_fail (priv->icalcomp != NULL); - - if (priv->summary.prop) - summary->value = icalproperty_get_summary (priv->summary.prop); - else - summary->value = NULL; - - if (priv->summary.altrep_param) - summary->altrep = icalparameter_get_altrep (priv->summary.altrep_param); - else - summary->altrep = NULL; -} - -/** - * cal_component_set_summary: - * @comp: A calendar component object. - * @summary: Summary property and its parameters. - * - * Sets the summary of a calendar component object. - **/ -void -cal_component_set_summary (CalComponent *comp, CalComponentText *summary) -{ - CalComponentPrivate *priv; - - g_return_if_fail (comp != NULL); - g_return_if_fail (IS_CAL_COMPONENT (comp)); - - priv = comp->priv; - g_return_if_fail (priv->icalcomp != NULL); - - if (!summary) { - if (priv->summary.prop) { - icalcomponent_remove_property (priv->icalcomp, priv->summary.prop); - icalproperty_free (priv->summary.prop); - - priv->summary.prop = NULL; - priv->summary.altrep_param = NULL; - } - - return; - } - - g_return_if_fail (summary->value != NULL); - - if (priv->summary.prop) - icalproperty_set_summary (priv->summary.prop, (char *) summary->value); - else { - priv->summary.prop = icalproperty_new_summary ((char *) summary->value); - icalcomponent_add_property (priv->icalcomp, priv->summary.prop); - } - - if (summary->altrep) { - g_assert (priv->summary.prop != NULL); - - if (priv->summary.altrep_param) - icalparameter_set_altrep (priv->summary.altrep_param, - (char *) summary->altrep); - else { - priv->summary.altrep_param = icalparameter_new_altrep ( - (char *) summary->altrep); - icalproperty_add_parameter (priv->summary.prop, - priv->summary.altrep_param); - } - } else if (priv->summary.altrep_param) { - icalproperty_remove_parameter (priv->summary.prop, ICAL_ALTREP_PARAMETER); - icalparameter_free (priv->summary.altrep_param); - priv->summary.altrep_param = NULL; - } -} - -/** - * cal_component_get_transparency: - * @comp: A calendar component object. - * @transp: Return value for the time transparency. - * - * Queries the time transparency of a calendar component object. - **/ -void -cal_component_get_transparency (CalComponent *comp, CalComponentTransparency *transp) -{ - CalComponentPrivate *priv; - icalproperty_transp ical_transp; - - g_return_if_fail (comp != NULL); - g_return_if_fail (IS_CAL_COMPONENT (comp)); - g_return_if_fail (transp != NULL); - - priv = comp->priv; - g_return_if_fail (priv->icalcomp != NULL); - - if (!priv->transparency) { - *transp = CAL_COMPONENT_TRANSP_NONE; - return; - } - - ical_transp = icalproperty_get_transp (priv->transparency); - - switch (ical_transp) - { - case ICAL_TRANSP_TRANSPARENT: - case ICAL_TRANSP_TRANSPARENTNOCONFLICT: - *transp = CAL_COMPONENT_TRANSP_TRANSPARENT; - break; - - case ICAL_TRANSP_OPAQUE: - case ICAL_TRANSP_OPAQUENOCONFLICT: - *transp = CAL_COMPONENT_TRANSP_OPAQUE; - break; - - default: - *transp = CAL_COMPONENT_TRANSP_UNKNOWN; - break; - } -} - -/** - * cal_component_set_transparency: - * @comp: A calendar component object. - * @transp: Time transparency value. - * - * Sets the time transparency of a calendar component object. - **/ -void -cal_component_set_transparency (CalComponent *comp, CalComponentTransparency transp) -{ - CalComponentPrivate *priv; - icalproperty_transp ical_transp; - - g_return_if_fail (comp != NULL); - g_return_if_fail (IS_CAL_COMPONENT (comp)); - g_return_if_fail (transp != CAL_COMPONENT_TRANSP_UNKNOWN); - - priv = comp->priv; - g_return_if_fail (priv->icalcomp != NULL); - - - if (transp == CAL_COMPONENT_TRANSP_NONE) { - if (priv->transparency) { - icalcomponent_remove_property (priv->icalcomp, priv->transparency); - icalproperty_free (priv->transparency); - priv->transparency = NULL; - } - - return; - } - - switch (transp) { - case CAL_COMPONENT_TRANSP_TRANSPARENT: - ical_transp = ICAL_TRANSP_TRANSPARENT; - break; - - case CAL_COMPONENT_TRANSP_OPAQUE: - ical_transp = ICAL_TRANSP_OPAQUE; - break; - - default: - g_assert_not_reached (); - ical_transp = ICAL_TRANSP_NONE; - } - - if (priv->transparency) - icalproperty_set_transp (priv->transparency, ical_transp); - else { - priv->transparency = icalproperty_new_transp (ical_transp); - icalcomponent_add_property (priv->icalcomp, priv->transparency); - } -} - -/** - * cal_component_get_url: - * @comp: A calendar component object. - * @url: Return value for the URL. - * - * Queries the uniform resource locator property of a calendar component object. - **/ -void -cal_component_get_url (CalComponent *comp, const char **url) -{ - CalComponentPrivate *priv; - - g_return_if_fail (comp != NULL); - g_return_if_fail (IS_CAL_COMPONENT (comp)); - g_return_if_fail (url != NULL); - - priv = comp->priv; - g_return_if_fail (priv->icalcomp != NULL); - - if (priv->url) - *url = icalproperty_get_url (priv->url); - else - *url = NULL; -} - -/** - * cal_component_set_url: - * @comp: A calendar component object. - * @url: URL value. - * - * Sets the uniform resource locator property of a calendar component object. - **/ -void -cal_component_set_url (CalComponent *comp, const char *url) -{ - CalComponentPrivate *priv; - - g_return_if_fail (comp != NULL); - g_return_if_fail (IS_CAL_COMPONENT (comp)); - - priv = comp->priv; - g_return_if_fail (priv->icalcomp != NULL); - - if (!url || !(*url)) { - if (priv->url) { - icalcomponent_remove_property (priv->icalcomp, priv->url); - icalproperty_free (priv->url); - priv->url = NULL; - } - - return; - } - - if (priv->url) - icalproperty_set_url (priv->url, (char *) url); - else { - priv->url = icalproperty_new_url ((char *) url); - icalcomponent_add_property (priv->icalcomp, priv->url); - } -} - -/* Gets a text list value */ -static void -get_attendee_list (GSList *attendee_list, GSList **al) -{ - GSList *l; - - *al = NULL; - - if (!attendee_list) - return; - - for (l = attendee_list; l; l = l->next) { - struct attendee *attendee; - CalComponentAttendee *a; - - attendee = l->data; - g_assert (attendee->prop != NULL); - - a = g_new0 (CalComponentAttendee, 1); - a->value = icalproperty_get_attendee (attendee->prop); - - if (attendee->member_param) - a->member = icalparameter_get_member (attendee->member_param); - if (attendee->cutype_param) - a->cutype = icalparameter_get_cutype (attendee->cutype_param); - if (attendee->role_param) - a->role = icalparameter_get_role (attendee->role_param); - if (attendee->partstat_param) - a->status = icalparameter_get_role (attendee->partstat_param); - if (attendee->rsvp_param && icalparameter_get_rsvp (attendee->rsvp_param) == ICAL_RSVP_TRUE) - a->rsvp = TRUE; - else - a->rsvp = FALSE; - if (attendee->delfrom_param) - a->delfrom = icalparameter_get_sentby (attendee->delfrom_param); - if (attendee->delto_param) - a->delto = icalparameter_get_sentby (attendee->delto_param); - if (attendee->sentby_param) - a->sentby = icalparameter_get_sentby (attendee->sentby_param); - if (attendee->cn_param) - a->cn = icalparameter_get_sentby (attendee->cn_param); - if (attendee->language_param) - a->language = icalparameter_get_sentby (attendee->language_param); - - *al = g_slist_prepend (*al, a); - } - - *al = g_slist_reverse (*al); -} - - -/* Sets a text list value */ -static void -set_attendee_list (icalcomponent *icalcomp, - GSList **attendee_list, - GSList *al) -{ - GSList *l; - - /* Remove old attendees */ - - for (l = *attendee_list; l; l = l->next) { - struct attendee *attendee; - - attendee = l->data; - g_assert (attendee->prop != NULL); - - icalcomponent_remove_property (icalcomp, attendee->prop); - icalproperty_free (attendee->prop); - g_free (attendee); - } - - g_slist_free (*attendee_list); - *attendee_list = NULL; - - /* Add in new attendees */ - - for (l = al; l; l = l->next) { - CalComponentAttendee *a; - struct attendee *attendee; - - a = l->data; - g_return_if_fail (a->value != NULL); - - attendee = g_new0 (struct attendee, 1); - - attendee->prop = icalproperty_new_attendee (a->value); - icalcomponent_add_property (icalcomp, attendee->prop); - - if (a->member) { - attendee->member_param = icalparameter_new_member (a->member); - icalproperty_add_parameter (attendee->prop, attendee->member_param); - } - - attendee->cutype_param = icalparameter_new_cutype (a->cutype); - icalproperty_add_parameter (attendee->prop, attendee->cutype_param); - - attendee->role_param = icalparameter_new_role (a->role); - icalproperty_add_parameter (attendee->prop, attendee->role_param); - - attendee->partstat_param = icalparameter_new_partstat (a->status); - icalproperty_add_parameter (attendee->prop, attendee->partstat_param); - - if (a->rsvp) - attendee->rsvp_param = icalparameter_new_rsvp (ICAL_RSVP_TRUE); - else - attendee->rsvp_param = icalparameter_new_rsvp (ICAL_RSVP_FALSE); - icalproperty_add_parameter (attendee->prop, attendee->rsvp_param); - - if (a->delfrom) { - attendee->delfrom_param = icalparameter_new_delegatedfrom (a->delfrom); - icalproperty_add_parameter (attendee->prop, attendee->delfrom_param); - } - if (a->delto) { - attendee->delto_param = icalparameter_new_delegatedto (a->delto); - icalproperty_add_parameter (attendee->prop, attendee->delto_param); - } - if (a->sentby) { - attendee->sentby_param = icalparameter_new_sentby (a->sentby); - icalproperty_add_parameter (attendee->prop, attendee->sentby_param); - } - if (a->cn) { - attendee->cn_param = icalparameter_new_cn (a->cn); - icalproperty_add_parameter (attendee->prop, attendee->cn_param); - } - if (a->language) { - attendee->language_param = icalparameter_new_language (a->language); - icalproperty_add_parameter (attendee->prop, attendee->language_param); - } - - *attendee_list = g_slist_prepend (*attendee_list, attendee); - } - - *attendee_list = g_slist_reverse (*attendee_list); -} - -/** - * cal_component_get_attendee_list: - * @comp: A calendar component object. - * @attendee_list: Return value for the attendee property. - * This should be freed using the cal_component_free_attendee_list () - * function. - * - * Queries the attendee properties of the calendar component object - **/ -void -cal_component_get_attendee_list (CalComponent *comp, GSList **attendee_list) -{ - CalComponentPrivate *priv; - - g_return_if_fail (comp != NULL); - g_return_if_fail (IS_CAL_COMPONENT (comp)); - g_return_if_fail (attendee_list != NULL); - - priv = comp->priv; - g_return_if_fail (priv->icalcomp != NULL); - - get_attendee_list (priv->attendee_list, attendee_list); -} - -/** - * cal_component_set_attendee_list: - * @comp: A calendar component object. - * @attendee_list: Values for attendee properties - * - * Sets the attendees of a calendar component object - **/ -void -cal_component_set_attendee_list (CalComponent *comp, GSList *attendee_list) -{ - CalComponentPrivate *priv; - - g_return_if_fail (comp != NULL); - g_return_if_fail (IS_CAL_COMPONENT (comp)); - - priv = comp->priv; - g_return_if_fail (priv->icalcomp != NULL); - - set_attendee_list (priv->icalcomp, &priv->attendee_list, attendee_list); -} - -gboolean -cal_component_has_attendees (CalComponent *comp) -{ - CalComponentPrivate *priv; - - g_return_val_if_fail (comp != NULL, FALSE); - g_return_val_if_fail (IS_CAL_COMPONENT (comp), FALSE); - - priv = comp->priv; - - if (g_slist_length (priv->attendee_list) > 0) - return TRUE; - - return FALSE; -} - -/** - * cal_component_get_location: - * @comp: A calendar component object. - * @url: Return value for the location. - * - * Queries the location property of a calendar component object. - **/ -void -cal_component_get_location (CalComponent *comp, const char **location) -{ - CalComponentPrivate *priv; - - g_return_if_fail (comp != NULL); - g_return_if_fail (IS_CAL_COMPONENT (comp)); - g_return_if_fail (location != NULL); - - priv = comp->priv; - g_return_if_fail (priv->icalcomp != NULL); - - if (priv->location) - *location = icalproperty_get_location (priv->location); - else - *location = NULL; -} - -/** - * cal_component_set_location: - * @comp: A calendar component object. - * @url: Location value. - * - * Sets the location property of a calendar component object. - **/ -void -cal_component_set_location (CalComponent *comp, const char *location) -{ - CalComponentPrivate *priv; - - g_return_if_fail (comp != NULL); - g_return_if_fail (IS_CAL_COMPONENT (comp)); - - priv = comp->priv; - g_return_if_fail (priv->icalcomp != NULL); - - if (!location || !(*location)) { - if (priv->location) { - icalcomponent_remove_property (priv->icalcomp, priv->location); - icalproperty_free (priv->location); - priv->location = NULL; - } - - return; - } - - if (priv->location) - icalproperty_set_location (priv->location, (char *) location); - else { - priv->location = icalproperty_new_location ((char *) location); - icalcomponent_add_property (priv->icalcomp, priv->location); - } -} - - - -/** - * cal_component_free_categories_list: - * @categ_list: List of category strings. - * - * Frees a list of category strings. - **/ -void -cal_component_free_categories_list (GSList *categ_list) -{ - GSList *l; - - for (l = categ_list; l; l = l->next) - g_free (l->data); - - g_slist_free (categ_list); -} - -/** - * cal_component_free_datetime: - * @dt: A date/time structure. - * - * Frees a date/time structure. - **/ -void -cal_component_free_datetime (CalComponentDateTime *dt) -{ - g_return_if_fail (dt != NULL); - - g_free (dt->value); - g_free ((char*)dt->tzid); -} - -void -cal_component_free_range (CalComponentRange *range) -{ - g_return_if_fail (range != NULL); - - cal_component_free_datetime (&range->datetime); -} - -/** - * cal_component_free_exdate_list: - * @exdate_list: List of #CalComponentDateTime structures. - * - * Frees a list of #CalComponentDateTime structures as returned by the - * cal_component_get_exdate_list() function. - **/ -void -cal_component_free_exdate_list (GSList *exdate_list) -{ - GSList *l; - - for (l = exdate_list; l; l = l->next) { - CalComponentDateTime *cdt; - - g_assert (l->data != NULL); - cdt = l->data; - - g_assert (cdt->value != NULL); - g_free (cdt->value); - g_free ((char*)cdt->tzid); - - g_free (cdt); - } - - g_slist_free (exdate_list); -} - -/** - * cal_component_free_geo: - * @geo: An #icalgeotype structure. - * - * Frees a struct #icalgeotype structure as returned by the calendar component - * functions. - **/ -void -cal_component_free_geo (struct icalgeotype *geo) -{ - g_return_if_fail (geo != NULL); - - g_free (geo); -} - -/** - * cal_component_free_icaltimetype: - * @t: An #icaltimetype structure. - * - * Frees a struct #icaltimetype value as returned by the calendar component - * functions. - **/ -void -cal_component_free_icaltimetype (struct icaltimetype *t) -{ - g_return_if_fail (t != NULL); - - g_free (t); -} - -/** - * cal_component_free_percent: - * @percent: Percent value. - * - * Frees a percent value as returned by the cal_component_get_percent() - * function. - **/ -void -cal_component_free_percent (int *percent) -{ - g_return_if_fail (percent != NULL); - - g_free (percent); -} - -/** - * cal_component_free_priority: - * @priority: Priority value. - * - * Frees a priority value as returned by the cal_component_get_priority() - * function. - **/ -void -cal_component_free_priority (int *priority) -{ - g_return_if_fail (priority != NULL); - - g_free (priority); -} - -/** - * cal_component_free_period_list: - * @period_list: List of #CalComponentPeriod structures. - * - * Frees a list of #CalComponentPeriod structures. - **/ -void -cal_component_free_period_list (GSList *period_list) -{ - GSList *l; - - for (l = period_list; l; l = l->next) { - CalComponentPeriod *period; - - g_assert (l->data != NULL); - - period = l->data; - g_free (period); - } - - g_slist_free (period_list); -} - -/** - * cal_component_free_recur_list: - * @recur_list: List of struct #icalrecurrencetype structures. - * - * Frees a list of struct #icalrecurrencetype structures. - **/ -void -cal_component_free_recur_list (GSList *recur_list) -{ - GSList *l; - - for (l = recur_list; l; l = l->next) { - struct icalrecurrencetype *r; - - g_assert (l->data != NULL); - r = l->data; - - g_free (r); - } - - g_slist_free (recur_list); -} - -/** - * cal_component_free_sequence: - * @sequence: Sequence number value. - * - * Frees a sequence number value. - **/ -void -cal_component_free_sequence (int *sequence) -{ - g_return_if_fail (sequence != NULL); - - g_free (sequence); -} - -/** - * cal_component_free_text_list: - * @text_list: List of #CalComponentText structures. - * - * Frees a list of #CalComponentText structures. This function should only be - * used to free lists of text values as returned by the other getter functions - * of #CalComponent. - **/ -void -cal_component_free_text_list (GSList *text_list) -{ - GSList *l; - - for (l = text_list; l; l = l->next) { - CalComponentText *text; - - g_assert (l->data != NULL); - - text = l->data; - g_return_if_fail (text != NULL); - g_free (text); - } - - g_slist_free (text_list); -} - -/** - * cal_component_free_attendee_list: - * @attendee_list: - * - * - **/ -void -cal_component_free_attendee_list (GSList *attendee_list) -{ - GSList *l; - - for (l = attendee_list; l; l = l->next) { - CalComponentAttendee *attendee; - - g_assert (l->data != NULL); - - attendee = l->data; - g_return_if_fail (attendee != NULL); - g_free (attendee); - } - - g_slist_free (attendee_list); -} - - - -/** - * cal_component_has_alarms: - * @comp: A calendar component object. - * - * Checks whether the component has any alarms. - * - * Return value: TRUE if the component has any alarms. - **/ -gboolean -cal_component_has_alarms (CalComponent *comp) -{ - CalComponentPrivate *priv; - - g_return_val_if_fail (comp != NULL, FALSE); - g_return_val_if_fail (IS_CAL_COMPONENT (comp), FALSE); - - priv = comp->priv; - g_return_val_if_fail (priv->icalcomp != NULL, FALSE); - - return g_hash_table_size (priv->alarm_uid_hash) != 0; -} - -/** - * cal_component_add_alarm: - * @comp: A calendar component. - * @alarm: An alarm. - * - * Adds an alarm subcomponent to a calendar component. You should have created - * the @alarm by using cal_component_alarm_new(); it is invalid to use a - * #CalComponentAlarm structure that came from cal_component_get_alarm(). After - * adding the alarm, the @alarm structure is no longer valid because the - * internal structures may change and you should get rid of it by using - * cal_component_alarm_free(). - **/ -void -cal_component_add_alarm (CalComponent *comp, CalComponentAlarm *alarm) -{ - CalComponentPrivate *priv; - - g_return_if_fail (comp != NULL); - g_return_if_fail (IS_CAL_COMPONENT (comp)); - g_return_if_fail (alarm != NULL); - - priv = comp->priv; - - add_alarm (comp, alarm->icalcomp, icalproperty_get_x (alarm->uid)); - icalcomponent_add_component (priv->icalcomp, alarm->icalcomp); -} - -/** - * cal_component_remove_alarm: - * @comp: A calendar component. - * @auid: UID of the alarm to remove. - * - * Removes an alarm subcomponent from a calendar component. If the alarm that - * corresponds to the specified @auid had been fetched with - * cal_component_get_alarm(), then those alarm structures will be invalid; you - * should get rid of them with cal_component_alarm_free() before using this - * function. - **/ -void -cal_component_remove_alarm (CalComponent *comp, const char *auid) -{ - CalComponentPrivate *priv; - icalcomponent *alarm; - - g_return_if_fail (comp != NULL); - g_return_if_fail (IS_CAL_COMPONENT (comp)); - g_return_if_fail (auid != NULL); - - priv = comp->priv; - g_return_if_fail (priv->icalcomp != NULL); - - alarm = g_hash_table_lookup (priv->alarm_uid_hash, auid); - if (!alarm) - return; - - g_hash_table_remove (priv->alarm_uid_hash, auid); - icalcomponent_remove_component (priv->icalcomp, alarm); - icalcomponent_free (alarm); -} - -static gboolean -for_each_remove_all_alarms (gpointer key, gpointer value, gpointer data) -{ - CalComponent *comp = CAL_COMPONENT (data); - CalComponentPrivate *priv; - icalcomponent *alarm = value; - - priv = comp->priv; - - icalcomponent_remove_component (priv->icalcomp, alarm); - icalcomponent_free (alarm); - - return TRUE; -} - -/** - * cal_component_remove_all_alarms: - * @comp: A calendar component - * - * Remove all alarms from the calendar component - **/ -void -cal_component_remove_all_alarms (CalComponent *comp) -{ - CalComponentPrivate *priv; - - g_return_if_fail (comp != NULL); - g_return_if_fail (IS_CAL_COMPONENT (comp)); - - priv = comp->priv; - g_return_if_fail (priv->icalcomp != NULL); - - g_hash_table_foreach_remove (priv->alarm_uid_hash, for_each_remove_all_alarms, comp); -} - - -/* Scans an icalproperty from a calendar component and adds its mapping to our - * own alarm structure. - */ -static void -scan_alarm_property (CalComponentAlarm *alarm, icalproperty *prop) -{ - icalproperty_kind kind; - const char *xname; - - kind = icalproperty_isa (prop); - - switch (kind) { - case ICAL_ACTION_PROPERTY: - alarm->action = prop; - break; - - case ICAL_ATTACH_PROPERTY: - /* FIXME: mail alarms may have any number of these, not just one */ - alarm->attach = prop; - break; - - case ICAL_DESCRIPTION_PROPERTY: - alarm->description.prop = prop; - alarm->description.altrep_param = icalproperty_get_first_parameter ( - prop, ICAL_ALTREP_PARAMETER); - break; - - case ICAL_DURATION_PROPERTY: - alarm->duration = prop; - break; - - case ICAL_REPEAT_PROPERTY: - alarm->repeat = prop; - break; - - case ICAL_TRIGGER_PROPERTY: - alarm->trigger = prop; - break; - - case ICAL_ATTENDEE_PROPERTY: - scan_attendee (&alarm->attendee_list, prop); - break; - - case ICAL_X_PROPERTY: - xname = icalproperty_get_x_name (prop); - g_assert (xname != NULL); - - if (strcmp (xname, EVOLUTION_ALARM_UID_PROPERTY) == 0) - alarm->uid = prop; - - break; - - default: - break; - } -} - -/* Creates a CalComponentAlarm from a libical alarm subcomponent */ -static CalComponentAlarm * -make_alarm (icalcomponent *subcomp) -{ - CalComponentAlarm *alarm; - icalproperty *prop; - - alarm = g_new (CalComponentAlarm, 1); - - alarm->icalcomp = subcomp; - alarm->uid = NULL; - - alarm->action = NULL; - alarm->attach = NULL; - alarm->description.prop = NULL; - alarm->description.altrep_param = NULL; - alarm->duration = NULL; - alarm->repeat = NULL; - alarm->trigger = NULL; - alarm->attendee_list = NULL; - - for (prop = icalcomponent_get_first_property (subcomp, ICAL_ANY_PROPERTY); - prop; - prop = icalcomponent_get_next_property (subcomp, ICAL_ANY_PROPERTY)) - scan_alarm_property (alarm, prop); - - g_assert (alarm->uid != NULL); - - return alarm; -} - -/** - * cal_component_get_alarm_uids: - * @comp: A calendar component. - * - * Builds a list of the unique identifiers of the alarm subcomponents inside a - * calendar component. - * - * Return value: List of unique identifiers for alarms. This should be freed - * using cal_obj_uid_list_free(). - **/ -GList * -cal_component_get_alarm_uids (CalComponent *comp) -{ - CalComponentPrivate *priv; - icalcompiter iter; - GList *l; - - g_return_val_if_fail (comp != NULL, NULL); - g_return_val_if_fail (IS_CAL_COMPONENT (comp), NULL); - - priv = comp->priv; - g_return_val_if_fail (priv->icalcomp != NULL, NULL); - - l = NULL; - for (iter = icalcomponent_begin_component (priv->icalcomp, ICAL_VALARM_COMPONENT); - icalcompiter_deref (&iter) != NULL; - icalcompiter_next (&iter)) { - icalcomponent *subcomp; - icalproperty *prop; - - subcomp = icalcompiter_deref (&iter); - for (prop = icalcomponent_get_first_property (subcomp, ICAL_X_PROPERTY); - prop; - prop = icalcomponent_get_next_property (subcomp, ICAL_X_PROPERTY)) { - const char *xname; - - xname = icalproperty_get_x_name (prop); - g_assert (xname != NULL); - - if (strcmp (xname, EVOLUTION_ALARM_UID_PROPERTY) == 0) { - const char *auid; - - auid = alarm_uid_from_prop (prop); - l = g_list_append (l, g_strdup (auid)); - } - } - } - - return l; -} - -/** - * cal_component_get_alarm: - * @comp: A calendar component. - * @auid: Unique identifier for the sought alarm subcomponent. - * - * Queries a particular alarm subcomponent of a calendar component. - * - * Return value: The alarm subcomponent that corresponds to the specified @auid, - * or #NULL if no alarm exists with that UID. This should be freed using - * cal_component_alarm_free(). - **/ -CalComponentAlarm * -cal_component_get_alarm (CalComponent *comp, const char *auid) -{ - CalComponentPrivate *priv; - icalcomponent *alarm; - - g_return_val_if_fail (comp != NULL, NULL); - g_return_val_if_fail (IS_CAL_COMPONENT (comp), NULL); - - priv = comp->priv; - g_return_val_if_fail (priv->icalcomp != NULL, NULL); - - g_return_val_if_fail (auid != NULL, NULL); - - alarm = g_hash_table_lookup (priv->alarm_uid_hash, auid); - - if (alarm) - return make_alarm (alarm); - else - return NULL; -} - -/** - * cal_component_alarms_free: - * @alarms: Component alarms structure. - * - * Frees a #CalComponentAlarms structure. - **/ -void -cal_component_alarms_free (CalComponentAlarms *alarms) -{ - GSList *l; - - g_return_if_fail (alarms != NULL); - - g_assert (alarms->comp != NULL); - g_object_unref (G_OBJECT (alarms->comp)); - - for (l = alarms->alarms; l; l = l->next) { - CalAlarmInstance *instance; - - instance = l->data; - g_assert (instance != NULL); - g_free (instance); - } - - g_slist_free (alarms->alarms); - g_free (alarms); -} - -/** - * cal_component_alarm_new: - * - * - * - * Return value: a new alarm component - **/ -CalComponentAlarm * -cal_component_alarm_new (void) -{ - CalComponentAlarm *alarm; - char *new_auid ; - - alarm = g_new (CalComponentAlarm, 1); - - alarm->icalcomp = icalcomponent_new (ICAL_VALARM_COMPONENT); - - new_auid = cal_component_gen_uid (); - alarm->uid = icalproperty_new_x (new_auid); - icalproperty_set_x_name (alarm->uid, EVOLUTION_ALARM_UID_PROPERTY); - icalcomponent_add_property (alarm->icalcomp, alarm->uid); - g_free (new_auid); - - alarm->action = NULL; - alarm->attach = NULL; - alarm->description.prop = NULL; - alarm->description.altrep_param = NULL; - alarm->duration = NULL; - alarm->repeat = NULL; - alarm->trigger = NULL; - alarm->attendee_list = NULL; - - return alarm; -} - -/** - * cal_component_alarm_clone: - * @alarm: An alarm subcomponent. - * - * Creates a new alarm subcomponent by copying the information from another one. - * - * Return value: A newly-created alarm subcomponent with the same values as the - * original one. Should be freed with cal_component_alarm_free(). - **/ -CalComponentAlarm * -cal_component_alarm_clone (CalComponentAlarm *alarm) -{ - icalcomponent *icalcomp; - - g_return_val_if_fail (alarm != NULL, NULL); - - icalcomp = icalcomponent_new_clone (alarm->icalcomp); - return make_alarm (icalcomp); -} - -/** - * cal_component_alarm_free: - * @alarm: A calendar alarm. - * - * Frees an alarm structure. - **/ -void -cal_component_alarm_free (CalComponentAlarm *alarm) -{ - GSList *l; - - g_return_if_fail (alarm != NULL); - - g_assert (alarm->icalcomp != NULL); - - if (icalcomponent_get_parent (alarm->icalcomp) == NULL) - icalcomponent_free (alarm->icalcomp); - - alarm->icalcomp = NULL; - alarm->uid = NULL; - alarm->action = NULL; - alarm->attach = NULL; - alarm->description.prop = NULL; - alarm->description.altrep_param = NULL; - alarm->duration = NULL; - alarm->repeat = NULL; - alarm->trigger = NULL; - - for (l = alarm->attendee_list; l != NULL; l = l->next) - g_free (l->data); - g_slist_free (alarm->attendee_list); - alarm->attendee_list = NULL; - - g_free (alarm); -} - -/** - * cal_component_alarm_get_uid: - * @alarm: An alarm subcomponent. - * - * Queries the unique identifier of an alarm subcomponent. - * - * Return value: UID of the alarm. - **/ -const char * -cal_component_alarm_get_uid (CalComponentAlarm *alarm) -{ - g_return_val_if_fail (alarm != NULL, NULL); - - return alarm_uid_from_prop (alarm->uid); -} - -/** - * cal_component_alarm_get_action: - * @alarm: An alarm. - * @action: Return value for the alarm's action type. - * - * Queries the action type of an alarm. - **/ -void -cal_component_alarm_get_action (CalComponentAlarm *alarm, CalAlarmAction *action) -{ - enum icalproperty_action ipa; - - g_return_if_fail (alarm != NULL); - g_return_if_fail (action != NULL); - - g_assert (alarm->icalcomp != NULL); - - if (!alarm->action) { - *action = CAL_ALARM_NONE; - return; - } - - ipa = icalproperty_get_action (alarm->action); - - switch (ipa) { - case ICAL_ACTION_AUDIO: - *action = CAL_ALARM_AUDIO; - break; - - case ICAL_ACTION_DISPLAY: - *action = CAL_ALARM_DISPLAY; - break; - - case ICAL_ACTION_EMAIL: - *action = CAL_ALARM_EMAIL; - break; - - case ICAL_ACTION_PROCEDURE: - *action = CAL_ALARM_PROCEDURE; - break; - - case ICAL_ACTION_NONE: - *action = CAL_ALARM_NONE; - break; - - default: - *action = CAL_ALARM_UNKNOWN; - } -} - -/** - * cal_component_alarm_set_action: - * @alarm: An alarm. - * @action: Action type. - * - * Sets the action type for an alarm. - **/ -void -cal_component_alarm_set_action (CalComponentAlarm *alarm, CalAlarmAction action) -{ - enum icalproperty_action ipa; - - g_return_if_fail (alarm != NULL); - g_return_if_fail (action != CAL_ALARM_NONE); - g_return_if_fail (action != CAL_ALARM_UNKNOWN); - - g_assert (alarm->icalcomp != NULL); - - switch (action) { - case CAL_ALARM_AUDIO: - ipa = ICAL_ACTION_AUDIO; - break; - - case CAL_ALARM_DISPLAY: - ipa = ICAL_ACTION_DISPLAY; - break; - - case CAL_ALARM_EMAIL: - ipa = ICAL_ACTION_EMAIL; - break; - - case CAL_ALARM_PROCEDURE: - ipa = ICAL_ACTION_PROCEDURE; - break; - - default: - g_assert_not_reached (); - ipa = ICAL_ACTION_NONE; - } - - if (alarm->action) - icalproperty_set_action (alarm->action, ipa); - else { - alarm->action = icalproperty_new_action (ipa); - icalcomponent_add_property (alarm->icalcomp, alarm->action); - } -} - -/** - * cal_component_alarm_get_attach: - * @alarm: An alarm. - * @attach: Return value for the attachment; should be freed using icalattach_unref(). - * - * Queries the attachment property of an alarm. - **/ -void -cal_component_alarm_get_attach (CalComponentAlarm *alarm, icalattach **attach) -{ - g_return_if_fail (alarm != NULL); - g_return_if_fail (attach != NULL); - - g_assert (alarm->icalcomp != NULL); - - if (alarm->attach) { - *attach = icalproperty_get_attach (alarm->attach); - icalattach_ref (*attach); - } else - *attach = NULL; -} - -/** - * cal_component_alarm_set_attach: - * @alarm: An alarm. - * @attach: Attachment property or NULL to remove an existing property. - * - * Sets the attachment property of an alarm. - **/ -void -cal_component_alarm_set_attach (CalComponentAlarm *alarm, icalattach *attach) -{ - g_return_if_fail (alarm != NULL); - - g_assert (alarm->icalcomp != NULL); - - if (alarm->attach) { - icalcomponent_remove_property (alarm->icalcomp, alarm->attach); - icalproperty_free (alarm->attach); - alarm->attach = NULL; - } - - if (attach) { - alarm->attach = icalproperty_new_attach (attach); - icalcomponent_add_property (alarm->icalcomp, alarm->attach); - } -} - -/** - * cal_component_alarm_get_description: - * @alarm: An alarm. - * @description: Return value for the description property and its parameters. - * - * Queries the description property of an alarm. - **/ -void -cal_component_alarm_get_description (CalComponentAlarm *alarm, CalComponentText *description) -{ - g_return_if_fail (alarm != NULL); - g_return_if_fail (description != NULL); - - g_assert (alarm->icalcomp != NULL); - - if (alarm->description.prop) - description->value = icalproperty_get_description (alarm->description.prop); - else - description->value = NULL; - - if (alarm->description.altrep_param) - description->altrep = icalparameter_get_altrep (alarm->description.altrep_param); - else - description->altrep = NULL; -} - -/** - * cal_component_alarm_set_description: - * @alarm: An alarm. - * @description: Description property and its parameters, or NULL for no description. - * - * Sets the description property of an alarm. - **/ -void -cal_component_alarm_set_description (CalComponentAlarm *alarm, CalComponentText *description) -{ - g_return_if_fail (alarm != NULL); - - g_assert (alarm->icalcomp != NULL); - - if (alarm->description.prop) { - icalcomponent_remove_property (alarm->icalcomp, alarm->description.prop); - icalproperty_free (alarm->description.prop); - - alarm->description.prop = NULL; - alarm->description.altrep_param = NULL; - } - - if (!description) - return; - - g_return_if_fail (description->value != NULL); - - alarm->description.prop = icalproperty_new_description (description->value); - icalcomponent_add_property (alarm->icalcomp, alarm->description.prop); - - if (description->altrep) { - alarm->description.altrep_param = icalparameter_new_altrep ( - (char *) description->altrep); - icalproperty_add_parameter (alarm->description.prop, - alarm->description.altrep_param); - } -} - -/** - * cal_component_alarm_get_repeat: - * @alarm: An alarm. - * @repeat: Return value for the repeat/duration properties. - * - * Queries the repeat/duration properties of an alarm. - **/ -void -cal_component_alarm_get_repeat (CalComponentAlarm *alarm, CalAlarmRepeat *repeat) -{ - g_return_if_fail (alarm != NULL); - g_return_if_fail (repeat != NULL); - - g_assert (alarm->icalcomp != NULL); - - if (!(alarm->repeat && alarm->duration)) { - repeat->repetitions = 0; - memset (&repeat->duration, 0, sizeof (repeat->duration)); - return; - } - - repeat->repetitions = icalproperty_get_repeat (alarm->repeat); - repeat->duration = icalproperty_get_duration (alarm->duration); -} - -/** - * cal_component_alarm_set_repeat: - * @alarm: An alarm. - * @repeat: Repeat/duration values. To remove any repetitions from the alarm, - * set the @repeat.repetitions to 0. - * - * Sets the repeat/duration values for an alarm. - **/ -void -cal_component_alarm_set_repeat (CalComponentAlarm *alarm, CalAlarmRepeat repeat) -{ - g_return_if_fail (alarm != NULL); - g_return_if_fail (repeat.repetitions >= 0); - - g_assert (alarm->icalcomp != NULL); - - /* Delete old properties */ - - if (alarm->repeat) { - icalcomponent_remove_property (alarm->icalcomp, alarm->repeat); - icalproperty_free (alarm->repeat); - alarm->repeat = NULL; - } - - if (alarm->duration) { - icalcomponent_remove_property (alarm->icalcomp, alarm->duration); - icalproperty_free (alarm->duration); - alarm->duration = NULL; - } - - /* Set the new properties */ - - if (repeat.repetitions == 0) - return; /* For zero extra repetitions the properties should not exist */ - - alarm->repeat = icalproperty_new_repeat (repeat.repetitions); - icalcomponent_add_property (alarm->icalcomp, alarm->repeat); - - alarm->duration = icalproperty_new_duration (repeat.duration); - icalcomponent_add_property (alarm->icalcomp, alarm->duration); -} - -/** - * cal_component_alarm_get_trigger: - * @alarm: An alarm. - * @trigger: Return value for the trigger time. - * - * Queries the trigger time for an alarm. - **/ -void -cal_component_alarm_get_trigger (CalComponentAlarm *alarm, CalAlarmTrigger *trigger) -{ - icalparameter *param; - struct icaltriggertype t; - gboolean relative; - - g_return_if_fail (alarm != NULL); - g_return_if_fail (trigger != NULL); - - g_assert (alarm->icalcomp != NULL); - - if (!alarm->trigger) { - trigger->type = CAL_ALARM_TRIGGER_NONE; - return; - } - - /* Get trigger type */ - - param = icalproperty_get_first_parameter (alarm->trigger, ICAL_VALUE_PARAMETER); - if (param) { - icalparameter_value value; - - value = icalparameter_get_value (param); - - switch (value) { - case ICAL_VALUE_DURATION: - relative = TRUE; - break; - - case ICAL_VALUE_DATETIME: - relative = FALSE; - break; - - default: - g_message ("cal_component_alarm_get_trigger(): Unknown value for trigger " - "value %d; using RELATIVE", value); - - relative = TRUE; - break; - } - } else - relative = TRUE; - - /* Get trigger value and the RELATED parameter */ - - t = icalproperty_get_trigger (alarm->trigger); - - if (relative) { - trigger->u.rel_duration = t.duration; - - param = icalproperty_get_first_parameter (alarm->trigger, ICAL_RELATED_PARAMETER); - if (param) { - icalparameter_related rel; - - rel = icalparameter_get_related (param); - - switch (rel) { - case ICAL_RELATED_START: - trigger->type = CAL_ALARM_TRIGGER_RELATIVE_START; - break; - - case ICAL_RELATED_END: - trigger->type = CAL_ALARM_TRIGGER_RELATIVE_END; - break; - - default: - g_assert_not_reached (); - } - } else - trigger->type = CAL_ALARM_TRIGGER_RELATIVE_START; - } else { - trigger->u.abs_time = t.time; - trigger->type = CAL_ALARM_TRIGGER_ABSOLUTE; - } -} - -/** - * cal_component_alarm_set_trigger: - * @alarm: An alarm. - * @trigger: Trigger time structure. - * - * Sets the trigger time of an alarm. - **/ -void -cal_component_alarm_set_trigger (CalComponentAlarm *alarm, CalAlarmTrigger trigger) -{ - struct icaltriggertype t; - icalparameter *param; - icalparameter_value value_type; - icalparameter_related related; - - g_return_if_fail (alarm != NULL); - g_return_if_fail (trigger.type != CAL_ALARM_TRIGGER_NONE); - - g_assert (alarm->icalcomp != NULL); - - /* Delete old trigger */ - - if (alarm->trigger) { - icalcomponent_remove_property (alarm->icalcomp, alarm->trigger); - icalproperty_free (alarm->trigger); - alarm->trigger = NULL; - } - - /* Set the value */ - - related = ICAL_RELATED_START; /* Keep GCC happy */ - - t.time = icaltime_null_time (); - t.duration = icaldurationtype_null_duration (); - switch (trigger.type) { - case CAL_ALARM_TRIGGER_RELATIVE_START: - t.duration = trigger.u.rel_duration; - value_type = ICAL_VALUE_DURATION; - related = ICAL_RELATED_START; - break; - - case CAL_ALARM_TRIGGER_RELATIVE_END: - t.duration = trigger.u.rel_duration; - value_type = ICAL_VALUE_DURATION; - related = ICAL_RELATED_END; - break; - - case CAL_ALARM_TRIGGER_ABSOLUTE: - t.time = trigger.u.abs_time; - value_type = ICAL_VALUE_DATETIME; - break; - - default: - g_assert_not_reached (); - return; - } - - alarm->trigger = icalproperty_new_trigger (t); - icalcomponent_add_property (alarm->icalcomp, alarm->trigger); - - /* Value parameters */ - - param = icalproperty_get_first_parameter (alarm->trigger, ICAL_VALUE_PARAMETER); - if (param) - icalparameter_set_value (param, value_type); - else { - param = icalparameter_new_value (value_type); - icalproperty_add_parameter (alarm->trigger, param); - } - - /* Related parameter */ - - if (trigger.type != CAL_ALARM_TRIGGER_ABSOLUTE) { - param = icalproperty_get_first_parameter (alarm->trigger, ICAL_RELATED_PARAMETER); - - if (param) - icalparameter_set_related (param, related); - else { - param = icalparameter_new_related (related); - icalproperty_add_parameter (alarm->trigger, param); - } - } -} - -void -cal_component_alarm_get_attendee_list (CalComponentAlarm *alarm, GSList **attendee_list) -{ - g_return_if_fail (alarm != NULL); - - get_attendee_list (alarm->attendee_list, attendee_list); -} - -void -cal_component_alarm_set_attendee_list (CalComponentAlarm *alarm, GSList *attendee_list) -{ - g_return_if_fail (alarm != NULL); - - set_attendee_list (alarm->icalcomp, &alarm->attendee_list, attendee_list); -} - -gboolean -cal_component_alarm_has_attendees (CalComponentAlarm *alarm) -{ - - g_return_val_if_fail (alarm != NULL, FALSE); - - if (g_slist_length (alarm->attendee_list) > 0) - return TRUE; - - return FALSE; -} - - -/** - * cal_component_alarm_get_icalcomponent - * @alarm: An alarm. - * - * Get the icalcomponent associated with the given #CalComponentAlarm. - * - * Returns: the icalcomponent. - */ -icalcomponent * -cal_component_alarm_get_icalcomponent (CalComponentAlarm *alarm) -{ - g_return_val_if_fail (alarm != NULL, NULL); - return alarm->icalcomp; -} - -/* Returns TRUE if both strings match, i.e. they are both NULL or the - strings are equal. */ -static gboolean -cal_component_strings_match (const gchar *string1, - const gchar *string2) -{ - if (string1 == NULL || string2 == NULL) - return (string1 == string2) ? TRUE : FALSE; - - if (!strcmp (string1, string2)) - return TRUE; - - return FALSE; -} - - -/** - * cal_component_event_dates_match: - * @comp1: A calendar component object. - * @comp2: A calendar component object. - * - * Checks if the DTSTART and DTEND properties of the 2 components match. - * Note that the events may have different recurrence properties which are not - * taken into account here. - * - * Returns: TRUE if the DTSTART and DTEND properties of the 2 components match. - **/ -gboolean -cal_component_event_dates_match (CalComponent *comp1, - CalComponent *comp2) -{ - CalComponentDateTime comp1_dtstart, comp1_dtend; - CalComponentDateTime comp2_dtstart, comp2_dtend; - gboolean retval = TRUE; - - cal_component_get_dtstart (comp1, &comp1_dtstart); - cal_component_get_dtend (comp1, &comp1_dtend); - cal_component_get_dtstart (comp2, &comp2_dtstart); - cal_component_get_dtend (comp2, &comp2_dtend); - - /* If either value is NULL they must both be NULL to match. */ - if (comp1_dtstart.value == NULL || comp2_dtstart.value == NULL) { - if (comp1_dtstart.value != comp2_dtstart.value) { - retval = FALSE; - goto out; - } - } else { - if (icaltime_compare (*comp1_dtstart.value, - *comp2_dtstart.value)) { - retval = FALSE; - goto out; - } - } - - if (comp1_dtend.value == NULL || comp2_dtend.value == NULL) { - if (comp1_dtend.value != comp2_dtend.value) { - retval = FALSE; - goto out; - } - } else { - if (icaltime_compare (*comp1_dtend.value, - *comp2_dtend.value)) { - retval = FALSE; - goto out; - } - } - - /* Now check the timezones. */ - if (!cal_component_strings_match (comp1_dtstart.tzid, - comp2_dtstart.tzid)) { - retval = FALSE; - goto out; - } - - if (!cal_component_strings_match (comp1_dtend.tzid, - comp2_dtend.tzid)) { - retval = FALSE; - } - - out: - - cal_component_free_datetime (&comp1_dtstart); - cal_component_free_datetime (&comp1_dtend); - cal_component_free_datetime (&comp2_dtstart); - cal_component_free_datetime (&comp2_dtend); - - return retval; -} - - diff --git a/calendar/cal-util/cal-component.h b/calendar/cal-util/cal-component.h deleted file mode 100644 index 3296c7b31c..0000000000 --- a/calendar/cal-util/cal-component.h +++ /dev/null @@ -1,449 +0,0 @@ -/* Evolution calendar - iCalendar component object - * - * Copyright (C) 2000 Ximian, Inc. - * Copyright (C) 2000 Ximian, Inc. - * - * Author: Federico Mena-Quintero <federico@ximian.com> - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of version 2 of the GNU General Public - * License as published by the Free Software Foundation. - * - * 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA. - */ - -#ifndef CAL_COMPONENT_H -#define CAL_COMPONENT_H - -#include <glib/gmacros.h> -#include <time.h> -#include <glib-object.h> -#include <libical/ical.h> - -G_BEGIN_DECLS - - - -#define CAL_COMPONENT_TYPE (cal_component_get_type ()) -#define CAL_COMPONENT(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), CAL_COMPONENT_TYPE, CalComponent)) -#define CAL_COMPONENT_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), CAL_COMPONENT_TYPE, \ - CalComponentClass)) -#define IS_CAL_COMPONENT(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), CAL_COMPONENT_TYPE)) -#define IS_CAL_COMPONENT_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), CAL_COMPONENT_TYPE)) - -/* Types of calendar components to be stored by a CalComponent, as per RFC 2445. - * We don't put the alarm component type here since we store alarms as separate - * structures inside the other "real" components. - */ -typedef enum { - CAL_COMPONENT_NO_TYPE, - CAL_COMPONENT_EVENT, - CAL_COMPONENT_TODO, - CAL_COMPONENT_JOURNAL, - CAL_COMPONENT_FREEBUSY, - CAL_COMPONENT_TIMEZONE -} CalComponentVType; - -/* Field identifiers for a calendar component; these are used by the data model - * for ETable. - * - * NOTE: These are also used in the ETable specification, and the column - * numbers are saved in the user settings file. So don't reorder them! - */ -typedef enum { - CAL_COMPONENT_FIELD_CATEGORIES, /* concatenation of the categories list */ - CAL_COMPONENT_FIELD_CLASSIFICATION, - CAL_COMPONENT_FIELD_COMPLETED, - CAL_COMPONENT_FIELD_DTEND, - CAL_COMPONENT_FIELD_DTSTART, - CAL_COMPONENT_FIELD_DUE, - CAL_COMPONENT_FIELD_GEO, - CAL_COMPONENT_FIELD_PERCENT, - CAL_COMPONENT_FIELD_PRIORITY, - CAL_COMPONENT_FIELD_SUMMARY, - CAL_COMPONENT_FIELD_TRANSPARENCY, - CAL_COMPONENT_FIELD_URL, - CAL_COMPONENT_FIELD_HAS_ALARMS, /* not a real field */ - CAL_COMPONENT_FIELD_ICON, /* not a real field */ - CAL_COMPONENT_FIELD_COMPLETE, /* not a real field */ - CAL_COMPONENT_FIELD_RECURRING, /* not a real field */ - CAL_COMPONENT_FIELD_OVERDUE, /* not a real field */ - CAL_COMPONENT_FIELD_COLOR, /* not a real field */ - CAL_COMPONENT_FIELD_STATUS, - CAL_COMPONENT_FIELD_COMPONENT, /* not a real field */ -#if 0 - CAL_COMPONENT_FIELD_LOCATION, -#endif - CAL_COMPONENT_FIELD_NUM_FIELDS -} CalComponentField; - -/* Structures and enumerations to return properties and their parameters */ - -/* CLASSIFICATION property */ -typedef enum { - CAL_COMPONENT_CLASS_NONE, - CAL_COMPONENT_CLASS_PUBLIC, - CAL_COMPONENT_CLASS_PRIVATE, - CAL_COMPONENT_CLASS_CONFIDENTIAL, - CAL_COMPONENT_CLASS_UNKNOWN -} CalComponentClassification; - -/* Properties that have time and timezone information */ -typedef struct { - /* Actual date/time value */ - struct icaltimetype *value; - - /* Timezone ID */ - const char *tzid; -} CalComponentDateTime; - -/* Way in which a period of time is specified */ -typedef enum { - CAL_COMPONENT_PERIOD_DATETIME, - CAL_COMPONENT_PERIOD_DURATION -} CalComponentPeriodType; - -/* Period of time, can have explicit start/end times or start/duration instead */ -typedef struct { - CalComponentPeriodType type; - - struct icaltimetype start; - - union { - struct icaltimetype end; - struct icaldurationtype duration; - } u; -} CalComponentPeriod; - -/* The type of range */ -typedef enum { - CAL_COMPONENT_RANGE_SINGLE, - CAL_COMPONENT_RANGE_THISPRIOR, - CAL_COMPONENT_RANGE_THISFUTURE, -} CalComponentRangeType; - -typedef struct { - CalComponentRangeType type; - - CalComponentDateTime datetime; -} CalComponentRange; - -/* Text properties */ -typedef struct { - /* Description string */ - const char *value; - - /* Alternate representation URI */ - const char *altrep; -} CalComponentText; - -/* Time transparency */ -typedef enum { - CAL_COMPONENT_TRANSP_NONE, - CAL_COMPONENT_TRANSP_TRANSPARENT, - CAL_COMPONENT_TRANSP_OPAQUE, - CAL_COMPONENT_TRANSP_UNKNOWN -} CalComponentTransparency; - -/* Organizer & Attendee */ -typedef struct { - const char *value; - - const char *member; - icalparameter_cutype cutype; - icalparameter_role role; - icalparameter_partstat status; - gboolean rsvp; - - const char *delto; - const char *delfrom; - const char *sentby; - const char *cn; - const char *language; -} CalComponentAttendee; - -typedef struct { - const char *value; - const char *sentby; - const char *cn; - const char *language; -} CalComponentOrganizer; - -/* Main calendar component object */ - -typedef struct _CalComponent CalComponent; -typedef struct _CalComponentClass CalComponentClass; - -typedef struct _CalComponentPrivate CalComponentPrivate; - -struct _CalComponent { - GObject object; - - /* Private data */ - CalComponentPrivate *priv; -}; - -struct _CalComponentClass { - GObjectClass parent_class; -}; - -/* Calendar component */ - -GType cal_component_get_type (void); - -char *cal_component_gen_uid (void); - -CalComponent *cal_component_new (void); - -CalComponent *cal_component_clone (CalComponent *comp); - -void cal_component_set_new_vtype (CalComponent *comp, CalComponentVType type); - -gboolean cal_component_set_icalcomponent (CalComponent *comp, icalcomponent *icalcomp); -icalcomponent *cal_component_get_icalcomponent (CalComponent *comp); -void cal_component_rescan (CalComponent *comp); -void cal_component_strip_errors (CalComponent *comp); - -CalComponentVType cal_component_get_vtype (CalComponent *comp); - -char *cal_component_get_as_string (CalComponent *comp); - -void cal_component_commit_sequence (CalComponent *comp); -void cal_component_abort_sequence (CalComponent *comp); - -void cal_component_get_uid (CalComponent *comp, const char **uid); -void cal_component_set_uid (CalComponent *comp, const char *uid); - -void cal_component_get_categories (CalComponent *comp, const char **categories); -void cal_component_set_categories (CalComponent *comp, const char *categories); -void cal_component_get_categories_list (CalComponent *comp, GSList **categ_list); -void cal_component_set_categories_list (CalComponent *comp, GSList *categ_list); - -void cal_component_get_classification (CalComponent *comp, CalComponentClassification *classif); -void cal_component_set_classification (CalComponent *comp, CalComponentClassification classif); - -void cal_component_get_comment_list (CalComponent *comp, GSList **text_list); -void cal_component_set_comment_list (CalComponent *comp, GSList *text_list); - -void cal_component_get_completed (CalComponent *comp, struct icaltimetype **t); -void cal_component_set_completed (CalComponent *comp, struct icaltimetype *t); - -void cal_component_get_contact_list (CalComponent *comp, GSList **text_list); -void cal_component_set_contact_list (CalComponent *comp, GSList *text_list); - -void cal_component_get_created (CalComponent *comp, struct icaltimetype **t); -void cal_component_set_created (CalComponent *comp, struct icaltimetype *t); - -void cal_component_get_description_list (CalComponent *comp, GSList **text_list); -void cal_component_set_description_list (CalComponent *comp, GSList *text_list); - -void cal_component_get_dtend (CalComponent *comp, CalComponentDateTime *dt); -void cal_component_set_dtend (CalComponent *comp, CalComponentDateTime *dt); - -void cal_component_get_dtstamp (CalComponent *comp, struct icaltimetype *t); -void cal_component_set_dtstamp (CalComponent *comp, struct icaltimetype *t); - -void cal_component_get_dtstart (CalComponent *comp, CalComponentDateTime *dt); -void cal_component_set_dtstart (CalComponent *comp, CalComponentDateTime *dt); - -void cal_component_get_due (CalComponent *comp, CalComponentDateTime *dt); -void cal_component_set_due (CalComponent *comp, CalComponentDateTime *dt); - -void cal_component_get_exdate_list (CalComponent *comp, GSList **exdate_list); -void cal_component_set_exdate_list (CalComponent *comp, GSList *exdate_list); -gboolean cal_component_has_exdates (CalComponent *comp); - -void cal_component_get_exrule_list (CalComponent *comp, GSList **recur_list); -void cal_component_get_exrule_property_list (CalComponent *comp, GSList **recur_list); -void cal_component_set_exrule_list (CalComponent *comp, GSList *recur_list); -gboolean cal_component_has_exrules (CalComponent *comp); - -gboolean cal_component_has_exceptions (CalComponent *comp); - -void cal_component_get_geo (CalComponent *comp, struct icalgeotype **geo); -void cal_component_set_geo (CalComponent *comp, struct icalgeotype *geo); - -void cal_component_get_last_modified (CalComponent *comp, struct icaltimetype **t); -void cal_component_set_last_modified (CalComponent *comp, struct icaltimetype *t); - -void cal_component_get_organizer (CalComponent *comp, CalComponentOrganizer *organizer); -void cal_component_set_organizer (CalComponent *comp, CalComponentOrganizer *organizer); -gboolean cal_component_has_organizer (CalComponent *comp); - -void cal_component_get_percent (CalComponent *comp, int **percent); -void cal_component_set_percent (CalComponent *comp, int *percent); - -void cal_component_get_priority (CalComponent *comp, int **priority); -void cal_component_set_priority (CalComponent *comp, int *priority); - -void cal_component_get_recurid (CalComponent *comp, CalComponentRange *recur_id); -void cal_component_set_recurid (CalComponent *comp, CalComponentRange *recur_id); - -void cal_component_get_rdate_list (CalComponent *comp, GSList **period_list); -void cal_component_set_rdate_list (CalComponent *comp, GSList *period_list); -gboolean cal_component_has_rdates (CalComponent *comp); - -void cal_component_get_rrule_list (CalComponent *comp, GSList **recur_list); -void cal_component_get_rrule_property_list (CalComponent *comp, GSList **recur_list); -void cal_component_set_rrule_list (CalComponent *comp, GSList *recur_list); -gboolean cal_component_has_rrules (CalComponent *comp); - -gboolean cal_component_has_recurrences (CalComponent *comp); -gboolean cal_component_has_simple_recurrence (CalComponent *comp); -gboolean cal_component_is_instance (CalComponent *comp); - -void cal_component_get_sequence (CalComponent *comp, int **sequence); -void cal_component_set_sequence (CalComponent *comp, int *sequence); - -void cal_component_get_status (CalComponent *comp, icalproperty_status *status); -void cal_component_set_status (CalComponent *comp, icalproperty_status status); - -void cal_component_get_summary (CalComponent *comp, CalComponentText *summary); -void cal_component_set_summary (CalComponent *comp, CalComponentText *summary); - -void cal_component_get_transparency (CalComponent *comp, CalComponentTransparency *transp); -void cal_component_set_transparency (CalComponent *comp, CalComponentTransparency transp); - -void cal_component_get_url (CalComponent *comp, const char **url); -void cal_component_set_url (CalComponent *comp, const char *url); - -void cal_component_get_attendee_list (CalComponent *comp, GSList **attendee_list); -void cal_component_set_attendee_list (CalComponent *comp, GSList *attendee_list); -gboolean cal_component_has_attendees (CalComponent *comp); - -void cal_component_get_location (CalComponent *comp, const char **location); -void cal_component_set_location (CalComponent *comp, const char *location); - -gboolean cal_component_event_dates_match (CalComponent *comp1, CalComponent *comp2); - - -/* Functions to free returned values */ - -void cal_component_free_categories_list (GSList *categ_list); -void cal_component_free_datetime (CalComponentDateTime *dt); -void cal_component_free_range (CalComponentRange *range); -void cal_component_free_exdate_list (GSList *exdate_list); -void cal_component_free_geo (struct icalgeotype *geo); -void cal_component_free_icaltimetype (struct icaltimetype *t); -void cal_component_free_percent (int *percent); -void cal_component_free_priority (int *priority); -void cal_component_free_period_list (GSList *period_list); -void cal_component_free_recur_list (GSList *recur_list); -void cal_component_free_sequence (int *sequence); -void cal_component_free_text_list (GSList *text_list); -void cal_component_free_attendee_list (GSList *attendee_list); - -/* Alarms */ - -/* Opaque structure used to represent alarm subcomponents */ -typedef struct _CalComponentAlarm CalComponentAlarm; - -/* An alarm occurrence, i.e. a trigger instance */ -typedef struct { - /* UID of the alarm that triggered */ - const char *auid; - - /* Trigger time, i.e. "5 minutes before the appointment" */ - time_t trigger; - - /* Actual event occurrence to which this trigger corresponds */ - time_t occur_start; - time_t occur_end; -} CalAlarmInstance; - -/* Alarm trigger instances for a particular component */ -typedef struct { - /* The actual component */ - CalComponent *comp; - - /* List of CalAlarmInstance structures */ - GSList *alarms; -} CalComponentAlarms; - -/* Alarm types */ -typedef enum { - CAL_ALARM_NONE, - CAL_ALARM_AUDIO, - CAL_ALARM_DISPLAY, - CAL_ALARM_EMAIL, - CAL_ALARM_PROCEDURE, - CAL_ALARM_UNKNOWN -} CalAlarmAction; - -/* Whether a trigger is relative to the start or end of an event occurrence, or - * whether it is specified to occur at an absolute time. - */ -typedef enum { - CAL_ALARM_TRIGGER_NONE, - CAL_ALARM_TRIGGER_RELATIVE_START, - CAL_ALARM_TRIGGER_RELATIVE_END, - CAL_ALARM_TRIGGER_ABSOLUTE -} CalAlarmTriggerType; - -typedef struct { - CalAlarmTriggerType type; - - union { - struct icaldurationtype rel_duration; - struct icaltimetype abs_time; - } u; -} CalAlarmTrigger; - -typedef struct { - /* Number of extra repetitions, zero for none */ - int repetitions; - - /* Interval between repetitions */ - struct icaldurationtype duration; -} CalAlarmRepeat; - -gboolean cal_component_has_alarms (CalComponent *comp); -void cal_component_add_alarm (CalComponent *comp, CalComponentAlarm *alarm); -void cal_component_remove_alarm (CalComponent *comp, const char *auid); -void cal_component_remove_all_alarms (CalComponent *comp); - -GList *cal_component_get_alarm_uids (CalComponent *comp); -CalComponentAlarm *cal_component_get_alarm (CalComponent *comp, const char *auid); - -void cal_component_alarms_free (CalComponentAlarms *alarms); - -/* CalComponentAlarms */ -CalComponentAlarm *cal_component_alarm_new (void); -CalComponentAlarm *cal_component_alarm_clone (CalComponentAlarm *alarm); -void cal_component_alarm_free (CalComponentAlarm *alarm); - -const char *cal_component_alarm_get_uid (CalComponentAlarm *alarm); - -void cal_component_alarm_get_action (CalComponentAlarm *alarm, CalAlarmAction *action); -void cal_component_alarm_set_action (CalComponentAlarm *alarm, CalAlarmAction action); - -void cal_component_alarm_get_attach (CalComponentAlarm *alarm, icalattach **attach); -void cal_component_alarm_set_attach (CalComponentAlarm *alarm, icalattach *attach); - -void cal_component_alarm_get_description (CalComponentAlarm *alarm, CalComponentText *description); -void cal_component_alarm_set_description (CalComponentAlarm *alarm, CalComponentText *description); - -void cal_component_alarm_get_repeat (CalComponentAlarm *alarm, CalAlarmRepeat *repeat); -void cal_component_alarm_set_repeat (CalComponentAlarm *alarm, CalAlarmRepeat repeat); - -void cal_component_alarm_get_trigger (CalComponentAlarm *alarm, CalAlarmTrigger *trigger); -void cal_component_alarm_set_trigger (CalComponentAlarm *alarm, CalAlarmTrigger trigger); - -void cal_component_alarm_get_attendee_list (CalComponentAlarm *alarm, GSList **attendee_list); -void cal_component_alarm_set_attendee_list (CalComponentAlarm *alarm, GSList *attendee_list); -gboolean cal_component_alarm_has_attendees (CalComponentAlarm *alarm); - -icalcomponent *cal_component_alarm_get_icalcomponent (CalComponentAlarm *alarm); - - - -G_END_DECLS - -#endif diff --git a/calendar/cal-util/cal-recur.c b/calendar/cal-util/cal-recur.c deleted file mode 100644 index 6decd3eae2..0000000000 --- a/calendar/cal-util/cal-recur.c +++ /dev/null @@ -1,4021 +0,0 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */ -/* - * Evolution calendar recurrence rule functions - * - * Copyright (C) 2000 Ximian, Inc. - * - * Author: Damon Chaplin <damon@ximian.com> - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of version 2 of the GNU General Public - * License as published by the Free Software Foundation. - * - * 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA. - */ - -#ifdef HAVE_CONFIG_H -#include <config.h> -#endif - -#include <stdlib.h> -#include <string.h> -#include <glib.h> -#include <libgnome/gnome-i18n.h> -#include <cal-util/cal-recur.h> -#include <cal-util/timeutil.h> - - -/* - * Introduction to The Recurrence Generation Functions: - * - * Note: This is pretty complicated. See the iCalendar spec (RFC 2445) for - * the specification of the recurrence rules and lots of examples - * (sections 4.3.10 & 4.8.5). We also want to support the older - * vCalendar spec, though this should be easy since it is basically a - * subset of iCalendar. - * - * o An iCalendar event can have any number of recurrence rules specifying - * occurrences of the event, as well as dates & times of specific - * occurrences. It can also have any number of recurrence rules and - * specific dates & times specifying exceptions to the occurrences. - * So we first merge all the occurrences generated, eliminating any - * duplicates, then we generate all the exceptions and remove these to - * form the final set of occurrences. - * - * o There are 7 frequencies of occurrences: YEARLY, MONTHLY, WEEKLY, DAILY, - * HOURLY, MINUTELY & SECONDLY. The 'interval' property specifies the - * multiples of the frequency which we step by. We generate a 'set' of - * occurrences for each period defined by the frequency & interval. - * So for a YEARLY frequency with an interval of 3, we generate a set of - * occurrences for every 3rd year. We use complete years here - any - * generated occurrences that occur before the event's start (or after its - * end) are just discarded. - * - * o There are 8 frequency modifiers: BYMONTH, BYWEEKNO, BYYEARDAY, BYMONTHDAY, - * BYDAY, BYHOUR, BYMINUTE & BYSECOND. These can either add extra occurrences - * or filter out occurrences. For example 'FREQ=YEARLY;BYMONTH=1,2' produces - * 2 occurrences for each year rather than the default 1. And - * 'FREQ=DAILY;BYMONTH=1' filters out all occurrences except those in Jan. - * If the modifier works on periods which are less than the recurrence - * frequency, then extra occurrences are added, otherwise occurrences are - * filtered. So we have 2 functions for each modifier - one to expand events - * and the other to filter. We use a table of functions for each frequency - * which points to the appropriate function to use for each modifier. - * - * o Any number of frequency modifiers can be used in a recurrence rule. - * (Though the iCalendar spec says that BYWEEKNO can only be used in a YEARLY - * rule, and some modifiers aren't appropriate for some frequencies - e.g. - * BYMONTHDAY is not really useful in a WEEKLY frequency, and BYYEARDAY is - * not useful in a MONTHLY or WEEKLY frequency). - * The frequency modifiers are applied in the order given above. The first 5 - * modifier rules (BYMONTH, BYWEEKNO, BYYEARDAY, BYMONTHDAY & BYDAY) all - * produce the days on which the occurrences take place, and so we have to - * compute some of these in parallel rather than sequentially, or we may end - * up with too many days. - * - * o Note that some expansion functions may produce days which are invalid, - * e.g. 31st September, 30th Feb. These invalid days are removed before the - * BYHOUR, BYMINUTE & BYSECOND modifier functions are applied. - * - * o After the set of occurrences for the frequency interval are generated, - * the BYSETPOS property is used to select which of the occurrences are - * finally output. If BYSETPOS is not specified then all the occurrences are - * output. - * - * - * FIXME: I think there are a few errors in this code: - * - * 1) I'm not sure it should be generating events in parallel like it says - * above. That needs to be checked. - * - * 2) I didn't think about timezone changes when implementing this. I just - * assumed all the occurrences of the event would be in local time. - * But when clocks go back or forwards due to daylight-saving time, some - * special handling may be needed, especially for the shorter frequencies. - * e.g. for a MINUTELY frequency it should probably iterate over all the - * minutes before and after clocks go back (i.e. some may be the same local - * time but have different UTC offsets). For longer frequencies, if an - * occurrence lands on the overlapping or non-existant time when clocks - * go back/forward, then it may need to choose which of the times to use - * or move the time forward or something. I'm not sure this is clear in the - * spec. - */ - -/* This is the maximum year we will go up to (inclusive). Since we use time_t - values we can't go past 2037 anyway, and some of our VTIMEZONEs may stop - at 2037 as well. */ -#define MAX_YEAR 2037 - -/* Define this for some debugging output. */ -#if 0 -#define CAL_OBJ_DEBUG 1 -#endif - -/* We will use icalrecurrencetype instead of this eventually. */ -typedef struct { - icalrecurrencetype_frequency freq; - - int interval; - - /* Specifies the end of the recurrence, inclusive. No occurrences are - generated after this date. If it is 0, the event recurs forever. */ - time_t enddate; - - /* WKST property - the week start day: 0 = Monday to 6 = Sunday. */ - gint week_start_day; - - - /* NOTE: I've used GList's here, but it doesn't matter if we use - other data structures like arrays. The code should be easy to - change. So long as it is easy to see if the modifier is set. */ - - /* For BYMONTH modifier. A list of GINT_TO_POINTERs, 0-11. */ - GList *bymonth; - - /* For BYWEEKNO modifier. A list of GINT_TO_POINTERs, [+-]1-53. */ - GList *byweekno; - - /* For BYYEARDAY modifier. A list of GINT_TO_POINTERs, [+-]1-366. */ - GList *byyearday; - - /* For BYMONTHDAY modifier. A list of GINT_TO_POINTERs, [+-]1-31. */ - GList *bymonthday; - - /* For BYDAY modifier. A list of GINT_TO_POINTERs, in pairs. - The first of each pair is the weekday, 0 = Monday to 6 = Sunday. - The second of each pair is the week number [+-]0-53. */ - GList *byday; - - /* For BYHOUR modifier. A list of GINT_TO_POINTERs, 0-23. */ - GList *byhour; - - /* For BYMINUTE modifier. A list of GINT_TO_POINTERs, 0-59. */ - GList *byminute; - - /* For BYSECOND modifier. A list of GINT_TO_POINTERs, 0-60. */ - GList *bysecond; - - /* For BYSETPOS modifier. A list of GINT_TO_POINTERs, +ve or -ve. */ - GList *bysetpos; -} CalRecurrence; - -/* This is what we use to pass to all the filter functions. */ -typedef struct _RecurData RecurData; -struct _RecurData { - CalRecurrence *recur; - - /* This is used for the WEEKLY frequency. It is the offset from the - week_start_day. */ - gint weekday_offset; - - /* This is used for fast lookup in BYMONTH filtering. */ - guint8 months[12]; - - /* This is used for fast lookup in BYYEARDAY filtering. */ - guint8 yeardays[367], neg_yeardays[367]; /* Days are 1 - 366. */ - - /* This is used for fast lookup in BYMONTHDAY filtering. */ - guint8 monthdays[32], neg_monthdays[32]; /* Days are 1 to 31. */ - - /* This is used for fast lookup in BYDAY filtering. */ - guint8 weekdays[7]; - - /* This is used for fast lookup in BYHOUR filtering. */ - guint8 hours[24]; - - /* This is used for fast lookup in BYMINUTE filtering. */ - guint8 minutes[60]; - - /* This is used for fast lookup in BYSECOND filtering. */ - guint8 seconds[62]; -}; - -/* This is what we use to represent a date & time. */ -typedef struct _CalObjTime CalObjTime; -struct _CalObjTime { - guint16 year; - guint8 month; /* 0 - 11 */ - guint8 day; /* 1 - 31 */ - guint8 hour; /* 0 - 23 */ - guint8 minute; /* 0 - 59 */ - guint8 second; /* 0 - 59 (maybe up to 61 for leap seconds) */ - guint8 flags; /* The meaning of this depends on where the - CalObjTime is used. In most cases this is - set to TRUE to indicate that this is an - RDATE with an end or a duration set. - In the exceptions code, this is set to TRUE - to indicate that this is an EXDATE with a - DATE value. */ -}; - -/* This is what we use to represent specific recurrence dates. - Note that we assume it starts with a CalObjTime when sorting. */ -typedef struct _CalObjRecurrenceDate CalObjRecurrenceDate; -struct _CalObjRecurrenceDate { - CalObjTime start; - CalComponentPeriod *period; -}; - -/* The paramter we use to store the enddate in RRULE and EXRULE properties. */ -#define EVOLUTION_END_DATE_PARAMETER "X-EVOLUTION-ENDDATE" - -typedef gboolean (*CalObjFindStartFn) (CalObjTime *event_start, - CalObjTime *event_end, - RecurData *recur_data, - CalObjTime *interval_start, - CalObjTime *interval_end, - CalObjTime *cotime); -typedef gboolean (*CalObjFindNextFn) (CalObjTime *cotime, - CalObjTime *event_end, - RecurData *recur_data, - CalObjTime *interval_end); -typedef GArray* (*CalObjFilterFn) (RecurData *recur_data, - GArray *occs); - -typedef struct _CalRecurVTable CalRecurVTable; -struct _CalRecurVTable { - CalObjFindStartFn find_start_position; - CalObjFindNextFn find_next_position; - - CalObjFilterFn bymonth_filter; - CalObjFilterFn byweekno_filter; - CalObjFilterFn byyearday_filter; - CalObjFilterFn bymonthday_filter; - CalObjFilterFn byday_filter; - CalObjFilterFn byhour_filter; - CalObjFilterFn byminute_filter; - CalObjFilterFn bysecond_filter; -}; - - -/* This is used to specify which parts of the CalObjTime to compare in - cal_obj_time_compare(). */ -typedef enum { - CALOBJ_YEAR, - CALOBJ_MONTH, - CALOBJ_DAY, - CALOBJ_HOUR, - CALOBJ_MINUTE, - CALOBJ_SECOND -} CalObjTimeComparison; - -static void cal_recur_generate_instances_of_rule (CalComponent *comp, - icalproperty *prop, - time_t start, - time_t end, - CalRecurInstanceFn cb, - gpointer cb_data, - CalRecurResolveTimezoneFn tz_cb, - gpointer tz_cb_data, - icaltimezone *default_timezone); - -static CalRecurrence * cal_recur_from_icalproperty (icalproperty *prop, - gboolean exception, - icaltimezone *zone, - gboolean convert_end_date); -static gint cal_recur_ical_weekday_to_weekday (enum icalrecurrencetype_weekday day); -static void cal_recur_free (CalRecurrence *r); - - -static gboolean cal_object_get_rdate_end (CalObjTime *occ, - GArray *rdate_periods); -static void cal_object_compute_duration (CalObjTime *start, - CalObjTime *end, - gint *days, - gint *seconds); - -static gboolean generate_instances_for_chunk (CalComponent *comp, - time_t comp_dtstart, - icaltimezone *zone, - GSList *rrules, - GSList *rdates, - GSList *exrules, - GSList *exdates, - gboolean single_rule, - CalObjTime *event_start, - time_t interval_start, - CalObjTime *chunk_start, - CalObjTime *chunk_end, - gint duration_days, - gint duration_seconds, - gboolean convert_end_date, - CalRecurInstanceFn cb, - gpointer cb_data); - -static GArray* cal_obj_expand_recurrence (CalObjTime *event_start, - icaltimezone *zone, - CalRecurrence *recur, - CalObjTime *interval_start, - CalObjTime *interval_end, - gboolean *finished); - -static GArray* cal_obj_generate_set_yearly (RecurData *recur_data, - CalRecurVTable *vtable, - CalObjTime *occ); -static GArray* cal_obj_generate_set_monthly (RecurData *recur_data, - CalRecurVTable *vtable, - CalObjTime *occ); -static GArray* cal_obj_generate_set_default (RecurData *recur_data, - CalRecurVTable *vtable, - CalObjTime *occ); - - -static CalRecurVTable* cal_obj_get_vtable (icalrecurrencetype_frequency recur_type); -static void cal_obj_initialize_recur_data (RecurData *recur_data, - CalRecurrence *recur, - CalObjTime *event_start); -static void cal_obj_sort_occurrences (GArray *occs); -static gint cal_obj_time_compare_func (const void *arg1, - const void *arg2); -static void cal_obj_remove_duplicates_and_invalid_dates (GArray *occs); -static void cal_obj_remove_exceptions (GArray *occs, - GArray *ex_occs); -static GArray* cal_obj_bysetpos_filter (CalRecurrence *recur, - GArray *occs); - - -static gboolean cal_obj_yearly_find_start_position (CalObjTime *event_start, - CalObjTime *event_end, - RecurData *recur_data, - CalObjTime *interval_start, - CalObjTime *interval_end, - CalObjTime *cotime); -static gboolean cal_obj_yearly_find_next_position (CalObjTime *cotime, - CalObjTime *event_end, - RecurData *recur_data, - CalObjTime *interval_end); - -static gboolean cal_obj_monthly_find_start_position (CalObjTime *event_start, - CalObjTime *event_end, - RecurData *recur_data, - CalObjTime *interval_start, - CalObjTime *interval_end, - CalObjTime *cotime); -static gboolean cal_obj_monthly_find_next_position (CalObjTime *cotime, - CalObjTime *event_end, - RecurData *recur_data, - CalObjTime *interval_end); - -static gboolean cal_obj_weekly_find_start_position (CalObjTime *event_start, - CalObjTime *event_end, - RecurData *recur_data, - CalObjTime *interval_start, - CalObjTime *interval_end, - CalObjTime *cotime); -static gboolean cal_obj_weekly_find_next_position (CalObjTime *cotime, - CalObjTime *event_end, - RecurData *recur_data, - CalObjTime *interval_end); - -static gboolean cal_obj_daily_find_start_position (CalObjTime *event_start, - CalObjTime *event_end, - RecurData *recur_data, - CalObjTime *interval_start, - CalObjTime *interval_end, - CalObjTime *cotime); -static gboolean cal_obj_daily_find_next_position (CalObjTime *cotime, - CalObjTime *event_end, - RecurData *recur_data, - CalObjTime *interval_end); - -static gboolean cal_obj_hourly_find_start_position (CalObjTime *event_start, - CalObjTime *event_end, - RecurData *recur_data, - CalObjTime *interval_start, - CalObjTime *interval_end, - CalObjTime *cotime); -static gboolean cal_obj_hourly_find_next_position (CalObjTime *cotime, - CalObjTime *event_end, - RecurData *recur_data, - CalObjTime *interval_end); - -static gboolean cal_obj_minutely_find_start_position (CalObjTime *event_start, - CalObjTime *event_end, - RecurData *recur_data, - CalObjTime *interval_start, - CalObjTime *interval_end, - CalObjTime *cotime); -static gboolean cal_obj_minutely_find_next_position (CalObjTime *cotime, - CalObjTime *event_end, - RecurData *recur_data, - CalObjTime *interval_end); - -static gboolean cal_obj_secondly_find_start_position (CalObjTime *event_start, - CalObjTime *event_end, - RecurData *recur_data, - CalObjTime *interval_start, - CalObjTime *interval_end, - CalObjTime *cotime); -static gboolean cal_obj_secondly_find_next_position (CalObjTime *cotime, - CalObjTime *event_end, - RecurData *recur_data, - CalObjTime *interval_end); - -static GArray* cal_obj_bymonth_expand (RecurData *recur_data, - GArray *occs); -static GArray* cal_obj_bymonth_filter (RecurData *recur_data, - GArray *occs); -static GArray* cal_obj_byweekno_expand (RecurData *recur_data, - GArray *occs); -#if 0 -/* This isn't used at present. */ -static GArray* cal_obj_byweekno_filter (RecurData *recur_data, - GArray *occs); -#endif -static GArray* cal_obj_byyearday_expand (RecurData *recur_data, - GArray *occs); -static GArray* cal_obj_byyearday_filter (RecurData *recur_data, - GArray *occs); -static GArray* cal_obj_bymonthday_expand (RecurData *recur_data, - GArray *occs); -static GArray* cal_obj_bymonthday_filter (RecurData *recur_data, - GArray *occs); -static GArray* cal_obj_byday_expand_yearly (RecurData *recur_data, - GArray *occs); -static GArray* cal_obj_byday_expand_monthly (RecurData *recur_data, - GArray *occs); -static GArray* cal_obj_byday_expand_weekly (RecurData *recur_data, - GArray *occs); -static GArray* cal_obj_byday_filter (RecurData *recur_data, - GArray *occs); -static GArray* cal_obj_byhour_expand (RecurData *recur_data, - GArray *occs); -static GArray* cal_obj_byhour_filter (RecurData *recur_data, - GArray *occs); -static GArray* cal_obj_byminute_expand (RecurData *recur_data, - GArray *occs); -static GArray* cal_obj_byminute_filter (RecurData *recur_data, - GArray *occs); -static GArray* cal_obj_bysecond_expand (RecurData *recur_data, - GArray *occs); -static GArray* cal_obj_bysecond_filter (RecurData *recur_data, - GArray *occs); - -static void cal_obj_time_add_months (CalObjTime *cotime, - gint months); -static void cal_obj_time_add_days (CalObjTime *cotime, - gint days); -static void cal_obj_time_add_hours (CalObjTime *cotime, - gint hours); -static void cal_obj_time_add_minutes (CalObjTime *cotime, - gint minutes); -static void cal_obj_time_add_seconds (CalObjTime *cotime, - gint seconds); -static gint cal_obj_time_compare (CalObjTime *cotime1, - CalObjTime *cotime2, - CalObjTimeComparison type); -static gint cal_obj_time_weekday (CalObjTime *cotime); -static gint cal_obj_time_weekday_offset (CalObjTime *cotime, - CalRecurrence *recur); -static gint cal_obj_time_day_of_year (CalObjTime *cotime); -static void cal_obj_time_find_first_week (CalObjTime *cotime, - RecurData *recur_data); -static void cal_object_time_from_time (CalObjTime *cotime, - time_t t, - icaltimezone *zone); -static gint cal_obj_date_only_compare_func (const void *arg1, - const void *arg2); - - - -static gboolean cal_recur_ensure_end_dates (CalComponent *comp, - gboolean refresh, - CalRecurResolveTimezoneFn tz_cb, - gpointer tz_cb_data); -static gboolean cal_recur_ensure_rule_end_date (CalComponent *comp, - icalproperty *prop, - gboolean exception, - gboolean refresh, - CalRecurResolveTimezoneFn tz_cb, - gpointer tz_cb_data); -static gboolean cal_recur_ensure_rule_end_date_cb (CalComponent *comp, - time_t instance_start, - time_t instance_end, - gpointer data); -static time_t cal_recur_get_rule_end_date (icalproperty *prop, - icaltimezone *default_timezone); -static void cal_recur_set_rule_end_date (icalproperty *prop, - time_t end_date); - - -#ifdef CAL_OBJ_DEBUG -static char* cal_obj_time_to_string (CalObjTime *cotime); -#endif - - -CalRecurVTable cal_obj_yearly_vtable = { - cal_obj_yearly_find_start_position, - cal_obj_yearly_find_next_position, - - cal_obj_bymonth_expand, - cal_obj_byweekno_expand, - cal_obj_byyearday_expand, - cal_obj_bymonthday_expand, - cal_obj_byday_expand_yearly, - cal_obj_byhour_expand, - cal_obj_byminute_expand, - cal_obj_bysecond_expand -}; - -CalRecurVTable cal_obj_monthly_vtable = { - cal_obj_monthly_find_start_position, - cal_obj_monthly_find_next_position, - - cal_obj_bymonth_filter, - NULL, /* BYWEEKNO is only applicable to YEARLY frequency. */ - NULL, /* BYYEARDAY is not useful in a MONTHLY frequency. */ - cal_obj_bymonthday_expand, - cal_obj_byday_expand_monthly, - cal_obj_byhour_expand, - cal_obj_byminute_expand, - cal_obj_bysecond_expand -}; - -CalRecurVTable cal_obj_weekly_vtable = { - cal_obj_weekly_find_start_position, - cal_obj_weekly_find_next_position, - - cal_obj_bymonth_filter, - NULL, /* BYWEEKNO is only applicable to YEARLY frequency. */ - NULL, /* BYYEARDAY is not useful in a WEEKLY frequency. */ - NULL, /* BYMONTHDAY is not useful in a WEEKLY frequency. */ - cal_obj_byday_expand_weekly, - cal_obj_byhour_expand, - cal_obj_byminute_expand, - cal_obj_bysecond_expand -}; - -CalRecurVTable cal_obj_daily_vtable = { - cal_obj_daily_find_start_position, - cal_obj_daily_find_next_position, - - cal_obj_bymonth_filter, - NULL, /* BYWEEKNO is only applicable to YEARLY frequency. */ - cal_obj_byyearday_filter, - cal_obj_bymonthday_filter, - cal_obj_byday_filter, - cal_obj_byhour_expand, - cal_obj_byminute_expand, - cal_obj_bysecond_expand -}; - -CalRecurVTable cal_obj_hourly_vtable = { - cal_obj_hourly_find_start_position, - cal_obj_hourly_find_next_position, - - cal_obj_bymonth_filter, - NULL, /* BYWEEKNO is only applicable to YEARLY frequency. */ - cal_obj_byyearday_filter, - cal_obj_bymonthday_filter, - cal_obj_byday_filter, - cal_obj_byhour_filter, - cal_obj_byminute_expand, - cal_obj_bysecond_expand -}; - -CalRecurVTable cal_obj_minutely_vtable = { - cal_obj_minutely_find_start_position, - cal_obj_minutely_find_next_position, - - cal_obj_bymonth_filter, - NULL, /* BYWEEKNO is only applicable to YEARLY frequency. */ - cal_obj_byyearday_filter, - cal_obj_bymonthday_filter, - cal_obj_byday_filter, - cal_obj_byhour_filter, - cal_obj_byminute_filter, - cal_obj_bysecond_expand -}; - -CalRecurVTable cal_obj_secondly_vtable = { - cal_obj_secondly_find_start_position, - cal_obj_secondly_find_next_position, - - cal_obj_bymonth_filter, - NULL, /* BYWEEKNO is only applicable to YEARLY frequency. */ - cal_obj_byyearday_filter, - cal_obj_bymonthday_filter, - cal_obj_byday_filter, - cal_obj_byhour_filter, - cal_obj_byminute_filter, - cal_obj_bysecond_filter -}; - -/* - * Calls the given callback function for each occurrence of the event that - * intersects the range between the given start and end times (the end time is - * not included). Note that the occurrences may start before the given start - * time. - * - * If the callback routine returns FALSE the occurrence generation stops. - * - * Both start and end can be -1, in which case we start at the events first - * instance and continue until it ends, or forever if it has no enddate. - */ -void -cal_recur_generate_instances (CalComponent *comp, - time_t start, - time_t end, - CalRecurInstanceFn cb, - gpointer cb_data, - CalRecurResolveTimezoneFn tz_cb, - gpointer tz_cb_data, - icaltimezone *default_timezone) -{ -#if 0 - g_print ("In cal_recur_generate_instances comp: %p\n", comp); - g_print (" start: %li - %s", start, ctime (&start)); - g_print (" end : %li - %s", end, ctime (&end)); -#endif - cal_recur_generate_instances_of_rule (comp, NULL, start, end, - cb, cb_data, tz_cb, tz_cb_data, - default_timezone); -} - - -/* - * Calls the given callback function for each occurrence of the given - * recurrence rule between the given start and end times. If the rule is NULL - * it uses all the rules from the component. - * - * If the callback routine returns FALSE the occurrence generation stops. - * - * The use of the specific rule is for determining the end of a rule when - * COUNT is set. The callback will count instances and store the enddate - * when COUNT is reached. - * - * Both start and end can be -1, in which case we start at the events first - * instance and continue until it ends, or forever if it has no enddate. - */ -static void -cal_recur_generate_instances_of_rule (CalComponent *comp, - icalproperty *prop, - time_t start, - time_t end, - CalRecurInstanceFn cb, - gpointer cb_data, - CalRecurResolveTimezoneFn tz_cb, - gpointer tz_cb_data, - icaltimezone *default_timezone) -{ - CalComponentDateTime dtstart, dtend; - time_t dtstart_time, dtend_time; - GSList *rrules = NULL, *rdates = NULL, elem; - GSList *exrules = NULL, *exdates = NULL; - CalObjTime interval_start, interval_end, event_start, event_end; - CalObjTime chunk_start, chunk_end; - gint days, seconds, year; - gboolean single_rule, convert_end_date = FALSE; - icaltimezone *start_zone = NULL, *end_zone = NULL; - - g_return_if_fail (comp != NULL); - g_return_if_fail (cb != NULL); - g_return_if_fail (tz_cb != NULL); - g_return_if_fail (start >= -1); - g_return_if_fail (end >= -1); - - /* Get dtstart, dtend, recurrences, and exceptions. Note that - cal_component_get_dtend() will convert a DURATION property to a - DTEND so we don't need to worry about that. */ - - cal_component_get_dtstart (comp, &dtstart); - cal_component_get_dtend (comp, &dtend); - - if (!dtstart.value) { - g_message ("cal_recur_generate_instances_of_rule(): bogus " - "component, does not have DTSTART. Skipping..."); - goto out; - } - - /* For DATE-TIME values with a TZID, we use the supplied callback to - resolve the TZID. For DATE values and DATE-TIME values without a - TZID (i.e. floating times) we use the default timezone. */ - if (dtstart.tzid && !dtstart.value->is_date) { - start_zone = (*tz_cb) (dtstart.tzid, tz_cb_data); - } else { - start_zone = default_timezone; - - /* Flag that we need to convert the saved ENDDATE property - to the default timezone. */ - convert_end_date = TRUE; - } - - dtstart_time = icaltime_as_timet_with_zone (*dtstart.value, - start_zone); - if (start == -1) - start = dtstart_time; - - if (dtend.value) { - /* If both DTSTART and DTEND are DATE values, and they are the - same day, we add 1 day to DTEND. This means that most - events created with the old Evolution behavior will still - work OK. I'm not sure what Outlook does in this case. */ - if (dtstart.value->is_date && dtend.value->is_date) { - if (icaltime_compare_date_only (*dtstart.value, - *dtend.value) == 0) { - icaltime_adjust (dtend.value, 1, 0, 0, 0); - } - } - } else { - /* If there is no DTEND, then if DTSTART is a DATE-TIME value - we use the same time (so we have a single point in time). - If DTSTART is a DATE value we add 1 day. */ - dtend.value = g_new (struct icaltimetype, 1); - *dtend.value = *dtstart.value; - - if (dtstart.value->is_date) { - icaltime_adjust (dtend.value, 1, 0, 0, 0); - } - } - - if (dtend.tzid && !dtend.value->is_date) { - end_zone = (*tz_cb) (dtend.tzid, tz_cb_data); - } else { - end_zone = default_timezone; - } - - /* We don't do this any more, since Outlook assumes that the DTEND - date is not included. */ -#if 0 - /* If DTEND is a DATE value, we add 1 day to it so that it includes - the entire day. */ - if (dtend.value->is_date) { - dtend.value->hour = 0; - dtend.value->minute = 0; - dtend.value->second = 0; - icaltime_adjust (dtend.value, 1, 0, 0, 0); - } -#endif - dtend_time = icaltime_as_timet_with_zone (*dtend.value, end_zone); - - /* If there is no recurrence, just call the callback if the event - intersects the given interval. */ - if (!(cal_component_has_recurrences (comp) - || cal_component_has_exceptions (comp))) { - if ((end == -1 || dtstart_time < end) && dtend_time > start) { - (* cb) (comp, dtstart_time, dtend_time, cb_data); - } - - goto out; - } - - /* If a specific recurrence rule is being used, set up a simple list, - else get the recurrence rules from the component. */ - if (prop) { - single_rule = TRUE; - - elem.data = prop; - elem.next = NULL; - rrules = &elem; - } else if (cal_component_is_instance (comp)) { - single_rule = FALSE; - } else { - single_rule = FALSE; - - /* Make sure all the enddates for the rules are set. */ - cal_recur_ensure_end_dates (comp, FALSE, tz_cb, tz_cb_data); - - cal_component_get_rrule_property_list (comp, &rrules); - cal_component_get_rdate_list (comp, &rdates); - cal_component_get_exrule_property_list (comp, &exrules); - cal_component_get_exdate_list (comp, &exdates); - } - - /* Convert the interval start & end to CalObjTime. Note that if end - is -1 interval_end won't be set, so don't use it! - Also note that we use end - 1 since we want the interval to be - inclusive as it makes the code simpler. We do all calculation - in the timezone of the DTSTART. */ - cal_object_time_from_time (&interval_start, start, start_zone); - if (end != -1) - cal_object_time_from_time (&interval_end, end - 1, start_zone); - - cal_object_time_from_time (&event_start, dtstart_time, start_zone); - cal_object_time_from_time (&event_end, dtend_time, start_zone); - - /* Calculate the duration of the event, which we use for all - occurrences. We can't just subtract start from end since that may - be affected by daylight-saving time. So we want a value of days - + seconds. */ - cal_object_compute_duration (&event_start, &event_end, - &days, &seconds); - - /* Take off the duration from interval_start, so we get occurrences - that start just before the start time but overlap it. But only do - that if the interval is after the event's start time. */ - if (start > dtstart_time) { - cal_obj_time_add_days (&interval_start, -days); - cal_obj_time_add_seconds (&interval_start, -seconds); - } - - /* Expand the recurrence for each year between start & end, or until - the callback returns 0 if end is 0. We do a year at a time to - give the callback function a chance to break out of the loop, and - so we don't get into problems with infinite recurrences. Since we - have to work on complete sets of occurrences, if there is a yearly - frequency it wouldn't make sense to break it into smaller chunks, - since we would then be calculating the same sets several times. - Though this does mean that we sometimes do a lot more work than - is necessary, e.g. if COUNT is set to something quite low. */ - for (year = interval_start.year; - (end == -1 || year <= interval_end.year) && year <= MAX_YEAR; - year++) { - chunk_start = interval_start; - chunk_start.year = year; - if (end != -1) - chunk_end = interval_end; - chunk_end.year = year; - - if (year != interval_start.year) { - chunk_start.month = 0; - chunk_start.day = 1; - chunk_start.hour = 0; - chunk_start.minute = 0; - chunk_start.second = 0; - } - if (end == -1 || year != interval_end.year) { - chunk_end.month = 11; - chunk_end.day = 31; - chunk_end.hour = 23; - chunk_end.minute = 59; - chunk_end.second = 61; - chunk_end.flags = FALSE; - } - - if (!generate_instances_for_chunk (comp, dtstart_time, - start_zone, - rrules, rdates, - exrules, exdates, - single_rule, - &event_start, - start, - &chunk_start, &chunk_end, - days, seconds, - convert_end_date, - cb, cb_data)) - break; - } - - if (!prop) { - cal_component_free_period_list (rdates); - cal_component_free_exdate_list (exdates); - } - - out: - cal_component_free_datetime (&dtstart); - cal_component_free_datetime (&dtend); -} - -/* Builds a list of GINT_TO_POINTER() elements out of a short array from a - * struct icalrecurrencetype. - */ -static GList * -array_to_list (short *array, int max_elements) -{ - GList *l; - int i; - - l = NULL; - - for (i = 0; i < max_elements && array[i] != ICAL_RECURRENCE_ARRAY_MAX; i++) - l = g_list_prepend (l, GINT_TO_POINTER ((int) (array[i]))); - return g_list_reverse (l); -} - -/** - * cal_recur_from_icalproperty: - * @prop: An RRULE or EXRULE #icalproperty. - * @exception: TRUE if this is an EXRULE rather than an RRULE. - * @zone: The DTSTART timezone, used for converting the UNTIL property if it - * is given as a DATE value. - * @convert_end_date: TRUE if the saved end date needs to be converted to the - * given @zone timezone. This is needed if the DTSTART is a DATE or floating - * time. - * - * Converts an #icalproperty to a #CalRecurrence. This should be - * freed using the cal_recur_free() function. - * - * Return value: #CalRecurrence structure. - **/ -static CalRecurrence * -cal_recur_from_icalproperty (icalproperty *prop, gboolean exception, - icaltimezone *zone, gboolean convert_end_date) -{ - struct icalrecurrencetype ir; - CalRecurrence *r; - gint max_elements, i; - GList *elem; - - g_return_val_if_fail (prop != NULL, NULL); - - r = g_new (CalRecurrence, 1); - - if (exception) - ir = icalproperty_get_exrule (prop); - else - ir = icalproperty_get_rrule (prop); - - r->freq = ir.freq; - r->interval = ir.interval; - - if (ir.count != 0) { - /* If COUNT is set, we use the pre-calculated enddate. - Note that this can be 0 if the RULE doesn't actually - generate COUNT instances. */ - r->enddate = cal_recur_get_rule_end_date (prop, convert_end_date ? zone : NULL); - } else { - if (icaltime_is_null_time (ir.until)) { - /* If neither COUNT or UNTIL is set, the event - recurs forever. */ - r->enddate = 0; - } else if (ir.until.is_date) { - /* If UNTIL is a DATE, we stop at the end of - the day, in local time (with the DTSTART timezone). - Note that UNTIL is inclusive so we stop before - midnight. */ - ir.until.hour = 23; - ir.until.minute = 59; - ir.until.second = 59; - ir.until.is_date = FALSE; - - r->enddate = icaltime_as_timet_with_zone (ir.until, - zone); -#if 0 - g_print (" until: %li - %s", r->enddate, ctime (&r->enddate)); -#endif - - } else { - /* If UNTIL is a DATE-TIME, it must be in UTC. */ - icaltimezone *utc_zone; - utc_zone = icaltimezone_get_utc_timezone (); - r->enddate = icaltime_as_timet_with_zone (ir.until, - utc_zone); - } - } - - r->week_start_day = cal_recur_ical_weekday_to_weekday (ir.week_start); - - r->bymonth = array_to_list (ir.by_month, - sizeof (ir.by_month) / sizeof (ir.by_month[0])); - for (elem = r->bymonth; elem; elem = elem->next) { - /* We need to convert from 1-12 to 0-11, i.e. subtract 1. */ - int month = GPOINTER_TO_INT (elem->data) - 1; - elem->data = GINT_TO_POINTER (month); - } - - r->byweekno = array_to_list (ir.by_week_no, - sizeof (ir.by_week_no) / sizeof (ir.by_week_no[0])); - - r->byyearday = array_to_list (ir.by_year_day, - sizeof (ir.by_year_day) / sizeof (ir.by_year_day[0])); - - r->bymonthday = array_to_list (ir.by_month_day, - sizeof (ir.by_month_day) / sizeof (ir.by_month_day[0])); - - /* FIXME: libical only supports 8 values, out of possible 107 * 7. */ - r->byday = NULL; - max_elements = sizeof (ir.by_day) / sizeof (ir.by_day[0]); - for (i = 0; i < max_elements && ir.by_day[i] != ICAL_RECURRENCE_ARRAY_MAX; i++) { - enum icalrecurrencetype_weekday day; - gint weeknum, weekday; - - day = icalrecurrencetype_day_day_of_week (ir.by_day[i]); - weeknum = icalrecurrencetype_day_position (ir.by_day[i]); - - weekday = cal_recur_ical_weekday_to_weekday (day); - - r->byday = g_list_prepend (r->byday, - GINT_TO_POINTER (weeknum)); - r->byday = g_list_prepend (r->byday, - GINT_TO_POINTER (weekday)); - } - - r->byhour = array_to_list (ir.by_hour, - sizeof (ir.by_hour) / sizeof (ir.by_hour[0])); - - r->byminute = array_to_list (ir.by_minute, - sizeof (ir.by_minute) / sizeof (ir.by_minute[0])); - - r->bysecond = array_to_list (ir.by_second, - sizeof (ir.by_second) / sizeof (ir.by_second[0])); - - r->bysetpos = array_to_list (ir.by_set_pos, - sizeof (ir.by_set_pos) / sizeof (ir.by_set_pos[0])); - - return r; -} - - -static gint -cal_recur_ical_weekday_to_weekday (enum icalrecurrencetype_weekday day) -{ - gint weekday; - - switch (day) { - case ICAL_NO_WEEKDAY: /* Monday is the default in RFC2445. */ - case ICAL_MONDAY_WEEKDAY: - weekday = 0; - break; - case ICAL_TUESDAY_WEEKDAY: - weekday = 1; - break; - case ICAL_WEDNESDAY_WEEKDAY: - weekday = 2; - break; - case ICAL_THURSDAY_WEEKDAY: - weekday = 3; - break; - case ICAL_FRIDAY_WEEKDAY: - weekday = 4; - break; - case ICAL_SATURDAY_WEEKDAY: - weekday = 5; - break; - case ICAL_SUNDAY_WEEKDAY: - weekday = 6; - break; - default: - g_warning ("cal_recur_ical_weekday_to_weekday(): Unknown week day %d", - day); - weekday = 0; - } - - return weekday; -} - - -/** - * cal_recur_free: - * @r: A #CalRecurrence structure. - * - * Frees a #CalRecurrence structure. - **/ -static void -cal_recur_free (CalRecurrence *r) -{ - g_return_if_fail (r != NULL); - - g_list_free (r->bymonth); - g_list_free (r->byweekno); - g_list_free (r->byyearday); - g_list_free (r->bymonthday); - g_list_free (r->byday); - g_list_free (r->byhour); - g_list_free (r->byminute); - g_list_free (r->bysecond); - g_list_free (r->bysetpos); - - g_free (r); -} - -/* Generates one year's worth of recurrence instances. Returns TRUE if all the - * callback invocations returned TRUE, or FALSE when any one of them returns - * FALSE, i.e. meaning that the instance generation should be stopped. - * - * This should only output instances whose start time is between chunk_start - * and chunk_end (inclusive), or we may generate duplicates when we do the next - * chunk. (This applies mainly to weekly recurrences, since weeks can span 2 - * years.) - * - * It should also only output instances that are on or after the event's - * DTSTART property and that intersect the required interval, between - * interval_start and interval_end. - */ -static gboolean -generate_instances_for_chunk (CalComponent *comp, - time_t comp_dtstart, - icaltimezone *zone, - GSList *rrules, - GSList *rdates, - GSList *exrules, - GSList *exdates, - gboolean single_rule, - CalObjTime *event_start, - time_t interval_start, - CalObjTime *chunk_start, - CalObjTime *chunk_end, - gint duration_days, - gint duration_seconds, - gboolean convert_end_date, - CalRecurInstanceFn cb, - gpointer cb_data) -{ - GArray *occs, *ex_occs, *tmp_occs, *rdate_periods; - CalObjTime cotime, *occ; - GSList *elem; - gint i; - time_t start_time, end_time; - struct icaltimetype start_tt, end_tt; - gboolean cb_status = TRUE, rule_finished, finished = TRUE; - -#if 0 - g_print ("In generate_instances_for_chunk rrules: %p\n" - " %i/%i/%i %02i:%02i:%02i - %i/%i/%i %02i:%02i:%02i\n", - rrules, - chunk_start->day, chunk_start->month + 1, - chunk_start->year, chunk_start->hour, - chunk_start->minute, chunk_start->second, - chunk_end->day, chunk_end->month + 1, - chunk_end->year, chunk_end->hour, - chunk_end->minute, chunk_end->second); -#endif - - occs = g_array_new (FALSE, FALSE, sizeof (CalObjTime)); - ex_occs = g_array_new (FALSE, FALSE, sizeof (CalObjTime)); - rdate_periods = g_array_new (FALSE, FALSE, - sizeof (CalObjRecurrenceDate)); - - /* The original DTSTART property is included in the occurrence set, - but not if we are just generating occurrences for a single rule. */ - if (!single_rule) { - /* We add it if it is in this chunk. If it is after this chunk - we set finished to FALSE, since we know we aren't finished - yet. */ - if (cal_obj_time_compare_func (event_start, chunk_end) >= 0) - finished = FALSE; - else if (cal_obj_time_compare_func (event_start, chunk_start) >= 0) - g_array_append_vals (occs, event_start, 1); - } - - /* Expand each of the recurrence rules. */ - for (elem = rrules; elem; elem = elem->next) { - icalproperty *prop; - CalRecurrence *r; - - prop = elem->data; - r = cal_recur_from_icalproperty (prop, FALSE, zone, - convert_end_date); - - tmp_occs = cal_obj_expand_recurrence (event_start, zone, r, - chunk_start, - chunk_end, - &rule_finished); - cal_recur_free (r); - - /* If any of the rules return FALSE for finished, we know we - have to carry on so we set finished to FALSE. */ - if (!rule_finished) - finished = FALSE; - - g_array_append_vals (occs, tmp_occs->data, tmp_occs->len); - g_array_free (tmp_occs, TRUE); - } - - /* Add on specific RDATE occurrence dates. If they have an end time - or duration set, flag them as RDATEs, and store a pointer to the - period in the rdate_periods array. Otherwise we can just treat them - as normal occurrences. */ - for (elem = rdates; elem; elem = elem->next) { - CalComponentPeriod *p; - CalObjRecurrenceDate rdate; - - p = elem->data; - - /* FIXME: We currently assume RDATEs are in the same timezone - as DTSTART. We should get the RDATE timezone and convert - to the DTSTART timezone first. */ - cotime.year = p->start.year; - cotime.month = p->start.month - 1; - cotime.day = p->start.day; - cotime.hour = p->start.hour; - cotime.minute = p->start.minute; - cotime.second = p->start.second; - cotime.flags = FALSE; - - /* If the rdate is after the current chunk we set finished - to FALSE, and we skip it. */ - if (cal_obj_time_compare_func (&cotime, chunk_end) >= 0) { - finished = FALSE; - continue; - } - - /* Check if the end date or duration is set. If it is we need - to store it so we can get it later. (libical seems to set - second to -1 to denote an unset time. See icalvalue.c) - FIXME. */ - if (p->type != CAL_COMPONENT_PERIOD_DATETIME - || p->u.end.second != -1) { - cotime.flags = TRUE; - - rdate.start = cotime; - rdate.period = p; - g_array_append_val (rdate_periods, rdate); - } - - g_array_append_val (occs, cotime); - } - - /* Expand each of the exception rules. */ - for (elem = exrules; elem; elem = elem->next) { - icalproperty *prop; - CalRecurrence *r; - - prop = elem->data; - r = cal_recur_from_icalproperty (prop, FALSE, zone, - convert_end_date); - - tmp_occs = cal_obj_expand_recurrence (event_start, zone, r, - chunk_start, - chunk_end, - &rule_finished); - cal_recur_free (r); - - g_array_append_vals (ex_occs, tmp_occs->data, tmp_occs->len); - g_array_free (tmp_occs, TRUE); - } - - /* Add on specific exception dates. */ - for (elem = exdates; elem; elem = elem->next) { - CalComponentDateTime *cdt; - - cdt = elem->data; - - /* FIXME: We currently assume EXDATEs are in the same timezone - as DTSTART. We should get the EXDATE timezone and convert - to the DTSTART timezone first. */ - cotime.year = cdt->value->year; - cotime.month = cdt->value->month - 1; - cotime.day = cdt->value->day; - - /* If the EXDATE has a DATE value, set the time to the start - of the day and set flags to TRUE so we know to skip all - occurrences on that date. */ - if (cdt->value->is_date) { - cotime.hour = 0; - cotime.minute = 0; - cotime.second = 0; - cotime.flags = TRUE; - } else { - cotime.hour = cdt->value->hour; - cotime.minute = cdt->value->minute; - cotime.second = cdt->value->second; - cotime.flags = FALSE; - } - - g_array_append_val (ex_occs, cotime); - } - - - /* Sort all the arrays. */ - cal_obj_sort_occurrences (occs); - cal_obj_sort_occurrences (ex_occs); - - qsort (rdate_periods->data, rdate_periods->len, - sizeof (CalObjRecurrenceDate), cal_obj_time_compare_func); - - /* Create the final array, by removing the exceptions from the - occurrences, and removing any duplicates. */ - cal_obj_remove_exceptions (occs, ex_occs); - - /* Call the callback for each occurrence. If it returns 0 we break - out of the loop. */ - for (i = 0; i < occs->len; i++) { - /* Convert each CalObjTime into a start & end time_t, and - check it is within the bounds of the event & interval. */ - occ = &g_array_index (occs, CalObjTime, i); -#if 0 - g_print ("Checking occurrence: %s\n", - cal_obj_time_to_string (occ)); -#endif - start_tt = icaltime_null_time (); - start_tt.year = occ->year; - start_tt.month = occ->month + 1; - start_tt.day = occ->day; - start_tt.hour = occ->hour; - start_tt.minute = occ->minute; - start_tt.second = occ->second; - start_time = icaltime_as_timet_with_zone (start_tt, zone); - - if (start_time == -1) { - g_warning ("time_t out of range"); - finished = TRUE; - break; - } - - /* Check to ensure that the start time is at or after the - event's DTSTART time, and that it is inside the chunk that - we are currently working on. (Note that the chunk_end time - is never after the interval end time, so this also tests - that we don't go past the end of the required interval). */ - if (start_time < comp_dtstart - || cal_obj_time_compare_func (occ, chunk_start) < 0 - || cal_obj_time_compare_func (occ, chunk_end) > 0) { -#if 0 - g_print (" start time invalid\n"); -#endif - continue; - } - - if (occ->flags) { - /* If it is an RDATE, we see if the end date or - duration was set. If not, we use the same duration - as the original occurrence. */ - if (!cal_object_get_rdate_end (occ, rdate_periods)) { - cal_obj_time_add_days (occ, duration_days); - cal_obj_time_add_seconds (occ, - duration_seconds); - } - } else { - cal_obj_time_add_days (occ, duration_days); - cal_obj_time_add_seconds (occ, duration_seconds); - } - - end_tt = icaltime_null_time (); - end_tt.year = occ->year; - end_tt.month = occ->month + 1; - end_tt.day = occ->day; - end_tt.hour = occ->hour; - end_tt.minute = occ->minute; - end_tt.second = occ->second; - end_time = icaltime_as_timet_with_zone (end_tt, zone); - - if (end_time == -1) { - g_warning ("time_t out of range"); - finished = TRUE; - break; - } - - /* Check that the end time is after the interval start, so we - know that it intersects the required interval. */ - if (end_time <= interval_start) { -#if 0 - g_print (" end time invalid\n"); -#endif - continue; - } - - cb_status = (*cb) (comp, start_time, end_time, cb_data); - if (!cb_status) - break; - } - - g_array_free (occs, TRUE); - g_array_free (ex_occs, TRUE); - g_array_free (rdate_periods, TRUE); - - /* We return TRUE (i.e. carry on) only if the callback has always - returned TRUE and we know that we have more occurrences to generate - (i.e. finished is FALSE). */ - return cb_status && !finished; -} - - -/* This looks up the occurrence time in the sorted rdate_periods array, and - tries to compute the end time of the occurrence. If no end time or duration - is set it returns FALSE and the default duration will be used. */ -static gboolean -cal_object_get_rdate_end (CalObjTime *occ, - GArray *rdate_periods) -{ - CalObjRecurrenceDate *rdate = NULL; - CalComponentPeriod *p; - gint lower, upper, middle, cmp = 0; - - lower = 0; - upper = rdate_periods->len; - - while (lower < upper) { - middle = (lower + upper) >> 1; - - rdate = &g_array_index (rdate_periods, CalObjRecurrenceDate, - middle); - - cmp = cal_obj_time_compare_func (occ, &rdate->start); - - if (cmp == 0) - break; - else if (cmp < 0) - upper = middle; - else - lower = middle + 1; - } - - /* This should never happen. */ - if (cmp == 0) { - g_warning ("Recurrence date not found"); - return FALSE; - } - - p = rdate->period; - if (p->type == CAL_COMPONENT_PERIOD_DATETIME) { - /* FIXME: We currently assume RDATEs are in the same timezone - as DTSTART. We should get the RDATE timezone and convert - to the DTSTART timezone first. */ - occ->year = p->u.end.year; - occ->month = p->u.end.month - 1; - occ->day = p->u.end.day; - occ->hour = p->u.end.hour; - occ->minute = p->u.end.minute; - occ->second = p->u.end.second; - occ->flags = FALSE; - } else { - cal_obj_time_add_days (occ, p->u.duration.weeks * 7 - + p->u.duration.days); - cal_obj_time_add_hours (occ, p->u.duration.hours); - cal_obj_time_add_minutes (occ, p->u.duration.minutes); - cal_obj_time_add_seconds (occ, p->u.duration.seconds); - } - - return TRUE; -} - - -static void -cal_object_compute_duration (CalObjTime *start, - CalObjTime *end, - gint *days, - gint *seconds) -{ - GDate start_date, end_date; - gint start_seconds, end_seconds; - - g_date_clear (&start_date, 1); - g_date_clear (&end_date, 1); - g_date_set_dmy (&start_date, start->day, start->month + 1, - start->year); - g_date_set_dmy (&end_date, end->day, end->month + 1, - end->year); - - *days = g_date_get_julian (&end_date) - g_date_get_julian (&start_date); - start_seconds = start->hour * 3600 + start->minute * 60 - + start->second; - end_seconds = end->hour * 3600 + end->minute * 60 + end->second; - - *seconds = end_seconds - start_seconds; - if (*seconds < 0) { - *days = *days - 1; - *seconds += 24 * 60 * 60; - } -} - - -/* Returns an unsorted GArray of CalObjTime's resulting from expanding the - given recurrence rule within the given interval. Note that it doesn't - clip the generated occurrences to the interval, i.e. if the interval - starts part way through the year this function still returns all the - occurrences for the year. Clipping is done later. - The finished flag is set to FALSE if there are more occurrences to generate - after the given interval.*/ -static GArray* -cal_obj_expand_recurrence (CalObjTime *event_start, - icaltimezone *zone, - CalRecurrence *recur, - CalObjTime *interval_start, - CalObjTime *interval_end, - gboolean *finished) -{ - CalRecurVTable *vtable; - CalObjTime *event_end = NULL, event_end_cotime; - RecurData recur_data; - CalObjTime occ, *cotime; - GArray *all_occs, *occs; - gint len; - - /* This is the resulting array of CalObjTime elements. */ - all_occs = g_array_new (FALSE, FALSE, sizeof (CalObjTime)); - - *finished = TRUE; - - vtable = cal_obj_get_vtable (recur->freq); - if (!vtable) - return all_occs; - - /* Calculate some useful data such as some fast lookup tables. */ - cal_obj_initialize_recur_data (&recur_data, recur, event_start); - - /* Compute the event_end, if the recur's enddate is set. */ - if (recur->enddate > 0) { - cal_object_time_from_time (&event_end_cotime, - recur->enddate, zone); - event_end = &event_end_cotime; - - /* If the enddate is before the requested interval return. */ - if (cal_obj_time_compare_func (event_end, interval_start) < 0) - return all_occs; - } - - /* Set finished to FALSE if we know there will be more occurrences to - do after this interval. */ - if (!interval_end || !event_end - || cal_obj_time_compare_func (event_end, interval_end) > 0) - *finished = FALSE; - - /* Get the first period based on the frequency and the interval that - intersects the interval between start and end. */ - if ((*vtable->find_start_position) (event_start, event_end, - &recur_data, - interval_start, interval_end, - &occ)) - return all_occs; - - /* Loop until the event ends or we go past the end of the required - interval. */ - for (;;) { - /* Generate the set of occurrences for this period. */ - switch (recur->freq) { - case ICAL_YEARLY_RECURRENCE: - occs = cal_obj_generate_set_yearly (&recur_data, - vtable, &occ); - break; - case ICAL_MONTHLY_RECURRENCE: - occs = cal_obj_generate_set_monthly (&recur_data, - vtable, &occ); - break; - default: - occs = cal_obj_generate_set_default (&recur_data, - vtable, &occ); - break; - } - - /* Sort the occurrences and remove duplicates. */ - cal_obj_sort_occurrences (occs); - cal_obj_remove_duplicates_and_invalid_dates (occs); - - /* Apply the BYSETPOS property. */ - occs = cal_obj_bysetpos_filter (recur, occs); - - /* Remove any occs after event_end. */ - len = occs->len - 1; - if (event_end) { - while (len >= 0) { - cotime = &g_array_index (occs, CalObjTime, - len); - if (cal_obj_time_compare_func (cotime, - event_end) <= 0) - break; - len--; - } - } - - /* Add the occurrences onto the main array. */ - if (len >= 0) - g_array_append_vals (all_occs, occs->data, len + 1); - - g_array_free (occs, TRUE); - - /* Skip to the next period, or exit the loop if finished. */ - if ((*vtable->find_next_position) (&occ, event_end, - &recur_data, interval_end)) - break; - } - - return all_occs; -} - - -static GArray* -cal_obj_generate_set_yearly (RecurData *recur_data, - CalRecurVTable *vtable, - CalObjTime *occ) -{ - CalRecurrence *recur = recur_data->recur; - GArray *occs_arrays[4], *occs, *occs2; - gint num_occs_arrays = 0, i; - - /* This is a bit complicated, since the iCalendar spec says that - several BYxxx modifiers can be used simultaneously. So we have to - be quite careful when determining the days of the occurrences. - The BYHOUR, BYMINUTE & BYSECOND modifiers are no problem at all. - - The modifiers we have to worry about are: BYMONTH, BYWEEKNO, - BYYEARDAY, BYMONTHDAY & BYDAY. We can't do these sequentially - since each filter will mess up the results of the previous one. - But they aren't all completely independant, e.g. BYMONTHDAY and - BYDAY are related to BYMONTH, and BYDAY is related to BYWEEKNO. - - BYDAY & BYMONTHDAY can also be applied independently, which makes - it worse. So we assume that if BYMONTH or BYWEEKNO is used, then - the BYDAY modifier applies to those, else it is applied - independantly. - - We expand the occurrences in parallel into the occs_arrays[] array, - and then merge them all into one GArray before expanding BYHOUR, - BYMINUTE & BYSECOND. */ - - if (recur->bymonth) { - occs = g_array_new (FALSE, FALSE, sizeof (CalObjTime)); - g_array_append_vals (occs, occ, 1); - - occs = (*vtable->bymonth_filter) (recur_data, occs); - - /* If BYMONTHDAY & BYDAY are both set we need to expand them - in parallel and add the results. */ - if (recur->bymonthday && recur->byday) { - /* Copy the occs array. */ - occs2 = g_array_new (FALSE, FALSE, - sizeof (CalObjTime)); - g_array_append_vals (occs2, occs->data, occs->len); - - occs = (*vtable->bymonthday_filter) (recur_data, occs); - /* Note that we explicitly call the monthly version - of the BYDAY expansion filter. */ - occs2 = cal_obj_byday_expand_monthly (recur_data, - occs2); - - /* Add the 2 resulting arrays together. */ - g_array_append_vals (occs, occs2->data, occs2->len); - g_array_free (occs2, TRUE); - } else { - occs = (*vtable->bymonthday_filter) (recur_data, occs); - /* Note that we explicitly call the monthly version - of the BYDAY expansion filter. */ - occs = cal_obj_byday_expand_monthly (recur_data, occs); - } - - occs_arrays[num_occs_arrays++] = occs; - } - - if (recur->byweekno) { - occs = g_array_new (FALSE, FALSE, sizeof (CalObjTime)); - g_array_append_vals (occs, occ, 1); - - occs = (*vtable->byweekno_filter) (recur_data, occs); - /* Note that we explicitly call the weekly version of the - BYDAY expansion filter. */ - occs = cal_obj_byday_expand_weekly (recur_data, occs); - - occs_arrays[num_occs_arrays++] = occs; - } - - if (recur->byyearday) { - occs = g_array_new (FALSE, FALSE, sizeof (CalObjTime)); - g_array_append_vals (occs, occ, 1); - - occs = (*vtable->byyearday_filter) (recur_data, occs); - - occs_arrays[num_occs_arrays++] = occs; - } - - /* If BYMONTHDAY is set, and BYMONTH is not set, we need to - expand BYMONTHDAY independantly. */ - if (recur->bymonthday && !recur->bymonth) { - occs = g_array_new (FALSE, FALSE, sizeof (CalObjTime)); - g_array_append_vals (occs, occ, 1); - - occs = (*vtable->bymonthday_filter) (recur_data, occs); - - occs_arrays[num_occs_arrays++] = occs; - } - - /* If BYDAY is set, and BYMONTH and BYWEEKNO are not set, we need to - expand BYDAY independantly. */ - if (recur->byday && !recur->bymonth && !recur->byweekno) { - occs = g_array_new (FALSE, FALSE, sizeof (CalObjTime)); - g_array_append_vals (occs, occ, 1); - - occs = (*vtable->byday_filter) (recur_data, occs); - - occs_arrays[num_occs_arrays++] = occs; - } - - /* Add all the arrays together. If no filters were used we just - create an array with one element. */ - if (num_occs_arrays > 0) { - occs = occs_arrays[0]; - for (i = 1; i < num_occs_arrays; i++) { - occs2 = occs_arrays[i]; - g_array_append_vals (occs, occs2->data, occs2->len); - g_array_free (occs2, TRUE); - } - } else { - occs = g_array_new (FALSE, FALSE, sizeof (CalObjTime)); - g_array_append_vals (occs, occ, 1); - } - - /* Now expand BYHOUR, BYMINUTE & BYSECOND. */ - occs = (*vtable->byhour_filter) (recur_data, occs); - occs = (*vtable->byminute_filter) (recur_data, occs); - occs = (*vtable->bysecond_filter) (recur_data, occs); - - return occs; -} - - -static GArray* -cal_obj_generate_set_monthly (RecurData *recur_data, - CalRecurVTable *vtable, - CalObjTime *occ) -{ - GArray *occs, *occs2; - - /* We start with just the one time in each set. */ - occs = g_array_new (FALSE, FALSE, sizeof (CalObjTime)); - g_array_append_vals (occs, occ, 1); - - occs = (*vtable->bymonth_filter) (recur_data, occs); - - /* We need to combine the output of BYMONTHDAY & BYDAY, by doing them - in parallel rather than sequentially. If we did them sequentially - then we would lose the occurrences generated by BYMONTHDAY, and - instead have repetitions of the occurrences from BYDAY. */ - if (recur_data->recur->bymonthday && recur_data->recur->byday) { - occs2 = g_array_new (FALSE, FALSE, sizeof (CalObjTime)); - g_array_append_vals (occs2, occs->data, occs->len); - - occs = (*vtable->bymonthday_filter) (recur_data, occs); - occs2 = (*vtable->byday_filter) (recur_data, occs2); - - g_array_append_vals (occs, occs2->data, occs2->len); - g_array_free (occs2, TRUE); - } else { - occs = (*vtable->bymonthday_filter) (recur_data, occs); - occs = (*vtable->byday_filter) (recur_data, occs); - } - - occs = (*vtable->byhour_filter) (recur_data, occs); - occs = (*vtable->byminute_filter) (recur_data, occs); - occs = (*vtable->bysecond_filter) (recur_data, occs); - - return occs; -} - - -static GArray* -cal_obj_generate_set_default (RecurData *recur_data, - CalRecurVTable *vtable, - CalObjTime *occ) -{ - GArray *occs; - -#if 0 - g_print ("Generating set for %i/%i/%i %02i:%02i:%02i\n", - occ->day, occ->month + 1, occ->year, occ->hour, occ->minute, - occ->second); -#endif - - /* We start with just the one time in the set. */ - occs = g_array_new (FALSE, FALSE, sizeof (CalObjTime)); - g_array_append_vals (occs, occ, 1); - - occs = (*vtable->bymonth_filter) (recur_data, occs); - if (vtable->byweekno_filter) - occs = (*vtable->byweekno_filter) (recur_data, occs); - if (vtable->byyearday_filter) - occs = (*vtable->byyearday_filter) (recur_data, occs); - if (vtable->bymonthday_filter) - occs = (*vtable->bymonthday_filter) (recur_data, occs); - occs = (*vtable->byday_filter) (recur_data, occs); - - occs = (*vtable->byhour_filter) (recur_data, occs); - occs = (*vtable->byminute_filter) (recur_data, occs); - occs = (*vtable->bysecond_filter) (recur_data, occs); - - return occs; -} - - - -/* Returns the function table corresponding to the recurrence frequency. */ -static CalRecurVTable* cal_obj_get_vtable (icalrecurrencetype_frequency recur_type) -{ - CalRecurVTable* vtable; - - switch (recur_type) { - case ICAL_YEARLY_RECURRENCE: - vtable = &cal_obj_yearly_vtable; - break; - case ICAL_MONTHLY_RECURRENCE: - vtable = &cal_obj_monthly_vtable; - break; - case ICAL_WEEKLY_RECURRENCE: - vtable = &cal_obj_weekly_vtable; - break; - case ICAL_DAILY_RECURRENCE: - vtable = &cal_obj_daily_vtable; - break; - case ICAL_HOURLY_RECURRENCE: - vtable = &cal_obj_hourly_vtable; - break; - case ICAL_MINUTELY_RECURRENCE: - vtable = &cal_obj_minutely_vtable; - break; - case ICAL_SECONDLY_RECURRENCE: - vtable = &cal_obj_secondly_vtable; - break; - default: - g_warning ("Unknown recurrence frequency"); - vtable = NULL; - } - - return vtable; -} - - -/* This creates a number of fast lookup tables used when filtering with the - modifier properties BYMONTH, BYYEARDAY etc. */ -static void -cal_obj_initialize_recur_data (RecurData *recur_data, - CalRecurrence *recur, - CalObjTime *event_start) -{ - GList *elem; - gint month, yearday, monthday, weekday, week_num, hour, minute, second; - - /* Clear the entire RecurData. */ - memset (recur_data, 0, sizeof (RecurData)); - - recur_data->recur = recur; - - /* Set the weekday, used for the WEEKLY frequency and the BYWEEKNO - modifier. */ - recur_data->weekday_offset = cal_obj_time_weekday_offset (event_start, - recur); - - /* Create an array of months from bymonths for fast lookup. */ - elem = recur->bymonth; - while (elem) { - month = GPOINTER_TO_INT (elem->data); - recur_data->months[month] = 1; - elem = elem->next; - } - - /* Create an array of yeardays from byyearday for fast lookup. - We create a second array to handle the negative values. The first - element there corresponds to the last day of the year. */ - elem = recur->byyearday; - while (elem) { - yearday = GPOINTER_TO_INT (elem->data); - if (yearday >= 0) - recur_data->yeardays[yearday] = 1; - else - recur_data->neg_yeardays[-yearday] = 1; - elem = elem->next; - } - - /* Create an array of monthdays from bymonthday for fast lookup. - We create a second array to handle the negative values. The first - element there corresponds to the last day of the month. */ - elem = recur->bymonthday; - while (elem) { - monthday = GPOINTER_TO_INT (elem->data); - if (monthday >= 0) - recur_data->monthdays[monthday] = 1; - else - recur_data->neg_monthdays[-monthday] = 1; - elem = elem->next; - } - - /* Create an array of weekdays from byday for fast lookup. */ - elem = recur->byday; - while (elem) { - weekday = GPOINTER_TO_INT (elem->data); - elem = elem->next; - /* The week number is not used when filtering. */ - week_num = GPOINTER_TO_INT (elem->data); - elem = elem->next; - - recur_data->weekdays[weekday] = 1; - } - - /* Create an array of hours from byhour for fast lookup. */ - elem = recur->byhour; - while (elem) { - hour = GPOINTER_TO_INT (elem->data); - recur_data->hours[hour] = 1; - elem = elem->next; - } - - /* Create an array of minutes from byminutes for fast lookup. */ - elem = recur->byminute; - while (elem) { - minute = GPOINTER_TO_INT (elem->data); - recur_data->minutes[minute] = 1; - elem = elem->next; - } - - /* Create an array of seconds from byseconds for fast lookup. */ - elem = recur->bysecond; - while (elem) { - second = GPOINTER_TO_INT (elem->data); - recur_data->seconds[second] = 1; - elem = elem->next; - } -} - - -static void -cal_obj_sort_occurrences (GArray *occs) -{ - qsort (occs->data, occs->len, sizeof (CalObjTime), - cal_obj_time_compare_func); -} - - -static void -cal_obj_remove_duplicates_and_invalid_dates (GArray *occs) -{ - static const int days_in_month[12] = { - 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31 - }; - - CalObjTime *occ, *prev_occ = NULL; - gint len, i, j = 0, year, month, days; - gboolean keep_occ; - - len = occs->len; - for (i = 0; i < len; i++) { - occ = &g_array_index (occs, CalObjTime, i); - keep_occ = TRUE; - - if (prev_occ && cal_obj_time_compare_func (occ, - prev_occ) == 0) - keep_occ = FALSE; - - year = occ->year; - month = occ->month; - days = days_in_month[occ->month]; - /* If it is february and a leap year, add a day. */ - if (month == 1 && (year % 4 == 0 - && (year % 100 != 0 - || year % 400 == 0))) - days++; - if (occ->day > days) - keep_occ = FALSE; - - if (keep_occ) { - if (i != j) - g_array_index (occs, CalObjTime, j) - = g_array_index (occs, CalObjTime, i); - j++; - } - - prev_occ = occ; - } - - g_array_set_size (occs, j); -} - - -/* Removes the exceptions from the ex_occs array from the occurrences in the - occs array, and removes any duplicates. Both arrays are sorted. */ -static void -cal_obj_remove_exceptions (GArray *occs, - GArray *ex_occs) -{ - CalObjTime *occ, *prev_occ = NULL, *ex_occ = NULL, *last_occ_kept; - gint i, j = 0, cmp, ex_index, occs_len, ex_occs_len; - gboolean keep_occ, current_time_is_exception = FALSE; - - if (occs->len == 0) - return; - - ex_index = 0; - occs_len = occs->len; - ex_occs_len = ex_occs->len; - - if (ex_occs_len > 0) - ex_occ = &g_array_index (ex_occs, CalObjTime, ex_index); - - for (i = 0; i < occs_len; i++) { - occ = &g_array_index (occs, CalObjTime, i); - keep_occ = TRUE; - - /* If the occurrence is a duplicate of the previous one, skip - it. */ - if (prev_occ - && cal_obj_time_compare_func (occ, prev_occ) == 0) { - keep_occ = FALSE; - - /* If this occurrence is an RDATE with an end or - duration set, and the previous occurrence in the - array was kept, set the RDATE flag of the last one, - so we still use the end date or duration. */ - if (occ->flags && !current_time_is_exception) { - last_occ_kept = &g_array_index (occs, - CalObjTime, - j - 1); - last_occ_kept->flags = TRUE; - } - } else { - /* We've found a new occurrence time. Reset the flag - to indicate that it hasn't been found in the - exceptions array (yet). */ - current_time_is_exception = FALSE; - - if (ex_occ) { - /* Step through the exceptions until we come - to one that matches or follows this - occurrence. */ - while (ex_occ) { - /* If the exception is an EXDATE with - a DATE value, we only have to - compare the date. */ - if (ex_occ->flags) - cmp = cal_obj_date_only_compare_func (ex_occ, occ); - else - cmp = cal_obj_time_compare_func (ex_occ, occ); - - if (cmp > 0) - break; - - /* Move to the next exception, or set - ex_occ to NULL when we reach the - end of array. */ - ex_index++; - if (ex_index < ex_occs_len) - ex_occ = &g_array_index (ex_occs, CalObjTime, ex_index); - else - ex_occ = NULL; - - /* If the exception did match this - occurrence we remove it, and set the - flag to indicate that the current - time is an exception. */ - if (cmp == 0) { - current_time_is_exception = TRUE; - keep_occ = FALSE; - break; - } - } - } - } - - if (keep_occ) { - /* We are keeping this occurrence, so we move it to - the next free space, unless its position hasn't - changed (i.e. all previous occurrences were also - kept). */ - if (i != j) - g_array_index (occs, CalObjTime, j) - = g_array_index (occs, CalObjTime, i); - j++; - } - - prev_occ = occ; - } - - g_array_set_size (occs, j); -} - - - -static GArray* -cal_obj_bysetpos_filter (CalRecurrence *recur, - GArray *occs) -{ - GArray *new_occs; - CalObjTime *occ; - GList *elem; - gint len, pos; - - /* If BYSETPOS has not been specified, or the array is empty, just - return the array. */ - elem = recur->bysetpos; - if (!elem || occs->len == 0) - return occs; - - new_occs = g_array_new (FALSE, FALSE, sizeof (CalObjTime)); - - /* Iterate over the indices given in bysetpos, adding the corresponding - element from occs to new_occs. */ - len = occs->len; - while (elem) { - pos = GPOINTER_TO_INT (elem->data); - - /* Negative values count back from the end of the array. */ - if (pos < 0) - pos += len; - /* Positive values need to be decremented since the array is - 0-based. */ - else - pos--; - - if (pos >= 0 && pos < len) { - occ = &g_array_index (occs, CalObjTime, pos); - g_array_append_vals (new_occs, occ, 1); - } - elem = elem->next; - } - - g_array_free (occs, TRUE); - - return new_occs; -} - - - - -/* Finds the first year from the event_start, counting in multiples of the - recurrence interval, that intersects the given interval. It returns TRUE - if there is no intersection. */ -static gboolean -cal_obj_yearly_find_start_position (CalObjTime *event_start, - CalObjTime *event_end, - RecurData *recur_data, - CalObjTime *interval_start, - CalObjTime *interval_end, - CalObjTime *cotime) -{ - *cotime = *event_start; - - /* Move on to the next interval, if the event starts before the - given interval. */ - if (cotime->year < interval_start->year) { - gint years = interval_start->year - cotime->year - + recur_data->recur->interval - 1; - years -= years % recur_data->recur->interval; - /* NOTE: The day may now be invalid, e.g. 29th Feb. */ - cotime->year += years; - } - - if ((event_end && cotime->year > event_end->year) - || (interval_end && cotime->year > interval_end->year)) - return TRUE; - - return FALSE; -} - - -static gboolean -cal_obj_yearly_find_next_position (CalObjTime *cotime, - CalObjTime *event_end, - RecurData *recur_data, - CalObjTime *interval_end) -{ - /* NOTE: The day may now be invalid, e.g. 29th Feb. */ - cotime->year += recur_data->recur->interval; - - if ((event_end && cotime->year > event_end->year) - || (interval_end && cotime->year > interval_end->year)) - return TRUE; - - return FALSE; -} - - - -static gboolean -cal_obj_monthly_find_start_position (CalObjTime *event_start, - CalObjTime *event_end, - RecurData *recur_data, - CalObjTime *interval_start, - CalObjTime *interval_end, - CalObjTime *cotime) -{ - *cotime = *event_start; - - /* Move on to the next interval, if the event starts before the - given interval. */ - if (cal_obj_time_compare (cotime, interval_start, CALOBJ_MONTH) < 0) { - gint months = (interval_start->year - cotime->year) * 12 - + interval_start->month - cotime->month - + recur_data->recur->interval - 1; - months -= months % recur_data->recur->interval; - /* NOTE: The day may now be invalid, e.g. 31st Sep. */ - cal_obj_time_add_months (cotime, months); - } - - if (event_end && cal_obj_time_compare (cotime, event_end, - CALOBJ_MONTH) > 0) - return TRUE; - if (interval_end && cal_obj_time_compare (cotime, interval_end, - CALOBJ_MONTH) > 0) - return TRUE; - - return FALSE; -} - - -static gboolean -cal_obj_monthly_find_next_position (CalObjTime *cotime, - CalObjTime *event_end, - RecurData *recur_data, - CalObjTime *interval_end) -{ - /* NOTE: The day may now be invalid, e.g. 31st Sep. */ - cal_obj_time_add_months (cotime, recur_data->recur->interval); - - if (event_end && cal_obj_time_compare (cotime, event_end, - CALOBJ_MONTH) > 0) - return TRUE; - if (interval_end && cal_obj_time_compare (cotime, interval_end, - CALOBJ_MONTH) > 0) - return TRUE; - - return FALSE; -} - - - -static gboolean -cal_obj_weekly_find_start_position (CalObjTime *event_start, - CalObjTime *event_end, - RecurData *recur_data, - CalObjTime *interval_start, - CalObjTime *interval_end, - CalObjTime *cotime) -{ - GDate event_start_date, interval_start_date; - guint32 event_start_julian, interval_start_julian; - gint interval_start_weekday_offset; - CalObjTime week_start; - - if (event_end && cal_obj_time_compare (event_end, interval_start, - CALOBJ_DAY) < 0) - return TRUE; - if (interval_end && cal_obj_time_compare (event_start, interval_end, - CALOBJ_DAY) > 0) - return TRUE; - - *cotime = *event_start; - - /* Convert the event start and interval start to GDates, so we can - easily find the number of days between them. */ - g_date_clear (&event_start_date, 1); - g_date_set_dmy (&event_start_date, event_start->day, - event_start->month + 1, event_start->year); - g_date_clear (&interval_start_date, 1); - g_date_set_dmy (&interval_start_date, interval_start->day, - interval_start->month + 1, interval_start->year); - - /* Calculate the start of the weeks corresponding to the event start - and interval start. */ - event_start_julian = g_date_get_julian (&event_start_date); - event_start_julian -= recur_data->weekday_offset; - - interval_start_julian = g_date_get_julian (&interval_start_date); - interval_start_weekday_offset = cal_obj_time_weekday_offset (interval_start, recur_data->recur); - interval_start_julian -= interval_start_weekday_offset; - - /* We want to find the first full week using the recurrence interval - that intersects the given interval dates. */ - if (event_start_julian < interval_start_julian) { - gint weeks = (interval_start_julian - event_start_julian) / 7; - weeks += recur_data->recur->interval - 1; - weeks -= weeks % recur_data->recur->interval; - cal_obj_time_add_days (cotime, weeks * 7); - } - - week_start = *cotime; - cal_obj_time_add_days (&week_start, -recur_data->weekday_offset); - - if (event_end && cal_obj_time_compare (&week_start, event_end, - CALOBJ_DAY) > 0) - return TRUE; - if (interval_end && cal_obj_time_compare (&week_start, interval_end, - CALOBJ_DAY) > 0) - return TRUE; - - return FALSE; -} - - -static gboolean -cal_obj_weekly_find_next_position (CalObjTime *cotime, - CalObjTime *event_end, - RecurData *recur_data, - CalObjTime *interval_end) -{ - CalObjTime week_start; - - cal_obj_time_add_days (cotime, recur_data->recur->interval * 7); - - /* Return TRUE if the start of this week is after the event finishes - or is after the end of the required interval. */ - week_start = *cotime; - cal_obj_time_add_days (&week_start, -recur_data->weekday_offset); - -#ifdef CAL_OBJ_DEBUG - g_print ("Next day: %s\n", cal_obj_time_to_string (cotime)); - g_print ("Week Start: %s\n", cal_obj_time_to_string (&week_start)); -#endif - - if (event_end && cal_obj_time_compare (&week_start, event_end, - CALOBJ_DAY) > 0) - return TRUE; - if (interval_end && cal_obj_time_compare (&week_start, interval_end, - CALOBJ_DAY) > 0) { -#ifdef CAL_OBJ_DEBUG - g_print ("Interval end reached: %s\n", - cal_obj_time_to_string (interval_end)); -#endif - return TRUE; - } - - return FALSE; -} - - -static gboolean -cal_obj_daily_find_start_position (CalObjTime *event_start, - CalObjTime *event_end, - RecurData *recur_data, - CalObjTime *interval_start, - CalObjTime *interval_end, - CalObjTime *cotime) -{ - GDate event_start_date, interval_start_date; - guint32 event_start_julian, interval_start_julian, days; - - if (interval_end && cal_obj_time_compare (event_start, interval_end, - CALOBJ_DAY) > 0) - return TRUE; - if (event_end && cal_obj_time_compare (event_end, interval_start, - CALOBJ_DAY) < 0) - return TRUE; - - *cotime = *event_start; - - /* Convert the event start and interval start to GDates, so we can - easily find the number of days between them. */ - g_date_clear (&event_start_date, 1); - g_date_set_dmy (&event_start_date, event_start->day, - event_start->month + 1, event_start->year); - g_date_clear (&interval_start_date, 1); - g_date_set_dmy (&interval_start_date, interval_start->day, - interval_start->month + 1, interval_start->year); - - event_start_julian = g_date_get_julian (&event_start_date); - interval_start_julian = g_date_get_julian (&interval_start_date); - - if (event_start_julian < interval_start_julian) { - days = interval_start_julian - event_start_julian - + recur_data->recur->interval - 1; - days -= days % recur_data->recur->interval; - cal_obj_time_add_days (cotime, days); - } - - if (event_end && cal_obj_time_compare (cotime, event_end, - CALOBJ_DAY) > 0) - return TRUE; - if (interval_end && cal_obj_time_compare (cotime, interval_end, - CALOBJ_DAY) > 0) - return TRUE; - - return FALSE; -} - - -static gboolean -cal_obj_daily_find_next_position (CalObjTime *cotime, - CalObjTime *event_end, - RecurData *recur_data, - CalObjTime *interval_end) -{ - cal_obj_time_add_days (cotime, recur_data->recur->interval); - - if (event_end && cal_obj_time_compare (cotime, event_end, - CALOBJ_DAY) > 0) - return TRUE; - if (interval_end && cal_obj_time_compare (cotime, interval_end, - CALOBJ_DAY) > 0) - return TRUE; - - return FALSE; -} - - -static gboolean -cal_obj_hourly_find_start_position (CalObjTime *event_start, - CalObjTime *event_end, - RecurData *recur_data, - CalObjTime *interval_start, - CalObjTime *interval_end, - CalObjTime *cotime) -{ - GDate event_start_date, interval_start_date; - guint32 event_start_julian, interval_start_julian, hours; - - if (interval_end && cal_obj_time_compare (event_start, interval_end, - CALOBJ_HOUR) > 0) - return TRUE; - if (event_end && cal_obj_time_compare (event_end, interval_start, - CALOBJ_HOUR) < 0) - return TRUE; - - *cotime = *event_start; - - if (cal_obj_time_compare (event_start, interval_start, - CALOBJ_HOUR) < 0) { - /* Convert the event start and interval start to GDates, so we - can easily find the number of days between them. */ - g_date_clear (&event_start_date, 1); - g_date_set_dmy (&event_start_date, event_start->day, - event_start->month + 1, event_start->year); - g_date_clear (&interval_start_date, 1); - g_date_set_dmy (&interval_start_date, interval_start->day, - interval_start->month + 1, - interval_start->year); - - event_start_julian = g_date_get_julian (&event_start_date); - interval_start_julian = g_date_get_julian (&interval_start_date); - - hours = (interval_start_julian - event_start_julian) * 24; - hours += interval_start->hour - event_start->hour; - hours += recur_data->recur->interval - 1; - hours -= hours % recur_data->recur->interval; - cal_obj_time_add_hours (cotime, hours); - } - - if (event_end && cal_obj_time_compare (cotime, event_end, - CALOBJ_HOUR) > 0) - return TRUE; - if (interval_end && cal_obj_time_compare (cotime, interval_end, - CALOBJ_HOUR) > 0) - return TRUE; - - return FALSE; -} - - -static gboolean -cal_obj_hourly_find_next_position (CalObjTime *cotime, - CalObjTime *event_end, - RecurData *recur_data, - CalObjTime *interval_end) -{ - cal_obj_time_add_hours (cotime, recur_data->recur->interval); - - if (event_end && cal_obj_time_compare (cotime, event_end, - CALOBJ_HOUR) > 0) - return TRUE; - if (interval_end && cal_obj_time_compare (cotime, interval_end, - CALOBJ_HOUR) > 0) - return TRUE; - - return FALSE; -} - - -static gboolean -cal_obj_minutely_find_start_position (CalObjTime *event_start, - CalObjTime *event_end, - RecurData *recur_data, - CalObjTime *interval_start, - CalObjTime *interval_end, - CalObjTime *cotime) -{ - GDate event_start_date, interval_start_date; - guint32 event_start_julian, interval_start_julian, minutes; - - if (interval_end && cal_obj_time_compare (event_start, interval_end, - CALOBJ_MINUTE) > 0) - return TRUE; - if (event_end && cal_obj_time_compare (event_end, interval_start, - CALOBJ_MINUTE) < 0) - return TRUE; - - *cotime = *event_start; - - if (cal_obj_time_compare (event_start, interval_start, - CALOBJ_MINUTE) < 0) { - /* Convert the event start and interval start to GDates, so we - can easily find the number of days between them. */ - g_date_clear (&event_start_date, 1); - g_date_set_dmy (&event_start_date, event_start->day, - event_start->month + 1, event_start->year); - g_date_clear (&interval_start_date, 1); - g_date_set_dmy (&interval_start_date, interval_start->day, - interval_start->month + 1, - interval_start->year); - - event_start_julian = g_date_get_julian (&event_start_date); - interval_start_julian = g_date_get_julian (&interval_start_date); - - minutes = (interval_start_julian - event_start_julian) - * 24 * 60; - minutes += (interval_start->hour - event_start->hour) * 24; - minutes += interval_start->minute - event_start->minute; - minutes += recur_data->recur->interval - 1; - minutes -= minutes % recur_data->recur->interval; - cal_obj_time_add_minutes (cotime, minutes); - } - - if (event_end && cal_obj_time_compare (cotime, event_end, - CALOBJ_MINUTE) > 0) - return TRUE; - if (interval_end && cal_obj_time_compare (cotime, interval_end, - CALOBJ_MINUTE) > 0) - return TRUE; - - return FALSE; -} - - -static gboolean -cal_obj_minutely_find_next_position (CalObjTime *cotime, - CalObjTime *event_end, - RecurData *recur_data, - CalObjTime *interval_end) -{ - cal_obj_time_add_minutes (cotime, recur_data->recur->interval); - - if (event_end && cal_obj_time_compare (cotime, event_end, - CALOBJ_MINUTE) > 0) - return TRUE; - if (interval_end && cal_obj_time_compare (cotime, interval_end, - CALOBJ_MINUTE) > 0) - return TRUE; - - return FALSE; -} - - -static gboolean -cal_obj_secondly_find_start_position (CalObjTime *event_start, - CalObjTime *event_end, - RecurData *recur_data, - CalObjTime *interval_start, - CalObjTime *interval_end, - CalObjTime *cotime) -{ - GDate event_start_date, interval_start_date; - guint32 event_start_julian, interval_start_julian, seconds; - - if (interval_end && cal_obj_time_compare (event_start, interval_end, - CALOBJ_SECOND) > 0) - return TRUE; - if (event_end && cal_obj_time_compare (event_end, interval_start, - CALOBJ_SECOND) < 0) - return TRUE; - - *cotime = *event_start; - - if (cal_obj_time_compare (event_start, interval_start, - CALOBJ_SECOND) < 0) { - /* Convert the event start and interval start to GDates, so we - can easily find the number of days between them. */ - g_date_clear (&event_start_date, 1); - g_date_set_dmy (&event_start_date, event_start->day, - event_start->month + 1, event_start->year); - g_date_clear (&interval_start_date, 1); - g_date_set_dmy (&interval_start_date, interval_start->day, - interval_start->month + 1, - interval_start->year); - - event_start_julian = g_date_get_julian (&event_start_date); - interval_start_julian = g_date_get_julian (&interval_start_date); - - seconds = (interval_start_julian - event_start_julian) - * 24 * 60 * 60; - seconds += (interval_start->hour - event_start->hour) - * 24 * 60; - seconds += (interval_start->minute - event_start->minute) * 60; - seconds += interval_start->second - event_start->second; - seconds += recur_data->recur->interval - 1; - seconds -= seconds % recur_data->recur->interval; - cal_obj_time_add_seconds (cotime, seconds); - } - - if (event_end && cal_obj_time_compare (cotime, event_end, - CALOBJ_SECOND) >= 0) - return TRUE; - if (interval_end && cal_obj_time_compare (cotime, interval_end, - CALOBJ_SECOND) >= 0) - return TRUE; - - return FALSE; -} - - -static gboolean -cal_obj_secondly_find_next_position (CalObjTime *cotime, - CalObjTime *event_end, - RecurData *recur_data, - CalObjTime *interval_end) -{ - cal_obj_time_add_seconds (cotime, recur_data->recur->interval); - - if (event_end && cal_obj_time_compare (cotime, event_end, - CALOBJ_SECOND) >= 0) - return TRUE; - if (interval_end && cal_obj_time_compare (cotime, interval_end, - CALOBJ_SECOND) >= 0) - return TRUE; - - return FALSE; -} - - - - - -/* If the BYMONTH rule is specified it expands each occurrence in occs, by - using each of the months in the bymonth list. */ -static GArray* -cal_obj_bymonth_expand (RecurData *recur_data, - GArray *occs) -{ - GArray *new_occs; - CalObjTime *occ; - GList *elem; - gint len, i; - - /* If BYMONTH has not been specified, or the array is empty, just - return the array. */ - if (!recur_data->recur->bymonth || occs->len == 0) - return occs; - - new_occs = g_array_new (FALSE, FALSE, sizeof (CalObjTime)); - - len = occs->len; - for (i = 0; i < len; i++) { - occ = &g_array_index (occs, CalObjTime, i); - - elem = recur_data->recur->bymonth; - while (elem) { - /* NOTE: The day may now be invalid, e.g. 31st Feb. */ - occ->month = GPOINTER_TO_INT (elem->data); - g_array_append_vals (new_occs, occ, 1); - elem = elem->next; - } - } - - g_array_free (occs, TRUE); - - return new_occs; -} - - -/* If the BYMONTH rule is specified it filters out all occurrences in occs - which do not match one of the months in the bymonth list. */ -static GArray* -cal_obj_bymonth_filter (RecurData *recur_data, - GArray *occs) -{ - GArray *new_occs; - CalObjTime *occ; - gint len, i; - - /* If BYMONTH has not been specified, or the array is empty, just - return the array. */ - if (!recur_data->recur->bymonth || occs->len == 0) - return occs; - - new_occs = g_array_new (FALSE, FALSE, sizeof (CalObjTime)); - - len = occs->len; - for (i = 0; i < len; i++) { - occ = &g_array_index (occs, CalObjTime, i); - if (recur_data->months[occ->month]) - g_array_append_vals (new_occs, occ, 1); - } - - g_array_free (occs, TRUE); - - return new_occs; -} - - - -static GArray* -cal_obj_byweekno_expand (RecurData *recur_data, - GArray *occs) -{ - GArray *new_occs; - CalObjTime *occ, year_start_cotime, year_end_cotime, cotime; - GList *elem; - gint len, i, weekno; - - /* If BYWEEKNO has not been specified, or the array is empty, just - return the array. */ - if (!recur_data->recur->byweekno || occs->len == 0) - return occs; - - new_occs = g_array_new (FALSE, FALSE, sizeof (CalObjTime)); - - len = occs->len; - for (i = 0; i < len; i++) { - occ = &g_array_index (occs, CalObjTime, i); - - /* Find the day that would correspond to week 1 (note that - week 1 is the first week starting from the specified week - start day that has 4 days in the new year). */ - year_start_cotime = *occ; - cal_obj_time_find_first_week (&year_start_cotime, - recur_data); - - /* Find the day that would correspond to week 1 of the next - year, which we use for -ve week numbers. */ - year_end_cotime = *occ; - year_end_cotime.year++; - cal_obj_time_find_first_week (&year_end_cotime, - recur_data); - - /* Now iterate over the week numbers in byweekno, generating a - new occurrence for each one. */ - elem = recur_data->recur->byweekno; - while (elem) { - weekno = GPOINTER_TO_INT (elem->data); - if (weekno > 0) { - cotime = year_start_cotime; - cal_obj_time_add_days (&cotime, - (weekno - 1) * 7); - } else { - cotime = year_end_cotime; - cal_obj_time_add_days (&cotime, weekno * 7); - } - - /* Skip occurrences if they fall outside the year. */ - if (cotime.year == occ->year) - g_array_append_val (new_occs, cotime); - elem = elem->next; - } - } - - g_array_free (occs, TRUE); - - return new_occs; -} - - -#if 0 -/* This isn't used at present. */ -static GArray* -cal_obj_byweekno_filter (RecurData *recur_data, - GArray *occs) -{ - - return occs; -} -#endif - - -static GArray* -cal_obj_byyearday_expand (RecurData *recur_data, - GArray *occs) -{ - GArray *new_occs; - CalObjTime *occ, year_start_cotime, year_end_cotime, cotime; - GList *elem; - gint len, i, dayno; - - /* If BYYEARDAY has not been specified, or the array is empty, just - return the array. */ - if (!recur_data->recur->byyearday || occs->len == 0) - return occs; - - new_occs = g_array_new (FALSE, FALSE, sizeof (CalObjTime)); - - len = occs->len; - for (i = 0; i < len; i++) { - occ = &g_array_index (occs, CalObjTime, i); - - /* Find the day that would correspond to day 1. */ - year_start_cotime = *occ; - year_start_cotime.month = 0; - year_start_cotime.day = 1; - - /* Find the day that would correspond to day 1 of the next - year, which we use for -ve day numbers. */ - year_end_cotime = *occ; - year_end_cotime.year++; - year_end_cotime.month = 0; - year_end_cotime.day = 1; - - /* Now iterate over the day numbers in byyearday, generating a - new occurrence for each one. */ - elem = recur_data->recur->byyearday; - while (elem) { - dayno = GPOINTER_TO_INT (elem->data); - if (dayno > 0) { - cotime = year_start_cotime; - cal_obj_time_add_days (&cotime, dayno - 1); - } else { - cotime = year_end_cotime; - cal_obj_time_add_days (&cotime, dayno); - } - - /* Skip occurrences if they fall outside the year. */ - if (cotime.year == occ->year) - g_array_append_val (new_occs, cotime); - elem = elem->next; - } - } - - g_array_free (occs, TRUE); - - return new_occs; -} - - -/* Note: occs must not contain invalid dates, e.g. 31st September. */ -static GArray* -cal_obj_byyearday_filter (RecurData *recur_data, - GArray *occs) -{ - GArray *new_occs; - CalObjTime *occ; - gint yearday, len, i, days_in_year; - - /* If BYYEARDAY has not been specified, or the array is empty, just - return the array. */ - if (!recur_data->recur->byyearday || occs->len == 0) - return occs; - - new_occs = g_array_new (FALSE, FALSE, sizeof (CalObjTime)); - - len = occs->len; - for (i = 0; i < len; i++) { - occ = &g_array_index (occs, CalObjTime, i); - yearday = cal_obj_time_day_of_year (occ); - if (recur_data->yeardays[yearday]) { - g_array_append_vals (new_occs, occ, 1); - } else { - days_in_year = g_date_is_leap_year (occ->year) - ? 366 : 365; - if (recur_data->neg_yeardays[days_in_year + 1 - - yearday]) - g_array_append_vals (new_occs, occ, 1); - } - } - - g_array_free (occs, TRUE); - - return new_occs; -} - - - -static GArray* -cal_obj_bymonthday_expand (RecurData *recur_data, - GArray *occs) -{ - GArray *new_occs; - CalObjTime *occ, month_start_cotime, month_end_cotime, cotime; - GList *elem; - gint len, i, dayno; - - /* If BYMONTHDAY has not been specified, or the array is empty, just - return the array. */ - if (!recur_data->recur->bymonthday || occs->len == 0) - return occs; - - new_occs = g_array_new (FALSE, FALSE, sizeof (CalObjTime)); - - len = occs->len; - for (i = 0; i < len; i++) { - occ = &g_array_index (occs, CalObjTime, i); - - /* Find the day that would correspond to day 1. */ - month_start_cotime = *occ; - month_start_cotime.day = 1; - - /* Find the day that would correspond to day 1 of the next - month, which we use for -ve day numbers. */ - month_end_cotime = *occ; - month_end_cotime.month++; - month_end_cotime.day = 1; - - /* Now iterate over the day numbers in bymonthday, generating a - new occurrence for each one. */ - elem = recur_data->recur->bymonthday; - while (elem) { - dayno = GPOINTER_TO_INT (elem->data); - if (dayno > 0) { - cotime = month_start_cotime; - cal_obj_time_add_days (&cotime, dayno - 1); - } else { - cotime = month_end_cotime; - cal_obj_time_add_days (&cotime, dayno); - } - - /* Skip occurrences if they fall outside the month. */ - if (cotime.month == occ->month) - g_array_append_val (new_occs, cotime); - elem = elem->next; - } - } - - g_array_free (occs, TRUE); - - return new_occs; -} - - -static GArray* -cal_obj_bymonthday_filter (RecurData *recur_data, - GArray *occs) -{ - GArray *new_occs; - CalObjTime *occ; - gint len, i, days_in_month; - - /* If BYMONTHDAY has not been specified, or the array is empty, just - return the array. */ - if (!recur_data->recur->bymonthday || occs->len == 0) - return occs; - - new_occs = g_array_new (FALSE, FALSE, sizeof (CalObjTime)); - - len = occs->len; - for (i = 0; i < len; i++) { - occ = &g_array_index (occs, CalObjTime, i); - if (recur_data->monthdays[occ->day]) { - g_array_append_vals (new_occs, occ, 1); - } else { - days_in_month = time_days_in_month (occ->year, - occ->month); - if (recur_data->neg_monthdays[days_in_month + 1 - - occ->day]) - g_array_append_vals (new_occs, occ, 1); - } - } - - g_array_free (occs, TRUE); - - return new_occs; -} - - - -static GArray* -cal_obj_byday_expand_yearly (RecurData *recur_data, - GArray *occs) -{ - GArray *new_occs; - CalObjTime *occ; - GList *elem; - gint len, i, weekday, week_num; - gint first_weekday, last_weekday, offset; - guint16 year; - - /* If BYDAY has not been specified, or the array is empty, just - return the array. */ - if (!recur_data->recur->byday || occs->len == 0) - return occs; - - new_occs = g_array_new (FALSE, FALSE, sizeof (CalObjTime)); - - len = occs->len; - for (i = 0; i < len; i++) { - occ = &g_array_index (occs, CalObjTime, i); - - elem = recur_data->recur->byday; - while (elem) { - weekday = GPOINTER_TO_INT (elem->data); - elem = elem->next; - week_num = GPOINTER_TO_INT (elem->data); - elem = elem->next; - - year = occ->year; - if (week_num == 0) { - /* Expand to every Mon/Tue/etc. in the year. */ - occ->month = 0; - occ->day = 1; - first_weekday = cal_obj_time_weekday (occ); - offset = (weekday + 7 - first_weekday) % 7; - cal_obj_time_add_days (occ, offset); - - while (occ->year == year) { - g_array_append_vals (new_occs, occ, 1); - cal_obj_time_add_days (occ, 7); - } - - } else if (week_num > 0) { - /* Add the nth Mon/Tue/etc. in the year. */ - occ->month = 0; - occ->day = 1; - first_weekday = cal_obj_time_weekday (occ); - offset = (weekday + 7 - first_weekday) % 7; - offset += (week_num - 1) * 7; - cal_obj_time_add_days (occ, offset); - if (occ->year == year) - g_array_append_vals (new_occs, occ, 1); - - } else { - /* Add the -nth Mon/Tue/etc. in the year. */ - occ->month = 11; - occ->day = 31; - last_weekday = cal_obj_time_weekday (occ); - offset = (last_weekday + 7 - weekday) % 7; - offset += (week_num - 1) * 7; - cal_obj_time_add_days (occ, -offset); - if (occ->year == year) - g_array_append_vals (new_occs, occ, 1); - } - - /* Reset the year, as we may have gone past the end. */ - occ->year = year; - } - } - - g_array_free (occs, TRUE); - - return new_occs; -} - - -static GArray* -cal_obj_byday_expand_monthly (RecurData *recur_data, - GArray *occs) -{ - GArray *new_occs; - CalObjTime *occ; - GList *elem; - gint len, i, weekday, week_num; - gint first_weekday, last_weekday, offset; - guint16 year; - guint8 month; - - /* If BYDAY has not been specified, or the array is empty, just - return the array. */ - if (!recur_data->recur->byday || occs->len == 0) - return occs; - - new_occs = g_array_new (FALSE, FALSE, sizeof (CalObjTime)); - - len = occs->len; - for (i = 0; i < len; i++) { - occ = &g_array_index (occs, CalObjTime, i); - - elem = recur_data->recur->byday; - while (elem) { - weekday = GPOINTER_TO_INT (elem->data); - elem = elem->next; - week_num = GPOINTER_TO_INT (elem->data); - elem = elem->next; - - year = occ->year; - month = occ->month; - if (week_num == 0) { - /* Expand to every Mon/Tue/etc. in the month.*/ - occ->day = 1; - first_weekday = cal_obj_time_weekday (occ); - offset = (weekday + 7 - first_weekday) % 7; - cal_obj_time_add_days (occ, offset); - - while (occ->year == year - && occ->month == month) { - g_array_append_vals (new_occs, occ, 1); - cal_obj_time_add_days (occ, 7); - } - - } else if (week_num > 0) { - /* Add the nth Mon/Tue/etc. in the month. */ - occ->day = 1; - first_weekday = cal_obj_time_weekday (occ); - offset = (weekday + 7 - first_weekday) % 7; - offset += (week_num - 1) * 7; - cal_obj_time_add_days (occ, offset); - if (occ->year == year && occ->month == month) - g_array_append_vals (new_occs, occ, 1); - - } else { - /* Add the -nth Mon/Tue/etc. in the month. */ - occ->day = time_days_in_month (occ->year, - occ->month); - last_weekday = cal_obj_time_weekday (occ); - - /* This calculates the number of days to step - backwards from the last day of the month - to the weekday we want. */ - offset = (last_weekday + 7 - weekday) % 7; - - /* This adds on the weeks. */ - offset += (-week_num - 1) * 7; - - cal_obj_time_add_days (occ, -offset); - if (occ->year == year && occ->month == month) - g_array_append_vals (new_occs, occ, 1); - } - - /* Reset the year & month, as we may have gone past - the end. */ - occ->year = year; - occ->month = month; - } - } - - g_array_free (occs, TRUE); - - return new_occs; -} - - -/* Note: occs must not contain invalid dates, e.g. 31st September. */ -static GArray* -cal_obj_byday_expand_weekly (RecurData *recur_data, - GArray *occs) -{ - GArray *new_occs; - CalObjTime *occ; - GList *elem; - gint len, i, weekday, week_num; - gint weekday_offset, new_weekday_offset; - - /* If BYDAY has not been specified, or the array is empty, just - return the array. */ - if (!recur_data->recur->byday || occs->len == 0) - return occs; - - new_occs = g_array_new (FALSE, FALSE, sizeof (CalObjTime)); - - len = occs->len; - for (i = 0; i < len; i++) { - occ = &g_array_index (occs, CalObjTime, i); - - elem = recur_data->recur->byday; - while (elem) { - weekday = GPOINTER_TO_INT (elem->data); - elem = elem->next; - - /* FIXME: Currently we just ignore this, but maybe we - should skip all elements where week_num != 0. - The spec isn't clear about this. */ - week_num = GPOINTER_TO_INT (elem->data); - elem = elem->next; - - weekday_offset = cal_obj_time_weekday_offset (occ, recur_data->recur); - new_weekday_offset = (weekday + 7 - recur_data->recur->week_start_day) % 7; - cal_obj_time_add_days (occ, new_weekday_offset - weekday_offset); - g_array_append_vals (new_occs, occ, 1); - } - } - - g_array_free (occs, TRUE); - - return new_occs; -} - - -/* Note: occs must not contain invalid dates, e.g. 31st September. */ -static GArray* -cal_obj_byday_filter (RecurData *recur_data, - GArray *occs) -{ - GArray *new_occs; - CalObjTime *occ; - gint len, i, weekday; - - /* If BYDAY has not been specified, or the array is empty, just - return the array. */ - if (!recur_data->recur->byday || occs->len == 0) - return occs; - - new_occs = g_array_new (FALSE, FALSE, sizeof (CalObjTime)); - - len = occs->len; - for (i = 0; i < len; i++) { - occ = &g_array_index (occs, CalObjTime, i); - weekday = cal_obj_time_weekday (occ); - - /* See if the weekday on its own is set. */ - if (recur_data->weekdays[weekday]) - g_array_append_vals (new_occs, occ, 1); - } - - g_array_free (occs, TRUE); - - return new_occs; -} - - - -/* If the BYHOUR rule is specified it expands each occurrence in occs, by - using each of the hours in the byhour list. */ -static GArray* -cal_obj_byhour_expand (RecurData *recur_data, - GArray *occs) -{ - GArray *new_occs; - CalObjTime *occ; - GList *elem; - gint len, i; - - /* If BYHOUR has not been specified, or the array is empty, just - return the array. */ - if (!recur_data->recur->byhour || occs->len == 0) - return occs; - - new_occs = g_array_new (FALSE, FALSE, sizeof (CalObjTime)); - - len = occs->len; - for (i = 0; i < len; i++) { - occ = &g_array_index (occs, CalObjTime, i); - - elem = recur_data->recur->byhour; - while (elem) { - occ->hour = GPOINTER_TO_INT (elem->data); - g_array_append_vals (new_occs, occ, 1); - elem = elem->next; - } - } - - g_array_free (occs, TRUE); - - return new_occs; -} - - -/* If the BYHOUR rule is specified it filters out all occurrences in occs - which do not match one of the hours in the byhour list. */ -static GArray* -cal_obj_byhour_filter (RecurData *recur_data, - GArray *occs) -{ - GArray *new_occs; - CalObjTime *occ; - gint len, i; - - /* If BYHOUR has not been specified, or the array is empty, just - return the array. */ - if (!recur_data->recur->byhour || occs->len == 0) - return occs; - - new_occs = g_array_new (FALSE, FALSE, sizeof (CalObjTime)); - - len = occs->len; - for (i = 0; i < len; i++) { - occ = &g_array_index (occs, CalObjTime, i); - if (recur_data->hours[occ->hour]) - g_array_append_vals (new_occs, occ, 1); - } - - g_array_free (occs, TRUE); - - return new_occs; -} - - - -/* If the BYMINUTE rule is specified it expands each occurrence in occs, by - using each of the minutes in the byminute list. */ -static GArray* -cal_obj_byminute_expand (RecurData *recur_data, - GArray *occs) -{ - GArray *new_occs; - CalObjTime *occ; - GList *elem; - gint len, i; - - /* If BYMINUTE has not been specified, or the array is empty, just - return the array. */ - if (!recur_data->recur->byminute || occs->len == 0) - return occs; - - new_occs = g_array_new (FALSE, FALSE, sizeof (CalObjTime)); - - len = occs->len; - for (i = 0; i < len; i++) { - occ = &g_array_index (occs, CalObjTime, i); - - elem = recur_data->recur->byminute; - while (elem) { - occ->minute = GPOINTER_TO_INT (elem->data); - g_array_append_vals (new_occs, occ, 1); - elem = elem->next; - } - } - - g_array_free (occs, TRUE); - - return new_occs; -} - - -/* If the BYMINUTE rule is specified it filters out all occurrences in occs - which do not match one of the minutes in the byminute list. */ -static GArray* -cal_obj_byminute_filter (RecurData *recur_data, - GArray *occs) -{ - GArray *new_occs; - CalObjTime *occ; - gint len, i; - - /* If BYMINUTE has not been specified, or the array is empty, just - return the array. */ - if (!recur_data->recur->byminute || occs->len == 0) - return occs; - - new_occs = g_array_new (FALSE, FALSE, sizeof (CalObjTime)); - - len = occs->len; - for (i = 0; i < len; i++) { - occ = &g_array_index (occs, CalObjTime, i); - if (recur_data->minutes[occ->minute]) - g_array_append_vals (new_occs, occ, 1); - } - - g_array_free (occs, TRUE); - - return new_occs; -} - - - -/* If the BYSECOND rule is specified it expands each occurrence in occs, by - using each of the seconds in the bysecond list. */ -static GArray* -cal_obj_bysecond_expand (RecurData *recur_data, - GArray *occs) -{ - GArray *new_occs; - CalObjTime *occ; - GList *elem; - gint len, i; - - /* If BYSECOND has not been specified, or the array is empty, just - return the array. */ - if (!recur_data->recur->bysecond || occs->len == 0) - return occs; - - new_occs = g_array_new (FALSE, FALSE, sizeof (CalObjTime)); - - len = occs->len; - for (i = 0; i < len; i++) { - occ = &g_array_index (occs, CalObjTime, i); - - elem = recur_data->recur->bysecond; - while (elem) { - occ->second = GPOINTER_TO_INT (elem->data); - g_array_append_vals (new_occs, occ, 1); - elem = elem->next; - } - } - - g_array_free (occs, TRUE); - - return new_occs; -} - - -/* If the BYSECOND rule is specified it filters out all occurrences in occs - which do not match one of the seconds in the bysecond list. */ -static GArray* -cal_obj_bysecond_filter (RecurData *recur_data, - GArray *occs) -{ - GArray *new_occs; - CalObjTime *occ; - gint len, i; - - /* If BYSECOND has not been specified, or the array is empty, just - return the array. */ - if (!recur_data->recur->bysecond || occs->len == 0) - return occs; - - new_occs = g_array_new (FALSE, FALSE, sizeof (CalObjTime)); - - len = occs->len; - for (i = 0; i < len; i++) { - occ = &g_array_index (occs, CalObjTime, i); - if (recur_data->seconds[occ->second]) - g_array_append_vals (new_occs, occ, 1); - } - - g_array_free (occs, TRUE); - - return new_occs; -} - - - - - -/* Adds a positive or negative number of months to the given CalObjTime, - updating the year appropriately so we end up with a valid month. - Note that the day may be invalid, e.g. 30th Feb. */ -static void -cal_obj_time_add_months (CalObjTime *cotime, - gint months) -{ - guint month, years; - - /* We use a guint to avoid overflow on the guint8. */ - month = cotime->month + months; - cotime->month = month % 12; - if (month > 0) { - cotime->year += month / 12; - } else { - years = month / 12; - if (cotime->month != 0) { - cotime->month += 12; - years -= 1; - } - cotime->year += years; - } -} - - -/* Adds a positive or negative number of days to the given CalObjTime, - updating the month and year appropriately so we end up with a valid day. */ -static void -cal_obj_time_add_days (CalObjTime *cotime, - gint days) -{ - gint day, days_in_month; - - /* We use a guint to avoid overflow on the guint8. */ - day = cotime->day; - day += days; - - if (days >= 0) { - for (;;) { - days_in_month = time_days_in_month (cotime->year, - cotime->month); - if (day <= days_in_month) - break; - - cotime->month++; - if (cotime->month >= 12) { - cotime->year++; - cotime->month = 0; - } - - day -= days_in_month; - } - - cotime->day = (guint8) day; - } else { - while (day <= 0) { - if (cotime->month == 0) { - cotime->year--; - cotime->month = 11; - } else { - cotime->month--; - } - - days_in_month = time_days_in_month (cotime->year, - cotime->month); - day += days_in_month; - } - - cotime->day = (guint8) day; - } -} - - -/* Adds a positive or negative number of hours to the given CalObjTime, - updating the day, month & year appropriately so we end up with a valid - time. */ -static void -cal_obj_time_add_hours (CalObjTime *cotime, - gint hours) -{ - gint hour, days; - - /* We use a gint to avoid overflow on the guint8. */ - hour = cotime->hour + hours; - cotime->hour = hour % 24; - if (hour >= 0) { - if (hour >= 24) - cal_obj_time_add_days (cotime, hour / 24); - } else { - days = hour / 24; - if (cotime->hour != 0) { - cotime->hour += 24; - days -= 1; - } - cal_obj_time_add_days (cotime, days); - } -} - - -/* Adds a positive or negative number of minutes to the given CalObjTime, - updating the rest of the CalObjTime appropriately. */ -static void -cal_obj_time_add_minutes (CalObjTime *cotime, - gint minutes) -{ - gint minute, hours; - - /* We use a gint to avoid overflow on the guint8. */ - minute = cotime->minute + minutes; - cotime->minute = minute % 60; - if (minute >= 0) { - if (minute >= 60) - cal_obj_time_add_hours (cotime, minute / 60); - } else { - hours = minute / 60; - if (cotime->minute != 0) { - cotime->minute += 60; - hours -= 1; - } - cal_obj_time_add_hours (cotime, hours); - } -} - - -/* Adds a positive or negative number of seconds to the given CalObjTime, - updating the rest of the CalObjTime appropriately. */ -static void -cal_obj_time_add_seconds (CalObjTime *cotime, - gint seconds) -{ - gint second, minutes; - - /* We use a gint to avoid overflow on the guint8. */ - second = cotime->second + seconds; - cotime->second = second % 60; - if (second >= 0) { - if (second >= 60) - cal_obj_time_add_minutes (cotime, second / 60); - } else { - minutes = second / 60; - if (cotime->second != 0) { - cotime->second += 60; - minutes -= 1; - } - cal_obj_time_add_minutes (cotime, minutes); - } -} - - -/* Compares 2 CalObjTimes. Returns -1 if the cotime1 is before cotime2, 0 if - they are the same, or 1 if cotime1 is after cotime2. The comparison type - specifies which parts of the times we are interested in, e.g. if CALOBJ_DAY - is used we only want to know if the days are different. */ -static gint -cal_obj_time_compare (CalObjTime *cotime1, - CalObjTime *cotime2, - CalObjTimeComparison type) -{ - if (cotime1->year < cotime2->year) - return -1; - if (cotime1->year > cotime2->year) - return 1; - - if (type == CALOBJ_YEAR) - return 0; - - if (cotime1->month < cotime2->month) - return -1; - if (cotime1->month > cotime2->month) - return 1; - - if (type == CALOBJ_MONTH) - return 0; - - if (cotime1->day < cotime2->day) - return -1; - if (cotime1->day > cotime2->day) - return 1; - - if (type == CALOBJ_DAY) - return 0; - - if (cotime1->hour < cotime2->hour) - return -1; - if (cotime1->hour > cotime2->hour) - return 1; - - if (type == CALOBJ_HOUR) - return 0; - - if (cotime1->minute < cotime2->minute) - return -1; - if (cotime1->minute > cotime2->minute) - return 1; - - if (type == CALOBJ_MINUTE) - return 0; - - if (cotime1->second < cotime2->second) - return -1; - if (cotime1->second > cotime2->second) - return 1; - - return 0; -} - - -/* This is the same as the above function, but without the comparison type. - It is used for qsort(). */ -static gint -cal_obj_time_compare_func (const void *arg1, - const void *arg2) -{ - CalObjTime *cotime1, *cotime2; - gint retval; - - cotime1 = (CalObjTime*) arg1; - cotime2 = (CalObjTime*) arg2; - - if (cotime1->year < cotime2->year) - retval = -1; - else if (cotime1->year > cotime2->year) - retval = 1; - - else if (cotime1->month < cotime2->month) - retval = -1; - else if (cotime1->month > cotime2->month) - retval = 1; - - else if (cotime1->day < cotime2->day) - retval = -1; - else if (cotime1->day > cotime2->day) - retval = 1; - - else if (cotime1->hour < cotime2->hour) - retval = -1; - else if (cotime1->hour > cotime2->hour) - retval = 1; - - else if (cotime1->minute < cotime2->minute) - retval = -1; - else if (cotime1->minute > cotime2->minute) - retval = 1; - - else if (cotime1->second < cotime2->second) - retval = -1; - else if (cotime1->second > cotime2->second) - retval = 1; - - else - retval = 0; - -#if 0 - g_print ("%s - ", cal_obj_time_to_string (cotime1)); - g_print ("%s : %i\n", cal_obj_time_to_string (cotime2), retval); -#endif - - return retval; -} - - -static gint -cal_obj_date_only_compare_func (const void *arg1, - const void *arg2) -{ - CalObjTime *cotime1, *cotime2; - - cotime1 = (CalObjTime*) arg1; - cotime2 = (CalObjTime*) arg2; - - if (cotime1->year < cotime2->year) - return -1; - if (cotime1->year > cotime2->year) - return 1; - - if (cotime1->month < cotime2->month) - return -1; - if (cotime1->month > cotime2->month) - return 1; - - if (cotime1->day < cotime2->day) - return -1; - if (cotime1->day > cotime2->day) - return 1; - - return 0; -} - - -/* Returns the weekday of the given CalObjTime, from 0 (Mon) - 6 (Sun). */ -static gint -cal_obj_time_weekday (CalObjTime *cotime) -{ - GDate date; - gint weekday; - - g_date_clear (&date, 1); - g_date_set_dmy (&date, cotime->day, cotime->month + 1, cotime->year); - - /* This results in a value of 0 (Monday) - 6 (Sunday). */ - weekday = g_date_get_weekday (&date) - 1; - - return weekday; -} - - -/* Returns the weekday of the given CalObjTime, from 0 - 6. The week start - day is Monday by default, but can be set in the recurrence rule. */ -static gint -cal_obj_time_weekday_offset (CalObjTime *cotime, - CalRecurrence *recur) -{ - GDate date; - gint weekday, offset; - - g_date_clear (&date, 1); - g_date_set_dmy (&date, cotime->day, cotime->month + 1, cotime->year); - - /* This results in a value of 0 (Monday) - 6 (Sunday). */ - weekday = g_date_get_weekday (&date) - 1; - - /* This calculates the offset of our day from the start of the week. - We just add on a week (to avoid any possible negative values) and - then subtract the specified week start day, then convert it into a - value from 0-6. */ - offset = (weekday + 7 - recur->week_start_day) % 7; - - return offset; -} - - -/* Returns the day of the year of the given CalObjTime, from 1 - 366. */ -static gint -cal_obj_time_day_of_year (CalObjTime *cotime) -{ - GDate date; - - g_date_clear (&date, 1); - g_date_set_dmy (&date, cotime->day, cotime->month + 1, cotime->year); - - return g_date_get_day_of_year (&date); -} - - -/* Finds the first week in the given CalObjTime's year, using the same weekday - as the event start day (i.e. from the RecurData). - The first week of the year is the first week starting from the specified - week start day that has 4 days in the new year. It may be in the previous - year. */ -static void -cal_obj_time_find_first_week (CalObjTime *cotime, - RecurData *recur_data) -{ - GDate date; - gint weekday, week_start_day, first_full_week_start_offset, offset; - - /* Find out the weekday of the 1st of the year, 0 (Mon) - 6 (Sun). */ - g_date_clear (&date, 1); - g_date_set_dmy (&date, 1, 1, cotime->year); - weekday = g_date_get_weekday (&date) - 1; - - /* Calculate the first day of the year that starts a new week, i.e. the - first week_start_day after weekday, using 0 = 1st Jan. - e.g. if the 1st Jan is a Tuesday (1) and week_start_day is a - Monday (0), the result will be (0 + 7 - 1) % 7 = 6 (7th Jan). */ - week_start_day = recur_data->recur->week_start_day; - first_full_week_start_offset = (week_start_day + 7 - weekday) % 7; - - /* Now see if we have to move backwards 1 week, i.e. if the week - starts on or after Jan 5th (since the previous week has 4 days in - this year and so will be the first week of the year). */ - if (first_full_week_start_offset >= 4) - first_full_week_start_offset -= 7; - - /* Now add the days to get to the event's weekday. */ - offset = first_full_week_start_offset + recur_data->weekday_offset; - - /* Now move the cotime to the appropriate day. */ - cotime->month = 0; - cotime->day = 1; - cal_obj_time_add_days (cotime, offset); -} - - -static void -cal_object_time_from_time (CalObjTime *cotime, - time_t t, - icaltimezone *zone) -{ - struct icaltimetype tt; - - tt = icaltime_from_timet_with_zone (t, FALSE, zone); - - cotime->year = tt.year; - cotime->month = tt.month - 1; - cotime->day = tt.day; - cotime->hour = tt.hour; - cotime->minute = tt.minute; - cotime->second = tt.second; - cotime->flags = FALSE; -} - - -/* Debugging function to convert a CalObjTime to a string. It uses a static - buffer so beware. */ -#ifdef CAL_OBJ_DEBUG -static char* -cal_obj_time_to_string (CalObjTime *cotime) -{ - static char buffer[20]; - char *weekdays[] = { "Mon", "Tue", "Wed", "Thu", "Fri", "Sat", "Sun", - " " }; - gint weekday; - - weekday = cal_obj_time_weekday (cotime); - - sprintf (buffer, "%s %02i/%02i/%04i %02i:%02i:%02i", - weekdays[weekday], - cotime->day, cotime->month + 1, cotime->year, - cotime->hour, cotime->minute, cotime->second); - return buffer; -} -#endif - - -/* This recalculates the end dates for recurrence & exception rules which use - the COUNT property. If refresh is TRUE it will recalculate all enddates - for rules which use COUNT. If refresh is FALSE, it will only calculate - the enddate if it hasn't already been set. It returns TRUE if the component - was changed, i.e. if the component should be saved at some point. - We store the enddate in the "X-EVOLUTION-ENDDATE" parameter of the RRULE - or EXRULE. */ -static gboolean -cal_recur_ensure_end_dates (CalComponent *comp, - gboolean refresh, - CalRecurResolveTimezoneFn tz_cb, - gpointer tz_cb_data) -{ - GSList *rrules, *exrules, *elem; - gboolean changed = FALSE; - - /* Do the RRULEs. */ - cal_component_get_rrule_property_list (comp, &rrules); - for (elem = rrules; elem; elem = elem->next) { - changed |= cal_recur_ensure_rule_end_date (comp, elem->data, - FALSE, refresh, - tz_cb, tz_cb_data); - } - - /* Do the EXRULEs. */ - cal_component_get_exrule_property_list (comp, &exrules); - for (elem = exrules; elem; elem = elem->next) { - changed |= cal_recur_ensure_rule_end_date (comp, elem->data, - TRUE, refresh, - tz_cb, tz_cb_data); - } - - return changed; -} - - -typedef struct _CalRecurEnsureEndDateData CalRecurEnsureEndDateData; -struct _CalRecurEnsureEndDateData { - gint count; - gint instances; - time_t end_date; -}; - - -static gboolean -cal_recur_ensure_rule_end_date (CalComponent *comp, - icalproperty *prop, - gboolean exception, - gboolean refresh, - CalRecurResolveTimezoneFn tz_cb, - gpointer tz_cb_data) -{ - struct icalrecurrencetype rule; - CalRecurEnsureEndDateData cb_data; - - if (exception) - rule = icalproperty_get_exrule (prop); - else - rule = icalproperty_get_rrule (prop); - - /* If the rule doesn't use COUNT just return. */ - if (rule.count == 0) - return FALSE; - - /* If refresh is FALSE, we check if the enddate is already set, and - if it is we just return. */ - if (!refresh) { - if (cal_recur_get_rule_end_date (prop, NULL) != -1) - return FALSE; - } - - /* Calculate the end date. Note that we initialize end_date to 0, so - if the RULE doesn't generate COUNT instances we save a time_t of 0. - Also note that we use the UTC timezone as the default timezone. - In get_end_date() if the DTSTART is a DATE or floating time, we will - convert the ENDDATE to the current timezone. */ - cb_data.count = rule.count; - cb_data.instances = 0; - cb_data.end_date = 0; - cal_recur_generate_instances_of_rule (comp, prop, -1, -1, - cal_recur_ensure_rule_end_date_cb, - &cb_data, tz_cb, tz_cb_data, - icaltimezone_get_utc_timezone ()); - - /* Store the end date in the "X-EVOLUTION-ENDDATE" parameter of the - rule. */ - cal_recur_set_rule_end_date (prop, cb_data.end_date); - - return TRUE; -} - - -static gboolean -cal_recur_ensure_rule_end_date_cb (CalComponent *comp, - time_t instance_start, - time_t instance_end, - gpointer data) -{ - CalRecurEnsureEndDateData *cb_data; - - cb_data = (CalRecurEnsureEndDateData*) data; - - cb_data->instances++; - - if (cb_data->instances == cb_data->count) { - cb_data->end_date = instance_start; - return FALSE; - } - - return TRUE; -} - - -/* If default_timezone is set, the saved ENDDATE parameter is assumed to be - in that timezone. This is used when the DTSTART is a DATE or floating - value, since the RRULE end date will change depending on the timezone that - it is evaluated in. */ -static time_t -cal_recur_get_rule_end_date (icalproperty *prop, - icaltimezone *default_timezone) -{ - icalparameter *param; - const char *xname, *xvalue; - icalvalue *value; - struct icaltimetype icaltime; - icaltimezone *zone; - - param = icalproperty_get_first_parameter (prop, ICAL_X_PARAMETER); - while (param) { - xname = icalparameter_get_xname (param); - if (xname && !strcmp (xname, EVOLUTION_END_DATE_PARAMETER)) { - xvalue = icalparameter_get_x (param); - value = icalvalue_new_from_string (ICAL_DATETIME_VALUE, - xvalue); - if (value) { - icaltime = icalvalue_get_datetime (value); - icalvalue_free (value); - - zone = default_timezone ? default_timezone : - icaltimezone_get_utc_timezone (); - return icaltime_as_timet_with_zone (icaltime, - zone); - } - } - - param = icalproperty_get_next_parameter (prop, - ICAL_X_PARAMETER); - } - - return -1; -} - - -static void -cal_recur_set_rule_end_date (icalproperty *prop, - time_t end_date) -{ - icalparameter *param; - icalvalue *value; - icaltimezone *utc_zone; - struct icaltimetype icaltime; - const char *end_date_string, *xname; - - /* We save the value as a UTC DATE-TIME. */ - utc_zone = icaltimezone_get_utc_timezone (); - icaltime = icaltime_from_timet_with_zone (end_date, FALSE, utc_zone); - value = icalvalue_new_datetime (icaltime); - end_date_string = icalvalue_as_ical_string (value); - icalvalue_free (value); - - /* If we already have an X-EVOLUTION-ENDDATE parameter, set the value - to the new date-time. */ - param = icalproperty_get_first_parameter (prop, ICAL_X_PARAMETER); - while (param) { - xname = icalparameter_get_xname (param); - if (xname && !strcmp (xname, EVOLUTION_END_DATE_PARAMETER)) { - icalparameter_set_x (param, end_date_string); - return; - } - param = icalproperty_get_next_parameter (prop, ICAL_X_PARAMETER); - } - - /* Create a new X-EVOLUTION-ENDDATE and add it to the property. */ - param = icalparameter_new_x (end_date_string); - icalparameter_set_xname (param, EVOLUTION_END_DATE_PARAMETER); - icalproperty_add_parameter (prop, param); -} - -const char *cal_recur_nth[31] = { - N_("1st"), - N_("2nd"), - N_("3rd"), - N_("4th"), - N_("5th"), - N_("6th"), - N_("7th"), - N_("8th"), - N_("9th"), - N_("10th"), - N_("11th"), - N_("12th"), - N_("13th"), - N_("14th"), - N_("15th"), - N_("16th"), - N_("17th"), - N_("18th"), - N_("19th"), - N_("20th"), - N_("21st"), - N_("22nd"), - N_("23rd"), - N_("24th"), - N_("25th"), - N_("26th"), - N_("27th"), - N_("28th"), - N_("29th"), - N_("30th"), - N_("31st") -}; - diff --git a/calendar/cal-util/cal-recur.h b/calendar/cal-util/cal-recur.h deleted file mode 100644 index 294107d618..0000000000 --- a/calendar/cal-util/cal-recur.h +++ /dev/null @@ -1,71 +0,0 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */ -/* - * Evolution calendar recurrence rule functions - * - * Copyright (C) 2000 Ximian, Inc. - * - * Author: Damon Chaplin <damon@ximian.com> - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of version 2 of the GNU General Public - * License as published by the Free Software Foundation. - * - * 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA. - */ - -#ifndef CAL_RECUR_H -#define CAL_RECUR_H - -#include <glib.h> -#include <cal-util/cal-component.h> - -G_BEGIN_DECLS - -typedef gboolean (* CalRecurInstanceFn) (CalComponent *comp, - time_t instance_start, - time_t instance_end, - gpointer data); - -typedef icaltimezone* (* CalRecurResolveTimezoneFn) (const char *tzid, - gpointer data); - -/* - * Calls the given callback function for each occurrence of the event that - * intersects the range between the given start and end times (the end time is - * not included). Note that the occurrences may start before the given start - * time. - * - * If the callback routine returns FALSE the occurrence generation stops. - * - * Both start and end can be -1, in which case we start at the events first - * instance and continue until it ends, or forever if it has no enddate. - * - * The tz_cb is used to resolve references to timezones. It is passed a TZID - * and should return the icaltimezone* corresponding to that TZID. We need to - * do this as we access timezones in different ways on the client & server. - * - * The default_timezone argument is used for DTSTART or DTEND properties that - * are DATE values or do not have a TZID (i.e. floating times). - */ -void cal_recur_generate_instances (CalComponent *comp, - time_t start, - time_t end, - CalRecurInstanceFn cb, - gpointer cb_data, - CalRecurResolveTimezoneFn tz_cb, - gpointer tz_cb_data, - icaltimezone *default_timezone); - -/* Localized nth-day-of-month strings. (Use with _() ) */ -extern const char *cal_recur_nth[31]; - -G_END_DECLS - -#endif diff --git a/calendar/cal-util/cal-util-marshal.list b/calendar/cal-util/cal-util-marshal.list deleted file mode 100644 index 77509b1c50..0000000000 --- a/calendar/cal-util/cal-util-marshal.list +++ /dev/null @@ -1,9 +0,0 @@ -NONE:INT,INT -NONE:ENUM,ENUM -NONE:ENUM,STRING -NONE:STRING,BOOL,INT,INT -NONE:STRING,STRING -NONE:STRING,STRING,STRING -NONE:POINTER,ENUM -NONE:POINTER,STRING -NONE:POINTER,POINTER diff --git a/calendar/cal-util/cal-util.c b/calendar/cal-util/cal-util.c deleted file mode 100644 index f6ad0d4007..0000000000 --- a/calendar/cal-util/cal-util.c +++ /dev/null @@ -1,926 +0,0 @@ -/* Evolution calendar utilities and types - * - * Copyright (C) 2000 Ximian, Inc. - * Copyright (C) 2000 Ximian, Inc. - * - * Author: Federico Mena-Quintero <federico@ximian.com> - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of version 2 of the GNU General Public - * License as published by the Free Software Foundation. - * - * 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA. - */ - -#include <config.h> -#include <stdlib.h> -#include <string.h> -#include <glib.h> -#include <glib/gstrfuncs.h> -#include <libgnome/gnome-i18n.h> -#include <libgnome/gnome-util.h> -#include "cal-util.h" - - - -/** - * cal_obj_instance_list_free: - * @list: List of #CalObjInstance structures. - * - * Frees a list of #CalObjInstance structures. - **/ -void -cal_obj_instance_list_free (GList *list) -{ - CalObjInstance *i; - GList *l; - - for (l = list; l; l = l->next) { - i = l->data; - - g_assert (i != NULL); - g_assert (i->uid != NULL); - - g_free (i->uid); - g_free (i); - } - - g_list_free (list); -} - -/** - * cal_obj_uid_list_free: - * @list: List of strings with unique identifiers. - * - * Frees a list of unique identifiers for calendar objects. - **/ -void -cal_obj_uid_list_free (GList *list) -{ - GList *l; - - for (l = list; l; l = l->next) { - char *uid; - - uid = l->data; - - g_assert (uid != NULL); - g_free (uid); - } - - g_list_free (list); -} - -icalcomponent * -cal_util_new_top_level (void) -{ - icalcomponent *icalcomp; - icalproperty *prop; - - icalcomp = icalcomponent_new (ICAL_VCALENDAR_COMPONENT); - - /* RFC 2445, section 4.7.1 */ - prop = icalproperty_new_calscale ("GREGORIAN"); - icalcomponent_add_property (icalcomp, prop); - - /* RFC 2445, section 4.7.3 */ - prop = icalproperty_new_prodid ("-//Ximian//NONSGML Evolution Calendar//EN"); - icalcomponent_add_property (icalcomp, prop); - - /* RFC 2445, section 4.7.4. This is the iCalendar spec version, *NOT* - * the product version! Do not change this! - */ - prop = icalproperty_new_version ("2.0"); - icalcomponent_add_property (icalcomp, prop); - - return icalcomp; -} - -static char * -get_line_fn (char *buf, size_t size, void *file) -{ - return fgets (buf, size, file); -} - -icalcomponent * -cal_util_parse_ics_file (const char *filename) -{ - icalparser *parser; - icalcomponent *icalcomp; - FILE *file; - - file = fopen (filename, "r"); - if (!file) - return NULL; - - parser = icalparser_new (); - icalparser_set_gen_data (parser, file); - - icalcomp = icalparser_parse (parser, get_line_fn); - icalparser_free (parser); - fclose (file); - - return icalcomp; -} - -/* Computes the range of time in which recurrences should be generated for a - * component in order to compute alarm trigger times. - */ -static void -compute_alarm_range (CalComponent *comp, GList *alarm_uids, time_t start, time_t end, - time_t *alarm_start, time_t *alarm_end) -{ - GList *l; - time_t repeat_time; - - *alarm_start = start; - *alarm_end = end; - - repeat_time = 0; - - for (l = alarm_uids; l; l = l->next) { - const char *auid; - CalComponentAlarm *alarm; - CalAlarmTrigger trigger; - struct icaldurationtype *dur; - time_t dur_time; - CalAlarmRepeat repeat; - - auid = l->data; - alarm = cal_component_get_alarm (comp, auid); - g_assert (alarm != NULL); - - cal_component_alarm_get_trigger (alarm, &trigger); - cal_component_alarm_get_repeat (alarm, &repeat); - cal_component_alarm_free (alarm); - - switch (trigger.type) { - case CAL_ALARM_TRIGGER_NONE: - case CAL_ALARM_TRIGGER_ABSOLUTE: - break; - - case CAL_ALARM_TRIGGER_RELATIVE_START: - case CAL_ALARM_TRIGGER_RELATIVE_END: - dur = &trigger.u.rel_duration; - dur_time = icaldurationtype_as_int (*dur); - - if (repeat.repetitions != 0) { - int rdur; - - rdur = repeat.repetitions * icaldurationtype_as_int (repeat.duration); - repeat_time = MAX (repeat_time, rdur); - } - - if (dur->is_neg) - /* If the duration is negative then dur_time - * will be negative as well; that is why we - * subtract to expand the range. - */ - *alarm_end = MAX (*alarm_end, end - dur_time); - else - *alarm_start = MIN (*alarm_start, start - dur_time); - - break; - - default: - g_assert_not_reached (); - } - } - - *alarm_start -= repeat_time; - - g_assert (*alarm_start <= *alarm_end); -} - -/* Closure data to generate alarm occurrences */ -struct alarm_occurrence_data { - /* These are the info we have */ - GList *alarm_uids; - time_t start; - time_t end; - CalAlarmAction *omit; - - /* This is what we compute */ - GSList *triggers; - int n_triggers; -}; - -static void -add_trigger (struct alarm_occurrence_data *aod, const char *auid, time_t trigger, - time_t occur_start, time_t occur_end) -{ - CalAlarmInstance *instance; - - instance = g_new (CalAlarmInstance, 1); - instance->auid = auid; - instance->trigger = trigger; - instance->occur_start = occur_start; - instance->occur_end = occur_end; - - aod->triggers = g_slist_prepend (aod->triggers, instance); - aod->n_triggers++; -} - -/* Callback used from cal_recur_generate_instances(); generates triggers for all - * of a component's RELATIVE alarms. - */ -static gboolean -add_alarm_occurrences_cb (CalComponent *comp, time_t start, time_t end, gpointer data) -{ - struct alarm_occurrence_data *aod; - GList *l; - - aod = data; - - for (l = aod->alarm_uids; l; l = l->next) { - const char *auid; - CalComponentAlarm *alarm; - CalAlarmAction action; - CalAlarmTrigger trigger; - CalAlarmRepeat repeat; - struct icaldurationtype *dur; - time_t dur_time; - time_t occur_time, trigger_time; - int i; - - auid = l->data; - alarm = cal_component_get_alarm (comp, auid); - g_assert (alarm != NULL); - - cal_component_alarm_get_action (alarm, &action); - cal_component_alarm_get_trigger (alarm, &trigger); - cal_component_alarm_get_repeat (alarm, &repeat); - cal_component_alarm_free (alarm); - - for (i = 0; aod->omit[i] != -1; i++) { - if (aod->omit[i] == action) - break; - } - if (aod->omit[i] != -1) - continue; - - if (trigger.type != CAL_ALARM_TRIGGER_RELATIVE_START - && trigger.type != CAL_ALARM_TRIGGER_RELATIVE_END) - continue; - - dur = &trigger.u.rel_duration; - dur_time = icaldurationtype_as_int (*dur); - - if (trigger.type == CAL_ALARM_TRIGGER_RELATIVE_START) - occur_time = start; - else - occur_time = end; - - /* If dur->is_neg is true then dur_time will already be - * negative. So we do not need to test for dur->is_neg here; we - * can simply add the dur_time value to the occur_time and get - * the correct result. - */ - - trigger_time = occur_time + dur_time; - - /* Add repeating alarms */ - - if (repeat.repetitions != 0) { - int i; - time_t repeat_time; - - repeat_time = icaldurationtype_as_int (repeat.duration); - - for (i = 0; i < repeat.repetitions; i++) { - time_t t; - - t = trigger_time + (i + 1) * repeat_time; - - if (t >= aod->start && t < aod->end) - add_trigger (aod, auid, t, start, end); - } - } - - /* Add the trigger itself */ - - if (trigger_time >= aod->start && trigger_time < aod->end) - add_trigger (aod, auid, trigger_time, start, end); - } - - return TRUE; -} - -/* Generates the absolute triggers for a component */ -static void -generate_absolute_triggers (CalComponent *comp, struct alarm_occurrence_data *aod, - CalRecurResolveTimezoneFn resolve_tzid, - gpointer user_data, - icaltimezone *default_timezone) -{ - GList *l; - CalComponentDateTime dt_start, dt_end; - - cal_component_get_dtstart (comp, &dt_start); - cal_component_get_dtend (comp, &dt_end); - - for (l = aod->alarm_uids; l; l = l->next) { - const char *auid; - CalComponentAlarm *alarm; - CalAlarmAction action; - CalAlarmRepeat repeat; - CalAlarmTrigger trigger; - time_t abs_time; - time_t occur_start, occur_end; - icaltimezone *zone; - int i; - - auid = l->data; - alarm = cal_component_get_alarm (comp, auid); - g_assert (alarm != NULL); - - cal_component_alarm_get_action (alarm, &action); - cal_component_alarm_get_trigger (alarm, &trigger); - cal_component_alarm_get_repeat (alarm, &repeat); - cal_component_alarm_free (alarm); - - for (i = 0; aod->omit[i] != -1; i++) { - if (aod->omit[i] == action) - break; - } - if (aod->omit[i] != -1) - continue; - - if (trigger.type != CAL_ALARM_TRIGGER_ABSOLUTE) - continue; - - /* Absolute triggers are always in UTC; see RFC 2445 section 4.8.6.3 */ - zone = icaltimezone_get_utc_timezone (); - - abs_time = icaltime_as_timet_with_zone (trigger.u.abs_time, zone); - - /* No particular occurrence, so just use the times from the component */ - - if (dt_start.value) { - if (dt_start.tzid && !dt_start.value->is_date) - zone = (* resolve_tzid) (dt_start.tzid, user_data); - else - zone = default_timezone; - - occur_start = icaltime_as_timet_with_zone (*dt_start.value, zone); - } else - occur_start = -1; - - if (dt_end.value) { - if (dt_end.tzid && !dt_end.value->is_date) - zone = (* resolve_tzid) (dt_end.tzid, user_data); - else - zone = default_timezone; - - occur_end = icaltime_as_timet_with_zone (*dt_end.value, zone); - } else - occur_end = -1; - - /* Add repeating alarms */ - - if (repeat.repetitions != 0) { - int i; - time_t repeat_time; - - repeat_time = icaldurationtype_as_int (repeat.duration); - - for (i = 0; i < repeat.repetitions; i++) { - time_t t; - - t = abs_time + (i + 1) * repeat_time; - - if (t >= aod->start && t < aod->end) - add_trigger (aod, auid, t, occur_start, occur_end); - } - } - - /* Add the trigger itself */ - - if (abs_time >= aod->start && abs_time < aod->end) - add_trigger (aod, auid, abs_time, occur_start, occur_end); - } - - cal_component_free_datetime (&dt_start); - cal_component_free_datetime (&dt_end); -} - -/* Compares two alarm instances; called from g_slist_sort() */ -static gint -compare_alarm_instance (gconstpointer a, gconstpointer b) -{ - const CalAlarmInstance *aia, *aib; - - aia = a; - aib = b; - - if (aia->trigger < aib->trigger) - return -1; - else if (aia->trigger > aib->trigger) - return 1; - else - return 0; -} - -/** - * cal_util_generate_alarms_for_comp - * @comp: the CalComponent to generate alarms from - * @start: start time - * @end: end time - * @resolve_tzid: callback for resolving timezones - * @user_data: data to be passed to the resolve_tzid callback - * @default_timezone: the timezone used to resolve DATE and floating DATE-TIME - * values. - * - * Generates alarm instances for a calendar component. Returns the instances - * structure, or NULL if no alarm instances occurred in the specified time - * range. - */ -CalComponentAlarms * -cal_util_generate_alarms_for_comp (CalComponent *comp, - time_t start, - time_t end, - CalAlarmAction *omit, - CalRecurResolveTimezoneFn resolve_tzid, - gpointer user_data, - icaltimezone *default_timezone) -{ - GList *alarm_uids; - time_t alarm_start, alarm_end; - struct alarm_occurrence_data aod; - CalComponentAlarms *alarms; - - if (!cal_component_has_alarms (comp)) - return NULL; - - alarm_uids = cal_component_get_alarm_uids (comp); - compute_alarm_range (comp, alarm_uids, start, end, &alarm_start, &alarm_end); - - aod.alarm_uids = alarm_uids; - aod.start = start; - aod.end = end; - aod.omit = omit; - aod.triggers = NULL; - aod.n_triggers = 0; - - cal_recur_generate_instances (comp, alarm_start, alarm_end, - add_alarm_occurrences_cb, &aod, - resolve_tzid, user_data, - default_timezone); - - /* We add the ABSOLUTE triggers separately */ - generate_absolute_triggers (comp, &aod, resolve_tzid, user_data, default_timezone); - - if (aod.n_triggers == 0) - return NULL; - - /* Create the component alarm instances structure */ - - alarms = g_new (CalComponentAlarms, 1); - alarms->comp = comp; - g_object_ref (G_OBJECT (alarms->comp)); - alarms->alarms = g_slist_sort (aod.triggers, compare_alarm_instance); - - return alarms; -} - -/** - * cal_util_generate_alarms_for_list - * @comps: list of CalComponent's - * @start: start time - * @end: end time - * @comp_alarms: list to be returned - * @resolve_tzid: callback for resolving timezones - * @user_data: data to be passed to the resolve_tzid callback - * @default_timezone: the timezone used to resolve DATE and floating DATE-TIME - * values. - * - * Iterates through all the components in the comps list and generates alarm - * instances for them; putting them in the comp_alarms list. - * - * Returns: the number of elements it added to that list. - */ -int -cal_util_generate_alarms_for_list (GList *comps, - time_t start, - time_t end, - CalAlarmAction *omit, - GSList **comp_alarms, - CalRecurResolveTimezoneFn resolve_tzid, - gpointer user_data, - icaltimezone *default_timezone) -{ - GList *l; - int n; - - n = 0; - - for (l = comps; l; l = l->next) { - CalComponent *comp; - CalComponentAlarms *alarms; - - comp = CAL_COMPONENT (l->data); - alarms = cal_util_generate_alarms_for_comp (comp, start, end, omit, resolve_tzid, user_data, default_timezone); - - if (alarms) { - *comp_alarms = g_slist_prepend (*comp_alarms, alarms); - n++; - } - } - - return n; -} - - -/* Converts an iCalendar PRIORITY value to a translated string. Any unknown - priority value (i.e. not 0-9) will be returned as "" (undefined). */ -char * -cal_util_priority_to_string (int priority) -{ - char *retval; - - if (priority <= 0) - retval = ""; - else if (priority <= 4) - retval = _("High"); - else if (priority == 5) - retval = _("Normal"); - else if (priority <= 9) - retval = _("Low"); - else - retval = ""; - - return retval; -} - - -/* Converts a translated priority string to an iCalendar priority value. - Returns -1 if the priority string is not valid. */ -int -cal_util_priority_from_string (const char *string) -{ - int priority; - - /* An empty string is the same as 'None'. */ - if (!string || !string[0] || !g_strcasecmp (string, _("Undefined"))) - priority = 0; - else if (!g_strcasecmp (string, _("High"))) - priority = 3; - else if (!g_strcasecmp (string, _("Normal"))) - priority = 5; - else if (!g_strcasecmp (string, _("Low"))) - priority = 7; - else - priority = -1; - - return priority; -} - -char * -cal_util_expand_uri (char *uri, gboolean tasks) -{ - return g_strdup (uri); -} - -/* callback for icalcomponent_foreach_tzid */ -typedef struct { - icalcomponent *vcal_comp; - icalcomponent *icalcomp; -} ForeachTzidData; - -static void -add_timezone_cb (icalparameter *param, void *data) -{ - icaltimezone *tz; - const char *tzid; - icalcomponent *vtz_comp; - ForeachTzidData *f_data = (ForeachTzidData *) data; - - tzid = icalparameter_get_tzid (param); - if (!tzid) - return; - - tz = icalcomponent_get_timezone (f_data->vcal_comp, tzid); - if (tz) - return; - - tz = icalcomponent_get_timezone (f_data->icalcomp, tzid); - if (!tz) { - tz = icaltimezone_get_builtin_timezone_from_tzid (tzid); - if (!tz) - return; - } - - vtz_comp = icaltimezone_get_component (tz); - if (!vtz_comp) - return; - - icalcomponent_add_component (f_data->vcal_comp, - icalcomponent_new_clone (vtz_comp)); -} - -/* Adds VTIMEZONE components to a VCALENDAR for all tzid's - * in the given CalComponent. */ -void -cal_util_add_timezones_from_component (icalcomponent *vcal_comp, - icalcomponent *icalcomp) -{ - ForeachTzidData f_data; - - g_return_if_fail (vcal_comp != NULL); - g_return_if_fail (icalcomp != NULL);; - - f_data.vcal_comp = vcal_comp; - f_data.icalcomp = icalcomp; - icalcomponent_foreach_tzid (icalcomp, add_timezone_cb, &f_data); -} - -gboolean -cal_util_component_is_instance (icalcomponent *icalcomp) -{ - icalproperty *prop; - - g_return_val_if_fail (icalcomp != NULL, FALSE); - - prop = icalcomponent_get_first_property (icalcomp, ICAL_RECURRENCEID_PROPERTY); - return prop ? TRUE : FALSE; -} - -gboolean -cal_util_component_has_alarms (icalcomponent *icalcomp) -{ - icalcomponent *alarm; - - g_return_val_if_fail (icalcomp != NULL, FALSE); - - alarm = icalcomponent_get_first_component (icalcomp, ICAL_VALARM_COMPONENT); - return alarm ? TRUE : FALSE; -} - -gboolean -cal_util_component_has_organizer (icalcomponent *icalcomp) -{ - icalproperty *prop; - - g_return_val_if_fail (icalcomp != NULL, FALSE); - - prop = icalcomponent_get_first_property (icalcomp, ICAL_ORGANIZER_PROPERTY); - return prop ? TRUE : FALSE; -} - -gboolean -cal_util_component_has_recurrences (icalcomponent *icalcomp) -{ - g_return_val_if_fail (icalcomp != NULL, FALSE); - - return cal_util_component_has_rdates (icalcomp) || cal_util_component_has_rrules (icalcomp); -} - -gboolean -cal_util_component_has_rdates (icalcomponent *icalcomp) -{ - icalproperty *prop; - - g_return_val_if_fail (icalcomp != NULL, FALSE); - - prop = icalcomponent_get_first_property (icalcomp, ICAL_RDATE_PROPERTY); - return prop ? TRUE : FALSE; -} - -gboolean -cal_util_component_has_rrules (icalcomponent *icalcomp) -{ - icalproperty *prop; - - g_return_val_if_fail (icalcomp != NULL, FALSE); - - prop = icalcomponent_get_first_property (icalcomp, ICAL_RRULE_PROPERTY); - return prop ? TRUE : FALSE; -} - -gboolean -cal_util_event_dates_match (icalcomponent *icalcomp1, icalcomponent *icalcomp2) -{ - struct icaltimetype c1_dtstart, c1_dtend, c2_dtstart, c2_dtend; - - g_return_val_if_fail (icalcomp1 != NULL, FALSE); - g_return_val_if_fail (icalcomp2 != NULL, FALSE); - - c1_dtstart = icalcomponent_get_dtstart (icalcomp1); - c1_dtend = icalcomponent_get_dtend (icalcomp1); - c2_dtstart = icalcomponent_get_dtstart (icalcomp2); - c2_dtend = icalcomponent_get_dtend (icalcomp2); - - /* if either value is NULL, they must both be NULL to match */ - if (icaltime_is_valid_time (c1_dtstart) || icaltime_is_valid_time (c2_dtstart)) { - if (!(icaltime_is_valid_time (c1_dtstart) && icaltime_is_valid_time (c2_dtstart))) - return FALSE; - } else { - if (icaltime_compare (c1_dtstart, c2_dtstart)) - return FALSE; - } - - if (icaltime_is_valid_time (c1_dtend) || icaltime_is_valid_time (c2_dtend)) { - if (!(icaltime_is_valid_time (c1_dtend) && icaltime_is_valid_time (c2_dtend))) - return FALSE; - } else { - if (icaltime_compare (c1_dtend, c2_dtend)) - return FALSE; - } - - - - /* now match the timezones */ - if (!(!c1_dtstart.zone && !c2_dtstart.zone) || - (c1_dtstart.zone && c2_dtstart.zone && - !strcmp (icaltimezone_get_tzid ((icaltimezone *) c1_dtstart.zone), - icaltimezone_get_tzid ((icaltimezone *) c2_dtstart.zone)))) - return FALSE; - - if (!(!c1_dtend.zone && !c2_dtend.zone) || - (c1_dtend.zone && c2_dtend.zone && - !strcmp (icaltimezone_get_tzid ((icaltimezone *) c1_dtend.zone), - icaltimezone_get_tzid ((icaltimezone *) c2_dtend.zone)))) - return FALSE; - - return TRUE; -} - -/* Individual instances management */ - -struct instance_data { - time_t start; - gboolean found; -}; - -static void -check_instance (icalcomponent *comp, struct icaltime_span span, void *data) -{ - struct instance_data *instance = data; - - if (span.start == instance->start) - instance->found = TRUE; -} - -/** - * cal_util_construct_instance: - * @icalcomp: a recurring #icalcomponent - * @rid: the RECURRENCE-ID to construct a component for - * - * This checks that @rid indicates a valid recurrence of @icalcomp, and - * if so, generates a copy of @comp containing a RECURRENCE-ID of @rid. - * - * Return value: the instance, or %NULL - **/ -icalcomponent * -cal_util_construct_instance (icalcomponent *icalcomp, - struct icaltimetype rid) -{ - struct instance_data instance; - struct icaltimetype start, end; - - g_return_val_if_fail (icalcomp != NULL, NULL); - - /* Make sure this is really recurring */ - if (!icalcomponent_get_first_property (icalcomp, ICAL_RRULE_PROPERTY) && - !icalcomponent_get_first_property (icalcomp, ICAL_RDATE_PROPERTY)) - return NULL; - - /* Make sure the specified instance really exists */ - /* FIXME: does the libical recurrence code work correctly now? */ - start = icaltime_convert_to_zone (rid, icaltimezone_get_utc_timezone ()); - end = start; - icaltime_adjust (&end, 0, 0, 0, 1); - - instance.start = icaltime_as_timet (start); - instance.found = FALSE; - icalcomponent_foreach_recurrence (icalcomp, start, end, - check_instance, &instance); - if (!instance.found) - return NULL; - - /* Make the instance */ - icalcomp = icalcomponent_new_clone (icalcomp); - icalcomponent_set_recurrenceid (icalcomp, rid); - - return icalcomp; -} - -static inline gboolean -time_matches_rid (struct icaltimetype itt, struct icaltimetype rid, CalObjModType mod) -{ - int compare; - - compare = icaltime_compare (itt, rid); - if (compare == 0) - return TRUE; - else if (compare < 0 && (mod & CALOBJ_MOD_THISANDPRIOR)) - return TRUE; - else if (compare > 0 && (mod & CALOBJ_MOD_THISANDFUTURE)) - return TRUE; - - return FALSE; -} - -/** - * cal_util_remove_instances: - * @icalcomp: a (recurring) #icalcomponent - * @rid: the base RECURRENCE-ID to remove - * @mod: how to interpret @rid - * - * Removes one or more instances from @comp according to @rid and @mod. - * - * FIXME: should probably have a return value indicating whether or not - * @icalcomp still has any instances - **/ -void -cal_util_remove_instances (icalcomponent *icalcomp, - struct icaltimetype rid, - CalObjModType mod) -{ - icalproperty *prop; - struct icaltimetype itt, recur; - struct icalrecurrencetype rule; - icalrecur_iterator *iter; - struct instance_data instance; - - g_return_if_fail (icalcomp != NULL); - g_return_if_fail (mod != CALOBJ_MOD_ALL); - - /* First remove RDATEs and EXDATEs in the indicated range. */ - for (prop = icalcomponent_get_first_property (icalcomp, ICAL_RDATE_PROPERTY); - prop; - prop = icalcomponent_get_next_property (icalcomp, ICAL_RDATE_PROPERTY)) { - struct icaldatetimeperiodtype period; - - period = icalproperty_get_rdate (prop); - if (time_matches_rid (period.time, rid, mod)) - icalcomponent_remove_property (icalcomp, prop); - } - for (prop = icalcomponent_get_first_property (icalcomp, ICAL_EXDATE_PROPERTY); - prop; - prop = icalcomponent_get_next_property (icalcomp, ICAL_EXDATE_PROPERTY)) { - itt = icalproperty_get_exdate (prop); - if (time_matches_rid (itt, rid, mod)) - icalcomponent_remove_property (icalcomp, prop); - } - - /* If we're only removing one instance, just add an EXDATE. */ - if (mod == CALOBJ_MOD_THIS) { - prop = icalproperty_new_exdate (rid); - icalcomponent_add_property (icalcomp, prop); - return; - } - - /* Otherwise, iterate through RRULEs */ - /* FIXME: this may generate duplicate EXRULEs */ - for (prop = icalcomponent_get_first_property (icalcomp, ICAL_RRULE_PROPERTY); - prop; - prop = icalcomponent_get_next_property (icalcomp, ICAL_RRULE_PROPERTY)) { - rule = icalproperty_get_rrule (prop); - - iter = icalrecur_iterator_new (rule, rid); - recur = icalrecur_iterator_next (iter); - - if (mod & CALOBJ_MOD_THISANDFUTURE) { - /* If there is a recurrence on or after rid, - * use the UNTIL parameter to truncate the rule - * at rid. - */ - if (!icaltime_is_null_time (recur)) { - rule.count = 0; - rule.until = rid; - icaltime_adjust (&rule.until, 0, 0, 0, -1); - icalproperty_set_rrule (prop, rule); - } - } else { - /* (If recur == rid, skip to the next occurrence) */ - if (icaltime_compare (recur, rid) == 0) - recur = icalrecur_iterator_next (iter); - - /* If there is a recurrence after rid, add - * an EXRULE to block instances up to rid. - * Otherwise, just remove the RRULE. - */ - if (!icaltime_is_null_time (recur)) { - rule.count = 0; - /* iCalendar says we should just use rid - * here, but Outlook/Exchange handle - * UNTIL incorrectly. - */ - rule.until = icaltime_add (rid, icalcomponent_get_duration (icalcomp)); - prop = icalproperty_new_exrule (rule); - icalcomponent_add_property (icalcomp, prop); - } else - icalcomponent_remove_property (icalcomp, prop); - } - - icalrecur_iterator_free (iter); - } -} diff --git a/calendar/cal-util/cal-util.h b/calendar/cal-util/cal-util.h deleted file mode 100644 index 0946380b36..0000000000 --- a/calendar/cal-util/cal-util.h +++ /dev/null @@ -1,137 +0,0 @@ -/* Evolution calendar utilities and types - * - * Copyright (C) 2000 Ximian, Inc. - * Copyright (C) 2000 Ximian, Inc. - * - * Author: Federico Mena-Quintero <federico@ximian.com> - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of version 2 of the GNU General Public - * License as published by the Free Software Foundation. - * - * 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA. - */ - -#ifndef CAL_UTIL_H -#define CAL_UTIL_H - -#include <libical/ical.h> -#include <time.h> -#include <glib.h> -#include <cal-util/cal-component.h> -#include <cal-util/cal-recur.h> - -G_BEGIN_DECLS - - - -/* Instance of a calendar object. This can be an actual occurrence, a - * recurrence, or an alarm trigger of a `real' calendar object. - */ -typedef struct { - char *uid; /* UID of the object */ - time_t start; /* Start time of instance */ - time_t end; /* End time of instance */ -} CalObjInstance; - -void cal_obj_instance_list_free (GList *list); - -/* Used for multiple UID queries */ -typedef enum { - CALOBJ_TYPE_EVENT = 1 << 0, - CALOBJ_TYPE_TODO = 1 << 1, - CALOBJ_TYPE_JOURNAL = 1 << 2, - CALOBJ_TYPE_ANY = 0x07 -} CalObjType; - -/* Used for modifying objects */ -typedef enum { - CALOBJ_MOD_THIS = 1 << 0, - CALOBJ_MOD_THISANDPRIOR = 1 << 1, - CALOBJ_MOD_THISANDFUTURE = 1 << 2, - CALOBJ_MOD_ALL = 0x07 -} CalObjModType; - -/* Used for mode stuff */ -typedef enum { - CAL_MODE_INVALID = -1, - CAL_MODE_LOCAL = 1 << 0, - CAL_MODE_REMOTE = 1 << 1, - CAL_MODE_ANY = 0x07 -} CalMode; - -void cal_obj_uid_list_free (GList *list); - -icalcomponent *cal_util_new_top_level (void); - -icalcomponent *cal_util_parse_ics_file (const char *filename); - -CalComponentAlarms *cal_util_generate_alarms_for_comp (CalComponent *comp, - time_t start, - time_t end, - CalAlarmAction *omit, - CalRecurResolveTimezoneFn resolve_tzid, - gpointer user_data, - icaltimezone *default_timezone); -int cal_util_generate_alarms_for_list (GList *comps, - time_t start, - time_t end, - CalAlarmAction *omit, - GSList **comp_alarms, - CalRecurResolveTimezoneFn resolve_tzid, - gpointer user_data, - icaltimezone *default_timezone); - -icaltimezone *cal_util_resolve_tzid (const char *tzid, gpointer data); - -char *cal_util_priority_to_string (int priority); -int cal_util_priority_from_string (const char *string); - -char *cal_util_expand_uri (char *uri, gboolean tasks); - -void cal_util_add_timezones_from_component (icalcomponent *vcal_comp, - icalcomponent *icalcomp); - -gboolean cal_util_component_is_instance (icalcomponent *icalcomp); -gboolean cal_util_component_has_alarms (icalcomponent *icalcomp); -gboolean cal_util_component_has_organizer (icalcomponent *icalcomp); -gboolean cal_util_component_has_recurrences (icalcomponent *icalcomp); -gboolean cal_util_component_has_rdates (icalcomponent *icalcomp); -gboolean cal_util_component_has_rrules (icalcomponent *icalcomp); - -gboolean cal_util_event_dates_match (icalcomponent *icalcomp1, icalcomponent *icalcomp2); - -/* The static capabilities to be supported by backends */ -#define CAL_STATIC_CAPABILITY_NO_ALARM_REPEAT "no-alarm-repeat" -#define CAL_STATIC_CAPABILITY_NO_AUDIO_ALARMS "no-audio-alarms" -#define CAL_STATIC_CAPABILITY_NO_DISPLAY_ALARMS "no-display-alarms" -#define CAL_STATIC_CAPABILITY_NO_EMAIL_ALARMS "no-email-alarms" -#define CAL_STATIC_CAPABILITY_NO_PROCEDURE_ALARMS "no-procedure-alarms" -#define CAL_STATIC_CAPABILITY_NO_TASK_ASSIGNMENT "no-task-assignment" -#define CAL_STATIC_CAPABILITY_NO_THISANDFUTURE "no-thisandfuture" -#define CAL_STATIC_CAPABILITY_NO_THISANDPRIOR "no-thisandprior" -#define CAL_STATIC_CAPABILITY_NO_TRANSPARENCY "no-transparency" -#define CAL_STATIC_CAPABILITY_ONE_ALARM_ONLY "one-alarm-only" -#define CAL_STATIC_CAPABILITY_ORGANIZER_MUST_ATTEND "organizer-must-attend" -#define CAL_STATIC_CAPABILITY_ORGANIZER_NOT_EMAIL_ADDRESS "organizer-not-email-address" -#define CAL_STATIC_CAPABILITY_REMOVE_ALARMS "remove-alarms" -#define CAL_STATIC_CAPABILITY_SAVE_SCHEDULES "save-schedules" - -/* Recurrent events. Management for instances */ -icalcomponent *cal_util_construct_instance (icalcomponent *icalcomp, - struct icaltimetype rid); -void cal_util_remove_instances (icalcomponent *icalcomp, - struct icaltimetype rid, - CalObjModType mod); - -G_END_DECLS - -#endif - diff --git a/calendar/cal-util/test-recur.c b/calendar/cal-util/test-recur.c deleted file mode 100644 index 03f19b52bd..0000000000 --- a/calendar/cal-util/test-recur.c +++ /dev/null @@ -1,182 +0,0 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */ - -/* - * Author : - * Damon Chaplin <damon@ximian.com> - * - * Copyright 2000, Ximian, Inc. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of version 2 of the GNU General Public - * License as published by the Free Software Foundation. - * - * 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 - * USA - */ - -/* - * This tests the recurrence rule expansion functions. - * - * NOTE: currently it starts from the event start date and continues - * until all recurrence rules/dates end or we reach MAX_OCCURRENCES - * occurrences. So it does not test generating occurrences for a specific - * interval. A nice addition might be to do this automatically and compare - * the results from the complete set to ensure they match. - */ - -#include <config.h> -#include <stdio.h> -#include <stdlib.h> -#include <string.h> -#include <gtk/gtkmain.h> -#include <cal-util/cal-recur.h> -#include <cal-util/cal-util.h> - - -/* Since events can recur infinitely, we set a limit to the number of - occurrences we output. */ -#define MAX_OCCURRENCES 1000 - -static void usage (void); -static void generate_occurrences (icalcomponent *comp); -static gboolean occurrence_cb (CalComponent *comp, - time_t instance_start, - time_t instance_end, - gpointer data); - - -int -main (int argc, - char *argv[]) -{ - gchar *filename; - icalcomponent *icalcomp; - - gtk_init (&argc, &argv); - - if (argc != 2) - usage (); - - filename = argv[1]; - - icalcomp = cal_util_parse_ics_file (filename); - if (icalcomp) - generate_occurrences (icalcomp); - - return 0; -} - - -static void -usage (void) -{ - g_print ("Usage: test-recur <filename>\n"); - exit (1); -} - - -/* This resolves any TZIDs in the components. The VTIMEZONEs must be in the - file we are reading. */ -static icaltimezone* -resolve_tzid_cb (const char *tzid, - gpointer user_data) -{ - icalcomponent *vcalendar_comp = user_data; - - if (!tzid || !tzid[0]) - return NULL; - else if (!strcmp (tzid, "UTC")) - return icaltimezone_get_utc_timezone (); - - return icalcomponent_get_timezone (vcalendar_comp, tzid); -} - - -static void -generate_occurrences (icalcomponent *icalcomp) -{ - icalcompiter iter; - icaltimezone *default_timezone; - - /* This is the timezone we will use for DATE and floating values. */ - default_timezone = icaltimezone_get_utc_timezone (); - - for (iter = icalcomponent_begin_component (icalcomp, ICAL_ANY_COMPONENT); - icalcompiter_deref (&iter) != NULL; - icalcompiter_next (&iter)) { - icalcomponent *tmp_icalcomp; - CalComponent *comp; - icalcomponent_kind kind; - gint occurrences; - - tmp_icalcomp = icalcompiter_deref (&iter); - kind = icalcomponent_isa (tmp_icalcomp); - - if (!(kind == ICAL_VEVENT_COMPONENT - || kind == ICAL_VTODO_COMPONENT - || kind == ICAL_VJOURNAL_COMPONENT)) - continue; - - comp = cal_component_new (); - - if (!cal_component_set_icalcomponent (comp, tmp_icalcomp)) - continue; - - g_print ("#############################################################################\n"); - g_print ("%s\n\n", icalcomponent_as_ical_string (tmp_icalcomp)); - g_print ("Instances:\n"); - - occurrences = 0; - /* I use specific times when I am trying to pin down a bug seen - in one of the calendar views. */ -#if 0 - cal_recur_generate_instances (comp, 982022400, 982108800, - occurrence_cb, &occurrences, - resolve_tzid_cb, icalcomp, - default_timezone); -#else - cal_recur_generate_instances (comp, -1, -1, - occurrence_cb, &occurrences, - resolve_tzid_cb, icalcomp, - default_timezone); -#endif - - /* Print the component again so we can see the - X-EVOLUTION-ENDDATE parameter (only set if COUNT is used). - */ - g_print ("#############################################################################\n"); -#if 0 - g_print ("%s\n\n", icalcomponent_as_ical_string (tmp_icalcomp)); -#endif - } -} - - -static gboolean -occurrence_cb (CalComponent *comp, - time_t instance_start, - time_t instance_end, - gpointer data) -{ - char start[32], finish[32]; - gint *occurrences; - - occurrences = (gint*) data; - - strcpy (start, ctime (&instance_start)); - start[24] = '\0'; - strcpy (finish, ctime (&instance_end)); - finish[24] = '\0'; - - g_print ("%s - %s\n", start, finish); - - (*occurrences)++; - return (*occurrences == MAX_OCCURRENCES) ? FALSE : TRUE; -} diff --git a/calendar/cal-util/timeutil.c b/calendar/cal-util/timeutil.c deleted file mode 100644 index 32ba50c4ae..0000000000 --- a/calendar/cal-util/timeutil.c +++ /dev/null @@ -1,576 +0,0 @@ -/* Miscellaneous time-related utilities - * - * Copyright (C) 2000, 2001 Ximian, Inc. - * - * Authors: Federico Mena <federico@ximian.com> - * Miguel de Icaza <miguel@ximian.com> - * Damon Chaplin <damon@ximian.com> - */ - -#include <string.h> -#include <ctype.h> -#include <glib.h> -#include "timeutil.h" - - - -#define REFORMATION_DAY 639787 /* First day of the reformation, counted from 1 Jan 1 */ -#define MISSING_DAYS 11 /* They corrected out 11 days */ -#define THURSDAY 4 /* First day of reformation */ -#define SATURDAY 6 /* Offset value; 1 Jan 1 was a Saturday */ - - -/* Number of days in a month, using 0 (Jan) to 11 (Dec). For leap years, - add 1 to February (month 1). */ -static const int days_in_month[12] = { - 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31 -}; - - - -/************************************************************************** - * time_t manipulation functions. - * - * NOTE: these use the Unix timezone functions like mktime() and localtime() - * and so should not be used in Evolution. New Evolution code should use - * icaltimetype values rather than time_t values wherever possible. - **************************************************************************/ - -/* Adds a day onto the time, using local time. - Note that if clocks go forward due to daylight savings time, there are - some non-existent local times, so the hour may be changed to make it a - valid time. This also means that it may not be wise to keep calling - time_add_day() to step through a certain period - if the hour gets changed - to make it valid time, any further calls to time_add_day() will also return - this hour, which may not be what you want. */ -time_t -time_add_day (time_t time, int days) -{ - struct tm *tm; - - tm = localtime (&time); - tm->tm_mday += days; - tm->tm_isdst = -1; - - return mktime (tm); -} - -time_t -time_add_week (time_t time, int weeks) -{ - return time_add_day (time, weeks * 7); -} - -/* Returns the start of the day, according to the local time. */ -time_t -time_day_begin (time_t t) -{ - struct tm tm; - - tm = *localtime (&t); - tm.tm_hour = tm.tm_min = tm.tm_sec = 0; - tm.tm_isdst = -1; - - return mktime (&tm); -} - -/* Returns the end of the day, according to the local time. */ -time_t -time_day_end (time_t t) -{ - struct tm tm; - - tm = *localtime (&t); - tm.tm_hour = tm.tm_min = tm.tm_sec = 0; - tm.tm_mday++; - tm.tm_isdst = -1; - - return mktime (&tm); -} - - -/************************************************************************** - * time_t manipulation functions, using timezones in libical. - * - * NOTE: these are only here to make the transition to the timezone - * functions easier. New code should use icaltimetype values rather than - * time_t values wherever possible. - **************************************************************************/ - - -/* Adds or subtracts a number of days to/from the given time_t value, using - the given timezone. - NOTE: this function is only here to make the transition to the timezone - functions easier. New code should use icaltimetype values and - icaltime_adjust() to add or subtract days, hours, minutes & seconds. */ -time_t -time_add_day_with_zone (time_t time, int days, icaltimezone *zone) -{ - struct icaltimetype tt; - - /* Convert to an icaltimetype. */ - tt = icaltime_from_timet_with_zone (time, FALSE, zone); - - /* Add/subtract the number of days. */ - icaltime_adjust (&tt, days, 0, 0, 0); - - /* Convert back to a time_t. */ - return icaltime_as_timet_with_zone (tt, zone); -} - - -/* Adds or subtracts a number of weeks to/from the given time_t value, using - the given timezone. - NOTE: this function is only here to make the transition to the timezone - functions easier. New code should use icaltimetype values and - icaltime_adjust() to add or subtract days, hours, minutes & seconds. */ -time_t -time_add_week_with_zone (time_t time, int weeks, icaltimezone *zone) -{ - return time_add_day_with_zone (time, weeks * 7, zone); -} - - -/* Adds or subtracts a number of months to/from the given time_t value, using - the given timezone. - - If the day would be off the end of the month (e.g. adding 1 month to - 30th January, would lead to an invalid day, 30th February), it moves it - down to the last day in the month, e.g. 28th Feb (or 29th in a leap year.) - - NOTE: this function is only here to make the transition to the timezone - functions easier. New code should use icaltimetype values and - icaltime_adjust() to add or subtract days, hours, minutes & seconds. */ -time_t -time_add_month_with_zone (time_t time, int months, icaltimezone *zone) -{ - struct icaltimetype tt; - int day, days_in_month; - - /* Convert to an icaltimetype. */ - tt = icaltime_from_timet_with_zone (time, FALSE, zone); - - /* Add on the number of months. */ - tt.month += months; - - /* Save the day, and set it to 1, so we don't overflow into the next - month. */ - day = tt.day; - tt.day = 1; - - /* Normalize it, fixing any month overflow. */ - tt = icaltime_normalize (tt); - - /* If we go past the end of a month, set it to the last day. */ - days_in_month = time_days_in_month (tt.year, tt.month - 1); - if (day > days_in_month) - day = days_in_month; - - tt.day = day; - - /* Convert back to a time_t. */ - return icaltime_as_timet_with_zone (tt, zone); -} - - -/* Returns the start of the year containing the given time_t, using the given - timezone. - NOTE: this function is only here to make the transition to the timezone - functions easier. New code should use icaltimetype values and - icaltime_adjust() to add or subtract days, hours, minutes & seconds. */ -time_t -time_year_begin_with_zone (time_t time, icaltimezone *zone) -{ - struct icaltimetype tt; - - /* Convert to an icaltimetype. */ - tt = icaltime_from_timet_with_zone (time, FALSE, zone); - - /* Set it to the start of the year. */ - tt.month = 1; - tt.day = 1; - tt.hour = 0; - tt.minute = 0; - tt.second = 0; - - /* Convert back to a time_t. */ - return icaltime_as_timet_with_zone (tt, zone); -} - - -/* Returns the start of the month containing the given time_t, using the given - timezone. - NOTE: this function is only here to make the transition to the timezone - functions easier. New code should use icaltimetype values and - icaltime_adjust() to add or subtract days, hours, minutes & seconds. */ -time_t -time_month_begin_with_zone (time_t time, icaltimezone *zone) -{ - struct icaltimetype tt; - - /* Convert to an icaltimetype. */ - tt = icaltime_from_timet_with_zone (time, FALSE, zone); - - /* Set it to the start of the month. */ - tt.day = 1; - tt.hour = 0; - tt.minute = 0; - tt.second = 0; - - /* Convert back to a time_t. */ - return icaltime_as_timet_with_zone (tt, zone); -} - - -/* Returns the start of the week containing the given time_t, using the given - timezone. week_start_day should use the same values as mktime(), - i.e. 0 (Sun) to 6 (Sat). - NOTE: this function is only here to make the transition to the timezone - functions easier. New code should use icaltimetype values and - icaltime_adjust() to add or subtract days, hours, minutes & seconds. */ -time_t -time_week_begin_with_zone (time_t time, int week_start_day, icaltimezone *zone) -{ - struct icaltimetype tt; - int weekday, offset; - - /* Convert to an icaltimetype. */ - tt = icaltime_from_timet_with_zone (time, FALSE, zone); - - /* Get the weekday. */ - weekday = time_day_of_week (tt.day, tt.month - 1, tt.year); - - /* Calculate the current offset from the week start day. */ - offset = (weekday + 7 - week_start_day) % 7; - - /* Set it to the start of the month. */ - tt.day -= offset; - tt.hour = 0; - tt.minute = 0; - tt.second = 0; - - /* Normalize it, to fix any overflow. */ - tt = icaltime_normalize (tt); - - /* Convert back to a time_t. */ - return icaltime_as_timet_with_zone (tt, zone); -} - - -/* Returns the start of the day containing the given time_t, using the given - timezone. - NOTE: this function is only here to make the transition to the timezone - functions easier. New code should use icaltimetype values and - icaltime_adjust() to add or subtract days, hours, minutes & seconds. */ -time_t -time_day_begin_with_zone (time_t time, icaltimezone *zone) -{ - struct icaltimetype tt; - - /* Convert to an icaltimetype. */ - tt = icaltime_from_timet_with_zone (time, FALSE, zone); - - /* Set it to the start of the day. */ - tt.hour = 0; - tt.minute = 0; - tt.second = 0; - - /* Convert back to a time_t. */ - return icaltime_as_timet_with_zone (tt, zone); -} - - -/* Returns the end of the day containing the given time_t, using the given - timezone. (The end of the day is the start of the next day.) - NOTE: this function is only here to make the transition to the timezone - functions easier. New code should use icaltimetype values and - icaltime_adjust() to add or subtract days, hours, minutes & seconds. */ -time_t -time_day_end_with_zone (time_t time, icaltimezone *zone) -{ - struct icaltimetype tt; - - /* Convert to an icaltimetype. */ - tt = icaltime_from_timet_with_zone (time, FALSE, zone); - - /* Set it to the start of the next day. */ - tt.day++; - tt.hour = 0; - tt.minute = 0; - tt.second = 0; - - /* Normalize it, to fix any overflow. */ - tt = icaltime_normalize (tt); - - /* Convert back to a time_t. */ - return icaltime_as_timet_with_zone (tt, zone); -} - -/** - * time_to_gdate_with_zone: - * @date: Destination #GDate value. - * @time: A time value. - * @zone: Desired timezone for destination @date, or NULL if the UTC timezone - * is desired. - * - * Converts a time_t value to a #GDate structure using the specified timezone. - * This is analogous to g_date_set_time() but takes the timezone into account. - **/ -void -time_to_gdate_with_zone (GDate *date, time_t time, icaltimezone *zone) -{ - struct icaltimetype tt; - - g_return_if_fail (date != NULL); - g_return_if_fail (time != -1); - - tt = icaltime_from_timet_with_zone (time, FALSE, - zone ? zone : icaltimezone_get_utc_timezone ()); - - g_date_set_dmy (date, tt.day, tt.month, tt.year); -} - - -/************************************************************************** - * General time functions. - **************************************************************************/ - - -/* Returns the number of days in the month. Year is the normal year, e.g. 2001. - Month is 0 (Jan) to 11 (Dec). */ -int -time_days_in_month (int year, int month) -{ - int days; - - g_return_val_if_fail (year >= 1900, 0); - g_return_val_if_fail ((month >= 0) && (month < 12), 0); - - days = days_in_month[month]; - if (month == 1 && time_is_leap_year (year)) - days++; - - return days; -} - - -/* Returns the 1-based day number within the year of the specified date. - Year is the normal year, e.g. 2001. Month is 0 to 11. */ -int -time_day_of_year (int day, int month, int year) -{ - int i; - - for (i = 0; i < month; i++) { - day += days_in_month[i]; - - if (i == 1 && time_is_leap_year (year)) - day++; - } - - return day; -} - - -/* Returns the day of the week for the specified date, 0 (Sun) to 6 (Sat). - For the days that were removed on the Gregorian reformation, it returns - Thursday. Year is the normal year, e.g. 2001. Month is 0 to 11. */ -int -time_day_of_week (int day, int month, int year) -{ - int n; - - n = (year - 1) * 365 + time_leap_years_up_to (year - 1) - + time_day_of_year (day, month, year); - - if (n < REFORMATION_DAY) - return (n - 1 + SATURDAY) % 7; - - if (n >= (REFORMATION_DAY + MISSING_DAYS)) - return (n - 1 + SATURDAY - MISSING_DAYS) % 7; - - return THURSDAY; -} - - -/* Returns whether the specified year is a leap year. Year is the normal year, - e.g. 2001. */ -gboolean -time_is_leap_year (int year) -{ - if (year <= 1752) - return !(year % 4); - else - return (!(year % 4) && (year % 100)) || !(year % 400); -} - - -/* Returns the number of leap years since year 1 up to (but not including) the - specified year. Year is the normal year, e.g. 2001. */ -int -time_leap_years_up_to (int year) -{ - /* There is normally a leap year every 4 years, except at the turn of - centuries since 1700. But there is a leap year on centuries since 1700 - which are divisible by 400. */ - return (year / 4 - - ((year > 1700) ? (year / 100 - 17) : 0) - + ((year > 1600) ? ((year - 1600) / 400) : 0)); -} - - -/** - * isodate_from_time_t: - * @t: A time value. - * - * Creates an ISO 8601 UTC representation from a time value. - * - * Return value: String with the ISO 8601 representation of the UTC time. - **/ -char * -isodate_from_time_t (time_t t) -{ - gchar *ret; - - ret = g_malloc (17); /* 4+2+2+1+2+2+2+1 + 1 */ - strftime (ret, 17, "%Y%m%dT%H%M%SZ", gmtime (&t)); - - return ret; -} - -/** - * time_from_isodate: - * @str: Date/time value in ISO 8601 format. - * - * Converts an ISO 8601 UTC time string into a time_t value. - * - * Return value: Time_t corresponding to the specified ISO string. - * Note that we only allow UTC times at present. - **/ -time_t -time_from_isodate (const char *str) -{ - struct icaltimetype tt = icaltime_null_time (); - icaltimezone *utc_zone; - int len, i; - - g_return_val_if_fail (str != NULL, -1); - - /* yyyymmdd[Thhmmss[Z]] */ - - len = strlen (str); - - if (!(len == 8 || len == 15 || len == 16)) - return -1; - - for (i = 0; i < len; i++) - if (!((i != 8 && i != 15 && isdigit (str[i])) - || (i == 8 && str[i] == 'T') - || (i == 15 && str[i] == 'Z'))) - return -1; - -#define digit_at(x,y) (x[y] - '0') - - tt.year = digit_at (str, 0) * 1000 - + digit_at (str, 1) * 100 - + digit_at (str, 2) * 10 - + digit_at (str, 3); - - tt.month = digit_at (str, 4) * 10 - + digit_at (str, 5); - - tt.day = digit_at (str, 6) * 10 - + digit_at (str, 7); - - if (len > 8) { - tt.hour = digit_at (str, 9) * 10 - + digit_at (str, 10); - tt.minute = digit_at (str, 11) * 10 - + digit_at (str, 12); - tt.second = digit_at (str, 13) * 10 - + digit_at (str, 14); - } - - utc_zone = icaltimezone_get_utc_timezone (); - - return icaltime_as_timet_with_zone (tt, utc_zone); -} - -struct tm -icaltimetype_to_tm (struct icaltimetype *itt) -{ - struct tm tm; - - memset (&tm, 0, sizeof (struct tm)); - - if (!itt->is_date) { - tm.tm_sec = itt->second; - tm.tm_min = itt->minute; - tm.tm_hour = itt->hour; - } - - tm.tm_mday = itt->day; - tm.tm_mon = itt->month - 1; - tm.tm_year = itt->year - 1900; - tm.tm_wday = time_day_of_week (itt->day, itt->month - 1, itt->year); - tm.tm_isdst = -1; - - return tm; -} - -/** - * icaltimetype_to_tm_with_zone: - * @itt: A time value. - * @from_zone: Source timezone. - * @to_zone: Destination timezone. - * - * Converts a time value from one timezone to another, and returns a struct tm - * representation of the time. - * - * Return value: The converted time as a struct tm. All fields will be - * set properly except for tm.tm_yday. - **/ -struct tm -icaltimetype_to_tm_with_zone (struct icaltimetype *itt, - icaltimezone *from_zone, - icaltimezone *to_zone) -{ - struct tm tm; - struct icaltimetype itt_copy; - - memset (&tm, 0, sizeof (tm)); - tm.tm_isdst = -1; - - g_return_val_if_fail (itt != NULL, tm); - - itt_copy = *itt; - - icaltimezone_convert_time (&itt_copy, from_zone, to_zone); - tm = icaltimetype_to_tm (&itt_copy); - - return tm; -} - -struct icaltimetype -tm_to_icaltimetype (struct tm *tm, gboolean is_date) -{ - struct icaltimetype itt; - - memset (&itt, 0, sizeof (struct icaltimetype)); - - if (!is_date) { - itt.second = tm->tm_sec; - itt.minute = tm->tm_min; - itt.hour = tm->tm_hour; - } - - itt.day = tm->tm_mday; - itt.month = tm->tm_mon + 1; - itt.year = tm->tm_year+ 1900; - - itt.is_utc = 0; - itt.is_date = is_date; - - return itt; -} - diff --git a/calendar/cal-util/timeutil.h b/calendar/cal-util/timeutil.h deleted file mode 100644 index df5d2db91c..0000000000 --- a/calendar/cal-util/timeutil.h +++ /dev/null @@ -1,122 +0,0 @@ -/* Miscellaneous time-related utilities - * - * Copyright (C) 1998 The Free Software Foundation - * Copyright (C) 2000 Ximian, Inc. - * - * Authors: Federico Mena <federico@ximian.com> - * Miguel de Icaza <miguel@ximian.com> - * Damon Chaplin <damon@ximian.com> - */ - -#ifndef TIMEUTIL_H -#define TIMEUTIL_H - - -#include <time.h> -#include <libical/ical.h> -#include <glib.h> - - -/************************************************************************** - * General time functions. - **************************************************************************/ - -/* Returns the number of days in the month. Year is the normal year, e.g. 2001. - Month is 0 (Jan) to 11 (Dec). */ -int time_days_in_month (int year, int month); - -/* Returns the 1-based day number within the year of the specified date. - Year is the normal year, e.g. 2001. Month is 0 to 11. */ -int time_day_of_year (int day, int month, int year); - -/* Returns the day of the week for the specified date, 0 (Sun) to 6 (Sat). - For the days that were removed on the Gregorian reformation, it returns - Thursday. Year is the normal year, e.g. 2001. Month is 0 to 11. */ -int time_day_of_week (int day, int month, int year); - -/* Returns whether the specified year is a leap year. Year is the normal year, - e.g. 2001. */ -gboolean time_is_leap_year (int year); - -/* Returns the number of leap years since year 1 up to (but not including) the - specified year. Year is the normal year, e.g. 2001. */ -int time_leap_years_up_to (int year); - -/* Convert to or from an ISO 8601 representation of a time, in UTC, - e.g. "20010708T183000Z". */ -char *isodate_from_time_t (time_t t); -time_t time_from_isodate (const char *str); - - -/************************************************************************** - * time_t manipulation functions. - * - * NOTE: these use the Unix timezone functions like mktime() and localtime() - * and so should not be used in Evolution. New Evolution code should use - * icaltimetype values rather than time_t values wherever possible. - **************************************************************************/ - -/* Add or subtract a number of days, weeks or months. */ -time_t time_add_day (time_t time, int days); -time_t time_add_week (time_t time, int weeks); - -/* Returns the beginning or end of the day. */ -time_t time_day_begin (time_t t); -time_t time_day_end (time_t t); - - -/************************************************************************** - * time_t manipulation functions, using timezones in libical. - * - * NOTE: these are only here to make the transition to the timezone - * functions easier. New code should use icaltimetype values rather than - * time_t values wherever possible. - **************************************************************************/ - -/* Adds or subtracts a number of days to/from the given time_t value, using - the given timezone. */ -time_t time_add_day_with_zone (time_t time, int days, icaltimezone *zone); - -/* Adds or subtracts a number of weeks to/from the given time_t value, using - the given timezone. */ -time_t time_add_week_with_zone (time_t time, int weeks, icaltimezone *zone); - -/* Adds or subtracts a number of months to/from the given time_t value, using - the given timezone. */ -time_t time_add_month_with_zone (time_t time, int months, icaltimezone *zone); - -/* Returns the start of the year containing the given time_t, using the given - timezone. */ -time_t time_year_begin_with_zone (time_t time, icaltimezone *zone); - -/* Returns the start of the month containing the given time_t, using the given - timezone. */ -time_t time_month_begin_with_zone (time_t time, icaltimezone *zone); - -/* Returns the start of the week containing the given time_t, using the given - timezone. week_start_day should use the same values as mktime(), - i.e. 0 (Sun) to 6 (Sat). */ -time_t time_week_begin_with_zone (time_t time, int week_start_day, - icaltimezone *zone); - -/* Returns the start of the day containing the given time_t, using the given - timezone. */ -time_t time_day_begin_with_zone (time_t time, icaltimezone *zone); - -/* Returns the end of the day containing the given time_t, using the given - timezone. (The end of the day is the start of the next day.) */ -time_t time_day_end_with_zone (time_t time, icaltimezone *zone); - -void time_to_gdate_with_zone (GDate *date, time_t time, icaltimezone *zone); - -/************************************************************************** - * struct tm manipulation - **************************************************************************/ - -struct tm icaltimetype_to_tm (struct icaltimetype *itt); -struct tm icaltimetype_to_tm_with_zone (struct icaltimetype *itt, - icaltimezone *from_zone, - icaltimezone *to_zone); -struct icaltimetype tm_to_icaltimetype (struct tm *tm, gboolean is_date); - -#endif diff --git a/calendar/conduits/calendar/Makefile.am b/calendar/conduits/calendar/Makefile.am index a3644d15d9..7d521ccc6a 100644 --- a/calendar/conduits/calendar/Makefile.am +++ b/calendar/conduits/calendar/Makefile.am @@ -1,8 +1,4 @@ INCLUDES = \ - -I$(top_srcdir) \ - -I$(top_srcdir)/calendar \ - -I$(top_builddir)/calendar/cal-client \ - -I$(top_srcdir)/libical/src \ -I$(top_srcdir)/e-util \ -I$(top_builddir)/e-util \ $(EVOLUTION_CALENDAR_CONDUIT_CFLAGS) @@ -17,10 +13,6 @@ libecalendar_conduit_la_SOURCES = \ libecalendar_conduit_la_LDFLAGS = -module -avoid-version libecalendar_conduit_la_LIBADD = \ $(top_builddir)/e-util/libeutil.la \ - $(top_builddir)/calendar/cal-client/libcal-client.la \ - $(top_builddir)/calendar/cal-util/libcal-util.la \ - $(top_builddir)/libversit/libversit.la \ - $(top_builddir)/libical/src/libical/libical-evolution.la \ $(top_builddir)/e-util/libeconduit.la \ $(EVOLUTION_CALENDAR_CONDUIT_LIBS) diff --git a/calendar/conduits/calendar/calendar-conduit.c b/calendar/conduits/calendar/calendar-conduit.c index 7a30262e6c..c1d0e45134 100644 --- a/calendar/conduits/calendar/calendar-conduit.c +++ b/calendar/conduits/calendar/calendar-conduit.c @@ -25,9 +25,9 @@ #define G_LOG_DOMAIN "ecalconduit" -#include <cal-client/cal-client-types.h> -#include <cal-client/cal-client.h> -#include <cal-util/timeutil.h> +#include <libecal/e-cal-types.h> +#include <libecal/e-cal.h> +#include <libecal/e-cal-time-util.h> #include <pi-source.h> #include <pi-socket.h> #include <pi-dlp.h> @@ -74,7 +74,7 @@ struct _ECalLocalRecord { GnomePilotDesktopRecord local; /* The corresponding Comp object */ - CalComponent *comp; + ECalComponent *comp; /* pilot-link appointment structure */ struct Appointment *appt; @@ -249,10 +249,10 @@ struct _ECalConduitContext { struct AppointmentAppInfo ai; - CalClient *client; + ECal *client; icaltimezone *timezone; - CalComponent *default_comp; + ECalComponent *default_comp; GList *comps; GList *changed; GHashTable *changed_hash; @@ -318,7 +318,7 @@ e_calendar_context_destroy (ECalConduitContext *ctxt) } if (ctxt->changed != NULL) - cal_client_change_list_free (ctxt->changed); + e_cal_change_list_free (ctxt->changed); if (ctxt->changed_hash != NULL) { g_hash_table_foreach_remove (ctxt->changed_hash, e_calendar_context_foreach_change, NULL); @@ -388,13 +388,13 @@ static char *print_remote (GnomePilotRecord *remote) /* Calendar Server routines */ static void -start_calendar_server_cb (CalClient *cal_client, - CalClientOpenStatus status, +start_calendar_server_cb (ECal *e_cal, + ECalOpenStatus status, gpointer data) { gboolean *success = data; - if (status == CAL_CLIENT_OPEN_SUCCESS) { + if (status == E_CAL_OPEN_SUCCESS) { *success = TRUE; } else { *success = FALSE; @@ -415,7 +415,7 @@ start_calendar_server (ECalConduitContext *ctxt) /* FIXME Need a mechanism for the user to select uri's */ /* FIXME Can we use the cal model? */ uri = g_strdup_printf ("file://%s/local/Calendar/", g_get_home_dir ()); - ctxt->client = cal_client_new (uri, CALOBJ_TYPE_EVENT); + ctxt->client = e_cal_new (uri, CALOBJ_TYPE_EVENT); g_free (uri); if (!ctxt->client) @@ -424,7 +424,7 @@ start_calendar_server (ECalConduitContext *ctxt) g_signal_connect (ctxt->client, "cal_opened", G_CALLBACK (start_calendar_server_cb), &success); - if (!cal_client_open (ctxt->client, FALSE, NULL)) + if (!e_cal_open (ctxt->client, FALSE, NULL)) return -1; /* run a sub event loop to turn cal-client's async load @@ -439,13 +439,13 @@ start_calendar_server (ECalConduitContext *ctxt) /* Utility routines */ static icaltimezone * -get_timezone (CalClient *client, const char *tzid) +get_timezone (ECal *client, const char *tzid) { icaltimezone *timezone = NULL; timezone = icaltimezone_get_builtin_timezone_from_tzid (tzid); if (timezone == NULL) - cal_client_get_timezone (client, tzid, &timezone, NULL); + e_cal_get_timezone (client, tzid, &timezone, NULL); return timezone; } @@ -542,7 +542,7 @@ is_empty_time (struct tm time) } static gboolean -is_all_day (CalClient *client, CalComponentDateTime *dt_start, CalComponentDateTime *dt_end) +is_all_day (ECal *client, ECalComponentDateTime *dt_start, ECalComponentDateTime *dt_end) { time_t dt_start_time, dt_end_time; icaltimezone *timezone; @@ -561,9 +561,9 @@ is_all_day (CalClient *client, CalComponentDateTime *dt_start, CalComponentDateT } static gboolean -process_multi_day (ECalConduitContext *ctxt, CalClientChange *ccc, GList **multi_comp, GList **multi_ccc) +process_multi_day (ECalConduitContext *ctxt, ECalChange *ccc, GList **multi_comp, GList **multi_ccc) { - CalComponentDateTime dt_start, dt_end; + ECalComponentDateTime dt_start, dt_end; icaltimezone *tz_start, *tz_end; time_t event_start, event_end, day_end; struct icaltimetype *old_start_value, *old_end_value; @@ -575,18 +575,18 @@ process_multi_day (ECalConduitContext *ctxt, CalClientChange *ccc, GList **multi *multi_ccc = NULL; *multi_comp = NULL; - if (ccc->type == CAL_CLIENT_CHANGE_DELETED) + if (ccc->type == E_CAL_CHANGE_DELETED) return FALSE; /* Start time */ - cal_component_get_dtstart (ccc->comp, &dt_start); + e_cal_component_get_dtstart (ccc->comp, &dt_start); if (dt_start.value->is_date) tz_start = ctxt->timezone; else tz_start = get_timezone (ctxt->client, dt_start.tzid); event_start = icaltime_as_timet_with_zone (*dt_start.value, tz_start); - cal_component_get_dtend (ccc->comp, &dt_end); + e_cal_component_get_dtend (ccc->comp, &dt_end); if (dt_end.value->is_date) tz_end = ctxt->timezone; else @@ -597,7 +597,7 @@ process_multi_day (ECalConduitContext *ctxt, CalClientChange *ccc, GList **multi if (day_end >= event_end) { ret = FALSE; goto cleanup; - } else if (cal_component_has_recurrences (ccc->comp) || !ctxt->cfg->multi_day_split) { + } else if (e_cal_component_has_recurrences (ccc->comp) || !ctxt->cfg->multi_day_split) { ret = TRUE; goto cleanup; } @@ -608,31 +608,31 @@ process_multi_day (ECalConduitContext *ctxt, CalClientChange *ccc, GList **multi old_start_value = dt_start.value; old_end_value = dt_end.value; while (!last) { - CalComponent *clone = cal_component_clone (ccc->comp); - char *new_uid = cal_component_gen_uid (); + ECalComponent *clone = e_cal_component_clone (ccc->comp); + char *new_uid = e_cal_component_gen_uid (); struct icaltimetype start_value, end_value; - CalClientChange *c = g_new0 (CalClientChange, 1); + ECalChange *c = g_new0 (ECalChange, 1); if (day_end >= event_end) { day_end = event_end; last = TRUE; } - cal_component_set_uid (clone, new_uid); + e_cal_component_set_uid (clone, new_uid); start_value = icaltime_from_timet_with_zone (event_start, is_date, tz_start); dt_start.value = &start_value; - cal_component_set_dtstart (clone, &dt_start); + e_cal_component_set_dtstart (clone, &dt_start); end_value = icaltime_from_timet_with_zone (day_end, is_date, tz_end); dt_end.value = &end_value; - cal_component_set_dtend (clone, &dt_end); + e_cal_component_set_dtend (clone, &dt_end); /* FIXME Error handling */ - cal_client_create_object (ctxt->client, cal_component_get_icalcomponent (clone), NULL, NULL); + e_cal_create_object (ctxt->client, e_cal_component_get_icalcomponent (clone), NULL, NULL); c->comp = clone; - c->type = CAL_CLIENT_CHANGE_ADDED; + c->type = E_CAL_CHANGE_ADDED; *multi_ccc = g_list_prepend (*multi_ccc, c); *multi_comp = g_list_prepend (*multi_comp, g_object_ref (c->comp)); @@ -643,14 +643,14 @@ process_multi_day (ECalConduitContext *ctxt, CalClientChange *ccc, GList **multi dt_start.value = old_start_value; dt_end.value = old_end_value; - cal_component_get_uid (ccc->comp, &uid); + e_cal_component_get_uid (ccc->comp, &uid); /* FIXME Error handling */ - cal_client_remove_object (ctxt->client, uid, NULL); - ccc->type = CAL_CLIENT_CHANGE_DELETED; + e_cal_remove_object (ctxt->client, uid, NULL); + ccc->type = E_CAL_CHANGE_DELETED; cleanup: - cal_component_free_datetime (&dt_start); - cal_component_free_datetime (&dt_end); + e_cal_component_free_datetime (&dt_start); + e_cal_component_free_datetime (&dt_end); return ret; } @@ -666,7 +666,7 @@ nth_weekday (int pos, icalrecurrencetype_weekday weekday) static GList * next_changed_item (ECalConduitContext *ctxt, GList *changes) { - CalClientChange *ccc; + ECalChange *ccc; GList *l; for (l = changes; l != NULL; l = l->next) { @@ -674,7 +674,7 @@ next_changed_item (ECalConduitContext *ctxt, GList *changes) ccc = l->data; - cal_component_get_uid (ccc->comp, &uid); + e_cal_component_get_uid (ccc->comp, &uid); if (g_hash_table_lookup (ctxt->changed_hash, uid)) return l; } @@ -685,7 +685,7 @@ next_changed_item (ECalConduitContext *ctxt, GList *changes) static void compute_status (ECalConduitContext *ctxt, ECalLocalRecord *local, const char *uid) { - CalClientChange *ccc; + ECalChange *ccc; local->local.archived = FALSE; local->local.secret = FALSE; @@ -698,15 +698,15 @@ compute_status (ECalConduitContext *ctxt, ECalLocalRecord *local, const char *ui } switch (ccc->type) { - case CAL_CLIENT_CHANGE_ADDED: + case E_CAL_CHANGE_ADDED: local->local.attr = GnomePilotRecordNew; break; - case CAL_CLIENT_CHANGE_MODIFIED: + case E_CAL_CHANGE_MODIFIED: local->local.attr = GnomePilotRecordModified; break; - case CAL_CLIENT_CHANGE_DELETED: + case E_CAL_CHANGE_DELETED: local->local.attr = GnomePilotRecordDeleted; break; } @@ -730,7 +730,7 @@ rrules_mostly_equal (struct icalrecurrencetype *a, struct icalrecurrencetype *b) } static gboolean -find_last_cb (CalComponent *comp, time_t start, time_t end, gpointer data) +find_last_cb (ECalComponent *comp, time_t start, time_t end, gpointer data) { time_t *last = data; @@ -763,17 +763,17 @@ local_record_to_pilot_record (ECalLocalRecord *local, } /* - * converts a CalComponent object to a ECalLocalRecord + * converts a ECalComponent object to a ECalLocalRecord */ static void -local_record_from_comp (ECalLocalRecord *local, CalComponent *comp, ECalConduitContext *ctxt) +local_record_from_comp (ECalLocalRecord *local, ECalComponent *comp, ECalConduitContext *ctxt) { const char *uid; - CalComponentText summary; + ECalComponentText summary; GSList *d_list = NULL, *edl = NULL, *l; - CalComponentText *description; - CalComponentDateTime dt_start, dt_end; - CalComponentClassification classif; + ECalComponentText *description; + ECalComponentDateTime dt_start, dt_end; + ECalComponentClassification classif; icaltimezone *default_tz = ctxt->timezone; int i; @@ -783,7 +783,7 @@ local_record_from_comp (ECalLocalRecord *local, CalComponent *comp, ECalConduitC local->comp = comp; g_object_ref (comp); - cal_component_get_uid (local->comp, &uid); + e_cal_component_get_uid (local->comp, &uid); local->local.ID = e_pilot_map_lookup_pid (ctxt->map, uid, TRUE); compute_status (ctxt, local, uid); @@ -813,13 +813,13 @@ local_record_from_comp (ECalLocalRecord *local, CalComponent *comp, ECalConduitC /* STOP: don't replace these with g_strdup, since free_Appointment uses free to deallocate */ - cal_component_get_summary (comp, &summary); + e_cal_component_get_summary (comp, &summary); if (summary.value) local->appt->description = e_pilot_utf8_to_pchar (summary.value); - cal_component_get_description_list (comp, &d_list); + e_cal_component_get_description_list (comp, &d_list); if (d_list) { - description = (CalComponentText *) d_list->data; + description = (ECalComponentText *) d_list->data; if (description && description->value) local->appt->note = e_pilot_utf8_to_pchar (description->value); else @@ -829,8 +829,8 @@ local_record_from_comp (ECalLocalRecord *local, CalComponent *comp, ECalConduitC } /* Start/End */ - cal_component_get_dtstart (comp, &dt_start); - cal_component_get_dtend (comp, &dt_end); + e_cal_component_get_dtstart (comp, &dt_start); + e_cal_component_get_dtend (comp, &dt_end); if (dt_start.value) { icaltimezone_convert_time (dt_start.value, get_timezone (ctxt->client, dt_start.tzid), @@ -851,18 +851,18 @@ local_record_from_comp (ECalLocalRecord *local, CalComponent *comp, ECalConduitC } else { local->appt->event = 1; } - cal_component_free_datetime (&dt_start); - cal_component_free_datetime (&dt_end); + e_cal_component_free_datetime (&dt_start); + e_cal_component_free_datetime (&dt_end); /* Recurrence Rules */ local->appt->repeatType = repeatNone; - if (!cal_component_is_instance (comp)) { - if (cal_component_has_rrules (comp)) { + if (!e_cal_component_is_instance (comp)) { + if (e_cal_component_has_rrules (comp)) { GSList *list; struct icalrecurrencetype *recur; - cal_component_get_rrule_list (comp, &list); + e_cal_component_get_rrule_list (comp, &list); recur = list->data; switch (recur->freq) { @@ -928,8 +928,8 @@ local_record_from_comp (ECalLocalRecord *local, CalComponent *comp, ECalConduitC /* The palm does not support count recurrences */ local->appt->repeatForever = 0; - cal_recur_generate_instances (comp, -1, -1, find_last_cb, &last, - cal_client_resolve_tzid_cb, ctxt->client, + e_cal_recur_generate_instances (comp, -1, -1, find_last_cb, &last, + e_cal_resolve_tzid_cb, ctxt->client, default_tz); itt = icaltime_from_timet_with_zone (last, TRUE, default_tz); local->appt->repeatEnd = icaltimetype_to_tm (&itt); @@ -937,37 +937,37 @@ local_record_from_comp (ECalLocalRecord *local, CalComponent *comp, ECalConduitC local->appt->repeatForever = 1; } - cal_component_free_recur_list (list); + e_cal_component_free_recur_list (list); } /* Exceptions */ - cal_component_get_exdate_list (comp, &edl); + e_cal_component_get_exdate_list (comp, &edl); local->appt->exceptions = g_slist_length (edl); local->appt->exception = g_new0 (struct tm, local->appt->exceptions); for (l = edl, i = 0; l != NULL; l = l->next, i++) { - CalComponentDateTime *dt = l->data; + ECalComponentDateTime *dt = l->data; icaltimezone_convert_time (dt->value, icaltimezone_get_utc_timezone (), default_tz); *local->appt->exception = icaltimetype_to_tm (dt->value); } - cal_component_free_exdate_list (edl); + e_cal_component_free_exdate_list (edl); } /* Alarm */ local->appt->alarm = 0; - if (cal_component_has_alarms (comp)) { + if (e_cal_component_has_alarms (comp)) { GList *uids, *l; - CalComponentAlarm *alarm; - CalAlarmTrigger trigger; + ECalComponentAlarm *alarm; + ECalComponentAlarmTrigger trigger; - uids = cal_component_get_alarm_uids (comp); + uids = e_cal_component_get_alarm_uids (comp); for (l = uids; l != NULL; l = l->next) { - alarm = cal_component_get_alarm (comp, l->data); - cal_component_alarm_get_trigger (alarm, &trigger); + alarm = e_cal_component_get_alarm (comp, l->data); + e_cal_component_alarm_get_trigger (alarm, &trigger); - if ((trigger.type == CAL_ALARM_TRIGGER_RELATIVE_START + if ((trigger.type == E_CAL_COMPONENT_ALARM_TRIGGER_RELATIVE_START && trigger.u.rel_duration.is_neg)) { local->appt->advanceUnits = advMinutes; local->appt->advance = @@ -998,14 +998,14 @@ local_record_from_comp (ECalLocalRecord *local, CalComponent *comp, ECalConduitC local->appt->alarm = 1; break; } - cal_component_alarm_free (alarm); + e_cal_component_alarm_free (alarm); } cal_obj_uid_list_free (uids); } - cal_component_get_classification (comp, &classif); + e_cal_component_get_classification (comp, &classif); - if (classif == CAL_COMPONENT_CLASS_PRIVATE) + if (classif == E_CAL_COMPONENT_CLASS_PRIVATE) local->local.secret = 1; else local->local.secret = 0; @@ -1018,15 +1018,15 @@ local_record_from_uid (ECalLocalRecord *local, const char *uid, ECalConduitContext *ctxt) { - CalComponent *comp; + ECalComponent *comp; icalcomponent *icalcomp; GError *error = NULL; g_assert(local!=NULL); - if (cal_client_get_object (ctxt->client, uid, NULL, &icalcomp, &error)) { - comp = cal_component_new (); - if (!cal_component_set_icalcomponent (comp, icalcomp)) { + if (e_cal_get_object (ctxt->client, uid, NULL, &icalcomp, &error)) { + comp = e_cal_component_new (); + if (!e_cal_component_set_icalcomponent (comp, icalcomp)) { g_object_unref (comp); icalcomponent_free (icalcomp); return; @@ -1035,9 +1035,9 @@ local_record_from_uid (ECalLocalRecord *local, local_record_from_comp (local, comp, ctxt); g_object_unref (comp); } else if (error->code == E_CALENDAR_STATUS_OBJECT_NOT_FOUND) { - comp = cal_component_new (); - cal_component_set_new_vtype (comp, CAL_COMPONENT_EVENT); - cal_component_set_uid (comp, uid); + comp = e_cal_component_new (); + e_cal_component_set_new_vtype (comp, E_CAL_COMPONENT_EVENT); + e_cal_component_set_uid (comp, uid); local_record_from_comp (local, comp, ctxt); g_object_unref (comp); } else { @@ -1047,19 +1047,19 @@ local_record_from_uid (ECalLocalRecord *local, g_clear_error (&error); } -static CalComponent * +static ECalComponent * comp_from_remote_record (GnomePilotConduitSyncAbs *conduit, GnomePilotRecord *remote, - CalComponent *in_comp, - CalClient *client, + ECalComponent *in_comp, + ECal *client, icaltimezone *timezone) { - CalComponent *comp; + ECalComponent *comp; struct Appointment appt; struct icaltimetype now = icaltime_from_timet_with_zone (time (NULL), FALSE, timezone), it; struct icalrecurrencetype recur; - CalComponentText summary = {NULL, NULL}; - CalComponentDateTime dt = {NULL, NULL}; + ECalComponentText summary = {NULL, NULL}; + ECalComponentDateTime dt = {NULL, NULL}; GSList *edl = NULL; char *txt; int pos, i; @@ -1070,32 +1070,32 @@ comp_from_remote_record (GnomePilotConduitSyncAbs *conduit, unpack_Appointment (&appt, remote->record, remote->length); if (in_comp == NULL) { - comp = cal_component_new (); - cal_component_set_new_vtype (comp, CAL_COMPONENT_EVENT); - cal_component_set_created (comp, &now); + comp = e_cal_component_new (); + e_cal_component_set_new_vtype (comp, E_CAL_COMPONENT_EVENT); + e_cal_component_set_created (comp, &now); } else { - comp = cal_component_clone (in_comp); + comp = e_cal_component_clone (in_comp); } - cal_component_set_last_modified (comp, &now); + e_cal_component_set_last_modified (comp, &now); summary.value = txt = e_pilot_utf8_from_pchar (appt.description); - cal_component_set_summary (comp, &summary); + e_cal_component_set_summary (comp, &summary); free (txt); /* The iCal description field */ if (!appt.note) { - cal_component_set_description_list (comp, NULL); + e_cal_component_set_description_list (comp, NULL); } else { GSList l; - CalComponentText text; + ECalComponentText text; text.value = txt = e_pilot_utf8_from_pchar (appt.note); text.altrep = NULL; l.data = &text; l.next = NULL; - cal_component_set_description_list (comp, &l); + e_cal_component_set_description_list (comp, &l); free (txt); } @@ -1103,21 +1103,21 @@ comp_from_remote_record (GnomePilotConduitSyncAbs *conduit, it = tm_to_icaltimetype (&appt.begin, TRUE); dt.value = ⁢ dt.tzid = NULL; - cal_component_set_dtstart (comp, &dt); - cal_component_set_dtend (comp, &dt); + e_cal_component_set_dtstart (comp, &dt); + e_cal_component_set_dtend (comp, &dt); } else { dt.tzid = icaltimezone_get_tzid (timezone); if (!is_empty_time (appt.begin)) { it = tm_to_icaltimetype (&appt.begin, FALSE); dt.value = ⁢ - cal_component_set_dtstart (comp, &dt); + e_cal_component_set_dtstart (comp, &dt); } if (!is_empty_time (appt.end)) { it = tm_to_icaltimetype (&appt.end, FALSE); dt.value = ⁢ - cal_component_set_dtend (comp, &dt); + e_cal_component_set_dtend (comp, &dt); } } @@ -1183,12 +1183,12 @@ comp_from_remote_record (GnomePilotConduitSyncAbs *conduit, } list = g_slist_append (list, &recur); - cal_component_set_rrule_list (comp, list); + e_cal_component_set_rrule_list (comp, list); /* If the desktop uses count and rrules are * equivalent, use count still on the desktop */ - if (!appt.repeatForever && cal_component_has_rrules (in_comp)) { - cal_component_get_rrule_list (in_comp, &existing); + if (!appt.repeatForever && e_cal_component_has_rrules (in_comp)) { + e_cal_component_get_rrule_list (in_comp, &existing); erecur = existing->data; /* If the rules are otherwise the same and the existing uses count, @@ -1197,31 +1197,31 @@ comp_from_remote_record (GnomePilotConduitSyncAbs *conduit, icaltime_is_null_time (erecur->until) && erecur->count > 0) { time_t last, elast; - cal_recur_generate_instances (comp, -1, -1, find_last_cb, &last, - cal_client_resolve_tzid_cb, client, + e_cal_recur_generate_instances (comp, -1, -1, find_last_cb, &last, + e_cal_resolve_tzid_cb, client, timezone); - cal_recur_generate_instances (in_comp, -1, -1, find_last_cb, &elast, - cal_client_resolve_tzid_cb, client, + e_cal_recur_generate_instances (in_comp, -1, -1, find_last_cb, &elast, + e_cal_resolve_tzid_cb, client, timezone); if (last == elast) { recur.until = icaltime_null_time (); recur.count = erecur->count; - cal_component_set_rrule_list (comp, list); + e_cal_component_set_rrule_list (comp, list); } } } g_slist_free (list); } else { - cal_component_set_rrule_list (comp, NULL); + e_cal_component_set_rrule_list (comp, NULL); } /* Exceptions */ for (i = 0; i < appt.exceptions; i++) { struct tm ex; - CalComponentDateTime *dt = g_new0 (CalComponentDateTime, 1); + ECalComponentDateTime *dt = g_new0 (ECalComponentDateTime, 1); dt->value = g_new0 (struct icaltimetype, 1); dt->tzid = NULL; @@ -1231,36 +1231,36 @@ comp_from_remote_record (GnomePilotConduitSyncAbs *conduit, edl = g_slist_prepend (edl, dt); } - cal_component_set_exdate_list (comp, edl); - cal_component_free_exdate_list (edl); + e_cal_component_set_exdate_list (comp, edl); + e_cal_component_free_exdate_list (edl); /* Alarm */ if (appt.alarm) { - CalComponentAlarm *alarm = NULL; - CalAlarmTrigger trigger; + ECalComponentAlarm *alarm = NULL; + ECalComponentAlarmTrigger trigger; gboolean found = FALSE; - if (cal_component_has_alarms (comp)) { + if (e_cal_component_has_alarms (comp)) { GList *uids, *l; - uids = cal_component_get_alarm_uids (comp); + uids = e_cal_component_get_alarm_uids (comp); for (l = uids; l != NULL; l = l->next) { - alarm = cal_component_get_alarm (comp, l->data); - cal_component_alarm_get_trigger (alarm, &trigger); - if ((trigger.type == CAL_ALARM_TRIGGER_RELATIVE_START + alarm = e_cal_component_get_alarm (comp, l->data); + e_cal_component_alarm_get_trigger (alarm, &trigger); + if ((trigger.type == E_CAL_COMPONENT_ALARM_TRIGGER_RELATIVE_START && trigger.u.rel_duration.is_neg)) { found = TRUE; break; } - cal_component_alarm_free (alarm); + e_cal_component_alarm_free (alarm); } cal_obj_uid_list_free (uids); } if (!found) - alarm = cal_component_alarm_new (); + alarm = e_cal_component_alarm_new (); - memset (&trigger, 0, sizeof (CalAlarmTrigger)); - trigger.type = CAL_ALARM_TRIGGER_RELATIVE_START; + memset (&trigger, 0, sizeof (ECalComponentAlarmTrigger)); + trigger.type = E_CAL_COMPONENT_ALARM_TRIGGER_RELATIVE_START; trigger.u.rel_duration.is_neg = 1; switch (appt.advanceUnits) { case advMinutes: @@ -1273,22 +1273,22 @@ comp_from_remote_record (GnomePilotConduitSyncAbs *conduit, trigger.u.rel_duration.days = appt.advance; break; } - cal_component_alarm_set_trigger (alarm, trigger); - cal_component_alarm_set_action (alarm, CAL_ALARM_DISPLAY); + e_cal_component_alarm_set_trigger (alarm, trigger); + e_cal_component_alarm_set_action (alarm, E_CAL_COMPONENT_ALARM_DISPLAY); if (!found) - cal_component_add_alarm (comp, alarm); - cal_component_alarm_free (alarm); + e_cal_component_add_alarm (comp, alarm); + e_cal_component_alarm_free (alarm); } - cal_component_set_transparency (comp, CAL_COMPONENT_TRANSP_NONE); + e_cal_component_set_transparency (comp, E_CAL_COMPONENT_TRANSP_NONE); if (remote->secret) - cal_component_set_classification (comp, CAL_COMPONENT_CLASS_PRIVATE); + e_cal_component_set_classification (comp, E_CAL_COMPONENT_CLASS_PRIVATE); else - cal_component_set_classification (comp, CAL_COMPONENT_CLASS_PUBLIC); + e_cal_component_set_classification (comp, E_CAL_COMPONENT_CLASS_PUBLIC); - cal_component_commit_sequence (comp); + e_cal_component_commit_sequence (comp); free_Appointment (&appt); @@ -1308,7 +1308,7 @@ check_for_slow_setting (GnomePilotConduit *c, ECalConduitContext *ctxt) gnome_pilot_conduit_standard_set_slow (conduit, TRUE); /* Or if the URI's don't match */ - uri = cal_client_get_uri (ctxt->client); + uri = e_cal_get_uri (ctxt->client); LOG (g_message ( " Current URI %s (%s)\n", uri, ctxt->cfg->last_uri ? ctxt->cfg->last_uri : "<NONE>" )); if (ctxt->cfg->last_uri != NULL && strcmp (ctxt->cfg->last_uri, uri)) { gnome_pilot_conduit_standard_set_slow (conduit, TRUE); @@ -1359,23 +1359,23 @@ pre_sync (GnomePilotConduit *conduit, /* Set the default timezone on the backend. */ if (ctxt->timezone) { - if (!cal_client_set_default_timezone (ctxt->client, ctxt->timezone, NULL)) + if (!e_cal_set_default_timezone (ctxt->client, ctxt->timezone, NULL)) return -1; } /* Get the default component */ - if (!cal_client_get_default_object (ctxt->client, &icalcomp, NULL)) + if (!e_cal_get_default_object (ctxt->client, &icalcomp, NULL)) return -1; - ctxt->default_comp = cal_component_new (); - if (!cal_component_set_icalcomponent (ctxt->default_comp, icalcomp)) { + ctxt->default_comp = e_cal_component_new (); + if (!e_cal_component_set_icalcomponent (ctxt->default_comp, icalcomp)) { g_object_unref (ctxt->default_comp); icalcomponent_free (icalcomp); return -1; } - ctxt->default_comp = cal_component_new (); - if (!cal_component_set_icalcomponent (ctxt->default_comp, icalcomp)) { + ctxt->default_comp = e_cal_component_new (); + if (!e_cal_component_set_icalcomponent (ctxt->default_comp, icalcomp)) { g_object_unref (ctxt->default_comp); icalcomponent_free (icalcomp); return -1; @@ -1387,19 +1387,19 @@ pre_sync (GnomePilotConduit *conduit, g_free (filename); /* Get the local database */ - if (!cal_client_get_object_list_as_comp (ctxt->client, "(#t)", &ctxt->comps, NULL)) + if (!e_cal_get_object_list_as_comp (ctxt->client, "(#t)", &ctxt->comps, NULL)) return -1; /* Find the added, modified and deleted items */ change_id = g_strdup_printf ("pilot-sync-evolution-calendar-%d", ctxt->cfg->pilot_id); - if (!cal_client_get_changes (ctxt->client, change_id, &ctxt->changed, NULL)) + if (!e_cal_get_changes (ctxt->client, change_id, &ctxt->changed, NULL)) return -1; ctxt->changed_hash = g_hash_table_new (g_str_hash, g_str_equal); g_free (change_id); /* See if we need to split up any events */ for (l = ctxt->changed; l != NULL; l = l->next) { - CalClientChange *ccc = l->data; + ECalChange *ccc = l->data; GList *multi_comp = NULL, *multi_ccc = NULL; if (process_multi_day (ctxt, ccc, &multi_comp, &multi_ccc)) { @@ -1413,10 +1413,10 @@ pre_sync (GnomePilotConduit *conduit, /* Remove the events that were split up */ g_list_concat (ctxt->changed, added); for (l = removed; l != NULL; l = l->next) { - CalClientChange *ccc = l->data; + ECalChange *ccc = l->data; const char *uid; - cal_component_get_uid (ccc->comp, &uid); + e_cal_component_get_uid (ccc->comp, &uid); if (e_pilot_map_lookup_pid (ctxt->map, uid, FALSE) == 0) { ctxt->changed = g_list_remove (ctxt->changed, ccc); g_object_unref (ccc->comp); @@ -1426,26 +1426,26 @@ pre_sync (GnomePilotConduit *conduit, g_list_free (removed); for (l = ctxt->changed; l != NULL; l = l->next) { - CalClientChange *ccc = l->data; + ECalChange *ccc = l->data; const char *uid; - cal_component_get_uid (ccc->comp, &uid); + e_cal_component_get_uid (ccc->comp, &uid); if (!e_pilot_map_uid_is_archived (ctxt->map, uid)) { g_hash_table_insert (ctxt->changed_hash, g_strdup (uid), ccc); switch (ccc->type) { - case CAL_CLIENT_CHANGE_ADDED: + case E_CAL_CHANGE_ADDED: add_records++; break; - case CAL_CLIENT_CHANGE_MODIFIED: + case E_CAL_CHANGE_MODIFIED: mod_records++; break; - case CAL_CLIENT_CHANGE_DELETED: + case E_CAL_CHANGE_DELETED: del_records++; break; } - } else if (ccc->type == CAL_CLIENT_CHANGE_DELETED) { + } else if (ccc->type == E_CAL_CHANGE_DELETED) { e_pilot_map_remove_by_uid (ctxt->map, uid); } } @@ -1490,7 +1490,7 @@ post_sync (GnomePilotConduit *conduit, LOG (g_message ( "post_sync: Calendar Conduit v.%s", CONDUIT_VERSION )); g_free (ctxt->cfg->last_uri); - ctxt->cfg->last_uri = g_strdup (cal_client_get_uri (ctxt->client)); + ctxt->cfg->last_uri = g_strdup (e_cal_get_uri (ctxt->client)); calconduit_save_configuration (ctxt->cfg); filename = map_name (ctxt); @@ -1501,8 +1501,8 @@ post_sync (GnomePilotConduit *conduit, * a race condition if anyone changes a record elsewhere during sycnc */ change_id = g_strdup_printf ("pilot-sync-evolution-calendar-%d", ctxt->cfg->pilot_id); - if (cal_client_get_changes (ctxt->client, change_id, &changed, NULL)) - cal_client_change_list_free (changed); + if (e_cal_get_changes (ctxt->client, change_id, &changed, NULL)) + e_cal_change_list_free (changed); g_free (change_id); LOG (g_message ( "---------------------------------------------------------\n" )); @@ -1520,7 +1520,7 @@ set_pilot_id (GnomePilotConduitSyncAbs *conduit, LOG (g_message ( "set_pilot_id: setting to %d\n", ID )); - cal_component_get_uid (local->comp, &uid); + e_cal_component_get_uid (local->comp, &uid); e_pilot_map_insert (ctxt->map, ID, uid, FALSE); return 0; @@ -1535,7 +1535,7 @@ set_status_cleared (GnomePilotConduitSyncAbs *conduit, LOG (g_message ( "set_status_cleared: clearing status\n" )); - cal_component_get_uid (local->comp, &uid); + e_cal_component_get_uid (local->comp, &uid); g_hash_table_remove (ctxt->changed_hash, uid); return 0; @@ -1612,7 +1612,7 @@ for_each_modified (GnomePilotConduitSyncAbs *conduit, iterator = next_changed_item (ctxt, iterator); if (iterator != NULL) { - CalClientChange *ccc = iterator->data; + ECalChange *ccc = iterator->data; *local = g_new0 (ECalLocalRecord, 1); local_record_from_comp (*local, ccc->comp, ctxt); @@ -1626,7 +1626,7 @@ for_each_modified (GnomePilotConduitSyncAbs *conduit, count++; iterator = g_list_next (iterator); if (iterator && (iterator = next_changed_item (ctxt, iterator))) { - CalClientChange *ccc = iterator->data; + ECalChange *ccc = iterator->data; *local = g_new0 (ECalLocalRecord, 1); local_record_from_comp (*local, ccc->comp, ctxt); @@ -1677,7 +1677,7 @@ add_record (GnomePilotConduitSyncAbs *conduit, GnomePilotRecord *remote, ECalConduitContext *ctxt) { - CalComponent *comp; + ECalComponent *comp; char *uid; int retval = 0; @@ -1688,10 +1688,10 @@ add_record (GnomePilotConduitSyncAbs *conduit, comp = comp_from_remote_record (conduit, remote, ctxt->default_comp, ctxt->client, ctxt->timezone); /* Give it a new UID otherwise it will be the uid of the default comp */ - uid = cal_component_gen_uid (); - cal_component_set_uid (comp, uid); + uid = e_cal_component_gen_uid (); + e_cal_component_set_uid (comp, uid); - if (!cal_client_create_object (ctxt->client, cal_component_get_icalcomponent (comp), NULL, NULL)) + if (!e_cal_create_object (ctxt->client, e_cal_component_get_icalcomponent (comp), NULL, NULL)) return -1; e_pilot_map_insert (ctxt->map, remote->ID, uid, FALSE); @@ -1709,7 +1709,7 @@ replace_record (GnomePilotConduitSyncAbs *conduit, GnomePilotRecord *remote, ECalConduitContext *ctxt) { - CalComponent *new_comp; + ECalComponent *new_comp; int retval = 0; g_return_val_if_fail (remote != NULL, -1); @@ -1721,7 +1721,7 @@ replace_record (GnomePilotConduitSyncAbs *conduit, g_object_unref (local->comp); local->comp = new_comp; - if (!cal_client_modify_object (ctxt->client, cal_component_get_icalcomponent (new_comp), + if (!e_cal_modify_object (ctxt->client, e_cal_component_get_icalcomponent (new_comp), CALOBJ_MOD_ALL, NULL)) return -1; @@ -1738,13 +1738,13 @@ delete_record (GnomePilotConduitSyncAbs *conduit, g_return_val_if_fail (local != NULL, -1); g_assert (local->comp != NULL); - cal_component_get_uid (local->comp, &uid); + e_cal_component_get_uid (local->comp, &uid); LOG (g_message ( "delete_record: deleting %s\n", uid )); e_pilot_map_remove_by_uid (ctxt->map, uid); /* FIXME Error handling */ - cal_client_remove_object (ctxt->client, uid, NULL); + e_cal_remove_object (ctxt->client, uid, NULL); return 0; } @@ -1762,7 +1762,7 @@ archive_record (GnomePilotConduitSyncAbs *conduit, LOG (g_message ( "archive_record: %s\n", archive ? "yes" : "no" )); - cal_component_get_uid (local->comp, &uid); + e_cal_component_get_uid (local->comp, &uid); e_pilot_map_insert (ctxt->map, local->local.ID, uid, archive); return retval; diff --git a/calendar/conduits/todo/Makefile.am b/calendar/conduits/todo/Makefile.am index bb03a5acfc..4b4fccc732 100644 --- a/calendar/conduits/todo/Makefile.am +++ b/calendar/conduits/todo/Makefile.am @@ -1,8 +1,4 @@ INCLUDES = \ - -I$(top_srcdir) \ - -I$(top_srcdir)/calendar \ - -I$(top_builddir)/calendar/cal-client \ - -I$(top_srcdir)/libical/src \ -I$(top_srcdir)/e-util \ -I$(top_builddir)/e-util \ $(EVOLUTION_CALENDAR_CONDUIT_CFLAGS) @@ -17,10 +13,6 @@ libetodo_conduit_la_SOURCES = \ libetodo_conduit_la_LDFLAGS = -module -avoid-version libetodo_conduit_la_LIBADD = \ $(top_builddir)/e-util/libeutil.la \ - $(top_builddir)/calendar/cal-client/libcal-client.la \ - $(top_builddir)/calendar/cal-util/libcal-util.la \ - $(top_builddir)/libversit/libversit.la \ - $(top_builddir)/libical/src/libical/libical-evolution.la \ $(top_builddir)/e-util/libeconduit.la \ $(EVOLUTION_CALENDAR_CONDUIT_LIBS) diff --git a/calendar/conduits/todo/todo-conduit.c b/calendar/conduits/todo/todo-conduit.c index df69cdd088..4b20e2cf39 100644 --- a/calendar/conduits/todo/todo-conduit.c +++ b/calendar/conduits/todo/todo-conduit.c @@ -25,14 +25,14 @@ #define G_LOG_DOMAIN "etodoconduit" -#include <cal-client/cal-client-types.h> -#include <cal-client/cal-client.h> -#include <cal-util/timeutil.h> +#include <libecal/e-cal-types.h> +#include <libecal/e-cal.h> +#include <libecal/e-cal-time-util.h> #include <pi-source.h> #include <pi-socket.h> #include <pi-dlp.h> #include <pi-todo.h> -#include <libical/src/libical/icaltypes.h> +#include <libical/icaltypes.h> #include <gpilotd/gnome-pilot-conduit.h> #include <gpilotd/gnome-pilot-conduit-sync-abs.h> #include <libgpilotdCM/gnome-pilot-conduit-management.h> @@ -73,7 +73,7 @@ struct _EToDoLocalRecord { GnomePilotDesktopRecord local; /* The corresponding Comp object */ - CalComponent *comp; + ECalComponent *comp; /* pilot-link todo structure */ struct ToDo *todo; @@ -251,10 +251,10 @@ struct _EToDoConduitContext { struct ToDoAppInfo ai; - CalClient *client; + ECal *client; icaltimezone *timezone; - CalComponent *default_comp; + ECalComponent *default_comp; GList *comps; GList *changed; GHashTable *changed_hash; @@ -329,7 +329,7 @@ e_todo_context_destroy (EToDoConduitContext *ctxt) } if (ctxt->changed != NULL) - cal_client_change_list_free (ctxt->changed); + e_cal_change_list_free (ctxt->changed); if (ctxt->map != NULL) e_pilot_map_destroy (ctxt->map); @@ -395,13 +395,13 @@ static char *print_remote (GnomePilotRecord *remote) /* Calendar Server routines */ static void -start_calendar_server_cb (CalClient *cal_client, - CalClientOpenStatus status, +start_calendar_server_cb (ECal *e_cal, + ECalOpenStatus status, gpointer data) { gboolean *success = data; - if (status == CAL_CLIENT_OPEN_SUCCESS) { + if (status == E_CAL_OPEN_SUCCESS) { *success = TRUE; } else { *success = FALSE; @@ -422,7 +422,7 @@ start_calendar_server (EToDoConduitContext *ctxt) /* FIXME Need a mechanism for the user to select uri's */ /* FIXME Can we use the cal model? */ uri = g_strdup_printf ("file://%s/local/Tasks/", g_get_home_dir ()); - ctxt->client = cal_client_new (uri, CALOBJ_TYPE_TODO); + ctxt->client = e_cal_new (uri, CALOBJ_TYPE_TODO); g_free (uri); if (!ctxt->client) @@ -431,7 +431,7 @@ start_calendar_server (EToDoConduitContext *ctxt) g_signal_connect (ctxt->client, "cal_opened", G_CALLBACK (start_calendar_server_cb), &success); - if (!cal_client_open (ctxt->client, FALSE, NULL)) + if (!e_cal_open (ctxt->client, FALSE, NULL)) return -1; /* run a sub event loop to turn cal-client's async load @@ -446,13 +446,13 @@ start_calendar_server (EToDoConduitContext *ctxt) /* Utility routines */ static icaltimezone * -get_timezone (CalClient *client, const char *tzid) +get_timezone (ECal *client, const char *tzid) { icaltimezone *timezone = NULL; timezone = icaltimezone_get_builtin_timezone_from_tzid (tzid); if (timezone == NULL) - cal_client_get_timezone (client, tzid, &timezone, NULL); + e_cal_get_timezone (client, tzid, &timezone, NULL); return timezone; } @@ -504,7 +504,7 @@ is_empty_time (struct tm time) static GList * next_changed_item (EToDoConduitContext *ctxt, GList *changes) { - CalClientChange *ccc; + ECalChange *ccc; GList *l; for (l = changes; l != NULL; l = l->next) { @@ -512,7 +512,7 @@ next_changed_item (EToDoConduitContext *ctxt, GList *changes) ccc = l->data; - cal_component_get_uid (ccc->comp, &uid); + e_cal_component_get_uid (ccc->comp, &uid); if (g_hash_table_lookup (ctxt->changed_hash, uid)) return l; } @@ -523,7 +523,7 @@ next_changed_item (EToDoConduitContext *ctxt, GList *changes) static void compute_status (EToDoConduitContext *ctxt, EToDoLocalRecord *local, const char *uid) { - CalClientChange *ccc; + ECalChange *ccc; local->local.archived = FALSE; local->local.secret = FALSE; @@ -536,13 +536,13 @@ compute_status (EToDoConduitContext *ctxt, EToDoLocalRecord *local, const char * } switch (ccc->type) { - case CAL_CLIENT_CHANGE_ADDED: + case E_CAL_CHANGE_ADDED: local->local.attr = GnomePilotRecordNew; break; - case CAL_CLIENT_CHANGE_MODIFIED: + case E_CAL_CHANGE_MODIFIED: local->local.attr = GnomePilotRecordModified; break; - case CAL_CLIENT_CHANGE_DELETED: + case E_CAL_CHANGE_DELETED: local->local.attr = GnomePilotRecordDeleted; break; } @@ -574,19 +574,19 @@ local_record_to_pilot_record (EToDoLocalRecord *local, } /* - * converts a CalComponent object to a EToDoLocalRecord + * converts a ECalComponent object to a EToDoLocalRecord */ static void -local_record_from_comp (EToDoLocalRecord *local, CalComponent *comp, EToDoConduitContext *ctxt) +local_record_from_comp (EToDoLocalRecord *local, ECalComponent *comp, EToDoConduitContext *ctxt) { const char *uid; int *priority; icalproperty_status status; - CalComponentText summary; + ECalComponentText summary; GSList *d_list = NULL; - CalComponentText *description; - CalComponentDateTime due; - CalComponentClassification classif; + ECalComponentText *description; + ECalComponentDateTime due; + ECalComponentClassification classif; icaltimezone *default_tz = get_default_timezone (); LOG (g_message ( "local_record_from_comp\n" )); @@ -597,7 +597,7 @@ local_record_from_comp (EToDoLocalRecord *local, CalComponent *comp, EToDoCondui local->comp = comp; g_object_ref (comp); - cal_component_get_uid (local->comp, &uid); + e_cal_component_get_uid (local->comp, &uid); local->local.ID = e_pilot_map_lookup_pid (ctxt->map, uid, TRUE); compute_status (ctxt, local, uid); @@ -619,13 +619,13 @@ local_record_from_comp (EToDoLocalRecord *local, CalComponent *comp, EToDoCondui /* STOP: don't replace these with g_strdup, since free_ToDo uses free to deallocate */ - cal_component_get_summary (comp, &summary); + e_cal_component_get_summary (comp, &summary); if (summary.value) local->todo->description = e_pilot_utf8_to_pchar (summary.value); - cal_component_get_description_list (comp, &d_list); + e_cal_component_get_description_list (comp, &d_list); if (d_list) { - description = (CalComponentText *) d_list->data; + description = (ECalComponentText *) d_list->data; if (description && description->value) local->todo->note = e_pilot_utf8_to_pchar (description->value); else @@ -634,7 +634,7 @@ local_record_from_comp (EToDoLocalRecord *local, CalComponent *comp, EToDoCondui local->todo->note = NULL; } - cal_component_get_due (comp, &due); + e_cal_component_get_due (comp, &due); if (due.value) { icaltimezone_convert_time (due.value, get_timezone (ctxt->client, due.tzid), @@ -644,15 +644,15 @@ local_record_from_comp (EToDoLocalRecord *local, CalComponent *comp, EToDoCondui } else { local->todo->indefinite = 1; } - cal_component_free_datetime (&due); + e_cal_component_free_datetime (&due); - cal_component_get_status (comp, &status); + e_cal_component_get_status (comp, &status); if (status == ICAL_STATUS_COMPLETED) local->todo->complete = 1; else local->todo->complete = 0; - cal_component_get_priority (comp, &priority); + e_cal_component_get_priority (comp, &priority); if (priority && *priority != 0) { if (*priority <= 3) local->todo->priority = 1; @@ -665,14 +665,14 @@ local_record_from_comp (EToDoLocalRecord *local, CalComponent *comp, EToDoCondui else local->todo->priority = 5; - cal_component_free_priority (priority); + e_cal_component_free_priority (priority); } else { local->todo->priority = ctxt->cfg->priority; } - cal_component_get_classification (comp, &classif); + e_cal_component_get_classification (comp, &classif); - if (classif == CAL_COMPONENT_CLASS_PRIVATE) + if (classif == E_CAL_COMPONENT_CLASS_PRIVATE) local->local.secret = 1; else local->local.secret = 0; @@ -685,15 +685,15 @@ local_record_from_uid (EToDoLocalRecord *local, const char *uid, EToDoConduitContext *ctxt) { - CalComponent *comp; + ECalComponent *comp; icalcomponent *icalcomp; GError *error = NULL; g_assert(local!=NULL); - if (cal_client_get_object (ctxt->client, uid, NULL, &icalcomp, &error)) { - comp = cal_component_new (); - if (!cal_component_set_icalcomponent (comp, icalcomp)) { + if (e_cal_get_object (ctxt->client, uid, NULL, &icalcomp, &error)) { + comp = e_cal_component_new (); + if (!e_cal_component_set_icalcomponent (comp, icalcomp)) { g_object_unref (comp); icalcomponent_free (icalcomp); return; @@ -702,9 +702,9 @@ local_record_from_uid (EToDoLocalRecord *local, local_record_from_comp (local, comp, ctxt); g_object_unref (comp); } else if (error->code == E_CALENDAR_STATUS_OBJECT_NOT_FOUND) { - comp = cal_component_new (); - cal_component_set_new_vtype (comp, CAL_COMPONENT_TODO); - cal_component_set_uid (comp, uid); + comp = e_cal_component_new (); + e_cal_component_set_new_vtype (comp, E_CAL_COMPONENT_TODO); + e_cal_component_set_uid (comp, uid); local_record_from_comp (local, comp, ctxt); g_object_unref (comp); } else { @@ -715,16 +715,16 @@ local_record_from_uid (EToDoLocalRecord *local, } -static CalComponent * +static ECalComponent * comp_from_remote_record (GnomePilotConduitSyncAbs *conduit, GnomePilotRecord *remote, - CalComponent *in_comp, + ECalComponent *in_comp, icaltimezone *timezone) { - CalComponent *comp; + ECalComponent *comp; struct ToDo todo; - CalComponentText summary = {NULL, NULL}; - CalComponentDateTime dt = {NULL, icaltimezone_get_tzid (timezone)}; + ECalComponentText summary = {NULL, NULL}; + ECalComponentDateTime dt = {NULL, icaltimezone_get_tzid (timezone)}; struct icaltimetype due, now; icaltimezone *utc_zone; int priority; @@ -740,64 +740,64 @@ comp_from_remote_record (GnomePilotConduitSyncAbs *conduit, utc_zone); if (in_comp == NULL) { - comp = cal_component_new (); - cal_component_set_new_vtype (comp, CAL_COMPONENT_TODO); - cal_component_set_created (comp, &now); + comp = e_cal_component_new (); + e_cal_component_set_new_vtype (comp, E_CAL_COMPONENT_TODO); + e_cal_component_set_created (comp, &now); } else { - comp = cal_component_clone (in_comp); + comp = e_cal_component_clone (in_comp); } - cal_component_set_last_modified (comp, &now); + e_cal_component_set_last_modified (comp, &now); summary.value = txt = e_pilot_utf8_from_pchar (todo.description); - cal_component_set_summary (comp, &summary); + e_cal_component_set_summary (comp, &summary); free (txt); /* The iCal description field */ if (!todo.note) { - cal_component_set_comment_list (comp, NULL); + e_cal_component_set_comment_list (comp, NULL); } else { GSList l; - CalComponentText text; + ECalComponentText text; text.value = txt = e_pilot_utf8_from_pchar (todo.note); text.altrep = NULL; l.data = &text; l.next = NULL; - cal_component_set_description_list (comp, &l); + e_cal_component_set_description_list (comp, &l); free (txt); } if (todo.complete) { int percent = 100; - cal_component_set_completed (comp, &now); - cal_component_set_percent (comp, &percent); - cal_component_set_status (comp, ICAL_STATUS_COMPLETED); + e_cal_component_set_completed (comp, &now); + e_cal_component_set_percent (comp, &percent); + e_cal_component_set_status (comp, ICAL_STATUS_COMPLETED); } else { int *percent = NULL; icalproperty_status status; - cal_component_set_completed (comp, NULL); + e_cal_component_set_completed (comp, NULL); - cal_component_get_percent (comp, &percent); + e_cal_component_get_percent (comp, &percent); if (percent == NULL || *percent == 100) { int p = 0; - cal_component_set_percent (comp, &p); + e_cal_component_set_percent (comp, &p); } if (percent != NULL) - cal_component_free_percent (percent); + e_cal_component_free_percent (percent); - cal_component_get_status (comp, &status); + e_cal_component_get_status (comp, &status); if (status == ICAL_STATUS_COMPLETED) - cal_component_set_status (comp, ICAL_STATUS_NEEDSACTION); + e_cal_component_set_status (comp, ICAL_STATUS_NEEDSACTION); } if (!is_empty_time (todo.due)) { due = tm_to_icaltimetype (&todo.due, TRUE); dt.value = &due; - cal_component_set_due (comp, &dt); + e_cal_component_set_due (comp, &dt); } switch (todo.priority) { @@ -817,15 +817,15 @@ comp_from_remote_record (GnomePilotConduitSyncAbs *conduit, priority = 9; } - cal_component_set_priority (comp, &priority); - cal_component_set_transparency (comp, CAL_COMPONENT_TRANSP_NONE); + e_cal_component_set_priority (comp, &priority); + e_cal_component_set_transparency (comp, E_CAL_COMPONENT_TRANSP_NONE); if (remote->secret) - cal_component_set_classification (comp, CAL_COMPONENT_CLASS_PRIVATE); + e_cal_component_set_classification (comp, E_CAL_COMPONENT_CLASS_PRIVATE); else - cal_component_set_classification (comp, CAL_COMPONENT_CLASS_PUBLIC); + e_cal_component_set_classification (comp, E_CAL_COMPONENT_CLASS_PUBLIC); - cal_component_commit_sequence (comp); + e_cal_component_commit_sequence (comp); free_ToDo(&todo); @@ -845,7 +845,7 @@ check_for_slow_setting (GnomePilotConduit *c, EToDoConduitContext *ctxt) gnome_pilot_conduit_standard_set_slow (conduit, TRUE); /* Or if the URI's don't match */ - uri = cal_client_get_uri (ctxt->client); + uri = e_cal_get_uri (ctxt->client); LOG (g_message ( " Current URI %s (%s)\n", uri, ctxt->cfg->last_uri ? ctxt->cfg->last_uri : "<NONE>" )); if (ctxt->cfg->last_uri != NULL && strcmp (ctxt->cfg->last_uri, uri)) { gnome_pilot_conduit_standard_set_slow (conduit, TRUE); @@ -897,23 +897,23 @@ pre_sync (GnomePilotConduit *conduit, /* Set the default timezone on the backend. */ if (ctxt->timezone) { - if (!cal_client_set_default_timezone (ctxt->client, ctxt->timezone, NULL)) + if (!e_cal_set_default_timezone (ctxt->client, ctxt->timezone, NULL)) return -1; } /* Get the default component */ - if (!cal_client_get_default_object (ctxt->client, &icalcomp, NULL)) + if (!e_cal_get_default_object (ctxt->client, &icalcomp, NULL)) return -1; - ctxt->default_comp = cal_component_new (); - if (!cal_component_set_icalcomponent (ctxt->default_comp, icalcomp)) { + ctxt->default_comp = e_cal_component_new (); + if (!e_cal_component_set_icalcomponent (ctxt->default_comp, icalcomp)) { g_object_unref (ctxt->default_comp); icalcomponent_free (icalcomp); return -1; } - ctxt->default_comp = cal_component_new (); - if (!cal_component_set_icalcomponent (ctxt->default_comp, icalcomp)) { + ctxt->default_comp = e_cal_component_new (); + if (!e_cal_component_set_icalcomponent (ctxt->default_comp, icalcomp)) { g_object_unref (ctxt->default_comp); icalcomponent_free (icalcomp); return -1; @@ -925,37 +925,37 @@ pre_sync (GnomePilotConduit *conduit, g_free (filename); /* Get the local database */ - if (!cal_client_get_object_list_as_comp (ctxt->client, "(#t)", &ctxt->comps, NULL)) + if (!e_cal_get_object_list_as_comp (ctxt->client, "(#t)", &ctxt->comps, NULL)) return -1; /* Count and hash the changes */ change_id = g_strdup_printf ("pilot-sync-evolution-todo-%d", ctxt->cfg->pilot_id); - if (!cal_client_get_changes (ctxt->client, change_id, &ctxt->changed, NULL)) + if (!e_cal_get_changes (ctxt->client, change_id, &ctxt->changed, NULL)) return -1; ctxt->changed_hash = g_hash_table_new (g_str_hash, g_str_equal); g_free (change_id); for (l = ctxt->changed; l != NULL; l = l->next) { - CalClientChange *ccc = l->data; + ECalChange *ccc = l->data; const char *uid; - cal_component_get_uid (ccc->comp, &uid); + e_cal_component_get_uid (ccc->comp, &uid); if (!e_pilot_map_uid_is_archived (ctxt->map, uid)) { g_hash_table_insert (ctxt->changed_hash, g_strdup (uid), ccc); switch (ccc->type) { - case CAL_CLIENT_CHANGE_ADDED: + case E_CAL_CHANGE_ADDED: add_records++; break; - case CAL_CLIENT_CHANGE_MODIFIED: + case E_CAL_CHANGE_MODIFIED: mod_records++; break; - case CAL_CLIENT_CHANGE_DELETED: + case E_CAL_CHANGE_DELETED: del_records++; break; } - } else if (ccc->type == CAL_CLIENT_CHANGE_DELETED) { + } else if (ccc->type == E_CAL_CHANGE_DELETED) { e_pilot_map_remove_by_uid (ctxt->map, uid); } } @@ -1000,7 +1000,7 @@ post_sync (GnomePilotConduit *conduit, LOG (g_message ( "post_sync: ToDo Conduit v.%s", CONDUIT_VERSION )); g_free (ctxt->cfg->last_uri); - ctxt->cfg->last_uri = g_strdup (cal_client_get_uri (ctxt->client)); + ctxt->cfg->last_uri = g_strdup (e_cal_get_uri (ctxt->client)); todoconduit_save_configuration (ctxt->cfg); filename = map_name (ctxt); @@ -1011,8 +1011,8 @@ post_sync (GnomePilotConduit *conduit, * a race condition if anyone changes a record elsewhere during sycnc */ change_id = g_strdup_printf ("pilot-sync-evolution-todo-%d", ctxt->cfg->pilot_id); - if (cal_client_get_changes (ctxt->client, change_id, &changed, NULL)) - cal_client_change_list_free (changed); + if (e_cal_get_changes (ctxt->client, change_id, &changed, NULL)) + e_cal_change_list_free (changed); g_free (change_id); LOG (g_message ( "---------------------------------------------------------\n" )); @@ -1030,7 +1030,7 @@ set_pilot_id (GnomePilotConduitSyncAbs *conduit, LOG (g_message ( "set_pilot_id: setting to %d\n", ID )); - cal_component_get_uid (local->comp, &uid); + e_cal_component_get_uid (local->comp, &uid); e_pilot_map_insert (ctxt->map, ID, uid, FALSE); return 0; @@ -1045,7 +1045,7 @@ set_status_cleared (GnomePilotConduitSyncAbs *conduit, LOG (g_message ( "set_status_cleared: clearing status\n" )); - cal_component_get_uid (local->comp, &uid); + e_cal_component_get_uid (local->comp, &uid); g_hash_table_remove (ctxt->changed_hash, uid); return 0; @@ -1122,7 +1122,7 @@ for_each_modified (GnomePilotConduitSyncAbs *conduit, iterator = next_changed_item (ctxt, iterator); if (iterator != NULL) { - CalClientChange *ccc = iterator->data; + ECalChange *ccc = iterator->data; *local = g_new0 (EToDoLocalRecord, 1); local_record_from_comp (*local, ccc->comp, ctxt); @@ -1136,7 +1136,7 @@ for_each_modified (GnomePilotConduitSyncAbs *conduit, count++; iterator = g_list_next (iterator); if (iterator && (iterator = next_changed_item (ctxt, iterator))) { - CalClientChange *ccc = iterator->data; + ECalChange *ccc = iterator->data; *local = g_new0 (EToDoLocalRecord, 1); local_record_from_comp (*local, ccc->comp, ctxt); @@ -1187,7 +1187,7 @@ add_record (GnomePilotConduitSyncAbs *conduit, GnomePilotRecord *remote, EToDoConduitContext *ctxt) { - CalComponent *comp; + ECalComponent *comp; char *uid; int retval = 0; @@ -1198,10 +1198,10 @@ add_record (GnomePilotConduitSyncAbs *conduit, comp = comp_from_remote_record (conduit, remote, ctxt->default_comp, ctxt->timezone); /* Give it a new UID otherwise it will be the uid of the default comp */ - uid = cal_component_gen_uid (); - cal_component_set_uid (comp, uid); + uid = e_cal_component_gen_uid (); + e_cal_component_set_uid (comp, uid); - if (!cal_client_create_object (ctxt->client, cal_component_get_icalcomponent (comp), NULL, NULL)) + if (!e_cal_create_object (ctxt->client, e_cal_component_get_icalcomponent (comp), NULL, NULL)) return -1; e_pilot_map_insert (ctxt->map, remote->ID, uid, FALSE); @@ -1217,7 +1217,7 @@ replace_record (GnomePilotConduitSyncAbs *conduit, GnomePilotRecord *remote, EToDoConduitContext *ctxt) { - CalComponent *new_comp; + ECalComponent *new_comp; int retval = 0; g_return_val_if_fail (remote != NULL, -1); @@ -1229,7 +1229,7 @@ replace_record (GnomePilotConduitSyncAbs *conduit, g_object_unref (local->comp); local->comp = new_comp; - if (!cal_client_modify_object (ctxt->client, cal_component_get_icalcomponent (new_comp), + if (!e_cal_modify_object (ctxt->client, e_cal_component_get_icalcomponent (new_comp), CALOBJ_MOD_ALL, NULL)) return -1; @@ -1246,13 +1246,13 @@ delete_record (GnomePilotConduitSyncAbs *conduit, g_return_val_if_fail (local != NULL, -1); g_return_val_if_fail (local->comp != NULL, -1); - cal_component_get_uid (local->comp, &uid); + e_cal_component_get_uid (local->comp, &uid); LOG (g_message ( "delete_record: deleting %s\n", uid )); e_pilot_map_remove_by_uid (ctxt->map, uid); /* FIXME Error handling */ - cal_client_remove_object (ctxt->client, uid, NULL); + e_cal_remove_object (ctxt->client, uid, NULL); return 0; } @@ -1270,7 +1270,7 @@ archive_record (GnomePilotConduitSyncAbs *conduit, LOG (g_message ( "archive_record: %s\n", archive ? "yes" : "no" )); - cal_component_get_uid (local->comp, &uid); + e_cal_component_get_uid (local->comp, &uid); e_pilot_map_insert (ctxt->map, local->local.ID, uid, archive); return retval; diff --git a/calendar/gui/Makefile.am b/calendar/gui/Makefile.am index ae623b84db..d05ae4dbc7 100644 --- a/calendar/gui/Makefile.am +++ b/calendar/gui/Makefile.am @@ -5,6 +5,19 @@ IDLS = \ $(top_srcdir)/calendar/idl/evolution-calendar.idl \ $(top_srcdir)/addressbook/gui/component/select-names/Evolution-Addressbook-SelectNames.idl +CALENDAR_IDL_GENERATED_H = \ + evolution-calendar.h +CALENDAR_IDL_GENERATED_C = \ + evolution-calendar-common.c \ + evolution-calendar-skels.c \ + evolution-calendar-stubs.c +CALENDAR_IDL_GENERATED = $(CALENDAR_IDL_GENERATED_C) $(CALENDAR_IDL_GENERATED_H) + +$(CALENDAR_IDL_GENERATED_H): $(IDLS) + $(ORBIT_IDL) -I $(srcdir) $(IDL_INCLUDES) \ + $(top_srcdir)/calendar/idl/evolution-calendar.idl +$(CALENDAR_IDL_GENERATED_C): $(CALENDAR_IDL_GENERATED_H) + # Message composer IDL files COMPOSER_IDL_GENERATED_H = \ @@ -20,7 +33,6 @@ $(COMPOSER_IDL_GENERATED_H): $(IDLS) $(srcdir)/../../composer/Evolution-Composer.idl $(COMPOSER_IDL_GENERATED_C): $(COMPOSER_IDL_GENERATED_H) - # SelectNames IDL files SELECT_NAMES_IDL_GENERATED_H = \ @@ -37,8 +49,11 @@ $(SELECT_NAMES_IDL_GENERATED_H): $(IDLS) $(SELECT_NAMES_IDL_GENERATED_C): $(SELECT_NAMES_IDL_GENERATED_H) -IDL_GENERATED = $(COMPOSER_IDL_GENERATED) $(SELECT_NAMES_IDL_GENERATED) +IDL_GENERATED = $(CALENDAR_IDL_GENERATED) $(COMPOSER_IDL_GENERATED) $(SELECT_NAMES_IDL_GENERATED) +# The marshallers +MARSHAL_GENERATED = e-calendar-marshal.c e-calendar-marshal.h +@EVO_MARSHAL_RULE@ SUBDIRS = alarm-notify dialogs @@ -53,8 +68,6 @@ INCLUDES = \ -I$(top_srcdir)/calendar/cal-client \ -I$(top_builddir)/calendar/cal-client \ -I$(top_srcdir)/libical/src \ - -I$(top_srcdir)/addressbook/backend \ - -I$(top_builddir)/addressbook/backend \ -I$(top_srcdir)/widgets \ -I$(top_srcdir)/a11y/calendar \ -DEVOLUTION_DATADIR=\""$(datadir)"\" \ @@ -77,6 +90,7 @@ etspec_DATA = \ libevolution_calendar_la_SOURCES = \ $(IDL_GENERATED) \ + $(MARSHAL_GENERATED) \ cal-search-bar.c \ cal-search-bar.h \ calendar-config.c \ @@ -203,8 +217,6 @@ libevolution_calendar_la_LIBADD = \ $(DB3_LDADD) \ $(top_builddir)/widgets/menus/libmenus.la \ $(top_builddir)/shell/libeshell.la \ - $(top_builddir)/calendar/cal-client/libcal-client.la \ - $(top_builddir)/addressbook/backend/ebook/libebook.la \ $(top_builddir)/calendar/gui/dialogs/libcal-dialogs.la \ $(top_builddir)/widgets/e-timezone-dialog/libetimezonedialog.la \ $(top_builddir)/widgets/misc/libemiscwidgets.la \ @@ -226,6 +238,7 @@ schemadir = $(GCONF_SCHEMA_FILE_DIR) schema_DATA = apps_evolution_calendar.schemas EXTRA_DIST = \ + e-calendar-marshal.list \ $(glade_DATA) \ $(schema_DATA) \ $(etspec_DATA) \ diff --git a/calendar/gui/alarm-notify/Makefile.am b/calendar/gui/alarm-notify/Makefile.am index 82ecd516cf..6e1675aaa9 100644 --- a/calendar/gui/alarm-notify/Makefile.am +++ b/calendar/gui/alarm-notify/Makefile.am @@ -20,9 +20,6 @@ privlibexec_PROGRAMS = evolution-alarm-notify INCLUDES = \ -DG_LOG_DOMAIN=\"evolution-alarm-notify\" \ -I$(top_srcdir) \ - -I$(top_srcdir)/calendar \ - -I$(top_builddir)/calendar \ - -I$(top_srcdir)/libical/src \ -I$(top_srcdir)/widgets \ -DEVOLUTION_GLADEDIR=\""$(gladedir)"\" \ -DEVOLUTION_IMAGESDIR=\""$(imagesdir)"\" \ @@ -51,8 +48,7 @@ evolution_alarm_notify_SOURCES = \ util.h evolution_alarm_notify_LDADD = \ - $(top_builddir)/calendar/cal-client/libcal-client.la \ - $(top_builddir)/calendar/cal-util/libcal-util.la \ + $(top_builddir)/e-util/libeutil.la \ $(EVOLUTION_CALENDAR_LIBS) server_in_files = GNOME_Evolution_Calendar_AlarmNotify.server.in.in diff --git a/calendar/gui/alarm-notify/alarm-notify-dialog.c b/calendar/gui/alarm-notify/alarm-notify-dialog.c index 3697fc1290..d1db74ae80 100644 --- a/calendar/gui/alarm-notify/alarm-notify-dialog.c +++ b/calendar/gui/alarm-notify/alarm-notify-dialog.c @@ -37,7 +37,7 @@ #include <gal/widgets/e-unicode.h> #include <gtkhtml/gtkhtml.h> #include <gtkhtml/gtkhtml-stream.h> -#include "cal-util/timeutil.h" +#include <libecal/e-cal-time-util.h> #include "alarm-notify-dialog.h" #include "config-data.h" #include "util.h" @@ -219,7 +219,7 @@ write_times (GtkHTMLStream *stream, char *start, char *end) /* Creates a heading for the alarm notification dialog */ static void write_html_heading (GtkHTMLStream *stream, const char *message, - CalComponentVType vtype, time_t occur_start, time_t occur_end) + ECalComponentVType vtype, time_t occur_start, time_t occur_end) { char *buf; char *start, *end; @@ -258,11 +258,11 @@ write_html_heading (GtkHTMLStream *stream, const char *message, /* Write the times */ switch (vtype) { - case CAL_COMPONENT_EVENT: + case E_CAL_COMPONENT_EVENT: write_times (stream, start, end); break; - case CAL_COMPONENT_TODO: + case E_CAL_COMPONENT_TODO: write_times (stream, start, end); break; @@ -293,7 +293,7 @@ write_html_heading (GtkHTMLStream *stream, const char *message, **/ gpointer alarm_notify_dialog (time_t trigger, time_t occur_start, time_t occur_end, - CalComponentVType vtype, const char *message, + ECalComponentVType vtype, const char *message, AlarmNotifyFunc func, gpointer func_data) { AlarmNotify *an; @@ -304,7 +304,7 @@ alarm_notify_dialog (time_t trigger, time_t occur_start, time_t occur_end, g_return_val_if_fail (trigger != -1, NULL); /* Only VEVENTs or VTODOs can have alarms */ - g_return_val_if_fail (vtype == CAL_COMPONENT_EVENT || vtype == CAL_COMPONENT_TODO, NULL); + g_return_val_if_fail (vtype == E_CAL_COMPONENT_EVENT || vtype == E_CAL_COMPONENT_TODO, NULL); g_return_val_if_fail (message != NULL, NULL); g_return_val_if_fail (func != NULL, NULL); diff --git a/calendar/gui/alarm-notify/alarm-notify-dialog.h b/calendar/gui/alarm-notify/alarm-notify-dialog.h index 39cadbca0b..9bebce0a08 100644 --- a/calendar/gui/alarm-notify/alarm-notify-dialog.h +++ b/calendar/gui/alarm-notify/alarm-notify-dialog.h @@ -23,7 +23,7 @@ #include <time.h> #include <glib.h> -#include <cal-util/cal-component.h> +#include <libecal/e-cal-component.h> @@ -36,7 +36,7 @@ typedef enum { typedef void (* AlarmNotifyFunc) (AlarmNotifyResult result, int snooze_mins, gpointer data); gpointer alarm_notify_dialog (time_t trigger, time_t occur_start, time_t occur_end, - CalComponentVType vtype, const char *message, + ECalComponentVType vtype, const char *message, AlarmNotifyFunc func, gpointer func_data); void alarm_notify_dialog_disable_buttons (gpointer dialog); diff --git a/calendar/gui/alarm-notify/alarm-notify.c b/calendar/gui/alarm-notify/alarm-notify.c index ce73223afb..267a1001ca 100644 --- a/calendar/gui/alarm-notify/alarm-notify.c +++ b/calendar/gui/alarm-notify/alarm-notify.c @@ -23,7 +23,7 @@ #endif #include <string.h> -#include <cal-client/cal-client.h> +#include <libecal/e-cal.h> #include "alarm-notify.h" #include "alarm-queue.h" #include "save.h" @@ -92,7 +92,7 @@ static void free_client_hash (gpointer key, gpointer value, gpointer user_data) { char *uri = key; - CalClient *client = value; + ECal *client = value; g_free (uri); g_object_unref (client); @@ -248,7 +248,7 @@ AlarmNotify_removeCalendar (PortableServer_Servant servant, { AlarmNotify *an; AlarmNotifyPrivate *priv; - CalClient *client; + ECal *client; an = ALARM_NOTIFY (bonobo_object_from_servant (servant)); priv = an->priv; @@ -299,7 +299,7 @@ alarm_notify_add_calendar (AlarmNotify *an, const char *str_uri, gboolean load_a CORBA_Environment *ev) { AlarmNotifyPrivate *priv; - CalClient *client; + ECal *client; g_return_if_fail (an != NULL); g_return_if_fail (IS_ALARM_NOTIFY (an)); @@ -312,10 +312,10 @@ alarm_notify_add_calendar (AlarmNotify *an, const char *str_uri, gboolean load_a if (g_hash_table_lookup (priv->uri_client_hash, str_uri)) return; - client = cal_client_new (str_uri, CALOBJ_TYPE_EVENT); + client = e_cal_new (str_uri, CALOBJ_TYPE_EVENT); if (client) { - if (cal_client_open (client, FALSE, NULL)) { + if (e_cal_open (client, FALSE, NULL)) { add_uri_to_load (str_uri); g_hash_table_insert (priv->uri_client_hash, diff --git a/calendar/gui/alarm-notify/alarm-queue.c b/calendar/gui/alarm-notify/alarm-queue.c index 774604c804..be9574d9d8 100644 --- a/calendar/gui/alarm-notify/alarm-queue.c +++ b/calendar/gui/alarm-notify/alarm-queue.c @@ -41,7 +41,8 @@ #include <libgnomeui/gnome-dialog-util.h> #include <libgnomeui/gnome-uidefs.h> #include <e-util/eggtrayicon.h> -#include <cal-util/timeutil.h> +#include <libecal/e-cal-time-util.h> +#include "evolution-calendar.h" #include "alarm.h" #include "alarm-notify-dialog.h" #include "alarm-queue.h" @@ -66,7 +67,7 @@ static GHashTable *client_alarms_hash = NULL; /* Structure that stores a client we are monitoring */ typedef struct { /* Monitored client */ - CalClient *client; + ECal *client; /* Number of times this client has been registered */ int refcount; @@ -80,7 +81,7 @@ typedef struct { GHashTable *uid_alarms_hash; } ClientAlarms; -/* Pair of a CalComponentAlarms and the mapping from queued alarm IDs to the +/* Pair of a ECalComponentAlarms and the mapping from queued alarm IDs to the * actual alarm instance structures. */ typedef struct { @@ -91,7 +92,7 @@ typedef struct { char *uid; /* The actual component and its alarm instances */ - CalComponentAlarms *alarms; + ECalComponentAlarms *alarms; /* List of QueuedAlarm structures */ GSList *queued_alarms; @@ -106,7 +107,7 @@ typedef struct { gpointer alarm_id; /* Instance from our parent CompQueuedAlarms->alarms->alarms list */ - CalAlarmInstance *instance; + ECalComponentAlarmInstance *instance; /* Whether this is a snoozed queued alarm or a normal one */ guint snooze : 1; @@ -176,7 +177,7 @@ midnight_refresh_cb (gpointer alarm_id, time_t trigger, gpointer data) /* Looks up a client in the client alarms hash table */ static ClientAlarms * -lookup_client (CalClient *client) +lookup_client (ECal *client) { return g_hash_table_lookup (client_alarms_hash, client); } @@ -226,7 +227,7 @@ remove_queued_alarm (CompQueuedAlarms *cqa, gpointer alarm_id, if (remove_alarm) { cqa->expecting_update = TRUE; - cal_client_discard_alarm (cqa->parent_client->client, cqa->alarms->comp, + e_cal_discard_alarm (cqa->parent_client->client, cqa->alarms->comp, qa->instance->auid, NULL); cqa->expecting_update = FALSE; } @@ -245,10 +246,10 @@ remove_queued_alarm (CompQueuedAlarms *cqa, gpointer alarm_id, g_free (cqa->uid); cqa->uid = NULL; cqa->parent_client = NULL; - cal_component_alarms_free (cqa->alarms); + e_cal_component_alarms_free (cqa->alarms); g_free (cqa); } else { - cal_component_alarms_free (cqa->alarms); + e_cal_component_alarms_free (cqa->alarms); cqa->alarms = NULL; } } @@ -258,10 +259,10 @@ static void alarm_trigger_cb (gpointer alarm_id, time_t trigger, gpointer data) { CompQueuedAlarms *cqa; - CalComponent *comp; + ECalComponent *comp; QueuedAlarm *qa; - CalComponentAlarm *alarm; - CalAlarmAction action; + ECalComponentAlarm *alarm; + ECalComponentAlarmAction action; cqa = data; comp = cqa->alarms->comp; @@ -279,26 +280,26 @@ alarm_trigger_cb (gpointer alarm_id, time_t trigger, gpointer data) * occurrence. */ - alarm = cal_component_get_alarm (comp, qa->instance->auid); + alarm = e_cal_component_get_alarm (comp, qa->instance->auid); g_assert (alarm != NULL); - cal_component_alarm_get_action (alarm, &action); - cal_component_alarm_free (alarm); + e_cal_component_alarm_get_action (alarm, &action); + e_cal_component_alarm_free (alarm); switch (action) { - case CAL_ALARM_AUDIO: + case E_CAL_COMPONENT_ALARM_AUDIO: audio_notification (trigger, cqa, alarm_id); break; - case CAL_ALARM_DISPLAY: + case E_CAL_COMPONENT_ALARM_DISPLAY: display_notification (trigger, cqa, alarm_id, TRUE); break; - case CAL_ALARM_EMAIL: + case E_CAL_COMPONENT_ALARM_EMAIL: mail_notification (trigger, cqa, alarm_id); break; - case CAL_ALARM_PROCEDURE: + case E_CAL_COMPONENT_ALARM_PROCEDURE: procedure_notification (trigger, cqa, alarm_id); break; @@ -308,11 +309,11 @@ alarm_trigger_cb (gpointer alarm_id, time_t trigger, gpointer data) } } -/* Adds the alarms in a CalComponentAlarms structure to the alarms queued for a +/* Adds the alarms in a ECalComponentAlarms structure to the alarms queued for a * particular client. Also puts the triggers in the alarm timer queue. */ static void -add_component_alarms (ClientAlarms *ca, CalComponentAlarms *alarms) +add_component_alarms (ClientAlarms *ca, ECalComponentAlarms *alarms) { const char *uid; CompQueuedAlarms *cqa; @@ -320,7 +321,7 @@ add_component_alarms (ClientAlarms *ca, CalComponentAlarms *alarms) /* No alarms? */ if (alarms->alarms == NULL) { - cal_component_alarms_free (alarms); + e_cal_component_alarms_free (alarms); return; } @@ -332,7 +333,7 @@ add_component_alarms (ClientAlarms *ca, CalComponentAlarms *alarms) cqa->queued_alarms = NULL; for (l = alarms->alarms; l; l = l->next) { - CalAlarmInstance *instance; + ECalComponentAlarmInstance *instance; gpointer alarm_id; QueuedAlarm *qa; @@ -353,14 +354,14 @@ add_component_alarms (ClientAlarms *ca, CalComponentAlarms *alarms) cqa->queued_alarms = g_slist_prepend (cqa->queued_alarms, qa); } - cal_component_get_uid (alarms->comp, &uid); + e_cal_component_get_uid (alarms->comp, &uid); /* If we failed to add all the alarms, then we should get rid of the cqa */ if (cqa->queued_alarms == NULL) { g_message ("add_component_alarms(): Could not add any of the alarms " "for the component `%s'; discarding it...", uid); - cal_component_alarms_free (cqa->alarms); + e_cal_component_alarms_free (cqa->alarms); cqa->alarms = NULL; g_free (cqa); @@ -379,10 +380,10 @@ load_alarms (ClientAlarms *ca, time_t start, time_t end) GSList *comp_alarms; GSList *l; - comp_alarms = cal_client_get_alarms_in_range (ca->client, start, end); + comp_alarms = e_cal_get_alarms_in_range (ca->client, start, end); for (l = comp_alarms; l; l = l->next) { - CalComponentAlarms *alarms; + ECalComponentAlarms *alarms; alarms = l->data; add_component_alarms (ca, alarms); @@ -427,13 +428,13 @@ load_missed_alarms (ClientAlarms *ca) /* Called when a calendar client finished loading; we load its alarms */ static void -cal_opened_cb (CalClient *client, CalClientOpenStatus status, gpointer data) +cal_opened_cb (ECal *client, ECalOpenStatus status, gpointer data) { ClientAlarms *ca; ca = data; - if (status != CAL_CLIENT_OPEN_SUCCESS) + if (status != E_CAL_OPEN_SUCCESS) return; load_alarms_for_today (ca); @@ -496,11 +497,11 @@ remove_comp (ClientAlarms *ca, const char *uid) * alarms. */ static void -obj_updated_cb (CalClient *client, const char *uid, gpointer data) +obj_updated_cb (ECal *client, const char *uid, gpointer data) { ClientAlarms *ca; time_t now, day_end; - CalComponentAlarms *alarms; + ECalComponentAlarms *alarms; gboolean found; icaltimezone *zone; CompQueuedAlarms *cqa; @@ -513,7 +514,7 @@ obj_updated_cb (CalClient *client, const char *uid, gpointer data) day_end = time_day_end_with_zone (now, zone); - found = cal_client_get_alarms_for_object (ca->client, uid, now, day_end, &alarms); + found = e_cal_get_alarms_for_object (ca->client, uid, now, day_end, &alarms); if (!found) { remove_comp (ca, uid); @@ -533,7 +534,7 @@ obj_updated_cb (CalClient *client, const char *uid, gpointer data) /* add the new alarms */ for (l = cqa->alarms->alarms; l; l = l->next) { - CalAlarmInstance *instance; + ECalComponentAlarmInstance *instance; gpointer alarm_id; QueuedAlarm *qa; @@ -566,7 +567,7 @@ obj_updated_cb (CalClient *client, const char *uid, gpointer data) * alarms. */ static void -obj_removed_cb (CalClient *client, const char *uid, gpointer data) +obj_removed_cb (ECal *client, const char *uid, gpointer data) { ClientAlarms *ca; @@ -610,16 +611,16 @@ create_snooze (CompQueuedAlarms *cqa, gpointer alarm_id, int snooze_mins) /* Launches a component editor for a component */ static void -edit_component (CalClient *client, CalComponent *comp) +edit_component (ECal *client, ECalComponent *comp) { const char *uid; const char *uri; CORBA_Environment ev; GNOME_Evolution_Calendar_CompEditorFactory factory; - cal_component_get_uid (comp, &uid); + e_cal_component_get_uid (comp, &uid); - uri = cal_client_get_uri (client); + uri = e_cal_get_uri (client); /* Get the factory */ @@ -695,15 +696,15 @@ typedef struct { time_t trigger; CompQueuedAlarms *cqa; gpointer alarm_id; - CalComponent *comp; - CalClient *client; + ECalComponent *comp; + ECal *client; GtkWidget *tray_icon; GtkWidget *image; GtkWidget *alarm_dialog; } TrayIconData; static void -on_dialog_obj_updated_cb (CalClient *client, const char *uid, gpointer data) +on_dialog_obj_updated_cb (ECal *client, const char *uid, gpointer data) { /* commented out so gcc won't complain about the unused variable struct notify_dialog_closure *c = data; @@ -711,12 +712,12 @@ on_dialog_obj_updated_cb (CalClient *client, const char *uid, gpointer data) } static void -on_dialog_obj_removed_cb (CalClient *client, const char *uid, gpointer data) +on_dialog_obj_removed_cb (ECal *client, const char *uid, gpointer data) { const char *our_uid; TrayIconData *tray_data = data; - cal_component_get_uid (tray_data->comp, &our_uid); + e_cal_component_get_uid (tray_data->comp, &our_uid); g_return_if_fail (our_uid && *our_uid); if (!strcmp (uid, our_uid)) { @@ -798,7 +799,7 @@ tray_icon_clicked_cb (GtkWidget *widget, GdkEventButton *event, gpointer user_da tray_data->trigger, qa->instance->occur_start, qa->instance->occur_end, - cal_component_get_vtype (tray_data->comp), + e_cal_component_get_vtype (tray_data->comp), tray_data->message, notify_dialog_cb, tray_data); if (tray_data->alarm_dialog) { @@ -838,15 +839,15 @@ display_notification (time_t trigger, CompQueuedAlarms *cqa, gpointer alarm_id, gboolean use_description) { QueuedAlarm *qa; - CalComponent *comp; - CalClient *client; - CalComponentVType vtype; + ECalComponent *comp; + ECal *client; + ECalComponentVType vtype; const char *message; - CalComponentAlarm *alarm; + ECalComponentAlarm *alarm; GtkWidget *tray_icon, *image, *ebox; GtkTooltips *tooltips; TrayIconData *tray_data; - CalComponentText text; + ECalComponentText text; char *str, *start_str, *end_str, *alarm_str; icaltimezone *current_zone; @@ -855,19 +856,19 @@ display_notification (time_t trigger, CompQueuedAlarms *cqa, if (!qa) return; - vtype = cal_component_get_vtype (comp); + vtype = e_cal_component_get_vtype (comp); /* get a sensible description for the event */ - alarm = cal_component_get_alarm (comp, qa->instance->auid); + alarm = e_cal_component_get_alarm (comp, qa->instance->auid); g_assert (alarm != NULL); - cal_component_alarm_get_description (alarm, &text); - cal_component_alarm_free (alarm); + e_cal_component_alarm_get_description (alarm, &text); + e_cal_component_alarm_free (alarm); if (text.value) message = text.value; else { - cal_component_get_summary (comp, &text); + e_cal_component_get_summary (comp, &text); if (text.value) message = text.value; else @@ -909,7 +910,7 @@ display_notification (time_t trigger, CompQueuedAlarms *cqa, tray_data->trigger = trigger; tray_data->cqa = cqa; tray_data->alarm_id = alarm_id; - tray_data->comp = cal_component_clone (comp); + tray_data->comp = e_cal_component_clone (comp); tray_data->client = cqa->parent_client->client; tray_data->image = image; tray_data->blink_state = FALSE; @@ -932,8 +933,8 @@ audio_notification (time_t trigger, CompQueuedAlarms *cqa, gpointer alarm_id) { QueuedAlarm *qa; - CalComponent *comp; - CalComponentAlarm *alarm; + ECalComponent *comp; + ECalComponentAlarm *alarm; icalattach *attach; comp = cqa->alarms->comp; @@ -941,11 +942,11 @@ audio_notification (time_t trigger, CompQueuedAlarms *cqa, if (!qa) return; - alarm = cal_component_get_alarm (comp, qa->instance->auid); + alarm = e_cal_component_get_alarm (comp, qa->instance->auid); g_assert (alarm != NULL); - cal_component_alarm_get_attach (alarm, &attach); - cal_component_alarm_free (alarm); + e_cal_component_alarm_get_attach (alarm, &attach); + e_cal_component_alarm_free (alarm); if (attach && icalattach_get_is_url (attach)) { const char *url; @@ -1038,9 +1039,9 @@ static void procedure_notification (time_t trigger, CompQueuedAlarms *cqa, gpointer alarm_id) { QueuedAlarm *qa; - CalComponent *comp; - CalComponentAlarm *alarm; - CalComponentText description; + ECalComponent *comp; + ECalComponentAlarm *alarm; + ECalComponentText description; icalattach *attach; const char *url; char *cmd; @@ -1051,12 +1052,12 @@ procedure_notification (time_t trigger, CompQueuedAlarms *cqa, gpointer alarm_id if (!qa) return; - alarm = cal_component_get_alarm (comp, qa->instance->auid); + alarm = e_cal_component_get_alarm (comp, qa->instance->auid); g_assert (alarm != NULL); - cal_component_alarm_get_attach (alarm, &attach); - cal_component_alarm_get_description (alarm, &description); - cal_component_alarm_free (alarm); + e_cal_component_alarm_get_attach (alarm, &attach); + e_cal_component_alarm_get_description (alarm, &description); + e_cal_component_alarm_free (alarm); /* If the alarm has no attachment, simply display a notification dialog. */ if (!attach) @@ -1125,7 +1126,7 @@ alarm_queue_init (void) static void free_client_alarms_cb (gpointer key, gpointer value, gpointer user_data) { - CalClient *client = key; + ECal *client = key; ClientAlarms *ca = value; if (ca) { @@ -1175,13 +1176,13 @@ alarm_queue_done (void) * queueing system when it is no longer wanted. **/ void -alarm_queue_add_client (CalClient *client) +alarm_queue_add_client (ECal *client) { ClientAlarms *ca; g_return_if_fail (alarm_queue_inited); g_return_if_fail (client != NULL); - g_return_if_fail (IS_CAL_CLIENT (client)); + g_return_if_fail (E_IS_CAL (client)); ca = lookup_client (client); if (ca) { @@ -1199,7 +1200,7 @@ alarm_queue_add_client (CalClient *client) ca->uid_alarms_hash = g_hash_table_new (g_str_hash, g_str_equal); - if (cal_client_get_load_state (client) != CAL_CLIENT_LOAD_LOADED) + if (e_cal_get_load_state (client) != E_CAL_LOAD_LOADED) g_signal_connect (client, "cal_opened", G_CALLBACK (cal_opened_cb), ca); @@ -1211,7 +1212,7 @@ alarm_queue_add_client (CalClient *client) G_CALLBACK (obj_removed_cb), ca); - if (cal_client_get_load_state (client) == CAL_CLIENT_LOAD_LOADED) { + if (e_cal_get_load_state (client) == E_CAL_LOAD_LOADED) { load_alarms_for_today (ca); load_missed_alarms (ca); } @@ -1264,13 +1265,13 @@ remove_client_alarms (ClientAlarms *ca) * Removes a calendar client from the alarm queueing system. **/ void -alarm_queue_remove_client (CalClient *client) +alarm_queue_remove_client (ECal *client) { ClientAlarms *ca; g_return_if_fail (alarm_queue_inited); g_return_if_fail (client != NULL); - g_return_if_fail (IS_CAL_CLIENT (client)); + g_return_if_fail (E_IS_CAL (client)); ca = lookup_client (client); g_return_if_fail (ca != NULL); diff --git a/calendar/gui/alarm-notify/alarm-queue.h b/calendar/gui/alarm-notify/alarm-queue.h index a37119145f..12802750ec 100644 --- a/calendar/gui/alarm-notify/alarm-queue.h +++ b/calendar/gui/alarm-notify/alarm-queue.h @@ -21,14 +21,14 @@ #ifndef ALARM_QUEUE_H #define ALARM_QUEUE_H -#include <cal-client/cal-client.h> +#include <libecal/e-cal.h> void alarm_queue_init (void); void alarm_queue_done (void); -void alarm_queue_add_client (CalClient *client); -void alarm_queue_remove_client (CalClient *client); +void alarm_queue_add_client (ECal *client); +void alarm_queue_remove_client (ECal *client); #endif diff --git a/calendar/gui/alarm-notify/util.c b/calendar/gui/alarm-notify/util.c index f40943d9b0..4bc91810a5 100644 --- a/calendar/gui/alarm-notify/util.c +++ b/calendar/gui/alarm-notify/util.c @@ -21,7 +21,7 @@ #include <libgnome/gnome-i18n.h> #include <e-util/e-time-utils.h> -#include <cal-util/timeutil.h> +#include <libecal/e-cal-time-util.h> #include "config-data.h" #include "util.h" diff --git a/calendar/gui/alarm-notify/util.h b/calendar/gui/alarm-notify/util.h index ab4cc4f995..7dae3dd7fe 100644 --- a/calendar/gui/alarm-notify/util.h +++ b/calendar/gui/alarm-notify/util.h @@ -22,7 +22,7 @@ #ifndef UTIL_H #define UTIL_H -#include <cal-util/cal-component.h> +#include <libecal/e-cal-component.h> char *timet_to_str_with_zone (time_t t, icaltimezone *zone); diff --git a/calendar/gui/cal-search-bar.c b/calendar/gui/cal-search-bar.c index d04cbcb492..3bc9143215 100644 --- a/calendar/gui/cal-search-bar.c +++ b/calendar/gui/cal-search-bar.c @@ -225,7 +225,7 @@ get_current_category (CalSearchBar *cal_search) /* Sets the query string to be (contains? "field" "text") */ static void -notify_query_contains (CalSearchBar *cal_search, const char *field) +notify_e_cal_view_contains (CalSearchBar *cal_search, const char *field) { char *text; char *sexp; @@ -294,19 +294,19 @@ regen_query (CalSearchBar *cal_search) switch (id) { case SEARCH_ANY_FIELD_CONTAINS: - notify_query_contains (cal_search, "any"); + notify_e_cal_view_contains (cal_search, "any"); break; case SEARCH_SUMMARY_CONTAINS: - notify_query_contains (cal_search, "summary"); + notify_e_cal_view_contains (cal_search, "summary"); break; case SEARCH_DESCRIPTION_CONTAINS: - notify_query_contains (cal_search, "description"); + notify_e_cal_view_contains (cal_search, "description"); break; case SEARCH_COMMENT_CONTAINS: - notify_query_contains (cal_search, "comment"); + notify_e_cal_view_contains (cal_search, "comment"); break; case SEARCH_CATEGORY_IS: diff --git a/calendar/gui/calendar-commands.c b/calendar/gui/calendar-commands.c index 5dbce1ec54..c63075f5ea 100644 --- a/calendar/gui/calendar-commands.c +++ b/calendar/gui/calendar-commands.c @@ -49,7 +49,7 @@ #include <bonobo/bonobo-ui-util.h> #include <bonobo/bonobo-exception.h> #include <gal/util/e-util.h> -#include <cal-util/timeutil.h> +#include <libecal/e-cal-time-util.h> #include "shell/Evolution.h" #include "calendar-commands.h" #include "calendar-config.h" @@ -86,13 +86,13 @@ file_new_appointment_cb (BonoboUIComponent *uic, gpointer data, const char *path { GnomeCalendar *gcal; time_t dtstart, dtend; - ECalView *cal_view; + ECalendarView *cal_view; gcal = GNOME_CALENDAR (data); - cal_view = (ECalView *) gnome_calendar_get_current_view_widget (gcal); - e_cal_view_get_selected_time_range (cal_view, &dtstart, &dtend); - e_cal_view_new_appointment_for (cal_view, dtstart, dtend, FALSE, FALSE); + cal_view = (ECalendarView *) gnome_calendar_get_current_view_widget (gcal); + e_calendar_view_get_selected_time_range (cal_view, &dtstart, &dtend); + e_calendar_view_new_appointment_for (cal_view, dtstart, dtend, FALSE, FALSE); } static void @@ -100,13 +100,13 @@ file_new_event_cb (BonoboUIComponent *uic, gpointer data, const char *path) { GnomeCalendar *gcal; time_t dtstart, dtend; - ECalView *cal_view; + ECalendarView *cal_view; gcal = GNOME_CALENDAR (data); - cal_view = (ECalView *) gnome_calendar_get_current_view_widget (gcal); - e_cal_view_get_selected_time_range (cal_view, &dtstart, &dtend); - e_cal_view_new_appointment_for (cal_view, dtstart, dtend, TRUE, FALSE); + cal_view = (ECalendarView *) gnome_calendar_get_current_view_widget (gcal); + e_calendar_view_get_selected_time_range (cal_view, &dtstart, &dtend); + e_calendar_view_new_appointment_for (cal_view, dtstart, dtend, TRUE, FALSE); } static void @@ -114,13 +114,13 @@ file_new_meeting_cb (BonoboUIComponent *uic, gpointer data, const char *path) { GnomeCalendar *gcal; time_t dtstart, dtend; - ECalView *cal_view; + ECalendarView *cal_view; gcal = GNOME_CALENDAR (data); - cal_view = (ECalView *) gnome_calendar_get_current_view_widget (gcal); - e_cal_view_get_selected_time_range (cal_view, &dtstart, &dtend); - e_cal_view_new_appointment_for (cal_view, dtstart, dtend, FALSE, TRUE); + cal_view = (ECalendarView *) gnome_calendar_get_current_view_widget (gcal); + e_calendar_view_get_selected_time_range (cal_view, &dtstart, &dtend); + e_calendar_view_new_appointment_for (cal_view, dtstart, dtend, FALSE, TRUE); } static void @@ -386,12 +386,12 @@ publish_freebusy_cmd (BonoboUIComponent *uic, gpointer data, const gchar *path) /* FIXME Should we aggregate the data? */ client_list = e_cal_model_get_client_list (gnome_calendar_get_calendar_model (gcal)); for (cl = client_list; cl != NULL; cl = cl->next) { - if (cal_client_get_free_busy ((CalClient *) cl->data, NULL, start, end, &comp_list, NULL)) { + if (e_cal_get_free_busy ((ECal *) cl->data, NULL, start, end, &comp_list, NULL)) { GList *l; for (l = comp_list; l; l = l->next) { - CalComponent *comp = CAL_COMPONENT (l->data); - itip_send_comp (CAL_COMPONENT_METHOD_PUBLISH, comp, (CalClient *) cl->data, NULL); + ECalComponent *comp = E_CAL_COMPONENT (l->data); + itip_send_comp (E_CAL_COMPONENT_METHOD_PUBLISH, comp, (ECal *) cl->data, NULL); g_object_unref (comp); } @@ -649,28 +649,28 @@ void calendar_control_sensitize_calendar_commands (BonoboControl *control, GnomeCalendar *gcal, gboolean enable) { BonoboUIComponent *uic; - ECalViewEvent *event; + ECalendarViewEvent *event; GList *list; int n_selected; GtkWidget *view; - CalClient *cal_client; + ECal *e_cal; gboolean read_only = FALSE, has_recurrences; uic = bonobo_control_get_ui_component (control); g_assert (uic != NULL); view = gnome_calendar_get_current_view_widget (gcal); - list = e_cal_view_get_selected_events (E_CAL_VIEW (view)); + list = e_calendar_view_get_selected_events (E_CALENDAR_VIEW (view)); n_selected = enable ? g_list_length (list) : 0; - event = (ECalViewEvent *) list ? list->data : NULL; + event = (ECalendarViewEvent *) list ? list->data : NULL; if (event) { - cal_client_is_read_only (event->comp_data->client, &read_only, NULL); + e_cal_is_read_only (event->comp_data->client, &read_only, NULL); } else { - cal_client = e_cal_model_get_default_client (gnome_calendar_get_calendar_model (gcal)); - if (cal_client) - cal_client_is_read_only (cal_client, &read_only, NULL); + e_cal = e_cal_model_get_default_client (gnome_calendar_get_calendar_model (gcal)); + if (e_cal) + e_cal_is_read_only (e_cal, &read_only, NULL); else read_only = TRUE; } @@ -698,8 +698,8 @@ calendar_control_sensitize_calendar_commands (BonoboControl *control, GnomeCalen has_recurrences = FALSE; if (n_selected > 0 && !read_only) { if (list) { - event = (ECalViewEvent *) list->data; - if (cal_util_component_has_recurrences (event->comp_data->icalcomp)) + event = (ECalendarViewEvent *) list->data; + if (e_cal_util_component_has_recurrences (event->comp_data->icalcomp)) has_recurrences = TRUE; } } @@ -725,16 +725,16 @@ sensitize_taskpad_commands (GnomeCalendar *gcal, BonoboControl *control, gboolea { BonoboUIComponent *uic; int n_selected; - CalClient *cal_client; + ECal *e_cal; gboolean read_only = TRUE; uic = bonobo_control_get_ui_component (control); g_assert (uic != NULL); n_selected = enable ? gnome_calendar_get_num_tasks_selected (gcal) : 0; - cal_client = gnome_calendar_get_task_pad_cal_client (gcal); - if (cal_client) - cal_client_is_read_only (cal_client, &read_only, NULL); + e_cal = gnome_calendar_get_task_pad_e_cal (gcal); + if (e_cal) + e_cal_is_read_only (e_cal, &read_only, NULL); else read_only = TRUE; diff --git a/calendar/gui/calendar-config.c b/calendar/gui/calendar-config.c index 4282ea7d5c..250328fa10 100644 --- a/calendar/gui/calendar-config.c +++ b/calendar/gui/calendar-config.c @@ -38,7 +38,7 @@ #include <libgnomeui/gnome-dialog.h> #include <gal/util/e-util.h> #include <widgets/e-timezone-dialog/e-timezone-dialog.h> -#include <cal-util/timeutil.h> +#include <libecal/e-cal-time-util.h> #include "calendar-component.h" #include "calendar-commands.h" diff --git a/calendar/gui/calendar-offline-handler.c b/calendar/gui/calendar-offline-handler.c index ff30299746..bd8949bd00 100644 --- a/calendar/gui/calendar-offline-handler.c +++ b/calendar/gui/calendar-offline-handler.c @@ -32,14 +32,14 @@ #include <bonobo/bonobo-i18n.h> #include <gal/util/e-util.h> #include "e-util/e-url.h" -#include <cal-client/cal-client.h> +#include <libecal/e-cal.h> #include "calendar-offline-handler.h" #define PARENT_TYPE bonobo_object_get_type () static BonoboObjectClass *parent_class = NULL; struct _CalendarOfflineHandlerPrivate { - CalClient *client; + ECal *client; GNOME_Evolution_OfflineProgressListener listener_interface; @@ -76,7 +76,7 @@ create_connection_list (CalendarOfflineHandler *offline_handler) priv = offline_handler->priv; - uris = cal_client_uri_list (priv->client, CAL_MODE_REMOTE); + uris = e_cal_uri_list (priv->client, CAL_MODE_REMOTE); list = GNOME_Evolution_ConnectionList__alloc (); list->_length = 0; @@ -139,7 +139,7 @@ update_offline (CalendarOfflineHandler *offline_handler) } static void -backend_cal_set_mode (CalClient *client, CalClientSetModeStatus status, CalMode mode, gpointer data) +backend_cal_set_mode (ECal *client, ECalSetModeStatus status, CalMode mode, gpointer data) { CalendarOfflineHandler *offline_handler = data; @@ -148,29 +148,29 @@ backend_cal_set_mode (CalClient *client, CalClientSetModeStatus status, CalMode } static void -backend_cal_opened_offline (CalClient *client, CalClientOpenStatus status, gpointer data) +backend_cal_opened_offline (ECal *client, ECalOpenStatus status, gpointer data) { CalendarOfflineHandler *offline_handler = data; - if (status != CAL_CLIENT_OPEN_SUCCESS) { + if (status != E_CAL_OPEN_SUCCESS) { update_offline (offline_handler); g_object_unref (client); return; } g_signal_connect (client, "cal_set_mode", G_CALLBACK (backend_cal_set_mode), offline_handler); - cal_client_set_mode (client, CAL_MODE_LOCAL); + e_cal_set_mode (client, CAL_MODE_LOCAL); } static void -backend_cal_opened_online (CalClient *client, CalClientOpenStatus status, gpointer data) +backend_cal_opened_online (ECal *client, ECalOpenStatus status, gpointer data) { - if (status != CAL_CLIENT_OPEN_SUCCESS) { + if (status != E_CAL_OPEN_SUCCESS) { g_object_unref (G_OBJECT (client)); return; } - cal_client_set_mode (client, CAL_MODE_REMOTE); + e_cal_set_mode (client, CAL_MODE_REMOTE); g_object_unref (client); } @@ -179,13 +179,13 @@ backend_go_offline (gpointer data, gpointer user_data) { CalendarOfflineHandler *offline_handler = user_data; char *uri = data; - CalClient *client; + ECal *client; gboolean success; GError *error = NULL; - client = cal_client_new (uri, CALOBJ_TYPE_ANY); + client = e_cal_new (uri, CALOBJ_TYPE_ANY); g_signal_connect (client, "cal_opened", G_CALLBACK (backend_cal_opened_offline), offline_handler); - success = cal_client_open (client, TRUE, &error); + success = e_cal_open (client, TRUE, &error); if (!success) { g_warning (_("backend_go_offline(): %s"), error->message); update_offline (offline_handler); @@ -200,14 +200,14 @@ backend_go_online (gpointer data, gpointer user_data) { CalendarOfflineHandler *offline_handler = user_data; char *uri = data; - CalClient *client; + ECal *client; gboolean success; GError *error = NULL; - client = cal_client_new (uri, CALOBJ_TYPE_ANY); + client = e_cal_new (uri, CALOBJ_TYPE_ANY); g_signal_connect (G_OBJECT (client), "cal_opened", G_CALLBACK (backend_cal_opened_online), offline_handler); - success = cal_client_open (client, TRUE, &error); + success = e_cal_open (client, TRUE, &error); if (!success) { g_warning (_("backend_go_online(): %s"), error->message); g_object_unref (G_OBJECT (client)); @@ -231,7 +231,7 @@ impl_goOffline (PortableServer_Servant servant, /* To update the status */ priv->listener_interface = CORBA_Object_duplicate (progress_listener, ev); - uris = cal_client_uri_list (priv->client, CAL_MODE_REMOTE); + uris = e_cal_uri_list (priv->client, CAL_MODE_REMOTE); g_list_foreach (uris, backend_go_offline, offline_handler); } @@ -247,7 +247,7 @@ impl_goOnline (PortableServer_Servant servant, offline_handler = CALENDAR_OFFLINE_HANDLER (bonobo_object_from_servant (servant)); priv = offline_handler->priv; - uris = cal_client_uri_list (priv->client, CAL_MODE_LOCAL); + uris = e_cal_uri_list (priv->client, CAL_MODE_LOCAL); g_list_foreach (uris, backend_go_online, offline_handler); } @@ -327,7 +327,7 @@ calendar_offline_handler_init (CalendarOfflineHandler *offline_handler) offline_handler->priv = priv; /* FIXME: what URI to use? */ - priv->client = cal_client_new ("", CALOBJ_TYPE_ANY); + priv->client = e_cal_new ("", CALOBJ_TYPE_ANY); priv->listener_interface = CORBA_OBJECT_NIL; priv->is_offline = FALSE; } diff --git a/calendar/gui/comp-editor-factory.c b/calendar/gui/comp-editor-factory.c index 7b7dcb4c87..ffb26a831c 100644 --- a/calendar/gui/comp-editor-factory.c +++ b/calendar/gui/comp-editor-factory.c @@ -27,7 +27,7 @@ #include <bonobo/bonobo-i18n.h> #include <evolution-calendar.h> #include <e-util/e-url.h> -#include <cal-client/cal-client.h> +#include <libecal/e-cal.h> #include "calendar-config.h" #include "e-comp-editor-registry.h" #include "comp-editor-factory.h" @@ -69,7 +69,7 @@ typedef struct { char *uri; /* Client of the calendar */ - CalClient *client; + ECal *client; /* Count editors using this client */ int editor_count; @@ -239,23 +239,23 @@ editor_destroy_cb (GtkObject *object, gpointer data) static void edit_existing (OpenClient *oc, const char *uid) { - CalComponent *comp; + ECalComponent *comp; icalcomponent *icalcomp; CompEditor *editor; - CalComponentVType vtype; + ECalComponentVType vtype; g_assert (oc->open); /* Get the object */ - if (!cal_client_get_object (oc->client, uid, NULL, &icalcomp, NULL)) { + if (!e_cal_get_object (oc->client, uid, NULL, &icalcomp, NULL)) { /* FIXME Better error handling */ g_warning (G_STRLOC ": Syntax error while getting component `%s'", uid); return; } - comp = cal_component_new (); - if (!cal_component_set_icalcomponent (comp, icalcomp)) { + comp = e_cal_component_new (); + if (!e_cal_component_set_icalcomponent (comp, icalcomp)) { g_object_unref (comp); icalcomponent_free (icalcomp); return; @@ -263,14 +263,14 @@ edit_existing (OpenClient *oc, const char *uid) /* Create the appropriate type of editor */ - vtype = cal_component_get_vtype (comp); + vtype = e_cal_component_get_vtype (comp); switch (vtype) { - case CAL_COMPONENT_EVENT: + case E_CAL_COMPONENT_EVENT: editor = COMP_EDITOR (event_editor_new (oc->client)); break; - case CAL_COMPONENT_TODO: + case E_CAL_COMPONENT_TODO: editor = COMP_EDITOR (task_editor_new (oc->client)); break; @@ -293,12 +293,12 @@ edit_existing (OpenClient *oc, const char *uid) /* Creates a component with the appropriate defaults for the specified component * type. */ -static CalComponent * -get_default_event (CalClient *client, gboolean all_day) +static ECalComponent * +get_default_event (ECal *client, gboolean all_day) { - CalComponent *comp; + ECalComponent *comp; struct icaltimetype itt; - CalComponentDateTime dt; + ECalComponentDateTime dt; char *location; icaltimezone *zone; @@ -313,8 +313,8 @@ get_default_event (CalClient *client, gboolean all_day) dt.value = &itt; dt.tzid = icaltimezone_get_tzid (zone); - cal_component_set_dtstart (comp, &dt); - cal_component_set_dtend (comp, &dt); + e_cal_component_set_dtstart (comp, &dt); + e_cal_component_set_dtend (comp, &dt); } else { itt = icaltime_current_time_with_zone (zone); icaltime_adjust (&itt, 0, 1, -itt.minute, -itt.second); @@ -322,20 +322,20 @@ get_default_event (CalClient *client, gboolean all_day) dt.value = &itt; dt.tzid = icaltimezone_get_tzid (zone); - cal_component_set_dtstart (comp, &dt); + e_cal_component_set_dtstart (comp, &dt); icaltime_adjust (&itt, 0, 1, 0, 0); - cal_component_set_dtend (comp, &dt); + e_cal_component_set_dtend (comp, &dt); } - cal_component_commit_sequence (comp); + e_cal_component_commit_sequence (comp); return comp; } -static CalComponent * -get_default_task (CalClient *client) +static ECalComponent * +get_default_task (ECal *client) { - CalComponent *comp; + ECalComponent *comp; comp = cal_comp_task_new_with_defaults (client); @@ -346,7 +346,7 @@ get_default_task (CalClient *client) static void edit_new (OpenClient *oc, const GNOME_Evolution_Calendar_CompEditorFactory_CompEditorMode type) { - CalComponent *comp; + ECalComponent *comp; CompEditor *editor; switch (type) { @@ -400,7 +400,7 @@ resolve_pending_requests (OpenClient *oc) zone = icaltimezone_get_builtin_timezone (location); if (zone) /* FIXME Error handling? */ - cal_client_set_default_timezone (oc->client, zone, NULL); + e_cal_set_default_timezone (oc->client, zone, NULL); for (l = oc->pending; l; l = l->next) { Request *request; @@ -428,7 +428,7 @@ resolve_pending_requests (OpenClient *oc) * requests. */ static void -cal_opened_cb (CalClient *client, CalClientOpenStatus status, gpointer data) +cal_opened_cb (ECal *client, ECalOpenStatus status, gpointer data) { OpenClient *oc; CompEditorFactory *factory; @@ -440,29 +440,29 @@ cal_opened_cb (CalClient *client, CalClientOpenStatus status, gpointer data) priv = factory->priv; switch (status) { - case CAL_CLIENT_OPEN_SUCCESS: + case E_CAL_OPEN_SUCCESS: oc->open = TRUE; resolve_pending_requests (oc); return; - case CAL_CLIENT_OPEN_ERROR: + case E_CAL_OPEN_ERROR: dialog = gtk_message_dialog_new (NULL, GTK_DIALOG_MODAL, GTK_MESSAGE_ERROR, GTK_BUTTONS_CLOSE, _("Error while opening the calendar")); break; - case CAL_CLIENT_OPEN_NOT_FOUND: + case E_CAL_OPEN_NOT_FOUND: /* bullshit; we specified only_if_exists = FALSE */ g_assert_not_reached (); return; - case CAL_CLIENT_OPEN_METHOD_NOT_SUPPORTED: + case E_CAL_OPEN_METHOD_NOT_SUPPORTED: dialog = gtk_message_dialog_new (NULL, GTK_DIALOG_MODAL, GTK_MESSAGE_ERROR, GTK_BUTTONS_CLOSE, _("Method not supported when opening the calendar")); break; - case CAL_CLIENT_OPEN_PERMISSION_DENIED : + case E_CAL_OPEN_PERMISSION_DENIED : dialog = gtk_message_dialog_new (NULL, GTK_DIALOG_MODAL, GTK_MESSAGE_ERROR, GTK_BUTTONS_CLOSE, _("Permission denied to open the calendar")); @@ -488,13 +488,13 @@ static OpenClient * open_client (CompEditorFactory *factory, const char *uristr) { CompEditorFactoryPrivate *priv; - CalClient *client; + ECal *client; OpenClient *oc; GError *error = NULL; priv = factory->priv; - client = cal_client_new (uristr, CALOBJ_TYPE_ANY); + client = e_cal_new (uristr, CALOBJ_TYPE_ANY); if (!client) return NULL; @@ -512,7 +512,7 @@ open_client (CompEditorFactory *factory, const char *uristr) g_hash_table_insert (priv->uri_client_hash, oc->uri, oc); - if (!cal_client_open (oc->client, FALSE, &error)) { + if (!e_cal_open (oc->client, FALSE, &error)) { g_warning (_("open_client(): %s"), error->message); g_free (oc->uri); g_object_unref (oc->client); diff --git a/calendar/gui/comp-util.c b/calendar/gui/comp-util.c index 45d9dc1f27..170adb0cf5 100644 --- a/calendar/gui/comp-util.c +++ b/calendar/gui/comp-util.c @@ -1,4 +1,4 @@ -/* Evolution calendar - Utilities for manipulating CalComponent objects +/* Evolution calendar - Utilities for manipulating ECalComponent objects * * Copyright (C) 2000 Ximian, Inc. * Copyright (C) 2000 Ximian, Inc. @@ -39,31 +39,31 @@ * component object. **/ void -cal_comp_util_add_exdate (CalComponent *comp, time_t t, icaltimezone *zone) +cal_comp_util_add_exdate (ECalComponent *comp, time_t t, icaltimezone *zone) { GSList *list; - CalComponentDateTime *cdt; + ECalComponentDateTime *cdt; g_return_if_fail (comp != NULL); - g_return_if_fail (IS_CAL_COMPONENT (comp)); + g_return_if_fail (E_IS_CAL_COMPONENT (comp)); - cal_component_get_exdate_list (comp, &list); + e_cal_component_get_exdate_list (comp, &list); - cdt = g_new (CalComponentDateTime, 1); + cdt = g_new (ECalComponentDateTime, 1); cdt->value = g_new (struct icaltimetype, 1); *cdt->value = icaltime_from_timet_with_zone (t, FALSE, zone); cdt->tzid = g_strdup (icaltimezone_get_tzid (zone)); list = g_slist_append (list, cdt); - cal_component_set_exdate_list (comp, list); - cal_component_free_exdate_list (list); + e_cal_component_set_exdate_list (comp, list); + e_cal_component_free_exdate_list (list); } /* Returns TRUE if the TZIDs are equivalent, i.e. both NULL or the same. */ static gboolean -cal_component_compare_tzid (const char *tzid1, const char *tzid2) +e_cal_component_compare_tzid (const char *tzid1, const char *tzid2) { gboolean retval = TRUE; @@ -81,7 +81,7 @@ cal_component_compare_tzid (const char *tzid1, const char *tzid2) /** * cal_comp_util_compare_event_timezones: * @comp: A calendar component object. - * @client: A #CalClient. + * @client: A #ECal. * * Checks if the component uses the given timezone for both the start and * the end time, or if the UTC offsets of the start and end times are the same @@ -91,11 +91,11 @@ cal_component_compare_tzid (const char *tzid1, const char *tzid2) * offset in the given timezone. **/ gboolean -cal_comp_util_compare_event_timezones (CalComponent *comp, - CalClient *client, +cal_comp_util_compare_event_timezones (ECalComponent *comp, + ECal *client, icaltimezone *zone) { - CalComponentDateTime start_datetime, end_datetime; + ECalComponentDateTime start_datetime, end_datetime; const char *tzid; gboolean retval = FALSE; icaltimezone *start_zone, *end_zone; @@ -103,8 +103,8 @@ cal_comp_util_compare_event_timezones (CalComponent *comp, tzid = icaltimezone_get_tzid (zone); - cal_component_get_dtstart (comp, &start_datetime); - cal_component_get_dtend (comp, &end_datetime); + e_cal_component_get_dtstart (comp, &start_datetime); + e_cal_component_get_dtend (comp, &end_datetime); /* If either the DTSTART or the DTEND is a DATE value, we return TRUE. Maybe if one was a DATE-TIME we should check that, but that should @@ -133,8 +133,8 @@ cal_comp_util_compare_event_timezones (CalComponent *comp, } /* FIXME: DURATION may be used instead. */ - if (cal_component_compare_tzid (tzid, start_datetime.tzid) - && cal_component_compare_tzid (tzid, end_datetime.tzid)) { + if (e_cal_component_compare_tzid (tzid, start_datetime.tzid) + && e_cal_component_compare_tzid (tzid, end_datetime.tzid)) { /* If both TZIDs are the same as the given zone's TZID, then we know the timezones are the same so we return TRUE. */ retval = TRUE; @@ -142,7 +142,7 @@ cal_comp_util_compare_event_timezones (CalComponent *comp, /* If the TZIDs differ, we have to compare the UTC offsets of the start and end times, using their own timezones and the given timezone. */ - if (!cal_client_get_timezone (client, start_datetime.tzid, + if (!e_cal_get_timezone (client, start_datetime.tzid, &start_zone, NULL)) goto out; @@ -157,7 +157,7 @@ cal_comp_util_compare_event_timezones (CalComponent *comp, goto out; } - if (!cal_client_get_timezone (client, end_datetime.tzid, + if (!e_cal_get_timezone (client, end_datetime.tzid, &end_zone, NULL)) goto out; @@ -177,8 +177,8 @@ cal_comp_util_compare_event_timezones (CalComponent *comp, out: - cal_component_free_datetime (&start_datetime); - cal_component_free_datetime (&end_datetime); + e_cal_component_free_datetime (&start_datetime); + e_cal_component_free_datetime (&end_datetime); return retval; } @@ -202,16 +202,16 @@ cal_comp_util_compare_event_timezones (CalComponent *comp, * user cancelled the deletion. **/ gboolean -cal_comp_is_on_server (CalComponent *comp, CalClient *client) +cal_comp_is_on_server (ECalComponent *comp, ECal *client) { const char *uid; icalcomponent *icalcomp; GError *error = NULL; g_return_val_if_fail (comp != NULL, FALSE); - g_return_val_if_fail (IS_CAL_COMPONENT (comp), FALSE); + g_return_val_if_fail (E_IS_CAL_COMPONENT (comp), FALSE); g_return_val_if_fail (client != NULL, FALSE); - g_return_val_if_fail (IS_CAL_CLIENT (client), FALSE); + g_return_val_if_fail (E_IS_CAL (client), FALSE); /* See if the component is on the server. If it is not, then it likely * means that the appointment is new, only in the day view, and we @@ -219,9 +219,9 @@ cal_comp_is_on_server (CalComponent *comp, CalClient *client) * confirm and we can just delete the event. Otherwise, we ask * the user. */ - cal_component_get_uid (comp, &uid); + e_cal_component_get_uid (comp, &uid); - if (cal_client_get_object (client, uid, NULL, &icalcomp, &error)) { + if (e_cal_get_object (client, uid, NULL, &icalcomp, &error)) { icalcomponent_free (icalcomp); return TRUE; @@ -243,22 +243,22 @@ cal_comp_is_on_server (CalComponent *comp, CalClient *client) * * Return value: A newly-created calendar component. **/ -CalComponent * -cal_comp_event_new_with_defaults (CalClient *client) +ECalComponent * +cal_comp_event_new_with_defaults (ECal *client) { icalcomponent *icalcomp; - CalComponent *comp; + ECalComponent *comp; int interval; CalUnits units; - CalComponentAlarm *alarm; + ECalComponentAlarm *alarm; icalproperty *icalprop; - CalAlarmTrigger trigger; + ECalComponentAlarmTrigger trigger; - if (!cal_client_get_default_object (client, &icalcomp, NULL)) + if (!e_cal_get_default_object (client, &icalcomp, NULL)) return NULL; - comp = cal_component_new (); - if (!cal_component_set_icalcomponent (comp, icalcomp)) { + comp = e_cal_component_new (); + if (!e_cal_component_set_icalcomponent (comp, icalcomp)) { g_object_unref (comp); icalcomponent_free (icalcomp); return NULL; @@ -270,20 +270,20 @@ cal_comp_event_new_with_defaults (CalClient *client) interval = calendar_config_get_default_reminder_interval (); units = calendar_config_get_default_reminder_units (); - alarm = cal_component_alarm_new (); + alarm = e_cal_component_alarm_new (); /* We don't set the description of the alarm; we'll copy it from the * summary when it gets committed to the server. For that, we add a * X-EVOLUTION-NEEDS-DESCRIPTION property to the alarm's component. */ - icalcomp = cal_component_alarm_get_icalcomponent (alarm); + icalcomp = e_cal_component_alarm_get_icalcomponent (alarm); icalprop = icalproperty_new_x ("1"); icalproperty_set_x_name (icalprop, "X-EVOLUTION-NEEDS-DESCRIPTION"); icalcomponent_add_property (icalcomp, icalprop); - cal_component_alarm_set_action (alarm, CAL_ALARM_DISPLAY); + e_cal_component_alarm_set_action (alarm, E_CAL_COMPONENT_ALARM_DISPLAY); - trigger.type = CAL_ALARM_TRIGGER_RELATIVE_START; + trigger.type = E_CAL_COMPONENT_ALARM_TRIGGER_RELATIVE_START; memset (&trigger.u.rel_duration, 0, sizeof (trigger.u.rel_duration)); @@ -306,33 +306,33 @@ cal_comp_event_new_with_defaults (CalClient *client) g_assert_not_reached (); } - cal_component_alarm_set_trigger (alarm, trigger); + e_cal_component_alarm_set_trigger (alarm, trigger); - cal_component_add_alarm (comp, alarm); - cal_component_alarm_free (alarm); + e_cal_component_add_alarm (comp, alarm); + e_cal_component_alarm_free (alarm); return comp; } -CalComponent * -cal_comp_task_new_with_defaults (CalClient *client) +ECalComponent * +cal_comp_task_new_with_defaults (ECal *client) { - CalComponent *comp; + ECalComponent *comp; icalcomponent *icalcomp; - if (!cal_client_get_default_object (client, &icalcomp, NULL)) + if (!e_cal_get_default_object (client, &icalcomp, NULL)) return NULL; - comp = cal_component_new (); - if (!cal_component_set_icalcomponent (comp, icalcomp)) { + comp = e_cal_component_new (); + if (!e_cal_component_set_icalcomponent (comp, icalcomp)) { g_object_unref (comp); icalcomponent_free (icalcomp); return NULL; } - comp = cal_component_new (); - if (!cal_component_set_icalcomponent (comp, icalcomp)) { + comp = e_cal_component_new (); + if (!e_cal_component_set_icalcomponent (comp, icalcomp)) { g_object_unref (comp); icalcomponent_free (icalcomp); return NULL; diff --git a/calendar/gui/comp-util.h b/calendar/gui/comp-util.h index c3326fbaa3..0f4542aba1 100644 --- a/calendar/gui/comp-util.h +++ b/calendar/gui/comp-util.h @@ -1,4 +1,4 @@ -/* Evolution calendar - Utilities for manipulating CalComponent objects +/* Evolution calendar - Utilities for manipulating ECalComponent objects * * Copyright (C) 2000 Ximian, Inc. * Copyright (C) 2000 Ximian, Inc. @@ -23,23 +23,23 @@ #define COMP_UTIL_H #include <gtk/gtkwidget.h> -#include <cal-util/cal-component.h> -#include <cal-client/cal-client.h> +#include <libecal/e-cal-component.h> +#include <libecal/e-cal.h> -void cal_comp_util_add_exdate (CalComponent *comp, time_t t, icaltimezone *zone); +void cal_comp_util_add_exdate (ECalComponent *comp, time_t t, icaltimezone *zone); /* Returns TRUE if the component uses the given timezone for both DTSTART and DTEND, or if the UTC offsets of the start and end times are the same as in the given zone. */ -gboolean cal_comp_util_compare_event_timezones (CalComponent *comp, - CalClient *client, +gboolean cal_comp_util_compare_event_timezones (ECalComponent *comp, + ECal *client, icaltimezone *zone); -gboolean cal_comp_is_on_server (CalComponent *comp, - CalClient *client); +gboolean cal_comp_is_on_server (ECalComponent *comp, + ECal *client); -CalComponent *cal_comp_event_new_with_defaults (CalClient *client); -CalComponent *cal_comp_task_new_with_defaults (CalClient *client); +ECalComponent *cal_comp_event_new_with_defaults (ECal *client); +ECalComponent *cal_comp_task_new_with_defaults (ECal *client); #endif diff --git a/calendar/gui/control-factory.c b/calendar/gui/control-factory.c index 9586d6f62d..58436ec841 100644 --- a/calendar/gui/control-factory.c +++ b/calendar/gui/control-factory.c @@ -32,7 +32,7 @@ #include <glade/glade.h> #include <libgnomeui/gnome-dialog-util.h> -#include <cal-util/timeutil.h> +#include <libecal/e-cal-time-util.h> #include <gui/gnome-cal.h> #include <gui/calendar-commands.h> #include <gui/calendar-config.h> @@ -78,7 +78,7 @@ get_prop (BonoboPropertyBag *bag, switch (arg_id) { case PROPERTY_CALENDAR_URI_IDX: - uri = cal_client_get_uri (e_cal_model_get_default_client (gnome_calendar_get_calendar_model (gcal))); + uri = e_cal_get_uri (e_cal_model_get_default_client (gnome_calendar_get_calendar_model (gcal))); BONOBO_ARG_SET_STRING (arg, uri); break; diff --git a/calendar/gui/dialogs/Makefile.am b/calendar/gui/dialogs/Makefile.am index 84424f8cc0..9181d5d3dd 100644 --- a/calendar/gui/dialogs/Makefile.am +++ b/calendar/gui/dialogs/Makefile.am @@ -20,8 +20,6 @@ INCLUDES = \ -I$(top_srcdir)/libical/src \ -I$(top_builddir)/shell \ -I$(top_srcdir)/shell \ - -I$(top_srcdir)/addressbook/backend \ - -I$(top_builddir)/addressbook/backend \ -DEVOLUTION_DATADIR=\""$(datadir)"\" \ -DEVOLUTION_GLADEDIR=\""$(gladedir)"\" \ -DEVOLUTION_IMAGESDIR=\""$(imagesdir)"\" \ diff --git a/calendar/gui/dialogs/alarm-options.c b/calendar/gui/dialogs/alarm-options.c index b94a75478d..f664d8d31f 100644 --- a/calendar/gui/dialogs/alarm-options.c +++ b/calendar/gui/dialogs/alarm-options.c @@ -51,7 +51,7 @@ typedef struct { GladeXML *xml; /* The alarm action selected */ - CalAlarmAction action; + ECalComponentAlarmAction action; /* Toplevel */ GtkWidget *toplevel; @@ -218,7 +218,7 @@ repeat_toggle_toggled_cb (GtkToggleButton *toggle, gpointer data) gtk_widget_set_sensitive (dialog->repeat_group, active); /* activate the 'OK' button */ - if (dialog->action == CAL_ALARM_PROCEDURE) + if (dialog->action == E_CAL_COMPONENT_ALARM_PROCEDURE) palarm_options_changed_cb (GTK_EDITABLE (dialog->palarm_program), dialog); } @@ -227,7 +227,7 @@ repeat_spin_button_changed_cb (GtkWidget *spin, gpointer user_data) { Dialog *dialog = user_data; - if (dialog->action == CAL_ALARM_PROCEDURE) + if (dialog->action == E_CAL_COMPONENT_ALARM_PROCEDURE) palarm_options_changed_cb (GTK_EDITABLE (dialog->palarm_program), dialog); } @@ -237,7 +237,7 @@ repeat_unit_changed_cb (GtkWidget *option_menu, gpointer user_data) { Dialog *dialog = user_data; - if (dialog->action == CAL_ALARM_PROCEDURE) + if (dialog->action == E_CAL_COMPONENT_ALARM_PROCEDURE) palarm_options_changed_cb (GTK_EDITABLE (dialog->palarm_program), dialog); } @@ -261,12 +261,12 @@ init_widgets (Dialog *dialog) /* Fills the audio alarm widgets with the values from the alarm component */ static void -alarm_to_aalarm_widgets (Dialog *dialog, CalComponentAlarm *alarm) +alarm_to_aalarm_widgets (Dialog *dialog, ECalComponentAlarm *alarm) { icalattach *attach; const char *url; - cal_component_alarm_get_attach (alarm, &attach); + e_cal_component_alarm_get_attach (alarm, &attach); if (!attach) { e_dialog_editable_set (dialog->aalarm_attach, NULL); @@ -289,12 +289,12 @@ alarm_to_aalarm_widgets (Dialog *dialog, CalComponentAlarm *alarm) /* Fills the display alarm widgets with the values from the alarm component */ static void -alarm_to_dalarm_widgets (Dialog *dialog, CalComponentAlarm *alarm) +alarm_to_dalarm_widgets (Dialog *dialog, ECalComponentAlarm *alarm) { - CalComponentText description; + ECalComponentText description; GtkTextBuffer *text_buffer; - cal_component_alarm_get_description (alarm, &description); + e_cal_component_alarm_get_description (alarm, &description); text_buffer = gtk_text_view_get_buffer (GTK_TEXT_VIEW (dialog->dalarm_description)); gtk_text_buffer_set_text (text_buffer, description.value ? description.value : "", -1); @@ -302,16 +302,16 @@ alarm_to_dalarm_widgets (Dialog *dialog, CalComponentAlarm *alarm) /* Fills the mail alarm widgets with the values from the alarm component */ static void -alarm_to_malarm_widgets (Dialog *dialog, CalComponentAlarm *alarm) +alarm_to_malarm_widgets (Dialog *dialog, ECalComponentAlarm *alarm) { - CalComponentText description; + ECalComponentText description; GtkTextBuffer *text_buffer; GSList *attendee_list, *l; EABDestination **destv; int len, i; /* Recipients */ - cal_component_alarm_get_attendee_list (alarm, &attendee_list); + e_cal_component_alarm_get_attendee_list (alarm, &attendee_list); len = g_slist_length (attendee_list); if (len <= 0) { @@ -323,7 +323,7 @@ alarm_to_malarm_widgets (Dialog *dialog, CalComponentAlarm *alarm) } else { destv = g_new0 (EABDestination *, len + 1); for (l = attendee_list, i = 0; l != NULL; l = l->next, i++) { - CalComponentAttendee *a = l->data; + ECalComponentAttendee *a = l->data; EABDestination *dest; dest = eab_destination_new (); @@ -344,10 +344,10 @@ alarm_to_malarm_widgets (Dialog *dialog, CalComponentAlarm *alarm) g_object_unref (GTK_OBJECT (destv[i])); g_free (destv); - cal_component_free_attendee_list (attendee_list); + e_cal_component_free_attendee_list (attendee_list); /* Description */ - cal_component_alarm_get_description (alarm, &description); + e_cal_component_alarm_get_description (alarm, &description); text_buffer = gtk_text_view_get_buffer (GTK_TEXT_VIEW (dialog->malarm_description)); gtk_text_buffer_set_text (text_buffer, description.value ? description.value : "", -1); @@ -355,13 +355,13 @@ alarm_to_malarm_widgets (Dialog *dialog, CalComponentAlarm *alarm) /* Fills the procedure alarm widgets with the values from the alarm component */ static void -alarm_to_palarm_widgets (Dialog *dialog, CalComponentAlarm *alarm) +alarm_to_palarm_widgets (Dialog *dialog, ECalComponentAlarm *alarm) { icalattach *attach; - CalComponentText description; + ECalComponentText description; - cal_component_alarm_get_attach (alarm, &attach); - cal_component_alarm_get_description (alarm, &description); + e_cal_component_alarm_get_attach (alarm, &attach); + e_cal_component_alarm_get_description (alarm, &description); if (attach) { const char *url; @@ -416,13 +416,13 @@ normalize_duration (struct icaldurationtype dur, int *value, enum duration_units /* Fills the repeat widgets with the values from the alarm component */ static void -alarm_to_repeat_widgets (Dialog *dialog, CalComponentAlarm *alarm) +alarm_to_repeat_widgets (Dialog *dialog, ECalComponentAlarm *alarm) { - CalAlarmRepeat repeat; + ECalComponentAlarmRepeat repeat; int value; enum duration_units units; - cal_component_alarm_get_repeat (alarm, &repeat); + e_cal_component_alarm_get_repeat (alarm, &repeat); /* Sensitivity */ @@ -449,20 +449,20 @@ alarm_to_repeat_widgets (Dialog *dialog, CalComponentAlarm *alarm) /* Fills the widgets with the values from the alarm component */ static void -alarm_to_dialog (Dialog *dialog, CalComponentAlarm *alarm) +alarm_to_dialog (Dialog *dialog, ECalComponentAlarm *alarm) { - CalAlarmAction action; + ECalComponentAlarmAction action; alarm_to_repeat_widgets (dialog, alarm); - cal_component_alarm_get_action (alarm, &action); + e_cal_component_alarm_get_action (alarm, &action); switch (action) { - case CAL_ALARM_NONE: + case E_CAL_COMPONENT_ALARM_NONE: g_assert_not_reached (); return; - case CAL_ALARM_AUDIO: + case E_CAL_COMPONENT_ALARM_AUDIO: gtk_window_set_title (GTK_WINDOW (dialog->toplevel), _("Audio Alarm Options")); gtk_widget_show (dialog->aalarm_group); gtk_widget_hide (dialog->dalarm_group); @@ -471,7 +471,7 @@ alarm_to_dialog (Dialog *dialog, CalComponentAlarm *alarm) alarm_to_aalarm_widgets (dialog, alarm); break; - case CAL_ALARM_DISPLAY: + case E_CAL_COMPONENT_ALARM_DISPLAY: gtk_window_set_title (GTK_WINDOW (dialog->toplevel), _("Message Alarm Options")); gtk_widget_hide (dialog->aalarm_group); gtk_widget_show (dialog->dalarm_group); @@ -480,7 +480,7 @@ alarm_to_dialog (Dialog *dialog, CalComponentAlarm *alarm) alarm_to_dalarm_widgets (dialog, alarm); break; - case CAL_ALARM_EMAIL: + case E_CAL_COMPONENT_ALARM_EMAIL: gtk_window_set_title (GTK_WINDOW (dialog->toplevel), _("Email Alarm Options")); gtk_widget_hide (dialog->aalarm_group); gtk_widget_hide (dialog->dalarm_group); @@ -489,7 +489,7 @@ alarm_to_dialog (Dialog *dialog, CalComponentAlarm *alarm) alarm_to_malarm_widgets (dialog, alarm); break; - case CAL_ALARM_PROCEDURE: + case E_CAL_COMPONENT_ALARM_PROCEDURE: gtk_window_set_title (GTK_WINDOW (dialog->toplevel), _("Program Alarm Options")); gtk_widget_hide (dialog->aalarm_group); gtk_widget_hide (dialog->dalarm_group); @@ -505,7 +505,7 @@ alarm_to_dialog (Dialog *dialog, CalComponentAlarm *alarm) G_CALLBACK (palarm_options_changed_cb), dialog); break; - case CAL_ALARM_UNKNOWN: + case E_CAL_COMPONENT_ALARM_UNKNOWN: gtk_window_set_title (GTK_WINDOW (dialog->toplevel), _("Unknown Alarm Options")); break; @@ -521,14 +521,14 @@ alarm_to_dialog (Dialog *dialog, CalComponentAlarm *alarm) /* Fills the alarm data with the values from the repeat/duration widgets */ static void -repeat_widgets_to_alarm (Dialog *dialog, CalComponentAlarm *alarm) +repeat_widgets_to_alarm (Dialog *dialog, ECalComponentAlarm *alarm) { - CalAlarmRepeat repeat; + ECalComponentAlarmRepeat repeat; if (!e_dialog_toggle_get (dialog->repeat_toggle)) { repeat.repetitions = 0; - cal_component_alarm_set_repeat (alarm, repeat); + e_cal_component_alarm_set_repeat (alarm, repeat); return; } @@ -552,13 +552,13 @@ repeat_widgets_to_alarm (Dialog *dialog, CalComponentAlarm *alarm) g_assert_not_reached (); } - cal_component_alarm_set_repeat (alarm, repeat); + e_cal_component_alarm_set_repeat (alarm, repeat); } /* Fills the audio alarm data with the values from the widgets */ static void -aalarm_widgets_to_alarm (Dialog *dialog, CalComponentAlarm *alarm) +aalarm_widgets_to_alarm (Dialog *dialog, ECalComponentAlarm *alarm) { char *url; icalattach *attach; @@ -567,16 +567,16 @@ aalarm_widgets_to_alarm (Dialog *dialog, CalComponentAlarm *alarm) attach = icalattach_new_from_url (url ? url : ""); g_free (url); - cal_component_alarm_set_attach (alarm, attach); + e_cal_component_alarm_set_attach (alarm, attach); icalattach_unref (attach); } /* Fills the display alarm data with the values from the widgets */ static void -dalarm_widgets_to_alarm (Dialog *dialog, CalComponentAlarm *alarm) +dalarm_widgets_to_alarm (Dialog *dialog, ECalComponentAlarm *alarm) { char *str; - CalComponentText description; + ECalComponentText description; GtkTextBuffer *text_buffer; GtkTextIter text_iter_start, text_iter_end; icalcomponent *icalcomp; @@ -590,12 +590,12 @@ dalarm_widgets_to_alarm (Dialog *dialog, CalComponentAlarm *alarm) description.value = str; description.altrep = NULL; - cal_component_alarm_set_description (alarm, &description); + e_cal_component_alarm_set_description (alarm, &description); g_free (str); /* remove the X-EVOLUTION-NEEDS-DESCRIPTION property, so that * we don't re-set the alarm's description */ - icalcomp = cal_component_alarm_get_icalcomponent (alarm); + icalcomp = e_cal_component_alarm_get_icalcomponent (alarm); icalprop = icalcomponent_get_first_property (icalcomp, ICAL_X_PROPERTY); while (icalprop) { const char *x_name; @@ -612,10 +612,10 @@ dalarm_widgets_to_alarm (Dialog *dialog, CalComponentAlarm *alarm) /* Fills the mail alarm data with the values from the widgets */ static void -malarm_widgets_to_alarm (Dialog *dialog, CalComponentAlarm *alarm) +malarm_widgets_to_alarm (Dialog *dialog, ECalComponentAlarm *alarm) { char *str; - CalComponentText description; + ECalComponentText description; GSList *attendee_list = NULL; EABDestination **destv; GtkTextBuffer *text_buffer; @@ -632,20 +632,20 @@ malarm_widgets_to_alarm (Dialog *dialog, CalComponentAlarm *alarm) for (i = 0; destv[i] != NULL; i++) { EABDestination *dest; - CalComponentAttendee *a; + ECalComponentAttendee *a; dest = destv[i]; - a = g_new0 (CalComponentAttendee, 1); + a = g_new0 (ECalComponentAttendee, 1); a->value = eab_destination_get_email (dest); a->cn = eab_destination_get_name (dest); attendee_list = g_slist_append (attendee_list, a); } - cal_component_alarm_set_attendee_list (alarm, attendee_list); + e_cal_component_alarm_set_attendee_list (alarm, attendee_list); - cal_component_free_attendee_list (attendee_list); + e_cal_component_free_attendee_list (attendee_list); eab_destination_freev (destv); /* Description */ @@ -657,12 +657,12 @@ malarm_widgets_to_alarm (Dialog *dialog, CalComponentAlarm *alarm) description.value = str; description.altrep = NULL; - cal_component_alarm_set_description (alarm, &description); + e_cal_component_alarm_set_description (alarm, &description); g_free (str); /* remove the X-EVOLUTION-NEEDS-DESCRIPTION property, so that * we don't re-set the alarm's description */ - icalcomp = cal_component_alarm_get_icalcomponent (alarm); + icalcomp = e_cal_component_alarm_get_icalcomponent (alarm); icalprop = icalcomponent_get_first_property(icalcomp, ICAL_X_PROPERTY); while (icalprop) { const char *x_name; @@ -679,12 +679,12 @@ malarm_widgets_to_alarm (Dialog *dialog, CalComponentAlarm *alarm) /* Fills the procedure alarm data with the values from the widgets */ static void -palarm_widgets_to_alarm (Dialog *dialog, CalComponentAlarm *alarm) +palarm_widgets_to_alarm (Dialog *dialog, ECalComponentAlarm *alarm) { char *program; icalattach *attach; char *str; - CalComponentText description; + ECalComponentText description; icalcomponent *icalcomp; icalproperty *icalprop; @@ -692,19 +692,19 @@ palarm_widgets_to_alarm (Dialog *dialog, CalComponentAlarm *alarm) attach = icalattach_new_from_url (program ? program : ""); g_free (program); - cal_component_alarm_set_attach (alarm, attach); + e_cal_component_alarm_set_attach (alarm, attach); icalattach_unref (attach); str = e_dialog_editable_get (dialog->palarm_args); description.value = str; description.altrep = NULL; - cal_component_alarm_set_description (alarm, &description); + e_cal_component_alarm_set_description (alarm, &description); g_free (str); /* remove the X-EVOLUTION-NEEDS-DESCRIPTION property, so that * we don't re-set the alarm's description */ - icalcomp = cal_component_alarm_get_icalcomponent (alarm); + icalcomp = e_cal_component_alarm_get_icalcomponent (alarm); icalprop = icalcomponent_get_first_property (icalcomp, ICAL_X_PROPERTY); while (icalprop) { const char *x_name; @@ -721,36 +721,36 @@ palarm_widgets_to_alarm (Dialog *dialog, CalComponentAlarm *alarm) /* Fills the alarm data with the values from the widgets */ static void -dialog_to_alarm (Dialog *dialog, CalComponentAlarm *alarm) +dialog_to_alarm (Dialog *dialog, ECalComponentAlarm *alarm) { - CalAlarmAction action; + ECalComponentAlarmAction action; repeat_widgets_to_alarm (dialog, alarm); - cal_component_alarm_get_action (alarm, &action); + e_cal_component_alarm_get_action (alarm, &action); switch (action) { - case CAL_ALARM_NONE: + case E_CAL_COMPONENT_ALARM_NONE: g_assert_not_reached (); break; - case CAL_ALARM_AUDIO: + case E_CAL_COMPONENT_ALARM_AUDIO: aalarm_widgets_to_alarm (dialog, alarm); break; - case CAL_ALARM_DISPLAY: + case E_CAL_COMPONENT_ALARM_DISPLAY: dalarm_widgets_to_alarm (dialog, alarm); break; - case CAL_ALARM_EMAIL: + case E_CAL_COMPONENT_ALARM_EMAIL: malarm_widgets_to_alarm (dialog, alarm); break; - case CAL_ALARM_PROCEDURE: + case E_CAL_COMPONENT_ALARM_PROCEDURE: palarm_widgets_to_alarm (dialog, alarm); break; - case CAL_ALARM_UNKNOWN: + case E_CAL_COMPONENT_ALARM_UNKNOWN: break; default: @@ -769,7 +769,7 @@ dialog_to_alarm (Dialog *dialog, CalComponentAlarm *alarm) * Return value: TRUE if the dialog could be created, FALSE otherwise. **/ gboolean -alarm_options_dialog_run (CalComponentAlarm *alarm, const char *email, gboolean repeat) +alarm_options_dialog_run (ECalComponentAlarm *alarm, const char *email, gboolean repeat) { Dialog dialog; int response_id; diff --git a/calendar/gui/dialogs/alarm-options.h b/calendar/gui/dialogs/alarm-options.h index 1b4abb56d9..5a07935810 100644 --- a/calendar/gui/dialogs/alarm-options.h +++ b/calendar/gui/dialogs/alarm-options.h @@ -21,8 +21,8 @@ #ifndef ALARM_OPTIONS_H #define ALARM_OPTIONS_H -#include <cal-util/cal-component.h> +#include <libecal/e-cal-component.h> -gboolean alarm_options_dialog_run (CalComponentAlarm *alarm, const char *email, gboolean repeat); +gboolean alarm_options_dialog_run (ECalComponentAlarm *alarm, const char *email, gboolean repeat); #endif diff --git a/calendar/gui/dialogs/alarm-page.c b/calendar/gui/dialogs/alarm-page.c index 919ed9a2c8..f07df3c28f 100644 --- a/calendar/gui/dialogs/alarm-page.c +++ b/calendar/gui/dialogs/alarm-page.c @@ -39,8 +39,8 @@ #include <gal/widgets/e-unicode.h> #include "e-util/e-dialog-widgets.h" #include "e-util/e-time-utils.h" -#include "cal-util/cal-util.h" -#include "cal-util/timeutil.h" +#include <libecal/e-cal-util.h> +#include <libecal/e-cal-time-util.h> #include "../calendar-config.h" #include "comp-editor-util.h" #include "alarm-options.h" @@ -74,7 +74,7 @@ struct _AlarmPagePrivate { GtkWidget *button_options; /* Alarm options dialog and the alarm we maintain */ - CalComponentAlarm *alarm; + ECalComponentAlarm *alarm; /* Alarm store for the GtkTreeView list widget */ EAlarmList *list_store; @@ -100,10 +100,10 @@ enum { /* Option menu maps */ static const int action_map[] = { - CAL_ALARM_DISPLAY, - CAL_ALARM_AUDIO, - CAL_ALARM_PROCEDURE, - CAL_ALARM_EMAIL, + E_CAL_COMPONENT_ALARM_DISPLAY, + E_CAL_COMPONENT_ALARM_AUDIO, + E_CAL_COMPONENT_ALARM_PROCEDURE, + E_CAL_COMPONENT_ALARM_EMAIL, -1 }; @@ -128,8 +128,8 @@ static const int relative_map[] = { }; static const int time_map[] = { - CAL_ALARM_TRIGGER_RELATIVE_START, - CAL_ALARM_TRIGGER_RELATIVE_END, + E_CAL_COMPONENT_ALARM_TRIGGER_RELATIVE_START, + E_CAL_COMPONENT_ALARM_TRIGGER_RELATIVE_END, -1 }; @@ -141,8 +141,8 @@ static void alarm_page_finalize (GObject *object); static GtkWidget *alarm_page_get_widget (CompEditorPage *page); static void alarm_page_focus_main_widget (CompEditorPage *page); -static void alarm_page_fill_widgets (CompEditorPage *page, CalComponent *comp); -static gboolean alarm_page_fill_component (CompEditorPage *page, CalComponent *comp); +static void alarm_page_fill_widgets (CompEditorPage *page, ECalComponent *comp); +static gboolean alarm_page_fill_component (CompEditorPage *page, ECalComponent *comp); static void alarm_page_set_summary (CompEditorPage *page, const char *summary); static void alarm_page_set_dates (CompEditorPage *page, CompEditorPageDates *dates); @@ -213,9 +213,9 @@ alarm_page_init (AlarmPage *apage) /* create the default alarm, which will contain the * X-EVOLUTION-NEEDS-DESCRIPTION property, so that we * set a correct description if none is set */ - priv->alarm = cal_component_alarm_new (); + priv->alarm = e_cal_component_alarm_new (); - icalcomp = cal_component_alarm_get_icalcomponent (priv->alarm); + icalcomp = e_cal_component_alarm_get_icalcomponent (priv->alarm); icalprop = icalproperty_new_x ("1"); icalproperty_set_x_name (icalprop, "X-EVOLUTION-NEEDS-DESCRIPTION"); icalcomponent_add_property (icalcomp, icalprop); @@ -246,7 +246,7 @@ alarm_page_finalize (GObject *object) } if (priv->alarm) { - cal_component_alarm_free (priv->alarm); + e_cal_component_alarm_free (priv->alarm); priv->alarm = NULL; } @@ -310,11 +310,11 @@ clear_widgets (AlarmPage *apage) gtk_label_set_text (GTK_LABEL (priv->date_time), ""); /* Sane defaults */ - e_dialog_option_menu_set (priv->action, CAL_ALARM_DISPLAY, action_map); + e_dialog_option_menu_set (priv->action, E_CAL_COMPONENT_ALARM_DISPLAY, action_map); e_dialog_spin_set (priv->interval_value, 15); e_dialog_option_menu_set (priv->value_units, MINUTES, value_map); e_dialog_option_menu_set (priv->relative, BEFORE, relative_map); - e_dialog_option_menu_set (priv->time, CAL_ALARM_TRIGGER_RELATIVE_START, time_map); + e_dialog_option_menu_set (priv->time, E_CAL_COMPONENT_ALARM_TRIGGER_RELATIVE_START, time_map); /* List data */ e_alarm_list_clear (priv->list_store); @@ -324,7 +324,7 @@ static void sensitize_buttons (AlarmPage *apage) { AlarmPagePrivate *priv; - CalClient *client; + ECal *client; GtkTreeSelection *selection; GtkTreeIter iter; gboolean have_selected; @@ -336,13 +336,13 @@ sensitize_buttons (AlarmPage *apage) have_selected = gtk_tree_selection_get_selected (selection, NULL, &iter); gtk_widget_set_sensitive (priv->add, - cal_client_get_one_alarm_only (client) && have_selected ? FALSE : TRUE); + e_cal_get_one_alarm_only (client) && have_selected ? FALSE : TRUE); gtk_widget_set_sensitive (priv->delete, have_selected); } /* Appends an alarm to the list */ static void -append_reminder (AlarmPage *apage, CalComponentAlarm *alarm) +append_reminder (AlarmPage *apage, ECalComponentAlarm *alarm) { AlarmPagePrivate *priv; GtkTreeView *view; @@ -359,12 +359,12 @@ append_reminder (AlarmPage *apage, CalComponentAlarm *alarm) /* fill_widgets handler for the alarm page */ static void -alarm_page_fill_widgets (CompEditorPage *page, CalComponent *comp) +alarm_page_fill_widgets (CompEditorPage *page, ECalComponent *comp) { AlarmPage *apage; AlarmPagePrivate *priv; GtkWidget *menu; - CalComponentText text; + ECalComponentText text; GList *alarms, *l; CompEditorPageDates dates; int i; @@ -379,7 +379,7 @@ alarm_page_fill_widgets (CompEditorPage *page, CalComponent *comp) clear_widgets (apage); /* Summary */ - cal_component_get_summary (comp, &text); + e_cal_component_get_summary (comp, &text); alarm_page_set_summary (page, text.value); /* Dates */ @@ -388,21 +388,21 @@ alarm_page_fill_widgets (CompEditorPage *page, CalComponent *comp) comp_editor_free_dates (&dates); /* List */ - if (!cal_component_has_alarms (comp)) + if (!e_cal_component_has_alarms (comp)) goto out; - alarms = cal_component_get_alarm_uids (comp); + alarms = e_cal_component_get_alarm_uids (comp); for (l = alarms; l != NULL; l = l->next) { - CalComponentAlarm *ca, *ca_copy; + ECalComponentAlarm *ca, *ca_copy; const char *auid; auid = l->data; - ca = cal_component_get_alarm (comp, auid); + ca = e_cal_component_get_alarm (comp, auid); g_assert (ca != NULL); - ca_copy = cal_component_alarm_clone (ca); - cal_component_alarm_free (ca); + ca_copy = e_cal_component_alarm_clone (ca); + e_cal_component_alarm_free (ca); append_reminder (apage, ca_copy); } @@ -413,7 +413,7 @@ alarm_page_fill_widgets (CompEditorPage *page, CalComponent *comp) /* Alarm types */ menu = gtk_option_menu_get_menu (GTK_OPTION_MENU (priv->action)); for (i = 0, l = GTK_MENU_SHELL (menu)->children; action_map[i] != -1; i++, l = l->next) { - if (cal_client_get_static_capability (page->client, action_map_cap[i])) + if (e_cal_get_static_capability (page->client, action_map_cap[i])) gtk_widget_set_sensitive (l->data, FALSE); else gtk_widget_set_sensitive (l->data, TRUE); @@ -426,7 +426,7 @@ alarm_page_fill_widgets (CompEditorPage *page, CalComponent *comp) /* fill_component handler for the alarm page */ static gboolean -alarm_page_fill_component (CompEditorPage *page, CalComponent *comp) +alarm_page_fill_component (CompEditorPage *page, ECalComponent *comp) { AlarmPage *apage; AlarmPagePrivate *priv; @@ -441,12 +441,12 @@ alarm_page_fill_component (CompEditorPage *page, CalComponent *comp) /* Remove all the alarms from the component */ - list = cal_component_get_alarm_uids (comp); + list = e_cal_component_get_alarm_uids (comp); for (l = list; l; l = l->next) { const char *auid; auid = l->data; - cal_component_remove_alarm (comp, auid); + e_cal_component_remove_alarm (comp, auid); } cal_obj_uid_list_free (list); @@ -457,26 +457,26 @@ alarm_page_fill_component (CompEditorPage *page, CalComponent *comp) for (valid_iter = gtk_tree_model_get_iter_first (model, &iter); valid_iter; valid_iter = gtk_tree_model_iter_next (model, &iter)) { - CalComponentAlarm *alarm, *alarm_copy; + ECalComponentAlarm *alarm, *alarm_copy; icalcomponent *icalcomp; icalproperty *icalprop; - alarm = (CalComponentAlarm *) e_alarm_list_get_alarm (priv->list_store, &iter); + alarm = (ECalComponentAlarm *) e_alarm_list_get_alarm (priv->list_store, &iter); g_assert (alarm != NULL); /* We set the description of the alarm if it's got * the X-EVOLUTION-NEEDS-DESCRIPTION property. */ - icalcomp = cal_component_alarm_get_icalcomponent (alarm); + icalcomp = e_cal_component_alarm_get_icalcomponent (alarm); icalprop = icalcomponent_get_first_property (icalcomp, ICAL_X_PROPERTY); while (icalprop) { const char *x_name; - CalComponentText summary; + ECalComponentText summary; x_name = icalproperty_get_x_name (icalprop); if (!strcmp (x_name, "X-EVOLUTION-NEEDS-DESCRIPTION")) { - cal_component_get_summary (comp, &summary); - cal_component_alarm_set_description (alarm, &summary); + e_cal_component_get_summary (comp, &summary); + e_cal_component_alarm_set_description (alarm, &summary); icalcomponent_remove_property (icalcomp, icalprop); break; @@ -489,9 +489,9 @@ alarm_page_fill_component (CompEditorPage *page, CalComponent *comp) * structures in the list did *not* come from the component. */ - alarm_copy = cal_component_alarm_clone (alarm); - cal_component_add_alarm (comp, alarm_copy); - cal_component_alarm_free (alarm_copy); + alarm_copy = e_cal_component_alarm_clone (alarm); + e_cal_component_add_alarm (comp, alarm_copy); + e_cal_component_alarm_free (alarm_copy); } return TRUE; @@ -521,17 +521,17 @@ alarm_page_set_summary (CompEditorPage *page, const char *summary) for (valid_iter = gtk_tree_model_get_iter_first (model, &iter); valid_iter; valid_iter = gtk_tree_model_iter_next (model, &iter)) { - CalComponentAlarm *alarm; - CalComponentText desc; + ECalComponentAlarm *alarm; + ECalComponentText desc; - alarm = (CalComponentAlarm *) e_alarm_list_get_alarm (priv->list_store, &iter); + alarm = (ECalComponentAlarm *) e_alarm_list_get_alarm (priv->list_store, &iter); g_assert (alarm != NULL); - cal_component_alarm_get_description (alarm, &desc); + e_cal_component_alarm_get_description (alarm, &desc); if (desc.value && *desc.value) { if (!strcmp (desc.value, priv->old_summary)) { desc.value = summary; - cal_component_alarm_set_description (alarm, &desc); + e_cal_component_alarm_set_description (alarm, &desc); } } } @@ -637,16 +637,16 @@ add_clicked_cb (GtkButton *button, gpointer data) { AlarmPage *apage; AlarmPagePrivate *priv; - CalComponentAlarm *alarm; - CalAlarmTrigger trigger; - CalAlarmAction action; + ECalComponentAlarm *alarm; + ECalComponentAlarmTrigger trigger; + ECalComponentAlarmAction action; apage = ALARM_PAGE (data); priv = apage->priv; - alarm = cal_component_alarm_clone (priv->alarm); + alarm = e_cal_component_alarm_clone (priv->alarm); - memset (&trigger, 0, sizeof (CalAlarmTrigger)); + memset (&trigger, 0, sizeof (ECalComponentAlarmTrigger)); trigger.type = e_dialog_option_menu_get (priv->time, time_map); if (e_dialog_option_menu_get (priv->relative, relative_map) == BEFORE) trigger.u.rel_duration.is_neg = 1; @@ -672,22 +672,22 @@ add_clicked_cb (GtkButton *button, gpointer data) default: g_assert_not_reached (); } - cal_component_alarm_set_trigger (alarm, trigger); + e_cal_component_alarm_set_trigger (alarm, trigger); action = e_dialog_option_menu_get (priv->action, action_map); - cal_component_alarm_set_action (alarm, action); - if (action == CAL_ALARM_EMAIL && !cal_component_alarm_has_attendees (alarm)) { + e_cal_component_alarm_set_action (alarm, action); + if (action == E_CAL_COMPONENT_ALARM_EMAIL && !e_cal_component_alarm_has_attendees (alarm)) { char *email; - if (!cal_client_get_alarm_email_address (COMP_EDITOR_PAGE (apage)->client, &email, NULL)) { - CalComponentAttendee *a; + if (!e_cal_get_alarm_email_address (COMP_EDITOR_PAGE (apage)->client, &email, NULL)) { + ECalComponentAttendee *a; GSList attendee_list; - a = g_new0 (CalComponentAttendee, 1); + a = g_new0 (ECalComponentAttendee, 1); a->value = email; attendee_list.data = a; attendee_list.next = NULL; - cal_component_alarm_set_attendee_list (alarm, &attendee_list); + e_cal_component_alarm_set_attendee_list (alarm, &attendee_list); g_free (email); g_free (a); } @@ -746,13 +746,13 @@ button_options_clicked_cb (GtkWidget *widget, gpointer data) apage = ALARM_PAGE (data); priv = apage->priv; - cal_component_alarm_set_action (priv->alarm, + e_cal_component_alarm_set_action (priv->alarm, e_dialog_option_menu_get (priv->action, action_map)); - repeat = !cal_client_get_static_capability (COMP_EDITOR_PAGE (apage)->client, + repeat = !e_cal_get_static_capability (COMP_EDITOR_PAGE (apage)->client, CAL_STATIC_CAPABILITY_NO_ALARM_REPEAT); - if (cal_client_get_alarm_email_address (COMP_EDITOR_PAGE (apage)->client, &email, NULL)) { + if (e_cal_get_alarm_email_address (COMP_EDITOR_PAGE (apage)->client, &email, NULL)) { if (!alarm_options_dialog_run (priv->alarm, email, repeat)) g_message ("button_options_clicked_cb(): Could not create the alarm options dialog"); } diff --git a/calendar/gui/dialogs/cancel-comp.c b/calendar/gui/dialogs/cancel-comp.c index e9efe92d99..3e9d76dead 100644 --- a/calendar/gui/dialogs/cancel-comp.c +++ b/calendar/gui/dialogs/cancel-comp.c @@ -40,20 +40,20 @@ * Return value: TRUE if the user clicked Yes, FALSE otherwise. **/ gboolean -cancel_component_dialog (GtkWindow *parent, CalClient *client, CalComponent *comp, gboolean deleting) +cancel_component_dialog (GtkWindow *parent, ECal *client, ECalComponent *comp, gboolean deleting) { GtkWidget *dialog; - CalComponentVType vtype; + ECalComponentVType vtype; char *str; gint response; - if (deleting && cal_client_get_save_schedules (client)) + if (deleting && e_cal_get_save_schedules (client)) return TRUE; - vtype = cal_component_get_vtype (comp); + vtype = e_cal_component_get_vtype (comp); switch (vtype) { - case CAL_COMPONENT_EVENT: + case E_CAL_COMPONENT_EVENT: if (deleting) str = g_strdup_printf (_("The event being deleted is a meeting, " "would you like to send a cancellation notice?")); @@ -62,7 +62,7 @@ cancel_component_dialog (GtkWindow *parent, CalClient *client, CalComponent *com "and delete this meeting?")); break; - case CAL_COMPONENT_TODO: + case E_CAL_COMPONENT_TODO: if (deleting) str = g_strdup_printf (_("The task being deleted is assigned, " "would you like to send a cancellation notice?")); @@ -71,7 +71,7 @@ cancel_component_dialog (GtkWindow *parent, CalClient *client, CalComponent *com "and delete this task?")); break; - case CAL_COMPONENT_JOURNAL: + case E_CAL_COMPONENT_JOURNAL: if (deleting) str = g_strdup_printf (_("The journal entry being deleted is published, " "would you like to send a cancellation notice?")); diff --git a/calendar/gui/dialogs/cancel-comp.h b/calendar/gui/dialogs/cancel-comp.h index 7dfb0fae31..a43f24f2fe 100644 --- a/calendar/gui/dialogs/cancel-comp.h +++ b/calendar/gui/dialogs/cancel-comp.h @@ -22,9 +22,9 @@ #define CANCEL_COMP_H #include <glib.h> -#include <cal-client/cal-client.h> -#include <cal-util/cal-component.h> +#include <libecal/e-cal.h> +#include <libecal/e-cal-component.h> -gboolean cancel_component_dialog (GtkWindow *parent, CalClient *client, CalComponent *comp, gboolean deleting); +gboolean cancel_component_dialog (GtkWindow *parent, ECal *client, ECalComponent *comp, gboolean deleting); #endif diff --git a/calendar/gui/dialogs/changed-comp.c b/calendar/gui/dialogs/changed-comp.c index 6d7ab0fc49..799a22579b 100644 --- a/calendar/gui/dialogs/changed-comp.c +++ b/calendar/gui/dialogs/changed-comp.c @@ -44,26 +44,26 @@ * Return value: TRUE if the user clicked Yes, FALSE otherwise. **/ gboolean -changed_component_dialog (GtkWindow *parent, CalComponent *comp, gboolean deleted, gboolean changed) +changed_component_dialog (GtkWindow *parent, ECalComponent *comp, gboolean deleted, gboolean changed) { GtkWidget *dialog; - CalComponentVType vtype; + ECalComponentVType vtype; char *str; gint response; - vtype = cal_component_get_vtype (comp); + vtype = e_cal_component_get_vtype (comp); if (deleted) { switch (vtype) { - case CAL_COMPONENT_EVENT: + case E_CAL_COMPONENT_EVENT: str = _("This event has been deleted."); break; - case CAL_COMPONENT_TODO: + case E_CAL_COMPONENT_TODO: str = _("This task has been deleted."); break; - case CAL_COMPONENT_JOURNAL: + case E_CAL_COMPONENT_JOURNAL: str = _("This journal entry has been deleted."); break; @@ -79,15 +79,15 @@ changed_component_dialog (GtkWindow *parent, CalComponent *comp, gboolean delete } else { switch (vtype) { - case CAL_COMPONENT_EVENT: + case E_CAL_COMPONENT_EVENT: str = _("This event has been changed."); break; - case CAL_COMPONENT_TODO: + case E_CAL_COMPONENT_TODO: str = _("This task has been changed."); break; - case CAL_COMPONENT_JOURNAL: + case E_CAL_COMPONENT_JOURNAL: str = _("This journal entry has been changed."); break; diff --git a/calendar/gui/dialogs/changed-comp.h b/calendar/gui/dialogs/changed-comp.h index a29e1a5fc4..f029f3388e 100644 --- a/calendar/gui/dialogs/changed-comp.h +++ b/calendar/gui/dialogs/changed-comp.h @@ -23,8 +23,8 @@ #include <glib.h> #include <gtk/gtkwindow.h> -#include <cal-util/cal-component.h> +#include <libecal/e-cal-component.h> -gboolean changed_component_dialog (GtkWindow *window, CalComponent *comp, gboolean deleted, gboolean changed); +gboolean changed_component_dialog (GtkWindow *window, ECalComponent *comp, gboolean deleted, gboolean changed); #endif diff --git a/calendar/gui/dialogs/comp-editor-page.c b/calendar/gui/dialogs/comp-editor-page.c index a0fdcca3a8..1a6611b017 100644 --- a/calendar/gui/dialogs/comp-editor-page.c +++ b/calendar/gui/dialogs/comp-editor-page.c @@ -225,7 +225,7 @@ comp_editor_page_focus_main_widget (CompEditorPage *page) * Fills the widgets of an editor page with the data from a calendar component. **/ void -comp_editor_page_fill_widgets (CompEditorPage *page, CalComponent *comp) +comp_editor_page_fill_widgets (CompEditorPage *page, ECalComponent *comp) { g_return_if_fail (page != NULL); g_return_if_fail (IS_COMP_EDITOR_PAGE (page)); @@ -247,7 +247,7 @@ comp_editor_page_fill_widgets (CompEditorPage *page, CalComponent *comp) * Returns: TRUE if the component could be filled, FALSE otherwise **/ gboolean -comp_editor_page_fill_component (CompEditorPage *page, CalComponent *comp) +comp_editor_page_fill_component (CompEditorPage *page, ECalComponent *comp) { g_return_val_if_fail (page != NULL, FALSE); g_return_val_if_fail (IS_COMP_EDITOR_PAGE (page), FALSE); @@ -260,14 +260,14 @@ comp_editor_page_fill_component (CompEditorPage *page, CalComponent *comp) } /** - * comp_editor_page_set_cal_client: + * comp_editor_page_set_e_cal: * @page: An editor page - * @client: A #CalClient object + * @client: A #ECal object * - * Sets the #CalClient for the dialog page to use. + * Sets the #ECal for the dialog page to use. **/ void -comp_editor_page_set_cal_client (CompEditorPage *page, CalClient *client) +comp_editor_page_set_e_cal (CompEditorPage *page, ECal *client) { g_return_if_fail (page != NULL); g_return_if_fail (IS_COMP_EDITOR_PAGE (page)); diff --git a/calendar/gui/dialogs/comp-editor-page.h b/calendar/gui/dialogs/comp-editor-page.h index e3d4535391..6046a7c039 100644 --- a/calendar/gui/dialogs/comp-editor-page.h +++ b/calendar/gui/dialogs/comp-editor-page.h @@ -23,8 +23,8 @@ #include <time.h> #include <gtk/gtkwidget.h> -#include <cal-util/cal-component.h> -#include "cal-client.h" +#include <libecal/e-cal-component.h> +#include <libecal/e-cal.h> G_BEGIN_DECLS @@ -37,17 +37,17 @@ G_BEGIN_DECLS #define IS_COMP_EDITOR_PAGE_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((obj), TYPE_COMP_EDITOR_PAGE)) typedef struct { - CalComponentDateTime *start; - CalComponentDateTime *end; - CalComponentDateTime *due; + ECalComponentDateTime *start; + ECalComponentDateTime *end; + ECalComponentDateTime *due; struct icaltimetype *complete; } CompEditorPageDates; typedef struct { GtkObject object; - /* Some of the pages need the CalClient to access timezone data. */ - CalClient *client; + /* Some of the pages need the ECal to access timezone data. */ + ECal *client; /* The GtkAccelGroup for the page. We install this when the page is mapped, and uninstall when it is unmapped. libglade would do this @@ -72,8 +72,8 @@ typedef struct { GtkWidget *(* get_widget) (CompEditorPage *page); void (* focus_main_widget) (CompEditorPage *page); - void (* fill_widgets) (CompEditorPage *page, CalComponent *comp); - gboolean (* fill_component) (CompEditorPage *page, CalComponent *comp); + void (* fill_widgets) (CompEditorPage *page, ECalComponent *comp); + gboolean (* fill_component) (CompEditorPage *page, ECalComponent *comp); void (* set_summary) (CompEditorPage *page, const char *summary); void (* set_dates) (CompEditorPage *page, CompEditorPageDates *dates); @@ -84,11 +84,11 @@ GtkType comp_editor_page_get_type (void); GtkWidget *comp_editor_page_get_widget (CompEditorPage *page); void comp_editor_page_focus_main_widget (CompEditorPage *page); void comp_editor_page_fill_widgets (CompEditorPage *page, - CalComponent *comp); + ECalComponent *comp); gboolean comp_editor_page_fill_component (CompEditorPage *page, - CalComponent *comp); -void comp_editor_page_set_cal_client (CompEditorPage *page, - CalClient *client); + ECalComponent *comp); +void comp_editor_page_set_e_cal (CompEditorPage *page, + ECal *client); void comp_editor_page_set_summary (CompEditorPage *page, const char *summary); void comp_editor_page_set_dates (CompEditorPage *page, diff --git a/calendar/gui/dialogs/comp-editor-util.c b/calendar/gui/dialogs/comp-editor-util.c index 4c3b683ec4..bdb66c6c92 100644 --- a/calendar/gui/dialogs/comp-editor-util.c +++ b/calendar/gui/dialogs/comp-editor-util.c @@ -32,7 +32,7 @@ #include <bonobo/bonobo-control.h> #include <bonobo/bonobo-widget.h> #include <e-util/e-time-utils.h> -#include <cal-util/timeutil.h> +#include <libecal/e-cal-time-util.h> #include "../calendar-config.h" #include "../e-date-edit-config.h" #include "comp-editor-util.h" @@ -49,37 +49,37 @@ * results. **/ void -comp_editor_dates (CompEditorPageDates *dates, CalComponent *comp) +comp_editor_dates (CompEditorPageDates *dates, ECalComponent *comp) { - CalComponentDateTime dt; + ECalComponentDateTime dt; dates->start = NULL; dates->end = NULL; dates->due = NULL; dates->complete = NULL; - /* Note that the CalComponentDateTime's returned contain allocated + /* Note that the ECalComponentDateTime's returned contain allocated icaltimetype and tzid values, so we just take over ownership of those. */ - cal_component_get_dtstart (comp, &dt); + e_cal_component_get_dtstart (comp, &dt); if (dt.value) { - dates->start = g_new (CalComponentDateTime, 1); + dates->start = g_new (ECalComponentDateTime, 1); *dates->start = dt; } - cal_component_get_dtend (comp, &dt); + e_cal_component_get_dtend (comp, &dt); if (dt.value) { - dates->end = g_new (CalComponentDateTime, 1); + dates->end = g_new (ECalComponentDateTime, 1); *dates->end = dt; } - cal_component_get_due (comp, &dt); + e_cal_component_get_due (comp, &dt); if (dt.value) { - dates->due = g_new (CalComponentDateTime, 1); + dates->due = g_new (ECalComponentDateTime, 1); *dates->due = dt; } - cal_component_get_completed (comp, &dates->complete); + e_cal_component_get_completed (comp, &dates->complete); } @@ -89,25 +89,25 @@ comp_editor_dates (CompEditorPageDates *dates, CalComponent *comp) void comp_editor_free_dates (CompEditorPageDates *dates) { - /* Note that cal_component_free_datetime() only frees the fields in + /* Note that e_cal_component_free_datetime() only frees the fields in the struct. It doesn't free the struct itself, so we do that. */ if (dates->start) { - cal_component_free_datetime (dates->start); + e_cal_component_free_datetime (dates->start); g_free (dates->start); } if (dates->end) { - cal_component_free_datetime (dates->end); + e_cal_component_free_datetime (dates->end); g_free (dates->end); } if (dates->due) { - cal_component_free_datetime (dates->due); + e_cal_component_free_datetime (dates->due); g_free (dates->due); } if (dates->complete) - cal_component_free_icaltimetype (dates->complete); + e_cal_component_free_icaltimetype (dates->complete); } diff --git a/calendar/gui/dialogs/comp-editor-util.h b/calendar/gui/dialogs/comp-editor-util.h index 04bbe23cf4..078cd6508c 100644 --- a/calendar/gui/dialogs/comp-editor-util.h +++ b/calendar/gui/dialogs/comp-editor-util.h @@ -24,7 +24,7 @@ #include <gtk/gtkwidget.h> #include "comp-editor-page.h" -void comp_editor_dates (CompEditorPageDates *date, CalComponent *comp); +void comp_editor_dates (CompEditorPageDates *date, ECalComponent *comp); void comp_editor_free_dates (CompEditorPageDates *dates); void comp_editor_date_label (CompEditorPageDates *dates, GtkWidget *label); diff --git a/calendar/gui/dialogs/comp-editor.c b/calendar/gui/dialogs/comp-editor.c index 14dad44b2a..5e88774ae5 100644 --- a/calendar/gui/dialogs/comp-editor.c +++ b/calendar/gui/dialogs/comp-editor.c @@ -55,10 +55,10 @@ /* Private part of the CompEditor structure */ struct _CompEditorPrivate { /* Client to use */ - CalClient *client; + ECal *client; /* Calendar object/uid we are editing; this is an internal copy */ - CalComponent *comp; + ECalComponent *comp; /* The pages we have */ GList *pages; @@ -91,9 +91,9 @@ static void comp_editor_init (CompEditor *editor); static gint comp_editor_key_press_event (GtkWidget *d, GdkEventKey *e); static void comp_editor_finalize (GObject *object); -static void real_set_cal_client (CompEditor *editor, CalClient *client); -static void real_edit_comp (CompEditor *editor, CalComponent *comp); -static gboolean real_send_comp (CompEditor *editor, CalComponentItipMethod method); +static void real_set_e_cal (CompEditor *editor, ECal *client); +static void real_edit_comp (CompEditor *editor, ECalComponent *comp); +static gboolean real_send_comp (CompEditor *editor, ECalComponentItipMethod method); static gboolean prompt_to_save_changes (CompEditor *editor, gboolean send); static void delete_comp (CompEditor *editor); static void close_dialog (CompEditor *editor); @@ -102,8 +102,8 @@ static void page_changed_cb (GtkObject *obj, gpointer data); static void page_summary_changed_cb (GtkObject *obj, const char *summary, gpointer data); static void page_dates_changed_cb (GtkObject *obj, CompEditorPageDates *dates, gpointer data); -static void obj_updated_cb (CalClient *client, const char *uid, gpointer data); -static void obj_removed_cb (CalClient *client, const char *uid, gpointer data); +static void obj_updated_cb (ECal *client, const char *uid, gpointer data); +static void obj_removed_cb (ECal *client, const char *uid, gpointer data); static void save_cmd (GtkWidget *widget, gpointer data); static void save_close_cmd (GtkWidget *widget, gpointer data); @@ -166,7 +166,7 @@ comp_editor_class_init (CompEditorClass *klass) parent_class = g_type_class_ref(BONOBO_TYPE_WINDOW); - klass->set_cal_client = real_set_cal_client; + klass->set_e_cal = real_set_e_cal; klass->edit_comp = real_edit_comp; klass->send_comp = real_send_comp; @@ -293,7 +293,7 @@ static gboolean save_comp (CompEditor *editor) { CompEditorPrivate *priv; - CalComponent *clone; + ECalComponent *clone; GList *l; gboolean result; GError *error = NULL; @@ -303,7 +303,7 @@ save_comp (CompEditor *editor) if (!priv->changed) return TRUE; - clone = cal_component_clone (priv->comp); + clone = e_cal_component_clone (priv->comp); for (l = priv->pages; l != NULL; l = l->next) { if (!comp_editor_page_fill_component (l->data, clone)) { g_object_unref((clone)); @@ -313,10 +313,10 @@ save_comp (CompEditor *editor) } /* If we are not the organizer, we don't update the sequence number */ - if (!cal_component_has_organizer (clone) || itip_organizer_is_user (clone, priv->client)) - cal_component_commit_sequence (clone); + if (!e_cal_component_has_organizer (clone) || itip_organizer_is_user (clone, priv->client)) + e_cal_component_commit_sequence (clone); else - cal_component_abort_sequence (clone); + e_cal_component_abort_sequence (clone); g_object_unref((priv->comp)); priv->comp = clone; @@ -324,9 +324,9 @@ save_comp (CompEditor *editor) priv->updating = TRUE; if (!cal_comp_is_on_server (priv->comp, priv->client)) { - result = cal_client_create_object (priv->client, cal_component_get_icalcomponent (priv->comp), NULL, &error); + result = e_cal_create_object (priv->client, e_cal_component_get_icalcomponent (priv->comp), NULL, &error); } else { - result = cal_client_modify_object (priv->client, cal_component_get_icalcomponent (priv->comp), priv->mod, &error); + result = e_cal_modify_object (priv->client, e_cal_component_get_icalcomponent (priv->comp), priv->mod, &error); } if (!result) { @@ -367,9 +367,9 @@ save_comp_with_send (CompEditor *editor) if (send && send_component_dialog ((GtkWindow *) editor, priv->client, priv->comp, !priv->existing_org)) { if (itip_organizer_is_user (priv->comp, priv->client)) - return comp_editor_send_comp (editor, CAL_COMPONENT_METHOD_REQUEST); + return comp_editor_send_comp (editor, E_CAL_COMPONENT_METHOD_REQUEST); else - return comp_editor_send_comp (editor, CAL_COMPONENT_METHOD_REPLY); + return comp_editor_send_comp (editor, E_CAL_COMPONENT_METHOD_REPLY); } return TRUE; @@ -383,9 +383,9 @@ delete_comp (CompEditor *editor) priv = editor->priv; - cal_component_get_uid (priv->comp, &uid); + e_cal_component_get_uid (priv->comp, &uid); priv->updating = TRUE; - cal_client_remove_object (priv->client, uid, NULL); + e_cal_remove_object (priv->client, uid, NULL); priv->updating = FALSE; close_dialog (editor); } @@ -402,7 +402,7 @@ prompt_to_save_changes (CompEditor *editor, gboolean send) switch (save_component_dialog (GTK_WINDOW (editor))) { case GTK_RESPONSE_YES: /* Save */ - if (cal_component_is_instance (priv->comp)) + if (e_cal_component_is_instance (priv->comp)) if (!recur_component_dialog (priv->client, priv->comp, &priv->mod, GTK_WINDOW (editor))) return FALSE; @@ -631,7 +631,7 @@ comp_editor_append_page (CompEditor *editor, /* If we are editing something, fill the widgets with current info */ if (priv->comp != NULL) { - CalComponent *comp; + ECalComponent *comp; comp = comp_editor_get_current_comp (editor); comp_editor_page_fill_widgets (page, comp); @@ -733,14 +733,14 @@ comp_editor_show_page (CompEditor *editor, CompEditorPage *page) } /** - * comp_editor_set_cal_client: + * comp_editor_set_e_cal: * @editor: A component editor * @client: The calendar client to use * * Sets the calendar client used by the editor to update components **/ void -comp_editor_set_cal_client (CompEditor *editor, CalClient *client) +comp_editor_set_e_cal (CompEditor *editor, ECal *client) { CompEditorClass *klass; @@ -749,20 +749,20 @@ comp_editor_set_cal_client (CompEditor *editor, CalClient *client) klass = COMP_EDITOR_CLASS (G_OBJECT_GET_CLASS (editor)); - if (klass->set_cal_client) - klass->set_cal_client (editor, client); + if (klass->set_e_cal) + klass->set_e_cal (editor, client); } /** - * comp_editor_get_cal_client: + * comp_editor_get_e_cal: * @editor: A component editor * * Returns the calendar client of the editor * * Return value: The calendar client of the editor **/ -CalClient * -comp_editor_get_cal_client (CompEditor *editor) +ECal * +comp_editor_get_e_cal (CompEditor *editor) { CompEditorPrivate *priv; @@ -776,25 +776,25 @@ comp_editor_get_cal_client (CompEditor *editor) /* Creates an appropriate title for the event editor dialog */ static char * -make_title_from_comp (CalComponent *comp) +make_title_from_comp (ECalComponent *comp) { char *title; const char *type_string; - CalComponentVType type; - CalComponentText text; + ECalComponentVType type; + ECalComponentText text; if (!comp) return g_strdup (_("Edit Appointment")); - type = cal_component_get_vtype (comp); + type = e_cal_component_get_vtype (comp); switch (type) { - case CAL_COMPONENT_EVENT: + case E_CAL_COMPONENT_EVENT: type_string = _("Appointment - %s"); break; - case CAL_COMPONENT_TODO: + case E_CAL_COMPONENT_TODO: type_string = _("Task - %s"); break; - case CAL_COMPONENT_JOURNAL: + case E_CAL_COMPONENT_JOURNAL: type_string = _("Journal entry - %s"); break; default: @@ -802,7 +802,7 @@ make_title_from_comp (CalComponent *comp) return NULL; } - cal_component_get_summary (comp, &text); + e_cal_component_get_summary (comp, &text); if (text.value) { title = g_strdup_printf (type_string, text.value); } else { @@ -814,24 +814,24 @@ make_title_from_comp (CalComponent *comp) /* Creates an appropriate title for the event editor dialog */ static char * -make_title_from_string (CalComponent *comp, const char *str) +make_title_from_string (ECalComponent *comp, const char *str) { char *title; const char *type_string; - CalComponentVType type; + ECalComponentVType type; if (!comp) return g_strdup (_("Edit Appointment")); - type = cal_component_get_vtype (comp); + type = e_cal_component_get_vtype (comp); switch (type) { - case CAL_COMPONENT_EVENT: + case E_CAL_COMPONENT_EVENT: type_string = _("Appointment - %s"); break; - case CAL_COMPONENT_TODO: + case E_CAL_COMPONENT_TODO: type_string = _("Task - %s"); break; - case CAL_COMPONENT_JOURNAL: + case E_CAL_COMPONENT_JOURNAL: type_string = _("Journal entry - %s"); break; default: @@ -849,19 +849,19 @@ make_title_from_string (CalComponent *comp, const char *str) } static const char * -make_icon_from_comp (CalComponent *comp) +make_icon_from_comp (ECalComponent *comp) { - CalComponentVType type; + ECalComponentVType type; if (!comp) return EVOLUTION_IMAGESDIR "/evolution-calendar-mini.png"; - type = cal_component_get_vtype (comp); + type = e_cal_component_get_vtype (comp); switch (type) { - case CAL_COMPONENT_EVENT: + case E_CAL_COMPONENT_EVENT: return EVOLUTION_IMAGESDIR "/buttons/new_appointment.png"; break; - case CAL_COMPONENT_TODO: + case E_CAL_COMPONENT_TODO: return EVOLUTION_IMAGESDIR "/buttons/new_task.png"; break; default: @@ -918,7 +918,7 @@ fill_widgets (CompEditor *editor) } static void -real_set_cal_client (CompEditor *editor, CalClient *client) +real_set_e_cal (CompEditor *editor, ECal *client) { CompEditorPrivate *priv; GList *elem; @@ -932,9 +932,9 @@ real_set_cal_client (CompEditor *editor, CalClient *client) return; if (client) { - g_return_if_fail (IS_CAL_CLIENT (client)); - g_return_if_fail (cal_client_get_load_state (client) == - CAL_CLIENT_LOAD_LOADED); + g_return_if_fail (E_IS_CAL (client)); + g_return_if_fail (e_cal_get_load_state (client) == + E_CAL_LOAD_LOADED); g_object_ref((client)); } @@ -948,7 +948,7 @@ real_set_cal_client (CompEditor *editor, CalClient *client) /* Pass the client to any pages that need it. */ for (elem = priv->pages; elem; elem = elem->next) - comp_editor_page_set_cal_client (elem->data, client); + comp_editor_page_set_e_cal (elem->data, client); g_signal_connect((priv->client), "obj_updated", G_CALLBACK (obj_updated_cb), editor); @@ -958,7 +958,7 @@ real_set_cal_client (CompEditor *editor, CalClient *client) } static void -real_edit_comp (CompEditor *editor, CalComponent *comp) +real_edit_comp (CompEditor *editor, ECalComponent *comp) { CompEditorPrivate *priv; @@ -973,9 +973,9 @@ real_edit_comp (CompEditor *editor, CalComponent *comp) } if (comp) - priv->comp = cal_component_clone (comp); + priv->comp = e_cal_component_clone (comp); - priv->existing_org = cal_component_has_organizer (comp); + priv->existing_org = e_cal_component_has_organizer (comp); priv->user_org = itip_organizer_is_user (comp, priv->client); priv->warned = FALSE; @@ -986,10 +986,10 @@ real_edit_comp (CompEditor *editor, CalComponent *comp) static gboolean -real_send_comp (CompEditor *editor, CalComponentItipMethod method) +real_send_comp (CompEditor *editor, ECalComponentItipMethod method) { CompEditorPrivate *priv; - CalComponent *tmp_comp; + ECalComponent *tmp_comp; g_return_val_if_fail (editor != NULL, FALSE); g_return_val_if_fail (IS_COMP_EDITOR (editor), FALSE); @@ -1022,14 +1022,14 @@ real_send_comp (CompEditor *editor, CalComponentItipMethod method) * Starts the editor editing the given component **/ void -comp_editor_edit_comp (CompEditor *editor, CalComponent *comp) +comp_editor_edit_comp (CompEditor *editor, ECalComponent *comp) { CompEditorClass *klass; g_return_if_fail (editor != NULL); g_return_if_fail (IS_COMP_EDITOR (editor)); g_return_if_fail (comp != NULL); - g_return_if_fail (IS_CAL_COMPONENT (comp)); + g_return_if_fail (E_IS_CAL_COMPONENT (comp)); klass = COMP_EDITOR_CLASS (G_OBJECT_GET_CLASS (editor)); @@ -1037,7 +1037,7 @@ comp_editor_edit_comp (CompEditor *editor, CalComponent *comp) klass->edit_comp (editor, comp); } -CalComponent * +ECalComponent * comp_editor_get_comp (CompEditor *editor) { CompEditorPrivate *priv; @@ -1050,11 +1050,11 @@ comp_editor_get_comp (CompEditor *editor) return priv->comp; } -CalComponent * +ECalComponent * comp_editor_get_current_comp (CompEditor *editor) { CompEditorPrivate *priv; - CalComponent *comp; + ECalComponent *comp; GList *l; g_return_val_if_fail (editor != NULL, NULL); @@ -1062,7 +1062,7 @@ comp_editor_get_current_comp (CompEditor *editor) priv = editor->priv; - comp = cal_component_clone (priv->comp); + comp = e_cal_component_clone (priv->comp); if (priv->changed) { for (l = priv->pages; l != NULL; l = l->next) comp_editor_page_fill_component (l->data, comp); @@ -1103,7 +1103,7 @@ comp_editor_delete_comp (CompEditor *editor) * **/ gboolean -comp_editor_send_comp (CompEditor *editor, CalComponentItipMethod method) +comp_editor_send_comp (CompEditor *editor, ECalComponentItipMethod method) { CompEditorClass *klass; @@ -1234,7 +1234,7 @@ save_cmd (GtkWidget *widget, gpointer data) commit_all_fields (editor); - if (cal_component_is_instance (priv->comp)) + if (e_cal_component_is_instance (priv->comp)) if (!recur_component_dialog (priv->client, priv->comp, &priv->mod, GTK_WINDOW (editor))) return; @@ -1251,7 +1251,7 @@ save_close_cmd (GtkWidget *widget, gpointer data) commit_all_fields (editor); - if (cal_component_is_instance (priv->comp)) + if (e_cal_component_is_instance (priv->comp)) if (!recur_component_dialog (priv->client, priv->comp, &priv->mod, GTK_WINDOW (editor))) return; @@ -1276,8 +1276,8 @@ save_as_cmd (GtkWidget *widget, gpointer data) if (filename == NULL) return; - ical_string = cal_client_get_component_as_string (priv->client, - cal_component_get_icalcomponent (priv->comp)); + ical_string = e_cal_get_component_as_string (priv->client, + e_cal_component_get_icalcomponent (priv->comp)); if (ical_string == NULL) { g_warning ("Couldn't convert item to a string"); return; @@ -1299,17 +1299,17 @@ delete_cmd (GtkWidget *widget, gpointer data) { CompEditor *editor = COMP_EDITOR (data); CompEditorPrivate *priv; - CalComponentVType vtype; + ECalComponentVType vtype; priv = editor->priv; - vtype = cal_component_get_vtype (priv->comp); + vtype = e_cal_component_get_vtype (priv->comp); if (delete_component_dialog (priv->comp, FALSE, 1, vtype, GTK_WIDGET (editor))) { if (itip_organizer_is_user (priv->comp, priv->client) && cancel_component_dialog ((GtkWindow *) editor, priv->client, priv->comp, TRUE)) - itip_send_comp (CAL_COMPONENT_METHOD_CANCEL, priv->comp, priv->client, NULL); + itip_send_comp (E_CAL_COMPONENT_METHOD_CANCEL, priv->comp, priv->client, NULL); delete_comp (editor); } @@ -1319,7 +1319,7 @@ static void print_cmd (GtkWidget *widget, gpointer data) { CompEditor *editor = COMP_EDITOR (data); - CalComponent *comp; + ECalComponent *comp; commit_all_fields (editor); @@ -1332,7 +1332,7 @@ static void print_preview_cmd (GtkWidget *widget, gpointer data) { CompEditor *editor = COMP_EDITOR (data); - CalComponent *comp; + ECalComponent *comp; commit_all_fields (editor); @@ -1431,24 +1431,24 @@ page_dates_changed_cb (GtkObject *obj, } static void -obj_updated_cb (CalClient *client, const char *uid, gpointer data) +obj_updated_cb (ECal *client, const char *uid, gpointer data) { CompEditor *editor = COMP_EDITOR (data); CompEditorPrivate *priv; - CalComponent *comp = NULL; + ECalComponent *comp = NULL; const char *edit_uid; priv = editor->priv; - cal_component_get_uid (priv->comp, &edit_uid); + e_cal_component_get_uid (priv->comp, &edit_uid); if (!strcmp (uid, edit_uid) && !priv->updating) { if (changed_component_dialog ((GtkWindow *) editor, priv->comp, FALSE, priv->changed)) { icalcomponent *icalcomp; - if (!cal_client_get_object (priv->client, uid, NULL, &icalcomp, NULL)) { - comp = cal_component_new (); - if (cal_component_set_icalcomponent (comp, icalcomp)) + if (!e_cal_get_object (priv->client, uid, NULL, &icalcomp, NULL)) { + comp = e_cal_component_new (); + if (e_cal_component_set_icalcomponent (comp, icalcomp)) comp_editor_edit_comp (editor, comp); else { GtkWidget *dlg; @@ -1470,7 +1470,7 @@ obj_updated_cb (CalClient *client, const char *uid, gpointer data) } static void -obj_removed_cb (CalClient *client, const char *uid, gpointer data) +obj_removed_cb (ECal *client, const char *uid, gpointer data) { CompEditor *editor = COMP_EDITOR (data); CompEditorPrivate *priv; @@ -1478,7 +1478,7 @@ obj_removed_cb (CalClient *client, const char *uid, gpointer data) priv = editor->priv; - cal_component_get_uid (priv->comp, &edit_uid); + e_cal_component_get_uid (priv->comp, &edit_uid); if (!strcmp (uid, edit_uid) && !priv->updating) { if (changed_component_dialog ((GtkWindow *) editor, priv->comp, TRUE, priv->changed)) diff --git a/calendar/gui/dialogs/comp-editor.h b/calendar/gui/dialogs/comp-editor.h index 8ef14c8edb..67684c0806 100644 --- a/calendar/gui/dialogs/comp-editor.h +++ b/calendar/gui/dialogs/comp-editor.h @@ -25,7 +25,7 @@ #include <bonobo/bonobo-window.h> #include <bonobo/bonobo-ui-engine.h> #include <bonobo/bonobo-ui-component.h> -#include "cal-client.h" +#include <libecal/e-cal.h> #include "../itip-utils.h" #include "comp-editor-page.h" #include "evolution-shell-component-utils.h" @@ -53,9 +53,9 @@ typedef struct { BonoboWindowClass parent_class; /* Virtual functions */ - void (* set_cal_client) (CompEditor *page, CalClient *client); - void (* edit_comp) (CompEditor *page, CalComponent *comp); - gboolean (* send_comp) (CompEditor *page, CalComponentItipMethod method); + void (* set_e_cal) (CompEditor *page, ECal *client); + void (* edit_comp) (CompEditor *page, ECalComponent *comp); + gboolean (* send_comp) (CompEditor *page, ECalComponentItipMethod method); } CompEditorClass; GtkType comp_editor_get_type (void); @@ -78,18 +78,18 @@ void comp_editor_remove_page (CompEditor *editor, CompEditorPage *page); void comp_editor_show_page (CompEditor *editor, CompEditorPage *page); -void comp_editor_set_cal_client (CompEditor *editor, - CalClient *client); -CalClient *comp_editor_get_cal_client (CompEditor *editor); +void comp_editor_set_e_cal (CompEditor *editor, + ECal *client); +ECal *comp_editor_get_e_cal (CompEditor *editor); void comp_editor_edit_comp (CompEditor *ee, - CalComponent *comp); -CalComponent *comp_editor_get_comp (CompEditor *editor); -CalComponent *comp_editor_get_current_comp (CompEditor *editor); + ECalComponent *comp); +ECalComponent *comp_editor_get_comp (CompEditor *editor); +ECalComponent *comp_editor_get_current_comp (CompEditor *editor); gboolean comp_editor_save_comp (CompEditor *editor, gboolean send); void comp_editor_delete_comp (CompEditor *editor); gboolean comp_editor_send_comp (CompEditor *editor, - CalComponentItipMethod method); + ECalComponentItipMethod method); gboolean comp_editor_close (CompEditor *editor); void comp_editor_merge_ui (CompEditor *editor, const char *filename, diff --git a/calendar/gui/dialogs/delete-comp.c b/calendar/gui/dialogs/delete-comp.c index b29c6305ce..adaa8895fa 100644 --- a/calendar/gui/dialogs/delete-comp.c +++ b/calendar/gui/dialogs/delete-comp.c @@ -55,9 +55,9 @@ * unconditionally return TRUE. **/ gboolean -delete_component_dialog (CalComponent *comp, +delete_component_dialog (ECalComponent *comp, gboolean consider_as_untitled, - int n_comps, CalComponentVType vtype, + int n_comps, ECalComponentVType vtype, GtkWidget *widget) { char *str; @@ -65,11 +65,11 @@ delete_component_dialog (CalComponent *comp, int ret; if (comp) { - g_return_val_if_fail (IS_CAL_COMPONENT (comp), FALSE); + g_return_val_if_fail (E_IS_CAL_COMPONENT (comp), FALSE); g_return_val_if_fail (n_comps == 1, FALSE); } else { g_return_val_if_fail (n_comps > 1, FALSE); - g_return_val_if_fail (vtype != CAL_COMPONENT_NO_TYPE, FALSE); + g_return_val_if_fail (vtype != E_CAL_COMPONENT_NO_TYPE, FALSE); } g_return_val_if_fail (widget != NULL, FALSE); @@ -79,19 +79,19 @@ delete_component_dialog (CalComponent *comp, return TRUE; if (comp) { - CalComponentText summary; + ECalComponentText summary; char *tmp; - vtype = cal_component_get_vtype (comp); + vtype = e_cal_component_get_vtype (comp); if (!consider_as_untitled) { - cal_component_get_summary (comp, &summary); + e_cal_component_get_summary (comp, &summary); tmp = g_strdup (summary.value); } else tmp = NULL; switch (vtype) { - case CAL_COMPONENT_EVENT: + case E_CAL_COMPONENT_EVENT: if (tmp) str = g_strdup_printf (_("Are you sure you want to delete " "the appointment `%s'?"), tmp); @@ -100,7 +100,7 @@ delete_component_dialog (CalComponent *comp, "untitled appointment?")); break; - case CAL_COMPONENT_TODO: + case E_CAL_COMPONENT_TODO: if (tmp) str = g_strdup_printf (_("Are you sure you want to delete " "the task `%s'?"), tmp); @@ -109,7 +109,7 @@ delete_component_dialog (CalComponent *comp, "untitled task?")); break; - case CAL_COMPONENT_JOURNAL: + case E_CAL_COMPONENT_JOURNAL: if (tmp) str = g_strdup_printf (_("Are you sure you want to delete " "the journal entry `%s'?"), tmp); @@ -128,17 +128,17 @@ delete_component_dialog (CalComponent *comp, g_free (tmp); } else { switch (vtype) { - case CAL_COMPONENT_EVENT: + case E_CAL_COMPONENT_EVENT: str = g_strdup_printf (_("Are you sure you want to delete " "%d appointments?"), n_comps); break; - case CAL_COMPONENT_TODO: + case E_CAL_COMPONENT_TODO: str = g_strdup_printf (_("Are you sure you want to delete " "%d tasks?"), n_comps); break; - case CAL_COMPONENT_JOURNAL: + case E_CAL_COMPONENT_JOURNAL: str = g_strdup_printf (_("Are you sure you want to delete " "%d journal entries?"), n_comps); break; diff --git a/calendar/gui/dialogs/delete-comp.h b/calendar/gui/dialogs/delete-comp.h index 64945b5bee..f8773c25d0 100644 --- a/calendar/gui/dialogs/delete-comp.h +++ b/calendar/gui/dialogs/delete-comp.h @@ -22,11 +22,11 @@ #define DELETE_COMP_H #include <gtk/gtkwidget.h> -#include <cal-util/cal-component.h> +#include <libecal/e-cal-component.h> -gboolean delete_component_dialog (CalComponent *comp, +gboolean delete_component_dialog (ECalComponent *comp, gboolean consider_as_untitled, - int n_comps, CalComponentVType vtype, + int n_comps, ECalComponentVType vtype, GtkWidget *widget); #endif diff --git a/calendar/gui/dialogs/delete-error.c b/calendar/gui/dialogs/delete-error.c index edbcaf9880..bc9c958862 100644 --- a/calendar/gui/dialogs/delete-error.c +++ b/calendar/gui/dialogs/delete-error.c @@ -38,7 +38,7 @@ * **/ void -delete_error_dialog (GError *error, CalComponentVType vtype) +delete_error_dialog (GError *error, ECalComponentVType vtype) { GtkWidget *dialog; const char *str; @@ -49,13 +49,13 @@ delete_error_dialog (GError *error, CalComponentVType vtype) switch (error->code) { case E_CALENDAR_STATUS_CORBA_EXCEPTION: switch (vtype) { - case CAL_COMPONENT_EVENT: + case E_CAL_COMPONENT_EVENT: str = _("The event could not be deleted due to a corba error"); break; - case CAL_COMPONENT_TODO: + case E_CAL_COMPONENT_TODO: str = _("The task could not be deleted due to a corba error"); break; - case CAL_COMPONENT_JOURNAL: + case E_CAL_COMPONENT_JOURNAL: str = _("The journal entry could not be deleted due to a corba error"); break; default: @@ -65,13 +65,13 @@ delete_error_dialog (GError *error, CalComponentVType vtype) break; case E_CALENDAR_STATUS_PERMISSION_DENIED: switch (vtype) { - case CAL_COMPONENT_EVENT: + case E_CAL_COMPONENT_EVENT: str = _("The event could not be deleted because permission was denied"); break; - case CAL_COMPONENT_TODO: + case E_CAL_COMPONENT_TODO: str = _("The task could not be deleted because permission was denied"); break; - case CAL_COMPONENT_JOURNAL: + case E_CAL_COMPONENT_JOURNAL: str = _("The journal entry could not be deleted because permission was denied"); break; default: @@ -81,13 +81,13 @@ delete_error_dialog (GError *error, CalComponentVType vtype) break; case E_CALENDAR_STATUS_OTHER_ERROR: switch (vtype) { - case CAL_COMPONENT_EVENT: + case E_CAL_COMPONENT_EVENT: str = _("The event could not be deleted due to an error"); break; - case CAL_COMPONENT_TODO: + case E_CAL_COMPONENT_TODO: str = _("The task could not be deleted due to an error"); break; - case CAL_COMPONENT_JOURNAL: + case E_CAL_COMPONENT_JOURNAL: str = _("The journal entry could not be deleted due to an error"); break; default: diff --git a/calendar/gui/dialogs/delete-error.h b/calendar/gui/dialogs/delete-error.h index 4ac8cf4515..68c132e479 100644 --- a/calendar/gui/dialogs/delete-error.h +++ b/calendar/gui/dialogs/delete-error.h @@ -22,9 +22,9 @@ #define DELETE_ERROR_H #include <glib.h> -#include <cal-client/cal-client.h> -#include <cal-util/cal-component.h> +#include <libecal/e-cal.h> +#include <libecal/e-cal-component.h> -void delete_error_dialog (GError *error, CalComponentVType vtype); +void delete_error_dialog (GError *error, ECalComponentVType vtype); #endif diff --git a/calendar/gui/dialogs/event-editor.c b/calendar/gui/dialogs/event-editor.c index 861a52c203..c3ba39aada 100644 --- a/calendar/gui/dialogs/event-editor.c +++ b/calendar/gui/dialogs/event-editor.c @@ -56,9 +56,9 @@ struct _EventEditorPrivate { static void event_editor_class_init (EventEditorClass *class); static void event_editor_init (EventEditor *ee); -static void event_editor_set_cal_client (CompEditor *editor, CalClient *client); -static void event_editor_edit_comp (CompEditor *editor, CalComponent *comp); -static gboolean event_editor_send_comp (CompEditor *editor, CalComponentItipMethod method); +static void event_editor_set_e_cal (CompEditor *editor, ECal *client); +static void event_editor_edit_comp (CompEditor *editor, ECalComponent *comp); +static gboolean event_editor_send_comp (CompEditor *editor, ECalComponentItipMethod method); static void event_editor_finalize (GObject *object); static void schedule_meeting_cmd (GtkWidget *widget, gpointer data); @@ -111,7 +111,7 @@ event_editor_class_init (EventEditorClass *klass) parent_class = g_type_class_ref(TYPE_COMP_EDITOR); - editor_class->set_cal_client = event_editor_set_cal_client; + editor_class->set_e_cal = event_editor_set_e_cal; editor_class->edit_comp = event_editor_edit_comp; editor_class->send_comp = event_editor_send_comp; @@ -129,7 +129,7 @@ set_menu_sens (EventEditor *ee) existing = comp_editor_get_existing_org (COMP_EDITOR (ee)); user = comp_editor_get_user_org (COMP_EDITOR (ee)); - cal_client_is_read_only (comp_editor_get_cal_client (COMP_EDITOR (ee)), &read_only, NULL); + e_cal_is_read_only (comp_editor_get_e_cal (COMP_EDITOR (ee)), &read_only, NULL); sens = priv->meeting_shown; comp_editor_set_ui_prop (COMP_EDITOR (ee), @@ -187,7 +187,7 @@ event_editor_init (EventEditor *ee) } EventEditor * -event_editor_construct (EventEditor *ee, CalClient *client) +event_editor_construct (EventEditor *ee, ECal *client) { EventEditorPrivate *priv; @@ -228,7 +228,7 @@ event_editor_construct (EventEditor *ee, CalClient *client) COMP_EDITOR_PAGE (priv->meet_page), _("Meeting")); - comp_editor_set_cal_client (COMP_EDITOR (ee), client); + comp_editor_set_e_cal (COMP_EDITOR (ee), client); comp_editor_merge_ui (COMP_EDITOR (ee), "evolution-event-editor.xml", verbs, pixmaps); @@ -240,7 +240,7 @@ event_editor_construct (EventEditor *ee, CalClient *client) } static void -event_editor_set_cal_client (CompEditor *editor, CalClient *client) +event_editor_set_e_cal (CompEditor *editor, ECal *client) { EventEditor *ee; EventEditorPrivate *priv; @@ -248,19 +248,19 @@ event_editor_set_cal_client (CompEditor *editor, CalClient *client) ee = EVENT_EDITOR (editor); priv = ee->priv; - e_meeting_store_set_cal_client (priv->model, client); + e_meeting_store_set_e_cal (priv->model, client); - if (parent_class->set_cal_client) - parent_class->set_cal_client (editor, client); + if (parent_class->set_e_cal) + parent_class->set_e_cal (editor, client); } static void -event_editor_edit_comp (CompEditor *editor, CalComponent *comp) +event_editor_edit_comp (CompEditor *editor, ECalComponent *comp) { EventEditor *ee; EventEditorPrivate *priv; - CalComponentOrganizer organizer; - CalClient *client; + ECalComponentOrganizer organizer; + ECal *client; GSList *attendees = NULL; ee = EVENT_EDITOR (editor); @@ -271,11 +271,11 @@ event_editor_edit_comp (CompEditor *editor, CalComponent *comp) if (parent_class->edit_comp) parent_class->edit_comp (editor, comp); - client = comp_editor_get_cal_client (COMP_EDITOR (editor)); + client = comp_editor_get_e_cal (COMP_EDITOR (editor)); /* Get meeting related stuff */ - cal_component_get_organizer (comp, &organizer); - cal_component_get_attendee_list (comp, &attendees); + e_cal_component_get_organizer (comp, &organizer); + e_cal_component_get_attendee_list (comp, &attendees); /* Clear things up */ e_meeting_store_remove_all_attendees (priv->model); @@ -299,10 +299,10 @@ event_editor_edit_comp (CompEditor *editor, CalComponent *comp) } for (l = attendees; l != NULL; l = l->next) { - CalComponentAttendee *ca = l->data; + ECalComponentAttendee *ca = l->data; EMeetingAttendee *ia; - ia = E_MEETING_ATTENDEE (e_meeting_attendee_new_from_cal_component_attendee (ca)); + ia = E_MEETING_ATTENDEE (e_meeting_attendee_new_from_e_cal_component_attendee (ca)); /* If we aren't the organizer or the attendee is just delegating, don't allow editing */ if (!comp_editor_get_user_org (editor) || e_meeting_attendee_is_set_delto (ia)) @@ -329,7 +329,7 @@ event_editor_edit_comp (CompEditor *editor, CalComponent *comp) e_meeting_attendee_set_edit_level (ia, E_MEETING_ATTENDEE_EDIT_STATUS); } g_object_unref(it); - } else if (cal_client_get_organizer_must_attend (client)) { + } else if (e_cal_get_organizer_must_attend (client)) { EMeetingAttendee *ia; ia = e_meeting_store_find_attendee (priv->model, organizer.value, &row); @@ -339,7 +339,7 @@ event_editor_edit_comp (CompEditor *editor, CalComponent *comp) priv->meeting_shown = TRUE; } - cal_component_free_attendee_list (attendees); + e_cal_component_free_attendee_list (attendees); set_menu_sens (ee); comp_editor_set_needs_send (COMP_EDITOR (ee), priv->meeting_shown && itip_organizer_is_user (comp, client)); @@ -348,26 +348,26 @@ event_editor_edit_comp (CompEditor *editor, CalComponent *comp) } static gboolean -event_editor_send_comp (CompEditor *editor, CalComponentItipMethod method) +event_editor_send_comp (CompEditor *editor, ECalComponentItipMethod method) { EventEditor *ee = EVENT_EDITOR (editor); EventEditorPrivate *priv; - CalComponent *comp = NULL; + ECalComponent *comp = NULL; priv = ee->priv; /* Don't cancel more than once or when just publishing */ - if (method == CAL_COMPONENT_METHOD_PUBLISH || - method == CAL_COMPONENT_METHOD_CANCEL) + if (method == E_CAL_COMPONENT_METHOD_PUBLISH || + method == E_CAL_COMPONENT_METHOD_CANCEL) goto parent; comp = meeting_page_get_cancel_comp (priv->meet_page); if (comp != NULL) { - CalClient *client; + ECal *client; gboolean result; - client = e_meeting_store_get_cal_client (priv->model); - result = itip_send_comp (CAL_COMPONENT_METHOD_CANCEL, comp, client, NULL); + client = e_meeting_store_get_e_cal (priv->model); + result = itip_send_comp (E_CAL_COMPONENT_METHOD_CANCEL, comp, client, NULL); g_object_unref((comp)); if (!result) @@ -410,7 +410,7 @@ event_editor_finalize (GObject *object) /** * event_editor_new: - * @client: a CalClient + * @client: a ECal * * Creates a new event editor dialog. * @@ -418,7 +418,7 @@ event_editor_finalize (GObject *object) * editor could not be created. **/ EventEditor * -event_editor_new (CalClient *client) +event_editor_new (ECal *client) { EventEditor *ee; @@ -474,19 +474,19 @@ refresh_meeting_cmd (GtkWidget *widget, gpointer data) { EventEditor *ee = EVENT_EDITOR (data); - comp_editor_send_comp (COMP_EDITOR (ee), CAL_COMPONENT_METHOD_REFRESH); + comp_editor_send_comp (COMP_EDITOR (ee), E_CAL_COMPONENT_METHOD_REFRESH); } static void cancel_meeting_cmd (GtkWidget *widget, gpointer data) { EventEditor *ee = EVENT_EDITOR (data); - CalComponent *comp; + ECalComponent *comp; comp = comp_editor_get_current_comp (COMP_EDITOR (ee)); if (cancel_component_dialog ((GtkWindow *) ee, - comp_editor_get_cal_client (COMP_EDITOR (ee)), comp, FALSE)) { - comp_editor_send_comp (COMP_EDITOR (ee), CAL_COMPONENT_METHOD_CANCEL); + comp_editor_get_e_cal (COMP_EDITOR (ee)), comp, FALSE)) { + comp_editor_send_comp (COMP_EDITOR (ee), E_CAL_COMPONENT_METHOD_CANCEL); comp_editor_delete_comp (COMP_EDITOR (ee)); } } @@ -497,7 +497,7 @@ forward_cmd (GtkWidget *widget, gpointer data) EventEditor *ee = EVENT_EDITOR (data); if (comp_editor_save_comp (COMP_EDITOR (ee), TRUE)) - comp_editor_send_comp (COMP_EDITOR (ee), CAL_COMPONENT_METHOD_PUBLISH); + comp_editor_send_comp (COMP_EDITOR (ee), E_CAL_COMPONENT_METHOD_PUBLISH); } static void diff --git a/calendar/gui/dialogs/event-editor.h b/calendar/gui/dialogs/event-editor.h index e0ce5043d8..9234b8310e 100644 --- a/calendar/gui/dialogs/event-editor.h +++ b/calendar/gui/dialogs/event-editor.h @@ -52,8 +52,8 @@ struct _EventEditorClass { GtkType event_editor_get_type (void); EventEditor *event_editor_construct (EventEditor *ee, - CalClient *client); -EventEditor *event_editor_new (CalClient *client); + ECal *client); +EventEditor *event_editor_new (ECal *client); void event_editor_show_meeting (EventEditor *ee); diff --git a/calendar/gui/dialogs/event-page.c b/calendar/gui/dialogs/event-page.c index 8813081f4d..c883174c1f 100644 --- a/calendar/gui/dialogs/event-page.c +++ b/calendar/gui/dialogs/event-page.c @@ -36,7 +36,7 @@ #include "e-util/e-categories-config.h" #include "e-util/e-dialog-widgets.h" #include "widgets/misc/e-dateedit.h" -#include "cal-util/timeutil.h" +#include <libecal/e-cal-time-util.h> #include "../calendar-config.h" #include "../e-timezone-entry.h" #include "comp-editor-util.h" @@ -91,8 +91,8 @@ static void event_page_finalize (GObject *object); static GtkWidget *event_page_get_widget (CompEditorPage *page); static void event_page_focus_main_widget (CompEditorPage *page); -static void event_page_fill_widgets (CompEditorPage *page, CalComponent *comp); -static gboolean event_page_fill_component (CompEditorPage *page, CalComponent *comp); +static void event_page_fill_widgets (CompEditorPage *page, ECalComponent *comp); +static gboolean event_page_fill_component (CompEditorPage *page, ECalComponent *comp); static void event_page_set_summary (CompEditorPage *page, const char *summary); static void event_page_set_dates (CompEditorPage *page, CompEditorPageDates *dates); @@ -198,15 +198,15 @@ event_page_finalize (GObject *object) static const int classification_map[] = { - CAL_COMPONENT_CLASS_PUBLIC, - CAL_COMPONENT_CLASS_PRIVATE, - CAL_COMPONENT_CLASS_CONFIDENTIAL, + E_CAL_COMPONENT_CLASS_PUBLIC, + E_CAL_COMPONENT_CLASS_PRIVATE, + E_CAL_COMPONENT_CLASS_CONFIDENTIAL, -1 }; static const int transparency_map[] = { - CAL_COMPONENT_TRANSP_TRANSPARENT, - CAL_COMPONENT_TRANSP_OPAQUE, + E_CAL_COMPONENT_TRANSP_TRANSPARENT, + E_CAL_COMPONENT_TRANSP_OPAQUE, -1 }; @@ -265,7 +265,7 @@ set_all_day (EventPage *epage, gboolean all_day) } static void -update_time (EventPage *epage, CalComponentDateTime *start_date, CalComponentDateTime *end_date) +update_time (EventPage *epage, ECalComponentDateTime *start_date, ECalComponentDateTime *end_date) { EventPagePrivate *priv; struct icaltimetype *start_tt, *end_tt, implied_tt; @@ -280,7 +280,7 @@ update_time (EventPage *epage, CalComponentDateTime *start_date, CalComponentDat start_zone = icaltimezone_get_builtin_timezone_from_tzid (start_date->tzid); if (!start_zone) { /* FIXME: Handle error better. */ - if (!cal_client_get_timezone (COMP_EDITOR_PAGE (epage)->client, + if (!e_cal_get_timezone (COMP_EDITOR_PAGE (epage)->client, start_date->tzid, &start_zone, NULL)) { g_warning ("Couldn't get timezone from server: %s", start_date->tzid ? start_date->tzid : ""); @@ -289,7 +289,7 @@ update_time (EventPage *epage, CalComponentDateTime *start_date, CalComponentDat end_zone = icaltimezone_get_builtin_timezone_from_tzid (end_date->tzid); if (!end_zone) { - if (!cal_client_get_timezone (COMP_EDITOR_PAGE (epage)->client, + if (!e_cal_get_timezone (COMP_EDITOR_PAGE (epage)->client, end_date->tzid, &end_zone, NULL)) { /* FIXME: Handle error better. */ g_warning ("Couldn't get timezone from server: %s", @@ -395,11 +395,11 @@ clear_widgets (EventPage *epage) /* Classification */ e_dialog_radio_set (priv->classification_public, - CAL_COMPONENT_CLASS_PRIVATE, classification_map); + E_CAL_COMPONENT_CLASS_PRIVATE, classification_map); /* Show Time As (Transparency) */ e_dialog_radio_set (priv->show_time_as_free, - CAL_COMPONENT_TRANSP_OPAQUE, transparency_map); + E_CAL_COMPONENT_TRANSP_OPAQUE, transparency_map); /* Categories */ e_dialog_editable_set (priv->categories, NULL); @@ -408,14 +408,14 @@ clear_widgets (EventPage *epage) /* fill_widgets handler for the event page */ static void -event_page_fill_widgets (CompEditorPage *page, CalComponent *comp) +event_page_fill_widgets (CompEditorPage *page, ECalComponent *comp) { EventPage *epage; EventPagePrivate *priv; - CalComponentText text; - CalComponentClassification cl; - CalComponentTransparency transparency; - CalComponentDateTime start_date, end_date; + ECalComponentText text; + ECalComponentClassification cl; + ECalComponentTransparency transparency; + ECalComponentDateTime start_date, end_date; const char *location; const char *categories; GSList *l; @@ -433,84 +433,84 @@ event_page_fill_widgets (CompEditorPage *page, CalComponent *comp) /* Summary, location, description(s) */ - cal_component_get_summary (comp, &text); + e_cal_component_get_summary (comp, &text); e_dialog_editable_set (priv->summary, text.value); - cal_component_get_location (comp, &location); + e_cal_component_get_location (comp, &location); e_dialog_editable_set (priv->location, location); - cal_component_get_description_list (comp, &l); + e_cal_component_get_description_list (comp, &l); if (l) { - text = *(CalComponentText *)l->data; + text = *(ECalComponentText *)l->data; gtk_text_buffer_set_text (gtk_text_view_get_buffer (GTK_TEXT_VIEW (priv->description)), text.value, -1); } - cal_component_free_text_list (l); + e_cal_component_free_text_list (l); /* Start and end times */ - cal_component_get_dtstart (comp, &start_date); - cal_component_get_dtend (comp, &end_date); + e_cal_component_get_dtstart (comp, &start_date); + e_cal_component_get_dtend (comp, &end_date); update_time (epage, &start_date, &end_date); - cal_component_free_datetime (&start_date); - cal_component_free_datetime (&end_date); + e_cal_component_free_datetime (&start_date); + e_cal_component_free_datetime (&end_date); /* Classification */ - cal_component_get_classification (comp, &cl); + e_cal_component_get_classification (comp, &cl); switch (cl) { - case CAL_COMPONENT_CLASS_PUBLIC: + case E_CAL_COMPONENT_CLASS_PUBLIC: e_dialog_radio_set (priv->classification_public, - CAL_COMPONENT_CLASS_PUBLIC, + E_CAL_COMPONENT_CLASS_PUBLIC, classification_map); break; - case CAL_COMPONENT_CLASS_PRIVATE: + case E_CAL_COMPONENT_CLASS_PRIVATE: e_dialog_radio_set (priv->classification_public, - CAL_COMPONENT_CLASS_PRIVATE, + E_CAL_COMPONENT_CLASS_PRIVATE, classification_map); break; - case CAL_COMPONENT_CLASS_CONFIDENTIAL: + case E_CAL_COMPONENT_CLASS_CONFIDENTIAL: e_dialog_radio_set (priv->classification_public, - CAL_COMPONENT_CLASS_CONFIDENTIAL, + E_CAL_COMPONENT_CLASS_CONFIDENTIAL, classification_map); break; default: /* default to PUBLIC */ e_dialog_radio_set (priv->classification_public, - CAL_COMPONENT_CLASS_PUBLIC, + E_CAL_COMPONENT_CLASS_PUBLIC, classification_map); break; } /* Show Time As (Transparency) */ - cal_component_get_transparency (comp, &transparency); + e_cal_component_get_transparency (comp, &transparency); switch (transparency) { - case CAL_COMPONENT_TRANSP_TRANSPARENT: + case E_CAL_COMPONENT_TRANSP_TRANSPARENT: e_dialog_radio_set (priv->show_time_as_free, - CAL_COMPONENT_TRANSP_TRANSPARENT, + E_CAL_COMPONENT_TRANSP_TRANSPARENT, transparency_map); break; default: e_dialog_radio_set (priv->show_time_as_free, - CAL_COMPONENT_TRANSP_OPAQUE, + E_CAL_COMPONENT_TRANSP_OPAQUE, transparency_map); break; } - if (cal_client_get_static_capability (page->client, CAL_STATIC_CAPABILITY_NO_TRANSPARENCY)) + if (e_cal_get_static_capability (page->client, CAL_STATIC_CAPABILITY_NO_TRANSPARENCY)) gtk_widget_hide (priv->show_time_frame); else gtk_widget_show (priv->show_time_frame); /* Categories */ - cal_component_get_categories (comp, &categories); + e_cal_component_get_categories (comp, &categories); e_dialog_editable_set (priv->categories, categories); priv->updating = FALSE; @@ -518,16 +518,16 @@ event_page_fill_widgets (CompEditorPage *page, CalComponent *comp) /* fill_component handler for the event page */ static gboolean -event_page_fill_component (CompEditorPage *page, CalComponent *comp) +event_page_fill_component (CompEditorPage *page, ECalComponent *comp) { EventPage *epage; EventPagePrivate *priv; - CalComponentDateTime start_date, end_date; + ECalComponentDateTime start_date, end_date; struct icaltimetype start_tt, end_tt; gboolean all_day_event, start_date_set, end_date_set; char *cat, *str; - CalComponentClassification classif; - CalComponentTransparency transparency; + ECalComponentClassification classif; + ECalComponentTransparency transparency; GtkTextBuffer *text_buffer; GtkTextIter text_iter_start, text_iter_end; @@ -539,14 +539,14 @@ event_page_fill_component (CompEditorPage *page, CalComponent *comp) str = e_dialog_editable_get (priv->summary); if (!str || strlen (str) == 0) - cal_component_set_summary (comp, NULL); + e_cal_component_set_summary (comp, NULL); else { - CalComponentText text; + ECalComponentText text; text.value = str; text.altrep = NULL; - cal_component_set_summary (comp, &text); + e_cal_component_set_summary (comp, &text); } if (str) @@ -556,9 +556,9 @@ event_page_fill_component (CompEditorPage *page, CalComponent *comp) str = e_dialog_editable_get (priv->location); if (!str || strlen (str) == 0) - cal_component_set_location (comp, NULL); + e_cal_component_set_location (comp, NULL); else - cal_component_set_location (comp, str); + e_cal_component_set_location (comp, str); if (str) g_free (str); @@ -570,17 +570,17 @@ event_page_fill_component (CompEditorPage *page, CalComponent *comp) str = gtk_text_buffer_get_text (text_buffer, &text_iter_start, &text_iter_end, FALSE); if (!str || strlen (str) == 0) - cal_component_set_description_list (comp, NULL); + e_cal_component_set_description_list (comp, NULL); else { GSList l; - CalComponentText text; + ECalComponentText text; text.value = str; text.altrep = NULL; l.data = &text; l.next = NULL; - cal_component_set_description_list (comp, &l); + e_cal_component_set_description_list (comp, &l); } if (str) @@ -649,8 +649,8 @@ event_page_fill_component (CompEditorPage *page, CalComponent *comp) end_date.tzid = icaltimezone_get_tzid (end_zone); } - cal_component_set_dtstart (comp, &start_date); - cal_component_set_dtend (comp, &end_date); + e_cal_component_set_dtstart (comp, &start_date); + e_cal_component_set_dtend (comp, &end_date); /* Categories */ @@ -660,7 +660,7 @@ event_page_fill_component (CompEditorPage *page, CalComponent *comp) if (cat) g_free (cat); - cal_component_set_categories (comp, str); + e_cal_component_set_categories (comp, str); if (str) g_free (str); @@ -669,13 +669,13 @@ event_page_fill_component (CompEditorPage *page, CalComponent *comp) classif = e_dialog_radio_get (priv->classification_public, classification_map); - cal_component_set_classification (comp, classif); + e_cal_component_set_classification (comp, classif); /* Show Time As (Transparency) */ transparency = e_dialog_radio_get (priv->show_time_as_free, transparency_map); - cal_component_set_transparency (comp, transparency); + e_cal_component_set_transparency (comp, transparency); return TRUE; } @@ -800,7 +800,7 @@ notify_dates_changed (EventPage *epage, struct icaltimetype *start_tt, { EventPagePrivate *priv; CompEditorPageDates dates; - CalComponentDateTime start_dt, end_dt; + ECalComponentDateTime start_dt, end_dt; gboolean all_day_event; icaltimezone *start_zone = NULL, *end_zone = NULL; diff --git a/calendar/gui/dialogs/meeting-page.c b/calendar/gui/dialogs/meeting-page.c index 546baa8dc3..311ff6c879 100644 --- a/calendar/gui/dialogs/meeting-page.c +++ b/calendar/gui/dialogs/meeting-page.c @@ -59,7 +59,7 @@ struct _MeetingPagePrivate { GPtrArray *deleted_attendees; /* To use in case of cancellation */ - CalComponent *comp; + ECalComponent *comp; /* List of identities */ EAccountList *accounts; @@ -97,8 +97,8 @@ static void meeting_page_finalize (GObject *object); static GtkWidget *meeting_page_get_widget (CompEditorPage *page); static void meeting_page_focus_main_widget (CompEditorPage *page); -static void meeting_page_fill_widgets (CompEditorPage *page, CalComponent *comp); -static gboolean meeting_page_fill_component (CompEditorPage *page, CalComponent *comp); +static void meeting_page_fill_widgets (CompEditorPage *page, ECalComponent *comp); +static gboolean meeting_page_fill_component (CompEditorPage *page, ECalComponent *comp); static CompEditorPageClass *parent_class = NULL; @@ -197,22 +197,22 @@ get_current_account (MeetingPage *mpage) } static void -set_attendees (CalComponent *comp, const GPtrArray *attendees) +set_attendees (ECalComponent *comp, const GPtrArray *attendees) { GSList *comp_attendees = NULL, *l; int i; for (i = 0; i < attendees->len; i++) { EMeetingAttendee *ia = g_ptr_array_index (attendees, i); - CalComponentAttendee *ca; + ECalComponentAttendee *ca; - ca = e_meeting_attendee_as_cal_component_attendee (ia); + ca = e_meeting_attendee_as_e_cal_component_attendee (ia); comp_attendees = g_slist_prepend (comp_attendees, ca); } comp_attendees = g_slist_reverse (comp_attendees); - cal_component_set_attendee_list (comp, comp_attendees); + e_cal_component_set_attendee_list (comp, comp_attendees); for (l = comp_attendees; l != NULL; l = l->next) g_free (l->data); @@ -319,11 +319,11 @@ clear_widgets (MeetingPage *mpage) /* fill_widgets handler for the meeting page */ static void -meeting_page_fill_widgets (CompEditorPage *page, CalComponent *comp) +meeting_page_fill_widgets (CompEditorPage *page, ECalComponent *comp) { MeetingPage *mpage; MeetingPagePrivate *priv; - CalComponentOrganizer organizer; + ECalComponentOrganizer organizer; mpage = MEETING_PAGE (page); priv = mpage->priv; @@ -342,11 +342,11 @@ meeting_page_fill_widgets (CompEditorPage *page, CalComponent *comp) clear_widgets (mpage); /* Component for cancellation */ - priv->comp = cal_component_clone (comp); + priv->comp = e_cal_component_clone (comp); /* If there is an existing organizer show it properly */ - if (cal_component_has_organizer (comp)) { - cal_component_get_organizer (comp, &organizer); + if (e_cal_component_has_organizer (comp)) { + e_cal_component_get_organizer (comp, &organizer); if (organizer.value != NULL) { const gchar *strip = itip_strip_mailto (organizer.value); gchar *string; @@ -355,12 +355,12 @@ meeting_page_fill_widgets (CompEditorPage *page, CalComponent *comp) gtk_widget_show (priv->existing_organizer_table); if (itip_organizer_is_user (comp, page->client)) { gtk_widget_show (priv->invite); - if (cal_client_get_static_capability ( + if (e_cal_get_static_capability ( page->client, CAL_STATIC_CAPABILITY_ORGANIZER_NOT_EMAIL_ADDRESS)) gtk_widget_hide (priv->existing_organizer_btn); } else { - if (cal_client_get_static_capability ( + if (e_cal_get_static_capability ( page->client, CAL_STATIC_CAPABILITY_ORGANIZER_NOT_EMAIL_ADDRESS)) gtk_widget_hide (priv->existing_organizer_btn); @@ -395,11 +395,11 @@ meeting_page_fill_widgets (CompEditorPage *page, CalComponent *comp) /* fill_component handler for the meeting page */ static gboolean -meeting_page_fill_component (CompEditorPage *page, CalComponent *comp) +meeting_page_fill_component (CompEditorPage *page, ECalComponent *comp) { MeetingPage *mpage; MeetingPagePrivate *priv; - CalComponentOrganizer organizer = {NULL, NULL, NULL, NULL}; + ECalComponentOrganizer organizer = {NULL, NULL, NULL, NULL}; mpage = MEETING_PAGE (page); priv = mpage->priv; @@ -428,7 +428,7 @@ meeting_page_fill_component (CompEditorPage *page, CalComponent *comp) organizer.value = addr; organizer.cn = a->id->name; - cal_component_set_organizer (comp, &organizer); + e_cal_component_set_organizer (comp, &organizer); g_free (addr); } @@ -691,7 +691,7 @@ add_btn_clicked_cb (GtkButton *btn, MeetingPage *mpage) **/ MeetingPage * meeting_page_construct (MeetingPage *mpage, EMeetingStore *ems, - CalClient *client) + ECal *client) { MeetingPagePrivate *priv; ETable *real_table; @@ -719,7 +719,7 @@ meeting_page_construct (MeetingPage *mpage, EMeetingStore *ems, } /* Address information */ - if (!cal_client_get_cal_address (client, &backend_address, NULL)) + if (!e_cal_get_cal_address (client, &backend_address, NULL)) return NULL; priv->accounts = itip_addresses_get (); @@ -797,7 +797,7 @@ meeting_page_construct (MeetingPage *mpage, EMeetingStore *ems, * not be created. **/ MeetingPage * -meeting_page_new (EMeetingStore *ems, CalClient *client) +meeting_page_new (EMeetingStore *ems, ECal *client) { MeetingPage *mpage; @@ -818,7 +818,7 @@ meeting_page_new (EMeetingStore *ems, CalClient *client) * * Return value: **/ -CalComponent * +ECalComponent * meeting_page_get_cancel_comp (MeetingPage *mpage) { MeetingPagePrivate *priv; @@ -833,5 +833,5 @@ meeting_page_get_cancel_comp (MeetingPage *mpage) set_attendees (priv->comp, priv->deleted_attendees); - return cal_component_clone (priv->comp); + return e_cal_component_clone (priv->comp); } diff --git a/calendar/gui/dialogs/meeting-page.h b/calendar/gui/dialogs/meeting-page.h index 5891189810..95533cd771 100644 --- a/calendar/gui/dialogs/meeting-page.h +++ b/calendar/gui/dialogs/meeting-page.h @@ -55,10 +55,10 @@ typedef struct { GtkType meeting_page_get_type (void); MeetingPage *meeting_page_construct (MeetingPage *mpage, EMeetingStore *ems, - CalClient *client); + ECal *client); MeetingPage *meeting_page_new (EMeetingStore *ems, - CalClient *client); -CalComponent *meeting_page_get_cancel_comp (MeetingPage *mpage); + ECal *client); +ECalComponent *meeting_page_get_cancel_comp (MeetingPage *mpage); diff --git a/calendar/gui/dialogs/recur-comp.c b/calendar/gui/dialogs/recur-comp.c index eafee32102..82648fe84d 100644 --- a/calendar/gui/dialogs/recur-comp.c +++ b/calendar/gui/dialogs/recur-comp.c @@ -32,30 +32,30 @@ gboolean -recur_component_dialog (CalClient *client, - CalComponent *comp, +recur_component_dialog (ECal *client, + ECalComponent *comp, CalObjModType *mod, GtkWindow *parent) { char *str; GtkWidget *dialog, *rb_this, *rb_prior, *rb_future, *rb_all, *hbox; - CalComponentVType vtype; + ECalComponentVType vtype; gboolean ret; - g_return_val_if_fail (IS_CAL_COMPONENT (comp), CALOBJ_MOD_THIS); + g_return_val_if_fail (E_IS_CAL_COMPONENT (comp), CALOBJ_MOD_THIS); - vtype = cal_component_get_vtype (comp); + vtype = e_cal_component_get_vtype (comp); switch (vtype) { - case CAL_COMPONENT_EVENT: + case E_CAL_COMPONENT_EVENT: str = g_strdup_printf (_("You are modifying a recurring event, what would you like to modify?")); break; - case CAL_COMPONENT_TODO: + case E_CAL_COMPONENT_TODO: str = g_strdup_printf (_("You are modifying a recurring task, what would you like to modify?")); break; - case CAL_COMPONENT_JOURNAL: + case E_CAL_COMPONENT_JOURNAL: str = g_strdup_printf (_("You are modifying a recurring journal entry, what would you like to modify?")); break; @@ -73,13 +73,13 @@ recur_component_dialog (CalClient *client, rb_this = gtk_radio_button_new_with_label (NULL, _("This Instance Only")); gtk_container_add (GTK_CONTAINER (hbox), rb_this); - if (!cal_client_get_static_capability (client, CAL_STATIC_CAPABILITY_NO_THISANDPRIOR)) { + if (!e_cal_get_static_capability (client, CAL_STATIC_CAPABILITY_NO_THISANDPRIOR)) { rb_prior = gtk_radio_button_new_with_label_from_widget (GTK_RADIO_BUTTON (rb_this), _("This and Prior Instances")); gtk_container_add (GTK_CONTAINER (hbox), rb_prior); } else rb_prior = NULL; - if (!cal_client_get_static_capability (client, CAL_STATIC_CAPABILITY_NO_THISANDFUTURE)) { + if (!e_cal_get_static_capability (client, CAL_STATIC_CAPABILITY_NO_THISANDFUTURE)) { rb_future = gtk_radio_button_new_with_label_from_widget (GTK_RADIO_BUTTON (rb_this), _("This and Future Instances")); gtk_container_add (GTK_CONTAINER (hbox), rb_future); } else diff --git a/calendar/gui/dialogs/recur-comp.h b/calendar/gui/dialogs/recur-comp.h index 76b1a63bef..94ccbdae87 100644 --- a/calendar/gui/dialogs/recur-comp.h +++ b/calendar/gui/dialogs/recur-comp.h @@ -22,12 +22,12 @@ #define RECUR_COMP_H #include <gtk/gtkwindow.h> -#include <cal-client/cal-client.h> -#include <cal-util/cal-component.h> -#include <cal-util/cal-util.h> +#include <libecal/e-cal.h> +#include <libecal/e-cal-component.h> +#include <libecal/e-cal-util.h> -gboolean recur_component_dialog (CalClient *client, - CalComponent *comp, +gboolean recur_component_dialog (ECal *client, + ECalComponent *comp, CalObjModType *mod, GtkWindow *parent); diff --git a/calendar/gui/dialogs/recurrence-page.c b/calendar/gui/dialogs/recurrence-page.c index ece6c115bb..c930e079a2 100644 --- a/calendar/gui/dialogs/recurrence-page.c +++ b/calendar/gui/dialogs/recurrence-page.c @@ -42,8 +42,8 @@ #include <e-util/e-dialog-widgets.h> #include <e-util/e-time-utils.h> #include <widgets/misc/e-dateedit.h> -#include <cal-util/cal-recur.h> -#include <cal-util/timeutil.h> +#include <libecal/e-cal-recur.h> +#include <libecal/e-cal-time-util.h> #include "../calendar-config.h" #include "../tag-calendar.h" #include "../weekday-picker.h" @@ -135,7 +135,7 @@ static const int ending_types_map[] = { /* Private part of the RecurrencePage structure */ struct _RecurrencePagePrivate { /* Component we use to expand the recurrence rules for the preview */ - CalComponent *comp; + ECalComponent *comp; /* Glade XML data */ GladeXML *xml; @@ -207,8 +207,8 @@ static void recurrence_page_finalize (GObject *object); static GtkWidget *recurrence_page_get_widget (CompEditorPage *page); static void recurrence_page_focus_main_widget (CompEditorPage *page); -static void recurrence_page_fill_widgets (CompEditorPage *page, CalComponent *comp); -static gboolean recurrence_page_fill_component (CompEditorPage *page, CalComponent *comp); +static void recurrence_page_fill_widgets (CompEditorPage *page, ECalComponent *comp); +static gboolean recurrence_page_fill_component (CompEditorPage *page, ECalComponent *comp); static void recurrence_page_set_summary (CompEditorPage *page, const char *summary); static void recurrence_page_set_dates (CompEditorPage *page, CompEditorPageDates *dates); @@ -422,7 +422,7 @@ clear_widgets (RecurrencePage *rpage) /* Appends an exception date to the list */ static void -append_exception (RecurrencePage *rpage, CalComponentDateTime *datetime) +append_exception (RecurrencePage *rpage, ECalComponentDateTime *datetime) { RecurrencePagePrivate *priv; GtkTreeView *view; @@ -437,17 +437,17 @@ append_exception (RecurrencePage *rpage, CalComponentDateTime *datetime) /* Fills in the exception widgets with the data from the calendar component */ static void -fill_exception_widgets (RecurrencePage *rpage, CalComponent *comp) +fill_exception_widgets (RecurrencePage *rpage, ECalComponent *comp) { RecurrencePagePrivate *priv; GSList *list, *l; gboolean added = FALSE; priv = rpage->priv; - cal_component_get_exdate_list (comp, &list); + e_cal_component_get_exdate_list (comp, &list); for (l = list; l; l = l->next) { - CalComponentDateTime *cdt; + ECalComponentDateTime *cdt; added = TRUE; @@ -455,19 +455,19 @@ fill_exception_widgets (RecurrencePage *rpage, CalComponent *comp) append_exception (rpage, cdt); } - cal_component_free_exdate_list (list); + e_cal_component_free_exdate_list (list); } /* Computes a weekday mask for the start day of a calendar component, * for use in a WeekdayPicker widget. */ static guint8 -get_start_weekday_mask (CalComponent *comp) +get_start_weekday_mask (ECalComponent *comp) { - CalComponentDateTime dt; + ECalComponentDateTime dt; guint8 retval; - cal_component_get_dtstart (comp, &dt); + e_cal_component_get_dtstart (comp, &dt); if (dt.value) { short weekday; @@ -477,7 +477,7 @@ get_start_weekday_mask (CalComponent *comp) } else retval = 0; - cal_component_free_datetime (&dt); + e_cal_component_free_datetime (&dt); return retval; } @@ -514,7 +514,7 @@ sensitize_recur_widgets (RecurrencePage *rpage) type = e_dialog_radio_get (priv->none, type_map); /* We can't preview that well for instances right now */ - if (cal_component_is_instance (priv->comp)) + if (e_cal_component_is_instance (priv->comp)) gtk_widget_set_sensitive (priv->preview_calendar, FALSE); else gtk_widget_set_sensitive (priv->preview_calendar, TRUE); @@ -569,7 +569,7 @@ nth_weekday (int pos, icalrecurrencetype_weekday weekday) * the calendar component. */ static void -simple_recur_to_comp (RecurrencePage *rpage, CalComponent *comp) +simple_recur_to_comp (RecurrencePage *rpage, ECalComponent *comp) { RecurrencePagePrivate *priv; struct icalrecurrencetype r; @@ -754,14 +754,14 @@ simple_recur_to_comp (RecurrencePage *rpage, CalComponent *comp) l.data = &r; l.next = NULL; - cal_component_set_rrule_list (comp, &l); + e_cal_component_set_rrule_list (comp, &l); } /* Fills a component with the data from the recurrence page; in the case of a * custom recurrence, it leaves it intact. */ static gboolean -fill_component (RecurrencePage *rpage, CalComponent *comp) +fill_component (RecurrencePage *rpage, ECalComponent *comp) { RecurrencePagePrivate *priv; enum recur_type recur_type; @@ -777,14 +777,14 @@ fill_component (RecurrencePage *rpage, CalComponent *comp) switch (recur_type) { case RECUR_NONE: - cal_component_set_rdate_list (comp, NULL); - cal_component_set_rrule_list (comp, NULL); - cal_component_set_exrule_list (comp, NULL); + e_cal_component_set_rdate_list (comp, NULL); + e_cal_component_set_rrule_list (comp, NULL); + e_cal_component_set_exrule_list (comp, NULL); break; case RECUR_SIMPLE: - cal_component_set_rdate_list (comp, NULL); - cal_component_set_exrule_list (comp, NULL); + e_cal_component_set_rdate_list (comp, NULL); + e_cal_component_set_exrule_list (comp, NULL); simple_recur_to_comp (rpage, comp); break; @@ -802,10 +802,10 @@ fill_component (RecurrencePage *rpage, CalComponent *comp) for (valid_iter = gtk_tree_model_get_iter_first (model, &iter); valid_iter; valid_iter = gtk_tree_model_iter_next (model, &iter)) { - const CalComponentDateTime *dt; - CalComponentDateTime *cdt; + const ECalComponentDateTime *dt; + ECalComponentDateTime *cdt; - cdt = g_new (CalComponentDateTime, 1); + cdt = g_new (ECalComponentDateTime, 1); cdt->value = g_new (struct icaltimetype, 1); dt = e_date_time_list_get_date_time (E_DATE_TIME_LIST (model), &iter); @@ -824,8 +824,8 @@ fill_component (RecurrencePage *rpage, CalComponent *comp) list = g_slist_prepend (list, cdt); } - cal_component_set_exdate_list (comp, list); - cal_component_free_exdate_list (list); + e_cal_component_set_exdate_list (comp, list); + e_cal_component_free_exdate_list (list); return TRUE; } @@ -837,8 +837,8 @@ static void preview_recur (RecurrencePage *rpage) { RecurrencePagePrivate *priv; - CalComponent *comp; - CalComponentDateTime cdt; + ECalComponent *comp; + ECalComponentDateTime cdt; GSList *l; icaltimezone *zone = NULL; @@ -847,44 +847,44 @@ preview_recur (RecurrencePage *rpage) /* If our component has not been set yet through ::fill_widgets(), we * cannot preview the recurrence. */ - if (!priv->comp || cal_component_is_instance (priv->comp)) + if (!priv->comp || e_cal_component_is_instance (priv->comp)) return; /* Create a scratch component with the start/end and * recurrence/exception information from the one we are editing. */ - comp = cal_component_new (); - cal_component_set_new_vtype (comp, CAL_COMPONENT_EVENT); + comp = e_cal_component_new (); + e_cal_component_set_new_vtype (comp, E_CAL_COMPONENT_EVENT); - cal_component_get_dtstart (priv->comp, &cdt); + e_cal_component_get_dtstart (priv->comp, &cdt); if (cdt.tzid != NULL) { - /* FIXME Will cal_client_get_timezone really not return builtin zones? */ - if (!cal_client_get_timezone (COMP_EDITOR_PAGE (rpage)->client, cdt.tzid, &zone, NULL)) + /* FIXME Will e_cal_get_timezone really not return builtin zones? */ + if (!e_cal_get_timezone (COMP_EDITOR_PAGE (rpage)->client, cdt.tzid, &zone, NULL)) zone = icaltimezone_get_builtin_timezone_from_tzid (cdt.tzid); } - cal_component_set_dtstart (comp, &cdt); - cal_component_free_datetime (&cdt); + e_cal_component_set_dtstart (comp, &cdt); + e_cal_component_free_datetime (&cdt); - cal_component_get_dtend (priv->comp, &cdt); - cal_component_set_dtend (comp, &cdt); - cal_component_free_datetime (&cdt); + e_cal_component_get_dtend (priv->comp, &cdt); + e_cal_component_set_dtend (comp, &cdt); + e_cal_component_free_datetime (&cdt); - cal_component_get_exdate_list (priv->comp, &l); - cal_component_set_exdate_list (comp, l); - cal_component_free_exdate_list (l); + e_cal_component_get_exdate_list (priv->comp, &l); + e_cal_component_set_exdate_list (comp, l); + e_cal_component_free_exdate_list (l); - cal_component_get_exrule_list (priv->comp, &l); - cal_component_set_exrule_list (comp, l); - cal_component_free_recur_list (l); + e_cal_component_get_exrule_list (priv->comp, &l); + e_cal_component_set_exrule_list (comp, l); + e_cal_component_free_recur_list (l); - cal_component_get_rdate_list (priv->comp, &l); - cal_component_set_rdate_list (comp, l); - cal_component_free_period_list (l); + e_cal_component_get_rdate_list (priv->comp, &l); + e_cal_component_set_rdate_list (comp, l); + e_cal_component_free_period_list (l); - cal_component_get_rrule_list (priv->comp, &l); - cal_component_set_rrule_list (comp, l); - cal_component_free_recur_list (l); + e_cal_component_get_rrule_list (priv->comp, &l); + e_cal_component_set_rrule_list (comp, l); + e_cal_component_free_recur_list (l); fill_component (rpage, comp); @@ -968,7 +968,7 @@ make_recur_month_num_submenu (const char *title, int start, int end) submenu = gtk_menu_new (); for (i = start; i < end; i++) { - item = gtk_menu_item_new_with_label (_(cal_recur_nth[i])); + item = gtk_menu_item_new_with_label (_(e_cal_recur_nth[i])); gtk_menu_shell_append(GTK_MENU_SHELL(submenu), item); gtk_object_set_user_data (GTK_OBJECT (item), GINT_TO_POINTER (i + 1)); gtk_widget_show (item); @@ -1006,7 +1006,7 @@ make_recur_month_num_menu (int month_index) } /* Current date */ - item = gtk_menu_item_new_with_label (_(cal_recur_nth[month_index - 1])); + item = gtk_menu_item_new_with_label (_(e_cal_recur_nth[month_index - 1])); gtk_menu_shell_append(GTK_MENU_SHELL(menu), item); gtk_widget_show (item); @@ -1096,7 +1096,7 @@ month_num_menu_selection_done_cb (GtkMenuShell *menu_shell, gpointer data) e_dialog_option_menu_set (priv->month_num_menu, month_num, month_num_options_map); label = GTK_BIN (priv->month_num_menu)->child; - gtk_label_set_text (GTK_LABEL (label), _(cal_recur_nth[priv->month_index - 1])); + gtk_label_set_text (GTK_LABEL (label), _(e_cal_recur_nth[priv->month_index - 1])); e_dialog_option_menu_set (priv->month_num_menu, 0, month_num_options_map); e_dialog_option_menu_set (priv->month_num_menu, month_num, month_num_options_map); @@ -1445,11 +1445,11 @@ fill_ending_date (RecurrencePage *rpage, struct icalrecurrencetype *r) /* Ending date */ if (!r->until.is_date) { - CalClient *client = COMP_EDITOR_PAGE (rpage)->client; - CalComponentDateTime dt; + ECal *client = COMP_EDITOR_PAGE (rpage)->client; + ECalComponentDateTime dt; icaltimezone *from_zone, *to_zone; - cal_component_get_dtstart (priv->comp, &dt); + e_cal_component_get_dtstart (priv->comp, &dt); if (dt.value->is_date) to_zone = icaltimezone_get_builtin_timezone (calendar_config_get_timezone ()); @@ -1457,7 +1457,7 @@ fill_ending_date (RecurrencePage *rpage, struct icalrecurrencetype *r) to_zone = icaltimezone_get_utc_timezone (); else /* FIXME Error checking? */ - cal_client_get_timezone (client, dt.tzid, &to_zone, NULL); + e_cal_get_timezone (client, dt.tzid, &to_zone, NULL); from_zone = icaltimezone_get_utc_timezone (); icaltimezone_convert_time (&r->until, from_zone, to_zone); @@ -1494,11 +1494,11 @@ fill_ending_date (RecurrencePage *rpage, struct icalrecurrencetype *r) * no rdates or exrules (exdates are handled just fine elsewhere). */ static void -recurrence_page_fill_widgets (CompEditorPage *page, CalComponent *comp) +recurrence_page_fill_widgets (CompEditorPage *page, ECalComponent *comp) { RecurrencePage *rpage; RecurrencePagePrivate *priv; - CalComponentText text; + ECalComponentText text; CompEditorPageDates dates; GSList *rrule_list; int len; @@ -1519,7 +1519,7 @@ recurrence_page_fill_widgets (CompEditorPage *page, CalComponent *comp) if (priv->comp) g_object_unref((priv->comp)); - priv->comp = cal_component_clone (comp); + priv->comp = e_cal_component_clone (comp); /* Don't send off changes during this time */ priv->updating = TRUE; @@ -1528,7 +1528,7 @@ recurrence_page_fill_widgets (CompEditorPage *page, CalComponent *comp) clear_widgets (rpage); /* Summary */ - cal_component_get_summary (comp, &text); + e_cal_component_get_summary (comp, &text); recurrence_page_set_summary (page, text.value); /* Dates */ @@ -1544,9 +1544,9 @@ recurrence_page_fill_widgets (CompEditorPage *page, CalComponent *comp) /* No recurrences? */ - if (!cal_component_has_rdates (comp) - && !cal_component_has_rrules (comp) - && !cal_component_has_exrules (comp)) { + if (!e_cal_component_has_rdates (comp) + && !e_cal_component_has_rrules (comp) + && !e_cal_component_has_exrules (comp)) { gtk_signal_handler_block_by_data (GTK_OBJECT (priv->none), rpage); gtk_signal_handler_block_by_data (GTK_OBJECT (priv->simple), @@ -1572,11 +1572,11 @@ recurrence_page_fill_widgets (CompEditorPage *page, CalComponent *comp) /* See if it is a custom set we don't support */ - cal_component_get_rrule_list (comp, &rrule_list); + e_cal_component_get_rrule_list (comp, &rrule_list); len = g_slist_length (rrule_list); if (len > 1 - || cal_component_has_rdates (comp) - || cal_component_has_exrules (comp)) + || e_cal_component_has_rdates (comp) + || e_cal_component_has_exrules (comp)) goto custom; /* Down to one rule, so test that one */ @@ -1718,9 +1718,9 @@ recurrence_page_fill_widgets (CompEditorPage *page, CalComponent *comp) goto custom; if (nth == -1) { - CalComponentDateTime dt; + ECalComponentDateTime dt; - cal_component_get_dtstart (comp, &dt); + e_cal_component_get_dtstart (comp, &dt); priv->month_index = dt.value->day; priv->month_num = MONTH_NUM_LAST; } else { @@ -1858,7 +1858,7 @@ recurrence_page_fill_widgets (CompEditorPage *page, CalComponent *comp) out: - cal_component_free_recur_list (rrule_list); + e_cal_component_free_recur_list (rrule_list); preview_recur (rpage); priv->updating = FALSE; @@ -1866,7 +1866,7 @@ recurrence_page_fill_widgets (CompEditorPage *page, CalComponent *comp) /* fill_component handler for the recurrence page */ static gboolean -recurrence_page_fill_component (CompEditorPage *page, CalComponent *comp) +recurrence_page_fill_component (CompEditorPage *page, ECalComponent *comp) { RecurrencePage *rpage; @@ -1893,7 +1893,7 @@ recurrence_page_set_dates (CompEditorPage *page, CompEditorPageDates *dates) { RecurrencePage *rpage; RecurrencePagePrivate *priv; - CalComponentDateTime dt; + ECalComponentDateTime dt; struct icaltimetype icaltime; guint8 mask; @@ -1912,13 +1912,13 @@ recurrence_page_set_dates (CompEditorPage *page, CompEditorPageDates *dates) if (dates->start) { icaltime = *dates->start->value; dt.tzid = dates->start->tzid; - cal_component_set_dtstart (priv->comp, &dt); + e_cal_component_set_dtstart (priv->comp, &dt); } if (dates->end) { icaltime = *dates->end->value; dt.tzid = dates->end->tzid; - cal_component_set_dtend (priv->comp, &dt); + e_cal_component_set_dtend (priv->comp, &dt); } /* Update the weekday picker if necessary */ @@ -2094,7 +2094,7 @@ exception_add_cb (GtkWidget *widget, gpointer data) { RecurrencePage *rpage; RecurrencePagePrivate *priv; - CalComponentDateTime dt; + ECalComponentDateTime dt; struct icaltimetype icaltime = icaltime_null_time (); gboolean date_set; @@ -2126,7 +2126,7 @@ exception_modify_cb (GtkWidget *widget, gpointer data) RecurrencePage *rpage; RecurrencePagePrivate *priv; GtkTreeSelection *selection; - CalComponentDateTime dt; + ECalComponentDateTime dt; struct icaltimetype icaltime = icaltime_null_time (); struct icaltimetype *tt; GtkTreeIter iter; @@ -2205,7 +2205,7 @@ exception_selection_changed_cb (GtkTreeSelection *selection, gpointer data) { RecurrencePage *rpage; RecurrencePagePrivate *priv; - const CalComponentDateTime *dt; + const ECalComponentDateTime *dt; struct icaltimetype *t; GtkTreeIter iter; diff --git a/calendar/gui/dialogs/schedule-page.c b/calendar/gui/dialogs/schedule-page.c index 06c2d57131..7ed42cb707 100644 --- a/calendar/gui/dialogs/schedule-page.c +++ b/calendar/gui/dialogs/schedule-page.c @@ -81,8 +81,8 @@ static void schedule_page_finalize (GObject *object); static GtkWidget *schedule_page_get_widget (CompEditorPage *page); static void schedule_page_focus_main_widget (CompEditorPage *page); -static void schedule_page_fill_widgets (CompEditorPage *page, CalComponent *comp); -static gboolean schedule_page_fill_component (CompEditorPage *page, CalComponent *comp); +static void schedule_page_fill_widgets (CompEditorPage *page, ECalComponent *comp); +static gboolean schedule_page_fill_component (CompEditorPage *page, ECalComponent *comp); static void schedule_page_set_dates (CompEditorPage *page, CompEditorPageDates *dates); static void times_changed_cb (GtkWidget *widget, gpointer data); @@ -203,7 +203,7 @@ schedule_page_focus_main_widget (CompEditorPage *page) /* Set date/time */ static void -update_time (SchedulePage *spage, CalComponentDateTime *start_date, CalComponentDateTime *end_date) +update_time (SchedulePage *spage, ECalComponentDateTime *start_date, ECalComponentDateTime *end_date) { SchedulePagePrivate *priv; struct icaltimetype start_tt, end_tt; @@ -217,7 +217,7 @@ update_time (SchedulePage *spage, CalComponentDateTime *start_date, CalComponent first. */ start_zone = icaltimezone_get_builtin_timezone_from_tzid (start_date->tzid); if (!start_zone) { - if (!cal_client_get_timezone (COMP_EDITOR_PAGE (spage)->client, + if (!e_cal_get_timezone (COMP_EDITOR_PAGE (spage)->client, start_date->tzid, &start_zone, NULL)) { /* FIXME: Handle error better. */ g_warning ("Couldn't get timezone from server: %s", @@ -227,7 +227,7 @@ update_time (SchedulePage *spage, CalComponentDateTime *start_date, CalComponent end_zone = icaltimezone_get_builtin_timezone_from_tzid (end_date->tzid); if (!end_zone) { - if (!cal_client_get_timezone (COMP_EDITOR_PAGE (spage)->client, + if (!e_cal_get_timezone (COMP_EDITOR_PAGE (spage)->client, end_date->tzid, &end_zone, NULL)) { /* FIXME: Handle error better. */ g_warning ("Couldn't get timezone from server: %s", @@ -286,11 +286,11 @@ clear_widgets (SchedulePage *spage) /* fill_widgets handler for the schedule page */ static void -schedule_page_fill_widgets (CompEditorPage *page, CalComponent *comp) +schedule_page_fill_widgets (CompEditorPage *page, ECalComponent *comp) { SchedulePage *spage; SchedulePagePrivate *priv; - CalComponentDateTime start_date, end_date; + ECalComponentDateTime start_date, end_date; spage = SCHEDULE_PAGE (page); priv = spage->priv; @@ -301,19 +301,19 @@ schedule_page_fill_widgets (CompEditorPage *page, CalComponent *comp) clear_widgets (spage); /* Start and end times */ - cal_component_get_dtstart (comp, &start_date); - cal_component_get_dtend (comp, &end_date); + e_cal_component_get_dtstart (comp, &start_date); + e_cal_component_get_dtend (comp, &end_date); update_time (spage, &start_date, &end_date); - cal_component_free_datetime (&start_date); - cal_component_free_datetime (&end_date); + e_cal_component_free_datetime (&start_date); + e_cal_component_free_datetime (&end_date); priv->updating = FALSE; } /* fill_component handler for the schedule page */ static gboolean -schedule_page_fill_component (CompEditorPage *page, CalComponent *comp) +schedule_page_fill_component (CompEditorPage *page, ECalComponent *comp) { SchedulePage *spage; SchedulePagePrivate *priv; @@ -473,7 +473,7 @@ times_changed_cb (GtkWidget *widget, gpointer data) SchedulePage *spage = data; SchedulePagePrivate *priv; CompEditorPageDates dates; - CalComponentDateTime start_dt, end_dt; + ECalComponentDateTime start_dt, end_dt; struct icaltimetype start_tt = icaltime_null_time (); struct icaltimetype end_tt = icaltime_null_time (); diff --git a/calendar/gui/dialogs/send-comp.c b/calendar/gui/dialogs/send-comp.c index 0ca96ead7b..3075747a92 100644 --- a/calendar/gui/dialogs/send-comp.c +++ b/calendar/gui/dialogs/send-comp.c @@ -40,20 +40,20 @@ * Return value: TRUE if the user clicked Yes, FALSE otherwise. **/ gboolean -send_component_dialog (GtkWindow *parent, CalClient *client, CalComponent *comp, gboolean new) +send_component_dialog (GtkWindow *parent, ECal *client, ECalComponent *comp, gboolean new) { GtkWidget *dialog; - CalComponentVType vtype; + ECalComponentVType vtype; char *str; gint response; - if (cal_client_get_save_schedules (client)) + if (e_cal_get_save_schedules (client)) return FALSE; - vtype = cal_component_get_vtype (comp); + vtype = e_cal_component_get_vtype (comp); switch (vtype) { - case CAL_COMPONENT_EVENT: + case E_CAL_COMPONENT_EVENT: if (new) str = g_strdup_printf (_("The meeting information has " "been created. Send it?")); @@ -63,7 +63,7 @@ send_component_dialog (GtkWindow *parent, CalClient *client, CalComponent *comp, "version?")); break; - case CAL_COMPONENT_TODO: + case E_CAL_COMPONENT_TODO: if (new) str = g_strdup_printf (_("The task assignment " "information has been " diff --git a/calendar/gui/dialogs/send-comp.h b/calendar/gui/dialogs/send-comp.h index e02bd74d1e..86be94ccdb 100644 --- a/calendar/gui/dialogs/send-comp.h +++ b/calendar/gui/dialogs/send-comp.h @@ -23,9 +23,9 @@ #include <glib.h> #include <gtk/gtkwindow.h> -#include <cal-client/cal-client.h> -#include <cal-util/cal-component.h> +#include <libecal/e-cal.h> +#include <libecal/e-cal-component.h> -gboolean send_component_dialog (GtkWindow *parent, CalClient *client, CalComponent *comp, gboolean new); +gboolean send_component_dialog (GtkWindow *parent, ECal *client, ECalComponent *comp, gboolean new); #endif diff --git a/calendar/gui/dialogs/task-details-page.c b/calendar/gui/dialogs/task-details-page.c index cdaa8d08a1..938a9ec1fe 100644 --- a/calendar/gui/dialogs/task-details-page.c +++ b/calendar/gui/dialogs/task-details-page.c @@ -94,8 +94,8 @@ static void task_details_page_finalize (GObject *object); static GtkWidget *task_details_page_get_widget (CompEditorPage *page); static void task_details_page_focus_main_widget (CompEditorPage *page); -static void task_details_page_fill_widgets (CompEditorPage *page, CalComponent *comp); -static gboolean task_details_page_fill_component (CompEditorPage *page, CalComponent *comp); +static void task_details_page_fill_widgets (CompEditorPage *page, ECalComponent *comp); +static gboolean task_details_page_fill_component (CompEditorPage *page, ECalComponent *comp); static CompEditorPageClass *parent_class = NULL; @@ -278,7 +278,7 @@ clear_widgets (TaskDetailsPage *tdpage) /* fill_widgets handler for the task page */ static void -task_details_page_fill_widgets (CompEditorPage *page, CalComponent *comp) +task_details_page_fill_widgets (CompEditorPage *page, ECalComponent *comp) { TaskDetailsPage *tdpage; TaskDetailsPagePrivate *priv; @@ -297,7 +297,7 @@ task_details_page_fill_widgets (CompEditorPage *page, CalComponent *comp) clear_widgets (tdpage); /* Percent Complete. */ - cal_component_get_percent (comp, &percent); + e_cal_component_get_percent (comp, &percent); if (percent) { e_dialog_spin_set (priv->percent_complete, *percent); } else { @@ -306,7 +306,7 @@ task_details_page_fill_widgets (CompEditorPage *page, CalComponent *comp) } /* Status. */ - cal_component_get_status (comp, &status); + e_cal_component_get_status (comp, &status); if (status == ICAL_STATUS_NONE || status == ICAL_STATUS_NEEDSACTION) { /* Try to use the percent value. */ if (percent) { @@ -322,10 +322,10 @@ task_details_page_fill_widgets (CompEditorPage *page, CalComponent *comp) e_dialog_option_menu_set (priv->status, status, status_map); if (percent) - cal_component_free_percent (percent); + e_cal_component_free_percent (percent); /* Completed Date. */ - cal_component_get_completed (comp, &completed); + e_cal_component_get_completed (comp, &completed); if (completed) { icaltimezone *utc_zone, *zone; char *location; @@ -345,21 +345,21 @@ task_details_page_fill_widgets (CompEditorPage *page, CalComponent *comp) completed->hour, completed->minute); - cal_component_free_icaltimetype (completed); + e_cal_component_free_icaltimetype (completed); } /* Priority. */ - cal_component_get_priority (comp, &priority_value); + e_cal_component_get_priority (comp, &priority_value); if (priority_value) { priority = priority_value_to_index (*priority_value); - cal_component_free_priority (priority_value); + e_cal_component_free_priority (priority_value); } else { priority = PRIORITY_UNDEFINED; } e_dialog_option_menu_set (priv->priority, priority, priority_map); /* URL */ - cal_component_get_url (comp, &url); + e_cal_component_get_url (comp, &url); e_dialog_editable_set (priv->url, url); priv->updating = FALSE; @@ -367,7 +367,7 @@ task_details_page_fill_widgets (CompEditorPage *page, CalComponent *comp) /* fill_component handler for the task page */ static gboolean -task_details_page_fill_component (CompEditorPage *page, CalComponent *comp) +task_details_page_fill_component (CompEditorPage *page, ECalComponent *comp) { TaskDetailsPage *tdpage; TaskDetailsPagePrivate *priv; @@ -383,16 +383,16 @@ task_details_page_fill_component (CompEditorPage *page, CalComponent *comp) /* Percent Complete. */ percent = e_dialog_spin_get_int (priv->percent_complete); - cal_component_set_percent (comp, &percent); + e_cal_component_set_percent (comp, &percent); /* Status. */ status = e_dialog_option_menu_get (priv->status, status_map); - cal_component_set_status (comp, status); + e_cal_component_set_status (comp, status); /* Priority. */ priority = e_dialog_option_menu_get (priv->priority, priority_map); priority_value = priority_index_to_value (priority); - cal_component_set_priority (comp, &priority_value); + e_cal_component_set_priority (comp, &priority_value); icaltime = icaltime_null_time (); @@ -424,14 +424,14 @@ task_details_page_fill_component (CompEditorPage *page, CalComponent *comp) icaltimezone *zone = icaltimezone_get_builtin_timezone (location); icaltimezone_convert_time (&icaltime, zone, icaltimezone_get_utc_timezone ()); - cal_component_set_completed (comp, &icaltime); + e_cal_component_set_completed (comp, &icaltime); } else { - cal_component_set_completed (comp, NULL); + e_cal_component_set_completed (comp, NULL); } /* URL. */ url = e_dialog_editable_get (priv->url); - cal_component_set_url (comp, url); + e_cal_component_set_url (comp, url); if (url) g_free (url); diff --git a/calendar/gui/dialogs/task-editor.c b/calendar/gui/dialogs/task-editor.c index 339fdca80d..5c796df3a3 100644 --- a/calendar/gui/dialogs/task-editor.c +++ b/calendar/gui/dialogs/task-editor.c @@ -51,9 +51,9 @@ struct _TaskEditorPrivate { static void task_editor_class_init (TaskEditorClass *class); static void task_editor_init (TaskEditor *te); -static void task_editor_set_cal_client (CompEditor *editor, CalClient *client); -static void task_editor_edit_comp (CompEditor *editor, CalComponent *comp); -static gboolean task_editor_send_comp (CompEditor *editor, CalComponentItipMethod method); +static void task_editor_set_e_cal (CompEditor *editor, ECal *client); +static void task_editor_edit_comp (CompEditor *editor, ECalComponent *comp); +static gboolean task_editor_send_comp (CompEditor *editor, ECalComponentItipMethod method); static void task_editor_finalize (GObject *object); static void assign_task_cmd (GtkWidget *widget, gpointer data); @@ -101,7 +101,7 @@ task_editor_class_init (TaskEditorClass *klass) parent_class = g_type_class_ref(TYPE_COMP_EDITOR); - editor_class->set_cal_client = task_editor_set_cal_client; + editor_class->set_e_cal = task_editor_set_e_cal; editor_class->edit_comp = task_editor_edit_comp; editor_class->send_comp = task_editor_send_comp; @@ -119,9 +119,9 @@ set_menu_sens (TaskEditor *te) existing = comp_editor_get_existing_org (COMP_EDITOR (te)); user = comp_editor_get_user_org (COMP_EDITOR (te)); - cal_client_is_read_only (comp_editor_get_cal_client (COMP_EDITOR (te)), &read_only, NULL); + e_cal_is_read_only (comp_editor_get_e_cal (COMP_EDITOR (te)), &read_only, NULL); - sens = cal_client_get_static_capability (comp_editor_get_cal_client (COMP_EDITOR (te)), + sens = e_cal_get_static_capability (comp_editor_get_e_cal (COMP_EDITOR (te)), CAL_STATIC_CAPABILITY_NO_TASK_ASSIGNMENT) || priv->assignment_shown || read_only; comp_editor_set_ui_prop (COMP_EDITOR (te), @@ -180,7 +180,7 @@ task_editor_init (TaskEditor *te) } TaskEditor * -task_editor_construct (TaskEditor *te, CalClient *client) +task_editor_construct (TaskEditor *te, ECal *client) { TaskEditorPrivate *priv; @@ -207,7 +207,7 @@ task_editor_construct (TaskEditor *te, CalClient *client) COMP_EDITOR_PAGE (priv->meet_page), _("Assignment")); - comp_editor_set_cal_client (COMP_EDITOR (te), client); + comp_editor_set_e_cal (COMP_EDITOR (te), client); comp_editor_merge_ui (COMP_EDITOR (te), "evolution-task-editor.xml", verbs, NULL); @@ -218,7 +218,7 @@ task_editor_construct (TaskEditor *te, CalClient *client) } static void -task_editor_set_cal_client (CompEditor *editor, CalClient *client) +task_editor_set_e_cal (CompEditor *editor, ECal *client) { TaskEditor *te; TaskEditorPrivate *priv; @@ -226,19 +226,19 @@ task_editor_set_cal_client (CompEditor *editor, CalClient *client) te = TASK_EDITOR (editor); priv = te->priv; - e_meeting_store_set_cal_client (priv->model, client); + e_meeting_store_set_e_cal (priv->model, client); - if (parent_class->set_cal_client) - parent_class->set_cal_client (editor, client); + if (parent_class->set_e_cal) + parent_class->set_e_cal (editor, client); } static void -task_editor_edit_comp (CompEditor *editor, CalComponent *comp) +task_editor_edit_comp (CompEditor *editor, ECalComponent *comp) { TaskEditor *te; TaskEditorPrivate *priv; - CalComponentOrganizer organizer; - CalClient *client; + ECalComponentOrganizer organizer; + ECal *client; GSList *attendees = NULL; te = TASK_EDITOR (editor); @@ -249,11 +249,11 @@ task_editor_edit_comp (CompEditor *editor, CalComponent *comp) if (parent_class->edit_comp) parent_class->edit_comp (editor, comp); - client = comp_editor_get_cal_client (COMP_EDITOR (editor)); + client = comp_editor_get_e_cal (COMP_EDITOR (editor)); /* Get meeting related stuff */ - cal_component_get_organizer (comp, &organizer); - cal_component_get_attendee_list (comp, &attendees); + e_cal_component_get_organizer (comp, &organizer); + e_cal_component_get_attendee_list (comp, &attendees); /* Clear things up */ e_meeting_store_remove_all_attendees (priv->model); @@ -271,10 +271,10 @@ task_editor_edit_comp (CompEditor *editor, CalComponent *comp) _("Assignment")); for (l = attendees; l != NULL; l = l->next) { - CalComponentAttendee *ca = l->data; + ECalComponentAttendee *ca = l->data; EMeetingAttendee *ia; - ia = E_MEETING_ATTENDEE (e_meeting_attendee_new_from_cal_component_attendee (ca)); + ia = E_MEETING_ATTENDEE (e_meeting_attendee_new_from_e_cal_component_attendee (ca)); /* If we aren't the organizer or the attendee is just delegating, don't allow editing */ if (!comp_editor_get_user_org (editor) || e_meeting_attendee_is_set_delto (ia)) e_meeting_attendee_set_edit_level (ia, E_MEETING_ATTENDEE_EDIT_NONE); @@ -300,7 +300,7 @@ task_editor_edit_comp (CompEditor *editor, CalComponent *comp) e_meeting_attendee_set_edit_level (ia, E_MEETING_ATTENDEE_EDIT_STATUS); } g_object_unref(it); - } else if (cal_client_get_organizer_must_attend (client)) { + } else if (e_cal_get_organizer_must_attend (client)) { EMeetingAttendee *ia; ia = e_meeting_store_find_attendee (priv->model, organizer.value, &row); @@ -310,7 +310,7 @@ task_editor_edit_comp (CompEditor *editor, CalComponent *comp) priv->assignment_shown = TRUE; } - cal_component_free_attendee_list (attendees); + e_cal_component_free_attendee_list (attendees); set_menu_sens (te); comp_editor_set_needs_send (COMP_EDITOR (te), priv->assignment_shown && itip_organizer_is_user (comp, client)); @@ -319,26 +319,26 @@ task_editor_edit_comp (CompEditor *editor, CalComponent *comp) } static gboolean -task_editor_send_comp (CompEditor *editor, CalComponentItipMethod method) +task_editor_send_comp (CompEditor *editor, ECalComponentItipMethod method) { TaskEditor *te = TASK_EDITOR (editor); TaskEditorPrivate *priv; - CalComponent *comp = NULL; + ECalComponent *comp = NULL; priv = te->priv; /* Don't cancel more than once or when just publishing */ - if (method == CAL_COMPONENT_METHOD_PUBLISH || - method == CAL_COMPONENT_METHOD_CANCEL) + if (method == E_CAL_COMPONENT_METHOD_PUBLISH || + method == E_CAL_COMPONENT_METHOD_CANCEL) goto parent; comp = meeting_page_get_cancel_comp (priv->meet_page); if (comp != NULL) { - CalClient *client; + ECal *client; gboolean result; - client = e_meeting_store_get_cal_client (priv->model); - result = itip_send_comp (CAL_COMPONENT_METHOD_CANCEL, comp, client, NULL); + client = e_meeting_store_get_e_cal (priv->model); + result = itip_send_comp (E_CAL_COMPONENT_METHOD_CANCEL, comp, client, NULL); g_object_unref((comp)); if (!result) @@ -379,7 +379,7 @@ task_editor_finalize (GObject *object) /** * task_editor_new: - * @client: a CalClient + * @client: a ECal * * Creates a new event editor dialog. * @@ -387,7 +387,7 @@ task_editor_finalize (GObject *object) * editor could not be created. **/ TaskEditor * -task_editor_new (CalClient *client) +task_editor_new (ECal *client) { TaskEditor *te; @@ -439,19 +439,19 @@ refresh_task_cmd (GtkWidget *widget, gpointer data) { TaskEditor *te = TASK_EDITOR (data); - comp_editor_send_comp (COMP_EDITOR (te), CAL_COMPONENT_METHOD_REFRESH); + comp_editor_send_comp (COMP_EDITOR (te), E_CAL_COMPONENT_METHOD_REFRESH); } static void cancel_task_cmd (GtkWidget *widget, gpointer data) { TaskEditor *te = TASK_EDITOR (data); - CalComponent *comp; + ECalComponent *comp; comp = comp_editor_get_current_comp (COMP_EDITOR (te)); if (cancel_component_dialog ((GtkWindow *) te, - comp_editor_get_cal_client (COMP_EDITOR (te)), comp, FALSE)) { - comp_editor_send_comp (COMP_EDITOR (te), CAL_COMPONENT_METHOD_CANCEL); + comp_editor_get_e_cal (COMP_EDITOR (te)), comp, FALSE)) { + comp_editor_send_comp (COMP_EDITOR (te), E_CAL_COMPONENT_METHOD_CANCEL); comp_editor_delete_comp (COMP_EDITOR (te)); } } @@ -462,7 +462,7 @@ forward_cmd (GtkWidget *widget, gpointer data) TaskEditor *te = TASK_EDITOR (data); if (comp_editor_save_comp (COMP_EDITOR (te), TRUE)) - comp_editor_send_comp (COMP_EDITOR (te), CAL_COMPONENT_METHOD_PUBLISH); + comp_editor_send_comp (COMP_EDITOR (te), E_CAL_COMPONENT_METHOD_PUBLISH); } static void diff --git a/calendar/gui/dialogs/task-editor.h b/calendar/gui/dialogs/task-editor.h index aec98b073e..e0e6ac75be 100644 --- a/calendar/gui/dialogs/task-editor.h +++ b/calendar/gui/dialogs/task-editor.h @@ -53,8 +53,8 @@ struct _TaskEditorClass { GtkType task_editor_get_type (void); TaskEditor *task_editor_construct (TaskEditor *te, - CalClient *client); -TaskEditor *task_editor_new (CalClient *client); + ECal *client); +TaskEditor *task_editor_new (ECal *client); void task_editor_show_assignment(TaskEditor *te); diff --git a/calendar/gui/dialogs/task-page.c b/calendar/gui/dialogs/task-page.c index fb7558ce5a..e691c8de92 100644 --- a/calendar/gui/dialogs/task-page.c +++ b/calendar/gui/dialogs/task-page.c @@ -73,9 +73,9 @@ struct _TaskPagePrivate { }; static const int classification_map[] = { - CAL_COMPONENT_CLASS_PUBLIC, - CAL_COMPONENT_CLASS_PRIVATE, - CAL_COMPONENT_CLASS_CONFIDENTIAL, + E_CAL_COMPONENT_CLASS_PUBLIC, + E_CAL_COMPONENT_CLASS_PRIVATE, + E_CAL_COMPONENT_CLASS_CONFIDENTIAL, -1 }; @@ -87,8 +87,8 @@ static void task_page_finalize (GObject *object); static GtkWidget *task_page_get_widget (CompEditorPage *page); static void task_page_focus_main_widget (CompEditorPage *page); -static void task_page_fill_widgets (CompEditorPage *page, CalComponent *comp); -static gboolean task_page_fill_component (CompEditorPage *page, CalComponent *comp); +static void task_page_fill_widgets (CompEditorPage *page, ECalComponent *comp); +static gboolean task_page_fill_component (CompEditorPage *page, ECalComponent *comp); static void task_page_set_summary (CompEditorPage *page, const char *summary); static void task_page_set_dates (CompEditorPage *page, CompEditorPageDates *dates); @@ -231,14 +231,14 @@ clear_widgets (TaskPage *tpage) /* Classification */ e_dialog_radio_set (priv->classification_public, - CAL_COMPONENT_CLASS_PRIVATE, classification_map); + E_CAL_COMPONENT_CLASS_PRIVATE, classification_map); /* Categories */ e_dialog_editable_set (priv->categories, NULL); } /* Decode the radio button group for classifications */ -static CalComponentClassification +static ECalComponentClassification classification_get (GtkWidget *widget) { return e_dialog_radio_get (widget, classification_map); @@ -246,13 +246,13 @@ classification_get (GtkWidget *widget) /* fill_widgets handler for the task page */ static void -task_page_fill_widgets (CompEditorPage *page, CalComponent *comp) +task_page_fill_widgets (CompEditorPage *page, ECalComponent *comp) { TaskPage *tpage; TaskPagePrivate *priv; - CalComponentText text; - CalComponentDateTime d; - CalComponentClassification cl; + ECalComponentText text; + ECalComponentDateTime d; + ECalComponentClassification cl; GSList *l; const char *categories; icaltimezone *zone, *default_zone; @@ -267,25 +267,25 @@ task_page_fill_widgets (CompEditorPage *page, CalComponent *comp) clear_widgets (tpage); /* Summary, description(s) */ - cal_component_get_summary (comp, &text); + e_cal_component_get_summary (comp, &text); e_dialog_editable_set (priv->summary, text.value); - cal_component_get_description_list (comp, &l); + e_cal_component_get_description_list (comp, &l); if (l) { - text = *(CalComponentText *)l->data; + text = *(ECalComponentText *)l->data; gtk_text_buffer_set_text (gtk_text_view_get_buffer (GTK_TEXT_VIEW (priv->description)), text.value, -1); } else { gtk_text_buffer_set_text (gtk_text_view_get_buffer (GTK_TEXT_VIEW (priv->description)), "", 0); } - cal_component_free_text_list (l); + e_cal_component_free_text_list (l); location = calendar_config_get_timezone (); default_zone = icaltimezone_get_builtin_timezone (location); /* Due Date. */ - cal_component_get_due (comp, &d); + e_cal_component_get_due (comp, &d); zone = NULL; if (d.value) { struct icaltimetype *due_tt = d.value; @@ -316,7 +316,7 @@ task_page_fill_widgets (CompEditorPage *page, CalComponent *comp) if (!zone) zone = icaltimezone_get_builtin_timezone_from_tzid (d.tzid); if (!zone) { - if (!cal_client_get_timezone (page->client, d.tzid, &zone, NULL)) + if (!e_cal_get_timezone (page->client, d.tzid, &zone, NULL)) /* FIXME: Handle error better. */ g_warning ("Couldn't get timezone from server: %s", d.tzid ? d.tzid : ""); @@ -324,11 +324,11 @@ task_page_fill_widgets (CompEditorPage *page, CalComponent *comp) e_timezone_entry_set_timezone (E_TIMEZONE_ENTRY (priv->due_timezone), zone); - cal_component_free_datetime (&d); + e_cal_component_free_datetime (&d); /* Start Date. */ - cal_component_get_dtstart (comp, &d); + e_cal_component_get_dtstart (comp, &d); zone = NULL; if (d.value) { struct icaltimetype *start_tt = d.value; @@ -356,7 +356,7 @@ task_page_fill_widgets (CompEditorPage *page, CalComponent *comp) if (!zone) zone = icaltimezone_get_builtin_timezone_from_tzid (d.tzid); if (!zone) { - if (!cal_client_get_timezone (page->client, d.tzid, &zone, NULL)) + if (!e_cal_get_timezone (page->client, d.tzid, &zone, NULL)) /* FIXME: Handle error better. */ g_warning ("Couldn't get timezone from server: %s", d.tzid ? d.tzid : ""); @@ -364,40 +364,40 @@ task_page_fill_widgets (CompEditorPage *page, CalComponent *comp) e_timezone_entry_set_timezone (E_TIMEZONE_ENTRY (priv->start_timezone), zone); - cal_component_free_datetime (&d); + e_cal_component_free_datetime (&d); /* Classification. */ - cal_component_get_classification (comp, &cl); + e_cal_component_get_classification (comp, &cl); switch (cl) { - case CAL_COMPONENT_CLASS_PUBLIC: + case E_CAL_COMPONENT_CLASS_PUBLIC: e_dialog_radio_set (priv->classification_public, - CAL_COMPONENT_CLASS_PUBLIC, + E_CAL_COMPONENT_CLASS_PUBLIC, classification_map); break; - case CAL_COMPONENT_CLASS_PRIVATE: + case E_CAL_COMPONENT_CLASS_PRIVATE: e_dialog_radio_set (priv->classification_public, - CAL_COMPONENT_CLASS_PRIVATE, + E_CAL_COMPONENT_CLASS_PRIVATE, classification_map); break; - case CAL_COMPONENT_CLASS_CONFIDENTIAL: + case E_CAL_COMPONENT_CLASS_CONFIDENTIAL: e_dialog_radio_set (priv->classification_public, - CAL_COMPONENT_CLASS_CONFIDENTIAL, + E_CAL_COMPONENT_CLASS_CONFIDENTIAL, classification_map); break; default: /* default to PUBLIC */ e_dialog_radio_set (priv->classification_public, - CAL_COMPONENT_CLASS_PUBLIC, + E_CAL_COMPONENT_CLASS_PUBLIC, classification_map); break; } /* Categories */ - cal_component_get_categories (comp, &categories); + e_cal_component_get_categories (comp, &categories); e_dialog_editable_set (priv->categories, categories); @@ -406,11 +406,11 @@ task_page_fill_widgets (CompEditorPage *page, CalComponent *comp) /* fill_component handler for the task page */ static gboolean -task_page_fill_component (CompEditorPage *page, CalComponent *comp) +task_page_fill_component (CompEditorPage *page, ECalComponent *comp) { TaskPage *tpage; TaskPagePrivate *priv; - CalComponentDateTime date; + ECalComponentDateTime date; struct icaltimetype start_tt, due_tt; char *cat, *str; gboolean start_date_set, due_date_set, time_set; @@ -428,14 +428,14 @@ task_page_fill_component (CompEditorPage *page, CalComponent *comp) str = e_dialog_editable_get (priv->summary); if (!str || strlen (str) == 0) - cal_component_set_summary (comp, NULL); + e_cal_component_set_summary (comp, NULL); else { - CalComponentText text; + ECalComponentText text; text.value = str; text.altrep = NULL; - cal_component_set_summary (comp, &text); + e_cal_component_set_summary (comp, &text); } if (str) @@ -448,17 +448,17 @@ task_page_fill_component (CompEditorPage *page, CalComponent *comp) str = gtk_text_buffer_get_text (text_buffer, &text_iter_start, &text_iter_end, FALSE); if (!str || strlen (str) == 0) - cal_component_set_description_list (comp, NULL); + e_cal_component_set_description_list (comp, NULL); else { GSList l; - CalComponentText text; + ECalComponentText text; text.value = str; text.altrep = NULL; l.data = &text; l.next = NULL; - cal_component_set_description_list (comp, &l); + e_cal_component_set_description_list (comp, &l); } if (str) @@ -493,9 +493,9 @@ task_page_fill_component (CompEditorPage *page, CalComponent *comp) due_tt.is_date = TRUE; date.tzid = NULL; } - cal_component_set_due (comp, &date); + e_cal_component_set_due (comp, &date); } else { - cal_component_set_due (comp, NULL); + e_cal_component_set_due (comp, NULL); } /* Start Date. */ @@ -522,9 +522,9 @@ task_page_fill_component (CompEditorPage *page, CalComponent *comp) start_tt.is_date = TRUE; date.tzid = NULL; } - cal_component_set_dtstart (comp, &date); + e_cal_component_set_dtstart (comp, &date); } else { - cal_component_set_dtstart (comp, NULL); + e_cal_component_set_dtstart (comp, NULL); } /* Check whether due datetime is before start datetime */ @@ -544,7 +544,7 @@ task_page_fill_component (CompEditorPage *page, CalComponent *comp) /* Classification. */ - cal_component_set_classification (comp, classification_get (priv->classification_public)); + e_cal_component_set_classification (comp, classification_get (priv->classification_public)); /* Categories */ cat = e_dialog_editable_get (priv->categories); @@ -552,7 +552,7 @@ task_page_fill_component (CompEditorPage *page, CalComponent *comp) if (cat) g_free (cat); - cal_component_set_categories (comp, str); + e_cal_component_set_categories (comp, str); if (str) g_free (str); @@ -680,7 +680,7 @@ date_changed_cb (EDateEdit *dedit, gpointer data) TaskPagePrivate *priv; CompEditorPageDates dates; gboolean date_set, time_set; - CalComponentDateTime start_dt, due_dt; + ECalComponentDateTime start_dt, due_dt; struct icaltimetype start_tt = icaltime_null_time(); struct icaltimetype due_tt = icaltime_null_time(); diff --git a/calendar/gui/e-alarm-list.c b/calendar/gui/e-alarm-list.c index 534a8c9449..c1429f8705 100644 --- a/calendar/gui/e-alarm-list.c +++ b/calendar/gui/e-alarm-list.c @@ -27,7 +27,7 @@ #include <gtk/gtktreednd.h> #include <libgnome/gnome-i18n.h> #include <glib.h> -#include <cal-util/timeutil.h> +#include <libecal/e-cal-time-util.h> #include <e-util/e-time-utils.h> #include "calendar-config.h" #include "e-alarm-list.h" @@ -264,7 +264,7 @@ e_alarm_list_get_column_type (GtkTreeModel *tree_model, return column_types [index]; } -const CalComponentAlarm * +const ECalComponentAlarm * e_alarm_list_get_alarm (EAlarmList *alarm_list, GtkTreeIter *iter) { g_return_val_if_fail (IS_VALID_ITER (alarm_list, iter), NULL); @@ -273,22 +273,22 @@ e_alarm_list_get_alarm (EAlarmList *alarm_list, GtkTreeIter *iter) } static void -free_alarm (CalComponentAlarm *alarm) +free_alarm (ECalComponentAlarm *alarm) { - cal_component_alarm_free (alarm); + e_cal_component_alarm_free (alarm); } -static CalComponentAlarm * -copy_alarm (const CalComponentAlarm *alarm) +static ECalComponentAlarm * +copy_alarm (const ECalComponentAlarm *alarm) { - return cal_component_alarm_clone ((CalComponentAlarm *) alarm); + return e_cal_component_alarm_clone ((ECalComponentAlarm *) alarm); } void e_alarm_list_set_alarm (EAlarmList *alarm_list, GtkTreeIter *iter, - const CalComponentAlarm *alarm) + const ECalComponentAlarm *alarm) { - CalComponentAlarm *alarm_old; + ECalComponentAlarm *alarm_old; g_return_if_fail (IS_VALID_ITER (alarm_list, iter)); @@ -300,7 +300,7 @@ e_alarm_list_set_alarm (EAlarmList *alarm_list, GtkTreeIter *iter, void e_alarm_list_append (EAlarmList *alarm_list, GtkTreeIter *iter, - const CalComponentAlarm *alarm) + const ECalComponentAlarm *alarm) { g_return_if_fail (alarm != NULL); @@ -321,7 +321,7 @@ e_alarm_list_remove (EAlarmList *alarm_list, GtkTreeIter *iter) g_return_if_fail (IS_VALID_ITER (alarm_list, iter)); n = g_list_position (alarm_list->list, G_LIST (iter->user_data)); - free_alarm ((CalComponentAlarm *) G_LIST (iter->user_data)->data); + free_alarm ((ECalComponentAlarm *) G_LIST (iter->user_data)->data); alarm_list->list = g_list_delete_link (alarm_list->list, G_LIST (iter->user_data)); row_deleted (alarm_list, n); } @@ -334,7 +334,7 @@ e_alarm_list_clear (EAlarmList *alarm_list) all_rows_deleted (alarm_list); for (l = alarm_list->list; l; l = g_list_next (l)) { - free_alarm ((CalComponentAlarm *) l->data); + free_alarm ((ECalComponentAlarm *) l->data); } g_list_free (alarm_list->list); @@ -444,37 +444,37 @@ get_alarm_duration_string (struct icaldurationtype *duration) } static char * -get_alarm_string (CalComponentAlarm *alarm) +get_alarm_string (ECalComponentAlarm *alarm) { - CalAlarmAction action; - CalAlarmTrigger trigger; + ECalComponentAlarmAction action; + ECalComponentAlarmTrigger trigger; char string[256]; char *base, *str = NULL, *dur; string [0] = '\0'; - cal_component_alarm_get_action (alarm, &action); - cal_component_alarm_get_trigger (alarm, &trigger); + e_cal_component_alarm_get_action (alarm, &action); + e_cal_component_alarm_get_trigger (alarm, &trigger); switch (action) { - case CAL_ALARM_AUDIO: + case E_CAL_COMPONENT_ALARM_AUDIO: base = _("Play a sound"); break; - case CAL_ALARM_DISPLAY: + case E_CAL_COMPONENT_ALARM_DISPLAY: base = _("Display a message"); break; - case CAL_ALARM_EMAIL: + case E_CAL_COMPONENT_ALARM_EMAIL: base = _("Send an email"); break; - case CAL_ALARM_PROCEDURE: + case E_CAL_COMPONENT_ALARM_PROCEDURE: base = _("Run a program"); break; - case CAL_ALARM_NONE: - case CAL_ALARM_UNKNOWN: + case E_CAL_COMPONENT_ALARM_NONE: + case E_CAL_COMPONENT_ALARM_UNKNOWN: default: base = _("Unknown action to be performed"); break; @@ -483,7 +483,7 @@ get_alarm_string (CalComponentAlarm *alarm) /* FIXME: This does not look like it will localize correctly. */ switch (trigger.type) { - case CAL_ALARM_TRIGGER_RELATIVE_START: + case E_CAL_COMPONENT_ALARM_TRIGGER_RELATIVE_START: dur = get_alarm_duration_string (&trigger.u.rel_duration); if (dur) { @@ -500,7 +500,7 @@ get_alarm_string (CalComponentAlarm *alarm) break; - case CAL_ALARM_TRIGGER_RELATIVE_END: + case E_CAL_COMPONENT_ALARM_TRIGGER_RELATIVE_END: dur = get_alarm_duration_string (&trigger.u.rel_duration); if (dur) { @@ -517,7 +517,7 @@ get_alarm_string (CalComponentAlarm *alarm) break; - case CAL_ALARM_TRIGGER_ABSOLUTE: { + case E_CAL_COMPONENT_ALARM_TRIGGER_ABSOLUTE: { struct icaltimetype itt; icaltimezone *utc_zone, *current_zone; char *location; @@ -541,7 +541,7 @@ get_alarm_string (CalComponentAlarm *alarm) break; } - case CAL_ALARM_TRIGGER_NONE: + case E_CAL_COMPONENT_ALARM_TRIGGER_NONE: default: str = g_strdup_printf (_("%s for an unknown trigger type"), base); break; @@ -557,7 +557,7 @@ e_alarm_list_get_value (GtkTreeModel *tree_model, GValue *value) { EAlarmList *alarm_list = E_ALARM_LIST (tree_model); - CalComponentAlarm *alarm; + ECalComponentAlarm *alarm; GList *l; const gchar *str; diff --git a/calendar/gui/e-alarm-list.h b/calendar/gui/e-alarm-list.h index 2a03f9099b..93cc8ac58a 100644 --- a/calendar/gui/e-alarm-list.h +++ b/calendar/gui/e-alarm-list.h @@ -24,7 +24,7 @@ #define E_ALARM_LIST_H #include <gtk/gtktreemodel.h> -#include <cal-util/cal-component.h> +#include <libecal/e-cal-component.h> G_BEGIN_DECLS @@ -66,11 +66,11 @@ struct _EAlarmListClass GtkType e_alarm_list_get_type (void); EAlarmList *e_alarm_list_new (void); -const CalComponentAlarm *e_alarm_list_get_alarm (EAlarmList *alarm_list, GtkTreeIter *iter); +const ECalComponentAlarm *e_alarm_list_get_alarm (EAlarmList *alarm_list, GtkTreeIter *iter); void e_alarm_list_set_alarm (EAlarmList *alarm_list, GtkTreeIter *iter, - const CalComponentAlarm *datetime); + const ECalComponentAlarm *datetime); void e_alarm_list_append (EAlarmList *alarm_list, GtkTreeIter *iter, - const CalComponentAlarm *datetime); + const ECalComponentAlarm *datetime); void e_alarm_list_remove (EAlarmList *alarm_list, GtkTreeIter *iter); void e_alarm_list_clear (EAlarmList *alarm_list); diff --git a/calendar/gui/e-cal-list-view-config.c b/calendar/gui/e-cal-list-view-config.c index 5e4bbc31d2..e7d82230df 100644 --- a/calendar/gui/e-cal-list-view-config.c +++ b/calendar/gui/e-cal-list-view-config.c @@ -167,7 +167,7 @@ set_timezone (ECalListView *list_view) if (!zone) zone = icaltimezone_get_utc_timezone (); - e_cal_view_set_timezone (E_CAL_VIEW (list_view), zone); + e_calendar_view_set_timezone (E_CALENDAR_VIEW (list_view), zone); g_free (location); } @@ -190,7 +190,7 @@ set_twentyfour_hour (ECalListView *list_view) use_24_hour = calendar_config_get_24_hour_format (); - e_cal_view_set_use_24_hour_format (E_CAL_VIEW (list_view), use_24_hour); + e_calendar_view_set_use_24_hour_format (E_CALENDAR_VIEW (list_view), use_24_hour); } static void diff --git a/calendar/gui/e-cal-list-view.c b/calendar/gui/e-cal-list-view.c index 359ac4d557..c504695ada 100644 --- a/calendar/gui/e-cal-list-view.c +++ b/calendar/gui/e-cal-list-view.c @@ -56,7 +56,7 @@ #include <e-util/e-categories-config.h> #include <e-util/e-dialog-utils.h> -#include "cal-util/timeutil.h" +#include <libecal/e-cal-time-util.h> #include "e-cal-model-calendar.h" #include "e-cell-date-edit-text.h" #include "dialogs/delete-comp.h" @@ -74,10 +74,10 @@ static void e_cal_list_view_class_init (ECalListViewClass *class); static void e_cal_list_view_init (ECalListView *cal_list_view); static void e_cal_list_view_destroy (GtkObject *object); -static void e_cal_list_view_update_query (ECalView *cal_view); +static void e_cal_list_view_update_query (ECalendarView *cal_view); -static GList *e_cal_list_view_get_selected_events (ECalView *cal_view); -static gboolean e_cal_list_view_get_visible_time_range (ECalView *cal_view, time_t *start_time, +static GList *e_cal_list_view_get_selected_events (ECalendarView *cal_view); +static gboolean e_cal_list_view_get_visible_time_range (ECalendarView *cal_view, time_t *start_time, time_t *end_time); static gboolean e_cal_list_view_popup_menu (GtkWidget *widget); @@ -87,22 +87,22 @@ static void e_cal_list_view_show_popup_menu (ECalListView *cal_list_ static gboolean e_cal_list_view_on_table_right_click (GtkWidget *table, gint row, gint col, GdkEvent *event, gpointer data); -static GtkTableClass *parent_class; /* Should be ECalViewClass? */ +static GtkTableClass *parent_class; /* Should be ECalendarViewClass? */ E_MAKE_TYPE (e_cal_list_view, "ECalListView", ECalListView, e_cal_list_view_class_init, - e_cal_list_view_init, e_cal_view_get_type ()); + e_cal_list_view_init, e_calendar_view_get_type ()); static void e_cal_list_view_class_init (ECalListViewClass *class) { GtkObjectClass *object_class; GtkWidgetClass *widget_class; - ECalViewClass *view_class; + ECalendarViewClass *view_class; parent_class = g_type_class_peek_parent (class); object_class = (GtkObjectClass *) class; widget_class = (GtkWidgetClass *) class; - view_class = (ECalViewClass *) class; + view_class = (ECalendarViewClass *) class; /* Method override */ object_class->destroy = e_cal_list_view_destroy; @@ -161,7 +161,7 @@ get_current_time_cb (ECellDateEdit *ecde, gpointer data) struct tm tmp_tm = { 0 }; struct icaltimetype tt; - zone = e_cal_view_get_timezone (E_CAL_VIEW (cal_list_view)); + zone = e_calendar_view_get_timezone (E_CALENDAR_VIEW (cal_list_view)); tt = icaltime_from_timet_with_zone (time (NULL), FALSE, zone); /* Now copy it to the struct tm and return it. */ @@ -210,7 +210,7 @@ setup_e_table (ECalListView *cal_list_view) GnomeCanvas *canvas; GtkStyle *style; - model = E_CAL_MODEL_CALENDAR (e_cal_view_get_model (E_CAL_VIEW (cal_list_view))); + model = E_CAL_MODEL_CALENDAR (e_calendar_view_get_model (E_CALENDAR_VIEW (cal_list_view))); if (cal_list_view->table_scrolled) { save_table_state (cal_list_view); @@ -392,15 +392,15 @@ setup_e_table_cb (gpointer data) } static void -e_cal_list_view_update_query (ECalView *cal_list_view) +e_cal_list_view_update_query (ECalendarView *cal_list_view) { - e_cal_view_set_status_message (E_CAL_VIEW (cal_list_view), _("Searching")); + e_calendar_view_set_status_message (E_CALENDAR_VIEW (cal_list_view), _("Searching")); if (!E_CAL_LIST_VIEW (cal_list_view)->set_table_id) E_CAL_LIST_VIEW (cal_list_view)->set_table_id = g_idle_add (setup_e_table_cb, cal_list_view); - e_cal_view_set_status_message (E_CAL_VIEW (cal_list_view), NULL); + e_calendar_view_set_status_message (E_CALENDAR_VIEW (cal_list_view), NULL); } static void @@ -408,7 +408,7 @@ e_cal_list_view_show_popup_menu (ECalListView *cal_list_view, gint row, GdkEvent { GtkMenu *popup; - popup = e_cal_view_create_popup_menu (E_CAL_VIEW (cal_list_view)); + popup = e_calendar_view_create_popup_menu (E_CALENDAR_VIEW (cal_list_view)); e_popup_menu (popup, gdk_event); } @@ -432,7 +432,7 @@ e_cal_list_view_on_table_right_click (GtkWidget *table, gint row, gint col, GdkE } static GList * -e_cal_list_view_get_selected_events (ECalView *cal_view) +e_cal_list_view_get_selected_events (ECalendarView *cal_view) { GList *event_list = NULL; gint cursor_row; @@ -445,11 +445,11 @@ e_cal_list_view_get_selected_events (ECalView *cal_view) cursor_row = e_table_get_cursor_row (e_table_scrolled_get_table (E_CAL_LIST_VIEW (cal_view)->table_scrolled)); if (cursor_row >= 0) { - ECalViewEvent *event; + ECalendarViewEvent *event; - event = E_CAL_LIST_VIEW (cal_view)->cursor_event = g_new0 (ECalViewEvent, 1); + event = E_CAL_LIST_VIEW (cal_view)->cursor_event = g_new0 (ECalendarViewEvent, 1); event->comp_data = - e_cal_model_get_component_at (e_cal_view_get_model (cal_view), + e_cal_model_get_component_at (e_calendar_view_get_model (cal_view), cursor_row); event_list = g_list_prepend (event_list, event); } @@ -476,19 +476,19 @@ adjust_range (icaltimetype icaltime, time_t *earliest, time_t *latest, gboolean * ideal, since it's used in a couple of places. We could probably be smarter about it, * and use do it less frequently... */ static gboolean -e_cal_list_view_get_visible_time_range (ECalView *cal_view, time_t *start_time, time_t *end_time) +e_cal_list_view_get_visible_time_range (ECalendarView *cal_view, time_t *start_time, time_t *end_time) { time_t earliest = G_MAXINT, latest = 0; gboolean set = FALSE; gint n_rows, i; - n_rows = e_table_model_row_count (E_TABLE_MODEL (e_cal_view_get_model (cal_view))); + n_rows = e_table_model_row_count (E_TABLE_MODEL (e_calendar_view_get_model (cal_view))); for (i = 0; i < n_rows; i++) { ECalModelComponent *comp; icalcomponent *icalcomp; - comp = e_cal_model_get_component_at (e_cal_view_get_model (cal_view), i); + comp = e_cal_model_get_component_at (e_calendar_view_get_model (cal_view), i); if (!comp) continue; @@ -515,11 +515,11 @@ e_cal_list_view_get_range_shown (ECalListView *cal_list_view, GDate *start_date, time_t first, last; GDate end_date; - if (!e_cal_list_view_get_visible_time_range (E_CAL_VIEW (cal_list_view), &first, &last)) + if (!e_cal_list_view_get_visible_time_range (E_CALENDAR_VIEW (cal_list_view), &first, &last)) return FALSE; - time_to_gdate_with_zone (start_date, first, e_cal_view_get_timezone (E_CAL_VIEW (cal_list_view))); - time_to_gdate_with_zone (&end_date, last, e_cal_view_get_timezone (E_CAL_VIEW (cal_list_view))); + time_to_gdate_with_zone (start_date, first, e_calendar_view_get_timezone (E_CALENDAR_VIEW (cal_list_view))); + time_to_gdate_with_zone (&end_date, last, e_calendar_view_get_timezone (E_CALENDAR_VIEW (cal_list_view))); *days_shown = g_date_days_between (start_date, &end_date); return TRUE; diff --git a/calendar/gui/e-cal-list-view.h b/calendar/gui/e-cal-list-view.h index edf2e843e2..37c0e9675b 100644 --- a/calendar/gui/e-cal-list-view.h +++ b/calendar/gui/e-cal-list-view.h @@ -50,7 +50,7 @@ typedef struct _ECalListViewClass ECalListViewClass; struct _ECalListView { - ECalView cal_view; + ECalendarView cal_view; /* The main display table */ ETableScrolled *table_scrolled; @@ -59,7 +59,7 @@ struct _ECalListView gchar *table_state_path; /* S-expression for query and the query object */ - CalQuery *query; + ECalView *query; /* The default category for new events */ gchar *default_category; @@ -67,8 +67,8 @@ struct _ECalListView /* Date editing cell */ ECellDateEdit *dates_cell; - /* The last ECalViewEvent we returned from e_cal_list_view_get_selected_events(), to be freed */ - ECalViewEvent *cursor_event; + /* The last ECalendarViewEvent we returned from e_cal_list_view_get_selected_events(), to be freed */ + ECalendarViewEvent *cursor_event; /* Idle handler ID for setting a new ETableModel */ gint set_table_id; @@ -76,7 +76,7 @@ struct _ECalListView struct _ECalListViewClass { - ECalViewClass parent_class; + ECalendarViewClass parent_class; }; diff --git a/calendar/gui/e-cal-model-calendar.c b/calendar/gui/e-cal-model-calendar.c index fc44d29862..76462064a2 100644 --- a/calendar/gui/e-cal-model-calendar.c +++ b/calendar/gui/e-cal-model-calendar.c @@ -127,7 +127,7 @@ get_dtend (ECalModelComponent *comp_data) comp_data->dtend->tt = tt_end; /* FIXME: handle errors */ - cal_client_get_timezone (comp_data->client, + e_cal_get_timezone (comp_data->client, icaltime_get_tzid (tt_end), &zone, NULL); comp_data->dtend->zone = zone; @@ -309,7 +309,7 @@ ecmc_set_value_at (ETableModel *etm, int col, int row, const void *value) } /* FIXME ask about mod type */ - if (!cal_client_modify_object (comp_data->client, comp_data->icalcomp, CALOBJ_MOD_ALL, NULL)) { + if (!e_cal_modify_object (comp_data->client, comp_data->icalcomp, CALOBJ_MOD_ALL, NULL)) { g_warning (G_STRLOC ": Could not modify the object!"); /* FIXME Show error dialog */ diff --git a/calendar/gui/e-cal-model-tasks.c b/calendar/gui/e-cal-model-tasks.c index 5442c92485..c6da14c7d1 100644 --- a/calendar/gui/e-cal-model-tasks.c +++ b/calendar/gui/e-cal-model-tasks.c @@ -221,7 +221,7 @@ get_completed (ECalModelComponent *comp_data) comp_data->completed->tt = tt_completed; /* FIXME: handle errors */ - cal_client_get_timezone (comp_data->client, + e_cal_get_timezone (comp_data->client, icaltime_get_tzid (tt_completed), &zone, NULL); comp_data->completed->zone = zone; @@ -251,7 +251,7 @@ get_due (ECalModelComponent *comp_data) comp_data->due->tt = tt_due; /* FIXME: handle errors */ - cal_client_get_timezone (comp_data->client, + e_cal_get_timezone (comp_data->client, icaltime_get_tzid (tt_due), &zone, NULL); comp_data->due->zone = zone; @@ -300,7 +300,7 @@ get_priority (ECalModelComponent *comp_data) prop = icalcomponent_get_first_property (comp_data->icalcomp, ICAL_PRIORITY_PROPERTY); if (prop) - return cal_util_priority_to_string (icalproperty_get_priority (prop)); + return e_cal_util_priority_to_string (icalproperty_get_priority (prop)); return ""; } @@ -374,7 +374,7 @@ get_due_status (ECalModelTasks *model, ECalModelComponent *comp_data) return E_CAL_MODEL_TASKS_DUE_NEVER; else { struct icaltimetype now_tt, due_tt; - CalClientGetStatus status; + ECalGetStatus status; icaltimezone *zone; /* Second, is it already completed? */ @@ -397,10 +397,10 @@ get_due_status (ECalModelTasks *model, ECalModelComponent *comp_data) return E_CAL_MODEL_TASKS_DUE_FUTURE; } else { /* Get the current time in the same timezone as the DUE date.*/ - status = cal_client_get_timezone (comp_data->client, + status = e_cal_get_timezone (comp_data->client, icaltime_get_tzid (due_tt), &zone, NULL); - if (status != CAL_CLIENT_GET_SUCCESS) + if (status != E_CAL_GET_SUCCESS) return E_CAL_MODEL_TASKS_DUE_FUTURE; now_tt = icaltime_current_time_with_zone (zone); @@ -617,12 +617,12 @@ set_status (ECalModelComponent *comp_data, const char *value) /* if (status == ICAL_STATUS_NEEDSACTION) { */ /* percent = 0; */ -/* cal_component_set_percent (comp, &percent); */ -/* cal_component_set_completed (comp, NULL); */ +/* e_cal_component_set_percent (comp, &percent); */ +/* e_cal_component_set_completed (comp, NULL); */ /* } else if (status == ICAL_STATUS_INPROCESS) { */ /* ensure_task_not_complete (comp); */ /* percent = 50; */ -/* cal_component_set_percent (comp, &percent); */ +/* e_cal_component_set_percent (comp, &percent); */ /* } else if (status == ICAL_STATUS_COMPLETED) { */ /* ensure_task_complete (comp, -1); */ /* } */ @@ -673,7 +673,7 @@ set_priority (ECalModelComponent *comp_data, const char *value) prop = icalcomponent_get_first_property (comp_data->icalcomp, ICAL_PRIORITY_PROPERTY); - priority = cal_util_priority_from_string (value); + priority = e_cal_util_priority_from_string (value); if (priority == -1) { g_warning ("Invalid priority"); priority = 0; @@ -757,7 +757,7 @@ ecmt_set_value_at (ETableModel *etm, int col, int row, const void *value) } /* FIXME ask about mod type */ - if (!cal_client_modify_object (comp_data->client, comp_data->icalcomp, CALOBJ_MOD_ALL, NULL)) { + if (!e_cal_modify_object (comp_data->client, comp_data->icalcomp, CALOBJ_MOD_ALL, NULL)) { g_warning (G_STRLOC ": Could not modify the object!"); /* FIXME Show error dialog */ diff --git a/calendar/gui/e-cal-model.c b/calendar/gui/e-cal-model.c index f23b272bdd..9e5dc34b2c 100644 --- a/calendar/gui/e-cal-model.c +++ b/calendar/gui/e-cal-model.c @@ -25,7 +25,7 @@ #include <gal/util/e-util.h> #include <e-util/e-config-listener.h> #include <e-util/e-time-utils.h> -#include <cal-util/timeutil.h> +#include <libecal/e-cal-time-util.h> #include "calendar-config.h" #include "comp-util.h" #include "e-cal-model.h" @@ -33,8 +33,8 @@ #include "misc.h" typedef struct { - CalClient *client; - CalQuery *query; + ECal *client; + ECalView *query; } ECalModelClient; struct _ECalModelPrivate { @@ -42,7 +42,7 @@ struct _ECalModelPrivate { GList *clients; /* The default client in the list */ - CalClient *default_client; + ECal *default_client; /* Array for storing the objects. Each element is of type ECalModelComponent */ GPtrArray *objects; @@ -353,7 +353,7 @@ get_dtstart (ECalModel *model, ECalModelComponent *comp_data) comp_data->dtstart->tt = tt_start; /* FIXME: handle errors */ - cal_client_get_timezone (comp_data->client, + e_cal_get_timezone (comp_data->client, icaltime_get_tzid (tt_start), &zone, NULL); comp_data->dtstart->zone = zone; @@ -415,23 +415,23 @@ ecm_value_at (ETableModel *etm, int col, int row) ICAL_VALARM_COMPONENT) != NULL)); case E_CAL_MODEL_FIELD_ICON : { - CalComponent *comp; + ECalComponent *comp; icalcomponent *icalcomp; gint retval = 0; - comp = cal_component_new (); + comp = e_cal_component_new (); icalcomp = icalcomponent_new_clone (comp_data->icalcomp); - if (cal_component_set_icalcomponent (comp, icalcomp)) { - if (cal_component_has_recurrences (comp)) + if (e_cal_component_set_icalcomponent (comp, icalcomp)) { + if (e_cal_component_has_recurrences (comp)) retval = 1; else if (itip_organizer_is_user (comp, comp_data->client)) retval = 3; else { GSList *attendees = NULL, *sl; - cal_component_get_attendee_list (comp, &attendees); + e_cal_component_get_attendee_list (comp, &attendees); for (sl = attendees; sl != NULL; sl = sl->next) { - CalComponentAttendee *ca = sl->data; + ECalComponentAttendee *ca = sl->data; const char *text; text = itip_strip_mailto (ca->value); @@ -444,7 +444,7 @@ ecm_value_at (ETableModel *etm, int col, int row) } } - cal_component_free_attendee_list (attendees); + e_cal_component_free_attendee_list (attendees); } } else icalcomponent_free (icalcomp); @@ -613,7 +613,7 @@ ecm_set_value_at (ETableModel *etm, int col, int row, const void *value) } /* FIXME ask about mod type */ - if (!cal_client_modify_object (comp_data->client, comp_data->icalcomp, CALOBJ_MOD_ALL, NULL)) { + if (!e_cal_modify_object (comp_data->client, comp_data->icalcomp, CALOBJ_MOD_ALL, NULL)) { g_warning (G_STRLOC ": Could not modify the object!"); /* FIXME Show error dialog */ @@ -661,7 +661,7 @@ ecm_append_row (ETableModel *etm, ETableModel *source, int row) comp_data.client = e_cal_model_get_default_client (model); /* guard against saving before the calendar is open */ - if (!(comp_data.client && cal_client_get_load_state (comp_data.client) == CAL_CLIENT_LOAD_LOADED)) + if (!(comp_data.client && e_cal_get_load_state (comp_data.client) == E_CAL_LOAD_LOADED)) return; comp_data.icalcomp = e_cal_model_create_component_with_defaults (model); @@ -680,7 +680,7 @@ ecm_append_row (ETableModel *etm, ETableModel *source, int row) } - if (!cal_client_create_object (comp_data.client, comp_data.icalcomp, NULL, NULL)) { + if (!e_cal_create_object (comp_data.client, comp_data.icalcomp, NULL, NULL)) { g_warning (G_STRLOC ": Could not create the object!"); /* FIXME: show error dialog */ @@ -886,7 +886,7 @@ ecm_get_color_for_component (ECalModel *model, ECalModelComponent *comp_data) for (l = assigned_colors[i].uris; l != NULL; l = l->next) { if (!strcmp ((const char *) l->data, - cal_client_get_uri (comp_data->client))) + e_cal_get_uri (comp_data->client))) { return assigned_colors[i].color; } @@ -895,7 +895,7 @@ ecm_get_color_for_component (ECalModel *model, ECalModelComponent *comp_data) /* return the first unused color */ assigned_colors[first_empty].uris = g_list_append (assigned_colors[first_empty].uris, - g_strdup (cal_client_get_uri (comp_data->client))); + g_strdup (e_cal_get_uri (comp_data->client))); return assigned_colors[first_empty].color; } @@ -1003,7 +1003,7 @@ e_cal_model_set_use_24_hour_format (ECalModel *model, gboolean use24) /** * e_cal_model_get_default_client */ -CalClient * +ECal * e_cal_model_get_default_client (ECalModel *model) { ECalModelPrivate *priv; @@ -1014,7 +1014,7 @@ e_cal_model_get_default_client (ECalModel *model) priv = model->priv; - /* we always return a valid CalClient, since we rely on it in many places */ + /* we always return a valid ECal, since we rely on it in many places */ if (priv->default_client) return priv->default_client; @@ -1027,7 +1027,7 @@ e_cal_model_get_default_client (ECalModel *model) } void -e_cal_model_set_default_client (ECalModel *model, CalClient *client) +e_cal_model_set_default_client (ECalModel *model, ECal *client) { ECalModelPrivate *priv; GList *l; @@ -1036,7 +1036,7 @@ e_cal_model_set_default_client (ECalModel *model, CalClient *client) g_return_if_fail (model != NULL); g_return_if_fail (E_IS_CAL_MODEL (model)); g_return_if_fail (client != NULL); - g_return_if_fail (IS_CAL_CLIENT (client)); + g_return_if_fail (E_IS_CAL (client)); priv = model->priv; @@ -1080,7 +1080,7 @@ e_cal_model_get_client_list (ECalModel *model) * @model: A calendar model. * @uri: Uri for the client to get. */ -CalClient * +ECal * e_cal_model_get_client_for_uri (ECalModel *model, const char *uri) { GList *l; @@ -1091,7 +1091,7 @@ e_cal_model_get_client_for_uri (ECalModel *model, const char *uri) for (l = model->priv->clients; l != NULL; l = l->next) { ECalModelClient *client_data = (ECalModelClient *) l->data; - if (!strcmp (uri, cal_client_get_uri (client_data->client))) + if (!strcmp (uri, e_cal_get_uri (client_data->client))) return client_data->client; } @@ -1099,7 +1099,7 @@ e_cal_model_get_client_for_uri (ECalModel *model, const char *uri) } static ECalModelComponent * -search_by_uid_and_client (ECalModelPrivate *priv, CalClient *client, const char *uid) +search_by_uid_and_client (ECalModelPrivate *priv, ECal *client, const char *uid) { gint i; @@ -1134,7 +1134,7 @@ get_position_in_array (GPtrArray *objects, gpointer item) } static void -query_objects_added_cb (CalQuery *query, GList *objects, gpointer user_data) +e_cal_view_objects_added_cb (ECalView *query, GList *objects, gpointer user_data) { ECalModel *model = (ECalModel *) user_data; ECalModelPrivate *priv; @@ -1151,7 +1151,7 @@ query_objects_added_cb (CalQuery *query, GList *objects, gpointer user_data) ECalModelComponent *comp_data; comp_data = g_new0 (ECalModelComponent, 1); - comp_data->client = cal_query_get_client (query); + comp_data->client = e_cal_view_get_client (query); comp_data->icalcomp = icalcomponent_new_clone (l->data); g_ptr_array_add (priv->objects, comp_data); @@ -1161,7 +1161,7 @@ query_objects_added_cb (CalQuery *query, GList *objects, gpointer user_data) } static void -query_objects_modified_cb (CalQuery *query, GList *objects, gpointer user_data) +e_cal_view_objects_modified_cb (ECalView *query, GList *objects, gpointer user_data) { ECalModelPrivate *priv; ECalModel *model = (ECalModel *) user_data; @@ -1174,7 +1174,7 @@ query_objects_modified_cb (CalQuery *query, GList *objects, gpointer user_data) e_table_model_pre_change (E_TABLE_MODEL (model)); - comp_data = search_by_uid_and_client (priv, cal_query_get_client (query), icalcomponent_get_uid (l->data)); + comp_data = search_by_uid_and_client (priv, e_cal_view_get_client (query), icalcomponent_get_uid (l->data)); g_assert (comp_data); if (comp_data->icalcomp) @@ -1203,7 +1203,7 @@ query_objects_modified_cb (CalQuery *query, GList *objects, gpointer user_data) } static void -query_objects_removed_cb (CalQuery *query, GList *uids, gpointer user_data) +e_cal_view_objects_removed_cb (ECalView *query, GList *uids, gpointer user_data) { ECalModelPrivate *priv; ECalModel *model = (ECalModel *) user_data; @@ -1217,7 +1217,7 @@ query_objects_removed_cb (CalQuery *query, GList *uids, gpointer user_data) e_table_model_pre_change (E_TABLE_MODEL (model)); - comp_data = search_by_uid_and_client (priv, cal_query_get_client (query), l->data); + comp_data = search_by_uid_and_client (priv, e_cal_view_get_client (query), l->data); g_assert (comp_data); pos = get_position_in_array (priv->objects, comp_data); @@ -1230,7 +1230,7 @@ query_objects_removed_cb (CalQuery *query, GList *uids, gpointer user_data) } static void -query_progress_cb (CalQuery *query, const char *message, int percent, gpointer user_data) +e_cal_view_progress_cb (ECalView *query, const char *message, int percent, gpointer user_data) { ECalModel *model = (ECalModel *) user_data; @@ -1240,7 +1240,7 @@ query_progress_cb (CalQuery *query, const char *message, int percent, gpointer u } static void -query_done_cb (CalQuery *query, ECalendarStatus status, gpointer user_data) +e_cal_view_done_cb (ECalView *query, ECalendarStatus status, gpointer user_data) { ECalModel *model = (ECalModel *) user_data; @@ -1254,7 +1254,7 @@ query_done_cb (CalQuery *query, ECalendarStatus status, gpointer user_data) * whether we want completed tasks. */ static char * -adjust_query_sexp (ECalModel *model, const char *sexp) +adjust_e_cal_view_sexp (ECalModel *model, const char *sexp) { ECalModelPrivate *priv; char *type_sexp, *new_sexp; @@ -1281,7 +1281,7 @@ adjust_query_sexp (ECalModel *model, const char *sexp) } static void -update_query_for_client (ECalModel *model, ECalModelClient *client_data) +update_e_cal_view_for_client (ECalModel *model, ECalModelClient *client_data) { ECalModelPrivate *priv; gchar *real_sexp; @@ -1298,9 +1298,9 @@ update_query_for_client (ECalModel *model, ECalModelClient *client_data) /* prepare the query */ g_assert (priv->sexp != NULL); - real_sexp = adjust_query_sexp (model, priv->sexp); + real_sexp = adjust_e_cal_view_sexp (model, priv->sexp); - if (!cal_client_get_query (client_data->client, real_sexp, &client_data->query, NULL)) { + if (!e_cal_get_query (client_data->client, real_sexp, &client_data->query, NULL)) { g_warning (G_STRLOC ": Unable to get query"); g_free (real_sexp); @@ -1308,17 +1308,17 @@ update_query_for_client (ECalModel *model, ECalModelClient *client_data) } g_free (real_sexp); - g_signal_connect (client_data->query, "objects_added", G_CALLBACK (query_objects_added_cb), model); - g_signal_connect (client_data->query, "objects_modified", G_CALLBACK (query_objects_modified_cb), model); - g_signal_connect (client_data->query, "objects_removed", G_CALLBACK (query_objects_removed_cb), model); - g_signal_connect (client_data->query, "query_progress", G_CALLBACK (query_progress_cb), model); - g_signal_connect (client_data->query, "query_done", G_CALLBACK (query_done_cb), model); + g_signal_connect (client_data->query, "objects_added", G_CALLBACK (e_cal_view_objects_added_cb), model); + g_signal_connect (client_data->query, "objects_modified", G_CALLBACK (e_cal_view_objects_modified_cb), model); + g_signal_connect (client_data->query, "objects_removed", G_CALLBACK (e_cal_view_objects_removed_cb), model); + g_signal_connect (client_data->query, "view_progress", G_CALLBACK (e_cal_view_progress_cb), model); + g_signal_connect (client_data->query, "view_done", G_CALLBACK (e_cal_view_done_cb), model); - cal_query_start (client_data->query); + e_cal_view_start (client_data->query); } static void -backend_died_cb (CalClient *client, gpointer user_data) +backend_died_cb (ECal *client, gpointer user_data) { ECalModel *model; @@ -1328,7 +1328,7 @@ backend_died_cb (CalClient *client, gpointer user_data) } static void -add_new_client (ECalModel *model, CalClient *client) +add_new_client (ECalModel *model, ECal *client) { ECalModelPrivate *priv; ECalModelClient *client_data; @@ -1345,15 +1345,15 @@ add_new_client (ECalModel *model, CalClient *client) g_signal_connect (G_OBJECT (client_data->client), "backend_died", G_CALLBACK (backend_died_cb), model); - update_query_for_client (model, client_data); + update_e_cal_view_for_client (model, client_data); } static void -cal_opened_cb (CalClient *client, CalClientOpenStatus status, gpointer user_data) +cal_opened_cb (ECal *client, ECalOpenStatus status, gpointer user_data) { ECalModel *model = (ECalModel *) user_data; - if (status != CAL_CLIENT_OPEN_SUCCESS) + if (status != E_CAL_OPEN_SUCCESS) return; add_new_client (model, client); @@ -1363,16 +1363,16 @@ cal_opened_cb (CalClient *client, CalClientOpenStatus status, gpointer user_data * e_cal_model_add_client */ void -e_cal_model_add_client (ECalModel *model, CalClient *client) +e_cal_model_add_client (ECalModel *model, ECal *client) { ECalModelPrivate *priv; g_return_if_fail (E_IS_CAL_MODEL (model)); - g_return_if_fail (IS_CAL_CLIENT (client)); + g_return_if_fail (E_IS_CAL (client)); priv = model->priv; - if (cal_client_get_load_state (client) == CAL_CLIENT_LOAD_LOADED) + if (e_cal_get_load_state (client) == E_CAL_LOAD_LOADED) add_new_client (model, client); else g_signal_connect (client, "cal_opened", G_CALLBACK (cal_opened_cb), model); @@ -1413,13 +1413,13 @@ remove_client (ECalModel *model, ECalModelClient *client_data) * e_cal_model_remove_client */ void -e_cal_model_remove_client (ECalModel *model, CalClient *client) +e_cal_model_remove_client (ECalModel *model, ECal *client) { GList *l; ECalModelPrivate *priv; g_return_if_fail (E_IS_CAL_MODEL (model)); - g_return_if_fail (IS_CAL_CLIENT (client)); + g_return_if_fail (E_IS_CAL (client)); priv = model->priv; for (l = priv->clients; l != NULL; l = l->next) { @@ -1478,7 +1478,7 @@ e_cal_model_set_query (ECalModel *model, const char *sexp) ECalModelClient *client_data; client_data = (ECalModelClient *) l->data; - update_query_for_client (model, client_data); + update_e_cal_view_for_client (model, client_data); } } @@ -1489,9 +1489,9 @@ icalcomponent * e_cal_model_create_component_with_defaults (ECalModel *model) { ECalModelPrivate *priv; - CalComponent *comp; + ECalComponent *comp; icalcomponent *icalcomp; - CalClient *client; + ECal *client; g_return_val_if_fail (E_IS_CAL_MODEL (model), NULL); @@ -1517,14 +1517,14 @@ e_cal_model_create_component_with_defaults (ECalModel *model) if (!comp) return icalcomponent_new (priv->kind); - icalcomp = icalcomponent_new_clone (cal_component_get_icalcomponent (comp)); + icalcomp = icalcomponent_new_clone (e_cal_component_get_icalcomponent (comp)); g_object_unref (comp); /* make sure the component has an UID */ if (!icalcomponent_get_uid (icalcomp)) { char *uid; - uid = cal_component_gen_uid (); + uid = e_cal_component_gen_uid (); icalcomponent_set_uid (icalcomp, uid); g_free (uid); diff --git a/calendar/gui/e-cal-model.h b/calendar/gui/e-cal-model.h index 6adbe0473f..9f193b4f07 100644 --- a/calendar/gui/e-cal-model.h +++ b/calendar/gui/e-cal-model.h @@ -23,7 +23,7 @@ #define E_CAL_MODEL_H #include <gal/e-table/e-table-model.h> -#include <cal-client/cal-client.h> +#include <libecal/e-cal.h> #include "e-cell-date-edit-text.h" G_BEGIN_DECLS @@ -53,7 +53,7 @@ typedef enum { } ECalModelField; typedef struct { - CalClient *client; + ECal *client; icalcomponent *icalcomp; /* private data */ @@ -88,12 +88,12 @@ void e_cal_model_set_default_category (ECalModel *model, const gc gboolean e_cal_model_get_use_24_hour_format (ECalModel *model); void e_cal_model_set_use_24_hour_format (ECalModel *model, gboolean use24); -CalClient *e_cal_model_get_default_client (ECalModel *model); -void e_cal_model_set_default_client (ECalModel *model, CalClient *client); +ECal *e_cal_model_get_default_client (ECalModel *model); +void e_cal_model_set_default_client (ECalModel *model, ECal *client); GList *e_cal_model_get_client_list (ECalModel *model); -CalClient *e_cal_model_get_client_for_uri (ECalModel *model, const char *uri); -void e_cal_model_add_client (ECalModel *model, CalClient *client); -void e_cal_model_remove_client (ECalModel *model, CalClient *client); +ECal *e_cal_model_get_client_for_uri (ECalModel *model, const char *uri); +void e_cal_model_add_client (ECalModel *model, ECal *client); +void e_cal_model_remove_client (ECalModel *model, ECal *client); void e_cal_model_remove_all_clients (ECalModel *model); void e_cal_model_set_query (ECalModel *model, const gchar *sexp); diff --git a/calendar/gui/e-cal-view.c b/calendar/gui/e-cal-view.c index 2e392560cd..332019cf2c 100644 --- a/calendar/gui/e-cal-view.c +++ b/calendar/gui/e-cal-view.c @@ -29,8 +29,8 @@ #include <libgnome/gnome-i18n.h> #include <gal/util/e-util.h> #include "e-util/e-dialog-utils.h" -#include "cal-util/cal-util-marshal.h" -#include "cal-util/timeutil.h" +#include "e-calendar-marshal.h" +#include <libecal/e-cal-time-util.h> #include "evolution-activity-client.h" #include "calendar-commands.h" #include "calendar-config.h" @@ -53,7 +53,7 @@ #define EVOLUTION_CALENDAR_PROGRESS_IMAGE "evolution-calendar-mini.png" static GdkPixbuf *progress_icon[2] = { NULL, NULL }; -struct _ECalViewPrivate { +struct _ECalendarViewPrivate { /* The GnomeCalendar we are associated to */ GnomeCalendar *calendar; @@ -74,11 +74,11 @@ struct _ECalViewPrivate { char *default_category; }; -static void e_cal_view_class_init (ECalViewClass *klass); -static void e_cal_view_init (ECalView *cal_view, ECalViewClass *klass); -static void e_cal_view_get_property (GObject *object, guint property_id, GValue *value, GParamSpec *pspec); -static void e_cal_view_set_property (GObject *object, guint property_id, const GValue *value, GParamSpec *pspec); -static void e_cal_view_destroy (GtkObject *object); +static void e_calendar_view_class_init (ECalendarViewClass *klass); +static void e_calendar_view_init (ECalendarView *cal_view, ECalendarViewClass *klass); +static void e_calendar_view_get_property (GObject *object, guint property_id, GValue *value, GParamSpec *pspec); +static void e_calendar_view_set_property (GObject *object, guint property_id, const GValue *value, GParamSpec *pspec); +static void e_calendar_view_destroy (GtkObject *object); static GObjectClass *parent_class = NULL; static GdkAtom clipboard_atom = GDK_NONE; @@ -101,20 +101,20 @@ enum { LAST_SIGNAL }; -static guint e_cal_view_signals[LAST_SIGNAL] = { 0 }; +static guint e_calendar_view_signals[LAST_SIGNAL] = { 0 }; static void -e_cal_view_set_property (GObject *object, guint property_id, const GValue *value, GParamSpec *pspec) +e_calendar_view_set_property (GObject *object, guint property_id, const GValue *value, GParamSpec *pspec) { - ECalView *cal_view; - ECalViewPrivate *priv; + ECalendarView *cal_view; + ECalendarViewPrivate *priv; - cal_view = E_CAL_VIEW (object); + cal_view = E_CALENDAR_VIEW (object); priv = cal_view->priv; switch (property_id) { case PROP_MODEL: - e_cal_view_set_model (cal_view, E_CAL_MODEL (g_value_get_object (value))); + e_calendar_view_set_model (cal_view, E_CAL_MODEL (g_value_get_object (value))); break; default: G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec); @@ -123,17 +123,17 @@ e_cal_view_set_property (GObject *object, guint property_id, const GValue *value } static void -e_cal_view_get_property (GObject *object, guint property_id, GValue *value, GParamSpec *pspec) +e_calendar_view_get_property (GObject *object, guint property_id, GValue *value, GParamSpec *pspec) { - ECalView *cal_view; - ECalViewPrivate *priv; + ECalendarView *cal_view; + ECalendarViewPrivate *priv; - cal_view = E_CAL_VIEW (object); + cal_view = E_CALENDAR_VIEW (object); priv = cal_view->priv; switch (property_id) { case PROP_MODEL: - g_value_set_object (value, e_cal_view_get_model (cal_view)); + g_value_set_object (value, e_calendar_view_get_model (cal_view)); break; default: G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec); @@ -142,7 +142,7 @@ e_cal_view_get_property (GObject *object, guint property_id, GValue *value, GPar } static void -e_cal_view_class_init (ECalViewClass *klass) +e_calendar_view_class_init (ECalendarViewClass *klass) { GObjectClass *gobject_class = G_OBJECT_CLASS (klass); GtkObjectClass *object_class = GTK_OBJECT_CLASS (klass); @@ -150,9 +150,9 @@ e_cal_view_class_init (ECalViewClass *klass) parent_class = g_type_class_peek_parent (klass); /* Method override */ - gobject_class->set_property = e_cal_view_set_property; - gobject_class->get_property = e_cal_view_get_property; - object_class->destroy = e_cal_view_destroy; + gobject_class->set_property = e_calendar_view_set_property; + gobject_class->get_property = e_calendar_view_get_property; + object_class->destroy = e_calendar_view_destroy; klass->selection_changed = NULL; klass->selected_time_changed = NULL; @@ -171,46 +171,46 @@ e_cal_view_class_init (ECalViewClass *klass) | G_PARAM_CONSTRUCT)); /* Create class' signals */ - e_cal_view_signals[SELECTION_CHANGED] = + e_calendar_view_signals[SELECTION_CHANGED] = g_signal_new ("selection_changed", G_TYPE_FROM_CLASS (klass), G_SIGNAL_RUN_LAST, - G_STRUCT_OFFSET (ECalViewClass, selection_changed), + G_STRUCT_OFFSET (ECalendarViewClass, selection_changed), NULL, NULL, g_cclosure_marshal_VOID__VOID, G_TYPE_NONE, 0); - e_cal_view_signals[SELECTED_TIME_CHANGED] = + e_calendar_view_signals[SELECTED_TIME_CHANGED] = g_signal_new ("selected_time_changed", G_TYPE_FROM_CLASS (klass), G_SIGNAL_RUN_LAST, - G_STRUCT_OFFSET (ECalViewClass, selected_time_changed), + G_STRUCT_OFFSET (ECalendarViewClass, selected_time_changed), NULL, NULL, g_cclosure_marshal_VOID__VOID, G_TYPE_NONE, 0); - e_cal_view_signals[TIMEZONE_CHANGED] = + e_calendar_view_signals[TIMEZONE_CHANGED] = g_signal_new ("timezone_changed", G_TYPE_FROM_CLASS (klass), G_SIGNAL_RUN_LAST, - G_STRUCT_OFFSET (ECalViewClass, timezone_changed), + G_STRUCT_OFFSET (ECalendarViewClass, timezone_changed), NULL, NULL, - cal_util_marshal_VOID__POINTER_POINTER, + e_calendar_marshal_VOID__POINTER_POINTER, G_TYPE_NONE, 2, G_TYPE_POINTER, G_TYPE_POINTER); - e_cal_view_signals[EVENT_CHANGED] = + e_calendar_view_signals[EVENT_CHANGED] = g_signal_new ("event_changed", G_TYPE_FROM_CLASS (object_class), G_SIGNAL_RUN_FIRST | G_SIGNAL_ACTION, - G_STRUCT_OFFSET (ECalViewClass, event_changed), + G_STRUCT_OFFSET (ECalendarViewClass, event_changed), NULL, NULL, g_cclosure_marshal_VOID__POINTER, G_TYPE_NONE, 1, G_TYPE_POINTER); - e_cal_view_signals[EVENT_ADDED] = + e_calendar_view_signals[EVENT_ADDED] = g_signal_new ("event_added", G_TYPE_FROM_CLASS (object_class), G_SIGNAL_RUN_FIRST | G_SIGNAL_ACTION, - G_STRUCT_OFFSET (ECalViewClass, event_added), + G_STRUCT_OFFSET (ECalendarViewClass, event_added), NULL, NULL, g_cclosure_marshal_VOID__POINTER, G_TYPE_NONE, 1, @@ -227,33 +227,33 @@ e_cal_view_class_init (ECalViewClass *klass) static void model_changed_cb (ETableModel *etm, gpointer user_data) { - ECalView *cal_view = E_CAL_VIEW (user_data); + ECalendarView *cal_view = E_CALENDAR_VIEW (user_data); - e_cal_view_update_query (cal_view); + e_calendar_view_update_query (cal_view); } static void model_row_changed_cb (ETableModel *etm, int row, gpointer user_data) { - ECalView *cal_view = E_CAL_VIEW (user_data); + ECalendarView *cal_view = E_CALENDAR_VIEW (user_data); - e_cal_view_update_query (cal_view); + e_calendar_view_update_query (cal_view); } static void model_cell_changed_cb (ETableModel *etm, int col, int row, gpointer user_data) { - ECalView *cal_view = E_CAL_VIEW (user_data); + ECalendarView *cal_view = E_CALENDAR_VIEW (user_data); - e_cal_view_update_query (cal_view); + e_calendar_view_update_query (cal_view); } static void model_rows_changed_cb (ETableModel *etm, int row, int count, gpointer user_data) { - ECalView *cal_view = E_CAL_VIEW (user_data); + ECalendarView *cal_view = E_CALENDAR_VIEW (user_data); - e_cal_view_update_query (cal_view); + e_calendar_view_update_query (cal_view); } static void @@ -261,7 +261,7 @@ selection_get (GtkWidget *invisible, GtkSelectionData *selection_data, guint info, guint time_stamp, - ECalView *cal_view) + ECalendarView *cal_view) { if (cal_view->priv->clipboard_selection != NULL) { gtk_selection_data_set (selection_data, @@ -275,7 +275,7 @@ selection_get (GtkWidget *invisible, static void selection_clear_event (GtkWidget *invisible, GdkEventSelection *event, - ECalView *cal_view) + ECalendarView *cal_view) { if (cal_view->priv->clipboard_selection != NULL) { g_free (cal_view->priv->clipboard_selection); @@ -284,10 +284,10 @@ selection_clear_event (GtkWidget *invisible, } void -e_cal_view_add_event (ECalView *cal_view, CalClient *client, time_t dtstart, +e_calendar_view_add_event (ECalendarView *cal_view, ECal *client, time_t dtstart, icaltimezone *default_zone, icalcomponent *icalcomp, gboolean in_top_canvas) { - CalComponent *comp; + ECalComponent *comp; struct icaltimetype itime, old_dtstart, old_dtend; time_t tt_start, tt_end, new_dtstart; struct icaldurationtype ic_dur; @@ -331,18 +331,18 @@ e_cal_view_add_event (ECalView *cal_view, CalClient *client, time_t dtstart, icalcomponent_set_dtend (icalcomp, itime); /* FIXME The new uid stuff can go away once we actually set it in the backend */ - uid = cal_component_gen_uid (); - comp = cal_component_new (); - cal_component_set_icalcomponent ( + uid = e_cal_component_gen_uid (); + comp = e_cal_component_new (); + e_cal_component_set_icalcomponent ( comp, icalcomponent_new_clone (icalcomp)); - cal_component_set_uid (comp, uid); + e_cal_component_set_uid (comp, uid); /* FIXME Error handling */ - if (cal_client_create_object (client, cal_component_get_icalcomponent (comp), NULL, NULL)) { + if (e_cal_create_object (client, e_cal_component_get_icalcomponent (comp), NULL, NULL)) { if (itip_organizer_is_user (comp, client) && send_component_dialog ((GtkWindow *) gtk_widget_get_toplevel (GTK_WIDGET (cal_view)), client, comp, TRUE)) { - itip_send_comp (CAL_COMPONENT_METHOD_REQUEST, comp, + itip_send_comp (E_CAL_COMPONENT_METHOD_REQUEST, comp, client, NULL); } } else { @@ -357,16 +357,16 @@ static void selection_received (GtkWidget *invisible, GtkSelectionData *selection_data, guint time, - ECalView *cal_view) + ECalendarView *cal_view) { char *comp_str, *default_tzid; icalcomponent *icalcomp; icalcomponent_kind kind; time_t selected_time_start, selected_time_end; icaltimezone *default_zone; - CalClient *client; + ECal *client; - g_return_if_fail (E_IS_CAL_VIEW (cal_view)); + g_return_if_fail (E_IS_CALENDAR_VIEW (cal_view)); if (selection_data->length < 0 || selection_data->type != GDK_SELECTION_TYPE_STRING) { @@ -382,7 +382,7 @@ selection_received (GtkWidget *invisible, client = e_cal_model_get_default_client (cal_view->priv->model); /* FIXME Error checking */ - cal_client_get_timezone (client, default_tzid, &default_zone, NULL); + e_cal_get_timezone (client, default_tzid, &default_zone, NULL); /* check the type of the component */ /* FIXME An error dialog if we return? */ @@ -390,8 +390,8 @@ selection_received (GtkWidget *invisible, if (kind != ICAL_VCALENDAR_COMPONENT && kind != ICAL_VEVENT_COMPONENT) return; - e_cal_view_set_status_message (cal_view, _("Updating objects")); - e_cal_view_get_selected_time_range (cal_view, &selected_time_start, &selected_time_end); + e_calendar_view_set_status_message (cal_view, _("Updating objects")); + e_calendar_view_get_selected_time_range (cal_view, &selected_time_start, &selected_time_end); /* FIXME Timezone handling */ if (kind == ICAL_VCALENDAR_COMPONENT) { @@ -402,14 +402,14 @@ selection_received (GtkWidget *invisible, while (subcomp) { child_kind = icalcomponent_isa (subcomp); if (child_kind == ICAL_VEVENT_COMPONENT) - e_cal_view_add_event (cal_view, client, selected_time_start, + e_calendar_view_add_event (cal_view, client, selected_time_start, default_zone, subcomp, FALSE); else if (child_kind == ICAL_VTIMEZONE_COMPONENT) { icaltimezone *zone; zone = icaltimezone_new (); icaltimezone_set_component (zone, subcomp); - cal_client_add_timezone (client, zone, NULL); + e_cal_add_timezone (client, zone, NULL); icaltimezone_free (zone, 1); } @@ -421,16 +421,16 @@ selection_received (GtkWidget *invisible, icalcomponent_free (icalcomp); } else { - e_cal_view_add_event (cal_view, client, selected_time_start, default_zone, icalcomp, FALSE); + e_calendar_view_add_event (cal_view, client, selected_time_start, default_zone, icalcomp, FALSE); } - e_cal_view_set_status_message (cal_view, NULL); + e_calendar_view_set_status_message (cal_view, NULL); } static void -e_cal_view_init (ECalView *cal_view, ECalViewClass *klass) +e_calendar_view_init (ECalendarView *cal_view, ECalendarViewClass *klass) { - cal_view->priv = g_new0 (ECalViewPrivate, 1); + cal_view->priv = g_new0 (ECalendarViewPrivate, 1); cal_view->priv->model = (ECalModel *) e_cal_model_calendar_new (); g_signal_connect (G_OBJECT (cal_view->priv->model), "model_changed", @@ -461,11 +461,11 @@ e_cal_view_init (ECalView *cal_view, ECalViewClass *klass) } static void -e_cal_view_destroy (GtkObject *object) +e_calendar_view_destroy (GtkObject *object) { - ECalView *cal_view = (ECalView *) object; + ECalendarView *cal_view = (ECalendarView *) object; - g_return_if_fail (E_IS_CAL_VIEW (cal_view)); + g_return_if_fail (E_IS_CALENDAR_VIEW (cal_view)); if (cal_view->priv) { if (cal_view->priv->model) { @@ -504,37 +504,37 @@ e_cal_view_destroy (GtkObject *object) GTK_OBJECT_CLASS (parent_class)->destroy (object); } -E_MAKE_TYPE (e_cal_view, "ECalView", ECalView, e_cal_view_class_init, - e_cal_view_init, GTK_TYPE_TABLE); +E_MAKE_TYPE (e_calendar_view, "ECalendarView", ECalendarView, e_calendar_view_class_init, + e_calendar_view_init, GTK_TYPE_TABLE); GnomeCalendar * -e_cal_view_get_calendar (ECalView *cal_view) +e_calendar_view_get_calendar (ECalendarView *cal_view) { - g_return_val_if_fail (E_IS_CAL_VIEW (cal_view), NULL); + g_return_val_if_fail (E_IS_CALENDAR_VIEW (cal_view), NULL); return cal_view->priv->calendar; } void -e_cal_view_set_calendar (ECalView *cal_view, GnomeCalendar *calendar) +e_calendar_view_set_calendar (ECalendarView *cal_view, GnomeCalendar *calendar) { - g_return_if_fail (E_IS_CAL_VIEW (cal_view)); + g_return_if_fail (E_IS_CALENDAR_VIEW (cal_view)); cal_view->priv->calendar = calendar; } ECalModel * -e_cal_view_get_model (ECalView *cal_view) +e_calendar_view_get_model (ECalendarView *cal_view) { - g_return_val_if_fail (E_IS_CAL_VIEW (cal_view), NULL); + g_return_val_if_fail (E_IS_CALENDAR_VIEW (cal_view), NULL); return cal_view->priv->model; } void -e_cal_view_set_model (ECalView *cal_view, ECalModel *model) +e_calendar_view_set_model (ECalendarView *cal_view, ECalModel *model) { - g_return_if_fail (E_IS_CAL_VIEW (cal_view)); + g_return_if_fail (E_IS_CALENDAR_VIEW (cal_view)); g_return_if_fail (E_IS_CAL_MODEL (model)); if (cal_view->priv->model) { @@ -551,41 +551,41 @@ e_cal_view_set_model (ECalView *cal_view, ECalModel *model) g_signal_connect (G_OBJECT (cal_view->priv->model), "model_rows_inserted", G_CALLBACK (model_rows_changed_cb), cal_view); g_signal_connect (G_OBJECT (cal_view->priv->model), "model_rows_deleted", G_CALLBACK (model_rows_changed_cb), cal_view); - e_cal_view_update_query (cal_view); + e_calendar_view_update_query (cal_view); } icaltimezone * -e_cal_view_get_timezone (ECalView *cal_view) +e_calendar_view_get_timezone (ECalendarView *cal_view) { - g_return_val_if_fail (E_IS_CAL_VIEW (cal_view), NULL); + g_return_val_if_fail (E_IS_CALENDAR_VIEW (cal_view), NULL); return e_cal_model_get_timezone (cal_view->priv->model); } void -e_cal_view_set_timezone (ECalView *cal_view, icaltimezone *zone) +e_calendar_view_set_timezone (ECalendarView *cal_view, icaltimezone *zone) { icaltimezone *old_zone; - g_return_if_fail (E_IS_CAL_VIEW (cal_view)); + g_return_if_fail (E_IS_CALENDAR_VIEW (cal_view)); old_zone = e_cal_model_get_timezone (cal_view->priv->model); if (old_zone == zone) return; e_cal_model_set_timezone (cal_view->priv->model, zone); - g_signal_emit (G_OBJECT (cal_view), e_cal_view_signals[TIMEZONE_CHANGED], 0, + g_signal_emit (G_OBJECT (cal_view), e_calendar_view_signals[TIMEZONE_CHANGED], 0, old_zone, zone); } const char * -e_cal_view_get_default_category (ECalView *cal_view) +e_calendar_view_get_default_category (ECalendarView *cal_view) { - g_return_val_if_fail (E_IS_CAL_VIEW (cal_view), NULL); + g_return_val_if_fail (E_IS_CALENDAR_VIEW (cal_view), NULL); return (const char *) cal_view->priv->default_category; } /** - * e_cal_view_set_default_category + * e_calendar_view_set_default_category * @cal_view: A calendar view. * @category: Default category name or NULL for no category. * @@ -593,9 +593,9 @@ e_cal_view_get_default_category (ECalView *cal_view) * components from the given calendar view. */ void -e_cal_view_set_default_category (ECalView *cal_view, const char *category) +e_calendar_view_set_default_category (ECalendarView *cal_view, const char *category) { - g_return_if_fail (E_IS_CAL_VIEW (cal_view)); + g_return_if_fail (E_IS_CALENDAR_VIEW (cal_view)); if (cal_view->priv->default_category) g_free (cal_view->priv->default_category); @@ -604,7 +604,7 @@ e_cal_view_set_default_category (ECalView *cal_view, const char *category) } /** - * e_cal_view_get_use_24_hour_format: + * e_calendar_view_get_use_24_hour_format: * @cal_view: A calendar view. * * Gets whether the view is using 24 hour times or not. @@ -612,32 +612,32 @@ e_cal_view_set_default_category (ECalView *cal_view, const char *category) * Returns: the 24 hour setting. */ gboolean -e_cal_view_get_use_24_hour_format (ECalView *cal_view) +e_calendar_view_get_use_24_hour_format (ECalendarView *cal_view) { - g_return_val_if_fail (E_IS_CAL_VIEW (cal_view), FALSE); + g_return_val_if_fail (E_IS_CALENDAR_VIEW (cal_view), FALSE); return e_cal_model_get_use_24_hour_format (cal_view->priv->model); } /** - * e_cal_view_set_use_24_hour_format + * e_calendar_view_set_use_24_hour_format * @cal_view: A calendar view. * @use_24_hour: Whether to use 24 hour times or not. * * Sets the 12/24 hour times setting for the given view. */ void -e_cal_view_set_use_24_hour_format (ECalView *cal_view, gboolean use_24_hour) +e_calendar_view_set_use_24_hour_format (ECalendarView *cal_view, gboolean use_24_hour) { - g_return_if_fail (E_IS_CAL_VIEW (cal_view)); + g_return_if_fail (E_IS_CALENDAR_VIEW (cal_view)); e_cal_model_set_use_24_hour_format (cal_view->priv->model, use_24_hour); } void -e_cal_view_set_status_message (ECalView *cal_view, const gchar *message) +e_calendar_view_set_status_message (ECalendarView *cal_view, const gchar *message) { - g_return_if_fail (E_IS_CAL_VIEW (cal_view)); + g_return_if_fail (E_IS_CALENDAR_VIEW (cal_view)); if (!message || !*message) { if (cal_view->priv->activity) { @@ -665,45 +665,45 @@ e_cal_view_set_status_message (ECalView *cal_view, const gchar *message) } GList * -e_cal_view_get_selected_events (ECalView *cal_view) +e_calendar_view_get_selected_events (ECalendarView *cal_view) { - g_return_val_if_fail (E_IS_CAL_VIEW (cal_view), NULL); + g_return_val_if_fail (E_IS_CALENDAR_VIEW (cal_view), NULL); - if (E_CAL_VIEW_CLASS (G_OBJECT_GET_CLASS (cal_view))->get_selected_events) - return E_CAL_VIEW_CLASS (G_OBJECT_GET_CLASS (cal_view))->get_selected_events (cal_view); + if (E_CALENDAR_VIEW_CLASS (G_OBJECT_GET_CLASS (cal_view))->get_selected_events) + return E_CALENDAR_VIEW_CLASS (G_OBJECT_GET_CLASS (cal_view))->get_selected_events (cal_view); return NULL; } void -e_cal_view_get_selected_time_range (ECalView *cal_view, time_t *start_time, time_t *end_time) +e_calendar_view_get_selected_time_range (ECalendarView *cal_view, time_t *start_time, time_t *end_time) { - g_return_if_fail (E_IS_CAL_VIEW (cal_view)); + g_return_if_fail (E_IS_CALENDAR_VIEW (cal_view)); - if (E_CAL_VIEW_CLASS (G_OBJECT_GET_CLASS (cal_view))->get_selected_time_range) { - E_CAL_VIEW_CLASS (G_OBJECT_GET_CLASS (cal_view))->get_selected_time_range ( + if (E_CALENDAR_VIEW_CLASS (G_OBJECT_GET_CLASS (cal_view))->get_selected_time_range) { + E_CALENDAR_VIEW_CLASS (G_OBJECT_GET_CLASS (cal_view))->get_selected_time_range ( cal_view, start_time, end_time); } } void -e_cal_view_set_selected_time_range (ECalView *cal_view, time_t start_time, time_t end_time) +e_calendar_view_set_selected_time_range (ECalendarView *cal_view, time_t start_time, time_t end_time) { - g_return_if_fail (E_IS_CAL_VIEW (cal_view)); + g_return_if_fail (E_IS_CALENDAR_VIEW (cal_view)); - if (E_CAL_VIEW_CLASS (G_OBJECT_GET_CLASS (cal_view))->set_selected_time_range) { - E_CAL_VIEW_CLASS (G_OBJECT_GET_CLASS (cal_view))->set_selected_time_range ( + if (E_CALENDAR_VIEW_CLASS (G_OBJECT_GET_CLASS (cal_view))->set_selected_time_range) { + E_CALENDAR_VIEW_CLASS (G_OBJECT_GET_CLASS (cal_view))->set_selected_time_range ( cal_view, start_time, end_time); } } gboolean -e_cal_view_get_visible_time_range (ECalView *cal_view, time_t *start_time, time_t *end_time) +e_calendar_view_get_visible_time_range (ECalendarView *cal_view, time_t *start_time, time_t *end_time) { - g_return_val_if_fail (E_IS_CAL_VIEW (cal_view), FALSE); + g_return_val_if_fail (E_IS_CALENDAR_VIEW (cal_view), FALSE); - if (E_CAL_VIEW_CLASS (G_OBJECT_GET_CLASS (cal_view))->get_visible_time_range) { - return E_CAL_VIEW_CLASS (G_OBJECT_GET_CLASS (cal_view))->get_visible_time_range ( + if (E_CALENDAR_VIEW_CLASS (G_OBJECT_GET_CLASS (cal_view))->get_visible_time_range) { + return E_CALENDAR_VIEW_CLASS (G_OBJECT_GET_CLASS (cal_view))->get_visible_time_range ( cal_view, start_time, end_time); } @@ -711,91 +711,91 @@ e_cal_view_get_visible_time_range (ECalView *cal_view, time_t *start_time, time_ } void -e_cal_view_update_query (ECalView *cal_view) +e_calendar_view_update_query (ECalendarView *cal_view) { - g_return_if_fail (E_IS_CAL_VIEW (cal_view)); + g_return_if_fail (E_IS_CALENDAR_VIEW (cal_view)); - e_cal_view_set_status_message (cal_view, _("Searching")); + e_calendar_view_set_status_message (cal_view, _("Searching")); - if (E_CAL_VIEW_CLASS (G_OBJECT_GET_CLASS (cal_view))->update_query) { - E_CAL_VIEW_CLASS (G_OBJECT_GET_CLASS (cal_view))->update_query (cal_view); + if (E_CALENDAR_VIEW_CLASS (G_OBJECT_GET_CLASS (cal_view))->update_query) { + E_CALENDAR_VIEW_CLASS (G_OBJECT_GET_CLASS (cal_view))->update_query (cal_view); } - e_cal_view_set_status_message (cal_view, NULL); + e_calendar_view_set_status_message (cal_view, NULL); } void -e_cal_view_cut_clipboard (ECalView *cal_view) +e_calendar_view_cut_clipboard (ECalendarView *cal_view) { GList *selected, *l; const char *uid; - g_return_if_fail (E_IS_CAL_VIEW (cal_view)); + g_return_if_fail (E_IS_CALENDAR_VIEW (cal_view)); - selected = e_cal_view_get_selected_events (cal_view); + selected = e_calendar_view_get_selected_events (cal_view); if (!selected) return; - e_cal_view_set_status_message (cal_view, _("Deleting selected objects")); + e_calendar_view_set_status_message (cal_view, _("Deleting selected objects")); - e_cal_view_copy_clipboard (cal_view); + e_calendar_view_copy_clipboard (cal_view); for (l = selected; l != NULL; l = l->next) { - CalComponent *comp; - ECalViewEvent *event = (ECalViewEvent *) l->data; + ECalComponent *comp; + ECalendarViewEvent *event = (ECalendarViewEvent *) l->data; GError *error = NULL; if (!event) continue; - comp = cal_component_new (); - cal_component_set_icalcomponent (comp, icalcomponent_new_clone (event->comp_data->icalcomp)); + comp = e_cal_component_new (); + e_cal_component_set_icalcomponent (comp, icalcomponent_new_clone (event->comp_data->icalcomp)); if (itip_organizer_is_user (comp, event->comp_data->client) && cancel_component_dialog ((GtkWindow *) gtk_widget_get_toplevel (GTK_WIDGET (cal_view)), event->comp_data->client, comp, TRUE)) - itip_send_comp (CAL_COMPONENT_METHOD_CANCEL, comp, + itip_send_comp (E_CAL_COMPONENT_METHOD_CANCEL, comp, event->comp_data->client, NULL); - cal_component_get_uid (comp, &uid); - cal_client_remove_object (event->comp_data->client, uid, &error); - delete_error_dialog (error, CAL_COMPONENT_EVENT); + e_cal_component_get_uid (comp, &uid); + e_cal_remove_object (event->comp_data->client, uid, &error); + delete_error_dialog (error, E_CAL_COMPONENT_EVENT); g_clear_error (&error); g_object_unref (comp); } - e_cal_view_set_status_message (cal_view, NULL); + e_calendar_view_set_status_message (cal_view, NULL); g_list_free (selected); } void -e_cal_view_copy_clipboard (ECalView *cal_view) +e_calendar_view_copy_clipboard (ECalendarView *cal_view) { GList *selected, *l; gchar *comp_str; icalcomponent *vcal_comp; icalcomponent *new_icalcomp; - ECalViewEvent *event; + ECalendarViewEvent *event; - g_return_if_fail (E_IS_CAL_VIEW (cal_view)); + g_return_if_fail (E_IS_CALENDAR_VIEW (cal_view)); - selected = e_cal_view_get_selected_events (cal_view); + selected = e_calendar_view_get_selected_events (cal_view); if (!selected) return; /* create top-level VCALENDAR component and add VTIMEZONE's */ - vcal_comp = cal_util_new_top_level (); + vcal_comp = e_cal_util_new_top_level (); for (l = selected; l != NULL; l = l->next) { - event = (ECalViewEvent *) l->data; + event = (ECalendarViewEvent *) l->data; if (event) - cal_util_add_timezones_from_component (vcal_comp, event->comp_data->icalcomp); + e_cal_util_add_timezones_from_component (vcal_comp, event->comp_data->icalcomp); } for (l = selected; l != NULL; l = l->next) { - event = (ECalViewEvent *) l->data; + event = (ECalendarViewEvent *) l->data; new_icalcomp = icalcomponent_new_clone (event->comp_data->icalcomp); icalcomponent_add_component (vcal_comp, new_icalcomp); @@ -814,9 +814,9 @@ e_cal_view_copy_clipboard (ECalView *cal_view) } void -e_cal_view_paste_clipboard (ECalView *cal_view) +e_calendar_view_paste_clipboard (ECalendarView *cal_view) { - g_return_if_fail (E_IS_CAL_VIEW (cal_view)); + g_return_if_fail (E_IS_CALENDAR_VIEW (cal_view)); gtk_selection_convert (cal_view->priv->invisible, clipboard_atom, @@ -825,14 +825,14 @@ e_cal_view_paste_clipboard (ECalView *cal_view) } static void -delete_event (ECalView *cal_view, ECalViewEvent *event) +delete_event (ECalendarView *cal_view, ECalendarViewEvent *event) { - CalComponent *comp; - CalComponentVType vtype; + ECalComponent *comp; + ECalComponentVType vtype; - comp = cal_component_new (); - cal_component_set_icalcomponent (comp, icalcomponent_new_clone (event->comp_data->icalcomp)); - vtype = cal_component_get_vtype (comp); + comp = e_cal_component_new (); + e_cal_component_set_icalcomponent (comp, icalcomponent_new_clone (event->comp_data->icalcomp)); + vtype = e_cal_component_get_vtype (comp); if (delete_component_dialog (comp, FALSE, 1, vtype, GTK_WIDGET (cal_view))) { const char *uid; @@ -842,17 +842,17 @@ delete_event (ECalView *cal_view, ECalViewEvent *event) && cancel_component_dialog ((GtkWindow *) gtk_widget_get_toplevel (GTK_WIDGET (cal_view)), event->comp_data->client, comp, TRUE)) - itip_send_comp (CAL_COMPONENT_METHOD_CANCEL, comp, + itip_send_comp (E_CAL_COMPONENT_METHOD_CANCEL, comp, event->comp_data->client, NULL); - cal_component_get_uid (comp, &uid); + e_cal_component_get_uid (comp, &uid); if (!uid || !*uid) { g_object_unref (comp); return; } - cal_client_remove_object (event->comp_data->client, uid, &error); - delete_error_dialog (error, CAL_COMPONENT_EVENT); + e_cal_remove_object (event->comp_data->client, uid, &error); + delete_error_dialog (error, E_CAL_COMPONENT_EVENT); g_clear_error (&error); } @@ -860,16 +860,16 @@ delete_event (ECalView *cal_view, ECalViewEvent *event) } void -e_cal_view_delete_selected_event (ECalView *cal_view) +e_calendar_view_delete_selected_event (ECalendarView *cal_view) { GList *selected; - ECalViewEvent *event; + ECalendarViewEvent *event; - selected = e_cal_view_get_selected_events (cal_view); + selected = e_calendar_view_get_selected_events (cal_view); if (!selected) return; - event = (ECalViewEvent *) selected->data; + event = (ECalendarViewEvent *) selected->data; if (event) delete_event (cal_view, event); @@ -877,17 +877,17 @@ e_cal_view_delete_selected_event (ECalView *cal_view) } void -e_cal_view_delete_selected_events (ECalView *cal_view) +e_calendar_view_delete_selected_events (ECalendarView *cal_view) { GList *selected, *l; - ECalViewEvent *event; + ECalendarViewEvent *event; - selected = e_cal_view_get_selected_events (cal_view); + selected = e_calendar_view_get_selected_events (cal_view); if (!selected) return; for (l = selected; l != NULL; l = l->next) { - event = (ECalViewEvent *) l->data; + event = (ECalendarViewEvent *) l->data; if (event) delete_event (cal_view, event); } @@ -896,24 +896,24 @@ e_cal_view_delete_selected_events (ECalView *cal_view) } void -e_cal_view_delete_selected_occurrence (ECalView *cal_view) +e_calendar_view_delete_selected_occurrence (ECalendarView *cal_view) { - ECalViewEvent *event; + ECalendarViewEvent *event; GList *selected; const char *uid; GError *error = NULL; - selected = e_cal_view_get_selected_events (cal_view); + selected = e_calendar_view_get_selected_events (cal_view); if (!selected) return; - event = (ECalViewEvent *) selected->data; + event = (ECalendarViewEvent *) selected->data; uid = icalcomponent_get_uid (event->comp_data->icalcomp); /* FIXME: use 'rid' argument */ - cal_client_remove_object_with_mod (event->comp_data->client, uid, NULL, CALOBJ_MOD_THIS, &error); + e_cal_remove_object_with_mod (event->comp_data->client, uid, NULL, CALOBJ_MOD_THIS, &error); - delete_error_dialog (error, CAL_COMPONENT_EVENT); + delete_error_dialog (error, E_CAL_COMPONENT_EVENT); g_clear_error (&error); /* free memory */ @@ -923,42 +923,42 @@ e_cal_view_delete_selected_occurrence (ECalView *cal_view) static void on_new_appointment (GtkWidget *widget, gpointer user_data) { - ECalView *cal_view = (ECalView *) user_data; + ECalendarView *cal_view = (ECalendarView *) user_data; - e_cal_view_new_appointment (cal_view); + e_calendar_view_new_appointment (cal_view); } static void on_new_event (GtkWidget *widget, gpointer user_data) { time_t dtstart, dtend; - ECalView *cal_view = (ECalView *) user_data; + ECalendarView *cal_view = (ECalendarView *) user_data; - e_cal_view_get_selected_time_range (cal_view, &dtstart, &dtend); - e_cal_view_new_appointment_for (cal_view, dtstart, dtend, TRUE, FALSE); + e_calendar_view_get_selected_time_range (cal_view, &dtstart, &dtend); + e_calendar_view_new_appointment_for (cal_view, dtstart, dtend, TRUE, FALSE); } static void on_new_meeting (GtkWidget *widget, gpointer user_data) { time_t dtstart, dtend; - ECalView *cal_view = (ECalView *) user_data; + ECalendarView *cal_view = (ECalendarView *) user_data; - e_cal_view_get_selected_time_range (cal_view, &dtstart, &dtend); - e_cal_view_new_appointment_for (cal_view, dtstart, dtend, FALSE, TRUE); + e_calendar_view_get_selected_time_range (cal_view, &dtstart, &dtend); + e_calendar_view_new_appointment_for (cal_view, dtstart, dtend, FALSE, TRUE); } static void on_new_task (GtkWidget *widget, gpointer user_data) { - ECalView *cal_view = (ECalView *) user_data; + ECalendarView *cal_view = (ECalendarView *) user_data; gnome_calendar_new_task (cal_view->priv->calendar); } static void on_goto_date (GtkWidget *widget, gpointer user_data) { - ECalView *cal_view = E_CAL_VIEW (user_data); + ECalendarView *cal_view = E_CALENDAR_VIEW (user_data); goto_dialog (cal_view->priv->calendar); } @@ -966,7 +966,7 @@ on_goto_date (GtkWidget *widget, gpointer user_data) static void on_goto_today (GtkWidget *widget, gpointer user_data) { - ECalView *cal_view = E_CAL_VIEW (user_data); + ECalendarView *cal_view = E_CALENDAR_VIEW (user_data); calendar_goto_today (cal_view->priv->calendar); } @@ -975,14 +975,14 @@ static void on_edit_appointment (GtkWidget *widget, gpointer user_data) { GList *selected; - ECalView *cal_view = E_CAL_VIEW (user_data); + ECalendarView *cal_view = E_CALENDAR_VIEW (user_data); - selected = e_cal_view_get_selected_events (cal_view); + selected = e_calendar_view_get_selected_events (cal_view); if (selected) { - ECalViewEvent *event = (ECalViewEvent *) selected->data; + ECalendarViewEvent *event = (ECalendarViewEvent *) selected->data; if (event) - e_cal_view_edit_appointment (cal_view, event->comp_data->client, + e_calendar_view_edit_appointment (cal_view, event->comp_data->client, event->comp_data->icalcomp, FALSE); g_list_free (selected); @@ -992,14 +992,14 @@ on_edit_appointment (GtkWidget *widget, gpointer user_data) static void on_print (GtkWidget *widget, gpointer user_data) { - ECalView *cal_view; + ECalendarView *cal_view; time_t start; GnomeCalendarViewType view_type; PrintView print_view; - cal_view = E_CAL_VIEW (user_data); + cal_view = E_CALENDAR_VIEW (user_data); - e_cal_view_get_visible_time_range (cal_view, &start, NULL); + e_calendar_view_get_visible_time_range (cal_view, &start, NULL); view_type = gnome_calendar_get_view (cal_view->priv->calendar); switch (view_type) { @@ -1027,16 +1027,16 @@ on_print (GtkWidget *widget, gpointer user_data) static void on_save_as (GtkWidget *widget, gpointer user_data) { - ECalView *cal_view; + ECalendarView *cal_view; GList *selected; char *filename; char *ical_string; FILE *file; - ECalViewEvent *event; + ECalendarViewEvent *event; - cal_view = E_CAL_VIEW (user_data); + cal_view = E_CALENDAR_VIEW (user_data); - selected = e_cal_view_get_selected_events (cal_view); + selected = e_calendar_view_get_selected_events (cal_view); if (!selected) return; @@ -1044,8 +1044,8 @@ on_save_as (GtkWidget *widget, gpointer user_data) if (filename == NULL) return; - event = (ECalViewEvent *) selected->data; - ical_string = cal_client_get_component_as_string (event->comp_data->client, event->comp_data->icalcomp); + event = (ECalendarViewEvent *) selected->data; + ical_string = e_cal_get_component_as_string (event->comp_data->client, event->comp_data->icalcomp); if (ical_string == NULL) { g_warning ("Couldn't convert item to a string"); return; @@ -1067,20 +1067,20 @@ on_save_as (GtkWidget *widget, gpointer user_data) static void on_print_event (GtkWidget *widget, gpointer user_data) { - ECalView *cal_view; + ECalendarView *cal_view; GList *selected; - ECalViewEvent *event; - CalComponent *comp; + ECalendarViewEvent *event; + ECalComponent *comp; - cal_view = E_CAL_VIEW (user_data); - selected = e_cal_view_get_selected_events (cal_view); + cal_view = E_CALENDAR_VIEW (user_data); + selected = e_calendar_view_get_selected_events (cal_view); if (!selected) return; - event = (ECalViewEvent *) selected->data; + event = (ECalendarViewEvent *) selected->data; - comp = cal_component_new (); - cal_component_set_icalcomponent (comp, icalcomponent_new_clone (event->comp_data->icalcomp)); + comp = e_cal_component_new (); + e_cal_component_set_icalcomponent (comp, icalcomponent_new_clone (event->comp_data->icalcomp)); print_comp (comp, event->comp_data->client, FALSE); g_object_unref (comp); @@ -1090,12 +1090,12 @@ static void on_meeting (GtkWidget *widget, gpointer user_data) { GList *selected; - ECalView *cal_view = E_CAL_VIEW (user_data); + ECalendarView *cal_view = E_CALENDAR_VIEW (user_data); - selected = e_cal_view_get_selected_events (cal_view); + selected = e_calendar_view_get_selected_events (cal_view); if (selected) { - ECalViewEvent *event = (ECalViewEvent *) selected->data; - e_cal_view_edit_appointment (cal_view, event->comp_data->client, event->comp_data->icalcomp, TRUE); + ECalendarViewEvent *event = (ECalendarViewEvent *) selected->data; + e_calendar_view_edit_appointment (cal_view, event->comp_data->client, event->comp_data->icalcomp, TRUE); g_list_free (selected); } @@ -1105,16 +1105,16 @@ static void on_forward (GtkWidget *widget, gpointer user_data) { GList *selected; - ECalView *cal_view = E_CAL_VIEW (user_data); + ECalendarView *cal_view = E_CALENDAR_VIEW (user_data); - selected = e_cal_view_get_selected_events (cal_view); + selected = e_calendar_view_get_selected_events (cal_view); if (selected) { - CalComponent *comp; - ECalViewEvent *event = (ECalViewEvent *) selected->data; + ECalComponent *comp; + ECalendarViewEvent *event = (ECalendarViewEvent *) selected->data; - comp = cal_component_new (); - cal_component_set_icalcomponent (comp, icalcomponent_new_clone (event->comp_data->icalcomp)); - itip_send_comp (CAL_COMPONENT_METHOD_PUBLISH, comp, event->comp_data->client, NULL); + comp = e_cal_component_new (); + e_cal_component_set_icalcomponent (comp, icalcomponent_new_clone (event->comp_data->icalcomp)); + itip_send_comp (E_CAL_COMPONENT_METHOD_PUBLISH, comp, event->comp_data->client, NULL); g_list_free (selected); g_object_unref (comp); @@ -1124,12 +1124,12 @@ on_forward (GtkWidget *widget, gpointer user_data) static void on_publish (GtkWidget *widget, gpointer user_data) { - ECalView *cal_view; + ECalendarView *cal_view; icaltimezone *utc; time_t start = time (NULL), end; GList *comp_list = NULL, *client_list, *cl; - cal_view = E_CAL_VIEW (user_data); + cal_view = E_CALENDAR_VIEW (user_data); utc = icaltimezone_get_utc_timezone (); start = time_day_begin_with_zone (start, utc); @@ -1137,12 +1137,12 @@ on_publish (GtkWidget *widget, gpointer user_data) client_list = e_cal_model_get_client_list (cal_view->priv->model); for (cl = client_list; cl != NULL; cl = cl->next) { - if (cal_client_get_free_busy ((CalClient *) cl->data, NULL, start, end, &comp_list, NULL)) { + if (e_cal_get_free_busy ((ECal *) cl->data, NULL, start, end, &comp_list, NULL)) { GList *l; for (l = comp_list; l; l = l->next) { - CalComponent *comp = CAL_COMPONENT (l->data); - itip_send_comp (CAL_COMPONENT_METHOD_PUBLISH, comp, (CalClient *) cl->data, NULL); + ECalComponent *comp = E_CAL_COMPONENT (l->data); + itip_send_comp (E_CAL_COMPONENT_METHOD_PUBLISH, comp, (ECal *) cl->data, NULL); g_object_unref (comp); } @@ -1157,52 +1157,52 @@ on_publish (GtkWidget *widget, gpointer user_data) static void on_settings (GtkWidget *widget, gpointer user_data) { - ECalView *cal_view; + ECalendarView *cal_view; - cal_view = E_CAL_VIEW (user_data); + cal_view = E_CALENDAR_VIEW (user_data); control_util_show_settings (cal_view->priv->calendar); } static void on_delete_appointment (GtkWidget *widget, gpointer user_data) { - ECalView *cal_view; + ECalendarView *cal_view; - cal_view = E_CAL_VIEW (user_data); - e_cal_view_delete_selected_event (cal_view); + cal_view = E_CALENDAR_VIEW (user_data); + e_calendar_view_delete_selected_event (cal_view); } static void on_delete_occurrence (GtkWidget *widget, gpointer user_data) { - ECalView *cal_view; + ECalendarView *cal_view; - cal_view = E_CAL_VIEW (user_data); - e_cal_view_delete_selected_occurrence (cal_view); + cal_view = E_CALENDAR_VIEW (user_data); + e_calendar_view_delete_selected_occurrence (cal_view); } static void on_cut (GtkWidget *widget, gpointer user_data) { - ECalView *cal_view = E_CAL_VIEW (user_data); + ECalendarView *cal_view = E_CALENDAR_VIEW (user_data); - e_cal_view_cut_clipboard (cal_view); + e_calendar_view_cut_clipboard (cal_view); } static void on_copy (GtkWidget *widget, gpointer user_data) { - ECalView *cal_view = E_CAL_VIEW (user_data); + ECalendarView *cal_view = E_CALENDAR_VIEW (user_data); - e_cal_view_copy_clipboard (cal_view); + e_calendar_view_copy_clipboard (cal_view); } static void on_paste (GtkWidget *widget, gpointer user_data) { - ECalView *cal_view = E_CAL_VIEW (user_data); + ECalendarView *cal_view = E_CALENDAR_VIEW (user_data); - e_cal_view_paste_clipboard (cal_view); + e_calendar_view_paste_clipboard (cal_view); } enum { @@ -1307,7 +1307,7 @@ static EPopupMenu child_items [] = { static void free_view_popup (GtkWidget *widget, gpointer data) { - ECalView *cal_view = E_CAL_VIEW (data); + ECalendarView *cal_view = E_CALENDAR_VIEW (data); if (cal_view->priv->view_menu == NULL) return; @@ -1362,19 +1362,19 @@ setup_popup_icons (EPopupMenu *context_menu) } GtkMenu * -e_cal_view_create_popup_menu (ECalView *cal_view) +e_calendar_view_create_popup_menu (ECalendarView *cal_view) { GList *selected; EPopupMenu *context_menu; guint32 disable_mask = 0, hide_mask = 0; GtkMenu *popup; - CalClient *client = NULL; + ECal *client = NULL; gboolean read_only = TRUE; - g_return_val_if_fail (E_IS_CAL_VIEW (cal_view), NULL); + g_return_val_if_fail (E_IS_CALENDAR_VIEW (cal_view), NULL); /* get the selection */ - selected = e_cal_view_get_selected_events (cal_view); + selected = e_calendar_view_get_selected_events (cal_view); if (selected == NULL) { cal_view->priv->view_menu = gnome_calendar_setup_view_popup (cal_view->priv->calendar); @@ -1383,26 +1383,26 @@ e_cal_view_create_popup_menu (ECalView *cal_view) client = e_cal_model_get_default_client (cal_view->priv->model); } else { - ECalViewEvent *event; + ECalendarViewEvent *event; context_menu = child_items; - event = (ECalViewEvent *) selected->data; - if (cal_util_component_has_recurrences (event->comp_data->icalcomp)) + event = (ECalendarViewEvent *) selected->data; + if (e_cal_util_component_has_recurrences (event->comp_data->icalcomp)) hide_mask |= MASK_SINGLE; else hide_mask |= MASK_RECURRING; - if (cal_util_component_is_instance (event->comp_data->icalcomp)) + if (e_cal_util_component_is_instance (event->comp_data->icalcomp)) hide_mask |= MASK_INSTANCE; - if (cal_util_component_has_organizer (event->comp_data->icalcomp)) { - CalComponent *comp; + if (e_cal_util_component_has_organizer (event->comp_data->icalcomp)) { + ECalComponent *comp; disable_mask |= MASK_MEETING; - comp = cal_component_new (); - cal_component_set_icalcomponent (comp, icalcomponent_new_clone (event->comp_data->icalcomp)); + comp = e_cal_component_new (); + e_cal_component_set_icalcomponent (comp, icalcomponent_new_clone (event->comp_data->icalcomp)); if (!itip_organizer_is_user (comp, event->comp_data->client)) disable_mask |= MASK_MEETING_ORGANIZER; @@ -1412,7 +1412,7 @@ e_cal_view_create_popup_menu (ECalView *cal_view) client = event->comp_data->client; } - cal_client_is_read_only (client, &read_only, NULL); + e_cal_is_read_only (client, &read_only, NULL); if (read_only) disable_mask |= MASK_EDITABLE; @@ -1424,7 +1424,7 @@ e_cal_view_create_popup_menu (ECalView *cal_view) } /** - * e_cal_view_new_appointment_for + * e_calendar_view_new_appointment_for * @cal_view: A calendar view. * @dtstart: A Unix time_t that marks the beginning of the appointment. * @dtend: A Unix time_t that marks the end of the appointment. @@ -1435,19 +1435,19 @@ e_cal_view_create_popup_menu (ECalView *cal_view) * Opens an event editor dialog for a new appointment. */ void -e_cal_view_new_appointment_for (ECalView *cal_view, +e_calendar_view_new_appointment_for (ECalendarView *cal_view, time_t dtstart, time_t dtend, gboolean all_day, gboolean meeting) { - ECalViewPrivate *priv; + ECalendarViewPrivate *priv; struct icaltimetype itt; - CalComponentDateTime dt; - CalComponent *comp; + ECalComponentDateTime dt; + ECalComponent *comp; icalcomponent *icalcomp; - CalComponentTransparency transparency; + ECalComponentTransparency transparency; - g_return_if_fail (E_IS_CAL_VIEW (cal_view)); + g_return_if_fail (E_IS_CALENDAR_VIEW (cal_view)); priv = cal_view->priv; @@ -1458,8 +1458,8 @@ e_cal_view_new_appointment_for (ECalView *cal_view, dt.tzid = icaltimezone_get_tzid (e_cal_model_get_timezone (cal_view->priv->model)); icalcomp = e_cal_model_create_component_with_defaults (priv->model); - comp = cal_component_new (); - cal_component_set_icalcomponent (comp, icalcomp); + comp = e_cal_component_new (); + e_cal_component_set_icalcomponent (comp, icalcomp); /* DTSTART, DTEND */ itt = icaltime_from_timet_with_zone (dtstart, FALSE, e_cal_model_get_timezone (cal_view->priv->model)); @@ -1467,7 +1467,7 @@ e_cal_view_new_appointment_for (ECalView *cal_view, itt.hour = itt.minute = itt.second = 0; itt.is_date = TRUE; } - cal_component_set_dtstart (comp, &dt); + e_cal_component_set_dtstart (comp, &dt); itt = icaltime_from_timet_with_zone (dtend, FALSE, e_cal_model_get_timezone (cal_view->priv->model)); if (all_day) { @@ -1479,20 +1479,20 @@ e_cal_view_new_appointment_for (ECalView *cal_view, itt.hour = itt.minute = itt.second = 0; itt.is_date = TRUE; } - cal_component_set_dtend (comp, &dt); + e_cal_component_set_dtend (comp, &dt); /* TRANSPARENCY */ - transparency = all_day ? CAL_COMPONENT_TRANSP_TRANSPARENT - : CAL_COMPONENT_TRANSP_OPAQUE; - cal_component_set_transparency (comp, transparency); + transparency = all_day ? E_CAL_COMPONENT_TRANSP_TRANSPARENT + : E_CAL_COMPONENT_TRANSP_OPAQUE; + e_cal_component_set_transparency (comp, transparency); /* CATEGORY */ - cal_component_set_categories (comp, priv->default_category); + e_cal_component_set_categories (comp, priv->default_category); /* edit the object */ - cal_component_commit_sequence (comp); + e_cal_component_commit_sequence (comp); - e_cal_view_edit_appointment (cal_view, + e_calendar_view_edit_appointment (cal_view, e_cal_model_get_default_client (priv->model), icalcomp, meeting); @@ -1500,7 +1500,7 @@ e_cal_view_new_appointment_for (ECalView *cal_view, } /** - * e_cal_view_new_appointment + * e_calendar_view_new_appointment * @cal_view: A calendar view. * * Opens an event editor dialog for a new appointment. The appointment's @@ -1508,18 +1508,18 @@ e_cal_view_new_appointment_for (ECalView *cal_view, * the calendar view. */ void -e_cal_view_new_appointment (ECalView *cal_view) +e_calendar_view_new_appointment (ECalendarView *cal_view) { time_t dtstart, dtend; - g_return_if_fail (E_IS_CAL_VIEW (cal_view)); + g_return_if_fail (E_IS_CALENDAR_VIEW (cal_view)); - e_cal_view_get_selected_time_range (cal_view, &dtstart, &dtend); - e_cal_view_new_appointment_for (cal_view, dtstart, dtend, FALSE, FALSE); + e_calendar_view_get_selected_time_range (cal_view, &dtstart, &dtend); + e_calendar_view_new_appointment_for (cal_view, dtstart, dtend, FALSE, FALSE); } /** - * e_cal_view_edit_appointment + * e_calendar_view_edit_appointment * @cal_view: A calendar view. * @client: Calendar client. * @icalcomp: The object to be edited. @@ -1529,18 +1529,18 @@ e_cal_view_new_appointment (ECalView *cal_view) * object. */ void -e_cal_view_edit_appointment (ECalView *cal_view, - CalClient *client, +e_calendar_view_edit_appointment (ECalendarView *cal_view, + ECal *client, icalcomponent *icalcomp, gboolean meeting) { - ECalViewPrivate *priv; + ECalendarViewPrivate *priv; CompEditor *ce; const char *uid; - CalComponent *comp; + ECalComponent *comp; - g_return_if_fail (E_IS_CAL_VIEW (cal_view)); - g_return_if_fail (IS_CAL_CLIENT (client)); + g_return_if_fail (E_IS_CALENDAR_VIEW (cal_view)); + g_return_if_fail (E_IS_CAL (client)); g_return_if_fail (icalcomp != NULL); priv = cal_view->priv; @@ -1554,8 +1554,8 @@ e_cal_view_edit_appointment (ECalView *cal_view, ee = event_editor_new (client); ce = COMP_EDITOR (ee); - comp = cal_component_new (); - cal_component_set_icalcomponent (comp, icalcomponent_new_clone (icalcomp)); + comp = e_cal_component_new (); + e_cal_component_set_icalcomponent (comp, icalcomponent_new_clone (icalcomp)); comp_editor_edit_comp (ce, comp); if (meeting) event_editor_show_meeting (ee); diff --git a/calendar/gui/e-cal-view.h b/calendar/gui/e-cal-view.h index 292871b709..a1b11023b3 100644 --- a/calendar/gui/e-cal-view.h +++ b/calendar/gui/e-cal-view.h @@ -20,10 +20,10 @@ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 * USA */ -#ifndef _E_CAL_VIEW_H_ -#define _E_CAL_VIEW_H_ +#ifndef _E_CALENDAR_VIEW_H_ +#define _E_CALENDAR_VIEW_H_ -#include <cal-client/cal-client.h> +#include <libecal/e-cal.h> #include <gtk/gtktable.h> #include "e-cal-model.h" #include "gnome-cal.h" @@ -34,21 +34,21 @@ G_BEGIN_DECLS * EView - base widget class for the calendar views. */ -#define E_CAL_VIEW(obj) GTK_CHECK_CAST (obj, e_cal_view_get_type (), ECalView) -#define E_CAL_VIEW_CLASS(klass) GTK_CHECK_CLASS_CAST (klass, e_cal_view_get_type (), ECalViewClass) -#define E_IS_CAL_VIEW(obj) GTK_CHECK_TYPE (obj, e_cal_view_get_type ()) +#define E_CALENDAR_VIEW(obj) GTK_CHECK_CAST (obj, e_calendar_view_get_type (), ECalendarView) +#define E_CALENDAR_VIEW_CLASS(klass) GTK_CHECK_CLASS_CAST (klass, e_calendar_view_get_type (), ECalendarViewClass) +#define E_IS_CALENDAR_VIEW(obj) GTK_CHECK_TYPE (obj, e_calendar_view_get_type ()) typedef enum { - E_CAL_VIEW_POS_OUTSIDE, - E_CAL_VIEW_POS_NONE, - E_CAL_VIEW_POS_EVENT, - E_CAL_VIEW_POS_LEFT_EDGE, - E_CAL_VIEW_POS_RIGHT_EDGE, - E_CAL_VIEW_POS_TOP_EDGE, - E_CAL_VIEW_POS_BOTTOM_EDGE -} ECalViewPosition; - -#define E_CAL_VIEW_EVENT_FIELDS \ + E_CALENDAR_VIEW_POS_OUTSIDE, + E_CALENDAR_VIEW_POS_NONE, + E_CALENDAR_VIEW_POS_EVENT, + E_CALENDAR_VIEW_POS_LEFT_EDGE, + E_CALENDAR_VIEW_POS_RIGHT_EDGE, + E_CALENDAR_VIEW_POS_TOP_EDGE, + E_CALENDAR_VIEW_POS_BOTTOM_EDGE +} ECalendarViewPosition; + +#define E_CALENDAR_VIEW_EVENT_FIELDS \ GnomeCanvasItem *canvas_item; \ ECalModelComponent *comp_data; \ gboolean allocated_comp_data; \ @@ -59,76 +59,76 @@ typedef enum { guint different_timezone : 1; typedef struct { - E_CAL_VIEW_EVENT_FIELDS -} ECalViewEvent; + E_CALENDAR_VIEW_EVENT_FIELDS +} ECalendarViewEvent; -typedef struct _ECalView ECalView; -typedef struct _ECalViewClass ECalViewClass; -typedef struct _ECalViewPrivate ECalViewPrivate; +typedef struct _ECalendarView ECalendarView; +typedef struct _ECalendarViewClass ECalendarViewClass; +typedef struct _ECalendarViewPrivate ECalendarViewPrivate; -struct _ECalView { +struct _ECalendarView { GtkTable table; - ECalViewPrivate *priv; + ECalendarViewPrivate *priv; }; -struct _ECalViewClass { +struct _ECalendarViewClass { GtkTableClass parent_class; /* Notification signals */ - void (* selection_changed) (ECalView *cal_view); - void (* selected_time_changed) (ECalView *cal_view); - void (* timezone_changed) (ECalView *cal_view, icaltimezone *old_zone, icaltimezone *new_zone); - void (* event_changed) (ECalView *day_view, ECalViewEvent *event); - void (* event_added) (ECalView *day_view, ECalViewEvent *event); + void (* selection_changed) (ECalendarView *cal_view); + void (* selected_time_changed) (ECalendarView *cal_view); + void (* timezone_changed) (ECalendarView *cal_view, icaltimezone *old_zone, icaltimezone *new_zone); + void (* event_changed) (ECalendarView *day_view, ECalendarViewEvent *event); + void (* event_added) (ECalendarView *day_view, ECalendarViewEvent *event); /* Virtual methods */ - GList * (* get_selected_events) (ECalView *cal_view); /* a GList of ECalViewEvent's */ - void (* get_selected_time_range) (ECalView *cal_view, time_t *start_time, time_t *end_time); - void (* set_selected_time_range) (ECalView *cal_view, time_t start_time, time_t end_time); - gboolean (* get_visible_time_range) (ECalView *cal_view, time_t *start_time, time_t *end_time); - void (* update_query) (ECalView *cal_view); + GList * (* get_selected_events) (ECalendarView *cal_view); /* a GList of ECalendarViewEvent's */ + void (* get_selected_time_range) (ECalendarView *cal_view, time_t *start_time, time_t *end_time); + void (* set_selected_time_range) (ECalendarView *cal_view, time_t start_time, time_t end_time); + gboolean (* get_visible_time_range) (ECalendarView *cal_view, time_t *start_time, time_t *end_time); + void (* update_query) (ECalendarView *cal_view); }; -GType e_cal_view_get_type (void); - -GnomeCalendar *e_cal_view_get_calendar (ECalView *cal_view); -void e_cal_view_set_calendar (ECalView *cal_view, GnomeCalendar *calendar); -ECalModel *e_cal_view_get_model (ECalView *cal_view); -void e_cal_view_set_model (ECalView *cal_view, ECalModel *model); -icaltimezone *e_cal_view_get_timezone (ECalView *cal_view); -void e_cal_view_set_timezone (ECalView *cal_view, icaltimezone *zone); -const char *e_cal_view_get_default_category (ECalView *cal_view); -void e_cal_view_set_default_category (ECalView *cal_view, const char *category); -gboolean e_cal_view_get_use_24_hour_format (ECalView *view); -void e_cal_view_set_use_24_hour_format (ECalView *view, gboolean use_24_hour); - -void e_cal_view_set_status_message (ECalView *cal_view, const gchar *message); - -GList *e_cal_view_get_selected_events (ECalView *cal_view); -void e_cal_view_get_selected_time_range (ECalView *cal_view, time_t *start_time, time_t *end_time); -void e_cal_view_set_selected_time_range (ECalView *cal_view, time_t start_time, time_t end_time); -gboolean e_cal_view_get_visible_time_range (ECalView *cal_view, time_t *start_time, time_t *end_time); -void e_cal_view_update_query (ECalView *cal_view); - -void e_cal_view_cut_clipboard (ECalView *cal_view); -void e_cal_view_copy_clipboard (ECalView *cal_view); -void e_cal_view_paste_clipboard (ECalView *cal_view); -void e_cal_view_delete_selected_event (ECalView *cal_view); -void e_cal_view_delete_selected_events (ECalView *cal_view); -void e_cal_view_delete_selected_occurrence (ECalView *cal_view); - -GtkMenu *e_cal_view_create_popup_menu (ECalView *cal_view); - -void e_cal_view_add_event (ECalView *cal_view, CalClient *client, time_t dtstart, +GType e_calendar_view_get_type (void); + +GnomeCalendar *e_calendar_view_get_calendar (ECalendarView *cal_view); +void e_calendar_view_set_calendar (ECalendarView *cal_view, GnomeCalendar *calendar); +ECalModel *e_calendar_view_get_model (ECalendarView *cal_view); +void e_calendar_view_set_model (ECalendarView *cal_view, ECalModel *model); +icaltimezone *e_calendar_view_get_timezone (ECalendarView *cal_view); +void e_calendar_view_set_timezone (ECalendarView *cal_view, icaltimezone *zone); +const char *e_calendar_view_get_default_category (ECalendarView *cal_view); +void e_calendar_view_set_default_category (ECalendarView *cal_view, const char *category); +gboolean e_calendar_view_get_use_24_hour_format (ECalendarView *view); +void e_calendar_view_set_use_24_hour_format (ECalendarView *view, gboolean use_24_hour); + +void e_calendar_view_set_status_message (ECalendarView *cal_view, const gchar *message); + +GList *e_calendar_view_get_selected_events (ECalendarView *cal_view); +void e_calendar_view_get_selected_time_range (ECalendarView *cal_view, time_t *start_time, time_t *end_time); +void e_calendar_view_set_selected_time_range (ECalendarView *cal_view, time_t start_time, time_t end_time); +gboolean e_calendar_view_get_visible_time_range (ECalendarView *cal_view, time_t *start_time, time_t *end_time); +void e_calendar_view_update_query (ECalendarView *cal_view); + +void e_calendar_view_cut_clipboard (ECalendarView *cal_view); +void e_calendar_view_copy_clipboard (ECalendarView *cal_view); +void e_calendar_view_paste_clipboard (ECalendarView *cal_view); +void e_calendar_view_delete_selected_event (ECalendarView *cal_view); +void e_calendar_view_delete_selected_events (ECalendarView *cal_view); +void e_calendar_view_delete_selected_occurrence (ECalendarView *cal_view); + +GtkMenu *e_calendar_view_create_popup_menu (ECalendarView *cal_view); + +void e_calendar_view_add_event (ECalendarView *cal_view, ECal *client, time_t dtstart, icaltimezone *default_zone, icalcomponent *icalcomp, gboolean in_top_canvas); -void e_cal_view_new_appointment_for (ECalView *cal_view, +void e_calendar_view_new_appointment_for (ECalendarView *cal_view, time_t dtstart, time_t dtend, gboolean all_day, gboolean meeting); -void e_cal_view_new_appointment (ECalView *cal_view); -void e_cal_view_edit_appointment (ECalView *cal_view, - CalClient *client, +void e_calendar_view_new_appointment (ECalendarView *cal_view); +void e_calendar_view_edit_appointment (ECalendarView *cal_view, + ECal *client, icalcomponent *icalcomp, gboolean meeting); diff --git a/calendar/gui/e-calendar-table.c b/calendar/gui/e-calendar-table.c index fdea4d33bb..173887dab5 100644 --- a/calendar/gui/e-calendar-table.c +++ b/calendar/gui/e-calendar-table.c @@ -24,7 +24,7 @@ */ /* - * ECalendarTable - displays the CalComponent objects in a table (an ETable). + * ECalendarTable - displays the ECalComponent objects in a table (an ETable). * Used for calendar events and tasks. */ @@ -188,30 +188,30 @@ compare_priorities (int *a, int *b) * FIXME: Does this ever get called?? It doesn't seem to. * I specified that the table should be sorted by this column, but it still * never calls this function. - * Also, this assumes it is passed pointers to CalComponents, but I think it + * Also, this assumes it is passed pointers to ECalComponents, but I think it * may just be passed pointers to the 2 cell values. */ static gint task_compare_cb (gconstpointer a, gconstpointer b) { - CalComponent *ca, *cb; - CalComponentDateTime due_a, due_b; + ECalComponent *ca, *cb; + ECalComponentDateTime due_a, due_b; int *prio_a, *prio_b; int retval; - ca = CAL_COMPONENT (a); - cb = CAL_COMPONENT (b); + ca = E_CAL_COMPONENT (a); + cb = E_CAL_COMPONENT (b); - cal_component_get_due (ca, &due_a); - cal_component_get_due (cb, &due_b); - cal_component_get_priority (ca, &prio_a); - cal_component_get_priority (cb, &prio_b); + e_cal_component_get_due (ca, &due_a); + e_cal_component_get_due (cb, &due_b); + e_cal_component_get_priority (ca, &prio_a); + e_cal_component_get_priority (cb, &prio_b); if (due_a.value && due_b.value) { int v; /* FIXME: TIMEZONES. But currently we have no way to get the - CalClient, so we can't get the timezone. */ + ECal, so we can't get the timezone. */ v = icaltime_compare (*due_a.value, *due_b.value); if (v == 0) @@ -225,14 +225,14 @@ task_compare_cb (gconstpointer a, gconstpointer b) else retval = compare_priorities (prio_a, prio_b); - cal_component_free_datetime (&due_a); - cal_component_free_datetime (&due_b); + e_cal_component_free_datetime (&due_a); + e_cal_component_free_datetime (&due_b); if (prio_a) - cal_component_free_priority (prio_a); + e_cal_component_free_priority (prio_a); if (prio_b) - cal_component_free_priority (prio_b); + e_cal_component_free_priority (prio_b); return retval; } @@ -287,8 +287,8 @@ priority_compare_cb (gconstpointer a, gconstpointer b) { int priority1, priority2; - priority1 = cal_util_priority_from_string ((const char*) a); - priority2 = cal_util_priority_from_string ((const char*) b); + priority1 = e_cal_util_priority_from_string ((const char*) a); + priority2 = e_cal_util_priority_from_string ((const char*) b); /* We change undefined priorities so they appear after 'Low'. */ if (priority1 <= 0) @@ -727,9 +727,9 @@ delete_selected_components (ECalendarTable *cal_table) ECalModelComponent *comp_data = (ECalModelComponent *) l->data; GError *error = NULL; - cal_client_remove_object (comp_data->client, + e_cal_remove_object (comp_data->client, icalcomponent_get_uid (comp_data->icalcomp), &error); - delete_error_dialog (error, CAL_COMPONENT_TODO); + delete_error_dialog (error, E_CAL_COMPONENT_TODO); g_clear_error (&error); } @@ -750,7 +750,7 @@ e_calendar_table_delete_selected (ECalendarTable *cal_table) ETable *etable; int n_selected; ECalModelComponent *comp_data; - CalComponent *comp; + ECalComponent *comp; g_return_if_fail (cal_table != NULL); g_return_if_fail (E_IS_CALENDAR_TABLE (cal_table)); @@ -768,11 +768,11 @@ e_calendar_table_delete_selected (ECalendarTable *cal_table) /* FIXME: this may be something other than a TODO component */ - comp = cal_component_new (); + comp = e_cal_component_new (); if (comp_data) - cal_component_set_icalcomponent (comp, icalcomponent_new_clone (comp_data->icalcomp)); + e_cal_component_set_icalcomponent (comp, icalcomponent_new_clone (comp_data->icalcomp)); - if (delete_component_dialog (comp, FALSE, n_selected, CAL_COMPONENT_TODO, + if (delete_component_dialog (comp, FALSE, n_selected, E_CAL_COMPONENT_TODO, GTK_WIDGET (cal_table))) delete_selected_components (cal_table); @@ -813,7 +813,7 @@ copy_row_cb (int model_row, gpointer data) return; /* add timezones to the VCALENDAR component */ - cal_util_add_timezones_from_component (cal_table->tmp_vcal, comp_data->icalcomp); + e_cal_util_add_timezones_from_component (cal_table->tmp_vcal, comp_data->icalcomp); /* add the new component to the VCALENDAR component */ comp_str = icalcomponent_as_ical_string (comp_data->icalcomp); @@ -845,7 +845,7 @@ e_calendar_table_copy_clipboard (ECalendarTable *cal_table) } /* create temporary VCALENDAR object */ - cal_table->tmp_vcal = cal_util_new_top_level (); + cal_table->tmp_vcal = e_cal_util_new_top_level (); etable = e_table_scrolled_get_table (E_TABLE_SCROLLED (cal_table->etable)); e_table_selected_row_foreach (etable, copy_row_cb, cal_table); @@ -886,12 +886,12 @@ open_task (ECalendarTable *cal_table, ECalModelComponent *comp_data, gboolean as tedit = e_comp_editor_registry_find (comp_editor_registry, uid); if (tedit == NULL) { - CalComponent *comp; + ECalComponent *comp; tedit = COMP_EDITOR (task_editor_new (comp_data->client)); - comp = cal_component_new (); - cal_component_set_icalcomponent (comp, icalcomponent_new_clone (comp_data->icalcomp)); + comp = e_cal_component_new (); + e_cal_component_set_icalcomponent (comp, icalcomponent_new_clone (comp_data->icalcomp)); comp_editor_edit_comp (tedit, comp); if (assign) task_editor_show_assignment (TASK_EDITOR (tedit)); @@ -1074,11 +1074,11 @@ e_calendar_table_show_popup_menu (ETable *table, } else hide_mask = MASK_SINGLE; - cal_client_is_read_only (comp_data->client, &read_only, NULL); + e_cal_is_read_only (comp_data->client, &read_only, NULL); if (!read_only) disable_mask |= MASK_EDITABLE; - if (cal_client_get_static_capability (comp_data->client, CAL_STATIC_CAPABILITY_NO_TASK_ASSIGNMENT)) + if (e_cal_get_static_capability (comp_data->client, CAL_STATIC_CAPABILITY_NO_TASK_ASSIGNMENT)) disable_mask |= MASK_ASSIGNABLE; setup_popup_icons (tasks_popup_menu); @@ -1143,7 +1143,7 @@ e_calendar_table_on_save_as (GtkWidget *widget, gpointer data) if (filename == NULL) return; - ical_string = cal_client_get_component_as_string (comp_data->client, comp_data->icalcomp); + ical_string = e_cal_get_component_as_string (comp_data->client, comp_data->icalcomp); if (ical_string == NULL) { g_warning ("Couldn't convert item to a string"); return; @@ -1165,7 +1165,7 @@ e_calendar_table_on_print_task (GtkWidget *widget, gpointer data) { ECalendarTable *cal_table; ECalModelComponent *comp_data; - CalComponent *comp; + ECalComponent *comp; cal_table = E_CALENDAR_TABLE (data); @@ -1173,8 +1173,8 @@ e_calendar_table_on_print_task (GtkWidget *widget, gpointer data) if (comp_data == NULL) return; - comp = cal_component_new (); - cal_component_set_icalcomponent (comp, icalcomponent_new_clone (comp_data->icalcomp)); + comp = e_cal_component_new (); + e_cal_component_set_icalcomponent (comp, icalcomponent_new_clone (comp_data->icalcomp)); print_comp (comp, comp_data->client, FALSE); g_object_unref (comp); @@ -1230,11 +1230,11 @@ e_calendar_table_on_forward (GtkWidget *widget, gpointer data) comp_data = get_selected_comp (cal_table); if (comp_data) { - CalComponent *comp; + ECalComponent *comp; - comp = cal_component_new (); - cal_component_set_icalcomponent (comp, icalcomponent_new_clone (comp_data->icalcomp)); - itip_send_comp (CAL_COMPONENT_METHOD_PUBLISH, comp, comp_data->client, NULL); + comp = e_cal_component_new (); + e_cal_component_set_icalcomponent (comp, icalcomponent_new_clone (comp_data->icalcomp)); + itip_send_comp (E_CAL_COMPONENT_METHOD_PUBLISH, comp, comp_data->client, NULL); g_object_unref (comp); } @@ -1318,8 +1318,8 @@ selection_received (GtkWidget *invisible, char *comp_str; icalcomponent *icalcomp; char *uid; - CalComponent *comp; - CalClient *client; + ECalComponent *comp; + ECal *client; icalcomponent_kind kind; g_return_if_fail (E_IS_CALENDAR_TABLE (cal_table)); @@ -1360,18 +1360,18 @@ selection_received (GtkWidget *invisible, if (child_kind == ICAL_VEVENT_COMPONENT || child_kind == ICAL_VTODO_COMPONENT || child_kind == ICAL_VJOURNAL_COMPONENT) { - CalComponent *tmp_comp; + ECalComponent *tmp_comp; - uid = cal_component_gen_uid (); - tmp_comp = cal_component_new (); - cal_component_set_icalcomponent ( + uid = e_cal_component_gen_uid (); + tmp_comp = e_cal_component_new (); + e_cal_component_set_icalcomponent ( tmp_comp, icalcomponent_new_clone (subcomp)); - cal_component_set_uid (tmp_comp, uid); + e_cal_component_set_uid (tmp_comp, uid); free (uid); /* FIXME should we convert start/due/complete times? */ /* FIXME Error handling */ - cal_client_create_object (client, cal_component_get_icalcomponent (tmp_comp), NULL, NULL); + e_cal_create_object (client, e_cal_component_get_icalcomponent (tmp_comp), NULL, NULL); g_object_unref (tmp_comp); } @@ -1380,13 +1380,13 @@ selection_received (GtkWidget *invisible, } } else { - comp = cal_component_new (); - cal_component_set_icalcomponent (comp, icalcomp); - uid = cal_component_gen_uid (); - cal_component_set_uid (comp, (const char *) uid); + comp = e_cal_component_new (); + e_cal_component_set_icalcomponent (comp, icalcomp); + uid = e_cal_component_gen_uid (); + e_cal_component_set_uid (comp, (const char *) uid); free (uid); - cal_client_create_object (client, cal_component_get_icalcomponent (comp), NULL, NULL); + e_cal_create_object (client, e_cal_component_get_icalcomponent (comp), NULL, NULL); g_object_unref (comp); } diff --git a/calendar/gui/e-calendar-view.c b/calendar/gui/e-calendar-view.c index 2e392560cd..332019cf2c 100644 --- a/calendar/gui/e-calendar-view.c +++ b/calendar/gui/e-calendar-view.c @@ -29,8 +29,8 @@ #include <libgnome/gnome-i18n.h> #include <gal/util/e-util.h> #include "e-util/e-dialog-utils.h" -#include "cal-util/cal-util-marshal.h" -#include "cal-util/timeutil.h" +#include "e-calendar-marshal.h" +#include <libecal/e-cal-time-util.h> #include "evolution-activity-client.h" #include "calendar-commands.h" #include "calendar-config.h" @@ -53,7 +53,7 @@ #define EVOLUTION_CALENDAR_PROGRESS_IMAGE "evolution-calendar-mini.png" static GdkPixbuf *progress_icon[2] = { NULL, NULL }; -struct _ECalViewPrivate { +struct _ECalendarViewPrivate { /* The GnomeCalendar we are associated to */ GnomeCalendar *calendar; @@ -74,11 +74,11 @@ struct _ECalViewPrivate { char *default_category; }; -static void e_cal_view_class_init (ECalViewClass *klass); -static void e_cal_view_init (ECalView *cal_view, ECalViewClass *klass); -static void e_cal_view_get_property (GObject *object, guint property_id, GValue *value, GParamSpec *pspec); -static void e_cal_view_set_property (GObject *object, guint property_id, const GValue *value, GParamSpec *pspec); -static void e_cal_view_destroy (GtkObject *object); +static void e_calendar_view_class_init (ECalendarViewClass *klass); +static void e_calendar_view_init (ECalendarView *cal_view, ECalendarViewClass *klass); +static void e_calendar_view_get_property (GObject *object, guint property_id, GValue *value, GParamSpec *pspec); +static void e_calendar_view_set_property (GObject *object, guint property_id, const GValue *value, GParamSpec *pspec); +static void e_calendar_view_destroy (GtkObject *object); static GObjectClass *parent_class = NULL; static GdkAtom clipboard_atom = GDK_NONE; @@ -101,20 +101,20 @@ enum { LAST_SIGNAL }; -static guint e_cal_view_signals[LAST_SIGNAL] = { 0 }; +static guint e_calendar_view_signals[LAST_SIGNAL] = { 0 }; static void -e_cal_view_set_property (GObject *object, guint property_id, const GValue *value, GParamSpec *pspec) +e_calendar_view_set_property (GObject *object, guint property_id, const GValue *value, GParamSpec *pspec) { - ECalView *cal_view; - ECalViewPrivate *priv; + ECalendarView *cal_view; + ECalendarViewPrivate *priv; - cal_view = E_CAL_VIEW (object); + cal_view = E_CALENDAR_VIEW (object); priv = cal_view->priv; switch (property_id) { case PROP_MODEL: - e_cal_view_set_model (cal_view, E_CAL_MODEL (g_value_get_object (value))); + e_calendar_view_set_model (cal_view, E_CAL_MODEL (g_value_get_object (value))); break; default: G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec); @@ -123,17 +123,17 @@ e_cal_view_set_property (GObject *object, guint property_id, const GValue *value } static void -e_cal_view_get_property (GObject *object, guint property_id, GValue *value, GParamSpec *pspec) +e_calendar_view_get_property (GObject *object, guint property_id, GValue *value, GParamSpec *pspec) { - ECalView *cal_view; - ECalViewPrivate *priv; + ECalendarView *cal_view; + ECalendarViewPrivate *priv; - cal_view = E_CAL_VIEW (object); + cal_view = E_CALENDAR_VIEW (object); priv = cal_view->priv; switch (property_id) { case PROP_MODEL: - g_value_set_object (value, e_cal_view_get_model (cal_view)); + g_value_set_object (value, e_calendar_view_get_model (cal_view)); break; default: G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec); @@ -142,7 +142,7 @@ e_cal_view_get_property (GObject *object, guint property_id, GValue *value, GPar } static void -e_cal_view_class_init (ECalViewClass *klass) +e_calendar_view_class_init (ECalendarViewClass *klass) { GObjectClass *gobject_class = G_OBJECT_CLASS (klass); GtkObjectClass *object_class = GTK_OBJECT_CLASS (klass); @@ -150,9 +150,9 @@ e_cal_view_class_init (ECalViewClass *klass) parent_class = g_type_class_peek_parent (klass); /* Method override */ - gobject_class->set_property = e_cal_view_set_property; - gobject_class->get_property = e_cal_view_get_property; - object_class->destroy = e_cal_view_destroy; + gobject_class->set_property = e_calendar_view_set_property; + gobject_class->get_property = e_calendar_view_get_property; + object_class->destroy = e_calendar_view_destroy; klass->selection_changed = NULL; klass->selected_time_changed = NULL; @@ -171,46 +171,46 @@ e_cal_view_class_init (ECalViewClass *klass) | G_PARAM_CONSTRUCT)); /* Create class' signals */ - e_cal_view_signals[SELECTION_CHANGED] = + e_calendar_view_signals[SELECTION_CHANGED] = g_signal_new ("selection_changed", G_TYPE_FROM_CLASS (klass), G_SIGNAL_RUN_LAST, - G_STRUCT_OFFSET (ECalViewClass, selection_changed), + G_STRUCT_OFFSET (ECalendarViewClass, selection_changed), NULL, NULL, g_cclosure_marshal_VOID__VOID, G_TYPE_NONE, 0); - e_cal_view_signals[SELECTED_TIME_CHANGED] = + e_calendar_view_signals[SELECTED_TIME_CHANGED] = g_signal_new ("selected_time_changed", G_TYPE_FROM_CLASS (klass), G_SIGNAL_RUN_LAST, - G_STRUCT_OFFSET (ECalViewClass, selected_time_changed), + G_STRUCT_OFFSET (ECalendarViewClass, selected_time_changed), NULL, NULL, g_cclosure_marshal_VOID__VOID, G_TYPE_NONE, 0); - e_cal_view_signals[TIMEZONE_CHANGED] = + e_calendar_view_signals[TIMEZONE_CHANGED] = g_signal_new ("timezone_changed", G_TYPE_FROM_CLASS (klass), G_SIGNAL_RUN_LAST, - G_STRUCT_OFFSET (ECalViewClass, timezone_changed), + G_STRUCT_OFFSET (ECalendarViewClass, timezone_changed), NULL, NULL, - cal_util_marshal_VOID__POINTER_POINTER, + e_calendar_marshal_VOID__POINTER_POINTER, G_TYPE_NONE, 2, G_TYPE_POINTER, G_TYPE_POINTER); - e_cal_view_signals[EVENT_CHANGED] = + e_calendar_view_signals[EVENT_CHANGED] = g_signal_new ("event_changed", G_TYPE_FROM_CLASS (object_class), G_SIGNAL_RUN_FIRST | G_SIGNAL_ACTION, - G_STRUCT_OFFSET (ECalViewClass, event_changed), + G_STRUCT_OFFSET (ECalendarViewClass, event_changed), NULL, NULL, g_cclosure_marshal_VOID__POINTER, G_TYPE_NONE, 1, G_TYPE_POINTER); - e_cal_view_signals[EVENT_ADDED] = + e_calendar_view_signals[EVENT_ADDED] = g_signal_new ("event_added", G_TYPE_FROM_CLASS (object_class), G_SIGNAL_RUN_FIRST | G_SIGNAL_ACTION, - G_STRUCT_OFFSET (ECalViewClass, event_added), + G_STRUCT_OFFSET (ECalendarViewClass, event_added), NULL, NULL, g_cclosure_marshal_VOID__POINTER, G_TYPE_NONE, 1, @@ -227,33 +227,33 @@ e_cal_view_class_init (ECalViewClass *klass) static void model_changed_cb (ETableModel *etm, gpointer user_data) { - ECalView *cal_view = E_CAL_VIEW (user_data); + ECalendarView *cal_view = E_CALENDAR_VIEW (user_data); - e_cal_view_update_query (cal_view); + e_calendar_view_update_query (cal_view); } static void model_row_changed_cb (ETableModel *etm, int row, gpointer user_data) { - ECalView *cal_view = E_CAL_VIEW (user_data); + ECalendarView *cal_view = E_CALENDAR_VIEW (user_data); - e_cal_view_update_query (cal_view); + e_calendar_view_update_query (cal_view); } static void model_cell_changed_cb (ETableModel *etm, int col, int row, gpointer user_data) { - ECalView *cal_view = E_CAL_VIEW (user_data); + ECalendarView *cal_view = E_CALENDAR_VIEW (user_data); - e_cal_view_update_query (cal_view); + e_calendar_view_update_query (cal_view); } static void model_rows_changed_cb (ETableModel *etm, int row, int count, gpointer user_data) { - ECalView *cal_view = E_CAL_VIEW (user_data); + ECalendarView *cal_view = E_CALENDAR_VIEW (user_data); - e_cal_view_update_query (cal_view); + e_calendar_view_update_query (cal_view); } static void @@ -261,7 +261,7 @@ selection_get (GtkWidget *invisible, GtkSelectionData *selection_data, guint info, guint time_stamp, - ECalView *cal_view) + ECalendarView *cal_view) { if (cal_view->priv->clipboard_selection != NULL) { gtk_selection_data_set (selection_data, @@ -275,7 +275,7 @@ selection_get (GtkWidget *invisible, static void selection_clear_event (GtkWidget *invisible, GdkEventSelection *event, - ECalView *cal_view) + ECalendarView *cal_view) { if (cal_view->priv->clipboard_selection != NULL) { g_free (cal_view->priv->clipboard_selection); @@ -284,10 +284,10 @@ selection_clear_event (GtkWidget *invisible, } void -e_cal_view_add_event (ECalView *cal_view, CalClient *client, time_t dtstart, +e_calendar_view_add_event (ECalendarView *cal_view, ECal *client, time_t dtstart, icaltimezone *default_zone, icalcomponent *icalcomp, gboolean in_top_canvas) { - CalComponent *comp; + ECalComponent *comp; struct icaltimetype itime, old_dtstart, old_dtend; time_t tt_start, tt_end, new_dtstart; struct icaldurationtype ic_dur; @@ -331,18 +331,18 @@ e_cal_view_add_event (ECalView *cal_view, CalClient *client, time_t dtstart, icalcomponent_set_dtend (icalcomp, itime); /* FIXME The new uid stuff can go away once we actually set it in the backend */ - uid = cal_component_gen_uid (); - comp = cal_component_new (); - cal_component_set_icalcomponent ( + uid = e_cal_component_gen_uid (); + comp = e_cal_component_new (); + e_cal_component_set_icalcomponent ( comp, icalcomponent_new_clone (icalcomp)); - cal_component_set_uid (comp, uid); + e_cal_component_set_uid (comp, uid); /* FIXME Error handling */ - if (cal_client_create_object (client, cal_component_get_icalcomponent (comp), NULL, NULL)) { + if (e_cal_create_object (client, e_cal_component_get_icalcomponent (comp), NULL, NULL)) { if (itip_organizer_is_user (comp, client) && send_component_dialog ((GtkWindow *) gtk_widget_get_toplevel (GTK_WIDGET (cal_view)), client, comp, TRUE)) { - itip_send_comp (CAL_COMPONENT_METHOD_REQUEST, comp, + itip_send_comp (E_CAL_COMPONENT_METHOD_REQUEST, comp, client, NULL); } } else { @@ -357,16 +357,16 @@ static void selection_received (GtkWidget *invisible, GtkSelectionData *selection_data, guint time, - ECalView *cal_view) + ECalendarView *cal_view) { char *comp_str, *default_tzid; icalcomponent *icalcomp; icalcomponent_kind kind; time_t selected_time_start, selected_time_end; icaltimezone *default_zone; - CalClient *client; + ECal *client; - g_return_if_fail (E_IS_CAL_VIEW (cal_view)); + g_return_if_fail (E_IS_CALENDAR_VIEW (cal_view)); if (selection_data->length < 0 || selection_data->type != GDK_SELECTION_TYPE_STRING) { @@ -382,7 +382,7 @@ selection_received (GtkWidget *invisible, client = e_cal_model_get_default_client (cal_view->priv->model); /* FIXME Error checking */ - cal_client_get_timezone (client, default_tzid, &default_zone, NULL); + e_cal_get_timezone (client, default_tzid, &default_zone, NULL); /* check the type of the component */ /* FIXME An error dialog if we return? */ @@ -390,8 +390,8 @@ selection_received (GtkWidget *invisible, if (kind != ICAL_VCALENDAR_COMPONENT && kind != ICAL_VEVENT_COMPONENT) return; - e_cal_view_set_status_message (cal_view, _("Updating objects")); - e_cal_view_get_selected_time_range (cal_view, &selected_time_start, &selected_time_end); + e_calendar_view_set_status_message (cal_view, _("Updating objects")); + e_calendar_view_get_selected_time_range (cal_view, &selected_time_start, &selected_time_end); /* FIXME Timezone handling */ if (kind == ICAL_VCALENDAR_COMPONENT) { @@ -402,14 +402,14 @@ selection_received (GtkWidget *invisible, while (subcomp) { child_kind = icalcomponent_isa (subcomp); if (child_kind == ICAL_VEVENT_COMPONENT) - e_cal_view_add_event (cal_view, client, selected_time_start, + e_calendar_view_add_event (cal_view, client, selected_time_start, default_zone, subcomp, FALSE); else if (child_kind == ICAL_VTIMEZONE_COMPONENT) { icaltimezone *zone; zone = icaltimezone_new (); icaltimezone_set_component (zone, subcomp); - cal_client_add_timezone (client, zone, NULL); + e_cal_add_timezone (client, zone, NULL); icaltimezone_free (zone, 1); } @@ -421,16 +421,16 @@ selection_received (GtkWidget *invisible, icalcomponent_free (icalcomp); } else { - e_cal_view_add_event (cal_view, client, selected_time_start, default_zone, icalcomp, FALSE); + e_calendar_view_add_event (cal_view, client, selected_time_start, default_zone, icalcomp, FALSE); } - e_cal_view_set_status_message (cal_view, NULL); + e_calendar_view_set_status_message (cal_view, NULL); } static void -e_cal_view_init (ECalView *cal_view, ECalViewClass *klass) +e_calendar_view_init (ECalendarView *cal_view, ECalendarViewClass *klass) { - cal_view->priv = g_new0 (ECalViewPrivate, 1); + cal_view->priv = g_new0 (ECalendarViewPrivate, 1); cal_view->priv->model = (ECalModel *) e_cal_model_calendar_new (); g_signal_connect (G_OBJECT (cal_view->priv->model), "model_changed", @@ -461,11 +461,11 @@ e_cal_view_init (ECalView *cal_view, ECalViewClass *klass) } static void -e_cal_view_destroy (GtkObject *object) +e_calendar_view_destroy (GtkObject *object) { - ECalView *cal_view = (ECalView *) object; + ECalendarView *cal_view = (ECalendarView *) object; - g_return_if_fail (E_IS_CAL_VIEW (cal_view)); + g_return_if_fail (E_IS_CALENDAR_VIEW (cal_view)); if (cal_view->priv) { if (cal_view->priv->model) { @@ -504,37 +504,37 @@ e_cal_view_destroy (GtkObject *object) GTK_OBJECT_CLASS (parent_class)->destroy (object); } -E_MAKE_TYPE (e_cal_view, "ECalView", ECalView, e_cal_view_class_init, - e_cal_view_init, GTK_TYPE_TABLE); +E_MAKE_TYPE (e_calendar_view, "ECalendarView", ECalendarView, e_calendar_view_class_init, + e_calendar_view_init, GTK_TYPE_TABLE); GnomeCalendar * -e_cal_view_get_calendar (ECalView *cal_view) +e_calendar_view_get_calendar (ECalendarView *cal_view) { - g_return_val_if_fail (E_IS_CAL_VIEW (cal_view), NULL); + g_return_val_if_fail (E_IS_CALENDAR_VIEW (cal_view), NULL); return cal_view->priv->calendar; } void -e_cal_view_set_calendar (ECalView *cal_view, GnomeCalendar *calendar) +e_calendar_view_set_calendar (ECalendarView *cal_view, GnomeCalendar *calendar) { - g_return_if_fail (E_IS_CAL_VIEW (cal_view)); + g_return_if_fail (E_IS_CALENDAR_VIEW (cal_view)); cal_view->priv->calendar = calendar; } ECalModel * -e_cal_view_get_model (ECalView *cal_view) +e_calendar_view_get_model (ECalendarView *cal_view) { - g_return_val_if_fail (E_IS_CAL_VIEW (cal_view), NULL); + g_return_val_if_fail (E_IS_CALENDAR_VIEW (cal_view), NULL); return cal_view->priv->model; } void -e_cal_view_set_model (ECalView *cal_view, ECalModel *model) +e_calendar_view_set_model (ECalendarView *cal_view, ECalModel *model) { - g_return_if_fail (E_IS_CAL_VIEW (cal_view)); + g_return_if_fail (E_IS_CALENDAR_VIEW (cal_view)); g_return_if_fail (E_IS_CAL_MODEL (model)); if (cal_view->priv->model) { @@ -551,41 +551,41 @@ e_cal_view_set_model (ECalView *cal_view, ECalModel *model) g_signal_connect (G_OBJECT (cal_view->priv->model), "model_rows_inserted", G_CALLBACK (model_rows_changed_cb), cal_view); g_signal_connect (G_OBJECT (cal_view->priv->model), "model_rows_deleted", G_CALLBACK (model_rows_changed_cb), cal_view); - e_cal_view_update_query (cal_view); + e_calendar_view_update_query (cal_view); } icaltimezone * -e_cal_view_get_timezone (ECalView *cal_view) +e_calendar_view_get_timezone (ECalendarView *cal_view) { - g_return_val_if_fail (E_IS_CAL_VIEW (cal_view), NULL); + g_return_val_if_fail (E_IS_CALENDAR_VIEW (cal_view), NULL); return e_cal_model_get_timezone (cal_view->priv->model); } void -e_cal_view_set_timezone (ECalView *cal_view, icaltimezone *zone) +e_calendar_view_set_timezone (ECalendarView *cal_view, icaltimezone *zone) { icaltimezone *old_zone; - g_return_if_fail (E_IS_CAL_VIEW (cal_view)); + g_return_if_fail (E_IS_CALENDAR_VIEW (cal_view)); old_zone = e_cal_model_get_timezone (cal_view->priv->model); if (old_zone == zone) return; e_cal_model_set_timezone (cal_view->priv->model, zone); - g_signal_emit (G_OBJECT (cal_view), e_cal_view_signals[TIMEZONE_CHANGED], 0, + g_signal_emit (G_OBJECT (cal_view), e_calendar_view_signals[TIMEZONE_CHANGED], 0, old_zone, zone); } const char * -e_cal_view_get_default_category (ECalView *cal_view) +e_calendar_view_get_default_category (ECalendarView *cal_view) { - g_return_val_if_fail (E_IS_CAL_VIEW (cal_view), NULL); + g_return_val_if_fail (E_IS_CALENDAR_VIEW (cal_view), NULL); return (const char *) cal_view->priv->default_category; } /** - * e_cal_view_set_default_category + * e_calendar_view_set_default_category * @cal_view: A calendar view. * @category: Default category name or NULL for no category. * @@ -593,9 +593,9 @@ e_cal_view_get_default_category (ECalView *cal_view) * components from the given calendar view. */ void -e_cal_view_set_default_category (ECalView *cal_view, const char *category) +e_calendar_view_set_default_category (ECalendarView *cal_view, const char *category) { - g_return_if_fail (E_IS_CAL_VIEW (cal_view)); + g_return_if_fail (E_IS_CALENDAR_VIEW (cal_view)); if (cal_view->priv->default_category) g_free (cal_view->priv->default_category); @@ -604,7 +604,7 @@ e_cal_view_set_default_category (ECalView *cal_view, const char *category) } /** - * e_cal_view_get_use_24_hour_format: + * e_calendar_view_get_use_24_hour_format: * @cal_view: A calendar view. * * Gets whether the view is using 24 hour times or not. @@ -612,32 +612,32 @@ e_cal_view_set_default_category (ECalView *cal_view, const char *category) * Returns: the 24 hour setting. */ gboolean -e_cal_view_get_use_24_hour_format (ECalView *cal_view) +e_calendar_view_get_use_24_hour_format (ECalendarView *cal_view) { - g_return_val_if_fail (E_IS_CAL_VIEW (cal_view), FALSE); + g_return_val_if_fail (E_IS_CALENDAR_VIEW (cal_view), FALSE); return e_cal_model_get_use_24_hour_format (cal_view->priv->model); } /** - * e_cal_view_set_use_24_hour_format + * e_calendar_view_set_use_24_hour_format * @cal_view: A calendar view. * @use_24_hour: Whether to use 24 hour times or not. * * Sets the 12/24 hour times setting for the given view. */ void -e_cal_view_set_use_24_hour_format (ECalView *cal_view, gboolean use_24_hour) +e_calendar_view_set_use_24_hour_format (ECalendarView *cal_view, gboolean use_24_hour) { - g_return_if_fail (E_IS_CAL_VIEW (cal_view)); + g_return_if_fail (E_IS_CALENDAR_VIEW (cal_view)); e_cal_model_set_use_24_hour_format (cal_view->priv->model, use_24_hour); } void -e_cal_view_set_status_message (ECalView *cal_view, const gchar *message) +e_calendar_view_set_status_message (ECalendarView *cal_view, const gchar *message) { - g_return_if_fail (E_IS_CAL_VIEW (cal_view)); + g_return_if_fail (E_IS_CALENDAR_VIEW (cal_view)); if (!message || !*message) { if (cal_view->priv->activity) { @@ -665,45 +665,45 @@ e_cal_view_set_status_message (ECalView *cal_view, const gchar *message) } GList * -e_cal_view_get_selected_events (ECalView *cal_view) +e_calendar_view_get_selected_events (ECalendarView *cal_view) { - g_return_val_if_fail (E_IS_CAL_VIEW (cal_view), NULL); + g_return_val_if_fail (E_IS_CALENDAR_VIEW (cal_view), NULL); - if (E_CAL_VIEW_CLASS (G_OBJECT_GET_CLASS (cal_view))->get_selected_events) - return E_CAL_VIEW_CLASS (G_OBJECT_GET_CLASS (cal_view))->get_selected_events (cal_view); + if (E_CALENDAR_VIEW_CLASS (G_OBJECT_GET_CLASS (cal_view))->get_selected_events) + return E_CALENDAR_VIEW_CLASS (G_OBJECT_GET_CLASS (cal_view))->get_selected_events (cal_view); return NULL; } void -e_cal_view_get_selected_time_range (ECalView *cal_view, time_t *start_time, time_t *end_time) +e_calendar_view_get_selected_time_range (ECalendarView *cal_view, time_t *start_time, time_t *end_time) { - g_return_if_fail (E_IS_CAL_VIEW (cal_view)); + g_return_if_fail (E_IS_CALENDAR_VIEW (cal_view)); - if (E_CAL_VIEW_CLASS (G_OBJECT_GET_CLASS (cal_view))->get_selected_time_range) { - E_CAL_VIEW_CLASS (G_OBJECT_GET_CLASS (cal_view))->get_selected_time_range ( + if (E_CALENDAR_VIEW_CLASS (G_OBJECT_GET_CLASS (cal_view))->get_selected_time_range) { + E_CALENDAR_VIEW_CLASS (G_OBJECT_GET_CLASS (cal_view))->get_selected_time_range ( cal_view, start_time, end_time); } } void -e_cal_view_set_selected_time_range (ECalView *cal_view, time_t start_time, time_t end_time) +e_calendar_view_set_selected_time_range (ECalendarView *cal_view, time_t start_time, time_t end_time) { - g_return_if_fail (E_IS_CAL_VIEW (cal_view)); + g_return_if_fail (E_IS_CALENDAR_VIEW (cal_view)); - if (E_CAL_VIEW_CLASS (G_OBJECT_GET_CLASS (cal_view))->set_selected_time_range) { - E_CAL_VIEW_CLASS (G_OBJECT_GET_CLASS (cal_view))->set_selected_time_range ( + if (E_CALENDAR_VIEW_CLASS (G_OBJECT_GET_CLASS (cal_view))->set_selected_time_range) { + E_CALENDAR_VIEW_CLASS (G_OBJECT_GET_CLASS (cal_view))->set_selected_time_range ( cal_view, start_time, end_time); } } gboolean -e_cal_view_get_visible_time_range (ECalView *cal_view, time_t *start_time, time_t *end_time) +e_calendar_view_get_visible_time_range (ECalendarView *cal_view, time_t *start_time, time_t *end_time) { - g_return_val_if_fail (E_IS_CAL_VIEW (cal_view), FALSE); + g_return_val_if_fail (E_IS_CALENDAR_VIEW (cal_view), FALSE); - if (E_CAL_VIEW_CLASS (G_OBJECT_GET_CLASS (cal_view))->get_visible_time_range) { - return E_CAL_VIEW_CLASS (G_OBJECT_GET_CLASS (cal_view))->get_visible_time_range ( + if (E_CALENDAR_VIEW_CLASS (G_OBJECT_GET_CLASS (cal_view))->get_visible_time_range) { + return E_CALENDAR_VIEW_CLASS (G_OBJECT_GET_CLASS (cal_view))->get_visible_time_range ( cal_view, start_time, end_time); } @@ -711,91 +711,91 @@ e_cal_view_get_visible_time_range (ECalView *cal_view, time_t *start_time, time_ } void -e_cal_view_update_query (ECalView *cal_view) +e_calendar_view_update_query (ECalendarView *cal_view) { - g_return_if_fail (E_IS_CAL_VIEW (cal_view)); + g_return_if_fail (E_IS_CALENDAR_VIEW (cal_view)); - e_cal_view_set_status_message (cal_view, _("Searching")); + e_calendar_view_set_status_message (cal_view, _("Searching")); - if (E_CAL_VIEW_CLASS (G_OBJECT_GET_CLASS (cal_view))->update_query) { - E_CAL_VIEW_CLASS (G_OBJECT_GET_CLASS (cal_view))->update_query (cal_view); + if (E_CALENDAR_VIEW_CLASS (G_OBJECT_GET_CLASS (cal_view))->update_query) { + E_CALENDAR_VIEW_CLASS (G_OBJECT_GET_CLASS (cal_view))->update_query (cal_view); } - e_cal_view_set_status_message (cal_view, NULL); + e_calendar_view_set_status_message (cal_view, NULL); } void -e_cal_view_cut_clipboard (ECalView *cal_view) +e_calendar_view_cut_clipboard (ECalendarView *cal_view) { GList *selected, *l; const char *uid; - g_return_if_fail (E_IS_CAL_VIEW (cal_view)); + g_return_if_fail (E_IS_CALENDAR_VIEW (cal_view)); - selected = e_cal_view_get_selected_events (cal_view); + selected = e_calendar_view_get_selected_events (cal_view); if (!selected) return; - e_cal_view_set_status_message (cal_view, _("Deleting selected objects")); + e_calendar_view_set_status_message (cal_view, _("Deleting selected objects")); - e_cal_view_copy_clipboard (cal_view); + e_calendar_view_copy_clipboard (cal_view); for (l = selected; l != NULL; l = l->next) { - CalComponent *comp; - ECalViewEvent *event = (ECalViewEvent *) l->data; + ECalComponent *comp; + ECalendarViewEvent *event = (ECalendarViewEvent *) l->data; GError *error = NULL; if (!event) continue; - comp = cal_component_new (); - cal_component_set_icalcomponent (comp, icalcomponent_new_clone (event->comp_data->icalcomp)); + comp = e_cal_component_new (); + e_cal_component_set_icalcomponent (comp, icalcomponent_new_clone (event->comp_data->icalcomp)); if (itip_organizer_is_user (comp, event->comp_data->client) && cancel_component_dialog ((GtkWindow *) gtk_widget_get_toplevel (GTK_WIDGET (cal_view)), event->comp_data->client, comp, TRUE)) - itip_send_comp (CAL_COMPONENT_METHOD_CANCEL, comp, + itip_send_comp (E_CAL_COMPONENT_METHOD_CANCEL, comp, event->comp_data->client, NULL); - cal_component_get_uid (comp, &uid); - cal_client_remove_object (event->comp_data->client, uid, &error); - delete_error_dialog (error, CAL_COMPONENT_EVENT); + e_cal_component_get_uid (comp, &uid); + e_cal_remove_object (event->comp_data->client, uid, &error); + delete_error_dialog (error, E_CAL_COMPONENT_EVENT); g_clear_error (&error); g_object_unref (comp); } - e_cal_view_set_status_message (cal_view, NULL); + e_calendar_view_set_status_message (cal_view, NULL); g_list_free (selected); } void -e_cal_view_copy_clipboard (ECalView *cal_view) +e_calendar_view_copy_clipboard (ECalendarView *cal_view) { GList *selected, *l; gchar *comp_str; icalcomponent *vcal_comp; icalcomponent *new_icalcomp; - ECalViewEvent *event; + ECalendarViewEvent *event; - g_return_if_fail (E_IS_CAL_VIEW (cal_view)); + g_return_if_fail (E_IS_CALENDAR_VIEW (cal_view)); - selected = e_cal_view_get_selected_events (cal_view); + selected = e_calendar_view_get_selected_events (cal_view); if (!selected) return; /* create top-level VCALENDAR component and add VTIMEZONE's */ - vcal_comp = cal_util_new_top_level (); + vcal_comp = e_cal_util_new_top_level (); for (l = selected; l != NULL; l = l->next) { - event = (ECalViewEvent *) l->data; + event = (ECalendarViewEvent *) l->data; if (event) - cal_util_add_timezones_from_component (vcal_comp, event->comp_data->icalcomp); + e_cal_util_add_timezones_from_component (vcal_comp, event->comp_data->icalcomp); } for (l = selected; l != NULL; l = l->next) { - event = (ECalViewEvent *) l->data; + event = (ECalendarViewEvent *) l->data; new_icalcomp = icalcomponent_new_clone (event->comp_data->icalcomp); icalcomponent_add_component (vcal_comp, new_icalcomp); @@ -814,9 +814,9 @@ e_cal_view_copy_clipboard (ECalView *cal_view) } void -e_cal_view_paste_clipboard (ECalView *cal_view) +e_calendar_view_paste_clipboard (ECalendarView *cal_view) { - g_return_if_fail (E_IS_CAL_VIEW (cal_view)); + g_return_if_fail (E_IS_CALENDAR_VIEW (cal_view)); gtk_selection_convert (cal_view->priv->invisible, clipboard_atom, @@ -825,14 +825,14 @@ e_cal_view_paste_clipboard (ECalView *cal_view) } static void -delete_event (ECalView *cal_view, ECalViewEvent *event) +delete_event (ECalendarView *cal_view, ECalendarViewEvent *event) { - CalComponent *comp; - CalComponentVType vtype; + ECalComponent *comp; + ECalComponentVType vtype; - comp = cal_component_new (); - cal_component_set_icalcomponent (comp, icalcomponent_new_clone (event->comp_data->icalcomp)); - vtype = cal_component_get_vtype (comp); + comp = e_cal_component_new (); + e_cal_component_set_icalcomponent (comp, icalcomponent_new_clone (event->comp_data->icalcomp)); + vtype = e_cal_component_get_vtype (comp); if (delete_component_dialog (comp, FALSE, 1, vtype, GTK_WIDGET (cal_view))) { const char *uid; @@ -842,17 +842,17 @@ delete_event (ECalView *cal_view, ECalViewEvent *event) && cancel_component_dialog ((GtkWindow *) gtk_widget_get_toplevel (GTK_WIDGET (cal_view)), event->comp_data->client, comp, TRUE)) - itip_send_comp (CAL_COMPONENT_METHOD_CANCEL, comp, + itip_send_comp (E_CAL_COMPONENT_METHOD_CANCEL, comp, event->comp_data->client, NULL); - cal_component_get_uid (comp, &uid); + e_cal_component_get_uid (comp, &uid); if (!uid || !*uid) { g_object_unref (comp); return; } - cal_client_remove_object (event->comp_data->client, uid, &error); - delete_error_dialog (error, CAL_COMPONENT_EVENT); + e_cal_remove_object (event->comp_data->client, uid, &error); + delete_error_dialog (error, E_CAL_COMPONENT_EVENT); g_clear_error (&error); } @@ -860,16 +860,16 @@ delete_event (ECalView *cal_view, ECalViewEvent *event) } void -e_cal_view_delete_selected_event (ECalView *cal_view) +e_calendar_view_delete_selected_event (ECalendarView *cal_view) { GList *selected; - ECalViewEvent *event; + ECalendarViewEvent *event; - selected = e_cal_view_get_selected_events (cal_view); + selected = e_calendar_view_get_selected_events (cal_view); if (!selected) return; - event = (ECalViewEvent *) selected->data; + event = (ECalendarViewEvent *) selected->data; if (event) delete_event (cal_view, event); @@ -877,17 +877,17 @@ e_cal_view_delete_selected_event (ECalView *cal_view) } void -e_cal_view_delete_selected_events (ECalView *cal_view) +e_calendar_view_delete_selected_events (ECalendarView *cal_view) { GList *selected, *l; - ECalViewEvent *event; + ECalendarViewEvent *event; - selected = e_cal_view_get_selected_events (cal_view); + selected = e_calendar_view_get_selected_events (cal_view); if (!selected) return; for (l = selected; l != NULL; l = l->next) { - event = (ECalViewEvent *) l->data; + event = (ECalendarViewEvent *) l->data; if (event) delete_event (cal_view, event); } @@ -896,24 +896,24 @@ e_cal_view_delete_selected_events (ECalView *cal_view) } void -e_cal_view_delete_selected_occurrence (ECalView *cal_view) +e_calendar_view_delete_selected_occurrence (ECalendarView *cal_view) { - ECalViewEvent *event; + ECalendarViewEvent *event; GList *selected; const char *uid; GError *error = NULL; - selected = e_cal_view_get_selected_events (cal_view); + selected = e_calendar_view_get_selected_events (cal_view); if (!selected) return; - event = (ECalViewEvent *) selected->data; + event = (ECalendarViewEvent *) selected->data; uid = icalcomponent_get_uid (event->comp_data->icalcomp); /* FIXME: use 'rid' argument */ - cal_client_remove_object_with_mod (event->comp_data->client, uid, NULL, CALOBJ_MOD_THIS, &error); + e_cal_remove_object_with_mod (event->comp_data->client, uid, NULL, CALOBJ_MOD_THIS, &error); - delete_error_dialog (error, CAL_COMPONENT_EVENT); + delete_error_dialog (error, E_CAL_COMPONENT_EVENT); g_clear_error (&error); /* free memory */ @@ -923,42 +923,42 @@ e_cal_view_delete_selected_occurrence (ECalView *cal_view) static void on_new_appointment (GtkWidget *widget, gpointer user_data) { - ECalView *cal_view = (ECalView *) user_data; + ECalendarView *cal_view = (ECalendarView *) user_data; - e_cal_view_new_appointment (cal_view); + e_calendar_view_new_appointment (cal_view); } static void on_new_event (GtkWidget *widget, gpointer user_data) { time_t dtstart, dtend; - ECalView *cal_view = (ECalView *) user_data; + ECalendarView *cal_view = (ECalendarView *) user_data; - e_cal_view_get_selected_time_range (cal_view, &dtstart, &dtend); - e_cal_view_new_appointment_for (cal_view, dtstart, dtend, TRUE, FALSE); + e_calendar_view_get_selected_time_range (cal_view, &dtstart, &dtend); + e_calendar_view_new_appointment_for (cal_view, dtstart, dtend, TRUE, FALSE); } static void on_new_meeting (GtkWidget *widget, gpointer user_data) { time_t dtstart, dtend; - ECalView *cal_view = (ECalView *) user_data; + ECalendarView *cal_view = (ECalendarView *) user_data; - e_cal_view_get_selected_time_range (cal_view, &dtstart, &dtend); - e_cal_view_new_appointment_for (cal_view, dtstart, dtend, FALSE, TRUE); + e_calendar_view_get_selected_time_range (cal_view, &dtstart, &dtend); + e_calendar_view_new_appointment_for (cal_view, dtstart, dtend, FALSE, TRUE); } static void on_new_task (GtkWidget *widget, gpointer user_data) { - ECalView *cal_view = (ECalView *) user_data; + ECalendarView *cal_view = (ECalendarView *) user_data; gnome_calendar_new_task (cal_view->priv->calendar); } static void on_goto_date (GtkWidget *widget, gpointer user_data) { - ECalView *cal_view = E_CAL_VIEW (user_data); + ECalendarView *cal_view = E_CALENDAR_VIEW (user_data); goto_dialog (cal_view->priv->calendar); } @@ -966,7 +966,7 @@ on_goto_date (GtkWidget *widget, gpointer user_data) static void on_goto_today (GtkWidget *widget, gpointer user_data) { - ECalView *cal_view = E_CAL_VIEW (user_data); + ECalendarView *cal_view = E_CALENDAR_VIEW (user_data); calendar_goto_today (cal_view->priv->calendar); } @@ -975,14 +975,14 @@ static void on_edit_appointment (GtkWidget *widget, gpointer user_data) { GList *selected; - ECalView *cal_view = E_CAL_VIEW (user_data); + ECalendarView *cal_view = E_CALENDAR_VIEW (user_data); - selected = e_cal_view_get_selected_events (cal_view); + selected = e_calendar_view_get_selected_events (cal_view); if (selected) { - ECalViewEvent *event = (ECalViewEvent *) selected->data; + ECalendarViewEvent *event = (ECalendarViewEvent *) selected->data; if (event) - e_cal_view_edit_appointment (cal_view, event->comp_data->client, + e_calendar_view_edit_appointment (cal_view, event->comp_data->client, event->comp_data->icalcomp, FALSE); g_list_free (selected); @@ -992,14 +992,14 @@ on_edit_appointment (GtkWidget *widget, gpointer user_data) static void on_print (GtkWidget *widget, gpointer user_data) { - ECalView *cal_view; + ECalendarView *cal_view; time_t start; GnomeCalendarViewType view_type; PrintView print_view; - cal_view = E_CAL_VIEW (user_data); + cal_view = E_CALENDAR_VIEW (user_data); - e_cal_view_get_visible_time_range (cal_view, &start, NULL); + e_calendar_view_get_visible_time_range (cal_view, &start, NULL); view_type = gnome_calendar_get_view (cal_view->priv->calendar); switch (view_type) { @@ -1027,16 +1027,16 @@ on_print (GtkWidget *widget, gpointer user_data) static void on_save_as (GtkWidget *widget, gpointer user_data) { - ECalView *cal_view; + ECalendarView *cal_view; GList *selected; char *filename; char *ical_string; FILE *file; - ECalViewEvent *event; + ECalendarViewEvent *event; - cal_view = E_CAL_VIEW (user_data); + cal_view = E_CALENDAR_VIEW (user_data); - selected = e_cal_view_get_selected_events (cal_view); + selected = e_calendar_view_get_selected_events (cal_view); if (!selected) return; @@ -1044,8 +1044,8 @@ on_save_as (GtkWidget *widget, gpointer user_data) if (filename == NULL) return; - event = (ECalViewEvent *) selected->data; - ical_string = cal_client_get_component_as_string (event->comp_data->client, event->comp_data->icalcomp); + event = (ECalendarViewEvent *) selected->data; + ical_string = e_cal_get_component_as_string (event->comp_data->client, event->comp_data->icalcomp); if (ical_string == NULL) { g_warning ("Couldn't convert item to a string"); return; @@ -1067,20 +1067,20 @@ on_save_as (GtkWidget *widget, gpointer user_data) static void on_print_event (GtkWidget *widget, gpointer user_data) { - ECalView *cal_view; + ECalendarView *cal_view; GList *selected; - ECalViewEvent *event; - CalComponent *comp; + ECalendarViewEvent *event; + ECalComponent *comp; - cal_view = E_CAL_VIEW (user_data); - selected = e_cal_view_get_selected_events (cal_view); + cal_view = E_CALENDAR_VIEW (user_data); + selected = e_calendar_view_get_selected_events (cal_view); if (!selected) return; - event = (ECalViewEvent *) selected->data; + event = (ECalendarViewEvent *) selected->data; - comp = cal_component_new (); - cal_component_set_icalcomponent (comp, icalcomponent_new_clone (event->comp_data->icalcomp)); + comp = e_cal_component_new (); + e_cal_component_set_icalcomponent (comp, icalcomponent_new_clone (event->comp_data->icalcomp)); print_comp (comp, event->comp_data->client, FALSE); g_object_unref (comp); @@ -1090,12 +1090,12 @@ static void on_meeting (GtkWidget *widget, gpointer user_data) { GList *selected; - ECalView *cal_view = E_CAL_VIEW (user_data); + ECalendarView *cal_view = E_CALENDAR_VIEW (user_data); - selected = e_cal_view_get_selected_events (cal_view); + selected = e_calendar_view_get_selected_events (cal_view); if (selected) { - ECalViewEvent *event = (ECalViewEvent *) selected->data; - e_cal_view_edit_appointment (cal_view, event->comp_data->client, event->comp_data->icalcomp, TRUE); + ECalendarViewEvent *event = (ECalendarViewEvent *) selected->data; + e_calendar_view_edit_appointment (cal_view, event->comp_data->client, event->comp_data->icalcomp, TRUE); g_list_free (selected); } @@ -1105,16 +1105,16 @@ static void on_forward (GtkWidget *widget, gpointer user_data) { GList *selected; - ECalView *cal_view = E_CAL_VIEW (user_data); + ECalendarView *cal_view = E_CALENDAR_VIEW (user_data); - selected = e_cal_view_get_selected_events (cal_view); + selected = e_calendar_view_get_selected_events (cal_view); if (selected) { - CalComponent *comp; - ECalViewEvent *event = (ECalViewEvent *) selected->data; + ECalComponent *comp; + ECalendarViewEvent *event = (ECalendarViewEvent *) selected->data; - comp = cal_component_new (); - cal_component_set_icalcomponent (comp, icalcomponent_new_clone (event->comp_data->icalcomp)); - itip_send_comp (CAL_COMPONENT_METHOD_PUBLISH, comp, event->comp_data->client, NULL); + comp = e_cal_component_new (); + e_cal_component_set_icalcomponent (comp, icalcomponent_new_clone (event->comp_data->icalcomp)); + itip_send_comp (E_CAL_COMPONENT_METHOD_PUBLISH, comp, event->comp_data->client, NULL); g_list_free (selected); g_object_unref (comp); @@ -1124,12 +1124,12 @@ on_forward (GtkWidget *widget, gpointer user_data) static void on_publish (GtkWidget *widget, gpointer user_data) { - ECalView *cal_view; + ECalendarView *cal_view; icaltimezone *utc; time_t start = time (NULL), end; GList *comp_list = NULL, *client_list, *cl; - cal_view = E_CAL_VIEW (user_data); + cal_view = E_CALENDAR_VIEW (user_data); utc = icaltimezone_get_utc_timezone (); start = time_day_begin_with_zone (start, utc); @@ -1137,12 +1137,12 @@ on_publish (GtkWidget *widget, gpointer user_data) client_list = e_cal_model_get_client_list (cal_view->priv->model); for (cl = client_list; cl != NULL; cl = cl->next) { - if (cal_client_get_free_busy ((CalClient *) cl->data, NULL, start, end, &comp_list, NULL)) { + if (e_cal_get_free_busy ((ECal *) cl->data, NULL, start, end, &comp_list, NULL)) { GList *l; for (l = comp_list; l; l = l->next) { - CalComponent *comp = CAL_COMPONENT (l->data); - itip_send_comp (CAL_COMPONENT_METHOD_PUBLISH, comp, (CalClient *) cl->data, NULL); + ECalComponent *comp = E_CAL_COMPONENT (l->data); + itip_send_comp (E_CAL_COMPONENT_METHOD_PUBLISH, comp, (ECal *) cl->data, NULL); g_object_unref (comp); } @@ -1157,52 +1157,52 @@ on_publish (GtkWidget *widget, gpointer user_data) static void on_settings (GtkWidget *widget, gpointer user_data) { - ECalView *cal_view; + ECalendarView *cal_view; - cal_view = E_CAL_VIEW (user_data); + cal_view = E_CALENDAR_VIEW (user_data); control_util_show_settings (cal_view->priv->calendar); } static void on_delete_appointment (GtkWidget *widget, gpointer user_data) { - ECalView *cal_view; + ECalendarView *cal_view; - cal_view = E_CAL_VIEW (user_data); - e_cal_view_delete_selected_event (cal_view); + cal_view = E_CALENDAR_VIEW (user_data); + e_calendar_view_delete_selected_event (cal_view); } static void on_delete_occurrence (GtkWidget *widget, gpointer user_data) { - ECalView *cal_view; + ECalendarView *cal_view; - cal_view = E_CAL_VIEW (user_data); - e_cal_view_delete_selected_occurrence (cal_view); + cal_view = E_CALENDAR_VIEW (user_data); + e_calendar_view_delete_selected_occurrence (cal_view); } static void on_cut (GtkWidget *widget, gpointer user_data) { - ECalView *cal_view = E_CAL_VIEW (user_data); + ECalendarView *cal_view = E_CALENDAR_VIEW (user_data); - e_cal_view_cut_clipboard (cal_view); + e_calendar_view_cut_clipboard (cal_view); } static void on_copy (GtkWidget *widget, gpointer user_data) { - ECalView *cal_view = E_CAL_VIEW (user_data); + ECalendarView *cal_view = E_CALENDAR_VIEW (user_data); - e_cal_view_copy_clipboard (cal_view); + e_calendar_view_copy_clipboard (cal_view); } static void on_paste (GtkWidget *widget, gpointer user_data) { - ECalView *cal_view = E_CAL_VIEW (user_data); + ECalendarView *cal_view = E_CALENDAR_VIEW (user_data); - e_cal_view_paste_clipboard (cal_view); + e_calendar_view_paste_clipboard (cal_view); } enum { @@ -1307,7 +1307,7 @@ static EPopupMenu child_items [] = { static void free_view_popup (GtkWidget *widget, gpointer data) { - ECalView *cal_view = E_CAL_VIEW (data); + ECalendarView *cal_view = E_CALENDAR_VIEW (data); if (cal_view->priv->view_menu == NULL) return; @@ -1362,19 +1362,19 @@ setup_popup_icons (EPopupMenu *context_menu) } GtkMenu * -e_cal_view_create_popup_menu (ECalView *cal_view) +e_calendar_view_create_popup_menu (ECalendarView *cal_view) { GList *selected; EPopupMenu *context_menu; guint32 disable_mask = 0, hide_mask = 0; GtkMenu *popup; - CalClient *client = NULL; + ECal *client = NULL; gboolean read_only = TRUE; - g_return_val_if_fail (E_IS_CAL_VIEW (cal_view), NULL); + g_return_val_if_fail (E_IS_CALENDAR_VIEW (cal_view), NULL); /* get the selection */ - selected = e_cal_view_get_selected_events (cal_view); + selected = e_calendar_view_get_selected_events (cal_view); if (selected == NULL) { cal_view->priv->view_menu = gnome_calendar_setup_view_popup (cal_view->priv->calendar); @@ -1383,26 +1383,26 @@ e_cal_view_create_popup_menu (ECalView *cal_view) client = e_cal_model_get_default_client (cal_view->priv->model); } else { - ECalViewEvent *event; + ECalendarViewEvent *event; context_menu = child_items; - event = (ECalViewEvent *) selected->data; - if (cal_util_component_has_recurrences (event->comp_data->icalcomp)) + event = (ECalendarViewEvent *) selected->data; + if (e_cal_util_component_has_recurrences (event->comp_data->icalcomp)) hide_mask |= MASK_SINGLE; else hide_mask |= MASK_RECURRING; - if (cal_util_component_is_instance (event->comp_data->icalcomp)) + if (e_cal_util_component_is_instance (event->comp_data->icalcomp)) hide_mask |= MASK_INSTANCE; - if (cal_util_component_has_organizer (event->comp_data->icalcomp)) { - CalComponent *comp; + if (e_cal_util_component_has_organizer (event->comp_data->icalcomp)) { + ECalComponent *comp; disable_mask |= MASK_MEETING; - comp = cal_component_new (); - cal_component_set_icalcomponent (comp, icalcomponent_new_clone (event->comp_data->icalcomp)); + comp = e_cal_component_new (); + e_cal_component_set_icalcomponent (comp, icalcomponent_new_clone (event->comp_data->icalcomp)); if (!itip_organizer_is_user (comp, event->comp_data->client)) disable_mask |= MASK_MEETING_ORGANIZER; @@ -1412,7 +1412,7 @@ e_cal_view_create_popup_menu (ECalView *cal_view) client = event->comp_data->client; } - cal_client_is_read_only (client, &read_only, NULL); + e_cal_is_read_only (client, &read_only, NULL); if (read_only) disable_mask |= MASK_EDITABLE; @@ -1424,7 +1424,7 @@ e_cal_view_create_popup_menu (ECalView *cal_view) } /** - * e_cal_view_new_appointment_for + * e_calendar_view_new_appointment_for * @cal_view: A calendar view. * @dtstart: A Unix time_t that marks the beginning of the appointment. * @dtend: A Unix time_t that marks the end of the appointment. @@ -1435,19 +1435,19 @@ e_cal_view_create_popup_menu (ECalView *cal_view) * Opens an event editor dialog for a new appointment. */ void -e_cal_view_new_appointment_for (ECalView *cal_view, +e_calendar_view_new_appointment_for (ECalendarView *cal_view, time_t dtstart, time_t dtend, gboolean all_day, gboolean meeting) { - ECalViewPrivate *priv; + ECalendarViewPrivate *priv; struct icaltimetype itt; - CalComponentDateTime dt; - CalComponent *comp; + ECalComponentDateTime dt; + ECalComponent *comp; icalcomponent *icalcomp; - CalComponentTransparency transparency; + ECalComponentTransparency transparency; - g_return_if_fail (E_IS_CAL_VIEW (cal_view)); + g_return_if_fail (E_IS_CALENDAR_VIEW (cal_view)); priv = cal_view->priv; @@ -1458,8 +1458,8 @@ e_cal_view_new_appointment_for (ECalView *cal_view, dt.tzid = icaltimezone_get_tzid (e_cal_model_get_timezone (cal_view->priv->model)); icalcomp = e_cal_model_create_component_with_defaults (priv->model); - comp = cal_component_new (); - cal_component_set_icalcomponent (comp, icalcomp); + comp = e_cal_component_new (); + e_cal_component_set_icalcomponent (comp, icalcomp); /* DTSTART, DTEND */ itt = icaltime_from_timet_with_zone (dtstart, FALSE, e_cal_model_get_timezone (cal_view->priv->model)); @@ -1467,7 +1467,7 @@ e_cal_view_new_appointment_for (ECalView *cal_view, itt.hour = itt.minute = itt.second = 0; itt.is_date = TRUE; } - cal_component_set_dtstart (comp, &dt); + e_cal_component_set_dtstart (comp, &dt); itt = icaltime_from_timet_with_zone (dtend, FALSE, e_cal_model_get_timezone (cal_view->priv->model)); if (all_day) { @@ -1479,20 +1479,20 @@ e_cal_view_new_appointment_for (ECalView *cal_view, itt.hour = itt.minute = itt.second = 0; itt.is_date = TRUE; } - cal_component_set_dtend (comp, &dt); + e_cal_component_set_dtend (comp, &dt); /* TRANSPARENCY */ - transparency = all_day ? CAL_COMPONENT_TRANSP_TRANSPARENT - : CAL_COMPONENT_TRANSP_OPAQUE; - cal_component_set_transparency (comp, transparency); + transparency = all_day ? E_CAL_COMPONENT_TRANSP_TRANSPARENT + : E_CAL_COMPONENT_TRANSP_OPAQUE; + e_cal_component_set_transparency (comp, transparency); /* CATEGORY */ - cal_component_set_categories (comp, priv->default_category); + e_cal_component_set_categories (comp, priv->default_category); /* edit the object */ - cal_component_commit_sequence (comp); + e_cal_component_commit_sequence (comp); - e_cal_view_edit_appointment (cal_view, + e_calendar_view_edit_appointment (cal_view, e_cal_model_get_default_client (priv->model), icalcomp, meeting); @@ -1500,7 +1500,7 @@ e_cal_view_new_appointment_for (ECalView *cal_view, } /** - * e_cal_view_new_appointment + * e_calendar_view_new_appointment * @cal_view: A calendar view. * * Opens an event editor dialog for a new appointment. The appointment's @@ -1508,18 +1508,18 @@ e_cal_view_new_appointment_for (ECalView *cal_view, * the calendar view. */ void -e_cal_view_new_appointment (ECalView *cal_view) +e_calendar_view_new_appointment (ECalendarView *cal_view) { time_t dtstart, dtend; - g_return_if_fail (E_IS_CAL_VIEW (cal_view)); + g_return_if_fail (E_IS_CALENDAR_VIEW (cal_view)); - e_cal_view_get_selected_time_range (cal_view, &dtstart, &dtend); - e_cal_view_new_appointment_for (cal_view, dtstart, dtend, FALSE, FALSE); + e_calendar_view_get_selected_time_range (cal_view, &dtstart, &dtend); + e_calendar_view_new_appointment_for (cal_view, dtstart, dtend, FALSE, FALSE); } /** - * e_cal_view_edit_appointment + * e_calendar_view_edit_appointment * @cal_view: A calendar view. * @client: Calendar client. * @icalcomp: The object to be edited. @@ -1529,18 +1529,18 @@ e_cal_view_new_appointment (ECalView *cal_view) * object. */ void -e_cal_view_edit_appointment (ECalView *cal_view, - CalClient *client, +e_calendar_view_edit_appointment (ECalendarView *cal_view, + ECal *client, icalcomponent *icalcomp, gboolean meeting) { - ECalViewPrivate *priv; + ECalendarViewPrivate *priv; CompEditor *ce; const char *uid; - CalComponent *comp; + ECalComponent *comp; - g_return_if_fail (E_IS_CAL_VIEW (cal_view)); - g_return_if_fail (IS_CAL_CLIENT (client)); + g_return_if_fail (E_IS_CALENDAR_VIEW (cal_view)); + g_return_if_fail (E_IS_CAL (client)); g_return_if_fail (icalcomp != NULL); priv = cal_view->priv; @@ -1554,8 +1554,8 @@ e_cal_view_edit_appointment (ECalView *cal_view, ee = event_editor_new (client); ce = COMP_EDITOR (ee); - comp = cal_component_new (); - cal_component_set_icalcomponent (comp, icalcomponent_new_clone (icalcomp)); + comp = e_cal_component_new (); + e_cal_component_set_icalcomponent (comp, icalcomponent_new_clone (icalcomp)); comp_editor_edit_comp (ce, comp); if (meeting) event_editor_show_meeting (ee); diff --git a/calendar/gui/e-calendar-view.h b/calendar/gui/e-calendar-view.h index 292871b709..a1b11023b3 100644 --- a/calendar/gui/e-calendar-view.h +++ b/calendar/gui/e-calendar-view.h @@ -20,10 +20,10 @@ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 * USA */ -#ifndef _E_CAL_VIEW_H_ -#define _E_CAL_VIEW_H_ +#ifndef _E_CALENDAR_VIEW_H_ +#define _E_CALENDAR_VIEW_H_ -#include <cal-client/cal-client.h> +#include <libecal/e-cal.h> #include <gtk/gtktable.h> #include "e-cal-model.h" #include "gnome-cal.h" @@ -34,21 +34,21 @@ G_BEGIN_DECLS * EView - base widget class for the calendar views. */ -#define E_CAL_VIEW(obj) GTK_CHECK_CAST (obj, e_cal_view_get_type (), ECalView) -#define E_CAL_VIEW_CLASS(klass) GTK_CHECK_CLASS_CAST (klass, e_cal_view_get_type (), ECalViewClass) -#define E_IS_CAL_VIEW(obj) GTK_CHECK_TYPE (obj, e_cal_view_get_type ()) +#define E_CALENDAR_VIEW(obj) GTK_CHECK_CAST (obj, e_calendar_view_get_type (), ECalendarView) +#define E_CALENDAR_VIEW_CLASS(klass) GTK_CHECK_CLASS_CAST (klass, e_calendar_view_get_type (), ECalendarViewClass) +#define E_IS_CALENDAR_VIEW(obj) GTK_CHECK_TYPE (obj, e_calendar_view_get_type ()) typedef enum { - E_CAL_VIEW_POS_OUTSIDE, - E_CAL_VIEW_POS_NONE, - E_CAL_VIEW_POS_EVENT, - E_CAL_VIEW_POS_LEFT_EDGE, - E_CAL_VIEW_POS_RIGHT_EDGE, - E_CAL_VIEW_POS_TOP_EDGE, - E_CAL_VIEW_POS_BOTTOM_EDGE -} ECalViewPosition; - -#define E_CAL_VIEW_EVENT_FIELDS \ + E_CALENDAR_VIEW_POS_OUTSIDE, + E_CALENDAR_VIEW_POS_NONE, + E_CALENDAR_VIEW_POS_EVENT, + E_CALENDAR_VIEW_POS_LEFT_EDGE, + E_CALENDAR_VIEW_POS_RIGHT_EDGE, + E_CALENDAR_VIEW_POS_TOP_EDGE, + E_CALENDAR_VIEW_POS_BOTTOM_EDGE +} ECalendarViewPosition; + +#define E_CALENDAR_VIEW_EVENT_FIELDS \ GnomeCanvasItem *canvas_item; \ ECalModelComponent *comp_data; \ gboolean allocated_comp_data; \ @@ -59,76 +59,76 @@ typedef enum { guint different_timezone : 1; typedef struct { - E_CAL_VIEW_EVENT_FIELDS -} ECalViewEvent; + E_CALENDAR_VIEW_EVENT_FIELDS +} ECalendarViewEvent; -typedef struct _ECalView ECalView; -typedef struct _ECalViewClass ECalViewClass; -typedef struct _ECalViewPrivate ECalViewPrivate; +typedef struct _ECalendarView ECalendarView; +typedef struct _ECalendarViewClass ECalendarViewClass; +typedef struct _ECalendarViewPrivate ECalendarViewPrivate; -struct _ECalView { +struct _ECalendarView { GtkTable table; - ECalViewPrivate *priv; + ECalendarViewPrivate *priv; }; -struct _ECalViewClass { +struct _ECalendarViewClass { GtkTableClass parent_class; /* Notification signals */ - void (* selection_changed) (ECalView *cal_view); - void (* selected_time_changed) (ECalView *cal_view); - void (* timezone_changed) (ECalView *cal_view, icaltimezone *old_zone, icaltimezone *new_zone); - void (* event_changed) (ECalView *day_view, ECalViewEvent *event); - void (* event_added) (ECalView *day_view, ECalViewEvent *event); + void (* selection_changed) (ECalendarView *cal_view); + void (* selected_time_changed) (ECalendarView *cal_view); + void (* timezone_changed) (ECalendarView *cal_view, icaltimezone *old_zone, icaltimezone *new_zone); + void (* event_changed) (ECalendarView *day_view, ECalendarViewEvent *event); + void (* event_added) (ECalendarView *day_view, ECalendarViewEvent *event); /* Virtual methods */ - GList * (* get_selected_events) (ECalView *cal_view); /* a GList of ECalViewEvent's */ - void (* get_selected_time_range) (ECalView *cal_view, time_t *start_time, time_t *end_time); - void (* set_selected_time_range) (ECalView *cal_view, time_t start_time, time_t end_time); - gboolean (* get_visible_time_range) (ECalView *cal_view, time_t *start_time, time_t *end_time); - void (* update_query) (ECalView *cal_view); + GList * (* get_selected_events) (ECalendarView *cal_view); /* a GList of ECalendarViewEvent's */ + void (* get_selected_time_range) (ECalendarView *cal_view, time_t *start_time, time_t *end_time); + void (* set_selected_time_range) (ECalendarView *cal_view, time_t start_time, time_t end_time); + gboolean (* get_visible_time_range) (ECalendarView *cal_view, time_t *start_time, time_t *end_time); + void (* update_query) (ECalendarView *cal_view); }; -GType e_cal_view_get_type (void); - -GnomeCalendar *e_cal_view_get_calendar (ECalView *cal_view); -void e_cal_view_set_calendar (ECalView *cal_view, GnomeCalendar *calendar); -ECalModel *e_cal_view_get_model (ECalView *cal_view); -void e_cal_view_set_model (ECalView *cal_view, ECalModel *model); -icaltimezone *e_cal_view_get_timezone (ECalView *cal_view); -void e_cal_view_set_timezone (ECalView *cal_view, icaltimezone *zone); -const char *e_cal_view_get_default_category (ECalView *cal_view); -void e_cal_view_set_default_category (ECalView *cal_view, const char *category); -gboolean e_cal_view_get_use_24_hour_format (ECalView *view); -void e_cal_view_set_use_24_hour_format (ECalView *view, gboolean use_24_hour); - -void e_cal_view_set_status_message (ECalView *cal_view, const gchar *message); - -GList *e_cal_view_get_selected_events (ECalView *cal_view); -void e_cal_view_get_selected_time_range (ECalView *cal_view, time_t *start_time, time_t *end_time); -void e_cal_view_set_selected_time_range (ECalView *cal_view, time_t start_time, time_t end_time); -gboolean e_cal_view_get_visible_time_range (ECalView *cal_view, time_t *start_time, time_t *end_time); -void e_cal_view_update_query (ECalView *cal_view); - -void e_cal_view_cut_clipboard (ECalView *cal_view); -void e_cal_view_copy_clipboard (ECalView *cal_view); -void e_cal_view_paste_clipboard (ECalView *cal_view); -void e_cal_view_delete_selected_event (ECalView *cal_view); -void e_cal_view_delete_selected_events (ECalView *cal_view); -void e_cal_view_delete_selected_occurrence (ECalView *cal_view); - -GtkMenu *e_cal_view_create_popup_menu (ECalView *cal_view); - -void e_cal_view_add_event (ECalView *cal_view, CalClient *client, time_t dtstart, +GType e_calendar_view_get_type (void); + +GnomeCalendar *e_calendar_view_get_calendar (ECalendarView *cal_view); +void e_calendar_view_set_calendar (ECalendarView *cal_view, GnomeCalendar *calendar); +ECalModel *e_calendar_view_get_model (ECalendarView *cal_view); +void e_calendar_view_set_model (ECalendarView *cal_view, ECalModel *model); +icaltimezone *e_calendar_view_get_timezone (ECalendarView *cal_view); +void e_calendar_view_set_timezone (ECalendarView *cal_view, icaltimezone *zone); +const char *e_calendar_view_get_default_category (ECalendarView *cal_view); +void e_calendar_view_set_default_category (ECalendarView *cal_view, const char *category); +gboolean e_calendar_view_get_use_24_hour_format (ECalendarView *view); +void e_calendar_view_set_use_24_hour_format (ECalendarView *view, gboolean use_24_hour); + +void e_calendar_view_set_status_message (ECalendarView *cal_view, const gchar *message); + +GList *e_calendar_view_get_selected_events (ECalendarView *cal_view); +void e_calendar_view_get_selected_time_range (ECalendarView *cal_view, time_t *start_time, time_t *end_time); +void e_calendar_view_set_selected_time_range (ECalendarView *cal_view, time_t start_time, time_t end_time); +gboolean e_calendar_view_get_visible_time_range (ECalendarView *cal_view, time_t *start_time, time_t *end_time); +void e_calendar_view_update_query (ECalendarView *cal_view); + +void e_calendar_view_cut_clipboard (ECalendarView *cal_view); +void e_calendar_view_copy_clipboard (ECalendarView *cal_view); +void e_calendar_view_paste_clipboard (ECalendarView *cal_view); +void e_calendar_view_delete_selected_event (ECalendarView *cal_view); +void e_calendar_view_delete_selected_events (ECalendarView *cal_view); +void e_calendar_view_delete_selected_occurrence (ECalendarView *cal_view); + +GtkMenu *e_calendar_view_create_popup_menu (ECalendarView *cal_view); + +void e_calendar_view_add_event (ECalendarView *cal_view, ECal *client, time_t dtstart, icaltimezone *default_zone, icalcomponent *icalcomp, gboolean in_top_canvas); -void e_cal_view_new_appointment_for (ECalView *cal_view, +void e_calendar_view_new_appointment_for (ECalendarView *cal_view, time_t dtstart, time_t dtend, gboolean all_day, gboolean meeting); -void e_cal_view_new_appointment (ECalView *cal_view); -void e_cal_view_edit_appointment (ECalView *cal_view, - CalClient *client, +void e_calendar_view_new_appointment (ECalendarView *cal_view); +void e_calendar_view_edit_appointment (ECalendarView *cal_view, + ECal *client, icalcomponent *icalcomp, gboolean meeting); diff --git a/calendar/gui/e-cell-date-edit-text.c b/calendar/gui/e-cell-date-edit-text.c index afd5fc1fb6..3d045fbdd6 100644 --- a/calendar/gui/e-cell-date-edit-text.c +++ b/calendar/gui/e-cell-date-edit-text.c @@ -23,7 +23,7 @@ /* * ECellDateEditText - a subclass of ECellText used to show and edit the text - * representation of the date, from a CalComponentDateTime* model value. + * representation of the date, from a ECalComponentDateTime* model value. */ #include <config.h> @@ -38,7 +38,7 @@ #include <gal/util/e-util.h> #include <gal/widgets/e-unicode.h> #include <e-util/e-time-utils.h> -#include <cal-util/timeutil.h> +#include <libecal/e-cal-time-util.h> #include "e-cell-date-edit-text.h" @@ -214,7 +214,7 @@ e_cell_date_edit_text_init (GtkObject *object) * * Creates a new ECell renderer that can be used to render and edit dates that * that come from the model. The value returned from the model is - * interpreted as being a CalComponentDateTime*. + * interpreted as being a ECalComponentDateTime*. * * Returns: an ECell object that can be used to render dates. */ diff --git a/calendar/gui/e-cell-date-edit-text.h b/calendar/gui/e-cell-date-edit-text.h index 53abb7dcff..ab00c0b39c 100644 --- a/calendar/gui/e-cell-date-edit-text.h +++ b/calendar/gui/e-cell-date-edit-text.h @@ -23,7 +23,7 @@ /* * ECellDateEditText - a subclass of ECellText used to show and edit the text - * representation of the date, from a CalComponentDateTime* model value. + * representation of the date, from a ECalComponentDateTime* model value. */ #ifndef _E_CELL_DATE_EDIT_TEXT_H_ diff --git a/calendar/gui/e-comp-editor-registry.c b/calendar/gui/e-comp-editor-registry.c index 68b33d11ff..9e2a63bd48 100644 --- a/calendar/gui/e-comp-editor-registry.c +++ b/calendar/gui/e-comp-editor-registry.c @@ -107,7 +107,7 @@ e_comp_editor_registry_add (ECompEditorRegistry *reg, CompEditor *editor, gboole { ECompEditorRegistryPrivate *priv; ECompEditorRegistryData *rdata; - CalComponent *comp; + ECalComponent *comp; const char *uid; g_return_if_fail (reg != NULL); @@ -118,7 +118,7 @@ e_comp_editor_registry_add (ECompEditorRegistry *reg, CompEditor *editor, gboole priv = reg->priv; comp = comp_editor_get_comp (editor); - cal_component_get_uid (comp, &uid); + e_cal_component_get_uid (comp, &uid); rdata = g_new0 (ECompEditorRegistryData, 1); @@ -193,14 +193,14 @@ editor_destroy_cb (GtkWidget *widget, gpointer data) ECompEditorRegistry *reg; ECompEditorRegistryPrivate *priv; ECompEditorRegistryData *rdata; - CalComponent *comp; + ECalComponent *comp; const char *uid; reg = E_COMP_EDITOR_REGISTRY (data); priv = reg->priv; comp = comp_editor_get_comp (COMP_EDITOR (widget)); - cal_component_get_uid (comp, &uid); + e_cal_component_get_uid (comp, &uid); rdata = g_hash_table_lookup (priv->editors, uid); diff --git a/calendar/gui/e-date-time-list.c b/calendar/gui/e-date-time-list.c index 5aef6f9c51..348ccc86a9 100644 --- a/calendar/gui/e-date-time-list.c +++ b/calendar/gui/e-date-time-list.c @@ -27,7 +27,7 @@ #include <glib.h> #include <e-util/e-time-utils.h> #include "e-date-time-list.h" -#include "cal-util/timeutil.h" +#include <libecal/e-cal-time-util.h> #include "calendar-config.h" #define G_LIST(x) ((GList *) x) @@ -262,7 +262,7 @@ e_date_time_list_get_column_type (GtkTreeModel *tree_model, return column_types [index]; } -const CalComponentDateTime * +const ECalComponentDateTime * e_date_time_list_get_date_time (EDateTimeList *date_time_list, GtkTreeIter *iter) { g_return_val_if_fail (IS_VALID_ITER (date_time_list, iter), NULL); @@ -271,7 +271,7 @@ e_date_time_list_get_date_time (EDateTimeList *date_time_list, GtkTreeIter *iter } static void -free_datetime (CalComponentDateTime *datetime) +free_datetime (ECalComponentDateTime *datetime) { g_free (datetime->value); if (datetime->tzid) @@ -279,12 +279,12 @@ free_datetime (CalComponentDateTime *datetime) g_free (datetime); } -static CalComponentDateTime * -copy_datetime (const CalComponentDateTime *datetime) +static ECalComponentDateTime * +copy_datetime (const ECalComponentDateTime *datetime) { - CalComponentDateTime *datetime_copy; + ECalComponentDateTime *datetime_copy; - datetime_copy = g_new0 (CalComponentDateTime, 1); + datetime_copy = g_new0 (ECalComponentDateTime, 1); datetime_copy->value = g_new (struct icaltimetype, 1); *datetime_copy->value = *datetime->value; @@ -295,16 +295,16 @@ copy_datetime (const CalComponentDateTime *datetime) } static gint -compare_datetime (const CalComponentDateTime *datetime1, const CalComponentDateTime *datetime2) +compare_datetime (const ECalComponentDateTime *datetime1, const ECalComponentDateTime *datetime2) { return icaltime_compare (*datetime1->value, *datetime2->value); } void e_date_time_list_set_date_time (EDateTimeList *date_time_list, GtkTreeIter *iter, - const CalComponentDateTime *datetime) + const ECalComponentDateTime *datetime) { - CalComponentDateTime *datetime_old; + ECalComponentDateTime *datetime_old; g_return_if_fail (IS_VALID_ITER (date_time_list, iter)); @@ -316,7 +316,7 @@ e_date_time_list_set_date_time (EDateTimeList *date_time_list, GtkTreeIter *iter void e_date_time_list_append (EDateTimeList *date_time_list, GtkTreeIter *iter, - const CalComponentDateTime *datetime) + const ECalComponentDateTime *datetime) { g_return_if_fail (datetime != NULL); @@ -339,7 +339,7 @@ e_date_time_list_remove (EDateTimeList *date_time_list, GtkTreeIter *iter) g_return_if_fail (IS_VALID_ITER (date_time_list, iter)); n = g_list_position (date_time_list->list, G_LIST (iter->user_data)); - free_datetime ((CalComponentDateTime *) G_LIST (iter->user_data)->data); + free_datetime ((ECalComponentDateTime *) G_LIST (iter->user_data)->data); date_time_list->list = g_list_delete_link (date_time_list->list, G_LIST (iter->user_data)); row_deleted (date_time_list, n); } @@ -352,7 +352,7 @@ e_date_time_list_clear (EDateTimeList *date_time_list) all_rows_deleted (date_time_list); for (l = date_time_list->list; l; l = g_list_next (l)) { - free_datetime ((CalComponentDateTime *) l->data); + free_datetime ((ECalComponentDateTime *) l->data); } g_list_free (date_time_list->list); @@ -403,7 +403,7 @@ e_date_time_list_get_path (GtkTreeModel *tree_model, /* Builds a static string out of an exception date */ static char * -get_exception_string (CalComponentDateTime *dt) +get_exception_string (ECalComponentDateTime *dt) { static char buf [256]; struct tm tmp_tm; @@ -433,7 +433,7 @@ e_date_time_list_get_value (GtkTreeModel *tree_model, GValue *value) { EDateTimeList *date_time_list = E_DATE_TIME_LIST (tree_model); - CalComponentDateTime *datetime; + ECalComponentDateTime *datetime; GList *l; const gchar *str; diff --git a/calendar/gui/e-date-time-list.h b/calendar/gui/e-date-time-list.h index 07a7c77b02..83b145c7c6 100644 --- a/calendar/gui/e-date-time-list.h +++ b/calendar/gui/e-date-time-list.h @@ -24,7 +24,7 @@ #define E_DATE_TIME_LIST_H #include <gtk/gtktreemodel.h> -#include <cal-util/cal-component.h> +#include <libecal/e-cal-component.h> G_BEGIN_DECLS @@ -66,14 +66,14 @@ struct _EDateTimeListClass GtkType e_date_time_list_get_type (void); EDateTimeList *e_date_time_list_new (void); -const CalComponentDateTime *e_date_time_list_get_date_time (EDateTimeList *date_time_list, +const ECalComponentDateTime *e_date_time_list_get_date_time (EDateTimeList *date_time_list, GtkTreeIter *iter); void e_date_time_list_set_date_time (EDateTimeList *date_time_list, GtkTreeIter *iter, - const CalComponentDateTime *datetime); + const ECalComponentDateTime *datetime); void e_date_time_list_append (EDateTimeList *date_time_list, GtkTreeIter *iter, - const CalComponentDateTime *datetime); + const ECalComponentDateTime *datetime); void e_date_time_list_remove (EDateTimeList *date_time_list, GtkTreeIter *iter); void e_date_time_list_clear (EDateTimeList *date_time_list); diff --git a/calendar/gui/e-day-view-config.c b/calendar/gui/e-day-view-config.c index bee97919f1..4c10451f40 100644 --- a/calendar/gui/e-day-view-config.c +++ b/calendar/gui/e-day-view-config.c @@ -167,7 +167,7 @@ set_timezone (EDayView *day_view) if (!zone) zone = icaltimezone_get_utc_timezone (); - e_cal_view_set_timezone (E_CAL_VIEW (day_view), zone); + e_calendar_view_set_timezone (E_CALENDAR_VIEW (day_view), zone); g_free (location); } @@ -214,7 +214,7 @@ set_twentyfour_hour (EDayView *day_view) use_24_hour = calendar_config_get_24_hour_format (); - e_cal_view_set_use_24_hour_format (E_CAL_VIEW (day_view), use_24_hour); + e_calendar_view_set_use_24_hour_format (E_CALENDAR_VIEW (day_view), use_24_hour); } static void diff --git a/calendar/gui/e-day-view-main-item.c b/calendar/gui/e-day-view-main-item.c index 15d6141a5a..2b7787ded4 100644 --- a/calendar/gui/e-day-view-main-item.c +++ b/calendar/gui/e-day-view-main-item.c @@ -191,7 +191,7 @@ e_day_view_main_item_draw (GnomeCanvasItem *canvas_item, GdkDrawable *drawable, for (day = 0; day < day_view->days_shown; day++) { day_start_tt = icaltime_from_timet_with_zone (day_view->day_starts[day], FALSE, - e_cal_view_get_timezone (E_CAL_VIEW (day_view))); + e_calendar_view_get_timezone (E_CALENDAR_VIEW (day_view))); weekday = icaltime_day_of_week (day_start_tt) - 1; work_day = day_view->working_days & (1 << weekday); @@ -318,7 +318,7 @@ e_day_view_main_item_draw_events_in_vbars (EDayViewMainItem *dvmitem, EDayViewEvent *event; GdkGC *gc; gint grid_x, event_num, bar_y, bar_h; - CalComponentTransparency transparency; + ECalComponentTransparency transparency; day_view = dvmitem->day_view; @@ -330,17 +330,17 @@ e_day_view_main_item_draw_events_in_vbars (EDayViewMainItem *dvmitem, /* Draw the busy times corresponding to the events in the day. */ for (event_num = 0; event_num < day_view->events[day]->len; event_num++) { - CalComponent *comp; + ECalComponent *comp; event = &g_array_index (day_view->events[day], EDayViewEvent, event_num); - comp = cal_component_new (); - cal_component_set_icalcomponent (comp, icalcomponent_new_clone (event->comp_data->icalcomp)); + comp = e_cal_component_new (); + e_cal_component_set_icalcomponent (comp, icalcomponent_new_clone (event->comp_data->icalcomp)); /* If the event is TRANSPARENT, skip it. */ - cal_component_get_transparency (comp, &transparency); - if (transparency == CAL_COMPONENT_TRANSP_TRANSPARENT) + e_cal_component_get_transparency (comp, &transparency); + if (transparency == E_CAL_COMPONENT_TRANSP_TRANSPARENT) continue; /* We can skip the events in the first column since they will @@ -375,7 +375,7 @@ e_day_view_main_item_draw_long_events_in_vbars (EDayViewMainItem *dvmitem, EDayViewEvent *event; gint event_num, start_day, end_day, day, bar_y1, bar_y2, grid_x; GdkGC *gc; - CalComponentTransparency transparency; + ECalComponentTransparency transparency; day_view = dvmitem->day_view; @@ -384,17 +384,17 @@ e_day_view_main_item_draw_long_events_in_vbars (EDayViewMainItem *dvmitem, for (event_num = 0; event_num < day_view->long_events->len; event_num++) { - CalComponent *comp; + ECalComponent *comp; event = &g_array_index (day_view->long_events, EDayViewEvent, event_num); - comp = cal_component_new (); - cal_component_set_icalcomponent (comp, icalcomponent_new_clone (event->comp_data->icalcomp)); + comp = e_cal_component_new (); + e_cal_component_set_icalcomponent (comp, icalcomponent_new_clone (event->comp_data->icalcomp)); /* If the event is TRANSPARENT, skip it. */ - cal_component_get_transparency (comp, &transparency); - if (transparency == CAL_COMPONENT_TRANSP_TRANSPARENT) + e_cal_component_get_transparency (comp, &transparency); + if (transparency == E_CAL_COMPONENT_TRANSP_TRANSPARENT) continue; if (!e_day_view_find_long_event_days (event, @@ -469,12 +469,12 @@ e_day_view_main_item_draw_day_event (EDayViewMainItem *dvmitem, GtkStyle *style; GdkGC *gc; GdkColor bg_color; - CalComponent *comp; + ECalComponent *comp; gint num_icons, icon_x, icon_y, icon_x_inc, icon_y_inc; gint max_icon_w, max_icon_h; gboolean draw_reminder_icon, draw_recurrence_icon, draw_timezone_icon, draw_meeting_icon; GSList *categories_list, *elem; - CalComponentTransparency transparency; + ECalComponentTransparency transparency; day_view = dvmitem->day_view; @@ -505,7 +505,7 @@ e_day_view_main_item_draw_day_event (EDayViewMainItem *dvmitem, since that is used for multiple events. But then you can't see where the event in the first column finishes. */ - if (gdk_color_parse (e_cal_model_get_color_for_component (e_cal_view_get_model (E_CAL_VIEW (day_view)), event->comp_data), + if (gdk_color_parse (e_cal_model_get_color_for_component (e_calendar_view_get_model (E_CALENDAR_VIEW (day_view)), event->comp_data), &bg_color)) { GdkColormap *colormap; @@ -541,21 +541,21 @@ e_day_view_main_item_draw_day_event (EDayViewMainItem *dvmitem, bar_y2 = event->end_minute * day_view->row_height / day_view->mins_per_row - y; /* When an item is being resized, we fill the bar up to the new row. */ - if (day_view->resize_drag_pos != E_CAL_VIEW_POS_NONE + if (day_view->resize_drag_pos != E_CALENDAR_VIEW_POS_NONE && day_view->resize_event_day == day && day_view->resize_event_num == event_num) { - if (day_view->resize_drag_pos == E_CAL_VIEW_POS_TOP_EDGE) + if (day_view->resize_drag_pos == E_CALENDAR_VIEW_POS_TOP_EDGE) bar_y1 = item_y + 1; - else if (day_view->resize_drag_pos == E_CAL_VIEW_POS_BOTTOM_EDGE) + else if (day_view->resize_drag_pos == E_CALENDAR_VIEW_POS_BOTTOM_EDGE) bar_y2 = item_y + item_h - 1; } - comp = cal_component_new (); - cal_component_set_icalcomponent (comp, icalcomponent_new_clone (event->comp_data->icalcomp)); + comp = e_cal_component_new (); + e_cal_component_set_icalcomponent (comp, icalcomponent_new_clone (event->comp_data->icalcomp)); /* Only fill it in if the event isn't TRANSPARENT. */ - cal_component_get_transparency (comp, &transparency); - if (transparency != CAL_COMPONENT_TRANSP_TRANSPARENT) { + e_cal_component_get_transparency (comp, &transparency); + if (transparency != E_CAL_COMPONENT_TRANSP_TRANSPARENT) { gdk_draw_rectangle (drawable, gc, TRUE, item_x + 1, bar_y1, E_DAY_VIEW_BAR_WIDTH - 2, bar_y2 - bar_y1); @@ -593,12 +593,12 @@ e_day_view_main_item_draw_day_event (EDayViewMainItem *dvmitem, icon_y = item_y + E_DAY_VIEW_EVENT_BORDER_HEIGHT + E_DAY_VIEW_ICON_Y_PAD; - if (cal_component_has_alarms (comp)) { + if (e_cal_component_has_alarms (comp)) { draw_reminder_icon = TRUE; num_icons++; } - if (cal_component_has_recurrences (comp)) { + if (e_cal_component_has_recurrences (comp)) { draw_recurrence_icon = TRUE; num_icons++; } @@ -610,12 +610,12 @@ e_day_view_main_item_draw_day_event (EDayViewMainItem *dvmitem, num_icons++; } - if (cal_component_has_organizer (comp)) { + if (e_cal_component_has_organizer (comp)) { draw_meeting_icon = TRUE; num_icons++; } - cal_component_get_categories_list (comp, &categories_list); + e_cal_component_get_categories_list (comp, &categories_list); for (elem = categories_list; elem; elem = elem->next) { char *category; GdkPixmap *pixmap = NULL; @@ -754,7 +754,7 @@ e_day_view_main_item_draw_day_event (EDayViewMainItem *dvmitem, } /* free memory */ - cal_component_free_categories_list (categories_list); + e_cal_component_free_categories_list (categories_list); g_object_unref (comp); } diff --git a/calendar/gui/e-day-view-time-item.c b/calendar/gui/e-day-view-time-item.c index 6a1e1d4279..d70b0fd861 100644 --- a/calendar/gui/e-day-view-time-item.c +++ b/calendar/gui/e-day-view-time-item.c @@ -364,7 +364,7 @@ e_day_view_time_item_draw (GnomeCanvasItem *canvas_item, long_line_x1, row_y, long_line_x2, row_y); - if (e_cal_view_get_use_24_hour_format (E_CAL_VIEW (day_view))) { + if (e_calendar_view_get_use_24_hour_format (E_CALENDAR_VIEW (day_view))) { g_snprintf (buffer, sizeof (buffer), "%i:%02i", display_hour, minute); } else { @@ -416,7 +416,7 @@ e_day_view_time_item_draw (GnomeCanvasItem *canvas_item, /* In 12-hour format we display 'am' or 'pm' instead of '00'. */ if (minute == 0 - && !e_cal_view_get_use_24_hour_format (E_CAL_VIEW (day_view))) { + && !e_calendar_view_get_use_24_hour_format (E_CALENDAR_VIEW (day_view))) { strcpy (buffer, suffix); } else { g_snprintf (buffer, sizeof (buffer), diff --git a/calendar/gui/e-day-view-top-item.c b/calendar/gui/e-day-view-top-item.c index 5a49408566..d2f60d7e7d 100644 --- a/calendar/gui/e-day-view-top-item.c +++ b/calendar/gui/e-day-view-top-item.c @@ -30,7 +30,7 @@ #include <libgnome/gnome-i18n.h> #include <gal/util/e-util.h> #include "e-util/e-categories-config.h" -#include "cal-util/timeutil.h" +#include <libecal/e-cal-time-util.h> #include "e-day-view-top-item.h" static void e_day_view_top_item_class_init (EDayViewTopItemClass *class); @@ -316,7 +316,7 @@ e_day_view_top_item_draw_long_event (EDayViewTopItem *dvtitem, gint start_day, end_day; gint item_x, item_y, item_w, item_h; gint text_x, icon_x, icon_y, icon_x_inc; - CalComponent *comp; + ECalComponent *comp; gchar buffer[16]; gint hour, display_hour, minute, offset, time_width, time_x; gint min_end_time_x, suffix_width, max_icon_x; @@ -348,8 +348,8 @@ e_day_view_top_item_draw_long_event (EDayViewTopItem *dvtitem, gc = day_view->main_gc; fg_gc = style->fg_gc[GTK_STATE_NORMAL]; bg_gc = style->bg_gc[GTK_STATE_NORMAL]; - comp = cal_component_new (); - cal_component_set_icalcomponent (comp, icalcomponent_new_clone (event->comp_data->icalcomp)); + comp = e_cal_component_new (); + e_cal_component_set_icalcomponent (comp, icalcomponent_new_clone (event->comp_data->icalcomp)); /* Draw the lines across the top & bottom of the entire event. */ gdk_gc_set_foreground (gc, &day_view->colors[E_DAY_VIEW_COLOR_LONG_EVENT_BORDER]); @@ -361,7 +361,7 @@ e_day_view_top_item_draw_long_event (EDayViewTopItem *dvtitem, item_x + item_w - 1 - x, item_y + item_h - 1 - y); /* Fill it in. */ - if (gdk_color_parse (e_cal_model_get_color_for_component (e_cal_view_get_model (E_CAL_VIEW (day_view)), + if (gdk_color_parse (e_cal_model_get_color_for_component (e_calendar_view_get_model (E_CALENDAR_VIEW (day_view)), event->comp_data), &bg_color)) { GdkColormap *colormap; @@ -380,13 +380,13 @@ e_day_view_top_item_draw_long_event (EDayViewTopItem *dvtitem, /* When resizing we don't draw the triangles.*/ draw_start_triangle = TRUE; draw_end_triangle = TRUE; - if (day_view->resize_drag_pos != E_CAL_VIEW_POS_NONE + if (day_view->resize_drag_pos != E_CALENDAR_VIEW_POS_NONE && day_view->resize_event_day == E_DAY_VIEW_LONG_EVENT && day_view->resize_event_num == event_num) { - if (day_view->resize_drag_pos == E_CAL_VIEW_POS_LEFT_EDGE) + if (day_view->resize_drag_pos == E_CALENDAR_VIEW_POS_LEFT_EDGE) draw_start_triangle = FALSE; - if (day_view->resize_drag_pos == E_CAL_VIEW_POS_RIGHT_EDGE) + if (day_view->resize_drag_pos == E_CALENDAR_VIEW_POS_RIGHT_EDGE) draw_end_triangle = FALSE; } @@ -448,7 +448,7 @@ e_day_view_top_item_draw_long_event (EDayViewTopItem *dvtitem, e_day_view_convert_time_to_display (day_view, hour, &display_hour, &suffix, &suffix_width); - if (e_cal_view_get_use_24_hour_format (E_CAL_VIEW (day_view))) { + if (e_calendar_view_get_use_24_hour_format (E_CALENDAR_VIEW (day_view))) { g_snprintf (buffer, sizeof (buffer), "%i:%02i", display_hour, minute); } else { @@ -497,7 +497,7 @@ e_day_view_top_item_draw_long_event (EDayViewTopItem *dvtitem, &display_hour, &suffix, &suffix_width); - if (e_cal_view_get_use_24_hour_format (E_CAL_VIEW (day_view))) { + if (e_calendar_view_get_use_24_hour_format (E_CALENDAR_VIEW (day_view))) { g_snprintf (buffer, sizeof (buffer), "%i:%02i", display_hour, minute); } else { @@ -527,7 +527,7 @@ e_day_view_top_item_draw_long_event (EDayViewTopItem *dvtitem, icon_y = item_y + E_DAY_VIEW_LONG_EVENT_BORDER_HEIGHT + E_DAY_VIEW_ICON_Y_PAD - y; - if (icon_x <= max_icon_x && cal_component_has_recurrences (comp)) { + if (icon_x <= max_icon_x && e_cal_component_has_recurrences (comp)) { gdk_gc_set_clip_origin (gc, icon_x, icon_y); gdk_gc_set_clip_mask (gc, day_view->recurrence_mask); gdk_draw_pixmap (drawable, gc, @@ -538,7 +538,7 @@ e_day_view_top_item_draw_long_event (EDayViewTopItem *dvtitem, icon_x -= icon_x_inc; } - if (icon_x <= max_icon_x && cal_component_has_alarms (comp)) { + if (icon_x <= max_icon_x && e_cal_component_has_alarms (comp)) { gdk_gc_set_clip_origin (gc, icon_x, icon_y); gdk_gc_set_clip_mask (gc, day_view->reminder_mask); gdk_draw_pixmap (drawable, gc, @@ -550,7 +550,7 @@ e_day_view_top_item_draw_long_event (EDayViewTopItem *dvtitem, } /* draw categories icons */ - cal_component_get_categories_list (comp, &categories_list); + e_cal_component_get_categories_list (comp, &categories_list); for (elem = categories_list; elem; elem = elem->next) { char *category; GdkPixmap *pixmap = NULL; @@ -578,7 +578,7 @@ e_day_view_top_item_draw_long_event (EDayViewTopItem *dvtitem, gdk_bitmap_unref (mask); } - cal_component_free_categories_list (categories_list); + e_cal_component_free_categories_list (categories_list); g_object_unref (comp); gdk_gc_set_clip_mask (gc, NULL); @@ -672,7 +672,7 @@ e_day_view_top_item_get_day_label (EDayView *day_view, gint day, day_start_tt = icaltime_from_timet_with_zone (day_view->day_starts[day], FALSE, - e_cal_view_get_timezone (E_CAL_VIEW (day_view))); + e_calendar_view_get_timezone (E_CALENDAR_VIEW (day_view))); day_start.tm_year = day_start_tt.year - 1900; day_start.tm_mon = day_start_tt.month - 1; day_start.tm_mday = day_start_tt.day; diff --git a/calendar/gui/e-day-view.c b/calendar/gui/e-day-view.c index bfdb788327..74943593aa 100644 --- a/calendar/gui/e-day-view.c +++ b/calendar/gui/e-day-view.c @@ -53,7 +53,7 @@ #include <e-util/e-categories-config.h> #include <e-util/e-dialog-utils.h> -#include "cal-util/timeutil.h" +#include <libecal/e-cal-time-util.h> #include "dialogs/delete-comp.h" #include "dialogs/delete-error.h" #include "dialogs/send-comp.h" @@ -159,11 +159,11 @@ static gboolean e_day_view_get_extreme_event (EDayView *day_view, static gboolean e_day_view_do_key_press (GtkWidget *widget, GdkEventKey *event); static gboolean e_day_view_popup_menu (GtkWidget *widget); -static GList *e_day_view_get_selected_events (ECalView *cal_view); -static void e_day_view_get_selected_time_range (ECalView *cal_view, time_t *start_time, time_t *end_time); -static void e_day_view_set_selected_time_range (ECalView *cal_view, time_t start_time, time_t end_time); -static gboolean e_day_view_get_visible_time_range (ECalView *cal_view, time_t *start_time, time_t *end_time); -static void e_day_view_update_query (ECalView *cal_view); +static GList *e_day_view_get_selected_events (ECalendarView *cal_view); +static void e_day_view_get_selected_time_range (ECalendarView *cal_view, time_t *start_time, time_t *end_time); +static void e_day_view_set_selected_time_range (ECalendarView *cal_view, time_t start_time, time_t end_time); +static gboolean e_day_view_get_visible_time_range (ECalendarView *cal_view, time_t *start_time, time_t *end_time); +static void e_day_view_update_query (ECalendarView *cal_view); static void e_day_view_goto_start_of_work_day (EDayView *day_view); static void e_day_view_goto_end_of_work_day (EDayView *day_view); static void e_day_view_change_duration_to_start_of_work_day (EDayView *day_view); @@ -237,27 +237,27 @@ static void e_day_view_abort_resize (EDayView *day_view, static gboolean e_day_view_on_long_event_button_press (EDayView *day_view, gint event_num, GdkEventButton *event, - ECalViewPosition pos, + ECalendarViewPosition pos, gint event_x, gint event_y); static gboolean e_day_view_on_event_button_press (EDayView *day_view, gint day, gint event_num, GdkEventButton *event, - ECalViewPosition pos, + ECalendarViewPosition pos, gint event_x, gint event_y); static void e_day_view_on_long_event_click (EDayView *day_view, gint event_num, GdkEventButton *bevent, - ECalViewPosition pos, + ECalendarViewPosition pos, gint event_x, gint event_y); static void e_day_view_on_event_click (EDayView *day_view, gint day, gint event_num, GdkEventButton *event, - ECalViewPosition pos, + ECalendarViewPosition pos, gint event_x, gint event_y); static void e_day_view_on_event_double_click (EDayView *day_view, @@ -278,12 +278,12 @@ static void e_day_view_recalc_day_starts (EDayView *day_view, static void e_day_view_recalc_num_rows (EDayView *day_view); static void e_day_view_recalc_cell_sizes (EDayView *day_view); -static ECalViewPosition e_day_view_convert_position_in_top_canvas (EDayView *day_view, +static ECalendarViewPosition e_day_view_convert_position_in_top_canvas (EDayView *day_view, gint x, gint y, gint *day_return, gint *event_num_return); -static ECalViewPosition e_day_view_convert_position_in_main_canvas (EDayView *day_view, +static ECalendarViewPosition e_day_view_convert_position_in_main_canvas (EDayView *day_view, gint x, gint y, gint *day_return, @@ -310,7 +310,7 @@ static void e_day_view_foreach_event_with_uid (EDayView *day_view, static void e_day_view_free_events (EDayView *day_view); static void e_day_view_free_event_array (EDayView *day_view, GArray *array); -static int e_day_view_add_event (CalComponent *comp, +static int e_day_view_add_event (ECalComponent *comp, time_t start, time_t end, gpointer data); @@ -444,19 +444,19 @@ static gboolean e_day_view_layout_timeout_cb (gpointer data); static GtkTableClass *parent_class; E_MAKE_TYPE (e_day_view, "EDayView", EDayView, e_day_view_class_init, - e_day_view_init, e_cal_view_get_type ()); + e_day_view_init, e_calendar_view_get_type ()); static void e_day_view_class_init (EDayViewClass *class) { GtkObjectClass *object_class; GtkWidgetClass *widget_class; - ECalViewClass *view_class; + ECalendarViewClass *view_class; parent_class = g_type_class_peek_parent (class); object_class = (GtkObjectClass *) class; widget_class = (GtkWidgetClass *) class; - view_class = (ECalViewClass *) class; + view_class = (ECalendarViewClass *) class; /* Method override */ object_class->destroy = e_day_view_destroy; @@ -482,7 +482,7 @@ e_day_view_class_init (EDayViewClass *class) } static void -timezone_changed_cb (ECalView *cal_view, icaltimezone *old_zone, +timezone_changed_cb (ECalendarView *cal_view, icaltimezone *old_zone, icaltimezone *new_zone, gpointer user_data) { struct icaltimetype tt; @@ -503,7 +503,7 @@ timezone_changed_cb (ECalView *cal_view, icaltimezone *old_zone, lower = icaltime_as_timet_with_zone (tt, new_zone); e_day_view_recalc_day_starts (day_view, lower); - e_day_view_update_query ((ECalView *) day_view); + e_day_view_update_query ((ECalendarView *) day_view); } static void @@ -581,7 +581,7 @@ e_day_view_init (EDayView *day_view) day_view->selection_drag_pos = E_DAY_VIEW_DRAG_END; day_view->selection_in_top_canvas = FALSE; - day_view->resize_drag_pos = E_CAL_VIEW_POS_NONE; + day_view->resize_drag_pos = E_CALENDAR_VIEW_POS_NONE; day_view->pressed_event_day = -1; @@ -819,7 +819,7 @@ e_day_view_init (EDayView *day_view) target_table, n_targets, GDK_ACTION_COPY | GDK_ACTION_MOVE | GDK_ACTION_ASK); - /* connect to ECalView's signals */ + /* connect to ECalendarView's signals */ g_signal_connect (G_OBJECT (day_view), "timezone_changed", G_CALLBACK (timezone_changed_cb), NULL); } @@ -1644,7 +1644,7 @@ e_day_view_update_event_label (EDayView *day_view, &end_suffix, &end_suffix_width); - if (e_cal_view_get_use_24_hour_format (E_CAL_VIEW (day_view))) { + if (e_calendar_view_get_use_24_hour_format (E_CALENDAR_VIEW (day_view))) { if (day_view->show_event_end_times) { /* 24 hour format with end time. */ text = g_strdup_printf @@ -1809,7 +1809,7 @@ e_day_view_find_event_from_uid (EDayView *day_view, and are both visible in the view, then the selection is set to those times, otherwise it is set to 1 hour from the start of the working day. */ static void -e_day_view_set_selected_time_range (ECalView *cal_view, +e_day_view_set_selected_time_range (ECalendarView *cal_view, time_t start_time, time_t end_time) { @@ -1825,7 +1825,7 @@ e_day_view_set_selected_time_range (ECalView *cal_view, start of the day given by start_time, otherwise it is the previous work-week start day. */ if (!day_view->work_week_view) { - lower = time_day_begin_with_zone (start_time, e_cal_view_get_timezone (E_CAL_VIEW (day_view))); + lower = time_day_begin_with_zone (start_time, e_calendar_view_get_timezone (E_CALENDAR_VIEW (day_view))); } else { lower = e_day_view_find_work_week_start (day_view, start_time); } @@ -1833,7 +1833,7 @@ e_day_view_set_selected_time_range (ECalView *cal_view, /* See if we need to change the days shown. */ if (lower != day_view->lower) { e_day_view_recalc_day_starts (day_view, lower); - e_day_view_update_query ((ECalView *) day_view); + e_day_view_update_query ((ECalendarView *) day_view); } /* Set the selection. */ @@ -1992,7 +1992,7 @@ e_day_view_find_work_week_start (EDayView *day_view, guint offset; struct icaltimetype tt = icaltime_null_time (); - time_to_gdate_with_zone (&date, start_time, e_cal_view_get_timezone (E_CAL_VIEW (day_view))); + time_to_gdate_with_zone (&date, start_time, e_calendar_view_get_timezone (E_CALENDAR_VIEW (day_view))); /* The start of the work-week is the first working day after the week start day. */ @@ -2023,12 +2023,12 @@ e_day_view_find_work_week_start (EDayView *day_view, tt.month = g_date_month (&date); tt.day = g_date_day (&date); - return icaltime_as_timet_with_zone (tt, e_cal_view_get_timezone (E_CAL_VIEW (day_view))); + return icaltime_as_timet_with_zone (tt, e_calendar_view_get_timezone (E_CALENDAR_VIEW (day_view))); } /* Returns the selected time range. */ static void -e_day_view_get_selected_time_range (ECalView *cal_view, time_t *start_time, time_t *end_time) +e_day_view_get_selected_time_range (ECalendarView *cal_view, time_t *start_time, time_t *end_time) { gint start_col, start_row, end_col, end_row; time_t start, end; @@ -2066,7 +2066,7 @@ e_day_view_get_selected_time_range (ECalView *cal_view, time_t *start_time, time /* Gets the visible time range. Returns FALSE if no time range has been set. */ static gboolean -e_day_view_get_visible_time_range (ECalView *cal_view, +e_day_view_get_visible_time_range (ECalendarView *cal_view, time_t *start_time, time_t *end_time) { @@ -2090,7 +2090,7 @@ e_day_view_recalc_day_starts (EDayView *day_view, day_view->day_starts[0] = start_time; for (day = 1; day <= day_view->days_shown; day++) { - day_view->day_starts[day] = time_add_day_with_zone (day_view->day_starts[day - 1], 1, e_cal_view_get_timezone (E_CAL_VIEW (day_view))); + day_view->day_starts[day] = time_add_day_with_zone (day_view->day_starts[day - 1], 1, e_calendar_view_get_timezone (E_CALENDAR_VIEW (day_view))); } #if 0 @@ -2161,7 +2161,7 @@ e_day_view_set_days_shown (EDayView *day_view, e_day_view_recalc_day_starts (day_view, day_view->lower); e_day_view_recalc_cell_sizes (day_view); - e_day_view_update_query ((ECalView *) day_view); + e_day_view_update_query ((ECalendarView *) day_view); } @@ -2404,7 +2404,7 @@ e_day_view_recalc_work_week (EDayView *day_view) day_view->selection_start_day = -1; e_day_view_recalc_day_starts (day_view, lower); - e_day_view_update_query ((ECalView *) day_view); + e_day_view_update_query ((ECalendarView *) day_view); /* This updates the date navigator. */ e_day_view_update_calendar_selection_time (day_view); @@ -2503,7 +2503,7 @@ e_day_view_on_top_canvas_button_press (GtkWidget *widget, EDayView *day_view) { gint event_x, event_y, day, event_num; - ECalViewPosition pos; + ECalendarViewPosition pos; /* Convert the coords to the main canvas window, or return if the window is not found. */ @@ -2516,10 +2516,10 @@ e_day_view_on_top_canvas_button_press (GtkWidget *widget, event_x, event_y, &day, &event_num); - if (pos == E_CAL_VIEW_POS_OUTSIDE) + if (pos == E_CALENDAR_VIEW_POS_OUTSIDE) return FALSE; - if (pos != E_CAL_VIEW_POS_NONE) + if (pos != E_CALENDAR_VIEW_POS_NONE) return e_day_view_on_long_event_button_press (day_view, event_num, event, pos, @@ -2532,8 +2532,8 @@ e_day_view_on_top_canvas_button_press (GtkWidget *widget, if (event->type == GDK_2BUTTON_PRESS) { time_t dtstart, dtend; - e_day_view_get_selected_time_range ((ECalView *) day_view, &dtstart, &dtend); - e_cal_view_new_appointment_for (E_CAL_VIEW (day_view), + e_day_view_get_selected_time_range ((ECalendarView *) day_view, &dtstart, &dtend); + e_calendar_view_new_appointment_for (E_CALENDAR_VIEW (day_view), dtstart, dtend, TRUE, FALSE); return TRUE; @@ -2619,7 +2619,7 @@ e_day_view_on_main_canvas_button_press (GtkWidget *widget, EDayView *day_view) { gint event_x, event_y, row, day, event_num; - ECalViewPosition pos; + ECalendarViewPosition pos; #if 0 g_print ("In e_day_view_on_main_canvas_button_press\n"); @@ -2638,10 +2638,10 @@ e_day_view_on_main_canvas_button_press (GtkWidget *widget, &day, &row, &event_num); - if (pos == E_CAL_VIEW_POS_OUTSIDE) + if (pos == E_CALENDAR_VIEW_POS_OUTSIDE) return FALSE; - if (pos != E_CAL_VIEW_POS_NONE) + if (pos != E_CALENDAR_VIEW_POS_NONE) return e_day_view_on_event_button_press (day_view, day, event_num, event, pos, event_x, event_y); @@ -2653,8 +2653,8 @@ e_day_view_on_main_canvas_button_press (GtkWidget *widget, if (event->type == GDK_2BUTTON_PRESS) { time_t dtstart, dtend; - e_day_view_get_selected_time_range ((ECalView *) day_view, &dtstart, &dtend); - e_cal_view_new_appointment_for (E_CAL_VIEW (day_view), + e_day_view_get_selected_time_range ((ECalendarView *) day_view, &dtstart, &dtend); + e_calendar_view_new_appointment_for (E_CALENDAR_VIEW (day_view), dtstart, dtend, FALSE, FALSE); return TRUE; @@ -2731,7 +2731,7 @@ static gboolean e_day_view_on_long_event_button_press (EDayView *day_view, gint event_num, GdkEventButton *event, - ECalViewPosition pos, + ECalendarViewPosition pos, gint event_x, gint event_y) { @@ -2773,7 +2773,7 @@ e_day_view_on_event_button_press (EDayView *day_view, gint day, gint event_num, GdkEventButton *event, - ECalViewPosition pos, + ECalendarViewPosition pos, gint event_x, gint event_y) { @@ -2813,7 +2813,7 @@ static void e_day_view_on_long_event_click (EDayView *day_view, gint event_num, GdkEventButton *bevent, - ECalViewPosition pos, + ECalendarViewPosition pos, gint event_x, gint event_y) { @@ -2825,14 +2825,14 @@ e_day_view_on_long_event_click (EDayView *day_view, event_num); /* Ignore clicks on the EText while editing. */ - if (pos == E_CAL_VIEW_POS_EVENT + if (pos == E_CALENDAR_VIEW_POS_EVENT && E_TEXT (event->canvas_item)->editing) return; - if ((cal_util_component_is_instance (event->comp_data->icalcomp) || - !cal_util_component_has_recurrences (event->comp_data->icalcomp)) - && (pos == E_CAL_VIEW_POS_LEFT_EDGE - || pos == E_CAL_VIEW_POS_RIGHT_EDGE)) { + if ((e_cal_util_component_is_instance (event->comp_data->icalcomp) || + !e_cal_util_component_has_recurrences (event->comp_data->icalcomp)) + && (pos == E_CALENDAR_VIEW_POS_LEFT_EDGE + || pos == E_CALENDAR_VIEW_POS_RIGHT_EDGE)) { if (!e_day_view_find_long_event_days (event, day_view->days_shown, day_view->day_starts, @@ -2889,7 +2889,7 @@ e_day_view_on_event_click (EDayView *day_view, gint day, gint event_num, GdkEventButton *bevent, - ECalViewPosition pos, + ECalendarViewPosition pos, gint event_x, gint event_y) { @@ -2900,14 +2900,14 @@ e_day_view_on_event_click (EDayView *day_view, event_num); /* Ignore clicks on the EText while editing. */ - if (pos == E_CAL_VIEW_POS_EVENT + if (pos == E_CALENDAR_VIEW_POS_EVENT && E_TEXT (event->canvas_item)->editing) return; - if ((cal_util_component_is_instance (event->comp_data->icalcomp) || - !cal_util_component_has_recurrences (event->comp_data->icalcomp)) - && (pos == E_CAL_VIEW_POS_TOP_EDGE - || pos == E_CAL_VIEW_POS_BOTTOM_EDGE)) { + if ((e_cal_util_component_is_instance (event->comp_data->icalcomp) || + !e_cal_util_component_has_recurrences (event->comp_data->icalcomp)) + && (pos == E_CALENDAR_VIEW_POS_TOP_EDGE + || pos == E_CALENDAR_VIEW_POS_BOTTOM_EDGE)) { /* Grab the keyboard focus, so the event being edited is saved and we can use the Escape key to abort the resize. */ if (!GTK_WIDGET_HAS_FOCUS (day_view)) @@ -2973,7 +2973,7 @@ e_day_view_reshape_resize_long_event_rect_item (EDayView *day_view) /* If we're not resizing an event, or the event is not shown, hide the resize bars. */ - if (day_view->resize_drag_pos == E_CAL_VIEW_POS_NONE + if (day_view->resize_drag_pos == E_CALENDAR_VIEW_POS_NONE || !e_day_view_get_long_event_position (day_view, event_num, &start_day, &end_day, &item_x, &item_y, @@ -3009,7 +3009,7 @@ e_day_view_reshape_resize_rect_item (EDayView *day_view) /* If we're not resizing an event, or the event is not shown, hide the resize bars. */ - if (day_view->resize_drag_pos == E_CAL_VIEW_POS_NONE + if (day_view->resize_drag_pos == E_CALENDAR_VIEW_POS_NONE || !e_day_view_get_event_position (day_view, day, event_num, &item_x, &item_y, &item_w, &item_h)) { @@ -3056,7 +3056,7 @@ e_day_view_on_event_double_click (EDayView *day_view, e_day_view_stop_editing_event (day_view); - e_cal_view_edit_appointment (E_CAL_VIEW (day_view), + e_calendar_view_edit_appointment (E_CALENDAR_VIEW (day_view), event->comp_data->client, event->comp_data->icalcomp, FALSE); } @@ -3072,7 +3072,7 @@ e_day_view_show_popup_menu (EDayView *day_view, day_view->popup_event_day = day; day_view->popup_event_num = event_num; - popup = e_cal_view_create_popup_menu (E_CAL_VIEW (day_view)); + popup = e_calendar_view_create_popup_menu (E_CALENDAR_VIEW (day_view)); e_popup_menu (popup, gdk_event); } @@ -3088,7 +3088,7 @@ e_day_view_popup_menu (GtkWidget *widget) /* Returns the currently-selected event, or NULL if none */ static GList * -e_day_view_get_selected_events (ECalView *cal_view) +e_day_view_get_selected_events (ECalendarView *cal_view) { EDayViewEvent *event = NULL; GList *list = NULL; @@ -3128,7 +3128,7 @@ process_component (EDayView *day_view, ECalModelComponent *comp_data) EDayViewEvent *event; gint day, event_num; const char *uid; - CalComponent *comp; + ECalComponent *comp; AddEventData add_event_data; /* If our time hasn't been set yet, just return. */ @@ -3148,8 +3148,8 @@ process_component (EDayView *day_view, ECalModelComponent *comp_data) event = &g_array_index (day_view->events[day], EDayViewEvent, event_num); - if (!cal_util_component_has_recurrences (comp_data->icalcomp) - && cal_util_event_dates_match (event->comp_data->icalcomp, comp_data->icalcomp)) { + if (!e_cal_util_component_has_recurrences (comp_data->icalcomp) + && e_cal_util_event_dates_match (event->comp_data->icalcomp, comp_data->icalcomp)) { #if 0 g_print ("updated object's dates unchanged\n"); #endif @@ -3170,16 +3170,16 @@ process_component (EDayView *day_view, ECalModelComponent *comp_data) } /* Add the occurrences of the event */ - comp = cal_component_new (); - cal_component_set_icalcomponent (comp, icalcomponent_new_clone (comp_data->icalcomp)); + comp = e_cal_component_new (); + e_cal_component_set_icalcomponent (comp, icalcomponent_new_clone (comp_data->icalcomp)); add_event_data.day_view = day_view; add_event_data.comp_data = comp_data; - cal_recur_generate_instances (comp, day_view->lower, + e_cal_recur_generate_instances (comp, day_view->lower, day_view->upper, e_day_view_add_event, &add_event_data, - cal_client_resolve_tzid_cb, comp_data->client, - e_cal_view_get_timezone (E_CAL_VIEW (day_view))); + e_cal_resolve_tzid_cb, comp_data->client, + e_calendar_view_get_timezone (E_CALENDAR_VIEW (day_view))); g_object_unref (comp); @@ -3188,7 +3188,7 @@ process_component (EDayView *day_view, ECalModelComponent *comp_data) /* Restarts a query for the day view */ static void -e_day_view_update_query (ECalView *cal_view) +e_day_view_update_query (ECalendarView *cal_view) { gint rows, r; EDayView *day_view = E_DAY_VIEW (cal_view); @@ -3200,11 +3200,11 @@ e_day_view_update_query (ECalView *cal_view) e_day_view_free_events (day_view); e_day_view_queue_layout (day_view); - rows = e_table_model_row_count (E_TABLE_MODEL (e_cal_view_get_model (E_CAL_VIEW (day_view)))); + rows = e_table_model_row_count (E_TABLE_MODEL (e_calendar_view_get_model (E_CALENDAR_VIEW (day_view)))); for (r = 0; r < rows; r++) { ECalModelComponent *comp_data; - comp_data = e_cal_model_get_component_at (e_cal_view_get_model (E_CAL_VIEW (day_view)), r); + comp_data = e_cal_model_get_component_at (e_calendar_view_get_model (E_CALENDAR_VIEW (day_view)), r); g_assert (comp_data != NULL); process_component (day_view, comp_data); } @@ -3245,7 +3245,7 @@ e_day_view_on_top_canvas_button_release (GtkWidget *widget, if (day_view->selection_is_being_dragged) { gdk_pointer_ungrab (event->time); e_day_view_finish_selection (day_view); - } else if (day_view->resize_drag_pos != E_CAL_VIEW_POS_NONE) { + } else if (day_view->resize_drag_pos != E_CALENDAR_VIEW_POS_NONE) { gdk_pointer_ungrab (event->time); e_day_view_finish_long_event_resize (day_view); } else if (day_view->pressed_event_day != -1) { @@ -3274,7 +3274,7 @@ e_day_view_on_main_canvas_button_release (GtkWidget *widget, gdk_pointer_ungrab (event->time); e_day_view_finish_selection (day_view); e_day_view_stop_auto_scroll (day_view); - } else if (day_view->resize_drag_pos != E_CAL_VIEW_POS_NONE) { + } else if (day_view->resize_drag_pos != E_CALENDAR_VIEW_POS_NONE) { gdk_pointer_ungrab (event->time); e_day_view_finish_resize (day_view); e_day_view_stop_auto_scroll (day_view); @@ -3297,14 +3297,14 @@ e_day_view_update_calendar_selection_time (EDayView *day_view) time_t start, end; GnomeCalendar *calendar; - e_day_view_get_selected_time_range ((ECalView *) day_view, &start, &end); + e_day_view_get_selected_time_range ((ECalendarView *) day_view, &start, &end); #if 0 g_print ("Start: %s", ctime (&start)); g_print ("End : %s", ctime (&end)); #endif - calendar = e_cal_view_get_calendar (E_CAL_VIEW (day_view)); + calendar = e_calendar_view_get_calendar (E_CALENDAR_VIEW (day_view)); if (calendar) gnome_calendar_set_selected_time_range (calendar, start, end); @@ -3317,7 +3317,7 @@ e_day_view_on_top_canvas_motion (GtkWidget *widget, EDayView *day_view) { EDayViewEvent *event = NULL; - ECalViewPosition pos; + ECalendarViewPosition pos; gint event_x, event_y, canvas_x, canvas_y; gint day, event_num; GdkCursor *cursor; @@ -3346,8 +3346,8 @@ e_day_view_on_top_canvas_motion (GtkWidget *widget, if (day_view->selection_is_being_dragged) { e_day_view_update_selection (day_view, day, -1); return TRUE; - } else if (day_view->resize_drag_pos != E_CAL_VIEW_POS_NONE) { - if (pos != E_CAL_VIEW_POS_OUTSIDE) { + } else if (day_view->resize_drag_pos != E_CALENDAR_VIEW_POS_NONE) { + if (pos != E_CALENDAR_VIEW_POS_OUTSIDE) { e_day_view_update_long_event_resize (day_view, day); return TRUE; } @@ -3357,8 +3357,8 @@ e_day_view_on_top_canvas_motion (GtkWidget *widget, event = &g_array_index (day_view->long_events, EDayViewEvent, day_view->pressed_event_num); - if ((cal_util_component_is_instance (event->comp_data->icalcomp) || - !cal_util_component_has_recurrences (event->comp_data->icalcomp)) + if ((e_cal_util_component_is_instance (event->comp_data->icalcomp) || + !e_cal_util_component_has_recurrences (event->comp_data->icalcomp)) && (abs (canvas_x - day_view->drag_event_x) > E_DAY_VIEW_DRAG_START_OFFSET || abs (canvas_y - day_view->drag_event_y) @@ -3386,11 +3386,11 @@ e_day_view_on_top_canvas_motion (GtkWidget *widget, cursor = day_view->normal_cursor; /* Recurring events can't be resized. */ - if (event && (cal_util_component_is_instance (event->comp_data->icalcomp) || - !cal_util_component_has_recurrences (event->comp_data->icalcomp))) { + if (event && (e_cal_util_component_is_instance (event->comp_data->icalcomp) || + !e_cal_util_component_has_recurrences (event->comp_data->icalcomp))) { switch (pos) { - case E_CAL_VIEW_POS_LEFT_EDGE: - case E_CAL_VIEW_POS_RIGHT_EDGE: + case E_CALENDAR_VIEW_POS_LEFT_EDGE: + case E_CALENDAR_VIEW_POS_RIGHT_EDGE: cursor = day_view->resize_width_cursor; break; default: @@ -3416,7 +3416,7 @@ e_day_view_on_main_canvas_motion (GtkWidget *widget, EDayView *day_view) { EDayViewEvent *event = NULL; - ECalViewPosition pos; + ECalendarViewPosition pos; gint event_x, event_y, canvas_x, canvas_y; gint row, day, event_num; GdkCursor *cursor; @@ -3444,14 +3444,14 @@ e_day_view_on_main_canvas_motion (GtkWidget *widget, event_num); if (day_view->selection_is_being_dragged) { - if (pos != E_CAL_VIEW_POS_OUTSIDE) { + if (pos != E_CALENDAR_VIEW_POS_OUTSIDE) { e_day_view_update_selection (day_view, day, row); e_day_view_check_auto_scroll (day_view, event_x, event_y); return TRUE; } - } else if (day_view->resize_drag_pos != E_CAL_VIEW_POS_NONE) { - if (pos != E_CAL_VIEW_POS_OUTSIDE) { + } else if (day_view->resize_drag_pos != E_CALENDAR_VIEW_POS_NONE) { + if (pos != E_CALENDAR_VIEW_POS_OUTSIDE) { e_day_view_update_resize (day_view, row); e_day_view_check_auto_scroll (day_view, event_x, event_y); @@ -3463,8 +3463,8 @@ e_day_view_on_main_canvas_motion (GtkWidget *widget, event = &g_array_index (day_view->events[day_view->pressed_event_day], EDayViewEvent, day_view->pressed_event_num); - if ((cal_util_component_is_instance (event->comp_data->icalcomp) || - !cal_util_component_has_recurrences (event->comp_data->icalcomp)) + if ((e_cal_util_component_is_instance (event->comp_data->icalcomp) || + !e_cal_util_component_has_recurrences (event->comp_data->icalcomp)) && (abs (canvas_x - day_view->drag_event_x) > E_DAY_VIEW_DRAG_START_OFFSET || abs (canvas_y - day_view->drag_event_y) @@ -3492,14 +3492,14 @@ e_day_view_on_main_canvas_motion (GtkWidget *widget, cursor = day_view->normal_cursor; /* Recurring events can't be resized. */ - if (event && (cal_util_component_is_instance (event->comp_data->icalcomp) || - !cal_util_component_has_recurrences (event->comp_data->icalcomp))) { + if (event && (e_cal_util_component_is_instance (event->comp_data->icalcomp) || + !e_cal_util_component_has_recurrences (event->comp_data->icalcomp))) { switch (pos) { - case E_CAL_VIEW_POS_LEFT_EDGE: + case E_CALENDAR_VIEW_POS_LEFT_EDGE: cursor = day_view->move_cursor; break; - case E_CAL_VIEW_POS_TOP_EDGE: - case E_CAL_VIEW_POS_BOTTOM_EDGE: + case E_CALENDAR_VIEW_POS_TOP_EDGE: + case E_CALENDAR_VIEW_POS_BOTTOM_EDGE: cursor = day_view->resize_height_cursor; break; default: @@ -3640,7 +3640,7 @@ e_day_view_update_long_event_resize (EDayView *day_view, event = &g_array_index (day_view->long_events, EDayViewEvent, event_num); - if (day_view->resize_drag_pos == E_CAL_VIEW_POS_LEFT_EDGE) { + if (day_view->resize_drag_pos == E_CALENDAR_VIEW_POS_LEFT_EDGE) { day = MIN (day, day_view->resize_end_row); if (day != day_view->resize_start_row) { need_reshape = TRUE; @@ -3681,7 +3681,7 @@ e_day_view_update_resize (EDayView *day_view, event = &g_array_index (day_view->events[day], EDayViewEvent, event_num); - if (day_view->resize_drag_pos == E_CAL_VIEW_POS_TOP_EDGE) { + if (day_view->resize_drag_pos == E_CALENDAR_VIEW_POS_TOP_EDGE) { row = MIN (row, day_view->resize_end_row); if (row != day_view->resize_start_row) { need_reshape = TRUE; @@ -3713,11 +3713,11 @@ e_day_view_finish_long_event_resize (EDayView *day_view) { EDayViewEvent *event; gint event_num; - CalComponent *comp; - CalComponentDateTime date; + ECalComponent *comp; + ECalComponentDateTime date; struct icaltimetype itt; time_t dt; - CalClient *client; + ECal *client; CalObjModType mod = CALOBJ_MOD_ALL; GtkWindow *toplevel; @@ -3730,27 +3730,27 @@ e_day_view_finish_long_event_resize (EDayView *day_view) /* We use a temporary copy of the comp since we don't want to change the original comp here. Otherwise we would not detect that the event's time had changed in the "update_event" callback. */ - comp = cal_component_new (); - cal_component_set_icalcomponent (comp, icalcomponent_new_clone (event->comp_data->icalcomp)); + comp = e_cal_component_new (); + e_cal_component_set_icalcomponent (comp, icalcomponent_new_clone (event->comp_data->icalcomp)); date.value = &itt; /* FIXME: Should probably keep the timezone of the original start and end times. */ - date.tzid = icaltimezone_get_tzid (e_cal_view_get_timezone (E_CAL_VIEW (day_view))); + date.tzid = icaltimezone_get_tzid (e_calendar_view_get_timezone (E_CALENDAR_VIEW (day_view))); - if (day_view->resize_drag_pos == E_CAL_VIEW_POS_LEFT_EDGE) { + if (day_view->resize_drag_pos == E_CALENDAR_VIEW_POS_LEFT_EDGE) { dt = day_view->day_starts[day_view->resize_start_row]; *date.value = icaltime_from_timet_with_zone (dt, FALSE, - e_cal_view_get_timezone (E_CAL_VIEW (day_view))); - cal_component_set_dtstart (comp, &date); + e_calendar_view_get_timezone (E_CALENDAR_VIEW (day_view))); + e_cal_component_set_dtstart (comp, &date); } else { dt = day_view->day_starts[day_view->resize_end_row + 1]; *date.value = icaltime_from_timet_with_zone (dt, FALSE, - e_cal_view_get_timezone (E_CAL_VIEW (day_view))); - cal_component_set_dtend (comp, &date); + e_calendar_view_get_timezone (E_CALENDAR_VIEW (day_view))); + e_cal_component_set_dtend (comp, &date); } - if (cal_component_has_recurrences (comp)) { + if (e_cal_component_has_recurrences (comp)) { if (!recur_component_dialog (client, comp, &mod, NULL)) { gtk_widget_queue_draw (day_view->top_canvas); goto out; @@ -3759,10 +3759,10 @@ e_day_view_finish_long_event_resize (EDayView *day_view) toplevel = GTK_WINDOW (gtk_widget_get_toplevel (GTK_WIDGET (day_view))); - if (cal_client_modify_object (client, cal_component_get_icalcomponent (comp), mod, NULL)) { + if (e_cal_modify_object (client, e_cal_component_get_icalcomponent (comp), mod, NULL)) { if (itip_organizer_is_user (comp, client) && send_component_dialog (toplevel, client, comp, TRUE)) { - itip_send_comp (CAL_COMPONENT_METHOD_REQUEST, comp, client, NULL); + itip_send_comp (E_CAL_COMPONENT_METHOD_REQUEST, comp, client, NULL); } else { g_message (G_STRLOC ": Could not update the object!"); } @@ -3771,7 +3771,7 @@ e_day_view_finish_long_event_resize (EDayView *day_view) out: gnome_canvas_item_hide (day_view->resize_long_event_rect_item); - day_view->resize_drag_pos = E_CAL_VIEW_POS_NONE; + day_view->resize_drag_pos = E_CALENDAR_VIEW_POS_NONE; g_object_unref (comp); } @@ -3784,11 +3784,11 @@ e_day_view_finish_resize (EDayView *day_view) { EDayViewEvent *event; gint day, event_num; - CalComponent *comp; - CalComponentDateTime date; + ECalComponent *comp; + ECalComponentDateTime date; struct icaltimetype itt; time_t dt; - CalClient *client; + ECal *client; CalObjModType mod = CALOBJ_MOD_ALL; GtkWindow *toplevel; @@ -3802,24 +3802,24 @@ e_day_view_finish_resize (EDayView *day_view) /* We use a temporary shallow copy of the ico since we don't want to change the original ico here. Otherwise we would not detect that the event's time had changed in the "update_event" callback. */ - comp = cal_component_new (); - cal_component_set_icalcomponent (comp, icalcomponent_new_clone (event->comp_data->icalcomp)); + comp = e_cal_component_new (); + e_cal_component_set_icalcomponent (comp, icalcomponent_new_clone (event->comp_data->icalcomp)); date.value = &itt; /* FIXME: Should probably keep the timezone of the original start and end times. */ - date.tzid = icaltimezone_get_tzid (e_cal_view_get_timezone (E_CAL_VIEW (day_view))); + date.tzid = icaltimezone_get_tzid (e_calendar_view_get_timezone (E_CALENDAR_VIEW (day_view))); - if (day_view->resize_drag_pos == E_CAL_VIEW_POS_TOP_EDGE) { + if (day_view->resize_drag_pos == E_CALENDAR_VIEW_POS_TOP_EDGE) { dt = e_day_view_convert_grid_position_to_time (day_view, day, day_view->resize_start_row); *date.value = icaltime_from_timet_with_zone (dt, FALSE, - e_cal_view_get_timezone (E_CAL_VIEW (day_view))); - cal_component_set_dtstart (comp, &date); + e_calendar_view_get_timezone (E_CALENDAR_VIEW (day_view))); + e_cal_component_set_dtstart (comp, &date); } else { dt = e_day_view_convert_grid_position_to_time (day_view, day, day_view->resize_end_row + 1); *date.value = icaltime_from_timet_with_zone (dt, FALSE, - e_cal_view_get_timezone (E_CAL_VIEW (day_view))); - cal_component_set_dtend (comp, &date); + e_calendar_view_get_timezone (E_CALENDAR_VIEW (day_view))); + e_cal_component_set_dtend (comp, &date); } gnome_canvas_item_hide (day_view->resize_rect_item); @@ -3831,9 +3831,9 @@ e_day_view_finish_resize (EDayView *day_view) gnome_canvas_item_hide (day_view->main_canvas_top_resize_bar_item); gnome_canvas_item_hide (day_view->main_canvas_bottom_resize_bar_item); - day_view->resize_drag_pos = E_CAL_VIEW_POS_NONE; + day_view->resize_drag_pos = E_CALENDAR_VIEW_POS_NONE; - if (cal_component_has_recurrences (comp)) { + if (e_cal_component_has_recurrences (comp)) { if (!recur_component_dialog (client, comp, &mod, NULL)) { gtk_widget_queue_draw (day_view->top_canvas); goto out; @@ -3842,11 +3842,11 @@ e_day_view_finish_resize (EDayView *day_view) toplevel = GTK_WINDOW (gtk_widget_get_toplevel (GTK_WIDGET (day_view))); - cal_component_commit_sequence (comp); - if (cal_client_modify_object (client, cal_component_get_icalcomponent (comp), mod, NULL)) { + e_cal_component_commit_sequence (comp); + if (e_cal_modify_object (client, e_cal_component_get_icalcomponent (comp), mod, NULL)) { if (itip_organizer_is_user (comp, client) && send_component_dialog (toplevel, client, comp, TRUE)) { - itip_send_comp (CAL_COMPONENT_METHOD_REQUEST, comp, client, NULL); + itip_send_comp (E_CAL_COMPONENT_METHOD_REQUEST, comp, client, NULL); } else { g_message (G_STRLOC ": Could not update the object!"); } @@ -3863,10 +3863,10 @@ e_day_view_abort_resize (EDayView *day_view, { gint day, event_num; - if (day_view->resize_drag_pos == E_CAL_VIEW_POS_NONE) + if (day_view->resize_drag_pos == E_CALENDAR_VIEW_POS_NONE) return; - day_view->resize_drag_pos = E_CAL_VIEW_POS_NONE; + day_view->resize_drag_pos = E_CALENDAR_VIEW_POS_NONE; gdk_pointer_ungrab (time); day = day_view->resize_event_day; @@ -3938,7 +3938,7 @@ e_day_view_free_event_array (EDayView *day_view, /* This adds one event to the view, adding it to the appropriate array. */ static gboolean -e_day_view_add_event (CalComponent *comp, +e_day_view_add_event (ECalComponent *comp, time_t start, time_t end, gpointer data) @@ -3964,9 +3964,9 @@ e_day_view_add_event (CalComponent *comp, g_return_val_if_fail (end > add_event_data->day_view->lower, TRUE); start_tt = icaltime_from_timet_with_zone (start, FALSE, - e_cal_view_get_timezone (E_CAL_VIEW (add_event_data->day_view))); + e_calendar_view_get_timezone (E_CALENDAR_VIEW (add_event_data->day_view))); end_tt = icaltime_from_timet_with_zone (end, FALSE, - e_cal_view_get_timezone (E_CAL_VIEW (add_event_data->day_view))); + e_calendar_view_get_timezone (E_CALENDAR_VIEW (add_event_data->day_view))); if (add_event_data->comp_data) { event.comp_data = add_event_data->comp_data; @@ -3975,9 +3975,9 @@ e_day_view_add_event (CalComponent *comp, event.comp_data = g_new0 (ECalModelComponent, 1); event.allocated_comp_data = TRUE; - event.comp_data->client = e_cal_model_get_default_client (e_cal_view_get_model (E_CAL_VIEW (add_event_data->day_view))); - cal_component_commit_sequence (comp); - event.comp_data->icalcomp = icalcomponent_new_clone (cal_component_get_icalcomponent (comp)); + event.comp_data->client = e_cal_model_get_default_client (e_calendar_view_get_model (E_CALENDAR_VIEW (add_event_data->day_view))); + e_cal_component_commit_sequence (comp); + event.comp_data->icalcomp = icalcomponent_new_clone (e_cal_component_get_icalcomponent (comp)); } event.start = start; @@ -3997,7 +3997,7 @@ e_day_view_add_event (CalComponent *comp, event.different_timezone = FALSE; if (!cal_comp_util_compare_event_timezones (comp, event.comp_data->client, - e_cal_view_get_timezone (E_CAL_VIEW (add_event_data->day_view)))) + e_calendar_view_get_timezone (E_CALENDAR_VIEW (add_event_data->day_view)))) event.different_timezone = TRUE; /* Find out which array to add the event to. */ @@ -4126,7 +4126,7 @@ e_day_view_reshape_long_event (EDayView *day_view, EDayViewEvent *event; gint start_day, end_day, item_x, item_y, item_w, item_h; gint text_x, text_w, num_icons, icons_width, width, time_width; - CalComponent *comp; + ECalComponent *comp; gint min_text_x, max_text_w, text_width, line_len; gchar *text, *end_of_line; gboolean show_icons = TRUE, use_max_width = FALSE; @@ -4157,15 +4157,15 @@ e_day_view_reshape_long_event (EDayView *day_view, /* We don't show the icons while resizing, since we'd have to draw them on top of the resize rect. Nor when editing. */ num_icons = 0; - comp = cal_component_new (); - cal_component_set_icalcomponent (comp, icalcomponent_new_clone (event->comp_data->icalcomp)); + comp = e_cal_component_new (); + e_cal_component_set_icalcomponent (comp, icalcomponent_new_clone (event->comp_data->icalcomp)); /* Set up Pango prerequisites */ font_desc = gtk_widget_get_style (GTK_WIDGET (day_view))->font_desc; pango_context = gtk_widget_get_pango_context (GTK_WIDGET (day_view)); layout = pango_layout_new (pango_context); - if (day_view->resize_drag_pos != E_CAL_VIEW_POS_NONE + if (day_view->resize_drag_pos != E_CALENDAR_VIEW_POS_NONE && day_view->resize_event_day == E_DAY_VIEW_LONG_EVENT && day_view->resize_event_num == event_num) show_icons = FALSE; @@ -4179,16 +4179,16 @@ e_day_view_reshape_long_event (EDayView *day_view, if (show_icons) { GSList *categories_list, *elem; - if (cal_component_has_alarms (comp)) + if (e_cal_component_has_alarms (comp)) num_icons++; - if (cal_component_has_recurrences (comp)) + if (e_cal_component_has_recurrences (comp)) num_icons++; if (event->different_timezone) num_icons++; - if (cal_component_has_organizer (comp)) + if (e_cal_component_has_organizer (comp)) num_icons++; - cal_component_get_categories_list (comp, &categories_list); + e_cal_component_get_categories_list (comp, &categories_list); for (elem = categories_list; elem; elem = elem->next) { char *category; GdkPixmap *pixmap = NULL; @@ -4198,7 +4198,7 @@ e_day_view_reshape_long_event (EDayView *day_view, if (e_categories_config_get_icon_for (category, &pixmap, &mask)) num_icons++; } - cal_component_free_categories_list (categories_list); + e_cal_component_free_categories_list (categories_list); } if (!event->canvas_item) { @@ -4330,25 +4330,25 @@ e_day_view_reshape_day_event (EDayView *day_view, /* We don't show the icons while resizing, since we'd have to draw them on top of the resize rect. */ num_icons = 0; - if (day_view->resize_drag_pos == E_CAL_VIEW_POS_NONE + if (day_view->resize_drag_pos == E_CALENDAR_VIEW_POS_NONE || day_view->resize_event_day != day || day_view->resize_event_num != event_num) { GSList *categories_list, *elem; - CalComponent *comp; + ECalComponent *comp; - comp = cal_component_new (); - cal_component_set_icalcomponent (comp, icalcomponent_new_clone (event->comp_data->icalcomp)); + comp = e_cal_component_new (); + e_cal_component_set_icalcomponent (comp, icalcomponent_new_clone (event->comp_data->icalcomp)); - if (cal_component_has_alarms (comp)) + if (e_cal_component_has_alarms (comp)) num_icons++; - if (cal_component_has_recurrences (comp)) + if (e_cal_component_has_recurrences (comp)) num_icons++; if (event->different_timezone) num_icons++; - if (cal_component_has_organizer (comp)) + if (e_cal_component_has_organizer (comp)) num_icons++; - cal_component_get_categories_list (comp, &categories_list); + e_cal_component_get_categories_list (comp, &categories_list); for (elem = categories_list; elem; elem = elem->next) { char *category; GdkPixmap *pixmap = NULL; @@ -4358,7 +4358,7 @@ e_day_view_reshape_day_event (EDayView *day_view, if (e_categories_config_get_icon_for (category, &pixmap, &mask)) num_icons++; } - cal_component_free_categories_list (categories_list); + e_cal_component_free_categories_list (categories_list); } if (num_icons > 0) { @@ -4513,13 +4513,13 @@ e_day_view_do_key_press (GtkWidget *widget, GdkEventKey *event) { EDayView *day_view; icalcomponent *icalcomp; - CalComponent *comp; + ECalComponent *comp; gint day, event_num; gchar *initial_text; guint keyval; gboolean stop_emission; time_t dtstart, dtend; - CalComponentDateTime start_dt, end_dt; + ECalComponentDateTime start_dt, end_dt; struct icaltimetype start_tt, end_tt; const char *uid; AddEventData add_event_data; @@ -4532,7 +4532,7 @@ e_day_view_do_key_press (GtkWidget *widget, GdkEventKey *event) keyval = event->keyval; /* The Escape key aborts a resize operation. */ - if (day_view->resize_drag_pos != E_CAL_VIEW_POS_NONE) { + if (day_view->resize_drag_pos != E_CALENDAR_VIEW_POS_NONE) { if (keyval == GDK_Escape) { e_day_view_abort_resize (day_view, event->time); } @@ -4646,38 +4646,38 @@ e_day_view_do_key_press (GtkWidget *widget, GdkEventKey *event) /* Add a new event covering the selected range */ - icalcomp = e_cal_model_create_component_with_defaults (e_cal_view_get_model (E_CAL_VIEW (day_view))); + icalcomp = e_cal_model_create_component_with_defaults (e_calendar_view_get_model (E_CALENDAR_VIEW (day_view))); if (!icalcomp) return FALSE; uid = icalcomponent_get_uid (icalcomp); - comp = cal_component_new (); - cal_component_set_icalcomponent (comp, icalcomp); + comp = e_cal_component_new (); + e_cal_component_set_icalcomponent (comp, icalcomp); - e_day_view_get_selected_time_range ((ECalView *) day_view, &dtstart, &dtend); + e_day_view_get_selected_time_range ((ECalendarView *) day_view, &dtstart, &dtend); start_tt = icaltime_from_timet_with_zone (dtstart, FALSE, - e_cal_view_get_timezone (E_CAL_VIEW (day_view))); + e_calendar_view_get_timezone (E_CALENDAR_VIEW (day_view))); end_tt = icaltime_from_timet_with_zone (dtend, FALSE, - e_cal_view_get_timezone (E_CAL_VIEW (day_view))); + e_calendar_view_get_timezone (E_CALENDAR_VIEW (day_view))); if (day_view->selection_in_top_canvas) { start_dt.tzid = NULL; start_tt.is_date = 1; end_tt.is_date = 1; } else { - start_dt.tzid = icaltimezone_get_tzid (e_cal_view_get_timezone (E_CAL_VIEW (day_view))); + start_dt.tzid = icaltimezone_get_tzid (e_calendar_view_get_timezone (E_CALENDAR_VIEW (day_view))); } start_dt.value = &start_tt; end_dt.value = &end_tt; end_dt.tzid = start_dt.tzid; - cal_component_set_dtstart (comp, &start_dt); - cal_component_set_dtend (comp, &end_dt); + e_cal_component_set_dtstart (comp, &start_dt); + e_cal_component_set_dtend (comp, &end_dt); - cal_component_set_categories ( - comp, e_cal_view_get_default_category (E_CAL_VIEW (day_view))); + e_cal_component_set_categories ( + comp, e_calendar_view_get_default_category (E_CALENDAR_VIEW (day_view))); /* We add the event locally and start editing it. We don't send it to the server until the user finishes editing it. */ @@ -5270,7 +5270,7 @@ static void e_day_view_cursor_key_left (EDayView *day_view, GdkEventKey *event) { if (day_view->selection_start_day == 0) { - gnome_calendar_previous (e_cal_view_get_calendar (E_CAL_VIEW (day_view))); + gnome_calendar_previous (e_calendar_view_get_calendar (E_CALENDAR_VIEW (day_view))); } else { day_view->selection_start_day--; day_view->selection_end_day--; @@ -5289,7 +5289,7 @@ static void e_day_view_cursor_key_right (EDayView *day_view, GdkEventKey *event) { if (day_view->selection_end_day == day_view->days_shown - 1) { - gnome_calendar_next (e_cal_view_get_calendar (E_CAL_VIEW (day_view))); + gnome_calendar_next (e_calendar_view_get_calendar (E_CALENDAR_VIEW (day_view))); } else { day_view->selection_start_day++; day_view->selection_end_day++; @@ -5567,7 +5567,7 @@ e_day_view_change_event_end_time_up (EDayView *day_view) resize_end_row = resize_start_row; if (resize_end_row == resize_start_row) return; - day_view->resize_drag_pos = E_CAL_VIEW_POS_BOTTOM_EDGE; + day_view->resize_drag_pos = E_CALENDAR_VIEW_POS_BOTTOM_EDGE; resize_end_row--; day_view->resize_start_row = resize_start_row; day_view->resize_end_row = resize_end_row; @@ -5598,7 +5598,7 @@ e_day_view_change_event_end_time_down (EDayView *day_view) resize_end_row = resize_start_row; if (resize_end_row == day_view->rows -1) return; - day_view->resize_drag_pos = E_CAL_VIEW_POS_BOTTOM_EDGE; + day_view->resize_drag_pos = E_CALENDAR_VIEW_POS_BOTTOM_EDGE; resize_end_row++; day_view->resize_start_row = resize_start_row; day_view->resize_end_row = resize_end_row; @@ -5655,9 +5655,9 @@ e_day_view_on_editing_stopped (EDayView *day_view, gboolean editing_long_event = FALSE; EDayViewEvent *event; gchar *text = NULL; - CalComponentText summary; - CalComponent *comp; - CalClient *client; + ECalComponentText summary; + ECalComponent *comp; + ECal *client; gboolean on_server; /* Note: the item we are passed here isn't reliable, so we just stop @@ -5701,8 +5701,8 @@ e_day_view_on_editing_stopped (EDayView *day_view, NULL); g_assert (text != NULL); - comp = cal_component_new (); - cal_component_set_icalcomponent (comp, icalcomponent_new_clone (event->comp_data->icalcomp)); + comp = e_cal_component_new (); + e_cal_component_set_icalcomponent (comp, icalcomponent_new_clone (event->comp_data->icalcomp)); client = event->comp_data->client; on_server = cal_comp_is_on_server (comp, client); @@ -5710,7 +5710,7 @@ e_day_view_on_editing_stopped (EDayView *day_view, if (string_is_empty (text) && !on_server) { const char *uid; - cal_component_get_uid (comp, &uid); + e_cal_component_get_uid (comp, &uid); e_day_view_foreach_event_with_uid (day_view, uid, e_day_view_remove_event_cb, NULL); @@ -5721,7 +5721,7 @@ e_day_view_on_editing_stopped (EDayView *day_view, } /* Only update the summary if necessary. */ - cal_component_get_summary (comp, &summary); + e_cal_component_get_summary (comp, &summary); if (summary.value && !strcmp (text, summary.value)) { if (day == E_DAY_VIEW_LONG_EVENT) e_day_view_reshape_long_event (day_view, event_num); @@ -5729,19 +5729,19 @@ e_day_view_on_editing_stopped (EDayView *day_view, e_day_view_update_event_label (day_view, day, event_num); } else if (summary.value || !string_is_empty (text)) { - icalcomponent *icalcomp = cal_component_get_icalcomponent (comp); + icalcomponent *icalcomp = e_cal_component_get_icalcomponent (comp); summary.value = text; summary.altrep = NULL; - cal_component_set_summary (comp, &summary); + e_cal_component_set_summary (comp, &summary); if (!on_server) { - if (!cal_client_create_object (client, icalcomp, NULL, NULL)) + if (!e_cal_create_object (client, icalcomp, NULL, NULL)) g_message (G_STRLOC ": Could not create the object!"); } else { CalObjModType mod = CALOBJ_MOD_ALL; GtkWindow *toplevel; - if (cal_component_has_recurrences (comp)) { + if (e_cal_component_has_recurrences (comp)) { if (!recur_component_dialog (client, comp, &mod, NULL)) { goto out; } @@ -5749,10 +5749,10 @@ e_day_view_on_editing_stopped (EDayView *day_view, /* FIXME When sending here, what exactly should we send? */ toplevel = GTK_WINDOW (gtk_widget_get_toplevel (GTK_WIDGET (day_view))); - if (cal_client_modify_object (client, icalcomp, mod, NULL)) { + if (e_cal_modify_object (client, icalcomp, mod, NULL)) { if (itip_organizer_is_user (comp, client) && send_component_dialog (toplevel, client, comp, FALSE)) - itip_send_comp (CAL_COMPONENT_METHOD_REQUEST, comp, + itip_send_comp (E_CAL_COMPONENT_METHOD_REQUEST, comp, client, NULL); } } @@ -5792,12 +5792,12 @@ e_day_view_convert_grid_position_to_time (EDayView *day_view, /* Create an icaltimetype and convert to a time_t. */ tt = icaltime_from_timet_with_zone (day_view->day_starts[col], - FALSE, e_cal_view_get_timezone (E_CAL_VIEW (day_view))); + FALSE, e_calendar_view_get_timezone (E_CALENDAR_VIEW (day_view))); tt.hour = minutes / 60; tt.minute = minutes % 60; tt.second = 0; - val = icaltime_as_timet_with_zone (tt, e_cal_view_get_timezone (E_CAL_VIEW (day_view))); + val = icaltime_as_timet_with_zone (tt, e_calendar_view_get_timezone (E_CALENDAR_VIEW (day_view))); return val; } @@ -5827,7 +5827,7 @@ e_day_view_convert_time_to_grid_position (EDayView *day_view, /* To find the row we need to convert the time to an icaltimetype, calculate the offset in minutes from the top of the display and divide it by the mins per row setting. */ - tt = icaltime_from_timet_with_zone (time, FALSE, e_cal_view_get_timezone (E_CAL_VIEW (day_view))); + tt = icaltime_from_timet_with_zone (time, FALSE, e_calendar_view_get_timezone (E_CALENDAR_VIEW (day_view))); minutes = tt.hour * 60 + tt.minute; minutes -= day_view->first_hour_shown * 60 + day_view->first_minute_shown; @@ -5895,7 +5895,7 @@ static gboolean e_day_view_auto_scroll_handler (gpointer data) { EDayView *day_view; - ECalViewPosition pos; + ECalendarViewPosition pos; gint scroll_x, scroll_y, new_scroll_y, canvas_x, canvas_y, row, day; GtkAdjustment *adj; @@ -5957,10 +5957,10 @@ e_day_view_auto_scroll_handler (gpointer data) if (day_view->last_mouse_x == -1) day = -1; - if (pos != E_CAL_VIEW_POS_OUTSIDE) { + if (pos != E_CALENDAR_VIEW_POS_OUTSIDE) { if (day_view->selection_is_being_dragged) { e_day_view_update_selection (day_view, day, row); - } else if (day_view->resize_drag_pos != E_CAL_VIEW_POS_NONE) { + } else if (day_view->resize_drag_pos != E_CALENDAR_VIEW_POS_NONE) { e_day_view_update_resize (day_view, row); } else if (day_view->drag_item->object.flags & GNOME_CANVAS_ITEM_VISIBLE) { @@ -6028,12 +6028,12 @@ e_day_view_get_event_position (EDayView *day_view, return FALSE; /* If the event is being resize, use the resize position. */ - if (day_view->resize_drag_pos != E_CAL_VIEW_POS_NONE + if (day_view->resize_drag_pos != E_CALENDAR_VIEW_POS_NONE && day_view->resize_event_day == day && day_view->resize_event_num == event_num) { - if (day_view->resize_drag_pos == E_CAL_VIEW_POS_TOP_EDGE) + if (day_view->resize_drag_pos == E_CALENDAR_VIEW_POS_TOP_EDGE) start_row = day_view->resize_start_row; - else if (day_view->resize_drag_pos == E_CAL_VIEW_POS_BOTTOM_EDGE) + else if (day_view->resize_drag_pos == E_CALENDAR_VIEW_POS_BOTTOM_EDGE) end_row = day_view->resize_end_row; } @@ -6081,12 +6081,12 @@ e_day_view_get_long_event_position (EDayView *day_view, return FALSE; /* If the event is being resize, use the resize position. */ - if (day_view->resize_drag_pos != E_CAL_VIEW_POS_NONE + if (day_view->resize_drag_pos != E_CALENDAR_VIEW_POS_NONE && day_view->resize_event_day == E_DAY_VIEW_LONG_EVENT && day_view->resize_event_num == event_num) { - if (day_view->resize_drag_pos == E_CAL_VIEW_POS_LEFT_EDGE) + if (day_view->resize_drag_pos == E_CALENDAR_VIEW_POS_LEFT_EDGE) *start_day = day_view->resize_start_row; - else if (day_view->resize_drag_pos == E_CAL_VIEW_POS_RIGHT_EDGE) + else if (day_view->resize_drag_pos == E_CALENDAR_VIEW_POS_RIGHT_EDGE) *end_day = day_view->resize_end_row; } @@ -6103,7 +6103,7 @@ e_day_view_get_long_event_position (EDayView *day_view, /* Converts a position within the entire top canvas to a day & event and a place within the event if appropriate. If event_num_return is NULL, it simply returns the grid position without trying to find the event. */ -static ECalViewPosition +static ECalendarViewPosition e_day_view_convert_position_in_top_canvas (EDayView *day_view, gint x, gint y, @@ -6119,7 +6119,7 @@ e_day_view_convert_position_in_top_canvas (EDayView *day_view, *event_num_return = -1; if (x < 0 || y < 0) - return E_CAL_VIEW_POS_OUTSIDE; + return E_CALENDAR_VIEW_POS_OUTSIDE; row = y / day_view->top_row_height - 1; @@ -6131,13 +6131,13 @@ e_day_view_convert_position_in_top_canvas (EDayView *day_view, } } if (day == -1) - return E_CAL_VIEW_POS_OUTSIDE; + return E_CALENDAR_VIEW_POS_OUTSIDE; *day_return = day; /* If only the grid position is wanted, return. */ if (event_num_return == NULL) - return E_CAL_VIEW_POS_NONE; + return E_CALENDAR_VIEW_POS_NONE; for (event_num = 0; event_num < day_view->long_events->len; event_num++) { @@ -6163,23 +6163,23 @@ e_day_view_convert_position_in_top_canvas (EDayView *day_view, if (x < item_x + E_DAY_VIEW_LONG_EVENT_BORDER_WIDTH + E_DAY_VIEW_LONG_EVENT_X_PAD) - return E_CAL_VIEW_POS_LEFT_EDGE; + return E_CALENDAR_VIEW_POS_LEFT_EDGE; if (x >= item_x + item_w - E_DAY_VIEW_LONG_EVENT_BORDER_WIDTH - E_DAY_VIEW_LONG_EVENT_X_PAD) - return E_CAL_VIEW_POS_RIGHT_EDGE; + return E_CALENDAR_VIEW_POS_RIGHT_EDGE; - return E_CAL_VIEW_POS_EVENT; + return E_CALENDAR_VIEW_POS_EVENT; } - return E_CAL_VIEW_POS_NONE; + return E_CALENDAR_VIEW_POS_NONE; } /* Converts a position within the entire main canvas to a day, row, event and a place within the event if appropriate. If event_num_return is NULL, it simply returns the grid position without trying to find the event. */ -static ECalViewPosition +static ECalendarViewPosition e_day_view_convert_position_in_main_canvas (EDayView *day_view, gint x, gint y, @@ -6202,11 +6202,11 @@ e_day_view_convert_position_in_main_canvas (EDayView *day_view, /* Check the position is inside the canvas, and determine the day and row. */ if (x < 0 || y < 0) - return E_CAL_VIEW_POS_OUTSIDE; + return E_CALENDAR_VIEW_POS_OUTSIDE; row = y / day_view->row_height; if (row >= day_view->rows) - return E_CAL_VIEW_POS_OUTSIDE; + return E_CALENDAR_VIEW_POS_OUTSIDE; day = -1; for (col = 1; col <= day_view->days_shown; col++) { @@ -6216,14 +6216,14 @@ e_day_view_convert_position_in_main_canvas (EDayView *day_view, } } if (day == -1) - return E_CAL_VIEW_POS_OUTSIDE; + return E_CALENDAR_VIEW_POS_OUTSIDE; *day_return = day; *row_return = row; /* If only the grid position is wanted, return. */ if (event_num_return == NULL) - return E_CAL_VIEW_POS_NONE; + return E_CALENDAR_VIEW_POS_NONE; /* Check the selected item first, since the horizontal resizing bars may be above other events. */ @@ -6236,10 +6236,10 @@ e_day_view_convert_position_in_main_canvas (EDayView *day_view, *event_num_return = day_view->resize_bars_event_num; if (y >= item_y - E_DAY_VIEW_BAR_HEIGHT && y < item_y + E_DAY_VIEW_EVENT_BORDER_HEIGHT) - return E_CAL_VIEW_POS_TOP_EDGE; + return E_CALENDAR_VIEW_POS_TOP_EDGE; if (y >= item_y + item_h - E_DAY_VIEW_EVENT_BORDER_HEIGHT && y < item_y + item_h + E_DAY_VIEW_BAR_HEIGHT) - return E_CAL_VIEW_POS_BOTTOM_EDGE; + return E_CALENDAR_VIEW_POS_BOTTOM_EDGE; } } } @@ -6260,20 +6260,20 @@ e_day_view_convert_position_in_main_canvas (EDayView *day_view, *event_num_return = event_num; if (x < item_x + E_DAY_VIEW_BAR_WIDTH) - return E_CAL_VIEW_POS_LEFT_EDGE; + return E_CALENDAR_VIEW_POS_LEFT_EDGE; if (y < item_y + E_DAY_VIEW_EVENT_BORDER_HEIGHT + E_DAY_VIEW_EVENT_Y_PAD) - return E_CAL_VIEW_POS_TOP_EDGE; + return E_CALENDAR_VIEW_POS_TOP_EDGE; if (y >= item_y + item_h - E_DAY_VIEW_EVENT_BORDER_HEIGHT - E_DAY_VIEW_EVENT_Y_PAD) - return E_CAL_VIEW_POS_BOTTOM_EDGE; + return E_CALENDAR_VIEW_POS_BOTTOM_EDGE; - return E_CAL_VIEW_POS_EVENT; + return E_CALENDAR_VIEW_POS_EVENT; } - return E_CAL_VIEW_POS_NONE; + return E_CALENDAR_VIEW_POS_NONE; } @@ -6301,7 +6301,7 @@ e_day_view_on_top_canvas_drag_motion (GtkWidget *widget, static void e_day_view_reshape_top_canvas_drag_item (EDayView *day_view) { - ECalViewPosition pos; + ECalendarViewPosition pos; gint x, y, day; /* Calculate the day & start row of the event being dragged, using @@ -6311,7 +6311,7 @@ e_day_view_reshape_top_canvas_drag_item (EDayView *day_view) pos = e_day_view_convert_position_in_top_canvas (day_view, x, y, &day, NULL); /* This shouldn't really happen in a drag. */ - if (pos == E_CAL_VIEW_POS_OUTSIDE) + if (pos == E_CALENDAR_VIEW_POS_OUTSIDE) return; if (day_view->drag_event_day == E_DAY_VIEW_LONG_EVENT) @@ -6448,7 +6448,7 @@ e_day_view_on_main_canvas_drag_motion (GtkWidget *widget, static void e_day_view_reshape_main_canvas_drag_item (EDayView *day_view) { - ECalViewPosition pos; + ECalendarViewPosition pos; gint x, y, day, row; /* Calculate the day & start row of the event being dragged, using @@ -6458,7 +6458,7 @@ e_day_view_reshape_main_canvas_drag_item (EDayView *day_view) pos = e_day_view_convert_position_in_main_canvas (day_view, x, y, &day, &row, NULL); /* This shouldn't really happen in a drag. */ - if (pos == E_CAL_VIEW_POS_OUTSIDE) + if (pos == E_CALENDAR_VIEW_POS_OUTSIDE) return; if (day_view->drag_event_day != -1 @@ -6710,8 +6710,8 @@ e_day_view_on_drag_data_get (GtkWidget *widget, char *comp_str; icalcomponent *vcal; - vcal = cal_util_new_top_level (); - cal_util_add_timezones_from_component (vcal, event->comp_data->icalcomp); + vcal = e_cal_util_new_top_level (); + e_cal_util_add_timezones_from_component (vcal, event->comp_data->icalcomp); icalcomponent_add_component ( vcal, icalcomponent_new_clone (event->comp_data->icalcomp)); @@ -6738,15 +6738,15 @@ e_day_view_on_top_canvas_drag_data_received (GtkWidget *widget, EDayView *day_view) { EDayViewEvent *event=NULL; - ECalViewPosition pos; + ECalendarViewPosition pos; gint day, start_day, end_day, num_days; gint start_offset, end_offset; - CalComponent *comp; - CalComponentDateTime date; + ECalComponent *comp; + ECalComponentDateTime date; struct icaltimetype itt; time_t dt; gboolean all_day_event; - CalClient *client; + ECal *client; gboolean drag_from_same_window; if (day_view->drag_event_day != -1) @@ -6754,7 +6754,7 @@ e_day_view_on_top_canvas_drag_data_received (GtkWidget *widget, else drag_from_same_window = FALSE; - client = e_cal_model_get_default_client (e_cal_view_get_model (E_CAL_VIEW (day_view))); + client = e_cal_model_get_default_client (e_calendar_view_get_model (E_CALENDAR_VIEW (day_view))); /* Note that we only support DnD within the EDayView at present. */ if ((data->length >= 0) && (data->format == 8) @@ -6764,7 +6764,7 @@ e_day_view_on_top_canvas_drag_data_received (GtkWidget *widget, pos = e_day_view_convert_position_in_top_canvas (day_view, x, y, &day, NULL); - if (pos != E_CAL_VIEW_POS_OUTSIDE) { + if (pos != E_CALENDAR_VIEW_POS_OUTSIDE) { CalObjModType mod = CALOBJ_MOD_ALL; GtkWindow *toplevel; @@ -6802,8 +6802,8 @@ e_day_view_on_top_canvas_drag_data_received (GtkWidget *widget, Otherwise we would not detect that the event's time had changed in the "update_event" callback. */ - comp = cal_component_new (); - cal_component_set_icalcomponent (comp, icalcomponent_new_clone (event->comp_data->icalcomp)); + comp = e_cal_component_new (); + e_cal_component_set_icalcomponent (comp, icalcomponent_new_clone (event->comp_data->icalcomp)); if (start_offset == 0 && end_offset == 0) all_day_event = TRUE; @@ -6814,32 +6814,32 @@ e_day_view_on_top_canvas_drag_data_received (GtkWidget *widget, dt = day_view->day_starts[day] + start_offset * 60; itt = icaltime_from_timet_with_zone (dt, FALSE, - e_cal_view_get_timezone (E_CAL_VIEW (day_view))); + e_calendar_view_get_timezone (E_CALENDAR_VIEW (day_view))); if (all_day_event) { itt.is_date = TRUE; date.tzid = NULL; } else { /* FIXME: Should probably keep the timezone of the original start and end times. */ - date.tzid = icaltimezone_get_tzid (e_cal_view_get_timezone (E_CAL_VIEW (day_view))); + date.tzid = icaltimezone_get_tzid (e_calendar_view_get_timezone (E_CALENDAR_VIEW (day_view))); } - cal_component_set_dtstart (comp, &date); + e_cal_component_set_dtstart (comp, &date); if (end_offset == 0) dt = day_view->day_starts[day + num_days]; else dt = day_view->day_starts[day + num_days - 1] + end_offset * 60; itt = icaltime_from_timet_with_zone (dt, FALSE, - e_cal_view_get_timezone (E_CAL_VIEW (day_view))); + e_calendar_view_get_timezone (E_CALENDAR_VIEW (day_view))); if (all_day_event) { itt.is_date = TRUE; date.tzid = NULL; } else { /* FIXME: Should probably keep the timezone of the original start and end times. */ - date.tzid = icaltimezone_get_tzid (e_cal_view_get_timezone (E_CAL_VIEW (day_view))); + date.tzid = icaltimezone_get_tzid (e_calendar_view_get_timezone (E_CALENDAR_VIEW (day_view))); } - cal_component_set_dtend (comp, &date); + e_cal_component_set_dtend (comp, &date); gtk_drag_finish (context, TRUE, TRUE, time); @@ -6851,18 +6851,18 @@ e_day_view_on_top_canvas_drag_data_received (GtkWidget *widget, if (event->canvas_item) gnome_canvas_item_show (event->canvas_item); - if (cal_component_has_recurrences (comp)) { + if (e_cal_component_has_recurrences (comp)) { if (!recur_component_dialog (client, comp, &mod, NULL)) return; } toplevel = GTK_WINDOW (gtk_widget_get_toplevel (GTK_WIDGET (day_view))); - cal_component_commit_sequence (comp); + e_cal_component_commit_sequence (comp); - if (cal_client_modify_object (client, cal_component_get_icalcomponent (comp), mod, NULL)) { + if (e_cal_modify_object (client, e_cal_component_get_icalcomponent (comp), mod, NULL)) { if (itip_organizer_is_user (comp, client) && send_component_dialog (toplevel, client, comp, FALSE)) - itip_send_comp (CAL_COMPONENT_METHOD_REQUEST, comp, + itip_send_comp (E_CAL_COMPONENT_METHOD_REQUEST, comp, client, NULL); } @@ -6885,7 +6885,7 @@ e_day_view_on_top_canvas_drag_data_received (GtkWidget *widget, pos = e_day_view_convert_position_in_top_canvas (day_view, x, y, &day, NULL); - if (pos == E_CAL_VIEW_POS_OUTSIDE) + if (pos == E_CALENDAR_VIEW_POS_OUTSIDE) goto error; comp_str = (char *) data->data; @@ -6894,7 +6894,7 @@ e_day_view_on_top_canvas_drag_data_received (GtkWidget *widget, goto error; default_tzid = calendar_config_get_timezone (); - cal_client_get_timezone (client, default_tzid, &default_zone, NULL); + e_cal_get_timezone (client, default_tzid, &default_zone, NULL); /* check the type of the component */ kind = icalcomponent_isa (icalcomp); @@ -6911,14 +6911,14 @@ e_day_view_on_top_canvas_drag_data_received (GtkWidget *widget, while (subcomp) { child_kind = icalcomponent_isa (subcomp); if (child_kind == ICAL_VEVENT_COMPONENT) - e_cal_view_add_event (E_CAL_VIEW (day_view), client, dtstart, + e_calendar_view_add_event (E_CALENDAR_VIEW (day_view), client, dtstart, default_zone, subcomp, TRUE); else if (child_kind == ICAL_VTIMEZONE_COMPONENT) { icaltimezone *zone; zone = icaltimezone_new (); icaltimezone_set_component (zone, subcomp); - cal_client_add_timezone (client, zone, NULL); + e_cal_add_timezone (client, zone, NULL); icaltimezone_free (zone, 1); } @@ -6930,7 +6930,7 @@ e_day_view_on_top_canvas_drag_data_received (GtkWidget *widget, icalcomponent_free (icalcomp); } else { - e_cal_view_add_event (E_CAL_VIEW (day_view), client, dtstart, default_zone, icalcomp, TRUE); + e_calendar_view_add_event (E_CALENDAR_VIEW (day_view), client, dtstart, default_zone, icalcomp, TRUE); } gtk_drag_finish (context, TRUE, TRUE, time); @@ -6953,14 +6953,14 @@ e_day_view_on_main_canvas_drag_data_received (GtkWidget *widget, EDayView *day_view) { EDayViewEvent *event = NULL; - ECalViewPosition pos; + ECalendarViewPosition pos; gint day, row, start_row, end_row, num_rows, scroll_x, scroll_y; gint start_offset, end_offset; - CalComponent *comp; - CalComponentDateTime date; + ECalComponent *comp; + ECalComponentDateTime date; struct icaltimetype itt; time_t dt; - CalClient *client; + ECal *client; gboolean drag_from_same_window; if (day_view->drag_event_day != -1) @@ -6968,7 +6968,7 @@ e_day_view_on_main_canvas_drag_data_received (GtkWidget *widget, else drag_from_same_window = FALSE; - client = e_cal_model_get_default_client (e_cal_view_get_model (E_CAL_VIEW (day_view))); + client = e_cal_model_get_default_client (e_calendar_view_get_model (E_CALENDAR_VIEW (day_view))); gnome_canvas_get_scroll_offsets (GNOME_CANVAS (widget), &scroll_x, &scroll_y); @@ -6983,7 +6983,7 @@ e_day_view_on_main_canvas_drag_data_received (GtkWidget *widget, pos = e_day_view_convert_position_in_main_canvas (day_view, x, y, &day, &row, NULL); - if (pos != E_CAL_VIEW_POS_OUTSIDE) { + if (pos != E_CALENDAR_VIEW_POS_OUTSIDE) { CalObjModType mod = CALOBJ_MOD_ALL; GtkWindow *toplevel; @@ -7020,20 +7020,20 @@ e_day_view_on_main_canvas_drag_data_received (GtkWidget *widget, don't want to change the original comp here. Otherwise we would not detect that the event's time had changed in the "update_event" callback. */ - comp = cal_component_new (); - cal_component_set_icalcomponent (comp, icalcomponent_new_clone (event->comp_data->icalcomp)); + comp = e_cal_component_new (); + e_cal_component_set_icalcomponent (comp, icalcomponent_new_clone (event->comp_data->icalcomp)); date.value = &itt; - date.tzid = icaltimezone_get_tzid (e_cal_view_get_timezone (E_CAL_VIEW (day_view))); + date.tzid = icaltimezone_get_tzid (e_calendar_view_get_timezone (E_CALENDAR_VIEW (day_view))); dt = e_day_view_convert_grid_position_to_time (day_view, day, row) + start_offset * 60; *date.value = icaltime_from_timet_with_zone (dt, FALSE, - e_cal_view_get_timezone (E_CAL_VIEW (day_view))); - cal_component_set_dtstart (comp, &date); + e_calendar_view_get_timezone (E_CALENDAR_VIEW (day_view))); + e_cal_component_set_dtstart (comp, &date); dt = e_day_view_convert_grid_position_to_time (day_view, day, row + num_rows) - end_offset * 60; *date.value = icaltime_from_timet_with_zone (dt, FALSE, - e_cal_view_get_timezone (E_CAL_VIEW (day_view))); - cal_component_set_dtend (comp, &date); + e_calendar_view_get_timezone (E_CALENDAR_VIEW (day_view))); + e_cal_component_set_dtend (comp, &date); gtk_drag_finish (context, TRUE, TRUE, time); @@ -7045,7 +7045,7 @@ e_day_view_on_main_canvas_drag_data_received (GtkWidget *widget, if (event->canvas_item) gnome_canvas_item_show (event->canvas_item); - if (cal_component_has_recurrences (comp)) { + if (e_cal_component_has_recurrences (comp)) { if (!recur_component_dialog (client, comp, &mod, NULL)) { g_object_unref (comp); return; @@ -7053,12 +7053,12 @@ e_day_view_on_main_canvas_drag_data_received (GtkWidget *widget, } toplevel = GTK_WINDOW (gtk_widget_get_toplevel (GTK_WIDGET (day_view))); - cal_component_commit_sequence (comp); + e_cal_component_commit_sequence (comp); - if (cal_client_modify_object (client, cal_component_get_icalcomponent (comp), mod, NULL)) { + if (e_cal_modify_object (client, e_cal_component_get_icalcomponent (comp), mod, NULL)) { if (itip_organizer_is_user (comp, client) && send_component_dialog (toplevel, client, comp, FALSE)) - itip_send_comp (CAL_COMPONENT_METHOD_REQUEST, comp, + itip_send_comp (E_CAL_COMPONENT_METHOD_REQUEST, comp, client, NULL); } @@ -7081,7 +7081,7 @@ e_day_view_on_main_canvas_drag_data_received (GtkWidget *widget, pos = e_day_view_convert_position_in_main_canvas (day_view, x, y, &day, &row, NULL); - if (pos == E_CAL_VIEW_POS_OUTSIDE) + if (pos == E_CALENDAR_VIEW_POS_OUTSIDE) goto error; comp_str = (char *) data->data; @@ -7090,7 +7090,7 @@ e_day_view_on_main_canvas_drag_data_received (GtkWidget *widget, goto error; default_tzid = calendar_config_get_timezone (); - cal_client_get_timezone (client, default_tzid, &default_zone, NULL); + e_cal_get_timezone (client, default_tzid, &default_zone, NULL); /* check the type of the component */ kind = icalcomponent_isa (icalcomp); @@ -7107,14 +7107,14 @@ e_day_view_on_main_canvas_drag_data_received (GtkWidget *widget, while (subcomp) { child_kind = icalcomponent_isa (subcomp); if (child_kind == ICAL_VEVENT_COMPONENT) - e_cal_view_add_event (E_CAL_VIEW (day_view), client, dtstart, + e_calendar_view_add_event (E_CALENDAR_VIEW (day_view), client, dtstart, default_zone, subcomp, FALSE); else if (child_kind == ICAL_VTIMEZONE_COMPONENT) { icaltimezone *zone; zone = icaltimezone_new (); icaltimezone_set_component (zone, subcomp); - cal_client_add_timezone (client, zone, NULL); + e_cal_add_timezone (client, zone, NULL); icaltimezone_free (zone, 1); } @@ -7126,7 +7126,7 @@ e_day_view_on_main_canvas_drag_data_received (GtkWidget *widget, icalcomponent_free (icalcomp); } else { - e_cal_view_add_event (E_CAL_VIEW (day_view), client, dtstart, default_zone, icalcomp, FALSE); + e_calendar_view_add_event (E_CALENDAR_VIEW (day_view), client, dtstart, default_zone, icalcomp, FALSE); } gtk_drag_finish (context, TRUE, TRUE, time); @@ -7150,7 +7150,7 @@ e_day_view_convert_time_to_display (EDayView *day_view, /* Calculate the actual hour number to display. For 12-hour format we convert 0-23 to 12-11am/12-11pm. */ *display_hour = hour; - if (e_cal_view_get_use_24_hour_format (E_CAL_VIEW (day_view))) { + if (e_calendar_view_get_use_24_hour_format (E_CALENDAR_VIEW (day_view))) { *suffix = ""; *suffix_width = 0; } else { @@ -7177,7 +7177,7 @@ e_day_view_get_time_string_width (EDayView *day_view) time_width = day_view->digit_width * 4 + day_view->colon_width; - if (!e_cal_view_get_use_24_hour_format (E_CAL_VIEW (day_view))) + if (!e_calendar_view_get_use_24_hour_format (E_CALENDAR_VIEW (day_view))) time_width += MAX (day_view->am_string_width, day_view->pm_string_width); diff --git a/calendar/gui/e-day-view.h b/calendar/gui/e-day-view.h index cb691f5762..e31f0946dd 100644 --- a/calendar/gui/e-day-view.h +++ b/calendar/gui/e-day-view.h @@ -169,7 +169,7 @@ typedef enum typedef struct _EDayViewEvent EDayViewEvent; struct _EDayViewEvent { - E_CAL_VIEW_EVENT_FIELDS + E_CALENDAR_VIEW_EVENT_FIELDS /* For events in the main canvas, this contains the start column. For long events in the top canvas, this is its row. */ @@ -194,7 +194,7 @@ typedef struct _EDayViewClass EDayViewClass; struct _EDayView { - ECalView cal_view; + ECalendarView cal_view; /* The top canvas where the dates and long appointments are shown. */ GtkWidget *top_canvas; @@ -211,7 +211,7 @@ struct _EDayView GtkWidget *vscrollbar; /* S-expression for query and the query object */ - CalQuery *query; + ECalView *query; /* The start and end of the days shown. */ time_t lower; @@ -408,7 +408,7 @@ struct _EDayView /* These are used when resizing events. */ gint resize_event_day; gint resize_event_num; - ECalViewPosition resize_drag_pos; + ECalendarViewPosition resize_drag_pos; gint resize_start_row; gint resize_end_row; @@ -456,7 +456,7 @@ struct _EDayView struct _EDayViewClass { - ECalViewClass parent_class; + ECalendarViewClass parent_class; }; diff --git a/calendar/gui/e-itip-control.c b/calendar/gui/e-itip-control.c index 257d10fd71..e05079dd88 100644 --- a/calendar/gui/e-itip-control.c +++ b/calendar/gui/e-itip-control.c @@ -43,9 +43,9 @@ #include <gtkhtml/gtkhtml.h> #include <gtkhtml/gtkhtml-stream.h> #include <libical/ical.h> -#include <cal-util/cal-component.h> -#include <cal-util/timeutil.h> -#include <cal-client/cal-client.h> +#include <libecal/e-cal-component.h> +#include <libecal/e-cal-time-util.h> +#include <libecal/e-cal.h> #include <e-util/e-time-utils.h> #include <e-util/e-dialog-widgets.h> #include <evolution-shell-client.h> @@ -60,12 +60,12 @@ struct _EItipControlPrivate { GtkWidget *html; GPtrArray *event_clients; - CalClient *event_client; + ECal *event_client; GPtrArray *task_clients; - CalClient *task_client; + ECal *task_client; char *vcalendar; - CalComponent *comp; + ECalComponent *comp; icalcomponent *main_comp; icalcomponent *ical_comp; icalcomponent *top_level; @@ -130,15 +130,15 @@ class_init (EItipControlClass *klass) object_class->finalize = finalize; } -static CalClient * +static ECal * start_calendar_server (EItipControl *itip, char *uri) { - CalClient *client; + ECal *client; GError *error = NULL; - client = cal_client_new (uri, CALOBJ_TYPE_EVENT); + client = e_cal_new (uri, CALOBJ_TYPE_EVENT); - if (!cal_client_open (client, TRUE, &error)) { + if (!e_cal_open (client, TRUE, &error)) { g_warning (_("start_calendar_server(): %s"), error->message); g_error_free (error); g_object_unref (client); @@ -149,13 +149,13 @@ start_calendar_server (EItipControl *itip, char *uri) } static gboolean -start_default_server (EItipControl *itip, CalClient *client, gboolean tasks) +start_default_server (EItipControl *itip, ECal *client, gboolean tasks) { #if 0 if (tasks) - return cal_client_open_default_tasks (client, FALSE); + return e_cal_open_default_tasks (client, FALSE); else - return cal_client_open_default_calendar (client, FALSE); + return e_cal_open_default_calendar (client, FALSE); #endif } @@ -201,7 +201,7 @@ get_servers (EItipControl *itip, EvolutionShellClient *shell_client, const char folder = folder_list->_buffer[j]; for (k = 0; possible_types[k] != NULL; k++) { - CalClient *client; + ECal *client; char *uri; if (itip->priv->destroyed) @@ -210,7 +210,7 @@ get_servers (EItipControl *itip, EvolutionShellClient *shell_client, const char if (strcmp (possible_types[k], folder.type)) continue; - uri = cal_util_expand_uri (folder.physicalUri, tasks); + uri = e_cal_util_expand_uri (folder.physicalUri, tasks); client = start_calendar_server (itip, uri); if (client != NULL) g_ptr_array_add (servers, client); @@ -229,19 +229,19 @@ get_servers (EItipControl *itip, EvolutionShellClient *shell_client, const char } #endif -static CalClient * -find_server (GPtrArray *servers, CalComponent *comp) +static ECal * +find_server (GPtrArray *servers, ECalComponent *comp) { const char *uid; int i; - cal_component_get_uid (comp, &uid); + e_cal_component_get_uid (comp, &uid); for (i = 0; i < servers->len; i++) { - CalClient *client; + ECal *client; icalcomponent *icalcomp; client = g_ptr_array_index (servers, i); - if (cal_client_get_object (client, uid, NULL, &icalcomp, NULL)) { + if (e_cal_get_object (client, uid, NULL, &icalcomp, NULL)) { icalcomponent_free (icalcomp); g_object_ref (client); @@ -527,7 +527,7 @@ find_attendee (icalcomponent *ical_comp, const char *address) } static void -write_label_piece (EItipControl *itip, CalComponentDateTime *dt, +write_label_piece (EItipControl *itip, ECalComponentDateTime *dt, char *buffer, int size, const char *stext, const char *etext, gboolean just_date) @@ -597,7 +597,7 @@ nth (int n) else if (n < 1 || n > 31) return "?"; else - return cal_recur_nth[n]; + return e_cal_recur_nth[n]; } static const char *dayname[] = { @@ -622,7 +622,7 @@ get_dayname (struct icalrecurrencetype *r, int i) } static void -write_recurrence_piece (EItipControl *itip, CalComponent *comp, +write_recurrence_piece (EItipControl *itip, ECalComponent *comp, char *buffer, int size) { GSList *rrules; @@ -634,12 +634,12 @@ write_recurrence_piece (EItipControl *itip, CalComponent *comp, buffer += len; size -= len; - if (!cal_component_has_simple_recurrence (comp)) { + if (!e_cal_component_has_simple_recurrence (comp)) { strcpy (buffer, _("Yes. (Complex Recurrence)")); return; } - cal_component_get_rrule_list (comp, &rrules); + e_cal_component_get_rrule_list (comp, &rrules); g_return_if_fail (rrules && !rrules->next); r = rrules->data; @@ -722,7 +722,7 @@ write_recurrence_piece (EItipControl *itip, CalComponent *comp, if (r->count) { sprintf (buffer, _(" a total of %d times"), r->count); } else if (!icaltime_is_null_time (r->until)) { - CalComponentDateTime dt; + ECalComponentDateTime dt; /* FIXME This should get the tzid id, not the whole zone */ dt.value = &r->until; @@ -737,20 +737,20 @@ write_recurrence_piece (EItipControl *itip, CalComponent *comp, static void set_date_label (EItipControl *itip, GtkHTML *html, GtkHTMLStream *html_stream, - CalComponent *comp) + ECalComponent *comp) { EItipControlPrivate *priv; - CalComponentDateTime datetime; + ECalComponentDateTime datetime; static char buffer[1024]; gboolean wrote = FALSE, task_completed = FALSE; - CalComponentVType type; + ECalComponentVType type; priv = itip->priv; - type = cal_component_get_vtype (comp); + type = e_cal_component_get_vtype (comp); buffer[0] = '\0'; - cal_component_get_dtstart (comp, &datetime); + e_cal_component_get_dtstart (comp, &datetime); if (datetime.value) { write_label_piece (itip, &datetime, buffer, 1024, _("<b>Starts:</b> "), @@ -758,19 +758,19 @@ set_date_label (EItipControl *itip, GtkHTML *html, GtkHTMLStream *html_stream, gtk_html_write (html, html_stream, buffer, strlen(buffer)); wrote = TRUE; } - cal_component_free_datetime (&datetime); + e_cal_component_free_datetime (&datetime); buffer[0] = '\0'; - cal_component_get_dtend (comp, &datetime); + e_cal_component_get_dtend (comp, &datetime); if (datetime.value){ write_label_piece (itip, &datetime, buffer, 1024, _("<b>Ends:</b> "), "<br>", FALSE); gtk_html_write (html, html_stream, buffer, strlen (buffer)); wrote = TRUE; } - cal_component_free_datetime (&datetime); + e_cal_component_free_datetime (&datetime); buffer[0] = '\0'; - if (cal_component_has_recurrences (comp)) { + if (e_cal_component_has_recurrences (comp)) { write_recurrence_piece (itip, comp, buffer, 1024); gtk_html_write (html, html_stream, buffer, strlen (buffer)); wrote = TRUE; @@ -778,8 +778,8 @@ set_date_label (EItipControl *itip, GtkHTML *html, GtkHTMLStream *html_stream, buffer[0] = '\0'; datetime.tzid = NULL; - cal_component_get_completed (comp, &datetime.value); - if (type == CAL_COMPONENT_TODO && datetime.value) { + e_cal_component_get_completed (comp, &datetime.value); + if (type == E_CAL_COMPONENT_TODO && datetime.value) { /* Pass TRUE as is_utc, so it gets converted to the current timezone. */ datetime.value->is_utc = TRUE; @@ -788,17 +788,17 @@ set_date_label (EItipControl *itip, GtkHTML *html, GtkHTMLStream *html_stream, wrote = TRUE; task_completed = TRUE; } - cal_component_free_datetime (&datetime); + e_cal_component_free_datetime (&datetime); buffer[0] = '\0'; - cal_component_get_due (comp, &datetime); - if (type == CAL_COMPONENT_TODO && !task_completed && datetime.value) { + e_cal_component_get_due (comp, &datetime); + if (type == E_CAL_COMPONENT_TODO && !task_completed && datetime.value) { write_label_piece (itip, &datetime, buffer, 1024, _("<b>Due:</b> "), "<br>", FALSE); gtk_html_write (html, html_stream, buffer, strlen (buffer)); wrote = TRUE; } - cal_component_free_datetime (&datetime); + e_cal_component_free_datetime (&datetime); if (wrote) gtk_html_stream_printf (html_stream, "<br>"); @@ -866,9 +866,9 @@ write_html (EItipControl *itip, const gchar *itip_desc, const gchar *itip_title, { EItipControlPrivate *priv; GtkHTMLStream *html_stream; - CalComponentText text; - CalComponentOrganizer organizer; - CalComponentAttendee *attendee; + ECalComponentText text; + ECalComponentOrganizer organizer; + ECalComponentAttendee *attendee; GSList *attendees, *l = NULL; const char *string; gchar *html; @@ -906,7 +906,7 @@ write_html (EItipControl *itip, const gchar *itip_desc, const gchar *itip_title, case ICAL_METHOD_REFRESH: case ICAL_METHOD_REPLY: /* An attendee sent this */ - cal_component_get_attendee_list (priv->comp, &attendees); + e_cal_component_get_attendee_list (priv->comp, &attendees); if (attendees != NULL) { attendee = attendees->data; html = g_strdup_printf (itip_desc, @@ -919,7 +919,7 @@ write_html (EItipControl *itip, const gchar *itip_desc, const gchar *itip_title, break; case ICAL_METHOD_REQUEST: /* The organizer sent this */ - cal_component_get_organizer (priv->comp, &organizer); + e_cal_component_get_organizer (priv->comp, &organizer); if (priv->delegator_address != NULL) { if (organizer.value != NULL) html = g_strdup_printf (itip_desc, @@ -951,7 +951,7 @@ write_html (EItipControl *itip, const gchar *itip_desc, const gchar *itip_title, case ICAL_METHOD_CANCEL: default: /* The organizer sent this */ - cal_component_get_organizer (priv->comp, &organizer); + e_cal_component_get_organizer (priv->comp, &organizer); if (organizer.value != NULL) html = g_strdup_printf (itip_desc, organizer.cn ? @@ -979,7 +979,7 @@ write_html (EItipControl *itip, const gchar *itip_desc, const gchar *itip_title, set_date_label (itip, GTK_HTML (priv->html), html_stream, priv->comp); /* Summary */ - cal_component_get_summary (priv->comp, &text); + e_cal_component_get_summary (priv->comp, &text); html = text.value ? camel_text_to_html (text.value, CAMEL_MIME_FILTER_TOHTML_CONVERT_NL, 0) : _("<i>None</i>"); gtk_html_stream_printf (html_stream, "<b>%s</b><br>%s<br><br>", _("Summary:"), html); @@ -987,7 +987,7 @@ write_html (EItipControl *itip, const gchar *itip_desc, const gchar *itip_title, g_free (html); /* Location */ - cal_component_get_location (priv->comp, &string); + e_cal_component_get_location (priv->comp, &string); if (string != NULL) { html = camel_text_to_html (string, CAMEL_MIME_FILTER_TOHTML_CONVERT_NL, 0); gtk_html_stream_printf (html_stream, "<b>%s</b><br>%s<br><br>", @@ -999,10 +999,10 @@ write_html (EItipControl *itip, const gchar *itip_desc, const gchar *itip_title, if (priv->method == ICAL_METHOD_REPLY) { GSList *alist; - cal_component_get_attendee_list (priv->comp, &alist); + e_cal_component_get_attendee_list (priv->comp, &alist); if (alist != NULL) { - CalComponentAttendee *a = alist->data; + ECalComponentAttendee *a = alist->data; gtk_html_stream_printf (html_stream, "<b>%s</b><br>", _("Status:")); @@ -1026,13 +1026,13 @@ write_html (EItipControl *itip, const gchar *itip_desc, const gchar *itip_title, } } - cal_component_free_attendee_list (alist); + e_cal_component_free_attendee_list (alist); } /* Description */ - cal_component_get_description_list (priv->comp, &l); + e_cal_component_get_description_list (priv->comp, &l); if (l) - text = *((CalComponentText *)l->data); + text = *((ECalComponentText *)l->data); if (l && text.value) { html = camel_text_to_html (text.value, CAMEL_MIME_FILTER_TOHTML_CONVERT_NL, 0); @@ -1040,7 +1040,7 @@ write_html (EItipControl *itip, const gchar *itip_desc, const gchar *itip_title, _("Description:"), html); g_free (html); } - cal_component_free_text_list (l); + e_cal_component_free_text_list (l); /* Separator */ gtk_html_write (GTK_HTML (priv->html), html_stream, HTML_SEP, strlen (HTML_SEP)); @@ -1176,29 +1176,29 @@ get_cancel_options () } -static CalComponent * +static ECalComponent * get_real_item (EItipControl *itip) { EItipControlPrivate *priv; - CalComponent *comp; + ECalComponent *comp; icalcomponent *icalcomp; - CalComponentVType type; + ECalComponentVType type; gboolean found = FALSE; const char *uid; priv = itip->priv; - type = cal_component_get_vtype (priv->comp); - cal_component_get_uid (priv->comp, &uid); + type = e_cal_component_get_vtype (priv->comp); + e_cal_component_get_uid (priv->comp, &uid); switch (type) { - case CAL_COMPONENT_EVENT: + case E_CAL_COMPONENT_EVENT: if (priv->event_client != NULL) - found = cal_client_get_object (priv->event_client, uid, NULL, &icalcomp, NULL); + found = e_cal_get_object (priv->event_client, uid, NULL, &icalcomp, NULL); break; - case CAL_COMPONENT_TODO: + case E_CAL_COMPONENT_TODO: if (priv->task_client != NULL) - found = cal_client_get_object (priv->task_client, uid, NULL, &icalcomp, NULL); + found = e_cal_get_object (priv->task_client, uid, NULL, &icalcomp, NULL); break; default: found = FALSE; @@ -1207,8 +1207,8 @@ get_real_item (EItipControl *itip) if (!found) return NULL; - comp = cal_component_new (); - if (!cal_component_set_icalcomponent (comp, icalcomp)) { + comp = e_cal_component_new (); + if (!e_cal_component_set_icalcomponent (comp, icalcomp)) { g_object_unref (comp); icalcomponent_free (icalcomp); return NULL; @@ -1218,29 +1218,29 @@ get_real_item (EItipControl *itip) } static void -adjust_item (EItipControl *itip, CalComponent *comp) +adjust_item (EItipControl *itip, ECalComponent *comp) { - CalComponent *real_comp; + ECalComponent *real_comp; real_comp = get_real_item (itip); if (real_comp != NULL) { - CalComponentText text; + ECalComponentText text; const char *string; GSList *l; - cal_component_get_summary (real_comp, &text); - cal_component_set_summary (comp, &text); - cal_component_get_location (real_comp, &string); - cal_component_set_location (comp, string); - cal_component_get_description_list (real_comp, &l); - cal_component_set_description_list (comp, l); - cal_component_free_text_list (l); + e_cal_component_get_summary (real_comp, &text); + e_cal_component_set_summary (comp, &text); + e_cal_component_get_location (real_comp, &string); + e_cal_component_set_location (comp, string); + e_cal_component_get_description_list (real_comp, &l); + e_cal_component_set_description_list (comp, l); + e_cal_component_free_text_list (l); g_object_unref (real_comp); } else { - CalComponentText text = {_("Unknown"), NULL}; + ECalComponentText text = {_("Unknown"), NULL}; - cal_component_set_summary (comp, &text); + e_cal_component_set_summary (comp, &text); } } @@ -1435,7 +1435,7 @@ static void show_current (EItipControl *itip) { EItipControlPrivate *priv; - CalComponentVType type; + ECalComponentVType type; icalcomponent *alarm_comp; icalcompiter alarm_iter; icalproperty *prop; @@ -1479,8 +1479,8 @@ show_current (EItipControl *itip) icalcompiter_next (&alarm_iter); } - priv->comp = cal_component_new (); - if (!cal_component_set_icalcomponent (priv->comp, priv->ical_comp)) { + priv->comp = e_cal_component_new (); + if (!e_cal_component_set_icalcomponent (priv->comp, priv->ical_comp)) { write_error_html (itip, _("The message does not appear to be properly formed")); g_object_unref (priv->comp); priv->comp = NULL; @@ -1490,19 +1490,19 @@ show_current (EItipControl *itip) /* Add default reminder if the config says so */ if (calendar_config_get_use_default_reminder ()) { - CalComponentAlarm *acomp; + ECalComponentAlarm *acomp; int interval; CalUnits units; - CalAlarmTrigger trigger; + ECalComponentAlarmTrigger trigger; interval = calendar_config_get_default_reminder_interval (); units = calendar_config_get_default_reminder_units (); - acomp = cal_component_alarm_new (); + acomp = e_cal_component_alarm_new (); - cal_component_alarm_set_action (acomp, CAL_ALARM_DISPLAY); + e_cal_component_alarm_set_action (acomp, E_CAL_COMPONENT_ALARM_DISPLAY); - trigger.type = CAL_ALARM_TRIGGER_RELATIVE_START; + trigger.type = E_CAL_COMPONENT_ALARM_TRIGGER_RELATIVE_START; memset (&trigger.u.rel_duration, 0, sizeof (trigger.u.rel_duration)); trigger.u.rel_duration.is_neg = TRUE; @@ -1521,16 +1521,16 @@ show_current (EItipControl *itip) g_assert_not_reached (); } - cal_component_alarm_set_trigger (acomp, trigger); - cal_component_add_alarm (priv->comp, acomp); + e_cal_component_alarm_set_trigger (acomp, trigger); + e_cal_component_add_alarm (priv->comp, acomp); - cal_component_alarm_free (acomp); + e_cal_component_alarm_free (acomp); } - type = cal_component_get_vtype (priv->comp); + type = e_cal_component_get_vtype (priv->comp); switch (type) { - case CAL_COMPONENT_EVENT: + case E_CAL_COMPONENT_EVENT: if (!priv->event_clients) { priv->event_clients = g_ptr_array_new (); /* EPFIXME */ @@ -1538,14 +1538,14 @@ show_current (EItipControl *itip) } show_current_event (itip); break; - case CAL_COMPONENT_TODO: + case E_CAL_COMPONENT_TODO: if (!priv->task_clients) { /* EPFIXME */ /* priv->task_clients = get_servers (itip, global_shell_client, tasks_types, TRUE); */ } show_current_todo (itip); break; - case CAL_COMPONENT_FREEBUSY: + case E_CAL_COMPONENT_FREEBUSY: show_current_freebusy (itip); break; default: @@ -1576,7 +1576,7 @@ e_itip_control_set_data (EItipControl *itip, const gchar *text) } priv->vcalendar = g_strdup (text); - priv->top_level = cal_util_new_top_level (); + priv->top_level = e_cal_util_new_top_level (); priv->main_comp = icalparser_parse_string (priv->vcalendar); if (priv->main_comp == NULL) { @@ -1818,8 +1818,8 @@ update_item (EItipControl *itip) struct icaltimetype stamp; icalproperty *prop; icalcomponent *clone; - CalClient *client; - CalComponentVType type; + ECal *client; + ECalComponentVType type; GtkWidget *dialog; priv = itip->priv; @@ -1838,8 +1838,8 @@ update_item (EItipControl *itip) icalproperty_set_x_name (prop, "X-MICROSOFT-CDO-REPLYTIME"); icalcomponent_add_property (priv->ical_comp, prop); - type = cal_component_get_vtype (priv->comp); - if (type == CAL_COMPONENT_TODO) + type = e_cal_component_get_vtype (priv->comp); + if (type == E_CAL_COMPONENT_TODO) client = priv->task_client; else client = priv->event_client; @@ -1849,7 +1849,7 @@ update_item (EItipControl *itip) icalcomponent_set_method (priv->top_level, priv->method); /* FIXME Better error dialog */ - if (!cal_client_receive_objects (client, priv->top_level, NULL)) { + if (!e_cal_receive_objects (client, priv->top_level, NULL)) { dialog = gnome_warning_dialog (_("Calendar file could not be updated!\n")); } else { dialog = gnome_ok_dialog (_("Update complete\n")); @@ -1864,19 +1864,19 @@ static void update_attendee_status (EItipControl *itip) { EItipControlPrivate *priv; - CalClient *client; - CalClientGetStatus status; - CalComponent *comp = NULL; + ECal *client; + ECalGetStatus status; + ECalComponent *comp = NULL; icalcomponent *icalcomp = NULL; - CalComponentVType type; + ECalComponentVType type; const char *uid; GtkWidget *dialog; - CalClientResult result; + ECalResult result; priv = itip->priv; - type = cal_component_get_vtype (priv->comp); - if (type == CAL_COMPONENT_TODO) + type = e_cal_component_get_vtype (priv->comp); + if (type == E_CAL_COMPONENT_TODO) client = priv->task_client; else client = priv->event_client; @@ -1888,21 +1888,21 @@ update_attendee_status (EItipControl *itip) } /* Obtain our version */ - cal_component_get_uid (priv->comp, &uid); - status = cal_client_get_object (client, uid, NULL, &icalcomp); + e_cal_component_get_uid (priv->comp, &uid); + status = e_cal_get_object (client, uid, NULL, &icalcomp); - if (status == CAL_CLIENT_GET_SUCCESS) { + if (status == E_CAL_GET_SUCCESS) { GSList *attendees; - comp = cal_component_new (); - if (!cal_component_set_icalcomponent (comp, icalcomp)) { + comp = e_cal_component_new (); + if (!e_cal_component_set_icalcomponent (comp, icalcomp)) { icalcomponent_free (icalcomp); dialog = gnome_warning_dialog (_("Object is invalid and cannot be updated\n")); } else { - cal_component_get_attendee_list (priv->comp, &attendees); + e_cal_component_get_attendee_list (priv->comp, &attendees); if (attendees != NULL) { - CalComponentAttendee *a = attendees->data; + ECalComponentAttendee *a = attendees->data; icalproperty *prop; prop = find_attendee (icalcomp, itip_strip_mailto (a->value)); @@ -1915,7 +1915,7 @@ update_attendee_status (EItipControl *itip) change_status (icalcomp, itip_strip_mailto (a->value), a->status); - cal_component_rescan (comp); + e_cal_component_rescan (comp); } else { goto cleanup; } @@ -1928,26 +1928,26 @@ update_attendee_status (EItipControl *itip) change_status (icalcomp, itip_strip_mailto (a->value), a->status); - cal_component_rescan (comp); + e_cal_component_rescan (comp); } } } - result = cal_client_update_object (client, comp); + result = e_cal_update_object (client, comp); switch (result) { - case CAL_CLIENT_RESULT_INVALID_OBJECT : + case E_CAL_RESULT_INVALID_OBJECT : dialog = gnome_warning_dialog (_("Object is invalid and cannot be updated\n")); break; - case CAL_CLIENT_RESULT_CORBA_ERROR : + case E_CAL_RESULT_CORBA_ERROR : dialog = gnome_warning_dialog (_("There was an error on the CORBA system\n")); break; - case CAL_CLIENT_RESULT_NOT_FOUND : + case E_CAL_RESULT_NOT_FOUND : dialog = gnome_warning_dialog (_("Object could not be found\n")); break; - case CAL_CLIENT_RESULT_PERMISSION_DENIED : + case E_CAL_RESULT_PERMISSION_DENIED : dialog = gnome_warning_dialog (_("You don't have the right permissions to update the calendar\n")); break; - case CAL_CLIENT_RESULT_SUCCESS : + case E_CAL_RESULT_SUCCESS : dialog = gnome_ok_dialog (_("Attendee status updated\n")); break; default : @@ -1969,16 +1969,16 @@ static void remove_item (EItipControl *itip) { EItipControlPrivate *priv; - CalClient *client; - CalComponentVType type; + ECal *client; + ECalComponentVType type; const char *uid; GtkWidget *dialog; GError *error = NULL; priv = itip->priv; - type = cal_component_get_vtype (priv->comp); - if (type == CAL_COMPONENT_TODO) + type = e_cal_component_get_vtype (priv->comp); + if (type == E_CAL_COMPONENT_TODO) client = priv->task_client; else client = priv->event_client; @@ -1986,8 +1986,8 @@ remove_item (EItipControl *itip) if (client == NULL) return; - cal_component_get_uid (priv->comp, &uid); - cal_client_remove_object (client, uid, &error); + e_cal_component_get_uid (priv->comp, &uid); + e_cal_remove_object (client, uid, &error); if (!error || error->code == E_CALENDAR_STATUS_OBJECT_NOT_FOUND) { dialog = gnome_ok_dialog (_("Removal Complete")); gnome_dialog_run_and_close (GNOME_DIALOG (dialog)); @@ -2002,25 +2002,25 @@ static void send_item (EItipControl *itip) { EItipControlPrivate *priv; - CalComponent *comp; - CalComponentVType vtype; + ECalComponent *comp; + ECalComponentVType vtype; GtkWidget *dialog; priv = itip->priv; comp = get_real_item (itip); - vtype = cal_component_get_vtype (comp); + vtype = e_cal_component_get_vtype (comp); if (comp != NULL) { switch (vtype) { - case CAL_COMPONENT_EVENT: - itip_send_comp (CAL_COMPONENT_METHOD_REQUEST, comp, priv->event_client, NULL); + case E_CAL_COMPONENT_EVENT: + itip_send_comp (E_CAL_COMPONENT_METHOD_REQUEST, comp, priv->event_client, NULL); break; - case CAL_COMPONENT_TODO: - itip_send_comp (CAL_COMPONENT_METHOD_REQUEST, comp, priv->task_client, NULL); + case E_CAL_COMPONENT_TODO: + itip_send_comp (E_CAL_COMPONENT_METHOD_REQUEST, comp, priv->task_client, NULL); break; default: - itip_send_comp (CAL_COMPONENT_METHOD_REQUEST, comp, NULL, NULL); + itip_send_comp (E_CAL_COMPONENT_METHOD_REQUEST, comp, NULL, NULL); } g_object_unref (comp); dialog = gnome_ok_dialog (_("Item sent!\n")); @@ -2034,7 +2034,7 @@ static void send_freebusy (EItipControl *itip) { EItipControlPrivate *priv; - CalComponentDateTime datetime; + ECalComponentDateTime datetime; time_t start, end; GtkWidget *dialog; GList *comp_list = NULL; @@ -2042,7 +2042,7 @@ send_freebusy (EItipControl *itip) priv = itip->priv; - cal_component_get_dtstart (priv->comp, &datetime); + e_cal_component_get_dtstart (priv->comp, &datetime); if (datetime.tzid) { zone = icalcomponent_get_timezone (priv->top_level, datetime.tzid); @@ -2050,9 +2050,9 @@ send_freebusy (EItipControl *itip) zone = NULL; } start = icaltime_as_timet_with_zone (*datetime.value, zone); - cal_component_free_datetime (&datetime); + e_cal_component_free_datetime (&datetime); - cal_component_get_dtend (priv->comp, &datetime); + e_cal_component_get_dtend (priv->comp, &datetime); if (datetime.tzid) { zone = icalcomponent_get_timezone (priv->top_level, datetime.tzid); @@ -2060,14 +2060,14 @@ send_freebusy (EItipControl *itip) zone = NULL; } end = icaltime_as_timet_with_zone (*datetime.value, zone); - cal_component_free_datetime (&datetime); + e_cal_component_free_datetime (&datetime); - if (cal_client_get_free_busy (priv->event_client, NULL, start, end, &comp_list, NULL)) { + if (e_cal_get_free_busy (priv->event_client, NULL, start, end, &comp_list, NULL)) { GList *l; for (l = comp_list; l; l = l->next) { - CalComponent *comp = CAL_COMPONENT (l->data); - itip_send_comp (CAL_COMPONENT_METHOD_REPLY, comp, priv->event_client, NULL); + ECalComponent *comp = E_CAL_COMPONENT (l->data); + itip_send_comp (E_CAL_COMPONENT_METHOD_REPLY, comp, priv->event_client, NULL); g_object_unref (comp); } @@ -2085,16 +2085,16 @@ button_selected_cb (EvolutionFolderSelectorButton *button, GNOME_Evolution_Folde { EItipControl *itip = E_ITIP_CONTROL (data); EItipControlPrivate *priv; - CalComponentVType type; + ECalComponentVType type; char *uri; priv = itip->priv; - type = cal_component_get_vtype (priv->comp); - if (type == CAL_COMPONENT_TODO) - uri = cal_util_expand_uri (folder->physicalUri, TRUE); + type = e_cal_component_get_vtype (priv->comp); + if (type == E_CAL_COMPONENT_TODO) + uri = e_cal_util_expand_uri (folder->physicalUri, TRUE); else - uri = cal_util_expand_uri (folder->physicalUri, FALSE); + uri = e_cal_util_expand_uri (folder->physicalUri, FALSE); g_object_unref (priv->event_client); priv->event_client = start_calendar_server (itip, uri); @@ -2137,21 +2137,21 @@ typedef struct { EItipControl *itip; GtkHTMLEmbedded *eb; - CalClient *client; + ECal *client; } ObjectRequestContext; static void -default_server_started_cb (CalClient *client, CalClientOpenStatus status, gpointer data) +default_server_started_cb (ECal *client, ECalOpenStatus status, gpointer data) { ObjectRequestContext *context = data; EItipControlPrivate *priv; GtkWidget *button; - CalComponentVType vtype; + ECalComponentVType vtype; priv = context->itip->priv; - if (status != CAL_CLIENT_OPEN_SUCCESS || + if (status != E_CAL_OPEN_SUCCESS || context->itip->priv->destroyed || context->itip->priv->html == NULL) { g_object_unref (context->client); @@ -2161,17 +2161,17 @@ default_server_started_cb (CalClient *client, CalClientOpenStatus status, gpoint } priv->event_client = client; - vtype = cal_component_get_vtype (priv->comp); + vtype = e_cal_component_get_vtype (priv->comp); switch (vtype) { #if 0 /* EPFIXME */ - case CAL_COMPONENT_EVENT: + case E_CAL_COMPONENT_EVENT: button = evolution_folder_selector_button_new ( global_shell_client, _("Select Calendar Folder"), calendar_config_default_calendar_folder (), calendar_types); break; - case CAL_COMPONENT_TODO: + case E_CAL_COMPONENT_TODO: button = evolution_folder_selector_button_new ( global_shell_client, _("Select Tasks Folder"), calendar_config_default_tasks_folder (), @@ -2198,23 +2198,23 @@ object_requested_cb (GtkHTML *html, GtkHTMLEmbedded *eb, gpointer data) EItipControl *itip = E_ITIP_CONTROL (data); ObjectRequestContext *context; EItipControlPrivate *priv; - CalComponentVType vtype; + ECalComponentVType vtype; gboolean success; priv = itip->priv; - vtype = cal_component_get_vtype (priv->comp); + vtype = e_cal_component_get_vtype (priv->comp); context = g_new0 (ObjectRequestContext, 1); context->itip = itip; context->eb = eb; switch (vtype) { - case CAL_COMPONENT_EVENT: - context->client = cal_client_new ("", CALOBJ_TYPE_EVENT); + case E_CAL_COMPONENT_EVENT: + context->client = e_cal_new ("", CALOBJ_TYPE_EVENT); success = start_default_server (itip, context->client, FALSE); break; - case CAL_COMPONENT_TODO: - context->client = cal_client_new ("", CALOBJ_TYPE_TODO); + case E_CAL_COMPONENT_TODO: + context->client = e_cal_new ("", CALOBJ_TYPE_TODO); success = start_default_server (itip, context->client, TRUE); break; default: @@ -2262,7 +2262,7 @@ ok_clicked_cb (GtkHTML *html, const gchar *method, const gchar *url, const gchar status = change_status (priv->ical_comp, priv->my_address, ICAL_PARTSTAT_ACCEPTED); if (status) { - cal_component_rescan (priv->comp); + e_cal_component_rescan (priv->comp); update_item (itip); } break; @@ -2270,7 +2270,7 @@ ok_clicked_cb (GtkHTML *html, const gchar *method, const gchar *url, const gchar status = change_status (priv->ical_comp, priv->my_address, ICAL_PARTSTAT_TENTATIVE); if (status) { - cal_component_rescan (priv->comp); + e_cal_component_rescan (priv->comp); update_item (itip); } break; @@ -2278,7 +2278,7 @@ ok_clicked_cb (GtkHTML *html, const gchar *method, const gchar *url, const gchar status = change_status (priv->ical_comp, priv->my_address, ICAL_PARTSTAT_DECLINED); if (status) { - cal_component_rescan (priv->comp); + e_cal_component_rescan (priv->comp); remove_item (itip); } break; @@ -2308,24 +2308,24 @@ ok_clicked_cb (GtkHTML *html, const gchar *method, const gchar *url, const gchar g_strfreev (fields); if (rsvp && status) { - CalComponent *comp = NULL; - CalComponentVType vtype; + ECalComponent *comp = NULL; + ECalComponentVType vtype; icalcomponent *ical_comp; icalproperty *prop; icalvalue *value; const char *attendee; GSList *l, *list = NULL; - comp = cal_component_clone (priv->comp); + comp = e_cal_component_clone (priv->comp); if (comp == NULL) return; - vtype = cal_component_get_vtype (comp); + vtype = e_cal_component_get_vtype (comp); if (priv->my_address == NULL) find_my_address (itip, priv->ical_comp); g_assert (priv->my_address != NULL); - ical_comp = cal_component_get_icalcomponent (comp); + ical_comp = e_cal_component_get_icalcomponent (comp); for (prop = icalcomponent_get_first_property (ical_comp, ICAL_ATTENDEE_PROPERTY); prop != NULL; @@ -2353,18 +2353,18 @@ ok_clicked_cb (GtkHTML *html, const gchar *method, const gchar *url, const gchar } g_slist_free (list); - cal_component_rescan (comp); + e_cal_component_rescan (comp); switch (vtype) { - case CAL_COMPONENT_EVENT: - itip_send_comp (CAL_COMPONENT_METHOD_REPLY, comp, + case E_CAL_COMPONENT_EVENT: + itip_send_comp (E_CAL_COMPONENT_METHOD_REPLY, comp, priv->event_client, priv->top_level); break; - case CAL_COMPONENT_TODO: - itip_send_comp (CAL_COMPONENT_METHOD_REPLY, comp, + case E_CAL_COMPONENT_TODO: + itip_send_comp (E_CAL_COMPONENT_METHOD_REPLY, comp, priv->task_client, priv->top_level); break; default: - itip_send_comp (CAL_COMPONENT_METHOD_REPLY, comp, NULL, NULL); + itip_send_comp (E_CAL_COMPONENT_METHOD_REPLY, comp, NULL, NULL); } g_object_unref (comp); } diff --git a/calendar/gui/e-meeting-attendee.c b/calendar/gui/e-meeting-attendee.c index 8b988f085f..474cf7b1a4 100644 --- a/calendar/gui/e-meeting-attendee.c +++ b/calendar/gui/e-meeting-attendee.c @@ -199,7 +199,7 @@ e_meeting_attendee_new (void) } GObject * -e_meeting_attendee_new_from_cal_component_attendee (CalComponentAttendee *ca) +e_meeting_attendee_new_from_e_cal_component_attendee (ECalComponentAttendee *ca) { EMeetingAttendee *ia; @@ -220,15 +220,15 @@ e_meeting_attendee_new_from_cal_component_attendee (CalComponentAttendee *ca) return G_OBJECT (ia); } -CalComponentAttendee * -e_meeting_attendee_as_cal_component_attendee (EMeetingAttendee *ia) +ECalComponentAttendee * +e_meeting_attendee_as_e_cal_component_attendee (EMeetingAttendee *ia) { EMeetingAttendeePrivate *priv; - CalComponentAttendee *ca; + ECalComponentAttendee *ca; priv = ia->priv; - ca = g_new0 (CalComponentAttendee, 1); + ca = g_new0 (ECalComponentAttendee, 1); ca->value = priv->address; ca->member = string_is_set (priv->member) ? priv->member : NULL; diff --git a/calendar/gui/e-meeting-attendee.h b/calendar/gui/e-meeting-attendee.h index 5ddc9968b2..42c5e13c2e 100644 --- a/calendar/gui/e-meeting-attendee.h +++ b/calendar/gui/e-meeting-attendee.h @@ -28,7 +28,7 @@ #endif #include <gtk/gtk.h> -#include <cal-util/cal-component.h> +#include <libecal/e-cal-component.h> #include "e-meeting-types.h" #ifdef __cplusplus @@ -80,9 +80,9 @@ struct _EMeetingAttendeeClass { GType e_meeting_attendee_get_type (void); GObject *e_meeting_attendee_new (void); -GObject *e_meeting_attendee_new_from_cal_component_attendee (CalComponentAttendee *ca); +GObject *e_meeting_attendee_new_from_e_cal_component_attendee (ECalComponentAttendee *ca); -CalComponentAttendee *e_meeting_attendee_as_cal_component_attendee (EMeetingAttendee *ia); +ECalComponentAttendee *e_meeting_attendee_as_e_cal_component_attendee (EMeetingAttendee *ia); const gchar *e_meeting_attendee_get_address (EMeetingAttendee *ia); void e_meeting_attendee_set_address (EMeetingAttendee *ia, gchar *address); diff --git a/calendar/gui/e-meeting-list-view.c b/calendar/gui/e-meeting-list-view.c index 4de564ff22..903b16f126 100644 --- a/calendar/gui/e-meeting-list-view.c +++ b/calendar/gui/e-meeting-list-view.c @@ -34,11 +34,11 @@ #include <libgnome/gnome-i18n.h> #include <libgnome/gnome-util.h> #include <libgnomevfs/gnome-vfs.h> -#include <ebook/e-book.h> -#include <ebook/e-vcard.h> -#include <cal-util/cal-component.h> -#include <cal-util/cal-util.h> -#include <cal-util/timeutil.h> +#include <libebook/e-book.h> +#include <libebook/e-vcard.h> +#include <libecal/e-cal-component.h> +#include <libecal/e-cal-util.h> +#include <libecal/e-cal-time-util.h> #include "Evolution-Addressbook-SelectNames.h" #include "calendar-config.h" #include "e-meeting-list-view.h" @@ -318,7 +318,7 @@ process_section (EMeetingListView *view, EABDestination **cards, icalparameter_r name = eab_destination_get_name (cards[i]); /* Get the field as attendee from the backend */ - if (cal_client_get_ldap_attribute (e_meeting_store_get_cal_client (priv->store), + if (e_cal_get_ldap_attribute (e_meeting_store_get_e_cal (priv->store), &attr, NULL)) { /* FIXME this should be more general */ if (!g_ascii_strcasecmp (attr, "icscalendar")) { diff --git a/calendar/gui/e-meeting-model.c b/calendar/gui/e-meeting-model.c index 964102d512..1a67594eca 100644 --- a/calendar/gui/e-meeting-model.c +++ b/calendar/gui/e-meeting-model.c @@ -39,9 +39,9 @@ #include <ebook/e-book.h> #include <ebook/e-book-async.h> #include <ebook/e-contact.h> -#include <cal-util/cal-component.h> -#include <cal-util/cal-util.h> -#include <cal-util/timeutil.h> +#include <libecal/e-cal-component.h> +#include <libecal/e-cal-util.h> +#include <libecal/e-cal-time-util.h> #include "Evolution-Addressbook-SelectNames.h" #include "calendar-config.h" #include "itip-utils.h" @@ -57,7 +57,7 @@ struct _EMeetingModelPrivate GList *tables; - CalClient *client; + ECal *client; icaltimezone *zone; EBook *ebook; @@ -678,8 +678,8 @@ e_meeting_model_new (void) } -CalClient * -e_meeting_model_get_cal_client (EMeetingModel *im) +ECal * +e_meeting_model_get_e_cal (EMeetingModel *im) { EMeetingModelPrivate *priv; @@ -689,7 +689,7 @@ e_meeting_model_get_cal_client (EMeetingModel *im) } void -e_meeting_model_set_cal_client (EMeetingModel *im, CalClient *client) +e_meeting_model_set_e_cal (EMeetingModel *im, ECal *client) { EMeetingModelPrivate *priv; @@ -1234,7 +1234,7 @@ process_free_busy (EMeetingModelQueueData *qdata, char *text) icalcompiter iter; icalcomponent *tz_top_level, *sub_comp; - tz_top_level = cal_util_new_top_level (); + tz_top_level = e_cal_util_new_top_level (); iter = icalcomponent_begin_component (main_comp, ICAL_VTIMEZONE_COMPONENT); while ((sub_comp = icalcompiter_deref (&iter)) != NULL) { @@ -1407,16 +1407,16 @@ refresh_busy_periods (gpointer data) users = g_list_append (users, g_strdup (user)); /* FIXME Error checking */ - cal_client_get_free_busy (priv->client, users, startt, endt, &fb_data, NULL); + e_cal_get_free_busy (priv->client, users, startt, endt, &fb_data, NULL); g_list_foreach (users, (GFunc)g_free, NULL); g_list_free (users); if (fb_data != NULL) { - CalComponent *comp = fb_data->data; + ECalComponent *comp = fb_data->data; char *comp_str; - comp_str = cal_component_get_as_string (comp); + comp_str = e_cal_component_get_as_string (comp); process_free_busy (qdata, comp_str); g_free (comp_str); return TRUE; @@ -1660,7 +1660,7 @@ process_section (EMeetingModel *im, EABDestination **destv, icalparameter_role r name = eab_destination_get_name (dest); /* Get the field as attendee from the backend */ - if (cal_client_get_ldap_attribute (priv->client, &attr, NULL) && attr) { + if (e_cal_get_ldap_attribute (priv->client, &attr, NULL) && attr) { /* FIXME this should be more general */ if (!strcmp (attr, "icscalendar")) { EContact *contact = eab_destination_get_contact (dest); diff --git a/calendar/gui/e-meeting-model.h b/calendar/gui/e-meeting-model.h index 50fba6c7a6..e709cd3aa4 100644 --- a/calendar/gui/e-meeting-model.h +++ b/calendar/gui/e-meeting-model.h @@ -26,7 +26,7 @@ #include <gtk/gtk.h> #include <gal/e-table/e-table-scrolled.h> #include <gal/e-table/e-table-model.h> -#include <cal-client/cal-client.h> +#include <libecal/e-cal.h> #include "e-meeting-attendee.h" G_BEGIN_DECLS @@ -72,8 +72,8 @@ typedef void (* EMeetingModelRefreshCallback) (gpointer data); GtkType e_meeting_model_get_type (void); GtkObject *e_meeting_model_new (void); -CalClient *e_meeting_model_get_cal_client (EMeetingModel *im); -void e_meeting_model_set_cal_client (EMeetingModel *im, CalClient *client); +ECal *e_meeting_model_get_e_cal (EMeetingModel *im); +void e_meeting_model_set_e_cal (EMeetingModel *im, ECal *client); icaltimezone *e_meeting_model_get_zone (EMeetingModel *im); void e_meeting_model_set_zone (EMeetingModel *im, icaltimezone *zone); diff --git a/calendar/gui/e-meeting-store.c b/calendar/gui/e-meeting-store.c index 6064971d9f..2bbaff4bec 100644 --- a/calendar/gui/e-meeting-store.c +++ b/calendar/gui/e-meeting-store.c @@ -29,10 +29,10 @@ #include <libgnome/gnome-i18n.h> #include <libgnome/gnome-util.h> #include <libgnomevfs/gnome-vfs.h> -#include <ebook/e-book.h> -#include <cal-util/cal-component.h> -#include <cal-util/cal-util.h> -#include <cal-util/timeutil.h> +#include <libebook/e-book.h> +#include <libecal/e-cal-component.h> +#include <libecal/e-cal-util.h> +#include <libecal/e-cal-time-util.h> #include "calendar-config.h" #include "itip-utils.h" #include "e-meeting-utils.h" @@ -45,7 +45,7 @@ struct _EMeetingStorePrivate { GPtrArray *attendees; gint stamp; - CalClient *client; + ECal *client; icaltimezone *zone; EBook *ebook; @@ -667,14 +667,14 @@ e_meeting_store_new (void) } -CalClient * -e_meeting_store_get_cal_client (EMeetingStore *store) +ECal * +e_meeting_store_get_e_cal (EMeetingStore *store) { return store->priv->client; } void -e_meeting_store_set_cal_client (EMeetingStore *store, CalClient *client) +e_meeting_store_set_e_cal (EMeetingStore *store, ECal *client) { if (store->priv->client != NULL) g_object_unref (store->priv->client); @@ -1057,7 +1057,7 @@ process_free_busy (EMeetingStoreQueueData *qdata, char *text) icalcompiter iter; icalcomponent *tz_top_level, *sub_comp; - tz_top_level = cal_util_new_top_level (); + tz_top_level = e_cal_util_new_top_level (); iter = icalcomponent_begin_component (main_comp, ICAL_VTIMEZONE_COMPONENT); while ((sub_comp = icalcompiter_deref (&iter)) != NULL) { @@ -1147,16 +1147,16 @@ refresh_busy_periods (gpointer data) user = itip_strip_mailto (e_meeting_attendee_get_address (attendee)); users = g_list_append (users, g_strdup (user)); - cal_client_get_free_busy (priv->client, users, startt, endt, &fb_data, NULL); + e_cal_get_free_busy (priv->client, users, startt, endt, &fb_data, NULL); g_list_foreach (users, (GFunc)g_free, NULL); g_list_free (users); if (fb_data != NULL) { - CalComponent *comp = fb_data->data; + ECalComponent *comp = fb_data->data; char *comp_str; - comp_str = cal_component_get_as_string (comp); + comp_str = e_cal_component_get_as_string (comp); process_free_busy (qdata, comp_str); g_free (comp_str); return TRUE; diff --git a/calendar/gui/e-meeting-store.h b/calendar/gui/e-meeting-store.h index e5e518289d..8454c380b0 100644 --- a/calendar/gui/e-meeting-store.h +++ b/calendar/gui/e-meeting-store.h @@ -24,7 +24,7 @@ #define _E_MEETING_STORE_H_ #include <gtk/gtkliststore.h> -#include <cal-client/cal-client.h> +#include <libecal/e-cal.h> #include "e-meeting-attendee.h" G_BEGIN_DECLS @@ -72,8 +72,8 @@ GObject *e_meeting_store_new (void); void e_meeting_store_set_value (EMeetingStore *im, int row, int col, const gchar *val); -CalClient *e_meeting_store_get_cal_client (EMeetingStore *im); -void e_meeting_store_set_cal_client (EMeetingStore *im, CalClient *client); +ECal *e_meeting_store_get_e_cal (EMeetingStore *im); +void e_meeting_store_set_e_cal (EMeetingStore *im, ECal *client); icaltimezone *e_meeting_store_get_zone (EMeetingStore *im); void e_meeting_store_set_zone (EMeetingStore *im, icaltimezone *zone); diff --git a/calendar/gui/e-select-names-renderer.c b/calendar/gui/e-select-names-renderer.c index 9b325d6ac0..fbda387d23 100644 --- a/calendar/gui/e-select-names-renderer.c +++ b/calendar/gui/e-select-names-renderer.c @@ -24,7 +24,7 @@ #include <gtk/gtkcellrenderertext.h> #include <gal/util/e-util.h> -#include "cal-util/cal-util-marshal.h" +#include "e-calendar-marshal.h" #include "e-select-names-editable.h" #include "e-select-names-renderer.h" @@ -161,7 +161,7 @@ esnr_class_init (ESelectNamesRendererClass *class) G_SIGNAL_RUN_LAST, G_STRUCT_OFFSET (ESelectNamesRendererClass, cell_edited), NULL, NULL, - cal_util_marshal_VOID__STRING_STRING_STRING, + e_calendar_marshal_VOID__STRING_STRING_STRING, G_TYPE_NONE, 3, G_TYPE_STRING, G_TYPE_STRING, G_TYPE_STRING); } diff --git a/calendar/gui/e-tasks.c b/calendar/gui/e-tasks.c index d094b3af56..a5b9eac4e8 100644 --- a/calendar/gui/e-tasks.c +++ b/calendar/gui/e-tasks.c @@ -36,7 +36,7 @@ #include "e-util/e-categories-config.h" #include "e-util/e-time-utils.h" #include "e-util/e-url.h" -#include "cal-util/timeutil.h" +#include <libecal/e-cal-time-util.h> #include "widgets/menus/gal-view-menus.h" #include "dialogs/delete-error.h" #include "dialogs/task-editor.h" @@ -53,8 +53,8 @@ /* Private part of the GnomeCalendar structure */ struct _ETasksPrivate { /* The calendar client object we monitor */ - CalClient *client; - CalQuery *query; + ECal *client; + ECalView *query; /* The ECalendarTable showing the tasks. */ GtkWidget *tasks_view; @@ -80,8 +80,8 @@ static void e_tasks_init (ETasks *tasks); static void setup_widgets (ETasks *tasks); static void e_tasks_destroy (GtkObject *object); -static void cal_opened_cb (CalClient *client, CalClientOpenStatus status, gpointer data); -static void backend_error_cb (CalClient *client, const char *message, gpointer data); +static void cal_opened_cb (ECal *client, ECalOpenStatus status, gpointer data); +static void backend_error_cb (ECal *client, const char *message, gpointer data); /* Signal IDs */ enum { @@ -117,17 +117,17 @@ timet_to_str_with_zone (time_t t, icaltimezone *zone) } static void -write_html (GtkHTMLStream *stream, CalComponent *comp) +write_html (GtkHTMLStream *stream, ECalComponent *comp) { - CalComponentText text; - CalComponentDateTime dt; + ECalComponentText text; + ECalComponentDateTime dt; gchar *buf, *str; icaltimezone *current_zone; GSList *l; icalproperty_status status; int *priority_value; - g_return_if_fail (IS_CAL_COMPONENT (comp)); + g_return_if_fail (E_IS_CAL_COMPONENT (comp)); str = calendar_config_get_timezone (); if (str && str[0]) { @@ -136,13 +136,13 @@ write_html (GtkHTMLStream *stream, CalComponent *comp) current_zone = icaltimezone_get_utc_timezone (); /* write document header */ - cal_component_get_summary (comp, &text); + e_cal_component_get_summary (comp, &text); gtk_html_stream_printf (stream, "<HTML><BODY><H1>%s</H1>", text.value); /* write icons for the categories */ - cal_component_get_categories_list (comp, &l); + e_cal_component_get_categories_list (comp, &l); if (l) { GSList *node; @@ -156,7 +156,7 @@ write_html (GtkHTMLStream *stream, CalComponent *comp) } } - cal_component_free_categories_list (l); + e_cal_component_free_categories_list (l); } /* write summary */ @@ -166,7 +166,7 @@ write_html (GtkHTMLStream *stream, CalComponent *comp) _("Summary:"), text.value); /* write start date */ - cal_component_get_dtstart (comp, &dt); + e_cal_component_get_dtstart (comp, &dt); if (dt.value != NULL) { buf = timet_to_str_with_zone (icaltime_as_timet (*dt.value), current_zone); str = g_locale_to_utf8 (buf, -1, NULL, NULL, NULL); @@ -178,11 +178,11 @@ write_html (GtkHTMLStream *stream, CalComponent *comp) gtk_html_stream_printf (stream, "<TR><TD VALIGN=\"TOP\" ALIGN=\"RIGHT\"><B>%s</B></TD><TD>%s</TD></TR>", _("Start Date:"), str); - cal_component_free_datetime (&dt); + e_cal_component_free_datetime (&dt); g_free (str); /* write Due Date */ - cal_component_get_due (comp, &dt); + e_cal_component_get_due (comp, &dt); if (dt.value != NULL) { buf = timet_to_str_with_zone (icaltime_as_timet (*dt.value), current_zone); str = g_locale_to_utf8 (buf, -1, NULL, NULL, NULL); @@ -194,12 +194,12 @@ write_html (GtkHTMLStream *stream, CalComponent *comp) gtk_html_stream_printf (stream, "<TR><TD VALIGN=\"TOP\" ALIGN=\"RIGHT\"><B>%s</B></TD><TD>%s</TD></TR>", _("Due Date:"), str); - cal_component_free_datetime (&dt); + e_cal_component_free_datetime (&dt); g_free (str); /* write status */ gtk_html_stream_printf (stream, "<TR><TD VALIGN=\"TOP\" ALIGN=\"RIGHT\"><B>%s</B></TD>", _("Status:")); - cal_component_get_status (comp, &status); + e_cal_component_get_status (comp, &status); switch (status) { case ICAL_STATUS_INPROCESS : str = g_strdup (_("In Progress")); @@ -221,7 +221,7 @@ write_html (GtkHTMLStream *stream, CalComponent *comp) /* write priority */ gtk_html_stream_printf (stream, "<TR><TD VALIGN=\"TOP\" ALIGN=\"RIGHT\"><B>%s</B></TD>", _("Priority:")); - cal_component_get_priority (comp, &priority_value); + e_cal_component_get_priority (comp, &priority_value); if (priority_value) { if (*priority_value == 0) str = g_strdup (""); @@ -235,7 +235,7 @@ write_html (GtkHTMLStream *stream, CalComponent *comp) gtk_html_stream_printf (stream, "<TD>%s</TD></TR>", str); g_free (str); - cal_component_free_priority (priority_value); + e_cal_component_free_priority (priority_value); } else gtk_html_stream_printf (stream, "<TD></TD></TR>"); @@ -243,7 +243,7 @@ write_html (GtkHTMLStream *stream, CalComponent *comp) gtk_html_stream_printf (stream, "<TR><TD COLSPAN=\"2\"><HR></TD></TR>"); gtk_html_stream_printf (stream, "<TR><TD VALIGN=\"TOP\" ALIGN=\"RIGHT\"><B>%s</B></TD>", _("Description:")); - cal_component_get_description_list (comp, &l); + e_cal_component_get_description_list (comp, &l); if (l) { GSList *node; @@ -253,7 +253,7 @@ write_html (GtkHTMLStream *stream, CalComponent *comp) gint i; GString *str = g_string_new ("");; - text = * (CalComponentText *) node->data; + text = * (ECalComponentText *) node->data; for (i = 0; i < strlen (text.value ? text.value : 0); i++) { if (text.value[i] == '\n') str = g_string_append (str, "<BR>"); @@ -271,13 +271,13 @@ write_html (GtkHTMLStream *stream, CalComponent *comp) gtk_html_stream_printf (stream, "</TD></TR>"); - cal_component_free_text_list (l); + e_cal_component_free_text_list (l); } else gtk_html_stream_printf (stream, "<TD></TD></TR>"); /* URL */ gtk_html_stream_printf (stream, "<TR><TD VALIGN=\"TOP\" ALIGN=\"RIGHT\"><B>%s</B></TD>", _("Web Page:")); - cal_component_get_url (comp, (const char **) &str); + e_cal_component_get_url (comp, (const char **) &str); if (str) gtk_html_stream_printf (stream, "<TD><A HREF=\"%s\">%s</A></TD></TR>", str, str); else @@ -320,7 +320,7 @@ table_cursor_change_cb (ETable *etable, int row, gpointer data) GtkHTMLStream *stream; ECalModel *model; ECalModelComponent *comp_data; - CalComponent *comp; + ECalComponent *comp; const char *uid; model = e_calendar_table_get_model (E_CALENDAR_TABLE (priv->tasks_view)); @@ -328,13 +328,13 @@ table_cursor_change_cb (ETable *etable, int row, gpointer data) stream = gtk_html_begin (GTK_HTML (priv->html)); comp_data = e_cal_model_get_component_at (model, e_table_get_cursor_row (etable)); - comp = cal_component_new (); - cal_component_set_icalcomponent (comp, icalcomponent_new_clone (comp_data->icalcomp)); + comp = e_cal_component_new (); + e_cal_component_set_icalcomponent (comp, icalcomponent_new_clone (comp_data->icalcomp)); write_html (stream, comp); gtk_html_stream_close (stream, GTK_HTML_STREAM_OK); - cal_component_get_uid (comp, &uid); + e_cal_component_get_uid (comp, &uid); if (priv->current_uid) g_free (priv->current_uid); priv->current_uid = g_strdup (uid); @@ -435,9 +435,9 @@ set_timezone (ETasks *tasks) if (!zone) zone = icaltimezone_get_utc_timezone (); - if (cal_client_get_load_state (priv->client) == CAL_CLIENT_LOAD_LOADED) + if (e_cal_get_load_state (priv->client) == E_CAL_LOAD_LOADED) /* FIXME Error checking */ - cal_client_set_default_timezone (priv->client, zone, NULL); + e_cal_set_default_timezone (priv->client, zone, NULL); } static void @@ -581,7 +581,7 @@ e_tasks_init (ETasks *tasks) /* Callback used when the set of categories changes in the calendar client */ static void -client_categories_changed_cb (CalClient *client, GPtrArray *categories, gpointer data) +client_categories_changed_cb (ECal *client, GPtrArray *categories, gpointer data) { ETasks *tasks; ETasksPrivate *priv; @@ -593,7 +593,7 @@ client_categories_changed_cb (CalClient *client, GPtrArray *categories, gpointer } static void -client_obj_updated_cb (CalClient *client, const char *uid, gpointer data) +client_obj_updated_cb (ECal *client, const char *uid, gpointer data) { ETasks *tasks; ETasksPrivate *priv; @@ -717,8 +717,8 @@ e_tasks_open (ETasks *tasks, g_free (message); g_free (urinopwd); - /* create the CalClient */ - priv->client = cal_client_new (real_uri, CALOBJ_TYPE_TODO); + /* create the ECal */ + priv->client = e_cal_new (real_uri, CALOBJ_TYPE_TODO); if (!priv->client) return FALSE; @@ -736,7 +736,7 @@ e_tasks_open (ETasks *tasks, e_cal_model_add_client (model, priv->client); - if (cal_client_open (priv->client, FALSE, &error)) { + if (e_cal_open (priv->client, FALSE, &error)) { g_message ("e_tasks_open(): %s", error->message); g_free (real_uri); e_uri_free (uri); @@ -798,8 +798,8 @@ permission_error (ETasks *tasks, const char *uri) /* Callback from the calendar client when a calendar is opened */ static void -cal_opened_cb (CalClient *client, - CalClientOpenStatus status, +cal_opened_cb (ECal *client, + ECalOpenStatus status, gpointer data) { ETasks *tasks; @@ -811,26 +811,26 @@ cal_opened_cb (CalClient *client, set_status_message (tasks, NULL); switch (status) { - case CAL_CLIENT_OPEN_SUCCESS: + case E_CAL_OPEN_SUCCESS: /* Everything is OK */ set_timezone (tasks); return; - case CAL_CLIENT_OPEN_ERROR: - load_error (tasks, cal_client_get_uri (client)); + case E_CAL_OPEN_ERROR: + load_error (tasks, e_cal_get_uri (client)); break; - case CAL_CLIENT_OPEN_NOT_FOUND: + case E_CAL_OPEN_NOT_FOUND: /* bullshit; we did not specify only_if_exists */ g_assert_not_reached (); return; - case CAL_CLIENT_OPEN_METHOD_NOT_SUPPORTED: - method_error (tasks, cal_client_get_uri (client)); + case E_CAL_OPEN_METHOD_NOT_SUPPORTED: + method_error (tasks, e_cal_get_uri (client)); break; - case CAL_CLIENT_OPEN_PERMISSION_DENIED: - permission_error (tasks, cal_client_get_uri (client)); + case E_CAL_OPEN_PERMISSION_DENIED: + permission_error (tasks, e_cal_get_uri (client)); break; default: @@ -840,7 +840,7 @@ cal_opened_cb (CalClient *client, /* Callback from the calendar client when an error occurs in the backend */ static void -backend_error_cb (CalClient *client, const char *message, gpointer data) +backend_error_cb (ECal *client, const char *message, gpointer data) { ETasks *tasks; ETasksPrivate *priv; @@ -850,7 +850,7 @@ backend_error_cb (CalClient *client, const char *message, gpointer data) tasks = E_TASKS (data); priv = tasks->priv; - urinopwd = get_uri_without_password (cal_client_get_uri (client)); + urinopwd = get_uri_without_password (e_cal_get_uri (client)); errmsg = g_strdup_printf (_("Error on %s:\n %s"), urinopwd, message); gnome_error_dialog_parented (errmsg, GTK_WINDOW (gtk_widget_get_toplevel (GTK_WIDGET (tasks)))); g_free (errmsg); @@ -862,7 +862,7 @@ e_tasks_new_task (ETasks *tasks) { ETasksPrivate *priv; TaskEditor *tedit; - CalComponent *comp; + ECalComponent *comp; const char *category; g_return_if_fail (E_IS_TASKS (tasks)); @@ -874,7 +874,7 @@ e_tasks_new_task (ETasks *tasks) comp = cal_comp_task_new_with_defaults (priv->client); category = cal_search_bar_get_category (CAL_SEARCH_BAR (priv->search_bar)); - cal_component_set_categories (comp, category); + e_cal_component_set_categories (comp, category); comp_editor_edit_comp (COMP_EDITOR (tedit), comp); g_object_unref (comp); @@ -966,7 +966,7 @@ e_tasks_delete_completed (ETasks *tasks) set_status_message (tasks, _("Expunging")); - if (!cal_client_get_object_list (priv->client, sexp, &objects, NULL)) { + if (!e_cal_get_object_list (priv->client, sexp, &objects, NULL)) { set_status_message (tasks, NULL); g_warning (G_STRLOC ": Could not get the objects"); @@ -975,7 +975,7 @@ e_tasks_delete_completed (ETasks *tasks) for (l = objects; l; l = l->next) { /* FIXME Better error handling */ - cal_client_remove_object (priv->client, icalcomponent_get_uid (l->data), NULL); + e_cal_remove_object (priv->client, icalcomponent_get_uid (l->data), NULL); } set_status_message (tasks, NULL); @@ -1053,7 +1053,7 @@ e_tasks_setup_view_menus (ETasks *tasks, BonoboUIComponent *uic) gal_view_collection_load (collection); } - priv->view_instance = gal_view_instance_new (collection, cal_client_get_uri (priv->client)); + priv->view_instance = gal_view_instance_new (collection, e_cal_get_uri (priv->client)); priv->view_menus = gal_view_menus_new (priv->view_instance); gal_view_menus_apply (priv->view_menus, uic, NULL); diff --git a/calendar/gui/e-tasks.h b/calendar/gui/e-tasks.h index efa2ea2d1e..a1cfc0612b 100644 --- a/calendar/gui/e-tasks.h +++ b/calendar/gui/e-tasks.h @@ -27,7 +27,7 @@ #include <bonobo/bonobo-ui-component.h> #include <gtk/gtktable.h> -#include <cal-client/cal-client.h> +#include <libecal/e-cal.h> #include "e-calendar-table.h" #define E_TYPE_TASKS (e_tasks_get_type ()) diff --git a/calendar/gui/e-timezone-entry.h b/calendar/gui/e-timezone-entry.h index 4f94cd88a1..94a7df9efc 100644 --- a/calendar/gui/e-timezone-entry.h +++ b/calendar/gui/e-timezone-entry.h @@ -33,7 +33,7 @@ #define __E_TIMEZONE_ENTRY_H_ #include <gtk/gtkhbox.h> -#include <cal-client/cal-client.h> +#include <libecal/e-cal.h> G_BEGIN_DECLS diff --git a/calendar/gui/e-week-view-config.c b/calendar/gui/e-week-view-config.c index 097d86dd92..1257813062 100644 --- a/calendar/gui/e-week-view-config.c +++ b/calendar/gui/e-week-view-config.c @@ -167,7 +167,7 @@ set_timezone (EWeekView *week_view) if (!zone) zone = icaltimezone_get_utc_timezone (); - e_cal_view_set_timezone (E_CAL_VIEW (week_view), zone); + e_calendar_view_set_timezone (E_CALENDAR_VIEW (week_view), zone); g_free (location); } @@ -214,7 +214,7 @@ set_twentyfour_hour (EWeekView *week_view) use_24_hour = calendar_config_get_24_hour_format (); - e_cal_view_set_use_24_hour_format (E_CAL_VIEW (week_view), use_24_hour); + e_calendar_view_set_use_24_hour_format (E_CALENDAR_VIEW (week_view), use_24_hour); } static void diff --git a/calendar/gui/e-week-view-event-item.c b/calendar/gui/e-week-view-event-item.c index a534943d75..85e1cf775a 100644 --- a/calendar/gui/e-week-view-event-item.c +++ b/calendar/gui/e-week-view-event-item.c @@ -84,7 +84,7 @@ static gboolean e_week_view_event_item_button_release (EWeekViewEventItem *wveit GdkEvent *event); static gboolean e_week_view_event_item_double_click (EWeekViewEventItem *wveitem, GdkEvent *bevent); -static ECalViewPosition e_week_view_event_item_get_position (EWeekViewEventItem *wveitem, +static ECalendarViewPosition e_week_view_event_item_get_position (EWeekViewEventItem *wveitem, gdouble x, gdouble y); @@ -287,7 +287,7 @@ e_week_view_event_item_draw (GnomeCanvasItem *canvas_item, rect_x = x1 + E_WEEK_VIEW_EVENT_L_PAD; rect_w = x2 - x1 - E_WEEK_VIEW_EVENT_L_PAD - E_WEEK_VIEW_EVENT_R_PAD + 1; - if (gdk_color_parse (e_cal_model_get_color_for_component (e_cal_view_get_model (E_CAL_VIEW (week_view)), + if (gdk_color_parse (e_cal_model_get_color_for_component (e_calendar_view_get_model (E_CALENDAR_VIEW (week_view)), event->comp_data), &bg_color)) { GdkColormap *colormap; @@ -377,7 +377,7 @@ e_week_view_event_item_draw (GnomeCanvasItem *canvas_item, rect_w -= 2; } - if (gdk_color_parse (e_cal_model_get_color_for_component (e_cal_view_get_model (E_CAL_VIEW (week_view)), + if (gdk_color_parse (e_cal_model_get_color_for_component (e_calendar_view_get_model (E_CALENDAR_VIEW (week_view)), event->comp_data), &bg_color)) { GdkColormap *colormap; @@ -550,7 +550,7 @@ e_week_view_draw_time (EWeekView *week_view, time_x += week_view->small_digit_width * 2; /* Draw the 'am'/'pm' suffix, if 12-hour format. */ - if (!e_cal_view_get_use_24_hour_format (E_CAL_VIEW (week_view))) { + if (!e_calendar_view_get_use_24_hour_format (E_CALENDAR_VIEW (week_view))) { pango_layout_set_text (layout, suffix, -1); gdk_draw_layout (drawable, gc, time_x, @@ -592,7 +592,7 @@ e_week_view_event_item_draw_icons (EWeekViewEventItem *wveitem, EWeekView *week_view; EWeekViewEvent *event; EWeekViewEventSpan *span; - CalComponent *comp; + ECalComponent *comp; GdkGC *gc; gint num_icons = 0, icon_x_inc; gboolean draw_reminder_icon = FALSE, draw_recurrence_icon = FALSE; @@ -605,17 +605,17 @@ e_week_view_event_item_draw_icons (EWeekViewEventItem *wveitem, wveitem->event_num); span = &g_array_index (week_view->spans, EWeekViewEventSpan, event->spans_index + wveitem->span_num); - comp = cal_component_new (); - cal_component_set_icalcomponent (comp, icalcomponent_new_clone (event->comp_data->icalcomp)); + comp = e_cal_component_new (); + e_cal_component_set_icalcomponent (comp, icalcomponent_new_clone (event->comp_data->icalcomp)); gc = week_view->main_gc; - if (cal_component_has_alarms (comp)) { + if (e_cal_component_has_alarms (comp)) { draw_reminder_icon = TRUE; num_icons++; } - if (cal_component_has_recurrences (comp)) { + if (e_cal_component_has_recurrences (comp)) { draw_recurrence_icon = TRUE; num_icons++; } @@ -625,7 +625,7 @@ e_week_view_event_item_draw_icons (EWeekViewEventItem *wveitem, num_icons++; } - cal_component_get_categories_list (comp, &categories_list); + e_cal_component_get_categories_list (comp, &categories_list); for (elem = categories_list; elem; elem = elem->next) { char *category; GdkPixmap *pixmap = NULL; @@ -700,7 +700,7 @@ e_week_view_event_item_draw_icons (EWeekViewEventItem *wveitem, gdk_bitmap_unref (mask); } - cal_component_free_categories_list (categories_list); + e_cal_component_free_categories_list (categories_list); gdk_gc_set_clip_mask (gc, NULL); } @@ -790,7 +790,7 @@ e_week_view_event_item_button_press (EWeekViewEventItem *wveitem, GdkEvent *bevent) { EWeekView *week_view; - ECalViewPosition pos; + ECalendarViewPosition pos; EWeekViewEvent *event; EWeekViewEventSpan *span; GnomeCanvasItem *item; @@ -811,7 +811,7 @@ e_week_view_event_item_button_press (EWeekViewEventItem *wveitem, pos = e_week_view_event_item_get_position (wveitem, bevent->button.x, bevent->button.y); - if (pos == E_CAL_VIEW_POS_NONE) + if (pos == E_CALENDAR_VIEW_POS_NONE) return FALSE; if (bevent->button.button == 1) { @@ -901,13 +901,13 @@ e_week_view_event_item_double_click (EWeekViewEventItem *wveitem, e_week_view_stop_editing_event (week_view); - e_cal_view_edit_appointment (E_CAL_VIEW (week_view), event->comp_data->client, event->comp_data->icalcomp, FALSE); + e_calendar_view_edit_appointment (E_CALENDAR_VIEW (week_view), event->comp_data->client, event->comp_data->icalcomp, FALSE); return TRUE; } -static ECalViewPosition +static ECalendarViewPosition e_week_view_event_item_get_position (EWeekViewEventItem *wveitem, gdouble x, gdouble y) @@ -918,7 +918,7 @@ e_week_view_event_item_get_position (EWeekViewEventItem *wveitem, item = GNOME_CANVAS_ITEM (wveitem); week_view = E_WEEK_VIEW (GTK_WIDGET (item->canvas)->parent); - g_return_val_if_fail (E_IS_WEEK_VIEW (week_view), E_CAL_VIEW_POS_NONE); + g_return_val_if_fail (E_IS_WEEK_VIEW (week_view), E_CALENDAR_VIEW_POS_NONE); #if 0 g_print ("In e_week_view_event_item_get_position item: %g,%g %g,%g point: %g,%g\n", item->x1, item->y1, item->x2, item->y2, x, y); @@ -926,20 +926,20 @@ e_week_view_event_item_get_position (EWeekViewEventItem *wveitem, if (x < item->x1 + E_WEEK_VIEW_EVENT_L_PAD || x >= item->x2 - E_WEEK_VIEW_EVENT_R_PAD) - return E_CAL_VIEW_POS_NONE; + return E_CALENDAR_VIEW_POS_NONE; /* Support left/right edge for long events only. */ if (!e_week_view_is_one_day_event (week_view, wveitem->event_num)) { if (x < item->x1 + E_WEEK_VIEW_EVENT_L_PAD + E_WEEK_VIEW_EVENT_BORDER_WIDTH + E_WEEK_VIEW_EVENT_EDGE_X_PAD) - return E_CAL_VIEW_POS_LEFT_EDGE; + return E_CALENDAR_VIEW_POS_LEFT_EDGE; if (x >= item->x2 + 1 - E_WEEK_VIEW_EVENT_R_PAD - E_WEEK_VIEW_EVENT_BORDER_WIDTH - E_WEEK_VIEW_EVENT_EDGE_X_PAD) - return E_CAL_VIEW_POS_RIGHT_EDGE; + return E_CALENDAR_VIEW_POS_RIGHT_EDGE; } - return E_CAL_VIEW_POS_EVENT; + return E_CALENDAR_VIEW_POS_EVENT; } diff --git a/calendar/gui/e-week-view-main-item.c b/calendar/gui/e-week-view-main-item.c index ca80da28c3..ed823c2dcd 100644 --- a/calendar/gui/e-week-view-main-item.c +++ b/calendar/gui/e-week-view-main-item.c @@ -346,7 +346,7 @@ e_week_view_main_item_draw_day (EWeekViewMainItem *wvmitem, /* Check if we are drawing today */ tt = icaltime_from_timet_with_zone (time (NULL), FALSE, - e_cal_view_get_timezone (E_CAL_VIEW (week_view))); + e_calendar_view_get_timezone (E_CALENDAR_VIEW (week_view))); if (g_date_year (date) == tt.year && g_date_month (date) == tt.month && g_date_day (date) == tt.day) diff --git a/calendar/gui/e-week-view.c b/calendar/gui/e-week-view.c index e4d701a0a6..99d0ad27c7 100644 --- a/calendar/gui/e-week-view.c +++ b/calendar/gui/e-week-view.c @@ -57,7 +57,7 @@ #include "dialogs/recur-comp.h" #include "comp-util.h" #include "itip-utils.h" -#include "cal-util/timeutil.h" +#include <libecal/e-cal-time-util.h> #include "calendar-commands.h" #include "calendar-config.h" #include "print.h" @@ -119,11 +119,11 @@ static gboolean e_week_view_get_next_tab_event (EWeekView *week_view, gint *next_span_num); static gboolean e_week_view_focus (GtkWidget *widget, GtkDirectionType direction); -static GList *e_week_view_get_selected_events (ECalView *cal_view); -static void e_week_view_get_selected_time_range (ECalView *cal_view, time_t *start_time, time_t *end_time); -static void e_week_view_set_selected_time_range (ECalView *cal_view, time_t start_time, time_t end_time); -static gboolean e_week_view_get_visible_time_range (ECalView *cal_view, time_t *start_time, time_t *end_time); -static void e_week_view_update_query (ECalView *cal_view); +static GList *e_week_view_get_selected_events (ECalendarView *cal_view); +static void e_week_view_get_selected_time_range (ECalendarView *cal_view, time_t *start_time, time_t *end_time); +static void e_week_view_set_selected_time_range (ECalendarView *cal_view, time_t start_time, time_t end_time); +static gboolean e_week_view_get_visible_time_range (ECalendarView *cal_view, time_t *start_time, time_t *end_time); +static void e_week_view_update_query (ECalendarView *cal_view); static void e_week_view_draw_shadow (EWeekView *week_view); static gboolean e_week_view_on_button_press (GtkWidget *widget, @@ -145,7 +145,7 @@ static void e_week_view_update_selection (EWeekView *week_view, gint day); static void e_week_view_free_events (EWeekView *week_view); -static gboolean e_week_view_add_event (CalComponent *comp, +static gboolean e_week_view_add_event (ECalComponent *comp, time_t start, time_t end, gpointer data); @@ -201,22 +201,22 @@ static void e_week_view_queue_layout (EWeekView *week_view); static void e_week_view_cancel_layout (EWeekView *week_view); static gboolean e_week_view_layout_timeout_cb (gpointer data); -static ECalViewClass *parent_class; +static ECalendarViewClass *parent_class; E_MAKE_TYPE (e_week_view, "EWeekView", EWeekView, e_week_view_class_init, - e_week_view_init, e_cal_view_get_type ()); + e_week_view_init, e_calendar_view_get_type ()); static void e_week_view_class_init (EWeekViewClass *class) { GtkObjectClass *object_class; GtkWidgetClass *widget_class; - ECalViewClass *view_class; + ECalendarViewClass *view_class; parent_class = g_type_class_peek_parent (class); object_class = (GtkObjectClass *) class; widget_class = (GtkWidgetClass *) class; - view_class = (ECalViewClass *) class; + view_class = (ECalendarViewClass *) class; /* Method override */ object_class->destroy = e_week_view_destroy; @@ -243,7 +243,7 @@ e_week_view_class_init (EWeekViewClass *class) } static void -timezone_changed_cb (ECalView *cal_view, icaltimezone *old_zone, +timezone_changed_cb (ECalendarView *cal_view, icaltimezone *old_zone, icaltimezone *new_zone, gpointer user_data) { struct icaltimetype tt = icaltime_null_time (); @@ -265,7 +265,7 @@ timezone_changed_cb (ECalView *cal_view, icaltimezone *old_zone, lower = icaltime_as_timet_with_zone (tt, new_zone); e_week_view_recalc_day_starts (week_view, lower); - e_week_view_update_query ((ECalView *) week_view); + e_week_view_update_query ((ECalendarView *) week_view); } static void @@ -406,7 +406,7 @@ e_week_view_init (EWeekView *week_view) week_view->resize_width_cursor = gdk_cursor_new (GDK_SB_H_DOUBLE_ARROW); week_view->last_cursor_set = NULL; - /* connect to ECalView's signals */ + /* connect to ECalendarView's signals */ g_signal_connect (G_OBJECT (week_view), "timezone_changed", G_CALLBACK (timezone_changed_cb), NULL); } @@ -1067,7 +1067,7 @@ e_week_view_focus (GtkWidget *widget, GtkDirectionType direction) /* Returns the currently-selected event, or NULL if none */ static GList * -e_week_view_get_selected_events (ECalView *cal_view) +e_week_view_get_selected_events (ECalendarView *cal_view) { EWeekViewEvent *event = NULL; GList *list = NULL; @@ -1094,7 +1094,7 @@ process_component (EWeekView *week_view, ECalModelComponent *comp_data) { EWeekViewEvent *event; gint event_num, num_days; - CalComponent *comp = NULL; + ECalComponent *comp = NULL; AddEventData add_event_data; const char *uid; @@ -1102,30 +1102,30 @@ process_component (EWeekView *week_view, ECalModelComponent *comp_data) if (!g_date_valid (&week_view->first_day_shown)) return; - comp = cal_component_new (); - if (!cal_component_set_icalcomponent (comp, icalcomponent_new_clone (comp_data->icalcomp))) { + comp = e_cal_component_new (); + if (!e_cal_component_set_icalcomponent (comp, icalcomponent_new_clone (comp_data->icalcomp))) { g_object_unref (comp); - g_message ("process_component(): Could not set icalcomponent on CalComponent"); + g_message ("process_component(): Could not set icalcomponent on ECalComponent"); return; } - cal_component_get_uid (comp, &uid); + e_cal_component_get_uid (comp, &uid); /* If the event already exists and the dates didn't change, we can update the event fairly easily without changing the events arrays or computing a new layout. */ if (e_week_view_find_event_from_uid (week_view, uid, &event_num)) { - CalComponent *tmp_comp; + ECalComponent *tmp_comp; event = &g_array_index (week_view->events, EWeekViewEvent, event_num); - tmp_comp = cal_component_new (); - cal_component_set_icalcomponent (tmp_comp, icalcomponent_new_clone (comp_data->icalcomp)); - if (!cal_component_has_recurrences (comp) - && !cal_component_has_recurrences (tmp_comp) - && cal_component_event_dates_match (comp, tmp_comp)) { + tmp_comp = e_cal_component_new (); + e_cal_component_set_icalcomponent (tmp_comp, icalcomponent_new_clone (comp_data->icalcomp)); + if (!e_cal_component_has_recurrences (comp) + && !e_cal_component_has_recurrences (tmp_comp) + && e_cal_component_event_dates_match (comp, tmp_comp)) { #if 0 g_print ("updated object's dates unchanged\n"); #endif @@ -1153,12 +1153,12 @@ process_component (EWeekView *week_view, ECalModelComponent *comp_data) add_event_data.week_view = week_view; add_event_data.comp_data = comp_data; - cal_recur_generate_instances (comp, + e_cal_recur_generate_instances (comp, week_view->day_starts[0], week_view->day_starts[num_days], e_week_view_add_event, &add_event_data, - cal_client_resolve_tzid_cb, comp_data->client, - e_cal_view_get_timezone (E_CAL_VIEW (week_view))); + e_cal_resolve_tzid_cb, comp_data->client, + e_calendar_view_get_timezone (E_CALENDAR_VIEW (week_view))); g_object_unref (comp); @@ -1167,7 +1167,7 @@ process_component (EWeekView *week_view, ECalModelComponent *comp_data) /* Restarts a query for the week view */ static void -e_week_view_update_query (ECalView *cal_view) +e_week_view_update_query (ECalendarView *cal_view) { gint rows, r; EWeekView *week_view = E_WEEK_VIEW (cal_view); @@ -1176,11 +1176,11 @@ e_week_view_update_query (ECalView *cal_view) e_week_view_free_events (week_view); e_week_view_queue_layout (week_view); - rows = e_table_model_row_count (E_TABLE_MODEL (e_cal_view_get_model (E_CAL_VIEW (week_view)))); + rows = e_table_model_row_count (E_TABLE_MODEL (e_calendar_view_get_model (E_CALENDAR_VIEW (week_view)))); for (r = 0; r < rows; r++) { ECalModelComponent *comp_data; - comp_data = e_cal_model_get_component_at (e_cal_view_get_model (E_CAL_VIEW (week_view)), r); + comp_data = e_cal_model_get_component_at (e_calendar_view_get_model (E_CALENDAR_VIEW (week_view)), r); g_assert (comp_data != NULL); process_component (week_view, comp_data); } @@ -1215,7 +1215,7 @@ e_week_view_draw_shadow (EWeekView *week_view) month and the days between start_time and end_time will be selected. To select a single day, use the same value for start_time & end_time. */ static void -e_week_view_set_selected_time_range (ECalView *cal_view, +e_week_view_set_selected_time_range (ECalendarView *cal_view, time_t start_time, time_t end_time) { @@ -1226,7 +1226,7 @@ e_week_view_set_selected_time_range (ECalView *cal_view, g_return_if_fail (E_IS_WEEK_VIEW (week_view)); - time_to_gdate_with_zone (&date, start_time, e_cal_view_get_timezone (E_CAL_VIEW (week_view))); + time_to_gdate_with_zone (&date, start_time, e_calendar_view_get_timezone (E_CALENDAR_VIEW (week_view))); if (week_view->multi_week_view) { /* Find the number of days since the start of the month. */ @@ -1275,11 +1275,11 @@ e_week_view_set_selected_time_range (ECalView *cal_view, || g_date_compare (&week_view->first_day_shown, &base_date)) { week_view->first_day_shown = base_date; start_time = time_add_day_with_zone (start_time, -day_offset, - e_cal_view_get_timezone (E_CAL_VIEW (week_view))); + e_calendar_view_get_timezone (E_CALENDAR_VIEW (week_view))); start_time = time_day_begin_with_zone (start_time, - e_cal_view_get_timezone (E_CAL_VIEW (week_view))); + e_calendar_view_get_timezone (E_CALENDAR_VIEW (week_view))); e_week_view_recalc_day_starts (week_view, start_time); - e_week_view_update_query ((ECalView *) week_view); + e_week_view_update_query ((ECalendarView *) week_view); } /* Set the selection to the given days. */ @@ -1287,10 +1287,10 @@ e_week_view_set_selected_time_range (ECalView *cal_view, - g_date_julian (&base_date); if (end_time == start_time || end_time <= time_add_day_with_zone (start_time, 1, - e_cal_view_get_timezone (E_CAL_VIEW (week_view)))) + e_calendar_view_get_timezone (E_CALENDAR_VIEW (week_view)))) week_view->selection_end_day = week_view->selection_start_day; else { - time_to_gdate_with_zone (&end_date, end_time - 60, e_cal_view_get_timezone (E_CAL_VIEW (week_view))); + time_to_gdate_with_zone (&end_date, end_time - 60, e_calendar_view_get_timezone (E_CALENDAR_VIEW (week_view))); week_view->selection_end_day = g_date_julian (&end_date) - g_date_julian (&base_date); } @@ -1323,17 +1323,17 @@ e_week_view_set_selected_time_range_visible (EWeekView *week_view, g_return_if_fail (E_IS_WEEK_VIEW (week_view)); - time_to_gdate_with_zone (&date, start_time, e_cal_view_get_timezone (E_CAL_VIEW (week_view))); + time_to_gdate_with_zone (&date, start_time, e_calendar_view_get_timezone (E_CALENDAR_VIEW (week_view))); /* Set the selection to the given days. */ week_view->selection_start_day = g_date_julian (&date) - g_date_julian (&week_view->first_day_shown); if (end_time == start_time || end_time <= time_add_day_with_zone (start_time, 1, - e_cal_view_get_timezone (E_CAL_VIEW (week_view)))) + e_calendar_view_get_timezone (E_CALENDAR_VIEW (week_view)))) week_view->selection_end_day = week_view->selection_start_day; else { - time_to_gdate_with_zone (&end_date, end_time - 60, e_cal_view_get_timezone (E_CAL_VIEW (week_view))); + time_to_gdate_with_zone (&end_date, end_time - 60, e_calendar_view_get_timezone (E_CALENDAR_VIEW (week_view))); week_view->selection_end_day = g_date_julian (&end_date) - g_date_julian (&week_view->first_day_shown); } @@ -1353,7 +1353,7 @@ e_week_view_set_selected_time_range_visible (EWeekView *week_view, /* Returns the selected time range. */ static void -e_week_view_get_selected_time_range (ECalView *cal_view, +e_week_view_get_selected_time_range (ECalendarView *cal_view, time_t *start_time, time_t *end_time) { @@ -1377,7 +1377,7 @@ e_week_view_get_selected_time_range (ECalView *cal_view, /* Gets the visible time range. Returns FALSE if no time range has been set. */ static gboolean -e_week_view_get_visible_time_range (ECalView *cal_view, +e_week_view_get_visible_time_range (ECalendarView *cal_view, time_t *start_time, time_t *end_time) { @@ -1458,10 +1458,10 @@ e_week_view_set_first_day_shown (EWeekView *week_view, start_tt.day = g_date_day (&base_date); start_time = icaltime_as_timet_with_zone (start_tt, - e_cal_view_get_timezone (E_CAL_VIEW (week_view))); + e_calendar_view_get_timezone (E_CALENDAR_VIEW (week_view))); e_week_view_recalc_day_starts (week_view, start_time); - e_week_view_update_query ((ECalView *) week_view); + e_week_view_update_query ((ECalendarView *) week_view); } /* Try to keep the previous selection, but if it is no longer shown @@ -1508,7 +1508,7 @@ e_week_view_recalc_day_starts (EWeekView *week_view, week_view->day_starts[0] = tmp_time; for (day = 1; day <= num_days; day++) { tmp_time = time_add_day_with_zone (tmp_time, 1, - e_cal_view_get_timezone (E_CAL_VIEW (week_view))); + e_calendar_view_get_timezone (E_CALENDAR_VIEW (week_view))); week_view->day_starts[day] = tmp_time; } } @@ -1598,7 +1598,7 @@ e_week_view_set_weeks_shown (EWeekView *week_view, if (g_date_valid (&week_view->first_day_shown)) e_week_view_set_first_day_shown (week_view, &week_view->first_day_shown); - e_week_view_update_query ((ECalView *) week_view); + e_week_view_update_query ((ECalendarView *) week_view); } } @@ -1959,7 +1959,7 @@ e_week_view_on_button_press (GtkWidget *widget, return FALSE; if (event->button == 1 && event->type == GDK_2BUTTON_PRESS) { - e_cal_view_new_appointment (E_CAL_VIEW (week_view)); + e_calendar_view_new_appointment (E_CALENDAR_VIEW (week_view)); return TRUE; } @@ -2016,7 +2016,7 @@ e_week_view_on_button_release (GtkWidget *widget, start = week_view->day_starts[week_view->selection_start_day]; end = week_view->day_starts[week_view->selection_end_day + 1]; - gnome_calendar_set_selected_time_range (e_cal_view_get_calendar (E_CAL_VIEW (week_view)), + gnome_calendar_set_selected_time_range (e_calendar_view_get_calendar (E_CALENDAR_VIEW (week_view)), start, end); } @@ -2225,7 +2225,7 @@ e_week_view_free_events (EWeekView *week_view) /* This adds one event to the view, adding it to the appropriate array. */ static gboolean -e_week_view_add_event (CalComponent *comp, +e_week_view_add_event (ECalComponent *comp, time_t start, time_t end, gpointer data) @@ -2251,9 +2251,9 @@ e_week_view_add_event (CalComponent *comp, g_return_val_if_fail (end > add_event_data->week_view->day_starts[0], TRUE); start_tt = icaltime_from_timet_with_zone (start, FALSE, - e_cal_view_get_timezone (E_CAL_VIEW (add_event_data->week_view))); + e_calendar_view_get_timezone (E_CALENDAR_VIEW (add_event_data->week_view))); end_tt = icaltime_from_timet_with_zone (end, FALSE, - e_cal_view_get_timezone (E_CAL_VIEW (add_event_data->week_view))); + e_calendar_view_get_timezone (E_CALENDAR_VIEW (add_event_data->week_view))); if (add_event_data->comp_data) { event.comp_data = add_event_data->comp_data; @@ -2262,9 +2262,9 @@ e_week_view_add_event (CalComponent *comp, event.comp_data = g_new0 (ECalModelComponent, 1); event.allocated_comp_data = TRUE; - event.comp_data->client = e_cal_model_get_default_client (e_cal_view_get_model (E_CAL_VIEW (add_event_data->week_view))); - cal_component_commit_sequence (comp); - event.comp_data->icalcomp = icalcomponent_new_clone (cal_component_get_icalcomponent (comp)); + event.comp_data->client = e_cal_model_get_default_client (e_calendar_view_get_model (E_CALENDAR_VIEW (add_event_data->week_view))); + e_cal_component_commit_sequence (comp); + event.comp_data->icalcomp = icalcomponent_new_clone (e_cal_component_get_icalcomponent (comp)); } event.start = start; event.end = end; @@ -2280,7 +2280,7 @@ e_week_view_add_event (CalComponent *comp, if (!cal_comp_util_compare_event_timezones ( comp, event.comp_data->client, - e_cal_view_get_timezone (E_CAL_VIEW (add_event_data->week_view)))) + e_calendar_view_get_timezone (E_CALENDAR_VIEW (add_event_data->week_view)))) event.different_timezone = TRUE; g_array_append_val (add_event_data->week_view->events, event); @@ -2419,7 +2419,7 @@ e_week_view_reshape_event_span (EWeekView *week_view, gint min_text_x, max_text_w, width; gboolean show_icons = TRUE, use_max_width = FALSE; gboolean one_day_event; - CalComponent *comp; + ECalComponent *comp; gdouble text_x, text_y, text_w, text_h; gchar *text, *end_of_line; gint line_len, text_width; @@ -2431,8 +2431,8 @@ e_week_view_reshape_event_span (EWeekView *week_view, event = &g_array_index (week_view->events, EWeekViewEvent, event_num); span = &g_array_index (week_view->spans, EWeekViewEventSpan, event->spans_index + span_num); - comp = cal_component_new (); - cal_component_set_icalcomponent (comp, icalcomponent_new_clone (event->comp_data->icalcomp)); + comp = e_cal_component_new (); + e_cal_component_set_icalcomponent (comp, icalcomponent_new_clone (event->comp_data->icalcomp)); one_day_event = e_week_view_is_one_day_event (week_view, event_num); @@ -2471,14 +2471,14 @@ e_week_view_reshape_event_span (EWeekView *week_view, if (show_icons) { GSList *categories_list, *elem; - if (cal_component_has_alarms (comp)) + if (e_cal_component_has_alarms (comp)) num_icons++; - if (cal_component_has_recurrences (comp)) + if (e_cal_component_has_recurrences (comp)) num_icons++; if (event->different_timezone) num_icons++; - cal_component_get_categories_list (comp, &categories_list); + e_cal_component_get_categories_list (comp, &categories_list); for (elem = categories_list; elem; elem = elem->next) { char *category; GdkPixmap *pixmap = NULL; @@ -2489,7 +2489,7 @@ e_week_view_reshape_event_span (EWeekView *week_view, num_icons++; } - cal_component_free_categories_list (categories_list); + e_cal_component_free_categories_list (categories_list); } /* Create the background canvas item if necessary. */ @@ -2507,9 +2507,9 @@ e_week_view_reshape_event_span (EWeekView *week_view, /* Create the text item if necessary. */ if (!span->text_item) { - CalComponentText text; + ECalComponentText text; - cal_component_get_summary (comp, &text); + e_cal_component_get_summary (comp, &text); span->text_item = gnome_canvas_item_new (GNOME_CANVAS_GROUP (GNOME_CANVAS (week_view->main_canvas)->root), e_text_get_type (), @@ -2707,16 +2707,16 @@ e_week_view_on_adjustment_changed (GtkAdjustment *adjustment, start_tt.month = g_date_month (&date); start_tt.day = g_date_day (&date); - lower = icaltime_as_timet_with_zone (start_tt, e_cal_view_get_timezone (E_CAL_VIEW (week_view))); + lower = icaltime_as_timet_with_zone (start_tt, e_calendar_view_get_timezone (E_CALENDAR_VIEW (week_view))); e_week_view_recalc_day_starts (week_view, lower); - e_week_view_update_query ((ECalView *) week_view); + e_week_view_update_query ((ECalendarView *) week_view); /* Update the selection, if needed. */ if (week_view->selection_start_day != -1) { start = week_view->day_starts[week_view->selection_start_day]; end = week_view->day_starts[week_view->selection_end_day + 1]; - gnome_calendar_set_selected_time_range (e_cal_view_get_calendar (E_CAL_VIEW (week_view)), + gnome_calendar_set_selected_time_range (e_calendar_view_get_calendar (E_CALENDAR_VIEW (week_view)), start, end); } } @@ -2853,7 +2853,7 @@ e_week_view_on_text_item_event (GnomeCanvasItem *item, event = &g_array_index (week_view->events, EWeekViewEvent, event_num); - e_cal_view_edit_appointment (E_CAL_VIEW (week_view), + e_calendar_view_edit_appointment (E_CALENDAR_VIEW (week_view), event->comp_data->client, event->comp_data->icalcomp, FALSE); @@ -2986,9 +2986,9 @@ e_week_view_on_editing_stopped (EWeekView *week_view, EWeekViewEvent *event; EWeekViewEventSpan *span; gchar *text = NULL; - CalComponent *comp; - CalComponentText summary; - CalClient *client; + ECalComponent *comp; + ECalComponentText summary; + ECal *client; const char *uid; gboolean on_server; @@ -3018,8 +3018,8 @@ e_week_view_on_editing_stopped (EWeekView *week_view, g_object_get (G_OBJECT (span->text_item), "text", &text, NULL); g_assert (text != NULL); - comp = cal_component_new (); - cal_component_set_icalcomponent (comp, icalcomponent_new_clone (event->comp_data->icalcomp)); + comp = e_cal_component_new (); + e_cal_component_set_icalcomponent (comp, icalcomponent_new_clone (event->comp_data->icalcomp)); client = event->comp_data->client; on_server = cal_comp_is_on_server (comp, client); @@ -3027,7 +3027,7 @@ e_week_view_on_editing_stopped (EWeekView *week_view, if (string_is_empty (text) && !on_server) { const char *uid; - cal_component_get_uid (comp, &uid); + e_cal_component_get_uid (comp, &uid); e_week_view_foreach_event_with_uid (week_view, uid, e_week_view_remove_event_cb, NULL); @@ -3037,26 +3037,26 @@ e_week_view_on_editing_stopped (EWeekView *week_view, } /* Only update the summary if necessary. */ - cal_component_get_summary (comp, &summary); + e_cal_component_get_summary (comp, &summary); if (summary.value && !strcmp (text, summary.value)) { if (!e_week_view_is_one_day_event (week_view, event_num)) e_week_view_reshape_event_span (week_view, event_num, span_num); } else if (summary.value || !string_is_empty (text)) { - icalcomponent *icalcomp = cal_component_get_icalcomponent (comp); + icalcomponent *icalcomp = e_cal_component_get_icalcomponent (comp); summary.value = text; summary.altrep = NULL; - cal_component_set_summary (comp, &summary); + e_cal_component_set_summary (comp, &summary); if (!on_server) { - if (!cal_client_create_object (client, icalcomp, NULL, NULL)) + if (!e_cal_create_object (client, icalcomp, NULL, NULL)) g_message (G_STRLOC ": Could not create the object!"); } else { CalObjModType mod = CALOBJ_MOD_ALL; GtkWindow *toplevel; - if (cal_component_has_recurrences (comp)) { + if (e_cal_component_has_recurrences (comp)) { if (!recur_component_dialog (client, comp, &mod, NULL)) { goto out; } @@ -3064,10 +3064,10 @@ e_week_view_on_editing_stopped (EWeekView *week_view, /* FIXME When sending here, what exactly should we send? */ toplevel = GTK_WINDOW (gtk_widget_get_toplevel (GTK_WIDGET (week_view))); - if (cal_client_modify_object (client, icalcomp, mod, NULL)) { + if (e_cal_modify_object (client, icalcomp, mod, NULL)) { if (itip_organizer_is_user (comp, client) && send_component_dialog (toplevel, client, comp, FALSE)) - itip_send_comp (CAL_COMPONENT_METHOD_REQUEST, comp, + itip_send_comp (E_CAL_COMPONENT_METHOD_REQUEST, comp, client, NULL); } } @@ -3178,11 +3178,11 @@ static gboolean e_week_view_do_key_press (GtkWidget *widget, GdkEventKey *event) { EWeekView *week_view; - CalComponent *comp; + ECalComponent *comp; icalcomponent *icalcomp; gint event_num; gchar *initial_text; - CalComponentDateTime date; + ECalComponentDateTime date; struct icaltimetype itt; time_t dtstart, dtend; const char *uid; @@ -3196,7 +3196,7 @@ e_week_view_do_key_press (GtkWidget *widget, GdkEventKey *event) /* The Escape key aborts a resize operation. */ #if 0 - if (week_view->resize_drag_pos != E_CAL_VIEW_POS_NONE) { + if (week_view->resize_drag_pos != E_CALENDAR_VIEW_POS_NONE) { if (event->keyval == GDK_Escape) { e_week_view_abort_resize (week_view, event->time); } @@ -3238,13 +3238,13 @@ e_week_view_do_key_press (GtkWidget *widget, GdkEventKey *event) initial_text = e_utf8_from_gtk_event_key (widget, event->keyval, event->string); /* Add a new event covering the selected range. */ - icalcomp = e_cal_model_create_component_with_defaults (e_cal_view_get_model (E_CAL_VIEW (week_view))); + icalcomp = e_cal_model_create_component_with_defaults (e_calendar_view_get_model (E_CALENDAR_VIEW (week_view))); if (!icalcomp) return FALSE; uid = icalcomponent_get_uid (icalcomp); - comp = cal_component_new (); - cal_component_set_icalcomponent (comp, icalcomp); + comp = e_cal_component_new (); + e_cal_component_set_icalcomponent (comp, icalcomp); dtstart = week_view->day_starts[week_view->selection_start_day]; dtend = week_view->day_starts[week_view->selection_end_day + 1]; @@ -3253,18 +3253,18 @@ e_week_view_do_key_press (GtkWidget *widget, GdkEventKey *event) date.tzid = NULL; /* We use DATE values now, so we don't need the timezone. */ - /*date.tzid = icaltimezone_get_tzid (e_cal_view_get_timezone (E_CAL_VIEW (week_view)));*/ + /*date.tzid = icaltimezone_get_tzid (e_calendar_view_get_timezone (E_CALENDAR_VIEW (week_view)));*/ *date.value = icaltime_from_timet_with_zone (dtstart, TRUE, - e_cal_view_get_timezone (E_CAL_VIEW (week_view))); - cal_component_set_dtstart (comp, &date); + e_calendar_view_get_timezone (E_CALENDAR_VIEW (week_view))); + e_cal_component_set_dtstart (comp, &date); *date.value = icaltime_from_timet_with_zone (dtend, TRUE, - e_cal_view_get_timezone (E_CAL_VIEW (week_view))); - cal_component_set_dtend (comp, &date); + e_calendar_view_get_timezone (E_CALENDAR_VIEW (week_view))); + e_cal_component_set_dtend (comp, &date); - cal_component_set_categories ( - comp, e_cal_view_get_default_category (E_CAL_VIEW (week_view))); + e_cal_component_set_categories ( + comp, e_calendar_view_get_default_category (E_CALENDAR_VIEW (week_view))); /* We add the event locally and start editing it. We don't send it to the server until the user finishes editing it. */ @@ -3483,7 +3483,7 @@ e_week_view_show_popup_menu (EWeekView *week_view, week_view->popup_event_num = event_num; - popup = e_cal_view_create_popup_menu (E_CAL_VIEW (week_view)); + popup = e_calendar_view_create_popup_menu (E_CALENDAR_VIEW (week_view)); e_popup_menu (popup, (GdkEvent *) bevent); } @@ -3504,7 +3504,7 @@ e_week_view_jump_to_button_item (EWeekView *week_view, GnomeCanvasItem *item) for (day = 0; day < E_WEEK_VIEW_MAX_WEEKS * 7; ++day) { if (item == week_view->jump_buttons[day]) { - calendar = e_cal_view_get_calendar (E_CAL_VIEW (week_view)); + calendar = e_calendar_view_get_calendar (E_CALENDAR_VIEW (week_view)); if (calendar) gnome_calendar_dayjump (calendar, @@ -3585,7 +3585,7 @@ e_week_view_convert_time_to_display (EWeekView *week_view, /* Calculate the actual hour number to display. For 12-hour format we convert 0-23 to 12-11am/12-11pm. */ *display_hour = hour; - if (e_cal_view_get_use_24_hour_format (E_CAL_VIEW (week_view))) { + if (e_calendar_view_get_use_24_hour_format (E_CALENDAR_VIEW (week_view))) { *suffix = ""; *suffix_width = 0; } else { @@ -3617,7 +3617,7 @@ e_week_view_get_time_string_width (EWeekView *week_view) time_width = week_view->digit_width * 4 + week_view->colon_width; - if (!e_cal_view_get_use_24_hour_format (E_CAL_VIEW (week_view))) + if (!e_calendar_view_get_use_24_hour_format (E_CALENDAR_VIEW (week_view))) time_width += MAX (week_view->am_string_width, week_view->pm_string_width); diff --git a/calendar/gui/e-week-view.h b/calendar/gui/e-week-view.h index f36760d76a..aca3f2bc2a 100644 --- a/calendar/gui/e-week-view.h +++ b/calendar/gui/e-week-view.h @@ -143,7 +143,7 @@ struct _EWeekViewEventSpan { typedef struct _EWeekViewEvent EWeekViewEvent; struct _EWeekViewEvent { - E_CAL_VIEW_EVENT_FIELDS + E_CALENDAR_VIEW_EVENT_FIELDS gint spans_index; guint8 num_spans; }; @@ -159,7 +159,7 @@ typedef struct _EWeekViewClass EWeekViewClass; struct _EWeekView { - ECalView cal_view; + ECalendarView cal_view; /* The top canvas where the dates are shown. */ GtkWidget *titles_canvas; @@ -175,7 +175,7 @@ struct _EWeekView GtkWidget *vscrollbar; /* The query object */ - CalQuery *query; + ECalView *query; /* The array of EWeekViewEvent elements. */ GArray *events; @@ -332,7 +332,7 @@ struct _EWeekView struct _EWeekViewClass { - ECalViewClass parent_class; + ECalendarViewClass parent_class; }; diff --git a/calendar/gui/gnome-cal.c b/calendar/gui/gnome-cal.c index 359de9c209..a14678f3e3 100644 --- a/calendar/gui/gnome-cal.c +++ b/calendar/gui/gnome-cal.c @@ -37,7 +37,7 @@ #include <libgnomeui/gnome-dialog-util.h> #include <bonobo/bonobo-exception.h> #include "e-util/e-url.h" -#include <cal-util/timeutil.h> +#include <libecal/e-cal-time-util.h> #include "widgets/menus/gal-view-menus.h" #include "e-comp-editor-registry.h" #include "dialogs/delete-error.h" @@ -85,7 +85,7 @@ struct _GnomeCalendarPrivate { */ /* The calendar client object we monitor */ - CalClient *task_pad_client; + ECal *task_pad_client; /* Set of categories from the tasks client */ GPtrArray *tasks_categories; @@ -123,12 +123,12 @@ struct _GnomeCalendarPrivate { /* Calendar query for the date navigator */ GList *dn_queries; /* list of CalQueries */ char *sexp; - guint query_timeout; + guint e_cal_view_timeout; /* This is the view currently shown. We use it to keep track of the positions of the panes. range_selected is TRUE if a range of dates was selected in the date navigator to show the view. */ - ECalView *views[GNOME_CAL_LAST_VIEW]; + ECalendarView *views[GNOME_CAL_LAST_VIEW]; GObject *configs[GNOME_CAL_LAST_VIEW]; GnomeCalendarViewType current_view_type; GList *notifications; @@ -370,7 +370,7 @@ gnome_calendar_class_init (GnomeCalendarClass *class) /* Callback used when the calendar query reports of an updated object */ static void -dn_query_objects_added_cb (CalQuery *query, GList *objects, gpointer data) +dn_e_cal_view_objects_added_cb (ECalView *query, GList *objects, gpointer data) { GnomeCalendar *gcal; GnomeCalendarPrivate *priv; @@ -380,23 +380,23 @@ dn_query_objects_added_cb (CalQuery *query, GList *objects, gpointer data) priv = gcal->priv; for (l = objects; l; l = l->next) { - CalComponent *comp = NULL; + ECalComponent *comp = NULL; - comp = cal_component_new (); - if (!cal_component_set_icalcomponent (comp, icalcomponent_new_clone (l->data))) { + comp = e_cal_component_new (); + if (!e_cal_component_set_icalcomponent (comp, icalcomponent_new_clone (l->data))) { g_object_unref (comp); continue; } - tag_calendar_by_comp (priv->date_navigator, comp, cal_query_get_client (query), NULL, + tag_calendar_by_comp (priv->date_navigator, comp, e_cal_view_get_client (query), NULL, FALSE, TRUE); g_object_unref (comp); } } static void -dn_query_objects_modified_cb (CalQuery *query, GList *objects, gpointer data) +dn_e_cal_view_objects_modified_cb (ECalView *query, GList *objects, gpointer data) { GnomeCalendar *gcal; GnomeCalendarPrivate *priv; @@ -413,7 +413,7 @@ dn_query_objects_modified_cb (CalQuery *query, GList *objects, gpointer data) /* Callback used when the calendar query reports of a removed object */ static void -dn_query_objects_removed_cb (CalQuery *query, GList *uids, gpointer data) +dn_e_cal_view_objects_removed_cb (ECalView *query, GList *uids, gpointer data) { GnomeCalendar *gcal; @@ -425,7 +425,7 @@ dn_query_objects_removed_cb (CalQuery *query, GList *uids, gpointer data) /* Callback used when the calendar query is done */ static void -dn_query_done_cb (CalQuery *query, ECalendarStatus status, gpointer data) +dn_e_cal_view_done_cb (ECalView *query, ECalendarStatus status, gpointer data) { GnomeCalendar *gcal; @@ -544,7 +544,7 @@ get_date_navigator_range (GnomeCalendar *gcal, time_t *start_time, time_t *end_t /* Adjusts a given query sexp with the time range of the date navigator */ static char * -adjust_query_sexp (GnomeCalendar *gcal, const char *sexp) +adjust_e_cal_view_sexp (GnomeCalendar *gcal, const char *sexp) { time_t start_time, end_time; char *start, *end; @@ -576,7 +576,7 @@ static void update_query (GnomeCalendar *gcal) { GnomeCalendarPrivate *priv; - CalQuery *old_query; + ECalView *old_query; char *real_sexp; GList *l; @@ -584,7 +584,7 @@ update_query (GnomeCalendar *gcal) e_calendar_item_clear_marks (priv->date_navigator->calitem); - e_cal_view_set_status_message (E_CAL_VIEW (priv->week_view), _("Searching")); + e_calendar_view_set_status_message (E_CALENDAR_VIEW (priv->week_view), _("Searching")); /* free the previous queries */ for (l = priv->dn_queries; l != NULL; l = l->next) { @@ -602,46 +602,46 @@ update_query (GnomeCalendar *gcal) g_assert (priv->sexp != NULL); - real_sexp = adjust_query_sexp (gcal, priv->sexp); + real_sexp = adjust_e_cal_view_sexp (gcal, priv->sexp); if (!real_sexp) { - e_cal_view_set_status_message (E_CAL_VIEW (priv->week_view), NULL); + e_calendar_view_set_status_message (E_CALENDAR_VIEW (priv->week_view), NULL); return; /* No time range is set, so don't start a query */ } /* create queries for each loaded client */ for (l = priv->clients_list; l != NULL; l = l->next) { - if (!cal_client_get_query ((CalClient *) l->data, real_sexp, &old_query, NULL)) { + if (!e_cal_get_query ((ECal *) l->data, real_sexp, &old_query, NULL)) { g_warning (G_STRLOC ": Could not create the query"); continue; } g_signal_connect (old_query, "objects_added", - G_CALLBACK (dn_query_objects_added_cb), gcal); + G_CALLBACK (dn_e_cal_view_objects_added_cb), gcal); g_signal_connect (old_query, "objects_modified", - G_CALLBACK (dn_query_objects_modified_cb), gcal); + G_CALLBACK (dn_e_cal_view_objects_modified_cb), gcal); g_signal_connect (old_query, "objects_removed", - G_CALLBACK (dn_query_objects_removed_cb), gcal); - g_signal_connect (old_query, "query_done", - G_CALLBACK (dn_query_done_cb), gcal); + G_CALLBACK (dn_e_cal_view_objects_removed_cb), gcal); + g_signal_connect (old_query, "view_done", + G_CALLBACK (dn_e_cal_view_done_cb), gcal); priv->dn_queries = g_list_append (priv->dn_queries, old_query); - cal_query_start (old_query); + e_cal_view_start (old_query); } g_free (real_sexp); - e_cal_view_set_status_message (E_CAL_VIEW (priv->week_view), NULL); + e_calendar_view_set_status_message (E_CALENDAR_VIEW (priv->week_view), NULL); } static void -adjust_query_for_view (ECalView *cal_view, const char *sexp) +adjust_e_cal_view_for_view (ECalendarView *cal_view, const char *sexp) { char *real_sexp, *start, *end; time_t ttstart, ttend; - e_cal_view_get_visible_time_range (cal_view, &ttstart, &ttend); + e_calendar_view_get_visible_time_range (cal_view, &ttstart, &ttend); start = isodate_from_time_t (ttstart); end = isodate_from_time_t (ttend); @@ -652,7 +652,7 @@ adjust_query_for_view (ECalView *cal_view, const char *sexp) " %s)", start, end, sexp); - e_cal_model_set_query (e_cal_view_get_model (cal_view), real_sexp); + e_cal_model_set_query (e_calendar_view_get_model (cal_view), real_sexp); g_free (start); g_free (end); @@ -690,7 +690,7 @@ gnome_calendar_set_query (GnomeCalendar *gcal, const char *sexp) /* Set the query on the views */ for (i = 0; i < GNOME_CAL_LAST_VIEW; i++) - adjust_query_for_view (E_CAL_VIEW (priv->views[i]), sexp); + adjust_e_cal_view_for_view (E_CALENDAR_VIEW (priv->views[i]), sexp); /* Set the query on the task pad */ model = e_calendar_table_get_model (E_CALENDAR_TABLE (priv->todo)); @@ -740,7 +740,7 @@ search_bar_category_changed_cb (CalSearchBar *cal_search, const char *category, priv = gcal->priv; for (i = 0; i < GNOME_CAL_LAST_VIEW; i++) { - e_cal_view_set_default_category (E_CAL_VIEW (priv->views[i]), + e_calendar_view_set_default_category (E_CALENDAR_VIEW (priv->views[i]), category); } @@ -851,17 +851,17 @@ set_timezone (GnomeCalendar *calendar) priv->zone = icaltimezone_get_utc_timezone (); for (l = priv->clients_list; l != NULL; l = l->next) { - CalClient *client = l->data; + ECal *client = l->data; - if (cal_client_get_load_state (client) == CAL_CLIENT_LOAD_LOADED) + if (e_cal_get_load_state (client) == E_CAL_LOAD_LOADED) /* FIXME Error checking */ - cal_client_set_default_timezone (client, priv->zone, NULL); + e_cal_set_default_timezone (client, priv->zone, NULL); } if (priv->task_pad_client - && cal_client_get_load_state (priv->task_pad_client) == CAL_CLIENT_LOAD_LOADED) { + && e_cal_get_load_state (priv->task_pad_client) == E_CAL_LOAD_LOADED) { /* FIXME Error Checking */ - cal_client_set_default_timezone (priv->task_pad_client, + e_cal_set_default_timezone (priv->task_pad_client, priv->zone, NULL); } } @@ -991,13 +991,13 @@ setup_widgets (GnomeCalendar *gcal) e_day_view_set_work_week_view (E_DAY_VIEW (priv->work_week_view), TRUE); e_day_view_set_days_shown (E_DAY_VIEW (priv->work_week_view), 5); - e_cal_view_set_calendar (E_CAL_VIEW (priv->work_week_view), gcal); + e_calendar_view_set_calendar (E_CALENDAR_VIEW (priv->work_week_view), gcal); connect_day_view_focus (gcal, E_DAY_VIEW (priv->work_week_view)); /* The Week View. */ priv->week_view = e_week_view_new (); - e_cal_view_set_calendar (E_CAL_VIEW (priv->week_view), gcal); + e_calendar_view_set_calendar (E_CALENDAR_VIEW (priv->week_view), gcal); g_signal_connect (priv->week_view, "selection_changed", G_CALLBACK (view_selection_changed_cb), gcal); @@ -1005,7 +1005,7 @@ setup_widgets (GnomeCalendar *gcal) /* The Month View. */ priv->month_view = e_week_view_new (); - e_cal_view_set_calendar (E_CAL_VIEW (priv->month_view), gcal); + e_calendar_view_set_calendar (E_CALENDAR_VIEW (priv->month_view), gcal); e_week_view_set_multi_week_view (E_WEEK_VIEW (priv->month_view), TRUE); g_signal_connect (priv->month_view, "selection_changed", G_CALLBACK (view_selection_changed_cb), gcal); @@ -1017,19 +1017,19 @@ setup_widgets (GnomeCalendar *gcal) priv->list_view = e_cal_list_view_new (filename); g_free (filename); - e_cal_view_set_calendar (E_CAL_VIEW (priv->list_view), gcal); + e_calendar_view_set_calendar (E_CALENDAR_VIEW (priv->list_view), gcal); connect_list_view_focus (gcal, E_CAL_LIST_VIEW (priv->list_view)); - priv->views[GNOME_CAL_DAY_VIEW] = E_CAL_VIEW (priv->day_view); + priv->views[GNOME_CAL_DAY_VIEW] = E_CALENDAR_VIEW (priv->day_view); priv->configs[GNOME_CAL_DAY_VIEW] = e_day_view_config_new (E_DAY_VIEW (priv->views[GNOME_CAL_DAY_VIEW])); - priv->views[GNOME_CAL_WORK_WEEK_VIEW] = E_CAL_VIEW (priv->work_week_view); + priv->views[GNOME_CAL_WORK_WEEK_VIEW] = E_CALENDAR_VIEW (priv->work_week_view); priv->configs[GNOME_CAL_WORK_WEEK_VIEW] = e_day_view_config_new (E_DAY_VIEW (priv->views[GNOME_CAL_WORK_WEEK_VIEW])); - priv->views[GNOME_CAL_WEEK_VIEW] = E_CAL_VIEW (priv->week_view); + priv->views[GNOME_CAL_WEEK_VIEW] = E_CALENDAR_VIEW (priv->week_view); priv->configs[GNOME_CAL_WEEK_VIEW] = e_week_view_config_new (E_WEEK_VIEW (priv->views[GNOME_CAL_WEEK_VIEW])); - priv->views[GNOME_CAL_MONTH_VIEW] = E_CAL_VIEW (priv->month_view); + priv->views[GNOME_CAL_MONTH_VIEW] = E_CALENDAR_VIEW (priv->month_view); priv->configs[GNOME_CAL_MONTH_VIEW] = e_week_view_config_new (E_WEEK_VIEW (priv->views[GNOME_CAL_MONTH_VIEW])); - priv->views[GNOME_CAL_LIST_VIEW] = E_CAL_VIEW (priv->list_view); + priv->views[GNOME_CAL_LIST_VIEW] = E_CALENDAR_VIEW (priv->list_view); priv->configs[GNOME_CAL_MONTH_VIEW] = e_cal_list_view_config_new (E_CAL_LIST_VIEW (priv->views[GNOME_CAL_LIST_VIEW])); priv->configs[GNOME_CAL_LIST_VIEW] = NULL; @@ -1142,9 +1142,9 @@ gnome_calendar_destroy (GtkObject *object) if (priv->dn_queries) { for (l = priv->dn_queries; l != NULL; l = l->next) { - g_signal_handlers_disconnect_matched ((CalQuery *) l->data, G_SIGNAL_MATCH_DATA, + g_signal_handlers_disconnect_matched ((ECalView *) l->data, G_SIGNAL_MATCH_DATA, 0, 0, NULL, NULL, gcal); - g_object_unref ((CalQuery *) l->data); + g_object_unref ((ECalView *) l->data); } g_list_free (priv->dn_queries); @@ -1156,9 +1156,9 @@ gnome_calendar_destroy (GtkObject *object) priv->sexp = NULL; } - if (priv->query_timeout) { - g_source_remove (priv->query_timeout); - priv->query_timeout = 0; + if (priv->e_cal_view_timeout) { + g_source_remove (priv->e_cal_view_timeout); + priv->e_cal_view_timeout = 0; } if (priv->task_pad_client) { @@ -1313,7 +1313,7 @@ gnome_calendar_update_view_times (GnomeCalendar *gcal) priv = gcal->priv; - e_cal_view_set_selected_time_range (E_CAL_VIEW (gnome_calendar_get_current_view_widget (gcal)), + e_calendar_view_set_selected_time_range (E_CALENDAR_VIEW (gnome_calendar_get_current_view_widget (gcal)), priv->selection_start_time, priv->selection_end_time); } @@ -1638,7 +1638,7 @@ gnome_calendar_setup_view_menus (GnomeCalendar *gcal, BonoboUIComponent *uic) } priv->view_instance = gal_view_instance_new (collection, - cal_client_get_uri (gnome_calendar_get_default_client (gcal))); + e_cal_get_uri (gnome_calendar_get_default_client (gcal))); priv->view_menus = gal_view_menus_new (priv->view_instance); gal_view_menus_set_show_define_views (priv->view_menus, FALSE); @@ -1771,7 +1771,7 @@ permission_error (GnomeCalendar *gcal, const char *uri) /* Callback from the calendar client when a calendar is loaded */ static gboolean -update_query_timeout (gpointer data) +update_e_cal_view_timeout (gpointer data) { GnomeCalendar *gcal = data; GnomeCalendarPrivate *priv; @@ -1780,13 +1780,13 @@ update_query_timeout (gpointer data) priv = gcal->priv; update_query (gcal); - priv->query_timeout = 0; + priv->e_cal_view_timeout = 0; return FALSE; } static void -client_cal_opened_cb (CalClient *client, CalClientOpenStatus status, gpointer data) +client_cal_opened_cb (ECal *client, ECalOpenStatus status, gpointer data) { GnomeCalendar *gcal; GnomeCalendarPrivate *priv; @@ -1797,15 +1797,15 @@ client_cal_opened_cb (CalClient *client, CalClientOpenStatus status, gpointer da priv = gcal->priv; switch (status) { - case CAL_CLIENT_OPEN_SUCCESS: + case E_CAL_OPEN_SUCCESS: /* Set the client's default timezone, if we have one. */ if (priv->zone) { /* FIXME Error checking */ - cal_client_set_default_timezone (client, priv->zone, NULL); + e_cal_set_default_timezone (client, priv->zone, NULL); } /* add the alarms for this client */ - uristr = get_uri_without_password (cal_client_get_uri (client)); + uristr = get_uri_without_password (e_cal_get_uri (client)); msg = g_strdup_printf (_("Adding alarms for %s"), uristr); g_free (uristr); if (client == priv->task_pad_client) { @@ -1814,31 +1814,31 @@ client_cal_opened_cb (CalClient *client, CalClientOpenStatus status, gpointer da priv->task_pad_client); } else { - e_cal_view_set_status_message (E_CAL_VIEW (priv->week_view), msg); - e_cal_model_add_client (e_cal_view_get_model (E_CAL_VIEW (priv->week_view)), client); + e_calendar_view_set_status_message (E_CALENDAR_VIEW (priv->week_view), msg); + e_cal_model_add_client (e_calendar_view_get_model (E_CALENDAR_VIEW (priv->week_view)), client); - priv->query_timeout = g_timeout_add (100, update_query_timeout, gcal); + priv->e_cal_view_timeout = g_timeout_add (100, update_e_cal_view_timeout, gcal); } g_free (msg); - add_alarms (cal_client_get_uri (client)); + add_alarms (e_cal_get_uri (client)); break; - case CAL_CLIENT_OPEN_ERROR: - open_error (gcal, cal_client_get_uri (client)); + case E_CAL_OPEN_ERROR: + open_error (gcal, e_cal_get_uri (client)); break; - case CAL_CLIENT_OPEN_NOT_FOUND: + case E_CAL_OPEN_NOT_FOUND: /* bullshit; we did not specify only_if_exists */ g_assert_not_reached (); return; - case CAL_CLIENT_OPEN_METHOD_NOT_SUPPORTED: - method_error (gcal, cal_client_get_uri (client)); + case E_CAL_OPEN_METHOD_NOT_SUPPORTED: + method_error (gcal, e_cal_get_uri (client)); break; - case CAL_CLIENT_OPEN_PERMISSION_DENIED : - permission_error (gcal, cal_client_get_uri (client)); + case E_CAL_OPEN_PERMISSION_DENIED : + permission_error (gcal, e_cal_get_uri (client)); break; default: @@ -1849,7 +1849,7 @@ client_cal_opened_cb (CalClient *client, CalClientOpenStatus status, gpointer da if (client == priv->task_pad_client) e_calendar_table_set_status_message (E_CALENDAR_TABLE (priv->todo), NULL); else - e_cal_view_set_status_message (E_CAL_VIEW (priv->week_view), NULL); + e_calendar_view_set_status_message (E_CALENDAR_VIEW (priv->week_view), NULL); } /* Duplicates an array of categories */ @@ -1943,7 +1943,7 @@ merge_categories (GPtrArray *a, GPtrArray *b) * have to merge the categories of the calendar and tasks clients. */ static void -client_categories_changed_cb (CalClient *client, GPtrArray *categories, gpointer data) +client_categories_changed_cb (ECal *client, GPtrArray *categories, gpointer data) { GnomeCalendar *gcal; GnomeCalendarPrivate *priv; @@ -1967,7 +1967,7 @@ client_categories_changed_cb (CalClient *client, GPtrArray *categories, gpointer /* Callback when we get an error message from the backend */ static void -backend_error_cb (CalClient *client, const char *message, gpointer data) +backend_error_cb (ECal *client, const char *message, gpointer data) { GnomeCalendar *gcal; GnomeCalendarPrivate *priv; @@ -1977,7 +1977,7 @@ backend_error_cb (CalClient *client, const char *message, gpointer data) gcal = GNOME_CALENDAR (data); priv = gcal->priv; - uristr = get_uri_without_password (cal_client_get_uri (client)); + uristr = get_uri_without_password (e_cal_get_uri (client)); errmsg = g_strdup_printf (_("Error on %s:\n %s"), uristr, message); gnome_error_dialog_parented (errmsg, GTK_WINDOW (gtk_widget_get_toplevel (GTK_WIDGET (gcal)))); g_free (errmsg); @@ -1986,7 +1986,7 @@ backend_error_cb (CalClient *client, const char *message, gpointer data) /* Callback when the backend dies */ static void -backend_died_cb (CalClient *client, gpointer data) +backend_died_cb (ECal *client, gpointer data) { GnomeCalendar *gcal; GnomeCalendarPrivate *priv; @@ -1997,7 +1997,7 @@ backend_died_cb (CalClient *client, gpointer data) priv = gcal->priv; /* FIXME This doesn't remove the calendar from the list or anything */ - uristr = get_uri_without_password (cal_client_get_uri (client)); + uristr = get_uri_without_password (e_cal_get_uri (client)); if (client == priv->task_pad_client) { message = g_strdup_printf (_("The task backend for\n%s\n has crashed. " "You will have to restart Evolution in order " @@ -2013,7 +2013,7 @@ backend_died_cb (CalClient *client, gpointer data) uristr); for (i = 0; i < GNOME_CAL_LAST_VIEW; i++) - e_cal_view_set_status_message (priv->views[i], NULL); + e_calendar_view_set_status_message (priv->views[i], NULL); } gnome_error_dialog_parented (message, GTK_WINDOW (gtk_widget_get_toplevel (GTK_WIDGET (gcal)))); @@ -2035,7 +2035,7 @@ gnome_calendar_construct (GnomeCalendar *gcal) /* * TaskPad Folder Client. */ - priv->task_pad_client = cal_client_new ("", CALOBJ_TYPE_TODO); /* FIXME: use default tasks */ + priv->task_pad_client = e_cal_new ("", CALOBJ_TYPE_TODO); /* FIXME: use default tasks */ if (!priv->task_pad_client) return NULL; @@ -2102,22 +2102,22 @@ gnome_calendar_get_calendar_model (GnomeCalendar *gcal) priv = gcal->priv; - return e_cal_view_get_model (priv->views[priv->current_view_type]); + return e_calendar_view_get_model (priv->views[priv->current_view_type]); } /** * gnome_calendar_get_default_client */ -CalClient * +ECal * gnome_calendar_get_default_client (GnomeCalendar *gcal) { g_return_val_if_fail (GNOME_IS_CALENDAR (gcal), NULL); - return e_cal_model_get_default_client (e_cal_view_get_model (E_CAL_VIEW (gcal->priv->week_view))); + return e_cal_model_get_default_client (e_calendar_view_get_model (E_CALENDAR_VIEW (gcal->priv->week_view))); } /** - * gnome_calendar_get_task_pad_cal_client: + * gnome_calendar_get_task_pad_e_cal: * @gcal: A calendar view. * * Queries the calendar client interface object that a calendar view is using @@ -2125,8 +2125,8 @@ gnome_calendar_get_default_client (GnomeCalendar *gcal) * * Return value: A calendar client interface object. **/ -CalClient * -gnome_calendar_get_task_pad_cal_client (GnomeCalendar *gcal) +ECal * +gnome_calendar_get_task_pad_e_cal (GnomeCalendar *gcal) { GnomeCalendarPrivate *priv; @@ -2197,7 +2197,7 @@ gboolean gnome_calendar_add_event_uri (GnomeCalendar *gcal, const char *str_uri) { GnomeCalendarPrivate *priv; - CalClient *client; + ECal *client; int i; g_return_val_if_fail (gcal != NULL, FALSE); @@ -2210,7 +2210,7 @@ gnome_calendar_add_event_uri (GnomeCalendar *gcal, const char *str_uri) if (client) return TRUE; - client = cal_client_new (str_uri, CALOBJ_TYPE_EVENT); + client = e_cal_new (str_uri, CALOBJ_TYPE_EVENT); g_hash_table_insert (priv->clients, g_strdup (str_uri), client); priv->clients_list = g_list_prepend (priv->clients_list, client); @@ -2218,7 +2218,7 @@ gnome_calendar_add_event_uri (GnomeCalendar *gcal, const char *str_uri) g_signal_connect (G_OBJECT (client), "categories_changed", G_CALLBACK (client_categories_changed_cb), gcal); g_signal_connect (G_OBJECT (client), "backend_died", G_CALLBACK (backend_died_cb), gcal); - if (!cal_client_open (client, FALSE, NULL)) { + if (!e_cal_open (client, FALSE, NULL)) { g_hash_table_remove (priv->clients, str_uri); priv->clients_list = g_list_prepend (priv->clients_list, client); g_signal_handlers_disconnect_matched (client, G_SIGNAL_MATCH_DATA, @@ -2230,7 +2230,7 @@ gnome_calendar_add_event_uri (GnomeCalendar *gcal, const char *str_uri) for (i = 0; i < GNOME_CAL_LAST_VIEW; i++) { ECalModel *model; - model = e_cal_view_get_model (priv->views[i]); + model = e_calendar_view_get_model (priv->views[i]); e_cal_model_add_client (model, client); } @@ -2254,7 +2254,7 @@ gboolean gnome_calendar_remove_event_uri (GnomeCalendar *gcal, const char *str_uri) { GnomeCalendarPrivate *priv; - CalClient *client; + ECal *client; int i; g_return_val_if_fail (GNOME_IS_CALENDAR (gcal), FALSE); @@ -2274,7 +2274,7 @@ gnome_calendar_remove_event_uri (GnomeCalendar *gcal, const char *str_uri) for (i = 0; i < GNOME_CAL_LAST_VIEW; i++) { ECalModel *model; - model = e_cal_view_get_model (priv->views[i]); + model = e_calendar_view_get_model (priv->views[i]); e_cal_model_remove_client (model, client); } @@ -2309,7 +2309,7 @@ gboolean gnome_calendar_set_default_uri (GnomeCalendar *gcal, const char *uri) { GnomeCalendarPrivate *priv; - CalClient *client; + ECal *client; int i; g_return_val_if_fail (GNOME_IS_CALENDAR (gcal), FALSE); @@ -2322,7 +2322,7 @@ gnome_calendar_set_default_uri (GnomeCalendar *gcal, const char *uri) for (i = 0; i < GNOME_CAL_LAST_VIEW; i++) { e_cal_model_set_default_client ( - e_cal_view_get_model (E_CAL_VIEW (priv->views[i])), + e_calendar_view_get_model (E_CALENDAR_VIEW (priv->views[i])), client); } @@ -2383,7 +2383,7 @@ gnome_calendar_new_task (GnomeCalendar *gcal) { GnomeCalendarPrivate *priv; TaskEditor *tedit; - CalComponent *comp; + ECalComponent *comp; icalcomponent *icalcomp; const char *category; @@ -2394,12 +2394,12 @@ gnome_calendar_new_task (GnomeCalendar *gcal) tedit = task_editor_new (priv->task_pad_client); - icalcomp = e_cal_model_create_component_with_defaults (e_cal_view_get_model (E_CAL_VIEW (priv->week_view))); - comp = cal_component_new (); - cal_component_set_icalcomponent (comp, icalcomp); + icalcomp = e_cal_model_create_component_with_defaults (e_calendar_view_get_model (E_CALENDAR_VIEW (priv->week_view))); + comp = e_cal_component_new (); + e_cal_component_set_icalcomponent (comp, icalcomp); category = cal_search_bar_get_category (CAL_SEARCH_BAR (priv->search_bar)); - cal_component_set_categories (comp, category); + e_cal_component_set_categories (comp, category); comp_editor_edit_comp (COMP_EDITOR (tedit), comp); g_object_unref (comp); @@ -2420,7 +2420,7 @@ gnome_calendar_get_current_time_range (GnomeCalendar *gcal, priv = gcal->priv; - e_cal_view_get_selected_time_range (E_CAL_VIEW (gnome_calendar_get_current_view_widget (gcal)), + e_calendar_view_get_selected_time_range (E_CALENDAR_VIEW (gnome_calendar_get_current_view_widget (gcal)), start_time, end_time); } @@ -2439,7 +2439,7 @@ gnome_calendar_get_visible_time_range (GnomeCalendar *gcal, priv = gcal->priv; - retval = e_cal_view_get_visible_time_range (E_CAL_VIEW (gnome_calendar_get_current_view_widget (gcal)), + retval = e_calendar_view_get_visible_time_range (E_CALENDAR_VIEW (gnome_calendar_get_current_view_widget (gcal)), start_time, end_time); return retval; @@ -2698,7 +2698,7 @@ gnome_calendar_cut_clipboard (GnomeCalendar *gcal) location = get_focus_location (gcal); if (location == FOCUS_CALENDAR) { - e_cal_view_cut_clipboard (E_CAL_VIEW (gnome_calendar_get_current_view_widget (gcal))); + e_calendar_view_cut_clipboard (E_CALENDAR_VIEW (gnome_calendar_get_current_view_widget (gcal))); } else if (location == FOCUS_TASKPAD) e_calendar_table_cut_clipboard (E_CALENDAR_TABLE (priv->todo)); else @@ -2716,7 +2716,7 @@ gnome_calendar_copy_clipboard (GnomeCalendar *gcal) location = get_focus_location (gcal); if (location == FOCUS_CALENDAR) { - e_cal_view_copy_clipboard (E_CAL_VIEW (gnome_calendar_get_current_view_widget (gcal))); + e_calendar_view_copy_clipboard (E_CALENDAR_VIEW (gnome_calendar_get_current_view_widget (gcal))); } else if (location == FOCUS_TASKPAD) e_calendar_table_copy_clipboard (E_CALENDAR_TABLE (priv->todo)); else @@ -2734,7 +2734,7 @@ gnome_calendar_paste_clipboard (GnomeCalendar *gcal) location = get_focus_location (gcal); if (location == FOCUS_CALENDAR) { - e_cal_view_paste_clipboard (E_CAL_VIEW (gnome_calendar_get_current_view_widget (gcal))); + e_calendar_view_paste_clipboard (E_CALENDAR_VIEW (gnome_calendar_get_current_view_widget (gcal))); } else if (location == FOCUS_TASKPAD) e_calendar_table_paste_clipboard (E_CALENDAR_TABLE (priv->todo)); else @@ -2841,7 +2841,7 @@ gnome_calendar_delete_selection (GnomeCalendar *gcal) if (location == FOCUS_CALENDAR) { view = gnome_calendar_get_current_view_widget (gcal); - e_cal_view_delete_selected_events (E_CAL_VIEW (view)); + e_calendar_view_delete_selected_events (E_CALENDAR_VIEW (view)); } else if (location == FOCUS_TASKPAD) e_calendar_table_delete_selected (E_CALENDAR_TABLE (priv->todo)); else @@ -2864,12 +2864,12 @@ gnome_calendar_delete_selected_occurrence (GnomeCalendar *gcal) if (location == FOCUS_CALENDAR) { view = gnome_calendar_get_current_view_widget (gcal); - e_cal_view_delete_selected_occurrence (E_CAL_VIEW (view)); + e_calendar_view_delete_selected_occurrence (E_CALENDAR_VIEW (view)); } } static gboolean -check_instance_cb (CalComponent *comp, +check_instance_cb (ECalComponent *comp, time_t instance_start, time_t instance_end, gpointer data) @@ -2899,46 +2899,46 @@ gnome_calendar_purge (GnomeCalendar *gcal, time_t older_than) " (make-time \"%s\")))", start, end); - e_cal_view_set_status_message (E_CAL_VIEW (priv->week_view), _("Purging")); + e_calendar_view_set_status_message (E_CALENDAR_VIEW (priv->week_view), _("Purging")); /* FIXME Confirm expunge */ for (l = priv->clients_list; l != NULL; l = l->next) { - CalClient *client = l->data; + ECal *client = l->data; GList *objects, *l; gboolean read_only = TRUE; - cal_client_is_read_only (client, &read_only, NULL); + e_cal_is_read_only (client, &read_only, NULL); if (!read_only) continue; - if (!cal_client_get_object_list (client, sexp, &objects, NULL)) { + if (!e_cal_get_object_list (client, sexp, &objects, NULL)) { g_warning (G_STRLOC ": Could not get the objects"); continue; } for (l = objects; l; l = l->next) { - CalComponent *comp; + ECalComponent *comp; gboolean remove = TRUE; - comp = cal_component_new (); - cal_component_set_icalcomponent (comp, icalcomponent_new_clone (l->data)); + comp = e_cal_component_new (); + e_cal_component_set_icalcomponent (comp, icalcomponent_new_clone (l->data)); - cal_recur_generate_instances (comp, older_than, -1, - (CalRecurInstanceFn) check_instance_cb, + e_cal_recur_generate_instances (comp, older_than, -1, + (ECalRecurInstanceFn) check_instance_cb, &remove, - (CalRecurResolveTimezoneFn) cal_client_resolve_tzid_cb, + (ECalRecurResolveTimezoneFn) e_cal_resolve_tzid_cb, client, priv->zone); /* FIXME Better error handling */ if (remove) - cal_client_remove_object (client, icalcomponent_get_uid (l->data), NULL); + e_cal_remove_object (client, icalcomponent_get_uid (l->data), NULL); g_object_unref (comp); } } - e_cal_view_set_status_message (E_CAL_VIEW (priv->week_view), NULL); + e_calendar_view_set_status_message (E_CALENDAR_VIEW (priv->week_view), NULL); g_free (sexp); g_free (start); diff --git a/calendar/gui/gnome-cal.h b/calendar/gui/gnome-cal.h index 748be4dc0c..0b1aba9b64 100644 --- a/calendar/gui/gnome-cal.h +++ b/calendar/gui/gnome-cal.h @@ -30,7 +30,7 @@ #include <bonobo/bonobo-ui-component.h> #include <gal/widgets/e-popup-menu.h> #include <widgets/misc/e-calendar.h> -#include <cal-client/cal-client.h> +#include <libecal/e-cal.h> #include "e-calendar-table.h" @@ -106,8 +106,8 @@ void gnome_calendar_set_ui_component (GnomeCalendar *cal, ECalendarTable *gnome_calendar_get_task_pad (GnomeCalendar *gcal); ECalModel *gnome_calendar_get_calendar_model (GnomeCalendar *gcal); -CalClient *gnome_calendar_get_default_client (GnomeCalendar *gcal); -CalClient *gnome_calendar_get_task_pad_cal_client(GnomeCalendar *gcal); +ECal *gnome_calendar_get_default_client (GnomeCalendar *gcal); +ECal *gnome_calendar_get_task_pad_e_cal(GnomeCalendar *gcal); gboolean gnome_calendar_add_event_uri (GnomeCalendar *gcal, const char *str_uri); gboolean gnome_calendar_remove_event_uri (GnomeCalendar *gcal, const char *str_uri); diff --git a/calendar/gui/goto.c b/calendar/gui/goto.c index 770e2e40ac..4bff9addca 100644 --- a/calendar/gui/goto.c +++ b/calendar/gui/goto.c @@ -70,7 +70,7 @@ static void ecal_date_range_changed (ECalendarItem *calitem, gpointer user_data) { GoToDialog *dlg = user_data; - CalClient *client; + ECal *client; client = gnome_calendar_get_default_client (dlg->gcal); if (client) diff --git a/calendar/gui/itip-utils.c b/calendar/gui/itip-utils.c index e2640f01f4..2ea27974fd 100644 --- a/calendar/gui/itip-utils.c +++ b/calendar/gui/itip-utils.c @@ -36,8 +36,8 @@ #include <Evolution-Composer.h> #include <e-util/e-dialog-utils.h> #include <e-util/e-time-utils.h> -#include <cal-util/timeutil.h> -#include <cal-util/cal-util.h> +#include <libecal/e-cal-time-util.h> +#include <libecal/e-cal-util.h> #include "calendar-config.h" #include "itip-utils.h" @@ -86,24 +86,24 @@ itip_addresses_get_default (void) } gboolean -itip_organizer_is_user (CalComponent *comp, CalClient *client) +itip_organizer_is_user (ECalComponent *comp, ECal *client) { - CalComponentOrganizer organizer; + ECalComponentOrganizer organizer; const char *strip; gboolean user_org = FALSE; - if (!cal_component_has_organizer (comp)) + if (!e_cal_component_has_organizer (comp)) return FALSE; - cal_component_get_organizer (comp, &organizer); + e_cal_component_get_organizer (comp, &organizer); if (organizer.value != NULL) { strip = itip_strip_mailto (organizer.value); - if (cal_client_get_static_capability (client, CAL_STATIC_CAPABILITY_ORGANIZER_NOT_EMAIL_ADDRESS)) { + if (e_cal_get_static_capability (client, CAL_STATIC_CAPABILITY_ORGANIZER_NOT_EMAIL_ADDRESS)) { char *email; - if (cal_client_get_cal_address (client, &email, NULL) && !g_strcasecmp (email, strip)) { + if (e_cal_get_cal_address (client, &email, NULL) && !g_strcasecmp (email, strip)) { g_free (email); return TRUE; @@ -119,16 +119,16 @@ itip_organizer_is_user (CalComponent *comp, CalClient *client) } gboolean -itip_sentby_is_user (CalComponent *comp) +itip_sentby_is_user (ECalComponent *comp) { - CalComponentOrganizer organizer; + ECalComponentOrganizer organizer; const char *strip; gboolean user_sentby = FALSE; - if (!cal_component_has_organizer (comp)) + if (!e_cal_component_has_organizer (comp)) return FALSE; - cal_component_get_organizer (comp, &organizer); + e_cal_component_get_organizer (comp, &organizer); if (organizer.sentby != NULL) { strip = itip_strip_mailto (organizer.sentby); user_sentby = e_account_list_find(itip_addresses_get(), E_ACCOUNT_FIND_ID_ADDRESS, strip) != NULL; @@ -167,7 +167,7 @@ get_label (struct icaltimetype *tt) typedef struct { GHashTable *tzids; icalcomponent *icomp; - CalClient *client; + ECal *client; icalcomponent *zones; } ItipUtilTZData; @@ -191,7 +191,7 @@ foreach_tzid_callback (icalparameter *param, gpointer data) if (zone == NULL) zone = icaltimezone_get_builtin_timezone_from_tzid (tzid); if (zone == NULL && tz_data->client != NULL) - cal_client_get_timezone (tz_data->client, tzid, &zone, NULL); + e_cal_get_timezone (tz_data->client, tzid, &zone, NULL); if (zone == NULL) return; @@ -205,21 +205,21 @@ foreach_tzid_callback (icalparameter *param, gpointer data) } static icalcomponent * -comp_toplevel_with_zones (CalComponentItipMethod method, CalComponent *comp, CalClient *client, icalcomponent *zones) +comp_toplevel_with_zones (ECalComponentItipMethod method, ECalComponent *comp, ECal *client, icalcomponent *zones) { icalcomponent *top_level, *icomp; icalproperty *prop; icalvalue *value; ItipUtilTZData tz_data; - top_level = cal_util_new_top_level (); + top_level = e_cal_util_new_top_level (); prop = icalproperty_new (ICAL_METHOD_PROPERTY); value = icalvalue_new_method (itip_methods_enum[method]); icalproperty_set_value (prop, value); icalcomponent_add_property (top_level, prop); - icomp = cal_component_get_icalcomponent (comp); + icomp = e_cal_component_get_icalcomponent (comp); icomp = icalcomponent_new_clone (icomp); tz_data.tzids = g_hash_table_new (g_str_hash, g_str_equal); @@ -248,21 +248,21 @@ users_has_attendee (GList *users, const char *address) } static CORBA_char * -comp_from (CalComponentItipMethod method, CalComponent *comp) +comp_from (ECalComponentItipMethod method, ECalComponent *comp) { - CalComponentOrganizer organizer; - CalComponentAttendee *attendee; + ECalComponentOrganizer organizer; + ECalComponentAttendee *attendee; GSList *attendees; CORBA_char *str; switch (method) { - case CAL_COMPONENT_METHOD_PUBLISH: + case E_CAL_COMPONENT_METHOD_PUBLISH: return CORBA_string_dup (""); - case CAL_COMPONENT_METHOD_REQUEST: - case CAL_COMPONENT_METHOD_CANCEL: - case CAL_COMPONENT_METHOD_ADD: - cal_component_get_organizer (comp, &organizer); + case E_CAL_COMPONENT_METHOD_REQUEST: + case E_CAL_COMPONENT_METHOD_CANCEL: + case E_CAL_COMPONENT_METHOD_ADD: + e_cal_component_get_organizer (comp, &organizer); if (organizer.value == NULL) { e_notice (NULL, GTK_MESSAGE_ERROR, _("An organizer must be set.")); @@ -272,36 +272,36 @@ comp_from (CalComponentItipMethod method, CalComponent *comp) return CORBA_string_dup (itip_strip_mailto (organizer.value)); default: - if (!cal_component_has_attendees (comp)) + if (!e_cal_component_has_attendees (comp)) return CORBA_string_dup (""); - cal_component_get_attendee_list (comp, &attendees); + e_cal_component_get_attendee_list (comp, &attendees); attendee = attendees->data; str = CORBA_string_dup (attendee->value ? itip_strip_mailto (attendee->value) : ""); - cal_component_free_attendee_list (attendees); + e_cal_component_free_attendee_list (attendees); return str; } } static GNOME_Evolution_Composer_RecipientList * -comp_to_list (CalComponentItipMethod method, CalComponent *comp, GList *users) +comp_to_list (ECalComponentItipMethod method, ECalComponent *comp, GList *users) { GNOME_Evolution_Composer_RecipientList *to_list; GNOME_Evolution_Composer_Recipient *recipient; - CalComponentOrganizer organizer; + ECalComponentOrganizer organizer; GSList *attendees, *l; gint len; switch (method) { - case CAL_COMPONENT_METHOD_REQUEST: - case CAL_COMPONENT_METHOD_CANCEL: - cal_component_get_attendee_list (comp, &attendees); + case E_CAL_COMPONENT_METHOD_REQUEST: + case E_CAL_COMPONENT_METHOD_CANCEL: + e_cal_component_get_attendee_list (comp, &attendees); len = g_slist_length (attendees); if (len <= 0) { e_notice (NULL, GTK_MESSAGE_ERROR, _("At least one attendee is necessary")); - cal_component_free_attendee_list (attendees); + e_cal_component_free_attendee_list (attendees); return NULL; } @@ -310,7 +310,7 @@ comp_to_list (CalComponentItipMethod method, CalComponent *comp, GList *users) to_list->_length = 0; to_list->_buffer = CORBA_sequence_GNOME_Evolution_Composer_Recipient_allocbuf (len); - cal_component_get_organizer (comp, &organizer); + e_cal_component_get_organizer (comp, &organizer); if (organizer.value == NULL) { e_notice (NULL, GTK_MESSAGE_ERROR, _("An organizer must be set.")); @@ -318,7 +318,7 @@ comp_to_list (CalComponentItipMethod method, CalComponent *comp, GList *users) } for (l = attendees; l != NULL; l = l->next) { - CalComponentAttendee *att = l->data; + ECalComponentAttendee *att = l->data; if (users_has_attendee (users, att->value)) continue; @@ -334,15 +334,15 @@ comp_to_list (CalComponentItipMethod method, CalComponent *comp, GList *users) to_list->_length++; } - cal_component_free_attendee_list (attendees); + e_cal_component_free_attendee_list (attendees); break; - case CAL_COMPONENT_METHOD_REPLY: - case CAL_COMPONENT_METHOD_ADD: - case CAL_COMPONENT_METHOD_REFRESH: - case CAL_COMPONENT_METHOD_COUNTER: - case CAL_COMPONENT_METHOD_DECLINECOUNTER: - cal_component_get_organizer (comp, &organizer); + case E_CAL_COMPONENT_METHOD_REPLY: + case E_CAL_COMPONENT_METHOD_ADD: + case E_CAL_COMPONENT_METHOD_REFRESH: + case E_CAL_COMPONENT_METHOD_COUNTER: + case E_CAL_COMPONENT_METHOD_DECLINECOUNTER: + e_cal_component_get_organizer (comp, &organizer); if (organizer.value == NULL) { e_notice (NULL, GTK_MESSAGE_ERROR, _("An organizer must be set.")); @@ -375,25 +375,25 @@ comp_to_list (CalComponentItipMethod method, CalComponent *comp, GList *users) } static CORBA_char * -comp_subject (CalComponentItipMethod method, CalComponent *comp) +comp_subject (ECalComponentItipMethod method, ECalComponent *comp) { - CalComponentText caltext; + ECalComponentText caltext; const char *description, *prefix = NULL; GSList *alist; CORBA_char *subject; - cal_component_get_summary (comp, &caltext); + e_cal_component_get_summary (comp, &caltext); if (caltext.value != NULL) description = caltext.value; else { - switch (cal_component_get_vtype (comp)) { - case CAL_COMPONENT_EVENT: + switch (e_cal_component_get_vtype (comp)) { + case E_CAL_COMPONENT_EVENT: description = _("Event information"); - case CAL_COMPONENT_TODO: + case E_CAL_COMPONENT_TODO: description = _("Task information"); - case CAL_COMPONENT_JOURNAL: + case E_CAL_COMPONENT_JOURNAL: description = _("Journal information"); - case CAL_COMPONENT_FREEBUSY: + case E_CAL_COMPONENT_FREEBUSY: description = _("Free/Busy information"); default: description = _("Calendar information"); @@ -401,18 +401,18 @@ comp_subject (CalComponentItipMethod method, CalComponent *comp) } switch (method) { - case CAL_COMPONENT_METHOD_PUBLISH: - case CAL_COMPONENT_METHOD_REQUEST: + case E_CAL_COMPONENT_METHOD_PUBLISH: + case E_CAL_COMPONENT_METHOD_REQUEST: /* FIXME: If this is an update to a previous * PUBLISH or REQUEST, then prefix = U_("Updated"); */ break; - case CAL_COMPONENT_METHOD_REPLY: - cal_component_get_attendee_list (comp, &alist); + case E_CAL_COMPONENT_METHOD_REPLY: + e_cal_component_get_attendee_list (comp, &alist); if (alist != NULL) { - CalComponentAttendee *a = alist->data; + ECalComponentAttendee *a = alist->data; switch (a->status) { case ICAL_PARTSTAT_ACCEPTED: @@ -427,27 +427,27 @@ comp_subject (CalComponentItipMethod method, CalComponent *comp) default: break; } - cal_component_free_attendee_list (alist); + e_cal_component_free_attendee_list (alist); } break; - case CAL_COMPONENT_METHOD_ADD: + case E_CAL_COMPONENT_METHOD_ADD: prefix = _("Updated"); break; - case CAL_COMPONENT_METHOD_CANCEL: + case E_CAL_COMPONENT_METHOD_CANCEL: prefix = _("Cancel"); break; - case CAL_COMPONENT_METHOD_REFRESH: + case E_CAL_COMPONENT_METHOD_REFRESH: prefix = _("Refresh"); break; - case CAL_COMPONENT_METHOD_COUNTER: + case E_CAL_COMPONENT_METHOD_COUNTER: prefix = _("Counter-proposal"); break; - case CAL_COMPONENT_METHOD_DECLINECOUNTER: + case E_CAL_COMPONENT_METHOD_DECLINECOUNTER: prefix = _("Declined"); break; @@ -466,22 +466,22 @@ comp_subject (CalComponentItipMethod method, CalComponent *comp) } static CORBA_char * -comp_content_type (CalComponent *comp, CalComponentItipMethod method) +comp_content_type (ECalComponent *comp, ECalComponentItipMethod method) { char tmp[256]; sprintf (tmp, "text/calendar; name=\"%s\"; charset=utf-8; METHOD=%s", - cal_component_get_vtype (comp) == CAL_COMPONENT_FREEBUSY ? + e_cal_component_get_vtype (comp) == E_CAL_COMPONENT_FREEBUSY ? "freebusy.ifb" : "calendar.ics", itip_methods[method]); return CORBA_string_dup (tmp); } static CORBA_char * -comp_filename (CalComponent *comp) +comp_filename (ECalComponent *comp) { - switch (cal_component_get_vtype (comp)) { - case CAL_COMPONENT_FREEBUSY: + switch (e_cal_component_get_vtype (comp)) { + case E_CAL_COMPONENT_FREEBUSY: return CORBA_string_dup ("freebusy.ifb"); default: return CORBA_string_dup ("calendar.ics"); @@ -489,29 +489,29 @@ comp_filename (CalComponent *comp) } static CORBA_char * -comp_description (CalComponent *comp) +comp_description (ECalComponent *comp) { CORBA_char *description; - CalComponentDateTime dt; + ECalComponentDateTime dt; char *start = NULL, *end = NULL; - switch (cal_component_get_vtype (comp)) { - case CAL_COMPONENT_EVENT: + switch (e_cal_component_get_vtype (comp)) { + case E_CAL_COMPONENT_EVENT: return CORBA_string_dup (_("Event information")); - case CAL_COMPONENT_TODO: + case E_CAL_COMPONENT_TODO: return CORBA_string_dup (_("Task information")); - case CAL_COMPONENT_JOURNAL: + case E_CAL_COMPONENT_JOURNAL: return CORBA_string_dup (_("Journal information")); - case CAL_COMPONENT_FREEBUSY: - cal_component_get_dtstart (comp, &dt); + case E_CAL_COMPONENT_FREEBUSY: + e_cal_component_get_dtstart (comp, &dt); if (dt.value) start = get_label (dt.value); - cal_component_free_datetime (&dt); + e_cal_component_free_datetime (&dt); - cal_component_get_dtend (comp, &dt); + e_cal_component_get_dtend (comp, &dt); if (dt.value) end = get_label (dt.value); - cal_component_free_datetime (&dt); + e_cal_component_free_datetime (&dt); if (start != NULL && end != NULL) { char *tmp; @@ -530,7 +530,7 @@ comp_description (CalComponent *comp) } static gboolean -comp_server_send (CalComponentItipMethod method, CalComponent *comp, CalClient *client, +comp_server_send (ECalComponentItipMethod method, ECalComponent *comp, ECal *client, icalcomponent *zones, GList **users) { icalcomponent *top_level; @@ -538,7 +538,7 @@ comp_server_send (CalComponentItipMethod method, CalComponent *comp, CalClient * GError *error = NULL; top_level = comp_toplevel_with_zones (method, comp, client, zones); - if (!cal_client_send_objects (client, top_level, &error)) { + if (!e_cal_send_objects (client, top_level, &error)) { /* FIXME Really need a book problem status code */ if (error->code != E_CALENDAR_STATUS_OK) { /* FIXME Better error message */ @@ -556,14 +556,14 @@ comp_server_send (CalComponentItipMethod method, CalComponent *comp, CalClient * } static gboolean -comp_limit_attendees (CalComponent *comp) +comp_limit_attendees (ECalComponent *comp) { icalcomponent *icomp; icalproperty *prop; gboolean found = FALSE, match = FALSE; GSList *l, *list = NULL; - icomp = cal_component_get_icalcomponent (comp); + icomp = e_cal_component_get_icalcomponent (comp); for (prop = icalcomponent_get_first_property (icomp, ICAL_ATTENDEE_PROPERTY); prop != NULL; @@ -607,11 +607,11 @@ comp_limit_attendees (CalComponent *comp) } static void -comp_sentby (CalComponent *comp, CalClient *client) +comp_sentby (ECalComponent *comp, ECal *client) { - CalComponentOrganizer organizer; + ECalComponentOrganizer organizer; - cal_component_get_organizer (comp, &organizer); + e_cal_component_get_organizer (comp, &organizer); if (!organizer.value) { EAccount *a = itip_addresses_get_default (); @@ -620,7 +620,7 @@ comp_sentby (CalComponent *comp, CalClient *client) organizer.cn = a->id->name; organizer.language = NULL; - cal_component_set_organizer (comp, &organizer); + e_cal_component_set_organizer (comp, &organizer); g_free ((char *) organizer.value); return; @@ -634,7 +634,7 @@ comp_sentby (CalComponent *comp, CalClient *client) organizer.cn = g_strdup (organizer.cn); organizer.language = g_strdup (organizer.language); - cal_component_set_organizer (comp, &organizer); + e_cal_component_set_organizer (comp, &organizer); g_free ((char *)organizer.value); g_free ((char *)organizer.sentby); @@ -642,26 +642,26 @@ comp_sentby (CalComponent *comp, CalClient *client) g_free ((char *)organizer.language); } } -static CalComponent * -comp_minimal (CalComponent *comp, gboolean attendee) +static ECalComponent * +comp_minimal (ECalComponent *comp, gboolean attendee) { - CalComponent *clone; + ECalComponent *clone; icalcomponent *icomp, *icomp_clone; icalproperty *prop; - CalComponentOrganizer organizer; + ECalComponentOrganizer organizer; const char *uid; GSList *comments; struct icaltimetype itt; - CalComponentRange recur_id; + ECalComponentRange recur_id; - clone = cal_component_new (); - cal_component_set_new_vtype (clone, cal_component_get_vtype (comp)); + clone = e_cal_component_new (); + e_cal_component_set_new_vtype (clone, e_cal_component_get_vtype (comp)); if (attendee) { GSList *attendees; - cal_component_get_attendee_list (comp, &attendees); - cal_component_set_attendee_list (clone, attendees); + e_cal_component_get_attendee_list (comp, &attendees); + e_cal_component_set_attendee_list (clone, attendees); if (!comp_limit_attendees (clone)) { e_notice (NULL, GTK_MESSAGE_ERROR, @@ -672,34 +672,34 @@ comp_minimal (CalComponent *comp, gboolean attendee) itt = icaltime_from_timet_with_zone (time (NULL), FALSE, icaltimezone_get_utc_timezone ()); - cal_component_set_dtstamp (clone, &itt); + e_cal_component_set_dtstamp (clone, &itt); - cal_component_get_organizer (comp, &organizer); + e_cal_component_get_organizer (comp, &organizer); if (organizer.value == NULL) goto error; - cal_component_set_organizer (clone, &organizer); + e_cal_component_set_organizer (clone, &organizer); - cal_component_get_uid (comp, &uid); - cal_component_set_uid (clone, uid); + e_cal_component_get_uid (comp, &uid); + e_cal_component_set_uid (clone, uid); - cal_component_get_comment_list (comp, &comments); + e_cal_component_get_comment_list (comp, &comments); if (g_slist_length (comments) <= 1) { - cal_component_set_comment_list (clone, comments); + e_cal_component_set_comment_list (clone, comments); } else { GSList *l = comments; comments = g_slist_remove_link (comments, l); - cal_component_set_comment_list (clone, l); - cal_component_free_text_list (l); + e_cal_component_set_comment_list (clone, l); + e_cal_component_free_text_list (l); } - cal_component_free_text_list (comments); + e_cal_component_free_text_list (comments); - cal_component_get_recurid (comp, &recur_id); + e_cal_component_get_recurid (comp, &recur_id); if (recur_id.datetime.value != NULL) - cal_component_set_recurid (clone, &recur_id); + e_cal_component_set_recurid (clone, &recur_id); - icomp = cal_component_get_icalcomponent (comp); - icomp_clone = cal_component_get_icalcomponent (clone); + icomp = e_cal_component_get_icalcomponent (comp); + icomp_clone = e_cal_component_get_icalcomponent (clone); for (prop = icalcomponent_get_first_property (icomp, ICAL_X_PROPERTY); prop != NULL; prop = icalcomponent_get_next_property (icomp, ICAL_X_PROPERTY)) @@ -710,7 +710,7 @@ comp_minimal (CalComponent *comp, gboolean attendee) icalcomponent_add_property (icomp_clone, p); } - cal_component_rescan (clone); + e_cal_component_rescan (clone); return clone; @@ -719,31 +719,31 @@ comp_minimal (CalComponent *comp, gboolean attendee) return NULL; } -static CalComponent * -comp_compliant (CalComponentItipMethod method, CalComponent *comp, CalClient *client, icalcomponent *zones) +static ECalComponent * +comp_compliant (ECalComponentItipMethod method, ECalComponent *comp, ECal *client, icalcomponent *zones) { - CalComponent *clone, *temp_clone; + ECalComponent *clone, *temp_clone; struct icaltimetype itt; - clone = cal_component_clone (comp); + clone = e_cal_component_clone (comp); itt = icaltime_from_timet_with_zone (time (NULL), FALSE, icaltimezone_get_utc_timezone ()); - cal_component_set_dtstamp (clone, &itt); + e_cal_component_set_dtstamp (clone, &itt); /* Make UNTIL date a datetime in a simple recurrence */ - if (cal_component_has_recurrences (clone) - && cal_component_has_simple_recurrence (clone)) { + if (e_cal_component_has_recurrences (clone) + && e_cal_component_has_simple_recurrence (clone)) { GSList *rrule_list; struct icalrecurrencetype *r; - cal_component_get_rrule_list (clone, &rrule_list); + e_cal_component_get_rrule_list (clone, &rrule_list); r = rrule_list->data; if (!icaltime_is_null_time (r->until) && r->until.is_date) { - CalComponentDateTime dt; + ECalComponentDateTime dt; icaltimezone *from_zone = NULL, *to_zone; - cal_component_get_dtstart (clone, &dt); + e_cal_component_get_dtstart (clone, &dt); if (dt.value->is_date) { from_zone = icaltimezone_get_builtin_timezone (calendar_config_get_timezone ()); @@ -756,7 +756,7 @@ comp_compliant (CalComponentItipMethod method, CalComponent *comp, CalClient *cl from_zone = icaltimezone_get_builtin_timezone_from_tzid (dt.tzid); if (from_zone == NULL && client != NULL) /* FIXME Error checking */ - cal_client_get_timezone (client, dt.tzid, &from_zone, NULL); + e_cal_get_timezone (client, dt.tzid, &from_zone, NULL); } to_zone = icaltimezone_get_utc_timezone (); @@ -769,44 +769,44 @@ comp_compliant (CalComponentItipMethod method, CalComponent *comp, CalClient *cl icaltimezone_convert_time (&r->until, from_zone, to_zone); r->until.is_utc = TRUE; - cal_component_set_rrule_list (clone, rrule_list); - cal_component_abort_sequence (clone); + e_cal_component_set_rrule_list (clone, rrule_list); + e_cal_component_abort_sequence (clone); } - cal_component_free_recur_list (rrule_list); + e_cal_component_free_recur_list (rrule_list); } /* We delete incoming alarms anyhow, and this helps with outlook */ - cal_component_remove_all_alarms (clone); + e_cal_component_remove_all_alarms (clone); /* Strip X-LIC-ERROR stuff */ - cal_component_strip_errors (clone); + e_cal_component_strip_errors (clone); /* Comply with itip spec */ switch (method) { - case CAL_COMPONENT_METHOD_PUBLISH: + case E_CAL_COMPONENT_METHOD_PUBLISH: comp_sentby (clone, client); - cal_component_set_attendee_list (clone, NULL); + e_cal_component_set_attendee_list (clone, NULL); break; - case CAL_COMPONENT_METHOD_REQUEST: + case E_CAL_COMPONENT_METHOD_REQUEST: comp_sentby (clone, client); break; - case CAL_COMPONENT_METHOD_CANCEL: + case E_CAL_COMPONENT_METHOD_CANCEL: comp_sentby (clone, client); break; - case CAL_COMPONENT_METHOD_REPLY: + case E_CAL_COMPONENT_METHOD_REPLY: break; - case CAL_COMPONENT_METHOD_ADD: + case E_CAL_COMPONENT_METHOD_ADD: break; - case CAL_COMPONENT_METHOD_REFRESH: + case E_CAL_COMPONENT_METHOD_REFRESH: /* Need to remove almost everything */ temp_clone = comp_minimal (clone, TRUE); g_object_unref (clone); clone = temp_clone; break; - case CAL_COMPONENT_METHOD_COUNTER: + case E_CAL_COMPONENT_METHOD_COUNTER: break; - case CAL_COMPONENT_METHOD_DECLINECOUNTER: + case E_CAL_COMPONENT_METHOD_DECLINECOUNTER: /* Need to remove almost everything */ temp_clone = comp_minimal (clone, FALSE); g_object_unref (clone); @@ -820,11 +820,11 @@ comp_compliant (CalComponentItipMethod method, CalComponent *comp, CalClient *cl } gboolean -itip_send_comp (CalComponentItipMethod method, CalComponent *send_comp, - CalClient *client, icalcomponent *zones) +itip_send_comp (ECalComponentItipMethod method, ECalComponent *send_comp, + ECal *client, icalcomponent *zones) { GNOME_Evolution_Composer composer_server; - CalComponent *comp = NULL; + ECalComponent *comp = NULL; icalcomponent *top_level = NULL; GList *users = NULL; GNOME_Evolution_Composer_RecipientList *to_list = NULL; @@ -840,7 +840,7 @@ itip_send_comp (CalComponentItipMethod method, CalComponent *send_comp, CORBA_exception_init (&ev); /* Give the server a chance to manipulate the comp */ - if (method != CAL_COMPONENT_METHOD_PUBLISH) { + if (method != E_CAL_COMPONENT_METHOD_PUBLISH) { if (!comp_server_send (method, send_comp, client, zones, &users)) goto cleanup; } @@ -852,7 +852,7 @@ itip_send_comp (CalComponentItipMethod method, CalComponent *send_comp, /* Recipients */ to_list = comp_to_list (method, comp, users); - if (method != CAL_COMPONENT_METHOD_PUBLISH) { + if (method != E_CAL_COMPONENT_METHOD_PUBLISH) { if (to_list == NULL || to_list->_length == 0) { /* We sent them all via the server */ retval = TRUE; @@ -894,7 +894,7 @@ itip_send_comp (CalComponentItipMethod method, CalComponent *send_comp, top_level = comp_toplevel_with_zones (method, comp, client, zones); ical_string = icalcomponent_as_ical_string (top_level); - if (cal_component_get_vtype (comp) == CAL_COMPONENT_EVENT) { + if (e_cal_component_get_vtype (comp) == E_CAL_COMPONENT_EVENT) { GNOME_Evolution_Composer_setBody (composer_server, ical_string, content_type, &ev); } else { GNOME_Evolution_Composer_setMultipartType (composer_server, GNOME_Evolution_Composer_MIXED, &ev); @@ -929,7 +929,7 @@ itip_send_comp (CalComponentItipMethod method, CalComponent *send_comp, goto cleanup; } - if (method == CAL_COMPONENT_METHOD_PUBLISH) { + if (method == E_CAL_COMPONENT_METHOD_PUBLISH) { GNOME_Evolution_Composer_show (composer_server, &ev); if (BONOBO_EX (&ev)) g_warning ("Unable to show the composer while sending iTip message"); diff --git a/calendar/gui/itip-utils.h b/calendar/gui/itip-utils.h index 981fd2a12d..cf9dd37643 100644 --- a/calendar/gui/itip-utils.h +++ b/calendar/gui/itip-utils.h @@ -5,31 +5,31 @@ #include <libical/ical.h> #include <string.h> #include <glib.h> -#include <cal-client/cal-client.h> -#include <cal-util/cal-component.h> +#include <libecal/e-cal.h> +#include <libecal/e-cal-component.h> #include <e-util/e-account-list.h> typedef enum { - CAL_COMPONENT_METHOD_PUBLISH, - CAL_COMPONENT_METHOD_REQUEST, - CAL_COMPONENT_METHOD_REPLY, - CAL_COMPONENT_METHOD_ADD, - CAL_COMPONENT_METHOD_CANCEL, - CAL_COMPONENT_METHOD_REFRESH, - CAL_COMPONENT_METHOD_COUNTER, - CAL_COMPONENT_METHOD_DECLINECOUNTER -} CalComponentItipMethod; + E_CAL_COMPONENT_METHOD_PUBLISH, + E_CAL_COMPONENT_METHOD_REQUEST, + E_CAL_COMPONENT_METHOD_REPLY, + E_CAL_COMPONENT_METHOD_ADD, + E_CAL_COMPONENT_METHOD_CANCEL, + E_CAL_COMPONENT_METHOD_REFRESH, + E_CAL_COMPONENT_METHOD_COUNTER, + E_CAL_COMPONENT_METHOD_DECLINECOUNTER +} ECalComponentItipMethod; EAccountList *itip_addresses_get (void); EAccount *itip_addresses_get_default (void); -gboolean itip_organizer_is_user (CalComponent *comp, CalClient *client); -gboolean itip_sentby_is_user (CalComponent *comp); +gboolean itip_organizer_is_user (ECalComponent *comp, ECal *client); +gboolean itip_sentby_is_user (ECalComponent *comp); const gchar *itip_strip_mailto (const gchar *address); -gboolean itip_send_comp (CalComponentItipMethod method, CalComponent *comp, - CalClient *client, icalcomponent *zones); +gboolean itip_send_comp (ECalComponentItipMethod method, ECalComponent *comp, + ECal *client, icalcomponent *zones); #endif diff --git a/calendar/gui/print.c b/calendar/gui/print.c index 0c0fa44886..2bea5a915a 100644 --- a/calendar/gui/print.c +++ b/calendar/gui/print.c @@ -45,7 +45,7 @@ #include <e-util/e-dialog-widgets.h> #include <e-util/e-time-utils.h> #include <gal/widgets/e-unicode.h> -#include <cal-util/timeutil.h> +#include <libecal/e-cal-time-util.h> #include "calendar-commands.h" #include "calendar-config.h" #include "e-day-view.h" @@ -523,7 +523,7 @@ format_date(time_t time, int flags, char *buffer, int bufflen) } static gboolean -instance_cb (CalComponent *comp, time_t instance_start, time_t instance_end, gpointer data) +instance_cb (ECalComponent *comp, time_t instance_start, time_t instance_end, gpointer data) { gboolean *found = data; @@ -543,7 +543,7 @@ print_month_small (GnomePrintContext *pc, GnomeCalendar *gcal, time_t month, int bordertitle) { icaltimezone *zone = get_timezone (); - CalClient *client; + ECal *client; GnomeFont *font, *font_bold, *font_normal; time_t now, next; int x, y; @@ -640,7 +640,7 @@ print_month_small (GnomePrintContext *pc, GnomeCalendar *gcal, time_t month, sprintf (buf, "%d", day); /* this is a slow messy way to do this ... but easy ... */ - cal_client_generate_instances (client, now, CALOBJ_TYPE_EVENT, + e_cal_generate_instances (client, now, CALOBJ_TYPE_EVENT, time_day_end_with_zone (now, zone), instance_cb, &found); @@ -856,7 +856,7 @@ print_day_background (GnomePrintContext *pc, GnomeCalendar *gcal, /* This adds one event to the view, adding it to the appropriate array. */ static gint -print_day_add_event (CalComponent *comp, +print_day_add_event (ECalComponent *comp, time_t start, time_t end, gint days_shown, @@ -932,7 +932,7 @@ print_day_add_event (CalComponent *comp, static gboolean -print_day_details_cb (CalComponent *comp, time_t istart, time_t iend, +print_day_details_cb (ECalComponent *comp, time_t istart, time_t iend, gpointer data) { struct pdinfo *pdi = (struct pdinfo *)data; @@ -1124,7 +1124,7 @@ print_day_details (GnomePrintContext *pc, GnomeCalendar *gcal, time_t whence, double left, double right, double top, double bottom) { icaltimezone *zone = get_timezone (); - CalClient *client; + ECal *client; EDayViewEvent *event; GnomeFont *font; time_t start, end; @@ -1152,7 +1152,7 @@ print_day_details (GnomePrintContext *pc, GnomeCalendar *gcal, time_t whence, /* Get the events from the server. */ client = gnome_calendar_get_default_client (gcal); - cal_client_generate_instances (client, CALOBJ_TYPE_EVENT, start, end, + e_cal_generate_instances (client, CALOBJ_TYPE_EVENT, start, end, print_day_details_cb, &pdi); qsort (pdi.long_events->data, pdi.long_events->len, sizeof (EDayViewEvent), e_day_view_event_sort_func); @@ -1242,7 +1242,7 @@ print_day_details (GnomePrintContext *pc, GnomeCalendar *gcal, time_t whence, /* This adds one event to the view, adding it to the appropriate array. */ static gboolean -print_week_summary_cb (CalComponent *comp, +print_week_summary_cb (ECalComponent *comp, time_t start, time_t end, gpointer data) @@ -1550,7 +1550,7 @@ print_week_summary (GnomePrintContext *pc, GnomeCalendar *gcal, double left, double right, double top, double bottom) { icaltimezone *zone = get_timezone (); - CalClient *client; + ECal *client; EWeekViewEvent *event; struct psinfo psi; time_t day_start; @@ -1588,7 +1588,7 @@ print_week_summary (GnomePrintContext *pc, GnomeCalendar *gcal, /* Get the events from the server. */ client = gnome_calendar_get_default_client (gcal); - cal_client_generate_instances (client, CALOBJ_TYPE_EVENT, + e_cal_generate_instances (client, CALOBJ_TYPE_EVENT, psi.day_starts[0], psi.day_starts[psi.days_shown], print_week_summary_cb, &psi); @@ -1773,7 +1773,7 @@ print_todo_details (GnomePrintContext *pc, GnomeCalendar *gcal, time_t start, time_t end, double left, double right, double top, double bottom) { - CalClient *client; + ECal *client; GnomeFont *font_summary; double y, yend, x, xend; struct icaltimetype *tt; @@ -1787,7 +1787,7 @@ print_todo_details (GnomePrintContext *pc, GnomeCalendar *gcal, task_pad = gnome_calendar_get_task_pad (gcal); table = e_calendar_table_get_table (task_pad); model = e_calendar_table_get_model (task_pad); - client = gnome_calendar_get_task_pad_cal_client (gcal); + client = gnome_calendar_get_task_pad_e_cal (gcal); font_summary = get_font_for_size (10, GNOME_FONT_BOOK, FALSE); @@ -1803,8 +1803,8 @@ print_todo_details (GnomePrintContext *pc, GnomeCalendar *gcal, rows = e_table_model_row_count (E_TABLE_MODEL (model)); for (row = 0; row < rows; row++) { ECalModelComponent *comp_data; - CalComponent *comp; - CalComponentText summary; + ECalComponent *comp; + ECalComponentText summary; int model_row; model_row = e_table_view_to_model_row (table, row); @@ -1812,10 +1812,10 @@ print_todo_details (GnomePrintContext *pc, GnomeCalendar *gcal, if (!comp_data) continue; - comp = cal_component_new (); - cal_component_set_icalcomponent (comp, icalcomponent_new_clone (comp_data->icalcomp)); + comp = e_cal_component_new (); + e_cal_component_set_icalcomponent (comp, icalcomponent_new_clone (comp_data->icalcomp)); - cal_component_get_summary (comp, &summary); + e_cal_component_get_summary (comp, &summary); if (!summary.value) { g_object_unref (comp); continue; @@ -1831,9 +1831,9 @@ print_todo_details (GnomePrintContext *pc, GnomeCalendar *gcal, print_border (pc, x + 2, x + 8, y - 3, y - 11, 0.1, -1.0); /* If the task is complete, print a tick in the box. */ - cal_component_get_completed (comp, &tt); + e_cal_component_get_completed (comp, &tt); if (tt) { - cal_component_free_icaltimetype (tt); + e_cal_component_free_icaltimetype (tt); gnome_print_setrgbcolor (pc, 0, 0, 0); gnome_print_setlinewidth (pc, 1.0); @@ -2163,7 +2163,7 @@ write_label_piece (time_t t, char *buffer, int size, char *stext, char *etext) } static icaltimezone* -get_zone_from_tzid (CalClient *client, const char *tzid) +get_zone_from_tzid (ECal *client, const char *tzid) { icaltimezone *zone; @@ -2171,7 +2171,7 @@ get_zone_from_tzid (CalClient *client, const char *tzid) the builtin timezone with the TZID first. */ zone = icaltimezone_get_builtin_timezone_from_tzid (tzid); if (!zone) { - if (!cal_client_get_timezone (client, tzid, &zone, NULL)) + if (!e_cal_get_timezone (client, tzid, &zone, NULL)) /* FIXME: Handle error better. */ g_warning ("Couldn't get timezone from server: %s", tzid ? tzid : ""); @@ -2181,44 +2181,44 @@ get_zone_from_tzid (CalClient *client, const char *tzid) } static void -print_date_label (GnomePrintContext *pc, CalComponent *comp, CalClient *client, +print_date_label (GnomePrintContext *pc, ECalComponent *comp, ECal *client, double left, double right, double top, double bottom) { icaltimezone *start_zone, *end_zone, *due_zone, *completed_zone; - CalComponentDateTime datetime; + ECalComponentDateTime datetime; time_t start = 0, end = 0, complete = 0, due = 0; static char buffer[1024]; - cal_component_get_dtstart (comp, &datetime); + e_cal_component_get_dtstart (comp, &datetime); if (datetime.value) { start_zone = get_zone_from_tzid (client, datetime.tzid); start = icaltime_as_timet_with_zone (*datetime.value, start_zone); } - cal_component_free_datetime (&datetime); + e_cal_component_free_datetime (&datetime); - cal_component_get_dtend (comp, &datetime); + e_cal_component_get_dtend (comp, &datetime); if (datetime.value) { end_zone = get_zone_from_tzid (client, datetime.tzid); end = icaltime_as_timet_with_zone (*datetime.value, end_zone); } - cal_component_free_datetime (&datetime); + e_cal_component_free_datetime (&datetime); - cal_component_get_due (comp, &datetime); + e_cal_component_get_due (comp, &datetime); if (datetime.value) { due_zone = get_zone_from_tzid (client, datetime.tzid); due = icaltime_as_timet_with_zone (*datetime.value, due_zone); } - cal_component_free_datetime (&datetime); + e_cal_component_free_datetime (&datetime); - cal_component_get_completed (comp, &datetime.value); + e_cal_component_get_completed (comp, &datetime.value); if (datetime.value) { completed_zone = icaltimezone_get_utc_timezone (); complete = icaltime_as_timet_with_zone (*datetime.value, completed_zone); - cal_component_free_icaltimetype (datetime.value); + e_cal_component_free_icaltimetype (datetime.value); } buffer[0] = '\0'; @@ -2248,24 +2248,24 @@ print_date_label (GnomePrintContext *pc, CalComponent *comp, CalClient *client, } static void -print_comp_item (GnomePrintContext *pc, CalComponent *comp, CalClient *client, +print_comp_item (GnomePrintContext *pc, ECalComponent *comp, ECal *client, double left, double right, double top, double bottom) { GnomeFont *font; - CalComponentVType vtype; - CalComponentText text; + ECalComponentVType vtype; + ECalComponentText text; GSList *desc, *l; const char *title, *categories; char *categories_string; GSList *contact_list, *elem; gint header_size; - vtype = cal_component_get_vtype (comp); + vtype = e_cal_component_get_vtype (comp); /* We should only be asked to print VEVENTs or VTODOs. */ - if (vtype == CAL_COMPONENT_EVENT) + if (vtype == E_CAL_COMPONENT_EVENT) title = _("Appointment"); - else if (vtype == CAL_COMPONENT_TODO) + else if (vtype == E_CAL_COMPONENT_TODO) title = _("Task"); else return; @@ -2285,7 +2285,7 @@ print_comp_item (GnomePrintContext *pc, CalComponent *comp, CalClient *client, /* Summary */ font = get_font_for_size (18, GNOME_FONT_BOLD, FALSE); - cal_component_get_summary (comp, &text); + e_cal_component_get_summary (comp, &text); top = bound_text (pc, font, text.value, left, right, top - 3, bottom, 0); g_object_unref (font); @@ -2297,7 +2297,7 @@ print_comp_item (GnomePrintContext *pc, CalComponent *comp, CalClient *client, font = get_font_for_size (12, GNOME_FONT_BOOK, FALSE); /* For a VTODO we print the Status, Priority, % Complete and URL. */ - if (vtype == CAL_COMPONENT_TODO) { + if (vtype == E_CAL_COMPONENT_TODO) { icalproperty_status status; const char *status_string = NULL; int *percent; @@ -2305,7 +2305,7 @@ print_comp_item (GnomePrintContext *pc, CalComponent *comp, CalClient *client, const char *url; /* Status */ - cal_component_get_status (comp, &status); + e_cal_component_get_status (comp, &status); if (status != ICAL_STATUS_NONE) { switch (status) { case ICAL_STATUS_NEEDSACTION: @@ -2335,12 +2335,12 @@ print_comp_item (GnomePrintContext *pc, CalComponent *comp, CalClient *client, } /* Priority */ - cal_component_get_priority (comp, &priority); + e_cal_component_get_priority (comp, &priority); if (priority && *priority >= 0) { char *priority_string, *text; - priority_string = cal_util_priority_to_string (*priority); - cal_component_free_priority (priority); + priority_string = e_cal_util_priority_to_string (*priority); + e_cal_component_free_priority (priority); text = g_strdup_printf (_("Priority: %s"), priority_string); top = bound_text (pc, font, text, @@ -2350,12 +2350,12 @@ print_comp_item (GnomePrintContext *pc, CalComponent *comp, CalClient *client, } /* Percent Complete */ - cal_component_get_percent (comp, &percent); + e_cal_component_get_percent (comp, &percent); if (percent) { char *percent_string; percent_string = g_strdup_printf (_("Percent Complete: %i"), *percent); - cal_component_free_percent (percent); + e_cal_component_free_percent (percent); top = bound_text (pc, font, percent_string, left, right, top, bottom, 0); @@ -2364,7 +2364,7 @@ print_comp_item (GnomePrintContext *pc, CalComponent *comp, CalClient *client, /* URL */ - cal_component_get_url (comp, &url); + e_cal_component_get_url (comp, &url); if (url && url[0]) { char *url_string = g_strdup_printf (_("URL: %s"), url); @@ -2378,7 +2378,7 @@ print_comp_item (GnomePrintContext *pc, CalComponent *comp, CalClient *client, } /* Categories */ - cal_component_get_categories (comp, &categories); + e_cal_component_get_categories (comp, &categories); if (categories && categories[0]) { categories_string = g_strdup_printf (_("Categories: %s"), categories); @@ -2389,17 +2389,17 @@ print_comp_item (GnomePrintContext *pc, CalComponent *comp, CalClient *client, } /* Contacts */ - cal_component_get_contact_list (comp, &contact_list); + e_cal_component_get_contact_list (comp, &contact_list); if (contact_list) { GString *contacts = g_string_new (_("Contacts: ")); for (elem = contact_list; elem; elem = elem->next) { - CalComponentText *t = elem->data; + ECalComponentText *t = elem->data; /* Put a comma between contacts. */ if (elem != contact_list) g_string_append (contacts, ", "); g_string_append (contacts, t->value); } - cal_component_free_text_list (contact_list); + e_cal_component_free_text_list (contact_list); top = bound_text (pc, font, contacts->str, left, right, top, bottom, 0); @@ -2411,14 +2411,14 @@ print_comp_item (GnomePrintContext *pc, CalComponent *comp, CalClient *client, top -= 16; /* Description */ - cal_component_get_description_list (comp, &desc); + e_cal_component_get_description_list (comp, &desc); for (l = desc; l != NULL; l = l->next) { - CalComponentText *text = l->data; + ECalComponentText *text = l->data; if (text->value != NULL) top = bound_text (pc, font, text->value, left, right, top-3, bottom, 0); } - cal_component_free_text_list (desc); + e_cal_component_free_text_list (desc); g_object_unref (font); gnome_print_showpage (pc); @@ -2542,7 +2542,7 @@ print_calendar (GnomeCalendar *gcal, gboolean preview, time_t date, void -print_comp (CalComponent *comp, CalClient *client, gboolean preview) +print_comp (ECalComponent *comp, ECal *client, gboolean preview) { GnomePrintJob *gpm; GnomePrintContext *pc; @@ -2550,7 +2550,7 @@ print_comp (CalComponent *comp, CalClient *client, gboolean preview) double l, r, t, b; g_return_if_fail (comp != NULL); - g_return_if_fail (IS_CAL_COMPONENT (comp)); + g_return_if_fail (E_IS_CAL_COMPONENT (comp)); if (!print_config) print_config = gnome_print_config_default (); diff --git a/calendar/gui/print.h b/calendar/gui/print.h index 4571b36976..495007d81d 100644 --- a/calendar/gui/print.h +++ b/calendar/gui/print.h @@ -34,7 +34,7 @@ typedef enum { } PrintView; void print_calendar (GnomeCalendar *gcal, gboolean preview, time_t at, PrintView default_view); -void print_comp (CalComponent *comp, CalClient *client, gboolean preview); +void print_comp (ECalComponent *comp, ECal *client, gboolean preview); void print_setup (void); diff --git a/calendar/gui/tag-calendar.c b/calendar/gui/tag-calendar.c index 147a69f246..8e6937d08a 100644 --- a/calendar/gui/tag-calendar.c +++ b/calendar/gui/tag-calendar.c @@ -23,7 +23,7 @@ #include <config.h> #endif -#include <cal-util/timeutil.h> +#include <libecal/e-cal-time-util.h> #include "calendar-config.h" #include "tag-calendar.h" @@ -85,22 +85,22 @@ prepare_tag (ECalendar *ecal, struct calendar_tag_closure *c, icaltimezone *zone return TRUE; } -/* Marks the specified range in an ECalendar; called from cal_client_generate_instances() */ +/* Marks the specified range in an ECalendar; called from e_cal_generate_instances() */ static gboolean -tag_calendar_cb (CalComponent *comp, +tag_calendar_cb (ECalComponent *comp, time_t istart, time_t iend, gpointer data) { struct calendar_tag_closure *c = data; struct icaltimetype start_tt, end_tt; - CalComponentTransparency transparency; + ECalComponentTransparency transparency; /* If we are skipping TRANSPARENT events, return if the event is transparent. */ if (c->skip_transparent_events) { - cal_component_get_transparency (comp, &transparency); - if (transparency == CAL_COMPONENT_TRANSP_TRANSPARENT) + e_cal_component_get_transparency (comp, &transparency); + if (transparency == E_CAL_COMPONENT_TRANSP_TRANSPARENT) return TRUE; } @@ -125,20 +125,20 @@ tag_calendar_cb (CalComponent *comp, * range. The occurrences are extracted from the specified calendar @client. **/ void -tag_calendar_by_client (ECalendar *ecal, CalClient *client) +tag_calendar_by_client (ECalendar *ecal, ECal *client) { struct calendar_tag_closure c; g_return_if_fail (ecal != NULL); g_return_if_fail (E_IS_CALENDAR (ecal)); g_return_if_fail (client != NULL); - g_return_if_fail (IS_CAL_CLIENT (client)); + g_return_if_fail (E_IS_CAL (client)); /* If the ECalendar isn't visible, we just return. */ if (!GTK_WIDGET_VISIBLE (ecal)) return; - if (cal_client_get_load_state (client) != CAL_CLIENT_LOAD_LOADED) + if (e_cal_get_load_state (client) != E_CAL_LOAD_LOADED) return; if (!prepare_tag (ecal, &c, NULL, TRUE)) @@ -149,7 +149,7 @@ tag_calendar_by_client (ECalendar *ecal, CalClient *client) #if 0 g_print ("DateNavigator generating instances\n"); #endif - cal_client_generate_instances (client, CALOBJ_TYPE_EVENT, + e_cal_generate_instances (client, CALOBJ_TYPE_EVENT, c.start_time, c.end_time, tag_calendar_cb, &c); } @@ -160,20 +160,20 @@ tag_calendar_by_client (ECalendar *ecal, CalClient *client) static icaltimezone* resolve_tzid_cb (const char *tzid, gpointer data) { - CalClient *client; + ECal *client; icaltimezone *zone = NULL; g_return_val_if_fail (data != NULL, NULL); - g_return_val_if_fail (IS_CAL_CLIENT (data), NULL); + g_return_val_if_fail (E_IS_CAL (data), NULL); - client = CAL_CLIENT (data); + client = E_CAL (data); /* Try to find the builtin timezone first. */ zone = icaltimezone_get_builtin_timezone_from_tzid (tzid); if (!zone) { /* FIXME: Handle errors. */ - cal_client_get_timezone (client, tzid, &zone, NULL); + e_cal_get_timezone (client, tzid, &zone, NULL); } return zone; @@ -194,7 +194,7 @@ resolve_tzid_cb (const char *tzid, gpointer data) * have been added to the calendar on the server yet. **/ void -tag_calendar_by_comp (ECalendar *ecal, CalComponent *comp, CalClient *client, icaltimezone *display_zone, +tag_calendar_by_comp (ECalendar *ecal, ECalComponent *comp, ECal *client, icaltimezone *display_zone, gboolean clear_first, gboolean comp_is_on_server) { struct calendar_tag_closure c; @@ -202,7 +202,7 @@ tag_calendar_by_comp (ECalendar *ecal, CalComponent *comp, CalClient *client, ic g_return_if_fail (ecal != NULL); g_return_if_fail (E_IS_CALENDAR (ecal)); g_return_if_fail (comp != NULL); - g_return_if_fail (IS_CAL_COMPONENT (comp)); + g_return_if_fail (E_IS_CAL_COMPONENT (comp)); /* If the ECalendar isn't visible, we just return. */ if (!GTK_WIDGET_VISIBLE (ecal)) @@ -217,12 +217,12 @@ tag_calendar_by_comp (ECalendar *ecal, CalComponent *comp, CalClient *client, ic g_print ("DateNavigator generating instances\n"); #endif if (comp_is_on_server) { - cal_recur_generate_instances (comp, c.start_time, c.end_time, + e_cal_recur_generate_instances (comp, c.start_time, c.end_time, tag_calendar_cb, &c, - cal_client_resolve_tzid_cb, + e_cal_resolve_tzid_cb, client, c.zone); } else { - cal_recur_generate_instances (comp, c.start_time, c.end_time, + e_cal_recur_generate_instances (comp, c.start_time, c.end_time, tag_calendar_cb, &c, resolve_tzid_cb, client, c.zone); diff --git a/calendar/gui/tag-calendar.h b/calendar/gui/tag-calendar.h index dc146e9c9f..d31d675543 100644 --- a/calendar/gui/tag-calendar.h +++ b/calendar/gui/tag-calendar.h @@ -23,11 +23,11 @@ #define TAG_CALENDAR_H #include <widgets/misc/e-calendar.h> -#include <cal-client/cal-client.h> +#include <libecal/e-cal.h> -void tag_calendar_by_client (ECalendar *ecal, CalClient *client); -void tag_calendar_by_comp (ECalendar *ecal, CalComponent *comp, - CalClient *client, icaltimezone *display_zone, +void tag_calendar_by_client (ECalendar *ecal, ECal *client); +void tag_calendar_by_comp (ECalendar *ecal, ECalComponent *comp, + ECal *client, icaltimezone *display_zone, gboolean clear_first, gboolean comp_is_on_server); #endif diff --git a/calendar/gui/tasks-component.c b/calendar/gui/tasks-component.c index 4e5de7c692..bdbe34db72 100644 --- a/calendar/gui/tasks-component.c +++ b/calendar/gui/tasks-component.c @@ -29,7 +29,7 @@ #include <bonobo/bonobo-control.h> #include <bonobo/bonobo-i18n.h> #include <gconf/gconf-client.h> -#include "cal-client/cal-client.h" +#include <libecal/e-cal.h> #include "e-cal-model.h" #include "e-tasks.h" #include "tasks-component.h" @@ -53,7 +53,7 @@ struct _TasksComponentPrivate { static void add_uri_for_source (ESource *source, ETasks *tasks) { - CalClient *client; + ECal *client; ECalModel *model; GError *error = NULL; char *uri = e_source_get_uri (source); @@ -61,8 +61,8 @@ add_uri_for_source (ESource *source, ETasks *tasks) model = e_calendar_table_get_model (e_tasks_get_calendar_table (tasks)); client = e_cal_model_get_client_for_uri (model, uri); if (!client) { - client = cal_client_new (uri, CALOBJ_TYPE_TODO); - if (cal_client_open (client, FALSE, &error)) { + client = e_cal_new (uri, CALOBJ_TYPE_TODO); + if (e_cal_open (client, FALSE, &error)) { e_cal_model_add_client (model, client); } else { g_warning (G_STRLOC ": Could not open tasks at %s: %s", uri, error->message); @@ -77,7 +77,7 @@ add_uri_for_source (ESource *source, ETasks *tasks) static void remove_uri_for_source (ESource *source, ETasks *tasks) { - CalClient *client; + ECal *client; ECalModel *model; char *uri = e_source_get_uri (source); @@ -143,7 +143,7 @@ primary_source_selection_changed_cb (ESourceSelector *selector, TasksComponent * { TasksComponentPrivate *priv; ESource *source; - CalClient *client; + ECal *client; char *uri; ECalModel *model; diff --git a/calendar/gui/tasks-control.c b/calendar/gui/tasks-control.c index 2729416ca8..8264393573 100644 --- a/calendar/gui/tasks-control.c +++ b/calendar/gui/tasks-control.c @@ -169,7 +169,7 @@ tasks_control_get_property (BonoboPropertyBag *bag, case TASKS_CONTROL_PROPERTY_URI_IDX: model = e_calendar_table_get_model (e_tasks_get_calendar_table (tasks)); - uri = cal_client_get_uri (e_cal_model_get_default_client (model)); + uri = e_cal_get_uri (e_cal_model_get_default_client (model)); BONOBO_ARG_SET_STRING (arg, uri); break; @@ -240,7 +240,7 @@ sensitize_commands (ETasks *tasks, BonoboControl *control, int n_selected) g_assert (uic != NULL); model = e_calendar_table_get_model (e_tasks_get_calendar_table (tasks)); - cal_client_is_read_only (e_cal_model_get_default_client (model), &read_only, NULL); + e_cal_is_read_only (e_cal_model_get_default_client (model), &read_only, NULL); bonobo_ui_component_set_prop (uic, "/commands/TasksCut", "sensitive", n_selected == 0 || read_only ? "0" : "1", diff --git a/calendar/idl/evolution-calendar.idl b/calendar/idl/evolution-calendar.idl index 8d0d344b5a..30f92dffc8 100644 --- a/calendar/idl/evolution-calendar.idl +++ b/calendar/idl/evolution-calendar.idl @@ -17,264 +17,9 @@ module GNOME { module Evolution { module Calendar { - /* A calendar component (event/todo/journal/etc), represented as an - * iCalendar string. - */ - typedef string CalObj; - typedef sequence<CalObj> CalObjSeq; - - typedef sequence<string> stringlist; - /* A unique identifier for a calendar component */ typedef string CalObjUID; - /* A unique identified for an event recurrence */ - typedef string CalRecurID; - - /* Simple sequence of strings */ - typedef sequence<string> StringSeq; - - /* Sequence of unique identifiers */ - typedef sequence<CalObjUID> CalObjUIDSeq; - - /* A VTIMEZONE component, represented as an iCalendar string. */ - typedef string CalTimezoneObj; - - /* A unique identifier for a VTIMEZONE component, i.e. its TZID. */ - typedef string CalTimezoneObjUID; - - /* A unique identifier for an alarm subcomponent */ - typedef string CalAlarmUID; - - /* Flags for getting UID sequences */ - typedef long CalObjType; - const CalObjType TYPE_EVENT = 1 << 0; - const CalObjType TYPE_TODO = 1 << 1; - const CalObjType TYPE_JOURNAL = 1 << 2; - const CalObjType TYPE_ANY = 0x07; - - /* Flags for getting UID sequences */ - typedef long CalObjModType; - const CalObjModType MOD_THIS = 1 << 0; - const CalObjModType MOD_THISANDPRIOR = 1 << 1; - const CalObjModType MOD_THISANDFUTURE = 1 << 2; - const CalObjModType MOD_ALL = 0x07; - - /* Flags for getting URI sequences */ - typedef long CalMode; - const CalMode MODE_LOCAL = 1 << 0; - const CalMode MODE_REMOTE = 1 << 1; - const CalMode MODE_ANY = 0x07; - - /* Types of object changes made */ - typedef long CalObjChangeType; - const CalObjChangeType ADDED = 1 << 0; - const CalObjChangeType MODIFIED = 1 << 1; - const CalObjChangeType DELETED = 1 << 2; - - /* Used to store a time_t */ - typedef unsigned long Time_t; - - /* An instance of a calendar component that actually occurs. These are - * "virtual" objects in that they are used to represent instances of - * recurring events and alarms. "Real" objects just contain the - * information required to figure out the times at which they recur or - * trigger. - */ - struct CalObjInstance { - CalObjUID uid; - Time_t start; - Time_t end; - }; - - /* Used to transfer a list of component occurrences */ - typedef sequence<CalObjInstance> CalObjInstanceSeq; - - /* An object change */ - struct CalObjChange { - CalObj calobj; - CalObjChangeType type; - }; - - /* Used to transfer a list of changed components */ - typedef sequence<CalObjChange> CalObjChangeSeq; - - /* Used to represent users and lists of users */ - typedef string User; - typedef sequence<User> UserList; - - enum CallStatus { - Success, - RepositoryOffline, - PermissionDenied, - InvalidRange, - ObjectNotFound, - InvalidObject, - CardIdAlreadyExists, - AuthenticationFailed, - AuthenticationRequired, - UnsupportedField, - UnsupportedMethod, - UnsupportedAuthenticationMethod, - TLSNotAvailable, - NoSuchCal, - - /* These can be returned for successful searches, but - indicate the result set was truncated */ - SearchSizeLimitExceeded, - SearchTimeLimitExceeded, - - InvalidQuery, - QueryRefused, - - CouldNotCancel, - - OtherError - }; - - interface Query; - - interface Listener; - - interface QueryListener; - - /* Calendar client interface */ - interface Cal : Bonobo::Unknown { - exception NotFound {}; - exception InvalidRange {}; - - /* A calendar is identified by its URI */ - readonly attribute string uri; - - oneway void open (in boolean only_if_exists); - oneway void remove (); - - /* Check write permissions for calendar */ - oneway void isReadOnly (); - - /* Information on the backend's capabilities */ - oneway void getStaticCapabilities (); - - /* Return the cal address associated with this calendar, if any. */ - oneway void getCalAddress (); - - oneway void getAlarmEmailAddress (); - - /* Returns the LDAP attribute to get attendees from */ - oneway void getLdapAttribute (); - - /* For going online/offline */ - void setMode (in CalMode mode); - - /* Get a default object of the backend's type */ - oneway void getDefaultObject (); - - /* Gets a component based on its URI */ - oneway void getObject (in CalObjUID uid, in CalRecurID rid); - - oneway void getObjectList (in string query); - - /* Methods for manipulating timezones */ - oneway void getTimezone (in CalTimezoneObjUID tzid); - oneway void addTimezone (in CalTimezoneObj tz); - /* The timezone used to resolve DATE and floating DATE-TIME values. */ - oneway void setDefaultTimezone (in CalTimezoneObjUID tzid); - - /* Gets a list of components that changed */ - oneway void getChanges (in string change_id); - - /* Returns free/busy objects for the given interval */ - oneway void getFreeBusy (in UserList users, in Time_t start, in Time_t end); - - /* Discards an alarm from a given component */ - oneway void discardAlarm (in CalObjUID uid, in CalAlarmUID auid); - - /* Methods for manipulating iCalendar objects */ - oneway void createObject (in CalObj calobj); - oneway void modifyObject (in CalObj calobj, in CalObjModType mod); - oneway void removeObject (in CalObjUID uid, in CalRecurID rid, in CalObjModType mod); - - /* Methods for getting/sending iCalendar VCALENDARS via iTip/iMip */ - oneway void receiveObjects (in CalObj calobj); - oneway void sendObjects (in CalObj calobj); - - /* Query methods */ - oneway void getQuery (in string sexp, in QueryListener ql); - }; - - /* Listener for changes in a calendar */ - interface Listener : Bonobo::Unknown { - /* Return status when setting calendar mode */ - enum SetModeStatus { - MODE_SET, /* All OK */ - MODE_NOT_SET, /* Generic error */ - MODE_NOT_SUPPORTED /* Mode not supported */ - }; - - oneway void notifyReadOnly (in CallStatus status, in boolean read_only); - oneway void notifyCalAddress (in CallStatus status, in string address); - oneway void notifyAlarmEmailAddress (in CallStatus status, in string address); - oneway void notifyLDAPAttribute (in CallStatus status, in string ldap_attribute); - oneway void notifyStaticCapabilities (in CallStatus status, in string capabilities); - - oneway void notifyCalOpened (in CallStatus status); - oneway void notifyCalRemoved (in CallStatus status); - - oneway void notifyObjectCreated (in CallStatus status, in string uid); - oneway void notifyObjectModified (in CallStatus status); - oneway void notifyObjectRemoved (in CallStatus status); - - oneway void notifyAlarmDiscarded (in CallStatus status); - - oneway void notifyObjectsReceived (in CallStatus status); - oneway void notifyObjectsSent (in CallStatus status); - - oneway void notifyDefaultObjectRequested (in CallStatus status, in CalObj object); - oneway void notifyObjectRequested (in CallStatus status, in CalObj object); - oneway void notifyObjectListRequested (in CallStatus status, in stringlist objects); - oneway void notifyQuery (in CallStatus status, in Query query); - - oneway void notifyTimezoneRequested (in CallStatus status, in CalTimezoneObj tz); - oneway void notifyTimezoneAdded (in CallStatus status, in CalTimezoneObjUID tzid); - oneway void notifyDefaultTimezoneSet (in CallStatus status); - - oneway void notifyChanges (in CallStatus status, in CalObjChangeSeq changes); - oneway void notifyFreeBusy (in CallStatus status, in CalObjSeq freebusy); - - /* Called from a Calendar when the mode is changed */ - oneway void notifyCalSetMode (in SetModeStatus status, in CalMode mode); - - /* Called from a Calendar when the list of categories changes */ - oneway void notifyCategoriesChanged (in StringSeq categories); - - /* Called from a Calendar when there is an error not notified otherwise */ - oneway void notifyErrorOccurred (in string message); - }; - - /* Handle to a live query on a calendar */ - interface Query : Bonobo::Unknown { - oneway void start (); - }; - - /* Listener for changes in a query of a calendar */ - interface QueryListener : Bonobo::Unknown { - oneway void notifyObjectsAdded (in stringlist objects); - oneway void notifyObjectsModified (in stringlist objects); - oneway void notifyObjectsRemoved (in CalObjUIDSeq uids); - oneway void notifyQueryProgress (in string message, in short percent); - oneway void notifyQueryDone (in CallStatus status); - }; - - /* A calendar factory, can load and create calendars */ - interface CalFactory : Bonobo::Unknown { - exception NilListener {}; - exception InvalidURI {}; - exception UnsupportedMethod {}; - - Cal getCal (in string uri, in CalObjType type, in Listener listener) - raises (NilListener, InvalidURI, UnsupportedMethod); - }; - /* Interface to the alarm notification service */ interface AlarmNotify : Bonobo::Unknown { exception InvalidURI {}; diff --git a/calendar/importers/Makefile.am b/calendar/importers/Makefile.am index 658f494cd8..8f4862daeb 100644 --- a/calendar/importers/Makefile.am +++ b/calendar/importers/Makefile.am @@ -11,12 +11,8 @@ INCLUDES = \ -I$(top_srcdir) \ -I$(top_builddir)/shell \ -I$(top_srcdir)/shell \ - -I$(top_srcdir)/calendar/cal-client \ - -I$(top_builddir)/calendar/cal-client \ -I$(top_srcdir)/calendar \ -I$(top_builddir)/calendar \ - -I$(top_srcdir)/libical/src \ - -I$(top_srcdir)/libical/src/libicalvcal \ $(EVOLUTION_CALENDAR_CFLAGS) libevolution_calendar_importers_la_SOURCES = \ @@ -28,7 +24,6 @@ libevolution_calendar_importers_la_LDFLAGS = -avoid-version -module libevolution_calendar_importers_la_LIBADD = \ $(top_builddir)/shell/importer/libevolution-importer.la \ - $(top_builddir)/libical/src/libicalvcal/libicalvcal-evolution.la \ $(IMPORTERS_LIBS) # evolution_calendar_importer_SOURCES = \ diff --git a/calendar/importers/icalendar-importer.c b/calendar/importers/icalendar-importer.c index a98fd9f126..733b5e41de 100644 --- a/calendar/importers/icalendar-importer.c +++ b/calendar/importers/icalendar-importer.c @@ -32,13 +32,13 @@ #include <libgnome/gnome-i18n.h> #include <bonobo/bonobo-control.h> #include <bonobo/bonobo-exception.h> -#include <cal-client.h> +#include <libecal/e-cal.h> #include <importer/evolution-importer.h> #include <importer/evolution-intelligent-importer.h> #include <importer/GNOME_Evolution_Importer.h> #include <shell/e-shell.h> #include <shell/evolution-shell-client.h> -#include "icalvcal.h" +#include <libical/icalvcal.h> #include "evolution-calendar-importer.h" /* We timeout after 2 minutes, when opening the folders. */ @@ -46,8 +46,8 @@ typedef struct { - CalClient *client; - CalClient *tasks_client; + ECal *client; + ECal *tasks_client; EvolutionImporter *importer; icalcomponent *icalcomp; gboolean folder_contains_events; @@ -179,34 +179,34 @@ prepare_tasks (icalcomponent *icalcomp, GList *vtodos) g_list_free (vtodos); } -static CalClientResult -update_single_object (CalClient *client, icalcomponent *icalcomp) +static ECalResult +update_single_object (ECal *client, icalcomponent *icalcomp) { char *uid; icalcomponent *tmp_icalcomp; uid = (char *) icalcomponent_get_uid (icalcomp); - if (cal_client_get_object (client, uid, NULL, &tmp_icalcomp, NULL)) - return cal_client_modify_object (client, icalcomp, CALOBJ_MOD_ALL, NULL) - ? CAL_CLIENT_RESULT_SUCCESS : CAL_CLIENT_RESULT_CORBA_ERROR; + if (e_cal_get_object (client, uid, NULL, &tmp_icalcomp, NULL)) + return e_cal_modify_object (client, icalcomp, CALOBJ_MOD_ALL, NULL) + ? E_CAL_RESULT_SUCCESS : E_CAL_RESULT_CORBA_ERROR; - return cal_client_create_object (client, icalcomp, &uid, NULL) - ? CAL_CLIENT_RESULT_SUCCESS : CAL_CLIENT_RESULT_CORBA_ERROR; + return e_cal_create_object (client, icalcomp, &uid, NULL) + ? E_CAL_RESULT_SUCCESS : E_CAL_RESULT_CORBA_ERROR; } -static CalClientResult -update_objects (CalClient *client, icalcomponent *icalcomp) +static ECalResult +update_objects (ECal *client, icalcomponent *icalcomp) { icalcomponent *subcomp; icalcomponent_kind kind; - CalClientResult result; + ECalResult result; kind = icalcomponent_isa (icalcomp); if (kind == ICAL_VTODO_COMPONENT || kind == ICAL_VEVENT_COMPONENT) return update_single_object (client, icalcomp); else if (kind != ICAL_VCALENDAR_COMPONENT) - return CAL_CLIENT_RESULT_INVALID_OBJECT; + return E_CAL_RESULT_INVALID_OBJECT; subcomp = icalcomponent_get_first_component (icalcomp, ICAL_ANY_COMPONENT); while (subcomp) { @@ -217,21 +217,21 @@ update_objects (CalClient *client, icalcomponent *icalcomp) zone = icaltimezone_new (); icaltimezone_set_component (zone, subcomp); - result = cal_client_add_timezone (client, zone, NULL); + result = e_cal_add_timezone (client, zone, NULL); icaltimezone_free (zone, 1); - if (result != CAL_CLIENT_RESULT_SUCCESS) + if (result != E_CAL_RESULT_SUCCESS) return result; } else if (kind == ICAL_VTODO_COMPONENT || kind == ICAL_VEVENT_COMPONENT) { result = update_single_object (client, subcomp); - if (result != CAL_CLIENT_RESULT_SUCCESS) + if (result != E_CAL_RESULT_SUCCESS) return result; } subcomp = icalcomponent_get_next_component (icalcomp, ICAL_ANY_COMPONENT); } - return CAL_CLIENT_RESULT_SUCCESS; + return E_CAL_RESULT_SUCCESS; } static void @@ -240,27 +240,27 @@ process_item_fn (EvolutionImporter *importer, void *closure, CORBA_Environment *ev) { - CalClientLoadState state, tasks_state; + ECalLoadState state, tasks_state; ICalImporter *ici = (ICalImporter *) closure; GNOME_Evolution_ImporterListener_ImporterResult result; result = GNOME_Evolution_ImporterListener_OK; g_return_if_fail (ici != NULL); - g_return_if_fail (IS_CAL_CLIENT (ici->client)); + g_return_if_fail (E_IS_CAL (ici->client)); g_return_if_fail (ici->icalcomp != NULL); - state = cal_client_get_load_state (ici->client); - tasks_state = cal_client_get_load_state (ici->tasks_client); - if (state == CAL_CLIENT_LOAD_LOADING - || tasks_state == CAL_CLIENT_LOAD_LOADING) { + state = e_cal_get_load_state (ici->client); + tasks_state = e_cal_get_load_state (ici->tasks_client); + if (state == E_CAL_LOAD_LOADING + || tasks_state == E_CAL_LOAD_LOADING) { GNOME_Evolution_ImporterListener_notifyResult ( listener, GNOME_Evolution_ImporterListener_BUSY, TRUE, ev); return; - } else if (state != CAL_CLIENT_LOAD_LOADED - || tasks_state != CAL_CLIENT_LOAD_LOADED) { + } else if (state != E_CAL_LOAD_LOADED + || tasks_state != E_CAL_LOAD_LOADED) { GNOME_Evolution_ImporterListener_notifyResult ( listener, GNOME_Evolution_ImporterListener_UNSUPPORTED_OPERATION, @@ -274,20 +274,20 @@ process_item_fn (EvolutionImporter *importer, contains just tasks, we strip out the VEVENTs, which do not get imported at all. */ if (ici->folder_contains_events && ici->folder_contains_tasks) { - if (update_objects (ici->client, ici->icalcomp) != CAL_CLIENT_RESULT_SUCCESS) + if (update_objects (ici->client, ici->icalcomp) != E_CAL_RESULT_SUCCESS) result = GNOME_Evolution_ImporterListener_BAD_DATA; } else if (ici->folder_contains_events) { GList *vtodos = prepare_events (ici->icalcomp); - if (update_objects (ici->client, ici->icalcomp) != CAL_CLIENT_RESULT_SUCCESS) + if (update_objects (ici->client, ici->icalcomp) != E_CAL_RESULT_SUCCESS) result = GNOME_Evolution_ImporterListener_BAD_DATA; prepare_tasks (ici->icalcomp, vtodos); if (update_objects (ici->tasks_client, - ici->icalcomp) != CAL_CLIENT_RESULT_SUCCESS) + ici->icalcomp) != E_CAL_RESULT_SUCCESS) result = GNOME_Evolution_ImporterListener_BAD_DATA; } else { prepare_tasks (ici->icalcomp, NULL); - if (update_objects (ici->client, ici->icalcomp) != CAL_CLIENT_RESULT_SUCCESS) + if (update_objects (ici->client, ici->icalcomp) != E_CAL_RESULT_SUCCESS) result = GNOME_Evolution_ImporterListener_BAD_DATA; } @@ -369,14 +369,14 @@ load_file_fn (EvolutionImporter *importer, } else real_uri = g_strdup (physical_uri); - /* create CalClient's */ + /* create ECal's */ if (!ici->client) - ici->client = cal_client_new (real_uri, CALOBJ_TYPE_EVENT); + ici->client = e_cal_new (real_uri, CALOBJ_TYPE_EVENT); if (!ici->tasks_client) - ici->tasks_client = cal_client_new ("", CALOBJ_TYPE_TODO); /* FIXME */ + ici->tasks_client = e_cal_new ("", CALOBJ_TYPE_TODO); /* FIXME */ - if (cal_client_open (ici->client, TRUE, NULL) - && cal_client_open (ici->tasks_client, FALSE, NULL)) { + if (e_cal_open (ici->client, TRUE, NULL) + && e_cal_open (ici->tasks_client, FALSE, NULL)) { ici->icalcomp = icalcomp; ret = TRUE; } @@ -521,14 +521,14 @@ vcal_load_file_fn (EvolutionImporter *importer, } else real_uri = g_strdup (physical_uri); - /* create CalClient's */ + /* create ECal's */ if (!ici->client) - ici->client = cal_client_new (real_uri, CALOBJ_TYPE_EVENT); + ici->client = e_cal_new (real_uri, CALOBJ_TYPE_EVENT); if (!ici->tasks_client) - ici->tasks_client = cal_client_new ("", CALOBJ_TYPE_TODO); + ici->tasks_client = e_cal_new ("", CALOBJ_TYPE_TODO); - if (cal_client_open (ici->client, TRUE, NULL) - && cal_client_open (ici->tasks_client, FALSE, NULL)) { + if (e_cal_open (ici->client, TRUE, NULL) + && e_cal_open (ici->tasks_client, FALSE, NULL)) { ici->icalcomp = icalcomp; ret = TRUE; } @@ -601,7 +601,7 @@ gnome_calendar_import_data_fn (EvolutionIntelligentImporter *ii, icalcomponent *icalcomp = NULL; char *filename; GList *vtodos; - CalClient *calendar_client = NULL, *tasks_client = NULL; + ECal *calendar_client = NULL, *tasks_client = NULL; int t; /* If neither is selected, just return. */ @@ -611,14 +611,14 @@ gnome_calendar_import_data_fn (EvolutionIntelligentImporter *ii, /* Try to open the default calendar & tasks folders. */ if (ici->do_calendar) { - calendar_client = cal_client_new ("", CALOBJ_TYPE_EVENT); /* FIXME: use default folder */ - if (!cal_client_open (calendar_client, FALSE, NULL)) + calendar_client = e_cal_new ("", CALOBJ_TYPE_EVENT); /* FIXME: use default folder */ + if (!e_cal_open (calendar_client, FALSE, NULL)) goto out; } if (ici->do_tasks) { - tasks_client = cal_client_new ("", CALOBJ_TYPE_TODO); /* FIXME: use default folder */ - if (!cal_client_open (tasks_client, FALSE, NULL)) + tasks_client = e_cal_new ("", CALOBJ_TYPE_TODO); /* FIXME: use default folder */ + if (!e_cal_open (tasks_client, FALSE, NULL)) goto out; } @@ -638,23 +638,23 @@ gnome_calendar_import_data_fn (EvolutionIntelligentImporter *ii, /* Wait for client to finish opening the calendar & tasks folders. */ for (t = 0; t < IMPORTER_TIMEOUT_SECONDS; t++) { - CalClientLoadState calendar_state, tasks_state; + ECalLoadState calendar_state, tasks_state; - calendar_state = tasks_state = CAL_CLIENT_LOAD_LOADED; + calendar_state = tasks_state = E_CAL_LOAD_LOADED; - /* We need this so the CalClient gets notified that the + /* We need this so the ECal gets notified that the folder is opened, via Corba. */ while (gtk_events_pending ()) gtk_main_iteration (); if (ici->do_calendar) - calendar_state = cal_client_get_load_state (calendar_client); + calendar_state = e_cal_get_load_state (calendar_client); if (ici->do_tasks) - tasks_state = cal_client_get_load_state (tasks_client); + tasks_state = e_cal_get_load_state (tasks_client); - if (calendar_state == CAL_CLIENT_LOAD_LOADED - && tasks_state == CAL_CLIENT_LOAD_LOADED) + if (calendar_state == E_CAL_LOAD_LOADED + && tasks_state == E_CAL_LOAD_LOADED) break; sleep (1); diff --git a/calendar/pcs/.cvsignore b/calendar/pcs/.cvsignore deleted file mode 100644 index ac51a554db..0000000000 --- a/calendar/pcs/.cvsignore +++ /dev/null @@ -1,11 +0,0 @@ -Makefile -Makefile.in -.deps -.libs -.pure -*.la -*.lo -evolution-calendar-stubs.c -evolution-calendar-skels.c -evolution-calendar-common.c -evolution-calendar.h diff --git a/calendar/pcs/Makefile.am b/calendar/pcs/Makefile.am deleted file mode 100644 index 0e47694cee..0000000000 --- a/calendar/pcs/Makefile.am +++ /dev/null @@ -1,92 +0,0 @@ -INCLUDES = \ - -DG_LOG_DOMAIN=\"wombat-pcs\" \ - -I$(top_srcdir) \ - -I$(top_srcdir)/calendar \ - -I$(top_builddir)/calendar \ - -I$(top_srcdir)/libical/src \ - -I$(top_builddir)/libical/src \ - -I$(top_srcdir)/libwombat \ - -I$(top_builddir)/libwombat \ - $(EVOLUTION_CALENDAR_CFLAGS) - -AM_CFLAGS = \ - -DGTK_DISABLE_DEPRECATED=1 \ - -DGDK_DISABLE_DEPRECATED=1 \ - -DG_DISABLE_DEPRECATED=1 \ - -DGNOME_DISABLE_DEPRECATED=1 - -CORBA_GENERATED_H = \ - evolution-calendar.h - -CORBA_GENERATED_C = \ - evolution-calendar-common.c \ - evolution-calendar-skels.c \ - evolution-calendar-stubs.c - -CORBA_GENERATED = $(CORBA_GENERATED_H) $(CORBA_GENERATED_C) - -idls = \ - $(srcdir)/../idl/evolution-calendar.idl - -idl_flags = -I $(srcdir) $(IDL_INCLUDES) - -$(CORBA_GENERATED_H): $(idls) - $(ORBIT_IDL) $(idl_flags) $(srcdir)/../idl/evolution-calendar.idl - -$(CORBA_GENERATED_C): $(CORBA_GENERATED_H) - -pcsincludedir = $(privincludedir)/pcs - -privlib_LTLIBRARIES = libpcs.la -noinst_LTLIBRARIES = libpcsfile.la libpcshttp.la - -pcsinclude_HEADERS = \ - $(CORBA_GENERATED_H) \ - cal.h \ - cal-backend.h \ - cal-backend-sync.h \ - cal-backend-util.h \ - cal-backend-object-sexp.h\ - cal-common.h \ - cal-factory.h \ - query.h - -libpcs_la_SOURCES = \ - $(pcsinclude_HEADERS) \ - $(CORBA_GENERATED_C) \ - cal.c \ - cal-backend.c \ - cal-backend-sync.c \ - cal-backend-util.c \ - cal-backend-object-sexp.c\ - cal-factory.c \ - query.c - -libpcs_la_LIBADD = \ - $(top_builddir)/calendar/cal-util/libcal-util.la \ - $(top_builddir)/e-util/libeutil.la - -libpcsfile_la_SOURCES = \ - cal-backend-file-events.c\ - cal-backend-file-events.h\ - cal-backend-file-todos.c\ - cal-backend-file-todos.h\ - cal-backend-file.c \ - cal-backend-file.h - -libpcsfile_la_LIBADD = \ - libpcs.la - -libpcshttp_la_SOURCES = \ - cal-backend-http.c \ - cal-backend-http.h - -libpcshttp_la_LIBADD = \ - libpcs.la - -BUILT_SOURCES = $(CORBA_GENERATED) -CLEANFILES = $(BUILT_SOURCES) - -dist-hook: - cd $(distdir); rm -f $(BUILT_SOURCES) - diff --git a/calendar/pcs/cal-backend-file-events.c b/calendar/pcs/cal-backend-file-events.c deleted file mode 100644 index a7cf56fac6..0000000000 --- a/calendar/pcs/cal-backend-file-events.c +++ /dev/null @@ -1,145 +0,0 @@ -/* Evolution calendar - iCalendar file backend - * - * Copyright (C) 2000 Ximian, Inc. - * Copyright (C) 2000 Ximian, Inc. - * - * Authors: Federico Mena-Quintero <federico@ximian.com> - * Rodrigo Moya <rodrigo@ximian.com> - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of version 2 of the GNU General Public - * License as published by the Free Software Foundation. - * - * 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA. - */ - -#include <config.h> -#include <string.h> -#include <unistd.h> -#include <bonobo/bonobo-exception.h> -#include <bonobo/bonobo-moniker-util.h> -#include <libgnome/gnome-i18n.h> -#include <libgnomevfs/gnome-vfs.h> -#include "e-util/e-xml-hash-utils.h" -#include "cal-util/cal-recur.h" -#include "cal-util/cal-util.h" -#include "cal-backend-file-events.h" -#include "cal-backend-util.h" - - - -/* Private part of the CalBackendFileEvents structure */ -struct _CalBackendFileEventsPrivate { -}; - - - -static void cal_backend_file_events_class_init (CalBackendFileEventsClass *class); -static void cal_backend_file_events_init (CalBackendFileEvents *cbfile, CalBackendFileEventsClass *class); -static void cal_backend_file_events_dispose (GObject *object); -static void cal_backend_file_events_finalize (GObject *object); - -static GObjectClass *parent_class; - - - -/** - * cal_backend_file_events_get_type: - * @void: - * - * Registers the #CalBackendFileEvents class if necessary, and returns the type ID - * associated to it. - * - * Return value: The type ID of the #CalBackendFileEvents class. - **/ -GType -cal_backend_file_events_get_type (void) -{ - static GType cal_backend_file_events_type = 0; - - if (!cal_backend_file_events_type) { - static GTypeInfo info = { - sizeof (CalBackendFileEventsClass), - (GBaseInitFunc) NULL, - (GBaseFinalizeFunc) NULL, - (GClassInitFunc) cal_backend_file_events_class_init, - NULL, NULL, - sizeof (CalBackendFileEvents), - 0, - (GInstanceInitFunc) cal_backend_file_events_init - }; - cal_backend_file_events_type = g_type_register_static (CAL_BACKEND_FILE_TYPE, - "CalBackendFileEvents", &info, 0); - } - - return cal_backend_file_events_type; -} - -/* Class initialization function for the file backend */ -static void -cal_backend_file_events_class_init (CalBackendFileEventsClass *klass) -{ - GObjectClass *object_class; - CalBackendClass *backend_class; - - object_class = G_OBJECT_CLASS (klass); - backend_class = CAL_BACKEND_CLASS (klass); - - parent_class = g_type_class_peek_parent (klass); - - object_class->dispose = cal_backend_file_events_dispose; - object_class->finalize = cal_backend_file_events_finalize; - -// backend_class->get_uri = cal_backend_file_events_get_uri; -} - -/* Object initialization function for the file backend */ -static void -cal_backend_file_events_init (CalBackendFileEvents *cbfile, CalBackendFileEventsClass *class) -{ - CalBackendFileEventsPrivate *priv; - - priv = g_new0 (CalBackendFileEventsPrivate, 1); - cbfile->priv = priv; - - cal_backend_file_set_file_name (CAL_BACKEND_FILE (cbfile), "calendar.ics"); -} - -/* Dispose handler for the file backend */ -static void -cal_backend_file_events_dispose (GObject *object) -{ - CalBackendFileEvents *cbfile; - CalBackendFileEventsPrivate *priv; - - cbfile = CAL_BACKEND_FILE_EVENTS (object); - priv = cbfile->priv; - - if (G_OBJECT_CLASS (parent_class)->dispose) - (* G_OBJECT_CLASS (parent_class)->dispose) (object); -} - -/* Finalize handler for the file backend */ -static void -cal_backend_file_events_finalize (GObject *object) -{ - CalBackendFileEvents *cbfile; - CalBackendFileEventsPrivate *priv; - - g_return_if_fail (object != NULL); - g_return_if_fail (IS_CAL_BACKEND_FILE_EVENTS (object)); - - cbfile = CAL_BACKEND_FILE_EVENTS (object); - priv = cbfile->priv; - - if (G_OBJECT_CLASS (parent_class)->finalize) - (* G_OBJECT_CLASS (parent_class)->finalize) (object); -} - diff --git a/calendar/pcs/cal-backend-file-events.h b/calendar/pcs/cal-backend-file-events.h deleted file mode 100644 index 3f812b3e09..0000000000 --- a/calendar/pcs/cal-backend-file-events.h +++ /dev/null @@ -1,61 +0,0 @@ -/* Evolution calendar - iCalendar file backend - * - * Copyright (C) 2000 Ximian, Inc. - * Copyright (C) 2000 Ximian, Inc. - * - * Author: Federico Mena-Quintero <federico@ximian.com> - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of version 2 of the GNU General Public - * License as published by the Free Software Foundation. - * - * 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA. - */ - -#ifndef CAL_BACKEND_FILE_EVENTS_H -#define CAL_BACKEND_FILE_EVENTS_H - -#include "cal-backend-file.h" - -G_BEGIN_DECLS - - - -#define CAL_BACKEND_FILE_EVENTS_TYPE (cal_backend_file_events_get_type ()) -#define CAL_BACKEND_FILE_EVENTS(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), CAL_BACKEND_FILE_EVENTS_TYPE, \ - CalBackendFileEvents)) -#define CAL_BACKEND_FILE_EVENTS_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), CAL_BACKEND_FILE_EVENTS_TYPE, \ - CalBackendFileEventsClass)) -#define IS_CAL_BACKEND_FILE_EVENTS(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), CAL_BACKEND_FILE_EVENTS_TYPE)) -#define IS_CAL_BACKEND_FILE_EVENTS_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), CAL_BACKEND_FILE_EVENTS_TYPE)) - -typedef struct _CalBackendFileEvents CalBackendFileEvents; -typedef struct _CalBackendFileEventsClass CalBackendFileEventsClass; - -typedef struct _CalBackendFileEventsPrivate CalBackendFileEventsPrivate; - -struct _CalBackendFileEvents { - CalBackendFile backend; - - /* Private data */ - CalBackendFileEventsPrivate *priv; -}; - -struct _CalBackendFileEventsClass { - CalBackendFileClass parent_class; -}; - -GType cal_backend_file_events_get_type (void); - - - -G_END_DECLS - -#endif diff --git a/calendar/pcs/cal-backend-file-todos.c b/calendar/pcs/cal-backend-file-todos.c deleted file mode 100644 index 6f56dd1776..0000000000 --- a/calendar/pcs/cal-backend-file-todos.c +++ /dev/null @@ -1,135 +0,0 @@ -/* Evolution calendar - iCalendar file backend for tasks - * - * Copyright (C) 2000 Ximian, Inc. - * Copyright (C) 2000 Ximian, Inc. - * - * Authors: Federico Mena-Quintero <federico@ximian.com> - * Rodrigo Moya <rodrigo@ximian.com> - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of version 2 of the GNU General Public - * License as published by the Free Software Foundation. - * - * 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA. - */ - -#include <libgnome/gnome-i18n.h> -#include "cal-backend-file-todos.h" - - - -/* Private part of the CalBackendFileTodos structure */ -struct _CalBackendFileTodosPrivate { -}; - - - -static void cal_backend_file_todos_class_init (CalBackendFileTodosClass *class); -static void cal_backend_file_todos_init (CalBackendFileTodos *cbfile, CalBackendFileTodosClass *class); -static void cal_backend_file_todos_dispose (GObject *object); -static void cal_backend_file_todos_finalize (GObject *object); - -static CalBackendFileClass *parent_class; - - - -/** - * cal_backend_file_todos_get_type: - * @void: - * - * Registers the #CalBackendFileTodos class if necessary, and returns the type ID - * associated to it. - * - * Return value: The type ID of the #CalBackendFileTodos class. - **/ -GType -cal_backend_file_todos_get_type (void) -{ - static GType cal_backend_file_todos_type = 0; - - if (!cal_backend_file_todos_type) { - static GTypeInfo info = { - sizeof (CalBackendFileTodosClass), - (GBaseInitFunc) NULL, - (GBaseFinalizeFunc) NULL, - (GClassInitFunc) cal_backend_file_todos_class_init, - NULL, NULL, - sizeof (CalBackendFileTodos), - 0, - (GInstanceInitFunc) cal_backend_file_todos_init - }; - cal_backend_file_todos_type = g_type_register_static (CAL_BACKEND_FILE_TYPE, - "CalBackendFileTodos", &info, 0); - } - - return cal_backend_file_todos_type; -} - -/* Class initialization function for the file backend */ -static void -cal_backend_file_todos_class_init (CalBackendFileTodosClass *klass) -{ - GObjectClass *object_class; - CalBackendClass *backend_class; - - object_class = G_OBJECT_CLASS (klass); - backend_class = CAL_BACKEND_CLASS (klass); - - parent_class = g_type_class_peek_parent (klass); - - object_class->dispose = cal_backend_file_todos_dispose; - object_class->finalize = cal_backend_file_todos_finalize; - -// backend_class->get_uri = cal_backend_file_todos_get_uri; -} - -/* Object initialization function for the file backend */ -static void -cal_backend_file_todos_init (CalBackendFileTodos *cbfile, CalBackendFileTodosClass *class) -{ - CalBackendFileTodosPrivate *priv; - - priv = g_new0 (CalBackendFileTodosPrivate, 1); - cbfile->priv = priv; - - cal_backend_file_set_file_name (CAL_BACKEND_FILE (cbfile), "tasks.ics"); -} - -/* Dispose handler for the file backend */ -static void -cal_backend_file_todos_dispose (GObject *object) -{ - CalBackendFileTodos *cbfile; - CalBackendFileTodosPrivate *priv; - - cbfile = CAL_BACKEND_FILE_TODOS (object); - priv = cbfile->priv; - - if (G_OBJECT_CLASS (parent_class)->dispose) - (* G_OBJECT_CLASS (parent_class)->dispose) (object); -} - -/* Finalize handler for the file backend */ -static void -cal_backend_file_todos_finalize (GObject *object) -{ - CalBackendFileTodos *cbfile; - CalBackendFileTodosPrivate *priv; - - g_return_if_fail (object != NULL); - g_return_if_fail (IS_CAL_BACKEND_FILE_TODOS (object)); - - cbfile = CAL_BACKEND_FILE_TODOS (object); - priv = cbfile->priv; - - if (G_OBJECT_CLASS (parent_class)->finalize) - (* G_OBJECT_CLASS (parent_class)->finalize) (object); -} - diff --git a/calendar/pcs/cal-backend-file-todos.h b/calendar/pcs/cal-backend-file-todos.h deleted file mode 100644 index 7f17122673..0000000000 --- a/calendar/pcs/cal-backend-file-todos.h +++ /dev/null @@ -1,61 +0,0 @@ -/* Evolution calendar - iCalendar file backend - * - * Copyright (C) 2000 Ximian, Inc. - * Copyright (C) 2000 Ximian, Inc. - * - * Author: Federico Mena-Quintero <federico@ximian.com> - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of version 2 of the GNU General Public - * License as published by the Free Software Foundation. - * - * 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA. - */ - -#ifndef CAL_BACKEND_FILE_TODOS_H -#define CAL_BACKEND_FILE_TODOS_H - -#include "cal-backend-file.h" - -G_BEGIN_DECLS - - - -#define CAL_BACKEND_FILE_TODOS_TYPE (cal_backend_file_todos_get_type ()) -#define CAL_BACKEND_FILE_TODOS(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), CAL_BACKEND_FILE_TODOS_TYPE, \ - CalBackendFileTodos)) -#define CAL_BACKEND_FILE_TODOS_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), CAL_BACKEND_FILE_TODOS_TYPE, \ - CalBackendFileTodosClass)) -#define IS_CAL_BACKEND_FILE_TODOS(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), CAL_BACKEND_FILE_TODOS_TYPE)) -#define IS_CAL_BACKEND_FILE_TODOS_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), CAL_BACKEND_FILE_TODOS_TYPE)) - -typedef struct _CalBackendFileTodos CalBackendFileTodos; -typedef struct _CalBackendFileTodosClass CalBackendFileTodosClass; - -typedef struct _CalBackendFileTodosPrivate CalBackendFileTodosPrivate; - -struct _CalBackendFileTodos { - CalBackendFile backend; - - /* Private data */ - CalBackendFileTodosPrivate *priv; -}; - -struct _CalBackendFileTodosClass { - CalBackendFileClass parent_class; -}; - -GType cal_backend_file_todos_get_type (void); - - - -G_END_DECLS - -#endif diff --git a/calendar/pcs/cal-backend-file.c b/calendar/pcs/cal-backend-file.c deleted file mode 100644 index a3cd2c360f..0000000000 --- a/calendar/pcs/cal-backend-file.c +++ /dev/null @@ -1,1988 +0,0 @@ -/* Evolution calendar - iCalendar file backend - * - * Copyright (C) 2000-2003 Ximian, Inc. - * - * Authors: Federico Mena-Quintero <federico@ximian.com> - * Rodrigo Moya <rodrigo@ximian.com> - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of version 2 of the GNU General Public - * License as published by the Free Software Foundation. - * - * 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA. - */ - -#include <config.h> -#include <string.h> -#include <unistd.h> -#include <bonobo/bonobo-exception.h> -#include <bonobo/bonobo-moniker-util.h> -#include <libgnome/gnome-i18n.h> -#include <libgnomevfs/gnome-vfs.h> -#include "e-util/e-xml-hash-utils.h" -#include "cal-util/cal-recur.h" -#include "cal-util/cal-util.h" -#include "cal-backend-file-events.h" -#include "cal-backend-util.h" -#include "cal-backend-object-sexp.h" - - - -/* Placeholder for each component and its recurrences */ -typedef struct { - CalComponent *full_object; - GHashTable *recurrences; -} CalBackendFileObject; - -/* Private part of the CalBackendFile structure */ -struct _CalBackendFilePrivate { - /* URI where the calendar data is stored */ - char *uri; - - /* Filename in the dir */ - char *file_name; - gboolean read_only; - - /* Toplevel VCALENDAR component */ - icalcomponent *icalcomp; - - /* All the objects in the calendar, hashed by UID. The - * hash key *is* the uid returned by cal_component_get_uid(); it is not - * copied, so don't free it when you remove an object from the hash - * table. Each item in the hash table is a CalBackendFileObject. - */ - GHashTable *comp_uid_hash; - - GList *comp; - - /* Config database handle for free/busy organizer information */ - EConfigListener *config_listener; - - /* The calendar's default timezone, used for resolving DATE and - floating DATE-TIME values. */ - icaltimezone *default_zone; - - /* The list of live queries */ - GList *queries; -}; - - - -static void cal_backend_file_dispose (GObject *object); -static void cal_backend_file_finalize (GObject *object); - -static CalBackendSyncClass *parent_class; - - - -/* g_hash_table_foreach() callback to destroy recurrences in the hash table */ -static void -free_recurrence (gpointer key, gpointer value, gpointer data) -{ - char *rid = key; - CalComponent *comp = value; - - g_free (rid); - g_object_unref (comp); -} - -/* g_hash_table_foreach() callback to destroy a CalBackendFileObject */ -static void -free_object (gpointer key, gpointer value, gpointer data) -{ - CalBackendFileObject *obj_data = value; - - g_object_unref (obj_data->full_object); - g_hash_table_foreach (obj_data->recurrences, (GHFunc) free_recurrence, NULL); - g_hash_table_destroy (obj_data->recurrences); -} - -/* Saves the calendar data */ -static void -save (CalBackendFile *cbfile) -{ - CalBackendFilePrivate *priv; - GnomeVFSURI *uri, *backup_uri; - GnomeVFSHandle *handle = NULL; - GnomeVFSResult result = GNOME_VFS_ERROR_BAD_FILE; - GnomeVFSFileSize out; - gchar *tmp, *backup_uristr; - char *buf; - - priv = cbfile->priv; - g_assert (priv->uri != NULL); - g_assert (priv->icalcomp != NULL); - - uri = gnome_vfs_uri_new (priv->uri); - if (!uri) - goto error_malformed_uri; - - /* save calendar to backup file */ - tmp = gnome_vfs_uri_to_string (uri, GNOME_VFS_URI_HIDE_NONE); - if (!tmp) { - gnome_vfs_uri_unref (uri); - goto error_malformed_uri; - } - - backup_uristr = g_strconcat (tmp, "~", NULL); - backup_uri = gnome_vfs_uri_new (backup_uristr); - - g_free (tmp); - g_free (backup_uristr); - - if (!backup_uri) { - gnome_vfs_uri_unref (uri); - goto error_malformed_uri; - } - - result = gnome_vfs_create_uri (&handle, backup_uri, - GNOME_VFS_OPEN_WRITE, - FALSE, 0666); - if (result != GNOME_VFS_OK) { - gnome_vfs_uri_unref (uri); - gnome_vfs_uri_unref (backup_uri); - goto error; - } - - buf = icalcomponent_as_ical_string (priv->icalcomp); - result = gnome_vfs_write (handle, buf, strlen (buf) * sizeof (char), &out); - gnome_vfs_close (handle); - if (result != GNOME_VFS_OK) { - gnome_vfs_uri_unref (uri); - gnome_vfs_uri_unref (backup_uri); - goto error; - } - - /* now copy the temporary file to the real file */ - result = gnome_vfs_move_uri (backup_uri, uri, TRUE); - - gnome_vfs_uri_unref (uri); - gnome_vfs_uri_unref (backup_uri); - if (result != GNOME_VFS_OK) - goto error; - - return; - - error_malformed_uri: - cal_backend_notify_error (CAL_BACKEND (cbfile), - _("Can't save calendar data: Malformed URI.")); - return; - - error: - cal_backend_notify_error (CAL_BACKEND (cbfile), gnome_vfs_result_to_string (result)); - return; -} - -/* Dispose handler for the file backend */ -static void -cal_backend_file_dispose (GObject *object) -{ - CalBackendFile *cbfile; - CalBackendFilePrivate *priv; - - cbfile = CAL_BACKEND_FILE (object); - priv = cbfile->priv; - - /* Save if necessary */ - - if (priv->comp_uid_hash) { - g_hash_table_foreach (priv->comp_uid_hash, (GHFunc) free_object, NULL); - g_hash_table_destroy (priv->comp_uid_hash); - priv->comp_uid_hash = NULL; - } - - g_list_free (priv->comp); - priv->comp = NULL; - - if (priv->icalcomp) { - icalcomponent_free (priv->icalcomp); - priv->icalcomp = NULL; - } - - if (priv->config_listener) { - g_object_unref (priv->config_listener); - priv->config_listener = NULL; - } - - if (G_OBJECT_CLASS (parent_class)->dispose) - (* G_OBJECT_CLASS (parent_class)->dispose) (object); -} - -/* Finalize handler for the file backend */ -static void -cal_backend_file_finalize (GObject *object) -{ - CalBackendFile *cbfile; - CalBackendFilePrivate *priv; - - g_return_if_fail (object != NULL); - g_return_if_fail (IS_CAL_BACKEND_FILE (object)); - - cbfile = CAL_BACKEND_FILE (object); - priv = cbfile->priv; - - /* Clean up */ - - if (priv->uri) { - g_free (priv->uri); - priv->uri = NULL; - } - - g_free (priv); - cbfile->priv = NULL; - - if (G_OBJECT_CLASS (parent_class)->finalize) - (* G_OBJECT_CLASS (parent_class)->finalize) (object); -} - - - -/* Looks up a component by its UID on the backend's component hash table */ -static CalComponent * -lookup_component (CalBackendFile *cbfile, const char *uid) -{ - CalBackendFilePrivate *priv; - CalBackendFileObject *obj_data; - - priv = cbfile->priv; - - obj_data = g_hash_table_lookup (priv->comp_uid_hash, uid); - return obj_data ? obj_data->full_object : NULL; -} - - - -/* Calendar backend methods */ - -/* Is_read_only handler for the file backend */ -static CalBackendSyncStatus -cal_backend_file_is_read_only (CalBackendSync *backend, Cal *cal, gboolean *read_only) -{ - CalBackendFile *cbfile = (CalBackendFile *) backend; - - *read_only = cbfile->priv->read_only; - - return GNOME_Evolution_Calendar_Success; -} - -/* Get_email_address handler for the file backend */ -static CalBackendSyncStatus -cal_backend_file_get_cal_address (CalBackendSync *backend, Cal *cal, char **address) -{ - /* A file backend has no particular email address associated - * with it (although that would be a useful feature some day). - */ - *address = NULL; - - return GNOME_Evolution_Calendar_Success; -} - -static CalBackendSyncStatus -cal_backend_file_get_ldap_attribute (CalBackendSync *backend, Cal *cal, char **attribute) -{ - *attribute = NULL; - - return GNOME_Evolution_Calendar_Success; -} - -static CalBackendSyncStatus -cal_backend_file_get_alarm_email_address (CalBackendSync *backend, Cal *cal, char **address) -{ - /* A file backend has no particular email address associated - * with it (although that would be a useful feature some day). - */ - *address = NULL; - - return GNOME_Evolution_Calendar_Success; -} - -static CalBackendSyncStatus -cal_backend_file_get_static_capabilities (CalBackendSync *backend, Cal *cal, char **capabilities) -{ - *capabilities = CAL_STATIC_CAPABILITY_NO_EMAIL_ALARMS; - - return GNOME_Evolution_Calendar_Success; -} - -/* function to resolve timezones */ -static icaltimezone * -resolve_tzid (const char *tzid, gpointer user_data) -{ - icalcomponent *vcalendar_comp = user_data; - - if (!tzid || !tzid[0]) - return NULL; - else if (!strcmp (tzid, "UTC")) - return icaltimezone_get_utc_timezone (); - - return icalcomponent_get_timezone (vcalendar_comp, tzid); -} - -/* Checks if the specified component has a duplicated UID and if so changes it */ -static void -check_dup_uid (CalBackendFile *cbfile, CalComponent *comp) -{ - CalBackendFilePrivate *priv; - CalBackendFileObject *obj_data; - const char *uid; - char *new_uid; - - priv = cbfile->priv; - - cal_component_get_uid (comp, &uid); - - obj_data = g_hash_table_lookup (priv->comp_uid_hash, uid); - if (!obj_data) - return; /* Everything is fine */ - - g_message ("check_dup_uid(): Got object with duplicated UID `%s', changing it...", uid); - - new_uid = cal_component_gen_uid (); - cal_component_set_uid (comp, new_uid); - g_free (new_uid); - - /* FIXME: I think we need to reset the SEQUENCE property and reset the - * CREATED/DTSTAMP/LAST-MODIFIED. - */ - - save (cbfile); -} - -static const char * -get_rid_string (CalComponent *comp) -{ - CalComponentRange range; - struct icaltimetype tt; - - cal_component_get_recurid (comp, &range); - if (!range.datetime.value) - return "0"; - tt = *range.datetime.value; - cal_component_free_range (&range); - - return icaltime_is_valid_time (tt) && !icaltime_is_null_time (tt) ? - icaltime_as_ical_string (tt) : "0"; -} - -static struct icaltimetype -get_rid_icaltime (CalComponent *comp) -{ - CalComponentRange range; - struct icaltimetype tt; - - cal_component_get_recurid (comp, &range); - if (!range.datetime.value) - return icaltime_null_time (); - tt = *range.datetime.value; - cal_component_free_range (&range); - - return tt; -} - -/* Tries to add an icalcomponent to the file backend. We only store the objects - * of the types we support; all others just remain in the toplevel component so - * that we don't lose them. - */ -static void -add_component (CalBackendFile *cbfile, CalComponent *comp, gboolean add_to_toplevel) -{ - CalBackendFilePrivate *priv; - CalBackendFileObject *obj_data; - const char *uid; - GSList *categories; - - priv = cbfile->priv; - - if (cal_component_is_instance (comp)) { /* FIXME: more checks needed, to detect detached instances */ - const char *rid; - - cal_component_get_uid (comp, &uid); - - obj_data = g_hash_table_lookup (priv->comp_uid_hash, uid); - if (!obj_data) { - g_warning (G_STRLOC ": Got an instance of a non-existing component"); - return; - } - - rid = get_rid_string (comp); - if (g_hash_table_lookup (obj_data->recurrences, rid)) { - g_warning (G_STRLOC ": Tried to adding an already existing recurrence"); - return; - } - - g_hash_table_insert (obj_data->recurrences, g_strdup (rid), comp); - } else { - /* Ensure that the UID is unique; some broken implementations spit - * components with duplicated UIDs. - */ - check_dup_uid (cbfile, comp); - cal_component_get_uid (comp, &uid); - - obj_data = g_new0 (CalBackendFileObject, 1); - obj_data->full_object = comp; - obj_data->recurrences = g_hash_table_new (g_str_hash, g_str_equal); - - g_hash_table_insert (priv->comp_uid_hash, (gpointer) uid, obj_data); - } - - priv->comp = g_list_prepend (priv->comp, comp); - - /* Put the object in the toplevel component if required */ - - if (add_to_toplevel) { - icalcomponent *icalcomp; - - icalcomp = cal_component_get_icalcomponent (comp); - g_assert (icalcomp != NULL); - - icalcomponent_add_component (priv->icalcomp, icalcomp); - } - - /* Update the set of categories */ - cal_component_get_categories_list (comp, &categories); - cal_backend_ref_categories (CAL_BACKEND (cbfile), categories); - cal_component_free_categories_list (categories); -} - -/* g_hash_table_foreach() callback to remove recurrences from the calendar */ -static void -remove_recurrence_cb (gpointer key, gpointer value, gpointer data) -{ - GList *l; - GSList *categories; - icalcomponent *icalcomp; - CalBackendFilePrivate *priv; - CalComponent *comp = value; - CalBackendFile *cbfile = data; - - priv = cbfile->priv; - - /* remove the recurrence from the top-level calendar */ - icalcomp = cal_component_get_icalcomponent (comp); - g_assert (icalcomp != NULL); - - icalcomponent_remove_component (priv->icalcomp, icalcomp); - - /* remove it from our mapping */ - l = g_list_find (priv->comp, comp); - priv->comp = g_list_delete_link (priv->comp, l); - - /* update the set of categories */ - cal_component_get_categories_list (comp, &categories); - cal_backend_unref_categories (CAL_BACKEND (cbfile), categories); - cal_component_free_categories_list (categories); -} - -/* Removes a component from the backend's hash and lists. Does not perform - * notification on the clients. Also removes the component from the toplevel - * icalcomponent. - */ -static void -remove_component (CalBackendFile *cbfile, CalComponent *comp) -{ - CalBackendFilePrivate *priv; - icalcomponent *icalcomp; - const char *uid; - GList *l; - GSList *categories; - CalBackendFileObject *obj_data; - - priv = cbfile->priv; - - /* Remove the icalcomp from the toplevel */ - - icalcomp = cal_component_get_icalcomponent (comp); - g_assert (icalcomp != NULL); - - icalcomponent_remove_component (priv->icalcomp, icalcomp); - - /* Remove it from our mapping */ - - cal_component_get_uid (comp, &uid); - obj_data = g_hash_table_lookup (priv->comp_uid_hash, uid); - if (!obj_data) - return; - - g_hash_table_remove (priv->comp_uid_hash, uid); - - l = g_list_find (priv->comp, comp); - g_assert (l != NULL); - priv->comp = g_list_delete_link (priv->comp, l); - - /* remove the recurrences also */ - g_hash_table_foreach (obj_data->recurrences, (GHFunc) remove_recurrence_cb, cbfile); - - /* Update the set of categories */ - cal_component_get_categories_list (comp, &categories); - cal_backend_unref_categories (CAL_BACKEND (cbfile), categories); - cal_component_free_categories_list (categories); - - free_object ((gpointer) uid, (gpointer) obj_data, NULL); -} - -/* Scans the toplevel VCALENDAR component and stores the objects it finds */ -static void -scan_vcalendar (CalBackendFile *cbfile) -{ - CalBackendFilePrivate *priv; - icalcompiter iter; - - priv = cbfile->priv; - g_assert (priv->icalcomp != NULL); - g_assert (priv->comp_uid_hash != NULL); - - for (iter = icalcomponent_begin_component (priv->icalcomp, ICAL_ANY_COMPONENT); - icalcompiter_deref (&iter) != NULL; - icalcompiter_next (&iter)) { - icalcomponent *icalcomp; - icalcomponent_kind kind; - CalComponent *comp; - - icalcomp = icalcompiter_deref (&iter); - - kind = icalcomponent_isa (icalcomp); - - if (!(kind == ICAL_VEVENT_COMPONENT - || kind == ICAL_VTODO_COMPONENT - || kind == ICAL_VJOURNAL_COMPONENT)) - continue; - - comp = cal_component_new (); - - if (!cal_component_set_icalcomponent (comp, icalcomp)) - continue; - - add_component (cbfile, comp, FALSE); - } -} - -/* Parses an open iCalendar file and loads it into the backend */ -static CalBackendSyncStatus -open_cal (CalBackendFile *cbfile, const char *uristr) -{ - CalBackendFilePrivate *priv; - icalcomponent *icalcomp; - - priv = cbfile->priv; - - icalcomp = cal_util_parse_ics_file (uristr); - if (!icalcomp) - return GNOME_Evolution_Calendar_OtherError; - - /* FIXME: should we try to demangle XROOT components and - * individual components as well? - */ - - if (icalcomponent_isa (icalcomp) != ICAL_VCALENDAR_COMPONENT) { - icalcomponent_free (icalcomp); - - return GNOME_Evolution_Calendar_OtherError; - } - - priv->icalcomp = icalcomp; - - priv->comp_uid_hash = g_hash_table_new (g_str_hash, g_str_equal); - scan_vcalendar (cbfile); - - priv->uri = g_strdup (uristr); - - return GNOME_Evolution_Calendar_Success; -} - -static CalBackendSyncStatus -create_cal (CalBackendFile *cbfile, const char *uristr) -{ - CalBackendFilePrivate *priv; - - priv = cbfile->priv; - - /* Create the new calendar information */ - priv->icalcomp = cal_util_new_top_level (); - - /* Create our internal data */ - priv->comp_uid_hash = g_hash_table_new (g_str_hash, g_str_equal); - - priv->uri = g_strdup (uristr); - - save (cbfile); - - return GNOME_Evolution_Calendar_Success; -} - -static char * -get_uri_string (CalBackend *backend) -{ - CalBackendFile *cbfile; - CalBackendFilePrivate *priv; - const char *master_uri; - char *full_uri, *str_uri; - GnomeVFSURI *uri; - - cbfile = CAL_BACKEND_FILE (backend); - priv = cbfile->priv; - - master_uri = cal_backend_get_uri (backend); - g_message (G_STRLOC ": Trying to open %s", master_uri); - - /* FIXME Check the error conditions a little more elegantly here */ - if (g_strrstr ("tasks.ics", master_uri) || g_strrstr ("calendar.ics", master_uri)) { - g_warning (G_STRLOC ": Existing file name %s", master_uri); - - return NULL; - } - - full_uri = g_strdup_printf ("%s%s%s", master_uri, G_DIR_SEPARATOR_S, priv->file_name); - uri = gnome_vfs_uri_new (full_uri); - g_free (full_uri); - - if (!uri) - return NULL; - - str_uri = gnome_vfs_uri_to_string (uri, - (GNOME_VFS_URI_HIDE_USER_NAME - | GNOME_VFS_URI_HIDE_PASSWORD - | GNOME_VFS_URI_HIDE_HOST_NAME - | GNOME_VFS_URI_HIDE_HOST_PORT - | GNOME_VFS_URI_HIDE_TOPLEVEL_METHOD)); - gnome_vfs_uri_unref (uri); - - if (!str_uri || !strlen (str_uri)) { - g_free (str_uri); - - return NULL; - } - - return str_uri; -} - -/* Open handler for the file backend */ -static CalBackendSyncStatus -cal_backend_file_open (CalBackendSync *backend, Cal *cal, gboolean only_if_exists) -{ - CalBackendFile *cbfile; - CalBackendFilePrivate *priv; - char *str_uri; - CalBackendSyncStatus status; - - cbfile = CAL_BACKEND_FILE (backend); - priv = cbfile->priv; - - /* Claim a succesful open if we are already open */ - if (priv->uri && priv->comp_uid_hash) - return GNOME_Evolution_Calendar_Success; - - str_uri = get_uri_string (CAL_BACKEND (backend)); - if (!str_uri) - return GNOME_Evolution_Calendar_OtherError; - - if (access (str_uri, R_OK) == 0) { - status = open_cal (cbfile, str_uri); - if (access (str_uri, W_OK) != 0) - priv->read_only = TRUE; - } else { - if (only_if_exists) - status = GNOME_Evolution_Calendar_NoSuchCal; - else - status = create_cal (cbfile, str_uri); - } - - g_free (str_uri); - - return status; -} - -static CalBackendSyncStatus -cal_backend_file_remove (CalBackendSync *backend, Cal *cal) -{ - CalBackendFile *cbfile; - CalBackendFilePrivate *priv; - char *str_uri; - - cbfile = CAL_BACKEND_FILE (backend); - priv = cbfile->priv; - - str_uri = get_uri_string (CAL_BACKEND (backend)); - if (!str_uri) - return GNOME_Evolution_Calendar_OtherError; - - if (access (str_uri, W_OK) != 0) { - g_free (str_uri); - - return GNOME_Evolution_Calendar_PermissionDenied; - } - - /* FIXME Remove backup file and whole directory too? */ - if (unlink (str_uri) != 0) { - g_free (str_uri); - - return GNOME_Evolution_Calendar_OtherError; - } - - g_free (str_uri); - - return GNOME_Evolution_Calendar_Success; -} - -/* is_loaded handler for the file backend */ -static gboolean -cal_backend_file_is_loaded (CalBackend *backend) -{ - CalBackendFile *cbfile; - CalBackendFilePrivate *priv; - - cbfile = CAL_BACKEND_FILE (backend); - priv = cbfile->priv; - - return (priv->icalcomp != NULL); -} - -/* is_remote handler for the file backend */ -static CalMode -cal_backend_file_get_mode (CalBackend *backend) -{ - CalBackendFile *cbfile; - CalBackendFilePrivate *priv; - - cbfile = CAL_BACKEND_FILE (backend); - priv = cbfile->priv; - - return CAL_MODE_LOCAL; -} - -/* Set_mode handler for the file backend */ -static void -cal_backend_file_set_mode (CalBackend *backend, CalMode mode) -{ - cal_backend_notify_mode (backend, - GNOME_Evolution_Calendar_Listener_MODE_NOT_SUPPORTED, - GNOME_Evolution_Calendar_MODE_LOCAL); - -} - -static CalBackendSyncStatus -cal_backend_file_get_default_object (CalBackendSync *backend, Cal *cal, char **object) -{ - CalComponent *comp; - - comp = cal_component_new (); - - switch (cal_backend_get_kind (CAL_BACKEND (backend))) { - case ICAL_VEVENT_COMPONENT: - cal_component_set_new_vtype (comp, CAL_COMPONENT_EVENT); - break; - case ICAL_VTODO_COMPONENT: - cal_component_set_new_vtype (comp, CAL_COMPONENT_TODO); - break; - case ICAL_VJOURNAL_COMPONENT: - cal_component_set_new_vtype (comp, CAL_COMPONENT_JOURNAL); - break; - default: - g_object_unref (comp); - return GNOME_Evolution_Calendar_ObjectNotFound; - } - - *object = cal_component_get_as_string (comp); - g_object_unref (comp); - - return GNOME_Evolution_Calendar_Success; -} - -/* Get_object_component handler for the file backend */ -static CalBackendSyncStatus -cal_backend_file_get_object (CalBackendSync *backend, Cal *cal, const char *uid, const char *rid, char **object) -{ - CalBackendFile *cbfile; - CalBackendFilePrivate *priv; - CalBackendFileObject *obj_data; - CalComponent *comp = NULL; - gboolean free_comp = FALSE; - - cbfile = CAL_BACKEND_FILE (backend); - priv = cbfile->priv; - - g_return_val_if_fail (priv->icalcomp != NULL, GNOME_Evolution_Calendar_InvalidObject); - g_return_val_if_fail (uid != NULL, GNOME_Evolution_Calendar_ObjectNotFound); - g_assert (priv->comp_uid_hash != NULL); - - obj_data = g_hash_table_lookup (priv->comp_uid_hash, uid); - if (!obj_data) - return GNOME_Evolution_Calendar_ObjectNotFound; - - if (rid && *rid) { - comp = g_hash_table_lookup (obj_data->recurrences, rid); - if (!comp) { - icalcomponent *icalcomp; - struct icaltimetype itt; - - itt = icaltime_from_string (rid); - icalcomp = cal_util_construct_instance ( - cal_component_get_icalcomponent (obj_data->full_object), - itt); - if (!icalcomp) - return GNOME_Evolution_Calendar_ObjectNotFound; - - comp = cal_component_new (); - free_comp = TRUE; - cal_component_set_icalcomponent (comp, icalcomp); - } - } else - comp = obj_data->full_object; - - if (!comp) - return GNOME_Evolution_Calendar_ObjectNotFound; - - *object = cal_component_get_as_string (comp); - - if (free_comp) - g_object_unref (comp); - - return GNOME_Evolution_Calendar_Success; -} - -/* Get_timezone_object handler for the file backend */ -static CalBackendSyncStatus -cal_backend_file_get_timezone (CalBackendSync *backend, Cal *cal, const char *tzid, char **object) -{ - CalBackendFile *cbfile; - CalBackendFilePrivate *priv; - icaltimezone *zone; - icalcomponent *icalcomp; - - cbfile = CAL_BACKEND_FILE (backend); - priv = cbfile->priv; - - g_return_val_if_fail (priv->icalcomp != NULL, GNOME_Evolution_Calendar_NoSuchCal); - g_return_val_if_fail (tzid != NULL, GNOME_Evolution_Calendar_ObjectNotFound); - - if (!strcmp (tzid, "UTC")) { - zone = icaltimezone_get_utc_timezone (); - } else { - zone = icalcomponent_get_timezone (priv->icalcomp, tzid); - if (!zone) { - zone = icaltimezone_get_builtin_timezone_from_tzid (tzid); - if (!zone) - return GNOME_Evolution_Calendar_ObjectNotFound; - } - } - - icalcomp = icaltimezone_get_component (zone); - if (!icalcomp) - return GNOME_Evolution_Calendar_InvalidObject; - - *object = g_strdup (icalcomponent_as_ical_string (icalcomp)); - - return GNOME_Evolution_Calendar_Success; -} - -/* Add_timezone handler for the file backend */ -static CalBackendSyncStatus -cal_backend_file_add_timezone (CalBackendSync *backend, Cal *cal, const char *tzobj) -{ - icalcomponent *tz_comp; - CalBackendFile *cbfile; - CalBackendFilePrivate *priv; - - cbfile = (CalBackendFile *) backend; - - g_return_val_if_fail (IS_CAL_BACKEND_FILE (cbfile), GNOME_Evolution_Calendar_OtherError); - g_return_val_if_fail (tzobj != NULL, GNOME_Evolution_Calendar_OtherError); - - priv = cbfile->priv; - - tz_comp = icalparser_parse_string (tzobj); - if (!tz_comp) - return GNOME_Evolution_Calendar_InvalidObject; - - if (icalcomponent_isa (tz_comp) == ICAL_VTIMEZONE_COMPONENT) { - icaltimezone *zone; - - zone = icaltimezone_new (); - icaltimezone_set_component (zone, tz_comp); - if (!icalcomponent_get_timezone (priv->icalcomp, - icaltimezone_get_tzid (zone))) { - icalcomponent_add_component (priv->icalcomp, tz_comp); - save (cbfile); - } - - icaltimezone_free (zone, 1); - } - - return GNOME_Evolution_Calendar_Success; -} - - -static CalBackendSyncStatus -cal_backend_file_set_default_timezone (CalBackendSync *backend, Cal *cal, const char *tzid) -{ - CalBackendFile *cbfile; - CalBackendFilePrivate *priv; - icaltimezone *zone; - - cbfile = CAL_BACKEND_FILE (backend); - priv = cbfile->priv; - - g_return_val_if_fail (priv->icalcomp != NULL, GNOME_Evolution_Calendar_NoSuchCal); - - /* Look up the VTIMEZONE in our icalcomponent. */ - zone = icalcomponent_get_timezone (priv->icalcomp, tzid); - if (!zone) - return GNOME_Evolution_Calendar_ObjectNotFound; - - /* Set the default timezone to it. */ - priv->default_zone = zone; - - return GNOME_Evolution_Calendar_Success; -} - -typedef struct { - GList *obj_list; - gboolean search_needed; - const char *query; - CalBackendObjectSExp *obj_sexp; - CalBackend *backend; - icaltimezone *default_zone; -} MatchObjectData; - -static void -match_recurrence_sexp (gpointer key, gpointer value, gpointer data) -{ - CalComponent *comp = value; - MatchObjectData *match_data = data; - - if ((!match_data->search_needed) || - (cal_backend_object_sexp_match_comp (match_data->obj_sexp, comp, match_data->backend))) { - match_data->obj_list = g_list_append (match_data->obj_list, - cal_component_get_as_string (comp)); - } -} - -static void -match_object_sexp (gpointer key, gpointer value, gpointer data) -{ - CalBackendFileObject *obj_data = value; - MatchObjectData *match_data = data; - - if ((!match_data->search_needed) || - (cal_backend_object_sexp_match_comp (match_data->obj_sexp, obj_data->full_object, match_data->backend))) { - match_data->obj_list = g_list_append (match_data->obj_list, - cal_component_get_as_string (obj_data->full_object)); - - /* match also recurrences */ - g_hash_table_foreach (obj_data->recurrences, - (GHFunc) match_recurrence_sexp, - match_data); - } -} - -/* Get_objects_in_range handler for the file backend */ -static CalBackendSyncStatus -cal_backend_file_get_object_list (CalBackendSync *backend, Cal *cal, const char *sexp, GList **objects) -{ - CalBackendFile *cbfile; - CalBackendFilePrivate *priv; - MatchObjectData match_data; - - cbfile = CAL_BACKEND_FILE (backend); - priv = cbfile->priv; - - g_message (G_STRLOC ": Getting object list (%s)", sexp); - - match_data.search_needed = TRUE; - match_data.query = sexp; - match_data.obj_list = NULL; - match_data.backend = CAL_BACKEND (backend); - match_data.default_zone = priv->default_zone; - - if (!strcmp (sexp, "#t")) - match_data.search_needed = FALSE; - - match_data.obj_sexp = cal_backend_object_sexp_new (sexp); - if (!match_data.obj_sexp) - return GNOME_Evolution_Calendar_InvalidQuery; - - g_hash_table_foreach (priv->comp_uid_hash, (GHFunc) match_object_sexp, &match_data); - - *objects = match_data.obj_list; - - return GNOME_Evolution_Calendar_Success; -} - -/* get_query handler for the file backend */ -static void -cal_backend_file_start_query (CalBackend *backend, Query *query) -{ - CalBackendFile *cbfile; - CalBackendFilePrivate *priv; - MatchObjectData match_data; - - cbfile = CAL_BACKEND_FILE (backend); - priv = cbfile->priv; - - g_message (G_STRLOC ": Starting query (%s)", query_get_text (query)); - - /* try to match all currently existing objects */ - match_data.search_needed = TRUE; - match_data.query = query_get_text (query); - match_data.obj_list = NULL; - match_data.backend = backend; - match_data.default_zone = priv->default_zone; - - if (!strcmp (match_data.query, "#t")) - match_data.search_needed = FALSE; - - match_data.obj_sexp = query_get_object_sexp (query); - if (!match_data.obj_sexp) { - query_notify_query_done (query, GNOME_Evolution_Calendar_InvalidQuery); - return; - } - - g_hash_table_foreach (priv->comp_uid_hash, (GHFunc) match_object_sexp, &match_data); - - /* notify listeners of all objects */ - if (match_data.obj_list) { - query_notify_objects_added (query, (const GList *) match_data.obj_list); - - /* free memory */ - g_list_foreach (match_data.obj_list, (GFunc) g_free, NULL); - g_list_free (match_data.obj_list); - } - - query_notify_query_done (query, GNOME_Evolution_Calendar_Success); -} - -static gboolean -free_busy_instance (CalComponent *comp, - time_t instance_start, - time_t instance_end, - gpointer data) -{ - icalcomponent *vfb = data; - icalproperty *prop; - icalparameter *param; - struct icalperiodtype ipt; - icaltimezone *utc_zone; - - utc_zone = icaltimezone_get_utc_timezone (); - - ipt.start = icaltime_from_timet_with_zone (instance_start, FALSE, utc_zone); - ipt.end = icaltime_from_timet_with_zone (instance_end, FALSE, utc_zone); - ipt.duration = icaldurationtype_null_duration (); - - /* add busy information to the vfb component */ - prop = icalproperty_new (ICAL_FREEBUSY_PROPERTY); - icalproperty_set_freebusy (prop, ipt); - - param = icalparameter_new_fbtype (ICAL_FBTYPE_BUSY); - icalproperty_add_parameter (prop, param); - - icalcomponent_add_property (vfb, prop); - - return TRUE; -} - -static icalcomponent * -create_user_free_busy (CalBackendFile *cbfile, const char *address, const char *cn, - time_t start, time_t end) -{ - CalBackendFilePrivate *priv; - GList *l; - icalcomponent *vfb; - icaltimezone *utc_zone; - CalBackendObjectSExp *obj_sexp; - char *query; - - priv = cbfile->priv; - - /* create the (unique) VFREEBUSY object that we'll return */ - vfb = icalcomponent_new_vfreebusy (); - if (address != NULL) { - icalproperty *prop; - icalparameter *param; - - prop = icalproperty_new_organizer (address); - if (prop != NULL && cn != NULL) { - param = icalparameter_new_cn (cn); - icalproperty_add_parameter (prop, param); - } - if (prop != NULL) - icalcomponent_add_property (vfb, prop); - } - utc_zone = icaltimezone_get_utc_timezone (); - icalcomponent_set_dtstart (vfb, icaltime_from_timet_with_zone (start, FALSE, utc_zone)); - icalcomponent_set_dtend (vfb, icaltime_from_timet_with_zone (end, FALSE, utc_zone)); - - /* add all objects in the given interval */ - query = g_strdup_printf ("occur-in-time-range? %lu %lu", start, end); - obj_sexp = cal_backend_object_sexp_new (query); - g_free (query); - - if (!obj_sexp) - return vfb; - - for (l = priv->comp; l; l = l->next) { - CalComponent *comp = l->data; - icalcomponent *icalcomp, *vcalendar_comp; - icalproperty *prop; - - icalcomp = cal_component_get_icalcomponent (comp); - if (!icalcomp) - continue; - - /* If the event is TRANSPARENT, skip it. */ - prop = icalcomponent_get_first_property (icalcomp, - ICAL_TRANSP_PROPERTY); - if (prop) { - icalproperty_transp transp_val = icalproperty_get_transp (prop); - if (transp_val == ICAL_TRANSP_TRANSPARENT || - transp_val == ICAL_TRANSP_TRANSPARENTNOCONFLICT) - continue; - } - - if (!cal_backend_object_sexp_match_comp (obj_sexp, l->data, CAL_BACKEND (cbfile))) - continue; - - vcalendar_comp = icalcomponent_get_parent (icalcomp); - cal_recur_generate_instances (comp, start, end, - free_busy_instance, - vfb, - resolve_tzid, - vcalendar_comp, - priv->default_zone); - } - - return vfb; -} - -/* Get_free_busy handler for the file backend */ -static CalBackendSyncStatus -cal_backend_file_get_free_busy (CalBackendSync *backend, Cal *cal, GList *users, - time_t start, time_t end, GList **freebusy) -{ - CalBackendFile *cbfile; - CalBackendFilePrivate *priv; - gchar *address, *name; - icalcomponent *vfb; - char *calobj; - GList *l; - - cbfile = CAL_BACKEND_FILE (backend); - priv = cbfile->priv; - - g_return_val_if_fail (priv->icalcomp != NULL, GNOME_Evolution_Calendar_NoSuchCal); - g_return_val_if_fail (start != -1 && end != -1, GNOME_Evolution_Calendar_InvalidRange); - g_return_val_if_fail (start <= end, GNOME_Evolution_Calendar_InvalidRange); - - *freebusy = NULL; - - if (users == NULL) { - if (cal_backend_mail_account_get_default (priv->config_listener, &address, &name)) { - vfb = create_user_free_busy (cbfile, address, name, start, end); - calobj = icalcomponent_as_ical_string (vfb); - *freebusy = g_list_append (*freebusy, g_strdup (calobj)); - icalcomponent_free (vfb); - g_free (address); - g_free (name); - } - } else { - for (l = users; l != NULL; l = l->next ) { - address = l->data; - if (cal_backend_mail_account_is_valid (priv->config_listener, address, &name)) { - vfb = create_user_free_busy (cbfile, address, name, start, end); - calobj = icalcomponent_as_ical_string (vfb); - *freebusy = g_list_append (*freebusy, g_strdup (calobj)); - icalcomponent_free (vfb); - g_free (name); - } - } - } - - return GNOME_Evolution_Calendar_Success; -} - -typedef struct -{ - CalBackendFile *backend; - icalcomponent_kind kind; - GList *deletes; - EXmlHash *ehash; -} CalBackendFileComputeChangesData; - -static void -cal_backend_file_compute_changes_foreach_key (const char *key, gpointer data) -{ - CalBackendFileComputeChangesData *be_data = data; - - if (!lookup_component (be_data->backend, key)) { - CalComponent *comp; - - comp = cal_component_new (); - if (be_data->kind == ICAL_VTODO_COMPONENT) - cal_component_set_new_vtype (comp, CAL_COMPONENT_TODO); - else - cal_component_set_new_vtype (comp, CAL_COMPONENT_EVENT); - - cal_component_set_uid (comp, key); - be_data->deletes = g_list_prepend (be_data->deletes, cal_component_get_as_string (comp)); - - e_xmlhash_remove (be_data->ehash, key); - } -} - -static CalBackendSyncStatus -cal_backend_file_compute_changes (CalBackendFile *cbfile, const char *change_id, - GList **adds, GList **modifies, GList **deletes) -{ - CalBackendFilePrivate *priv; - char *filename; - EXmlHash *ehash; - CalBackendFileComputeChangesData be_data; - GList *i; - - priv = cbfile->priv; - - /* FIXME Will this always work? */ - filename = g_strdup_printf ("%s/%s.db", priv->uri, change_id); - ehash = e_xmlhash_new (filename); - g_free (filename); - - /* Calculate adds and modifies */ - for (i = priv->comp; i != NULL; i = i->next) { - const char *uid; - char *calobj; - - cal_component_get_uid (i->data, &uid); - calobj = cal_component_get_as_string (i->data); - - g_assert (calobj != NULL); - - /* check what type of change has occurred, if any */ - switch (e_xmlhash_compare (ehash, uid, calobj)) { - case E_XMLHASH_STATUS_SAME: - break; - case E_XMLHASH_STATUS_NOT_FOUND: - *adds = g_list_prepend (*adds, g_strdup (calobj)); - e_xmlhash_add (ehash, uid, calobj); - break; - case E_XMLHASH_STATUS_DIFFERENT: - *modifies = g_list_prepend (*modifies, g_strdup (calobj)); - e_xmlhash_add (ehash, uid, calobj); - break; - } - - g_free (calobj); - } - - /* Calculate deletions */ - be_data.backend = cbfile; - be_data.kind = cal_backend_get_kind (CAL_BACKEND (cbfile)); - be_data.deletes = NULL; - be_data.ehash = ehash; - e_xmlhash_foreach_key (ehash, (EXmlHashFunc)cal_backend_file_compute_changes_foreach_key, &be_data); - - *deletes = be_data.deletes; - - e_xmlhash_write (ehash); - e_xmlhash_destroy (ehash); - - return GNOME_Evolution_Calendar_Success; -} - -/* Get_changes handler for the file backend */ -static CalBackendSyncStatus -cal_backend_file_get_changes (CalBackendSync *backend, Cal *cal, const char *change_id, - GList **adds, GList **modifies, GList **deletes) -{ - CalBackendFile *cbfile; - CalBackendFilePrivate *priv; - - cbfile = CAL_BACKEND_FILE (backend); - priv = cbfile->priv; - - g_return_val_if_fail (priv->icalcomp != NULL, GNOME_Evolution_Calendar_NoSuchCal); - g_return_val_if_fail (change_id != NULL, GNOME_Evolution_Calendar_ObjectNotFound); - - return cal_backend_file_compute_changes (cbfile, change_id, adds, modifies, deletes); -} - -/* Discard_alarm handler for the file backend */ -static CalBackendSyncStatus -cal_backend_file_discard_alarm (CalBackendSync *backend, Cal *cal, const char *uid, const char *auid) -{ - /* we just do nothing with the alarm */ - return GNOME_Evolution_Calendar_Success; -} - -static CalBackendSyncStatus -cal_backend_file_create_object (CalBackendSync *backend, Cal *cal, const char *calobj, char **uid) -{ - CalBackendFile *cbfile; - CalBackendFilePrivate *priv; - icalcomponent *icalcomp; - icalcomponent_kind kind; - CalComponent *comp; - const char *comp_uid; - struct icaltimetype current; - - cbfile = CAL_BACKEND_FILE (backend); - priv = cbfile->priv; - - g_return_val_if_fail (priv->icalcomp != NULL, GNOME_Evolution_Calendar_NoSuchCal); - g_return_val_if_fail (calobj != NULL, GNOME_Evolution_Calendar_ObjectNotFound); - - icalcomp = icalparser_parse_string ((char *) calobj); - if (!icalcomp) - return GNOME_Evolution_Calendar_InvalidObject; - - /* FIXME Check kind with the parent */ - kind = icalcomponent_isa (icalcomp); - if (kind != ICAL_VEVENT_COMPONENT && kind != ICAL_VTODO_COMPONENT) { - icalcomponent_free (icalcomp); - return GNOME_Evolution_Calendar_InvalidObject; - } - - /* Get the UID */ - comp_uid = icalcomponent_get_uid (icalcomp); - - /* check the object is not in our cache */ - if (lookup_component (cbfile, comp_uid)) { - icalcomponent_free (icalcomp); - return GNOME_Evolution_Calendar_CardIdAlreadyExists; - } - - /* Create the cal component */ - comp = cal_component_new (); - cal_component_set_icalcomponent (comp, icalcomp); - - /* Set the created and last modified times on the component */ - current = icaltime_from_timet (time (NULL), 0); - cal_component_set_created (comp, ¤t); - cal_component_set_last_modified (comp, ¤t); - - /* Add the object */ - add_component (cbfile, comp, TRUE); - - /* Save the file */ - save (cbfile); - - /* Return the UID */ - if (uid) - *uid = g_strdup (comp_uid); - - return GNOME_Evolution_Calendar_Success; -} - -static CalBackendSyncStatus -cal_backend_file_modify_object (CalBackendSync *backend, Cal *cal, const char *calobj, - CalObjModType mod, char **old_object) -{ - CalBackendFile *cbfile; - CalBackendFilePrivate *priv; - icalcomponent *icalcomp; - icalcomponent_kind kind; - const char *comp_uid, *rid; - char *real_rid; - CalComponent *comp, *recurrence; - CalBackendFileObject *obj_data; - struct icaltimetype current; - - cbfile = CAL_BACKEND_FILE (backend); - priv = cbfile->priv; - - g_return_val_if_fail (priv->icalcomp != NULL, GNOME_Evolution_Calendar_NoSuchCal); - g_return_val_if_fail (calobj != NULL, GNOME_Evolution_Calendar_ObjectNotFound); - - icalcomp = icalparser_parse_string ((char *) calobj); - if (!icalcomp) - return GNOME_Evolution_Calendar_InvalidObject; - - /* check kind with the parent */ - kind = icalcomponent_isa (icalcomp); - if (kind != ICAL_VEVENT_COMPONENT && kind != ICAL_VTODO_COMPONENT) { - icalcomponent_free (icalcomp); - return GNOME_Evolution_Calendar_InvalidObject; - } - - /* Get the uid */ - comp_uid = icalcomponent_get_uid (icalcomp); - - /* Get the object from our cache */ - if (!(obj_data = g_hash_table_lookup (priv->comp_uid_hash, comp_uid))) { - icalcomponent_free (icalcomp); - return GNOME_Evolution_Calendar_ObjectNotFound; - } - - /* Create the cal component */ - comp = cal_component_new (); - cal_component_set_icalcomponent (comp, icalcomp); - - /* Set the last modified time on the component */ - current = icaltime_from_timet (time (NULL), 0); - cal_component_set_last_modified (comp, ¤t); - - /* handle mod_type */ - switch (mod) { - case CALOBJ_MOD_THIS : - rid = get_rid_string (comp); - if (!rid || !*rid) { - g_object_unref (comp); - return GNOME_Evolution_Calendar_ObjectNotFound; - } - - if (g_hash_table_lookup_extended (obj_data->recurrences, rid, - &real_rid, &recurrence)) { - /* remove the component from our data */ - icalcomponent_remove_component (priv->icalcomp, - cal_component_get_icalcomponent (recurrence)); - priv->comp = g_list_remove (priv->comp, recurrence); - g_hash_table_remove (obj_data->recurrences, rid); - - /* free memory */ - g_free (real_rid); - g_object_unref (recurrence); - } else { - char *old, *new; - - old = cal_component_get_as_string (obj_data->full_object); - - cal_util_remove_instances (cal_component_get_icalcomponent (obj_data->full_object), - get_rid_icaltime (comp), - mod); - - new = cal_component_get_as_string (obj_data->full_object); - - cal_backend_notify_object_modified (CAL_BACKEND (backend), old, new); - - g_free (old); - g_free (new); - } - - /* add the detached instance */ - g_hash_table_insert (obj_data->recurrences, g_strdup (get_rid_string (comp)), comp); - break; - case CALOBJ_MOD_THISANDPRIOR : - break; - case CALOBJ_MOD_THISANDFUTURE : - break; - case CALOBJ_MOD_ALL : - /* in this case, we blow away all recurrences, and start over - with a clean component */ - /* Remove the old version */ - remove_component (cbfile, obj_data->full_object); - - /* Add the new object */ - add_component (cbfile, comp, TRUE); - break; - } - - save (cbfile); - - if (old_object) - *old_object = cal_component_get_as_string (comp); - - return GNOME_Evolution_Calendar_Success; -} - -static void -remove_instance (CalBackendFile *cbfile, CalBackendFileObject *obj_data, const char *rid) -{ - char *hash_rid; - CalComponent *comp; - GSList *categories; - - if (!rid || !*rid) - return; - - if (g_hash_table_lookup_extended (obj_data->recurrences, rid, &hash_rid, &comp)) { - /* remove the component from our data */ - icalcomponent_remove_component (cbfile->priv->icalcomp, - cal_component_get_icalcomponent (comp)); - cbfile->priv->comp = g_list_remove (cbfile->priv->comp, comp); - g_hash_table_remove (obj_data->recurrences, rid); - - /* update the set of categories */ - cal_component_get_categories_list (comp, &categories); - cal_backend_unref_categories (CAL_BACKEND (cbfile), categories); - cal_component_free_categories_list (categories); - - /* free memory */ - g_free (hash_rid); - g_object_unref (comp); - - return; - } - - /* remove the component from our data, temporarily */ - icalcomponent_remove_component (cbfile->priv->icalcomp, - cal_component_get_icalcomponent (obj_data->full_object)); - cbfile->priv->comp = g_list_remove (cbfile->priv->comp, obj_data->full_object); - - cal_util_remove_instances (cal_component_get_icalcomponent (obj_data->full_object), - icaltime_from_string (rid), CALOBJ_MOD_THIS); - - /* add the modified object to the beginning of the list, - so that it's always before any detached instance we - might have */ - cbfile->priv->comp = g_list_prepend (cbfile->priv->comp, obj_data->full_object); -} - -typedef struct { - CalBackendFile *cbfile; - CalBackendFileObject *obj_data; - const char *rid; - CalObjModType mod; -} RemoveRecurrenceData; - -static gboolean -remove_object_instance_cb (gpointer key, gpointer value, gpointer user_data) -{ - time_t fromtt, instancett; - GSList *categories; - char *rid = key; - CalComponent *instance = value; - RemoveRecurrenceData *rrdata = user_data; - - fromtt = icaltime_as_timet (icaltime_from_string (rrdata->rid)); - instancett = icaltime_as_timet (get_rid_icaltime (instance)); - - if (fromtt > 0 && instancett > 0) { - if ((rrdata->mod == CALOBJ_MOD_THISANDPRIOR && instancett <= fromtt) || - (rrdata->mod == CALOBJ_MOD_THISANDFUTURE && instancett >= fromtt)) { - /* remove the component from our data */ - icalcomponent_remove_component (rrdata->cbfile->priv->icalcomp, - cal_component_get_icalcomponent (instance)); - rrdata->cbfile->priv->comp = g_list_remove (rrdata->cbfile->priv->comp, instance); - - /* update the set of categories */ - cal_component_get_categories_list (instance, &categories); - cal_backend_unref_categories (CAL_BACKEND (rrdata->cbfile), categories); - cal_component_free_categories_list (categories); - - /* free memory */ - g_free (rid); - g_object_unref (instance); - - return TRUE; - } - } - - return FALSE; -} - -/* Remove_object handler for the file backend */ -static CalBackendSyncStatus -cal_backend_file_remove_object (CalBackendSync *backend, Cal *cal, - const char *uid, const char *rid, - CalObjModType mod, char **object) -{ - CalBackendFile *cbfile; - CalBackendFilePrivate *priv; - CalBackendFileObject *obj_data; - CalComponent *comp; - GSList *categories; - RemoveRecurrenceData rrdata; - - cbfile = CAL_BACKEND_FILE (backend); - priv = cbfile->priv; - - g_return_val_if_fail (priv->icalcomp != NULL, GNOME_Evolution_Calendar_NoSuchCal); - g_return_val_if_fail (uid != NULL, GNOME_Evolution_Calendar_ObjectNotFound); - - obj_data = g_hash_table_lookup (priv->comp_uid_hash, uid); - if (!obj_data) - return GNOME_Evolution_Calendar_ObjectNotFound; - - comp = obj_data->full_object; - - switch (mod) { - case CALOBJ_MOD_ALL : - *object = cal_component_get_as_string (comp); - remove_component (cbfile, comp); - break; - case CALOBJ_MOD_THIS : - if (!rid || !*rid) - return GNOME_Evolution_Calendar_ObjectNotFound; - - remove_instance (cbfile, obj_data, rid); - break; - case CALOBJ_MOD_THISANDPRIOR : - case CALOBJ_MOD_THISANDFUTURE : - if (!rid || !*rid) - return GNOME_Evolution_Calendar_ObjectNotFound; - - /* remove the component from our data, temporarily */ - icalcomponent_remove_component (priv->icalcomp, - cal_component_get_icalcomponent (comp)); - priv->comp = g_list_remove (priv->comp, comp); - - cal_util_remove_instances (cal_component_get_icalcomponent (comp), - icaltime_from_string (rid), mod); - - /* now remove all detached instances */ - rrdata.cbfile = cbfile; - rrdata.obj_data = obj_data; - rrdata.rid = rid; - rrdata.mod = mod; - g_hash_table_foreach_remove (obj_data->recurrences, (GHRFunc) remove_object_instance_cb, &rrdata); - - /* add the modified object to the beginning of the list, - so that it's always before any detached instance we - might have */ - priv->comp = g_list_prepend (priv->comp, comp); - break; - } - - save (cbfile); - - return GNOME_Evolution_Calendar_Success; -} - -static gboolean -cancel_received_object (CalBackendFile *cbfile, icalcomponent *icalcomp) -{ - CalComponent *old_comp; - - /* Find the old version of the component. */ - old_comp = lookup_component (cbfile, icalcomponent_get_uid (icalcomp)); - if (!old_comp) - return FALSE; - - /* And remove it */ - remove_component (cbfile, old_comp); - - return TRUE; -} - -typedef struct { - GHashTable *zones; - - gboolean found; -} CalBackendFileTzidData; - -static void -check_tzids (icalparameter *param, void *data) -{ - CalBackendFileTzidData *tzdata = data; - const char *tzid; - - tzid = icalparameter_get_tzid (param); - if (!tzid || g_hash_table_lookup (tzdata->zones, tzid)) - tzdata->found = FALSE; -} - -/* Update_objects handler for the file backend. */ -static CalBackendSyncStatus -cal_backend_file_receive_objects (CalBackendSync *backend, Cal *cal, const char *calobj) -{ - CalBackendFile *cbfile; - CalBackendFilePrivate *priv; - icalcomponent *toplevel_comp, *icalcomp = NULL; - icalcomponent_kind kind; - icalproperty_method method; - icalcomponent *subcomp; - GList *comps, *l; - CalBackendFileTzidData tzdata; - CalBackendSyncStatus status = GNOME_Evolution_Calendar_Success; - - cbfile = CAL_BACKEND_FILE (backend); - priv = cbfile->priv; - - g_return_val_if_fail (priv->icalcomp != NULL, GNOME_Evolution_Calendar_InvalidObject); - g_return_val_if_fail (calobj != NULL, GNOME_Evolution_Calendar_InvalidObject); - - /* Pull the component from the string and ensure that it is sane */ - toplevel_comp = icalparser_parse_string ((char *) calobj); - if (!toplevel_comp) - return GNOME_Evolution_Calendar_InvalidObject; - - kind = icalcomponent_isa (toplevel_comp); - if (kind != ICAL_VCALENDAR_COMPONENT) { - /* If its not a VCALENDAR, make it one to simplify below */ - icalcomp = toplevel_comp; - toplevel_comp = cal_util_new_top_level (); - icalcomponent_add_component (toplevel_comp, icalcomp); - } - - method = icalcomponent_get_method (toplevel_comp); - - /* Build a list of timezones so we can make sure all the objects have valid info */ - tzdata.zones = g_hash_table_new_full (g_str_hash, g_str_equal, g_free, NULL); - - subcomp = icalcomponent_get_first_component (toplevel_comp, ICAL_VTIMEZONE_COMPONENT); - while (subcomp) { - icaltimezone *zone; - - zone = icaltimezone_new (); - if (icaltimezone_set_component (zone, subcomp)) - g_hash_table_insert (tzdata.zones, g_strdup (icaltimezone_get_tzid (zone)), NULL); - - subcomp = icalcomponent_get_next_component (toplevel_comp, ICAL_VTIMEZONE_COMPONENT); - } - - /* First we make sure all the components are usuable */ - comps = NULL; - subcomp = icalcomponent_get_first_component (toplevel_comp, ICAL_ANY_COMPONENT); - while (subcomp) { - /* We ignore anything except VEVENT, VTODO and VJOURNAL - components. */ - icalcomponent_kind child_kind = icalcomponent_isa (subcomp); - - switch (child_kind) { - case ICAL_VEVENT_COMPONENT: - case ICAL_VTODO_COMPONENT: - case ICAL_VJOURNAL_COMPONENT: - tzdata.found = TRUE; - icalcomponent_foreach_tzid (subcomp, check_tzids, &tzdata); - - if (!tzdata.found) { - status = GNOME_Evolution_Calendar_InvalidObject; - goto error; - } - - if (!icalcomponent_get_uid (subcomp)) { - status = GNOME_Evolution_Calendar_InvalidObject; - goto error; - } - - comps = g_list_prepend (comps, subcomp); - break; - default: - /* Ignore it */ - break; - } - - subcomp = icalcomponent_get_next_component (toplevel_comp, ICAL_ANY_COMPONENT); - } - - /* Now we manipulate the components we care about */ - for (l = comps; l; l = l->next) { - subcomp = l->data; - - switch (method) { - case ICAL_METHOD_PUBLISH: - case ICAL_METHOD_REQUEST: - /* FIXME Need to see the new create/modify stuff before we set this up */ - break; - case ICAL_METHOD_REPLY: - /* FIXME Update the status of the user, if we are the organizer */ - break; - case ICAL_METHOD_ADD: - /* FIXME This should be doable once all the recurid stuff is done */ - break; - case ICAL_METHOD_COUNTER: - status = GNOME_Evolution_Calendar_UnsupportedMethod; - goto error; - break; - case ICAL_METHOD_DECLINECOUNTER: - status = GNOME_Evolution_Calendar_UnsupportedMethod; - goto error; - break; - case ICAL_METHOD_CANCEL: - /* FIXME Do we need to remove the subcomp so it isn't merged? */ - if (cancel_received_object (cbfile, subcomp)) { - const char *calobj = icalcomponent_as_ical_string (subcomp); - cal_backend_notify_object_removed (CAL_BACKEND (backend), icalcomponent_get_uid (subcomp), calobj); - } - break; - default: - status = GNOME_Evolution_Calendar_UnsupportedMethod; - goto error; - } - } - g_list_free (comps); - - /* Merge the iCalendar components with our existing VCALENDAR, - resolving any conflicting TZIDs. */ - icalcomponent_merge_component (priv->icalcomp, toplevel_comp); - - save (cbfile); - - error: - g_hash_table_destroy (tzdata.zones); - - return status; -} - -static CalBackendSyncStatus -cal_backend_file_send_objects (CalBackendSync *backend, Cal *cal, const char *calobj) -{ - /* FIXME Put in a util routine to send stuff via email */ - - return GNOME_Evolution_Calendar_Success; -} - -static icaltimezone * -cal_backend_file_internal_get_default_timezone (CalBackend *backend) -{ - CalBackendFile *cbfile; - CalBackendFilePrivate *priv; - - cbfile = CAL_BACKEND_FILE (backend); - priv = cbfile->priv; - - g_return_val_if_fail (priv->icalcomp != NULL, NULL); - - return priv->default_zone; -} - -static icaltimezone * -cal_backend_file_internal_get_timezone (CalBackend *backend, const char *tzid) -{ - CalBackendFile *cbfile; - CalBackendFilePrivate *priv; - icaltimezone *zone; - - cbfile = CAL_BACKEND_FILE (backend); - priv = cbfile->priv; - - g_return_val_if_fail (priv->icalcomp != NULL, NULL); - - if (!strcmp (tzid, "UTC")) - zone = icaltimezone_get_utc_timezone (); - else { - zone = icalcomponent_get_timezone (priv->icalcomp, tzid); - if (!zone) - zone = icaltimezone_get_builtin_timezone_from_tzid (tzid); - } - - return zone; -} - -/* Object initialization function for the file backend */ -static void -cal_backend_file_init (CalBackendFile *cbfile, CalBackendFileClass *class) -{ - CalBackendFilePrivate *priv; - - priv = g_new0 (CalBackendFilePrivate, 1); - cbfile->priv = priv; - - priv->uri = NULL; - priv->file_name = g_strdup ("calendar.ics"); - priv->read_only = FALSE; - priv->icalcomp = NULL; - priv->comp_uid_hash = NULL; - priv->comp = NULL; - - /* The timezone defaults to UTC. */ - priv->default_zone = icaltimezone_get_utc_timezone (); - - priv->config_listener = e_config_listener_new (); -} - -/* Class initialization function for the file backend */ -static void -cal_backend_file_class_init (CalBackendFileClass *class) -{ - GObjectClass *object_class; - CalBackendClass *backend_class; - CalBackendSyncClass *sync_class; - - object_class = (GObjectClass *) class; - backend_class = (CalBackendClass *) class; - sync_class = (CalBackendSyncClass *) class; - - parent_class = (CalBackendSyncClass *) g_type_class_peek_parent (class); - - object_class->dispose = cal_backend_file_dispose; - object_class->finalize = cal_backend_file_finalize; - - sync_class->is_read_only_sync = cal_backend_file_is_read_only; - sync_class->get_cal_address_sync = cal_backend_file_get_cal_address; - sync_class->get_alarm_email_address_sync = cal_backend_file_get_alarm_email_address; - sync_class->get_ldap_attribute_sync = cal_backend_file_get_ldap_attribute; - sync_class->get_static_capabilities_sync = cal_backend_file_get_static_capabilities; - sync_class->open_sync = cal_backend_file_open; - sync_class->remove_sync = cal_backend_file_remove; - sync_class->create_object_sync = cal_backend_file_create_object; - sync_class->modify_object_sync = cal_backend_file_modify_object; - sync_class->remove_object_sync = cal_backend_file_remove_object; - sync_class->discard_alarm_sync = cal_backend_file_discard_alarm; - sync_class->receive_objects_sync = cal_backend_file_receive_objects; - sync_class->send_objects_sync = cal_backend_file_send_objects; - sync_class->get_default_object_sync = cal_backend_file_get_default_object; - sync_class->get_object_sync = cal_backend_file_get_object; - sync_class->get_object_list_sync = cal_backend_file_get_object_list; - sync_class->get_timezone_sync = cal_backend_file_get_timezone; - sync_class->add_timezone_sync = cal_backend_file_add_timezone; - sync_class->set_default_timezone_sync = cal_backend_file_set_default_timezone; - sync_class->get_freebusy_sync = cal_backend_file_get_free_busy; - sync_class->get_changes_sync = cal_backend_file_get_changes; - - backend_class->is_loaded = cal_backend_file_is_loaded; - backend_class->start_query = cal_backend_file_start_query; - backend_class->get_mode = cal_backend_file_get_mode; - backend_class->set_mode = cal_backend_file_set_mode; - - backend_class->internal_get_default_timezone = cal_backend_file_internal_get_default_timezone; - backend_class->internal_get_timezone = cal_backend_file_internal_get_timezone; -} - - -/** - * cal_backend_file_get_type: - * @void: - * - * Registers the #CalBackendFile class if necessary, and returns the type ID - * associated to it. - * - * Return value: The type ID of the #CalBackendFile class. - **/ -GType -cal_backend_file_get_type (void) -{ - static GType cal_backend_file_type = 0; - - if (!cal_backend_file_type) { - static GTypeInfo info = { - sizeof (CalBackendFileClass), - (GBaseInitFunc) NULL, - (GBaseFinalizeFunc) NULL, - (GClassInitFunc) cal_backend_file_class_init, - NULL, NULL, - sizeof (CalBackendFile), - 0, - (GInstanceInitFunc) cal_backend_file_init - }; - cal_backend_file_type = g_type_register_static (CAL_TYPE_BACKEND_SYNC, - "CalBackendFile", &info, 0); - } - - return cal_backend_file_type; -} - -void -cal_backend_file_set_file_name (CalBackendFile *cbfile, const char *file_name) -{ - CalBackendFilePrivate *priv; - - g_return_if_fail (cbfile != NULL); - g_return_if_fail (IS_CAL_BACKEND_FILE (cbfile)); - g_return_if_fail (file_name != NULL); - - priv = cbfile->priv; - - if (priv->file_name) - g_free (priv->file_name); - - priv->file_name = g_strdup (file_name); -} - -const char * -cal_backend_file_get_file_name (CalBackendFile *cbfile) -{ - CalBackendFilePrivate *priv; - - g_return_val_if_fail (cbfile != NULL, NULL); - g_return_val_if_fail (IS_CAL_BACKEND_FILE (cbfile), NULL); - - priv = cbfile->priv; - - return priv->file_name; -} diff --git a/calendar/pcs/cal-backend-file.h b/calendar/pcs/cal-backend-file.h deleted file mode 100644 index ebe190cb2a..0000000000 --- a/calendar/pcs/cal-backend-file.h +++ /dev/null @@ -1,65 +0,0 @@ -/* Evolution calendar - iCalendar file backend - * - * Copyright (C) 2000 Ximian, Inc. - * Copyright (C) 2000 Ximian, Inc. - * - * Author: Federico Mena-Quintero <federico@ximian.com> - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of version 2 of the GNU General Public - * License as published by the Free Software Foundation. - * - * 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA. - */ - -#ifndef CAL_BACKEND_FILE_H -#define CAL_BACKEND_FILE_H - -#include "pcs/cal-backend-sync.h" - -G_BEGIN_DECLS - - - -#define CAL_BACKEND_FILE_TYPE (cal_backend_file_get_type ()) -#define CAL_BACKEND_FILE(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), CAL_BACKEND_FILE_TYPE, \ - CalBackendFile)) -#define CAL_BACKEND_FILE_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), CAL_BACKEND_FILE_TYPE, \ - CalBackendFileClass)) -#define IS_CAL_BACKEND_FILE(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), CAL_BACKEND_FILE_TYPE)) -#define IS_CAL_BACKEND_FILE_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), CAL_BACKEND_FILE_TYPE)) - -typedef struct _CalBackendFile CalBackendFile; -typedef struct _CalBackendFileClass CalBackendFileClass; - -typedef struct _CalBackendFilePrivate CalBackendFilePrivate; - -struct _CalBackendFile { - CalBackendSync backend; - - /* Private data */ - CalBackendFilePrivate *priv; -}; - -struct _CalBackendFileClass { - CalBackendSyncClass parent_class; -}; - -GType cal_backend_file_get_type (void); - -void cal_backend_file_set_file_name (CalBackendFile *cbfile, - const char *file_name); -const char *cal_backend_file_get_file_name (CalBackendFile *cbfile); - - - -G_END_DECLS - -#endif diff --git a/calendar/pcs/cal-backend-http.c b/calendar/pcs/cal-backend-http.c deleted file mode 100644 index d8cc343b3f..0000000000 --- a/calendar/pcs/cal-backend-http.c +++ /dev/null @@ -1,621 +0,0 @@ -/* Evolution calendar - iCalendar http backend - * - * Copyright (C) 2003 Novell, Inc. - * - * Authors: Hans Petter Jansson <hpj@ximian.com> - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of version 2 of the GNU General Public - * License as published by the Free Software Foundation. - * - * 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA. - * - * Based in part on the file backend. - */ - -#include <config.h> -#include <string.h> -#include <unistd.h> -#include <bonobo/bonobo-exception.h> -#include <bonobo/bonobo-moniker-util.h> -#include <libgnome/gnome-i18n.h> -#include <libgnomevfs/gnome-vfs.h> -#include "e-util/e-xml-hash-utils.h" -#include "cal-util/cal-recur.h" -#include "cal-util/cal-util.h" -#include "cal-backend-http.h" -#include "cal-backend-file.h" -#include "cal-backend-util.h" -#include "cal-backend-object-sexp.h" - - - -/* Private part of the CalBackendHttp structure */ -struct _CalBackendHttpPrivate { - /* URI to get remote calendar data from */ - char *uri; - - /* Local/remote mode */ - CalMode mode; - - /* Cached-file backend */ - CalBackendFile file_backend; - - /* The calendar's default timezone, used for resolving DATE and - floating DATE-TIME values. */ - icaltimezone *default_zone; - - /* The list of live queries */ - GList *queries; -}; - - - -static void cal_backend_http_dispose (GObject *object); -static void cal_backend_http_finalize (GObject *object); - -static CalBackendSyncClass *parent_class; - - - -/* Dispose handler for the file backend */ -static void -cal_backend_http_dispose (GObject *object) -{ - CalBackendHttp *cbfile; - CalBackendHttpPrivate *priv; - - cbfile = CAL_BACKEND_HTTP (object); - priv = cbfile->priv; - - if (G_OBJECT_CLASS (parent_class)->dispose) - (* G_OBJECT_CLASS (parent_class)->dispose) (object); -} - -/* Finalize handler for the file backend */ -static void -cal_backend_http_finalize (GObject *object) -{ - CalBackendHttp *cbfile; - CalBackendHttpPrivate *priv; - - g_return_if_fail (object != NULL); - g_return_if_fail (IS_CAL_BACKEND_HTTP (object)); - - cbfile = CAL_BACKEND_HTTP (object); - priv = cbfile->priv; - - /* Clean up */ - - if (priv->uri) { - g_free (priv->uri); - priv->uri = NULL; - } - - g_free (priv); - cbfile->priv = NULL; - - if (G_OBJECT_CLASS (parent_class)->finalize) - (* G_OBJECT_CLASS (parent_class)->finalize) (object); -} - - - -/* Calendar backend methods */ - -/* Is_read_only handler for the file backend */ -static CalBackendSyncStatus -cal_backend_http_is_read_only (CalBackendSync *backend, Cal *cal, gboolean *read_only) -{ - CalBackendHttp *cbfile = backend; - - *read_only = TRUE; - - return GNOME_Evolution_Calendar_Success; -} - -/* Get_email_address handler for the file backend */ -static CalBackendSyncStatus -cal_backend_http_get_cal_address (CalBackendSync *backend, Cal *cal, char **address) -{ - /* A file backend has no particular email address associated - * with it (although that would be a useful feature some day). - */ - *address = NULL; - - return GNOME_Evolution_Calendar_Success; -} - -static CalBackendSyncStatus -cal_backend_http_get_ldap_attribute (CalBackendSync *backend, Cal *cal, char **attribute) -{ - *attribute = NULL; - - return GNOME_Evolution_Calendar_Success; -} - -static CalBackendSyncStatus -cal_backend_http_get_alarm_email_address (CalBackendSync *backend, Cal *cal, char **address) -{ - /* A file backend has no particular email address associated - * with it (although that would be a useful feature some day). - */ - *address = NULL; - - return GNOME_Evolution_Calendar_Success; -} - -static CalBackendSyncStatus -cal_backend_http_get_static_capabilities (CalBackendSync *backend, Cal *cal, char **capabilities) -{ - *capabilities = CAL_STATIC_CAPABILITY_NO_EMAIL_ALARMS; - - return GNOME_Evolution_Calendar_Success; -} - -/* Open handler for the file backend */ -static CalBackendSyncStatus -cal_backend_http_open (CalBackendSync *backend, Cal *cal, gboolean only_if_exists) -{ - CalBackendHttp *cbfile; - CalBackendHttpPrivate *priv; - char *str_uri; - CalBackendSyncStatus status = GNOME_Evolution_Calendar_NoSuchCal; - - cbfile = CAL_BACKEND_HTTP (backend); - priv = cbfile->priv; - - g_message ("Open URI '%s'.", cal_backend_get_uri (CAL_BACKEND (cbfile))); - - return status; -} - -static CalBackendSyncStatus -cal_backend_http_remove (CalBackendSync *backend, Cal *cal) -{ - CalBackendHttp *cbfile; - CalBackendHttpPrivate *priv; - char *str_uri; - - cbfile = CAL_BACKEND_HTTP (backend); - priv = cbfile->priv; - - return GNOME_Evolution_Calendar_OtherError; -} - -/* is_loaded handler for the file backend */ -static gboolean -cal_backend_http_is_loaded (CalBackend *backend) -{ - CalBackendHttp *cbfile; - CalBackendHttpPrivate *priv; - - cbfile = CAL_BACKEND_HTTP (backend); - priv = cbfile->priv; - - return FALSE; -} - -/* is_remote handler for the file backend */ -static CalMode -cal_backend_http_get_mode (CalBackend *backend) -{ - CalBackendHttp *cbfile; - CalBackendHttpPrivate *priv; - - cbfile = CAL_BACKEND_HTTP (backend); - priv = cbfile->priv; - - return priv->mode; -} - -#define cal_mode_to_corba(mode) \ - (mode == CAL_MODE_LOCAL ? GNOME_Evolution_Calendar_MODE_LOCAL : \ - mode == CAL_MODE_REMOTE ? GNOME_Evolution_Calendar_MODE_REMOTE : \ - GNOME_Evolution_Calendar_MODE_ANY) - -/* Set_mode handler for the file backend */ -static void -cal_backend_http_set_mode (CalBackend *backend, CalMode mode) -{ - CalBackendHttp *cbfile; - CalBackendHttpPrivate *priv; - GNOME_Evolution_Calendar_CalMode set_mode; - - cbfile = CAL_BACKEND_HTTP (backend); - priv = cbfile->priv; - - switch (mode) { - case CAL_MODE_LOCAL: - case CAL_MODE_REMOTE: - priv->mode = mode; - set_mode = cal_mode_to_corba (mode); - break; - case CAL_MODE_ANY: - priv->mode = CAL_MODE_REMOTE; - set_mode = GNOME_Evolution_Calendar_MODE_REMOTE; - break; - default: - set_mode = GNOME_Evolution_Calendar_MODE_ANY; - break; - } - - if (set_mode == GNOME_Evolution_Calendar_MODE_ANY) - cal_backend_notify_mode (backend, - GNOME_Evolution_Calendar_Listener_MODE_NOT_SUPPORTED, - cal_mode_to_corba (priv->mode)); - else - cal_backend_notify_mode (backend, - GNOME_Evolution_Calendar_Listener_MODE_SET, - set_mode); -} - -static CalBackendSyncStatus -cal_backend_http_get_default_object (CalBackendSync *backend, Cal *cal, char **object) -{ - CalComponent *comp; - - return GNOME_Evolution_Calendar_Success; -} - -/* Get_object_component handler for the file backend */ -static CalBackendSyncStatus -cal_backend_http_get_object (CalBackendSync *backend, Cal *cal, const char *uid, const char *rid, char **object) -{ - CalBackendHttp *cbfile; - CalBackendHttpPrivate *priv; - CalComponent *comp = NULL; - gboolean free_comp = FALSE; - - cbfile = CAL_BACKEND_HTTP (backend); - priv = cbfile->priv; - - g_return_val_if_fail (uid != NULL, GNOME_Evolution_Calendar_ObjectNotFound); - - return GNOME_Evolution_Calendar_Success; -} - -/* Get_timezone_object handler for the file backend */ -static CalBackendSyncStatus -cal_backend_http_get_timezone (CalBackendSync *backend, Cal *cal, const char *tzid, char **object) -{ - CalBackendHttp *cbfile; - CalBackendHttpPrivate *priv; - icaltimezone *zone; - icalcomponent *icalcomp; - - cbfile = CAL_BACKEND_HTTP (backend); - priv = cbfile->priv; - - g_return_val_if_fail (tzid != NULL, GNOME_Evolution_Calendar_ObjectNotFound); - - return GNOME_Evolution_Calendar_Success; -} - -/* Add_timezone handler for the file backend */ -static CalBackendSyncStatus -cal_backend_http_add_timezone (CalBackendSync *backend, Cal *cal, const char *tzobj) -{ - icalcomponent *tz_comp; - CalBackendHttp *cbfile; - CalBackendHttpPrivate *priv; - - cbfile = (CalBackendHttp *) backend; - - g_return_val_if_fail (IS_CAL_BACKEND_HTTP (cbfile), GNOME_Evolution_Calendar_OtherError); - g_return_val_if_fail (tzobj != NULL, GNOME_Evolution_Calendar_OtherError); - - priv = cbfile->priv; - - return GNOME_Evolution_Calendar_Success; -} - -static CalBackendSyncStatus -cal_backend_http_set_default_timezone (CalBackendSync *backend, Cal *cal, const char *tzid) -{ - CalBackendHttp *cbfile; - CalBackendHttpPrivate *priv; - icaltimezone *zone; - - cbfile = CAL_BACKEND_HTTP (backend); - priv = cbfile->priv; - - return GNOME_Evolution_Calendar_Success; -} - -/* Get_objects_in_range handler for the file backend */ -static CalBackendSyncStatus -cal_backend_http_get_object_list (CalBackendSync *backend, Cal *cal, const char *sexp, GList **objects) -{ - CalBackendHttp *cbfile; - CalBackendHttpPrivate *priv; - - cbfile = CAL_BACKEND_HTTP (backend); - priv = cbfile->priv; - - return GNOME_Evolution_Calendar_Success; -} - -/* get_query handler for the file backend */ -static void -cal_backend_http_start_query (CalBackend *backend, Query *query) -{ - CalBackendHttp *cbfile; - CalBackendHttpPrivate *priv; - - cbfile = CAL_BACKEND_HTTP (backend); - priv = cbfile->priv; -} - -/* Get_free_busy handler for the file backend */ -static CalBackendSyncStatus -cal_backend_http_get_free_busy (CalBackendSync *backend, Cal *cal, GList *users, - time_t start, time_t end, GList **freebusy) -{ - CalBackendHttp *cbfile; - CalBackendHttpPrivate *priv; - gchar *address, *name; - icalcomponent *vfb; - char *calobj; - GList *l; - - cbfile = CAL_BACKEND_HTTP (backend); - priv = cbfile->priv; - - g_return_val_if_fail (start != -1 && end != -1, GNOME_Evolution_Calendar_InvalidRange); - g_return_val_if_fail (start <= end, GNOME_Evolution_Calendar_InvalidRange); - - return GNOME_Evolution_Calendar_Success; -} - -/* Get_changes handler for the file backend */ -static CalBackendSyncStatus -cal_backend_http_get_changes (CalBackendSync *backend, Cal *cal, const char *change_id, - GList **adds, GList **modifies, GList **deletes) -{ - CalBackendHttp *cbfile; - CalBackendHttpPrivate *priv; - - cbfile = CAL_BACKEND_HTTP (backend); - priv = cbfile->priv; - - g_return_val_if_fail (change_id != NULL, GNOME_Evolution_Calendar_ObjectNotFound); - - return GNOME_Evolution_Calendar_Success; -} - -/* Discard_alarm handler for the file backend */ -static CalBackendSyncStatus -cal_backend_http_discard_alarm (CalBackendSync *backend, Cal *cal, const char *uid, const char *auid) -{ - /* we just do nothing with the alarm */ - return GNOME_Evolution_Calendar_Success; -} - -static CalBackendSyncStatus -cal_backend_http_create_object (CalBackendSync *backend, Cal *cal, const char *calobj, char **uid) -{ - CalBackendHttp *cbfile; - CalBackendHttpPrivate *priv; - icalcomponent *icalcomp; - icalcomponent_kind kind; - CalComponent *comp; - const char *comp_uid; - struct icaltimetype current; - - cbfile = CAL_BACKEND_HTTP (backend); - priv = cbfile->priv; - - g_return_val_if_fail (calobj != NULL, GNOME_Evolution_Calendar_ObjectNotFound); - - return GNOME_Evolution_Calendar_Success; -} - -static CalBackendSyncStatus -cal_backend_http_modify_object (CalBackendSync *backend, Cal *cal, const char *calobj, - CalObjModType mod, char **old_object) -{ - CalBackendHttp *cbfile; - CalBackendHttpPrivate *priv; - icalcomponent *icalcomp; - icalcomponent_kind kind; - const char *comp_uid; - CalComponent *comp; - struct icaltimetype current; - - cbfile = CAL_BACKEND_HTTP (backend); - priv = cbfile->priv; - - g_return_val_if_fail (calobj != NULL, GNOME_Evolution_Calendar_ObjectNotFound); - - return GNOME_Evolution_Calendar_Success; -} - -/* Remove_object handler for the file backend */ -static CalBackendSyncStatus -cal_backend_http_remove_object (CalBackendSync *backend, Cal *cal, - const char *uid, const char *rid, - CalObjModType mod, char **object) -{ - CalBackendHttp *cbfile; - CalBackendHttpPrivate *priv; - CalComponent *comp; - char *hash_rid; - GSList *categories; - - cbfile = CAL_BACKEND_HTTP (backend); - priv = cbfile->priv; - - g_return_val_if_fail (uid != NULL, GNOME_Evolution_Calendar_ObjectNotFound); - - return GNOME_Evolution_Calendar_Success; -} - -/* Update_objects handler for the file backend. */ -static CalBackendSyncStatus -cal_backend_http_receive_objects (CalBackendSync *backend, Cal *cal, const char *calobj) -{ - CalBackendHttp *cbfile; - CalBackendHttpPrivate *priv; - icalcomponent *toplevel_comp, *icalcomp = NULL; - icalcomponent_kind kind; - icalproperty_method method; - icalcomponent *subcomp; - GList *comps, *l; - CalBackendSyncStatus status = GNOME_Evolution_Calendar_Success; - - cbfile = CAL_BACKEND_HTTP (backend); - priv = cbfile->priv; - - g_return_val_if_fail (calobj != NULL, GNOME_Evolution_Calendar_InvalidObject); - - return status; -} - -static CalBackendSyncStatus -cal_backend_http_send_objects (CalBackendSync *backend, Cal *cal, const char *calobj) -{ - /* FIXME Put in a util routine to send stuff via email */ - - return GNOME_Evolution_Calendar_Success; -} - -static icaltimezone * -cal_backend_http_internal_get_default_timezone (CalBackend *backend) -{ - CalBackendHttp *cbfile; - CalBackendHttpPrivate *priv; - - cbfile = CAL_BACKEND_HTTP (backend); - priv = cbfile->priv; - - - return priv->default_zone; -} - -static icaltimezone * -cal_backend_http_internal_get_timezone (CalBackend *backend, const char *tzid) -{ - CalBackendHttp *cbfile; - CalBackendHttpPrivate *priv; - icaltimezone *zone; - - cbfile = CAL_BACKEND_HTTP (backend); - priv = cbfile->priv; - - if (!strcmp (tzid, "UTC")) - zone = icaltimezone_get_utc_timezone (); - else { - zone = icaltimezone_get_builtin_timezone_from_tzid (tzid); - } - - return zone; -} - -/* Object initialization function for the file backend */ -static void -cal_backend_http_init (CalBackendHttp *cbfile, CalBackendHttpClass *class) -{ - CalBackendHttpPrivate *priv; - - g_message ("Webcal backend init."); - - priv = g_new0 (CalBackendHttpPrivate, 1); - cbfile->priv = priv; - - priv->uri = NULL; - -#if 0 - priv->config_listener = e_config_listener_new (); -#endif -} - -/* Class initialization function for the file backend */ -static void -cal_backend_http_class_init (CalBackendHttpClass *class) -{ - GObjectClass *object_class; - CalBackendClass *backend_class; - CalBackendSyncClass *sync_class; - - object_class = (GObjectClass *) class; - backend_class = (CalBackendClass *) class; - sync_class = (CalBackendSyncClass *) class; - - parent_class = (CalBackendSyncClass *) g_type_class_peek_parent (class); - - object_class->dispose = cal_backend_http_dispose; - object_class->finalize = cal_backend_http_finalize; - - sync_class->is_read_only_sync = cal_backend_http_is_read_only; - sync_class->get_cal_address_sync = cal_backend_http_get_cal_address; - sync_class->get_alarm_email_address_sync = cal_backend_http_get_alarm_email_address; - sync_class->get_ldap_attribute_sync = cal_backend_http_get_ldap_attribute; - sync_class->get_static_capabilities_sync = cal_backend_http_get_static_capabilities; - sync_class->open_sync = cal_backend_http_open; - sync_class->remove_sync = cal_backend_http_remove; - sync_class->create_object_sync = cal_backend_http_create_object; - sync_class->modify_object_sync = cal_backend_http_modify_object; - sync_class->remove_object_sync = cal_backend_http_remove_object; - sync_class->discard_alarm_sync = cal_backend_http_discard_alarm; - sync_class->receive_objects_sync = cal_backend_http_receive_objects; - sync_class->send_objects_sync = cal_backend_http_send_objects; - sync_class->get_default_object_sync = cal_backend_http_get_default_object; - sync_class->get_object_sync = cal_backend_http_get_object; - sync_class->get_object_list_sync = cal_backend_http_get_object_list; - sync_class->get_timezone_sync = cal_backend_http_get_timezone; - sync_class->add_timezone_sync = cal_backend_http_add_timezone; - sync_class->set_default_timezone_sync = cal_backend_http_set_default_timezone; - sync_class->get_freebusy_sync = cal_backend_http_get_free_busy; - sync_class->get_changes_sync = cal_backend_http_get_changes; - - backend_class->is_loaded = cal_backend_http_is_loaded; - backend_class->start_query = cal_backend_http_start_query; - backend_class->get_mode = cal_backend_http_get_mode; - backend_class->set_mode = cal_backend_http_set_mode; - - backend_class->internal_get_default_timezone = cal_backend_http_internal_get_default_timezone; - backend_class->internal_get_timezone = cal_backend_http_internal_get_timezone; -} - - -/** - * cal_backend_http_get_type: - * @void: - * - * Registers the #CalBackendHttp class if necessary, and returns the type ID - * associated to it. - * - * Return value: The type ID of the #CalBackendHttp class. - **/ -GType -cal_backend_http_get_type (void) -{ - static GType cal_backend_http_type = 0; - - g_message (G_STRLOC); - - if (!cal_backend_http_type) { - static GTypeInfo info = { - sizeof (CalBackendHttpClass), - (GBaseInitFunc) NULL, - (GBaseFinalizeFunc) NULL, - (GClassInitFunc) cal_backend_http_class_init, - NULL, NULL, - sizeof (CalBackendHttp), - 0, - (GInstanceInitFunc) cal_backend_http_init - }; - cal_backend_http_type = g_type_register_static (CAL_TYPE_BACKEND_SYNC, - "CalBackendHttp", &info, 0); - } - - return cal_backend_http_type; -} diff --git a/calendar/pcs/cal-backend-http.h b/calendar/pcs/cal-backend-http.h deleted file mode 100644 index 35f47cae16..0000000000 --- a/calendar/pcs/cal-backend-http.h +++ /dev/null @@ -1,61 +0,0 @@ -/* Evolution calendar - iCalendar file backend - * - * Copyright (C) 2000 Ximian, Inc. - * Copyright (C) 2000 Ximian, Inc. - * - * Author: Federico Mena-Quintero <federico@ximian.com> - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of version 2 of the GNU General Public - * License as published by the Free Software Foundation. - * - * 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA. - */ - -#ifndef CAL_BACKEND_HTTP_H -#define CAL_BACKEND_HTTP_H - -#include "pcs/cal-backend-sync.h" - -G_BEGIN_DECLS - - - -#define CAL_BACKEND_HTTP_TYPE (cal_backend_http_get_type ()) -#define CAL_BACKEND_HTTP(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), CAL_BACKEND_HTTP_TYPE, \ - CalBackendHttp)) -#define CAL_BACKEND_HTTP_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), CAL_BACKEND_HTTP_TYPE, \ - CalBackendHttpClass)) -#define IS_CAL_BACKEND_HTTP(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), CAL_BACKEND_HTTP_TYPE)) -#define IS_CAL_BACKEND_HTTP_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), CAL_BACKEND_HTTP_TYPE)) - -typedef struct _CalBackendHttp CalBackendHttp; -typedef struct _CalBackendHttpClass CalBackendHttpClass; - -typedef struct _CalBackendHttpPrivate CalBackendHttpPrivate; - -struct _CalBackendHttp { - CalBackendSync backend; - - /* Private data */ - CalBackendHttpPrivate *priv; -}; - -struct _CalBackendHttpClass { - CalBackendSyncClass parent_class; -}; - -GType cal_backend_http_get_type (void); - - - -G_END_DECLS - -#endif diff --git a/calendar/pcs/cal-backend-object-sexp.c b/calendar/pcs/cal-backend-object-sexp.c deleted file mode 100644 index 4bc6b78ebe..0000000000 --- a/calendar/pcs/cal-backend-object-sexp.c +++ /dev/null @@ -1,1007 +0,0 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */ -/* - * cal-backend-card-sexp.c - * Copyright 1999, 2000, 2001, Ximian, Inc. - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Library General Public - * License, version 2, as published by the Free Software Foundation. - * - * This library 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 - * Library General Public License for more details. - * - * You should have received a copy of the GNU Library General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA - * 02111-1307, USA. - */ - -#include <string.h> -#include <libgnome/gnome-i18n.h> -#include <e-util/e-sexp.h> -#include <gal/widgets/e-unicode.h> -#include <cal-util/timeutil.h> - -#include "cal-backend-object-sexp.h" - -static GObjectClass *parent_class; - -typedef struct _SearchContext SearchContext; - -struct _CalBackendObjectSExpPrivate { - ESExp *search_sexp; - char *text; - SearchContext *search_context; -}; - -struct _SearchContext { - CalComponent *comp; - CalBackend *backend; -}; - -static ESExpResult * -func_time_now (ESExp *esexp, int argc, ESExpResult **argv, void *data) -{ - ESExpResult *result; - - if (argc != 0) { - e_sexp_fatal_error (esexp, _("time-now expects 0 arguments")); - return NULL; - } - - result = e_sexp_result_new (esexp, ESEXP_RES_TIME); - result->value.time = time (NULL); - - return result; -} - -/* (make-time ISODATE) - * - * ISODATE - string, ISO 8601 date/time representation - * - * Constructs a time_t value for the specified date. - */ -static ESExpResult * -func_make_time (ESExp *esexp, int argc, ESExpResult **argv, void *data) -{ - const char *str; - time_t t; - ESExpResult *result; - - if (argc != 1) { - e_sexp_fatal_error (esexp, _("make-time expects 1 argument")); - return NULL; - } - - if (argv[0]->type != ESEXP_RES_STRING) { - e_sexp_fatal_error (esexp, _("make-time expects argument 1 " - "to be a string")); - return NULL; - } - str = argv[0]->value.string; - - t = time_from_isodate (str); - if (t == -1) { - e_sexp_fatal_error (esexp, _("make-time argument 1 must be an " - "ISO 8601 date/time string")); - return NULL; - } - - result = e_sexp_result_new (esexp, ESEXP_RES_TIME); - result->value.time = t; - - return result; -} - -/* (time-add-day TIME N) - * - * TIME - time_t, base time - * N - int, number of days to add - * - * Adds the specified number of days to a time value. - * - * FIXME: TIMEZONES - need to use a timezone or daylight saving changes will - * make the result incorrect. - */ -static ESExpResult * -func_time_add_day (ESExp *esexp, int argc, ESExpResult **argv, void *data) -{ - ESExpResult *result; - time_t t; - int n; - - if (argc != 2) { - e_sexp_fatal_error (esexp, _("time-add-day expects 2 arguments")); - return NULL; - } - - if (argv[0]->type != ESEXP_RES_TIME) { - e_sexp_fatal_error (esexp, _("time-add-day expects argument 1 " - "to be a time_t")); - return NULL; - } - t = argv[0]->value.time; - - if (argv[1]->type != ESEXP_RES_INT) { - e_sexp_fatal_error (esexp, _("time-add-day expects argument 2 " - "to be an integer")); - return NULL; - } - n = argv[1]->value.number; - - result = e_sexp_result_new (esexp, ESEXP_RES_TIME); - result->value.time = time_add_day (t, n); - - return result; -} - -/* (time-day-begin TIME) - * - * TIME - time_t, base time - * - * Returns the start of the day, according to the local time. - * - * FIXME: TIMEZONES - this uses the current Unix timezone. - */ -static ESExpResult * -func_time_day_begin (ESExp *esexp, int argc, ESExpResult **argv, void *data) -{ - time_t t; - ESExpResult *result; - - if (argc != 1) { - e_sexp_fatal_error (esexp, _("time-day-begin expects 1 argument")); - return NULL; - } - - if (argv[0]->type != ESEXP_RES_TIME) { - e_sexp_fatal_error (esexp, _("time-day-begin expects argument 1 " - "to be a time_t")); - return NULL; - } - t = argv[0]->value.time; - - result = e_sexp_result_new (esexp, ESEXP_RES_TIME); - result->value.time = time_day_begin (t); - - return result; -} - -/* (time-day-end TIME) - * - * TIME - time_t, base time - * - * Returns the end of the day, according to the local time. - * - * FIXME: TIMEZONES - this uses the current Unix timezone. - */ -static ESExpResult * -func_time_day_end (ESExp *esexp, int argc, ESExpResult **argv, void *data) -{ - time_t t; - ESExpResult *result; - - if (argc != 1) { - e_sexp_fatal_error (esexp, _("time-day-end expects 1 argument")); - return NULL; - } - - if (argv[0]->type != ESEXP_RES_TIME) { - e_sexp_fatal_error (esexp, _("time-day-end expects argument 1 " - "to be a time_t")); - return NULL; - } - t = argv[0]->value.time; - - result = e_sexp_result_new (esexp, ESEXP_RES_TIME); - result->value.time = time_day_end (t); - - return result; -} - -/* (get-vtype) - * - * Returns a string indicating the type of component (VEVENT, VTODO, VJOURNAL, - * VFREEBUSY, VTIMEZONE, UNKNOWN). - */ -static ESExpResult * -func_get_vtype (ESExp *esexp, int argc, ESExpResult **argv, void *data) -{ - SearchContext *ctx = data; - CalComponentVType vtype; - char *str; - ESExpResult *result; - - /* Check argument types */ - - if (argc != 0) { - e_sexp_fatal_error (esexp, _("get-vtype expects 0 arguments")); - return NULL; - } - - /* Get the type */ - - vtype = cal_component_get_vtype (ctx->comp); - - switch (vtype) { - case CAL_COMPONENT_EVENT: - str = g_strdup ("VEVENT"); - break; - - case CAL_COMPONENT_TODO: - str = g_strdup ("VTODO"); - break; - - case CAL_COMPONENT_JOURNAL: - str = g_strdup ("VJOURNAL"); - break; - - case CAL_COMPONENT_FREEBUSY: - str = g_strdup ("VFREEBUSY"); - break; - - case CAL_COMPONENT_TIMEZONE: - str = g_strdup ("VTIMEZONE"); - break; - - default: - str = g_strdup ("UNKNOWN"); - break; - } - - result = e_sexp_result_new (esexp, ESEXP_RES_STRING); - result->value.string = str; - - return result; -} - -/* (occur-in-time-range? START END) - * - * START - time_t, start of the time range - * END - time_t, end of the time range - * - * Returns a boolean indicating whether the component has any occurrences in the - * specified time range. - */ -static ESExpResult * -func_occur_in_time_range (ESExp *esexp, int argc, ESExpResult **argv, void *data) -{ - SearchContext *ctx = data; - time_t start, end, tt; - gboolean occurs; - ESExpResult *result; - CalComponentDateTime dt; - - /* Check argument types */ - - if (argc != 2) { - e_sexp_fatal_error (esexp, _("occur-in-time-range? expects 2 arguments")); - return NULL; - } - - if (argv[0]->type != ESEXP_RES_TIME) { - e_sexp_fatal_error (esexp, _("occur-in-time-range? expects argument 1 " - "to be a time_t")); - return NULL; - } - start = argv[0]->value.time; - - if (argv[1]->type != ESEXP_RES_TIME) { - e_sexp_fatal_error (esexp, _("occur-in-time-range? expects argument 2 " - "to be a time_t")); - return NULL; - } - end = argv[1]->value.time; - - /* See if the object occurs in the specified time range */ - occurs = FALSE; - - cal_component_get_dtstart (ctx->comp, &dt); - if (dt.value) { - icaltimezone *zone; - - if (dt.tzid) - zone = cal_backend_internal_get_timezone (ctx->backend, dt.tzid); - else - zone = cal_backend_internal_get_default_timezone (ctx->backend); - - tt = icaltime_as_timet_with_zone (*dt.value, zone); - if (tt >= start && tt <= end) - occurs = TRUE; - else { - cal_component_get_dtend (ctx->comp, &dt); - if (dt.value) { - if (dt.tzid) - zone = cal_backend_internal_get_timezone (ctx->backend, dt.tzid); - else - zone = cal_backend_internal_get_default_timezone (ctx->backend); - - tt = icaltime_as_timet_with_zone (*dt.value, zone); - if (tt >= start && tt <= end) - occurs = TRUE; - } - } - } - - result = e_sexp_result_new (esexp, ESEXP_RES_BOOL); - result->value.bool = occurs; - - return result; -} - -/* Returns whether a list of CalComponentText items matches the specified string */ -static gboolean -matches_text_list (GSList *text_list, const char *str) -{ - GSList *l; - gboolean matches; - - matches = FALSE; - - for (l = text_list; l; l = l->next) { - CalComponentText *text; - - text = l->data; - g_assert (text->value != NULL); - - if (e_utf8_strstrcasedecomp (text->value, str) != NULL) { - matches = TRUE; - break; - } - } - - return matches; -} - -/* Returns whether the comments in a component matches the specified string */ -static gboolean -matches_comment (CalComponent *comp, const char *str) -{ - GSList *list; - gboolean matches; - - cal_component_get_comment_list (comp, &list); - matches = matches_text_list (list, str); - cal_component_free_text_list (list); - - return matches; -} - -/* Returns whether the description in a component matches the specified string */ -static gboolean -matches_description (CalComponent *comp, const char *str) -{ - GSList *list; - gboolean matches; - - cal_component_get_description_list (comp, &list); - matches = matches_text_list (list, str); - cal_component_free_text_list (list); - - return matches; -} - -/* Returns whether the summary in a component matches the specified string */ -static gboolean -matches_summary (CalComponent *comp, const char *str) -{ - CalComponentText text; - - cal_component_get_summary (comp, &text); - - if (!text.value) - return FALSE; - - return e_utf8_strstrcasedecomp (text.value, str) != NULL; -} - -/* Returns whether any text field in a component matches the specified string */ -static gboolean -matches_any (CalComponent *comp, const char *str) -{ - /* As an optimization, and to make life easier for the individual - * predicate functions, see if we are looking for the empty string right - * away. - */ - if (strlen (str) == 0) - return TRUE; - - return (matches_comment (comp, str) - || matches_description (comp, str) - || matches_summary (comp, str)); -} - -/* (contains? FIELD STR) - * - * FIELD - string, name of field to match (any, comment, description, summary) - * STR - string, match string - * - * Returns a boolean indicating whether the specified field contains the - * specified string. - */ -static ESExpResult * -func_contains (ESExp *esexp, int argc, ESExpResult **argv, void *data) -{ - SearchContext *ctx = data; - const char *field; - const char *str; - gboolean matches; - ESExpResult *result; - - /* Check argument types */ - - if (argc != 2) { - e_sexp_fatal_error (esexp, _("contains? expects 2 arguments")); - return NULL; - } - - if (argv[0]->type != ESEXP_RES_STRING) { - e_sexp_fatal_error (esexp, _("contains? expects argument 1 " - "to be a string")); - return NULL; - } - field = argv[0]->value.string; - - if (argv[1]->type != ESEXP_RES_STRING) { - e_sexp_fatal_error (esexp, _("contains? expects argument 2 " - "to be a string")); - return NULL; - } - str = argv[1]->value.string; - - /* See if it matches */ - - if (strcmp (field, "any") == 0) - matches = matches_any (ctx->comp, str); - else if (strcmp (field, "comment") == 0) - matches = matches_comment (ctx->comp, str); - else if (strcmp (field, "description") == 0) - matches = matches_description (ctx->comp, str); - else if (strcmp (field, "summary") == 0) - matches = matches_summary (ctx->comp, str); - else { - e_sexp_fatal_error (esexp, _("contains? expects argument 1 to " - "be one of \"any\", \"summary\", \"description\"")); - return NULL; - } - - result = e_sexp_result_new (esexp, ESEXP_RES_BOOL); - result->value.bool = matches; - - return result; -} - -/* (has-alarms? #f|#t) - * - * A boolean value for components that have/dont have alarms. - * - * Returns: a boolean indicating whether the component has alarms or not. - */ -static ESExpResult * -func_has_alarms (ESExp *esexp, int argc, ESExpResult **argv, void *data) -{ - SearchContext *ctx = data; - ESExpResult *result; - gboolean has_to_have_alarms; - - /* Check argument types */ - - if (argc != 1) { - e_sexp_fatal_error (esexp, _("has-alarms? expects at least 1 argument")); - return NULL; - } - - if (argv[0]->type != ESEXP_RES_BOOL) { - e_sexp_fatal_error (esexp, _("has-alarms? excepts argument to be a boolean")); - return NULL; - } - - has_to_have_alarms = argv[0]->value.bool; - result = e_sexp_result_new (esexp, ESEXP_RES_BOOL); - - if (has_to_have_alarms && cal_component_has_alarms (ctx->comp)) - result->value.bool = TRUE; - else if (!has_to_have_alarms && !cal_component_has_alarms (ctx->comp)) - result->value.bool = TRUE; - else - result->value.bool = FALSE; - - return result; -} - -/* (has-categories? STR+) - * (has-categories? #f) - * - * STR - At least one string specifying a category - * Or you can specify a single #f (boolean false) value for components - * that have no categories assigned to them ("unfiled"). - * - * Returns a boolean indicating whether the component has all the specified - * categories. - */ -static ESExpResult * -func_has_categories (ESExp *esexp, int argc, ESExpResult **argv, void *data) -{ - SearchContext *ctx = data; - gboolean unfiled; - int i; - GSList *categories; - gboolean matches; - ESExpResult *result; - - /* Check argument types */ - - if (argc < 1) { - e_sexp_fatal_error (esexp, _("has-categories? expects at least 1 argument")); - return NULL; - } - - if (argc == 1 && argv[0]->type == ESEXP_RES_BOOL) - unfiled = TRUE; - else - unfiled = FALSE; - - if (!unfiled) - for (i = 0; i < argc; i++) - if (argv[i]->type != ESEXP_RES_STRING) { - e_sexp_fatal_error (esexp, _("has-categories? expects all arguments " - "to be strings or one and only one " - "argument to be a boolean false (#f)")); - return NULL; - } - - /* Search categories. First, if there are no categories we return - * whether unfiled components are supposed to match. - */ - - cal_component_get_categories_list (ctx->comp, &categories); - if (!categories) { - result = e_sexp_result_new (esexp, ESEXP_RES_BOOL); - result->value.bool = unfiled; - - return result; - } - - /* Otherwise, we *do* have categories but unfiled components were - * requested, so this component does not match. - */ - if (unfiled) { - result = e_sexp_result_new (esexp, ESEXP_RES_BOOL); - result->value.bool = FALSE; - - return result; - } - - matches = TRUE; - - for (i = 0; i < argc; i++) { - const char *sought; - GSList *l; - gboolean has_category; - - sought = argv[i]->value.string; - - has_category = FALSE; - - for (l = categories; l; l = l->next) { - const char *category; - - category = l->data; - - if (strcmp (category, sought) == 0) { - has_category = TRUE; - break; - } - } - - if (!has_category) { - matches = FALSE; - break; - } - } - - cal_component_free_categories_list (categories); - - result = e_sexp_result_new (esexp, ESEXP_RES_BOOL); - result->value.bool = matches; - - return result; -} - -/* (is-completed?) - * - * Returns a boolean indicating whether the component is completed (i.e. has - * a COMPLETED property. This is really only useful for TODO components. - */ -static ESExpResult * -func_is_completed (ESExp *esexp, int argc, ESExpResult **argv, void *data) -{ - SearchContext *ctx = data; - ESExpResult *result; - struct icaltimetype *t; - gboolean complete = FALSE; - - /* Check argument types */ - - if (argc != 0) { - e_sexp_fatal_error (esexp, _("is-completed? expects 0 arguments")); - return NULL; - } - - cal_component_get_completed (ctx->comp, &t); - if (t) { - complete = TRUE; - cal_component_free_icaltimetype (t); - } - - result = e_sexp_result_new (esexp, ESEXP_RES_BOOL); - result->value.bool = complete; - - return result; -} - -/* (completed-before? TIME) - * - * TIME - time_t - * - * Returns a boolean indicating whether the component was completed on or - * before the given time (i.e. it checks the COMPLETED property). - * This is really only useful for TODO components. - */ -static ESExpResult * -func_completed_before (ESExp *esexp, int argc, ESExpResult **argv, void *data) -{ - SearchContext *ctx = data; - ESExpResult *result; - struct icaltimetype *tt; - icaltimezone *zone; - gboolean retval = FALSE; - time_t before_time, completed_time; - - /* Check argument types */ - - if (argc != 1) { - e_sexp_fatal_error (esexp, _("completed-before? expects 1 argument")); - return NULL; - } - - if (argv[0]->type != ESEXP_RES_TIME) { - e_sexp_fatal_error (esexp, _("completed-before? expects argument 1 " - "to be a time_t")); - return NULL; - } - before_time = argv[0]->value.time; - - cal_component_get_completed (ctx->comp, &tt); - if (tt) { - /* COMPLETED must be in UTC. */ - zone = icaltimezone_get_utc_timezone (); - completed_time = icaltime_as_timet_with_zone (*tt, zone); - -#if 0 - g_print ("Query Time : %s", ctime (&before_time)); - g_print ("Completed Time: %s", ctime (&completed_time)); -#endif - - /* We want to return TRUE if before_time is after - completed_time. */ - if (difftime (before_time, completed_time) > 0) { -#if 0 - g_print (" Returning TRUE\n"); -#endif - retval = TRUE; - } - - cal_component_free_icaltimetype (tt); - } - - result = e_sexp_result_new (esexp, ESEXP_RES_BOOL); - result->value.bool = retval; - - return result; -} - -#if 0 -static struct prop_info { - ECardSimpleField field_id; - const char *query_prop; - const char *ecard_prop; -#define PROP_TYPE_NORMAL 0x01 -#define PROP_TYPE_LIST 0x02 -#define PROP_TYPE_LISTITEM 0x03 -#define PROP_TYPE_ID 0x04 - int prop_type; - gboolean (*list_compare)(ECardSimple *ecard, const char *str, - char *(*compare)(const char*, const char*)); - -} prop_info_table[] = { -#define NORMAL_PROP(f,q,e) {f, q, e, PROP_TYPE_NORMAL, NULL} -#define ID_PROP {0, "id", NULL, PROP_TYPE_ID, NULL} -#define LIST_PROP(q,e,c) {0, q, e, PROP_TYPE_LIST, c} - - /* query prop, ecard prop, type, list compare function */ - NORMAL_PROP ( E_CARD_SIMPLE_FIELD_FILE_AS, "file_as", "file_as" ), - LIST_PROP ( "full_name", "full_name", compare_name), /* not really a list, but we need to compare both full and surname */ - NORMAL_PROP ( E_CARD_SIMPLE_FIELD_URL, "url", "url" ), - NORMAL_PROP ( E_CARD_SIMPLE_FIELD_MAILER, "mailer", "mailer"), - NORMAL_PROP ( E_CARD_SIMPLE_FIELD_ORG, "org", "org"), - NORMAL_PROP ( E_CARD_SIMPLE_FIELD_ORG_UNIT, "org_unit", "org_unit"), - NORMAL_PROP ( E_CARD_SIMPLE_FIELD_OFFICE, "office", "office"), - NORMAL_PROP ( E_CARD_SIMPLE_FIELD_TITLE, "title", "title"), - NORMAL_PROP ( E_CARD_SIMPLE_FIELD_ROLE, "role", "role"), - NORMAL_PROP ( E_CARD_SIMPLE_FIELD_MANAGER, "manager", "manager"), - NORMAL_PROP ( E_CARD_SIMPLE_FIELD_ASSISTANT, "assistant", "assistant"), - NORMAL_PROP ( E_CARD_SIMPLE_FIELD_NICKNAME, "nickname", "nickname"), - NORMAL_PROP ( E_CARD_SIMPLE_FIELD_SPOUSE, "spouse", "spouse" ), - NORMAL_PROP ( E_CARD_SIMPLE_FIELD_NOTE, "note", "note"), - ID_PROP, - LIST_PROP ( "email", "email", compare_email ), - LIST_PROP ( "phone", "phone", compare_phone ), - LIST_PROP ( "address", "address", compare_address ), - LIST_PROP ( "category", "category", compare_category ), - LIST_PROP ( "arbitrary", "arbitrary", compare_arbitrary ) -}; -static int num_prop_infos = sizeof(prop_info_table) / sizeof(prop_info_table[0]); - -static ESExpResult * -entry_compare(SearchContext *ctx, struct _ESExp *f, - int argc, struct _ESExpResult **argv, - char *(*compare)(const char*, const char*)) -{ - ESExpResult *r; - int truth = FALSE; - - if (argc == 2 - && argv[0]->type == ESEXP_RES_STRING - && argv[1]->type == ESEXP_RES_STRING) { - char *propname; - struct prop_info *info = NULL; - int i; - gboolean any_field; - - propname = argv[0]->value.string; - - any_field = !strcmp(propname, "x-evolution-any-field"); - for (i = 0; i < num_prop_infos; i ++) { - if (any_field - || !strcmp (prop_info_table[i].query_prop, propname)) { - info = &prop_info_table[i]; - - if (info->prop_type == PROP_TYPE_NORMAL) { - char *prop = NULL; - /* searches where the query's property - maps directly to an ecard property */ - - prop = e_card_simple_get (ctx->card, info->field_id); - - if (prop && compare(prop, argv[1]->value.string)) { - truth = TRUE; - } - if ((!prop) && compare("", argv[1]->value.string)) { - truth = TRUE; - } - g_free (prop); - } else if (info->prop_type == PROP_TYPE_LIST) { - /* the special searches that match any of the list elements */ - truth = info->list_compare (ctx->card, argv[1]->value.string, compare); - } else if (info->prop_type == PROP_TYPE_ID) { - const char *prop = NULL; - /* searches where the query's property - maps directly to an ecard property */ - - prop = e_card_get_id (ctx->card->card); - - if (prop && compare(prop, argv[1]->value.string)) { - truth = TRUE; - } - if ((!prop) && compare("", argv[1]->value.string)) { - truth = TRUE; - } - } - - /* if we're looking at all fields and find a match, - or if we're just looking at this one field, - break. */ - if ((any_field && truth) - || !any_field) - break; - } - } - - } - r = e_sexp_result_new(f, ESEXP_RES_BOOL); - r->value.bool = truth; - - return r; -} -#endif - -/* 'builtin' functions */ -static struct { - char *name; - ESExpFunc *func; - int type; /* set to 1 if a function can perform shortcut evaluation, or - doesn't execute everything, 0 otherwise */ -} symbols[] = { - /* Time-related functions */ - { "time-now", func_time_now, 0 }, - { "make-time", func_make_time, 0 }, - { "time-add-day", func_time_add_day, 0 }, - { "time-day-begin", func_time_day_begin, 0 }, - { "time-day-end", func_time_day_end, 0 }, - - /* Component-related functions */ - { "get-vtype", func_get_vtype, 0 }, - { "occur-in-time-range?", func_occur_in_time_range, 0 }, - { "contains?", func_contains, 0 }, - { "has-alarms?", func_has_alarms, 0 }, - { "has-categories?", func_has_categories, 0 }, - { "is-completed?", func_is_completed, 0 }, - { "completed-before?", func_completed_before, 0 } -}; - -gboolean -cal_backend_object_sexp_match_comp (CalBackendObjectSExp *sexp, CalComponent *comp, CalBackend *backend) -{ - ESExpResult *r; - gboolean retval; - - sexp->priv->search_context->comp = g_object_ref (comp); - sexp->priv->search_context->backend = g_object_ref (backend); - - /* if it's not a valid vcard why is it in our db? :) */ - if (!sexp->priv->search_context->comp) - return FALSE; - - r = e_sexp_eval(sexp->priv->search_sexp); - - retval = (r && r->type == ESEXP_RES_BOOL && r->value.bool); - - g_object_unref (sexp->priv->search_context->comp); - g_object_unref (sexp->priv->search_context->backend); - - e_sexp_result_free(sexp->priv->search_sexp, r); - - return retval; -} - -gboolean -cal_backend_object_sexp_match_object (CalBackendObjectSExp *sexp, const char *object, CalBackend *backend) -{ - CalComponent *comp; - icalcomponent *icalcomp; - gboolean retval; - - icalcomp = icalcomponent_new_from_string ((char *) object); - if (!icalcomp) - return FALSE; - - comp = cal_component_new (); - cal_component_set_icalcomponent (comp, icalcomp); - - retval = cal_backend_object_sexp_match_comp (sexp, comp, backend); - - g_object_unref (comp); - - return retval; -} - - - -/** - * cal_backend_card_sexp_new: - */ -CalBackendObjectSExp * -cal_backend_object_sexp_new (const char *text) -{ - CalBackendObjectSExp *sexp = g_object_new (CAL_TYPE_BACKEND_OBJECT_SEXP, NULL); - int esexp_error; - int i; - - sexp->priv->search_sexp = e_sexp_new(); - sexp->priv->text = g_strdup (text); - - for(i=0;i<sizeof(symbols)/sizeof(symbols[0]);i++) { - if (symbols[i].type == 1) { - e_sexp_add_ifunction(sexp->priv->search_sexp, 0, symbols[i].name, - (ESExpIFunc *)symbols[i].func, sexp->priv->search_context); - } else { - e_sexp_add_function(sexp->priv->search_sexp, 0, symbols[i].name, - symbols[i].func, sexp->priv->search_context); - } - } - - e_sexp_input_text(sexp->priv->search_sexp, text, strlen(text)); - esexp_error = e_sexp_parse(sexp->priv->search_sexp); - - if (esexp_error == -1) { - g_object_unref (sexp); - sexp = NULL; - } - - return sexp; -} - -const char * -cal_backend_object_sexp_text (CalBackendObjectSExp *sexp) -{ - CalBackendObjectSExpPrivate *priv; - - g_return_val_if_fail (sexp != NULL, NULL); - g_return_val_if_fail (CAL_IS_BACKEND_OBJECT_SEXP (sexp), NULL); - - priv = sexp->priv; - - return priv->text; -} - -static void -cal_backend_object_sexp_dispose (GObject *object) -{ - CalBackendObjectSExp *sexp = CAL_BACKEND_OBJECT_SEXP (object); - - if (sexp->priv) { - e_sexp_unref(sexp->priv->search_sexp); - - g_free (sexp->priv->text); - - g_free (sexp->priv->search_context); - g_free (sexp->priv); - sexp->priv = NULL; - } - - if (G_OBJECT_CLASS (parent_class)->dispose) - G_OBJECT_CLASS (parent_class)->dispose (object); -} - -static void -cal_backend_object_sexp_class_init (CalBackendObjectSExpClass *klass) -{ - GObjectClass *object_class = G_OBJECT_CLASS (klass); - - parent_class = g_type_class_peek_parent (klass); - - /* Set the virtual methods. */ - - object_class->dispose = cal_backend_object_sexp_dispose; -} - -static void -cal_backend_object_sexp_init (CalBackendObjectSExp *sexp) -{ - CalBackendObjectSExpPrivate *priv; - - priv = g_new0 (CalBackendObjectSExpPrivate, 1); - - sexp->priv = priv; - priv->search_context = g_new (SearchContext, 1); -} - -/** - * cal_backend_object_sexp_get_type: - */ -GType -cal_backend_object_sexp_get_type (void) -{ - static GType type = 0; - - if (! type) { - GTypeInfo info = { - sizeof (CalBackendObjectSExpClass), - NULL, /* base_class_init */ - NULL, /* base_class_finalize */ - (GClassInitFunc) cal_backend_object_sexp_class_init, - NULL, /* class_finalize */ - NULL, /* class_data */ - sizeof (CalBackendObjectSExp), - 0, /* n_preallocs */ - (GInstanceInitFunc) cal_backend_object_sexp_init - }; - - type = g_type_register_static (G_TYPE_OBJECT, "CalBackendObjectSExp", &info, 0); - } - - return type; -} diff --git a/calendar/pcs/cal-backend-object-sexp.h b/calendar/pcs/cal-backend-object-sexp.h deleted file mode 100644 index dbac3b6abc..0000000000 --- a/calendar/pcs/cal-backend-object-sexp.h +++ /dev/null @@ -1,67 +0,0 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */ -/* - * cal-backend-card-sexp.h - * Copyright 2000, 2001, Ximian, Inc. - * - * Authors: - * Chris Lahey <clahey@ximian.com> - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Library General Public - * License, version 2, as published by the Free Software Foundation. - * - * This library 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 - * Library General Public License for more details. - * - * You should have received a copy of the GNU Library General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA - * 02111-1307, USA. - */ - -#ifndef __CAL_BACKEND_OBJECT_SEXP_H__ -#define __CAL_BACKEND_OBJECT_SEXP_H__ - -#include <glib.h> -#include <glib-object.h> -#include <pcs/cal-backend.h> -#include <cal-util/cal-component.h> - -G_BEGIN_DECLS - -#define CAL_TYPE_BACKEND_OBJECT_SEXP (cal_backend_object_sexp_get_type ()) -#define CAL_BACKEND_OBJECT_SEXP(o) (G_TYPE_CHECK_INSTANCE_CAST ((o), CAL_TYPE_BACKEND_OBJECT_SEXP, CalBackendObjectSExp)) -#define CAL_BACKEND_OBJECT_SEXP_CLASS(k) (G_TYPE_CHECK_CLASS_CAST((k), CAL_BACKEND_TYPE, CalBackendObjectSExpClass)) -#define CAL_IS_BACKEND_OBJECT_SEXP(o) (G_TYPE_CHECK_INSTANCE_TYPE ((o), CAL_TYPE_BACKEND_OBJECT_SEXP)) -#define CAL_IS_BACKEND_OBJECT_SEXP_CLASS(k) (G_TYPE_CHECK_CLASS_TYPE ((k), CAL_TYPE_BACKEND_OBJECT_SEXP)) -#define CAL_BACKEND_OBJECT_SEXP_GET_CLASS(k) (G_TYPE_INSTANCE_GET_CLASS ((obj), CAL_TYPE_BACKEND_OBJECT_SEXP, CALBackendObjectSExpClass)) - -typedef struct _CalBackendObjectSExpPrivate CalBackendObjectSExpPrivate; - -struct _CalBackendObjectSExp { - GObject parent_object; - - CalBackendObjectSExpPrivate *priv; -}; - -struct _CalBackendObjectSExpClass { - GObjectClass parent_class; -}; - -GType cal_backend_object_sexp_get_type (void); -CalBackendObjectSExp *cal_backend_object_sexp_new (const char *text); -const char *cal_backend_object_sexp_text (CalBackendObjectSExp *sexp); - - -gboolean cal_backend_object_sexp_match_object (CalBackendObjectSExp *sexp, - const char *object, - CalBackend *backend); -gboolean cal_backend_object_sexp_match_comp (CalBackendObjectSExp *sexp, - CalComponent *comp, - CalBackend *backend); - -G_END_DECLS - -#endif /* __CAL_BACKEND_OBJECT_SEXP_H__ */ diff --git a/calendar/pcs/cal-backend-sync.c b/calendar/pcs/cal-backend-sync.c deleted file mode 100644 index c385a89b72..0000000000 --- a/calendar/pcs/cal-backend-sync.c +++ /dev/null @@ -1,607 +0,0 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */ -/* - * Author: - * Chris Toshok (toshok@ximian.com) - * - * Copyright (C) 2003, Ximian, Inc. - */ - -#ifdef CONFIG_H -#include <config.h> -#endif - -#include "cal-backend-sync.h" - -struct _CalBackendSyncPrivate { - int mumble; -}; - -static GObjectClass *parent_class; - -G_LOCK_DEFINE_STATIC (cal_sync_mutex); -#define SYNC_LOCK() G_LOCK (cal_sync_mutex) -#define SYNC_UNLOCK() G_UNLOCK (cal_sync_mutex) - -CalBackendSyncStatus -cal_backend_sync_is_read_only (CalBackendSync *backend, Cal *cal, gboolean *read_only) -{ - g_return_val_if_fail (backend && CAL_IS_BACKEND_SYNC (backend), GNOME_Evolution_Calendar_OtherError); - g_return_val_if_fail (read_only, GNOME_Evolution_Calendar_OtherError); - - g_assert (CAL_BACKEND_SYNC_GET_CLASS (backend)->is_read_only_sync); - - return (* CAL_BACKEND_SYNC_GET_CLASS (backend)->is_read_only_sync) (backend, cal, read_only); -} - -CalBackendSyncStatus -cal_backend_sync_get_cal_address (CalBackendSync *backend, Cal *cal, char **address) -{ - g_return_val_if_fail (backend && CAL_IS_BACKEND_SYNC (backend), GNOME_Evolution_Calendar_OtherError); - g_return_val_if_fail (address, GNOME_Evolution_Calendar_OtherError); - - g_assert (CAL_BACKEND_SYNC_GET_CLASS (backend)->get_cal_address_sync); - - return (* CAL_BACKEND_SYNC_GET_CLASS (backend)->get_cal_address_sync) (backend, cal, address); -} - -CalBackendSyncStatus -cal_backend_sync_get_alarm_email_address (CalBackendSync *backend, Cal *cal, char **address) -{ - g_return_val_if_fail (backend && CAL_IS_BACKEND_SYNC (backend), GNOME_Evolution_Calendar_OtherError); - g_return_val_if_fail (address, GNOME_Evolution_Calendar_OtherError); - - g_assert (CAL_BACKEND_SYNC_GET_CLASS (backend)->get_alarm_email_address_sync); - - return (* CAL_BACKEND_SYNC_GET_CLASS (backend)->get_alarm_email_address_sync) (backend, cal, address); -} - -CalBackendSyncStatus -cal_backend_sync_get_ldap_attribute (CalBackendSync *backend, Cal *cal, char **attribute) -{ - g_return_val_if_fail (backend && CAL_IS_BACKEND_SYNC (backend), GNOME_Evolution_Calendar_OtherError); - g_return_val_if_fail (attribute, GNOME_Evolution_Calendar_OtherError); - - g_assert (CAL_BACKEND_SYNC_GET_CLASS (backend)->get_ldap_attribute_sync); - - return (* CAL_BACKEND_SYNC_GET_CLASS (backend)->get_ldap_attribute_sync) (backend, cal, attribute); -} - -CalBackendSyncStatus -cal_backend_sync_get_static_capabilities (CalBackendSync *backend, Cal *cal, char **capabilities) -{ - g_return_val_if_fail (backend && CAL_IS_BACKEND_SYNC (backend), GNOME_Evolution_Calendar_OtherError); - g_return_val_if_fail (capabilities, GNOME_Evolution_Calendar_OtherError); - - g_assert (CAL_BACKEND_SYNC_GET_CLASS (backend)->get_static_capabilities_sync); - - return (* CAL_BACKEND_SYNC_GET_CLASS (backend)->get_static_capabilities_sync) (backend, cal, capabilities); -} - -CalBackendSyncStatus -cal_backend_sync_open (CalBackendSync *backend, Cal *cal, gboolean only_if_exists) -{ - CalBackendSyncStatus status; - - g_return_val_if_fail (backend && CAL_IS_BACKEND_SYNC (backend), GNOME_Evolution_Calendar_OtherError); - - g_assert (CAL_BACKEND_SYNC_GET_CLASS (backend)->open_sync); - - SYNC_LOCK (); - - status = (* CAL_BACKEND_SYNC_GET_CLASS (backend)->open_sync) (backend, cal, only_if_exists); - - SYNC_UNLOCK (); - - return status; -} - -CalBackendSyncStatus -cal_backend_sync_remove (CalBackendSync *backend, Cal *cal) -{ - g_return_val_if_fail (backend && CAL_IS_BACKEND_SYNC (backend), GNOME_Evolution_Calendar_OtherError); - - g_assert (CAL_BACKEND_SYNC_GET_CLASS (backend)->remove_sync); - - return (* CAL_BACKEND_SYNC_GET_CLASS (backend)->remove_sync) (backend, cal); -} - -CalBackendSyncStatus -cal_backend_sync_create_object (CalBackendSync *backend, Cal *cal, const char *calobj, char **uid) -{ - g_return_val_if_fail (backend && CAL_IS_BACKEND_SYNC (backend), GNOME_Evolution_Calendar_OtherError); - - g_assert (CAL_BACKEND_SYNC_GET_CLASS (backend)->create_object_sync); - - return (* CAL_BACKEND_SYNC_GET_CLASS (backend)->create_object_sync) (backend, cal, calobj, uid); -} - -CalBackendSyncStatus -cal_backend_sync_modify_object (CalBackendSync *backend, Cal *cal, const char *calobj, - CalObjModType mod, char **old_object) -{ - g_return_val_if_fail (backend && CAL_IS_BACKEND_SYNC (backend), GNOME_Evolution_Calendar_OtherError); - - g_assert (CAL_BACKEND_SYNC_GET_CLASS (backend)->modify_object_sync); - - return (* CAL_BACKEND_SYNC_GET_CLASS (backend)->modify_object_sync) (backend, cal, - calobj, mod, old_object); -} - -CalBackendSyncStatus -cal_backend_sync_remove_object (CalBackendSync *backend, Cal *cal, const char *uid, const char *rid, - CalObjModType mod, char **object) -{ - g_return_val_if_fail (backend && CAL_IS_BACKEND_SYNC (backend), GNOME_Evolution_Calendar_OtherError); - - g_assert (CAL_BACKEND_SYNC_GET_CLASS (backend)->remove_object_sync); - - return (* CAL_BACKEND_SYNC_GET_CLASS (backend)->remove_object_sync) (backend, cal, uid, rid, mod, object); -} - -CalBackendSyncStatus -cal_backend_sync_discard_alarm (CalBackendSync *backend, Cal *cal, const char *uid, const char *auid) -{ - g_return_val_if_fail (backend && CAL_IS_BACKEND_SYNC (backend), GNOME_Evolution_Calendar_OtherError); - - g_assert (CAL_BACKEND_SYNC_GET_CLASS (backend)->discard_alarm_sync); - - return (* CAL_BACKEND_SYNC_GET_CLASS (backend)->discard_alarm_sync) (backend, cal, uid, auid); -} - -CalBackendSyncStatus -cal_backend_sync_receive_objects (CalBackendSync *backend, Cal *cal, const char *calobj) -{ - g_return_val_if_fail (backend && CAL_IS_BACKEND_SYNC (backend), GNOME_Evolution_Calendar_OtherError); - - g_assert (CAL_BACKEND_SYNC_GET_CLASS (backend)->receive_objects_sync); - - return (* CAL_BACKEND_SYNC_GET_CLASS (backend)->receive_objects_sync) (backend, cal, calobj); -} - -CalBackendSyncStatus -cal_backend_sync_send_objects (CalBackendSync *backend, Cal *cal, const char *calobj) -{ - g_return_val_if_fail (backend && CAL_IS_BACKEND_SYNC (backend), GNOME_Evolution_Calendar_OtherError); - - g_assert (CAL_BACKEND_SYNC_GET_CLASS (backend)->send_objects_sync); - - return (* CAL_BACKEND_SYNC_GET_CLASS (backend)->send_objects_sync) (backend, cal, calobj); -} - -CalBackendSyncStatus -cal_backend_sync_get_default_object (CalBackendSync *backend, Cal *cal, char **object) -{ - g_return_val_if_fail (backend && CAL_IS_BACKEND_SYNC (backend), GNOME_Evolution_Calendar_OtherError); - g_return_val_if_fail (object, GNOME_Evolution_Calendar_OtherError); - - g_assert (CAL_BACKEND_SYNC_GET_CLASS (backend)->get_default_object_sync); - - return (* CAL_BACKEND_SYNC_GET_CLASS (backend)->get_default_object_sync) (backend, cal, object); -} - -CalBackendSyncStatus -cal_backend_sync_get_object (CalBackendSync *backend, Cal *cal, const char *uid, const char *rid, char **object) -{ - g_return_val_if_fail (backend && CAL_IS_BACKEND_SYNC (backend), GNOME_Evolution_Calendar_OtherError); - g_return_val_if_fail (object, GNOME_Evolution_Calendar_OtherError); - - g_assert (CAL_BACKEND_SYNC_GET_CLASS (backend)->get_object_sync); - - return (* CAL_BACKEND_SYNC_GET_CLASS (backend)->get_object_sync) (backend, cal, uid, rid, object); -} - -CalBackendSyncStatus -cal_backend_sync_get_object_list (CalBackendSync *backend, Cal *cal, const char *sexp, GList **objects) -{ - g_return_val_if_fail (backend && CAL_IS_BACKEND_SYNC (backend), GNOME_Evolution_Calendar_OtherError); - g_return_val_if_fail (objects, GNOME_Evolution_Calendar_OtherError); - - g_assert (CAL_BACKEND_SYNC_GET_CLASS (backend)->get_object_list_sync); - - return (* CAL_BACKEND_SYNC_GET_CLASS (backend)->get_object_list_sync) (backend, cal, sexp, objects); -} - -CalBackendSyncStatus -cal_backend_sync_get_timezone (CalBackendSync *backend, Cal *cal, const char *tzid, char **object) -{ - g_return_val_if_fail (CAL_IS_BACKEND_SYNC (backend), GNOME_Evolution_Calendar_OtherError); - - g_assert (CAL_BACKEND_SYNC_GET_CLASS (backend)->get_timezone_sync != NULL); - - return (* CAL_BACKEND_SYNC_GET_CLASS (backend)->get_timezone_sync) (backend, cal, tzid, object); -} - -CalBackendSyncStatus -cal_backend_sync_add_timezone (CalBackendSync *backend, Cal *cal, const char *tzobj) -{ - g_return_val_if_fail (CAL_IS_BACKEND_SYNC (backend), GNOME_Evolution_Calendar_OtherError); - - g_assert (CAL_BACKEND_SYNC_GET_CLASS (backend)->add_timezone_sync != NULL); - - return (* CAL_BACKEND_SYNC_GET_CLASS (backend)->add_timezone_sync) (backend, cal, tzobj); -} - -CalBackendSyncStatus -cal_backend_sync_set_default_timezone (CalBackendSync *backend, Cal *cal, const char *tzid) -{ - g_return_val_if_fail (CAL_IS_BACKEND_SYNC (backend), GNOME_Evolution_Calendar_OtherError); - - g_assert (CAL_BACKEND_SYNC_GET_CLASS (backend)->set_default_timezone_sync != NULL); - - return (* CAL_BACKEND_SYNC_GET_CLASS (backend)->set_default_timezone_sync) (backend, cal, tzid); -} - - -CalBackendSyncStatus -cal_backend_sync_get_changes (CalBackendSync *backend, Cal *cal, const char *change_id, - GList **adds, GList **modifies, GList **deletes) -{ - g_return_val_if_fail (CAL_IS_BACKEND_SYNC (backend), GNOME_Evolution_Calendar_OtherError); - - g_assert (CAL_BACKEND_SYNC_GET_CLASS (backend)->get_changes_sync != NULL); - - return (* CAL_BACKEND_SYNC_GET_CLASS (backend)->get_changes_sync) (backend, cal, change_id, - adds, modifies, deletes); -} - -CalBackendSyncStatus -cal_backend_sync_get_free_busy (CalBackendSync *backend, Cal *cal, GList *users, - time_t start, time_t end, GList **freebusy) -{ - g_return_val_if_fail (CAL_IS_BACKEND_SYNC (backend), GNOME_Evolution_Calendar_OtherError); - - g_assert (CAL_BACKEND_SYNC_GET_CLASS (backend)->get_freebusy_sync != NULL); - - return (* CAL_BACKEND_SYNC_GET_CLASS (backend)->get_freebusy_sync) (backend, cal, users, - start, end, freebusy); -} - - -static void -_cal_backend_is_read_only (CalBackend *backend, Cal *cal) -{ - CalBackendSyncStatus status; - gboolean read_only = TRUE; - - status = cal_backend_sync_is_read_only (CAL_BACKEND_SYNC (backend), cal, &read_only); - - cal_notify_read_only (cal, status, read_only); -} - -static void -_cal_backend_get_cal_address (CalBackend *backend, Cal *cal) -{ - CalBackendSyncStatus status; - char *address = NULL; - - status = cal_backend_sync_get_cal_address (CAL_BACKEND_SYNC (backend), cal, &address); - - cal_notify_cal_address (cal, status, address); - - g_free (address); -} - -static void -_cal_backend_get_alarm_email_address (CalBackend *backend, Cal *cal) -{ - CalBackendSyncStatus status; - char *address = NULL; - - status = cal_backend_sync_get_cal_address (CAL_BACKEND_SYNC (backend), cal, &address); - - cal_notify_alarm_email_address (cal, status, address); - - g_free (address); -} - -static void -_cal_backend_get_ldap_attribute (CalBackend *backend, Cal *cal) -{ - CalBackendSyncStatus status; - char *attribute = NULL; - - status = cal_backend_sync_get_cal_address (CAL_BACKEND_SYNC (backend), cal, &attribute); - - cal_notify_ldap_attribute (cal, status, attribute); - - g_free (attribute); -} - -static void -_cal_backend_get_static_capabilities (CalBackend *backend, Cal *cal) -{ - CalBackendSyncStatus status; - char *capabilities = NULL; - - status = cal_backend_sync_get_cal_address (CAL_BACKEND_SYNC (backend), cal, &capabilities); - - cal_notify_static_capabilities (cal, status, capabilities); - - g_free (capabilities); -} - -static void -_cal_backend_open (CalBackend *backend, Cal *cal, gboolean only_if_exists) -{ - CalBackendSyncStatus status; - - status = cal_backend_sync_open (CAL_BACKEND_SYNC (backend), cal, only_if_exists); - - cal_notify_open (cal, status); -} - -static void -_cal_backend_remove (CalBackend *backend, Cal *cal) -{ - CalBackendSyncStatus status; - - status = cal_backend_sync_remove (CAL_BACKEND_SYNC (backend), cal); - - cal_notify_remove (cal, status); -} - -static void -_cal_backend_create_object (CalBackend *backend, Cal *cal, const char *calobj) -{ - CalBackendSyncStatus status; - char *uid = NULL; - - status = cal_backend_sync_create_object (CAL_BACKEND_SYNC (backend), cal, calobj, &uid); - - cal_notify_object_created (cal, status, uid, calobj); - - if (uid) - g_free (uid); -} - -static void -_cal_backend_modify_object (CalBackend *backend, Cal *cal, const char *calobj, CalObjModType mod) -{ - CalBackendSyncStatus status; - char *old_object = NULL; - - status = cal_backend_sync_modify_object (CAL_BACKEND_SYNC (backend), cal, - calobj, mod, &old_object); - - cal_notify_object_modified (cal, status, old_object, calobj); -} - -static void -_cal_backend_remove_object (CalBackend *backend, Cal *cal, const char *uid, const char *rid, CalObjModType mod) -{ - CalBackendSyncStatus status; - char *object = NULL; - - status = cal_backend_sync_remove_object (CAL_BACKEND_SYNC (backend), cal, uid, rid, mod, &object); - - cal_notify_object_removed (cal, status, uid, object); -} - -static void -_cal_backend_discard_alarm (CalBackend *backend, Cal *cal, const char *uid, const char *auid) -{ - CalBackendSyncStatus status; - - status = cal_backend_sync_discard_alarm (CAL_BACKEND_SYNC (backend), cal, uid, auid); - - cal_notify_alarm_discarded (cal, status); -} - -static void -_cal_backend_receive_objects (CalBackend *backend, Cal *cal, const char *calobj) -{ - CalBackendSyncStatus status; - - status = cal_backend_sync_receive_objects (CAL_BACKEND_SYNC (backend), cal, calobj); - - cal_notify_objects_received (cal, status); -} - -static void -_cal_backend_send_objects (CalBackend *backend, Cal *cal, const char *calobj) -{ - CalBackendSyncStatus status; - - status = cal_backend_sync_send_objects (CAL_BACKEND_SYNC (backend), cal, calobj); - - cal_notify_objects_sent (cal, status); -} - -static void -_cal_backend_get_default_object (CalBackend *backend, Cal *cal) -{ - CalBackendSyncStatus status; - char *object = NULL; - - status = cal_backend_sync_get_default_object (CAL_BACKEND_SYNC (backend), cal, &object); - - cal_notify_default_object (cal, status, object); - - g_free (object); -} - -static void -_cal_backend_get_object (CalBackend *backend, Cal *cal, const char *uid, const char *rid) -{ - CalBackendSyncStatus status; - char *object = NULL; - - status = cal_backend_sync_get_object (CAL_BACKEND_SYNC (backend), cal, uid, rid, &object); - - cal_notify_object (cal, status, object); - - g_free (object); -} - -static void -_cal_backend_get_object_list (CalBackend *backend, Cal *cal, const char *sexp) -{ - CalBackendSyncStatus status; - GList *objects = NULL, *l; - - status = cal_backend_sync_get_object_list (CAL_BACKEND_SYNC (backend), cal, sexp, &objects); - - cal_notify_object_list (cal, status, objects); - - for (l = objects; l; l = l->next) - g_free (l->data); - g_list_free (objects); -} - -static void -_cal_backend_get_timezone (CalBackend *backend, Cal *cal, const char *tzid) -{ - CalBackendSyncStatus status; - char *object = NULL; - - status = cal_backend_sync_get_timezone (CAL_BACKEND_SYNC (backend), cal, tzid, &object); - - cal_notify_timezone_requested (cal, status, object); -} - -static void -_cal_backend_add_timezone (CalBackend *backend, Cal *cal, const char *tzobj) -{ - CalBackendSyncStatus status; - - status = cal_backend_sync_add_timezone (CAL_BACKEND_SYNC (backend), cal, tzobj); - - cal_notify_timezone_added (cal, status, tzobj); -} - -static void -_cal_backend_set_default_timezone (CalBackend *backend, Cal *cal, const char *tzid) -{ - CalBackendSyncStatus status; - - status = cal_backend_sync_set_default_timezone (CAL_BACKEND_SYNC (backend), cal, tzid); - - cal_notify_default_timezone_set (cal, status); -} - -static void -_cal_backend_get_changes (CalBackend *backend, Cal *cal, const char *change_id) -{ - CalBackendSyncStatus status; - GList *adds = NULL, *modifies = NULL, *deletes = NULL, *l; - - status = cal_backend_sync_get_changes (CAL_BACKEND_SYNC (backend), cal, change_id, - &adds, &modifies, &deletes); - - cal_notify_changes (cal, status, adds, modifies, deletes); - - for (l = adds; l; l = l->next) - g_free (l->data); - g_list_free (adds); - - for (l = modifies; l; l = l->next) - g_free (l->data); - g_list_free (modifies); - - for (l = deletes; l; l = l->next) - g_free (l->data); - g_list_free (deletes); -} - -static void -_cal_backend_get_free_busy (CalBackend *backend, Cal *cal, GList *users, time_t start, time_t end) -{ - CalBackendSyncStatus status; - GList *freebusy = NULL, *l; - - status = cal_backend_sync_get_free_busy (CAL_BACKEND_SYNC (backend), cal, users, start, end, &freebusy); - - cal_notify_free_busy (cal, status, freebusy); - - for (l = freebusy; l; l = l->next) - g_free (l->data); - g_list_free (freebusy); -} - -static void -cal_backend_sync_init (CalBackendSync *backend) -{ - CalBackendSyncPrivate *priv; - - priv = g_new0 (CalBackendSyncPrivate, 1); - - backend->priv = priv; -} - -static void -cal_backend_sync_dispose (GObject *object) -{ - CalBackendSync *backend; - - backend = CAL_BACKEND_SYNC (object); - - if (backend->priv) { - g_free (backend->priv); - - backend->priv = NULL; - } - - G_OBJECT_CLASS (parent_class)->dispose (object); -} - -static void -cal_backend_sync_class_init (CalBackendSyncClass *klass) -{ - GObjectClass *object_class; - CalBackendClass *backend_class = CAL_BACKEND_CLASS (klass); - - parent_class = g_type_class_peek_parent (klass); - - object_class = (GObjectClass *) klass; - - backend_class->is_read_only = _cal_backend_is_read_only; - backend_class->get_cal_address = _cal_backend_get_cal_address; - backend_class->get_alarm_email_address = _cal_backend_get_alarm_email_address; - backend_class->get_ldap_attribute = _cal_backend_get_ldap_attribute; - backend_class->get_static_capabilities = _cal_backend_get_static_capabilities; - backend_class->open = _cal_backend_open; - backend_class->remove = _cal_backend_remove; - backend_class->create_object = _cal_backend_create_object; - backend_class->modify_object = _cal_backend_modify_object; - backend_class->remove_object = _cal_backend_remove_object; - backend_class->discard_alarm = _cal_backend_discard_alarm; - backend_class->receive_objects = _cal_backend_receive_objects; - backend_class->send_objects = _cal_backend_send_objects; - backend_class->get_default_object = _cal_backend_get_default_object; - backend_class->get_object = _cal_backend_get_object; - backend_class->get_object_list = _cal_backend_get_object_list; - backend_class->get_timezone = _cal_backend_get_timezone; - backend_class->add_timezone = _cal_backend_add_timezone; - backend_class->set_default_timezone = _cal_backend_set_default_timezone; - backend_class->get_changes = _cal_backend_get_changes; - backend_class->get_free_busy = _cal_backend_get_free_busy; - - object_class->dispose = cal_backend_sync_dispose; -} - -/** - * cal_backend_get_type: - */ -GType -cal_backend_sync_get_type (void) -{ - static GType type = 0; - - if (! type) { - GTypeInfo info = { - sizeof (CalBackendSyncClass), - NULL, /* base_class_init */ - NULL, /* base_class_finalize */ - (GClassInitFunc) cal_backend_sync_class_init, - NULL, /* class_finalize */ - NULL, /* class_data */ - sizeof (CalBackendSync), - 0, /* n_preallocs */ - (GInstanceInitFunc) cal_backend_sync_init - }; - - type = g_type_register_static (CAL_BACKEND_TYPE, "CalBackendSync", &info, 0); - } - - return type; -} diff --git a/calendar/pcs/cal-backend-sync.h b/calendar/pcs/cal-backend-sync.h deleted file mode 100644 index 2953ac2afa..0000000000 --- a/calendar/pcs/cal-backend-sync.h +++ /dev/null @@ -1,143 +0,0 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */ -/* - */ - -#ifndef __Cal_BACKEND_SYNC_H__ -#define __Cal_BACKEND_SYNC_H__ - -#include <glib.h> -#include <pcs/cal-backend.h> -#include <pcs/evolution-calendar.h> - -G_BEGIN_DECLS - -#define CAL_TYPE_BACKEND_SYNC (cal_backend_sync_get_type ()) -#define CAL_BACKEND_SYNC(o) (G_TYPE_CHECK_INSTANCE_CAST ((o), CAL_TYPE_BACKEND_SYNC, CalBackendSync)) -#define CAL_BACKEND_SYNC_CLASS(k) (G_TYPE_CHECK_CLASS_CAST((k), CAL_TYPE_BACKEND_SYNC, CalBackendSyncClass)) -#define CAL_IS_BACKEND_SYNC(o) (G_TYPE_CHECK_INSTANCE_TYPE ((o), CAL_TYPE_BACKEND_SYNC)) -#define CAL_IS_BACKEND_SYNC_CLASS(k) (G_TYPE_CHECK_CLASS_TYPE ((k), CAL_TYPE_BACKEND_SYNC)) -#define CAL_BACKEND_SYNC_GET_CLASS(k) (G_TYPE_INSTANCE_GET_CLASS ((k), CAL_TYPE_BACKEND_SYNC, CalBackendSyncClass)) -typedef struct _CalBackendSync CalBackendSync; -typedef struct _CalBackendSyncClass CalBackendSyncClass; -typedef struct _CalBackendSyncPrivate CalBackendSyncPrivate; - -typedef GNOME_Evolution_Calendar_CallStatus CalBackendSyncStatus; - -struct _CalBackendSync { - CalBackend parent_object; - - CalBackendSyncPrivate *priv; -}; - -struct _CalBackendSyncClass { - CalBackendClass parent_class; - - /* Virtual methods */ - CalBackendSyncStatus (*is_read_only_sync) (CalBackendSync *backend, Cal *cal, gboolean *read_only); - CalBackendSyncStatus (*get_cal_address_sync) (CalBackendSync *backend, Cal *cal, char **address); - CalBackendSyncStatus (*get_alarm_email_address_sync) (CalBackendSync *backend, Cal *cal, char **address); - CalBackendSyncStatus (*get_ldap_attribute_sync) (CalBackendSync *backend, Cal *cal, char **attribute); - CalBackendSyncStatus (*get_static_capabilities_sync) (CalBackendSync *backend, Cal *cal, char **capabilities); - - CalBackendSyncStatus (*open_sync) (CalBackendSync *backend, Cal *cal, gboolean only_if_exists); - CalBackendSyncStatus (*remove_sync) (CalBackendSync *backend, Cal *cal); - - CalBackendSyncStatus (*create_object_sync) (CalBackendSync *backend, Cal *cal, const char *calobj, char **uid); - CalBackendSyncStatus (*modify_object_sync) (CalBackendSync *backend, Cal *cal, const char *calobj, CalObjModType mod, char **old_object); - CalBackendSyncStatus (*remove_object_sync) (CalBackendSync *backend, Cal *cal, const char *uid, const char *rid, CalObjModType mod, char **object); - - CalBackendSyncStatus (*discard_alarm_sync) (CalBackendSync *backend, Cal *cal, const char *uid, const char *auid); - - CalBackendSyncStatus (*receive_objects_sync) (CalBackendSync *backend, Cal *cal, const char *calobj); - CalBackendSyncStatus (*send_objects_sync) (CalBackendSync *backend, Cal *cal, const char *calobj); - - CalBackendSyncStatus (*get_default_object_sync) (CalBackendSync *backend, Cal *cal, char **object); - CalBackendSyncStatus (*get_object_sync) (CalBackendSync *backend, Cal *cal, const char *uid, const char *rid, char **object); - CalBackendSyncStatus (*get_object_list_sync) (CalBackendSync *backend, Cal *cal, const char *sexp, GList **objects); - - CalBackendSyncStatus (*get_timezone_sync) (CalBackendSync *backend, Cal *cal, const char *tzid, char **object); - CalBackendSyncStatus (*add_timezone_sync) (CalBackendSync *backend, Cal *cal, const char *tzobj); - CalBackendSyncStatus (*set_default_timezone_sync) (CalBackendSync *backend, Cal *cal, const char *tzid); - - CalBackendSyncStatus (*get_changes_sync) (CalBackendSync *backend, Cal *cal, const char *change_id, GList **adds, GList **modifies, GList **deletes); - CalBackendSyncStatus (*get_freebusy_sync) (CalBackendSync *backend, Cal *cal, GList *users, time_t start, time_t end, GList **freebusy); - - /* Padding for future expansion */ - void (*_cal_reserved0) (void); - void (*_cal_reserved1) (void); - void (*_cal_reserved2) (void); - void (*_cal_reserved3) (void); - void (*_cal_reserved4) (void); - -}; - -typedef CalBackendSync * (*CalBackendSyncFactoryFn) (void); -GType cal_backend_sync_get_type (void); -CalBackendSyncStatus cal_backend_sync_is_read_only (CalBackendSync *backend, - Cal *cal, - gboolean *read_only); -CalBackendSyncStatus cal_backend_sync_get_cal_address (CalBackendSync *backend, - Cal *cal, - char **address); -CalBackendSyncStatus cal_backend_sync_get_alarm_email_address (CalBackendSync *backend, - Cal *cal, - char **address); -CalBackendSyncStatus cal_backend_sync_get_ldap_attribute (CalBackendSync *backend, - Cal *cal, - char **attribute); -CalBackendSyncStatus cal_backend_sync_get_static_capabilities (CalBackendSync *backend, - Cal *cal, - char **capabiliites); -CalBackendSyncStatus cal_backend_sync_open (CalBackendSync *backend, - Cal *cal, - gboolean only_if_exists); -CalBackendSyncStatus cal_backend_sync_remove (CalBackendSync *backend, - Cal *cal); -CalBackendSyncStatus cal_backend_sync_create_object (CalBackendSync *backend, - Cal *cal, - const char *calobj, - char **uid); -CalBackendSyncStatus cal_backend_sync_modify_object (CalBackendSync *backend, - Cal *cal, - const char *calobj, - CalObjModType mod, - char **old_object); -CalBackendSyncStatus cal_backend_sync_remove_object (CalBackendSync *backend, - Cal *cal, - const char *uid, - const char *rid, - CalObjModType mod, - char **object); -CalBackendSyncStatus cal_backend_sync_discard_alarm (CalBackendSync *backend, Cal *cal, const char *uid, const char *auid); - -CalBackendSyncStatus cal_backend_sync_receive_objects (CalBackendSync *backend, - Cal *cal, - const char *calobj); -CalBackendSyncStatus cal_backend_sync_send_objects (CalBackendSync *backend, - Cal *cal, - const char *calobj); -CalBackendSyncStatus cal_backend_sync_get_default_object (CalBackendSync *backend, - Cal *cal, - char **object); - -CalBackendSyncStatus cal_backend_sync_get_object (CalBackendSync *backend, - Cal *cal, - const char *uid, - const char *rid, - char **object); - -CalBackendSyncStatus cal_backend_sync_get_object_list (CalBackendSync *backend, - Cal *cal, - const char *sexp, - GList **objects); - -CalBackendSyncStatus cal_backend_sync_get_timezone (CalBackendSync *backend, Cal *cal, const char *tzid, char **object); -CalBackendSyncStatus cal_backend_sync_add_timezone (CalBackendSync *backend, Cal *cal, const char *tzobj); -CalBackendSyncStatus cal_backend_sync_set_default_timezone (CalBackendSync *backend, Cal *cal, const char *tzid); - -CalBackendSyncStatus cal_backend_sync_get_changes (CalBackendSync *backend, Cal *cal, const char *change_id, GList **adds, GList **modifies, GList **deletes); -CalBackendSyncStatus cal_backend_sync_get_free_busy (CalBackendSync *backend, Cal *cal, GList *users, time_t start, time_t end, GList **freebusy); - -G_END_DECLS - -#endif /* ! __CAL_BACKEND_SYNC_H__ */ diff --git a/calendar/pcs/cal-backend-util.c b/calendar/pcs/cal-backend-util.c deleted file mode 100644 index 86bf761878..0000000000 --- a/calendar/pcs/cal-backend-util.c +++ /dev/null @@ -1,61 +0,0 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */ -/* Evolution calendar - generic backend class - * - * Copyright (C) 2000 Ximian, Inc. - * Copyright (C) 2001 Ximian, Inc. - * - * Authors: Rodrigo Moya <rodrigo@ximian.com> - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of version 2 of the GNU General Public - * License as published by the Free Software Foundation. - * - * 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA. - */ - -#include <string.h> -#include "cal-backend-util.h" -#include <e-util/e-account-list.h> - -static EAccountList *accounts; - -gboolean -cal_backend_mail_account_get_default (EConfigListener *db, - char **address, - char **name) -{ - const EAccount *account; - - if (accounts == NULL) - accounts = e_account_list_new(gconf_client_get_default()); - - account = e_account_list_get_default(accounts); - if (account) { - *address = g_strdup(account->id->address); - *name = g_strdup(account->id->name); - } - - return account != NULL; -} - -gboolean -cal_backend_mail_account_is_valid (EConfigListener *db, char *user, char **name) -{ - const EAccount *account; - - if (accounts == NULL) - accounts = e_account_list_new(gconf_client_get_default()); - - account = e_account_list_find(accounts, E_ACCOUNT_FIND_ID_ADDRESS, user); - if (account) - *name = g_strdup(account->id->name); - - return account != NULL; -} diff --git a/calendar/pcs/cal-backend-util.h b/calendar/pcs/cal-backend-util.h deleted file mode 100644 index 228179b8c7..0000000000 --- a/calendar/pcs/cal-backend-util.h +++ /dev/null @@ -1,42 +0,0 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */ -/* Evolution calendar - generic backend class - * - * Copyright (C) 2000 Ximian, Inc. - * Copyright (C) 2001 Ximian, Inc. - * - * Authors: Rodrigo Moya <rodrigo@ximian.com> - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of version 2 of the GNU General Public - * License as published by the Free Software Foundation. - * - * 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA. - */ - -#ifndef CAL_BACKEND_UTIL_H -#define CAL_BACKEND_UTIL_H - -#include <e-util/e-config-listener.h> -#include <pcs/cal-backend.h> - -G_BEGIN_DECLS - -/* - * Functions for accessing mail configuration - */ - -gboolean cal_backend_mail_account_get_default (EConfigListener *db, - char **address, char **name); -gboolean cal_backend_mail_account_is_valid (EConfigListener *db, - char *user, char **name); - -G_END_DECLS - -#endif diff --git a/calendar/pcs/cal-backend.c b/calendar/pcs/cal-backend.c deleted file mode 100644 index df2f7408e4..0000000000 --- a/calendar/pcs/cal-backend.c +++ /dev/null @@ -1,1199 +0,0 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */ -/* Evolution calendar - generic backend class - * - * Copyright (C) 2000 Ximian, Inc. - * Copyright (C) 2000 Ximian, Inc. - * - * Authors: Federico Mena-Quintero <federico@ximian.com> - * JP Rosevear <jpr@ximian.com> - * Rodrigo Moya <rodrigo@ximian.com> - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of version 2 of the GNU General Public - * License as published by the Free Software Foundation. - * - * 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA. - */ - -#include <config.h> -#include <libxml/parser.h> -#include <libxml/parserInternals.h> -#include <libxml/xmlmemory.h> - -#include "cal-backend.h" -#include "libversit/vcc.h" - - - -/* A category that exists in some of the objects of the calendar */ -typedef struct { - /* Category name, also used as the key in the categories hash table */ - char *name; - - /* Number of objects that have this category */ - int refcount; -} CalBackendCategory; - -/* Private part of the CalBackend structure */ -struct _CalBackendPrivate { - /* The uri for this backend */ - char *uri; - - /* The kind of components for this backend */ - icalcomponent_kind kind; - - /* List of Cal objects */ - GMutex *clients_mutex; - GList *clients; - - GMutex *queries_mutex; - EList *queries; - - /* Hash table of live categories, temporary hash of - * added/removed categories, and idle handler for sending - * category_changed. - */ - GHashTable *categories; - GHashTable *changed_categories; - guint category_idle_id; -}; - -/* Property IDs */ -enum props { - PROP_0, - PROP_URI, - PROP_KIND -}; - -/* Signal IDs */ -enum { - LAST_CLIENT_GONE, - OPENED, - REMOVED, - LAST_SIGNAL -}; -static guint cal_backend_signals[LAST_SIGNAL]; - -static void cal_backend_class_init (CalBackendClass *class); -static void cal_backend_init (CalBackend *backend); -static void cal_backend_finalize (GObject *object); - -static void notify_categories_changed (CalBackend *backend); - -#define CLASS(backend) (CAL_BACKEND_CLASS (G_OBJECT_GET_CLASS (backend))) - -static GObjectClass *parent_class; - - - -/** - * cal_backend_get_type: - * @void: - * - * Registers the #CalBackend class if necessary, and returns the type ID - * associated to it. - * - * Return value: The type ID of the #CalBackend class. - **/ -GType -cal_backend_get_type (void) -{ - static GType cal_backend_type = 0; - - if (!cal_backend_type) { - static GTypeInfo info = { - sizeof (CalBackendClass), - (GBaseInitFunc) NULL, - (GBaseFinalizeFunc) NULL, - (GClassInitFunc) cal_backend_class_init, - NULL, NULL, - sizeof (CalBackend), - 0, - (GInstanceInitFunc) cal_backend_init, - }; - cal_backend_type = g_type_register_static (G_TYPE_OBJECT, "CalBackend", &info, 0); - } - - return cal_backend_type; -} - -static void -cal_backend_set_property (GObject *object, guint property_id, const GValue *value, GParamSpec *pspec) -{ - CalBackend *backend; - CalBackendPrivate *priv; - - backend = CAL_BACKEND (object); - priv = backend->priv; - - switch (property_id) { - case PROP_URI: - g_free (priv->uri); - priv->uri = g_value_dup_string (value); - break; - case PROP_KIND: - priv->kind = g_value_get_ulong (value); - break; - default: - G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec); - break; - } -} - -static void -cal_backend_get_property (GObject *object, guint property_id, GValue *value, GParamSpec *pspec) -{ - CalBackend *backend; - CalBackendPrivate *priv; - - backend = CAL_BACKEND (object); - priv = backend->priv; - - switch (property_id) { - case PROP_URI: - g_value_set_string (value, cal_backend_get_uri (backend)); - break; - case PROP_KIND: - g_value_set_ulong (value, cal_backend_get_kind (backend)); - break; - default: - G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec); - break; - } -} - -/* Class initialization function for the calendar backend */ -static void -cal_backend_class_init (CalBackendClass *class) -{ - GObjectClass *object_class; - - parent_class = (GObjectClass *) g_type_class_peek_parent (class); - - object_class = (GObjectClass *) class; - - object_class->set_property = cal_backend_set_property; - object_class->get_property = cal_backend_get_property; - object_class->finalize = cal_backend_finalize; - - g_object_class_install_property (object_class, PROP_URI, - g_param_spec_string ("uri", NULL, NULL, "", - G_PARAM_READABLE | G_PARAM_WRITABLE - | G_PARAM_CONSTRUCT_ONLY)); - - g_object_class_install_property (object_class, PROP_KIND, - g_param_spec_ulong ("kind", NULL, NULL, - ICAL_NO_COMPONENT, ICAL_XLICMIMEPART_COMPONENT, - ICAL_NO_COMPONENT, - G_PARAM_READABLE | G_PARAM_WRITABLE - | G_PARAM_CONSTRUCT_ONLY)); - cal_backend_signals[LAST_CLIENT_GONE] = - g_signal_new ("last_client_gone", - G_TYPE_FROM_CLASS (class), - G_SIGNAL_RUN_FIRST, - G_STRUCT_OFFSET (CalBackendClass, last_client_gone), - NULL, NULL, - g_cclosure_marshal_VOID__VOID, - G_TYPE_NONE, 0); - cal_backend_signals[OPENED] = - g_signal_new ("opened", - G_TYPE_FROM_CLASS (class), - G_SIGNAL_RUN_FIRST, - G_STRUCT_OFFSET (CalBackendClass, opened), - NULL, NULL, - g_cclosure_marshal_VOID__ENUM, - G_TYPE_NONE, 1, - G_TYPE_INT); - cal_backend_signals[REMOVED] = - g_signal_new ("removed", - G_TYPE_FROM_CLASS (class), - G_SIGNAL_RUN_FIRST, - G_STRUCT_OFFSET (CalBackendClass, removed), - NULL, NULL, - g_cclosure_marshal_VOID__ENUM, - G_TYPE_NONE, 1, - G_TYPE_INT); - - class->last_client_gone = NULL; - class->opened = NULL; - class->obj_updated = NULL; - - class->get_cal_address = NULL; - class->get_alarm_email_address = NULL; - class->get_static_capabilities = NULL; - class->open = NULL; - class->is_loaded = NULL; - class->is_read_only = NULL; - class->start_query = NULL; - class->get_mode = NULL; - class->set_mode = NULL; - class->get_object = NULL; - class->get_default_object = NULL; - class->get_object_list = NULL; - class->get_free_busy = NULL; - class->get_changes = NULL; - class->discard_alarm = NULL; - class->create_object = NULL; - class->modify_object = NULL; - class->remove_object = NULL; - class->receive_objects = NULL; - class->send_objects = NULL; - class->get_timezone = NULL; - class->add_timezone = NULL; - class->set_default_timezone = NULL; -} - -/* Object initialization func for the calendar backend */ -void -cal_backend_init (CalBackend *backend) -{ - CalBackendPrivate *priv; - - priv = g_new0 (CalBackendPrivate, 1); - backend->priv = priv; - - priv->clients = NULL; - priv->clients_mutex = g_mutex_new (); - - /* FIXME bonobo_object_ref/unref? */ - priv->queries = e_list_new((EListCopyFunc) g_object_ref, (EListFreeFunc) g_object_unref, NULL); - priv->queries_mutex = g_mutex_new (); - - priv->categories = g_hash_table_new (g_str_hash, g_str_equal); - priv->changed_categories = g_hash_table_new (g_str_hash, g_str_equal); -} - -/* Used from g_hash_table_foreach(), frees a CalBackendCategory structure */ -static void -free_category_cb (gpointer key, gpointer value, gpointer data) -{ - CalBackendCategory *c = value; - - g_free (c->name); - g_free (c); -} - -static gboolean -prune_changed_categories (gpointer key, gpointer value, gpointer data) -{ - CalBackendCategory *c = value; - - if (!c->refcount) - free_category_cb (key, value, data); - return TRUE; -} - -void -cal_backend_finalize (GObject *object) -{ - CalBackend *backend = (CalBackend *)object; - CalBackendPrivate *priv; - - priv = backend->priv; - - g_assert (priv->clients == NULL); - - g_object_unref (priv->queries); - - g_hash_table_foreach_remove (priv->changed_categories, prune_changed_categories, NULL); - g_hash_table_destroy (priv->changed_categories); - - g_hash_table_foreach (priv->categories, free_category_cb, NULL); - g_hash_table_destroy (priv->categories); - - g_mutex_free (priv->clients_mutex); - g_mutex_free (priv->queries_mutex); - - if (priv->category_idle_id) - g_source_remove (priv->category_idle_id); - - g_free (priv); - - G_OBJECT_CLASS (parent_class)->finalize (object); -} - - - -/** - * cal_backend_get_uri: - * @backend: A calendar backend. - * - * Queries the URI of a calendar backend, which must already have an open - * calendar. - * - * Return value: The URI where the calendar is stored. - **/ -const char * -cal_backend_get_uri (CalBackend *backend) -{ - CalBackendPrivate *priv; - - g_return_val_if_fail (backend != NULL, NULL); - g_return_val_if_fail (IS_CAL_BACKEND (backend), NULL); - - priv = backend->priv; - - return priv->uri; -} - -icalcomponent_kind -cal_backend_get_kind (CalBackend *backend) -{ - CalBackendPrivate *priv; - - g_return_val_if_fail (backend != NULL, ICAL_NO_COMPONENT); - g_return_val_if_fail (IS_CAL_BACKEND (backend), ICAL_NO_COMPONENT); - - priv = backend->priv; - - return priv->kind; -} - -static void -cal_destroy_cb (gpointer data, GObject *where_cal_was) -{ - CalBackend *backend = CAL_BACKEND (data); - - cal_backend_remove_client (backend, (Cal *) where_cal_was); -} - -static void -listener_died_cb (gpointer cnx, gpointer data) -{ - Cal *cal = CAL (data); - - cal_backend_remove_client (cal_get_backend (cal), cal); -} - -static void -last_client_gone (CalBackend *backend) -{ - g_signal_emit (backend, cal_backend_signals[LAST_CLIENT_GONE], 0); -} - -void -cal_backend_add_client (CalBackend *backend, Cal *cal) -{ - CalBackendPrivate *priv; - - g_return_if_fail (backend != NULL); - g_return_if_fail (IS_CAL_BACKEND (backend)); - g_return_if_fail (cal != NULL); - g_return_if_fail (IS_CAL (cal)); - - priv = backend->priv; - - bonobo_object_set_immortal (BONOBO_OBJECT (cal), TRUE); - - g_object_weak_ref (G_OBJECT (cal), cal_destroy_cb, backend); - - ORBit_small_listen_for_broken (cal_get_listener (cal), G_CALLBACK (listener_died_cb), cal); - - g_mutex_lock (priv->clients_mutex); - priv->clients = g_list_append (priv->clients, cal); - g_mutex_unlock (priv->clients_mutex); - - /* Tell the new client about the list of categories. - * (Ends up telling all the other clients too, but *shrug*.) - */ - /* FIXME This doesn't seem right at all */ - notify_categories_changed (backend); -} - -void -cal_backend_remove_client (CalBackend *backend, Cal *cal) -{ - CalBackendPrivate *priv; - - /* XXX this needs a bit more thinking wrt the mutex - we - should be holding it when we check to see if clients is - NULL */ - g_return_if_fail (backend != NULL); - g_return_if_fail (IS_CAL_BACKEND (backend)); - g_return_if_fail (cal != NULL); - g_return_if_fail (IS_CAL (cal)); - - priv = backend->priv; - - /* Disconnect */ - g_mutex_lock (priv->clients_mutex); - priv->clients = g_list_remove (priv->clients, cal); - g_mutex_unlock (priv->clients_mutex); - - /* When all clients go away, notify the parent factory about it so that - * it may decide whether to kill the backend or not. - */ - if (!priv->clients) - last_client_gone (backend); -} - -void -cal_backend_add_query (CalBackend *backend, Query *query) -{ - g_return_if_fail (backend != NULL); - g_return_if_fail (IS_CAL_BACKEND (backend)); - - g_mutex_lock (backend->priv->queries_mutex); - - e_list_append (backend->priv->queries, query); - - g_mutex_unlock (backend->priv->queries_mutex); -} - -EList * -cal_backend_get_queries (CalBackend *backend) -{ - g_return_val_if_fail (backend != NULL, NULL); - g_return_val_if_fail (IS_CAL_BACKEND (backend), NULL); - - return g_object_ref (backend->priv->queries); -} - - -/** - * cal_backend_get_cal_address: - * @backend: A calendar backend. - * - * Queries the cal address associated with a calendar backend, which - * must already have an open calendar. - * - * Return value: The cal address associated with the calendar. - **/ -void -cal_backend_get_cal_address (CalBackend *backend, Cal *cal) -{ - g_return_if_fail (backend != NULL); - g_return_if_fail (IS_CAL_BACKEND (backend)); - - g_assert (CLASS (backend)->get_cal_address != NULL); - (* CLASS (backend)->get_cal_address) (backend, cal); -} - -void -cal_backend_get_alarm_email_address (CalBackend *backend, Cal *cal) -{ - g_return_if_fail (backend != NULL); - g_return_if_fail (IS_CAL_BACKEND (backend)); - - g_assert (CLASS (backend)->get_alarm_email_address != NULL); - (* CLASS (backend)->get_alarm_email_address) (backend, cal); -} - -void -cal_backend_get_ldap_attribute (CalBackend *backend, Cal *cal) -{ - g_return_if_fail (backend != NULL); - g_return_if_fail (IS_CAL_BACKEND (backend)); - - g_assert (CLASS (backend)->get_ldap_attribute != NULL); - (* CLASS (backend)->get_ldap_attribute) (backend, cal); -} - -void -cal_backend_get_static_capabilities (CalBackend *backend, Cal *cal) -{ - g_return_if_fail (backend != NULL); - g_return_if_fail (IS_CAL_BACKEND (backend)); - - g_assert (CLASS (backend)->get_static_capabilities != NULL); - (* CLASS (backend)->get_static_capabilities) (backend, cal); -} - -/** - * cal_backend_open: - * @backend: A calendar backend. - * @uristr: URI that contains the calendar data. - * @only_if_exists: Whether the calendar should be opened only if it already - * exists. If FALSE, a new calendar will be created when the specified @uri - * does not exist. - * - * Opens a calendar backend with data from a calendar stored at the specified - * URI. - * - * Return value: An operation status code. - **/ -void -cal_backend_open (CalBackend *backend, Cal *cal, gboolean only_if_exists) -{ - g_return_if_fail (backend != NULL); - g_return_if_fail (IS_CAL_BACKEND (backend)); - - g_assert (CLASS (backend)->open != NULL); - (* CLASS (backend)->open) (backend, cal, only_if_exists); -} - -void -cal_backend_remove (CalBackend *backend, Cal *cal) -{ - g_return_if_fail (backend != NULL); - g_return_if_fail (IS_CAL_BACKEND (backend)); - - g_assert (CLASS (backend)->remove != NULL); - (* CLASS (backend)->remove) (backend, cal); -} - -/** - * cal_backend_is_loaded: - * @backend: A calendar backend. - * - * Queries whether a calendar backend has been loaded yet. - * - * Return value: TRUE if the backend has been loaded with data, FALSE - * otherwise. - **/ -gboolean -cal_backend_is_loaded (CalBackend *backend) -{ - gboolean result; - - g_return_val_if_fail (backend != NULL, FALSE); - g_return_val_if_fail (IS_CAL_BACKEND (backend), FALSE); - - g_assert (CLASS (backend)->is_loaded != NULL); - result = (* CLASS (backend)->is_loaded) (backend); - - return result; -} - -/** - * cal_backend_is_read_only - * @backend: A calendar backend. - * - * Queries whether a calendar backend is read only or not. - * - * Return value: TRUE if the calendar is read only, FALSE otherwise. - */ -void -cal_backend_is_read_only (CalBackend *backend, Cal *cal) -{ - g_return_if_fail (backend != NULL); - g_return_if_fail (IS_CAL_BACKEND (backend)); - - g_assert (CLASS (backend)->is_read_only != NULL); - (* CLASS (backend)->is_read_only) (backend, cal); -} - -void -cal_backend_start_query (CalBackend *backend, Query *query) -{ - g_return_if_fail (backend != NULL); - g_return_if_fail (IS_CAL_BACKEND (backend)); - - g_assert (CLASS (backend)->start_query != NULL); - (* CLASS (backend)->start_query) (backend, query); -} - -/** - * cal_backend_get_mode: - * @backend: A calendar backend. - * - * Queries whether a calendar backend is connected remotely. - * - * Return value: The current mode the calendar is in - **/ -CalMode -cal_backend_get_mode (CalBackend *backend) -{ - CalMode result; - - g_return_val_if_fail (backend != NULL, FALSE); - g_return_val_if_fail (IS_CAL_BACKEND (backend), FALSE); - - g_assert (CLASS (backend)->get_mode != NULL); - result = (* CLASS (backend)->get_mode) (backend); - - return result; -} - - -/** - * cal_backend_set_mode: - * @backend: A calendar backend - * @mode: Mode to change to - * - * Sets the mode of the calendar - * - **/ -void -cal_backend_set_mode (CalBackend *backend, CalMode mode) -{ - g_return_if_fail (backend != NULL); - g_return_if_fail (IS_CAL_BACKEND (backend)); - - g_assert (CLASS (backend)->set_mode != NULL); - (* CLASS (backend)->set_mode) (backend, mode); -} - -void -cal_backend_get_default_object (CalBackend *backend, Cal *cal) -{ - g_return_if_fail (backend != NULL); - g_return_if_fail (IS_CAL_BACKEND (backend)); - - g_assert (CLASS (backend)->get_default_object != NULL); - (* CLASS (backend)->get_default_object) (backend, cal); -} - -/** - * cal_backend_get_object: - * @backend: A calendar backend. - * @uid: Unique identifier for a calendar object. - * @rid: ID for the object's recurrence to get. - * - * Queries a calendar backend for a calendar object based on its unique - * identifier and its recurrence ID (if a recurrent appointment). - * - * Return value: The string representation of a complete calendar wrapping the - * the sought object, or NULL if no object had the specified UID. - **/ -void -cal_backend_get_object (CalBackend *backend, Cal *cal, const char *uid, const char *rid) -{ - g_return_if_fail (backend != NULL); - g_return_if_fail (IS_CAL_BACKEND (backend)); - g_return_if_fail (uid != NULL); - - g_assert (CLASS (backend)->get_object != NULL); - (* CLASS (backend)->get_object) (backend, cal, uid, rid); -} - -/** - * cal_backend_get_object_list: - * @backend: - * @type: - * - * - * - * Return value: - **/ -void -cal_backend_get_object_list (CalBackend *backend, Cal *cal, const char *sexp) -{ - g_return_if_fail (backend != NULL); - g_return_if_fail (IS_CAL_BACKEND (backend)); - - g_assert (CLASS (backend)->get_object_list != NULL); - return (* CLASS (backend)->get_object_list) (backend, cal, sexp); -} - -/** - * cal_backend_get_free_busy: - * @backend: A calendar backend. - * @users: List of users to get free/busy information for. - * @start: Start time for query. - * @end: End time for query. - * - * Gets a free/busy object for the given time interval - * - * Return value: a list of CalObj's - **/ -void -cal_backend_get_free_busy (CalBackend *backend, Cal *cal, GList *users, time_t start, time_t end) -{ - g_return_if_fail (backend != NULL); - g_return_if_fail (IS_CAL_BACKEND (backend)); - g_return_if_fail (start != -1 && end != -1); - g_return_if_fail (start <= end); - - g_assert (CLASS (backend)->get_free_busy != NULL); - (* CLASS (backend)->get_free_busy) (backend, cal, users, start, end); -} - -/** - * cal_backend_get_changes: - * @backend: A calendar backend - * @change_id: A unique uid for the callers change list - * - * Builds a sequence of objects and the type of change that occurred on them since - * the last time the give change_id was seen - * - * Return value: A list of the objects that changed and the type of change - **/ -void -cal_backend_get_changes (CalBackend *backend, Cal *cal, const char *change_id) -{ - g_return_if_fail (backend != NULL); - g_return_if_fail (IS_CAL_BACKEND (backend)); - g_return_if_fail (change_id != NULL); - - g_assert (CLASS (backend)->get_changes != NULL); - (* CLASS (backend)->get_changes) (backend, cal, change_id); -} - -/** - * cal_backend_discard_alarm - * @backend: A calendar backend. - * @uid: UID of the component to discard the alarm from. - * @auid: Alarm ID. - * - * Discards an alarm from the given component. This allows the specific backend - * to do whatever is needed to really discard the alarm. - * - **/ -void -cal_backend_discard_alarm (CalBackend *backend, Cal *cal, const char *uid, const char *auid) -{ - g_return_if_fail (backend != NULL); - g_return_if_fail (IS_CAL_BACKEND (backend)); - g_return_if_fail (uid != NULL); - g_return_if_fail (auid != NULL); - - g_assert (CLASS (backend)->discard_alarm != NULL); - (* CLASS (backend)->discard_alarm) (backend, cal, uid, auid); -} - -void -cal_backend_create_object (CalBackend *backend, Cal *cal, const char *calobj) -{ - g_return_if_fail (backend != NULL); - g_return_if_fail (IS_CAL_BACKEND (backend)); - g_return_if_fail (calobj != NULL); - - g_assert (CLASS (backend)->create_object != NULL); - (* CLASS (backend)->create_object) (backend, cal, calobj); -} - -void -cal_backend_modify_object (CalBackend *backend, Cal *cal, const char *calobj, CalObjModType mod) -{ - g_return_if_fail (backend != NULL); - g_return_if_fail (IS_CAL_BACKEND (backend)); - g_return_if_fail (calobj != NULL); - - g_assert (CLASS (backend)->modify_object != NULL); - (* CLASS (backend)->modify_object) (backend, cal, calobj, mod); -} - -/** - * cal_backend_remove_object: - * @backend: A calendar backend. - * @uid: Unique identifier of the object to remove. - * @rid: A recurrence ID. - * - * Removes an object in a calendar backend. The backend will notify all of its - * clients about the change. - * - **/ -void -cal_backend_remove_object (CalBackend *backend, Cal *cal, const char *uid, const char *rid, CalObjModType mod) -{ - g_return_if_fail (backend != NULL); - g_return_if_fail (IS_CAL_BACKEND (backend)); - g_return_if_fail (uid != NULL); - - g_assert (CLASS (backend)->remove_object != NULL); - (* CLASS (backend)->remove_object) (backend, cal, uid, rid, mod); -} - -void -cal_backend_receive_objects (CalBackend *backend, Cal *cal, const char *calobj) -{ - g_return_if_fail (backend != NULL); - g_return_if_fail (IS_CAL_BACKEND (backend)); - g_return_if_fail (calobj != NULL); - - g_assert (CLASS (backend)->receive_objects != NULL); - return (* CLASS (backend)->receive_objects) (backend, cal, calobj); -} - -void -cal_backend_send_objects (CalBackend *backend, Cal *cal, const char *calobj) -{ - g_return_if_fail (backend != NULL); - g_return_if_fail (IS_CAL_BACKEND (backend)); - g_return_if_fail (calobj != NULL); - - g_assert (CLASS (backend)->send_objects != NULL); - return (* CLASS (backend)->send_objects) (backend, cal, calobj); -} - -/** - * cal_backend_get_timezone: - * @backend: A calendar backend. - * @tzid: Unique identifier of a VTIMEZONE object. Note that this must not be - * NULL. - * - * Returns the icaltimezone* corresponding to the TZID, or NULL if the TZID - * can't be found. - * - * Returns: The icaltimezone* corresponding to the given TZID, or NULL. - **/ -void -cal_backend_get_timezone (CalBackend *backend, Cal *cal, const char *tzid) -{ - g_return_if_fail (backend != NULL); - g_return_if_fail (IS_CAL_BACKEND (backend)); - g_return_if_fail (tzid != NULL); - - g_assert (CLASS (backend)->get_timezone != NULL); - (* CLASS (backend)->get_timezone) (backend, cal, tzid); -} - -/** - * cal_backend_set_default_timezone: - * @backend: A calendar backend. - * @tzid: The TZID identifying the timezone. - * - * Sets the default timezone for the calendar, which is used to resolve - * DATE and floating DATE-TIME values. - * - * Returns: TRUE if the VTIMEZONE data for the timezone was found, or FALSE if - * not. - **/ -void -cal_backend_set_default_timezone (CalBackend *backend, Cal *cal, const char *tzid) -{ - g_return_if_fail (backend != NULL); - g_return_if_fail (IS_CAL_BACKEND (backend)); - g_return_if_fail (tzid != NULL); - - g_assert (CLASS (backend)->set_default_timezone != NULL); - (* CLASS (backend)->set_default_timezone) (backend, cal, tzid); -} - -/** - * cal_backend_add_timezone - * @backend: A calendar backend. - * @tzobj: The timezone object, in a string. - * - * Add a timezone object to the given backend. - * - * Returns: TRUE if successful, or FALSE if not. - */ -void -cal_backend_add_timezone (CalBackend *backend, Cal *cal, const char *tzobj) -{ - g_return_if_fail (IS_CAL_BACKEND (backend)); - g_return_if_fail (tzobj != NULL); - g_return_if_fail (CLASS (backend)->add_timezone != NULL); - - (* CLASS (backend)->add_timezone) (backend, cal, tzobj); -} - -icaltimezone * -cal_backend_internal_get_default_timezone (CalBackend *backend) -{ - g_return_val_if_fail (IS_CAL_BACKEND (backend), NULL); - g_return_val_if_fail (CLASS (backend)->internal_get_default_timezone != NULL, NULL); - - return (* CLASS (backend)->internal_get_default_timezone) (backend); -} - -icaltimezone * -cal_backend_internal_get_timezone (CalBackend *backend, const char *tzid) -{ - g_return_val_if_fail (IS_CAL_BACKEND (backend), NULL); - g_return_val_if_fail (tzid != NULL, NULL); - g_return_val_if_fail (CLASS (backend)->internal_get_timezone != NULL, NULL); - - return (* CLASS (backend)->internal_get_timezone) (backend, tzid); -} - -/** - * cal_backend_notify_object_created: - * @backend: A calendar backend. - * @calobj: iCalendar representation of new object - * - * Notifies each of the backend's listeners about a new object. - * - * cal_notify_object_created() calls this for you. You only need to - * call cal_backend_notify_object_created() yourself to report objects - * created by non-PCS clients. - **/ -void -cal_backend_notify_object_created (CalBackend *backend, const char *calobj) -{ - EList *queries; - EIterator *iter; - Query *query; - - queries = cal_backend_get_queries (backend); - iter = e_list_get_iterator (queries); - - while (e_iterator_is_valid (iter)) { - query = QUERY (e_iterator_get (iter)); - - bonobo_object_ref (query); - if (query_object_matches (query, calobj)) - query_notify_objects_added_1 (query, calobj); - bonobo_object_unref (query); - - e_iterator_next (iter); - } - g_object_unref (iter); - g_object_unref (queries); -} - -/** - * cal_backend_notify_object_modified: - * @backend: A calendar backend. - * @old_object: iCalendar representation of the original form of the object - * @object: iCalendar representation of the new form of the object - * - * Notifies each of the backend's listeners about a modified object. - * - * cal_notify_object_modified() calls this for you. You only need to - * call cal_backend_notify_object_modified() yourself to report objects - * modified by non-PCS clients. - **/ -void -cal_backend_notify_object_modified (CalBackend *backend, - const char *old_object, const char *object) -{ - EList *queries; - EIterator *iter; - Query *query; - gboolean old_match, new_match; - - queries = cal_backend_get_queries (backend); - iter = e_list_get_iterator (queries); - - while (e_iterator_is_valid (iter)) { - query = QUERY (e_iterator_get (iter)); - - bonobo_object_ref (query); - - old_match = query_object_matches (query, old_object); - new_match = query_object_matches (query, object); - if (old_match && new_match) - query_notify_objects_modified_1 (query, object); - else if (new_match) - query_notify_objects_added_1 (query, object); - else /* if (old_match) */ { - icalcomponent *comp; - - comp = icalcomponent_new_from_string ((char *)old_object); - query_notify_objects_removed_1 (query, icalcomponent_get_uid (comp)); - icalcomponent_free (comp); - } - - bonobo_object_unref (query); - - e_iterator_next (iter); - } - g_object_unref (iter); - g_object_unref (queries); -} - -/** - * cal_backend_notify_object_removed: - * @backend: A calendar backend. - * @uid: the UID of the removed object - * @old_object: iCalendar representation of the removed object - * - * Notifies each of the backend's listeners about a removed object. - * - * cal_notify_object_removed() calls this for you. You only need to - * call cal_backend_notify_object_removed() yourself to report objects - * removed by non-PCS clients. - **/ -void -cal_backend_notify_object_removed (CalBackend *backend, const char *uid, - const char *old_object) -{ - EList *queries; - EIterator *iter; - Query *query; - - queries = cal_backend_get_queries (backend); - iter = e_list_get_iterator (queries); - - while (e_iterator_is_valid (iter)) { - query = QUERY (e_iterator_get (iter)); - - bonobo_object_ref (query); - if (query_object_matches (query, old_object)) - query_notify_objects_removed_1 (query, uid); - bonobo_object_unref (query); - - e_iterator_next (iter); - } - g_object_unref (iter); - g_object_unref (queries); -} - -/** - * cal_backend_notify_mode: - * @backend: A calendar backend. - * @status: Status of the mode set - * @mode: the current mode - * - * Notifies each of the backend's listeners about the results of a - * setMode call. - **/ -void -cal_backend_notify_mode (CalBackend *backend, - GNOME_Evolution_Calendar_Listener_SetModeStatus status, - GNOME_Evolution_Calendar_CalMode mode) -{ - CalBackendPrivate *priv = backend->priv; - GList *l; - - for (l = priv->clients; l; l = l->next) - cal_notify_mode (l->data, status, mode); -} - -/** - * cal_backend_notify_error: - * @backend: A calendar backend. - * @message: Error message - * - * Notifies each of the backend's listeners about an error - **/ -void -cal_backend_notify_error (CalBackend *backend, const char *message) -{ - CalBackendPrivate *priv = backend->priv; - GList *l; - - for (l = priv->clients; l; l = l->next) - cal_notify_error (l->data, message); -} - -static void -add_category_cb (gpointer name, gpointer category, gpointer data) -{ - GNOME_Evolution_Calendar_StringSeq *seq = data; - - seq->_buffer[seq->_length++] = CORBA_string_dup (name); -} - -static void -notify_categories_changed (CalBackend *backend) -{ - CalBackendPrivate *priv = backend->priv; - GNOME_Evolution_Calendar_StringSeq *seq; - GList *l; - - /* Build the sequence of category names */ - seq = GNOME_Evolution_Calendar_StringSeq__alloc (); - seq->_length = 0; - seq->_maximum = g_hash_table_size (priv->categories); - seq->_buffer = CORBA_sequence_CORBA_string_allocbuf (seq->_maximum); - CORBA_sequence_set_release (seq, TRUE); - - g_hash_table_foreach (priv->categories, add_category_cb, seq); - - /* Notify the clients */ - for (l = priv->clients; l; l = l->next) - cal_notify_categories_changed (l->data, seq); - - CORBA_free (seq); -} - -static gboolean -idle_notify_categories_changed (gpointer data) -{ - CalBackend *backend = CAL_BACKEND (data); - CalBackendPrivate *priv = backend->priv; - - if (g_hash_table_size (priv->changed_categories)) { - notify_categories_changed (backend); - g_hash_table_foreach_remove (priv->changed_categories, prune_changed_categories, NULL); - } - - priv->category_idle_id = 0; - - return FALSE; -} - -/** - * cal_backend_ref_categories: - * @backend: A calendar backend - * @categories: a list of categories - * - * Adds 1 to the refcount of each of the named categories. If any of - * the categories are new, clients will be notified of the updated - * category list at idle time. - **/ -void -cal_backend_ref_categories (CalBackend *backend, GSList *categories) -{ - CalBackendPrivate *priv; - CalBackendCategory *c; - const char *name; - - priv = backend->priv; - - while (categories) { - name = categories->data; - c = g_hash_table_lookup (priv->categories, name); - - if (c) - c->refcount++; - else { - /* See if it was recently removed */ - - c = g_hash_table_lookup (priv->changed_categories, name); - if (c && c->refcount == 0) { - /* Move it back to the set of live categories */ - g_hash_table_remove (priv->changed_categories, c->name); - - c->refcount = 1; - g_hash_table_insert (priv->categories, c->name, c); - } else { - /* Create a new category */ - c = g_new (CalBackendCategory, 1); - c->name = g_strdup (name); - c->refcount = 1; - g_hash_table_insert (priv->categories, c->name, c); - g_hash_table_insert (priv->changed_categories, c->name, c); - } - } - - categories = categories->next; - } - - if (g_hash_table_size (priv->changed_categories) && - !priv->category_idle_id) - priv->category_idle_id = g_idle_add (idle_notify_categories_changed, backend); -} - -/** - * cal_backend_unref_categories: - * @backend: A calendar backend - * @categories: a list of categories - * - * Subtracts 1 from the refcount of each of the named categories. If - * any of the refcounts go down to 0, clients will be notified of the - * updated category list at idle time. - **/ -void -cal_backend_unref_categories (CalBackend *backend, GSList *categories) -{ - CalBackendPrivate *priv; - CalBackendCategory *c; - const char *name; - - priv = backend->priv; - - while (categories) { - name = categories->data; - c = g_hash_table_lookup (priv->categories, name); - - if (c) { - g_assert (c != NULL); - g_assert (c->refcount > 0); - - c->refcount--; - - if (c->refcount == 0) { - g_hash_table_remove (priv->categories, c->name); - g_hash_table_insert (priv->changed_categories, c->name, c); - } - } - - categories = categories->next; - } - - if (g_hash_table_size (priv->changed_categories) && - !priv->category_idle_id) - priv->category_idle_id = g_idle_add (idle_notify_categories_changed, backend); -} diff --git a/calendar/pcs/cal-backend.h b/calendar/pcs/cal-backend.h deleted file mode 100644 index 5b4e59a6a8..0000000000 --- a/calendar/pcs/cal-backend.h +++ /dev/null @@ -1,178 +0,0 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */ -/* Evolution calendar - generic backend class - * - * Copyright (C) 2000 Ximian, Inc. - * Copyright (C) 2000 Ximian, Inc. - * - * Authors: Federico Mena-Quintero <federico@ximian.com> - * Rodrigo Moya <rodrigo@ximian.com> - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of version 2 of the GNU General Public - * License as published by the Free Software Foundation. - * - * 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA. - */ - -#ifndef CAL_BACKEND_H -#define CAL_BACKEND_H - -#include <e-util/e-list.h> -#include <cal-util/cal-util.h> -#include <cal-util/cal-component.h> -#include "pcs/evolution-calendar.h" -#include "pcs/cal-common.h" -#include "pcs/cal.h" -#include "pcs/query.h" - -G_BEGIN_DECLS - - - -#define CAL_BACKEND_TYPE (cal_backend_get_type ()) -#define CAL_BACKEND(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), CAL_BACKEND_TYPE, CalBackend)) -#define CAL_BACKEND_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), CAL_BACKEND_TYPE, \ - CalBackendClass)) -#define IS_CAL_BACKEND(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), CAL_BACKEND_TYPE)) -#define IS_CAL_BACKEND_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), CAL_BACKEND_TYPE)) - -typedef struct _CalBackendPrivate CalBackendPrivate; - -struct _CalBackend { - GObject object; - - CalBackendPrivate *priv; -}; - -struct _CalBackendClass { - GObjectClass parent_class; - - /* Notification signals */ - void (* last_client_gone) (CalBackend *backend); - void (* cal_added) (CalBackend *backend, Cal *cal); - - gboolean (* is_loaded) (CalBackend *backend); - - /* FIXME What to pass back here */ - void (* opened) (CalBackend *backend, int status); - void (* removed) (CalBackend *backend, int status); - void (* obj_updated) (CalBackend *backend, const char *uid); - - /* Virtual methods */ - void (* is_read_only) (CalBackend *backend, Cal *cal); - void (* get_cal_address) (CalBackend *backend, Cal *cal); - void (* get_alarm_email_address) (CalBackend *backend, Cal *cal); - void (* get_ldap_attribute) (CalBackend *backend, Cal *cal); - void (* get_static_capabilities) (CalBackend *backend, Cal *cal); - - void (* open) (CalBackend *backend, Cal *cal, gboolean only_if_exists); - void (* remove) (CalBackend *backend, Cal *cal); - - /* Object related virtual methods */ - void (* create_object) (CalBackend *backend, Cal *cal, const char *calobj); - void (* modify_object) (CalBackend *backend, Cal *cal, const char *calobj, CalObjModType mod); - void (* remove_object) (CalBackend *backend, Cal *cal, const char *uid, const char *rid, CalObjModType mod); - - void (* discard_alarm) (CalBackend *backend, Cal *cal, const char *uid, const char *auid); - - void (* receive_objects) (CalBackend *backend, Cal *cal, const char *calobj); - void (* send_objects) (CalBackend *backend, Cal *cal, const char *calobj); - - void (* get_default_object) (CalBackend *backend, Cal *cal); - void (* get_object) (CalBackend *backend, Cal *cal, const char *uid, const char *rid); - void (* get_object_list) (CalBackend *backend, Cal *cal, const char *sexp); - - /* Timezone related virtual methods */ - void (* get_timezone) (CalBackend *backend, Cal *cal, const char *tzid); - void (* add_timezone) (CalBackend *backend, Cal *cal, const char *object); - void (* set_default_timezone) (CalBackend *backend, Cal *cal, const char *tzid); - - void (* start_query) (CalBackend *backend, Query *query); - - /* Mode relate virtual methods */ - CalMode (* get_mode) (CalBackend *backend); - void (* set_mode) (CalBackend *backend, CalMode mode); - - void (* get_free_busy) (CalBackend *backend, Cal *cal, GList *users, time_t start, time_t end); - void (* get_changes) (CalBackend *backend, Cal *cal, const char *change_id); - - /* Internal methods for use only in the pcs */ - icaltimezone *(* internal_get_default_timezone) (CalBackend *backend); - icaltimezone *(* internal_get_timezone) (CalBackend *backend, const char *tzid); -}; - -GType cal_backend_get_type (void); - -const char *cal_backend_get_uri (CalBackend *backend); -icalcomponent_kind cal_backend_get_kind (CalBackend *backend); - -void cal_backend_add_client (CalBackend *backend, Cal *cal); -void cal_backend_remove_client (CalBackend *backend, Cal *cal); - -void cal_backend_add_query (CalBackend *backend, Query *query); -EList *cal_backend_get_queries (CalBackend *backend); - -void cal_backend_is_read_only (CalBackend *backend, Cal *cal); -void cal_backend_get_cal_address (CalBackend *backend, Cal *cal); -void cal_backend_get_alarm_email_address (CalBackend *backend, Cal *cal); -void cal_backend_get_ldap_attribute (CalBackend *backend, Cal *cal); -void cal_backend_get_static_capabilities (CalBackend *backend, Cal *cal); - -void cal_backend_open (CalBackend *backend, Cal *cal, gboolean only_if_exists); -void cal_backend_remove (CalBackend *backend, Cal *cal); - -void cal_backend_create_object (CalBackend *backend, Cal *cal, const char *calobj); -void cal_backend_modify_object (CalBackend *backend, Cal *cal, const char *calobj, CalObjModType mod); -void cal_backend_remove_object (CalBackend *backend, Cal *cal, const char *uid, const char *rid, CalObjModType mod); - -void cal_backend_discard_alarm (CalBackend *backend, Cal *cal, const char *uid, const char *auid); - -void cal_backend_receive_objects (CalBackend *backend, Cal *cal, const char *calobj); -void cal_backend_send_objects (CalBackend *backend, Cal *cal, const char *calobj); - -void cal_backend_get_default_object (CalBackend *backend, Cal *cal); -void cal_backend_get_object (CalBackend *backend, Cal *cal, const char *uid, const char *rid); -void cal_backend_get_object_list (CalBackend *backend, Cal *cal, const char *sexp); - -gboolean cal_backend_is_loaded (CalBackend *backend); - -void cal_backend_start_query (CalBackend *backend, Query *query); - -CalMode cal_backend_get_mode (CalBackend *backend); -void cal_backend_set_mode (CalBackend *backend, CalMode mode); - -void cal_backend_get_timezone (CalBackend *backend, Cal *cal, const char *tzid); -void cal_backend_add_timezone (CalBackend *backend, Cal *cal, const char *object); -void cal_backend_set_default_timezone (CalBackend *backend, Cal *cal, const char *tzid); - -void cal_backend_get_changes (CalBackend *backend, Cal *cal, const char *change_id); -void cal_backend_get_free_busy (CalBackend *backend, Cal *cal, GList *users, time_t start, time_t end); - -icaltimezone* cal_backend_internal_get_default_timezone (CalBackend *backend); -icaltimezone* cal_backend_internal_get_timezone (CalBackend *backend, const char *tzid); - -void cal_backend_last_client_gone (CalBackend *backend); - -void cal_backend_notify_object_created (CalBackend *backend, const char *calobj); -void cal_backend_notify_object_modified (CalBackend *backend, const char *old_object, const char *object); -void cal_backend_notify_object_removed (CalBackend *backend, const char *uid, const char *old_object); - -void cal_backend_notify_mode (CalBackend *backend, - GNOME_Evolution_Calendar_Listener_SetModeStatus status, - GNOME_Evolution_Calendar_CalMode mode); -void cal_backend_notify_error (CalBackend *backend, const char *message); -void cal_backend_ref_categories (CalBackend *backend, GSList *categories); -void cal_backend_unref_categories (CalBackend *backend, GSList *categories); - - - -G_END_DECLS - -#endif diff --git a/calendar/pcs/cal-common.h b/calendar/pcs/cal-common.h deleted file mode 100644 index 5a588c93c8..0000000000 --- a/calendar/pcs/cal-common.h +++ /dev/null @@ -1,47 +0,0 @@ -/* Evolution calendar server - common declarations - * - * Copyright (C) 2000 Ximian, Inc. - * Copyright (C) 2000 Ximian, Inc. - * - * Author: Federico Mena-Quintero <federico@ximian.com> - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of version 2 of the GNU General Public - * License as published by the Free Software Foundation. - * - * 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA. - */ - -#ifndef CAL_COMMON_H -#define CAL_COMMON_H - -#include <glib/gmacros.h> - -G_BEGIN_DECLS - - - -typedef struct _CalBackend CalBackend; -typedef struct _CalBackendClass CalBackendClass; - -typedef struct _Cal Cal; -typedef struct _CalClass CalClass; - -typedef struct _Query Query; -typedef struct _QueryClass QueryClass; - -typedef struct _CalBackendObjectSExp CalBackendObjectSExp; -typedef struct _CalBackendObjectSExpClass CalBackendObjectSExpClass; - - - -G_END_DECLS - -#endif diff --git a/calendar/pcs/cal-factory.c b/calendar/pcs/cal-factory.c deleted file mode 100644 index 2f72ec5911..0000000000 --- a/calendar/pcs/cal-factory.c +++ /dev/null @@ -1,482 +0,0 @@ -/* Evolution calendar factory - * - * Copyright (C) 2000-2003 Ximian, Inc. - * - * Authors: - * Federico Mena-Quintero <federico@ximian.com> - * JP Rosevear <jpr@ximian.com> - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of version 2 of the GNU General Public - * License as published by the Free Software Foundation. - * - * 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA. - */ - -#include <bonobo-activation/bonobo-activation.h> -#include <bonobo/bonobo-exception.h> -#include <bonobo/bonobo-main.h> -#include "e-util/e-url.h" -#include "evolution-calendar.h" -#include "cal-backend.h" -#include "cal.h" -#include "cal-factory.h" - -#define PARENT_TYPE BONOBO_TYPE_OBJECT -#define DEFAULT_CAL_FACTORY_OAF_ID "OAFIID:GNOME_Evolution_Wombat_CalendarFactory" - -static BonoboObjectClass *parent_class; - -/* Private part of the CalFactory structure */ -struct _CalFactoryPrivate { - /* Hash table from URI method strings to GType * for backend class types */ - GHashTable *methods; - - /* Hash table from GnomeVFSURI structures to CalBackend objects */ - GHashTable *backends; - - /* OAFIID of the factory */ - char *iid; - - /* Whether we have been registered with OAF yet */ - guint registered : 1; -}; - -/* Signal IDs */ -enum SIGNALS { - LAST_CALENDAR_GONE, - LAST_SIGNAL -}; - -static guint signals[LAST_SIGNAL]; - -/* Opening calendars */ -static icalcomponent_kind -calobjtype_to_icalkind (const GNOME_Evolution_Calendar_CalObjType type) -{ - switch (type){ - case GNOME_Evolution_Calendar_TYPE_EVENT: - return ICAL_VEVENT_COMPONENT; - case GNOME_Evolution_Calendar_TYPE_TODO: - return ICAL_VTODO_COMPONENT; - case GNOME_Evolution_Calendar_TYPE_JOURNAL: - return ICAL_VJOURNAL_COMPONENT; - } - - return ICAL_NO_COMPONENT; -} - -static GType -get_backend_type (GHashTable *methods, const char *method, icalcomponent_kind kind) -{ - GHashTable *kinds; - GType type; - - kinds = g_hash_table_lookup (methods, method); - if (!kinds) - return 0; - - type = GPOINTER_TO_INT (g_hash_table_lookup (kinds, GINT_TO_POINTER (kind))); - - return type; -} - -/* Looks up a calendar backend in a factory's hash table of uri->cal. If - * *non-NULL, orig_uri_return will be set to point to the original key in the - * *hash table. - */ -static CalBackend * -lookup_backend (CalFactory *factory, const char *uristr) -{ - CalFactoryPrivate *priv; - EUri *uri; - CalBackend *backend; - char *tmp; - - priv = factory->priv; - - uri = e_uri_new (uristr); - if (!uri) - return NULL; - - tmp = e_uri_to_string (uri, FALSE); - backend = g_hash_table_lookup (priv->backends, tmp); - g_free (tmp); - e_uri_free (uri); - - return backend; -} - -/* Callback used when a backend loses its last connected client */ -static void -backend_last_client_gone_cb (CalBackend *backend, gpointer data) -{ - CalFactory *factory; - CalFactoryPrivate *priv; - CalBackend *ret_backend; - const char *uristr; - - fprintf (stderr, "backend_last_client_gone_cb() called!\n"); - - factory = CAL_FACTORY (data); - priv = factory->priv; - - /* Remove the backend from the hash table */ - - uristr = cal_backend_get_uri (backend); - g_assert (uristr != NULL); - - ret_backend = lookup_backend (factory, uristr); - g_assert (ret_backend != NULL); - g_assert (ret_backend == backend); - - g_hash_table_remove (priv->backends, uristr); - - /* Notify upstream if there are no more backends */ - - if (g_hash_table_size (priv->backends) == 0) - g_signal_emit (G_OBJECT (factory), signals[LAST_CALENDAR_GONE], 0); -} - - - -static GNOME_Evolution_Calendar_Cal -impl_CalFactory_getCal (PortableServer_Servant servant, - const CORBA_char *str_uri, - const GNOME_Evolution_Calendar_CalObjType type, - const GNOME_Evolution_Calendar_Listener listener, - CORBA_Environment *ev) -{ - CalFactory *factory; - CalFactoryPrivate *priv; - Cal *cal = CORBA_OBJECT_NIL; - CalBackend *backend; - CORBA_Environment ev2; - GNOME_Evolution_Calendar_Listener listener_copy; - GType backend_type; - EUri *uri; - char *uri_string; - - factory = CAL_FACTORY (bonobo_object_from_servant (servant)); - priv = factory->priv; - - /* Parse the uri */ - uri = e_uri_new (str_uri); - if (!uri) { - bonobo_exception_set (ev, ex_GNOME_Evolution_Calendar_CalFactory_InvalidURI); - - return CORBA_OBJECT_NIL; - } - uri_string = e_uri_to_string (uri, FALSE); - - /* Find the associated backend type (if any) */ - backend_type = get_backend_type (priv->methods, uri->protocol, calobjtype_to_icalkind (type)); - if (!backend_type) { - /* FIXME Distinguish between method and kind failures? */ - bonobo_exception_set (ev, ex_GNOME_Evolution_Calendar_CalFactory_UnsupportedMethod); - goto cleanup; - } - - /* Duplicate the listener object */ - CORBA_exception_init (&ev2); - listener_copy = CORBA_Object_duplicate (listener, &ev2); - - if (BONOBO_EX (&ev2)) { - g_warning (G_STRLOC ": could not duplicate the listener"); - bonobo_exception_set (ev, ex_GNOME_Evolution_Calendar_CalFactory_NilListener); - CORBA_exception_free (&ev2); - goto cleanup; - } - CORBA_exception_free (&ev2); - - /* Look for an existing backend */ - backend = lookup_backend (factory, uri_string); - if (!backend) { - /* There was no existing backend, create a new one */ - backend = g_object_new (backend_type, "uri", uri_string, "kind", calobjtype_to_icalkind (type), NULL); - if (!backend) { - g_warning (G_STRLOC ": could not instantiate backend"); - bonobo_exception_set (ev, ex_GNOME_Evolution_Calendar_CalFactory_UnsupportedMethod); - goto cleanup; - } - - /* Track the backend */ - g_hash_table_insert (priv->backends, g_strdup (uri_string), backend); - - g_signal_connect (G_OBJECT (backend), "last_client_gone", - G_CALLBACK (backend_last_client_gone_cb), - factory); - } - - /* Create the corba calendar */ - cal = cal_new (backend, uri_string, listener); - if (!cal) { - g_warning (G_STRLOC ": could not create the corba calendar"); - bonobo_exception_set (ev, ex_GNOME_Evolution_Calendar_CalFactory_UnsupportedMethod); - goto cleanup; - } - - /* Let the backend know about its clients corba clients */ - cal_backend_add_client (backend, cal); - - cleanup: - e_uri_free (uri); - g_free (uri_string); - - return CORBA_Object_duplicate (BONOBO_OBJREF (cal), ev); -} - - - -/** - * cal_factory_new: - * @void: - * - * Creates a new #CalFactory object. - * - * Return value: A newly-created #CalFactory, or NULL if its corresponding CORBA - * object could not be created. - **/ -CalFactory * -cal_factory_new (void) -{ - CalFactory *factory; - - factory = g_object_new (CAL_FACTORY_TYPE, - "poa", bonobo_poa_get_threaded (ORBIT_THREAD_HINT_PER_REQUEST, NULL), - NULL); - - return factory; -} - -/* Destroy handler for the calendar */ -static void -cal_factory_finalize (GObject *object) -{ - CalFactory *factory; - CalFactoryPrivate *priv; - - g_return_if_fail (object != NULL); - g_return_if_fail (IS_CAL_FACTORY (object)); - - factory = CAL_FACTORY (object); - priv = factory->priv; - - g_hash_table_destroy (priv->methods); - priv->methods = NULL; - - /* Should we assert that there are no more backends? */ - g_hash_table_destroy (priv->backends); - priv->backends = NULL; - - if (priv->registered) { - bonobo_activation_active_server_unregister (priv->iid, BONOBO_OBJREF (factory)); - priv->registered = FALSE; - } - g_free (priv->iid); - - g_free (priv); - factory->priv = NULL; - - if (G_OBJECT_CLASS (parent_class)->finalize) - (* G_OBJECT_CLASS (parent_class)->finalize) (object); -} - -/* Class initialization function for the calendar factory */ -static void -cal_factory_class_init (CalFactoryClass *klass) -{ - GObjectClass *object_class = (GObjectClass *) klass; - POA_GNOME_Evolution_Calendar_CalFactory__epv *epv = &klass->epv; - - parent_class = g_type_class_peek_parent (klass); - - signals[LAST_CALENDAR_GONE] = - g_signal_new ("last_calendar_gone", - G_TYPE_FROM_CLASS (klass), - G_SIGNAL_RUN_FIRST, - G_STRUCT_OFFSET (CalFactoryClass, last_calendar_gone), - NULL, NULL, - g_cclosure_marshal_VOID__VOID, - G_TYPE_NONE, 0); - - /* Class method overrides */ - object_class->finalize = cal_factory_finalize; - - /* Epv methods */ - epv->getCal = impl_CalFactory_getCal; -} - -/* Object initialization function for the calendar factory */ -static void -cal_factory_init (CalFactory *factory, CalFactoryClass *klass) -{ - CalFactoryPrivate *priv; - - priv = g_new0 (CalFactoryPrivate, 1); - factory->priv = priv; - - priv->methods = g_hash_table_new_full (g_str_hash, g_str_equal, - (GDestroyNotify) g_free, (GDestroyNotify) g_hash_table_destroy); - priv->backends = g_hash_table_new_full (g_str_hash, g_str_equal, - (GDestroyNotify) g_free, (GDestroyNotify) g_object_unref); - priv->registered = FALSE; -} - -BONOBO_TYPE_FUNC_FULL (CalFactory, - GNOME_Evolution_Calendar_CalFactory, - PARENT_TYPE, - cal_factory); - -/** - * cal_factory_register_storage: - * @factory: A calendar factory. - * @iid: OAFIID for the factory to be registered. - * - * Registers a calendar factory with the OAF object activation daemon. This - * function must be called before any clients can activate the factory. - * - * Return value: TRUE on success, FALSE otherwise. - **/ -gboolean -cal_factory_register_storage (CalFactory *factory, const char *iid) -{ - CalFactoryPrivate *priv; - Bonobo_RegistrationResult result; - char *tmp_iid; - - g_return_val_if_fail (factory != NULL, FALSE); - g_return_val_if_fail (IS_CAL_FACTORY (factory), FALSE); - - priv = factory->priv; - - g_return_val_if_fail (!priv->registered, FALSE); - - /* if iid is NULL, use the default factory OAFIID */ - if (iid) - tmp_iid = g_strdup (iid); - else - tmp_iid = g_strdup (DEFAULT_CAL_FACTORY_OAF_ID); - - result = bonobo_activation_active_server_register (tmp_iid, BONOBO_OBJREF (factory)); - - switch (result) { - case Bonobo_ACTIVATION_REG_SUCCESS: - priv->registered = TRUE; - priv->iid = tmp_iid; - return TRUE; - - case Bonobo_ACTIVATION_REG_NOT_LISTED: - g_warning (G_STRLOC ": cannot register the calendar factory (not listed)"); - break; - - case Bonobo_ACTIVATION_REG_ALREADY_ACTIVE: - g_warning (G_STRLOC ": cannot register the calendar factory (already active)"); - break; - - case Bonobo_ACTIVATION_REG_ERROR: - default: - g_warning (G_STRLOC ": cannot register the calendar factory (generic error)"); - break; - } - - g_free (tmp_iid); - - return FALSE; -} - -/** - * cal_factory_register_method: - * @factory: A calendar factory. - * @method: Method for the URI, i.e. "http", "file", etc. - * @backend_type: Class type of the backend to create for this @method. - * - * Registers the type of a #CalBackend subclass that will be used to handle URIs - * with a particular method. When the factory is asked to open a particular - * URI, it will look in its list of registered methods and create a backend of - * the appropriate type. - **/ -void -cal_factory_register_method (CalFactory *factory, const char *method, icalcomponent_kind kind, GType backend_type) -{ - CalFactoryPrivate *priv; - char *method_str; - GHashTable *kinds; - GType type; - - g_return_if_fail (factory != NULL); - g_return_if_fail (IS_CAL_FACTORY (factory)); - g_return_if_fail (method != NULL); - g_return_if_fail (backend_type != 0); - g_return_if_fail (g_type_is_a (backend_type, CAL_BACKEND_TYPE)); - - priv = factory->priv; - - method_str = g_ascii_strdown (method, -1); - - kinds = g_hash_table_lookup (priv->methods, method_str); - if (kinds) { - type = GPOINTER_TO_INT (g_hash_table_lookup (kinds, GINT_TO_POINTER (kind))); - if (type) { - g_warning (G_STRLOC ": method `%s' already registered", method_str); - g_free (method_str); - - return; - } - } else { - kinds = g_hash_table_new_full (g_direct_hash, g_direct_equal, NULL, NULL); - g_hash_table_insert (priv->methods, method_str, kinds); - } - - g_hash_table_insert (kinds, GINT_TO_POINTER (kind), GINT_TO_POINTER (backend_type)); -} - -/** - * cal_factory_get_n_backends - * @factory: A calendar factory. - * - * Get the number of backends currently active in the given factory. - * - * Returns: the number of backends. - */ -int -cal_factory_get_n_backends (CalFactory *factory) -{ - CalFactoryPrivate *priv; - - g_return_val_if_fail (IS_CAL_FACTORY (factory), 0); - - priv = factory->priv; - return g_hash_table_size (priv->backends); -} - -/* Frees a uri/backend pair from the backends hash table */ -static void -dump_backend (gpointer key, gpointer value, gpointer data) -{ - char *uri; - CalBackend *backend; - - uri = key; - backend = value; - - g_message (" %s: %p", uri, backend); -} - -void -cal_factory_dump_active_backends (CalFactory *factory) -{ - CalFactoryPrivate *priv; - - g_message ("Active PCS backends"); - - priv = factory->priv; - g_hash_table_foreach (priv->backends, dump_backend, NULL); -} diff --git a/calendar/pcs/cal-factory.h b/calendar/pcs/cal-factory.h deleted file mode 100644 index d6d2b895ed..0000000000 --- a/calendar/pcs/cal-factory.h +++ /dev/null @@ -1,74 +0,0 @@ -/* Evolution calendar factory - * - * Copyright (C) 2000 Ximian, Inc. - * - * Author: Federico Mena-Quintero <federico@ximian.com> - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of version 2 of the GNU General Public - * License as published by the Free Software Foundation. - * - * 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA. - */ - -#ifndef CAL_FACTORY_H -#define CAL_FACTORY_H - -#include <bonobo/bonobo-object.h> -#include <libical/ical.h> - -#include "pcs/evolution-calendar.h" - -G_BEGIN_DECLS - - - -#define CAL_FACTORY_TYPE (cal_factory_get_type ()) -#define CAL_FACTORY(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), CAL_FACTORY_TYPE, CalFactory)) -#define CAL_FACTORY_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), CAL_FACTORY_TYPE, \ - CalFactoryClass)) -#define IS_CAL_FACTORY(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), CAL_FACTORY_TYPE)) -#define IS_CAL_FACTORY_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), CAL_FACTORY_TYPE)) - -typedef struct _CalFactory CalFactory; -typedef struct _CalFactoryClass CalFactoryClass; - -typedef struct _CalFactoryPrivate CalFactoryPrivate; - -struct _CalFactory { - BonoboObject object; - - /* Private data */ - CalFactoryPrivate *priv; -}; - -struct _CalFactoryClass { - BonoboObjectClass parent_class; - - POA_GNOME_Evolution_Calendar_CalFactory__epv epv; - - /* Notification signals */ - void (* last_calendar_gone) (CalFactory *factory); -}; - -GType cal_factory_get_type (void); -CalFactory *cal_factory_new (void); - -gboolean cal_factory_register_storage (CalFactory *factory, const char *iid); -void cal_factory_register_method (CalFactory *factory, - const char *method, - icalcomponent_kind kind, - GType backend_type); -int cal_factory_get_n_backends (CalFactory *factory); -void cal_factory_dump_active_backends (CalFactory *factory); - -G_END_DECLS - -#endif diff --git a/calendar/pcs/cal.c b/calendar/pcs/cal.c deleted file mode 100644 index aec1591da3..0000000000 --- a/calendar/pcs/cal.c +++ /dev/null @@ -1,1244 +0,0 @@ -/* Evolution calendar client interface object - * - * Copyright (C) 2000 Ximian, Inc. - * Copyright (C) 2000 Ximian, Inc. - * - * Authors: Federico Mena-Quintero <federico@ximian.com> - * Rodrigo Moya <rodrigo@ximian.com> - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of version 2 of the GNU General Public - * License as published by the Free Software Foundation. - * - * 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA. - */ - -#ifdef HAVE_CONFIG_H -#include <config.h> -#endif - -#include <libical/ical.h> -#include <bonobo/bonobo-main.h> -#include <bonobo/bonobo-exception.h> -#include "cal-backend.h" -#include "cal.h" - -#define PARENT_TYPE BONOBO_TYPE_OBJECT - -static BonoboObjectClass *parent_class; - -/* Private part of the Cal structure */ -struct _CalPrivate { - /* Our backend */ - CalBackend *backend; - - /* Listener on the client we notify */ - GNOME_Evolution_Calendar_Listener listener; -}; - -/* Cal::get_uri method */ -static CORBA_char * -impl_Cal_get_uri (PortableServer_Servant servant, - CORBA_Environment *ev) -{ - Cal *cal; - CalPrivate *priv; - const char *str_uri; - CORBA_char *str_uri_copy; - - cal = CAL (bonobo_object_from_servant (servant)); - priv = cal->priv; - - str_uri = cal_backend_get_uri (priv->backend); - str_uri_copy = CORBA_string_dup (str_uri); - - return str_uri_copy; -} - -static void -impl_Cal_open (PortableServer_Servant servant, - CORBA_boolean only_if_exists, - CORBA_Environment *ev) -{ - Cal *cal; - CalPrivate *priv; - - cal = CAL (bonobo_object_from_servant (servant)); - priv = cal->priv; - - cal_backend_open (priv->backend, cal, only_if_exists); -} - -static void -impl_Cal_remove (PortableServer_Servant servant, - CORBA_Environment *ev) -{ - Cal *cal; - CalPrivate *priv; - - cal = CAL (bonobo_object_from_servant (servant)); - priv = cal->priv; - - cal_backend_remove (priv->backend, cal); -} - -/* Cal::isReadOnly method */ -static void -impl_Cal_isReadOnly (PortableServer_Servant servant, - CORBA_Environment *ev) -{ - Cal *cal; - CalPrivate *priv; - - cal = CAL (bonobo_object_from_servant (servant)); - priv = cal->priv; - - cal_backend_is_read_only (priv->backend, cal); -} - -/* Cal::getEmailAddress method */ -static void -impl_Cal_getCalAddress (PortableServer_Servant servant, - CORBA_Environment *ev) -{ - Cal *cal; - CalPrivate *priv; - - cal = CAL (bonobo_object_from_servant (servant)); - priv = cal->priv; - - cal_backend_get_cal_address (priv->backend, cal); -} - -/* Cal::get_alarm_email_address method */ -static void -impl_Cal_getAlarmEmailAddress (PortableServer_Servant servant, - CORBA_Environment *ev) -{ - Cal *cal; - CalPrivate *priv; - - cal = CAL (bonobo_object_from_servant (servant)); - priv = cal->priv; - - cal_backend_get_alarm_email_address (priv->backend, cal); -} - -/* Cal::get_ldap_attribute method */ -static void -impl_Cal_getLdapAttribute (PortableServer_Servant servant, - CORBA_Environment *ev) -{ - Cal *cal; - CalPrivate *priv; - - cal = CAL (bonobo_object_from_servant (servant)); - priv = cal->priv; - - cal_backend_get_ldap_attribute (priv->backend, cal); -} - -/* Cal::getSchedulingInformation method */ -static void -impl_Cal_getStaticCapabilities (PortableServer_Servant servant, - CORBA_Environment *ev) -{ - Cal *cal; - CalPrivate *priv; - - cal = CAL (bonobo_object_from_servant (servant)); - priv = cal->priv; - - cal_backend_get_static_capabilities (priv->backend, cal); -} - -/* Cal::setMode method */ -static void -impl_Cal_setMode (PortableServer_Servant servant, - GNOME_Evolution_Calendar_CalMode mode, - CORBA_Environment *ev) -{ - Cal *cal; - CalPrivate *priv; - - cal = CAL (bonobo_object_from_servant (servant)); - priv = cal->priv; - - cal_backend_set_mode (priv->backend, mode); -} - -static void -impl_Cal_getDefaultObject (PortableServer_Servant servant, - CORBA_Environment *ev) -{ - Cal *cal; - CalPrivate *priv; - - cal = CAL (bonobo_object_from_servant (servant)); - priv = cal->priv; - - cal_backend_get_default_object (priv->backend, cal); -} - -/* Cal::getObject method */ -static void -impl_Cal_getObject (PortableServer_Servant servant, - const CORBA_char *uid, - const CORBA_char *rid, - CORBA_Environment *ev) -{ - Cal *cal; - CalPrivate *priv; - - cal = CAL (bonobo_object_from_servant (servant)); - priv = cal->priv; - - cal_backend_get_object (priv->backend, cal, uid, rid); -} - -/* Cal::getObjectsInRange method */ -static void -impl_Cal_getObjectList (PortableServer_Servant servant, - const CORBA_char *query, - CORBA_Environment *ev) -{ - Cal *cal; - CalPrivate *priv; - - cal = CAL (bonobo_object_from_servant (servant)); - priv = cal->priv; - - cal_backend_get_object_list (priv->backend, cal, query); -} - -/* Cal::getChanges method */ -static void -impl_Cal_getChanges (PortableServer_Servant servant, - const CORBA_char *change_id, - CORBA_Environment *ev) -{ - Cal *cal; - CalPrivate *priv; - - cal = CAL (bonobo_object_from_servant (servant)); - priv = cal->priv; - - cal_backend_get_changes (priv->backend, cal, change_id); -} - -/* Cal::getFreeBusy method */ -static void -impl_Cal_getFreeBusy (PortableServer_Servant servant, - const GNOME_Evolution_Calendar_UserList *user_list, - const GNOME_Evolution_Calendar_Time_t start, - const GNOME_Evolution_Calendar_Time_t end, - CORBA_Environment *ev) -{ - Cal *cal; - CalPrivate *priv; - GList *users = NULL; - - cal = CAL (bonobo_object_from_servant (servant)); - priv = cal->priv; - - /* convert the CORBA user list to a GList */ - if (user_list) { - int i; - - for (i = 0; i < user_list->_length; i++) - users = g_list_append (users, user_list->_buffer[i]); - } - - /* call the backend's get_free_busy method */ - cal_backend_get_free_busy (priv->backend, cal, users, start, end); -} - -/* Cal::discardAlarm method */ -static void -impl_Cal_discardAlarm (PortableServer_Servant servant, - const CORBA_char *uid, - const CORBA_char *auid, - CORBA_Environment *ev) -{ - Cal *cal; - CalPrivate *priv; - - cal = CAL (bonobo_object_from_servant (servant)); - priv = cal->priv; - - cal_backend_discard_alarm (priv->backend, cal, uid, auid); -} - -static void -impl_Cal_createObject (PortableServer_Servant servant, - const CORBA_char *calobj, - CORBA_Environment *ev) -{ - Cal *cal; - CalPrivate *priv; - - cal = CAL (bonobo_object_from_servant (servant)); - priv = cal->priv; - - cal_backend_create_object (priv->backend, cal, calobj); -} - -static void -impl_Cal_modifyObject (PortableServer_Servant servant, - const CORBA_char *calobj, - const GNOME_Evolution_Calendar_CalObjModType mod, - CORBA_Environment *ev) -{ - Cal *cal; - CalPrivate *priv; - - cal = CAL (bonobo_object_from_servant (servant)); - priv = cal->priv; - - cal_backend_modify_object (priv->backend, cal, calobj, mod); -} - -/* Cal::removeObject method */ -static void -impl_Cal_removeObject (PortableServer_Servant servant, - const CORBA_char *uid, - const CORBA_char *rid, - const GNOME_Evolution_Calendar_CalObjModType mod, - CORBA_Environment *ev) -{ - Cal *cal; - CalPrivate *priv; - - cal = CAL (bonobo_object_from_servant (servant)); - priv = cal->priv; - - cal_backend_remove_object (priv->backend, cal, uid, rid, mod); -} - -static void -impl_Cal_receiveObjects (PortableServer_Servant servant, const CORBA_char *calobj, CORBA_Environment *ev) -{ - Cal *cal; - CalPrivate *priv; - - cal = CAL (bonobo_object_from_servant (servant)); - priv = cal->priv; - - cal_backend_receive_objects (priv->backend, cal, calobj); -} - -static void -impl_Cal_sendObjects (PortableServer_Servant servant, const CORBA_char *calobj, CORBA_Environment *ev) -{ - Cal *cal; - CalPrivate *priv; - - cal = CAL (bonobo_object_from_servant (servant)); - priv = cal->priv; - - cal_backend_send_objects (priv->backend, cal, calobj); -} - -/* Cal::getQuery implementation */ -static void -impl_Cal_getQuery (PortableServer_Servant servant, - const CORBA_char *sexp, - GNOME_Evolution_Calendar_QueryListener ql, - CORBA_Environment *ev) -{ - - Cal *cal; - CalPrivate *priv; - Query *query; - CalBackendObjectSExp *obj_sexp; - - cal = CAL (bonobo_object_from_servant (servant)); - priv = cal->priv; - - /* we handle this entirely here, since it doesn't require any - backend involvement now that we have pas_book_view_start to - actually kick off the search. */ - - obj_sexp = cal_backend_object_sexp_new (sexp); - if (!obj_sexp) { - cal_notify_query (cal, GNOME_Evolution_Calendar_InvalidQuery, NULL); - - return; - } - - query = query_new (priv->backend, ql, obj_sexp); - if (!query) { - g_object_unref (obj_sexp); - cal_notify_query (cal, GNOME_Evolution_Calendar_OtherError, NULL); - - return; - } - - cal_backend_add_query (priv->backend, query); - - cal_notify_query (cal, GNOME_Evolution_Calendar_Success, query); - - g_object_unref (query); -} - - -/* Cal::getTimezone method */ -static void -impl_Cal_getTimezone (PortableServer_Servant servant, - const CORBA_char *tzid, - CORBA_Environment *ev) -{ - Cal *cal; - CalPrivate *priv; - - cal = CAL (bonobo_object_from_servant (servant)); - priv = cal->priv; - - cal_backend_get_timezone (priv->backend, cal, tzid); -} - -/* Cal::addTimezone method */ -static void -impl_Cal_addTimezone (PortableServer_Servant servant, - const CORBA_char *tz, - CORBA_Environment *ev) -{ - Cal *cal; - CalPrivate *priv; - - cal = CAL (bonobo_object_from_servant (servant)); - priv = cal->priv; - - cal_backend_add_timezone (priv->backend, cal, tz); -} - -/* Cal::setDefaultTimezone method */ -static void -impl_Cal_setDefaultTimezone (PortableServer_Servant servant, - const CORBA_char *tzid, - CORBA_Environment *ev) -{ - Cal *cal; - CalPrivate *priv; - - cal = CAL (bonobo_object_from_servant (servant)); - priv = cal->priv; - - cal_backend_set_default_timezone (priv->backend, cal, tzid); -} - -/** - * cal_construct: - * @cal: A calendar client interface. - * @corba_cal: CORBA object for the calendar. - * @backend: Calendar backend that this @cal presents an interface to. - * @listener: Calendar listener for notification. - * - * Constructs a calendar client interface object by binding the corresponding - * CORBA object to it. The calendar interface is bound to the specified - * @backend, and will notify the @listener about changes to the calendar. - * - * Return value: The same object as the @cal argument. - **/ -Cal * -cal_construct (Cal *cal, - CalBackend *backend, - GNOME_Evolution_Calendar_Listener listener) -{ - CalPrivate *priv; - CORBA_Environment ev; - - g_return_val_if_fail (cal != NULL, NULL); - g_return_val_if_fail (IS_CAL (cal), NULL); - g_return_val_if_fail (backend != NULL, NULL); - g_return_val_if_fail (IS_CAL_BACKEND (backend), NULL); - - priv = cal->priv; - - CORBA_exception_init (&ev); - priv->listener = CORBA_Object_duplicate (listener, &ev); - if (BONOBO_EX (&ev)) { - g_message ("cal_construct: could not duplicate the listener"); - priv->listener = CORBA_OBJECT_NIL; - CORBA_exception_free (&ev); - return NULL; - } - - CORBA_exception_free (&ev); - - priv->backend = backend; - - return cal; -} - -/** - * cal_new: - * @backend: A calendar backend. - * @listener: A calendar listener. - * - * Creates a new calendar client interface object and binds it to the specified - * @backend and @listener objects. - * - * Return value: A newly-created #Cal calendar client interface object, or NULL - * if its corresponding CORBA object could not be created. - **/ -Cal * -cal_new (CalBackend *backend, const char *uri, GNOME_Evolution_Calendar_Listener listener) -{ - Cal *cal, *retval; - - g_return_val_if_fail (backend != NULL, NULL); - g_return_val_if_fail (IS_CAL_BACKEND (backend), NULL); - - cal = CAL (g_object_new (CAL_TYPE, - "poa", bonobo_poa_get_threaded (ORBIT_THREAD_HINT_PER_REQUEST, NULL), - NULL)); - - retval = cal_construct (cal, backend, listener); - if (!retval) { - g_message (G_STRLOC ": could not construct the calendar client interface"); - bonobo_object_unref (BONOBO_OBJECT (cal)); - return NULL; - } - - return retval; -} - -CalBackend * -cal_get_backend (Cal *cal) -{ - g_return_val_if_fail (cal != NULL, NULL); - g_return_val_if_fail (IS_CAL (cal), NULL); - - return cal->priv->backend; -} - -GNOME_Evolution_Calendar_Listener -cal_get_listener (Cal *cal) -{ - g_return_val_if_fail (cal != NULL, NULL); - g_return_val_if_fail (IS_CAL (cal), NULL); - - return cal->priv->listener; -} - -/* Destroy handler for the calendar */ -static void -cal_finalize (GObject *object) -{ - Cal *cal; - CalPrivate *priv; - CORBA_Environment ev; - - g_return_if_fail (object != NULL); - g_return_if_fail (IS_CAL (object)); - - cal = CAL (object); - priv = cal->priv; - - priv->backend = NULL; - - CORBA_exception_init (&ev); - bonobo_object_release_unref (priv->listener, &ev); - if (BONOBO_EX (&ev)) - g_message (G_STRLOC ": could not release the listener"); - - priv->listener = NULL; - CORBA_exception_free (&ev); - - g_free (priv); - - if (G_OBJECT_CLASS (parent_class)->finalize) - (* G_OBJECT_CLASS (parent_class)->finalize) (object); -} - - - -/* Class initialization function for the calendar */ -static void -cal_class_init (CalClass *klass) -{ - GObjectClass *object_class = (GObjectClass *) klass; - POA_GNOME_Evolution_Calendar_Cal__epv *epv = &klass->epv; - - parent_class = g_type_class_peek_parent (klass); - - /* Class method overrides */ - object_class->finalize = cal_finalize; - - /* Epv methods */ - epv->_get_uri = impl_Cal_get_uri; - epv->open = impl_Cal_open; - epv->remove = impl_Cal_remove; - epv->isReadOnly = impl_Cal_isReadOnly; - epv->getCalAddress = impl_Cal_getCalAddress; - epv->getAlarmEmailAddress = impl_Cal_getAlarmEmailAddress; - epv->getLdapAttribute = impl_Cal_getLdapAttribute; - epv->getStaticCapabilities = impl_Cal_getStaticCapabilities; - epv->setMode = impl_Cal_setMode; - epv->getDefaultObject = impl_Cal_getDefaultObject; - epv->getObject = impl_Cal_getObject; - epv->getTimezone = impl_Cal_getTimezone; - epv->addTimezone = impl_Cal_addTimezone; - epv->setDefaultTimezone = impl_Cal_setDefaultTimezone; - epv->getObjectList = impl_Cal_getObjectList; - epv->getChanges = impl_Cal_getChanges; - epv->getFreeBusy = impl_Cal_getFreeBusy; - epv->discardAlarm = impl_Cal_discardAlarm; - epv->createObject = impl_Cal_createObject; - epv->modifyObject = impl_Cal_modifyObject; - epv->removeObject = impl_Cal_removeObject; - epv->receiveObjects = impl_Cal_receiveObjects; - epv->sendObjects = impl_Cal_sendObjects; - epv->getQuery = impl_Cal_getQuery; -} - - -/* Object initialization function for the calendar */ -static void -cal_init (Cal *cal, CalClass *klass) -{ - CalPrivate *priv; - - priv = g_new0 (CalPrivate, 1); - cal->priv = priv; - - priv->listener = CORBA_OBJECT_NIL; -} - -BONOBO_TYPE_FUNC_FULL (Cal, GNOME_Evolution_Calendar_Cal, PARENT_TYPE, cal); - -void -cal_notify_read_only (Cal *cal, GNOME_Evolution_Calendar_CallStatus status, gboolean read_only) -{ - CalPrivate *priv; - CORBA_Environment ev; - - g_return_if_fail (cal != NULL); - g_return_if_fail (IS_CAL (cal)); - - priv = cal->priv; - g_return_if_fail (priv->listener != CORBA_OBJECT_NIL); - - CORBA_exception_init (&ev); - GNOME_Evolution_Calendar_Listener_notifyReadOnly (priv->listener, status, read_only, &ev); - - if (BONOBO_EX (&ev)) - g_message (G_STRLOC ": could not notify the listener of read only"); - - CORBA_exception_free (&ev); -} - -void -cal_notify_cal_address (Cal *cal, GNOME_Evolution_Calendar_CallStatus status, const char *address) -{ - CalPrivate *priv; - CORBA_Environment ev; - - g_return_if_fail (cal != NULL); - g_return_if_fail (IS_CAL (cal)); - - priv = cal->priv; - g_return_if_fail (priv->listener != CORBA_OBJECT_NIL); - - CORBA_exception_init (&ev); - GNOME_Evolution_Calendar_Listener_notifyCalAddress (priv->listener, status, address ? address : "", &ev); - - if (BONOBO_EX (&ev)) - g_message (G_STRLOC ": could not notify the listener of cal address"); - - CORBA_exception_free (&ev); -} - -void -cal_notify_alarm_email_address (Cal *cal, GNOME_Evolution_Calendar_CallStatus status, const char *address) -{ - CalPrivate *priv; - CORBA_Environment ev; - - g_return_if_fail (cal != NULL); - g_return_if_fail (IS_CAL (cal)); - - priv = cal->priv; - g_return_if_fail (priv->listener != CORBA_OBJECT_NIL); - - CORBA_exception_init (&ev); - GNOME_Evolution_Calendar_Listener_notifyAlarmEmailAddress (priv->listener, status, address ? address : "", &ev); - - if (BONOBO_EX (&ev)) - g_message (G_STRLOC ": could not notify the listener of alarm address"); - - CORBA_exception_free (&ev); -} - -void -cal_notify_ldap_attribute (Cal *cal, GNOME_Evolution_Calendar_CallStatus status, const char *attribute) -{ - CalPrivate *priv; - CORBA_Environment ev; - - g_return_if_fail (cal != NULL); - g_return_if_fail (IS_CAL (cal)); - - priv = cal->priv; - g_return_if_fail (priv->listener != CORBA_OBJECT_NIL); - - CORBA_exception_init (&ev); - GNOME_Evolution_Calendar_Listener_notifyLDAPAttribute (priv->listener, status, attribute ? attribute : "", &ev); - - if (BONOBO_EX (&ev)) - g_message (G_STRLOC ": could not notify the listener of ldap attribute"); - - CORBA_exception_free (&ev); -} - -void -cal_notify_static_capabilities (Cal *cal, GNOME_Evolution_Calendar_CallStatus status, const char *capabilities) -{ - CalPrivate *priv; - CORBA_Environment ev; - - g_return_if_fail (cal != NULL); - g_return_if_fail (IS_CAL (cal)); - - priv = cal->priv; - g_return_if_fail (priv->listener != CORBA_OBJECT_NIL); - - CORBA_exception_init (&ev); - GNOME_Evolution_Calendar_Listener_notifyStaticCapabilities (priv->listener, status, - capabilities ? capabilities : "", &ev); - - if (BONOBO_EX (&ev)) - g_message (G_STRLOC ": could not notify the listener of static capabilities"); - - CORBA_exception_free (&ev); -} - -void -cal_notify_open (Cal *cal, GNOME_Evolution_Calendar_CallStatus status) -{ - CalPrivate *priv; - CORBA_Environment ev; - - g_return_if_fail (cal != NULL); - g_return_if_fail (IS_CAL (cal)); - - priv = cal->priv; - g_return_if_fail (priv->listener != CORBA_OBJECT_NIL); - - CORBA_exception_init (&ev); - GNOME_Evolution_Calendar_Listener_notifyCalOpened (priv->listener, status, &ev); - - if (BONOBO_EX (&ev)) - g_message (G_STRLOC ": could not notify the listener of open"); - - CORBA_exception_free (&ev); -} - -void -cal_notify_remove (Cal *cal, GNOME_Evolution_Calendar_CallStatus status) -{ - CalPrivate *priv; - CORBA_Environment ev; - - g_return_if_fail (cal != NULL); - g_return_if_fail (IS_CAL (cal)); - - priv = cal->priv; - g_return_if_fail (priv->listener != CORBA_OBJECT_NIL); - - CORBA_exception_init (&ev); - GNOME_Evolution_Calendar_Listener_notifyCalRemoved (priv->listener, status, &ev); - - if (BONOBO_EX (&ev)) - g_message (G_STRLOC ": could not notify the listener of remove"); - - CORBA_exception_free (&ev); -} - -void -cal_notify_object_created (Cal *cal, GNOME_Evolution_Calendar_CallStatus status, - const char *uid, const char *object) -{ - CalPrivate *priv; - CORBA_Environment ev; - - g_return_if_fail (cal != NULL); - g_return_if_fail (IS_CAL (cal)); - - priv = cal->priv; - g_return_if_fail (priv->listener != CORBA_OBJECT_NIL); - - if (status == GNOME_Evolution_Calendar_Success) - cal_backend_notify_object_created (priv->backend, object); - - CORBA_exception_init (&ev); - GNOME_Evolution_Calendar_Listener_notifyObjectCreated (priv->listener, status, uid ? uid : "", &ev); - - if (BONOBO_EX (&ev)) - g_message (G_STRLOC ": could not notify the listener of object creation"); - - CORBA_exception_free (&ev); -} - -void -cal_notify_object_modified (Cal *cal, GNOME_Evolution_Calendar_CallStatus status, - const char *old_object, const char *object) -{ - CalPrivate *priv; - CORBA_Environment ev; - - g_return_if_fail (cal != NULL); - g_return_if_fail (IS_CAL (cal)); - - priv = cal->priv; - g_return_if_fail (priv->listener != CORBA_OBJECT_NIL); - - if (status == GNOME_Evolution_Calendar_Success) - cal_backend_notify_object_modified (priv->backend, old_object, object); - - CORBA_exception_init (&ev); - GNOME_Evolution_Calendar_Listener_notifyObjectModified (priv->listener, status, &ev); - - if (BONOBO_EX (&ev)) - g_message (G_STRLOC ": could not notify the listener of object creation"); - - CORBA_exception_free (&ev); -} - -void -cal_notify_object_removed (Cal *cal, GNOME_Evolution_Calendar_CallStatus status, - const char *uid, const char *object) -{ - CalPrivate *priv; - CORBA_Environment ev; - - g_return_if_fail (cal != NULL); - g_return_if_fail (IS_CAL (cal)); - - priv = cal->priv; - g_return_if_fail (priv->listener != CORBA_OBJECT_NIL); - - if (status == GNOME_Evolution_Calendar_Success) - cal_backend_notify_object_removed (priv->backend, uid, object); - - CORBA_exception_init (&ev); - GNOME_Evolution_Calendar_Listener_notifyObjectRemoved (priv->listener, status, &ev); - - if (BONOBO_EX (&ev)) - g_message (G_STRLOC ": could not notify the listener of object removal"); - - CORBA_exception_free (&ev); -} - -void -cal_notify_objects_received (Cal *cal, GNOME_Evolution_Calendar_CallStatus status) -{ - CalPrivate *priv; - CORBA_Environment ev; - - g_return_if_fail (cal != NULL); - g_return_if_fail (IS_CAL (cal)); - - priv = cal->priv; - g_return_if_fail (priv->listener != CORBA_OBJECT_NIL); - - CORBA_exception_init (&ev); - GNOME_Evolution_Calendar_Listener_notifyObjectsReceived (priv->listener, status, &ev); - - if (BONOBO_EX (&ev)) - g_message (G_STRLOC ": could not notify the listener of objects received"); - - CORBA_exception_free (&ev); -} - -void -cal_notify_alarm_discarded (Cal *cal, GNOME_Evolution_Calendar_CallStatus status) -{ - CalPrivate *priv; - CORBA_Environment ev; - - g_return_if_fail (cal != NULL); - g_return_if_fail (IS_CAL (cal)); - - priv = cal->priv; - g_return_if_fail (priv->listener != CORBA_OBJECT_NIL); - - CORBA_exception_init (&ev); - GNOME_Evolution_Calendar_Listener_notifyAlarmDiscarded (priv->listener, status, &ev); - - if (BONOBO_EX (&ev)) - g_message (G_STRLOC ": could not notify the listener of alarm discarded"); - - CORBA_exception_free (&ev); -} - -void -cal_notify_objects_sent (Cal *cal, GNOME_Evolution_Calendar_CallStatus status) -{ - CalPrivate *priv; - CORBA_Environment ev; - - g_return_if_fail (cal != NULL); - g_return_if_fail (IS_CAL (cal)); - - priv = cal->priv; - g_return_if_fail (priv->listener != CORBA_OBJECT_NIL); - - CORBA_exception_init (&ev); - GNOME_Evolution_Calendar_Listener_notifyObjectsSent (priv->listener, status, &ev); - - if (BONOBO_EX (&ev)) - g_message (G_STRLOC ": could not notify the listener of objects sent"); - - CORBA_exception_free (&ev); -} - -void -cal_notify_default_object (Cal *cal, GNOME_Evolution_Calendar_CallStatus status, char *object) -{ - CalPrivate *priv; - CORBA_Environment ev; - - g_return_if_fail (cal != NULL); - g_return_if_fail (IS_CAL (cal)); - - priv = cal->priv; - g_return_if_fail (priv->listener != CORBA_OBJECT_NIL); - - CORBA_exception_init (&ev); - - GNOME_Evolution_Calendar_Listener_notifyDefaultObjectRequested (priv->listener, status, - object ? object : "", &ev); - - if (BONOBO_EX (&ev)) - g_message (G_STRLOC ": could not notify the listener of default object"); - - CORBA_exception_free (&ev); -} - -void -cal_notify_object (Cal *cal, GNOME_Evolution_Calendar_CallStatus status, char *object) -{ - CalPrivate *priv; - CORBA_Environment ev; - - g_return_if_fail (cal != NULL); - g_return_if_fail (IS_CAL (cal)); - - priv = cal->priv; - g_return_if_fail (priv->listener != CORBA_OBJECT_NIL); - - CORBA_exception_init (&ev); - - GNOME_Evolution_Calendar_Listener_notifyObjectRequested (priv->listener, status, - object ? object : "", &ev); - - if (BONOBO_EX (&ev)) - g_message (G_STRLOC ": could not notify the listener of object"); - - CORBA_exception_free (&ev); -} - -void -cal_notify_object_list (Cal *cal, GNOME_Evolution_Calendar_CallStatus status, GList *objects) -{ - CalPrivate *priv; - CORBA_Environment ev; - GNOME_Evolution_Calendar_stringlist seq; - GList *l; - int i; - - g_return_if_fail (cal != NULL); - g_return_if_fail (IS_CAL (cal)); - - priv = cal->priv; - g_return_if_fail (priv->listener != CORBA_OBJECT_NIL); - - CORBA_exception_init (&ev); - - seq._maximum = g_list_length (objects); - seq._length = 0; - seq._buffer = GNOME_Evolution_Calendar_stringlist_allocbuf (seq._maximum); - - for (l = objects, i = 0; l; l = l->next, i++) { - seq._buffer[i] = CORBA_string_dup (l->data); - seq._length++; - } - - GNOME_Evolution_Calendar_Listener_notifyObjectListRequested (priv->listener, status, &seq, &ev); - - if (BONOBO_EX (&ev)) - g_message (G_STRLOC ": could not notify the listener of object list"); - - CORBA_exception_free (&ev); - - CORBA_free(seq._buffer); -} - -void -cal_notify_query (Cal *cal, GNOME_Evolution_Calendar_CallStatus status, Query *query) -{ - CalPrivate *priv; - CORBA_Environment ev; - - g_return_if_fail (cal != NULL); - g_return_if_fail (IS_CAL (cal)); - - priv = cal->priv; - g_return_if_fail (priv->listener != CORBA_OBJECT_NIL); - - CORBA_exception_init (&ev); - GNOME_Evolution_Calendar_Listener_notifyQuery (priv->listener, status, BONOBO_OBJREF (query), &ev); - - if (BONOBO_EX (&ev)) - g_message (G_STRLOC ": could not notify the listener of query"); - - CORBA_exception_free (&ev); -} - -void -cal_notify_timezone_requested (Cal *cal, GNOME_Evolution_Calendar_CallStatus status, const char *object) -{ - CalPrivate *priv; - CORBA_Environment ev; - - g_return_if_fail (IS_CAL (cal)); - - priv = cal->priv; - g_return_if_fail (priv->listener != CORBA_OBJECT_NIL); - - CORBA_exception_init (&ev); - GNOME_Evolution_Calendar_Listener_notifyTimezoneRequested (priv->listener, status, object ? object : "", &ev); - - if (BONOBO_EX (&ev)) - g_warning (G_STRLOC ": could not notify the listener of timezone requested"); - - CORBA_exception_free (&ev); -} - -void -cal_notify_timezone_added (Cal *cal, GNOME_Evolution_Calendar_CallStatus status, const char *tzid) -{ - CalPrivate *priv; - CORBA_Environment ev; - - g_return_if_fail (IS_CAL (cal)); - - priv = cal->priv; - g_return_if_fail (priv->listener != CORBA_OBJECT_NIL); - - CORBA_exception_init (&ev); - GNOME_Evolution_Calendar_Listener_notifyTimezoneAdded (priv->listener, status, tzid ? tzid : "", &ev); - - if (BONOBO_EX (&ev)) - g_warning (G_STRLOC ": could not notify the listener of timezone added"); - - CORBA_exception_free (&ev); -} - -void -cal_notify_default_timezone_set (Cal *cal, GNOME_Evolution_Calendar_CallStatus status) -{ - CalPrivate *priv; - CORBA_Environment ev; - - g_return_if_fail (IS_CAL (cal)); - - priv = cal->priv; - g_return_if_fail (priv->listener != CORBA_OBJECT_NIL); - - CORBA_exception_init (&ev); - GNOME_Evolution_Calendar_Listener_notifyDefaultTimezoneSet (priv->listener, status, &ev); - - if (BONOBO_EX (&ev)) - g_warning (G_STRLOC ": could not notify the listener of default timezone set"); - - CORBA_exception_free (&ev); -} - -void -cal_notify_changes (Cal *cal, GNOME_Evolution_Calendar_CallStatus status, - GList *adds, GList *modifies, GList *deletes) -{ - CalPrivate *priv; - CORBA_Environment ev; - GNOME_Evolution_Calendar_CalObjChangeSeq seq; - GList *l; - int n, i; - - g_return_if_fail (IS_CAL (cal)); - - priv = cal->priv; - g_return_if_fail (priv->listener != CORBA_OBJECT_NIL); - - n = g_list_length (adds) + g_list_length (modifies) + g_list_length (deletes); - seq._maximum = n; - seq._length = n; - seq._buffer = CORBA_sequence_GNOME_Evolution_Calendar_CalObjChange_allocbuf (n); - - i = 0; - for (l = adds; l; i++, l = l->next) { - GNOME_Evolution_Calendar_CalObjChange *change = &seq._buffer[i]; - - change->calobj = CORBA_string_dup (l->data); - change->type = GNOME_Evolution_Calendar_ADDED; - } - - for (l = modifies; l; i++, l = l->next) { - GNOME_Evolution_Calendar_CalObjChange *change = &seq._buffer[i]; - - change->calobj = CORBA_string_dup (l->data); - change->type = GNOME_Evolution_Calendar_MODIFIED; - } - - for (l = deletes; l; i++, l = l->next) { - GNOME_Evolution_Calendar_CalObjChange *change = &seq._buffer[i]; - - change->calobj = CORBA_string_dup (l->data); - change->type = GNOME_Evolution_Calendar_DELETED; - } - - CORBA_exception_init (&ev); - GNOME_Evolution_Calendar_Listener_notifyDefaultTimezoneSet (priv->listener, status, &ev); - - CORBA_free (seq._buffer); - - if (BONOBO_EX (&ev)) - g_warning (G_STRLOC ": could not notify the listener of default timezone set"); - - CORBA_exception_free (&ev); -} - -void -cal_notify_free_busy (Cal *cal, GNOME_Evolution_Calendar_CallStatus status, GList *freebusy) -{ - CalPrivate *priv; - CORBA_Environment ev; - GNOME_Evolution_Calendar_CalObjSeq seq; - GList *l; - int n, i; - - g_return_if_fail (IS_CAL (cal)); - - priv = cal->priv; - g_return_if_fail (priv->listener != CORBA_OBJECT_NIL); - - n = g_list_length (freebusy); - seq._maximum = n; - seq._length = n; - seq._buffer = CORBA_sequence_GNOME_Evolution_Calendar_CalObj_allocbuf (n); - - for (i = 0, l = freebusy; l; i++, l = l->next) - seq._buffer[i] = CORBA_string_dup (l->data); - - CORBA_exception_init (&ev); - GNOME_Evolution_Calendar_Listener_notifyDefaultTimezoneSet (priv->listener, status, &ev); - - CORBA_free (seq._buffer); - - if (BONOBO_EX (&ev)) - g_warning (G_STRLOC ": could not notify the listener of freebusy"); - - CORBA_exception_free (&ev); -} - -/** - * cal_notify_mode: - * @cal: A calendar client interface. - * @status: Status of the mode set. - * @mode: The current mode. - * - * Notifys the listener of the results of a setMode call. - **/ -void -cal_notify_mode (Cal *cal, - GNOME_Evolution_Calendar_Listener_SetModeStatus status, - GNOME_Evolution_Calendar_CalMode mode) -{ - CalPrivate *priv; - CORBA_Environment ev; - - g_return_if_fail (cal != NULL); - g_return_if_fail (IS_CAL (cal)); - - priv = cal->priv; - g_return_if_fail (priv->listener != CORBA_OBJECT_NIL); - - CORBA_exception_init (&ev); - GNOME_Evolution_Calendar_Listener_notifyCalSetMode (priv->listener, status, mode, &ev); - - if (BONOBO_EX (&ev)) - g_message ("cal_notify_mode(): could not notify the listener " - "about a mode change"); - - CORBA_exception_free (&ev); -} - -/** - * cal_notify_error - * @cal: A calendar client interface. - * @message: Error message. - * - * Notify a calendar client of an error occurred in the backend. - */ -void -cal_notify_error (Cal *cal, const char *message) -{ - CalPrivate *priv; - CORBA_Environment ev; - - g_return_if_fail (cal != NULL); - g_return_if_fail (IS_CAL (cal)); - g_return_if_fail (message != NULL); - - priv = cal->priv; - g_return_if_fail (priv->listener != CORBA_OBJECT_NIL); - - CORBA_exception_init (&ev); - GNOME_Evolution_Calendar_Listener_notifyErrorOccurred (priv->listener, (char *) message, &ev); - - if (BONOBO_EX (&ev)) - g_message ("cal_notify_remove(): could not notify the listener " - "about a removed object"); - - CORBA_exception_free (&ev); -} - -/** - * cal_notify_categories_changed: - * @cal: A calendar client interface. - * @categories: List of categories. - * - * Notifies a listener attached to a calendar client interface object about the - * current set of categories in a calendar backend. - **/ -void -cal_notify_categories_changed (Cal *cal, GNOME_Evolution_Calendar_StringSeq *categories) -{ - CalPrivate *priv; - CORBA_Environment ev; - - g_return_if_fail (cal != NULL); - g_return_if_fail (IS_CAL (cal)); - g_return_if_fail (categories != NULL); - - priv = cal->priv; - g_return_if_fail (priv->listener != CORBA_OBJECT_NIL); - - CORBA_exception_init (&ev); - GNOME_Evolution_Calendar_Listener_notifyCategoriesChanged (priv->listener, categories, &ev); - - if (BONOBO_EX (&ev)) - g_message ("cal_notify_categories_changed(): Could not notify the listener " - "about the current set of categories"); - - CORBA_exception_free (&ev); -} diff --git a/calendar/pcs/cal.h b/calendar/pcs/cal.h deleted file mode 100644 index f3d35f1f5f..0000000000 --- a/calendar/pcs/cal.h +++ /dev/null @@ -1,111 +0,0 @@ -/* Evolution calendar client interface object - * - * Copyright (C) 2000 Ximian, Inc. - * Copyright (C) 2000 Ximian, Inc. - * - * Authors: Federico Mena-Quintero <federico@ximian.com> - * Rodrigo Moya <rodrigo@ximian.com> - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of version 2 of the GNU General Public - * License as published by the Free Software Foundation. - * - * 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA. - */ - -#ifndef CAL_H -#define CAL_H - -#include <bonobo/bonobo-object.h> -#include "pcs/evolution-calendar.h" -#include "pcs/cal-common.h" -#include "pcs/query.h" - -G_BEGIN_DECLS - - - -#define CAL_TYPE (cal_get_type ()) -#define CAL(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), CAL_TYPE, Cal)) -#define CAL_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), CAL_TYPE, CalClass)) -#define IS_CAL(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), CAL_TYPE)) -#define IS_CAL_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), CAL_TYPE)) - -typedef struct _CalPrivate CalPrivate; - -struct _Cal { - BonoboObject object; - - /* Private data */ - CalPrivate *priv; -}; - -struct _CalClass { - BonoboObjectClass parent_class; - - POA_GNOME_Evolution_Calendar_Cal__epv epv; -}; - -GType cal_get_type (void); - -Cal *cal_construct (Cal *cal, - CalBackend *backend, - GNOME_Evolution_Calendar_Listener listener); - -Cal *cal_new (CalBackend *backend, const char *uri, GNOME_Evolution_Calendar_Listener listener); - -CalBackend *cal_get_backend (Cal *cal); -GNOME_Evolution_Calendar_Listener cal_get_listener (Cal *cal); - -void cal_notify_read_only (Cal *cal, GNOME_Evolution_Calendar_CallStatus status, gboolean read_only); -void cal_notify_cal_address (Cal *cal, GNOME_Evolution_Calendar_CallStatus status, const char *address); -void cal_notify_alarm_email_address (Cal *cal, GNOME_Evolution_Calendar_CallStatus status, const char *address); -void cal_notify_ldap_attribute (Cal *cal, GNOME_Evolution_Calendar_CallStatus status, const char *attribute); -void cal_notify_static_capabilities (Cal *cal, GNOME_Evolution_Calendar_CallStatus status, const char *capabilities); - -void cal_notify_open (Cal *cal, GNOME_Evolution_Calendar_CallStatus status); -void cal_notify_remove (Cal *cal, GNOME_Evolution_Calendar_CallStatus status); - -void cal_notify_object_created (Cal *cal, GNOME_Evolution_Calendar_CallStatus status, - const char *uid, const char *object); -void cal_notify_object_modified (Cal *cal, GNOME_Evolution_Calendar_CallStatus status, - const char *old_object, const char *object); -void cal_notify_object_removed (Cal *cal, GNOME_Evolution_Calendar_CallStatus status, - const char *uid, const char *object); -void cal_notify_alarm_discarded (Cal *cal, GNOME_Evolution_Calendar_CallStatus status); - -void cal_notify_objects_received (Cal *cal, GNOME_Evolution_Calendar_CallStatus status); -void cal_notify_objects_sent (Cal *cal, GNOME_Evolution_Calendar_CallStatus status); - -void cal_notify_default_object (Cal *cal, GNOME_Evolution_Calendar_CallStatus status, char *object); -void cal_notify_object (Cal *cal, GNOME_Evolution_Calendar_CallStatus status, char *object); -void cal_notify_object_list (Cal *cal, GNOME_Evolution_Calendar_CallStatus status, GList *objects); - -void cal_notify_query (Cal *cal, GNOME_Evolution_Calendar_CallStatus status, Query *query); - -void cal_notify_timezone_requested (Cal *cal, GNOME_Evolution_Calendar_CallStatus status, const char *object); -void cal_notify_timezone_added (Cal *cal, GNOME_Evolution_Calendar_CallStatus status, const char *tzid); -void cal_notify_default_timezone_set (Cal *cal, GNOME_Evolution_Calendar_CallStatus status); - -void cal_notify_changes (Cal *cal, GNOME_Evolution_Calendar_CallStatus status, GList *adds, GList *modifies, GList *deletes); -void cal_notify_free_busy (Cal *cal, GNOME_Evolution_Calendar_CallStatus status, GList *freebusy); - -void cal_notify_mode (Cal *cal, - GNOME_Evolution_Calendar_Listener_SetModeStatus status, - GNOME_Evolution_Calendar_CalMode mode); -void cal_notify_error (Cal *cal, const char *message); - -void cal_notify_categories_changed (Cal *cal, GNOME_Evolution_Calendar_StringSeq *categories); - - - -G_END_DECLS - -#endif diff --git a/calendar/pcs/query.c b/calendar/pcs/query.c deleted file mode 100644 index 453c1cc4ce..0000000000 --- a/calendar/pcs/query.c +++ /dev/null @@ -1,492 +0,0 @@ -/* Evolution calendar - Live search query implementation - * - * Copyright (C) 2001 Ximian, Inc. - * - * Author: Federico Mena-Quintero <federico@ximian.com> - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of version 2 of the GNU General Public - * License as published by the Free Software Foundation. - * - * 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA. - */ - -#ifdef HAVE_CONFIG_H -#include <config.h> -#endif - -#include <glib.h> -#include <bonobo/bonobo-exception.h> -#include <e-util/e-component-listener.h> -#include <pcs/cal-backend-object-sexp.h> -#include "query.h" - - - -/* Private part of the Query structure */ -struct _QueryPrivate { - /* The backend we are monitoring */ - CalBackend *backend; - - /* The listener we report to */ - GNOME_Evolution_Calendar_QueryListener listener; - EComponentListener *component_listener; - - /* Sexp that defines the query */ - CalBackendObjectSExp *sexp; -}; - - - - -static void query_class_init (QueryClass *class); -static void query_init (Query *query, QueryClass *class); -static void query_finalize (GObject *object); - -static BonoboObjectClass *parent_class; - - - -BONOBO_TYPE_FUNC_FULL (Query, - GNOME_Evolution_Calendar_Query, - BONOBO_TYPE_OBJECT, - query); - -/* Property IDs */ -enum props { - PROP_0, - PROP_BACKEND, - PROP_LISTENER, - PROP_SEXP -}; - - -static void -listener_died_cb (EComponentListener *cl, gpointer data) -{ - Query *query = QUERY (data); - QueryPrivate *priv; - - priv = query->priv; - - g_object_unref (priv->component_listener); - priv->component_listener = NULL; - - bonobo_object_release_unref (priv->listener, NULL); - priv->listener = NULL; -} - -static void -impl_Query_start (PortableServer_Servant servant, CORBA_Environment *ev) -{ - Query *query; - QueryPrivate *priv; - - query = QUERY (bonobo_object_from_servant (servant)); - priv = query->priv; - - cal_backend_start_query (priv->backend, query); -} - -static void -query_set_property (GObject *object, guint property_id, const GValue *value, GParamSpec *pspec) -{ - Query *query; - QueryPrivate *priv; - CORBA_Environment ev; - - query = QUERY (object); - priv = query->priv; - - switch (property_id) { - case PROP_BACKEND: - priv->backend = CAL_BACKEND (g_value_dup_object (value)); - break; - case PROP_LISTENER: - CORBA_exception_init (&ev); - priv->listener = CORBA_Object_duplicate (g_value_get_pointer (value), &ev); - CORBA_exception_free (&ev); - - priv->component_listener = e_component_listener_new (priv->listener); - g_signal_connect (G_OBJECT (priv->component_listener), "component_died", - G_CALLBACK (listener_died_cb), query); - break; - case PROP_SEXP: - priv->sexp = CAL_BACKEND_OBJECT_SEXP (g_value_dup_object (value)); - break; - default: - G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec); - break; - } -} - -static void -query_get_property (GObject *object, guint property_id, GValue *value, GParamSpec *pspec) -{ - Query *query; - QueryPrivate *priv; - - query = QUERY (object); - priv = query->priv; - - switch (property_id) { - case PROP_BACKEND: - g_value_set_object (value, priv->backend); - case PROP_LISTENER: - g_value_set_pointer (value, priv->listener); - break; - case PROP_SEXP: - g_value_set_object (value, priv->sexp); - break; - default: - G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec); - break; - } -} - -/* Class initialization function for the live search query */ -static void -query_class_init (QueryClass *klass) -{ - GObjectClass *object_class; - POA_GNOME_Evolution_Calendar_Query__epv *epv = &klass->epv; - GParamSpec *param; - - object_class = (GObjectClass *) klass; - - parent_class = g_type_class_peek_parent (klass); - - object_class->set_property = query_set_property; - object_class->get_property = query_get_property; - object_class->finalize = query_finalize; - - epv->start = impl_Query_start; - - param = g_param_spec_object ("backend", NULL, NULL, CAL_BACKEND_TYPE, - G_PARAM_READABLE | G_PARAM_WRITABLE | G_PARAM_CONSTRUCT_ONLY); - g_object_class_install_property (object_class, PROP_BACKEND, param); - param = g_param_spec_pointer ("listener", NULL, NULL, - G_PARAM_READABLE | G_PARAM_WRITABLE | G_PARAM_CONSTRUCT_ONLY); - g_object_class_install_property (object_class, PROP_LISTENER, param); - param = g_param_spec_object ("sexp", NULL, NULL, CAL_TYPE_BACKEND_OBJECT_SEXP, - G_PARAM_READABLE | G_PARAM_WRITABLE | G_PARAM_CONSTRUCT_ONLY); - g_object_class_install_property (object_class, PROP_SEXP, param); -} - -/* Object initialization function for the live search query */ -static void -query_init (Query *query, QueryClass *class) -{ - QueryPrivate *priv; - - priv = g_new0 (QueryPrivate, 1); - query->priv = priv; - - priv->backend = NULL; - priv->listener = NULL; - priv->component_listener = NULL; - priv->sexp = NULL; -} - -/* Finalize handler for the live search query */ -static void -query_finalize (GObject *object) -{ - Query *query; - QueryPrivate *priv; - - g_return_if_fail (object != NULL); - g_return_if_fail (IS_QUERY (object)); - - query = QUERY (object); - priv = query->priv; - - if (priv->backend) - g_object_unref (priv->backend); - - if (priv->listener != NULL) - bonobo_object_release_unref (priv->listener, NULL); - - if (priv->component_listener != NULL) - g_object_unref (priv->component_listener); - - if (priv->sexp) - g_object_unref (priv->sexp); - - g_free (priv); - - if (G_OBJECT_CLASS (parent_class)->finalize) - (* G_OBJECT_CLASS (parent_class)->finalize) (object); -} - -/** - * query_new: - * @backend: Calendar backend that the query object will monitor. - * @ql: Listener for query results. - * @sexp: Sexp that defines the query. - * - * Creates a new query engine object that monitors a calendar backend. - * - * Return value: A newly-created query object, or NULL on failure. - **/ -Query * -query_new (CalBackend *backend, - GNOME_Evolution_Calendar_QueryListener ql, - CalBackendObjectSExp *sexp) -{ - Query *query; - - query = g_object_new (QUERY_TYPE, "backend", backend, "listener", ql, - "sexp", sexp, NULL); - - return query; -} - -/** - * query_get_sexp - * @query: A #Query object. - * - * Get the expression used for the given query. - * - * Returns: the query expression used to search. - */ -const char * -query_get_text (Query *query) -{ - g_return_val_if_fail (IS_QUERY (query), NULL); - - return cal_backend_object_sexp_text (query->priv->sexp); -} - -CalBackendObjectSExp * -query_get_object_sexp (Query *query) -{ - g_return_val_if_fail (IS_QUERY (query), NULL); - - return query->priv->sexp; -} - -gboolean -query_object_matches (Query *query, const char *object) -{ - QueryPrivate *priv; - - g_return_val_if_fail (query != NULL, FALSE); - g_return_val_if_fail (IS_QUERY (query), FALSE); - g_return_val_if_fail (object != NULL, FALSE); - - priv = query->priv; - - return cal_backend_object_sexp_match_object (priv->sexp, object, priv->backend); -} - -void -query_notify_objects_added (Query *query, const GList *objects) -{ - QueryPrivate *priv; - GNOME_Evolution_Calendar_stringlist obj_list; - CORBA_Environment ev; - const GList *l; - int num_objs, i; - - g_return_if_fail (query != NULL); - g_return_if_fail (IS_QUERY (query)); - - priv = query->priv; - g_return_if_fail (priv->listener != CORBA_OBJECT_NIL); - - CORBA_exception_init (&ev); - - num_objs = g_list_length ((GList*)objects); - obj_list._buffer = GNOME_Evolution_Calendar_stringlist_allocbuf (num_objs); - obj_list._maximum = num_objs; - obj_list._length = num_objs; - - for (l = objects, i = 0; l; l = l->next, i++) - obj_list._buffer[i] = CORBA_string_dup (l->data); - - GNOME_Evolution_Calendar_QueryListener_notifyObjectsAdded (priv->listener, &obj_list, &ev); - - CORBA_free (obj_list._buffer); - - if (BONOBO_EX (&ev)) - g_warning (G_STRLOC ": could not notify the listener of object addition"); - - CORBA_exception_free (&ev); -} - -void -query_notify_objects_added_1 (Query *query, const char *object) -{ - QueryPrivate *priv; - GList objects; - - g_return_if_fail (query != NULL); - g_return_if_fail (IS_QUERY (query)); - - priv = query->priv; - g_return_if_fail (priv->listener != CORBA_OBJECT_NIL); - - objects.next = objects.prev = NULL; - objects.data = (gpointer)object; - - query_notify_objects_added (query, &objects); -} - -void -query_notify_objects_modified (Query *query, const GList *objects) -{ - QueryPrivate *priv; - GNOME_Evolution_Calendar_CalObjUIDSeq obj_list; - CORBA_Environment ev; - const GList *l; - int num_objs, i; - - g_return_if_fail (query != NULL); - g_return_if_fail (IS_QUERY (query)); - - priv = query->priv; - g_return_if_fail (priv->listener != CORBA_OBJECT_NIL); - - CORBA_exception_init (&ev); - - num_objs = g_list_length ((GList*)objects); - obj_list._buffer = GNOME_Evolution_Calendar_stringlist_allocbuf (num_objs); - obj_list._maximum = num_objs; - obj_list._length = num_objs; - - for (l = objects, i = 0; l; l = l->next, i++) - obj_list._buffer[i] = CORBA_string_dup (l->data); - - GNOME_Evolution_Calendar_QueryListener_notifyObjectsModified (priv->listener, &obj_list, &ev); - - CORBA_free (obj_list._buffer); - - if (BONOBO_EX (&ev)) - g_warning (G_STRLOC ": could not notify the listener of object modification"); - - CORBA_exception_free (&ev); -} - -void -query_notify_objects_modified_1 (Query *query, const char *object) -{ - QueryPrivate *priv; - GList objects; - - g_return_if_fail (query != NULL); - g_return_if_fail (IS_QUERY (query)); - - priv = query->priv; - g_return_if_fail (priv->listener != CORBA_OBJECT_NIL); - - objects.next = objects.prev = NULL; - objects.data = (gpointer)object; - - query_notify_objects_modified (query, &objects); -} - -void -query_notify_objects_removed (Query *query, const GList *uids) -{ - QueryPrivate *priv; - GNOME_Evolution_Calendar_CalObjUIDSeq uid_list; - CORBA_Environment ev; - const GList *l; - int num_uids, i; - - g_return_if_fail (query != NULL); - g_return_if_fail (IS_QUERY (query)); - - priv = query->priv; - g_return_if_fail (priv->listener != CORBA_OBJECT_NIL); - - CORBA_exception_init (&ev); - - num_uids = g_list_length ((GList*)uids); - uid_list._buffer = GNOME_Evolution_Calendar_CalObjUIDSeq_allocbuf (num_uids); - uid_list._maximum = num_uids; - uid_list._length = num_uids; - - for (l = uids, i = 0; l; l = l->next, i ++) - uid_list._buffer[i] = CORBA_string_dup (l->data); - - GNOME_Evolution_Calendar_QueryListener_notifyObjectsRemoved (priv->listener, &uid_list, &ev); - - CORBA_free (uid_list._buffer); - - if (BONOBO_EX (&ev)) - g_warning (G_STRLOC ": could not notify the listener of object removal"); - - - CORBA_exception_free (&ev); -} - -void -query_notify_objects_removed_1 (Query *query, const char *uid) -{ - QueryPrivate *priv; - GList uids; - - g_return_if_fail (query != NULL); - g_return_if_fail (IS_QUERY (query)); - - priv = query->priv; - g_return_if_fail (priv->listener != CORBA_OBJECT_NIL); - - uids.next = uids.prev = NULL; - uids.data = (gpointer)uid; - - query_notify_objects_removed (query, &uids); -} - -void -query_notify_query_progress (Query *query, const char *message, int percent) -{ - QueryPrivate *priv; - CORBA_Environment ev; - - g_return_if_fail (query != NULL); - g_return_if_fail (IS_QUERY (query)); - - priv = query->priv; - g_return_if_fail (priv->listener != CORBA_OBJECT_NIL); - - CORBA_exception_init (&ev); - - GNOME_Evolution_Calendar_QueryListener_notifyQueryProgress (priv->listener, message, percent, &ev); - - if (BONOBO_EX (&ev)) - g_warning (G_STRLOC ": could not notify the listener of query progress"); - - CORBA_exception_free (&ev); -} - -void -query_notify_query_done (Query *query, GNOME_Evolution_Calendar_CallStatus status) -{ - QueryPrivate *priv; - CORBA_Environment ev; - - g_return_if_fail (query != NULL); - g_return_if_fail (IS_QUERY (query)); - - priv = query->priv; - g_return_if_fail (priv->listener != CORBA_OBJECT_NIL); - - CORBA_exception_init (&ev); - - GNOME_Evolution_Calendar_QueryListener_notifyQueryDone (priv->listener, status, &ev); - - if (BONOBO_EX (&ev)) - g_warning (G_STRLOC ": could not notify the listener of query completion"); - - CORBA_exception_free (&ev); -} diff --git a/calendar/pcs/query.h b/calendar/pcs/query.h deleted file mode 100644 index 9c03aa2661..0000000000 --- a/calendar/pcs/query.h +++ /dev/null @@ -1,81 +0,0 @@ -/* Evolution calendar - Live search query implementation - * - * Copyright (C) 2001 Ximian, Inc. - * - * Author: Federico Mena-Quintero <federico@ximian.com> - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of version 2 of the GNU General Public - * License as published by the Free Software Foundation. - * - * 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA. - */ - -#ifndef QUERY_H -#define QUERY_H - -#include <bonobo/bonobo-object.h> -#include "pcs/cal-common.h" -#include "pcs/evolution-calendar.h" -#include "cal-backend-object-sexp.h" - -G_BEGIN_DECLS - - - -#define QUERY_TYPE (query_get_type ()) -#define QUERY(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), QUERY_TYPE, Query)) -#define QUERY_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), QUERY_TYPE, QueryClass)) -#define IS_QUERY(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), QUERY_TYPE)) -#define IS_QUERY_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), QUERY_TYPE)) - -typedef struct _QueryPrivate QueryPrivate; - -struct _Query { - BonoboObject xobject; - - /* Private data */ - QueryPrivate *priv; -}; - -struct _QueryClass { - BonoboObjectClass parent_class; - - POA_GNOME_Evolution_Calendar_Query__epv epv; -}; - -GType query_get_type (void); -Query *query_new (CalBackend *backend, - GNOME_Evolution_Calendar_QueryListener ql, - CalBackendObjectSExp *sexp); -const char *query_get_text (Query *query); -CalBackendObjectSExp *query_get_object_sexp (Query *query); -gboolean query_object_matches (Query *query, const char *object); -void query_notify_objects_added (Query *query, - const GList *objects); -void query_notify_objects_added_1 (Query *query, - const char *object); -void query_notify_objects_modified (Query *query, - const GList *objects); -void query_notify_objects_modified_1 (Query *query, - const char *object); -void query_notify_objects_removed (Query *query, - const GList *uids); -void query_notify_objects_removed_1 (Query *query, - const char *uid); -void query_notify_query_progress (Query *query, - const char *message, - int percent); -void query_notify_query_done (Query *query, - GNOME_Evolution_Calendar_CallStatus status); - -G_END_DECLS - -#endif diff --git a/configure.in b/configure.in index eb6f08eba6..51a736131c 100644 --- a/configure.in +++ b/configure.in @@ -1077,7 +1077,7 @@ esac AM_PATH_ORBIT2(2.8.0) AC_MSG_CHECKING(for CORBA include paths) -IDL_INCLUDES="-I "`pkg-config --variable=idldir libbonobo-2.0`" -I "`pkg-config --variable=idldir bonobo-activation-2.0` +IDL_INCLUDES="-I "`pkg-config --variable=idldir libbonobo-2.0`" -I "`pkg-config --variable=idldir bonobo-activation-2.0`" -I "`pkg-config --variable=idldir evolution-data-server-1.0` AC_MSG_RESULT($IDL_INCLUDES) AC_SUBST(IDL_INCLUDES) @@ -1115,6 +1115,10 @@ CPPFLAGS="$CPPFLAGS_save" dnl --- Flags for the various libraries we build +EVO_SET_COMPILE_FLAGS(TZDIALOG, libecal-1.0, $GNOME_FULL_CFLAGS, $GNOME_FULL_LIBS) +AC_SUBST(TZDIALOG_CFLAGS) +AC_SUBST(TZDIALOG_LIBS) + EVO_SET_COMPILE_FLAGS(CAMEL, glib-2.0 gthread-2.0 gal-2.2 >= $GAL_REQUIRED $mozilla_nss, $THREADS_CFLAGS $KRB4_CFLAGS $KRB5_CFLAGS $MANUAL_NSS_CFLAGS $OPENSSL_CFLAGS, $THREADS_LIBS $KRB4_LDFLAGS $KRB5_LDFLAGS $MANUAL_NSS_LIBS $OPENSSL_LDFLAGS) @@ -1165,7 +1169,7 @@ AC_SUBST(SHELL_LIBS) dnl --- evolution-addressbook flags -EVOLUTION_ADDRESSBOOK_DEPS="gconf-2.0 libbonoboui-2.0 libglade-2.0 gal-2.2 >= $GAL_REQUIRED libgnomeui-2.0 libgnome-2.0 libgnomecanvas-2.0 gnome-vfs-2.0 libgnomeprintui-2.2 libgtkhtml-3.1 >= $GTKHTML_REQUIRED" +EVOLUTION_ADDRESSBOOK_DEPS="gconf-2.0 libbonoboui-2.0 libglade-2.0 gal-2.2 >= $GAL_REQUIRED libgnomeui-2.0 libgnome-2.0 libgnomecanvas-2.0 gnome-vfs-2.0 libgnomeprintui-2.2 libgtkhtml-3.1 >= $GTKHTML_REQUIRED libebook-1.0" EVO_SET_COMPILE_FLAGS(EVOLUTION_ADDRESSBOOK, $EVOLUTION_ADDRESSBOOK_DEPS) AC_SUBST(EVOLUTION_ADDRESSBOOK_CFLAGS) @@ -1179,27 +1183,33 @@ fi dnl --- evolution-calendar flags -EVO_SET_COMPILE_FLAGS(EVOLUTION_CALENDAR, libgnome-2.0 libgnomeui-2.0 libbonoboui-2.0 gal-2.2 >= $GAL_REQUIRED libglade-2.0 gnome-vfs-2.0 libgnomeprint-2.2 libgnomeprintui-2.2 libgtkhtml-3.1 >= $GTKHTML_REQUIRED, ${GTKHTML_CFLAGS}, ${GTKHTML_LIBS}) +EVO_SET_COMPILE_FLAGS(EVOLUTION_CALENDAR, libgnome-2.0 libgnomeui-2.0 libbonoboui-2.0 gal-2.2 >= $GAL_REQUIRED libglade-2.0 gnome-vfs-2.0 libgnomeprint-2.2 libgnomeprintui-2.2 libgtkhtml-3.1 >= $GTKHTML_REQUIRED libebook-1.0 libecal-1.0) AC_SUBST(EVOLUTION_CALENDAR_CFLAGS) AC_SUBST(EVOLUTION_CALENDAR_LIBS) if test x$enable_pilot_conduits = xyes; then -EVO_SET_COMPILE_FLAGS(EVOLUTION_CALENDAR_CONDUIT, gnome-pilot-2.0 $EVOLUTION_CALENDAR_DEPS) +EVO_SET_COMPILE_FLAGS(EVOLUTION_CALENDAR_CONDUIT, gnome-pilot-2.0, $EVOLUTION_CALENDAR_CFLAGS, $EVOLUTION_CALENDAR_LIBS) AC_SUBST(EVOLUTION_CALENDAR_CONDUIT_CFLAGS) AC_SUBST(EVOLUTION_CALENDAR_CONDUIT_LIBS) fi dnl --- evolution-mail flags -EVO_SET_COMPILE_FLAGS(EVOLUTION_MAIL, libgnome-2.0 libgnomeui-2.0 libbonoboui-2.0 gal-2.2 >= $GAL_REQUIRED libglade-2.0 gnome-vfs-module-2.0 libgnomeprint-2.2 libgnomeprintui-2.2 libgtkhtml-3.1 >= $GTKHTML_REQUIRED libxml-2.0 bonobo-activation-2.0 gthread-2.0 gconf-2.0 $mozilla_nss) +EVO_SET_COMPILE_FLAGS(EVOLUTION_MAIL, libgnome-2.0 libgnomeui-2.0 libbonoboui-2.0 gal-2.2 >= $GAL_REQUIRED libglade-2.0 gnome-vfs-module-2.0 libgnomeprint-2.2 libgnomeprintui-2.2 libgtkhtml-3.1 >= $GTKHTML_REQUIRED libxml-2.0 bonobo-activation-2.0 gthread-2.0 gconf-2.0 $mozilla_nss libebook-1.0) AC_SUBST(EVOLUTION_MAIL_CFLAGS) AC_SUBST(EVOLUTION_MAIL_LIBS) -dnl -- wombat flags +dnl -- evolution-data-server IDL -EVO_SET_COMPILE_FLAGS(WOMBAT, gal-2.2 libgnome-2.0, $LDAP_CFLAGS, $LDAP_LIBS) -AC_SUBST(WOMBAT_CFLAGS) -AC_SUBST(WOMBAT_LIBS) +AC_MSG_CHECKING(for evolution-data-server IDL) +DATASERVER_IDL=`pkg-config --variable=idldir evolution-data-server-1.0`/Evolution-DataServer.idl +echo $DATASERVER_IDL +if test -f "$DATASERVER_IDL"; then + AC_MSG_RESULT($DATASERVER_IDL) + AC_SUBST(DATASERVER_IDL) +else + AC_MSG_ERROR(no) +fi dnl ******************* dnl Special directories @@ -1374,13 +1384,6 @@ addressbook/gui/contact-list-editor/Makefile addressbook/gui/merging/Makefile addressbook/gui/search/Makefile addressbook/gui/widgets/Makefile -addressbook/backend/Makefile -addressbook/backend/ebook/Makefile -addressbook/backend/ebook/tests/Makefile -addressbook/backend/ebook/tests/ebook/Makefile -addressbook/backend/ebook/tests/vcard/Makefile -addressbook/backend/pas/Makefile -addressbook/backend/idl/Makefile addressbook/conduit/Makefile addressbook/printing/Makefile addressbook/util/Makefile @@ -1444,16 +1447,12 @@ widgets/Makefile widgets/e-timezone-dialog/Makefile widgets/menus/Makefile widgets/misc/Makefile -wombat/Makefile calendar/Makefile calendar/importers/Makefile calendar/idl/Makefile -calendar/cal-util/Makefile -calendar/cal-client/Makefile calendar/conduits/Makefile calendar/conduits/todo/Makefile calendar/conduits/calendar/Makefile -calendar/pcs/Makefile calendar/gui/Makefile calendar/gui/alarm-notify/Makefile calendar/gui/dialogs/Makefile @@ -1464,8 +1463,6 @@ smime/lib/Makefile smime/gui/Makefile tools/Makefile evolution-shell.pc -evolution-addressbook.pc -evolution-calendar.pc camel.pc ]) diff --git a/e-util/ename/Makefile.am b/e-util/ename/Makefile.am index 1909e191ec..1986eae133 100644 --- a/e-util/ename/Makefile.am +++ b/e-util/ename/Makefile.am @@ -12,19 +12,14 @@ ename_libs = \ libename.la \ $(E_NAME_LIBS) -privlib_LTLIBRARIES = libename.la +noinst_LTLIBRARIES = libename.la libename_la_SOURCES = \ - e-address-western.c \ - e-name-western.c - -libenameincludedir = $(privincludedir)/ename - -libenameinclude_HEADERS = \ e-address-western.h \ e-name-western-tables.h \ - e-name-western.h - + e-name-western.h \ + e-address-western.c \ + e-name-western.c noinst_PROGRAMS = \ test-ename-western \ diff --git a/evolution-addressbook.pc.in b/evolution-addressbook.pc.in deleted file mode 100644 index 69b68c918e..0000000000 --- a/evolution-addressbook.pc.in +++ /dev/null @@ -1,17 +0,0 @@ -prefix=@prefix@ -exec_prefix=@exec_prefix@ -libdir=@libdir@ -includedir=@includedir@ - -idldir=@idldir@ -IDL_INCLUDES=-I ${idldir} @IDL_INCLUDES@ - -privlibdir=@privlibdir@ -privincludedir=@privincludedir@ - -Name: evolution-addressbook -Description: libraries needed for Evolution addressbook backends -Version: @VERSION@ -Requires: gconf-2.0 libbonobo-2.0 gal-2.2 >= @GAL_REQUIRED@ libgnome-2.0 camel = @VERSION@ -Libs: -L${privlibdir} -lpas -lebook -lename -lversit -Cflags: -I${privincludedir} diff --git a/evolution-calendar.pc.in b/evolution-calendar.pc.in deleted file mode 100644 index 28042a122b..0000000000 --- a/evolution-calendar.pc.in +++ /dev/null @@ -1,17 +0,0 @@ -prefix=@prefix@ -exec_prefix=@exec_prefix@ -libdir=@libdir@ -includedir=@includedir@ - -idldir=@idldir@ -IDL_INCLUDES=-I ${idldir} @IDL_INCLUDES@ - -privlibdir=@privlibdir@ -privincludedir=@privincludedir@ - -Name: evolution-calendar -Description: libraries needed for Evolution calendar backends -Version: @VERSION@ -Requires: libgnome-2.0 libbonobo-2.0 gal-2.2 >= @GAL_REQUIRED@ gnome-vfs-2.0 -Libs: -L${privlibdir} -lpcs -lcal-util -lcal-client -lical-evolution -leutil -Cflags: -I${privincludedir} -I${privincludedir}/libical diff --git a/mail/Makefile.am b/mail/Makefile.am index 6b79d2f7e7..216b6d1124 100644 --- a/mail/Makefile.am +++ b/mail/Makefile.am @@ -17,8 +17,6 @@ INCLUDES = \ -I$(top_srcdir)/shell \ -I$(top_srcdir)/shell/importer \ -I$(top_builddir)/shell/importer \ - -I$(top_srcdir)/addressbook/backend \ - -I$(top_builddir)/addressbook/backend \ $(EVOLUTION_MAIL_CFLAGS) \ -DEVOLUTION_DATADIR=\""$(datadir)"\" \ -DEVOLUTION_PRIVDATADIR=\""$(privdatadir)"\" \ @@ -175,7 +173,6 @@ libevolution_mail_la_LIBADD = \ $(top_builddir)/composer/libcomposer.la \ $(top_builddir)/widgets/misc/libemiscwidgets.la \ $(top_builddir)/widgets/misc/libefilterbar.la \ - $(top_builddir)/addressbook/backend/ebook/libebook.la \ $(top_builddir)/filter/libfilter.la \ $(top_builddir)/widgets/menus/libmenus.la \ $(EVOLUTION_MAIL_LIBS) diff --git a/shell/ChangeLog b/shell/ChangeLog index 68cd5346da..aea1998abc 100644 --- a/shell/ChangeLog +++ b/shell/ChangeLog @@ -1,3 +1,9 @@ +2003-11-07 JP Rosevear <jpr@ximian.com> + + * main.c: use e-d-s idl to check interface version + + * Makefile.am: build e-d-s idl + 2003-11-03 Ettore Perazzoli <ettore@ximian.com> * e-shell-shared-folder-picker-dialog.c (setup_name_selector): diff --git a/shell/Makefile.am b/shell/Makefile.am index ac0e2d75d9..52cb69d8e2 100644 --- a/shell/Makefile.am +++ b/shell/Makefile.am @@ -19,6 +19,7 @@ INCLUDES = \ -DDATADIR=\""$(datadir)"\" \ -DLIBDIR=\""$(datadir)"\" \ -DG_LOG_DOMAIN=\"evolution-shell\" \ + $(TZDIALOG_CFLAGS) \ $(SHELL_CFLAGS) noinst_PROGRAMS = evolution evolution-test-component @@ -79,25 +80,21 @@ $(SELECT_NAMES_IDL_GENERATED_H): $(SELECT_NAMES_IDL) $(SELECT_NAMES_IDL_GENERATED_C): $(SELECT_NAMES_IDL_GENERATED_H) -# Wombat CORBA stuff +# Data Server CORBA stuff +DATASERVER_IDL_GENERATED_H = \ + Evolution-DataServer.h -WOMBAT_IDL = \ - $(top_srcdir)/wombat/Evolution-Wombat.idl +DATASERVER_IDL_GENERATED_C = \ + Evolution-DataServer-common.c \ + Evolution-DataServer-skels.c \ + Evolution-DataServer-stubs.c -WOMBAT_IDL_GENERATED_H = \ - Evolution-Wombat.h +DATASERVER_IDL_GENERATED = $(DATASERVER_IDL_GENERATED_C) $(DATASERVER_IDL_GENERATED_H) -WOMBAT_IDL_GENERATED_C = \ - Evolution-Wombat-common.c \ - Evolution-Wombat-skels.c \ - Evolution-Wombat-stubs.c +$(DATASERVER_IDL_GENERATED_H): $(DATASERVER_IDL) + $(ORBIT_IDL) -I $(srcdir) $(IDL_INCLUDES) $(DATASERVER_IDL) -WOMBAT_IDL_GENERATED = $(WOMBAT_IDL_GENERATED_C) $(WOMBAT_IDL_GENERATED_H) - -$(WOMBAT_IDL_GENERATED_H): $(WOMBAT_IDL) - $(ORBIT_IDL) -I $(srcdir) $(IDL_INCLUDES) $(WOMBAT_IDL) - -$(WOMBAT_IDL_GENERATED_C): $(WOMBAT_IDL_GENERATED_H) +$(DATASERVER_IDL_GENERATED_C): $(DATASERVER_IDL_GENERATED_H) # IDL install @@ -182,7 +179,7 @@ libeshell_la_LIBADD = \ evolution_SOURCES = \ $(SELECT_NAMES_IDL_GENERATED) \ - $(WOMBAT_IDL_GENERATED) \ + $(DATASERVER_IDL_GENERATED) \ e-component-registry.c \ e-component-registry.h \ e-config-upgrade.c \ @@ -232,7 +229,7 @@ evolution_LDADD = \ $(top_builddir)/widgets/e-timezone-dialog/libetimezonedialog.la \ $(top_builddir)/widgets/misc/libemiscwidgets.la \ $(top_builddir)/e-util/libeutil.la \ - $(top_builddir)/libical/src/libical/libical-evolution.la \ + $(TZDIALOG_LIBS) \ $(SHELL_LIBS) # Test component @@ -327,7 +324,7 @@ evolution.pure: evolution endif -BUILT_SOURCES = $(IDL_GENERATED) $(SELECT_NAMES_IDL_GENERATED) $(MARSHAL_GENERATED) $(server_DATA) $(WOMBAT_IDL_GENERATED) +BUILT_SOURCES = $(IDL_GENERATED) $(SELECT_NAMES_IDL_GENERATED) $(MARSHAL_GENERATED) $(server_DATA) $(DATASERVER_IDL_GENERATED) CLEANFILES = $(BUILT_SOURCES) dist-hook: diff --git a/shell/main.c b/shell/main.c index 6d84090840..8a6d011cb6 100644 --- a/shell/main.c +++ b/shell/main.c @@ -60,7 +60,7 @@ #include <glade/glade.h> #include "e-config-upgrade.h" -#include "Evolution-Wombat.h" +#include "Evolution-DataServer.h" #ifdef GTKHTML_HAVE_GCONF #include <gconf/gconf.h> @@ -178,20 +178,20 @@ kill_wombat (void) static void kill_old_wombat (void) { - GNOME_Evolution_WombatInterfaceCheck iface; + GNOME_Evolution_DataServer_InterfaceCheck iface; CORBA_Environment ev; CORBA_char *version; CORBA_exception_init (&ev); - iface = bonobo_activation_activate_from_id ("OAFIID:GNOME_Evolution_Wombat_InterfaceCheck", 0, NULL, &ev); + iface = bonobo_activation_activate_from_id ("OAFIID:GNOME_Evolution_DataServer_InterfaceCheck", 0, NULL, &ev); if (BONOBO_EX (&ev) || iface == CORBA_OBJECT_NIL) { kill_wombat (); CORBA_exception_free (&ev); return; } - version = GNOME_Evolution_WombatInterfaceCheck__get_interfaceVersion (iface, &ev); + version = GNOME_Evolution_DataServer_InterfaceCheck__get_interfaceVersion (iface, &ev); if (BONOBO_EX (&ev)) { kill_wombat (); CORBA_Object_release (iface, &ev); diff --git a/widgets/ChangeLog b/widgets/ChangeLog index 51ea4593d1..b74cef767a 100644 --- a/widgets/ChangeLog +++ b/widgets/ChangeLog @@ -1,3 +1,7 @@ +2003-11-07 JP Rosevear <jpr@ximian.com> + + * e-timezone-dialog/Makefile.am: use TZDIALOG_FLAGS + 2003-10-09 Jeffrey Stedfast <fejj@ximian.com> * e-timezone-dialog/Makefile.am: INCLUDE path fixes for changes diff --git a/widgets/e-timezone-dialog/Makefile.am b/widgets/e-timezone-dialog/Makefile.am index 46e46b0319..ee9b3f0cc8 100644 --- a/widgets/e-timezone-dialog/Makefile.am +++ b/widgets/e-timezone-dialog/Makefile.am @@ -3,7 +3,7 @@ INCLUDES = \ -I$(top_srcdir)/libical/src \ -DEVOLUTION_GLADEDIR=\""$(gladedir)"\" \ -DG_LOG_DOMAIN=__FILE__ \ - $(GNOME_FULL_CFLAGS) + $(TZDIALOG_CFLAGS) noinst_LTLIBRARIES = \ libetimezonedialog.la diff --git a/wombat/.cvsignore b/wombat/.cvsignore deleted file mode 100644 index 9c09bbbbfb..0000000000 --- a/wombat/.cvsignore +++ /dev/null @@ -1,16 +0,0 @@ -.deps -.libs -.pure -Makefile -Makefile.in -*.lo -*.la -evolution-wombat -evolution-wombat.pure -GNOME_Evolution_Wombat.server -GNOME_Evolution_Wombat.server.in -GNOME_Evolution_Wombat.server.in.in -Evolution-Wombat-common.c -Evolution-Wombat-skels.c -Evolution-Wombat-stubs.c -Evolution-Wombat.h diff --git a/wombat/ChangeLog b/wombat/ChangeLog deleted file mode 100644 index a0a17c4b3e..0000000000 --- a/wombat/ChangeLog +++ /dev/null @@ -1,64 +0,0 @@ -2003-10-31 Hans Petter Jansson <hpj@ximian.com> - - * Makefile.am (evolution_wombat_LDADD): Add http backend lib. - - * wombat.c (setup_pcs): Register webcal method for http backend. - -2003-10-24 Dan Winship <danw@ximian.com> - - * Makefile.am (evolution_wombat_LDADD): put back the conditional - libpasldap stuff, and make evolution-wombat explicitly depend on - the specific backends again; libpas itself cannot depend on the - backends. Use libpcsfile.la for the calendar dependency, and - remove libebook, libcal-util, libedb3util and libeutil, since - they're properly pulled in by libtool now. - -2003-10-23 Ettore Perazzoli <ettore@ximian.com> - - * GNOME_Evolution_WombatNOLDAP.server.in.in: Add - "calendar:supported_protocol" attribute that was missing here (but - was in the LDAP one). - -2003-10-21 Chris Toshok <toshok@ximian.com> - - * GNOME_Evolution_WombatLDAP.server.in.in: add vcf to - supported_protocols. - - * GNOME_Evolution_WombatNOLDAP.server.in.in: same. - - * wombat.c (setup_pas): register the vcf backend. - - * Makefile.am (evolution_wombat_LDADD): replace the conditional - libpasldap stuff and the references to all the libpas* backends - with libpas.la. - -2003-10-15 Rodrigo Moya <rodrigo@ximian.com> - - * wombat.c (termination_handler): re-enabled the call to - cal_factory_get_n_backends, so that we only terminate if there - are no active backends (either addressbook or calendar). - -2003-10-09 Jeffrey Stedfast <fejj@ximian.com> - - * Makefile.am: INCLUDE path fixes for changes made to libical - build. - -2003-08-13 JP Rosevear <jpr@ximian.com> - - * wombat.c (termination_handler): comment out some bits - (setup_pcs): register kind and method - - * GNOME_Evolution_Wombat.server.in.in: add calendar protocol - - * GNOME_Evolution_WombatLDAP.server.in.in: ditto - -2003-06-26 Rodrigo Moya <rodrigo@ximian.com> - - * Evolution-Wombat.idl: removed WombatClient interface. - - * Makefile.am: don't link libwombat in. - -2003-06-16 Frederic Crozat <fcrozat@mandrakesoft.com> - - * Makefile.am: - Add missing skel/stub to BUILD_SOURCES (bug #44717). diff --git a/wombat/ChangeLog.pre-1-4 b/wombat/ChangeLog.pre-1-4 deleted file mode 100644 index ec653aec2a..0000000000 --- a/wombat/ChangeLog.pre-1-4 +++ /dev/null @@ -1,484 +0,0 @@ -2003-04-07 Dan Winship <danw@ximian.com> - - * GNOME_Evolution_WombatLDAP.server.in.in: clean up server names - - * GNOME_Evolution_WombatNOLDAP.server.in.in: Likewise - -2003-03-28 Ettore Perazzoli <ettore@ximian.com> - - * GNOME_Evolution_WombatLDAP.server.in.in: Add InterfaceCheck - object. - * GNOME_Evolution_WombatNOLDAP.server.in.in: Likewise. - - * wombat-interface-check.c: New, from evolution-1-2-branch. - * wombat-interface-check.h: Likewise. - - * wombat.c (setup_pas): Removed argc/argv args. - (setup_pcs): Likewise. - (setup_interface_check): New interface to set up the - InterfaceCheck object. - (main): Call the latter. - -2003-03-13 Dan Winship <danw@ximian.com> - - * Makefile.am (GNOME_Evolution_Wombat.server.in.in): Make this - depend on Makefile so it gets regenerated if you switch from - --without-openldap to --with-openldap - -2003-02-21 Dan Winship <danw@ximian.com> - - * Makefile.am (evolution_wombat_LDADD): cleanup - -2003-02-19 Chris Toshok <toshok@ximian.com> - - * wombat.c (termination_handler): gtk_main_quit => - bonobo_main_quit. - -2003-02-07 Rodney Dawes <dobey@ximian.com> - - * Makefile.am: privlibexecdir not evolibexecdir for the server file - -2003-02-06 Dan Winship <danw@ximian.com> - - * Makefile.am: cleanup - - * wombat.c (main): s/PACKAGE/GETTEXT_PACKAGE/ in gettext init - -2003-02-01 Hans Petter Jansson <hpj@ximian.com> - - * Makefile.am: Make .server file point to where wombat is now - installed. - -2003-01-29 Rodney Dawes <dobey@ximian.com> - - * Makefile.am: Install wombat to - $(libexecdir)/evolution/$(BASE_VERSION) - -2003-01-27 Ettore Perazzoli <ettore@ximian.com> - - * Makefile.am: Rename wombat to evolution-wombat. - * GNOME_Evolution_WombatLDAP.server.in.in: Updated accordingly. - * GNOME_Evolution_WombatNOLDAP.server.in.in: Likewise. - -2003-01-14 Ettore Perazzoli <ettore@ximian.com> - - * Makefile.am: Do not dist the .server.in files; just dist the - .server.in.in ones. - (EXTRA_DIST): Add GNOME_Evolution_WombatLDAP.server.in.in and - GNOME_Evolution_WombatNOLDAP.server.in.in - -2003-01-06 Dan Winship <danw@ximian.com> - - * Makefile.am: Remove idldir definition. It's defined in - configure.in now. - -2002-12-06 Hans Petter Jansson <hpj@ximian.com> - - * GNOME_Evolution_WombatNOLDAP.server.in.in: It appears that - Ettore's @LIBEXECDIR@ change didn't make it in for this file. - Fixed that. - -2002-11-16 Chris Toshok <toshok@ximian.com> - - * GNOME_Evolution_WombatLDAP.server.in.in: remove the moniker - cruft. - - * GNOME_Evolution_WombatNOLDAP.server.in.in: same. - -2002-11-15 Ettore Perazzoli <ettore@ximian.com> - - * Makefile.am: Added rule to create - GNOME_Evolution_Wombat.server.in from - GNOME_Evolution_Wombat.server.in.in, substituting @LIBEXECDIR@. - Also install wombat in $libexecdir instead of $bindir. - - * GNOME_Evolution_WombatNOLDAP.server.in.in: Renamed from - GNOME_Evolution_WombatNOLDAP.server.in. Changed the location from - "wombat" to "@LIBEXECDIR@/wombat". - - * GNOME_Evolution_WombatLDAP.server.in.in: Renamed from - GNOME_Evolution_WombatLDAP.server.in. Changed the location from - "wombat" to "@LIBEXECDIR@/wombat". - -2002-11-07 Rodrigo Moya <rodrigo@ximian.com> - - * wombat.c: re-enabled calendar parts. - -2002-11-06 Chris Toshok <toshok@ximian.com> - - * Makefile.am (wombat_LDADD): remove libcamel.la from the link for - the time being. - - * wombat.c: ifdef out (#ifdef PENDING_PORT_WORK) the calendar - stuff, since it doesn't link at the moment - undefined symbols in - pcs. Also, include gtk.h so the gtk_* in the calendar portions - will still work. - -2002-11-05 Chris Toshok <toshok@ximian.com> - - * Makefile.am: change over from .oaf files to .server files and - remove the moniker stuff from the build. - - * wombat.c: port over to gnome2, and nuke all the config moniker - stuff. - - * wombat-moniker.[ch]: remove - - * wombat-private-moniker.[ch]: remove - - * GNOME_Evolution_WombatLDAP.server.in: rename the oaf.in file to this. - - * GNOME_Evolution_WombatNOLDAP.server.in: rename the oaf.in file to this. - - * .cvsignore: s/oaf/server - -2002-08-01 Chris Toshok <toshok@ximian.com> - - * wombat.c (last_calendar_gone_cb): remove the annoying fprintf - about Queueing termination, since we never actually terminate. - -2002-07-25 Chris Toshok <toshok@ximian.com> - - * wombat.c (main): add a silly "up and running" message. - -2002-07-22 Dan Winship <danw@ximian.com> - - * Makefile.am (wombat_LDADD): Include libpcsfile.a, libpasfile.a - and (if ENABLE_LDAP) libpasldap.a - -2002-07-15 Peter Williams <peterw@ximian.com> - - * Makefile.am (EXTRA_DIST): Apparently we can't remove - $(idl_DATA) from $(EXTRA_DIST). - -2002-07-08 Peter Williams <peterw@ximian.com> - - * wombat.idl: Renamed to Evolution-Wombat.idl, since - we're installing it now and should play nice namespacily. - - * Makefile.am: Rename wombat.idl and install it. - -2002-04-26 Jeffrey Stedfast <fejj@ximian.com> - - * Makefile.am: Removed dependency on libibex. - -2002-04-04 Jeffrey Stedfast <fejj@ximian.com> - - * Makefile.am: Re-Add $(WOMBAT_LIBS) so wombat actually links. - -2002-04-04 Ettore Perazzoli <ettore@ximian.com> - - * Makefile.am (wombat_LDADD): Put DB3_LDADD and LDAP_LIBS on the - top so the PAS backend uses the right version of DB3 and always - links to LDAP. - -2002-03-19 Dan Winship <danw@ximian.com> - - * Makefile.am (wombat_LDADD): s/libversit.la/libversit.a/ - -2002-01-28 Radek Doulik <rodo@ximian.com> - - * Makefile.am (wombat_LDADD): added DB3_LDADD - -2002-01-27 Ettore Perazzoli <ettore@ximian.com> - - * Makefile.am: Use WOMBAT_LIBS and WOMBAT_CFLAGS. - -2001-10-29 Damon Chaplin <damon@ximian.com> - - * Makefile.am (wombat_LDADD): use libical-evolution.la - -2001-10-29 Chris Toshok <toshok@ximian.com> - - * wombat.c (dump_backends): new function, ifdef'ed DEBUG_BACKENDS. - (main): add SIGUSR2 handler for dump_backends, ifdef'ed - DEBUG_BACKENDS. - -2001-10-22 Ettore Perazzoli <ettore@ximian.com> - - * wombat.c (main): Register the public ConfigDatabase interface - last to work around an OAF race condition. - -2001-10-11 Chris Toshok <toshok@ximian.com> - - * Makefile.am (wombat_SOURCES): add wombat-private-moniker.[ch]. - - * GNOME_Evolution_WombatLDAP.oaf.in: add wombat-private - factory/moniker. - - * GNOME_Evolution_WombatNOLDAP.oaf.in: same. - - * wombat-private-moniker.[ch]: xmldb for private database -- non - configuration settings, basically. - -2001-10-02 Chris Toshok <toshok@ximian.com> - - * GNOME_Evolution_WombatNOLDAP.oaf.in: add - addressbook:supported_protocols containing just the file protocol. - - * GNOME_Evolution_WombatLDAP.oaf.in: add - addressbook:supported_protocols containing both ldap and file. - - * Makefile.am (OAF_IN_FILE): we have to possible files now, since - the addressbook looks up factories by corba interface and the - protocols supported by the factory (as listed in the .oaf file.) - - * .cvsignore: ignore GNOME_Evolution_Wombat.oaf.in, since it's - generated now. - -2001-09-26 Chris Toshok <toshok@ximian.com> - - * wombat.c (setup_pas): add OAFIID parameter to the call to the - pas_book_factory_activate function, as with the calendar stuff. - -2001-09-19 Rodrigo Moya <rodrigo@ximian.com> - - * wombat.c (setup_pcs): add OAFIID parameter to the call to the - cal_factory_oaf_register function - -2001-08-02 Jon Trowbridge <trow@ximian.com> - - * Makefile.am: Added camel dependency (now needed by ebook). - -2001-07-10 Peter Williams <peterw@ximian.com> - - * Makefile.am (EXTRA_DIST): Distribute wombat.idl. - -2001-06-24 Federico Mena Quintero <federico@ximian.com> - - * wombat.c (main): Shut down gnome-vfs. - -2001-06-22 Jeffrey Stedfast <fejj@ximian.com> - - * Makefile.am (wombat_LDADD): Added libwombat/libwombat.la - -2001-06-21 Rodrigo Moya <rodrigo@ximian.com> - - * wombat.idl: added new interface (WombatClient) - -2001-06-18 Dan Winship <danw@ximian.com> - - * Makefile.am (wombat_LDADD): Add libedb3util - -2001-06-03 Ettore Perazzoli <ettore@ximian.com> - - * Makefile.am (wombat_LDADD): Move `$(DB3_LDADD)' before libeutil. - -2001-05-31 Christopher James Lahey <clahey@ximian.com> - - * Makefile.am (wombat_LDADD): Added db3 libs. - -2001-04-03 Dietmar Maurer <dietmar@ximian.com> - - * wombat-moniker.c (wombat_lookup_db): fix ref. counting problem - -2001-03-27 Dietmar Maurer <dietmar@ximian.com> - - * wombat-moniker.c (wombat_moniker_resolve): we can now resolve to - storages and streams. - -2001-03-26 Kjartan Maraas <kmaraas@gnome.org> - - * wombat.c: Replace <gnome.h> <and <bonobo.h> includes - and add <stdlib.h> to remove warnings from newer gcc. - -2001-03-21 JP Rosevear <jpr@ximian.com> - - * Makefile.am: add wombat-moniker.h as a source so it gets disted - -2001-03-21 Dietmar Maurer <dietmar@ximian.com> - - * wombat.c (setup_config): initialise the moniker factory - - * GNOME_Evolution_Wombat.oaf.in: added the necessary entries for - the wombat moniker. - - * wombat-moniker.[ch]: wombat is now a moniker - -2001-03-15 Jon Trowbridge <trow@ximian.com> - - * wombat.c (main): If we can't initialize a service on startup, - tell us which one before terminating. - -2001-02-27 Federico Mena Quintero <federico@ximian.com> - - * wombat.c (init_corba): Use VERSION and the Wombat description - for gnome_init_with_popt_table(). - -2001-02-16 Federico Mena Quintero <federico@ximian.com> - - * wombat.c (main): Unref the factories if we failed to initialize - anything. - (setup_pcs): Call cal_factory_oaf_register(). Removed the OAF - registration code from here; now it is in the CalFactory itself. - -2001-02-12 Kjartan Maraas <kmaraas@gnome.org> - - * Makefile.am: xml-i18n-tools setup. - * GNOME_Evolution_Wombat.oaf.in: Mark strings for translation. - -2001-02-08 JP Rosevear <jpr@ximian.com> - - * Makefile.am: Remove useless ldflags - -2001-01-17 Federico Mena Quintero <federico@ximian.com> - - * wombat.c (setup_pcs): Return a success value. - (setup_pas): Likewise. - (setup_config): Likewise. - (main): Exit if we could not initialize all of the Wombat - services. - (init_corba): Check the return value of gnome_init_with_popt_table(). - (main): Call bindtextdomain() and textdomain(). - -2000-12-23 Ettore Perazzoli <ettore@helixcode.com> - - * Makefile.am (INCLUDES): Add `-I$(top_builddir)/calendar/pcs' for - builddir compliance. - -2000-12-13 Ettore Perazzoli <ettore@helixcode.com> - - * Makefile.am (INCLUDES): Sigh. - `-I$(top_builddir)/libical/src/libical'. - -2000-12-11 Federico Mena Quintero <federico@helixcode.com> - - * Makefile.am (wombat_LDADD): Link to the libical shared library. - -2000-11-11 Matt Bissiri <bissiri@eecs.umich.edu> - - * wombat.oafinfo: - Update the remaining "IDL:Evolution*" to "IDL:GNOME/Evolution*" - to sync up with yesterday's IDL re-scoping. - -2000-10-23 Dan Winship <danw@helixcode.com> - - * Makefile.am (INCLUDES): Update EVOLUTION_LOCALEDIR - -2000-09-25 Federico Mena Quintero <federico@helixcode.com> - - * Makefile.am (INCLUDES): Add the libical include path. - -2000-09-25 Jeffrey Stedfast <fejj@helixcode.com> - - * Makefile.am: ename moved so link against - e-util/ename/libename.la - -2000-08-26 JP Rosevear <jpr@helixcode.com> - - * Makefile.am: Remove gnorba related code - - * wombat.c: Remove gnorba related code - - * wombat.gnorba: Kill - -2000-08-24 Federico Mena Quintero <federico@helixcode.com> - - * Makefile.am (wombat_LDADD): Reorder libical libs. - -2000-08-02 Federico Mena Quintero <federico@helixcode.com> - - * wombat.c (setup_pcs): Register the iCalendar file backend instad - of the old IMC backend. - -2000-05-13 Ettore Perazzoli <ettore@helixcode.com> - - * Makefile.am (INCLUDES): GNOME includes should come last, so that - we are sure we pick our own includes instead of the installed - ones, if any. - -2000-05-10 Christopher James Lahey <clahey@helixcode.com> - - * Makefile.am: Added an include for the pcs directory. - -2000-05-08 Federico Mena Quintero <federico@helixcode.com> - - * wombat.c (setup_pcs): Register the "file" method with the IMC - backend. - -2000-05-05 Chris Toshok <toshok@helixcode.com> - * .cvsignore: ignore wombat.pure - - * Makefile.am: add support for building wombat.pure - -2000-05-01 Federico Mena Quintero <federico@helixcode.com> - - * wombat.c (main): Doh, also unref the pas_book_factory when we - are done. - -2000-04-30 Federico Mena Quintero <federico@helixcode.com> - - * wombat.c (setup_pas): Connect to the "last_book_gone" signal of - the book factory. - (last_book_gone_cb): Handle the "last_book_gone" signal. - (termination_handler): Check if the book factory has zero running - backends. - -2000-04-30 Christopher James Lahey <clahey@helixcode.com> - - * Makefile.am: Added ename libs to LDADD. - -2000-04-27 Ettore Perazzoli <ettore@helixcode.com> - - * wombat.c - (register_pcs): New function for registering into the name - service. Varies according on whether we are `USING_OAF' or not. - (init_corba): New function for initializing the CORBA stuff. - Implementation depends on `USING_OAF'. - (init_bonobo): Use `init_corba'. - - * Makefile.am: Updated for OAF. - -2000-04-25 Federico Mena Quintero <federico@helixcode.com> - - * wombat.c (cal_factory pas_book_factory): New module-wide - variables for the PAS and PCS factories. - (setup_pcs): Connect to the "last_calendar_gone" signal of the - calendar factory. - (last_calendar_gone_cb): Queue a termination job. - (queue_termination): Function to queue a termination job. We have - to use a timeout to reduce the probability of running into GOAD's - race condition with factories. - (termination_handler): Check that the PCS and the PAS have zero - backends. If so, exit the main loop. - (setup_vfs): Use EXIT_FAILURE instead of 1. - (init_bonobo): Likewise. - (main): Destroy the factories and exit Wombat. Wheee! - -2000-04-16 Federico Mena Quintero <federico@helixcode.com> - - * Makefile.am (INCLUDES): Removed spurious calendar directories - from the include path. Added "wombat" log domain for glib. - (wombat_LDADD): Link libpcs.a instead of the old shared library. - - * wombat.c: cal-factory.h is an internal include file. * wombat.c - (setup_pcs): We should NOT share a CORBA_environment across all - functions! Use our own CORBA_environment. - (init_bonobo): Use our own CORBA_environment. Free the exception - after initializing GOAD, and present some error messages if - necessary. (Should g_message()s for exceptional situations be - marked for translation?). - -2000-04-15 Ettore Perazzoli <ettore@helixcode.com> - - * Makefile.am (INCLUDES): Added - `-I$(top_builddir)/addressbook/backend/pas', and - `-I$(top_builddir)/calendar/pcs' because that's where the - IDL-generated files go. - -2000-04-14 Chris Toshok <toshok@helixcode.com> - - * Makefile.am (wombat_LDADD): use BONOBO_VFS_GNOME_LIBS instead of - BONOBO_HTML_GNOME_LIBS. fixes freebsd's problem running wombat. - -2000-04-14 Federico Mena Quintero <federico@helixcode.com> - - * wombat.c (setup_pcs): Must pass "object" for the kind to - goad_server_register(); "server" is meaningless. - (setup_pcs): Do not free the CORBA environment more than once. - Also, fix error messages. - - * wombat.gnorba: The GOAD ID is "evolution:calendar-factory", not - "evolution:calendar-server". - - * ChangeLog: Started the ChangeLog for Wombat. diff --git a/wombat/Evolution-Wombat.idl b/wombat/Evolution-Wombat.idl deleted file mode 100644 index 3f25693599..0000000000 --- a/wombat/Evolution-Wombat.idl +++ /dev/null @@ -1,19 +0,0 @@ -/* - * Wombat interfaces. - * - * Copyright (C) 2000, 2001, 2002, Ximian, Inc. - */ - -#include <Bonobo.idl> - -module GNOME { -module Evolution { - - interface Config { - }; - - interface WombatInterfaceCheck : Bonobo::Unknown { - readonly attribute string interfaceVersion; - }; -}; -}; diff --git a/wombat/GNOME_Evolution_WombatLDAP.server.in.in b/wombat/GNOME_Evolution_WombatLDAP.server.in.in deleted file mode 100644 index b82fe26803..0000000000 --- a/wombat/GNOME_Evolution_WombatLDAP.server.in.in +++ /dev/null @@ -1,50 +0,0 @@ -<oaf_info> - -<oaf_server iid="OAFIID:GNOME_Evolution_Wombat_ServerFactory" - type="exe" - location="@LIBEXECDIR@/evolution-wombat"> - - <oaf_attribute name="repo_ids" type="stringv"> - <item value="IDL:GNOME/Evolution/BookFactory:1.0"/> - <item value="IDL:Bonobo/Unknown:1.0"/> - </oaf_attribute> - - <oaf_attribute name="name" type="string" - _value="Evolution Addressbook local/LDAP backend"/> - - <oaf_attribute name="addressbook:supported_protocols" type="stringv"> - <item value="ldap"/> - <item value="file"/> - <item value="vcf"/> - </oaf_attribute> -</oaf_server> - -<oaf_server iid="OAFIID:GNOME_Evolution_Wombat_CalendarFactory" - type="exe" - location="@LIBEXECDIR@/evolution-wombat"> - - <oaf_attribute name="repo_ids" type="stringv"> - <item value="IDL:GNOME/Evolution/Calendar/CalFactory:1.0"/> - <item value="IDL:Bonobo/Unknown:1.0"/> - </oaf_attribute> - - <oaf_attribute name="name" type="string" - _value="Evolution Calendar local file backend"/> - - <oaf_attribute name="calendar:supported_protocols" type="stringv"> - <item value="file"/> - </oaf_attribute> -</oaf_server> - -<oaf_server iid="OAFIID:GNOME_Evolution_Wombat_InterfaceCheck" - type="exe" - location="@LIBEXECDIR@/evolution-wombat"> - - <oaf_attribute name="repo_ids" type="stringv"> - <item value="IDL:GNOME/Evolution/WombatInterfaceCheck:1.0"/> - <item value="IDL:Bonobo/Unknown:1.0"/> - </oaf_attribute> - -</oaf_server> - -</oaf_info> diff --git a/wombat/GNOME_Evolution_WombatNOLDAP.server.in.in b/wombat/GNOME_Evolution_WombatNOLDAP.server.in.in deleted file mode 100644 index 84a460db99..0000000000 --- a/wombat/GNOME_Evolution_WombatNOLDAP.server.in.in +++ /dev/null @@ -1,49 +0,0 @@ -<oaf_info> - -<oaf_server iid="OAFIID:GNOME_Evolution_Wombat_ServerFactory" - type="exe" - location="@LIBEXECDIR@/evolution-wombat"> - - <oaf_attribute name="repo_ids" type="stringv"> - <item value="IDL:GNOME/Evolution/BookFactory:1.0"/> - <item value="IDL:Bonobo/Unknown:1.0"/> - </oaf_attribute> - - <oaf_attribute name="name" type="string" - _value="Evolution Addressbook local backend"/> - - <oaf_attribute name="addressbook:supported_protocols" type="stringv"> - <item value="file"/> - <item value="vcf"/> - </oaf_attribute> -</oaf_server> - -<oaf_server iid="OAFIID:GNOME_Evolution_Wombat_CalendarFactory" - type="exe" - location="@LIBEXECDIR@/evolution-wombat"> - - <oaf_attribute name="repo_ids" type="stringv"> - <item value="IDL:GNOME/Evolution/Calendar/CalFactory:1.0"/> - <item value="IDL:Bonobo/Unknown:1.0"/> - </oaf_attribute> - - <oaf_attribute name="name" type="string" - _value="Evolution Calendar local file backend"/> - - <oaf_attribute name="calendar:supported_protocols" type="stringv"> - <item value="file"/> - </oaf_attribute> -</oaf_server> - -<oaf_server iid="OAFIID:GNOME_Evolution_Wombat_InterfaceCheck" - type="exe" - location="@LIBEXECDIR@/evolution-wombat"> - - <oaf_attribute name="repo_ids" type="stringv"> - <item value="IDL:GNOME/Evolution/WombatInterfaceCheck:1.0"/> - <item value="IDL:Bonobo/Unknown:1.0"/> - </oaf_attribute> - -</oaf_server> - -</oaf_info> diff --git a/wombat/Makefile.am b/wombat/Makefile.am deleted file mode 100644 index 7caa352d14..0000000000 --- a/wombat/Makefile.am +++ /dev/null @@ -1,97 +0,0 @@ -INCLUDES = \ - -DG_LOG_DOMAIN=\"wombat\" \ - -DPREFIX=\"$(prefix)\" \ - -DSYSCONFDIR=\"$(sysconfdir)\" \ - -DDATADIR=\"$(datadir)\" \ - -DLIBDIR=\"$(libdir)\" \ - -I$(top_srcdir)/e-util \ - -I$(top_srcdir) \ - -I$(top_srcdir)/addressbook/backend \ - -I$(top_builddir)/addressbook/backend \ - -I$(top_srcdir)/calendar \ - -I$(top_srcdir)/calendar \ - -I$(top_builddir)/calendar \ - -I$(top_srcdir)/libical/src \ - -DEVOLUTION_LOCALEDIR=\""$(localedir)"\" \ - $(WOMBAT_CFLAGS) - -IDLS = \ - Evolution-Wombat.idl - -IDL_GENERATED_H = \ - Evolution-Wombat.h - -IDL_GENERATED_C = \ - Evolution-Wombat-common.c \ - Evolution-Wombat-skels.c \ - Evolution-Wombat-stubs.c - -IDL_GENERATED = $(IDL_GENERATED_H) $(IDL_GENERATED_C) - -$(IDL_GENERATED_H): $(IDLS) - $(ORBIT_IDL) -I $(srcdir) $(IDL_INCLUDES) $(srcdir)/Evolution-Wombat.idl - -$(IDL_GENERATED_C): $(IDL_GENERATED_H) - - -privlibexec_PROGRAMS = \ - evolution-wombat - -evolution_wombat_SOURCES = \ - $(IDL_GENERATED) \ - wombat-interface-check.c \ - wombat-interface-check.h \ - wombat.c - -if ENABLE_LDAP -LDAP_BACKEND = $(top_builddir)/addressbook/backend/pas/libpasldap.la -endif - -evolution_wombat_LDADD = \ - $(top_builddir)/addressbook/backend/pas/libpasfile.la \ - $(top_builddir)/addressbook/backend/pas/libpasvcf.la \ - $(LDAP_BACKEND) \ - $(top_builddir)/calendar/pcs/libpcsfile.la \ - $(top_builddir)/calendar/pcs/libpcshttp.la \ - $(WOMBAT_LIBS) - -if ENABLE_LDAP -SERVER_IN_FILE=GNOME_Evolution_WombatLDAP.server.in.in -else -SERVER_IN_FILE=GNOME_Evolution_WombatNOLDAP.server.in.in -endif - -GNOME_Evolution_Wombat.server.in.in: $(SERVER_IN_FILE) Makefile - cp $< $@ - -server_in_files = GNOME_Evolution_Wombat.server.in.in -server_DATA = $(server_in_files:.server.in.in=_$(BASE_VERSION).server) -@EVO_SUBST_SERVER_RULE@ -@EVO_NAME_SERVER_RULE@ -@INTLTOOL_SERVER_RULE@ - -idl_DATA = $(IDLS) - -EXTRA_DIST = \ - $(server_in_files) \ - $(idl_DATA) \ - ChangeLog.pre-1-4 \ - GNOME_Evolution_WombatLDAP.server.in.in \ - GNOME_Evolution_WombatNOLDAP.server.in.in - -BUILT_SOURCES = $(IDL_GENERATED) $(server_DATA) -CLEANFILES = $(BUILT_SOURCES) - -dist-hook: - cd $(distdir); rm -f $(BUILT_SOURCES) - -if ENABLE_PURIFY -PLINK = $(LIBTOOL) --mode=link $(PURIFY) $(CCLD) $(AM_CFLAGS) $(CFLAGS) $(LDFLAGS) -o $@ - -all-local: evolution-wombat.pure - -evolution-wombat.pure: evolution-wombat - @rm -f evolution-wombat.pure - $(PLINK) $(evolution_wombat_LDFLAGS) $(evolution_wombat_OBJECTS) $(evolution_wombat_LDADD) $(LIBS) - -endif diff --git a/wombat/wombat-interface-check.c b/wombat/wombat-interface-check.c deleted file mode 100644 index f7766cd218..0000000000 --- a/wombat/wombat-interface-check.c +++ /dev/null @@ -1,70 +0,0 @@ -/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 8; tab-width: 8 -*- */ -/* wombat-interface-check.c - * - * Copyright (C) 2002 Ximian, Inc. - * - * 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., 59 Temple Place - Suite 330, - * Boston, MA 02111-1307, USA. - * - * Author: Ettore Perazzoli <ettore@ximian.com> - */ - -#ifdef HAVE_CONFIG_H -#include <config.h> -#endif - -#include "wombat-interface-check.h" - -#include <gal/util/e-util.h> - - -#define PARENT_TYPE bonobo_object_get_type () -static BonoboObjectClass *parent_class = NULL; - - -static CORBA_char * -impl__get_interfaceVersion (PortableServer_Servant servant, - CORBA_Environment *ev) -{ - return CORBA_string_dup (VERSION); -} - - -static void -wombat_interface_check_class_init (WombatInterfaceCheckClass *class) -{ - parent_class = g_type_class_ref (PARENT_TYPE); - - class->epv._get_interfaceVersion = impl__get_interfaceVersion; -} - -static void -wombat_interface_check_init (WombatInterfaceCheck *interface_check) -{ - /* (Nothing to initialize here.) */ -} - - -WombatInterfaceCheck * -wombat_interface_check_new (void) -{ - return g_object_new (WOMBAT_TYPE_INTERFACE_CHECK, NULL); -} - - -BONOBO_TYPE_FUNC_FULL (WombatInterfaceCheck, - GNOME_Evolution_WombatInterfaceCheck, - PARENT_TYPE, - wombat_interface_check) diff --git a/wombat/wombat-interface-check.h b/wombat/wombat-interface-check.h deleted file mode 100644 index 9cd00b5b62..0000000000 --- a/wombat/wombat-interface-check.h +++ /dev/null @@ -1,68 +0,0 @@ -/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 8; tab-width: 8 -*- */ -/* wombat-interface-check.h - * - * Copyright (C) 2002 Ximian, Inc. - * - * 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., 59 Temple Place - Suite 330, - * Boston, MA 02111-1307, USA. - * - * Author: Ettore Perazzoli <ettore@ximian.com> - */ - -#ifndef _WOMBAT_INTERFACE_CHECK_H_ -#define _WOMBAT_INTERFACE_CHECK_H_ - -#ifdef HAVE_CONFIG_H -#include <config.h> -#endif - -#include <bonobo/bonobo-object.h> -#include "Evolution-Wombat.h" - -#ifdef __cplusplus -extern "C" { -#pragma } -#endif /* __cplusplus */ - -#define WOMBAT_TYPE_INTERFACE_CHECK (wombat_interface_check_get_type ()) -#define WOMBAT_INTERFACE_CHECK(obj) (GTK_CHECK_CAST ((obj), WOMBAT_TYPE_INTERFACE_CHECK, WombatInterfaceCheck)) -#define WOMBAT_INTERFACE_CHECK_CLASS(klass) (GTK_CHECK_CLASS_CAST ((klass), WOMBAT_TYPE_INTERFACE_CHECK, WombatInterfaceCheckClass)) -#define WOMBAT_IS_INTERFACE_CHECK(obj) (GTK_CHECK_TYPE ((obj), WOMBAT_TYPE_INTERFACE_CHECK)) -#define WOMBAT_IS_INTERFACE_CHECK_CLASS(klass) (GTK_CHECK_CLASS_TYPE ((obj), WOMBAT_TYPE_INTERFACE_CHECK)) - - -typedef struct _WombatInterfaceCheck WombatInterfaceCheck; -typedef struct _WombatInterfaceCheckPrivate WombatInterfaceCheckPrivate; -typedef struct _WombatInterfaceCheckClass WombatInterfaceCheckClass; - -struct _WombatInterfaceCheck { - BonoboObject parent; -}; - -struct _WombatInterfaceCheckClass { - BonoboObjectClass parent_class; - - POA_GNOME_Evolution_WombatInterfaceCheck__epv epv; -}; - - -GType wombat_interface_check_get_type (void); -WombatInterfaceCheck *wombat_interface_check_new (void); - -#ifdef __cplusplus -} -#endif /* __cplusplus */ - -#endif /* _WOMBAT_INTERFACE_CHECK_H_ */ diff --git a/wombat/wombat.c b/wombat/wombat.c deleted file mode 100644 index 64b9c47677..0000000000 --- a/wombat/wombat.c +++ /dev/null @@ -1,262 +0,0 @@ -/* Wombat personal information server - main file - * - * Author: Nat Friedman <nat@ximian.com> - * - * Copyright 2000, Ximian, Inc. - */ - -#ifdef HAVE_CONFIG_H -#include <config.h> -#endif - -/* define this if you need/want to be able to send USR2 to wombat and - get a list of the active backends */ -/*#define DEBUG_BACKENDS*/ - -#include <stdlib.h> -#ifdef DEBUG_BACKENDS -#include <sys/signal.h> -#endif - -#include <glib.h> -#include <libgnome/gnome-init.h> -#include <bonobo-activation/bonobo-activation.h> -#include <libgnomevfs/gnome-vfs-init.h> -#include <bonobo/bonobo-main.h> -#include <bonobo/bonobo-i18n.h> -#include <bonobo/bonobo-exception.h> -#include <bonobo/bonobo-generic-factory.h> - -#include "pas/pas-book-factory.h" -#include "pas/pas-backend-file.h" -#include "pas/pas-backend-vcf.h" -#ifdef HAVE_LDAP -#include "pas/pas-backend-ldap.h" -#endif - -#include "calendar/pcs/cal-factory.h" -#include "calendar/pcs/cal-backend-file-events.h" -#include "calendar/pcs/cal-backend-file-todos.h" -#include "calendar/pcs/cal-backend-http.h" - -#include "wombat-interface-check.h" - -#define CAL_FACTORY_OAF_ID "OAFIID:GNOME_Evolution_Wombat_CalendarFactory" -#define PAS_BOOK_FACTORY_OAF_ID "OAFIID:GNOME_Evolution_Wombat_ServerFactory" - -/* The and addressbook calendar factories */ - -static CalFactory *cal_factory; - -static PASBookFactory *pas_book_factory; - -/* Timeout interval in milliseconds for termination */ -#define EXIT_TIMEOUT 5000 - -/* Timeout ID for termination handler */ -static guint termination_handler_id; - - - -/* Termination */ - -/* Termination handler. Checks if both factories have zero running backends, - * and if so terminates the program. - */ -static gboolean -termination_handler (gpointer data) -{ - if (cal_factory_get_n_backends (cal_factory) == 0 && - pas_book_factory_get_n_backends (pas_book_factory) == 0) { - fprintf (stderr, "termination_handler(): Terminating the Wombat. Have a nice day.\n"); - bonobo_main_quit (); - } - - termination_handler_id = 0; - return FALSE; -} - -/* Queues a timeout for handling termination of Wombat */ -static void -queue_termination (void) -{ - if (termination_handler_id) - return; - - termination_handler_id = g_timeout_add (EXIT_TIMEOUT, termination_handler, NULL); -} - - - -static void -last_book_gone_cb (PASBookFactory *factory, gpointer data) -{ - queue_termination (); -} - -static gboolean -setup_pas (void) -{ - pas_book_factory = pas_book_factory_new (); - - if (!pas_book_factory) - return FALSE; - - pas_book_factory_register_backend ( - pas_book_factory, "file", pas_backend_file_new); - - pas_book_factory_register_backend ( - pas_book_factory, "vcf", pas_backend_vcf_new); - -#ifdef HAVE_LDAP - pas_book_factory_register_backend ( - pas_book_factory, "ldap", pas_backend_ldap_new); -#endif - - g_signal_connect (pas_book_factory, - "last_book_gone", - G_CALLBACK (last_book_gone_cb), - NULL); - - if (!pas_book_factory_activate (pas_book_factory, PAS_BOOK_FACTORY_OAF_ID)) { - bonobo_object_unref (BONOBO_OBJECT (pas_book_factory)); - pas_book_factory = NULL; - return FALSE; - } - - return TRUE; -} - - -/* Personal calendar server */ - -/* Callback used when the calendar factory has no more running backends */ -static void -last_calendar_gone_cb (CalFactory *factory, gpointer data) -{ - queue_termination (); -} - -/* Creates the calendar factory object and registers it */ -static gboolean -setup_pcs (void) -{ - cal_factory = cal_factory_new (); - - if (!cal_factory) { - g_message ("setup_pcs(): Could not create the calendar factory"); - return FALSE; - } - - cal_factory_register_method (cal_factory, "file", ICAL_VEVENT_COMPONENT, CAL_BACKEND_FILE_EVENTS_TYPE); - cal_factory_register_method (cal_factory, "file", ICAL_VTODO_COMPONENT, CAL_BACKEND_FILE_TODOS_TYPE); - cal_factory_register_method (cal_factory, "webcal", ICAL_VEVENT_COMPONENT, CAL_BACKEND_HTTP_TYPE); - - if (!cal_factory_register_storage (cal_factory, CAL_FACTORY_OAF_ID)) { - bonobo_object_unref (BONOBO_OBJECT (cal_factory)); - cal_factory = NULL; - return FALSE; - } - - g_signal_connect (G_OBJECT (cal_factory), - "last_calendar_gone", - G_CALLBACK (last_calendar_gone_cb), - NULL); - - return TRUE; -} - - -/* Interface check iface. */ - -static gboolean -setup_interface_check (void) -{ - WombatInterfaceCheck *interface_check_iface = wombat_interface_check_new (); - int result; - - result = bonobo_activation_active_server_register ("OAFIID:GNOME_Evolution_Wombat_InterfaceCheck", - BONOBO_OBJREF (interface_check_iface)); - - return result == Bonobo_ACTIVATION_REG_SUCCESS; -} - - - -#ifdef DEBUG_BACKENDS -static void -dump_backends (int signal) -{ - pas_book_factory_dump_active_backends (pas_book_factory); - cal_factory_dump_active_backends (cal_factory); -} -#endif - -int -main (int argc, char **argv) -{ - gboolean did_pas=FALSE, did_pcs=FALSE; - - bindtextdomain (GETTEXT_PACKAGE, EVOLUTION_LOCALEDIR); - textdomain (GETTEXT_PACKAGE); - - g_message ("Starting wombat"); - -#ifdef DEBUG_BACKENDS - signal (SIGUSR2, dump_backends); -#endif - - gnome_program_init ("Wombat", VERSION, - LIBGNOME_MODULE, - argc, argv, - GNOME_PROGRAM_STANDARD_PROPERTIES, NULL); - - bonobo_init_full (&argc, argv, - bonobo_activation_orb_get(), - CORBA_OBJECT_NIL, - CORBA_OBJECT_NIL); - - if (!( (did_pas = setup_pas ()) - && (did_pcs = setup_pcs ()) - )) { - - const gchar *failed = NULL; - - if (!did_pas) - failed = "PAS"; - else if (!did_pcs) - failed = "PCS"; - - g_message ("main(): could not initialize Wombat service \"%s\"; terminating", failed); - - if (pas_book_factory) { - bonobo_object_unref (BONOBO_OBJECT (pas_book_factory)); - pas_book_factory = NULL; - } - - if (cal_factory) { - bonobo_object_unref (BONOBO_OBJECT (cal_factory)); - cal_factory = NULL; - } - exit (EXIT_FAILURE); - } - - if (! setup_interface_check ()) { - g_message ("Cannot register Wombat::InterfaceCheck object"); - exit (EXIT_FAILURE); - } - - g_print ("Wombat up and running\n"); - - bonobo_main (); - - bonobo_object_unref (BONOBO_OBJECT (cal_factory)); - cal_factory = NULL; - - bonobo_object_unref (BONOBO_OBJECT (pas_book_factory)); - pas_book_factory = NULL; - - gnome_vfs_shutdown (); - - return 0; -} |