Backend now retrieves a request, not an Atom ID
authorThadeu Lima de Souza Cascardo <cascardo@holoscopio.com>
Mon, 13 Oct 2008 00:31:59 +0000 (21:31 -0300)
committerThadeu Lima de Souza Cascardo <cascardo@holoscopio.com>
Mon, 13 Oct 2008 01:31:46 +0000 (22:31 -0300)
We map an Atom ID to a backend request and, then, retrieve this request
from the backend.

atom/backend.c
backend/files/giochannel.c
backend/gio/gio.c
include/atompub/backend.h

index faf031c..793d23f 100644 (file)
@@ -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;
 }
 
index 7661ae1..1c4bcf0 100644 (file)
 #include <atompub/atom-glib.h>
 
 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)
index 33a8ff9..02a8640 100644 (file)
 #include <string.h>
 
 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;
index d608800..93a147a 100644 (file)
@@ -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 *);