* mu-msg-part.c, mu-msg-sexp.c: handle parts with unknown (or zero) size
correctly, set :size to -1 so front-end can deal with it appropriately.
This commit is contained in:
@ -130,7 +130,8 @@ mu_msg_part_get_text (MuMsgPart *self, gboolean *err)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/* note: this will return -1 in case of error or if the size is
|
||||||
|
* unknown */
|
||||||
static ssize_t
|
static ssize_t
|
||||||
get_part_size (GMimePart *part)
|
get_part_size (GMimePart *part)
|
||||||
{
|
{
|
||||||
@ -143,11 +144,11 @@ get_part_size (GMimePart *part)
|
|||||||
|
|
||||||
stream = g_mime_data_wrapper_get_stream (wrapper);
|
stream = g_mime_data_wrapper_get_stream (wrapper);
|
||||||
if (!stream)
|
if (!stream)
|
||||||
return -1;
|
return -1; /* no stream -> size is 0 */
|
||||||
|
else
|
||||||
|
return g_mime_stream_length (stream);
|
||||||
|
|
||||||
/* NOTE: it seems we shouldn't unref stream/wrapper */
|
/* NOTE: it seems we shouldn't unref stream/wrapper */
|
||||||
|
|
||||||
return g_mime_stream_length (stream);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@ -49,8 +49,8 @@ struct _MuMsgPart {
|
|||||||
/* usually, "attachment" or "inline" */
|
/* usually, "attachment" or "inline" */
|
||||||
char *disposition;
|
char *disposition;
|
||||||
|
|
||||||
/* size of the part; or <= 0 if unknown */
|
/* size of the part; or < 0 if unknown */
|
||||||
size_t size;
|
ssize_t size;
|
||||||
|
|
||||||
gpointer data; /* opaque data */
|
gpointer data; /* opaque data */
|
||||||
|
|
||||||
|
|||||||
@ -222,11 +222,11 @@ each_part (MuMsg *msg, MuMsgPart *part, gchar **parts)
|
|||||||
name = g_strdup_printf ("\"part-%d\"", part->index);
|
name = g_strdup_printf ("\"part-%d\"", part->index);
|
||||||
|
|
||||||
tmp = g_strdup_printf
|
tmp = g_strdup_printf
|
||||||
("%s(:index %d :name %s :mime-type \"%s/%s\" :size %u)",
|
("%s(:index %d :name %s :mime-type \"%s/%s\" :size %i)",
|
||||||
*parts ? *parts : "", part->index, name,
|
*parts ? *parts : "", part->index, name,
|
||||||
part->type ? part->type : "application",
|
part->type ? part->type : "application",
|
||||||
part->subtype ? part->subtype : "octet-stream",
|
part->subtype ? part->subtype : "octet-stream",
|
||||||
(unsigned)part->size);
|
(int)part->size);
|
||||||
|
|
||||||
g_free (*parts);
|
g_free (*parts);
|
||||||
*parts = tmp;
|
*parts = tmp;
|
||||||
|
|||||||
Reference in New Issue
Block a user