[rygel/rygel-0-14] media-export: Use libunistring for collation
- From: Jens Georg <jensgeorg src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [rygel/rygel-0-14] media-export: Use libunistring for collation
- Date: Wed, 13 Jun 2012 20:00:30 +0000 (UTC)
commit fc3a24f5b93bb88c2d5342563914f9b975e0c901
Author: Jens Georg <mail jensge org>
Date: Sun May 6 22:15:12 2012 +0200
media-export: Use libunistring for collation
configure.ac | 11 ++++++
src/plugins/media-export/Makefile.am | 6 ++-
.../media-export/rygel-media-export-collate.c | 38 ++++++++++++++++++++
.../media-export/rygel-media-export-database.vala | 10 ++++--
4 files changed, 60 insertions(+), 5 deletions(-)
---
diff --git a/configure.ac b/configure.ac
index b8a6ae0..17fcc2b 100644
--- a/configure.ac
+++ b/configure.ac
@@ -169,6 +169,17 @@ then
PKG_CHECK_MODULES(GSTREAMER_TAG, gstreamer-tag-0.10 >= $GSTREAMER_TAG_REQUIRED);
PKG_CHECK_MODULES(GSTREAMER_APP, gstreamer-app-0.10 >= $GSTREAMER_APP_REQUIRED);
RYGEL_CHECK_PACKAGES([sqlite3 gstreamer-tag-0.10 gstreamer-app-0.10])
+ AC_CHECK_HEADER([unistr.h],
+ AC_CHECK_LIB([unistring],
+ [u8_strcoll],
+ [have_unistring=yes],[have_unistring=no]))
+ if test "x$have_unistring" = "xyes"; then
+ AC_DEFINE([HAVE_UNISTRING],[1],[Use libunistring for collation])
+ COLLATION_CFLAGS=
+ COLLATION_LIBS=-lunistring
+ AC_SUBST([COLLATION_CFLAGS])
+ AC_SUBST([COLLATION_LIBS])
+ fi
fi
dnl Gettext
diff --git a/src/plugins/media-export/Makefile.am b/src/plugins/media-export/Makefile.am
index 451e035..cf29ca1 100644
--- a/src/plugins/media-export/Makefile.am
+++ b/src/plugins/media-export/Makefile.am
@@ -35,7 +35,8 @@ librygel_media_export_la_SOURCES = \
rygel-media-export-item.vala \
rygel-media-export-jpeg-writer.vala \
rygel-media-export-object-factory.vala \
- rygel-media-export-writable-db-container.vala
+ rygel-media-export-writable-db-container.vala \
+ rygel-media-export-collate.c
librygel_media_export_la_VALAFLAGS = \
--pkg gupnp-dlna-1.0 \
@@ -49,7 +50,8 @@ librygel_media_export_la_LIBADD = \
$(LIBGUPNP_DLNA_LIBS) \
$(GSTREAMER_TAG_LIBS) \
$(GSTREAMER_APP_LIBS) \
- $(LIBSQLITE3_LIBS)
+ $(LIBSQLITE3_LIBS) \
+ $(COLLATION_LIBS)
librygel_media_export_la_LDFLAGS = $(RYGEL_PLUGIN_LINKER_FLAGS)
diff --git a/src/plugins/media-export/rygel-media-export-collate.c b/src/plugins/media-export/rygel-media-export-collate.c
new file mode 100644
index 0000000..eccf527
--- /dev/null
+++ b/src/plugins/media-export/rygel-media-export-collate.c
@@ -0,0 +1,38 @@
+/*
+ * Copyright (C) 2012 Jens Georg <mail jensge org>.
+ *
+ * Author: Jens Georg <mail jensge org>
+ *
+ * This file is part of Rygel.
+ *
+ * Rygel is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * Rygel is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ */
+
+#include <glib.h>
+
+#ifdef HAVE_UNISTRING
+#include <unistr.h>
+gint rygel_media_export_utf8_collate_str (const char *a, const char *b)
+{
+ return u8_strcoll (a, b);
+}
+
+#else
+
+gint rygel_media_export_utf8_collate_str (const char *a, const char *b)
+{
+ return g_utf8_collate (a, b);
+}
+#endif
diff --git a/src/plugins/media-export/rygel-media-export-database.vala b/src/plugins/media-export/rygel-media-export-database.vala
index 5dea5fa..16c007d 100644
--- a/src/plugins/media-export/rygel-media-export-database.vala
+++ b/src/plugins/media-export/rygel-media-export-database.vala
@@ -27,6 +27,10 @@ public errordomain Rygel.MediaExport.DatabaseError {
SQLITE_ERROR
}
+namespace Rygel.MediaExport {
+ extern static int utf8_collate_str (string a, string b);
+}
+
/**
* This class is a thin wrapper around SQLite's database object.
*
@@ -70,10 +74,10 @@ internal class Rygel.MediaExport.Database : SqliteWrapper {
unowned uint8[] _b = (uint8[]) b;
_b.length = blen;
- var str_a = ((string) _a).casefold ();
- var str_b = ((string) _b).casefold ();
+ var str_a = ((string) _a);
+ var str_b = ((string) _b);
- return str_a.collate (str_b);
+ return utf8_collate_str (str_a, str_b);
}
/**
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]