[evolution/new-importer: 1/3] Prototype asynchronous EImportHandler API.
- From: Matthew Barnes <mbarnes src gnome org>
- To: svn-commits-list gnome org
- Cc:
- Subject: [evolution/new-importer: 1/3] Prototype asynchronous EImportHandler API.
- Date: Wed, 28 Oct 2009 01:52:52 +0000 (UTC)
commit bd5fc3bd53f363b55a3dac20db117212045c9d74
Author: Matthew Barnes <mbarnes redhat com>
Date: Fri Sep 25 09:53:58 2009 -0400
Prototype asynchronous EImportHandler API.
e-util/Makefile.am | 2 +
e-util/e-import-handler.c | 174 +++++++++++++++++++++++++++++++++++++++++++++
e-util/e-import-handler.h | 115 +++++++++++++++++++++++++++++
3 files changed, 291 insertions(+), 0 deletions(-)
---
diff --git a/e-util/Makefile.am b/e-util/Makefile.am
index a869cf1..a6e5656 100644
--- a/e-util/Makefile.am
+++ b/e-util/Makefile.am
@@ -27,6 +27,7 @@ eutilinclude_HEADERS = \
e-html-utils.h \
e-icon-factory.h \
e-import.h \
+ e-import-handler.h \
e-logger.h \
e-marshal.h \
e-mktemp.h \
@@ -97,6 +98,7 @@ libeutil_la_SOURCES = \
e-html-utils.c \
e-icon-factory.c \
e-import.c \
+ e-import-handler.c \
e-logger.c \
e-marshal.c \
e-mktemp.c \
diff --git a/e-util/e-import-handler.c b/e-util/e-import-handler.c
new file mode 100644
index 0000000..c5d6c48
--- /dev/null
+++ b/e-util/e-import-handler.c
@@ -0,0 +1,174 @@
+/*
+ * e-import-handler.c
+ *
+ * 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/>
+ *
+ *
+ * Copyright (C) 1999-2008 Novell, Inc. (www.novell.com)
+ *
+ */
+
+#include "e-import-handler.h"
+
+#define E_IMPORT_HANDLER_GET_PRIVATE(obj) \
+ (G_TYPE_INSTANCE_GET_PRIVATE \
+ ((obj), E_TYPE_IMPORT_HANDLER, EImportHandlerPrivate))
+
+struct _EImportHandlerPrivate {
+ gint placeholder;
+};
+
+static gpointer parent_class;
+
+static void
+import_handler_constructed (GObject *object)
+{
+ /* This allows subclasses to chain up safely since GObject
+ * does not implement this method, and we might want to do
+ * something here in the future. */
+}
+
+static void
+import_handler_class_init (EImportHandlerClass *class)
+{
+ GObjectClass *object_class;
+
+ parent_class = g_type_class_peek_parent (class);
+ g_type_class_add_private (class, sizeof (EImportHandlerPrivate));
+
+ object_class = G_OBJECT_CLASS (class);
+ object_class->constructed = import_handler_constructed;
+}
+
+static void
+import_handler_init (EImportHandler *handler)
+{
+ handler->priv = E_IMPORT_HANDLER_GET_PRIVATE (handler);
+}
+
+GType
+e_import_handler_get_type (void)
+{
+ static GType type = 0;
+
+ if (G_UNLIKELY (type == 0)) {
+ static const GTypeInfo type_info = {
+ sizeof (EImportHandlerClass),
+ (GBaseInitFunc) NULL,
+ (GBaseFinalizeFunc) NULL,
+ (GClassInitFunc) import_handler_class_init,
+ (GClassFinalizeFunc) NULL,
+ NULL, /* class_data */
+ sizeof (EImportHandler),
+ 0, /* n_preallocs */
+ (GInstanceInitFunc) import_handler_init,
+ NULL /* value_table */
+ };
+
+ type = g_type_register_static (
+ G_TYPE_OBJECT, "EImportHandler",
+ &type_info, G_TYPE_FLAG_ABSTRACT);
+ };
+
+ return type;
+}
+
+GtkWidget *
+e_import_handler_get_destination_chooser (EImportHandler *handler)
+{
+ EImportHandlerClass *class;
+
+ g_return_val_if_fail (E_IS_IMPORT_HANDLER (handler), NULL);
+
+ class = E_IMPORT_HANDLER_GET_CLASS (handler);
+ g_return_val_if_fail (class->get_destination_chooser != NULL, NULL);
+
+ return class->get_destination_chooser (handler);
+}
+
+void
+e_import_handler_import_async (EImportHandler *handler,
+ GFile *source,
+ GCancellable *cancellable,
+ GFileProgressCallback progress_callback,
+ gpointer progress_callback_data,
+ GAsyncReadyCallback callback,
+ gpointer user_data)
+{
+ EImportHandlerClass *class;
+
+ g_return_if_fail (E_IS_IMPORT_HANDLER (handler));
+ g_return_if_fail (G_IS_FILE (source));
+ g_return_if_fail (callback != NULL);
+
+ class = E_IMPORT_HANDLER_GET_CLASS (handler);
+ g_return_if_fail (class->import_async != NULL);
+
+ class->import_async (
+ handler, source, cancellable,
+ progress_callback, progress_callback_data,
+ callback, user_data);
+}
+
+gboolean
+e_import_handler_import_finish (EImportHandler *handler,
+ GAsyncResult *result,
+ GError **error)
+{
+ EImportHandlerClass *class;
+
+ g_return_val_if_fail (E_IS_IMPORT_HANDLER (handler), FALSE);
+ g_return_val_if_fail (G_IS_ASYNC_RESULT (result), FALSE);
+
+ class = E_IMPORT_HANDLER_GET_CLASS (handler);
+ g_return_val_if_fail (class->import_finish != NULL, FALSE);
+
+ return class->import_finish (handler, result, error);
+}
+
+void
+e_import_handler_inspect_async (EImportHandler *handler,
+ GFile *source,
+ GCancellable *cancellable,
+ GAsyncReadyCallback callback,
+ gpointer user_data)
+{
+ EImportHandlerClass *class;
+
+ g_return_if_fail (E_IS_IMPORT_HANDLER (handler));
+ g_return_if_fail (G_IS_FILE (source));
+ g_return_if_fail (callback != NULL);
+
+ class = E_IMPORT_HANDLER_GET_CLASS (handler);
+ g_return_if_fail (class->inspect_async != NULL);
+
+ class->inspect_async (
+ handler, source, cancellable, callback, user_data);
+}
+
+gboolean
+e_import_handler_inspect_finish (EImportHandler *handler,
+ GAsyncResult *result,
+ GError **error)
+{
+ EImportHandlerClass *class;
+
+ g_return_val_if_fail (E_IS_IMPORT_HANDLER (handler), FALSE);
+ g_return_val_if_fail (G_IS_ASYNC_RESULT (result), FALSE);
+
+ class = E_IMPORT_HANDLER_GET_CLASS (handler);
+ g_return_val_if_fail (class->inspect_finish != NULL, FALSE);
+
+ return class->inspect_finish (handler, result, error);
+}
diff --git a/e-util/e-import-handler.h b/e-util/e-import-handler.h
new file mode 100644
index 0000000..52b349b
--- /dev/null
+++ b/e-util/e-import-handler.h
@@ -0,0 +1,115 @@
+/*
+ * e-import-handler.h
+ *
+ * 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/>
+ *
+ *
+ * Copyright (C) 1999-2008 Novell, Inc. (www.novell.com)
+ *
+ */
+
+#ifndef E_IMPORT_HANDLER_H
+#define E_IMPORT_HANDLER_H
+
+#include <gtk/gtk.h>
+
+/* Standard GObject macros */
+#define E_TYPE_IMPORT_HANDLER \
+ (e_import_handler_get_type ())
+#define E_IMPORT_HANDLER(obj) \
+ (G_TYPE_CHECK_INSTANCE_CAST \
+ ((obj), E_TYPE_IMPORT_HANDLER, EImportHandler))
+#define E_IMPORT_HANDLER_CLASS(cls) \
+ (G_TYPE_CHECK_CLASS_CAST \
+ ((cls), E_TYPE_IMPORT_HANDLER, EImportHandlerClass))
+#define E_IS_IMPORT_HANDLER(obj) \
+ (G_TYPE_CHECK_INSTANCE_TYPE \
+ ((obj), E_TYPE_IMPORT_HANDLER))
+#define E_IS_IMPORT_HANDLER_CLASS(cls) \
+ (G_TYPE_CHECK_CLASS_TYPE \
+ ((cls), E_TYPE_IMPORT_HANDLER))
+#define E_IMPORT_HANDLER_GET_CLASS(obj) \
+ (G_TYPE_INSTANCE_GET_CLASS \
+ ((obj), E_TYPE_IMPORT_HANDLER, EImportHandlerClass))
+
+G_BEGIN_DECLS
+
+typedef struct _EImportHandler EImportHandler;
+typedef struct _EImportHandlerClass EImportHandlerClass;
+typedef struct _EImportHandlerPrivate EImportHandlerPrivate;
+
+typedef enum {
+ E_IMPORT_PROGRAM_DATA = 1 << 0,
+ E_IMPORT_SINGLE_FILE = 1 << 1
+} EImportHandlerFlags;
+
+struct _EImportHandler {
+ GObject parent;
+ EImportHandlerPrivate *priv;
+};
+
+struct _EImportHandlerClass {
+ GObjectClass parent_class;
+
+ const gchar *name;
+ const gchar *description;
+ EImportHandlerFlags flags;
+
+ GtkWidget * (*get_destination_chooser)
+ (EImportHandler *handler);
+ void (*import_async) (EImportHandler *handler,
+ GFile *source,
+ GCancellable *cancellable,
+ GFileProgressCallback progress_callback,
+ gpointer progress_callback_data,
+ GAsyncReadyCallback callback,
+ gpointer user_data);
+ gboolean (*import_finish) (EImportHandler *handler,
+ GAsyncResult *result,
+ GError **error);
+ void (*inspect_async) (EImportHandler *handler,
+ GFile *source,
+ GCancellable *cancellable,
+ GAsyncReadyCallback callback,
+ gpointer user_data);
+ gboolean (*inspect_finish) (EImportHandler *handler,
+ GAsyncResult *result,
+ GError **error);
+};
+
+GType e_import_handler_get_type (void);
+GtkWidget * e_import_handler_get_destination_chooser
+ (EImportHandler *handler);
+void e_import_handler_import_async (EImportHandler *handler,
+ GFile *source,
+ GCancellable *cancellable,
+ GFileProgressCallback progress_callback,
+ gpointer progress_callback_data,
+ GAsyncReadyCallback callback,
+ gpointer user_data);
+gboolean e_import_handler_import_finish (EImportHandler *handler,
+ GAsyncResult *result,
+ GError **error);
+void e_import_handler_inspect_async (EImportHandler *handler,
+ GFile *source,
+ GCancellable *cancellable,
+ GAsyncReadyCallback callback,
+ gpointer user_data);
+gboolean e_import_handler_inspect_finish (EImportHandler *handler,
+ GAsyncResult *result,
+ GError **error);
+
+G_END_DECLS
+
+#endif /* E_IMPORT_HANDLER_H */
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]