Ejemplo n.º 1
0
void session_deinit(void)
{
	g_free_not_null(irssi_binary);

        command_unbind("upgrade", (SIGNAL_FUNC) cmd_upgrade);

	signal_remove("session save", (SIGNAL_FUNC) sig_session_save);
	signal_remove("session restore", (SIGNAL_FUNC) sig_session_restore);
	signal_remove("session save server", (SIGNAL_FUNC) session_save_server_channels);
	signal_remove("session restore server", (SIGNAL_FUNC) session_restore_server_channels);
	signal_remove("session save channel", (SIGNAL_FUNC) session_save_channel_nicks);
	signal_remove("session restore channel", (SIGNAL_FUNC) session_restore_channel_nicks);
	signal_remove("irssi init finished", (SIGNAL_FUNC) sig_init_finished);
}
Ejemplo n.º 2
0
void irc_expandos_deinit(void)
{
	g_free_not_null(last_join);

	expando_destroy(":", expando_lastjoin);
	expando_destroy("H", expando_server_numeric);
	expando_destroy("S", expando_servername);
	expando_destroy("X", expando_userhost);
	expando_destroy("x", expando_hostname);
	expando_destroy("usermode", expando_usermode);
	expando_destroy("cumode", expando_cumode);

	signal_remove("event join", (SIGNAL_FUNC) event_join);
}
Ejemplo n.º 3
0
void window_set_history(WINDOW_REC *window, const char *name)
{
	char *oldname;
	oldname = window->history_name;

	if (name == NULL || *name == '\0')
		window->history_name = NULL;
	else
		window->history_name = g_strdup(name);

	signal_emit("window history changed", 1, window, oldname);

	g_free_not_null(oldname);
}
Ejemplo n.º 4
0
/* Destroy DCC record */
void dcc_destroy(DCC_REC *dcc)
{
	g_return_if_fail(dcc != NULL);
	if (dcc->destroyed) return;

	dcc_conns = g_slist_remove(dcc_conns, dcc);

	dcc->destroyed = TRUE;
	signal_emit("dcc destroyed", 1, dcc);

	if (dcc->handle != NULL) net_disconnect(dcc->handle);
	if (dcc->tagconn != -1) g_source_remove(dcc->tagconn);
	if (dcc->tagread != -1) g_source_remove(dcc->tagread);
	if (dcc->tagwrite != -1) g_source_remove(dcc->tagwrite);

        MODULE_DATA_DEINIT(dcc);
	g_free_not_null(dcc->servertag);
	g_free_not_null(dcc->target);
	g_free(dcc->mynick);
	g_free(dcc->nick);
	g_free(dcc->arg);
	g_free(dcc);
}
Ejemplo n.º 5
0
static void rejoin_destroy(IRC_SERVER_REC *server, REJOIN_REC *rec)
{
	g_return_if_fail(IS_IRC_SERVER(server));
	g_return_if_fail(rec != NULL);

	server->rejoin_channels =
		g_slist_remove(server->rejoin_channels, rec);

	signal_emit("channel rejoin remove", 2, server, rec);

	g_free(rec->channel);
	g_free_not_null(rec->key);
	g_free(rec);
}
Ejemplo n.º 6
0
static void key_configure_destroy(KEY_REC *rec)
{
	g_return_if_fail(rec != NULL);

	rec->info->keys = g_slist_remove(rec->info->keys, rec);
	g_hash_table_remove(keys, rec->key);

	if (!key_config_frozen)
                key_states_rescan();

	g_free_not_null(rec->data);
	g_free(rec->key);
	g_free(rec);
}
Ejemplo n.º 7
0
static void event_whois(IRC_SERVER_REC *server, const char *data)
{
        char *params, *nick, *user, *host, *realname;
	NOTIFY_NICK_REC *nickrec;
	NOTIFYLIST_REC *notify;

	g_return_if_fail(data != NULL);
	g_return_if_fail(server != NULL);

	params = event_get_params(data, 6, NULL, &nick, &user, &host, NULL, &realname);

	notify = notifylist_find(nick, server->connrec->chatnet);
	if (notify != NULL && !mask_match(SERVER(server), notify->mask, nick, user, host)) {
		/* user or host didn't match */
		g_free(params);
		return;
	}

	nickrec = notify_nick_find(server, nick);
	if (nickrec != NULL) {
                g_free_not_null(last_notify_nick);
		last_notify_nick = g_strdup(nick);

		g_free_not_null(nickrec->user);
		g_free_not_null(nickrec->host);
		g_free_not_null(nickrec->realname);
		g_free_and_null(nickrec->awaymsg);
		nickrec->user = g_strdup(user);
		nickrec->host = g_strdup(host);
		nickrec->realname = g_strdup(realname);

		nickrec->away = FALSE;
		nickrec->host_ok = TRUE;
		nickrec->idle_ok = TRUE;
	}
	g_free(params);
}
Ejemplo n.º 8
0
void gui_readline_deinit(void)
{
	g_free_not_null(cutbuffer);
	g_source_remove(readtag);

	key_unbind("backward_character", (SIGNAL_FUNC) key_backward_character);
	key_unbind("forward_character", (SIGNAL_FUNC) key_forward_character);
 	key_unbind("backward_word", (SIGNAL_FUNC) key_backward_word);
	key_unbind("forward_word", (SIGNAL_FUNC) key_forward_word);
	key_unbind("beginning_of_line", (SIGNAL_FUNC) key_beginning_of_line);
	key_unbind("end_of_line", (SIGNAL_FUNC) key_end_of_line);

	key_unbind("backward_history", (SIGNAL_FUNC) key_backward_history);
	key_unbind("forward_history", (SIGNAL_FUNC) key_forward_history);

	key_unbind("backspace", (SIGNAL_FUNC) key_backspace);
	key_unbind("delete_character", (SIGNAL_FUNC) key_delete_character);
	key_unbind("delete_next_word", (SIGNAL_FUNC) key_delete_next_word);
	key_unbind("delete_previous_word", (SIGNAL_FUNC) key_delete_previous_word);
	key_unbind("delete_to_previous_space", (SIGNAL_FUNC) key_delete_to_previous_space);
	key_unbind("erase_line", (SIGNAL_FUNC) key_erase_line);
	key_unbind("erase_to_beg_of_line", (SIGNAL_FUNC) key_erase_to_beg_of_line);
	key_unbind("erase_to_end_of_line", (SIGNAL_FUNC) key_erase_to_end_of_line);
	key_unbind("yank_from_cutbuffer", (SIGNAL_FUNC) key_yank_from_cutbuffer);
	key_unbind("transpose_characters", (SIGNAL_FUNC) key_transpose_characters);

	key_unbind("word_completion", (SIGNAL_FUNC) key_word_completion);
	key_unbind("check_replaces", (SIGNAL_FUNC) key_check_replaces);

	key_unbind("previous_window", (SIGNAL_FUNC) key_previous_window);
	key_unbind("next_window", (SIGNAL_FUNC) key_next_window);
	key_unbind("upper_window", (SIGNAL_FUNC) key_upper_window);
	key_unbind("lower_window", (SIGNAL_FUNC) key_lower_window);
	key_unbind("active_window", (SIGNAL_FUNC) key_active_window);
	key_unbind("next_window_item", (SIGNAL_FUNC) key_next_window_item);
	key_unbind("previous_window_item", (SIGNAL_FUNC) key_previous_window_item);

	key_unbind("refresh_screen", (SIGNAL_FUNC) irssi_redraw);
	key_unbind("scroll_backward", (SIGNAL_FUNC) key_scroll_backward);
	key_unbind("scroll_forward", (SIGNAL_FUNC) key_scroll_forward);
	key_unbind("scroll_start", (SIGNAL_FUNC) key_scroll_start);
	key_unbind("scroll_end", (SIGNAL_FUNC) key_scroll_end);

	key_unbind("special_char", (SIGNAL_FUNC) key_addchar);
	key_unbind("change_window", (SIGNAL_FUNC) key_change_window);

	signal_remove("window changed automatic", (SIGNAL_FUNC) sig_window_auto_changed);
	signal_remove("gui entry redirect", (SIGNAL_FUNC) sig_gui_entry_redirect);
}
Ejemplo n.º 9
0
void log_write_rec(LOG_REC *log, const char *str, int level)
{
        char *colorstr;
	struct tm *tm;
	time_t now;
	int hour, day;

	g_return_if_fail(log != NULL);
	g_return_if_fail(str != NULL);

	if (log->handle == -1)
		return;

	now = time(NULL);
	tm = localtime(&now);
	hour = tm->tm_hour;
	day = tm->tm_mday;

	tm = localtime(&log->last);
	day -= tm->tm_mday; /* tm breaks in log_rotate_check() .. */
	if (tm->tm_hour != hour) {
		/* hour changed, check if we need to rotate log file */
                log_rotate_check(log);
	}

	if (day != 0) {
		/* day changed */
		log_write_timestamp(log->handle,
				    settings_get_str("log_day_changed"),
				    "\n", now);
	}

	log->last = now;

	if (log->colorizer == NULL)
		colorstr = NULL;
        else
                str = colorstr = log->colorizer(str);

        if ((level & MSGLEVEL_LASTLOG) == 0)
		log_write_timestamp(log->handle, log_timestamp, str, now);
	else
		write_buffer(log->handle, str, strlen(str));
	write_buffer(log->handle, "\n", 1);

	signal_emit("log written", 2, log, str);

        g_free_not_null(colorstr);
}
Ejemplo n.º 10
0
static void server_eventtable_destroy(char *key, GSList *value)
{
	GSList *tmp;

	g_free(key);

	for (tmp = value; tmp != NULL; tmp = tmp->next) {
		REDIRECT_REC *rec = tmp->data;

		g_free_not_null(rec->arg);
		g_free(rec->name);
		g_free(rec);
	}
	g_slist_free(value);
}
Ejemplo n.º 11
0
void query_destroy(QUERY_REC *query)
{
	g_return_if_fail(IS_QUERY(query));

        if (query->destroying) return;
	query->destroying = TRUE;

	queries = g_slist_remove(queries, query);
	if (query->server != NULL) {
		query->server->queries =
			g_slist_remove(query->server->queries, query);
	}
	signal_emit("query destroyed", 1, query);

        MODULE_DATA_DEINIT(query);
	g_free_not_null(query->hilight_color);
        g_free_not_null(query->server_tag);
        g_free_not_null(query->address);
	g_free(query->visible_name);
	g_free(query->name);

        query->type = 0;
	g_free(query);
}
Ejemplo n.º 12
0
static void event_away(IRC_SERVER_REC *server, const char *data)
{
    char *params, *nick, *awaymsg, *recoded;

    g_return_if_fail(data != NULL);

    params = event_get_params(data, 3, NULL, &nick, &awaymsg);
    recoded = recode_in(SERVER(server), awaymsg, nick);
    if (!settings_get_bool("show_away_once") ||
            last_away_nick == NULL || g_strcasecmp(last_away_nick, nick) != 0 ||
            last_away_msg == NULL || g_strcasecmp(last_away_msg, awaymsg) != 0) {
        /* don't show the same away message
           from the same nick all the time */
        g_free_not_null(last_away_nick);
        g_free_not_null(last_away_msg);
        last_away_nick = g_strdup(nick);
        last_away_msg = g_strdup(awaymsg);

        printformat(server, nick, MSGLEVEL_CRAP,
                    IRCTXT_NICK_AWAY, nick, recoded);
    }
    g_free(params);
    g_free(recoded);
}
Ejemplo n.º 13
0
/* Parse user mode string */
static void parse_user_mode(IRC_SERVER_REC *server, const char *modestr)
{
	char *newmode, *oldmode;

	g_return_if_fail(IS_IRC_SERVER(server));
	g_return_if_fail(modestr != NULL);

	newmode = modes_join(server->usermode, modestr, FALSE);
	oldmode = server->usermode;
	server->usermode = newmode;
	server->server_operator = (strchr(newmode, 'o') != NULL);

	signal_emit("user mode changed", 2, server, oldmode);
	g_free_not_null(oldmode);
}
Ejemplo n.º 14
0
void window_item_activity(WI_ITEM_REC *item, int data_level,
			  const char *hilight_color)
{
	int old_data_level;

	old_data_level = item->data_level;
	if (data_level == 0 || item->data_level < data_level) {
		item->data_level = data_level;
                g_free_not_null(item->hilight_color);
		item->hilight_color = g_strdup(hilight_color);
		signal_emit("window item hilight", 1, item);
	}

	signal_emit("window item activity", 2, item,
		    GINT_TO_POINTER(old_data_level));
}
Ejemplo n.º 15
0
/* redraw activity, FIXME: if we didn't get enough size, this gets buggy.
   At least "Det:" isn't printed properly. also we should rearrange the
   act list so that the highest priority items comes first. */
static void item_act(SBAR_ITEM_REC *item, int get_size_only)
{
	char *actlist;

	actlist = get_activity_list(item->bar->parent_window, TRUE, TRUE);
	if (actlist == NULL) {
		if (get_size_only)
			item->min_size = item->max_size = 0;
		return;
	}

	statusbar_item_default_handler(item, get_size_only,
				       NULL, actlist, FALSE);

	g_free_not_null(actlist);
}
Ejemplo n.º 16
0
static void botnet_destroy(BOTNET_REC *botnet)
{
	botnets = g_slist_remove(botnets, botnet);

        while (botnet->uplinks != NULL)
		bot_uplink_destroy(botnet->uplinks->data);
        while (botnet->downlinks != NULL)
		bot_downlink_destroy(botnet->downlinks->data);

	botnet_disconnect(botnet);

	g_free_not_null(botnet->addr);
	g_free(botnet->name);
	g_free(botnet->nick);
	g_free(botnet);
}
Ejemplo n.º 17
0
void window_activity(WINDOW_REC *window, int data_level,
		     const char *hilight_color)
{
	int old_data_level;

	old_data_level = window->data_level;
	if (data_level == 0 || window->data_level < data_level) {
		window->data_level = data_level;
                g_free_not_null(window->hilight_color);
		window->hilight_color = g_strdup(hilight_color);
		signal_emit("window hilight", 1, window);
	}

	signal_emit("window activity", 2, window,
		    GINT_TO_POINTER(old_data_level));
}
Ejemplo n.º 18
0
void gui_entry_set_prompt(const char *str)
{
	if (str != NULL) {
		if (permanent_prompt) return;

		g_free_not_null(prompt);
		prompt = g_strdup(str);
		promptlen = format_get_length(prompt);
	}

        if (prompt != NULL)
		gui_printtext(0, LINES-1, prompt);

	entry_screenpos();
	entry_update();
}
Ejemplo n.º 19
0
void gui_entry_set_prompt(const char *str)
{
	if (str != NULL) {
		if (permanent_prompt) return;

		g_free_not_null(prompt);
		prompt = g_strdup(str);
		promptlen = strlen(prompt);
	}

	set_color(stdscr, 0);
	mvaddstr(LINES-1, 0, prompt);

	entry_screenpos();
	entry_update();
}
Ejemplo n.º 20
0
static void log_destroy(LOG_REC *log)
{
	g_return_if_fail(log != NULL);

	if (log->handle != -1)
		log_stop_logging(log);

	logs = g_slist_remove(logs, log);
	signal_emit("log remove", 1, log);

	while (log->items != NULL)
		log_item_destroy(log, log->items->data);
	g_free(log->fname);
	g_free_not_null(log->real_fname);
	g_free(log);
}
Ejemplo n.º 21
0
/* callback: net_connect() finished for DCC GET */
static void sig_dccget_connected(DCC_REC *dcc)
{
	struct stat statbuf;
	char *fname;

	g_return_if_fail(dcc != NULL);

	if (net_geterror(dcc->handle) != 0) {
		/* error connecting */
		signal_emit("dcc error connect", 1, dcc);
		dcc_destroy(dcc);
		return;
	}

	g_source_remove(dcc->tagconn);

	g_free_not_null(dcc->file);
	dcc->file = dcc_get_download_path(dcc->arg);

	/* if some plugin wants to change the file name/path here.. */
	signal_emit("dcc get receive", 1, dcc);

	if (stat(dcc->file, &statbuf) == 0 && dcc->get_type == DCC_GET_RENAME) {
		/* file exists, rename.. */
		fname = get_rename_file(dcc->file);
		g_free(dcc->file);
		dcc->file = fname;
	}

	if (dcc->get_type != DCC_GET_RESUME) {
		dcc->fhandle = open(dcc->file, O_WRONLY | O_TRUNC | O_CREAT, dcc_file_create_mode);
		if (dcc->fhandle == -1) {
			signal_emit("dcc error file create", 2, dcc, dcc->file);
			dcc_destroy(dcc);
			return;
		}
	}

	dcc->databufsize = settings_get_int("dcc_block_size");
        if (dcc->databufsize <= 0) dcc->databufsize = 2048;
	dcc->databuf = g_malloc(dcc->databufsize);

	dcc->starttime = time(NULL);
	dcc->tagread = g_input_add(dcc->handle, G_INPUT_READ,
				   (GInputFunction) sig_dccget_receive, dcc);
	signal_emit("dcc connected", 1, dcc);
}
Ejemplo n.º 22
0
/* SYNTAX: WINDOW THEME <name> */
static void cmd_window_theme(const char *data)
{
	THEME_REC *theme;

	g_free_not_null(active_win->theme_name);
	active_win->theme_name = g_strdup(data);

	active_win->theme = theme = theme_load(data);
	if (theme != NULL) {
		printformat_window(active_win, MSGLEVEL_CLIENTNOTICE,
				   TXT_WINDOW_THEME_CHANGED,
				   theme->name, theme->path);
	} else {
		printformat_window(active_win, MSGLEVEL_CLIENTNOTICE,
				   TXT_THEME_NOT_FOUND, data);
	}
}
Ejemplo n.º 23
0
/* save channel specific user record */
static void botuser_save_chan(const char *key, USER_CHAN_REC *rec, CONFIG_NODE *node)
{
	CONFIG_NODE *noderec;
	char *str;

	if (rec->flags == 0) {
                /* no flags in this channel - no need to save to config */
		config_node_set_str(userconfig, node, rec->channel, NULL);
		return;
	}

	noderec = config_node_section(node, rec->channel, NODE_TYPE_BLOCK);

	str = botuser_value2flags(rec->flags);
	config_node_set_str(userconfig, noderec, "flags", str);
	g_free_not_null(str);
}
Ejemplo n.º 24
0
static void sig_message_private(SERVER_REC *server, const char *msg,
				const char *nick, const char *address)
{
	QUERY_REC *query;
        char *freemsg = NULL;

	query = query_find(server, nick);

	if (settings_get_bool("emphasis"))
		msg = freemsg = expand_emphasis((WI_ITEM_REC *) query, msg);

	printformat(server, nick, MSGLEVEL_MSGS,
		    query == NULL ? TXT_MSG_PRIVATE :
		    TXT_MSG_PRIVATE_QUERY, nick, address, msg);

	g_free_not_null(freemsg);
}
Ejemplo n.º 25
0
static SERVER_REC *irc_connect_server(const char *data)
{
	SERVER_CONNECT_REC *conn;
	SERVER_REC *server;
	GHashTable *optlist;
	char *addr, *portstr, *password, *nick, *ircnet, *host;
	void *free_arg;

	g_return_val_if_fail(data != NULL, NULL);

	if (!cmd_get_params(data, &free_arg, 4 | PARAM_FLAG_OPTIONS,
			    "connect", &optlist, &addr, &portstr, &password, &nick))
		return NULL;
	if (*addr == '+') addr++;
	if (*addr == '\0') {
		signal_emit("error command", 1, GINT_TO_POINTER(CMDERR_NOT_ENOUGH_PARAMS));
		cmd_params_free(free_arg);
		return NULL;
	}

	if (strcmp(password, "-") == 0)
		*password = '******';

	/* connect to server */
	conn = server_create_conn(addr, atoi(portstr), password, nick);
        ircnet = g_hash_table_lookup(optlist, "ircnet");
	if (ircnet != NULL && *ircnet != '\0') {
		g_free_not_null(conn->chatnet);
		conn->chatnet = g_strdup(ircnet);
	}
        host = g_hash_table_lookup(optlist, "host");
	if (host != NULL && *host != '\0') {
		IPADDR ip;

		if (net_gethostbyname(host, &ip) == 0) {
			if (conn->own_ip == NULL)
				conn->own_ip = g_new(IPADDR, 1);
			memcpy(conn->own_ip, &ip, sizeof(IPADDR));
		}
	}
	server = server_connect(conn);

	cmd_params_free(free_arg);
	return server;
}
Ejemplo n.º 26
0
/* split the line to command and arguments */
static char *line_get_command(const char *line, char **args, int aliases)
{
	const char *ptr, *cmdargs;
	char *cmd, *checkcmd;

	g_return_val_if_fail(line != NULL, NULL);
	g_return_val_if_fail(args != NULL, NULL);

	cmd = checkcmd = NULL; *args = "";
	cmdargs = NULL; ptr = line;

	do {
		ptr = strchr(ptr, ' ');
		if (ptr == NULL) {
			checkcmd = g_strdup(line);
			cmdargs = "";
		} else {
			checkcmd = g_strndup(line, (int) (ptr-line));

			while (*ptr == ' ') ptr++;
			cmdargs = ptr;
		}

		if (aliases ? !alias_find(checkcmd) :
		    !command_find(checkcmd)) {
			/* not found, use the previous */
			g_free(checkcmd);
			break;
		}

		/* found, check if it has subcommands */
		g_free_not_null(cmd);
		if (!aliases)
			cmd = checkcmd;
		else {
                        cmd = g_strdup(alias_find(checkcmd));
			g_free(checkcmd);
		}
		*args = (char *) cmdargs;
	} while (ptr != NULL);

        if (cmd != NULL)
		ascii_strdown(cmd);
	return cmd;
}
Ejemplo n.º 27
0
void query_destroy(QUERY_REC *query)
{
	g_return_if_fail(query != NULL);

        if (query->destroying) return;
	query->destroying = TRUE;

	queries = g_slist_remove(queries, query);
	if (query->server != NULL)
		query->server->queries = g_slist_remove(query->server->queries, query);
	signal_emit("query destroyed", 1, query);

        MODULE_DATA_DEINIT(query);
        g_free_not_null(query->address);
	g_free(query->nick);
        g_free(query->server_tag);
	g_free(query);
}
Ejemplo n.º 28
0
static void event_server_info(IRC_SERVER_REC *server, const char *data)
{
	char *params, *ircd_version, *usermodes, *chanmodes;

	g_return_if_fail(server != NULL);

	params = event_get_params(data, 5, NULL, NULL, &ircd_version, &usermodes, &chanmodes);

	/* check if server understands I and e channel modes */
	if (strchr(chanmodes, 'I') && strchr(chanmodes, 'e'))
		server->emode_known = TRUE;

	/* save server version */
	g_free_not_null(server->version);
	server->version = g_strdup(ircd_version);

	g_free(params);
}
Ejemplo n.º 29
0
static void notifylist_print(NOTIFYLIST_REC *rec)
{
	char idle[MAX_INT_STRLEN], *ircnets;

	if (rec->idle_check_time <= 0)
		idle[0] = '\0';
	else
		g_snprintf(idle, sizeof(idle), "%d", rec->idle_check_time);

	ircnets = rec->ircnets == NULL ? NULL :
		g_strjoinv(",", rec->ircnets);

	printformat(NULL, NULL, MSGLEVEL_CLIENTCRAP, IRCTXT_NOTIFY_LIST,
		    rec->mask, ircnets != NULL ? ircnets : "",
		    rec->away_check ? "-away" : "", idle);

	g_free_not_null(ircnets);
}
Ejemplo n.º 30
0
Archivo: keyboard.c Proyecto: ahf/irssi
static void keyinfo_remove(KEYINFO_REC *info)
{
	g_return_if_fail(info != NULL);

	keyinfos = g_slist_remove(keyinfos, info);
	signal_emit("keyinfo destroyed", 1, info);

	/* destroy all keys */
        g_slist_foreach(info->keys, (GFunc) key_destroy, keys);
        g_slist_foreach(info->default_keys, (GFunc) key_destroy, default_keys);

	/* destroy key info */
	g_slist_free(info->keys);
	g_slist_free(info->default_keys);
	g_free_not_null(info->description);
	g_free(info->id);
	g_free(info);
}