Added publish handler to frontend
[cascardo/atompub.git] / atom / frontend.c
index e530aa8..8365957 100644 (file)
@@ -28,6 +28,10 @@ struct _atom_frontend
   void (*map_entries) (AtomCtx *, char **, AtomEntry **, size_t);
   int  (*is_feed) (AtomCtx *, char *);
   AtomRequest * (*get_request) (AtomCtx *);
+  void (*handle_error) (AtomCtx *);
+  void (*handle_entry) (AtomCtx *, AtomEntry *);
+  void (*handle_feed) (AtomCtx *, AtomFeed *);
+  void (*handle_publish) (AtomCtx *, AtomEntry *);
 };
 
 AtomFrontend *
@@ -38,6 +42,10 @@ atom_frontend_new ()
   frontend->map_entries = NULL;
   frontend->is_feed = NULL;
   frontend->get_request = NULL;
+  frontend->handle_error = NULL;
+  frontend->handle_entry = NULL;
+  frontend->handle_feed = NULL;
+  frontend->handle_publish = NULL;
   return frontend;
 }
 
@@ -71,6 +79,34 @@ atom_frontend_get_request_set (AtomFrontend *frontend,
   frontend->get_request = get_request;
 }
 
+void
+atom_frontend_handle_error_set (AtomFrontend *frontend,
+                               void handle_error (AtomCtx *))
+{
+  frontend->handle_error = handle_error;
+}
+
+void
+atom_frontend_handle_entry_set (AtomFrontend *frontend,
+                               void handle_entry (AtomCtx *, AtomEntry *))
+{
+  frontend->handle_entry = handle_entry;
+}
+
+void
+atom_frontend_handle_feed_set (AtomFrontend *frontend,
+                              void handle_feed (AtomCtx *, AtomFeed *))
+{
+  frontend->handle_feed = handle_feed;
+}
+
+void
+atom_frontend_handle_publish_set (AtomFrontend *frontend,
+                                 void handle_publish (AtomCtx *, AtomEntry *))
+{
+  frontend->handle_publish = handle_publish;
+}
+
 void
 atom_frontend_map_entries (AtomCtx *ctx, char ** reqs,
                           AtomEntry ** entries, size_t len)
@@ -111,3 +147,47 @@ atom_get_request (AtomCtx *ctx)
     }
   return NULL;
 }
+
+void
+atom_handle_error (AtomCtx *ctx)
+{
+  AtomFrontend *frontend;
+  frontend = atom_frontend (ctx);
+  if (frontend && frontend->handle_error)
+    {
+      frontend->handle_error (ctx);
+    }
+}
+
+void
+atom_handle_entry (AtomCtx *ctx, AtomEntry *entry)
+{
+  AtomFrontend *frontend;
+  frontend = atom_frontend (ctx);
+  if (frontend && frontend->handle_entry)
+    {
+      frontend->handle_entry (ctx, entry);
+    }
+}
+
+void
+atom_handle_feed (AtomCtx *ctx, AtomFeed *feed)
+{
+  AtomFrontend *frontend;
+  frontend = atom_frontend (ctx);
+  if (frontend && frontend->handle_feed)
+    {
+      frontend->handle_feed (ctx, feed);
+    }
+}
+
+void
+atom_handle_publish (AtomCtx *ctx, AtomEntry *entry)
+{
+  AtomFrontend *frontend;
+  frontend = atom_frontend (ctx);
+  if (frontend && frontend->handle_publish)
+    {
+      frontend->handle_publish (ctx, entry);
+    }
+}