aboutsummaryrefslogtreecommitdiffstats
path: root/mail/em-format-html.c
diff options
context:
space:
mode:
authorMatthew Barnes <mbarnes@redhat.com>2009-05-27 22:29:19 +0800
committerMatthew Barnes <mbarnes@redhat.com>2009-05-27 22:29:19 +0800
commit948235c3d1076dbe6ed2e57a24c16a083bbd9f01 (patch)
tree4133b1adfd94d8f889ca7ad4ad851346518f4171 /mail/em-format-html.c
parentcc3a98fc1ad5bb87aa7335f3de404ee7feee1541 (diff)
downloadgsoc2013-evolution-948235c3d1076dbe6ed2e57a24c16a083bbd9f01.tar.gz
gsoc2013-evolution-948235c3d1076dbe6ed2e57a24c16a083bbd9f01.tar.zst
gsoc2013-evolution-948235c3d1076dbe6ed2e57a24c16a083bbd9f01.zip
Prefer GLib basic types over C types.
Diffstat (limited to 'mail/em-format-html.c')
-rw-r--r--mail/em-format-html.c156
1 files changed, 78 insertions, 78 deletions
diff --git a/mail/em-format-html.c b/mail/em-format-html.c
index 6bc4a79794..1991c0d67f 100644
--- a/mail/em-format-html.c
+++ b/mail/em-format-html.c
@@ -92,12 +92,12 @@
struct _EMFormatHTMLCache {
CamelMultipart *textmp;
- char partid[1];
+ gchar partid[1];
};
struct _EMFormatHTMLPrivate {
struct _CamelMimeMessage *last_part; /* not reffed, DO NOT dereference */
- volatile int format_id; /* format thread id */
+ volatile gint format_id; /* format thread id */
guint format_timeout_id;
struct _format_msg *format_timeout_msg;
@@ -129,7 +129,7 @@ enum {
PROP_TEXT_COLOR
};
-static void efh_url_requested(GtkHTML *html, const char *url, GtkHTMLStream *handle, EMFormatHTML *efh);
+static void efh_url_requested(GtkHTML *html, const gchar *url, GtkHTMLStream *handle, EMFormatHTML *efh);
static gboolean efh_object_requested(GtkHTML *html, GtkHTMLEmbedded *eb, EMFormatHTML *efh);
static void efh_gtkhtml_destroy(GtkHTML *html, EMFormatHTML *efh);
@@ -154,7 +154,7 @@ struct _format_msg {
EMFormat *format_source;
EMHTMLStream *estream;
CamelFolder *folder;
- char *uid;
+ gchar *uid;
CamelMimeMessage *message;
};
@@ -169,7 +169,7 @@ efh_format_exec (struct _format_msg *m)
{
struct _EMFormatHTMLJob *job;
struct _EMFormatPURITree *puri_level;
- int cancelled = FALSE;
+ gint cancelled = FALSE;
CamelURL *base;
if (m->format->html == NULL)
@@ -395,7 +395,7 @@ efh_gtkhtml_destroy(GtkHTML *html, EMFormatHTML *efh)
}
static struct _EMFormatHTMLCache *
-efh_insert_cache(EMFormatHTML *efh, const char *partid)
+efh_insert_cache(EMFormatHTML *efh, const gchar *partid)
{
struct _EMFormatHTMLCache *efhc;
@@ -685,7 +685,7 @@ efh_format_attachment (EMFormat *emf,
const gchar *mime_type,
const EMFormatHandler *handle)
{
- char *text, *html;
+ gchar *text, *html;
/* we display all inlined attachments only */
@@ -1123,12 +1123,12 @@ em_format_html_set_show_sender_photo (EMFormatHTML *efh,
}
CamelMimePart *
-em_format_html_file_part(EMFormatHTML *efh, const char *mime_type, const char *filename)
+em_format_html_file_part(EMFormatHTML *efh, const gchar *mime_type, const gchar *filename)
{
CamelMimePart *part;
CamelStream *stream;
CamelDataWrapper *dw;
- char *basename;
+ gchar *basename;
stream = camel_stream_fs_new_with_name(filename, O_RDONLY, 0);
if (stream == NULL)
@@ -1153,7 +1153,7 @@ em_format_html_file_part(EMFormatHTML *efh, const char *mime_type, const char *f
/* all this api is a pain in the bum ... */
EMFormatHTMLPObject *
-em_format_html_add_pobject(EMFormatHTML *efh, size_t size, const char *classid, CamelMimePart *part, EMFormatHTMLPObjectFunc func)
+em_format_html_add_pobject(EMFormatHTML *efh, size_t size, const gchar *classid, CamelMimePart *part, EMFormatHTMLPObjectFunc func)
{
EMFormatHTMLPObject *pobj;
@@ -1178,7 +1178,7 @@ em_format_html_add_pobject(EMFormatHTML *efh, size_t size, const char *classid,
}
EMFormatHTMLPObject *
-em_format_html_find_pobject(EMFormatHTML *emf, const char *classid)
+em_format_html_find_pobject(EMFormatHTML *emf, const gchar *classid)
{
EMFormatHTMLPObject *pw;
@@ -1226,7 +1226,7 @@ em_format_html_clear_pobject(EMFormatHTML *emf)
}
struct _EMFormatHTMLJob *
-em_format_html_job_new(EMFormatHTML *emfh, void (*callback)(struct _EMFormatHTMLJob *job, int cancelled), void *data)
+em_format_html_job_new(EMFormatHTML *emfh, void (*callback)(struct _EMFormatHTMLJob *job, gint cancelled), gpointer data)
{
struct _EMFormatHTMLJob *job = g_malloc0(sizeof(*job));
@@ -1250,22 +1250,22 @@ em_format_html_job_queue(EMFormatHTML *emfh, struct _EMFormatHTMLJob *job)
/* ********************************************************************** */
-static void emfh_getpuri(struct _EMFormatHTMLJob *job, int cancelled)
+static void emfh_getpuri(struct _EMFormatHTMLJob *job, gint cancelled)
{
d(printf(" running getpuri task\n"));
if (!cancelled)
job->u.puri->func((EMFormat *)job->format, job->stream, job->u.puri);
}
-static void emfh_gethttp(struct _EMFormatHTMLJob *job, int cancelled)
+static void emfh_gethttp(struct _EMFormatHTMLJob *job, gint cancelled)
{
CamelStream *cistream = NULL, *costream = NULL, *instream = NULL;
CamelURL *url;
CamelContentType *content_type;
CamelHttpStream *tmp_stream;
ssize_t n, total = 0, pc_complete = 0, nread = 0;
- char buffer[1500];
- const char *length;
+ gchar buffer[1500];
+ const gchar *length;
if (cancelled
|| (url = camel_url_new(job->u.uri, NULL)) == NULL)
@@ -1278,7 +1278,7 @@ static void emfh_gethttp(struct _EMFormatHTMLJob *job, int cancelled)
if (instream == NULL) {
MailConfigHTTPMode policy;
- char *proxy;
+ gchar *proxy;
policy = em_format_html_get_image_loading_policy (job->format);
@@ -1364,7 +1364,7 @@ badurl:
/* ********************************************************************** */
static void
-efh_url_requested(GtkHTML *html, const char *url, GtkHTMLStream *handle, EMFormatHTML *efh)
+efh_url_requested(GtkHTML *html, const gchar *url, GtkHTMLStream *handle, EMFormatHTML *efh)
{
EMFormatPURI *puri;
struct _EMFormatHTMLJob *job = NULL;
@@ -1398,7 +1398,7 @@ efh_url_requested(GtkHTML *html, const char *url, GtkHTMLStream *handle, EMForma
d(printf(" adding job, get %s\n", url));
job = em_format_html_job_new(efh, emfh_gethttp, g_strdup(url));
} else if (g_ascii_strncasecmp(url, "/", 1) == 0) {
- char *data = NULL;
+ gchar *data = NULL;
gsize length = 0;
gboolean status;
@@ -1423,7 +1423,7 @@ static gboolean
efh_object_requested(GtkHTML *html, GtkHTMLEmbedded *eb, EMFormatHTML *efh)
{
EMFormatHTMLPObject *pobject;
- int res = FALSE;
+ gint res = FALSE;
if (eb->classid == NULL)
return FALSE;
@@ -1447,7 +1447,7 @@ efh_object_requested(GtkHTML *html, GtkHTMLEmbedded *eb, EMFormatHTML *efh)
/* FIXME: This is duplicated in em-format-html-display, should be exported or in security module */
static const struct {
- const char *icon, *shortdesc;
+ const gchar *icon, *shortdesc;
} smime_sign_table[5] = {
{ "stock_signature-bad", N_("Unsigned") },
{ "stock_signature-ok", N_("Valid signature") },
@@ -1457,7 +1457,7 @@ static const struct {
};
static const struct {
- const char *icon, *shortdesc;
+ const gchar *icon, *shortdesc;
} smime_encrypt_table[4] = {
{ "stock_lock-broken", N_("Unencrypted") },
{ "stock_lock", N_("Encrypted, weak"),},
@@ -1465,7 +1465,7 @@ static const struct {
{ "stock_lock-ok", N_("Encrypted, strong") },
};
-static const char *smime_sign_colour[4] = {
+static const gchar *smime_sign_colour[4] = {
"", " bgcolor=\"#88bb88\"", " bgcolor=\"#bb8888\"", " bgcolor=\"#e8d122\""
};
@@ -1487,8 +1487,8 @@ efh_format_secure(EMFormat *emf, CamelStream *stream, CamelMimePart *part, Camel
if (emf->valid == valid
&& (valid->encrypt.status != CAMEL_CIPHER_VALIDITY_ENCRYPT_NONE
|| valid->sign.status != CAMEL_CIPHER_VALIDITY_SIGN_NONE)) {
- char *classid, *iconpath;
- const char *icon;
+ gchar *classid, *iconpath;
+ const gchar *icon;
CamelMimePart *iconpart;
camel_stream_printf (stream, "<table border=0 width=\"100%%\" cellpadding=3 cellspacing=0%s><tr>",
@@ -1530,10 +1530,10 @@ efh_text_plain(EMFormatHTML *efh, CamelStream *stream, CamelMimePart *part, EMFo
CamelMultipart *mp;
CamelDataWrapper *dw;
CamelContentType *type;
- const char *format;
+ const gchar *format;
guint32 flags;
guint32 rgb;
- int i, count, len;
+ gint i, count, len;
struct _EMFormatHTMLCache *efhc;
flags = efh->text_html_flags;
@@ -1679,7 +1679,7 @@ efh_write_text_html(EMFormat *emf, CamelStream *stream, EMFormatPURI *puri)
{
#if d(!)0
CamelStream *out;
- int fd;
+ gint fd;
CamelDataWrapper *dw;
fd = dup(STDOUT_FILENO);
@@ -1696,10 +1696,10 @@ efh_write_text_html(EMFormat *emf, CamelStream *stream, EMFormatPURI *puri)
static void
efh_text_html(EMFormatHTML *efh, CamelStream *stream, CamelMimePart *part, EMFormatHandler *info)
{
- const char *location;
+ const gchar *location;
/* This is set but never used for anything */
EMFormatPURI *puri;
- char *cid = NULL;
+ gchar *cid = NULL;
camel_stream_printf (
stream, "<div style=\"border: solid #%06x 1px; background-color: #%06x; color: #%06x;\">\n"
@@ -1751,8 +1751,8 @@ static void
efh_message_external(EMFormatHTML *efh, CamelStream *stream, CamelMimePart *part, EMFormatHandler *info)
{
CamelContentType *type;
- const char *access_type;
- char *url = NULL, *desc = NULL;
+ const gchar *access_type;
+ gchar *url = NULL, *desc = NULL;
if (!part) {
camel_stream_printf(stream, _("Unknown external-body part."));
@@ -1769,9 +1769,9 @@ efh_message_external(EMFormatHTML *efh, CamelStream *stream, CamelMimePart *part
if (!g_ascii_strcasecmp(access_type, "ftp") ||
!g_ascii_strcasecmp(access_type, "anon-ftp")) {
- const char *name, *site, *dir, *mode;
- char *path;
- char ftype[16];
+ const gchar *name, *site, *dir, *mode;
+ gchar *path;
+ gchar ftype[16];
name = camel_content_type_param (type, "name");
site = camel_content_type_param (type, "site");
@@ -1795,7 +1795,7 @@ efh_message_external(EMFormatHTML *efh, CamelStream *stream, CamelMimePart *part
g_free (path);
desc = g_strdup_printf (_("Pointer to FTP site (%s)"), url);
} else if (!g_ascii_strcasecmp (access_type, "local-file")) {
- const char *name, *site;
+ const gchar *name, *site;
name = camel_content_type_param (type, "name");
site = camel_content_type_param (type, "site");
@@ -1808,8 +1808,8 @@ efh_message_external(EMFormatHTML *efh, CamelStream *stream, CamelMimePart *part
else
desc = g_strdup_printf(_("Pointer to local file (%s)"), name);
} else if (!g_ascii_strcasecmp (access_type, "URL")) {
- const char *urlparam;
- char *s, *d;
+ const gchar *urlparam;
+ gchar *s, *d;
/* RFC 2017 */
@@ -1882,11 +1882,11 @@ emfh_write_related(EMFormat *emf, CamelStream *stream, EMFormatPURI *puri)
}
static void
-emfh_multipart_related_check(struct _EMFormatHTMLJob *job, int cancelled)
+emfh_multipart_related_check(struct _EMFormatHTMLJob *job, gint cancelled)
{
struct _EMFormatPURITree *ptree;
EMFormatPURI *puri, *purin;
- char *oldpartid;
+ gchar *oldpartid;
if (cancelled)
return;
@@ -1921,8 +1921,8 @@ efh_multipart_related(EMFormat *emf, CamelStream *stream, CamelMimePart *part, c
CamelMultipart *mp = (CamelMultipart *)camel_medium_get_content_object((CamelMedium *)part);
CamelMimePart *body_part, *display_part = NULL;
CamelContentType *content_type;
- const char *start;
- int i, nparts, partidlen, displayid = 0;
+ const gchar *start;
+ gint i, nparts, partidlen, displayid = 0;
/* puri is set but never used */
EMFormatPURI *puri;
struct _EMFormatHTMLJob *job;
@@ -1936,8 +1936,8 @@ efh_multipart_related(EMFormat *emf, CamelStream *stream, CamelMimePart *part, c
content_type = camel_mime_part_get_content_type(part);
start = camel_content_type_param (content_type, "start");
if (start && strlen(start)>2) {
- int len;
- const char *cid;
+ gint len;
+ const gchar *cid;
/* strip <>'s */
len = strlen (start) - 2;
@@ -2064,10 +2064,10 @@ efh_builtin_init(EMFormatHTMLClass *efhc)
/* ********************************************************************** */
static void
-efh_format_text_header (EMFormatHTML *emfh, CamelStream *stream, const char *label, const char *value, guint32 flags)
+efh_format_text_header (EMFormatHTML *emfh, CamelStream *stream, const gchar *label, const gchar *value, guint32 flags)
{
- const char *fmt, *html;
- char *mhtml = NULL;
+ const gchar *fmt, *html;
+ gchar *mhtml = NULL;
gboolean is_rtl;
if (value == NULL)
@@ -2126,11 +2126,11 @@ static gchar *
efh_format_address (EMFormatHTML *efh, GString *out, struct _camel_header_address *a, gchar *field)
{
guint32 flags = CAMEL_MIME_FILTER_TOHTML_CONVERT_SPACES;
- char *name, *mailto, *addr;
- int i=0;
+ gchar *name, *mailto, *addr;
+ gint i=0;
gboolean wrap = FALSE;
- char *str = NULL;
- int limit = mail_config_get_address_count ();
+ gchar *str = NULL;
+ gint limit = mail_config_get_address_count ();
if (field ) {
if ((!strcmp (field, _("To")) && !(efh->header_wrap_flags & EM_FORMAT_HTML_HEADER_TO))
@@ -2148,11 +2148,11 @@ efh_format_address (EMFormatHTML *efh, GString *out, struct _camel_header_addres
switch (a->type) {
case CAMEL_HEADER_ADDRESS_NAME:
if (name && *name) {
- char *real, *mailaddr;
+ gchar *real, *mailaddr;
g_string_append_printf (out, "%s &lt;", name);
/* rfc2368 for mailto syntax and url encoding extras */
- if ((real = camel_header_encode_phrase ((unsigned char *)a->name))) {
+ if ((real = camel_header_encode_phrase ((guchar *)a->name))) {
mailaddr = g_strdup_printf("%s <%s>", real, a->v.addr);
g_free (real);
mailto = camel_url_encode (mailaddr, "?=&()");
@@ -2233,9 +2233,9 @@ efh_format_address (EMFormatHTML *efh, GString *out, struct _camel_header_addres
}
static void
-canon_header_name (char *name)
+canon_header_name (gchar *name)
{
- char *inptr = name;
+ gchar *inptr = name;
/* canonicalise the header name... first letter is
* capitalised and any letter following a '-' also gets
@@ -2257,14 +2257,14 @@ canon_header_name (char *name)
}
static void
-efh_format_header(EMFormat *emf, CamelStream *stream, CamelMedium *part, struct _camel_header_raw *header, guint32 flags, const char *charset)
+efh_format_header(EMFormat *emf, CamelStream *stream, CamelMedium *part, struct _camel_header_raw *header, guint32 flags, const gchar *charset)
{
EMFormatHTML *efh = (EMFormatHTML *)emf;
- char *name, *buf, *value = NULL;
- const char *label, *txt;
+ gchar *name, *buf, *value = NULL;
+ const gchar *label, *txt;
gboolean addrspec = FALSE;
- char *str_field = NULL;
- int i;
+ gchar *str_field = NULL;
+ gint i;
name = alloca(strlen(header->name)+1);
strcpy(name, header->name);
@@ -2282,7 +2282,7 @@ efh_format_header(EMFormat *emf, CamelStream *stream, CamelMedium *part, struct
if (addrspec) {
struct _camel_header_address *addrs;
GString *html;
- char *img;
+ gchar *img;
buf = camel_header_unfold (header->value);
if (!(addrs = camel_header_address_decode (buf, emf->charset ? emf->charset : emf->default_charset))) {
@@ -2293,7 +2293,7 @@ efh_format_header(EMFormat *emf, CamelStream *stream, CamelMedium *part, struct
g_free (buf);
html = g_string_new("");
- img = efh_format_address(efh, html, addrs, (char *)label);
+ img = efh_format_address(efh, html, addrs, (gchar *)label);
if (img) {
str_field = g_strdup_printf ("%s%s:", img, label);
@@ -2319,7 +2319,7 @@ efh_format_header(EMFormat *emf, CamelStream *stream, CamelMedium *part, struct
txt = value = camel_header_format_ctext (header->value, charset);
flags |= EM_FORMAT_HEADER_BOLD;
} else if (!strcmp (name, "Date") || !strcmp (name, "Resent-Date")) {
- int msg_offset, local_tz;
+ gint msg_offset, local_tz;
time_t msg_date;
struct tm local;
@@ -2337,17 +2337,17 @@ efh_format_header(EMFormat *emf, CamelStream *stream, CamelMedium *part, struct
msg_offset -= local_tz / 60;
if (msg_offset) {
- char buf[256], *html;
+ gchar buf[256], *html;
msg_offset += (local.tm_hour * 60) + local.tm_min;
if (msg_offset >= (24 * 60) || msg_offset < 0) {
/* translators: strftime format for local time equivalent in Date header display, with day */
- char *msg = g_strdup_printf("<I>%s</I>", _(" (%a, %R %Z)"));
+ gchar *msg = g_strdup_printf("<I>%s</I>", _(" (%a, %R %Z)"));
e_utf8_strftime(buf, sizeof(buf), msg, &local);
g_free(msg);
} else {
/* translators: strftime format for local time equivalent in Date header display, without day */
- char *msg = g_strdup_printf("<I>%s</I>", _(" (%R %Z)"));
+ gchar *msg = g_strdup_printf("<I>%s</I>", _(" (%R %Z)"));
e_utf8_strftime(buf, sizeof(buf), msg, &local);
g_free(msg);
}
@@ -2407,18 +2407,18 @@ efh_format_headers(EMFormatHTML *efh, CamelStream *stream, CamelMedium *part)
{
EMFormat *emf = (EMFormat *) efh;
EMFormatHeader *h;
- const char *charset;
+ const gchar *charset;
CamelContentType *ct;
struct _camel_header_raw *header;
gboolean have_icon = FALSE;
- const char *photo_name = NULL;
+ const gchar *photo_name = NULL;
CamelInternetAddress *cia = NULL;
gboolean face_decoded = FALSE, contact_has_photo = FALSE;
guchar *face_header_value = NULL;
gsize face_header_len = 0;
- char *header_sender = NULL, *header_from = NULL, *name;
+ gchar *header_sender = NULL, *header_from = NULL, *name;
gboolean mail_from_delegate = FALSE;
- const char *hdr_charset;
+ const gchar *hdr_charset;
if (!part)
return;
@@ -2506,9 +2506,9 @@ efh_format_headers(EMFormatHTML *efh, CamelStream *stream, CamelMedium *part)
header = header->next;
}
} else {
- int mailer_shown = FALSE;
+ gint mailer_shown = FALSE;
while (h->next) {
- int mailer, face;
+ gint mailer, face;
header = ((CamelMimePart *)part)->headers;
mailer = !g_ascii_strcasecmp (h->name, "X-Evolution-Mailer");
@@ -2547,7 +2547,7 @@ efh_format_headers(EMFormatHTML *efh, CamelStream *stream, CamelMedium *part)
if (strstr(use_header->value, "Evolution"))
have_icon = TRUE;
} else if (!face_decoded && face && !g_ascii_strcasecmp (header->name, "Face")) {
- char *cp = header->value;
+ gchar *cp = header->value;
/* Skip over spaces */
while (*cp == ' ')
@@ -2572,12 +2572,12 @@ efh_format_headers(EMFormatHTML *efh, CamelStream *stream, CamelMedium *part)
camel_stream_printf(stream, "</table></td>");
if (photo_name) {
- char *classid;
+ gchar *classid;
CamelMimePart *photopart;
gboolean only_local_photo;
cia = camel_internet_address_new();
- camel_address_decode((CamelAddress *) cia, (const char *) photo_name);
+ camel_address_decode((CamelAddress *) cia, (const gchar *) photo_name);
only_local_photo = em_format_html_get_only_local_photos (efh);
photopart = em_utils_contact_photo (cia, only_local_photo);
@@ -2598,11 +2598,11 @@ efh_format_headers(EMFormatHTML *efh, CamelStream *stream, CamelMedium *part)
}
if (!contact_has_photo && face_decoded) {
- char *classid;
+ gchar *classid;
CamelMimePart *part;
part = camel_mime_part_new ();
- camel_mime_part_set_content ((CamelMimePart *) part, (const char *) face_header_value, face_header_len, "image/png");
+ camel_mime_part_set_content ((CamelMimePart *) part, (const gchar *) face_header_value, face_header_len, "image/png");
classid = g_strdup_printf("icon:///em-format-html/face/photo/header");
camel_stream_printf(stream, "<td align=\"right\" valign=\"top\"><img width=48 src=\"%s\"></td>", classid);
em_format_add_puri(emf, sizeof(EMFormatPURI), classid, part, efh_write_image);
@@ -2611,7 +2611,7 @@ efh_format_headers(EMFormatHTML *efh, CamelStream *stream, CamelMedium *part)
if (have_icon && efh->show_icon) {
GtkIconInfo *icon_info;
- char *classid;
+ gchar *classid;
CamelMimePart *iconpart = NULL;
classid = g_strdup_printf("icon:///em-format-html/%s/icon/header", emf->part_id->str);