Introducing AtomID, which is used in core, instead of IRI
[cascardo/atompub.git] / backend / gio / gio.c
index a7366bf..f430f84 100644 (file)
 #include <gio/gio.h>
 #include <atompub/atom.h>
 #include <atompub/atom-glib.h>
+#include <string.h>
 
 static GFile *
-gio_iri_to_file (AtomCtx *ctx, IRI *iri)
+gio_id_to_file (AtomCtx *ctx, AtomID *id)
 {
   gchar *root = atom_config_get_str (ctx, "gio", "root");
-  gchar *path = iri_get_path (iri);
+  gchar *path = atom_id_string (id);
   gchar *filename = g_build_filename (root, path, NULL);
   GFile *file = g_file_new_for_path (filename);
   g_free (root);
@@ -55,11 +56,11 @@ gio_file_to_atom (AtomCtx *ctx, GFile *file)
 }
 
 static AtomEntry *
-gio_atom_retrieve_entry (AtomCtx *ctx, IRI *iri)
+gio_atom_retrieve_entry (AtomCtx *ctx, AtomID *id)
 {
   GFile *file;
   AtomEntry *atom;
-  file = gio_iri_to_file (ctx, iri);
+  file = gio_id_to_file (ctx, id);
   atom = gio_file_to_atom (ctx, file);
   g_object_unref (file);
   return atom;
@@ -101,6 +102,12 @@ gio_enumerate_entries (AtomCtx *ctx, AtomEntry ***entries, size_t *len)
   g_ptr_array_free (array, FALSE);
 }
 
+static int
+gio_atom_is_feed (AtomCtx *ctx, AtomID *id)
+{
+  return (!strcmp (atom_id_string (id), "/"));
+}
+
 AtomBackend *
 gio_backend (void)
 {
@@ -108,5 +115,6 @@ gio_backend (void)
   backend = atom_backend_new ();
   atom_backend_retrieve_entry_set (backend, gio_atom_retrieve_entry);
   atom_backend_enumerate_entries_set (backend, gio_enumerate_entries);
+  atom_backend_is_feed_set (backend, gio_atom_is_feed);
   return backend;
 }