From dd4b3d257f73f1f464e0e7ffb299b01444c62df0 Mon Sep 17 00:00:00 2001 From: Thadeu Lima de Souza Cascardo Date: Sun, 12 Oct 2008 21:31:59 -0300 Subject: [PATCH] Backend now retrieves a request, not an Atom ID We map an Atom ID to a backend request and, then, retrieve this request from the backend. --- atom/backend.c | 8 ++++---- backend/files/giochannel.c | 9 ++++----- backend/gio/gio.c | 9 ++++----- include/atompub/backend.h | 4 ++-- 4 files changed, 14 insertions(+), 16 deletions(-) diff --git a/atom/backend.c b/atom/backend.c index faf031c..793d23f 100644 --- a/atom/backend.c +++ b/atom/backend.c @@ -25,7 +25,7 @@ struct _atom_backend { - AtomEntry * (*retrieve_entry) (AtomCtx *, AtomID *); + AtomEntry * (*retrieve_entry) (AtomCtx *, char *); void (*enumerate_entries) (AtomCtx *, char ***, AtomEntry ***, size_t *); }; @@ -48,7 +48,7 @@ atom_backend_delete (AtomBackend *backend) void atom_backend_retrieve_entry_set (AtomBackend *backend, AtomEntry *retrieve_entry (AtomCtx *, - AtomID *)) + char *)) { backend->retrieve_entry = retrieve_entry; } @@ -64,12 +64,12 @@ atom_backend_enumerate_entries_set (AtomBackend *backend, } AtomEntry * -atom_retrieve_entry (AtomCtx *ctx, AtomID *id) +atom_retrieve_entry (AtomCtx *ctx, char *req) { AtomBackend *backend; backend = atom_backend (ctx); if (backend && backend->retrieve_entry) - return backend->retrieve_entry (ctx, id); + return backend->retrieve_entry (ctx, req); return NULL; } diff --git a/backend/files/giochannel.c b/backend/files/giochannel.c index 7661ae1..1c4bcf0 100644 --- a/backend/files/giochannel.c +++ b/backend/files/giochannel.c @@ -22,17 +22,16 @@ #include static gchar * -giochannel_id_to_filename (AtomCtx *ctx, AtomID *id) +giochannel_req_to_filename (AtomCtx *ctx, char *req) { gchar *root = atom_config_get_str (ctx, "giochannel", "root"); - gchar *path = atom_id_string (id); - gchar *filename = g_build_filename (root, path, NULL); + gchar *filename = g_build_filename (root, req, NULL); g_free (root); return filename; } static AtomEntry * -giochannel_atom_retrieve_entry (AtomCtx *ctx, AtomID *id) +giochannel_atom_retrieve_entry (AtomCtx *ctx, char *req) { gchar *filename; GIOChannel *channel; @@ -40,7 +39,7 @@ giochannel_atom_retrieve_entry (AtomCtx *ctx, AtomID *id) gchar *data; gsize len; AtomEntry *atom; - filename = giochannel_id_to_filename (ctx, id); + filename = giochannel_req_to_filename (ctx, req); channel = g_io_channel_new_file ((const gchar *) filename, "r", &error); g_free (filename); if (channel == NULL) diff --git a/backend/gio/gio.c b/backend/gio/gio.c index 33a8ff9..02a8640 100644 --- a/backend/gio/gio.c +++ b/backend/gio/gio.c @@ -24,11 +24,10 @@ #include static GFile * -gio_id_to_file (AtomCtx *ctx, AtomID *id) +gio_req_to_file (AtomCtx *ctx, char *req) { gchar *root = atom_config_get_str (ctx, "gio", "root"); - gchar *path = atom_id_string (id); - gchar *filename = g_build_filename (root, path, NULL); + gchar *filename = g_build_filename (root, req, NULL); GFile *file = g_file_new_for_path (filename); g_free (root); g_free (filename); @@ -56,11 +55,11 @@ gio_file_to_atom (AtomCtx *ctx, GFile *file) } static AtomEntry * -gio_atom_retrieve_entry (AtomCtx *ctx, AtomID *id) +gio_atom_retrieve_entry (AtomCtx *ctx, char *req) { GFile *file; AtomEntry *atom; - file = gio_id_to_file (ctx, id); + file = gio_req_to_file (ctx, req); atom = gio_file_to_atom (ctx, file); g_object_unref (file); return atom; diff --git a/include/atompub/backend.h b/include/atompub/backend.h index d608800..93a147a 100644 --- a/include/atompub/backend.h +++ b/include/atompub/backend.h @@ -30,11 +30,11 @@ typedef struct _atom_backend AtomBackend; AtomBackend *atom_backend_new (void); void atom_backend_delete (AtomBackend *); void atom_backend_retrieve_entry_set (AtomBackend *, - AtomEntry * (AtomCtx *, AtomID *)); + AtomEntry * (AtomCtx *, char *)); void atom_backend_enumerate_entries_set (AtomBackend *, void (AtomCtx *, char ***, AtomEntry ***, size_t *)); -AtomEntry * atom_retrieve_entry (AtomCtx *, AtomID *); +AtomEntry * atom_retrieve_entry (AtomCtx *, char *); void atom_enumerate_entries (AtomCtx *, char ***, AtomEntry ***, size_t *); AtomFeed * atom_retrieve_feed (AtomCtx *); AtomBackend * atom_backend (AtomCtx *); -- 2.20.1