Implement backend interface to publish entries
authorThadeu Lima de Souza Cascardo <cascardo@holoscopio.com>
Fri, 24 Oct 2008 23:49:59 +0000 (21:49 -0200)
committerThadeu Lima de Souza Cascardo <cascardo@holoscopio.com>
Sun, 26 Oct 2008 15:41:02 +0000 (13:41 -0200)
atom/backend.c
include/atompub/backend.h

index 793d23f..1b3ff32 100644 (file)
@@ -27,6 +27,7 @@ struct _atom_backend
 {
   AtomEntry * (*retrieve_entry) (AtomCtx *, char *);
   void (*enumerate_entries) (AtomCtx *, char ***, AtomEntry ***, size_t *);
+  void (*publish_entry) (AtomCtx *, char *, AtomEntry *);
 };
 
 AtomBackend *
@@ -63,6 +64,14 @@ atom_backend_enumerate_entries_set (AtomBackend *backend,
   backend->enumerate_entries = enumerate_entries;
 }
 
+void
+atom_backend_publish_entry_set (AtomBackend *backend,
+                               void publish_entry (AtomCtx *, char *,
+                                                   AtomEntry *))
+{
+  backend->publish_entry = publish_entry;
+}
+
 AtomEntry *
 atom_retrieve_entry (AtomCtx *ctx, char *req)
 {
@@ -127,3 +136,22 @@ atom_retrieve_feed (AtomCtx *ctx)
   g_free (entries);
   return feed;
 }
+
+void
+atom_publish_entry (AtomCtx *ctx, char *req, AtomEntry *entry)
+{
+  AtomBackend *backend;
+  AtomError *aerr;
+  backend = atom_backend (ctx);
+  if (backend && backend->publish_entry)
+    {
+      backend->publish_entry (ctx, req, entry);
+    }
+  else
+    {
+      aerr = atom_error_new ();
+      atom_error_code_set (aerr, 501);
+      atom_error_message_set (aerr, "Not Implemented");
+      atom_error_set (ctx, aerr);
+    }
+}
index 93a147a..30c516a 100644 (file)
@@ -34,9 +34,12 @@ void atom_backend_retrieve_entry_set (AtomBackend *,
 void atom_backend_enumerate_entries_set (AtomBackend *,
                                         void (AtomCtx *, char ***,
                                               AtomEntry ***, size_t *));
+void atom_backend_publish_entry_set (AtomBackend *,
+                                    void (AtomCtx *, char *, AtomEntry*));
 AtomEntry * atom_retrieve_entry (AtomCtx *, char *);
 void atom_enumerate_entries (AtomCtx *, char ***, AtomEntry ***, size_t *);
 AtomFeed * atom_retrieve_feed (AtomCtx *);
+void atom_publish_entry (AtomCtx *, char *, AtomEntry *);
 AtomBackend * atom_backend (AtomCtx *);
 void atom_backend_set (AtomCtx *, AtomBackend *);