void
remove_google_contacts_source_group (void)
{
	ESourceList  *source_list;
	ESourceGroup *group;
	const gchar *key;

	key = "/apps/evolution/addressbook/sources";
	source_list = e_source_list_new_for_gconf_default (key);

	if (source_list == NULL)
		return;

	group = e_source_list_peek_group_by_base_uri (source_list, "google://");

	if (group) {
		GSList *sources;

		sources = e_source_group_peek_sources (group);

		if (NULL == sources) {
			e_source_list_remove_group (source_list, group);
			e_source_list_sync (source_list, NULL);
		}
	}
	g_object_unref (source_list);
}
static gboolean
is_eex_source_available (EShellView *shell_view)
{
	EShellSidebar *shell_sidebar;
	ESourceSelector *selector = NULL;
	ESourceList *source_list;
	ESourceGroup *group;
	gint sources_count;

	shell_sidebar = e_shell_view_get_shell_sidebar (shell_view);
	g_return_val_if_fail (shell_sidebar != NULL, FALSE);

	g_object_get (shell_sidebar, "selector", &selector, NULL);
	g_return_val_if_fail (selector != NULL, FALSE);

	source_list = e_source_selector_get_source_list (selector);
	if (!source_list) {
		g_object_unref (selector);
		return FALSE;
	}

	group = e_source_list_peek_group_by_base_uri (source_list, "exchange://");
	if (!group) {
		g_object_unref (selector);
		return FALSE;
	}

	sources_count = g_slist_length (e_source_group_peek_sources (group));
	g_object_unref (selector);

	return sources_count > 0;
}
static void
remove_couchdb_contacts_source_group (void)
{
	ESourceList *source_list;

	source_list = e_source_list_new_for_gconf_default("/apps/evolution/addressbook/sources");
	if (source_list) {
		ESourceGroup *group;

		group = e_source_list_peek_group_by_base_uri (source_list, COUCHDB_BASE_URI);
		if (group) {
			GSList *sources;

			sources = e_source_group_peek_sources (group);
			if (sources == NULL) {
				e_source_list_remove_group (source_list, group);
				e_source_list_sync (source_list, NULL);
			}
		}

		g_object_unref (G_OBJECT (source_list));
	}
}
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;
}