/*
 * Purple - Internet Messaging Library
 * Copyright (C) Pidgin Developers <devel@pidgin.im>
 *
 * Purple is the legal property of its developers, whose names are too numerous
 * to list here. Please refer to the COPYRIGHT file distributed with this
 * source distribution.
 *
 * This library is free software; you can redistribute it and/or modify it
 * under the terms of the GNU General Public License as published by the Free
 * Software Foundation; either version 2 of the License, or (at your option)
 * any later version.
 *
 * 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 General Public License for
 * more details.
 *
 * You should have received a copy of the GNU General Public License along with
 * this library; if not, see <https://www.gnu.org/licenses/>.
 */

#if !defined(PURPLE_GLOBAL_HEADER_INSIDE) && !defined(PURPLE_COMPILATION)
# error "only <purple.h> may be included directly"
#endif

#ifndef PURPLE_REQUEST_FIELD_ACCOUNT_H
#define PURPLE_REQUEST_FIELD_ACCOUNT_H

#include <glib.h>
#include <glib-object.h>

#include "purpleaccount.h"
#include "purplerequestfield.h"
#include "purpleversion.h"

G_BEGIN_DECLS

/**
 * PurpleRequestFieldAccount:
 *
 * An account request field.
 *
 * Since: 3.0
 */
#define PURPLE_TYPE_REQUEST_FIELD_ACCOUNT (purple_request_field_account_get_type())

PURPLE_AVAILABLE_IN_3_0
G_DECLARE_FINAL_TYPE(PurpleRequestFieldAccount, purple_request_field_account,
                     PURPLE, REQUEST_FIELD_ACCOUNT, PurpleRequestField)

/**
 * purple_request_field_account_get_account:
 *
 * Gets the selected account.
 *
 * Returns: (transfer none) (nullable): The selected account.
 *
 * Since: 3.0
 */
PURPLE_AVAILABLE_IN_3_0
PurpleAccount *purple_request_field_account_get_account(PurpleRequestFieldAccount *field);

/**
 * purple_request_field_account_get_model:
 *
 * Gets the model that contains the available accounts.
 *
 * Returns: (transfer none) (nullable): The list of accounts.
 *
 * Since: 3.0
 */
PURPLE_AVAILABLE_IN_3_0
GListModel *purple_request_field_account_get_model(PurpleRequestFieldAccount *field);

/**
 * purple_request_field_account_new:
 * @id: the ID
 * @label: the label
 * @model: the list model containing accounts
 *
 * Creates an account field.
 *
 * Model should be a [iface@Gio.ListModel] containing the accounts to display.
 * This can be set to an [class@AccountManager] instance to display all
 * accounts enabled and disabled. [method@AccountManager.get_enabled],
 * [method@AccountManager.get_disabled], and
 * [method@AccountManager.get_connected_accounts] could also be used directly
 * or as a list to filter.
 *
 * Returns: (transfer full) (type PurpleRequestFieldAccount): The new field.
 *
 * Since: 3.0
 */
PURPLE_AVAILABLE_IN_3_0
PurpleRequestField *purple_request_field_account_new(const char *id, const char *label, GListModel *model);

/**
 * purple_request_field_account_set_account:
 * @account: (transfer none) (nullable): the new account
 *
 * Sets the selected account.
 *
 * If @account is not in [property@RequestFieldAccount:model] then this does
 * nothing.
 *
 * Since: 3.0
 */
PURPLE_AVAILABLE_IN_3_0
void purple_request_field_account_set_account(PurpleRequestFieldAccount *field, PurpleAccount *account);

/**
 * purple_request_field_account_set_model:
 * @model: (transfer none) (nullable): the new model
 *
 * Sets the model of accounts.
 *
 * Since: 3.0
 */
PURPLE_AVAILABLE_IN_3_0
void purple_request_field_account_set_model(PurpleRequestFieldAccount *field, GListModel *model);

G_END_DECLS

#endif /* PURPLE_REQUEST_FIELD_ACCOUNT_H */
