Пример #1
0
void query_init(QUERY_REC *query, int automatic)
{
	g_return_if_fail(query != NULL);
	g_return_if_fail(query->name != NULL);

	queries = g_slist_append(queries, query);

        MODULE_DATA_INIT(query);
	query->type = module_get_uniq_id_str("WINDOW ITEM TYPE", "QUERY");
        query->destroy = (void (*) (WI_ITEM_REC *)) query_destroy;
	query->get_target = query_get_target;
	query->createtime = time(NULL);
	query->last_unread_msg = time(NULL);
	query->visible_name = g_strdup(query->name);

	if (query->server_tag != NULL) {
		query->server = server_find_tag(query->server_tag);
		if (query->server != NULL) {
			query->server->queries =
				g_slist_append(query->server->queries, query);
		}
	}

	signal_emit("query created", 2, query, GINT_TO_POINTER(automatic));
}
Пример #2
0
/* initializes server record but doesn't start connecting */
void server_connect_init(SERVER_REC *server)
{
	const char *str;

	g_return_if_fail(server != NULL);

	MODULE_DATA_INIT(server);
	server->type = module_get_uniq_id("SERVER", 0);
	server_ref(server);

	server->nick = g_strdup(server->connrec->nick);
	if (server->connrec->username == NULL || *server->connrec->username == '\0') {
		g_free_not_null(server->connrec->username);

		str = g_get_user_name();
		if (*str == '\0') str = "unknown";
		server->connrec->username = g_strdup(str);
	}
	if (server->connrec->realname == NULL || *server->connrec->realname == '\0') {
		g_free_not_null(server->connrec->realname);

		str = g_get_real_name();
		if (*str == '\0') str = server->connrec->username;
		server->connrec->realname = g_strdup(str);
	}

	server->tag = server_create_tag(server->connrec);
	server->connect_tag = -1;
}
Пример #3
0
void channel_init(CHANNEL_REC *channel, SERVER_REC *server, const char *name,
		  const char *visible_name, int automatic)
{
	g_return_if_fail(channel != NULL);
	g_return_if_fail(name != NULL);
	g_return_if_fail(server != NULL);

	if (visible_name == NULL)
		visible_name = name;

        MODULE_DATA_INIT(channel);
	channel->type = module_get_uniq_id_str("WINDOW ITEM TYPE", "CHANNEL");
        channel->destroy = (void (*) (WI_ITEM_REC *)) channel_destroy;
	channel->get_target = channel_get_target;
        channel->get_join_data = get_join_data;

	channel->chat_type = server->chat_type;
	channel->server = server;
	channel->name = g_strdup(name);
	channel->visible_name = g_strdup(visible_name);
	channel->mode = g_strdup("");
	channel->createtime = time(NULL);

	channels = g_slist_append(channels, channel);
	server->channels = g_slist_append(server->channels, channel);

	signal_emit("channel created", 2, channel, GINT_TO_POINTER(automatic));
}
Пример #4
0
/* Initialize DCC record */
void dcc_init_rec(DCC_REC *dcc, IRC_SERVER_REC *server, CHAT_DCC_REC *chat,
		  const char *nick, const char *arg)
{
	g_return_if_fail(dcc != NULL);
	g_return_if_fail(nick != NULL);
	g_return_if_fail(arg != NULL);

        MODULE_DATA_INIT(dcc);
	dcc->created = time(NULL);
	dcc->chat = chat;
	dcc->arg = g_strdup(arg);
	dcc->nick = g_strdup(nick);
	dcc->tagconn = dcc->tagread = dcc->tagwrite = -1;
	dcc->server = server;
	dcc->mynick = g_strdup(server != NULL ? server->nick :
			       chat != NULL ? chat->nick : "??");

	dcc->servertag = server != NULL ? g_strdup(server->tag) :
		(chat == NULL ? NULL : g_strdup(chat->servertag));

	dcc->pasv_id = -1; /* Not a passive DCC */

	dcc_conns = g_slist_append(dcc_conns, dcc);
	signal_emit("dcc created", 1, dcc);
}
Пример #5
0
void channel_init(CHANNEL_REC *channel, int automatic)
{
	g_return_if_fail(channel != NULL);
	g_return_if_fail(channel->name != NULL);

	channels = g_slist_append(channels, channel);
	if (channel->server != NULL) {
		channel->server->channels =
			g_slist_append(channel->server->channels, channel);
	}

        MODULE_DATA_INIT(channel);
	channel->type = module_get_uniq_id_str("WINDOW ITEM TYPE", "CHANNEL");
        channel->mode = g_strdup("");
	channel->createtime = time(NULL);

	signal_emit("channel created", 2, channel, GINT_TO_POINTER(automatic));
}
Пример #6
0
/* Initialize DCC record */
static void dcc_init_server_rec(SERVER_DCC_REC *dcc, IRC_SERVER_REC *server,
				const char *mynick, const char *servertag)
{
	g_return_if_fail(dcc != NULL);
	g_return_if_fail(IS_DCC_SERVER(dcc));

	MODULE_DATA_INIT(dcc);
	dcc->created = time(NULL);
	dcc->chat = NULL;
	dcc->arg = NULL;
	dcc->nick = NULL;
	dcc->tagconn = dcc->tagread = dcc->tagwrite = -1;
	dcc->server = server;
	dcc->mynick = g_strdup(mynick);
	dcc->servertag = g_strdup(servertag);

	dcc_conns = g_slist_append(dcc_conns, dcc);
	signal_emit("dcc created", 1, dcc);
}
Пример #7
0
void query_init(QUERY_REC *query, int automatic)
{
	g_return_if_fail(query != NULL);
	g_return_if_fail(query->name != NULL);

	queries = g_slist_append(queries, query);

        MODULE_DATA_INIT(query);
	query->type = module_get_uniq_id_str("WINDOW ITEM TYPE", "QUERY");
	if (query->server_tag != NULL) {
		query->server = server_find_tag(query->server_tag);
		if (query->server != NULL) {
			query->server->queries =
				g_slist_append(query->server->queries, query);
		}
	}

	signal_emit("query created", 2, query, GINT_TO_POINTER(automatic));
}
Пример #8
0
QUERY_REC *query_create(IRC_SERVER_REC *server, const char *nick, int automatic)
{
	QUERY_REC *rec;

	g_return_val_if_fail(nick != NULL, NULL);

	rec = g_new0(QUERY_REC, 1);
	queries = g_slist_append(queries, rec);
	if (server != NULL) server->queries = g_slist_append(server->queries, rec);

        MODULE_DATA_INIT(rec);
	rec->type = module_get_uniq_id("IRC", WI_IRC_QUERY);
	rec->nick = g_strdup(nick);
	if (server != NULL) {
		rec->server_tag = g_strdup(server->tag);
		rec->server = server;
	}

	signal_emit("query created", 2, rec, GINT_TO_POINTER(automatic));
	return rec;
}
Пример #9
0
static EXEC_WI_REC *exec_wi_create(WINDOW_REC *window, PROCESS_REC *rec)
{
	EXEC_WI_REC *item;

        g_return_val_if_fail(window != NULL, NULL);
        g_return_val_if_fail(rec != NULL, NULL);

	item = g_new0(EXEC_WI_REC, 1);
	item->type = module_get_uniq_id_str("WINDOW ITEM TYPE", "EXEC");
        item->destroy = (void (*) (WI_ITEM_REC *)) exec_wi_destroy;
	item->get_target = exec_get_target;
	item->visible_name = rec->name != NULL ? g_strdup(rec->name) :
		g_strdup_printf("%%%d", rec->id);

	item->createtime = time(NULL);
        item->process = rec;

	MODULE_DATA_INIT(item);
	window_item_add(window, (WI_ITEM_REC *) item, FALSE);
        return item;
}