pidgin/pidgin

Merged in default (pull request #604)

2019-10-15, Gary Kramlich
099e1c9bfac3
Merged in default (pull request #604)

Use GList functions instead of manual iterations

Approved-by: Elliott Sales de Andrade
Approved-by: Gary Kramlich
Approved-by: Eion Robb
--- a/finch/plugins/gnttinyurl.c Tue Oct 15 03:59:57 2019 +0000
+++ b/finch/plugins/gnttinyurl.c Tue Oct 15 04:05:27 2019 +0000
@@ -221,17 +221,15 @@
}
/* ensure the conversation still exists */
- for (; convs; convs = convs->next) {
- if ((PurpleConversation *)(convs->data) == conv) {
- FinchConv *fconv = FINCH_CONV(conv);
- gchar *str = g_strdup_printf("[%d] %s", data->num, url);
- GntTextView *tv = GNT_TEXT_VIEW(fconv->tv);
- gnt_text_view_tag_change(tv, data->tag, str, FALSE);
- g_free(str);
- g_free(data->tag);
- g_free(data);
- return;
- }
+ if (g_list_find(convs, conv)) {
+ FinchConv *fconv = FINCH_CONV(conv);
+ gchar *str = g_strdup_printf("[%d] %s", data->num, url);
+ GntTextView *tv = GNT_TEXT_VIEW(fconv->tv);
+ gnt_text_view_tag_change(tv, data->tag, str, FALSE);
+ g_free(str);
+ g_free(data->tag);
+ g_free(data);
+ return;
}
g_free(data->tag);
g_free(data);
--- a/libpurple/e2ee.c Tue Oct 15 03:59:57 2019 +0000
+++ b/libpurple/e2ee.c Tue Oct 15 04:05:27 2019 +0000
@@ -189,8 +189,7 @@
main_provider = NULL;
- for (it = clear_states; it; it = g_list_next(it))
- purple_conversation_set_e2ee_state(it->data, NULL);
+ g_list_foreach(clear_states, (GFunc)purple_conversation_set_e2ee_state, NULL);
g_list_free(clear_states);
}
--- a/libpurple/media/backend-fs2.c Tue Oct 15 03:59:57 2019 +0000
+++ b/libpurple/media/backend-fs2.c Tue Oct 15 04:05:27 2019 +0000
@@ -498,10 +498,7 @@
/* VA-API elements aren't well supported in Farstream. Ignore them. */
features = gst_registry_get_feature_list_by_plugin(gst_registry_get(),
"vaapi");
- for (it = features; it; it = it->next) {
- gst_plugin_feature_set_rank((GstPluginFeature *)it->data,
- GST_RANK_NONE);
- }
+ g_list_foreach(features, (GFunc)gst_plugin_feature_set_rank, GINT_TO_POINTER(GST_RANK_NONE));
gst_plugin_feature_list_free(features);
}
--- a/libpurple/plugins/idle.c Tue Oct 15 03:59:57 2019 +0000
+++ b/libpurple/plugins/idle.c Tue Oct 15 04:05:27 2019 +0000
@@ -221,16 +221,9 @@
static void
unidle_all_action(PurplePluginAction *action)
{
- GList *l;
-
/* freeing the list here will cause segfaults if the user idles an account
* after the list is freed */
- for (l = idled_accts; l; l = l->next)
- {
- PurpleAccount *account = l->data;
- set_idle_time(account, 0);
- }
-
+ g_list_foreach(idled_accts, (GFunc)set_idle_time, GINT_TO_POINTER(0));
g_list_free(idled_accts);
idled_accts = NULL;
}
--- a/libpurple/protocols/bonjour/bonjour.c Tue Oct 15 03:59:57 2019 +0000
+++ b/libpurple/protocols/bonjour/bonjour.c Tue Oct 15 04:05:27 2019 +0000
@@ -444,17 +444,11 @@
static void
bonjour_rename_group(PurpleConnection *connection, const char *old_name, PurpleGroup *group, GList *moved_buddies)
{
- GList *cur;
const char *new_group;
- PurpleBuddy *buddy;
new_group = purple_group_get_name(group);
- for (cur = moved_buddies; cur; cur = cur->next) {
- buddy = cur->data;
- bonjour_do_group_change(buddy, new_group);
- }
-
+ g_list_foreach(moved_buddies, (GFunc)bonjour_do_group_change, new_group);
}
static gboolean
--- a/libpurple/protocols/irc/msgs.c Tue Oct 15 03:59:57 2019 +0000
+++ b/libpurple/protocols/irc/msgs.c Tue Oct 15 04:05:27 2019 +0000
@@ -699,14 +699,9 @@
}
if (users != NULL) {
- GList *l;
-
purple_chat_conversation_add_users(PURPLE_CHAT_CONVERSATION(convo), users, NULL, flags, FALSE);
- for (l = users; l != NULL; l = l->next)
- g_free(l->data);
-
- g_list_free(users);
+ g_list_free_full(users, g_free);
g_list_free(flags);
}
--- a/libpurple/protocols/jabber/adhoccommands.c Tue Oct 15 03:59:57 2019 +0000
+++ b/libpurple/protocols/jabber/adhoccommands.c Tue Oct 15 04:05:27 2019 +0000
@@ -113,7 +113,6 @@
static void do_adhoc_action_cb(JabberStream *js, PurpleXmlNode *result, const char *actionhandle, gpointer user_data) {
PurpleXmlNode *command;
- GList *action;
JabberAdHocActionInfo *actionInfo = user_data;
JabberIq *iq = jabber_iq_new(js, JABBER_IQ_SET);
jabber_iq_set_callback(iq, jabber_adhoc_parse, NULL);
@@ -134,11 +133,7 @@
purple_xmlnode_insert_child(command,result);
}
- for(action = actionInfo->actionslist; action; action = g_list_next(action)) {
- char *handle = action->data;
- g_free(handle);
- }
- g_list_free(actionInfo->actionslist);
+ g_list_free_full(actionInfo->actionslist, g_free);
g_free(actionInfo->sessionid);
g_free(actionInfo->who);
g_free(actionInfo->node);
--- a/libpurple/protocols/jabber/xdata.c Tue Oct 15 03:59:57 2019 +0000
+++ b/libpurple/protocols/jabber/xdata.c Tue Oct 15 04:05:27 2019 +0000
@@ -145,13 +145,7 @@
g_free(data->values->data);
data->values = g_slist_delete_link(data->values, data->values);
}
- if (data->actions) {
- GList *action;
- for(action = data->actions; action; action = g_list_next(action)) {
- g_free(action->data);
- }
- g_list_free(data->actions);
- }
+ g_list_free_full(data->actions, g_free);
g_free(data);
if (hasActions)
@@ -167,20 +161,13 @@
jabber_x_data_action_cb cb = data->cb;
gpointer user_data = data->user_data;
JabberStream *js = data->js;
- gboolean hasActions = FALSE;
+ gboolean hasActions = (data->actions != NULL);
g_hash_table_destroy(data->fields);
while(data->values) {
g_free(data->values->data);
data->values = g_slist_delete_link(data->values, data->values);
}
- if (data->actions) {
- GList *action;
- hasActions = TRUE;
- for(action = data->actions; action; action = g_list_next(action)) {
- g_free(action->data);
- }
- g_list_free(data->actions);
- }
+ g_list_free_full(data->actions, g_free);
g_free(data);
purple_xmlnode_set_namespace(result, "jabber:x:data");
--- a/libpurple/protocols/zephyr/zephyr.c Tue Oct 15 03:59:57 2019 +0000
+++ b/libpurple/protocols/zephyr/zephyr.c Tue Oct 15 04:05:27 2019 +0000
@@ -740,16 +740,16 @@
static gboolean pending_zloc(zephyr_account *zephyr, const char *who)
{
GList *curr;
-
- for (curr = zephyr->pending_zloc_names; curr != NULL; curr = curr->next) {
- char* normalized_who = local_zephyr_normalize(zephyr,who);
- if (!g_ascii_strcasecmp(normalized_who, (char *)curr->data)) {
- g_free((char *)curr->data);
- zephyr->pending_zloc_names = g_list_delete_link(zephyr->pending_zloc_names, curr);
- return TRUE;
- }
- }
- return FALSE;
+ char* normalized_who = local_zephyr_normalize(zephyr,who);
+
+ curr = g_list_find_custom(zephyr->pending_zloc_names, normalized_who, (GCompareFunc)g_ascii_strcasecmp);
+ g_free(normalized_who);
+ if (curr == NULL)
+ return FALSE;
+
+ g_free((char *)curr->data);
+ zephyr->pending_zloc_names = g_list_delete_link(zephyr->pending_zloc_names, curr);
+ return TRUE;
}
/* Called when the server notifies us a message couldn't get sent */
@@ -1982,17 +1982,11 @@
static void zephyr_close(PurpleConnection * gc)
{
- GList *l;
GSList *s;
zephyr_account *zephyr = purple_connection_get_protocol_data(gc);
pid_t tzc_pid = zephyr->tzc_pid;
- l = zephyr->pending_zloc_names;
- while (l) {
- g_free((char *)l->data);
- l = l->next;
- }
- g_list_free(zephyr->pending_zloc_names);
+ g_list_free_full(zephyr->pending_zloc_names, g_free);
if (purple_account_get_bool(purple_connection_get_account(gc), "write_anyone", FALSE))
write_anyone(zephyr);
--- a/libpurple/savedstatuses.c Tue Oct 15 03:59:57 2019 +0000
+++ b/libpurple/savedstatuses.c Tue Oct 15 04:05:27 2019 +0000
@@ -683,16 +683,9 @@
purple_savedstatus_unset_all_substatuses(const PurpleAccount *account,
gpointer user_data)
{
- GList *iter;
- PurpleSavedStatus *status;
-
g_return_if_fail(account != NULL);
- for (iter = saved_statuses; iter != NULL; iter = iter->next)
- {
- status = (PurpleSavedStatus *)iter->data;
- purple_savedstatus_unset_substatus(status, account);
- }
+ g_list_foreach(saved_statuses, (GFunc)purple_savedstatus_unset_substatus, account);
}
void
--- a/pidgin/gtkaccount.c Tue Oct 15 03:59:57 2019 +0000
+++ b/pidgin/gtkaccount.c Tue Oct 15 04:05:27 2019 +0000
@@ -2208,7 +2208,6 @@
populate_accounts_list(AccountsWindow *dialog)
{
GList *l;
- gboolean ret = FALSE;
GdkPixbuf *global_buddyicon = NULL;
const char *path;
@@ -2222,15 +2221,13 @@
}
}
- for (l = purple_accounts_get_all(); l != NULL; l = l->next) {
- ret = TRUE;
- add_account_to_liststore((PurpleAccount *)l->data, global_buddyicon);
- }
+ l = purple_accounts_get_all();
+ g_list_foreach(l, (GFunc)add_account_to_liststore, global_buddyicon);
if (global_buddyicon != NULL)
g_object_unref(G_OBJECT(global_buddyicon));
- return ret;
+ return l != NULL;
}
static void
@@ -2388,10 +2385,8 @@
global_buddyicon_changed(const char *name, PurplePrefType type,
gconstpointer value, gpointer window)
{
- GList *list;
- for (list = purple_accounts_get_all(); list; list = list->next) {
- account_modified_cb(list->data, window);
- }
+ GList *list = purple_accounts_get_all();
+ g_list_foreach(list, (GFunc)account_modified_cb, window);
}
void
--- a/pidgin/gtknotify.c Tue Oct 15 03:59:57 2019 +0000
+++ b/pidgin/gtknotify.c Tue Oct 15 04:05:27 2019 +0000
@@ -274,7 +274,6 @@
{
PidginNotifyPounceData *pounce_data;
PidginNotifyDialog *dialog = (PidginNotifyDialog*)data;
- PurplePounce *pounce;
GList *list;
list = purple_pounces_get_all();
@@ -283,12 +282,9 @@
PIDGIN_POUNCE_DATA, &pounce_data,
-1);
- for (; list != NULL; list = list->next) {
- pounce = list->data;
- if (pounce == pounce_data->pounce) {
- pidgin_pounce_editor_show(pounce_data->account, NULL, pounce_data->pounce);
- return;
- }
+ if (g_list_find(list, pounce_data->pounce) != NULL) {
+ pidgin_pounce_editor_show(pounce_data->account, NULL, pounce_data->pounce);
+ return;
}
purple_debug_warning("gtknotify", "Pounce was destroyed.\n");
@@ -348,12 +344,8 @@
g_list_free_full(list, (GDestroyNotify)gtk_tree_path_free);
pounces = purple_pounces_get_all();
- for (; pounces != NULL; pounces = pounces->next) {
- PurplePounce *pounce = pounces->data;
- if (pounce == pounce_data->pounce) {
- gtk_widget_set_sensitive(pounce_dialog->edit_button, TRUE);
- break;
- }
+ if (g_list_find(pounces, pounce_data->pounce) != NULL) {
+ gtk_widget_set_sensitive(pounce_dialog->edit_button, TRUE);
}
gtk_widget_set_sensitive(pounce_dialog->open_button, TRUE);
--- a/pidgin/plugins/screencap.c Tue Oct 15 03:59:57 2019 +0000
+++ b/pidgin/plugins/screencap.c Tue Oct 15 04:05:27 2019 +0000
@@ -720,14 +720,10 @@
g_return_if_fail(conv_insert_image != NULL);
conv_submenu = gtk_widget_get_parent(conv_insert_image);
- pos = -1;
children = gtk_container_get_children(GTK_CONTAINER(conv_submenu));
- for (it = children, i = 0; it; it = g_list_next(it), i++) {
- if (it->data == conv_insert_image) {
- pos = i + 1;
- break;
- }
- }
+ pos = g_list_index(children, conv_insert_image);
+ if (pos != -1)
+ ++pos;
g_list_free(children);
g_warn_if_fail(pos >= 0);
--- a/pidgin/plugins/xmppconsole/xmppconsole.c Tue Oct 15 03:59:57 2019 +0000
+++ b/pidgin/plugins/xmppconsole/xmppconsole.c Tue Oct 15 04:05:27 2019 +0000
@@ -514,22 +514,13 @@
static void
signed_off_cb(PurpleConnection *gc)
{
- int i = 0;
- GList *l;
+ int i;
if (!console)
return;
- l = console->accounts;
- while (l) {
- PurpleConnection *g = l->data;
- if (gc == g)
- break;
- i++;
- l = l->next;
- }
-
- if (l == NULL)
+ i = g_list_index(console->accounts, gc);
+ if (i == -1)
return;
gtk_combo_box_text_remove(GTK_COMBO_BOX_TEXT(console->dropdown), i);