From e8a65e3b688b9807ff912727bd50ebeb7562e622 Mon Sep 17 00:00:00 2001 From: James Booth Date: Sat, 22 Nov 2014 21:13:33 +0000 Subject: [PATCH] Renamed roster autocomplete functions --- src/command/command.c | 28 ++++++++++++++-------------- src/roster_list.c | 8 ++++---- src/roster_list.h | 8 ++++---- src/ui/titlebar.c | 4 ++-- tests/test_roster_list.c | 28 ++++++++++++++-------------- 5 files changed, 38 insertions(+), 38 deletions(-) diff --git a/src/command/command.c b/src/command/command.c index 7ad80bcc..967a2fe4 100644 --- a/src/command/command.c +++ b/src/command/command.c @@ -1864,7 +1864,7 @@ _cmd_complete_parameters(char *input, int *size) gchar *contact_choices[] = { "/msg", "/info", "/status" }; for (i = 0; i < ARRAY_SIZE(contact_choices); i++) { result = autocomplete_param_with_func(input, size, contact_choices[i], - roster_find_contact); + roster_contact_autocomplete); if (result != NULL) { ui_replace_input(input, result, size); g_free(result); @@ -1875,7 +1875,7 @@ _cmd_complete_parameters(char *input, int *size) gchar *resource_choices[] = { "/caps", "/software", "/ping" }; for (i = 0; i < ARRAY_SIZE(resource_choices); i++) { result = autocomplete_param_with_func(input, size, resource_choices[i], - roster_find_resource); + roster_fulljid_autocomplete); if (result != NULL) { ui_replace_input(input, result, size); g_free(result); @@ -1884,7 +1884,7 @@ _cmd_complete_parameters(char *input, int *size) } } - result = autocomplete_param_with_func(input, size, "/invite", roster_find_contact); + result = autocomplete_param_with_func(input, size, "/invite", roster_contact_autocomplete); if (result != NULL) { ui_replace_input(input, result, size); g_free(result); @@ -2013,7 +2013,7 @@ _who_autocomplete(char *input, int *size) "/who unavailable" }; for (i = 0; i < ARRAY_SIZE(group_commands); i++) { - result = autocomplete_param_with_func(input, size, group_commands[i], roster_find_group); + result = autocomplete_param_with_func(input, size, group_commands[i], roster_group_autocomplete); if (result != NULL) { return result; } @@ -2032,15 +2032,15 @@ static char * _roster_autocomplete(char *input, int *size) { char *result = NULL; - result = autocomplete_param_with_func(input, size, "/roster nick", roster_find_jid); + result = autocomplete_param_with_func(input, size, "/roster nick", roster_barejid_autocomplete); if (result != NULL) { return result; } - result = autocomplete_param_with_func(input, size, "/roster clearnick", roster_find_jid); + result = autocomplete_param_with_func(input, size, "/roster clearnick", roster_barejid_autocomplete); if (result != NULL) { return result; } - result = autocomplete_param_with_func(input, size, "/roster remove", roster_find_jid); + result = autocomplete_param_with_func(input, size, "/roster remove", roster_barejid_autocomplete); if (result != NULL) { return result; } @@ -2068,24 +2068,24 @@ static char * _group_autocomplete(char *input, int *size) { char *result = NULL; - result = autocomplete_param_with_func(input, size, "/group show", roster_find_group); + result = autocomplete_param_with_func(input, size, "/group show", roster_group_autocomplete); if (result != NULL) { return result; } - result = autocomplete_param_no_with_func(input, size, "/group add", 4, roster_find_contact); + result = autocomplete_param_no_with_func(input, size, "/group add", 4, roster_contact_autocomplete); if (result != NULL) { return result; } - result = autocomplete_param_no_with_func(input, size, "/group remove", 4, roster_find_contact); + result = autocomplete_param_no_with_func(input, size, "/group remove", 4, roster_contact_autocomplete); if (result != NULL) { return result; } - result = autocomplete_param_with_func(input, size, "/group add", roster_find_group); + result = autocomplete_param_with_func(input, size, "/group add", roster_group_autocomplete); if (result != NULL) { return result; } - result = autocomplete_param_with_func(input, size, "/group remove", roster_find_group); + result = autocomplete_param_with_func(input, size, "/group remove", roster_group_autocomplete); if (result != NULL) { return result; } @@ -2307,7 +2307,7 @@ _otr_autocomplete(char *input, int *size) { char *found = NULL; - found = autocomplete_param_with_func(input, size, "/otr start", roster_find_contact); + found = autocomplete_param_with_func(input, size, "/otr start", roster_contact_autocomplete); if (found != NULL) { return found; } @@ -2326,7 +2326,7 @@ _otr_autocomplete(char *input, int *size) g_string_append(beginning, " "); g_string_append(beginning, args[1]); - found = autocomplete_param_with_func(input, size, beginning->str, roster_find_contact); + found = autocomplete_param_with_func(input, size, beginning->str, roster_contact_autocomplete); g_string_free(beginning, TRUE); if (found != NULL) { g_strfreev(args); diff --git a/src/roster_list.c b/src/roster_list.c index 771a1554..886a3fe7 100644 --- a/src/roster_list.c +++ b/src/roster_list.c @@ -322,13 +322,13 @@ roster_has_pending_subscriptions(void) } char * -roster_find_contact(char *search_str) +roster_contact_autocomplete(char *search_str) { return autocomplete_complete(name_ac, search_str, TRUE); } char * -roster_find_resource(char *search_str) +roster_fulljid_autocomplete(char *search_str) { return autocomplete_complete(fulljid_ac, search_str, TRUE); } @@ -384,13 +384,13 @@ roster_get_groups(void) } char * -roster_find_group(char *search_str) +roster_group_autocomplete(char *search_str) { return autocomplete_complete(groups_ac, search_str, TRUE); } char * -roster_find_jid(char *search_str) +roster_barejid_autocomplete(char *search_str) { return autocomplete_complete(barejid_ac, search_str, TRUE); } diff --git a/src/roster_list.h b/src/roster_list.h index 280dbe1c..13b0bac7 100644 --- a/src/roster_list.h +++ b/src/roster_list.h @@ -58,12 +58,12 @@ gboolean roster_add(const char * const barejid, const char * const name, GSList char * roster_barejid_from_name(const char * const name); GSList * roster_get_contacts(void); gboolean roster_has_pending_subscriptions(void); -char * roster_find_contact(char *search_str); -char * roster_find_resource(char *search_str); +char * roster_contact_autocomplete(char *search_str); +char * roster_fulljid_autocomplete(char *search_str); GSList * roster_get_group(const char * const group); GSList * roster_get_groups(void); -char * roster_find_group(char *search_str); -char * roster_find_jid(char *search_str); +char * roster_group_autocomplete(char *search_str); +char * roster_barejid_autocomplete(char *search_str); GSList * roster_get_contacts_by_presence(const char * const presence); GSList * roster_get_nogroup(void); diff --git a/src/ui/titlebar.c b/src/ui/titlebar.c index 42da14b6..8d05eefb 100644 --- a/src/ui/titlebar.c +++ b/src/ui/titlebar.c @@ -264,7 +264,7 @@ _show_privacy(void) if (current_recipient != NULL) { char *recipient_jid = NULL; - char *found_contact = roster_find_contact(current_recipient); + char *found_contact = roster_contact_autocomplete(current_recipient); if (found_contact != NULL) { recipient_jid = roster_barejid_from_name(current_recipient); free(found_contact); @@ -338,7 +338,7 @@ _show_contact_presence(void) if (prefs_get_boolean(PREF_PRESENCE) && current_recipient) { char *recipient_jid = NULL; - char *found_contact = roster_find_contact(current_recipient); + char *found_contact = roster_contact_autocomplete(current_recipient); if (found_contact) { recipient_jid = roster_barejid_from_name(current_recipient); free(found_contact); diff --git a/tests/test_roster_list.c b/tests/test_roster_list.c index 5c767531..41ccb8cf 100644 --- a/tests/test_roster_list.c +++ b/tests/test_roster_list.c @@ -158,7 +158,7 @@ void find_first_exists(void **state) char *search = strdup("B"); - char *result = roster_find_contact(search); + char *result = roster_contact_autocomplete(search); assert_string_equal("Bob", result); free(result); free(search); @@ -172,7 +172,7 @@ void find_second_exists(void **state) roster_add("Dave", NULL, NULL, NULL, FALSE); roster_add("Bob", NULL, NULL, NULL, FALSE); - char *result = roster_find_contact("Dav"); + char *result = roster_contact_autocomplete("Dav"); assert_string_equal("Dave", result); free(result); roster_free(); @@ -185,7 +185,7 @@ void find_third_exists(void **state) roster_add("Dave", NULL, NULL, NULL, FALSE); roster_add("Bob", NULL, NULL, NULL, FALSE); - char *result = roster_find_contact("Ja"); + char *result = roster_contact_autocomplete("Ja"); assert_string_equal("James", result); free(result); roster_free(); @@ -198,7 +198,7 @@ void find_returns_null(void **state) roster_add("Dave", NULL, NULL, NULL, FALSE); roster_add("Bob", NULL, NULL, NULL, FALSE); - char *result = roster_find_contact("Mike"); + char *result = roster_contact_autocomplete("Mike"); assert_null(result); roster_free(); } @@ -206,7 +206,7 @@ void find_returns_null(void **state) void find_on_empty_returns_null(void **state) { roster_init(); - char *result = roster_find_contact("James"); + char *result = roster_contact_autocomplete("James"); assert_null(result); roster_free(); } @@ -218,8 +218,8 @@ void find_twice_returns_second_when_two_match(void **state) roster_add("Jamie", NULL, NULL, NULL, FALSE); roster_add("Bob", NULL, NULL, NULL, FALSE); - char *result1 = roster_find_contact("Jam"); - char *result2 = roster_find_contact(result1); + char *result1 = roster_contact_autocomplete("Jam"); + char *result2 = roster_contact_autocomplete(result1); assert_string_equal("Jamie", result2); free(result1); free(result2); @@ -240,11 +240,11 @@ void find_five_times_finds_fifth(void **state) roster_add("Jamy", NULL, NULL, NULL, FALSE); roster_add("Jamz", NULL, NULL, NULL, FALSE); - char *result1 = roster_find_contact("Jam"); - char *result2 = roster_find_contact(result1); - char *result3 = roster_find_contact(result2); - char *result4 = roster_find_contact(result3); - char *result5 = roster_find_contact(result4); + char *result1 = roster_contact_autocomplete("Jam"); + char *result2 = roster_contact_autocomplete(result1); + char *result3 = roster_contact_autocomplete(result2); + char *result4 = roster_contact_autocomplete(result3); + char *result5 = roster_contact_autocomplete(result4); assert_string_equal("Jamo", result5); free(result1); free(result2); @@ -261,9 +261,9 @@ void find_twice_returns_first_when_two_match_and_reset(void **state) roster_add("Jamie", NULL, NULL, NULL, FALSE); roster_add("Bob", NULL, NULL, NULL, FALSE); - char *result1 = roster_find_contact("Jam"); + char *result1 = roster_contact_autocomplete("Jam"); roster_reset_search_attempts(); - char *result2 = roster_find_contact(result1); + char *result2 = roster_contact_autocomplete(result1); assert_string_equal("James", result2); free(result1); free(result2);