[gnome-games] core: Add MediaInfo
- From: Adrien Plazas <aplazas src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-games] core: Add MediaInfo
- Date: Thu, 1 Jun 2017 15:11:56 +0000 (UTC)
commit 2b8e749f650d7694fb220744604b3bd8eb987411
Author: Adrien Plazas <kekun plazas laposte net>
Date: Wed May 31 14:57:12 2017 +0200
core: Add MediaInfo
This will be used to extract information on a game media from an URI.
https://bugzilla.gnome.org/show_bug.cgi?id=783319
src/Makefile.am | 1 +
src/core/media-info.vala | 43 +++++++++++++++++++++++++++++++++++++++++++
2 files changed, 44 insertions(+), 0 deletions(-)
---
diff --git a/src/Makefile.am b/src/Makefile.am
index d769481..a49476d 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -49,6 +49,7 @@ gnome_games_SOURCES = \
core/icon.vala \
core/input-capabilities.vala \
core/media.vala \
+ core/media-info.vala \
core/media-set/media-set.vala \
core/media-set/media-set-error.vala \
core/plugin.vala \
diff --git a/src/core/media-info.vala b/src/core/media-info.vala
new file mode 100644
index 0000000..3c5ab93
--- /dev/null
+++ b/src/core/media-info.vala
@@ -0,0 +1,43 @@
+// This file is part of GNOME Games. License: GPL-3.0+.
+
+public class Games.MediaInfo : Object {
+ public string platform { get; private set; }
+ public string game_id { get; private set; }
+ public string? media_id { get; private set; }
+ public uint media_index { get; private set; }
+
+ public MediaInfo (string platform, string game_id, string? media_id, uint media_index) {
+ this.platform = platform;
+ this.game_id = game_id;
+ 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";
+ }
+}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]