aboutsummaryrefslogtreecommitdiffstats
path: root/mail/em-composer-utils.c
diff options
context:
space:
mode:
Diffstat (limited to 'mail/em-composer-utils.c')
-rw-r--r--mail/em-composer-utils.c263
1 files changed, 0 insertions, 263 deletions
diff --git a/mail/em-composer-utils.c b/mail/em-composer-utils.c
index 3f851c0991..bc84e5508c 100644
--- a/mail/em-composer-utils.c
+++ b/mail/em-composer-utils.c
@@ -1850,269 +1850,6 @@ em_utils_redirect_message (EShell *shell,
composer_set_no_change (composer);
}
-/* Message disposition notifications, rfc 2298 */
-void
-em_utils_handle_receipt (EMailBackend *backend,
- CamelFolder *folder,
- const gchar *message_uid,
- CamelMimeMessage *message)
-{
- EAccount *account;
- const gchar *addr;
- CamelMessageInfo *info;
-
- g_return_if_fail (E_IS_MAIL_BACKEND (backend));
- g_return_if_fail (CAMEL_IS_FOLDER (folder));
- g_return_if_fail (CAMEL_IS_MIME_MESSAGE (message));
-
- info = camel_folder_get_message_info (folder, message_uid);
- if (info == NULL)
- return;
-
- if (camel_message_info_user_flag (info, "receipt-handled")) {
- camel_folder_free_message_info (folder, info);
- return;
- }
-
- addr = camel_medium_get_header (
- CAMEL_MEDIUM (message), "Disposition-Notification-To");
- if (addr == NULL) {
- camel_folder_free_message_info (folder, info);
- return;
- }
-
- camel_message_info_set_user_flag (info, "receipt-handled", TRUE);
- camel_folder_free_message_info (folder, info);
-
- account = em_utils_guess_account_with_recipients (message, folder);
-
- /* TODO Should probably decode/format the address,
- * since it could be in rfc2047 format. */
- if (addr == NULL) {
- addr = "";
- } else {
- while (camel_mime_is_lwsp (*addr))
- addr++;
- }
-
- if (account == NULL)
- return;
-
- if (account->receipt_policy == E_ACCOUNT_RECEIPT_NEVER)
- return;
-
- if (account->receipt_policy == E_ACCOUNT_RECEIPT_ASK) {
- GtkWindow *window;
- const gchar *subject;
- gint response;
-
- /* FIXME Parent window should be passed in. */
- window = e_shell_get_active_window (NULL);
- subject = camel_mime_message_get_subject (message);
-
- response = e_alert_run_dialog_for_args (
- window, "mail:ask-receipt", addr, subject, NULL);
-
- if (response != GTK_RESPONSE_YES)
- return;
- }
-
- em_utils_send_receipt (backend, folder, message);
-}
-
-static void
-em_utils_receipt_done (CamelFolder *folder,
- GAsyncResult *result,
- EMailBackend *backend)
-{
- /* FIXME Poor error handling. */
- if (!e_mail_folder_append_message_finish (folder, result, NULL, NULL))
- return;
-
- mail_send (backend);
-}
-
-void
-em_utils_send_receipt (EMailBackend *backend,
- CamelFolder *folder,
- CamelMimeMessage *message)
-{
- /* See RFC #3798 for a description of message receipts */
- EAccount *account = em_utils_guess_account_with_recipients (message, folder);
- CamelMimeMessage *receipt = camel_mime_message_new ();
- CamelMultipart *body = camel_multipart_new ();
- CamelMimePart *part;
- CamelDataWrapper *receipt_text, *receipt_data;
- CamelContentType *type;
- CamelInternetAddress *addr;
- CamelStream *stream;
- CamelFolder *out_folder;
- CamelMessageInfo *info;
- const gchar *message_id;
- const gchar *message_date;
- const gchar *message_subject;
- const gchar *receipt_address;
- gchar *fake_msgid;
- gchar *hostname;
- gchar *self_address, *receipt_subject;
- gchar *ua, *recipient;
- gchar *transport_uid;
- gchar *content;
-
- message_id = camel_medium_get_header (
- CAMEL_MEDIUM (message), "Message-ID");
- message_date = camel_medium_get_header (
- CAMEL_MEDIUM (message), "Date");
- message_subject = camel_mime_message_get_subject (message);
- receipt_address = camel_medium_get_header (
- CAMEL_MEDIUM (message), "Disposition-Notification-To");
-
- if (!receipt_address)
- return;
-
- /* the 'account' should be always set */
- g_return_if_fail (account != NULL);
-
- /* Collect information for the receipt */
-
- /* We use camel_header_msgid_generate () to get a canonical
- * hostname, then skip the part leading to '@' */
- hostname = strchr ((fake_msgid = camel_header_msgid_generate ()), '@');
- hostname++;
-
- self_address = account->id->address;
-
- if (!message_id)
- message_id = "";
- if (!message_date)
- message_date ="";
-
- /* Create toplevel container */
- camel_data_wrapper_set_mime_type (
- CAMEL_DATA_WRAPPER (body),
- "multipart/report;"
- "report-type=\"disposition-notification\"");
- camel_multipart_set_boundary (body, NULL);
-
- /* Create textual receipt */
- receipt_text = camel_data_wrapper_new ();
- type = camel_content_type_new ("text", "plain");
- camel_content_type_set_param (type, "format", "flowed");
- camel_content_type_set_param (type, "charset", "UTF-8");
- camel_data_wrapper_set_mime_type_field (receipt_text, type);
- camel_content_type_unref (type);
- content = g_strdup_printf (
- /* Translators: First %s is an email address, second %s
- * is the subject of the email, third %s is the date. */
- _("Your message to %s about \"%s\" on %s has been read."),
- self_address, message_subject, message_date);
- stream = camel_stream_mem_new ();
- camel_stream_write_string (stream, content, NULL, NULL);
- camel_data_wrapper_construct_from_stream_sync (
- receipt_text, stream, NULL, NULL);
- g_object_unref (stream);
- g_free (content);
-
- part = camel_mime_part_new ();
- camel_medium_set_content (CAMEL_MEDIUM (part), receipt_text);
- camel_mime_part_set_encoding (
- part, CAMEL_TRANSFER_ENCODING_QUOTEDPRINTABLE);
- g_object_unref (receipt_text);
- camel_multipart_add_part (body, part);
- g_object_unref (part);
-
- /* Create the machine-readable receipt */
- receipt_data = camel_data_wrapper_new ();
- part = camel_mime_part_new ();
-
- ua = g_strdup_printf (
- "%s; %s", hostname, "Evolution "
- VERSION SUB_VERSION " " VERSION_COMMENT);
- recipient = g_strdup_printf ("rfc822; %s", self_address);
-
- type = camel_content_type_new ("message", "disposition-notification");
- camel_data_wrapper_set_mime_type_field (receipt_data, type);
- camel_content_type_unref (type);
-
- content = g_strdup_printf (
- "Reporting-UA: %s\n"
- "Final-Recipient: %s\n"
- "Original-Message-ID: %s\n"
- "Disposition: manual-action/MDN-sent-manually; displayed\n",
- ua, recipient, message_id);
- stream = camel_stream_mem_new ();
- camel_stream_write_string (stream, content, NULL, NULL);
- camel_data_wrapper_construct_from_stream_sync (
- receipt_data, stream, NULL, NULL);
- g_object_unref (stream);
- g_free (content);
-
- g_free (ua);
- g_free (recipient);
- g_free (fake_msgid);
-
- camel_medium_set_content (CAMEL_MEDIUM (part), receipt_data);
- camel_mime_part_set_encoding (part, CAMEL_TRANSFER_ENCODING_7BIT);
- g_object_unref (receipt_data);
- camel_multipart_add_part (body, part);
- g_object_unref (part);
-
- /* Finish creating the message */
- camel_medium_set_content (
- CAMEL_MEDIUM (receipt), CAMEL_DATA_WRAPPER (body));
- g_object_unref (body);
-
- /* Translators: %s is the subject of the email message */
- receipt_subject = g_strdup_printf (
- _("Delivery Notification for: \"%s\""), message_subject);
- camel_mime_message_set_subject (receipt, receipt_subject);
- g_free (receipt_subject);
-
- addr = camel_internet_address_new ();
- camel_address_decode (CAMEL_ADDRESS (addr), self_address);
- camel_mime_message_set_from (receipt, addr);
- g_object_unref (addr);
-
- addr = camel_internet_address_new ();
- camel_address_decode (CAMEL_ADDRESS (addr), receipt_address);
- camel_mime_message_set_recipients (
- receipt, CAMEL_RECIPIENT_TYPE_TO, addr);
- g_object_unref (addr);
-
- transport_uid = g_strconcat (account->uid, "-transport", NULL);
-
- camel_medium_set_header (
- CAMEL_MEDIUM (receipt),
- "Return-Path", "<>");
- camel_medium_set_header (
- CAMEL_MEDIUM (receipt),
- "X-Evolution-Account",
- account->uid);
- camel_medium_set_header (
- CAMEL_MEDIUM (receipt),
- "X-Evolution-Transport",
- transport_uid);
- camel_medium_set_header (
- CAMEL_MEDIUM (receipt),
- "X-Evolution-Fcc",
- account->sent_folder_uri);
-
- g_free (transport_uid);
-
- /* Send the receipt */
- info = camel_message_info_new (NULL);
- out_folder = e_mail_local_get_folder (E_MAIL_LOCAL_FOLDER_OUTBOX);
- camel_message_info_set_flags (
- info, CAMEL_MESSAGE_SEEN, CAMEL_MESSAGE_SEEN);
-
- /* FIXME Pass a GCancellable. */
- e_mail_folder_append_message (
- out_folder, receipt, info, G_PRIORITY_DEFAULT, NULL,
- (GAsyncReadyCallback) em_utils_receipt_done, backend);
-
- camel_message_info_free (info);
-}
-
/* Replying to messages... */
EDestination **