evolution-data-server r9478 - in trunk/calendar: . libedata-cal
- From: pchen svn gnome org
- To: svn-commits-list gnome org
- Subject: evolution-data-server r9478 - in trunk/calendar: . libedata-cal
- Date: Thu, 4 Sep 2008 10:28:49 +0000 (UTC)
Author: pchen
Date: Thu Sep 4 10:28:49 2008
New Revision: 9478
URL: http://svn.gnome.org/viewvc/evolution-data-server?rev=9478&view=rev
Log:
2008-09-04 Chenthill Palanisamy <pchenthill novell com>
* libedata-cal/Makefile.am:
* libedata-cal/e-cal-backend.c
(e_cal_backend_notify_objects_added),
(e_cal_backend_notify_objects_removed),
(e_cal_backend_notify_objects_modified): New functions added.
* libedata-cal/e-cal-backend.h:
* libedata-cal/e-data-cal-factory.c (get_backend_factory),
(impl_CalFactory_getCal), (e_data_cal_factory_register_backend),
(e_data_cal_factory_register_backends):
* libedata-cal/e-data-cal-factory.h: Added LoaderFactory which
* is a subclass of BackendFactory.
Added:
trunk/calendar/libedata-cal/e-cal-backend-loader-factory.c
trunk/calendar/libedata-cal/e-cal-backend-loader-factory.h
Modified:
trunk/calendar/ChangeLog
trunk/calendar/libedata-cal/Makefile.am
trunk/calendar/libedata-cal/e-cal-backend.c
trunk/calendar/libedata-cal/e-cal-backend.h
trunk/calendar/libedata-cal/e-data-cal-factory.c
trunk/calendar/libedata-cal/e-data-cal-factory.h
Modified: trunk/calendar/libedata-cal/Makefile.am
==============================================================================
--- trunk/calendar/libedata-cal/Makefile.am (original)
+++ trunk/calendar/libedata-cal/Makefile.am Thu Sep 4 10:28:49 2008
@@ -38,6 +38,7 @@
e-cal-backend.c \
e-cal-backend-cache.c \
e-cal-backend-factory.c \
+ e-cal-backend-loader-factory.c \
e-cal-backend-sexp.c \
e-cal-backend-sync.c \
e-cal-backend-util.c \
@@ -60,7 +61,7 @@
$(CORBA_GENERATED_H) \
e-cal-backend.h \
e-cal-backend-cache.h \
- e-cal-backend-factory.h \
+ e-cal-backend-loader-factory.h \
e-cal-backend-sync.h \
e-cal-backend-util.h \
e-cal-backend-sexp.h \
Added: trunk/calendar/libedata-cal/e-cal-backend-loader-factory.c
==============================================================================
--- (empty file)
+++ trunk/calendar/libedata-cal/e-cal-backend-loader-factory.c Thu Sep 4 10:28:49 2008
@@ -0,0 +1,59 @@
+/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
+/*
+ *
+ * Author:
+ * Chenthill Palanisamy (pchenthill novell com)
+ *
+ * Copyright (C) 1999-2008 Novell, Inc. (www.novell.com)
+ */
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+
+#include <string.h>
+
+#include "e-cal-backend-loader-factory.h"
+
+static GObjectClass *parent_class = NULL;
+
+static void
+e_cal_backend_loader_factory_instance_init (ECalBackendLoaderFactory *factory)
+{
+}
+
+static void
+e_cal_backend_loader_factory_class_init (ECalBackendLoaderFactoryClass *klass)
+{
+ GObjectClass *object_class;
+
+ parent_class = g_type_class_peek_parent (klass);
+
+ object_class = G_OBJECT_CLASS (klass);
+
+}
+
+GType
+e_cal_backend_loader_factory_get_type (void)
+{
+ static GType type = 0;
+
+ if (! type) {
+ GTypeInfo info = {
+ sizeof (ECalBackendLoaderFactoryClass),
+ NULL, /* base_class_init */
+ NULL, /* base_class_finalize */
+ (GClassInitFunc) e_cal_backend_loader_factory_class_init,
+ NULL, /* class_finalize */
+ NULL, /* class_data */
+ sizeof (ECalBackend),
+ 0, /* n_preallocs */
+ (GInstanceInitFunc) e_cal_backend_loader_factory_instance_init
+ };
+
+ type = g_type_register_static (E_TYPE_CAL_BACKEND_FACTORY, "ECalBackendLoaderFactory", &info, 0);
+ }
+
+ return type;
+}
+
Added: trunk/calendar/libedata-cal/e-cal-backend-loader-factory.h
==============================================================================
--- (empty file)
+++ trunk/calendar/libedata-cal/e-cal-backend-loader-factory.h Thu Sep 4 10:28:49 2008
@@ -0,0 +1,55 @@
+/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 8; tab-width: 8 -*- */
+/* e-cal-backend-loader-factory.h
+ *
+ * Copyright (C) 1999-2008 Novell, Inc. (www.novell.com)
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of version 2 of the GNU Lesser General Public
+ * License as published by the Free Software Foundation.
+ *
+ * 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 Lesser General Public
+ * License along with this program; if not, write to the
+ * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ * Boston, MA 02110-1301, USA.
+ *
+ * Author: Chenthill Palanisamy <pchenthill novell com>
+ */
+
+#ifndef _E_CAL_BACKEND_LOADER_FACTORY_H_
+#define _E_CAL_BACKEND_LOADER_FACTORY_H_
+
+#include <glib-object.h>
+#include "e-cal-backend-factory.h"
+
+G_BEGIN_DECLS
+
+#define E_TYPE_CAL_BACKEND_LOADER_FACTORY (e_cal_backend_loader_factory_get_type ())
+#define E_CAL_BACKEND_LOADER_FACTORY(o) (G_TYPE_CHECK_INSTANCE_CAST ((o), E_TYPE_CAL_BACKEND_LOADER_FACTORY, ECalBackendLoaderFactory))
+#define E_CAL_BACKEND_LOADER_FACTORY_CLASS(k) (G_TYPE_CHECK_CLASS_CAST((k), E_TYPE_CAL_BACKEND_LOADER_FACTORY, ECalBackendLoaderFactoryClass))
+#define E_IS_CAL_BACKEND_LOADER_FACTORY(o) (G_TYPE_CHECK_INSTANCE_TYPE ((o), E_TYPE_CAL_BACKEND_LOADER_FACTORY))
+#define E_IS_CAL_BACKEND_LOADER_FACTORY_CLASS(k) (G_TYPE_CHECK_CLASS_TYPE ((k), E_TYPE_CAL_BACKEND_LOADER_FACTORY))
+#define E_CAL_BACKEND_LOADER_FACTORY_GET_CLASS(o) (G_TYPE_INSTANCE_GET_CLASS ((o), E_TYPE_CAL_BACKEND_LOADER_FACTORY, ECalBackendLoaderFactoryClass))
+
+typedef struct _ECalBackendLoaderFactoryPrivate ECalBackendLoaderFactoryPrivate;
+
+typedef struct {
+ ECalBackendFactory parent_object;
+} ECalBackendLoaderFactory;
+
+typedef struct {
+ ECalBackendFactoryClass parent_class;
+
+ GSList* (*get_protocol_list) (ECalBackendLoaderFactory *factory);
+ ECalBackend* (*new_backend_with_protocol) (ECalBackendLoaderFactory *factory, ESource *source, const char *protocol);
+} ECalBackendLoaderFactoryClass;
+
+GType e_cal_backend_loader_factory_get_type (void);
+
+G_END_DECLS
+
+#endif /* _E_CAL_BACKEND_LOADER_FACTORY_H_ */
Modified: trunk/calendar/libedata-cal/e-cal-backend.c
==============================================================================
--- trunk/calendar/libedata-cal/e-cal-backend.c (original)
+++ trunk/calendar/libedata-cal/e-cal-backend.c Thu Sep 4 10:28:49 2008
@@ -1403,6 +1403,25 @@
g_object_unref (iter);
}
+
+void
+e_cal_backend_notify_objects_added (ECalBackend *backend, EDataCalView *query, const GList *objects)
+{
+ e_data_cal_view_notify_objects_added (query, objects);
+}
+
+void
+e_cal_backend_notify_objects_removed (ECalBackend *backend, EDataCalView *query, const GList *ids)
+{
+ e_data_cal_view_notify_objects_removed (query, ids);
+}
+
+void
+e_cal_backend_notify_objects_modified (ECalBackend *backend, EDataCalView *query, const GList *objects)
+{
+ e_data_cal_view_notify_objects_modified (query, objects);
+}
+
/**
* e_cal_backend_notify_mode:
* @backend: A calendar backend.
Modified: trunk/calendar/libedata-cal/e-cal-backend.h
==============================================================================
--- trunk/calendar/libedata-cal/e-cal-backend.h (original)
+++ trunk/calendar/libedata-cal/e-cal-backend.h Thu Sep 4 10:28:49 2008
@@ -166,8 +166,6 @@
icaltimezone* e_cal_backend_internal_get_default_timezone (ECalBackend *backend);
icaltimezone* e_cal_backend_internal_get_timezone (ECalBackend *backend, const char *tzid);
-void e_cal_backend_last_client_gone (ECalBackend *backend);
-
void e_cal_backend_set_notification_proxy (ECalBackend *backend, ECalBackend *proxy);
void e_cal_backend_notify_object_created (ECalBackend *backend, const char *calobj);
void e_cal_backend_notify_object_modified (ECalBackend *backend, const char *old_object, const char *object);
@@ -185,7 +183,9 @@
void e_cal_backend_notify_readonly (ECalBackend *backend, gboolean read_only);
void e_cal_backend_notify_cal_address (ECalBackend *backend, char *address);
-
+void e_cal_backend_notify_objects_added (ECalBackend *backend, EDataCalView *query, const GList *objects);
+void e_cal_backend_notify_objects_removed (ECalBackend *backend, EDataCalView *query, const GList *ids);
+void e_cal_backend_notify_objects_modified (ECalBackend *backend, EDataCalView *query, const GList *objects);
G_END_DECLS
Modified: trunk/calendar/libedata-cal/e-data-cal-factory.c
==============================================================================
--- trunk/calendar/libedata-cal/e-data-cal-factory.c (original)
+++ trunk/calendar/libedata-cal/e-data-cal-factory.c Thu Sep 4 10:28:49 2008
@@ -86,8 +86,10 @@
ECalBackendFactory *factory;
kinds = g_hash_table_lookup (methods, method);
- if (!kinds)
+ if (!kinds) {
return NULL;
+ }
+
factory = g_hash_table_lookup (kinds, GINT_TO_POINTER (kind));
@@ -201,7 +203,11 @@
backend = g_hash_table_lookup (factory->priv->backends, uri_type_string);
if (!backend) {
/* There was no existing backend, create a new one */
- backend = e_cal_backend_factory_new_backend (backend_factory, source);
+ if (E_IS_CAL_BACKEND_LOADER_FACTORY (backend_factory)) {
+ backend = E_CAL_BACKEND_LOADER_FACTORY_GET_CLASS (backend_factory)->new_backend_with_protocol ((ECalBackendLoaderFactory *)backend_factory,
+ source, uri->protocol);
+ } else
+ backend = e_cal_backend_factory_new_backend (backend_factory, source);
if (!backend) {
g_warning (G_STRLOC ": could not instantiate backend");
@@ -242,7 +248,6 @@
return ret_cal;
}
-
/**
* e_data_cal_factory_new:
@@ -445,38 +450,55 @@
{
EDataCalFactoryPrivate *priv;
const char *method;
- char *method_str;
GHashTable *kinds;
GType type;
icalcomponent_kind kind;
+ GSList *methods = NULL, *l;
g_return_if_fail (factory && E_IS_DATA_CAL_FACTORY (factory));
g_return_if_fail (backend_factory && E_IS_CAL_BACKEND_FACTORY (backend_factory));
priv = factory->priv;
- method = E_CAL_BACKEND_FACTORY_GET_CLASS (backend_factory)->get_protocol (backend_factory);
+ if (E_IS_CAL_BACKEND_LOADER_FACTORY (backend_factory)) {
+ GSList *list = E_CAL_BACKEND_LOADER_FACTORY_GET_CLASS (backend_factory)->get_protocol_list ((ECalBackendLoaderFactory *) backend_factory);
+ methods = g_slist_copy (list);
+ } else if (E_CAL_BACKEND_FACTORY_GET_CLASS (backend_factory)->get_protocol) {
+ method = E_CAL_BACKEND_FACTORY_GET_CLASS (backend_factory)->get_protocol (backend_factory);
+ methods = g_slist_append (methods, (gpointer) method);
+ } else {
+ g_assert_not_reached ();
+ return;
+ }
+
kind = E_CAL_BACKEND_FACTORY_GET_CLASS (backend_factory)->get_kind (backend_factory);
- method_str = g_ascii_strdown (method, -1);
+ for (l= methods; l != NULL; l = g_slist_next (l)) {
+ char *method_str;
+
+ method = l->data;
+
+ method_str = g_ascii_strdown (method, -1);
+
+ kinds = g_hash_table_lookup (priv->methods, method_str);
+ if (kinds) {
+ type = GPOINTER_TO_INT (g_hash_table_lookup (kinds, GINT_TO_POINTER (kind)));
+ if (type) {
+ g_warning (G_STRLOC ": method `%s' already registered", method_str);
+ g_free (method_str);
+ g_slist_free (methods);
+ return;
+ }
- kinds = g_hash_table_lookup (priv->methods, method_str);
- if (kinds) {
- type = GPOINTER_TO_INT (g_hash_table_lookup (kinds, GINT_TO_POINTER (kind)));
- if (type) {
- g_warning (G_STRLOC ": method `%s' already registered", method_str);
g_free (method_str);
-
- return;
+ } else {
+ kinds = g_hash_table_new_full (g_direct_hash, g_direct_equal, NULL, NULL);
+ g_hash_table_insert (priv->methods, method_str, kinds);
}
- g_free (method_str);
- } else {
- kinds = g_hash_table_new_full (g_direct_hash, g_direct_equal, NULL, NULL);
- g_hash_table_insert (priv->methods, method_str, kinds);
+ g_hash_table_insert (kinds, GINT_TO_POINTER (kind), backend_factory);
}
-
- g_hash_table_insert (kinds, GINT_TO_POINTER (kind), backend_factory);
+ g_slist_free (methods);
}
/**
@@ -491,6 +513,7 @@
GList *factories, *f;
factories = e_data_server_get_extensions_for_type (E_TYPE_CAL_BACKEND_FACTORY);
+
for (f = factories; f; f = f->next) {
ECalBackendFactory *backend_factory = f->data;
Modified: trunk/calendar/libedata-cal/e-data-cal-factory.h
==============================================================================
--- trunk/calendar/libedata-cal/e-data-cal-factory.h (original)
+++ trunk/calendar/libedata-cal/e-data-cal-factory.h Thu Sep 4 10:28:49 2008
@@ -24,7 +24,7 @@
#include <bonobo/bonobo-object.h>
#include <libical/ical.h>
#include <libedata-cal/Evolution-DataServer-Calendar.h>
-#include <libedata-cal/e-cal-backend-factory.h>
+#include <libedata-cal/e-cal-backend-loader-factory.h>
G_BEGIN_DECLS
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]