[recipes/image-download: 8/10] Add api to get a soup session
- From: Matthias Clasen <matthiasc src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [recipes/image-download: 8/10] Add api to get a soup session
- Date: Mon, 6 Mar 2017 00:34:21 +0000 (UTC)
commit 45686be236f0716891b34aa446599df9cf12952b
Author: Matthias Clasen <mclasen redhat com>
Date: Sun Mar 5 18:20:06 2017 -0500
Add api to get a soup session
We want to keep a single, global soup session.
src/gr-app.c | 18 +++++++++++++++---
src/gr-app.h | 4 +++-
2 files changed, 18 insertions(+), 4 deletions(-)
---
diff --git a/src/gr-app.c b/src/gr-app.c
index 25392a1..43f8ca9 100644
--- a/src/gr-app.c
+++ b/src/gr-app.c
@@ -41,6 +41,7 @@ struct _GrApp
GtkApplication parent_instance;
GrRecipeStore *store;
+ SoupSession *session;
GrShellSearchProvider *search_provider;
GrRecipeExporter *exporter;
@@ -55,6 +56,7 @@ gr_app_finalize (GObject *object)
{
GrApp *self = GR_APP (object);
+ g_clear_object (&self->session);
g_clear_object (&self->store);
g_clear_object (&self->search_provider);
g_clear_object (&self->css_provider);
@@ -387,7 +389,7 @@ gr_app_dbus_register (GApplication *application,
GrApp *app = GR_APP (application);
app->search_provider = gr_shell_search_provider_new ();
- gr_shell_search_provider_setup (app->search_provider, app->store);
+ gr_shell_search_provider_setup (app->search_provider, gr_app_get_recipe_store (app));
return gr_shell_search_provider_register (app->search_provider, connection, error);
}
@@ -419,8 +421,9 @@ gr_app_init (GrApp *self)
g_log_set_writer_func (log_writer, NULL, NULL);
- self->store = gr_recipe_store_new ();
-
+ self->session = soup_session_new_with_options (SOUP_SESSION_USER_AGENT,
+ PACKAGE_NAME "/" PACKAGE_VERSION,
+ NULL);
}
static int
@@ -478,5 +481,14 @@ gr_app_new (void)
GrRecipeStore *
gr_app_get_recipe_store (GrApp *app)
{
+ if (!app->store)
+ app->store = gr_recipe_store_new ();
+
return app->store;
}
+
+SoupSession *
+gr_app_get_soup_session (GrApp *app)
+{
+ return app->session;
+}
diff --git a/src/gr-app.h b/src/gr-app.h
index 6db6956..e4d9ad3 100644
--- a/src/gr-app.h
+++ b/src/gr-app.h
@@ -15,10 +15,11 @@
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
-
+
#pragma once
#include <gtk/gtk.h>
+#include <libsoup/soup.h>
#include "gr-recipe-store.h"
G_BEGIN_DECLS
@@ -29,5 +30,6 @@ G_DECLARE_FINAL_TYPE (GrApp, gr_app, GR, APP, GtkApplication)
GrApp *gr_app_new (void);
GrRecipeStore *gr_app_get_recipe_store (GrApp *app);
+SoupSession *gr_app_get_soup_session (GrApp *app);
G_END_DECLS
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]