/*
 * 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_CORE_H
#define PURPLE_CORE_H

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

#include "purpleaccountmanager.h"
#include "purplebadgemanager.h"
#include "purplecommandmanager.h"
#include "purplecontactmanager.h"
#include "purpleconversationmanager.h"
#include "purplecredentialmanager.h"
#include "purplefiletransfermanager.h"
#include "purpleidlemanager.h"
#include "purplenotificationmanager.h"
#include "purplepresencemanager.h"
#include "purpleprotocolmanager.h"
#include "purplescheduler.h"
#include "purpleui.h"
#include "purpleversion.h"
#include "purplewhiteboardmanager.h"

G_BEGIN_DECLS

#define PURPLE_CORE_ERROR purple_core_error_quark()

/**
 * PurpleCoreError:
 * @PURPLE_CORE_ERROR_REQUIRED_PROPERTY_NOT_SET: A required property was not
 *  set.
 * @PURPLE_CORE_ERROR_NO_SETTINGS_BACKEND: The user interface did not provide a
 *  settings backend.
 *
 * Error codes returned by the core.
 *
 * Since: 3.0
 */
typedef enum {
	PURPLE_CORE_ERROR_REQUIRED_PROPERTY_NOT_SET PURPLE_AVAILABLE_ENUMERATOR_IN_3_0,
	PURPLE_CORE_ERROR_NO_SETTINGS_BACKEND PURPLE_AVAILABLE_ENUMERATOR_IN_3_0,
} PurpleCoreError;

/**
 * purple_core_error_quark:
 *
 * The error domain to identify errors with the core.
 *
 * Returns: The error domain.
 *
 * Since: 3.0
 */
PURPLE_AVAILABLE_IN_3_0
GQuark purple_core_error_quark(void);

/**
 * PurpleCore:
 *
 * The core instance for libpurple.
 *
 * This is primarily used for connecting to signals.
 *
 * Since: 3.0
 */
PURPLE_AVAILABLE_IN_3_0
#define PURPLE_TYPE_CORE (purple_core_get_type())

G_DECLARE_FINAL_TYPE(PurpleCore, purple_core, PURPLE, CORE, GObject)

/**
 * purple_core_set_default:
 * @core: (transfer full): the core to set as the default
 *
 * Sets the core that should be returned from [func@Core.get_default].
 *
 * > Note: this should only be called once by the user interface.
 *
 * Since: 3.0
 */
PURPLE_AVAILABLE_IN_3_0
void purple_core_set_default(PurpleCore *core);

/**
 * purple_core_get_account_manager:
 *
 * Gets the account manager that the core is using.
 *
 * Returns: (transfer none): The manager.
 *
 * Since: 3.0
 */
PURPLE_AVAILABLE_IN_3_0
PurpleAccountManager *purple_core_get_account_manager(PurpleCore *core);

/**
 * purple_core_get_badge_manager:
 *
 * Gets the badge manager that the core is using.
 *
 * Returns: (transfer none): The manager.
 *
 * Since: 3.0
 */
PURPLE_AVAILABLE_IN_3_0
PurpleBadgeManager *purple_core_get_badge_manager(PurpleCore *core);

/**
 * purple_core_get_command_manager:
 *
 * Gets the command manager that the core is using.
 *
 * Returns: (transfer none): The manager.
 *
 * Since: 3.0
 */
PURPLE_AVAILABLE_IN_3_0
PurpleCommandManager *purple_core_get_command_manager(PurpleCore *core);

/**
 * purple_core_get_contact_manager:
 *
 * Gets the contact manager that the core is using.
 *
 * Returns: (transfer none): The manager.
 *
 * Since: 3.0
 */
PURPLE_AVAILABLE_IN_3_0
PurpleContactManager *purple_core_get_contact_manager(PurpleCore *core);

/**
 * purple_core_get_conversation_manager:
 *
 * Gets the conversation manager that the core is using.
 *
 * Returns: (transfer none): The manager.
 *
 * Since: 3.0
 */
PURPLE_AVAILABLE_IN_3_0
PurpleConversationManager *purple_core_get_conversation_manager(PurpleCore *core);

/**
 * purple_core_get_credential_manager:
 *
 * Gets the credential manager that the core is using.
 *
 * Returns: (transfer none): The manager.
 *
 * Since: 3.0
 */
PURPLE_AVAILABLE_IN_3_0
PurpleCredentialManager *purple_core_get_credential_manager(PurpleCore *core);

/**
 * purple_core_get_default:
 *
 * Gets the default core that is in use.
 *
 * Returns: (transfer none) (nullable): The core.
 *
 * Since: 3.0
 */
PURPLE_AVAILABLE_IN_3_0
PurpleCore *purple_core_get_default(void);

/**
 * purple_core_get_file_transfer_manager:
 *
 * Gets the file_transfer manager that the core is using.
 *
 * Returns: (transfer none): The manager.
 *
 * Since: 3.0
 */
PURPLE_AVAILABLE_IN_3_0
PurpleFileTransferManager *purple_core_get_file_transfer_manager(PurpleCore *core);

/**
 * purple_core_get_idle_manager:
 *
 * Gets the idle manager that the core is using.
 *
 * Returns: (transfer none): The manager.
 *
 * Since: 3.0
 */
PURPLE_AVAILABLE_IN_3_0
PurpleIdleManager *purple_core_get_idle_manager(PurpleCore *core);

/**
 * purple_core_get_notification_manager:
 *
 * Gets the notification manager that the core is using.
 *
 * Returns: (transfer none): The manager.
 *
 * Since: 3.0
 */
PURPLE_AVAILABLE_IN_3_0
PurpleNotificationManager *purple_core_get_notification_manager(PurpleCore *core);

/**
 * purple_core_get_presence_manager:
 *
 * Gets the presence manager that the core is using.
 *
 * Returns: (transfer none): The manager.
 *
 * Since: 3.0
 */
PURPLE_AVAILABLE_IN_3_0
PurplePresenceManager *purple_core_get_presence_manager(PurpleCore *core);

/**
 * purple_core_get_protocol_manager:
 *
 * Gets the protocol manager that the core is using.
 *
 * Returns: (transfer none): The manager.
 *
 * Since: 3.0
 */
PURPLE_AVAILABLE_IN_3_0
PurpleProtocolManager *purple_core_get_protocol_manager(PurpleCore *core);

/**
 * purple_core_get_scheduler:
 *
 * Gets the scheduler that the core is using.
 *
 * Returns: (transfer none): The scheduler.
 *
 * Since: 3.0
 */
PURPLE_AVAILABLE_IN_3_0
PurpleScheduler *purple_core_get_scheduler(PurpleCore *core);

/**
 * purple_core_get_whiteboard_manager:
 *
 * Gets the whiteboard manager that the core is using.
 *
 * Returns: (transfer none): The manager.
 *
 * Since: 3.0
 */
PURPLE_AVAILABLE_IN_3_0
PurpleWhiteboardManager *purple_core_get_whiteboard_manager(PurpleCore *core);

/**
 * purple_core_new:
 * @ui: (not nullable): the ui starting the core
 * @error: (out) (nullable): a return address for a #GError
 *
 * Creates a new core instance.
 *
 * Returns: (transfer full): The new core on success.
 *
 * Since: 3.0
 */
PURPLE_AVAILABLE_IN_3_0
PurpleCore *purple_core_new(PurpleUi *ui, GError **error);

/**
 * purple_core_start:
 * @error: a return address for a #GError, or %NULL.
 *
 * Starts libpurple asynchronously.
 *
 * Returns: true if successful.
 *
 * Since: 3.0
 */
PURPLE_AVAILABLE_IN_3_0
gboolean purple_core_start(PurpleCore *core, GError **error);

/**
 * purple_core_quit:
 *
 * Quits the core of purple, which, depending on the UI, may quit the
 * application using the purple core.
 *
 * Since: 3.0
 */
PURPLE_AVAILABLE_IN_3_0
void purple_core_quit(PurpleCore *core);

/**
 * purple_core_get_developer_mode:
 *
 * Gets whether or not developer mode is turned on.
 *
 * Developer mode doesn't do anything itself. It is just a hint to other parts
 * of the code base to present things that are useful for developers.
 *
 * Returns: %TRUE if developer mode is on, otherwise %FALSE.
 *
 * Since: 3.0
 */
PURPLE_AVAILABLE_IN_3_0
gboolean purple_core_get_developer_mode(PurpleCore *core);

/**
 * purple_core_get_settings_backend:
 *
 * Gets the settings backend to use when saving/loading settings.
 *
 * Note, because we do not want to leak `G_SETTINGS_ENABLE_BACKEND` into
 * libpurple users, this function returns a `gpointer`, and you should cast to
 * `GSettingsBackend *` after setting `G_SETTINGS_ENABLE_BACKEND` for the files
 * where you need it.
 *
 * Returns: (transfer none): The [class@Gio.SettingsBackend] to use.
 *
 * Since: 3.0
 */
PURPLE_AVAILABLE_IN_3_0
gpointer purple_core_get_settings_backend(PurpleCore *core);

/**
 * purple_core_new_settings:
 * @schema_id: the id of the schema
 *
 * Creates a new settings object using the preferred backend.
 *
 * Returns: (transfer full): The new instance.
 *
 * Since: 3.0
 */
PURPLE_AVAILABLE_IN_3_0
GSettings *purple_core_new_settings(PurpleCore *core, const char *schema_id);

/**
 * purple_core_get_ui:
 *
 * Gets the [class@Purple.Ui] that is running.
 *
 * Returns: (transfer none): The ui.
 *
 * Since: 3.0
 */
PURPLE_AVAILABLE_IN_3_0
PurpleUi *purple_core_get_ui(PurpleCore *core);

/**
 * purple_get_locale_dir:
 *
 * Gets the search directory for translations.
 *
 * This can be overridden by the `PURPLE_LOCALE_DIR` environment variable.
 *
 * Returns: The directory where translations should be searched for.
 *
 * Since: 3.0
 */
PURPLE_AVAILABLE_IN_3_0
const char *purple_get_locale_dir(void);

G_END_DECLS

#endif /* PURPLE_CORE_H */

/*

                                                  /===-
                                                `//"\\   """"`---.___.-""
             ______-==|                         | |  \\           _-"`
       __--"""  ,-/-==\\                        | |   `\        ,'
    _-"       /'    |  \\            ___         / /      \      /
  .'        /       |   \\         /"   "\    /' /        \   /'
 /  ____  /         |    \`\.__/-""  D O   \_/'  /          \/'
/-'"    """""---__  |     "-/"   O G     R   /'        _--"`
                  \_|      /   R    __--_  t ),   __--""
                    '""--_/  T   _-"_>--<_\ h '-" \
                   {\__--_/}    / \\__>--<__\ e B  \
                   /'   (_/  _-"  | |__>--<__|   U  |
                  |   _/) )-"     | |__>--<__|  R   |
                  / /" ,_/       / /__>---<__/ N    |
                 o-o _//        /-"_>---<__-" I    /
                 (^("          /"_>---<__-  N   _-"
                ,/|           /__>--<__/  A  _-"
             ,//('(          |__>--<__|  T  /                  .----_
            ( ( '))          |__>--<__|    |                 /' _---_"\
         `-)) )) (           |__>--<__|  O |               /'  /     "\`\
        ,/,'//( (             \__>--<__\  R \            /'  //        ||
      ,( ( ((, ))              "-__>--<_"-_  "--____---"' _/'/        /'
    `"/  )` ) ,/|                 "-_">--<_/-__       __-" _/
  ._-"//( )/ )) `                    ""-'_/_/ /"""""""__--"
   ;'( ')/ ,)(                              """"""""""
  ' ') '( (/
    '   '  `

*/
