Make Message-ID string generation less confusing.
[claws.git] / src / common / utils.c
index 182be8e6be97ebfbb3a30ef54972ef8051ee00a6..d7d1b4cb9e5a7c448dacc3c38702216c6b5740aa 100644 (file)
@@ -1,6 +1,6 @@
 /*
  * Claws Mail -- a GTK+ based, lightweight, and fast e-mail client
- * Copyright (C) 1999-2015 Hiroyuki Yamamoto & The Claws Mail Team
+ * Copyright (C) 1999-2016 Hiroyuki Yamamoto & The Claws Mail Team
  *
  * This program is free software; you can redistribute it and/or modify
  * it under the terms of the GNU General Public License as published by
@@ -1792,7 +1792,7 @@ const gchar *get_home_dir(void)
                if (w32_shgetfolderpath
                            (NULL, CSIDL_APPDATA|CSIDL_FLAG_CREATE,
                             NULL, 0, home_dir_utf16) < 0)
-                               strcpy (home_dir_utf16, "C:\\Sylpheed");
+                               strcpy (home_dir_utf16, "C:\\Claws Mail");
                home_dir_utf8 = g_utf16_to_utf8 ((const gunichar *)home_dir_utf16, -1, NULL, NULL, NULL);
        }
        return home_dir_utf8;
@@ -2055,32 +2055,6 @@ time_t get_file_mtime(const gchar *file)
        return s.st_mtime;
 }
 
-off_t get_file_size_as_crlf(const gchar *file)
-{
-       FILE *fp;
-       off_t size = 0;
-       gchar buf[BUFFSIZE];
-
-       if ((fp = g_fopen(file, "rb")) == NULL) {
-               FILE_OP_ERROR(file, "g_fopen");
-               return -1;
-       }
-
-       while (fgets(buf, sizeof(buf), fp) != NULL) {
-               strretchomp(buf);
-               size += strlen(buf) + 2;
-       }
-
-       if (ferror(fp)) {
-               FILE_OP_ERROR(file, "fgets");
-               size = -1;
-       }
-
-       fclose(fp);
-
-       return size;
-}
-
 gboolean file_exist(const gchar *file, gboolean allow_fifo)
 {
        GStatBuf s;
@@ -3557,7 +3531,7 @@ gchar *tzoffset(time_t *now)
        return offset_string;
 }
 
-void get_rfc822_date(gchar *buf, gint len)
+static void _get_rfc822_date(gchar *buf, gint len, gboolean hidetz)
 {
        struct tm *lt;
        time_t t;
@@ -3573,7 +3547,17 @@ void get_rfc822_date(gchar *buf, gint len)
               day, mon, &dd, &hh, &mm, &ss, &yyyy);
 
        g_snprintf(buf, len, "%s, %d %s %d %02d:%02d:%02d %s",
-                  day, dd, mon, yyyy, hh, mm, ss, tzoffset(&t));
+                  day, dd, mon, yyyy, hh, mm, ss, (hidetz? "-0000": tzoffset(&t)));
+}
+
+void get_rfc822_date(gchar *buf, gint len)
+{
+       _get_rfc822_date(buf, len, FALSE);
+}
+
+void get_rfc822_date_hide_tz(gchar *buf, gint len)
+{
+       _get_rfc822_date(buf, len, TRUE);
 }
 
 void debug_set_mode(gboolean mode)
@@ -3747,39 +3731,6 @@ gint g_int_compare(gconstpointer a, gconstpointer b)
        return GPOINTER_TO_INT(a) - GPOINTER_TO_INT(b);
 }
 
-gchar *generate_msgid(gchar *buf, gint len, gchar *user_addr)
-{
-       struct tm *lt;
-       time_t t;
-       gchar *addr;
-       struct tm buft;
-
-       t = time(NULL);
-       lt = localtime_r(&t, &buft);
-
-       if (user_addr != NULL)
-             addr = g_strdup_printf(".%s", user_addr);
-       else if (strlen(buf) != 0)
-             addr = g_strdup_printf("@%s", buf);
-       else
-             addr = g_strdup_printf("@%s", get_domain_name());
-
-       /* Replace all @ but the last one in addr, with underscores.
-        * RFC 2822 States that msg-id syntax only allows one @.
-        */
-       while (strchr(addr, '@') != NULL && strchr(addr, '@') != strrchr(addr, '@'))
-               *(strchr(addr, '@')) = '_';
-
-       g_snprintf(buf, len, "%04d%02d%02d%02d%02d%02d.%08x%s",
-                  lt->tm_year + 1900, lt->tm_mon + 1,
-                  lt->tm_mday, lt->tm_hour,
-                  lt->tm_min, lt->tm_sec,
-                  (guint) rand(), addr);
-
-       g_free(addr);
-       return buf;
-}
-
 /*
    quote_cmd_argument()