Mercurial > pidgin
comparison libpurple/protocols/jabber/si.c @ 29315:7b1cfd48beab
propagate from branch 'im.pidgin.cpw.attention_ui' (head 3d97b094123bd082b1438ea44cb25169aa41315c)
to branch 'im.pidgin.pidgin.next.minor' (head d00241305ccc36eef5bd6723980b66a2e6108856)
author | Marcus Lundblad <ml@update.uu.se> |
---|---|
date | Mon, 16 Nov 2009 22:06:27 +0000 |
parents | e77894113a14 |
children | c4f836780e1c |
comparison
equal
deleted
inserted
replaced
29314:c783f9e66171 | 29315:7b1cfd48beab |
---|---|
851 xmlnode_set_attrib(query, "sid", jsx->stream_id); | 851 xmlnode_set_attrib(query, "sid", jsx->stream_id); |
852 | 852 |
853 /* If we successfully started listening locally */ | 853 /* If we successfully started listening locally */ |
854 if (sock >= 0) { | 854 if (sock >= 0) { |
855 gchar *jid; | 855 gchar *jid; |
856 const char *local_ip, *public_ip; | 856 GList *local_ips = |
857 | 857 purple_network_get_all_local_system_ips(); |
858 const char *public_ip; | |
859 gboolean has_public_ip = FALSE; | |
860 | |
858 jsx->local_streamhost_fd = sock; | 861 jsx->local_streamhost_fd = sock; |
859 | 862 |
860 jid = g_strdup_printf("%s@%s/%s", jsx->js->user->node, | 863 jid = g_strdup_printf("%s@%s/%s", jsx->js->user->node, |
861 jsx->js->user->domain, jsx->js->user->resource); | 864 jsx->js->user->domain, jsx->js->user->resource); |
862 xfer->local_port = purple_network_get_port_from_fd(sock); | 865 xfer->local_port = purple_network_get_port_from_fd(sock); |
863 g_snprintf(port, sizeof(port), "%hu", xfer->local_port); | 866 g_snprintf(port, sizeof(port), "%hu", xfer->local_port); |
864 | 867 |
865 /* Include the localhost's IP (for in-network transfers) */ | 868 public_ip = purple_network_get_my_ip(jsx->js->fd); |
866 local_ip = purple_network_get_local_system_ip(jsx->js->fd); | 869 |
867 if (strcmp(local_ip, "0.0.0.0") != 0) { | 870 /* Include the localhost's IPs (for in-network transfers) */ |
871 while (local_ips) { | |
872 gchar *local_ip = local_ips->data; | |
868 streamhost_count++; | 873 streamhost_count++; |
869 streamhost = xmlnode_new_child(query, "streamhost"); | 874 streamhost = xmlnode_new_child(query, "streamhost"); |
870 xmlnode_set_attrib(streamhost, "jid", jid); | 875 xmlnode_set_attrib(streamhost, "jid", jid); |
871 xmlnode_set_attrib(streamhost, "host", local_ip); | 876 xmlnode_set_attrib(streamhost, "host", local_ip); |
872 xmlnode_set_attrib(streamhost, "port", port); | 877 xmlnode_set_attrib(streamhost, "port", port); |
878 if (purple_strequal(local_ip, public_ip)) | |
879 has_public_ip = TRUE; | |
880 g_free(local_ip); | |
881 local_ips = g_list_delete_link(local_ips, local_ips); | |
873 } | 882 } |
874 | 883 |
875 /* Include the public IP (assuming that there is a port mapped somehow) */ | 884 /* Include the public IP (assuming that there is a port mapped somehow) */ |
876 public_ip = purple_network_get_my_ip(jsx->js->fd); | 885 if (!has_public_ip && strcmp(public_ip, "0.0.0.0") != 0) { |
877 if (strcmp(public_ip, local_ip) != 0 && strcmp(public_ip, "0.0.0.0") != 0) { | |
878 streamhost_count++; | 886 streamhost_count++; |
879 streamhost = xmlnode_new_child(query, "streamhost"); | 887 streamhost = xmlnode_new_child(query, "streamhost"); |
880 xmlnode_set_attrib(streamhost, "jid", jid); | 888 xmlnode_set_attrib(streamhost, "jid", jid); |
881 xmlnode_set_attrib(streamhost, "host", public_ip); | 889 xmlnode_set_attrib(streamhost, "host", public_ip); |
882 xmlnode_set_attrib(streamhost, "port", port); | 890 xmlnode_set_attrib(streamhost, "port", port); |