| 371 void bonjour_jabber_process_packet(PurpleBuddy *pb, PurpleXmlNode *packet) { |
371 void bonjour_jabber_process_packet(PurpleBuddy *pb, PurpleXmlNode *packet) { |
| 372 |
372 |
| 373 g_return_if_fail(packet != NULL); |
373 g_return_if_fail(packet != NULL); |
| 374 g_return_if_fail(pb != NULL); |
374 g_return_if_fail(pb != NULL); |
| 375 |
375 |
| 376 if (!strcmp(packet->name, "message")) |
376 if (g_strcmp0(packet->name, "message") == 0) |
| 377 _jabber_parse_and_write_message_to_ui(packet, pb); |
377 _jabber_parse_and_write_message_to_ui(packet, pb); |
| 378 else if(!strcmp(packet->name, "iq")) |
378 else if (g_strcmp0(packet->name, "iq") == 0) |
| 379 xep_iq_parse(packet, pb); |
379 xep_iq_parse(packet, pb); |
| 380 else |
380 else { |
| 381 purple_debug_warning("bonjour", "Unknown packet: %s\n", packet->name ? packet->name : "(null)"); |
381 purple_debug_warning("bonjour", "Unknown packet: %s\n", |
| |
382 packet->name ? packet->name : "(null)"); |
| |
383 } |
| 382 } |
384 } |
| 383 |
385 |
| 384 static void bonjour_jabber_stream_ended(BonjourJabberConversation *bconv) { |
386 static void bonjour_jabber_stream_ended(BonjourJabberConversation *bconv) { |
| 385 |
387 |
| 386 /* Inform the user that the conversation has been closed */ |
388 /* Inform the user that the conversation has been closed */ |
| 654 return; |
656 return; |
| 655 |
657 |
| 656 flags = fcntl(client_socket, F_GETFL); |
658 flags = fcntl(client_socket, F_GETFL); |
| 657 fcntl(client_socket, F_SETFL, flags | O_NONBLOCK); |
659 fcntl(client_socket, F_SETFL, flags | O_NONBLOCK); |
| 658 #ifndef _WIN32 |
660 #ifndef _WIN32 |
| 659 fcntl(client_socket, F_SETFD, FD_CLOEXEC); |
661 if (fcntl(client_socket, F_SETFD, FD_CLOEXEC) != 0) |
| |
662 purple_debug_warning("bonjour", "jabber: couldn't set FD_CLOEXEC\n"); |
| 660 #endif |
663 #endif |
| 661 |
664 |
| 662 /* Look for the buddy that has opened the conversation and fill information */ |
665 /* Look for the buddy that has opened the conversation and fill information */ |
| 663 #ifdef HAVE_INET_NTOP |
666 #ifdef HAVE_INET_NTOP |
| 664 if (their_addr.sa.sa_family == AF_INET6) { |
667 if (their_addr.sa.sa_family == AF_INET6) { |
| 773 #ifdef PF_INET6 |
776 #ifdef PF_INET6 |
| 774 if (jdata->socket6 != -1) { |
777 if (jdata->socket6 != -1) { |
| 775 common_sockaddr_t addr6; |
778 common_sockaddr_t addr6; |
| 776 #ifdef IPV6_V6ONLY |
779 #ifdef IPV6_V6ONLY |
| 777 int on = 1; |
780 int on = 1; |
| 778 setsockopt(jdata->socket6, IPPROTO_IPV6, IPV6_V6ONLY, &on, sizeof(on)); |
781 if (setsockopt(jdata->socket6, IPPROTO_IPV6, IPV6_V6ONLY, &on, sizeof(on)) != 0) { |
| |
782 purple_debug_error("bonjour", "couldn't force IPv6\n"); |
| |
783 return -1; |
| |
784 } |
| 779 #endif |
785 #endif |
| 780 memset(&addr6, 0, sizeof(addr6)); |
786 memset(&addr6, 0, sizeof(addr6)); |
| 781 addr6.in6.sin6_family = AF_INET6; |
787 addr6.in6.sin6_family = AF_INET6; |
| 782 addr6.in6.sin6_port = htons(jdata->port); |
788 addr6.in6.sin6_port = htons(jdata->port); |
| 783 addr6.in6.sin6_addr = in6addr_any; |
789 addr6.in6.sin6_addr = in6addr_any; |
| 1175 } |
1181 } |
| 1176 |
1182 |
| 1177 /* Close the socket and remove the watcher */ |
1183 /* Close the socket and remove the watcher */ |
| 1178 if (bconv->socket >= 0) { |
1184 if (bconv->socket >= 0) { |
| 1179 /* Send the end of the stream to the other end of the conversation */ |
1185 /* Send the end of the stream to the other end of the conversation */ |
| 1180 if (bconv->sent_stream_start == FULLY_SENT) |
1186 if (bconv->sent_stream_start == FULLY_SENT) { |
| 1181 send(bconv->socket, STREAM_END, strlen(STREAM_END), 0); |
1187 size_t len = strlen(STREAM_END); |
| |
1188 if (send(bconv->socket, STREAM_END, len, 0) != len) { |
| |
1189 purple_debug_error("bonjour", |
| |
1190 "bonjour_jabber_close_conversation: " |
| |
1191 "couldn't send data\n"); |
| |
1192 } |
| |
1193 } |
| 1182 /* TODO: We're really supposed to wait for "</stream:stream>" before closing the socket */ |
1194 /* TODO: We're really supposed to wait for "</stream:stream>" before closing the socket */ |
| 1183 close(bconv->socket); |
1195 close(bconv->socket); |
| 1184 } |
1196 } |
| 1185 if (bconv->rx_handler != 0) |
1197 if (bconv->rx_handler != 0) |
| 1186 purple_input_remove(bconv->rx_handler); |
1198 purple_input_remove(bconv->rx_handler); |