Siegfried Gevatter has proposed merging lp:~zeitgeist/zeitgeist/mimetypes into
lp:zeitgeist.
Requested reviews:
Michal Hruby (mhr3)
For more details, see:
https://code.launchpad.net/~zeitgeist/zeitgeist/mimetypes/+merge/87033
--
https://code.launchpad.net/~zeitgeist/zeitgeist/mimetypes/+merge/87033
Your team Zeitgeist Framework Team is subscribed to branch lp:zeitgeist.
=== modified file '.bzrignore'
--- .bzrignore 2011-11-01 18:12:14 +
+++ .bzrignore 2011-12-28 18:19:23 +
@@ -54,3 +54,4 @@
extra/python/_ontology.py
test/direct/*.c
src/zeitgeist-daemon
+mimetype-test
=== modified file 'src/Makefile.am'
--- src/Makefile.am 2011-11-01 18:30:37 +
+++ src/Makefile.am 2011-12-28 18:19:23 +
@@ -44,6 +44,7 @@
where-clause.vala \
ontology.vala \
ontology-uris.vala \
+ mimetype.vala \
$(NULL)
zeitgeist_daemon_SOURCES = \
=== added file 'src/mimetype.vala'
--- src/mimetype.vala 1970-01-01 00:00:00 +
+++ src/mimetype.vala 2011-12-28 18:19:23 +
@@ -0,0 +1,343 @@
+/* datamodel.vala
+ *
+ * Copyright © 2011 Collabora Ltd.
+ * By Siegfried-Angel Gevatter Pujals siegfr...@gevatter.com
+ * Copyright © 2010 Canonical, Ltd.
+ * By Mikkel Kamstrup Erlandsen mikkel.kamst...@canonical.com
+ *
+ * This program 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.1 of the License, or
+ * (at your option) any later version.
+ *
+ * This program 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 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, see http://www.gnu.org/licenses/.
+ *
+ */
+
+using Zeitgeist;
+
+namespace Zeitgeist
+{
+
+private static bool mimetypes_loaded = false;
+private static bool schemes_loaded = false;
+
+private static HashTablestring, string? mimetypes = null;
+private static SListMimeRegex? mimetypes_regexs;
+private static SListUriScheme? schemes;
+
+private struct MimeRegex
+{
+public Regex regex;
+public string interpretation_uri;
+
+public MimeRegex (string mimetype_regex, string interpretation_uri)
+throws RegexError
+{
+this.regex = new Regex (mimetype_regex, 0, 0);
+this.interpretation_uri = interpretation_uri;
+}
+}
+
+private struct UriScheme
+{
+public string uri_scheme;
+public string manifestation_uri;
+}
+
+/**
+ * zeitgeist_register_mimetype:
+ * @mimetype: A MIME-type string. Eg. emphasistext/plain/emphasis
+ * @interpretation_uri: A URI defining the subject interpretation type to
+ * associate with @mimetype
+ *
+ * Associate a MIME-type with a given interpretation type. Registered
+ * MIME-types can be looked up with zeitgeist_interpretation_for_mimetype().
+ *
+ * You can register a regular expression as mimetype if instead of this
+ * function you invoke zeitgeist_register_mimetype_regex().
+ *
+ * MIME-types are first looked up by their exact name and then if none is
+ * found the regular expressions will be checked as fallbacks.
+ *
+ * This library will install a wide range a common mimetypes for you, so
+ * unless you have very specific needs you will normally not have to call
+ * this function.
+ *
+ * FIXME: link to list of interpretations
+ */
+public void register_mimetype (string mimetype, string interpretation_uri)
+{
+if (mimetypes == null)
+mimetypes = new HashTablestring, string(str_hash, str_equal);
+
+mimetypes.insert (mimetype, interpretation_uri);
+}
+
+/**
+ * zeitgeist_register_mimetype_regex:
+ * @mimetype: A regular expression matching a certain range of mimetypes.
+ * Eg. emphasistext/.*/emphasis to match all
+ * emphasistext/emphasis subtypes.
+ * @interpretation_uri: A URI defining the subject interpretation type to
+ * associate with the matched MIME-types
+ *
+ * Associate a range of MIME-types with a given interpretation type.
+ * Registered MIME-types can be looked up with
+ * zeitgeist_interpretation_for_mimetype().
+ *
+ * If you only need to register one specific MIME-type, it is more efficient
+ * to use zeitgeist_register_mimetype() instead of this function.
+ *
+ * MIME-types are first looked up by their exact name and then if none is
+ * found the regular expressions will be checked as fallbacks.
+ *
+ * This library will install a wide range a common mimetypes for you, so
+ * unless you have very specific needs you will normally not have to call
+ *