gmime r1288 - in trunk: . docs/reference examples gmime mono tests
- From: fejj svn gnome org
- To: svn-commits-list gnome org
- Subject: gmime r1288 - in trunk: . docs/reference examples gmime mono tests
- Date: Wed, 28 May 2008 00:18:45 +0000 (UTC)
Author: fejj
Date: Wed May 28 00:18:44 2008
New Revision: 1288
URL: http://svn.gnome.org/viewvc/gmime?rev=1288&view=rev
Log:
2008-05-26 Jeffrey Stedfast <fejj novell com>
* gmime/gmime-message.c (g_mime_message_get_body): Removed.
* gmime/gmime-disposition.c: Changed GMimeDisposition to
GMimeContentDisposition and updated method names to match.
(g_mime_content_disposition_new_from_string): Same as the old
g_mime_disposition_new().
(g_mime_content_disposition_new): New ctor that doesn't take any
args.
(g_mime_content_disposition_set_parameter): Renamed from
g_mime_disposition_add_parameter().
(g_mime_content_disposition_get_disposition): Renamed from
g_mime_disposition_get().
(g_mime_content_disposition_set_disposition): Renamed from
g_mime_disposition_set().
* gmime/gmime-object.c: Moved Content-Disposition handling here.
(g_mime_object_get_content_disposition): New method which is the
equivalent of g_mime_part_get_content_disposition_object().
(g_mime_object_set_content_disposition): New method which is the
equivalent of g_mime_part_set_content_disposition_object().
(g_mime_object_get_disposition): New method which is the
equivalent of g_mime_part_get_content_disposition().
(g_mime_object_set_disposition): New method which is the
equivalent of g_mime_part_set_content_disposition().
(g_mime_object_get_content_disposition_parameter): New method
which is the equivalent of
g_mime_part_get_content_disposition_parameter().
(g_mime_object_set_content_disposition_parameter): New method
which is the equivalent of
g_mime_part_add_content_disposition_parameter().
* gmime/gmime-part.c (g_mime_part_get_content_disposition_object):
Moved functionality to GMimeObject.
(g_mime_part_set_content_disposition_object): Same.
(g_mime_part_set_content_disposition): Same.
(g_mime_part_get_content_disposition): Same.
(g_mime_part_add_content_disposition_parameter): Same.
(g_mime_part_get_content_disposition_parameter): Same.
(g_mime_part_set_content): Removed long-deprecated function.
(g_mime_part_set_content_byte_array): Same.
(g_mime_part_set_pre_encoded_content): Same.
(g_mime_part_get_content): Same.
(g_mime_part_set_content_type):
Removed... equivalent functionality already on GMimeObject.
(g_mime_part_get_content_type): Same.
Modified:
trunk/ChangeLog
trunk/docs/reference/gmime-sections.txt
trunk/examples/imap-example.c
trunk/gmime/gmime-content-type.c
trunk/gmime/gmime-disposition.c
trunk/gmime/gmime-disposition.h
trunk/gmime/gmime-message.c
trunk/gmime/gmime-message.h
trunk/gmime/gmime-object.c
trunk/gmime/gmime-object.h
trunk/gmime/gmime-part.c
trunk/gmime/gmime-part.h
trunk/mono/gmime-api.raw
trunk/tests/test-parser.c
Modified: trunk/docs/reference/gmime-sections.txt
==============================================================================
--- trunk/docs/reference/gmime-sections.txt (original)
+++ trunk/docs/reference/gmime-sections.txt Wed May 28 00:18:44 2008
@@ -604,14 +604,15 @@
<FILE>gmime-disposition</FILE>
GMIME_DISPOSITION_ATTACHMENT
GMIME_DISPOSITION_INLINE
-GMimeDisposition
-g_mime_disposition_new
-g_mime_disposition_destroy
-g_mime_disposition_set
-g_mime_disposition_get
-g_mime_disposition_add_parameter
-g_mime_disposition_get_parameter
-g_mime_disposition_header
+GMimeContentDisposition
+g_mime_content_disposition_new
+g_mime_content_disposition_new_from_string
+g_mime_content_disposition_destroy
+g_mime_content_disposition_set_disposition
+g_mime_content_disposition_get_disposition
+g_mime_content_disposition_set_parameter
+g_mime_content_disposition_get_parameter
+g_mime_content_disposition_to_string
</SECTION>
<SECTION>
@@ -624,6 +625,12 @@
g_mime_object_get_content_type
g_mime_object_set_content_type_parameter
g_mime_object_get_content_type_parameter
+g_mime_object_set_disposition
+g_mime_object_get_disposition
+g_mime_object_set_content_disposition
+g_mime_object_get_content_disposition
+g_mime_object_set_content_disposition_parameter
+g_mime_object_get_content_disposition_parameter
g_mime_object_set_content_id
g_mime_object_get_content_id
g_mime_object_add_header
@@ -663,24 +670,12 @@
g_mime_part_verify_content_md5
g_mime_part_set_content_location
g_mime_part_get_content_location
-g_mime_part_set_content_type
-g_mime_part_get_content_type
g_mime_part_set_encoding
g_mime_part_get_encoding
g_mime_part_encoding_to_string
g_mime_part_encoding_from_string
-g_mime_part_get_content_disposition_object
-g_mime_part_set_content_disposition_object
-g_mime_part_set_content_disposition
-g_mime_part_get_content_disposition
-g_mime_part_add_content_disposition_parameter
-g_mime_part_get_content_disposition_parameter
g_mime_part_set_filename
g_mime_part_get_filename
-g_mime_part_set_content
-g_mime_part_set_pre_encoded_content
-g_mime_part_set_content_byte_array
-g_mime_part_get_content
g_mime_part_get_content_object
g_mime_part_set_content_object
@@ -797,7 +792,6 @@
g_mime_message_get_header
g_mime_message_set_mime_part
g_mime_message_get_mime_part
-g_mime_message_get_body
g_mime_message_get_headers
g_mime_message_foreach_part
Modified: trunk/examples/imap-example.c
==============================================================================
--- trunk/examples/imap-example.c (original)
+++ trunk/examples/imap-example.c Wed May 28 00:18:44 2008
@@ -191,9 +191,9 @@
/* print body */
write_part_bodystructure ((GMimeObject *) message->mime_part, fp);
} else if (GMIME_IS_PART (part)) {
- if (GMIME_PART (part)->disposition) {
- fprintf (fp, "\"%s\" ", GMIME_PART (part)->disposition->disposition);
- if ((param = GMIME_PART (part)->disposition->params)) {
+ if (GMIME_OBJECT (part)->disposition) {
+ fprintf (fp, "\"%s\" ", GMIME_OBJECT (part)->disposition->disposition);
+ if ((param = GMIME_OBJECT (part)->disposition->params)) {
fputc ('(', fp);
while (param) {
fprintf (fp, "\"%s\" \"%s\"", param->name, param->value);
Modified: trunk/gmime/gmime-content-type.c
==============================================================================
--- trunk/gmime/gmime-content-type.c (original)
+++ trunk/gmime/gmime-content-type.c Wed May 28 00:18:44 2008
@@ -283,11 +283,9 @@
mime_type->param_hash = g_hash_table_new (g_mime_strcase_hash, g_mime_strcase_equal);
}
- if (param == NULL) {
- param = g_mime_param_new (attribute, value);
- mime_type->params = g_mime_param_append_param (mime_type->params, param);
- g_hash_table_insert (mime_type->param_hash, param->name, param);
- }
+ param = g_mime_param_new (attribute, value);
+ mime_type->params = g_mime_param_append_param (mime_type->params, param);
+ g_hash_table_insert (mime_type->param_hash, param->name, param);
}
Modified: trunk/gmime/gmime-disposition.c
==============================================================================
--- trunk/gmime/gmime-disposition.c (original)
+++ trunk/gmime/gmime-disposition.c Wed May 28 00:18:44 2008
@@ -32,77 +32,91 @@
/**
* SECTION: gmime-disposition
- * @title: GMimeDisposition
+ * @title: GMimeContentDisposition
* @short_description: Content-Disposition fields
* @see_also:
*
- * A #GMimeDisposition represents the pre-parsed contents of a
+ * A #GMimeContentDisposition represents the pre-parsed contents of a
* Content-Disposition header field.
**/
/**
- * g_mime_disposition_new:
- * @disposition: disposition header (and params)
+ * g_mime_content_disposition_new:
*
- * Creates a new GMimeDisposition object.
+ * Creates a new #GMimeContentDisposition object.
*
- * Returns a new disposition object
+ * Returns a new #GMimeContentDisposition object.
**/
-GMimeDisposition *
-g_mime_disposition_new (const char *disposition)
+GMimeContentDisposition *
+g_mime_content_disposition_new (void)
{
- GMimeDisposition *new;
+ GMimeContentDisposition *disposition;
+
+ disposition = g_new (GMimeContentDisposition, 1);
+ disposition->disposition = g_strdup (GMIME_DISPOSITION_ATTACHMENT);
+ disposition->params = NULL;
+ disposition->param_hash = NULL;
+
+ return disposition;
+}
+
+
+/**
+ * g_mime_content_disposition_new_from_string:
+ * @str: Content-Disposition field value or %NULL
+ *
+ * Creates a new #GMimeContentDisposition object.
+ *
+ * Returns a new #GMimeContentDisposition object.
+ **/
+GMimeContentDisposition *
+g_mime_content_disposition_new_from_string (const char *str)
+{
+ GMimeContentDisposition *disposition;
+ const char *inptr = str;
GMimeParam *param;
- const char *inptr;
char *value;
- new = g_new (GMimeDisposition, 1);
- if (!disposition) {
- new->disposition = g_strdup (GMIME_DISPOSITION_ATTACHMENT);
- new->params = NULL;
- new->param_hash = NULL;
-
- return new;
- }
+ if (str == NULL)
+ return g_mime_content_disposition_new ();
+
+ disposition = g_new (GMimeContentDisposition, 1);
/* get content disposition part */
/* find ; or \0 */
- inptr = disposition;
while (*inptr && *inptr != ';')
inptr++;
- value = g_strndup (disposition, (size_t) (inptr - disposition));
- g_strstrip (value);
-
- new->disposition = value;
+ value = g_strndup (str, (size_t) (inptr - str));
+ disposition->disposition = g_strstrip (value);
/* parse the parameters, if any */
if (*inptr++ == ';' && *inptr) {
- param = new->params = g_mime_param_new_from_string (inptr);
- new->param_hash = g_hash_table_new (g_mime_strcase_hash, g_mime_strcase_equal);
+ param = disposition->params = g_mime_param_new_from_string (inptr);
+ disposition->param_hash = g_hash_table_new (g_mime_strcase_hash, g_mime_strcase_equal);
while (param) {
- g_hash_table_insert (new->param_hash, param->name, param);
+ g_hash_table_insert (disposition->param_hash, param->name, param);
param = param->next;
}
} else {
- new->params = NULL;
- new->param_hash = NULL;
+ disposition->param_hash = NULL;
+ disposition->params = NULL;
}
- return new;
+ return disposition;
}
/**
- * g_mime_disposition_destroy:
- * @disposition: disposition object
+ * g_mime_content_disposition_destroy:
+ * @disposition: a #GMimeContentDisposition object
*
- * Destroy the disposition object.
+ * Destroy the #GMimeContentDisposition object.
**/
void
-g_mime_disposition_destroy (GMimeDisposition *disposition)
+g_mime_content_disposition_destroy (GMimeContentDisposition *disposition)
{
if (disposition) {
g_free (disposition->disposition);
@@ -116,17 +130,17 @@
/**
- * g_mime_disposition_set:
- * @disposition: disposition object
+ * g_mime_content_disposition_set_disposition:
+ * @disposition: a #GMimeContentDisposition object
* @value: disposition value
*
* Sets the disposition to @value which may be one of
- * GMIME_DISPOSITION_ATTACHMENT or GMIME_DISPOSITION_INLINE or, by your
- * choice, any other string which would indicate how the MIME part
- * should be displayed by the MUA.
+ * #GMIME_DISPOSITION_ATTACHMENT or #GMIME_DISPOSITION_INLINE or, by
+ * your choice, any other string which would indicate how the MIME
+ * part should be displayed by the MUA.
**/
void
-g_mime_disposition_set (GMimeDisposition *disposition, const char *value)
+g_mime_content_disposition_set_disposition (GMimeContentDisposition *disposition, const char *value)
{
g_return_if_fail (disposition != NULL);
g_return_if_fail (value != NULL);
@@ -137,16 +151,16 @@
/**
- * g_mime_disposition_get:
- * @disposition: disposition object
+ * g_mime_content_disposition_get_disposition:
+ * @disposition: a #GMimeContentDisposition object
*
* Gets the disposition or %NULL on fail.
*
* Returns the disposition string which is probably one of
- * GMIME_DISPOSITION_ATTACHMENT or GMIME_DISPOSITION_INLINE.
+ * #GMIME_DISPOSITION_ATTACHMENT or #GMIME_DISPOSITION_INLINE.
**/
const char *
-g_mime_disposition_get (GMimeDisposition *disposition)
+g_mime_content_disposition_get_disposition (GMimeContentDisposition *disposition)
{
g_return_val_if_fail (disposition != NULL, NULL);
@@ -155,16 +169,15 @@
/**
- * g_mime_disposition_add_parameter:
- * @disposition: disposition object
+ * g_mime_content_disposition_set_parameter:
+ * @disposition: a #GMimeContentDisposition object
* @attribute: parameter name
* @value: parameter value
*
- * Adds a new parameter of name @name and value @value to the
- * disposition.
+ * Sets a parameter on the Content-Disposition.
**/
void
-g_mime_disposition_add_parameter (GMimeDisposition *disposition, const char *attribute, const char *value)
+g_mime_content_disposition_set_parameter (GMimeContentDisposition *disposition, const char *attribute, const char *value)
{
GMimeParam *param = NULL;
@@ -173,28 +186,25 @@
g_return_if_fail (value != NULL);
if (disposition->params) {
- param = g_hash_table_lookup (disposition->param_hash, attribute);
- if (param) {
+ if ((param = g_hash_table_lookup (disposition->param_hash, attribute))) {
g_free (param->value);
param->value = g_strdup (value);
+ return;
}
- } else {
+ } else if (!disposition->param_hash) {
/* hash table may not be initialized */
- if (!disposition->param_hash)
- disposition->param_hash = g_hash_table_new (g_mime_strcase_hash, g_mime_strcase_equal);
+ disposition->param_hash = g_hash_table_new (g_mime_strcase_hash, g_mime_strcase_equal);
}
- if (param == NULL) {
- param = g_mime_param_new (attribute, value);
- disposition->params = g_mime_param_append_param (disposition->params, param);
- g_hash_table_insert (disposition->param_hash, param->name, param);
- }
+ param = g_mime_param_new (attribute, value);
+ disposition->params = g_mime_param_append_param (disposition->params, param);
+ g_hash_table_insert (disposition->param_hash, param->name, param);
}
/**
- * g_mime_disposition_get_parameter:
- * @disposition: disposition object
+ * g_mime_content_disposition_get_parameter:
+ * @disposition: a #GMimeContentDisposition object
* @attribute: parameter name
*
* Gets the value of the parameter @attribute, or %NULL on fail.
@@ -202,7 +212,7 @@
* Returns the value of the parameter of name @attribute.
**/
const char *
-g_mime_disposition_get_parameter (GMimeDisposition *disposition, const char *attribute)
+g_mime_content_disposition_get_parameter (GMimeContentDisposition *disposition, const char *attribute)
{
GMimeParam *param;
@@ -212,18 +222,16 @@
if (!disposition->param_hash)
return NULL;
- param = g_hash_table_lookup (disposition->param_hash, attribute);
-
- if (param)
- return param->value;
- else
+ if (!(param = g_hash_table_lookup (disposition->param_hash, attribute)))
return NULL;
+
+ return param->value;
}
/**
- * g_mime_disposition_header:
- * @disposition: disposition object
+ * g_mime_content_disposition_to_string:
+ * @disposition: a #GMimeContentDisposition object
* @fold: fold header if needed
*
* Allocates a string buffer containing the Content-Disposition header
@@ -232,7 +240,7 @@
* Returns a string containing the disposition header
**/
char *
-g_mime_disposition_header (GMimeDisposition *disposition, gboolean fold)
+g_mime_content_disposition_to_string (GMimeContentDisposition *disposition, gboolean fold)
{
GString *string;
char *header, *buf;
Modified: trunk/gmime/gmime-disposition.h
==============================================================================
--- trunk/gmime/gmime-disposition.h (original)
+++ trunk/gmime/gmime-disposition.h Wed May 28 00:18:44 2008
@@ -44,26 +44,28 @@
#define GMIME_DISPOSITION_INLINE "inline"
-struct _GMimeDisposition {
+struct _GMimeContentDisposition {
char *disposition;
GMimeParam *params;
GHashTable *param_hash;
};
-typedef struct _GMimeDisposition GMimeDisposition;
+typedef struct _GMimeContentDisposition GMimeContentDisposition;
-GMimeDisposition *g_mime_disposition_new (const char *disposition);
+GMimeContentDisposition *g_mime_content_disposition_new (void);
+GMimeContentDisposition *g_mime_content_disposition_new_from_string (const char *str);
-void g_mime_disposition_destroy (GMimeDisposition *disposition);
+void g_mime_content_disposition_destroy (GMimeContentDisposition *disposition);
-void g_mime_disposition_set (GMimeDisposition *disposition, const char *value);
-const char *g_mime_disposition_get (GMimeDisposition *disposition);
+void g_mime_content_disposition_set_disposition (GMimeContentDisposition *disposition, const char *value);
+const char *g_mime_content_disposition_get_disposition (GMimeContentDisposition *disposition);
-void g_mime_disposition_add_parameter (GMimeDisposition *disposition, const char *attribute,
- const char *value);
-const char *g_mime_disposition_get_parameter (GMimeDisposition *disposition, const char *attribute);
+void g_mime_content_disposition_set_parameter (GMimeContentDisposition *disposition,
+ const char *attribute, const char *value);
+const char *g_mime_content_disposition_get_parameter (GMimeContentDisposition *disposition,
+ const char *attribute);
-char *g_mime_disposition_header (GMimeDisposition *disposition, gboolean fold);
+char *g_mime_content_disposition_to_string (GMimeContentDisposition *disposition, gboolean fold);
G_END_DECLS
Modified: trunk/gmime/gmime-message.c
==============================================================================
--- trunk/gmime/gmime-message.c (original)
+++ trunk/gmime/gmime-message.c Wed May 28 00:18:44 2008
@@ -1496,65 +1496,6 @@
/**
- * g_mime_message_get_body:
- * @message: MIME Message
- * @want_plain: request text/plain
- * @is_html: body returned is in html format
- *
- * Attempts to get the body of the message in the preferred format
- * specified by @want_plain.
- *
- * WARNING: This interface is deprecated.
- *
- * Returns the prefered form of the message body. Sets the value of
- * @is_html to %TRUE if the part returned is in HTML format, otherwise
- * %FALSE.
- *
- * Note: This function is NOT guarenteed to always work as it
- * makes some assumptions that are not necessarily true. It is
- * recommended that you traverse the MIME structure yourself.
- **/
-char *
-g_mime_message_get_body (const GMimeMessage *message, gboolean want_plain, gboolean *is_html)
-{
- GMimeObject *mime_part = NULL;
- const GMimeContentType *type;
- GMimeMultipart *multipart;
- const char *content;
- char *body = NULL;
- size_t len = 0;
-
- g_return_val_if_fail (GMIME_IS_MESSAGE (message), NULL);
- g_return_val_if_fail (is_html != NULL, NULL);
-
- type = g_mime_object_get_content_type (message->mime_part);
- if (GMIME_IS_MULTIPART (message->mime_part)) {
- /* let's see if we can find a body in the multipart */
- multipart = GMIME_MULTIPART (message->mime_part);
- if (g_mime_content_type_is_type (type, "multipart", "alternative"))
- mime_part = handle_multipart_alternative (multipart, want_plain, is_html);
- else
- mime_part = handle_multipart_mixed (multipart, want_plain, is_html);
- } else if (g_mime_content_type_is_type (type, "text", "*")) {
- /* this *has* to be the message body */
- if (g_mime_content_type_is_type (type, "text", "html"))
- *is_html = TRUE;
- else
- *is_html = FALSE;
-
- mime_part = message->mime_part;
- }
-
- if (mime_part != NULL) {
- content = g_mime_part_get_content (GMIME_PART (mime_part), &len);
- body = g_strndup (content, len);
- }
-
- return body;
-}
-
-
-/**
* g_mime_message_get_headers:
* @message: MIME Message
*
Modified: trunk/gmime/gmime-message.h
==============================================================================
--- trunk/gmime/gmime-message.h (original)
+++ trunk/gmime/gmime-message.h Wed May 28 00:18:44 2008
@@ -123,10 +123,6 @@
GMimeObject *g_mime_message_get_mime_part (GMimeMessage *message);
void g_mime_message_set_mime_part (GMimeMessage *message, GMimeObject *mime_part);
-#ifndef GMIME_DISABLE_DEPRECATED
-char *g_mime_message_get_body (const GMimeMessage *message, gboolean want_plain, gboolean *is_html);
-#endif /* GMIME_DISABLE_DEPRECATED */
-
char *g_mime_message_get_headers (GMimeMessage *message);
void g_mime_message_foreach_part (GMimeMessage *message, GMimePartFunc callback, gpointer data);
Modified: trunk/gmime/gmime-object.c
==============================================================================
--- trunk/gmime/gmime-object.c (original)
+++ trunk/gmime/gmime-object.c Wed May 28 00:18:44 2008
@@ -35,10 +35,10 @@
/**
* SECTION: gmime-object
* @title: GMimeObject
- * @short_description: Abstract MIME objects
+ * @short_description: Abstract Mime objects
* @see_also:
*
- * #GMimeObject is an abstract class from which all Message and MIME
+ * #GMimeObject is an abstract class from which all Message and Mime
* parts are derived.
**/
@@ -68,6 +68,7 @@
static ssize_t write_to_stream (GMimeObject *object, GMimeStream *stream);
static ssize_t write_content_type (GMimeStream *stream, const char *name, const char *value);
+static ssize_t write_disposition (GMimeStream *stream, const char *name, const char *value);
static void type_registry_init (void);
@@ -126,11 +127,13 @@
static void
g_mime_object_init (GMimeObject *object, GMimeObjectClass *klass)
{
- object->content_type = NULL;
object->headers = g_mime_header_new ();
+ object->content_type = NULL;
+ object->disposition = NULL;
object->content_id = NULL;
g_mime_header_register_writer (object->headers, "Content-Type", write_content_type);
+ g_mime_header_register_writer (object->headers, "Content-Disposition", write_disposition);
}
static void
@@ -141,6 +144,9 @@
if (mime->content_type)
g_mime_content_type_destroy (mime->content_type);
+ if (mime->disposition)
+ g_mime_content_disposition_destroy (mime->disposition);
+
if (mime->headers)
g_mime_header_destroy (mime->headers);
@@ -176,6 +182,28 @@
return nwritten;
}
+static ssize_t
+write_disposition (GMimeStream *stream, const char *name, const char *value)
+{
+ GMimeContentDisposition *disposition;
+ ssize_t nwritten;
+ GString *out;
+
+ out = g_string_new ("");
+ g_string_printf (out, "%s: ", name);
+
+ disposition = g_mime_content_disposition_new_from_string (value);
+ g_string_append (out, disposition->disposition);
+
+ g_mime_param_write_to_string (disposition->params, TRUE, out);
+ g_mime_content_disposition_destroy (disposition);
+
+ nwritten = g_mime_stream_write (stream, out->str, out->len);
+ g_string_free (out, TRUE);
+
+ return nwritten;
+}
+
/**
* g_mime_object_register_type:
@@ -230,7 +258,7 @@
*
* Performs a lookup of registered #GMimeObject subclasses, registered
* using g_mime_object_register_type(), to find an appropriate class
- * capable of handling MIME parts of type @type/@subtype. If no class
+ * capable of handling Mime parts of type @type/@subtype. If no class
* has been registered to handle that type, it looks for a registered
* class that can handle @type. If that also fails, then it will use
* the generic part class, #GMimePart.
@@ -306,7 +334,6 @@
g_free (p);
}
-
static void
set_content_type (GMimeObject *object, GMimeContentType *content_type)
{
@@ -321,10 +348,10 @@
/**
* g_mime_object_set_content_type:
- * @object: MIME object
- * @mime_type: MIME type
+ * @object: Mime object
+ * @mime_type: Mime type
*
- * Sets the content-type for the specified MIME object.
+ * Sets the content-type for the specified Mime object.
**/
void
g_mime_object_set_content_type (GMimeObject *object, GMimeContentType *mime_type)
@@ -338,12 +365,12 @@
/**
* g_mime_object_get_content_type:
- * @object: MIME object
+ * @object: Mime object
*
- * Gets the Content-Type object for the given MIME object or %NULL on
+ * Gets the Content-Type object for the given Mime object or %NULL on
* fail.
*
- * Returns the content-type object for the specified MIME object.
+ * Returns the content-type object for the specified Mime object.
**/
const GMimeContentType *
g_mime_object_get_content_type (GMimeObject *object)
@@ -356,7 +383,7 @@
/**
* g_mime_object_set_content_type_parameter:
- * @object: MIME object
+ * @object: Mime object
* @name: param name
* @value: param value
*
@@ -376,10 +403,10 @@
/**
* g_mime_object_get_content_type_parameter:
- * @object: MIME object
+ * @object: Mime object
* @name: param name
*
- * Gets the value of the content-type param @name set on the MIME part
+ * Gets the value of the content-type param @name set on the Mime part
* @object.
*
* Returns the value of the requested content-type param or %NULL on
@@ -396,11 +423,157 @@
/**
+ * g_mime_object_get_content_disposition:
+ * @object: Mime object
+ *
+ * Get the content disposition for the specified Mime object.
+ *
+ * Returns the #GMimeContentDisposition set on the Mime object.
+ **/
+const GMimeContentDisposition *
+g_mime_object_get_content_disposition (GMimeObject *object)
+{
+ g_return_val_if_fail (GMIME_IS_OBJECT (object), NULL);
+
+ return object->disposition;
+}
+
+
+static void
+sync_content_disposition (GMimeObject *object)
+{
+ char *str;
+
+ if (object->disposition) {
+ str = g_mime_content_disposition_to_string (object->disposition, FALSE);
+ g_mime_header_set (object->headers, "Content-Disposition", str);
+ g_free (str);
+ } else {
+ g_mime_header_remove (object->headers, "Content-Disposition");
+ }
+}
+
+
+/**
+ * g_mime_object_set_content_disposition:
+ * @object: Mime object
+ * @disposition: a #GMimeContentDisposition object
+ *
+ * Set the content disposition for the specified mime part.
+ **/
+void
+g_mime_object_set_content_disposition (GMimeObject *object, GMimeContentDisposition *disposition)
+{
+ g_return_if_fail (GMIME_IS_OBJECT (object));
+
+ if (object->disposition)
+ g_mime_content_disposition_destroy (object->disposition);
+
+ object->disposition = disposition;
+
+ sync_content_disposition (object);
+}
+
+
+/**
+ * g_mime_object_set_disposition:
+ * @object: Mime object
+ * @disposition: disposition ("attachment" or "inline")
+ *
+ * Sets the disposition to @disposition which may be one of
+ * #GMIME_DISPOSITION_ATTACHMENT or #GMIME_DISPOSITION_INLINE or, by
+ * your choice, any other string which would indicate how the Mime
+ * part should be displayed by the MUA.
+ **/
+void
+g_mime_object_set_disposition (GMimeObject *object, const char *disposition)
+{
+ g_return_if_fail (GMIME_IS_OBJECT (object));
+
+ if (object->disposition) {
+ g_mime_content_disposition_set_disposition (object->disposition, disposition);
+ sync_content_disposition (object);
+ } else if (disposition) {
+ object->disposition = g_mime_content_disposition_new_from_string (disposition);
+ sync_content_disposition (object);
+ }
+}
+
+
+/**
+ * g_mime_object_get_disposition:
+ * @object: Mime object
+ *
+ * Gets the Mime object's disposition if set or %NULL otherwise.
+ *
+ * Returns the disposition string which is probably one of
+ * #GMIME_DISPOSITION_ATTACHMENT or #GMIME_DISPOSITION_INLINE.
+ **/
+const char *
+g_mime_object_get_disposition (GMimeObject *object)
+{
+ g_return_val_if_fail (GMIME_IS_OBJECT (object), NULL);
+
+ if (object->disposition)
+ return g_mime_content_disposition_get_disposition (object->disposition);
+
+ return NULL;
+}
+
+
+/**
+ * g_mime_object_set_content_disposition_parameter:
+ * @object: Mime object
+ * @attribute: parameter name
+ * @value: parameter value
+ *
+ * Add a content-disposition parameter to the specified mime part.
+ **/
+void
+g_mime_object_set_content_disposition_parameter (GMimeObject *object, const char *attribute, const char *value)
+{
+ g_return_if_fail (GMIME_IS_OBJECT (object));
+ g_return_if_fail (attribute != NULL);
+
+ if (!object->disposition)
+ object->disposition = g_mime_content_disposition_new ();
+
+ g_mime_content_disposition_set_parameter (object->disposition, attribute, value);
+
+ sync_content_disposition (object);
+}
+
+
+/**
+ * g_mime_object_get_content_disposition_parameter:
+ * @object: Mime object
+ * @attribute: parameter name
+ *
+ * Gets the value of the Content-Disposition parameter specified by
+ * @attribute, or %NULL if the parameter does not exist.
+ *
+ * Returns the value of a previously defined content-disposition
+ * parameter specified by @attribute.
+ **/
+const char *
+g_mime_object_get_content_disposition_parameter (GMimeObject *object, const char *attribute)
+{
+ g_return_val_if_fail (GMIME_IS_OBJECT (object), NULL);
+ g_return_val_if_fail (attribute != NULL, NULL);
+
+ if (!object->disposition)
+ return NULL;
+
+ return g_mime_content_disposition_get_parameter (object->disposition, attribute);
+}
+
+
+/**
* g_mime_object_set_content_id:
- * @object: MIME object
+ * @object: Mime object
* @content_id: content-id (addr-spec portion)
*
- * Sets the Content-Id of the MIME object.
+ * Sets the Content-Id of the Mime object.
**/
void
g_mime_object_set_content_id (GMimeObject *object, const char *content_id)
@@ -420,9 +593,9 @@
/**
* g_mime_object_get_content_id:
- * @object: MIME object
+ * @object: Mime object
*
- * Gets the Content-Id of the MIME object or NULL if one is not set.
+ * Gets the Content-Id of the Mime object or NULL if one is not set.
*
* Returns a const pointer to the Content-Id header.
**/
@@ -436,12 +609,14 @@
enum {
+ HEADER_CONTENT_DISPOSITION,
HEADER_CONTENT_TYPE,
HEADER_CONTENT_ID,
HEADER_UNKNOWN,
};
static char *headers[] = {
+ "Content-Disposition",
"Content-Type",
"Content-Id",
NULL
@@ -450,6 +625,7 @@
static gboolean
process_header (GMimeObject *object, const char *header, const char *value)
{
+ GMimeContentDisposition *disposition;
GMimeContentType *content_type;
int i;
@@ -459,6 +635,12 @@
}
switch (i) {
+ case HEADER_CONTENT_DISPOSITION:
+ disposition = g_mime_content_disposition_new_from_string (value);
+ if (object->disposition)
+ g_mime_content_disposition_destroy (object->disposition);
+ object->disposition = disposition;
+ break;
case HEADER_CONTENT_TYPE:
content_type = g_mime_content_type_new_from_string (value);
g_mime_object_set_content_type (object, content_type);
@@ -490,7 +672,7 @@
* @header: header name
* @value: header value
*
- * Adds an arbitrary header to the MIME object.
+ * Adds an arbitrary header to the Mime object.
**/
void
g_mime_object_add_header (GMimeObject *object, const char *header, const char *value)
@@ -517,7 +699,7 @@
* @header: header name
* @value: header value
*
- * Sets an arbitrary header on the MIME object.
+ * Sets an arbitrary header on the Mime object.
**/
void
g_mime_object_set_header (GMimeObject *object, const char *header, const char *value)
@@ -593,10 +775,10 @@
* g_mime_object_get_headers:
* @object: mime object
*
- * Allocates a string buffer containing all of the MIME object's raw
+ * Allocates a string buffer containing all of the Mime object's raw
* headers.
*
- * Returns an allocated string containing all of the raw MIME headers.
+ * Returns an allocated string containing all of the raw Mime headers.
**/
char *
g_mime_object_get_headers (GMimeObject *object)
@@ -619,7 +801,7 @@
* @object: mime object
* @stream: stream
*
- * Write the contents of the MIME object to @stream.
+ * Write the contents of the Mime object to @stream.
*
* Returns -1 on fail.
**/
Modified: trunk/gmime/gmime-object.h
==============================================================================
--- trunk/gmime/gmime-object.h (original)
+++ trunk/gmime/gmime-object.h Wed May 28 00:18:44 2008
@@ -26,6 +26,7 @@
#include <glib-object.h>
#include <gmime/gmime-content-type.h>
+#include <gmime/gmime-disposition.h>
#include <gmime/gmime-stream.h>
#include <gmime/gmime-header.h>
@@ -44,6 +45,7 @@
struct _GMimeObject {
GObject parent_object;
+ GMimeContentDisposition *disposition;
GMimeContentType *content_type;
GMimeHeader *headers;
@@ -86,10 +88,18 @@
void g_mime_object_set_content_type (GMimeObject *object, GMimeContentType *mime_type);
const GMimeContentType *g_mime_object_get_content_type (GMimeObject *object);
-
void g_mime_object_set_content_type_parameter (GMimeObject *object, const char *name, const char *value);
const char *g_mime_object_get_content_type_parameter (GMimeObject *object, const char *name);
+void g_mime_object_set_content_disposition (GMimeObject *object, GMimeContentDisposition *disposition);
+const GMimeContentDisposition *g_mime_object_get_content_disposition (GMimeObject *object);
+
+void g_mime_object_set_disposition (GMimeObject *object, const char *disposition);
+const char *g_mime_object_get_disposition (GMimeObject *object);
+
+void g_mime_object_set_content_disposition_parameter (GMimeObject *object, const char *attribute, const char *value);
+const char *g_mime_object_get_content_disposition_parameter (GMimeObject *object, const char *attribute);
+
void g_mime_object_set_content_id (GMimeObject *object, const char *content_id);
const char *g_mime_object_get_content_id (GMimeObject *object);
Modified: trunk/gmime/gmime-part.c
==============================================================================
--- trunk/gmime/gmime-part.c (original)
+++ trunk/gmime/gmime-part.c Wed May 28 00:18:44 2008
@@ -67,8 +67,6 @@
static char *mime_part_get_headers (GMimeObject *object);
static ssize_t mime_part_write_to_stream (GMimeObject *object, GMimeStream *stream);
-static ssize_t write_disposition (GMimeStream *stream, const char *name, const char *value);
-
#define NEEDS_DECODING(encoding) (((GMimePartEncodingType) encoding) == GMIME_PART_ENCODING_BASE64 || \
((GMimePartEncodingType) encoding) == GMIME_PART_ENCODING_UUENCODE || \
((GMimePartEncodingType) encoding) == GMIME_PART_ENCODING_QUOTEDPRINTABLE)
@@ -125,13 +123,10 @@
g_mime_part_init (GMimePart *mime_part, GMimePartClass *klass)
{
mime_part->encoding = GMIME_PART_ENCODING_DEFAULT;
- mime_part->disposition = NULL;
mime_part->content_description = NULL;
mime_part->content_location = NULL;
mime_part->content_md5 = NULL;
mime_part->content = NULL;
-
- g_mime_header_register_writer (((GMimeObject *) mime_part)->headers, "Content-Disposition", write_disposition);
}
static void
@@ -139,9 +134,6 @@
{
GMimePart *mime_part = (GMimePart *) object;
- if (mime_part->disposition)
- g_mime_disposition_destroy (mime_part->disposition);
-
g_free (mime_part->content_description);
g_free (mime_part->content_location);
g_free (mime_part->content_md5);
@@ -162,7 +154,6 @@
enum {
HEADER_CONTENT_TRANSFER_ENCODING,
- HEADER_CONTENT_DISPOSITION,
HEADER_CONTENT_DESCRIPTION,
HEADER_CONTENT_LOCATION,
HEADER_CONTENT_MD5,
@@ -171,55 +162,12 @@
static char *headers[] = {
"Content-Transfer-Encoding",
- "Content-Disposition",
"Content-Description",
"Content-Location",
"Content-Md5",
NULL
};
-static ssize_t
-write_disposition (GMimeStream *stream, const char *name, const char *value)
-{
- GMimeDisposition *disposition;
- ssize_t nwritten;
- GString *out;
-
- out = g_string_new ("");
- g_string_printf (out, "%s: ", name);
-
- disposition = g_mime_disposition_new (value);
- g_string_append (out, disposition->disposition);
-
- g_mime_param_write_to_string (disposition->params, TRUE, out);
- g_mime_disposition_destroy (disposition);
-
- nwritten = g_mime_stream_write (stream, out->str, out->len);
- g_string_free (out, TRUE);
-
- return nwritten;
-}
-
-static void
-set_disposition (GMimePart *mime_part, const char *disposition)
-{
- if (mime_part->disposition)
- g_mime_disposition_destroy (mime_part->disposition);
-
- mime_part->disposition = g_mime_disposition_new (disposition);
-}
-
-static void
-sync_content_disposition (GMimePart *mime_part)
-{
- char *str;
-
- if (mime_part->disposition) {
- str = g_mime_disposition_header (mime_part->disposition, FALSE);
- g_mime_header_set (GMIME_OBJECT (mime_part)->headers, "Content-Disposition", str);
- g_free (str);
- }
-}
static gboolean
process_header (GMimeObject *object, const char *header, const char *value)
@@ -240,9 +188,6 @@
g_strstrip (text);
mime_part->encoding = g_mime_part_encoding_from_string (text);
break;
- case HEADER_CONTENT_DISPOSITION:
- set_disposition (mime_part, value);
- break;
case HEADER_CONTENT_DESCRIPTION:
/* FIXME: we should decode this */
g_free (mime_part->content_description);
@@ -922,128 +867,6 @@
/**
- * g_mime_part_get_content_disposition_object:
- * @mime_part: Mime part
- *
- * Get the content disposition for the specified mime part.
- *
- * Returns the #GMimeDisposition set on the mime part.
- **/
-const GMimeDisposition *
-g_mime_part_get_content_disposition_object (GMimePart *mime_part)
-{
- g_return_val_if_fail (GMIME_IS_PART (mime_part), NULL);
-
- return mime_part->disposition;
-}
-
-
-/**
- * g_mime_part_set_content_disposition_object:
- * @mime_part: Mime part
- * @disposition: disposition object
- *
- * Set the content disposition for the specified mime part.
- **/
-void
-g_mime_part_set_content_disposition_object (GMimePart *mime_part, GMimeDisposition *disposition)
-{
- g_return_if_fail (GMIME_IS_PART (mime_part));
-
- if (mime_part->disposition)
- g_mime_disposition_destroy (mime_part->disposition);
-
- mime_part->disposition = disposition;
-
- sync_content_disposition (mime_part);
-}
-
-
-/**
- * g_mime_part_set_content_disposition:
- * @mime_part: Mime part
- * @disposition: disposition
- *
- * Set the content disposition for the specified mime part
- **/
-void
-g_mime_part_set_content_disposition (GMimePart *mime_part, const char *disposition)
-{
- g_return_if_fail (GMIME_IS_PART (mime_part));
-
- set_disposition (mime_part, disposition);
- sync_content_disposition (mime_part);
-}
-
-
-/**
- * g_mime_part_get_content_disposition:
- * @mime_part: Mime part
- *
- * Gets the content disposition if set or %NULL otherwise.
- *
- * Returns the content disposition for the specified mime part.
- **/
-const char *
-g_mime_part_get_content_disposition (GMimePart *mime_part)
-{
- g_return_val_if_fail (GMIME_IS_PART (mime_part), NULL);
-
- if (mime_part->disposition)
- return g_mime_disposition_get (mime_part->disposition);
-
- return NULL;
-}
-
-
-/**
- * g_mime_part_add_content_disposition_parameter:
- * @mime_part: Mime part
- * @attribute: parameter name
- * @value: parameter value
- *
- * Add a content-disposition parameter to the specified mime part.
- **/
-void
-g_mime_part_add_content_disposition_parameter (GMimePart *mime_part, const char *attribute, const char *value)
-{
- g_return_if_fail (GMIME_IS_PART (mime_part));
- g_return_if_fail (attribute != NULL);
-
- if (!mime_part->disposition)
- mime_part->disposition = g_mime_disposition_new (GMIME_DISPOSITION_ATTACHMENT);
-
- g_mime_disposition_add_parameter (mime_part->disposition, attribute, value);
-
- sync_content_disposition (mime_part);
-}
-
-
-/**
- * g_mime_part_get_content_disposition_parameter:
- * @mime_part: Mime part
- * @attribute: parameter name
- *
- * Gets the value of the Content-Disposition parameter specified by
- * @attribute, or %NULL if the parameter does not exist.
- *
- * Returns the value of a previously defined content-disposition
- * parameter specified by @attribute.
- **/
-const char *
-g_mime_part_get_content_disposition_parameter (GMimePart *mime_part, const char *attribute)
-{
- g_return_val_if_fail (GMIME_IS_PART (mime_part), NULL);
- g_return_val_if_fail (attribute != NULL, NULL);
-
- if (!mime_part->disposition)
- return NULL;
-
- return g_mime_disposition_get_parameter (mime_part->disposition, attribute);
-}
-
-
-/**
* g_mime_part_set_filename:
* @mime_part: Mime part
* @filename: the filename of the Mime Part's content
@@ -1054,16 +877,15 @@
void
g_mime_part_set_filename (GMimePart *mime_part, const char *filename)
{
- g_return_if_fail (GMIME_IS_PART (mime_part));
-
- if (!mime_part->disposition)
- mime_part->disposition = g_mime_disposition_new (GMIME_DISPOSITION_ATTACHMENT);
+ GMimeObject *object = (GMimeObject *) mime_part;
- g_mime_disposition_add_parameter (mime_part->disposition, "filename", filename);
+ g_return_if_fail (GMIME_IS_PART (mime_part));
- g_mime_object_set_content_type_parameter (GMIME_OBJECT (mime_part), "name", filename);
+ if (!object->disposition)
+ g_mime_object_set_disposition (object, GMIME_DISPOSITION_ATTACHMENT);
- sync_content_disposition (mime_part);
+ g_mime_object_set_content_disposition_parameter (object, "filename", filename);
+ g_mime_object_set_content_type_parameter (object, "name", filename);
}
@@ -1081,135 +903,16 @@
const char *
g_mime_part_get_filename (const GMimePart *mime_part)
{
+ GMimeObject *object = (GMimeObject *) mime_part;
const char *filename = NULL;
g_return_val_if_fail (GMIME_IS_PART (mime_part), NULL);
- if (mime_part->disposition)
- filename = g_mime_disposition_get_parameter (mime_part->disposition, "filename");
-
- if (!filename) {
- /* check the "name" param in the content-type */
- return g_mime_object_get_content_type_parameter (GMIME_OBJECT (mime_part), "name");
- }
+ if ((filename = g_mime_object_get_content_disposition_parameter (object, "filename")))
+ return filename;
- return filename;
-}
-
-
-/**
- * g_mime_part_set_content:
- * @mime_part: Mime part
- * @content: raw mime part content
- * @len: raw content length
- *
- * WARNING: This interface is deprecated. Use
- * g_mime_part_set_content_object() instead.
- *
- * Sets the content of the Mime Part (only non-multiparts)
- **/
-void
-g_mime_part_set_content (GMimePart *mime_part, const char *content, size_t len)
-{
- GMimeStream *stream;
-
- g_return_if_fail (GMIME_IS_PART (mime_part));
-
- if (!mime_part->content)
- mime_part->content = g_mime_data_wrapper_new ();
-
- stream = g_mime_stream_mem_new_with_buffer (content, len);
- g_mime_data_wrapper_set_stream (mime_part->content, stream);
- g_mime_data_wrapper_set_encoding (mime_part->content, GMIME_PART_ENCODING_DEFAULT);
- g_object_unref (stream);
-}
-
-
-/**
- * g_mime_part_set_content_byte_array:
- * @mime_part: Mime part
- * @content: raw mime part content.
- *
- * WARNING: This interface is deprecated. Use
- * g_mime_part_set_content_object() instead.
- *
- * Sets the content of the Mime Part (only non-multiparts)
- **/
-void
-g_mime_part_set_content_byte_array (GMimePart *mime_part, GByteArray *content)
-{
- GMimeStream *stream;
-
- g_return_if_fail (GMIME_IS_PART (mime_part));
-
- if (!mime_part->content)
- mime_part->content = g_mime_data_wrapper_new ();
-
- stream = g_mime_stream_mem_new_with_byte_array (content);
- g_mime_data_wrapper_set_stream (mime_part->content, stream);
- g_mime_data_wrapper_set_encoding (mime_part->content, GMIME_PART_ENCODING_DEFAULT);
- g_object_unref (stream);
-}
-
-
-/**
- * g_mime_part_set_pre_encoded_content:
- * @mime_part: Mime part
- * @content: encoded mime part content
- * @len: length of the content
- * @encoding: content encoding
- *
- * WARNING: This interface is deprecated. Use
- * g_mime_part_set_content_object() instead.
- *
- * Sets the encoding type and raw content on the mime part after
- * decoding the content.
- **/
-void
-g_mime_part_set_pre_encoded_content (GMimePart *mime_part, const char *content,
- size_t len, GMimePartEncodingType encoding)
-{
- GMimeStream *stream, *filtered_stream;
- GMimeFilter *filter;
-
- g_return_if_fail (GMIME_IS_PART (mime_part));
- g_return_if_fail (content != NULL);
-
- if (!mime_part->content)
- mime_part->content = g_mime_data_wrapper_new ();
-
- stream = g_mime_stream_mem_new ();
- filtered_stream = g_mime_stream_filter_new_with_stream (stream);
- switch (encoding) {
- case GMIME_PART_ENCODING_BASE64:
- filter = g_mime_filter_basic_new_type (GMIME_FILTER_BASIC_BASE64_DEC);
- g_mime_stream_filter_add (GMIME_STREAM_FILTER (filtered_stream), filter);
- g_object_unref (filter);
- break;
- case GMIME_PART_ENCODING_QUOTEDPRINTABLE:
- filter = g_mime_filter_basic_new_type (GMIME_FILTER_BASIC_QP_DEC);
- g_mime_stream_filter_add (GMIME_STREAM_FILTER (filtered_stream), filter);
- g_object_unref (filter);
- break;
- case GMIME_PART_ENCODING_UUENCODE:
- filter = g_mime_filter_basic_new_type (GMIME_FILTER_BASIC_UU_DEC);
- g_mime_stream_filter_add (GMIME_STREAM_FILTER (filtered_stream), filter);
- g_object_unref (filter);
- break;
- default:
- break;
- }
-
- g_mime_stream_write (filtered_stream, (char *) content, len);
- g_mime_stream_flush (filtered_stream);
- g_object_unref (filtered_stream);
-
- g_mime_stream_reset (stream);
- g_mime_data_wrapper_set_stream (mime_part->content, stream);
- g_mime_data_wrapper_set_encoding (mime_part->content, GMIME_PART_ENCODING_DEFAULT);
- g_object_unref (stream);
-
- mime_part->encoding = encoding;
+ /* check the "name" param in the content-type */
+ return g_mime_object_get_content_type_parameter (object, "name");
}
@@ -1254,72 +957,3 @@
return mime_part->content;
}
-
-
-/**
- * g_mime_part_get_content:
- * @mime_part: MIME part object
- * @len: pointer to the content length
- *
- * Gets the raw contents of the mime part and sets @len to the length
- * of the raw data buffer.
- *
- * WARNING: This interface is deprecated. Use
- * g_mime_part_get_content_object() instead.
- *
- * Returns a const char * pointer to the raw contents of the MIME Part
- * and sets @len to the length of the buffer. Note: textual content
- * will not be converted to UTF-8. Also note that this buffer will not
- * be nul-terminated and may in fact contain nul bytes mid-buffer so
- * you MUST treat the data returned as raw binary data even if the
- * content type is text.
- **/
-const char *
-g_mime_part_get_content (const GMimePart *mime_part, size_t *len)
-{
- const char *retval = NULL;
- GMimeStream *stream;
-
- g_return_val_if_fail (GMIME_IS_PART (mime_part), NULL);
-
- if (!mime_part->content || !mime_part->content->stream) {
- d(g_warning ("no content set on this mime part"));
- return NULL;
- }
-
- stream = mime_part->content->stream;
- if (!GMIME_IS_STREAM_MEM (stream) || NEEDS_DECODING (mime_part->content->encoding)) {
- /* Decode and cache this mime part's contents... */
- GMimeStream *cache;
- GByteArray *buf;
-
- buf = g_byte_array_new ();
- cache = g_mime_stream_mem_new_with_byte_array (buf);
-
- g_mime_data_wrapper_write_to_stream (mime_part->content, cache);
-
- g_mime_data_wrapper_set_stream (mime_part->content, cache);
- g_mime_data_wrapper_set_encoding (mime_part->content, GMIME_PART_ENCODING_DEFAULT);
- g_object_unref (cache);
-
- *len = buf->len;
- retval = (char *) buf->data;
- } else {
- GByteArray *buf = GMIME_STREAM_MEM (stream)->buffer;
- gint64 end_index = (gint64) buf->len;
- gint64 start_index = 0;
-
- /* check boundaries */
- if (stream->bound_start >= 0)
- start_index = CLAMP (stream->bound_start, 0, (gint64) buf->len);
- if (stream->bound_end >= 0)
- end_index = CLAMP (stream->bound_end, 0, (gint64) buf->len);
- if (end_index < start_index)
- end_index = start_index;
-
- *len = end_index - start_index;
- retval = (char *) buf->data + start_index;
- }
-
- return retval;
-}
Modified: trunk/gmime/gmime-part.h
==============================================================================
--- trunk/gmime/gmime-part.h (original)
+++ trunk/gmime/gmime-part.h Wed May 28 00:18:44 2008
@@ -26,8 +26,6 @@
#include <stdio.h>
#include <gmime/gmime-object.h>
-#include <gmime/gmime-param.h>
-#include <gmime/gmime-disposition.h>
#include <gmime/gmime-data-wrapper.h>
G_BEGIN_DECLS
@@ -46,7 +44,6 @@
GMimeObject parent_object;
GMimePartEncodingType encoding;
- GMimeDisposition *disposition;
char *content_description;
char *content_location;
char *content_md5;
@@ -83,34 +80,14 @@
void g_mime_part_set_content_location (GMimePart *mime_part, const char *content_location);
const char *g_mime_part_get_content_location (GMimePart *mime_part);
-void g_mime_part_set_content_type (GMimePart *mime_part, GMimeContentType *mime_type);
-const GMimeContentType *g_mime_part_get_content_type (GMimePart *mime_part);
-
void g_mime_part_set_encoding (GMimePart *mime_part, GMimePartEncodingType encoding);
GMimePartEncodingType g_mime_part_get_encoding (GMimePart *mime_part);
const char *g_mime_part_encoding_to_string (GMimePartEncodingType encoding);
GMimePartEncodingType g_mime_part_encoding_from_string (const char *encoding);
-const GMimeDisposition *g_mime_part_get_content_disposition_object (GMimePart *mime_part);
-void g_mime_part_set_content_disposition_object (GMimePart *mime_part, GMimeDisposition *disposition);
-void g_mime_part_set_content_disposition (GMimePart *mime_part, const char *disposition);
-const char *g_mime_part_get_content_disposition (GMimePart *mime_part);
-
-void g_mime_part_add_content_disposition_parameter (GMimePart *mime_part, const char *attribute,
- const char *value);
-const char *g_mime_part_get_content_disposition_parameter (GMimePart *mime_part, const char *attribute);
-
void g_mime_part_set_filename (GMimePart *mime_part, const char *filename);
const char *g_mime_part_get_filename (const GMimePart *mime_part);
-#ifndef GMIME_DISABLE_DEPRECATED
-void g_mime_part_set_content_byte_array (GMimePart *mime_part, GByteArray *content);
-void g_mime_part_set_content (GMimePart *mime_part, const char *content, size_t len);
-void g_mime_part_set_pre_encoded_content (GMimePart *mime_part, const char *content,
- size_t len, GMimePartEncodingType encoding);
-const char *g_mime_part_get_content (const GMimePart *mime_part, size_t *len);
-#endif /* GMIME_DISABLE_DEPRECATED */
-
void g_mime_part_set_content_object (GMimePart *mime_part, GMimeDataWrapper *content);
GMimeDataWrapper *g_mime_part_get_content_object (const GMimePart *mime_part);
Modified: trunk/mono/gmime-api.raw
==============================================================================
--- trunk/mono/gmime-api.raw (original)
+++ trunk/mono/gmime-api.raw Wed May 28 00:18:44 2008
@@ -698,13 +698,6 @@
<method name="GetAllRecipients" cname="g_mime_message_get_all_recipients">
<return-type type="InternetAddressList*" />
</method>
- <method name="GetBody" cname="g_mime_message_get_body" deprecated="1">
- <return-type type="char*" />
- <parameters>
- <parameter type="gboolean" name="want_plain" />
- <parameter type="gboolean*" name="is_html" />
- </parameters>
- </method>
<method name="GetDate" cname="g_mime_message_get_date">
<return-type type="void" />
<parameters>
@@ -1050,6 +1043,7 @@
</method>
</object>
<object name="Object" cname="GMimeObject" parent="GObject">
+ <field name="Disposition" cname="disposition" type="GMimeContentDisposition*" />
<field name="ContentType" cname="content_type" type="GMimeContentType*" />
<field name="Headers" cname="headers" type="GMimeHeader*" />
<field name="ContentId" cname="content_id" type="char*" />
@@ -1109,6 +1103,15 @@
<parameter type="const-char*" name="value" />
</parameters>
</method>
+ <method name="GetContentDisposition" cname="g_mime_object_get_content_disposition">
+ <return-type type="const-GMimeContentDisposition*" />
+ </method>
+ <method name="GetContentDispositionParameter" cname="g_mime_object_get_content_disposition_parameter">
+ <return-type type="const-char*" />
+ <parameters>
+ <parameter type="const-char*" name="attribute" />
+ </parameters>
+ </method>
<method name="GetContentId" cname="g_mime_object_get_content_id">
<return-type type="const-char*" />
</method>
@@ -1121,6 +1124,9 @@
<parameter type="const-char*" name="name" />
</parameters>
</method>
+ <method name="GetDisposition" cname="g_mime_object_get_disposition">
+ <return-type type="const-char*" />
+ </method>
<method name="GetHeader" cname="g_mime_object_get_header">
<return-type type="const-char*" />
<parameters>
@@ -1153,6 +1159,19 @@
<parameter type="const-char*" name="header" />
</parameters>
</method>
+ <method name="SetContentDisposition" cname="g_mime_object_set_content_disposition">
+ <return-type type="void" />
+ <parameters>
+ <parameter type="GMimeContentDisposition*" name="disposition" />
+ </parameters>
+ </method>
+ <method name="SetContentDispositionParameter" cname="g_mime_object_set_content_disposition_parameter">
+ <return-type type="void" />
+ <parameters>
+ <parameter type="const-char*" name="attribute" />
+ <parameter type="const-char*" name="value" />
+ </parameters>
+ </method>
<method name="SetContentId" cname="g_mime_object_set_content_id">
<return-type type="void" />
<parameters>
@@ -1172,6 +1191,12 @@
<parameter type="const-char*" name="value" />
</parameters>
</method>
+ <method name="SetDisposition" cname="g_mime_object_set_disposition">
+ <return-type type="void" />
+ <parameters>
+ <parameter type="const-char*" name="disposition" />
+ </parameters>
+ </method>
<method name="SetHeader" cname="g_mime_object_set_header">
<return-type type="void" />
<parameters>
@@ -1262,18 +1287,10 @@
</object>
<object name="Part" cname="GMimePart" parent="GMimeObject">
<field name="Encoding" cname="encoding" type="GMimePartEncodingType" />
- <field name="Disposition" cname="disposition" type="GMimeDisposition*" />
<field name="ContentDescription" cname="content_description" type="char*" />
<field name="ContentLocation" cname="content_location" type="char*" />
<field name="ContentMd5" cname="content_md5" type="char*" />
<field name="Content" cname="content" type="GMimeDataWrapper*" />
- <method name="AddContentDispositionParameter" cname="g_mime_part_add_content_disposition_parameter">
- <return-type type="void" />
- <parameters>
- <parameter type="const-char*" name="attribute" />
- <parameter type="const-char*" name="value" />
- </parameters>
- </method>
<method name="EncodingFromString" cname="g_mime_part_encoding_from_string" shared="true">
<return-type type="GMimePartEncodingType" />
<parameters>
@@ -1286,27 +1303,9 @@
<parameter type="GMimePartEncodingType" name="encoding" />
</parameters>
</method>
- <method name="GetContent" cname="g_mime_part_get_content" deprecated="1">
- <return-type type="const-char*" />
- <parameters>
- <parameter type="size_t*" name="len" />
- </parameters>
- </method>
<method name="GetContentDescription" cname="g_mime_part_get_content_description">
<return-type type="const-char*" />
</method>
- <method name="GetContentDisposition" cname="g_mime_part_get_content_disposition">
- <return-type type="const-char*" />
- </method>
- <method name="GetContentDispositionObject" cname="g_mime_part_get_content_disposition_object">
- <return-type type="const-GMimeDisposition*" />
- </method>
- <method name="GetContentDispositionParameter" cname="g_mime_part_get_content_disposition_parameter">
- <return-type type="const-char*" />
- <parameters>
- <parameter type="const-char*" name="attribute" />
- </parameters>
- </method>
<method name="GetContentHeader" cname="g_mime_part_get_content_header">
<return-type type="const-char*" />
<parameters>
@@ -1344,37 +1343,12 @@
<parameter type="const-char*" name="subtype" />
</parameters>
</constructor>
- <method name="SetContent" cname="g_mime_part_set_content" deprecated="1">
- <return-type type="void" />
- <parameters>
- <parameter type="const-char*" name="content" />
- <parameter type="size_t" name="len" />
- </parameters>
- </method>
- <method name="SetContentByteArray" cname="g_mime_part_set_content_byte_array" deprecated="1">
- <return-type type="void" />
- <parameters>
- <parameter type="GByteArray*" name="content" />
- </parameters>
- </method>
<method name="SetContentDescription" cname="g_mime_part_set_content_description">
<return-type type="void" />
<parameters>
<parameter type="const-char*" name="description" />
</parameters>
</method>
- <method name="SetContentDisposition" cname="g_mime_part_set_content_disposition">
- <return-type type="void" />
- <parameters>
- <parameter type="const-char*" name="disposition" />
- </parameters>
- </method>
- <method name="SetContentDispositionObject" cname="g_mime_part_set_content_disposition_object">
- <return-type type="void" />
- <parameters>
- <parameter type="GMimeDisposition*" name="disposition" />
- </parameters>
- </method>
<method name="SetContentHeader" cname="g_mime_part_set_content_header">
<return-type type="void" />
<parameters>
@@ -1424,14 +1398,6 @@
<parameter type="const-char*" name="filename" />
</parameters>
</method>
- <method name="SetPreEncodedContent" cname="g_mime_part_set_pre_encoded_content" deprecated="1">
- <return-type type="void" />
- <parameters>
- <parameter type="const-char*" name="content" />
- <parameter type="size_t" name="len" />
- <parameter type="GMimePartEncodingType" name="encoding" />
- </parameters>
- </method>
<method name="VerifyContentMd5" cname="g_mime_part_verify_content_md5">
<return-type type="gboolean" />
</method>
@@ -1973,89 +1939,90 @@
</parameters>
</method>
</struct>
- <struct name="ContentType" cname="GMimeContentType" opaque="true">
- <field name="Type" cname="type" type="char*" access="public" writeable="true" />
- <field name="Subtype" cname="subtype" type="char*" access="public" writeable="true" />
+ <struct name="ContentDisposition" cname="GMimeContentDisposition" opaque="true">
+ <field name="Disposition" cname="disposition" type="char*" access="public" writeable="true" />
<field name="Params" cname="params" type="GMimeParam*" access="public" writeable="true" />
<field name="ParamHash" cname="param_hash" type="GHashTable*" access="public" writeable="true" />
- <method name="Destroy" cname="g_mime_content_type_destroy">
+ <method name="Destroy" cname="g_mime_content_disposition_destroy">
<return-type type="void" />
</method>
- <method name="GetParameter" cname="g_mime_content_type_get_parameter">
+ <method name="GetDisposition" cname="g_mime_content_disposition_get_disposition">
+ <return-type type="const-char*" />
+ </method>
+ <method name="GetParameter" cname="g_mime_content_disposition_get_parameter">
<return-type type="const-char*" />
<parameters>
<parameter type="const-char*" name="attribute" />
</parameters>
</method>
- <method name="IsType" cname="g_mime_content_type_is_type">
- <return-type type="gboolean" />
+ <constructor cname="g_mime_content_disposition_new" />
+ <constructor cname="g_mime_content_disposition_new_from_string">
<parameters>
- <parameter type="const-char*" name="type" />
- <parameter type="const-char*" name="subtype" />
- </parameters>
- </method>
- <constructor cname="g_mime_content_type_new">
- <parameters>
- <parameter type="const-char*" name="type" />
- <parameter type="const-char*" name="subtype" />
+ <parameter type="const-char*" name="str" />
</parameters>
</constructor>
- <constructor cname="g_mime_content_type_new_from_string">
+ <method name="SetDisposition" cname="g_mime_content_disposition_set_disposition">
+ <return-type type="void" />
<parameters>
- <parameter type="const-char*" name="string" />
+ <parameter type="const-char*" name="value" />
</parameters>
- </constructor>
- <method name="SetParameter" cname="g_mime_content_type_set_parameter">
+ </method>
+ <method name="SetParameter" cname="g_mime_content_disposition_set_parameter">
<return-type type="void" />
<parameters>
<parameter type="const-char*" name="attribute" />
<parameter type="const-char*" name="value" />
</parameters>
</method>
- <method name="ToString" cname="g_mime_content_type_to_string">
+ <method name="ToString" cname="g_mime_content_disposition_to_string">
<return-type type="char*" />
+ <parameters>
+ <parameter type="gboolean" name="fold" />
+ </parameters>
</method>
</struct>
- <struct name="Disposition" cname="GMimeDisposition" opaque="true">
- <field name="Disposition" cname="disposition" type="char*" access="public" writeable="true" />
+ <struct name="ContentType" cname="GMimeContentType" opaque="true">
+ <field name="Type" cname="type" type="char*" access="public" writeable="true" />
+ <field name="Subtype" cname="subtype" type="char*" access="public" writeable="true" />
<field name="Params" cname="params" type="GMimeParam*" access="public" writeable="true" />
<field name="ParamHash" cname="param_hash" type="GHashTable*" access="public" writeable="true" />
- <method name="AddParameter" cname="g_mime_disposition_add_parameter">
- <return-type type="void" />
- <parameters>
- <parameter type="const-char*" name="attribute" />
- <parameter type="const-char*" name="value" />
- </parameters>
- </method>
- <method name="Destroy" cname="g_mime_disposition_destroy">
+ <method name="Destroy" cname="g_mime_content_type_destroy">
<return-type type="void" />
</method>
- <method name="Get" cname="g_mime_disposition_get">
- <return-type type="const-char*" />
- </method>
- <method name="GetParameter" cname="g_mime_disposition_get_parameter">
+ <method name="GetParameter" cname="g_mime_content_type_get_parameter">
<return-type type="const-char*" />
<parameters>
<parameter type="const-char*" name="attribute" />
</parameters>
</method>
- <method name="Header" cname="g_mime_disposition_header">
- <return-type type="char*" />
+ <method name="IsType" cname="g_mime_content_type_is_type">
+ <return-type type="gboolean" />
<parameters>
- <parameter type="gboolean" name="fold" />
+ <parameter type="const-char*" name="type" />
+ <parameter type="const-char*" name="subtype" />
</parameters>
</method>
- <constructor cname="g_mime_disposition_new">
+ <constructor cname="g_mime_content_type_new">
<parameters>
- <parameter type="const-char*" name="disposition" />
+ <parameter type="const-char*" name="type" />
+ <parameter type="const-char*" name="subtype" />
+ </parameters>
+ </constructor>
+ <constructor cname="g_mime_content_type_new_from_string">
+ <parameters>
+ <parameter type="const-char*" name="string" />
</parameters>
</constructor>
- <method name="Set" cname="g_mime_disposition_set">
+ <method name="SetParameter" cname="g_mime_content_type_set_parameter">
<return-type type="void" />
<parameters>
+ <parameter type="const-char*" name="attribute" />
<parameter type="const-char*" name="value" />
</parameters>
</method>
+ <method name="ToString" cname="g_mime_content_type_to_string">
+ <return-type type="char*" />
+ </method>
</struct>
<struct name="Header" cname="GMimeHeader" opaque="true">
<method name="Add" cname="g_mime_header_add">
@@ -2751,7 +2718,7 @@
<method name="UnquoteString" cname="g_mime_utils_unquote_string" shared="true">
<return-type type="void" />
<parameters>
- <parameter type="char*" name="string" />
+ <parameter type="char*" name="str" />
</parameters>
</method>
<method name="UnstructuredHeaderFold" cname="g_mime_utils_unstructured_header_fold" shared="true">
Modified: trunk/tests/test-parser.c
==============================================================================
--- trunk/tests/test-parser.c (original)
+++ trunk/tests/test-parser.c Wed May 28 00:18:44 2008
@@ -39,7 +39,6 @@
/*#define TEST_RAW_HEADER*/
#define TEST_PRESERVE_HEADERS
-#define TEST_GET_BODY
#define PRINT_MIME_STRUCT
/*#define TEST_WRITE_TO_STREAM*/
@@ -140,20 +139,6 @@
}
#endif
-#ifdef TEST_GET_BODY
- {
- /* test of get_body */
- char *body;
-
- body = g_mime_message_get_body (message, FALSE, &is_html);
- fprintf (stdout, "Testing get_body (looking for html...%s)\n\n-->%s<--\n\n",
- body && is_html ? "found" : "not found",
- body ? body : "No message body found");
-
- g_free (body);
- }
-#endif
-
#ifdef TEST_WRITE_TO_STREAM
stream = g_mime_stream_fs_new (2);
g_mime_object_write_to_stream (GMIME_OBJECT (message), stream);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]