libpurple/purplebadgemanager.h

Thu, 07 Aug 2025 21:32:18 -0500

author
Gary Kramlich <grim@reaperworld.com>
date
Thu, 07 Aug 2025 21:32:18 -0500
changeset 43300
0604c6839974
parent 43076
6b0210915ee3
permissions
-rw-r--r--

Clean up and modernize PurpleImage

Testing Done:
Ran the tests under valgrind and called in the turtles.

Reviewed at https://reviews.imfreedom.org/r/4074/

/*
 * 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_BADGE_MANAGER_H
#define PURPLE_BADGE_MANAGER_H

#include <glib.h>

#include "purplebadge.h"

G_BEGIN_DECLS

#define PURPLE_TYPE_BADGE_MANAGER (purple_badge_manager_get_type())

/**
 * PurpleBadgeManager:
 *
 * A cache for badges.
 *
 * This can be used to reuse badges where necessary without having to create a
 * new instance every time.
 *
 * Since: 3.0
 */
PURPLE_AVAILABLE_IN_3_0
G_DECLARE_FINAL_TYPE(PurpleBadgeManager, purple_badge_manager,
                     PURPLE, BADGE_MANAGER, GObject)

/**
 * purple_badge_manager_add:
 * @manager: The instance.
 * @badge: (transfer none): The badge to add.
 *
 * Adds @badge to @manager.
 *
 * Returns: %TRUE if @badge was not already added to @manager.
 *
 * Since: 3.0
 */
PURPLE_AVAILABLE_IN_3_0
gboolean purple_badge_manager_add(PurpleBadgeManager *manager, PurpleBadge *badge);

/**
 * purple_badge_manager_new:
 *
 * Creates a new badge manager.
 *
 * A badge manager is just a runtime cache to help protocols and plugins by
 * holding onto an instance which can be referenced instead of having to always
 * create a new instance.
 *
 * Returns: (transfer full): The new instance.
 *
 * Since: 3.0
 */
PURPLE_AVAILABLE_IN_3_0
PurpleBadgeManager *purple_badge_manager_new(void);

/**
 * purple_badge_manager_get_default:
 *
 * Gets the default instance of #PurpleBadgeManager.
 *
 * This instance can be used for any of the API including connecting to
 * signals.
 *
 * Returns: (transfer none): The default instance.
 *
 * Since: 3.0
 */
PURPLE_AVAILABLE_IN_3_0
PurpleBadgeManager *purple_badge_manager_get_default(void);

/**
 * purple_badge_manager_find:
 * @manager: The instance.
 * @id: The identifier of the badge.
 *
 * Looks for badge with the given id.
 *
 * Returns: (transfer none) (nullable): The [class@PurpleBadge] if found.
 *
 * Since: 3.0
 */
PURPLE_AVAILABLE_IN_3_0
PurpleBadge *purple_badge_manager_find(PurpleBadgeManager *manager, const char *id);

/**
 * purple_badge_manager_remove:
 * @manager: The instance.
 * @id: The identifier of the badge.
 *
 * Removes a badge with the given identifier.
 *
 * Returns: %TRUE if @badge was found and removed.
 *
 * Since: 3.0
 */
PURPLE_AVAILABLE_IN_3_0
gboolean purple_badge_manager_remove(PurpleBadgeManager *manager, const char *id);

G_END_DECLS

#endif /* PURPLE_BADGE_MANAGER_H */

mercurial