RE: Priorities and attachments



On Fri, 2007-03-23 at 17:20 +0100, Philip Van Hoof wrote:


> > > (BTW, I noticed that eg. tny_mime_part_has_content_type does not
> > >  match case-insensitively)
> > 
> > I'm already waiting for your patch :) (I think it should do it case
> > insensitively and have it documented that way).
> 
> I haven't yet committed a fix for this one.

I checked this, it should match case insensitively.


int
camel_content_type_is(CamelContentType *ct, const char *type, const char
*subtype)
{
	/* no type == text/plain or text/"*" */
	if (ct==NULL || (ct->type == NULL && ct->subtype == NULL)) {
		return (!g_ascii_strcasecmp(type, "text")
			&& (!g_ascii_strcasecmp(subtype, "plain")
			    || !strcmp(subtype, "*")));
	}

	return (ct->type != NULL
		&& (!g_ascii_strcasecmp(ct->type, type)
		    && ((ct->subtype != NULL
			 && !g_ascii_strcasecmp(ct->subtype, subtype))
			|| !strcmp("*", subtype))));
}




static gboolean 
tny_camel_mime_part_content_type_is_default (TnyMimePart *self, const
gchar *type)
{
	TnyCamelMimePartPriv *priv = TNY_CAMEL_MIME_PART_GET_PRIVATE (self);
	CamelContentType *ctype;
	gchar *dup, *str1, *str2, *ptr;
	gboolean retval = FALSE;

	g_mutex_lock (priv->part_lock);
	ctype = camel_mime_part_get_content_type (priv->part);
	g_mutex_unlock (priv->part_lock);

	/* Whoooo, pointer hocus .. */

	dup = g_strdup (type);
	ptr = strchr (dup, '/');
	ptr++; str2 = g_strdup (ptr);
	ptr--; *ptr = '\0'; str1 = dup;

	/* pocus ! */

	retval = camel_content_type_is (ctype, (const char*)str1, 
			(const char*)str2);

	/* TODO: Q: camel_content_type_unref (ctype); */

	g_free (dup);
	g_free (str2);

	return retval;
}

-- 
Philip Van Hoof, software developer
home: me at pvanhoof dot be 
gnome: pvanhoof at gnome dot org 
http://www.pvanhoof.be/blog







[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]