/*
 * 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_ACCOUNT_MANAGER_SEAGULL_BACKEND_H
#define PURPLE_ACCOUNT_MANAGER_SEAGULL_BACKEND_H

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

#include <gio/gio.h>

#include <seagull.h>

#include "purpleaccount.h"
#include "purpleaccountmanagerbackend.h"
#include "purpleversion.h"

G_BEGIN_DECLS

#define PURPLE_ACCOUNT_MANAGER_SEAGULL_BACKEND_ERROR purple_account_manager_seagull_backend_error_quark()

/**
 * PurpleAccountManagerSeagullBackendError:
 * @PURPLE_ACCOUNT_MANAGER_SEAGULL_BACKEND_ERROR_FAILED_TO_CLEANUP: Used when
 *  cleaning up a prepared statement failed.
 *
 * Error codes returned by [class@AccountManagerSeagullBackend].
 *
 * Since: 3.0
 */
typedef enum {
    PURPLE_ACCOUNT_MANAGER_SEAGULL_BACKEND_ERROR_FAILED_TO_CLEANUP PURPLE_AVAILABLE_ENUMERATOR_IN_3_0,
} PurpleAccountManagerSeagullBackendError;

/**
 * purple_account_manager_seagull_backend_error_quark:
 *
 * The error domain to identify errors from
 * [class@AccountManagerSeagullBackend].
 *
 * Returns: The error domain.
 *
 * Since: 3.0
 */
PURPLE_AVAILABLE_IN_3_0
GQuark purple_account_manager_seagull_backend_error_quark(void);

#define PURPLE_TYPE_ACCOUNT_MANAGER_SEAGULL_BACKEND (purple_account_manager_seagull_backend_get_type())

/**
 * PurpleAccountManagerSeagullBackend:
 *
 * A [class@AccountManagerBackend] that uses Seagull to store accounts in a
 * SQLite database.
 *
 * Since: 3.0
 */

PURPLE_AVAILABLE_IN_3_0
G_DECLARE_FINAL_TYPE(PurpleAccountManagerSeagullBackend,
                     purple_account_manager_seagull_backend,
                     PURPLE, ACCOUNT_MANAGER_SEAGULL_BACKEND,
                     PurpleAccountManagerBackend)

/**
 * purple_account_manager_seagull_backend_get_filename:
 *
 * Gets the filename of the database being used.
 *
 * Returns: The filename.
 *
 * Since: 3.0
 */
PURPLE_AVAILABLE_IN_3_0
const char *purple_account_manager_seagull_backend_get_filename(PurpleAccountManagerSeagullBackend *backend);

/**
 * purple_account_manager_seagull_backend_new:
 * @filename: (nullable): the filename to use
 * @error: (out) (nullable): a return address for a #GError
 *
 * Attempts to create a new Seagull backend.
 *
 * If @filename is %NULL, an in memory database will be used.
 *
 * Returns: (transfer full) (nullable) (type PurpleAccountManagerSeagullBackend):
 *          The new backend.
 *
 * Since: 3.0
 */
PURPLE_AVAILABLE_IN_3_0
PurpleAccountManagerBackend *purple_account_manager_seagull_backend_new(const char *filename, GError **error);

G_END_DECLS

#endif /* PURPLE_ACCOUNT_MANAGER_SEAGULL_BACKEND_H */
