Implement backend interface to publish entries
[cascardo/atompub.git] / atom / backend.c
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);
+    }
+}