[gnome-games] steam: Fetch covers using libsoup
- From: Adrien Plazas <aplazas src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-games] steam: Fetch covers using libsoup
- Date: Sat, 11 Aug 2018 01:06:30 +0000 (UTC)
commit 22db3779a6cbfe8a3c98aed51ed3aaef5848ecee
Author: Alexander Mikhaylenko <exalm7659 gmail com>
Date: Sat Aug 11 02:43:25 2018 +0500
steam: Fetch covers using libsoup
Fixes covers in Flatpak.
plugins/steam/src/steam-cover.vala | 30 +++++++++++++++++-------------
src/meson.build | 1 +
2 files changed, 18 insertions(+), 13 deletions(-)
---
diff --git a/plugins/steam/src/steam-cover.vala b/plugins/steam/src/steam-cover.vala
index 85ead93f..517db2a8 100644
--- a/plugins/steam/src/steam-cover.vala
+++ b/plugins/steam/src/steam-cover.vala
@@ -41,19 +41,23 @@ public class Games.SteamCover : Object, Cover {
var cover_path = get_cover_path ();
- var src = File.new_for_uri (uri);
- var dst = File.new_for_path (cover_path);
-
- try {
- yield src.copy_async (dst, FileCopyFlags.OVERWRITE);
- }
- catch (Error e) {
- warning (e.message);
-
- return;
- }
-
- load_cover ();
+ var session = new Soup.Session ();
+ var message = new Soup.Message ("GET", uri);
+
+ session.queue_message (message, (sess, mess) => {
+ if (mess.status_code != Soup.Status.OK) {
+ debug ("Failed to load %s: %u %s.", uri, mess.status_code,
mess.reason_phrase);
+
+ return;
+ }
+
+ try {
+ FileUtils.set_data (cover_path, mess.response_body.data);
+ load_cover ();
+ } catch (Error e) {
+ warning (e.message);
+ }
+ });
}
private void load_cover () {
diff --git a/src/meson.build b/src/meson.build
index 95e869e0..3633d1ca 100644
--- a/src/meson.build
+++ b/src/meson.build
@@ -224,6 +224,7 @@ plugin_dependencies = [
glib_dep,
gtk_dep,
retro_gtk_dep,
+ soup_dep,
tracker_sparql_dep,
]
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]