[gnome-software] fwupd: Do not use the shared SoupSession
- From: Richard Hughes <rhughes src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-software] fwupd: Do not use the shared SoupSession
- Date: Wed, 20 Dec 2017 11:44:24 +0000 (UTC)
commit b0361d6f510197bfeb32cbb9fc18bb148d5ea8ce
Author: Richard Hughes <richard hughsie com>
Date: Wed Dec 20 11:39:38 2017 +0000
fwupd: Do not use the shared SoupSession
Turning off the content decoder for all plugins isn't the right thing to do.
lib/gs-plugin-loader.c | 2 --
lib/gs-plugin-private.h | 2 --
lib/gs-plugin.c | 4 ++--
lib/gs-plugin.h | 2 ++
plugins/fwupd/gs-plugin-fwupd.c | 10 ++++++++++
5 files changed, 14 insertions(+), 6 deletions(-)
---
diff --git a/lib/gs-plugin-loader.c b/lib/gs-plugin-loader.c
index ece41e1..7247090 100644
--- a/lib/gs-plugin-loader.c
+++ b/lib/gs-plugin-loader.c
@@ -2814,8 +2814,6 @@ gs_plugin_loader_init (GsPluginLoader *plugin_loader)
priv->soup_session = soup_session_new_with_options (SOUP_SESSION_USER_AGENT, gs_user_agent (),
SOUP_SESSION_TIMEOUT, 10,
NULL);
- soup_session_remove_feature_by_type (priv->soup_session,
- SOUP_TYPE_CONTENT_DECODER);
/* get the locale without the various UTF-8 suffixes */
tmp = g_getenv ("GS_SELF_TEST_LOCALE");
diff --git a/lib/gs-plugin-private.h b/lib/gs-plugin-private.h
index 7de3a0d..47b4c5e 100644
--- a/lib/gs-plugin-private.h
+++ b/lib/gs-plugin-private.h
@@ -61,8 +61,6 @@ void gs_plugin_set_profile (GsPlugin *plugin,
AsProfile *profile);
void gs_plugin_set_auth_array (GsPlugin *plugin,
GPtrArray *auth_array);
-void gs_plugin_set_soup_session (GsPlugin *plugin,
- SoupSession *soup_session);
void gs_plugin_set_global_cache (GsPlugin *plugin,
GsAppList *global_cache);
void gs_plugin_set_running_other (GsPlugin *plugin,
diff --git a/lib/gs-plugin.c b/lib/gs-plugin.c
index 9b1fe7a..ec85b8e 100644
--- a/lib/gs-plugin.c
+++ b/lib/gs-plugin.c
@@ -759,7 +759,7 @@ gs_plugin_set_profile (GsPlugin *plugin, AsProfile *profile)
* gs_plugin_get_soup_session:
* @plugin: a #GsPlugin
*
- * Gets the soup session that plugins can use when downloading.
+ * Gets the soup session that this plugin can use when downloading.
*
* Returns: the #SoupSession
*
@@ -777,7 +777,7 @@ gs_plugin_get_soup_session (GsPlugin *plugin)
* @plugin: a #GsPlugin
* @soup_session: a #SoupSession
*
- * Sets the soup session that plugins will use when downloading.
+ * Sets the soup session that this plugin will use when downloading.
*
* Since: 3.22
**/
diff --git a/lib/gs-plugin.h b/lib/gs-plugin.h
index fe10aa1..00fe5da 100644
--- a/lib/gs-plugin.h
+++ b/lib/gs-plugin.h
@@ -85,6 +85,8 @@ const gchar *gs_plugin_get_locale (GsPlugin *plugin);
const gchar *gs_plugin_get_language (GsPlugin *plugin);
AsProfile *gs_plugin_get_profile (GsPlugin *plugin);
SoupSession *gs_plugin_get_soup_session (GsPlugin *plugin);
+void gs_plugin_set_soup_session (GsPlugin *plugin,
+ SoupSession *soup_session);
void gs_plugin_add_auth (GsPlugin *plugin,
GsAuth *auth);
GsAuth *gs_plugin_get_auth_by_id (GsPlugin *plugin,
diff --git a/plugins/fwupd/gs-plugin-fwupd.c b/plugins/fwupd/gs-plugin-fwupd.c
index 426d45e..08e2aa0 100644
--- a/plugins/fwupd/gs-plugin-fwupd.c
+++ b/plugins/fwupd/gs-plugin-fwupd.c
@@ -102,6 +102,8 @@ void
gs_plugin_initialize (GsPlugin *plugin)
{
GsPluginData *priv = gs_plugin_alloc_data (plugin, sizeof(GsPluginData));
+ g_autoptr(SoupSession) soup_session = NULL;
+
priv->client = fwupd_client_new ();
priv->to_download = g_ptr_array_new_with_free_func (g_free);
priv->to_ignore = g_ptr_array_new_with_free_func (g_free);
@@ -120,6 +122,14 @@ gs_plugin_initialize (GsPlugin *plugin)
}
#endif
+ /* use a custom session with the content decoder turned off */
+ soup_session = soup_session_new_with_options (SOUP_SESSION_USER_AGENT, gs_user_agent (),
+ SOUP_SESSION_TIMEOUT, 10,
+ NULL);
+ soup_session_remove_feature_by_type (soup_session,
+ SOUP_TYPE_CONTENT_DECODER);
+ gs_plugin_set_soup_session (plugin, soup_session);
+
/* set name of MetaInfo file */
gs_plugin_set_appstream_id (plugin, "org.gnome.Software.Plugin.Fwupd");
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]