1
0
mirror of https://github.com/irssi/irssi.git synced 2025-01-03 14:56:47 -05:00

Merge pull request #779 from vague666/activity_hide_target_only_channels_v2

Allow selection of what kind of activity targets to ignore v2
This commit is contained in:
ailin-nemui 2018-01-08 12:19:46 +01:00 committed by GitHub
commit f83ba5a5bb
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -470,26 +470,49 @@ void fe_common_core_finish_init(void)
gboolean strarray_find_dest(char **array, const TEXT_DEST_REC *dest)
{
WI_ITEM_REC *item;
int server_tag_len, channel_type, query_type;
char **tmp;
channel_type = module_get_uniq_id_str("WINDOW ITEM TYPE", "CHANNEL");
query_type = module_get_uniq_id_str("WINDOW ITEM TYPE", "QUERY");
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;
if (strarray_find(array, dest->target) != -1)
return TRUE;
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;
tagtarget = g_strdup_printf("%s/%s", dest->server_tag, dest->target);
ret = strarray_find(array, tagtarget);
g_free(tagtarget);
if (ret != -1)
return TRUE;
item = window_item_find_window(dest->window, dest->server, dest->target);
if (item == NULL) {
return FALSE;
}
server_tag_len = dest->server_tag != NULL ? strlen(dest->server_tag) : 0;
for (tmp = array; *tmp != NULL; tmp++) {
char *str = *tmp;
if (*str == '\0') {
continue;
}
if (server_tag_len &&
g_ascii_strncasecmp(str, dest->server_tag, server_tag_len) == 0 &&
str[server_tag_len] == '/') {
str += server_tag_len + 1;
}
if (g_strcmp0(str, "") == 0 || g_strcmp0(str, "::all") == 0) {
return TRUE;
} else if (g_ascii_strcasecmp(str, dest->target) == 0) {
return TRUE;
} else if (item->type == query_type &&
g_strcmp0(str, dest->target[0] == '=' ? "::dccqueries" :
"::queries") == 0) {
return TRUE;
} else if (item->type == channel_type &&
g_strcmp0(str, "::channels") == 0) {
return TRUE;
}
}
return FALSE;
}