[gnome-software/wip/rancell/reviews: 14/14] Use shared SoupSession
- From: Robert Ancell <rancell src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-software/wip/rancell/reviews: 14/14] Use shared SoupSession
- Date: Sun, 14 Feb 2016 05:06:54 +0000 (UTC)
commit afc89ff8aafa754b06be2071ecdcf267e1827936
Author: Robert Ancell <robert ancell canonical com>
Date: Sun Feb 14 18:06:34 2016 +1300
Use shared SoupSession
src/plugins/gs-plugin-ubuntu-reviews.c | 32 +-------------------------------
1 files changed, 1 insertions(+), 31 deletions(-)
---
diff --git a/src/plugins/gs-plugin-ubuntu-reviews.c b/src/plugins/gs-plugin-ubuntu-reviews.c
index 16809b0..482f853 100644
--- a/src/plugins/gs-plugin-ubuntu-reviews.c
+++ b/src/plugins/gs-plugin-ubuntu-reviews.c
@@ -38,7 +38,6 @@ struct GsPluginPrivate {
gchar *db_path;
sqlite3 *db;
gsize db_loaded;
- SoupSession *session;
gchar *consumer_key;
gchar *consumer_secret;
gchar *token_key;
@@ -101,29 +100,6 @@ gs_plugin_destroy (GsPlugin *plugin)
g_clear_pointer (&priv->consumer_secret, g_free);
g_clear_pointer (&priv->consumer_key, g_free);
g_clear_pointer (&priv->db, sqlite3_close);
- g_clear_object (&priv->session);
-}
-
-static gboolean
-setup_networking (GsPlugin *plugin, GError **error)
-{
- /* already set up */
- if (plugin->priv->session != NULL)
- return TRUE;
-
- /* set up a session */
- plugin->priv->session = soup_session_new_with_options (SOUP_SESSION_USER_AGENT,
- gs_user_agent (),
- NULL);
- if (plugin->priv->session == NULL) {
- g_set_error (error,
- GS_PLUGIN_ERROR,
- GS_PLUGIN_ERROR_FAILED,
- "%s: failed to setup networking",
- plugin->name);
- return FALSE;
- }
- return TRUE;
}
static gint
@@ -359,9 +335,6 @@ send_review_request (GsPlugin *plugin, const gchar *method, const gchar *path, J
g_autoptr(SoupMessage) msg = NULL;
guint status_code;
- if (!setup_networking (plugin, error))
- return FALSE;
-
uri = g_strdup_printf ("%s%s",
UBUNTU_REVIEWS_SERVER, path);
msg = soup_message_new (method, uri);
@@ -386,7 +359,7 @@ send_review_request (GsPlugin *plugin, const gchar *method, const gchar *path, J
priv->token_key,
priv->token_secret);
- status_code = soup_session_send_message (plugin->priv->session, msg);
+ status_code = soup_session_send_message (plugin->soup_session, msg);
if (status_code != SOUP_STATUS_OK) {
g_set_error (error,
GS_PLUGIN_ERROR,
@@ -966,9 +939,6 @@ gs_plugin_review_submit (GsPlugin *plugin,
return FALSE;
}
- if (!setup_networking (plugin, error))
- return FALSE;
-
if (!sign_into_ubuntu (plugin, error))
return FALSE;
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]