aboutsummaryrefslogtreecommitdiffstats
path: root/calendar
diff options
context:
space:
mode:
authorJP Rosevear <jpr@ximian.com>2001-07-27 09:00:33 +0800
committerJP Rosevear <jpr@src.gnome.org>2001-07-27 09:00:33 +0800
commit6229cd14f15ac6b3ba82ea5110ced18cc96bde1e (patch)
tree9a1be40fd5db5a7e1ff54057e822504a694c5d06 /calendar
parent11198e3e269225589650e27c8bbd3d219dac2c9b (diff)
downloadgsoc2013-evolution-6229cd14f15ac6b3ba82ea5110ced18cc96bde1e.tar
gsoc2013-evolution-6229cd14f15ac6b3ba82ea5110ced18cc96bde1e.tar.gz
gsoc2013-evolution-6229cd14f15ac6b3ba82ea5110ced18cc96bde1e.tar.bz2
gsoc2013-evolution-6229cd14f15ac6b3ba82ea5110ced18cc96bde1e.tar.lz
gsoc2013-evolution-6229cd14f15ac6b3ba82ea5110ced18cc96bde1e.tar.xz
gsoc2013-evolution-6229cd14f15ac6b3ba82ea5110ced18cc96bde1e.tar.zst
gsoc2013-evolution-6229cd14f15ac6b3ba82ea5110ced18cc96bde1e.zip
free a list of attendees (meeting_page_fill_widgets): clean up attendee
2001-07-26 JP Rosevear <jpr@ximian.com> * gui/dialogs/meeting-page.c (cleanup_attendees): free a list of attendees (meeting_page_fill_widgets): clean up attendee lists and fix typo (find_match): add ability to return pos of match (popup_delete_cb): if deletion happens, make sure to tidy up delegation chain * gui/dialogs/e-delegate-dialog.c (e_delegate_dialog_construct): use the destination rather than text property (e_delegate_dialog_get_delegate): ditto (e_delegate_dialog_new): take name/address pair for dialog default * gui/dialogs/e-delegate-dialog.h: update protos * gui/e-itip-control.c (clean_up): only unref the object if we have one * gui/itip-control-factory.c (stream_read): make sure we null terminate the final buffer * gui/itip-utils.c (itip_send_comp): strip the mailto: from the organizer address if necessary svn path=/trunk/; revision=11440
Diffstat (limited to 'calendar')
-rw-r--r--calendar/ChangeLog25
-rw-r--r--calendar/gui/dialogs/e-delegate-dialog.c40
-rw-r--r--calendar/gui/dialogs/e-delegate-dialog.h20
-rw-r--r--calendar/gui/dialogs/meeting-page.c104
-rw-r--r--calendar/gui/e-itip-control.c3
-rw-r--r--calendar/gui/itip-bonobo-control.c15
-rw-r--r--calendar/gui/itip-control-factory.c15
-rw-r--r--calendar/gui/itip-utils.c2
8 files changed, 156 insertions, 68 deletions
diff --git a/calendar/ChangeLog b/calendar/ChangeLog
index c5547f57a9..c8f98c5939 100644
--- a/calendar/ChangeLog
+++ b/calendar/ChangeLog
@@ -1,3 +1,28 @@
+2001-07-26 JP Rosevear <jpr@ximian.com>
+
+ * gui/dialogs/meeting-page.c (cleanup_attendees): free a list of
+ attendees
+ (meeting_page_fill_widgets): clean up attendee lists and fix typo
+ (find_match): add ability to return pos of match
+ (popup_delete_cb): if deletion happens, make sure to tidy up
+ delegation chain
+
+ * gui/dialogs/e-delegate-dialog.c (e_delegate_dialog_construct):
+ use the destination rather than text property
+ (e_delegate_dialog_get_delegate): ditto
+ (e_delegate_dialog_new): take name/address pair for dialog default
+
+ * gui/dialogs/e-delegate-dialog.h: update protos
+
+ * gui/e-itip-control.c (clean_up): only unref the object if we
+ have one
+
+ * gui/itip-control-factory.c (stream_read): make sure we null
+ terminate the final buffer
+
+ * gui/itip-utils.c (itip_send_comp): strip the mailto: from the
+ organizer address if necessary
+
2001-07-26 Damon Chaplin <damon@ximian.com>
* gui/dialogs/recurrence-page.c (exception_select_row_cb): check that
diff --git a/calendar/gui/dialogs/e-delegate-dialog.c b/calendar/gui/dialogs/e-delegate-dialog.c
index beb93d5dc8..1a245d0d32 100644
--- a/calendar/gui/dialogs/e-delegate-dialog.c
+++ b/calendar/gui/dialogs/e-delegate-dialog.c
@@ -145,9 +145,11 @@ e_delegate_dialog_destroy (GtkObject *object)
EDelegateDialog *
-e_delegate_dialog_construct (EDelegateDialog *edd)
+e_delegate_dialog_construct (EDelegateDialog *edd, const char *name, const char *address)
{
EDelegateDialogPrivate *priv;
+ EDestination *dest;
+ EDestination *destv[2] = {NULL, NULL};
Bonobo_Control corba_control;
CORBA_Environment ev;
@@ -197,7 +199,15 @@ e_delegate_dialog_construct (EDelegateDialog *edd)
gtk_widget_show (priv->entry);
gtk_box_pack_start (GTK_BOX (priv->hbox), priv->entry, TRUE, TRUE, 0);
-
+ dest = e_destination_new ();
+ destv[0] = dest;
+ if (name != NULL && *name)
+ e_destination_set_name (dest, name);
+ if (address != NULL && *address)
+ e_destination_set_email (dest, address);
+ bonobo_widget_set_property (BONOBO_WIDGET (priv->entry), "destinations", e_destination_exportv (destv), NULL);
+ gtk_object_unref (GTK_OBJECT (dest));
+
gtk_signal_connect (GTK_OBJECT (priv->addressbook), "clicked",
GTK_SIGNAL_FUNC (addressbook_clicked_cb), edd);
@@ -253,12 +263,12 @@ addressbook_clicked_cb (GtkWidget *widget, gpointer data)
* editor could not be created.
**/
EDelegateDialog *
-e_delegate_dialog_new (void)
+e_delegate_dialog_new (const char *name, const char *address)
{
EDelegateDialog *edd;
edd = E_DELEGATE_DIALOG (gtk_type_new (E_TYPE_DELEGATE_DIALOG));
- return e_delegate_dialog_construct (E_DELEGATE_DIALOG (edd));
+ return e_delegate_dialog_construct (E_DELEGATE_DIALOG (edd), name, address);
}
char *
@@ -273,11 +283,9 @@ e_delegate_dialog_get_delegate (EDelegateDialog *edd)
priv = edd->priv;
- bonobo_widget_get_property (BONOBO_WIDGET (priv->entry), "text", &string, NULL);
+ bonobo_widget_get_property (BONOBO_WIDGET (priv->entry), "destinations", &string, NULL);
destv = e_destination_importv (string);
- g_message ("importv: [%s]", string);
-
if (destv && destv[0] != NULL) {
g_free (priv->address);
priv->address = g_strdup (e_destination_get_email (destv[0]));
@@ -318,24 +326,6 @@ e_delegate_dialog_get_delegate_name (EDelegateDialog *edd)
return g_strdup (priv->name);
}
-void
-e_delegate_dialog_set_delegate (EDelegateDialog *edd,
- const char *address)
-{
- EDelegateDialogPrivate *priv;
-
- g_return_if_fail (edd != NULL);
- g_return_if_fail (E_IS_DELEGATE_DIALOG (edd));
-
- priv = edd->priv;
-
- if (priv->address)
- g_free (priv->address);
-
- priv->address = g_strdup (address);
-}
-
-
GtkWidget*
e_delegate_dialog_get_toplevel (EDelegateDialog *edd)
{
diff --git a/calendar/gui/dialogs/e-delegate-dialog.h b/calendar/gui/dialogs/e-delegate-dialog.h
index 971751828b..fd083ec2ca 100644
--- a/calendar/gui/dialogs/e-delegate-dialog.h
+++ b/calendar/gui/dialogs/e-delegate-dialog.h
@@ -50,20 +50,24 @@ struct _EDelegateDialogClass {
GtkObjectClass parent_class;
};
+GtkType e_delegate_dialog_get_type (void);
-GtkType e_delegate_dialog_get_type (void);
-EDelegateDialog* e_delegate_dialog_construct (EDelegateDialog *etd);
+EDelegateDialog* e_delegate_dialog_construct (EDelegateDialog *etd,
+ const char *name,
+ const char *address);
-EDelegateDialog* e_delegate_dialog_new (void);
+EDelegateDialog* e_delegate_dialog_new (const char *name,
+ const char *address);
-char* e_delegate_dialog_get_delegate (EDelegateDialog *etd);
+char* e_delegate_dialog_get_delegate (EDelegateDialog *etd);
-char* e_delegate_dialog_get_delegate_name (EDelegateDialog *etd);
+char* e_delegate_dialog_get_delegate_name (EDelegateDialog *etd);
-void e_delegate_dialog_set_delegate (EDelegateDialog *etd,
- const char *address);
+void e_delegate_dialog_set_delegate (EDelegateDialog *etd,
+ const char *address);
+
+GtkWidget* e_delegate_dialog_get_toplevel (EDelegateDialog *etd);
-GtkWidget* e_delegate_dialog_get_toplevel (EDelegateDialog *etd);
diff --git a/calendar/gui/dialogs/meeting-page.c b/calendar/gui/dialogs/meeting-page.c
index 89f511e77d..27f927cfa0 100644
--- a/calendar/gui/dialogs/meeting-page.c
+++ b/calendar/gui/dialogs/meeting-page.c
@@ -90,9 +90,10 @@ struct attendee {
/* Private part of the MeetingPage structure */
struct _MeetingPagePrivate {
- /* List of attendees */
+ /* Lists of attendees */
GSList *attendees;
-
+ GSList *deleted_attendees;
+
/* List of identities */
GList *addresses;
GList *address_strings;
@@ -221,6 +222,28 @@ meeting_page_init (MeetingPage *mpage)
priv->updating = FALSE;
}
+static void
+cleanup_attendees (GSList *attendees)
+{
+ GSList *l;
+
+ for (l = attendees; l != NULL; l = l->next) {
+ struct attendee *a = l->data;
+
+ g_free (a->address);
+ g_free (a->member);
+ g_free (a->delto);
+ g_free (a->delfrom);
+ g_free (a->sentby);
+ g_free (a->cn);
+ g_free (a->language);
+
+ g_free (a);
+ }
+
+ g_slist_free (attendees);
+}
+
/* Destroy handler for the task page */
static void
meeting_page_destroy (GtkObject *object)
@@ -236,6 +259,9 @@ meeting_page_destroy (GtkObject *object)
mpage = MEETING_PAGE (object);
priv = mpage->priv;
+ cleanup_attendees (priv->attendees);
+ cleanup_attendees (priv->deleted_attendees);
+
itip_addresses_free (priv->addresses);
g_list_free (priv->address_strings);
@@ -322,6 +348,12 @@ meeting_page_fill_widgets (CompEditorPage *page, CalComponent *comp)
priv->updating = TRUE;
+ /* Clean out old data */
+ cleanup_attendees (priv->attendees);
+ cleanup_attendees (priv->deleted_attendees);
+ priv->attendees = NULL;
+ priv->deleted_attendees = NULL;
+
/* Clean the screen */
clear_widgets (mpage);
@@ -369,7 +401,7 @@ meeting_page_fill_widgets (CompEditorPage *page, CalComponent *comp)
attendee->status = att->status;
attendee->rsvp = att->rsvp;
attendee->delto = att->delto ? g_strdup (att->delto) : g_strdup ("");
- attendee->delfrom = att->delto ? g_strdup (att->delfrom) : g_strdup ("");
+ attendee->delfrom = att->delfrom ? g_strdup (att->delfrom) : g_strdup ("");
attendee->sentby = att->sentby ? g_strdup (att->sentby) : g_strdup ("");
attendee->cn = att->cn ? g_strdup (att->cn) : g_strdup ("");
attendee->language = att->language ? g_strdup (att->language) : g_strdup ("");
@@ -819,20 +851,27 @@ partstat_to_text (CalComponentPartStat partstat)
}
static struct attendee *
-is_duplicate (MeetingPage *mpage, char *address)
+find_match (MeetingPage *mpage, char *address, int *pos)
{
MeetingPagePrivate *priv;
struct attendee *a;
GSList *l;
+ int i;
priv = mpage->priv;
+ if (address == NULL)
+ return NULL;
+
/* Make sure we can add the new delegatee person */
- for (l = priv->attendees; l != NULL; l = l->next) {
+ for (l = priv->attendees, i = 0; l != NULL; l = l->next, i++) {
a = l->data;
- if (a->address != NULL && !g_strcasecmp (itip_strip_mailto (a->address), itip_strip_mailto (address)))
+ if (a->address != NULL && !g_strcasecmp (itip_strip_mailto (a->address), itip_strip_mailto (address))) {
+ if (pos != NULL)
+ *pos = i;
return a;
+ }
}
return NULL;
@@ -876,7 +915,7 @@ append_row (ETableModel *etm, ETableModel *model, int row, void *data)
priv = mpage->priv;
address = (char *) e_table_model_value_at (model, MEETING_ATTENDEE_COL, row);
- if (is_duplicate (mpage, address) != NULL) {
+ if (find_match (mpage, address, NULL) != NULL) {
duplicate_error ();
return;
}
@@ -1007,9 +1046,12 @@ set_value_at (ETableModel *etm, int col, int row, const void *val, void *data)
static gboolean
is_cell_editable (ETableModel *etm, int col, int row, void *data)
{
+ g_print ("Is editable, %d, %d\n", col, row);
+
switch (col) {
case MEETING_DELTO_COL:
case MEETING_DELFROM_COL:
+ g_print ("FALSE\n");
return FALSE;
default:
@@ -1201,13 +1243,16 @@ popup_delegate_cb (GtkWidget *widget, gpointer data)
MeetingPagePrivate *priv;
EDelegateDialog *edd;
GtkWidget *dialog;
+ struct attendee *a;
char *address = NULL, *name = NULL;
gint row_cnt;
priv = mpage->priv;
+ a = g_slist_nth_data (priv->attendees, priv->row);
+
/* Show dialog. */
- edd = e_delegate_dialog_new ();
+ edd = e_delegate_dialog_new (NULL, itip_strip_mailto (a->delto));
dialog = e_delegate_dialog_get_toplevel (edd);
if (gnome_dialog_run_and_close (GNOME_DIALOG (dialog)) == 0){
@@ -1218,7 +1263,7 @@ popup_delegate_cb (GtkWidget *widget, gpointer data)
address = e_delegate_dialog_get_delegate (edd);
/* Make sure we can add the new delegatee person */
- if (is_duplicate (mpage, address) != NULL) {
+ if (find_match (mpage, address, NULL) != NULL) {
duplicate_error ();
goto cleanup;
}
@@ -1228,9 +1273,10 @@ popup_delegate_cb (GtkWidget *widget, gpointer data)
if (a->delto) {
struct attendee *b;
- b = is_duplicate (mpage, a->delto);
- if (b != NULL) {
+ b = find_match (mpage, a->delto, NULL);
+ if (b != NULL) {
priv->attendees = g_slist_remove (priv->attendees, b);
+ priv->deleted_attendees = g_slist_append (priv->deleted_attendees, b);
e_table_model_row_deleted (priv->model, priv->row);
}
@@ -1279,14 +1325,42 @@ popup_delete_cb (GtkWidget *widget, gpointer data)
{
MeetingPage *mpage = MEETING_PAGE (data);
MeetingPagePrivate *priv;
- GSList *l;
+ struct attendee *a;
+ int pos = 0;
priv = mpage->priv;
+
+ a = g_slist_nth_data (priv->attendees, priv->row);
- l = g_slist_nth (priv->attendees, priv->row);
- priv->attendees = g_slist_remove (priv->attendees, l->data);
+ /* If this was a delegatee, no longer delegate */
+ if (a->delfrom != NULL) {
+ struct attendee *b;
+
+ b = find_match (mpage, a->delfrom, &pos);
+ if (b != NULL && b->delto) {
+ g_free (b->delto);
+ b->delto = g_strdup ("");
+
+ e_table_model_row_changed (priv->model, pos);
+ }
+ }
+
+ /* Handle deleting all attendees in the delegation chain */
+ pos = priv->row;
+ while (a != NULL) {
+ struct attendee *b = NULL;
+
+ e_table_model_pre_change (priv->model);
- e_table_model_row_deleted (priv->model, priv->row);
+ priv->attendees = g_slist_remove (priv->attendees, a);
+ priv->deleted_attendees = g_slist_append (priv->deleted_attendees, a);
+
+ e_table_model_row_deleted (priv->model, pos);
+
+ if (a->delto != NULL)
+ b = find_match (mpage, a->delto, &pos);
+ a = b;
+ }
}
enum {
diff --git a/calendar/gui/e-itip-control.c b/calendar/gui/e-itip-control.c
index 4cd270a3b1..c22c0a643f 100644
--- a/calendar/gui/e-itip-control.c
+++ b/calendar/gui/e-itip-control.c
@@ -348,7 +348,8 @@ clean_up (EItipControl *itip)
g_free (priv->vcalendar);
priv->vcalendar = NULL;
- gtk_object_unref (GTK_OBJECT (priv->comp));
+ if (priv->comp)
+ gtk_object_unref (GTK_OBJECT (priv->comp));
priv->comp = NULL;
icalcomponent_free (priv->top_level);
diff --git a/calendar/gui/itip-bonobo-control.c b/calendar/gui/itip-bonobo-control.c
index 9c8068bde0..1fca85f10d 100644
--- a/calendar/gui/itip-bonobo-control.c
+++ b/calendar/gui/itip-bonobo-control.c
@@ -54,7 +54,7 @@ static char *
stream_read (Bonobo_Stream stream)
{
Bonobo_Stream_iobuf *buffer;
- CORBA_Environment ev;
+ CORBA_Environment ev;
gchar *data = NULL;
gint length = 0;
@@ -72,18 +72,15 @@ stream_read (Bonobo_Stream stream)
if (buffer->_length <= 0)
break;
- data = g_realloc (data,
- length + buffer->_length);
-
- memcpy (data + length,
- buffer->_buffer, buffer->_length);
-
+ data = g_realloc (data, length + buffer->_length + 1);
+ memcpy (data + length, buffer->_buffer, buffer->_length);
length += buffer->_length;
-
+ data[length] = '\0';
+
CORBA_free (buffer);
#undef READ_CHUNK_SIZE
} while (1);
-
+
CORBA_free (buffer);
CORBA_exception_free (&ev);
diff --git a/calendar/gui/itip-control-factory.c b/calendar/gui/itip-control-factory.c
index 9c8068bde0..1fca85f10d 100644
--- a/calendar/gui/itip-control-factory.c
+++ b/calendar/gui/itip-control-factory.c
@@ -54,7 +54,7 @@ static char *
stream_read (Bonobo_Stream stream)
{
Bonobo_Stream_iobuf *buffer;
- CORBA_Environment ev;
+ CORBA_Environment ev;
gchar *data = NULL;
gint length = 0;
@@ -72,18 +72,15 @@ stream_read (Bonobo_Stream stream)
if (buffer->_length <= 0)
break;
- data = g_realloc (data,
- length + buffer->_length);
-
- memcpy (data + length,
- buffer->_buffer, buffer->_length);
-
+ data = g_realloc (data, length + buffer->_length + 1);
+ memcpy (data + length, buffer->_buffer, buffer->_length);
length += buffer->_length;
-
+ data[length] = '\0';
+
CORBA_free (buffer);
#undef READ_CHUNK_SIZE
} while (1);
-
+
CORBA_free (buffer);
CORBA_exception_free (&ev);
diff --git a/calendar/gui/itip-utils.c b/calendar/gui/itip-utils.c
index f755b13558..9a126446ea 100644
--- a/calendar/gui/itip-utils.c
+++ b/calendar/gui/itip-utils.c
@@ -236,7 +236,7 @@ itip_send_comp (CalComponentItipMethod method, CalComponent *comp)
recipient->name = CORBA_string_dup (organizer.cn);
else
recipient->name = CORBA_string_dup ("");
- recipient->address = CORBA_string_dup (organizer.value);
+ recipient->address = CORBA_string_dup (itip_strip_mailto (organizer.value));
break;
default: