aboutsummaryrefslogtreecommitdiffstats
path: root/calendar
diff options
context:
space:
mode:
Diffstat (limited to 'calendar')
-rw-r--r--calendar/ChangeLog12
-rw-r--r--calendar/cal-client/cal-client.c2
-rw-r--r--calendar/gui/e-calendar-table.c2
-rw-r--r--calendar/gui/e-day-view.c70
-rw-r--r--calendar/gui/e-week-view.c74
5 files changed, 147 insertions, 13 deletions
diff --git a/calendar/ChangeLog b/calendar/ChangeLog
index 07bc15705d..9860c7b52a 100644
--- a/calendar/ChangeLog
+++ b/calendar/ChangeLog
@@ -1,3 +1,15 @@
+2001-07-25 Rodrigo Moya <rodrigo@ximian.com>
+
+ * gui/e-day-view.c (selection_received_cb): check type of component
+ before actually pasting.
+ Deal with VCALENDAR components also (fixes bug #5140)
+
+ * gui/e-week-view.c (selection_received_cb): ditto
+
+ * cal-client/cal-client.c (cal_client_update_object): check the return
+ value from cal_component_get_as_string and don't call
+ GNOME_Evolution_Calendar_Cal_updateObjects if NULL
+
2001-07-25 Damon Chaplin <damon@ximian.com>
* gui/dialogs/comp-editor.c (pixmaps): used the new print preview icon.
diff --git a/calendar/cal-client/cal-client.c b/calendar/cal-client/cal-client.c
index 4d2ba2805b..601686b3bc 100644
--- a/calendar/cal-client/cal-client.c
+++ b/calendar/cal-client/cal-client.c
@@ -1867,6 +1867,8 @@ cal_client_update_object (CalClient *client, CalComponent *comp)
cal_component_commit_sequence (comp);
obj_string = cal_client_get_component_as_string (client, comp);
+ if (obj_string == NULL)
+ return FALSE;
CORBA_exception_init (&ev);
GNOME_Evolution_Calendar_Cal_updateObjects (priv->cal, obj_string, &ev);
diff --git a/calendar/gui/e-calendar-table.c b/calendar/gui/e-calendar-table.c
index e24f1d3d2b..999b64d99f 100644
--- a/calendar/gui/e-calendar-table.c
+++ b/calendar/gui/e-calendar-table.c
@@ -1191,6 +1191,8 @@ selection_received (GtkWidget *invisible,
CalComponent *comp;
icalcomponent_kind kind;
+ g_return_if_fail (E_IS_CALENDAR_TABLE (cal_table));
+
if (selection_data->length < 0 ||
selection_data->type != GDK_SELECTION_TYPE_STRING) {
return;
diff --git a/calendar/gui/e-day-view.c b/calendar/gui/e-day-view.c
index d46d941c2b..7f11e2d7b5 100644
--- a/calendar/gui/e-day-view.c
+++ b/calendar/gui/e-day-view.c
@@ -6673,6 +6673,7 @@ selection_received (GtkWidget *invisible,
icalcomponent *icalcomp;
time_t dtstart, dtend;
struct icaltimetype itime;
+ icalcomponent_kind kind;
CalComponent *comp;
char *uid;
@@ -6685,21 +6686,78 @@ selection_received (GtkWidget *invisible,
comp_str = (char *) selection_data->data;
icalcomp = icalparser_parse_string ((const char *) comp_str);
- if (icalcomp) {
- e_day_view_get_selected_time_range (day_view, &dtstart, &dtend);
+ if (!icalcomp)
+ return;
+
+ /* check the type of the component */
+ kind = icalcomponent_isa (icalcomp);
+ if (kind != ICAL_VCALENDAR_COMPONENT &&
+ kind != ICAL_VEVENT_COMPONENT &&
+ kind != ICAL_VTODO_COMPONENT &&
+ kind != ICAL_VJOURNAL_COMPONENT) {
+ return;
+ }
+
+ e_day_view_get_selected_time_range (day_view, &dtstart, &dtend);
+
+ if (kind == ICAL_VCALENDAR_COMPONENT) {
+ int num_found = 0;
+ icalcomponent_kind child_kind;
+ icalcomponent *subcomp;
+
+ subcomp = icalcomponent_get_first_component (
+ icalcomp, ICAL_ANY_COMPONENT);
+ while (subcomp) {
+ child_kind = icalcomponent_isa (subcomp);
+ if (child_kind == ICAL_VEVENT_COMPONENT ||
+ child_kind == ICAL_VTODO_COMPONENT ||
+ child_kind == ICAL_VJOURNAL_COMPONENT) {
+ CalComponent *tmp_comp;
+
+ itime = icaltime_from_timet_with_zone (dtstart, FALSE, day_view->zone);
+ /* FIXME: Need to set TZID. */
+ icalcomponent_set_dtstart (icalcomp, itime);
+
+ itime = icaltime_from_timet_with_zone (dtend, FALSE, day_view->zone);
+ /* FIXME: Need to set TZID. */
+ icalcomponent_set_dtend (icalcomp, itime);
+
+ uid = cal_component_gen_uid ();
+ tmp_comp = cal_component_new ();
+ cal_component_set_icalcomponent (
+ tmp_comp, icalcomponent_new_clone (subcomp));
+ cal_component_set_uid (tmp_comp, uid);
+
+ free (uid);
+ gtk_object_unref (GTK_OBJECT (tmp_comp));
+
+ num_found++;
+ }
+ subcomp = icalcomponent_get_next_component (
+ icalcomp, ICAL_ANY_COMPONENT);
+ }
+
+ if (num_found) {
+ comp = cal_component_new ();
+ cal_component_set_icalcomponent (comp, icalcomp);
- itime = icaltime_from_timet_with_zone (dtstart, FALSE,
- day_view->zone);
+ cal_client_update_object (day_view->client, comp);
+
+ gtk_object_unref (GTK_OBJECT (comp));
+ }
+ }
+ else {
+ itime = icaltime_from_timet_with_zone (dtstart, FALSE, day_view->zone);
/* FIXME: Need to set TZID. */
icalcomponent_set_dtstart (icalcomp, itime);
- itime = icaltime_from_timet_with_zone (dtend, FALSE,
- day_view->zone);
+ itime = icaltime_from_timet_with_zone (dtend, FALSE, day_view->zone);
/* FIXME: Need to set TZID. */
icalcomponent_set_dtend (icalcomp, itime);
comp = cal_component_new ();
cal_component_set_icalcomponent (comp, icalcomp);
+
uid = cal_component_gen_uid ();
cal_component_set_uid (comp, (const char *) uid);
free (uid);
diff --git a/calendar/gui/e-week-view.c b/calendar/gui/e-week-view.c
index 719297fe7e..0f230c21fe 100644
--- a/calendar/gui/e-week-view.c
+++ b/calendar/gui/e-week-view.c
@@ -3583,6 +3583,7 @@ selection_received (GtkWidget *invisible,
icalcomponent *icalcomp;
time_t dtstart, dtend;
struct icaltimetype itime;
+ icalcomponent_kind kind;
CalComponent *comp;
char *uid;
@@ -3595,15 +3596,74 @@ selection_received (GtkWidget *invisible,
comp_str = (char *) selection_data->data;
icalcomp = icalparser_parse_string ((const char *) comp_str);
- if (icalcomp) {
- dtstart = week_view->day_starts[week_view->selection_start_day];
- itime = icaltime_from_timet_with_zone (dtstart, FALSE,
- week_view->zone);
+ if (!icalcomp)
+ return;
+
+ /* check the type of the component */
+ kind = icalcomponent_isa (icalcomp);
+ if (kind != ICAL_VCALENDAR_COMPONENT &&
+ kind != ICAL_VEVENT_COMPONENT &&
+ kind != ICAL_VTODO_COMPONENT &&
+ kind != ICAL_VJOURNAL_COMPONENT) {
+ return;
+ }
+
+ dtstart = week_view->day_starts[week_view->selection_start_day];
+ dtend = week_view->day_starts[week_view->selection_end_day + 1];
+
+ if (kind == ICAL_VCALENDAR_COMPONENT) {
+ int num_found = 0;
+ icalcomponent_kind child_kind;
+ icalcomponent *subcomp;
+
+ subcomp = icalcomponent_get_first_component (
+ icalcomp, ICAL_ANY_COMPONENT);
+ while (subcomp) {
+ child_kind = icalcomponent_isa (subcomp);
+ if (child_kind == ICAL_VEVENT_COMPONENT ||
+ child_kind == ICAL_VTODO_COMPONENT ||
+ child_kind == ICAL_VJOURNAL_COMPONENT) {
+ CalComponent *tmp_comp;
+
+ itime = icaltime_from_timet_with_zone (dtstart, FALSE, week_view->zone);
+ /* FIXME: Need to set TZID. */
+ icalcomponent_set_dtstart (icalcomp, itime);
+
+ itime = icaltime_from_timet_with_zone (dtend, FALSE, week_view->zone);
+ /* FIXME: Need to set TZID. */
+ icalcomponent_set_dtend (icalcomp, itime);
+
+ uid = cal_component_gen_uid ();
+ tmp_comp = cal_component_new ();
+ cal_component_set_icalcomponent (
+ tmp_comp, icalcomponent_new_clone (subcomp));
+ cal_component_set_uid (tmp_comp, uid);
+
+ free (uid);
+ gtk_object_unref (GTK_OBJECT (tmp_comp));
+
+ num_found++;
+ }
+ subcomp = icalcomponent_get_next_component (
+ icalcomp, ICAL_ANY_COMPONENT);
+ }
+
+ if (num_found) {
+ comp = cal_component_new ();
+ cal_component_set_icalcomponent (comp, icalcomp);
+
+ cal_client_update_object (week_view->client, comp);
+
+ gtk_object_unref (GTK_OBJECT (comp));
+ }
+ }
+ else {
+ itime = icaltime_from_timet_with_zone (dtstart, FALSE, week_view->zone);
+ /* FIXME: need to set TZID */
icalcomponent_set_dtstart (icalcomp, itime);
- dtend = week_view->day_starts[week_view->selection_end_day + 1];
- itime = icaltime_from_timet_with_zone (dtend, FALSE,
- week_view->zone);
+ itime = icaltime_from_timet_with_zone (dtend, FALSE, week_view->zone);
+ /* FIXME: need to set TZID */
icalcomponent_set_dtend (icalcomp, itime);
comp = cal_component_new ();