2 * Copyright (C) 2007 Thadeu Lima de Souza Cascardo <cascardo@holoscopio.com>
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation; either version 2 of the License, or
7 * (at your option) any later version.
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
14 * You should have received a copy of the GNU General Public License along
15 * with this program; if not, write to the Free Software Foundation, Inc.,
16 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
20 #include <atompub/atom.h>
28 AtomEntry * (*retrieve_entry) (AtomCtx *, AtomID *);
29 void (*enumerate_entries) (AtomCtx *, char ***, AtomEntry ***, size_t *);
36 backend = g_slice_new (AtomBackend);
37 backend->retrieve_entry = NULL;
38 backend->enumerate_entries = NULL;
43 atom_backend_delete (AtomBackend *backend)
45 g_slice_free (AtomBackend, backend);
49 atom_backend_retrieve_entry_set (AtomBackend *backend,
50 AtomEntry *retrieve_entry (AtomCtx *,
53 backend->retrieve_entry = retrieve_entry;
57 atom_backend_enumerate_entries_set (AtomBackend *backend,
58 void enumerate_entries (AtomCtx *,
63 backend->enumerate_entries = enumerate_entries;
67 atom_retrieve_entry (AtomCtx *ctx, AtomID *id)
70 backend = atom_backend (ctx);
71 if (backend && backend->retrieve_entry)
72 return backend->retrieve_entry (ctx, id);
77 atom_backend_enumerate_entries (AtomCtx *ctx, char *** reqs,
78 AtomEntry *** entries, size_t *len)
82 AtomEntry **rentries = NULL;
85 backend = atom_backend (ctx);
86 if (backend && backend->enumerate_entries)
88 backend->enumerate_entries (ctx, &rreqs, &rentries, &rlen);
89 atom_map_backend_requests (ctx, rreqs, rentries, rlen);
90 atom_frontend_map_entries (ctx, rreqs, rentries, rlen);
98 for (i = 0; i < rlen; i++)
108 for (i = 0; i < rlen; i++)
109 atom_entry_delete (rentries[i]);
117 atom_retrieve_feed (AtomCtx *ctx)
122 atom_backend_enumerate_entries (ctx, NULL, &entries, &len);
123 if (atom_error_get (ctx) != NULL)
125 feed = atom_feed_new ();
126 atom_feed_entry_append_array (feed, entries, len);