Changeset 3248

Show
Ignore:
Timestamp:
01/13/08 12:21:55
Author:
pvanhoof
Message:

2008-01-13 Philip Van Hoof <pvanhoof@gnome.org>

        • Changed tny_mime_part_construct_from_stream to

tny_mime_part_construct, added a parameter for the
content-transfer-encoding too

        • This was a major API change
Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/ChangeLog

    r3246 r3248  
     12008-01-13  Philip Van Hoof <pvanhoof@gnome.org> 
     2 
     3        * Changed tny_mime_part_construct_from_stream to 
     4        tny_mime_part_construct, added a parameter for the 
     5        content-transfer-encoding too 
     6 
     7        * This was a major API change 
     8 
    192008-01-12  Philip Van Hoof <pvanhoof@gnome.org> 
    210 
  • trunk/libtinymail-camel/tny-camel-bs-mime-part.c

    r3235 r3248  
    635635 
    636636static gint 
    637 tny_camel_bs_mime_part_construct_from_stream (TnyMimePart *self, TnyStream *stream, const gchar *type
    638 { 
    639         return TNY_CAMEL_BS_MIME_PART_GET_CLASS (self)->construct_from_stream_func (self, stream, type); 
     637tny_camel_bs_mime_part_construct (TnyMimePart *self, TnyStream *stream, const gchar *mime_type, const gchar *transfer_encoding
     638{ 
     639        return TNY_CAMEL_BS_MIME_PART_GET_CLASS (self)->construct_func (self, stream, mime_type, transfer_encoding); 
    640640} 
    641641 
    642642static gint 
    643 tny_camel_bs_mime_part_construct_from_stream_default (TnyMimePart *self, TnyStream *stream, const gchar *type
     643tny_camel_bs_mime_part_construct_default (TnyMimePart *self, TnyStream *stream, const gchar *mime_type, const gchar* transfer_encoding
    644644{ 
    645645        return -1; 
    646646} 
     647 
     648static const gchar*  
     649tny_camel_bs_mime_part_get_transfer_encoding (TnyMimePart *self) 
     650{ 
     651        return TNY_CAMEL_BS_MIME_PART_GET_CLASS (self)->get_transfer_encoding_func (self); 
     652} 
     653 
     654static const gchar*  
     655tny_camel_bs_mime_part_get_transfer_encoding_default (TnyMimePart *self) 
     656{ 
     657        TnyCamelBsMimePartPriv *priv = TNY_CAMEL_BS_MIME_PART_GET_PRIVATE (self); 
     658        return priv->bodystructure->encoding; 
     659} 
     660 
    647661 
    648662static TnyStream*  
     
    9951009        klass->get_stream_func = tny_camel_bs_mime_part_get_stream; 
    9961010        klass->write_to_stream_func = tny_camel_bs_mime_part_write_to_stream; 
    997         klass->construct_from_stream_func = tny_camel_bs_mime_part_construct_from_stream
     1011        klass->construct_func = tny_camel_bs_mime_part_construct
    9981012        klass->get_filename_func = tny_camel_bs_mime_part_get_filename; 
    9991013        klass->get_content_id_func = tny_camel_bs_mime_part_get_content_id; 
     
    10151029        klass->set_header_pair_func = tny_camel_bs_mime_part_set_header_pair; 
    10161030        klass->decode_to_stream_async_func = tny_camel_bs_mime_part_decode_to_stream_async; 
    1017  
     1031        klass->get_transfer_encoding_func = tny_camel_bs_mime_part_get_transfer_encoding; 
    10181032        return; 
    10191033} 
     
    10321046        class->get_stream_func = tny_camel_bs_mime_part_get_stream_default; 
    10331047        class->write_to_stream_func = tny_camel_bs_mime_part_write_to_stream_default; 
    1034         class->construct_from_stream_func = tny_camel_bs_mime_part_construct_from_stream_default; 
     1048        class->construct_func = tny_camel_bs_mime_part_construct_default; 
    10351049        class->get_filename_func = tny_camel_bs_mime_part_get_filename_default; 
    10361050        class->get_content_id_func = tny_camel_bs_mime_part_get_content_id_default; 
     
    10521066        class->set_header_pair_func = tny_camel_bs_mime_part_set_header_pair_default; 
    10531067        class->decode_to_stream_async_func = tny_camel_bs_mime_part_decode_to_stream_async_default; 
     1068        class->get_transfer_encoding_func = tny_camel_bs_mime_part_get_transfer_encoding_default; 
    10541069 
    10551070        object_class->finalize = tny_camel_bs_mime_part_finalize; 
  • trunk/libtinymail-camel/tny-camel-bs-mime-part.h

    r3171 r3248  
    5353        gssize (*decode_to_stream_func) (TnyMimePart *self, TnyStream *stream, GError **err); 
    5454        gssize (*write_to_stream_func) (TnyMimePart *self, TnyStream *stream, GError **err); 
    55         gint (*construct_from_stream_func) (TnyMimePart *self, TnyStream *stream, const gchar *type); 
     55        gint (*construct_func) (TnyMimePart *self, TnyStream *stream, const gchar *mime_type, const gchar *transfer_encoding); 
    5656        const gchar* (*get_filename_func) (TnyMimePart *self); 
    5757        const gchar* (*get_content_id_func) (TnyMimePart *self); 
     
    7272        void (*set_header_pair_func) (TnyMimePart *self, const gchar *name, const gchar *value); 
    7373        void (*decode_to_stream_async_func) (TnyMimePart *self, TnyStream *stream, TnyMimePartCallback callback, TnyStatusCallback status_callback, gpointer user_data); 
     74        const gchar* (*get_transfer_encoding_func) (TnyMimePart *self); 
    7475}; 
    7576 
  • trunk/libtinymail-camel/tny-camel-mime-part.c

    r3243 r3248  
    311311        } 
    312312 
    313         tny_mime_part_construct_from_stream (piece, in_stream, type); 
     313        tny_mime_part_construct (piece, in_stream, type, tny_mime_part_get_transfer_encoding (orig)); 
    314314 
    315315        if (tny_mime_part_get_description (orig)) 
     
    365365} 
    366366 
     367static const gchar*  
     368tny_camel_mime_part_get_transfer_encoding (TnyMimePart *self) 
     369{ 
     370        return TNY_CAMEL_MIME_PART_GET_CLASS (self)->get_transfer_encoding_func (self); 
     371} 
     372 
     373static const gchar*  
     374tny_camel_mime_part_get_transfer_encoding_default (TnyMimePart *self) 
     375{ 
     376        TnyCamelMimePartPriv *priv = TNY_CAMEL_MIME_PART_GET_PRIVATE (self); 
     377        CamelTransferEncoding encoding =  camel_mime_part_get_encoding (priv->part); 
     378        const char *text = camel_transfer_encoding_to_string (encoding); 
     379        return (const gchar *) text; 
     380} 
     381 
    367382static gint 
    368383tny_camel_mime_part_add_part_default (TnyMimePart *self, TnyMimePart *part) 
     
    700715 
    701716static gint 
    702 tny_camel_mime_part_construct_from_stream (TnyMimePart *self, TnyStream *stream, const gchar *type
    703 { 
    704         return TNY_CAMEL_MIME_PART_GET_CLASS (self)->construct_from_stream_func (self, stream, type); 
     717tny_camel_mime_part_construct (TnyMimePart *self, TnyStream *stream, const gchar *mime_type, const gchar *transfer_encoding
     718{ 
     719        return TNY_CAMEL_MIME_PART_GET_CLASS (self)->construct_func (self, stream, mime_type, transfer_encoding); 
    705720} 
    706721 
    707722static gint 
    708 tny_camel_mime_part_construct_from_stream_default (TnyMimePart *self, TnyStream *stream, const gchar *type
     723tny_camel_mime_part_construct_default (TnyMimePart *self, TnyStream *stream, const gchar *mime_type, const gchar *transfer_encoding
    709724{ 
    710725        TnyCamelMimePartPriv *priv = TNY_CAMEL_MIME_PART_GET_PRIVATE (self); 
     
    713728        CamelMedium *medium; 
    714729        CamelStream *cstream; 
     730        CamelTransferEncoding encoding; 
    715731 
    716732        g_assert (TNY_IS_STREAM (stream)); 
     
    720736        g_mutex_lock (priv->part_lock); 
    721737 
    722         if (type && g_ascii_strncasecmp (type, "text", 4) != 0 && g_ascii_strcasecmp (type, "message/rfc822") != 0) 
    723                 camel_mime_part_set_encoding (priv->part,  
    724                         CAMEL_TRANSFER_ENCODING_BASE64); 
     738        encoding = camel_transfer_encoding_from_string (transfer_encoding); 
     739        camel_mime_part_set_encoding (priv->part, encoding); 
    725740 
    726741        medium = CAMEL_MEDIUM (priv->part); 
     
    733748                camel_object_unref (CAMEL_OBJECT (wrapper)); 
    734749 
    735         if (type && g_ascii_strcasecmp (type, "message/rfc822") == 0) 
     750        if (mime_type && g_ascii_strcasecmp (mime_type, "message/rfc822") == 0) 
    736751                wrapper = (CamelDataWrapper *) camel_mime_message_new (); 
    737752        else 
     
    739754 
    740755        retval = camel_data_wrapper_construct_from_stream (wrapper, cstream); 
    741         if (type) 
    742                 camel_data_wrapper_set_mime_type (wrapper, type); 
     756        if (mime_type) 
     757                camel_data_wrapper_set_mime_type (wrapper, mime_type); 
    743758 
    744759        camel_medium_set_content_object(medium, wrapper); 
     760 
     761        camel_mime_part_set_content_id (priv->part, NULL); 
    745762 
    746763        camel_object_unref (cstream); 
     
    11771194        klass->get_stream_func = tny_camel_mime_part_get_stream; 
    11781195        klass->write_to_stream_func = tny_camel_mime_part_write_to_stream; 
    1179         klass->construct_from_stream_func = tny_camel_mime_part_construct_from_stream
     1196        klass->construct_func = tny_camel_mime_part_construct
    11801197        klass->get_filename_func = tny_camel_mime_part_get_filename; 
    11811198        klass->get_content_id_func = tny_camel_mime_part_get_content_id; 
     
    11971214        klass->set_header_pair_func = tny_camel_mime_part_set_header_pair; 
    11981215        klass->decode_to_stream_async_func = tny_camel_mime_part_decode_to_stream_async; 
     1216        klass->get_transfer_encoding_func = tny_camel_mime_part_get_transfer_encoding; 
     1217 
    11991218        return; 
    12001219} 
     
    12131232        class->get_stream_func = tny_camel_mime_part_get_stream_default; 
    12141233        class->write_to_stream_func = tny_camel_mime_part_write_to_stream_default; 
    1215         class->construct_from_stream_func = tny_camel_mime_part_construct_from_stream_default; 
     1234        class->construct_func = tny_camel_mime_part_construct_default; 
    12161235        class->get_filename_func = tny_camel_mime_part_get_filename_default; 
    12171236        class->get_content_id_func = tny_camel_mime_part_get_content_id_default; 
     
    12331252        class->set_header_pair_func = tny_camel_mime_part_set_header_pair_default; 
    12341253        class->decode_to_stream_async_func = tny_camel_mime_part_decode_to_stream_async_default; 
     1254        class->get_transfer_encoding_func = tny_camel_mime_part_get_transfer_encoding_default; 
    12351255 
    12361256        object_class->finalize = tny_camel_mime_part_finalize; 
  • trunk/libtinymail-camel/tny-camel-mime-part.h

    r3171 r3248  
    5555        gssize (*decode_to_stream_func) (TnyMimePart *self, TnyStream *stream, GError **err); 
    5656        gssize (*write_to_stream_func) (TnyMimePart *self, TnyStream *stream, GError **err); 
    57         gint (*construct_from_stream_func) (TnyMimePart *self, TnyStream *stream, const gchar *type); 
     57        gint (*construct_func) (TnyMimePart *self, TnyStream *stream, const gchar *mime_type, const gchar *transfer_encoding); 
    5858        const gchar* (*get_filename_func) (TnyMimePart *self); 
    5959        const gchar* (*get_content_id_func) (TnyMimePart *self); 
     
    7474        void (*set_header_pair_func) (TnyMimePart *self, const gchar *name, const gchar *value); 
    7575        void (*decode_to_stream_async_func) (TnyMimePart *self, TnyStream *stream, TnyMimePartCallback callback, TnyStatusCallback status_callback, gpointer user_data); 
    76  
     76        const gchar* (*get_transfer_encoding_func) (TnyMimePart *self); 
    7777}; 
    7878 
  • trunk/libtinymail/tny-mime-part.c

    r3235 r3248  
    745745 
    746746/** 
    747  * tny_mime_part_construct_from_stream
     747 * tny_mime_part_construct
    748748 * @self: a #TnyMimePart 
    749749 * @stream: a #TnyStream 
    750  * @type: the MIME type like "text/plain" 
     750 * @mime_type: the MIME type like "text/plain" 
     751 * @transfer_encoding: the Content-Transfer-Encoding 
    751752 *  
    752753 * Set the stream from which the part will read its content 
     754 * 
     755 * Valid values for @transfer_encoding are "7bit", "8bit", "base64", 
     756 * "quoted-printable", "binary" and "x-uuencode" 
    753757 * 
    754758 * Example: 
     
    759763 * { 
    760764 *      TnyFsStream *stream = tny_fs_stream_new (fd); 
    761  *      tny_mime_part_construct_from_stream (part, TNY_STREAM (stream)); 
     765 *      tny_mime_part_construct (part, TNY_STREAM (stream), "text/html", "base64"); 
    762766 * } 
    763767 * </programlisting></informalexample> 
     
    768772 **/ 
    769773gint 
    770 tny_mime_part_construct_from_stream (TnyMimePart *self, TnyStream *stream, const gchar *type
     774tny_mime_part_construct (TnyMimePart *self, TnyStream *stream, const gchar *mime_type, const gchar *transfer_encoding
    771775{ 
    772776        gint retval; 
     
    775779        g_assert (TNY_IS_MIME_PART (self)); 
    776780        g_assert (TNY_IS_STREAM (stream)); 
    777         g_assert (TNY_MIME_PART_GET_IFACE (self)->construct_from_stream_func != NULL); 
    778 #endif 
    779  
    780         retval = TNY_MIME_PART_GET_IFACE (self)->construct_from_stream_func (self, stream, type); 
     781        g_assert (TNY_MIME_PART_GET_IFACE (self)->construct_func != NULL); 
     782#endif 
     783 
     784        retval = TNY_MIME_PART_GET_IFACE (self)->construct_func (self, stream, mime_type, transfer_encoding); 
    781785 
    782786#ifdef DBC /* ensure */ 
     
    785789 
    786790        return retval; 
     791} 
     792 
     793 
     794/** 
     795 * tny_mime_part_get_transfer_encoding: 
     796 * @self: a #TnyMimePart 
     797 *  
     798 * Get the transfer encoding of @self or NULL if default transfer encoding 7bit. 
     799 *  
     800 * returns (null-ok): transfer encoding 
     801 * since: 1.0 
     802 * audience: application-developer 
     803 **/ 
     804const gchar*  
     805tny_mime_part_get_transfer_encoding (TnyMimePart *self) 
     806{ 
     807#ifdef DBC /* require */ 
     808        g_assert (TNY_IS_MIME_PART (self)); 
     809        g_assert (TNY_MIME_PART_GET_IFACE (self)->get_transfer_encoding_func != NULL); 
     810#endif 
     811 
     812        return TNY_MIME_PART_GET_IFACE (self)->get_transfer_encoding_func (self); 
    787813} 
    788814 
  • trunk/libtinymail/tny-mime-part.h

    r3171 r3248  
    4949        gssize (*decode_to_stream_func) (TnyMimePart *self, TnyStream *stream, GError **err); 
    5050        gssize (*write_to_stream_func) (TnyMimePart *self, TnyStream *stream, GError **err); 
    51         gint (*construct_from_stream_func) (TnyMimePart *self, TnyStream *stream, const gchar *type); 
     51        gint (*construct_func) (TnyMimePart *self, TnyStream *stream, const gchar *mime_type, const gchar *transfer_encoding); 
    5252        const gchar* (*get_filename_func) (TnyMimePart *self); 
    5353        const gchar* (*get_content_id_func) (TnyMimePart *self); 
     
    6969        void (*set_header_pair_func) (TnyMimePart *self, const gchar *name, const gchar *value); 
    7070        void (*decode_to_stream_async_func) (TnyMimePart *self, TnyStream *stream, TnyMimePartCallback callback, TnyStatusCallback status_callback, gpointer user_data); 
     71        const gchar* (*get_transfer_encoding_func) (TnyMimePart *self); 
     72 
    7173}; 
    7274 
     
    7779TnyStream* tny_mime_part_get_stream (TnyMimePart *self); 
    7880gssize tny_mime_part_write_to_stream (TnyMimePart *self, TnyStream *stream, GError **err); 
    79 gint tny_mime_part_construct_from_stream (TnyMimePart *self, TnyStream *stream, const gchar *type); 
     81gint tny_mime_part_construct (TnyMimePart *self, TnyStream *stream, const gchar *mime_type, const gchar *transfer_encoding); 
    8082const gchar* tny_mime_part_get_filename (TnyMimePart *self); 
    8183const gchar* tny_mime_part_get_content_id (TnyMimePart *self); 
     
    9799void tny_mime_part_set_header_pair (TnyMimePart *self, const gchar *name, const gchar *value); 
    98100void tny_mime_part_decode_to_stream_async (TnyMimePart *self, TnyStream *stream, TnyMimePartCallback callback, TnyStatusCallback status_callback, gpointer user_data); 
     101const gchar* tny_mime_part_get_transfer_encoding (TnyMimePart *self); 
    99102 
    100103G_END_DECLS