{
AtomEntry * (*retrieve_entry) (AtomCtx *, AtomID *);
void (*enumerate_entries) (AtomCtx *, char ***, AtomEntry ***, size_t *);
- int (*is_feed) (AtomCtx *, AtomID *);
};
AtomBackend *
backend = g_slice_new (AtomBackend);
backend->retrieve_entry = NULL;
backend->enumerate_entries = NULL;
- backend->is_feed = NULL;
return 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)
{
*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)
{
struct _atom_frontend
{
void (*map_entries) (AtomCtx *, char **, AtomEntry **, size_t);
+ int (*is_feed) (AtomCtx *, char *);
};
AtomFrontend *
AtomFrontend *frontend;
frontend = g_slice_new (AtomFrontend);
frontend->map_entries = NULL;
+ frontend->is_feed = NULL;
return frontend;
}
frontend->map_entries = map_entries;
}
+void
+atom_frontend_is_feed_set (AtomFrontend *frontend,
+ int is_feed (AtomCtx *, char *))
+{
+ frontend->is_feed = is_feed;
+}
+
void
atom_frontend_map_entries (AtomCtx *ctx, char ** reqs,
AtomEntry ** entries, size_t len)
frontend->map_entries (ctx, reqs, entries, len);
}
}
+
+int
+atom_is_feed (AtomCtx *ctx, char *req)
+{
+ AtomFrontend *frontend;
+ AtomError *aerr;
+ frontend = atom_frontend (ctx);
+ if (frontend && frontend->is_feed)
+ {
+ return frontend->is_feed (ctx, req);
+ }
+ /* If frontend cannot decide if a request is a feed, let's tell it's
+ * not. If the request mapping cannot be done, it will return a "Not
+ * Found" error anyway.
+ */
+ return 0;
+}
g_ptr_array_free (filenames, FALSE);
}
-static int
-gio_atom_is_feed (AtomCtx *ctx, AtomID *id)
-{
- return (!strcmp (atom_id_string (id), "/"));
-}
-
AtomBackend *
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;
}
void atom_backend_enumerate_entries_set (AtomBackend *,
void (AtomCtx *, char ***,
AtomEntry ***, size_t *));
-void atom_backend_is_feed_set (AtomBackend *, int (AtomCtx *, AtomID *));
AtomEntry * atom_retrieve_entry (AtomCtx *, AtomID *);
void atom_enumerate_entries (AtomCtx *, char ***, AtomEntry ***, size_t *);
-int atom_is_feed (AtomCtx *, AtomID *);
AtomFeed * atom_retrieve_feed (AtomCtx *);
AtomBackend * atom_backend (AtomCtx *);
void atom_backend_set (AtomCtx *, AtomBackend *);
void atom_frontend_map_entries_set (AtomFrontend *,
void (AtomCtx *, char **,
AtomEntry **, size_t));
+void atom_frontend_is_feed_set (AtomFrontend *,
+ int is_feed (AtomCtx *, char *));
void atom_map_entries (AtomCtx *, char **, AtomEntry **, size_t);
+int atom_is_feed (AtomCtx *, char *);
AtomFrontend * atom_frontend (AtomCtx *);
void atom_frontend_set (AtomCtx *, AtomFrontend *);