static void server_setup_fill_chatnet(SERVER_CONNECT_REC *conn, CHATNET_REC *chatnet) { g_return_if_fail(IS_SERVER_CONNECT(conn)); g_return_if_fail(IS_CHATNET(chatnet)); if (chatnet->nick != NULL && chatnet->nick[0] != '\0') { g_free(conn->nick); conn->nick = g_strdup(chatnet->nick);; } if (chatnet->username != NULL && chatnet->username[0] != '\0') { g_free(conn->username); conn->username = g_strdup(chatnet->username);; } if (chatnet->realname != NULL && chatnet->realname[0] != '\0') { g_free(conn->realname); conn->realname = g_strdup(chatnet->realname);; } if (chatnet->own_host != NULL) { conn_set_ip(conn, chatnet->own_host, &chatnet->own_ip4, &chatnet->own_ip6); } signal_emit("server setup fill chatnet", 2, conn, chatnet); }
/* Fill information to connection from server setup record */ void server_setup_fill_conn(IRC_SERVER_CONNECT_REC *conn, SETUP_SERVER_REC *sserver) { if (sserver->own_host != NULL) conn_set_ip(conn, &sserver->own_ip, sserver->own_host); sserver->last_connect = time(NULL); if (sserver->ircnet != NULL && conn->ircnet == NULL) conn->ircnet = g_strdup(sserver->ircnet); if (sserver->password != NULL && conn->password == NULL) conn->password = g_strdup(sserver->password); if (sserver->cmd_queue_speed > 0) conn->cmd_queue_speed = sserver->cmd_queue_speed; if (sserver->max_cmds_at_once > 0) conn->max_cmds_at_once = sserver->max_cmds_at_once; }
/* Fill information to connection from server setup record */ void server_setup_fill_reconn(SERVER_CONNECT_REC *conn, SERVER_SETUP_REC *sserver) { g_return_if_fail(IS_SERVER_CONNECT(conn)); g_return_if_fail(IS_SERVER_SETUP(sserver)); if (sserver->own_host != NULL) { conn_set_ip(conn, sserver->own_host, &sserver->own_ip4, &sserver->own_ip6); } if (sserver->chatnet != NULL && conn->chatnet == NULL) conn->chatnet = g_strdup(sserver->chatnet); if (sserver->password != NULL && conn->password == NULL) conn->password = g_strdup(sserver->password); signal_emit("server setup fill reconn", 2, conn, sserver); }
/* Create server connection record. `address' is required, rest can be NULL */ static IRC_SERVER_CONNECT_REC * create_addr_conn(const char *address, int port, const char *password, const char *nick) { IRC_SERVER_CONNECT_REC *conn; SETUP_SERVER_REC *sserver; IRCNET_REC *ircnet; g_return_val_if_fail(address != NULL, NULL); conn = g_new0(IRC_SERVER_CONNECT_REC, 1); conn->address = g_strdup(address); conn->port = port > 0 ? port : 6667; if (password && *password) conn->password = g_strdup(password); if (nick && *nick) conn->nick = g_strdup(nick); if (!conn->nick) conn->nick = g_strdup(settings_get_str("default_nick")); conn->alternate_nick = g_strdup(settings_get_str("alternate_nick")); conn->username = g_strdup(settings_get_str("user_name")); conn->realname = g_strdup(settings_get_str("real_name")); /* proxy settings */ if (settings_get_bool("use_ircproxy")) { conn->proxy = g_strdup(settings_get_str("proxy_address")); conn->proxy_port = settings_get_int("proxy_port"); conn->proxy_string = g_strdup(settings_get_str("proxy_string")); } /* source IP */ get_source_host_ip(); if (source_host_ok) { conn->own_ip = g_new(IPADDR, 1); memcpy(conn->own_ip, source_host_ip, sizeof(IPADDR)); } /* fill the information from setup */ sserver = server_setup_find(address, -1); if (sserver == NULL) return conn; server_setup_fill_conn(conn, sserver); /* fill the rest from IRC network settings */ ircnet = sserver->ircnet == NULL ? NULL : ircnet_find(sserver->ircnet); if (ircnet == NULL) return conn; if (ircnet->nick && !(nick && *nick)) { g_free(conn->nick); conn->nick = g_strdup(ircnet->nick);; } if (ircnet->username) { g_free(conn->username); conn->username = g_strdup(ircnet->username);; } if (ircnet->realname) { g_free(conn->realname); conn->realname = g_strdup(ircnet->realname);; } if (ircnet->max_kicks > 0) conn->max_kicks = ircnet->max_kicks; if (ircnet->max_msgs > 0) conn->max_msgs = ircnet->max_msgs; if (ircnet->max_modes > 0) conn->max_modes = ircnet->max_modes; if (ircnet->max_whois > 0) conn->max_whois = ircnet->max_whois; if (ircnet->max_cmds_at_once > 0 && sserver->max_cmds_at_once <= 0) conn->max_cmds_at_once = ircnet->max_cmds_at_once; if (ircnet->cmd_queue_speed > 0 && sserver->cmd_queue_speed <= 0) conn->cmd_queue_speed = ircnet->cmd_queue_speed; if (sserver->own_host == NULL && ircnet->own_host != NULL) conn_set_ip(conn, &ircnet->own_ip, ircnet->own_host); return conn; }