[recipes] Use the OpenURI portal for sending email
- From: Matthias Clasen <matthiasc src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [recipes] Use the OpenURI portal for sending email
- Date: Mon, 13 Feb 2017 11:14:22 +0000 (UTC)
commit dea7aa28a4dc364023b4de7400f68e7c5fd3bb2a
Author: Matthias Clasen <mclasen redhat com>
Date: Mon Feb 13 06:11:55 2017 -0500
Use the OpenURI portal for sending email
This is much simpler than using HostCommand, or adding a
dedicated email sending portal.
Thanks to Alexander Larsson for the idea.
src/gr-mail.c | 39 +++++++--------------------------------
src/gr-mail.h | 2 +-
src/gr-recipe-exporter.c | 7 +++----
3 files changed, 11 insertions(+), 37 deletions(-)
---
diff --git a/src/gr-mail.c b/src/gr-mail.c
index 3fea9ef..1a0dc6e 100644
--- a/src/gr-mail.c
+++ b/src/gr-mail.c
@@ -26,16 +26,13 @@ gboolean
gr_send_mail (const char *address,
const char *subject,
const char *body,
- GList *attachments,
+ const char **attachments,
GError **error)
{
g_autoptr(GString) url = NULL;
- GList *l;
g_autofree char *encoded_subject = NULL;
g_autofree char *encoded_body = NULL;
- const char *argv[4];
- g_autoptr(GDBusConnection) bus = NULL;
- g_autoptr(GVariant) result = NULL;
+ int i;
encoded_subject = g_uri_escape_string (subject ? subject : "", NULL, FALSE);
encoded_body = g_uri_escape_string (body ? body : "", NULL, FALSE);
@@ -46,34 +43,12 @@ gr_send_mail (const char *address,
g_string_append_printf (url, "?subject=%s", encoded_subject);
g_string_append_printf (url, "&body=%s", encoded_body);
- for (l = attachments; l; l = l->next) {
- g_autofree char *path = g_uri_escape_string (l->data, NULL, FALSE);
+ for (i = 0; attachments[i]; i++) {
+ g_autofree char *path = NULL;
+
+ path = g_uri_escape_string (attachments[i], NULL, FALSE);
g_string_append_printf (url, "&attach=%s", path);
}
- argv[0] = "/usr/bin/evolution";
- argv[1] = "--component=mail";
- argv[2] = url->str;
- argv[3] = NULL;
-
- bus = g_bus_get_sync (G_BUS_TYPE_SESSION, NULL, NULL);
-
- result = g_dbus_connection_call_sync (bus,
- "org.freedesktop.Flatpak",
- "/org/freedesktop/Flatpak/Development",
- "org.freedesktop.Flatpak.Development",
- "HostCommand",
- g_variant_new ("(^ay^aay@a{uh}@a{ss}u)",
- g_get_home_dir (),
- argv,
- g_variant_new_array (G_VARIANT_TYPE ("{uh}"), NULL, 0),
- g_variant_new_array (G_VARIANT_TYPE ("{ss}"), NULL, 0),
- 0),
- G_VARIANT_TYPE ("(u)"),
- 0,
- G_MAXINT,
- NULL,
- error);
-
- return result != NULL;
+ return g_app_info_launch_default_for_uri (url->str, NULL, error);
}
diff --git a/src/gr-mail.h b/src/gr-mail.h
index de66eac..81c8afa 100644
--- a/src/gr-mail.h
+++ b/src/gr-mail.h
@@ -27,7 +27,7 @@ G_BEGIN_DECLS
gboolean gr_send_mail (const char *address,
const char *subject,
const char *body,
- GList *attachments,
+ const char **attachments,
GError **error);
G_END_DECLS
diff --git a/src/gr-recipe-exporter.c b/src/gr-recipe-exporter.c
index 35995f4..f8be949 100644
--- a/src/gr-recipe-exporter.c
+++ b/src/gr-recipe-exporter.c
@@ -134,7 +134,7 @@ completed_cb (AutoarCompressor *compressor,
const char *address;
const char *subject;
g_autofree char *body = NULL;
- GList *attachments;
+ const char *attachments[2];
if (exporter->contribute) {
address = "recipes-list gnome org";
@@ -172,7 +172,8 @@ completed_cb (AutoarCompressor *compressor,
path = g_file_get_path (exporter->dest);
- attachments = g_list_append (NULL, path);
+ attachments[0] = path;
+ attachments[1] = NULL;
if (!gr_send_mail (address, subject, body, attachments, &error)) {
GtkWidget *error_dialog;
@@ -194,8 +195,6 @@ completed_cb (AutoarCompressor *compressor,
gtk_widget_show (error_dialog);
}
- g_list_free (attachments);
-
cleanup_export (exporter);
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]