equal
deleted
inserted
replaced
1 /* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */ |
1 /* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */ |
2 /* |
2 /* |
3 * Copyright (C) 2003-2006 Imendio AB |
3 * Copyright (C) 2003-2007 Imendio AB |
4 * Copyright (C) 2006 Nokia Corporation. All rights reserved. |
4 * Copyright (C) 2006 Nokia Corporation. All rights reserved. |
5 * Copyright (C) 2007 Collabora Ltd. |
5 * Copyright (C) 2007 Collabora Ltd. |
6 * |
6 * |
7 * This program is free software; you can redistribute it and/or |
7 * This program is free software; you can redistribute it and/or |
8 * modify it under the terms of the GNU Lesser General Public License as |
8 * modify it under the terms of the GNU Lesser General Public License as |
771 } |
771 } |
772 |
772 |
773 void |
773 void |
774 _lm_connection_socket_result (LmConnection *connection, gboolean result) |
774 _lm_connection_socket_result (LmConnection *connection, gboolean result) |
775 { |
775 { |
776 LmMessage *m; |
776 LmMessage *m; |
777 gchar *server_from_jid; |
777 gchar *server_from_jid; |
778 gchar *ch; |
|
779 gchar *ch_end; |
|
780 |
778 |
781 if (!result) { |
779 if (!result) { |
782 _lm_connection_do_close (connection); |
780 _lm_connection_do_close (connection); |
783 |
781 |
784 if (connection->open_cb) { |
782 if (connection->open_cb) { |
803 _lm_connection_do_close (connection); |
801 _lm_connection_do_close (connection); |
804 |
802 |
805 return; |
803 return; |
806 } |
804 } |
807 |
805 |
808 if (connection->jid != NULL && (ch = strchr (connection->jid, '@')) != NULL) { |
806 if (!connection_get_server_from_jid (connection->jid, &server_from_jid)) { |
809 ch_end = strchr(ch + 1, '/'); |
|
810 if (ch_end != NULL) { |
|
811 server_from_jid = g_strndup (ch + 1, ch_end - ch - 1); |
|
812 } else { |
|
813 server_from_jid = g_strdup (ch + 1); |
|
814 } |
|
815 } else { |
|
816 server_from_jid = g_strdup (connection->server); |
807 server_from_jid = g_strdup (connection->server); |
817 } |
808 } |
818 |
809 |
819 m = lm_message_new (server_from_jid, LM_MESSAGE_TYPE_STREAM); |
810 m = lm_message_new (server_from_jid, LM_MESSAGE_TYPE_STREAM); |
820 lm_message_node_set_attributes (m->node, |
811 lm_message_node_set_attributes (m->node, |
822 "http://etherx.jabber.org/streams", |
813 "http://etherx.jabber.org/streams", |
823 "xmlns", "jabber:client", |
814 "xmlns", "jabber:client", |
824 "version", "1.0", |
815 "version", "1.0", |
825 NULL); |
816 NULL); |
826 |
817 |
|
818 g_free (server_from_jid); |
827 lm_verbose ("Opening stream..."); |
819 lm_verbose ("Opening stream..."); |
828 |
820 |
829 if (!lm_connection_send (connection, m, NULL)) { |
821 if (!lm_connection_send (connection, m, NULL)) { |
830 lm_verbose ("Failed to send stream information\n"); |
822 lm_verbose ("Failed to send stream information\n"); |
831 _lm_connection_do_close (connection); |
823 _lm_connection_do_close (connection); |
832 } |
824 } |
833 |
825 |
834 g_free (server_from_jid); |
|
835 lm_message_unref (m); |
826 lm_message_unref (m); |
836 } |
827 } |
837 |
828 |
838 gboolean |
829 gboolean |
839 _lm_connection_async_connect_waiting (LmConnection *connection) |
830 _lm_connection_async_connect_waiting (LmConnection *connection) |