From 498337e8524e1acf9f9471fc8c54038341035911 Mon Sep 17 00:00:00 2001 From: Milan Crha Date: Wed, 2 Mar 2011 15:12:02 +0100 Subject: Do not leak attachments in a mail view --- plugins/mail-to-task/mail-to-task.c | 1 + 1 file changed, 1 insertion(+) (limited to 'plugins/mail-to-task/mail-to-task.c') diff --git a/plugins/mail-to-task/mail-to-task.c b/plugins/mail-to-task/mail-to-task.c index 794badc969..558489578a 100644 --- a/plugins/mail-to-task/mail-to-task.c +++ b/plugins/mail-to-task/mail-to-task.c @@ -384,6 +384,7 @@ set_attachments (ECal *client, ECalComponent *comp, CamelMimeMessage *message) /* XXX Does this take ownership of the list? */ e_cal_component_set_attachment_list (comp, uri_list); + e_attachment_store_remove_all (store); g_object_unref (destination); g_object_unref (store); } -- cgit v1.2.3 From 54da4fc09cf226fdb59b9f0c70555e2e57dc1f91 Mon Sep 17 00:00:00 2001 From: Matthew Barnes Date: Sun, 8 May 2011 13:24:42 -0400 Subject: Coding style cleanups. --- plugins/mail-to-task/mail-to-task.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'plugins/mail-to-task/mail-to-task.c') diff --git a/plugins/mail-to-task/mail-to-task.c b/plugins/mail-to-task/mail-to-task.c index 558489578a..1deca6d4f1 100644 --- a/plugins/mail-to-task/mail-to-task.c +++ b/plugins/mail-to-task/mail-to-task.c @@ -433,7 +433,7 @@ report_error_idle (const gchar *format, const gchar *param) err->param = g_strdup (param); g_usleep (250); - g_idle_add ((GSourceFunc)do_report_error, err); + g_idle_add ((GSourceFunc) do_report_error, err); } struct _manage_comp @@ -869,7 +869,7 @@ do_mail_to_event (AsyncData *data) if (mcs) { /* process this in the main thread, as we may ask user too */ - g_idle_add ((GSourceFunc)do_manage_comp_idle, mcs); + g_idle_add ((GSourceFunc) do_manage_comp_idle, mcs); } } -- cgit v1.2.3 From c24038c4f62f37b89d1bda9542ca5ccc843d4ea0 Mon Sep 17 00:00:00 2001 From: Milan Crha Date: Fri, 27 May 2011 15:23:07 +0200 Subject: Bug #646109 - Fix use of include to make sure translations work --- plugins/mail-to-task/mail-to-task.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'plugins/mail-to-task/mail-to-task.c') diff --git a/plugins/mail-to-task/mail-to-task.c b/plugins/mail-to-task/mail-to-task.c index 1deca6d4f1..3ebc818013 100644 --- a/plugins/mail-to-task/mail-to-task.c +++ b/plugins/mail-to-task/mail-to-task.c @@ -25,7 +25,7 @@ /* Convert a mail message into a task */ #ifdef HAVE_CONFIG_H -#include "config.h" +#include #endif #include -- cgit v1.2.3 From 84339b3be5a771406fcd5898bbd21dc1c5b98c82 Mon Sep 17 00:00:00 2001 From: Milan Crha Date: Tue, 14 Jun 2011 08:54:20 +0200 Subject: Do not use deprecated EBook/ECal API --- plugins/mail-to-task/mail-to-task.c | 98 ++++++++++++++++++++----------------- 1 file changed, 52 insertions(+), 46 deletions(-) (limited to 'plugins/mail-to-task/mail-to-task.c') diff --git a/plugins/mail-to-task/mail-to-task.c b/plugins/mail-to-task/mail-to-task.c index 3ebc818013..29e0a10e5b 100644 --- a/plugins/mail-to-task/mail-to-task.c +++ b/plugins/mail-to-task/mail-to-task.c @@ -34,9 +34,10 @@ #include #include -#include +#include #include #include +#include #include #include @@ -44,7 +45,6 @@ #include #include #include -#include #include #include #include @@ -291,7 +291,7 @@ attachment_save_finished (EAttachmentStore *store, } static void -set_attachments (ECal *client, ECalComponent *comp, CamelMimeMessage *message) +set_attachments (ECalClient *client, ECalComponent *comp, CamelMimeMessage *message) { /* XXX Much of this is copied from CompEditor::get_attachment_list(). * Perhaps it should be split off as a separate utility? */ @@ -321,7 +321,7 @@ set_attachments (ECal *client, ECalComponent *comp, CamelMimeMessage *message) return; e_cal_component_get_uid (comp, &comp_uid); - local_store = e_cal_get_local_attachment_store (client); + local_store = e_cal_client_get_local_attachment_store (client); path = g_build_path ("/", local_store, comp_uid, NULL); destination = g_file_new_for_path (path); @@ -438,7 +438,7 @@ report_error_idle (const gchar *format, const gchar *param) struct _manage_comp { - ECal *client; + ECalClient *client; ECalComponent *comp; icalcomponent *stored_comp; /* the one in client already */ }; @@ -481,18 +481,18 @@ do_ask (const gchar *text, gboolean is_create_edit_add) } static const gchar * -get_question_edit_old (ECalSourceType source_type) +get_question_edit_old (ECalClientSourceType source_type) { const gchar *ask = NULL; switch (source_type) { - case E_CAL_SOURCE_TYPE_EVENT: + case E_CAL_CLIENT_SOURCE_TYPE_EVENTS: ask = _("Selected calendar contains event '%s' already. Would you like to edit the old event?"); break; - case E_CAL_SOURCE_TYPE_TODO: + case E_CAL_CLIENT_SOURCE_TYPE_TASKS: ask = _("Selected task list contains task '%s' already. Would you like to edit the old task?"); break; - case E_CAL_SOURCE_TYPE_JOURNAL: + case E_CAL_CLIENT_SOURCE_TYPE_MEMOS: ask = _("Selected memo list contains memo '%s' already. Would you like to edit the old memo?"); break; default: @@ -504,24 +504,24 @@ get_question_edit_old (ECalSourceType source_type) } static const gchar * -get_question_create_new (ECalSourceType source_type) +get_question_create_new (ECalClientSourceType source_type) { const gchar *ask = NULL; switch (source_type) { - case E_CAL_SOURCE_TYPE_EVENT: + case E_CAL_CLIENT_SOURCE_TYPE_EVENTS: /* Translators: Codewise it is impossible to provide separate strings for all combinations of singular and plural. Please translate it in the way that you feel is most appropriate for your language. */ ask = _("Selected calendar contains some events for the given mails already. Would you like to create new events anyway?"); break; - case E_CAL_SOURCE_TYPE_TODO: + case E_CAL_CLIENT_SOURCE_TYPE_TASKS: /* Translators: Codewise it is impossible to provide separate strings for all combinations of singular and plural. Please translate it in the way that you feel is most appropriate for your language. */ ask = _("Selected task list contains some tasks for the given mails already. Would you like to create new tasks anyway?"); break; - case E_CAL_SOURCE_TYPE_JOURNAL: + case E_CAL_CLIENT_SOURCE_TYPE_MEMOS: /* Translators: Codewise it is impossible to provide separate strings for all combinations of singular and plural. Please translate it in the way that you feel is most appropriate for your language. */ @@ -536,12 +536,12 @@ get_question_create_new (ECalSourceType source_type) } static const gchar * -get_question_create_new_n (ECalSourceType source_type, gint count) +get_question_create_new_n (ECalClientSourceType source_type, gint count) { const gchar *ask = NULL; switch (source_type) { - case E_CAL_SOURCE_TYPE_EVENT: + case E_CAL_CLIENT_SOURCE_TYPE_EVENTS: ask = ngettext ( /* Translators: Codewise it is impossible to provide separate strings for all combinations of singular and plural. Please translate it in the way that you @@ -550,7 +550,7 @@ get_question_create_new_n (ECalSourceType source_type, gint count) "Selected calendar contains events for the given mails already. Would you like to create new events anyway?", count); break; - case E_CAL_SOURCE_TYPE_TODO: + case E_CAL_CLIENT_SOURCE_TYPE_TASKS: ask = ngettext ( /* Translators: Codewise it is impossible to provide separate strings for all combinations of singular and plural. Please translate it in the way that you @@ -559,7 +559,7 @@ get_question_create_new_n (ECalSourceType source_type, gint count) "Selected task list contains tasks for the given mails already. Would you like to create new tasks anyway?", count); break; - case E_CAL_SOURCE_TYPE_JOURNAL: + case E_CAL_CLIENT_SOURCE_TYPE_MEMOS: ask = ngettext ( /* Translators: Codewise it is impossible to provide separate strings for all combinations of singular and plural. Please translate it in the way that you @@ -582,7 +582,7 @@ do_manage_comp_idle (GSList *manage_comp_datas) GError *error = NULL; guint with_old = 0; gboolean need_editor = FALSE; - ECalSourceType source_type = E_CAL_SOURCE_TYPE_LAST; + ECalClientSourceType source_type = E_CAL_CLIENT_SOURCE_TYPE_LAST; GSList *l; g_return_val_if_fail (manage_comp_datas != NULL, FALSE); @@ -593,10 +593,10 @@ do_manage_comp_idle (GSList *manage_comp_datas) if (mc->comp && (e_cal_component_has_attendees (mc->comp) || e_cal_component_has_organizer (mc->comp))) need_editor = TRUE; - source_type = e_cal_get_source_type (mc->client); + source_type = e_cal_client_get_source_type (mc->client); } - if (source_type == E_CAL_SOURCE_TYPE_LAST) { + if (source_type == E_CAL_CLIENT_SOURCE_TYPE_LAST) { g_slist_foreach (manage_comp_datas, (GFunc) free_manage_comp_struct, NULL); g_slist_free (manage_comp_datas); @@ -634,7 +634,7 @@ do_manage_comp_idle (GSList *manage_comp_datas) g_object_unref (edit_comp); edit_comp = NULL; - error = g_error_new (E_CALENDAR_ERROR, E_CALENDAR_STATUS_INVALID_OBJECT, "%s", _("Invalid object returned from a server")); + error = g_error_new (E_CAL_CLIENT_ERROR, E_CAL_CLIENT_ERROR_INVALID_OBJECT, "%s", _("Invalid object returned from a server")); } } else if (chosen == GTK_RESPONSE_NO) { /* user wants to create a new event, thus generate a new UID */ @@ -686,6 +686,7 @@ do_manage_comp_idle (GSList *manage_comp_datas) if (can) { for (l = manage_comp_datas; l && !error; l = l->next) { struct _manage_comp *mc = l->data; + gchar *uid = NULL; if (!mc) continue; @@ -699,7 +700,8 @@ do_manage_comp_idle (GSList *manage_comp_datas) g_free (new_uid); } - e_cal_create_object (mc->client, e_cal_component_get_icalcomponent (mc->comp), NULL, &error); + e_cal_client_create_object_sync (mc->client, e_cal_component_get_icalcomponent (mc->comp), &uid, NULL, &error); + g_free (uid); } } } @@ -716,7 +718,7 @@ do_manage_comp_idle (GSList *manage_comp_datas) } typedef struct { - ECal *client; + ECalClient *client; CamelFolder *folder; GPtrArray *uids; gchar *selected_text; @@ -726,27 +728,26 @@ typedef struct { static gboolean do_mail_to_event (AsyncData *data) { - ECal *client = data->client; + ECalClient *client = data->client; CamelFolder *folder = data->folder; GPtrArray *uids = data->uids; GError *err = NULL; - gboolean readonly = FALSE; /* open the task client */ - if (!e_cal_open (client, FALSE, &err)) { + if (!e_client_open_sync (E_CLIENT (client), FALSE, NULL, &err)) { report_error_idle (_("Cannot open calendar. %s"), err ? err->message : _("Unknown error.")); - } else if (!e_cal_is_read_only (client, &readonly, &err) || readonly) { + } else if (e_client_is_readonly (E_CLIENT (client))) { if (err) report_error_idle ("Check readonly failed. %s", err->message); else { - switch (e_cal_get_source_type (client)) { - case E_CAL_SOURCE_TYPE_EVENT: + switch (e_cal_client_get_source_type (client)) { + case E_CAL_CLIENT_SOURCE_TYPE_EVENTS: report_error_idle (_("Selected source is read only, thus cannot create event there. Select other source, please."), NULL); break; - case E_CAL_SOURCE_TYPE_TODO: + case E_CAL_CLIENT_SOURCE_TYPE_TASKS: report_error_idle (_("Selected source is read only, thus cannot create task there. Select other source, please."), NULL); break; - case E_CAL_SOURCE_TYPE_JOURNAL: + case E_CAL_CLIENT_SOURCE_TYPE_MEMOS: report_error_idle (_("Selected source is read only, thus cannot create memo there. Select other source, please."), NULL); break; default: @@ -757,7 +758,7 @@ do_mail_to_event (AsyncData *data) } else { GSList *mcs = NULL; gint i; - ECalSourceType source_type = e_cal_get_source_type (client); + ECalClientSourceType source_type = e_cal_client_get_source_type (client); ECalComponentDateTime dt, dt2; struct icaltimetype tt, tt2; @@ -791,13 +792,13 @@ do_mail_to_event (AsyncData *data) comp = e_cal_component_new (); switch (source_type) { - case E_CAL_SOURCE_TYPE_EVENT: + case E_CAL_CLIENT_SOURCE_TYPE_EVENTS: e_cal_component_set_new_vtype (comp, E_CAL_COMPONENT_EVENT); break; - case E_CAL_SOURCE_TYPE_TODO: + case E_CAL_CLIENT_SOURCE_TYPE_TASKS: e_cal_component_set_new_vtype (comp, E_CAL_COMPONENT_TODO); break; - case E_CAL_SOURCE_TYPE_JOURNAL: + case E_CAL_CLIENT_SOURCE_TYPE_MEMOS: e_cal_component_set_new_vtype (comp, E_CAL_COMPONENT_JOURNAL); break; default: @@ -808,7 +809,7 @@ do_mail_to_event (AsyncData *data) e_cal_component_set_uid (comp, camel_mime_message_get_message_id (message)); e_cal_component_set_dtstart (comp, &dt); - if (source_type == E_CAL_SOURCE_TYPE_EVENT) { + if (source_type == E_CAL_CLIENT_SOURCE_TYPE_EVENTS) { /* make it an all-day event */ e_cal_component_set_dtend (comp, &dt2); } @@ -859,7 +860,7 @@ do_mail_to_event (AsyncData *data) mc->client = g_object_ref (client); mc->comp = g_object_ref (comp); - if (!e_cal_get_object (client, icalcomponent_get_uid (icalcomp), NULL, &(mc->stored_comp), NULL)) + if (!e_cal_client_get_object_sync (client, icalcomponent_get_uid (icalcomp), NULL, &(mc->stored_comp), NULL, NULL)) mc->stored_comp = NULL; mcs = g_slist_append (mcs, mc); @@ -937,7 +938,7 @@ get_selected_text (EMailReader *reader) } static void -mail_to_event (ECalSourceType source_type, +mail_to_event (ECalClientSourceType source_type, gboolean with_attendees, EMailReader *reader) { @@ -952,7 +953,7 @@ mail_to_event (ECalSourceType source_type, folder = e_mail_reader_get_folder (reader); uids = e_mail_reader_get_selected_uids (reader); - if (!e_cal_get_sources (&source_list, source_type, &error)) { + if (!e_cal_client_get_sources (&source_list, source_type, &error)) { e_notice (NULL, GTK_MESSAGE_ERROR, _("Cannot get source list. %s"), error ? error->message : _("Unknown error.")); if (error) @@ -999,21 +1000,26 @@ mail_to_event (ECalSourceType source_type, if (source) { /* if a source has been selected, perform the mail2event operation */ - ECal *client = NULL; + ECalClient *client = NULL; AsyncData *data = NULL; GThread *thread = NULL; + GError *error = NULL; - client = e_auth_new_cal_from_source (source, source_type); + client = e_cal_client_new (source, source_type, &error); if (!client) { gchar *uri = e_source_get_uri (source); - e_notice (NULL, GTK_MESSAGE_ERROR, "Could not create the client: %s", uri); + e_notice (NULL, GTK_MESSAGE_ERROR, "Could not create the client '%s': %s", uri, error ? error->message : "Unknown error"); g_free (uri); g_object_unref (source_list); + if (error) + g_error_free (error); return; } + g_signal_connect (client, "authenticate", G_CALLBACK (e_client_utils_authenticate_handler), NULL); + /* Fill the elements in AsynData */ data = g_new0 (AsyncData, 1); data->client = client; @@ -1040,28 +1046,28 @@ static void action_mail_convert_to_event_cb (GtkAction *action, EMailReader *reader) { - mail_to_event (E_CAL_SOURCE_TYPE_EVENT, FALSE, reader); + mail_to_event (E_CAL_CLIENT_SOURCE_TYPE_EVENTS, FALSE, reader); } static void action_mail_convert_to_meeting_cb (GtkAction *action, EMailReader *reader) { - mail_to_event (E_CAL_SOURCE_TYPE_EVENT, TRUE, reader); + mail_to_event (E_CAL_CLIENT_SOURCE_TYPE_EVENTS, TRUE, reader); } static void action_mail_convert_to_memo_cb (GtkAction *action, EMailReader *reader) { - mail_to_event (E_CAL_SOURCE_TYPE_JOURNAL, FALSE, reader); + mail_to_event (E_CAL_CLIENT_SOURCE_TYPE_MEMOS, FALSE, reader); } static void action_mail_convert_to_task_cb (GtkAction *action, EMailReader *reader) { - mail_to_event (E_CAL_SOURCE_TYPE_TODO, FALSE, reader); + mail_to_event (E_CAL_CLIENT_SOURCE_TYPE_TASKS, FALSE, reader); } /* Note, we're not using EPopupActions here because we update the state -- cgit v1.2.3 From f811cdac0eb1f73edc33a3491b1f4ce5f9164de0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Dan=20Vr=C3=A1til?= Date: Thu, 23 Jun 2011 09:35:26 +0200 Subject: Bug #646442 - [mail-to-task] Edit event details before adding to calendar --- plugins/mail-to-task/mail-to-task.c | 539 ++++++++++++++++++++++-------------- 1 file changed, 327 insertions(+), 212 deletions(-) (limited to 'plugins/mail-to-task/mail-to-task.c') diff --git a/plugins/mail-to-task/mail-to-task.c b/plugins/mail-to-task/mail-to-task.c index 29e0a10e5b..1ac7652d40 100644 --- a/plugins/mail-to-task/mail-to-task.c +++ b/plugins/mail-to-task/mail-to-task.c @@ -35,7 +35,9 @@ #include #include #include +#include #include +#include #include #include @@ -48,7 +50,10 @@ #include #include #include -#include +#include +#include +#include +#include #include #define E_SHELL_WINDOW_ACTION_CONVERT_TO_EVENT(window) \ @@ -65,6 +70,79 @@ gboolean mail_browser_init (GtkUIManager *ui_manager, gboolean mail_shell_view_init (GtkUIManager *ui_manager, EShellView *shell_view); +static CompEditor* +get_component_editor (EShell *shell, + ECalClient *client, + ECalComponent *comp, + gboolean is_new, + GError **error) +{ + ECalComponentId *id; + CompEditorFlags flags = 0; + CompEditor *editor = NULL; + + g_return_val_if_fail (E_IS_SHELL (shell), NULL); + g_return_val_if_fail (E_IS_CAL_CLIENT (client), NULL); + g_return_val_if_fail (E_IS_CAL_COMPONENT (comp), NULL); + + id = e_cal_component_get_id (comp); + g_return_val_if_fail (id != NULL, NULL); + g_return_val_if_fail (id->uid != NULL, NULL); + + if (is_new) { + flags |= COMP_EDITOR_NEW_ITEM; + } else { + editor = comp_editor_find_instance (id->uid); + } + + if (!editor) { + if (itip_organizer_is_user (comp, client)) + flags |= COMP_EDITOR_USER_ORG; + + switch (e_cal_component_get_vtype (comp)) { + case E_CAL_COMPONENT_EVENT: + if (e_cal_component_has_attendees (comp)) + flags |= COMP_EDITOR_MEETING; + + editor = event_editor_new (client, shell, flags); + + if (flags & COMP_EDITOR_MEETING) + event_editor_show_meeting (EVENT_EDITOR (editor)); + break; + case E_CAL_COMPONENT_TODO: + if (e_cal_component_has_attendees (comp)) + flags |= COMP_EDITOR_IS_ASSIGNED; + + editor = task_editor_new (client, shell, flags); + + if (flags & COMP_EDITOR_IS_ASSIGNED) + task_editor_show_assignment (TASK_EDITOR (editor)); + break; + case E_CAL_COMPONENT_JOURNAL: + if (e_cal_component_has_organizer (comp)) + flags |= COMP_EDITOR_IS_SHARED; + + editor = memo_editor_new (client, shell, flags); + break; + default: + if (error) + *error = e_client_error_create (E_CLIENT_ERROR_INVALID_ARG, NULL); + break; + } + + if (editor) { + comp_editor_edit_comp (editor, comp); + + /* request save for new events */ + comp_editor_set_changed (editor, is_new); + } + } + + e_cal_component_free_id (id); + + return editor; +} + static void set_attendees (ECalComponent *comp, CamelMimeMessage *message, const gchar *organizer) { @@ -173,9 +251,9 @@ set_description (ECalComponent *comp, CamelMimeMessage *message) CamelStream *stream; CamelContentType *type; CamelMimePart *mime_part = CAMEL_MIME_PART (message); - ECalComponentText text; + ECalComponentText *text = NULL; GByteArray *byte_array; - GSList sl; + GSList *sl = NULL; gchar *str, *convert_str = NULL; gsize bytes_read, bytes_written; gint count = 2; @@ -213,19 +291,20 @@ set_description (ECalComponent *comp, CamelMimeMessage *message) &bytes_read, &bytes_written, NULL); } + text = g_new0 (ECalComponentText, 1); if (convert_str) - text.value = prepend_from (message, &convert_str); + text->value = prepend_from (message, &convert_str); else - text.value = prepend_from (message, &str); - text.altrep = NULL; - sl.next = NULL; - sl.data = &text; + text->value = prepend_from (message, &str); + text->altrep = NULL; + sl = g_slist_append (sl, text); - e_cal_component_set_description_list (comp, &sl); + e_cal_component_set_description_list (comp, sl); g_free (str); if (convert_str) g_free (convert_str); + e_cal_component_free_text_list (sl); } static gchar * @@ -254,21 +333,23 @@ set_organizer (ECalComponent *comp) return res; } +struct _att_async_cb_data { + gchar **uris; + EFlag *flag; +}; + static void attachment_load_finished (EAttachmentStore *store, GAsyncResult *result, gpointer user_data) { - struct { - gchar **uris; - gboolean done; - } *status = user_data; + struct _att_async_cb_data *data = user_data; /* XXX Should be no need to check for error here. * This is just to reset state in the EAttachment. */ e_attachment_store_load_finish (store, result, NULL); - status->done = TRUE; + e_flag_set (data->flag); } static void @@ -276,18 +357,19 @@ attachment_save_finished (EAttachmentStore *store, GAsyncResult *result, gpointer user_data) { + struct _att_async_cb_data *data = user_data; gchar **uris; + GError *error = NULL; - struct { - gchar **uris; - gboolean done; - } *status = user_data; + uris = e_attachment_store_save_finish (store, result, &error); + if (error) + data->uris = NULL; + else + data->uris = uris; - /* XXX Add some error handling here! */ - uris = e_attachment_store_save_finish (store, result, NULL); + g_clear_error (&error); - status->uris = uris; - status->done = TRUE; + e_flag_set (data->flag); } static void @@ -306,11 +388,10 @@ set_attachments (ECalClient *client, ECalComponent *comp, CamelMimeMessage *mess const gchar *local_store; gint ii, n_parts; gchar *path; + struct _att_async_cb_data cb_data; - struct { - gchar **uris; - gboolean done; - } status; + cb_data.flag = e_flag_new (); + cb_data.uris = NULL; content = camel_medium_get_content ((CamelMedium *) message); if (!content || !CAMEL_IS_MULTIPART (content)) @@ -344,42 +425,44 @@ set_attachments (ECalClient *client, ECalComponent *comp, CamelMimeMessage *mess attachment_list = g_list_append (attachment_list, attachment); } - status.done = FALSE; + e_flag_clear (cb_data.flag); e_attachment_store_load_async ( store, attachment_list, (GAsyncReadyCallback) - attachment_load_finished, &status); + attachment_load_finished, &cb_data); /* Loading should be instantaneous since we already have - * the full content, but we still have to crank the main - * loop until the callback gets triggered. */ - while (!status.done) - gtk_main_iteration (); + * the full content, but we need to wait for the callback. + */ + e_flag_wait (cb_data.flag); g_list_foreach (attachment_list, (GFunc) g_object_unref, NULL); g_list_free (attachment_list); - status.uris = NULL; - status.done = FALSE; + cb_data.uris = NULL; + e_flag_clear (cb_data.flag); e_attachment_store_save_async ( store, destination, (GAsyncReadyCallback) - attachment_save_finished, &status); + attachment_save_finished, &cb_data); - /* We can't return until we have results, so crank - * the main loop until the callback gets triggered. */ - while (!status.done) - gtk_main_iteration (); + /* We can't return until we have results. */ + e_flag_wait (cb_data.flag); - g_return_if_fail (status.uris != NULL); + if (cb_data.uris == NULL) { + e_flag_free (cb_data.flag); + g_warning ("No attachment URIs retrieved."); + return; + } /* Transfer the URI strings to the GSList. */ - for (ii = 0; status.uris[ii] != NULL; ii++) { - uri_list = g_slist_prepend (uri_list, status.uris[ii]); - status.uris[ii] = NULL; + for (ii = 0; cb_data.uris[ii] != NULL; ii++) { + uri_list = g_slist_prepend (uri_list, cb_data.uris[ii]); + cb_data.uris[ii] = NULL; } - g_free (status.uris); + e_flag_free (cb_data.flag); + g_free (cb_data.uris); /* XXX Does this take ownership of the list? */ e_cal_component_set_attachment_list (comp, uri_list); @@ -441,6 +524,12 @@ struct _manage_comp ECalClient *client; ECalComponent *comp; icalcomponent *stored_comp; /* the one in client already */ + GCond *cond; + GMutex *mutex; + gint mails_count; + gint mails_done; + gchar *editor_title; + gboolean can_continue; }; static void @@ -452,6 +541,13 @@ free_manage_comp_struct (struct _manage_comp *mc) g_object_unref (mc->client); if (mc->stored_comp) icalcomponent_free (mc->stored_comp); + if (mc->mutex) + g_mutex_free (mc->mutex); + if (mc->cond) + g_cond_free (mc->cond); + if (mc->editor_title) + g_free (mc->editor_title); + g_free (mc); } @@ -504,28 +600,19 @@ get_question_edit_old (ECalClientSourceType source_type) } static const gchar * -get_question_create_new (ECalClientSourceType source_type) +get_question_add_all_mails (ECalClientSourceType source_type) { const gchar *ask = NULL; switch (source_type) { case E_CAL_CLIENT_SOURCE_TYPE_EVENTS: - /* Translators: Codewise it is impossible to provide separate strings for all - combinations of singular and plural. Please translate it in the way that you - feel is most appropriate for your language. */ - ask = _("Selected calendar contains some events for the given mails already. Would you like to create new events anyway?"); + ask = _("You have selected %d mails to be converted to events. Do you really want to add them all?"); break; case E_CAL_CLIENT_SOURCE_TYPE_TASKS: - /* Translators: Codewise it is impossible to provide separate strings for all - combinations of singular and plural. Please translate it in the way that you - feel is most appropriate for your language. */ - ask = _("Selected task list contains some tasks for the given mails already. Would you like to create new tasks anyway?"); + ask = _("You have selected %d mails to be converted to tasks. Do you really want to add them all?"); break; case E_CAL_CLIENT_SOURCE_TYPE_MEMOS: - /* Translators: Codewise it is impossible to provide separate strings for all - combinations of singular and plural. Please translate it in the way that you - feel is most appropriate for your language. */ - ask = _("Selected memo list contains some memos for the given mails already. Would you like to create new memos anyway?"); + ask = _("You have selected %d mails to be converted to memos. Do you really want to add them all?"); break; default: g_assert_not_reached (); @@ -535,185 +622,156 @@ get_question_create_new (ECalClientSourceType source_type) return ask; } -static const gchar * -get_question_create_new_n (ECalClientSourceType source_type, gint count) +static void +comp_editor_closed (CompEditor *editor, + gboolean accepted, + struct _manage_comp *mc) { - const gchar *ask = NULL; + if (!mc) + return; - switch (source_type) { - case E_CAL_CLIENT_SOURCE_TYPE_EVENTS: - ask = ngettext ( - /* Translators: Codewise it is impossible to provide separate strings for all - combinations of singular and plural. Please translate it in the way that you - feel is most appropriate for your language. */ - "Selected calendar contains an event for the given mail already. Would you like to create new event anyway?", - "Selected calendar contains events for the given mails already. Would you like to create new events anyway?", - count); - break; - case E_CAL_CLIENT_SOURCE_TYPE_TASKS: - ask = ngettext ( - /* Translators: Codewise it is impossible to provide separate strings for all - combinations of singular and plural. Please translate it in the way that you - feel is most appropriate for your language. */ - "Selected task list contains a task for the given mail already. Would you like to create new task anyway?", - "Selected task list contains tasks for the given mails already. Would you like to create new tasks anyway?", - count); - break; - case E_CAL_CLIENT_SOURCE_TYPE_MEMOS: - ask = ngettext ( - /* Translators: Codewise it is impossible to provide separate strings for all - combinations of singular and plural. Please translate it in the way that you - feel is most appropriate for your language. */ - "Selected memo list contains a memo for the given mail already. Would you like to create new memo anyway?", - "Selected memo list contains memos for the given mails already. Would you like to create new memos anyway?", - count); - break; - default: - g_assert_not_reached (); - break; - } + if (!accepted && mc->mails_done < mc->mails_count) + mc->can_continue = (do_ask (_("Do you wish to continue converting remaining mails?"), FALSE) == GTK_RESPONSE_YES); - return ask; + /* Signal the do_mail_to_event thread that editor was closed and editor + for next event can be displayed (if any) */ + g_cond_signal (mc->cond); } -static gboolean -do_manage_comp_idle (GSList *manage_comp_datas) +/* + * This handler takes title of the editor window and + * inserts information about number of processed mails and + * number of all mails to process, so the window title + * will look like "Appointment (3/10) - An appoitment name" + */ +static void +comp_editor_title_changed (GtkWidget *widget, + GParamSpec *pspec, + struct _manage_comp *mc) { - GError *error = NULL; - guint with_old = 0; - gboolean need_editor = FALSE; - ECalClientSourceType source_type = E_CAL_CLIENT_SOURCE_TYPE_LAST; - GSList *l; - - g_return_val_if_fail (manage_comp_datas != NULL, FALSE); + GtkWindow *editor = GTK_WINDOW (widget); + const gchar *title = gtk_window_get_title (editor); + gchar *new_title; + gchar *splitter; + gchar *comp_name, *task_name; - if (manage_comp_datas->data) { - struct _manage_comp *mc = manage_comp_datas->data; + if (!mc) + return; - if (mc->comp && (e_cal_component_has_attendees (mc->comp) || e_cal_component_has_organizer (mc->comp))) - need_editor = TRUE; + /* Recursion prevence */ + if (mc->editor_title && g_utf8_collate (mc->editor_title, title) == 0) + return; - source_type = e_cal_client_get_source_type (mc->client); - } + splitter = strchr (title, '-'); + if (!splitter) + return; - if (source_type == E_CAL_CLIENT_SOURCE_TYPE_LAST) { - g_slist_foreach (manage_comp_datas, (GFunc) free_manage_comp_struct, NULL); - g_slist_free (manage_comp_datas); + comp_name = g_strndup (title, splitter - title - 1); + task_name = g_strdup (splitter + 2); + new_title = g_strdup_printf ("%s (%d/%d) - %s", + comp_name, mc->mails_done, mc->mails_count, task_name); - g_warning ("mail-to-task: Incorrect call of %s, no data given", G_STRFUNC); - return FALSE; - } + /* Remember the new title, so that when gtk_window_set_title() causes + this handler to be recursively called, we can recognize that and + prevent endless recursion */ + if (mc->editor_title) + g_free (mc->editor_title); + mc->editor_title = new_title; - for (l = manage_comp_datas; l; l = l->next) { - struct _manage_comp *mc = l->data; + gtk_window_set_title (editor, new_title); - if (mc && mc->stored_comp) - with_old++; - } + g_free (comp_name); + g_free (task_name); +} - if (need_editor) { - for (l = manage_comp_datas; l && !error; l = l->next) { - ECalComponent *edit_comp = NULL; - struct _manage_comp *mc = l->data; +static gboolean +do_manage_comp_idle (struct _manage_comp *mc) +{ + GError *error = NULL; + ECalClientSourceType source_type = E_CAL_CLIENT_SOURCE_TYPE_LAST; + ECalComponent *edit_comp = NULL; - if (!mc) - continue; + g_return_val_if_fail (mc, FALSE); - if (mc->stored_comp) { - const gchar *ask = get_question_edit_old (source_type); + source_type = e_cal_client_get_source_type (mc->client); - if (ask) { - gchar *msg = g_strdup_printf (ask, icalcomponent_get_summary (mc->stored_comp) ? icalcomponent_get_summary (mc->stored_comp) : _("[No Summary]")); - gint chosen; + if (source_type == E_CAL_CLIENT_SOURCE_TYPE_LAST) { + free_manage_comp_struct (mc); - chosen = do_ask (msg, TRUE); + g_warning ("mail-to-task: Incorrect call of %s, no data given", G_STRFUNC); + return FALSE; + } - if (chosen == GTK_RESPONSE_YES) { - edit_comp = e_cal_component_new (); - if (!e_cal_component_set_icalcomponent (edit_comp, icalcomponent_new_clone (mc->stored_comp))) { - g_object_unref (edit_comp); - edit_comp = NULL; + if (mc->stored_comp) { + const gchar *ask = get_question_edit_old (source_type); - error = g_error_new (E_CAL_CLIENT_ERROR, E_CAL_CLIENT_ERROR_INVALID_OBJECT, "%s", _("Invalid object returned from a server")); - } - } else if (chosen == GTK_RESPONSE_NO) { - /* user wants to create a new event, thus generate a new UID */ - gchar *new_uid = e_cal_component_gen_uid (); + if (ask) { + gchar *msg = g_strdup_printf (ask, icalcomponent_get_summary (mc->stored_comp) ? icalcomponent_get_summary (mc->stored_comp) : _("[No Summary]")); + gint chosen; - edit_comp = mc->comp; - e_cal_component_set_uid (edit_comp, new_uid); - e_cal_component_set_recurid (edit_comp, NULL); + chosen = do_ask (msg, TRUE); - g_free (new_uid); - } + if (chosen == GTK_RESPONSE_YES) { + edit_comp = e_cal_component_new (); + if (!e_cal_component_set_icalcomponent (edit_comp, icalcomponent_new_clone (mc->stored_comp))) { + g_object_unref (edit_comp); + edit_comp = NULL; + error = g_error_new (E_CAL_CLIENT_ERROR, + E_CAL_CLIENT_ERROR_INVALID_OBJECT, + "%s", _("Invalid object returned from a server")); - g_free (msg); } - } else { + } else if (chosen == GTK_RESPONSE_NO) { + /* user wants to create a new event, thus generate a new UID */ + gchar *new_uid = e_cal_component_gen_uid (); edit_comp = mc->comp; + e_cal_component_set_uid (edit_comp, new_uid); + e_cal_component_set_recurid (edit_comp, NULL); + g_free (new_uid); } - - if (edit_comp) { - EShell *shell; - - /* FIXME Pass in the EShell instance. */ - shell = e_shell_get_default (); - open_component_editor ( - shell, mc->client, edit_comp, - edit_comp == mc->comp, &error); - if (edit_comp != mc->comp) - g_object_unref (edit_comp); - } + g_free (msg); } } else { - gboolean can = TRUE; - - if (with_old > 0) { - const gchar *ask = NULL; - - can = FALSE; - - if (with_old == g_slist_length (manage_comp_datas)) { - ask = get_question_create_new_n (source_type, with_old); - } else { - ask = get_question_create_new (source_type); - } - - if (ask) - can = do_ask (ask, FALSE) == GTK_RESPONSE_YES; - } + edit_comp = mc->comp; + } - if (can) { - for (l = manage_comp_datas; l && !error; l = l->next) { - struct _manage_comp *mc = l->data; - gchar *uid = NULL; + if (edit_comp) { + EShell *shell; + CompEditor *editor; - if (!mc) - continue; + /* FIXME Pass in the EShell instance. */ + shell = e_shell_get_default (); + editor = get_component_editor (shell, mc->client, edit_comp, + edit_comp == mc->comp, &error); - if (mc->stored_comp) { - gchar *new_uid = e_cal_component_gen_uid (); + if (editor && !error) { + /* Force editor's title change */ + comp_editor_title_changed (GTK_WIDGET (editor), NULL, mc); - e_cal_component_set_uid (mc->comp, new_uid); - e_cal_component_set_recurid (mc->comp, NULL); + g_signal_connect (editor, "notify::title", + G_CALLBACK (comp_editor_title_changed), mc); + g_signal_connect (editor, "comp_closed", + G_CALLBACK (comp_editor_closed), mc); - g_free (new_uid); - } + gtk_window_present (GTK_WINDOW (editor)); - e_cal_client_create_object_sync (mc->client, e_cal_component_get_icalcomponent (mc->comp), &uid, NULL, &error); - g_free (uid); - } + if (edit_comp != mc->comp) + g_object_unref (edit_comp); + } else { + g_warning ("Failed to create event editor: %s", error ? error->message : "Unknown error"); + g_cond_signal (mc->cond); } + } else { + /* User canceled editing already existing event, so treat it as if he just closed the editor window */ + comp_editor_closed (NULL, FALSE, mc); + g_cond_signal (mc->cond); } if (error) { e_notice (NULL, GTK_MESSAGE_ERROR, _("An error occurred during processing: %s"), error->message); - g_error_free (error); + g_clear_error (&error); } - g_slist_foreach (manage_comp_datas, (GFunc) free_manage_comp_struct, NULL); - g_slist_free (manage_comp_datas); - return FALSE; } @@ -756,11 +814,11 @@ do_mail_to_event (AsyncData *data) } } } else { - GSList *mcs = NULL; gint i; ECalClientSourceType source_type = e_cal_client_get_source_type (client); ECalComponentDateTime dt, dt2; struct icaltimetype tt, tt2; + struct _manage_comp *oldmc = NULL; /* set start day of the event as today, without time - easier than looking for a calendar's time zone */ tt = icaltime_today (); @@ -859,24 +917,53 @@ do_mail_to_event (AsyncData *data) mc = g_new0 (struct _manage_comp, 1); mc->client = g_object_ref (client); mc->comp = g_object_ref (comp); + mc->mutex = g_mutex_new (); + mc->cond = g_cond_new (); + mc->mails_count = uids->len; + mc->mails_done = i + 1; /* Current task */ + mc->editor_title = NULL; + mc->can_continue = TRUE; + + if (oldmc) { + /* Wait for user to quit the editor created in previous iteration + * before displaying next one */ + gboolean can_continue; + g_mutex_lock (oldmc->mutex); + g_cond_wait (oldmc->cond, oldmc->mutex); + g_mutex_unlock (oldmc->mutex); + can_continue = oldmc->can_continue; + free_manage_comp_struct (oldmc); + oldmc = NULL; + + if (!can_continue) + break; + } if (!e_cal_client_get_object_sync (client, icalcomponent_get_uid (icalcomp), NULL, &(mc->stored_comp), NULL, NULL)) mc->stored_comp = NULL; - mcs = g_slist_append (mcs, mc); + g_idle_add ((GSourceFunc) do_manage_comp_idle, mc); + + oldmc = mc; g_object_unref (comp); + g_object_unref (message); + } - if (mcs) { - /* process this in the main thread, as we may ask user too */ - g_idle_add ((GSourceFunc) do_manage_comp_idle, mcs); + /* Wait for the last editor and then clean up */ + if (oldmc) { + g_mutex_lock (oldmc->mutex); + g_cond_wait (oldmc->cond, oldmc->mutex); + g_mutex_unlock (oldmc->mutex); + free_manage_comp_struct (oldmc); } } /* free memory */ g_object_unref (data->client); - g_ptr_array_free (data->uids, TRUE); + camel_folder_free_uids (folder, uids); + g_object_unref (folder); g_free (data->selected_text); g_free (data); data = NULL; @@ -947,22 +1034,36 @@ mail_to_event (ECalClientSourceType source_type, ESourceList *source_list = NULL; gboolean done = FALSE; GSList *groups, *p; - ESource *source = NULL; + ESource *source = NULL, *default_source = NULL; GError *error = NULL; + gint writable_sources = 0; folder = e_mail_reader_get_folder (reader); uids = e_mail_reader_get_selected_uids (reader); if (!e_cal_client_get_sources (&source_list, source_type, &error)) { e_notice (NULL, GTK_MESSAGE_ERROR, _("Cannot get source list. %s"), error ? error->message : _("Unknown error.")); - if (error) g_error_free (error); - + camel_folder_free_uids (folder, uids); + g_object_unref (folder); return; } - /* Check if there is only one writeable source, if so do not ask user to pick it */ + /* Ask before converting 10 or more mails to events */ + if (uids->len > 10) { + gchar *question = g_strdup_printf (get_question_add_all_mails (source_type), uids->len); + if (do_ask (question, FALSE) == GTK_RESPONSE_NO) { + g_free (question); + g_object_unref (source_list); + camel_folder_free_uids (folder, uids); + g_object_unref (folder); + return; + } + g_free (question); + } + + /* Find 'Default' source. When no source is default, ask user to pick one */ groups = e_source_list_peek_groups (source_list); for (p = groups; p != NULL && !done; p = p->next) { ESourceGroup *group = E_SOURCE_GROUP (p->data); @@ -972,19 +1073,20 @@ mail_to_event (ECalClientSourceType source_type, for (q = sources; q != NULL; q = q->next) { ESource *s = E_SOURCE (q->data); - if (s && !e_source_get_readonly (s)) { - if (source) { - source = NULL; - done = TRUE; - break; - } + if (s && e_source_get_property (s, "default") && !e_source_get_readonly (s)) { + default_source = s; + done = TRUE; + break; + } + if (s && !e_source_get_readonly (s)) { + writable_sources++; source = s; } } } - if (!source) { + if (!default_source && writable_sources > 1) { GtkWidget *dialog; /* ask the user which tasks list to save to */ @@ -996,6 +1098,17 @@ mail_to_event (ECalClientSourceType source_type, source = e_source_selector_dialog_peek_primary_selection (E_SOURCE_SELECTOR_DIALOG (dialog)); gtk_widget_destroy (dialog); + } else if (!source && default_source) { + source = default_source; + } else { + e_notice (NULL, GTK_MESSAGE_ERROR, _("No writable calendar is available.")); + + g_object_unref (source_list); + camel_folder_free_uids (folder, uids); + g_object_unref (folder); + if (error) + g_error_free (error); + return; } if (source) { @@ -1013,6 +1126,8 @@ mail_to_event (ECalClientSourceType source_type, g_free (uri); g_object_unref (source_list); + camel_folder_free_uids (folder, uids); + g_object_unref (folder); if (error) g_error_free (error); return; -- cgit v1.2.3 From 126772ab2b4b64fbe608ac3505ce924ed2b692b9 Mon Sep 17 00:00:00 2001 From: Milan Crha Date: Fri, 26 Aug 2011 10:56:37 +0200 Subject: Bug #655549 - [mail-to-task] Ignores cancel of source select dialog --- plugins/mail-to-task/mail-to-task.c | 2 ++ 1 file changed, 2 insertions(+) (limited to 'plugins/mail-to-task/mail-to-task.c') diff --git a/plugins/mail-to-task/mail-to-task.c b/plugins/mail-to-task/mail-to-task.c index 1ac7652d40..56da9efa7e 100644 --- a/plugins/mail-to-task/mail-to-task.c +++ b/plugins/mail-to-task/mail-to-task.c @@ -1096,6 +1096,8 @@ mail_to_event (ECalClientSourceType source_type, if (gtk_dialog_run (GTK_DIALOG (dialog)) == GTK_RESPONSE_OK) source = e_source_selector_dialog_peek_primary_selection (E_SOURCE_SELECTOR_DIALOG (dialog)); + else + source = NULL; gtk_widget_destroy (dialog); } else if (!source && default_source) { -- cgit v1.2.3 From b8a55643a382956df48d897cc6480ed7a28e3c62 Mon Sep 17 00:00:00 2001 From: Milan Crha Date: Fri, 26 Aug 2011 11:24:49 +0200 Subject: Bug #655551 - [mail-to-task] Pick organizer based on selected folder's store --- plugins/mail-to-task/mail-to-task.c | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) (limited to 'plugins/mail-to-task/mail-to-task.c') diff --git a/plugins/mail-to-task/mail-to-task.c b/plugins/mail-to-task/mail-to-task.c index 56da9efa7e..ddcd1328d1 100644 --- a/plugins/mail-to-task/mail-to-task.c +++ b/plugins/mail-to-task/mail-to-task.c @@ -308,14 +308,21 @@ set_description (ECalComponent *comp, CamelMimeMessage *message) } static gchar * -set_organizer (ECalComponent *comp) +set_organizer (ECalComponent *comp, CamelFolder *folder) { - EAccount *account; + EAccount *account = NULL; const gchar *str, *name; ECalComponentOrganizer organizer = {NULL, NULL, NULL, NULL}; gchar *res; - account = e_get_default_account (); + if (folder) { + CamelStore *store = camel_folder_get_parent_store (folder); + + account = e_get_account_by_uid (camel_service_get_uid (CAMEL_SERVICE (store))); + } + + if (!account) + account = e_get_default_account (); if (!account) return NULL; @@ -894,7 +901,7 @@ do_mail_to_event (AsyncData *data) gchar *organizer; /* set actual user as organizer, to be able to change event's properties */ - organizer = set_organizer (comp); + organizer = set_organizer (comp, data->folder); set_attendees (comp, message, organizer); g_free (organizer); } -- cgit v1.2.3 From bc03bf534a55275bd7e5de99e0c0b612d33c25d7 Mon Sep 17 00:00:00 2001 From: Milan Crha Date: Fri, 26 Aug 2011 14:22:58 +0200 Subject: Changing source in CompEditor blocks UI --- plugins/mail-to-task/mail-to-task.c | 14 ++++++++++++++ 1 file changed, 14 insertions(+) (limited to 'plugins/mail-to-task/mail-to-task.c') diff --git a/plugins/mail-to-task/mail-to-task.c b/plugins/mail-to-task/mail-to-task.c index ddcd1328d1..a39456a00f 100644 --- a/plugins/mail-to-task/mail-to-task.c +++ b/plugins/mail-to-task/mail-to-task.c @@ -827,6 +827,20 @@ do_mail_to_event (AsyncData *data) struct icaltimetype tt, tt2; struct _manage_comp *oldmc = NULL; + #define cache_backend_prop(prop) { \ + gchar *val = NULL; \ + e_client_get_backend_property_sync (E_CLIENT (client), prop, &val, NULL, NULL); \ + g_free (val); \ + } + + /* precache backend properties, thus editor have them ready when needed */ + cache_backend_prop (CAL_BACKEND_PROPERTY_CAL_EMAIL_ADDRESS); + cache_backend_prop (CAL_BACKEND_PROPERTY_ALARM_EMAIL_ADDRESS); + cache_backend_prop (CAL_BACKEND_PROPERTY_DEFAULT_OBJECT); + e_client_get_capabilities (E_CLIENT (client)); + + #undef cache_backend_prop + /* set start day of the event as today, without time - easier than looking for a calendar's time zone */ tt = icaltime_today (); dt.value = &tt; -- cgit v1.2.3 From f382dbf020a25ee21608dc41d84f20624520f06b Mon Sep 17 00:00:00 2001 From: Milan Crha Date: Fri, 26 Aug 2011 14:56:12 +0200 Subject: [mail-to-task] Uses incorrect function to free array of message uids --- plugins/mail-to-task/mail-to-task.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) (limited to 'plugins/mail-to-task/mail-to-task.c') diff --git a/plugins/mail-to-task/mail-to-task.c b/plugins/mail-to-task/mail-to-task.c index a39456a00f..61eb5fb2f3 100644 --- a/plugins/mail-to-task/mail-to-task.c +++ b/plugins/mail-to-task/mail-to-task.c @@ -983,7 +983,7 @@ do_mail_to_event (AsyncData *data) /* free memory */ g_object_unref (data->client); - camel_folder_free_uids (folder, uids); + em_utils_uids_free (uids); g_object_unref (folder); g_free (data->selected_text); g_free (data); @@ -1066,7 +1066,7 @@ mail_to_event (ECalClientSourceType source_type, e_notice (NULL, GTK_MESSAGE_ERROR, _("Cannot get source list. %s"), error ? error->message : _("Unknown error.")); if (error) g_error_free (error); - camel_folder_free_uids (folder, uids); + em_utils_uids_free (uids); g_object_unref (folder); return; } @@ -1077,7 +1077,7 @@ mail_to_event (ECalClientSourceType source_type, if (do_ask (question, FALSE) == GTK_RESPONSE_NO) { g_free (question); g_object_unref (source_list); - camel_folder_free_uids (folder, uids); + em_utils_uids_free (uids); g_object_unref (folder); return; } @@ -1127,7 +1127,7 @@ mail_to_event (ECalClientSourceType source_type, e_notice (NULL, GTK_MESSAGE_ERROR, _("No writable calendar is available.")); g_object_unref (source_list); - camel_folder_free_uids (folder, uids); + em_utils_uids_free (uids); g_object_unref (folder); if (error) g_error_free (error); @@ -1149,7 +1149,7 @@ mail_to_event (ECalClientSourceType source_type, g_free (uri); g_object_unref (source_list); - camel_folder_free_uids (folder, uids); + em_utils_uids_free (uids); g_object_unref (folder); if (error) g_error_free (error); -- cgit v1.2.3 From 777c1cbd40eb63365f2c28e38f6a93beb2d1c9d1 Mon Sep 17 00:00:00 2001 From: Matthew Barnes Date: Tue, 16 Aug 2011 11:25:56 -0400 Subject: Coding style and whitespace cleanup. --- plugins/mail-to-task/mail-to-task.c | 47 +++++++++++++++++++++++-------------- 1 file changed, 29 insertions(+), 18 deletions(-) (limited to 'plugins/mail-to-task/mail-to-task.c') diff --git a/plugins/mail-to-task/mail-to-task.c b/plugins/mail-to-task/mail-to-task.c index 61eb5fb2f3..eb9e762b75 100644 --- a/plugins/mail-to-task/mail-to-task.c +++ b/plugins/mail-to-task/mail-to-task.c @@ -70,7 +70,7 @@ gboolean mail_browser_init (GtkUIManager *ui_manager, gboolean mail_shell_view_init (GtkUIManager *ui_manager, EShellView *shell_view); -static CompEditor* +static CompEditor * get_component_editor (EShell *shell, ECalClient *client, ECalComponent *comp, @@ -144,7 +144,9 @@ get_component_editor (EShell *shell, } static void -set_attendees (ECalComponent *comp, CamelMimeMessage *message, const gchar *organizer) +set_attendees (ECalComponent *comp, + CamelMimeMessage *message, + const gchar *organizer) { GSList *attendees = NULL, *to_free = NULL; ECalComponentAttendee *ca; @@ -214,7 +216,8 @@ set_attendees (ECalComponent *comp, CamelMimeMessage *message, const gchar *orga } static const gchar * -prepend_from (CamelMimeMessage *message, gchar **text) +prepend_from (CamelMimeMessage *message, + gchar **text) { gchar *res, *tmp, *addr = NULL; const gchar *name = NULL, *eml = NULL; @@ -245,7 +248,8 @@ prepend_from (CamelMimeMessage *message, gchar **text) } static void -set_description (ECalComponent *comp, CamelMimeMessage *message) +set_description (ECalComponent *comp, + CamelMimeMessage *message) { CamelDataWrapper *content; CamelStream *stream; @@ -308,7 +312,8 @@ set_description (ECalComponent *comp, CamelMimeMessage *message) } static gchar * -set_organizer (ECalComponent *comp, CamelFolder *folder) +set_organizer (ECalComponent *comp, + CamelFolder *folder) { EAccount *account = NULL; const gchar *str, *name; @@ -380,7 +385,9 @@ attachment_save_finished (EAttachmentStore *store, } static void -set_attachments (ECalClient *client, ECalComponent *comp, CamelMimeMessage *message) +set_attachments (ECalClient *client, + ECalComponent *comp, + CamelMimeMessage *message) { /* XXX Much of this is copied from CompEditor::get_attachment_list(). * Perhaps it should be split off as a separate utility? */ @@ -480,7 +487,8 @@ set_attachments (ECalClient *client, ECalComponent *comp, CamelMimeMessage *mess } static void -set_priority (ECalComponent *comp, CamelMimePart *part) +set_priority (ECalComponent *comp, + CamelMimePart *part) { const gchar *prio; @@ -515,7 +523,8 @@ do_report_error (struct _report_error *err) } static void -report_error_idle (const gchar *format, const gchar *param) +report_error_idle (const gchar *format, + const gchar *param) { struct _report_error *err = g_new (struct _report_error, 1); @@ -559,7 +568,8 @@ free_manage_comp_struct (struct _manage_comp *mc) } static gint -do_ask (const gchar *text, gboolean is_create_edit_add) +do_ask (const gchar *text, + gboolean is_create_edit_add) { gint res; GtkWidget *dialog = gtk_message_dialog_new (NULL, @@ -631,8 +641,8 @@ get_question_add_all_mails (ECalClientSourceType source_type) static void comp_editor_closed (CompEditor *editor, - gboolean accepted, - struct _manage_comp *mc) + gboolean accepted, + struct _manage_comp *mc) { if (!mc) return; @@ -641,7 +651,7 @@ comp_editor_closed (CompEditor *editor, mc->can_continue = (do_ask (_("Do you wish to continue converting remaining mails?"), FALSE) == GTK_RESPONSE_YES); /* Signal the do_mail_to_event thread that editor was closed and editor - for next event can be displayed (if any) */ + * for next event can be displayed (if any) */ g_cond_signal (mc->cond); } @@ -653,8 +663,8 @@ comp_editor_closed (CompEditor *editor, */ static void comp_editor_title_changed (GtkWidget *widget, - GParamSpec *pspec, - struct _manage_comp *mc) + GParamSpec *pspec, + struct _manage_comp *mc) { GtkWindow *editor = GTK_WINDOW (widget); const gchar *title = gtk_window_get_title (editor); @@ -679,8 +689,8 @@ comp_editor_title_changed (GtkWidget *widget, comp_name, mc->mails_done, mc->mails_count, task_name); /* Remember the new title, so that when gtk_window_set_title() causes - this handler to be recursively called, we can recognize that and - prevent endless recursion */ + * this handler to be recursively called, we can recognize that and + * prevent endless recursion */ if (mc->editor_title) g_free (mc->editor_title); mc->editor_title = new_title; @@ -996,12 +1006,13 @@ do_mail_to_event (AsyncData *data) } static gboolean -text_contains_nonwhitespace (const gchar *text, gint len) +text_contains_nonwhitespace (const gchar *text, + gint len) { const gchar *p; gunichar c = 0; - if (!text || len<=0) + if (!text || len <= 0) return FALSE; p = text; -- cgit v1.2.3 From 981d3d17680fd8592c8593732b2640f17ad6d572 Mon Sep 17 00:00:00 2001 From: Milan Crha Date: Mon, 26 Sep 2011 11:02:47 +0200 Subject: Bug #655252 - Need to escape the comp_uid part of a path --- plugins/mail-to-task/mail-to-task.c | 21 ++++++++++++++------- 1 file changed, 14 insertions(+), 7 deletions(-) (limited to 'plugins/mail-to-task/mail-to-task.c') diff --git a/plugins/mail-to-task/mail-to-task.c b/plugins/mail-to-task/mail-to-task.c index eb9e762b75..1d9f1fa0d0 100644 --- a/plugins/mail-to-task/mail-to-task.c +++ b/plugins/mail-to-task/mail-to-task.c @@ -37,6 +37,7 @@ #include #include #include +#include #include #include #include @@ -400,8 +401,8 @@ set_attachments (ECalClient *client, GSList *uri_list = NULL; const gchar *comp_uid = NULL; const gchar *local_store; + gchar *filename_prefix, *tmp; gint ii, n_parts; - gchar *path; struct _att_async_cb_data cb_data; cb_data.flag = e_flag_new (); @@ -416,11 +417,15 @@ set_attachments (ECalClient *client, return; e_cal_component_get_uid (comp, &comp_uid); - local_store = e_cal_client_get_local_attachment_store (client); - path = g_build_path ("/", local_store, comp_uid, NULL); + g_return_if_fail (comp_uid != NULL); - destination = g_file_new_for_path (path); - g_free (path); + tmp = g_strdup (comp_uid); + e_filename_make_safe (tmp); + filename_prefix = g_strconcat (tmp, "-", NULL); + g_free (tmp); + + local_store = e_cal_client_get_local_attachment_store (client); + destination = g_file_new_for_path (local_store); /* Create EAttachments from the MIME parts and add them to the * attachment store. */ @@ -457,8 +462,10 @@ set_attachments (ECalClient *client, e_flag_clear (cb_data.flag); e_attachment_store_save_async ( - store, destination, (GAsyncReadyCallback) - attachment_save_finished, &cb_data); + store, destination, filename_prefix, + (GAsyncReadyCallback) attachment_save_finished, &cb_data); + + g_free (filename_prefix); /* We can't return until we have results. */ e_flag_wait (cb_data.flag); -- cgit v1.2.3 From 3e2efde8299cda56382dfc8f3457f302048a89a6 Mon Sep 17 00:00:00 2001 From: Rodrigo Moya Date: Thu, 13 Oct 2011 18:23:17 +0200 Subject: Remove unneeded GConf header --- plugins/mail-to-task/mail-to-task.c | 1 - 1 file changed, 1 deletion(-) (limited to 'plugins/mail-to-task/mail-to-task.c') diff --git a/plugins/mail-to-task/mail-to-task.c b/plugins/mail-to-task/mail-to-task.c index 810a2b593c..f028528575 100644 --- a/plugins/mail-to-task/mail-to-task.c +++ b/plugins/mail-to-task/mail-to-task.c @@ -33,7 +33,6 @@ #include #include -#include #include #include #include -- cgit v1.2.3 From e64d6fe05c30c2cc1d7625a202afba3ba2da07cd Mon Sep 17 00:00:00 2001 From: Matthew Barnes Date: Tue, 22 Nov 2011 18:22:14 -0500 Subject: Miscellaneous cleanups. --- plugins/mail-to-task/mail-to-task.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) (limited to 'plugins/mail-to-task/mail-to-task.c') diff --git a/plugins/mail-to-task/mail-to-task.c b/plugins/mail-to-task/mail-to-task.c index 29329d284e..a4713c5447 100644 --- a/plugins/mail-to-task/mail-to-task.c +++ b/plugins/mail-to-task/mail-to-task.c @@ -321,9 +321,13 @@ set_organizer (ECalComponent *comp, gchar *res; if (folder) { - CamelStore *store = camel_folder_get_parent_store (folder); + CamelStore *store; + const gchar *uid; - account = e_get_account_by_uid (camel_service_get_uid (CAMEL_SERVICE (store))); + store = camel_folder_get_parent_store (folder); + uid = camel_service_get_uid (CAMEL_SERVICE (store)); + + account = e_get_account_by_uid (uid); } if (!account) -- cgit v1.2.3