Thu, 13 Feb 2014 21:59:24 +0530
Merged default branch
| 11477 | 1 | /* |
| 15884 | 2 | * purple - Bonjour Protocol Plugin |
| 11477 | 3 | * |
| 15884 | 4 | * Purple is the legal property of its developers, whose names are too numerous |
| 11477 | 5 | * to list here. Please refer to the COPYRIGHT file distributed with this |
| 6 | * source distribution. | |
| 7 | * | |
| 8 | * This program is free software; you can redistribute it and/or modify | |
| 9 | * it under the terms of the GNU General Public License as published by | |
| 10 | * the Free Software Foundation; either version 2 of the License, or | |
| 11 | * (at your option) any later version. | |
| 12 | * | |
| 13 | * This program is distributed in the hope that it will be useful, | |
| 14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | |
| 15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
| 16 | * GNU General Public License for more details. | |
| 17 | * | |
| 18 | * You should have received a copy of the GNU General Public License | |
| 19 | * along with this program; if not, write to the Free Software | |
|
19859
71d37b57eff2
The FSF changed its address a while ago; our files were out of date.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
19832
diff
changeset
|
20 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02111-1301 USA |
| 11477 | 21 | */ |
|
21720
235394d5c7f4
Pull a bunch of bugfix only changes to im.pidgin.pidgin.2.3.1,
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
21638
diff
changeset
|
22 | |
|
235394d5c7f4
Pull a bunch of bugfix only changes to im.pidgin.pidgin.2.3.1,
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
21638
diff
changeset
|
23 | #include "internal.h" |
|
235394d5c7f4
Pull a bunch of bugfix only changes to im.pidgin.pidgin.2.3.1,
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
21638
diff
changeset
|
24 | |
|
11688
d5a7c35ddc80
[gaim-migrate @ 13974]
Daniel Atallah <datallah@pidgin.im>
parents:
11539
diff
changeset
|
25 | #ifndef _WIN32 |
|
21524
472e58992083
Patch from some Intel folks to implement file transfer in Bonjour using XEP-0096 and 0065. This hopefully will work with Gaijm (haven't yet tested) and, of course, between libpurple instances; it will not work with Adium or iChat.
Daniel Atallah <datallah@pidgin.im>
parents:
21503
diff
changeset
|
26 | #include <net/if.h> |
|
472e58992083
Patch from some Intel folks to implement file transfer in Bonjour using XEP-0096 and 0065. This hopefully will work with Gaijm (haven't yet tested) and, of course, between libpurple instances; it will not work with Adium or iChat.
Daniel Atallah <datallah@pidgin.im>
parents:
21503
diff
changeset
|
27 | #include <sys/ioctl.h> |
| 11477 | 28 | #include <sys/socket.h> |
| 29 | #include <netinet/in.h> | |
| 30 | #include <arpa/inet.h> | |
|
11688
d5a7c35ddc80
[gaim-migrate @ 13974]
Daniel Atallah <datallah@pidgin.im>
parents:
11539
diff
changeset
|
31 | #else |
|
d5a7c35ddc80
[gaim-migrate @ 13974]
Daniel Atallah <datallah@pidgin.im>
parents:
11539
diff
changeset
|
32 | #include "libc_interface.h" |
|
d5a7c35ddc80
[gaim-migrate @ 13974]
Daniel Atallah <datallah@pidgin.im>
parents:
11539
diff
changeset
|
33 | #endif |
|
d5a7c35ddc80
[gaim-migrate @ 13974]
Daniel Atallah <datallah@pidgin.im>
parents:
11539
diff
changeset
|
34 | #include <sys/types.h> |
| 21917 | 35 | |
| 36 | /* Solaris */ | |
| 37 | #if defined (__SVR4) && defined (__sun) | |
| 38 | #include <sys/sockio.h> | |
| 39 | #endif | |
| 40 | ||
| 11477 | 41 | #include <glib.h> |
|
23072
6e7c147d622a
Bonjour build fixes for MSVC.
Daniel Atallah <datallah@pidgin.im>
parents:
22824
diff
changeset
|
42 | #ifdef HAVE_UNISTD_H |
| 11477 | 43 | #include <unistd.h> |
|
23072
6e7c147d622a
Bonjour build fixes for MSVC.
Daniel Atallah <datallah@pidgin.im>
parents:
22824
diff
changeset
|
44 | #endif |
| 11477 | 45 | #include <fcntl.h> |
| 46 | ||
|
29761
0f6862f2782f
Implementation of IPv6 support for Bonjour
Daniel Atallah <datallah@pidgin.im>
parents:
27625
diff
changeset
|
47 | #ifdef HAVE_GETIFADDRS |
|
0f6862f2782f
Implementation of IPv6 support for Bonjour
Daniel Atallah <datallah@pidgin.im>
parents:
27625
diff
changeset
|
48 | #include <ifaddrs.h> |
|
0f6862f2782f
Implementation of IPv6 support for Bonjour
Daniel Atallah <datallah@pidgin.im>
parents:
27625
diff
changeset
|
49 | #endif |
|
0f6862f2782f
Implementation of IPv6 support for Bonjour
Daniel Atallah <datallah@pidgin.im>
parents:
27625
diff
changeset
|
50 | |
|
0f6862f2782f
Implementation of IPv6 support for Bonjour
Daniel Atallah <datallah@pidgin.im>
parents:
27625
diff
changeset
|
51 | |
| 11477 | 52 | #include "network.h" |
| 53 | #include "eventloop.h" | |
| 54 | #include "connection.h" | |
|
34706
02cb08146888
Renamed blist.[ch] to buddylist.[ch]
Ankit Vani <a@nevitus.org>
parents:
34632
diff
changeset
|
55 | #include "buddylist.h" |
| 11477 | 56 | #include "xmlnode.h" |
| 57 | #include "debug.h" | |
| 58 | #include "notify.h" | |
| 59 | #include "util.h" | |
| 60 | ||
| 61 | #include "jabber.h" | |
|
19056
05cd9ab28312
Update the Bonjour prpl to use libxml explicitly instead of the xml_node stuff. This allows us to deal with partial reads. I also fixed issues related to starting conversations with iChat and a couple other things. Fixes #2022,#1652
Daniel Atallah <datallah@pidgin.im>
parents:
18947
diff
changeset
|
62 | #include "parser.h" |
| 11477 | 63 | #include "bonjour.h" |
| 64 | #include "buddy.h" | |
|
34911
8b46f11b9e7e
Refactored bonjour and irc to use the GObject xfer API
Ankit Vani <a@nevitus.org>
parents:
34910
diff
changeset
|
65 | #include "bonjour_ft.h" |
|
21524
472e58992083
Patch from some Intel folks to implement file transfer in Bonjour using XEP-0096 and 0065. This hopefully will work with Gaijm (haven't yet tested) and, of course, between libpurple instances; it will not work with Adium or iChat.
Daniel Atallah <datallah@pidgin.im>
parents:
21503
diff
changeset
|
66 | |
|
472e58992083
Patch from some Intel folks to implement file transfer in Bonjour using XEP-0096 and 0065. This hopefully will work with Gaijm (haven't yet tested) and, of course, between libpurple instances; it will not work with Adium or iChat.
Daniel Atallah <datallah@pidgin.im>
parents:
21503
diff
changeset
|
67 | #ifdef _SIZEOF_ADDR_IFREQ |
|
472e58992083
Patch from some Intel folks to implement file transfer in Bonjour using XEP-0096 and 0065. This hopefully will work with Gaijm (haven't yet tested) and, of course, between libpurple instances; it will not work with Adium or iChat.
Daniel Atallah <datallah@pidgin.im>
parents:
21503
diff
changeset
|
68 | # define HX_SIZE_OF_IFREQ(a) _SIZEOF_ADDR_IFREQ(a) |
|
472e58992083
Patch from some Intel folks to implement file transfer in Bonjour using XEP-0096 and 0065. This hopefully will work with Gaijm (haven't yet tested) and, of course, between libpurple instances; it will not work with Adium or iChat.
Daniel Atallah <datallah@pidgin.im>
parents:
21503
diff
changeset
|
69 | #else |
|
472e58992083
Patch from some Intel folks to implement file transfer in Bonjour using XEP-0096 and 0065. This hopefully will work with Gaijm (haven't yet tested) and, of course, between libpurple instances; it will not work with Adium or iChat.
Daniel Atallah <datallah@pidgin.im>
parents:
21503
diff
changeset
|
70 | # define HX_SIZE_OF_IFREQ(a) sizeof(a) |
|
472e58992083
Patch from some Intel folks to implement file transfer in Bonjour using XEP-0096 and 0065. This hopefully will work with Gaijm (haven't yet tested) and, of course, between libpurple instances; it will not work with Adium or iChat.
Daniel Atallah <datallah@pidgin.im>
parents:
21503
diff
changeset
|
71 | #endif |
| 11477 | 72 | |
|
17661
96c6a21c4139
Send 'to' and 'from' attributes in the stream start message.
Daniel Atallah <datallah@pidgin.im>
parents:
17660
diff
changeset
|
73 | #define STREAM_END "</stream:stream>" |
|
96c6a21c4139
Send 'to' and 'from' attributes in the stream start message.
Daniel Atallah <datallah@pidgin.im>
parents:
17660
diff
changeset
|
74 | /* TODO: specify version='1.0' and send stream features */ |
|
96c6a21c4139
Send 'to' and 'from' attributes in the stream start message.
Daniel Atallah <datallah@pidgin.im>
parents:
17660
diff
changeset
|
75 | #define DOCTYPE "<?xml version=\"1.0\" encoding=\"UTF-8\" ?>\n" \ |
|
96c6a21c4139
Send 'to' and 'from' attributes in the stream start message.
Daniel Atallah <datallah@pidgin.im>
parents:
17660
diff
changeset
|
76 | "<stream:stream xmlns=\"jabber:client\" xmlns:stream=\"http://etherx.jabber.org/streams\" from=\"%s\" to=\"%s\">" |
|
96c6a21c4139
Send 'to' and 'from' attributes in the stream start message.
Daniel Atallah <datallah@pidgin.im>
parents:
17660
diff
changeset
|
77 | |
|
21727
decfc3a613ff
applied changes from b9c97ed0f9ada9069e8bd994b01fdde0b484083c
Daniel Atallah <datallah@pidgin.im>
parents:
21720
diff
changeset
|
78 | enum sent_stream_start_types { |
|
decfc3a613ff
applied changes from b9c97ed0f9ada9069e8bd994b01fdde0b484083c
Daniel Atallah <datallah@pidgin.im>
parents:
21720
diff
changeset
|
79 | NOT_SENT = 0, |
|
decfc3a613ff
applied changes from b9c97ed0f9ada9069e8bd994b01fdde0b484083c
Daniel Atallah <datallah@pidgin.im>
parents:
21720
diff
changeset
|
80 | PARTIALLY_SENT = 1, |
|
decfc3a613ff
applied changes from b9c97ed0f9ada9069e8bd994b01fdde0b484083c
Daniel Atallah <datallah@pidgin.im>
parents:
21720
diff
changeset
|
81 | FULLY_SENT = 2 |
|
decfc3a613ff
applied changes from b9c97ed0f9ada9069e8bd994b01fdde0b484083c
Daniel Atallah <datallah@pidgin.im>
parents:
21720
diff
changeset
|
82 | }; |
|
decfc3a613ff
applied changes from b9c97ed0f9ada9069e8bd994b01fdde0b484083c
Daniel Atallah <datallah@pidgin.im>
parents:
21720
diff
changeset
|
83 | |
|
21524
472e58992083
Patch from some Intel folks to implement file transfer in Bonjour using XEP-0096 and 0065. This hopefully will work with Gaijm (haven't yet tested) and, of course, between libpurple instances; it will not work with Adium or iChat.
Daniel Atallah <datallah@pidgin.im>
parents:
21503
diff
changeset
|
84 | static void |
|
34935
686fa55b0deb
Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents:
34911
diff
changeset
|
85 | xep_iq_parse(PurpleXmlNode *packet, PurpleBuddy *pb); |
|
21524
472e58992083
Patch from some Intel folks to implement file transfer in Bonjour using XEP-0096 and 0065. This hopefully will work with Gaijm (haven't yet tested) and, of course, between libpurple instances; it will not work with Adium or iChat.
Daniel Atallah <datallah@pidgin.im>
parents:
21503
diff
changeset
|
86 | |
|
17662
233ff0515d7b
Consolidate BonjourJabberConversation creation and deletion.
Daniel Atallah <datallah@pidgin.im>
parents:
17661
diff
changeset
|
87 | static BonjourJabberConversation * |
|
21944
c41d17a1b8d9
This is the second part of the fix to support having multiple presence records in Bonjour (and also supporting multiple presences using the same IP). Incoming conversations are no longer immediately attached to a buddy - we use an algorithm to match a conversation to a buddy based on the IP and, if possible the "from" attribute of the stream or the first tag in the stream. Thanks to Sjoerd Simons from Telepahy Salut for noticing and suggesting the algorithm. Fixes #4187. It'd be good if a few people test this.
Daniel Atallah <datallah@pidgin.im>
parents:
21936
diff
changeset
|
88 | bonjour_jabber_conv_new(PurpleBuddy *pb, PurpleAccount *account, const char *ip) { |
|
17662
233ff0515d7b
Consolidate BonjourJabberConversation creation and deletion.
Daniel Atallah <datallah@pidgin.im>
parents:
17661
diff
changeset
|
89 | |
|
233ff0515d7b
Consolidate BonjourJabberConversation creation and deletion.
Daniel Atallah <datallah@pidgin.im>
parents:
17661
diff
changeset
|
90 | BonjourJabberConversation *bconv = g_new0(BonjourJabberConversation, 1); |
|
233ff0515d7b
Consolidate BonjourJabberConversation creation and deletion.
Daniel Atallah <datallah@pidgin.im>
parents:
17661
diff
changeset
|
91 | bconv->socket = -1; |
|
34529
68cf25486001
GObjectify PurpleCircBuffer as PurpleCircularBuffer (from gobjectification branch)
Ankit Vani <a@nevitus.org>
parents:
33892
diff
changeset
|
92 | bconv->tx_buf = purple_circular_buffer_new(512); |
|
19579
d79d5c95ce5a
Reset unsigned int input handlers to 0 instead of -1.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
19373
diff
changeset
|
93 | bconv->tx_handler = 0; |
|
d79d5c95ce5a
Reset unsigned int input handlers to 0 instead of -1.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
19373
diff
changeset
|
94 | bconv->rx_handler = 0; |
|
21609
30ca7a909e62
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.
Daniel Atallah <datallah@pidgin.im>
parents:
21549
diff
changeset
|
95 | bconv->pb = pb; |
|
21944
c41d17a1b8d9
This is the second part of the fix to support having multiple presence records in Bonjour (and also supporting multiple presences using the same IP). Incoming conversations are no longer immediately attached to a buddy - we use an algorithm to match a conversation to a buddy based on the IP and, if possible the "from" attribute of the stream or the first tag in the stream. Thanks to Sjoerd Simons from Telepahy Salut for noticing and suggesting the algorithm. Fixes #4187. It'd be good if a few people test this.
Daniel Atallah <datallah@pidgin.im>
parents:
21936
diff
changeset
|
96 | bconv->account = account; |
|
c41d17a1b8d9
This is the second part of the fix to support having multiple presence records in Bonjour (and also supporting multiple presences using the same IP). Incoming conversations are no longer immediately attached to a buddy - we use an algorithm to match a conversation to a buddy based on the IP and, if possible the "from" attribute of the stream or the first tag in the stream. Thanks to Sjoerd Simons from Telepahy Salut for noticing and suggesting the algorithm. Fixes #4187. It'd be good if a few people test this.
Daniel Atallah <datallah@pidgin.im>
parents:
21936
diff
changeset
|
97 | bconv->ip = g_strdup(ip); |
|
17662
233ff0515d7b
Consolidate BonjourJabberConversation creation and deletion.
Daniel Atallah <datallah@pidgin.im>
parents:
17661
diff
changeset
|
98 | |
|
21727
decfc3a613ff
applied changes from b9c97ed0f9ada9069e8bd994b01fdde0b484083c
Daniel Atallah <datallah@pidgin.im>
parents:
21720
diff
changeset
|
99 | bonjour_parser_setup(bconv); |
|
decfc3a613ff
applied changes from b9c97ed0f9ada9069e8bd994b01fdde0b484083c
Daniel Atallah <datallah@pidgin.im>
parents:
21720
diff
changeset
|
100 | |
|
17662
233ff0515d7b
Consolidate BonjourJabberConversation creation and deletion.
Daniel Atallah <datallah@pidgin.im>
parents:
17661
diff
changeset
|
101 | return bconv; |
|
233ff0515d7b
Consolidate BonjourJabberConversation creation and deletion.
Daniel Atallah <datallah@pidgin.im>
parents:
17661
diff
changeset
|
102 | } |
|
233ff0515d7b
Consolidate BonjourJabberConversation creation and deletion.
Daniel Atallah <datallah@pidgin.im>
parents:
17661
diff
changeset
|
103 | |
|
12443
ad94864144f8
[gaim-migrate @ 14750]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
11830
diff
changeset
|
104 | static const char * |
| 15884 | 105 | _font_size_ichat_to_purple(int size) |
| 11477 | 106 | { |
| 107 | if (size > 24) { | |
|
11826
10ebbc41f163
[gaim-migrate @ 14117]
Richard Laager <rlaager@pidgin.im>
parents:
11823
diff
changeset
|
108 | return "7"; |
|
11539
fbabe3f89777
[gaim-migrate @ 13794]
Mark Doliner <markdoliner@pidgin.im>
parents:
11515
diff
changeset
|
109 | } else if (size >= 21) { |
|
11826
10ebbc41f163
[gaim-migrate @ 14117]
Richard Laager <rlaager@pidgin.im>
parents:
11823
diff
changeset
|
110 | return "6"; |
|
11539
fbabe3f89777
[gaim-migrate @ 13794]
Mark Doliner <markdoliner@pidgin.im>
parents:
11515
diff
changeset
|
111 | } else if (size >= 17) { |
|
11826
10ebbc41f163
[gaim-migrate @ 14117]
Richard Laager <rlaager@pidgin.im>
parents:
11823
diff
changeset
|
112 | return "5"; |
|
11539
fbabe3f89777
[gaim-migrate @ 13794]
Mark Doliner <markdoliner@pidgin.im>
parents:
11515
diff
changeset
|
113 | } else if (size >= 14) { |
|
11826
10ebbc41f163
[gaim-migrate @ 14117]
Richard Laager <rlaager@pidgin.im>
parents:
11823
diff
changeset
|
114 | return "4"; |
|
11539
fbabe3f89777
[gaim-migrate @ 13794]
Mark Doliner <markdoliner@pidgin.im>
parents:
11515
diff
changeset
|
115 | } else if (size >= 12) { |
|
11826
10ebbc41f163
[gaim-migrate @ 14117]
Richard Laager <rlaager@pidgin.im>
parents:
11823
diff
changeset
|
116 | return "3"; |
|
11539
fbabe3f89777
[gaim-migrate @ 13794]
Mark Doliner <markdoliner@pidgin.im>
parents:
11515
diff
changeset
|
117 | } else if (size >= 10) { |
|
11826
10ebbc41f163
[gaim-migrate @ 14117]
Richard Laager <rlaager@pidgin.im>
parents:
11823
diff
changeset
|
118 | return "2"; |
| 11477 | 119 | } |
| 120 | ||
|
11826
10ebbc41f163
[gaim-migrate @ 14117]
Richard Laager <rlaager@pidgin.im>
parents:
11823
diff
changeset
|
121 | return "1"; |
| 11477 | 122 | } |
|
17633
b76241c02857
Some more Bonjour cleanup and leak fixing.
Daniel Atallah <datallah@pidgin.im>
parents:
17632
diff
changeset
|
123 | |
|
22824
fba8507310d3
Fix an issue with formatting in Bonjour messages. It looks like it has been
Daniel Atallah <datallah@pidgin.im>
parents:
22622
diff
changeset
|
124 | static gchar * |
|
34935
686fa55b0deb
Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents:
34911
diff
changeset
|
125 | get_xmlnode_contents(PurpleXmlNode *node) |
|
22824
fba8507310d3
Fix an issue with formatting in Bonjour messages. It looks like it has been
Daniel Atallah <datallah@pidgin.im>
parents:
22622
diff
changeset
|
126 | { |
|
fba8507310d3
Fix an issue with formatting in Bonjour messages. It looks like it has been
Daniel Atallah <datallah@pidgin.im>
parents:
22622
diff
changeset
|
127 | gchar *contents; |
|
fba8507310d3
Fix an issue with formatting in Bonjour messages. It looks like it has been
Daniel Atallah <datallah@pidgin.im>
parents:
22622
diff
changeset
|
128 | |
|
34935
686fa55b0deb
Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents:
34911
diff
changeset
|
129 | contents = purple_xmlnode_to_str(node, NULL); |
|
22824
fba8507310d3
Fix an issue with formatting in Bonjour messages. It looks like it has been
Daniel Atallah <datallah@pidgin.im>
parents:
22622
diff
changeset
|
130 | |
|
fba8507310d3
Fix an issue with formatting in Bonjour messages. It looks like it has been
Daniel Atallah <datallah@pidgin.im>
parents:
22622
diff
changeset
|
131 | /* we just want the stuff inside <font></font> |
|
34935
686fa55b0deb
Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents:
34911
diff
changeset
|
132 | * There isn't stuff exposed in PurpleXmlNode.c to do this more cleanly. */ |
|
22824
fba8507310d3
Fix an issue with formatting in Bonjour messages. It looks like it has been
Daniel Atallah <datallah@pidgin.im>
parents:
22622
diff
changeset
|
133 | |
|
fba8507310d3
Fix an issue with formatting in Bonjour messages. It looks like it has been
Daniel Atallah <datallah@pidgin.im>
parents:
22622
diff
changeset
|
134 | if (contents) { |
|
fba8507310d3
Fix an issue with formatting in Bonjour messages. It looks like it has been
Daniel Atallah <datallah@pidgin.im>
parents:
22622
diff
changeset
|
135 | char *bodystart = strchr(contents, '>'); |
|
25096
55cf9c998554
Fix CID 399 - I'm reasonably sure this couldn't ever actually cause a NULL deref.
Daniel Atallah <datallah@pidgin.im>
parents:
25095
diff
changeset
|
136 | char *bodyend = bodystart ? strrchr(bodystart, '<') : NULL; |
|
22824
fba8507310d3
Fix an issue with formatting in Bonjour messages. It looks like it has been
Daniel Atallah <datallah@pidgin.im>
parents:
22622
diff
changeset
|
137 | if (bodystart && bodyend && (bodystart + 1) != bodyend) { |
|
fba8507310d3
Fix an issue with formatting in Bonjour messages. It looks like it has been
Daniel Atallah <datallah@pidgin.im>
parents:
22622
diff
changeset
|
138 | *bodyend = '\0'; |
|
fba8507310d3
Fix an issue with formatting in Bonjour messages. It looks like it has been
Daniel Atallah <datallah@pidgin.im>
parents:
22622
diff
changeset
|
139 | memmove(contents, bodystart + 1, (bodyend - bodystart)); |
|
fba8507310d3
Fix an issue with formatting in Bonjour messages. It looks like it has been
Daniel Atallah <datallah@pidgin.im>
parents:
22622
diff
changeset
|
140 | } |
|
fba8507310d3
Fix an issue with formatting in Bonjour messages. It looks like it has been
Daniel Atallah <datallah@pidgin.im>
parents:
22622
diff
changeset
|
141 | } |
|
fba8507310d3
Fix an issue with formatting in Bonjour messages. It looks like it has been
Daniel Atallah <datallah@pidgin.im>
parents:
22622
diff
changeset
|
142 | |
|
fba8507310d3
Fix an issue with formatting in Bonjour messages. It looks like it has been
Daniel Atallah <datallah@pidgin.im>
parents:
22622
diff
changeset
|
143 | return contents; |
|
fba8507310d3
Fix an issue with formatting in Bonjour messages. It looks like it has been
Daniel Atallah <datallah@pidgin.im>
parents:
22622
diff
changeset
|
144 | } |
|
fba8507310d3
Fix an issue with formatting in Bonjour messages. It looks like it has been
Daniel Atallah <datallah@pidgin.im>
parents:
22622
diff
changeset
|
145 | |
|
12443
ad94864144f8
[gaim-migrate @ 14750]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
11830
diff
changeset
|
146 | static void |
|
34935
686fa55b0deb
Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents:
34911
diff
changeset
|
147 | _jabber_parse_and_write_message_to_ui(PurpleXmlNode *message_node, PurpleBuddy *pb) |
| 11477 | 148 | { |
|
34935
686fa55b0deb
Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents:
34911
diff
changeset
|
149 | PurpleXmlNode *body_node, *html_node, *events_node; |
|
24562
22ed1e1ef32f
More Bonjour struct hiding fixes.
Richard Laager <rlaager@pidgin.im>
parents:
24333
diff
changeset
|
150 | PurpleConnection *gc = purple_account_get_connection(purple_buddy_get_account(pb)); |
|
21936
79f3a365cffb
Cleanup to prevent unnecessary alloc/free. Also a small fix to remove the possiblity that a message will be sent before the stream is started.
Daniel Atallah <datallah@pidgin.im>
parents:
21920
diff
changeset
|
151 | gchar *body = NULL; |
| 11477 | 152 | |
|
34935
686fa55b0deb
Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents:
34911
diff
changeset
|
153 | body_node = purple_xmlnode_get_child(message_node, "body"); |
|
686fa55b0deb
Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents:
34911
diff
changeset
|
154 | html_node = purple_xmlnode_get_child(message_node, "html"); |
|
21936
79f3a365cffb
Cleanup to prevent unnecessary alloc/free. Also a small fix to remove the possiblity that a message will be sent before the stream is started.
Daniel Atallah <datallah@pidgin.im>
parents:
21920
diff
changeset
|
155 | |
|
79f3a365cffb
Cleanup to prevent unnecessary alloc/free. Also a small fix to remove the possiblity that a message will be sent before the stream is started.
Daniel Atallah <datallah@pidgin.im>
parents:
21920
diff
changeset
|
156 | if (body_node == NULL && html_node == NULL) { |
|
79f3a365cffb
Cleanup to prevent unnecessary alloc/free. Also a small fix to remove the possiblity that a message will be sent before the stream is started.
Daniel Atallah <datallah@pidgin.im>
parents:
21920
diff
changeset
|
157 | purple_debug_error("bonjour", "No body or html node found, discarding message.\n"); |
| 11477 | 158 | return; |
|
21936
79f3a365cffb
Cleanup to prevent unnecessary alloc/free. Also a small fix to remove the possiblity that a message will be sent before the stream is started.
Daniel Atallah <datallah@pidgin.im>
parents:
21920
diff
changeset
|
159 | } |
|
11539
fbabe3f89777
[gaim-migrate @ 13794]
Mark Doliner <markdoliner@pidgin.im>
parents:
11515
diff
changeset
|
160 | |
|
34935
686fa55b0deb
Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents:
34911
diff
changeset
|
161 | events_node = purple_xmlnode_get_child_with_namespace(message_node, "x", "jabber:x:event"); |
|
21936
79f3a365cffb
Cleanup to prevent unnecessary alloc/free. Also a small fix to remove the possiblity that a message will be sent before the stream is started.
Daniel Atallah <datallah@pidgin.im>
parents:
21920
diff
changeset
|
162 | if (events_node != NULL) { |
|
33892
ef97228bc5f0
Fix most of warnings for gtk2 and linux
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33799
diff
changeset
|
163 | #if 0 |
|
34935
686fa55b0deb
Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents:
34911
diff
changeset
|
164 | if (purple_xmlnode_get_child(events_node, "composing") != NULL) |
|
21936
79f3a365cffb
Cleanup to prevent unnecessary alloc/free. Also a small fix to remove the possiblity that a message will be sent before the stream is started.
Daniel Atallah <datallah@pidgin.im>
parents:
21920
diff
changeset
|
165 | composing_event = TRUE; |
|
33892
ef97228bc5f0
Fix most of warnings for gtk2 and linux
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33799
diff
changeset
|
166 | #endif |
|
34935
686fa55b0deb
Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents:
34911
diff
changeset
|
167 | if (purple_xmlnode_get_child(events_node, "id") != NULL) { |
|
21936
79f3a365cffb
Cleanup to prevent unnecessary alloc/free. Also a small fix to remove the possiblity that a message will be sent before the stream is started.
Daniel Atallah <datallah@pidgin.im>
parents:
21920
diff
changeset
|
168 | /* The user is just typing */ |
|
79f3a365cffb
Cleanup to prevent unnecessary alloc/free. Also a small fix to remove the possiblity that a message will be sent before the stream is started.
Daniel Atallah <datallah@pidgin.im>
parents:
21920
diff
changeset
|
169 | /* TODO: Deal with typing notification */ |
|
79f3a365cffb
Cleanup to prevent unnecessary alloc/free. Also a small fix to remove the possiblity that a message will be sent before the stream is started.
Daniel Atallah <datallah@pidgin.im>
parents:
21920
diff
changeset
|
170 | return; |
|
79f3a365cffb
Cleanup to prevent unnecessary alloc/free. Also a small fix to remove the possiblity that a message will be sent before the stream is started.
Daniel Atallah <datallah@pidgin.im>
parents:
21920
diff
changeset
|
171 | } |
|
79f3a365cffb
Cleanup to prevent unnecessary alloc/free. Also a small fix to remove the possiblity that a message will be sent before the stream is started.
Daniel Atallah <datallah@pidgin.im>
parents:
21920
diff
changeset
|
172 | } |
|
79f3a365cffb
Cleanup to prevent unnecessary alloc/free. Also a small fix to remove the possiblity that a message will be sent before the stream is started.
Daniel Atallah <datallah@pidgin.im>
parents:
21920
diff
changeset
|
173 | |
|
79f3a365cffb
Cleanup to prevent unnecessary alloc/free. Also a small fix to remove the possiblity that a message will be sent before the stream is started.
Daniel Atallah <datallah@pidgin.im>
parents:
21920
diff
changeset
|
174 | if (html_node != NULL) { |
|
34935
686fa55b0deb
Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents:
34911
diff
changeset
|
175 | PurpleXmlNode *html_body_node; |
|
17633
b76241c02857
Some more Bonjour cleanup and leak fixing.
Daniel Atallah <datallah@pidgin.im>
parents:
17632
diff
changeset
|
176 | |
|
34935
686fa55b0deb
Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents:
34911
diff
changeset
|
177 | html_body_node = purple_xmlnode_get_child(html_node, "body"); |
|
21936
79f3a365cffb
Cleanup to prevent unnecessary alloc/free. Also a small fix to remove the possiblity that a message will be sent before the stream is started.
Daniel Atallah <datallah@pidgin.im>
parents:
21920
diff
changeset
|
178 | if (html_body_node != NULL) { |
|
34935
686fa55b0deb
Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents:
34911
diff
changeset
|
179 | PurpleXmlNode *html_body_font_node; |
|
17633
b76241c02857
Some more Bonjour cleanup and leak fixing.
Daniel Atallah <datallah@pidgin.im>
parents:
17632
diff
changeset
|
180 | |
|
34935
686fa55b0deb
Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents:
34911
diff
changeset
|
181 | html_body_font_node = purple_xmlnode_get_child(html_body_node, "font"); |
|
21936
79f3a365cffb
Cleanup to prevent unnecessary alloc/free. Also a small fix to remove the possiblity that a message will be sent before the stream is started.
Daniel Atallah <datallah@pidgin.im>
parents:
21920
diff
changeset
|
182 | /* Types of messages sent by iChat */ |
|
79f3a365cffb
Cleanup to prevent unnecessary alloc/free. Also a small fix to remove the possiblity that a message will be sent before the stream is started.
Daniel Atallah <datallah@pidgin.im>
parents:
21920
diff
changeset
|
183 | if (html_body_font_node != NULL) { |
|
79f3a365cffb
Cleanup to prevent unnecessary alloc/free. Also a small fix to remove the possiblity that a message will be sent before the stream is started.
Daniel Atallah <datallah@pidgin.im>
parents:
21920
diff
changeset
|
184 | gchar *html_body; |
|
33799
c8a9082d50d1
Apply libpurple3 changes to recently merged code.
Daniel Atallah <datallah@pidgin.im>
parents:
33796
diff
changeset
|
185 | const char *font_face, *font_size, *font_color, |
|
24196
864b0ca6577c
Don't arbitrarily default font settings when none are specified for incoming
Daniel Atallah <datallah@pidgin.im>
parents:
24039
diff
changeset
|
186 | *ichat_balloon_color, *ichat_text_color; |
|
21936
79f3a365cffb
Cleanup to prevent unnecessary alloc/free. Also a small fix to remove the possiblity that a message will be sent before the stream is started.
Daniel Atallah <datallah@pidgin.im>
parents:
21920
diff
changeset
|
187 | |
|
34935
686fa55b0deb
Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents:
34911
diff
changeset
|
188 | font_face = purple_xmlnode_get_attrib(html_body_font_node, "face"); |
|
11826
10ebbc41f163
[gaim-migrate @ 14117]
Richard Laager <rlaager@pidgin.im>
parents:
11823
diff
changeset
|
189 | /* The absolute iChat font sizes should be converted to 1..7 range */ |
|
34935
686fa55b0deb
Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents:
34911
diff
changeset
|
190 | font_size = purple_xmlnode_get_attrib(html_body_font_node, "ABSZ"); |
|
11539
fbabe3f89777
[gaim-migrate @ 13794]
Mark Doliner <markdoliner@pidgin.im>
parents:
11515
diff
changeset
|
191 | if (font_size != NULL) |
| 15884 | 192 | font_size = _font_size_ichat_to_purple(atoi(font_size)); |
|
34935
686fa55b0deb
Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents:
34911
diff
changeset
|
193 | font_color = purple_xmlnode_get_attrib(html_body_font_node, "color"); |
|
686fa55b0deb
Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents:
34911
diff
changeset
|
194 | ichat_balloon_color = purple_xmlnode_get_attrib(html_body_node, "ichatballooncolor"); |
|
686fa55b0deb
Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents:
34911
diff
changeset
|
195 | ichat_text_color = purple_xmlnode_get_attrib(html_body_node, "ichattextcolor"); |
|
24196
864b0ca6577c
Don't arbitrarily default font settings when none are specified for incoming
Daniel Atallah <datallah@pidgin.im>
parents:
24039
diff
changeset
|
196 | |
|
22824
fba8507310d3
Fix an issue with formatting in Bonjour messages. It looks like it has been
Daniel Atallah <datallah@pidgin.im>
parents:
22622
diff
changeset
|
197 | html_body = get_xmlnode_contents(html_body_font_node); |
|
21936
79f3a365cffb
Cleanup to prevent unnecessary alloc/free. Also a small fix to remove the possiblity that a message will be sent before the stream is started.
Daniel Atallah <datallah@pidgin.im>
parents:
21920
diff
changeset
|
198 | |
|
11539
fbabe3f89777
[gaim-migrate @ 13794]
Mark Doliner <markdoliner@pidgin.im>
parents:
11515
diff
changeset
|
199 | if (html_body == NULL) |
|
24196
864b0ca6577c
Don't arbitrarily default font settings when none are specified for incoming
Daniel Atallah <datallah@pidgin.im>
parents:
24039
diff
changeset
|
200 | /* This is the kind of formatted messages that Purple creates */ |
|
34935
686fa55b0deb
Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents:
34911
diff
changeset
|
201 | html_body = purple_xmlnode_to_str(html_body_font_node, NULL); |
|
21936
79f3a365cffb
Cleanup to prevent unnecessary alloc/free. Also a small fix to remove the possiblity that a message will be sent before the stream is started.
Daniel Atallah <datallah@pidgin.im>
parents:
21920
diff
changeset
|
202 | |
|
79f3a365cffb
Cleanup to prevent unnecessary alloc/free. Also a small fix to remove the possiblity that a message will be sent before the stream is started.
Daniel Atallah <datallah@pidgin.im>
parents:
21920
diff
changeset
|
203 | if (html_body != NULL) { |
|
24196
864b0ca6577c
Don't arbitrarily default font settings when none are specified for incoming
Daniel Atallah <datallah@pidgin.im>
parents:
24039
diff
changeset
|
204 | GString *str = g_string_new("<font"); |
|
21936
79f3a365cffb
Cleanup to prevent unnecessary alloc/free. Also a small fix to remove the possiblity that a message will be sent before the stream is started.
Daniel Atallah <datallah@pidgin.im>
parents:
21920
diff
changeset
|
205 | |
|
24196
864b0ca6577c
Don't arbitrarily default font settings when none are specified for incoming
Daniel Atallah <datallah@pidgin.im>
parents:
24039
diff
changeset
|
206 | if (font_face) |
|
864b0ca6577c
Don't arbitrarily default font settings when none are specified for incoming
Daniel Atallah <datallah@pidgin.im>
parents:
24039
diff
changeset
|
207 | g_string_append_printf(str, " face='%s'", font_face); |
|
864b0ca6577c
Don't arbitrarily default font settings when none are specified for incoming
Daniel Atallah <datallah@pidgin.im>
parents:
24039
diff
changeset
|
208 | if (font_size) |
|
864b0ca6577c
Don't arbitrarily default font settings when none are specified for incoming
Daniel Atallah <datallah@pidgin.im>
parents:
24039
diff
changeset
|
209 | g_string_append_printf(str, " size='%s'", font_size); |
|
32762
19da30ca0ffb
It seems like we should be using this color tag for something...
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32744
diff
changeset
|
210 | if (font_color) |
|
19da30ca0ffb
It seems like we should be using this color tag for something...
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32744
diff
changeset
|
211 | g_string_append_printf(str, " color='%s'", font_color); |
|
19da30ca0ffb
It seems like we should be using this color tag for something...
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32744
diff
changeset
|
212 | else if (ichat_text_color) |
|
24196
864b0ca6577c
Don't arbitrarily default font settings when none are specified for incoming
Daniel Atallah <datallah@pidgin.im>
parents:
24039
diff
changeset
|
213 | g_string_append_printf(str, " color='%s'", ichat_text_color); |
|
864b0ca6577c
Don't arbitrarily default font settings when none are specified for incoming
Daniel Atallah <datallah@pidgin.im>
parents:
24039
diff
changeset
|
214 | if (ichat_balloon_color) |
|
864b0ca6577c
Don't arbitrarily default font settings when none are specified for incoming
Daniel Atallah <datallah@pidgin.im>
parents:
24039
diff
changeset
|
215 | g_string_append_printf(str, " back='%s'", ichat_balloon_color); |
|
864b0ca6577c
Don't arbitrarily default font settings when none are specified for incoming
Daniel Atallah <datallah@pidgin.im>
parents:
24039
diff
changeset
|
216 | g_string_append_printf(str, ">%s</font>", html_body); |
|
864b0ca6577c
Don't arbitrarily default font settings when none are specified for incoming
Daniel Atallah <datallah@pidgin.im>
parents:
24039
diff
changeset
|
217 | |
|
864b0ca6577c
Don't arbitrarily default font settings when none are specified for incoming
Daniel Atallah <datallah@pidgin.im>
parents:
24039
diff
changeset
|
218 | body = g_string_free(str, FALSE); |
|
21936
79f3a365cffb
Cleanup to prevent unnecessary alloc/free. Also a small fix to remove the possiblity that a message will be sent before the stream is started.
Daniel Atallah <datallah@pidgin.im>
parents:
21920
diff
changeset
|
219 | |
|
79f3a365cffb
Cleanup to prevent unnecessary alloc/free. Also a small fix to remove the possiblity that a message will be sent before the stream is started.
Daniel Atallah <datallah@pidgin.im>
parents:
21920
diff
changeset
|
220 | g_free(html_body); |
|
79f3a365cffb
Cleanup to prevent unnecessary alloc/free. Also a small fix to remove the possiblity that a message will be sent before the stream is started.
Daniel Atallah <datallah@pidgin.im>
parents:
21920
diff
changeset
|
221 | } |
| 11477 | 222 | } |
| 223 | } | |
| 224 | } | |
|
11539
fbabe3f89777
[gaim-migrate @ 13794]
Mark Doliner <markdoliner@pidgin.im>
parents:
11515
diff
changeset
|
225 | |
|
21936
79f3a365cffb
Cleanup to prevent unnecessary alloc/free. Also a small fix to remove the possiblity that a message will be sent before the stream is started.
Daniel Atallah <datallah@pidgin.im>
parents:
21920
diff
changeset
|
226 | /* Compose the message */ |
|
79f3a365cffb
Cleanup to prevent unnecessary alloc/free. Also a small fix to remove the possiblity that a message will be sent before the stream is started.
Daniel Atallah <datallah@pidgin.im>
parents:
21920
diff
changeset
|
227 | if (body == NULL && body_node != NULL) |
|
34935
686fa55b0deb
Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents:
34911
diff
changeset
|
228 | body = purple_xmlnode_get_data(body_node); |
|
11539
fbabe3f89777
[gaim-migrate @ 13794]
Mark Doliner <markdoliner@pidgin.im>
parents:
11515
diff
changeset
|
229 | |
|
21936
79f3a365cffb
Cleanup to prevent unnecessary alloc/free. Also a small fix to remove the possiblity that a message will be sent before the stream is started.
Daniel Atallah <datallah@pidgin.im>
parents:
21920
diff
changeset
|
230 | if (body == NULL) { |
|
79f3a365cffb
Cleanup to prevent unnecessary alloc/free. Also a small fix to remove the possiblity that a message will be sent before the stream is started.
Daniel Atallah <datallah@pidgin.im>
parents:
21920
diff
changeset
|
231 | purple_debug_error("bonjour", "No html body or regular body found.\n"); |
|
79f3a365cffb
Cleanup to prevent unnecessary alloc/free. Also a small fix to remove the possiblity that a message will be sent before the stream is started.
Daniel Atallah <datallah@pidgin.im>
parents:
21920
diff
changeset
|
232 | return; |
| 11477 | 233 | } |
|
11539
fbabe3f89777
[gaim-migrate @ 13794]
Mark Doliner <markdoliner@pidgin.im>
parents:
11515
diff
changeset
|
234 | |
|
11826
10ebbc41f163
[gaim-migrate @ 14117]
Richard Laager <rlaager@pidgin.im>
parents:
11823
diff
changeset
|
235 | /* Send the message to the UI */ |
|
35499
c4c5e0a670b1
Fix namespaces issues in libpurple.
Ankit Vani <a@nevitus.org>
parents:
35378
diff
changeset
|
236 | purple_serv_got_im(gc, purple_buddy_get_name(pb), body, 0, time(NULL)); |
|
11539
fbabe3f89777
[gaim-migrate @ 13794]
Mark Doliner <markdoliner@pidgin.im>
parents:
11515
diff
changeset
|
237 | |
| 11477 | 238 | g_free(body); |
| 239 | } | |
| 240 | ||
|
21944
c41d17a1b8d9
This is the second part of the fix to support having multiple presence records in Bonjour (and also supporting multiple presences using the same IP). Incoming conversations are no longer immediately attached to a buddy - we use an algorithm to match a conversation to a buddy based on the IP and, if possible the "from" attribute of the stream or the first tag in the stream. Thanks to Sjoerd Simons from Telepahy Salut for noticing and suggesting the algorithm. Fixes #4187. It'd be good if a few people test this.
Daniel Atallah <datallah@pidgin.im>
parents:
21936
diff
changeset
|
241 | struct _match_buddies_by_address_t { |
|
17633
b76241c02857
Some more Bonjour cleanup and leak fixing.
Daniel Atallah <datallah@pidgin.im>
parents:
17632
diff
changeset
|
242 | const char *address; |
|
21944
c41d17a1b8d9
This is the second part of the fix to support having multiple presence records in Bonjour (and also supporting multiple presences using the same IP). Incoming conversations are no longer immediately attached to a buddy - we use an algorithm to match a conversation to a buddy based on the IP and, if possible the "from" attribute of the stream or the first tag in the stream. Thanks to Sjoerd Simons from Telepahy Salut for noticing and suggesting the algorithm. Fixes #4187. It'd be good if a few people test this.
Daniel Atallah <datallah@pidgin.im>
parents:
21936
diff
changeset
|
243 | GSList *matched_buddies; |
| 12708 | 244 | }; |
| 245 | ||
| 246 | static void | |
|
26767
7489049a3bde
Change purple_blist_get_buddies to return a list instead of the hash table.
Paul Aurich <darkrain42@pidgin.im>
parents:
25911
diff
changeset
|
247 | _match_buddies_by_address(gpointer value, gpointer data) |
| 11477 | 248 | { |
|
17661
96c6a21c4139
Send 'to' and 'from' attributes in the stream start message.
Daniel Atallah <datallah@pidgin.im>
parents:
17660
diff
changeset
|
249 | PurpleBuddy *pb = value; |
|
24938
fc6952107e1f
Finished moving to api for bonjour
Gary Kramlich <grim@reaperworld.com>
parents:
24562
diff
changeset
|
250 | BonjourBuddy *bb = NULL; |
|
21944
c41d17a1b8d9
This is the second part of the fix to support having multiple presence records in Bonjour (and also supporting multiple presences using the same IP). Incoming conversations are no longer immediately attached to a buddy - we use an algorithm to match a conversation to a buddy based on the IP and, if possible the "from" attribute of the stream or the first tag in the stream. Thanks to Sjoerd Simons from Telepahy Salut for noticing and suggesting the algorithm. Fixes #4187. It'd be good if a few people test this.
Daniel Atallah <datallah@pidgin.im>
parents:
21936
diff
changeset
|
251 | struct _match_buddies_by_address_t *mbba = data; |
|
11539
fbabe3f89777
[gaim-migrate @ 13794]
Mark Doliner <markdoliner@pidgin.im>
parents:
11515
diff
changeset
|
252 | |
|
24938
fc6952107e1f
Finished moving to api for bonjour
Gary Kramlich <grim@reaperworld.com>
parents:
24562
diff
changeset
|
253 | bb = purple_buddy_get_protocol_data(pb); |
|
fc6952107e1f
Finished moving to api for bonjour
Gary Kramlich <grim@reaperworld.com>
parents:
24562
diff
changeset
|
254 | |
| 13962 | 255 | /* |
|
26990
385ad4d15ae5
Use more efficient purple_find_buddies in bonjour.
Paul Aurich <darkrain42@pidgin.im>
parents:
26767
diff
changeset
|
256 | * If the current PurpleBuddy's data is not null, then continue to determine |
|
21920
3087a567aedf
Update Bonjour prpl to support multiple presence records for the same buddy. Eliminate the Howl backend to avoid having to maintain yet another set of code. References #4187 (more to come to fix the rest of the ticket).
Daniel Atallah <datallah@pidgin.im>
parents:
21917
diff
changeset
|
257 | * whether one of the buddies IPs matches the target IP. |
| 13962 | 258 | */ |
|
26990
385ad4d15ae5
Use more efficient purple_find_buddies in bonjour.
Paul Aurich <darkrain42@pidgin.im>
parents:
26767
diff
changeset
|
259 | if (bb != NULL) |
| 13962 | 260 | { |
|
21944
c41d17a1b8d9
This is the second part of the fix to support having multiple presence records in Bonjour (and also supporting multiple presences using the same IP). Incoming conversations are no longer immediately attached to a buddy - we use an algorithm to match a conversation to a buddy based on the IP and, if possible the "from" attribute of the stream or the first tag in the stream. Thanks to Sjoerd Simons from Telepahy Salut for noticing and suggesting the algorithm. Fixes #4187. It'd be good if a few people test this.
Daniel Atallah <datallah@pidgin.im>
parents:
21936
diff
changeset
|
261 | const char *ip; |
|
c41d17a1b8d9
This is the second part of the fix to support having multiple presence records in Bonjour (and also supporting multiple presences using the same IP). Incoming conversations are no longer immediately attached to a buddy - we use an algorithm to match a conversation to a buddy based on the IP and, if possible the "from" attribute of the stream or the first tag in the stream. Thanks to Sjoerd Simons from Telepahy Salut for noticing and suggesting the algorithm. Fixes #4187. It'd be good if a few people test this.
Daniel Atallah <datallah@pidgin.im>
parents:
21936
diff
changeset
|
262 | GSList *tmp = bb->ips; |
|
21920
3087a567aedf
Update Bonjour prpl to support multiple presence records for the same buddy. Eliminate the Howl backend to avoid having to maintain yet another set of code. References #4187 (more to come to fix the rest of the ticket).
Daniel Atallah <datallah@pidgin.im>
parents:
21917
diff
changeset
|
263 | |
|
21944
c41d17a1b8d9
This is the second part of the fix to support having multiple presence records in Bonjour (and also supporting multiple presences using the same IP). Incoming conversations are no longer immediately attached to a buddy - we use an algorithm to match a conversation to a buddy based on the IP and, if possible the "from" attribute of the stream or the first tag in the stream. Thanks to Sjoerd Simons from Telepahy Salut for noticing and suggesting the algorithm. Fixes #4187. It'd be good if a few people test this.
Daniel Atallah <datallah@pidgin.im>
parents:
21936
diff
changeset
|
264 | while(tmp) { |
|
c41d17a1b8d9
This is the second part of the fix to support having multiple presence records in Bonjour (and also supporting multiple presences using the same IP). Incoming conversations are no longer immediately attached to a buddy - we use an algorithm to match a conversation to a buddy based on the IP and, if possible the "from" attribute of the stream or the first tag in the stream. Thanks to Sjoerd Simons from Telepahy Salut for noticing and suggesting the algorithm. Fixes #4187. It'd be good if a few people test this.
Daniel Atallah <datallah@pidgin.im>
parents:
21936
diff
changeset
|
265 | ip = tmp->data; |
|
c41d17a1b8d9
This is the second part of the fix to support having multiple presence records in Bonjour (and also supporting multiple presences using the same IP). Incoming conversations are no longer immediately attached to a buddy - we use an algorithm to match a conversation to a buddy based on the IP and, if possible the "from" attribute of the stream or the first tag in the stream. Thanks to Sjoerd Simons from Telepahy Salut for noticing and suggesting the algorithm. Fixes #4187. It'd be good if a few people test this.
Daniel Atallah <datallah@pidgin.im>
parents:
21936
diff
changeset
|
266 | if (ip != NULL && g_ascii_strcasecmp(ip, mbba->address) == 0) { |
|
c41d17a1b8d9
This is the second part of the fix to support having multiple presence records in Bonjour (and also supporting multiple presences using the same IP). Incoming conversations are no longer immediately attached to a buddy - we use an algorithm to match a conversation to a buddy based on the IP and, if possible the "from" attribute of the stream or the first tag in the stream. Thanks to Sjoerd Simons from Telepahy Salut for noticing and suggesting the algorithm. Fixes #4187. It'd be good if a few people test this.
Daniel Atallah <datallah@pidgin.im>
parents:
21936
diff
changeset
|
267 | mbba->matched_buddies = g_slist_prepend(mbba->matched_buddies, pb); |
|
c41d17a1b8d9
This is the second part of the fix to support having multiple presence records in Bonjour (and also supporting multiple presences using the same IP). Incoming conversations are no longer immediately attached to a buddy - we use an algorithm to match a conversation to a buddy based on the IP and, if possible the "from" attribute of the stream or the first tag in the stream. Thanks to Sjoerd Simons from Telepahy Salut for noticing and suggesting the algorithm. Fixes #4187. It'd be good if a few people test this.
Daniel Atallah <datallah@pidgin.im>
parents:
21936
diff
changeset
|
268 | break; |
|
21920
3087a567aedf
Update Bonjour prpl to support multiple presence records for the same buddy. Eliminate the Howl backend to avoid having to maintain yet another set of code. References #4187 (more to come to fix the rest of the ticket).
Daniel Atallah <datallah@pidgin.im>
parents:
21917
diff
changeset
|
269 | } |
|
21944
c41d17a1b8d9
This is the second part of the fix to support having multiple presence records in Bonjour (and also supporting multiple presences using the same IP). Incoming conversations are no longer immediately attached to a buddy - we use an algorithm to match a conversation to a buddy based on the IP and, if possible the "from" attribute of the stream or the first tag in the stream. Thanks to Sjoerd Simons from Telepahy Salut for noticing and suggesting the algorithm. Fixes #4187. It'd be good if a few people test this.
Daniel Atallah <datallah@pidgin.im>
parents:
21936
diff
changeset
|
270 | tmp = tmp->next; |
|
21920
3087a567aedf
Update Bonjour prpl to support multiple presence records for the same buddy. Eliminate the Howl backend to avoid having to maintain yet another set of code. References #4187 (more to come to fix the rest of the ticket).
Daniel Atallah <datallah@pidgin.im>
parents:
21917
diff
changeset
|
271 | } |
| 11477 | 272 | } |
| 273 | } | |
| 274 | ||
|
17665
26bff2090889
Update Bonjour to do nonblocking I/O correctly.
Daniel Atallah <datallah@pidgin.im>
parents:
17663
diff
changeset
|
275 | static void |
|
26bff2090889
Update Bonjour to do nonblocking I/O correctly.
Daniel Atallah <datallah@pidgin.im>
parents:
17663
diff
changeset
|
276 | _send_data_write_cb(gpointer data, gint source, PurpleInputCondition cond) |
| 11477 | 277 | { |
|
17665
26bff2090889
Update Bonjour to do nonblocking I/O correctly.
Daniel Atallah <datallah@pidgin.im>
parents:
17663
diff
changeset
|
278 | PurpleBuddy *pb = data; |
|
24938
fc6952107e1f
Finished moving to api for bonjour
Gary Kramlich <grim@reaperworld.com>
parents:
24562
diff
changeset
|
279 | BonjourBuddy *bb = purple_buddy_get_protocol_data(pb); |
|
17665
26bff2090889
Update Bonjour to do nonblocking I/O correctly.
Daniel Atallah <datallah@pidgin.im>
parents:
17663
diff
changeset
|
280 | BonjourJabberConversation *bconv = bb->conversation; |
|
26bff2090889
Update Bonjour to do nonblocking I/O correctly.
Daniel Atallah <datallah@pidgin.im>
parents:
17663
diff
changeset
|
281 | int ret, writelen; |
|
26bff2090889
Update Bonjour to do nonblocking I/O correctly.
Daniel Atallah <datallah@pidgin.im>
parents:
17663
diff
changeset
|
282 | |
|
34529
68cf25486001
GObjectify PurpleCircBuffer as PurpleCircularBuffer (from gobjectification branch)
Ankit Vani <a@nevitus.org>
parents:
33892
diff
changeset
|
283 | writelen = purple_circular_buffer_get_max_read(bconv->tx_buf); |
|
17665
26bff2090889
Update Bonjour to do nonblocking I/O correctly.
Daniel Atallah <datallah@pidgin.im>
parents:
17663
diff
changeset
|
284 | |
|
26bff2090889
Update Bonjour to do nonblocking I/O correctly.
Daniel Atallah <datallah@pidgin.im>
parents:
17663
diff
changeset
|
285 | if (writelen == 0) { |
|
26bff2090889
Update Bonjour to do nonblocking I/O correctly.
Daniel Atallah <datallah@pidgin.im>
parents:
17663
diff
changeset
|
286 | purple_input_remove(bconv->tx_handler); |
|
19579
d79d5c95ce5a
Reset unsigned int input handlers to 0 instead of -1.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
19373
diff
changeset
|
287 | bconv->tx_handler = 0; |
|
17665
26bff2090889
Update Bonjour to do nonblocking I/O correctly.
Daniel Atallah <datallah@pidgin.im>
parents:
17663
diff
changeset
|
288 | return; |
|
26bff2090889
Update Bonjour to do nonblocking I/O correctly.
Daniel Atallah <datallah@pidgin.im>
parents:
17663
diff
changeset
|
289 | } |
|
11539
fbabe3f89777
[gaim-migrate @ 13794]
Mark Doliner <markdoliner@pidgin.im>
parents:
11515
diff
changeset
|
290 | |
|
34529
68cf25486001
GObjectify PurpleCircBuffer as PurpleCircularBuffer (from gobjectification branch)
Ankit Vani <a@nevitus.org>
parents:
33892
diff
changeset
|
291 | ret = send(bconv->socket, purple_circular_buffer_get_output(bconv->tx_buf), writelen, 0); |
|
17665
26bff2090889
Update Bonjour to do nonblocking I/O correctly.
Daniel Atallah <datallah@pidgin.im>
parents:
17663
diff
changeset
|
292 | |
|
26bff2090889
Update Bonjour to do nonblocking I/O correctly.
Daniel Atallah <datallah@pidgin.im>
parents:
17663
diff
changeset
|
293 | if (ret < 0 && errno == EAGAIN) |
|
26bff2090889
Update Bonjour to do nonblocking I/O correctly.
Daniel Atallah <datallah@pidgin.im>
parents:
17663
diff
changeset
|
294 | return; |
|
26bff2090889
Update Bonjour to do nonblocking I/O correctly.
Daniel Atallah <datallah@pidgin.im>
parents:
17663
diff
changeset
|
295 | else if (ret <= 0) { |
|
24938
fc6952107e1f
Finished moving to api for bonjour
Gary Kramlich <grim@reaperworld.com>
parents:
24562
diff
changeset
|
296 | PurpleConversation *conv = NULL; |
|
fc6952107e1f
Finished moving to api for bonjour
Gary Kramlich <grim@reaperworld.com>
parents:
24562
diff
changeset
|
297 | PurpleAccount *account = NULL; |
|
21389
e1dd8142bb87
replace most calls to strerror with calls to g_strerror. strerror will return
Nathan Walp <nwalp@pidgin.im>
parents:
21093
diff
changeset
|
298 | const char *error = g_strerror(errno); |
|
17665
26bff2090889
Update Bonjour to do nonblocking I/O correctly.
Daniel Atallah <datallah@pidgin.im>
parents:
17663
diff
changeset
|
299 | |
|
26bff2090889
Update Bonjour to do nonblocking I/O correctly.
Daniel Atallah <datallah@pidgin.im>
parents:
17663
diff
changeset
|
300 | purple_debug_error("bonjour", "Error sending message to buddy %s error: %s\n", |
|
26bff2090889
Update Bonjour to do nonblocking I/O correctly.
Daniel Atallah <datallah@pidgin.im>
parents:
17663
diff
changeset
|
301 | purple_buddy_get_name(pb), error ? error : "(null)"); |
|
26bff2090889
Update Bonjour to do nonblocking I/O correctly.
Daniel Atallah <datallah@pidgin.im>
parents:
17663
diff
changeset
|
302 | |
|
24938
fc6952107e1f
Finished moving to api for bonjour
Gary Kramlich <grim@reaperworld.com>
parents:
24562
diff
changeset
|
303 | account = purple_buddy_get_account(pb); |
|
fc6952107e1f
Finished moving to api for bonjour
Gary Kramlich <grim@reaperworld.com>
parents:
24562
diff
changeset
|
304 | |
|
34632
ebe6b2a60305
Changed all arguments and return types of Chat and IMs to PurpleChatConversation and PurpleIMConversation.
Ankit Vani <a@nevitus.org>
parents:
34625
diff
changeset
|
305 | conv = PURPLE_CONVERSATION(purple_conversations_find_im_with_account(bb->name, account)); |
|
17665
26bff2090889
Update Bonjour to do nonblocking I/O correctly.
Daniel Atallah <datallah@pidgin.im>
parents:
17663
diff
changeset
|
306 | if (conv != NULL) |
|
26bff2090889
Update Bonjour to do nonblocking I/O correctly.
Daniel Atallah <datallah@pidgin.im>
parents:
17663
diff
changeset
|
307 | purple_conversation_write(conv, NULL, |
|
26bff2090889
Update Bonjour to do nonblocking I/O correctly.
Daniel Atallah <datallah@pidgin.im>
parents:
17663
diff
changeset
|
308 | _("Unable to send message."), |
|
26bff2090889
Update Bonjour to do nonblocking I/O correctly.
Daniel Atallah <datallah@pidgin.im>
parents:
17663
diff
changeset
|
309 | PURPLE_MESSAGE_SYSTEM, time(NULL)); |
|
26bff2090889
Update Bonjour to do nonblocking I/O correctly.
Daniel Atallah <datallah@pidgin.im>
parents:
17663
diff
changeset
|
310 | |
|
26bff2090889
Update Bonjour to do nonblocking I/O correctly.
Daniel Atallah <datallah@pidgin.im>
parents:
17663
diff
changeset
|
311 | bonjour_jabber_close_conversation(bb->conversation); |
|
26bff2090889
Update Bonjour to do nonblocking I/O correctly.
Daniel Atallah <datallah@pidgin.im>
parents:
17663
diff
changeset
|
312 | bb->conversation = NULL; |
|
26bff2090889
Update Bonjour to do nonblocking I/O correctly.
Daniel Atallah <datallah@pidgin.im>
parents:
17663
diff
changeset
|
313 | return; |
| 11477 | 314 | } |
|
11539
fbabe3f89777
[gaim-migrate @ 13794]
Mark Doliner <markdoliner@pidgin.im>
parents:
11515
diff
changeset
|
315 | |
|
34529
68cf25486001
GObjectify PurpleCircBuffer as PurpleCircularBuffer (from gobjectification branch)
Ankit Vani <a@nevitus.org>
parents:
33892
diff
changeset
|
316 | purple_circular_buffer_mark_read(bconv->tx_buf, ret); |
|
17665
26bff2090889
Update Bonjour to do nonblocking I/O correctly.
Daniel Atallah <datallah@pidgin.im>
parents:
17663
diff
changeset
|
317 | } |
|
26bff2090889
Update Bonjour to do nonblocking I/O correctly.
Daniel Atallah <datallah@pidgin.im>
parents:
17663
diff
changeset
|
318 | |
|
26bff2090889
Update Bonjour to do nonblocking I/O correctly.
Daniel Atallah <datallah@pidgin.im>
parents:
17663
diff
changeset
|
319 | static gint |
|
26bff2090889
Update Bonjour to do nonblocking I/O correctly.
Daniel Atallah <datallah@pidgin.im>
parents:
17663
diff
changeset
|
320 | _send_data(PurpleBuddy *pb, char *message) |
|
26bff2090889
Update Bonjour to do nonblocking I/O correctly.
Daniel Atallah <datallah@pidgin.im>
parents:
17663
diff
changeset
|
321 | { |
|
26bff2090889
Update Bonjour to do nonblocking I/O correctly.
Daniel Atallah <datallah@pidgin.im>
parents:
17663
diff
changeset
|
322 | gint ret; |
|
26bff2090889
Update Bonjour to do nonblocking I/O correctly.
Daniel Atallah <datallah@pidgin.im>
parents:
17663
diff
changeset
|
323 | int len = strlen(message); |
|
24938
fc6952107e1f
Finished moving to api for bonjour
Gary Kramlich <grim@reaperworld.com>
parents:
24562
diff
changeset
|
324 | BonjourBuddy *bb = purple_buddy_get_protocol_data(pb); |
|
17665
26bff2090889
Update Bonjour to do nonblocking I/O correctly.
Daniel Atallah <datallah@pidgin.im>
parents:
17663
diff
changeset
|
325 | BonjourJabberConversation *bconv = bb->conversation; |
|
26bff2090889
Update Bonjour to do nonblocking I/O correctly.
Daniel Atallah <datallah@pidgin.im>
parents:
17663
diff
changeset
|
326 | |
|
26bff2090889
Update Bonjour to do nonblocking I/O correctly.
Daniel Atallah <datallah@pidgin.im>
parents:
17663
diff
changeset
|
327 | /* If we're not ready to actually send, append it to the buffer */ |
|
19579
d79d5c95ce5a
Reset unsigned int input handlers to 0 instead of -1.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
19373
diff
changeset
|
328 | if (bconv->tx_handler != 0 |
|
17665
26bff2090889
Update Bonjour to do nonblocking I/O correctly.
Daniel Atallah <datallah@pidgin.im>
parents:
17663
diff
changeset
|
329 | || bconv->connect_data != NULL |
|
21727
decfc3a613ff
applied changes from b9c97ed0f9ada9069e8bd994b01fdde0b484083c
Daniel Atallah <datallah@pidgin.im>
parents:
21720
diff
changeset
|
330 | || bconv->sent_stream_start != FULLY_SENT |
|
19056
05cd9ab28312
Update the Bonjour prpl to use libxml explicitly instead of the xml_node stuff. This allows us to deal with partial reads. I also fixed issues related to starting conversations with iChat and a couple other things. Fixes #2022,#1652
Daniel Atallah <datallah@pidgin.im>
parents:
18947
diff
changeset
|
331 | || !bconv->recv_stream_start |
|
34529
68cf25486001
GObjectify PurpleCircBuffer as PurpleCircularBuffer (from gobjectification branch)
Ankit Vani <a@nevitus.org>
parents:
33892
diff
changeset
|
332 | || purple_circular_buffer_get_max_read(bconv->tx_buf) > 0) { |
|
17665
26bff2090889
Update Bonjour to do nonblocking I/O correctly.
Daniel Atallah <datallah@pidgin.im>
parents:
17663
diff
changeset
|
333 | ret = -1; |
|
26bff2090889
Update Bonjour to do nonblocking I/O correctly.
Daniel Atallah <datallah@pidgin.im>
parents:
17663
diff
changeset
|
334 | errno = EAGAIN; |
|
26bff2090889
Update Bonjour to do nonblocking I/O correctly.
Daniel Atallah <datallah@pidgin.im>
parents:
17663
diff
changeset
|
335 | } else { |
|
26bff2090889
Update Bonjour to do nonblocking I/O correctly.
Daniel Atallah <datallah@pidgin.im>
parents:
17663
diff
changeset
|
336 | ret = send(bconv->socket, message, len, 0); |
|
26bff2090889
Update Bonjour to do nonblocking I/O correctly.
Daniel Atallah <datallah@pidgin.im>
parents:
17663
diff
changeset
|
337 | } |
|
26bff2090889
Update Bonjour to do nonblocking I/O correctly.
Daniel Atallah <datallah@pidgin.im>
parents:
17663
diff
changeset
|
338 | |
|
26bff2090889
Update Bonjour to do nonblocking I/O correctly.
Daniel Atallah <datallah@pidgin.im>
parents:
17663
diff
changeset
|
339 | if (ret == -1 && errno == EAGAIN) |
|
26bff2090889
Update Bonjour to do nonblocking I/O correctly.
Daniel Atallah <datallah@pidgin.im>
parents:
17663
diff
changeset
|
340 | ret = 0; |
|
26bff2090889
Update Bonjour to do nonblocking I/O correctly.
Daniel Atallah <datallah@pidgin.im>
parents:
17663
diff
changeset
|
341 | else if (ret <= 0) { |
|
26bff2090889
Update Bonjour to do nonblocking I/O correctly.
Daniel Atallah <datallah@pidgin.im>
parents:
17663
diff
changeset
|
342 | PurpleConversation *conv; |
|
25140
7c494d2bc5e4
propagate from branch 'im.pidgin.pidgin' (head 009f3ea551248605298fbf1b88d7a873b2a6c7a3)
Richard Laager <rlaager@pidgin.im>
diff
changeset
|
343 | PurpleAccount *account; |
|
21389
e1dd8142bb87
replace most calls to strerror with calls to g_strerror. strerror will return
Nathan Walp <nwalp@pidgin.im>
parents:
21093
diff
changeset
|
344 | const char *error = g_strerror(errno); |
|
17665
26bff2090889
Update Bonjour to do nonblocking I/O correctly.
Daniel Atallah <datallah@pidgin.im>
parents:
17663
diff
changeset
|
345 | |
|
26bff2090889
Update Bonjour to do nonblocking I/O correctly.
Daniel Atallah <datallah@pidgin.im>
parents:
17663
diff
changeset
|
346 | purple_debug_error("bonjour", "Error sending message to buddy %s error: %s\n", |
|
26bff2090889
Update Bonjour to do nonblocking I/O correctly.
Daniel Atallah <datallah@pidgin.im>
parents:
17663
diff
changeset
|
347 | purple_buddy_get_name(pb), error ? error : "(null)"); |
|
26bff2090889
Update Bonjour to do nonblocking I/O correctly.
Daniel Atallah <datallah@pidgin.im>
parents:
17663
diff
changeset
|
348 | |
|
24938
fc6952107e1f
Finished moving to api for bonjour
Gary Kramlich <grim@reaperworld.com>
parents:
24562
diff
changeset
|
349 | account = purple_buddy_get_account(pb); |
|
fc6952107e1f
Finished moving to api for bonjour
Gary Kramlich <grim@reaperworld.com>
parents:
24562
diff
changeset
|
350 | |
|
34632
ebe6b2a60305
Changed all arguments and return types of Chat and IMs to PurpleChatConversation and PurpleIMConversation.
Ankit Vani <a@nevitus.org>
parents:
34625
diff
changeset
|
351 | conv = PURPLE_CONVERSATION(purple_conversations_find_im_with_account(bb->name, account)); |
|
17665
26bff2090889
Update Bonjour to do nonblocking I/O correctly.
Daniel Atallah <datallah@pidgin.im>
parents:
17663
diff
changeset
|
352 | if (conv != NULL) |
|
26bff2090889
Update Bonjour to do nonblocking I/O correctly.
Daniel Atallah <datallah@pidgin.im>
parents:
17663
diff
changeset
|
353 | purple_conversation_write(conv, NULL, |
|
26bff2090889
Update Bonjour to do nonblocking I/O correctly.
Daniel Atallah <datallah@pidgin.im>
parents:
17663
diff
changeset
|
354 | _("Unable to send message."), |
|
26bff2090889
Update Bonjour to do nonblocking I/O correctly.
Daniel Atallah <datallah@pidgin.im>
parents:
17663
diff
changeset
|
355 | PURPLE_MESSAGE_SYSTEM, time(NULL)); |
|
26bff2090889
Update Bonjour to do nonblocking I/O correctly.
Daniel Atallah <datallah@pidgin.im>
parents:
17663
diff
changeset
|
356 | |
|
26bff2090889
Update Bonjour to do nonblocking I/O correctly.
Daniel Atallah <datallah@pidgin.im>
parents:
17663
diff
changeset
|
357 | bonjour_jabber_close_conversation(bb->conversation); |
|
26bff2090889
Update Bonjour to do nonblocking I/O correctly.
Daniel Atallah <datallah@pidgin.im>
parents:
17663
diff
changeset
|
358 | bb->conversation = NULL; |
|
26bff2090889
Update Bonjour to do nonblocking I/O correctly.
Daniel Atallah <datallah@pidgin.im>
parents:
17663
diff
changeset
|
359 | return -1; |
|
26bff2090889
Update Bonjour to do nonblocking I/O correctly.
Daniel Atallah <datallah@pidgin.im>
parents:
17663
diff
changeset
|
360 | } |
|
26bff2090889
Update Bonjour to do nonblocking I/O correctly.
Daniel Atallah <datallah@pidgin.im>
parents:
17663
diff
changeset
|
361 | |
|
26bff2090889
Update Bonjour to do nonblocking I/O correctly.
Daniel Atallah <datallah@pidgin.im>
parents:
17663
diff
changeset
|
362 | if (ret < len) { |
|
21727
decfc3a613ff
applied changes from b9c97ed0f9ada9069e8bd994b01fdde0b484083c
Daniel Atallah <datallah@pidgin.im>
parents:
21720
diff
changeset
|
363 | /* Don't interfere with the stream starting */ |
|
21936
79f3a365cffb
Cleanup to prevent unnecessary alloc/free. Also a small fix to remove the possiblity that a message will be sent before the stream is started.
Daniel Atallah <datallah@pidgin.im>
parents:
21920
diff
changeset
|
364 | if (bconv->sent_stream_start == FULLY_SENT && bconv->recv_stream_start && bconv->tx_handler == 0) |
|
17665
26bff2090889
Update Bonjour to do nonblocking I/O correctly.
Daniel Atallah <datallah@pidgin.im>
parents:
17663
diff
changeset
|
365 | bconv->tx_handler = purple_input_add(bconv->socket, PURPLE_INPUT_WRITE, |
|
26bff2090889
Update Bonjour to do nonblocking I/O correctly.
Daniel Atallah <datallah@pidgin.im>
parents:
17663
diff
changeset
|
366 | _send_data_write_cb, pb); |
|
34529
68cf25486001
GObjectify PurpleCircBuffer as PurpleCircularBuffer (from gobjectification branch)
Ankit Vani <a@nevitus.org>
parents:
33892
diff
changeset
|
367 | purple_circular_buffer_append(bconv->tx_buf, message + ret, len - ret); |
|
17665
26bff2090889
Update Bonjour to do nonblocking I/O correctly.
Daniel Atallah <datallah@pidgin.im>
parents:
17663
diff
changeset
|
368 | } |
|
26bff2090889
Update Bonjour to do nonblocking I/O correctly.
Daniel Atallah <datallah@pidgin.im>
parents:
17663
diff
changeset
|
369 | |
|
26bff2090889
Update Bonjour to do nonblocking I/O correctly.
Daniel Atallah <datallah@pidgin.im>
parents:
17663
diff
changeset
|
370 | return ret; |
| 11477 | 371 | } |
| 372 | ||
|
34935
686fa55b0deb
Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents:
34911
diff
changeset
|
373 | void bonjour_jabber_process_packet(PurpleBuddy *pb, PurpleXmlNode *packet) { |
|
21612
9fce536735e3
Various bugfixes including using purple_account_remove_buddy() in addition to purple_blist_remove_buddy() to make sure that the buddy gets cleaned up fully when logging out or we go offline.
Daniel Atallah <datallah@pidgin.im>
parents:
21609
diff
changeset
|
374 | |
|
9fce536735e3
Various bugfixes including using purple_account_remove_buddy() in addition to purple_blist_remove_buddy() to make sure that the buddy gets cleaned up fully when logging out or we go offline.
Daniel Atallah <datallah@pidgin.im>
parents:
21609
diff
changeset
|
375 | g_return_if_fail(packet != NULL); |
|
21944
c41d17a1b8d9
This is the second part of the fix to support having multiple presence records in Bonjour (and also supporting multiple presences using the same IP). Incoming conversations are no longer immediately attached to a buddy - we use an algorithm to match a conversation to a buddy based on the IP and, if possible the "from" attribute of the stream or the first tag in the stream. Thanks to Sjoerd Simons from Telepahy Salut for noticing and suggesting the algorithm. Fixes #4187. It'd be good if a few people test this.
Daniel Atallah <datallah@pidgin.im>
parents:
21936
diff
changeset
|
376 | g_return_if_fail(pb != NULL); |
|
21612
9fce536735e3
Various bugfixes including using purple_account_remove_buddy() in addition to purple_blist_remove_buddy() to make sure that the buddy gets cleaned up fully when logging out or we go offline.
Daniel Atallah <datallah@pidgin.im>
parents:
21609
diff
changeset
|
377 | |
|
19056
05cd9ab28312
Update the Bonjour prpl to use libxml explicitly instead of the xml_node stuff. This allows us to deal with partial reads. I also fixed issues related to starting conversations with iChat and a couple other things. Fixes #2022,#1652
Daniel Atallah <datallah@pidgin.im>
parents:
18947
diff
changeset
|
378 | if (!strcmp(packet->name, "message")) |
|
05cd9ab28312
Update the Bonjour prpl to use libxml explicitly instead of the xml_node stuff. This allows us to deal with partial reads. I also fixed issues related to starting conversations with iChat and a couple other things. Fixes #2022,#1652
Daniel Atallah <datallah@pidgin.im>
parents:
18947
diff
changeset
|
379 | _jabber_parse_and_write_message_to_ui(packet, pb); |
|
21524
472e58992083
Patch from some Intel folks to implement file transfer in Bonjour using XEP-0096 and 0065. This hopefully will work with Gaijm (haven't yet tested) and, of course, between libpurple instances; it will not work with Adium or iChat.
Daniel Atallah <datallah@pidgin.im>
parents:
21503
diff
changeset
|
380 | else if(!strcmp(packet->name, "iq")) |
|
25097
c950e59e30bf
Further cleanup to fix CID 373.
Daniel Atallah <datallah@pidgin.im>
parents:
25096
diff
changeset
|
381 | xep_iq_parse(packet, pb); |
|
19056
05cd9ab28312
Update the Bonjour prpl to use libxml explicitly instead of the xml_node stuff. This allows us to deal with partial reads. I also fixed issues related to starting conversations with iChat and a couple other things. Fixes #2022,#1652
Daniel Atallah <datallah@pidgin.im>
parents:
18947
diff
changeset
|
382 | else |
|
21612
9fce536735e3
Various bugfixes including using purple_account_remove_buddy() in addition to purple_blist_remove_buddy() to make sure that the buddy gets cleaned up fully when logging out or we go offline.
Daniel Atallah <datallah@pidgin.im>
parents:
21609
diff
changeset
|
383 | purple_debug_warning("bonjour", "Unknown packet: %s\n", packet->name ? packet->name : "(null)"); |
|
19056
05cd9ab28312
Update the Bonjour prpl to use libxml explicitly instead of the xml_node stuff. This allows us to deal with partial reads. I also fixed issues related to starting conversations with iChat and a couple other things. Fixes #2022,#1652
Daniel Atallah <datallah@pidgin.im>
parents:
18947
diff
changeset
|
384 | } |
|
05cd9ab28312
Update the Bonjour prpl to use libxml explicitly instead of the xml_node stuff. This allows us to deal with partial reads. I also fixed issues related to starting conversations with iChat and a couple other things. Fixes #2022,#1652
Daniel Atallah <datallah@pidgin.im>
parents:
18947
diff
changeset
|
385 | |
|
25095
0e356664879d
Clean up some stuff that the behavior has changed on to fix CID 398.
Daniel Atallah <datallah@pidgin.im>
parents:
24562
diff
changeset
|
386 | static void bonjour_jabber_stream_ended(BonjourJabberConversation *bconv) { |
|
0e356664879d
Clean up some stuff that the behavior has changed on to fix CID 398.
Daniel Atallah <datallah@pidgin.im>
parents:
24562
diff
changeset
|
387 | |
|
0e356664879d
Clean up some stuff that the behavior has changed on to fix CID 398.
Daniel Atallah <datallah@pidgin.im>
parents:
24562
diff
changeset
|
388 | /* Inform the user that the conversation has been closed */ |
|
0e356664879d
Clean up some stuff that the behavior has changed on to fix CID 398.
Daniel Atallah <datallah@pidgin.im>
parents:
24562
diff
changeset
|
389 | BonjourBuddy *bb = NULL; |
|
25870
ccb76c75d39f
a few struct hiding clean ups
Gary Kramlich <grim@reaperworld.com>
parents:
25150
diff
changeset
|
390 | const gchar *name = bconv->pb ? purple_buddy_get_name(bconv->pb) : "(unknown)"; |
|
25095
0e356664879d
Clean up some stuff that the behavior has changed on to fix CID 398.
Daniel Atallah <datallah@pidgin.im>
parents:
24562
diff
changeset
|
391 | |
|
30270
8380aae8b132
I before E, except after C
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
30249
diff
changeset
|
392 | purple_debug_info("bonjour", "Received conversation close notification from %s.\n", name); |
|
25095
0e356664879d
Clean up some stuff that the behavior has changed on to fix CID 398.
Daniel Atallah <datallah@pidgin.im>
parents:
24562
diff
changeset
|
393 | |
|
0e356664879d
Clean up some stuff that the behavior has changed on to fix CID 398.
Daniel Atallah <datallah@pidgin.im>
parents:
24562
diff
changeset
|
394 | if(bconv->pb != NULL) |
|
25150
b0e1b122d83a
merge of 'c93933e47474a5522b300e0ac9f8aa777205e964'
Sadrul Habib Chowdhury <sadrul@pidgin.im>
diff
changeset
|
395 | bb = purple_buddy_get_protocol_data(bconv->pb); |
|
25095
0e356664879d
Clean up some stuff that the behavior has changed on to fix CID 398.
Daniel Atallah <datallah@pidgin.im>
parents:
24562
diff
changeset
|
396 | #if 0 |
|
0e356664879d
Clean up some stuff that the behavior has changed on to fix CID 398.
Daniel Atallah <datallah@pidgin.im>
parents:
24562
diff
changeset
|
397 | if(bconv->pb != NULL) { |
|
0e356664879d
Clean up some stuff that the behavior has changed on to fix CID 398.
Daniel Atallah <datallah@pidgin.im>
parents:
24562
diff
changeset
|
398 | PurpleConversation *conv; |
|
34625
03d62b1660fc
Refactor code to remove conversation type from some instances of purple_conversations_find_with_account()
Ankit Vani <a@nevitus.org>
parents:
34622
diff
changeset
|
399 | conv = purple_conversations_find_im_with_account(bconv->pb->name, bconv->pb->account); |
|
25095
0e356664879d
Clean up some stuff that the behavior has changed on to fix CID 398.
Daniel Atallah <datallah@pidgin.im>
parents:
24562
diff
changeset
|
400 | if (conv != NULL) { |
|
0e356664879d
Clean up some stuff that the behavior has changed on to fix CID 398.
Daniel Atallah <datallah@pidgin.im>
parents:
24562
diff
changeset
|
401 | char *tmp = g_strdup_printf(_("%s has closed the conversation."), bconv->pb->name); |
|
0e356664879d
Clean up some stuff that the behavior has changed on to fix CID 398.
Daniel Atallah <datallah@pidgin.im>
parents:
24562
diff
changeset
|
402 | purple_conversation_write(conv, NULL, tmp, PURPLE_MESSAGE_SYSTEM, time(NULL)); |
|
0e356664879d
Clean up some stuff that the behavior has changed on to fix CID 398.
Daniel Atallah <datallah@pidgin.im>
parents:
24562
diff
changeset
|
403 | g_free(tmp); |
|
0e356664879d
Clean up some stuff that the behavior has changed on to fix CID 398.
Daniel Atallah <datallah@pidgin.im>
parents:
24562
diff
changeset
|
404 | } |
|
0e356664879d
Clean up some stuff that the behavior has changed on to fix CID 398.
Daniel Atallah <datallah@pidgin.im>
parents:
24562
diff
changeset
|
405 | } |
|
0e356664879d
Clean up some stuff that the behavior has changed on to fix CID 398.
Daniel Atallah <datallah@pidgin.im>
parents:
24562
diff
changeset
|
406 | #endif |
|
0e356664879d
Clean up some stuff that the behavior has changed on to fix CID 398.
Daniel Atallah <datallah@pidgin.im>
parents:
24562
diff
changeset
|
407 | /* Close the socket, clear the watcher and free memory */ |
|
0e356664879d
Clean up some stuff that the behavior has changed on to fix CID 398.
Daniel Atallah <datallah@pidgin.im>
parents:
24562
diff
changeset
|
408 | bonjour_jabber_close_conversation(bconv); |
|
0e356664879d
Clean up some stuff that the behavior has changed on to fix CID 398.
Daniel Atallah <datallah@pidgin.im>
parents:
24562
diff
changeset
|
409 | if(bb) |
|
0e356664879d
Clean up some stuff that the behavior has changed on to fix CID 398.
Daniel Atallah <datallah@pidgin.im>
parents:
24562
diff
changeset
|
410 | bb->conversation = NULL; |
|
0e356664879d
Clean up some stuff that the behavior has changed on to fix CID 398.
Daniel Atallah <datallah@pidgin.im>
parents:
24562
diff
changeset
|
411 | } |
|
19056
05cd9ab28312
Update the Bonjour prpl to use libxml explicitly instead of the xml_node stuff. This allows us to deal with partial reads. I also fixed issues related to starting conversations with iChat and a couple other things. Fixes #2022,#1652
Daniel Atallah <datallah@pidgin.im>
parents:
18947
diff
changeset
|
412 | |
|
12443
ad94864144f8
[gaim-migrate @ 14750]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
11830
diff
changeset
|
413 | static void |
| 15884 | 414 | _client_socket_handler(gpointer data, gint socket, PurpleInputCondition condition) |
| 11477 | 415 | { |
|
21944
c41d17a1b8d9
This is the second part of the fix to support having multiple presence records in Bonjour (and also supporting multiple presences using the same IP). Incoming conversations are no longer immediately attached to a buddy - we use an algorithm to match a conversation to a buddy based on the IP and, if possible the "from" attribute of the stream or the first tag in the stream. Thanks to Sjoerd Simons from Telepahy Salut for noticing and suggesting the algorithm. Fixes #4187. It'd be good if a few people test this.
Daniel Atallah <datallah@pidgin.im>
parents:
21936
diff
changeset
|
416 | BonjourJabberConversation *bconv = data; |
|
33783
8b37d3593783
bonjour: Similify code and get rid of some unnecessary control character removal
Daniel Atallah <datallah@pidgin.im>
parents:
33782
diff
changeset
|
417 | gssize len; |
|
19056
05cd9ab28312
Update the Bonjour prpl to use libxml explicitly instead of the xml_node stuff. This allows us to deal with partial reads. I also fixed issues related to starting conversations with iChat and a couple other things. Fixes #2022,#1652
Daniel Atallah <datallah@pidgin.im>
parents:
18947
diff
changeset
|
418 | static char message[4096]; |
|
05cd9ab28312
Update the Bonjour prpl to use libxml explicitly instead of the xml_node stuff. This allows us to deal with partial reads. I also fixed issues related to starting conversations with iChat and a couple other things. Fixes #2022,#1652
Daniel Atallah <datallah@pidgin.im>
parents:
18947
diff
changeset
|
419 | |
|
11826
10ebbc41f163
[gaim-migrate @ 14117]
Richard Laager <rlaager@pidgin.im>
parents:
11823
diff
changeset
|
420 | /* Read the data from the socket */ |
|
33783
8b37d3593783
bonjour: Similify code and get rid of some unnecessary control character removal
Daniel Atallah <datallah@pidgin.im>
parents:
33782
diff
changeset
|
421 | if ((len = recv(socket, message, sizeof(message) - 1, 0)) < 0) { |
|
11826
10ebbc41f163
[gaim-migrate @ 14117]
Richard Laager <rlaager@pidgin.im>
parents:
11823
diff
changeset
|
422 | /* There have been an error reading from the socket */ |
|
33783
8b37d3593783
bonjour: Similify code and get rid of some unnecessary control character removal
Daniel Atallah <datallah@pidgin.im>
parents:
33782
diff
changeset
|
423 | if (len != -1 || errno != EAGAIN) { |
|
21612
9fce536735e3
Various bugfixes including using purple_account_remove_buddy() in addition to purple_blist_remove_buddy() to make sure that the buddy gets cleaned up fully when logging out or we go offline.
Daniel Atallah <datallah@pidgin.im>
parents:
21609
diff
changeset
|
424 | const char *err = g_strerror(errno); |
|
19056
05cd9ab28312
Update the Bonjour prpl to use libxml explicitly instead of the xml_node stuff. This allows us to deal with partial reads. I also fixed issues related to starting conversations with iChat and a couple other things. Fixes #2022,#1652
Daniel Atallah <datallah@pidgin.im>
parents:
18947
diff
changeset
|
425 | |
|
33783
8b37d3593783
bonjour: Similify code and get rid of some unnecessary control character removal
Daniel Atallah <datallah@pidgin.im>
parents:
33782
diff
changeset
|
426 | purple_debug_warning("bonjour", |
|
8b37d3593783
bonjour: Similify code and get rid of some unnecessary control character removal
Daniel Atallah <datallah@pidgin.im>
parents:
33782
diff
changeset
|
427 | "receive of %" G_GSSIZE_FORMAT " error: %s\n", |
|
8b37d3593783
bonjour: Similify code and get rid of some unnecessary control character removal
Daniel Atallah <datallah@pidgin.im>
parents:
33782
diff
changeset
|
428 | len, err ? err : "(null)"); |
|
19056
05cd9ab28312
Update the Bonjour prpl to use libxml explicitly instead of the xml_node stuff. This allows us to deal with partial reads. I also fixed issues related to starting conversations with iChat and a couple other things. Fixes #2022,#1652
Daniel Atallah <datallah@pidgin.im>
parents:
18947
diff
changeset
|
429 | |
|
21944
c41d17a1b8d9
This is the second part of the fix to support having multiple presence records in Bonjour (and also supporting multiple presences using the same IP). Incoming conversations are no longer immediately attached to a buddy - we use an algorithm to match a conversation to a buddy based on the IP and, if possible the "from" attribute of the stream or the first tag in the stream. Thanks to Sjoerd Simons from Telepahy Salut for noticing and suggesting the algorithm. Fixes #4187. It'd be good if a few people test this.
Daniel Atallah <datallah@pidgin.im>
parents:
21936
diff
changeset
|
430 | bonjour_jabber_close_conversation(bconv); |
|
24938
fc6952107e1f
Finished moving to api for bonjour
Gary Kramlich <grim@reaperworld.com>
parents:
24562
diff
changeset
|
431 | if (bconv->pb != NULL) { |
|
fc6952107e1f
Finished moving to api for bonjour
Gary Kramlich <grim@reaperworld.com>
parents:
24562
diff
changeset
|
432 | BonjourBuddy *bb = purple_buddy_get_protocol_data(bconv->pb); |
|
30825
87a79bbdc985
The hostname used for a bonjour account should always be the current machine
Daniel Atallah <datallah@pidgin.im>
parents:
30626
diff
changeset
|
433 | |
|
24938
fc6952107e1f
Finished moving to api for bonjour
Gary Kramlich <grim@reaperworld.com>
parents:
24562
diff
changeset
|
434 | if(bb != NULL) |
|
fc6952107e1f
Finished moving to api for bonjour
Gary Kramlich <grim@reaperworld.com>
parents:
24562
diff
changeset
|
435 | bb->conversation = NULL; |
|
21944
c41d17a1b8d9
This is the second part of the fix to support having multiple presence records in Bonjour (and also supporting multiple presences using the same IP). Incoming conversations are no longer immediately attached to a buddy - we use an algorithm to match a conversation to a buddy based on the IP and, if possible the "from" attribute of the stream or the first tag in the stream. Thanks to Sjoerd Simons from Telepahy Salut for noticing and suggesting the algorithm. Fixes #4187. It'd be good if a few people test this.
Daniel Atallah <datallah@pidgin.im>
parents:
21936
diff
changeset
|
436 | } |
|
17665
26bff2090889
Update Bonjour to do nonblocking I/O correctly.
Daniel Atallah <datallah@pidgin.im>
parents:
17663
diff
changeset
|
437 | |
|
26bff2090889
Update Bonjour to do nonblocking I/O correctly.
Daniel Atallah <datallah@pidgin.im>
parents:
17663
diff
changeset
|
438 | /* I guess we really don't need to notify the user. |
|
26bff2090889
Update Bonjour to do nonblocking I/O correctly.
Daniel Atallah <datallah@pidgin.im>
parents:
17663
diff
changeset
|
439 | * If they try to send another message it'll reconnect */ |
|
26bff2090889
Update Bonjour to do nonblocking I/O correctly.
Daniel Atallah <datallah@pidgin.im>
parents:
17663
diff
changeset
|
440 | } |
| 11477 | 441 | return; |
|
19056
05cd9ab28312
Update the Bonjour prpl to use libxml explicitly instead of the xml_node stuff. This allows us to deal with partial reads. I also fixed issues related to starting conversations with iChat and a couple other things. Fixes #2022,#1652
Daniel Atallah <datallah@pidgin.im>
parents:
18947
diff
changeset
|
442 | } else if (len == 0) { /* The other end has closed the socket */ |
|
24938
fc6952107e1f
Finished moving to api for bonjour
Gary Kramlich <grim@reaperworld.com>
parents:
24562
diff
changeset
|
443 | const gchar *name = purple_buddy_get_name(bconv->pb); |
|
fc6952107e1f
Finished moving to api for bonjour
Gary Kramlich <grim@reaperworld.com>
parents:
24562
diff
changeset
|
444 | purple_debug_warning("bonjour", "Connection closed (without stream end) by %s.\n", (name) ? name : "(unknown)"); |
|
21944
c41d17a1b8d9
This is the second part of the fix to support having multiple presence records in Bonjour (and also supporting multiple presences using the same IP). Incoming conversations are no longer immediately attached to a buddy - we use an algorithm to match a conversation to a buddy based on the IP and, if possible the "from" attribute of the stream or the first tag in the stream. Thanks to Sjoerd Simons from Telepahy Salut for noticing and suggesting the algorithm. Fixes #4187. It'd be good if a few people test this.
Daniel Atallah <datallah@pidgin.im>
parents:
21936
diff
changeset
|
445 | bonjour_jabber_stream_ended(bconv); |
|
19056
05cd9ab28312
Update the Bonjour prpl to use libxml explicitly instead of the xml_node stuff. This allows us to deal with partial reads. I also fixed issues related to starting conversations with iChat and a couple other things. Fixes #2022,#1652
Daniel Atallah <datallah@pidgin.im>
parents:
18947
diff
changeset
|
446 | return; |
| 11477 | 447 | } |
|
11539
fbabe3f89777
[gaim-migrate @ 13794]
Mark Doliner <markdoliner@pidgin.im>
parents:
11515
diff
changeset
|
448 | |
|
33783
8b37d3593783
bonjour: Similify code and get rid of some unnecessary control character removal
Daniel Atallah <datallah@pidgin.im>
parents:
33782
diff
changeset
|
449 | message[len] = '\0'; |
|
19056
05cd9ab28312
Update the Bonjour prpl to use libxml explicitly instead of the xml_node stuff. This allows us to deal with partial reads. I also fixed issues related to starting conversations with iChat and a couple other things. Fixes #2022,#1652
Daniel Atallah <datallah@pidgin.im>
parents:
18947
diff
changeset
|
450 | |
|
33783
8b37d3593783
bonjour: Similify code and get rid of some unnecessary control character removal
Daniel Atallah <datallah@pidgin.im>
parents:
33782
diff
changeset
|
451 | purple_debug_info("bonjour", "Receive: -%s- %" G_GSSIZE_FORMAT " bytes\n", message, len); |
|
8b37d3593783
bonjour: Similify code and get rid of some unnecessary control character removal
Daniel Atallah <datallah@pidgin.im>
parents:
33782
diff
changeset
|
452 | bonjour_parser_process(bconv, message, len); |
|
19056
05cd9ab28312
Update the Bonjour prpl to use libxml explicitly instead of the xml_node stuff. This allows us to deal with partial reads. I also fixed issues related to starting conversations with iChat and a couple other things. Fixes #2022,#1652
Daniel Atallah <datallah@pidgin.im>
parents:
18947
diff
changeset
|
453 | } |
|
17633
b76241c02857
Some more Bonjour cleanup and leak fixing.
Daniel Atallah <datallah@pidgin.im>
parents:
17632
diff
changeset
|
454 | |
|
17665
26bff2090889
Update Bonjour to do nonblocking I/O correctly.
Daniel Atallah <datallah@pidgin.im>
parents:
17663
diff
changeset
|
455 | struct _stream_start_data { |
|
26bff2090889
Update Bonjour to do nonblocking I/O correctly.
Daniel Atallah <datallah@pidgin.im>
parents:
17663
diff
changeset
|
456 | char *msg; |
|
26bff2090889
Update Bonjour to do nonblocking I/O correctly.
Daniel Atallah <datallah@pidgin.im>
parents:
17663
diff
changeset
|
457 | }; |
|
26bff2090889
Update Bonjour to do nonblocking I/O correctly.
Daniel Atallah <datallah@pidgin.im>
parents:
17663
diff
changeset
|
458 | |
|
19056
05cd9ab28312
Update the Bonjour prpl to use libxml explicitly instead of the xml_node stuff. This allows us to deal with partial reads. I also fixed issues related to starting conversations with iChat and a couple other things. Fixes #2022,#1652
Daniel Atallah <datallah@pidgin.im>
parents:
18947
diff
changeset
|
459 | |
|
17665
26bff2090889
Update Bonjour to do nonblocking I/O correctly.
Daniel Atallah <datallah@pidgin.im>
parents:
17663
diff
changeset
|
460 | static void |
|
26bff2090889
Update Bonjour to do nonblocking I/O correctly.
Daniel Atallah <datallah@pidgin.im>
parents:
17663
diff
changeset
|
461 | _start_stream(gpointer data, gint source, PurpleInputCondition condition) |
|
26bff2090889
Update Bonjour to do nonblocking I/O correctly.
Daniel Atallah <datallah@pidgin.im>
parents:
17663
diff
changeset
|
462 | { |
|
21944
c41d17a1b8d9
This is the second part of the fix to support having multiple presence records in Bonjour (and also supporting multiple presences using the same IP). Incoming conversations are no longer immediately attached to a buddy - we use an algorithm to match a conversation to a buddy based on the IP and, if possible the "from" attribute of the stream or the first tag in the stream. Thanks to Sjoerd Simons from Telepahy Salut for noticing and suggesting the algorithm. Fixes #4187. It'd be good if a few people test this.
Daniel Atallah <datallah@pidgin.im>
parents:
21936
diff
changeset
|
463 | BonjourJabberConversation *bconv = data; |
|
19056
05cd9ab28312
Update the Bonjour prpl to use libxml explicitly instead of the xml_node stuff. This allows us to deal with partial reads. I also fixed issues related to starting conversations with iChat and a couple other things. Fixes #2022,#1652
Daniel Atallah <datallah@pidgin.im>
parents:
18947
diff
changeset
|
464 | struct _stream_start_data *ss = bconv->stream_data; |
|
17665
26bff2090889
Update Bonjour to do nonblocking I/O correctly.
Daniel Atallah <datallah@pidgin.im>
parents:
17663
diff
changeset
|
465 | int len, ret; |
|
26bff2090889
Update Bonjour to do nonblocking I/O correctly.
Daniel Atallah <datallah@pidgin.im>
parents:
17663
diff
changeset
|
466 | |
|
26bff2090889
Update Bonjour to do nonblocking I/O correctly.
Daniel Atallah <datallah@pidgin.im>
parents:
17663
diff
changeset
|
467 | len = strlen(ss->msg); |
|
26bff2090889
Update Bonjour to do nonblocking I/O correctly.
Daniel Atallah <datallah@pidgin.im>
parents:
17663
diff
changeset
|
468 | |
|
26bff2090889
Update Bonjour to do nonblocking I/O correctly.
Daniel Atallah <datallah@pidgin.im>
parents:
17663
diff
changeset
|
469 | /* Start Stream */ |
|
26bff2090889
Update Bonjour to do nonblocking I/O correctly.
Daniel Atallah <datallah@pidgin.im>
parents:
17663
diff
changeset
|
470 | ret = send(source, ss->msg, len, 0); |
|
26bff2090889
Update Bonjour to do nonblocking I/O correctly.
Daniel Atallah <datallah@pidgin.im>
parents:
17663
diff
changeset
|
471 | |
|
26bff2090889
Update Bonjour to do nonblocking I/O correctly.
Daniel Atallah <datallah@pidgin.im>
parents:
17663
diff
changeset
|
472 | if (ret == -1 && errno == EAGAIN) |
|
26bff2090889
Update Bonjour to do nonblocking I/O correctly.
Daniel Atallah <datallah@pidgin.im>
parents:
17663
diff
changeset
|
473 | return; |
|
26bff2090889
Update Bonjour to do nonblocking I/O correctly.
Daniel Atallah <datallah@pidgin.im>
parents:
17663
diff
changeset
|
474 | else if (ret <= 0) { |
|
21389
e1dd8142bb87
replace most calls to strerror with calls to g_strerror. strerror will return
Nathan Walp <nwalp@pidgin.im>
parents:
21093
diff
changeset
|
475 | const char *err = g_strerror(errno); |
|
17665
26bff2090889
Update Bonjour to do nonblocking I/O correctly.
Daniel Atallah <datallah@pidgin.im>
parents:
17663
diff
changeset
|
476 | PurpleConversation *conv; |
|
21944
c41d17a1b8d9
This is the second part of the fix to support having multiple presence records in Bonjour (and also supporting multiple presences using the same IP). Incoming conversations are no longer immediately attached to a buddy - we use an algorithm to match a conversation to a buddy based on the IP and, if possible the "from" attribute of the stream or the first tag in the stream. Thanks to Sjoerd Simons from Telepahy Salut for noticing and suggesting the algorithm. Fixes #4187. It'd be good if a few people test this.
Daniel Atallah <datallah@pidgin.im>
parents:
21936
diff
changeset
|
477 | const char *bname = bconv->buddy_name; |
|
c41d17a1b8d9
This is the second part of the fix to support having multiple presence records in Bonjour (and also supporting multiple presences using the same IP). Incoming conversations are no longer immediately attached to a buddy - we use an algorithm to match a conversation to a buddy based on the IP and, if possible the "from" attribute of the stream or the first tag in the stream. Thanks to Sjoerd Simons from Telepahy Salut for noticing and suggesting the algorithm. Fixes #4187. It'd be good if a few people test this.
Daniel Atallah <datallah@pidgin.im>
parents:
21936
diff
changeset
|
478 | BonjourBuddy *bb = NULL; |
|
21920
3087a567aedf
Update Bonjour prpl to support multiple presence records for the same buddy. Eliminate the Howl backend to avoid having to maintain yet another set of code. References #4187 (more to come to fix the rest of the ticket).
Daniel Atallah <datallah@pidgin.im>
parents:
21917
diff
changeset
|
479 | |
|
21944
c41d17a1b8d9
This is the second part of the fix to support having multiple presence records in Bonjour (and also supporting multiple presences using the same IP). Incoming conversations are no longer immediately attached to a buddy - we use an algorithm to match a conversation to a buddy based on the IP and, if possible the "from" attribute of the stream or the first tag in the stream. Thanks to Sjoerd Simons from Telepahy Salut for noticing and suggesting the algorithm. Fixes #4187. It'd be good if a few people test this.
Daniel Atallah <datallah@pidgin.im>
parents:
21936
diff
changeset
|
480 | if(bconv->pb) { |
|
24938
fc6952107e1f
Finished moving to api for bonjour
Gary Kramlich <grim@reaperworld.com>
parents:
24562
diff
changeset
|
481 | bb = purple_buddy_get_protocol_data(bconv->pb); |
|
21944
c41d17a1b8d9
This is the second part of the fix to support having multiple presence records in Bonjour (and also supporting multiple presences using the same IP). Incoming conversations are no longer immediately attached to a buddy - we use an algorithm to match a conversation to a buddy based on the IP and, if possible the "from" attribute of the stream or the first tag in the stream. Thanks to Sjoerd Simons from Telepahy Salut for noticing and suggesting the algorithm. Fixes #4187. It'd be good if a few people test this.
Daniel Atallah <datallah@pidgin.im>
parents:
21936
diff
changeset
|
482 | bname = purple_buddy_get_name(bconv->pb); |
|
c41d17a1b8d9
This is the second part of the fix to support having multiple presence records in Bonjour (and also supporting multiple presences using the same IP). Incoming conversations are no longer immediately attached to a buddy - we use an algorithm to match a conversation to a buddy based on the IP and, if possible the "from" attribute of the stream or the first tag in the stream. Thanks to Sjoerd Simons from Telepahy Salut for noticing and suggesting the algorithm. Fixes #4187. It'd be good if a few people test this.
Daniel Atallah <datallah@pidgin.im>
parents:
21936
diff
changeset
|
483 | } |
|
17665
26bff2090889
Update Bonjour to do nonblocking I/O correctly.
Daniel Atallah <datallah@pidgin.im>
parents:
17663
diff
changeset
|
484 | |
|
21944
c41d17a1b8d9
This is the second part of the fix to support having multiple presence records in Bonjour (and also supporting multiple presences using the same IP). Incoming conversations are no longer immediately attached to a buddy - we use an algorithm to match a conversation to a buddy based on the IP and, if possible the "from" attribute of the stream or the first tag in the stream. Thanks to Sjoerd Simons from Telepahy Salut for noticing and suggesting the algorithm. Fixes #4187. It'd be good if a few people test this.
Daniel Atallah <datallah@pidgin.im>
parents:
21936
diff
changeset
|
485 | purple_debug_error("bonjour", "Error starting stream with buddy %s at %s error: %s\n", |
|
c41d17a1b8d9
This is the second part of the fix to support having multiple presence records in Bonjour (and also supporting multiple presences using the same IP). Incoming conversations are no longer immediately attached to a buddy - we use an algorithm to match a conversation to a buddy based on the IP and, if possible the "from" attribute of the stream or the first tag in the stream. Thanks to Sjoerd Simons from Telepahy Salut for noticing and suggesting the algorithm. Fixes #4187. It'd be good if a few people test this.
Daniel Atallah <datallah@pidgin.im>
parents:
21936
diff
changeset
|
486 | bname ? bname : "(unknown)", bconv->ip, err ? err : "(null)"); |
|
17665
26bff2090889
Update Bonjour to do nonblocking I/O correctly.
Daniel Atallah <datallah@pidgin.im>
parents:
17663
diff
changeset
|
487 | |
|
34632
ebe6b2a60305
Changed all arguments and return types of Chat and IMs to PurpleChatConversation and PurpleIMConversation.
Ankit Vani <a@nevitus.org>
parents:
34625
diff
changeset
|
488 | conv = PURPLE_CONVERSATION(purple_conversations_find_im_with_account(bname, bconv->account)); |
|
17665
26bff2090889
Update Bonjour to do nonblocking I/O correctly.
Daniel Atallah <datallah@pidgin.im>
parents:
17663
diff
changeset
|
489 | if (conv != NULL) |
|
26bff2090889
Update Bonjour to do nonblocking I/O correctly.
Daniel Atallah <datallah@pidgin.im>
parents:
17663
diff
changeset
|
490 | purple_conversation_write(conv, NULL, |
|
26bff2090889
Update Bonjour to do nonblocking I/O correctly.
Daniel Atallah <datallah@pidgin.im>
parents:
17663
diff
changeset
|
491 | _("Unable to send the message, the conversation couldn't be started."), |
|
26bff2090889
Update Bonjour to do nonblocking I/O correctly.
Daniel Atallah <datallah@pidgin.im>
parents:
17663
diff
changeset
|
492 | PURPLE_MESSAGE_SYSTEM, time(NULL)); |
|
26bff2090889
Update Bonjour to do nonblocking I/O correctly.
Daniel Atallah <datallah@pidgin.im>
parents:
17663
diff
changeset
|
493 | |
|
19056
05cd9ab28312
Update the Bonjour prpl to use libxml explicitly instead of the xml_node stuff. This allows us to deal with partial reads. I also fixed issues related to starting conversations with iChat and a couple other things. Fixes #2022,#1652
Daniel Atallah <datallah@pidgin.im>
parents:
18947
diff
changeset
|
494 | bonjour_jabber_close_conversation(bconv); |
|
21944
c41d17a1b8d9
This is the second part of the fix to support having multiple presence records in Bonjour (and also supporting multiple presences using the same IP). Incoming conversations are no longer immediately attached to a buddy - we use an algorithm to match a conversation to a buddy based on the IP and, if possible the "from" attribute of the stream or the first tag in the stream. Thanks to Sjoerd Simons from Telepahy Salut for noticing and suggesting the algorithm. Fixes #4187. It'd be good if a few people test this.
Daniel Atallah <datallah@pidgin.im>
parents:
21936
diff
changeset
|
495 | if(bb != NULL) |
|
c41d17a1b8d9
This is the second part of the fix to support having multiple presence records in Bonjour (and also supporting multiple presences using the same IP). Incoming conversations are no longer immediately attached to a buddy - we use an algorithm to match a conversation to a buddy based on the IP and, if possible the "from" attribute of the stream or the first tag in the stream. Thanks to Sjoerd Simons from Telepahy Salut for noticing and suggesting the algorithm. Fixes #4187. It'd be good if a few people test this.
Daniel Atallah <datallah@pidgin.im>
parents:
21936
diff
changeset
|
496 | bb->conversation = NULL; |
|
17665
26bff2090889
Update Bonjour to do nonblocking I/O correctly.
Daniel Atallah <datallah@pidgin.im>
parents:
17663
diff
changeset
|
497 | |
|
26bff2090889
Update Bonjour to do nonblocking I/O correctly.
Daniel Atallah <datallah@pidgin.im>
parents:
17663
diff
changeset
|
498 | return; |
|
26bff2090889
Update Bonjour to do nonblocking I/O correctly.
Daniel Atallah <datallah@pidgin.im>
parents:
17663
diff
changeset
|
499 | } |
|
26bff2090889
Update Bonjour to do nonblocking I/O correctly.
Daniel Atallah <datallah@pidgin.im>
parents:
17663
diff
changeset
|
500 | |
|
26bff2090889
Update Bonjour to do nonblocking I/O correctly.
Daniel Atallah <datallah@pidgin.im>
parents:
17663
diff
changeset
|
501 | /* This is EXTREMELY unlikely to happen */ |
|
26bff2090889
Update Bonjour to do nonblocking I/O correctly.
Daniel Atallah <datallah@pidgin.im>
parents:
17663
diff
changeset
|
502 | if (ret < len) { |
|
26bff2090889
Update Bonjour to do nonblocking I/O correctly.
Daniel Atallah <datallah@pidgin.im>
parents:
17663
diff
changeset
|
503 | char *tmp = g_strdup(ss->msg + ret); |
|
26bff2090889
Update Bonjour to do nonblocking I/O correctly.
Daniel Atallah <datallah@pidgin.im>
parents:
17663
diff
changeset
|
504 | g_free(ss->msg); |
|
26bff2090889
Update Bonjour to do nonblocking I/O correctly.
Daniel Atallah <datallah@pidgin.im>
parents:
17663
diff
changeset
|
505 | ss->msg = tmp; |
|
26bff2090889
Update Bonjour to do nonblocking I/O correctly.
Daniel Atallah <datallah@pidgin.im>
parents:
17663
diff
changeset
|
506 | return; |
|
26bff2090889
Update Bonjour to do nonblocking I/O correctly.
Daniel Atallah <datallah@pidgin.im>
parents:
17663
diff
changeset
|
507 | } |
|
26bff2090889
Update Bonjour to do nonblocking I/O correctly.
Daniel Atallah <datallah@pidgin.im>
parents:
17663
diff
changeset
|
508 | |
|
26bff2090889
Update Bonjour to do nonblocking I/O correctly.
Daniel Atallah <datallah@pidgin.im>
parents:
17663
diff
changeset
|
509 | g_free(ss->msg); |
|
26bff2090889
Update Bonjour to do nonblocking I/O correctly.
Daniel Atallah <datallah@pidgin.im>
parents:
17663
diff
changeset
|
510 | g_free(ss); |
|
19056
05cd9ab28312
Update the Bonjour prpl to use libxml explicitly instead of the xml_node stuff. This allows us to deal with partial reads. I also fixed issues related to starting conversations with iChat and a couple other things. Fixes #2022,#1652
Daniel Atallah <datallah@pidgin.im>
parents:
18947
diff
changeset
|
511 | bconv->stream_data = NULL; |
|
05cd9ab28312
Update the Bonjour prpl to use libxml explicitly instead of the xml_node stuff. This allows us to deal with partial reads. I also fixed issues related to starting conversations with iChat and a couple other things. Fixes #2022,#1652
Daniel Atallah <datallah@pidgin.im>
parents:
18947
diff
changeset
|
512 | |
|
05cd9ab28312
Update the Bonjour prpl to use libxml explicitly instead of the xml_node stuff. This allows us to deal with partial reads. I also fixed issues related to starting conversations with iChat and a couple other things. Fixes #2022,#1652
Daniel Atallah <datallah@pidgin.im>
parents:
18947
diff
changeset
|
513 | /* Stream started; process the send buffer if there is one */ |
|
05cd9ab28312
Update the Bonjour prpl to use libxml explicitly instead of the xml_node stuff. This allows us to deal with partial reads. I also fixed issues related to starting conversations with iChat and a couple other things. Fixes #2022,#1652
Daniel Atallah <datallah@pidgin.im>
parents:
18947
diff
changeset
|
514 | purple_input_remove(bconv->tx_handler); |
|
21727
decfc3a613ff
applied changes from b9c97ed0f9ada9069e8bd994b01fdde0b484083c
Daniel Atallah <datallah@pidgin.im>
parents:
21720
diff
changeset
|
515 | bconv->tx_handler = 0; |
|
decfc3a613ff
applied changes from b9c97ed0f9ada9069e8bd994b01fdde0b484083c
Daniel Atallah <datallah@pidgin.im>
parents:
21720
diff
changeset
|
516 | bconv->sent_stream_start = FULLY_SENT; |
|
19056
05cd9ab28312
Update the Bonjour prpl to use libxml explicitly instead of the xml_node stuff. This allows us to deal with partial reads. I also fixed issues related to starting conversations with iChat and a couple other things. Fixes #2022,#1652
Daniel Atallah <datallah@pidgin.im>
parents:
18947
diff
changeset
|
517 | |
|
21944
c41d17a1b8d9
This is the second part of the fix to support having multiple presence records in Bonjour (and also supporting multiple presences using the same IP). Incoming conversations are no longer immediately attached to a buddy - we use an algorithm to match a conversation to a buddy based on the IP and, if possible the "from" attribute of the stream or the first tag in the stream. Thanks to Sjoerd Simons from Telepahy Salut for noticing and suggesting the algorithm. Fixes #4187. It'd be good if a few people test this.
Daniel Atallah <datallah@pidgin.im>
parents:
21936
diff
changeset
|
518 | bonjour_jabber_stream_started(bconv); |
|
19056
05cd9ab28312
Update the Bonjour prpl to use libxml explicitly instead of the xml_node stuff. This allows us to deal with partial reads. I also fixed issues related to starting conversations with iChat and a couple other things. Fixes #2022,#1652
Daniel Atallah <datallah@pidgin.im>
parents:
18947
diff
changeset
|
519 | } |
|
05cd9ab28312
Update the Bonjour prpl to use libxml explicitly instead of the xml_node stuff. This allows us to deal with partial reads. I also fixed issues related to starting conversations with iChat and a couple other things. Fixes #2022,#1652
Daniel Atallah <datallah@pidgin.im>
parents:
18947
diff
changeset
|
520 | |
|
21944
c41d17a1b8d9
This is the second part of the fix to support having multiple presence records in Bonjour (and also supporting multiple presences using the same IP). Incoming conversations are no longer immediately attached to a buddy - we use an algorithm to match a conversation to a buddy based on the IP and, if possible the "from" attribute of the stream or the first tag in the stream. Thanks to Sjoerd Simons from Telepahy Salut for noticing and suggesting the algorithm. Fixes #4187. It'd be good if a few people test this.
Daniel Atallah <datallah@pidgin.im>
parents:
21936
diff
changeset
|
521 | static gboolean bonjour_jabber_send_stream_init(BonjourJabberConversation *bconv, int client_socket) |
|
19056
05cd9ab28312
Update the Bonjour prpl to use libxml explicitly instead of the xml_node stuff. This allows us to deal with partial reads. I also fixed issues related to starting conversations with iChat and a couple other things. Fixes #2022,#1652
Daniel Atallah <datallah@pidgin.im>
parents:
18947
diff
changeset
|
522 | { |
|
05cd9ab28312
Update the Bonjour prpl to use libxml explicitly instead of the xml_node stuff. This allows us to deal with partial reads. I also fixed issues related to starting conversations with iChat and a couple other things. Fixes #2022,#1652
Daniel Atallah <datallah@pidgin.im>
parents:
18947
diff
changeset
|
523 | int ret, len; |
|
05cd9ab28312
Update the Bonjour prpl to use libxml explicitly instead of the xml_node stuff. This allows us to deal with partial reads. I also fixed issues related to starting conversations with iChat and a couple other things. Fixes #2022,#1652
Daniel Atallah <datallah@pidgin.im>
parents:
18947
diff
changeset
|
524 | char *stream_start; |
|
21944
c41d17a1b8d9
This is the second part of the fix to support having multiple presence records in Bonjour (and also supporting multiple presences using the same IP). Incoming conversations are no longer immediately attached to a buddy - we use an algorithm to match a conversation to a buddy based on the IP and, if possible the "from" attribute of the stream or the first tag in the stream. Thanks to Sjoerd Simons from Telepahy Salut for noticing and suggesting the algorithm. Fixes #4187. It'd be good if a few people test this.
Daniel Atallah <datallah@pidgin.im>
parents:
21936
diff
changeset
|
525 | const char *bname = bconv->buddy_name; |
|
c41d17a1b8d9
This is the second part of the fix to support having multiple presence records in Bonjour (and also supporting multiple presences using the same IP). Incoming conversations are no longer immediately attached to a buddy - we use an algorithm to match a conversation to a buddy based on the IP and, if possible the "from" attribute of the stream or the first tag in the stream. Thanks to Sjoerd Simons from Telepahy Salut for noticing and suggesting the algorithm. Fixes #4187. It'd be good if a few people test this.
Daniel Atallah <datallah@pidgin.im>
parents:
21936
diff
changeset
|
526 | |
|
c41d17a1b8d9
This is the second part of the fix to support having multiple presence records in Bonjour (and also supporting multiple presences using the same IP). Incoming conversations are no longer immediately attached to a buddy - we use an algorithm to match a conversation to a buddy based on the IP and, if possible the "from" attribute of the stream or the first tag in the stream. Thanks to Sjoerd Simons from Telepahy Salut for noticing and suggesting the algorithm. Fixes #4187. It'd be good if a few people test this.
Daniel Atallah <datallah@pidgin.im>
parents:
21936
diff
changeset
|
527 | if (bconv->pb != NULL) |
|
c41d17a1b8d9
This is the second part of the fix to support having multiple presence records in Bonjour (and also supporting multiple presences using the same IP). Incoming conversations are no longer immediately attached to a buddy - we use an algorithm to match a conversation to a buddy based on the IP and, if possible the "from" attribute of the stream or the first tag in the stream. Thanks to Sjoerd Simons from Telepahy Salut for noticing and suggesting the algorithm. Fixes #4187. It'd be good if a few people test this.
Daniel Atallah <datallah@pidgin.im>
parents:
21936
diff
changeset
|
528 | bname = purple_buddy_get_name(bconv->pb); |
|
19056
05cd9ab28312
Update the Bonjour prpl to use libxml explicitly instead of the xml_node stuff. This allows us to deal with partial reads. I also fixed issues related to starting conversations with iChat and a couple other things. Fixes #2022,#1652
Daniel Atallah <datallah@pidgin.im>
parents:
18947
diff
changeset
|
529 | |
|
21944
c41d17a1b8d9
This is the second part of the fix to support having multiple presence records in Bonjour (and also supporting multiple presences using the same IP). Incoming conversations are no longer immediately attached to a buddy - we use an algorithm to match a conversation to a buddy based on the IP and, if possible the "from" attribute of the stream or the first tag in the stream. Thanks to Sjoerd Simons from Telepahy Salut for noticing and suggesting the algorithm. Fixes #4187. It'd be good if a few people test this.
Daniel Atallah <datallah@pidgin.im>
parents:
21936
diff
changeset
|
530 | /* If we have no idea who "to" is, use an empty string. |
|
c41d17a1b8d9
This is the second part of the fix to support having multiple presence records in Bonjour (and also supporting multiple presences using the same IP). Incoming conversations are no longer immediately attached to a buddy - we use an algorithm to match a conversation to a buddy based on the IP and, if possible the "from" attribute of the stream or the first tag in the stream. Thanks to Sjoerd Simons from Telepahy Salut for noticing and suggesting the algorithm. Fixes #4187. It'd be good if a few people test this.
Daniel Atallah <datallah@pidgin.im>
parents:
21936
diff
changeset
|
531 | * If we don't know now, it is because the other side isn't playing nice, so they can't complain. */ |
|
c41d17a1b8d9
This is the second part of the fix to support having multiple presence records in Bonjour (and also supporting multiple presences using the same IP). Incoming conversations are no longer immediately attached to a buddy - we use an algorithm to match a conversation to a buddy based on the IP and, if possible the "from" attribute of the stream or the first tag in the stream. Thanks to Sjoerd Simons from Telepahy Salut for noticing and suggesting the algorithm. Fixes #4187. It'd be good if a few people test this.
Daniel Atallah <datallah@pidgin.im>
parents:
21936
diff
changeset
|
532 | if (bname == NULL) |
|
c41d17a1b8d9
This is the second part of the fix to support having multiple presence records in Bonjour (and also supporting multiple presences using the same IP). Incoming conversations are no longer immediately attached to a buddy - we use an algorithm to match a conversation to a buddy based on the IP and, if possible the "from" attribute of the stream or the first tag in the stream. Thanks to Sjoerd Simons from Telepahy Salut for noticing and suggesting the algorithm. Fixes #4187. It'd be good if a few people test this.
Daniel Atallah <datallah@pidgin.im>
parents:
21936
diff
changeset
|
533 | bname = ""; |
|
c41d17a1b8d9
This is the second part of the fix to support having multiple presence records in Bonjour (and also supporting multiple presences using the same IP). Incoming conversations are no longer immediately attached to a buddy - we use an algorithm to match a conversation to a buddy based on the IP and, if possible the "from" attribute of the stream or the first tag in the stream. Thanks to Sjoerd Simons from Telepahy Salut for noticing and suggesting the algorithm. Fixes #4187. It'd be good if a few people test this.
Daniel Atallah <datallah@pidgin.im>
parents:
21936
diff
changeset
|
534 | |
|
30825
87a79bbdc985
The hostname used for a bonjour account should always be the current machine
Daniel Atallah <datallah@pidgin.im>
parents:
30626
diff
changeset
|
535 | stream_start = g_strdup_printf(DOCTYPE, bonjour_get_jid(bconv->account), bname); |
|
19056
05cd9ab28312
Update the Bonjour prpl to use libxml explicitly instead of the xml_node stuff. This allows us to deal with partial reads. I also fixed issues related to starting conversations with iChat and a couple other things. Fixes #2022,#1652
Daniel Atallah <datallah@pidgin.im>
parents:
18947
diff
changeset
|
536 | len = strlen(stream_start); |
|
05cd9ab28312
Update the Bonjour prpl to use libxml explicitly instead of the xml_node stuff. This allows us to deal with partial reads. I also fixed issues related to starting conversations with iChat and a couple other things. Fixes #2022,#1652
Daniel Atallah <datallah@pidgin.im>
parents:
18947
diff
changeset
|
537 | |
|
21944
c41d17a1b8d9
This is the second part of the fix to support having multiple presence records in Bonjour (and also supporting multiple presences using the same IP). Incoming conversations are no longer immediately attached to a buddy - we use an algorithm to match a conversation to a buddy based on the IP and, if possible the "from" attribute of the stream or the first tag in the stream. Thanks to Sjoerd Simons from Telepahy Salut for noticing and suggesting the algorithm. Fixes #4187. It'd be good if a few people test this.
Daniel Atallah <datallah@pidgin.im>
parents:
21936
diff
changeset
|
538 | bconv->sent_stream_start = PARTIALLY_SENT; |
|
21727
decfc3a613ff
applied changes from b9c97ed0f9ada9069e8bd994b01fdde0b484083c
Daniel Atallah <datallah@pidgin.im>
parents:
21720
diff
changeset
|
539 | |
|
19056
05cd9ab28312
Update the Bonjour prpl to use libxml explicitly instead of the xml_node stuff. This allows us to deal with partial reads. I also fixed issues related to starting conversations with iChat and a couple other things. Fixes #2022,#1652
Daniel Atallah <datallah@pidgin.im>
parents:
18947
diff
changeset
|
540 | /* Start the stream */ |
|
05cd9ab28312
Update the Bonjour prpl to use libxml explicitly instead of the xml_node stuff. This allows us to deal with partial reads. I also fixed issues related to starting conversations with iChat and a couple other things. Fixes #2022,#1652
Daniel Atallah <datallah@pidgin.im>
parents:
18947
diff
changeset
|
541 | ret = send(client_socket, stream_start, len, 0); |
|
05cd9ab28312
Update the Bonjour prpl to use libxml explicitly instead of the xml_node stuff. This allows us to deal with partial reads. I also fixed issues related to starting conversations with iChat and a couple other things. Fixes #2022,#1652
Daniel Atallah <datallah@pidgin.im>
parents:
18947
diff
changeset
|
542 | |
|
05cd9ab28312
Update the Bonjour prpl to use libxml explicitly instead of the xml_node stuff. This allows us to deal with partial reads. I also fixed issues related to starting conversations with iChat and a couple other things. Fixes #2022,#1652
Daniel Atallah <datallah@pidgin.im>
parents:
18947
diff
changeset
|
543 | if (ret == -1 && errno == EAGAIN) |
|
05cd9ab28312
Update the Bonjour prpl to use libxml explicitly instead of the xml_node stuff. This allows us to deal with partial reads. I also fixed issues related to starting conversations with iChat and a couple other things. Fixes #2022,#1652
Daniel Atallah <datallah@pidgin.im>
parents:
18947
diff
changeset
|
544 | ret = 0; |
|
05cd9ab28312
Update the Bonjour prpl to use libxml explicitly instead of the xml_node stuff. This allows us to deal with partial reads. I also fixed issues related to starting conversations with iChat and a couple other things. Fixes #2022,#1652
Daniel Atallah <datallah@pidgin.im>
parents:
18947
diff
changeset
|
545 | else if (ret <= 0) { |
|
21389
e1dd8142bb87
replace most calls to strerror with calls to g_strerror. strerror will return
Nathan Walp <nwalp@pidgin.im>
parents:
21093
diff
changeset
|
546 | const char *err = g_strerror(errno); |
|
21944
c41d17a1b8d9
This is the second part of the fix to support having multiple presence records in Bonjour (and also supporting multiple presences using the same IP). Incoming conversations are no longer immediately attached to a buddy - we use an algorithm to match a conversation to a buddy based on the IP and, if possible the "from" attribute of the stream or the first tag in the stream. Thanks to Sjoerd Simons from Telepahy Salut for noticing and suggesting the algorithm. Fixes #4187. It'd be good if a few people test this.
Daniel Atallah <datallah@pidgin.im>
parents:
21936
diff
changeset
|
547 | |
|
c41d17a1b8d9
This is the second part of the fix to support having multiple presence records in Bonjour (and also supporting multiple presences using the same IP). Incoming conversations are no longer immediately attached to a buddy - we use an algorithm to match a conversation to a buddy based on the IP and, if possible the "from" attribute of the stream or the first tag in the stream. Thanks to Sjoerd Simons from Telepahy Salut for noticing and suggesting the algorithm. Fixes #4187. It'd be good if a few people test this.
Daniel Atallah <datallah@pidgin.im>
parents:
21936
diff
changeset
|
548 | purple_debug_error("bonjour", "Error starting stream with buddy %s at %s error: %s\n", |
|
c41d17a1b8d9
This is the second part of the fix to support having multiple presence records in Bonjour (and also supporting multiple presences using the same IP). Incoming conversations are no longer immediately attached to a buddy - we use an algorithm to match a conversation to a buddy based on the IP and, if possible the "from" attribute of the stream or the first tag in the stream. Thanks to Sjoerd Simons from Telepahy Salut for noticing and suggesting the algorithm. Fixes #4187. It'd be good if a few people test this.
Daniel Atallah <datallah@pidgin.im>
parents:
21936
diff
changeset
|
549 | (*bname) ? bname : "(unknown)", bconv->ip, err ? err : "(null)"); |
|
21920
3087a567aedf
Update Bonjour prpl to support multiple presence records for the same buddy. Eliminate the Howl backend to avoid having to maintain yet another set of code. References #4187 (more to come to fix the rest of the ticket).
Daniel Atallah <datallah@pidgin.im>
parents:
21917
diff
changeset
|
550 | |
|
21944
c41d17a1b8d9
This is the second part of the fix to support having multiple presence records in Bonjour (and also supporting multiple presences using the same IP). Incoming conversations are no longer immediately attached to a buddy - we use an algorithm to match a conversation to a buddy based on the IP and, if possible the "from" attribute of the stream or the first tag in the stream. Thanks to Sjoerd Simons from Telepahy Salut for noticing and suggesting the algorithm. Fixes #4187. It'd be good if a few people test this.
Daniel Atallah <datallah@pidgin.im>
parents:
21936
diff
changeset
|
551 | if (bconv->pb) { |
|
c41d17a1b8d9
This is the second part of the fix to support having multiple presence records in Bonjour (and also supporting multiple presences using the same IP). Incoming conversations are no longer immediately attached to a buddy - we use an algorithm to match a conversation to a buddy based on the IP and, if possible the "from" attribute of the stream or the first tag in the stream. Thanks to Sjoerd Simons from Telepahy Salut for noticing and suggesting the algorithm. Fixes #4187. It'd be good if a few people test this.
Daniel Atallah <datallah@pidgin.im>
parents:
21936
diff
changeset
|
552 | PurpleConversation *conv; |
|
34632
ebe6b2a60305
Changed all arguments and return types of Chat and IMs to PurpleChatConversation and PurpleIMConversation.
Ankit Vani <a@nevitus.org>
parents:
34625
diff
changeset
|
553 | conv = PURPLE_CONVERSATION(purple_conversations_find_im_with_account(bname, bconv->account)); |
|
21944
c41d17a1b8d9
This is the second part of the fix to support having multiple presence records in Bonjour (and also supporting multiple presences using the same IP). Incoming conversations are no longer immediately attached to a buddy - we use an algorithm to match a conversation to a buddy based on the IP and, if possible the "from" attribute of the stream or the first tag in the stream. Thanks to Sjoerd Simons from Telepahy Salut for noticing and suggesting the algorithm. Fixes #4187. It'd be good if a few people test this.
Daniel Atallah <datallah@pidgin.im>
parents:
21936
diff
changeset
|
554 | if (conv != NULL) |
|
c41d17a1b8d9
This is the second part of the fix to support having multiple presence records in Bonjour (and also supporting multiple presences using the same IP). Incoming conversations are no longer immediately attached to a buddy - we use an algorithm to match a conversation to a buddy based on the IP and, if possible the "from" attribute of the stream or the first tag in the stream. Thanks to Sjoerd Simons from Telepahy Salut for noticing and suggesting the algorithm. Fixes #4187. It'd be good if a few people test this.
Daniel Atallah <datallah@pidgin.im>
parents:
21936
diff
changeset
|
555 | purple_conversation_write(conv, NULL, |
|
c41d17a1b8d9
This is the second part of the fix to support having multiple presence records in Bonjour (and also supporting multiple presences using the same IP). Incoming conversations are no longer immediately attached to a buddy - we use an algorithm to match a conversation to a buddy based on the IP and, if possible the "from" attribute of the stream or the first tag in the stream. Thanks to Sjoerd Simons from Telepahy Salut for noticing and suggesting the algorithm. Fixes #4187. It'd be good if a few people test this.
Daniel Atallah <datallah@pidgin.im>
parents:
21936
diff
changeset
|
556 | _("Unable to send the message, the conversation couldn't be started."), |
|
c41d17a1b8d9
This is the second part of the fix to support having multiple presence records in Bonjour (and also supporting multiple presences using the same IP). Incoming conversations are no longer immediately attached to a buddy - we use an algorithm to match a conversation to a buddy based on the IP and, if possible the "from" attribute of the stream or the first tag in the stream. Thanks to Sjoerd Simons from Telepahy Salut for noticing and suggesting the algorithm. Fixes #4187. It'd be good if a few people test this.
Daniel Atallah <datallah@pidgin.im>
parents:
21936
diff
changeset
|
557 | PURPLE_MESSAGE_SYSTEM, time(NULL)); |
|
c41d17a1b8d9
This is the second part of the fix to support having multiple presence records in Bonjour (and also supporting multiple presences using the same IP). Incoming conversations are no longer immediately attached to a buddy - we use an algorithm to match a conversation to a buddy based on the IP and, if possible the "from" attribute of the stream or the first tag in the stream. Thanks to Sjoerd Simons from Telepahy Salut for noticing and suggesting the algorithm. Fixes #4187. It'd be good if a few people test this.
Daniel Atallah <datallah@pidgin.im>
parents:
21936
diff
changeset
|
558 | } |
|
19056
05cd9ab28312
Update the Bonjour prpl to use libxml explicitly instead of the xml_node stuff. This allows us to deal with partial reads. I also fixed issues related to starting conversations with iChat and a couple other things. Fixes #2022,#1652
Daniel Atallah <datallah@pidgin.im>
parents:
18947
diff
changeset
|
559 | |
|
05cd9ab28312
Update the Bonjour prpl to use libxml explicitly instead of the xml_node stuff. This allows us to deal with partial reads. I also fixed issues related to starting conversations with iChat and a couple other things. Fixes #2022,#1652
Daniel Atallah <datallah@pidgin.im>
parents:
18947
diff
changeset
|
560 | close(client_socket); |
|
05cd9ab28312
Update the Bonjour prpl to use libxml explicitly instead of the xml_node stuff. This allows us to deal with partial reads. I also fixed issues related to starting conversations with iChat and a couple other things. Fixes #2022,#1652
Daniel Atallah <datallah@pidgin.im>
parents:
18947
diff
changeset
|
561 | g_free(stream_start); |
|
05cd9ab28312
Update the Bonjour prpl to use libxml explicitly instead of the xml_node stuff. This allows us to deal with partial reads. I also fixed issues related to starting conversations with iChat and a couple other things. Fixes #2022,#1652
Daniel Atallah <datallah@pidgin.im>
parents:
18947
diff
changeset
|
562 | |
|
05cd9ab28312
Update the Bonjour prpl to use libxml explicitly instead of the xml_node stuff. This allows us to deal with partial reads. I also fixed issues related to starting conversations with iChat and a couple other things. Fixes #2022,#1652
Daniel Atallah <datallah@pidgin.im>
parents:
18947
diff
changeset
|
563 | return FALSE; |
|
17665
26bff2090889
Update Bonjour to do nonblocking I/O correctly.
Daniel Atallah <datallah@pidgin.im>
parents:
17663
diff
changeset
|
564 | } |
|
19056
05cd9ab28312
Update the Bonjour prpl to use libxml explicitly instead of the xml_node stuff. This allows us to deal with partial reads. I also fixed issues related to starting conversations with iChat and a couple other things. Fixes #2022,#1652
Daniel Atallah <datallah@pidgin.im>
parents:
18947
diff
changeset
|
565 | |
|
05cd9ab28312
Update the Bonjour prpl to use libxml explicitly instead of the xml_node stuff. This allows us to deal with partial reads. I also fixed issues related to starting conversations with iChat and a couple other things. Fixes #2022,#1652
Daniel Atallah <datallah@pidgin.im>
parents:
18947
diff
changeset
|
566 | /* This is unlikely to happen */ |
|
05cd9ab28312
Update the Bonjour prpl to use libxml explicitly instead of the xml_node stuff. This allows us to deal with partial reads. I also fixed issues related to starting conversations with iChat and a couple other things. Fixes #2022,#1652
Daniel Atallah <datallah@pidgin.im>
parents:
18947
diff
changeset
|
567 | if (ret < len) { |
|
05cd9ab28312
Update the Bonjour prpl to use libxml explicitly instead of the xml_node stuff. This allows us to deal with partial reads. I also fixed issues related to starting conversations with iChat and a couple other things. Fixes #2022,#1652
Daniel Atallah <datallah@pidgin.im>
parents:
18947
diff
changeset
|
568 | struct _stream_start_data *ss = g_new(struct _stream_start_data, 1); |
|
05cd9ab28312
Update the Bonjour prpl to use libxml explicitly instead of the xml_node stuff. This allows us to deal with partial reads. I also fixed issues related to starting conversations with iChat and a couple other things. Fixes #2022,#1652
Daniel Atallah <datallah@pidgin.im>
parents:
18947
diff
changeset
|
569 | ss->msg = g_strdup(stream_start + ret); |
|
21944
c41d17a1b8d9
This is the second part of the fix to support having multiple presence records in Bonjour (and also supporting multiple presences using the same IP). Incoming conversations are no longer immediately attached to a buddy - we use an algorithm to match a conversation to a buddy based on the IP and, if possible the "from" attribute of the stream or the first tag in the stream. Thanks to Sjoerd Simons from Telepahy Salut for noticing and suggesting the algorithm. Fixes #4187. It'd be good if a few people test this.
Daniel Atallah <datallah@pidgin.im>
parents:
21936
diff
changeset
|
570 | bconv->stream_data = ss; |
|
19056
05cd9ab28312
Update the Bonjour prpl to use libxml explicitly instead of the xml_node stuff. This allows us to deal with partial reads. I also fixed issues related to starting conversations with iChat and a couple other things. Fixes #2022,#1652
Daniel Atallah <datallah@pidgin.im>
parents:
18947
diff
changeset
|
571 | /* Finish sending the stream start */ |
|
21944
c41d17a1b8d9
This is the second part of the fix to support having multiple presence records in Bonjour (and also supporting multiple presences using the same IP). Incoming conversations are no longer immediately attached to a buddy - we use an algorithm to match a conversation to a buddy based on the IP and, if possible the "from" attribute of the stream or the first tag in the stream. Thanks to Sjoerd Simons from Telepahy Salut for noticing and suggesting the algorithm. Fixes #4187. It'd be good if a few people test this.
Daniel Atallah <datallah@pidgin.im>
parents:
21936
diff
changeset
|
572 | bconv->tx_handler = purple_input_add(client_socket, |
|
c41d17a1b8d9
This is the second part of the fix to support having multiple presence records in Bonjour (and also supporting multiple presences using the same IP). Incoming conversations are no longer immediately attached to a buddy - we use an algorithm to match a conversation to a buddy based on the IP and, if possible the "from" attribute of the stream or the first tag in the stream. Thanks to Sjoerd Simons from Telepahy Salut for noticing and suggesting the algorithm. Fixes #4187. It'd be good if a few people test this.
Daniel Atallah <datallah@pidgin.im>
parents:
21936
diff
changeset
|
573 | PURPLE_INPUT_WRITE, _start_stream, bconv); |
|
19056
05cd9ab28312
Update the Bonjour prpl to use libxml explicitly instead of the xml_node stuff. This allows us to deal with partial reads. I also fixed issues related to starting conversations with iChat and a couple other things. Fixes #2022,#1652
Daniel Atallah <datallah@pidgin.im>
parents:
18947
diff
changeset
|
574 | } else |
|
21944
c41d17a1b8d9
This is the second part of the fix to support having multiple presence records in Bonjour (and also supporting multiple presences using the same IP). Incoming conversations are no longer immediately attached to a buddy - we use an algorithm to match a conversation to a buddy based on the IP and, if possible the "from" attribute of the stream or the first tag in the stream. Thanks to Sjoerd Simons from Telepahy Salut for noticing and suggesting the algorithm. Fixes #4187. It'd be good if a few people test this.
Daniel Atallah <datallah@pidgin.im>
parents:
21936
diff
changeset
|
575 | bconv->sent_stream_start = FULLY_SENT; |
|
19056
05cd9ab28312
Update the Bonjour prpl to use libxml explicitly instead of the xml_node stuff. This allows us to deal with partial reads. I also fixed issues related to starting conversations with iChat and a couple other things. Fixes #2022,#1652
Daniel Atallah <datallah@pidgin.im>
parents:
18947
diff
changeset
|
576 | |
|
05cd9ab28312
Update the Bonjour prpl to use libxml explicitly instead of the xml_node stuff. This allows us to deal with partial reads. I also fixed issues related to starting conversations with iChat and a couple other things. Fixes #2022,#1652
Daniel Atallah <datallah@pidgin.im>
parents:
18947
diff
changeset
|
577 | g_free(stream_start); |
|
05cd9ab28312
Update the Bonjour prpl to use libxml explicitly instead of the xml_node stuff. This allows us to deal with partial reads. I also fixed issues related to starting conversations with iChat and a couple other things. Fixes #2022,#1652
Daniel Atallah <datallah@pidgin.im>
parents:
18947
diff
changeset
|
578 | |
|
21727
decfc3a613ff
applied changes from b9c97ed0f9ada9069e8bd994b01fdde0b484083c
Daniel Atallah <datallah@pidgin.im>
parents:
21720
diff
changeset
|
579 | return TRUE; |
|
decfc3a613ff
applied changes from b9c97ed0f9ada9069e8bd994b01fdde0b484083c
Daniel Atallah <datallah@pidgin.im>
parents:
21720
diff
changeset
|
580 | } |
|
decfc3a613ff
applied changes from b9c97ed0f9ada9069e8bd994b01fdde0b484083c
Daniel Atallah <datallah@pidgin.im>
parents:
21720
diff
changeset
|
581 | |
|
21944
c41d17a1b8d9
This is the second part of the fix to support having multiple presence records in Bonjour (and also supporting multiple presences using the same IP). Incoming conversations are no longer immediately attached to a buddy - we use an algorithm to match a conversation to a buddy based on the IP and, if possible the "from" attribute of the stream or the first tag in the stream. Thanks to Sjoerd Simons from Telepahy Salut for noticing and suggesting the algorithm. Fixes #4187. It'd be good if a few people test this.
Daniel Atallah <datallah@pidgin.im>
parents:
21936
diff
changeset
|
582 | /* This gets called when we've successfully sent our <stream:stream /> |
|
30270
8380aae8b132
I before E, except after C
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
30249
diff
changeset
|
583 | * AND when we've received a <stream:stream /> */ |
|
21944
c41d17a1b8d9
This is the second part of the fix to support having multiple presence records in Bonjour (and also supporting multiple presences using the same IP). Incoming conversations are no longer immediately attached to a buddy - we use an algorithm to match a conversation to a buddy based on the IP and, if possible the "from" attribute of the stream or the first tag in the stream. Thanks to Sjoerd Simons from Telepahy Salut for noticing and suggesting the algorithm. Fixes #4187. It'd be good if a few people test this.
Daniel Atallah <datallah@pidgin.im>
parents:
21936
diff
changeset
|
584 | void bonjour_jabber_stream_started(BonjourJabberConversation *bconv) { |
|
21727
decfc3a613ff
applied changes from b9c97ed0f9ada9069e8bd994b01fdde0b484083c
Daniel Atallah <datallah@pidgin.im>
parents:
21720
diff
changeset
|
585 | |
|
21944
c41d17a1b8d9
This is the second part of the fix to support having multiple presence records in Bonjour (and also supporting multiple presences using the same IP). Incoming conversations are no longer immediately attached to a buddy - we use an algorithm to match a conversation to a buddy based on the IP and, if possible the "from" attribute of the stream or the first tag in the stream. Thanks to Sjoerd Simons from Telepahy Salut for noticing and suggesting the algorithm. Fixes #4187. It'd be good if a few people test this.
Daniel Atallah <datallah@pidgin.im>
parents:
21936
diff
changeset
|
586 | if (bconv->sent_stream_start == NOT_SENT && !bonjour_jabber_send_stream_init(bconv, bconv->socket)) { |
|
21727
decfc3a613ff
applied changes from b9c97ed0f9ada9069e8bd994b01fdde0b484083c
Daniel Atallah <datallah@pidgin.im>
parents:
21720
diff
changeset
|
587 | const char *err = g_strerror(errno); |
|
21944
c41d17a1b8d9
This is the second part of the fix to support having multiple presence records in Bonjour (and also supporting multiple presences using the same IP). Incoming conversations are no longer immediately attached to a buddy - we use an algorithm to match a conversation to a buddy based on the IP and, if possible the "from" attribute of the stream or the first tag in the stream. Thanks to Sjoerd Simons from Telepahy Salut for noticing and suggesting the algorithm. Fixes #4187. It'd be good if a few people test this.
Daniel Atallah <datallah@pidgin.im>
parents:
21936
diff
changeset
|
588 | const char *bname = bconv->buddy_name; |
|
21920
3087a567aedf
Update Bonjour prpl to support multiple presence records for the same buddy. Eliminate the Howl backend to avoid having to maintain yet another set of code. References #4187 (more to come to fix the rest of the ticket).
Daniel Atallah <datallah@pidgin.im>
parents:
21917
diff
changeset
|
589 | |
|
21944
c41d17a1b8d9
This is the second part of the fix to support having multiple presence records in Bonjour (and also supporting multiple presences using the same IP). Incoming conversations are no longer immediately attached to a buddy - we use an algorithm to match a conversation to a buddy based on the IP and, if possible the "from" attribute of the stream or the first tag in the stream. Thanks to Sjoerd Simons from Telepahy Salut for noticing and suggesting the algorithm. Fixes #4187. It'd be good if a few people test this.
Daniel Atallah <datallah@pidgin.im>
parents:
21936
diff
changeset
|
590 | if (bconv->pb) |
|
c41d17a1b8d9
This is the second part of the fix to support having multiple presence records in Bonjour (and also supporting multiple presences using the same IP). Incoming conversations are no longer immediately attached to a buddy - we use an algorithm to match a conversation to a buddy based on the IP and, if possible the "from" attribute of the stream or the first tag in the stream. Thanks to Sjoerd Simons from Telepahy Salut for noticing and suggesting the algorithm. Fixes #4187. It'd be good if a few people test this.
Daniel Atallah <datallah@pidgin.im>
parents:
21936
diff
changeset
|
591 | bname = purple_buddy_get_name(bconv->pb); |
|
c41d17a1b8d9
This is the second part of the fix to support having multiple presence records in Bonjour (and also supporting multiple presences using the same IP). Incoming conversations are no longer immediately attached to a buddy - we use an algorithm to match a conversation to a buddy based on the IP and, if possible the "from" attribute of the stream or the first tag in the stream. Thanks to Sjoerd Simons from Telepahy Salut for noticing and suggesting the algorithm. Fixes #4187. It'd be good if a few people test this.
Daniel Atallah <datallah@pidgin.im>
parents:
21936
diff
changeset
|
592 | |
|
c41d17a1b8d9
This is the second part of the fix to support having multiple presence records in Bonjour (and also supporting multiple presences using the same IP). Incoming conversations are no longer immediately attached to a buddy - we use an algorithm to match a conversation to a buddy based on the IP and, if possible the "from" attribute of the stream or the first tag in the stream. Thanks to Sjoerd Simons from Telepahy Salut for noticing and suggesting the algorithm. Fixes #4187. It'd be good if a few people test this.
Daniel Atallah <datallah@pidgin.im>
parents:
21936
diff
changeset
|
593 | purple_debug_error("bonjour", "Error starting stream with buddy %s at %s error: %s\n", |
|
c41d17a1b8d9
This is the second part of the fix to support having multiple presence records in Bonjour (and also supporting multiple presences using the same IP). Incoming conversations are no longer immediately attached to a buddy - we use an algorithm to match a conversation to a buddy based on the IP and, if possible the "from" attribute of the stream or the first tag in the stream. Thanks to Sjoerd Simons from Telepahy Salut for noticing and suggesting the algorithm. Fixes #4187. It'd be good if a few people test this.
Daniel Atallah <datallah@pidgin.im>
parents:
21936
diff
changeset
|
594 | bname ? bname : "(unknown)", bconv->ip, err ? err : "(null)"); |
|
21727
decfc3a613ff
applied changes from b9c97ed0f9ada9069e8bd994b01fdde0b484083c
Daniel Atallah <datallah@pidgin.im>
parents:
21720
diff
changeset
|
595 | |
|
21944
c41d17a1b8d9
This is the second part of the fix to support having multiple presence records in Bonjour (and also supporting multiple presences using the same IP). Incoming conversations are no longer immediately attached to a buddy - we use an algorithm to match a conversation to a buddy based on the IP and, if possible the "from" attribute of the stream or the first tag in the stream. Thanks to Sjoerd Simons from Telepahy Salut for noticing and suggesting the algorithm. Fixes #4187. It'd be good if a few people test this.
Daniel Atallah <datallah@pidgin.im>
parents:
21936
diff
changeset
|
596 | if (bconv->pb) { |
|
c41d17a1b8d9
This is the second part of the fix to support having multiple presence records in Bonjour (and also supporting multiple presences using the same IP). Incoming conversations are no longer immediately attached to a buddy - we use an algorithm to match a conversation to a buddy based on the IP and, if possible the "from" attribute of the stream or the first tag in the stream. Thanks to Sjoerd Simons from Telepahy Salut for noticing and suggesting the algorithm. Fixes #4187. It'd be good if a few people test this.
Daniel Atallah <datallah@pidgin.im>
parents:
21936
diff
changeset
|
597 | PurpleConversation *conv; |
|
34632
ebe6b2a60305
Changed all arguments and return types of Chat and IMs to PurpleChatConversation and PurpleIMConversation.
Ankit Vani <a@nevitus.org>
parents:
34625
diff
changeset
|
598 | conv = PURPLE_CONVERSATION(purple_conversations_find_im_with_account(bname, bconv->account)); |
|
21944
c41d17a1b8d9
This is the second part of the fix to support having multiple presence records in Bonjour (and also supporting multiple presences using the same IP). Incoming conversations are no longer immediately attached to a buddy - we use an algorithm to match a conversation to a buddy based on the IP and, if possible the "from" attribute of the stream or the first tag in the stream. Thanks to Sjoerd Simons from Telepahy Salut for noticing and suggesting the algorithm. Fixes #4187. It'd be good if a few people test this.
Daniel Atallah <datallah@pidgin.im>
parents:
21936
diff
changeset
|
599 | if (conv != NULL) |
|
c41d17a1b8d9
This is the second part of the fix to support having multiple presence records in Bonjour (and also supporting multiple presences using the same IP). Incoming conversations are no longer immediately attached to a buddy - we use an algorithm to match a conversation to a buddy based on the IP and, if possible the "from" attribute of the stream or the first tag in the stream. Thanks to Sjoerd Simons from Telepahy Salut for noticing and suggesting the algorithm. Fixes #4187. It'd be good if a few people test this.
Daniel Atallah <datallah@pidgin.im>
parents:
21936
diff
changeset
|
600 | purple_conversation_write(conv, NULL, |
|
c41d17a1b8d9
This is the second part of the fix to support having multiple presence records in Bonjour (and also supporting multiple presences using the same IP). Incoming conversations are no longer immediately attached to a buddy - we use an algorithm to match a conversation to a buddy based on the IP and, if possible the "from" attribute of the stream or the first tag in the stream. Thanks to Sjoerd Simons from Telepahy Salut for noticing and suggesting the algorithm. Fixes #4187. It'd be good if a few people test this.
Daniel Atallah <datallah@pidgin.im>
parents:
21936
diff
changeset
|
601 | _("Unable to send the message, the conversation couldn't be started."), |
|
c41d17a1b8d9
This is the second part of the fix to support having multiple presence records in Bonjour (and also supporting multiple presences using the same IP). Incoming conversations are no longer immediately attached to a buddy - we use an algorithm to match a conversation to a buddy based on the IP and, if possible the "from" attribute of the stream or the first tag in the stream. Thanks to Sjoerd Simons from Telepahy Salut for noticing and suggesting the algorithm. Fixes #4187. It'd be good if a few people test this.
Daniel Atallah <datallah@pidgin.im>
parents:
21936
diff
changeset
|
602 | PURPLE_MESSAGE_SYSTEM, time(NULL)); |
|
c41d17a1b8d9
This is the second part of the fix to support having multiple presence records in Bonjour (and also supporting multiple presences using the same IP). Incoming conversations are no longer immediately attached to a buddy - we use an algorithm to match a conversation to a buddy based on the IP and, if possible the "from" attribute of the stream or the first tag in the stream. Thanks to Sjoerd Simons from Telepahy Salut for noticing and suggesting the algorithm. Fixes #4187. It'd be good if a few people test this.
Daniel Atallah <datallah@pidgin.im>
parents:
21936
diff
changeset
|
603 | } |
|
19056
05cd9ab28312
Update the Bonjour prpl to use libxml explicitly instead of the xml_node stuff. This allows us to deal with partial reads. I also fixed issues related to starting conversations with iChat and a couple other things. Fixes #2022,#1652
Daniel Atallah <datallah@pidgin.im>
parents:
18947
diff
changeset
|
604 | |
|
21944
c41d17a1b8d9
This is the second part of the fix to support having multiple presence records in Bonjour (and also supporting multiple presences using the same IP). Incoming conversations are no longer immediately attached to a buddy - we use an algorithm to match a conversation to a buddy based on the IP and, if possible the "from" attribute of the stream or the first tag in the stream. Thanks to Sjoerd Simons from Telepahy Salut for noticing and suggesting the algorithm. Fixes #4187. It'd be good if a few people test this.
Daniel Atallah <datallah@pidgin.im>
parents:
21936
diff
changeset
|
605 | /* We don't want to recieve anything else */ |
|
c41d17a1b8d9
This is the second part of the fix to support having multiple presence records in Bonjour (and also supporting multiple presences using the same IP). Incoming conversations are no longer immediately attached to a buddy - we use an algorithm to match a conversation to a buddy based on the IP and, if possible the "from" attribute of the stream or the first tag in the stream. Thanks to Sjoerd Simons from Telepahy Salut for noticing and suggesting the algorithm. Fixes #4187. It'd be good if a few people test this.
Daniel Atallah <datallah@pidgin.im>
parents:
21936
diff
changeset
|
606 | close(bconv->socket); |
|
c41d17a1b8d9
This is the second part of the fix to support having multiple presence records in Bonjour (and also supporting multiple presences using the same IP). Incoming conversations are no longer immediately attached to a buddy - we use an algorithm to match a conversation to a buddy based on the IP and, if possible the "from" attribute of the stream or the first tag in the stream. Thanks to Sjoerd Simons from Telepahy Salut for noticing and suggesting the algorithm. Fixes #4187. It'd be good if a few people test this.
Daniel Atallah <datallah@pidgin.im>
parents:
21936
diff
changeset
|
607 | bconv->socket = -1; |
|
19056
05cd9ab28312
Update the Bonjour prpl to use libxml explicitly instead of the xml_node stuff. This allows us to deal with partial reads. I also fixed issues related to starting conversations with iChat and a couple other things. Fixes #2022,#1652
Daniel Atallah <datallah@pidgin.im>
parents:
18947
diff
changeset
|
608 | |
|
21727
decfc3a613ff
applied changes from b9c97ed0f9ada9069e8bd994b01fdde0b484083c
Daniel Atallah <datallah@pidgin.im>
parents:
21720
diff
changeset
|
609 | /* This must be asynchronous because it destroys the parser and we |
|
decfc3a613ff
applied changes from b9c97ed0f9ada9069e8bd994b01fdde0b484083c
Daniel Atallah <datallah@pidgin.im>
parents:
21720
diff
changeset
|
610 | * may be in the middle of parsing. |
|
decfc3a613ff
applied changes from b9c97ed0f9ada9069e8bd994b01fdde0b484083c
Daniel Atallah <datallah@pidgin.im>
parents:
21720
diff
changeset
|
611 | */ |
|
21944
c41d17a1b8d9
This is the second part of the fix to support having multiple presence records in Bonjour (and also supporting multiple presences using the same IP). Incoming conversations are no longer immediately attached to a buddy - we use an algorithm to match a conversation to a buddy based on the IP and, if possible the "from" attribute of the stream or the first tag in the stream. Thanks to Sjoerd Simons from Telepahy Salut for noticing and suggesting the algorithm. Fixes #4187. It'd be good if a few people test this.
Daniel Atallah <datallah@pidgin.im>
parents:
21936
diff
changeset
|
612 | async_bonjour_jabber_close_conversation(bconv); |
|
21727
decfc3a613ff
applied changes from b9c97ed0f9ada9069e8bd994b01fdde0b484083c
Daniel Atallah <datallah@pidgin.im>
parents:
21720
diff
changeset
|
613 | return; |
|
decfc3a613ff
applied changes from b9c97ed0f9ada9069e8bd994b01fdde0b484083c
Daniel Atallah <datallah@pidgin.im>
parents:
21720
diff
changeset
|
614 | } |
|
decfc3a613ff
applied changes from b9c97ed0f9ada9069e8bd994b01fdde0b484083c
Daniel Atallah <datallah@pidgin.im>
parents:
21720
diff
changeset
|
615 | |
|
21944
c41d17a1b8d9
This is the second part of the fix to support having multiple presence records in Bonjour (and also supporting multiple presences using the same IP). Incoming conversations are no longer immediately attached to a buddy - we use an algorithm to match a conversation to a buddy based on the IP and, if possible the "from" attribute of the stream or the first tag in the stream. Thanks to Sjoerd Simons from Telepahy Salut for noticing and suggesting the algorithm. Fixes #4187. It'd be good if a few people test this.
Daniel Atallah <datallah@pidgin.im>
parents:
21936
diff
changeset
|
616 | /* If the stream has been completely started and we know who we're talking to, we can start doing stuff. */ |
|
c41d17a1b8d9
This is the second part of the fix to support having multiple presence records in Bonjour (and also supporting multiple presences using the same IP). Incoming conversations are no longer immediately attached to a buddy - we use an algorithm to match a conversation to a buddy based on the IP and, if possible the "from" attribute of the stream or the first tag in the stream. Thanks to Sjoerd Simons from Telepahy Salut for noticing and suggesting the algorithm. Fixes #4187. It'd be good if a few people test this.
Daniel Atallah <datallah@pidgin.im>
parents:
21936
diff
changeset
|
617 | /* I don't think the circ_buffer can actually contain anything without a buddy being associated, but lets be explicit. */ |
|
c41d17a1b8d9
This is the second part of the fix to support having multiple presence records in Bonjour (and also supporting multiple presences using the same IP). Incoming conversations are no longer immediately attached to a buddy - we use an algorithm to match a conversation to a buddy based on the IP and, if possible the "from" attribute of the stream or the first tag in the stream. Thanks to Sjoerd Simons from Telepahy Salut for noticing and suggesting the algorithm. Fixes #4187. It'd be good if a few people test this.
Daniel Atallah <datallah@pidgin.im>
parents:
21936
diff
changeset
|
618 | if (bconv->sent_stream_start == FULLY_SENT && bconv->recv_stream_start |
|
34529
68cf25486001
GObjectify PurpleCircBuffer as PurpleCircularBuffer (from gobjectification branch)
Ankit Vani <a@nevitus.org>
parents:
33892
diff
changeset
|
619 | && bconv->pb && purple_circular_buffer_get_max_read(bconv->tx_buf) > 0) { |
|
21727
decfc3a613ff
applied changes from b9c97ed0f9ada9069e8bd994b01fdde0b484083c
Daniel Atallah <datallah@pidgin.im>
parents:
21720
diff
changeset
|
620 | /* Watch for when we can write the buffered messages */ |
|
decfc3a613ff
applied changes from b9c97ed0f9ada9069e8bd994b01fdde0b484083c
Daniel Atallah <datallah@pidgin.im>
parents:
21720
diff
changeset
|
621 | bconv->tx_handler = purple_input_add(bconv->socket, PURPLE_INPUT_WRITE, |
|
21944
c41d17a1b8d9
This is the second part of the fix to support having multiple presence records in Bonjour (and also supporting multiple presences using the same IP). Incoming conversations are no longer immediately attached to a buddy - we use an algorithm to match a conversation to a buddy based on the IP and, if possible the "from" attribute of the stream or the first tag in the stream. Thanks to Sjoerd Simons from Telepahy Salut for noticing and suggesting the algorithm. Fixes #4187. It'd be good if a few people test this.
Daniel Atallah <datallah@pidgin.im>
parents:
21936
diff
changeset
|
622 | _send_data_write_cb, bconv->pb); |
|
21727
decfc3a613ff
applied changes from b9c97ed0f9ada9069e8bd994b01fdde0b484083c
Daniel Atallah <datallah@pidgin.im>
parents:
21720
diff
changeset
|
623 | /* We can probably write the data right now. */ |
|
21944
c41d17a1b8d9
This is the second part of the fix to support having multiple presence records in Bonjour (and also supporting multiple presences using the same IP). Incoming conversations are no longer immediately attached to a buddy - we use an algorithm to match a conversation to a buddy based on the IP and, if possible the "from" attribute of the stream or the first tag in the stream. Thanks to Sjoerd Simons from Telepahy Salut for noticing and suggesting the algorithm. Fixes #4187. It'd be good if a few people test this.
Daniel Atallah <datallah@pidgin.im>
parents:
21936
diff
changeset
|
624 | _send_data_write_cb(bconv->pb, bconv->socket, PURPLE_INPUT_WRITE); |
|
21727
decfc3a613ff
applied changes from b9c97ed0f9ada9069e8bd994b01fdde0b484083c
Daniel Atallah <datallah@pidgin.im>
parents:
21720
diff
changeset
|
625 | } |
|
decfc3a613ff
applied changes from b9c97ed0f9ada9069e8bd994b01fdde0b484083c
Daniel Atallah <datallah@pidgin.im>
parents:
21720
diff
changeset
|
626 | |
|
17665
26bff2090889
Update Bonjour to do nonblocking I/O correctly.
Daniel Atallah <datallah@pidgin.im>
parents:
17663
diff
changeset
|
627 | } |
|
26bff2090889
Update Bonjour to do nonblocking I/O correctly.
Daniel Atallah <datallah@pidgin.im>
parents:
17663
diff
changeset
|
628 | |
|
29761
0f6862f2782f
Implementation of IPv6 support for Bonjour
Daniel Atallah <datallah@pidgin.im>
parents:
27625
diff
changeset
|
629 | #ifndef INET6_ADDRSTRLEN |
|
0f6862f2782f
Implementation of IPv6 support for Bonjour
Daniel Atallah <datallah@pidgin.im>
parents:
27625
diff
changeset
|
630 | #define INET6_ADDRSTRLEN 46 |
|
0f6862f2782f
Implementation of IPv6 support for Bonjour
Daniel Atallah <datallah@pidgin.im>
parents:
27625
diff
changeset
|
631 | #endif |
|
0f6862f2782f
Implementation of IPv6 support for Bonjour
Daniel Atallah <datallah@pidgin.im>
parents:
27625
diff
changeset
|
632 | |
|
12443
ad94864144f8
[gaim-migrate @ 14750]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
11830
diff
changeset
|
633 | static void |
| 15884 | 634 | _server_socket_handler(gpointer data, int server_socket, PurpleInputCondition condition) |
| 11477 | 635 | { |
|
21944
c41d17a1b8d9
This is the second part of the fix to support having multiple presence records in Bonjour (and also supporting multiple presences using the same IP). Incoming conversations are no longer immediately attached to a buddy - we use an algorithm to match a conversation to a buddy based on the IP and, if possible the "from" attribute of the stream or the first tag in the stream. Thanks to Sjoerd Simons from Telepahy Salut for noticing and suggesting the algorithm. Fixes #4187. It'd be good if a few people test this.
Daniel Atallah <datallah@pidgin.im>
parents:
21936
diff
changeset
|
636 | BonjourJabber *jdata = data; |
|
35554
fdd1f3a3c6df
Fix the last ppc64 warning
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35499
diff
changeset
|
637 | common_sockaddr_t their_addr; /* connector's address information */ |
|
fdd1f3a3c6df
Fix the last ppc64 warning
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35499
diff
changeset
|
638 | socklen_t sin_size = sizeof(common_sockaddr_t); |
| 11477 | 639 | int client_socket; |
|
20239
ae122f419324
applied changes from 2762c6075c0dc52a96098c5478c5bf68cfd890a3
Luke Schierer <lschiere@pidgin.im>
parents:
19859
diff
changeset
|
640 | int flags; |
|
29761
0f6862f2782f
Implementation of IPv6 support for Bonjour
Daniel Atallah <datallah@pidgin.im>
parents:
27625
diff
changeset
|
641 | #ifdef HAVE_INET_NTOP |
|
0f6862f2782f
Implementation of IPv6 support for Bonjour
Daniel Atallah <datallah@pidgin.im>
parents:
27625
diff
changeset
|
642 | char addrstr[INET6_ADDRSTRLEN]; |
|
0f6862f2782f
Implementation of IPv6 support for Bonjour
Daniel Atallah <datallah@pidgin.im>
parents:
27625
diff
changeset
|
643 | #endif |
|
0f6862f2782f
Implementation of IPv6 support for Bonjour
Daniel Atallah <datallah@pidgin.im>
parents:
27625
diff
changeset
|
644 | const char *address_text; |
|
21944
c41d17a1b8d9
This is the second part of the fix to support having multiple presence records in Bonjour (and also supporting multiple presences using the same IP). Incoming conversations are no longer immediately attached to a buddy - we use an algorithm to match a conversation to a buddy based on the IP and, if possible the "from" attribute of the stream or the first tag in the stream. Thanks to Sjoerd Simons from Telepahy Salut for noticing and suggesting the algorithm. Fixes #4187. It'd be good if a few people test this.
Daniel Atallah <datallah@pidgin.im>
parents:
21936
diff
changeset
|
645 | struct _match_buddies_by_address_t *mbba; |
|
c41d17a1b8d9
This is the second part of the fix to support having multiple presence records in Bonjour (and also supporting multiple presences using the same IP). Incoming conversations are no longer immediately attached to a buddy - we use an algorithm to match a conversation to a buddy based on the IP and, if possible the "from" attribute of the stream or the first tag in the stream. Thanks to Sjoerd Simons from Telepahy Salut for noticing and suggesting the algorithm. Fixes #4187. It'd be good if a few people test this.
Daniel Atallah <datallah@pidgin.im>
parents:
21936
diff
changeset
|
646 | BonjourJabberConversation *bconv; |
|
26767
7489049a3bde
Change purple_blist_get_buddies to return a list instead of the hash table.
Paul Aurich <darkrain42@pidgin.im>
parents:
25911
diff
changeset
|
647 | GSList *buddies; |
| 11477 | 648 | |
|
11826
10ebbc41f163
[gaim-migrate @ 14117]
Richard Laager <rlaager@pidgin.im>
parents:
11823
diff
changeset
|
649 | /* Check that it is a read condition */ |
|
17633
b76241c02857
Some more Bonjour cleanup and leak fixing.
Daniel Atallah <datallah@pidgin.im>
parents:
17632
diff
changeset
|
650 | if (condition != PURPLE_INPUT_READ) |
| 11477 | 651 | return; |
| 652 | ||
|
29761
0f6862f2782f
Implementation of IPv6 support for Bonjour
Daniel Atallah <datallah@pidgin.im>
parents:
27625
diff
changeset
|
653 | memset(&their_addr, 0, sin_size); |
|
0f6862f2782f
Implementation of IPv6 support for Bonjour
Daniel Atallah <datallah@pidgin.im>
parents:
27625
diff
changeset
|
654 | |
|
35554
fdd1f3a3c6df
Fix the last ppc64 warning
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35499
diff
changeset
|
655 | if ((client_socket = accept(server_socket, &their_addr.sa, &sin_size)) == -1) |
| 11477 | 656 | return; |
|
17633
b76241c02857
Some more Bonjour cleanup and leak fixing.
Daniel Atallah <datallah@pidgin.im>
parents:
17632
diff
changeset
|
657 | |
|
20239
ae122f419324
applied changes from 2762c6075c0dc52a96098c5478c5bf68cfd890a3
Luke Schierer <lschiere@pidgin.im>
parents:
19859
diff
changeset
|
658 | flags = fcntl(client_socket, F_GETFL); |
|
ae122f419324
applied changes from 2762c6075c0dc52a96098c5478c5bf68cfd890a3
Luke Schierer <lschiere@pidgin.im>
parents:
19859
diff
changeset
|
659 | fcntl(client_socket, F_SETFL, flags | O_NONBLOCK); |
|
24039
8173b6258f5a
These fds don't need to be inherited by child processes.
Daniel Atallah <datallah@pidgin.im>
parents:
23883
diff
changeset
|
660 | #ifndef _WIN32 |
|
8173b6258f5a
These fds don't need to be inherited by child processes.
Daniel Atallah <datallah@pidgin.im>
parents:
23883
diff
changeset
|
661 | fcntl(client_socket, F_SETFD, FD_CLOEXEC); |
|
8173b6258f5a
These fds don't need to be inherited by child processes.
Daniel Atallah <datallah@pidgin.im>
parents:
23883
diff
changeset
|
662 | #endif |
| 11477 | 663 | |
| 13962 | 664 | /* Look for the buddy that has opened the conversation and fill information */ |
|
29761
0f6862f2782f
Implementation of IPv6 support for Bonjour
Daniel Atallah <datallah@pidgin.im>
parents:
27625
diff
changeset
|
665 | #ifdef HAVE_INET_NTOP |
|
35554
fdd1f3a3c6df
Fix the last ppc64 warning
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35499
diff
changeset
|
666 | if (their_addr.sa.sa_family == AF_INET6) { |
|
fdd1f3a3c6df
Fix the last ppc64 warning
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35499
diff
changeset
|
667 | address_text = inet_ntop(their_addr.sa.sa_family, |
|
fdd1f3a3c6df
Fix the last ppc64 warning
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35499
diff
changeset
|
668 | &their_addr.in6.sin6_addr, addrstr, sizeof(addrstr)); |
|
32058
95953bd2f239
Append interface ID only to local interfaces for IPv6 Bonjour.
Linus Lüssing <linus.luessing@web.de>
parents:
31749
diff
changeset
|
669 | |
|
35554
fdd1f3a3c6df
Fix the last ppc64 warning
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35499
diff
changeset
|
670 | append_iface_if_linklocal(addrstr, their_addr.in6.sin6_scope_id); |
|
fdd1f3a3c6df
Fix the last ppc64 warning
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35499
diff
changeset
|
671 | } else { |
|
fdd1f3a3c6df
Fix the last ppc64 warning
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35499
diff
changeset
|
672 | address_text = inet_ntop(their_addr.sa.sa_family, |
|
fdd1f3a3c6df
Fix the last ppc64 warning
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35499
diff
changeset
|
673 | &their_addr.in.sin_addr, addrstr, sizeof(addrstr)); |
|
32058
95953bd2f239
Append interface ID only to local interfaces for IPv6 Bonjour.
Linus Lüssing <linus.luessing@web.de>
parents:
31749
diff
changeset
|
674 | } |
|
29761
0f6862f2782f
Implementation of IPv6 support for Bonjour
Daniel Atallah <datallah@pidgin.im>
parents:
27625
diff
changeset
|
675 | #else |
|
35554
fdd1f3a3c6df
Fix the last ppc64 warning
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35499
diff
changeset
|
676 | address_text = inet_ntoa(their_addr.in.sin_addr); |
|
29761
0f6862f2782f
Implementation of IPv6 support for Bonjour
Daniel Atallah <datallah@pidgin.im>
parents:
27625
diff
changeset
|
677 | #endif |
|
19832
84b69b21672b
Patch from QuLogic. Fixes #2903 ('Missing newlines in debug messages.')
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
19749
diff
changeset
|
678 | purple_debug_info("bonjour", "Received incoming connection from %s.\n", address_text); |
|
21944
c41d17a1b8d9
This is the second part of the fix to support having multiple presence records in Bonjour (and also supporting multiple presences using the same IP). Incoming conversations are no longer immediately attached to a buddy - we use an algorithm to match a conversation to a buddy based on the IP and, if possible the "from" attribute of the stream or the first tag in the stream. Thanks to Sjoerd Simons from Telepahy Salut for noticing and suggesting the algorithm. Fixes #4187. It'd be good if a few people test this.
Daniel Atallah <datallah@pidgin.im>
parents:
21936
diff
changeset
|
679 | mbba = g_new0(struct _match_buddies_by_address_t, 1); |
|
c41d17a1b8d9
This is the second part of the fix to support having multiple presence records in Bonjour (and also supporting multiple presences using the same IP). Incoming conversations are no longer immediately attached to a buddy - we use an algorithm to match a conversation to a buddy based on the IP and, if possible the "from" attribute of the stream or the first tag in the stream. Thanks to Sjoerd Simons from Telepahy Salut for noticing and suggesting the algorithm. Fixes #4187. It'd be good if a few people test this.
Daniel Atallah <datallah@pidgin.im>
parents:
21936
diff
changeset
|
680 | mbba->address = address_text; |
|
26767
7489049a3bde
Change purple_blist_get_buddies to return a list instead of the hash table.
Paul Aurich <darkrain42@pidgin.im>
parents:
25911
diff
changeset
|
681 | |
|
34728
8efd73063ecf
Renamed buddy list functions to more appropriate/simler names.
Ankit Vani <a@nevitus.org>
parents:
34706
diff
changeset
|
682 | buddies = purple_blist_find_buddies(jdata->account, NULL); |
|
26767
7489049a3bde
Change purple_blist_get_buddies to return a list instead of the hash table.
Paul Aurich <darkrain42@pidgin.im>
parents:
25911
diff
changeset
|
683 | g_slist_foreach(buddies, _match_buddies_by_address, mbba); |
|
7489049a3bde
Change purple_blist_get_buddies to return a list instead of the hash table.
Paul Aurich <darkrain42@pidgin.im>
parents:
25911
diff
changeset
|
684 | g_slist_free(buddies); |
|
21944
c41d17a1b8d9
This is the second part of the fix to support having multiple presence records in Bonjour (and also supporting multiple presences using the same IP). Incoming conversations are no longer immediately attached to a buddy - we use an algorithm to match a conversation to a buddy based on the IP and, if possible the "from" attribute of the stream or the first tag in the stream. Thanks to Sjoerd Simons from Telepahy Salut for noticing and suggesting the algorithm. Fixes #4187. It'd be good if a few people test this.
Daniel Atallah <datallah@pidgin.im>
parents:
21936
diff
changeset
|
685 | |
|
c41d17a1b8d9
This is the second part of the fix to support having multiple presence records in Bonjour (and also supporting multiple presences using the same IP). Incoming conversations are no longer immediately attached to a buddy - we use an algorithm to match a conversation to a buddy based on the IP and, if possible the "from" attribute of the stream or the first tag in the stream. Thanks to Sjoerd Simons from Telepahy Salut for noticing and suggesting the algorithm. Fixes #4187. It'd be good if a few people test this.
Daniel Atallah <datallah@pidgin.im>
parents:
21936
diff
changeset
|
686 | if (mbba->matched_buddies == NULL) { |
| 29999 | 687 | purple_debug_info("bonjour", "We don't like invisible buddies, this is not a superheroes comic\n"); |
|
21944
c41d17a1b8d9
This is the second part of the fix to support having multiple presence records in Bonjour (and also supporting multiple presences using the same IP). Incoming conversations are no longer immediately attached to a buddy - we use an algorithm to match a conversation to a buddy based on the IP and, if possible the "from" attribute of the stream or the first tag in the stream. Thanks to Sjoerd Simons from Telepahy Salut for noticing and suggesting the algorithm. Fixes #4187. It'd be good if a few people test this.
Daniel Atallah <datallah@pidgin.im>
parents:
21936
diff
changeset
|
688 | g_free(mbba); |
| 11477 | 689 | close(client_socket); |
| 690 | return; | |
| 691 | } | |
| 692 | ||
|
21944
c41d17a1b8d9
This is the second part of the fix to support having multiple presence records in Bonjour (and also supporting multiple presences using the same IP). Incoming conversations are no longer immediately attached to a buddy - we use an algorithm to match a conversation to a buddy based on the IP and, if possible the "from" attribute of the stream or the first tag in the stream. Thanks to Sjoerd Simons from Telepahy Salut for noticing and suggesting the algorithm. Fixes #4187. It'd be good if a few people test this.
Daniel Atallah <datallah@pidgin.im>
parents:
21936
diff
changeset
|
693 | g_slist_free(mbba->matched_buddies); |
|
c41d17a1b8d9
This is the second part of the fix to support having multiple presence records in Bonjour (and also supporting multiple presences using the same IP). Incoming conversations are no longer immediately attached to a buddy - we use an algorithm to match a conversation to a buddy based on the IP and, if possible the "from" attribute of the stream or the first tag in the stream. Thanks to Sjoerd Simons from Telepahy Salut for noticing and suggesting the algorithm. Fixes #4187. It'd be good if a few people test this.
Daniel Atallah <datallah@pidgin.im>
parents:
21936
diff
changeset
|
694 | g_free(mbba); |
|
17665
26bff2090889
Update Bonjour to do nonblocking I/O correctly.
Daniel Atallah <datallah@pidgin.im>
parents:
17663
diff
changeset
|
695 | |
|
21944
c41d17a1b8d9
This is the second part of the fix to support having multiple presence records in Bonjour (and also supporting multiple presences using the same IP). Incoming conversations are no longer immediately attached to a buddy - we use an algorithm to match a conversation to a buddy based on the IP and, if possible the "from" attribute of the stream or the first tag in the stream. Thanks to Sjoerd Simons from Telepahy Salut for noticing and suggesting the algorithm. Fixes #4187. It'd be good if a few people test this.
Daniel Atallah <datallah@pidgin.im>
parents:
21936
diff
changeset
|
696 | /* We've established that this *could* be from one of our buddies. |
|
c41d17a1b8d9
This is the second part of the fix to support having multiple presence records in Bonjour (and also supporting multiple presences using the same IP). Incoming conversations are no longer immediately attached to a buddy - we use an algorithm to match a conversation to a buddy based on the IP and, if possible the "from" attribute of the stream or the first tag in the stream. Thanks to Sjoerd Simons from Telepahy Salut for noticing and suggesting the algorithm. Fixes #4187. It'd be good if a few people test this.
Daniel Atallah <datallah@pidgin.im>
parents:
21936
diff
changeset
|
697 | * Wait for the stream open to see if that matches too before assigning it. |
|
c41d17a1b8d9
This is the second part of the fix to support having multiple presence records in Bonjour (and also supporting multiple presences using the same IP). Incoming conversations are no longer immediately attached to a buddy - we use an algorithm to match a conversation to a buddy based on the IP and, if possible the "from" attribute of the stream or the first tag in the stream. Thanks to Sjoerd Simons from Telepahy Salut for noticing and suggesting the algorithm. Fixes #4187. It'd be good if a few people test this.
Daniel Atallah <datallah@pidgin.im>
parents:
21936
diff
changeset
|
698 | */ |
|
c41d17a1b8d9
This is the second part of the fix to support having multiple presence records in Bonjour (and also supporting multiple presences using the same IP). Incoming conversations are no longer immediately attached to a buddy - we use an algorithm to match a conversation to a buddy based on the IP and, if possible the "from" attribute of the stream or the first tag in the stream. Thanks to Sjoerd Simons from Telepahy Salut for noticing and suggesting the algorithm. Fixes #4187. It'd be good if a few people test this.
Daniel Atallah <datallah@pidgin.im>
parents:
21936
diff
changeset
|
699 | bconv = bonjour_jabber_conv_new(NULL, jdata->account, address_text); |
|
17665
26bff2090889
Update Bonjour to do nonblocking I/O correctly.
Daniel Atallah <datallah@pidgin.im>
parents:
17663
diff
changeset
|
700 | |
|
21944
c41d17a1b8d9
This is the second part of the fix to support having multiple presence records in Bonjour (and also supporting multiple presences using the same IP). Incoming conversations are no longer immediately attached to a buddy - we use an algorithm to match a conversation to a buddy based on the IP and, if possible the "from" attribute of the stream or the first tag in the stream. Thanks to Sjoerd Simons from Telepahy Salut for noticing and suggesting the algorithm. Fixes #4187. It'd be good if a few people test this.
Daniel Atallah <datallah@pidgin.im>
parents:
21936
diff
changeset
|
701 | /* We wait for the stream start before doing anything else */ |
|
c41d17a1b8d9
This is the second part of the fix to support having multiple presence records in Bonjour (and also supporting multiple presences using the same IP). Incoming conversations are no longer immediately attached to a buddy - we use an algorithm to match a conversation to a buddy based on the IP and, if possible the "from" attribute of the stream or the first tag in the stream. Thanks to Sjoerd Simons from Telepahy Salut for noticing and suggesting the algorithm. Fixes #4187. It'd be good if a few people test this.
Daniel Atallah <datallah@pidgin.im>
parents:
21936
diff
changeset
|
702 | bconv->socket = client_socket; |
|
c41d17a1b8d9
This is the second part of the fix to support having multiple presence records in Bonjour (and also supporting multiple presences using the same IP). Incoming conversations are no longer immediately attached to a buddy - we use an algorithm to match a conversation to a buddy based on the IP and, if possible the "from" attribute of the stream or the first tag in the stream. Thanks to Sjoerd Simons from Telepahy Salut for noticing and suggesting the algorithm. Fixes #4187. It'd be good if a few people test this.
Daniel Atallah <datallah@pidgin.im>
parents:
21936
diff
changeset
|
703 | bconv->rx_handler = purple_input_add(client_socket, PURPLE_INPUT_READ, _client_socket_handler, bconv); |
|
c41d17a1b8d9
This is the second part of the fix to support having multiple presence records in Bonjour (and also supporting multiple presences using the same IP). Incoming conversations are no longer immediately attached to a buddy - we use an algorithm to match a conversation to a buddy based on the IP and, if possible the "from" attribute of the stream or the first tag in the stream. Thanks to Sjoerd Simons from Telepahy Salut for noticing and suggesting the algorithm. Fixes #4187. It'd be good if a few people test this.
Daniel Atallah <datallah@pidgin.im>
parents:
21936
diff
changeset
|
704 | |
| 11477 | 705 | } |
| 706 | ||
|
29761
0f6862f2782f
Implementation of IPv6 support for Bonjour
Daniel Atallah <datallah@pidgin.im>
parents:
27625
diff
changeset
|
707 | static int |
|
0f6862f2782f
Implementation of IPv6 support for Bonjour
Daniel Atallah <datallah@pidgin.im>
parents:
27625
diff
changeset
|
708 | start_serversocket_listening(int port, int socket, struct sockaddr *addr, size_t addr_size, gboolean ip6, gboolean allow_port_fallback) |
| 11477 | 709 | { |
|
29761
0f6862f2782f
Implementation of IPv6 support for Bonjour
Daniel Atallah <datallah@pidgin.im>
parents:
27625
diff
changeset
|
710 | int ret_port = port; |
| 11477 | 711 | |
|
29761
0f6862f2782f
Implementation of IPv6 support for Bonjour
Daniel Atallah <datallah@pidgin.im>
parents:
27625
diff
changeset
|
712 | purple_debug_info("bonjour", "Attempting to bind IPv%d socket to port %d.\n", ip6 ? 6 : 4, port); |
|
11539
fbabe3f89777
[gaim-migrate @ 13794]
Mark Doliner <markdoliner@pidgin.im>
parents:
11515
diff
changeset
|
713 | |
|
25641
cf74c04c6f41
Better support running many Bonjour clients on the same machine by allowing a
Daniel Atallah <datallah@pidgin.im>
parents:
25097
diff
changeset
|
714 | /* Try to use the specified port - if it isn't available, use a random port */ |
|
29761
0f6862f2782f
Implementation of IPv6 support for Bonjour
Daniel Atallah <datallah@pidgin.im>
parents:
27625
diff
changeset
|
715 | if (bind(socket, addr, addr_size) != 0) { |
|
0f6862f2782f
Implementation of IPv6 support for Bonjour
Daniel Atallah <datallah@pidgin.im>
parents:
27625
diff
changeset
|
716 | |
|
27625
3f5d49f43feb
Make some error messages more uniform.
Mark Doliner <markdoliner@pidgin.im>
parents:
27343
diff
changeset
|
717 | purple_debug_info("bonjour", "Unable to bind to specified " |
|
29761
0f6862f2782f
Implementation of IPv6 support for Bonjour
Daniel Atallah <datallah@pidgin.im>
parents:
27625
diff
changeset
|
718 | "port %i: %s\n", port, g_strerror(errno)); |
|
0f6862f2782f
Implementation of IPv6 support for Bonjour
Daniel Atallah <datallah@pidgin.im>
parents:
27625
diff
changeset
|
719 | |
|
0f6862f2782f
Implementation of IPv6 support for Bonjour
Daniel Atallah <datallah@pidgin.im>
parents:
27625
diff
changeset
|
720 | if (!allow_port_fallback) { |
|
0f6862f2782f
Implementation of IPv6 support for Bonjour
Daniel Atallah <datallah@pidgin.im>
parents:
27625
diff
changeset
|
721 | purple_debug_warning("bonjour", "Not attempting random port assignment.\n"); |
|
25641
cf74c04c6f41
Better support running many Bonjour clients on the same machine by allowing a
Daniel Atallah <datallah@pidgin.im>
parents:
25097
diff
changeset
|
722 | return -1; |
| 13971 | 723 | } |
|
29761
0f6862f2782f
Implementation of IPv6 support for Bonjour
Daniel Atallah <datallah@pidgin.im>
parents:
27625
diff
changeset
|
724 | #ifdef PF_INET6 |
|
0f6862f2782f
Implementation of IPv6 support for Bonjour
Daniel Atallah <datallah@pidgin.im>
parents:
27625
diff
changeset
|
725 | if (ip6) |
|
0f6862f2782f
Implementation of IPv6 support for Bonjour
Daniel Atallah <datallah@pidgin.im>
parents:
27625
diff
changeset
|
726 | ((struct sockaddr_in6 *) addr)->sin6_port = 0; |
|
0f6862f2782f
Implementation of IPv6 support for Bonjour
Daniel Atallah <datallah@pidgin.im>
parents:
27625
diff
changeset
|
727 | else |
|
0f6862f2782f
Implementation of IPv6 support for Bonjour
Daniel Atallah <datallah@pidgin.im>
parents:
27625
diff
changeset
|
728 | #endif |
|
0f6862f2782f
Implementation of IPv6 support for Bonjour
Daniel Atallah <datallah@pidgin.im>
parents:
27625
diff
changeset
|
729 | ((struct sockaddr_in *) addr)->sin_port = 0; |
|
0f6862f2782f
Implementation of IPv6 support for Bonjour
Daniel Atallah <datallah@pidgin.im>
parents:
27625
diff
changeset
|
730 | |
|
0f6862f2782f
Implementation of IPv6 support for Bonjour
Daniel Atallah <datallah@pidgin.im>
parents:
27625
diff
changeset
|
731 | if (bind(socket, addr, addr_size) != 0) { |
|
0f6862f2782f
Implementation of IPv6 support for Bonjour
Daniel Atallah <datallah@pidgin.im>
parents:
27625
diff
changeset
|
732 | purple_debug_error("bonjour", "Unable to bind IPv%d socket to port: %s\n", ip6 ? 6 : 4, g_strerror(errno)); |
|
0f6862f2782f
Implementation of IPv6 support for Bonjour
Daniel Atallah <datallah@pidgin.im>
parents:
27625
diff
changeset
|
733 | return -1; |
|
0f6862f2782f
Implementation of IPv6 support for Bonjour
Daniel Atallah <datallah@pidgin.im>
parents:
27625
diff
changeset
|
734 | } |
|
0f6862f2782f
Implementation of IPv6 support for Bonjour
Daniel Atallah <datallah@pidgin.im>
parents:
27625
diff
changeset
|
735 | ret_port = purple_network_get_port_from_fd(socket); |
| 11477 | 736 | } |
|
11539
fbabe3f89777
[gaim-migrate @ 13794]
Mark Doliner <markdoliner@pidgin.im>
parents:
11515
diff
changeset
|
737 | |
|
29761
0f6862f2782f
Implementation of IPv6 support for Bonjour
Daniel Atallah <datallah@pidgin.im>
parents:
27625
diff
changeset
|
738 | purple_debug_info("bonjour", "Bound IPv%d socket to port %d.\n", ip6 ? 6 : 4, ret_port); |
|
0f6862f2782f
Implementation of IPv6 support for Bonjour
Daniel Atallah <datallah@pidgin.im>
parents:
27625
diff
changeset
|
739 | |
| 13971 | 740 | /* Attempt to listen on the bound socket */ |
|
29761
0f6862f2782f
Implementation of IPv6 support for Bonjour
Daniel Atallah <datallah@pidgin.im>
parents:
27625
diff
changeset
|
741 | if (listen(socket, 10) != 0) { |
|
0f6862f2782f
Implementation of IPv6 support for Bonjour
Daniel Atallah <datallah@pidgin.im>
parents:
27625
diff
changeset
|
742 | purple_debug_error("bonjour", "Unable to listen on IPv%d socket: %s\n", ip6 ? 6 : 4, g_strerror(errno)); |
| 11477 | 743 | return -1; |
| 744 | } | |
| 745 | ||
|
11826
10ebbc41f163
[gaim-migrate @ 14117]
Richard Laager <rlaager@pidgin.im>
parents:
11823
diff
changeset
|
746 | #if 0 |
|
12730
f64fdbc34677
[gaim-migrate @ 15074]
Daniel Atallah <datallah@pidgin.im>
parents:
12708
diff
changeset
|
747 | /* TODO: Why isn't this being used? */ |
|
32594
f2feea134fdb
Remove deprecated purple_network_listen_map_external().
Andrew Victor <andrew.victor@mxit.com>
parents:
32592
diff
changeset
|
748 | data->socket = purple_network_listen(jdata->port, AF_UNSPEC, SOCK_STREAM, TRUE); |
| 11477 | 749 | |
|
21944
c41d17a1b8d9
This is the second part of the fix to support having multiple presence records in Bonjour (and also supporting multiple presences using the same IP). Incoming conversations are no longer immediately attached to a buddy - we use an algorithm to match a conversation to a buddy based on the IP and, if possible the "from" attribute of the stream or the first tag in the stream. Thanks to Sjoerd Simons from Telepahy Salut for noticing and suggesting the algorithm. Fixes #4187. It'd be good if a few people test this.
Daniel Atallah <datallah@pidgin.im>
parents:
21936
diff
changeset
|
750 | if (jdata->socket == -1) |
|
11826
10ebbc41f163
[gaim-migrate @ 14117]
Richard Laager <rlaager@pidgin.im>
parents:
11823
diff
changeset
|
751 | { |
| 15884 | 752 | purple_debug_error("bonjour", "No se ha podido crear el socket\n"); |
|
11826
10ebbc41f163
[gaim-migrate @ 14117]
Richard Laager <rlaager@pidgin.im>
parents:
11823
diff
changeset
|
753 | } |
|
10ebbc41f163
[gaim-migrate @ 14117]
Richard Laager <rlaager@pidgin.im>
parents:
11823
diff
changeset
|
754 | #endif |
| 11477 | 755 | |
|
29761
0f6862f2782f
Implementation of IPv6 support for Bonjour
Daniel Atallah <datallah@pidgin.im>
parents:
27625
diff
changeset
|
756 | return ret_port; |
|
0f6862f2782f
Implementation of IPv6 support for Bonjour
Daniel Atallah <datallah@pidgin.im>
parents:
27625
diff
changeset
|
757 | } |
|
0f6862f2782f
Implementation of IPv6 support for Bonjour
Daniel Atallah <datallah@pidgin.im>
parents:
27625
diff
changeset
|
758 | |
|
0f6862f2782f
Implementation of IPv6 support for Bonjour
Daniel Atallah <datallah@pidgin.im>
parents:
27625
diff
changeset
|
759 | gint |
|
0f6862f2782f
Implementation of IPv6 support for Bonjour
Daniel Atallah <datallah@pidgin.im>
parents:
27625
diff
changeset
|
760 | bonjour_jabber_start(BonjourJabber *jdata) |
|
0f6862f2782f
Implementation of IPv6 support for Bonjour
Daniel Atallah <datallah@pidgin.im>
parents:
27625
diff
changeset
|
761 | { |
|
0f6862f2782f
Implementation of IPv6 support for Bonjour
Daniel Atallah <datallah@pidgin.im>
parents:
27625
diff
changeset
|
762 | int ipv6_port = -1, ipv4_port = -1; |
|
0f6862f2782f
Implementation of IPv6 support for Bonjour
Daniel Atallah <datallah@pidgin.im>
parents:
27625
diff
changeset
|
763 | |
|
0f6862f2782f
Implementation of IPv6 support for Bonjour
Daniel Atallah <datallah@pidgin.im>
parents:
27625
diff
changeset
|
764 | /* Open a listening socket for incoming conversations */ |
|
0f6862f2782f
Implementation of IPv6 support for Bonjour
Daniel Atallah <datallah@pidgin.im>
parents:
27625
diff
changeset
|
765 | #ifdef PF_INET6 |
|
0f6862f2782f
Implementation of IPv6 support for Bonjour
Daniel Atallah <datallah@pidgin.im>
parents:
27625
diff
changeset
|
766 | jdata->socket6 = socket(PF_INET6, SOCK_STREAM, 0); |
|
0f6862f2782f
Implementation of IPv6 support for Bonjour
Daniel Atallah <datallah@pidgin.im>
parents:
27625
diff
changeset
|
767 | #endif |
|
0f6862f2782f
Implementation of IPv6 support for Bonjour
Daniel Atallah <datallah@pidgin.im>
parents:
27625
diff
changeset
|
768 | jdata->socket = socket(PF_INET, SOCK_STREAM, 0); |
|
0f6862f2782f
Implementation of IPv6 support for Bonjour
Daniel Atallah <datallah@pidgin.im>
parents:
27625
diff
changeset
|
769 | if (jdata->socket == -1 && jdata->socket6 == -1) { |
|
0f6862f2782f
Implementation of IPv6 support for Bonjour
Daniel Atallah <datallah@pidgin.im>
parents:
27625
diff
changeset
|
770 | purple_debug_error("bonjour", "Unable to create socket: %s", |
|
0f6862f2782f
Implementation of IPv6 support for Bonjour
Daniel Atallah <datallah@pidgin.im>
parents:
27625
diff
changeset
|
771 | g_strerror(errno)); |
|
0f6862f2782f
Implementation of IPv6 support for Bonjour
Daniel Atallah <datallah@pidgin.im>
parents:
27625
diff
changeset
|
772 | return -1; |
|
0f6862f2782f
Implementation of IPv6 support for Bonjour
Daniel Atallah <datallah@pidgin.im>
parents:
27625
diff
changeset
|
773 | } |
|
0f6862f2782f
Implementation of IPv6 support for Bonjour
Daniel Atallah <datallah@pidgin.im>
parents:
27625
diff
changeset
|
774 | |
|
0f6862f2782f
Implementation of IPv6 support for Bonjour
Daniel Atallah <datallah@pidgin.im>
parents:
27625
diff
changeset
|
775 | #ifdef PF_INET6 |
|
0f6862f2782f
Implementation of IPv6 support for Bonjour
Daniel Atallah <datallah@pidgin.im>
parents:
27625
diff
changeset
|
776 | if (jdata->socket6 != -1) { |
|
0f6862f2782f
Implementation of IPv6 support for Bonjour
Daniel Atallah <datallah@pidgin.im>
parents:
27625
diff
changeset
|
777 | struct sockaddr_in6 addr6; |
|
30827
80f23383cb29
Use IPV6_V6ONLY for the bonjour IPv6 socket so that we can register the separate IPv4 socket on the same port. Fixes #12657
Daniel Atallah <datallah@pidgin.im>
parents:
30825
diff
changeset
|
778 | #ifdef IPV6_V6ONLY |
|
80f23383cb29
Use IPV6_V6ONLY for the bonjour IPv6 socket so that we can register the separate IPv4 socket on the same port. Fixes #12657
Daniel Atallah <datallah@pidgin.im>
parents:
30825
diff
changeset
|
779 | int on = 1; |
|
80f23383cb29
Use IPV6_V6ONLY for the bonjour IPv6 socket so that we can register the separate IPv4 socket on the same port. Fixes #12657
Daniel Atallah <datallah@pidgin.im>
parents:
30825
diff
changeset
|
780 | setsockopt(jdata->socket6, IPPROTO_IPV6, IPV6_V6ONLY, &on, sizeof(on)); |
|
80f23383cb29
Use IPV6_V6ONLY for the bonjour IPv6 socket so that we can register the separate IPv4 socket on the same port. Fixes #12657
Daniel Atallah <datallah@pidgin.im>
parents:
30825
diff
changeset
|
781 | #endif |
|
29761
0f6862f2782f
Implementation of IPv6 support for Bonjour
Daniel Atallah <datallah@pidgin.im>
parents:
27625
diff
changeset
|
782 | memset(&addr6, 0, sizeof(addr6)); |
|
0f6862f2782f
Implementation of IPv6 support for Bonjour
Daniel Atallah <datallah@pidgin.im>
parents:
27625
diff
changeset
|
783 | addr6.sin6_family = AF_INET6; |
|
0f6862f2782f
Implementation of IPv6 support for Bonjour
Daniel Atallah <datallah@pidgin.im>
parents:
27625
diff
changeset
|
784 | addr6.sin6_port = htons(jdata->port); |
|
0f6862f2782f
Implementation of IPv6 support for Bonjour
Daniel Atallah <datallah@pidgin.im>
parents:
27625
diff
changeset
|
785 | addr6.sin6_addr = in6addr_any; |
|
0f6862f2782f
Implementation of IPv6 support for Bonjour
Daniel Atallah <datallah@pidgin.im>
parents:
27625
diff
changeset
|
786 | ipv6_port = start_serversocket_listening(jdata->port, jdata->socket6, (struct sockaddr *) &addr6, sizeof(addr6), TRUE, TRUE); |
|
0f6862f2782f
Implementation of IPv6 support for Bonjour
Daniel Atallah <datallah@pidgin.im>
parents:
27625
diff
changeset
|
787 | /* Open a watcher in the socket we have just opened */ |
|
0f6862f2782f
Implementation of IPv6 support for Bonjour
Daniel Atallah <datallah@pidgin.im>
parents:
27625
diff
changeset
|
788 | if (ipv6_port > 0) { |
|
0f6862f2782f
Implementation of IPv6 support for Bonjour
Daniel Atallah <datallah@pidgin.im>
parents:
27625
diff
changeset
|
789 | jdata->watcher_id6 = purple_input_add(jdata->socket6, PURPLE_INPUT_READ, _server_socket_handler, jdata); |
|
0f6862f2782f
Implementation of IPv6 support for Bonjour
Daniel Atallah <datallah@pidgin.im>
parents:
27625
diff
changeset
|
790 | jdata->port = ipv6_port; |
|
0f6862f2782f
Implementation of IPv6 support for Bonjour
Daniel Atallah <datallah@pidgin.im>
parents:
27625
diff
changeset
|
791 | } else { |
|
0f6862f2782f
Implementation of IPv6 support for Bonjour
Daniel Atallah <datallah@pidgin.im>
parents:
27625
diff
changeset
|
792 | purple_debug_error("bonjour", "Failed to start listening on IPv6 socket.\n"); |
|
0f6862f2782f
Implementation of IPv6 support for Bonjour
Daniel Atallah <datallah@pidgin.im>
parents:
27625
diff
changeset
|
793 | close(jdata->socket6); |
|
0f6862f2782f
Implementation of IPv6 support for Bonjour
Daniel Atallah <datallah@pidgin.im>
parents:
27625
diff
changeset
|
794 | jdata->socket6 = -1; |
|
0f6862f2782f
Implementation of IPv6 support for Bonjour
Daniel Atallah <datallah@pidgin.im>
parents:
27625
diff
changeset
|
795 | } |
|
0f6862f2782f
Implementation of IPv6 support for Bonjour
Daniel Atallah <datallah@pidgin.im>
parents:
27625
diff
changeset
|
796 | } |
|
0f6862f2782f
Implementation of IPv6 support for Bonjour
Daniel Atallah <datallah@pidgin.im>
parents:
27625
diff
changeset
|
797 | #endif |
|
0f6862f2782f
Implementation of IPv6 support for Bonjour
Daniel Atallah <datallah@pidgin.im>
parents:
27625
diff
changeset
|
798 | if (jdata->socket != -1) { |
|
0f6862f2782f
Implementation of IPv6 support for Bonjour
Daniel Atallah <datallah@pidgin.im>
parents:
27625
diff
changeset
|
799 | struct sockaddr_in addr4; |
|
0f6862f2782f
Implementation of IPv6 support for Bonjour
Daniel Atallah <datallah@pidgin.im>
parents:
27625
diff
changeset
|
800 | memset(&addr4, 0, sizeof(addr4)); |
|
0f6862f2782f
Implementation of IPv6 support for Bonjour
Daniel Atallah <datallah@pidgin.im>
parents:
27625
diff
changeset
|
801 | addr4.sin_family = AF_INET; |
|
0f6862f2782f
Implementation of IPv6 support for Bonjour
Daniel Atallah <datallah@pidgin.im>
parents:
27625
diff
changeset
|
802 | addr4.sin_port = htons(jdata->port); |
|
0f6862f2782f
Implementation of IPv6 support for Bonjour
Daniel Atallah <datallah@pidgin.im>
parents:
27625
diff
changeset
|
803 | ipv4_port = start_serversocket_listening(jdata->port, jdata->socket, (struct sockaddr *) &addr4, sizeof(addr4), FALSE, ipv6_port != -1); |
|
0f6862f2782f
Implementation of IPv6 support for Bonjour
Daniel Atallah <datallah@pidgin.im>
parents:
27625
diff
changeset
|
804 | /* Open a watcher in the socket we have just opened */ |
|
0f6862f2782f
Implementation of IPv6 support for Bonjour
Daniel Atallah <datallah@pidgin.im>
parents:
27625
diff
changeset
|
805 | if (ipv4_port > 0) { |
|
0f6862f2782f
Implementation of IPv6 support for Bonjour
Daniel Atallah <datallah@pidgin.im>
parents:
27625
diff
changeset
|
806 | jdata->watcher_id = purple_input_add(jdata->socket, PURPLE_INPUT_READ, _server_socket_handler, jdata); |
|
0f6862f2782f
Implementation of IPv6 support for Bonjour
Daniel Atallah <datallah@pidgin.im>
parents:
27625
diff
changeset
|
807 | jdata->port = ipv4_port; |
|
0f6862f2782f
Implementation of IPv6 support for Bonjour
Daniel Atallah <datallah@pidgin.im>
parents:
27625
diff
changeset
|
808 | } else { |
|
0f6862f2782f
Implementation of IPv6 support for Bonjour
Daniel Atallah <datallah@pidgin.im>
parents:
27625
diff
changeset
|
809 | purple_debug_error("bonjour", "Failed to start listening on IPv4 socket.\n"); |
|
0f6862f2782f
Implementation of IPv6 support for Bonjour
Daniel Atallah <datallah@pidgin.im>
parents:
27625
diff
changeset
|
810 | close(jdata->socket); |
|
0f6862f2782f
Implementation of IPv6 support for Bonjour
Daniel Atallah <datallah@pidgin.im>
parents:
27625
diff
changeset
|
811 | jdata->socket = -1; |
|
0f6862f2782f
Implementation of IPv6 support for Bonjour
Daniel Atallah <datallah@pidgin.im>
parents:
27625
diff
changeset
|
812 | } |
|
0f6862f2782f
Implementation of IPv6 support for Bonjour
Daniel Atallah <datallah@pidgin.im>
parents:
27625
diff
changeset
|
813 | } |
|
0f6862f2782f
Implementation of IPv6 support for Bonjour
Daniel Atallah <datallah@pidgin.im>
parents:
27625
diff
changeset
|
814 | |
|
0f6862f2782f
Implementation of IPv6 support for Bonjour
Daniel Atallah <datallah@pidgin.im>
parents:
27625
diff
changeset
|
815 | if (!(ipv6_port > 0 || ipv4_port > 0)) { |
|
0f6862f2782f
Implementation of IPv6 support for Bonjour
Daniel Atallah <datallah@pidgin.im>
parents:
27625
diff
changeset
|
816 | purple_debug_error("bonjour", "Unable to listen on socket: %s", |
|
0f6862f2782f
Implementation of IPv6 support for Bonjour
Daniel Atallah <datallah@pidgin.im>
parents:
27625
diff
changeset
|
817 | g_strerror(errno)); |
|
0f6862f2782f
Implementation of IPv6 support for Bonjour
Daniel Atallah <datallah@pidgin.im>
parents:
27625
diff
changeset
|
818 | return -1; |
|
0f6862f2782f
Implementation of IPv6 support for Bonjour
Daniel Atallah <datallah@pidgin.im>
parents:
27625
diff
changeset
|
819 | } |
|
11539
fbabe3f89777
[gaim-migrate @ 13794]
Mark Doliner <markdoliner@pidgin.im>
parents:
11515
diff
changeset
|
820 | |
|
21944
c41d17a1b8d9
This is the second part of the fix to support having multiple presence records in Bonjour (and also supporting multiple presences using the same IP). Incoming conversations are no longer immediately attached to a buddy - we use an algorithm to match a conversation to a buddy based on the IP and, if possible the "from" attribute of the stream or the first tag in the stream. Thanks to Sjoerd Simons from Telepahy Salut for noticing and suggesting the algorithm. Fixes #4187. It'd be good if a few people test this.
Daniel Atallah <datallah@pidgin.im>
parents:
21936
diff
changeset
|
821 | return jdata->port; |
| 11477 | 822 | } |
| 823 | ||
|
17665
26bff2090889
Update Bonjour to do nonblocking I/O correctly.
Daniel Atallah <datallah@pidgin.im>
parents:
17663
diff
changeset
|
824 | static void |
|
26bff2090889
Update Bonjour to do nonblocking I/O correctly.
Daniel Atallah <datallah@pidgin.im>
parents:
17663
diff
changeset
|
825 | _connected_to_buddy(gpointer data, gint source, const gchar *error) |
|
26bff2090889
Update Bonjour to do nonblocking I/O correctly.
Daniel Atallah <datallah@pidgin.im>
parents:
17663
diff
changeset
|
826 | { |
|
26bff2090889
Update Bonjour to do nonblocking I/O correctly.
Daniel Atallah <datallah@pidgin.im>
parents:
17663
diff
changeset
|
827 | PurpleBuddy *pb = data; |
|
24938
fc6952107e1f
Finished moving to api for bonjour
Gary Kramlich <grim@reaperworld.com>
parents:
24562
diff
changeset
|
828 | BonjourBuddy *bb = purple_buddy_get_protocol_data(pb); |
|
17665
26bff2090889
Update Bonjour to do nonblocking I/O correctly.
Daniel Atallah <datallah@pidgin.im>
parents:
17663
diff
changeset
|
829 | |
|
26bff2090889
Update Bonjour to do nonblocking I/O correctly.
Daniel Atallah <datallah@pidgin.im>
parents:
17663
diff
changeset
|
830 | bb->conversation->connect_data = NULL; |
|
26bff2090889
Update Bonjour to do nonblocking I/O correctly.
Daniel Atallah <datallah@pidgin.im>
parents:
17663
diff
changeset
|
831 | |
|
26bff2090889
Update Bonjour to do nonblocking I/O correctly.
Daniel Atallah <datallah@pidgin.im>
parents:
17663
diff
changeset
|
832 | if (source < 0) { |
|
24938
fc6952107e1f
Finished moving to api for bonjour
Gary Kramlich <grim@reaperworld.com>
parents:
24562
diff
changeset
|
833 | PurpleConversation *conv = NULL; |
|
fc6952107e1f
Finished moving to api for bonjour
Gary Kramlich <grim@reaperworld.com>
parents:
24562
diff
changeset
|
834 | PurpleAccount *account = NULL; |
|
31748
45c25b4868cb
bonjour: Recurse through user IP addresses instead of using the first one only
Simon van der Linden <simon@vanderlinden.eu.org>
parents:
30827
diff
changeset
|
835 | GSList *tmp = bb->ips; |
|
17665
26bff2090889
Update Bonjour to do nonblocking I/O correctly.
Daniel Atallah <datallah@pidgin.im>
parents:
17663
diff
changeset
|
836 | |
|
31748
45c25b4868cb
bonjour: Recurse through user IP addresses instead of using the first one only
Simon van der Linden <simon@vanderlinden.eu.org>
parents:
30827
diff
changeset
|
837 | purple_debug_error("bonjour", "Error connecting to buddy %s at %s:%d (%s); Trying next IP address\n", |
|
45c25b4868cb
bonjour: Recurse through user IP addresses instead of using the first one only
Simon van der Linden <simon@vanderlinden.eu.org>
parents:
30827
diff
changeset
|
838 | purple_buddy_get_name(pb), bb->conversation->ip, bb->port_p2pj, error); |
|
45c25b4868cb
bonjour: Recurse through user IP addresses instead of using the first one only
Simon van der Linden <simon@vanderlinden.eu.org>
parents:
30827
diff
changeset
|
839 | |
|
31749
710d5d207306
bonjour: Update to 427f3622bbeb4 to match the last used IP more reliably.
Daniel Atallah <datallah@pidgin.im>
parents:
31748
diff
changeset
|
840 | /* There may be multiple entries for the same IP - one per |
|
710d5d207306
bonjour: Update to 427f3622bbeb4 to match the last used IP more reliably.
Daniel Atallah <datallah@pidgin.im>
parents:
31748
diff
changeset
|
841 | * presence recieved (e.g. multiple interfaces). |
|
710d5d207306
bonjour: Update to 427f3622bbeb4 to match the last used IP more reliably.
Daniel Atallah <datallah@pidgin.im>
parents:
31748
diff
changeset
|
842 | * We need to make sure that we find the previously used entry. |
|
710d5d207306
bonjour: Update to 427f3622bbeb4 to match the last used IP more reliably.
Daniel Atallah <datallah@pidgin.im>
parents:
31748
diff
changeset
|
843 | */ |
|
710d5d207306
bonjour: Update to 427f3622bbeb4 to match the last used IP more reliably.
Daniel Atallah <datallah@pidgin.im>
parents:
31748
diff
changeset
|
844 | while (tmp && bb->conversation->ip_link != tmp->data) |
|
710d5d207306
bonjour: Update to 427f3622bbeb4 to match the last used IP more reliably.
Daniel Atallah <datallah@pidgin.im>
parents:
31748
diff
changeset
|
845 | tmp = g_slist_next(tmp); |
|
710d5d207306
bonjour: Update to 427f3622bbeb4 to match the last used IP more reliably.
Daniel Atallah <datallah@pidgin.im>
parents:
31748
diff
changeset
|
846 | if (tmp) |
|
710d5d207306
bonjour: Update to 427f3622bbeb4 to match the last used IP more reliably.
Daniel Atallah <datallah@pidgin.im>
parents:
31748
diff
changeset
|
847 | tmp = g_slist_next(tmp); |
|
17665
26bff2090889
Update Bonjour to do nonblocking I/O correctly.
Daniel Atallah <datallah@pidgin.im>
parents:
17663
diff
changeset
|
848 | |
|
24938
fc6952107e1f
Finished moving to api for bonjour
Gary Kramlich <grim@reaperworld.com>
parents:
24562
diff
changeset
|
849 | account = purple_buddy_get_account(pb); |
|
fc6952107e1f
Finished moving to api for bonjour
Gary Kramlich <grim@reaperworld.com>
parents:
24562
diff
changeset
|
850 | |
|
31748
45c25b4868cb
bonjour: Recurse through user IP addresses instead of using the first one only
Simon van der Linden <simon@vanderlinden.eu.org>
parents:
30827
diff
changeset
|
851 | if (tmp != NULL) { |
|
45c25b4868cb
bonjour: Recurse through user IP addresses instead of using the first one only
Simon van der Linden <simon@vanderlinden.eu.org>
parents:
30827
diff
changeset
|
852 | const gchar *ip; |
|
45c25b4868cb
bonjour: Recurse through user IP addresses instead of using the first one only
Simon van der Linden <simon@vanderlinden.eu.org>
parents:
30827
diff
changeset
|
853 | PurpleProxyConnectData *connect_data; |
|
45c25b4868cb
bonjour: Recurse through user IP addresses instead of using the first one only
Simon van der Linden <simon@vanderlinden.eu.org>
parents:
30827
diff
changeset
|
854 | |
|
31749
710d5d207306
bonjour: Update to 427f3622bbeb4 to match the last used IP more reliably.
Daniel Atallah <datallah@pidgin.im>
parents:
31748
diff
changeset
|
855 | bb->conversation->ip_link = ip = tmp->data; |
|
31748
45c25b4868cb
bonjour: Recurse through user IP addresses instead of using the first one only
Simon van der Linden <simon@vanderlinden.eu.org>
parents:
30827
diff
changeset
|
856 | |
|
45c25b4868cb
bonjour: Recurse through user IP addresses instead of using the first one only
Simon van der Linden <simon@vanderlinden.eu.org>
parents:
30827
diff
changeset
|
857 | purple_debug_info("bonjour", "Starting conversation with %s at %s:%d\n", |
|
45c25b4868cb
bonjour: Recurse through user IP addresses instead of using the first one only
Simon van der Linden <simon@vanderlinden.eu.org>
parents:
30827
diff
changeset
|
858 | purple_buddy_get_name(pb), ip, bb->port_p2pj); |
|
45c25b4868cb
bonjour: Recurse through user IP addresses instead of using the first one only
Simon van der Linden <simon@vanderlinden.eu.org>
parents:
30827
diff
changeset
|
859 | |
|
45c25b4868cb
bonjour: Recurse through user IP addresses instead of using the first one only
Simon van der Linden <simon@vanderlinden.eu.org>
parents:
30827
diff
changeset
|
860 | connect_data = purple_proxy_connect(purple_account_get_connection(account), |
|
45c25b4868cb
bonjour: Recurse through user IP addresses instead of using the first one only
Simon van der Linden <simon@vanderlinden.eu.org>
parents:
30827
diff
changeset
|
861 | account, ip, bb->port_p2pj, _connected_to_buddy, pb); |
|
45c25b4868cb
bonjour: Recurse through user IP addresses instead of using the first one only
Simon van der Linden <simon@vanderlinden.eu.org>
parents:
30827
diff
changeset
|
862 | |
|
45c25b4868cb
bonjour: Recurse through user IP addresses instead of using the first one only
Simon van der Linden <simon@vanderlinden.eu.org>
parents:
30827
diff
changeset
|
863 | if (connect_data != NULL) { |
|
45c25b4868cb
bonjour: Recurse through user IP addresses instead of using the first one only
Simon van der Linden <simon@vanderlinden.eu.org>
parents:
30827
diff
changeset
|
864 | g_free(bb->conversation->ip); |
|
45c25b4868cb
bonjour: Recurse through user IP addresses instead of using the first one only
Simon van der Linden <simon@vanderlinden.eu.org>
parents:
30827
diff
changeset
|
865 | bb->conversation->ip = g_strdup(ip); |
|
45c25b4868cb
bonjour: Recurse through user IP addresses instead of using the first one only
Simon van der Linden <simon@vanderlinden.eu.org>
parents:
30827
diff
changeset
|
866 | bb->conversation->connect_data = connect_data; |
|
45c25b4868cb
bonjour: Recurse through user IP addresses instead of using the first one only
Simon van der Linden <simon@vanderlinden.eu.org>
parents:
30827
diff
changeset
|
867 | |
|
45c25b4868cb
bonjour: Recurse through user IP addresses instead of using the first one only
Simon van der Linden <simon@vanderlinden.eu.org>
parents:
30827
diff
changeset
|
868 | return; |
|
45c25b4868cb
bonjour: Recurse through user IP addresses instead of using the first one only
Simon van der Linden <simon@vanderlinden.eu.org>
parents:
30827
diff
changeset
|
869 | } |
|
45c25b4868cb
bonjour: Recurse through user IP addresses instead of using the first one only
Simon van der Linden <simon@vanderlinden.eu.org>
parents:
30827
diff
changeset
|
870 | } |
|
45c25b4868cb
bonjour: Recurse through user IP addresses instead of using the first one only
Simon van der Linden <simon@vanderlinden.eu.org>
parents:
30827
diff
changeset
|
871 | |
|
45c25b4868cb
bonjour: Recurse through user IP addresses instead of using the first one only
Simon van der Linden <simon@vanderlinden.eu.org>
parents:
30827
diff
changeset
|
872 | purple_debug_error("bonjour", "No more addresses for buddy %s. Aborting", purple_buddy_get_name(pb)); |
|
45c25b4868cb
bonjour: Recurse through user IP addresses instead of using the first one only
Simon van der Linden <simon@vanderlinden.eu.org>
parents:
30827
diff
changeset
|
873 | |
|
34632
ebe6b2a60305
Changed all arguments and return types of Chat and IMs to PurpleChatConversation and PurpleIMConversation.
Ankit Vani <a@nevitus.org>
parents:
34625
diff
changeset
|
874 | conv = PURPLE_CONVERSATION(purple_conversations_find_im_with_account(bb->name, account)); |
|
17665
26bff2090889
Update Bonjour to do nonblocking I/O correctly.
Daniel Atallah <datallah@pidgin.im>
parents:
17663
diff
changeset
|
875 | if (conv != NULL) |
|
26bff2090889
Update Bonjour to do nonblocking I/O correctly.
Daniel Atallah <datallah@pidgin.im>
parents:
17663
diff
changeset
|
876 | purple_conversation_write(conv, NULL, |
|
26bff2090889
Update Bonjour to do nonblocking I/O correctly.
Daniel Atallah <datallah@pidgin.im>
parents:
17663
diff
changeset
|
877 | _("Unable to send the message, the conversation couldn't be started."), |
|
26bff2090889
Update Bonjour to do nonblocking I/O correctly.
Daniel Atallah <datallah@pidgin.im>
parents:
17663
diff
changeset
|
878 | PURPLE_MESSAGE_SYSTEM, time(NULL)); |
|
26bff2090889
Update Bonjour to do nonblocking I/O correctly.
Daniel Atallah <datallah@pidgin.im>
parents:
17663
diff
changeset
|
879 | |
|
26bff2090889
Update Bonjour to do nonblocking I/O correctly.
Daniel Atallah <datallah@pidgin.im>
parents:
17663
diff
changeset
|
880 | bonjour_jabber_close_conversation(bb->conversation); |
|
26bff2090889
Update Bonjour to do nonblocking I/O correctly.
Daniel Atallah <datallah@pidgin.im>
parents:
17663
diff
changeset
|
881 | bb->conversation = NULL; |
|
26bff2090889
Update Bonjour to do nonblocking I/O correctly.
Daniel Atallah <datallah@pidgin.im>
parents:
17663
diff
changeset
|
882 | return; |
|
26bff2090889
Update Bonjour to do nonblocking I/O correctly.
Daniel Atallah <datallah@pidgin.im>
parents:
17663
diff
changeset
|
883 | } |
|
26bff2090889
Update Bonjour to do nonblocking I/O correctly.
Daniel Atallah <datallah@pidgin.im>
parents:
17663
diff
changeset
|
884 | |
|
21944
c41d17a1b8d9
This is the second part of the fix to support having multiple presence records in Bonjour (and also supporting multiple presences using the same IP). Incoming conversations are no longer immediately attached to a buddy - we use an algorithm to match a conversation to a buddy based on the IP and, if possible the "from" attribute of the stream or the first tag in the stream. Thanks to Sjoerd Simons from Telepahy Salut for noticing and suggesting the algorithm. Fixes #4187. It'd be good if a few people test this.
Daniel Atallah <datallah@pidgin.im>
parents:
21936
diff
changeset
|
885 | if (!bonjour_jabber_send_stream_init(bb->conversation, source)) { |
|
21389
e1dd8142bb87
replace most calls to strerror with calls to g_strerror. strerror will return
Nathan Walp <nwalp@pidgin.im>
parents:
21093
diff
changeset
|
886 | const char *err = g_strerror(errno); |
|
24938
fc6952107e1f
Finished moving to api for bonjour
Gary Kramlich <grim@reaperworld.com>
parents:
24562
diff
changeset
|
887 | PurpleConversation *conv = NULL; |
|
fc6952107e1f
Finished moving to api for bonjour
Gary Kramlich <grim@reaperworld.com>
parents:
24562
diff
changeset
|
888 | PurpleAccount *account = NULL; |
|
17665
26bff2090889
Update Bonjour to do nonblocking I/O correctly.
Daniel Atallah <datallah@pidgin.im>
parents:
17663
diff
changeset
|
889 | |
|
26bff2090889
Update Bonjour to do nonblocking I/O correctly.
Daniel Atallah <datallah@pidgin.im>
parents:
17663
diff
changeset
|
890 | purple_debug_error("bonjour", "Error starting stream with buddy %s at %s:%d error: %s\n", |
|
21944
c41d17a1b8d9
This is the second part of the fix to support having multiple presence records in Bonjour (and also supporting multiple presences using the same IP). Incoming conversations are no longer immediately attached to a buddy - we use an algorithm to match a conversation to a buddy based on the IP and, if possible the "from" attribute of the stream or the first tag in the stream. Thanks to Sjoerd Simons from Telepahy Salut for noticing and suggesting the algorithm. Fixes #4187. It'd be good if a few people test this.
Daniel Atallah <datallah@pidgin.im>
parents:
21936
diff
changeset
|
891 | purple_buddy_get_name(pb), bb->conversation->ip, bb->port_p2pj, err ? err : "(null)"); |
|
17665
26bff2090889
Update Bonjour to do nonblocking I/O correctly.
Daniel Atallah <datallah@pidgin.im>
parents:
17663
diff
changeset
|
892 | |
|
24938
fc6952107e1f
Finished moving to api for bonjour
Gary Kramlich <grim@reaperworld.com>
parents:
24562
diff
changeset
|
893 | account = purple_buddy_get_account(pb); |
|
fc6952107e1f
Finished moving to api for bonjour
Gary Kramlich <grim@reaperworld.com>
parents:
24562
diff
changeset
|
894 | |
|
34632
ebe6b2a60305
Changed all arguments and return types of Chat and IMs to PurpleChatConversation and PurpleIMConversation.
Ankit Vani <a@nevitus.org>
parents:
34625
diff
changeset
|
895 | conv = PURPLE_CONVERSATION(purple_conversations_find_im_with_account(bb->name, account)); |
|
17665
26bff2090889
Update Bonjour to do nonblocking I/O correctly.
Daniel Atallah <datallah@pidgin.im>
parents:
17663
diff
changeset
|
896 | if (conv != NULL) |
|
26bff2090889
Update Bonjour to do nonblocking I/O correctly.
Daniel Atallah <datallah@pidgin.im>
parents:
17663
diff
changeset
|
897 | purple_conversation_write(conv, NULL, |
|
26bff2090889
Update Bonjour to do nonblocking I/O correctly.
Daniel Atallah <datallah@pidgin.im>
parents:
17663
diff
changeset
|
898 | _("Unable to send the message, the conversation couldn't be started."), |
|
26bff2090889
Update Bonjour to do nonblocking I/O correctly.
Daniel Atallah <datallah@pidgin.im>
parents:
17663
diff
changeset
|
899 | PURPLE_MESSAGE_SYSTEM, time(NULL)); |
|
26bff2090889
Update Bonjour to do nonblocking I/O correctly.
Daniel Atallah <datallah@pidgin.im>
parents:
17663
diff
changeset
|
900 | |
|
26bff2090889
Update Bonjour to do nonblocking I/O correctly.
Daniel Atallah <datallah@pidgin.im>
parents:
17663
diff
changeset
|
901 | close(source); |
|
26bff2090889
Update Bonjour to do nonblocking I/O correctly.
Daniel Atallah <datallah@pidgin.im>
parents:
17663
diff
changeset
|
902 | bonjour_jabber_close_conversation(bb->conversation); |
|
26bff2090889
Update Bonjour to do nonblocking I/O correctly.
Daniel Atallah <datallah@pidgin.im>
parents:
17663
diff
changeset
|
903 | bb->conversation = NULL; |
|
26bff2090889
Update Bonjour to do nonblocking I/O correctly.
Daniel Atallah <datallah@pidgin.im>
parents:
17663
diff
changeset
|
904 | return; |
|
26bff2090889
Update Bonjour to do nonblocking I/O correctly.
Daniel Atallah <datallah@pidgin.im>
parents:
17663
diff
changeset
|
905 | } |
|
21727
decfc3a613ff
applied changes from b9c97ed0f9ada9069e8bd994b01fdde0b484083c
Daniel Atallah <datallah@pidgin.im>
parents:
21720
diff
changeset
|
906 | |
|
decfc3a613ff
applied changes from b9c97ed0f9ada9069e8bd994b01fdde0b484083c
Daniel Atallah <datallah@pidgin.im>
parents:
21720
diff
changeset
|
907 | /* Start listening for the stream acknowledgement */ |
|
decfc3a613ff
applied changes from b9c97ed0f9ada9069e8bd994b01fdde0b484083c
Daniel Atallah <datallah@pidgin.im>
parents:
21720
diff
changeset
|
908 | bb->conversation->socket = source; |
|
decfc3a613ff
applied changes from b9c97ed0f9ada9069e8bd994b01fdde0b484083c
Daniel Atallah <datallah@pidgin.im>
parents:
21720
diff
changeset
|
909 | bb->conversation->rx_handler = purple_input_add(source, |
|
21944
c41d17a1b8d9
This is the second part of the fix to support having multiple presence records in Bonjour (and also supporting multiple presences using the same IP). Incoming conversations are no longer immediately attached to a buddy - we use an algorithm to match a conversation to a buddy based on the IP and, if possible the "from" attribute of the stream or the first tag in the stream. Thanks to Sjoerd Simons from Telepahy Salut for noticing and suggesting the algorithm. Fixes #4187. It'd be good if a few people test this.
Daniel Atallah <datallah@pidgin.im>
parents:
21936
diff
changeset
|
910 | PURPLE_INPUT_READ, _client_socket_handler, bb->conversation); |
|
c41d17a1b8d9
This is the second part of the fix to support having multiple presence records in Bonjour (and also supporting multiple presences using the same IP). Incoming conversations are no longer immediately attached to a buddy - we use an algorithm to match a conversation to a buddy based on the IP and, if possible the "from" attribute of the stream or the first tag in the stream. Thanks to Sjoerd Simons from Telepahy Salut for noticing and suggesting the algorithm. Fixes #4187. It'd be good if a few people test this.
Daniel Atallah <datallah@pidgin.im>
parents:
21936
diff
changeset
|
911 | } |
|
c41d17a1b8d9
This is the second part of the fix to support having multiple presence records in Bonjour (and also supporting multiple presences using the same IP). Incoming conversations are no longer immediately attached to a buddy - we use an algorithm to match a conversation to a buddy based on the IP and, if possible the "from" attribute of the stream or the first tag in the stream. Thanks to Sjoerd Simons from Telepahy Salut for noticing and suggesting the algorithm. Fixes #4187. It'd be good if a few people test this.
Daniel Atallah <datallah@pidgin.im>
parents:
21936
diff
changeset
|
912 | |
|
c41d17a1b8d9
This is the second part of the fix to support having multiple presence records in Bonjour (and also supporting multiple presences using the same IP). Incoming conversations are no longer immediately attached to a buddy - we use an algorithm to match a conversation to a buddy based on the IP and, if possible the "from" attribute of the stream or the first tag in the stream. Thanks to Sjoerd Simons from Telepahy Salut for noticing and suggesting the algorithm. Fixes #4187. It'd be good if a few people test this.
Daniel Atallah <datallah@pidgin.im>
parents:
21936
diff
changeset
|
913 | void |
|
c41d17a1b8d9
This is the second part of the fix to support having multiple presence records in Bonjour (and also supporting multiple presences using the same IP). Incoming conversations are no longer immediately attached to a buddy - we use an algorithm to match a conversation to a buddy based on the IP and, if possible the "from" attribute of the stream or the first tag in the stream. Thanks to Sjoerd Simons from Telepahy Salut for noticing and suggesting the algorithm. Fixes #4187. It'd be good if a few people test this.
Daniel Atallah <datallah@pidgin.im>
parents:
21936
diff
changeset
|
914 | bonjour_jabber_conv_match_by_name(BonjourJabberConversation *bconv) { |
|
24938
fc6952107e1f
Finished moving to api for bonjour
Gary Kramlich <grim@reaperworld.com>
parents:
24562
diff
changeset
|
915 | PurpleBuddy *pb = NULL; |
|
fc6952107e1f
Finished moving to api for bonjour
Gary Kramlich <grim@reaperworld.com>
parents:
24562
diff
changeset
|
916 | BonjourBuddy *bb = NULL; |
|
21944
c41d17a1b8d9
This is the second part of the fix to support having multiple presence records in Bonjour (and also supporting multiple presences using the same IP). Incoming conversations are no longer immediately attached to a buddy - we use an algorithm to match a conversation to a buddy based on the IP and, if possible the "from" attribute of the stream or the first tag in the stream. Thanks to Sjoerd Simons from Telepahy Salut for noticing and suggesting the algorithm. Fixes #4187. It'd be good if a few people test this.
Daniel Atallah <datallah@pidgin.im>
parents:
21936
diff
changeset
|
917 | |
|
c41d17a1b8d9
This is the second part of the fix to support having multiple presence records in Bonjour (and also supporting multiple presences using the same IP). Incoming conversations are no longer immediately attached to a buddy - we use an algorithm to match a conversation to a buddy based on the IP and, if possible the "from" attribute of the stream or the first tag in the stream. Thanks to Sjoerd Simons from Telepahy Salut for noticing and suggesting the algorithm. Fixes #4187. It'd be good if a few people test this.
Daniel Atallah <datallah@pidgin.im>
parents:
21936
diff
changeset
|
918 | g_return_if_fail(bconv->ip != NULL); |
|
c41d17a1b8d9
This is the second part of the fix to support having multiple presence records in Bonjour (and also supporting multiple presences using the same IP). Incoming conversations are no longer immediately attached to a buddy - we use an algorithm to match a conversation to a buddy based on the IP and, if possible the "from" attribute of the stream or the first tag in the stream. Thanks to Sjoerd Simons from Telepahy Salut for noticing and suggesting the algorithm. Fixes #4187. It'd be good if a few people test this.
Daniel Atallah <datallah@pidgin.im>
parents:
21936
diff
changeset
|
919 | g_return_if_fail(bconv->pb == NULL); |
|
c41d17a1b8d9
This is the second part of the fix to support having multiple presence records in Bonjour (and also supporting multiple presences using the same IP). Incoming conversations are no longer immediately attached to a buddy - we use an algorithm to match a conversation to a buddy based on the IP and, if possible the "from" attribute of the stream or the first tag in the stream. Thanks to Sjoerd Simons from Telepahy Salut for noticing and suggesting the algorithm. Fixes #4187. It'd be good if a few people test this.
Daniel Atallah <datallah@pidgin.im>
parents:
21936
diff
changeset
|
920 | |
|
34728
8efd73063ecf
Renamed buddy list functions to more appropriate/simler names.
Ankit Vani <a@nevitus.org>
parents:
34706
diff
changeset
|
921 | pb = purple_blist_find_buddy(bconv->account, bconv->buddy_name); |
|
24938
fc6952107e1f
Finished moving to api for bonjour
Gary Kramlich <grim@reaperworld.com>
parents:
24562
diff
changeset
|
922 | if (pb && (bb = purple_buddy_get_protocol_data(pb))) { |
|
21944
c41d17a1b8d9
This is the second part of the fix to support having multiple presence records in Bonjour (and also supporting multiple presences using the same IP). Incoming conversations are no longer immediately attached to a buddy - we use an algorithm to match a conversation to a buddy based on the IP and, if possible the "from" attribute of the stream or the first tag in the stream. Thanks to Sjoerd Simons from Telepahy Salut for noticing and suggesting the algorithm. Fixes #4187. It'd be good if a few people test this.
Daniel Atallah <datallah@pidgin.im>
parents:
21936
diff
changeset
|
923 | const char *ip; |
|
c41d17a1b8d9
This is the second part of the fix to support having multiple presence records in Bonjour (and also supporting multiple presences using the same IP). Incoming conversations are no longer immediately attached to a buddy - we use an algorithm to match a conversation to a buddy based on the IP and, if possible the "from" attribute of the stream or the first tag in the stream. Thanks to Sjoerd Simons from Telepahy Salut for noticing and suggesting the algorithm. Fixes #4187. It'd be good if a few people test this.
Daniel Atallah <datallah@pidgin.im>
parents:
21936
diff
changeset
|
924 | GSList *tmp = bb->ips; |
|
c41d17a1b8d9
This is the second part of the fix to support having multiple presence records in Bonjour (and also supporting multiple presences using the same IP). Incoming conversations are no longer immediately attached to a buddy - we use an algorithm to match a conversation to a buddy based on the IP and, if possible the "from" attribute of the stream or the first tag in the stream. Thanks to Sjoerd Simons from Telepahy Salut for noticing and suggesting the algorithm. Fixes #4187. It'd be good if a few people test this.
Daniel Atallah <datallah@pidgin.im>
parents:
21936
diff
changeset
|
925 | |
|
c41d17a1b8d9
This is the second part of the fix to support having multiple presence records in Bonjour (and also supporting multiple presences using the same IP). Incoming conversations are no longer immediately attached to a buddy - we use an algorithm to match a conversation to a buddy based on the IP and, if possible the "from" attribute of the stream or the first tag in the stream. Thanks to Sjoerd Simons from Telepahy Salut for noticing and suggesting the algorithm. Fixes #4187. It'd be good if a few people test this.
Daniel Atallah <datallah@pidgin.im>
parents:
21936
diff
changeset
|
926 | purple_debug_info("bonjour", "Found buddy %s for incoming conversation \"from\" attrib.\n", |
|
c41d17a1b8d9
This is the second part of the fix to support having multiple presence records in Bonjour (and also supporting multiple presences using the same IP). Incoming conversations are no longer immediately attached to a buddy - we use an algorithm to match a conversation to a buddy based on the IP and, if possible the "from" attribute of the stream or the first tag in the stream. Thanks to Sjoerd Simons from Telepahy Salut for noticing and suggesting the algorithm. Fixes #4187. It'd be good if a few people test this.
Daniel Atallah <datallah@pidgin.im>
parents:
21936
diff
changeset
|
927 | purple_buddy_get_name(pb)); |
|
c41d17a1b8d9
This is the second part of the fix to support having multiple presence records in Bonjour (and also supporting multiple presences using the same IP). Incoming conversations are no longer immediately attached to a buddy - we use an algorithm to match a conversation to a buddy based on the IP and, if possible the "from" attribute of the stream or the first tag in the stream. Thanks to Sjoerd Simons from Telepahy Salut for noticing and suggesting the algorithm. Fixes #4187. It'd be good if a few people test this.
Daniel Atallah <datallah@pidgin.im>
parents:
21936
diff
changeset
|
928 | |
|
c41d17a1b8d9
This is the second part of the fix to support having multiple presence records in Bonjour (and also supporting multiple presences using the same IP). Incoming conversations are no longer immediately attached to a buddy - we use an algorithm to match a conversation to a buddy based on the IP and, if possible the "from" attribute of the stream or the first tag in the stream. Thanks to Sjoerd Simons from Telepahy Salut for noticing and suggesting the algorithm. Fixes #4187. It'd be good if a few people test this.
Daniel Atallah <datallah@pidgin.im>
parents:
21936
diff
changeset
|
929 | /* Check that one of the buddy's IPs matches */ |
|
c41d17a1b8d9
This is the second part of the fix to support having multiple presence records in Bonjour (and also supporting multiple presences using the same IP). Incoming conversations are no longer immediately attached to a buddy - we use an algorithm to match a conversation to a buddy based on the IP and, if possible the "from" attribute of the stream or the first tag in the stream. Thanks to Sjoerd Simons from Telepahy Salut for noticing and suggesting the algorithm. Fixes #4187. It'd be good if a few people test this.
Daniel Atallah <datallah@pidgin.im>
parents:
21936
diff
changeset
|
930 | while(tmp) { |
|
c41d17a1b8d9
This is the second part of the fix to support having multiple presence records in Bonjour (and also supporting multiple presences using the same IP). Incoming conversations are no longer immediately attached to a buddy - we use an algorithm to match a conversation to a buddy based on the IP and, if possible the "from" attribute of the stream or the first tag in the stream. Thanks to Sjoerd Simons from Telepahy Salut for noticing and suggesting the algorithm. Fixes #4187. It'd be good if a few people test this.
Daniel Atallah <datallah@pidgin.im>
parents:
21936
diff
changeset
|
931 | ip = tmp->data; |
|
c41d17a1b8d9
This is the second part of the fix to support having multiple presence records in Bonjour (and also supporting multiple presences using the same IP). Incoming conversations are no longer immediately attached to a buddy - we use an algorithm to match a conversation to a buddy based on the IP and, if possible the "from" attribute of the stream or the first tag in the stream. Thanks to Sjoerd Simons from Telepahy Salut for noticing and suggesting the algorithm. Fixes #4187. It'd be good if a few people test this.
Daniel Atallah <datallah@pidgin.im>
parents:
21936
diff
changeset
|
932 | if (ip != NULL && g_ascii_strcasecmp(ip, bconv->ip) == 0) { |
|
32215
0a4e72c8a67e
Use accessor functions in a few places
Mark Doliner <markdoliner@pidgin.im>
parents:
31749
diff
changeset
|
933 | PurpleConnection *pc = purple_account_get_connection(bconv->account); |
|
32260
5b0ecccb3bbb
Convert bonjour prpl to use accessor functions purple_connection_get_protocol_data() and purple_connection_set_protocol_data().
Andrew Victor <andrew.victor@mxit.com>
parents:
32215
diff
changeset
|
934 | BonjourData *bd = purple_connection_get_protocol_data(pc); |
|
5b0ecccb3bbb
Convert bonjour prpl to use accessor functions purple_connection_get_protocol_data() and purple_connection_set_protocol_data().
Andrew Victor <andrew.victor@mxit.com>
parents:
32215
diff
changeset
|
935 | BonjourJabber *jdata = bd->jabber_data; |
|
21944
c41d17a1b8d9
This is the second part of the fix to support having multiple presence records in Bonjour (and also supporting multiple presences using the same IP). Incoming conversations are no longer immediately attached to a buddy - we use an algorithm to match a conversation to a buddy based on the IP and, if possible the "from" attribute of the stream or the first tag in the stream. Thanks to Sjoerd Simons from Telepahy Salut for noticing and suggesting the algorithm. Fixes #4187. It'd be good if a few people test this.
Daniel Atallah <datallah@pidgin.im>
parents:
21936
diff
changeset
|
936 | |
|
c41d17a1b8d9
This is the second part of the fix to support having multiple presence records in Bonjour (and also supporting multiple presences using the same IP). Incoming conversations are no longer immediately attached to a buddy - we use an algorithm to match a conversation to a buddy based on the IP and, if possible the "from" attribute of the stream or the first tag in the stream. Thanks to Sjoerd Simons from Telepahy Salut for noticing and suggesting the algorithm. Fixes #4187. It'd be good if a few people test this.
Daniel Atallah <datallah@pidgin.im>
parents:
21936
diff
changeset
|
937 | purple_debug_info("bonjour", "Matched buddy %s to incoming conversation \"from\" attrib and IP (%s)\n", |
|
c41d17a1b8d9
This is the second part of the fix to support having multiple presence records in Bonjour (and also supporting multiple presences using the same IP). Incoming conversations are no longer immediately attached to a buddy - we use an algorithm to match a conversation to a buddy based on the IP and, if possible the "from" attribute of the stream or the first tag in the stream. Thanks to Sjoerd Simons from Telepahy Salut for noticing and suggesting the algorithm. Fixes #4187. It'd be good if a few people test this.
Daniel Atallah <datallah@pidgin.im>
parents:
21936
diff
changeset
|
938 | purple_buddy_get_name(pb), bconv->ip); |
|
c41d17a1b8d9
This is the second part of the fix to support having multiple presence records in Bonjour (and also supporting multiple presences using the same IP). Incoming conversations are no longer immediately attached to a buddy - we use an algorithm to match a conversation to a buddy based on the IP and, if possible the "from" attribute of the stream or the first tag in the stream. Thanks to Sjoerd Simons from Telepahy Salut for noticing and suggesting the algorithm. Fixes #4187. It'd be good if a few people test this.
Daniel Atallah <datallah@pidgin.im>
parents:
21936
diff
changeset
|
939 | |
|
c41d17a1b8d9
This is the second part of the fix to support having multiple presence records in Bonjour (and also supporting multiple presences using the same IP). Incoming conversations are no longer immediately attached to a buddy - we use an algorithm to match a conversation to a buddy based on the IP and, if possible the "from" attribute of the stream or the first tag in the stream. Thanks to Sjoerd Simons from Telepahy Salut for noticing and suggesting the algorithm. Fixes #4187. It'd be good if a few people test this.
Daniel Atallah <datallah@pidgin.im>
parents:
21936
diff
changeset
|
940 | /* Attach conv. to buddy and remove from pending list */ |
|
c41d17a1b8d9
This is the second part of the fix to support having multiple presence records in Bonjour (and also supporting multiple presences using the same IP). Incoming conversations are no longer immediately attached to a buddy - we use an algorithm to match a conversation to a buddy based on the IP and, if possible the "from" attribute of the stream or the first tag in the stream. Thanks to Sjoerd Simons from Telepahy Salut for noticing and suggesting the algorithm. Fixes #4187. It'd be good if a few people test this.
Daniel Atallah <datallah@pidgin.im>
parents:
21936
diff
changeset
|
941 | jdata->pending_conversations = g_slist_remove(jdata->pending_conversations, bconv); |
|
c41d17a1b8d9
This is the second part of the fix to support having multiple presence records in Bonjour (and also supporting multiple presences using the same IP). Incoming conversations are no longer immediately attached to a buddy - we use an algorithm to match a conversation to a buddy based on the IP and, if possible the "from" attribute of the stream or the first tag in the stream. Thanks to Sjoerd Simons from Telepahy Salut for noticing and suggesting the algorithm. Fixes #4187. It'd be good if a few people test this.
Daniel Atallah <datallah@pidgin.im>
parents:
21936
diff
changeset
|
942 | |
|
c41d17a1b8d9
This is the second part of the fix to support having multiple presence records in Bonjour (and also supporting multiple presences using the same IP). Incoming conversations are no longer immediately attached to a buddy - we use an algorithm to match a conversation to a buddy based on the IP and, if possible the "from" attribute of the stream or the first tag in the stream. Thanks to Sjoerd Simons from Telepahy Salut for noticing and suggesting the algorithm. Fixes #4187. It'd be good if a few people test this.
Daniel Atallah <datallah@pidgin.im>
parents:
21936
diff
changeset
|
943 | /* Check if the buddy already has a conversation and, if so, replace it */ |
|
c41d17a1b8d9
This is the second part of the fix to support having multiple presence records in Bonjour (and also supporting multiple presences using the same IP). Incoming conversations are no longer immediately attached to a buddy - we use an algorithm to match a conversation to a buddy based on the IP and, if possible the "from" attribute of the stream or the first tag in the stream. Thanks to Sjoerd Simons from Telepahy Salut for noticing and suggesting the algorithm. Fixes #4187. It'd be good if a few people test this.
Daniel Atallah <datallah@pidgin.im>
parents:
21936
diff
changeset
|
944 | if(bb->conversation != NULL && bb->conversation != bconv) |
|
c41d17a1b8d9
This is the second part of the fix to support having multiple presence records in Bonjour (and also supporting multiple presences using the same IP). Incoming conversations are no longer immediately attached to a buddy - we use an algorithm to match a conversation to a buddy based on the IP and, if possible the "from" attribute of the stream or the first tag in the stream. Thanks to Sjoerd Simons from Telepahy Salut for noticing and suggesting the algorithm. Fixes #4187. It'd be good if a few people test this.
Daniel Atallah <datallah@pidgin.im>
parents:
21936
diff
changeset
|
945 | bonjour_jabber_close_conversation(bb->conversation); |
|
c41d17a1b8d9
This is the second part of the fix to support having multiple presence records in Bonjour (and also supporting multiple presences using the same IP). Incoming conversations are no longer immediately attached to a buddy - we use an algorithm to match a conversation to a buddy based on the IP and, if possible the "from" attribute of the stream or the first tag in the stream. Thanks to Sjoerd Simons from Telepahy Salut for noticing and suggesting the algorithm. Fixes #4187. It'd be good if a few people test this.
Daniel Atallah <datallah@pidgin.im>
parents:
21936
diff
changeset
|
946 | |
|
c41d17a1b8d9
This is the second part of the fix to support having multiple presence records in Bonjour (and also supporting multiple presences using the same IP). Incoming conversations are no longer immediately attached to a buddy - we use an algorithm to match a conversation to a buddy based on the IP and, if possible the "from" attribute of the stream or the first tag in the stream. Thanks to Sjoerd Simons from Telepahy Salut for noticing and suggesting the algorithm. Fixes #4187. It'd be good if a few people test this.
Daniel Atallah <datallah@pidgin.im>
parents:
21936
diff
changeset
|
947 | bconv->pb = pb; |
|
c41d17a1b8d9
This is the second part of the fix to support having multiple presence records in Bonjour (and also supporting multiple presences using the same IP). Incoming conversations are no longer immediately attached to a buddy - we use an algorithm to match a conversation to a buddy based on the IP and, if possible the "from" attribute of the stream or the first tag in the stream. Thanks to Sjoerd Simons from Telepahy Salut for noticing and suggesting the algorithm. Fixes #4187. It'd be good if a few people test this.
Daniel Atallah <datallah@pidgin.im>
parents:
21936
diff
changeset
|
948 | bb->conversation = bconv; |
|
c41d17a1b8d9
This is the second part of the fix to support having multiple presence records in Bonjour (and also supporting multiple presences using the same IP). Incoming conversations are no longer immediately attached to a buddy - we use an algorithm to match a conversation to a buddy based on the IP and, if possible the "from" attribute of the stream or the first tag in the stream. Thanks to Sjoerd Simons from Telepahy Salut for noticing and suggesting the algorithm. Fixes #4187. It'd be good if a few people test this.
Daniel Atallah <datallah@pidgin.im>
parents:
21936
diff
changeset
|
949 | |
|
c41d17a1b8d9
This is the second part of the fix to support having multiple presence records in Bonjour (and also supporting multiple presences using the same IP). Incoming conversations are no longer immediately attached to a buddy - we use an algorithm to match a conversation to a buddy based on the IP and, if possible the "from" attribute of the stream or the first tag in the stream. Thanks to Sjoerd Simons from Telepahy Salut for noticing and suggesting the algorithm. Fixes #4187. It'd be good if a few people test this.
Daniel Atallah <datallah@pidgin.im>
parents:
21936
diff
changeset
|
950 | break; |
|
c41d17a1b8d9
This is the second part of the fix to support having multiple presence records in Bonjour (and also supporting multiple presences using the same IP). Incoming conversations are no longer immediately attached to a buddy - we use an algorithm to match a conversation to a buddy based on the IP and, if possible the "from" attribute of the stream or the first tag in the stream. Thanks to Sjoerd Simons from Telepahy Salut for noticing and suggesting the algorithm. Fixes #4187. It'd be good if a few people test this.
Daniel Atallah <datallah@pidgin.im>
parents:
21936
diff
changeset
|
951 | } |
|
c41d17a1b8d9
This is the second part of the fix to support having multiple presence records in Bonjour (and also supporting multiple presences using the same IP). Incoming conversations are no longer immediately attached to a buddy - we use an algorithm to match a conversation to a buddy based on the IP and, if possible the "from" attribute of the stream or the first tag in the stream. Thanks to Sjoerd Simons from Telepahy Salut for noticing and suggesting the algorithm. Fixes #4187. It'd be good if a few people test this.
Daniel Atallah <datallah@pidgin.im>
parents:
21936
diff
changeset
|
952 | tmp = tmp->next; |
|
c41d17a1b8d9
This is the second part of the fix to support having multiple presence records in Bonjour (and also supporting multiple presences using the same IP). Incoming conversations are no longer immediately attached to a buddy - we use an algorithm to match a conversation to a buddy based on the IP and, if possible the "from" attribute of the stream or the first tag in the stream. Thanks to Sjoerd Simons from Telepahy Salut for noticing and suggesting the algorithm. Fixes #4187. It'd be good if a few people test this.
Daniel Atallah <datallah@pidgin.im>
parents:
21936
diff
changeset
|
953 | } |
|
c41d17a1b8d9
This is the second part of the fix to support having multiple presence records in Bonjour (and also supporting multiple presences using the same IP). Incoming conversations are no longer immediately attached to a buddy - we use an algorithm to match a conversation to a buddy based on the IP and, if possible the "from" attribute of the stream or the first tag in the stream. Thanks to Sjoerd Simons from Telepahy Salut for noticing and suggesting the algorithm. Fixes #4187. It'd be good if a few people test this.
Daniel Atallah <datallah@pidgin.im>
parents:
21936
diff
changeset
|
954 | } |
|
c41d17a1b8d9
This is the second part of the fix to support having multiple presence records in Bonjour (and also supporting multiple presences using the same IP). Incoming conversations are no longer immediately attached to a buddy - we use an algorithm to match a conversation to a buddy based on the IP and, if possible the "from" attribute of the stream or the first tag in the stream. Thanks to Sjoerd Simons from Telepahy Salut for noticing and suggesting the algorithm. Fixes #4187. It'd be good if a few people test this.
Daniel Atallah <datallah@pidgin.im>
parents:
21936
diff
changeset
|
955 | |
|
c41d17a1b8d9
This is the second part of the fix to support having multiple presence records in Bonjour (and also supporting multiple presences using the same IP). Incoming conversations are no longer immediately attached to a buddy - we use an algorithm to match a conversation to a buddy based on the IP and, if possible the "from" attribute of the stream or the first tag in the stream. Thanks to Sjoerd Simons from Telepahy Salut for noticing and suggesting the algorithm. Fixes #4187. It'd be good if a few people test this.
Daniel Atallah <datallah@pidgin.im>
parents:
21936
diff
changeset
|
956 | /* We've failed to match a buddy - give up */ |
|
c41d17a1b8d9
This is the second part of the fix to support having multiple presence records in Bonjour (and also supporting multiple presences using the same IP). Incoming conversations are no longer immediately attached to a buddy - we use an algorithm to match a conversation to a buddy based on the IP and, if possible the "from" attribute of the stream or the first tag in the stream. Thanks to Sjoerd Simons from Telepahy Salut for noticing and suggesting the algorithm. Fixes #4187. It'd be good if a few people test this.
Daniel Atallah <datallah@pidgin.im>
parents:
21936
diff
changeset
|
957 | if (bconv->pb == NULL) { |
|
c41d17a1b8d9
This is the second part of the fix to support having multiple presence records in Bonjour (and also supporting multiple presences using the same IP). Incoming conversations are no longer immediately attached to a buddy - we use an algorithm to match a conversation to a buddy based on the IP and, if possible the "from" attribute of the stream or the first tag in the stream. Thanks to Sjoerd Simons from Telepahy Salut for noticing and suggesting the algorithm. Fixes #4187. It'd be good if a few people test this.
Daniel Atallah <datallah@pidgin.im>
parents:
21936
diff
changeset
|
958 | /* This must be asynchronous because it destroys the parser and we |
|
c41d17a1b8d9
This is the second part of the fix to support having multiple presence records in Bonjour (and also supporting multiple presences using the same IP). Incoming conversations are no longer immediately attached to a buddy - we use an algorithm to match a conversation to a buddy based on the IP and, if possible the "from" attribute of the stream or the first tag in the stream. Thanks to Sjoerd Simons from Telepahy Salut for noticing and suggesting the algorithm. Fixes #4187. It'd be good if a few people test this.
Daniel Atallah <datallah@pidgin.im>
parents:
21936
diff
changeset
|
959 | * may be in the middle of parsing. |
|
c41d17a1b8d9
This is the second part of the fix to support having multiple presence records in Bonjour (and also supporting multiple presences using the same IP). Incoming conversations are no longer immediately attached to a buddy - we use an algorithm to match a conversation to a buddy based on the IP and, if possible the "from" attribute of the stream or the first tag in the stream. Thanks to Sjoerd Simons from Telepahy Salut for noticing and suggesting the algorithm. Fixes #4187. It'd be good if a few people test this.
Daniel Atallah <datallah@pidgin.im>
parents:
21936
diff
changeset
|
960 | */ |
|
c41d17a1b8d9
This is the second part of the fix to support having multiple presence records in Bonjour (and also supporting multiple presences using the same IP). Incoming conversations are no longer immediately attached to a buddy - we use an algorithm to match a conversation to a buddy based on the IP and, if possible the "from" attribute of the stream or the first tag in the stream. Thanks to Sjoerd Simons from Telepahy Salut for noticing and suggesting the algorithm. Fixes #4187. It'd be good if a few people test this.
Daniel Atallah <datallah@pidgin.im>
parents:
21936
diff
changeset
|
961 | async_bonjour_jabber_close_conversation(bconv); |
|
c41d17a1b8d9
This is the second part of the fix to support having multiple presence records in Bonjour (and also supporting multiple presences using the same IP). Incoming conversations are no longer immediately attached to a buddy - we use an algorithm to match a conversation to a buddy based on the IP and, if possible the "from" attribute of the stream or the first tag in the stream. Thanks to Sjoerd Simons from Telepahy Salut for noticing and suggesting the algorithm. Fixes #4187. It'd be good if a few people test this.
Daniel Atallah <datallah@pidgin.im>
parents:
21936
diff
changeset
|
962 | } |
|
c41d17a1b8d9
This is the second part of the fix to support having multiple presence records in Bonjour (and also supporting multiple presences using the same IP). Incoming conversations are no longer immediately attached to a buddy - we use an algorithm to match a conversation to a buddy based on the IP and, if possible the "from" attribute of the stream or the first tag in the stream. Thanks to Sjoerd Simons from Telepahy Salut for noticing and suggesting the algorithm. Fixes #4187. It'd be good if a few people test this.
Daniel Atallah <datallah@pidgin.im>
parents:
21936
diff
changeset
|
963 | } |
|
c41d17a1b8d9
This is the second part of the fix to support having multiple presence records in Bonjour (and also supporting multiple presences using the same IP). Incoming conversations are no longer immediately attached to a buddy - we use an algorithm to match a conversation to a buddy based on the IP and, if possible the "from" attribute of the stream or the first tag in the stream. Thanks to Sjoerd Simons from Telepahy Salut for noticing and suggesting the algorithm. Fixes #4187. It'd be good if a few people test this.
Daniel Atallah <datallah@pidgin.im>
parents:
21936
diff
changeset
|
964 | |
|
c41d17a1b8d9
This is the second part of the fix to support having multiple presence records in Bonjour (and also supporting multiple presences using the same IP). Incoming conversations are no longer immediately attached to a buddy - we use an algorithm to match a conversation to a buddy based on the IP and, if possible the "from" attribute of the stream or the first tag in the stream. Thanks to Sjoerd Simons from Telepahy Salut for noticing and suggesting the algorithm. Fixes #4187. It'd be good if a few people test this.
Daniel Atallah <datallah@pidgin.im>
parents:
21936
diff
changeset
|
965 | |
|
c41d17a1b8d9
This is the second part of the fix to support having multiple presence records in Bonjour (and also supporting multiple presences using the same IP). Incoming conversations are no longer immediately attached to a buddy - we use an algorithm to match a conversation to a buddy based on the IP and, if possible the "from" attribute of the stream or the first tag in the stream. Thanks to Sjoerd Simons from Telepahy Salut for noticing and suggesting the algorithm. Fixes #4187. It'd be good if a few people test this.
Daniel Atallah <datallah@pidgin.im>
parents:
21936
diff
changeset
|
966 | void |
|
c41d17a1b8d9
This is the second part of the fix to support having multiple presence records in Bonjour (and also supporting multiple presences using the same IP). Incoming conversations are no longer immediately attached to a buddy - we use an algorithm to match a conversation to a buddy based on the IP and, if possible the "from" attribute of the stream or the first tag in the stream. Thanks to Sjoerd Simons from Telepahy Salut for noticing and suggesting the algorithm. Fixes #4187. It'd be good if a few people test this.
Daniel Atallah <datallah@pidgin.im>
parents:
21936
diff
changeset
|
967 | bonjour_jabber_conv_match_by_ip(BonjourJabberConversation *bconv) { |
|
32215
0a4e72c8a67e
Use accessor functions in a few places
Mark Doliner <markdoliner@pidgin.im>
parents:
31749
diff
changeset
|
968 | PurpleConnection *pc = purple_account_get_connection(bconv->account); |
|
32260
5b0ecccb3bbb
Convert bonjour prpl to use accessor functions purple_connection_get_protocol_data() and purple_connection_set_protocol_data().
Andrew Victor <andrew.victor@mxit.com>
parents:
32215
diff
changeset
|
969 | BonjourData *bd = purple_connection_get_protocol_data(pc); |
|
5b0ecccb3bbb
Convert bonjour prpl to use accessor functions purple_connection_get_protocol_data() and purple_connection_set_protocol_data().
Andrew Victor <andrew.victor@mxit.com>
parents:
32215
diff
changeset
|
970 | BonjourJabber *jdata = bd->jabber_data; |
|
21944
c41d17a1b8d9
This is the second part of the fix to support having multiple presence records in Bonjour (and also supporting multiple presences using the same IP). Incoming conversations are no longer immediately attached to a buddy - we use an algorithm to match a conversation to a buddy based on the IP and, if possible the "from" attribute of the stream or the first tag in the stream. Thanks to Sjoerd Simons from Telepahy Salut for noticing and suggesting the algorithm. Fixes #4187. It'd be good if a few people test this.
Daniel Atallah <datallah@pidgin.im>
parents:
21936
diff
changeset
|
971 | struct _match_buddies_by_address_t *mbba; |
|
26767
7489049a3bde
Change purple_blist_get_buddies to return a list instead of the hash table.
Paul Aurich <darkrain42@pidgin.im>
parents:
25911
diff
changeset
|
972 | GSList *buddies; |
|
21944
c41d17a1b8d9
This is the second part of the fix to support having multiple presence records in Bonjour (and also supporting multiple presences using the same IP). Incoming conversations are no longer immediately attached to a buddy - we use an algorithm to match a conversation to a buddy based on the IP and, if possible the "from" attribute of the stream or the first tag in the stream. Thanks to Sjoerd Simons from Telepahy Salut for noticing and suggesting the algorithm. Fixes #4187. It'd be good if a few people test this.
Daniel Atallah <datallah@pidgin.im>
parents:
21936
diff
changeset
|
973 | |
|
c41d17a1b8d9
This is the second part of the fix to support having multiple presence records in Bonjour (and also supporting multiple presences using the same IP). Incoming conversations are no longer immediately attached to a buddy - we use an algorithm to match a conversation to a buddy based on the IP and, if possible the "from" attribute of the stream or the first tag in the stream. Thanks to Sjoerd Simons from Telepahy Salut for noticing and suggesting the algorithm. Fixes #4187. It'd be good if a few people test this.
Daniel Atallah <datallah@pidgin.im>
parents:
21936
diff
changeset
|
974 | mbba = g_new0(struct _match_buddies_by_address_t, 1); |
|
c41d17a1b8d9
This is the second part of the fix to support having multiple presence records in Bonjour (and also supporting multiple presences using the same IP). Incoming conversations are no longer immediately attached to a buddy - we use an algorithm to match a conversation to a buddy based on the IP and, if possible the "from" attribute of the stream or the first tag in the stream. Thanks to Sjoerd Simons from Telepahy Salut for noticing and suggesting the algorithm. Fixes #4187. It'd be good if a few people test this.
Daniel Atallah <datallah@pidgin.im>
parents:
21936
diff
changeset
|
975 | mbba->address = bconv->ip; |
|
26767
7489049a3bde
Change purple_blist_get_buddies to return a list instead of the hash table.
Paul Aurich <darkrain42@pidgin.im>
parents:
25911
diff
changeset
|
976 | |
|
34728
8efd73063ecf
Renamed buddy list functions to more appropriate/simler names.
Ankit Vani <a@nevitus.org>
parents:
34706
diff
changeset
|
977 | buddies = purple_blist_find_buddies(jdata->account, NULL); |
|
26767
7489049a3bde
Change purple_blist_get_buddies to return a list instead of the hash table.
Paul Aurich <darkrain42@pidgin.im>
parents:
25911
diff
changeset
|
978 | g_slist_foreach(buddies, _match_buddies_by_address, mbba); |
|
7489049a3bde
Change purple_blist_get_buddies to return a list instead of the hash table.
Paul Aurich <darkrain42@pidgin.im>
parents:
25911
diff
changeset
|
979 | g_slist_free(buddies); |
|
21944
c41d17a1b8d9
This is the second part of the fix to support having multiple presence records in Bonjour (and also supporting multiple presences using the same IP). Incoming conversations are no longer immediately attached to a buddy - we use an algorithm to match a conversation to a buddy based on the IP and, if possible the "from" attribute of the stream or the first tag in the stream. Thanks to Sjoerd Simons from Telepahy Salut for noticing and suggesting the algorithm. Fixes #4187. It'd be good if a few people test this.
Daniel Atallah <datallah@pidgin.im>
parents:
21936
diff
changeset
|
980 | |
|
c41d17a1b8d9
This is the second part of the fix to support having multiple presence records in Bonjour (and also supporting multiple presences using the same IP). Incoming conversations are no longer immediately attached to a buddy - we use an algorithm to match a conversation to a buddy based on the IP and, if possible the "from" attribute of the stream or the first tag in the stream. Thanks to Sjoerd Simons from Telepahy Salut for noticing and suggesting the algorithm. Fixes #4187. It'd be good if a few people test this.
Daniel Atallah <datallah@pidgin.im>
parents:
21936
diff
changeset
|
981 | /* If there is exactly one match, use it */ |
|
c41d17a1b8d9
This is the second part of the fix to support having multiple presence records in Bonjour (and also supporting multiple presences using the same IP). Incoming conversations are no longer immediately attached to a buddy - we use an algorithm to match a conversation to a buddy based on the IP and, if possible the "from" attribute of the stream or the first tag in the stream. Thanks to Sjoerd Simons from Telepahy Salut for noticing and suggesting the algorithm. Fixes #4187. It'd be good if a few people test this.
Daniel Atallah <datallah@pidgin.im>
parents:
21936
diff
changeset
|
982 | if(mbba->matched_buddies != NULL) { |
|
c41d17a1b8d9
This is the second part of the fix to support having multiple presence records in Bonjour (and also supporting multiple presences using the same IP). Incoming conversations are no longer immediately attached to a buddy - we use an algorithm to match a conversation to a buddy based on the IP and, if possible the "from" attribute of the stream or the first tag in the stream. Thanks to Sjoerd Simons from Telepahy Salut for noticing and suggesting the algorithm. Fixes #4187. It'd be good if a few people test this.
Daniel Atallah <datallah@pidgin.im>
parents:
21936
diff
changeset
|
983 | if(mbba->matched_buddies->next != NULL) |
|
c41d17a1b8d9
This is the second part of the fix to support having multiple presence records in Bonjour (and also supporting multiple presences using the same IP). Incoming conversations are no longer immediately attached to a buddy - we use an algorithm to match a conversation to a buddy based on the IP and, if possible the "from" attribute of the stream or the first tag in the stream. Thanks to Sjoerd Simons from Telepahy Salut for noticing and suggesting the algorithm. Fixes #4187. It'd be good if a few people test this.
Daniel Atallah <datallah@pidgin.im>
parents:
21936
diff
changeset
|
984 | purple_debug_error("bonjour", "More than one buddy matched for ip %s.\n", bconv->ip); |
|
c41d17a1b8d9
This is the second part of the fix to support having multiple presence records in Bonjour (and also supporting multiple presences using the same IP). Incoming conversations are no longer immediately attached to a buddy - we use an algorithm to match a conversation to a buddy based on the IP and, if possible the "from" attribute of the stream or the first tag in the stream. Thanks to Sjoerd Simons from Telepahy Salut for noticing and suggesting the algorithm. Fixes #4187. It'd be good if a few people test this.
Daniel Atallah <datallah@pidgin.im>
parents:
21936
diff
changeset
|
985 | else { |
|
c41d17a1b8d9
This is the second part of the fix to support having multiple presence records in Bonjour (and also supporting multiple presences using the same IP). Incoming conversations are no longer immediately attached to a buddy - we use an algorithm to match a conversation to a buddy based on the IP and, if possible the "from" attribute of the stream or the first tag in the stream. Thanks to Sjoerd Simons from Telepahy Salut for noticing and suggesting the algorithm. Fixes #4187. It'd be good if a few people test this.
Daniel Atallah <datallah@pidgin.im>
parents:
21936
diff
changeset
|
986 | PurpleBuddy *pb = mbba->matched_buddies->data; |
|
24938
fc6952107e1f
Finished moving to api for bonjour
Gary Kramlich <grim@reaperworld.com>
parents:
24562
diff
changeset
|
987 | BonjourBuddy *bb = purple_buddy_get_protocol_data(pb); |
|
21944
c41d17a1b8d9
This is the second part of the fix to support having multiple presence records in Bonjour (and also supporting multiple presences using the same IP). Incoming conversations are no longer immediately attached to a buddy - we use an algorithm to match a conversation to a buddy based on the IP and, if possible the "from" attribute of the stream or the first tag in the stream. Thanks to Sjoerd Simons from Telepahy Salut for noticing and suggesting the algorithm. Fixes #4187. It'd be good if a few people test this.
Daniel Atallah <datallah@pidgin.im>
parents:
21936
diff
changeset
|
988 | |
|
c41d17a1b8d9
This is the second part of the fix to support having multiple presence records in Bonjour (and also supporting multiple presences using the same IP). Incoming conversations are no longer immediately attached to a buddy - we use an algorithm to match a conversation to a buddy based on the IP and, if possible the "from" attribute of the stream or the first tag in the stream. Thanks to Sjoerd Simons from Telepahy Salut for noticing and suggesting the algorithm. Fixes #4187. It'd be good if a few people test this.
Daniel Atallah <datallah@pidgin.im>
parents:
21936
diff
changeset
|
989 | purple_debug_info("bonjour", "Matched buddy %s to incoming conversation using IP (%s)\n", |
|
c41d17a1b8d9
This is the second part of the fix to support having multiple presence records in Bonjour (and also supporting multiple presences using the same IP). Incoming conversations are no longer immediately attached to a buddy - we use an algorithm to match a conversation to a buddy based on the IP and, if possible the "from" attribute of the stream or the first tag in the stream. Thanks to Sjoerd Simons from Telepahy Salut for noticing and suggesting the algorithm. Fixes #4187. It'd be good if a few people test this.
Daniel Atallah <datallah@pidgin.im>
parents:
21936
diff
changeset
|
990 | purple_buddy_get_name(pb), bconv->ip); |
|
c41d17a1b8d9
This is the second part of the fix to support having multiple presence records in Bonjour (and also supporting multiple presences using the same IP). Incoming conversations are no longer immediately attached to a buddy - we use an algorithm to match a conversation to a buddy based on the IP and, if possible the "from" attribute of the stream or the first tag in the stream. Thanks to Sjoerd Simons from Telepahy Salut for noticing and suggesting the algorithm. Fixes #4187. It'd be good if a few people test this.
Daniel Atallah <datallah@pidgin.im>
parents:
21936
diff
changeset
|
991 | |
|
c41d17a1b8d9
This is the second part of the fix to support having multiple presence records in Bonjour (and also supporting multiple presences using the same IP). Incoming conversations are no longer immediately attached to a buddy - we use an algorithm to match a conversation to a buddy based on the IP and, if possible the "from" attribute of the stream or the first tag in the stream. Thanks to Sjoerd Simons from Telepahy Salut for noticing and suggesting the algorithm. Fixes #4187. It'd be good if a few people test this.
Daniel Atallah <datallah@pidgin.im>
parents:
21936
diff
changeset
|
992 | /* Attach conv. to buddy and remove from pending list */ |
|
c41d17a1b8d9
This is the second part of the fix to support having multiple presence records in Bonjour (and also supporting multiple presences using the same IP). Incoming conversations are no longer immediately attached to a buddy - we use an algorithm to match a conversation to a buddy based on the IP and, if possible the "from" attribute of the stream or the first tag in the stream. Thanks to Sjoerd Simons from Telepahy Salut for noticing and suggesting the algorithm. Fixes #4187. It'd be good if a few people test this.
Daniel Atallah <datallah@pidgin.im>
parents:
21936
diff
changeset
|
993 | jdata->pending_conversations = g_slist_remove(jdata->pending_conversations, bconv); |
|
c41d17a1b8d9
This is the second part of the fix to support having multiple presence records in Bonjour (and also supporting multiple presences using the same IP). Incoming conversations are no longer immediately attached to a buddy - we use an algorithm to match a conversation to a buddy based on the IP and, if possible the "from" attribute of the stream or the first tag in the stream. Thanks to Sjoerd Simons from Telepahy Salut for noticing and suggesting the algorithm. Fixes #4187. It'd be good if a few people test this.
Daniel Atallah <datallah@pidgin.im>
parents:
21936
diff
changeset
|
994 | |
|
c41d17a1b8d9
This is the second part of the fix to support having multiple presence records in Bonjour (and also supporting multiple presences using the same IP). Incoming conversations are no longer immediately attached to a buddy - we use an algorithm to match a conversation to a buddy based on the IP and, if possible the "from" attribute of the stream or the first tag in the stream. Thanks to Sjoerd Simons from Telepahy Salut for noticing and suggesting the algorithm. Fixes #4187. It'd be good if a few people test this.
Daniel Atallah <datallah@pidgin.im>
parents:
21936
diff
changeset
|
995 | /* Check if the buddy already has a conversation and, if so, replace it */ |
|
c41d17a1b8d9
This is the second part of the fix to support having multiple presence records in Bonjour (and also supporting multiple presences using the same IP). Incoming conversations are no longer immediately attached to a buddy - we use an algorithm to match a conversation to a buddy based on the IP and, if possible the "from" attribute of the stream or the first tag in the stream. Thanks to Sjoerd Simons from Telepahy Salut for noticing and suggesting the algorithm. Fixes #4187. It'd be good if a few people test this.
Daniel Atallah <datallah@pidgin.im>
parents:
21936
diff
changeset
|
996 | if (bb->conversation != NULL && bb->conversation != bconv) |
|
c41d17a1b8d9
This is the second part of the fix to support having multiple presence records in Bonjour (and also supporting multiple presences using the same IP). Incoming conversations are no longer immediately attached to a buddy - we use an algorithm to match a conversation to a buddy based on the IP and, if possible the "from" attribute of the stream or the first tag in the stream. Thanks to Sjoerd Simons from Telepahy Salut for noticing and suggesting the algorithm. Fixes #4187. It'd be good if a few people test this.
Daniel Atallah <datallah@pidgin.im>
parents:
21936
diff
changeset
|
997 | bonjour_jabber_close_conversation(bb->conversation); |
|
c41d17a1b8d9
This is the second part of the fix to support having multiple presence records in Bonjour (and also supporting multiple presences using the same IP). Incoming conversations are no longer immediately attached to a buddy - we use an algorithm to match a conversation to a buddy based on the IP and, if possible the "from" attribute of the stream or the first tag in the stream. Thanks to Sjoerd Simons from Telepahy Salut for noticing and suggesting the algorithm. Fixes #4187. It'd be good if a few people test this.
Daniel Atallah <datallah@pidgin.im>
parents:
21936
diff
changeset
|
998 | |
|
c41d17a1b8d9
This is the second part of the fix to support having multiple presence records in Bonjour (and also supporting multiple presences using the same IP). Incoming conversations are no longer immediately attached to a buddy - we use an algorithm to match a conversation to a buddy based on the IP and, if possible the "from" attribute of the stream or the first tag in the stream. Thanks to Sjoerd Simons from Telepahy Salut for noticing and suggesting the algorithm. Fixes #4187. It'd be good if a few people test this.
Daniel Atallah <datallah@pidgin.im>
parents:
21936
diff
changeset
|
999 | bconv->pb = pb; |
|
c41d17a1b8d9
This is the second part of the fix to support having multiple presence records in Bonjour (and also supporting multiple presences using the same IP). Incoming conversations are no longer immediately attached to a buddy - we use an algorithm to match a conversation to a buddy based on the IP and, if possible the "from" attribute of the stream or the first tag in the stream. Thanks to Sjoerd Simons from Telepahy Salut for noticing and suggesting the algorithm. Fixes #4187. It'd be good if a few people test this.
Daniel Atallah <datallah@pidgin.im>
parents:
21936
diff
changeset
|
1000 | bb->conversation = bconv; |
|
c41d17a1b8d9
This is the second part of the fix to support having multiple presence records in Bonjour (and also supporting multiple presences using the same IP). Incoming conversations are no longer immediately attached to a buddy - we use an algorithm to match a conversation to a buddy based on the IP and, if possible the "from" attribute of the stream or the first tag in the stream. Thanks to Sjoerd Simons from Telepahy Salut for noticing and suggesting the algorithm. Fixes #4187. It'd be good if a few people test this.
Daniel Atallah <datallah@pidgin.im>
parents:
21936
diff
changeset
|
1001 | } |
|
c41d17a1b8d9
This is the second part of the fix to support having multiple presence records in Bonjour (and also supporting multiple presences using the same IP). Incoming conversations are no longer immediately attached to a buddy - we use an algorithm to match a conversation to a buddy based on the IP and, if possible the "from" attribute of the stream or the first tag in the stream. Thanks to Sjoerd Simons from Telepahy Salut for noticing and suggesting the algorithm. Fixes #4187. It'd be good if a few people test this.
Daniel Atallah <datallah@pidgin.im>
parents:
21936
diff
changeset
|
1002 | } else |
|
c41d17a1b8d9
This is the second part of the fix to support having multiple presence records in Bonjour (and also supporting multiple presences using the same IP). Incoming conversations are no longer immediately attached to a buddy - we use an algorithm to match a conversation to a buddy based on the IP and, if possible the "from" attribute of the stream or the first tag in the stream. Thanks to Sjoerd Simons from Telepahy Salut for noticing and suggesting the algorithm. Fixes #4187. It'd be good if a few people test this.
Daniel Atallah <datallah@pidgin.im>
parents:
21936
diff
changeset
|
1003 | purple_debug_error("bonjour", "No buddies matched for ip %s.\n", bconv->ip); |
|
c41d17a1b8d9
This is the second part of the fix to support having multiple presence records in Bonjour (and also supporting multiple presences using the same IP). Incoming conversations are no longer immediately attached to a buddy - we use an algorithm to match a conversation to a buddy based on the IP and, if possible the "from" attribute of the stream or the first tag in the stream. Thanks to Sjoerd Simons from Telepahy Salut for noticing and suggesting the algorithm. Fixes #4187. It'd be good if a few people test this.
Daniel Atallah <datallah@pidgin.im>
parents:
21936
diff
changeset
|
1004 | |
|
c41d17a1b8d9
This is the second part of the fix to support having multiple presence records in Bonjour (and also supporting multiple presences using the same IP). Incoming conversations are no longer immediately attached to a buddy - we use an algorithm to match a conversation to a buddy based on the IP and, if possible the "from" attribute of the stream or the first tag in the stream. Thanks to Sjoerd Simons from Telepahy Salut for noticing and suggesting the algorithm. Fixes #4187. It'd be good if a few people test this.
Daniel Atallah <datallah@pidgin.im>
parents:
21936
diff
changeset
|
1005 | /* We've failed to match a buddy - give up */ |
|
c41d17a1b8d9
This is the second part of the fix to support having multiple presence records in Bonjour (and also supporting multiple presences using the same IP). Incoming conversations are no longer immediately attached to a buddy - we use an algorithm to match a conversation to a buddy based on the IP and, if possible the "from" attribute of the stream or the first tag in the stream. Thanks to Sjoerd Simons from Telepahy Salut for noticing and suggesting the algorithm. Fixes #4187. It'd be good if a few people test this.
Daniel Atallah <datallah@pidgin.im>
parents:
21936
diff
changeset
|
1006 | if (bconv->pb == NULL) { |
|
c41d17a1b8d9
This is the second part of the fix to support having multiple presence records in Bonjour (and also supporting multiple presences using the same IP). Incoming conversations are no longer immediately attached to a buddy - we use an algorithm to match a conversation to a buddy based on the IP and, if possible the "from" attribute of the stream or the first tag in the stream. Thanks to Sjoerd Simons from Telepahy Salut for noticing and suggesting the algorithm. Fixes #4187. It'd be good if a few people test this.
Daniel Atallah <datallah@pidgin.im>
parents:
21936
diff
changeset
|
1007 | /* This must be asynchronous because it destroys the parser and we |
|
c41d17a1b8d9
This is the second part of the fix to support having multiple presence records in Bonjour (and also supporting multiple presences using the same IP). Incoming conversations are no longer immediately attached to a buddy - we use an algorithm to match a conversation to a buddy based on the IP and, if possible the "from" attribute of the stream or the first tag in the stream. Thanks to Sjoerd Simons from Telepahy Salut for noticing and suggesting the algorithm. Fixes #4187. It'd be good if a few people test this.
Daniel Atallah <datallah@pidgin.im>
parents:
21936
diff
changeset
|
1008 | * may be in the middle of parsing. |
|
c41d17a1b8d9
This is the second part of the fix to support having multiple presence records in Bonjour (and also supporting multiple presences using the same IP). Incoming conversations are no longer immediately attached to a buddy - we use an algorithm to match a conversation to a buddy based on the IP and, if possible the "from" attribute of the stream or the first tag in the stream. Thanks to Sjoerd Simons from Telepahy Salut for noticing and suggesting the algorithm. Fixes #4187. It'd be good if a few people test this.
Daniel Atallah <datallah@pidgin.im>
parents:
21936
diff
changeset
|
1009 | */ |
|
c41d17a1b8d9
This is the second part of the fix to support having multiple presence records in Bonjour (and also supporting multiple presences using the same IP). Incoming conversations are no longer immediately attached to a buddy - we use an algorithm to match a conversation to a buddy based on the IP and, if possible the "from" attribute of the stream or the first tag in the stream. Thanks to Sjoerd Simons from Telepahy Salut for noticing and suggesting the algorithm. Fixes #4187. It'd be good if a few people test this.
Daniel Atallah <datallah@pidgin.im>
parents:
21936
diff
changeset
|
1010 | async_bonjour_jabber_close_conversation(bconv); |
|
c41d17a1b8d9
This is the second part of the fix to support having multiple presence records in Bonjour (and also supporting multiple presences using the same IP). Incoming conversations are no longer immediately attached to a buddy - we use an algorithm to match a conversation to a buddy based on the IP and, if possible the "from" attribute of the stream or the first tag in the stream. Thanks to Sjoerd Simons from Telepahy Salut for noticing and suggesting the algorithm. Fixes #4187. It'd be good if a few people test this.
Daniel Atallah <datallah@pidgin.im>
parents:
21936
diff
changeset
|
1011 | } |
|
c41d17a1b8d9
This is the second part of the fix to support having multiple presence records in Bonjour (and also supporting multiple presences using the same IP). Incoming conversations are no longer immediately attached to a buddy - we use an algorithm to match a conversation to a buddy based on the IP and, if possible the "from" attribute of the stream or the first tag in the stream. Thanks to Sjoerd Simons from Telepahy Salut for noticing and suggesting the algorithm. Fixes #4187. It'd be good if a few people test this.
Daniel Atallah <datallah@pidgin.im>
parents:
21936
diff
changeset
|
1012 | |
|
c41d17a1b8d9
This is the second part of the fix to support having multiple presence records in Bonjour (and also supporting multiple presences using the same IP). Incoming conversations are no longer immediately attached to a buddy - we use an algorithm to match a conversation to a buddy based on the IP and, if possible the "from" attribute of the stream or the first tag in the stream. Thanks to Sjoerd Simons from Telepahy Salut for noticing and suggesting the algorithm. Fixes #4187. It'd be good if a few people test this.
Daniel Atallah <datallah@pidgin.im>
parents:
21936
diff
changeset
|
1013 | g_slist_free(mbba->matched_buddies); |
|
c41d17a1b8d9
This is the second part of the fix to support having multiple presence records in Bonjour (and also supporting multiple presences using the same IP). Incoming conversations are no longer immediately attached to a buddy - we use an algorithm to match a conversation to a buddy based on the IP and, if possible the "from" attribute of the stream or the first tag in the stream. Thanks to Sjoerd Simons from Telepahy Salut for noticing and suggesting the algorithm. Fixes #4187. It'd be good if a few people test this.
Daniel Atallah <datallah@pidgin.im>
parents:
21936
diff
changeset
|
1014 | g_free(mbba); |
|
17665
26bff2090889
Update Bonjour to do nonblocking I/O correctly.
Daniel Atallah <datallah@pidgin.im>
parents:
17663
diff
changeset
|
1015 | } |
|
26bff2090889
Update Bonjour to do nonblocking I/O correctly.
Daniel Atallah <datallah@pidgin.im>
parents:
17663
diff
changeset
|
1016 | |
|
21528
06532211eb62
Leak fix, cleanup and code reuse.
Daniel Atallah <datallah@pidgin.im>
parents:
21527
diff
changeset
|
1017 | static PurpleBuddy * |
|
21944
c41d17a1b8d9
This is the second part of the fix to support having multiple presence records in Bonjour (and also supporting multiple presences using the same IP). Incoming conversations are no longer immediately attached to a buddy - we use an algorithm to match a conversation to a buddy based on the IP and, if possible the "from" attribute of the stream or the first tag in the stream. Thanks to Sjoerd Simons from Telepahy Salut for noticing and suggesting the algorithm. Fixes #4187. It'd be good if a few people test this.
Daniel Atallah <datallah@pidgin.im>
parents:
21936
diff
changeset
|
1018 | _find_or_start_conversation(BonjourJabber *jdata, const gchar *to) |
| 11477 | 1019 | { |
|
21528
06532211eb62
Leak fix, cleanup and code reuse.
Daniel Atallah <datallah@pidgin.im>
parents:
21527
diff
changeset
|
1020 | PurpleBuddy *pb = NULL; |
|
06532211eb62
Leak fix, cleanup and code reuse.
Daniel Atallah <datallah@pidgin.im>
parents:
21527
diff
changeset
|
1021 | BonjourBuddy *bb = NULL; |
|
06532211eb62
Leak fix, cleanup and code reuse.
Daniel Atallah <datallah@pidgin.im>
parents:
21527
diff
changeset
|
1022 | |
|
21944
c41d17a1b8d9
This is the second part of the fix to support having multiple presence records in Bonjour (and also supporting multiple presences using the same IP). Incoming conversations are no longer immediately attached to a buddy - we use an algorithm to match a conversation to a buddy based on the IP and, if possible the "from" attribute of the stream or the first tag in the stream. Thanks to Sjoerd Simons from Telepahy Salut for noticing and suggesting the algorithm. Fixes #4187. It'd be good if a few people test this.
Daniel Atallah <datallah@pidgin.im>
parents:
21936
diff
changeset
|
1023 | g_return_val_if_fail(jdata != NULL, NULL); |
|
21528
06532211eb62
Leak fix, cleanup and code reuse.
Daniel Atallah <datallah@pidgin.im>
parents:
21527
diff
changeset
|
1024 | g_return_val_if_fail(to != NULL, NULL); |
|
11539
fbabe3f89777
[gaim-migrate @ 13794]
Mark Doliner <markdoliner@pidgin.im>
parents:
11515
diff
changeset
|
1025 | |
|
34728
8efd73063ecf
Renamed buddy list functions to more appropriate/simler names.
Ankit Vani <a@nevitus.org>
parents:
34706
diff
changeset
|
1026 | pb = purple_blist_find_buddy(jdata->account, to); |
|
24938
fc6952107e1f
Finished moving to api for bonjour
Gary Kramlich <grim@reaperworld.com>
parents:
24562
diff
changeset
|
1027 | if (pb == NULL || (bb = purple_buddy_get_protocol_data(pb)) == NULL) |
|
11693
1a42a66ca0f8
[gaim-migrate @ 13979]
Mark Doliner <markdoliner@pidgin.im>
parents:
11688
diff
changeset
|
1028 | /* You can not send a message to an offline buddy */ |
|
21528
06532211eb62
Leak fix, cleanup and code reuse.
Daniel Atallah <datallah@pidgin.im>
parents:
21527
diff
changeset
|
1029 | return NULL; |
|
11693
1a42a66ca0f8
[gaim-migrate @ 13979]
Mark Doliner <markdoliner@pidgin.im>
parents:
11688
diff
changeset
|
1030 | |
|
17607
4d7a1c0f169b
Improve error handling while connecting to a bonjour buddy.
Daniel Atallah <datallah@pidgin.im>
parents:
17596
diff
changeset
|
1031 | /* Check if there is a previously open conversation */ |
|
4d7a1c0f169b
Improve error handling while connecting to a bonjour buddy.
Daniel Atallah <datallah@pidgin.im>
parents:
17596
diff
changeset
|
1032 | if (bb->conversation == NULL) |
|
4d7a1c0f169b
Improve error handling while connecting to a bonjour buddy.
Daniel Atallah <datallah@pidgin.im>
parents:
17596
diff
changeset
|
1033 | { |
|
17665
26bff2090889
Update Bonjour to do nonblocking I/O correctly.
Daniel Atallah <datallah@pidgin.im>
parents:
17663
diff
changeset
|
1034 | PurpleProxyConnectData *connect_data; |
|
17699
ece5beaecd19
More robust hack to force Bonjour to use no proxy when directly connecting to buddy.
Daniel Atallah <datallah@pidgin.im>
parents:
17665
diff
changeset
|
1035 | PurpleProxyInfo *proxy_info; |
|
31748
45c25b4868cb
bonjour: Recurse through user IP addresses instead of using the first one only
Simon van der Linden <simon@vanderlinden.eu.org>
parents:
30827
diff
changeset
|
1036 | const char *ip = bb->ips->data; /* Start with the first IP address. */ |
|
17665
26bff2090889
Update Bonjour to do nonblocking I/O correctly.
Daniel Atallah <datallah@pidgin.im>
parents:
17663
diff
changeset
|
1037 | |
|
31748
45c25b4868cb
bonjour: Recurse through user IP addresses instead of using the first one only
Simon van der Linden <simon@vanderlinden.eu.org>
parents:
30827
diff
changeset
|
1038 | purple_debug_info("bonjour", "Starting conversation with %s at %s:%d\n", to, ip, bb->port_p2pj); |
|
21528
06532211eb62
Leak fix, cleanup and code reuse.
Daniel Atallah <datallah@pidgin.im>
parents:
21527
diff
changeset
|
1039 | |
|
17665
26bff2090889
Update Bonjour to do nonblocking I/O correctly.
Daniel Atallah <datallah@pidgin.im>
parents:
17663
diff
changeset
|
1040 | /* Make sure that the account always has a proxy of "none". |
|
26bff2090889
Update Bonjour to do nonblocking I/O correctly.
Daniel Atallah <datallah@pidgin.im>
parents:
17663
diff
changeset
|
1041 | * This is kind of dirty, but proxy_connect_none() isn't exposed. */ |
|
21944
c41d17a1b8d9
This is the second part of the fix to support having multiple presence records in Bonjour (and also supporting multiple presences using the same IP). Incoming conversations are no longer immediately attached to a buddy - we use an algorithm to match a conversation to a buddy based on the IP and, if possible the "from" attribute of the stream or the first tag in the stream. Thanks to Sjoerd Simons from Telepahy Salut for noticing and suggesting the algorithm. Fixes #4187. It'd be good if a few people test this.
Daniel Atallah <datallah@pidgin.im>
parents:
21936
diff
changeset
|
1042 | proxy_info = purple_account_get_proxy_info(jdata->account); |
|
17699
ece5beaecd19
More robust hack to force Bonjour to use no proxy when directly connecting to buddy.
Daniel Atallah <datallah@pidgin.im>
parents:
17665
diff
changeset
|
1043 | if (proxy_info == NULL) { |
|
ece5beaecd19
More robust hack to force Bonjour to use no proxy when directly connecting to buddy.
Daniel Atallah <datallah@pidgin.im>
parents:
17665
diff
changeset
|
1044 | proxy_info = purple_proxy_info_new(); |
|
21944
c41d17a1b8d9
This is the second part of the fix to support having multiple presence records in Bonjour (and also supporting multiple presences using the same IP). Incoming conversations are no longer immediately attached to a buddy - we use an algorithm to match a conversation to a buddy based on the IP and, if possible the "from" attribute of the stream or the first tag in the stream. Thanks to Sjoerd Simons from Telepahy Salut for noticing and suggesting the algorithm. Fixes #4187. It'd be good if a few people test this.
Daniel Atallah <datallah@pidgin.im>
parents:
21936
diff
changeset
|
1045 | purple_account_set_proxy_info(jdata->account, proxy_info); |
|
17665
26bff2090889
Update Bonjour to do nonblocking I/O correctly.
Daniel Atallah <datallah@pidgin.im>
parents:
17663
diff
changeset
|
1046 | } |
|
35378
5d9e2581005b
gtk-doc prep: *_get_type() functions are hidden as standard GType-returning funcs, so rename them.
Ankit Vani <a@nevitus.org>
parents:
34999
diff
changeset
|
1047 | purple_proxy_info_set_proxy_type(proxy_info, PURPLE_PROXY_NONE); |
|
17665
26bff2090889
Update Bonjour to do nonblocking I/O correctly.
Daniel Atallah <datallah@pidgin.im>
parents:
17663
diff
changeset
|
1048 | |
|
27343
8a367ee70456
Pass the gc as the handle in a bunch of calls to purple_proxy_connect
Mark Doliner <markdoliner@pidgin.im>
parents:
26990
diff
changeset
|
1049 | connect_data = purple_proxy_connect( |
|
8a367ee70456
Pass the gc as the handle in a bunch of calls to purple_proxy_connect
Mark Doliner <markdoliner@pidgin.im>
parents:
26990
diff
changeset
|
1050 | purple_account_get_connection(jdata->account), |
|
8a367ee70456
Pass the gc as the handle in a bunch of calls to purple_proxy_connect
Mark Doliner <markdoliner@pidgin.im>
parents:
26990
diff
changeset
|
1051 | jdata->account, |
|
21920
3087a567aedf
Update Bonjour prpl to support multiple presence records for the same buddy. Eliminate the Howl backend to avoid having to maintain yet another set of code. References #4187 (more to come to fix the rest of the ticket).
Daniel Atallah <datallah@pidgin.im>
parents:
21917
diff
changeset
|
1052 | ip, bb->port_p2pj, _connected_to_buddy, pb); |
|
17665
26bff2090889
Update Bonjour to do nonblocking I/O correctly.
Daniel Atallah <datallah@pidgin.im>
parents:
17663
diff
changeset
|
1053 | |
|
26bff2090889
Update Bonjour to do nonblocking I/O correctly.
Daniel Atallah <datallah@pidgin.im>
parents:
17663
diff
changeset
|
1054 | if (connect_data == NULL) { |
|
26bff2090889
Update Bonjour to do nonblocking I/O correctly.
Daniel Atallah <datallah@pidgin.im>
parents:
17663
diff
changeset
|
1055 | purple_debug_error("bonjour", "Unable to connect to buddy (%s).\n", to); |
|
21528
06532211eb62
Leak fix, cleanup and code reuse.
Daniel Atallah <datallah@pidgin.im>
parents:
21527
diff
changeset
|
1056 | return NULL; |
|
17665
26bff2090889
Update Bonjour to do nonblocking I/O correctly.
Daniel Atallah <datallah@pidgin.im>
parents:
17663
diff
changeset
|
1057 | } |
|
17607
4d7a1c0f169b
Improve error handling while connecting to a bonjour buddy.
Daniel Atallah <datallah@pidgin.im>
parents:
17596
diff
changeset
|
1058 | |
|
21944
c41d17a1b8d9
This is the second part of the fix to support having multiple presence records in Bonjour (and also supporting multiple presences using the same IP). Incoming conversations are no longer immediately attached to a buddy - we use an algorithm to match a conversation to a buddy based on the IP and, if possible the "from" attribute of the stream or the first tag in the stream. Thanks to Sjoerd Simons from Telepahy Salut for noticing and suggesting the algorithm. Fixes #4187. It'd be good if a few people test this.
Daniel Atallah <datallah@pidgin.im>
parents:
21936
diff
changeset
|
1059 | bb->conversation = bonjour_jabber_conv_new(pb, jdata->account, ip); |
|
17665
26bff2090889
Update Bonjour to do nonblocking I/O correctly.
Daniel Atallah <datallah@pidgin.im>
parents:
17663
diff
changeset
|
1060 | bb->conversation->connect_data = connect_data; |
|
31749
710d5d207306
bonjour: Update to 427f3622bbeb4 to match the last used IP more reliably.
Daniel Atallah <datallah@pidgin.im>
parents:
31748
diff
changeset
|
1061 | bb->conversation->ip_link = ip; |
|
17665
26bff2090889
Update Bonjour to do nonblocking I/O correctly.
Daniel Atallah <datallah@pidgin.im>
parents:
17663
diff
changeset
|
1062 | /* We don't want _send_data() to register the tx_handler; |
|
26bff2090889
Update Bonjour to do nonblocking I/O correctly.
Daniel Atallah <datallah@pidgin.im>
parents:
17663
diff
changeset
|
1063 | * that neeeds to wait until we're actually connected. */ |
|
26bff2090889
Update Bonjour to do nonblocking I/O correctly.
Daniel Atallah <datallah@pidgin.im>
parents:
17663
diff
changeset
|
1064 | bb->conversation->tx_handler = 0; |
|
17607
4d7a1c0f169b
Improve error handling while connecting to a bonjour buddy.
Daniel Atallah <datallah@pidgin.im>
parents:
17596
diff
changeset
|
1065 | } |
|
21528
06532211eb62
Leak fix, cleanup and code reuse.
Daniel Atallah <datallah@pidgin.im>
parents:
21527
diff
changeset
|
1066 | return pb; |
|
06532211eb62
Leak fix, cleanup and code reuse.
Daniel Atallah <datallah@pidgin.im>
parents:
21527
diff
changeset
|
1067 | } |
|
06532211eb62
Leak fix, cleanup and code reuse.
Daniel Atallah <datallah@pidgin.im>
parents:
21527
diff
changeset
|
1068 | |
|
06532211eb62
Leak fix, cleanup and code reuse.
Daniel Atallah <datallah@pidgin.im>
parents:
21527
diff
changeset
|
1069 | int |
|
21944
c41d17a1b8d9
This is the second part of the fix to support having multiple presence records in Bonjour (and also supporting multiple presences using the same IP). Incoming conversations are no longer immediately attached to a buddy - we use an algorithm to match a conversation to a buddy based on the IP and, if possible the "from" attribute of the stream or the first tag in the stream. Thanks to Sjoerd Simons from Telepahy Salut for noticing and suggesting the algorithm. Fixes #4187. It'd be good if a few people test this.
Daniel Atallah <datallah@pidgin.im>
parents:
21936
diff
changeset
|
1070 | bonjour_jabber_send_message(BonjourJabber *jdata, const gchar *to, const gchar *body) |
|
21528
06532211eb62
Leak fix, cleanup and code reuse.
Daniel Atallah <datallah@pidgin.im>
parents:
21527
diff
changeset
|
1071 | { |
|
34935
686fa55b0deb
Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents:
34911
diff
changeset
|
1072 | PurpleXmlNode *message_node, *node, *node2; |
|
24333
9f23bb1c02c9
Looks like we need to convert the message into XHTML first. Fixes #7160.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
24196
diff
changeset
|
1073 | gchar *message, *xhtml; |
|
21528
06532211eb62
Leak fix, cleanup and code reuse.
Daniel Atallah <datallah@pidgin.im>
parents:
21527
diff
changeset
|
1074 | PurpleBuddy *pb; |
|
06532211eb62
Leak fix, cleanup and code reuse.
Daniel Atallah <datallah@pidgin.im>
parents:
21527
diff
changeset
|
1075 | BonjourBuddy *bb; |
|
06532211eb62
Leak fix, cleanup and code reuse.
Daniel Atallah <datallah@pidgin.im>
parents:
21527
diff
changeset
|
1076 | int ret; |
|
06532211eb62
Leak fix, cleanup and code reuse.
Daniel Atallah <datallah@pidgin.im>
parents:
21527
diff
changeset
|
1077 | |
|
21944
c41d17a1b8d9
This is the second part of the fix to support having multiple presence records in Bonjour (and also supporting multiple presences using the same IP). Incoming conversations are no longer immediately attached to a buddy - we use an algorithm to match a conversation to a buddy based on the IP and, if possible the "from" attribute of the stream or the first tag in the stream. Thanks to Sjoerd Simons from Telepahy Salut for noticing and suggesting the algorithm. Fixes #4187. It'd be good if a few people test this.
Daniel Atallah <datallah@pidgin.im>
parents:
21936
diff
changeset
|
1078 | pb = _find_or_start_conversation(jdata, to); |
|
24938
fc6952107e1f
Finished moving to api for bonjour
Gary Kramlich <grim@reaperworld.com>
parents:
24562
diff
changeset
|
1079 | if (pb == NULL || (bb = purple_buddy_get_protocol_data(pb)) == NULL) { |
|
21528
06532211eb62
Leak fix, cleanup and code reuse.
Daniel Atallah <datallah@pidgin.im>
parents:
21527
diff
changeset
|
1080 | purple_debug_info("bonjour", "Can't send a message to an offline buddy (%s).\n", to); |
|
06532211eb62
Leak fix, cleanup and code reuse.
Daniel Atallah <datallah@pidgin.im>
parents:
21527
diff
changeset
|
1081 | /* You can not send a message to an offline buddy */ |
|
06532211eb62
Leak fix, cleanup and code reuse.
Daniel Atallah <datallah@pidgin.im>
parents:
21527
diff
changeset
|
1082 | return -10000; |
|
06532211eb62
Leak fix, cleanup and code reuse.
Daniel Atallah <datallah@pidgin.im>
parents:
21527
diff
changeset
|
1083 | } |
|
06532211eb62
Leak fix, cleanup and code reuse.
Daniel Atallah <datallah@pidgin.im>
parents:
21527
diff
changeset
|
1084 | |
|
24333
9f23bb1c02c9
Looks like we need to convert the message into XHTML first. Fixes #7160.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
24196
diff
changeset
|
1085 | purple_markup_html_to_xhtml(body, &xhtml, &message); |
|
9f23bb1c02c9
Looks like we need to convert the message into XHTML first. Fixes #7160.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
24196
diff
changeset
|
1086 | |
|
34935
686fa55b0deb
Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents:
34911
diff
changeset
|
1087 | message_node = purple_xmlnode_new("message"); |
|
686fa55b0deb
Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents:
34911
diff
changeset
|
1088 | purple_xmlnode_set_attrib(message_node, "to", bb->name); |
|
686fa55b0deb
Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents:
34911
diff
changeset
|
1089 | purple_xmlnode_set_attrib(message_node, "from", bonjour_get_jid(jdata->account)); |
|
686fa55b0deb
Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents:
34911
diff
changeset
|
1090 | purple_xmlnode_set_attrib(message_node, "type", "chat"); |
|
17660
23c712d0a795
Cleanup, fix a leak and prevent the inbound xml from being parsed twice for every message.
Daniel Atallah <datallah@pidgin.im>
parents:
17633
diff
changeset
|
1091 | |
|
11826
10ebbc41f163
[gaim-migrate @ 14117]
Richard Laager <rlaager@pidgin.im>
parents:
11823
diff
changeset
|
1092 | /* Enclose the message from the UI within a "font" node */ |
|
34935
686fa55b0deb
Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents:
34911
diff
changeset
|
1093 | node = purple_xmlnode_new_child(message_node, "body"); |
|
686fa55b0deb
Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents:
34911
diff
changeset
|
1094 | purple_xmlnode_insert_data(node, message, strlen(message)); |
|
17660
23c712d0a795
Cleanup, fix a leak and prevent the inbound xml from being parsed twice for every message.
Daniel Atallah <datallah@pidgin.im>
parents:
17633
diff
changeset
|
1095 | g_free(message); |
|
11539
fbabe3f89777
[gaim-migrate @ 13794]
Mark Doliner <markdoliner@pidgin.im>
parents:
11515
diff
changeset
|
1096 | |
|
34935
686fa55b0deb
Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents:
34911
diff
changeset
|
1097 | node = purple_xmlnode_new_child(message_node, "html"); |
|
686fa55b0deb
Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents:
34911
diff
changeset
|
1098 | purple_xmlnode_set_namespace(node, "http://www.w3.org/1999/xhtml"); |
|
11539
fbabe3f89777
[gaim-migrate @ 13794]
Mark Doliner <markdoliner@pidgin.im>
parents:
11515
diff
changeset
|
1099 | |
|
34935
686fa55b0deb
Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents:
34911
diff
changeset
|
1100 | node = purple_xmlnode_new_child(node, "body"); |
|
24333
9f23bb1c02c9
Looks like we need to convert the message into XHTML first. Fixes #7160.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
24196
diff
changeset
|
1101 | message = g_strdup_printf("<font>%s</font>", xhtml); |
|
34935
686fa55b0deb
Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents:
34911
diff
changeset
|
1102 | node2 = purple_xmlnode_from_str(message, strlen(message)); |
|
24333
9f23bb1c02c9
Looks like we need to convert the message into XHTML first. Fixes #7160.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
24196
diff
changeset
|
1103 | g_free(xhtml); |
|
17660
23c712d0a795
Cleanup, fix a leak and prevent the inbound xml from being parsed twice for every message.
Daniel Atallah <datallah@pidgin.im>
parents:
17633
diff
changeset
|
1104 | g_free(message); |
|
34935
686fa55b0deb
Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents:
34911
diff
changeset
|
1105 | purple_xmlnode_insert_child(node, node2); |
|
11539
fbabe3f89777
[gaim-migrate @ 13794]
Mark Doliner <markdoliner@pidgin.im>
parents:
11515
diff
changeset
|
1106 | |
|
34935
686fa55b0deb
Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents:
34911
diff
changeset
|
1107 | node = purple_xmlnode_new_child(message_node, "x"); |
|
686fa55b0deb
Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents:
34911
diff
changeset
|
1108 | purple_xmlnode_set_namespace(node, "jabber:x:event"); |
|
686fa55b0deb
Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents:
34911
diff
changeset
|
1109 | purple_xmlnode_insert_child(node, purple_xmlnode_new("composing")); |
|
11539
fbabe3f89777
[gaim-migrate @ 13794]
Mark Doliner <markdoliner@pidgin.im>
parents:
11515
diff
changeset
|
1110 | |
|
34935
686fa55b0deb
Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents:
34911
diff
changeset
|
1111 | message = purple_xmlnode_to_str(message_node, NULL); |
|
686fa55b0deb
Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents:
34911
diff
changeset
|
1112 | purple_xmlnode_free(message_node); |
| 11477 | 1113 | |
|
17665
26bff2090889
Update Bonjour to do nonblocking I/O correctly.
Daniel Atallah <datallah@pidgin.im>
parents:
17663
diff
changeset
|
1114 | ret = _send_data(pb, message) >= 0; |
|
17660
23c712d0a795
Cleanup, fix a leak and prevent the inbound xml from being parsed twice for every message.
Daniel Atallah <datallah@pidgin.im>
parents:
17633
diff
changeset
|
1115 | |
|
15873
78d3aa0fb61e
plug some memory leaks
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
15435
diff
changeset
|
1116 | g_free(message); |
|
78d3aa0fb61e
plug some memory leaks
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
15435
diff
changeset
|
1117 | |
|
17665
26bff2090889
Update Bonjour to do nonblocking I/O correctly.
Daniel Atallah <datallah@pidgin.im>
parents:
17663
diff
changeset
|
1118 | return ret; |
| 11477 | 1119 | } |
| 1120 | ||
|
21944
c41d17a1b8d9
This is the second part of the fix to support having multiple presence records in Bonjour (and also supporting multiple presences using the same IP). Incoming conversations are no longer immediately attached to a buddy - we use an algorithm to match a conversation to a buddy based on the IP and, if possible the "from" attribute of the stream or the first tag in the stream. Thanks to Sjoerd Simons from Telepahy Salut for noticing and suggesting the algorithm. Fixes #4187. It'd be good if a few people test this.
Daniel Atallah <datallah@pidgin.im>
parents:
21936
diff
changeset
|
1121 | static gboolean |
|
c41d17a1b8d9
This is the second part of the fix to support having multiple presence records in Bonjour (and also supporting multiple presences using the same IP). Incoming conversations are no longer immediately attached to a buddy - we use an algorithm to match a conversation to a buddy based on the IP and, if possible the "from" attribute of the stream or the first tag in the stream. Thanks to Sjoerd Simons from Telepahy Salut for noticing and suggesting the algorithm. Fixes #4187. It'd be good if a few people test this.
Daniel Atallah <datallah@pidgin.im>
parents:
21936
diff
changeset
|
1122 | _async_bonjour_jabber_close_conversation_cb(gpointer data) { |
|
c41d17a1b8d9
This is the second part of the fix to support having multiple presence records in Bonjour (and also supporting multiple presences using the same IP). Incoming conversations are no longer immediately attached to a buddy - we use an algorithm to match a conversation to a buddy based on the IP and, if possible the "from" attribute of the stream or the first tag in the stream. Thanks to Sjoerd Simons from Telepahy Salut for noticing and suggesting the algorithm. Fixes #4187. It'd be good if a few people test this.
Daniel Atallah <datallah@pidgin.im>
parents:
21936
diff
changeset
|
1123 | BonjourJabberConversation *bconv = data; |
|
c41d17a1b8d9
This is the second part of the fix to support having multiple presence records in Bonjour (and also supporting multiple presences using the same IP). Incoming conversations are no longer immediately attached to a buddy - we use an algorithm to match a conversation to a buddy based on the IP and, if possible the "from" attribute of the stream or the first tag in the stream. Thanks to Sjoerd Simons from Telepahy Salut for noticing and suggesting the algorithm. Fixes #4187. It'd be good if a few people test this.
Daniel Atallah <datallah@pidgin.im>
parents:
21936
diff
changeset
|
1124 | bonjour_jabber_close_conversation(bconv); |
|
c41d17a1b8d9
This is the second part of the fix to support having multiple presence records in Bonjour (and also supporting multiple presences using the same IP). Incoming conversations are no longer immediately attached to a buddy - we use an algorithm to match a conversation to a buddy based on the IP and, if possible the "from" attribute of the stream or the first tag in the stream. Thanks to Sjoerd Simons from Telepahy Salut for noticing and suggesting the algorithm. Fixes #4187. It'd be good if a few people test this.
Daniel Atallah <datallah@pidgin.im>
parents:
21936
diff
changeset
|
1125 | return FALSE; |
|
c41d17a1b8d9
This is the second part of the fix to support having multiple presence records in Bonjour (and also supporting multiple presences using the same IP). Incoming conversations are no longer immediately attached to a buddy - we use an algorithm to match a conversation to a buddy based on the IP and, if possible the "from" attribute of the stream or the first tag in the stream. Thanks to Sjoerd Simons from Telepahy Salut for noticing and suggesting the algorithm. Fixes #4187. It'd be good if a few people test this.
Daniel Atallah <datallah@pidgin.im>
parents:
21936
diff
changeset
|
1126 | } |
|
c41d17a1b8d9
This is the second part of the fix to support having multiple presence records in Bonjour (and also supporting multiple presences using the same IP). Incoming conversations are no longer immediately attached to a buddy - we use an algorithm to match a conversation to a buddy based on the IP and, if possible the "from" attribute of the stream or the first tag in the stream. Thanks to Sjoerd Simons from Telepahy Salut for noticing and suggesting the algorithm. Fixes #4187. It'd be good if a few people test this.
Daniel Atallah <datallah@pidgin.im>
parents:
21936
diff
changeset
|
1127 | |
|
c41d17a1b8d9
This is the second part of the fix to support having multiple presence records in Bonjour (and also supporting multiple presences using the same IP). Incoming conversations are no longer immediately attached to a buddy - we use an algorithm to match a conversation to a buddy based on the IP and, if possible the "from" attribute of the stream or the first tag in the stream. Thanks to Sjoerd Simons from Telepahy Salut for noticing and suggesting the algorithm. Fixes #4187. It'd be good if a few people test this.
Daniel Atallah <datallah@pidgin.im>
parents:
21936
diff
changeset
|
1128 | void |
|
c41d17a1b8d9
This is the second part of the fix to support having multiple presence records in Bonjour (and also supporting multiple presences using the same IP). Incoming conversations are no longer immediately attached to a buddy - we use an algorithm to match a conversation to a buddy based on the IP and, if possible the "from" attribute of the stream or the first tag in the stream. Thanks to Sjoerd Simons from Telepahy Salut for noticing and suggesting the algorithm. Fixes #4187. It'd be good if a few people test this.
Daniel Atallah <datallah@pidgin.im>
parents:
21936
diff
changeset
|
1129 | async_bonjour_jabber_close_conversation(BonjourJabberConversation *bconv) { |
|
32215
0a4e72c8a67e
Use accessor functions in a few places
Mark Doliner <markdoliner@pidgin.im>
parents:
31749
diff
changeset
|
1130 | PurpleConnection *pc = purple_account_get_connection(bconv->account); |
|
32260
5b0ecccb3bbb
Convert bonjour prpl to use accessor functions purple_connection_get_protocol_data() and purple_connection_set_protocol_data().
Andrew Victor <andrew.victor@mxit.com>
parents:
32215
diff
changeset
|
1131 | BonjourData *bd = purple_connection_get_protocol_data(pc); |
|
5b0ecccb3bbb
Convert bonjour prpl to use accessor functions purple_connection_get_protocol_data() and purple_connection_set_protocol_data().
Andrew Victor <andrew.victor@mxit.com>
parents:
32215
diff
changeset
|
1132 | BonjourJabber *jdata = bd->jabber_data; |
|
21944
c41d17a1b8d9
This is the second part of the fix to support having multiple presence records in Bonjour (and also supporting multiple presences using the same IP). Incoming conversations are no longer immediately attached to a buddy - we use an algorithm to match a conversation to a buddy based on the IP and, if possible the "from" attribute of the stream or the first tag in the stream. Thanks to Sjoerd Simons from Telepahy Salut for noticing and suggesting the algorithm. Fixes #4187. It'd be good if a few people test this.
Daniel Atallah <datallah@pidgin.im>
parents:
21936
diff
changeset
|
1133 | |
|
c41d17a1b8d9
This is the second part of the fix to support having multiple presence records in Bonjour (and also supporting multiple presences using the same IP). Incoming conversations are no longer immediately attached to a buddy - we use an algorithm to match a conversation to a buddy based on the IP and, if possible the "from" attribute of the stream or the first tag in the stream. Thanks to Sjoerd Simons from Telepahy Salut for noticing and suggesting the algorithm. Fixes #4187. It'd be good if a few people test this.
Daniel Atallah <datallah@pidgin.im>
parents:
21936
diff
changeset
|
1134 | jdata->pending_conversations = g_slist_remove(jdata->pending_conversations, bconv); |
|
c41d17a1b8d9
This is the second part of the fix to support having multiple presence records in Bonjour (and also supporting multiple presences using the same IP). Incoming conversations are no longer immediately attached to a buddy - we use an algorithm to match a conversation to a buddy based on the IP and, if possible the "from" attribute of the stream or the first tag in the stream. Thanks to Sjoerd Simons from Telepahy Salut for noticing and suggesting the algorithm. Fixes #4187. It'd be good if a few people test this.
Daniel Atallah <datallah@pidgin.im>
parents:
21936
diff
changeset
|
1135 | |
|
c41d17a1b8d9
This is the second part of the fix to support having multiple presence records in Bonjour (and also supporting multiple presences using the same IP). Incoming conversations are no longer immediately attached to a buddy - we use an algorithm to match a conversation to a buddy based on the IP and, if possible the "from" attribute of the stream or the first tag in the stream. Thanks to Sjoerd Simons from Telepahy Salut for noticing and suggesting the algorithm. Fixes #4187. It'd be good if a few people test this.
Daniel Atallah <datallah@pidgin.im>
parents:
21936
diff
changeset
|
1136 | /* Disconnect this conv. from the buddy here so it can't be disposed of twice.*/ |
|
c41d17a1b8d9
This is the second part of the fix to support having multiple presence records in Bonjour (and also supporting multiple presences using the same IP). Incoming conversations are no longer immediately attached to a buddy - we use an algorithm to match a conversation to a buddy based on the IP and, if possible the "from" attribute of the stream or the first tag in the stream. Thanks to Sjoerd Simons from Telepahy Salut for noticing and suggesting the algorithm. Fixes #4187. It'd be good if a few people test this.
Daniel Atallah <datallah@pidgin.im>
parents:
21936
diff
changeset
|
1137 | if(bconv->pb != NULL) { |
|
24938
fc6952107e1f
Finished moving to api for bonjour
Gary Kramlich <grim@reaperworld.com>
parents:
24562
diff
changeset
|
1138 | BonjourBuddy *bb = purple_buddy_get_protocol_data(bconv->pb); |
|
21944
c41d17a1b8d9
This is the second part of the fix to support having multiple presence records in Bonjour (and also supporting multiple presences using the same IP). Incoming conversations are no longer immediately attached to a buddy - we use an algorithm to match a conversation to a buddy based on the IP and, if possible the "from" attribute of the stream or the first tag in the stream. Thanks to Sjoerd Simons from Telepahy Salut for noticing and suggesting the algorithm. Fixes #4187. It'd be good if a few people test this.
Daniel Atallah <datallah@pidgin.im>
parents:
21936
diff
changeset
|
1139 | if (bb->conversation == bconv) |
|
c41d17a1b8d9
This is the second part of the fix to support having multiple presence records in Bonjour (and also supporting multiple presences using the same IP). Incoming conversations are no longer immediately attached to a buddy - we use an algorithm to match a conversation to a buddy based on the IP and, if possible the "from" attribute of the stream or the first tag in the stream. Thanks to Sjoerd Simons from Telepahy Salut for noticing and suggesting the algorithm. Fixes #4187. It'd be good if a few people test this.
Daniel Atallah <datallah@pidgin.im>
parents:
21936
diff
changeset
|
1140 | bb->conversation = NULL; |
|
c41d17a1b8d9
This is the second part of the fix to support having multiple presence records in Bonjour (and also supporting multiple presences using the same IP). Incoming conversations are no longer immediately attached to a buddy - we use an algorithm to match a conversation to a buddy based on the IP and, if possible the "from" attribute of the stream or the first tag in the stream. Thanks to Sjoerd Simons from Telepahy Salut for noticing and suggesting the algorithm. Fixes #4187. It'd be good if a few people test this.
Daniel Atallah <datallah@pidgin.im>
parents:
21936
diff
changeset
|
1141 | } |
|
c41d17a1b8d9
This is the second part of the fix to support having multiple presence records in Bonjour (and also supporting multiple presences using the same IP). Incoming conversations are no longer immediately attached to a buddy - we use an algorithm to match a conversation to a buddy based on the IP and, if possible the "from" attribute of the stream or the first tag in the stream. Thanks to Sjoerd Simons from Telepahy Salut for noticing and suggesting the algorithm. Fixes #4187. It'd be good if a few people test this.
Daniel Atallah <datallah@pidgin.im>
parents:
21936
diff
changeset
|
1142 | |
|
22238
c69aff70828d
Prevent a crash caused by freed memory being accessed.
Daniel Atallah <datallah@pidgin.im>
parents:
21944
diff
changeset
|
1143 | bconv->close_timeout = purple_timeout_add(0, _async_bonjour_jabber_close_conversation_cb, bconv); |
|
21944
c41d17a1b8d9
This is the second part of the fix to support having multiple presence records in Bonjour (and also supporting multiple presences using the same IP). Incoming conversations are no longer immediately attached to a buddy - we use an algorithm to match a conversation to a buddy based on the IP and, if possible the "from" attribute of the stream or the first tag in the stream. Thanks to Sjoerd Simons from Telepahy Salut for noticing and suggesting the algorithm. Fixes #4187. It'd be good if a few people test this.
Daniel Atallah <datallah@pidgin.im>
parents:
21936
diff
changeset
|
1144 | } |
|
c41d17a1b8d9
This is the second part of the fix to support having multiple presence records in Bonjour (and also supporting multiple presences using the same IP). Incoming conversations are no longer immediately attached to a buddy - we use an algorithm to match a conversation to a buddy based on the IP and, if possible the "from" attribute of the stream or the first tag in the stream. Thanks to Sjoerd Simons from Telepahy Salut for noticing and suggesting the algorithm. Fixes #4187. It'd be good if a few people test this.
Daniel Atallah <datallah@pidgin.im>
parents:
21936
diff
changeset
|
1145 | |
|
11539
fbabe3f89777
[gaim-migrate @ 13794]
Mark Doliner <markdoliner@pidgin.im>
parents:
11515
diff
changeset
|
1146 | void |
|
17663
fd736a4d91a9
Close conversation connections when logging out of the Bonjour account. This also fixes leakage.
Daniel Atallah <datallah@pidgin.im>
parents:
17662
diff
changeset
|
1147 | bonjour_jabber_close_conversation(BonjourJabberConversation *bconv) |
| 11477 | 1148 | { |
|
21609
30ca7a909e62
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.
Daniel Atallah <datallah@pidgin.im>
parents:
21549
diff
changeset
|
1149 | if (bconv != NULL) { |
|
21944
c41d17a1b8d9
This is the second part of the fix to support having multiple presence records in Bonjour (and also supporting multiple presences using the same IP). Incoming conversations are no longer immediately attached to a buddy - we use an algorithm to match a conversation to a buddy based on the IP and, if possible the "from" attribute of the stream or the first tag in the stream. Thanks to Sjoerd Simons from Telepahy Salut for noticing and suggesting the algorithm. Fixes #4187. It'd be good if a few people test this.
Daniel Atallah <datallah@pidgin.im>
parents:
21936
diff
changeset
|
1150 | BonjourData *bd = NULL; |
|
c41d17a1b8d9
This is the second part of the fix to support having multiple presence records in Bonjour (and also supporting multiple presences using the same IP). Incoming conversations are no longer immediately attached to a buddy - we use an algorithm to match a conversation to a buddy based on the IP and, if possible the "from" attribute of the stream or the first tag in the stream. Thanks to Sjoerd Simons from Telepahy Salut for noticing and suggesting the algorithm. Fixes #4187. It'd be good if a few people test this.
Daniel Atallah <datallah@pidgin.im>
parents:
21936
diff
changeset
|
1151 | |
|
32215
0a4e72c8a67e
Use accessor functions in a few places
Mark Doliner <markdoliner@pidgin.im>
parents:
31749
diff
changeset
|
1152 | PurpleConnection *pc = purple_account_get_connection(bconv->account); |
|
34999
90850ff4b5eb
Backed out changeset 348356cbc657
Ankit Vani <a@nevitus.org>
parents:
34989
diff
changeset
|
1153 | if (PURPLE_CONNECTION_IS_VALID(pc)) { |
|
32260
5b0ecccb3bbb
Convert bonjour prpl to use accessor functions purple_connection_get_protocol_data() and purple_connection_set_protocol_data().
Andrew Victor <andrew.victor@mxit.com>
parents:
32215
diff
changeset
|
1154 | bd = purple_connection_get_protocol_data(pc); |
|
21944
c41d17a1b8d9
This is the second part of the fix to support having multiple presence records in Bonjour (and also supporting multiple presences using the same IP). Incoming conversations are no longer immediately attached to a buddy - we use an algorithm to match a conversation to a buddy based on the IP and, if possible the "from" attribute of the stream or the first tag in the stream. Thanks to Sjoerd Simons from Telepahy Salut for noticing and suggesting the algorithm. Fixes #4187. It'd be good if a few people test this.
Daniel Atallah <datallah@pidgin.im>
parents:
21936
diff
changeset
|
1155 | bd->jabber_data->pending_conversations = g_slist_remove(bd->jabber_data->pending_conversations, bconv); |
|
c41d17a1b8d9
This is the second part of the fix to support having multiple presence records in Bonjour (and also supporting multiple presences using the same IP). Incoming conversations are no longer immediately attached to a buddy - we use an algorithm to match a conversation to a buddy based on the IP and, if possible the "from" attribute of the stream or the first tag in the stream. Thanks to Sjoerd Simons from Telepahy Salut for noticing and suggesting the algorithm. Fixes #4187. It'd be good if a few people test this.
Daniel Atallah <datallah@pidgin.im>
parents:
21936
diff
changeset
|
1156 | } |
|
21609
30ca7a909e62
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.
Daniel Atallah <datallah@pidgin.im>
parents:
21549
diff
changeset
|
1157 | |
|
30ca7a909e62
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.
Daniel Atallah <datallah@pidgin.im>
parents:
21549
diff
changeset
|
1158 | /* Cancel any file transfers that are waiting to begin */ |
|
21944
c41d17a1b8d9
This is the second part of the fix to support having multiple presence records in Bonjour (and also supporting multiple presences using the same IP). Incoming conversations are no longer immediately attached to a buddy - we use an algorithm to match a conversation to a buddy based on the IP and, if possible the "from" attribute of the stream or the first tag in the stream. Thanks to Sjoerd Simons from Telepahy Salut for noticing and suggesting the algorithm. Fixes #4187. It'd be good if a few people test this.
Daniel Atallah <datallah@pidgin.im>
parents:
21936
diff
changeset
|
1159 | /* There wont be any transfers if it hasn't been attached to a buddy */ |
|
c41d17a1b8d9
This is the second part of the fix to support having multiple presence records in Bonjour (and also supporting multiple presences using the same IP). Incoming conversations are no longer immediately attached to a buddy - we use an algorithm to match a conversation to a buddy based on the IP and, if possible the "from" attribute of the stream or the first tag in the stream. Thanks to Sjoerd Simons from Telepahy Salut for noticing and suggesting the algorithm. Fixes #4187. It'd be good if a few people test this.
Daniel Atallah <datallah@pidgin.im>
parents:
21936
diff
changeset
|
1160 | if (bconv->pb != NULL && bd != NULL) { |
|
c41d17a1b8d9
This is the second part of the fix to support having multiple presence records in Bonjour (and also supporting multiple presences using the same IP). Incoming conversations are no longer immediately attached to a buddy - we use an algorithm to match a conversation to a buddy based on the IP and, if possible the "from" attribute of the stream or the first tag in the stream. Thanks to Sjoerd Simons from Telepahy Salut for noticing and suggesting the algorithm. Fixes #4187. It'd be good if a few people test this.
Daniel Atallah <datallah@pidgin.im>
parents:
21936
diff
changeset
|
1161 | GSList *xfers, *tmp_next; |
|
c41d17a1b8d9
This is the second part of the fix to support having multiple presence records in Bonjour (and also supporting multiple presences using the same IP). Incoming conversations are no longer immediately attached to a buddy - we use an algorithm to match a conversation to a buddy based on the IP and, if possible the "from" attribute of the stream or the first tag in the stream. Thanks to Sjoerd Simons from Telepahy Salut for noticing and suggesting the algorithm. Fixes #4187. It'd be good if a few people test this.
Daniel Atallah <datallah@pidgin.im>
parents:
21936
diff
changeset
|
1162 | xfers = bd->xfer_lists; |
|
c41d17a1b8d9
This is the second part of the fix to support having multiple presence records in Bonjour (and also supporting multiple presences using the same IP). Incoming conversations are no longer immediately attached to a buddy - we use an algorithm to match a conversation to a buddy based on the IP and, if possible the "from" attribute of the stream or the first tag in the stream. Thanks to Sjoerd Simons from Telepahy Salut for noticing and suggesting the algorithm. Fixes #4187. It'd be good if a few people test this.
Daniel Atallah <datallah@pidgin.im>
parents:
21936
diff
changeset
|
1163 | while(xfers != NULL) { |
|
c41d17a1b8d9
This is the second part of the fix to support having multiple presence records in Bonjour (and also supporting multiple presences using the same IP). Incoming conversations are no longer immediately attached to a buddy - we use an algorithm to match a conversation to a buddy based on the IP and, if possible the "from" attribute of the stream or the first tag in the stream. Thanks to Sjoerd Simons from Telepahy Salut for noticing and suggesting the algorithm. Fixes #4187. It'd be good if a few people test this.
Daniel Atallah <datallah@pidgin.im>
parents:
21936
diff
changeset
|
1164 | PurpleXfer *xfer = xfers->data; |
|
c41d17a1b8d9
This is the second part of the fix to support having multiple presence records in Bonjour (and also supporting multiple presences using the same IP). Incoming conversations are no longer immediately attached to a buddy - we use an algorithm to match a conversation to a buddy based on the IP and, if possible the "from" attribute of the stream or the first tag in the stream. Thanks to Sjoerd Simons from Telepahy Salut for noticing and suggesting the algorithm. Fixes #4187. It'd be good if a few people test this.
Daniel Atallah <datallah@pidgin.im>
parents:
21936
diff
changeset
|
1165 | tmp_next = xfers->next; |
|
c41d17a1b8d9
This is the second part of the fix to support having multiple presence records in Bonjour (and also supporting multiple presences using the same IP). Incoming conversations are no longer immediately attached to a buddy - we use an algorithm to match a conversation to a buddy based on the IP and, if possible the "from" attribute of the stream or the first tag in the stream. Thanks to Sjoerd Simons from Telepahy Salut for noticing and suggesting the algorithm. Fixes #4187. It'd be good if a few people test this.
Daniel Atallah <datallah@pidgin.im>
parents:
21936
diff
changeset
|
1166 | /* We only need to cancel this if it hasn't actually started transferring. */ |
|
c41d17a1b8d9
This is the second part of the fix to support having multiple presence records in Bonjour (and also supporting multiple presences using the same IP). Incoming conversations are no longer immediately attached to a buddy - we use an algorithm to match a conversation to a buddy based on the IP and, if possible the "from" attribute of the stream or the first tag in the stream. Thanks to Sjoerd Simons from Telepahy Salut for noticing and suggesting the algorithm. Fixes #4187. It'd be good if a few people test this.
Daniel Atallah <datallah@pidgin.im>
parents:
21936
diff
changeset
|
1167 | /* This will change if we ever support IBB transfers. */ |
|
32701
43727c8b9372
Bonjour: Use file-transfer accessor functions.
Andrew Victor <andrew.victor@mxit.com>
parents:
32594
diff
changeset
|
1168 | if (strcmp(purple_xfer_get_remote_user(xfer), purple_buddy_get_name(bconv->pb)) == 0 |
|
21944
c41d17a1b8d9
This is the second part of the fix to support having multiple presence records in Bonjour (and also supporting multiple presences using the same IP). Incoming conversations are no longer immediately attached to a buddy - we use an algorithm to match a conversation to a buddy based on the IP and, if possible the "from" attribute of the stream or the first tag in the stream. Thanks to Sjoerd Simons from Telepahy Salut for noticing and suggesting the algorithm. Fixes #4187. It'd be good if a few people test this.
Daniel Atallah <datallah@pidgin.im>
parents:
21936
diff
changeset
|
1169 | && (purple_xfer_get_status(xfer) == PURPLE_XFER_STATUS_NOT_STARTED |
|
c41d17a1b8d9
This is the second part of the fix to support having multiple presence records in Bonjour (and also supporting multiple presences using the same IP). Incoming conversations are no longer immediately attached to a buddy - we use an algorithm to match a conversation to a buddy based on the IP and, if possible the "from" attribute of the stream or the first tag in the stream. Thanks to Sjoerd Simons from Telepahy Salut for noticing and suggesting the algorithm. Fixes #4187. It'd be good if a few people test this.
Daniel Atallah <datallah@pidgin.im>
parents:
21936
diff
changeset
|
1170 | || purple_xfer_get_status(xfer) == PURPLE_XFER_STATUS_UNKNOWN)) { |
|
c41d17a1b8d9
This is the second part of the fix to support having multiple presence records in Bonjour (and also supporting multiple presences using the same IP). Incoming conversations are no longer immediately attached to a buddy - we use an algorithm to match a conversation to a buddy based on the IP and, if possible the "from" attribute of the stream or the first tag in the stream. Thanks to Sjoerd Simons from Telepahy Salut for noticing and suggesting the algorithm. Fixes #4187. It'd be good if a few people test this.
Daniel Atallah <datallah@pidgin.im>
parents:
21936
diff
changeset
|
1171 | purple_xfer_cancel_remote(xfer); |
|
c41d17a1b8d9
This is the second part of the fix to support having multiple presence records in Bonjour (and also supporting multiple presences using the same IP). Incoming conversations are no longer immediately attached to a buddy - we use an algorithm to match a conversation to a buddy based on the IP and, if possible the "from" attribute of the stream or the first tag in the stream. Thanks to Sjoerd Simons from Telepahy Salut for noticing and suggesting the algorithm. Fixes #4187. It'd be good if a few people test this.
Daniel Atallah <datallah@pidgin.im>
parents:
21936
diff
changeset
|
1172 | } |
|
c41d17a1b8d9
This is the second part of the fix to support having multiple presence records in Bonjour (and also supporting multiple presences using the same IP). Incoming conversations are no longer immediately attached to a buddy - we use an algorithm to match a conversation to a buddy based on the IP and, if possible the "from" attribute of the stream or the first tag in the stream. Thanks to Sjoerd Simons from Telepahy Salut for noticing and suggesting the algorithm. Fixes #4187. It'd be good if a few people test this.
Daniel Atallah <datallah@pidgin.im>
parents:
21936
diff
changeset
|
1173 | xfers = tmp_next; |
|
21609
30ca7a909e62
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.
Daniel Atallah <datallah@pidgin.im>
parents:
21549
diff
changeset
|
1174 | } |
|
30ca7a909e62
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.
Daniel Atallah <datallah@pidgin.im>
parents:
21549
diff
changeset
|
1175 | } |
|
30ca7a909e62
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.
Daniel Atallah <datallah@pidgin.im>
parents:
21549
diff
changeset
|
1176 | |
|
11826
10ebbc41f163
[gaim-migrate @ 14117]
Richard Laager <rlaager@pidgin.im>
parents:
11823
diff
changeset
|
1177 | /* Close the socket and remove the watcher */ |
|
17660
23c712d0a795
Cleanup, fix a leak and prevent the inbound xml from being parsed twice for every message.
Daniel Atallah <datallah@pidgin.im>
parents:
17633
diff
changeset
|
1178 | if (bconv->socket >= 0) { |
|
23c712d0a795
Cleanup, fix a leak and prevent the inbound xml from being parsed twice for every message.
Daniel Atallah <datallah@pidgin.im>
parents:
17633
diff
changeset
|
1179 | /* Send the end of the stream to the other end of the conversation */ |
|
21727
decfc3a613ff
applied changes from b9c97ed0f9ada9069e8bd994b01fdde0b484083c
Daniel Atallah <datallah@pidgin.im>
parents:
21720
diff
changeset
|
1180 | if (bconv->sent_stream_start == FULLY_SENT) |
|
17660
23c712d0a795
Cleanup, fix a leak and prevent the inbound xml from being parsed twice for every message.
Daniel Atallah <datallah@pidgin.im>
parents:
17633
diff
changeset
|
1181 | send(bconv->socket, STREAM_END, strlen(STREAM_END), 0); |
|
23c712d0a795
Cleanup, fix a leak and prevent the inbound xml from being parsed twice for every message.
Daniel Atallah <datallah@pidgin.im>
parents:
17633
diff
changeset
|
1182 | /* TODO: We're really supposed to wait for "</stream:stream>" before closing the socket */ |
|
23c712d0a795
Cleanup, fix a leak and prevent the inbound xml from being parsed twice for every message.
Daniel Atallah <datallah@pidgin.im>
parents:
17633
diff
changeset
|
1183 | close(bconv->socket); |
|
23c712d0a795
Cleanup, fix a leak and prevent the inbound xml from being parsed twice for every message.
Daniel Atallah <datallah@pidgin.im>
parents:
17633
diff
changeset
|
1184 | } |
|
19579
d79d5c95ce5a
Reset unsigned int input handlers to 0 instead of -1.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
19373
diff
changeset
|
1185 | if (bconv->rx_handler != 0) |
|
17665
26bff2090889
Update Bonjour to do nonblocking I/O correctly.
Daniel Atallah <datallah@pidgin.im>
parents:
17663
diff
changeset
|
1186 | purple_input_remove(bconv->rx_handler); |
|
26bff2090889
Update Bonjour to do nonblocking I/O correctly.
Daniel Atallah <datallah@pidgin.im>
parents:
17663
diff
changeset
|
1187 | if (bconv->tx_handler > 0) |
|
26bff2090889
Update Bonjour to do nonblocking I/O correctly.
Daniel Atallah <datallah@pidgin.im>
parents:
17663
diff
changeset
|
1188 | purple_input_remove(bconv->tx_handler); |
|
11539
fbabe3f89777
[gaim-migrate @ 13794]
Mark Doliner <markdoliner@pidgin.im>
parents:
11515
diff
changeset
|
1189 | |
|
11826
10ebbc41f163
[gaim-migrate @ 14117]
Richard Laager <rlaager@pidgin.im>
parents:
11823
diff
changeset
|
1190 | /* Free all the data related to the conversation */ |
|
34529
68cf25486001
GObjectify PurpleCircBuffer as PurpleCircularBuffer (from gobjectification branch)
Ankit Vani <a@nevitus.org>
parents:
33892
diff
changeset
|
1191 | g_object_unref(G_OBJECT(bconv->tx_buf)); |
|
17665
26bff2090889
Update Bonjour to do nonblocking I/O correctly.
Daniel Atallah <datallah@pidgin.im>
parents:
17663
diff
changeset
|
1192 | if (bconv->connect_data != NULL) |
|
26bff2090889
Update Bonjour to do nonblocking I/O correctly.
Daniel Atallah <datallah@pidgin.im>
parents:
17663
diff
changeset
|
1193 | purple_proxy_connect_cancel(bconv->connect_data); |
|
26bff2090889
Update Bonjour to do nonblocking I/O correctly.
Daniel Atallah <datallah@pidgin.im>
parents:
17663
diff
changeset
|
1194 | if (bconv->stream_data != NULL) { |
|
26bff2090889
Update Bonjour to do nonblocking I/O correctly.
Daniel Atallah <datallah@pidgin.im>
parents:
17663
diff
changeset
|
1195 | struct _stream_start_data *ss = bconv->stream_data; |
|
26bff2090889
Update Bonjour to do nonblocking I/O correctly.
Daniel Atallah <datallah@pidgin.im>
parents:
17663
diff
changeset
|
1196 | g_free(ss->msg); |
|
26bff2090889
Update Bonjour to do nonblocking I/O correctly.
Daniel Atallah <datallah@pidgin.im>
parents:
17663
diff
changeset
|
1197 | g_free(ss); |
|
26bff2090889
Update Bonjour to do nonblocking I/O correctly.
Daniel Atallah <datallah@pidgin.im>
parents:
17663
diff
changeset
|
1198 | } |
|
19056
05cd9ab28312
Update the Bonjour prpl to use libxml explicitly instead of the xml_node stuff. This allows us to deal with partial reads. I also fixed issues related to starting conversations with iChat and a couple other things. Fixes #2022,#1652
Daniel Atallah <datallah@pidgin.im>
parents:
18947
diff
changeset
|
1199 | |
|
05cd9ab28312
Update the Bonjour prpl to use libxml explicitly instead of the xml_node stuff. This allows us to deal with partial reads. I also fixed issues related to starting conversations with iChat and a couple other things. Fixes #2022,#1652
Daniel Atallah <datallah@pidgin.im>
parents:
18947
diff
changeset
|
1200 | if (bconv->context != NULL) |
|
05cd9ab28312
Update the Bonjour prpl to use libxml explicitly instead of the xml_node stuff. This allows us to deal with partial reads. I also fixed issues related to starting conversations with iChat and a couple other things. Fixes #2022,#1652
Daniel Atallah <datallah@pidgin.im>
parents:
18947
diff
changeset
|
1201 | bonjour_parser_setup(bconv); |
|
05cd9ab28312
Update the Bonjour prpl to use libxml explicitly instead of the xml_node stuff. This allows us to deal with partial reads. I also fixed issues related to starting conversations with iChat and a couple other things. Fixes #2022,#1652
Daniel Atallah <datallah@pidgin.im>
parents:
18947
diff
changeset
|
1202 | |
|
22238
c69aff70828d
Prevent a crash caused by freed memory being accessed.
Daniel Atallah <datallah@pidgin.im>
parents:
21944
diff
changeset
|
1203 | if (bconv->close_timeout != 0) |
|
c69aff70828d
Prevent a crash caused by freed memory being accessed.
Daniel Atallah <datallah@pidgin.im>
parents:
21944
diff
changeset
|
1204 | purple_timeout_remove(bconv->close_timeout); |
|
c69aff70828d
Prevent a crash caused by freed memory being accessed.
Daniel Atallah <datallah@pidgin.im>
parents:
21944
diff
changeset
|
1205 | |
|
21944
c41d17a1b8d9
This is the second part of the fix to support having multiple presence records in Bonjour (and also supporting multiple presences using the same IP). Incoming conversations are no longer immediately attached to a buddy - we use an algorithm to match a conversation to a buddy based on the IP and, if possible the "from" attribute of the stream or the first tag in the stream. Thanks to Sjoerd Simons from Telepahy Salut for noticing and suggesting the algorithm. Fixes #4187. It'd be good if a few people test this.
Daniel Atallah <datallah@pidgin.im>
parents:
21936
diff
changeset
|
1206 | g_free(bconv->buddy_name); |
|
c41d17a1b8d9
This is the second part of the fix to support having multiple presence records in Bonjour (and also supporting multiple presences using the same IP). Incoming conversations are no longer immediately attached to a buddy - we use an algorithm to match a conversation to a buddy based on the IP and, if possible the "from" attribute of the stream or the first tag in the stream. Thanks to Sjoerd Simons from Telepahy Salut for noticing and suggesting the algorithm. Fixes #4187. It'd be good if a few people test this.
Daniel Atallah <datallah@pidgin.im>
parents:
21936
diff
changeset
|
1207 | g_free(bconv->ip); |
|
17660
23c712d0a795
Cleanup, fix a leak and prevent the inbound xml from being parsed twice for every message.
Daniel Atallah <datallah@pidgin.im>
parents:
17633
diff
changeset
|
1208 | g_free(bconv); |
| 11477 | 1209 | } |
| 1210 | } | |
| 1211 | ||
|
11539
fbabe3f89777
[gaim-migrate @ 13794]
Mark Doliner <markdoliner@pidgin.im>
parents:
11515
diff
changeset
|
1212 | void |
|
21944
c41d17a1b8d9
This is the second part of the fix to support having multiple presence records in Bonjour (and also supporting multiple presences using the same IP). Incoming conversations are no longer immediately attached to a buddy - we use an algorithm to match a conversation to a buddy based on the IP and, if possible the "from" attribute of the stream or the first tag in the stream. Thanks to Sjoerd Simons from Telepahy Salut for noticing and suggesting the algorithm. Fixes #4187. It'd be good if a few people test this.
Daniel Atallah <datallah@pidgin.im>
parents:
21936
diff
changeset
|
1213 | bonjour_jabber_stop(BonjourJabber *jdata) |
| 11477 | 1214 | { |
|
17633
b76241c02857
Some more Bonjour cleanup and leak fixing.
Daniel Atallah <datallah@pidgin.im>
parents:
17632
diff
changeset
|
1215 | /* Close the server socket and remove the watcher */ |
|
21944
c41d17a1b8d9
This is the second part of the fix to support having multiple presence records in Bonjour (and also supporting multiple presences using the same IP). Incoming conversations are no longer immediately attached to a buddy - we use an algorithm to match a conversation to a buddy based on the IP and, if possible the "from" attribute of the stream or the first tag in the stream. Thanks to Sjoerd Simons from Telepahy Salut for noticing and suggesting the algorithm. Fixes #4187. It'd be good if a few people test this.
Daniel Atallah <datallah@pidgin.im>
parents:
21936
diff
changeset
|
1216 | if (jdata->socket >= 0) |
|
c41d17a1b8d9
This is the second part of the fix to support having multiple presence records in Bonjour (and also supporting multiple presences using the same IP). Incoming conversations are no longer immediately attached to a buddy - we use an algorithm to match a conversation to a buddy based on the IP and, if possible the "from" attribute of the stream or the first tag in the stream. Thanks to Sjoerd Simons from Telepahy Salut for noticing and suggesting the algorithm. Fixes #4187. It'd be good if a few people test this.
Daniel Atallah <datallah@pidgin.im>
parents:
21936
diff
changeset
|
1217 | close(jdata->socket); |
|
c41d17a1b8d9
This is the second part of the fix to support having multiple presence records in Bonjour (and also supporting multiple presences using the same IP). Incoming conversations are no longer immediately attached to a buddy - we use an algorithm to match a conversation to a buddy based on the IP and, if possible the "from" attribute of the stream or the first tag in the stream. Thanks to Sjoerd Simons from Telepahy Salut for noticing and suggesting the algorithm. Fixes #4187. It'd be good if a few people test this.
Daniel Atallah <datallah@pidgin.im>
parents:
21936
diff
changeset
|
1218 | if (jdata->watcher_id > 0) |
|
c41d17a1b8d9
This is the second part of the fix to support having multiple presence records in Bonjour (and also supporting multiple presences using the same IP). Incoming conversations are no longer immediately attached to a buddy - we use an algorithm to match a conversation to a buddy based on the IP and, if possible the "from" attribute of the stream or the first tag in the stream. Thanks to Sjoerd Simons from Telepahy Salut for noticing and suggesting the algorithm. Fixes #4187. It'd be good if a few people test this.
Daniel Atallah <datallah@pidgin.im>
parents:
21936
diff
changeset
|
1219 | purple_input_remove(jdata->watcher_id); |
|
29761
0f6862f2782f
Implementation of IPv6 support for Bonjour
Daniel Atallah <datallah@pidgin.im>
parents:
27625
diff
changeset
|
1220 | if (jdata->socket6 >= 0) |
|
0f6862f2782f
Implementation of IPv6 support for Bonjour
Daniel Atallah <datallah@pidgin.im>
parents:
27625
diff
changeset
|
1221 | close(jdata->socket6); |
|
0f6862f2782f
Implementation of IPv6 support for Bonjour
Daniel Atallah <datallah@pidgin.im>
parents:
27625
diff
changeset
|
1222 | if (jdata->watcher_id6 > 0) |
|
0f6862f2782f
Implementation of IPv6 support for Bonjour
Daniel Atallah <datallah@pidgin.im>
parents:
27625
diff
changeset
|
1223 | purple_input_remove(jdata->watcher_id6); |
|
11539
fbabe3f89777
[gaim-migrate @ 13794]
Mark Doliner <markdoliner@pidgin.im>
parents:
11515
diff
changeset
|
1224 | |
|
17633
b76241c02857
Some more Bonjour cleanup and leak fixing.
Daniel Atallah <datallah@pidgin.im>
parents:
17632
diff
changeset
|
1225 | /* Close all the conversation sockets and remove all the watchers after sending end streams */ |
|
32215
0a4e72c8a67e
Use accessor functions in a few places
Mark Doliner <markdoliner@pidgin.im>
parents:
31749
diff
changeset
|
1226 | if (!purple_account_is_disconnected(jdata->account)) { |
|
17660
23c712d0a795
Cleanup, fix a leak and prevent the inbound xml from being parsed twice for every message.
Daniel Atallah <datallah@pidgin.im>
parents:
17633
diff
changeset
|
1227 | GSList *buddies, *l; |
|
17633
b76241c02857
Some more Bonjour cleanup and leak fixing.
Daniel Atallah <datallah@pidgin.im>
parents:
17632
diff
changeset
|
1228 | |
|
34728
8efd73063ecf
Renamed buddy list functions to more appropriate/simler names.
Ankit Vani <a@nevitus.org>
parents:
34706
diff
changeset
|
1229 | buddies = purple_blist_find_buddies(jdata->account, NULL); |
|
17663
fd736a4d91a9
Close conversation connections when logging out of the Bonjour account. This also fixes leakage.
Daniel Atallah <datallah@pidgin.im>
parents:
17662
diff
changeset
|
1230 | for (l = buddies; l; l = l->next) { |
|
24938
fc6952107e1f
Finished moving to api for bonjour
Gary Kramlich <grim@reaperworld.com>
parents:
24562
diff
changeset
|
1231 | BonjourBuddy *bb = purple_buddy_get_protocol_data((PurpleBuddy*) l->data); |
|
30249
8e9926aa236a
bonjour: Fix a crash-on-disconnect I introduced. Closes #11851
Paul Aurich <darkrain42@pidgin.im>
parents:
29999
diff
changeset
|
1232 | if (bb && bb->conversation) { |
|
29932
2ac5b74d0649
Fix two related on-disconnect double frees.
Paul Aurich <darkrain42@pidgin.im>
parents:
29761
diff
changeset
|
1233 | /* Any ongoing connection attempt is cancelled |
|
34751
374a9500c430
Added _purple_connection_wants_to_die() to internal.h to be used by account.c. Removed _purple_connection_destroy().
Ankit Vani <a@nevitus.org>
parents:
34728
diff
changeset
|
1234 | * when a connection is destroyed */ |
|
29932
2ac5b74d0649
Fix two related on-disconnect double frees.
Paul Aurich <darkrain42@pidgin.im>
parents:
29761
diff
changeset
|
1235 | bb->conversation->connect_data = NULL; |
|
23160
0aff8f3882f4
applied changes from 3d595739f53a259d5dae408a05f64d2836f02ac9
Daniel Atallah <datallah@pidgin.im>
parents:
23072
diff
changeset
|
1236 | bonjour_jabber_close_conversation(bb->conversation); |
|
0aff8f3882f4
applied changes from 3d595739f53a259d5dae408a05f64d2836f02ac9
Daniel Atallah <datallah@pidgin.im>
parents:
23072
diff
changeset
|
1237 | bb->conversation = NULL; |
|
0aff8f3882f4
applied changes from 3d595739f53a259d5dae408a05f64d2836f02ac9
Daniel Atallah <datallah@pidgin.im>
parents:
23072
diff
changeset
|
1238 | } |
|
17663
fd736a4d91a9
Close conversation connections when logging out of the Bonjour account. This also fixes leakage.
Daniel Atallah <datallah@pidgin.im>
parents:
17662
diff
changeset
|
1239 | } |
|
17665
26bff2090889
Update Bonjour to do nonblocking I/O correctly.
Daniel Atallah <datallah@pidgin.im>
parents:
17663
diff
changeset
|
1240 | |
| 11477 | 1241 | g_slist_free(buddies); |
| 1242 | } | |
|
21944
c41d17a1b8d9
This is the second part of the fix to support having multiple presence records in Bonjour (and also supporting multiple presences using the same IP). Incoming conversations are no longer immediately attached to a buddy - we use an algorithm to match a conversation to a buddy based on the IP and, if possible the "from" attribute of the stream or the first tag in the stream. Thanks to Sjoerd Simons from Telepahy Salut for noticing and suggesting the algorithm. Fixes #4187. It'd be good if a few people test this.
Daniel Atallah <datallah@pidgin.im>
parents:
21936
diff
changeset
|
1243 | |
|
c41d17a1b8d9
This is the second part of the fix to support having multiple presence records in Bonjour (and also supporting multiple presences using the same IP). Incoming conversations are no longer immediately attached to a buddy - we use an algorithm to match a conversation to a buddy based on the IP and, if possible the "from" attribute of the stream or the first tag in the stream. Thanks to Sjoerd Simons from Telepahy Salut for noticing and suggesting the algorithm. Fixes #4187. It'd be good if a few people test this.
Daniel Atallah <datallah@pidgin.im>
parents:
21936
diff
changeset
|
1244 | while (jdata->pending_conversations != NULL) { |
|
c41d17a1b8d9
This is the second part of the fix to support having multiple presence records in Bonjour (and also supporting multiple presences using the same IP). Incoming conversations are no longer immediately attached to a buddy - we use an algorithm to match a conversation to a buddy based on the IP and, if possible the "from" attribute of the stream or the first tag in the stream. Thanks to Sjoerd Simons from Telepahy Salut for noticing and suggesting the algorithm. Fixes #4187. It'd be good if a few people test this.
Daniel Atallah <datallah@pidgin.im>
parents:
21936
diff
changeset
|
1245 | bonjour_jabber_close_conversation(jdata->pending_conversations->data); |
|
c41d17a1b8d9
This is the second part of the fix to support having multiple presence records in Bonjour (and also supporting multiple presences using the same IP). Incoming conversations are no longer immediately attached to a buddy - we use an algorithm to match a conversation to a buddy based on the IP and, if possible the "from" attribute of the stream or the first tag in the stream. Thanks to Sjoerd Simons from Telepahy Salut for noticing and suggesting the algorithm. Fixes #4187. It'd be good if a few people test this.
Daniel Atallah <datallah@pidgin.im>
parents:
21936
diff
changeset
|
1246 | jdata->pending_conversations = g_slist_delete_link(jdata->pending_conversations, jdata->pending_conversations); |
|
c41d17a1b8d9
This is the second part of the fix to support having multiple presence records in Bonjour (and also supporting multiple presences using the same IP). Incoming conversations are no longer immediately attached to a buddy - we use an algorithm to match a conversation to a buddy based on the IP and, if possible the "from" attribute of the stream or the first tag in the stream. Thanks to Sjoerd Simons from Telepahy Salut for noticing and suggesting the algorithm. Fixes #4187. It'd be good if a few people test this.
Daniel Atallah <datallah@pidgin.im>
parents:
21936
diff
changeset
|
1247 | } |
| 11477 | 1248 | } |
|
21524
472e58992083
Patch from some Intel folks to implement file transfer in Bonjour using XEP-0096 and 0065. This hopefully will work with Gaijm (haven't yet tested) and, of course, between libpurple instances; it will not work with Adium or iChat.
Daniel Atallah <datallah@pidgin.im>
parents:
21503
diff
changeset
|
1249 | |
|
472e58992083
Patch from some Intel folks to implement file transfer in Bonjour using XEP-0096 and 0065. This hopefully will work with Gaijm (haven't yet tested) and, of course, between libpurple instances; it will not work with Adium or iChat.
Daniel Atallah <datallah@pidgin.im>
parents:
21503
diff
changeset
|
1250 | XepIq * |
|
21609
30ca7a909e62
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.
Daniel Atallah <datallah@pidgin.im>
parents:
21549
diff
changeset
|
1251 | xep_iq_new(void *data, XepIqType type, const char *to, const char *from, const char *id) |
|
21524
472e58992083
Patch from some Intel folks to implement file transfer in Bonjour using XEP-0096 and 0065. This hopefully will work with Gaijm (haven't yet tested) and, of course, between libpurple instances; it will not work with Adium or iChat.
Daniel Atallah <datallah@pidgin.im>
parents:
21503
diff
changeset
|
1252 | { |
|
34935
686fa55b0deb
Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents:
34911
diff
changeset
|
1253 | PurpleXmlNode *iq_node = NULL; |
|
21524
472e58992083
Patch from some Intel folks to implement file transfer in Bonjour using XEP-0096 and 0065. This hopefully will work with Gaijm (haven't yet tested) and, of course, between libpurple instances; it will not work with Adium or iChat.
Daniel Atallah <datallah@pidgin.im>
parents:
21503
diff
changeset
|
1254 | XepIq *iq = NULL; |
|
472e58992083
Patch from some Intel folks to implement file transfer in Bonjour using XEP-0096 and 0065. This hopefully will work with Gaijm (haven't yet tested) and, of course, between libpurple instances; it will not work with Adium or iChat.
Daniel Atallah <datallah@pidgin.im>
parents:
21503
diff
changeset
|
1255 | |
|
21548
b19c433f5af2
Cleanup and fix the socks5 proxy connect address to be correct.
Daniel Atallah <datallah@pidgin.im>
parents:
21547
diff
changeset
|
1256 | g_return_val_if_fail(data != NULL, NULL); |
|
b19c433f5af2
Cleanup and fix the socks5 proxy connect address to be correct.
Daniel Atallah <datallah@pidgin.im>
parents:
21547
diff
changeset
|
1257 | g_return_val_if_fail(to != NULL, NULL); |
|
b19c433f5af2
Cleanup and fix the socks5 proxy connect address to be correct.
Daniel Atallah <datallah@pidgin.im>
parents:
21547
diff
changeset
|
1258 | g_return_val_if_fail(id != NULL, NULL); |
|
21524
472e58992083
Patch from some Intel folks to implement file transfer in Bonjour using XEP-0096 and 0065. This hopefully will work with Gaijm (haven't yet tested) and, of course, between libpurple instances; it will not work with Adium or iChat.
Daniel Atallah <datallah@pidgin.im>
parents:
21503
diff
changeset
|
1259 | |
|
34935
686fa55b0deb
Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents:
34911
diff
changeset
|
1260 | iq_node = purple_xmlnode_new("iq"); |
|
21524
472e58992083
Patch from some Intel folks to implement file transfer in Bonjour using XEP-0096 and 0065. This hopefully will work with Gaijm (haven't yet tested) and, of course, between libpurple instances; it will not work with Adium or iChat.
Daniel Atallah <datallah@pidgin.im>
parents:
21503
diff
changeset
|
1261 | |
|
34935
686fa55b0deb
Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents:
34911
diff
changeset
|
1262 | purple_xmlnode_set_attrib(iq_node, "to", to); |
|
686fa55b0deb
Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents:
34911
diff
changeset
|
1263 | purple_xmlnode_set_attrib(iq_node, "from", from); |
|
686fa55b0deb
Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents:
34911
diff
changeset
|
1264 | purple_xmlnode_set_attrib(iq_node, "id", id); |
|
21524
472e58992083
Patch from some Intel folks to implement file transfer in Bonjour using XEP-0096 and 0065. This hopefully will work with Gaijm (haven't yet tested) and, of course, between libpurple instances; it will not work with Adium or iChat.
Daniel Atallah <datallah@pidgin.im>
parents:
21503
diff
changeset
|
1265 | switch (type) { |
|
472e58992083
Patch from some Intel folks to implement file transfer in Bonjour using XEP-0096 and 0065. This hopefully will work with Gaijm (haven't yet tested) and, of course, between libpurple instances; it will not work with Adium or iChat.
Daniel Atallah <datallah@pidgin.im>
parents:
21503
diff
changeset
|
1266 | case XEP_IQ_SET: |
|
34935
686fa55b0deb
Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents:
34911
diff
changeset
|
1267 | purple_xmlnode_set_attrib(iq_node, "type", "set"); |
|
21524
472e58992083
Patch from some Intel folks to implement file transfer in Bonjour using XEP-0096 and 0065. This hopefully will work with Gaijm (haven't yet tested) and, of course, between libpurple instances; it will not work with Adium or iChat.
Daniel Atallah <datallah@pidgin.im>
parents:
21503
diff
changeset
|
1268 | break; |
|
472e58992083
Patch from some Intel folks to implement file transfer in Bonjour using XEP-0096 and 0065. This hopefully will work with Gaijm (haven't yet tested) and, of course, between libpurple instances; it will not work with Adium or iChat.
Daniel Atallah <datallah@pidgin.im>
parents:
21503
diff
changeset
|
1269 | case XEP_IQ_GET: |
|
34935
686fa55b0deb
Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents:
34911
diff
changeset
|
1270 | purple_xmlnode_set_attrib(iq_node, "type", "get"); |
|
21524
472e58992083
Patch from some Intel folks to implement file transfer in Bonjour using XEP-0096 and 0065. This hopefully will work with Gaijm (haven't yet tested) and, of course, between libpurple instances; it will not work with Adium or iChat.
Daniel Atallah <datallah@pidgin.im>
parents:
21503
diff
changeset
|
1271 | break; |
|
472e58992083
Patch from some Intel folks to implement file transfer in Bonjour using XEP-0096 and 0065. This hopefully will work with Gaijm (haven't yet tested) and, of course, between libpurple instances; it will not work with Adium or iChat.
Daniel Atallah <datallah@pidgin.im>
parents:
21503
diff
changeset
|
1272 | case XEP_IQ_RESULT: |
|
34935
686fa55b0deb
Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents:
34911
diff
changeset
|
1273 | purple_xmlnode_set_attrib(iq_node, "type", "result"); |
|
21524
472e58992083
Patch from some Intel folks to implement file transfer in Bonjour using XEP-0096 and 0065. This hopefully will work with Gaijm (haven't yet tested) and, of course, between libpurple instances; it will not work with Adium or iChat.
Daniel Atallah <datallah@pidgin.im>
parents:
21503
diff
changeset
|
1274 | break; |
|
472e58992083
Patch from some Intel folks to implement file transfer in Bonjour using XEP-0096 and 0065. This hopefully will work with Gaijm (haven't yet tested) and, of course, between libpurple instances; it will not work with Adium or iChat.
Daniel Atallah <datallah@pidgin.im>
parents:
21503
diff
changeset
|
1275 | case XEP_IQ_ERROR: |
|
34935
686fa55b0deb
Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents:
34911
diff
changeset
|
1276 | purple_xmlnode_set_attrib(iq_node, "type", "error"); |
|
21524
472e58992083
Patch from some Intel folks to implement file transfer in Bonjour using XEP-0096 and 0065. This hopefully will work with Gaijm (haven't yet tested) and, of course, between libpurple instances; it will not work with Adium or iChat.
Daniel Atallah <datallah@pidgin.im>
parents:
21503
diff
changeset
|
1277 | break; |
|
472e58992083
Patch from some Intel folks to implement file transfer in Bonjour using XEP-0096 and 0065. This hopefully will work with Gaijm (haven't yet tested) and, of course, between libpurple instances; it will not work with Adium or iChat.
Daniel Atallah <datallah@pidgin.im>
parents:
21503
diff
changeset
|
1278 | case XEP_IQ_NONE: |
|
472e58992083
Patch from some Intel folks to implement file transfer in Bonjour using XEP-0096 and 0065. This hopefully will work with Gaijm (haven't yet tested) and, of course, between libpurple instances; it will not work with Adium or iChat.
Daniel Atallah <datallah@pidgin.im>
parents:
21503
diff
changeset
|
1279 | default: |
|
34935
686fa55b0deb
Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents:
34911
diff
changeset
|
1280 | purple_xmlnode_set_attrib(iq_node, "type", "none"); |
|
21524
472e58992083
Patch from some Intel folks to implement file transfer in Bonjour using XEP-0096 and 0065. This hopefully will work with Gaijm (haven't yet tested) and, of course, between libpurple instances; it will not work with Adium or iChat.
Daniel Atallah <datallah@pidgin.im>
parents:
21503
diff
changeset
|
1281 | break; |
|
472e58992083
Patch from some Intel folks to implement file transfer in Bonjour using XEP-0096 and 0065. This hopefully will work with Gaijm (haven't yet tested) and, of course, between libpurple instances; it will not work with Adium or iChat.
Daniel Atallah <datallah@pidgin.im>
parents:
21503
diff
changeset
|
1282 | } |
|
472e58992083
Patch from some Intel folks to implement file transfer in Bonjour using XEP-0096 and 0065. This hopefully will work with Gaijm (haven't yet tested) and, of course, between libpurple instances; it will not work with Adium or iChat.
Daniel Atallah <datallah@pidgin.im>
parents:
21503
diff
changeset
|
1283 | |
|
21548
b19c433f5af2
Cleanup and fix the socks5 proxy connect address to be correct.
Daniel Atallah <datallah@pidgin.im>
parents:
21547
diff
changeset
|
1284 | iq = g_new0(XepIq, 1); |
|
21524
472e58992083
Patch from some Intel folks to implement file transfer in Bonjour using XEP-0096 and 0065. This hopefully will work with Gaijm (haven't yet tested) and, of course, between libpurple instances; it will not work with Adium or iChat.
Daniel Atallah <datallah@pidgin.im>
parents:
21503
diff
changeset
|
1285 | iq->node = iq_node; |
|
472e58992083
Patch from some Intel folks to implement file transfer in Bonjour using XEP-0096 and 0065. This hopefully will work with Gaijm (haven't yet tested) and, of course, between libpurple instances; it will not work with Adium or iChat.
Daniel Atallah <datallah@pidgin.im>
parents:
21503
diff
changeset
|
1286 | iq->type = type; |
|
472e58992083
Patch from some Intel folks to implement file transfer in Bonjour using XEP-0096 and 0065. This hopefully will work with Gaijm (haven't yet tested) and, of course, between libpurple instances; it will not work with Adium or iChat.
Daniel Atallah <datallah@pidgin.im>
parents:
21503
diff
changeset
|
1287 | iq->data = ((BonjourData*)data)->jabber_data; |
|
472e58992083
Patch from some Intel folks to implement file transfer in Bonjour using XEP-0096 and 0065. This hopefully will work with Gaijm (haven't yet tested) and, of course, between libpurple instances; it will not work with Adium or iChat.
Daniel Atallah <datallah@pidgin.im>
parents:
21503
diff
changeset
|
1288 | iq->to = (char*)to; |
|
21609
30ca7a909e62
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.
Daniel Atallah <datallah@pidgin.im>
parents:
21549
diff
changeset
|
1289 | |
|
21524
472e58992083
Patch from some Intel folks to implement file transfer in Bonjour using XEP-0096 and 0065. This hopefully will work with Gaijm (haven't yet tested) and, of course, between libpurple instances; it will not work with Adium or iChat.
Daniel Atallah <datallah@pidgin.im>
parents:
21503
diff
changeset
|
1290 | return iq; |
|
472e58992083
Patch from some Intel folks to implement file transfer in Bonjour using XEP-0096 and 0065. This hopefully will work with Gaijm (haven't yet tested) and, of course, between libpurple instances; it will not work with Adium or iChat.
Daniel Atallah <datallah@pidgin.im>
parents:
21503
diff
changeset
|
1291 | } |
|
472e58992083
Patch from some Intel folks to implement file transfer in Bonjour using XEP-0096 and 0065. This hopefully will work with Gaijm (haven't yet tested) and, of course, between libpurple instances; it will not work with Adium or iChat.
Daniel Atallah <datallah@pidgin.im>
parents:
21503
diff
changeset
|
1292 | |
|
472e58992083
Patch from some Intel folks to implement file transfer in Bonjour using XEP-0096 and 0065. This hopefully will work with Gaijm (haven't yet tested) and, of course, between libpurple instances; it will not work with Adium or iChat.
Daniel Atallah <datallah@pidgin.im>
parents:
21503
diff
changeset
|
1293 | static gboolean |
|
472e58992083
Patch from some Intel folks to implement file transfer in Bonjour using XEP-0096 and 0065. This hopefully will work with Gaijm (haven't yet tested) and, of course, between libpurple instances; it will not work with Adium or iChat.
Daniel Atallah <datallah@pidgin.im>
parents:
21503
diff
changeset
|
1294 | check_if_blocked(PurpleBuddy *pb) |
|
472e58992083
Patch from some Intel folks to implement file transfer in Bonjour using XEP-0096 and 0065. This hopefully will work with Gaijm (haven't yet tested) and, of course, between libpurple instances; it will not work with Adium or iChat.
Daniel Atallah <datallah@pidgin.im>
parents:
21503
diff
changeset
|
1295 | { |
|
472e58992083
Patch from some Intel folks to implement file transfer in Bonjour using XEP-0096 and 0065. This hopefully will work with Gaijm (haven't yet tested) and, of course, between libpurple instances; it will not work with Adium or iChat.
Daniel Atallah <datallah@pidgin.im>
parents:
21503
diff
changeset
|
1296 | gboolean blocked = FALSE; |
|
472e58992083
Patch from some Intel folks to implement file transfer in Bonjour using XEP-0096 and 0065. This hopefully will work with Gaijm (haven't yet tested) and, of course, between libpurple instances; it will not work with Adium or iChat.
Daniel Atallah <datallah@pidgin.im>
parents:
21503
diff
changeset
|
1297 | GSList *l = NULL; |
|
25097
c950e59e30bf
Further cleanup to fix CID 373.
Daniel Atallah <datallah@pidgin.im>
parents:
25096
diff
changeset
|
1298 | PurpleAccount *acc = purple_buddy_get_account(pb); |
|
21524
472e58992083
Patch from some Intel folks to implement file transfer in Bonjour using XEP-0096 and 0065. This hopefully will work with Gaijm (haven't yet tested) and, of course, between libpurple instances; it will not work with Adium or iChat.
Daniel Atallah <datallah@pidgin.im>
parents:
21503
diff
changeset
|
1299 | |
|
25097
c950e59e30bf
Further cleanup to fix CID 373.
Daniel Atallah <datallah@pidgin.im>
parents:
25096
diff
changeset
|
1300 | if(acc == NULL) |
|
21524
472e58992083
Patch from some Intel folks to implement file transfer in Bonjour using XEP-0096 and 0065. This hopefully will work with Gaijm (haven't yet tested) and, of course, between libpurple instances; it will not work with Adium or iChat.
Daniel Atallah <datallah@pidgin.im>
parents:
21503
diff
changeset
|
1301 | return FALSE; |
|
472e58992083
Patch from some Intel folks to implement file transfer in Bonjour using XEP-0096 and 0065. This hopefully will work with Gaijm (haven't yet tested) and, of course, between libpurple instances; it will not work with Adium or iChat.
Daniel Atallah <datallah@pidgin.im>
parents:
21503
diff
changeset
|
1302 | |
|
24398
4865c2ee6ea8
Start hiding blist.h internals in prpls.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
24333
diff
changeset
|
1303 | acc = purple_buddy_get_account(pb); |
|
21524
472e58992083
Patch from some Intel folks to implement file transfer in Bonjour using XEP-0096 and 0065. This hopefully will work with Gaijm (haven't yet tested) and, of course, between libpurple instances; it will not work with Adium or iChat.
Daniel Atallah <datallah@pidgin.im>
parents:
21503
diff
changeset
|
1304 | |
|
34578
cfb2f856a5d0
Refactored prpls according to the changed PurpleAccount API
Ankit Vani <a@nevitus.org>
parents:
34529
diff
changeset
|
1305 | for(l = purple_account_privacy_get_denied(acc); l != NULL; l = l->next) { |
|
24938
fc6952107e1f
Finished moving to api for bonjour
Gary Kramlich <grim@reaperworld.com>
parents:
24562
diff
changeset
|
1306 | const gchar *name = purple_buddy_get_name(pb); |
|
30825
87a79bbdc985
The hostname used for a bonjour account should always be the current machine
Daniel Atallah <datallah@pidgin.im>
parents:
30626
diff
changeset
|
1307 | const gchar *username = bonjour_get_jid(acc); |
|
24938
fc6952107e1f
Finished moving to api for bonjour
Gary Kramlich <grim@reaperworld.com>
parents:
24562
diff
changeset
|
1308 | |
|
fc6952107e1f
Finished moving to api for bonjour
Gary Kramlich <grim@reaperworld.com>
parents:
24562
diff
changeset
|
1309 | if(!purple_utf8_strcasecmp(name, (char *)l->data)) { |
|
fc6952107e1f
Finished moving to api for bonjour
Gary Kramlich <grim@reaperworld.com>
parents:
24562
diff
changeset
|
1310 | purple_debug_info("bonjour", "%s has been blocked by %s.\n", name, username); |
|
21524
472e58992083
Patch from some Intel folks to implement file transfer in Bonjour using XEP-0096 and 0065. This hopefully will work with Gaijm (haven't yet tested) and, of course, between libpurple instances; it will not work with Adium or iChat.
Daniel Atallah <datallah@pidgin.im>
parents:
21503
diff
changeset
|
1311 | blocked = TRUE; |
|
472e58992083
Patch from some Intel folks to implement file transfer in Bonjour using XEP-0096 and 0065. This hopefully will work with Gaijm (haven't yet tested) and, of course, between libpurple instances; it will not work with Adium or iChat.
Daniel Atallah <datallah@pidgin.im>
parents:
21503
diff
changeset
|
1312 | break; |
|
472e58992083
Patch from some Intel folks to implement file transfer in Bonjour using XEP-0096 and 0065. This hopefully will work with Gaijm (haven't yet tested) and, of course, between libpurple instances; it will not work with Adium or iChat.
Daniel Atallah <datallah@pidgin.im>
parents:
21503
diff
changeset
|
1313 | } |
|
472e58992083
Patch from some Intel folks to implement file transfer in Bonjour using XEP-0096 and 0065. This hopefully will work with Gaijm (haven't yet tested) and, of course, between libpurple instances; it will not work with Adium or iChat.
Daniel Atallah <datallah@pidgin.im>
parents:
21503
diff
changeset
|
1314 | } |
|
472e58992083
Patch from some Intel folks to implement file transfer in Bonjour using XEP-0096 and 0065. This hopefully will work with Gaijm (haven't yet tested) and, of course, between libpurple instances; it will not work with Adium or iChat.
Daniel Atallah <datallah@pidgin.im>
parents:
21503
diff
changeset
|
1315 | return blocked; |
|
472e58992083
Patch from some Intel folks to implement file transfer in Bonjour using XEP-0096 and 0065. This hopefully will work with Gaijm (haven't yet tested) and, of course, between libpurple instances; it will not work with Adium or iChat.
Daniel Atallah <datallah@pidgin.im>
parents:
21503
diff
changeset
|
1316 | } |
|
472e58992083
Patch from some Intel folks to implement file transfer in Bonjour using XEP-0096 and 0065. This hopefully will work with Gaijm (haven't yet tested) and, of course, between libpurple instances; it will not work with Adium or iChat.
Daniel Atallah <datallah@pidgin.im>
parents:
21503
diff
changeset
|
1317 | |
|
472e58992083
Patch from some Intel folks to implement file transfer in Bonjour using XEP-0096 and 0065. This hopefully will work with Gaijm (haven't yet tested) and, of course, between libpurple instances; it will not work with Adium or iChat.
Daniel Atallah <datallah@pidgin.im>
parents:
21503
diff
changeset
|
1318 | static void |
|
34935
686fa55b0deb
Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents:
34911
diff
changeset
|
1319 | xep_iq_parse(PurpleXmlNode *packet, PurpleBuddy *pb) |
|
21524
472e58992083
Patch from some Intel folks to implement file transfer in Bonjour using XEP-0096 and 0065. This hopefully will work with Gaijm (haven't yet tested) and, of course, between libpurple instances; it will not work with Adium or iChat.
Daniel Atallah <datallah@pidgin.im>
parents:
21503
diff
changeset
|
1320 | { |
|
25140
7c494d2bc5e4
propagate from branch 'im.pidgin.pidgin' (head 009f3ea551248605298fbf1b88d7a873b2a6c7a3)
Richard Laager <rlaager@pidgin.im>
diff
changeset
|
1321 | PurpleAccount *account; |
|
7c494d2bc5e4
propagate from branch 'im.pidgin.pidgin' (head 009f3ea551248605298fbf1b88d7a873b2a6c7a3)
Richard Laager <rlaager@pidgin.im>
diff
changeset
|
1322 | PurpleConnection *gc; |
|
21524
472e58992083
Patch from some Intel folks to implement file transfer in Bonjour using XEP-0096 and 0065. This hopefully will work with Gaijm (haven't yet tested) and, of course, between libpurple instances; it will not work with Adium or iChat.
Daniel Atallah <datallah@pidgin.im>
parents:
21503
diff
changeset
|
1323 | |
|
472e58992083
Patch from some Intel folks to implement file transfer in Bonjour using XEP-0096 and 0065. This hopefully will work with Gaijm (haven't yet tested) and, of course, between libpurple instances; it will not work with Adium or iChat.
Daniel Atallah <datallah@pidgin.im>
parents:
21503
diff
changeset
|
1324 | if(check_if_blocked(pb)) |
|
472e58992083
Patch from some Intel folks to implement file transfer in Bonjour using XEP-0096 and 0065. This hopefully will work with Gaijm (haven't yet tested) and, of course, between libpurple instances; it will not work with Adium or iChat.
Daniel Atallah <datallah@pidgin.im>
parents:
21503
diff
changeset
|
1325 | return; |
|
472e58992083
Patch from some Intel folks to implement file transfer in Bonjour using XEP-0096 and 0065. This hopefully will work with Gaijm (haven't yet tested) and, of course, between libpurple instances; it will not work with Adium or iChat.
Daniel Atallah <datallah@pidgin.im>
parents:
21503
diff
changeset
|
1326 | |
|
25140
7c494d2bc5e4
propagate from branch 'im.pidgin.pidgin' (head 009f3ea551248605298fbf1b88d7a873b2a6c7a3)
Richard Laager <rlaager@pidgin.im>
diff
changeset
|
1327 | account = purple_buddy_get_account(pb); |
|
7c494d2bc5e4
propagate from branch 'im.pidgin.pidgin' (head 009f3ea551248605298fbf1b88d7a873b2a6c7a3)
Richard Laager <rlaager@pidgin.im>
diff
changeset
|
1328 | gc = purple_account_get_connection(account); |
|
7c494d2bc5e4
propagate from branch 'im.pidgin.pidgin' (head 009f3ea551248605298fbf1b88d7a873b2a6c7a3)
Richard Laager <rlaager@pidgin.im>
diff
changeset
|
1329 | |
|
34935
686fa55b0deb
Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents:
34911
diff
changeset
|
1330 | if (purple_xmlnode_get_child(packet, "si") != NULL || purple_xmlnode_get_child(packet, "error") != NULL) |
|
25140
7c494d2bc5e4
propagate from branch 'im.pidgin.pidgin' (head 009f3ea551248605298fbf1b88d7a873b2a6c7a3)
Richard Laager <rlaager@pidgin.im>
diff
changeset
|
1331 | xep_si_parse(gc, packet, pb); |
|
21524
472e58992083
Patch from some Intel folks to implement file transfer in Bonjour using XEP-0096 and 0065. This hopefully will work with Gaijm (haven't yet tested) and, of course, between libpurple instances; it will not work with Adium or iChat.
Daniel Atallah <datallah@pidgin.im>
parents:
21503
diff
changeset
|
1332 | else |
|
25140
7c494d2bc5e4
propagate from branch 'im.pidgin.pidgin' (head 009f3ea551248605298fbf1b88d7a873b2a6c7a3)
Richard Laager <rlaager@pidgin.im>
diff
changeset
|
1333 | xep_bytestreams_parse(gc, packet, pb); |
|
21524
472e58992083
Patch from some Intel folks to implement file transfer in Bonjour using XEP-0096 and 0065. This hopefully will work with Gaijm (haven't yet tested) and, of course, between libpurple instances; it will not work with Adium or iChat.
Daniel Atallah <datallah@pidgin.im>
parents:
21503
diff
changeset
|
1334 | } |
|
472e58992083
Patch from some Intel folks to implement file transfer in Bonjour using XEP-0096 and 0065. This hopefully will work with Gaijm (haven't yet tested) and, of course, between libpurple instances; it will not work with Adium or iChat.
Daniel Atallah <datallah@pidgin.im>
parents:
21503
diff
changeset
|
1335 | |
|
472e58992083
Patch from some Intel folks to implement file transfer in Bonjour using XEP-0096 and 0065. This hopefully will work with Gaijm (haven't yet tested) and, of course, between libpurple instances; it will not work with Adium or iChat.
Daniel Atallah <datallah@pidgin.im>
parents:
21503
diff
changeset
|
1336 | int |
|
21548
b19c433f5af2
Cleanup and fix the socks5 proxy connect address to be correct.
Daniel Atallah <datallah@pidgin.im>
parents:
21547
diff
changeset
|
1337 | xep_iq_send_and_free(XepIq *iq) |
|
21524
472e58992083
Patch from some Intel folks to implement file transfer in Bonjour using XEP-0096 and 0065. This hopefully will work with Gaijm (haven't yet tested) and, of course, between libpurple instances; it will not work with Adium or iChat.
Daniel Atallah <datallah@pidgin.im>
parents:
21503
diff
changeset
|
1338 | { |
|
472e58992083
Patch from some Intel folks to implement file transfer in Bonjour using XEP-0096 and 0065. This hopefully will work with Gaijm (haven't yet tested) and, of course, between libpurple instances; it will not work with Adium or iChat.
Daniel Atallah <datallah@pidgin.im>
parents:
21503
diff
changeset
|
1339 | int ret = -1; |
|
472e58992083
Patch from some Intel folks to implement file transfer in Bonjour using XEP-0096 and 0065. This hopefully will work with Gaijm (haven't yet tested) and, of course, between libpurple instances; it will not work with Adium or iChat.
Daniel Atallah <datallah@pidgin.im>
parents:
21503
diff
changeset
|
1340 | PurpleBuddy *pb = NULL; |
|
21528
06532211eb62
Leak fix, cleanup and code reuse.
Daniel Atallah <datallah@pidgin.im>
parents:
21527
diff
changeset
|
1341 | |
|
21524
472e58992083
Patch from some Intel folks to implement file transfer in Bonjour using XEP-0096 and 0065. This hopefully will work with Gaijm (haven't yet tested) and, of course, between libpurple instances; it will not work with Adium or iChat.
Daniel Atallah <datallah@pidgin.im>
parents:
21503
diff
changeset
|
1342 | /* start the talk, reuse the message socket */ |
|
21944
c41d17a1b8d9
This is the second part of the fix to support having multiple presence records in Bonjour (and also supporting multiple presences using the same IP). Incoming conversations are no longer immediately attached to a buddy - we use an algorithm to match a conversation to a buddy based on the IP and, if possible the "from" attribute of the stream or the first tag in the stream. Thanks to Sjoerd Simons from Telepahy Salut for noticing and suggesting the algorithm. Fixes #4187. It'd be good if a few people test this.
Daniel Atallah <datallah@pidgin.im>
parents:
21936
diff
changeset
|
1343 | pb = _find_or_start_conversation((BonjourJabber*) iq->data, iq->to); |
|
21524
472e58992083
Patch from some Intel folks to implement file transfer in Bonjour using XEP-0096 and 0065. This hopefully will work with Gaijm (haven't yet tested) and, of course, between libpurple instances; it will not work with Adium or iChat.
Daniel Atallah <datallah@pidgin.im>
parents:
21503
diff
changeset
|
1344 | /* Send the message */ |
|
21528
06532211eb62
Leak fix, cleanup and code reuse.
Daniel Atallah <datallah@pidgin.im>
parents:
21527
diff
changeset
|
1345 | if (pb != NULL) { |
|
06532211eb62
Leak fix, cleanup and code reuse.
Daniel Atallah <datallah@pidgin.im>
parents:
21527
diff
changeset
|
1346 | /* Convert xml node into stream */ |
|
34935
686fa55b0deb
Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents:
34911
diff
changeset
|
1347 | gchar *msg = purple_xmlnode_to_str(iq->node, NULL); |
|
21524
472e58992083
Patch from some Intel folks to implement file transfer in Bonjour using XEP-0096 and 0065. This hopefully will work with Gaijm (haven't yet tested) and, of course, between libpurple instances; it will not work with Adium or iChat.
Daniel Atallah <datallah@pidgin.im>
parents:
21503
diff
changeset
|
1348 | ret = _send_data(pb, msg); |
|
21528
06532211eb62
Leak fix, cleanup and code reuse.
Daniel Atallah <datallah@pidgin.im>
parents:
21527
diff
changeset
|
1349 | g_free(msg); |
|
06532211eb62
Leak fix, cleanup and code reuse.
Daniel Atallah <datallah@pidgin.im>
parents:
21527
diff
changeset
|
1350 | } |
|
21548
b19c433f5af2
Cleanup and fix the socks5 proxy connect address to be correct.
Daniel Atallah <datallah@pidgin.im>
parents:
21547
diff
changeset
|
1351 | |
|
34935
686fa55b0deb
Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents:
34911
diff
changeset
|
1352 | purple_xmlnode_free(iq->node); |
|
21548
b19c433f5af2
Cleanup and fix the socks5 proxy connect address to be correct.
Daniel Atallah <datallah@pidgin.im>
parents:
21547
diff
changeset
|
1353 | iq->node = NULL; |
|
b19c433f5af2
Cleanup and fix the socks5 proxy connect address to be correct.
Daniel Atallah <datallah@pidgin.im>
parents:
21547
diff
changeset
|
1354 | g_free(iq); |
|
21528
06532211eb62
Leak fix, cleanup and code reuse.
Daniel Atallah <datallah@pidgin.im>
parents:
21527
diff
changeset
|
1355 | |
|
06532211eb62
Leak fix, cleanup and code reuse.
Daniel Atallah <datallah@pidgin.im>
parents:
21527
diff
changeset
|
1356 | return (ret >= 0) ? 0 : -1; |
|
21524
472e58992083
Patch from some Intel folks to implement file transfer in Bonjour using XEP-0096 and 0065. This hopefully will work with Gaijm (haven't yet tested) and, of course, between libpurple instances; it will not work with Adium or iChat.
Daniel Atallah <datallah@pidgin.im>
parents:
21503
diff
changeset
|
1357 | } |
|
472e58992083
Patch from some Intel folks to implement file transfer in Bonjour using XEP-0096 and 0065. This hopefully will work with Gaijm (haven't yet tested) and, of course, between libpurple instances; it will not work with Adium or iChat.
Daniel Atallah <datallah@pidgin.im>
parents:
21503
diff
changeset
|
1358 | |
|
29761
0f6862f2782f
Implementation of IPv6 support for Bonjour
Daniel Atallah <datallah@pidgin.im>
parents:
27625
diff
changeset
|
1359 | /* This returns a list containing all non-localhost IPs */ |
|
0f6862f2782f
Implementation of IPv6 support for Bonjour
Daniel Atallah <datallah@pidgin.im>
parents:
27625
diff
changeset
|
1360 | GSList * |
|
0f6862f2782f
Implementation of IPv6 support for Bonjour
Daniel Atallah <datallah@pidgin.im>
parents:
27625
diff
changeset
|
1361 | bonjour_jabber_get_local_ips(int fd) |
|
21524
472e58992083
Patch from some Intel folks to implement file transfer in Bonjour using XEP-0096 and 0065. This hopefully will work with Gaijm (haven't yet tested) and, of course, between libpurple instances; it will not work with Adium or iChat.
Daniel Atallah <datallah@pidgin.im>
parents:
21503
diff
changeset
|
1362 | { |
|
29761
0f6862f2782f
Implementation of IPv6 support for Bonjour
Daniel Atallah <datallah@pidgin.im>
parents:
27625
diff
changeset
|
1363 | GSList *ips = NULL; |
|
0f6862f2782f
Implementation of IPv6 support for Bonjour
Daniel Atallah <datallah@pidgin.im>
parents:
27625
diff
changeset
|
1364 | const char *address_text; |
|
0f6862f2782f
Implementation of IPv6 support for Bonjour
Daniel Atallah <datallah@pidgin.im>
parents:
27625
diff
changeset
|
1365 | int ret; |
|
0f6862f2782f
Implementation of IPv6 support for Bonjour
Daniel Atallah <datallah@pidgin.im>
parents:
27625
diff
changeset
|
1366 | |
|
0f6862f2782f
Implementation of IPv6 support for Bonjour
Daniel Atallah <datallah@pidgin.im>
parents:
27625
diff
changeset
|
1367 | #ifdef HAVE_GETIFADDRS /* This is required for IPv6 */ |
|
0f6862f2782f
Implementation of IPv6 support for Bonjour
Daniel Atallah <datallah@pidgin.im>
parents:
27625
diff
changeset
|
1368 | { |
|
0f6862f2782f
Implementation of IPv6 support for Bonjour
Daniel Atallah <datallah@pidgin.im>
parents:
27625
diff
changeset
|
1369 | struct ifaddrs *ifap, *ifa; |
|
0f6862f2782f
Implementation of IPv6 support for Bonjour
Daniel Atallah <datallah@pidgin.im>
parents:
27625
diff
changeset
|
1370 | struct sockaddr *addr; |
|
0f6862f2782f
Implementation of IPv6 support for Bonjour
Daniel Atallah <datallah@pidgin.im>
parents:
27625
diff
changeset
|
1371 | char addrstr[INET6_ADDRSTRLEN]; |
|
0f6862f2782f
Implementation of IPv6 support for Bonjour
Daniel Atallah <datallah@pidgin.im>
parents:
27625
diff
changeset
|
1372 | |
|
0f6862f2782f
Implementation of IPv6 support for Bonjour
Daniel Atallah <datallah@pidgin.im>
parents:
27625
diff
changeset
|
1373 | ret = getifaddrs(&ifap); |
|
0f6862f2782f
Implementation of IPv6 support for Bonjour
Daniel Atallah <datallah@pidgin.im>
parents:
27625
diff
changeset
|
1374 | if (ret != 0) { |
|
0f6862f2782f
Implementation of IPv6 support for Bonjour
Daniel Atallah <datallah@pidgin.im>
parents:
27625
diff
changeset
|
1375 | const char *error = g_strerror(errno); |
|
0f6862f2782f
Implementation of IPv6 support for Bonjour
Daniel Atallah <datallah@pidgin.im>
parents:
27625
diff
changeset
|
1376 | purple_debug_error("bonjour", "getifaddrs() error: %s\n", error ? error : "(null)"); |
|
0f6862f2782f
Implementation of IPv6 support for Bonjour
Daniel Atallah <datallah@pidgin.im>
parents:
27625
diff
changeset
|
1377 | return NULL; |
|
0f6862f2782f
Implementation of IPv6 support for Bonjour
Daniel Atallah <datallah@pidgin.im>
parents:
27625
diff
changeset
|
1378 | } |
|
0f6862f2782f
Implementation of IPv6 support for Bonjour
Daniel Atallah <datallah@pidgin.im>
parents:
27625
diff
changeset
|
1379 | |
|
0f6862f2782f
Implementation of IPv6 support for Bonjour
Daniel Atallah <datallah@pidgin.im>
parents:
27625
diff
changeset
|
1380 | for (ifa = ifap; ifa != NULL; ifa = ifa->ifa_next) { |
|
0f6862f2782f
Implementation of IPv6 support for Bonjour
Daniel Atallah <datallah@pidgin.im>
parents:
27625
diff
changeset
|
1381 | if (!(ifa->ifa_flags & IFF_RUNNING) || (ifa->ifa_flags & IFF_LOOPBACK) || ifa->ifa_addr == NULL) |
|
0f6862f2782f
Implementation of IPv6 support for Bonjour
Daniel Atallah <datallah@pidgin.im>
parents:
27625
diff
changeset
|
1382 | continue; |
|
0f6862f2782f
Implementation of IPv6 support for Bonjour
Daniel Atallah <datallah@pidgin.im>
parents:
27625
diff
changeset
|
1383 | |
|
0f6862f2782f
Implementation of IPv6 support for Bonjour
Daniel Atallah <datallah@pidgin.im>
parents:
27625
diff
changeset
|
1384 | addr = ifa->ifa_addr; |
|
0f6862f2782f
Implementation of IPv6 support for Bonjour
Daniel Atallah <datallah@pidgin.im>
parents:
27625
diff
changeset
|
1385 | address_text = NULL; |
|
0f6862f2782f
Implementation of IPv6 support for Bonjour
Daniel Atallah <datallah@pidgin.im>
parents:
27625
diff
changeset
|
1386 | switch (addr->sa_family) { |
|
0f6862f2782f
Implementation of IPv6 support for Bonjour
Daniel Atallah <datallah@pidgin.im>
parents:
27625
diff
changeset
|
1387 | case AF_INET: |
|
0f6862f2782f
Implementation of IPv6 support for Bonjour
Daniel Atallah <datallah@pidgin.im>
parents:
27625
diff
changeset
|
1388 | address_text = inet_ntop(addr->sa_family, &((struct sockaddr_in *)addr)->sin_addr, |
|
0f6862f2782f
Implementation of IPv6 support for Bonjour
Daniel Atallah <datallah@pidgin.im>
parents:
27625
diff
changeset
|
1389 | addrstr, sizeof(addrstr)); |
|
0f6862f2782f
Implementation of IPv6 support for Bonjour
Daniel Atallah <datallah@pidgin.im>
parents:
27625
diff
changeset
|
1390 | break; |
|
0f6862f2782f
Implementation of IPv6 support for Bonjour
Daniel Atallah <datallah@pidgin.im>
parents:
27625
diff
changeset
|
1391 | #ifdef PF_INET6 |
|
0f6862f2782f
Implementation of IPv6 support for Bonjour
Daniel Atallah <datallah@pidgin.im>
parents:
27625
diff
changeset
|
1392 | case AF_INET6: |
|
0f6862f2782f
Implementation of IPv6 support for Bonjour
Daniel Atallah <datallah@pidgin.im>
parents:
27625
diff
changeset
|
1393 | address_text = inet_ntop(addr->sa_family, &((struct sockaddr_in6 *)addr)->sin6_addr, |
|
0f6862f2782f
Implementation of IPv6 support for Bonjour
Daniel Atallah <datallah@pidgin.im>
parents:
27625
diff
changeset
|
1394 | addrstr, sizeof(addrstr)); |
|
0f6862f2782f
Implementation of IPv6 support for Bonjour
Daniel Atallah <datallah@pidgin.im>
parents:
27625
diff
changeset
|
1395 | break; |
|
0f6862f2782f
Implementation of IPv6 support for Bonjour
Daniel Atallah <datallah@pidgin.im>
parents:
27625
diff
changeset
|
1396 | #endif |
|
0f6862f2782f
Implementation of IPv6 support for Bonjour
Daniel Atallah <datallah@pidgin.im>
parents:
27625
diff
changeset
|
1397 | } |
|
0f6862f2782f
Implementation of IPv6 support for Bonjour
Daniel Atallah <datallah@pidgin.im>
parents:
27625
diff
changeset
|
1398 | |
|
0f6862f2782f
Implementation of IPv6 support for Bonjour
Daniel Atallah <datallah@pidgin.im>
parents:
27625
diff
changeset
|
1399 | if (address_text != NULL) { |
|
0f6862f2782f
Implementation of IPv6 support for Bonjour
Daniel Atallah <datallah@pidgin.im>
parents:
27625
diff
changeset
|
1400 | if (addr->sa_family == AF_INET) |
|
0f6862f2782f
Implementation of IPv6 support for Bonjour
Daniel Atallah <datallah@pidgin.im>
parents:
27625
diff
changeset
|
1401 | ips = g_slist_append(ips, g_strdup(address_text)); |
|
0f6862f2782f
Implementation of IPv6 support for Bonjour
Daniel Atallah <datallah@pidgin.im>
parents:
27625
diff
changeset
|
1402 | else |
|
0f6862f2782f
Implementation of IPv6 support for Bonjour
Daniel Atallah <datallah@pidgin.im>
parents:
27625
diff
changeset
|
1403 | ips = g_slist_prepend(ips, g_strdup(address_text)); |
|
0f6862f2782f
Implementation of IPv6 support for Bonjour
Daniel Atallah <datallah@pidgin.im>
parents:
27625
diff
changeset
|
1404 | } |
|
0f6862f2782f
Implementation of IPv6 support for Bonjour
Daniel Atallah <datallah@pidgin.im>
parents:
27625
diff
changeset
|
1405 | } |
|
0f6862f2782f
Implementation of IPv6 support for Bonjour
Daniel Atallah <datallah@pidgin.im>
parents:
27625
diff
changeset
|
1406 | |
|
0f6862f2782f
Implementation of IPv6 support for Bonjour
Daniel Atallah <datallah@pidgin.im>
parents:
27625
diff
changeset
|
1407 | freeifaddrs(ifap); |
|
0f6862f2782f
Implementation of IPv6 support for Bonjour
Daniel Atallah <datallah@pidgin.im>
parents:
27625
diff
changeset
|
1408 | |
|
0f6862f2782f
Implementation of IPv6 support for Bonjour
Daniel Atallah <datallah@pidgin.im>
parents:
27625
diff
changeset
|
1409 | } |
|
0f6862f2782f
Implementation of IPv6 support for Bonjour
Daniel Atallah <datallah@pidgin.im>
parents:
27625
diff
changeset
|
1410 | #else |
|
0f6862f2782f
Implementation of IPv6 support for Bonjour
Daniel Atallah <datallah@pidgin.im>
parents:
27625
diff
changeset
|
1411 | { |
|
21524
472e58992083
Patch from some Intel folks to implement file transfer in Bonjour using XEP-0096 and 0065. This hopefully will work with Gaijm (haven't yet tested) and, of course, between libpurple instances; it will not work with Adium or iChat.
Daniel Atallah <datallah@pidgin.im>
parents:
21503
diff
changeset
|
1412 | char *tmp; |
|
472e58992083
Patch from some Intel folks to implement file transfer in Bonjour using XEP-0096 and 0065. This hopefully will work with Gaijm (haven't yet tested) and, of course, between libpurple instances; it will not work with Adium or iChat.
Daniel Atallah <datallah@pidgin.im>
parents:
21503
diff
changeset
|
1413 | struct ifconf ifc; |
|
472e58992083
Patch from some Intel folks to implement file transfer in Bonjour using XEP-0096 and 0065. This hopefully will work with Gaijm (haven't yet tested) and, of course, between libpurple instances; it will not work with Adium or iChat.
Daniel Atallah <datallah@pidgin.im>
parents:
21503
diff
changeset
|
1414 | struct ifreq *ifr; |
|
29761
0f6862f2782f
Implementation of IPv6 support for Bonjour
Daniel Atallah <datallah@pidgin.im>
parents:
27625
diff
changeset
|
1415 | char buffer[1024]; |
|
21524
472e58992083
Patch from some Intel folks to implement file transfer in Bonjour using XEP-0096 and 0065. This hopefully will work with Gaijm (haven't yet tested) and, of course, between libpurple instances; it will not work with Adium or iChat.
Daniel Atallah <datallah@pidgin.im>
parents:
21503
diff
changeset
|
1416 | struct sockaddr_in *sinptr; |
|
472e58992083
Patch from some Intel folks to implement file transfer in Bonjour using XEP-0096 and 0065. This hopefully will work with Gaijm (haven't yet tested) and, of course, between libpurple instances; it will not work with Adium or iChat.
Daniel Atallah <datallah@pidgin.im>
parents:
21503
diff
changeset
|
1417 | int source = fd; |
|
472e58992083
Patch from some Intel folks to implement file transfer in Bonjour using XEP-0096 and 0065. This hopefully will work with Gaijm (haven't yet tested) and, of course, between libpurple instances; it will not work with Adium or iChat.
Daniel Atallah <datallah@pidgin.im>
parents:
21503
diff
changeset
|
1418 | |
|
472e58992083
Patch from some Intel folks to implement file transfer in Bonjour using XEP-0096 and 0065. This hopefully will work with Gaijm (haven't yet tested) and, of course, between libpurple instances; it will not work with Adium or iChat.
Daniel Atallah <datallah@pidgin.im>
parents:
21503
diff
changeset
|
1419 | if (fd < 0) |
|
472e58992083
Patch from some Intel folks to implement file transfer in Bonjour using XEP-0096 and 0065. This hopefully will work with Gaijm (haven't yet tested) and, of course, between libpurple instances; it will not work with Adium or iChat.
Daniel Atallah <datallah@pidgin.im>
parents:
21503
diff
changeset
|
1420 | source = socket(PF_INET, SOCK_STREAM, 0); |
|
472e58992083
Patch from some Intel folks to implement file transfer in Bonjour using XEP-0096 and 0065. This hopefully will work with Gaijm (haven't yet tested) and, of course, between libpurple instances; it will not work with Adium or iChat.
Daniel Atallah <datallah@pidgin.im>
parents:
21503
diff
changeset
|
1421 | |
|
472e58992083
Patch from some Intel folks to implement file transfer in Bonjour using XEP-0096 and 0065. This hopefully will work with Gaijm (haven't yet tested) and, of course, between libpurple instances; it will not work with Adium or iChat.
Daniel Atallah <datallah@pidgin.im>
parents:
21503
diff
changeset
|
1422 | ifc.ifc_len = sizeof(buffer); |
|
472e58992083
Patch from some Intel folks to implement file transfer in Bonjour using XEP-0096 and 0065. This hopefully will work with Gaijm (haven't yet tested) and, of course, between libpurple instances; it will not work with Adium or iChat.
Daniel Atallah <datallah@pidgin.im>
parents:
21503
diff
changeset
|
1423 | ifc.ifc_req = (struct ifreq *)buffer; |
|
29761
0f6862f2782f
Implementation of IPv6 support for Bonjour
Daniel Atallah <datallah@pidgin.im>
parents:
27625
diff
changeset
|
1424 | ret = ioctl(source, SIOCGIFCONF, &ifc); |
|
21524
472e58992083
Patch from some Intel folks to implement file transfer in Bonjour using XEP-0096 and 0065. This hopefully will work with Gaijm (haven't yet tested) and, of course, between libpurple instances; it will not work with Adium or iChat.
Daniel Atallah <datallah@pidgin.im>
parents:
21503
diff
changeset
|
1425 | |
|
472e58992083
Patch from some Intel folks to implement file transfer in Bonjour using XEP-0096 and 0065. This hopefully will work with Gaijm (haven't yet tested) and, of course, between libpurple instances; it will not work with Adium or iChat.
Daniel Atallah <datallah@pidgin.im>
parents:
21503
diff
changeset
|
1426 | if (fd < 0) |
|
472e58992083
Patch from some Intel folks to implement file transfer in Bonjour using XEP-0096 and 0065. This hopefully will work with Gaijm (haven't yet tested) and, of course, between libpurple instances; it will not work with Adium or iChat.
Daniel Atallah <datallah@pidgin.im>
parents:
21503
diff
changeset
|
1427 | close(source); |
|
21527
fe89b20df0f7
I thought I was just fixing a leak in this commit, but it turns out I forgot to add the new files in the previous commit.
Daniel Atallah <datallah@pidgin.im>
parents:
21524
diff
changeset
|
1428 | |
|
29761
0f6862f2782f
Implementation of IPv6 support for Bonjour
Daniel Atallah <datallah@pidgin.im>
parents:
27625
diff
changeset
|
1429 | if (ret < 0) { |
|
0f6862f2782f
Implementation of IPv6 support for Bonjour
Daniel Atallah <datallah@pidgin.im>
parents:
27625
diff
changeset
|
1430 | const char *error = g_strerror(errno); |
|
0f6862f2782f
Implementation of IPv6 support for Bonjour
Daniel Atallah <datallah@pidgin.im>
parents:
27625
diff
changeset
|
1431 | purple_debug_error("bonjour", "ioctl(SIOCGIFCONF) error: %s\n", error ? error : "(null)"); |
|
0f6862f2782f
Implementation of IPv6 support for Bonjour
Daniel Atallah <datallah@pidgin.im>
parents:
27625
diff
changeset
|
1432 | return NULL; |
|
0f6862f2782f
Implementation of IPv6 support for Bonjour
Daniel Atallah <datallah@pidgin.im>
parents:
27625
diff
changeset
|
1433 | } |
|
0f6862f2782f
Implementation of IPv6 support for Bonjour
Daniel Atallah <datallah@pidgin.im>
parents:
27625
diff
changeset
|
1434 | |
|
21524
472e58992083
Patch from some Intel folks to implement file transfer in Bonjour using XEP-0096 and 0065. This hopefully will work with Gaijm (haven't yet tested) and, of course, between libpurple instances; it will not work with Adium or iChat.
Daniel Atallah <datallah@pidgin.im>
parents:
21503
diff
changeset
|
1435 | tmp = buffer; |
|
29761
0f6862f2782f
Implementation of IPv6 support for Bonjour
Daniel Atallah <datallah@pidgin.im>
parents:
27625
diff
changeset
|
1436 | while (tmp < buffer + ifc.ifc_len) { |
|
21524
472e58992083
Patch from some Intel folks to implement file transfer in Bonjour using XEP-0096 and 0065. This hopefully will work with Gaijm (haven't yet tested) and, of course, between libpurple instances; it will not work with Adium or iChat.
Daniel Atallah <datallah@pidgin.im>
parents:
21503
diff
changeset
|
1437 | ifr = (struct ifreq *)tmp; |
|
472e58992083
Patch from some Intel folks to implement file transfer in Bonjour using XEP-0096 and 0065. This hopefully will work with Gaijm (haven't yet tested) and, of course, between libpurple instances; it will not work with Adium or iChat.
Daniel Atallah <datallah@pidgin.im>
parents:
21503
diff
changeset
|
1438 | tmp += HX_SIZE_OF_IFREQ(*ifr); |
|
472e58992083
Patch from some Intel folks to implement file transfer in Bonjour using XEP-0096 and 0065. This hopefully will work with Gaijm (haven't yet tested) and, of course, between libpurple instances; it will not work with Adium or iChat.
Daniel Atallah <datallah@pidgin.im>
parents:
21503
diff
changeset
|
1439 | |
|
29761
0f6862f2782f
Implementation of IPv6 support for Bonjour
Daniel Atallah <datallah@pidgin.im>
parents:
27625
diff
changeset
|
1440 | if (ifr->ifr_addr.sa_family == AF_INET) { |
|
21524
472e58992083
Patch from some Intel folks to implement file transfer in Bonjour using XEP-0096 and 0065. This hopefully will work with Gaijm (haven't yet tested) and, of course, between libpurple instances; it will not work with Adium or iChat.
Daniel Atallah <datallah@pidgin.im>
parents:
21503
diff
changeset
|
1441 | sinptr = (struct sockaddr_in *)&ifr->ifr_addr; |
|
29761
0f6862f2782f
Implementation of IPv6 support for Bonjour
Daniel Atallah <datallah@pidgin.im>
parents:
27625
diff
changeset
|
1442 | if ((ntohl(sinptr->sin_addr.s_addr) >> 24) != 127) { |
|
0f6862f2782f
Implementation of IPv6 support for Bonjour
Daniel Atallah <datallah@pidgin.im>
parents:
27625
diff
changeset
|
1443 | address_text = inet_ntoa(sinptr->sin_addr); |
|
0f6862f2782f
Implementation of IPv6 support for Bonjour
Daniel Atallah <datallah@pidgin.im>
parents:
27625
diff
changeset
|
1444 | ips = g_slist_prepend(ips, g_strdup(address_text)); |
|
21524
472e58992083
Patch from some Intel folks to implement file transfer in Bonjour using XEP-0096 and 0065. This hopefully will work with Gaijm (haven't yet tested) and, of course, between libpurple instances; it will not work with Adium or iChat.
Daniel Atallah <datallah@pidgin.im>
parents:
21503
diff
changeset
|
1445 | } |
|
29761
0f6862f2782f
Implementation of IPv6 support for Bonjour
Daniel Atallah <datallah@pidgin.im>
parents:
27625
diff
changeset
|
1446 | } |
|
21524
472e58992083
Patch from some Intel folks to implement file transfer in Bonjour using XEP-0096 and 0065. This hopefully will work with Gaijm (haven't yet tested) and, of course, between libpurple instances; it will not work with Adium or iChat.
Daniel Atallah <datallah@pidgin.im>
parents:
21503
diff
changeset
|
1447 | } |
|
29761
0f6862f2782f
Implementation of IPv6 support for Bonjour
Daniel Atallah <datallah@pidgin.im>
parents:
27625
diff
changeset
|
1448 | } |
|
0f6862f2782f
Implementation of IPv6 support for Bonjour
Daniel Atallah <datallah@pidgin.im>
parents:
27625
diff
changeset
|
1449 | #endif |
|
21524
472e58992083
Patch from some Intel folks to implement file transfer in Bonjour using XEP-0096 and 0065. This hopefully will work with Gaijm (haven't yet tested) and, of course, between libpurple instances; it will not work with Adium or iChat.
Daniel Atallah <datallah@pidgin.im>
parents:
21503
diff
changeset
|
1450 | |
|
29761
0f6862f2782f
Implementation of IPv6 support for Bonjour
Daniel Atallah <datallah@pidgin.im>
parents:
27625
diff
changeset
|
1451 | return ips; |
|
21524
472e58992083
Patch from some Intel folks to implement file transfer in Bonjour using XEP-0096 and 0065. This hopefully will work with Gaijm (haven't yet tested) and, of course, between libpurple instances; it will not work with Adium or iChat.
Daniel Atallah <datallah@pidgin.im>
parents:
21503
diff
changeset
|
1452 | } |
|
32058
95953bd2f239
Append interface ID only to local interfaces for IPv6 Bonjour.
Linus Lüssing <linus.luessing@web.de>
parents:
31749
diff
changeset
|
1453 | |
|
95953bd2f239
Append interface ID only to local interfaces for IPv6 Bonjour.
Linus Lüssing <linus.luessing@web.de>
parents:
31749
diff
changeset
|
1454 | void |
|
32069
fc06dd6b7c3f
Fix the compilation of the Bonjour prpl on Windows.
Eion Robb <eion@robbmob.com>
parents:
32058
diff
changeset
|
1455 | append_iface_if_linklocal(char *ip, guint32 interface_param) { |
|
32058
95953bd2f239
Append interface ID only to local interfaces for IPv6 Bonjour.
Linus Lüssing <linus.luessing@web.de>
parents:
31749
diff
changeset
|
1456 | struct in6_addr in6_addr; |
|
95953bd2f239
Append interface ID only to local interfaces for IPv6 Bonjour.
Linus Lüssing <linus.luessing@web.de>
parents:
31749
diff
changeset
|
1457 | int len_remain = INET6_ADDRSTRLEN - strlen(ip); |
|
95953bd2f239
Append interface ID only to local interfaces for IPv6 Bonjour.
Linus Lüssing <linus.luessing@web.de>
parents:
31749
diff
changeset
|
1458 | |
|
95953bd2f239
Append interface ID only to local interfaces for IPv6 Bonjour.
Linus Lüssing <linus.luessing@web.de>
parents:
31749
diff
changeset
|
1459 | if (len_remain <= 1) |
|
95953bd2f239
Append interface ID only to local interfaces for IPv6 Bonjour.
Linus Lüssing <linus.luessing@web.de>
parents:
31749
diff
changeset
|
1460 | return; |
|
95953bd2f239
Append interface ID only to local interfaces for IPv6 Bonjour.
Linus Lüssing <linus.luessing@web.de>
parents:
31749
diff
changeset
|
1461 | |
|
95953bd2f239
Append interface ID only to local interfaces for IPv6 Bonjour.
Linus Lüssing <linus.luessing@web.de>
parents:
31749
diff
changeset
|
1462 | if (inet_pton(AF_INET6, ip, &in6_addr) != 1 || |
|
95953bd2f239
Append interface ID only to local interfaces for IPv6 Bonjour.
Linus Lüssing <linus.luessing@web.de>
parents:
31749
diff
changeset
|
1463 | !IN6_IS_ADDR_LINKLOCAL(&in6_addr)) |
|
95953bd2f239
Append interface ID only to local interfaces for IPv6 Bonjour.
Linus Lüssing <linus.luessing@web.de>
parents:
31749
diff
changeset
|
1464 | return; |
|
95953bd2f239
Append interface ID only to local interfaces for IPv6 Bonjour.
Linus Lüssing <linus.luessing@web.de>
parents:
31749
diff
changeset
|
1465 | |
|
95953bd2f239
Append interface ID only to local interfaces for IPv6 Bonjour.
Linus Lüssing <linus.luessing@web.de>
parents:
31749
diff
changeset
|
1466 | snprintf(ip + strlen(ip), len_remain, "%%%d", |
|
32069
fc06dd6b7c3f
Fix the compilation of the Bonjour prpl on Windows.
Eion Robb <eion@robbmob.com>
parents:
32058
diff
changeset
|
1467 | interface_param); |
|
32058
95953bd2f239
Append interface ID only to local interfaces for IPv6 Bonjour.
Linus Lüssing <linus.luessing@web.de>
parents:
31749
diff
changeset
|
1468 | } |