aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorIain Holmes <iain@src.gnome.org>2001-05-15 05:42:57 +0800
committerIain Holmes <iain@src.gnome.org>2001-05-15 05:42:57 +0800
commit4f400ba1f64a674467251ac7b858f302de0c2f10 (patch)
tree01405449ba900254580973875ae4ce27660f273a
parentf759e8b024bab3bb365d2fc80097d7a8eed98125 (diff)
downloadgsoc2013-evolution-4f400ba1f64a674467251ac7b858f302de0c2f10.tar
gsoc2013-evolution-4f400ba1f64a674467251ac7b858f302de0c2f10.tar.gz
gsoc2013-evolution-4f400ba1f64a674467251ac7b858f302de0c2f10.tar.bz2
gsoc2013-evolution-4f400ba1f64a674467251ac7b858f302de0c2f10.tar.lz
gsoc2013-evolution-4f400ba1f64a674467251ac7b858f302de0c2f10.tar.xz
gsoc2013-evolution-4f400ba1f64a674467251ac7b858f302de0c2f10.tar.zst
gsoc2013-evolution-4f400ba1f64a674467251ac7b858f302de0c2f10.zip
Fix up the Importers. Remove spewage, and update for latest styles
svn path=/trunk/; revision=9802
-rw-r--r--importers/ChangeLog19
-rw-r--r--importers/elm-importer.c167
-rw-r--r--importers/netscape-importer.c12
-rw-r--r--importers/pine-importer.c32
4 files changed, 166 insertions, 64 deletions
diff --git a/importers/ChangeLog b/importers/ChangeLog
index 0c41190527..5e74da717b 100644
--- a/importers/ChangeLog
+++ b/importers/ChangeLog
@@ -1,3 +1,22 @@
+2001-05-14 Iain Holmes <iain@ximian.com>
+
+ * elm-importer.c (elm_store_settings): Store the elm settings.
+ (elm_restore_settings): Restore all the settings.
+ (elm_can_import): Check the importer settings, handle the don't ask me
+ again stuff.
+ (scan_dir): Switch the arguments to match the other importers.
+ (destroy_cb): Store the settings.
+ (elm_create_structure): Set all the settings, handle the new location
+ of the elm mail.
+ (create_checkboxes_control): Add a "Don't ask me again" box.
+
+2001-05-09 Iain Holmes <iain@ximian.com>
+
+ * pine-importer.c (import_addressfile): Free memory leaks.
+ Fix spewage.
+
+ * netscape-importer.c: Fix spewage.
+
2001-05-09 Iain Holmes <iain@ximian.com>
* elm-importer.c (elm_can_import): Check the elm rc file for the mail dir.
diff --git a/importers/elm-importer.c b/importers/elm-importer.c
index bda86d72d3..58e3ad7ff9 100644
--- a/importers/elm-importer.c
+++ b/importers/elm-importer.c
@@ -69,6 +69,9 @@ typedef struct {
gboolean do_mail;
GtkWidget *alias;
gboolean do_alias;
+
+ GtkWidget *ask;
+ gboolean ask_again;
} ElmImporter;
typedef struct {
@@ -82,6 +85,46 @@ static GHashTable *elm_prefs = NULL;
static void import_next (ElmImporter *importer);
static void
+elm_store_settings (ElmImporter *importer)
+{
+ char *evolution_dir, *key;
+
+ evolution_dir = gnome_util_prepend_user_home ("evolution");
+ key = g_strdup_printf ("=%s/config/Elm-Importer=/settings/",
+ evolution_dir);
+ g_free (evolution_dir);
+
+ gnome_config_push_prefix (key);
+ g_free (key);
+
+ gnome_config_set_bool ("mail", importer->do_mail);
+ gnome_config_set_bool ("alias", importer->do_alias);
+
+ gnome_config_set_bool ("ask-again", importer->ask_again);
+ gnome_config_pop_prefix ();
+}
+
+static void
+elm_restore_settings (ElmImporter *importer)
+{
+ char *evolution_dir, *key;
+
+ evolution_dir = gnome_util_prepend_user_home ("evolution");
+ key = g_strdup_printf ("=%s/config/Elm-Importer=/settings/",
+ evolution_dir);
+ g_free (evolution_dir);
+
+ gnome_config_push_prefix (key);
+ g_free (key);
+
+ importer->do_mail = gnome_config_get_bool ("mail=True");
+ importer->do_alias = gnome_config_get_bool ("alias=True");
+
+ importer->ask_again = gnome_config_get_bool ("ask-again=False");
+ gnome_config_pop_prefix ();
+}
+
+static void
importer_cb (EvolutionImporterListener *listener,
EvolutionImporterResult result,
gboolean more_items,
@@ -185,7 +228,6 @@ parse_elm_rc (const char *elmrc)
linestart = line;
}
- g_print ("linestart = '%s'", linestart);
end = strstr (linestart, " = ");
if (end == NULL) {
g_warning ("Broken line");
@@ -227,24 +269,39 @@ elm_can_import (EvolutionIntelligentImporter *ii,
void *closure)
{
ElmImporter *importer = closure;
- char *key, *elmdir, *maildir, *evolution_dir, *alias;
+ char *key, *elmdir, *maildir, *evolution_dir, *aliasfile;
char *elmrc;
gboolean exists, mailexists, aliasexists;
+ gboolean mail, alias;
evolution_dir = gnome_util_prepend_user_home ("evolution");
/* Already imported */
- key = g_strdup_printf ("=%s/config/Importers=/importers/", evolution_dir);
+ key = g_strdup_printf ("=%s/config/Importers=/elm-importers/", evolution_dir);
g_free (evolution_dir);
gnome_config_push_prefix (key);
g_free (key);
- if (gnome_config_get_bool (KEY) == TRUE) {
+ mail = gnome_config_get_bool ("mail-imported");
+ alias = gnome_config_get_bool ("alias-importer");
+
+ if (alias && mail) {
gnome_config_pop_prefix ();
return FALSE;
}
gnome_config_pop_prefix ();
+ importer->do_mail = !mail;
+ gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (importer->mail),
+ importer->do_mail);
+ importer->do_alias = !alias;
+ gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (importer->alias),
+ importer->do_alias);
+
+ if (importer->ask_again == TRUE) {
+ return FALSE;
+ }
+
elmdir = gnome_util_prepend_user_home (".elm");
exists = g_file_exists (elmdir);
@@ -270,25 +327,12 @@ elm_can_import (EvolutionIntelligentImporter *ii,
g_free (maildir);
- g_print ("\nChecking for %s\n", elmdir);
mailexists = g_file_exists (elmdir);
g_free (elmdir);
- importer->do_mail = mailexists;
- gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (importer->mail),
- importer->do_mail);
- gtk_widget_set_sensitive (importer->mail, mailexists);
-
- alias = gnome_util_prepend_user_home (".elm/aliases");
- aliasexists = g_file_exists (alias);
- g_free (alias);
-
- importer->do_alias = aliasexists;
- gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (importer->alias),
- importer->do_alias);
-#ifdef WE_HAVE_WORKING_ALIAS_IMPORTING
- gtk_widget_set_sensitive (importer->alias, aliasexists);
-#endif
+ aliasfile = gnome_util_prepend_user_home (".elm/aliases");
+ aliasexists = g_file_exists (aliasfile);
+ g_free (aliasfile);
exists = (aliasexists || mailexists);
@@ -318,8 +362,8 @@ import_next (ElmImporter *importer)
static void
scan_dir (ElmImporter *importer,
- const char *dirname,
- const char *orig_parent)
+ const char *orig_parent,
+ const char *dirname)
{
DIR *maildir;
struct stat buf;
@@ -371,7 +415,7 @@ scan_dir (ElmImporter *importer,
importer->dir_list = g_list_append (importer->dir_list, pf);
subdir = g_concat_dir_and_file (orig_parent, current->d_name);
- scan_dir (importer, fullname, subdir);
+ scan_dir (importer, subdir, fullname);
g_free (subdir);
}
@@ -387,25 +431,55 @@ elm_create_structure (EvolutionIntelligentImporter *ii,
ElmImporter *importer = closure;
char *maildir, *key, *evolution_dir;
- maildir = gnome_util_prepend_user_home ("Mail");
- scan_dir (importer, maildir, "/");
- g_free (maildir);
-
- /* Import them */
- import_next (importer);
+ /* Reference our object so when the shell release_unrefs us
+ we will still exist and not go byebye */
+ bonobo_object_ref (BONOBO_OBJECT (ii));
+ elm_store_settings (importer);
evolution_dir = gnome_util_prepend_user_home ("evolution");
- key = g_strdup_printf ("=%s/config/Importers=/importers/", evolution_dir);
+ key = g_strdup_printf ("=%s/config/Importers=/elm-importers/", evolution_dir);
g_free (evolution_dir);
-
gnome_config_push_prefix (key);
g_free (key);
-
- gnome_config_set_bool (KEY, TRUE);
+
+ if (importer->do_alias == TRUE) {
+ /* Do the aliases */
+ }
+
+ if (importer->do_mail == TRUE) {
+ char *elmdir;
+ gnome_config_set_bool ("mail-importer", TRUE);
+
+ maildir = elm_get_rc_value ("maildir");
+ if (maildir == NULL) {
+ maildir = g_strdup ("Mail");
+ } else {
+ maildir = g_strdup (maildir);
+ }
+
+ if (!g_path_is_absolute (maildir)) {
+ elmdir = gnome_util_prepend_user_home (maildir);
+ } else {
+ elmdir = g_strdup (maildir);
+ }
+
+ g_free (maildir);
+
+ scan_dir (importer, "/", maildir);
+ g_free (maildir);
+
+ /* Import them */
+ import_next (importer);
+ }
+
gnome_config_pop_prefix ();
-
+
gnome_config_sync ();
gnome_config_drop_all ();
+
+ if (importer->do_mail == FALSE) {
+ bonobo_object_unref (BONOBO_OBJECT (ii));
+ }
}
static void
@@ -416,6 +490,7 @@ elm_destroy_cb (GtkObject *object,
g_print ("Mail - %s\n", importer->do_mail ? "Yes" : "No");
g_print ("Alias - %s\n", importer->do_alias ? "Yes" : "No");
+ elm_store_settings (importer);
gtk_main_quit ();
}
@@ -431,7 +506,7 @@ checkbox_toggle_cb (GtkToggleButton *tb,
static BonoboControl *
create_checkboxes_control (ElmImporter *importer)
{
- GtkWidget *container, *vbox;
+ GtkWidget *container, *vbox, *sep;
BonoboControl *control;
container = gtk_frame_new (_("Import"));
@@ -448,15 +523,27 @@ create_checkboxes_control (ElmImporter *importer)
GTK_SIGNAL_FUNC (checkbox_toggle_cb),
&importer->do_alias);
+ sep = gtk_hseparator_new ();
+
+ importer->ask = gtk_check_button_new_with_label (_("Don't ask me again"));
+ gtk_signal_connect (GTK_OBJECT (importer->ask), "toggled",
+ GTK_SIGNAL_FUNC (checkbox_toggle_cb),
+ &importer->ask_again);
+
gtk_box_pack_start (GTK_BOX (vbox), importer->mail, FALSE, FALSE, 0);
gtk_box_pack_start (GTK_BOX (vbox), importer->alias, FALSE, FALSE, 0);
+ gtk_box_pack_start (GTK_BOX (vbox), sep, FALSE, FALSE, 0);
+ gtk_box_pack_start (GTK_BOX (vbox), importer->ask, FALSE, FALSE, 0);
/* Disable the things that can't be done */
gtk_widget_set_sensitive (importer->alias, FALSE);
- gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (importer->mail), TRUE);
- importer->do_mail = TRUE;
- importer->do_alias = FALSE;
+ gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (importer->mail),
+ importer->do_mail);
+ gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (importer->alias),
+ importer->do_alias);
+ gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (importer->ask),
+ importer->ask_again);
gtk_widget_show_all (container);
control = bonobo_control_new (container);
@@ -471,10 +558,12 @@ factory_fn (BonoboGenericFactory *_factory,
BonoboControl *control;
ElmImporter *elm;
CORBA_Environment ev;
- char *message = N_("Evolution has found Elm mail files in ~/Mail.\n"
+ char *message = N_("Evolution has found Elm mail files\n"
"Would you like to import them into Evolution?");
elm = g_new0 (ElmImporter, 1);
+ elm_restore_settings (elm);
+
CORBA_exception_init (&ev);
elm->importer = oaf_activate_from_id (MBOX_IMPORTER_IID, 0, NULL, &ev);
if (ev._major != CORBA_NO_EXCEPTION) {
diff --git a/importers/netscape-importer.c b/importers/netscape-importer.c
index 67d20d835b..ab20d31188 100644
--- a/importers/netscape-importer.c
+++ b/importers/netscape-importer.c
@@ -143,7 +143,6 @@ netscape_get_integer (const char *strname)
char *intstr;
intstr = g_hash_table_lookup (user_prefs, strname);
- g_print ("Request: %s %s.\n", strname, intstr);
if (intstr == NULL) {
return 0;
} else {
@@ -158,7 +157,6 @@ netscape_get_boolean (const char *strname)
boolstr = g_hash_table_lookup (user_prefs, strname);
- g_print ("Request: %s %s.\n", strname, boolstr);
if (boolstr == NULL) {
return FALSE;
} else {
@@ -195,7 +193,7 @@ netscape_get_key (const char *line)
key = g_strdup (start);
g_free (line_dup);
- g_warning ("Found key: %s", key);
+ d(g_warning ("Found key: %s", key));
return key;
die:
@@ -245,7 +243,7 @@ netscape_get_value (const char *line)
value = g_strdup (start);
g_free (line_dup);
- g_warning ("Found value: %s", value);
+ d(g_warning ("Found value: %s", value));
return value;
die:
@@ -396,7 +394,6 @@ netscape_import_accounts (NetscapeImporter *importer)
char *serverstr, *name, *url;
const char *username;
- g_warning ("i: %d", i);
/* Create a server for each of these */
serverstr = g_strdup_printf ("mail.imap.server.%s.", servers[i]);
name = g_strconcat (serverstr, "userName", NULL);
@@ -409,7 +406,6 @@ netscape_import_accounts (NetscapeImporter *importer)
else
url = g_strconcat ("imap://", servers[i], NULL);
- g_warning ("URL: %s", url);
imapsource.url = CORBA_string_dup (url);
imapsource.keep_on_server = netscape_get_boolean ("mail.leave_on_server");
@@ -550,7 +546,7 @@ netscape_import_file (NetscapeImporter *importer,
CORBA_Object objref;
/* Do import */
- g_warning ("Importing %s as %s\n", path, folderpath);
+ d(g_warning ("Importing %s as %s\n", path, folderpath));
CORBA_exception_init (&ev);
@@ -566,7 +562,7 @@ netscape_import_file (NetscapeImporter *importer,
importer->listener = evolution_importer_listener_new (importer_cb,
importer);
objref = bonobo_object_corba_objref (BONOBO_OBJECT (importer->listener));
- g_print ("%s:Processing...\n", __FUNCTION__);
+ d(g_print ("%s:Processing...\n", __FUNCTION__));
CORBA_exception_init (&ev);
GNOME_Evolution_Importer_processItem (importer->importer,
objref, &ev);
diff --git a/importers/pine-importer.c b/importers/pine-importer.c
index d0d9f33c45..787b9f78f7 100644
--- a/importers/pine-importer.c
+++ b/importers/pine-importer.c
@@ -142,7 +142,7 @@ get_field (char **start,
/* if start is just \n then we need the next line */
if (**start == '\n') {
- g_warning ("Need next line");
+ d(g_warning ("Need next line"));
if (fgets (line, 4096, handle) == NULL) {
g_warning ("Hmmm, no next line");
return NULL;
@@ -181,7 +181,7 @@ get_field (char **start,
*start = end + 1;
}
- g_warning ("Found %s", field);
+ d(g_warning ("Found %s", field));
return field;
}
@@ -243,13 +243,13 @@ import_addressfile (EBook *book,
start = line;
nick = get_field (&start, handle);
- g_print ("Nick: %s\n", nick);
+ d(g_print ("Nick: %s\n", nick));
fullname = get_field (&start, handle);
- g_print ("Fullname: %s\n", fullname);
+ d(g_print ("Fullname: %s\n", fullname));
address = get_field (&start, handle);
- g_print ("Address: %s\n", address);
+ d(g_print ("Address: %s\n", address));
if (*address == '(') {
char nextline[4096];
@@ -273,30 +273,22 @@ import_addressfile (EBook *book,
*(bracket + 1) == '\t') {
*(bracket + 1) = 0;
- g_print ("More addresses: %s\n", nextline);
-#if 0
- e_list_append (emaillist, g_strdup (nextline));
-#endif
+ d(g_print ("More addresses: %s\n", nextline));
start = bracket + 2;
break;
} else {
- g_print ("More addresses: %s\n", nextline);
-#if 0
- e_list_append (emaillist, g_strdup (nextline));
-#endif
+ d(g_print ("More addresses: %s\n", nextline));
}
}
} else {
email = parse_address (address);
-
- g_print ("Real address: %s", email);
}
fcc = get_field (&start, handle);
- g_print ("FCC: %s\n", fcc);
+ d(g_print ("FCC: %s\n", fcc));
comment = get_field (&start, handle);
- g_print ("Comment: %s\n", comment);
+ d(g_print ("Comment: %s\n", comment));
if (distrib == FALSE) {
/* This was not a distribution list...
@@ -321,6 +313,12 @@ import_addressfile (EBook *book,
e_book_add_card (importer->book, simple->card, NULL, NULL);
}
+ g_free (nick);
+ g_free (email);
+ g_free (address);
+ g_free (comment);
+ g_free (fcc);
+ g_free (fullname);
}
fclose (handle);