summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/idle-connection.c31
-rw-r--r--src/idle-server-connection.c13
2 files changed, 14 insertions, 30 deletions
diff --git a/src/idle-connection.c b/src/idle-connection.c
index 79fbc58..0c04461 100644
--- a/src/idle-connection.c
+++ b/src/idle-connection.c
@@ -223,7 +223,7 @@ static IdleParserHandlerResult _version_privmsg_handler(IdleParser *parser, Idle
static IdleParserHandlerResult _welcome_handler(IdleParser *parser, IdleParserMessageCode code, GValueArray *args, gpointer user_data);
static IdleParserHandlerResult _whois_user_handler(IdleParser *parser, IdleParserMessageCode code, GValueArray *args, gpointer user_data);
-static void sconn_status_changed_cb(IdleServerConnection *sconn, IdleServerConnectionState state, IdleServerConnectionStateReason reason, IdleConnection *conn);
+static void sconn_disconnected_cb(IdleServerConnection *sconn, IdleServerConnectionStateReason reason, IdleConnection *conn);
static void sconn_received_cb(IdleServerConnection *sconn, gchar *raw_msg, IdleConnection *conn);
static void irc_handshakes(IdleConnection *conn);
@@ -711,6 +711,7 @@ static void _connection_connect_ready(GObject *source_object, GAsyncResult *res,
}
priv->conn = sconn;
+ priv->sconn_status = SERVER_CONNECTION_STATE_CONNECTED;
g_signal_connect(sconn, "received", (GCallback)(sconn_received_cb), conn);
@@ -754,26 +755,23 @@ static void _start_connecting_continue(IdleConnection *conn) {
if (priv->use_ssl)
idle_server_connection_set_tls(sconn, TRUE);
- g_signal_connect(sconn, "status-changed", (GCallback)(sconn_status_changed_cb), conn);
+ g_signal_connect(sconn, "disconnected", (GCallback)(sconn_disconnected_cb), conn);
idle_server_connection_connect_async(sconn, NULL, _connection_connect_ready, conn);
}
static gboolean keepalive_timeout_cb(gpointer user_data);
-static void sconn_status_changed_cb(IdleServerConnection *sconn, IdleServerConnectionState state, IdleServerConnectionStateReason reason, IdleConnection *conn) {
+static void sconn_disconnected_cb(IdleServerConnection *sconn, IdleServerConnectionStateReason reason, IdleConnection *conn) {
IdleConnectionPrivate *priv = conn->priv;
TpConnectionStatusReason tp_reason;
/* cancel scheduled forced disconnect since we are now disconnected */
- if (state == SERVER_CONNECTION_STATE_NOT_CONNECTED &&
- priv->force_disconnect_id) {
+ if (priv->force_disconnect_id) {
g_source_remove(priv->force_disconnect_id);
priv->force_disconnect_id = 0;
}
- IDLE_DEBUG("called with state %u", state);
-
switch (reason) {
case SERVER_CONNECTION_STATE_REASON_ERROR:
tp_reason = TP_CONNECTION_STATUS_REASON_NETWORK_ERROR;
@@ -791,23 +789,8 @@ static void sconn_status_changed_cb(IdleServerConnection *sconn, IdleServerConne
if (priv->quitting)
tp_reason = TP_CONNECTION_STATUS_REASON_REQUESTED;
- switch (state) {
- case SERVER_CONNECTION_STATE_NOT_CONNECTED:
- connection_disconnect_cb(conn, tp_reason);
- break;
-
- case SERVER_CONNECTION_STATE_CONNECTING:
- break;
-
- case SERVER_CONNECTION_STATE_CONNECTED:
- break;
-
- default:
- g_assert_not_reached();
- break;
- }
-
- priv->sconn_status = state;
+ connection_disconnect_cb(conn, tp_reason);
+ priv->sconn_status = SERVER_CONNECTION_STATE_NOT_CONNECTED;
}
static void sconn_received_cb(IdleServerConnection *sconn, gchar *raw_msg, IdleConnection *conn) {
diff --git a/src/idle-server-connection.c b/src/idle-server-connection.c
index be8413a..82fffdf 100644
--- a/src/idle-server-connection.c
+++ b/src/idle-server-connection.c
@@ -41,7 +41,7 @@ typedef struct _IdleServerConnectionPrivate IdleServerConnectionPrivate;
G_DEFINE_TYPE(IdleServerConnection, idle_server_connection, G_TYPE_OBJECT)
enum {
- STATUS_CHANGED,
+ DISCONNECTED,
RECEIVED,
LAST_SIGNAL
};
@@ -207,13 +207,13 @@ static void idle_server_connection_class_init(IdleServerConnectionClass *klass)
g_object_class_install_property(object_class, PROP_TLS_MANAGER, pspec);
- signals[STATUS_CHANGED] = g_signal_new("status-changed",
+ signals[DISCONNECTED] = g_signal_new("disconnected",
G_OBJECT_CLASS_TYPE(klass),
G_SIGNAL_RUN_LAST | G_SIGNAL_DETAILED,
0,
NULL, NULL,
g_cclosure_marshal_generic,
- G_TYPE_NONE, 2, G_TYPE_UINT, G_TYPE_UINT);
+ G_TYPE_NONE, 1, G_TYPE_UINT);
signals[RECEIVED] = g_signal_new("received",
G_OBJECT_CLASS_TYPE(klass),
@@ -231,10 +231,11 @@ static void change_state(IdleServerConnection *conn, IdleServerConnectionState s
if (state == priv->state)
return;
- IDLE_DEBUG("emitting status-changed, state %u, reason %u", state, reason);
-
+ IDLE_DEBUG("moving to state %u, reason %u", state, reason);
priv->state = state;
- g_signal_emit(conn, signals[STATUS_CHANGED], 0, state, reason);
+
+ if (state == SERVER_CONNECTION_STATE_NOT_CONNECTED)
+ g_signal_emit(conn, signals[DISCONNECTED], 0, reason);
}
static void _input_stream_read(IdleServerConnection *conn, GInputStream *input_stream, GAsyncReadyCallback callback) {