[gnome-games] core: Add Media.get_info() and Media.with_info()



commit 4e21da7ab33e16139dd1b545b3c772e8d688b3d7
Author: Adrien Plazas <kekun plazas laposte net>
Date:   Thu Jun 1 10:36:18 2017 +0200

    core: Add Media.get_info() and Media.with_info()
    
    Allow to attach information to and retrieve it from a Media.
    
    https://bugzilla.gnome.org/show_bug.cgi?id=783319

 src/core/media-info.vala |   28 ----------------------------
 src/core/media.vala      |    7 +++++++
 2 files changed, 7 insertions(+), 28 deletions(-)
---
diff --git a/src/core/media-info.vala b/src/core/media-info.vala
index 3c5ab93..5b8d996 100644
--- a/src/core/media-info.vala
+++ b/src/core/media-info.vala
@@ -12,32 +12,4 @@ public class Games.MediaInfo : Object {
                this.media_id = media_id;
                this.media_index = media_index;
        }
-
-       public static uint game_hash (MediaInfo media_info) {
-               return str_hash (media_info.platform) +
-                      str_hash (media_info.game_id);
-       }
-
-       public static bool game_equal (MediaInfo a, MediaInfo b) {
-               return str_equal (a.platform, b.platform) &
-                      str_equal (a.game_id, b.game_id);
-       }
-
-       public static uint media_hash (MediaInfo media_info) {
-               return str_hash (media_info.platform) +
-                      str_hash (media_info.game_id) +
-                      str_hash (media_info.media_id);
-       }
-
-       public static bool media_equal (MediaInfo a, MediaInfo b) {
-               return str_equal (a.platform, b.platform) &
-                      str_equal (a.game_id, b.game_id) &
-                      str_equal (a.media_id, b.media_id);
-       }
-
-       public string to_string () {
-               return media_id == null ?
-                       @"urn:gnome:Games:$platform:$game_id:" :
-                       @"urn:gnome:Games:$platform:$game_id:$media_id";
-       }
 }
diff --git a/src/core/media.vala b/src/core/media.vala
index 292bf5f..e7dba74 100644
--- a/src/core/media.vala
+++ b/src/core/media.vala
@@ -3,13 +3,20 @@
 public class Games.Media : Object {
        public Title? title { get; private set; }
 
+       private MediaInfo media_info;
        private Uri[] uris;
 
        public Media (Title? title = null) {
+               this.media_info = new MediaInfo ("Dummy", "dummy", null, 0);
                this.title = title;
                this.uris = {};
        }
 
+       public MediaInfo get_media_info () {
+               // FIXME A proper MediaInfo shbould be returned at all time.
+               return media_info ?? new MediaInfo ("Dummy", "dummy", null, 0);
+       }
+
        public Uri[] get_uris () {
                return uris;
        }


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]