pidgin/pidgin

cc7d4ff5a205
Parents b1ccd1961499
Children 226e6e8bb07d
rename accountopt.[ch] to purpleaccountoption.[ch]
--- a/finch/gntaccount.c Fri Sep 27 02:44:08 2019 -0500
+++ b/finch/gntaccount.c Fri Sep 27 03:43:47 2019 -0500
@@ -37,10 +37,10 @@
#include "finch.h"
#include <account.h>
-#include <accountopt.h>
#include <connection.h>
#include <notify.h>
#include <plugins.h>
+#include <purpleaccountoption.h>
#include <request.h>
#include <savedstatuses.h>
--- a/libpurple/accountopt.c Fri Sep 27 02:44:08 2019 -0500
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,349 +0,0 @@
-/* purple
- *
- * 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, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02111-1301 USA
- */
-#include "internal.h"
-
-#include "accountopt.h"
-#include "util.h"
-#include "glibcompat.h"
-
-/*
- * An option for an account.
- *
- * This is set by protocols, and appears in the account settings
- * dialogs.
- */
-struct _PurpleAccountOption
-{
- PurplePrefType type; /* The type of value. */
-
- char *text; /* The text that will appear to the user. */
- char *pref_name; /* The name of the associated preference. */
-
- union
- {
- gboolean boolean; /* The default boolean value. */
- int integer; /* The default integer value. */
- char *string; /* The default string value. */
- GList *list; /* The default list value. */
-
- } default_value;
-
- union
- {
- struct
- {
- gboolean masked; /* Whether the value entered should
- * be obscured from view (for
- * passwords and similar options)
- */
- GSList *hints; /* List of hinted values */
- } string;
- } params;
-};
-
-PurpleAccountOption *
-purple_account_option_new(PurplePrefType type, const char *text,
- const char *pref_name)
-{
- PurpleAccountOption *option;
-
- g_return_val_if_fail(type != PURPLE_PREF_NONE, NULL);
- g_return_val_if_fail(text != NULL, NULL);
- g_return_val_if_fail(pref_name != NULL, NULL);
-
- option = g_new0(PurpleAccountOption, 1);
-
- option->type = type;
- option->text = g_strdup(text);
- option->pref_name = g_strdup(pref_name);
-
- return option;
-}
-
-PurpleAccountOption *
-purple_account_option_bool_new(const char *text, const char *pref_name,
- gboolean default_value)
-{
- PurpleAccountOption *option;
-
- option = purple_account_option_new(PURPLE_PREF_BOOLEAN, text, pref_name);
-
- if (option == NULL)
- return NULL;
-
- option->default_value.boolean = default_value;
-
- return option;
-}
-
-PurpleAccountOption *
-purple_account_option_int_new(const char *text, const char *pref_name,
- int default_value)
-{
- PurpleAccountOption *option;
-
- option = purple_account_option_new(PURPLE_PREF_INT, text, pref_name);
-
- if (option == NULL)
- return NULL;
-
- option->default_value.integer = default_value;
-
- return option;
-}
-
-PurpleAccountOption *
-purple_account_option_string_new(const char *text, const char *pref_name,
- const char *default_value)
-{
- PurpleAccountOption *option;
-
- option = purple_account_option_new(PURPLE_PREF_STRING, text, pref_name);
-
- if (option == NULL)
- return NULL;
-
- option->default_value.string = g_strdup(default_value);
-
- return option;
-}
-
-PurpleAccountOption *
-purple_account_option_list_new(const char *text, const char *pref_name,
- GList *list)
-{
- PurpleAccountOption *option;
-
- option = purple_account_option_new(PURPLE_PREF_STRING_LIST, text, pref_name);
-
- if (option == NULL)
- return NULL;
-
- option->default_value.list = list;
-
- return option;
-}
-
-static void
-purple_account_option_list_free(gpointer data, gpointer user_data)
-{
- PurpleKeyValuePair *kvp = data;
-
- g_free(kvp->value);
- g_free(kvp->key);
- g_free(kvp);
-}
-
-void
-purple_account_option_destroy(PurpleAccountOption *option)
-{
- g_return_if_fail(option != NULL);
-
- g_free(option->text);
- g_free(option->pref_name);
-
- if (option->type == PURPLE_PREF_STRING)
- {
- g_free(option->default_value.string);
- g_slist_free_full(option->params.string.hints, &g_free);
- }
- else if (option->type == PURPLE_PREF_STRING_LIST)
- {
- g_list_free_full(option->default_value.list,
- (GDestroyNotify)purple_account_option_list_free);
- }
-
- g_free(option);
-}
-
-void
-purple_account_option_set_default_bool(PurpleAccountOption *option,
- gboolean value)
-{
- g_return_if_fail(option != NULL);
- g_return_if_fail(option->type == PURPLE_PREF_BOOLEAN);
-
- option->default_value.boolean = value;
-}
-
-void
-purple_account_option_set_default_int(PurpleAccountOption *option, int value)
-{
- g_return_if_fail(option != NULL);
- g_return_if_fail(option->type == PURPLE_PREF_INT);
-
- option->default_value.integer = value;
-}
-
-void
-purple_account_option_set_default_string(PurpleAccountOption *option,
- const char *value)
-{
- g_return_if_fail(option != NULL);
- g_return_if_fail(option->type == PURPLE_PREF_STRING);
-
- g_free(option->default_value.string);
- option->default_value.string = g_strdup(value);
-}
-
-void
-purple_account_option_string_set_masked(PurpleAccountOption *option, gboolean masked)
-{
- g_return_if_fail(option != NULL);
- g_return_if_fail(option->type == PURPLE_PREF_STRING);
-
- option->params.string.masked = masked;
-}
-
-void
-purple_account_option_string_set_hints(PurpleAccountOption *option, GSList *hints)
-{
- g_return_if_fail(option != NULL);
- g_return_if_fail(option->type == PURPLE_PREF_STRING);
-
- g_slist_free_full(option->params.string.hints, &g_free);
- option->params.string.hints = hints;
-}
-
-void
-purple_account_option_set_list(PurpleAccountOption *option, GList *values)
-{
- g_return_if_fail(option != NULL);
- g_return_if_fail(option->type == PURPLE_PREF_STRING_LIST);
-
- g_list_free_full(option->default_value.list,
- (GDestroyNotify)purple_account_option_list_free);
-
- option->default_value.list = values;
-}
-
-void
-purple_account_option_add_list_item(PurpleAccountOption *option,
- const char *key, const char *value)
-{
- PurpleKeyValuePair *kvp;
-
- g_return_if_fail(option != NULL);
- g_return_if_fail(key != NULL);
- g_return_if_fail(value != NULL);
- g_return_if_fail(option->type == PURPLE_PREF_STRING_LIST);
-
- kvp = g_new0(PurpleKeyValuePair, 1);
- kvp->key = g_strdup(key);
- kvp->value = g_strdup(value);
-
- option->default_value.list = g_list_append(option->default_value.list,
- kvp);
-}
-
-PurplePrefType
-purple_account_option_get_pref_type(const PurpleAccountOption *option)
-{
- g_return_val_if_fail(option != NULL, PURPLE_PREF_NONE);
-
- return option->type;
-}
-
-const char *
-purple_account_option_get_text(const PurpleAccountOption *option)
-{
- g_return_val_if_fail(option != NULL, NULL);
-
- return option->text;
-}
-
-const char *
-purple_account_option_get_setting(const PurpleAccountOption *option)
-{
- g_return_val_if_fail(option != NULL, NULL);
-
- return option->pref_name;
-}
-
-gboolean
-purple_account_option_get_default_bool(const PurpleAccountOption *option)
-{
- g_return_val_if_fail(option != NULL, FALSE);
- g_return_val_if_fail(option->type == PURPLE_PREF_BOOLEAN, FALSE);
-
- return option->default_value.boolean;
-}
-
-int
-purple_account_option_get_default_int(const PurpleAccountOption *option)
-{
- g_return_val_if_fail(option != NULL, -1);
- g_return_val_if_fail(option->type == PURPLE_PREF_INT, -1);
-
- return option->default_value.integer;
-}
-
-const char *
-purple_account_option_get_default_string(const PurpleAccountOption *option)
-{
- g_return_val_if_fail(option != NULL, NULL);
- g_return_val_if_fail(option->type == PURPLE_PREF_STRING, NULL);
-
- return option->default_value.string;
-}
-
-const char *
-purple_account_option_get_default_list_value(const PurpleAccountOption *option)
-{
- PurpleKeyValuePair *kvp;
-
- g_return_val_if_fail(option != NULL, NULL);
- g_return_val_if_fail(option->type == PURPLE_PREF_STRING_LIST, NULL);
-
- if (option->default_value.list == NULL)
- return NULL;
-
- kvp = option->default_value.list->data;
-
- return (kvp ? kvp->value : NULL);
-}
-
-gboolean
-purple_account_option_string_get_masked(const PurpleAccountOption *option)
-{
- g_return_val_if_fail(option != NULL, FALSE);
- g_return_val_if_fail(option->type == PURPLE_PREF_STRING, FALSE);
-
- return option->params.string.masked;
-}
-
-const GSList *
-purple_account_option_string_get_hints(const PurpleAccountOption *option)
-{
- g_return_val_if_fail(option != NULL, FALSE);
- g_return_val_if_fail(option->type == PURPLE_PREF_STRING, FALSE);
-
- return option->params.string.hints;
-}
-
-GList *
-purple_account_option_get_list(const PurpleAccountOption *option)
-{
- g_return_val_if_fail(option != NULL, NULL);
- g_return_val_if_fail(option->type == PURPLE_PREF_STRING_LIST, NULL);
-
- return option->default_value.list;
-}
--- a/libpurple/accountopt.h Fri Sep 27 02:44:08 2019 -0500
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,331 +0,0 @@
-/* purple
- *
- * 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, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02111-1301 USA
- */
-
-#ifndef PURPLE_ACCOUNTOPT_H
-#define PURPLE_ACCOUNTOPT_H
-/**
- * SECTION:accountopt
- * @section_id: libpurple-accountopt
- * @short_description: <filename>accountopt.h</filename>
- * @title: Account Options API
- */
-
-#include "prefs.h"
-
-/**************************************************************************/
-/* Data Structures */
-/**************************************************************************/
-
-/**
- * PurpleAccountOption:
- *
- * An option for an account.
- *
- * This is set by protocols, and appears in the account settings
- * dialogs.
- */
-typedef struct _PurpleAccountOption PurpleAccountOption;
-
-G_BEGIN_DECLS
-
-/**************************************************************************/
-/* Account Option API */
-/**************************************************************************/
-
-/**
- * purple_account_option_new:
- * @type: The type of option.
- * @text: The text of the option.
- * @pref_name: The account preference name for the option.
- *
- * Creates a new account option. If you know what @a type will be in advance,
- * consider using purple_account_option_bool_new(),
- * purple_account_option_int_new(), purple_account_option_string_new() or
- * purple_account_option_list_new() (as appropriate) instead.
- *
- * Returns: The account option.
- */
-PurpleAccountOption *purple_account_option_new(PurplePrefType type,
- const char *text, const char *pref_name);
-
-/**
- * purple_account_option_bool_new:
- * @text: The text of the option.
- * @pref_name: The account preference name for the option.
- * @default_value: The default value.
- *
- * Creates a new boolean account option.
- *
- * Returns: The account option.
- */
-PurpleAccountOption *purple_account_option_bool_new(const char *text,
- const char *pref_name, gboolean default_value);
-
-/**
- * purple_account_option_int_new:
- * @text: The text of the option.
- * @pref_name: The account preference name for the option.
- * @default_value: The default value.
- *
- * Creates a new integer account option.
- *
- * Returns: The account option.
- */
-PurpleAccountOption *purple_account_option_int_new(const char *text,
- const char *pref_name, int default_value);
-
-/**
- * purple_account_option_string_new:
- * @text: The text of the option.
- * @pref_name: The account preference name for the option.
- * @default_value: The default value.
- *
- * Creates a new string account option.
- *
- * Returns: The account option.
- */
-PurpleAccountOption *purple_account_option_string_new(const char *text,
- const char *pref_name, const char *default_value);
-
-/**
- * purple_account_option_list_new:
- * @text: The text of the option.
- * @pref_name: The account preference name for the option.
- * @list: (element-type PurpleKeyValuePair) (transfer full): The key, value list.
- *
- * Creates a new list account option.
- *
- * The list passed will be owned by the account option, and the
- * strings inside will be freed automatically.
- *
- * The list is a list of #PurpleKeyValuePair items. The key is the label that
- * should be displayed to the user, and the <type>(const char *)</type> value is
- * the internal ID that should be passed to purple_account_set_string() to
- * choose that value.
- *
- * Returns: The account option.
- */
-PurpleAccountOption *purple_account_option_list_new(const char *text,
- const char *pref_name, GList *list);
-
-/**
- * purple_account_option_destroy:
- * @option: The option to destroy.
- *
- * Destroys an account option.
- */
-void purple_account_option_destroy(PurpleAccountOption *option);
-
-/**
- * purple_account_option_set_default_bool:
- * @option: The account option.
- * @value: The default boolean value.
- *
- * Sets the default boolean value for an account option.
- */
-void purple_account_option_set_default_bool(PurpleAccountOption *option,
- gboolean value);
-
-/**
- * purple_account_option_set_default_int:
- * @option: The account option.
- * @value: The default integer value.
- *
- * Sets the default integer value for an account option.
- */
-void purple_account_option_set_default_int(PurpleAccountOption *option,
- int value);
-
-/**
- * purple_account_option_set_default_string:
- * @option: The account option.
- * @value: The default string value.
- *
- * Sets the default string value for an account option.
- */
-void purple_account_option_set_default_string(PurpleAccountOption *option,
- const char *value);
-
-/**
- * purple_account_option_string_set_masked:
- * @option: The account option.
- * @masked: The masking.
- *
- * Sets the masking for an account option. Setting this to %TRUE acts
- * as a hint to the UI that the option's value should be obscured from
- * view, like a password.
- */
-void
-purple_account_option_string_set_masked(PurpleAccountOption *option, gboolean masked);
-
-/**
- * purple_account_option_string_set_hints:
- * @option: The account option.
- * @hints: (element-type utf8) (transfer full): The list of hints, stored as strings.
- *
- * Sets the hint list for an account option.
- *
- * The list passed will be owned by the account option, and the
- * strings inside will be freed automatically.
- */
-void purple_account_option_string_set_hints(PurpleAccountOption *option,
- GSList *hints);
-
-/**
- * purple_account_option_set_list:
- * @option: The account option.
- * @values: (element-type PurpleKeyValuePair) (transfer full): The default list
- * value.
- *
- * Sets the list values for an account option.
- *
- * The list passed will be owned by the account option, and the
- * strings inside will be freed automatically.
- *
- * The list is in key, value pairs. The key is the ID stored and used
- * internally, and the value is the label displayed.
- */
-void purple_account_option_set_list(PurpleAccountOption *option, GList *values);
-
-/**
- * purple_account_option_add_list_item:
- * @option: The account option.
- * @key: The key.
- * @value: The value.
- *
- * Adds an item to a list account option.
- */
-void purple_account_option_add_list_item(PurpleAccountOption *option,
- const char *key, const char *value);
-
-/**
- * purple_account_option_get_pref_type:
- * @option: The account option.
- *
- * Returns the specified account option's type.
- *
- * Returns: The account option's type.
- */
-PurplePrefType purple_account_option_get_pref_type(const PurpleAccountOption *option);
-
-/**
- * purple_account_option_get_text:
- * @option: The account option.
- *
- * Returns the text for an account option.
- *
- * Returns: The account option's text.
- */
-const char *purple_account_option_get_text(const PurpleAccountOption *option);
-
-/**
- * purple_account_option_get_setting:
- * @option: The account option.
- *
- * Returns the name of an account option. This corresponds to the @c pref_name
- * parameter supplied to purple_account_option_new() or one of the
- * type-specific constructors.
- *
- * Returns: The option's name.
- */
-const char *purple_account_option_get_setting(const PurpleAccountOption *option);
-
-/**
- * purple_account_option_get_default_bool:
- * @option: The account option.
- *
- * Returns the default boolean value for an account option.
- *
- * Returns: The default boolean value.
- */
-gboolean purple_account_option_get_default_bool(const PurpleAccountOption *option);
-
-/**
- * purple_account_option_get_default_int:
- * @option: The account option.
- *
- * Returns the default integer value for an account option.
- *
- * Returns: The default integer value.
- */
-int purple_account_option_get_default_int(const PurpleAccountOption *option);
-
-/**
- * purple_account_option_get_default_string:
- * @option: The account option.
- *
- * Returns the default string value for an account option.
- *
- * Returns: The default string value.
- */
-const char *purple_account_option_get_default_string(
- const PurpleAccountOption *option);
-
-/**
- * purple_account_option_get_default_list_value:
- * @option: The account option.
- *
- * Returns the default string value for a list account option.
- *
- * Returns: The default list string value.
- */
-const char *purple_account_option_get_default_list_value(
- const PurpleAccountOption *option);
-
-/**
- * purple_account_option_string_get_masked:
- * @option: The account option.
- *
- * Returns whether an option's value should be masked from view, like a
- * password. If so, the UI might display each character of the option
- * as a '*' (for example).
- *
- * Returns: %TRUE if the option's value should be obscured.
- */
-gboolean
-purple_account_option_string_get_masked(const PurpleAccountOption *option);
-
-/**
- * purple_account_option_string_get_hints:
- * @option: The account option.
- *
- * Returns the list of hints for an account option.
- *
- * Returns: (element-type utf8) (transfer none): A list of hints.
- */
-const GSList * purple_account_option_string_get_hints(const PurpleAccountOption *option);
-
-/**
- * purple_account_option_get_list:
- * @option: The account option.
- *
- * Returns the list values for an account option.
- *
- * Returns: (element-type PurpleKeyValuePair) (transfer none): A list of
- * #PurpleKeyValuePair, mapping the human-readable description of the
- * value to the <type>(const char *)</type> that should be passed to
- * purple_account_set_string() to set the option.
- */
-GList *purple_account_option_get_list(const PurpleAccountOption *option);
-
-G_END_DECLS
-
-#endif /* PURPLE_ACCOUNTOPT_H */
--- a/libpurple/meson.build Fri Sep 27 02:44:08 2019 -0500
+++ b/libpurple/meson.build Fri Sep 27 03:43:47 2019 -0500
@@ -1,7 +1,6 @@
purple_coresources = [
'account.c',
'accounts.c',
- 'accountopt.c',
'action.c',
'attention.c',
'blistnode.c',
@@ -49,6 +48,7 @@
'protocol.c',
'protocols.c',
'purple-gio.c',
+ 'purpleaccountoption.c',
'purpleaccountusersplit.c',
'queuedoutputstream.c',
'request.c',
@@ -84,7 +84,6 @@
purple_coreheaders = [
'account.h',
'accounts.h',
- 'accountopt.h',
'action.h',
'attention.h',
'blistnode.h',
@@ -128,6 +127,7 @@
'protocol.h',
'protocols.h',
'purple-gio.h',
+ 'purpleaccountoption.h',
'purpleaccountusersplit.h',
'queuedoutputstream.h',
'request.h',
--- a/libpurple/protocol.h Fri Sep 27 02:44:08 2019 -0500
+++ b/libpurple/protocol.h Fri Sep 27 03:43:47 2019 -0500
@@ -39,7 +39,6 @@
typedef struct _PurpleProtocolClass PurpleProtocolClass;
#include "account.h"
-#include "accountopt.h"
#include "buddyicon.h"
#include "buddylist.h"
#include "connection.h"
@@ -51,6 +50,7 @@
#include "message.h"
#include "notify.h"
#include "plugins.h"
+#include "purpleaccountoption.h"
#include "purpleaccountusersplit.h"
#include "roomlist.h"
#include "status.h"
--- a/libpurple/protocols.c Fri Sep 27 02:44:08 2019 -0500
+++ b/libpurple/protocols.c Fri Sep 27 03:43:47 2019 -0500
@@ -21,12 +21,12 @@
*
*/
#include "internal.h"
-#include "accountopt.h"
#include "conversation.h"
#include "debug.h"
#include "network.h"
#include "notify.h"
#include "protocol.h"
+#include "purpleaccountoption.h"
#include "request.h"
#include "util.h"
--- a/libpurple/protocols/facebook/facebook.c Fri Sep 27 02:44:08 2019 -0500
+++ b/libpurple/protocols/facebook/facebook.c Fri Sep 27 03:43:47 2019 -0500
@@ -22,7 +22,6 @@
#include "internal.h"
#include "account.h"
-#include "accountopt.h"
#include "action.h"
#include "blistnode.h"
#include "buddy.h"
@@ -42,6 +41,7 @@
#include "presence.h"
#include "protocol.h"
#include "protocols.h"
+#include "purpleaccountoption.h"
#include "request.h"
#include "roomlist.h"
#include "server.h"
--- a/libpurple/protocols/gg/gg.c Fri Sep 27 02:44:08 2019 -0500
+++ b/libpurple/protocols/gg/gg.c Fri Sep 27 03:43:47 2019 -0500
@@ -33,7 +33,7 @@
#include "version.h"
#include "notify.h"
#include "buddylist.h"
-#include "accountopt.h"
+#include "purpleaccountoption.h"
#include "core.h"
#include "debug.h"
#include "util.h"
--- a/libpurple/protocols/gg/servconn.h Fri Sep 27 02:44:08 2019 -0500
+++ b/libpurple/protocols/gg/servconn.h Fri Sep 27 03:43:47 2019 -0500
@@ -31,7 +31,7 @@
#define PURPLE_GG_SERVCONN_H
#include <internal.h>
-#include <accountopt.h>
+#include <purpleaccountoption.h>
void ggp_servconn_setup(PurpleAccountOption *server_option);
void ggp_servconn_cleanup(void);
--- a/libpurple/protocols/jabber/jabber.c Fri Sep 27 02:44:08 2019 -0500
+++ b/libpurple/protocols/jabber/jabber.c Fri Sep 27 03:43:47 2019 -0500
@@ -23,7 +23,6 @@
#include "internal.h"
#include "account.h"
-#include "accountopt.h"
#include "buddylist.h"
#include "core.h"
#include "cmds.h"
@@ -36,6 +35,7 @@
#include "pluginpref.h"
#include "proxy.h"
#include "protocol.h"
+#include "purpleaccountoption.h"
#include "request.h"
#include "server.h"
#include "status.h"
--- a/libpurple/protocols/novell/novell.c Fri Sep 27 02:44:08 2019 -0500
+++ b/libpurple/protocols/novell/novell.c Fri Sep 27 03:43:47 2019 -0500
@@ -20,7 +20,6 @@
#include "internal.h"
-#include "accountopt.h"
#include "action.h"
#include "debug.h"
#include "plugins.h"
@@ -28,6 +27,7 @@
#include "nmuser.h"
#include "notify.h"
#include "novell.h"
+#include "purpleaccountoption.h"
#include "util.h"
#include "sslconn.h"
#include "request.h"
--- a/libpurple/protocols/oscar/oscar.c Fri Sep 27 02:44:08 2019 -0500
+++ b/libpurple/protocols/oscar/oscar.c Fri Sep 27 03:43:47 2019 -0500
@@ -31,7 +31,6 @@
#include "internal.h"
#include "account.h"
-#include "accountopt.h"
#include "buddyicon.h"
#include "conversation.h"
#include "core.h"
@@ -42,6 +41,7 @@
#include "notify.h"
#include "protocol.h"
#include "proxy.h"
+#include "purpleaccountoption.h"
#include "request.h"
#include "util.h"
#include "version.h"
--- a/libpurple/protocols/oscar/oscarcommon.h Fri Sep 27 02:44:08 2019 -0500
+++ b/libpurple/protocols/oscar/oscarcommon.h Fri Sep 27 03:43:47 2019 -0500
@@ -29,10 +29,10 @@
#include "internal.h"
-#include "accountopt.h"
#include "protocol.h"
#include "version.h"
#include "notify.h"
+#include "purpleaccountoption.h"
#include "status.h"
#define AIM_DEFAULT_LOGIN_SERVER "login.oscar.aol.com"
--- a/libpurple/protocols/sametime/sametime.c Fri Sep 27 02:44:08 2019 -0500
+++ b/libpurple/protocols/sametime/sametime.c Fri Sep 27 03:43:47 2019 -0500
@@ -33,7 +33,6 @@
/* purple includes */
#include "account.h"
-#include "accountopt.h"
#include "action.h"
#include "circularbuffer.h"
#include "conversation.h"
@@ -43,6 +42,7 @@
#include "notify.h"
#include "plugins.h"
#include "protocol.h"
+#include "purpleaccountoption.h"
#include "purpleaccountusersplit.h"
#include "request.h"
#include "version.h"
--- a/libpurple/protocols/zephyr/zephyr.c Fri Sep 27 02:44:08 2019 -0500
+++ b/libpurple/protocols/zephyr/zephyr.c Fri Sep 27 03:43:47 2019 -0500
@@ -28,7 +28,7 @@
*/
#include "libpurple/internal.h"
-#include "accountopt.h"
+#include "purpleaccountoption.h"
#include "action.h"
#include "debug.h"
#include "notify.h"
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/libpurple/purpleaccountoption.c Fri Sep 27 03:43:47 2019 -0500
@@ -0,0 +1,349 @@
+/* purple
+ *
+ * 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, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02111-1301 USA
+ */
+#include "internal.h"
+
+#include "purpleaccountoption.h"
+#include "util.h"
+#include "glibcompat.h"
+
+/*
+ * An option for an account.
+ *
+ * This is set by protocols, and appears in the account settings
+ * dialogs.
+ */
+struct _PurpleAccountOption
+{
+ PurplePrefType type; /* The type of value. */
+
+ char *text; /* The text that will appear to the user. */
+ char *pref_name; /* The name of the associated preference. */
+
+ union
+ {
+ gboolean boolean; /* The default boolean value. */
+ int integer; /* The default integer value. */
+ char *string; /* The default string value. */
+ GList *list; /* The default list value. */
+
+ } default_value;
+
+ union
+ {
+ struct
+ {
+ gboolean masked; /* Whether the value entered should
+ * be obscured from view (for
+ * passwords and similar options)
+ */
+ GSList *hints; /* List of hinted values */
+ } string;
+ } params;
+};
+
+PurpleAccountOption *
+purple_account_option_new(PurplePrefType type, const char *text,
+ const char *pref_name)
+{
+ PurpleAccountOption *option;
+
+ g_return_val_if_fail(type != PURPLE_PREF_NONE, NULL);
+ g_return_val_if_fail(text != NULL, NULL);
+ g_return_val_if_fail(pref_name != NULL, NULL);
+
+ option = g_new0(PurpleAccountOption, 1);
+
+ option->type = type;
+ option->text = g_strdup(text);
+ option->pref_name = g_strdup(pref_name);
+
+ return option;
+}
+
+PurpleAccountOption *
+purple_account_option_bool_new(const char *text, const char *pref_name,
+ gboolean default_value)
+{
+ PurpleAccountOption *option;
+
+ option = purple_account_option_new(PURPLE_PREF_BOOLEAN, text, pref_name);
+
+ if (option == NULL)
+ return NULL;
+
+ option->default_value.boolean = default_value;
+
+ return option;
+}
+
+PurpleAccountOption *
+purple_account_option_int_new(const char *text, const char *pref_name,
+ int default_value)
+{
+ PurpleAccountOption *option;
+
+ option = purple_account_option_new(PURPLE_PREF_INT, text, pref_name);
+
+ if (option == NULL)
+ return NULL;
+
+ option->default_value.integer = default_value;
+
+ return option;
+}
+
+PurpleAccountOption *
+purple_account_option_string_new(const char *text, const char *pref_name,
+ const char *default_value)
+{
+ PurpleAccountOption *option;
+
+ option = purple_account_option_new(PURPLE_PREF_STRING, text, pref_name);
+
+ if (option == NULL)
+ return NULL;
+
+ option->default_value.string = g_strdup(default_value);
+
+ return option;
+}
+
+PurpleAccountOption *
+purple_account_option_list_new(const char *text, const char *pref_name,
+ GList *list)
+{
+ PurpleAccountOption *option;
+
+ option = purple_account_option_new(PURPLE_PREF_STRING_LIST, text, pref_name);
+
+ if (option == NULL)
+ return NULL;
+
+ option->default_value.list = list;
+
+ return option;
+}
+
+static void
+purple_account_option_list_free(gpointer data, gpointer user_data)
+{
+ PurpleKeyValuePair *kvp = data;
+
+ g_free(kvp->value);
+ g_free(kvp->key);
+ g_free(kvp);
+}
+
+void
+purple_account_option_destroy(PurpleAccountOption *option)
+{
+ g_return_if_fail(option != NULL);
+
+ g_free(option->text);
+ g_free(option->pref_name);
+
+ if (option->type == PURPLE_PREF_STRING)
+ {
+ g_free(option->default_value.string);
+ g_slist_free_full(option->params.string.hints, &g_free);
+ }
+ else if (option->type == PURPLE_PREF_STRING_LIST)
+ {
+ g_list_free_full(option->default_value.list,
+ (GDestroyNotify)purple_account_option_list_free);
+ }
+
+ g_free(option);
+}
+
+void
+purple_account_option_set_default_bool(PurpleAccountOption *option,
+ gboolean value)
+{
+ g_return_if_fail(option != NULL);
+ g_return_if_fail(option->type == PURPLE_PREF_BOOLEAN);
+
+ option->default_value.boolean = value;
+}
+
+void
+purple_account_option_set_default_int(PurpleAccountOption *option, int value)
+{
+ g_return_if_fail(option != NULL);
+ g_return_if_fail(option->type == PURPLE_PREF_INT);
+
+ option->default_value.integer = value;
+}
+
+void
+purple_account_option_set_default_string(PurpleAccountOption *option,
+ const char *value)
+{
+ g_return_if_fail(option != NULL);
+ g_return_if_fail(option->type == PURPLE_PREF_STRING);
+
+ g_free(option->default_value.string);
+ option->default_value.string = g_strdup(value);
+}
+
+void
+purple_account_option_string_set_masked(PurpleAccountOption *option, gboolean masked)
+{
+ g_return_if_fail(option != NULL);
+ g_return_if_fail(option->type == PURPLE_PREF_STRING);
+
+ option->params.string.masked = masked;
+}
+
+void
+purple_account_option_string_set_hints(PurpleAccountOption *option, GSList *hints)
+{
+ g_return_if_fail(option != NULL);
+ g_return_if_fail(option->type == PURPLE_PREF_STRING);
+
+ g_slist_free_full(option->params.string.hints, &g_free);
+ option->params.string.hints = hints;
+}
+
+void
+purple_account_option_set_list(PurpleAccountOption *option, GList *values)
+{
+ g_return_if_fail(option != NULL);
+ g_return_if_fail(option->type == PURPLE_PREF_STRING_LIST);
+
+ g_list_free_full(option->default_value.list,
+ (GDestroyNotify)purple_account_option_list_free);
+
+ option->default_value.list = values;
+}
+
+void
+purple_account_option_add_list_item(PurpleAccountOption *option,
+ const char *key, const char *value)
+{
+ PurpleKeyValuePair *kvp;
+
+ g_return_if_fail(option != NULL);
+ g_return_if_fail(key != NULL);
+ g_return_if_fail(value != NULL);
+ g_return_if_fail(option->type == PURPLE_PREF_STRING_LIST);
+
+ kvp = g_new0(PurpleKeyValuePair, 1);
+ kvp->key = g_strdup(key);
+ kvp->value = g_strdup(value);
+
+ option->default_value.list = g_list_append(option->default_value.list,
+ kvp);
+}
+
+PurplePrefType
+purple_account_option_get_pref_type(const PurpleAccountOption *option)
+{
+ g_return_val_if_fail(option != NULL, PURPLE_PREF_NONE);
+
+ return option->type;
+}
+
+const char *
+purple_account_option_get_text(const PurpleAccountOption *option)
+{
+ g_return_val_if_fail(option != NULL, NULL);
+
+ return option->text;
+}
+
+const char *
+purple_account_option_get_setting(const PurpleAccountOption *option)
+{
+ g_return_val_if_fail(option != NULL, NULL);
+
+ return option->pref_name;
+}
+
+gboolean
+purple_account_option_get_default_bool(const PurpleAccountOption *option)
+{
+ g_return_val_if_fail(option != NULL, FALSE);
+ g_return_val_if_fail(option->type == PURPLE_PREF_BOOLEAN, FALSE);
+
+ return option->default_value.boolean;
+}
+
+int
+purple_account_option_get_default_int(const PurpleAccountOption *option)
+{
+ g_return_val_if_fail(option != NULL, -1);
+ g_return_val_if_fail(option->type == PURPLE_PREF_INT, -1);
+
+ return option->default_value.integer;
+}
+
+const char *
+purple_account_option_get_default_string(const PurpleAccountOption *option)
+{
+ g_return_val_if_fail(option != NULL, NULL);
+ g_return_val_if_fail(option->type == PURPLE_PREF_STRING, NULL);
+
+ return option->default_value.string;
+}
+
+const char *
+purple_account_option_get_default_list_value(const PurpleAccountOption *option)
+{
+ PurpleKeyValuePair *kvp;
+
+ g_return_val_if_fail(option != NULL, NULL);
+ g_return_val_if_fail(option->type == PURPLE_PREF_STRING_LIST, NULL);
+
+ if (option->default_value.list == NULL)
+ return NULL;
+
+ kvp = option->default_value.list->data;
+
+ return (kvp ? kvp->value : NULL);
+}
+
+gboolean
+purple_account_option_string_get_masked(const PurpleAccountOption *option)
+{
+ g_return_val_if_fail(option != NULL, FALSE);
+ g_return_val_if_fail(option->type == PURPLE_PREF_STRING, FALSE);
+
+ return option->params.string.masked;
+}
+
+const GSList *
+purple_account_option_string_get_hints(const PurpleAccountOption *option)
+{
+ g_return_val_if_fail(option != NULL, FALSE);
+ g_return_val_if_fail(option->type == PURPLE_PREF_STRING, FALSE);
+
+ return option->params.string.hints;
+}
+
+GList *
+purple_account_option_get_list(const PurpleAccountOption *option)
+{
+ g_return_val_if_fail(option != NULL, NULL);
+ g_return_val_if_fail(option->type == PURPLE_PREF_STRING_LIST, NULL);
+
+ return option->default_value.list;
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/libpurple/purpleaccountoption.h Fri Sep 27 03:43:47 2019 -0500
@@ -0,0 +1,331 @@
+/* purple
+ *
+ * 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, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02111-1301 USA
+ */
+
+#ifndef PURPLE_ACCOUNTOPT_H
+#define PURPLE_ACCOUNTOPT_H
+/**
+ * SECTION:accountopt
+ * @section_id: libpurple-accountopt
+ * @short_description: <filename>accountopt.h</filename>
+ * @title: Account Options API
+ */
+
+#include "prefs.h"
+
+/**************************************************************************/
+/* Data Structures */
+/**************************************************************************/
+
+/**
+ * PurpleAccountOption:
+ *
+ * An option for an account.
+ *
+ * This is set by protocols, and appears in the account settings
+ * dialogs.
+ */
+typedef struct _PurpleAccountOption PurpleAccountOption;
+
+G_BEGIN_DECLS
+
+/**************************************************************************/
+/* Account Option API */
+/**************************************************************************/
+
+/**
+ * purple_account_option_new:
+ * @type: The type of option.
+ * @text: The text of the option.
+ * @pref_name: The account preference name for the option.
+ *
+ * Creates a new account option. If you know what @a type will be in advance,
+ * consider using purple_account_option_bool_new(),
+ * purple_account_option_int_new(), purple_account_option_string_new() or
+ * purple_account_option_list_new() (as appropriate) instead.
+ *
+ * Returns: The account option.
+ */
+PurpleAccountOption *purple_account_option_new(PurplePrefType type,
+ const char *text, const char *pref_name);
+
+/**
+ * purple_account_option_bool_new:
+ * @text: The text of the option.
+ * @pref_name: The account preference name for the option.
+ * @default_value: The default value.
+ *
+ * Creates a new boolean account option.
+ *
+ * Returns: The account option.
+ */
+PurpleAccountOption *purple_account_option_bool_new(const char *text,
+ const char *pref_name, gboolean default_value);
+
+/**
+ * purple_account_option_int_new:
+ * @text: The text of the option.
+ * @pref_name: The account preference name for the option.
+ * @default_value: The default value.
+ *
+ * Creates a new integer account option.
+ *
+ * Returns: The account option.
+ */
+PurpleAccountOption *purple_account_option_int_new(const char *text,
+ const char *pref_name, int default_value);
+
+/**
+ * purple_account_option_string_new:
+ * @text: The text of the option.
+ * @pref_name: The account preference name for the option.
+ * @default_value: The default value.
+ *
+ * Creates a new string account option.
+ *
+ * Returns: The account option.
+ */
+PurpleAccountOption *purple_account_option_string_new(const char *text,
+ const char *pref_name, const char *default_value);
+
+/**
+ * purple_account_option_list_new:
+ * @text: The text of the option.
+ * @pref_name: The account preference name for the option.
+ * @list: (element-type PurpleKeyValuePair) (transfer full): The key, value list.
+ *
+ * Creates a new list account option.
+ *
+ * The list passed will be owned by the account option, and the
+ * strings inside will be freed automatically.
+ *
+ * The list is a list of #PurpleKeyValuePair items. The key is the label that
+ * should be displayed to the user, and the <type>(const char *)</type> value is
+ * the internal ID that should be passed to purple_account_set_string() to
+ * choose that value.
+ *
+ * Returns: The account option.
+ */
+PurpleAccountOption *purple_account_option_list_new(const char *text,
+ const char *pref_name, GList *list);
+
+/**
+ * purple_account_option_destroy:
+ * @option: The option to destroy.
+ *
+ * Destroys an account option.
+ */
+void purple_account_option_destroy(PurpleAccountOption *option);
+
+/**
+ * purple_account_option_set_default_bool:
+ * @option: The account option.
+ * @value: The default boolean value.
+ *
+ * Sets the default boolean value for an account option.
+ */
+void purple_account_option_set_default_bool(PurpleAccountOption *option,
+ gboolean value);
+
+/**
+ * purple_account_option_set_default_int:
+ * @option: The account option.
+ * @value: The default integer value.
+ *
+ * Sets the default integer value for an account option.
+ */
+void purple_account_option_set_default_int(PurpleAccountOption *option,
+ int value);
+
+/**
+ * purple_account_option_set_default_string:
+ * @option: The account option.
+ * @value: The default string value.
+ *
+ * Sets the default string value for an account option.
+ */
+void purple_account_option_set_default_string(PurpleAccountOption *option,
+ const char *value);
+
+/**
+ * purple_account_option_string_set_masked:
+ * @option: The account option.
+ * @masked: The masking.
+ *
+ * Sets the masking for an account option. Setting this to %TRUE acts
+ * as a hint to the UI that the option's value should be obscured from
+ * view, like a password.
+ */
+void
+purple_account_option_string_set_masked(PurpleAccountOption *option, gboolean masked);
+
+/**
+ * purple_account_option_string_set_hints:
+ * @option: The account option.
+ * @hints: (element-type utf8) (transfer full): The list of hints, stored as strings.
+ *
+ * Sets the hint list for an account option.
+ *
+ * The list passed will be owned by the account option, and the
+ * strings inside will be freed automatically.
+ */
+void purple_account_option_string_set_hints(PurpleAccountOption *option,
+ GSList *hints);
+
+/**
+ * purple_account_option_set_list:
+ * @option: The account option.
+ * @values: (element-type PurpleKeyValuePair) (transfer full): The default list
+ * value.
+ *
+ * Sets the list values for an account option.
+ *
+ * The list passed will be owned by the account option, and the
+ * strings inside will be freed automatically.
+ *
+ * The list is in key, value pairs. The key is the ID stored and used
+ * internally, and the value is the label displayed.
+ */
+void purple_account_option_set_list(PurpleAccountOption *option, GList *values);
+
+/**
+ * purple_account_option_add_list_item:
+ * @option: The account option.
+ * @key: The key.
+ * @value: The value.
+ *
+ * Adds an item to a list account option.
+ */
+void purple_account_option_add_list_item(PurpleAccountOption *option,
+ const char *key, const char *value);
+
+/**
+ * purple_account_option_get_pref_type:
+ * @option: The account option.
+ *
+ * Returns the specified account option's type.
+ *
+ * Returns: The account option's type.
+ */
+PurplePrefType purple_account_option_get_pref_type(const PurpleAccountOption *option);
+
+/**
+ * purple_account_option_get_text:
+ * @option: The account option.
+ *
+ * Returns the text for an account option.
+ *
+ * Returns: The account option's text.
+ */
+const char *purple_account_option_get_text(const PurpleAccountOption *option);
+
+/**
+ * purple_account_option_get_setting:
+ * @option: The account option.
+ *
+ * Returns the name of an account option. This corresponds to the @c pref_name
+ * parameter supplied to purple_account_option_new() or one of the
+ * type-specific constructors.
+ *
+ * Returns: The option's name.
+ */
+const char *purple_account_option_get_setting(const PurpleAccountOption *option);
+
+/**
+ * purple_account_option_get_default_bool:
+ * @option: The account option.
+ *
+ * Returns the default boolean value for an account option.
+ *
+ * Returns: The default boolean value.
+ */
+gboolean purple_account_option_get_default_bool(const PurpleAccountOption *option);
+
+/**
+ * purple_account_option_get_default_int:
+ * @option: The account option.
+ *
+ * Returns the default integer value for an account option.
+ *
+ * Returns: The default integer value.
+ */
+int purple_account_option_get_default_int(const PurpleAccountOption *option);
+
+/**
+ * purple_account_option_get_default_string:
+ * @option: The account option.
+ *
+ * Returns the default string value for an account option.
+ *
+ * Returns: The default string value.
+ */
+const char *purple_account_option_get_default_string(
+ const PurpleAccountOption *option);
+
+/**
+ * purple_account_option_get_default_list_value:
+ * @option: The account option.
+ *
+ * Returns the default string value for a list account option.
+ *
+ * Returns: The default list string value.
+ */
+const char *purple_account_option_get_default_list_value(
+ const PurpleAccountOption *option);
+
+/**
+ * purple_account_option_string_get_masked:
+ * @option: The account option.
+ *
+ * Returns whether an option's value should be masked from view, like a
+ * password. If so, the UI might display each character of the option
+ * as a '*' (for example).
+ *
+ * Returns: %TRUE if the option's value should be obscured.
+ */
+gboolean
+purple_account_option_string_get_masked(const PurpleAccountOption *option);
+
+/**
+ * purple_account_option_string_get_hints:
+ * @option: The account option.
+ *
+ * Returns the list of hints for an account option.
+ *
+ * Returns: (element-type utf8) (transfer none): A list of hints.
+ */
+const GSList * purple_account_option_string_get_hints(const PurpleAccountOption *option);
+
+/**
+ * purple_account_option_get_list:
+ * @option: The account option.
+ *
+ * Returns the list values for an account option.
+ *
+ * Returns: (element-type PurpleKeyValuePair) (transfer none): A list of
+ * #PurpleKeyValuePair, mapping the human-readable description of the
+ * value to the <type>(const char *)</type> that should be passed to
+ * purple_account_set_string() to set the option.
+ */
+GList *purple_account_option_get_list(const PurpleAccountOption *option);
+
+G_END_DECLS
+
+#endif /* PURPLE_ACCOUNTOPT_H */
--- a/pidgin/gtkaccount.c Fri Sep 27 02:44:08 2019 -0500
+++ b/pidgin/gtkaccount.c Fri Sep 27 03:43:47 2019 -0500
@@ -23,13 +23,13 @@
#include "pidgin.h"
#include "account.h"
-#include "accountopt.h"
#include "core.h"
#include "debug.h"
#include "notify.h"
#include "plugins.h"
#include "prefs.h"
#include "protocol.h"
+#include "purpleaccountoption.h"
#include "request.h"
#include "savedstatuses.h"
#include "signals.h"