/*
 * 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_PROTOCOL_CONTACTS_H
#define PURPLE_PROTOCOL_CONTACTS_H

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

#include <birb.h>

#include "purplecontact.h"
#include "purpleprotocol.h"
#include "purpleversion.h"

#define PURPLE_TYPE_PROTOCOL_CONTACTS (purple_protocol_contacts_get_type())

PURPLE_AVAILABLE_IN_3_0
G_DECLARE_INTERFACE(PurpleProtocolContacts,
                    purple_protocol_contacts, PURPLE,
                    PROTOCOL_CONTACTS, PurpleProtocol)

/**
 * PurpleProtocolContacts:
 *
 * #PurpleProtocolContacts provides methods for interacting with remote
 * contacts.
 *
 * Since: 3.0
 */

/**
 * PURPLE_PROTOCOL_CONTACTS_DOMAIN:
 *
 * A domain for errors from the [class@ProtocolContacts] API.
 *
 * Since: 3.0
 */
#define PURPLE_PROTOCOL_CONTACTS_DOMAIN \
	g_quark_from_static_string("purple-protocol-contacts") \
	PURPLE_AVAILABLE_MACRO_IN_3_0

struct _PurpleProtocolContactsInterface {
	/*< private >*/
	GTypeInterface parent;

	/*< public >*/
	void (*get_profile_async)(PurpleProtocolContacts *protocol, PurpleContact *contact, GCancellable *cancellable, GAsyncReadyCallback callback, gpointer data);
	char *(*get_profile_finish)(PurpleProtocolContacts *protocol, GAsyncResult *result, GError **error);

	BirbActionMenu *(*get_action_menu)(PurpleProtocolContacts *protocol, PurpleContact *contact);

	void (*set_alias_async)(PurpleProtocolContacts *protocol, PurpleContact *contact, const char *alias, GCancellable *cancellable, GAsyncReadyCallback callback, gpointer data);
	gboolean (*set_alias_finish)(PurpleProtocolContacts *protocol, GAsyncResult *result, GError **error);

	/*< private >*/
	gpointer reserved[4];
};

G_BEGIN_DECLS

/**
 * purple_protocol_contacts_implements_get_profile:
 *
 * Gets whether or not the protocol contacts implements getting a profile for
 * a contact.
 *
 * Returns: true if the protocol contacts implements
 *          [vfunc@ProtocolContacts.get_profile_async] and
 *          [vfunc@ProtocolContacts.get_profile_finish].
 *
 * Since: 3.0
 */
PURPLE_AVAILABLE_IN_3_0
gboolean purple_protocol_contacts_implements_get_profile(PurpleProtocolContacts *protocol);

/**
 * purple_protocol_contacts_get_profile_async:
 * @contact: the contact whose profile to get
 * @cancellable: (nullable): an optional GCancellable
 * @callback: (scope async): a callback to call when the request is complete
 * @data: user data to pass to the callback
 *
 * Starts the process requesting the contact's profile.
 *
 * Call [method@ProtocolContacts.get_profile_finish] to get the results.
 *
 * Since: 3.0
 */
PURPLE_AVAILABLE_IN_3_0
void purple_protocol_contacts_get_profile_async(PurpleProtocolContacts *protocol, PurpleContact *contact, GCancellable *cancellable, GAsyncReadyCallback callback, gpointer data);

/**
 * purple_protocol_contacts_get_profile_finish:
 * @result: the result
 * @error: (out) (nullable): an address for a #GError
 *
 * Finishes a previous call to [method@ProtocolContacts.get_profile_async] and
 * gets the result.
 *
 * Returns: (transfer full): A plain text string of the contact's profile.
 *
 * Since: 3.0
 */
PURPLE_AVAILABLE_IN_3_0
char *purple_protocol_contacts_get_profile_finish(PurpleProtocolContacts *protocol, GAsyncResult *result, GError **error);

/**
 * purple_protocol_contacts_implements_get_action_menu:
 *
 * Checks whether or not [vfunc@ProtocolContacts.get_action_menu] is
 * implemented.
 *
 * Returns: true if the virtual function is implemented.
 *
 * Since: 3.0
 */
PURPLE_AVAILABLE_IN_3_0
gboolean purple_protocol_contacts_implements_get_action_menu(PurpleProtocolContacts *protocol);

/**
 * purple_protocol_contacts_get_action_menu:
 * @contact: (transfer none): the contact whose action menu to get
 *
 * Gets an action menu for a contact.
 *
 * An action menu is a list of actions that can be performed on the contact.
 *
 * Returns: (transfer full) (nullable): The action menu.
 *
 * Since: 3.0
 */
PURPLE_AVAILABLE_IN_3_0
BirbActionMenu *purple_protocol_contacts_get_action_menu(PurpleProtocolContacts *protocol, PurpleContact *contact);

/**
 * purple_protocol_contacts_implements_set_alias:
 *
 * Checks whether or not the [vfunc@ProtocolContacts.set_alias_async] and
 * [vfunc@ProtocolContacts.set_alias_finish] are implemented.
 *
 * Returns: true if everything is implemented.
 *
 * Since: 3.0
 */
PURPLE_AVAILABLE_IN_3_0
gboolean purple_protocol_contacts_implements_set_alias(PurpleProtocolContacts *protocol);

/**
 * purple_protocol_contacts_set_alias_async:
 * @contact: the contact whose alias to set
 * @alias: (nullable): the new alias
 * @cancellable: (nullable): an optional GCancellable
 * @callback: (scope async): a callback to call when the request is complete
 * @data: user data to pass to the callback
 *
 * Starts the process of setting an alias on a contact.
 *
 * Call [method@ProtocolContacts.set_alias_finish] from the callback to get
 * the results.
 *
 * Since: 3.0
 */
PURPLE_AVAILABLE_IN_3_0
void purple_protocol_contacts_set_alias_async(PurpleProtocolContacts *protocol, PurpleContact *contact, const char *alias, GCancellable *cancellable, GAsyncReadyCallback callback, gpointer data);

/**
 * purple_protocol_contacts_set_alias_finish:
 * @result: the result
 * @error: (out) (nullable): an address for a #GError
 *
 * Finishes a previous call to [method@ProtocolContacts.set_alias_async] and
 * gets the result.
 *
 * Returns: true if the alias was set successfully.
 *
 * Since: 3.0
 */
PURPLE_AVAILABLE_IN_3_0
gboolean purple_protocol_contacts_set_alias_finish(PurpleProtocolContacts *protocol, GAsyncResult *result, GError **error);

G_END_DECLS

#endif /* PURPLE_PROTOCOL_CONTACTS_H */
