Better current_host, current_port
This commit is contained in:
parent
80e30ed758
commit
c06362a750
|
@ -72,8 +72,11 @@ gboolean on_gm_net_connect_timeout(GmNet *net);
|
||||||
|
|
||||||
static void
|
static void
|
||||||
gm_net_finalize(GObject *object) {
|
gm_net_finalize(GObject *object) {
|
||||||
//GmNet *net = GM_NET(object);
|
GmNet *net = GM_NET(object);
|
||||||
|
|
||||||
|
g_free(net->priv->current_host);
|
||||||
|
g_free(net->priv->current_port);
|
||||||
|
|
||||||
G_OBJECT_CLASS(gm_net_parent_class)->finalize(object);
|
G_OBJECT_CLASS(gm_net_parent_class)->finalize(object);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -145,6 +148,18 @@ gm_net_init(GmNet *net) {
|
||||||
net->priv->connect_check_id = 0;
|
net->priv->connect_check_id = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
gm_net_set_host(GmNet *net, gchar const *host) {
|
||||||
|
g_free(net->priv->current_host);
|
||||||
|
net->priv->current_host = g_strdup(host);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
gm_net_set_port(GmNet *net, gchar const *port) {
|
||||||
|
g_free(net->priv->current_port);
|
||||||
|
net->priv->current_port = g_strdup(port);
|
||||||
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
gm_net_set_state(GmNet *net, GmNetState state) {
|
gm_net_set_state(GmNet *net, GmNetState state) {
|
||||||
g_signal_emit(net, net_signals[STATE_CHANGING], 0, state);
|
g_signal_emit(net, net_signals[STATE_CHANGING], 0, state);
|
||||||
|
@ -269,8 +284,8 @@ gm_net_connect_next(GmNet *net) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
net->priv->current_host = host;
|
gm_net_set_host(net, host);
|
||||||
net->priv->current_port = port;
|
gm_net_set_port(net, port);
|
||||||
gm_net_set_state(net, GM_NET_STATE_TRY_ADDRESS);
|
gm_net_set_state(net, GM_NET_STATE_TRY_ADDRESS);
|
||||||
|
|
||||||
net->priv->socket = socket(tmp->ai_family, tmp->ai_socktype,
|
net->priv->socket = socket(tmp->ai_family, tmp->ai_socktype,
|
||||||
|
@ -381,8 +396,8 @@ gm_net_connect(GmNet *net, const gchar *host, const gchar *port) {
|
||||||
snprintf(shost, NI_MAXHOST - 1, "%s", host);
|
snprintf(shost, NI_MAXHOST - 1, "%s", host);
|
||||||
snprintf(sport, NI_MAXSERV - 1, "%s", port);
|
snprintf(sport, NI_MAXSERV - 1, "%s", port);
|
||||||
|
|
||||||
net->priv->current_host = shost;
|
gm_net_set_host(net, shost);
|
||||||
net->priv->current_port = sport;
|
gm_net_set_port(net, sport);
|
||||||
|
|
||||||
gm_net_set_state(net, GM_NET_STATE_CONNECTING);
|
gm_net_set_state(net, GM_NET_STATE_CONNECTING);
|
||||||
|
|
||||||
|
|
Reference in New Issue