Connection: use a boolean for ServerConnection status
Will Thompson
11 years ago
145 | 145 | * network connection |
146 | 146 | */ |
147 | 147 | IdleServerConnection *conn; |
148 | guint sconn_status; | |
148 | /* | |
149 | * TRUE if 'conn' is connected to the server. (This just represents the TCP | |
150 | * stream; not whether we are authenticated.) | |
151 | */ | |
152 | gboolean sconn_connected; | |
149 | 153 | |
150 | 154 | /* When we sent a PING to the server which it hasn't PONGed for yet, or 0 if |
151 | 155 | * there isn't a PING outstanding. |
245 | 249 | IdleConnectionPrivate *priv = G_TYPE_INSTANCE_GET_PRIVATE (obj, IDLE_TYPE_CONNECTION, IdleConnectionPrivate); |
246 | 250 | |
247 | 251 | obj->priv = priv; |
248 | priv->sconn_status = SERVER_CONNECTION_STATE_NOT_CONNECTED; | |
252 | priv->sconn_connected = FALSE; | |
249 | 253 | priv->msg_queue = g_queue_new(); |
250 | 254 | |
251 | 255 | tp_contacts_mixin_init ((GObject *) obj, G_STRUCT_OFFSET (IdleConnection, contacts)); |
710 | 714 | } |
711 | 715 | |
712 | 716 | priv->conn = sconn; |
713 | priv->sconn_status = SERVER_CONNECTION_STATE_CONNECTED; | |
717 | priv->sconn_connected = TRUE; | |
714 | 718 | |
715 | 719 | g_signal_connect(sconn, "received", (GCallback)(sconn_received_cb), conn); |
716 | 720 | |
789 | 793 | tp_reason = TP_CONNECTION_STATUS_REASON_REQUESTED; |
790 | 794 | |
791 | 795 | connection_disconnect_cb(conn, tp_reason); |
792 | priv->sconn_status = SERVER_CONNECTION_STATE_NOT_CONNECTED; | |
796 | priv->sconn_connected = FALSE; | |
793 | 797 | } |
794 | 798 | |
795 | 799 | static void sconn_received_cb(IdleServerConnection *sconn, gchar *raw_msg, IdleConnection *conn) { |
805 | 809 | gchar cmd[IRC_MSG_MAXLEN + 1]; |
806 | 810 | gint64 now; |
807 | 811 | |
808 | if (priv->sconn_status != SERVER_CONNECTION_STATE_CONNECTED || | |
812 | if (!priv->sconn_connected || | |
809 | 813 | priv->quitting) { |
810 | 814 | priv->keepalive_timeout = 0; |
811 | 815 | return FALSE; |
865 | 869 | |
866 | 870 | IDLE_DEBUG("called"); |
867 | 871 | |
868 | if (priv->sconn_status != SERVER_CONNECTION_STATE_CONNECTED) { | |
872 | if (!priv->sconn_connected) { | |
869 | 873 | IDLE_DEBUG("connection was not connected!"); |
870 | 874 | |
871 | 875 | priv->msg_queue_timeout = 0; |