pidgin/pidgin

b5eccef8404e
Avoid manual handling of icons in request field list items

* Use `PurpleKeyValuePair` as field list items
* Replace `icons` list with `has_icons` flag, thus fixing memleak
* Replace `purple_request_field_list_get_icons` with `purple_request_field_list_has_icons`

Testing Done:
Compile and run.

Reviewed at https://reviews.imfreedom.org/r/563/
/*
* 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 program 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 program 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 program; 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_H
#define PURPLE_PROTOCOL_H
#include <glib.h>
#include <glib-object.h>
/**
* SECTION:protocol
* @section_id: libpurple-protocol
* @short_description: <filename>protocol.h</filename>
* @title: Protocol Object and Interfaces
*
* #PurpleProtocol is the base type for all protocols in libpurple.
*/
#define PURPLE_TYPE_PROTOCOL (purple_protocol_get_type())
G_DECLARE_DERIVABLE_TYPE(PurpleProtocol, purple_protocol, PURPLE, PROTOCOL,
GObject)
#include "account.h"
#include "buddyicon.h"
#include "buddylist.h"
#include "chat.h"
#include "connection.h"
#include "conversations.h"
#include "debug.h"
#include "xfer.h"
#include "image.h"
#include "notify.h"
#include "plugins.h"
#include "purpleaccountoption.h"
#include "purpleaccountusersplit.h"
#include "purplemessage.h"
#include "purplewhiteboard.h"
#include "purplewhiteboardops.h"
#include "roomlist.h"
#include "status.h"
/**
* PurpleProtocol:
*
* Represents an instance of a protocol registered with #PurpleProtocolManager.
*/
/**
* PurpleProtocolClass:
* @get_user_splits: Returns a list of all #PurpleAccountUserSplit's that the
* procotol provides.
* @get_account_options: Returns a list of all #PurpleAccountOption's for the
* protocol.
* @get_buddy_icon_spec: Returns a #PurpleBuddyIconSpec that should be used.
* @get_whiteboard_ops: Return the #PurpleWhiteboardOps that should be used.
* @login: Logs into the server.
* @close: Close sconnection with the server.
* @status_types: Returns a list of #PurpleStatusType which exist for this
* account; and must add at least the offline and online states.
* @list_icon: Returns the base icon name for the given buddy and account. If
* buddy is %NULL and the account is non-%NULL, it will return the
* name to use for the account's icon. If both are %NULL, it will
* return the name to use for the protocol's icon.
*
* The base class for all protocols.
*
* All protocol types must implement the methods in this class.
*
* Since: 3.0.0
*/
struct _PurpleProtocolClass {
GObjectClass parent_class;
GList *(*get_user_splits)(PurpleProtocol *protocol);
GList *(*get_account_options)(PurpleProtocol *protocol);
PurpleBuddyIconSpec *(*get_buddy_icon_spec)(PurpleProtocol *protocol);
PurpleWhiteboardOps *(*get_whiteboard_ops)(PurpleProtocol *protocol);
void (*login)(PurpleAccount *account);
void (*close)(PurpleConnection *connection);
GList *(*status_types)(PurpleAccount *account);
const gchar *(*list_icon)(PurpleAccount *account, PurpleBuddy *buddy);
/*< private >*/
gpointer reserved[4];
};
/**
* PURPLE_PROTOCOL_IMPLEMENTS:
* @protocol: The protocol in which to check
* @IFACE: The interface name in caps. e.g. <literal>CLIENT</literal>
* @func: The function to check
*
* Returns: %TRUE if a protocol implements a function in an interface,
* %FALSE otherwise.
*/
#define PURPLE_PROTOCOL_IMPLEMENTS(protocol, IFACE, func) \
(PURPLE_IS_PROTOCOL_##IFACE(protocol) && \
PURPLE_PROTOCOL_##IFACE##_GET_IFACE(protocol)->func != NULL)
G_BEGIN_DECLS
/**
* purple_protocol_get_id:
* @protocol: The #PurpleProtocol instance.
*
* Gets the ID of a protocol.
*
* Returns: The ID of the protocol.
*
* Since: 3.0.0
*/
const gchar *purple_protocol_get_id(PurpleProtocol *protocol);
/**
* purple_protocol_get_name:
* @protocol: The #PurpleProtocol instance.
*
* Gets the translated name of a protocol.
*
* Returns: The translated name of the protocol.
*
* Since: 3.0.0
*/
const gchar *purple_protocol_get_name(PurpleProtocol *protocol);
/**
* purple_protocol_get_options:
* @protocol: The #PurpleProtocol instance.
*
* Gets the options of a protocol.
*
* Returns: The options of the protocol.
*
* Since: 3.0.0
*/
PurpleProtocolOptions purple_protocol_get_options(PurpleProtocol *protocol);
/**
* purple_protocol_get_user_splits:
* @protocol: The #PurpleProtocol instance.
*
* Gets the user splits of a protocol.
*
* Returns: (element-type PurpleAccountUserSplit) (transfer full): The user
* splits of the protocol.
*
* Since: 3.0.0
*/
GList *purple_protocol_get_user_splits(PurpleProtocol *protocol);
/**
* purple_protocol_get_account_options:
* @protocol: The #PurpleProtocol instance.
*
* Gets the account options for a protocol.
*
* Returns: (element-type PurpleAccountOption) (transfer full): The account
* options for the protocol.
*
* Since: 3.0.0
*/
GList *purple_protocol_get_account_options(PurpleProtocol *protocol);
/**
* purple_protocol_get_icon_spec:
* @protocol: The #PurpleProtocol instance.
*
* Gets the icon spec of a protocol.
*
* Returns: (transfer full): The icon spec of the protocol.
*
* Since: 3.0.0
*/
PurpleBuddyIconSpec *purple_protocol_get_icon_spec(PurpleProtocol *protocol);
/**
* purple_protocol_get_whiteboard_ops:
* @protocol: The #PurpleProtocol instance.
*
* Gets the whiteboard ops of a protocol.
*
* Returns: (transfer none): The whiteboard ops of the protocol.
*
* Since: 3.0.0
*/
PurpleWhiteboardOps *purple_protocol_get_whiteboard_ops(PurpleProtocol *protocol);
/**
* purple_protocol_login:
* @protocol: The #PurpleProtocol instance.
* @account: The #PurpleAccount to login.
*
* Logs @account in using @protocol.
*
* Since: 3.0.0
*/
void purple_protocol_login(PurpleProtocol *protocol, PurpleAccount *account);
/**
* purple_protocol_close:
* @protocol: The #PurpleProtocol instance.
* @connection: The #PurpleConnection to close.
*
* Closes @connection using @protocol.
*
* Since: 3.0.0
*/
void purple_protocol_close(PurpleProtocol *protocol, PurpleConnection *connection);
/**
* purple_protocol_get_status_types:
* @protocol: The #PurpleProtocol instance.
* @account: The #PurpleAccount instance.
*
* Gets all of the #PurpleStatusType's for @account which uses @protocol.
*
* Returns: (transfer full) (element-type PurpleStatusType): A list of the
* available PurpleStatusType's for @account with @protocol.
*
* Since: 3.0.0
*/
GList *purple_protocol_get_status_types(PurpleProtocol *protocol, PurpleAccount *account);
/**
* purple_protocol_get_list_icon:
* @protocol: The #PurpleProtocol instance.
* @account: The #PurpleAccount instance.
* @buddy: The #PurpleBuddy instance.
*
* Gets the icon to show in the contact list for @buddy on @account which uses
* @protocol.
*
* Both @account and @buddy may be %NULL to get the default icon for @protocol.
*
* Returns: The name of the icon file to use in the contact list for @buddy.
*
* Since: 3.0.0
*/
const gchar *purple_protocol_get_list_icon(PurpleProtocol *protocol, PurpleAccount *account, PurpleBuddy *buddy);
G_END_DECLS
#endif /* PURPLE_PROTOCOL_H */