[evolution/wip-webkit2] Move functions that are returning selection or web view content to return const gchar



commit 8597417da1df6ba8b2a67fbd5ed99baa59018e9a
Author: Tomas Popela <tpopela redhat com>
Date:   Tue Oct 29 14:05:52 2013 +0100

    Move functions that are returning selection or web view content to return const gchar

 e-util/e-web-view.c        |   28 ++++++++++++++--------------
 e-util/e-web-view.h        |    8 ++++----
 mail/e-mail-reader-utils.c |    6 ++----
 3 files changed, 20 insertions(+), 22 deletions(-)
---
diff --git a/e-util/e-web-view.c b/e-util/e-web-view.c
index 9131796..0382f40 100644
--- a/e-util/e-web-view.c
+++ b/e-util/e-web-view.c
@@ -2152,15 +2152,15 @@ get_document_content_html_cb (GDBusProxy *web_extension,
                              GTask *task)
 {
        GVariant *result_variant;
-       gchar *html_content;
+       const gchar *html_content;
 
        result_variant = g_dbus_proxy_call_finish (web_extension, result, NULL);
        if (result_variant) {
-               g_variant_get (result_variant, "(s)", &html_content);
+               html_content = g_variant_get_string (result_variant, NULL);
                g_variant_unref (result_variant);
        }
 
-       g_task_return_pointer (task, html_content, g_free);
+       g_task_return_pointer (task, g_strdup (html_content), g_free);
        g_object_unref (task);
 }
 
@@ -2195,7 +2195,7 @@ e_web_view_get_content_html (EWebView *web_view,
                g_task_return_pointer (task, NULL, NULL);
 }
 
-gchar *
+const gchar *
 e_web_view_get_content_html_finish (EWebView *web_view,
                                     GAsyncResult *result,
                                     GError **error)
@@ -2206,7 +2206,7 @@ e_web_view_get_content_html_finish (EWebView *web_view,
        return g_task_propagate_pointer (G_TASK (result), error);
 }
 
-gchar *
+const gchar *
 e_web_view_get_content_html_sync (EWebView *web_view,
                                   GCancellable *cancellable,
                                   GError **error)
@@ -2218,7 +2218,7 @@ e_web_view_get_content_html_sync (EWebView *web_view,
        web_extension = e_web_view_get_web_extension_proxy (web_view);
        if (web_extension) {
                GVariant *result;
-               gchar *html_content = NULL;
+               const gchar *html_content = NULL;
 
                result = g_dbus_proxy_call_sync (
                                web_extension,
@@ -2233,7 +2233,7 @@ e_web_view_get_content_html_sync (EWebView *web_view,
                                error);
 
                if (result) {
-                       g_variant_get (result, "(s)", &html_content);
+                       html_content = g_variant_get_string (result, NULL);
                        g_variant_unref (result);
                        return html_content;
                }
@@ -2872,15 +2872,15 @@ get_selection_content_html_cb (GDBusProxy *web_extension,
                                GTask *task)
 {
        GVariant *result_variant;
-       gchar *html_content;
+       const gchar *html_content;
 
        result_variant = g_dbus_proxy_call_finish (web_extension, result, NULL);
        if (result_variant) {
-               g_variant_get (result_variant, "(s)", &html_content);
+               html_content = g_variant_get_string (result_variant, NULL);
                g_variant_unref (result_variant);
        }
 
-       g_task_return_pointer (task, html_content, g_free);
+       g_task_return_pointer (task, g_strdup (html_content), g_free);
        g_object_unref (task);
 }
 
@@ -2918,7 +2918,7 @@ e_web_view_get_selection_content_html (EWebView *web_view,
                g_task_return_pointer (task, NULL, NULL);
 }
 
-gchar *
+const gchar *
 e_web_view_get_selection_content_html_finish (EWebView *web_view,
                                               GAsyncResult *result,
                                               GError **error)
@@ -2929,7 +2929,7 @@ e_web_view_get_selection_content_html_finish (EWebView *web_view,
        return g_task_propagate_pointer (G_TASK (result), error);
 }
 
-gchar *
+const gchar *
 e_web_view_get_selection_content_html_sync (EWebView *web_view,
                                             GCancellable *cancellable,
                                             GError **error)
@@ -2944,7 +2944,7 @@ e_web_view_get_selection_content_html_sync (EWebView *web_view,
        web_extension = e_web_view_get_web_extension_proxy (web_view);
        if (web_extension) {
                GVariant *result;
-               gchar *html_content = NULL;
+               const gchar *html_content = NULL;
 
                result = g_dbus_proxy_call_sync (
                                web_extension,
@@ -2959,7 +2959,7 @@ e_web_view_get_selection_content_html_sync (EWebView *web_view,
                                error);
 
                if (result) {
-                       g_variant_get (result, "(s)", &html_content);
+                       html_content = g_variant_get_string (result, NULL);
                        g_variant_unref (result);
                        return html_content;
                }
diff --git a/e-util/e-web-view.h b/e-util/e-web-view.h
index c275bc9..9fb2e42 100644
--- a/e-util/e-web-view.h
+++ b/e-util/e-web-view.h
@@ -127,11 +127,11 @@ void              e_web_view_get_content_html     (EWebView *web_view,
                                                 GCancellable *cancellable,
                                                 GAsyncReadyCallback callback,
                                                 gpointer user_data);
-gchar *                e_web_view_get_content_html_finish
+const gchar *  e_web_view_get_content_html_finish
                                                (EWebView *web_view,
                                                 GAsyncResult *result,
                                                 GError **error);
-gchar *                e_web_view_get_content_html_sync
+const gchar *  e_web_view_get_content_html_sync
                                                (EWebView *web_view,
                                                 GCancellable *cancellable,
                                                 GError **error);
@@ -210,11 +210,11 @@ void              e_web_view_get_selection_content_html
                                                 GCancellable *cancellable,
                                                 GAsyncReadyCallback callback,
                                                 gpointer user_data);
-gchar *                e_web_view_get_selection_content_html_finish
+const gchar *  e_web_view_get_selection_content_html_finish
                                                (EWebView *web_view,
                                                 GAsyncResult *result,
                                                 GError **error);
-gchar *                e_web_view_get_selection_content_html_sync
+const gchar *  e_web_view_get_selection_content_html_sync
                                                (EWebView *web_view,
                                                 GCancellable *cancellable,
                                                 GError **error);
diff --git a/mail/e-mail-reader-utils.c b/mail/e-mail-reader-utils.c
index 512af51..170404c 100644
--- a/mail/e-mail-reader-utils.c
+++ b/mail/e-mail-reader-utils.c
@@ -1747,7 +1747,7 @@ e_mail_reader_reply_to_message (EMailReader *reader,
        EWebView *web_view;
        struct _camel_header_raw *header;
        const gchar *uid;
-       gchar *selection = NULL;
+       const gchar *selection;
        gint length;
        gchar *mail_uri;
        CamelObjectBag *registry;
@@ -1848,7 +1848,7 @@ e_mail_reader_reply_to_message (EMailReader *reader,
        if (!e_web_view_is_selection_active (web_view))
                goto whole_message;
 
-       selection = e_web_view_get_selection_html (web_view);
+       selection = e_web_view_get_selection_content_html_sync (web_view, NULL, NULL);
        if (selection == NULL || *selection == '\0')
                goto whole_message;
 
@@ -1912,8 +1912,6 @@ e_mail_reader_reply_to_message (EMailReader *reader,
 
        g_object_unref (new_message);
 
-       g_free (selection);
-
        goto exit;
 
 whole_message:


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]