[evolution-data-server] Adapt ECalBackendCalDAV to libedata-cal changes.
- From: Matthew Barnes <mbarnes src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [evolution-data-server] Adapt ECalBackendCalDAV to libedata-cal changes.
- Date: Mon, 26 Sep 2011 13:47:50 +0000 (UTC)
commit dc49f9666acee3b51a3dbed9629430415fb65bb9
Author: Matthew Barnes <mbarnes redhat com>
Date: Fri Sep 9 13:21:19 2011 -0400
Adapt ECalBackendCalDAV to libedata-cal changes.
calendar/backends/caldav/Makefile.am | 1 -
.../backends/caldav/e-cal-backend-caldav-factory.c | 175 ++++++++++----------
.../backends/caldav/e-cal-backend-caldav-factory.h | 38 -----
calendar/backends/caldav/e-cal-backend-caldav.c | 52 ++++---
calendar/backends/caldav/e-cal-backend-caldav.h | 30 +++-
5 files changed, 136 insertions(+), 160 deletions(-)
---
diff --git a/calendar/backends/caldav/Makefile.am b/calendar/backends/caldav/Makefile.am
index 1ae1232..fad450b 100644
--- a/calendar/backends/caldav/Makefile.am
+++ b/calendar/backends/caldav/Makefile.am
@@ -11,7 +11,6 @@ libecalbackendcaldav_la_CPPFLAGS = \
libecalbackendcaldav_la_SOURCES = \
e-cal-backend-caldav-factory.c \
- e-cal-backend-caldav-factory.h \
e-cal-backend-caldav.c \
e-cal-backend-caldav.h
diff --git a/calendar/backends/caldav/e-cal-backend-caldav-factory.c b/calendar/backends/caldav/e-cal-backend-caldav-factory.c
index 5e775f4..ef6cab4 100644
--- a/calendar/backends/caldav/e-cal-backend-caldav-factory.c
+++ b/calendar/backends/caldav/e-cal-backend-caldav-factory.c
@@ -22,113 +22,110 @@
*
*/
-#ifdef HAVE_CONFIG_H
#include <config.h>
-#endif
-#include <string.h>
-
-#include "e-cal-backend-caldav-factory.h"
+#include <libedata-cal/e-cal-backend-factory.h>
#include "e-cal-backend-caldav.h"
-typedef struct {
- ECalBackendFactory parent_object;
-} ECalBackendCalDAVFactory;
+#define FACTORY_NAME "caldav"
+
+typedef ECalBackendFactory ECalBackendCalDAVEventsFactory;
+typedef ECalBackendFactoryClass ECalBackendCalDAVEventsFactoryClass;
+
+typedef ECalBackendFactory ECalBackendCalDAVJournalFactory;
+typedef ECalBackendFactoryClass ECalBackendCalDAVJournalFactoryClass;
+
+typedef ECalBackendFactory ECalBackendCalDAVTodosFactory;
+typedef ECalBackendFactoryClass ECalBackendCalDAVTodosFactoryClass;
+
+/* Module Entry Points */
+void e_module_load (GTypeModule *type_module);
+void e_module_unload (GTypeModule *type_module);
+
+/* Forward Declarations */
+GType e_cal_backend_caldav_events_factory_get_type (void);
+GType e_cal_backend_caldav_journal_factory_get_type (void);
+GType e_cal_backend_caldav_todos_factory_get_type (void);
+
+G_DEFINE_DYNAMIC_TYPE (
+ ECalBackendCalDAVEventsFactory,
+ e_cal_backend_caldav_events_factory,
+ E_TYPE_CAL_BACKEND_FACTORY)
+
+G_DEFINE_DYNAMIC_TYPE (
+ ECalBackendCalDAVJournalFactory,
+ e_cal_backend_caldav_journal_factory,
+ E_TYPE_CAL_BACKEND_FACTORY)
+
+G_DEFINE_DYNAMIC_TYPE (
+ ECalBackendCalDAVTodosFactory,
+ e_cal_backend_caldav_todos_factory,
+ E_TYPE_CAL_BACKEND_FACTORY)
-typedef struct {
- ECalBackendFactoryClass parent_class;
-} ECalBackendCalDAVFactoryClass;
+static void
+e_cal_backend_caldav_events_factory_class_init (ECalBackendFactoryClass *class)
+{
+ class->factory_name = FACTORY_NAME;
+ class->component_kind = ICAL_VEVENT_COMPONENT;
+ class->backend_type = E_TYPE_CAL_BACKEND_CALDAV;
+}
static void
-ecb_caldav_factory_instance_init (ECalBackendCalDAVFactory *factory)
+e_cal_backend_caldav_events_factory_class_finalize (ECalBackendFactoryClass *class)
{
}
-static const gchar *
-_get_protocol (ECalBackendFactory *factory)
+static void
+e_cal_backend_caldav_events_factory_init (ECalBackendFactory *factory)
{
- return "caldav";
}
-#define declare_functions(_type,_name) \
- \
-static ECalBackend * \
-_new_backend_ ## _type (ECalBackendFactory *factory, ESource *source) \
-{ \
- return g_object_new (E_TYPE_CAL_BACKEND_CALDAV, \
- "source", source, \
- "kind", ICAL_ ## _type ## _COMPONENT, \
- NULL); \
-} \
- \
-static icalcomponent_kind \
-_get_kind_ ## _type (ECalBackendFactory *factory) \
-{ \
- return ICAL_ ## _type ## _COMPONENT; \
-} \
- \
-static void \
-_backend_factory_class_init_ ## _type (ECalBackendCalDAVFactoryClass *klass) \
-{ \
- ECalBackendFactoryClass *bc = E_CAL_BACKEND_FACTORY_CLASS (klass); \
- \
- g_return_if_fail (bc != NULL); \
- \
- bc->get_protocol = _get_protocol; \
- bc->get_kind = _get_kind_ ## _type; \
- bc->new_backend = _new_backend_ ## _type; \
-} \
- \
-static GType \
-backend_factory_get_type_ ## _type (GTypeModule *module) \
-{ \
- static GType type = 0; \
- \
- GTypeInfo info = { \
- sizeof (ECalBackendCalDAVFactoryClass), \
- NULL, /* base_class_init */ \
- NULL, /* base_class_finalize */ \
- (GClassInitFunc) _backend_factory_class_init_ ## _type, \
- NULL, /* class_finalize */ \
- NULL, /* class_data */ \
- sizeof (ECalBackend), \
- 0, /* n_preallocs */ \
- (GInstanceInitFunc) ecb_caldav_factory_instance_init \
- }; \
- \
- if (!type) { \
- type = g_type_module_register_type (module, \
- E_TYPE_CAL_BACKEND_FACTORY, \
- _name, \
- &info, 0); \
- } \
- \
- return type; \
-} \
-
-declare_functions (VEVENT, "ECalBackendCalDAVEventsFactory")
-declare_functions (VTODO, "ECalBackendCalDAVTodosFactory")
-declare_functions (VJOURNAL, "ECalBackendCalDAVMemosFactory")
-
-static GType caldav_types[3];
-
-void
-eds_module_initialize (GTypeModule *module)
+static void
+e_cal_backend_caldav_journal_factory_class_init (ECalBackendFactoryClass *class)
{
- caldav_types[0] = backend_factory_get_type_VEVENT (module);
- caldav_types[1] = backend_factory_get_type_VTODO (module);
- caldav_types[2] = backend_factory_get_type_VJOURNAL (module);
+ class->factory_name = FACTORY_NAME;
+ class->component_kind = ICAL_VJOURNAL_COMPONENT;
+ class->backend_type = E_TYPE_CAL_BACKEND_CALDAV;
}
-void
-eds_module_shutdown (void)
+static void
+e_cal_backend_caldav_journal_factory_class_finalize (ECalBackendFactoryClass *class)
{
}
-void
-eds_module_list_types (const GType **types,
- gint *num_types)
+static void
+e_cal_backend_caldav_journal_factory_init (ECalBackendFactory *factory)
{
- *types = caldav_types;
- *num_types = 3;
}
+
+static void
+e_cal_backend_caldav_todos_factory_class_init (ECalBackendFactoryClass *class)
+{
+ class->factory_name = FACTORY_NAME;
+ class->component_kind = ICAL_VTODO_COMPONENT;
+ class->backend_type = E_TYPE_CAL_BACKEND_CALDAV;
+}
+
+static void
+e_cal_backend_caldav_todos_factory_class_finalize (ECalBackendFactoryClass *class)
+{
+}
+
+static void
+e_cal_backend_caldav_todos_factory_init (ECalBackendFactory *factory)
+{
+}
+
+G_MODULE_EXPORT void
+e_module_load (GTypeModule *type_module)
+{
+ e_cal_backend_caldav_events_factory_register_type (type_module);
+ e_cal_backend_caldav_journal_factory_register_type (type_module);
+ e_cal_backend_caldav_todos_factory_register_type (type_module);
+}
+
+G_MODULE_EXPORT void
+e_module_unload (GTypeModule *type_module)
+{
+}
+
diff --git a/calendar/backends/caldav/e-cal-backend-caldav.c b/calendar/backends/caldav/e-cal-backend-caldav.c
index 0acc6a3..facdd52 100644
--- a/calendar/backends/caldav/e-cal-backend-caldav.c
+++ b/calendar/backends/caldav/e-cal-backend-caldav.c
@@ -73,9 +73,6 @@ typedef enum {
/* Private part of the ECalBackendHttp structure */
struct _ECalBackendCalDAVPrivate {
- /* online/offline */
- gboolean is_online;
-
/* The local disk cache */
ECalBackendStore *store;
@@ -580,7 +577,7 @@ check_state (ECalBackendCalDAV *cbdav,
return FALSE;
}
- if (!priv->is_online) {
+ if (!e_backend_get_online (E_BACKEND (cbdav))) {
if (!priv->do_offline) {
g_propagate_error (perror, EDC_ERROR (RepositoryOffline));
@@ -2163,6 +2160,7 @@ caldav_synch_slave_loop (gpointer data)
if (!priv->opened) {
gboolean server_unreachable = FALSE;
GError *local_error = NULL;
+ gboolean online;
if (caldav_server_open_calendar (cbdav, &server_unreachable, &local_error)) {
priv->opened = TRUE;
@@ -2193,7 +2191,9 @@ caldav_synch_slave_loop (gpointer data)
}
e_cal_backend_notify_readonly (E_CAL_BACKEND (cbdav), priv->read_only);
- e_cal_backend_notify_online (E_CAL_BACKEND (cbdav), priv->is_online);
+
+ online = e_backend_get_online (E_BACKEND (cbdav));
+ e_cal_backend_notify_online (E_CAL_BACKEND (cbdav), online);
}
if (priv->opened) {
@@ -2263,7 +2263,7 @@ get_usermail (ECalBackend *backend)
g_return_val_if_fail (backend != NULL, NULL);
- source = e_cal_backend_get_source (backend);
+ source = e_backend_get_source (E_BACKEND (backend));
if (source) {
res = e_source_get_duped_property (source, "usermail");
if (res && *res)
@@ -2313,7 +2313,7 @@ caldav_get_backend_property (ECalBackendSync *backend,
g_string_append (caps, "," CAL_STATIC_CAPABILITY_NO_EMAIL_ALARMS);
g_free (usermail);
- source = e_cal_backend_get_source (E_CAL_BACKEND (backend));
+ source = e_backend_get_source (E_BACKEND (backend));
if (source) {
const gchar *prop = e_source_get_property (source, "autoschedule");
@@ -2372,8 +2372,9 @@ initialize_backend (ECalBackendCalDAV *cbdav,
priv = cbdav->priv;
backend = E_CAL_BACKEND (cbdav);
- source = e_cal_backend_get_source (backend);
cache_dir = e_cal_backend_get_cache_dir (backend);
+ source = e_backend_get_source (E_BACKEND (backend));
+ uri = e_source_get_uri (source);
if (!g_signal_handler_find (G_OBJECT (source), G_SIGNAL_MATCH_FUNC | G_SIGNAL_MATCH_DATA, 0, 0, NULL, caldav_source_changed_cb, cbdav))
g_signal_connect (G_OBJECT (source), "changed", G_CALLBACK (caldav_source_changed_cb), cbdav);
@@ -2388,7 +2389,6 @@ initialize_backend (ECalBackendCalDAV *cbdav,
priv->auth_required = os_val != NULL;
os_val = e_source_get_property(source, "ssl");
- uri = e_cal_backend_get_uri (backend);
g_free (priv->uri);
priv->uri = NULL;
@@ -2556,6 +2556,7 @@ caldav_do_open (ECalBackendSync *backend,
{
ECalBackendCalDAV *cbdav;
ECalBackendCalDAVPrivate *priv;
+ gboolean online;
cbdav = E_CAL_BACKEND_CALDAV (backend);
priv = cbdav->priv;
@@ -2570,7 +2571,9 @@ caldav_do_open (ECalBackendSync *backend,
return;
}
- if (!priv->do_offline && !priv->is_online) {
+ online = e_backend_get_online (E_BACKEND (backend));
+
+ if (!priv->do_offline && !online) {
g_mutex_unlock (priv->busy_lock);
g_propagate_error (perror, EDC_ERROR (RepositoryOffline));
return;
@@ -2580,7 +2583,7 @@ caldav_do_open (ECalBackendSync *backend,
priv->opened = TRUE;
priv->is_google = FALSE;
- if (priv->is_online) {
+ if (online) {
GError *local_error = NULL;
open_calendar (cbdav, &local_error);
@@ -2600,7 +2603,7 @@ caldav_do_open (ECalBackendSync *backend,
}
e_cal_backend_notify_readonly (E_CAL_BACKEND (backend), priv->read_only);
- e_cal_backend_notify_online (E_CAL_BACKEND (backend), priv->is_online);
+ e_cal_backend_notify_online (E_CAL_BACKEND (backend), online);
g_mutex_unlock (priv->busy_lock);
}
@@ -4635,27 +4638,27 @@ caldav_get_free_busy (ECalBackendSync *backend,
}
static void
-caldav_set_online (ECalBackend *backend,
- gboolean is_online)
+caldav_notify_online_cb (ECalBackend *backend,
+ GParamSpec *pspec)
{
ECalBackendCalDAV *cbdav;
ECalBackendCalDAVPrivate *priv;
+ gboolean online;
cbdav = E_CAL_BACKEND_CALDAV (backend);
priv = cbdav->priv;
/*g_mutex_lock (priv->busy_lock);*/
- if ((priv->is_online ? 1: 0) == (is_online ? 1 : 0) || !priv->loaded) {
- priv->is_online = is_online;
- e_cal_backend_notify_online (backend, is_online);
+ online = e_backend_get_online (E_BACKEND (backend));
+
+ if (!priv->loaded) {
+ e_cal_backend_notify_online (backend, online);
/*g_mutex_unlock (priv->busy_lock);*/
return;
}
- priv->is_online = is_online;
-
- if (is_online) {
+ if (online) {
/* Wake up the slave thread */
priv->slave_cmd = SLAVE_SHOULD_WORK;
g_cond_signal (priv->cond);
@@ -4664,7 +4667,7 @@ caldav_set_online (ECalBackend *backend,
priv->slave_cmd = SLAVE_SHOULD_SLEEP;
}
- e_cal_backend_notify_online (backend, is_online);
+ e_cal_backend_notify_online (backend, online);
/*g_mutex_unlock (priv->busy_lock);*/
}
@@ -4748,7 +4751,7 @@ e_cal_backend_caldav_dispose (GObject *object)
return;
}
- source = e_cal_backend_get_source (E_CAL_BACKEND (cbdav));
+ source = e_backend_get_source (E_BACKEND (cbdav));
if (source)
g_signal_handlers_disconnect_by_func (G_OBJECT (source), caldav_source_changed_cb, cbdav);
@@ -4839,6 +4842,10 @@ e_cal_backend_caldav_init (ECalBackendCalDAV *cbdav)
G_CALLBACK (soup_authenticate), cbdav);
e_cal_backend_sync_set_lock (E_CAL_BACKEND_SYNC (cbdav), FALSE);
+
+ g_signal_connect (
+ cbdav, "notify::online",
+ G_CALLBACK (caldav_notify_online_cb), NULL);
}
static void
@@ -4879,7 +4886,6 @@ e_cal_backend_caldav_class_init (ECalBackendCalDAVClass *class)
sync_class->get_free_busy_sync = caldav_get_free_busy;
backend_class->start_view = caldav_start_view;
- backend_class->set_online = caldav_set_online;
backend_class->internal_get_timezone = caldav_internal_get_timezone;
}
diff --git a/calendar/backends/caldav/e-cal-backend-caldav.h b/calendar/backends/caldav/e-cal-backend-caldav.h
index 9289c0f..d9ad8d3 100644
--- a/calendar/backends/caldav/e-cal-backend-caldav.h
+++ b/calendar/backends/caldav/e-cal-backend-caldav.h
@@ -25,21 +25,33 @@
#include <libedata-cal/e-cal-backend-sync.h>
-G_BEGIN_DECLS
+/* Standard GObject macros */
+#define E_TYPE_CAL_BACKEND_CALDAV \
+ (e_cal_backend_caldav_get_type ())
+#define E_CAL_BACKEND_CALDAV(obj) \
+ (G_TYPE_CHECK_INSTANCE_CAST \
+ ((obj), E_TYPE_CAL_BACKEND_CALDAV, ECalBackendCalDAV))
+#define E_CAL_BACKEND_CALDAV_CLASS(cls) \
+ (G_TYPE_CHECK_CLASS_CAST \
+ ((cls), E_TYPE_CAL_BACKEND_CALDAV, ECalBackendCalDAVClass))
+#define E_IS_CAL_BACKEND_CALDAV(obj) \
+ (G_TYPE_CHECK_INSTANCE_TYPE \
+ ((obj), E_TYPE_CAL_BACKEND_CALDAV))
+#define E_IS_CAL_BACKEND_CALDAV_CLASS(cls) \
+ (G_TYPE_CHECK_CLASS_TYPE \
+ ((cls), E_TYPE_CAL_BACKEND_CALDAV))
+#define E_CAL_BACKEND_CALDAV_GET_CLASS(obj) \
+ (G_TYPE_INSTANCE_GET_CLASS \
+ ((obj), E_TYPE_CAL_BACKEND_CALDAV, ECalBackendCalDAVClass))
-#define E_TYPE_CAL_BACKEND_CALDAV (e_cal_backend_caldav_get_type ())
-#define E_CAL_BACKEND_CALDAV(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), E_TYPE_CAL_BACKEND_CALDAV, ECalBackendCalDAV))
-#define E_CAL_BACKEND_CALDAV_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), E_TYPE_CAL_BACKEND_CALDAV, ECalBackendCalDAVClass))
-#define E_IS_CAL_BACKEND_CALDAV(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), E_TYPE_CAL_BACKEND_CALDAV))
-#define E_IS_CAL_BACKEND_CALDAV_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), E_TYPE_CAL_BACKEND_CALDAV))
+G_BEGIN_DECLS
typedef struct _ECalBackendCalDAV ECalBackendCalDAV;
typedef struct _ECalBackendCalDAVClass ECalBackendCalDAVClass;
typedef struct _ECalBackendCalDAVPrivate ECalBackendCalDAVPrivate;
struct _ECalBackendCalDAV {
- ECalBackendSync backend;
-
+ ECalBackendSync parent;
ECalBackendCalDAVPrivate *priv;
};
@@ -47,7 +59,7 @@ struct _ECalBackendCalDAVClass {
ECalBackendSyncClass parent_class;
};
-GType e_cal_backend_caldav_get_type (void);
+GType e_cal_backend_caldav_get_type (void);
G_END_DECLS
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]