The frontend tells if a request is a feed or not
[cascardo/atompub.git] / atom / backend.c
index 7fe3beb..faf031c 100644 (file)
@@ -27,7 +27,6 @@ struct _atom_backend
 {
   AtomEntry * (*retrieve_entry) (AtomCtx *, AtomID *);
   void (*enumerate_entries) (AtomCtx *, char ***, AtomEntry ***, size_t *);
-  int  (*is_feed) (AtomCtx *, AtomID *);
 };
 
 AtomBackend *
@@ -64,13 +63,6 @@ atom_backend_enumerate_entries_set (AtomBackend *backend,
   backend->enumerate_entries = enumerate_entries;
 }
 
-void
-atom_backend_is_feed_set (AtomBackend *backend,
-                         int is_feed (AtomCtx *, AtomID *))
-{
-  backend->is_feed = is_feed;
-}
-
 AtomEntry *
 atom_retrieve_entry (AtomCtx *ctx, AtomID *id)
 {
@@ -94,6 +86,8 @@ atom_backend_enumerate_entries (AtomCtx *ctx, char *** reqs,
   if (backend && backend->enumerate_entries)
     {
       backend->enumerate_entries (ctx, &rreqs, &rentries, &rlen);
+      atom_map_backend_requests (ctx, rreqs, rentries, rlen);
+      atom_frontend_map_entries (ctx, rreqs, rentries, rlen);
     }
   if (reqs)
     {
@@ -119,27 +113,6 @@ atom_backend_enumerate_entries (AtomCtx *ctx, char *** reqs,
     *len = rlen;
 }
 
-int
-atom_is_feed (AtomCtx *ctx, AtomID *id)
-{
-  AtomBackend *backend;
-  AtomError *aerr;
-  backend = atom_backend (ctx);
-  if (backend && backend->is_feed)
-    {
-      return backend->is_feed (ctx, id);
-    }
-  /* Frontend may make the decision of whether the requested resource is
-   * a feed or not. If it is not able to do so and backend isn't either,
-   * it is an error.
-   */
-  aerr = atom_error_new ();
-  atom_error_code_set (aerr, 404);
-  atom_error_message_set (aerr, "Not Found");
-  atom_error_set (ctx, aerr);
-  return 0;
-}
-
 AtomFeed *
 atom_retrieve_feed (AtomCtx *ctx)
 {
@@ -154,29 +127,3 @@ atom_retrieve_feed (AtomCtx *ctx)
   g_free (entries);
   return feed;
 }
-
-AtomResource *
-atom_retrieve_resource (AtomCtx *ctx, AtomID *id)
-{
-  AtomResource *res;
-  res = NULL;
-  if (atom_is_feed (ctx, id))
-    {
-      AtomFeed *feed;
-      feed = atom_retrieve_feed (ctx);
-      if (feed == NULL)
-        return NULL;
-      res = atom_resource_new_from_feed (feed);
-      atom_feed_delete (feed);
-    }
-  else if (atom_error_get (ctx) == NULL)
-    {
-      AtomEntry *entry;
-      entry = atom_retrieve_entry (ctx, id);
-      if (entry == NULL)
-        return NULL;
-      res = atom_resource_new_from_entry (entry);
-      atom_entry_delete (entry);
-    }
-  return res;
-}