aboutsummaryrefslogtreecommitdiffstats
path: root/calendar
diff options
context:
space:
mode:
Diffstat (limited to 'calendar')
-rw-r--r--calendar/ChangeLog7
-rw-r--r--calendar/conduits/calendar/calendar-conduit.c76
-rw-r--r--calendar/gui/e-meeting-model.c124
3 files changed, 123 insertions, 84 deletions
diff --git a/calendar/ChangeLog b/calendar/ChangeLog
index af77afeebc..1bd6d5f607 100644
--- a/calendar/ChangeLog
+++ b/calendar/ChangeLog
@@ -1,3 +1,10 @@
+2001-10-30 JP Rosevear <jpr@ximian.com>
+
+ * gui/e-meeting-model.c (process_section): process an individual
+ section here
+ (select_names_ok_cb): call above
+ (get_select_name_dialog): listen for ok:dialog signal
+
2001-10-29 Damon Chaplin <damon@ximian.com>
* importers/Makefile.am (evolution_calendar_importer_LDADD):
diff --git a/calendar/conduits/calendar/calendar-conduit.c b/calendar/conduits/calendar/calendar-conduit.c
index fcd976355d..c845fc4516 100644
--- a/calendar/conduits/calendar/calendar-conduit.c
+++ b/calendar/conduits/calendar/calendar-conduit.c
@@ -367,6 +367,7 @@ process_multi_day (ECalConduitContext *ctxt, CalClientChange *ccc, GList **multi
icaltimezone *tz_start, *tz_end;
time_t event_start, event_end, day_end;
struct icaltimetype *old_start_value, *old_end_value;
+ const char *uid;
gboolean last = FALSE;
gboolean ret = TRUE;
@@ -375,27 +376,34 @@ process_multi_day (ECalConduitContext *ctxt, CalClientChange *ccc, GList **multi
if (ccc->type == CAL_CLIENT_CHANGE_DELETED)
return FALSE;
-
+
+ /* Start time */
cal_component_get_dtstart (ccc->comp, &dt_start);
- tz_start = get_timezone (ctxt->client, dt_start.tzid);
+ 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);
- tz_end = get_timezone (ctxt->client, dt_end.tzid);
+ if (dt_end.value->is_date) {
+ icaltime_adjust (dt_end.value, 1, 0, 0, 0);
+ tz_end = ctxt->timezone;
+ } else {
+ tz_end = get_timezone (ctxt->client, dt_end.tzid);
+ }
event_end = icaltime_as_timet_with_zone (*dt_end.value, tz_end);
- day_end = time_day_end_with_zone (event_start, ctxt->timezone);
-
- if (day_end < event_end) {
- const char *uid;
-
- cal_component_get_uid (ccc->comp, &uid);
- cal_client_remove_object (ctxt->client, uid);
- ccc->type = CAL_CLIENT_CHANGE_DELETED;
- } else {
+ day_end = time_day_end_with_zone (event_start, ctxt->timezone);
+ if (day_end >= event_end) {
ret = FALSE;
goto cleanup;
+ } else if (cal_component_has_recurrences (ccc->comp)) {
+ ret = TRUE;
+ goto cleanup;
}
+ INFO ("Split info: %lu, %lu, %lu", event_start, event_end, day_end);
old_start_value = dt_start.value;
old_end_value = dt_end.value;
while (!last) {
@@ -408,14 +416,15 @@ process_multi_day (ECalConduitContext *ctxt, CalClientChange *ccc, GList **multi
day_end = event_end;
last = TRUE;
}
-
+
cal_component_set_uid (clone, new_uid);
-
+
start_value = icaltime_from_timet_with_zone (event_start, FALSE, tz_start);
dt_start.value = &start_value;
+ cal_component_set_dtstart (clone, &dt_start);
+
end_value = icaltime_from_timet_with_zone (day_end, FALSE, tz_end);
dt_end.value = &end_value;
- cal_component_set_dtstart (clone, &dt_start);
cal_component_set_dtend (clone, &dt_end);
cal_client_update_object (ctxt->client, clone);
@@ -431,6 +440,10 @@ 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);
+ cal_client_remove_object (ctxt->client, uid);
+ ccc->type = CAL_CLIENT_CHANGE_DELETED;
cleanup:
cal_component_free_datetime (&dt_start);
@@ -951,7 +964,7 @@ pre_sync (GnomePilotConduit *conduit,
ECalConduitContext *ctxt)
{
GnomePilotConduitSyncAbs *abs_conduit;
- GList *l;
+ GList *removed = NULL, *added = NULL, *l;
int len;
unsigned char *buf;
char *filename, *change_id;
@@ -964,7 +977,9 @@ pre_sync (GnomePilotConduit *conduit,
ctxt->dbi = dbi;
ctxt->client = NULL;
-
+
+ gnome_pilot_conduit_warning (conduit, "Random warning");
+
if (start_calendar_server (ctxt) != 0) {
WARN(_("Could not start wombat server"));
gnome_pilot_conduit_error (conduit, _("Could not start wombat"));
@@ -995,24 +1010,33 @@ pre_sync (GnomePilotConduit *conduit,
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;
GList *multi_uid = NULL, *multi_ccc = NULL;
- /* Handle Multi-day events */
if (process_multi_day (ctxt, ccc, &multi_uid, &multi_ccc)) {
- const char *uid;
ctxt->uids = g_list_concat (ctxt->uids, multi_uid);
- ctxt->changed = g_list_concat (ctxt->changed, multi_ccc);
+
+ added = g_list_concat (added, multi_ccc);
+ removed = g_list_prepend (removed, ccc);
+ }
+ }
- 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);
- gtk_object_unref (GTK_OBJECT (ccc->comp));
- g_free (ccc);
- }
+ /* 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;
+ const char *uid;
+
+ 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);
+ gtk_object_unref (GTK_OBJECT (ccc->comp));
+ g_free (ccc);
}
}
+ g_list_free (removed);
for (l = ctxt->changed; l != NULL; l = l->next) {
CalClientChange *ccc = l->data;
diff --git a/calendar/gui/e-meeting-model.c b/calendar/gui/e-meeting-model.c
index c9555a6f9b..d57da3b78a 100644
--- a/calendar/gui/e-meeting-model.c
+++ b/calendar/gui/e-meeting-model.c
@@ -89,6 +89,17 @@ struct _EMeetingModelPrivate
#define BUF_SIZE 1024
+static char *sections[] = {N_("Chair Persons"),
+ N_("Required Participants"),
+ N_("Optional Participants"),
+ N_("Non-Participants"),
+ NULL};
+static icalparameter_role roles[] = {ICAL_ROLE_CHAIR,
+ ICAL_ROLE_REQPARTICIPANT,
+ ICAL_ROLE_OPTPARTICIPANT,
+ ICAL_ROLE_NONPARTICIPANT,
+ ICAL_ROLE_NONE};
+
typedef struct _EMeetingModelAttendeeRefreshData EMeetingModelAttendeeRefreshData;
struct _EMeetingModelAttendeeRefreshData {
char buffer[BUF_SIZE];
@@ -110,11 +121,11 @@ static void init (EMeetingModel *model);
static void destroy (GtkObject *obj);
static void attendee_changed_cb (EMeetingAttendee *ia, gpointer data);
-static void invite_entry_changed_cb (BonoboListener *listener,
- char *event_name,
- CORBA_any *arg,
- CORBA_Environment *ev,
- gpointer data);
+static void select_names_ok_cb (BonoboListener *listener,
+ char *event_name,
+ CORBA_any *arg,
+ CORBA_Environment *ev,
+ gpointer data);
static void table_destroy_cb (ETableScrolled *etable, gpointer data);
@@ -1326,18 +1337,16 @@ e_meeting_model_etable_from_model (EMeetingModel *im, const gchar *spec_file, co
}
static void
-add_section (GNOME_Evolution_Addressbook_SelectNames corba_select_names, const char *name, int limit)
+add_section (GNOME_Evolution_Addressbook_SelectNames corba_select_names, const char *name)
{
CORBA_Environment ev;
CORBA_exception_init (&ev);
- if (limit != 0)
- GNOME_Evolution_Addressbook_SelectNames_addSectionWithLimit (corba_select_names,
- name, name, limit, &ev);
- else
- GNOME_Evolution_Addressbook_SelectNames_addSection (corba_select_names,
- name, name, &ev);
+ GNOME_Evolution_Addressbook_SelectNames_addSection (corba_select_names,
+ name,
+ gettext (name),
+ &ev);
CORBA_exception_free (&ev);
}
@@ -1346,11 +1355,8 @@ static gboolean
get_select_name_dialog (EMeetingModel *im)
{
EMeetingModelPrivate *priv;
- const char *sections[] = {_("Chair Persons"),
- _("Required Participants"),
- _("Optional Participants"),
- _("Non-Participants")};
CORBA_Environment ev;
+ int i;
priv = im->priv;
@@ -1360,8 +1366,9 @@ get_select_name_dialog (EMeetingModel *im)
int i;
CORBA_exception_init (&ev);
- for (i = 0; i < 4; i++) {
- corba_control = GNOME_Evolution_Addressbook_SelectNames_getEntryBySection (priv->corba_select_names, sections[i], &ev);
+ for (i = 0; sections[i] != NULL; i++) {
+ corba_control = GNOME_Evolution_Addressbook_SelectNames_getEntryBySection
+ (priv->corba_select_names, sections[i], &ev);
if (BONOBO_EX (&ev)) {
CORBA_exception_free (&ev);
return FALSE;
@@ -1380,14 +1387,12 @@ get_select_name_dialog (EMeetingModel *im)
priv->corba_select_names = oaf_activate_from_id (SELECT_NAMES_OAFID, 0, NULL, &ev);
- add_section (priv->corba_select_names, sections[0], 0);
- add_section (priv->corba_select_names, sections[1], 0);
- add_section (priv->corba_select_names, sections[2], 0);
- add_section (priv->corba_select_names, sections[3], 0);
+ for (i = 0; sections[i] != NULL; i++)
+ add_section (priv->corba_select_names, sections[i]);
bonobo_event_source_client_add_listener (priv->corba_select_names,
- invite_entry_changed_cb,
- "GNOME/Evolution:changed:model",
+ select_names_ok_cb,
+ "GNOME/Evolution:ok:dialog",
NULL, im);
if (BONOBO_EX (&ev)) {
@@ -1420,34 +1425,10 @@ e_meeting_model_invite_others_dialog (EMeetingModel *im)
}
static void
-invite_entry_changed_cb (BonoboListener *listener,
- char *event_name,
- CORBA_any *arg,
- CORBA_Environment *ev,
- gpointer data)
+process_section (EMeetingModel *im, EDestination **destv, icalparameter_role role)
{
- EMeetingModel *im = data;
- EMeetingModelPrivate *priv;
- Bonobo_Control corba_control;
- GtkWidget *control_widget;
- EDestination **destv;
- char *string = NULL, *section;
int i;
- priv = im->priv;
-
- section = BONOBO_ARG_GET_STRING (arg);
-
- g_message ("event: \"%s\", section \"%s\"", event_name, section);
-
- corba_control = GNOME_Evolution_Addressbook_SelectNames_getEntryBySection (priv->corba_select_names, section, ev);
- control_widget = bonobo_widget_new_control_from_objref (corba_control, CORBA_OBJECT_NIL);
-
- bonobo_widget_get_property (BONOBO_WIDGET (control_widget), "destinations", &string, NULL);
- destv = e_destination_importv (string);
- if (destv == NULL)
- return;
-
for (i = 0; destv[i] != NULL; i++) {
EMeetingAttendee *ia;
const char *name, *address;
@@ -1455,22 +1436,49 @@ invite_entry_changed_cb (BonoboListener *listener,
name = e_destination_get_name (destv[i]);
address = e_destination_get_email (destv[i]);
+ if (address == NULL || *address == '\0')
+ continue;
+
if (e_meeting_model_find_attendee (im, address, NULL) == NULL) {
ia = e_meeting_model_add_attendee_with_defaults (im);
e_meeting_attendee_set_address (ia, g_strdup_printf ("MAILTO:%s", address));
- if (!strcmp (section, _("Chair Persons")))
- e_meeting_attendee_set_role (ia, ICAL_ROLE_CHAIR);
- else if (!strcmp (section, _("Required Participants")))
- e_meeting_attendee_set_role (ia, ICAL_ROLE_REQPARTICIPANT);
- else if (!strcmp (section, _("Optional Participants")))
- e_meeting_attendee_set_role (ia, ICAL_ROLE_OPTPARTICIPANT);
- else if (!strcmp (section, _("Non-Participants")))
- e_meeting_attendee_set_role (ia, ICAL_ROLE_NONPARTICIPANT);
+ e_meeting_attendee_set_role (ia, role);
e_meeting_attendee_set_cn (ia, g_strdup (name));
}
}
- e_destination_freev (destv);
+}
+
+static void
+select_names_ok_cb (BonoboListener *listener,
+ char *event_name,
+ CORBA_any *arg,
+ CORBA_Environment *ev,
+ gpointer data)
+{
+ EMeetingModel *im = data;
+ EMeetingModelPrivate *priv;
+ Bonobo_Control corba_control;
+ GtkWidget *control_widget;
+ EDestination **destv;
+ char *string = NULL;
+ int i;
+
+ priv = im->priv;
+
+ for (i = 0; sections[i] != NULL; i++) {
+ corba_control = GNOME_Evolution_Addressbook_SelectNames_getEntryBySection
+ (priv->corba_select_names, sections[i], ev);
+ control_widget = bonobo_widget_new_control_from_objref
+ (corba_control, CORBA_OBJECT_NIL);
+
+ bonobo_widget_get_property (BONOBO_WIDGET (control_widget), "destinations", &string, NULL);
+ destv = e_destination_importv (string);
+ if (destv != NULL) {
+ process_section (im, destv, roles[i]);
+ e_destination_freev (destv);
+ }
+ }
}
static void