Commit db94bed1 authored by Daniel Espinosa Ortiz's avatar Daniel Espinosa Ortiz

Sealing GdaBinary: API change

parent 292f32c0
......@@ -427,7 +427,7 @@ rt_dump_tree_offset (RtNode *tree, gint offset)
g_free (copy);
g_print ("]\n");
}
else if (tree->binary.data) {
else if (gda_binary_get_data (tree->binary)) {
g_print ("BINARY\n");
}
else
......@@ -472,7 +472,7 @@ rt_dump_tree_to_string (RtNode *tree, GString *string)
}
g_string_append (string, "]|");
}
else if (tree->binary.data)
else if (gda_binary_get_data (tree->binary))
g_string_append (string, "BINARY|");
else
g_string_append_c (string, '|');
......@@ -500,8 +500,7 @@ rt_free_node (RtNode *node)
if (node->next)
rt_free_node (node->next);
g_free (node->text);
if (node->binary.data)
g_free (node->binary.data);
gda_binary_free (node->binary);
g_free (node);
}
......@@ -520,8 +519,8 @@ merge_text_node_child (RtNode *tree)
if (! child)
return FALSE;
if ((tree->markup == RT_MARKUP_NONE) && !tree->binary.data &&
(child->markup == RT_MARKUP_NONE) && ! child->child && child->text && !child->binary.data) {
if ((tree->markup == RT_MARKUP_NONE) && !gda_binary_get_data (tree->binary) &&
(child->markup == RT_MARKUP_NONE) && ! child->child && child->text && !gda_binary_get_data (child->binary)) {
if (tree->text) {
gchar *tmp;
tmp = tree->text;
......@@ -551,8 +550,8 @@ merge_text_node_siblings (RtNode *tree)
if (! tree->next)
break;
RtNode *next = tree->next;
if ((tree->markup == RT_MARKUP_NONE) && !tree->binary.data &&
(next->markup == RT_MARKUP_NONE) && !next->binary.data &&
if ((tree->markup == RT_MARKUP_NONE) && !gda_binary_get_data (tree->binary) &&
(next->markup == RT_MARKUP_NONE) && !gda_binary_get_data (next->binary) &&
! next->child && next->text) {
if (tree->text) {
gchar *tmp;
......@@ -581,17 +580,15 @@ merge_text_node_siblings (RtNode *tree)
static gboolean
merge_single_child_text (RtNode *tree)
{
if (! (tree->text || tree->binary.data) &&
if (! (tree->text || gda_binary_get_data (tree->binary)) &&
tree->child && !tree->child->next &&
! tree->child->child &&
(tree->child->text || tree->child->binary.data) &&
(tree->child->text || gda_binary_get_data (tree->child->binary)) &&
(tree->child->markup == RT_MARKUP_NONE)) {
tree->text = tree->child->text;
tree->child->text = NULL;
tree->binary.data = tree->child->binary.data;
tree->child->binary.data = NULL;
tree->binary.binary_length = tree->child->binary.binary_length;
tree->child->binary.binary_length = 0;
gda_binary_set_data (tree->binary, gda_binary_get_data (tree->child->binary), gda_binary_get_size (tree->child->binary));
gda_binary_reset_data (tree->child->binary);
rt_free_node (tree->child);
tree->child = NULL;
return TRUE;
......@@ -855,6 +852,7 @@ rt_parse_text (const gchar *text)
TextTag *current = NULL;
retnode = g_new0 (RtNode, 1);
retnode->binary = gda_binary_new ();
contextnode = retnode;
ptr = text;
......@@ -878,6 +876,7 @@ rt_parse_text (const gchar *text)
gchar *part;
RtNode *node;
node = g_new0 (RtNode, 1);
node->binary = gda_binary_new ();
node->parent = contextnode;
node->markup = RT_MARKUP_NONE;
if (prev == text)
......@@ -906,6 +905,7 @@ rt_parse_text (const gchar *text)
else {
RtNode *n;
n = g_new0 (RtNode, 1);
n->binary = gda_binary_new ();
n->parent = contextnode;
n->markup = RT_MARKUP_PARA;
n->text = array [i];
......@@ -919,7 +919,9 @@ rt_parse_text (const gchar *text)
else {
gchar *tmp;
tmp = remove_newlines_from_base64 (part);
node->binary.data = g_base64_decode_inplace (tmp, (gsize*) & node->binary.binary_length);
gsize size;
guchar *buffer = g_base64_decode_inplace (tmp, & size);
gda_binary_set_data (node->binary, buffer, size);
}
}
else {
......@@ -961,7 +963,7 @@ rt_parse_text (const gchar *text)
tmp, NULL);
g_free (tmp);
}
else if (lnode->binary.data) {
else if (gda_binary_get_data (lnode->binary)) {
TO_IMPLEMENT;
}
else
......@@ -985,6 +987,7 @@ rt_parse_text (const gchar *text)
if (! tag_matched) {
RtNode *node;
node = g_new0 (RtNode, 1);
node->binary = gda_binary_new ();
node->parent = contextnode;
node->offset = ssol;
node->markup = internal_markup_to_external (mt, &(node->offset));
......@@ -1001,6 +1004,7 @@ rt_parse_text (const gchar *text)
for (; i < node->offset; i++) {
RtNode *tmpn;
tmpn = g_new0 (RtNode, 1);
tmpn->binary = gda_binary_new ();
tmpn->parent = contextnode;
tmpn->markup = RT_MARKUP_LIST;
tmpn->offset = i;
......@@ -1018,6 +1022,7 @@ rt_parse_text (const gchar *text)
for (i = 0; i < node->offset; i++) {
RtNode *tmpn;
tmpn = g_new0 (RtNode, 1);
tmpn->binary = gda_binary_new ();
tmpn->parent = contextnode;
tmpn->markup = RT_MARKUP_LIST;
tmpn->offset = i;
......@@ -1169,9 +1174,9 @@ rich_text_node_to_docbook (RenderingContext *context, xmlNodePtr top_parent, RtN
#ifdef HAVE_GDKPIXBUF
GdkPixdata pixdata;
if (rtnode->binary.data &&
gdk_pixdata_deserialize (&pixdata, rtnode->binary.binary_length,
(guint8*) rtnode->binary.data, NULL)) {
if (gda_binary_get_data (rtnode->binary) &&
gdk_pixdata_deserialize (&pixdata, gda_binary_get_size (rtnode->binary),
(guint8*) gda_binary_get_data (rtnode->binary), NULL)) {
GdkPixbuf *pixbuf;
pixbuf = gdk_pixbuf_from_pixdata (&pixdata, TRUE, NULL);
if (pixbuf) {
......@@ -1189,9 +1194,9 @@ rich_text_node_to_docbook (RenderingContext *context, xmlNodePtr top_parent, RtN
#endif
if (!saved) {
if (rtnode->binary.data &&
g_file_set_contents (file, (gchar*) rtnode->binary.data,
rtnode->binary.binary_length, NULL)) {
if (gda_binary_get_data (rtnode->binary) &&
g_file_set_contents (file, (gchar*) gda_binary_get_data (rtnode->binary),
gda_binary_get_size (rtnode->binary), NULL)) {
g_print ("Writen BIN file '%s'\n", file);
saved = TRUE;
type = 2;
......@@ -1381,9 +1386,9 @@ rich_text_node_to_html (RenderingContext *context, xmlNodePtr top_parent, RtNode
#ifdef HAVE_GDKPIXBUF
GdkPixdata pixdata;
if (rtnode->binary.data &&
gdk_pixdata_deserialize (&pixdata, rtnode->binary.binary_length,
(guint8*) rtnode->binary.data, NULL)) {
if (gda_binary_get_data (rtnode->binary) &&
gdk_pixdata_deserialize (&pixdata, gda_binary_get_size (rtnode->binary),
(guint8*) gda_binary_get_data (rtnode->binary), NULL)) {
GdkPixbuf *pixbuf;
pixbuf = gdk_pixbuf_from_pixdata (&pixdata, TRUE, NULL);
if (pixbuf) {
......@@ -1401,9 +1406,9 @@ rich_text_node_to_html (RenderingContext *context, xmlNodePtr top_parent, RtNode
#endif
if (!saved) {
if (rtnode->binary.data &&
g_file_set_contents (file, (gchar*) rtnode->binary.data,
rtnode->binary.binary_length, NULL)) {
if (gda_binary_get_data (rtnode->binary) &&
g_file_set_contents (file, (gchar*) gda_binary_get_data (rtnode->binary),
gda_binary_get_size (rtnode->binary), NULL)) {
g_print ("Writen BIN file '%s'\n", file);
saved = TRUE;
type = 2;
......
......@@ -56,7 +56,7 @@ struct _RtNode {
RtMarkup markup;
gint offset;
gchar *text;
GdaBinary binary;
GdaBinary *binary;
};
RtNode *rt_parse_text (const gchar *text);
......
......@@ -81,9 +81,8 @@ file_load_cb (GtkWidget *button, BinMenu *menu)
if (g_file_get_contents (filename, &data, &length, &error)) {
GdaBinary *bin;
GValue *nvalue;
bin = g_new0 (GdaBinary, 1);
bin->data = (guchar*) data;
bin->binary_length = length;
bin = gda_binary_new ();
gda_binary_set_data (bin, (guchar*) data, length);
nvalue = gda_value_new (GDA_TYPE_BINARY);
gda_value_take_binary (nvalue, bin);
......@@ -119,24 +118,24 @@ export_data (BinMenu *menu, const gchar *filename, GError **error)
if (menu->entry_type == GDA_TYPE_BINARY) {
const GdaBinary *bin;
bin = gda_value_get_binary (menu->tmpvalue);
allok = g_file_set_contents (filename, (gchar *) bin->data,
bin->binary_length, error);
allok = g_file_set_contents (filename, (gchar *) gda_binary_get_data (bin),
gda_binary_get_size (bin), error);
}
else if (menu->entry_type == GDA_TYPE_BLOB) {
GdaBlob *blob;
blob = (GdaBlob*) gda_value_get_blob (menu->tmpvalue);
if (blob->op) {
if (gda_blob_get_op (blob)) {
GValue *dest_value;
GdaBlob *dest_blob;
dest_value = gda_value_new_blob_from_file (filename);
dest_blob = (GdaBlob*) gda_value_get_blob (dest_value);
allok = gda_blob_op_write_all (dest_blob->op, (GdaBlob*) blob);
allok = gda_blob_op_write_all (gda_blob_get_op (dest_blob), (GdaBlob*) blob);
gda_value_free (dest_value);
}
else
allok = g_file_set_contents (filename, (gchar *) ((GdaBinary*)blob)->data,
((GdaBinary*)blob)->binary_length, error);
allok = g_file_set_contents (filename, (gchar *) gda_binary_get_data (gda_blob_get_binary (blob)),
gda_binary_get_size (gda_blob_get_binary (blob)), error);
}
else
g_assert_not_reached ();
......@@ -297,7 +296,7 @@ common_bin_get_description (BinMenu *binmenu)
if (G_VALUE_TYPE (value) == GDA_TYPE_BINARY) {
const GdaBinary *bin;
bin = gda_value_get_binary (value);
size = format_size (bin->binary_length);
size = format_size (gda_binary_get_size (bin));
g_string_append (string, size);
g_free (size);
}
......@@ -305,10 +304,10 @@ common_bin_get_description (BinMenu *binmenu)
const GdaBlob *blob;
GdaBinary *bin;
blob = gda_value_get_blob (value);
bin = (GdaBinary *) blob;
if (blob->op) {
bin = gda_blob_get_binary (blob);
if (gda_blob_get_op (blob)) {
glong len;
len = gda_blob_op_get_length (blob->op);
len = gda_blob_op_get_length (gda_blob_get_op (blob));
if (len >= 0) {
size = format_size (len);
g_string_append (string, size);
......@@ -318,7 +317,7 @@ common_bin_get_description (BinMenu *binmenu)
g_string_append (string, _("Unknown size"));
}
else {
size = format_size (bin->binary_length);
size = format_size (gda_binary_get_size (bin));
g_string_append (string, size);
g_free (size);
}
......@@ -486,29 +485,29 @@ adjust_ctype (BinMenu *binmenu)
if (G_VALUE_TYPE (value) == GDA_TYPE_BINARY) {
const GdaBinary *bin;
bin = gda_value_get_binary (value);
binmenu->ctype = g_content_type_guess (NULL, bin->data, (gsize) bin->binary_length, NULL);
binmenu->ctype = g_content_type_guess (NULL, gda_binary_get_data (bin), (gsize) gda_binary_get_size (bin), NULL);
}
else if (G_VALUE_TYPE (value) == GDA_TYPE_BLOB) {
const GdaBlob *blob;
GdaBinary *bin;
blob = gda_value_get_blob (value);
bin = (GdaBinary *) blob;
if (blob->op) {
bin = gda_blob_get_binary (blob);
if (gda_blob_get_op (blob)) {
glong len;
len = gda_blob_op_get_length (blob->op);
len = gda_blob_op_get_length (gda_blob_get_op (blob));
if (len >= 0) {
GdaBlob *blob2;
blob2 = (GdaBlob*) gda_blob_copy ((gpointer) blob);
gda_blob_op_read (blob2->op, blob2, 0, 1024);
bin = (GdaBinary *) blob2;
binmenu->ctype = g_content_type_guess (NULL, bin->data,
(gsize) bin->binary_length, NULL);
gda_blob_op_read (gda_blob_get_op (blob2), blob2, 0, 1024);
bin = gda_blob_get_binary (blob2);
binmenu->ctype = g_content_type_guess (NULL, gda_binary_get_data (bin),
(gsize) gda_binary_get_size (bin), NULL);
gda_blob_free ((gpointer) blob2);
}
}
else
binmenu->ctype = g_content_type_guess (NULL, bin->data,
(gsize) bin->binary_length, NULL);
binmenu->ctype = g_content_type_guess (NULL, gda_binary_get_data (bin),
(gsize) gda_binary_get_size (bin), NULL);
}
else
g_assert_not_reached ();
......
......@@ -53,24 +53,24 @@ common_pict_load_data (PictOptions *options, const GValue *value, PictBinData *b
blob = (GdaBlob *) gda_value_get_blob ((GValue *) value);
g_assert (blob);
bin = (GdaBinary *) blob;
if (blob->op &&
(bin->binary_length != gda_blob_op_get_length (blob->op)))
gda_blob_op_read_all (blob->op, blob);
if (bin->binary_length > 0) {
bindata->data = g_new (guchar, bin->binary_length);
bindata->data_length = bin->binary_length;
memcpy (bindata->data, bin->data, bin->binary_length);
bin = gda_blob_get_binary (blob);
if (gda_blob_get_op (blob) &&
(gda_binary_get_size (bin) != gda_blob_op_get_length (gda_blob_get_op (blob))))
gda_blob_op_read_all (gda_blob_get_op (blob), blob);
if (gda_binary_get_size (bin) > 0) {
bindata->data = g_new (guchar, gda_binary_get_size (bin));
bindata->data_length = gda_binary_get_size (bin);
memcpy (bindata->data, gda_binary_get_data (bin), gda_binary_get_size (bin));
}
}
else if (G_VALUE_TYPE ((GValue *) value) == GDA_TYPE_BINARY) {
GdaBinary *bin;
bin = (GdaBinary *) gda_value_get_binary ((GValue *) value);
if (bin && bin->binary_length > 0) {
bindata->data = g_new (guchar, bin->binary_length);
bindata->data_length = bin->binary_length;
memcpy (bindata->data, bin->data, bin->binary_length);
if (bin && gda_binary_get_size (bin) > 0) {
bindata->data = g_new (guchar, gda_binary_get_size (bin));
bindata->data_length = gda_binary_get_size (bin);
memcpy (bindata->data, gda_binary_get_data (bin), gda_binary_get_size (bin));
}
else {
*out_icon_name = "dialog-error";
......@@ -588,19 +588,19 @@ common_pict_add_cached_pixbuf (PictOptions *options, const GValue *value, GdkPix
const GdaBinary *bin;
bin = gda_value_get_binary (value);
hash = g_new (gint, 1);
*hash = compute_hash (bin->data, bin->binary_length);
*hash = compute_hash (gda_binary_get_data (bin), gda_binary_get_size (bin));
g_hash_table_insert (options->pixbuf_hash, hash, g_object_ref (pixbuf));
}
else if (GDA_VALUE_HOLDS_BLOB (value)) {
const GdaBinary *bin;
const GdaBlob *blob;
blob = gda_value_get_blob (value);
bin = (GdaBinary *) blob;
bin = gda_binary_get_binary (blob);
if (bin) {
if (!bin->data && blob->op)
gda_blob_op_read_all (blob->op, (GdaBlob*) blob);
if (!gda_binary_get_data (bin) && gda_blob_get_op (blob))
gda_blob_op_read_all (gda_blob_get_op (blob), (GdaBlob*) blob);
hash = g_new (gint, 1);
*hash = compute_hash (bin->data, bin->binary_length);
*hash = compute_hash (gda_binary_get_data (bin), gda_binary_get_size (bin));
g_hash_table_insert (options->pixbuf_hash, hash, g_object_ref (pixbuf));
}
}
......@@ -623,7 +623,7 @@ common_pict_fetch_cached_pixbuf (PictOptions *options, const GValue *value)
const GdaBinary *bin;
bin = gda_value_get_binary (value);
if (bin) {
hash = compute_hash (bin->data, bin->binary_length);
hash = compute_hash (gda_binary_get_data (bin), gda_binary_get_size (bin));
pixbuf = g_hash_table_lookup (options->pixbuf_hash, &hash);
}
}
......@@ -631,11 +631,11 @@ common_pict_fetch_cached_pixbuf (PictOptions *options, const GValue *value)
const GdaBinary *bin;
const GdaBlob *blob;
blob = gda_value_get_blob (value);
bin = (GdaBinary *) blob;
bin = gda_blob_get_binary (blob);
if (bin) {
if (!bin->data && blob->op)
gda_blob_op_read_all (blob->op, (GdaBlob*) blob);
hash = compute_hash (bin->data, bin->binary_length);
if (!gda_binary_get_data (bin) && gda_blob_get_op (blob))
gda_blob_op_read_all (gda_blob_get_op (blob), (GdaBlob*) blob);
hash = compute_hash (gda_binary_get_data (bin), gda_binary_get_size (bin));
pixbuf = g_hash_table_lookup (options->pixbuf_hash, &hash);
}
}
......
......@@ -483,12 +483,12 @@ value_is_equal_to (GdauiEntryWrapper *mgwrap, const GValue *value)
blob = (GdaBlob*) gda_value_get_blob ((GValue *) value);
g_assert (blob);
bin = (GdaBinary *) blob;
if (blob->op &&
(bin->binary_length != gda_blob_op_get_length (blob->op)))
gda_blob_op_read_all (blob->op, blob);
bin = gda_blob_get_binary (blob);
if (gda_blob_get_op (blob) &&
(gda_binary_get_size (bin) != gda_blob_op_get_length (gda_blob_get_op (blob))))
gda_blob_op_read_all (gda_blob_get_op (blob), blob);
if (mgpict->priv->bindata.data)
return !memcmp (bin->data, mgpict->priv->bindata.data, MIN (mgpict->priv->bindata.data_length, bin->binary_length));
return !memcmp (gda_binary_get_data (bin), mgpict->priv->bindata.data, MIN (mgpict->priv->bindata.data_length, gda_binary_get_size (bin)));
else
return FALSE;
}
......@@ -497,7 +497,7 @@ value_is_equal_to (GdauiEntryWrapper *mgwrap, const GValue *value)
bin = (GdaBinary *) gda_value_get_binary ((GValue *) value);
if (bin && mgpict->priv->bindata.data)
return !memcmp (bin->data, mgpict->priv->bindata.data, MIN (mgpict->priv->bindata.data_length, bin->binary_length));
return !memcmp (gda_binary_get_data (bin), mgpict->priv->bindata.data, MIN (mgpict->priv->bindata.data_length, gda_binary_get_size (bin)));
else
return FALSE;
}
......
/*
/*
* Copyright (C) 2010 - 2015 Vivien Malerba <malerba@gnome-db.org>
* Copyright (C) 2011 Murray Cumming <murrayc@murrayc.com>
*
......@@ -191,24 +191,24 @@ real_set_value (GdauiEntryWrapper *mgwrap, const GValue *value)
const GdaBlob *blob;
GdaBinary *bin;
blob = gda_value_get_blob (value);
bin = (GdaBinary *) blob;
if (blob->op &&
(bin->binary_length != gda_blob_op_get_length (blob->op)))
gda_blob_op_read_all (blob->op, (GdaBlob*) blob);
if (g_utf8_validate ((gchar*) bin->data, bin->binary_length, NULL)) {
bin = gda_blob_get_binary (blob);
if (gda_blob_get_op (blob) &&
(gda_binary_get_size (bin) != gda_blob_op_get_length (gda_blob_op (blob))))
gda_blob_op_read_all (gda_blob_get_op (blob), (GdaBlob*) blob);
if (g_utf8_validate ((gchar*) gda_binary_get_data (bin), gda_binary_get_size (bin), NULL)) {
gdaui_rt_editor_set_contents (GDAUI_RT_EDITOR (mgtxt->priv->view),
(gchar*) bin->data,
bin->binary_length);
(gchar*) gda_binary_get_data (bin),
gda_binary_get_size (bin));
done = TRUE;
}
}
else if (G_VALUE_TYPE (value) == GDA_TYPE_BINARY) {
const GdaBinary *bin;
bin = gda_value_get_binary (value);
if (g_utf8_validate ((gchar*) bin->data, bin->binary_length, NULL)) {
if (g_utf8_validate ((gchar*) gda_binary_get_data (bin), gda_binary_get_size (bin), NULL)) {
gdaui_rt_editor_set_contents (GDAUI_RT_EDITOR (mgtxt->priv->view),
(gchar*) bin->data,
bin->binary_length);
(gchar*) gda_binary_get_data (bin),
gda_binary_get_size (bin));
done = TRUE;
}
}
......
......@@ -320,22 +320,22 @@ real_set_value (GdauiEntryWrapper *mgwrap, const GValue *value)
const GdaBlob *blob;
GdaBinary *bin;
blob = gda_value_get_blob (value);
bin = (GdaBinary *) blob;
if (blob->op &&
(bin->binary_length != gda_blob_op_get_length (blob->op)))
gda_blob_op_read_all (blob->op, (GdaBlob*) blob);
if (g_utf8_validate ((gchar*) bin->data, bin->binary_length, NULL)) {
gtk_text_buffer_set_text (mgtxt->priv->buffer, (gchar*) bin->data,
bin->binary_length);
bin = gda_blob_get_binary (blob);
if (gda_blob_get_op (blob) &&
(gda_binary_get_size (bin) != gda_blob_op_get_length (gda_blob_get_op (blob))))
gda_blob_op_read_all (gda_blob_get_op (blob), (GdaBlob*) blob);
if (g_utf8_validate ((gchar*) gda_binary_get_data (bin), gda_binary_get_size (bin), NULL)) {
gtk_text_buffer_set_text (mgtxt->priv->buffer, (gchar*) gda_binary_get_data (bin),
gda_binary_get_size (bin));
done = TRUE;
}
}
else if (G_VALUE_TYPE (value) == GDA_TYPE_BINARY) {
const GdaBinary *bin;
bin = gda_value_get_binary (value);
if (g_utf8_validate ((gchar*) bin->data, bin->binary_length, NULL)) {
gtk_text_buffer_set_text (mgtxt->priv->buffer, (gchar*) bin->data,
bin->binary_length);
if (g_utf8_validate ((gchar*) gda_binary_get_data (bin), gda_binary_get_size (bin), NULL)) {
gtk_text_buffer_set_text (mgtxt->priv->buffer, (gchar*) gda_binary_get_data (bin),
gda_binary_get_size (bin));
done = TRUE;
}
}
......
......@@ -1703,16 +1703,16 @@ menu_copy_row_cb (GtkWidget *widget, GdauiRawGrid *grid)
GdaBlob *blob;
blob = (GdaBlob *) gda_value_get_blob ((GValue *) cvalue);
g_assert (blob);
bin = (GdaBinary *) blob;
if (blob->op &&
(bin->binary_length != gda_blob_op_get_length (blob->op)))
gda_blob_op_read_all (blob->op, blob);
bin = gda_blob_get_binary (blob);
if (gda_blob_get_op (blob) &&
(gda_binary_get_size (bin) != gda_blob_op_get_length (gda_blob_get_op (blob))))
gda_blob_op_read_all (gda_blob_get_op (blob), blob);
}
if (bin) {
GdkPixbufLoader *loader;
GdkPixbuf *pixbuf = NULL;
loader = gdk_pixbuf_loader_new ();
if (gdk_pixbuf_loader_write (loader, bin->data, bin->binary_length, NULL)) {
if (gdk_pixbuf_loader_write (loader, gda_binary_get_data (bin), gda_binary_get_size (bin), NULL)) {
if (gdk_pixbuf_loader_close (loader, NULL)) {
pixbuf = gdk_pixbuf_loader_get_pixbuf (loader);
g_object_ref (pixbuf);
......
......@@ -180,6 +180,7 @@ gda_dir_blob_op_read (GdaBlobOp *op, GdaBlob *blob, glong offset, glong size)
GdaBinary *bin;
FILE *file;
size_t nread;
guchar *buffer;
g_return_val_if_fail (GDA_IS_DIR_BLOB_OP (op), -1);
dirop = GDA_DIR_BLOB_OP (op);
......@@ -199,14 +200,11 @@ gda_dir_blob_op_read (GdaBlobOp *op, GdaBlob *blob, glong offset, glong size)
return -1;
}
bin = (GdaBinary *) blob;
if (bin->data) {
g_free (bin->data);
bin->data = NULL;
}
bin->data = g_new0 (guchar, size);
nread = fread ((char *) (bin->data), 1, size, file);
bin->binary_length = nread;
bin = gda_blob_get_binary (blob);
gda_binary_reset_data (bin);
buffer = g_new0 (guchar, size);
nread = fread ((char *) (buffer), 1, size, file);
gda_binary_set_data (bin, buffer, nread);
fclose (file);
return nread;
......@@ -240,25 +238,26 @@ gda_dir_blob_op_write (GdaBlobOp *op, GdaBlob *blob, glong offset)
}
}
if (blob->op && (blob->op != op)) {
if (gda_blob_get_op (blob) && (gda_blob_get_op (blob) != op)) {
/* use data through blob->op */
#define buf_size 16384
gint nread = 0;
GdaBlob *tmpblob = g_new0 (GdaBlob, 1);
gda_blob_set_op (tmpblob, blob->op);
GdaBlob *tmpblob = gda_blob_new ();
gda_blob_set_op (tmpblob, gda_blob_get_op (blob));
nbwritten = 0;
for (nread = gda_blob_op_read (tmpblob->op, tmpblob, 0, buf_size);
for (nread = gda_blob_op_read (gda_blob_get_op (tmpblob), tmpblob, 0, buf_size);
nread > 0;
nread = gda_blob_op_read (tmpblob->op, tmpblob, nbwritten, buf_size)) {
GdaBinary *bin = (GdaBinary *) tmpblob;
nread = gda_blob_op_read (gda_blob_get_op (tmpblob), tmpblob, nbwritten, buf_size)) {
GdaBinary *bin = gda_blob_get_binary (tmpblob);
glong tmp_written;
tmp_written = fwrite ((char *) (bin->data), sizeof (guchar), bin->binary_length, file);
if (tmp_written < bin->binary_length) {
guchar *buffer;
tmp_written = fwrite ((char *) (buffer), sizeof (guchar), gda_binary_get_size (bin), file);
if (tmp_written < gda_binary_get_size (bin)) {
/* error writing stream */
fclose (file);
gda_blob_free ((gpointer) tmpblob);
gda_blob_free (tmpblob);
return -1;
}
nbwritten += tmp_written;
......@@ -267,11 +266,11 @@ gda_dir_blob_op_write (GdaBlobOp *op, GdaBlob *blob, glong offset)
break;
}
fclose (file);
gda_blob_free ((gpointer) tmpblob);
gda_blob_free (tmpblob);
}
else {
bin = (GdaBinary *) blob;
nbwritten = fwrite ((char *) (bin->data), 1, bin->binary_length, file);
nbwritten = fwrite ((char *) (gda_binary_get_data (bin)), 1, gda_binary_get_size (bin), file);
fclose (file);
}
......
......@@ -332,9 +332,9 @@ gda_blob_op_read_all (GdaBlobOp *op, GdaBlob *blob)
g_return_val_if_fail (GDA_IS_BLOB_OP (op), FALSE);
g_return_val_if_fail (blob, FALSE);
len = gda_blob_op_get_length (blob->op);
len = gda_blob_op_get_length (gda_blob_get_op (blob));
if (len >= 0)
return (gda_blob_op_read (blob->op, blob, 0, len) < 0) ? FALSE : TRUE;
return (gda_blob_op_read (gda_blob_get_op (blob), blob, 0, len) < 0) ? FALSE : TRUE;
else
return FALSE;
}
......
......@@ -832,7 +832,7 @@ gda_data_model_dir_get_value_at (GdaDataModel *model, gint col, gint row, GError
GdaBlobOp *op;
gchar *filename;
blob = g_new0 (GdaBlob, 1);
blob = gda_blob_new ();
/* file mapping in mem */
filename = compute_filename (imodel, frow);
......@@ -1029,8 +1029,8 @@ gda_data_model_dir_set_values (GdaDataModel *model, gint row, GList *values, GEr
if (frow->data_value) {
GdaBlob *blob;
blob = (GdaBlob *) gda_value_get_blob (frow->data_value);