[gnome-games] platform: Add get_uid_prefix ()
- From: Alexander Mikhaylenko <alexm src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-games] platform: Add get_uid_prefix ()
- Date: Fri, 9 Aug 2019 13:38:28 +0000 (UTC)
commit 26937ccc91eda2a259f7ebf78eded4b486dc7b71
Author: Yetizone <andreii lisita gmail com>
Date: Sun Jun 9 09:51:48 2019 +0300
platform: Add get_uid_prefix ()
plugins/desktop/src/desktop-plugin.vala | 3 ++-
plugins/dreamcast/src/dreamcast-plugin.vala | 3 ++-
plugins/game-cube/src/game-cube-plugin.vala | 3 ++-
plugins/libretro/src/libretro-plugin.vala | 3 ++-
plugins/love/src/love-plugin.vala | 6 +++---
plugins/ms-dos/src/ms-dos-plugin.vala | 6 +++---
plugins/nintendo-ds/src/nintendo-ds-plugin.vala | 6 +++---
plugins/playstation/src/playstation-plugin.vala | 3 ++-
plugins/sega-cd/src/sega-cd-plugin.vala | 9 +++++----
plugins/sega-saturn/src/sega-saturn-plugin.vala | 3 ++-
plugins/steam/src/steam-plugin.vala | 3 ++-
plugins/turbografx-cd/src/turbografx-cd-plugin.vala | 6 +++---
plugins/virtual-boy/src/virtual-boy-plugin.vala | 6 +++---
plugins/wii/src/wii-plugin.vala | 3 ++-
src/core/platform.vala | 2 ++
src/dummy/dummy-platform.vala | 4 ++++
src/generic/generic-platform.vala | 8 +++++++-
src/retro/retro-platform.vala | 8 +++++++-
src/ui/application.vala | 2 +-
19 files changed, 57 insertions(+), 30 deletions(-)
---
diff --git a/plugins/desktop/src/desktop-plugin.vala b/plugins/desktop/src/desktop-plugin.vala
index e7967f5d..1b03dcd4 100644
--- a/plugins/desktop/src/desktop-plugin.vala
+++ b/plugins/desktop/src/desktop-plugin.vala
@@ -4,11 +4,12 @@ private class Games.DesktopPlugin : Object, Plugin {
private const string MIME_TYPE = "application/x-desktop";
private const string PLATFORM_ID = "Desktop";
private const string PLATFORM_NAME = _("Desktop");
+ private const string PLATFORM_UID_PREFIX = "desktop";
private static Platform platform;
static construct {
- platform = new GenericPlatform (PLATFORM_ID, PLATFORM_NAME);
+ platform = new GenericPlatform (PLATFORM_ID, PLATFORM_NAME, PLATFORM_UID_PREFIX);
}
public Platform[] get_platforms () {
diff --git a/plugins/dreamcast/src/dreamcast-plugin.vala b/plugins/dreamcast/src/dreamcast-plugin.vala
index bcf4c2fe..93a89948 100644
--- a/plugins/dreamcast/src/dreamcast-plugin.vala
+++ b/plugins/dreamcast/src/dreamcast-plugin.vala
@@ -4,11 +4,12 @@ private class Games.DreamcastPlugin : Object, Plugin {
private const string MIME_TYPE = "application/x-dc-rom";
private const string PLATFORM_ID = "Dreamcast";
private const string PLATFORM_NAME = _("Dreamcast");
+ private const string PLATFORM_UID_PREFIX = "dreamcast";
private static RetroPlatform platform;
static construct {
- platform = new RetroPlatform (PLATFORM_ID, PLATFORM_NAME, { MIME_TYPE });
+ platform = new RetroPlatform (PLATFORM_ID, PLATFORM_NAME, { MIME_TYPE }, PLATFORM_UID_PREFIX);
}
public Platform[] get_platforms () {
diff --git a/plugins/game-cube/src/game-cube-plugin.vala b/plugins/game-cube/src/game-cube-plugin.vala
index eea79684..8bc4411e 100644
--- a/plugins/game-cube/src/game-cube-plugin.vala
+++ b/plugins/game-cube/src/game-cube-plugin.vala
@@ -4,11 +4,12 @@ private class Games.GameCubePlugin : Object, Plugin {
private const string MIME_TYPE = "application/x-gamecube-rom";
private const string PLATFORM_ID = "GameCube";
private const string PLATFORM_NAME = _("Nintendo GameCube");
+ private const string PLATFORM_UID_PREFIX = "game-cube";
private static RetroPlatform platform;
static construct {
- platform = new RetroPlatform (PLATFORM_ID, PLATFORM_NAME, { MIME_TYPE });
+ platform = new RetroPlatform (PLATFORM_ID, PLATFORM_NAME, { MIME_TYPE }, PLATFORM_UID_PREFIX);
}
public Platform[] get_platforms () {
diff --git a/plugins/libretro/src/libretro-plugin.vala b/plugins/libretro/src/libretro-plugin.vala
index 75ec64b9..84008eb4 100644
--- a/plugins/libretro/src/libretro-plugin.vala
+++ b/plugins/libretro/src/libretro-plugin.vala
@@ -4,11 +4,12 @@ private class Games.LibretroPlugin : Object, Plugin {
private const string LIBRETRO_FILE_SCHEME = "libretro+file";
private const string PLATFORM_ID = "Libretro";
private const string PLATFORM_NAME = _("Libretro");
+ private const string PLATFORM_UID_PREFIX = "libretro";
private static Platform platform;
static construct {
- platform = new GenericPlatform (PLATFORM_ID, PLATFORM_NAME);
+ platform = new GenericPlatform (PLATFORM_ID, PLATFORM_NAME, PLATFORM_UID_PREFIX);
}
public Platform[] get_platforms () {
diff --git a/plugins/love/src/love-plugin.vala b/plugins/love/src/love-plugin.vala
index add7c237..34e51038 100644
--- a/plugins/love/src/love-plugin.vala
+++ b/plugins/love/src/love-plugin.vala
@@ -1,15 +1,15 @@
// This file is part of GNOME Games. License: GPL-3.0+.
private class Games.LovePlugin : Object, Plugin {
- private const string FINGERPRINT_PREFIX = "love";
private const string MIME_TYPE = "application/x-love-game";
private const string PLATFORM_ID = "LOVE";
private const string PLATFORM_NAME = _("LÖVE");
+ private const string PLATFORM_UID_PREFIX = "love";
private static Platform platform;
static construct {
- platform = new GenericPlatform (PLATFORM_ID, PLATFORM_NAME);
+ platform = new GenericPlatform (PLATFORM_ID, PLATFORM_NAME, PLATFORM_UID_PREFIX);
}
public Platform[] get_platforms () {
@@ -29,7 +29,7 @@ private class Games.LovePlugin : Object, Plugin {
}
private static Game game_for_uri (Uri uri) throws Error {
- var uid = new FingerprintUid (uri, FINGERPRINT_PREFIX);
+ var uid = new FingerprintUid (uri, PLATFORM_UID_PREFIX);
var package = new LovePackage (uri);
var title = new LoveTitle (package);
var icon = new LoveIcon (package);
diff --git a/plugins/ms-dos/src/ms-dos-plugin.vala b/plugins/ms-dos/src/ms-dos-plugin.vala
index 10fdd1a3..42ed8935 100644
--- a/plugins/ms-dos/src/ms-dos-plugin.vala
+++ b/plugins/ms-dos/src/ms-dos-plugin.vala
@@ -1,15 +1,15 @@
// This file is part of GNOME Games. License: GPL-3.0+.
private class Games.MsDosPlugin : Object, Plugin {
- private const string FINGERPRINT_PREFIX = "ms-dos";
private const string MIME_TYPE = "application/x-ms-dos-executable";
private const string PLATFORM_ID = "MSDOS";
private const string PLATFORM_NAME = _("MS-DOS");
+ private const string PLATFORM_UID_PREFIX = "ms-dos";
private static RetroPlatform platform;
static construct {
- platform = new RetroPlatform (PLATFORM_ID, PLATFORM_NAME, { MIME_TYPE });
+ platform = new RetroPlatform (PLATFORM_ID, PLATFORM_NAME, { MIME_TYPE }, PLATFORM_UID_PREFIX);
}
public Platform[] get_platforms () {
@@ -25,7 +25,7 @@ private class Games.MsDosPlugin : Object, Plugin {
}
private static Game game_for_uri (Uri uri) throws Error {
- var uid = new FingerprintUid (uri, FINGERPRINT_PREFIX);
+ var uid = new FingerprintUid (uri, PLATFORM_UID_PREFIX);
var title = new FilenameTitle (uri);
var media = new GriloMedia (title, MIME_TYPE);
var release_date = new GriloReleaseDate (media);
diff --git a/plugins/nintendo-ds/src/nintendo-ds-plugin.vala b/plugins/nintendo-ds/src/nintendo-ds-plugin.vala
index c397fda2..0ad5cd68 100644
--- a/plugins/nintendo-ds/src/nintendo-ds-plugin.vala
+++ b/plugins/nintendo-ds/src/nintendo-ds-plugin.vala
@@ -1,15 +1,15 @@
// This file is part of GNOME Games. License: GPL-3.0+.
private class Games.NintendoDsPlugin : Object, Plugin {
- private const string FINGERPRINT_PREFIX = "nintendo-ds";
private const string MIME_TYPE = "application/x-nintendo-ds-rom";
private const string PLATFORM_ID = "NintendoDS";
private const string PLATFORM_NAME = _("Nintendo DS");
+ private const string PLATFORM_UID_PREFIX = "nintendo-ds";
private static RetroPlatform platform;
static construct {
- platform = new RetroPlatform (PLATFORM_ID, PLATFORM_NAME, { MIME_TYPE });
+ platform = new RetroPlatform (PLATFORM_ID, PLATFORM_NAME, { MIME_TYPE }, PLATFORM_UID_PREFIX);
}
public Platform[] get_platforms () {
@@ -29,7 +29,7 @@ private class Games.NintendoDsPlugin : Object, Plugin {
}
private static Game game_for_uri (Uri uri) throws Error {
- var uid = new FingerprintUid (uri, FINGERPRINT_PREFIX);
+ var uid = new FingerprintUid (uri, PLATFORM_UID_PREFIX);
var title = new FilenameTitle (uri);
var icon = new NintendoDsIcon (uri);
var media = new GriloMedia (title, MIME_TYPE);
diff --git a/plugins/playstation/src/playstation-plugin.vala b/plugins/playstation/src/playstation-plugin.vala
index 967b4bef..7695de96 100644
--- a/plugins/playstation/src/playstation-plugin.vala
+++ b/plugins/playstation/src/playstation-plugin.vala
@@ -5,12 +5,13 @@ private class Games.PlayStation : Object, Plugin {
private const string PHONY_MIME_TYPE = "application/x-playstation-rom";
private const string PLATFORM_ID = "PlayStation";
private const string PLATFORM_NAME = _("PlayStation");
+ private const string PLATFORM_UID_PREFIX = "playstation";
private static RetroPlatform platform;
static construct {
string[] mime_types = { CUE_MIME_TYPE, PHONY_MIME_TYPE };
- platform = new RetroPlatform (PLATFORM_ID, PLATFORM_NAME, mime_types);
+ platform = new RetroPlatform (PLATFORM_ID, PLATFORM_NAME, mime_types, PLATFORM_UID_PREFIX);
}
public Platform[] get_platforms () {
diff --git a/plugins/sega-cd/src/sega-cd-plugin.vala b/plugins/sega-cd/src/sega-cd-plugin.vala
index ae376ff8..56869813 100644
--- a/plugins/sega-cd/src/sega-cd-plugin.vala
+++ b/plugins/sega-cd/src/sega-cd-plugin.vala
@@ -3,7 +3,8 @@
private class Games.SegaCDPlugin : Object, Plugin {
private const string 32X_MIME_TYPE = "application/x-genesis-32x-rom";
- private const string SEGA_CD_PREFIX = "mega-cd";
+ private const string SEGA_CD_UID_PREFIX = "mega-cd";
+ private const string SEGA_CD_32X_UID_PREFIX = "mega-cd";
private const string CUE_MIME_TYPE = "application/x-cue";
private const string SEGA_CD_MIME_TYPE = "application/x-sega-cd-rom";
private const string SEGA_CD_PLATFORM_ID = "SegaCD";
@@ -19,8 +20,8 @@ private class Games.SegaCDPlugin : Object, Plugin {
static construct {
string[] mime_types = { CUE_MIME_TYPE, SEGA_CD_MIME_TYPE };
string[] mime_types_32x = { CUE_MIME_TYPE, SEGA_CD_MIME_TYPE, 32X_MIME_TYPE };
- platform_sega_cd = new RetroPlatform (SEGA_CD_PLATFORM_ID, SEGA_CD_PLATFORM_NAME, mime_types);
- platform_sega_cd_32x = new RetroPlatform (SEGA_CD_32X_PLATFORM_ID, SEGA_CD_32X_PLATFORM_NAME,
mime_types_32x);
+ platform_sega_cd = new RetroPlatform (SEGA_CD_PLATFORM_ID, SEGA_CD_PLATFORM_NAME, mime_types,
SEGA_CD_UID_PREFIX);
+ platform_sega_cd_32x = new RetroPlatform (SEGA_CD_32X_PLATFORM_ID, SEGA_CD_32X_PLATFORM_NAME,
mime_types_32x, SEGA_CD_32X_UID_PREFIX);
}
public Platform[] get_platforms () {
@@ -73,7 +74,7 @@ private class Games.SegaCDPlugin : Object, Plugin {
var bin_uri = new Uri (bin_file.get_uri ());
var header_offset = header.get_offset ();
- var uid = new FingerprintUid.for_chunk (bin_uri, SEGA_CD_PREFIX, header_offset,
SegaCDHeader.HEADER_LENGTH);
+ var uid = new FingerprintUid.for_chunk (bin_uri, SEGA_CD_UID_PREFIX, header_offset,
SegaCDHeader.HEADER_LENGTH);
var title = new FilenameTitle (uri);
var media = new GriloMedia (title, SEGA_CD_MIME_TYPE);
var cover = new CompositeCover ({
diff --git a/plugins/sega-saturn/src/sega-saturn-plugin.vala b/plugins/sega-saturn/src/sega-saturn-plugin.vala
index 4637d2d2..1e0aac04 100644
--- a/plugins/sega-saturn/src/sega-saturn-plugin.vala
+++ b/plugins/sega-saturn/src/sega-saturn-plugin.vala
@@ -5,12 +5,13 @@ private class Games.SegaSaturnPlugin : Object, Plugin {
private const string SEGA_SATURN_MIME_TYPE = "application/x-saturn-rom";
private const string PLATFORM_ID = "SegaSaturn";
private const string PLATFORM_NAME = _("Sega Saturn");
+ private const string PLATFORM_UID_PREFIX = "sega-saturn";
private static RetroPlatform platform;
static construct {
string[] mime_types = { CUE_MIME_TYPE, SEGA_SATURN_MIME_TYPE };
- platform = new RetroPlatform (PLATFORM_ID, PLATFORM_NAME, mime_types);
+ platform = new RetroPlatform (PLATFORM_ID, PLATFORM_NAME, mime_types, PLATFORM_UID_PREFIX);
}
public Platform[] get_platforms () {
diff --git a/plugins/steam/src/steam-plugin.vala b/plugins/steam/src/steam-plugin.vala
index 0e60dd90..5ea51ecc 100644
--- a/plugins/steam/src/steam-plugin.vala
+++ b/plugins/steam/src/steam-plugin.vala
@@ -8,11 +8,12 @@ private class Games.SteamPlugin : Object, Plugin {
private const string FLATPAK_STEAM_FILE_SCHEME = "flatpak+steam+file";
private const string PLATFORM_ID = "Steam";
private const string PLATFORM_NAME = _("Steam");
+ private const string PLATFORM_UID_PREFIX = "steam";
private static Platform platform;
static construct {
- platform = new GenericPlatform (PLATFORM_ID, PLATFORM_NAME);
+ platform = new GenericPlatform (PLATFORM_ID, PLATFORM_NAME, PLATFORM_UID_PREFIX);
// Add directories where Steam installs icons
var home = Environment.get_home_dir ();
diff --git a/plugins/turbografx-cd/src/turbografx-cd-plugin.vala
b/plugins/turbografx-cd/src/turbografx-cd-plugin.vala
index 1abe0cc0..bde08da1 100644
--- a/plugins/turbografx-cd/src/turbografx-cd-plugin.vala
+++ b/plugins/turbografx-cd/src/turbografx-cd-plugin.vala
@@ -1,19 +1,19 @@
// This file is part of GNOME Games. License: GPL-3.0+.
private class Games.TurboGrafxCDPlugin : Object, Plugin {
- private const string FINGERPRINT_PREFIX = "pc-engine";
private const string PHONY_MIME_TYPE = "application/x-pc-engine-cd-rom";
private const string CUE_MIME_TYPE = "application/x-cue";
private const string CD_MAGIC_VALUE = "PC Engine CD-ROM SYSTEM";
private const string PLATFORM_ID = "TurboGrafxCD";
/* translators: known as "CD-ROM²" in eastern Asia and France */
private const string PLATFORM_NAME = _("TurboGrafx-CD");
+ private const string PLATFORM_UID_PREFIX = "pc-engine";
private static RetroPlatform platform;
static construct {
string[] mime_types = { CUE_MIME_TYPE, PHONY_MIME_TYPE };
- platform = new RetroPlatform (PLATFORM_ID, PLATFORM_NAME, mime_types);
+ platform = new RetroPlatform (PLATFORM_ID, PLATFORM_NAME, mime_types, PLATFORM_UID_PREFIX);
}
public Platform[] get_platforms () {
@@ -36,7 +36,7 @@ private class Games.TurboGrafxCDPlugin : Object, Plugin {
if (!is_valid_disc (uri))
throw new TurboGrafxCDError.INVALID_DISC ("“%s” isn’t a valid TurboGrafx-CD disc.",
uri.to_string ());
- var uid = new FingerprintUid (uri, FINGERPRINT_PREFIX);
+ var uid = new FingerprintUid (uri, PLATFORM_UID_PREFIX);
var title = new FilenameTitle (uri);
var media = new GriloMedia (title, PHONY_MIME_TYPE);
var cover = new CompositeCover ({
diff --git a/plugins/virtual-boy/src/virtual-boy-plugin.vala b/plugins/virtual-boy/src/virtual-boy-plugin.vala
index c6ce11c2..88463241 100644
--- a/plugins/virtual-boy/src/virtual-boy-plugin.vala
+++ b/plugins/virtual-boy/src/virtual-boy-plugin.vala
@@ -1,15 +1,15 @@
// This file is part of GNOME Games. License: GPL-3.0+.
private class Games.VirtualBoyPlugin : Object, Plugin {
- private const string FINGERPRINT_PREFIX = "virtual-boy";
private const string MIME_TYPE = "application/x-virtual-boy-rom";
private const string PLATFORM_ID = "VirtualBoy";
private const string PLATFORM_NAME = _("Virtual Boy");
+ private const string PLATFORM_UID_PREFIX = "virtual-boy";
private static RetroPlatform platform;
static construct {
- platform = new RetroPlatform (PLATFORM_ID, PLATFORM_NAME, { MIME_TYPE });
+ platform = new RetroPlatform (PLATFORM_ID, PLATFORM_NAME, { MIME_TYPE }, PLATFORM_UID_PREFIX);
}
public Platform[] get_platforms () {
@@ -34,7 +34,7 @@ private class Games.VirtualBoyPlugin : Object, Plugin {
var header = new VirtualBoyHeader (file);
header.check_validity ();
- var uid = new FingerprintUid (uri, FINGERPRINT_PREFIX);
+ var uid = new FingerprintUid (uri, PLATFORM_UID_PREFIX);
var title = new FilenameTitle (uri);
var media = new GriloMedia (title, MIME_TYPE);
var cover = new CompositeCover ({
diff --git a/plugins/wii/src/wii-plugin.vala b/plugins/wii/src/wii-plugin.vala
index 3b3b9e6a..b9e3aadd 100644
--- a/plugins/wii/src/wii-plugin.vala
+++ b/plugins/wii/src/wii-plugin.vala
@@ -4,11 +4,12 @@ private class Games.WiiPlugin : Object, Plugin {
private const string MIME_TYPE = "application/x-wii-rom";
private const string PLATFORM_ID = "Wii";
private const string PLATFORM_NAME = _("Wii");
+ private const string PLATFORM_UID_PREFIX = "wii";
private static RetroPlatform platform;
static construct {
- platform = new RetroPlatform (PLATFORM_ID, PLATFORM_NAME, { MIME_TYPE });
+ platform = new RetroPlatform (PLATFORM_ID, PLATFORM_NAME, { MIME_TYPE }, PLATFORM_UID_PREFIX);
}
public Platform[] get_platforms () {
diff --git a/src/core/platform.vala b/src/core/platform.vala
index a5a57f77..6f07cec6 100644
--- a/src/core/platform.vala
+++ b/src/core/platform.vala
@@ -5,6 +5,8 @@ public interface Games.Platform : Object {
public abstract string get_name ();
+ public abstract string get_uid_prefix ();
+
public abstract PreferencesPagePlatformsRow get_row ();
public static uint hash (Platform platform) {
diff --git a/src/dummy/dummy-platform.vala b/src/dummy/dummy-platform.vala
index 6d83eee3..0b410867 100644
--- a/src/dummy/dummy-platform.vala
+++ b/src/dummy/dummy-platform.vala
@@ -9,6 +9,10 @@ public class Games.DummyPlatform : Object, Platform {
return _("Unknown");
}
+ public string get_uid_prefix () {
+ return "unknown";
+ }
+
public PreferencesPagePlatformsRow get_row () {
return new PreferencesPagePlatformsGenericRow (_("Unknown"));
}
diff --git a/src/generic/generic-platform.vala b/src/generic/generic-platform.vala
index 09abf1c4..96b0412b 100644
--- a/src/generic/generic-platform.vala
+++ b/src/generic/generic-platform.vala
@@ -3,10 +3,12 @@
public class Games.GenericPlatform : Object, Platform {
private string name;
private string id;
+ private string uid_prefix;
- public GenericPlatform (string id, string name) {
+ public GenericPlatform (string id, string name, string uid_prefix) {
this.id = id;
this.name = name;
+ this.uid_prefix = uid_prefix;
}
public string get_id () {
@@ -17,6 +19,10 @@ public class Games.GenericPlatform : Object, Platform {
return name;
}
+ public string get_uid_prefix () {
+ return uid_prefix;
+ }
+
public PreferencesPagePlatformsRow get_row () {
return new PreferencesPagePlatformsGenericRow (name);
}
diff --git a/src/retro/retro-platform.vala b/src/retro/retro-platform.vala
index b5faf0f9..a84838e4 100644
--- a/src/retro/retro-platform.vala
+++ b/src/retro/retro-platform.vala
@@ -4,11 +4,13 @@ public class Games.RetroPlatform : Object, Platform {
private string name;
private string id;
private string[] mime_types;
+ private string prefix;
- public RetroPlatform (string id, string name, string[] mime_types) {
+ public RetroPlatform (string id, string name, string[] mime_types, string prefix) {
this.id = id;
this.name = name;
this.mime_types = mime_types;
+ this.prefix = prefix;
}
public string get_id () {
@@ -19,6 +21,10 @@ public class Games.RetroPlatform : Object, Platform {
return name;
}
+ public string get_uid_prefix () {
+ return prefix;
+ }
+
public string[] get_mime_types () {
return mime_types;
}
diff --git a/src/ui/application.vala b/src/ui/application.vala
index 747eb119..4423ee79 100644
--- a/src/ui/application.vala
+++ b/src/ui/application.vala
@@ -290,7 +290,7 @@ public class Games.Application : Gtk.Application {
}
var platform_name = simple_type.get_platform_name ();
- var platform = new RetroPlatform (simple_type.platform, platform_name, {
simple_type.mime_type });
+ var platform = new RetroPlatform (simple_type.platform, platform_name, {
simple_type.mime_type }, simple_type.prefix);
platform_register.add_platform (platform);
var game_uri_adapter = new RetroSimpleGameUriAdapter (simple_type, platform);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]