Changeset 3387

Show
Ignore:
Timestamp:
02/09/08 13:09:17
Author:
pvanhoof
Message:
        • Added a tny_mime_part_get_decoded_stream API
        • This was a minor API change
Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/ChangeLog

    r3386 r3387  
    55        * Various smaller fixes and code improvements 
    66        * Has-attachment status detection improvement 
     7        * Added a tny_mime_part_get_decoded_stream API 
     8 
     9        * This was a minor API change 
    710 
    8112008-02-05  Philip Van Hoof <pvanhoof@gnome.org> 
  • trunk/libtinymail-camel/tny-camel-mime-part.c

    r3360 r3387  
    6363#include <camel/camel-mime-filter-windows.h> 
    6464 
     65static ssize_t camel_stream_format_text (CamelDataWrapper *dw, CamelStream *stream); 
     66 
    6567static void  
    6668tny_camel_mime_part_set_header_pair (TnyMimePart *self, const gchar *name, const gchar *value) 
     
    277279        TnyIterator *iter; 
    278280        const gchar *type = tny_mime_part_get_content_type (orig); 
    279         TnyStream *in_stream = tny_mime_part_get_stream (orig); 
     281        TnyStream *in_stream = tny_mime_part_get_decoded_stream (orig); 
    280282/* 
    281283        TnyList *header_pairs = tny_simple_list_new (); 
     
    827829        return retval; 
    828830} 
     831 
     832 
     833 
     834 
     835static TnyStream*  
     836tny_camel_mime_part_get_decoded_stream (TnyMimePart *self) 
     837{ 
     838        return TNY_CAMEL_MIME_PART_GET_CLASS (self)->get_decoded_stream(self); 
     839} 
     840 
     841static TnyStream*  
     842tny_camel_mime_part_get_decoded_stream_default (TnyMimePart *self) 
     843{ 
     844        TnyCamelMimePartPriv *priv = TNY_CAMEL_MIME_PART_GET_PRIVATE (self); 
     845        TnyStream *retval = NULL; 
     846        CamelDataWrapper *wrapper; 
     847        CamelMedium *medium; 
     848        CamelStream *stream = camel_stream_mem_new (); 
     849 
     850        g_mutex_lock (priv->part_lock); 
     851        medium =  CAMEL_MEDIUM (priv->part); 
     852        camel_object_ref (medium); 
     853        g_mutex_unlock (priv->part_lock); 
     854 
     855        wrapper = camel_medium_get_content_object (medium); 
     856 
     857        if (!wrapper) { 
     858                wrapper = camel_data_wrapper_new ();  
     859                camel_medium_set_content_object (medium, wrapper); 
     860                camel_object_unref (wrapper); 
     861        }  
     862 
     863        if (wrapper->stream) { 
     864                camel_stream_reset (wrapper->stream); 
     865 
     866                if (camel_content_type_is (wrapper->mime_type, "text", "*")) 
     867                        camel_stream_format_text (wrapper, stream); 
     868                else 
     869                        camel_data_wrapper_decode_to_stream (wrapper, stream); 
     870        } 
     871 
     872        retval = TNY_STREAM (tny_camel_stream_new (stream)); 
     873        camel_object_unref (stream); 
     874 
     875        tny_stream_reset (retval); 
     876        camel_object_unref (medium); 
     877 
     878        return retval; 
     879} 
     880 
    829881 
    830882static const gchar*  
  • trunk/libtinymail-camel/tny-camel-mime-part.h

    r3359 r3387  
    5353        gboolean (*content_type_is) (TnyMimePart *self, const gchar *content_type); 
    5454        TnyStream* (*get_stream) (TnyMimePart *self); 
     55        TnyStream* (*get_decoded_stream) (TnyMimePart *self); 
    5556        gssize (*decode_to_stream) (TnyMimePart *self, TnyStream *stream, GError **err); 
    5657        gssize (*write_to_stream) (TnyMimePart *self, TnyStream *stream, GError **err); 
  • trunk/libtinymail/tny-mime-part.c

    r3359 r3387  
    868868} 
    869869 
     870 
     871 
     872/** 
     873 * tny_mime_part_get_decoded_stream: 
     874 * @self: a #TnyMimePart 
     875 *  
     876 * Inefficiently get a stream for @self. The entire data of the part will be 
     877 * kept in memory until the returned value is unreferenced. 
     878 * 
     879 * returns: an in-memory stream 
     880 * since: 1.0 
     881 * audience: application-developer 
     882 **/ 
     883TnyStream*  
     884tny_mime_part_get_decoded_stream (TnyMimePart *self) 
     885{ 
     886        TnyStream *retval; 
     887 
     888#ifdef DBC /* require */ 
     889        g_assert (TNY_IS_MIME_PART (self)); 
     890        g_assert (TNY_MIME_PART_GET_IFACE (self)->get_decoded_stream!= NULL); 
     891#endif 
     892 
     893        retval = TNY_MIME_PART_GET_IFACE (self)->get_decoded_stream(self); 
     894 
     895#ifdef DBC /* ensure */ 
     896        g_assert (TNY_IS_STREAM (retval)); 
     897#endif 
     898 
     899        return retval; 
     900} 
     901 
    870902/** 
    871903 * tny_mime_part_get_content_type: 
  • trunk/libtinymail/tny-mime-part.h

    r3359 r3387  
    4747        gboolean (*content_type_is) (TnyMimePart *self, const gchar *content_type); 
    4848        TnyStream* (*get_stream) (TnyMimePart *self); 
     49        TnyStream* (*get_decoded_stream) (TnyMimePart *self); 
    4950        gssize (*decode_to_stream) (TnyMimePart *self, TnyStream *stream, GError **err); 
    5051        gssize (*write_to_stream) (TnyMimePart *self, TnyStream *stream, GError **err); 
     
    7980gboolean tny_mime_part_content_type_is (TnyMimePart *self, const gchar *type); 
    8081TnyStream* tny_mime_part_get_stream (TnyMimePart *self); 
     82TnyStream* tny_mime_part_get_decoded_stream (TnyMimePart *self); 
    8183gssize tny_mime_part_write_to_stream (TnyMimePart *self, TnyStream *stream, GError **err); 
    8284gint tny_mime_part_construct (TnyMimePart *self, TnyStream *stream, const gchar *mime_type, const gchar *transfer_encoding);