loudmouth/lm-connection.c
changeset 345 9a94f040cc56
parent 344 11473296fea5
child 394 03933ba2fb40
equal deleted inserted replaced
344:11473296fea5 345:9a94f040cc56
   342 connection_start_keep_alive (LmConnection *connection)
   342 connection_start_keep_alive (LmConnection *connection)
   343 {
   343 {
   344 	/* try using TCP keepalives if possible */
   344 	/* try using TCP keepalives if possible */
   345 	if ((connection->keep_alive_rate > 0) &&
   345 	if ((connection->keep_alive_rate > 0) &&
   346 		lm_socket_set_keepalive (connection->socket,
   346 		lm_socket_set_keepalive (connection->socket,
   347 			connection->keep_alive_rate))
   347 			connection->keep_alive_rate)) {
   348 		return;
   348 		return;
       
   349 	}
   349 
   350 
   350 	if (connection->keep_alive_source) {
   351 	if (connection->keep_alive_source) {
   351 		connection_stop_keep_alive (connection);
   352 		connection_stop_keep_alive (connection);
   352 	}
   353 	}
   353 
   354 
   456 
   457 
   457 	if (!connection_get_server_from_jid (connection->jid, &domain)) {
   458 	if (!connection_get_server_from_jid (connection->jid, &domain)) {
   458 		domain = g_strdup (connection->server);
   459 		domain = g_strdup (connection->server);
   459 	}
   460 	}
   460 
   461 
   461 	lm_verbose ("Connecting to: %s:%d\n", 
   462 	lm_verbose ("Connecting to: %s:%d\n", connection->server, connection->port);
   462 		    connection->server, connection->port);
       
   463 
   463 
   464 	connection->socket = lm_socket_create (connection->context,
   464 	connection->socket = lm_socket_create (connection->context,
   465 					       (IncomingDataFunc) connection_incoming_data,
   465 					       (IncomingDataFunc) connection_incoming_data,
   466 					       (SocketClosedFunc) connection_socket_closed_cb,
   466 					       (SocketClosedFunc) connection_socket_closed_cb,
   467 					       (ConnectResultFunc) connection_socket_connect_cb,
   467 					       (ConnectResultFunc) connection_socket_connect_cb,
   524 	gchar        *password;
   524 	gchar        *password;
   525 	gchar        *resource;
   525 	gchar        *resource;
   526 } AuthReqData;
   526 } AuthReqData;
   527 
   527 
   528 static void 
   528 static void 
   529 auth_req_data_free (AuthReqData *data) {
   529 auth_req_data_free (AuthReqData *data) 
       
   530 {
   530 	g_free (data->username);
   531 	g_free (data->username);
   531 	g_free (data->password);
   532 	g_free (data->password);
   532 	g_free (data->resource);
   533 	g_free (data->resource);
   533 	g_free (data);
   534 	g_free (data);
   534 }
   535 }
   756 	} else {
   757 	} else {
   757 		lm_verbose ("Old Jabber stream received: %s\n", 
   758 		lm_verbose ("Old Jabber stream received: %s\n", 
   758 			    connection->stream_id);
   759 			    connection->stream_id);
   759 	}
   760 	}
   760 	
   761 	
   761 	if (connection->state < LM_CONNECTION_STATE_OPEN)
   762 	if (connection->state < LM_CONNECTION_STATE_OPEN) {
   762 		connection->state = LM_CONNECTION_STATE_OPEN;
   763 		connection->state = LM_CONNECTION_STATE_OPEN;
       
   764 	}
   763 	
   765 	
   764 	/* Check to see if the stream is correctly set up */
   766 	/* Check to see if the stream is correctly set up */
   765 	result = TRUE;
   767 	result = TRUE;
   766 
   768 
   767 	connection_start_keep_alive (connection);
   769 	connection_start_keep_alive (connection);
   772 		connection->open_cb = NULL;
   774 		connection->open_cb = NULL;
   773 		
   775 		
   774 		if (cb->func) {
   776 		if (cb->func) {
   775 		        (* ((LmResultFunction) cb->func)) (connection, result,
   777 		        (* ((LmResultFunction) cb->func)) (connection, result,
   776 			        			   cb->user_data);
   778 			        			   cb->user_data);
   777 
       
   778 		}
   779 		}
   779 		_lm_utils_free_callback (cb);
   780 		_lm_utils_free_callback (cb);
   780 	}
   781 	}
   781 }
   782 }
   782 
   783 
  1123 			if (user && pass) {
  1124 			if (user && pass) {
  1124 				GError *error = NULL;
  1125 				GError *error = NULL;
  1125 				_lm_connection_old_auth (connection, user, pass,
  1126 				_lm_connection_old_auth (connection, user, pass,
  1126 					connection->resource, &error);
  1127 					connection->resource, &error);
  1127 
  1128 
  1128 				if (error)
  1129 				if (error) {
  1129 					g_error_free (error);
  1130 					g_error_free (error);
  1130 
  1131 				}
  1131 			}
  1132 			}
  1132 
  1133 
  1133 			lm_sasl_free (connection->sasl);
  1134 			lm_sasl_free (connection->sasl);
  1134 			connection->sasl = NULL;
  1135 			connection->sasl = NULL;
  1135 		}
  1136 		}