[evolution-data-server/account-mgmt: 12/33] Adapt libedata-cal to the new ESource API.
- From: Matthew Barnes <mbarnes src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [evolution-data-server/account-mgmt: 12/33] Adapt libedata-cal to the new ESource API.
- Date: Wed, 7 Sep 2011 16:08:06 +0000 (UTC)
commit fe973367f8f27b75886d089b4cfb52ecb07cf1df
Author: Matthew Barnes <mbarnes redhat com>
Date: Sat Nov 13 15:02:02 2010 -0500
Adapt libedata-cal to the new ESource API.
calendar/libedata-cal/e-cal-backend-util.c | 150 ++++++++---
calendar/libedata-cal/e-cal-backend.c | 112 +-------
calendar/libedata-cal/e-cal-backend.h | 1 -
calendar/libedata-cal/e-data-cal-factory.c | 288 +++++++++-----------
calendar/libedata-cal/e-data-cal.xml | 6 -
.../libedata-cal/libedata-cal-sections.txt | 1 -
.../calendar/libedata-cal/tmpl/e-cal-backend.sgml | 14 -
7 files changed, 239 insertions(+), 333 deletions(-)
---
diff --git a/calendar/libedata-cal/e-cal-backend-util.c b/calendar/libedata-cal/e-cal-backend-util.c
index 4adf829..67cd6a6 100644
--- a/calendar/libedata-cal/e-cal-backend-util.c
+++ b/calendar/libedata-cal/e-cal-backend-util.c
@@ -26,9 +26,9 @@
#include <string.h>
#include <glib/gi18n-lib.h>
#include "e-cal-backend-util.h"
-#include "libedataserver/e-account-list.h"
-
-static EAccountList *accounts;
+#include <libedataserver/e-source-registry.h>
+#include <libedataserver/e-source-mail-account.h>
+#include <libedataserver/e-source-mail-identity.h>
/**
* e_cal_backend_mail_account_get_default:
@@ -43,23 +43,46 @@ gboolean
e_cal_backend_mail_account_get_default (gchar **address,
gchar **name)
{
- const EAccount *account;
+ ESource *source;
+ ESourceRegistry *registry;
+ ESourceMailAccount *mail_account;
+ ESourceMailIdentity *mail_identity;
+ const gchar *extension_name;
+ const gchar *identity_uid;
+ const gchar *value;
+
+ registry = e_source_registry_get_default ();
+ source = e_source_registry_get_default_mail_account (registry);
+
+ if (source == NULL)
+ return FALSE;
- if (accounts == NULL) {
- GConfClient *gconf = gconf_client_get_default ();
+ extension_name = E_SOURCE_EXTENSION_MAIL_ACCOUNT;
+ if (!e_source_has_extension (source, extension_name))
+ return FALSE;
- accounts = e_account_list_new (gconf);
+ mail_account = e_source_get_extension (source, extension_name);
+ identity_uid = e_source_mail_account_get_identity_uid (mail_account);
+ source = e_source_registry_lookup_by_uid (registry, identity_uid);
- g_object_unref (gconf);
- }
+ if (source == NULL)
+ return FALSE;
- account = e_account_list_get_default (accounts);
- if (account) {
- *address = g_strdup(account->id->address);
- *name = g_strdup(account->id->name);
- }
+ extension_name = E_SOURCE_EXTENSION_MAIL_IDENTITY;
+ if (!e_source_has_extension (source, extension_name))
+ return FALSE;
+
+ mail_identity = e_source_get_extension (source, extension_name);
- return account != NULL;
+ value = e_source_mail_identity_get_address (mail_identity);
+ if (address != NULL)
+ *address = g_strdup (value);
+
+ value = e_source_mail_identity_get_name (mail_identity);
+ if (name != NULL)
+ *name = g_strdup (value);
+
+ return TRUE;
}
/**
@@ -75,21 +98,62 @@ gboolean
e_cal_backend_mail_account_is_valid (gchar *user,
gchar **name)
{
- const EAccount *account;
+ ESourceRegistry *registry;
+ GList *list, *iter;
+ const gchar *extension_name;
+ gboolean valid = FALSE;
+
+ g_return_val_if_fail (user != NULL, FALSE);
+
+ registry = e_source_registry_get_default ();
+ extension_name = E_SOURCE_EXTENSION_MAIL_ACCOUNT;
- if (accounts == NULL) {
- GConfClient *gconf = gconf_client_get_default ();
+ list = e_source_registry_list_sources (registry, extension_name);
- accounts = e_account_list_new (gconf);
+ for (iter = list; iter != NULL; iter = g_list_next (iter)) {
+ ESource *source = E_SOURCE (iter->data);
+ ESourceMailAccount *mail_account;
+ ESourceMailIdentity *mail_identity;
+ const gchar *address;
+ const gchar *display_name;
+ const gchar *uid;
- g_object_unref (gconf);
+ display_name = e_source_get_display_name (source);
+
+ extension_name = E_SOURCE_EXTENSION_MAIL_ACCOUNT;
+ mail_account = e_source_get_extension (source, extension_name);
+ uid = e_source_mail_account_get_identity_uid (mail_account);
+
+ if (uid == NULL)
+ continue;
+
+ source = e_source_registry_lookup_by_uid (registry, uid);
+
+ if (source == NULL)
+ continue;
+
+ extension_name = E_SOURCE_EXTENSION_MAIL_IDENTITY;
+
+ if (!e_source_has_extension (source, extension_name))
+ continue;
+
+ mail_identity = e_source_get_extension (source, extension_name);
+ address = e_source_mail_identity_get_address (mail_identity);
+
+ if (address == NULL)
+ continue;
+
+ if (g_ascii_strcasecmp (address, user) == 0) {
+ if (name != NULL)
+ *name = g_strdup (display_name);
+ valid = TRUE;
+ break;
+ }
}
- account = e_account_list_find (accounts, E_ACCOUNT_FIND_ID_ADDRESS, user);
- if (account)
- *name = g_strdup(account->id->name);
+ g_list_free (list);
- return account != NULL;
+ return valid;
}
/**
@@ -153,35 +217,35 @@ is_attendee_declined (icalcomponent *icalcomp,
gboolean
e_cal_backend_user_declined (icalcomponent *icalcomp)
{
- gboolean res = FALSE;
- EAccountList *accounts;
- GConfClient *gconf;
+ ESourceRegistry *registry;
+ GList *list, *iter;
+ const gchar *extension_name;
+ gboolean declined = FALSE;
g_return_val_if_fail (icalcomp != NULL, FALSE);
- gconf = gconf_client_get_default ();
- accounts = e_account_list_new (gconf);
+ registry = e_source_registry_get_default ();
+ extension_name = E_SOURCE_EXTENSION_MAIL_IDENTITY;
- if (accounts) {
- EIterator *it;
+ list = e_source_registry_list_sources (registry, extension_name);
- for (it = e_list_get_iterator (E_LIST (accounts)); e_iterator_is_valid (it); e_iterator_next (it)) {
- EAccount *account = (EAccount *) e_iterator_get (it);
+ for (iter = list; iter != NULL; iter = g_list_next (iter)) {
+ ESourceMailIdentity *extension;
+ ESource *source;
+ const gchar *address;
- if (account && account->enabled && e_account_get_string (account, E_ACCOUNT_ID_ADDRESS)) {
- res = is_attendee_declined (icalcomp, e_account_get_string (account, E_ACCOUNT_ID_ADDRESS));
+ source = E_SOURCE (iter->data);
+ extension = e_source_get_extension (source, extension_name);
+ address = e_source_mail_identity_get_address (extension);
- if (res)
- break;
- }
+ if (is_attendee_declined (icalcomp, address)) {
+ declined = TRUE;
+ break;
}
-
- g_object_unref (it);
- g_object_unref (accounts);
}
- g_object_unref (gconf);
+ g_list_free (list);
- return res;
+ return declined;
}
diff --git a/calendar/libedata-cal/e-cal-backend.c b/calendar/libedata-cal/e-cal-backend.c
index b21f085..803bbe1 100644
--- a/calendar/libedata-cal/e-cal-backend.c
+++ b/calendar/libedata-cal/e-cal-backend.c
@@ -43,9 +43,6 @@ struct _ECalBackendPrivate {
gboolean opening, opened, readonly, removed, online;
- /* URI, from source. This is cached, since we return const. */
- gchar *uri;
-
gchar *cache_dir;
/* List of Cal objects */
@@ -65,8 +62,7 @@ enum {
PROP_0,
PROP_CACHE_DIR,
PROP_KIND,
- PROP_SOURCE,
- PROP_URI
+ PROP_SOURCE
};
/* Signal IDs */
@@ -82,37 +78,13 @@ static void e_cal_backend_remove_client_private (ECalBackend *backend, EDataCal
G_DEFINE_TYPE (ECalBackend, e_cal_backend, G_TYPE_OBJECT);
static void
-source_changed_cb (ESource *source,
- ECalBackend *backend)
-{
- ECalBackendPrivate *priv;
- gchar *suri;
-
- g_return_if_fail (source != NULL);
- g_return_if_fail (backend != NULL);
- g_return_if_fail (E_IS_CAL_BACKEND (backend));
-
- priv = backend->priv;
- g_return_if_fail (priv != NULL);
- g_return_if_fail (priv->source == source);
-
- suri = e_source_get_uri (priv->source);
- if (!priv->uri || (suri && !g_str_equal (priv->uri, suri))) {
- g_free (priv->uri);
- priv->uri = suri;
- } else {
- g_free (suri);
- }
-}
-
-static void
cal_backend_set_default_cache_dir (ECalBackend *backend)
{
ESource *source;
icalcomponent_kind kind;
const gchar *component_type;
const gchar *user_cache_dir;
- gchar *mangled_uri;
+ const gchar *uid;
gchar *filename;
user_cache_dir = e_get_user_cache_dir ();
@@ -120,6 +92,9 @@ cal_backend_set_default_cache_dir (ECalBackend *backend)
kind = e_cal_backend_get_kind (backend);
source = e_cal_backend_get_source (backend);
+ uid = e_source_get_uid (source);
+ g_return_if_fail (uid != NULL);
+
switch (kind) {
case ICAL_VEVENT_COMPONENT:
component_type = "calendar";
@@ -134,49 +109,20 @@ cal_backend_set_default_cache_dir (ECalBackend *backend)
g_return_if_reached ();
}
- /* Mangle the URI to not contain invalid characters. */
- mangled_uri = g_strdelimit (e_source_get_uri (source), ":/", '_');
-
filename = g_build_filename (
- user_cache_dir, component_type, mangled_uri, NULL);
+ user_cache_dir, component_type, uid, NULL);
e_cal_backend_set_cache_dir (backend, filename);
g_free (filename);
-
- g_free (mangled_uri);
}
static void
cal_backend_set_source (ECalBackend *backend,
ESource *source)
{
- if (backend->priv->source != NULL) {
- g_signal_handlers_disconnect_matched (backend->priv->source, G_SIGNAL_MATCH_FUNC | G_SIGNAL_MATCH_DATA, 0, 0, NULL, source_changed_cb, backend);
+ if (backend->priv->source != NULL)
g_object_unref (backend->priv->source);
- }
-
- if (source != NULL)
- g_signal_connect (
- g_object_ref (source), "changed",
- G_CALLBACK (source_changed_cb), backend);
backend->priv->source = source;
-
- /* Cache the URI */
- if (source != NULL) {
- g_free (backend->priv->uri);
- backend->priv->uri = e_source_get_uri (source);
- }
-}
-
-static void
-cal_backend_set_uri (ECalBackend *backend,
- const gchar *uri)
-{
- /* ESource's URI gets priority. */
- if (backend->priv->source == NULL) {
- g_free (backend->priv->uri);
- backend->priv->uri = g_strdup (uri);
- }
}
static void
@@ -251,11 +197,6 @@ cal_backend_set_property (GObject *object,
E_CAL_BACKEND (object),
g_value_get_object (value));
return;
- case PROP_URI:
- cal_backend_set_uri (
- E_CAL_BACKEND (object),
- g_value_get_string (value));
- return;
}
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
@@ -283,11 +224,6 @@ cal_backend_get_property (GObject *object,
value, e_cal_backend_get_source (
E_CAL_BACKEND (object)));
return;
- case PROP_URI:
- g_value_set_string (
- value, e_cal_backend_get_uri (
- E_CAL_BACKEND (object)));
- return;
}
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
@@ -309,13 +245,9 @@ cal_backend_finalize (GObject *object)
g_mutex_free (priv->clients_mutex);
g_mutex_free (priv->views_mutex);
- g_free (priv->uri);
g_free (priv->cache_dir);
- if (priv->source) {
- g_signal_handlers_disconnect_matched (priv->source, G_SIGNAL_MATCH_DATA, 0, 0, NULL, NULL, object);
- g_object_unref (priv->source);
- }
+ g_object_unref (priv->source);
/* Chain up to parent's finalize() method. */
G_OBJECT_CLASS (e_cal_backend_parent_class)->finalize (object);
@@ -379,17 +311,6 @@ e_cal_backend_class_init (ECalBackendClass *klass)
G_PARAM_READWRITE |
G_PARAM_CONSTRUCT_ONLY));
- g_object_class_install_property (
- object_class,
- PROP_URI,
- g_param_spec_string (
- "uri",
- NULL,
- NULL,
- "",
- G_PARAM_READWRITE |
- G_PARAM_CONSTRUCT_ONLY));
-
signals[LAST_CLIENT_GONE] = g_signal_new (
"last_client_gone",
G_TYPE_FROM_CLASS (klass),
@@ -433,23 +354,6 @@ e_cal_backend_get_source (ECalBackend *backend)
}
/**
- * e_cal_backend_get_uri:
- * @backend: an #ECalBackend
- *
- * Queries the URI of a calendar backend, which must already have an open
- * calendar.
- *
- * Returns: The URI where the calendar is stored.
- **/
-const gchar *
-e_cal_backend_get_uri (ECalBackend *backend)
-{
- g_return_val_if_fail (E_IS_CAL_BACKEND (backend), NULL);
-
- return backend->priv->uri;
-}
-
-/**
* e_cal_backend_get_kind:
* @backend: an #ECalBackend
*
diff --git a/calendar/libedata-cal/e-cal-backend.h b/calendar/libedata-cal/e-cal-backend.h
index 75721f6..8e57802 100644
--- a/calendar/libedata-cal/e-cal-backend.h
+++ b/calendar/libedata-cal/e-cal-backend.h
@@ -173,7 +173,6 @@ struct _ECalBackendClass {
GType e_cal_backend_get_type (void);
ESource * e_cal_backend_get_source (ECalBackend *backend);
-const gchar * e_cal_backend_get_uri (ECalBackend *backend);
icalcomponent_kind e_cal_backend_get_kind (ECalBackend *backend);
gboolean e_cal_backend_is_online (ECalBackend *backend);
gboolean e_cal_backend_is_opened (ECalBackend *backend);
diff --git a/calendar/libedata-cal/e-data-cal-factory.c b/calendar/libedata-cal/e-data-cal-factory.c
index 4413341..dd2d947 100644
--- a/calendar/libedata-cal/e-data-cal-factory.c
+++ b/calendar/libedata-cal/e-data-cal-factory.c
@@ -40,11 +40,11 @@
#endif
#endif
-#include <libedataserver/e-url.h>
-#include <libedataserver/e-source-list.h>
+#include <libedataserver/e-source-registry.h>
#include <libebackend/e-data-server-module.h>
#include <libebackend/e-offline-listener.h>
#include <libecal/e-cal-client.h>
+#include <libecal/e-source-calendar.h>
#include "e-cal-backend.h"
#include "e-cal-backend-factory.h"
#include "e-data-cal.h"
@@ -106,9 +106,6 @@ struct _EDataCalFactoryPrivate {
gboolean is_online;
- /* this is for notifications of source changes */
- ESourceList *lists[E_CAL_CLIENT_SOURCE_TYPE_LAST];
-
/* backends divided by their type */
GList *backends_by_type[E_CAL_CLIENT_SOURCE_TYPE_LAST];
@@ -179,64 +176,6 @@ icalkind_to_ecalclientsourcetype (const icalcomponent_kind kind)
return E_CAL_CLIENT_SOURCE_TYPE_LAST;
}
-static void
-update_source_in_backend (ECalBackend *backend,
- ESource *updated_source)
-{
- ESource *backend_source;
- xmlNodePtr xml;
-
- g_return_if_fail (backend != NULL);
- g_return_if_fail (updated_source != NULL);
-
- backend_source = e_cal_backend_get_source (backend);
-
- xml = xmlNewNode (NULL, (const xmlChar *) "dummy");
- e_source_dump_to_xml_node (updated_source, xml);
- e_source_update_from_xml_node (backend_source, xml->children, NULL);
- xmlFreeNode (xml);
-}
-
-static void
-source_list_changed_cb (ESourceList *list,
- EDataCalFactory *factory)
-{
- EDataCalFactoryPrivate *priv;
- gint i;
-
- g_return_if_fail (list != NULL);
- g_return_if_fail (E_IS_DATA_CAL_FACTORY (factory));
-
- priv = factory->priv;
-
- g_mutex_lock (priv->backends_mutex);
-
- for (i = 0; i < E_CAL_CLIENT_SOURCE_TYPE_LAST; i++) {
- GList *iter;
-
- if (list != priv->lists[i])
- continue;
-
- for (iter = priv->backends_by_type[i]; iter; iter = iter->next) {
- ECalBackend *backend = iter->data;
- ESource *source, *list_source;
- const gchar *uid;
-
- source = e_cal_backend_get_source (backend);
- uid = e_source_peek_uid (source);
- list_source = e_source_list_peek_source_by_uid (
- priv->lists[i], uid);
-
- if (list_source != NULL)
- update_source_in_backend (backend, list_source);
- }
-
- break;
- }
-
- g_mutex_unlock (priv->backends_mutex);
-}
-
static ECalBackendFactory *
get_backend_factory (GHashTable *methods,
const gchar *method,
@@ -330,33 +269,6 @@ struct find_backend_data {
icalcomponent_kind kind;
};
-static void
-find_backend_cb (gpointer key,
- gpointer value,
- gpointer data)
-{
- struct find_backend_data *fbd = data;
-
- if (fbd && fbd->str_uri && !fbd->backend) {
- ECalBackend *backend = value;
- ESource *backend_source;
- gchar *str_uri;
-
- backend_source = e_cal_backend_get_source (backend);
- str_uri = e_source_get_uri (backend_source);
-
- if (str_uri && g_str_equal (str_uri, fbd->str_uri)) {
- const gchar *uid_kind = key, *pos;
-
- pos = strrchr (uid_kind, ':');
- if (pos && atoi (pos + 1) == fbd->kind)
- fbd->backend = backend;
- }
-
- g_free (str_uri);
- }
-}
-
static gboolean
impl_CalFactory_get_cal (EGdbusCalFactory *object,
GDBusMethodInvocation *invocation,
@@ -368,21 +280,21 @@ impl_CalFactory_get_cal (EGdbusCalFactory *object,
EDataCalFactoryPrivate *priv = factory->priv;
ECalBackendFactory *backend_factory;
GDBusConnection *connection;
+ ESourceRegistry *registry;
ESource *source;
- gchar *str_uri;
- EUri *uri;
gchar *uid_type_string;
gchar *path = NULL;
+ const gchar *backend_name;
const gchar *sender;
GList *list;
GError *error = NULL;
- gchar *source_xml = NULL;
+ gchar *uid = NULL;
guint type = 0;
sender = g_dbus_method_invocation_get_sender (invocation);
connection = g_dbus_method_invocation_get_connection (invocation);
- if (!e_gdbus_cal_factory_decode_get_cal (in_source_type, &source_xml, &type)) {
+ 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);
@@ -391,60 +303,61 @@ impl_CalFactory_get_cal (EGdbusCalFactory *object,
return TRUE;
}
- source = e_source_new_from_standalone_xml (source_xml);
- if (!source) {
- g_free (source_xml);
-
- error = g_error_new (
- E_DATA_CAL_ERROR, NoSuchCal, _("Invalid source"));
+ if (uid == NULL || *uid == '\0') {
+ error = g_error_new_literal (
+ 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;
}
- g_free (source_xml);
+ /* Remove a pending exit */
+ if (priv->exit_timeout) {
+ g_source_remove (priv->exit_timeout);
+ priv->exit_timeout = 0;
+ }
- /* Get the URI so we can extract the protocol */
- str_uri = e_source_get_uri (source);
- if (!str_uri) {
- g_object_unref (source);
+ registry = e_source_registry_get_default ();
+ source = e_source_registry_lookup_by_uid (registry, uid);
+ if (source == NULL) {
error = g_error_new (
- E_DATA_CAL_ERROR, NoSuchCal, _("Empty URI"));
+ 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;
}
- /* Parse the uri */
- uri = e_uri_new (str_uri);
- if (!uri) {
- g_object_unref (source);
- g_free (str_uri);
-
+ backend_name = e_source_get_backend_name (source);
+ if (backend_name == NULL || *backend_name == '\0') {
error = g_error_new (
- E_DATA_CAL_ERROR, NoSuchCal, _("Invalid URI"));
+ E_DATA_CAL_ERROR, NoSuchCal,
+ _("No backend specified in source UID '%s'"), uid);
g_dbus_method_invocation_return_gerror (invocation, error);
g_error_free (error);
+ g_free (uid);
return TRUE;
}
uid_type_string = g_strdup_printf (
- "%s:%d", e_source_peek_uid (source),
- (gint) calobjtype_to_icalkind (type));
+ "%s:%d", uid, (gint) calobjtype_to_icalkind (type));
/* Find the associated backend factory (if any) */
backend_factory = get_backend_factory (
- priv->methods, uri->protocol,
+ priv->methods, backend_name,
calobjtype_to_icalkind (type));
if (!backend_factory) {
error = g_error_new (
E_DATA_CAL_ERROR, NoSuchCal,
_("No backend factory for '%s' of '%s'"),
- uri->protocol, calobjtype_to_string (type));
+ backend_name, calobjtype_to_string (type));
goto cleanup2;
}
@@ -456,28 +369,7 @@ impl_CalFactory_get_cal (EGdbusCalFactory *object,
factory->priv->backends, uid_type_string);
if (!backend) {
- /* Find backend by URL, if opened, thus functions like
- * e_cal_system_new_* will not create new backends for
- * the same URL. */
- struct find_backend_data fbd;
-
- fbd.str_uri = str_uri;
- fbd.kind = calobjtype_to_icalkind (type);
- fbd.backend = NULL;
-
- g_hash_table_foreach (priv->backends, find_backend_cb, &fbd);
-
- if (fbd.backend) {
- backend = fbd.backend;
- g_object_unref (source);
- source = e_cal_backend_get_source (backend);
- g_object_ref (source);
- }
- }
-
- if (!backend) {
ECalClientSourceType st;
- icalcomponent_kind kind;
/* There was no existing backend, create a new one */
backend = e_cal_backend_factory_new_backend (
@@ -490,21 +382,11 @@ impl_CalFactory_get_cal (EGdbusCalFactory *object,
goto cleanup;
}
- kind = e_cal_backend_get_kind (backend);
- st = icalkind_to_ecalclientsourcetype (kind);
+ st = icalkind_to_ecalclientsourcetype (
+ e_cal_backend_get_kind (backend));
if (st != E_CAL_CLIENT_SOURCE_TYPE_LAST) {
- if (!priv->lists[st] &&
- e_cal_client_get_sources (
- &(priv->lists[st]), st, NULL)) {
- g_signal_connect (
- priv->lists[st], "changed",
- G_CALLBACK (source_list_changed_cb),
- factory);
- }
-
- if (priv->lists[st])
- priv->backends_by_type[st] = g_list_prepend (
- priv->backends_by_type[st], backend);
+ priv->backends_by_type[st] = g_list_prepend (
+ priv->backends_by_type[st], backend);
}
/* Track the backend */
@@ -515,9 +397,6 @@ impl_CalFactory_get_cal (EGdbusCalFactory *object,
backend, "last-client-gone",
G_CALLBACK (last_client_gone_cb), factory);
e_cal_backend_set_online (backend, priv->is_online);
- } else if (!e_source_equal (source, e_cal_backend_get_source (backend))) {
- /* source changed, update it in a backend */
- update_source_in_backend (backend, source);
}
/* Remove a pending exit */
@@ -549,10 +428,8 @@ cleanup:
g_mutex_unlock (priv->backends_mutex);
cleanup2:
- g_free (str_uri);
- e_uri_free (uri);
g_free (uid_type_string);
- g_object_unref (source);
+ g_free (uid);
e_gdbus_cal_factory_complete_get_cal (object, invocation, path, error);
@@ -605,11 +482,6 @@ e_data_cal_factory_dispose (GObject *object)
}
for (ii = 0; ii < E_CAL_CLIENT_SOURCE_TYPE_LAST; ii++) {
- if (priv->lists[ii] != NULL) {
- g_object_unref (priv->lists[ii]);
- priv->lists[ii] = NULL;
- }
-
g_list_free (priv->backends_by_type[ii]);
priv->backends_by_type[ii] = NULL;
}
@@ -988,6 +860,68 @@ handle_term_signal (gpointer data)
#endif
#endif
+static void
+source_load_error (ESourceRegistry *registry,
+ GFile *file,
+ const GError *error)
+{
+ gchar *basename;
+
+ basename = g_file_get_basename (file);
+ g_critical ("Failed to load source '%s': %s", basename, error->message);
+ g_free (basename);
+}
+
+static void
+source_added (ESourceRegistry *registry,
+ ESource *source,
+ EDataCalFactory *factory)
+{
+ const gchar *display_name;
+ const gchar *uid;
+
+ uid = e_source_get_uid (source);
+ display_name = e_source_get_display_name (source);
+
+ g_message ("Source '%s' added (uid:%s)", display_name, uid);
+}
+
+static void
+source_removed (ESourceRegistry *registry,
+ ESource *source,
+ EDataCalFactory *factory)
+{
+ ECalBackend *backend;
+ const gchar *display_name;
+ const gchar *uid;
+#if 0 /* ACCOUNT_MGMT */
+ GError *error = NULL;
+#endif /* ACCOUNT_MGMT */
+
+ uid = e_source_get_uid (source);
+ display_name = e_source_get_display_name (source);
+
+ g_message ("Source '%s' removed (uid:%s)", display_name, uid);
+
+ backend = g_hash_table_lookup (factory->priv->backends, uid);
+
+ if (backend == NULL) {
+ g_message ("No corresponding backend found");
+ return;
+ }
+
+ g_message ("Notifying backend of removal");
+
+#if 0 /* ACCOUNT_MGMT */
+ if (e_cal_backend_remove (backend, &error))
+ g_message ("Backend cleanup was successful");
+ else {
+ g_message ("Backend cleanup failed: %s", error->message);
+ g_error_free (error);
+ }
+#endif /* ACCOUNT_MGMT */
+}
+
static GOptionEntry entries[] = {
/* FIXME Have the description translated for 3.2, but this
@@ -1005,6 +939,7 @@ main (gint argc,
EOfflineListener *eol;
GOptionContext *context;
EDataCalFactory *factory;
+ ESourceRegistry *registry;
guint owner_id;
GError *error = NULL;
@@ -1057,8 +992,32 @@ main (gint argc,
ical_set_unknown_token_handling_setting (ICAL_DISCARD_TOKEN);
#endif
+ /* Register ESource extensions we'll need. */
+ E_TYPE_SOURCE_CALENDAR;
+ E_TYPE_SOURCE_MEMO_LIST;
+ E_TYPE_SOURCE_TASK_LIST;
+
+ registry = e_source_registry_get_default ();
factory = g_object_new (E_TYPE_DATA_CAL_FACTORY, NULL);
+ g_signal_connect (
+ registry, "load-error",
+ G_CALLBACK (source_load_error), NULL);
+
+ g_signal_connect (
+ registry, "source-added",
+ G_CALLBACK (source_added), factory);
+
+ g_signal_connect (
+ registry, "source-removed",
+ G_CALLBACK (source_removed), factory);
+
+ /* Failure here is fatal. Don't even try to keep going. */
+ if (!e_source_registry_load_sources (registry, &error)) {
+ g_error ("%s", error->message);
+ g_assert_not_reached ();
+ }
+
loop = g_main_loop_new (NULL, FALSE);
eol = e_offline_listener_new ();
@@ -1070,7 +1029,8 @@ main (gint argc,
owner_id = g_bus_own_name (
G_BUS_TYPE_SESSION,
CALENDAR_DBUS_SERVICE_NAME,
- G_BUS_NAME_OWNER_FLAGS_REPLACE | G_BUS_NAME_OWNER_FLAGS_ALLOW_REPLACEMENT,
+ G_BUS_NAME_OWNER_FLAGS_REPLACE |
+ G_BUS_NAME_OWNER_FLAGS_ALLOW_REPLACEMENT,
on_bus_acquired,
on_name_acquired,
on_name_lost,
diff --git a/calendar/libedata-cal/e-data-cal.xml b/calendar/libedata-cal/e-data-cal.xml
index 95717d9..f30a254 100644
--- a/calendar/libedata-cal/e-data-cal.xml
+++ b/calendar/libedata-cal/e-data-cal.xml
@@ -18,12 +18,6 @@
<arg name="mode" type="i"/>
</signal>
- <method name="getUri">
- <annotation name="org.freedesktop.DBus.GLib.CSymbol" value="impl_Cal_get_uri"/>
- <annotation name="org.freedesktop.DBus.GLib.Async" value=""/>
- <arg name="str_uri_copy" type="s" direction="out"/>
- </method>
-
<method name="getCacheDir">
<annotation name="org.freedesktop.DBus.GLib.CSymbol" value="impl_Cal_getCacheDir"/>
<annotation name="org.freedesktop.DBus.GLib.Async" value=""/>
diff --git a/docs/reference/calendar/libedata-cal/libedata-cal-sections.txt b/docs/reference/calendar/libedata-cal/libedata-cal-sections.txt
index 81f0c47..77efac9 100644
--- a/docs/reference/calendar/libedata-cal/libedata-cal-sections.txt
+++ b/docs/reference/calendar/libedata-cal/libedata-cal-sections.txt
@@ -12,7 +12,6 @@ CAL_BACKEND_PROPERTY_CAL_EMAIL_ADDRESS
CAL_BACKEND_PROPERTY_ALARM_EMAIL_ADDRESS
CAL_BACKEND_PROPERTY_DEFAULT_OBJECT
e_cal_backend_get_source
-e_cal_backend_get_uri
e_cal_backend_get_kind
e_cal_backend_is_online
e_cal_backend_is_opened
diff --git a/docs/reference/calendar/libedata-cal/tmpl/e-cal-backend.sgml b/docs/reference/calendar/libedata-cal/tmpl/e-cal-backend.sgml
index 2ca7f1e..cc08ab8 100644
--- a/docs/reference/calendar/libedata-cal/tmpl/e-cal-backend.sgml
+++ b/docs/reference/calendar/libedata-cal/tmpl/e-cal-backend.sgml
@@ -48,11 +48,6 @@ Base class for calendar/tasks backend implementations.
</para>
-<!-- ##### ARG ECalBackend:uri ##### -->
-<para>
-
-</para>
-
<!-- ##### MACRO CLIENT_BACKEND_PROPERTY_OPENED ##### -->
<para>
@@ -125,15 +120,6 @@ Base class for calendar/tasks backend implementations.
@Returns:
-<!-- ##### FUNCTION e_cal_backend_get_uri ##### -->
-<para>
-
-</para>
-
- backend:
- Returns:
-
-
<!-- ##### FUNCTION e_cal_backend_get_kind ##### -->
<para>
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]