Correctly extract the server from a JID when resource is included.
If a full JID (including resource) was given to lm_connection_set_jid it would
include the resource part when trying to connect to the server.
Patch from Matthias Quasthoff
--- a/loudmouth/lm-connection.c Sat Feb 24 03:33:00 2007 +0100
+++ b/loudmouth/lm-connection.c Sat Feb 24 04:03:49 2007 +0100
@@ -734,6 +734,7 @@
LmMessage *m;
gchar *server_from_jid;
gchar *ch;
+ gchar *ch_end;
if (!result) {
_lm_connection_do_close (connection);
@@ -763,9 +764,14 @@
}
if (connection->jid != NULL && (ch = strchr (connection->jid, '@')) != NULL) {
- server_from_jid = ch + 1;
+ ch_end = strchr(ch + 1, '/');
+ if (ch_end != NULL) {
+ server_from_jid = g_strndup (ch + 1, ch_end - ch - 1);
+ } else {
+ server_from_jid = g_strdup (ch + 1);
+ }
} else {
- server_from_jid = connection->server;
+ server_from_jid = g_strdup (connection->server);
}
m = lm_message_new (server_from_jid, LM_MESSAGE_TYPE_STREAM);
@@ -783,6 +789,7 @@
_lm_connection_do_close (connection);
}
+ g_free (server_from_jid);
lm_message_unref (m);
}