aboutsummaryrefslogtreecommitdiffstats
path: root/calendar/gui
diff options
context:
space:
mode:
authorMatthew Barnes <mbarnes@redhat.com>2011-04-27 04:23:40 +0800
committerMatthew Barnes <mbarnes@redhat.com>2011-04-27 05:00:01 +0800
commit1af7571c5c475ecf3f95d56a0fe7af78c7be3180 (patch)
tree03bb5cb3133b2d949250fef68fbc6b56e131751b /calendar/gui
parent2594b0d00cff45936250e9294ce6eb7cacd87c25 (diff)
downloadgsoc2013-evolution-1af7571c5c475ecf3f95d56a0fe7af78c7be3180.tar
gsoc2013-evolution-1af7571c5c475ecf3f95d56a0fe7af78c7be3180.tar.gz
gsoc2013-evolution-1af7571c5c475ecf3f95d56a0fe7af78c7be3180.tar.bz2
gsoc2013-evolution-1af7571c5c475ecf3f95d56a0fe7af78c7be3180.tar.lz
gsoc2013-evolution-1af7571c5c475ecf3f95d56a0fe7af78c7be3180.tar.xz
gsoc2013-evolution-1af7571c5c475ecf3f95d56a0fe7af78c7be3180.tar.zst
gsoc2013-evolution-1af7571c5c475ecf3f95d56a0fe7af78c7be3180.zip
Refactor CompEditor pages to isolate EAccount usage.
Hide EAccount usage behind more generic APIs so EAccount can be replaced more easily in the account-mgmt branch.
Diffstat (limited to 'calendar/gui')
-rw-r--r--calendar/gui/dialogs/event-page.c216
-rw-r--r--calendar/gui/dialogs/memo-page.c161
-rw-r--r--calendar/gui/dialogs/task-page.c213
3 files changed, 354 insertions, 236 deletions
diff --git a/calendar/gui/dialogs/event-page.c b/calendar/gui/dialogs/event-page.c
index 9560f590d2..6b9110bc86 100644
--- a/calendar/gui/dialogs/event-page.c
+++ b/calendar/gui/dialogs/event-page.c
@@ -109,7 +109,6 @@ struct _EventPagePrivate {
GtkWidget *location;
GtkWidget *location_label;
- EAccountList *accounts;
GList *address_strings;
EMeetingAttendee *ia;
gchar *user_add;
@@ -206,35 +205,54 @@ static void set_subscriber_info_string (EventPage *epage, const gchar *backend_a
G_DEFINE_TYPE (EventPage, event_page, TYPE_COMP_EDITOR_PAGE)
-static EAccount *
-get_current_account (EventPage *epage)
+static gboolean
+get_current_identity (EventPage *page,
+ gchar **name,
+ gchar **mailto)
{
- EventPagePrivate *priv;
- EIterator *it;
- const gchar *str;
+ EAccountList *account_list;
+ EIterator *iterator;
+ GtkWidget *entry;
+ const gchar *text;
+ gboolean match = FALSE;
- priv = epage->priv;
+ entry = gtk_bin_get_child (GTK_BIN (page->priv->organizer));
+ text = gtk_entry_get_text (GTK_ENTRY (entry));
- str = gtk_entry_get_text (GTK_ENTRY (gtk_bin_get_child (GTK_BIN (priv->organizer))));
- if (!str)
- return NULL;
+ if (text == NULL || *text == '\0')
+ return FALSE;
- for (it = e_list_get_iterator ((EList *)priv->accounts); e_iterator_is_valid (it); e_iterator_next (it)) {
- EAccount *a = (EAccount *)e_iterator_get (it);
- gchar *full = g_strdup_printf("%s <%s>", a->id->name, a->id->address);
+ account_list = e_get_account_list ();
+ iterator = e_list_get_iterator (E_LIST (account_list));
- if (!g_ascii_strcasecmp (full, str)) {
- g_free (full);
- g_object_unref (it);
+ while (!match && e_iterator_is_valid (iterator)) {
+ EAccount *account;
+ const gchar *id_name;
+ const gchar *id_address;
+ gchar *identity;
- return a;
- }
+ /* XXX EIterator misuses const. */
+ account = (EAccount *) e_iterator_get (iterator);
+
+ id_name = account->id->name;
+ id_address = account->id->address;
- g_free (full);
+ identity = g_strdup_printf ("%s <%s>", id_name, id_address);
+ match = (g_ascii_strcasecmp (text, identity) == 0);
+ g_free (identity);
+
+ if (match && name != NULL)
+ *name = g_strdup (id_name);
+
+ if (match && mailto != NULL)
+ *mailto = g_strdup_printf ("MAILTO:%s", id_address);
+
+ e_iterator_next (iterator);
}
- g_object_unref (it);
- return NULL;
+ g_object_unref (iterator);
+
+ return match;
}
static void
@@ -818,22 +836,21 @@ update_time (EventPage *epage,
static void
organizer_changed_cb (GtkEntry *entry, EventPage *epage)
{
- EAccount *account;
+ gchar *name;
+ gchar *mailto;
- g_return_if_fail (entry != NULL);
g_return_if_fail (GTK_IS_ENTRY (entry));
- g_return_if_fail (epage != NULL);
g_return_if_fail (IS_EVENT_PAGE (epage));
if (!epage->priv->ia)
return;
- account = get_current_account (epage);
- if (!account || !account->id)
+ if (!get_current_identity (epage, &name, &mailto))
return;
- e_meeting_attendee_set_address (epage->priv->ia, g_strdup_printf ("MAILTO:%s", account->id->address));
- e_meeting_attendee_set_cn (epage->priv->ia, g_strdup (account->id->name));
+ /* XXX EMeetingAttendee takes ownership of the strings. */
+ e_meeting_attendee_set_cn (epage->priv->ia, name);
+ e_meeting_attendee_set_address (epage->priv->ia, mailto);
}
static void
@@ -985,6 +1002,8 @@ event_page_fill_widgets (CompEditorPage *page,
if (priv->is_meeting) {
ECalComponentOrganizer organizer;
+ gchar *name = NULL;
+ gchar *mailto = NULL;
priv->user_add = itip_get_comp_attendee (comp, client);
@@ -1039,33 +1058,52 @@ event_page_fill_widgets (CompEditorPage *page,
g_free (string);
priv->existing = TRUE;
}
- } else {
- EAccount *a;
-
- a = get_current_account (epage);
- if (a != NULL) {
- priv->ia = e_meeting_store_add_attendee_with_defaults (priv->meeting_store);
- g_object_ref (priv->ia);
-
- if (!(backend_addr && *backend_addr) || !g_ascii_strcasecmp (backend_addr, a->id->address)) {
- e_meeting_attendee_set_address (priv->ia, g_strdup_printf ("MAILTO:%s", a->id->address));
- e_meeting_attendee_set_cn (priv->ia, g_strdup (a->id->name));
- } else {
- e_meeting_attendee_set_address (priv->ia, g_strdup_printf ("MAILTO:%s", backend_addr));
- e_meeting_attendee_set_sentby (priv->ia, g_strdup_printf ("MAILTO:%s", a->id->address));
+ } else if (get_current_identity (epage, &name, &mailto)) {
+ EMeetingAttendee *attendee;
+ gchar *backend_mailto = NULL;
+
+ if (backend_addr != NULL && *backend_addr != '\0') {
+ backend_mailto = g_strdup_printf (
+ "MAILTO:%s", backend_addr);
+ if (g_ascii_strcasecmp (backend_mailto, mailto) == 0) {
+ g_free (backend_mailto);
+ backend_mailto = NULL;
}
+ }
- if (client && e_cal_get_organizer_must_accept (client))
- e_meeting_attendee_set_status (priv->ia, ICAL_PARTSTAT_NEEDSACTION);
- else
- e_meeting_attendee_set_status (priv->ia, ICAL_PARTSTAT_ACCEPTED);
- e_meeting_list_view_add_attendee_to_name_selector (E_MEETING_LIST_VIEW (priv->list_view), priv->ia);
+ attendee =
+ e_meeting_store_add_attendee_with_defaults (
+ priv->meeting_store);
+ priv->ia = g_object_ref (attendee);
+
+ if (backend_mailto == NULL) {
+ e_meeting_attendee_set_cn (attendee, name);
+ e_meeting_attendee_set_address (attendee, mailto);
+ name = mailto = NULL;
+ } else {
+ e_meeting_attendee_set_address (attendee, backend_mailto);
+ e_meeting_attendee_set_sentby (attendee, mailto);
+ backend_mailto = mailto = NULL;
}
+
+ if (client && e_cal_get_organizer_must_accept (client))
+ e_meeting_attendee_set_status (
+ attendee, ICAL_PARTSTAT_NEEDSACTION);
+ else
+ e_meeting_attendee_set_status (
+ attendee, ICAL_PARTSTAT_ACCEPTED);
+
+ e_meeting_list_view_add_attendee_to_name_selector (
+ E_MEETING_LIST_VIEW (priv->list_view), attendee);
+
+ g_free (backend_mailto);
}
+
+ g_free (mailto);
+ g_free (name);
}
- if (backend_addr)
- g_free (backend_addr);
+ g_free (backend_addr);
/* Start and end times */
e_cal_component_get_dtstart (comp, &start_date);
@@ -1438,44 +1476,47 @@ event_page_fill_component (CompEditorPage *page,
ECalComponentOrganizer organizer = {NULL, NULL, NULL, NULL};
if (!priv->existing) {
- EAccount *a;
- gchar *backend_addr = NULL, *org_addr = NULL, *sentby = NULL;
+ gchar *backend_addr = NULL;
+ gchar *backend_mailto = NULL;
+ gchar *name;
+ gchar *mailto;
e_cal_get_cal_address (client, &backend_addr, NULL);
/* Find the identity for the organizer or sentby field */
- a = get_current_account (epage);
-
- /* Sanity Check */
- if (a == NULL) {
- e_notice (priv->main, GTK_MESSAGE_ERROR,
- _("The organizer selected no longer has an account."));
+ if (!get_current_identity (epage, &name, &mailto)) {
+ e_notice (
+ priv->main, GTK_MESSAGE_ERROR,
+ _("An organizer is required."));
return FALSE;
}
- if (a->id->address == NULL || strlen (a->id->address) == 0) {
- e_notice (priv->main, GTK_MESSAGE_ERROR,
- _("An organizer is required."));
- return FALSE;
+ /* Prefer the backend address if we have one. */
+ if (backend_addr != NULL && *backend_addr != '\0') {
+ backend_mailto = g_strdup_printf (
+ "MAILTO:%s", backend_addr);
+ if (g_ascii_strcasecmp (backend_mailto, mailto) == 0) {
+ g_free (backend_mailto);
+ backend_mailto = NULL;
+ }
}
- if (!(backend_addr && *backend_addr) || !g_ascii_strcasecmp (backend_addr, a->id->address)) {
- org_addr = g_strdup_printf ("MAILTO:%s", a->id->address);
- organizer.value = org_addr;
- organizer.cn = a->id->name;
+ if (backend_mailto == NULL) {
+ organizer.cn = name;
+ organizer.value = mailto;
+ name = mailto = NULL;
} else {
- gchar *sentby = NULL;
- org_addr = g_strdup_printf ("MAILTO:%s", backend_addr);
- sentby = g_strdup_printf ("MAILTO:%s", a->id->address);
- organizer.value = org_addr;
- organizer.sentby = sentby;
+ organizer.value = backend_mailto;
+ organizer.sentby = mailto;
+ backend_mailto = mailto = NULL;
}
e_cal_component_set_organizer (comp, &organizer);
g_free (backend_addr);
- g_free (org_addr);
- g_free (sentby);
+ g_free (backend_mailto);
+ g_free (name);
+ g_free (mailto);
}
if (e_meeting_store_count_actual_attendees (priv->meeting_store) < 1) {
@@ -3211,8 +3252,8 @@ event_page_construct (EventPage *epage,
EMeetingStore *meeting_store)
{
EventPagePrivate *priv;
- EIterator *it;
- EAccount *a;
+ EAccountList *account_list;
+ EIterator *iterator;
priv = epage->priv;
priv->meeting_store = g_object_ref (meeting_store);
@@ -3231,24 +3272,27 @@ event_page_construct (EventPage *epage,
return NULL;
}
- priv->accounts = e_get_account_list ();
- for (it = e_list_get_iterator ((EList *)priv->accounts);
- e_iterator_is_valid (it);
- e_iterator_next (it)) {
- gchar *full = NULL;
+ account_list = e_get_account_list ();
+ iterator = e_list_get_iterator (E_LIST (account_list));
- a = (EAccount *)e_iterator_get (it);
+ while (e_iterator_is_valid (iterator)) {
+ EAccount *account;
- /* skip disabled accounts */
- if (!a->enabled)
- continue;
+ /* XXX EIterator misuses const. */
+ account = (EAccount *) e_iterator_get (iterator);
- full = g_strdup_printf("%s <%s>", a->id->name, a->id->address);
+ if (account->enabled)
+ priv->address_strings = g_list_append (
+ priv->address_strings,
+ g_strdup_printf (
+ "%s <%s>",
+ account->id->name,
+ account->id->address));
- priv->address_strings = g_list_append (priv->address_strings, full);
+ e_iterator_next (iterator);
}
- g_object_unref (it);
+ g_object_unref (iterator);
if (priv->address_strings) {
GList *l;
diff --git a/calendar/gui/dialogs/memo-page.c b/calendar/gui/dialogs/memo-page.c
index 6e5313eec7..88d755efb6 100644
--- a/calendar/gui/dialogs/memo-page.c
+++ b/calendar/gui/dialogs/memo-page.c
@@ -64,8 +64,6 @@ struct _MemoPagePrivate {
GtkWidget *memo_content;
- EAccountList *accounts;
-
/* Generic informative messages placeholder */
GtkWidget *info_hbox;
GtkWidget *info_icon;
@@ -107,6 +105,56 @@ static void memo_page_select_organizer (MemoPage *mpage, const gchar *backend_ad
G_DEFINE_TYPE (MemoPage, memo_page, TYPE_COMP_EDITOR_PAGE)
+static gboolean
+get_current_identity (MemoPage *page,
+ gchar **name,
+ gchar **mailto)
+{
+ EAccountList *account_list;
+ EIterator *iterator;
+ GtkWidget *entry;
+ const gchar *text;
+ gboolean match = FALSE;
+
+ entry = gtk_bin_get_child (GTK_BIN (page->priv->org_combo));
+ text = gtk_entry_get_text (GTK_ENTRY (entry));
+
+ if (text == NULL || *text == '\0')
+ return FALSE;
+
+ account_list = e_get_account_list ();
+ iterator = e_list_get_iterator (E_LIST (account_list));
+
+ while (!match && e_iterator_is_valid (iterator)) {
+ EAccount *account;
+ const gchar *id_name;
+ const gchar *id_address;
+ gchar *identity;
+
+ /* XXX EIterator misuses const. */
+ account = (EAccount *) e_iterator_get (iterator);
+
+ id_name = account->id->name;
+ id_address = account->id->address;
+
+ identity = g_strdup_printf ("%s <%s>", id_name, id_address);
+ match = (g_ascii_strcasecmp (text, identity) == 0);
+ g_free (identity);
+
+ if (match && name != NULL)
+ *name = g_strdup (id_name);
+
+ if (match && mailto != NULL)
+ *mailto = g_strdup_printf ("MAILTO:%s", id_address);
+
+ e_iterator_next (iterator);
+ }
+
+ g_object_unref (iterator);
+
+ return match;
+}
+
/* Fills the widgets with default values */
static void
clear_widgets (MemoPage *mpage)
@@ -553,35 +601,6 @@ fill_comp_with_recipients (ENameSelector *name_selector, ECalComponent *comp)
return FALSE;
}
-static EAccount *
-get_current_account (MemoPage *page)
-{
- MemoPagePrivate *priv = page->priv;
- EIterator *it;
- const gchar *str;
-
- str = gtk_entry_get_text (GTK_ENTRY (gtk_bin_get_child (GTK_BIN (priv->org_combo))));
- if (!str)
- return NULL;
-
- for (it = e_list_get_iterator ((EList *)priv->accounts); e_iterator_is_valid (it); e_iterator_next (it)) {
- EAccount *a = (EAccount *)e_iterator_get (it);
- gchar *full = g_strdup_printf("%s <%s>", a->id->name, a->id->address);
-
- if (!g_ascii_strcasecmp (full, str)) {
- g_free (full);
- g_object_unref (it);
-
- return a;
- }
-
- g_free (full);
- }
- g_object_unref (it);
-
- return NULL;
-}
-
/* fill_component handler for the memo page */
static gboolean
memo_page_fill_component (CompEditorPage *page,
@@ -699,36 +718,39 @@ memo_page_fill_component (CompEditorPage *page,
if ((flags & COMP_EDITOR_IS_SHARED) && (flags & COMP_EDITOR_NEW_ITEM) && fill_comp_with_recipients (priv->name_selector, comp)) {
ECalComponentOrganizer organizer = {NULL, NULL, NULL, NULL};
- EAccount *a;
- gchar *backend_addr = NULL, *org_addr = NULL, *sentby = NULL;
+ gchar *backend_addr = NULL;
+ gchar *backend_mailto = NULL;
+ gchar *name;
+ gchar *mailto;
e_cal_get_cal_address (client, &backend_addr, NULL);
/* Find the identity for the organizer or sentby field */
- a = get_current_account (mpage);
-
- /* Sanity Check */
- if (a == NULL) {
- e_notice (priv->main, GTK_MESSAGE_ERROR,
- _("The organizer selected no longer has an account."));
+ if (!get_current_identity (mpage, &name, &mailto)) {
+ e_notice (
+ priv->main, GTK_MESSAGE_ERROR,
+ _("An organizer is required."));
return FALSE;
}
- if (a->id->address == NULL || strlen (a->id->address) == 0) {
- e_notice (priv->main, GTK_MESSAGE_ERROR,
- _("An organizer is required."));
- return FALSE;
+ /* Prefer the backend addres if we have one. */
+ if (backend_addr != NULL && *backend_addr != '\0') {
+ backend_mailto = g_strdup_printf (
+ "MAILTO:%s", backend_addr);
+ if (g_ascii_strcasecmp (backend_mailto, mailto) == 0) {
+ g_free (backend_mailto);
+ backend_mailto = NULL;
+ }
}
- if (!(backend_addr && *backend_addr) || !g_ascii_strcasecmp (backend_addr, a->id->address)) {
- org_addr = g_strdup_printf ("MAILTO:%s", a->id->address);
- organizer.value = org_addr;
- organizer.cn = a->id->name;
+ if (backend_mailto == NULL) {
+ organizer.cn = name;
+ organizer.value = mailto;
+ name = mailto = NULL;
} else {
- org_addr = g_strdup_printf ("MAILTO:%s", backend_addr);
- sentby = g_strdup_printf ("MAILTO:%s", a->id->address);
- organizer.value = org_addr;
- organizer.sentby = sentby;
+ organizer.value = backend_mailto;
+ organizer.sentby = mailto;
+ backend_mailto = mailto = NULL;
}
e_cal_component_set_organizer (comp, &organizer);
@@ -737,8 +759,9 @@ memo_page_fill_component (CompEditorPage *page,
comp_editor_set_needs_send (editor, TRUE);
g_free (backend_addr);
- g_free (org_addr);
- g_free (sentby);
+ g_free (backend_mailto);
+ g_free (name);
+ g_free (mailto);
}
return TRUE;
@@ -1138,8 +1161,6 @@ memo_page_construct (MemoPage *mpage)
MemoPagePrivate *priv = mpage->priv;
CompEditor *editor;
CompEditorFlags flags;
- EIterator *it;
- EAccount *a;
editor = comp_editor_page_get_editor (COMP_EDITOR_PAGE (mpage));
flags = comp_editor_get_flags (editor);
@@ -1154,24 +1175,30 @@ memo_page_construct (MemoPage *mpage)
}
if (flags & COMP_EDITOR_IS_SHARED) {
- priv->accounts = e_get_account_list ();
- for (it = e_list_get_iterator ((EList *)priv->accounts);
- e_iterator_is_valid (it);
- e_iterator_next (it)) {
- gchar *full = NULL;
+ EAccountList *account_list;
+ EIterator *iterator;
- a = (EAccount *)e_iterator_get (it);
+ account_list = e_get_account_list ();
+ iterator = e_list_get_iterator (E_LIST (account_list));
- /* skip disabled accounts */
- if (!a->enabled)
- continue;
+ while (e_iterator_is_valid (iterator)) {
+ EAccount *account;
+
+ /* XXX EIterator misuses const. */
+ account = (EAccount *) e_iterator_get (iterator);
- full = g_strdup_printf("%s <%s>", a->id->name, a->id->address);
+ if (account->enabled)
+ priv->address_strings = g_list_append (
+ priv->address_strings,
+ g_strdup_printf (
+ "%s <%s>",
+ account->id->name,
+ account->id->address));
- priv->address_strings = g_list_append (priv->address_strings, full);
+ e_iterator_next (iterator);
}
- g_object_unref (it);
+ g_object_unref (iterator);
if (priv->address_strings) {
GList *l;
diff --git a/calendar/gui/dialogs/task-page.c b/calendar/gui/dialogs/task-page.c
index 0ddd325448..499e9e14ba 100644
--- a/calendar/gui/dialogs/task-page.c
+++ b/calendar/gui/dialogs/task-page.c
@@ -65,7 +65,6 @@ struct _TaskPagePrivate {
/* Widgets from the UI file */
GtkWidget *main;
- EAccountList *accounts;
GList *address_strings;
EMeetingAttendee *ia;
gchar *user_add;
@@ -139,35 +138,54 @@ static void set_subscriber_info_string (TaskPage *tpage, const gchar *backend_ad
G_DEFINE_TYPE (TaskPage, task_page, TYPE_COMP_EDITOR_PAGE)
-static EAccount *
-get_current_account (TaskPage *page)
+static gboolean
+get_current_identity (TaskPage *page,
+ gchar **name,
+ gchar **mailto)
{
- TaskPagePrivate *priv;
- EIterator *it;
- const gchar *str;
+ EAccountList *account_list;
+ EIterator *iterator;
+ GtkWidget *entry;
+ const gchar *text;
+ gboolean match = FALSE;
- priv = page->priv;
+ entry = gtk_bin_get_child (GTK_BIN (page->priv->organizer));
+ text = gtk_entry_get_text (GTK_ENTRY (entry));
- str = gtk_entry_get_text (GTK_ENTRY (gtk_bin_get_child (GTK_BIN (priv->organizer))));
- if (!str)
- return NULL;
+ if (text == NULL || *text == '\0')
+ return FALSE;
- for (it = e_list_get_iterator ((EList *)priv->accounts); e_iterator_is_valid (it); e_iterator_next (it)) {
- EAccount *a = (EAccount *)e_iterator_get (it);
- gchar *full = g_strdup_printf("%s <%s>", a->id->name, a->id->address);
+ account_list = e_get_account_list ();
+ iterator = e_list_get_iterator (E_LIST (account_list));
- if (!g_ascii_strcasecmp (full, str)) {
- g_free (full);
- g_object_unref (it);
+ while (!match && e_iterator_is_valid (iterator)) {
+ EAccount *account;
+ const gchar *id_name;
+ const gchar *id_address;
+ gchar *identity;
- return a;
- }
+ /* XXX EIterator misuses const. */
+ account = (EAccount *) e_iterator_get (iterator);
+
+ id_name = account->id->name;
+ id_address = account->id->address;
- g_free (full);
+ identity = g_strdup_printf ("%s <%s>", id_name, id_address);
+ match = (g_ascii_strcasecmp (text, identity) == 0);
+ g_free (identity);
+
+ if (match && name != NULL)
+ *name = g_strdup (id_name);
+
+ if (match && mailto != NULL)
+ *mailto = g_strdup_printf ("MAILTO:%s", id_address);
+
+ e_iterator_next (iterator);
}
- g_object_unref (it);
- return NULL;
+ g_object_unref (iterator);
+
+ return match;
}
/* Fills the widgets with default values */
@@ -352,7 +370,8 @@ static void
organizer_changed_cb (GtkEntry *entry,
TaskPage *tpage)
{
- EAccount *account;
+ gchar *name;
+ gchar *mailto;
g_return_if_fail (GTK_IS_ENTRY (entry));
g_return_if_fail (IS_TASK_PAGE (tpage));
@@ -360,12 +379,12 @@ organizer_changed_cb (GtkEntry *entry,
if (!tpage->priv->ia)
return;
- account = get_current_account (tpage);
- if (!account || !account->id)
+ if (!get_current_identity (tpage, &name, &mailto))
return;
- e_meeting_attendee_set_address (tpage->priv->ia, g_strdup_printf ("MAILTO:%s", account->id->address));
- e_meeting_attendee_set_cn (tpage->priv->ia, g_strdup (account->id->name));
+ /* XXX EMeetingAttendee takes ownership of the strings. */
+ e_meeting_attendee_set_cn (tpage->priv->ia, name);
+ e_meeting_attendee_set_address (tpage->priv->ia, mailto);
}
static void
@@ -610,6 +629,8 @@ task_page_fill_widgets (CompEditorPage *page,
if (priv->is_assignment) {
ECalComponentOrganizer organizer;
+ gchar *name = NULL;
+ gchar *mailto = NULL;
priv->user_add = itip_get_comp_attendee (comp, client);
@@ -664,33 +685,52 @@ task_page_fill_widgets (CompEditorPage *page,
g_free (string);
priv->existing = TRUE;
}
- } else {
- EAccount *a;
-
- a = get_current_account (tpage);
- if (a != NULL) {
- priv->ia = e_meeting_store_add_attendee_with_defaults (priv->meeting_store);
- g_object_ref (priv->ia);
-
- if (!(backend_addr && *backend_addr) || !g_ascii_strcasecmp (backend_addr, a->id->address)) {
- e_meeting_attendee_set_address (priv->ia, g_strdup_printf ("MAILTO:%s", a->id->address));
- e_meeting_attendee_set_cn (priv->ia, g_strdup (a->id->name));
- } else {
- e_meeting_attendee_set_address (priv->ia, g_strdup_printf ("MAILTO:%s", backend_addr));
- e_meeting_attendee_set_sentby (priv->ia, g_strdup_printf ("MAILTO:%s", a->id->address));
+ } else if (get_current_identity (tpage, &name, &mailto)) {
+ EMeetingAttendee *attendee;
+ gchar *backend_mailto = NULL;
+
+ if (backend_addr != NULL && *backend_addr != '\0') {
+ backend_mailto = g_strdup_printf (
+ "MAILTO:%s", backend_addr);
+ if (g_ascii_strcasecmp (backend_mailto, mailto) == 0) {
+ g_free (backend_mailto);
+ backend_mailto = NULL;
}
+ }
- if (client && e_cal_get_organizer_must_accept (client))
- e_meeting_attendee_set_status (priv->ia, ICAL_PARTSTAT_NEEDSACTION);
- else
- e_meeting_attendee_set_status (priv->ia, ICAL_PARTSTAT_ACCEPTED);
- e_meeting_list_view_add_attendee_to_name_selector (E_MEETING_LIST_VIEW (priv->list_view), priv->ia);
+ attendee =
+ e_meeting_store_add_attendee_with_defaults (
+ priv->meeting_store);
+ priv->ia = g_object_ref (attendee);
+
+ if (backend_mailto == NULL) {
+ e_meeting_attendee_set_cn (attendee, name);
+ e_meeting_attendee_set_address (attendee, mailto);
+ name = mailto = NULL;
+ } else {
+ e_meeting_attendee_set_address (attendee, backend_mailto);
+ e_meeting_attendee_set_sentby (attendee, mailto);
+ backend_mailto = mailto = NULL;
}
+
+ if (client && e_cal_get_organizer_must_accept (client))
+ e_meeting_attendee_set_status (
+ attendee, ICAL_PARTSTAT_NEEDSACTION);
+ else
+ e_meeting_attendee_set_status (
+ attendee, ICAL_PARTSTAT_ACCEPTED);
+
+ e_meeting_list_view_add_attendee_to_name_selector (
+ E_MEETING_LIST_VIEW (priv->list_view), attendee);
+
+ g_free (backend_mailto);
}
+
+ g_free (mailto);
+ g_free (name);
}
- if (backend_addr)
- g_free (backend_addr);
+ g_free (backend_addr);
sensitize_widgets (tpage);
@@ -852,43 +892,47 @@ task_page_fill_component (CompEditorPage *page,
ECalComponentOrganizer organizer = {NULL, NULL, NULL, NULL};
if (!priv->existing) {
- EAccount *a;
- gchar *backend_addr = NULL, *org_addr = NULL, *sentby = NULL;
+ gchar *backend_addr = NULL;
+ gchar *backend_mailto = NULL;
+ gchar *name;
+ gchar *mailto;
e_cal_get_cal_address (client, &backend_addr, NULL);
/* Find the identity for the organizer or sentby field */
- a = get_current_account (tpage);
-
- /* Sanity Check */
- if (a == NULL) {
- e_notice (priv->main, GTK_MESSAGE_ERROR,
- _("The organizer selected no longer has an account."));
+ if (!get_current_identity (tpage, &name, &mailto)) {
+ e_notice (
+ priv->main, GTK_MESSAGE_ERROR,
+ _("An organizer is required."));
return FALSE;
}
- if (a->id->address == NULL || strlen (a->id->address) == 0) {
- e_notice (priv->main, GTK_MESSAGE_ERROR,
- _("An organizer is required."));
- return FALSE;
+ /* Prefer the backend address if we have one. */
+ if (backend_addr != NULL && *backend_addr != '\0') {
+ backend_mailto = g_strdup_printf (
+ "MAILTO:%s", backend_addr);
+ if (g_ascii_strcasecmp (backend_mailto, mailto) == 0) {
+ g_free (backend_mailto);
+ backend_mailto = NULL;
+ }
}
- if (!(backend_addr && *backend_addr) || !g_ascii_strcasecmp (backend_addr, a->id->address)) {
- org_addr = g_strdup_printf ("MAILTO:%s", a->id->address);
- organizer.value = org_addr;
- organizer.cn = a->id->name;
+ if (backend_mailto == NULL) {
+ organizer.cn = name;
+ organizer.value = mailto;
+ name = mailto = NULL;
} else {
- org_addr = g_strdup_printf ("MAILTO:%s", backend_addr);
- sentby = g_strdup_printf ("MAILTO:%s", a->id->address);
- organizer.value = org_addr;
- organizer.sentby = sentby;
+ organizer.value = backend_mailto;
+ organizer.sentby = mailto;
+ backend_mailto = mailto = NULL;
}
e_cal_component_set_organizer (comp, &organizer);
g_free (backend_addr);
- g_free (org_addr);
- g_free (sentby);
+ g_free (backend_mailto);
+ g_free (name);
+ g_free (mailto);
}
if (e_meeting_store_count_actual_attendees (priv->meeting_store) < 1) {
@@ -2060,8 +2104,8 @@ task_page_construct (TaskPage *tpage,
ECal *client)
{
TaskPagePrivate *priv;
- EIterator *it;
- EAccount *a;
+ EAccountList *account_list;
+ EIterator *iterator;
priv = tpage->priv;
priv->meeting_store = g_object_ref (meeting_store);
@@ -2082,24 +2126,27 @@ task_page_construct (TaskPage *tpage,
return NULL;
}
- priv->accounts = e_get_account_list ();
- for (it = e_list_get_iterator ((EList *)priv->accounts);
- e_iterator_is_valid (it);
- e_iterator_next (it)) {
- gchar *full = NULL;
+ account_list = e_get_account_list ();
+ iterator = e_list_get_iterator (E_LIST (account_list));
- a = (EAccount *)e_iterator_get (it);
+ while (e_iterator_is_valid (iterator)) {
+ EAccount *account;
- /* skip disabled accounts */
- if (!a->enabled)
- continue;
+ /* XXX EIterator misuses const. */
+ account = (EAccount *) e_iterator_get (iterator);
- full = g_strdup_printf("%s <%s>", a->id->name, a->id->address);
+ if (account->enabled)
+ priv->address_strings = g_list_append (
+ priv->address_strings,
+ g_strdup_printf (
+ "%s <%s>",
+ account->id->name,
+ account->id->address));
- priv->address_strings = g_list_append (priv->address_strings, full);
+ e_iterator_next (iterator);
}
- g_object_unref (it);
+ g_object_unref (iterator);
if (priv->address_strings) {
GList *l;