pidgin/pidgin

90446617d967
Parents 001c4e774da0
Children 2b679acefffa
Use GList functions instead of manual iterations
--- a/finch/gntaccount.c Sat Oct 12 22:49:37 2019 -0400
+++ b/finch/gntaccount.c Sun Oct 13 15:45:39 2019 +0300
@@ -914,11 +914,7 @@
iter = purple_accounts_get_all();
if (iter) {
- for (; iter; iter = iter->next) {
- if (purple_account_get_enabled(iter->data, FINCH_UI))
- break;
- }
- if (!iter)
+ if (!g_list_find_custom(iter, FINCH_UI, (GCompareFunc)purple_account_get_enabled))
finch_accounts_show_all();
} else {
edit_account(NULL);
--- a/finch/plugins/gnttinyurl.c Sat Oct 12 22:49:37 2019 -0400
+++ b/finch/plugins/gnttinyurl.c Sun Oct 13 15:45:39 2019 +0300
@@ -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 Sat Oct 12 22:49:37 2019 -0400
+++ b/libpurple/e2ee.c Sun Oct 13 15:45:39 2019 +0300
@@ -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 Sat Oct 12 22:49:37 2019 -0400
+++ b/libpurple/media/backend-fs2.c Sun Oct 13 15:45:39 2019 +0300
@@ -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 Sat Oct 12 22:49:37 2019 -0400
+++ b/libpurple/plugins/idle.c Sun Oct 13 15:45:39 2019 +0300
@@ -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 Sat Oct 12 22:49:37 2019 -0400
+++ b/libpurple/protocols/bonjour/bonjour.c Sun Oct 13 15:45:39 2019 +0300
@@ -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 Sat Oct 12 22:49:37 2019 -0400
+++ b/libpurple/protocols/irc/msgs.c Sun Oct 13 15:45:39 2019 +0300
@@ -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 Sat Oct 12 22:49:37 2019 -0400
+++ b/libpurple/protocols/jabber/adhoccommands.c Sun Oct 13 15:45:39 2019 +0300
@@ -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 Sat Oct 12 22:49:37 2019 -0400
+++ b/libpurple/protocols/jabber/xdata.c Sun Oct 13 15:45:39 2019 +0300
@@ -146,11 +146,7 @@
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);
@@ -174,12 +170,8 @@
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);
--- a/libpurple/protocols/zephyr/zephyr.c Sat Oct 12 22:49:37 2019 -0400
+++ b/libpurple/protocols/zephyr/zephyr.c Sun Oct 13 15:45:39 2019 +0300
@@ -740,16 +740,15 @@
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);
+ 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 +1981,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 Sat Oct 12 22:49:37 2019 -0400
+++ b/libpurple/savedstatuses.c Sun Oct 13 15:45:39 2019 +0300
@@ -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 Sat Oct 12 22:49:37 2019 -0400
+++ b/pidgin/gtkaccount.c Sun Oct 13 15:45:39 2019 +0300
@@ -2222,10 +2222,9 @@
}
}
- 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();
+ ret = l != NULL;
+ g_list_foreach(l, (GFunc)add_account_to_liststore, global_buddyicon);
if (global_buddyicon != NULL)
g_object_unref(G_OBJECT(global_buddyicon));
@@ -2388,10 +2387,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 Sat Oct 12 22:49:37 2019 -0400
+++ b/pidgin/gtknotify.c Sun Oct 13 15:45:39 2019 +0300
@@ -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,13 +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);
gtk_widget_set_sensitive(pounce_dialog->dismiss_button, TRUE);
--- a/pidgin/plugins/screencap.c Sat Oct 12 22:49:37 2019 -0400
+++ b/pidgin/plugins/screencap.c Sun Oct 13 15:45:39 2019 +0300
@@ -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 Sat Oct 12 22:49:37 2019 -0400
+++ b/pidgin/plugins/xmppconsole/xmppconsole.c Sun Oct 13 15:45:39 2019 +0300
@@ -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);