コード例 #1
0
ファイル: windows.c プロジェクト: svn2github/irssi
WINDOW_REC *window_find_item(WINDOW_REC *window, const char *name)
{
	WINDOW_REC *rec;
	WI_ITEM_REC *item;

	g_return_val_if_fail(name != NULL, NULL);

	rec = window_find_name(name);
	if (rec != NULL) return rec;

	item = window == NULL ? NULL :
		window_item_find(window->active_server, name);
	if (item == NULL && window->active_server != NULL) {
		/* not found from the active server - any server? */
		item = window_item_find(NULL, name);
	}

	if (item == NULL) {
		char *chan;

		/* still nothing? maybe user just left the # in front of
		   channel, try again with it.. */
		chan = g_strdup_printf("#%s", name);
		item = window == NULL ? NULL :
			window_item_find(window->active_server, chan);
		if (item == NULL) item = window_item_find(NULL, chan);
		g_free(chan);
	}

	if (item == NULL)
		return 0;

	return MODULE_DATA(item);
}
コード例 #2
0
ファイル: fe-log.c プロジェクト: ailin-nemui/irssi
static void autolog_open_check(TEXT_DEST_REC *dest)
{
	const char *deftarget;
	SERVER_REC *server = dest->server;
	const char *server_tag = dest->server_tag;
	const char *target = dest->target;
	int level = dest->level;

	/* FIXME: kind of a kludge, but we don't want to reopen logs when
	   we're parting the channel with /WINDOW CLOSE.. Maybe a small
	   timeout would be nice instead of immediately closing the log file
	   after "window item destroyed" */
	if (level == MSGLEVEL_PARTS ||
	    (autolog_level & level) == 0 || target == NULL || *target == '\0')
		return;

	deftarget = server ? server->nick : "unknown";

	/* log only channels that have been saved to the config */
	if (settings_get_bool("autolog_only_saved_channels") && IS_CHANNEL(window_item_find(server, target))
		&& channel_setup_find(target, server_tag) == NULL)
		return;

	if (autolog_ignore_targets != NULL &&
	    strarray_find_dest(autolog_ignore_targets, dest))
		return;

	if (target != NULL)
		autolog_open(server, server_tag, g_strcmp0(target, "*") ? target : deftarget);
}
コード例 #3
0
ファイル: fe-channels.c プロジェクト: svn2github/irssi
static void signal_channel_created(CHANNEL_REC *channel, gpointer automatic)
{
	if (window_item_find(channel->server, channel->name) == NULL) {
		window_item_create((WI_ITEM_REC *) channel,
				   GPOINTER_TO_INT(automatic));
	}
}
コード例 #4
0
ファイル: window-activity.c プロジェクト: ahf/irssi-old
static void sig_hilight_text(TEXT_DEST_REC *dest, const char *msg)
{
	WI_ITEM_REC *item;
	int data_level;

	if (dest->window == active_win || (dest->level & hide_level))
		return;

	if (dest->level & hilight_level) {
		data_level = DATA_LEVEL_HILIGHT+dest->hilight_priority;
	} else {
		data_level = (dest->level & msg_level) ?
			DATA_LEVEL_MSG : DATA_LEVEL_TEXT;
	}

	if (hide_targets != NULL && (dest->level & MSGLEVEL_HILIGHT) == 0 && dest->target != NULL) {
		/* check for both target and tag/target */
		if (strarray_find_dest(hide_targets, dest))
			return;
	}

	if (dest->target != NULL) {
		item = window_item_find(dest->server, dest->target);
		if (item != NULL) {
			window_item_activity(item, data_level,
					     dest->hilight_color);
		}
	}
	window_activity(dest->window, data_level, dest->hilight_color);
}
コード例 #5
0
ファイル: fe-windows.c プロジェクト: svn2github/irssi
WINDOW_REC *window_find_closest(void *server, const char *name, int level)
{
	WINDOW_REC *window,*namewindow=NULL;
	WI_ITEM_REC *item;

	/* match by name */
	item = name == NULL ? NULL :
		window_item_find(server, name);
	if (item != NULL) {
		namewindow = window_item_window(item);
		if (namewindow != NULL && ((namewindow->level & level) != 0 ||
		    !settings_get_bool("window_check_level_first")))
		  return namewindow;
	}

	/* match by level */
	if (level != MSGLEVEL_HILIGHT)
		level &= ~(MSGLEVEL_HILIGHT | MSGLEVEL_NOHILIGHT);
	window = window_find_level(server, level);
	if (window != NULL) return window;

	/* match by level - ignore server */
	window = window_find_level(NULL, level);
	if (window != NULL) return window;

	/* still return item's window if we didnt find anything */
	if (namewindow != NULL) return namewindow;

	/* fallback to active */
	return active_win;
}
コード例 #6
0
ファイル: fe-exec.c プロジェクト: svn2github/irssi
static void sig_exec_input(PROCESS_REC *rec, const char *text)
{
	WI_ITEM_REC *item;
	SERVER_REC *server;
        char *str;

	if (rec->quiet)
		return;

        item = NULL;
	server = NULL;

	if (rec->target != NULL) {
		item = window_item_find(NULL, rec->target);
		server = item != NULL ? item->server :
			active_win->active_server;

		str = g_strconcat(rec->target_nick ? "-nick " :
				  rec->target_channel ? "-channel " : "",
				  rec->target, " ", text, NULL);
		signal_emit(rec->notice ? "command notice" : "command msg",
			    3, str, server, item);
                g_free(str);
	} else if (rec->target_item != NULL) {
		printtext(NULL, rec->target_item->visible_name,
			  rec->level, "%s", text);
	} else {
		printtext_window(rec->target_win, rec->level, "%s", text);
	}
}
コード例 #7
0
ファイル: fe-exec.c プロジェクト: svn2github/irssi
static void sig_exec_input(PROCESS_REC *rec, const char *text)
{
	WI_ITEM_REC *item;
	SERVER_REC *server;
        char *str;

        item = NULL;
	server = NULL;

	if (rec->target != NULL) {
		item = window_item_find(NULL, rec->target);
		server = item != NULL ? item->server :
			active_win->active_server;

                str = g_strconcat(rec->target, " ", text, NULL);
		signal_emit(rec->notice ? "command notice" : "command msg",
			    3, str, server, item);
                g_free(str);
	} else if (rec->target_item != NULL) {
		printtext(NULL, rec->target_item->name, MSGLEVEL_CLIENTCRAP,
			  "%s", text);
	} else {
		printtext_window(rec->target_win, MSGLEVEL_CLIENTCRAP,
				 "%s", text);
	}
}
コード例 #8
0
ファイル: fe-queries.c プロジェクト: svn2github/irssi
static void signal_query_created(QUERY_REC *query, gpointer automatic)
{
	g_return_if_fail(IS_QUERY(query));

	if (window_item_find(query->server, query->name) != NULL)
		return;

	window_item_create((WI_ITEM_REC *) query, GPOINTER_TO_INT(automatic));
	printformat(query->server, query->name, MSGLEVEL_CLIENTNOTICE,
		    TXT_QUERY_STARTED, query->name);
}
コード例 #9
0
ファイル: fe-windows.c プロジェクト: GPF/irssi
WINDOW_REC *window_find_item(SERVER_REC *server, const char *name)
{
	WINDOW_REC *rec;
	WI_ITEM_REC *item;

	g_return_val_if_fail(name != NULL, NULL);

	rec = window_find_name(name);
	if (rec != NULL) return rec;

	item = server == NULL ? NULL :
		window_item_find(server, name);
	if (item == NULL) {
		/* not found from the active server - any server? */
		item = window_item_find(NULL, name);
	}

	if (item == NULL)
		return NULL;

	return window_item_window(item);
}
コード例 #10
0
static PyObject *PyServer_window_item_find(PyServer *self, PyObject *args, PyObject *kwds)
{
    static char *kwlist[] = {"name", NULL};
    char *name = "";

    RET_NULL_IF_INVALID(self->data);

    if (!PyArg_ParseTupleAndKeywords(args, kwds, "s", kwlist, 
           &name))
        return NULL;

    return py_irssi_chat_new(window_item_find(self->data, name), 1);
}
コード例 #11
0
ファイル: window-commands.c プロジェクト: svn2github/irssi
/* SYNTAX: WINDOW ITEM MOVE <number>|<name> */
static void cmd_window_item_move(const char *data, SERVER_REC *server,
                                 WI_ITEM_REC *item)
{
        WINDOW_REC *window;

        if (is_numeric(data, '\0')) {
                /* move current window item to specified window */
                window = window_find_refnum(atoi(data));
        } else {
                /* move specified window item to current window */
                item = window_item_find(server, data);
                window = active_win;
        }
        if (window != NULL && item != NULL)
                window_item_set_active(window, item);
}
コード例 #12
0
ファイル: fe-windows.c プロジェクト: GPF/irssi
WINDOW_REC *window_find_closest(void *server, const char *name, int level)
{
	WINDOW_REC *window,*namewindow=NULL;
	WI_ITEM_REC *item;
	int i;

	/* match by name */
	item = name == NULL ? NULL :
		window_item_find(server, name);
	if (item != NULL) {
		namewindow = window_item_window(item);
		if (namewindow != NULL &&
		    ((namewindow->level & level) != 0 ||
		     !settings_get_bool("window_check_level_first"))) {
			/* match, but if multiple windows have the same level
			   we could be choosing a bad one here, eg.
			   name=nick1 would get nick2's query instead of
			   generic msgs window.

	                   And check for prefixed !channel name --Borys  */
			if (g_ascii_strcasecmp(name, item->visible_name) == 0 ||
			    g_ascii_strcasecmp(name, (char *) window_item_get_target((WI_ITEM_REC *) item)) == 0)
				return namewindow;
		}
	}

	/* prefer windows without items */
	for (i = 0; i < 2; i++) {
		/* match by level */
		if (level != MSGLEVEL_HILIGHT)
			level &= ~(MSGLEVEL_HILIGHT | MSGLEVEL_NOHILIGHT);
		window = window_find_level(server, level);
		if (window != NULL && (i == 1 || window->items == NULL))
			return window;

		/* match by level - ignore server */
		window = window_find_level(NULL, level);
		if (window != NULL && (i == 1 || window->items == NULL))
			return window;
	}

	/* still return item's window if we didnt find anything */
	if (namewindow != NULL) return namewindow;

	/* fallback to active */
	return active_win;
}
コード例 #13
0
static void event_privmsg(const char *data, IRC_SERVER_REC *server, const char *nick, const char *addr)
{
	WINDOW_REC *window;
	WI_ITEM_REC *item;
	char *params, *target, *msg;
	int level;

	g_return_if_fail(data != NULL);

	params = event_get_params(data, 2 | PARAM_FLAG_GETREST, &target, &msg);

	/* get window and window item */
	level = ischannel(*target) ? MSGLEVEL_PUBLIC : MSGLEVEL_MSGS;
	item = window_item_find(server, ischannel(*target) ? target : nick);
	window = item == NULL ?
		window_find_closest(server, target, GPOINTER_TO_INT(level)) :
		window_item_window(item);

	/* check that msg wasn't send to current window and
	   that it didn't get ignored */
        if (window != active_win && !ignore_check(server, nick, addr, target, msg, level)) {
                /* hilight */
		if (item != NULL) item->last_color = irc_hilight_last_color();
		level = (item != NULL && item->last_color > 0) ||
			!ischannel(*target) || irc_nick_match(server->nick, msg) ?
			NEWDATA_HILIGHT : NEWDATA_MSG;
		if (item != NULL && item->new_data < level) {
			item->new_data = level;
			signal_emit("window item hilight", 1, item);
		} else {
			int oldlevel = window->new_data;

			if (window->new_data < level) {
				window->new_data = level;
				window->last_color = irc_hilight_last_color();
				signal_emit("window hilight", 2, window, GINT_TO_POINTER(oldlevel));
			}
			signal_emit("window activity", 2, window, GINT_TO_POINTER(oldlevel));
		}
	}

	g_free(params);
}
コード例 #14
0
ファイル: window-activity.c プロジェクト: FabrizioFabbe/silc
static void sig_hilight_text(TEXT_DEST_REC *dest, const char *msg)
{
	WI_ITEM_REC *item;
        char *tagtarget;
	int data_level;

	if (dest->window == active_win || (dest->level & hide_level))
		return;

	if (dest->level & hilight_level) {
		data_level = DATA_LEVEL_HILIGHT+dest->hilight_priority;
	} else {
		data_level = (dest->level & msg_level) ?
			DATA_LEVEL_MSG : DATA_LEVEL_TEXT;
	}

	if ((dest->level & MSGLEVEL_HILIGHT) == 0 && dest->target != NULL) {
		/* check for both target and tag/target */
		if (hide_target_activity(data_level, dest->target))
			return;

		tagtarget = dest->server_tag == NULL ? NULL :
			g_strdup_printf("%s/%s", dest->server_tag,
					dest->target);
		if (hide_target_activity(data_level, tagtarget)) {
			g_free(tagtarget);
			return;
		}
		g_free(tagtarget);
	}

	if (dest->target != NULL) {
		item = window_item_find(dest->server, dest->target);
		if (item != NULL) {
			window_item_activity(item, data_level,
					     dest->hilight_color);
		}
	}
	window_activity(dest->window, data_level, dest->hilight_color);
}
コード例 #15
0
ファイル: window-commands.c プロジェクト: Brijen/MacIrssi
/* SYNTAX: WINDOW ITEM MOVE <number>|<name> */
static void cmd_window_item_move(const char *data, SERVER_REC *server,
                                 WI_ITEM_REC *item)
{
	WINDOW_REC *window;
	void *free_arg;
	char *target;

	if (!cmd_get_params(data, &free_arg, 1, &target))
		return;

        if (is_numeric(target, '\0')) {
                /* move current window item to specified window */
                window = window_find_refnum(atoi(target));
        } else {
                /* move specified window item to current window */
                item = window_item_find(server, target);
                window = active_win;
        }
        if (window != NULL && item != NULL)
		window_item_set_active(window, item);

	cmd_params_free(free_arg);
}
コード例 #16
0
ファイル: windows.c プロジェクト: svn2github/irssi
WINDOW_REC *window_find_closest(void *server, const char *name, int level)
{
	WINDOW_REC *window;
	WI_ITEM_REC *item;

	/* match by name */
	item = name == NULL ? NULL :
		window_item_find(server, name);
	if (item != NULL)
                return window_item_window(item);

	/* match by level */
	if (level != MSGLEVEL_HILIGHT)
		level &= ~(MSGLEVEL_HILIGHT | MSGLEVEL_NOHILIGHT);
	window = window_find_level(server, level);
	if (window != NULL) return window;

	/* match by level - ignore server */
	window = window_find_level(NULL, level);
	if (window != NULL) return window;

	/* fallback to active */
	return active_win;
}