[gnome-games] Use libsoup instead of gvfs to download the covers
- From: Mathieu Bridon <mbridon src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-games] Use libsoup instead of gvfs to download the covers
- Date: Sat, 13 Aug 2016 12:29:03 +0000 (UTC)
commit e82e08eb1c0297d52e80b02275612b6c9584acae
Author: Mathieu Bridon <bochecha daitauha fr>
Date: Fri Aug 12 23:32:39 2016 +0200
Use libsoup instead of gvfs to download the covers
gvfs doesn't work very well in flatpak.
https://bugzilla.gnome.org/show_bug.cgi?id=769829
configure.ac | 1 +
src/Makefile.am | 1 +
src/grilo/grilo-cover.vala | 20 ++++++++++----------
3 files changed, 12 insertions(+), 10 deletions(-)
---
diff --git a/configure.ac b/configure.ac
index b31d0f4..d3c4c2e 100644
--- a/configure.ac
+++ b/configure.ac
@@ -52,6 +52,7 @@ PKG_CHECK_MODULES(GNOME_GAMES, [
glib-2.0 >= $GLIB_MIN_VERSION
grilo-0.3
gtk+-3.0
+ libsoup-2.4
retro-gobject-0.6
retro-gtk-0.6
tracker-sparql-1.0
diff --git a/src/Makefile.am b/src/Makefile.am
index 2bf0703..625455b 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -139,6 +139,7 @@ gnome_games_VALAFLAGS = \
--pkg glib-2.0 \
--pkg grilo-0.3 \
--pkg gtk+-3.0 \
+ --pkg libsoup-2.4 \
--pkg tracker-sparql-1.0 \
--pkg retro-gobject-0.6 \
--pkg retro-gtk-0.6 \
diff --git a/src/grilo/grilo-cover.vala b/src/grilo/grilo-cover.vala
index ab92442..1023104 100644
--- a/src/grilo/grilo-cover.vala
+++ b/src/grilo/grilo-cover.vala
@@ -60,19 +60,19 @@ public class Games.GriloCover : Object, Cover {
var cover_path = get_cover_path ();
- var src = File.new_for_uri (uri);
- var dst = File.new_for_path (cover_path);
+ var session = new Soup.Session ();
+ var message = new Soup.Message ("GET", uri);
- try {
- yield src.copy_async (dst, FileCopyFlags.OVERWRITE);
- }
- catch (Error e) {
- warning (e.message);
+ session.queue_message (message, (sess, mess) => {
+ if (mess.status_code != 200) {
+ debug ("Failed to load %s: %u %s.", uri, mess.status_code,
mess.reason_phrase);
- return;
- }
+ return;
+ }
- load_cover ();
+ FileUtils.set_data (cover_path, mess.response_body.data);
+ load_cover ();
+ });
}
private void load_cover () {
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]