2001-03-29 Kjartan Maraas <kmaraas@gnome.org> * e-component-registry.c: Remove/replace unneeded includes and move around stuff so that system headers are included first. * e-corba-storage.c: Replace #include <bonobo.h> * e-folder-tree.c: Shuffle. * e-folder.c: Remove #include <gtk/gtkobject.h> * e-local-storage.c: Replace #include <gnome.h> and <bonobo.h> * e-setup.c: Replace #include <glib.h> and <gnome.h> * e-shell-folder-creation-dialog.c: Replace #include <gnome.h> * e-shell-folder-title-bar.c: Replace <gnome.h> * e-shell-utils.c: Same here. * e-shell-view-menu.c: Same here (and <bonobo.h>) * e-shell-view.c: Replace <gnome.h> and <bonobo.h> * e-shell.c: Replace <gnome.h> * e-shell.h: Shuffle. * e-shortcuts-view-model.c: Replace <gnome.h> * e-shortcuts-view.c: Remove #include <gnome.h> * e-shortcuts.c: Move <string.h> up. * e-splash.c: Replace <gnome.h> * e-storage-set-view.c: Replace <gnome.h> * e-storage-set.c: Shuffle * e-storage.c: Replace <gnome.h> * evolution-local-storage.c: Same here * evolution-local-storage.h: And here. * evolution-session.c: Same here too. * evolution-session.h: Replace <bonobo.h> * evolution-shell-client.c: Here too. * evolution-shell-component-client.c: Shuffle. * evolution-shell-component.c: Replace <bonobo.h> * evolution-shell-view.c: Remove #include <bonobo.h> * evolution-shell-view.h: Replace <gnome.h> * evolution-storage-listener.c: Replace <gnome.h> and <bonobo.h> * evolution-storage-listener.h: Replace <gnome.h> * evolution-storage-set-view-listener.c: Replace <gnome.h> and <bonobo.h> * evolution-storage-set-view.c: Remove <gnome.h> * evolution-storage.c: Replace <bonobo.h> * main.c: Replace <gnome.h> and <bonobo.h> * importer/importer.c: Replace <gnome.h> * importer/intelligent.c: Replace <gnome.h>. Add prototype for svn path=/trunk/; revision=9019
233 lines
5.9 KiB
C
233 lines
5.9 KiB
C
/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
|
|
/* intelligent.c
|
|
*
|
|
* Authors:
|
|
* Iain Holmes <iain@ximian.com>
|
|
*
|
|
* Copyright 2001 Ximian, Inc. (http://www.ximian.com)
|
|
*
|
|
* 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 the Free Software Foundation; either version 2 of the
|
|
* License, or (at your option) any later version.
|
|
*
|
|
* This program is distributed in the hope that it will be useful,
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
* GNU General Public License for more details.
|
|
*
|
|
* You should have received a copy of the GNU General Public License
|
|
* along with this program; if not, write to the Free Software
|
|
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
|
|
* USA
|
|
*/
|
|
|
|
#ifdef HAVE_CONFIG_H
|
|
#include <config.h>
|
|
#endif
|
|
|
|
#include <gtk/gtkbox.h>
|
|
#include <gtk/gtkcheckbutton.h>
|
|
#include <gtk/gtklabel.h>
|
|
#include <gtk/gtkmain.h>
|
|
#include <gtk/gtkobject.h>
|
|
#include <gtk/gtktogglebutton.h>
|
|
#include <gtk/gtkwidget.h>
|
|
#include <gtk/gtkwindow.h>
|
|
|
|
#include <libgnome/gnome-defs.h>
|
|
#include <libgnome/gnome-config.h>
|
|
#include <libgnome/gnome-i18n.h>
|
|
#include <libgnome/gnome-util.h>
|
|
#include <libgnomeui/gnome-dialog.h>
|
|
#include <libgnomeui/gnome-stock.h>
|
|
|
|
#include <liboaf/liboaf.h>
|
|
|
|
#include "intelligent.h"
|
|
#include "GNOME_Evolution_Importer.h"
|
|
|
|
/* Prototypes */
|
|
|
|
void intelligent_importer_init (void);
|
|
|
|
/* End prototypes */
|
|
|
|
static void
|
|
start_importer (const char *iid)
|
|
{
|
|
CORBA_Object importer;
|
|
CORBA_Environment ev;
|
|
CORBA_char *name;
|
|
CORBA_char *message;
|
|
CORBA_boolean can_run;
|
|
|
|
GtkWidget *dialog, *label, *ask;
|
|
gboolean dontaskagain;
|
|
char *str, *prefix;
|
|
|
|
if (iid == NULL || *iid == '\0')
|
|
return;
|
|
|
|
/* Check if we want to show this one again */
|
|
prefix = g_strdup_printf ("=%s/evolution/config/Shell=/intelligent-importers/", gnome_util_user_home ());
|
|
gnome_config_push_prefix (prefix);
|
|
g_free (prefix);
|
|
|
|
dontaskagain = gnome_config_get_bool (iid);
|
|
gnome_config_pop_prefix ();
|
|
|
|
if (dontaskagain)
|
|
return;
|
|
|
|
CORBA_exception_init (&ev);
|
|
importer = oaf_activate_from_id ((char *) iid, 0, NULL, &ev);
|
|
if (ev._major != CORBA_NO_EXCEPTION) {
|
|
CORBA_exception_free (&ev);
|
|
g_warning ("Could not start %s", iid);
|
|
return;
|
|
}
|
|
|
|
CORBA_exception_free (&ev);
|
|
if (importer == CORBA_OBJECT_NIL) {
|
|
g_warning ("Could not activate_component %s", iid);
|
|
return;
|
|
}
|
|
|
|
CORBA_exception_init (&ev);
|
|
can_run = GNOME_Evolution_IntelligentImporter_canImport (importer, &ev);
|
|
if (ev._major != CORBA_NO_EXCEPTION) {
|
|
g_warning ("Could not get canImport(%s): %s", iid, CORBA_exception_id (&ev));
|
|
CORBA_Object_release (importer, &ev);
|
|
CORBA_exception_free (&ev);
|
|
return;
|
|
}
|
|
CORBA_exception_free (&ev);
|
|
|
|
if (can_run == FALSE) {
|
|
return;
|
|
}
|
|
|
|
name = GNOME_Evolution_IntelligentImporter__get_importername (importer,
|
|
&ev);
|
|
if (ev._major != CORBA_NO_EXCEPTION) {
|
|
g_warning ("Could not get name(%s): %s", iid, CORBA_exception_id (&ev));
|
|
CORBA_Object_release (importer, &ev);
|
|
CORBA_exception_free (&ev);
|
|
return;
|
|
}
|
|
message = GNOME_Evolution_IntelligentImporter__get_message (importer, &ev);
|
|
if (ev._major != CORBA_NO_EXCEPTION) {
|
|
g_warning ("Could not get message(%s): %s", iid, CORBA_exception_id (&ev));
|
|
CORBA_Object_release (importer, &ev);
|
|
CORBA_exception_free (&ev);
|
|
return;
|
|
}
|
|
|
|
CORBA_exception_free (&ev);
|
|
|
|
dialog = gnome_dialog_new ("Import files",
|
|
GNOME_STOCK_BUTTON_YES, GNOME_STOCK_BUTTON_NO,
|
|
NULL);
|
|
gtk_window_set_title (GTK_WINDOW (dialog), name);
|
|
CORBA_free (name);
|
|
|
|
label = gtk_label_new (message);
|
|
CORBA_free (message);
|
|
|
|
gtk_box_pack_start (GTK_BOX (GNOME_DIALOG (dialog)->vbox), label,
|
|
FALSE, FALSE, 0);
|
|
gtk_widget_show (label);
|
|
|
|
ask = gtk_check_button_new_with_label (_("Don't ask me again"));
|
|
gtk_box_pack_start (GTK_BOX (GNOME_DIALOG (dialog)->vbox), ask,
|
|
FALSE, FALSE, 0);
|
|
gtk_widget_show (ask);
|
|
|
|
switch (gnome_dialog_run (GNOME_DIALOG (dialog))) {
|
|
case 0:
|
|
/* Yes */
|
|
dontaskagain = gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (ask));
|
|
prefix = g_strdup_printf ("=%s/evolution/config/Shell=/intelligent-importers/", gnome_util_user_home ());
|
|
gnome_config_push_prefix (prefix);
|
|
g_free (prefix);
|
|
|
|
gnome_config_set_bool (iid, dontaskagain);
|
|
gnome_config_sync ();
|
|
gnome_config_drop_all ();
|
|
|
|
gnome_config_pop_prefix ();
|
|
|
|
gtk_object_destroy (GTK_OBJECT (dialog));
|
|
while (gtk_events_pending ())
|
|
gtk_main_iteration ();
|
|
|
|
GNOME_Evolution_IntelligentImporter_importData (importer, &ev);
|
|
break;
|
|
case 1:
|
|
case -1:
|
|
default:
|
|
/* No */
|
|
dontaskagain = gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (ask));
|
|
prefix = g_strdup_printf ("=%s/evolution/config/Shell=/intelligent-importers/", gnome_util_user_home ());
|
|
gnome_config_push_prefix (prefix);
|
|
g_free (prefix);
|
|
|
|
gnome_config_set_bool (iid, dontaskagain);
|
|
gnome_config_sync ();
|
|
gnome_config_drop_all ();
|
|
|
|
gnome_config_pop_prefix ();
|
|
|
|
gtk_object_destroy (GTK_OBJECT (dialog));
|
|
|
|
break;
|
|
}
|
|
|
|
CORBA_exception_init (&ev);
|
|
CORBA_Object_release (importer, &ev);
|
|
CORBA_exception_free (&ev);
|
|
}
|
|
|
|
|
|
static GList *
|
|
get_intelligent_importers (void)
|
|
{
|
|
OAF_ServerInfoList *info_list;
|
|
GList *iids_ret = NULL;
|
|
CORBA_Environment ev;
|
|
int i;
|
|
|
|
CORBA_exception_init (&ev);
|
|
info_list = oaf_query ("repo_ids.has ('IDL:GNOME/Evolution/IntelligentImporter:1.0')", NULL, &ev);
|
|
CORBA_exception_free (&ev);
|
|
|
|
for (i = 0; i < info_list->_length; i++) {
|
|
const OAF_ServerInfo *info;
|
|
|
|
info = info_list->_buffer + i;
|
|
iids_ret = g_list_prepend (iids_ret, g_strdup (info->iid));
|
|
}
|
|
|
|
return iids_ret;
|
|
}
|
|
|
|
void
|
|
intelligent_importer_init (void)
|
|
{
|
|
GList *importers, *l;
|
|
|
|
importers = get_intelligent_importers ();
|
|
if (importers == NULL)
|
|
return; /* No intelligent importers. Easy :) */
|
|
|
|
/* Loop through each importer, running it. */
|
|
for (l = importers; l; l = l->next) {
|
|
start_importer (l->data);
|
|
g_free (l->data);
|
|
}
|
|
|
|
g_list_free (importers);
|
|
}
|
|
|