[evolution-patches] 71373 Re-enabling first run wizard



First pass at this.  The basics seem to work.  I haven't tested the
intelligent import really at all (if something is found).  I'm also not
so thrilled about the name and placement of the "upgrade.attempt" event,
its not clear where else it could go or be named though.

-JP
-- 
JP Rosevear <jpr novell com>
Novell, Inc.
Index: ChangeLog
===================================================================
RCS file: /cvs/gnome/evolution/ChangeLog,v
retrieving revision 1.1439
diff -u -r1.1439 ChangeLog
--- ChangeLog	3 Feb 2005 17:58:52 -0000	1.1439
+++ ChangeLog	21 Feb 2005 21:55:31 -0000
@@ -1,3 +1,7 @@
+2005-02-21  JP Rosevear  <jpr novell com>
+
+	* configure.in: add startup wizard plugin
+
 2005-02-01  Priit Laes <amd store20 com>
 
 	* configure.in : Remove duplicate entries for addressbook-groupwise,
Index: configure.in
===================================================================
RCS file: /cvs/gnome/evolution/configure.in,v
retrieving revision 1.784
diff -u -r1.784 configure.in
--- configure.in	9 Feb 2005 00:24:57 -0000	1.784
+++ configure.in	21 Feb 2005 21:55:32 -0000
@@ -1333,7 +1333,7 @@
 AC_ARG_ENABLE(plugins, [  --enable-plugins=[no/all/list]      Enable plugins.],enable_plugins="$enableval",enable_plugins=base)
 
 dnl Add any new plugins here
-plugins_base="calendar-file calendar-http calendar-weather groupwise-account-setup itip-formatter plugin-manager send-options shared-folder groupwise-send-options exchange-account-setup groupwise-status-tracking default-source addressbook-file addressbook-groupwise" 
+plugins_base="calendar-file calendar-http calendar-weather groupwise-account-setup itip-formatter plugin-manager send-options shared-folder groupwise-send-options exchange-account-setup groupwise-status-tracking default-source addressbook-file addressbook-groupwise startup-wizard" 
 
 plugins_all="bbdb subject-thread save-attachments prefer-plain save-calendar select-one-source copy-tool mail-to-meeting mail-to-task folder-unsubscribe mark-calendar-offline audio-inline mailing-list-actions backup-restore new-mail-notify" 
 
@@ -1579,6 +1579,7 @@
 plugins/default-source/Makefile
 plugins/addressbook-file/Makefile
 plugins/addressbook-groupwise/Makefile
+plugins/startup-wizard/Makefile
 smime/Makefile
 smime/lib/Makefile
 smime/gui/Makefile
Index: ChangeLog
===================================================================
RCS file: /cvs/gnome/evolution/mail/ChangeLog,v
retrieving revision 1.3577
diff -u -r1.3577 ChangeLog
--- ChangeLog	21 Feb 2005 06:37:13 -0000	1.3577
+++ ChangeLog	21 Feb 2005 21:55:57 -0000
@@ -1,3 +1,13 @@
+2005-02-21  JP Rosevear  <jpr novell com>
+
+	* em-account-editor.h: update protos
+
+	* em-account-editor.c (em_account_editor_new_with_config_id):
+	create a new account editor with a specific config id
+	(em_account_editor_new): pass NULL to construct
+	(em_account_editor_construct): take a config id argument and use
+	it if non-null
+
 2005-02-14  Not Zed  <NotZed Ximian com>
 
 	** See bug #61363 & e-util/ChangeLog
Index: em-account-editor.c
===================================================================
RCS file: /cvs/gnome/evolution/mail/em-account-editor.c,v
retrieving revision 1.19
diff -u -r1.19 em-account-editor.c
--- em-account-editor.c	21 Feb 2005 06:37:13 -0000	1.19
+++ em-account-editor.c	21 Feb 2005 21:55:58 -0000
@@ -284,7 +284,30 @@
 {
 	EMAccountEditor *emae = g_object_new(em_account_editor_get_type(), 0);
 
-	em_account_editor_construct(emae, account, type);
+	em_account_editor_construct(emae, account, type, NULL);
+
+	return emae;
+}
+
+/**
+ * em_account_editor_new_with_config_id:
+ * @account: 
+ * @type: 
+ * @config_id: 
+ * 
+ * Create a new account editor with the given config id.  If @account
+ * is NULL then this is to create a new account, else @account is
+ * copied to a working structure and is for editing an existing
+ * account.
+ * 
+ * Return value: 
+ **/
+EMAccountEditor *
+em_account_editor_new_with_config_id(struct _EAccount *account, em_account_editor_t type, char *config_id)
+{
+	EMAccountEditor *emae = g_object_new(em_account_editor_get_type(), 0);
+
+	em_account_editor_construct(emae, account, type, config_id);
 
 	return emae;
 }
@@ -2484,7 +2507,7 @@
 }
 
 void
-em_account_editor_construct(EMAccountEditor *emae, EAccount *account, em_account_editor_t type)
+em_account_editor_construct(EMAccountEditor *emae, EAccount *account, em_account_editor_t type, char *config_id)
 {
 	EMAccountEditorPrivate *gui = emae->priv;
 	int i, index;
@@ -2528,7 +2551,7 @@
 		 *
 		 * The account editor window.
 		 */
-		ec = em_config_new(E_CONFIG_BOOK, "org.gnome.evolution.mail.config.accountEditor");
+		ec = em_config_new(E_CONFIG_BOOK, config_id ? config_id : "org.gnome.evolution.mail.config.accountEditor");
 		items = emae_editor_items;
 	} else {
 		/** @HookPoint-EMConfig: New Mail Account Druid
@@ -2539,7 +2562,7 @@
 		 *
 		 * The new mail account druid.
 		 */
-		ec = em_config_new(E_CONFIG_DRUID, "org.gnome.evolution.mail.config.accountDruid");
+		ec = em_config_new(E_CONFIG_DRUID, config_id ? config_id : "org.gnome.evolution.mail.config.accountDruid");
 		items = emae_druid_items;
 	}
 
Index: em-account-editor.h
===================================================================
RCS file: /cvs/gnome/evolution/mail/em-account-editor.h,v
retrieving revision 1.2
diff -u -r1.2 em-account-editor.h
--- em-account-editor.h	20 Sep 2004 05:59:54 -0000	1.2
+++ em-account-editor.h	21 Feb 2005 21:55:58 -0000
@@ -64,8 +64,9 @@
 
 GType em_account_editor_get_type(void);
 
-void em_account_editor_construct(EMAccountEditor *emae, struct _EAccount *account, em_account_editor_t type);
+void em_account_editor_construct(EMAccountEditor *emae, struct _EAccount *account, em_account_editor_t type, char *config_id);
 EMAccountEditor *em_account_editor_new(struct _EAccount *account, em_account_editor_t type);
+EMAccountEditor *em_account_editor_new_with_config_id(struct _EAccount *account, em_account_editor_t type, char *config_id);
 
 gboolean em_account_editor_save (EMAccountEditor *gui);
 void em_account_editor_destroy (EMAccountEditor *gui);
Index: startup-wizard/.cvsignore
===================================================================
RCS file: startup-wizard/.cvsignore
diff -N startup-wizard/.cvsignore
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ startup-wizard/.cvsignore	21 Feb 2005 21:56:26 -0000
@@ -0,0 +1,3 @@
+Makefile.in
+Makefile
+org-gnome-evolution-startup-wizard.eplug
Index: startup-wizard/ChangeLog
===================================================================
RCS file: startup-wizard/ChangeLog
diff -N startup-wizard/ChangeLog
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ startup-wizard/ChangeLog	21 Feb 2005 21:56:26 -0000
@@ -0,0 +1,4 @@
+2005-02-21  JP Rosevear  <jpr novell com>
+
+	* startup-wizard.c: A plugin the does the startup wizard
+
Index: startup-wizard/Makefile.am
===================================================================
RCS file: startup-wizard/Makefile.am
diff -N startup-wizard/Makefile.am
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ startup-wizard/Makefile.am	21 Feb 2005 21:56:26 -0000
@@ -0,0 +1,20 @@
+INCLUDES = -I .						\
+	-I$(top_srcdir)	                                \
+	$(EVOLUTION_MAIL_CFLAGS)
+
+ EVO_PLUGIN_RULE@
+
+plugin_DATA = org-gnome-evolution-startup-wizard.eplug
+plugin_LTLIBRARIES = liborg-gnome-evolution-startup-wizard.la
+
+liborg_gnome_evolution_startup_wizard_la_SOURCES = 	\
+	startup-wizard.c
+
+liborg_gnome_evolution_startup_wizard_la_LIBADD = 		\
+	$(top_builddir)/e-util/libeutil.la 			\
+	$(top_builddir)/widgets/misc/libemiscwidgets.la		\
+	$(EVOLUTION_MAIL_LIBS)
+
+liborg_gnome_evolution_startup_wizard_la_LDFLAGS = -module -avoid-version
+
+EXTRA_DIST = org-gnome-evolution-startup-wizard.eplug.in
Index: startup-wizard/org-gnome-evolution-startup-wizard.eplug.in
===================================================================
RCS file: startup-wizard/org-gnome-evolution-startup-wizard.eplug.in
diff -N startup-wizard/org-gnome-evolution-startup-wizard.eplug.in
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ startup-wizard/org-gnome-evolution-startup-wizard.eplug.in	21 Feb 2005 21:56:26 -0000
@@ -0,0 +1,25 @@
+<?xml version="1.0"?>
+<e-plugin-list>
+	  <e-plugin
+	    type="shlib"
+	    id="org.gnome.evolution.plugin.startup-wizard"
+	    location="@PLUGINDIR@/liborg-gnome-evolution-startup-wizard.so"
+	    name="Startup wizard">
+
+		<hook class="org.gnome.evolution.shell.events:1.0">
+			<event
+			   id="upgrade.attempt"
+			   handle="startup_wizard"
+			   target="upgrade"
+			/>
+		</hook>    
+
+	    <hook class="org.gnome.evolution.mail.config:1.0">
+		      <group target="account" id="org.gnome.evolution.mail.config.accountWizard" check="startup_wizard_check" commit="startup_wizard_commit" abort="startup_wizard_abort">
+			<item type="page" path="50.timezone" factory="startup_wizard_timezone_page"/>
+			<item type="page" path="60.importers" factory="startup_wizard_importer_page"/>
+		      </group>
+	    </hook>
+
+	  </e-plugin>
+</e-plugin-list>
Index: startup-wizard/startup-wizard.c
===================================================================
RCS file: startup-wizard/startup-wizard.c
diff -N startup-wizard/startup-wizard.c
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ startup-wizard/startup-wizard.c	21 Feb 2005 21:56:26 -0000
@@ -0,0 +1,508 @@
+/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*-
+ *
+ *  JP Rosevear <jpr novell com>
+ *  Copyright (C) 2005 Novell, Inc.
+ *
+ *  Permission is hereby granted, free of charge, to any person
+ *  obtaining a copy of this software and associated documentation
+ *  files (the "Software"), to deal in the Software without
+ *  restriction, including without limitation the rights to use, copy,
+ *  modify, merge, publish, distribute, sublicense, and/or sell copies
+ *  of the Software, and to permit persons to whom the Software is
+ *  furnished to do so, subject to the following conditions:
+ *  
+ *  The above copyright notice and this permission notice shall be
+ *  included in all copies or substantial portions of the Software.
+ *  
+ *  THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ *  EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ *  MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ *  NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
+ *  HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ *  WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ *  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
+ *  DEALINGS IN THE SOFTWARE.
+ */
+
+
+#include <gconf/gconf-client.h>
+#include <glib/gi18n.h>
+#include <gtk/gtk.h>
+#include <libgnomeui/libgnomeui.h>
+#include <bonobo/bonobo-exception.h>
+#include <bonobo/bonobo-widget.h>
+#include "widgets/e-timezone-dialog/e-timezone-dialog.h"
+#include "e-util/e-icon-factory.h"
+#include "e-util/e-gtk-utils.h"
+#include "shell/es-event.h"
+#include "shell/importer/GNOME_Evolution_Importer.h"
+#include "mail/em-config.h"
+#include "mail/em-account-editor.h"
+#include "calendar/gui/calendar-config.h"
+
+typedef struct _ImportData {
+	GList *importers;
+	
+	int running;
+	gboolean prepared;
+} ImportData;
+
+typedef struct _IntelligentImporterData {
+	CORBA_Object object;
+	Bonobo_Control control;
+	GtkWidget *widget;
+
+	char *name;
+	char *blurb;
+	char *iid;
+} IntelligentImporterData;
+
+typedef struct _SelectedImporterData{
+	CORBA_Object importer;
+	char *iid;
+} SelectedImporterData;
+
+#define IMPORT_PAGE_DATA "StartupWizard::ImportData"
+#define IMPORT_TIMEZONE_DIALOG "StartupWizard::TimezoneDialog"
+
+void startup_wizard (EPlugin *ep, ESEventTargetUpgrade *target);
+GtkWidget *startup_wizard_timezone_page (EPlugin *ep, EConfigHookItemFactoryData *hook_data);
+GtkWidget *startup_wizard_importer_page (EPlugin *ep, EConfigHookItemFactoryData *hook_data);
+gboolean startup_wizard_check (EPlugin *ep, EConfigHookPageCheckData *check_data);
+void startup_wizard_commit (EPlugin *ep, EMConfigTargetAccount *target);
+void startup_wizard_abort (EPlugin *ep, EMConfigTargetAccount *target);
+
+void
+startup_wizard (EPlugin *ep, ESEventTargetUpgrade *target)
+{
+	GConfClient *client;
+	GSList *accounts;
+	EMAccountEditor *emae;
+	
+	client = gconf_client_get_default ();
+	accounts = gconf_client_get_list (client, "/apps/evolution/mail/accounts", GCONF_VALUE_STRING, NULL);
+	g_object_unref (client);
+	
+	if (accounts != NULL) {
+		g_slist_foreach (accounts, (GFunc) g_free, NULL);
+		g_slist_free (accounts);
+
+		return;
+	}	
+
+	emae = em_account_editor_new_with_config_id (NULL, EMAE_DRUID, "org.gnome.evolution.mail.config.accountWizard");
+
+	gtk_window_set_title (GTK_WINDOW (emae->editor), _("Evolution Setup Assistant"));
+
+	/* FIXME Fix page title */
+	gnome_druid_page_edge_set_text (GNOME_DRUID_PAGE_EDGE (e_config_page_get ((EConfig *) emae->config, "0.start")), "Welcome to Evolution. The next few screens will allow Evolution "
+					"to connect to your email accounts, and to import files from other applications.\n\n"
+					"Please click the \"Forward\" button to continue.");
+	
+	gtk_widget_show (emae->editor);
+	gtk_main ();
+}
+
+GtkWidget *
+startup_wizard_timezone_page (EPlugin *ep, EConfigHookItemFactoryData *hook_data)
+{
+	ETimezoneDialog *etd;
+	GtkWidget *page;
+	GdkPixbuf *pixbuf;
+	icaltimezone *zone;
+	
+	etd = e_timezone_dialog_new ();
+	g_object_set_data (G_OBJECT (hook_data->config), IMPORT_TIMEZONE_DIALOG, etd);
+	
+	pixbuf = e_icon_factory_get_icon ("stock_timezone", E_ICON_SIZE_DIALOG);
+	page = gnome_druid_page_standard_new_with_vals ("Timezone", pixbuf, NULL);
+	g_object_unref (pixbuf);
+	e_timezone_dialog_reparent (etd, GNOME_DRUID_PAGE_STANDARD (page)->vbox);
+
+	zone = calendar_config_get_icaltimezone	();
+	if (zone)
+		e_timezone_dialog_set_timezone (etd, zone);
+	
+	gnome_druid_append_page (GNOME_DRUID (hook_data->parent), GNOME_DRUID_PAGE (page));
+
+	return GTK_WIDGET (page);
+}
+
+GtkWidget *
+startup_wizard_importer_page (EPlugin *ep, EConfigHookItemFactoryData *hook_data)
+{
+	GtkWidget *page, *label, *sep;
+	GdkPixbuf *pixbuf;
+
+	pixbuf = e_icon_factory_get_icon ("stock_mail-import", E_ICON_SIZE_DIALOG);
+	page = gnome_druid_page_standard_new_with_vals ("Importing files", pixbuf, NULL);
+	g_object_unref (pixbuf);
+
+	label = gtk_label_new (_("Please select the information that you would like to import:"));
+	gtk_box_pack_start (GTK_BOX (GNOME_DRUID_PAGE_STANDARD (page)->vbox), label, FALSE, FALSE, 3);
+
+	sep = gtk_hseparator_new ();
+	gtk_box_pack_start (GTK_BOX (GNOME_DRUID_PAGE_STANDARD (page)->vbox), sep, FALSE, FALSE, 3);
+
+	gnome_druid_append_page (GNOME_DRUID (hook_data->parent), GNOME_DRUID_PAGE (page));
+
+	return GTK_WIDGET (page);
+}
+
+static GList *
+get_intelligent_importers (void)
+{
+	Bonobo_ServerInfoList *info_list;
+	GList *iids_ret = NULL;
+	CORBA_Environment ev;
+	char *query;
+	int i;
+
+	CORBA_exception_init (&ev);
+	query = g_strdup_printf ("repo_ids.has ('IDL:GNOME/Evolution/IntelligentImporter:%s')", BASE_VERSION);
+	info_list = bonobo_activation_query (query, NULL, &ev);
+	g_free (query);
+
+	if (BONOBO_EX (&ev) || info_list == CORBA_OBJECT_NIL) {
+		g_warning ("Cannot find importers -- %s", BONOBO_EX_REPOID (&ev));
+		CORBA_exception_free (&ev);
+		return NULL;
+	}
+	CORBA_exception_free (&ev);
+
+	for (i = 0; i < info_list->_length; i++) {
+		const Bonobo_ServerInfo *info;
+
+		info = info_list->_buffer + i;
+		iids_ret = g_list_prepend (iids_ret, g_strdup (info->iid));
+	}
+
+	return iids_ret;
+}
+ 
+gboolean
+startup_wizard_check (EPlugin *ep, EConfigHookPageCheckData *check_data)
+{
+	EConfig *ec;
+	GnomeDruid *druid;
+	GnomeDruidPage *finish_page, *import_page;
+	GtkWidget *dialog;
+	ImportData *import_data;
+	GList *l, *importers;
+	GtkWidget *table;
+	int running = 0;
+
+	if (strcmp ("60.importers", check_data->pageid))
+		return TRUE;
+
+	ec = check_data->config;
+	
+	import_data = g_object_get_data (G_OBJECT (ec), IMPORT_PAGE_DATA);
+	if (!import_data) {
+		/* FIXME Free this */
+		import_data = g_new0 (ImportData, 1);
+		g_object_set_data (G_OBJECT (ec), IMPORT_PAGE_DATA, import_data);
+	}
+
+	druid = GNOME_DRUID (ec->widget);
+	import_page = GNOME_DRUID_PAGE (e_config_page_get (ec, "60.import"));
+	finish_page = GNOME_DRUID_PAGE (e_config_page_get (ec, "999.end"));
+	
+	if (import_data->prepared == TRUE) {
+		if (import_data->running == 0)
+			gnome_druid_set_page (druid, finish_page);
+		return TRUE;
+	}
+
+	import_data->prepared = TRUE;
+
+	dialog = gtk_message_dialog_new (NULL, 0, GTK_MESSAGE_INFO,
+					 GTK_BUTTONS_NONE,
+					 _("Please wait...\nScanning for existing setups"));
+#if !GTK_CHECK_VERSION (2,4,0)
+	gtk_dialog_set_has_separator (GTK_DIALOG (dialog), FALSE);
+#endif
+	e_make_widget_backing_stored (dialog);
+
+	gtk_window_set_title (GTK_WINDOW (dialog), _("Starting import"));
+	gtk_widget_show_all (dialog);
+	gtk_widget_show_now (dialog);
+
+	gtk_widget_queue_draw (dialog);
+	gdk_flush ();
+
+	while (gtk_events_pending ()) {
+		gtk_main_iteration ();
+	}
+
+	importers = get_intelligent_importers ();
+	if (importers == NULL) {
+		/* No importers, go directly to finish, do not pass go
+		   Do not collect $200 */
+		gnome_druid_set_page (druid, finish_page);
+		gtk_widget_destroy (dialog);
+		return TRUE;
+	}
+
+	table = gtk_table_new (g_list_length (importers), 2, FALSE);
+	for (l = importers; l; l = l->next) {
+		GtkWidget *label;
+		CORBA_Environment ev;
+		gboolean can_run;
+		char *str;
+		IntelligentImporterData *id;
+
+		id = g_new0 (IntelligentImporterData, 1);
+		id->iid = g_strdup (l->data);
+
+		CORBA_exception_init (&ev);
+		id->object = bonobo_activation_activate_from_id ((char *) id->iid, 0, NULL, &ev);
+		if (BONOBO_EX (&ev)) {
+			g_warning ("Could not start %s:%s", id->iid,
+				   CORBA_exception_id (&ev));
+
+			CORBA_exception_free (&ev);
+			/* Clean up the IID */
+			g_free (id->iid);
+			g_free (id);
+			continue;
+		}
+
+		if (id->object == CORBA_OBJECT_NIL) {
+			g_warning ("Could not activate component %s", id->iid);
+			CORBA_exception_free (&ev);
+
+			g_free (id->iid);
+			g_free (id);
+			continue;
+		}
+
+		can_run = GNOME_Evolution_IntelligentImporter_canImport (id->object, &ev);
+		if (BONOBO_EX (&ev)) {
+			g_warning ("Could not call canImport(%s): %s", id->iid,
+				   CORBA_exception_id (&ev));
+			bonobo_object_release_unref (id->object, &ev);
+			CORBA_exception_free (&ev);
+
+			g_free (id->iid);
+			g_free (id);
+			continue;
+		}
+
+		if (can_run == FALSE) {
+			bonobo_object_release_unref (id->object, &ev);
+			CORBA_exception_free (&ev);
+			g_free (id->iid);
+			g_free (id);
+			continue;
+		}
+
+		running++;
+		id->name = GNOME_Evolution_IntelligentImporter__get_importername (id->object, &ev);
+		if (BONOBO_EX (&ev)) {
+			g_warning ("Could not get name(%s): %s", id->iid,
+				   CORBA_exception_id (&ev));
+			bonobo_object_release_unref (id->object, &ev);
+			CORBA_exception_free (&ev);
+			g_free (id->iid);
+			g_free (id);
+			continue;
+		}
+
+		id->blurb = GNOME_Evolution_IntelligentImporter__get_message (id->object, &ev);
+		if (BONOBO_EX (&ev)) {
+			g_warning ("Could not get message(%s): %s",
+				   id->iid, CORBA_exception_id (&ev));
+			bonobo_object_release_unref (id->object, &ev);
+			CORBA_exception_free (&ev);
+			g_free (id->iid);
+			CORBA_free (id->name);
+			g_free (id);
+			continue;
+		}
+
+		id->control = Bonobo_Unknown_queryInterface (id->object,
+							     "IDL:Bonobo/Control:1.0", &ev);
+		if (BONOBO_EX (&ev)) {
+			g_warning ("Could not QI for Bonobo/Control:1.0 %s:%s",
+				   id->iid, CORBA_exception_id (&ev));
+			bonobo_object_release_unref (id->object, &ev);
+			CORBA_exception_free (&ev);
+			g_free (id->iid);
+			CORBA_free (id->name);
+			CORBA_free (id->blurb);
+			continue;
+		}
+
+		if (id->control != CORBA_OBJECT_NIL) {
+			id->widget = bonobo_widget_new_control_from_objref (id->control, CORBA_OBJECT_NIL);
+			gtk_widget_show (id->widget);
+		} else {
+			printf("no control\n");
+			id->widget = gtk_label_new ("");
+			gtk_widget_show (id->widget);
+		}
+
+		CORBA_exception_free (&ev);
+
+		import_data->importers = g_list_prepend (import_data->importers, id);
+		str = g_strdup_printf (_("From %s:"), id->name);
+		label = gtk_label_new (str);
+		g_free (str);
+
+		gtk_misc_set_alignment (GTK_MISC (label), 0, .5); 
+
+		gtk_table_attach (GTK_TABLE (table), label, 0, 1, running - 1,
+				  running, GTK_FILL, 0, 0, 0);
+		gtk_table_attach (GTK_TABLE (table), id->widget, 1, 2,
+				  running - 1, running, GTK_FILL, 0, 3, 0);
+		gtk_widget_show_all (table);
+
+		gtk_box_pack_start (GTK_BOX (GNOME_DRUID_PAGE_STANDARD (import_page)->vbox), table,
+				    FALSE, FALSE, 0);
+	}
+
+	if (running == 0) {
+		gnome_druid_set_page (druid, finish_page);
+		gtk_widget_destroy (dialog);
+		return TRUE;
+	}
+
+	import_data->running = running;
+	gtk_widget_destroy (dialog);
+
+	return FALSE;	
+}
+
+static void
+free_importers (ImportData *import_data)
+{
+	GList *l;
+
+	for (l = import_data->importers; l; l = l->next) {
+		IntelligentImporterData *iid;
+
+		iid = l->data;
+		if (iid->object != CORBA_OBJECT_NIL) 
+			bonobo_object_release_unref (iid->object, NULL);
+	}
+
+	g_list_free (import_data->importers);
+}
+
+static void
+start_importers (GList *p)
+{
+	CORBA_Environment ev;
+	
+	for (; p; p = p->next) {
+		SelectedImporterData *sid = p->data;
+
+		CORBA_exception_init (&ev);
+		GNOME_Evolution_IntelligentImporter_importData (sid->importer, &ev);
+		if (BONOBO_EX (&ev)) {
+			g_warning ("Error importing %s\n%s", sid->iid,
+				   CORBA_exception_id (&ev));
+		}
+		CORBA_exception_free (&ev);
+	}
+}
+
+static void
+do_import (ImportData *import_data)
+{
+	CORBA_Environment ev;
+	GList *l, *selected = NULL;
+
+	for (l = import_data->importers; l; l = l->next) {
+		IntelligentImporterData *importer_data;
+		SelectedImporterData *sid;
+		char *iid;
+
+		importer_data = l->data;
+		iid = g_strdup (importer_data->iid);
+
+		sid = g_new (SelectedImporterData, 1);
+		sid->iid = iid;
+
+		CORBA_exception_init (&ev);
+		sid->importer = bonobo_object_dup_ref (importer_data->object, &ev);
+		if (BONOBO_EX (&ev)) {
+			g_warning ("Error duplication %s\n(%s)", iid,
+				   CORBA_exception_id (&ev));
+			g_free (iid);
+			CORBA_exception_free (&ev);
+			g_free (sid);
+			continue;
+		}
+		CORBA_exception_free (&ev);
+
+		selected = g_list_prepend (selected, sid);
+	}
+
+	free_importers (import_data);
+
+	if (selected != NULL) {
+		start_importers (selected);
+
+		for (l = selected; l; l = l->next) {
+			SelectedImporterData *sid = l->data;
+
+			CORBA_exception_init (&ev);
+			bonobo_object_release_unref (sid->importer, &ev);
+			CORBA_exception_free (&ev);
+
+			g_free (sid->iid);
+			g_free (sid);
+		}
+		g_list_free (selected);
+	}
+}
+
+void
+startup_wizard_commit (EPlugin *ep, EMConfigTargetAccount *target)
+{
+	EConfig *ec = ((EConfigTarget *)target)->config;
+	ImportData *import_data;
+	ETimezoneDialog *etd;
+	icaltimezone *zone;
+
+	import_data = g_object_get_data (G_OBJECT (ec), IMPORT_PAGE_DATA);
+	if (import_data)
+		do_import (import_data);		
+	
+	/* Set Timezone */
+	etd = g_object_get_data (G_OBJECT (ec), IMPORT_TIMEZONE_DIALOG);
+	if (etd) {
+		g_message ("Cleaning up timezone information");
+		zone = e_timezone_dialog_get_timezone (E_TIMEZONE_DIALOG (etd));
+		if (zone)
+			calendar_config_set_timezone (icaltimezone_get_display_name (zone));
+
+		/* Need to do this otherwise the timezone widget gets destroyed but the
+		   timezone object isn't, and we can get a crash like #22047.  */
+		g_object_unref (etd);
+		g_object_set_data (G_OBJECT (ec), IMPORT_TIMEZONE_DIALOG, NULL);
+	}
+	
+
+	gtk_main_quit ();
+}
+
+void
+startup_wizard_abort (EPlugin *ep, EMConfigTargetAccount *target)
+{
+	EConfig *ec = ((EConfigTarget *)target)->config;
+	ETimezoneDialog *etd;
+
+	etd = g_object_get_data (G_OBJECT (ec), IMPORT_TIMEZONE_DIALOG);
+	if (etd) {
+		/* Need to do this otherwise the timezone widget gets destroyed but the
+		   timezone object isn't, and we can get a crash like #22047.  */
+		g_object_unref (etd);
+		g_object_set_data (G_OBJECT (ec), IMPORT_TIMEZONE_DIALOG, NULL);
+	}
+
+	gtk_main_quit ();
+	exit (0);
+}
Index: ChangeLog
===================================================================
RCS file: /cvs/gnome/evolution/shell/ChangeLog,v
retrieving revision 1.1496
diff -u -r1.1496 ChangeLog
--- ChangeLog	16 Feb 2005 16:18:36 -0000	1.1496
+++ ChangeLog	21 Feb 2005 22:00:46 -0000
@@ -1,3 +1,11 @@
+2005-02-21  JP Rosevear  <jpr novell com>
+
+	* es-event.c (es_event_target_new_upgrade): create upgrade target
+
+	* es-event.h: add upgrade target 
+
+	* e-shell.c (e_shell_attempt_upgrade): emit upgrade.attempt
+
 2005-02-10  JP Rosevear  <jpr novell com>
 
 	* e-component-registry.c (query_components): unref the menu icon
Index: es-event.c
===================================================================
RCS file: /cvs/gnome/evolution/shell/es-event.c,v
retrieving revision 1.1
diff -u -r1.1 es-event.c
--- es-event.c	25 Oct 2004 04:46:18 -0000	1.1
+++ es-event.c	21 Feb 2005 22:00:47 -0000
@@ -129,6 +129,18 @@
 	return t;
 }
 
+ESEventTargetUpgrade *
+es_event_target_new_upgrade(ESEvent *eme, int major, int minor, int revision)
+{
+	ESEventTargetUpgrade *t = e_event_target_new(&eme->event, ES_EVENT_TARGET_UPGRADE, sizeof(*t));
+
+	t->major = major;
+	t->minor = minor;
+	t->revision = revision;
+
+	return t;	
+}
+
 /* ********************************************************************** */
 
 static void *emeh_parent_class;
@@ -142,6 +154,7 @@
 
 static const EEventHookTargetMap emeh_targets[] = {
 	{ "state", ES_EVENT_TARGET_STATE, emeh_state_masks },
+	{ "upgrade", ES_EVENT_TARGET_UPGRADE, NULL },
 	{ 0 }
 };
 
Index: es-event.h
===================================================================
RCS file: /cvs/gnome/evolution/shell/es-event.h,v
retrieving revision 1.1
diff -u -r1.1 es-event.h
--- es-event.h	25 Oct 2004 04:46:18 -0000	1.1
+++ es-event.h	21 Feb 2005 22:00:47 -0000
@@ -38,6 +38,7 @@
 /* Current target description */
 enum _es_event_target_t {
 	ES_EVENT_TARGET_STATE,
+	ES_EVENT_TARGET_UPGRADE
 };
 
 /* Flags that qualify TARGET_STATE */
@@ -47,6 +48,7 @@
 };
 
 typedef struct _ESEventTargetState ESEventTargetState;
+typedef struct _ESEventTargetUpgrade ESEventTargetUpgrade;
 
 struct _ESEventTargetState {
 	EEventTarget target;
@@ -54,6 +56,14 @@
 	int state;
 };
 
+struct _ESEventTargetUpgrade {
+	EEventTarget target;
+
+	int major;
+	int minor;
+	int revision;
+};
+
 typedef struct _EEventItem ESEventItem;
 
 /* The object */
@@ -72,6 +82,7 @@
 ESEvent *es_event_peek(void);
 
 ESEventTargetState *es_event_target_new_state(ESEvent *emp, int state);
+ESEventTargetUpgrade *es_event_target_new_upgrade(ESEvent *emp, int major, int minor, int revision);
 
 /* ********************************************************************** */
 
Index: e-shell.c
===================================================================
RCS file: /cvs/gnome/evolution/shell/e-shell.c,v
retrieving revision 1.258
diff -u -r1.258 e-shell.c
--- e-shell.c	10 Jan 2005 02:35:12 -0000	1.258
+++ e-shell.c	21 Feb 2005 22:00:47 -0000
@@ -651,13 +651,6 @@
 	
 	e_shell_attempt_upgrade(shell);
 
-#if 0
-	if (e_shell_startup_wizard_create () == FALSE) {
-		bonobo_object_unref (BONOBO_OBJECT (shell));
-		exit (0);
-	}
-#endif
-
 	priv->is_initialized = TRUE;
 
 	switch (startup_line_mode) {
@@ -780,6 +773,7 @@
 	int done_upgrade = FALSE;
 	char *oldpath;
 	struct stat st;
+	ESEvent *ese;
 
 	gconf_client = gconf_client_get_default();
 
@@ -870,6 +864,16 @@
 	g_free(oldpath);
 	g_object_unref (gconf_client);
 
+	/** @Event: Shell attempted upgrade
+	 * @Id: upgrade.attempt
+	 * @Target: ESMenuTargetState
+	 * 
+	 * This event is emitted whenever the shell successfully attempts an upgrade.
+	 *
+	 */
+	ese = es_event_peek();
+	e_event_emit((EEvent *)ese, "upgrade.attempt", (EEventTarget *)es_event_target_new_upgrade(ese, cmajor, cminor, crevision));
+	
 	return TRUE;
 }
 


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]