diff options
author | Elliott Sales de Andrade <quantum.analyst@gmail.com> | 2022-10-05 00:50:12 -0500 |
---|---|---|
committer | Elliott Sales de Andrade <quantum.analyst@gmail.com> | 2022-10-05 00:50:12 -0500 |
commit | 6fd215ca0899af3fce37355b69a0447f55427d0c (patch) | |
tree | 7b87a326dec7cb4519209973ce669b2fce767d90 | |
parent | 72d4db0a871d7598db2eee47cc0e17ae6b5bc944 (diff) | |
download | pidgin-6fd215ca0899af3fce37355b69a0447f55427d0c.tar.gz |
Merge purple_status_set_active_with_attrs{,_dict}
Its docs say it should only be called by the account, conversation, and buddy
APIs, and all of those use the `_dict` version, so the other can be dropped,
and we might as well rename it at the same time.
Testing Done:
Compiled and opened demo account, which indirectly call this through buddy statuses.
Reviewed at https://reviews.imfreedom.org/r/1861/
-rw-r--r-- | ChangeLog.API | 6 | ||||
-rw-r--r-- | libpurple/account.c | 5 | ||||
-rw-r--r-- | libpurple/protocols.c | 4 | ||||
-rw-r--r-- | libpurple/status.c | 21 | ||||
-rw-r--r-- | libpurple/status.h | 28 | ||||
-rw-r--r-- | libpurple/util.c | 26 |
6 files changed, 30 insertions, 60 deletions
diff --git a/ChangeLog.API b/ChangeLog.API index 50795eac0a..d1bbbc501b 100644 --- a/ChangeLog.API +++ b/ChangeLog.API @@ -257,8 +257,9 @@ version 3.0.0 (??/??/????): * PurpleStatus is now a GObject. Please see the documentation for details. * purple_status_attr_* functions are now purple_status_attribute_* - * purple_status_set_active_with_attrs_list renamed to - purple_status_set_active_with_attrs_dict + * purple_status_set_active_with_attrs renamed to + purple_status_set_active_with_attributes and now takes a + GHashTable * PurpleStatusAttr renamed to PurpleStatusAttribute * PurplePresence is now an abstract type, and is a GObject. Please see the documentation for details. @@ -727,6 +728,7 @@ version 3.0.0 (??/??/????): * purple_ssl_strerror * purple_ssl_uninit * purple_ssl_write + * purple_status_set_active_with_attrs_list * purple_status_set_attr_boolean * purple_status_set_attr_int * purple_status_set_attr_string diff --git a/libpurple/account.c b/libpurple/account.c index f885b80e7a..b9f8a8b703 100644 --- a/libpurple/account.c +++ b/libpurple/account.c @@ -1536,8 +1536,9 @@ purple_account_set_status_attrs(PurpleAccount *account, const char *status_id, return; } - if (active || purple_status_is_independent(status)) - purple_status_set_active_with_attrs_dict(status, active, attrs); + if (active || purple_status_is_independent(status)) { + purple_status_set_active_with_attributes(status, active, attrs); + } /* * Our current statuses are saved to accounts.xml (so that when we diff --git a/libpurple/protocols.c b/libpurple/protocols.c index baf749bfbb..243f44077e 100644 --- a/libpurple/protocols.c +++ b/libpurple/protocols.c @@ -116,7 +116,7 @@ purple_protocol_got_account_status_with_attributes(PurpleAccount *account, g_return_if_fail(status != NULL); - purple_status_set_active_with_attrs_dict(status, TRUE, attributes); + purple_status_set_active_with_attributes(status, TRUE, attributes); } void @@ -234,7 +234,7 @@ purple_protocol_got_user_status_with_attributes(PurpleAccount *account, old_status = purple_presence_get_active_status(presence); - purple_status_set_active_with_attrs_dict(status, TRUE, attributes); + purple_status_set_active_with_attributes(status, TRUE, attributes); purple_buddy_update_status(buddy, old_status); } diff --git a/libpurple/status.c b/libpurple/status.c index 12fa97b9d6..5265e4f47c 100644 --- a/libpurple/status.c +++ b/libpurple/status.c @@ -646,27 +646,12 @@ status_set_attr_string(PurpleStatus *status, const char *id, void purple_status_set_active(PurpleStatus *status, gboolean active) { - purple_status_set_active_with_attrs_dict(status, active, NULL); -} - -/* - * This used to parse the va_list directly, but now it creates a GList - * and passes it to purple_status_set_active_with_attrs_list(). That - * function was created because account.c needs to pass a GList of - * attributes to the status API. - */ -void -purple_status_set_active_with_attrs(PurpleStatus *status, gboolean active, va_list args) -{ - GHashTable *attrs = purple_attrs_from_vargs(args); - - purple_status_set_active_with_attrs_dict(status, active, attrs); - g_hash_table_destroy(attrs); + purple_status_set_active_with_attributes(status, active, NULL); } void -purple_status_set_active_with_attrs_dict(PurpleStatus *status, gboolean active, - GHashTable *attrs) +purple_status_set_active_with_attributes(PurpleStatus *status, gboolean active, + GHashTable *attrs) { gboolean changed = FALSE; GList *l; diff --git a/libpurple/status.h b/libpurple/status.h index 2361eb1360..b95f1ed81f 100644 --- a/libpurple/status.h +++ b/libpurple/status.h @@ -613,29 +613,13 @@ PurpleStatus *purple_status_new(PurpleStatusType *status_type, void purple_status_set_active(PurpleStatus *status, gboolean active); /** - * purple_status_set_active_with_attrs: + * purple_status_set_active_with_attributes: * @status: The status. * @active: The active state. - * @args: A list of attributes to set on the status. This list is - * composed of key/value pairs, where each key is a valid - * attribute name for this PurpleStatusType. The list should - * be NULL terminated. - * - * Sets whether or not a status is active. - * - * This should only be called by the account, conversation, and buddy APIs. - */ -void purple_status_set_active_with_attrs(PurpleStatus *status, gboolean active, - va_list args); - -/** - * purple_status_set_active_with_attrs_dict: (rename-to purple_status_set_active_with_attrs) - * @status: The status. - * @active: The active state. - * @attrs: (element-type utf8 gpointer): A hash table of attributes to set on - * the status. This hash table's keys are valid attribute names for - * this PurpleStatusType. The hash table is not modified or freed by - * this function. + * @attrs: (nullable) (element-type utf8 gpointer): A hash table of attributes + * to set on the status. This hash table's keys are valid attribute + * names for this PurpleStatusType. The hash table is not modified or + * freed by this function. * * Sets whether or not a status is active. * @@ -643,7 +627,7 @@ void purple_status_set_active_with_attrs(PurpleStatus *status, gboolean active, * * Since: 3.0.0 */ -void purple_status_set_active_with_attrs_dict(PurpleStatus *status, gboolean active, GHashTable *attrs); +void purple_status_set_active_with_attributes(PurpleStatus *status, gboolean active, GHashTable *attrs); /** * purple_status_get_status_type: diff --git a/libpurple/util.c b/libpurple/util.c index f7dac2a7b8..a2bbcbc8b4 100644 --- a/libpurple/util.c +++ b/libpurple/util.c @@ -931,15 +931,6 @@ purple_escape_filename(const char *str) return buf; } -static void -set_status_with_attrs(PurpleStatus *status, ...) -{ - va_list args; - va_start(args, status); - purple_status_set_active_with_attrs(status, TRUE, args); - va_end(args); -} - void purple_util_set_current_song(const char *title, const char *artist, const char *album) { PurpleAccountManager *manager = purple_account_manager_get_default(); @@ -956,11 +947,18 @@ void purple_util_set_current_song(const char *title, const char *artist, const c if (!tune) continue; if (title) { - set_status_with_attrs(tune, - PURPLE_TUNE_TITLE, title, - PURPLE_TUNE_ARTIST, artist, - PURPLE_TUNE_ALBUM, album, - NULL); + GHashTable *attributes = g_hash_table_new(g_str_hash, g_str_equal); + + g_hash_table_insert(attributes, PURPLE_TUNE_TITLE, + (gpointer)title); + g_hash_table_insert(attributes, PURPLE_TUNE_ARTIST, + (gpointer)artist); + g_hash_table_insert(attributes, PURPLE_TUNE_TITLE, + (gpointer)album); + + purple_status_set_active_with_attributes(tune, TRUE, attributes); + + g_hash_table_destroy(attributes); } else { purple_status_set_active(tune, FALSE); } |