2006-02-26 05:25:19 +03:00
|
|
|
/*
|
|
|
|
* Copyright 2006 Richard Wilson <info@tinct.net>
|
2007-08-08 20:16:03 +04:00
|
|
|
*
|
|
|
|
* This file is part of NetSurf, http://www.netsurf-browser.org/
|
|
|
|
*
|
|
|
|
* NetSurf is free software; you can redistribute it and/or modify
|
|
|
|
* it under the terms of the GNU General Public License as published by
|
|
|
|
* the Free Software Foundation; version 2 of the License.
|
|
|
|
*
|
|
|
|
* NetSurf is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
2006-02-26 05:25:19 +03:00
|
|
|
*/
|
|
|
|
|
2008-08-24 19:44:29 +04:00
|
|
|
/** \file
|
|
|
|
* Content for image/ico (implementation)
|
|
|
|
*/
|
|
|
|
|
2008-07-27 03:42:24 +04:00
|
|
|
#include "utils/config.h"
|
|
|
|
#ifdef WITH_BMP
|
|
|
|
|
2006-02-26 05:25:19 +03:00
|
|
|
#include <assert.h>
|
|
|
|
#include <string.h>
|
|
|
|
#include <stdbool.h>
|
|
|
|
#include <stdlib.h>
|
Merged revisions 4345-4346,4350-4351,4389,4391,4395,4401-4403,4423,4485-4486 via svnmerge from
svn://semichrome.net/branches/dynis/netsurf
........
r4345 | dynis | 2008-06-15 18:37:23 -0500 (Sun, 15 Jun 2008) | 1 line
Move NetSurf's gifread.h to libnsgif
........
r4346 | dynis | 2008-06-15 18:38:38 -0500 (Sun, 15 Jun 2008) | 1 line
Remove NetSurf's gifread.c (replaced by libnsgif)
........
r4350 | dynis | 2008-06-15 18:57:17 -0500 (Sun, 15 Jun 2008) | 1 line
Added references to libnsgif where necessary; corrected function calls where callbacks were implemented
........
r4351 | dynis | 2008-06-15 19:00:33 -0500 (Sun, 15 Jun 2008) | 1 line
Updated Makefile to compile with libnsgif
........
r4389 | dynis | 2008-06-18 13:58:51 -0500 (Wed, 18 Jun 2008) | 1 line
Altered bitmap callback table name for gif images to avoid ambiguity when bmp image library is created
........
r4391 | dynis | 2008-06-18 14:08:39 -0500 (Wed, 18 Jun 2008) | 1 line
Updated netsurf branch to use new bitmap callback table structure name that was altered in libnsgif
........
r4395 | dynis | 2008-06-18 14:54:51 -0500 (Wed, 18 Jun 2008) | 1 line
Corrected param comments for bitmap_set_suspendable()
........
r4401 | dynis | 2008-06-18 18:39:50 -0500 (Wed, 18 Jun 2008) | 1 line
Added references to libnsbmp where necessary; corrected function calls where callbacks were implemented
........
r4402 | dynis | 2008-06-18 18:40:47 -0500 (Wed, 18 Jun 2008) | 1 line
Updated Makefile to compile with libnsbmp
........
r4403 | dynis | 2008-06-18 18:41:53 -0500 (Wed, 18 Jun 2008) | 1 line
Remove NetSurf's bmpread.c and bmpread.h (replaced by libnsbmp)
........
r4423 | dynis | 2008-06-22 14:21:30 -0500 (Sun, 22 Jun 2008) | 1 line
Correct a silly mistake in nsbmp_bitmap_create
........
r4485 | dynis | 2008-07-01 04:13:48 -0500 (Tue, 01 Jul 2008) | 1 line
Integrated the latest versions of libnsgif and libnsbmp into NetSurf
........
r4486 | dynis | 2008-07-01 05:27:10 -0500 (Tue, 01 Jul 2008) | 1 line
Altered bitmap functions to receive void pointers for proper utilisation of libnsgif and libnsbmp
........
svn path=/trunk/netsurf/; revision=5071
2008-08-12 07:49:34 +04:00
|
|
|
#include <libnsbmp.h>
|
2007-05-31 02:39:54 +04:00
|
|
|
#include "utils/config.h"
|
2010-03-28 16:56:39 +04:00
|
|
|
#include "content/content_protected.h"
|
|
|
|
#include "content/hlcache.h"
|
2007-05-31 02:39:54 +04:00
|
|
|
#include "desktop/plotters.h"
|
|
|
|
#include "image/bitmap.h"
|
2011-05-07 00:40:09 +04:00
|
|
|
#include "image/bmp.h"
|
2007-05-31 02:39:54 +04:00
|
|
|
#include "image/ico.h"
|
|
|
|
#include "utils/log.h"
|
|
|
|
#include "utils/messages.h"
|
2011-05-07 00:40:09 +04:00
|
|
|
#include "utils/talloc.h"
|
2007-05-31 02:39:54 +04:00
|
|
|
#include "utils/utils.h"
|
2006-02-26 05:25:19 +03:00
|
|
|
|
2011-05-07 00:40:09 +04:00
|
|
|
typedef struct nsico_content {
|
|
|
|
struct content base;
|
|
|
|
|
|
|
|
struct ico_collection *ico; /** ICO collection data */
|
|
|
|
} nsico_content;
|
|
|
|
|
|
|
|
static const char *nsico_types[] = {
|
|
|
|
"application/ico",
|
|
|
|
"application/x-ico",
|
|
|
|
"image/ico",
|
|
|
|
"image/vnd.microsoft.icon",
|
|
|
|
"image/x-icon"
|
|
|
|
};
|
|
|
|
|
|
|
|
static lwc_string *nsico_mime_types[NOF_ELEMENTS(nsico_types)];
|
|
|
|
|
|
|
|
|
2011-05-08 23:54:35 +04:00
|
|
|
static nserror nsico_create_ico_data(nsico_content *c)
|
|
|
|
{
|
|
|
|
union content_msg_data msg_data;
|
2011-05-07 00:40:09 +04:00
|
|
|
|
2011-05-08 23:54:35 +04:00
|
|
|
c->ico = calloc(sizeof(ico_collection), 1);
|
|
|
|
if (c->ico == NULL) {
|
|
|
|
msg_data.error = messages_get("NoMemory");
|
|
|
|
content_broadcast(&c->base, CONTENT_MSG_ERROR, msg_data);
|
|
|
|
return NSERROR_NOMEM;
|
2011-05-07 00:40:09 +04:00
|
|
|
}
|
2011-05-08 23:54:35 +04:00
|
|
|
ico_collection_create(c->ico, &bmp_bitmap_callbacks);
|
2011-05-07 00:40:09 +04:00
|
|
|
return NSERROR_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2011-05-08 23:54:35 +04:00
|
|
|
static nserror nsico_create(const content_handler *handler,
|
2011-05-07 00:40:09 +04:00
|
|
|
lwc_string *imime_type, const struct http_parameter *params,
|
|
|
|
llcache_handle *llcache, const char *fallback_charset,
|
|
|
|
bool quirks, struct content **c)
|
|
|
|
{
|
|
|
|
nsico_content *result;
|
|
|
|
nserror error;
|
|
|
|
|
|
|
|
result = talloc_zero(0, nsico_content);
|
|
|
|
if (result == NULL)
|
|
|
|
return NSERROR_NOMEM;
|
|
|
|
|
|
|
|
error = content__init(&result->base, handler, imime_type, params,
|
|
|
|
llcache, fallback_charset, quirks);
|
|
|
|
if (error != NSERROR_OK) {
|
|
|
|
talloc_free(result);
|
|
|
|
return error;
|
|
|
|
}
|
|
|
|
|
|
|
|
error = nsico_create_ico_data(result);
|
|
|
|
if (error != NSERROR_OK) {
|
|
|
|
talloc_free(result);
|
|
|
|
return error;
|
|
|
|
}
|
|
|
|
|
|
|
|
*c = (struct content *) result;
|
|
|
|
|
|
|
|
return NSERROR_OK;
|
|
|
|
}
|
|
|
|
|
2006-02-26 05:25:19 +03:00
|
|
|
|
|
|
|
|
2011-05-08 23:54:35 +04:00
|
|
|
static bool nsico_convert(struct content *c)
|
2008-08-24 19:44:29 +04:00
|
|
|
{
|
2011-05-07 00:40:09 +04:00
|
|
|
nsico_content *ico = (nsico_content *) c;
|
2006-02-26 05:25:19 +03:00
|
|
|
struct bmp_image *bmp;
|
|
|
|
bmp_result res;
|
|
|
|
union content_msg_data msg_data;
|
2010-03-28 16:56:39 +04:00
|
|
|
const char *data;
|
|
|
|
unsigned long size;
|
2010-04-03 15:55:28 +04:00
|
|
|
char title[100];
|
2006-02-26 05:25:19 +03:00
|
|
|
|
Merged revisions 4345-4346,4350-4351,4389,4391,4395,4401-4403,4423,4485-4486 via svnmerge from
svn://semichrome.net/branches/dynis/netsurf
........
r4345 | dynis | 2008-06-15 18:37:23 -0500 (Sun, 15 Jun 2008) | 1 line
Move NetSurf's gifread.h to libnsgif
........
r4346 | dynis | 2008-06-15 18:38:38 -0500 (Sun, 15 Jun 2008) | 1 line
Remove NetSurf's gifread.c (replaced by libnsgif)
........
r4350 | dynis | 2008-06-15 18:57:17 -0500 (Sun, 15 Jun 2008) | 1 line
Added references to libnsgif where necessary; corrected function calls where callbacks were implemented
........
r4351 | dynis | 2008-06-15 19:00:33 -0500 (Sun, 15 Jun 2008) | 1 line
Updated Makefile to compile with libnsgif
........
r4389 | dynis | 2008-06-18 13:58:51 -0500 (Wed, 18 Jun 2008) | 1 line
Altered bitmap callback table name for gif images to avoid ambiguity when bmp image library is created
........
r4391 | dynis | 2008-06-18 14:08:39 -0500 (Wed, 18 Jun 2008) | 1 line
Updated netsurf branch to use new bitmap callback table structure name that was altered in libnsgif
........
r4395 | dynis | 2008-06-18 14:54:51 -0500 (Wed, 18 Jun 2008) | 1 line
Corrected param comments for bitmap_set_suspendable()
........
r4401 | dynis | 2008-06-18 18:39:50 -0500 (Wed, 18 Jun 2008) | 1 line
Added references to libnsbmp where necessary; corrected function calls where callbacks were implemented
........
r4402 | dynis | 2008-06-18 18:40:47 -0500 (Wed, 18 Jun 2008) | 1 line
Updated Makefile to compile with libnsbmp
........
r4403 | dynis | 2008-06-18 18:41:53 -0500 (Wed, 18 Jun 2008) | 1 line
Remove NetSurf's bmpread.c and bmpread.h (replaced by libnsbmp)
........
r4423 | dynis | 2008-06-22 14:21:30 -0500 (Sun, 22 Jun 2008) | 1 line
Correct a silly mistake in nsbmp_bitmap_create
........
r4485 | dynis | 2008-07-01 04:13:48 -0500 (Tue, 01 Jul 2008) | 1 line
Integrated the latest versions of libnsgif and libnsbmp into NetSurf
........
r4486 | dynis | 2008-07-01 05:27:10 -0500 (Tue, 01 Jul 2008) | 1 line
Altered bitmap functions to receive void pointers for proper utilisation of libnsgif and libnsbmp
........
svn path=/trunk/netsurf/; revision=5071
2008-08-12 07:49:34 +04:00
|
|
|
/* set the ico data */
|
2010-03-28 16:56:39 +04:00
|
|
|
data = content__get_source_data(c, &size);
|
|
|
|
|
Merged revisions 4345-4346,4350-4351,4389,4391,4395,4401-4403,4423,4485-4486 via svnmerge from
svn://semichrome.net/branches/dynis/netsurf
........
r4345 | dynis | 2008-06-15 18:37:23 -0500 (Sun, 15 Jun 2008) | 1 line
Move NetSurf's gifread.h to libnsgif
........
r4346 | dynis | 2008-06-15 18:38:38 -0500 (Sun, 15 Jun 2008) | 1 line
Remove NetSurf's gifread.c (replaced by libnsgif)
........
r4350 | dynis | 2008-06-15 18:57:17 -0500 (Sun, 15 Jun 2008) | 1 line
Added references to libnsgif where necessary; corrected function calls where callbacks were implemented
........
r4351 | dynis | 2008-06-15 19:00:33 -0500 (Sun, 15 Jun 2008) | 1 line
Updated Makefile to compile with libnsgif
........
r4389 | dynis | 2008-06-18 13:58:51 -0500 (Wed, 18 Jun 2008) | 1 line
Altered bitmap callback table name for gif images to avoid ambiguity when bmp image library is created
........
r4391 | dynis | 2008-06-18 14:08:39 -0500 (Wed, 18 Jun 2008) | 1 line
Updated netsurf branch to use new bitmap callback table structure name that was altered in libnsgif
........
r4395 | dynis | 2008-06-18 14:54:51 -0500 (Wed, 18 Jun 2008) | 1 line
Corrected param comments for bitmap_set_suspendable()
........
r4401 | dynis | 2008-06-18 18:39:50 -0500 (Wed, 18 Jun 2008) | 1 line
Added references to libnsbmp where necessary; corrected function calls where callbacks were implemented
........
r4402 | dynis | 2008-06-18 18:40:47 -0500 (Wed, 18 Jun 2008) | 1 line
Updated Makefile to compile with libnsbmp
........
r4403 | dynis | 2008-06-18 18:41:53 -0500 (Wed, 18 Jun 2008) | 1 line
Remove NetSurf's bmpread.c and bmpread.h (replaced by libnsbmp)
........
r4423 | dynis | 2008-06-22 14:21:30 -0500 (Sun, 22 Jun 2008) | 1 line
Correct a silly mistake in nsbmp_bitmap_create
........
r4485 | dynis | 2008-07-01 04:13:48 -0500 (Tue, 01 Jul 2008) | 1 line
Integrated the latest versions of libnsgif and libnsbmp into NetSurf
........
r4486 | dynis | 2008-07-01 05:27:10 -0500 (Tue, 01 Jul 2008) | 1 line
Altered bitmap functions to receive void pointers for proper utilisation of libnsgif and libnsbmp
........
svn path=/trunk/netsurf/; revision=5071
2008-08-12 07:49:34 +04:00
|
|
|
/* analyse the ico */
|
2011-05-07 00:40:09 +04:00
|
|
|
res = ico_analyse(ico->ico, size, (unsigned char *) data);
|
2008-08-24 19:44:29 +04:00
|
|
|
|
2006-02-26 05:25:19 +03:00
|
|
|
switch (res) {
|
2010-03-28 16:56:39 +04:00
|
|
|
case BMP_OK:
|
|
|
|
break;
|
|
|
|
case BMP_INSUFFICIENT_MEMORY:
|
|
|
|
msg_data.error = messages_get("NoMemory");
|
|
|
|
content_broadcast(c, CONTENT_MSG_ERROR, msg_data);
|
|
|
|
return false;
|
|
|
|
case BMP_INSUFFICIENT_DATA:
|
|
|
|
case BMP_DATA_ERROR:
|
|
|
|
msg_data.error = messages_get("BadICO");
|
|
|
|
content_broadcast(c, CONTENT_MSG_ERROR, msg_data);
|
|
|
|
return false;
|
2006-02-26 05:25:19 +03:00
|
|
|
}
|
|
|
|
|
2008-08-24 19:44:29 +04:00
|
|
|
/* Store our content width and description */
|
2011-05-07 00:40:09 +04:00
|
|
|
c->width = ico->ico->width;
|
|
|
|
c->height = ico->ico->height;
|
2010-04-03 15:55:28 +04:00
|
|
|
snprintf(title, sizeof(title), messages_get("ICOTitle"),
|
|
|
|
c->width, c->height, size);
|
|
|
|
content__set_title(c, title);
|
2011-05-07 00:40:09 +04:00
|
|
|
c->size += (ico->ico->width * ico->ico->height * 4) + 16 + 44;
|
2006-02-26 05:25:19 +03:00
|
|
|
|
|
|
|
/* exit as a success */
|
2011-05-07 00:40:09 +04:00
|
|
|
bmp = ico_find(ico->ico, 255, 255);
|
2006-02-26 05:25:19 +03:00
|
|
|
assert(bmp);
|
|
|
|
c->bitmap = bmp->bitmap;
|
2008-10-11 00:54:49 +04:00
|
|
|
bitmap_modified(c->bitmap);
|
2011-02-27 23:11:39 +03:00
|
|
|
|
|
|
|
content_set_ready(c);
|
|
|
|
content_set_done(c);
|
2008-10-11 00:54:49 +04:00
|
|
|
|
2008-03-10 15:41:41 +03:00
|
|
|
/* Done: update status bar */
|
|
|
|
content_set_status(c, "");
|
2006-02-26 05:25:19 +03:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2011-06-29 00:17:39 +04:00
|
|
|
static bool nsico_redraw(struct content *c, struct content_redraw_data *data,
|
2011-06-30 19:48:07 +04:00
|
|
|
const struct rect *clip, const struct redraw_context *ctx)
|
2008-08-24 19:44:29 +04:00
|
|
|
{
|
2011-05-07 00:40:09 +04:00
|
|
|
nsico_content *ico = (nsico_content *) c;
|
2011-06-29 00:17:39 +04:00
|
|
|
struct bmp_image *bmp = ico_find(ico->ico, data->width, data->height);
|
2009-06-30 17:02:23 +04:00
|
|
|
bitmap_flags_t flags = BITMAPF_NONE;
|
|
|
|
|
2006-02-26 05:25:19 +03:00
|
|
|
if (!bmp->decoded)
|
2009-06-30 17:02:23 +04:00
|
|
|
if (bmp_decode(bmp) != BMP_OK)
|
Merged revisions 4345-4346,4350-4351,4389,4391,4395,4401-4403,4423,4485-4486 via svnmerge from
svn://semichrome.net/branches/dynis/netsurf
........
r4345 | dynis | 2008-06-15 18:37:23 -0500 (Sun, 15 Jun 2008) | 1 line
Move NetSurf's gifread.h to libnsgif
........
r4346 | dynis | 2008-06-15 18:38:38 -0500 (Sun, 15 Jun 2008) | 1 line
Remove NetSurf's gifread.c (replaced by libnsgif)
........
r4350 | dynis | 2008-06-15 18:57:17 -0500 (Sun, 15 Jun 2008) | 1 line
Added references to libnsgif where necessary; corrected function calls where callbacks were implemented
........
r4351 | dynis | 2008-06-15 19:00:33 -0500 (Sun, 15 Jun 2008) | 1 line
Updated Makefile to compile with libnsgif
........
r4389 | dynis | 2008-06-18 13:58:51 -0500 (Wed, 18 Jun 2008) | 1 line
Altered bitmap callback table name for gif images to avoid ambiguity when bmp image library is created
........
r4391 | dynis | 2008-06-18 14:08:39 -0500 (Wed, 18 Jun 2008) | 1 line
Updated netsurf branch to use new bitmap callback table structure name that was altered in libnsgif
........
r4395 | dynis | 2008-06-18 14:54:51 -0500 (Wed, 18 Jun 2008) | 1 line
Corrected param comments for bitmap_set_suspendable()
........
r4401 | dynis | 2008-06-18 18:39:50 -0500 (Wed, 18 Jun 2008) | 1 line
Added references to libnsbmp where necessary; corrected function calls where callbacks were implemented
........
r4402 | dynis | 2008-06-18 18:40:47 -0500 (Wed, 18 Jun 2008) | 1 line
Updated Makefile to compile with libnsbmp
........
r4403 | dynis | 2008-06-18 18:41:53 -0500 (Wed, 18 Jun 2008) | 1 line
Remove NetSurf's bmpread.c and bmpread.h (replaced by libnsbmp)
........
r4423 | dynis | 2008-06-22 14:21:30 -0500 (Sun, 22 Jun 2008) | 1 line
Correct a silly mistake in nsbmp_bitmap_create
........
r4485 | dynis | 2008-07-01 04:13:48 -0500 (Tue, 01 Jul 2008) | 1 line
Integrated the latest versions of libnsgif and libnsbmp into NetSurf
........
r4486 | dynis | 2008-07-01 05:27:10 -0500 (Tue, 01 Jul 2008) | 1 line
Altered bitmap functions to receive void pointers for proper utilisation of libnsgif and libnsbmp
........
svn path=/trunk/netsurf/; revision=5071
2008-08-12 07:49:34 +04:00
|
|
|
return false;
|
2009-06-30 17:02:23 +04:00
|
|
|
|
2006-02-26 05:25:19 +03:00
|
|
|
c->bitmap = bmp->bitmap;
|
2009-06-30 17:02:23 +04:00
|
|
|
|
2011-06-29 00:17:39 +04:00
|
|
|
if (data->repeat_x)
|
2009-06-30 17:02:23 +04:00
|
|
|
flags |= BITMAPF_REPEAT_X;
|
2011-06-29 00:17:39 +04:00
|
|
|
if (data->repeat_y)
|
2009-06-30 17:02:23 +04:00
|
|
|
flags |= BITMAPF_REPEAT_Y;
|
|
|
|
|
2011-06-30 19:48:07 +04:00
|
|
|
return ctx->plot->bitmap(data->x, data->y, data->width, data->height,
|
2011-06-29 00:17:39 +04:00
|
|
|
c->bitmap, data->background_colour, flags);
|
2006-02-26 05:25:19 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2011-05-08 23:54:35 +04:00
|
|
|
static void nsico_destroy(struct content *c)
|
2006-02-26 05:25:19 +03:00
|
|
|
{
|
2011-05-07 00:40:09 +04:00
|
|
|
nsico_content *ico = (nsico_content *) c;
|
|
|
|
|
|
|
|
ico_finalise(ico->ico);
|
|
|
|
free(ico->ico);
|
2006-02-26 05:25:19 +03:00
|
|
|
}
|
|
|
|
|
2011-05-08 23:54:35 +04:00
|
|
|
static nserror nsico_clone(const struct content *old, struct content **newc)
|
2010-04-04 16:41:19 +04:00
|
|
|
{
|
2011-05-07 00:40:09 +04:00
|
|
|
nsico_content *ico;
|
|
|
|
nserror error;
|
|
|
|
|
|
|
|
ico = talloc_zero(0, nsico_content);
|
|
|
|
if (ico == NULL)
|
|
|
|
return NSERROR_NOMEM;
|
|
|
|
|
|
|
|
error = content__clone(old, &ico->base);
|
|
|
|
if (error != NSERROR_OK) {
|
|
|
|
content_destroy(&ico->base);
|
|
|
|
return error;
|
|
|
|
}
|
|
|
|
|
2010-04-04 16:41:19 +04:00
|
|
|
/* Simply replay creation and conversion */
|
2011-05-07 00:40:09 +04:00
|
|
|
error = nsico_create_ico_data(ico);
|
|
|
|
if (error != NSERROR_OK) {
|
|
|
|
content_destroy(&ico->base);
|
|
|
|
return error;
|
|
|
|
}
|
2010-04-04 16:41:19 +04:00
|
|
|
|
|
|
|
if (old->status == CONTENT_STATUS_READY ||
|
|
|
|
old->status == CONTENT_STATUS_DONE) {
|
2011-05-07 00:40:09 +04:00
|
|
|
if (nsico_convert(&ico->base) == false) {
|
|
|
|
content_destroy(&ico->base);
|
|
|
|
return NSERROR_CLONE_FAILED;
|
|
|
|
}
|
2010-04-04 16:41:19 +04:00
|
|
|
}
|
|
|
|
|
2011-05-07 00:40:09 +04:00
|
|
|
*newc = (struct content *) ico;
|
|
|
|
|
|
|
|
return NSERROR_OK;
|
|
|
|
}
|
|
|
|
|
2011-05-08 23:54:35 +04:00
|
|
|
static content_type nsico_content_type(lwc_string *mime_type)
|
2011-05-07 00:40:09 +04:00
|
|
|
{
|
|
|
|
return CONTENT_IMAGE;
|
2010-04-04 16:41:19 +04:00
|
|
|
}
|
|
|
|
|
2011-05-08 23:54:35 +04:00
|
|
|
static const content_handler nsico_content_handler = {
|
2011-05-09 19:32:34 +04:00
|
|
|
.create = nsico_create,
|
|
|
|
.data_complete = nsico_convert,
|
|
|
|
.destroy = nsico_destroy,
|
|
|
|
.redraw = nsico_redraw,
|
|
|
|
.clone = nsico_clone,
|
|
|
|
.type = nsico_content_type,
|
|
|
|
.no_share = false,
|
2011-05-08 23:54:35 +04:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
nserror nsico_init(void)
|
|
|
|
{
|
|
|
|
uint32_t i;
|
|
|
|
lwc_error lerror;
|
|
|
|
nserror error;
|
|
|
|
|
|
|
|
for (i = 0; i < NOF_ELEMENTS(nsico_mime_types); i++) {
|
|
|
|
lerror = lwc_intern_string(nsico_types[i],
|
|
|
|
strlen(nsico_types[i]),
|
|
|
|
&nsico_mime_types[i]);
|
|
|
|
if (lerror != lwc_error_ok) {
|
|
|
|
error = NSERROR_NOMEM;
|
|
|
|
goto error;
|
|
|
|
}
|
|
|
|
|
|
|
|
error = content_factory_register_handler(nsico_mime_types[i],
|
|
|
|
&nsico_content_handler);
|
|
|
|
if (error != NSERROR_OK)
|
|
|
|
goto error;
|
|
|
|
}
|
|
|
|
|
|
|
|
return NSERROR_OK;
|
|
|
|
|
|
|
|
error:
|
|
|
|
nsico_fini();
|
|
|
|
|
|
|
|
return error;
|
|
|
|
}
|
|
|
|
|
|
|
|
void nsico_fini(void)
|
|
|
|
{
|
|
|
|
uint32_t i;
|
|
|
|
|
|
|
|
for (i = 0; i < NOF_ELEMENTS(nsico_mime_types); i++) {
|
|
|
|
if (nsico_mime_types[i] != NULL)
|
|
|
|
lwc_string_unref(nsico_mime_types[i]);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2006-02-26 05:25:19 +03:00
|
|
|
#endif
|