1
0
mirror of https://github.com/profanity-im/profanity.git synced 2024-09-22 19:45:54 -04:00

Free resource lists on /account command

This commit is contained in:
James Booth 2015-02-09 19:50:41 +00:00
parent 44c5b34a71
commit 268c33e1c6
2 changed files with 13 additions and 8 deletions

2
.gitignore vendored
View File

@ -25,7 +25,7 @@ configure.scan
stamp-h1 stamp-h1
*~ *~
*dirstamp *dirstamp
valgrind.out valgrind*.out*
core core
bugs/ bugs/
TODO TODO

View File

@ -717,20 +717,24 @@ cons_show_account(ProfAccount *account)
GList *resources = jabber_get_available_resources(); GList *resources = jabber_get_available_resources();
GList *ordered_resources = NULL; GList *ordered_resources = NULL;
if (resources != NULL) { GList *curr = resources;
if (curr != NULL) {
win_save_println(console, "Resources:"); win_save_println(console, "Resources:");
// sort in order of availabiltiy // sort in order of availabiltiy
while (resources != NULL) { while (curr != NULL) {
Resource *resource = resources->data; Resource *resource = curr->data;
ordered_resources = g_list_insert_sorted(ordered_resources, ordered_resources = g_list_insert_sorted(ordered_resources,
resource, (GCompareFunc)resource_compare_availability); resource, (GCompareFunc)resource_compare_availability);
resources = g_list_next(resources); curr = g_list_next(curr);
} }
} }
while (ordered_resources != NULL) { g_list_free(resources);
Resource *resource = ordered_resources->data;
curr = ordered_resources;
while (curr != NULL) {
Resource *resource = curr->data;
const char *resource_presence = string_from_resource_presence(resource->presence); const char *resource_presence = string_from_resource_presence(resource->presence);
theme_item_t presence_colour = theme_main_presence_attrs(resource_presence); theme_item_t presence_colour = theme_main_presence_attrs(resource_presence);
win_save_vprint(console, '-', NULL, NO_EOL, presence_colour, "", " %s (%d), %s", resource->name, resource->priority, resource_presence); win_save_vprint(console, '-', NULL, NO_EOL, presence_colour, "", " %s (%d), %s", resource->name, resource->priority, resource_presence);
@ -785,8 +789,9 @@ cons_show_account(ProfAccount *account)
caps_destroy(caps); caps_destroy(caps);
} }
ordered_resources = g_list_next(ordered_resources); curr = g_list_next(curr);
} }
g_list_free(ordered_resources);
} }
cons_alert(); cons_alert();