enum name change and early exit if no server_tag

This commit is contained in:
Jari Matilainen 2017-01-13 20:16:23 +00:00
commit 7a9d9bd40b
3 changed files with 47 additions and 47 deletions

View file

@ -469,15 +469,18 @@ gboolean strarray_find_dest(char **array, const TEXT_DEST_REC *dest)
if (strarray_find(array, "*") != -1) if (strarray_find(array, "*") != -1)
return TRUE; return TRUE;
// we ignore all channels // we ignore all channels
else if (type & WITEM_TYPE_CHANNEL && strarray_find(array, "#") != -1) else if (type & WI_TYPE_CHANNEL && strarray_find(array, "#") != -1)
return TRUE; return TRUE;
// Is this a dcc chat? // Is this a dcc chat?
else if (type & WITEM_TYPE_DCCCHAT && strarray_find(array, "=") != -1) else if (type & WI_TYPE_DCCCHAT && strarray_find(array, "=") != -1)
return TRUE; return TRUE;
// Is this a private query window? // Is this a private query window?
else if (type & WITEM_TYPE_PRIVMSG && strarray_find(array, "@") != -1) else if (type & WI_TYPE_PRIVMSG && strarray_find(array, "@") != -1)
return TRUE; return TRUE;
else if (dest->server_tag != NULL) {
if (dest->server_tag == NULL)
return FALSE;
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); g_free(prefix);
@ -488,12 +491,12 @@ gboolean strarray_find_dest(char **array, const TEXT_DEST_REC *dest)
gboolean found = FALSE; gboolean found = FALSE;
// 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 (type & WITEM_TYPE_CHANNEL) { if (type & WI_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 (type & WITEM_TYPE_QUERY) { else if (type & WI_TYPE_QUERY) {
if (type & WITEM_TYPE_DCCCHAT) if (type & WI_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("@"));
@ -513,7 +516,4 @@ gboolean strarray_find_dest(char **array, const TEXT_DEST_REC *dest)
g_slist_free(targets); g_slist_free(targets);
g_free(prefix); g_free(prefix);
return found; return found;
}
return FALSE;
} }

View file

@ -140,19 +140,19 @@ void window_item_set_active(WINDOW_REC *window, WI_ITEM_REC *item)
WindowType window_item_get_type(WI_ITEM_REC *item) WindowType window_item_get_type(WI_ITEM_REC *item)
{ {
g_return_val_if_fail(item != NULL, WITEM_TYPE_OTHER); g_return_val_if_fail(item != NULL, WI_TYPE_OTHER);
const char *type = module_find_id_str("WINDOW ITEM TYPE", item->type); const char *type = module_find_id_str("WINDOW ITEM TYPE", item->type);
if (g_ascii_strcasecmp(type, "CHANNEL") == 0) if (g_ascii_strcasecmp(type, "CHANNEL") == 0)
return WITEM_TYPE_CHANNEL; return WI_TYPE_CHANNEL;
else if (g_ascii_strcasecmp(type, "QUERY") == 0) { else if (g_ascii_strcasecmp(type, "QUERY") == 0) {
if (g_str_has_prefix("=", item->name)) if (g_str_has_prefix("=", item->name))
return WITEM_TYPE_QUERY | WITEM_TYPE_DCCCHAT; return WI_TYPE_QUERY | WI_TYPE_DCCCHAT;
else else
return WITEM_TYPE_QUERY | WITEM_TYPE_PRIVMSG; return WI_TYPE_QUERY | WI_TYPE_PRIVMSG;
} }
else else
return WITEM_TYPE_OTHER; return WI_TYPE_OTHER;
} }
/* Return TRUE if `item' is the active window item in the window. /* Return TRUE if `item' is the active window item in the window.

View file

@ -4,11 +4,11 @@
#include "fe-windows.h" #include "fe-windows.h"
typedef enum { typedef enum {
WITEM_TYPE_CHANNEL = 1, WI_TYPE_CHANNEL = 1,
WITEM_TYPE_QUERY = 2, WI_TYPE_QUERY = 2,
WITEM_TYPE_PRIVMSG = 4, WI_TYPE_PRIVMSG = 4,
WITEM_TYPE_DCCCHAT = 8, WI_TYPE_DCCCHAT = 8,
WITEM_TYPE_OTHER = 16 WI_TYPE_OTHER = 16
} WindowType; } WindowType;
/* Add/remove/destroy window item from `window' */ /* Add/remove/destroy window item from `window' */