2006-10-16 Mikael Hallendal <micke@imendio.com>
* loudmouth/lm-connection.c: (_lm_connection_succeeded),
(_lm_connection_failed_with_error), (connection_do_open),
(connection_do_close), (lm_connection_new):
- Keep a reference to LmConnectData and remove the source if connect
is cancelled before the connection is open.
- Fixes LM-59.
* loudmouth/lm-message-node.c: (lm_message_node_to_string):
- Use GString to build message node XML.
- Escape the attribute values unless raw-mode is specified.
- Fixes LM-48.
- Patch from Dafydd Harries.
--- a/ChangeLog Thu Sep 21 12:08:29 2006 +0000
+++ b/ChangeLog Mon Oct 16 21:49:37 2006 +0000
@@ -1,3 +1,17 @@
+2006-10-16 Mikael Hallendal <micke@imendio.com>
+
+ * loudmouth/lm-connection.c: (_lm_connection_succeeded),
+ (_lm_connection_failed_with_error), (connection_do_open),
+ (connection_do_close), (lm_connection_new):
+ - Keep a reference to LmConnectData and remove the source if connect
+ is cancelled before the connection is open.
+ - Fixes LM-59.
+ * loudmouth/lm-message-node.c: (lm_message_node_to_string):
+ - Use GString to build message node XML.
+ - Escape the attribute values unless raw-mode is specified.
+ - Fixes LM-48.
+ - Patch from Dafydd Harries.
+
2006-09-21 Mikael Hallendal <micke@imendio.com>
* NEWS:
--- a/loudmouth/lm-connection.c Thu Sep 21 12:08:29 2006 +0000
+++ b/loudmouth/lm-connection.c Mon Oct 16 21:49:37 2006 +0000
@@ -98,6 +98,8 @@
guint io_watch_out;
GString *out_buf;
+ LmConnectData *connect_data;
+
gint ref_count;
};
@@ -361,6 +363,7 @@
connection->io_channel = connect_data->io_channel;
freeaddrinfo (connect_data->resolved_addrs);
+ connection->connect_data = NULL;
g_free (connect_data);
if (connection->ssl) {
@@ -501,6 +504,7 @@
}
freeaddrinfo (connect_data->resolved_addrs);
+ connection->connect_data = NULL;
g_free (connect_data);
} else {
/* try to connect to the next host */
@@ -934,6 +938,8 @@
data->io_channel = NULL;
data->fd = -1;
+ connection->connect_data = data;
+
connection_do_connect (data);
return TRUE;
}
@@ -941,10 +947,30 @@
static void
connection_do_close (LmConnection *connection)
{
- GSource *source;
+ GSource *source;
+ LmConnectData *data;
connection_stop_keep_alive (connection);
+ if (connection->io_watch_connect != 0) {
+
+ source = g_main_context_find_source_by_id (connection->context,
+ connection->io_watch_connect);
+
+ if (source) {
+ g_source_destroy (source);
+ }
+
+ connection->io_watch_connect = 0;
+ }
+
+ data = connection->connect_data;
+ if (data) {
+ freeaddrinfo (data->resolved_addrs);
+ connection->connect_data = NULL;
+ g_free (data);
+ }
+
if (connection->io_channel) {
if (connection->io_watch_in != 0) {
source = g_main_context_find_source_by_id (connection->context,
@@ -988,17 +1014,6 @@
connection->io_watch_out = 0;
}
- if (connection->io_watch_connect != 0) {
-
- source = g_main_context_find_source_by_id (connection->context,
- connection->io_watch_connect);
-
- if (source) {
- g_source_destroy (source);
- }
-
- connection->io_watch_connect = 0;
- }
g_io_channel_unref (connection->io_channel);
connection->io_channel = NULL;
@@ -1524,6 +1539,7 @@
connection->keep_alive_id = 0;
connection->keep_alive_rate = 0;
connection->out_buf = NULL;
+ connection->connect_data = NULL;
connection->id_handlers = g_hash_table_new_full (g_str_hash,
g_str_equal,
--- a/loudmouth/lm-message-node.c Thu Sep 21 12:08:29 2006 +0000
+++ b/loudmouth/lm-message-node.c Mon Oct 16 21:49:37 2006 +0000
@@ -438,8 +438,7 @@
gchar *
lm_message_node_to_string (LmMessageNode *node)
{
- gchar *ret_val;
- gchar *str;
+ GString *ret;
GSList *l;
LmMessageNode *child;
@@ -449,46 +448,46 @@
return g_strdup ("");
}
- str = g_strdup_printf ("<%s", node->name);
+ ret = g_string_new ("<");
+ g_string_append (ret, node->name);
for (l = node->attributes; l; l = l->next) {
KeyValuePair *kvp = (KeyValuePair *) l->data;
+
+ if (node->raw_mode == FALSE) {
+ gchar *escaped;
+
+ escaped = g_markup_escape_text (kvp->value, -1);
+ g_string_append_printf (ret, " %s=\"%s\"", escaped, tmp);
+ g_free (escaped);
+ } else {
+ g_string_append_printf (ret, " %s=\"%s\"", kvp->value, tmp);
+ }
- ret_val = g_strdup_printf ("%s %s=\"%s\"",
- str, kvp->key, kvp->value);
- g_free (str);
- str = ret_val;
}
- ret_val = g_strconcat (str, ">", NULL);
- g_free (str);
+ g_string_append_c (ret, '>');
if (node->value) {
gchar *tmp;
- str = ret_val;
-
if (node->raw_mode == FALSE) {
tmp = g_markup_escape_text (node->value, -1);
- ret_val = g_strconcat (str, tmp, NULL);
+ g_string_append (ret, tmp);
g_free (tmp);
} else {
- ret_val = g_strconcat (str, node->value, NULL);
+ g_string_append (ret, node->value);
}
- g_free (str);
}
for (child = node->children; child; child = child->next) {
gchar *child_str = lm_message_node_to_string (child);
- str = ret_val;
- ret_val = g_strconcat (str, " ", child_str, NULL);
- g_free (str);
+ g_string_append_c (ret, ' ');
+ g_string_append (ret, child_str);
g_free (child_str);
}
- str = ret_val;
- ret_val = g_strdup_printf ("%s</%s>\n", str, node->name);
- g_free (str);
+ g_string_append_printf (ret, "</%s>\n", node->name);
- return ret_val;
+ return g_string_free (ret, FALSE);
}