2005-08-12 Mikael Hallendal <micke@imendio.com>
* loudmouth/lm-connection.c:
(lm_connection_authenticate_and_block):
- Set state correctly.
- Fixes LM-7.
(lm_connection_send_with_reply_and_block):
- Check that connection is open before using it.
- Fixes LM-6.
--- a/ChangeLog Sat Jul 30 19:54:02 2005 +0000
+++ b/ChangeLog Fri Aug 12 09:51:26 2005 +0000
@@ -1,3 +1,18 @@
+2005-08-12 Mikael Hallendal <micke@imendio.com>
+
+ * loudmouth/lm-connection.c:
+ (lm_connection_authenticate_and_block):
+ - Set state correctly.
+ - Fixes LM-7.
+ (lm_connection_send_with_reply_and_block):
+ - Check that connection is open before using it.
+ - Fixes LM-6.
+
+2005-08-12 Mikael Hallendal <micke@imendio.com>
+
+ * loudmouth/lm-connection.c:
+ (lm_connection_authenticate_and_block):
+
2005-07-30 Mikael Hallendal <micke@imendio.com>
* autogen.sh:
--- a/loudmouth/lm-connection.c Sat Jul 30 19:54:02 2005 +0000
+++ b/loudmouth/lm-connection.c Fri Aug 12 09:51:26 2005 +0000
@@ -76,7 +76,7 @@
guint io_watch_err;
guint io_watch_hup;
guint fd;
- guint io_watch_connect;
+ guint io_watch_connect;
guint open_id;
LmCallback *open_cb;
@@ -521,14 +521,14 @@
connect_data->io_channel = g_io_channel_unix_new (fd);
if (connection->proxy) {
- connection->io_watch_connect =
+ connection->io_watch_connect =
connection_add_watch (connection,
connect_data->io_channel,
G_IO_OUT|G_IO_ERR,
(GIOFunc) _lm_proxy_connect_cb,
connect_data);
} else {
- connection->io_watch_connect =
+ connection->io_watch_connect =
connection_add_watch (connection,
connect_data->io_channel,
G_IO_OUT|G_IO_ERR,
@@ -1437,11 +1437,14 @@
return FALSE;
}
+ connection->state = LM_CONNECTION_STATE_AUTHENTICATING;
+
m = connection_create_auth_req_msg (username);
result = lm_connection_send_with_reply_and_block (connection, m, error);
lm_message_unref (m);
if (!result) {
+ connection->state = LM_CONNECTION_STATE_OPEN;
return FALSE;
}
@@ -1454,6 +1457,7 @@
result = lm_connection_send_with_reply_and_block (connection, m, error);
if (!result) {
+ connection->state = LM_CONNECTION_STATE_OPEN;
return FALSE;
}
@@ -1462,9 +1466,11 @@
switch (type) {
case LM_MESSAGE_SUB_TYPE_RESULT:
+ connection->state = LM_CONNECTION_STATE_AUTHENTICATED;
return TRUE;
break;
case LM_MESSAGE_SUB_TYPE_ERROR:
+ connection->state = LM_CONNECTION_STATE_OPEN;
g_set_error (error,
LM_ERROR,
LM_ERROR_AUTH_FAILED,
@@ -1825,6 +1831,15 @@
g_return_val_if_fail (connection != NULL, NULL);
g_return_val_if_fail (message != NULL, NULL);
+ if (connection->state < LM_CONNECTION_STATE_OPENING) {
+ g_set_error (error,
+ LM_ERROR,
+ LM_ERROR_CONNECTION_NOT_OPEN,
+ "Connection is not open, call lm_connection_open() first");
+ return FALSE;
+ }
+
+
if (lm_message_node_get_attribute (message->node, "id")) {
id = g_strdup (lm_message_node_get_attribute (message->node,
"id"));