diff options
author | Jari Matilainen <jari.matilainen@istone.se> | 2017-10-24 12:02:30 +0200 |
---|---|---|
committer | Jari Matilainen <jari.matilainen@istone.se> | 2017-11-02 15:33:15 +0100 |
commit | 60c31219a278330498e695e4d7fca05ea69962e4 (patch) | |
tree | 7818f98b8fb149f62a8d9c2efe50a58309f11fcd /src/fe-common/core | |
parent | c890ecafa0ce3df1a339ae201598184ab1585d36 (diff) | |
download | irssi-60c31219a278330498e695e4d7fca05ea69962e4.zip |
Allow selection of what kind of activity targets to ignore
Initialize tagtarget on declaration
move code around for better flow, extra checks for uninitialized values
remove unnecessary item->type checks
don't strdup sign
add braces around if statements, use strcmp0 with single characters and remove g_str_has_prefix
refactoring
changed g_ascii_strcasecmp to g_strcmp0
Add networktag/ shorthand
fixed memory leaks
changed from #@= to ::channels, ::queries and ::dccqueries
check for empty string and continue; if found
fixed bug with empty string check
Clean up code
Diffstat (limited to 'src/fe-common/core')
-rw-r--r-- | src/fe-common/core/fe-common-core.c | 45 |
1 files changed, 31 insertions, 14 deletions
diff --git a/src/fe-common/core/fe-common-core.c b/src/fe-common/core/fe-common-core.c index 512fc84c..bce9ab4e 100644 --- a/src/fe-common/core/fe-common-core.c +++ b/src/fe-common/core/fe-common-core.c @@ -461,26 +461,43 @@ void fe_common_core_finish_init(void) gboolean strarray_find_dest(char **array, const TEXT_DEST_REC *dest) { + int channel_type = module_get_uniq_id_str("WINDOW ITEM TYPE", "CHANNEL"); + int query_type = module_get_uniq_id_str("WINDOW ITEM TYPE", "QUERY"); + char **tmp; + g_return_val_if_fail(array != NULL, FALSE); + g_return_val_if_fail(dest != NULL, FALSE); + g_return_val_if_fail(dest->window != NULL, FALSE); + g_return_val_if_fail(dest->target != NULL, FALSE); - if (strarray_find(array, "*") != -1) - return TRUE; + WI_ITEM_REC *item = window_item_find_window(dest->window, dest->server, dest->target); + if (item == NULL) { + return FALSE; + } - if (strarray_find(array, dest->target) != -1) - return TRUE; + int server_tag_len = dest->server_tag ? strlen(dest->server_tag) : 0; + for (tmp = array; *tmp != NULL; tmp++) { + char *str = *tmp; + if (*str == '\0') { + continue; + } - if (dest->server_tag != NULL) { - char *tagtarget = g_strdup_printf("%s/%s", dest->server_tag, "*"); - int ret = strarray_find(array, tagtarget); - g_free(tagtarget); - if (ret != -1) - return TRUE; + if (server_tag_len && !g_ascii_strncasecmp(str, dest->server_tag, server_tag_len) && str[server_tag_len] == '/') { + str += server_tag_len + 1; + } - tagtarget = g_strdup_printf("%s/%s", dest->server_tag, dest->target); - ret = strarray_find(array, tagtarget); - g_free(tagtarget); - if (ret != -1) + if (!g_strcmp0(str, "") || !g_strcmp0(str, "::all")) { return TRUE; + } else if (!g_ascii_strcasecmp(str, dest->target)) { + return TRUE; + } else if (item->type == query_type && + !g_strcmp0(str, (dest->target[0] == '=') ? "::dccqueries" : "::queries")) { + return TRUE; + } else if (item->type == channel_type && + !g_strcmp0(str, "::channels")) { + return TRUE; + } } + return FALSE; } |