diff options
-rw-r--r-- | calendar/gui/dialogs/comp-editor.c | 15 | ||||
-rw-r--r-- | em-format/em-format.c | 25 | ||||
-rw-r--r-- | mail/em-composer-utils.c | 20 | ||||
-rw-r--r-- | mail/em-format-html-display.c | 14 | ||||
-rw-r--r-- | mail/em-utils.c | 16 | ||||
-rw-r--r-- | plugins/groupwise-features/install-shared.c | 14 | ||||
-rw-r--r-- | plugins/itip-formatter/itip-formatter.c | 17 | ||||
-rw-r--r-- | plugins/mail-to-task/mail-to-task.c | 13 |
8 files changed, 82 insertions, 52 deletions
diff --git a/calendar/gui/dialogs/comp-editor.c b/calendar/gui/dialogs/comp-editor.c index 5a97f037ad..6e3776d1fc 100644 --- a/calendar/gui/dialogs/comp-editor.c +++ b/calendar/gui/dialogs/comp-editor.c @@ -2891,7 +2891,8 @@ comp_editor_get_mime_attach_list (CompEditor *editor) EAttachment *attachment; CamelDataWrapper *wrapper; CamelMimePart *mime_part; - CamelStreamMem *mstream; + CamelStream *stream; + GByteArray *byte_array; guchar *buffer = NULL; const gchar *desc, *disp; gint column_id; @@ -2908,15 +2909,17 @@ comp_editor_get_mime_attach_list (CompEditor *editor) cal_mime_attach = g_malloc0 (sizeof (struct CalMimeAttach)); wrapper = camel_medium_get_content (CAMEL_MEDIUM (mime_part)); - mstream = (CamelStreamMem *) camel_stream_mem_new (); - camel_data_wrapper_decode_to_stream (wrapper, (CamelStream *) mstream); - buffer = g_memdup (mstream->buffer->data, mstream->buffer->len); + byte_array = g_byte_array_new (); + stream = camel_stream_mem_new_with_byte_array (byte_array); + + camel_data_wrapper_decode_to_stream (wrapper, stream); + buffer = g_memdup (byte_array->data, byte_array->len); camel_mime_part_set_content_id (mime_part, NULL); cal_mime_attach->encoded_data = (gchar *)buffer; - cal_mime_attach->length = mstream->buffer->len; + cal_mime_attach->length = byte_array->len; cal_mime_attach->filename = g_strdup (camel_mime_part_get_filename (mime_part)); desc = camel_mime_part_get_description (mime_part); if (!desc || *desc == '\0') @@ -2931,7 +2934,7 @@ comp_editor_get_mime_attach_list (CompEditor *editor) attach_list = g_slist_append (attach_list, cal_mime_attach); - camel_object_unref (mstream); + camel_object_unref (stream); } diff --git a/em-format/em-format.c b/em-format/em-format.c index c348e0f19f..ca4a269fcf 100644 --- a/em-format/em-format.c +++ b/em-format/em-format.c @@ -2036,18 +2036,27 @@ em_format_snoop_type (CamelMimePart *part) name_type = e_util_guess_mime_type (filename, FALSE); dw = camel_medium_get_content ((CamelMedium *)part); - if (!camel_data_wrapper_is_offline(dw)) { - CamelStreamMem *mem = (CamelStreamMem *)camel_stream_mem_new(); + if (!camel_data_wrapper_is_offline (dw)) { + GByteArray *byte_array; + CamelStream *stream; - if (camel_data_wrapper_decode_to_stream(dw, (CamelStream *)mem) > 0) { - gchar *ct = g_content_type_guess (filename, mem->buffer->data, mem->buffer->len, NULL); + byte_array = g_byte_array_new (); + stream = camel_stream_mem_new_with_byte_array (byte_array); - if (ct) - magic_type = g_content_type_get_mime_type (ct); + if (camel_data_wrapper_decode_to_stream (dw, stream) > 0) { + gchar *content_type; - g_free (ct); + content_type = g_content_type_guess ( + filename, byte_array->data, + byte_array->len, NULL); + + if (content_type != NULL) + magic_type = g_content_type_get_mime_type (content_type); + + g_free (content_type); } - camel_object_unref(mem); + + camel_object_unref (stream); } d(printf("snooped part, magic_type '%s' name_type '%s'\n", magic_type, name_type)); diff --git a/mail/em-composer-utils.c b/mail/em-composer-utils.c index ffa053712f..3bd5021f12 100644 --- a/mail/em-composer-utils.c +++ b/mail/em-composer-utils.c @@ -920,7 +920,8 @@ traverse_parts (GSList *clues, CamelMimeMessage *message, CamelDataWrapper *cont } else if (CAMEL_IS_MIME_PART (content)) { CamelMimePart *part = CAMEL_MIME_PART (content); CamelContentType *type; - CamelStream *mem; + CamelStream *stream; + GByteArray *byte_array; gchar *str; content = camel_medium_get_content (CAMEL_MEDIUM (part)); @@ -936,17 +937,18 @@ traverse_parts (GSList *clues, CamelMimeMessage *message, CamelDataWrapper *cont if (!camel_content_type_is (type, "text", "*")) return; - mem = camel_stream_mem_new (); - camel_data_wrapper_decode_to_stream (content, mem); + byte_array = g_byte_array_new (); + stream = camel_stream_mem_new_with_byte_array (byte_array); + camel_data_wrapper_decode_to_stream (content, stream); - str = g_strndup ((const gchar *)((CamelStreamMem *) mem)->buffer->data, ((CamelStreamMem *) mem)->buffer->len); - camel_object_unref (mem); + str = g_strndup ((gchar *) byte_array->data, byte_array->len); + camel_object_unref (stream); if (replace_variables (clues, message, &str)) { - mem = camel_stream_mem_new_with_buffer (str, strlen (str)); - camel_stream_reset (mem); - camel_data_wrapper_construct_from_stream (content, mem); - camel_object_unref (mem); + stream = camel_stream_mem_new_with_buffer (str, strlen (str)); + camel_stream_reset (stream); + camel_data_wrapper_construct_from_stream (content, stream); + camel_object_unref (stream); } g_free (str); diff --git a/mail/em-format-html-display.c b/mail/em-format-html-display.c index 54a768ec59..cca924ac9f 100644 --- a/mail/em-format-html-display.c +++ b/mail/em-format-html-display.c @@ -463,11 +463,12 @@ efhd_format_optional (EMFormat *emf, { gchar *classid, *html; struct _attach_puri *info; - CamelStream *stream; + CamelStream *stream = NULL; - if (CAMEL_IS_STREAM_FILTER (fstream) && ((CamelStreamFilter *) fstream)->source) - stream = ((CamelStreamFilter *) fstream)->source; - else + if (CAMEL_IS_STREAM_FILTER (fstream)) + stream = camel_stream_filter_get_source ( + CAMEL_STREAM_FILTER (fstream)); + if (stream == NULL) stream = fstream; classid = g_strdup_printf ("optional%s", emf->part_id->str); @@ -970,6 +971,7 @@ efhd_attachment_optional(EMFormatHTML *efh, GtkHTMLEmbedded *eb, EMFormatHTMLPOb GtkWidget *view; GtkAllocation allocation; GtkTextBuffer *buffer; + GByteArray *byte_array; /* FIXME: handle default shown case */ d(printf("adding attachment button/content for optional rendering\n")); @@ -1027,7 +1029,9 @@ efhd_attachment_optional(EMFormatHTML *efh, GtkHTMLEmbedded *eb, EMFormatHTMLPOb gtk_text_view_set_editable (GTK_TEXT_VIEW (view), FALSE); gtk_text_view_set_cursor_visible (GTK_TEXT_VIEW (view), FALSE); buffer = gtk_text_view_get_buffer(GTK_TEXT_VIEW (view)); - gtk_text_buffer_set_text (buffer, (gchar *)info->mstream->buffer->data, info->mstream->buffer->len); + byte_array = camel_stream_mem_get_byte_array (info->mstream); + gtk_text_buffer_set_text ( + buffer, (gchar *) byte_array->data, byte_array->len); camel_object_unref(info->mstream); info->mstream = NULL; gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (scroll), diff --git a/mail/em-utils.c b/mail/em-utils.c index ae6f01e7ea..a1dd9ea565 100644 --- a/mail/em-utils.c +++ b/mail/em-utils.c @@ -635,21 +635,25 @@ em_utils_read_messages_from_stream(CamelFolder *folder, CamelStream *stream) * Warning: This could block the ui for an extended period. **/ void -em_utils_selection_set_mailbox(GtkSelectionData *data, CamelFolder *folder, GPtrArray *uids) +em_utils_selection_set_mailbox (GtkSelectionData *data, + CamelFolder *folder, + GPtrArray *uids) { + GByteArray *byte_array; CamelStream *stream; GdkAtom target; target = gtk_selection_data_get_target (data); - stream = camel_stream_mem_new(); - if (em_utils_write_messages_to_stream(folder, uids, stream) == 0) + byte_array = g_byte_array_new (); + stream = camel_stream_mem_new_with_byte_array (byte_array); + + if (em_utils_write_messages_to_stream (folder, uids, stream) == 0) gtk_selection_data_set( data, target, 8, - ((CamelStreamMem *)stream)->buffer->data, - ((CamelStreamMem *)stream)->buffer->len); + byte_array->data, byte_array->len); - camel_object_unref(stream); + camel_object_unref (stream); } /** diff --git a/plugins/groupwise-features/install-shared.c b/plugins/groupwise-features/install-shared.c index b82027a946..c3be10312c 100644 --- a/plugins/groupwise-features/install-shared.c +++ b/plugins/groupwise-features/install-shared.c @@ -186,8 +186,9 @@ org_gnome_popup_wizard (EPlugin *ep, EMEventTargetMessage *target) const gchar *name; const gchar *email; CamelMimeMessage *msg = (CamelMimeMessage *) target->message; - CamelStreamMem *content; + CamelStream *stream; CamelDataWrapper *dw; + GByteArray *byte_array; gchar *start_message; if (!msg) @@ -205,9 +206,10 @@ org_gnome_popup_wizard (EPlugin *ep, EMEventTargetMessage *target) return; } - content = (CamelStreamMem *)camel_stream_mem_new(); - camel_data_wrapper_write_to_stream(dw, (CamelStream *)content); - camel_stream_write((CamelStream *)content, "", 1); + byte_array = g_byte_array_new (); + stream = camel_stream_mem_new_with_byte_array (byte_array); + camel_data_wrapper_write_to_stream (dw, stream); + camel_stream_write (stream, "", 1); from_addr = camel_mime_message_get_from ((CamelMimeMessage *)target->message); if (from_addr && camel_internet_address_get(from_addr, 0, &name, &email)) { @@ -218,7 +220,7 @@ org_gnome_popup_wizard (EPlugin *ep, EMEventTargetMessage *target) "Message from '%s'\n\n\n" "%s\n\n\n" "Click 'Apply' to install the shared folder\n\n"), - name, name, content->buffer->data); + name, name, byte_array->data); page = gtk_label_new (start_message); gtk_label_set_line_wrap (GTK_LABEL (page), TRUE); @@ -244,7 +246,7 @@ org_gnome_popup_wizard (EPlugin *ep, EMEventTargetMessage *target) } else g_warning ("Could not get the sender name"); - camel_object_unref(content); + camel_object_unref (stream); } } diff --git a/plugins/itip-formatter/itip-formatter.c b/plugins/itip-formatter/itip-formatter.c index ddec723c99..6a85f94ead 100644 --- a/plugins/itip-formatter/itip-formatter.c +++ b/plugins/itip-formatter/itip-formatter.c @@ -2524,7 +2524,8 @@ format_itip (EPlugin *ep, EMFormatHookTarget *target) gchar *classid; struct _itip_puri *puri; CamelDataWrapper *content; - CamelStream *mem; + CamelStream *stream; + GByteArray *byte_array; classid = g_strdup_printf("itip:///%s", ((EMFormat *) target->format)->part_id->str); @@ -2550,14 +2551,18 @@ format_itip (EPlugin *ep, EMFormatHookTarget *target) /* This is non-gui thread. Download the part for using in the main thread */ content = camel_medium_get_content ((CamelMedium *) target->part); - mem = camel_stream_mem_new (); - camel_data_wrapper_decode_to_stream (content, mem); - if (((CamelStreamMem *) mem)->buffer->len == 0) + byte_array = g_byte_array_new (); + stream = camel_stream_mem_new_with_byte_array (byte_array); + camel_data_wrapper_decode_to_stream (content, stream); + + if (byte_array->len == 0) puri->vcalendar = NULL; else - puri->vcalendar = g_strndup ((gchar *)((CamelStreamMem *) mem)->buffer->data, ((CamelStreamMem *) mem)->buffer->len); - camel_object_unref (mem); + puri->vcalendar = g_strndup ( + (gchar *) byte_array->data, byte_array->len); + + camel_object_unref (stream); camel_stream_printf (target->stream, "<table border=0 width=\"100%%\" cellpadding=3><tr>"); camel_stream_printf (target->stream, "<td valign=top><object classid=\"%s\"></object></td><td width=100%% valign=top>", classid); diff --git a/plugins/mail-to-task/mail-to-task.c b/plugins/mail-to-task/mail-to-task.c index 0ac562d92d..cebf779ee6 100644 --- a/plugins/mail-to-task/mail-to-task.c +++ b/plugins/mail-to-task/mail-to-task.c @@ -171,10 +171,11 @@ static void set_description (ECalComponent *comp, CamelMimeMessage *message) { CamelDataWrapper *content; - CamelStream *mem; + CamelStream *stream; CamelContentType *type; CamelMimePart *mime_part = CAMEL_MIME_PART (message); ECalComponentText text; + GByteArray *byte_array; GSList sl; gchar *str, *convert_str = NULL; gsize bytes_read, bytes_written; @@ -200,11 +201,11 @@ set_description (ECalComponent *comp, CamelMimeMessage *message) if (!camel_content_type_is (type, "text", "plain")) return; - mem = camel_stream_mem_new (); - camel_data_wrapper_decode_to_stream (content, mem); - - str = g_strndup ((const gchar *)((CamelStreamMem *) mem)->buffer->data, ((CamelStreamMem *) mem)->buffer->len); - camel_object_unref (mem); + byte_array = g_byte_array_new (); + stream = camel_stream_mem_new_with_byte_array (byte_array); + camel_data_wrapper_decode_to_stream (content, stream); + str = g_strndup ((gchar *) byte_array->data, byte_array->len); + camel_object_unref (stream); /* convert to UTF-8 string */ if (str && content->mime_type->params && content->mime_type->params->value) { |