<commit_before>/*
 * e-source-contacts.c
 *
 * This program is free software; you can redistribute it and/or
 * modify it under the terms of the GNU Lesser General Public
 * License as published by the Free Software Foundation; either
 * version 2 of the License, or (at your option) version 3.
 *
 * 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
 * Lesser General Public License for more details.
 *
 * You should have received a copy of the GNU Lesser General Public
 * License along with the program; if not, see <webcal://www.gnu.org/licenses/>
 *
 */

#include "e-source-contacts.h"

#define E_SOURCE_CONTACTS_GET_PRIVATE(obj) \
	(G_TYPE_INSTANCE_GET_PRIVATE \
	((obj), E_TYPE_SOURCE_CONTACTS, ESourceContactsPrivate))

struct _ESourceContactsPrivate {
	gboolean include_me;
};

enum {
	PROP_0,
	PROP_INCLUDE_ME
};

G_DEFINE_DYNAMIC_TYPE (
	ESourceContacts,
	e_source_contacts,
	E_TYPE_SOURCE_EXTENSION)

static void
source_contacts_set_property (GObject *object,
                              guint property_id,
                              const GValue *value,
                              GParamSpec *pspec)
{
	switch (property_id) {
		case PROP_INCLUDE_ME:
			e_source_contacts_set_include_me (
				E_SOURCE_CONTACTS (object),
				g_value_get_boolean (value));
			return;
	}

	G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
}

static void
source_contacts_get_property (GObject *object,
                              guint property_id,
                              GValue *value,
                              GParamSpec *pspec)
{
	switch (property_id) {
		case PROP_INCLUDE_ME:
			g_value_set_boolean (
				value,
				e_source_contacts_get_include_me (
				E_SOURCE_CONTACTS (object)));
			return;
	}

	G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
}

static void
e_source_contacts_class_init (ESourceContactsClass *class)
{
	GObjectClass *object_class;
	ESourceExtensionClass *extension_class;

	g_type_class_add_private (class, sizeof (ESourceContactsPrivate));

	object_class = G_OBJECT_CLASS (class);
	object_class->set_property = source_contacts_set_property;
	object_class->get_property = source_contacts_get_property;

	extension_class = E_SOURCE_EXTENSION_CLASS (class);
	extension_class->name = E_SOURCE_EXTENSION_CONTACTS_BACKEND;

	g_object_class_install_property (
		object_class,
		PROP_INCLUDE_ME,
		g_param_spec_boolean (
			"include-me",
			"Include Me",
			"Include this address book in the contacts calendar",
			TRUE,
			G_PARAM_READWRITE |
			G_PARAM_CONSTRUCT |
			E_SOURCE_PARAM_SETTING));
}

static void
e_source_contacts_class_finalize (ESourceContactsClass *class)
{
}

static void
e_source_contacts_init (ESourceContacts *extension)
{
	extension->priv = E_SOURCE_CONTACTS_GET_PRIVATE (extension);
}

void
e_source_contacts_type_register (GTypeModule *type_module)
{
	/* XXX G_DEFINE_DYNAMIC_TYPE declares a static type registration
	 *     function, so we have to wrap it with a public function in
	 *     order to register types from a separate compilation unit. */
	e_source_contacts_register_type (type_module);
}<commit_msg>ESourceContacts: Only include local address books by default.<commit_after>/*
 * e-source-contacts.c
 *
 * This program is free software; you can redistribute it and/or
 * modify it under the terms of the GNU Lesser General Public
 * License as published by the Free Software Foundation; either
 * version 2 of the License, or (at your option) version 3.
 *
 * 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
 * Lesser General Public License for more details.
 *
 * You should have received a copy of the GNU Lesser General Public
 * License along with the program; if not, see <webcal://www.gnu.org/licenses/>
 *
 */

#include "e-source-contacts.h"

#define E_SOURCE_CONTACTS_GET_PRIVATE(obj) \
	(G_TYPE_INSTANCE_GET_PRIVATE \
	((obj), E_TYPE_SOURCE_CONTACTS, ESourceContactsPrivate))

struct _ESourceContactsPrivate {
	gboolean include_me;
};

enum {
	PROP_0,
	PROP_INCLUDE_ME
};

G_DEFINE_DYNAMIC_TYPE (
	ESourceContacts,
	e_source_contacts,
	E_TYPE_SOURCE_EXTENSION)

static void
source_contacts_set_property (GObject *object,
                              guint property_id,
                              const GValue *value,
                              GParamSpec *pspec)
{
	switch (property_id) {
		case PROP_INCLUDE_ME:
			e_source_contacts_set_include_me (
				E_SOURCE_CONTACTS (object),
				g_value_get_boolean (value));
			return;
	}

	G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
}

static void
source_contacts_get_property (GObject *object,
                              guint property_id,
                              GValue *value,
                              GParamSpec *pspec)
{
	switch (property_id) {
		case PROP_INCLUDE_ME:
			g_value_set_boolean (
				value,
				e_source_contacts_get_include_me (
				E_SOURCE_CONTACTS (object)));
			return;
	}

	G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
}

static void
source_contacts_constructed (GObject *object)
{
	ESource *source;
	ESourceExtension *extension;
	ESourceBackend *backend_extension;
	ESourceContacts *contacts_extension;
	const gchar *backend_name;
	const gchar *extension_name;
	gboolean include_me;

	/* Chain up to parent's constructed() method. */
	G_OBJECT_CLASS (e_source_contacts_parent_class)->constructed (object);

	extension = E_SOURCE_EXTENSION (object);
	source = e_source_extension_get_source (extension);

	extension_name = E_SOURCE_EXTENSION_ADDRESS_BOOK;
	backend_extension = e_source_get_extension (source, extension_name);
	backend_name = e_source_backend_get_backend_name (backend_extension);

	/* Only include local address books by default. */
	include_me = (g_strcmp0 (backend_name, "local") == 0);

	contacts_extension = E_SOURCE_CONTACTS (extension);
	e_source_contacts_set_include_me (contacts_extension, include_me);
}

static void
e_source_contacts_class_init (ESourceContactsClass *class)
{
	GObjectClass *object_class;
	ESourceExtensionClass *extension_class;

	g_type_class_add_private (class, sizeof (ESourceContactsPrivate));

	object_class = G_OBJECT_CLASS (class);
	object_class->set_property = source_contacts_set_property;
	object_class->get_property = source_contacts_get_property;
	object_class->constructed = source_contacts_constructed;

	extension_class = E_SOURCE_EXTENSION_CLASS (class);
	extension_class->name = E_SOURCE_EXTENSION_CONTACTS_BACKEND;

	g_object_class_install_property (
		object_class,
		PROP_INCLUDE_ME,
		g_param_spec_boolean (
			"include-me",
			"Include Me",
			"Include this address book in the contacts calendar",
			FALSE,  /* see constructed() */
			G_PARAM_READWRITE |
			E_SOURCE_PARAM_SETTING));
}

static void
e_source_contacts_class_finalize (ESourceContactsClass *class)
{
}

static void
e_source_contacts_init (ESourceContacts *extension)
{
	extension->priv = E_SOURCE_CONTACTS_GET_PRIVATE (extension);
}

void
e_source_contacts_type_register (GTypeModule *type_module)
{
	/* XXX G_DEFINE_DYNAMIC_TYPE declares a static type registration
	 *     function, so we have to wrap it with a public function in
	 *     order to register types from a separate compilation unit. */
	e_source_contacts_register_type (type_module);
}
{'fraction_non_alphanumeric': 0.07083056478405315, 'fraction_numerical': 0.00106312292358804, 'mean_word_length': 4.197513812154696, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 15, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1206979', 'n_tokens_mistral': 2518, 'n_tokens_neox': 2375, 'n_words': 601}