Rename lm_conn_get_effective_jid() to lm_conn_get_full_jid() to
authorSenko Rasic <senko.rasic@collabora.co.uk>
Tue, 30 Oct 2007 23:22:09 +0100
changeset 307 f169e9281745
parent 306 d466fc30829f
child 308 7e2050a6df75
Rename lm_conn_get_effective_jid() to lm_conn_get_full_jid() to be LM1.2 API compatible, allow it to be usable even if XMPP1.0 resource binding isn't done.
loudmouth/lm-connection.c
loudmouth/lm-connection.h
--- a/loudmouth/lm-connection.c	Tue Oct 30 23:14:48 2007 +0100
+++ b/loudmouth/lm-connection.c	Tue Oct 30 23:22:09 2007 +0100
@@ -963,6 +963,7 @@
 	/* use whatever server returns as our effective jid */
 	jid_node = lm_message_node_find_child (message->node, "jid");
 	if (jid_node) {
+		g_free (connection->effective_jid);
 		connection->effective_jid = g_strdup
 			(lm_message_node_get_value (jid_node));
 	}
@@ -1381,14 +1382,16 @@
 						      user_data, 
 						      notify);
 
+	connection->resource = g_strdup (resource);
+	connection->effective_jid = g_strdup_printf ("%s/%s", 
+		connection->jid, connection->resource);
+
 	if (connection->use_xmpp) {
 		lm_sasl_authenticate (connection->sasl,
 				      username, password,
 				      connection->server,
 				      connection_sasl_auth_finished);
 
-		connection->resource = g_strdup (resource);
-
 		connection->features_cb  =
 			lm_message_handler_new (connection_features_cb,
 				NULL, NULL);
@@ -1630,22 +1633,20 @@
 }
 
 /**
- * lm_connection_get_effective_jid:
+ * lm_connection_get_full_jid:
  * @connection: an #LmConnection
  * 
- * Returns the jid that server set for us after resource binding.
+ * Returns the full jid that server set for us after
+ * resource binding, complete with the resource.
  *
  * Return value: the jid
  **/
-const gchar *
-lm_connection_get_effective_jid (LmConnection *connection)
+gchar *
+lm_connection_get_full_jid (LmConnection *connection)
 {
 	g_return_val_if_fail (connection != NULL, NULL);
 
-	if (connection->effective_jid)
-		return connection->effective_jid;
-	else
-		return connection->jid;
+	return connection->effective_jid;
 }
 
 /**
--- a/loudmouth/lm-connection.h	Tue Oct 30 23:14:48 2007 +0100
+++ b/loudmouth/lm-connection.h	Tue Oct 30 23:22:09 2007 +0100
@@ -118,7 +118,7 @@
 void          lm_connection_set_jid           (LmConnection       *connection,
 					       const gchar        *jid);
 const gchar * lm_connection_get_jid           (LmConnection       *connection);
-const gchar * lm_connection_get_effective_jid (LmConnection       *connection);
+gchar *       lm_connection_get_full_jid      (LmConnection       *connection);
 
 guint         lm_connection_get_port          (LmConnection       *connection);
 void          lm_connection_set_port          (LmConnection       *connection,