Mercurial > pidgin
comparison libpurple/protocols/bonjour/jabber.c @ 21522:dc703f13449a
Fix a couple bugs in the Bonjour XEP-0065 implementation, mainly related to error handling, but also send a <streamhost-used /> result. Also fix a XEP-0096 bug where the SI profile wasn't being specified. These bring ft with gajim closer to working, but we aren't there yet.
author | Daniel Atallah <daniel.atallah@gmail.com> |
---|---|
date | Thu, 15 Nov 2007 14:53:53 +0000 |
parents | 7a05b6f84545 |
children | 5b9da9db7e81 |
comparison
equal
deleted
inserted
replaced
21521:287ee978db2e | 21522:dc703f13449a |
---|---|
87 return "12"; | 87 return "12"; |
88 } | 88 } |
89 #endif | 89 #endif |
90 | 90 |
91 static BonjourJabberConversation * | 91 static BonjourJabberConversation * |
92 bonjour_jabber_conv_new() { | 92 bonjour_jabber_conv_new(PurpleBuddy *pb) { |
93 | 93 |
94 BonjourJabberConversation *bconv = g_new0(BonjourJabberConversation, 1); | 94 BonjourJabberConversation *bconv = g_new0(BonjourJabberConversation, 1); |
95 bconv->socket = -1; | 95 bconv->socket = -1; |
96 bconv->tx_buf = purple_circ_buffer_new(512); | 96 bconv->tx_buf = purple_circ_buffer_new(512); |
97 bconv->tx_handler = 0; | 97 bconv->tx_handler = 0; |
98 bconv->rx_handler = 0; | 98 bconv->rx_handler = 0; |
99 bconv->pb = pb; | |
99 | 100 |
100 return bconv; | 101 return bconv; |
101 } | 102 } |
102 | 103 |
103 | 104 |
399 #endif | 400 #endif |
400 /* Close the socket, clear the watcher and free memory */ | 401 /* Close the socket, clear the watcher and free memory */ |
401 bonjour_jabber_close_conversation(bb->conversation); | 402 bonjour_jabber_close_conversation(bb->conversation); |
402 bb->conversation = NULL; | 403 bb->conversation = NULL; |
403 } | 404 } |
404 | |
405 } | 405 } |
406 | 406 |
407 void bonjour_jabber_stream_started(PurpleBuddy *pb) { | 407 void bonjour_jabber_stream_started(PurpleBuddy *pb) { |
408 BonjourBuddy *bb = pb->proto_data; | 408 BonjourBuddy *bb = pb->proto_data; |
409 BonjourJabberConversation *bconv = bb->conversation; | 409 BonjourJabberConversation *bconv = bb->conversation; |
571 bb = pb->proto_data; | 571 bb = pb->proto_data; |
572 | 572 |
573 /* Check if the conversation has been previously started */ | 573 /* Check if the conversation has been previously started */ |
574 if (bb->conversation == NULL) | 574 if (bb->conversation == NULL) |
575 { | 575 { |
576 bb->conversation = bonjour_jabber_conv_new(); | 576 bb->conversation = bonjour_jabber_conv_new(pb); |
577 | 577 |
578 if (!bonjour_jabber_stream_init(pb, client_socket)) { | 578 if (!bonjour_jabber_stream_init(pb, client_socket)) { |
579 close(client_socket); | 579 close(client_socket); |
580 return; | 580 return; |
581 } | 581 } |
750 if (connect_data == NULL) { | 750 if (connect_data == NULL) { |
751 purple_debug_error("bonjour", "Unable to connect to buddy (%s).\n", to); | 751 purple_debug_error("bonjour", "Unable to connect to buddy (%s).\n", to); |
752 return NULL; | 752 return NULL; |
753 } | 753 } |
754 | 754 |
755 bb->conversation = bonjour_jabber_conv_new(); | 755 bb->conversation = bonjour_jabber_conv_new(pb); |
756 bb->conversation->connect_data = connect_data; | 756 bb->conversation->connect_data = connect_data; |
757 /* We don't want _send_data() to register the tx_handler; | 757 /* We don't want _send_data() to register the tx_handler; |
758 * that neeeds to wait until we're actually connected. */ | 758 * that neeeds to wait until we're actually connected. */ |
759 bb->conversation->tx_handler = 0; | 759 bb->conversation->tx_handler = 0; |
760 } | 760 } |
814 } | 814 } |
815 | 815 |
816 void | 816 void |
817 bonjour_jabber_close_conversation(BonjourJabberConversation *bconv) | 817 bonjour_jabber_close_conversation(BonjourJabberConversation *bconv) |
818 { | 818 { |
819 if (bconv != NULL) | 819 if (bconv != NULL) { |
820 { | 820 GList *xfers, *tmp_next; |
821 BonjourData *bd = bconv->pb->account->gc->proto_data; | |
822 | |
823 /* Cancel any file transfers that are waiting to begin */ | |
824 xfers = bd->xfer_lists; | |
825 while(xfers != NULL) { | |
826 PurpleXfer *xfer = xfers->data; | |
827 tmp_next = xfers->next; | |
828 /* We only need to cancel this if it hasn't actually started transferring. */ | |
829 /* This will change if we ever support IBB transfers. */ | |
830 if (strcmp(xfer->who, bconv->pb->name) == 0 | |
831 && (purple_xfer_get_status(xfer) == PURPLE_XFER_STATUS_NOT_STARTED | |
832 || purple_xfer_get_status(xfer) == PURPLE_XFER_STATUS_UNKNOWN)) { | |
833 purple_xfer_cancel_remote(xfer); | |
834 } | |
835 xfers = tmp_next; | |
836 } | |
837 | |
821 /* Close the socket and remove the watcher */ | 838 /* Close the socket and remove the watcher */ |
822 if (bconv->socket >= 0) { | 839 if (bconv->socket >= 0) { |
823 /* Send the end of the stream to the other end of the conversation */ | 840 /* Send the end of the stream to the other end of the conversation */ |
824 if (bconv->sent_stream_start) | 841 if (bconv->sent_stream_start) |
825 send(bconv->socket, STREAM_END, strlen(STREAM_END), 0); | 842 send(bconv->socket, STREAM_END, strlen(STREAM_END), 0); |
872 g_slist_free(buddies); | 889 g_slist_free(buddies); |
873 } | 890 } |
874 } | 891 } |
875 | 892 |
876 XepIq * | 893 XepIq * |
877 xep_iq_new(void *data, XepIqType type, const gchar *to, const gchar *id) | 894 xep_iq_new(void *data, XepIqType type, const char *to, const char *from, const char *id) |
878 { | 895 { |
879 xmlnode *iq_node = NULL; | 896 xmlnode *iq_node = NULL; |
880 XepIq *iq = NULL; | 897 XepIq *iq = NULL; |
881 | 898 |
882 g_return_val_if_fail(data != NULL, NULL); | 899 g_return_val_if_fail(data != NULL, NULL); |
884 g_return_val_if_fail(id != NULL, NULL); | 901 g_return_val_if_fail(id != NULL, NULL); |
885 | 902 |
886 iq_node = xmlnode_new("iq"); | 903 iq_node = xmlnode_new("iq"); |
887 | 904 |
888 xmlnode_set_attrib(iq_node, "to", to); | 905 xmlnode_set_attrib(iq_node, "to", to); |
906 xmlnode_set_attrib(iq_node, "from", from); | |
889 xmlnode_set_attrib(iq_node, "id", id); | 907 xmlnode_set_attrib(iq_node, "id", id); |
890 switch (type) { | 908 switch (type) { |
891 case XEP_IQ_SET: | 909 case XEP_IQ_SET: |
892 xmlnode_set_attrib(iq_node, "type", "set"); | 910 xmlnode_set_attrib(iq_node, "type", "set"); |
893 break; | 911 break; |
909 iq = g_new0(XepIq, 1); | 927 iq = g_new0(XepIq, 1); |
910 iq->node = iq_node; | 928 iq->node = iq_node; |
911 iq->type = type; | 929 iq->type = type; |
912 iq->data = ((BonjourData*)data)->jabber_data; | 930 iq->data = ((BonjourData*)data)->jabber_data; |
913 iq->to = (char*)to; | 931 iq->to = (char*)to; |
932 | |
914 return iq; | 933 return iq; |
915 } | 934 } |
916 | 935 |
917 static gboolean | 936 static gboolean |
918 check_if_blocked(PurpleBuddy *pb) | 937 check_if_blocked(PurpleBuddy *pb) |