-static gboolean
-is_ascii(const gchar *s)
-{
- while (s[0]) {
- if (s[0] & 128 || s[0] < 32)
- return FALSE;
- s++;
- }
- return TRUE;
-}
-
-static char *
-get_content_type(const gchar *s)
-{
- GString *type;
-
- type = g_string_new("text/plain");
- if (!is_ascii(s)) {
- if (g_utf8_validate(s, -1, NULL)) {
- g_string_append(type, "; charset=\"utf-8\"");
- } else {
- /* it should be impossible to reach this, but better safe than sorry */
- g_warning("invalid utf8 in message");
- g_string_append(type, "; charset=\"latin1\"");
- }
- }
- return g_string_free(type, FALSE);
-}
-
-static GQuark
-modest_error_quark (void)
-{
- static GQuark err_q = 0;
-
- if (err_q == 0)
- err_q = g_quark_from_static_string ("modest-error-quark");
-
- return err_q;
-}
-
-
-static void
-set_error (ModestMailOperation *mail_op,
- ModestMailOperationErrorCode error_code,
- const gchar *fmt, ...)
-{
- ModestMailOperationPrivate *priv;
- GError* error;
- va_list args;
- gchar* orig;
-
- priv = MODEST_MAIL_OPERATION_GET_PRIVATE(mail_op);
-
- va_start (args, fmt);
-
- orig = g_strdup_vprintf(fmt, args);
- error = g_error_new (MODEST_ERROR, error_code, orig);
-
- va_end (args);
-
- if (priv->error)
- g_object_unref (priv->error);
-
- priv->error = error;
-}