aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/account.c32
-rw-r--r--src/codeconv.c54
-rw-r--r--src/codeconv.h5
-rw-r--r--src/folder.c11
-rw-r--r--src/main.c95
-rw-r--r--src/prefs.c2
-rw-r--r--src/prefs.h2
-rw-r--r--src/prefs_account.c12
-rw-r--r--src/prefs_common.c11
-rw-r--r--src/prefs_filter.c10
-rw-r--r--src/utils.c37
-rw-r--r--src/utils.h2
-rw-r--r--src/xml.c3
13 files changed, 191 insertions, 85 deletions
diff --git a/src/account.c b/src/account.c
index 8c9fe253..582b5d2d 100644
--- a/src/account.c
+++ b/src/account.c
@@ -44,7 +44,6 @@
#include "stock_pixmap.h"
#include "statusbar.h"
#include "inc.h"
-#include "codeconv.h"
#include "gtkutils.h"
#include "utils.h"
#include "alertpanel.h"
@@ -115,23 +114,13 @@ void account_read_config_all(void)
{
GSList *ac_label_list = NULL, *cur;
gchar *rcpath;
- const gchar *encoding = NULL;
FILE *fp;
gchar buf[PREFSBUFSIZE];
PrefsAccount *ac_prefs;
debug_print(_("Reading all config for each account...\n"));
- rcpath = g_strconcat(get_rc_dir(), G_DIR_SEPARATOR_S, ACCOUNT_RC,
- NULL);
- if (!is_file_exist(rcpath)) {
- debug_print("reading older version of accountrc ...\n");
- g_free(rcpath);
- rcpath = g_strconcat(get_old_rc_dir(), G_DIR_SEPARATOR_S,
- ACCOUNT_RC, NULL);
- encoding = conv_get_locale_charset_str();
- }
-
+ rcpath = g_strconcat(get_rc_dir(), G_DIR_SEPARATOR_S, ACCOUNT_RC, NULL);
if ((fp = fopen(rcpath, "rb")) == NULL) {
if (ENOENT != errno) FILE_OP_ERROR(rcpath, "fopen");
g_free(rcpath);
@@ -144,22 +133,9 @@ void account_read_config_all(void)
strretchomp(buf);
memmove(buf, buf + 1, strlen(buf));
buf[strlen(buf) - 1] = '\0';
- if (encoding) {
- gchar *conv_str;
-
- conv_str = conv_codeset_strdup
- (buf, encoding,
- conv_get_internal_charset_str());
- if (!conv_str)
- conv_str = g_strdup(buf);
- debug_print("Found label: %s\n", conv_str);
- ac_label_list = g_slist_append(ac_label_list,
- conv_str);
- } else {
- debug_print("Found label: %s\n", buf);
- ac_label_list = g_slist_append(ac_label_list,
- g_strdup(buf));
- }
+ debug_print("Found label: %s\n", buf);
+ ac_label_list = g_slist_append(ac_label_list,
+ g_strdup(buf));
}
}
fclose(fp);
diff --git a/src/codeconv.c b/src/codeconv.c
index 454cb0e4..3502f1d3 100644
--- a/src/codeconv.c
+++ b/src/codeconv.c
@@ -1,6 +1,6 @@
/*
* Sylpheed -- a GTK+ based, lightweight, and fast e-mail client
- * Copyright (C) 1999-2004 Hiroyuki Yamamoto
+ * Copyright (C) 1999-2005 Hiroyuki Yamamoto
*
* 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
@@ -21,6 +21,8 @@
# include "config.h"
#endif
+#include "defs.h"
+
#include <glib.h>
#include <string.h>
#include <ctype.h>
@@ -1760,3 +1762,53 @@ void conv_encode_header(gchar *dest, gint len, const gchar *src,
}
#undef LBREAK_IF_REQUIRED
+
+gint conv_copy_file(const gchar *src, const gchar *dest, const gchar *encoding)
+{
+ FILE *src_fp, *dest_fp;
+ gchar buf[BUFFSIZE], outbuf[BUFFSIZE];
+ CodeConverter *conv;
+ gboolean err = FALSE;
+
+ if ((src_fp = fopen(src, "rb")) == NULL) {
+ FILE_OP_ERROR(src, "fopen");
+ return -1;
+ }
+ if ((dest_fp = fopen(dest, "wb")) == NULL) {
+ FILE_OP_ERROR(dest, "fopen");
+ fclose(src_fp);
+ return -1;
+ }
+
+ if (change_file_mode_rw(dest_fp, dest) < 0) {
+ FILE_OP_ERROR(dest, "chmod");
+ g_warning("can't change file mode\n");
+ }
+
+ conv = conv_code_converter_new(encoding);
+
+ while (fgets(buf, sizeof(buf), src_fp) != NULL) {
+ if (conv_convert(conv, outbuf, sizeof(outbuf), buf) == 0)
+ fputs(outbuf, dest_fp);
+ else
+ fputs(buf, dest_fp);
+ }
+
+ conv_code_converter_destroy(conv);
+
+ if (ferror(src_fp)) {
+ FILE_OP_ERROR(src, "fgets");
+ err = TRUE;
+ }
+ fclose(src_fp);
+ if (fclose(dest_fp) == EOF) {
+ FILE_OP_ERROR(dest, "fclose");
+ err = TRUE;
+ }
+ if (err) {
+ unlink(dest);
+ return -1;
+ }
+
+ return 0;
+}
diff --git a/src/codeconv.h b/src/codeconv.h
index 71e0a20b..2c1ff3c7 100644
--- a/src/codeconv.h
+++ b/src/codeconv.h
@@ -1,6 +1,6 @@
/*
* Sylpheed -- a GTK+ based, lightweight, and fast e-mail client
- * Copyright (C) 1999-2004 Hiroyuki Yamamoto
+ * Copyright (C) 1999-2005 Hiroyuki Yamamoto
*
* 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
@@ -237,5 +237,8 @@ void conv_encode_header (gchar *dest,
gint header_len,
gboolean addr_field);
+gint conv_copy_file (const gchar *src,
+ const gchar *dest,
+ const gchar *src_encoding);
#endif /* __CODECONV_H__ */
diff --git a/src/folder.c b/src/folder.c
index 93e8b334..7e96c294 100644
--- a/src/folder.c
+++ b/src/folder.c
@@ -1,6 +1,6 @@
/*
* Sylpheed -- a GTK+ based, lightweight, and fast e-mail client
- * Copyright (C) 1999-2003 Hiroyuki Yamamoto
+ * Copyright (C) 1999-2005 Hiroyuki Yamamoto
*
* 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
@@ -339,14 +339,7 @@ gint folder_read_list(void)
gchar *path;
path = folder_get_list_path();
- if (!is_file_exist(path)) {
- debug_print("reading older version of folderlist.xml ...\n");
- path = g_strconcat(get_old_rc_dir(), G_DIR_SEPARATOR_S,
- FOLDER_LIST, NULL);
- AUTORELEASE_STR(path, return -1);
- if (!is_file_exist(path))
- return -1;
- }
+ if (!is_file_exist(path)) return -1;
node = xml_parse_file(path);
if (!node) return -1;
diff --git a/src/main.c b/src/main.c
index 0f46186a..45112282 100644
--- a/src/main.c
+++ b/src/main.c
@@ -1,6 +1,6 @@
/*
* Sylpheed -- a GTK+ based, lightweight, and fast e-mail client
- * Copyright (C) 1999-2004 Hiroyuki Yamamoto
+ * Copyright (C) 1999-2005 Hiroyuki Yamamoto
*
* 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
@@ -27,10 +27,6 @@
#include <gtk/gtkmain.h>
#include <gtk/gtkrc.h>
-#if HAVE_GDK_IMLIB
-# include <gdk_imlib.h>
-#endif
-
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
@@ -40,6 +36,7 @@
#include <sys/stat.h>
#include <sys/types.h>
#include <signal.h>
+#include <dirent.h>
#if HAVE_LOCALE_H
# include <locale.h>
@@ -67,6 +64,7 @@
#include "alertpanel.h"
#include "statusbar.h"
#include "addressbook.h"
+#include "addrindex.h"
#include "compose.h"
#include "folder.h"
#include "setup.h"
@@ -116,6 +114,8 @@ static void lock_socket_input_cb (gpointer data,
GdkInputCondition condition);
static gchar *get_socket_name (void);
+static void migrate_old_config (void);
+
static void open_compose_new (const gchar *address,
GPtrArray *attach_files);
@@ -181,12 +181,6 @@ int main(int argc, char *argv[])
g_error(_("g_thread is not supported by glib.\n"));
#endif
-#if HAVE_GDK_IMLIB
- gdk_imlib_init();
- gtk_widget_push_visual(gdk_imlib_get_visual());
- gtk_widget_push_colormap(gdk_imlib_get_colormap());
-#endif
-
#if USE_SSL
ssl_init();
#endif
@@ -217,7 +211,15 @@ int main(int argc, char *argv[])
if (rename(RC_DIR, RC_DIR ".bak") < 0)
FILE_OP_ERROR(RC_DIR, "rename");
}
- MAKE_DIR_IF_NOT_EXIST(RC_DIR);
+
+ /* migration from ~/.sylpheed to ~/.sylpheed-2.0 */
+ if (!is_dir_exist(RC_DIR)) {
+ if (make_dir(RC_DIR) < 0)
+ return 1;
+ if (is_dir_exist(OLD_RC_DIR))
+ migrate_old_config();
+ }
+
MAKE_DIR_IF_NOT_EXIST(get_imap_cache_dir());
MAKE_DIR_IF_NOT_EXIST(get_news_cache_dir());
MAKE_DIR_IF_NOT_EXIST(get_mime_tmp_dir());
@@ -684,6 +686,75 @@ static void lock_socket_input_cb(gpointer data,
fd_close(sock);
}
+static void migrate_old_config(void)
+{
+ DIR *dp;
+ struct dirent *d;
+ GPatternSpec *pspec;
+
+ if (alertpanel(_("Migration of configuration"),
+ _("The previous version of configuration found.\n"
+ "Do you want to migrate it?"),
+ _("Yes"), _("No"), NULL) != G_ALERTDEFAULT)
+ return;
+
+ debug_print("Migrating old configuration...\n");
+
+#define COPY_FILE(rcfile) \
+ conv_copy_file(OLD_RC_DIR G_DIR_SEPARATOR_S rcfile, \
+ RC_DIR G_DIR_SEPARATOR_S rcfile, \
+ conv_get_locale_charset_str())
+
+ COPY_FILE(ACCOUNT_RC);
+ COPY_FILE(ACTIONS_RC);
+ COPY_FILE(CUSTOM_HEADER_RC);
+ COPY_FILE(DISPLAY_HEADER_RC);
+ COPY_FILE(FILTER_HEADER_RC);
+#if 0
+ COPY_FILE(COMMON_RC);
+#endif
+ COPY_FILE(COMMAND_HISTORY);
+
+#undef COPY_FILE
+
+ copy_file(OLD_RC_DIR G_DIR_SEPARATOR_S FILTER_LIST,
+ RC_DIR G_DIR_SEPARATOR_S FILTER_LIST, FALSE);
+ copy_file(OLD_RC_DIR G_DIR_SEPARATOR_S FOLDER_LIST,
+ RC_DIR G_DIR_SEPARATOR_S FOLDER_LIST, FALSE);
+
+ copy_dir(OLD_RC_DIR G_DIR_SEPARATOR_S "uidl",
+ RC_DIR G_DIR_SEPARATOR_S "uidl");
+
+ if (!is_file_exist(OLD_RC_DIR G_DIR_SEPARATOR_S ADDRESSBOOK_INDEX_FILE))
+ return;
+
+ if ((dp = opendir(OLD_RC_DIR)) == NULL) {
+ FILE_OP_ERROR(OLD_RC_DIR, "opendir");
+ return;
+ }
+
+ pspec = g_pattern_spec_new("addrbook-*.xml");
+
+ while ((d = readdir(dp)) != NULL) {
+ if (g_pattern_match_string(pspec, d->d_name)) {
+ gchar *old_file;
+ gchar *new_file;
+
+ old_file = g_strconcat(OLD_RC_DIR G_DIR_SEPARATOR_S,
+ d->d_name, NULL);
+ new_file = g_strconcat(RC_DIR G_DIR_SEPARATOR_S,
+ d->d_name, NULL);
+ copy_file(old_file, new_file, FALSE);
+ g_free(new_file);
+ g_free(old_file);
+ }
+ }
+
+ g_pattern_spec_free(pspec);
+
+ closedir(dp);
+}
+
static void open_compose_new(const gchar *address, GPtrArray *attach_files)
{
gchar *addr = NULL;
diff --git a/src/prefs.c b/src/prefs.c
index b6d2fac8..07bf5d97 100644
--- a/src/prefs.c
+++ b/src/prefs.c
@@ -1,6 +1,6 @@
/*
* Sylpheed -- a GTK+ based, lightweight, and fast e-mail client
- * Copyright (C) 1999-2004 Hiroyuki Yamamoto
+ * Copyright (C) 1999-2005 Hiroyuki Yamamoto
*
* 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
diff --git a/src/prefs.h b/src/prefs.h
index 77ec216b..11bf6ca0 100644
--- a/src/prefs.h
+++ b/src/prefs.h
@@ -1,6 +1,6 @@
/*
* Sylpheed -- a GTK+ based, lightweight, and fast e-mail client
- * Copyright (C) 1999-2004 Hiroyuki Yamamoto
+ * Copyright (C) 1999-2005 Hiroyuki Yamamoto
*
* 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
diff --git a/src/prefs_account.c b/src/prefs_account.c
index 39a5f101..46673b04 100644
--- a/src/prefs_account.c
+++ b/src/prefs_account.c
@@ -43,7 +43,6 @@
#include "foldersel.h"
#include "inc.h"
#include "menu.h"
-#include "codeconv.h"
#include "gtkutils.h"
#include "utils.h"
#include "alertpanel.h"
@@ -516,7 +515,6 @@ void prefs_account_read_config(PrefsAccount *ac_prefs, const gchar *label)
{
const guchar *p = label;
gchar *rcpath;
- const gchar *encoding = NULL;
gint id;
g_return_if_fail(ac_prefs != NULL);
@@ -525,15 +523,7 @@ void prefs_account_read_config(PrefsAccount *ac_prefs, const gchar *label)
memset(&tmp_ac_prefs, 0, sizeof(PrefsAccount));
rcpath = g_strconcat(get_rc_dir(), G_DIR_SEPARATOR_S, ACCOUNT_RC, NULL);
- if (!is_file_exist(rcpath)) {
- debug_print("reading older version of accountrc ...\n");
- g_free(rcpath);
- rcpath = g_strconcat(get_old_rc_dir(), G_DIR_SEPARATOR_S,
- ACCOUNT_RC, NULL);
- encoding = conv_get_locale_charset_str();
- }
-
- prefs_read_config(param, label, rcpath, encoding);
+ prefs_read_config(param, label, rcpath, NULL);
g_free(rcpath);
*ac_prefs = tmp_ac_prefs;
diff --git a/src/prefs_common.c b/src/prefs_common.c
index 1780d94c..86476bc6 100644
--- a/src/prefs_common.c
+++ b/src/prefs_common.c
@@ -1,6 +1,6 @@
/*
* Sylpheed -- a GTK+ based, lightweight, and fast e-mail client
- * Copyright (C) 1999-2004 Hiroyuki Yamamoto
+ * Copyright (C) 1999-2005 Hiroyuki Yamamoto
*
* 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
@@ -755,15 +755,6 @@ void prefs_common_read_config(void)
gchar buf[PREFSBUFSIZE];
path = g_strconcat(get_rc_dir(), G_DIR_SEPARATOR_S, COMMON_RC, NULL);
-#if 0
- if (!is_file_exist(path)) {
- debug_print("reading older version of sylpheedrc ...\n");
- g_free(path);
- path = g_strconcat(get_old_rc_dir(), G_DIR_SEPARATOR_S,
- COMMON_RC, NULL);
- encoding = conv_get_locale_charset_str();
- }
-#endif
prefs_read_config(param, "Common", path, NULL);
g_free(path);
diff --git a/src/prefs_filter.c b/src/prefs_filter.c
index 28dfcbf6..36c820c4 100644
--- a/src/prefs_filter.c
+++ b/src/prefs_filter.c
@@ -1,6 +1,6 @@
/*
* Sylpheed -- a GTK+ based, lightweight, and fast e-mail client
- * Copyright (C) 1999-2004 Hiroyuki Yamamoto
+ * Copyright (C) 1999-2005 Hiroyuki Yamamoto
*
* 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
@@ -329,14 +329,8 @@ void prefs_filter_read_config(void)
rcpath = g_strconcat(get_rc_dir(), G_DIR_SEPARATOR_S, FILTER_LIST,
NULL);
if (!is_file_exist(rcpath)) {
- debug_print("reading older version of filter.xml ...\n");
g_free(rcpath);
- rcpath = g_strconcat(get_old_rc_dir(), G_DIR_SEPARATOR_S,
- FILTER_LIST, NULL);
- if (!is_file_exist(rcpath)) {
- g_free(rcpath);
- return;
- }
+ return;
}
node = xml_parse_file(rcpath);
diff --git a/src/utils.c b/src/utils.c
index 570f60f3..42b294e1 100644
--- a/src/utils.c
+++ b/src/utils.c
@@ -1,6 +1,6 @@
/*
* Sylpheed -- a GTK+ based, lightweight, and fast e-mail client
- * Copyright (C) 1999-2004 Hiroyuki Yamamoto
+ * Copyright (C) 1999-2005 Hiroyuki Yamamoto
*
* 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
@@ -2219,6 +2219,41 @@ gint copy_file(const gchar *src, const gchar *dest, gboolean keep_backup)
return 0;
}
+gint copy_dir(const gchar *src, const gchar *dest)
+{
+ DIR *dp;
+ struct dirent *d;
+ gchar *src_file;
+ gchar *dest_file;
+
+ if ((dp = opendir(src)) == NULL) {
+ FILE_OP_ERROR(src, "opendir");
+ return -1;
+ }
+
+ if (make_dir_hier(dest) < 0) {
+ closedir(dp);
+ return -1;
+ }
+
+ while ((d = readdir(dp)) != NULL) {
+ if (!strcmp(d->d_name, ".") || !strcmp(d->d_name, ".."))
+ continue;
+
+ src_file = g_strconcat(src, G_DIR_SEPARATOR_S, d->d_name, NULL);
+ dest_file = g_strconcat(dest, G_DIR_SEPARATOR_S, d->d_name,
+ NULL);
+ if (is_file_exist(src_file))
+ copy_file(src_file, dest_file, FALSE);
+ g_free(dest_file);
+ g_free(src_file);
+ }
+
+ closedir(dp);
+
+ return 0;
+}
+
gint move_file(const gchar *src, const gchar *dest, gboolean overwrite)
{
if (overwrite == FALSE && is_file_exist(dest)) {
diff --git a/src/utils.h b/src/utils.h
index f21cd06c..d884daf9 100644
--- a/src/utils.h
+++ b/src/utils.h
@@ -369,6 +369,8 @@ gint remove_dir_recursive (const gchar *dir);
gint copy_file (const gchar *src,
const gchar *dest,
gboolean keep_backup);
+gint copy_dir (const gchar *src,
+ const gchar *dest);
gint move_file (const gchar *src,
const gchar *dest,
gboolean overwrite);
diff --git a/src/xml.c b/src/xml.c
index f0ad1c2c..fac7b8fb 100644
--- a/src/xml.c
+++ b/src/xml.c
@@ -1,6 +1,6 @@
/*
* Sylpheed -- a GTK+ based, lightweight, and fast e-mail client
- * Copyright (C) 1999-2004 Hiroyuki Yamamoto
+ * Copyright (C) 1999-2005 Hiroyuki Yamamoto
*
* 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
@@ -176,7 +176,6 @@ gint xml_get_dtd(XMLFile *file)
bufp += 9;
extract_quote(bufp, '"');
file->encoding = g_strdup(bufp);
- g_print("encoding = %s\n", bufp);
} else
file->encoding =
g_strdup(conv_get_internal_charset_str());