diff --git a/.travis.yml b/.travis.yml index 5c7435fb..3e1b576a 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,9 +1,11 @@ +dist: trusty +sudo: required language: c install: - lsb_release -a - uname -a - sudo apt-get update - - sudo apt-get -y install libssl-dev libexpat1-dev libncursesw5-dev libglib2.0-dev libnotify-dev libcurl3-dev libxss-dev libotr2-dev libgpgme11-dev autoconf-archive expect-dev tcl-dev libtool python-dev + - sudo apt-get -y install libssl-dev libexpat1-dev libncursesw5-dev libglib2.0-dev libnotify-dev libcurl3-dev libxss-dev libotr5-dev libgpgme11-dev autoconf-archive expect-dev tcl-dev libtool python-dev libgtk2.0-dev - git clone git://github.com/boothj5/libmesode.git - cd libmesode - mkdir m4 diff --git a/CHANGELOG b/CHANGELOG index 59f6798b..b9d3d284 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -9,8 +9,11 @@ - Add prof.get_room_nick plugins api function - Add main.help.header theme option - Look for system TLS certificate path by default (/tls certpath) +- Use service discovery to set account muc property +- Allow clearing account muc and resource properties - Allow plugins to complete file paths with prof.filepath_completer_add function - Add encryption settings functions to plugins api +- Allow plugins to block message sending on pre message send hooks - Bug fixes: https://github.com/boothj5/profanity/milestone/15?closed=1 0.5.0 diff --git a/LICENSE.txt b/LICENSE.txt index 4a6aef54..d634a15d 100644 --- a/LICENSE.txt +++ b/LICENSE.txt @@ -1,5 +1,5 @@ Profanity -Copyright (C) 2012 - 2016 James Booth +Copyright (C) 2012 - 2017 James Booth Profanity is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/Makefile.am b/Makefile.am index b8424856..e3b72b86 100644 --- a/Makefile.am +++ b/Makefile.am @@ -245,7 +245,7 @@ endif man_MANS = $(man_sources) -EXTRA_DIST = $(man_sources) $(icons_sources) $(themes_sources) $(script_sources) profrc.example LICENSE.txt +EXTRA_DIST = $(man_sources) $(icons_sources) $(themes_sources) $(script_sources) profrc.example LICENSE.txt README.md CHANGELOG if INCLUDE_GIT_VERSION EXTRA_DIST += .git/HEAD .git/index diff --git a/apidocs/python/conf.py b/apidocs/python/conf.py index bf28caa9..c4793a1e 100644 --- a/apidocs/python/conf.py +++ b/apidocs/python/conf.py @@ -48,7 +48,7 @@ master_doc = 'index' # General information about the project. project = u'Profanity Python Plugins API' -copyright = u'2016, boothj5' +copyright = u'2016 - 2017, boothj5' author = u'boothj5' # The version info for the project you're documenting, acts as replacement for diff --git a/configure.ac b/configure.ac index 211c1b45..45725950 100644 --- a/configure.ac +++ b/configure.ac @@ -151,8 +151,8 @@ AS_IF([test "x$ncurses_cv_wget_wch" != xyes], [AC_MSG_ERROR([ncurses does not support wide characters])]) ### Check for other profanity dependencies -PKG_CHECK_MODULES([glib], [glib-2.0 >= 2.26], [], - [AC_MSG_ERROR([glib 2.26 or higher is required for profanity])]) +PKG_CHECK_MODULES([glib], [glib-2.0 >= 2.40], [], + [AC_MSG_ERROR([glib 2.40 or higher is required for profanity])]) PKG_CHECK_MODULES([curl], [libcurl], [], [AC_CHECK_LIB([curl], [main], [], [AC_MSG_ERROR([libcurl is required for profanity])])]) diff --git a/docs/profanity.1 b/docs/profanity.1 index 433a1286..01b6c12e 100644 --- a/docs/profanity.1 +++ b/docs/profanity.1 @@ -1,4 +1,4 @@ -.TH Profanity 1 "August 2016" "Profanity XMPP client" +.TH Profanity 1 "January 2017" "Profanity XMPP client" .SH NAME Profanity \- a simple console based XMPP chat client. .SH SYNOPSIS @@ -62,7 +62,7 @@ or by sending a mail directly to: .br .PP .SH LICENSE -Copyright (C) 2012 \- 2016 James Booth . +Copyright (C) 2012 \- 2017 James Booth . License GPLv3+: GNU GPL version 3 or later This is free software; you are free to change and redistribute it. There is NO WARRANTY, to the extent permitted by law. diff --git a/src/command/cmd_ac.c b/src/command/cmd_ac.c index 628fb6b8..544719d4 100644 --- a/src/command/cmd_ac.c +++ b/src/command/cmd_ac.c @@ -1,7 +1,7 @@ /* * cmd_ac.c * - * Copyright (C) 2012 - 2016 James Booth + * Copyright (C) 2012 - 2017 James Booth * * This file is part of Profanity. * @@ -184,6 +184,7 @@ static Autocomplete console_ac; static Autocomplete console_msg_ac; static Autocomplete autoping_ac; static Autocomplete plugins_ac; +static Autocomplete plugins_sourcepath_ac; static Autocomplete plugins_load_ac; static Autocomplete plugins_unload_ac; static Autocomplete plugins_reload_ac; @@ -714,6 +715,11 @@ cmd_ac_init(void) autocomplete_add(plugins_ac, "unload"); autocomplete_add(plugins_ac, "reload"); autocomplete_add(plugins_ac, "python_version"); + autocomplete_add(plugins_ac, "sourcepath"); + + plugins_sourcepath_ac = autocomplete_new(); + autocomplete_add(plugins_sourcepath_ac, "set"); + autocomplete_add(plugins_sourcepath_ac, "clear"); filepath_ac = autocomplete_new(); @@ -1011,6 +1017,7 @@ cmd_ac_reset(ProfWin *window) autocomplete_reset(console_msg_ac); autocomplete_reset(autoping_ac); autocomplete_reset(plugins_ac); + autocomplete_reset(plugins_sourcepath_ac); autocomplete_reset(blocked_ac); autocomplete_reset(tray_ac); autocomplete_reset(presence_ac); @@ -2025,10 +2032,21 @@ _plugins_autocomplete(ProfWin *window, const char *const input) { char *result = NULL; + if (strncmp(input, "/plugins sourcepath set ", 24) == 0) { + return cmd_ac_complete_filepath(input, "/plugins sourcepath set"); + } + if (strncmp(input, "/plugins install ", 17) == 0) { return cmd_ac_complete_filepath(input, "/plugins install"); } + if (strncmp(input, "/plugins sourcepath ", 20) == 0) { + result = autocomplete_param_with_ac(input, "/plugins sourcepath", plugins_sourcepath_ac, TRUE); + if (result) { + return result; + } + } + if (strncmp(input, "/plugins load ", 14) == 0) { if (plugins_load_ac == NULL) { plugins_load_ac = autocomplete_new(); diff --git a/src/command/cmd_ac.h b/src/command/cmd_ac.h index 78aec927..b5e2f7d6 100644 --- a/src/command/cmd_ac.h +++ b/src/command/cmd_ac.h @@ -1,7 +1,7 @@ /* * cmd_ac.h * - * Copyright (C) 2012 - 2016 James Booth + * Copyright (C) 2012 - 2017 James Booth * * This file is part of Profanity. * diff --git a/src/command/cmd_defs.c b/src/command/cmd_defs.c index 33ae1a76..d5eba7c8 100644 --- a/src/command/cmd_defs.c +++ b/src/command/cmd_defs.c @@ -1,7 +1,7 @@ /* * cmd_defs.c * - * Copyright (C) 2012 - 2016 James Booth + * Copyright (C) 2012 - 2017 James Booth * * This file is part of Profanity. * @@ -576,7 +576,7 @@ static struct cmd_t command_defs[] = CMD_SYN( "/leave") CMD_DESC( - "Leave the current chat room.") + "Leave the current chat or room.") CMD_NOARGS CMD_NOEXAMPLES }, @@ -1580,7 +1580,7 @@ static struct cmd_t command_defs[] = CMD_EXAMPLES( "/alias add friends /who online friends", "/alias add /q /quit", - "/alias a /away \"I'm in a meeting.\"", + "/alias add a /away \"I'm in a meeting.\"", "/alias remove q", "/alias list") }, @@ -2046,26 +2046,38 @@ static struct cmd_t command_defs[] = }, { "/plugins", - parse_args, 0, 2, NULL, - CMD_NOSUBFUNCS + parse_args, 0, 3, NULL, + CMD_SUBFUNCS( + { "sourcepath", cmd_plugins_sourcepath }, + { "install", cmd_plugins_install }, + { "load", cmd_plugins_load }, + { "unload", cmd_plugins_unload }, + { "reload", cmd_plugins_reload }, + { "python_version", cmd_plugins_python_version }) CMD_MAINFUNC(cmd_plugins) CMD_NOTAGS CMD_SYN( "/plugins", - "/plugins install ", - "/plugins unload ", - "/plugins load ", + "/plugins sourcepath set ", + "/plugins sourcepath clear", + "/plugins install []", + "/plugins unload []", + "/plugins load []", "/plugins reload []", "/plugins python_version") CMD_DESC( "Manage plugins. Passing no arguments lists currently loaded plugins.") CMD_ARGS( - { "install ", "Install file to plugins directory, and load or reload the plugin." }, - { "load ", "Load a plugin that already exists in the plugin directory." }, - { "unload ", "Unload a loaded plugin." }, - { "reload []", "Reload a plugin, passing no argument will reload all plugins." }, - { "python_version", "Show the Python interpreter version." }) + { "sourcepath set ", "Set the default path to install plugins from, will be used if no arg is passed to /plugins install." }, + { "sourcepath clear", "Clear the default plugins source path." }, + { "install []", "Install a plugin, or all plugins found in a directory (recursive). Passing no argument will use the sourcepath if one is set." }, + { "load []", "Load a plugin that already exists in the plugin directory, passing no argument loads all found plugins." }, + { "unload []", "Unload a loaded plugin, passing no argument will unload all plugins." }, + { "reload []", "Reload a plugin, passing no argument will reload all plugins." }, + { "python_version", "Show the Python interpreter version." }) CMD_EXAMPLES( + "/plugins sourcepath set /home/meee/projects/profanity-plugins", + "/plugins install", "/plugins install /home/steveharris/Downloads/metal.py", "/plugins load browser.py", "/plugins unload say.py", diff --git a/src/command/cmd_defs.h b/src/command/cmd_defs.h index 3f07693b..074970c9 100644 --- a/src/command/cmd_defs.h +++ b/src/command/cmd_defs.h @@ -1,7 +1,7 @@ /* * cmd_defs.h * - * Copyright (C) 2012 - 2016 James Booth + * Copyright (C) 2012 - 2017 James Booth * * This file is part of Profanity. * diff --git a/src/command/cmd_funcs.c b/src/command/cmd_funcs.c index eab3c596..b1db10d6 100644 --- a/src/command/cmd_funcs.c +++ b/src/command/cmd_funcs.c @@ -1,7 +1,7 @@ /* * cmd_funcs.c * - * Copyright (C) 2012 - 2016 James Booth + * Copyright (C) 2012 - 2017 James Booth * * This file is part of Profanity. * @@ -4756,24 +4756,14 @@ cmd_clear(ProfWin *window, const char *const command, gchar **args) gboolean cmd_leave(ProfWin *window, const char *const command, gchar **args) { - jabber_conn_status_t conn_status = connection_get_status(); - int index = wins_get_current_num(); - - if (window->type != WIN_MUC) { - cons_show("You can only use the /leave command in a chat room."); + if (window->type != WIN_MUC && window->type != WIN_CHAT && window->type != WIN_PRIVATE) { + cons_show("The /leave command is only valid in chat, or chat room windows."); cons_alert(); return TRUE; } - // handle leaving rooms, or chat - if (conn_status == JABBER_CONNECTED) { - ui_close_connected_win(index); - } - - // close the window - ui_close_win(index); - - return TRUE; + // use /close behaviour + return cmd_close(window, "/leave", args); } gboolean @@ -6212,44 +6202,91 @@ cmd_xa(ProfWin *window, const char *const command, gchar **args) } gboolean -cmd_plugins(ProfWin *window, const char *const command, gchar **args) +cmd_plugins_sourcepath(ProfWin *window, const char *const command, gchar **args) { - if (g_strcmp0(args[0], "install") == 0) { - char *filename = args[1]; - if (filename == NULL) { + if (args[1] == NULL) { + char *sourcepath = prefs_get_string(PREF_PLUGINS_SOURCEPATH); + if (sourcepath) { + cons_show("Current plugins sourcepath: %s", sourcepath); + prefs_free_string(sourcepath); + } else { + cons_show("Plugins sourcepath not currently set."); + } + return TRUE; + } + + if (g_strcmp0(args[1], "clear") == 0) { + prefs_set_string(PREF_PLUGINS_SOURCEPATH, NULL); + cons_show("Plugins sourcepath cleared."); + return TRUE; + } + + if (g_strcmp0(args[1], "set") == 0) { + char *path = args[2]; + if (path == NULL) { cons_bad_cmd_usage(command); return TRUE; } // expand ~ to $HOME - if (filename[0] == '~' && filename[1] == '/') { - if (asprintf(&filename, "%s/%s", getenv("HOME"), filename+2) == -1) { + if (path[0] == '~' && path[1] == '/') { + if (asprintf(&path, "%s/%s", getenv("HOME"), path+2) == -1) { return TRUE; } } else { - filename = strdup(filename); + path = strdup(path); } - if (access(filename, R_OK) != 0) { - cons_show("File not found: %s", filename); - free(filename); + if (!is_dir(path)) { + cons_show("Plugins sourcepath must be a directory."); return TRUE; } - if (!is_regular_file(filename)) { - cons_show("Not a file: %s", filename); - free(filename); + cons_show("Setting plugins sourcepath: %s", path); + prefs_set_string(PREF_PLUGINS_SOURCEPATH, path); + return TRUE; + } + + cons_bad_cmd_usage(command); + return TRUE; +} + +gboolean +cmd_plugins_install(ProfWin *window, const char *const command, gchar **args) +{ + char *path = args[1]; + if (path == NULL) { + char* sourcepath = prefs_get_string(PREF_PLUGINS_SOURCEPATH); + if (sourcepath) { + path = strdup(sourcepath); + prefs_free_string(sourcepath); + } else { + cons_show("Either a path must be provided or the sourcepath property must be set, see /help plugins"); return TRUE; } + } else if (path[0] == '~' && path[1] == '/') { + if (asprintf(&path, "%s/%s", getenv("HOME"), path+2) == -1) { + return TRUE; + } + } else { + path = strdup(path); + } - if (!g_str_has_suffix(filename, ".py") && !g_str_has_suffix(filename, ".so")) { + if (access(path, R_OK) != 0) { + cons_show("File not found: %s", path); + free(path); + return TRUE; + } + + if (is_regular_file(path)) { + if (!g_str_has_suffix(path, ".py") && !g_str_has_suffix(path, ".so")) { cons_show("Plugins must have one of the following extensions: '.py' '.so'"); - free(filename); + free(path); return TRUE; } - gchar *plugin_name = g_path_get_basename(filename); - gboolean result = plugins_install(plugin_name, filename); + gchar *plugin_name = g_path_get_basename(path); + gboolean result = plugins_install(plugin_name, path); if (result) { cons_show("Plugin installed: %s", plugin_name); } else { @@ -6257,75 +6294,145 @@ cmd_plugins(ProfWin *window, const char *const command, gchar **args) } g_free(plugin_name); - free(filename); - return TRUE; - } else if (g_strcmp0(args[0], "load") == 0) { - if (args[1] == NULL) { - cons_bad_cmd_usage(command); - return TRUE; - } - gboolean res = plugins_load(args[1]); - if (res) { - cons_show("Loaded plugin: %s", args[1]); - } else { - cons_show("Failed to load plugin: %s", args[1]); - } - - return TRUE; - } else if (g_strcmp0(args[0], "unload") == 0) { - if (args[1] == NULL) { - cons_bad_cmd_usage(command); - return TRUE; - } - gboolean res = plugins_unload(args[1]); - if (res) { - cons_show("Unloaded plugin: %s", args[1]); - } else { - cons_show("Failed to unload plugin: %s", args[1]); - } - - return TRUE; - } else if (g_strcmp0(args[0], "reload") == 0) { - if (args[1] == NULL) { - plugins_reload_all(); - cons_show("Reloaded all plugins"); - } else { - gboolean res = plugins_reload(args[1]); - if (res) { - cons_show("Reloaded plugin: %s", args[1]); - } else { - cons_show("Failed to reload plugin: %s", args[1]); - } - } - - return TRUE; - } else if (g_strcmp0(args[0], "python_version") == 0) { -#ifdef HAVE_PYTHON - const char *version = python_get_version(); - cons_show("Python version:"); - cons_show("%s", version); -#else - cons_show("This build does not support pytyon plugins."); -#endif - return TRUE; - - } else { - GList *plugins = plugins_loaded_list(); - if (plugins == NULL) { - cons_show("No plugins installed."); - return TRUE; - } - - GList *curr = plugins; - cons_show("Installed plugins:"); - while (curr) { - cons_show(" %s", curr->data); - curr = g_list_next(curr); - } - g_list_free(plugins); - + free(path); return TRUE; } + + if (is_dir(path)) { + PluginsInstallResult* result = plugins_install_all(path); + if (result->installed || result->failed) { + if (result->installed) { + cons_show(""); + cons_show("Installed plugins:"); + GSList *curr = result->installed; + while (curr) { + cons_show(" %s", curr->data); + curr = g_slist_next(curr); + } + } + if (result->failed) { + cons_show(""); + cons_show("Failed installs:"); + GSList *curr = result->failed; + while (curr) { + cons_show(" %s", curr->data); + curr = g_slist_next(curr); + } + } + } else { + cons_show("No plugins found in: %s", path); + } + free(path); + plugins_free_install_result(result); + return TRUE; + } + + cons_show("Argument must be a file or directory."); + return TRUE; +} + +gboolean +cmd_plugins_load(ProfWin *window, const char *const command, gchar **args) +{ + if (args[1] == NULL) { + GSList *loaded = plugins_load_all(); + if (loaded) { + cons_show("Loaded plugins:"); + GSList *curr = loaded; + while (curr) { + cons_show(" %s", curr->data); + curr = g_slist_next(curr); + } + g_slist_free_full(loaded, g_free); + } else { + cons_show("No plugins loaded."); + } + return TRUE; + } + + gboolean res = plugins_load(args[1]); + if (res) { + cons_show("Loaded plugin: %s", args[1]); + } else { + cons_show("Failed to load plugin: %s", args[1]); + } + + return TRUE; +} + +gboolean +cmd_plugins_unload(ProfWin *window, const char *const command, gchar **args) +{ + if (args[1] == NULL) { + gboolean res = plugins_unload_all(); + if (res) { + cons_show("Unloaded all plugins."); + } else { + cons_show("No plugins unloaded."); + } + return TRUE; + } + + gboolean res = plugins_unload(args[1]); + if (res) { + cons_show("Unloaded plugin: %s", args[1]); + } else { + cons_show("Failed to unload plugin: %s", args[1]); + } + + return TRUE; +} + +gboolean +cmd_plugins_reload(ProfWin *window, const char *const command, gchar **args) +{ + if (args[1] == NULL) { + plugins_reload_all(); + cons_show("Reloaded all plugins"); + return TRUE; + } + + gboolean res = plugins_reload(args[1]); + if (res) { + cons_show("Reloaded plugin: %s", args[1]); + } else { + cons_show("Failed to reload plugin: %s", args[1]); + } + + return TRUE; +} + +gboolean +cmd_plugins_python_version(ProfWin *window, const char *const command, gchar **args) +{ +#ifdef HAVE_PYTHON + const char *version = python_get_version(); + cons_show("Python version:"); + cons_show("%s", version); +#else + cons_show("This build does not support pytyon plugins."); +#endif + return TRUE; +} + +gboolean +cmd_plugins(ProfWin *window, const char *const command, gchar **args) +{ + GList *plugins = plugins_loaded_list(); + if (plugins == NULL) { + cons_show("No plugins installed."); + return TRUE; + } + + GList *curr = plugins; + cons_show("Installed plugins:"); + while (curr) { + cons_show(" %s", curr->data); + curr = g_list_next(curr); + } + g_list_free(plugins); + + return TRUE; } gboolean diff --git a/src/command/cmd_funcs.h b/src/command/cmd_funcs.h index 69358277..2f0e0bac 100644 --- a/src/command/cmd_funcs.h +++ b/src/command/cmd_funcs.h @@ -1,7 +1,7 @@ /* * cmd_funcs.h * - * Copyright (C) 2012 - 2016 James Booth + * Copyright (C) 2012 - 2017 James Booth * * This file is part of Profanity. * @@ -158,7 +158,15 @@ gboolean cmd_script(ProfWin *window, const char *const command, gchar **args); gboolean cmd_export(ProfWin *window, const char *const command, gchar **args); gboolean cmd_charset(ProfWin *window, const char *const command, gchar **args); gboolean cmd_console(ProfWin *window, const char *const command, gchar **args); + gboolean cmd_plugins(ProfWin *window, const char *const command, gchar **args); +gboolean cmd_plugins_sourcepath(ProfWin *window, const char *const command, gchar **args); +gboolean cmd_plugins_install(ProfWin *window, const char *const command, gchar **args); +gboolean cmd_plugins_load(ProfWin *window, const char *const command, gchar **args); +gboolean cmd_plugins_unload(ProfWin *window, const char *const command, gchar **args); +gboolean cmd_plugins_reload(ProfWin *window, const char *const command, gchar **args); +gboolean cmd_plugins_python_version(ProfWin *window, const char *const command, gchar **args); + gboolean cmd_blocked(ProfWin *window, const char *const command, gchar **args); gboolean cmd_account(ProfWin *window, const char *const command, gchar **args); diff --git a/src/common.c b/src/common.c index d3f09a56..d9c7d73f 100644 --- a/src/common.c +++ b/src/common.c @@ -1,7 +1,7 @@ /* * common.c * - * Copyright (C) 2012 - 2016 James Booth + * Copyright (C) 2012 - 2017 James Booth * * This file is part of Profanity. * @@ -67,54 +67,6 @@ static unsigned long unique_id = 0; static size_t _data_callback(void *ptr, size_t size, size_t nmemb, void *data); -// taken from glib 2.30.3 -gchar* -p_utf8_substring(const gchar *str, glong start_pos, glong end_pos) -{ - gchar *start, *end, *out; - - start = g_utf8_offset_to_pointer (str, start_pos); - end = g_utf8_offset_to_pointer (start, end_pos - start_pos); - - out = g_malloc (end - start + 1); - memcpy (out, start, end - start); - out[end - start] = 0; - - return out; -} - -void -p_slist_free_full(GSList *items, GDestroyNotify free_func) -{ - g_slist_foreach (items, (GFunc) free_func, NULL); - g_slist_free (items); -} - -void -p_list_free_full(GList *items, GDestroyNotify free_func) -{ - g_list_foreach (items, (GFunc) free_func, NULL); - g_list_free (items); -} - -gboolean -p_hash_table_add(GHashTable *hash_table, gpointer key) -{ - // doesn't handle when key exists, but value == NULL - gpointer found = g_hash_table_lookup(hash_table, key); - g_hash_table_replace(hash_table, key, key); - - return (found == NULL); -} - -gboolean -p_hash_table_contains(GHashTable *hash_table, gconstpointer key) -{ - // doesn't handle when key exists, but value == NULL - gpointer found = g_hash_table_lookup(hash_table, key); - return (found != NULL); -} - gboolean create_dir(char *name) { @@ -509,13 +461,18 @@ prof_occurrences(const char *const needle, const char *const haystack, int offse return *result; } - if (g_str_has_prefix(&haystack[offset], needle)) { + gchar *haystack_curr = g_utf8_offset_to_pointer(haystack, offset); + if (g_str_has_prefix(haystack_curr, needle)) { if (whole_word) { - char *prev = g_utf8_prev_char(&haystack[offset]); - char *next = g_utf8_next_char(&haystack[offset] + strlen(needle) - 1); - gunichar prevu = g_utf8_get_char(prev); - gunichar nextu = g_utf8_get_char(next); - if (!g_unichar_isalnum(prevu) && !g_unichar_isalnum(nextu)) { + gchar *needle_last_ch = g_utf8_offset_to_pointer(needle, g_utf8_strlen(needle, -1)- 1); + int needle_last_ch_len = mblen(needle_last_ch, MB_CUR_MAX); + + gchar *haystack_before_ch = g_utf8_prev_char(haystack_curr); + gchar *haystack_after_ch = g_utf8_next_char(haystack_curr + strlen(needle) - needle_last_ch_len); + + gunichar before = g_utf8_get_char(haystack_before_ch); + gunichar after = g_utf8_get_char(haystack_after_ch); + if (!g_unichar_isalnum(before) && !g_unichar_isalnum(after)) { *result = g_slist_append(*result, GINT_TO_POINTER(offset)); } } else { @@ -523,10 +480,53 @@ prof_occurrences(const char *const needle, const char *const haystack, int offse } } - if (haystack[offset+1] != '\0') { - *result = prof_occurrences(needle, haystack, offset+1, whole_word, result); + offset++; + if (g_strcmp0(g_utf8_offset_to_pointer(haystack, offset), "\0") != 0) { + *result = prof_occurrences(needle, haystack, offset, whole_word, result); } return *result; } +int +is_regular_file(const char *path) +{ + struct stat st; + stat(path, &st); + return S_ISREG(st.st_mode); +} + +int +is_dir(const char *path) +{ + struct stat st; + stat(path, &st); + return S_ISDIR(st.st_mode); +} + +void +get_file_paths_recursive(const char *path, GSList **contents) +{ + if (!is_dir(path)) { + return; + } + + GDir* directory = g_dir_open(path, 0, NULL); + const gchar *entry = g_dir_read_name(directory); + while (entry) { + GString *full = g_string_new(path); + if (!g_str_has_suffix(full->str, "/")) { + g_string_append(full, "/"); + } + g_string_append(full, entry); + + if (is_dir(full->str)) { + get_file_paths_recursive(full->str, contents); + } else if (is_regular_file(full->str)) { + *contents = g_slist_append(*contents, full->str); + } + + g_string_free(full, FALSE); + entry = g_dir_read_name(directory); + } +} diff --git a/src/common.h b/src/common.h index c463d62c..421c56cd 100644 --- a/src/common.h +++ b/src/common.h @@ -1,7 +1,7 @@ /* * common.h * - * Copyright (C) 2012 - 2016 James Booth + * Copyright (C) 2012 - 2017 James Booth * * This file is part of Profanity. * @@ -40,20 +40,6 @@ #include -#if !GLIB_CHECK_VERSION(2,28,0) -#define g_slist_free_full(items, free_func) p_slist_free_full(items, free_func) -#define g_list_free_full(items, free_func) p_list_free_full(items, free_func) -#endif - -#if !GLIB_CHECK_VERSION(2,30,0) -#define g_utf8_substring(str, start_pos, end_pos) p_utf8_substring(str, start_pos, end_pos) -#endif - -#if !GLIB_CHECK_VERSION(2,32,0) -#define g_hash_table_add(hash_table, key) p_hash_table_add(hash_table, key) -#define g_hash_table_contains(hash_table, key) p_hash_table_contains(hash_table, key) -#endif - #ifndef NOTIFY_CHECK_VERSION #define notify_notification_new(summary, body, icon) notify_notification_new(summary, body, icon, NULL) #endif @@ -94,12 +80,6 @@ typedef enum { RESOURCE_XA } resource_presence_t; -gchar* p_utf8_substring(const gchar *str, glong start_pos, glong end_pos); -void p_slist_free_full(GSList *items, GDestroyNotify free_func); -void p_list_free_full(GList *items, GDestroyNotify free_func); -gboolean p_hash_table_add(GHashTable *hash_table, gpointer key); -gboolean p_hash_table_contains(GHashTable *hash_table, gconstpointer key); - gboolean create_dir(char *name); gboolean mkdir_recursive(const char *dir); gboolean copy_file(const char *const src, const char *const target); @@ -123,4 +103,8 @@ gboolean is_notify_enabled(void); GSList* prof_occurrences(const char *const needle, const char *const haystack, int offset, gboolean whole_word, GSList **result); +int is_regular_file(const char *path); +int is_dir(const char *path); +void get_file_paths_recursive(const char *directory, GSList **contents); + #endif diff --git a/src/config/account.c b/src/config/account.c index 8baa1dbb..8225b99d 100644 --- a/src/config/account.c +++ b/src/config/account.c @@ -1,7 +1,7 @@ /* * account.c * - * Copyright (C) 2012 - 2016 James Booth + * Copyright (C) 2012 - 2017 James Booth * * This file is part of Profanity. * diff --git a/src/config/account.h b/src/config/account.h index 32fee0f8..045732e0 100644 --- a/src/config/account.h +++ b/src/config/account.h @@ -1,7 +1,7 @@ /* * account.h * - * Copyright (C) 2012 - 2016 James Booth + * Copyright (C) 2012 - 2017 James Booth * * This file is part of Profanity. * diff --git a/src/config/accounts.c b/src/config/accounts.c index 7dc852ae..fd57a177 100644 --- a/src/config/accounts.c +++ b/src/config/accounts.c @@ -1,7 +1,7 @@ /* * accounts.c * - * Copyright (C) 2012 - 2016 James Booth + * Copyright (C) 2012 - 2017 James Booth * * This file is part of Profanity. * diff --git a/src/config/accounts.h b/src/config/accounts.h index 4d30cbd9..f5735f07 100644 --- a/src/config/accounts.h +++ b/src/config/accounts.h @@ -1,7 +1,7 @@ /* * accounts.h * - * Copyright (C) 2012 - 2016 James Booth + * Copyright (C) 2012 - 2017 James Booth * * This file is part of Profanity. * diff --git a/src/config/conflists.c b/src/config/conflists.c index d80ab254..36817005 100644 --- a/src/config/conflists.c +++ b/src/config/conflists.c @@ -1,7 +1,7 @@ /* * conflists.c * - * Copyright (C) 2012 - 2016 James Booth + * Copyright (C) 2012 - 2017 James Booth * * This file is part of Profanity. * diff --git a/src/config/conflists.h b/src/config/conflists.h index 5fb280e1..3a5506a2 100644 --- a/src/config/conflists.h +++ b/src/config/conflists.h @@ -1,7 +1,7 @@ /* * conflists.h * - * Copyright (C) 2012 - 2016 James Booth + * Copyright (C) 2012 - 2017 James Booth * * This file is part of Profanity. * diff --git a/src/config/files.c b/src/config/files.c index d60b4efa..5322c49f 100644 --- a/src/config/files.c +++ b/src/config/files.c @@ -1,7 +1,7 @@ /* * files.c * - * Copyright (C) 2012 - 2016 James Booth + * Copyright (C) 2012 - 2017 James Booth * * This file is part of Profanity. * diff --git a/src/config/files.h b/src/config/files.h index 47a73b43..2ffff016 100644 --- a/src/config/files.h +++ b/src/config/files.h @@ -1,7 +1,7 @@ /* * files.h * - * Copyright (C) 2012 - 2016 James Booth + * Copyright (C) 2012 - 2017 James Booth * * This file is part of Profanity. * diff --git a/src/config/preferences.c b/src/config/preferences.c index 4eed12ff..6dc8ef32 100644 --- a/src/config/preferences.c +++ b/src/config/preferences.c @@ -1,7 +1,7 @@ /* * preferences.c * - * Copyright (C) 2012 - 2016 James Booth + * Copyright (C) 2012 - 2017 James Booth * * This file is part of Profanity. * @@ -59,6 +59,7 @@ #define PREF_GROUP_OTR "otr" #define PREF_GROUP_PGP "pgp" #define PREF_GROUP_MUC "muc" +#define PREF_GROUP_PLUGINS "plugins" #define INPBLOCK_DEFAULT 1000 @@ -665,27 +666,27 @@ prefs_get_tray_timer(void) gchar** prefs_get_plugins(void) { - if (!g_key_file_has_group(prefs, "plugins")) { + if (!g_key_file_has_group(prefs, PREF_GROUP_PLUGINS)) { return NULL; } - if (!g_key_file_has_key(prefs, "plugins", "load", NULL)) { + if (!g_key_file_has_key(prefs, PREF_GROUP_PLUGINS, "load", NULL)) { return NULL; } - return g_key_file_get_string_list(prefs, "plugins", "load", NULL, NULL); + return g_key_file_get_string_list(prefs, PREF_GROUP_PLUGINS, "load", NULL, NULL); } void prefs_add_plugin(const char *const name) { - conf_string_list_add(prefs, "plugins", "load", name); + conf_string_list_add(prefs, PREF_GROUP_PLUGINS, "load", name); _save_prefs(); } void prefs_remove_plugin(const char *const name) { - conf_string_list_remove(prefs, "plugins", "load", name); + conf_string_list_remove(prefs, PREF_GROUP_PLUGINS, "load", name); _save_prefs(); } @@ -1614,6 +1615,8 @@ _get_group(preference_t pref) return PREF_GROUP_PGP; case PREF_BOOKMARK_INVITE: return PREF_GROUP_MUC; + case PREF_PLUGINS_SOURCEPATH: + return PREF_GROUP_PLUGINS; default: return NULL; } @@ -1814,6 +1817,8 @@ _get_key(preference_t pref) return "console.chat"; case PREF_BOOKMARK_INVITE: return "bookmark.invite"; + case PREF_PLUGINS_SOURCEPATH: + return "sourcepath"; default: return NULL; } diff --git a/src/config/preferences.h b/src/config/preferences.h index 72385de5..cc605c79 100644 --- a/src/config/preferences.h +++ b/src/config/preferences.h @@ -1,7 +1,7 @@ /* * preferences.h * - * Copyright (C) 2012 - 2016 James Booth + * Copyright (C) 2012 - 2017 James Booth * * This file is part of Profanity. * @@ -141,6 +141,7 @@ typedef enum { PREF_CONSOLE_PRIVATE, PREF_CONSOLE_CHAT, PREF_BOOKMARK_INVITE, + PREF_PLUGINS_SOURCEPATH, } preference_t; typedef struct prof_alias_t { diff --git a/src/config/scripts.c b/src/config/scripts.c index 41f93e3c..d093e8d9 100644 --- a/src/config/scripts.c +++ b/src/config/scripts.c @@ -1,7 +1,7 @@ /* * scripts.c * - * Copyright (C) 2012 - 2016 James Booth + * Copyright (C) 2012 - 2017 James Booth * * This file is part of Profanity. * diff --git a/src/config/scripts.h b/src/config/scripts.h index aa2ba3d7..d7652138 100644 --- a/src/config/scripts.h +++ b/src/config/scripts.h @@ -1,7 +1,7 @@ /* * scripts.h * - * Copyright (C) 2012 - 2016 James Booth + * Copyright (C) 2012 - 2017 James Booth * * This file is part of Profanity. * diff --git a/src/config/theme.c b/src/config/theme.c index 3cd50d6e..5a44e370 100644 --- a/src/config/theme.c +++ b/src/config/theme.c @@ -1,7 +1,7 @@ /* * theme.c * - * Copyright (C) 2012 - 2016 James Booth + * Copyright (C) 2012 - 2017 James Booth * * This file is part of Profanity. * @@ -104,6 +104,7 @@ theme_init(const char *const theme_name) g_hash_table_insert(defaults, strdup("statusbar.brackets"), strdup("cyan")); g_hash_table_insert(defaults, strdup("statusbar.active"), strdup("cyan")); g_hash_table_insert(defaults, strdup("statusbar.new"), strdup("white")); + g_hash_table_insert(defaults, strdup("statusbar.time"), strdup("white")); g_hash_table_insert(defaults, strdup("me"), strdup("yellow")); g_hash_table_insert(defaults, strdup("them"), strdup("green")); g_hash_table_insert(defaults, strdup("receipt.sent"), strdup("red")); @@ -755,6 +756,7 @@ theme_attrs(theme_item_t attrs) case THEME_STATUS_BRACKET: _theme_prep_fgnd("statusbar.brackets", lookup_str, &bold); break; case THEME_STATUS_ACTIVE: _theme_prep_fgnd("statusbar.active", lookup_str, &bold); break; case THEME_STATUS_NEW: _theme_prep_fgnd("statusbar.new", lookup_str, &bold); break; + case THEME_STATUS_TIME: _theme_prep_fgnd("statusbar.time", lookup_str, &bold); break; case THEME_ME: _theme_prep_fgnd("me", lookup_str, &bold); break; case THEME_THEM: _theme_prep_fgnd("them", lookup_str, &bold); break; case THEME_RECEIPT_SENT: _theme_prep_fgnd("receipt.sent", lookup_str, &bold); break; @@ -843,6 +845,7 @@ theme_attrs(theme_item_t attrs) case THEME_STATUS_BRACKET: case THEME_STATUS_ACTIVE: case THEME_STATUS_NEW: + case THEME_STATUS_TIME: _theme_prep_bgnd("statusbar", "blue", lookup_str); break; default: diff --git a/src/config/theme.h b/src/config/theme.h index 9896c1b9..747eace1 100644 --- a/src/config/theme.h +++ b/src/config/theme.h @@ -1,7 +1,7 @@ /* * theme.h * - * Copyright (C) 2012 - 2016 James Booth + * Copyright (C) 2012 - 2017 James Booth * * This file is part of Profanity. * @@ -69,6 +69,7 @@ typedef enum { THEME_STATUS_BRACKET, THEME_STATUS_ACTIVE, THEME_STATUS_NEW, + THEME_STATUS_TIME, THEME_ME, THEME_THEM, THEME_ROOMINFO, diff --git a/src/config/tlscerts.c b/src/config/tlscerts.c index edef2c8c..a664eabb 100644 --- a/src/config/tlscerts.c +++ b/src/config/tlscerts.c @@ -1,7 +1,7 @@ /* * tlscerts.c * - * Copyright (C) 2012 - 2016 James Booth + * Copyright (C) 2012 - 2017 James Booth * * This file is part of Profanity. * diff --git a/src/config/tlscerts.h b/src/config/tlscerts.h index 76b2a344..c32412de 100644 --- a/src/config/tlscerts.h +++ b/src/config/tlscerts.h @@ -1,7 +1,7 @@ /* * tlscerts.h * - * Copyright (C) 2012 - 2016 James Booth + * Copyright (C) 2012 - 2017 James Booth * * This file is part of Profanity. * diff --git a/src/event/client_events.c b/src/event/client_events.c index bdc25931..2ed4ca8e 100644 --- a/src/event/client_events.c +++ b/src/event/client_events.c @@ -1,7 +1,7 @@ /* * client_events.c * - * Copyright (C) 2012 - 2016 James Booth + * Copyright (C) 2012 - 2017 James Booth * * This file is part of Profanity. * diff --git a/src/event/client_events.h b/src/event/client_events.h index b46a0a13..1c9733d2 100644 --- a/src/event/client_events.h +++ b/src/event/client_events.h @@ -1,7 +1,7 @@ /* * client_events.h * - * Copyright (C) 2012 - 2016 James Booth + * Copyright (C) 2012 - 2017 James Booth * * This file is part of Profanity. * diff --git a/src/event/server_events.c b/src/event/server_events.c index 56971e6a..f0b2e176 100644 --- a/src/event/server_events.c +++ b/src/event/server_events.c @@ -1,7 +1,7 @@ /* * server_events.c * - * Copyright (C) 2012 - 2016 James Booth + * Copyright (C) 2012 - 2017 James Booth * * This file is part of Profanity. * diff --git a/src/event/server_events.h b/src/event/server_events.h index cc67952f..75bb4379 100644 --- a/src/event/server_events.h +++ b/src/event/server_events.h @@ -1,7 +1,7 @@ /* * server_events.h * - * Copyright (C) 2012 - 2016 James Booth + * Copyright (C) 2012 - 2017 James Booth * * This file is part of Profanity. * diff --git a/src/log.c b/src/log.c index 43a7be6e..572999d6 100644 --- a/src/log.c +++ b/src/log.c @@ -1,7 +1,7 @@ /* * log.c * - * Copyright (C) 2012 - 2016 James Booth + * Copyright (C) 2012 - 2017 James Booth * * This file is part of Profanity. * diff --git a/src/log.h b/src/log.h index b065a448..5b25d349 100644 --- a/src/log.h +++ b/src/log.h @@ -1,7 +1,7 @@ /* * log.h * - * Copyright (C) 2012 - 2016 James Booth + * Copyright (C) 2012 - 2017 James Booth * * This file is part of Profanity. * diff --git a/src/main.c b/src/main.c index 8032478c..a473ac42 100644 --- a/src/main.c +++ b/src/main.c @@ -1,7 +1,7 @@ /* * main.c * - * Copyright (C) 2012 - 2016 James Booth + * Copyright (C) 2012 - 2017 James Booth * * This file is part of Profanity. * @@ -90,7 +90,7 @@ main(int argc, char **argv) g_print("Profanity, version %s\n", PACKAGE_VERSION); } - g_print("Copyright (C) 2012 - 2016 James Booth <%s>.\n", PACKAGE_BUGREPORT); + g_print("Copyright (C) 2012 - 2017 James Booth <%s>.\n", PACKAGE_BUGREPORT); g_print("License GPLv3+: GNU GPL version 3 or later \n"); g_print("\n"); g_print("This is free software; you are free to change and redistribute it.\n"); diff --git a/src/otr/otr.c b/src/otr/otr.c index 0dc56a59..65948493 100644 --- a/src/otr/otr.c +++ b/src/otr/otr.c @@ -1,7 +1,7 @@ /* * otr.c * - * Copyright (C) 2012 - 2016 James Booth + * Copyright (C) 2012 - 2017 James Booth * * This file is part of Profanity. * diff --git a/src/otr/otr.h b/src/otr/otr.h index a50503af..067a6fdb 100644 --- a/src/otr/otr.h +++ b/src/otr/otr.h @@ -1,7 +1,7 @@ /* * otr.h * - * Copyright (C) 2012 - 2016 James Booth + * Copyright (C) 2012 - 2017 James Booth * * This file is part of Profanity. * diff --git a/src/otr/otrlib.h b/src/otr/otrlib.h index 1031f8c1..99c1d1e2 100644 --- a/src/otr/otrlib.h +++ b/src/otr/otrlib.h @@ -1,7 +1,7 @@ /* * otrlib.h * - * Copyright (C) 2012 - 2016 James Booth + * Copyright (C) 2012 - 2017 James Booth * * This file is part of Profanity. * diff --git a/src/otr/otrlibv3.c b/src/otr/otrlibv3.c index 4f7a6135..04fdfb19 100644 --- a/src/otr/otrlibv3.c +++ b/src/otr/otrlibv3.c @@ -1,7 +1,7 @@ /* * otrlibv3.c * - * Copyright (C) 2012 - 2016 James Booth + * Copyright (C) 2012 - 2017 James Booth * * This file is part of Profanity. * diff --git a/src/otr/otrlibv4.c b/src/otr/otrlibv4.c index af41baed..39c254dd 100644 --- a/src/otr/otrlibv4.c +++ b/src/otr/otrlibv4.c @@ -1,7 +1,7 @@ /* * otrlibv4.c * - * Copyright (C) 2012 - 2016 James Booth + * Copyright (C) 2012 - 2017 James Booth * * This file is part of Profanity. * diff --git a/src/pgp/gpg.c b/src/pgp/gpg.c index ef501844..2a875404 100644 --- a/src/pgp/gpg.c +++ b/src/pgp/gpg.c @@ -1,7 +1,7 @@ /* * gpg.c * - * Copyright (C) 2012 - 2016 James Booth + * Copyright (C) 2012 - 2017 James Booth * * This file is part of Profanity. * diff --git a/src/pgp/gpg.h b/src/pgp/gpg.h index 038578ef..81128df2 100644 --- a/src/pgp/gpg.h +++ b/src/pgp/gpg.h @@ -1,7 +1,7 @@ /* * gpg.h * - * Copyright (C) 2012 - 2016 James Booth + * Copyright (C) 2012 - 2017 James Booth * * This file is part of Profanity. * diff --git a/src/plugins/api.c b/src/plugins/api.c index 9aa41485..76751957 100644 --- a/src/plugins/api.c +++ b/src/plugins/api.c @@ -1,7 +1,7 @@ /* * api.c * - * Copyright (C) 2012 - 2016 James Booth + * Copyright (C) 2012 - 2017 James Booth * * This file is part of Profanity. * diff --git a/src/plugins/api.h b/src/plugins/api.h index 9e5c7c53..51a5ac0f 100644 --- a/src/plugins/api.h +++ b/src/plugins/api.h @@ -1,7 +1,7 @@ /* * api.h * - * Copyright (C) 2012 - 2016 James Booth + * Copyright (C) 2012 - 2017 James Booth * * This file is part of Profanity. * diff --git a/src/plugins/autocompleters.c b/src/plugins/autocompleters.c index 496913e6..1f0d3c4c 100644 --- a/src/plugins/autocompleters.c +++ b/src/plugins/autocompleters.c @@ -1,7 +1,7 @@ /* * autocompleters.c * - * Copyright (C) 2012 - 2016 James Booth + * Copyright (C) 2012 - 2017 James Booth * * This file is part of Profanity. * diff --git a/src/plugins/autocompleters.h b/src/plugins/autocompleters.h index 22ec2ca4..2d6b072d 100644 --- a/src/plugins/autocompleters.h +++ b/src/plugins/autocompleters.h @@ -1,7 +1,7 @@ /* * autocompleters.h * - * Copyright (C) 2012 - 2016 James Booth + * Copyright (C) 2012 - 2017 James Booth * * This file is part of Profanity. * diff --git a/src/plugins/c_api.c b/src/plugins/c_api.c index dd63d004..9d40b7c7 100644 --- a/src/plugins/c_api.c +++ b/src/plugins/c_api.c @@ -1,7 +1,7 @@ /* * c_api.c * - * Copyright (C) 2012 - 2016 James Booth + * Copyright (C) 2012 - 2017 James Booth * * This file is part of Profanity. * diff --git a/src/plugins/c_api.h b/src/plugins/c_api.h index 40281fcf..25a56555 100644 --- a/src/plugins/c_api.h +++ b/src/plugins/c_api.h @@ -1,7 +1,7 @@ /* * c_api.h * - * Copyright (C) 2012 - 2016 James Booth + * Copyright (C) 2012 - 2017 James Booth * * This file is part of Profanity. * diff --git a/src/plugins/c_plugins.c b/src/plugins/c_plugins.c index 675457e5..c97c4fee 100644 --- a/src/plugins/c_plugins.c +++ b/src/plugins/c_plugins.c @@ -1,7 +1,7 @@ /* * c_plugins.c * - * Copyright (C) 2012 - 2016 James Booth + * Copyright (C) 2012 - 2017 James Booth * * This file is part of Profanity. * diff --git a/src/plugins/c_plugins.h b/src/plugins/c_plugins.h index 42c65f38..a7d5f879 100644 --- a/src/plugins/c_plugins.h +++ b/src/plugins/c_plugins.h @@ -1,7 +1,7 @@ /* * c_plugins.h * - * Copyright (C) 2012 - 2016 James Booth + * Copyright (C) 2012 - 2017 James Booth * * This file is part of Profanity. * diff --git a/src/plugins/callbacks.c b/src/plugins/callbacks.c index 1240e2c8..102fd679 100644 --- a/src/plugins/callbacks.c +++ b/src/plugins/callbacks.c @@ -1,7 +1,7 @@ /* * callbacks.c * - * Copyright (C) 2012 - 2016 James Booth + * Copyright (C) 2012 - 2017 James Booth * * This file is part of Profanity. * diff --git a/src/plugins/callbacks.h b/src/plugins/callbacks.h index 4fea2151..40f0a064 100644 --- a/src/plugins/callbacks.h +++ b/src/plugins/callbacks.h @@ -1,7 +1,7 @@ /* * callbacks.h * - * Copyright (C) 2012 - 2016 James Booth + * Copyright (C) 2012 - 2017 James Booth * * This file is part of Profanity. * diff --git a/src/plugins/disco.c b/src/plugins/disco.c index 320b7fa7..a03d651f 100644 --- a/src/plugins/disco.c +++ b/src/plugins/disco.c @@ -1,7 +1,7 @@ /* * disco.c * - * Copyright (C) 2012 - 2016 James Booth + * Copyright (C) 2012 - 2017 James Booth * * This file is part of Profanity. * diff --git a/src/plugins/disco.h b/src/plugins/disco.h index d08b6537..71912253 100644 --- a/src/plugins/disco.h +++ b/src/plugins/disco.h @@ -1,7 +1,7 @@ /* * disco.h * - * Copyright (C) 2012 - 2016 James Booth + * Copyright (C) 2012 - 2017 James Booth * * This file is part of Profanity. * diff --git a/src/plugins/plugins.c b/src/plugins/plugins.c index f190a8d0..92d605e8 100644 --- a/src/plugins/plugins.c +++ b/src/plugins/plugins.c @@ -1,7 +1,7 @@ /* * plugins.c * - * Copyright (C) 2012 - 2016 James Booth + * Copyright (C) 2012 - 2017 James Booth * * This file is part of Profanity. * @@ -129,6 +129,43 @@ plugins_init(void) return; } +void +plugins_free_install_result(PluginsInstallResult *result) +{ + if (!result) { + return; + } + g_slist_free_full(result->installed, free); + g_slist_free_full(result->failed, free); +} + +PluginsInstallResult* +plugins_install_all(const char *const path) +{ + PluginsInstallResult *result = malloc(sizeof(PluginsInstallResult)); + result->installed = NULL; + result->failed = NULL; + GSList *contents = NULL; + get_file_paths_recursive(path, &contents); + + GSList *curr = contents; + while (curr) { + if (g_str_has_suffix(curr->data, ".py") || g_str_has_suffix(curr->data, ".so")) { + gchar *plugin_name = g_path_get_basename(curr->data); + if (plugins_install(plugin_name, curr->data)) { + result->installed = g_slist_append(result->installed, strdup(curr->data)); + } else { + result->failed = g_slist_append(result->failed, strdup(curr->data)); + } + } + curr = g_slist_next(curr); + } + + g_slist_free_full(contents, g_free); + + return result; +} + gboolean plugins_install(const char *const plugin_name, const char *const filename) { @@ -153,6 +190,23 @@ plugins_install(const char *const plugin_name, const char *const filename) return result; } +GSList* +plugins_load_all(void) +{ + GSList *plugins = plugins_unloaded_list(); + GSList *loaded = NULL; + GSList *curr = plugins; + while (curr) { + if (plugins_load(curr->data)) { + loaded = g_slist_append(loaded, strdup(curr->data)); + } + curr = g_slist_next(curr); + } + g_slist_free_full(plugins, g_free); + + return loaded; +} + gboolean plugins_load(const char *const name) { @@ -190,6 +244,32 @@ plugins_load(const char *const name) } } +gboolean +plugins_unload_all(void) +{ + gboolean result = FALSE; + GList *plugin_names = g_hash_table_get_keys(plugins); + GList *plugin_names_dup = NULL; + GList *curr = plugin_names; + while (curr) { + plugin_names_dup = g_list_append(plugin_names_dup, strdup(curr->data)); + curr = g_list_next(curr); + } + g_list_free(plugin_names); + + curr = plugin_names_dup; + while (curr) { + if (plugins_unload(curr->data)) { + result = TRUE; + } + curr = g_list_next(curr); + } + + g_list_free_full(plugin_names_dup, free); + + return result; +} + gboolean plugins_unload(const char *const name) { diff --git a/src/plugins/plugins.h b/src/plugins/plugins.h index ce97237d..af659757 100644 --- a/src/plugins/plugins.h +++ b/src/plugins/plugins.h @@ -1,7 +1,7 @@ /* * plugins.h * - * Copyright (C) 2012 - 2016 James Booth + * Copyright (C) 2012 - 2017 James Booth * * This file is part of Profanity. * @@ -42,6 +42,11 @@ typedef enum { LANG_C } lang_t; +typedef struct prof_plugins_install_t { + GSList *installed; + GSList *failed; +} PluginsInstallResult; + typedef struct prof_plugin_t { char *name; lang_t lang; @@ -107,9 +112,14 @@ char* plugins_autocomplete(const char *const input); void plugins_reset_autocomplete(void); void plugins_shutdown(void); +void plugins_free_install_result(PluginsInstallResult *result); + gboolean plugins_install(const char *const plugin_name, const char *const filename); +PluginsInstallResult* plugins_install_all(const char *const path); gboolean plugins_load(const char *const name); +GSList* plugins_load_all(void); gboolean plugins_unload(const char *const name); +gboolean plugins_unload_all(void); gboolean plugins_reload(const char *const name); void plugins_reload_all(void); diff --git a/src/plugins/profapi.c b/src/plugins/profapi.c index 6d580162..782487cd 100644 --- a/src/plugins/profapi.c +++ b/src/plugins/profapi.c @@ -1,7 +1,7 @@ /* * prof_api.c * - * Copyright (C) 2012 - 2016 James Booth + * Copyright (C) 2012 - 2017 James Booth * * This file is part of Profanity. * diff --git a/src/plugins/profapi.h b/src/plugins/profapi.h index a684821e..60f5f463 100644 --- a/src/plugins/profapi.h +++ b/src/plugins/profapi.h @@ -1,7 +1,7 @@ /* * prof_api.h * - * Copyright (C) 2012 - 2016 James Booth + * Copyright (C) 2012 - 2017 James Booth * * This file is part of Profanity. * diff --git a/src/plugins/python_api.c b/src/plugins/python_api.c index 4ee13039..aa707e06 100644 --- a/src/plugins/python_api.c +++ b/src/plugins/python_api.c @@ -1,7 +1,7 @@ /* * python_api.c * - * Copyright (C) 2012 - 2016 James Booth + * Copyright (C) 2012 - 2017 James Booth * * This file is part of Profanity. * diff --git a/src/plugins/python_api.h b/src/plugins/python_api.h index 335821d0..a5848997 100644 --- a/src/plugins/python_api.h +++ b/src/plugins/python_api.h @@ -1,7 +1,7 @@ /* * python_api.h * - * Copyright (C) 2012 - 2016 James Booth + * Copyright (C) 2012 - 2017 James Booth * * This file is part of Profanity. * diff --git a/src/plugins/python_plugins.c b/src/plugins/python_plugins.c index 897f7b54..f8f35628 100644 --- a/src/plugins/python_plugins.c +++ b/src/plugins/python_plugins.c @@ -1,7 +1,7 @@ /* * python_plugins.c * - * Copyright (C) 2012 - 2016 James Booth + * Copyright (C) 2012 - 2017 James Booth * * This file is part of Profanity. * diff --git a/src/plugins/python_plugins.h b/src/plugins/python_plugins.h index 24b04b8c..778846b2 100644 --- a/src/plugins/python_plugins.h +++ b/src/plugins/python_plugins.h @@ -1,7 +1,7 @@ /* * python_plugins.h * - * Copyright (C) 2012 - 2016 James Booth + * Copyright (C) 2012 - 2017 James Booth * * This file is part of Profanity. * diff --git a/src/plugins/settings.c b/src/plugins/settings.c index 0ca2283b..78d8cec0 100644 --- a/src/plugins/settings.c +++ b/src/plugins/settings.c @@ -1,7 +1,7 @@ /* * settings.c * - * Copyright (C) 2012 - 2016 James Booth + * Copyright (C) 2012 - 2017 James Booth * * This file is part of Profanity. * diff --git a/src/plugins/settings.h b/src/plugins/settings.h index e05ee7ac..d2601fe8 100644 --- a/src/plugins/settings.h +++ b/src/plugins/settings.h @@ -1,7 +1,7 @@ /* * settings.h * - * Copyright (C) 2012 - 2016 James Booth + * Copyright (C) 2012 - 2017 James Booth * * This file is part of Profanity. * diff --git a/src/plugins/themes.c b/src/plugins/themes.c index e2e62a51..0c5d33ee 100644 --- a/src/plugins/themes.c +++ b/src/plugins/themes.c @@ -1,7 +1,7 @@ /* * themes.c * - * Copyright (C) 2012 - 2016 James Booth + * Copyright (C) 2012 - 2017 James Booth * * This file is part of Profanity. * diff --git a/src/plugins/themes.h b/src/plugins/themes.h index 398eb9e3..9bd6ee4a 100644 --- a/src/plugins/themes.h +++ b/src/plugins/themes.h @@ -1,7 +1,7 @@ /* * themes.h * - * Copyright (C) 2012 - 2016 James Booth + * Copyright (C) 2012 - 2017 James Booth * * This file is part of Profanity. * diff --git a/src/profanity.c b/src/profanity.c index d76d03a3..ace3fb2b 100644 --- a/src/profanity.c +++ b/src/profanity.c @@ -1,7 +1,7 @@ /* * profanity.c * - * Copyright (C) 2012 - 2016 James Booth + * Copyright (C) 2012 - 2017 James Booth * * This file is part of Profanity. * diff --git a/src/profanity.h b/src/profanity.h index 1b507edc..23dabdf6 100644 --- a/src/profanity.h +++ b/src/profanity.h @@ -1,7 +1,7 @@ /* * profanity.h * - * Copyright (C) 2012 - 2016 James Booth + * Copyright (C) 2012 - 2017 James Booth * * This file is part of Profanity. * diff --git a/src/tools/autocomplete.c b/src/tools/autocomplete.c index e54bba9f..b94db481 100644 --- a/src/tools/autocomplete.c +++ b/src/tools/autocomplete.c @@ -1,7 +1,7 @@ /* * autocomplete.c * - * Copyright (C) 2012 - 2016 James Booth + * Copyright (C) 2012 - 2017 James Booth * * This file is part of Profanity. * @@ -35,6 +35,7 @@ #include #include #include +#include #include "common.h" #include "tools/autocomplete.h" @@ -330,10 +331,17 @@ autocomplete_param_no_with_func(const char *const input, char *command, int arg_ static gchar* _search_from(Autocomplete ac, GSList *curr, gboolean quote) { + gchar *search_str_ascii = g_str_to_ascii(ac->search_str, NULL); + gchar *search_str_lower = g_ascii_strdown(search_str_ascii, -1); + g_free(search_str_ascii); + while(curr) { + gchar *curr_ascii = g_str_to_ascii(curr->data, NULL); + gchar *curr_lower = g_ascii_strdown(curr_ascii, -1); + g_free(curr_ascii); // match found - if (strncmp(curr->data, ac->search_str, strlen(ac->search_str)) == 0) { + if (strncmp(curr_lower, search_str_lower, strlen(search_str_lower)) == 0) { // set pointer to last found ac->last_found = curr; @@ -347,16 +355,22 @@ _search_from(Autocomplete ac, GSList *curr, gboolean quote) gchar *result = quoted->str; g_string_free(quoted, FALSE); + g_free(search_str_lower); + g_free(curr_lower); return result; // otherwise just return the string } else { + g_free(search_str_lower); + g_free(curr_lower); return strdup(curr->data); } } + g_free(curr_lower); curr = g_slist_next(curr); } + g_free(search_str_lower); return NULL; } diff --git a/src/tools/autocomplete.h b/src/tools/autocomplete.h index 7c2a2f4a..bead7f12 100644 --- a/src/tools/autocomplete.h +++ b/src/tools/autocomplete.h @@ -1,7 +1,7 @@ /* * autocomplete.h * - * Copyright (C) 2012 - 2016 James Booth + * Copyright (C) 2012 - 2017 James Booth * * This file is part of Profanity. * diff --git a/src/tools/http_upload.c b/src/tools/http_upload.c index 8a31b25c..6e5dd27c 100644 --- a/src/tools/http_upload.c +++ b/src/tools/http_upload.c @@ -1,7 +1,7 @@ /* * http_upload.c * - * Copyright (C) 2012 - 2016 James Booth + * Copyright (C) 2012 - 2017 James Booth * * This file is part of Profanity. * @@ -52,6 +52,7 @@ #include "config/preferences.h" #include "ui/ui.h" #include "ui/window.h" +#include "common.h" #define FALLBACK_MIMETYPE "application/octet-stream" #define FALLBACK_CONTENTTYPE_HEADER "Content-Type: application/octet-stream" @@ -330,10 +331,3 @@ off_t file_size(const char* const filename) stat(filename, &st); return st.st_size; } - -int is_regular_file(const char *filename) -{ - struct stat st; - stat(filename, &st); - return S_ISREG(st.st_mode); -} diff --git a/src/tools/http_upload.h b/src/tools/http_upload.h index 217c1321..ae8f8223 100644 --- a/src/tools/http_upload.h +++ b/src/tools/http_upload.h @@ -1,7 +1,7 @@ /* * http_upload.h * - * Copyright (C) 2012 - 2016 James Booth + * Copyright (C) 2012 - 2017 James Booth * * This file is part of Profanity. * @@ -62,6 +62,5 @@ void* http_file_put(void *userdata); char* file_mime_type(const char* const file_name); off_t file_size(const char* const file_name); -int is_regular_file(const char *filename); #endif diff --git a/src/tools/parser.c b/src/tools/parser.c index d6ec13df..1e960235 100644 --- a/src/tools/parser.c +++ b/src/tools/parser.c @@ -1,7 +1,7 @@ /* * parser.c * - * Copyright (C) 2012 - 2016 James Booth + * Copyright (C) 2012 - 2017 James Booth * * This file is part of Profanity. * diff --git a/src/tools/parser.h b/src/tools/parser.h index b5ce5383..a60ee823 100644 --- a/src/tools/parser.h +++ b/src/tools/parser.h @@ -1,7 +1,7 @@ /* * parser.h * - * Copyright (C) 2012 - 2016 James Booth + * Copyright (C) 2012 - 2017 James Booth * * This file is part of Profanity. * diff --git a/src/tools/tinyurl.c b/src/tools/tinyurl.c index af0d088b..1b94a936 100644 --- a/src/tools/tinyurl.c +++ b/src/tools/tinyurl.c @@ -1,7 +1,7 @@ /* * tinyurl.c * - * Copyright (C) 2012 - 2016 James Booth + * Copyright (C) 2012 - 2017 James Booth * * This file is part of Profanity. * diff --git a/src/tools/tinyurl.h b/src/tools/tinyurl.h index e30d9773..9e99539b 100644 --- a/src/tools/tinyurl.h +++ b/src/tools/tinyurl.h @@ -1,7 +1,7 @@ /* * tinyurl.h * - * Copyright (C) 2012 - 2016 James Booth + * Copyright (C) 2012 - 2017 James Booth * * This file is part of Profanity. * diff --git a/src/ui/buffer.c b/src/ui/buffer.c index b55ebf3a..102ba4b2 100644 --- a/src/ui/buffer.c +++ b/src/ui/buffer.c @@ -1,7 +1,7 @@ /* * buffer.c * - * Copyright (C) 2012 - 2016 James Booth + * Copyright (C) 2012 - 2017 James Booth * * This file is part of Profanity. * diff --git a/src/ui/buffer.h b/src/ui/buffer.h index a191aa45..8a14dd51 100644 --- a/src/ui/buffer.h +++ b/src/ui/buffer.h @@ -1,7 +1,7 @@ /* * buffer.h * - * Copyright (C) 2012 - 2016 James Booth + * Copyright (C) 2012 - 2017 James Booth * * This file is part of Profanity. * diff --git a/src/ui/chatwin.c b/src/ui/chatwin.c index 646ef578..3ca44dd3 100644 --- a/src/ui/chatwin.c +++ b/src/ui/chatwin.c @@ -1,7 +1,7 @@ /* * chatwin.c * - * Copyright (C) 2012 - 2016 James Booth + * Copyright (C) 2012 - 2017 James Booth * * This file is part of Profanity. * diff --git a/src/ui/console.c b/src/ui/console.c index 75b66451..4c24b450 100644 --- a/src/ui/console.c +++ b/src/ui/console.c @@ -1,7 +1,7 @@ /* * console.c * - * Copyright (C) 2012 - 2016 James Booth + * Copyright (C) 2012 - 2017 James Booth * * This file is part of Profanity. * @@ -412,7 +412,7 @@ cons_about(void) } } - win_println(console, THEME_DEFAULT, '-', "Copyright (C) 2012 - 2016 James Booth <%s>.", PACKAGE_BUGREPORT); + win_println(console, THEME_DEFAULT, '-', "Copyright (C) 2012 - 2017 James Booth <%s>.", PACKAGE_BUGREPORT); win_println(console, THEME_DEFAULT, '-', "License GPLv3+: GNU GPL version 3 or later "); win_println(console, THEME_DEFAULT, '-', ""); win_println(console, THEME_DEFAULT, '-', "This is free software; you are free to change and redistribute it."); @@ -2224,6 +2224,7 @@ cons_theme_properties(void) _cons_theme_bar_prop(THEME_STATUS_BRACKET, "statusbar.brackets"); _cons_theme_bar_prop(THEME_STATUS_ACTIVE, "statusbar.active"); _cons_theme_bar_prop(THEME_STATUS_NEW, "statusbar.new"); + _cons_theme_bar_prop(THEME_STATUS_TIME, "statusbar.time"); _cons_theme_prop(THEME_TIME, "main.time"); _cons_theme_prop(THEME_TEXT, "main.text"); diff --git a/src/ui/core.c b/src/ui/core.c index a12bb3ea..539d78fd 100644 --- a/src/ui/core.c +++ b/src/ui/core.c @@ -1,7 +1,7 @@ /* * core.c * - * Copyright (C) 2012 - 2016 James Booth + * Copyright (C) 2012 - 2017 James Booth * * This file is part of Profanity. * diff --git a/src/ui/inputwin.c b/src/ui/inputwin.c index 9197485f..b42c366a 100644 --- a/src/ui/inputwin.c +++ b/src/ui/inputwin.c @@ -1,7 +1,7 @@ /* * inputwin.c * - * Copyright (C) 2012 - 2016 James Booth + * Copyright (C) 2012 - 2017 James Booth * * This file is part of Profanity. * diff --git a/src/ui/inputwin.h b/src/ui/inputwin.h index b36ae68d..000c13c6 100644 --- a/src/ui/inputwin.h +++ b/src/ui/inputwin.h @@ -1,7 +1,7 @@ /* * inputwin.c * - * Copyright (C) 2012 - 2016 James Booth + * Copyright (C) 2012 - 2017 James Booth * * This file is part of Profanity. * diff --git a/src/ui/mucconfwin.c b/src/ui/mucconfwin.c index 6bdf23fe..d181c769 100644 --- a/src/ui/mucconfwin.c +++ b/src/ui/mucconfwin.c @@ -1,7 +1,7 @@ /* * mucconfwin.c * - * Copyright (C) 2012 - 2016 James Booth + * Copyright (C) 2012 - 2017 James Booth * * This file is part of Profanity. * diff --git a/src/ui/mucwin.c b/src/ui/mucwin.c index e532871c..cb929b4a 100644 --- a/src/ui/mucwin.c +++ b/src/ui/mucwin.c @@ -1,7 +1,7 @@ /* * mucwin.c * - * Copyright (C) 2012 - 2016 James Booth + * Copyright (C) 2012 - 2017 James Booth * * This file is part of Profanity. * diff --git a/src/ui/notifier.c b/src/ui/notifier.c index c2be3be7..7cf9ad02 100644 --- a/src/ui/notifier.c +++ b/src/ui/notifier.c @@ -1,7 +1,7 @@ /* * notifier.c * - * Copyright (C) 2012 - 2016 James Booth + * Copyright (C) 2012 - 2017 James Booth * * This file is part of Profanity. * diff --git a/src/ui/occupantswin.c b/src/ui/occupantswin.c index 716ddda7..213c1f85 100644 --- a/src/ui/occupantswin.c +++ b/src/ui/occupantswin.c @@ -1,7 +1,7 @@ /* * occupantswin.c * - * Copyright (C) 2012 - 2016 James Booth + * Copyright (C) 2012 - 2017 James Booth * * This file is part of Profanity. * diff --git a/src/ui/privwin.c b/src/ui/privwin.c index 7fb9c62d..20f4b1cb 100644 --- a/src/ui/privwin.c +++ b/src/ui/privwin.c @@ -1,7 +1,7 @@ /* * privwin.c * - * Copyright (C) 2012 - 2016 James Booth + * Copyright (C) 2012 - 2017 James Booth * * This file is part of Profanity. * diff --git a/src/ui/rosterwin.c b/src/ui/rosterwin.c index 933d1a72..30dedea6 100644 --- a/src/ui/rosterwin.c +++ b/src/ui/rosterwin.c @@ -1,7 +1,7 @@ /* * rosterwin.c * - * Copyright (C) 2012 - 2016 James Booth + * Copyright (C) 2012 - 2017 James Booth * * This file is part of Profanity. * diff --git a/src/ui/screen.c b/src/ui/screen.c index 63cdab27..519f3b1e 100644 --- a/src/ui/screen.c +++ b/src/ui/screen.c @@ -1,7 +1,7 @@ /* * screen.c * - * Copyright (C) 2012 - 2016 James Booth + * Copyright (C) 2012 - 2017 James Booth * * This file is part of Profanity. * diff --git a/src/ui/screen.h b/src/ui/screen.h index 388d6fb5..0ff94fd5 100644 --- a/src/ui/screen.h +++ b/src/ui/screen.h @@ -1,7 +1,7 @@ /* * screen.h * - * Copyright (C) 2012 - 2016 James Booth + * Copyright (C) 2012 - 2017 James Booth * * This file is part of Profanity. * diff --git a/src/ui/statusbar.c b/src/ui/statusbar.c index 9964c314..7998d7b4 100644 --- a/src/ui/statusbar.c +++ b/src/ui/statusbar.c @@ -1,7 +1,7 @@ /* * statusbar.c * - * Copyright (C) 2012 - 2016 James Booth + * Copyright (C) 2012 - 2017 James Booth * * This file is part of Profanity. * @@ -459,6 +459,7 @@ _status_bar_draw(void) last_time = g_date_time_new_now(tz); int bracket_attrs = theme_attrs(THEME_STATUS_BRACKET); + int time_attrs = theme_attrs(THEME_STATUS_TIME); char *time_pref = prefs_get_string(PREF_TIME_STATUSBAR); if (g_strcmp0(time_pref, "off") != 0) { @@ -468,7 +469,9 @@ _status_bar_draw(void) wattron(status_bar, bracket_attrs); mvwaddch(status_bar, 0, 1, '['); wattroff(status_bar, bracket_attrs); + wattron(status_bar, time_attrs); mvwprintw(status_bar, 0, 2, date_fmt); + wattroff(status_bar, time_attrs); wattron(status_bar, bracket_attrs); mvwaddch(status_bar, 0, 2 + len, ']'); wattroff(status_bar, bracket_attrs); diff --git a/src/ui/statusbar.h b/src/ui/statusbar.h index 390d0203..ce863b75 100644 --- a/src/ui/statusbar.h +++ b/src/ui/statusbar.h @@ -1,7 +1,7 @@ /* * statusbar.h * - * Copyright (C) 2012 - 2016 James Booth + * Copyright (C) 2012 - 2017 James Booth * * This file is part of Profanity. * diff --git a/src/ui/titlebar.c b/src/ui/titlebar.c index 77360ec5..3b170558 100644 --- a/src/ui/titlebar.c +++ b/src/ui/titlebar.c @@ -1,7 +1,7 @@ /* * titlebar.c * - * Copyright (C) 2012 - 2016 James Booth + * Copyright (C) 2012 - 2017 James Booth * * This file is part of Profanity. * diff --git a/src/ui/titlebar.h b/src/ui/titlebar.h index ca8da30a..dda517a2 100644 --- a/src/ui/titlebar.h +++ b/src/ui/titlebar.h @@ -1,7 +1,7 @@ /* * titlebar.h * - * Copyright (C) 2012 - 2016 James Booth + * Copyright (C) 2012 - 2017 James Booth * * This file is part of Profanity. * diff --git a/src/ui/tray.c b/src/ui/tray.c index 6aca8ea5..36817004 100644 --- a/src/ui/tray.c +++ b/src/ui/tray.c @@ -1,7 +1,7 @@ /* * tray.c * - * Copyright (C) 2012 - 2016 James Booth + * Copyright (C) 2012 - 2017 James Booth * * This file is part of Profanity. * diff --git a/src/ui/tray.h b/src/ui/tray.h index f33176e7..4efe988a 100644 --- a/src/ui/tray.h +++ b/src/ui/tray.h @@ -1,7 +1,7 @@ /* * tray.h * - * Copyright (C) 2012 - 2016 James Booth + * Copyright (C) 2012 - 2017 James Booth * * This file is part of Profanity. * diff --git a/src/ui/ui.h b/src/ui/ui.h index 608059de..a04dc9e6 100644 --- a/src/ui/ui.h +++ b/src/ui/ui.h @@ -1,7 +1,7 @@ /* * ui.h * - * Copyright (C) 2012 - 2016 James Booth + * Copyright (C) 2012 - 2017 James Booth * * This file is part of Profanity. * diff --git a/src/ui/win_types.h b/src/ui/win_types.h index 462e177e..87ee0b40 100644 --- a/src/ui/win_types.h +++ b/src/ui/win_types.h @@ -1,7 +1,7 @@ /* * win_types.h * - * Copyright (C) 2012 - 2016 James Booth + * Copyright (C) 2012 - 2017 James Booth * * This file is part of Profanity. * diff --git a/src/ui/window.c b/src/ui/window.c index 6b8ae06e..aea4b60c 100644 --- a/src/ui/window.c +++ b/src/ui/window.c @@ -1,7 +1,7 @@ /* * window.c * - * Copyright (C) 2012 - 2016 James Booth + * Copyright (C) 2012 - 2017 James Booth * * This file is part of Profanity. * diff --git a/src/ui/window.h b/src/ui/window.h index 31ccd7e3..074e5855 100644 --- a/src/ui/window.h +++ b/src/ui/window.h @@ -1,7 +1,7 @@ /* * window.h * - * Copyright (C) 2012 - 2016 James Booth + * Copyright (C) 2012 - 2017 James Booth * * This file is part of Profanity. * diff --git a/src/ui/window_list.c b/src/ui/window_list.c index 1692cb4e..cf16dbab 100644 --- a/src/ui/window_list.c +++ b/src/ui/window_list.c @@ -1,7 +1,7 @@ /* * window_list.c * - * Copyright (C) 2012 - 2016 James Booth + * Copyright (C) 2012 - 2017 James Booth * * This file is part of Profanity. * diff --git a/src/ui/window_list.h b/src/ui/window_list.h index 0f319ac8..450175b7 100644 --- a/src/ui/window_list.h +++ b/src/ui/window_list.h @@ -1,7 +1,7 @@ /* * window_list.h * - * Copyright (C) 2012 - 2016 James Booth + * Copyright (C) 2012 - 2017 James Booth * * This file is part of Profanity. * diff --git a/src/ui/xmlwin.c b/src/ui/xmlwin.c index 009bb5e3..e845b2e0 100644 --- a/src/ui/xmlwin.c +++ b/src/ui/xmlwin.c @@ -1,7 +1,7 @@ /* * xmlwin.c * - * Copyright (C) 2012 - 2016 James Booth + * Copyright (C) 2012 - 2017 James Booth * * This file is part of Profanity. * diff --git a/src/xmpp/blocking.c b/src/xmpp/blocking.c index 88266068..05b80380 100644 --- a/src/xmpp/blocking.c +++ b/src/xmpp/blocking.c @@ -1,7 +1,7 @@ /* * blocking.c * - * Copyright (C) 2012 - 2016 James Booth + * Copyright (C) 2012 - 2017 James Booth * * This file is part of Profanity. * diff --git a/src/xmpp/blocking.h b/src/xmpp/blocking.h index 14ae68b6..1e3b6961 100644 --- a/src/xmpp/blocking.h +++ b/src/xmpp/blocking.h @@ -1,7 +1,7 @@ /* * blocking.h * - * Copyright (C) 2012 - 2016 James Booth + * Copyright (C) 2012 - 2017 James Booth * * This file is part of Profanity. * diff --git a/src/xmpp/bookmark.c b/src/xmpp/bookmark.c index d4371dc5..84b5e4bb 100644 --- a/src/xmpp/bookmark.c +++ b/src/xmpp/bookmark.c @@ -1,7 +1,7 @@ /* * bookmark.c * - * Copyright (C) 2012 - 2016 James Booth + * Copyright (C) 2012 - 2017 James Booth * * This file is part of Profanity. * diff --git a/src/xmpp/bookmark.h b/src/xmpp/bookmark.h index a4e243f1..c9dfa214 100644 --- a/src/xmpp/bookmark.h +++ b/src/xmpp/bookmark.h @@ -1,7 +1,7 @@ /* * bookmark.h * - * Copyright (C) 2012 - 2016 James Booth + * Copyright (C) 2012 - 2017 James Booth * * This file is part of Profanity. * diff --git a/src/xmpp/capabilities.c b/src/xmpp/capabilities.c index 7571ad0c..263680a6 100644 --- a/src/xmpp/capabilities.c +++ b/src/xmpp/capabilities.c @@ -1,7 +1,7 @@ /* * capabilities.c * - * Copyright (C) 2012 - 2016 James Booth + * Copyright (C) 2012 - 2017 James Booth * * This file is part of Profanity. * diff --git a/src/xmpp/capabilities.h b/src/xmpp/capabilities.h index 9b77734e..c1b820fb 100644 --- a/src/xmpp/capabilities.h +++ b/src/xmpp/capabilities.h @@ -1,7 +1,7 @@ /* * capabilities.h * - * Copyright (C) 2012 - 2016 James Booth + * Copyright (C) 2012 - 2017 James Booth * * This file is part of Profanity. * diff --git a/src/xmpp/chat_session.c b/src/xmpp/chat_session.c index d08ba340..6e6d871a 100644 --- a/src/xmpp/chat_session.c +++ b/src/xmpp/chat_session.c @@ -1,7 +1,7 @@ /* * chat_session.c * - * Copyright (C) 2012 - 2016 James Booth + * Copyright (C) 2012 - 2017 James Booth * * This file is part of Profanity. * diff --git a/src/xmpp/chat_session.h b/src/xmpp/chat_session.h index 46edb494..be3b1ce6 100644 --- a/src/xmpp/chat_session.h +++ b/src/xmpp/chat_session.h @@ -1,7 +1,7 @@ /* * chat_session.h * - * Copyright (C) 2012 - 2016 James Booth + * Copyright (C) 2012 - 2017 James Booth * * This file is part of Profanity. * diff --git a/src/xmpp/chat_state.c b/src/xmpp/chat_state.c index ad78c3b9..cb1b9f69 100644 --- a/src/xmpp/chat_state.c +++ b/src/xmpp/chat_state.c @@ -1,7 +1,7 @@ /* * chat_state.c * - * Copyright (C) 2012 - 2016 James Booth + * Copyright (C) 2012 - 2017 James Booth * * This file is part of Profanity. * diff --git a/src/xmpp/chat_state.h b/src/xmpp/chat_state.h index 8fcfabf5..9255cb04 100644 --- a/src/xmpp/chat_state.h +++ b/src/xmpp/chat_state.h @@ -1,7 +1,7 @@ /* * chat_state.h * - * Copyright (C) 2012 - 2016 James Booth + * Copyright (C) 2012 - 2017 James Booth * * This file is part of Profanity. * diff --git a/src/xmpp/connection.c b/src/xmpp/connection.c index 2c74f1e4..438e1c8a 100644 --- a/src/xmpp/connection.c +++ b/src/xmpp/connection.c @@ -1,7 +1,7 @@ /* * connection.c * - * Copyright (C) 2012 - 2016 James Booth + * Copyright (C) 2012 - 2017 James Booth * * This file is part of Profanity. * diff --git a/src/xmpp/connection.h b/src/xmpp/connection.h index 7bedb94a..ea3d08e7 100644 --- a/src/xmpp/connection.h +++ b/src/xmpp/connection.h @@ -1,7 +1,7 @@ /* * connection.h * - * Copyright (C) 2012 - 2016 James Booth + * Copyright (C) 2012 - 2017 James Booth * * This file is part of Profanity. * diff --git a/src/xmpp/contact.c b/src/xmpp/contact.c index d50af5cd..0fbff9d5 100644 --- a/src/xmpp/contact.c +++ b/src/xmpp/contact.c @@ -1,7 +1,7 @@ /* * contact.c * - * Copyright (C) 2012 - 2016 James Booth + * Copyright (C) 2012 - 2017 James Booth * * This file is part of Profanity. * diff --git a/src/xmpp/contact.h b/src/xmpp/contact.h index 8e71faef..73849351 100644 --- a/src/xmpp/contact.h +++ b/src/xmpp/contact.h @@ -1,7 +1,7 @@ /* * contact.h * - * Copyright (C) 2012 - 2016 James Booth + * Copyright (C) 2012 - 2017 James Booth * * This file is part of Profanity. * diff --git a/src/xmpp/form.c b/src/xmpp/form.c index 25f1bb7b..e1bd4a93 100644 --- a/src/xmpp/form.c +++ b/src/xmpp/form.c @@ -1,7 +1,7 @@ /* * form.c * - * Copyright (C) 2012 - 2016 James Booth + * Copyright (C) 2012 - 2017 James Booth * * This file is part of Profanity. * diff --git a/src/xmpp/form.h b/src/xmpp/form.h index 5ce9ce31..aa446017 100644 --- a/src/xmpp/form.h +++ b/src/xmpp/form.h @@ -1,7 +1,7 @@ /* * form.h * - * Copyright (C) 2012 - 2016 James Booth + * Copyright (C) 2012 - 2017 James Booth * * This file is part of Profanity. * diff --git a/src/xmpp/iq.c b/src/xmpp/iq.c index f5e1657c..edbf3557 100644 --- a/src/xmpp/iq.c +++ b/src/xmpp/iq.c @@ -1,7 +1,7 @@ /* * iq.c * - * Copyright (C) 2012 - 2016 James Booth + * Copyright (C) 2012 - 2017 James Booth * * This file is part of Profanity. * diff --git a/src/xmpp/iq.h b/src/xmpp/iq.h index 1c9474fb..e56d2f59 100644 --- a/src/xmpp/iq.h +++ b/src/xmpp/iq.h @@ -1,7 +1,7 @@ /* * iq.h * - * Copyright (C) 2012 - 2016 James Booth + * Copyright (C) 2012 - 2017 James Booth * * This file is part of Profanity. * diff --git a/src/xmpp/jid.c b/src/xmpp/jid.c index 135a21df..ac4cdcdb 100644 --- a/src/xmpp/jid.c +++ b/src/xmpp/jid.c @@ -1,7 +1,7 @@ /* * jid.c * - * Copyright (C) 2012 - 2016 James Booth + * Copyright (C) 2012 - 2017 James Booth * * This file is part of Profanity. * diff --git a/src/xmpp/jid.h b/src/xmpp/jid.h index 16e6e78b..0ce0ec5b 100644 --- a/src/xmpp/jid.h +++ b/src/xmpp/jid.h @@ -1,7 +1,7 @@ /* * jid.h * - * Copyright (C) 2012 - 2016 James Booth + * Copyright (C) 2012 - 2017 James Booth * * This file is part of Profanity. * diff --git a/src/xmpp/message.c b/src/xmpp/message.c index d78e891f..4afbe4b1 100644 --- a/src/xmpp/message.c +++ b/src/xmpp/message.c @@ -1,7 +1,7 @@ /* * message.c * - * Copyright (C) 2012 - 2016 James Booth + * Copyright (C) 2012 - 2017 James Booth * * This file is part of Profanity. * diff --git a/src/xmpp/message.h b/src/xmpp/message.h index c6561bca..b8ba039e 100644 --- a/src/xmpp/message.h +++ b/src/xmpp/message.h @@ -1,7 +1,7 @@ /* * message.h * - * Copyright (C) 2012 - 2016 James Booth + * Copyright (C) 2012 - 2017 James Booth * * This file is part of Profanity. * diff --git a/src/xmpp/muc.c b/src/xmpp/muc.c index b7c9884e..7e926593 100644 --- a/src/xmpp/muc.c +++ b/src/xmpp/muc.c @@ -1,7 +1,7 @@ /* * muc.c * - * Copyright (C) 2012 - 2016 James Booth + * Copyright (C) 2012 - 2017 James Booth * * This file is part of Profanity. * diff --git a/src/xmpp/muc.h b/src/xmpp/muc.h index 84be1dd2..fedabc2a 100644 --- a/src/xmpp/muc.h +++ b/src/xmpp/muc.h @@ -1,7 +1,7 @@ /* * muc.h * - * Copyright (C) 2012 - 2016 James Booth + * Copyright (C) 2012 - 2017 James Booth * * This file is part of Profanity. * diff --git a/src/xmpp/presence.c b/src/xmpp/presence.c index 2a844ac6..f2772f59 100644 --- a/src/xmpp/presence.c +++ b/src/xmpp/presence.c @@ -1,7 +1,7 @@ /* * presence.c * - * Copyright (C) 2012 - 2016 James Booth + * Copyright (C) 2012 - 2017 James Booth * * This file is part of Profanity. * diff --git a/src/xmpp/presence.h b/src/xmpp/presence.h index f16f2201..4415be1b 100644 --- a/src/xmpp/presence.h +++ b/src/xmpp/presence.h @@ -1,7 +1,7 @@ /* * presence.h * - * Copyright (C) 2012 - 2016 James Booth + * Copyright (C) 2012 - 2017 James Booth * * This file is part of Profanity. * diff --git a/src/xmpp/resource.c b/src/xmpp/resource.c index 2309883c..154f8490 100644 --- a/src/xmpp/resource.c +++ b/src/xmpp/resource.c @@ -1,7 +1,7 @@ /* * resource.c * - * Copyright (C) 2012 - 2016 James Booth + * Copyright (C) 2012 - 2017 James Booth * * This file is part of Profanity. * diff --git a/src/xmpp/resource.h b/src/xmpp/resource.h index ec22569a..8acc5207 100644 --- a/src/xmpp/resource.h +++ b/src/xmpp/resource.h @@ -1,7 +1,7 @@ /* * resource.h * - * Copyright (C) 2012 - 2016 James Booth + * Copyright (C) 2012 - 2017 James Booth * * This file is part of Profanity. * diff --git a/src/xmpp/roster.c b/src/xmpp/roster.c index c7725b43..ba152410 100644 --- a/src/xmpp/roster.c +++ b/src/xmpp/roster.c @@ -1,7 +1,7 @@ /* * roster.c * - * Copyright (C) 2012 - 2016 James Booth + * Copyright (C) 2012 - 2017 James Booth * * This file is part of Profanity. * diff --git a/src/xmpp/roster.h b/src/xmpp/roster.h index 49acf9a6..806c7316 100644 --- a/src/xmpp/roster.h +++ b/src/xmpp/roster.h @@ -1,7 +1,7 @@ /* * roster.h * - * Copyright (C) 2012 - 2016 James Booth + * Copyright (C) 2012 - 2017 James Booth * * This file is part of Profanity. * diff --git a/src/xmpp/roster_list.c b/src/xmpp/roster_list.c index 057146a2..19d0ea06 100644 --- a/src/xmpp/roster_list.c +++ b/src/xmpp/roster_list.c @@ -1,7 +1,7 @@ /* * roster_list.c * - * Copyright (C) 2012 - 2016 James Booth + * Copyright (C) 2012 - 2017 James Booth * * This file is part of Profanity. * diff --git a/src/xmpp/roster_list.h b/src/xmpp/roster_list.h index 843c2546..971285c2 100644 --- a/src/xmpp/roster_list.h +++ b/src/xmpp/roster_list.h @@ -1,7 +1,7 @@ /* * roster_list.h * - * Copyright (C) 2012 - 2016 James Booth + * Copyright (C) 2012 - 2017 James Booth * * This file is part of Profanity. * diff --git a/src/xmpp/session.c b/src/xmpp/session.c index ea6a8a7f..633af31f 100644 --- a/src/xmpp/session.c +++ b/src/xmpp/session.c @@ -1,7 +1,7 @@ /* * session.c * - * Copyright (C) 2012 - 2016 James Booth + * Copyright (C) 2012 - 2017 James Booth * * This file is part of Profanity. * diff --git a/src/xmpp/session.h b/src/xmpp/session.h index 2d51d65c..a8c6ab83 100644 --- a/src/xmpp/session.h +++ b/src/xmpp/session.h @@ -1,7 +1,7 @@ /* * session.h * - * Copyright (C) 2012 - 2016 James Booth + * Copyright (C) 2012 - 2017 James Booth * * This file is part of Profanity. * diff --git a/src/xmpp/stanza.c b/src/xmpp/stanza.c index 2c4f1bd0..4dd0a2d4 100644 --- a/src/xmpp/stanza.c +++ b/src/xmpp/stanza.c @@ -1,7 +1,7 @@ /* * stanza.c * - * Copyright (C) 2012 - 2016 James Booth + * Copyright (C) 2012 - 2017 James Booth * * This file is part of Profanity. * diff --git a/src/xmpp/stanza.h b/src/xmpp/stanza.h index 2c923657..5da1c2c3 100644 --- a/src/xmpp/stanza.h +++ b/src/xmpp/stanza.h @@ -1,7 +1,7 @@ /* * stanza.h * - * Copyright (C) 2012 - 2016 James Booth + * Copyright (C) 2012 - 20172017 James Booth * * This file is part of Profanity. * diff --git a/src/xmpp/xmpp.h b/src/xmpp/xmpp.h index c70fd4dd..dcbb7615 100644 --- a/src/xmpp/xmpp.h +++ b/src/xmpp/xmpp.h @@ -1,7 +1,7 @@ /* * xmpp.h * - * Copyright (C) 2012 - 2016 James Booth + * Copyright (C) 2012 - 2017 James Booth * * This file is part of Profanity. * diff --git a/tests/unittests/test_autocomplete.c b/tests/unittests/test_autocomplete.c index 2fd68b51..755e01c9 100644 --- a/tests/unittests/test_autocomplete.c +++ b/tests/unittests/test_autocomplete.c @@ -117,3 +117,67 @@ void add_two_same_updates(void **state) autocomplete_clear(ac); g_slist_free_full(result, g_free); } + +void complete_accented_with_accented(void **state) +{ + Autocomplete ac = autocomplete_new(); + autocomplete_add(ac, "èâîô"); + + char *result = autocomplete_complete(ac, "èâ", TRUE); + + assert_string_equal("èâîô", result); + + autocomplete_clear(ac); +} + +void complete_accented_with_base(void **state) +{ + Autocomplete ac = autocomplete_new(); + autocomplete_add(ac, "èâîô"); + + char *result = autocomplete_complete(ac, "ea", TRUE); + + assert_string_equal("èâîô", result); + + autocomplete_clear(ac); +} + +void complete_both_with_accented(void **state) +{ + Autocomplete ac = autocomplete_new(); + autocomplete_add(ac, "eaooooo"); + autocomplete_add(ac, "èâîô"); + + char *result1 = autocomplete_complete(ac, "èâ", TRUE); + char *result2 = autocomplete_complete(ac, result1, TRUE); + + assert_string_equal("èâîô", result2); + + autocomplete_clear(ac); +} + +void complete_both_with_base(void **state) +{ + Autocomplete ac = autocomplete_new(); + autocomplete_add(ac, "eaooooo"); + autocomplete_add(ac, "èâîô"); + + char *result1 = autocomplete_complete(ac, "ea", TRUE); + char *result2 = autocomplete_complete(ac, result1, TRUE); + + assert_string_equal("èâîô", result2); + + autocomplete_clear(ac); +} + +void complete_ignores_case(void **state) +{ + Autocomplete ac = autocomplete_new(); + autocomplete_add(ac, "MyBuddy"); + + char *result = autocomplete_complete(ac, "myb", TRUE); + + assert_string_equal("MyBuddy", result); + + autocomplete_clear(ac); +} diff --git a/tests/unittests/test_autocomplete.h b/tests/unittests/test_autocomplete.h index 4ad327c0..a9dd34cb 100644 --- a/tests/unittests/test_autocomplete.h +++ b/tests/unittests/test_autocomplete.h @@ -8,3 +8,8 @@ void add_two_and_complete_returns_second(void **state); void add_two_adds_two(void **state); void add_two_same_adds_one(void **state); void add_two_same_updates(void **state); +void complete_accented_with_accented(void **state); +void complete_accented_with_base(void **state); +void complete_both_with_accented(void **state); +void complete_both_with_base(void **state); +void complete_ignores_case(void **state); diff --git a/tests/unittests/test_common.c b/tests/unittests/test_common.c index d03f2123..75eed6e2 100644 --- a/tests/unittests/test_common.c +++ b/tests/unittests/test_common.c @@ -444,12 +444,25 @@ void prof_whole_occurrences_tests(void **state) assert_true(_lists_equal(prof_occurrences("boothj5", "boothj5, hi", 0, TRUE, &actual), expected)); g_slist_free(actual); actual = NULL; g_slist_free(expected); expected = NULL; + expected = g_slist_append(expected, GINT_TO_POINTER(0)); + assert_true(_lists_equal(prof_occurrences("我能吞下玻璃而", "我能吞下玻璃而", 0, TRUE, &actual), expected)); g_slist_free(actual); actual = NULL; + assert_true(_lists_equal(prof_occurrences("我能吞下玻璃而", "我能吞下玻璃而 hi", 0, TRUE, &actual), expected)); g_slist_free(actual); actual = NULL; + assert_true(_lists_equal(prof_occurrences("我能吞下玻璃而", "我能吞下玻璃而: hi", 0, TRUE, &actual), expected)); g_slist_free(actual); actual = NULL; + assert_true(_lists_equal(prof_occurrences("我能吞下玻璃而", "我能吞下玻璃而, hi", 0, TRUE, &actual), expected)); g_slist_free(actual); actual = NULL; + g_slist_free(expected); expected = NULL; + expected = g_slist_append(expected, GINT_TO_POINTER(6)); assert_true(_lists_equal(prof_occurrences("boothj5", "hello boothj5", 0, TRUE, &actual), expected)); g_slist_free(actual); actual = NULL; assert_true(_lists_equal(prof_occurrences("boothj5", "hello boothj5 there", 0, TRUE, &actual), expected)); g_slist_free(actual); actual = NULL; assert_true(_lists_equal(prof_occurrences("boothj5", "heyy @boothj5, there", 0, TRUE, &actual), expected)); g_slist_free(actual); actual = NULL; g_slist_free(expected); expected = NULL; + expected = g_slist_append(expected, GINT_TO_POINTER(6)); + assert_true(_lists_equal(prof_occurrences("我能吞下玻璃而", "hello 我能吞下玻璃而", 0, TRUE, &actual), expected)); g_slist_free(actual); actual = NULL; + assert_true(_lists_equal(prof_occurrences("我能吞下玻璃而", "hello 我能吞下玻璃而 there", 0, TRUE, &actual), expected)); g_slist_free(actual); actual = NULL; + assert_true(_lists_equal(prof_occurrences("我能吞下玻璃而", "heyy @我能吞下玻璃而, there", 0, TRUE, &actual), expected)); g_slist_free(actual); actual = NULL; + g_slist_free(expected); expected = NULL; + expected = g_slist_append(expected, GINT_TO_POINTER(6)); expected = g_slist_append(expected, GINT_TO_POINTER(26)); assert_true(_lists_equal(prof_occurrences("boothj5", "hello boothj5 some more a boothj5 stuff", 0, TRUE, &actual), expected)); g_slist_free(actual); actual = NULL; @@ -457,6 +470,13 @@ void prof_whole_occurrences_tests(void **state) assert_true(_lists_equal(prof_occurrences("boothj5", "heyy @boothj5, there hows boothj5?", 0, TRUE, &actual), expected)); g_slist_free(actual); actual = NULL; g_slist_free(expected); expected = NULL; + expected = g_slist_append(expected, GINT_TO_POINTER(6)); + expected = g_slist_append(expected, GINT_TO_POINTER(26)); + assert_true(_lists_equal(prof_occurrences("我能吞下玻璃而", "hello 我能吞下玻璃而 some more a 我能吞下玻璃而 stuff", 0, TRUE, &actual), expected)); g_slist_free(actual); actual = NULL; + assert_true(_lists_equal(prof_occurrences("我能吞下玻璃而", "hello 我能吞下玻璃而 there ands #我能吞下玻璃而", 0, TRUE, &actual), expected)); g_slist_free(actual); actual = NULL; + assert_true(_lists_equal(prof_occurrences("我能吞下玻璃而", "heyy @我能吞下玻璃而, there hows 我能吞下玻璃而?", 0, TRUE, &actual), expected)); g_slist_free(actual); actual = NULL; + g_slist_free(expected); expected = NULL; + expected = g_slist_append(expected, GINT_TO_POINTER(6)); assert_true(_lists_equal(prof_occurrences("p", "ppppp p", 0, TRUE, &actual), expected)); g_slist_free(actual); actual = NULL; g_slist_free(expected); expected = NULL; @@ -488,4 +508,16 @@ void prof_whole_occurrences_tests(void **state) assert_true(_lists_equal(prof_occurrences("k", "kk", 0, TRUE, &actual), expected)); g_slist_free(actual); actual = NULL; assert_true(_lists_equal(prof_occurrences("k", "kkkkkkk", 0, TRUE, &actual), expected)); g_slist_free(actual); actual = NULL; g_slist_free(expected); expected = NULL; + + expected = NULL; + assert_true(_lists_equal(prof_occurrences("我能吞下玻璃而", "我能吞下玻璃而hello", 0, TRUE, &actual), expected)); g_slist_free(actual); actual = NULL; + assert_true(_lists_equal(prof_occurrences("我能吞下玻璃而", "hey我能吞下玻璃而", 0, TRUE, &actual), expected)); g_slist_free(actual); actual = NULL; + assert_true(_lists_equal(prof_occurrences("我能吞下玻璃而", "hey我能吞下玻璃而hithere", 0, TRUE, &actual), expected)); g_slist_free(actual); actual = NULL; + assert_true(_lists_equal(prof_occurrences("我能吞下玻璃而", "hey 我能吞下玻璃而hithere", 0, TRUE, &actual), expected)); g_slist_free(actual); actual = NULL; + assert_true(_lists_equal(prof_occurrences("我能吞下玻璃而", "hey @我能吞下玻璃而hithere", 0, TRUE, &actual), expected)); g_slist_free(actual); actual = NULL; + assert_true(_lists_equal(prof_occurrences("我能吞下玻璃而", "hey我能吞下玻璃而 hithere", 0, TRUE, &actual), expected)); g_slist_free(actual); actual = NULL; + assert_true(_lists_equal(prof_occurrences("我能吞下玻璃而", "hey我能吞下玻璃而, hithere", 0, TRUE, &actual), expected)); g_slist_free(actual); actual = NULL; + assert_true(_lists_equal(prof_occurrences("我能吞下玻璃而", "我能吞下玻璃而我能吞下玻璃而", 0, TRUE, &actual), expected)); g_slist_free(actual); actual = NULL; + assert_true(_lists_equal(prof_occurrences("我能吞下玻璃而", "我能吞下玻璃而fill我能吞下玻璃而", 0, TRUE, &actual), expected)); g_slist_free(actual); actual = NULL; + g_slist_free(expected); expected = NULL; } diff --git a/tests/unittests/tools/stub_http_upload.c b/tests/unittests/tools/stub_http_upload.c index cb7688cf..508d3f8b 100644 --- a/tests/unittests/tools/stub_http_upload.c +++ b/tests/unittests/tools/stub_http_upload.c @@ -1,37 +1,3 @@ -/* - * http_upload.h - * - * Copyright (C) 2012 - 2016 James Booth - * - * This file is part of Profanity. - * - * Profanity is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Profanity is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Profanity. If not, see . - * - * In addition, as a special exception, the copyright holders give permission to - * link the code of portions of this program with the OpenSSL library under - * certain conditions as described in each individual source file, and - * distribute linked combinations including the two. - * - * You must obey the GNU General Public License in all respects for all of the - * code used other than OpenSSL. If you modify file(s) with this exception, you - * may extend this exception to your version of the file(s), but you are not - * obligated to do so. If you do not wish to do so, delete this exception - * statement from your version. If you delete this exception statement from all - * source files in the program, then also delete it here. - * - */ - #ifndef TOOLS_HTTP_UPLOAD_H #define TOOLS_HTTP_UPLOAD_H @@ -58,6 +24,5 @@ void* http_file_put(void *userdata) {} char* file_mime_type(const char* const file_name) {} off_t file_size(const char* const file_name) {} -int is_regular_file(const char *filename) {} #endif diff --git a/tests/unittests/unittests.c b/tests/unittests/unittests.c index e0a5dd34..5c411ab6 100644 --- a/tests/unittests/unittests.c +++ b/tests/unittests/unittests.c @@ -6,6 +6,7 @@ #include #include #include +#include #include "config.h" #include "xmpp/chat_session.h" @@ -37,6 +38,7 @@ #include "test_plugins_disco.h" int main(int argc, char* argv[]) { + setlocale(LC_ALL, ""); const UnitTest all_tests[] = { unit_test(replace_one_substr), @@ -88,6 +90,11 @@ int main(int argc, char* argv[]) { unit_test(add_two_adds_two), unit_test(add_two_same_adds_one), unit_test(add_two_same_updates), + unit_test(complete_accented_with_accented), + unit_test(complete_accented_with_base), + unit_test(complete_both_with_accented), + unit_test(complete_both_with_base), + unit_test(complete_ignores_case), unit_test(create_jid_from_null_returns_null), unit_test(create_jid_from_empty_string_returns_null),