1
0
mirror of https://github.com/profanity-im/profanity.git synced 2024-12-04 14:46:46 -05:00

Autocomplete: added free function

Fixed tests
This commit is contained in:
James Booth 2013-01-11 00:17:18 +00:00
parent ce8faa8d34
commit 89967905db
10 changed files with 38 additions and 21 deletions

View File

@ -72,8 +72,8 @@ accounts_load(void)
void void
accounts_close(void) accounts_close(void)
{ {
p_autocomplete_clear(all_ac); p_autocomplete_free(all_ac);
p_autocomplete_clear(enabled_ac); p_autocomplete_free(enabled_ac);
g_key_file_free(accounts); g_key_file_free(accounts);
} }

View File

@ -712,20 +712,20 @@ cmd_init(void)
void void
cmd_close(void) cmd_close(void)
{ {
p_autocomplete_clear(commands_ac); p_autocomplete_free(commands_ac);
p_autocomplete_clear(who_ac); p_autocomplete_free(who_ac);
p_autocomplete_clear(help_ac); p_autocomplete_free(help_ac);
p_autocomplete_clear(notify_ac); p_autocomplete_free(notify_ac);
p_autocomplete_clear(sub_ac); p_autocomplete_free(sub_ac);
p_autocomplete_clear(log_ac); p_autocomplete_free(log_ac);
p_autocomplete_clear(prefs_ac); p_autocomplete_free(prefs_ac);
p_autocomplete_clear(autoaway_ac); p_autocomplete_free(autoaway_ac);
p_autocomplete_clear(autoaway_mode_ac); p_autocomplete_free(autoaway_mode_ac);
p_autocomplete_clear(theme_ac); p_autocomplete_free(theme_ac);
if (theme_load_ac != NULL) { if (theme_load_ac != NULL) {
p_autocomplete_clear(theme_load_ac); p_autocomplete_free(theme_load_ac);
} }
p_autocomplete_clear(account_ac); p_autocomplete_free(account_ac);
} }
// Command autocompletion functions // Command autocompletion functions

View File

@ -48,6 +48,12 @@ contact_list_clear(void)
g_hash_table_remove_all(contacts); g_hash_table_remove_all(contacts);
} }
void
contact_list_free()
{
p_autocomplete_free(ac);
}
void void
contact_list_reset_search_attempts(void) contact_list_reset_search_attempts(void)
{ {

View File

@ -29,6 +29,7 @@
void contact_list_init(void); void contact_list_init(void);
void contact_list_clear(void); void contact_list_clear(void);
void contact_list_free(void);
void contact_list_reset_search_attempts(void); void contact_list_reset_search_attempts(void);
void contact_list_remove(const char * const jid); void contact_list_remove(const char * const jid);
gboolean contact_list_add(const char * const jid, const char * const name, gboolean contact_list_add(const char * const jid, const char * const name,

View File

@ -72,7 +72,7 @@ prefs_load(void)
void void
prefs_close(void) prefs_close(void)
{ {
p_autocomplete_clear(boolean_choice_ac); p_autocomplete_free(boolean_choice_ac);
g_key_file_free(prefs); g_key_file_free(prefs);
} }

View File

@ -63,6 +63,14 @@ p_autocomplete_reset(PAutocomplete ac)
} }
} }
void
p_autocomplete_free(PAutocomplete ac)
{
p_autocomplete_clear(ac);
g_free(ac);
ac = NULL;
}
gboolean gboolean
p_autocomplete_add(PAutocomplete ac, void *item) p_autocomplete_add(PAutocomplete ac, void *item)
{ {

View File

@ -36,6 +36,7 @@ PAutocomplete p_obj_autocomplete_new(PStrFunc str_func, PCopyFunc copy_func,
PEqualDeepFunc equal_deep_func, GDestroyNotify free_func); PEqualDeepFunc equal_deep_func, GDestroyNotify free_func);
void p_autocomplete_clear(PAutocomplete ac); void p_autocomplete_clear(PAutocomplete ac);
void p_autocomplete_reset(PAutocomplete ac); void p_autocomplete_reset(PAutocomplete ac);
void p_autocomplete_free(PAutocomplete ac);
gboolean p_autocomplete_add(PAutocomplete ac, void *item); gboolean p_autocomplete_add(PAutocomplete ac, void *item);
gboolean p_autocomplete_remove(PAutocomplete ac, const char * const item); gboolean p_autocomplete_remove(PAutocomplete ac, const char * const item);
GSList * p_autocomplete_get_list(PAutocomplete ac); GSList * p_autocomplete_get_list(PAutocomplete ac);

View File

@ -545,11 +545,12 @@ static void
_shutdown(void) _shutdown(void)
{ {
jabber_disconnect(); jabber_disconnect();
contact_list_clear(); contact_list_free();
ui_close(); ui_close();
chat_log_close(); chat_log_close();
prefs_close(); prefs_close();
theme_close(); theme_close();
accounts_close();
cmd_close(); cmd_close();
log_close(); log_close();
} }

View File

@ -358,7 +358,7 @@ _room_free(muc_room *room)
room->roster = NULL; room->roster = NULL;
} }
if (room->nick_ac != NULL) { if (room->nick_ac != NULL) {
p_autocomplete_clear(room->nick_ac); p_autocomplete_free(room->nick_ac);
} }
if (room->nick_changes != NULL) { if (room->nick_changes != NULL) {
g_hash_table_remove_all(room->nick_changes); g_hash_table_remove_all(room->nick_changes);

View File

@ -191,7 +191,7 @@ static void test_status_when_no_value(void)
static void update_show(void) static void update_show(void)
{ {
contact_list_add("James", NULL, "away", NULL, NULL, FALSE); contact_list_add("James", NULL, "away", NULL, NULL, FALSE);
contact_list_update_contact("James", "dnd", NULL); contact_list_update_contact("James", "dnd", NULL, NULL);
GSList *list = get_contact_list(); GSList *list = get_contact_list();
assert_int_equals(1, g_slist_length(list)); assert_int_equals(1, g_slist_length(list));
@ -203,7 +203,7 @@ static void update_show(void)
static void set_show_to_null(void) static void set_show_to_null(void)
{ {
contact_list_add("James", NULL, "away", NULL, NULL, FALSE); contact_list_add("James", NULL, "away", NULL, NULL, FALSE);
contact_list_update_contact("James", NULL, NULL); contact_list_update_contact("James", NULL, NULL, NULL);
GSList *list = get_contact_list(); GSList *list = get_contact_list();
assert_int_equals(1, g_slist_length(list)); assert_int_equals(1, g_slist_length(list));
@ -215,7 +215,7 @@ static void set_show_to_null(void)
static void update_status(void) static void update_status(void)
{ {
contact_list_add("James", NULL, NULL, "I'm not here right now", NULL, FALSE); contact_list_add("James", NULL, NULL, "I'm not here right now", NULL, FALSE);
contact_list_update_contact("James", NULL, "Gone to lunch"); contact_list_update_contact("James", NULL, "Gone to lunch", NULL);
GSList *list = get_contact_list(); GSList *list = get_contact_list();
assert_int_equals(1, g_slist_length(list)); assert_int_equals(1, g_slist_length(list));
@ -227,7 +227,7 @@ static void update_status(void)
static void set_status_to_null(void) static void set_status_to_null(void)
{ {
contact_list_add("James", NULL, NULL, "Gone to lunch", NULL, FALSE); contact_list_add("James", NULL, NULL, "Gone to lunch", NULL, FALSE);
contact_list_update_contact("James", NULL, NULL); contact_list_update_contact("James", NULL, NULL, NULL);
GSList *list = get_contact_list(); GSList *list = get_contact_list();
assert_int_equals(1, g_slist_length(list)); assert_int_equals(1, g_slist_length(list));