[evolution-data-server] Replace EGdbusCalFactory with EDBusCalendarFactory.
- From: Matthew Barnes <mbarnes src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [evolution-data-server] Replace EGdbusCalFactory with EDBusCalendarFactory.
- Date: Thu, 24 Jan 2013 18:49:31 +0000 (UTC)
commit 902ae2a7530cae53e8293c4ebad3ed3ccb33d5ae
Author: Matthew Barnes <mbarnes redhat com>
Date: Thu Jan 24 13:16:46 2013 -0500
Replace EGdbusCalFactory with EDBusCalendarFactory.
calendar/libecal/Makefile.am | 4 +-
calendar/libecal/e-cal-client.c | 53 +--
calendar/libedata-cal/Makefile.am | 2 +
calendar/libedata-cal/e-data-cal-factory.c | 246 ++++++----
calendar/libedata-cal/e-data-cal-factory.xml | 17 -
calendar/libegdbus/Makefile.am | 2 -
calendar/libegdbus/e-gdbus-cal-factory.c | 668 --------------------------
calendar/libegdbus/e-gdbus-cal-factory.h | 114 -----
8 files changed, 175 insertions(+), 931 deletions(-)
---
diff --git a/calendar/libecal/Makefile.am b/calendar/libecal/Makefile.am
index 8c24537..c3921f7 100644
--- a/calendar/libecal/Makefile.am
+++ b/calendar/libecal/Makefile.am
@@ -20,9 +20,11 @@ libecal_INCLUDES = \
-I$(top_srcdir)/calendar \
-I$(top_srcdir)/calendar/libegdbus \
-I$(top_srcdir)/calendar/libedata-cal \
+ -I$(top_srcdir)/private \
-I$(top_builddir) \
-I$(top_builddir)/calendar \
- -I$(top_builddir)/calendar/libecal
+ -I$(top_builddir)/calendar/libecal \
+ -I$(top_builddir)/private
libecal_1_2_la_CPPFLAGS = \
$(AM_CPPFLAGS) \
diff --git a/calendar/libecal/e-cal-client.c b/calendar/libecal/e-cal-client.c
index 421a63d..3f74629 100644
--- a/calendar/libecal/e-cal-client.c
+++ b/calendar/libecal/e-cal-client.c
@@ -26,6 +26,9 @@
#include <glib/gi18n-lib.h>
#include <gio/gio.h>
+/* Private D-Bus classes. */
+#include <e-dbus-calendar-factory.h>
+
#include <libedataserver/e-client-private.h>
#include "e-cal-client.h"
@@ -36,7 +39,6 @@
#include "e-timezone-cache.h"
#include "e-gdbus-cal.h"
-#include "e-gdbus-cal-factory.h"
#define E_CAL_CLIENT_GET_PRIVATE(obj) \
(G_TYPE_INSTANCE_GET_PRIVATE \
@@ -205,7 +207,7 @@ set_proxy_gone_error (GError **error)
}
static guint active_cal_clients = 0, cal_connection_closed_id = 0;
-static EGdbusCalFactory *cal_factory = NULL;
+static EDBusCalendarFactory *cal_factory = NULL;
static GRecMutex cal_factory_lock;
#define LOCK_FACTORY() g_rec_mutex_lock (&cal_factory_lock)
#define UNLOCK_FACTORY() g_rec_mutex_unlock (&cal_factory_lock)
@@ -286,7 +288,7 @@ gdbus_cal_factory_activate (GCancellable *cancellable,
return TRUE;
}
- cal_factory = e_gdbus_cal_factory_proxy_new_for_bus_sync (
+ cal_factory = e_dbus_calendar_factory_proxy_new_for_bus_sync (
G_BUS_TYPE_SESSION,
G_DBUS_PROXY_FLAGS_NONE,
CALENDAR_DBUS_SERVICE_NAME,
@@ -495,23 +497,6 @@ backend_property_changed_cb (EGdbusCal *object,
g_free (prop_value);
}
-static EDataCalObjType
-convert_type (ECalClientSourceType type)
-{
- switch (type) {
- case E_CAL_CLIENT_SOURCE_TYPE_EVENTS:
- return Event;
- case E_CAL_CLIENT_SOURCE_TYPE_TASKS:
- return Todo;
- case E_CAL_CLIENT_SOURCE_TYPE_MEMOS:
- return Journal;
- default:
- return AnyType;
- }
-
- return AnyType;
-}
-
/*
* Converts a GSList of icalcomponents into a NULL-terminated array of
* valid UTF-8 strings, suitable for sending over DBus.
@@ -1129,7 +1114,6 @@ e_cal_client_new (ESource *source,
GError *err = NULL;
GDBusConnection *connection;
const gchar *uid;
- gchar **strv;
gchar *object_path = NULL;
g_return_val_if_fail (E_IS_SOURCE (source), NULL);
@@ -1155,23 +1139,28 @@ e_cal_client_new (ESource *source,
}
uid = e_source_get_uid (source);
- strv = e_gdbus_cal_factory_encode_get_cal (uid, convert_type (source_type));
- if (!strv) {
- g_set_error_literal (error, E_CLIENT_ERROR, E_CLIENT_ERROR_OTHER_ERROR, _("Other error"));
- return NULL;
- }
client = g_object_new (E_TYPE_CAL_CLIENT, "source", source, NULL);
client->priv->source_type = source_type;
UNLOCK_FACTORY ();
- e_gdbus_cal_factory_call_get_cal_sync (
- G_DBUS_PROXY (cal_factory),
- (const gchar * const *) strv,
- &object_path, NULL, &err);
-
- g_strfreev (strv);
+ switch (source_type) {
+ case E_CAL_CLIENT_SOURCE_TYPE_EVENTS:
+ e_dbus_calendar_factory_call_open_calendar_sync (
+ cal_factory, uid, &object_path, NULL, &err);
+ break;
+ case E_CAL_CLIENT_SOURCE_TYPE_TASKS:
+ e_dbus_calendar_factory_call_open_task_list_sync (
+ cal_factory, uid, &object_path, NULL, &err);
+ break;
+ case E_CAL_CLIENT_SOURCE_TYPE_MEMOS:
+ e_dbus_calendar_factory_call_open_memo_list_sync (
+ cal_factory, uid, &object_path, NULL, &err);
+ break;
+ default:
+ g_return_val_if_reached (NULL);
+ }
/* Sanity check. */
g_return_val_if_fail (
diff --git a/calendar/libedata-cal/Makefile.am b/calendar/libedata-cal/Makefile.am
index f4ab97a..4ca704e 100644
--- a/calendar/libedata-cal/Makefile.am
+++ b/calendar/libedata-cal/Makefile.am
@@ -9,8 +9,10 @@ libedata_cal_1_2_la_CPPFLAGS = \
-I$(top_srcdir) \
-I$(top_srcdir)/calendar \
-I$(top_srcdir)/calendar/libegdbus \
+ -I$(top_srcdir)/private \
-I$(top_builddir) \
-I$(top_builddir)/calendar \
+ -I$(top_builddir)/private \
$(EVOLUTION_CALENDAR_CFLAGS) \
$(CAMEL_CFLAGS) \
$(CODE_COVERAGE_CFLAGS) \
diff --git a/calendar/libedata-cal/e-data-cal-factory.c b/calendar/libedata-cal/e-data-cal-factory.c
index 7c5f1b1..474bdd6 100644
--- a/calendar/libedata-cal/e-data-cal-factory.c
+++ b/calendar/libedata-cal/e-data-cal-factory.c
@@ -30,13 +30,14 @@
#include <unistd.h>
#include <glib/gi18n.h>
+/* Private D-Bus classes. */
+#include <e-dbus-calendar-factory.h>
+
#include "e-cal-backend.h"
#include "e-cal-backend-factory.h"
#include "e-data-cal.h"
#include "e-data-cal-factory.h"
-#include "e-gdbus-cal-factory.h"
-
#include <libical/ical.h>
#define d(x)
@@ -47,7 +48,7 @@
struct _EDataCalFactoryPrivate {
ESourceRegistry *registry;
- EGdbusCalFactory *gdbus_object;
+ EDBusCalendarFactory *dbus_factory;
GMutex calendars_lock;
/* A hash of object paths for calendar URIs to EDataCals */
@@ -78,33 +79,15 @@ G_DEFINE_TYPE_WITH_CODE (
static EBackend *
data_cal_factory_ref_backend (EDataFactory *factory,
ESource *source,
- EDataCalObjType type,
+ const gchar *extension_name,
+ const gchar *type_string,
GError **error)
{
EBackend *backend;
ESourceBackend *extension;
- const gchar *extension_name;
- const gchar *type_string;
gchar *backend_name;
gchar *hash_key;
- switch (type) {
- case Event:
- extension_name = E_SOURCE_EXTENSION_CALENDAR;
- type_string = "VEVENT";
- break;
- case Todo:
- extension_name = E_SOURCE_EXTENSION_TASK_LIST;
- type_string = "VTODO";
- break;
- case Journal:
- extension_name = E_SOURCE_EXTENSION_MEMO_LIST;
- type_string = "VJOURNAL";
- break;
- default:
- g_return_val_if_reached (NULL);
- }
-
extension = e_source_get_extension (source, extension_name);
backend_name = e_source_backend_dup_backend_name (extension);
@@ -191,76 +174,47 @@ calendar_freed_cb (EDataCalFactory *factory,
e_dbus_server_release (E_DBUS_SERVER (factory));
}
-static gboolean
-impl_CalFactory_get_cal (EGdbusCalFactory *object,
- GDBusMethodInvocation *invocation,
- const gchar * const *in_source_type,
- EDataCalFactory *factory)
+static gchar *
+data_cal_factory_open (EDataCalFactory *factory,
+ GDBusConnection *connection,
+ const gchar *sender,
+ const gchar *uid,
+ const gchar *extension_name,
+ const gchar *type_string,
+ GError **error)
{
EDataCal *calendar;
EBackend *backend;
- EDataCalFactoryPrivate *priv = factory->priv;
- GDBusConnection *connection;
ESourceRegistry *registry;
ESource *source;
gchar *object_path;
- const gchar *sender;
GList *list;
- GError *error = NULL;
- gchar *uid = NULL;
- guint type = 0;
-
- sender = g_dbus_method_invocation_get_sender (invocation);
- connection = g_dbus_method_invocation_get_connection (invocation);
-
- registry = e_data_cal_factory_get_registry (factory);
-
- if (!e_gdbus_cal_factory_decode_get_cal (in_source_type, &uid, &type)) {
- error = g_error_new (
- E_DATA_CAL_ERROR, NoSuchCal, _("Invalid call"));
- g_dbus_method_invocation_return_gerror (invocation, error);
- g_error_free (error);
-
- return TRUE;
- }
if (uid == NULL || *uid == '\0') {
- error = g_error_new_literal (
- E_DATA_CAL_ERROR, NoSuchCal,
+ g_set_error (
+ error, E_DATA_CAL_ERROR, NoSuchCal,
_("Missing source UID"));
- g_dbus_method_invocation_return_gerror (invocation, error);
- g_error_free (error);
- g_free (uid);
-
- return TRUE;
+ return NULL;
}
+ registry = e_data_cal_factory_get_registry (factory);
source = e_source_registry_ref_source (registry, uid);
if (source == NULL) {
- error = g_error_new (
- E_DATA_CAL_ERROR, NoSuchCal,
+ g_set_error (
+ error, E_DATA_CAL_ERROR, NoSuchCal,
_("No such source for UID '%s'"), uid);
- g_dbus_method_invocation_return_gerror (invocation, error);
- g_error_free (error);
- g_free (uid);
-
- return TRUE;
+ return NULL;
}
backend = data_cal_factory_ref_backend (
- E_DATA_FACTORY (factory), source, type, &error);
+ E_DATA_FACTORY (factory), source,
+ extension_name, type_string, error);
g_object_unref (source);
- if (error != NULL) {
- g_dbus_method_invocation_return_gerror (invocation, error);
- g_error_free (error);
-
- return TRUE;
- }
-
- g_return_val_if_fail (E_IS_BACKEND (backend), FALSE);
+ if (backend == NULL)
+ return NULL;
e_dbus_server_hold (E_DBUS_SERVER (factory));
@@ -268,13 +222,14 @@ impl_CalFactory_get_cal (EGdbusCalFactory *object,
calendar = e_data_cal_new (
E_CAL_BACKEND (backend),
- connection, object_path, &error);
+ connection, object_path, error);
if (calendar != NULL) {
- g_mutex_lock (&priv->calendars_lock);
+ g_mutex_lock (&factory->priv->calendars_lock);
g_hash_table_insert (
- priv->calendars, g_strdup (object_path), calendar);
- g_mutex_unlock (&priv->calendars_lock);
+ factory->priv->calendars,
+ g_strdup (object_path), calendar);
+ g_mutex_unlock (&factory->priv->calendars_lock);
e_cal_backend_add_client (E_CAL_BACKEND (backend), calendar);
@@ -283,24 +238,111 @@ impl_CalFactory_get_cal (EGdbusCalFactory *object,
calendar_freed_cb, factory);
/* Update the hash of open connections. */
- g_mutex_lock (&priv->connections_lock);
- list = g_hash_table_lookup (priv->connections, sender);
+ g_mutex_lock (&factory->priv->connections_lock);
+ list = g_hash_table_lookup (
+ factory->priv->connections, sender);
list = g_list_prepend (list, calendar);
g_hash_table_insert (
- priv->connections, g_strdup (sender), list);
- g_mutex_unlock (&priv->connections_lock);
+ factory->priv->connections,
+ g_strdup (sender), list);
+ g_mutex_unlock (&factory->priv->connections_lock);
+
+ } else {
+ g_free (object_path);
+ object_path = NULL;
}
g_object_unref (backend);
- e_gdbus_cal_factory_complete_get_cal (
- object, invocation, object_path, error);
+ return object_path;
+}
+
+static gboolean
+data_cal_factory_handle_open_calendar_cb (EDBusCalendarFactory *interface,
+ GDBusMethodInvocation *invocation,
+ const gchar *uid,
+ EDataCalFactory *factory)
+{
+ GDBusConnection *connection;
+ const gchar *sender;
+ gchar *object_path;
+ GError *error = NULL;
+
+ connection = g_dbus_method_invocation_get_connection (invocation);
+ sender = g_dbus_method_invocation_get_sender (invocation);
+
+ object_path = data_cal_factory_open (
+ factory, connection, sender, uid,
+ E_SOURCE_EXTENSION_CALENDAR, "VEVENT", &error);
+
+ if (object_path != NULL) {
+ e_dbus_calendar_factory_complete_open_calendar (
+ interface, invocation, object_path);
+ g_free (object_path);
+ } else {
+ g_return_val_if_fail (error != NULL, FALSE);
+ g_dbus_method_invocation_take_error (invocation, error);
+ }
+
+ return TRUE;
+}
+
+static gboolean
+data_cal_factory_handle_open_task_list_cb (EDBusCalendarFactory *interface,
+ GDBusMethodInvocation *invocation,
+ const gchar *uid,
+ EDataCalFactory *factory)
+{
+ GDBusConnection *connection;
+ const gchar *sender;
+ gchar *object_path;
+ GError *error = NULL;
+
+ connection = g_dbus_method_invocation_get_connection (invocation);
+ sender = g_dbus_method_invocation_get_sender (invocation);
+
+ object_path = data_cal_factory_open (
+ factory, connection, sender, uid,
+ E_SOURCE_EXTENSION_TASK_LIST, "VTODO", &error);
+
+ if (object_path != NULL) {
+ e_dbus_calendar_factory_complete_open_task_list (
+ interface, invocation, object_path);
+ g_free (object_path);
+ } else {
+ g_return_val_if_fail (error != NULL, FALSE);
+ g_dbus_method_invocation_take_error (invocation, error);
+ }
- if (error != NULL)
- g_error_free (error);
+ return TRUE;
+}
- g_free (object_path);
- g_free (uid);
+static gboolean
+data_cal_factory_handle_open_memo_list_cb (EDBusCalendarFactory *interface,
+ GDBusMethodInvocation *invocation,
+ const gchar *uid,
+ EDataCalFactory *factory)
+{
+ GDBusConnection *connection;
+ const gchar *sender;
+ gchar *object_path;
+ GError *error = NULL;
+
+ connection = g_dbus_method_invocation_get_connection (invocation);
+ sender = g_dbus_method_invocation_get_sender (invocation);
+
+ object_path = data_cal_factory_open (
+ factory, connection, sender, uid,
+ E_SOURCE_EXTENSION_MEMO_LIST, "VJOURNAL", &error);
+
+ if (object_path != NULL) {
+ e_dbus_calendar_factory_complete_open_memo_list (
+ interface, invocation, object_path);
+ g_free (object_path);
+ } else {
+ g_return_val_if_fail (error != NULL, FALSE);
+ g_dbus_method_invocation_take_error (invocation, error);
+ }
return TRUE;
}
@@ -348,9 +390,9 @@ data_cal_factory_dispose (GObject *object)
priv->registry = NULL;
}
- if (priv->gdbus_object != NULL) {
- g_object_unref (priv->gdbus_object);
- priv->gdbus_object = NULL;
+ if (priv->dbus_factory != NULL) {
+ g_object_unref (priv->dbus_factory);
+ priv->dbus_factory = NULL;
}
/* Chain up to parent's dispose() method. */
@@ -379,26 +421,23 @@ data_cal_factory_bus_acquired (EDBusServer *server,
GDBusConnection *connection)
{
EDataCalFactoryPrivate *priv;
- guint registration_id;
GError *error = NULL;
priv = E_DATA_CAL_FACTORY_GET_PRIVATE (server);
- registration_id = e_gdbus_cal_factory_register_object (
- priv->gdbus_object,
+ g_dbus_interface_skeleton_export (
+ G_DBUS_INTERFACE_SKELETON (priv->dbus_factory),
connection,
"/org/gnome/evolution/dataserver/CalendarFactory",
&error);
if (error != NULL) {
g_error (
- "Failed to register a CalendarFactory object: %s",
+ "Failed to export CalendarFactory interface: %s",
error->message);
g_assert_not_reached ();
}
- g_assert (registration_id > 0);
-
/* Chain up to parent's bus_acquired() method. */
E_DBUS_SERVER_CLASS (e_data_cal_factory_parent_class)->
bus_acquired (server, connection);
@@ -522,10 +561,23 @@ e_data_cal_factory_init (EDataCalFactory *factory)
{
factory->priv = E_DATA_CAL_FACTORY_GET_PRIVATE (factory);
- factory->priv->gdbus_object = e_gdbus_cal_factory_stub_new ();
+ factory->priv->dbus_factory =
+ e_dbus_calendar_factory_skeleton_new ();
+
+ g_signal_connect (
+ factory->priv->dbus_factory, "handle-open-calendar",
+ G_CALLBACK (data_cal_factory_handle_open_calendar_cb),
+ factory);
+
+ g_signal_connect (
+ factory->priv->dbus_factory, "handle-open-task-list",
+ G_CALLBACK (data_cal_factory_handle_open_task_list_cb),
+ factory);
+
g_signal_connect (
- factory->priv->gdbus_object, "handle-get-cal",
- G_CALLBACK (impl_CalFactory_get_cal), factory);
+ factory->priv->dbus_factory, "handle-open-memo-list",
+ G_CALLBACK (data_cal_factory_handle_open_memo_list_cb),
+ factory);
g_mutex_init (&factory->priv->calendars_lock);
factory->priv->calendars = g_hash_table_new_full (
diff --git a/calendar/libegdbus/Makefile.am b/calendar/libegdbus/Makefile.am
index 6d354c5..e0d3bf1 100644
--- a/calendar/libegdbus/Makefile.am
+++ b/calendar/libegdbus/Makefile.am
@@ -13,8 +13,6 @@ libegdbus_cal_la_CPPFLAGS = \
libegdbus_cal_la_SOURCES = \
e-gdbus-cal.h \
e-gdbus-cal.c \
- e-gdbus-cal-factory.h \
- e-gdbus-cal-factory.c \
e-gdbus-cal-view.h \
e-gdbus-cal-view.c
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]