loudmouth/lm-connection.c
changeset 501 5f71592beac8
parent 500 915cd386918e
child 503 c7c1722ec2db
--- a/loudmouth/lm-connection.c	Mon Oct 06 01:13:17 2008 +0200
+++ b/loudmouth/lm-connection.c	Mon Oct 06 01:41:19 2008 +0200
@@ -524,9 +524,7 @@
 		return FALSE;
 	}
 
-	if (!connection_get_server_from_jid (connection->jid, &domain)) {
-		domain = g_strdup (connection->server);
-	}
+        domain = _lm_connection_get_server (connection);
 
 	lm_verbose ("Connecting to: %s:%d\n", connection->server, connection->port);
 
@@ -993,9 +991,7 @@
 
 	lm_verbose ("Sending stream header\n");
 
-	if (!connection_get_server_from_jid (connection->jid, &server_from_jid)) {
-		server_from_jid = g_strdup (connection->server);
-	}
+        server_from_jid = _lm_connection_get_server (connection);
 
 	m = lm_message_new (server_from_jid, LM_MESSAGE_TYPE_STREAM);
 	lm_message_node_set_attributes (m->node,
@@ -1023,6 +1019,20 @@
         return conn->context;
 }
 
+gchar *
+_lm_connection_get_server (LmConnection *conn)
+{
+        gchar *server;
+
+        g_return_val_if_fail (conn != NULL, NULL);
+
+	if (!connection_get_server_from_jid (conn->jid, &server)) {
+		server = g_strdup (conn->server);
+	}
+
+        return server;
+}
+
 gboolean 
 _lm_connection_async_connect_waiting (LmConnection *connection)
 {