/*
 * 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_CONTACTS_H
#define PURPLE_CONTACTS_H

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

#include "purpleaccount.h"
#include "purplecontact.h"
#include "purpleversion.h"

G_BEGIN_DECLS

#define PURPLE_TYPE_CONTACTS (purple_contacts_get_type())

PURPLE_AVAILABLE_IN_3_0
G_DECLARE_FINAL_TYPE(PurpleContacts, purple_contacts, PURPLE,
                     CONTACTS, GObject)

/**
 * PurpleContacts:
 *
 * A collection for [class@Purple.Contact]s.
 *
 * This collection does not make any attempt to make sure the contacts belong
 * to the same account.
 *
 * Since: 3.0
 */

/**
 * purple_contacts_add:
 * @contact: (transfer none): the contact to add
 *
 * Add a contact.
 *
 * If a contact with a matching id already exists, no action will be taken.
 *
 * Returns: true if the contact was added.
 *
 * Since: 3.0
 */
PURPLE_AVAILABLE_IN_3_0
gboolean purple_contacts_add(PurpleContacts *contacts, PurpleContact *contact);

/**
 * purple_contacts_find_with_id:
 * @id: (nullable): the id of the contact to find
 *
 * Look up a contact based on their id.
 *
 * Returns: (transfer none) (nullable): The contact if found.
 *
 * Since: 3.0
 */
PURPLE_AVAILABLE_IN_3_0
PurpleContact *purple_contacts_find_with_id(PurpleContacts *contacts, const char *id);

/**
 * purple_contacts_new:
 *
 * Creates a new instance.
 *
 * Returns: (transfer full): The new instance.
 *
 * Since: 3.0
 */
PURPLE_AVAILABLE_IN_3_0
PurpleContacts *purple_contacts_new(void);

/**
 * purple_contacts_remove:
 * @contact: (transfer none): the contact to remove
 *
 * Remove a contact.
 *
 * Returns: true if the contact was found and removed.
 *
 * Since: 3.0
 */
PURPLE_AVAILABLE_IN_3_0
gboolean purple_contacts_remove(PurpleContacts *contacts, PurpleContact *contact);

/**
 * purple_contacts_remove_with_id:
 * @id: (nullable): the id of the contact to remove
 *
 * Remove a contact.
 *
 * Returns: true if the contact was found and removed.
 *
 * Since: 3.0
 */
PURPLE_AVAILABLE_IN_3_0
gboolean purple_contacts_remove_with_id(PurpleContacts *contacts, const char *id);

G_END_DECLS

#endif /* PURPLE_CONTACTS_H */
