X-Git-Url: http://git.cascardo.eti.br/?a=blobdiff_plain;f=atom%2Ffrontend.c;h=b634c3849a86c7235f983501f4db6c9102b6f793;hb=47d4299470c059a4fb79ee73e6125e2319df19d8;hp=ed0faad8570ab806694e048cdf9b5bae6cd0efa2;hpb=5e0b46512db1307562af23db7ea1a1c5f6655472;p=cascardo%2Fatompub.git diff --git a/atom/frontend.c b/atom/frontend.c index ed0faad..b634c38 100644 --- a/atom/frontend.c +++ b/atom/frontend.c @@ -27,6 +27,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 *); }; AtomFrontend * @@ -36,6 +40,10 @@ atom_frontend_new () frontend = g_slice_new (AtomFrontend); frontend->map_entries = NULL; frontend->is_feed = NULL; + frontend->get_request = NULL; + frontend->handle_error = NULL; + frontend->handle_entry = NULL; + frontend->handle_feed = NULL; return frontend; } @@ -62,6 +70,34 @@ atom_frontend_is_feed_set (AtomFrontend *frontend, frontend->is_feed = is_feed; } +void +atom_frontend_get_request_set (AtomFrontend *frontend, + AtomRequest * get_request (AtomCtx *)) +{ + 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_map_entries (AtomCtx *ctx, char ** reqs, AtomEntry ** entries, size_t len) @@ -90,3 +126,48 @@ atom_is_feed (AtomCtx *ctx, char *req) */ return 0; } + +AtomRequest * +atom_get_request (AtomCtx *ctx) +{ + AtomFrontend *frontend; + frontend = atom_frontend (ctx); + if (frontend && frontend->get_request) + { + return frontend->get_request (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); + } +}