diff options
author | James Booth <boothj5@gmail.com> | 2013-01-25 01:11:49 +0000 |
---|---|---|
committer | James Booth <boothj5@gmail.com> | 2013-01-25 01:11:49 +0000 |
commit | 527e739ac6962627ad6b5c76fa08357e33b6da0e (patch) | |
tree | d292484d9c7c2c3fdc5fbb4ee88d7c820a091ac6 | |
parent | 6b632625df37be70f221efc9d2a4adfca40786ed (diff) | |
download | profani-tty-527e739ac6962627ad6b5c76fa08357e33b6da0e.tar.gz |
Got rid of old naming convention on prof_autocomplete
-rw-r--r-- | Makefile.am | 6 | ||||
-rw-r--r-- | src/accounts.c | 42 | ||||
-rw-r--r-- | src/autocomplete.c (renamed from src/prof_autocomplete.c) | 36 | ||||
-rw-r--r-- | src/autocomplete.h (renamed from src/prof_autocomplete.h) | 26 | ||||
-rw-r--r-- | src/command.c | 238 | ||||
-rw-r--r-- | src/contact_list.c | 16 | ||||
-rw-r--r-- | src/muc.c | 16 | ||||
-rw-r--r-- | src/muc.h | 4 | ||||
-rw-r--r-- | src/preferences.c | 16 | ||||
-rw-r--r-- | tests/test_autocomplete.c (renamed from tests/test_prof_autocomplete.c) | 110 | ||||
-rw-r--r-- | tests/testsuite.c | 2 | ||||
-rw-r--r-- | tests/testsuite.h | 2 |
12 files changed, 257 insertions, 257 deletions
diff --git a/Makefile.am b/Makefile.am index 71a9ad2e..3f7485d8 100644 --- a/Makefile.am +++ b/Makefile.am @@ -1,8 +1,8 @@ bin_PROGRAMS = profanity profanity_SOURCES = src/command.c src/contact.c src/history.c src/jabber.h \ - src/preferences.c src/prof_autocomplete.c src/status_bar.c \ + src/preferences.c src/autocomplete.c src/status_bar.c \ src/command.h src/contact.h src/history.h src/log.c src/preferences.h \ - src/prof_autocomplete.h src/title_bar.c src/windows.c src/common.c \ + src/autocomplete.h src/title_bar.c src/windows.c src/common.c \ src/contact_list.c src/input_win.c src/log.h src/profanity.c \ src/prof_history.c src/ui.h src/common.h src/ contact_list.h src/connection.c \ src/main.c src/profanity.h src/prof_history.h src/chat_log.c \ @@ -17,7 +17,7 @@ TESTS = tests/testsuite check_PROGRAMS = tests/testsuite tests_testsuite_SOURCES = tests/test_contact_list.c src/contact_list.c src/contact.c \ tests/test_common.c tests/test_prof_history.c src/prof_history.c src/common.c \ - tests/test_prof_autocomplete.c src/prof_autocomplete.c tests/testsuite.c \ + tests/test_autocomplete.c src/autocomplete.c tests/testsuite.c \ tests/test_parser.c src/parser.c tests/test_jid.c src/jid.c tests_testsuite_LDADD = -lheadunit -lstdc++ diff --git a/src/accounts.c b/src/accounts.c index 4bb5ec89..08e73b90 100644 --- a/src/accounts.c +++ b/src/accounts.c @@ -28,13 +28,13 @@ #include "accounts.h" #include "files.h" #include "log.h" -#include "prof_autocomplete.h" +#include "autocomplete.h" static gchar *accounts_loc; static GKeyFile *accounts; -static PAutocomplete all_ac; -static PAutocomplete enabled_ac; +static Autocomplete all_ac; +static Autocomplete enabled_ac; static void _save_accounts(void); @@ -42,8 +42,8 @@ void accounts_load(void) { log_info("Loading accounts"); - all_ac = p_autocomplete_new(); - enabled_ac = p_autocomplete_new(); + all_ac = autocomplete_new(); + enabled_ac = autocomplete_new(); accounts_loc = files_get_accounts_file(); accounts = g_key_file_new(); @@ -58,9 +58,9 @@ accounts_load(void) gsize i; for (i = 0; i < njids; i++) { if (g_key_file_get_boolean(accounts, jids[i], "enabled", NULL)) { - p_autocomplete_add(enabled_ac, strdup(jids[i])); + autocomplete_add(enabled_ac, strdup(jids[i])); } - p_autocomplete_add(all_ac, strdup(jids[i])); + autocomplete_add(all_ac, strdup(jids[i])); } for (i = 0; i < njids; i++) { @@ -72,33 +72,33 @@ accounts_load(void) void accounts_close(void) { - p_autocomplete_free(all_ac); - p_autocomplete_free(enabled_ac); + autocomplete_free(all_ac); + autocomplete_free(enabled_ac); g_key_file_free(accounts); } char * accounts_find_enabled(char *prefix) { - return p_autocomplete_complete(enabled_ac, prefix); + return autocomplete_complete(enabled_ac, prefix); } char * accounts_find_all(char *prefix) { - return p_autocomplete_complete(all_ac, prefix); + return autocomplete_complete(all_ac, prefix); } void accounts_reset_all_search(void) { - p_autocomplete_reset(all_ac); + autocomplete_reset(all_ac); } void accounts_reset_enabled_search(void) { - p_autocomplete_reset(enabled_ac); + autocomplete_reset(enabled_ac); } void @@ -113,8 +113,8 @@ accounts_add_login(const char *jid, const char *altdomain) } _save_accounts(); - p_autocomplete_add(all_ac, strdup(jid)); - p_autocomplete_add(enabled_ac, strdup(jid)); + autocomplete_add(all_ac, strdup(jid)); + autocomplete_add(enabled_ac, strdup(jid)); // already exists, update old style accounts } else { @@ -184,7 +184,7 @@ accounts_enable(const char * const name) if (g_key_file_has_group(accounts, name)) { g_key_file_set_boolean(accounts, name, "enabled", TRUE); _save_accounts(); - p_autocomplete_add(enabled_ac, strdup(name)); + autocomplete_add(enabled_ac, strdup(name)); return TRUE; } else { return FALSE; @@ -197,7 +197,7 @@ accounts_disable(const char * const name) if (g_key_file_has_group(accounts, name)) { g_key_file_set_boolean(accounts, name, "enabled", FALSE); _save_accounts(); - p_autocomplete_remove(enabled_ac, strdup(name)); + autocomplete_remove(enabled_ac, strdup(name)); return TRUE; } else { return FALSE; @@ -233,11 +233,11 @@ accounts_rename(const char * const account_name, const char * const new_name) g_key_file_remove_group(accounts, account_name, NULL); _save_accounts(); - p_autocomplete_remove(all_ac, strdup(account_name)); - p_autocomplete_add(all_ac, strdup(new_name)); + autocomplete_remove(all_ac, strdup(account_name)); + autocomplete_add(all_ac, strdup(new_name)); if (g_key_file_get_boolean(accounts, new_name, "enabled", NULL)) { - p_autocomplete_remove(enabled_ac, strdup(account_name)); - p_autocomplete_add(enabled_ac, strdup(new_name)); + autocomplete_remove(enabled_ac, strdup(account_name)); + autocomplete_add(enabled_ac, strdup(new_name)); } return TRUE; diff --git a/src/prof_autocomplete.c b/src/autocomplete.c index 65f1b89e..baeeecb2 100644 --- a/src/prof_autocomplete.c +++ b/src/autocomplete.c @@ -1,5 +1,5 @@ /* - * prof_autocomplete.c + * autocomplete.c * * Copyright (C) 2012, 2013 James Booth <boothj5@gmail.com> * @@ -23,20 +23,20 @@ #include <stdlib.h> #include <string.h> -#include "prof_autocomplete.h" +#include "autocomplete.h" -struct p_autocomplete_t { +struct autocomplete_t { GSList *items; GSList *last_found; gchar *search_str; }; -static gchar * _search_from(PAutocomplete ac, GSList *curr); +static gchar * _search_from(Autocomplete ac, GSList *curr); -PAutocomplete -p_autocomplete_new(void) +Autocomplete +autocomplete_new(void) { - PAutocomplete new = malloc(sizeof(struct p_autocomplete_t)); + Autocomplete new = malloc(sizeof(struct autocomplete_t)); new->items = NULL; new->last_found = NULL; new->search_str = NULL; @@ -45,16 +45,16 @@ p_autocomplete_new(void) } void -p_autocomplete_clear(PAutocomplete ac) +autocomplete_clear(Autocomplete ac) { g_slist_free_full(ac->items, free); ac->items = NULL; - p_autocomplete_reset(ac); + autocomplete_reset(ac); } void -p_autocomplete_reset(PAutocomplete ac) +autocomplete_reset(Autocomplete ac) { ac->last_found = NULL; if (ac->search_str != NULL) { @@ -64,15 +64,15 @@ p_autocomplete_reset(PAutocomplete ac) } void -p_autocomplete_free(PAutocomplete ac) +autocomplete_free(Autocomplete ac) { - p_autocomplete_clear(ac); + autocomplete_clear(ac); g_free(ac); ac = NULL; } gboolean -p_autocomplete_add(PAutocomplete ac, void *item) +autocomplete_add(Autocomplete ac, void *item) { if (ac->items == NULL) { ac->items = g_slist_append(ac->items, item); @@ -111,7 +111,7 @@ p_autocomplete_add(PAutocomplete ac, void *item) } gboolean -p_autocomplete_remove(PAutocomplete ac, const char * const item) +autocomplete_remove(Autocomplete ac, const char * const item) { // reset last found if it points to the item to be removed if (ac->last_found != NULL) @@ -140,7 +140,7 @@ p_autocomplete_remove(PAutocomplete ac, const char * const item) } GSList * -p_autocomplete_get_list(PAutocomplete ac) +autocomplete_get_list(Autocomplete ac) { GSList *copy = NULL; GSList *curr = ac->items; @@ -154,7 +154,7 @@ p_autocomplete_get_list(PAutocomplete ac) } gchar * -p_autocomplete_complete(PAutocomplete ac, gchar *search_str) +autocomplete_complete(Autocomplete ac, gchar *search_str) { gchar *found = NULL; @@ -184,13 +184,13 @@ p_autocomplete_complete(PAutocomplete ac, gchar *search_str) return found; // we found nothing, reset search - p_autocomplete_reset(ac); + autocomplete_reset(ac); return NULL; } } static gchar * -_search_from(PAutocomplete ac, GSList *curr) +_search_from(Autocomplete ac, GSList *curr) { while(curr) { diff --git a/src/prof_autocomplete.h b/src/autocomplete.h index d6476661..03f4a013 100644 --- a/src/prof_autocomplete.h +++ b/src/autocomplete.h @@ -1,5 +1,5 @@ /* - * prof_autocomplete.h + * autocomplete.h * * Copyright (C) 2012, 2013 James Booth <boothj5@gmail.com> * @@ -20,26 +20,26 @@ * */ -#ifndef PROF_AUTOCOMPLETE_H -#define PROF_AUTOCOMPLETE_H +#ifndef AUTOCOMPLETE_H +#define AUTOCOMPLETE_H #include <glib.h> -typedef struct p_autocomplete_t *PAutocomplete; +typedef struct autocomplete_t *Autocomplete; typedef const char * (*PStrFunc)(const void *obj); typedef void * (*PCopyFunc)(const void *obj); typedef int (*PEqualFunc)(const void *o1, const void *o2); typedef int (*PEqualDeepFunc)(const void *o1, const void *o2); -PAutocomplete p_autocomplete_new(void); -PAutocomplete p_obj_autocomplete_new(PStrFunc str_func, PCopyFunc copy_func, +Autocomplete autocomplete_new(void); +Autocomplete obj_autocomplete_new(PStrFunc str_func, PCopyFunc copy_func, PEqualDeepFunc equal_deep_func, GDestroyNotify free_func); -void p_autocomplete_clear(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_remove(PAutocomplete ac, const char * const item); -GSList * p_autocomplete_get_list(PAutocomplete ac); -gchar * p_autocomplete_complete(PAutocomplete ac, gchar *search_str); +void autocomplete_clear(Autocomplete ac); +void autocomplete_reset(Autocomplete ac); +void autocomplete_free(Autocomplete ac); +gboolean autocomplete_add(Autocomplete ac, void *item); +gboolean autocomplete_remove(Autocomplete ac, const char * const item); +GSList * autocomplete_get_list(Autocomplete ac); +gchar * autocomplete_complete(Autocomplete ac, gchar *search_str); #endif diff --git a/src/command.c b/src/command.c index aa08b9f3..1631f253 100644 --- a/src/command.c +++ b/src/command.c @@ -40,7 +40,7 @@ #include "log.h" #include "parser.h" #include "preferences.h" -#include "prof_autocomplete.h" +#include "autocomplete.h" #include "profanity.h" #include "muc.h" #include "theme.h" @@ -84,7 +84,7 @@ static void _account_autocomplete(char *input, int *size); static void _parameter_autocomplete(char *input, int *size, char *command, autocomplete_func func); static void _parameter_autocomplete_with_ac(char *input, int *size, char *command, - PAutocomplete ac); + Autocomplete ac); static int _strtoi(char *str, int *saveptr, int min, int max); gchar** _cmd_parse_args(const char * const inp, int min, int max, int *num); @@ -632,19 +632,19 @@ static struct cmd_t presence_commands[] = NULL } } }, }; -static PAutocomplete commands_ac; -static PAutocomplete who_ac; -static PAutocomplete help_ac; -static PAutocomplete notify_ac; -static PAutocomplete prefs_ac; -static PAutocomplete sub_ac; -static PAutocomplete log_ac; -static PAutocomplete autoaway_ac; -static PAutocomplete autoaway_mode_ac; -static PAutocomplete titlebar_ac; -static PAutocomplete theme_ac; -static PAutocomplete theme_load_ac; -static PAutocomplete account_ac; +static Autocomplete commands_ac; +static Autocomplete who_ac; +static Autocomplete help_ac; +static Autocomplete notify_ac; +static Autocomplete prefs_ac; +static Autocomplete sub_ac; +static Autocomplete log_ac; +static Autocomplete autoaway_ac; +static Autocomplete autoaway_mode_ac; +static Autocomplete titlebar_ac; +static Autocomplete theme_ac; +static Autocomplete theme_load_ac; +static Autocomplete account_ac; /* * Initialise command autocompleter and history @@ -654,93 +654,93 @@ cmd_init(void) { log_info("Initialising commands"); - commands_ac = p_autocomplete_new(); - who_ac = p_autocomplete_new(); - - prefs_ac = p_autocomplete_new(); - p_autocomplete_add(prefs_ac, strdup("ui")); - p_autocomplete_add(prefs_ac, strdup("desktop")); - p_autocomplete_add(prefs_ac, strdup("chat")); - p_autocomplete_add(prefs_ac, strdup("log")); - p_autocomplete_add(prefs_ac, strdup("conn")); - p_autocomplete_add(prefs_ac, strdup("presence")); - - help_ac = p_autocomplete_new(); - p_autocomplete_add(help_ac, strdup("list")); - p_autocomplete_add(help_ac, strdup("basic")); - p_autocomplete_add(help_ac, strdup("presence")); - p_autocomplete_add(help_ac, strdup("settings")); - p_autocomplete_add(help_ac, strdup("navigation")); - - notify_ac = p_autocomplete_new(); - p_autocomplete_add(notify_ac, strdup("message")); - p_autocomplete_add(notify_ac, strdup("typing")); - p_autocomplete_add(notify_ac, strdup("remind")); - p_autocomplete_add(notify_ac, strdup("status")); - - sub_ac = p_autocomplete_new(); - p_autocomplete_add(sub_ac, strdup("request")); - p_autocomplete_add(sub_ac, strdup("allow")); - p_autocomplete_add(sub_ac, strdup("deny")); - p_autocomplete_add(sub_ac, strdup("show")); - p_autocomplete_add(sub_ac, strdup("sent")); - p_autocomplete_add(sub_ac, strdup("received")); - - titlebar_ac = p_autocomplete_new(); - p_autocomplete_add(titlebar_ac, strdup("version")); - - log_ac = p_autocomplete_new(); - p_autocomplete_add(log_ac, strdup("maxsize")); - - autoaway_ac = p_autocomplete_new(); - p_autocomplete_add(autoaway_ac, strdup("mode")); - p_autocomplete_add(autoaway_ac, strdup("time")); - p_autocomplete_add(autoaway_ac, strdup("message")); - p_autocomplete_add(autoaway_ac, strdup("check")); - - autoaway_mode_ac = p_autocomplete_new(); - p_autocomplete_add(autoaway_mode_ac, strdup("away")); - p_autocomplete_add(autoaway_mode_ac, strdup("idle")); - p_autocomplete_add(autoaway_mode_ac, strdup("off")); - - theme_ac = p_autocomplete_new(); - p_autocomplete_add(theme_ac, strdup("list")); - p_autocomplete_add(theme_ac, strdup("set")); - - account_ac = p_autocomplete_new(); - p_autocomplete_add(account_ac, strdup("list")); - p_autocomplete_add(account_ac, strdup("show")); - p_autocomplete_add(account_ac, strdup("add")); - p_autocomplete_add(account_ac, strdup("enable")); - p_autocomplete_add(account_ac, strdup("disable")); - p_autocomplete_add(account_ac, strdup("rename")); - p_autocomplete_add(account_ac, strdup("set")); + commands_ac = autocomplete_new(); + who_ac = autocomplete_new(); + + prefs_ac = autocomplete_new(); + autocomplete_add(prefs_ac, strdup("ui")); + autocomplete_add(prefs_ac, strdup("desktop")); + autocomplete_add(prefs_ac, strdup("chat")); + autocomplete_add(prefs_ac, strdup("log")); + autocomplete_add(prefs_ac, strdup("conn")); + autocomplete_add(prefs_ac, strdup("presence")); + + help_ac = autocomplete_new(); + autocomplete_add(help_ac, strdup("list")); + autocomplete_add(help_ac, strdup("basic")); + autocomplete_add(help_ac, strdup("presence")); + autocomplete_add(help_ac, strdup("settings")); + autocomplete_add(help_ac, strdup("navigation")); + + notify_ac = autocomplete_new(); + autocomplete_add(notify_ac, strdup("message")); + autocomplete_add(notify_ac, strdup("typing")); + autocomplete_add(notify_ac, strdup("remind")); + autocomplete_add(notify_ac, strdup("status")); + + sub_ac = autocomplete_new(); + autocomplete_add(sub_ac, strdup("request")); + autocomplete_add(sub_ac, strdup("allow")); + autocomplete_add(sub_ac, strdup("deny")); + autocomplete_add(sub_ac, strdup("show")); + autocomplete_add(sub_ac, strdup("sent")); + autocomplete_add(sub_ac, strdup("received")); + + titlebar_ac = autocomplete_new(); + autocomplete_add(titlebar_ac, strdup("version")); + + log_ac = autocomplete_new(); + autocomplete_add(log_ac, strdup("maxsize")); + + autoaway_ac = autocomplete_new(); + autocomplete_add(autoaway_ac, strdup("mode")); + autocomplete_add(autoaway_ac, strdup("time")); + autocomplete_add(autoaway_ac, strdup("message")); + autocomplete_add(autoaway_ac, strdup("check")); + + autoaway_mode_ac = autocomplete_new(); + autocomplete_add(autoaway_mode_ac, strdup("away")); + autocomplete_add(autoaway_mode_ac, strdup("idle")); + autocomplete_add(autoaway_mode_ac, strdup("off")); + + theme_ac = autocomplete_new(); + autocomplete_add(theme_ac, strdup("list")); + autocomplete_add(theme_ac, strdup("set")); + + account_ac = autocomplete_new(); + autocomplete_add(account_ac, strdup("list")); + autocomplete_add(account_ac, strdup("show")); + autocomplete_add(account_ac, strdup("add")); + autocomplete_add(account_ac, strdup("enable")); + autocomplete_add(account_ac, strdup("disable")); + autocomplete_add(account_ac, strdup("rename")); + autocomplete_add(account_ac, strdup("set")); theme_load_ac = NULL; unsigned int i; for (i = 0; i < ARRAY_SIZE(main_commands); i++) { struct cmd_t *pcmd = main_commands+i; - p_autocomplete_add(commands_ac, (gchar *)strdup(pcmd->cmd)); - p_autocomplete_add(help_ac, (gchar *)strdup(pcmd->cmd+1)); + autocomplete_add(commands_ac, (gchar *)strdup(pcmd->cmd)); + autocomplete_add(help_ac, (gchar *)strdup(pcmd->cmd+1)); } for (i = 0; i < ARRAY_SIZE(setting_commands); i++) { struct cmd_t *pcmd = setting_commands+i; - p_autocomplete_add(commands_ac, (gchar *)strdup(pcmd->cmd)); - p_autocomplete_add(help_ac, (gchar *)strdup(pcmd->cmd+1)); + autocomplete_add(commands_ac, (gchar *)strdup(pcmd->cmd)); + autocomplete_add(help_ac, (gchar *)strdup(pcmd->cmd+1)); } for (i = 0; i < ARRAY_SIZE(presence_commands); i++) { struct cmd_t *pcmd = presence_commands+i; - p_autocomplete_add(commands_ac, (gchar *)strdup(pcmd->cmd)); - p_autocomplete_add(help_ac, (gchar *)strdup(pcmd->cmd+1)); - p_autocomplete_add(who_ac, (gchar *)strdup(pcmd->cmd+1)); + autocomplete_add(commands_ac, (gchar *)strdup(pcmd->cmd)); + autocomplete_add(help_ac, (gchar *)strdup(pcmd->cmd+1)); + autocomplete_add(who_ac, (gchar *)strdup(pcmd->cmd+1)); } - p_autocomplete_add(who_ac, strdup("offline")); - p_autocomplete_add(who_ac, strdup("available")); - p_autocomplete_add(who_ac, strdup("unavailable")); + autocomplete_add(who_ac, strdup("offline")); + autocomplete_add(who_ac, strdup("available")); + autocomplete_add(who_ac, strdup("unavailable")); history_init(); } @@ -748,20 +748,20 @@ cmd_init(void) void cmd_close(void) { - p_autocomplete_free(commands_ac); - p_autocomplete_free(who_ac); - p_autocomplete_free(help_ac); - p_autocomplete_free(notify_ac); - p_autocomplete_free(sub_ac); - p_autocomplete_free(log_ac); - p_autocomplete_free(prefs_ac); - p_autocomplete_free(autoaway_ac); - p_autocomplete_free(autoaway_mode_ac); - p_autocomplete_free(theme_ac); + autocomplete_free(commands_ac); + autocomplete_free(who_ac); + autocomplete_free(help_ac); + autocomplete_free(notify_ac); + autocomplete_free(sub_ac); + autocomplete_free(log_ac); + autocomplete_free(prefs_ac); + autocomplete_free(autoaway_ac); + autocomplete_free(autoaway_mode_ac); + autocomplete_free(theme_ac); if (theme_load_ac != NULL) { - p_autocomplete_free(theme_load_ac); + autocomplete_free(theme_load_ac); } - p_autocomplete_free(account_ac); + autocomplete_free(account_ac); } // Command autocompletion functions @@ -779,7 +779,7 @@ cmd_autocomplete(char *input, int *size) inp_cpy[i] = input[i]; } inp_cpy[i] = '\0'; - found = p_autocomplete_complete(commands_ac, inp_cpy); + found = autocomplete_complete(commands_ac, inp_cpy); if (found != NULL) { auto_msg = (char *) malloc((strlen(found) + 1) * sizeof(char)); strcpy(auto_msg, found); @@ -801,29 +801,29 @@ cmd_reset_autocomplete() accounts_reset_all_search(); accounts_reset_enabled_search(); prefs_reset_boolean_choice(); - p_autocomplete_reset(help_ac); - p_autocomplete_reset(notify_ac); - p_autocomplete_reset(sub_ac); + autocomplete_reset(help_ac); + autocomplete_reset(notify_ac); + autocomplete_reset(sub_ac); if (win_current_is_groupchat()) { - PAutocomplete nick_ac = muc_get_roster_ac(win_current_get_recipient()); + Autocomplete nick_ac = muc_get_roster_ac(win_current_get_recipient()); if (nick_ac != NULL) { - p_autocomplete_reset(nick_ac); + autocomplete_reset(nick_ac); } } - p_autocomplete_reset(who_ac); - p_autocomplete_reset(prefs_ac); - p_autocomplete_reset(log_ac); - p_autocomplete_reset(commands_ac); - p_autocomplete_reset(autoaway_ac); - p_autocomplete_reset(autoaway_mode_ac); - p_autocomplete_reset(theme_ac); + autocomplete_reset(who_ac); + autocomplete_reset(prefs_ac); + autocomplete_reset(log_ac); + autocomplete_reset(commands_ac); + autocomplete_reset(autoaway_ac); + autocomplete_reset(autoaway_mode_ac); + autocomplete_reset(theme_ac); if (theme_load_ac != NULL) { - p_autocomplete_reset(theme_load_ac); + autocomplete_reset(theme_load_ac); theme_load_ac = NULL; } - p_autocomplete_reset(account_ac); + autocomplete_reset(account_ac); } GSList * @@ -954,7 +954,7 @@ _cmd_complete_parameters(char *input, int *size) prefs_autocomplete_boolean_choice); if (win_current_is_groupchat()) { - PAutocomplete nick_ac = muc_get_roster_ac(win_current_get_recipient()); + Autocomplete nick_ac = muc_get_roster_ac(win_current_get_recipient()); if (nick_ac != NULL) { _parameter_autocomplete_with_ac(input, size, "/msg", nick_ac); _parameter_autocomplete_with_ac(input, size, "/info", nick_ac); @@ -2394,7 +2394,7 @@ _parameter_autocomplete(char *input, int *size, char *command, static void _parameter_autocomplete_with_ac(char *input, int *size, char *command, - PAutocomplete ac) + Autocomplete ac) { char *found = NULL; char *auto_msg = NULL; @@ -2408,7 +2408,7 @@ _parameter_autocomplete_with_ac(char *input, int *size, char *command, inp_cpy[i-len] = input[i]; } inp_cpy[(*size) - len] = '\0'; - found = p_autocomplete_complete(ac, inp_cpy); + found = autocomplete_complete(ac, inp_cpy); if (found != NULL) { auto_msg = (char *) malloc((len + (strlen(found) + 1)) * sizeof(char)); strcpy(auto_msg, command_cpy); @@ -2523,14 +2523,14 @@ _theme_autocomplete(char *input, int *size) { if ((strncmp(input, "/theme set ", 11) == 0) && (*size > 11)) { if (theme_load_ac == NULL) { - theme_load_ac = p_autocomplete_new(); + theme_load_ac = autocomplete_new(); GSList *themes = theme_list(); while (themes != NULL) { - p_autocomplete_add(theme_load_ac, strdup(themes->data)); + autocomplete_add(theme_load_ac, strdup(themes->data)); themes = g_slist_next(themes); } g_slist_free(themes); - p_autocomplete_add(theme_load_ac, "default"); + autocomplete_add(theme_load_ac, "default"); } _parameter_autocomplete_with_ac(input, size, "/theme set", theme_load_ac); } else if ((strncmp(input, "/theme ", 7) == 0) && (*size > 7)) { diff --git a/src/contact_list.c b/src/contact_list.c index 50a63475..75f0eed7 100644 --- a/src/contact_list.c +++ b/src/contact_list.c @@ -25,9 +25,9 @@ #include <glib.h> #include "contact.h" -#include "prof_autocomplete.h" +#include "autocomplete.h" -static PAutocomplete ac; +static Autocomplete ac; static GHashTable *contacts; static gboolean _key_equals(void *key1, void *key2); @@ -36,7 +36,7 @@ static gboolean _datetimes_equal(GDateTime *dt1, GDateTime *dt2); void contact_list_init(void) { - ac = p_autocomplete_new(); + ac = autocomplete_new(); contacts = g_hash_table_new_full(g_str_hash, (GEqualFunc)_key_equals, g_free, (GDestroyNotify)p_contact_free); } @@ -44,20 +44,20 @@ contact_list_init(void) void contact_list_clear(void) { - p_autocomplete_clear(ac); + autocomplete_clear(ac); g_hash_table_remove_all(contacts); } void contact_list_free() { - p_autocomplete_free(ac); + autocomplete_free(ac); } void contact_list_reset_search_attempts(void) { - p_autocomplete_reset(ac); + autocomplete_reset(ac); } gboolean @@ -72,7 +72,7 @@ contact_list_add(const char * const jid, const char * const name, contact = p_contact_new(jid, name, presence, status, subscription, pending_out, NULL); g_hash_table_insert(contacts, strdup(jid), contact); - p_autocomplete_add(ac, strdup(jid)); + autocomplete_add(ac, strdup(jid)); added = TRUE; } @@ -172,7 +172,7 @@ get_contact_list(void) char * contact_list_find_contact(char *search_str) { - return p_autocomplete_complete(ac, search_str); + return autocomplete_complete(ac, search_str); } PContact diff --git a/src/muc.c b/src/muc.c index efe22abd..a599aea9 100644 --- a/src/muc.c +++ b/src/muc.c @@ -27,7 +27,7 @@ #include "contact.h" #include "jid.h" -#include "prof_autocomplete.h" +#include "autocomplete.h" typedef struct _muc_room_t { char *room; // e.g. test@conference.server @@ -35,7 +35,7 @@ typedef struct _muc_room_t { char *subject; gboolean pending_nick_change; GHashTable *roster; - PAutocomplete nick_ac; + Autocomplete nick_ac; GHashTable *nick_changes; gboolean roster_received; } ChatRoom; @@ -61,7 +61,7 @@ muc_join_room(const char * const room, const char * const nick) new_room->subject = NULL; new_room->roster = g_hash_table_new_full(g_str_hash, g_str_equal, g_free, (GDestroyNotify)p_contact_free); - new_room->nick_ac = p_autocomplete_new(); + new_room->nick_ac = autocomplete_new(); new_room->nick_changes = g_hash_table_new_full(g_str_hash, g_str_equal, g_free, g_free); new_room->roster_received = FALSE; @@ -215,7 +215,7 @@ muc_add_to_roster(const char * const room, const char * const nick, if (old == NULL) { updated = TRUE; - p_autocomplete_add(chat_room->nick_ac, strdup(nick)); + autocomplete_add(chat_room->nick_ac, strdup(nick)); } else if ((g_strcmp0(p_contact_presence(old), show) != 0) || (g_strcmp0(p_contact_status(old), status) != 0)) { updated = TRUE; @@ -237,7 +237,7 @@ muc_remove_from_roster(const char * const room, const char * const nick) if (chat_room != NULL) { g_hash_table_remove(chat_room->roster, nick); - p_autocomplete_remove(chat_room->nick_ac, nick); + autocomplete_remove(chat_room->nick_ac, nick); } } @@ -271,9 +271,9 @@ muc_get_roster(const char * const room) } /* - * Return a PAutocomplete representing the room member's in the roster + * Return a Autocomplete representing the room member's in the roster */ -PAutocomplete +Autocomplete muc_get_roster_ac(const char * const room) { ChatRoom *chat_room = g_hash_table_lookup(rooms, room); @@ -377,7 +377,7 @@ _free_room(ChatRoom *room) room->roster = NULL; } if (room->nick_ac != NULL) { - p_autocomplete_free(room->nick_ac); + autocomplete_free(room->nick_ac); } if (room->nick_changes != NULL) { g_hash_table_remove_all(room->nick_changes); diff --git a/src/muc.h b/src/muc.h index 8b8ed018..efd637fd 100644 --- a/src/muc.h +++ b/src/muc.h @@ -25,7 +25,7 @@ #include <glib.h> -#include "prof_autocomplete.h" +#include "autocomplete.h" void muc_join_room(const char * const room, const char * const nick); void muc_leave_room(const char * const room); @@ -43,7 +43,7 @@ gboolean muc_add_to_roster(const char * const room, const char * const nick, const char * const caps_str); void muc_remove_from_roster(const char * const room, const char * const nick); GList * muc_get_roster(const char * const room); -PAutocomplete muc_get_roster_ac(const char * const room); +Autocomplete muc_get_roster_ac(const char * const room); gboolean muc_nick_in_roster(const char * const room, const char * const nick); PContact muc_get_participant(const char * const room, const char * const nick); void muc_set_roster_received(const char * const room); diff --git a/src/preferences.c b/src/preferences.c index 574ae223..d12470f6 100644 --- a/src/preferences.c +++ b/src/preferences.c @@ -35,13 +35,13 @@ #include "files.h" #include "log.h" #include "preferences.h" -#include "prof_autocomplete.h" +#include "autocomplete.h" static gchar *prefs_loc; static GKeyFile *prefs; gint log_maxsize = 0; -static PAutocomplete boolean_choice_ac; +static Autocomplete boolean_choice_ac; static void _save_prefs(void); @@ -64,28 +64,28 @@ prefs_load(void) g_error_free(err); } - boolean_choice_ac = p_autocomplete_new(); - p_autocomplete_add(boolean_choice_ac, strdup("on")); - p_autocomplete_add(boolean_choice_ac, strdup("off")); + boolean_choice_ac = autocomplete_new(); + autocomplete_add(boolean_choice_ac, strdup("on")); + autocomplete_add(boolean_choice_ac, strdup("off")); } void prefs_close(void) { - p_autocomplete_free(boolean_choice_ac); + autocomplete_free(boolean_choice_ac); g_key_file_free(prefs); } char * prefs_autocomplete_boolean_choice(char *prefix) { - return p_autocomplete_complete(boolean_choice_ac, prefix); + return autocomplete_complete(boolean_choice_ac, prefix); } void prefs_reset_boolean_choice(void) { - p_autocomplete_reset(boolean_choice_ac); + autocomplete_reset(boolean_choice_ac); } gboolean diff --git a/tests/test_prof_autocomplete.c b/tests/test_autocomplete.c index b61c9cf6..ee90e0cb 100644 --- a/tests/test_prof_autocomplete.c +++ b/tests/test_autocomplete.c @@ -5,115 +5,115 @@ #include <glib.h> #include "contact.h" -#include "prof_autocomplete.h" +#include "autocomplete.h" static void clear_empty(void) { - PAutocomplete ac = p_autocomplete_new(); - p_autocomplete_clear(ac); + Autocomplete ac = autocomplete_new(); + autocomplete_clear(ac); } static void reset_after_create(void) { - PAutocomplete ac = p_autocomplete_new(); - p_autocomplete_reset(ac); - p_autocomplete_clear(ac); + Autocomplete ac = autocomplete_new(); + autocomplete_reset(ac); + autocomplete_clear(ac); } static void find_after_create(void) { - PAutocomplete ac = p_autocomplete_new(); - p_autocomplete_complete(ac, "hello"); - p_autocomplete_clear(ac); + Autocomplete ac = autocomplete_new(); + autocomplete_complete(ac, "hello"); + autocomplete_clear(ac); } static void get_after_create_returns_null(void) { - PAutocomplete ac = p_autocomplete_new(); - GSList *result = p_autocomplete_get_list(ac); + Autocomplete ac = autocomplete_new(); + GSList *result = autocomplete_get_list(ac); assert_is_null(result); - p_autocomplete_clear(ac); + autocomplete_clear(ac); } static void add_one_and_complete(void) { char *item = strdup("Hello"); - PAutocomplete ac = p_autocomplete_new(); - p_autocomplete_add(ac, item); - char *result = p_autocomplete_complete(ac, "Hel"); + Autocomplete ac = autocomplete_new(); + autocomplete_add(ac, item); + char *result = autocomplete_complete(ac, "Hel"); assert_string_equals("Hello", result); - p_autocomplete_clear(ac); + autocomplete_clear(ac); } static void add_two_and_complete_returns_first(void) { char *item1 = strdup("Hello"); char *item2 = strdup("Help"); - PAutocomplete ac = p_autocomplete_new(); - p_autocomplete_add(ac, item1); - p_autocomplete_add(ac, item2); - char *result = p_autocomplete_complete(ac, "Hel"); + Autocomplete ac = autocomplete_new(); + autocomplete_add(ac, item1); + autocomplete_add(ac, item2); + char *result = autocomplete_complete(ac, "Hel"); assert_string_equals("Hello", result); - p_autocomplete_clear(ac); + autocomplete_clear(ac); } static void add_two_and_complete_returns_second(void) { char *item1 = strdup("Hello"); char *item2 = strdup("Help"); - PAutocomplete ac = p_autocomplete_new(); - p_autocomplete_add(ac, item1); - p_autocomplete_add(ac, item2); - char *result1 = p_autocomplete_complete(ac, "Hel"); - char *result2 = p_autocomplete_complete(ac, result1); + Autocomplete ac = autocomplete_new(); + autocomplete_add(ac, item1); + autocomplete_add(ac, item2); + char *result1 = autocomplete_complete(ac, "Hel"); + char *result2 = autocomplete_complete(ac, result1); assert_string_equals("Help", result2); - p_autocomplete_clear(ac); + autocomplete_clear(ac); } static void add_two_adds_two(void) { char *item1 = strdup("Hello"); char *item2 = strdup("Help"); - PAutocomplete ac = p_autocomplete_new(); - p_autocomplete_add(ac, item1); - p_autocomplete_add(ac, item2); - GSList *result = p_autocomplete_get_list(ac); + Autocomplete ac = autocomplete_new(); + autocomplete_add(ac, item1); + autocomplete_add(ac, item2); + GSList *result = autocomplete_get_list(ac); assert_int_equals(2, g_slist_length(result)); - p_autocomplete_clear(ac); + autocomplete_clear(ac); } static void add_two_same_adds_one(void) { char *item1 = strdup("Hello"); char *item2 = strdup("Hello"); - PAutocomplete ac = p_autocomplete_new(); - p_autocomplete_add(ac, item1); - p_autocomplete_add(ac, item2); - GSList *result = p_autocomplete_get_list(ac); + Autocomplete ac = autocomplete_new(); + autocomplete_add(ac, item1); + autocomplete_add(ac, item2); + GSList *result = autocomplete_get_list(ac); assert_int_equals(1, g_slist_length(result)); - p_autocomplete_clear(ac); + autocomplete_clear(ac); } static void add_two_same_updates(void) { char *item1 = strdup("Hello"); char *item2 = strdup("Hello"); - PAutocomplete ac = p_autocomplete_new(); - p_autocomplete_add(ac, item1); - p_autocomplete_add(ac, item2); - GSList *result = p_autocomplete_get_list(ac); + Autocomplete ac = autocomplete_new(); + autocomplete_add(ac, item1); + autocomplete_add(ac, item2); + GSList *result = autocomplete_get_list(ac); GSList *first = g_slist_nth(result, 0); @@ -121,51 +121,51 @@ static void add_two_same_updates(void) assert_string_equals("Hello", str); - p_autocomplete_clear(ac); + autocomplete_clear(ac); } static void add_one_returns_true(void) { char *item = strdup("Hello"); - PAutocomplete ac = p_autocomplete_new(); - int result = p_autocomplete_add(ac, item); + Autocomplete ac = autocomplete_new(); + int result = autocomplete_add(ac, item); assert_true(result); - p_autocomplete_clear(ac); + autocomplete_clear(ac); } static void add_two_different_returns_true(void) { char *item1 = strdup("Hello"); char *item2 = strdup("Hello there"); - PAutocomplete ac = p_autocomplete_new(); - int result1 = p_autocomplete_add(ac, item1); - int result2 = p_autocomplete_add(ac, item2); + Autocomplete ac = autocomplete_new(); + int result1 = autocomplete_add(ac, item1); + int result2 = autocomplete_add(ac, item2); assert_true(result1); assert_true(result2); - p_autocomplete_clear(ac); + autocomplete_clear(ac); } static void add_two_same_returns_false(void) { char *item1 = strdup("Hello"); char *item2 = strdup("Hello"); - PAutocomplete ac = p_autocomplete_new(); - int result1 = p_autocomplete_add(ac, item1); - int result2 = p_autocomplete_add(ac, item2); + Autocomplete ac = autocomplete_new(); + int result1 = autocomplete_add(ac, item1); + int result2 = autocomplete_add(ac, item2); assert_true(result1); assert_false(result2); - p_autocomplete_clear(ac); + autocomplete_clear(ac); } -void register_prof_autocomplete_tests(void) +void register_autocomplete_tests(void) { - TEST_MODULE("prof_autocomplete tests"); + TEST_MODULE("autocomplete tests"); TEST(clear_empty); TEST(reset_after_create); TEST(find_after_create); diff --git a/tests/testsuite.c b/tests/testsuite.c index bbaa06d6..3720ca32 100644 --- a/tests/testsuite.c +++ b/tests/testsuite.c @@ -6,7 +6,7 @@ int main(void) register_prof_history_tests(); register_contact_list_tests(); register_common_tests(); - register_prof_autocomplete_tests(); + register_autocomplete_tests(); register_parser_tests(); register_jid_tests(); run_suite(); diff --git a/tests/testsuite.h b/tests/testsuite.h index 96d601dc..eecf1b00 100644 --- a/tests/testsuite.h +++ b/tests/testsuite.h @@ -4,7 +4,7 @@ void register_prof_history_tests(void); void register_contact_list_tests(void); void register_common_tests(void); -void register_prof_autocomplete_tests(void); +void register_autocomplete_tests(void); void register_parser_tests(void); void register_jid_tests(void); |