<commit_before>/* vi: set et sw=4 ts=4 cino=t0,(0: */
/* -*- Mode: C; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
/*
 * This file is part of libaccounts-glib
 *
 * Copyright (C) 2011 Nokia Corporation.
 *
 * Contact: <NAME> <<EMAIL>>
 *
 * This library is free software; you can redistribute it and/or
 * modify it under the terms of the GNU Lesser General Public License
 * version 2.1 as published by the Free Software Foundation.
 *
 * This library 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 this library; if not, write to the Free Software
 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
 * 02110-1301 USA
 */

/**
 * SECTION:ag-account-service
 * @short_description: Account settings for a specific service
 * @include: libaccounts-glib/ag-account-service.h
 *
 * The #AgAccountService object provides access to the account settings for a
 * specific service type. It is meant to be easier to use than the AgAccount
 * class because it hides the complexity of the account structure and gives
 * access to only the limited subset of account settings which are relevant to
 * a service.
 *
 * To get an #AgAccountService one can use the #AgManager methods
 * ag_manager_get_account_services() or
 * ag_manager_get_enabled_account_services(), which both return a #GList of
 * account services. Note that if the #AgManager was instantiated for a
 * specific service type, these lists will contain only those account services
 * matching that service type.
 * Another way to get an #AgAccountService is to instantiate one using
 * ag_account_service_new(): this is useful if one already has an #AgAccount
 * instance.
 *
 * This is intended to be a convenient wrapper over the accounts settings
 * specific for a service; as such, it doesn't offer all the editing
 * possibilities offered by the #AgAccount class, such as enabling the service
 * itself: these operations should ideally not be performed by consumer
 * applications, but by the account editing UI only.
 *
 * <informalexample>
 *   <programlisting>
 * AgManager *manager;
 * GList *services, *list;
 *
 * // Instantiate an account manager interested in e-mail services only.
 * manager = ag_manager_new_for_service_type ("e-mail");
 *
 * // Get the list of enabled AgAccountService objects of type e-mail.
 * services = ag_manager_get_enabled_account_services (manager);
 *
 * // Loop through the account services and do something useful with them.
 * for (list = services; list != NULL; list = list->next)
 * {
 *     AgAccountService *service = AG_ACCOUNT_SERVICE (list->data);
 *     GValue v_server = { 0, }, v_port = { 0, }, v_username = { 0, };
 *     gchar *server = NULL, *username = NULL;
 *     gint port;
 *     AgSettingSource src;
 *     AgAccount *account;
 *
 *     g_value_init (&v_server, G_TYPE_STRING);
 *     src = ag_account_service_get_value (service, "pop3/hostname", &v_server);
 *     if (src != AG_SETTING_SOURCE_NONE)
 *         server = g_value_get_string (&v_server);
 *
 *     g_value_init (&v_port, G_TYPE_INT);
 *     src = ag_account_service_get_value (service, "pop3/port", &v_port);
 *     if (src != AG_SETTING_SOURCE_NONE)
 *         port = g_value_get_string (&v_port);
 *
 *     // Suppose that the e-mail address is stored in the global account
 *     // settings; let's get it from there:
 *     g_value_init (&v_username, G_TYPE_STRING);
 *     account = ag_account_service_get_account (service);
 *     src = ag_account_get_value (service, "username", &v_username);
 *     if (src != AG_SETTING_SOURCE_NONE)
 *         username = g_value_get_string (&v_username);
 *
 *     ...
 *
 *     g_value_unset (&v_username);
 *     g_value_unset (&v_port);
 *     g_value_unset (&v_server);
 * }
 *   </programlisting>
 * </informalexample>
 *
 * <note>
 *   <para>
 * User applications (with the notable exception of the accounts editing
 * application) should never use account services which are not enabled, and
 * should stop using an account when the account service becomes disabled. The
 * latter can be done by connecting to the #AgAccountService::changed signal
 * and checking if ag_account_service_get_enabled() still returns true.
 * Note that if the account gets deleted, it will always get disabled first;
 * so, there is no need to connect to the #AgAccount::deleted signal; one can
 * just monitor the #AgAccountService::changed signal.
 *   </para>
 * </note>
 */

#include "ag-account-service.h"
#include "ag-errors.h"
#include "ag-internals.h"
#include "ag-manager.h"
#include "ag-service-type.h"

enum {
    PROP_0,

    PROP_ACCOUNT,
    PROP_SERVICE
};

struct _AgAccountServicePrivate {
    AgAccount *account;
    AgService *service;<commit_msg>Give AgAccountService example a title<commit_after>/* vi: set et sw=4 ts=4 cino=t0,(0: */
/* -*- Mode: C; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
/*
 * This file is part of libaccounts-glib
 *
 * Copyright (C) 2011 Nokia Corporation.
 *
 * Contact: <NAME> <<EMAIL>>
 *
 * This library is free software; you can redistribute it and/or
 * modify it under the terms of the GNU Lesser General Public License
 * version 2.1 as published by the Free Software Foundation.
 *
 * This library 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 this library; if not, write to the Free Software
 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
 * 02110-1301 USA
 */

/**
 * SECTION:ag-account-service
 * @short_description: Account settings for a specific service
 * @include: libaccounts-glib/ag-account-service.h
 *
 * The #AgAccountService object provides access to the account settings for a
 * specific service type. It is meant to be easier to use than the AgAccount
 * class because it hides the complexity of the account structure and gives
 * access to only the limited subset of account settings which are relevant to
 * a service.
 *
 * To get an #AgAccountService one can use the #AgManager methods
 * ag_manager_get_account_services() or
 * ag_manager_get_enabled_account_services(), which both return a #GList of
 * account services. Note that if the #AgManager was instantiated for a
 * specific service type, these lists will contain only those account services
 * matching that service type.
 * Another way to get an #AgAccountService is to instantiate one using
 * ag_account_service_new(): this is useful if one already has an #AgAccount
 * instance.
 *
 * This is intended to be a convenient wrapper over the accounts settings
 * specific for a service; as such, it doesn't offer all the editing
 * possibilities offered by the #AgAccount class, such as enabling the service
 * itself: these operations should ideally not be performed by consumer
 * applications, but by the account editing UI only.
 *
 * <example>
 * <title>Querying available e-mail services</title>
 *   <programlisting>
 * AgManager *manager;
 * GList *services, *list;
 *
 * // Instantiate an account manager interested in e-mail services only.
 * manager = ag_manager_new_for_service_type ("e-mail");
 *
 * // Get the list of enabled AgAccountService objects of type e-mail.
 * services = ag_manager_get_enabled_account_services (manager);
 *
 * // Loop through the account services and do something useful with them.
 * for (list = services; list != NULL; list = list->next)
 * {
 *     AgAccountService *service = AG_ACCOUNT_SERVICE (list->data);
 *     GValue v_server = { 0, }, v_port = { 0, }, v_username = { 0, };
 *     gchar *server = NULL, *username = NULL;
 *     gint port;
 *     AgSettingSource src;
 *     AgAccount *account;
 *
 *     g_value_init (&v_server, G_TYPE_STRING);
 *     src = ag_account_service_get_value (service, "pop3/hostname", &v_server);
 *     if (src != AG_SETTING_SOURCE_NONE)
 *         server = g_value_get_string (&v_server);
 *
 *     g_value_init (&v_port, G_TYPE_INT);
 *     src = ag_account_service_get_value (service, "pop3/port", &v_port);
 *     if (src != AG_SETTING_SOURCE_NONE)
 *         port = g_value_get_string (&v_port);
 *
 *     // Suppose that the e-mail address is stored in the global account
 *     // settings; let's get it from there:
 *     g_value_init (&v_username, G_TYPE_STRING);
 *     account = ag_account_service_get_account (service);
 *     src = ag_account_get_value (service, "username", &v_username);
 *     if (src != AG_SETTING_SOURCE_NONE)
 *         username = g_value_get_string (&v_username);
 *
 *     ...
 *
 *     g_value_unset (&v_username);
 *     g_value_unset (&v_port);
 *     g_value_unset (&v_server);
 * }
 *   </programlisting>
 * </example>
 *
 * <note>
 *   <para>
 * User applications (with the notable exception of the accounts editing
 * application) should never use account services which are not enabled, and
 * should stop using an account when the account service becomes disabled. The
 * latter can be done by connecting to the #AgAccountService::changed signal
 * and checking if ag_account_service_get_enabled() still returns true.
 * Note that if the account gets deleted, it will always get disabled first;
 * so, there is no need to connect to the #AgAccount::deleted signal; one can
 * just monitor the #AgAccountService::changed signal.
 *   </para>
 * </note>
 */

#include "ag-account-service.h"
#include "ag-errors.h"
#include "ag-internals.h"
#include "ag-manager.h"
#include "ag-service-type.h"

enum {
    PROP_0,

    PROP_ACCOUNT,
    PROP_SERVICE
};

struct _AgAccountServicePrivate {
    AgAccount *account;
    AgService *service;
{'fraction_non_alphanumeric': 0.09343459578295193, 'fraction_numerical': 0.005596082742080543, 'mean_word_length': 3.7589158345221114, 'pattern_counts': {'":': 0, '<': 27, '<?xml version=': 0, '>': 31, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, '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': '1770914', 'n_tokens_mistral': 2919, 'n_tokens_neox': 2860, 'n_words': 1129}