mirror of
https://github.com/irssi/irssi.git
synced 2026-08-22 18:12:12 +02:00
Reworked code to use helper function for window item type
This commit is contained in:
parent
f272976505
commit
94600348cc
1 changed files with 43 additions and 45 deletions
|
|
@ -463,31 +463,37 @@ void fe_common_core_finish_init(void)
|
||||||
gboolean strarray_find_dest(char **array, const TEXT_DEST_REC *dest)
|
gboolean strarray_find_dest(char **array, const TEXT_DEST_REC *dest)
|
||||||
{
|
{
|
||||||
g_return_val_if_fail(array != NULL, FALSE);
|
g_return_val_if_fail(array != NULL, FALSE);
|
||||||
const char *type = module_find_id_str("WINDOW ITEM TYPE", dest->window->active->type);
|
WindowType type = window_item_get_type(dest->window->active);
|
||||||
|
|
||||||
if ((strarray_find(array, "*") != -1) || // we ignore all targets
|
// we ignore all targets
|
||||||
(g_ascii_strcasecmp(type, "CHANNEL") == 0 && strarray_find(array, "#") != -1) || // we ignore all channels
|
if (strarray_find(array, "*") != -1)
|
||||||
(g_ascii_strcasecmp(type, "QUERY") == 0 && // Is this a query?
|
return TRUE;
|
||||||
(g_str_has_prefix("=", dest->target) ? // is it a dcc chat?
|
// we ignore all channels
|
||||||
strarray_find(array, "=") != -1 : // are we ignoring dcc chat?
|
else if (type & WITEM_TYPE_CHANNEL && strarray_find(array, "#") != -1)
|
||||||
strarray_find(array, "@") != -1)) || // are we ognoring regular queries?
|
return TRUE;
|
||||||
(strarray_find(array, dest->target) != -1)) // we ignore all channels with specific name
|
// Is this a dcc chat?
|
||||||
|
else if (type & WITEM_TYPE_DCCCHAT && strarray_find(array, "=") != -1)
|
||||||
|
return TRUE;
|
||||||
|
// Is this a private query window?
|
||||||
|
else if (type & WITEM_TYPE_PRIVMSG && strarray_find(array, "@") != -1)
|
||||||
return TRUE;
|
return TRUE;
|
||||||
else if (dest->server_tag != NULL) {
|
else if (dest->server_tag != NULL) {
|
||||||
char *prefix = g_strdup_printf("%s/", dest->server_tag);
|
char *prefix = g_strdup_printf("%s/", dest->server_tag);
|
||||||
if (strarray_find_prefix(array, prefix)) {
|
if (!strarray_find_prefix(array, prefix)) {
|
||||||
|
g_free(prefix);
|
||||||
|
return FALSE;
|
||||||
|
}
|
||||||
|
|
||||||
GSList *targets = NULL, *iterator = NULL;
|
GSList *targets = NULL, *iterator = NULL;
|
||||||
gboolean found = FALSE;
|
gboolean found = FALSE;
|
||||||
|
|
||||||
if (type != NULL) {
|
|
||||||
// create a list of types to look for
|
// create a list of types to look for
|
||||||
targets = g_slist_append(targets, g_strdup("*"));
|
targets = g_slist_append(targets, g_strdup("*"));
|
||||||
if (g_ascii_strcasecmp(type, "CHANNEL") == 0) {
|
if (type & WITEM_TYPE_CHANNEL) {
|
||||||
targets = g_slist_append(targets, g_strdup("#"));
|
targets = g_slist_append(targets, g_strdup("#"));
|
||||||
targets = g_slist_append(targets, g_strdup(dest->target));
|
targets = g_slist_append(targets, g_strdup(dest->target));
|
||||||
}
|
}
|
||||||
else if (g_ascii_strcasecmp(type, "QUERY") == 0) {
|
else if (type & WITEM_TYPE_QUERY) {
|
||||||
if (g_str_has_prefix("=", dest->target))
|
if (type & WITEM_TYPE_DCCCHAT)
|
||||||
targets = g_slist_append(targets, g_strdup("="));
|
targets = g_slist_append(targets, g_strdup("="));
|
||||||
else
|
else
|
||||||
targets = g_slist_append(targets, g_strdup("@"));
|
targets = g_slist_append(targets, g_strdup("@"));
|
||||||
|
|
@ -503,19 +509,11 @@ gboolean strarray_find_dest(char **array, const TEXT_DEST_REC *dest)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
g_slist_foreach(targets, (GFunc)g_free, NULL);
|
g_slist_foreach(targets, (GFunc)g_free, NULL);
|
||||||
g_slist_free(targets);
|
g_slist_free(targets);
|
||||||
g_free(prefix);
|
g_free(prefix);
|
||||||
|
|
||||||
return found;
|
return found;
|
||||||
}
|
}
|
||||||
else {
|
|
||||||
g_free(prefix);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue