[gnome-software] Use libsoup with g_autoptr



commit fbe45050619aed3861dd5af0ac31c0080d7661cc
Author: Kalev Lember <klember redhat com>
Date:   Wed Sep 9 16:13:54 2015 +0200

    Use libsoup with g_autoptr
    
    ... and bump its dep to 2.51.92 for the cleanup macro support.

 configure.ac                                  |    2 +-
 src/gs-cleanup.h                              |   10 ----------
 src/plugins/gs-plugin-fedora-tagger-ratings.c |    4 ++--
 src/plugins/gs-plugin-fedora-tagger-usage.c   |    3 +--
 src/plugins/gs-plugin-fwupd.c                 |    8 +++-----
 src/plugins/gs-plugin-icons.c                 |    3 +--
 6 files changed, 8 insertions(+), 22 deletions(-)
---
diff --git a/configure.ac b/configure.ac
index 9c5f270..b44a96f 100644
--- a/configure.ac
+++ b/configure.ac
@@ -63,7 +63,7 @@ PKG_CHECK_MODULES(GTK, gtk+-3.0 >= 3.17.7 gio-unix-2.0)
 PKG_CHECK_MODULES(PACKAGEKIT, packagekit-glib2 >= 1.0.9)
 PKG_CHECK_MODULES(APPSTREAM, appstream-glib >= 0.5.1)
 PKG_CHECK_MODULES(SQLITE, sqlite3)
-PKG_CHECK_MODULES(SOUP, libsoup-2.4 >= 2.42)
+PKG_CHECK_MODULES(SOUP, libsoup-2.4 >= 2.51.92)
 PKG_CHECK_MODULES(GSETTINGS_DESKTOP_SCHEMAS, gsettings-desktop-schemas >= 3.11.5)
 PKG_CHECK_MODULES(GNOME_DESKTOP, gnome-desktop-3.0 >= 3.17.92)
 PKG_CHECK_MODULES(POLKIT, polkit-gobject-1)
diff --git a/src/gs-cleanup.h b/src/gs-cleanup.h
index 186dea4..94dac41 100644
--- a/src/gs-cleanup.h
+++ b/src/gs-cleanup.h
@@ -33,13 +33,6 @@ G_BEGIN_DECLS
     func (*(Type*)v); \
   }
 
-#define GS_DEFINE_CLEANUP_FUNCTION0(Type, name, func) \
-  static inline void name (void *v) \
-  { \
-    if (*(Type*)v) \
-      func (*(Type*)v); \
-  }
-
 #define GS_DEFINE_CLEANUP_FUNCTIONt(Type, name, func) \
   static inline void name (void *v) \
   { \
@@ -47,15 +40,12 @@ G_BEGIN_DECLS
       func (*(Type*)v, TRUE); \
   }
 
-GS_DEFINE_CLEANUP_FUNCTION0(GObject*, gs_local_obj_unref, g_object_unref)
-
 GS_DEFINE_CLEANUP_FUNCTIONt(GString*, gs_local_free_string, g_string_free)
 
 GS_DEFINE_CLEANUP_FUNCTION(GList*, gs_local_free_plugin_list, gs_plugin_list_free)
 
 #define _cleanup_plugin_list_free_ __attribute__ ((cleanup(gs_local_free_plugin_list)))
 #define _cleanup_string_free_ __attribute__ ((cleanup(gs_local_free_string)))
-#define _cleanup_object_unref_ __attribute__ ((cleanup(gs_local_obj_unref)))
 
 G_END_DECLS
 
diff --git a/src/plugins/gs-plugin-fedora-tagger-ratings.c b/src/plugins/gs-plugin-fedora-tagger-ratings.c
index 8786d20..9c9dff8 100644
--- a/src/plugins/gs-plugin-fedora-tagger-ratings.c
+++ b/src/plugins/gs-plugin-fedora-tagger-ratings.c
@@ -187,7 +187,7 @@ gs_plugin_app_set_rating_pkg (GsPlugin *plugin,
        g_autofree gchar *data = NULL;
        g_autofree gchar *error_msg = NULL;
        g_autofree gchar *uri = NULL;
-       _cleanup_object_unref_ SoupMessage *msg = NULL;
+       g_autoptr(SoupMessage) msg = NULL;
 
        /* create the PUT data */
        uri = g_strdup_printf ("%s/api/v1/rating/%s/",
@@ -355,7 +355,7 @@ gs_plugin_fedora_tagger_download (GsPlugin *plugin, GError **error)
        guint i;
        guint status_code;
        g_autofree gchar *uri = NULL;
-       _cleanup_object_unref_ SoupMessage *msg = NULL;
+       g_autoptr(SoupMessage) msg = NULL;
        g_autoptr(GPtrArray) items = NULL;
        g_auto(GStrv) split = NULL;
 
diff --git a/src/plugins/gs-plugin-fedora-tagger-usage.c b/src/plugins/gs-plugin-fedora-tagger-usage.c
index dc103aa..ddad2bd 100644
--- a/src/plugins/gs-plugin-fedora-tagger-usage.c
+++ b/src/plugins/gs-plugin-fedora-tagger-usage.c
@@ -26,7 +26,6 @@
 #include <sqlite3.h>
 #include <stdlib.h>
 
-#include "gs-cleanup.h"
 #include <gs-plugin.h>
 #include <gs-utils.h>
 
@@ -131,7 +130,7 @@ gs_plugin_app_set_usage_pkg (GsPlugin *plugin,
        guint status_code;
        g_autofree gchar *data = NULL;
        g_autofree gchar *uri = NULL;
-       _cleanup_object_unref_ SoupMessage *msg = NULL;
+       g_autoptr(SoupMessage) msg = NULL;
 
        /* create the PUT data */
        uri = g_strdup_printf ("%s/api/v1/usage/%s/",
diff --git a/src/plugins/gs-plugin-fwupd.c b/src/plugins/gs-plugin-fwupd.c
index 42e1d8b..e871ef6 100644
--- a/src/plugins/gs-plugin-fwupd.c
+++ b/src/plugins/gs-plugin-fwupd.c
@@ -31,8 +31,6 @@
 
 #include <gs-plugin.h>
 
-#include "gs-cleanup.h"
-
 struct GsPluginPrivate {
        gsize                    done_init;
        GDBusProxy              *proxy;
@@ -634,8 +632,8 @@ gs_plugin_fwupd_check_lvfs_metadata (GsPlugin *plugin,
        g_autofree gchar *url_data = NULL;
        g_autofree gchar *url_sig = NULL;
        g_autoptr(GKeyFile) config = NULL;
-       _cleanup_object_unref_ SoupMessage *msg_data = NULL;
-       _cleanup_object_unref_ SoupMessage *msg_sig = NULL;
+       g_autoptr(SoupMessage) msg_data = NULL;
+       g_autoptr(SoupMessage) msg_sig = NULL;
 
        /* read config file */
        config = g_key_file_new ();
@@ -759,7 +757,7 @@ gs_plugin_refresh (GsPlugin *plugin,
                g_autoptr(GError) error_local = NULL;
                g_autofree gchar *basename = NULL;
                g_autofree gchar *filename_cache = NULL;
-               _cleanup_object_unref_ SoupMessage *msg = NULL;
+               g_autoptr(SoupMessage) msg = NULL;
 
                tmp = g_ptr_array_index (plugin->priv->to_download, i);
                basename = g_path_get_basename (tmp);
diff --git a/src/plugins/gs-plugin-icons.c b/src/plugins/gs-plugin-icons.c
index 46de16d..23dc046 100644
--- a/src/plugins/gs-plugin-icons.c
+++ b/src/plugins/gs-plugin-icons.c
@@ -27,7 +27,6 @@
 #include <glib/gi18n.h>
 #include <libsoup/soup.h>
 
-#include "gs-cleanup.h"
 #include <gs-plugin.h>
 #include <gs-utils.h>
 
@@ -112,7 +111,7 @@ gs_plugin_icons_download (GsPlugin *plugin, const gchar *uri, const gchar *filen
        g_autoptr(GdkPixbuf) pixbuf_new = NULL;
        g_autoptr(GdkPixbuf) pixbuf = NULL;
        g_autoptr(GInputStream) stream = NULL;
-       _cleanup_object_unref_ SoupMessage *msg = NULL;
+       g_autoptr(SoupMessage) msg = NULL;
 
        /* create the GET data */
        msg = soup_message_new (SOUP_METHOD_GET, uri);


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