[rygel] db,lms: Share collation functions
- From: Jens Georg <jensgeorg src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [rygel] db,lms: Share collation functions
- Date: Sun, 17 Jan 2016 21:33:03 +0000 (UTC)
commit cc9f215348fe07eac0cd38d91b6070b21e20df34
Author: Jens Georg <mail jensge org>
Date: Sun Apr 19 15:45:46 2015 +0200
db,lms: Share collation functions
Signed-off-by: Jens Georg <mail jensge org>
src/plugins/lms/Makefile.am | 1 -
src/plugins/lms/rygel-lms-collate.c | 49 -------------------------------
src/plugins/lms/rygel-lms-database.vala | 47 +----------------------------
3 files changed, 2 insertions(+), 95 deletions(-)
---
diff --git a/src/plugins/lms/Makefile.am b/src/plugins/lms/Makefile.am
index d7170b5..5cdee17 100644
--- a/src/plugins/lms/Makefile.am
+++ b/src/plugins/lms/Makefile.am
@@ -20,7 +20,6 @@ librygel_lms_la_SOURCES = \
rygel-lms-all-images.vala \
rygel-lms-image-years.vala \
rygel-lms-image-year.vala \
- rygel-lms-collate.c \
rygel-lms-dbus-interfaces.vala
librygel_lms_la_VALAFLAGS = \
diff --git a/src/plugins/lms/rygel-lms-database.vala b/src/plugins/lms/rygel-lms-database.vala
index e898d66..f7d6ca6 100644
--- a/src/plugins/lms/rygel-lms-database.vala
+++ b/src/plugins/lms/rygel-lms-database.vala
@@ -33,10 +33,6 @@ public errordomain Rygel.LMS.DatabaseError {
NOT_FOUND
}
-namespace Rygel.LMS {
- extern static int utf8_collate_str (uint8[] a, uint8[] b);
-}
-
public class Rygel.LMS.Database {
public signal void db_updated(uint64 old_update_id, uint64 new_update_id);
@@ -45,45 +41,6 @@ public class Rygel.LMS.Database {
private LMS.DBus lms_proxy;
private uint64 update_id;
- /**
- * Function to implement the custom SQL function 'contains'
- */
- private static void utf8_contains (Sqlite.Context context,
- Sqlite.Value[] args)
- requires (args.length == 2) {
- if (args[0].to_text () == null ||
- args[1].to_text () == null) {
- context.result_int (0);
-
- return;
- }
-
- var pattern = Regex.escape_string (args[1].to_text ());
- if (Regex.match_simple (pattern,
- args[0].to_text (),
- RegexCompileFlags.CASELESS)) {
- context.result_int (1);
- } else {
- context.result_int (0);
- }
- }
-
- /**
- * Function to implement the custom SQLite collation 'CASEFOLD'.
- *
- * Uses utf8 case-fold to compare the strings.
- */
- private static int utf8_collate (int alen, void* a, int blen, void* b) {
- // unowned to prevent array copy
- unowned uint8[] _a = (uint8[]) a;
- _a.length = alen;
-
- unowned uint8[] _b = (uint8[]) b;
- _b.length = blen;
-
- return LMS.utf8_collate_str (_a, _b);
- }
-
public Database () throws DatabaseError {
string db_path;
try {
@@ -114,13 +71,13 @@ public class Rygel.LMS.Database {
2,
Sqlite.UTF8,
null,
- LMS.Database.utf8_contains,
+ Rygel.Database.Database.utf8_contains,
null,
null);
this.db.create_collation ("CASEFOLD",
Sqlite.UTF8,
- LMS.Database.utf8_collate);
+ Rygel.Database.Database.utf8_collate);
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]