Everything under shell/importer is unused. Kill it.
svn path=/branches/kill-bonobo/; revision=37305
This commit is contained in:
@ -1,97 +0,0 @@
|
||||
/* -*- Mode: IDL; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
|
||||
/*
|
||||
* Interfaces for the importer framework.
|
||||
*
|
||||
* Authors:
|
||||
* Iain Holmes <iain@ximian.com>
|
||||
*
|
||||
* Copyright (C) 2000 Ximian, Inc.
|
||||
*/
|
||||
|
||||
#include <Bonobo.idl>
|
||||
|
||||
module GNOME {
|
||||
module Evolution {
|
||||
interface ImporterListener : Bonobo::Unknown {
|
||||
enum ImporterResult {
|
||||
OK,
|
||||
UNSUPPORTED_OPERATION,
|
||||
NOT_READY,
|
||||
BUSY,
|
||||
UNKNOWN_DATA,
|
||||
BAD_DATA,
|
||||
BAD_FILE
|
||||
};
|
||||
|
||||
/**
|
||||
* notifyResult:
|
||||
* @result: The result of the import.
|
||||
* @more_items: Are there any more items to be processed?
|
||||
*
|
||||
* Notifies the listener of the result and whether there are
|
||||
* any more items to be imported.
|
||||
*/
|
||||
oneway void notifyResult (in ImporterResult result,
|
||||
in boolean more_items);
|
||||
};
|
||||
|
||||
interface Importer : Bonobo::Unknown {
|
||||
|
||||
/**
|
||||
* processItem:
|
||||
* @listener: The ImporterListener that will be notified of the
|
||||
* progress.
|
||||
*
|
||||
* Processes the next item.
|
||||
*
|
||||
*/
|
||||
oneway void processItem (in ImporterListener listener);
|
||||
|
||||
/**
|
||||
* getError:
|
||||
*
|
||||
* Retrieve a detailed explaination of the error.
|
||||
*
|
||||
* Returns: A string.
|
||||
*/
|
||||
string getError ();
|
||||
|
||||
void createControl (out Bonobo::Control control);
|
||||
|
||||
/**
|
||||
* supportFormat:
|
||||
* @filename: The filename of the file.
|
||||
*
|
||||
* Checks if the importer created by this factory can
|
||||
* import the file specified.
|
||||
*
|
||||
* Returns: A boolean, TRUE if it can import the file,
|
||||
* FALSE otherwise.
|
||||
*/
|
||||
boolean supportFormat (in string filename);
|
||||
|
||||
/**
|
||||
* loadFile:
|
||||
* @filename: The filename of the file.
|
||||
* @folderpath: The full pathname to the folder.
|
||||
* @foldertpe: The type of the folder to import to.
|
||||
*
|
||||
* Loads the file and prepares an Importer object that can
|
||||
* process files of this type.
|
||||
*
|
||||
* Returns: An Importer object.
|
||||
*/
|
||||
boolean loadFile (in string filename);
|
||||
};
|
||||
|
||||
interface IntelligentImporter : Bonobo::Unknown {
|
||||
|
||||
readonly attribute string importername;
|
||||
readonly attribute string message;
|
||||
|
||||
boolean canImport ();
|
||||
|
||||
void importData ();
|
||||
};
|
||||
};
|
||||
};
|
||||
@ -1,66 +0,0 @@
|
||||
INCLUDES = \
|
||||
-I$(top_srcdir) \
|
||||
-I$(top_srcdir)/shell \
|
||||
-I$(top_builddir)/shell \
|
||||
-DG_LOG_DOMAIN=\"Evolution-Importer\" \
|
||||
-DEVOLUTION_GLADEDIR="\"$(gladedir)\"" \
|
||||
$(SHELL_CFLAGS)
|
||||
|
||||
privlib_LTLIBRARIES = libevolution-importer.la
|
||||
|
||||
|
||||
# IDL stuff
|
||||
|
||||
IDLS = GNOME_Evolution_Importer.idl
|
||||
|
||||
IDL_GENERATED_H = \
|
||||
GNOME_Evolution_Importer.h
|
||||
|
||||
IDL_GENERATED_C = \
|
||||
GNOME_Evolution_Importer-common.c \
|
||||
GNOME_Evolution_Importer-skels.c \
|
||||
GNOME_Evolution_Importer-stubs.c
|
||||
|
||||
IDL_GENERATED = $(IDL_GENERATED_H) $(IDL_GENERATED_C)
|
||||
|
||||
$(IDL_GENERATED_H): $(IDLS)
|
||||
$(ORBIT_IDL) -I $(srcdir) $(IDL_INCLUDES) $(srcdir)/GNOME_Evolution_Importer.idl
|
||||
|
||||
$(IDL_GENERATED_C): $(IDL_GENERATED_H)
|
||||
|
||||
idl_DATA = $(IDLS)
|
||||
|
||||
|
||||
# Component
|
||||
|
||||
libevolution_importerincludedir = $(privincludedir)/importer
|
||||
libevolution_importer_la_SOURCES = \
|
||||
$(IDL_GENERATED) \
|
||||
evolution-intelligent-importer.c \
|
||||
evolution-importer-client.c \
|
||||
evolution-importer-listener.c \
|
||||
evolution-importer.c \
|
||||
intelligent.c \
|
||||
intelligent.h
|
||||
|
||||
libevolution_importerinclude_HEADERS = \
|
||||
GNOME_Evolution_Importer.h \
|
||||
evolution-intelligent-importer.h \
|
||||
evolution-importer-client.h \
|
||||
evolution-importer-listener.h \
|
||||
evolution-importer.h
|
||||
|
||||
libevolution_importer_la_LIBADD = \
|
||||
$(top_builddir)/e-util/libeutil.la \
|
||||
$(SHELL_LIBS)
|
||||
|
||||
glade_DATA = import.glade
|
||||
|
||||
EXTRA_DIST = $(glade_DATA) $(IDLS)
|
||||
|
||||
BUILT_SOURCES= $(IDL_GENERATED)
|
||||
CLEANFILES = $(BUILT_SOURCES)
|
||||
|
||||
dist-hook:
|
||||
cd $(distdir); rm -f $(BUILT_SOURCES)
|
||||
|
||||
@ -1,267 +0,0 @@
|
||||
/*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2 of the License, or (at your option) version 3.
|
||||
*
|
||||
* 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
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with the program; if not, see <http://www.gnu.org/licenses/>
|
||||
*
|
||||
*
|
||||
* Authors:
|
||||
* Iain Holmes <iain@ximian.com>
|
||||
*
|
||||
* Based on evolution-shell-component-client.c by Ettore Perazzoli
|
||||
*
|
||||
* Copyright (C) 1999-2008 Novell, Inc. (www.novell.com)
|
||||
*
|
||||
*/
|
||||
|
||||
#ifdef HAVE_CONFIG_H
|
||||
#include <config.h>
|
||||
#endif
|
||||
|
||||
#include "evolution-importer-client.h"
|
||||
|
||||
#include <glib.h>
|
||||
#include <bonobo/bonobo-object.h>
|
||||
#include <bonobo/bonobo-main.h>
|
||||
#include <bonobo/bonobo-widget.h>
|
||||
#include <bonobo/bonobo-exception.h>
|
||||
|
||||
#include "GNOME_Evolution_Importer.h"
|
||||
|
||||
G_DEFINE_TYPE (EvolutionImporterClient, evolution_importer_client, G_TYPE_OBJECT)
|
||||
|
||||
|
||||
static void
|
||||
finalise (GObject *object)
|
||||
{
|
||||
/* FIXME: should this unref the client->objref?? */
|
||||
|
||||
(* G_OBJECT_CLASS (evolution_importer_client_parent_class)->finalize) (object);
|
||||
}
|
||||
|
||||
static void
|
||||
evolution_importer_client_class_init (EvolutionImporterClientClass *klass)
|
||||
{
|
||||
GObjectClass *object_class;
|
||||
|
||||
object_class = G_OBJECT_CLASS (klass);
|
||||
|
||||
object_class->finalize = finalise;
|
||||
}
|
||||
|
||||
static void
|
||||
evolution_importer_client_init (EvolutionImporterClient *client)
|
||||
{
|
||||
}
|
||||
|
||||
/**
|
||||
* evolution_importer_client_new:
|
||||
* @objref: The CORBA_Object to make a client for.
|
||||
*
|
||||
* Makes a client for @objref. @objref should be an Evolution_Importer.
|
||||
*
|
||||
* Returns: A newly created EvolutionImporterClient.
|
||||
*/
|
||||
EvolutionImporterClient *
|
||||
evolution_importer_client_new (const CORBA_Object objref)
|
||||
{
|
||||
EvolutionImporterClient *client;
|
||||
|
||||
g_return_val_if_fail (objref != CORBA_OBJECT_NIL, NULL);
|
||||
|
||||
client = g_object_new (evolution_importer_client_get_type (), NULL);
|
||||
client->objref = objref;
|
||||
|
||||
return client;
|
||||
}
|
||||
|
||||
/**
|
||||
* evolution_importer_client_new_from_id:
|
||||
* @id: The oafiid of the component to make a client for.
|
||||
*
|
||||
* Makes a client for the object returned by activating @id.
|
||||
*
|
||||
* Returns: A newly created EvolutionImporterClient.
|
||||
*/
|
||||
EvolutionImporterClient *
|
||||
evolution_importer_client_new_from_id (const char *id)
|
||||
{
|
||||
CORBA_Environment ev;
|
||||
CORBA_Object objref;
|
||||
|
||||
g_return_val_if_fail (id != NULL, NULL);
|
||||
|
||||
CORBA_exception_init (&ev);
|
||||
objref = bonobo_activation_activate_from_id ((char *) id, 0, NULL, &ev);
|
||||
if (ev._major != CORBA_NO_EXCEPTION) {
|
||||
CORBA_exception_free (&ev);
|
||||
g_warning ("Could not start %s.", id);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
CORBA_exception_free (&ev);
|
||||
if (objref == CORBA_OBJECT_NIL) {
|
||||
g_warning ("Could not activate component %s", id);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
return evolution_importer_client_new (objref);
|
||||
}
|
||||
|
||||
/* API */
|
||||
GtkWidget *
|
||||
evolution_importer_client_create_control (EvolutionImporterClient *client)
|
||||
{
|
||||
GNOME_Evolution_Importer corba_importer;
|
||||
GtkWidget *widget = NULL;
|
||||
Bonobo_Control control;
|
||||
CORBA_Environment ev;
|
||||
|
||||
g_return_val_if_fail (client != NULL, NULL);
|
||||
g_return_val_if_fail (EVOLUTION_IS_IMPORTER_CLIENT (client), NULL);
|
||||
|
||||
CORBA_exception_init (&ev);
|
||||
corba_importer = client->objref;
|
||||
GNOME_Evolution_Importer_createControl (corba_importer, &control, &ev);
|
||||
|
||||
if (!BONOBO_EX (&ev)) {
|
||||
/* FIXME Pass in container? */
|
||||
widget = bonobo_widget_new_control_from_objref (control, NULL);
|
||||
gtk_widget_show (widget);
|
||||
}
|
||||
|
||||
CORBA_exception_free (&ev);
|
||||
|
||||
return widget;
|
||||
}
|
||||
|
||||
/**
|
||||
* evolution_importer_client_support_format:
|
||||
* @client: The EvolutionImporterClient.
|
||||
* @filename: Name of the file to check.
|
||||
*
|
||||
* Checks whether @client is able to import @filename.
|
||||
*
|
||||
* Returns: TRUE if @client can import @filename, FALSE otherwise.
|
||||
*/
|
||||
gboolean
|
||||
evolution_importer_client_support_format (EvolutionImporterClient *client,
|
||||
const char *filename)
|
||||
{
|
||||
GNOME_Evolution_Importer corba_importer;
|
||||
gboolean result;
|
||||
CORBA_Environment ev;
|
||||
|
||||
g_return_val_if_fail (client != NULL, FALSE);
|
||||
g_return_val_if_fail (EVOLUTION_IS_IMPORTER_CLIENT (client), FALSE);
|
||||
g_return_val_if_fail (filename != NULL, FALSE);
|
||||
|
||||
CORBA_exception_init (&ev);
|
||||
corba_importer = client->objref;
|
||||
result = GNOME_Evolution_Importer_supportFormat (corba_importer,
|
||||
filename, &ev);
|
||||
CORBA_exception_free (&ev);
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* evolution_importer_client_load_file:
|
||||
* @client: The EvolutionImporterClient.
|
||||
* @filename: The file to load.
|
||||
* @physical_uri: The physical URI of the folder to import data into.
|
||||
* @folder_type: The type of the folder represented by @physical_uri.
|
||||
*
|
||||
* Loads and initialises the importer.
|
||||
*
|
||||
* Returns: TRUE on sucess, FALSE on failure.
|
||||
*/
|
||||
gboolean
|
||||
evolution_importer_client_load_file (EvolutionImporterClient *client, const char *filename)
|
||||
{
|
||||
GNOME_Evolution_Importer corba_importer;
|
||||
gboolean result;
|
||||
CORBA_Environment ev;
|
||||
|
||||
g_return_val_if_fail (client != NULL, FALSE);
|
||||
g_return_val_if_fail (EVOLUTION_IS_IMPORTER_CLIENT (client), FALSE);
|
||||
g_return_val_if_fail (filename != NULL, FALSE);
|
||||
|
||||
CORBA_exception_init (&ev);
|
||||
corba_importer = client->objref;
|
||||
result = GNOME_Evolution_Importer_loadFile (corba_importer, filename, &ev);
|
||||
if (ev._major != CORBA_NO_EXCEPTION) {
|
||||
g_warning ("Oh there *WAS* an exception.\nIt was %s",
|
||||
CORBA_exception_id (&ev));
|
||||
CORBA_exception_free (&ev);
|
||||
return FALSE;
|
||||
}
|
||||
CORBA_exception_free (&ev);
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* evolution_importer_client_process_item:
|
||||
* @client: The EvolutionImporterClient.
|
||||
* @listener: The EvolutionImporterListener.
|
||||
*
|
||||
* Starts importing the next item in the file. @listener will be notified
|
||||
* when the item has finished.
|
||||
*/
|
||||
void
|
||||
evolution_importer_client_process_item (EvolutionImporterClient *client,
|
||||
EvolutionImporterListener *listener)
|
||||
{
|
||||
GNOME_Evolution_Importer corba_importer;
|
||||
GNOME_Evolution_ImporterListener corba_listener;
|
||||
CORBA_Environment ev;
|
||||
|
||||
g_return_if_fail (client != NULL);
|
||||
g_return_if_fail (EVOLUTION_IS_IMPORTER_CLIENT (client));
|
||||
g_return_if_fail (listener != NULL);
|
||||
g_return_if_fail (EVOLUTION_IS_IMPORTER_LISTENER (listener));
|
||||
|
||||
CORBA_exception_init (&ev);
|
||||
|
||||
corba_importer = client->objref;
|
||||
corba_listener = bonobo_object_corba_objref (BONOBO_OBJECT (listener));
|
||||
GNOME_Evolution_Importer_processItem (corba_importer,
|
||||
corba_listener, &ev);
|
||||
CORBA_exception_free (&ev);
|
||||
}
|
||||
|
||||
/**
|
||||
* evolution_importer_client_get_error:
|
||||
* @client: The EvolutionImporterClient.
|
||||
*
|
||||
* Gets the error as a string.
|
||||
*
|
||||
* Returns: The error as a string. If there is no error NULL is returned.
|
||||
* Importers need not support this method and if so, NULL is also returned.
|
||||
*/
|
||||
const char *
|
||||
evolution_importer_client_get_error (EvolutionImporterClient *client)
|
||||
{
|
||||
GNOME_Evolution_Importer corba_importer;
|
||||
CORBA_char *str;
|
||||
CORBA_Environment ev;
|
||||
|
||||
g_return_val_if_fail (client != NULL, NULL);
|
||||
g_return_val_if_fail (EVOLUTION_IS_IMPORTER_CLIENT (client), NULL);
|
||||
|
||||
corba_importer = client->objref;
|
||||
|
||||
CORBA_exception_init (&ev);
|
||||
str = GNOME_Evolution_Importer_getError (corba_importer, &ev);
|
||||
|
||||
return str;
|
||||
}
|
||||
@ -1,74 +0,0 @@
|
||||
/*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2 of the License, or (at your option) version 3.
|
||||
*
|
||||
* 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
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with the program; if not, see <http://www.gnu.org/licenses/>
|
||||
*
|
||||
*
|
||||
* Authors:
|
||||
* Iain Holmes <iain@ximian.com>
|
||||
*
|
||||
* Copyright (C) 1999-2008 Novell, Inc. (www.novell.com)
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef EVOLUTION_IMPORTER_CLIENT_H
|
||||
#define EVOLUTION_IMPORTER_CLIENT_H
|
||||
|
||||
#include <glib.h>
|
||||
#include <gtk/gtk.h>
|
||||
#include <importer/evolution-importer.h>
|
||||
#include <importer/evolution-importer-listener.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#pragma }
|
||||
#endif
|
||||
|
||||
#define EVOLUTION_TYPE_IMPORTER_CLIENT (evolution_importer_client_get_type ())
|
||||
#define EVOLUTION_IMPORTER_CLIENT(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), EVOLUTION_TYPE_IMPORTER_CLIENT, EvolutionImporterClient))
|
||||
#define EVOLUTION_IMPORTER_CLIENT_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), EVOLUTION_TYPE_IMPORTER_CLIENT, EvolutionImporterClientClass))
|
||||
#define EVOLUTION_IS_IMPORTER_CLIENT(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), EVOLUTION_TYPE_IMPORTER_CLIENT))
|
||||
#define EVOLUTION_IS_IMPORTER_CLIENT_CLASS(klass) (G_TYPE_CHECK_INSTANCE_TYPE ((klass), EVOLUTION_TYPE_IMPORTER_CLIENT))
|
||||
|
||||
|
||||
typedef struct _EvolutionImporterClient EvolutionImporterClient;
|
||||
typedef struct _EvolutionImporterClientClass EvolutionImporterClientClass;
|
||||
|
||||
struct _EvolutionImporterClient {
|
||||
GObject parent_type;
|
||||
|
||||
GNOME_Evolution_Importer objref;
|
||||
};
|
||||
|
||||
struct _EvolutionImporterClientClass {
|
||||
GObjectClass parent_class;
|
||||
};
|
||||
|
||||
GType evolution_importer_client_get_type (void);
|
||||
|
||||
EvolutionImporterClient *evolution_importer_client_new (const CORBA_Object objref);
|
||||
EvolutionImporterClient *evolution_importer_client_new_from_id (const char *id);
|
||||
|
||||
GtkWidget *evolution_importer_client_create_control (EvolutionImporterClient *client);
|
||||
gboolean evolution_importer_client_support_format (EvolutionImporterClient *client,
|
||||
const char *filename);
|
||||
gboolean evolution_importer_client_load_file (EvolutionImporterClient *client,
|
||||
const char *filename);
|
||||
void evolution_importer_client_process_item (EvolutionImporterClient *client,
|
||||
EvolutionImporterListener *listener);
|
||||
const char *evolution_importer_client_get_error (EvolutionImporterClient *client);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
||||
@ -1,224 +0,0 @@
|
||||
/*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2 of the License, or (at your option) version 3.
|
||||
*
|
||||
* 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
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with the program; if not, see <http://www.gnu.org/licenses/>
|
||||
*
|
||||
*
|
||||
* Authors:
|
||||
* Iain Holmes <iain@ximian.com>
|
||||
*
|
||||
* Copyright (C) 1999-2008 Novell, Inc. (www.novell.com)
|
||||
*
|
||||
*/
|
||||
|
||||
#ifdef HAVE_CONFIG_H
|
||||
#include <config.h>
|
||||
#endif
|
||||
|
||||
#include "evolution-importer-listener.h"
|
||||
|
||||
#include <bonobo/bonobo-object.h>
|
||||
#include <e-util/e-util.h>
|
||||
|
||||
#include "GNOME_Evolution_Importer.h"
|
||||
#define PARENT_TYPE BONOBO_OBJECT_TYPE
|
||||
|
||||
static BonoboObjectClass *parent_class = NULL;
|
||||
|
||||
struct _EvolutionImporterListenerPrivate {
|
||||
EvolutionImporterListenerCallback callback;
|
||||
|
||||
void *closure;
|
||||
};
|
||||
|
||||
#if 0
|
||||
static POA_GNOME_Evolution_ImporterListener__vepv Listener_vepv;
|
||||
|
||||
static POA_GNOME_Evolution_ImporterListener *
|
||||
create_servant (void)
|
||||
{
|
||||
POA_GNOME_Evolution_ImporterListener *servant;
|
||||
CORBA_Environment ev;
|
||||
|
||||
servant = (POA_GNOME_Evolution_ImporterListener *) g_new0 (BonoboObjectServant, 1);
|
||||
servant->vepv = &Listener_vepv;
|
||||
|
||||
CORBA_exception_init (&ev);
|
||||
POA_GNOME_Evolution_ImporterListener__init ((PortableServer_Servant) servant, &ev);
|
||||
if (ev._major != CORBA_NO_EXCEPTION) {
|
||||
g_free (servant);
|
||||
CORBA_exception_free (&ev);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
CORBA_exception_free (&ev);
|
||||
|
||||
return servant;
|
||||
}
|
||||
#endif
|
||||
|
||||
static EvolutionImporterResult
|
||||
corba_result_to_evolution (GNOME_Evolution_ImporterListener_ImporterResult corba_result)
|
||||
{
|
||||
switch (corba_result) {
|
||||
case GNOME_Evolution_ImporterListener_OK:
|
||||
return EVOLUTION_IMPORTER_OK;
|
||||
case GNOME_Evolution_ImporterListener_UNSUPPORTED_OPERATION:
|
||||
return EVOLUTION_IMPORTER_UNSUPPORTED_OPERATION;
|
||||
case GNOME_Evolution_ImporterListener_UNKNOWN_DATA:
|
||||
return EVOLUTION_IMPORTER_UNKNOWN_DATA;
|
||||
case GNOME_Evolution_ImporterListener_BAD_DATA:
|
||||
return EVOLUTION_IMPORTER_BAD_DATA;
|
||||
case GNOME_Evolution_ImporterListener_BAD_FILE:
|
||||
return EVOLUTION_IMPORTER_BAD_FILE;
|
||||
case GNOME_Evolution_ImporterListener_NOT_READY:
|
||||
return EVOLUTION_IMPORTER_NOT_READY;
|
||||
case GNOME_Evolution_ImporterListener_BUSY:
|
||||
return EVOLUTION_IMPORTER_BUSY;
|
||||
default:
|
||||
return EVOLUTION_IMPORTER_UNKNOWN_ERROR;
|
||||
}
|
||||
}
|
||||
|
||||
static inline EvolutionImporterListener *
|
||||
evolution_importer_listener_from_servant (PortableServer_Servant servant)
|
||||
{
|
||||
return EVOLUTION_IMPORTER_LISTENER (bonobo_object_from_servant (servant));
|
||||
}
|
||||
|
||||
static void
|
||||
impl_GNOME_Evolution_ImporterListener_notifyResult (PortableServer_Servant servant,
|
||||
GNOME_Evolution_ImporterListener_ImporterResult result,
|
||||
CORBA_boolean more_items,
|
||||
CORBA_Environment *ev)
|
||||
{
|
||||
EvolutionImporterListener *listener;
|
||||
EvolutionImporterListenerPrivate *priv;
|
||||
EvolutionImporterResult out_result;
|
||||
|
||||
listener = evolution_importer_listener_from_servant (servant);
|
||||
priv = listener->priv;
|
||||
|
||||
out_result = corba_result_to_evolution (result);
|
||||
if (priv->callback) {
|
||||
(priv->callback) (listener, out_result, more_items,
|
||||
priv->closure);
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
/* GObject methods */
|
||||
static void
|
||||
finalise (GObject *object)
|
||||
{
|
||||
EvolutionImporterListener *listener;
|
||||
EvolutionImporterListenerPrivate *priv;
|
||||
|
||||
listener = EVOLUTION_IMPORTER_LISTENER (object);
|
||||
priv = listener->priv;
|
||||
|
||||
if (priv == NULL)
|
||||
return;
|
||||
|
||||
g_free (priv);
|
||||
listener->priv = NULL;
|
||||
|
||||
G_OBJECT_CLASS (parent_class)->finalize(object);
|
||||
}
|
||||
|
||||
#if 0
|
||||
static void
|
||||
corba_class_init (void)
|
||||
{
|
||||
POA_GNOME_Evolution_ImporterListener__vepv *vepv;
|
||||
POA_GNOME_Evolution_ImporterListener__epv *epv;
|
||||
PortableServer_ServantBase__epv *base_epv;
|
||||
|
||||
base_epv = g_new0 (PortableServer_ServantBase__epv, 1);
|
||||
base_epv->_private = NULL;
|
||||
base_epv->finalize = NULL;
|
||||
base_epv->default_POA = NULL;
|
||||
|
||||
epv = g_new0 (POA_GNOME_Evolution_ImporterListener__epv, 1);
|
||||
epv->notifyResult = impl_GNOME_Evolution_ImporterListener_notifyResult;
|
||||
|
||||
vepv = &Listener_vepv;
|
||||
vepv->_base_epv = base_epv;
|
||||
vepv->Bonobo_Unknown_epv = bonobo_object_get_epv ();
|
||||
vepv->GNOME_Evolution_ImporterListener_epv = epv;
|
||||
}
|
||||
#endif
|
||||
|
||||
static void
|
||||
evolution_importer_listener_class_init (EvolutionImporterListenerClass *klass)
|
||||
{
|
||||
GObjectClass *object_class;
|
||||
POA_GNOME_Evolution_ImporterListener__epv *epv = &klass->epv;
|
||||
|
||||
object_class = G_OBJECT_CLASS (klass);
|
||||
object_class->finalize = finalise;
|
||||
|
||||
parent_class = g_type_class_ref(PARENT_TYPE);
|
||||
epv->notifyResult = impl_GNOME_Evolution_ImporterListener_notifyResult;
|
||||
}
|
||||
|
||||
static void
|
||||
evolution_importer_listener_init (EvolutionImporterListener *listener)
|
||||
{
|
||||
EvolutionImporterListenerPrivate *priv;
|
||||
|
||||
priv = g_new0 (EvolutionImporterListenerPrivate, 1);
|
||||
listener->priv = priv;
|
||||
}
|
||||
|
||||
static void
|
||||
evolution_importer_listener_construct (EvolutionImporterListener *listener,
|
||||
EvolutionImporterListenerCallback callback,
|
||||
void *closure)
|
||||
{
|
||||
EvolutionImporterListenerPrivate *priv;
|
||||
|
||||
g_return_if_fail (listener != NULL);
|
||||
g_return_if_fail (EVOLUTION_IS_IMPORTER_LISTENER (listener));
|
||||
g_return_if_fail (callback != NULL);
|
||||
|
||||
priv = listener->priv;
|
||||
priv->callback = callback;
|
||||
priv->closure = closure;
|
||||
}
|
||||
|
||||
/**
|
||||
* evolution_importer_listener_new
|
||||
* @callback: The #EvolutionImporterListenerCallback callback.
|
||||
* @closure: The data that will be passed to that callback.
|
||||
*
|
||||
* Creates a new #EvolutionImporterListener object which calls @callback when
|
||||
* something happens.
|
||||
* Returns: A newly allocated #EvolutionImporterListener.
|
||||
*/
|
||||
EvolutionImporterListener *
|
||||
evolution_importer_listener_new (EvolutionImporterListenerCallback callback,
|
||||
void *closure)
|
||||
{
|
||||
EvolutionImporterListener *listener;
|
||||
|
||||
listener = g_object_new (evolution_importer_listener_get_type (), NULL);
|
||||
|
||||
evolution_importer_listener_construct (listener, callback, closure);
|
||||
return listener;
|
||||
}
|
||||
|
||||
BONOBO_TYPE_FUNC_FULL (EvolutionImporterListener,
|
||||
GNOME_Evolution_ImporterListener,
|
||||
PARENT_TYPE, evolution_importer_listener);
|
||||
@ -1,71 +0,0 @@
|
||||
/*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2 of the License, or (at your option) version 3.
|
||||
*
|
||||
* 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
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with the program; if not, see <http://www.gnu.org/licenses/>
|
||||
*
|
||||
*
|
||||
* Authors:
|
||||
* Iain Holmes <iain@ximian.com>
|
||||
*
|
||||
* Copyright (C) 1999-2008 Novell, Inc. (www.novell.com)
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef EVOLUTION_IMPORTER_LISTENER_H
|
||||
#define EVOLUTION_IMPORTER_LISTENER_H
|
||||
|
||||
#include <glib.h>
|
||||
#include <bonobo/bonobo-object.h>
|
||||
#include <importer/GNOME_Evolution_Importer.h>
|
||||
#include "evolution-importer.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#pragma }
|
||||
#endif /* cplusplus */
|
||||
|
||||
#define EVOLUTION_TYPE_IMPORTER_LISTENER (evolution_importer_listener_get_type ())
|
||||
#define EVOLUTION_IMPORTER_LISTENER(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), EVOLUTION_TYPE_IMPORTER_LISTENER, EvolutionImporterListener))
|
||||
#define EVOLUTION_IMPORTER_LISTENER_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), EVOLUTION_TYPE_IMPORTER_LISTENER, EvolutionImporterListenerClass))
|
||||
#define EVOLUTION_IS_IMPORTER_LISTENER(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), EVOLUTION_TYPE_IMPORTER_LISTENER))
|
||||
#define EVOLUTION_IS_IMPORTER_LISTENER_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((obj), EVOLUTION_TYPE_IMPORTER_LISTENER))
|
||||
|
||||
typedef struct _EvolutionImporterListener EvolutionImporterListener;
|
||||
typedef struct _EvolutionImporterListenerPrivate EvolutionImporterListenerPrivate;
|
||||
typedef struct _EvolutionImporterListenerClass EvolutionImporterListenerClass;
|
||||
|
||||
typedef void (* EvolutionImporterListenerCallback) (EvolutionImporterListener *listener,
|
||||
EvolutionImporterResult result,
|
||||
gboolean more_items,
|
||||
void *closure);
|
||||
struct _EvolutionImporterListener {
|
||||
BonoboObject parent;
|
||||
|
||||
EvolutionImporterListenerPrivate *priv;
|
||||
};
|
||||
|
||||
struct _EvolutionImporterListenerClass {
|
||||
BonoboObjectClass parent_class;
|
||||
|
||||
POA_GNOME_Evolution_ImporterListener__epv epv;
|
||||
};
|
||||
|
||||
GType evolution_importer_listener_get_type (void);
|
||||
|
||||
EvolutionImporterListener *evolution_importer_listener_new (EvolutionImporterListenerCallback callback,
|
||||
void *closure);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
||||
@ -1,249 +0,0 @@
|
||||
/*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2 of the License, or (at your option) version 3.
|
||||
*
|
||||
* 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
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with the program; if not, see <http://www.gnu.org/licenses/>
|
||||
*
|
||||
*
|
||||
* Authors:
|
||||
* Iain Holmes <iain@ximian.com>
|
||||
*
|
||||
* Copyright (C) 1999-2008 Novell, Inc. (www.novell.com)
|
||||
*
|
||||
*/
|
||||
|
||||
#ifdef HAVE_CONFIG_H
|
||||
#include <config.h>
|
||||
#endif
|
||||
|
||||
#include "evolution-importer.h"
|
||||
|
||||
#include <bonobo/bonobo-object.h>
|
||||
#include <e-util/e-util.h>
|
||||
|
||||
#include "GNOME_Evolution_Importer.h"
|
||||
|
||||
#define PARENT_TYPE BONOBO_OBJECT_TYPE
|
||||
static BonoboObjectClass *parent_class = NULL;
|
||||
|
||||
struct _EvolutionImporterPrivate {
|
||||
EvolutionImporterCreateControlFn create_control_fn;
|
||||
EvolutionImporterLoadFileFn load_file_fn;
|
||||
EvolutionImporterSupportFormatFn support_format_fn;
|
||||
EvolutionImporterProcessItemFn process_item_fn;
|
||||
EvolutionImporterGetErrorFn get_error_fn;
|
||||
|
||||
void *closure;
|
||||
};
|
||||
|
||||
|
||||
static inline EvolutionImporter *
|
||||
evolution_importer_from_servant (PortableServer_Servant servant)
|
||||
{
|
||||
return EVOLUTION_IMPORTER (bonobo_object_from_servant (servant));
|
||||
}
|
||||
|
||||
static void
|
||||
impl_GNOME_Evolution_Importer_createControl (PortableServer_Servant servant,
|
||||
Bonobo_Control *control,
|
||||
CORBA_Environment *ev)
|
||||
{
|
||||
EvolutionImporter *importer;
|
||||
EvolutionImporterPrivate *priv;
|
||||
|
||||
importer = evolution_importer_from_servant (servant);
|
||||
priv = importer->priv;
|
||||
|
||||
if (priv->create_control_fn != NULL)
|
||||
(priv->create_control_fn) (importer, control, priv->closure);
|
||||
else
|
||||
CORBA_exception_set_system (ev, ex_CORBA_NO_IMPLEMENT, CORBA_COMPLETED_NO);
|
||||
}
|
||||
|
||||
static CORBA_boolean
|
||||
impl_GNOME_Evolution_Importer_supportFormat (PortableServer_Servant servant,
|
||||
const CORBA_char *filename,
|
||||
CORBA_Environment *ev)
|
||||
{
|
||||
EvolutionImporter *importer;
|
||||
EvolutionImporterPrivate *priv;
|
||||
|
||||
importer = evolution_importer_from_servant (servant);
|
||||
priv = importer->priv;
|
||||
|
||||
if (priv->support_format_fn != NULL)
|
||||
return (priv->support_format_fn) (importer, filename,
|
||||
priv->closure);
|
||||
else
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
static CORBA_boolean
|
||||
impl_GNOME_Evolution_Importer_loadFile (PortableServer_Servant servant,
|
||||
const CORBA_char *filename,
|
||||
CORBA_Environment *ev)
|
||||
{
|
||||
EvolutionImporter *importer;
|
||||
EvolutionImporterPrivate *priv;
|
||||
|
||||
importer = evolution_importer_from_servant (servant);
|
||||
priv = importer->priv;
|
||||
|
||||
if (priv->load_file_fn != NULL)
|
||||
return (priv->load_file_fn) (importer, filename, priv->closure);
|
||||
else
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
static void
|
||||
impl_GNOME_Evolution_Importer_processItem (PortableServer_Servant servant,
|
||||
GNOME_Evolution_ImporterListener listener,
|
||||
CORBA_Environment *ev)
|
||||
{
|
||||
EvolutionImporter *importer;
|
||||
EvolutionImporterPrivate *priv;
|
||||
|
||||
importer = evolution_importer_from_servant (servant);
|
||||
priv = importer->priv;
|
||||
|
||||
if (priv->process_item_fn != NULL)
|
||||
(priv->process_item_fn) (importer, listener, priv->closure, ev);
|
||||
else
|
||||
GNOME_Evolution_ImporterListener_notifyResult (listener,
|
||||
GNOME_Evolution_ImporterListener_UNSUPPORTED_OPERATION, FALSE, ev);
|
||||
}
|
||||
|
||||
static CORBA_char *
|
||||
impl_GNOME_Evolution_Importer_getError (PortableServer_Servant servant,
|
||||
CORBA_Environment *ev)
|
||||
{
|
||||
EvolutionImporter *importer;
|
||||
EvolutionImporterPrivate *priv;
|
||||
CORBA_char *out_str;
|
||||
|
||||
importer = evolution_importer_from_servant (servant);
|
||||
priv = importer->priv;
|
||||
|
||||
if (priv->get_error_fn != NULL) {
|
||||
out_str = (priv->get_error_fn) (importer, priv->closure);
|
||||
return CORBA_string_dup (out_str ? out_str : "");
|
||||
} else
|
||||
return CORBA_string_dup ("");
|
||||
}
|
||||
|
||||
|
||||
static void
|
||||
finalise (GObject *object)
|
||||
{
|
||||
EvolutionImporter *importer;
|
||||
EvolutionImporterPrivate *priv;
|
||||
|
||||
importer = EVOLUTION_IMPORTER (object);
|
||||
priv = importer->priv;
|
||||
|
||||
if (priv == NULL)
|
||||
return;
|
||||
|
||||
g_free (priv);
|
||||
importer->priv = NULL;
|
||||
|
||||
G_OBJECT_CLASS (parent_class)->finalize (object);
|
||||
}
|
||||
|
||||
static void
|
||||
evolution_importer_class_init (EvolutionImporterClass *klass)
|
||||
{
|
||||
GObjectClass *object_class;
|
||||
POA_GNOME_Evolution_Importer__epv *epv = &klass->epv;
|
||||
|
||||
object_class = G_OBJECT_CLASS (klass);
|
||||
object_class->finalize = finalise;
|
||||
|
||||
parent_class = g_type_class_ref(PARENT_TYPE);
|
||||
epv->createControl = impl_GNOME_Evolution_Importer_createControl;
|
||||
epv->supportFormat = impl_GNOME_Evolution_Importer_supportFormat;
|
||||
epv->loadFile = impl_GNOME_Evolution_Importer_loadFile;
|
||||
epv->processItem = impl_GNOME_Evolution_Importer_processItem;
|
||||
epv->getError = impl_GNOME_Evolution_Importer_getError;
|
||||
}
|
||||
|
||||
static void
|
||||
evolution_importer_init (EvolutionImporter *importer)
|
||||
{
|
||||
EvolutionImporterPrivate *priv;
|
||||
|
||||
priv = g_new0 (EvolutionImporterPrivate, 1);
|
||||
|
||||
importer->priv = priv;
|
||||
}
|
||||
|
||||
|
||||
|
||||
static void
|
||||
evolution_importer_construct (EvolutionImporter *importer,
|
||||
EvolutionImporterCreateControlFn create_control_fn,
|
||||
EvolutionImporterSupportFormatFn support_format_fn,
|
||||
EvolutionImporterLoadFileFn load_file_fn,
|
||||
EvolutionImporterProcessItemFn process_item_fn,
|
||||
EvolutionImporterGetErrorFn get_error_fn,
|
||||
void *closure)
|
||||
{
|
||||
EvolutionImporterPrivate *priv;
|
||||
|
||||
g_return_if_fail (importer != NULL);
|
||||
g_return_if_fail (EVOLUTION_IS_IMPORTER (importer));
|
||||
g_return_if_fail (support_format_fn != NULL);
|
||||
g_return_if_fail (load_file_fn != NULL);
|
||||
g_return_if_fail (process_item_fn != NULL);
|
||||
|
||||
priv = importer->priv;
|
||||
priv->create_control_fn = create_control_fn;
|
||||
priv->support_format_fn = support_format_fn;
|
||||
priv->load_file_fn = load_file_fn;
|
||||
priv->process_item_fn = process_item_fn;
|
||||
priv->get_error_fn = get_error_fn;
|
||||
|
||||
priv->closure = closure;
|
||||
}
|
||||
|
||||
/**
|
||||
* evolution_importer_new:
|
||||
* @support_format_fn: The function to be called by the supportFormat method.
|
||||
* @load_file_fn: The function to be called by the loadFile method.
|
||||
* @process_item_fn: The function to be called by the processItem method.
|
||||
* @get_error_fn: The function to be called by the getError method.
|
||||
* @closure: The data to be passed to all of the above functions.
|
||||
*
|
||||
* Creates a new EvolutionImporter object. Of the parameters only
|
||||
* @get_error_function and @closure may be #NULL.
|
||||
*
|
||||
* Returns: A newly created EvolutionImporter object.
|
||||
*/
|
||||
EvolutionImporter *
|
||||
evolution_importer_new (EvolutionImporterCreateControlFn create_control_fn,
|
||||
EvolutionImporterSupportFormatFn support_format_fn,
|
||||
EvolutionImporterLoadFileFn load_file_fn,
|
||||
EvolutionImporterProcessItemFn process_item_fn,
|
||||
EvolutionImporterGetErrorFn get_error_fn,
|
||||
void *closure)
|
||||
{
|
||||
EvolutionImporter *importer;
|
||||
|
||||
importer = g_object_new(evolution_importer_get_type (), NULL);
|
||||
evolution_importer_construct (importer, create_control_fn, support_format_fn, load_file_fn,
|
||||
process_item_fn, get_error_fn, closure);
|
||||
return importer;
|
||||
}
|
||||
|
||||
BONOBO_TYPE_FUNC_FULL (EvolutionImporter,
|
||||
GNOME_Evolution_Importer,
|
||||
PARENT_TYPE,
|
||||
evolution_importer);
|
||||
@ -1,100 +0,0 @@
|
||||
/*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2 of the License, or (at your option) version 3.
|
||||
*
|
||||
* 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
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with the program; if not, see <http://www.gnu.org/licenses/>
|
||||
*
|
||||
*
|
||||
* Authors:
|
||||
* Iain Holmes <iain@ximian.com>
|
||||
*
|
||||
* Copyright (C) 1999-2008 Novell, Inc. (www.novell.com)
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef EVOLUTION_IMPORTER_H
|
||||
#define EVOLUTION_IMPORTER_H
|
||||
|
||||
#include <glib.h>
|
||||
#include <bonobo/bonobo-object.h>
|
||||
#include <importer/GNOME_Evolution_Importer.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#pragma }
|
||||
#endif /* cplusplus */
|
||||
|
||||
#define EVOLUTION_TYPE_IMPORTER (evolution_importer_get_type ())
|
||||
#define EVOLUTION_IMPORTER(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), EVOLUTION_TYPE_IMPORTER, EvolutionImporter))
|
||||
#define EVOLUTION_IMPORTER_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), EVOLUTION_TYPE_IMPORTER, EvolutionImporterClass))
|
||||
#define EVOLUTION_IS_IMPORTER(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), EVOLUTION_TYPE_IMPORTER))
|
||||
#define EVOLUTION_IS_IMPORTER_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((obj), EVOLUTION_TYPE_IMPORTER))
|
||||
|
||||
typedef struct _EvolutionImporter EvolutionImporter;
|
||||
typedef struct _EvolutionImporterPrivate EvolutionImporterPrivate;
|
||||
typedef struct _EvolutionImporterClass EvolutionImporterClass;
|
||||
|
||||
typedef void (* EvolutionImporterCreateControlFn) (EvolutionImporter *importer,
|
||||
Bonobo_Control *control,
|
||||
void *closure);
|
||||
|
||||
typedef gboolean (* EvolutionImporterSupportFormatFn) (EvolutionImporter *importer,
|
||||
const char *filename,
|
||||
void *closure);
|
||||
typedef gboolean (* EvolutionImporterLoadFileFn) (EvolutionImporter *importer,
|
||||
const char *filename,
|
||||
void *closure);
|
||||
typedef void (* EvolutionImporterProcessItemFn) (EvolutionImporter *importer,
|
||||
CORBA_Object listener,
|
||||
void *closure,
|
||||
CORBA_Environment *ev);
|
||||
typedef char *(* EvolutionImporterGetErrorFn) (EvolutionImporter *importer,
|
||||
void *closure);
|
||||
|
||||
typedef enum {
|
||||
EVOLUTION_IMPORTER_OK,
|
||||
EVOLUTION_IMPORTER_UNSUPPORTED_OPERATION,
|
||||
EVOLUTION_IMPORTER_INTERRUPTED,
|
||||
EVOLUTION_IMPORTER_BUSY,
|
||||
EVOLUTION_IMPORTER_NOT_READY,
|
||||
EVOLUTION_IMPORTER_UNKNOWN_DATA,
|
||||
EVOLUTION_IMPORTER_BAD_DATA,
|
||||
EVOLUTION_IMPORTER_BAD_FILE,
|
||||
EVOLUTION_IMPORTER_UNKNOWN_ERROR
|
||||
} EvolutionImporterResult;
|
||||
|
||||
struct _EvolutionImporter {
|
||||
BonoboObject parent;
|
||||
|
||||
EvolutionImporterPrivate *priv;
|
||||
};
|
||||
|
||||
struct _EvolutionImporterClass {
|
||||
BonoboObjectClass parent_class;
|
||||
|
||||
POA_GNOME_Evolution_Importer__epv epv;
|
||||
};
|
||||
|
||||
GType evolution_importer_get_type (void);
|
||||
|
||||
EvolutionImporter *evolution_importer_new (EvolutionImporterCreateControlFn create_control_fn,
|
||||
EvolutionImporterSupportFormatFn support_format_fn,
|
||||
EvolutionImporterLoadFileFn load_file_fn,
|
||||
EvolutionImporterProcessItemFn process_item_fn,
|
||||
EvolutionImporterGetErrorFn get_error_fn,
|
||||
void *closure);
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
||||
@ -1,197 +0,0 @@
|
||||
/*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2 of the License, or (at your option) version 3.
|
||||
*
|
||||
* 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
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with the program; if not, see <http://www.gnu.org/licenses/>
|
||||
*
|
||||
*
|
||||
* Authors:
|
||||
* Iain Holmes <iain@ximian.com>
|
||||
*
|
||||
* Copyright (C) 1999-2008 Novell, Inc. (www.novell.com)
|
||||
*
|
||||
*/
|
||||
|
||||
#ifdef HAVE_CONFIG_H
|
||||
#include <config.h>
|
||||
#endif
|
||||
|
||||
#include "evolution-intelligent-importer.h"
|
||||
|
||||
#include <bonobo/bonobo-object.h>
|
||||
|
||||
#include "GNOME_Evolution_Importer.h"
|
||||
|
||||
#define PARENT_TYPE BONOBO_OBJECT_TYPE
|
||||
static BonoboObjectClass *parent_class = NULL;
|
||||
|
||||
struct _EvolutionIntelligentImporterPrivate {
|
||||
EvolutionIntelligentImporterCanImportFn can_import_fn;
|
||||
EvolutionIntelligentImporterImportDataFn import_data_fn;
|
||||
|
||||
char *importername;
|
||||
char *message;
|
||||
void *closure;
|
||||
};
|
||||
|
||||
|
||||
static inline EvolutionIntelligentImporter *
|
||||
evolution_intelligent_importer_from_servant (PortableServer_Servant servant)
|
||||
{
|
||||
return EVOLUTION_INTELLIGENT_IMPORTER (bonobo_object_from_servant (servant));
|
||||
}
|
||||
|
||||
static CORBA_char *
|
||||
impl_GNOME_Evolution_IntelligentImporter__get_importername (PortableServer_Servant servant,
|
||||
CORBA_Environment *ev)
|
||||
{
|
||||
EvolutionIntelligentImporter *ii;
|
||||
|
||||
ii = evolution_intelligent_importer_from_servant (servant);
|
||||
|
||||
return CORBA_string_dup (ii->priv->importername ?
|
||||
ii->priv->importername : "");
|
||||
}
|
||||
|
||||
static CORBA_char *
|
||||
impl_GNOME_Evolution_IntelligentImporter__get_message (PortableServer_Servant servant,
|
||||
CORBA_Environment *ev)
|
||||
{
|
||||
EvolutionIntelligentImporter *ii;
|
||||
|
||||
ii = evolution_intelligent_importer_from_servant (servant);
|
||||
|
||||
return CORBA_string_dup (ii->priv->message ?
|
||||
ii->priv->message : "");
|
||||
}
|
||||
|
||||
static CORBA_boolean
|
||||
impl_GNOME_Evolution_IntelligentImporter_canImport (PortableServer_Servant servant,
|
||||
CORBA_Environment *ev)
|
||||
{
|
||||
EvolutionIntelligentImporter *ii;
|
||||
EvolutionIntelligentImporterPrivate *priv;
|
||||
|
||||
ii = evolution_intelligent_importer_from_servant (servant);
|
||||
priv = ii->priv;
|
||||
|
||||
if (priv->can_import_fn != NULL)
|
||||
return (priv->can_import_fn) (ii, priv->closure);
|
||||
else
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
static void
|
||||
impl_GNOME_Evolution_IntelligentImporter_importData (PortableServer_Servant servant,
|
||||
CORBA_Environment *ev)
|
||||
{
|
||||
EvolutionIntelligentImporter *ii;
|
||||
EvolutionIntelligentImporterPrivate *priv;
|
||||
|
||||
ii = evolution_intelligent_importer_from_servant (servant);
|
||||
priv = ii->priv;
|
||||
|
||||
if (priv->import_data_fn)
|
||||
(priv->import_data_fn) (ii, priv->closure);
|
||||
}
|
||||
|
||||
|
||||
static void
|
||||
finalise (GObject *object)
|
||||
{
|
||||
EvolutionIntelligentImporter *ii;
|
||||
|
||||
ii = EVOLUTION_INTELLIGENT_IMPORTER (object);
|
||||
|
||||
if (ii->priv == NULL)
|
||||
return;
|
||||
|
||||
g_free (ii->priv->importername);
|
||||
g_free (ii->priv);
|
||||
ii->priv = NULL;
|
||||
|
||||
G_OBJECT_CLASS (parent_class)->finalize (object);
|
||||
}
|
||||
|
||||
static void
|
||||
evolution_intelligent_importer_class_init (EvolutionIntelligentImporterClass *klass)
|
||||
{
|
||||
GObjectClass *object_class;
|
||||
POA_GNOME_Evolution_IntelligentImporter__epv *epv = &klass->epv;
|
||||
|
||||
object_class = G_OBJECT_CLASS (klass);
|
||||
object_class->finalize = finalise;
|
||||
|
||||
parent_class = g_type_class_ref(PARENT_TYPE);
|
||||
epv->_get_importername = impl_GNOME_Evolution_IntelligentImporter__get_importername;
|
||||
epv->_get_message = impl_GNOME_Evolution_IntelligentImporter__get_message;
|
||||
epv->canImport = impl_GNOME_Evolution_IntelligentImporter_canImport;
|
||||
epv->importData = impl_GNOME_Evolution_IntelligentImporter_importData;
|
||||
}
|
||||
|
||||
static void
|
||||
evolution_intelligent_importer_init (EvolutionIntelligentImporter *ii)
|
||||
{
|
||||
ii->priv = g_new0 (EvolutionIntelligentImporterPrivate, 1);
|
||||
}
|
||||
|
||||
|
||||
static void
|
||||
evolution_intelligent_importer_construct (EvolutionIntelligentImporter *ii,
|
||||
EvolutionIntelligentImporterCanImportFn can_import_fn,
|
||||
EvolutionIntelligentImporterImportDataFn import_data_fn,
|
||||
const char *importername,
|
||||
const char *message,
|
||||
void *closure)
|
||||
{
|
||||
g_return_if_fail (ii != NULL);
|
||||
ii->priv->importername = g_strdup (importername);
|
||||
ii->priv->message = g_strdup (message);
|
||||
|
||||
ii->priv->can_import_fn = can_import_fn;
|
||||
ii->priv->import_data_fn = import_data_fn;
|
||||
ii->priv->closure = closure;
|
||||
}
|
||||
|
||||
/**
|
||||
* evolution_intelligent_importer_new:
|
||||
* can_import_fn: The function that will be called to see if this importer can do
|
||||
* anything.
|
||||
* import_data_fn: The function that will be called when the importer should
|
||||
* import the data.
|
||||
* importername: The name of this importer.
|
||||
* message: The message that will be displayed when the importer can import.
|
||||
* closure: The data to be passed to @can_import_fn and @import_data_fn.
|
||||
*
|
||||
* Creates a new IntelligentImporter.
|
||||
*
|
||||
* Returns: A newly allocated EvolutionIntelligentImporter.
|
||||
*/
|
||||
EvolutionIntelligentImporter *
|
||||
evolution_intelligent_importer_new (EvolutionIntelligentImporterCanImportFn can_import_fn,
|
||||
EvolutionIntelligentImporterImportDataFn import_data_fn,
|
||||
const char *importername,
|
||||
const char *message,
|
||||
void *closure)
|
||||
{
|
||||
EvolutionIntelligentImporter *ii;
|
||||
|
||||
ii = g_object_new (evolution_intelligent_importer_get_type (), NULL);
|
||||
evolution_intelligent_importer_construct (ii, can_import_fn,
|
||||
import_data_fn, importername,
|
||||
message, closure);
|
||||
return ii;
|
||||
}
|
||||
|
||||
BONOBO_TYPE_FUNC_FULL (EvolutionIntelligentImporter,
|
||||
GNOME_Evolution_IntelligentImporter,
|
||||
PARENT_TYPE,
|
||||
evolution_intelligent_importer);
|
||||
@ -1,74 +0,0 @@
|
||||
/*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2 of the License, or (at your option) version 3.
|
||||
*
|
||||
* 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
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with the program; if not, see <http://www.gnu.org/licenses/>
|
||||
*
|
||||
*
|
||||
* Authors:
|
||||
* Iain Holmes <iain@ximian.com>
|
||||
*
|
||||
* Copyright (C) 1999-2008 Novell, Inc. (www.novell.com)
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef EVOLUTION_INTELLIGENT_IMPORTER_H
|
||||
#define EVOLUTION_INTELLIGENT_IMPORTER_H
|
||||
|
||||
#include <glib.h>
|
||||
#include <bonobo/bonobo-object.h>
|
||||
#include <importer/GNOME_Evolution_Importer.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#pragma }
|
||||
#endif /* __cplusplus */
|
||||
|
||||
#define EVOLUTION_TYPE_INTELLIGENT_IMPORTER (evolution_intelligent_importer_get_type ())
|
||||
#define EVOLUTION_INTELLIGENT_IMPORTER(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), EVOLUTION_TYPE_INTELLIGENT_IMPORTER, EvolutionIntelligentImporter))
|
||||
#define EVOLUTION_INTELLIGENT_IMPORTER_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), EVOLUTION_TYPE_INTELLIGENT_IMPORTER, EvolutionIntelligentImporterClass))
|
||||
#define EVOLUTION_IS_INTELLIGENT_IMPORTER(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), EVOLUTION_TYPE_INTELLIGENT_IMPORTER))
|
||||
#define EVOLUTION_IS_INTELLIGENT_IMPORTER_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((obj), EVOLUTION_TYPE_INTELLIGENT_IMPORTER))
|
||||
|
||||
typedef struct _EvolutionIntelligentImporter EvolutionIntelligentImporter;
|
||||
typedef struct _EvolutionIntelligentImporterPrivate EvolutionIntelligentImporterPrivate;
|
||||
typedef struct _EvolutionIntelligentImporterClass EvolutionIntelligentImporterClass;
|
||||
|
||||
typedef gboolean (* EvolutionIntelligentImporterCanImportFn) (EvolutionIntelligentImporter *ii,
|
||||
void *closure);
|
||||
typedef void (* EvolutionIntelligentImporterImportDataFn) (EvolutionIntelligentImporter *ii,
|
||||
void *closure);
|
||||
|
||||
struct _EvolutionIntelligentImporter {
|
||||
BonoboObject parent;
|
||||
|
||||
EvolutionIntelligentImporterPrivate *priv;
|
||||
};
|
||||
|
||||
struct _EvolutionIntelligentImporterClass {
|
||||
BonoboObjectClass parent_class;
|
||||
|
||||
POA_GNOME_Evolution_IntelligentImporter__epv epv;
|
||||
};
|
||||
|
||||
GType evolution_intelligent_importer_get_type (void);
|
||||
|
||||
EvolutionIntelligentImporter *evolution_intelligent_importer_new (EvolutionIntelligentImporterCanImportFn can_import_fn,
|
||||
EvolutionIntelligentImporterImportDataFn import_data_fn,
|
||||
const char *importername,
|
||||
const char *message,
|
||||
void *closure);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
||||
@ -1,124 +0,0 @@
|
||||
<?xml version="1.0" standalone="no"?> <!--*- mode: xml -*-->
|
||||
<!DOCTYPE glade-interface SYSTEM "http://glade.gnome.org/glade-2.0.dtd">
|
||||
|
||||
<glade-interface>
|
||||
<requires lib="gnome"/>
|
||||
|
||||
<widget class="GtkWindow" id="importwizard">
|
||||
<property name="title" translatable="yes">Evolution Import Assistant</property>
|
||||
<property name="type">GTK_WINDOW_TOPLEVEL</property>
|
||||
<property name="window_position">GTK_WIN_POS_CENTER_ON_PARENT</property>
|
||||
<property name="modal">False</property>
|
||||
<property name="resizable">True</property>
|
||||
<property name="destroy_with_parent">False</property>
|
||||
|
||||
<child>
|
||||
<widget class="GnomeDruid" id="druid1">
|
||||
<property name="border_width">4</property>
|
||||
<property name="visible">True</property>
|
||||
<property name="show_help">False</property>
|
||||
|
||||
<child>
|
||||
<widget class="GnomeDruidPageEdge" id="page0">
|
||||
<property name="visible">True</property>
|
||||
<property name="position">GNOME_EDGE_START</property>
|
||||
<property name="title" translatable="yes">Evolution Import Assistant</property>
|
||||
<property name="text" translatable="yes">Welcome to the Evolution Import Assistant.
|
||||
With this assistant you will be guided through the process of
|
||||
importing external files into Evolution.</property>
|
||||
</widget>
|
||||
</child>
|
||||
|
||||
<child>
|
||||
<widget class="GnomeDruidPageStandard" id="page1">
|
||||
<property name="visible">True</property>
|
||||
<property name="title" translatable="yes">Importer Type</property>
|
||||
|
||||
<child internal-child="vbox">
|
||||
<widget class="GtkVBox" id="druid-vbox2">
|
||||
<property name="border_width">16</property>
|
||||
<property name="visible">True</property>
|
||||
<property name="homogeneous">False</property>
|
||||
<property name="spacing">0</property>
|
||||
|
||||
<child>
|
||||
<placeholder/>
|
||||
</child>
|
||||
</widget>
|
||||
</child>
|
||||
</widget>
|
||||
</child>
|
||||
|
||||
<child>
|
||||
<widget class="GnomeDruidPageStandard" id="page2-file">
|
||||
<property name="visible">True</property>
|
||||
<property name="title" translatable="yes">Select a File</property>
|
||||
|
||||
<child internal-child="vbox">
|
||||
<widget class="GtkVBox" id="druid-vbox1">
|
||||
<property name="border_width">16</property>
|
||||
<property name="visible">True</property>
|
||||
<property name="homogeneous">False</property>
|
||||
<property name="spacing">0</property>
|
||||
|
||||
<child>
|
||||
<placeholder/>
|
||||
</child>
|
||||
</widget>
|
||||
</child>
|
||||
</widget>
|
||||
</child>
|
||||
|
||||
<child>
|
||||
<widget class="GnomeDruidPageStandard" id="page3-file">
|
||||
<property name="visible">True</property>
|
||||
<property name="title" translatable="yes">Import Location</property>
|
||||
|
||||
<child internal-child="vbox">
|
||||
<widget class="GtkVBox" id="druid-vbox3">
|
||||
<property name="border_width">16</property>
|
||||
<property name="visible">True</property>
|
||||
<property name="homogeneous">False</property>
|
||||
<property name="spacing">0</property>
|
||||
|
||||
<child>
|
||||
<placeholder/>
|
||||
</child>
|
||||
</widget>
|
||||
</child>
|
||||
</widget>
|
||||
</child>
|
||||
|
||||
<child>
|
||||
<widget class="GnomeDruidPageStandard" id="page2-intelligent">
|
||||
<property name="visible">True</property>
|
||||
<property name="title" translatable="yes">Select Information to Import</property>
|
||||
|
||||
<child internal-child="vbox">
|
||||
<widget class="GtkVBox" id="druid-vbox3">
|
||||
<property name="border_width">16</property>
|
||||
<property name="visible">True</property>
|
||||
<property name="homogeneous">False</property>
|
||||
<property name="spacing">0</property>
|
||||
|
||||
<child>
|
||||
<placeholder/>
|
||||
</child>
|
||||
</widget>
|
||||
</child>
|
||||
</widget>
|
||||
</child>
|
||||
|
||||
<child>
|
||||
<widget class="GnomeDruidPageEdge" id="page4">
|
||||
<property name="visible">True</property>
|
||||
<property name="position">GNOME_EDGE_FINISH</property>
|
||||
<property name="title" translatable="yes">Import File</property>
|
||||
<property name="text" translatable="yes">Click "Import" to begin importing the file into Evolution. </property>
|
||||
</widget>
|
||||
</child>
|
||||
</widget>
|
||||
</child>
|
||||
</widget>
|
||||
|
||||
</glade-interface>
|
||||
@ -1,469 +0,0 @@
|
||||
/*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2 of the License, or (at your option) version 3.
|
||||
*
|
||||
* 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
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with the program; if not, see <http://www.gnu.org/licenses/>
|
||||
*
|
||||
*
|
||||
* Authors:
|
||||
* Iain Holmes <iain@ximian.com>
|
||||
*
|
||||
* Copyright (C) 1999-2008 Novell, Inc. (www.novell.com)
|
||||
*
|
||||
*/
|
||||
|
||||
#ifdef HAVE_CONFIG_H
|
||||
#include <config.h>
|
||||
#endif
|
||||
|
||||
#include "intelligent.h"
|
||||
|
||||
#include <gtk/gtk.h>
|
||||
|
||||
#include <libgnome/gnome-config.h>
|
||||
#include <glib/gi18n.h>
|
||||
|
||||
#include <bonobo/bonobo-object.h>
|
||||
#include <bonobo/bonobo-widget.h>
|
||||
|
||||
#include "intelligent.h"
|
||||
#include "GNOME_Evolution_Importer.h"
|
||||
|
||||
/* Prototypes */
|
||||
|
||||
void intelligent_importer_init (void);
|
||||
|
||||
/* End prototypes */
|
||||
|
||||
typedef struct {
|
||||
CORBA_Object object;
|
||||
Bonobo_Control control;
|
||||
GtkWidget *widget;
|
||||
|
||||
char *name;
|
||||
char *blurb;
|
||||
char *iid;
|
||||
} IntelligentImporterData;
|
||||
|
||||
typedef struct {
|
||||
GtkWidget *dialog;
|
||||
GtkWidget *placeholder;
|
||||
GtkWidget *clist;
|
||||
BonoboWidget *current;
|
||||
|
||||
GList *importers;
|
||||
|
||||
int running;
|
||||
} IntelligentImporterDialog;
|
||||
|
||||
typedef struct {
|
||||
CORBA_Object importer;
|
||||
char *iid;
|
||||
} SelectedImporterData;
|
||||
|
||||
static void
|
||||
free_importer_dialog (IntelligentImporterDialog *d)
|
||||
{
|
||||
GList *l;
|
||||
|
||||
for (l = d->importers; l; l = l->next) {
|
||||
CORBA_Environment ev;
|
||||
IntelligentImporterData *data;
|
||||
|
||||
data = l->data;
|
||||
|
||||
CORBA_exception_init (&ev);
|
||||
if (data->object != CORBA_OBJECT_NIL)
|
||||
bonobo_object_release_unref (data->object, &ev);
|
||||
|
||||
g_free (data->iid);
|
||||
g_free (data->name);
|
||||
g_free (data->blurb);
|
||||
g_free (data);
|
||||
}
|
||||
|
||||
g_list_free (d->importers);
|
||||
gtk_widget_destroy (d->dialog);
|
||||
g_free (d);
|
||||
}
|
||||
|
||||
static void
|
||||
start_importers (GList *selected)
|
||||
{
|
||||
CORBA_Environment ev;
|
||||
|
||||
CORBA_exception_init (&ev);
|
||||
for (; selected; selected = selected->next) {
|
||||
SelectedImporterData *selection = selected->data;
|
||||
|
||||
GNOME_Evolution_IntelligentImporter_importData (selection->importer, &ev);
|
||||
if (ev._major != CORBA_NO_EXCEPTION) {
|
||||
g_warning ("Error importing %s\n%s", selection->iid,
|
||||
CORBA_exception_id (&ev));
|
||||
}
|
||||
}
|
||||
CORBA_exception_free (&ev);
|
||||
}
|
||||
|
||||
static GList *
|
||||
get_intelligent_importers (void)
|
||||
{
|
||||
Bonobo_ServerInfoList *info_list;
|
||||
GList *iids_ret = NULL;
|
||||
CORBA_Environment ev;
|
||||
int i;
|
||||
|
||||
CORBA_exception_init (&ev);
|
||||
info_list = bonobo_activation_query ("repo_ids.has ('IDL:GNOME/Evolution/IntelligentImporter:" BASE_VERSION "')", NULL, &ev);
|
||||
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;
|
||||
}
|
||||
|
||||
static void
|
||||
select_row_cb (GtkCList *clist,
|
||||
int row,
|
||||
int column,
|
||||
GdkEvent *ev,
|
||||
IntelligentImporterDialog *d)
|
||||
{
|
||||
gtk_notebook_set_current_page (GTK_NOTEBOOK (d->placeholder), row);
|
||||
}
|
||||
|
||||
static void
|
||||
unselect_row_cb (GtkCList *clist,
|
||||
int row,
|
||||
int column,
|
||||
GdkEvent *ev,
|
||||
IntelligentImporterDialog *d)
|
||||
{
|
||||
gtk_notebook_set_current_page (GTK_NOTEBOOK (d->placeholder), d->running);
|
||||
}
|
||||
|
||||
static IntelligentImporterDialog *
|
||||
create_gui (GList *importers)
|
||||
{
|
||||
GtkWidget *dialog, *clist, *sw, *label;
|
||||
GtkWidget *hbox, *vbox, *dummy;
|
||||
IntelligentImporterDialog *d;
|
||||
GList *l;
|
||||
int running = 0;
|
||||
|
||||
d = g_new (IntelligentImporterDialog, 1);
|
||||
d->dialog = dialog = gtk_dialog_new();
|
||||
gtk_dialog_set_has_separator ((GtkDialog *) dialog, FALSE);
|
||||
gtk_container_set_border_width ((GtkContainer *) ((GtkDialog *)dialog)->vbox, 0);
|
||||
gtk_container_set_border_width ((GtkContainer *) ((GtkDialog *)dialog)->action_area, 12);
|
||||
|
||||
gtk_window_set_title((GtkWindow *)dialog, _("Importers"));
|
||||
dummy = gtk_button_new_from_stock(GTK_STOCK_CONVERT);
|
||||
gtk_button_set_label((GtkButton *)dummy, _("Import"));
|
||||
gtk_dialog_add_action_widget((GtkDialog *)dialog, dummy, GTK_RESPONSE_ACCEPT);
|
||||
|
||||
dummy = gtk_button_new_from_stock(GTK_STOCK_NO);
|
||||
gtk_button_set_label((GtkButton *)dummy, _("Do not import"));
|
||||
gtk_dialog_add_action_widget((GtkDialog *)dialog, dummy, GTK_RESPONSE_REJECT);
|
||||
|
||||
dummy = gtk_button_new_from_stock(GTK_STOCK_CANCEL);
|
||||
gtk_button_set_label((GtkButton *)dummy, _("Do not ask me again"));
|
||||
gtk_dialog_add_action_widget((GtkDialog *)dialog, dummy, GTK_RESPONSE_CANCEL);
|
||||
d->importers = NULL;
|
||||
d->current = NULL;
|
||||
|
||||
d->clist = clist = gtk_clist_new (1);
|
||||
gtk_clist_set_selection_mode (GTK_CLIST (d->clist), GTK_SELECTION_MULTIPLE);
|
||||
|
||||
label = gtk_label_new (_("Evolution can import data from the following files:"));
|
||||
gtk_misc_set_alignment(GTK_MISC(label), 0, .5);
|
||||
gtk_box_pack_start (GTK_BOX (GTK_DIALOG (dialog)->vbox), label,
|
||||
TRUE, TRUE, 0);
|
||||
|
||||
hbox = gtk_hbox_new (FALSE, 2);
|
||||
gtk_container_set_border_width (GTK_CONTAINER (hbox), 2);
|
||||
|
||||
gtk_box_pack_start (GTK_BOX (GTK_DIALOG (dialog)->vbox), hbox,
|
||||
TRUE, TRUE, 0);
|
||||
|
||||
sw = gtk_scrolled_window_new (NULL, NULL);
|
||||
gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW(sw),
|
||||
GTK_POLICY_AUTOMATIC,
|
||||
GTK_POLICY_AUTOMATIC);
|
||||
gtk_scrolled_window_set_shadow_type (GTK_SCROLLED_WINDOW (sw), GTK_SHADOW_IN);
|
||||
gtk_widget_set_size_request (sw, 300, 150);
|
||||
gtk_container_add (GTK_CONTAINER (sw), clist);
|
||||
gtk_box_pack_start (GTK_BOX (hbox), sw, TRUE, TRUE, 0);
|
||||
|
||||
vbox = gtk_vbox_new (FALSE, 0);
|
||||
gtk_container_set_border_width (GTK_CONTAINER (vbox), 2);
|
||||
gtk_box_pack_start (GTK_BOX (hbox), vbox, TRUE, TRUE, 0);
|
||||
|
||||
d->placeholder = gtk_notebook_new ();
|
||||
gtk_notebook_set_show_tabs (GTK_NOTEBOOK (d->placeholder), FALSE);
|
||||
gtk_box_pack_start (GTK_BOX (vbox), d->placeholder, TRUE, TRUE, 0);
|
||||
|
||||
for (l = importers; l; l = l->next) {
|
||||
IntelligentImporterData *data;
|
||||
CORBA_Environment ev;
|
||||
gboolean dontaskagain, can_run;
|
||||
char *text[1], *prefix;
|
||||
|
||||
/* Check if we want to show this one again */
|
||||
prefix = g_strdup_printf ("=%s/evolution/config/Shell=/intelligent-importers/", g_get_home_dir ());
|
||||
gnome_config_push_prefix (prefix);
|
||||
g_free (prefix);
|
||||
|
||||
dontaskagain = gnome_config_get_bool (l->data);
|
||||
gnome_config_pop_prefix ();
|
||||
|
||||
if (dontaskagain)
|
||||
continue;
|
||||
|
||||
data = g_new0 (IntelligentImporterData, 1);
|
||||
data->iid = g_strdup (l->data);
|
||||
|
||||
CORBA_exception_init (&ev);
|
||||
data->object = bonobo_activation_activate_from_id ((char *) data->iid, 0,
|
||||
NULL, &ev);
|
||||
if (ev._major != CORBA_NO_EXCEPTION) {
|
||||
g_warning ("Could not start %s: %s", data->iid,
|
||||
CORBA_exception_id (&ev));
|
||||
CORBA_exception_free (&ev);
|
||||
|
||||
/* Clean up the IntelligentImporterData */
|
||||
g_free (data->iid);
|
||||
g_free (data);
|
||||
continue;
|
||||
}
|
||||
|
||||
CORBA_exception_free (&ev);
|
||||
if (data->object == CORBA_OBJECT_NIL) {
|
||||
g_warning ("Could not activate_component %s", data->iid);
|
||||
g_free (data->iid);
|
||||
g_free (data);
|
||||
continue;
|
||||
}
|
||||
|
||||
CORBA_exception_init (&ev);
|
||||
can_run = GNOME_Evolution_IntelligentImporter_canImport (data->object,
|
||||
&ev);
|
||||
if (ev._major != CORBA_NO_EXCEPTION) {
|
||||
g_warning ("Could not get canImport(%s): %s",
|
||||
data->iid, CORBA_exception_id (&ev));
|
||||
bonobo_object_release_unref (data->object, &ev);
|
||||
CORBA_exception_free (&ev);
|
||||
g_free (data->iid);
|
||||
g_free (data);
|
||||
continue;
|
||||
}
|
||||
CORBA_exception_free (&ev);
|
||||
|
||||
if (can_run == FALSE) {
|
||||
CORBA_exception_init (&ev);
|
||||
bonobo_object_release_unref (data->object, &ev);
|
||||
CORBA_exception_free (&ev);
|
||||
g_free (data->iid);
|
||||
g_free (data);
|
||||
continue;
|
||||
}
|
||||
|
||||
running++;
|
||||
|
||||
data->name = g_strdup (GNOME_Evolution_IntelligentImporter__get_importername (data->object, &ev));
|
||||
if (ev._major != CORBA_NO_EXCEPTION) {
|
||||
g_warning ("Could not get name(%s): %s",
|
||||
data->iid, CORBA_exception_id (&ev));
|
||||
bonobo_object_release_unref (data->object, &ev);
|
||||
CORBA_exception_free (&ev);
|
||||
g_free (data->iid);
|
||||
g_free (data);
|
||||
continue;
|
||||
}
|
||||
|
||||
data->blurb = g_strdup (GNOME_Evolution_IntelligentImporter__get_message (data->object, &ev));
|
||||
if (ev._major != CORBA_NO_EXCEPTION) {
|
||||
g_warning ("Could not get message(%s): %s",
|
||||
data->iid, CORBA_exception_id (&ev));
|
||||
bonobo_object_release_unref (data->object, &ev);
|
||||
CORBA_exception_free (&ev);
|
||||
g_free (data->iid);
|
||||
g_free (data->name);
|
||||
g_free (data);
|
||||
continue;
|
||||
}
|
||||
|
||||
data->control = Bonobo_Unknown_queryInterface (data->object,
|
||||
"IDL:Bonobo/Control:1.0", &ev);
|
||||
if (ev._major != CORBA_NO_EXCEPTION) {
|
||||
g_warning ("Could not QI for Bonobo/Control:1.0 %s:%s",
|
||||
data->iid, CORBA_exception_id (&ev));
|
||||
bonobo_object_release_unref (data->object, &ev);
|
||||
CORBA_exception_free (&ev);
|
||||
g_free (data->iid);
|
||||
g_free (data->name);
|
||||
g_free (data->blurb);
|
||||
continue;
|
||||
}
|
||||
if (data->control != CORBA_OBJECT_NIL) {
|
||||
data->widget = bonobo_widget_new_control_from_objref (data->control, CORBA_OBJECT_NIL);
|
||||
/* Ref this widget so even if we remove it from the
|
||||
containers it will always have an extra ref. */
|
||||
gtk_widget_show (data->widget);
|
||||
g_object_ref (data->widget);
|
||||
} else {
|
||||
data->widget = gtk_label_new ("");
|
||||
}
|
||||
|
||||
CORBA_exception_free (&ev);
|
||||
|
||||
d->importers = g_list_prepend (d->importers, data);
|
||||
gtk_notebook_prepend_page (GTK_NOTEBOOK (d->placeholder),
|
||||
data->widget, NULL);
|
||||
text[0] = data->name;
|
||||
gtk_clist_prepend (GTK_CLIST (clist), text);
|
||||
}
|
||||
|
||||
d->running = running;
|
||||
dummy = gtk_drawing_area_new ();
|
||||
gtk_widget_show (dummy);
|
||||
gtk_notebook_append_page (GTK_NOTEBOOK (d->placeholder),
|
||||
dummy, NULL);
|
||||
/* Set the start to the blank page */
|
||||
gtk_notebook_set_current_page (GTK_NOTEBOOK (d->placeholder), running);
|
||||
|
||||
g_signal_connect((clist), "select-row",
|
||||
G_CALLBACK (select_row_cb), d);
|
||||
g_signal_connect((clist), "unselect-row",
|
||||
G_CALLBACK (unselect_row_cb), d);
|
||||
|
||||
gtk_widget_show_all (GTK_DIALOG (dialog)->vbox);
|
||||
return d;
|
||||
}
|
||||
|
||||
void
|
||||
intelligent_importer_init (void)
|
||||
{
|
||||
GList *importers, *l, *selected = NULL;
|
||||
IntelligentImporterDialog *d;
|
||||
char *prefix;
|
||||
gboolean dontaskagain;
|
||||
int resp;
|
||||
|
||||
prefix = g_strdup_printf ("=%s/evolution/config/Shell=/intelligent-importers/", g_get_home_dir());
|
||||
gnome_config_push_prefix (prefix);
|
||||
g_free (prefix);
|
||||
|
||||
dontaskagain = gnome_config_get_bool ("Dontaskagain=False");
|
||||
gnome_config_pop_prefix ();
|
||||
|
||||
if (dontaskagain) {
|
||||
return;
|
||||
}
|
||||
|
||||
importers = get_intelligent_importers ();
|
||||
if (importers == NULL)
|
||||
return; /* No intelligent importers. Easy :) */
|
||||
|
||||
d = create_gui (importers);
|
||||
if (d->running == 0) {
|
||||
free_importer_dialog (d);
|
||||
return; /* No runnable intelligent importers. */
|
||||
}
|
||||
|
||||
resp = gtk_dialog_run((GtkDialog *)d->dialog);
|
||||
gtk_widget_destroy(d->dialog);
|
||||
switch (resp) {
|
||||
case GTK_RESPONSE_ACCEPT:
|
||||
/* Make a list of the importers */
|
||||
|
||||
/* FIXME: Sort this list and don't do it a slow way */
|
||||
for (l = GTK_CLIST (d->clist)->selection; l; l = l->next) {
|
||||
IntelligentImporterData *data;
|
||||
SelectedImporterData *new_data;
|
||||
CORBA_Environment ev;
|
||||
char *iid;
|
||||
|
||||
data = g_list_nth_data (d->importers, GPOINTER_TO_INT (l->data));
|
||||
iid = g_strdup (data->iid);
|
||||
|
||||
new_data = g_new (SelectedImporterData, 1);
|
||||
new_data->iid = iid;
|
||||
|
||||
/* Reference the remote object, and duplicate the
|
||||
local one. */
|
||||
CORBA_exception_init (&ev);
|
||||
new_data->importer = bonobo_object_dup_ref (data->object, &ev);
|
||||
if (ev._major != CORBA_NO_EXCEPTION) {
|
||||
g_warning ("Error duplicating %s\n%s", iid,
|
||||
CORBA_exception_id (&ev));
|
||||
g_free (iid);
|
||||
CORBA_exception_free (&ev);
|
||||
g_free (new_data);
|
||||
continue;
|
||||
}
|
||||
CORBA_exception_free (&ev);
|
||||
|
||||
selected = g_list_prepend (selected, new_data);
|
||||
}
|
||||
|
||||
/* Now destroy all the importers, as we've kept references to
|
||||
the ones we need */
|
||||
free_importer_dialog (d);
|
||||
|
||||
if (selected != NULL) {
|
||||
/* Restart the selected ones */
|
||||
start_importers (selected);
|
||||
|
||||
/* Free the selected list */
|
||||
for (l = selected; l; l = l->next) {
|
||||
CORBA_Environment ev;
|
||||
SelectedImporterData *selection = l->data;
|
||||
|
||||
CORBA_exception_init (&ev);
|
||||
bonobo_object_release_unref (selection->importer, &ev);
|
||||
CORBA_exception_free (&ev);
|
||||
|
||||
g_free (selection->iid);
|
||||
g_free (selection);
|
||||
}
|
||||
g_list_free (selected);
|
||||
}
|
||||
|
||||
break;
|
||||
|
||||
case GTK_RESPONSE_CANCEL: /* Dont ask again */
|
||||
prefix = g_strdup_printf ("=%s/evolution/config/Shell=/intelligent-importers/", g_get_home_dir());
|
||||
gnome_config_push_prefix (prefix);
|
||||
g_free (prefix);
|
||||
|
||||
gnome_config_set_bool ("Dontaskagain", TRUE);
|
||||
gnome_config_pop_prefix ();
|
||||
|
||||
gnome_config_sync ();
|
||||
gnome_config_drop_all ();
|
||||
g_print ("Not asking again");
|
||||
free_importer_dialog (d);
|
||||
break;
|
||||
|
||||
default:
|
||||
case GTK_RESPONSE_REJECT: /* No button */
|
||||
free_importer_dialog (d);
|
||||
break;
|
||||
}
|
||||
|
||||
g_list_free (importers);
|
||||
}
|
||||
@ -1,28 +0,0 @@
|
||||
/*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2 of the License, or (at your option) version 3.
|
||||
*
|
||||
* 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
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with the program; if not, see <http://www.gnu.org/licenses/>
|
||||
*
|
||||
*
|
||||
* Authors:
|
||||
* Kjartan Maraas <kmaraas@gnome.org>
|
||||
*
|
||||
* Copyright (C) 1999-2008 Novell, Inc. (www.novell.com)
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef __INTELLIGENT_H__
|
||||
#define __INTELLIGENT_H__
|
||||
|
||||
void intelligent_importer_init (void);
|
||||
|
||||
#endif
|
||||
Reference in New Issue
Block a user