[gnome-games/wip/exalm/uid: 2/13] fingerprint: Drop FingerprintUid
- From: Alexander Mikhaylenko <alexm src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-games/wip/exalm/uid: 2/13] fingerprint: Drop FingerprintUid
- Date: Sun, 23 Feb 2020 12:34:40 +0000 (UTC)
commit 1fd7e0613fb2cb229268bceefe5ab6d84eb28ee0
Author: Alexander Mikhaylenko <alexm gnome org>
Date: Fri Feb 21 17:33:45 2020 +0500
fingerprint: Drop FingerprintUid
Provide functions that return strings instead, and use GenericUid.
plugins/love/src/love-plugin.vala | 2 +-
plugins/ms-dos/src/ms-dos-plugin.vala | 2 +-
plugins/nintendo-ds/src/nintendo-ds-plugin.vala | 2 +-
plugins/sega-cd/src/sega-cd-plugin.vala | 2 +-
.../turbografx-cd/src/turbografx-cd-plugin.vala | 2 +-
plugins/virtual-boy/src/virtual-boy-plugin.vala | 2 +-
src/retro/retro-simple-game-uri-adapter.vala | 2 +-
src/utils/fingerprint.vala | 30 ++++------------------
8 files changed, 12 insertions(+), 32 deletions(-)
---
diff --git a/plugins/love/src/love-plugin.vala b/plugins/love/src/love-plugin.vala
index 30e3d2ec..2bdc4cb4 100644
--- a/plugins/love/src/love-plugin.vala
+++ b/plugins/love/src/love-plugin.vala
@@ -36,7 +36,7 @@ private class Games.LovePlugin : Object, Plugin {
}
private static Game game_for_uri (Uri uri) throws Error {
- var uid = new FingerprintUid (uri, PLATFORM_UID_PREFIX);
+ var uid = new GenericUid (Fingerprint.get_uid (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 f7104eb1..f4543f90 100644
--- a/plugins/ms-dos/src/ms-dos-plugin.vala
+++ b/plugins/ms-dos/src/ms-dos-plugin.vala
@@ -32,7 +32,7 @@ private class Games.MsDosPlugin : Object, Plugin {
}
private static Game game_for_uri (Uri uri) throws Error {
- var uid = new FingerprintUid (uri, PLATFORM_UID_PREFIX);
+ var uid = new GenericUid (Fingerprint.get_uid (uri, PLATFORM_UID_PREFIX));
var title = new FilenameTitle (uri);
var media = new GriloMedia (title, MIME_TYPE);
var cover = new CompositeCover ({
diff --git a/plugins/nintendo-ds/src/nintendo-ds-plugin.vala b/plugins/nintendo-ds/src/nintendo-ds-plugin.vala
index 768925c9..ece7d308 100644
--- a/plugins/nintendo-ds/src/nintendo-ds-plugin.vala
+++ b/plugins/nintendo-ds/src/nintendo-ds-plugin.vala
@@ -36,7 +36,7 @@ private class Games.NintendoDsPlugin : Object, Plugin {
}
private static Game game_for_uri (Uri uri) throws Error {
- var uid = new FingerprintUid (uri, PLATFORM_UID_PREFIX);
+ var uid = new GenericUid (Fingerprint.get_uid (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/sega-cd/src/sega-cd-plugin.vala b/plugins/sega-cd/src/sega-cd-plugin.vala
index 13baae0f..81eb1a18 100644
--- a/plugins/sega-cd/src/sega-cd-plugin.vala
+++ b/plugins/sega-cd/src/sega-cd-plugin.vala
@@ -81,7 +81,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_UID_PREFIX, header_offset,
SegaCDHeader.HEADER_LENGTH);
+ var uid = new GenericUid (Fingerprint.get_uid_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/turbografx-cd/src/turbografx-cd-plugin.vala
b/plugins/turbografx-cd/src/turbografx-cd-plugin.vala
index 0bb5e912..450ac3f0 100644
--- a/plugins/turbografx-cd/src/turbografx-cd-plugin.vala
+++ b/plugins/turbografx-cd/src/turbografx-cd-plugin.vala
@@ -42,7 +42,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, PLATFORM_UID_PREFIX);
+ var uid = new GenericUid (Fingerprint.get_uid (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 ee20a746..a3c5516b 100644
--- a/plugins/virtual-boy/src/virtual-boy-plugin.vala
+++ b/plugins/virtual-boy/src/virtual-boy-plugin.vala
@@ -40,7 +40,7 @@ private class Games.VirtualBoyPlugin : Object, Plugin {
var header = new VirtualBoyHeader (file);
header.check_validity ();
- var uid = new FingerprintUid (uri, PLATFORM_UID_PREFIX);
+ var uid = new GenericUid (Fingerprint.get_uid (uri, PLATFORM_UID_PREFIX));
var title = new FilenameTitle (uri);
var media = new GriloMedia (title, MIME_TYPE);
var cover = new CompositeCover ({
diff --git a/src/retro/retro-simple-game-uri-adapter.vala b/src/retro/retro-simple-game-uri-adapter.vala
index d25536a0..35eed310 100644
--- a/src/retro/retro-simple-game-uri-adapter.vala
+++ b/src/retro/retro-simple-game-uri-adapter.vala
@@ -10,7 +10,7 @@ private class Games.RetroSimpleGameUriAdapter : GameUriAdapter, Object {
}
public Game game_for_uri (Uri uri) throws Error {
- var uid = new FingerprintUid (uri, simple_type.prefix);
+ var uid = new GenericUid (Fingerprint.get_uid (uri, simple_type.prefix));
var title = new FilenameTitle (uri);
var media = new GriloMedia (title, simple_type.mime_type);
var cover = new CompositeCover ({
diff --git a/src/utils/fingerprint.vala b/src/utils/fingerprint.vala
index 6fd3a680..4a0ff4e2 100644
--- a/src/utils/fingerprint.vala
+++ b/src/utils/fingerprint.vala
@@ -22,36 +22,16 @@ namespace Games.Fingerprint {
return Checksum.compute_for_bytes (ChecksumType.MD5, bytes);
}
-}
-public class Games.FingerprintUid : Object, Uid {
- private Uri uri;
- private string prefix;
- private size_t start;
- private size_t? length;
- private string uid;
-
- public FingerprintUid (Uri uri, string prefix) {
- this.uri = uri;
- this.prefix = prefix;
- start = 0;
- length = null;
- }
+ public string get_uid (Uri uri, string prefix) throws Error {
+ var fingerprint = Fingerprint.get_for_file_uri (uri, 0, null);
- public FingerprintUid.for_chunk (Uri uri, string prefix, size_t start, size_t length) {
- this.uri = uri;
- this.prefix = prefix;
- this.start = start;
- this.length = length;
+ return @"$prefix-$fingerprint";
}
- public string get_uid () throws Error {
- if (uid != null)
- return uid;
-
+ public string get_uid_for_chunk (Uri uri, string prefix, size_t start, size_t length) throws Error {
var fingerprint = Fingerprint.get_for_file_uri (uri, start, length);
- uid = @"$prefix-$fingerprint";
- return uid;
+ return @"$prefix-$fingerprint";
}
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]