Added backend interface to enumerate entries
[cascardo/atompub.git] / src / ctx.c
index 9b81a3b..e9d940b 100644 (file)
--- a/src/ctx.c
+++ b/src/ctx.c
@@ -23,8 +23,9 @@
 
 struct _atom_ctx
 {
-  GError *error;
+  AtomError *error;
   gpointer config_data;
+  AtomBackend *backend;
 };
 
 AtomCtx *
@@ -34,15 +35,34 @@ atom_ctx_new ()
   ctx = g_slice_new (AtomCtx);
   ctx->error = NULL;
   ctx->config_data = NULL;
+  ctx->backend = NULL;
   return ctx;
 }
 
 void
-atom_error_set (AtomCtx *ctx, GError *error)
+atom_ctx_delete (AtomCtx *ctx)
 {
+  if (ctx->error)
+    atom_error_delete (ctx->error);
+  if (ctx->backend)
+    atom_backend_delete (ctx->backend);
+  g_slice_free (AtomCtx, ctx);
+}
+
+void
+atom_error_set (AtomCtx *ctx, AtomError *error)
+{
+  if (ctx->error)
+    atom_error_delete (ctx->error);
   ctx->error = error;
 }
 
+AtomError *
+atom_error_get (AtomCtx *ctx)
+{
+  return ctx->error;
+}
+
 void *
 atom_config_data (AtomCtx *ctx)
 {
@@ -54,3 +74,15 @@ atom_config_data_set (AtomCtx *ctx, void *data)
 {
   ctx->config_data = data;
 }
+
+AtomBackend *
+atom_backend (AtomCtx *ctx)
+{
+  return ctx->backend;
+}
+
+void
+atom_backend_set (AtomCtx *ctx, AtomBackend *backend)
+{
+  ctx->backend = backend;
+}