static nserror svg_create(const content_handler *handler, lwc_string *imime_type, const struct http_parameter *params, struct llcache_handle *llcache, const char *fallback_charset, bool quirks, struct content **c) { svg_content *svg; nserror error; svg = calloc(1, sizeof(svg_content)); if (svg == NULL) return NSERROR_NOMEM; error = content__init(&svg->base, handler, imime_type, params, llcache, fallback_charset, quirks); if (error != NSERROR_OK) { free(svg); return error; } error = svg_create_svg_data(svg); if (error != NSERROR_OK) { free(svg); return error; } *c = (struct content *) svg; return NSERROR_OK; }
static nserror nsgif_create(const content_handler *handler, lwc_string *imime_type, const struct http_parameter *params, llcache_handle *llcache, const char *fallback_charset, bool quirks, struct content **c) { nsgif_content *result; nserror error; result = calloc(1, sizeof(nsgif_content)); if (result == NULL) return NSERROR_NOMEM; error = content__init(&result->base, handler, imime_type, params, llcache, fallback_charset, quirks); if (error != NSERROR_OK) { free(result); return error; } error = nsgif_create_gif_data(result); if (error != NSERROR_OK) { free(result); return error; } *c = (struct content *) result; return NSERROR_OK; }
static nserror nspng_create(const content_handler *handler, lwc_string *imime_type, const http_parameter *params, llcache_handle *llcache, const char *fallback_charset, bool quirks, struct content **c) { nspng_content *png_c; nserror error; png_c = calloc(1, sizeof(nspng_content)); if (png_c == NULL) return NSERROR_NOMEM; error = content__init(&png_c->base, handler, imime_type, params, llcache, fallback_charset, quirks); if (error != NSERROR_OK) { free(png_c); return error; } error = nspng_create_png_data(png_c); if (error != NSERROR_OK) { free(png_c); return error; } *c = (struct content *)png_c; return NSERROR_OK; }
/** * Initialise a CSS content * * \param c Content to initialise * \param params Content-Type parameters * \return true on success, false on failure */ nserror nscss_create(const content_handler *handler, lwc_string *imime_type, const http_parameter *params, llcache_handle *llcache, const char *fallback_charset, bool quirks, struct content **c) { nscss_content *result; const char *charset = NULL; const char *xnsbase = NULL; lwc_string *charset_value = NULL; union content_msg_data msg_data; nserror error; result = calloc(1, sizeof(nscss_content)); if (result == NULL) return NSERROR_NOMEM; error = content__init(&result->base, handler, imime_type, params, llcache, fallback_charset, quirks); if (error != NSERROR_OK) { free(result); return error; } /* Find charset specified on HTTP layer, if any */ error = http_parameter_list_find_item(params, css_charset, &charset_value); if (error != NSERROR_OK || lwc_string_length(charset_value) == 0) { /* No charset specified, use fallback, if any */ /** \todo libcss will take this as gospel, which is wrong */ charset = fallback_charset; } else { charset = lwc_string_data(charset_value); } /* Compute base URL for stylesheet */ xnsbase = llcache_handle_get_header(llcache, "X-NS-Base"); if (xnsbase == NULL) { xnsbase = nsurl_access(content_get_url(&result->base)); } error = nscss_create_css_data(&result->data, xnsbase, charset, result->base.quirks, nscss_content_done, result); if (error != NSERROR_OK) { msg_data.error = messages_get("NoMemory"); content_broadcast(&result->base, CONTENT_MSG_ERROR, msg_data); if (charset_value != NULL) lwc_string_unref(charset_value); free(result); return error; } if (charset_value != NULL) lwc_string_unref(charset_value); *c = (struct content *) result; return NSERROR_OK; }
static nserror nsbmp_create_bmp_data(nsbmp_content *bmp) { union content_msg_data msg_data; bmp_bitmap_callback_vt bmp_bitmap_callbacks = { .bitmap_create = nsbmp_bitmap_create, .bitmap_destroy = guit->bitmap->destroy, .bitmap_get_buffer = guit->bitmap->get_buffer, .bitmap_get_bpp = guit->bitmap->get_bpp }; bmp->bmp = calloc(sizeof(struct bmp_image), 1); if (bmp->bmp == NULL) { msg_data.error = messages_get("NoMemory"); content_broadcast(&bmp->base, CONTENT_MSG_ERROR, msg_data); return NSERROR_NOMEM; } bmp_create(bmp->bmp, &bmp_bitmap_callbacks); return NSERROR_OK; } static nserror nsbmp_create(const content_handler *handler, lwc_string *imime_type, const struct http_parameter *params, llcache_handle *llcache, const char *fallback_charset, bool quirks, struct content **c) { nsbmp_content *bmp; nserror error; bmp = calloc(1, sizeof(nsbmp_content)); if (bmp == NULL) return NSERROR_NOMEM; error = content__init(&bmp->base, handler, imime_type, params, llcache, fallback_charset, quirks); if (error != NSERROR_OK) { free(bmp); return error; } error = nsbmp_create_bmp_data(bmp); if (error != NSERROR_OK) { free(bmp); return error; } *c = (struct content *) bmp; return NSERROR_OK; }
static nserror nsvideo_create(const content_handler *handler, lwc_string *imime_type, const http_parameter *params, llcache_handle *llcache, const char *fallback_charset, bool quirks, struct content **c) { nsvideo_content *video; nserror error; GstBus *bus; video = calloc(1, sizeof(nsvideo_content)); if (video == NULL) return NSERROR_NOMEM; error = content__init(&video->base, handler, imime_type, params, llcache, fallback_charset, quirks); if (error != NSERROR_OK) { free(video); return error; } error = llcache_handle_force_stream(llcache); if (error != NSERROR_OK) { free(video); return error; } video->playbin = gst_element_factory_make("playbin2", NULL); if (video->playbin == NULL) { free(video); return NSERROR_NOMEM; } bus = gst_pipeline_get_bus(GST_PIPELINE(video->playbin)); gst_bus_add_watch(bus, (GstBusFunc) nsvideo_bus_call, video); gst_object_unref(bus); g_object_set(video->playbin, "uri", "appsrc://", NULL); g_signal_connect(video->playbin, "deep-notify::source", G_CALLBACK(nsvideo_source_event), video); /** \todo Create appsink & register with playbin */ gst_element_set_state(video->playbin, GST_STATE_PLAYING); *c = (struct content *) video; return NSERROR_OK; }
nserror amiga_dt_picture_create(const content_handler *handler, lwc_string *imime_type, const http_parameter *params, llcache_handle *llcache, const char *fallback_charset, bool quirks, struct content **c) { struct amiga_dt_picture_content *adt; nserror error; adt = calloc(1, sizeof(struct amiga_dt_picture_content)); if (adt == NULL) return NSERROR_NOMEM; error = content__init((struct content *)adt, handler, imime_type, params, llcache, fallback_charset, quirks); if (error != NSERROR_OK) { free(adt); return error; } *c = (struct content *)adt; return NSERROR_OK; }
/** * Content create entry point. */ static nserror nsjpeg_create(const content_handler *handler, lwc_string *imime_type, const http_parameter *params, llcache_handle *llcache, const char *fallback_charset, bool quirks, struct content **c) { struct content *jpeg; nserror error; jpeg = talloc_zero(0, struct content); if (jpeg == NULL) return NSERROR_NOMEM; error = content__init(jpeg, handler, imime_type, params, llcache, fallback_charset, quirks); if (error != NSERROR_OK) { talloc_free(jpeg); return error; } *c = jpeg; return NSERROR_OK; }
nserror artworks_create(const content_handler *handler, lwc_string *imime_type, const struct http_parameter *params, llcache_handle *llcache, const char *fallback_charset, bool quirks, struct content **c) { artworks_content *aw; nserror error; aw = calloc(1, sizeof(artworks_content)); if (aw == NULL) return NSERROR_NOMEM; error = content__init(&aw->base, handler, imime_type, params, llcache, fallback_charset, quirks); if (error != NSERROR_OK) { free(aw); return error; } *c = (struct content *) aw; return NSERROR_OK; }
static nserror nssprite_create(const content_handler *handler, lwc_string *imime_type, const struct http_parameter *params, llcache_handle *llcache, const char *fallback_charset, bool quirks, struct content **c) { nssprite_content *sprite; nserror error; sprite = calloc(1, sizeof(nssprite_content)); if (sprite == NULL) return NSERROR_NOMEM; error = content__init(&sprite->base, handler, imime_type, params, llcache, fallback_charset, quirks); if (error != NSERROR_OK) { free(sprite); return error; } *c = (struct content *) sprite; return NSERROR_OK; }