static void
sig_save_status(XMPP_SERVER_CONNECT_REC *conn, XMPP_SERVER_REC *server)
{
	if (!IS_XMPP_SERVER_CONNECT(conn) || !IS_XMPP_SERVER(server)
	    || !server->connected)
		return;
	conn->show = server->show;
	conn->priority = server->priority;
}
Exemplo n.º 2
0
static void
sig_save_status(XMPP_SERVER_CONNECT_REC *conn,
    XMPP_SERVER_REC *server)
{
	if (!IS_XMPP_SERVER_CONNECT(conn) || !IS_XMPP_SERVER(server)
	    || !server->connected)
		return;
	save_channels(server, conn);
}
Exemplo n.º 3
0
static void
sig_conn_remove(RECONNECT_REC *rec)
{
	XMPP_SERVER_CONNECT_REC *conn;

	if (!IS_XMPP_SERVER_CONNECT(rec->conn))
		return;
	conn = XMPP_SERVER_CONNECT(rec->conn);
	g_slist_foreach(conn->channels_list, (GFunc)g_free, NULL);
	g_slist_free(conn->channels_list);
}
static void
sig_server_connect_copy(SERVER_CONNECT_REC **dest, XMPP_SERVER_CONNECT_REC *src)
{
	XMPP_SERVER_CONNECT_REC *conn;

	g_return_if_fail(dest != NULL);
	if (!IS_XMPP_SERVER_CONNECT(src))
		return;
	conn = g_new0(XMPP_SERVER_CONNECT_REC, 1);
	conn->chat_type = XMPP_PROTOCOL;
	conn->show = src->show;
	conn->priority = src->priority;
	*dest = (SERVER_CONNECT_REC *)conn;
}
Exemplo n.º 5
0
static void
sig_conn_copy(SERVER_CONNECT_REC **dest, XMPP_SERVER_CONNECT_REC *src)
{
	GSList *tmp;
	XMPP_SERVER_CONNECT_REC *conn;

	g_return_if_fail(dest != NULL);
	if (!IS_XMPP_SERVER_CONNECT(src))
		return;
	conn = (XMPP_SERVER_CONNECT_REC *)*dest;
	conn->channels_list = NULL;
	for (tmp = src->channels_list; tmp != NULL; tmp = tmp->next) {
		conn->channels_list = g_slist_append(conn->channels_list,
		    g_strdup(tmp->data));
	}
}
Exemplo n.º 6
0
static void
sig_server_connect_copy(SERVER_CONNECT_REC **dest, XMPP_SERVER_CONNECT_REC *src)
{
	XMPP_SERVER_CONNECT_REC *conn;

	g_return_if_fail(dest != NULL);
	if (!IS_XMPP_SERVER_CONNECT(src))
		return;
	conn = g_new0(XMPP_SERVER_CONNECT_REC, 1);
	conn->chat_type = XMPP_PROTOCOL;
	conn->show = src->show;
	conn->priority = src->priority;
	conn->prompted_password = g_strdup(src->prompted_password);
	g_free(src->nick);
	src->nick = src->real_jid;
	src->real_jid = NULL;
	*dest = (SERVER_CONNECT_REC *)conn;
}
Exemplo n.º 7
0
SERVER_REC *
xmpp_server_init_connect(SERVER_CONNECT_REC *connrec)
{
	XMPP_SERVER_REC *server;
	XMPP_SERVER_CONNECT_REC *conn = (XMPP_SERVER_CONNECT_REC *)connrec;
	char *recoded;

	if (conn->address == NULL || conn->address[0] == '\0')
		return NULL;
	if (conn->nick == NULL || conn->nick[0] == '\0')
		return NULL;
	g_return_val_if_fail(IS_XMPP_SERVER_CONNECT(conn), NULL);

	server = g_new0(XMPP_SERVER_REC, 1);
	server->chat_type = XMPP_PROTOCOL;
	server->user = xmpp_extract_user(conn->nick);
	server->domain = xmpp_have_domain(conn->nick) ?
	    xmpp_extract_domain(conn->nick) : g_strdup(conn->address);
	server->jid = xmpp_have_domain(conn->nick) ?
	    xmpp_strip_resource(conn->nick)
	    : g_strconcat(server->user, "@", server->domain, (void *)NULL);
	server->resource = xmpp_extract_resource(conn->nick);
	if (server->resource == NULL)
		server->resource = g_strdup("irssi-xmpp");
	server->priority = settings_get_int("xmpp_priority");
	if (xmpp_priority_out_of_bound(server->priority))
		server->priority = 0;
	server->ping_id = NULL;
	server->server_features = NULL;
	server->my_resources = NULL;
	server->roster = NULL;
	server->msg_handlers = NULL;
	server->channels_join = channels_join;
	server->isnickflag = isnickflag_func;
	server->ischannel = ischannel_func;
	server->get_nick_flags = get_nick_flags;
	server->send_message = send_message;
	server->connrec = (XMPP_SERVER_CONNECT_REC *)conn;
	server_connect_ref(connrec);

	/* don't use irssi's sockets */
	server->connrec->no_connect = TRUE;
	server->connect_pid = -1;

	if (server->connrec->port <= 0)
		server->connrec->port = (server->connrec->use_ssl) ?
		    LM_CONNECTION_DEFAULT_PORT_SSL : LM_CONNECTION_DEFAULT_PORT;

	if (conn->real_jid == NULL)
		conn->real_jid = conn->nick;
	else
		g_free(conn->nick);
	conn->nick = g_strdup(settings_get_bool("xmpp_set_nick_as_username") ?
	    server->user : server->jid);

	/* init loudmouth connection structure */
	server->lmconn = lm_connection_new(NULL);
	lm_connection_set_server(server->lmconn, server->connrec->address);
	lm_connection_set_port(server->lmconn, server->connrec->port);
	recoded = xmpp_recode_out(server->jid);
	lm_connection_set_jid(server->lmconn, recoded);
	g_free(recoded);
	lm_connection_set_keep_alive_rate(server->lmconn, 30);

	server->timeout_tag = 0;
	server_connect_init((SERVER_REC *)server);
	server->connect_tag = 1;
	return (SERVER_REC *)server;
}