Remove ESourceList. Breaks build.
authorMatthew Barnes <mbarnes@redhat.com>
Fri, 12 Nov 2010 14:42:37 +0000 (09:42 -0500)
committerMatthew Barnes <mbarnes@redhat.com>
Sun, 3 Jun 2012 23:51:07 +0000 (19:51 -0400)
docs/reference/libedataserver/libedataserver-docs.sgml
docs/reference/libedataserver/libedataserver-sections.txt
docs/reference/libedataserver/libedataserver.types
libedataserver/Makefile.am
libedataserver/e-source-list.c [deleted file]
libedataserver/e-source-list.h [deleted file]
tests/libedataserver/test-source-list.c [deleted file]

index 7a6d968..ce12c56 100644 (file)
@@ -26,7 +26,6 @@
     <xi:include href="xml/e-sexp.xml"/>
     <xi:include href="xml/e-source.xml"/>
     <xi:include href="xml/e-source-group.xml"/>
-    <xi:include href="xml/e-source-list.xml"/>
     <xi:include href="xml/e-time-utils.xml"/>
     <xi:include href="xml/e-uid.xml"/>
     <xi:include href="xml/e-util.xml"/>
index e666219..2c034b5 100644 (file)
@@ -345,41 +345,6 @@ e_source_group_get_type
 </SECTION>
 
 <SECTION>
-<FILE>e-source-list</FILE>
-<TITLE>ESourceList</TITLE>
-ESourceList
-e_source_list_new
-e_source_list_new_for_gconf
-e_source_list_new_for_gconf_default
-e_source_list_peek_groups
-e_source_list_peek_group_by_uid
-e_source_list_peek_group_by_base_uri
-e_source_list_peek_group_by_properties
-e_source_list_peek_source_by_uid
-e_source_list_peek_source_any
-e_source_list_peek_default_source
-e_source_list_add_group
-e_source_list_remove_group
-e_source_list_remove_group_by_uid
-e_source_list_ensure_group
-e_source_list_remove_group_by_base_uri
-e_source_list_remove_source_by_uid
-e_source_list_sync
-e_source_list_is_gconf_updated
-<SUBSECTION Standard>
-E_SOURCE_LIST
-E_IS_SOURCE_LIST
-E_TYPE_SOURCE_LIST
-E_SOURCE_LIST_CLASS
-E_IS_SOURCE_LIST_CLASS
-E_SOURCE_LIST_GET_CLASS
-ESourceListClass
-<SUBSECTION Private>
-ESourceListPrivate
-e_source_list_get_type
-</SECTION>
-
-<SECTION>
 <FILE>e-source</FILE>
 <TITLE>ESource</TITLE>
 ESource
index e6aea8a..0f8f158 100644 (file)
@@ -7,7 +7,6 @@
 #include <libedataserver/e-proxy.h>
 #include <libedataserver/e-source.h>
 #include <libedataserver/e-source-group.h>
-#include <libedataserver/e-source-list.h>
 
 e_account_get_type
 e_account_list_get_type
@@ -18,4 +17,3 @@ e_list_iterator_get_type
 e_proxy_get_type
 e_source_get_type
 e_source_group_get_type
-e_source_list_get_type
index 564661e..e1a15dd 100644 (file)
@@ -39,7 +39,6 @@ libedataserver_1_2_la_SOURCES =               \
        e-proxy.c                       \
        e-sexp.c                        \
        e-source-group.c                \
-       e-source-list.c                 \
        e-source.c                      \
        e-debug-log.c                   \
        e-time-utils.c                  \
@@ -82,7 +81,6 @@ libedataserverinclude_HEADERS =               \
        e-proxy.h                       \
        e-sexp.h                        \
        e-source-group.h                \
-       e-source-list.h                 \
        e-source.h                      \
        e-debug-log.h                   \
        e-time-utils.h                  \
diff --git a/libedataserver/e-source-list.c b/libedataserver/e-source-list.c
deleted file mode 100644 (file)
index 0ca8f2e..0000000
+++ /dev/null
@@ -1,1017 +0,0 @@
-/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 8; tab-width: 8 -*- */
-/* e-source-list.c
- *
- * 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: Ettore Perazzoli <ettore@ximian.com>
- */
-
-#ifdef HAVE_CONFIG_H
-#include <config.h>
-#endif
-
-#include <string.h>
-#include "e-source-list.h"
-
-#define E_SOURCE_LIST_GET_PRIVATE(obj) \
-       (G_TYPE_INSTANCE_GET_PRIVATE \
-       ((obj), E_TYPE_SOURCE_LIST, ESourceListPrivate))
-
-struct _ESourceListPrivate {
-       GConfClient *gconf_client;
-       gchar *gconf_path;
-
-       gint gconf_notify_id;
-
-       GSList *groups;
-
-       gboolean ignore_group_changed;
-       gint sync_idle_id;
-};
-
-/* Signals.  */
-
-enum {
-       CHANGED,
-       GROUP_REMOVED,
-       GROUP_ADDED,
-       LAST_SIGNAL
-};
-static guint signals[LAST_SIGNAL] = { 0 };
-
-/* Forward declarations.  */
-
-static gboolean  sync_idle_callback      (ESourceList  *list);
-static void      group_changed_callback  (ESourceGroup *group,
-                                         ESourceList  *list);
-static void      conf_changed_callback   (GConfClient  *client,
-                                         guint  connection_id,
-                                         GConfEntry   *entry,
-                                         ESourceList  *list);
-
-/* Utility functions.  */
-
-static void
-load_from_gconf (ESourceList *list)
-{
-       GSList *conf_list, *p, *q;
-       GSList *new_groups_list;
-       GHashTable *new_groups_hash;
-       gboolean changed = FALSE;
-       gint pos;
-
-       conf_list = gconf_client_get_list (list->priv->gconf_client,
-                                          list->priv->gconf_path,
-                                          GCONF_VALUE_STRING, NULL);
-
-       new_groups_list = NULL;
-       new_groups_hash = g_hash_table_new (g_direct_hash, g_direct_equal);
-
-       for (p = conf_list, pos = 0; p != NULL; p = p->next, pos++) {
-               const xmlChar *xml = p->data;
-               xmlDocPtr xmldoc;
-               gchar *group_uid;
-               ESourceGroup *existing_group;
-
-               xmldoc = xmlParseDoc (xml);
-               if (xmldoc == NULL)
-                       continue;
-
-               group_uid = e_source_group_uid_from_xmldoc (xmldoc);
-               if (group_uid == NULL) {
-                       xmlFreeDoc (xmldoc);
-                       continue;
-               }
-
-               existing_group = e_source_list_peek_group_by_uid (list, group_uid);
-               if (g_hash_table_lookup (new_groups_hash, existing_group) != NULL) {
-                       xmlFreeDoc (xmldoc);
-                       g_free (group_uid);
-                       continue;
-               }
-
-               if (existing_group == NULL) {
-                       ESourceGroup *new_group = e_source_group_new_from_xmldoc (xmldoc);
-
-                       if (new_group != NULL) {
-                               g_signal_connect (new_group, "changed", G_CALLBACK (group_changed_callback), list);
-                               new_groups_list = g_slist_prepend (new_groups_list, new_group);
-
-                               g_hash_table_insert (new_groups_hash, new_group, new_group);
-                               g_signal_emit (list, signals[GROUP_ADDED], 0, new_group);
-                               changed = TRUE;
-                       }
-               } else {
-                       gboolean group_changed;
-
-                       list->priv->ignore_group_changed++;
-
-                       if (e_source_group_update_from_xmldoc (existing_group, xmldoc, &group_changed)) {
-                               new_groups_list = g_slist_prepend (new_groups_list, existing_group);
-                               g_object_ref (existing_group);
-                               g_hash_table_insert (new_groups_hash, existing_group, existing_group);
-
-                               if (group_changed)
-                                       changed = TRUE;
-                       }
-
-                       list->priv->ignore_group_changed--;
-               }
-
-               xmlFreeDoc (xmldoc);
-               g_free (group_uid);
-       }
-
-       new_groups_list = g_slist_reverse (new_groups_list);
-
-       g_slist_foreach (conf_list, (GFunc) g_free, NULL);
-       g_slist_free (conf_list);
-
-       /* Emit "group_removed" and disconnect the "changed" signal for all the
-        * groups that we haven't found in the new list.  Also, check if the
-        * order has changed.  */
-       q = new_groups_list;
-       for (p = list->priv->groups; p != NULL; p = p->next) {
-               ESourceGroup *group = E_SOURCE_GROUP (p->data);
-
-               if (g_hash_table_lookup (new_groups_hash, group) == NULL) {
-                       changed = TRUE;
-                       g_signal_emit (list, signals[GROUP_REMOVED], 0, group);
-                       g_signal_handlers_disconnect_by_func (group, group_changed_callback, list);
-               }
-
-               if (!changed && q != NULL) {
-                       if (q->data != p->data)
-                               changed = TRUE;
-                       q = q->next;
-               }
-       }
-
-       g_hash_table_destroy (new_groups_hash);
-
-       /* Replace the original group list with the new one.  */
-
-       g_slist_foreach (list->priv->groups, (GFunc) g_object_unref, NULL);
-       g_slist_free (list->priv->groups);
-
-       list->priv->groups = new_groups_list;
-
-       /* FIXME if the order changes, the function doesn't notice.  */
-
-       if (changed)
-               g_signal_emit (list, signals[CHANGED], 0);
-}
-
-static void
-remove_group (ESourceList *list,
-              ESourceGroup *group)
-{
-       list->priv->groups = g_slist_remove (list->priv->groups, group);
-
-       g_signal_emit (list, signals[GROUP_REMOVED], 0, group);
-       g_object_unref (group);
-
-       g_signal_emit (list, signals[CHANGED], 0);
-}
-
-/* Callbacks.  */
-
-static gboolean
-sync_idle_callback (ESourceList *list)
-{
-       GError *error = NULL;
-
-       g_return_val_if_fail (E_IS_SOURCE_LIST (list), FALSE);
-
-       g_object_ref (list);
-       if (!e_source_list_sync (list, &error)) {
-               g_warning ("Cannot update \"%s\": %s", list->priv->gconf_path, error ? error->message : "Unknown error");
-               g_error_free (error);
-       }
-
-       list->priv->sync_idle_id= 0;
-       g_object_unref (list);
-
-       return FALSE;
-}
-
-static void
-group_changed_callback (ESourceGroup *group,
-                        ESourceList *list)
-{
-       g_return_if_fail (E_IS_SOURCE_LIST (list));
-
-       g_object_ref (list);
-
-       if (!list->priv->ignore_group_changed)
-               g_signal_emit (list, signals[CHANGED], 0);
-
-       if (list->priv->sync_idle_id == 0)
-               list->priv->sync_idle_id = g_idle_add ((GSourceFunc) sync_idle_callback, list);
-
-       g_object_unref (list);
-}
-
-static void
-conf_changed_callback (GConfClient *client,
-                       guint connection_id,
-                       GConfEntry *entry,
-                       ESourceList *list)
-{
-       g_return_if_fail (E_IS_SOURCE_LIST (list));
-
-       g_object_ref (list);
-       load_from_gconf (list);
-       g_object_unref (list);
-}
-
-/* GObject methods.  */
-
-G_DEFINE_TYPE (ESourceList, e_source_list, G_TYPE_OBJECT)
-
-static void
-source_list_dispose (GObject *object)
-{
-       ESourceListPrivate *priv;
-
-       priv = E_SOURCE_LIST_GET_PRIVATE (object);
-
-       if (priv->gconf_client != NULL && priv->gconf_notify_id != 0) {
-               gconf_client_notify_remove (priv->gconf_client, priv->gconf_notify_id);
-               priv->gconf_notify_id = 0;
-       }
-
-       if (priv->sync_idle_id != 0) {
-               GError *error = NULL;
-
-               g_source_remove (priv->sync_idle_id);
-               priv->sync_idle_id = 0;
-
-               if (!e_source_list_sync (E_SOURCE_LIST (object), &error))
-                       g_warning ("Could not update \"%s\": %s",
-                                  priv->gconf_path, error->message);
-       }
-
-       if (priv->groups != NULL) {
-               GSList *p;
-
-               for (p = priv->groups; p != NULL; p = p->next)
-                       g_object_unref (p->data);
-
-               g_slist_free (priv->groups);
-               priv->groups = NULL;
-       }
-
-       if (priv->gconf_client != NULL) {
-               g_object_unref (priv->gconf_client);
-               priv->gconf_client = NULL;
-       }
-
-       /* Chain up to parent's dispose() method. */
-       G_OBJECT_CLASS (e_source_list_parent_class)->dispose (object);
-}
-
-static void
-source_list_finalize (GObject *object)
-{
-       ESourceListPrivate *priv;
-
-       priv = E_SOURCE_LIST_GET_PRIVATE (object);
-
-       g_free (priv->gconf_path);
-
-       /* Chain up to parent's finalize() method. */
-       G_OBJECT_CLASS (e_source_list_parent_class)->finalize (object);
-}
-
-/* Initialization.  */
-
-static void
-e_source_list_class_init (ESourceListClass *class)
-{
-       GObjectClass *object_class;
-
-       g_type_class_add_private (class, sizeof (ESourceListPrivate));
-
-       object_class = G_OBJECT_CLASS (class);
-       object_class->dispose  = source_list_dispose;
-       object_class->finalize = source_list_finalize;
-
-       signals[CHANGED] = g_signal_new (
-               "changed",
-               G_OBJECT_CLASS_TYPE (object_class),
-               G_SIGNAL_RUN_LAST,
-               G_STRUCT_OFFSET (ESourceListClass, changed),
-               NULL, NULL,
-               g_cclosure_marshal_VOID__VOID,
-               G_TYPE_NONE, 0);
-
-       signals[GROUP_REMOVED] = g_signal_new (
-               "group_removed",
-               G_OBJECT_CLASS_TYPE (object_class),
-               G_SIGNAL_RUN_LAST,
-               G_STRUCT_OFFSET (ESourceListClass, group_removed),
-               NULL, NULL,
-               g_cclosure_marshal_VOID__OBJECT,
-               G_TYPE_NONE, 1,
-               E_TYPE_SOURCE_GROUP);
-
-       signals[GROUP_ADDED] = g_signal_new (
-               "group_added",
-               G_OBJECT_CLASS_TYPE (object_class),
-               G_SIGNAL_RUN_LAST,
-               G_STRUCT_OFFSET (ESourceListClass, group_added),
-               NULL, NULL,
-               g_cclosure_marshal_VOID__OBJECT,
-               G_TYPE_NONE, 1,
-               E_TYPE_SOURCE_GROUP);
-}
-
-static void
-e_source_list_init (ESourceList *source_list)
-{
-       source_list->priv = E_SOURCE_LIST_GET_PRIVATE (source_list);
-}
-
-/* Public methods.  */
-
-ESourceList *
-e_source_list_new (void)
-{
-       ESourceList *list = g_object_new (e_source_list_get_type (), NULL);
-
-       return list;
-}
-
-ESourceList *
-e_source_list_new_for_gconf (GConfClient *client,
-                             const gchar *path)
-{
-       ESourceList *list;
-
-       g_return_val_if_fail (GCONF_IS_CLIENT (client), NULL);
-       g_return_val_if_fail (path != NULL, NULL);
-
-       list = g_object_new (e_source_list_get_type (), NULL);
-
-       list->priv->gconf_path = g_strdup (path);
-       list->priv->gconf_client = client;
-       g_object_ref (client);
-
-       gconf_client_add_dir (client, path, GCONF_CLIENT_PRELOAD_ONELEVEL, NULL);
-
-       list->priv->gconf_notify_id
-               = gconf_client_notify_add (client, path,
-                                          (GConfClientNotifyFunc) conf_changed_callback, list,
-                                          NULL, NULL);
-       load_from_gconf (list);
-
-       return list;
-}
-
-ESourceList *
-e_source_list_new_for_gconf_default (const gchar *path)
-{
-       ESourceList *list;
-
-       g_return_val_if_fail (path != NULL, NULL);
-
-       list = g_object_new (e_source_list_get_type (), NULL);
-
-       list->priv->gconf_path = g_strdup (path);
-       list->priv->gconf_client = gconf_client_get_default ();
-
-       gconf_client_add_dir (list->priv->gconf_client, path, GCONF_CLIENT_PRELOAD_ONELEVEL, NULL);
-
-       list->priv->gconf_notify_id
-               = gconf_client_notify_add (list->priv->gconf_client, path,
-                                          (GConfClientNotifyFunc) conf_changed_callback, list,
-                                          NULL, NULL);
-       load_from_gconf (list);
-
-       return list;
-}
-
-/**
- * e_source_list_peek_groups:
- *
- * Return value: (transfer none) (element-type ESourceGroup):
- */
-GSList *
-e_source_list_peek_groups (ESourceList *list)
-{
-       g_return_val_if_fail (E_IS_SOURCE_LIST (list), NULL);
-
-       return list->priv->groups;
-}
-
-/**
- * e_source_list_peek_group_by_uid:
- *
- * Return value: (transfer none): the #ESourceGroup
- */
-ESourceGroup *
-e_source_list_peek_group_by_uid (ESourceList *list,
-                                 const gchar *uid)
-{
-       GSList *p;
-
-       g_return_val_if_fail (E_IS_SOURCE_LIST (list), NULL);
-       g_return_val_if_fail (uid != NULL, NULL);
-
-       for (p = list->priv->groups; p != NULL; p = p->next) {
-               ESourceGroup *group = E_SOURCE_GROUP (p->data);
-
-               if (strcmp (e_source_group_peek_uid (group), uid) == 0)
-                       return group;
-       }
-
-       return NULL;
-}
-
-/**
- * e_source_list_peek_group_by_base_uri:
- * @list: an #ESourceList
- * @base_uri: a group base URI
- *
- * Returns the first #ESourceGroup having the given base URI.
- * The base URI is usually just the URI scheme, such as "http://".
- * If no such group is present in @list, the function returns %NULL.
- *
- * Returns: (transfer none): an #ESourceGroup with a matching base URI, or %NULL
- *
- * Since: 2.28
- **/
-ESourceGroup *
-e_source_list_peek_group_by_base_uri (ESourceList *list,
-                                      const gchar *base_uri)
-{
-       GSList *p;
-       gint len;
-
-       g_return_val_if_fail (E_IS_SOURCE_LIST (list), NULL);
-       g_return_val_if_fail (base_uri != NULL, NULL);
-
-       len = strlen (base_uri);
-
-       for (p = list->priv->groups; p != NULL; p = p->next) {
-               ESourceGroup *group = E_SOURCE_GROUP (p->data);
-               const gchar *buri = e_source_group_peek_base_uri (group);
-
-               if (buri && g_ascii_strncasecmp (buri, base_uri, len) == 0)
-                       return group;
-       }
-
-       return NULL;
-}
-
-struct property_check_struct {
-       ESourceGroup *group;
-       gboolean same;
-};
-
-static void
-check_group_property (const gchar *property_name,
-                      const gchar *property_value,
-                      struct property_check_struct *pcs)
-{
-       gchar *value;
-
-       g_return_if_fail (property_name != NULL);
-       g_return_if_fail (property_value != NULL);
-       g_return_if_fail (pcs != NULL);
-       g_return_if_fail (pcs->group != NULL);
-
-       value = e_source_group_get_property (pcs->group, property_name);
-       pcs->same = pcs->same && value && g_ascii_strcasecmp (property_value, value) == 0;
-       g_free (value);
-}
-
-/**
- * e_source_list_peek_group_by_properties:
- *
- * Peeks group by its properties. Parameters are pairs of strings
- * property_name, property_value, terminated by NULL! ESourceGroup
- * is returned only if matches all the properties. Values are compared
- * case insensitively.
- *
- * Returns: (transfer none): the #ESourceGroup
- *
- * Since: 2.28
- **/
-ESourceGroup *
-e_source_list_peek_group_by_properties (ESourceList *list,
-                                        const gchar *property_name,
-                                        ...)
-{
-       GSList *p;
-       va_list ap;
-       GHashTable *props;
-
-       g_return_val_if_fail (E_IS_SOURCE_LIST (list), NULL);
-       g_return_val_if_fail (property_name != NULL, NULL);
-
-       props = g_hash_table_new (g_str_hash, g_str_equal);
-
-       va_start (ap, property_name);
-       while (property_name) {
-               const gchar *value = va_arg (ap, const gchar *);
-
-               if (!value)
-                       break;
-
-               g_hash_table_insert (props, (gpointer) property_name, (gpointer) value);
-               property_name = va_arg (ap, const gchar *);
-       }
-       va_end (ap);
-
-       for (p = list->priv->groups; p != NULL; p = p->next) {
-               struct property_check_struct pcs;
-
-               pcs.group = E_SOURCE_GROUP (p->data);
-               pcs.same = TRUE;
-
-               g_hash_table_foreach (props, (GHFunc) check_group_property, &pcs);
-
-               if (pcs.same) {
-                       g_hash_table_unref (props);
-                       return pcs.group;
-               }
-       }
-
-       g_hash_table_unref (props);
-
-       return NULL;
-}
-
-/**
- * e_source_list_peek_source_by_uid:
- *
- * Return value: (transfer none): the #ESource
- */
-ESource *
-e_source_list_peek_source_by_uid (ESourceList *list,
-                                  const gchar *uid)
-{
-       GSList *p;
-
-       g_return_val_if_fail (E_IS_SOURCE_LIST (list), NULL);
-       g_return_val_if_fail (uid != NULL, NULL);
-
-       for (p = list->priv->groups; p != NULL; p = p->next) {
-               ESourceGroup *group = E_SOURCE_GROUP (p->data);
-               ESource *source;
-
-               source = e_source_group_peek_source_by_uid (group, uid);
-               if (source)
-                       return source;
-       }
-
-       return NULL;
-}
-
-/**
- * e_source_list_peek_source_any:
- *
- * Returns: (transfer none): the #ESource
- */
-ESource *
-e_source_list_peek_source_any (ESourceList *list)
-{
-       GSList *p;
-
-       g_return_val_if_fail (E_IS_SOURCE_LIST (list), NULL);
-
-       for (p = list->priv->groups; p != NULL; p = p->next) {
-               ESourceGroup *group = E_SOURCE_GROUP (p->data);
-               GSList *sources;
-
-               sources = e_source_group_peek_sources (group);
-               if (sources && sources->data)
-                       return E_SOURCE (sources->data);
-       }
-
-       return NULL;
-}
-
-/**
- * e_source_list_peek_default_source:
- * @list: an #ESourceList
- *
- * Attempts to find a default #ESource in @list by looking for
- * a source with a property named "default", or else a source with a
- * property named "system".  If no such #ESource exists, the function
- * returns %NULL.
- *
- * Returns: (transfer none) (allow-none): the default #ESource in @list, or %NULL
- *
- * Since: 2.32
- **/
-ESource *
-e_source_list_peek_default_source (ESourceList *list)
-{
-       ESource *system_source = NULL;
-       GSList *groups;
-       GSList *iter1;
-
-       g_return_val_if_fail (E_IS_SOURCE_LIST (list), NULL);
-
-       groups = e_source_list_peek_groups (list);
-
-       for (iter1 = groups; iter1 != NULL; iter1 = iter1->next) {
-               ESourceGroup *source_group;
-               GSList *sources;
-               GSList *iter2;
-               gboolean is_local_group;
-
-               source_group = E_SOURCE_GROUP (iter1->data);
-               sources = e_source_group_peek_sources (source_group);
-
-               is_local_group = e_source_group_peek_base_uri (source_group)
-                                && g_str_equal (e_source_group_peek_base_uri (source_group), "local:");
-
-               for (iter2 = sources; iter2 != NULL; iter2 = iter2->next) {
-                       ESource *source;
-
-                       source = E_SOURCE (iter2->data);
-
-                       /* If we find the default source, we're done. */
-                       if (e_source_get_property (source, "default"))
-                               return source;
-
-                       /* Make a note of the system source.  If we fail
-                        * to find a default source we fall back to this. */
-                       if (e_source_get_property (source, "system") ||
-                           (is_local_group && !system_source && e_source_peek_relative_uri (source)
-                            && g_str_equal (e_source_peek_relative_uri (source), "system")))
-                               system_source = source;
-               }
-       }
-
-       return system_source;
-}
-
-gboolean
-e_source_list_add_group (ESourceList *list,
-                         ESourceGroup *group,
-                         gint position)
-{
-       const gchar *uid;
-
-       g_return_val_if_fail (E_IS_SOURCE_LIST (list), FALSE);
-       g_return_val_if_fail (E_IS_SOURCE_GROUP (group), FALSE);
-
-       uid = e_source_group_peek_uid (group);
-
-       if (e_source_list_peek_group_by_uid (list, uid) != NULL)
-               return FALSE;
-
-       list->priv->groups = g_slist_insert (
-               list->priv->groups, g_object_ref (group), position);
-
-       g_signal_connect (
-               group, "changed",
-               G_CALLBACK (group_changed_callback), list);
-
-       g_signal_emit (list, signals[GROUP_ADDED], 0, group);
-       g_signal_emit (list, signals[CHANGED], 0);
-
-       return TRUE;
-}
-
-/**
- * e_source_list_remove_group:
- * @list: an #ESourceList
- * @group: an #ESourceGroup
- *
- * Removes the first #ESourceGroup with a unique ID matching @group
- * (possibly @group itself) from @list.  The function returns %TRUE if a
- * matching group was found, otherwise %FALSE.
- *
- * Returns: %TRUE if an #ESourceGroup was removed, %FALSE otherwise
- **/
-gboolean
-e_source_list_remove_group (ESourceList *list,
-                            ESourceGroup *group)
-{
-       const gchar *uid;
-
-       g_return_val_if_fail (E_IS_SOURCE_LIST (list), FALSE);
-       g_return_val_if_fail (E_IS_SOURCE_GROUP (group), FALSE);
-
-       uid = e_source_group_peek_uid (group);
-
-       if (e_source_list_peek_group_by_uid (list, uid) == NULL)
-               return FALSE;
-
-       remove_group (list, group);
-
-       return TRUE;
-}
-
-/**
- * e_source_list_remove_group_by_uid:
- * @list: an #ESourceList
- * @uid: the unique ID of an #ESourceGroup
- *
- * Removes the first #ESourceGroup with the given unique ID from @list.
- * The function returns %TRUE if a matching group was found, otherwise
- * %FALSE.
- *
- * Returns: %TRUE if an #ESourceGroup was removed, %FALSE otherwise
- **/
-gboolean
-e_source_list_remove_group_by_uid (ESourceList *list,
-                                   const gchar *uid)
-{
-       ESourceGroup *group;
-
-       g_return_val_if_fail (E_IS_SOURCE_LIST (list), FALSE);
-       g_return_val_if_fail (uid != NULL, FALSE);
-
-       group = e_source_list_peek_group_by_uid (list, uid);
-       if (group== NULL)
-               return FALSE;
-
-       remove_group (list, group);
-       return TRUE;
-}
-
-/**
- * e_source_list_ensure_group:
- * @list: an #ESourceList
- * @name: a localized group name
- * @base_uri: a group base URI
- * @ret_it: whether to return the group
- *
- * Ensures an #ESourceGroup with the given base URI exists in @list, and
- * renames its to the given name.  If @ret_it is %TRUE, the matching group
- * will be returned and should be unreferenced with g_object_unref().
- *
- * Returns: (transfer full): the matching #ESourceGroup if @ret_it is %TRUE,
- *          otherwise %NULL
- *
- * Since: 2.28
- **/
-ESourceGroup *
-e_source_list_ensure_group (ESourceList *list,
-                            const gchar *name,
-                            const gchar *base_uri,
-                            gboolean ret_it)
-{
-       ESourceGroup *group;
-
-       g_return_val_if_fail (E_IS_SOURCE_LIST (list), NULL);
-       g_return_val_if_fail (name != NULL, NULL);
-       g_return_val_if_fail (base_uri != NULL, NULL);
-
-       group = e_source_list_peek_group_by_base_uri (list, base_uri);
-       if (group) {
-               e_source_group_set_name (group, name);
-               if (ret_it)
-                       g_object_ref (group);
-               else
-                       group = NULL;
-       } else {
-               group = e_source_group_new (name, base_uri);
-
-               if (!e_source_list_add_group (list, group, -1)) {
-                       g_warning ("Could not add source group %s with base uri %s to a source list", name, base_uri);
-                       g_object_unref (group);
-                       group = NULL;
-               } else {
-                       /* save it now */
-                       e_source_list_sync (list, NULL);
-
-                       if (!ret_it) {
-                               g_object_unref (group);
-                               group = NULL;
-                       }
-               }
-       }
-
-       return group;
-}
-
-/**
- * e_source_list_remove_group_by_base_uri:
- * @list: an #ESourceList
- * @base_uri: a group base URI
- *
- * Removes the first #ESourceGroup having the given base URI from @list.
- * The base URI is usually just the URI scheme, such as "http://".  The
- * function returns %TRUE if a matching group was found, otherwise %FALSE.
- *
- * Returns: %TRUE if an #ESourceGroup was removed, %FALSE otherwise
- *
- * Since: 2.28
- **/
-gboolean
-e_source_list_remove_group_by_base_uri (ESourceList *list,
-                                        const gchar *base_uri)
-{
-       ESourceGroup *group;
-
-       g_return_val_if_fail (E_IS_SOURCE_LIST (list), FALSE);
-       g_return_val_if_fail (base_uri != NULL, FALSE);
-
-       group = e_source_list_peek_group_by_base_uri (list, base_uri);
-       if (group == NULL)
-               return FALSE;
-
-       remove_group (list, group);
-       return TRUE;
-}
-
-/**
- * e_source_list_remove_source_by_uid:
- * @list: an #ESourceList
- * @uid: the unique ID of an #ESource
- *
- * Removes the first #ESource with the given unique ID from @list.  The
- * function returns %TRUE if a matching source was found, otherwise %FALSE.
- *
- * Returns: %TRUE if an #ESource was removed, %FALSE otherwise
- **/
-gboolean
-e_source_list_remove_source_by_uid (ESourceList *list,
-                                    const gchar *uid)
-{
-       GSList *p;
-
-       g_return_val_if_fail (E_IS_SOURCE_LIST (list), FALSE);
-       g_return_val_if_fail (uid != NULL, FALSE);
-
-       for (p = list->priv->groups; p != NULL; p = p->next) {
-               ESourceGroup *group = E_SOURCE_GROUP (p->data);
-               ESource *source;
-
-               source = e_source_group_peek_source_by_uid (group, uid);
-               if (source)
-                       return e_source_group_remove_source_by_uid (group, uid);
-       }
-
-       return FALSE;
-}
-
-/**
- * e_source_list_sync:
- * @list: an #ESourceList
- * @error: return location for a #GError, or %NULL
- *
- * Writes the contents of @list to GConf.  If an error occurs, such as
- * the GConf daemon not responding, the function sets @error and returns
- * %FALSE.
- *
- * Returns: %TRUE on success, %FALSE on failure
- **/
-gboolean
-e_source_list_sync (ESourceList *list,
-                    GError **error)
-{
-       GSList *conf_list;
-       GSList *p;
-       gboolean retval;
-
-       g_return_val_if_fail (E_IS_SOURCE_LIST (list), FALSE);
-
-       conf_list = NULL;
-       for (p = list->priv->groups; p != NULL; p = p->next)
-               conf_list = g_slist_prepend (
-                       conf_list, e_source_group_to_xml (
-                       E_SOURCE_GROUP (p->data)));
-       conf_list = g_slist_reverse (conf_list);
-
-       if (!e_source_list_is_gconf_updated (list))
-               retval = gconf_client_set_list (
-                       list->priv->gconf_client,
-                       list->priv->gconf_path,
-                       GCONF_VALUE_STRING,
-                       conf_list, error);
-       else
-               retval = TRUE;
-
-       g_slist_foreach (conf_list, (GFunc) g_free, NULL);
-       g_slist_free (conf_list);
-
-       return retval;
-}
-
-/**
- * e_source_list_is_gconf_updated:
- * @list: an #ESourceList
- *
- * Returns %TRUE if the GConf data for @list is up-to-date, %FALSE if
- * e_source_list_sync() should be called.
- *
- * Returns: %TRUE if the GConf data for @list is up-to-date
- **/
-gboolean
-e_source_list_is_gconf_updated (ESourceList *list)
-{
-       gchar *source_group_xml = NULL;
-       gchar *gconf_xml = NULL;
-       gchar *group_uid = NULL;
-       GSList *conf_list = NULL, *temp = NULL, *p = NULL;
-       xmlDocPtr xmldoc;
-       ESourceGroup *group = NULL;
-       GSList *groups = NULL;
-       gboolean conf_to_list = TRUE, list_to_conf = TRUE;
-
-       g_return_val_if_fail (list != NULL, FALSE);
-
-       conf_list = gconf_client_get_list (list->priv->gconf_client,
-                                          list->priv->gconf_path,
-                                          GCONF_VALUE_STRING, NULL);
-
-       /* From conf to list */
-
-       for (temp = conf_list; temp != NULL; temp = temp->next) {
-               gconf_xml = (gchar *) temp->data;
-               xmldoc = xmlParseDoc ((const xmlChar *) gconf_xml);
-
-               if (xmldoc == NULL)
-                       continue;
-
-               group_uid = e_source_group_uid_from_xmldoc (xmldoc);
-               group = e_source_list_peek_group_by_uid (list, group_uid);
-               g_free (group_uid);
-               xmlFreeDoc (xmldoc);
-
-               if (group) {
-                       source_group_xml = e_source_group_to_xml (group);
-                       if (e_source_group_xmlstr_equal (gconf_xml, source_group_xml)) {
-                               g_free (source_group_xml);
-                               continue;
-                       }
-                       else {
-                               conf_to_list  = FALSE;
-                               g_free (source_group_xml);
-                               break;
-                       }
-               } else {
-                       conf_to_list = FALSE;
-                       break;
-               }
-       }
-
-       /* If there is mismatch, free the conf_list and return FALSE */
-       if (!conf_to_list) {
-               for (p = conf_list; p != NULL; p = p->next) {
-                       gconf_xml = (gchar *) p->data;
-                       g_free (gconf_xml);
-               }
-               g_slist_free (conf_list);
-               return FALSE;
-       }
-
-       groups = e_source_list_peek_groups (list);
-
-       /* From list to conf */
-
-       for (p = groups; p != NULL; p = p->next) {
-               group = E_SOURCE_GROUP (p->data);
-               source_group_xml = e_source_group_to_xml (group);
-
-               for (temp = conf_list; temp != NULL; temp = temp->next) {
-                       gconf_xml = (gchar *) temp->data;
-                       if (!e_source_group_xmlstr_equal (gconf_xml, source_group_xml))
-                               continue;
-                       else
-                               break;
-               }
-               g_free (source_group_xml);
-
-               if (!temp) {
-                       list_to_conf = FALSE;
-                       break;
-               }
-
-       }
-
-       for (p = conf_list; p != NULL; p = p->next) {
-               gconf_xml = (gchar *) p->data;
-               g_free (gconf_xml);
-       }
-       g_slist_free (conf_list);
-
-       /* If there is mismatch return FALSE */
-       if (!list_to_conf)
-               return FALSE;
-
-       return TRUE;
-}
diff --git a/libedataserver/e-source-list.h b/libedataserver/e-source-list.h
deleted file mode 100644 (file)
index d67b490..0000000
+++ /dev/null
@@ -1,123 +0,0 @@
-/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 8; tab-width: 8 -*- */
-/* e-source-list.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: Ettore Perazzoli <ettore@ximian.com>
- */
-
-#ifndef E_SOURCE_LIST_H
-#define E_SOURCE_LIST_H
-
-#include <libxml/tree.h>
-#include <gconf/gconf-client.h>
-#include <libedataserver/e-source-group.h>
-
-/* Standard GObject macros */
-#define E_TYPE_SOURCE_LIST \
-       (e_source_list_get_type ())
-#define E_SOURCE_LIST(obj) \
-       (G_TYPE_CHECK_INSTANCE_CAST \
-       ((obj), E_TYPE_SOURCE_LIST, ESourceList))
-#define E_SOURCE_LIST_CLASS(cls) \
-       (G_TYPE_CHECK_CLASS_CAST \
-       ((cls), E_TYPE_SOURCE_LIST, ESourceListClass))
-#define E_IS_SOURCE_LIST(obj) \
-       (G_TYPE_CHECK_INSTANCE_TYPE \
-       ((obj), E_TYPE_SOURCE_LIST))
-#define E_IS_SOURCE_LIST_CLASS(cls) \
-       (G_TYPE_CHECK_CLASS_TYPE \
-       ((cls), E_TYPE_SOURCE_LIST))
-#define E_SOURCE_LIST_GET_CLASS(obj) \
-       (G_TYPE_INSTANCE_GET_CLASS \
-       ((obj), E_TYPE_SOURCE_LIST, ESourceListClass))
-
-G_BEGIN_DECLS
-
-typedef struct _ESourceList ESourceList;
-typedef struct _ESourceListClass ESourceListClass;
-typedef struct _ESourceListPrivate ESourceListPrivate;
-
-/**
- * ESourceList:
- *
- * Contains only private data that should be read and manipulated using the
- * functions below.
- **/
-struct _ESourceList {
-       GObject parent;
-       ESourceListPrivate *priv;
-};
-
-struct _ESourceListClass {
-       GObjectClass parent_class;
-
-       /* Signals */
-       void            (*changed)              (ESourceList *source_list);
-       void            (*group_removed)        (ESourceList *source_list,
-                                                ESourceGroup *group);
-       void            (*group_added)          (ESourceList *source_list,
-                                                ESourceGroup *group);
-};
-
-GType          e_source_list_get_type          (void) G_GNUC_CONST;
-ESourceList *  e_source_list_new               (void);
-ESourceList *  e_source_list_new_for_gconf     (GConfClient *client,
-                                                const gchar  *path);
-ESourceList *  e_source_list_new_for_gconf_default
-                                               (const gchar *path);
-GSList *       e_source_list_peek_groups       (ESourceList *list);
-ESourceGroup * e_source_list_peek_group_by_uid (ESourceList *list,
-                                                const gchar *uid);
-ESourceGroup * e_source_list_peek_group_by_base_uri
-                                               (ESourceList *list,
-                                                const gchar *base_uri);
-ESourceGroup * e_source_list_peek_group_by_properties
-                                               (ESourceList *list,
-                                                const gchar *property_name,
-                                                ...);
-ESource *      e_source_list_peek_source_by_uid
-                                               (ESourceList *list,
-                                                const gchar  *uid);
-ESource *      e_source_list_peek_source_any   (ESourceList *list);
-ESource *      e_source_list_peek_default_source
-                                               (ESourceList *list);
-gboolean       e_source_list_add_group         (ESourceList *list,
-                                                ESourceGroup *group,
-                                                gint position);
-gboolean       e_source_list_remove_group      (ESourceList  *list,
-                                                ESourceGroup *group);
-gboolean       e_source_list_remove_group_by_uid
-                                               (ESourceList *list,
-                                                const gchar *uid);
-ESourceGroup * e_source_list_ensure_group      (ESourceList *list,
-                                                const gchar *name,
-                                                const gchar *base_uri,
-                                                gboolean ret_it);
-gboolean       e_source_list_remove_group_by_base_uri
-                                               (ESourceList *list,
-                                                const gchar *base_uri);
-gboolean       e_source_list_remove_source_by_uid
-                                               (ESourceList  *list,
-                                                const gchar *uid);
-gboolean       e_source_list_sync              (ESourceList *list,
-                                                GError **error);
-gboolean       e_source_list_is_gconf_updated  (ESourceList *list);
-
-G_END_DECLS
-
-#endif /* E_SOURCE_LIST_H */
diff --git a/tests/libedataserver/test-source-list.c b/tests/libedataserver/test-source-list.c
deleted file mode 100644 (file)
index 68f171f..0000000
+++ /dev/null
@@ -1,547 +0,0 @@
-/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 8; tab-width: 8 -*- */
-/* test-source-list.c - Test for the ESourceList class.
- *
- * 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: Ettore Perazzoli <ettore@ximian.com>
- */
-
-#include <config.h>
-#include <libedataserver/e-source-list.h>
-
-/* Globals. */
-
-static GMainLoop *main_loop = NULL;
-static ESourceList *list = NULL;
-static gint idle_dump_id = 0;
-
-/* Options.  */
-
-static gboolean listen = FALSE;
-static gboolean dump = FALSE;
-static gchar *key_arg = (gchar *) "/apps/evolution/test/source_list";
-static gchar *source_arg = NULL;
-static gchar *group_arg = NULL;
-static gchar *add_group_arg = NULL;
-static gchar *add_source_arg = NULL;
-static gchar *remove_group_arg = NULL;
-static gchar *remove_source_arg = NULL;
-static gchar *property_arg = NULL;
-static gchar *set_name_arg = NULL;
-static gchar *set_base_uri_arg = NULL;
-static gchar *set_relative_uri_arg = NULL;
-static gchar *set_color_arg = NULL;
-static gchar *set_value_arg = NULL;
-static gboolean unset_value = FALSE;
-static gboolean unset_color = FALSE;
-
-static GOptionEntry entries[] = {
-       { "key", '\0', 0, G_OPTION_ARG_STRING, &key_arg, "Name of the GConf key to use", "PATH" },
-       { "source", '\0', 0, G_OPTION_ARG_STRING, &source_arg, "UID of source to apply operations too", "UID"},
-       { "group", '\0', 0, G_OPTION_ARG_STRING, &group_arg, "UID of group to apply operations too", "UID" },
-       { "add-group", '\0', 0, G_OPTION_ARG_STRING, &add_group_arg, "Add group of specified name", "GROUP" },
-       { "add-source", '\0', 0, G_OPTION_ARG_STRING, &add_source_arg, "Add source of specified name", "SOURCE" },
-       { "remove-group", '\0', 0, G_OPTION_ARG_STRING, &remove_group_arg, "Remove group of specified name", "GROUP" },
-       { "remove-source", '\0', 0, G_OPTION_ARG_STRING, &remove_source_arg, "Remove source of specified name", "SOURCE" },
-       { "property", '\0', 0, G_OPTION_ARG_STRING, &property_arg, "Name of source property to apply operation to", "PROPERTY" },
-       { "set-name", '\0', 0, G_OPTION_ARG_STRING, &set_name_arg, "Set name of source or group.  When used with --group, it sets the name of a group. When used with both --group and --source, it sets the name of a source.", "NAME" },
-       { "set-relative-uri", '\0', 0, G_OPTION_ARG_STRING, &set_relative_uri_arg, "Set relative URI of a source.  Use with --source or --add-source.", "NAME" },
-       { "set-base-uri", '\0', 0, G_OPTION_ARG_STRING, &set_base_uri_arg, "Set base URI of a group.  Use with --group or --add-group.", "NAME" },
-       { "set-color", '\0', 0, G_OPTION_ARG_STRING, &set_color_arg, "Set the color of a source.  Use with --source or --add-source.", "COLOR (rrggbb)" },
-       { "unset-color", '\0', 0, G_OPTION_ARG_NONE, &unset_color, "Unset the color of a source.  Use with --source or --add-source.", NULL },
-       { "set-value", '\0', 0, G_OPTION_ARG_STRING, &set_value_arg, "Set a property on a source.  Use with --source and --property.", NULL },
-       { "unset-value", '\0', 0, G_OPTION_ARG_NONE, &unset_value, "Unset a property on a source.  Use with --source and --property.", NULL },
-       { "listen", '\0', 0, G_OPTION_ARG_NONE, &listen, "Wait and listen for changes.", NULL },
-       { "dump", '\0', 0, G_OPTION_ARG_NONE, &dump, "List the current configured sources.", NULL },
-       { NULL }
-};
-
-/* Forward decls.  */
-static void group_added_callback (ESourceList *list, ESourceGroup *group);
-static void group_removed_callback (ESourceList *list, ESourceGroup *group);
-static void source_added_callback (ESourceGroup *group, ESource *source);
-static void source_removed_callback (ESourceGroup *group, ESource *source);
-
-static void
-dump_property (const gchar *prop,
-               const gchar *value)
-{
-       g_print ("\t\t\t%s: %s\n", prop, value);
-}
-
-static void
-dump_source (ESource *source)
-{
-       gchar *uri = e_source_get_uri (source);
-       const gchar *color_spec;
-
-       g_print ("\tSource %s\n", e_source_get_uid (source));
-       g_print ("\t\tname: %s\n", e_source_get_display_name (source));
-       g_print ("\t\trelative_uri: %s\n", e_source_peek_relative_uri (source));
-       g_print ("\t\tabsolute_uri: %s\n", uri);
-
-       color_spec = e_source_peek_color_spec (source);
-       if (color_spec != NULL)
-               g_print ("\t\tcolor: %s\n", color_spec);
-
-       g_print ("\t\tproperties:\n");
-       e_source_foreach_property (source, (GHFunc) dump_property, NULL);
-
-       g_free (uri);
-}
-
-static void
-dump_group (ESourceGroup *group)
-{
-       GSList *sources, *p;
-
-       g_print ("Group %s\n", e_source_group_peek_uid (group));
-       g_print ("\tname: %s\n", e_source_group_peek_name (group));
-       g_print ("\tbase_uri: %s\n", e_source_group_peek_base_uri (group));
-
-       sources = e_source_group_peek_sources (group);
-       for (p = sources; p != NULL; p = p->next) {
-               ESource *source = E_SOURCE (p->data);
-
-               dump_source (source);
-
-               if (e_source_peek_group (source) != group)
-                       g_warning ("\t\t** ERROR ** parent pointer is %p, should be %p",
-                                  (gpointer) e_source_peek_group (source),
-                                  (gpointer) group);
-       }
-}
-
-static void
-dump_list (void)
-{
-       GSList *groups, *p;
-
-       groups = e_source_list_peek_groups (list);
-       if (groups == NULL) {
-               g_print ("(No items)\n");
-               return;
-       }
-
-       for (p = groups; p != NULL; p = p->next)
-               dump_group (E_SOURCE_GROUP (p->data));
-}
-
-static gint
-idle_dump_callback (gpointer unused_data)
-{
-       dump_list ();
-       idle_dump_id = 0;
-
-       return FALSE;
-}
-
-static void
-dump_on_idle (void)
-{
-       if (idle_dump_id == 0)
-               idle_dump_id = g_idle_add (idle_dump_callback, NULL);
-}
-
-static void
-source_changed_callback (ESource *source)
-{
-       static gint count = 0;
-
-       g_print ("** Event: source \"%s\" changed (%d)\n", e_source_get_display_name (source), ++count);
-
-       dump_on_idle ();
-}
-
-static void
-group_changed_callback (ESourceGroup *group)
-{
-       static gint count = 0;
-
-       g_print ("** Event: group \"%s\" changed (%d)\n", e_source_group_peek_name (group), ++count);
-
-       dump_on_idle ();
-}
-
-static void
-list_changed_callback (ESourceGroup *group)
-{
-       static gint count = 0;
-
-       g_print ("** Event: list changed (%d)\n", ++count);
-
-       dump_on_idle ();
-}
-
-static void
-connect_source (ESource *source)
-{
-       g_object_ref (source);
-       g_signal_connect (source, "changed", G_CALLBACK (source_changed_callback), NULL);
-}
-
-static void
-connect_group (ESourceGroup *group)
-{
-       GSList *sources, *p;
-
-       g_object_ref (group);
-       g_signal_connect (group, "changed", G_CALLBACK (group_changed_callback), NULL);
-       g_signal_connect (group, "source_added", G_CALLBACK (source_added_callback), NULL);
-       g_signal_connect (group, "source_removed", G_CALLBACK (source_removed_callback), NULL);
-
-       sources = e_source_group_peek_sources (group);
-       for (p = sources; p != NULL; p = p->next)
-               connect_source (E_SOURCE (p->data));
-}
-
-static void
-connect_list (void)
-{
-       GSList *groups, *p;
-
-       g_signal_connect (list, "changed", G_CALLBACK (list_changed_callback), NULL);
-       g_signal_connect (list, "group_added", G_CALLBACK (group_added_callback), NULL);
-       g_signal_connect (list, "group_removed", G_CALLBACK (group_removed_callback), NULL);
-
-       groups = e_source_list_peek_groups (list);
-       for (p = groups; p != NULL; p = p->next)
-               connect_group (E_SOURCE_GROUP (p->data));
-}
-
-static void
-disconnect_group (ESourceGroup *group)
-{
-       g_signal_handlers_disconnect_by_func (group, G_CALLBACK (group_changed_callback), NULL);
-       g_signal_handlers_disconnect_by_func (group, G_CALLBACK (source_added_callback), NULL);
-
-       g_object_unref (group);
-}
-
-static void
-disconnect_source (ESource *source)
-{
-       g_signal_handlers_disconnect_by_func (source, G_CALLBACK (source_changed_callback), NULL);
-
-       g_object_unref (source);
-}
-
-static void
-source_added_callback (ESourceGroup *group,
-                       ESource *source)
-{
-       static gint count = 0;
-
-       g_print ("** Event: source \"%s\" added (%d)\n", e_source_get_display_name (source), ++count);
-
-       connect_source (source);
-       dump_on_idle ();
-}
-
-static void
-source_removed_callback (ESourceGroup *group,
-                         ESource *source)
-{
-       static gint count = 0;
-
-       g_print ("** Event: source \"%s\" removed (%d)\n", e_source_get_display_name (source), ++count);
-
-       disconnect_source (source);
-       dump_on_idle ();
-}
-
-static void
-group_added_callback (ESourceList *list,
-                      ESourceGroup *group)
-{
-       static gint count = 0;
-
-       g_print ("** Event: group \"%s\" added (%d)\n", e_source_group_peek_name (group), ++count);
-
-       connect_group (group);
-       dump_on_idle ();
-}
-
-static void
-group_removed_callback (ESourceList *list,
-                        ESourceGroup *group)
-{
-       static gint count = 0;
-
-       g_print ("** Event: group \"%s\" removed (%d)\n", e_source_group_peek_name (group), ++count);
-
-       disconnect_group (group);
-       dump_on_idle ();
-}
-
-static gint
-on_idle_do_stuff (gpointer unused_data)
-{
-       GConfClient *client = gconf_client_get_default ();
-       ESourceGroup *new_group = NULL;
-       ESource *new_source = NULL;
-
-       list = e_source_list_new_for_gconf (client, key_arg);
-       g_object_unref (client);
-
-       if (add_group_arg != NULL) {
-               if (group_arg != NULL) {
-                       fprintf (stderr, "--add-group and --group cannot be used at the same time.\n");
-                       exit (1);
-               }
-               if (set_base_uri_arg == NULL) {
-                       fprintf (stderr, "When using --add-group, you need to specify a base URI using --set-base-uri.\n");
-                       exit (1);
-               }
-
-               new_group = e_source_group_new (add_group_arg, set_base_uri_arg);
-               e_source_list_add_group (list, new_group, -1);
-               g_object_unref (new_group);
-
-               e_source_list_sync (list, NULL);
-       }
-
-       if (remove_group_arg != NULL) {
-               ESourceGroup *group;
-
-               group = e_source_list_peek_group_by_uid (list, remove_group_arg);
-               if (group == NULL) {
-                       fprintf (stderr, "No such group \"%s\".\n", remove_group_arg);
-                       exit (1);
-               }
-
-               e_source_list_remove_group (list, group);
-               e_source_list_sync (list, NULL);
-       }
-
-       if (add_source_arg != NULL) {
-               ESourceGroup *group;
-
-               if (group_arg == NULL && new_group == NULL) {
-                       fprintf (stderr,
-                                "When using --add-source, you need to specify a group using either --group\n"
-                                "or --add-group.\n");
-                       exit (1);
-               }
-               if (set_relative_uri_arg == NULL) {
-                       fprintf (stderr,
-                                "When using --add-source, you need to specify a relative URI using\n"
-                                "--set-relative-uri.\n");
-                       exit (1);
-               }
-
-               if (group_arg == NULL) {
-                       group = new_group;
-               } else {
-                       group = e_source_list_peek_group_by_uid (list, group_arg);
-                       if (group == NULL) {
-                               fprintf (stderr, "No such group \"%s\".\n", group_arg == NULL ? add_group_arg : group_arg);
-                               exit (1);
-                       }
-               }
-
-               new_source = e_source_new (add_source_arg, set_relative_uri_arg);
-               e_source_group_add_source (group, new_source, -1);
-               e_source_list_sync (list, NULL);
-       }
-
-       if (remove_source_arg != NULL) {
-               ESource *source;
-
-               source = e_source_list_peek_source_by_uid (list, remove_source_arg);
-               if (source == NULL) {
-                       fprintf (stderr, "No such source \"%s\".\n", remove_source_arg);
-                       exit (1);
-               }
-
-               e_source_list_remove_source_by_uid (list, remove_source_arg);
-               e_source_list_sync (list, NULL);
-       }
-
-       if (set_name_arg != NULL) {
-               if (group_arg == NULL && source_arg == NULL) {
-                       fprintf (stderr,
-                                "When using --set-name, you need to specify a source (using --source"
-                                "alone) or a group (using --group alone).\n");
-                       exit (1);
-               }
-
-               if (source_arg != NULL) {
-                       ESource *source = e_source_list_peek_source_by_uid (list, source_arg);
-
-                       if (source != NULL) {
-                               e_source_set_name (source, set_name_arg);
-                       } else {
-                               fprintf (stderr, "No such source \"%s\".\n", source_arg);
-                               exit (1);
-                       }
-               } else {
-                       ESourceGroup *group = e_source_list_peek_group_by_uid (list, group_arg);
-
-                       if (group != NULL) {
-                               e_source_group_set_name (group, set_name_arg);
-                       } else {
-                               fprintf (stderr, "No such group \"%s\".\n", group_arg);
-                               exit (1);
-                       }
-               }
-
-               e_source_list_sync (list, NULL);
-       }
-
-       if (set_relative_uri_arg != NULL && add_source_arg == NULL) {
-               ESource *source;
-
-               if (source_arg == NULL) {
-                       fprintf (stderr,
-                                "When using --set-relative-uri, you need to specify a source using "
-                                "--source.\n");
-                       exit (1);
-               }
-
-               source = e_source_list_peek_source_by_uid (list, source_arg);
-               e_source_set_relative_uri (source, set_relative_uri_arg);
-               e_source_list_sync (list, NULL);
-       }
-
-       if (set_color_arg != NULL) {
-               ESource *source;
-
-               if (add_source_arg == NULL && source_arg == NULL) {
-                       fprintf (stderr,
-                                "When using --set-color, you need to specify a source using --source\n");
-                       exit (1);
-               }
-
-               if (add_source_arg != NULL)
-                       source = new_source;
-               else
-                       source = e_source_list_peek_source_by_uid (list, source_arg);
-
-               e_source_set_color_spec (source, set_color_arg);
-               e_source_list_sync (list, NULL);
-       }
-
-       if (unset_color) {
-               ESource *source;
-
-               if (add_source_arg == NULL && source_arg == NULL) {
-                       fprintf (stderr,
-                                "When using --unset-color, you need to specify a source using --source\n");
-                       exit (1);
-               }
-
-               if (add_source_arg != NULL)
-                       source = new_source;
-               else
-                       source = e_source_list_peek_source_by_uid (list, source_arg);
-
-               e_source_set_color_spec (source, NULL);
-               e_source_list_sync (list, NULL);
-       }
-
-       if (set_base_uri_arg != NULL && add_group_arg == NULL) {
-               ESourceGroup *group;
-
-               if (group_arg == NULL) {
-                       fprintf (stderr,
-                                "When using --set-base-uri, you need to specify a group using --group.\n");
-                       exit (1);
-               }
-
-               group = e_source_list_peek_group_by_uid (list, group_arg);
-               e_source_group_set_base_uri (group, set_base_uri_arg);
-               e_source_list_sync (list, NULL);
-       }
-
-       if (set_value_arg != NULL) {
-               ESource *source;
-
-               if (add_source_arg == NULL && source_arg == NULL) {
-                       fprintf (stderr,
-                                "When using --set-value, you need to specify a source using --source\n");
-                       exit (1);
-               }
-
-               if (property_arg == NULL) {
-                       fprintf (stderr,
-                                "When using --set-value, you need to specify a property using --property\n");
-                       exit (1);
-               }
-
-               if (add_source_arg != NULL)
-                       source = new_source;
-               else
-                       source = e_source_list_peek_source_by_uid (list, source_arg);
-
-               e_source_set_property (source, property_arg, set_value_arg);
-               e_source_list_sync (list, NULL);
-       }
-
-       if (unset_value) {
-               ESource *source;
-
-               if (add_source_arg == NULL && source_arg == NULL) {
-                       fprintf (stderr,
-                                "When using --unset-value, you need to specify a source using --source\n");
-                       exit (1);
-               }
-
-               if (property_arg == NULL) {
-                       fprintf (stderr,
-                                "When using --unset-value, you need to specify a property using --property\n");
-                       exit (1);
-               }
-
-               if (add_source_arg != NULL)
-                       source = new_source;
-               else
-                       source = e_source_list_peek_source_by_uid (list, source_arg);
-
-               e_source_set_property (source, property_arg, NULL);
-               e_source_list_sync (list, NULL);
-       }
-
-       connect_list ();
-
-       if (dump)
-               dump_list ();
-
-       if (!listen)
-               g_main_loop_quit (main_loop);
-
-       return FALSE;
-}
-
-gint
-main (gint argc,
-      gchar **argv)
-{
-       GOptionContext *context;
-       GError *error = NULL;
-
-       context = g_option_context_new ("- test source lists");
-       g_option_context_add_main_entries (context, entries, GETTEXT_PACKAGE);
-       g_option_context_parse (context, &argc, &argv, &error);
-
-       g_idle_add (on_idle_do_stuff, NULL);
-
-       main_loop = g_main_loop_new (NULL, TRUE);
-       g_main_loop_run (main_loop);
-
-       return 0;
-}