libpurple/protocols/bonjour/jabber.c

Sat, 19 Jul 2008 00:18:18 +0000

author
Daniel Atallah <datallah@pidgin.im>
date
Sat, 19 Jul 2008 00:18:18 +0000
changeset 23883
222e2f637efd
parent 23160
0aff8f3882f4
child 24039
8173b6258f5a
permissions
-rw-r--r--

Fix running several Bonjour instances on the same machine.
The server socket had SO_REUSEADDR set, which was causing all the instances to
share the same port (and therefore it was indeterminate who would actually get
the incoming connection).
Fixes #6231

11477
98b4f8643569 [gaim-migrate @ 13719]
Mark Doliner <markdoliner@pidgin.im>
parents:
diff changeset
1 /*
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15873
diff changeset
2 * purple - Bonjour Protocol Plugin
11477
98b4f8643569 [gaim-migrate @ 13719]
Mark Doliner <markdoliner@pidgin.im>
parents:
diff changeset
3 *
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15873
diff changeset
4 * Purple is the legal property of its developers, whose names are too numerous
11477
98b4f8643569 [gaim-migrate @ 13719]
Mark Doliner <markdoliner@pidgin.im>
parents:
diff changeset
5 * to list here. Please refer to the COPYRIGHT file distributed with this
98b4f8643569 [gaim-migrate @ 13719]
Mark Doliner <markdoliner@pidgin.im>
parents:
diff changeset
6 * source distribution.
98b4f8643569 [gaim-migrate @ 13719]
Mark Doliner <markdoliner@pidgin.im>
parents:
diff changeset
7 *
98b4f8643569 [gaim-migrate @ 13719]
Mark Doliner <markdoliner@pidgin.im>
parents:
diff changeset
8 * This program is free software; you can redistribute it and/or modify
98b4f8643569 [gaim-migrate @ 13719]
Mark Doliner <markdoliner@pidgin.im>
parents:
diff changeset
9 * it under the terms of the GNU General Public License as published by
98b4f8643569 [gaim-migrate @ 13719]
Mark Doliner <markdoliner@pidgin.im>
parents:
diff changeset
10 * the Free Software Foundation; either version 2 of the License, or
98b4f8643569 [gaim-migrate @ 13719]
Mark Doliner <markdoliner@pidgin.im>
parents:
diff changeset
11 * (at your option) any later version.
98b4f8643569 [gaim-migrate @ 13719]
Mark Doliner <markdoliner@pidgin.im>
parents:
diff changeset
12 *
98b4f8643569 [gaim-migrate @ 13719]
Mark Doliner <markdoliner@pidgin.im>
parents:
diff changeset
13 * This program is distributed in the hope that it will be useful,
98b4f8643569 [gaim-migrate @ 13719]
Mark Doliner <markdoliner@pidgin.im>
parents:
diff changeset
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
98b4f8643569 [gaim-migrate @ 13719]
Mark Doliner <markdoliner@pidgin.im>
parents:
diff changeset
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
98b4f8643569 [gaim-migrate @ 13719]
Mark Doliner <markdoliner@pidgin.im>
parents:
diff changeset
16 * GNU General Public License for more details.
98b4f8643569 [gaim-migrate @ 13719]
Mark Doliner <markdoliner@pidgin.im>
parents:
diff changeset
17 *
98b4f8643569 [gaim-migrate @ 13719]
Mark Doliner <markdoliner@pidgin.im>
parents:
diff changeset
18 * You should have received a copy of the GNU General Public License
98b4f8643569 [gaim-migrate @ 13719]
Mark Doliner <markdoliner@pidgin.im>
parents:
diff changeset
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
98b4f8643569 [gaim-migrate @ 13719]
Mark Doliner <markdoliner@pidgin.im>
parents:
diff changeset
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
98b4f8643569 [gaim-migrate @ 13719]
Mark Doliner <markdoliner@pidgin.im>
parents:
diff changeset
28 #include <sys/socket.h>
98b4f8643569 [gaim-migrate @ 13719]
Mark Doliner <markdoliner@pidgin.im>
parents:
diff changeset
29 #include <netinet/in.h>
98b4f8643569 [gaim-migrate @ 13719]
Mark Doliner <markdoliner@pidgin.im>
parents:
diff changeset
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
7786f5730f36 Fix #4079 for real.
Daniel Atallah <datallah@pidgin.im>
parents: 21913
diff changeset
35
7786f5730f36 Fix #4079 for real.
Daniel Atallah <datallah@pidgin.im>
parents: 21913
diff changeset
36 /* Solaris */
7786f5730f36 Fix #4079 for real.
Daniel Atallah <datallah@pidgin.im>
parents: 21913
diff changeset
37 #if defined (__SVR4) && defined (__sun)
7786f5730f36 Fix #4079 for real.
Daniel Atallah <datallah@pidgin.im>
parents: 21913
diff changeset
38 #include <sys/sockio.h>
7786f5730f36 Fix #4079 for real.
Daniel Atallah <datallah@pidgin.im>
parents: 21913
diff changeset
39 #endif
7786f5730f36 Fix #4079 for real.
Daniel Atallah <datallah@pidgin.im>
parents: 21913
diff changeset
40
11477
98b4f8643569 [gaim-migrate @ 13719]
Mark Doliner <markdoliner@pidgin.im>
parents:
diff changeset
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
98b4f8643569 [gaim-migrate @ 13719]
Mark Doliner <markdoliner@pidgin.im>
parents:
diff changeset
43 #include <unistd.h>
23072
6e7c147d622a Bonjour build fixes for MSVC.
Daniel Atallah <datallah@pidgin.im>
parents: 22824
diff changeset
44 #endif
11477
98b4f8643569 [gaim-migrate @ 13719]
Mark Doliner <markdoliner@pidgin.im>
parents:
diff changeset
45 #include <fcntl.h>
98b4f8643569 [gaim-migrate @ 13719]
Mark Doliner <markdoliner@pidgin.im>
parents:
diff changeset
46
98b4f8643569 [gaim-migrate @ 13719]
Mark Doliner <markdoliner@pidgin.im>
parents:
diff changeset
47 #include "network.h"
98b4f8643569 [gaim-migrate @ 13719]
Mark Doliner <markdoliner@pidgin.im>
parents:
diff changeset
48 #include "eventloop.h"
98b4f8643569 [gaim-migrate @ 13719]
Mark Doliner <markdoliner@pidgin.im>
parents:
diff changeset
49 #include "connection.h"
98b4f8643569 [gaim-migrate @ 13719]
Mark Doliner <markdoliner@pidgin.im>
parents:
diff changeset
50 #include "blist.h"
98b4f8643569 [gaim-migrate @ 13719]
Mark Doliner <markdoliner@pidgin.im>
parents:
diff changeset
51 #include "xmlnode.h"
98b4f8643569 [gaim-migrate @ 13719]
Mark Doliner <markdoliner@pidgin.im>
parents:
diff changeset
52 #include "debug.h"
98b4f8643569 [gaim-migrate @ 13719]
Mark Doliner <markdoliner@pidgin.im>
parents:
diff changeset
53 #include "notify.h"
98b4f8643569 [gaim-migrate @ 13719]
Mark Doliner <markdoliner@pidgin.im>
parents:
diff changeset
54 #include "util.h"
98b4f8643569 [gaim-migrate @ 13719]
Mark Doliner <markdoliner@pidgin.im>
parents:
diff changeset
55
98b4f8643569 [gaim-migrate @ 13719]
Mark Doliner <markdoliner@pidgin.im>
parents:
diff changeset
56 #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
57 #include "parser.h"
11477
98b4f8643569 [gaim-migrate @ 13719]
Mark Doliner <markdoliner@pidgin.im>
parents:
diff changeset
58 #include "bonjour.h"
98b4f8643569 [gaim-migrate @ 13719]
Mark Doliner <markdoliner@pidgin.im>
parents:
diff changeset
59 #include "buddy.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
60 #include "bonjour_ft.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
61
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
62 #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
63 # 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
64 #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
65 # 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
66 #endif
11477
98b4f8643569 [gaim-migrate @ 13719]
Mark Doliner <markdoliner@pidgin.im>
parents:
diff changeset
67
17661
96c6a21c4139 Send 'to' and 'from' attributes in the stream start message.
Daniel Atallah <datallah@pidgin.im>
parents: 17660
diff changeset
68 #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
69 /* 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
70 #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
71 "<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
72
21727
decfc3a613ff applied changes from b9c97ed0f9ada9069e8bd994b01fdde0b484083c
Daniel Atallah <datallah@pidgin.im>
parents: 21720
diff changeset
73 enum sent_stream_start_types {
decfc3a613ff applied changes from b9c97ed0f9ada9069e8bd994b01fdde0b484083c
Daniel Atallah <datallah@pidgin.im>
parents: 21720
diff changeset
74 NOT_SENT = 0,
decfc3a613ff applied changes from b9c97ed0f9ada9069e8bd994b01fdde0b484083c
Daniel Atallah <datallah@pidgin.im>
parents: 21720
diff changeset
75 PARTIALLY_SENT = 1,
decfc3a613ff applied changes from b9c97ed0f9ada9069e8bd994b01fdde0b484083c
Daniel Atallah <datallah@pidgin.im>
parents: 21720
diff changeset
76 FULLY_SENT = 2
decfc3a613ff applied changes from b9c97ed0f9ada9069e8bd994b01fdde0b484083c
Daniel Atallah <datallah@pidgin.im>
parents: 21720
diff changeset
77 };
decfc3a613ff applied changes from b9c97ed0f9ada9069e8bd994b01fdde0b484083c
Daniel Atallah <datallah@pidgin.im>
parents: 21720
diff changeset
78
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
79 static void
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
80 xep_iq_parse(xmlnode *packet, PurpleConnection *connection, 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
81
17662
233ff0515d7b Consolidate BonjourJabberConversation creation and deletion.
Daniel Atallah <datallah@pidgin.im>
parents: 17661
diff changeset
82 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
83 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
84
233ff0515d7b Consolidate BonjourJabberConversation creation and deletion.
Daniel Atallah <datallah@pidgin.im>
parents: 17661
diff changeset
85 BonjourJabberConversation *bconv = g_new0(BonjourJabberConversation, 1);
233ff0515d7b Consolidate BonjourJabberConversation creation and deletion.
Daniel Atallah <datallah@pidgin.im>
parents: 17661
diff changeset
86 bconv->socket = -1;
17665
26bff2090889 Update Bonjour to do nonblocking I/O correctly.
Daniel Atallah <datallah@pidgin.im>
parents: 17663
diff changeset
87 bconv->tx_buf = purple_circ_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
88 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
89 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
90 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
91 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
92 bconv->ip = g_strdup(ip);
17662
233ff0515d7b Consolidate BonjourJabberConversation creation and deletion.
Daniel Atallah <datallah@pidgin.im>
parents: 17661
diff changeset
93
21727
decfc3a613ff applied changes from b9c97ed0f9ada9069e8bd994b01fdde0b484083c
Daniel Atallah <datallah@pidgin.im>
parents: 21720
diff changeset
94 bonjour_parser_setup(bconv);
decfc3a613ff applied changes from b9c97ed0f9ada9069e8bd994b01fdde0b484083c
Daniel Atallah <datallah@pidgin.im>
parents: 21720
diff changeset
95
17662
233ff0515d7b Consolidate BonjourJabberConversation creation and deletion.
Daniel Atallah <datallah@pidgin.im>
parents: 17661
diff changeset
96 return bconv;
233ff0515d7b Consolidate BonjourJabberConversation creation and deletion.
Daniel Atallah <datallah@pidgin.im>
parents: 17661
diff changeset
97 }
233ff0515d7b Consolidate BonjourJabberConversation creation and deletion.
Daniel Atallah <datallah@pidgin.im>
parents: 17661
diff changeset
98
12443
ad94864144f8 [gaim-migrate @ 14750]
Stu Tomlinson <nosnilmot@pidgin.im>
parents: 11830
diff changeset
99 static const char *
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15873
diff changeset
100 _font_size_ichat_to_purple(int size)
11477
98b4f8643569 [gaim-migrate @ 13719]
Mark Doliner <markdoliner@pidgin.im>
parents:
diff changeset
101 {
98b4f8643569 [gaim-migrate @ 13719]
Mark Doliner <markdoliner@pidgin.im>
parents:
diff changeset
102 if (size > 24) {
11826
10ebbc41f163 [gaim-migrate @ 14117]
Richard Laager <rlaager@pidgin.im>
parents: 11823
diff changeset
103 return "7";
11539
fbabe3f89777 [gaim-migrate @ 13794]
Mark Doliner <markdoliner@pidgin.im>
parents: 11515
diff changeset
104 } else if (size >= 21) {
11826
10ebbc41f163 [gaim-migrate @ 14117]
Richard Laager <rlaager@pidgin.im>
parents: 11823
diff changeset
105 return "6";
11539
fbabe3f89777 [gaim-migrate @ 13794]
Mark Doliner <markdoliner@pidgin.im>
parents: 11515
diff changeset
106 } else if (size >= 17) {
11826
10ebbc41f163 [gaim-migrate @ 14117]
Richard Laager <rlaager@pidgin.im>
parents: 11823
diff changeset
107 return "5";
11539
fbabe3f89777 [gaim-migrate @ 13794]
Mark Doliner <markdoliner@pidgin.im>
parents: 11515
diff changeset
108 } else if (size >= 14) {
11826
10ebbc41f163 [gaim-migrate @ 14117]
Richard Laager <rlaager@pidgin.im>
parents: 11823
diff changeset
109 return "4";
11539
fbabe3f89777 [gaim-migrate @ 13794]
Mark Doliner <markdoliner@pidgin.im>
parents: 11515
diff changeset
110 } else if (size >= 12) {
11826
10ebbc41f163 [gaim-migrate @ 14117]
Richard Laager <rlaager@pidgin.im>
parents: 11823
diff changeset
111 return "3";
11539
fbabe3f89777 [gaim-migrate @ 13794]
Mark Doliner <markdoliner@pidgin.im>
parents: 11515
diff changeset
112 } else if (size >= 10) {
11826
10ebbc41f163 [gaim-migrate @ 14117]
Richard Laager <rlaager@pidgin.im>
parents: 11823
diff changeset
113 return "2";
11477
98b4f8643569 [gaim-migrate @ 13719]
Mark Doliner <markdoliner@pidgin.im>
parents:
diff changeset
114 }
98b4f8643569 [gaim-migrate @ 13719]
Mark Doliner <markdoliner@pidgin.im>
parents:
diff changeset
115
11826
10ebbc41f163 [gaim-migrate @ 14117]
Richard Laager <rlaager@pidgin.im>
parents: 11823
diff changeset
116 return "1";
11477
98b4f8643569 [gaim-migrate @ 13719]
Mark Doliner <markdoliner@pidgin.im>
parents:
diff changeset
117 }
17633
b76241c02857 Some more Bonjour cleanup and leak fixing.
Daniel Atallah <datallah@pidgin.im>
parents: 17632
diff changeset
118
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
119 static gchar *
fba8507310d3 Fix an issue with formatting in Bonjour messages. It looks like it has been
Daniel Atallah <datallah@pidgin.im>
parents: 22622
diff changeset
120 get_xmlnode_contents(xmlnode *node)
fba8507310d3 Fix an issue with formatting in Bonjour messages. It looks like it has been
Daniel Atallah <datallah@pidgin.im>
parents: 22622
diff changeset
121 {
fba8507310d3 Fix an issue with formatting in Bonjour messages. It looks like it has been
Daniel Atallah <datallah@pidgin.im>
parents: 22622
diff changeset
122 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
123
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 contents = xmlnode_to_str(node, NULL);
fba8507310d3 Fix an issue with formatting in Bonjour messages. It looks like it has been
Daniel Atallah <datallah@pidgin.im>
parents: 22622
diff changeset
125
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 /* we just want the stuff inside <font></font>
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 * There isn't stuff exposed in xmlnode.c to do this more cleanly. */
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
fba8507310d3 Fix an issue with formatting in Bonjour messages. It looks like it has been
Daniel Atallah <datallah@pidgin.im>
parents: 22622
diff changeset
129 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
130 char *bodystart = strchr(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
131 char *bodyend = strrchr(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
132 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
133 *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
134 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
135 }
fba8507310d3 Fix an issue with formatting in Bonjour messages. It looks like it has been
Daniel Atallah <datallah@pidgin.im>
parents: 22622
diff changeset
136 }
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
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 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
139 }
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
12443
ad94864144f8 [gaim-migrate @ 14750]
Stu Tomlinson <nosnilmot@pidgin.im>
parents: 11830
diff changeset
141 static void
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
142 _jabber_parse_and_write_message_to_ui(xmlnode *message_node, PurpleBuddy *pb)
11477
98b4f8643569 [gaim-migrate @ 13719]
Mark Doliner <markdoliner@pidgin.im>
parents:
diff changeset
143 {
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
144 xmlnode *body_node, *html_node, *events_node;
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
145 PurpleConnection *gc = pb->account->gc;
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
146 gchar *body = NULL;
11477
98b4f8643569 [gaim-migrate @ 13719]
Mark Doliner <markdoliner@pidgin.im>
parents:
diff changeset
147 gboolean composing_event = FALSE;
98b4f8643569 [gaim-migrate @ 13719]
Mark Doliner <markdoliner@pidgin.im>
parents:
diff changeset
148
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
149 body_node = xmlnode_get_child(message_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
150 html_node = xmlnode_get_child(message_node, "html");
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
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
152 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
153 purple_debug_error("bonjour", "No body or html node found, discarding message.\n");
11477
98b4f8643569 [gaim-migrate @ 13719]
Mark Doliner <markdoliner@pidgin.im>
parents:
diff changeset
154 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
155 }
11539
fbabe3f89777 [gaim-migrate @ 13794]
Mark Doliner <markdoliner@pidgin.im>
parents: 11515
diff changeset
156
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
157 events_node = xmlnode_get_child_with_namespace(message_node, "x", "jabber:x:event");
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
158 if (events_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
159 if (xmlnode_get_child(events_node, "composing") != 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
160 composing_event = TRUE;
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
161 if (xmlnode_get_child(events_node, "id") != 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
162 /* 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
163 /* 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
164 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
165 }
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
166 }
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
167
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 if (html_node != NULL) {
17633
b76241c02857 Some more Bonjour cleanup and leak fixing.
Daniel Atallah <datallah@pidgin.im>
parents: 17632
diff changeset
169 xmlnode *html_body_node;
b76241c02857 Some more Bonjour cleanup and leak fixing.
Daniel Atallah <datallah@pidgin.im>
parents: 17632
diff changeset
170
11477
98b4f8643569 [gaim-migrate @ 13719]
Mark Doliner <markdoliner@pidgin.im>
parents:
diff changeset
171 html_body_node = 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
172 if (html_body_node != NULL) {
17633
b76241c02857 Some more Bonjour cleanup and leak fixing.
Daniel Atallah <datallah@pidgin.im>
parents: 17632
diff changeset
173 xmlnode *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
174 const char *ichat_balloon_color = 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
175 const char *ichat_text_color = 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
176 const char *font_face = 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
177 const char *font_size = 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
178 const char *font_color = NULL;
17633
b76241c02857 Some more Bonjour cleanup and leak fixing.
Daniel Atallah <datallah@pidgin.im>
parents: 17632
diff changeset
179
11477
98b4f8643569 [gaim-migrate @ 13719]
Mark Doliner <markdoliner@pidgin.im>
parents:
diff changeset
180 ichat_balloon_color = xmlnode_get_attrib(html_body_node, "ichatballooncolor");
98b4f8643569 [gaim-migrate @ 13719]
Mark Doliner <markdoliner@pidgin.im>
parents:
diff changeset
181 ichat_text_color = xmlnode_get_attrib(html_body_node, "ichattextcolor");
98b4f8643569 [gaim-migrate @ 13719]
Mark Doliner <markdoliner@pidgin.im>
parents:
diff changeset
182 html_body_font_node = 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
183
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 /* 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
185 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
186 gchar *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
187
11477
98b4f8643569 [gaim-migrate @ 13719]
Mark Doliner <markdoliner@pidgin.im>
parents:
diff changeset
188 font_face = 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 */
11477
98b4f8643569 [gaim-migrate @ 13719]
Mark Doliner <markdoliner@pidgin.im>
parents:
diff changeset
190 font_size = 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
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15873
diff changeset
192 font_size = _font_size_ichat_to_purple(atoi(font_size));
11477
98b4f8643569 [gaim-migrate @ 13719]
Mark Doliner <markdoliner@pidgin.im>
parents:
diff changeset
193 font_color = xmlnode_get_attrib(html_body_font_node, "color");
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
194 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
195
11539
fbabe3f89777 [gaim-migrate @ 13794]
Mark Doliner <markdoliner@pidgin.im>
parents: 11515
diff changeset
196 if (html_body == NULL)
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15873
diff changeset
197 /* This is the kind of formated messages that Purple creates */
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
198 html_body = 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
199
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
200 if (html_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
201 /* Use some sane defaults */
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 if (font_face == NULL) font_face = "Helvetica";
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 (font_size == NULL) font_size = "3";
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
204 if (ichat_text_color == NULL) ichat_text_color = "#000000";
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 if (ichat_balloon_color == NULL) ichat_balloon_color = "#FFFFFF";
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
206
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
207 body = g_strdup_printf("<font face='%s' size='%s' color='%s' back='%s'>%s</font>",
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
208 font_face, font_size, ichat_text_color, ichat_balloon_color,
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
209 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
210
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
211 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
212 }
11477
98b4f8643569 [gaim-migrate @ 13719]
Mark Doliner <markdoliner@pidgin.im>
parents:
diff changeset
213 }
98b4f8643569 [gaim-migrate @ 13719]
Mark Doliner <markdoliner@pidgin.im>
parents:
diff changeset
214 }
98b4f8643569 [gaim-migrate @ 13719]
Mark Doliner <markdoliner@pidgin.im>
parents:
diff changeset
215 }
11539
fbabe3f89777 [gaim-migrate @ 13794]
Mark Doliner <markdoliner@pidgin.im>
parents: 11515
diff changeset
216
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
217 /* 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
218 if (body == NULL && body_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
219 body = xmlnode_get_data(body_node);
11539
fbabe3f89777 [gaim-migrate @ 13794]
Mark Doliner <markdoliner@pidgin.im>
parents: 11515
diff changeset
220
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
221 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
222 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
223 return;
11477
98b4f8643569 [gaim-migrate @ 13719]
Mark Doliner <markdoliner@pidgin.im>
parents:
diff changeset
224 }
11539
fbabe3f89777 [gaim-migrate @ 13794]
Mark Doliner <markdoliner@pidgin.im>
parents: 11515
diff changeset
225
11826
10ebbc41f163 [gaim-migrate @ 14117]
Richard Laager <rlaager@pidgin.im>
parents: 11823
diff changeset
226 /* Send the message to the UI */
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
227 serv_got_im(gc, pb->name, body, 0, time(NULL));
11539
fbabe3f89777 [gaim-migrate @ 13794]
Mark Doliner <markdoliner@pidgin.im>
parents: 11515
diff changeset
228
11477
98b4f8643569 [gaim-migrate @ 13719]
Mark Doliner <markdoliner@pidgin.im>
parents:
diff changeset
229 g_free(body);
98b4f8643569 [gaim-migrate @ 13719]
Mark Doliner <markdoliner@pidgin.im>
parents:
diff changeset
230 }
98b4f8643569 [gaim-migrate @ 13719]
Mark Doliner <markdoliner@pidgin.im>
parents:
diff changeset
231
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
232 struct _match_buddies_by_address_t {
17633
b76241c02857 Some more Bonjour cleanup and leak fixing.
Daniel Atallah <datallah@pidgin.im>
parents: 17632
diff changeset
233 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
234 GSList *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
235 BonjourJabber *jdata;
12708
54098581385f [gaim-migrate @ 15052]
Sean Egan <seanegan@pidgin.im>
parents: 12443
diff changeset
236 };
54098581385f [gaim-migrate @ 15052]
Sean Egan <seanegan@pidgin.im>
parents: 12443
diff changeset
237
54098581385f [gaim-migrate @ 15052]
Sean Egan <seanegan@pidgin.im>
parents: 12443
diff changeset
238 static 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
239 _match_buddies_by_address(gpointer key, gpointer value, gpointer data)
11477
98b4f8643569 [gaim-migrate @ 13719]
Mark Doliner <markdoliner@pidgin.im>
parents:
diff changeset
240 {
17661
96c6a21c4139 Send 'to' and 'from' attributes in the stream start message.
Daniel Atallah <datallah@pidgin.im>
parents: 17660
diff changeset
241 PurpleBuddy *pb = value;
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
242 struct _match_buddies_by_address_t *mbba = data;
11539
fbabe3f89777 [gaim-migrate @ 13794]
Mark Doliner <markdoliner@pidgin.im>
parents: 11515
diff changeset
243
13962
71617bf27d00 [gaim-migrate @ 16386]
Jono Cole
parents: 13267
diff changeset
244 /*
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15873
diff changeset
245 * If the current PurpleBuddy's data is not null and the PurpleBuddy's account
13962
71617bf27d00 [gaim-migrate @ 16386]
Jono Cole
parents: 13267
diff changeset
246 * is the same as the account requesting the check 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
247 * whether one of the buddies IPs matches the target IP.
13962
71617bf27d00 [gaim-migrate @ 16386]
Jono Cole
parents: 13267
diff changeset
248 */
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
249 if (mbba->jdata->account == pb->account && pb->proto_data != NULL)
13962
71617bf27d00 [gaim-migrate @ 16386]
Jono Cole
parents: 13267
diff changeset
250 {
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 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
252 BonjourBuddy *bb = pb->proto_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
253 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
254
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
255 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
256 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
257 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
258 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
259 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
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 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
262 }
11477
98b4f8643569 [gaim-migrate @ 13719]
Mark Doliner <markdoliner@pidgin.im>
parents:
diff changeset
263 }
98b4f8643569 [gaim-migrate @ 13719]
Mark Doliner <markdoliner@pidgin.im>
parents:
diff changeset
264 }
98b4f8643569 [gaim-migrate @ 13719]
Mark Doliner <markdoliner@pidgin.im>
parents:
diff changeset
265
17665
26bff2090889 Update Bonjour to do nonblocking I/O correctly.
Daniel Atallah <datallah@pidgin.im>
parents: 17663
diff changeset
266 static void
26bff2090889 Update Bonjour to do nonblocking I/O correctly.
Daniel Atallah <datallah@pidgin.im>
parents: 17663
diff changeset
267 _send_data_write_cb(gpointer data, gint source, PurpleInputCondition cond)
11477
98b4f8643569 [gaim-migrate @ 13719]
Mark Doliner <markdoliner@pidgin.im>
parents:
diff changeset
268 {
17665
26bff2090889 Update Bonjour to do nonblocking I/O correctly.
Daniel Atallah <datallah@pidgin.im>
parents: 17663
diff changeset
269 PurpleBuddy *pb = data;
26bff2090889 Update Bonjour to do nonblocking I/O correctly.
Daniel Atallah <datallah@pidgin.im>
parents: 17663
diff changeset
270 BonjourBuddy *bb = pb->proto_data;
26bff2090889 Update Bonjour to do nonblocking I/O correctly.
Daniel Atallah <datallah@pidgin.im>
parents: 17663
diff changeset
271 BonjourJabberConversation *bconv = bb->conversation;
26bff2090889 Update Bonjour to do nonblocking I/O correctly.
Daniel Atallah <datallah@pidgin.im>
parents: 17663
diff changeset
272 int ret, writelen;
26bff2090889 Update Bonjour to do nonblocking I/O correctly.
Daniel Atallah <datallah@pidgin.im>
parents: 17663
diff changeset
273
26bff2090889 Update Bonjour to do nonblocking I/O correctly.
Daniel Atallah <datallah@pidgin.im>
parents: 17663
diff changeset
274 writelen = purple_circ_buffer_get_max_read(bconv->tx_buf);
26bff2090889 Update Bonjour to do nonblocking I/O correctly.
Daniel Atallah <datallah@pidgin.im>
parents: 17663
diff changeset
275
26bff2090889 Update Bonjour to do nonblocking I/O correctly.
Daniel Atallah <datallah@pidgin.im>
parents: 17663
diff changeset
276 if (writelen == 0) {
26bff2090889 Update Bonjour to do nonblocking I/O correctly.
Daniel Atallah <datallah@pidgin.im>
parents: 17663
diff changeset
277 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
278 bconv->tx_handler = 0;
17665
26bff2090889 Update Bonjour to do nonblocking I/O correctly.
Daniel Atallah <datallah@pidgin.im>
parents: 17663
diff changeset
279 return;
26bff2090889 Update Bonjour to do nonblocking I/O correctly.
Daniel Atallah <datallah@pidgin.im>
parents: 17663
diff changeset
280 }
11539
fbabe3f89777 [gaim-migrate @ 13794]
Mark Doliner <markdoliner@pidgin.im>
parents: 11515
diff changeset
281
17665
26bff2090889 Update Bonjour to do nonblocking I/O correctly.
Daniel Atallah <datallah@pidgin.im>
parents: 17663
diff changeset
282 ret = send(bconv->socket, bconv->tx_buf->outptr, writelen, 0);
26bff2090889 Update Bonjour to do nonblocking I/O correctly.
Daniel Atallah <datallah@pidgin.im>
parents: 17663
diff changeset
283
26bff2090889 Update Bonjour to do nonblocking I/O correctly.
Daniel Atallah <datallah@pidgin.im>
parents: 17663
diff changeset
284 if (ret < 0 && errno == EAGAIN)
26bff2090889 Update Bonjour to do nonblocking I/O correctly.
Daniel Atallah <datallah@pidgin.im>
parents: 17663
diff changeset
285 return;
26bff2090889 Update Bonjour to do nonblocking I/O correctly.
Daniel Atallah <datallah@pidgin.im>
parents: 17663
diff changeset
286 else if (ret <= 0) {
26bff2090889 Update Bonjour to do nonblocking I/O correctly.
Daniel Atallah <datallah@pidgin.im>
parents: 17663
diff changeset
287 PurpleConversation *conv;
21389
e1dd8142bb87 replace most calls to strerror with calls to g_strerror. strerror will return
Nathan Walp <nwalp@pidgin.im>
parents: 21093
diff changeset
288 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
289
26bff2090889 Update Bonjour to do nonblocking I/O correctly.
Daniel Atallah <datallah@pidgin.im>
parents: 17663
diff changeset
290 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
291 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
292
26bff2090889 Update Bonjour to do nonblocking I/O correctly.
Daniel Atallah <datallah@pidgin.im>
parents: 17663
diff changeset
293 conv = purple_find_conversation_with_account(PURPLE_CONV_TYPE_IM, bb->name, pb->account);
26bff2090889 Update Bonjour to do nonblocking I/O correctly.
Daniel Atallah <datallah@pidgin.im>
parents: 17663
diff changeset
294 if (conv != NULL)
26bff2090889 Update Bonjour to do nonblocking I/O correctly.
Daniel Atallah <datallah@pidgin.im>
parents: 17663
diff changeset
295 purple_conversation_write(conv, NULL,
26bff2090889 Update Bonjour to do nonblocking I/O correctly.
Daniel Atallah <datallah@pidgin.im>
parents: 17663
diff changeset
296 _("Unable to send message."),
26bff2090889 Update Bonjour to do nonblocking I/O correctly.
Daniel Atallah <datallah@pidgin.im>
parents: 17663
diff changeset
297 PURPLE_MESSAGE_SYSTEM, time(NULL));
26bff2090889 Update Bonjour to do nonblocking I/O correctly.
Daniel Atallah <datallah@pidgin.im>
parents: 17663
diff changeset
298
26bff2090889 Update Bonjour to do nonblocking I/O correctly.
Daniel Atallah <datallah@pidgin.im>
parents: 17663
diff changeset
299 bonjour_jabber_close_conversation(bb->conversation);
26bff2090889 Update Bonjour to do nonblocking I/O correctly.
Daniel Atallah <datallah@pidgin.im>
parents: 17663
diff changeset
300 bb->conversation = NULL;
26bff2090889 Update Bonjour to do nonblocking I/O correctly.
Daniel Atallah <datallah@pidgin.im>
parents: 17663
diff changeset
301 return;
11477
98b4f8643569 [gaim-migrate @ 13719]
Mark Doliner <markdoliner@pidgin.im>
parents:
diff changeset
302 }
11539
fbabe3f89777 [gaim-migrate @ 13794]
Mark Doliner <markdoliner@pidgin.im>
parents: 11515
diff changeset
303
17665
26bff2090889 Update Bonjour to do nonblocking I/O correctly.
Daniel Atallah <datallah@pidgin.im>
parents: 17663
diff changeset
304 purple_circ_buffer_mark_read(bconv->tx_buf, ret);
26bff2090889 Update Bonjour to do nonblocking I/O correctly.
Daniel Atallah <datallah@pidgin.im>
parents: 17663
diff changeset
305 }
26bff2090889 Update Bonjour to do nonblocking I/O correctly.
Daniel Atallah <datallah@pidgin.im>
parents: 17663
diff changeset
306
26bff2090889 Update Bonjour to do nonblocking I/O correctly.
Daniel Atallah <datallah@pidgin.im>
parents: 17663
diff changeset
307 static gint
26bff2090889 Update Bonjour to do nonblocking I/O correctly.
Daniel Atallah <datallah@pidgin.im>
parents: 17663
diff changeset
308 _send_data(PurpleBuddy *pb, char *message)
26bff2090889 Update Bonjour to do nonblocking I/O correctly.
Daniel Atallah <datallah@pidgin.im>
parents: 17663
diff changeset
309 {
26bff2090889 Update Bonjour to do nonblocking I/O correctly.
Daniel Atallah <datallah@pidgin.im>
parents: 17663
diff changeset
310 gint ret;
26bff2090889 Update Bonjour to do nonblocking I/O correctly.
Daniel Atallah <datallah@pidgin.im>
parents: 17663
diff changeset
311 int len = strlen(message);
26bff2090889 Update Bonjour to do nonblocking I/O correctly.
Daniel Atallah <datallah@pidgin.im>
parents: 17663
diff changeset
312 BonjourBuddy *bb = pb->proto_data;
26bff2090889 Update Bonjour to do nonblocking I/O correctly.
Daniel Atallah <datallah@pidgin.im>
parents: 17663
diff changeset
313 BonjourJabberConversation *bconv = bb->conversation;
26bff2090889 Update Bonjour to do nonblocking I/O correctly.
Daniel Atallah <datallah@pidgin.im>
parents: 17663
diff changeset
314
26bff2090889 Update Bonjour to do nonblocking I/O correctly.
Daniel Atallah <datallah@pidgin.im>
parents: 17663
diff changeset
315 /* 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
316 if (bconv->tx_handler != 0
17665
26bff2090889 Update Bonjour to do nonblocking I/O correctly.
Daniel Atallah <datallah@pidgin.im>
parents: 17663
diff changeset
317 || bconv->connect_data != NULL
21727
decfc3a613ff applied changes from b9c97ed0f9ada9069e8bd994b01fdde0b484083c
Daniel Atallah <datallah@pidgin.im>
parents: 21720
diff changeset
318 || 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
319 || !bconv->recv_stream_start
17665
26bff2090889 Update Bonjour to do nonblocking I/O correctly.
Daniel Atallah <datallah@pidgin.im>
parents: 17663
diff changeset
320 || purple_circ_buffer_get_max_read(bconv->tx_buf) > 0) {
26bff2090889 Update Bonjour to do nonblocking I/O correctly.
Daniel Atallah <datallah@pidgin.im>
parents: 17663
diff changeset
321 ret = -1;
26bff2090889 Update Bonjour to do nonblocking I/O correctly.
Daniel Atallah <datallah@pidgin.im>
parents: 17663
diff changeset
322 errno = EAGAIN;
26bff2090889 Update Bonjour to do nonblocking I/O correctly.
Daniel Atallah <datallah@pidgin.im>
parents: 17663
diff changeset
323 } else {
26bff2090889 Update Bonjour to do nonblocking I/O correctly.
Daniel Atallah <datallah@pidgin.im>
parents: 17663
diff changeset
324 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
325 }
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 (ret == -1 && errno == EAGAIN)
26bff2090889 Update Bonjour to do nonblocking I/O correctly.
Daniel Atallah <datallah@pidgin.im>
parents: 17663
diff changeset
328 ret = 0;
26bff2090889 Update Bonjour to do nonblocking I/O correctly.
Daniel Atallah <datallah@pidgin.im>
parents: 17663
diff changeset
329 else if (ret <= 0) {
26bff2090889 Update Bonjour to do nonblocking I/O correctly.
Daniel Atallah <datallah@pidgin.im>
parents: 17663
diff changeset
330 PurpleConversation *conv;
21389
e1dd8142bb87 replace most calls to strerror with calls to g_strerror. strerror will return
Nathan Walp <nwalp@pidgin.im>
parents: 21093
diff changeset
331 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
332
26bff2090889 Update Bonjour to do nonblocking I/O correctly.
Daniel Atallah <datallah@pidgin.im>
parents: 17663
diff changeset
333 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
334 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
335
26bff2090889 Update Bonjour to do nonblocking I/O correctly.
Daniel Atallah <datallah@pidgin.im>
parents: 17663
diff changeset
336 conv = purple_find_conversation_with_account(PURPLE_CONV_TYPE_IM, bb->name, pb->account);
26bff2090889 Update Bonjour to do nonblocking I/O correctly.
Daniel Atallah <datallah@pidgin.im>
parents: 17663
diff changeset
337 if (conv != NULL)
26bff2090889 Update Bonjour to do nonblocking I/O correctly.
Daniel Atallah <datallah@pidgin.im>
parents: 17663
diff changeset
338 purple_conversation_write(conv, NULL,
26bff2090889 Update Bonjour to do nonblocking I/O correctly.
Daniel Atallah <datallah@pidgin.im>
parents: 17663
diff changeset
339 _("Unable to send message."),
26bff2090889 Update Bonjour to do nonblocking I/O correctly.
Daniel Atallah <datallah@pidgin.im>
parents: 17663
diff changeset
340 PURPLE_MESSAGE_SYSTEM, time(NULL));
26bff2090889 Update Bonjour to do nonblocking I/O correctly.
Daniel Atallah <datallah@pidgin.im>
parents: 17663
diff changeset
341
26bff2090889 Update Bonjour to do nonblocking I/O correctly.
Daniel Atallah <datallah@pidgin.im>
parents: 17663
diff changeset
342 bonjour_jabber_close_conversation(bb->conversation);
26bff2090889 Update Bonjour to do nonblocking I/O correctly.
Daniel Atallah <datallah@pidgin.im>
parents: 17663
diff changeset
343 bb->conversation = NULL;
26bff2090889 Update Bonjour to do nonblocking I/O correctly.
Daniel Atallah <datallah@pidgin.im>
parents: 17663
diff changeset
344 return -1;
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
26bff2090889 Update Bonjour to do nonblocking I/O correctly.
Daniel Atallah <datallah@pidgin.im>
parents: 17663
diff changeset
347 if (ret < len) {
21727
decfc3a613ff applied changes from b9c97ed0f9ada9069e8bd994b01fdde0b484083c
Daniel Atallah <datallah@pidgin.im>
parents: 21720
diff changeset
348 /* 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
349 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
350 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
351 _send_data_write_cb, pb);
26bff2090889 Update Bonjour to do nonblocking I/O correctly.
Daniel Atallah <datallah@pidgin.im>
parents: 17663
diff changeset
352 purple_circ_buffer_append(bconv->tx_buf, message + ret, len - ret);
26bff2090889 Update Bonjour to do nonblocking I/O correctly.
Daniel Atallah <datallah@pidgin.im>
parents: 17663
diff changeset
353 }
26bff2090889 Update Bonjour to do nonblocking I/O correctly.
Daniel Atallah <datallah@pidgin.im>
parents: 17663
diff changeset
354
26bff2090889 Update Bonjour to do nonblocking I/O correctly.
Daniel Atallah <datallah@pidgin.im>
parents: 17663
diff changeset
355 return ret;
11477
98b4f8643569 [gaim-migrate @ 13719]
Mark Doliner <markdoliner@pidgin.im>
parents:
diff changeset
356 }
98b4f8643569 [gaim-migrate @ 13719]
Mark Doliner <markdoliner@pidgin.im>
parents:
diff changeset
357
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
358 void bonjour_jabber_process_packet(PurpleBuddy *pb, xmlnode *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
359
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
360 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
361 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
362
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
363 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
364 _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
365 else if(!strcmp(packet->name, "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
366 xep_iq_parse(packet, NULL, 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
367 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
368 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
369 }
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
370
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
371
12443
ad94864144f8 [gaim-migrate @ 14750]
Stu Tomlinson <nosnilmot@pidgin.im>
parents: 11830
diff changeset
372 static void
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15873
diff changeset
373 _client_socket_handler(gpointer data, gint socket, PurpleInputCondition condition)
11477
98b4f8643569 [gaim-migrate @ 13719]
Mark Doliner <markdoliner@pidgin.im>
parents:
diff changeset
374 {
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
375 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
376 gint len, message_length;
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
377 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
378
11826
10ebbc41f163 [gaim-migrate @ 14117]
Richard Laager <rlaager@pidgin.im>
parents: 11823
diff changeset
379 /* Read the data from the 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
380 if ((len = recv(socket, message, sizeof(message) - 1, 0)) == -1) {
11826
10ebbc41f163 [gaim-migrate @ 14117]
Richard Laager <rlaager@pidgin.im>
parents: 11823
diff changeset
381 /* There have been an error reading from the socket */
17665
26bff2090889 Update Bonjour to do nonblocking I/O correctly.
Daniel Atallah <datallah@pidgin.im>
parents: 17663
diff changeset
382 if (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
383 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
384
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
385 purple_debug_warning("bonjour", "receive error: %s\n", 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
386
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
387 bonjour_jabber_close_conversation(bconv);
23160
0aff8f3882f4 applied changes from 3d595739f53a259d5dae408a05f64d2836f02ac9
Daniel Atallah <datallah@pidgin.im>
parents: 23072
diff changeset
388 if (bconv->pb != NULL && bconv->pb->proto_data != 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
389 BonjourBuddy *bb = bconv->pb->proto_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
390 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
391 }
17665
26bff2090889 Update Bonjour to do nonblocking I/O correctly.
Daniel Atallah <datallah@pidgin.im>
parents: 17663
diff changeset
392
26bff2090889 Update Bonjour to do nonblocking I/O correctly.
Daniel Atallah <datallah@pidgin.im>
parents: 17663
diff changeset
393 /* 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
394 * 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
395 }
11477
98b4f8643569 [gaim-migrate @ 13719]
Mark Doliner <markdoliner@pidgin.im>
parents:
diff changeset
396 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
397 } else if (len == 0) { /* The other end has closed the 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
398 purple_debug_warning("bonjour", "Connection closed (without stream end) by %s.\n", (bconv->pb && bconv->pb->name) ? bconv->pb->name : "(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
399 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
400 return;
11477
98b4f8643569 [gaim-migrate @ 13719]
Mark Doliner <markdoliner@pidgin.im>
parents:
diff changeset
401 } else {
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
402 message_length = len;
11477
98b4f8643569 [gaim-migrate @ 13719]
Mark Doliner <markdoliner@pidgin.im>
parents:
diff changeset
403 message[message_length] = '\0';
11539
fbabe3f89777 [gaim-migrate @ 13794]
Mark Doliner <markdoliner@pidgin.im>
parents: 11515
diff changeset
404
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
405 while (message_length > 0 && g_ascii_iscntrl(message[message_length - 1])) {
11477
98b4f8643569 [gaim-migrate @ 13719]
Mark Doliner <markdoliner@pidgin.im>
parents:
diff changeset
406 message[message_length - 1] = '\0';
98b4f8643569 [gaim-migrate @ 13719]
Mark Doliner <markdoliner@pidgin.im>
parents:
diff changeset
407 message_length--;
98b4f8643569 [gaim-migrate @ 13719]
Mark Doliner <markdoliner@pidgin.im>
parents:
diff changeset
408 }
98b4f8643569 [gaim-migrate @ 13719]
Mark Doliner <markdoliner@pidgin.im>
parents:
diff changeset
409 }
11539
fbabe3f89777 [gaim-migrate @ 13794]
Mark Doliner <markdoliner@pidgin.im>
parents: 11515
diff changeset
410
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
411 purple_debug_info("bonjour", "Receive: -%s- %d bytes\n", message, 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
412
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
413 bonjour_parser_process(bconv, message, message_length);
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
414 }
17633
b76241c02857 Some more Bonjour cleanup and leak fixing.
Daniel Atallah <datallah@pidgin.im>
parents: 17632
diff changeset
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 void bonjour_jabber_stream_ended(BonjourJabberConversation *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
417
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
418 purple_debug_info("bonjour", "Recieved conversation close notification from %s.\n", bconv->pb ? bconv->pb->name : "(unknown)");
19373
5c4391d94bf5 Don't trigger another libxml2 parse from within one of the parsing callbacks. References #1652.
Daniel Atallah <datallah@pidgin.im>
parents: 19056
diff changeset
419
19749
21cc72fa3f6f Prevent duplicate window closed notifications.
Daniel Atallah <datallah@pidgin.im>
parents: 19579
diff changeset
420 /* Inform the user that the conversation has been closed */
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
421 if (bconv != 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
422 BonjourBuddy *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
423
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
424 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
425 bb = bconv->pb->proto_data;
21082
0f41e90e5b03 don't assume </stream:stream> means the conversation window is closed. Fixes #3690
Sean Egan <seanegan@pidgin.im>
parents: 20239
diff changeset
426 #if 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
427 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
428 PurpleConversation *conv;
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
429 conv = purple_find_conversation_with_account(PURPLE_CONV_TYPE_IM, bconv->pb->name, bconv->pb->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
430 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
431 char *tmp = g_strdup_printf(_("%s has closed the conversation."), bconv->pb->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
432 purple_conversation_write(conv, NULL, tmp, 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
433 g_free(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
434 }
19749
21cc72fa3f6f Prevent duplicate window closed notifications.
Daniel Atallah <datallah@pidgin.im>
parents: 19579
diff changeset
435 }
21082
0f41e90e5b03 don't assume </stream:stream> means the conversation window is closed. Fixes #3690
Sean Egan <seanegan@pidgin.im>
parents: 20239
diff changeset
436 #endif
19749
21cc72fa3f6f Prevent duplicate window closed notifications.
Daniel Atallah <datallah@pidgin.im>
parents: 19579
diff changeset
437 /* Close the socket, clear the watcher and free memory */
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
438 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
439 if(bb)
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
440 bb->conversation = NULL;
19749
21cc72fa3f6f Prevent duplicate window closed notifications.
Daniel Atallah <datallah@pidgin.im>
parents: 19579
diff changeset
441 }
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 }
18947
bb754041e5b4 Fix memory leak (also includes an efficiency rearrangement for the xmlnode parsing that has been sitting on my machine for a while).
Daniel Atallah <datallah@pidgin.im>
parents: 18338
diff changeset
443
11477
98b4f8643569 [gaim-migrate @ 13719]
Mark Doliner <markdoliner@pidgin.im>
parents:
diff changeset
444
17665
26bff2090889 Update Bonjour to do nonblocking I/O correctly.
Daniel Atallah <datallah@pidgin.im>
parents: 17663
diff changeset
445 struct _stream_start_data {
26bff2090889 Update Bonjour to do nonblocking I/O correctly.
Daniel Atallah <datallah@pidgin.im>
parents: 17663
diff changeset
446 char *msg;
26bff2090889 Update Bonjour to do nonblocking I/O correctly.
Daniel Atallah <datallah@pidgin.im>
parents: 17663
diff changeset
447 };
26bff2090889 Update Bonjour to do nonblocking I/O correctly.
Daniel Atallah <datallah@pidgin.im>
parents: 17663
diff changeset
448
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
449
17665
26bff2090889 Update Bonjour to do nonblocking I/O correctly.
Daniel Atallah <datallah@pidgin.im>
parents: 17663
diff changeset
450 static void
26bff2090889 Update Bonjour to do nonblocking I/O correctly.
Daniel Atallah <datallah@pidgin.im>
parents: 17663
diff changeset
451 _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
452 {
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
453 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
454 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
455 int len, ret;
26bff2090889 Update Bonjour to do nonblocking I/O correctly.
Daniel Atallah <datallah@pidgin.im>
parents: 17663
diff changeset
456
26bff2090889 Update Bonjour to do nonblocking I/O correctly.
Daniel Atallah <datallah@pidgin.im>
parents: 17663
diff changeset
457 len = strlen(ss->msg);
26bff2090889 Update Bonjour to do nonblocking I/O correctly.
Daniel Atallah <datallah@pidgin.im>
parents: 17663
diff changeset
458
26bff2090889 Update Bonjour to do nonblocking I/O correctly.
Daniel Atallah <datallah@pidgin.im>
parents: 17663
diff changeset
459 /* Start Stream */
26bff2090889 Update Bonjour to do nonblocking I/O correctly.
Daniel Atallah <datallah@pidgin.im>
parents: 17663
diff changeset
460 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
461
26bff2090889 Update Bonjour to do nonblocking I/O correctly.
Daniel Atallah <datallah@pidgin.im>
parents: 17663
diff changeset
462 if (ret == -1 && errno == EAGAIN)
26bff2090889 Update Bonjour to do nonblocking I/O correctly.
Daniel Atallah <datallah@pidgin.im>
parents: 17663
diff changeset
463 return;
26bff2090889 Update Bonjour to do nonblocking I/O correctly.
Daniel Atallah <datallah@pidgin.im>
parents: 17663
diff changeset
464 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
465 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
466 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
467 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
468 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
469
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
470 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
471 bb = bconv->pb->proto_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
472 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
473 }
17665
26bff2090889 Update Bonjour to do nonblocking I/O correctly.
Daniel Atallah <datallah@pidgin.im>
parents: 17663
diff changeset
474
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
475 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
476 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
477
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
478 conv = purple_find_conversation_with_account(PURPLE_CONV_TYPE_IM, bname, bconv->account);
17665
26bff2090889 Update Bonjour to do nonblocking I/O correctly.
Daniel Atallah <datallah@pidgin.im>
parents: 17663
diff changeset
479 if (conv != NULL)
26bff2090889 Update Bonjour to do nonblocking I/O correctly.
Daniel Atallah <datallah@pidgin.im>
parents: 17663
diff changeset
480 purple_conversation_write(conv, NULL,
26bff2090889 Update Bonjour to do nonblocking I/O correctly.
Daniel Atallah <datallah@pidgin.im>
parents: 17663
diff changeset
481 _("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
482 PURPLE_MESSAGE_SYSTEM, time(NULL));
26bff2090889 Update Bonjour to do nonblocking I/O correctly.
Daniel Atallah <datallah@pidgin.im>
parents: 17663
diff changeset
483
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
484 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
485 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
486 bb->conversation = NULL;
17665
26bff2090889 Update Bonjour to do nonblocking I/O correctly.
Daniel Atallah <datallah@pidgin.im>
parents: 17663
diff changeset
487
26bff2090889 Update Bonjour to do nonblocking I/O correctly.
Daniel Atallah <datallah@pidgin.im>
parents: 17663
diff changeset
488 return;
26bff2090889 Update Bonjour to do nonblocking I/O correctly.
Daniel Atallah <datallah@pidgin.im>
parents: 17663
diff changeset
489 }
26bff2090889 Update Bonjour to do nonblocking I/O correctly.
Daniel Atallah <datallah@pidgin.im>
parents: 17663
diff changeset
490
26bff2090889 Update Bonjour to do nonblocking I/O correctly.
Daniel Atallah <datallah@pidgin.im>
parents: 17663
diff changeset
491 /* This is EXTREMELY unlikely to happen */
26bff2090889 Update Bonjour to do nonblocking I/O correctly.
Daniel Atallah <datallah@pidgin.im>
parents: 17663
diff changeset
492 if (ret < len) {
26bff2090889 Update Bonjour to do nonblocking I/O correctly.
Daniel Atallah <datallah@pidgin.im>
parents: 17663
diff changeset
493 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
494 g_free(ss->msg);
26bff2090889 Update Bonjour to do nonblocking I/O correctly.
Daniel Atallah <datallah@pidgin.im>
parents: 17663
diff changeset
495 ss->msg = tmp;
26bff2090889 Update Bonjour to do nonblocking I/O correctly.
Daniel Atallah <datallah@pidgin.im>
parents: 17663
diff changeset
496 return;
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
26bff2090889 Update Bonjour to do nonblocking I/O correctly.
Daniel Atallah <datallah@pidgin.im>
parents: 17663
diff changeset
499 g_free(ss->msg);
26bff2090889 Update Bonjour to do nonblocking I/O correctly.
Daniel Atallah <datallah@pidgin.im>
parents: 17663
diff changeset
500 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
501 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
502
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
503 /* 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
504 purple_input_remove(bconv->tx_handler);
21727
decfc3a613ff applied changes from b9c97ed0f9ada9069e8bd994b01fdde0b484083c
Daniel Atallah <datallah@pidgin.im>
parents: 21720
diff changeset
505 bconv->tx_handler = 0;
decfc3a613ff applied changes from b9c97ed0f9ada9069e8bd994b01fdde0b484083c
Daniel Atallah <datallah@pidgin.im>
parents: 21720
diff changeset
506 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
507
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
508 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
509 }
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
510
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
511 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
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 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
514 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
515 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
516
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
517 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
518 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
519
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
520 /* 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
521 * 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
522 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
523 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
524
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 stream_start = g_strdup_printf(DOCTYPE, purple_account_get_username(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
526 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
527
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
528 bconv->sent_stream_start = PARTIALLY_SENT;
21727
decfc3a613ff applied changes from b9c97ed0f9ada9069e8bd994b01fdde0b484083c
Daniel Atallah <datallah@pidgin.im>
parents: 21720
diff changeset
529
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
530 /* 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
531 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
532
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
533 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
534 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
535 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
536 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
537
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 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
539 (*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
540
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
541 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
542 PurpleConversation *conv;
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
543 conv = purple_find_conversation_with_account(PURPLE_CONV_TYPE_IM, bname, bconv->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
544 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
545 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
546 _("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
547 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
548 }
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
549
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
550 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
551 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
552
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
553 return FALSE;
17665
26bff2090889 Update Bonjour to do nonblocking I/O correctly.
Daniel Atallah <datallah@pidgin.im>
parents: 17663
diff changeset
554 }
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
555
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
556 /* 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
557 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
558 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
559 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
560 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
561 /* 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
562 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
563 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
564 } 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
565 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
566
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 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
568
21727
decfc3a613ff applied changes from b9c97ed0f9ada9069e8bd994b01fdde0b484083c
Daniel Atallah <datallah@pidgin.im>
parents: 21720
diff changeset
569 return TRUE;
decfc3a613ff applied changes from b9c97ed0f9ada9069e8bd994b01fdde0b484083c
Daniel Atallah <datallah@pidgin.im>
parents: 21720
diff changeset
570 }
decfc3a613ff applied changes from b9c97ed0f9ada9069e8bd994b01fdde0b484083c
Daniel Atallah <datallah@pidgin.im>
parents: 21720
diff changeset
571
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 /* This gets called when we've successfully sent our <stream:stream />
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 * AND when we've recieved a <stream:stream /> */
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
574 void bonjour_jabber_stream_started(BonjourJabberConversation *bconv) {
21727
decfc3a613ff applied changes from b9c97ed0f9ada9069e8bd994b01fdde0b484083c
Daniel Atallah <datallah@pidgin.im>
parents: 21720
diff changeset
575
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
576 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
577 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
578 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
579
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
580 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
581 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
582
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
583 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
584 bname ? bname : "(unknown)", bconv->ip, err ? err : "(null)");
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->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
587 PurpleConversation *conv;
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 conv = purple_find_conversation_with_account(PURPLE_CONV_TYPE_IM, bname, bconv->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
589 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
590 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
591 _("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
592 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
593 }
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
594
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
595 /* 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
596 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
597 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
598
21727
decfc3a613ff applied changes from b9c97ed0f9ada9069e8bd994b01fdde0b484083c
Daniel Atallah <datallah@pidgin.im>
parents: 21720
diff changeset
599 /* 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
600 * may be in the middle of parsing.
decfc3a613ff applied changes from b9c97ed0f9ada9069e8bd994b01fdde0b484083c
Daniel Atallah <datallah@pidgin.im>
parents: 21720
diff changeset
601 */
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
602 async_bonjour_jabber_close_conversation(bconv);
21727
decfc3a613ff applied changes from b9c97ed0f9ada9069e8bd994b01fdde0b484083c
Daniel Atallah <datallah@pidgin.im>
parents: 21720
diff changeset
603 return;
decfc3a613ff applied changes from b9c97ed0f9ada9069e8bd994b01fdde0b484083c
Daniel Atallah <datallah@pidgin.im>
parents: 21720
diff changeset
604 }
decfc3a613ff applied changes from b9c97ed0f9ada9069e8bd994b01fdde0b484083c
Daniel Atallah <datallah@pidgin.im>
parents: 21720
diff changeset
605
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
606 /* 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
607 /* 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
608 if (bconv->sent_stream_start == FULLY_SENT && bconv->recv_stream_start
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
609 && bconv->pb && purple_circ_buffer_get_max_read(bconv->tx_buf) > 0) {
21727
decfc3a613ff applied changes from b9c97ed0f9ada9069e8bd994b01fdde0b484083c
Daniel Atallah <datallah@pidgin.im>
parents: 21720
diff changeset
610 /* Watch for when we can write the buffered messages */
decfc3a613ff applied changes from b9c97ed0f9ada9069e8bd994b01fdde0b484083c
Daniel Atallah <datallah@pidgin.im>
parents: 21720
diff changeset
611 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
612 _send_data_write_cb, bconv->pb);
21727
decfc3a613ff applied changes from b9c97ed0f9ada9069e8bd994b01fdde0b484083c
Daniel Atallah <datallah@pidgin.im>
parents: 21720
diff changeset
613 /* 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
614 _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
615 }
decfc3a613ff applied changes from b9c97ed0f9ada9069e8bd994b01fdde0b484083c
Daniel Atallah <datallah@pidgin.im>
parents: 21720
diff changeset
616
17665
26bff2090889 Update Bonjour to do nonblocking I/O correctly.
Daniel Atallah <datallah@pidgin.im>
parents: 17663
diff changeset
617 }
26bff2090889 Update Bonjour to do nonblocking I/O correctly.
Daniel Atallah <datallah@pidgin.im>
parents: 17663
diff changeset
618
12443
ad94864144f8 [gaim-migrate @ 14750]
Stu Tomlinson <nosnilmot@pidgin.im>
parents: 11830
diff changeset
619 static void
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15873
diff changeset
620 _server_socket_handler(gpointer data, int server_socket, PurpleInputCondition condition)
11477
98b4f8643569 [gaim-migrate @ 13719]
Mark Doliner <markdoliner@pidgin.im>
parents:
diff changeset
621 {
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 BonjourJabber *jdata = data;
11826
10ebbc41f163 [gaim-migrate @ 14117]
Richard Laager <rlaager@pidgin.im>
parents: 11823
diff changeset
623 struct sockaddr_in their_addr; /* connector's address information */
11515
09651c1daa98 [gaim-migrate @ 13760]
Mark Doliner <markdoliner@pidgin.im>
parents: 11498
diff changeset
624 socklen_t sin_size = sizeof(struct sockaddr);
11477
98b4f8643569 [gaim-migrate @ 13719]
Mark Doliner <markdoliner@pidgin.im>
parents:
diff changeset
625 int client_socket;
20239
ae122f419324 applied changes from 2762c6075c0dc52a96098c5478c5bf68cfd890a3
Luke Schierer <lschiere@pidgin.im>
parents: 19859
diff changeset
626 int flags;
11539
fbabe3f89777 [gaim-migrate @ 13794]
Mark Doliner <markdoliner@pidgin.im>
parents: 11515
diff changeset
627 char *address_text = 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
628 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
629 BonjourJabberConversation *bconv;
11477
98b4f8643569 [gaim-migrate @ 13719]
Mark Doliner <markdoliner@pidgin.im>
parents:
diff changeset
630
11826
10ebbc41f163 [gaim-migrate @ 14117]
Richard Laager <rlaager@pidgin.im>
parents: 11823
diff changeset
631 /* 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
632 if (condition != PURPLE_INPUT_READ)
11477
98b4f8643569 [gaim-migrate @ 13719]
Mark Doliner <markdoliner@pidgin.im>
parents:
diff changeset
633 return;
98b4f8643569 [gaim-migrate @ 13719]
Mark Doliner <markdoliner@pidgin.im>
parents:
diff changeset
634
11539
fbabe3f89777 [gaim-migrate @ 13794]
Mark Doliner <markdoliner@pidgin.im>
parents: 11515
diff changeset
635 if ((client_socket = accept(server_socket, (struct sockaddr *)&their_addr, &sin_size)) == -1)
11477
98b4f8643569 [gaim-migrate @ 13719]
Mark Doliner <markdoliner@pidgin.im>
parents:
diff changeset
636 return;
17633
b76241c02857 Some more Bonjour cleanup and leak fixing.
Daniel Atallah <datallah@pidgin.im>
parents: 17632
diff changeset
637
20239
ae122f419324 applied changes from 2762c6075c0dc52a96098c5478c5bf68cfd890a3
Luke Schierer <lschiere@pidgin.im>
parents: 19859
diff changeset
638 flags = fcntl(client_socket, F_GETFL);
ae122f419324 applied changes from 2762c6075c0dc52a96098c5478c5bf68cfd890a3
Luke Schierer <lschiere@pidgin.im>
parents: 19859
diff changeset
639 fcntl(client_socket, F_SETFL, flags | O_NONBLOCK);
11477
98b4f8643569 [gaim-migrate @ 13719]
Mark Doliner <markdoliner@pidgin.im>
parents:
diff changeset
640
13962
71617bf27d00 [gaim-migrate @ 16386]
Jono Cole
parents: 13267
diff changeset
641 /* Look for the buddy that has opened the conversation and fill information */
11477
98b4f8643569 [gaim-migrate @ 13719]
Mark Doliner <markdoliner@pidgin.im>
parents:
diff changeset
642 address_text = inet_ntoa(their_addr.sin_addr);
19832
84b69b21672b Patch from QuLogic. Fixes #2903 ('Missing newlines in debug messages.')
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 19749
diff changeset
643 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
644 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
645 mbba->address = address_text;
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 mbba->jdata = jdata;
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
647 g_hash_table_foreach(purple_get_blist()->buddies, _match_buddies_by_address, 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
648
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
649 if (mbba->matched_buddies == NULL) {
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15873
diff changeset
650 purple_debug_info("bonjour", "We don't like invisible buddies, this is not a superheros 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
651 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
652 g_free(mbba);
11477
98b4f8643569 [gaim-migrate @ 13719]
Mark Doliner <markdoliner@pidgin.im>
parents:
diff changeset
653 close(client_socket);
98b4f8643569 [gaim-migrate @ 13719]
Mark Doliner <markdoliner@pidgin.im>
parents:
diff changeset
654 return;
98b4f8643569 [gaim-migrate @ 13719]
Mark Doliner <markdoliner@pidgin.im>
parents:
diff changeset
655 }
98b4f8643569 [gaim-migrate @ 13719]
Mark Doliner <markdoliner@pidgin.im>
parents:
diff changeset
656
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
657 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
658 g_free(mbba);
17665
26bff2090889 Update Bonjour to do nonblocking I/O correctly.
Daniel Atallah <datallah@pidgin.im>
parents: 17663
diff changeset
659
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
660 /* 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
661 * 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
662 */
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
663 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
664
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
665 /* 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
666 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
667 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
668
11477
98b4f8643569 [gaim-migrate @ 13719]
Mark Doliner <markdoliner@pidgin.im>
parents:
diff changeset
669 }
98b4f8643569 [gaim-migrate @ 13719]
Mark Doliner <markdoliner@pidgin.im>
parents:
diff changeset
670
11539
fbabe3f89777 [gaim-migrate @ 13794]
Mark Doliner <markdoliner@pidgin.im>
parents: 11515
diff changeset
671 gint
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
672 bonjour_jabber_start(BonjourJabber *jdata)
11477
98b4f8643569 [gaim-migrate @ 13719]
Mark Doliner <markdoliner@pidgin.im>
parents:
diff changeset
673 {
98b4f8643569 [gaim-migrate @ 13719]
Mark Doliner <markdoliner@pidgin.im>
parents:
diff changeset
674 struct sockaddr_in my_addr;
13971
648326341d27 [gaim-migrate @ 16406]
Jonty Wareing
parents: 13964
diff changeset
675 int i;
648326341d27 [gaim-migrate @ 16406]
Jonty Wareing
parents: 13964
diff changeset
676 gboolean bind_successful;
11477
98b4f8643569 [gaim-migrate @ 13719]
Mark Doliner <markdoliner@pidgin.im>
parents:
diff changeset
677
11826
10ebbc41f163 [gaim-migrate @ 14117]
Richard Laager <rlaager@pidgin.im>
parents: 11823
diff changeset
678 /* Open a listening socket for incoming conversations */
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 if ((jdata->socket = socket(PF_INET, SOCK_STREAM, 0)) < 0)
11539
fbabe3f89777 [gaim-migrate @ 13794]
Mark Doliner <markdoliner@pidgin.im>
parents: 11515
diff changeset
680 {
21389
e1dd8142bb87 replace most calls to strerror with calls to g_strerror. strerror will return
Nathan Walp <nwalp@pidgin.im>
parents: 21093
diff changeset
681 purple_debug_error("bonjour", "Cannot open socket: %s\n", 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
682 purple_connection_error_reason (jdata->account->gc,
21279
40685e1f50ca Rename:
Will Thompson <resiak@pidgin.im>
parents: 20435
diff changeset
683 PURPLE_CONNECTION_ERROR_NETWORK_ERROR,
40685e1f50ca Rename:
Will Thompson <resiak@pidgin.im>
parents: 20435
diff changeset
684 _("Cannot open socket"));
11477
98b4f8643569 [gaim-migrate @ 13719]
Mark Doliner <markdoliner@pidgin.im>
parents:
diff changeset
685 return -1;
98b4f8643569 [gaim-migrate @ 13719]
Mark Doliner <markdoliner@pidgin.im>
parents:
diff changeset
686 }
11539
fbabe3f89777 [gaim-migrate @ 13794]
Mark Doliner <markdoliner@pidgin.im>
parents: 11515
diff changeset
687
11477
98b4f8643569 [gaim-migrate @ 13719]
Mark Doliner <markdoliner@pidgin.im>
parents:
diff changeset
688 memset(&my_addr, 0, sizeof(struct sockaddr_in));
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
689 my_addr.sin_family = AF_INET;
11539
fbabe3f89777 [gaim-migrate @ 13794]
Mark Doliner <markdoliner@pidgin.im>
parents: 11515
diff changeset
690
13971
648326341d27 [gaim-migrate @ 16406]
Jonty Wareing
parents: 13964
diff changeset
691 /* Attempt to find a free port */
648326341d27 [gaim-migrate @ 16406]
Jonty Wareing
parents: 13964
diff changeset
692 bind_successful = FALSE;
648326341d27 [gaim-migrate @ 16406]
Jonty Wareing
parents: 13964
diff changeset
693 for (i = 0; i < 10; i++)
648326341d27 [gaim-migrate @ 16406]
Jonty Wareing
parents: 13964
diff changeset
694 {
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
695 my_addr.sin_port = htons(jdata->port);
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 if (bind(jdata->socket, (struct sockaddr*)&my_addr, sizeof(struct sockaddr)) == 0)
13971
648326341d27 [gaim-migrate @ 16406]
Jonty Wareing
parents: 13964
diff changeset
697 {
648326341d27 [gaim-migrate @ 16406]
Jonty Wareing
parents: 13964
diff changeset
698 bind_successful = TRUE;
648326341d27 [gaim-migrate @ 16406]
Jonty Wareing
parents: 13964
diff changeset
699 break;
648326341d27 [gaim-migrate @ 16406]
Jonty Wareing
parents: 13964
diff changeset
700 }
23883
222e2f637efd Fix running several Bonjour instances on the same machine.
Daniel Atallah <datallah@pidgin.im>
parents: 23160
diff changeset
701
222e2f637efd Fix running several Bonjour instances on the same machine.
Daniel Atallah <datallah@pidgin.im>
parents: 23160
diff changeset
702 purple_debug_info("bonjour", "Unable to bind to port %u.(%s)\n", jdata->port, 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
703 jdata->port++;
13971
648326341d27 [gaim-migrate @ 16406]
Jonty Wareing
parents: 13964
diff changeset
704 }
648326341d27 [gaim-migrate @ 16406]
Jonty Wareing
parents: 13964
diff changeset
705
648326341d27 [gaim-migrate @ 16406]
Jonty Wareing
parents: 13964
diff changeset
706 /* On no! We tried 10 ports and could not bind to ANY of them */
648326341d27 [gaim-migrate @ 16406]
Jonty Wareing
parents: 13964
diff changeset
707 if (!bind_successful)
11539
fbabe3f89777 [gaim-migrate @ 13794]
Mark Doliner <markdoliner@pidgin.im>
parents: 11515
diff changeset
708 {
21389
e1dd8142bb87 replace most calls to strerror with calls to g_strerror. strerror will return
Nathan Walp <nwalp@pidgin.im>
parents: 21093
diff changeset
709 purple_debug_error("bonjour", "Cannot bind socket: %s\n", 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
710 purple_connection_error_reason (jdata->account->gc,
21279
40685e1f50ca Rename:
Will Thompson <resiak@pidgin.im>
parents: 20435
diff changeset
711 PURPLE_CONNECTION_ERROR_NETWORK_ERROR,
40685e1f50ca Rename:
Will Thompson <resiak@pidgin.im>
parents: 20435
diff changeset
712 _("Could not bind socket to port"));
11477
98b4f8643569 [gaim-migrate @ 13719]
Mark Doliner <markdoliner@pidgin.im>
parents:
diff changeset
713 return -1;
98b4f8643569 [gaim-migrate @ 13719]
Mark Doliner <markdoliner@pidgin.im>
parents:
diff changeset
714 }
11539
fbabe3f89777 [gaim-migrate @ 13794]
Mark Doliner <markdoliner@pidgin.im>
parents: 11515
diff changeset
715
13971
648326341d27 [gaim-migrate @ 16406]
Jonty Wareing
parents: 13964
diff changeset
716 /* Attempt to listen on the bound 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
717 if (listen(jdata->socket, 10) != 0)
11539
fbabe3f89777 [gaim-migrate @ 13794]
Mark Doliner <markdoliner@pidgin.im>
parents: 11515
diff changeset
718 {
21389
e1dd8142bb87 replace most calls to strerror with calls to g_strerror. strerror will return
Nathan Walp <nwalp@pidgin.im>
parents: 21093
diff changeset
719 purple_debug_error("bonjour", "Cannot listen on socket: %s\n", 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
720 purple_connection_error_reason (jdata->account->gc,
21279
40685e1f50ca Rename:
Will Thompson <resiak@pidgin.im>
parents: 20435
diff changeset
721 PURPLE_CONNECTION_ERROR_NETWORK_ERROR,
40685e1f50ca Rename:
Will Thompson <resiak@pidgin.im>
parents: 20435
diff changeset
722 _("Could not listen on socket"));
11477
98b4f8643569 [gaim-migrate @ 13719]
Mark Doliner <markdoliner@pidgin.im>
parents:
diff changeset
723 return -1;
98b4f8643569 [gaim-migrate @ 13719]
Mark Doliner <markdoliner@pidgin.im>
parents:
diff changeset
724 }
98b4f8643569 [gaim-migrate @ 13719]
Mark Doliner <markdoliner@pidgin.im>
parents:
diff changeset
725
11826
10ebbc41f163 [gaim-migrate @ 14117]
Richard Laager <rlaager@pidgin.im>
parents: 11823
diff changeset
726 #if 0
12730
f64fdbc34677 [gaim-migrate @ 15074]
Daniel Atallah <datallah@pidgin.im>
parents: 12708
diff changeset
727 /* TODO: Why isn't this being used? */
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
728 data->socket = purple_network_listen(jdata->port, SOCK_STREAM);
11477
98b4f8643569 [gaim-migrate @ 13719]
Mark Doliner <markdoliner@pidgin.im>
parents:
diff changeset
729
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
730 if (jdata->socket == -1)
11826
10ebbc41f163 [gaim-migrate @ 14117]
Richard Laager <rlaager@pidgin.im>
parents: 11823
diff changeset
731 {
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15873
diff changeset
732 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
733 }
10ebbc41f163 [gaim-migrate @ 14117]
Richard Laager <rlaager@pidgin.im>
parents: 11823
diff changeset
734 #endif
11477
98b4f8643569 [gaim-migrate @ 13719]
Mark Doliner <markdoliner@pidgin.im>
parents:
diff changeset
735
11826
10ebbc41f163 [gaim-migrate @ 14117]
Richard Laager <rlaager@pidgin.im>
parents: 11823
diff changeset
736 /* Open a watcher in the socket we have just opened */
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
737 jdata->watcher_id = purple_input_add(jdata->socket, PURPLE_INPUT_READ, _server_socket_handler, jdata);
11539
fbabe3f89777 [gaim-migrate @ 13794]
Mark Doliner <markdoliner@pidgin.im>
parents: 11515
diff changeset
738
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
739 return jdata->port;
11477
98b4f8643569 [gaim-migrate @ 13719]
Mark Doliner <markdoliner@pidgin.im>
parents:
diff changeset
740 }
98b4f8643569 [gaim-migrate @ 13719]
Mark Doliner <markdoliner@pidgin.im>
parents:
diff changeset
741
17665
26bff2090889 Update Bonjour to do nonblocking I/O correctly.
Daniel Atallah <datallah@pidgin.im>
parents: 17663
diff changeset
742 static void
26bff2090889 Update Bonjour to do nonblocking I/O correctly.
Daniel Atallah <datallah@pidgin.im>
parents: 17663
diff changeset
743 _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
744 {
26bff2090889 Update Bonjour to do nonblocking I/O correctly.
Daniel Atallah <datallah@pidgin.im>
parents: 17663
diff changeset
745 PurpleBuddy *pb = data;
26bff2090889 Update Bonjour to do nonblocking I/O correctly.
Daniel Atallah <datallah@pidgin.im>
parents: 17663
diff changeset
746 BonjourBuddy *bb = pb->proto_data;
26bff2090889 Update Bonjour to do nonblocking I/O correctly.
Daniel Atallah <datallah@pidgin.im>
parents: 17663
diff changeset
747
26bff2090889 Update Bonjour to do nonblocking I/O correctly.
Daniel Atallah <datallah@pidgin.im>
parents: 17663
diff changeset
748 bb->conversation->connect_data = NULL;
26bff2090889 Update Bonjour to do nonblocking I/O correctly.
Daniel Atallah <datallah@pidgin.im>
parents: 17663
diff changeset
749
26bff2090889 Update Bonjour to do nonblocking I/O correctly.
Daniel Atallah <datallah@pidgin.im>
parents: 17663
diff changeset
750 if (source < 0) {
26bff2090889 Update Bonjour to do nonblocking I/O correctly.
Daniel Atallah <datallah@pidgin.im>
parents: 17663
diff changeset
751 PurpleConversation *conv;
26bff2090889 Update Bonjour to do nonblocking I/O correctly.
Daniel Atallah <datallah@pidgin.im>
parents: 17663
diff changeset
752
26bff2090889 Update Bonjour to do nonblocking I/O correctly.
Daniel Atallah <datallah@pidgin.im>
parents: 17663
diff changeset
753 purple_debug_error("bonjour", "Error connecting to 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
754 purple_buddy_get_name(pb), bb->conversation->ip, bb->port_p2pj, error ? error : "(null)");
17665
26bff2090889 Update Bonjour to do nonblocking I/O correctly.
Daniel Atallah <datallah@pidgin.im>
parents: 17663
diff changeset
755
26bff2090889 Update Bonjour to do nonblocking I/O correctly.
Daniel Atallah <datallah@pidgin.im>
parents: 17663
diff changeset
756 conv = purple_find_conversation_with_account(PURPLE_CONV_TYPE_IM, bb->name, pb->account);
26bff2090889 Update Bonjour to do nonblocking I/O correctly.
Daniel Atallah <datallah@pidgin.im>
parents: 17663
diff changeset
757 if (conv != NULL)
26bff2090889 Update Bonjour to do nonblocking I/O correctly.
Daniel Atallah <datallah@pidgin.im>
parents: 17663
diff changeset
758 purple_conversation_write(conv, NULL,
26bff2090889 Update Bonjour to do nonblocking I/O correctly.
Daniel Atallah <datallah@pidgin.im>
parents: 17663
diff changeset
759 _("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
760 PURPLE_MESSAGE_SYSTEM, time(NULL));
26bff2090889 Update Bonjour to do nonblocking I/O correctly.
Daniel Atallah <datallah@pidgin.im>
parents: 17663
diff changeset
761
26bff2090889 Update Bonjour to do nonblocking I/O correctly.
Daniel Atallah <datallah@pidgin.im>
parents: 17663
diff changeset
762 bonjour_jabber_close_conversation(bb->conversation);
26bff2090889 Update Bonjour to do nonblocking I/O correctly.
Daniel Atallah <datallah@pidgin.im>
parents: 17663
diff changeset
763 bb->conversation = NULL;
26bff2090889 Update Bonjour to do nonblocking I/O correctly.
Daniel Atallah <datallah@pidgin.im>
parents: 17663
diff changeset
764 return;
26bff2090889 Update Bonjour to do nonblocking I/O correctly.
Daniel Atallah <datallah@pidgin.im>
parents: 17663
diff changeset
765 }
26bff2090889 Update Bonjour to do nonblocking I/O correctly.
Daniel Atallah <datallah@pidgin.im>
parents: 17663
diff changeset
766
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
767 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
768 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
769 PurpleConversation *conv;
26bff2090889 Update Bonjour to do nonblocking I/O correctly.
Daniel Atallah <datallah@pidgin.im>
parents: 17663
diff changeset
770
26bff2090889 Update Bonjour to do nonblocking I/O correctly.
Daniel Atallah <datallah@pidgin.im>
parents: 17663
diff changeset
771 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
772 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
773
26bff2090889 Update Bonjour to do nonblocking I/O correctly.
Daniel Atallah <datallah@pidgin.im>
parents: 17663
diff changeset
774 conv = purple_find_conversation_with_account(PURPLE_CONV_TYPE_IM, bb->name, pb->account);
26bff2090889 Update Bonjour to do nonblocking I/O correctly.
Daniel Atallah <datallah@pidgin.im>
parents: 17663
diff changeset
775 if (conv != NULL)
26bff2090889 Update Bonjour to do nonblocking I/O correctly.
Daniel Atallah <datallah@pidgin.im>
parents: 17663
diff changeset
776 purple_conversation_write(conv, NULL,
26bff2090889 Update Bonjour to do nonblocking I/O correctly.
Daniel Atallah <datallah@pidgin.im>
parents: 17663
diff changeset
777 _("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
778 PURPLE_MESSAGE_SYSTEM, time(NULL));
26bff2090889 Update Bonjour to do nonblocking I/O correctly.
Daniel Atallah <datallah@pidgin.im>
parents: 17663
diff changeset
779
26bff2090889 Update Bonjour to do nonblocking I/O correctly.
Daniel Atallah <datallah@pidgin.im>
parents: 17663
diff changeset
780 close(source);
26bff2090889 Update Bonjour to do nonblocking I/O correctly.
Daniel Atallah <datallah@pidgin.im>
parents: 17663
diff changeset
781 bonjour_jabber_close_conversation(bb->conversation);
26bff2090889 Update Bonjour to do nonblocking I/O correctly.
Daniel Atallah <datallah@pidgin.im>
parents: 17663
diff changeset
782 bb->conversation = NULL;
26bff2090889 Update Bonjour to do nonblocking I/O correctly.
Daniel Atallah <datallah@pidgin.im>
parents: 17663
diff changeset
783 return;
26bff2090889 Update Bonjour to do nonblocking I/O correctly.
Daniel Atallah <datallah@pidgin.im>
parents: 17663
diff changeset
784 }
21727
decfc3a613ff applied changes from b9c97ed0f9ada9069e8bd994b01fdde0b484083c
Daniel Atallah <datallah@pidgin.im>
parents: 21720
diff changeset
785
decfc3a613ff applied changes from b9c97ed0f9ada9069e8bd994b01fdde0b484083c
Daniel Atallah <datallah@pidgin.im>
parents: 21720
diff changeset
786 /* Start listening for the stream acknowledgement */
decfc3a613ff applied changes from b9c97ed0f9ada9069e8bd994b01fdde0b484083c
Daniel Atallah <datallah@pidgin.im>
parents: 21720
diff changeset
787 bb->conversation->socket = source;
decfc3a613ff applied changes from b9c97ed0f9ada9069e8bd994b01fdde0b484083c
Daniel Atallah <datallah@pidgin.im>
parents: 21720
diff changeset
788 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
789 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
790 }
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
791
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
792 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
793 bonjour_jabber_conv_match_by_name(BonjourJabberConversation *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
794 PurpleBuddy *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
795
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
796 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
797 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
798
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
799 pb = purple_find_buddy(bconv->account, 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
800 if (pb && pb->proto_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
801 BonjourBuddy *bb = pb->proto_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
802 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
803 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
804
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
805 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
806 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
807
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
808 /* 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
809 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
810 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
811 if (ip != NULL && g_ascii_strcasecmp(ip, bconv->ip) == 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
812 BonjourJabber *jdata = ((BonjourData*) bconv->account->gc->proto_data)->jabber_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
813
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
814 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
815 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
816
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
817 /* 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
818 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
819
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
820 /* 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
821 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
822 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
823
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
824 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
825 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
826
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
827 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
828 }
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
829 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
830 }
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
831 }
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
832
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
833 /* 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
834 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
835 /* 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
836 * 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
837 */
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
838 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
839 }
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
840 }
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
841
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
842
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
843 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
844 bonjour_jabber_conv_match_by_ip(BonjourJabberConversation *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
845 BonjourJabber *jdata = ((BonjourData*) bconv->account->gc->proto_data)->jabber_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
846 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
847
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
848 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
849 mbba->address = 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
850 mbba->jdata = jdata;
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
851 g_hash_table_foreach(purple_get_blist()->buddies, _match_buddies_by_address, 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
852
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
853 /* 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
854 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
855 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
856 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
857 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
858 PurpleBuddy *pb = mbba->matched_buddies->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
859 BonjourBuddy *bb = pb->proto_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
860
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
861 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
862 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
863
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
864 /* 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
865 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
866
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
867 /* 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
868 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
869 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
870
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
871 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
872 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
873 }
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
874 } 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
875 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
876
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
877 /* 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
878 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
879 /* 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
880 * 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
881 */
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
882 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
883 }
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
884
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 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
886 g_free(mbba);
17665
26bff2090889 Update Bonjour to do nonblocking I/O correctly.
Daniel Atallah <datallah@pidgin.im>
parents: 17663
diff changeset
887 }
26bff2090889 Update Bonjour to do nonblocking I/O correctly.
Daniel Atallah <datallah@pidgin.im>
parents: 17663
diff changeset
888
21528
06532211eb62 Leak fix, cleanup and code reuse.
Daniel Atallah <datallah@pidgin.im>
parents: 21527
diff changeset
889 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
890 _find_or_start_conversation(BonjourJabber *jdata, const gchar *to)
11477
98b4f8643569 [gaim-migrate @ 13719]
Mark Doliner <markdoliner@pidgin.im>
parents:
diff changeset
891 {
21528
06532211eb62 Leak fix, cleanup and code reuse.
Daniel Atallah <datallah@pidgin.im>
parents: 21527
diff changeset
892 PurpleBuddy *pb = NULL;
06532211eb62 Leak fix, cleanup and code reuse.
Daniel Atallah <datallah@pidgin.im>
parents: 21527
diff changeset
893 BonjourBuddy *bb = NULL;
06532211eb62 Leak fix, cleanup and code reuse.
Daniel Atallah <datallah@pidgin.im>
parents: 21527
diff changeset
894
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
895 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
896 g_return_val_if_fail(to != NULL, NULL);
11539
fbabe3f89777 [gaim-migrate @ 13794]
Mark Doliner <markdoliner@pidgin.im>
parents: 11515
diff changeset
897
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
898 pb = purple_find_buddy(jdata->account, to);
21528
06532211eb62 Leak fix, cleanup and code reuse.
Daniel Atallah <datallah@pidgin.im>
parents: 21527
diff changeset
899 if (pb == NULL || pb->proto_data == NULL)
11693
1a42a66ca0f8 [gaim-migrate @ 13979]
Mark Doliner <markdoliner@pidgin.im>
parents: 11688
diff changeset
900 /* 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
901 return NULL;
11693
1a42a66ca0f8 [gaim-migrate @ 13979]
Mark Doliner <markdoliner@pidgin.im>
parents: 11688
diff changeset
902
21528
06532211eb62 Leak fix, cleanup and code reuse.
Daniel Atallah <datallah@pidgin.im>
parents: 21527
diff changeset
903 bb = (BonjourBuddy *) pb->proto_data;
11693
1a42a66ca0f8 [gaim-migrate @ 13979]
Mark Doliner <markdoliner@pidgin.im>
parents: 11688
diff changeset
904
17607
4d7a1c0f169b Improve error handling while connecting to a bonjour buddy.
Daniel Atallah <datallah@pidgin.im>
parents: 17596
diff changeset
905 /* 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
906 if (bb->conversation == NULL)
4d7a1c0f169b Improve error handling while connecting to a bonjour buddy.
Daniel Atallah <datallah@pidgin.im>
parents: 17596
diff changeset
907 {
17665
26bff2090889 Update Bonjour to do nonblocking I/O correctly.
Daniel Atallah <datallah@pidgin.im>
parents: 17663
diff changeset
908 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
909 PurpleProxyInfo *proxy_info;
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
910 /* For better or worse, use the first IP*/
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
911 const char *ip = bb->ips->data;
17665
26bff2090889 Update Bonjour to do nonblocking I/O correctly.
Daniel Atallah <datallah@pidgin.im>
parents: 17663
diff changeset
912
21549
7436059db33b Don't map the port used for bonjour file transfers externally. This adds a new function that will go away in 3.0.0 when we can modify purple_network_do_listen to take an additional parameter.
Daniel Atallah <datallah@pidgin.im>
parents: 21548
diff changeset
913 purple_debug_info("bonjour", "Starting conversation with %s\n", to);
21528
06532211eb62 Leak fix, cleanup and code reuse.
Daniel Atallah <datallah@pidgin.im>
parents: 21527
diff changeset
914
17665
26bff2090889 Update Bonjour to do nonblocking I/O correctly.
Daniel Atallah <datallah@pidgin.im>
parents: 17663
diff changeset
915 /* 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
916 * 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
917 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
918 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
919 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
920 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
921 }
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
922 purple_proxy_info_set_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
923
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
924 connect_data = purple_proxy_connect(NULL, 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
925 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
926
26bff2090889 Update Bonjour to do nonblocking I/O correctly.
Daniel Atallah <datallah@pidgin.im>
parents: 17663
diff changeset
927 if (connect_data == NULL) {
26bff2090889 Update Bonjour to do nonblocking I/O correctly.
Daniel Atallah <datallah@pidgin.im>
parents: 17663
diff changeset
928 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
929 return NULL;
17665
26bff2090889 Update Bonjour to do nonblocking I/O correctly.
Daniel Atallah <datallah@pidgin.im>
parents: 17663
diff changeset
930 }
17607
4d7a1c0f169b Improve error handling while connecting to a bonjour buddy.
Daniel Atallah <datallah@pidgin.im>
parents: 17596
diff changeset
931
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
932 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
933 bb->conversation->connect_data = connect_data;
26bff2090889 Update Bonjour to do nonblocking I/O correctly.
Daniel Atallah <datallah@pidgin.im>
parents: 17663
diff changeset
934 /* 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
935 * 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
936 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
937 }
21528
06532211eb62 Leak fix, cleanup and code reuse.
Daniel Atallah <datallah@pidgin.im>
parents: 21527
diff changeset
938 return pb;
06532211eb62 Leak fix, cleanup and code reuse.
Daniel Atallah <datallah@pidgin.im>
parents: 21527
diff changeset
939 }
06532211eb62 Leak fix, cleanup and code reuse.
Daniel Atallah <datallah@pidgin.im>
parents: 21527
diff changeset
940
06532211eb62 Leak fix, cleanup and code reuse.
Daniel Atallah <datallah@pidgin.im>
parents: 21527
diff changeset
941 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
942 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
943 {
06532211eb62 Leak fix, cleanup and code reuse.
Daniel Atallah <datallah@pidgin.im>
parents: 21527
diff changeset
944 xmlnode *message_node, *node, *node2;
06532211eb62 Leak fix, cleanup and code reuse.
Daniel Atallah <datallah@pidgin.im>
parents: 21527
diff changeset
945 gchar *message;
06532211eb62 Leak fix, cleanup and code reuse.
Daniel Atallah <datallah@pidgin.im>
parents: 21527
diff changeset
946 PurpleBuddy *pb;
06532211eb62 Leak fix, cleanup and code reuse.
Daniel Atallah <datallah@pidgin.im>
parents: 21527
diff changeset
947 BonjourBuddy *bb;
06532211eb62 Leak fix, cleanup and code reuse.
Daniel Atallah <datallah@pidgin.im>
parents: 21527
diff changeset
948 int ret;
06532211eb62 Leak fix, cleanup and code reuse.
Daniel Atallah <datallah@pidgin.im>
parents: 21527
diff changeset
949
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
950 pb = _find_or_start_conversation(jdata, to);
23160
0aff8f3882f4 applied changes from 3d595739f53a259d5dae408a05f64d2836f02ac9
Daniel Atallah <datallah@pidgin.im>
parents: 23072
diff changeset
951 if (pb == NULL || pb->proto_data == NULL) {
21528
06532211eb62 Leak fix, cleanup and code reuse.
Daniel Atallah <datallah@pidgin.im>
parents: 21527
diff changeset
952 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
953 /* 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
954 return -10000;
06532211eb62 Leak fix, cleanup and code reuse.
Daniel Atallah <datallah@pidgin.im>
parents: 21527
diff changeset
955 }
06532211eb62 Leak fix, cleanup and code reuse.
Daniel Atallah <datallah@pidgin.im>
parents: 21527
diff changeset
956
06532211eb62 Leak fix, cleanup and code reuse.
Daniel Atallah <datallah@pidgin.im>
parents: 21527
diff changeset
957 bb = pb->proto_data;
17607
4d7a1c0f169b Improve error handling while connecting to a bonjour buddy.
Daniel Atallah <datallah@pidgin.im>
parents: 17596
diff changeset
958
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
959 message_node = xmlnode_new("message");
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
960 xmlnode_set_attrib(message_node, "to", bb->name);
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
961 xmlnode_set_attrib(message_node, "from", purple_account_get_username(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
962 xmlnode_set_attrib(message_node, "type", "chat");
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
963
11826
10ebbc41f163 [gaim-migrate @ 14117]
Richard Laager <rlaager@pidgin.im>
parents: 11823
diff changeset
964 /* Enclose the message from the UI within a "font" node */
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
965 node = xmlnode_new_child(message_node, "body");
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
966 message = purple_markup_strip_html(body);
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
967 xmlnode_insert_data(node, message, strlen(message));
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
968 g_free(message);
11539
fbabe3f89777 [gaim-migrate @ 13794]
Mark Doliner <markdoliner@pidgin.im>
parents: 11515
diff changeset
969
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
970 node = xmlnode_new_child(message_node, "html");
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
971 xmlnode_set_namespace(node, "http://www.w3.org/1999/xhtml");
11539
fbabe3f89777 [gaim-migrate @ 13794]
Mark Doliner <markdoliner@pidgin.im>
parents: 11515
diff changeset
972
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
973 node = xmlnode_new_child(node, "body");
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
974 message = g_strdup_printf("<font>%s</font>", body);
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
975 node2 = xmlnode_from_str(message, strlen(message));
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
976 g_free(message);
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
977 xmlnode_insert_child(node, node2);
11539
fbabe3f89777 [gaim-migrate @ 13794]
Mark Doliner <markdoliner@pidgin.im>
parents: 11515
diff changeset
978
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
979 node = xmlnode_new_child(message_node, "x");
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
980 xmlnode_set_namespace(node, "jabber:x:event");
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
981 xmlnode_insert_child(node, xmlnode_new("composing"));
11539
fbabe3f89777 [gaim-migrate @ 13794]
Mark Doliner <markdoliner@pidgin.im>
parents: 11515
diff changeset
982
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
983 message = xmlnode_to_str(message_node, NULL);
15873
78d3aa0fb61e plug some memory leaks
Stu Tomlinson <nosnilmot@pidgin.im>
parents: 15435
diff changeset
984 xmlnode_free(message_node);
11477
98b4f8643569 [gaim-migrate @ 13719]
Mark Doliner <markdoliner@pidgin.im>
parents:
diff changeset
985
17665
26bff2090889 Update Bonjour to do nonblocking I/O correctly.
Daniel Atallah <datallah@pidgin.im>
parents: 17663
diff changeset
986 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
987
15873
78d3aa0fb61e plug some memory leaks
Stu Tomlinson <nosnilmot@pidgin.im>
parents: 15435
diff changeset
988 g_free(message);
78d3aa0fb61e plug some memory leaks
Stu Tomlinson <nosnilmot@pidgin.im>
parents: 15435
diff changeset
989
17665
26bff2090889 Update Bonjour to do nonblocking I/O correctly.
Daniel Atallah <datallah@pidgin.im>
parents: 17663
diff changeset
990 return ret;
11477
98b4f8643569 [gaim-migrate @ 13719]
Mark Doliner <markdoliner@pidgin.im>
parents:
diff changeset
991 }
98b4f8643569 [gaim-migrate @ 13719]
Mark Doliner <markdoliner@pidgin.im>
parents:
diff changeset
992
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
993 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
994 _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
995 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
996 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
997 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
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
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 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
1001 async_bonjour_jabber_close_conversation(BonjourJabberConversation *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
1002 BonjourJabber *jdata = ((BonjourData*) bconv->account->gc->proto_data)->jabber_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
1003
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 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
1005
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 /* 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
1007 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
1008 BonjourBuddy *bb = bconv->pb->proto_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
1009 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
1010 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
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
22238
c69aff70828d Prevent a crash caused by freed memory being accessed.
Daniel Atallah <datallah@pidgin.im>
parents: 21944
diff changeset
1013 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
1014 }
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
1015
11539
fbabe3f89777 [gaim-migrate @ 13794]
Mark Doliner <markdoliner@pidgin.im>
parents: 11515
diff changeset
1016 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
1017 bonjour_jabber_close_conversation(BonjourJabberConversation *bconv)
11477
98b4f8643569 [gaim-migrate @ 13719]
Mark Doliner <markdoliner@pidgin.im>
parents:
diff changeset
1018 {
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
1019 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
1020 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
1021
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
1022 if(PURPLE_CONNECTION_IS_VALID(bconv->account->gc)) {
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 bd = bconv->account->gc->proto_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
1024 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
1025 }
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
1026
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
1027 /* 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
1028 /* 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
1029 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
1030 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
1031 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
1032 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
1033 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
1034 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
1035 /* 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
1036 /* This will change if we ever support IBB transfers. */
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
1037 if (strcmp(xfer->who, bconv->pb->name) == 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
1038 && (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
1039 || 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
1040 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
1041 }
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 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
1043 }
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
1044 }
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
1045
11826
10ebbc41f163 [gaim-migrate @ 14117]
Richard Laager <rlaager@pidgin.im>
parents: 11823
diff changeset
1046 /* 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
1047 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
1048 /* 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
1049 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
1050 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
1051 /* 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
1052 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
1053 }
19579
d79d5c95ce5a Reset unsigned int input handlers to 0 instead of -1.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 19373
diff changeset
1054 if (bconv->rx_handler != 0)
17665
26bff2090889 Update Bonjour to do nonblocking I/O correctly.
Daniel Atallah <datallah@pidgin.im>
parents: 17663
diff changeset
1055 purple_input_remove(bconv->rx_handler);
26bff2090889 Update Bonjour to do nonblocking I/O correctly.
Daniel Atallah <datallah@pidgin.im>
parents: 17663
diff changeset
1056 if (bconv->tx_handler > 0)
26bff2090889 Update Bonjour to do nonblocking I/O correctly.
Daniel Atallah <datallah@pidgin.im>
parents: 17663
diff changeset
1057 purple_input_remove(bconv->tx_handler);
11539
fbabe3f89777 [gaim-migrate @ 13794]
Mark Doliner <markdoliner@pidgin.im>
parents: 11515
diff changeset
1058
11826
10ebbc41f163 [gaim-migrate @ 14117]
Richard Laager <rlaager@pidgin.im>
parents: 11823
diff changeset
1059 /* Free all the data related to the conversation */
17665
26bff2090889 Update Bonjour to do nonblocking I/O correctly.
Daniel Atallah <datallah@pidgin.im>
parents: 17663
diff changeset
1060 purple_circ_buffer_destroy(bconv->tx_buf);
26bff2090889 Update Bonjour to do nonblocking I/O correctly.
Daniel Atallah <datallah@pidgin.im>
parents: 17663
diff changeset
1061 if (bconv->connect_data != NULL)
26bff2090889 Update Bonjour to do nonblocking I/O correctly.
Daniel Atallah <datallah@pidgin.im>
parents: 17663
diff changeset
1062 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
1063 if (bconv->stream_data != NULL) {
26bff2090889 Update Bonjour to do nonblocking I/O correctly.
Daniel Atallah <datallah@pidgin.im>
parents: 17663
diff changeset
1064 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
1065 g_free(ss->msg);
26bff2090889 Update Bonjour to do nonblocking I/O correctly.
Daniel Atallah <datallah@pidgin.im>
parents: 17663
diff changeset
1066 g_free(ss);
26bff2090889 Update Bonjour to do nonblocking I/O correctly.
Daniel Atallah <datallah@pidgin.im>
parents: 17663
diff changeset
1067 }
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
1068
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
1069 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
1070 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
1071
22238
c69aff70828d Prevent a crash caused by freed memory being accessed.
Daniel Atallah <datallah@pidgin.im>
parents: 21944
diff changeset
1072 if (bconv->close_timeout != 0)
c69aff70828d Prevent a crash caused by freed memory being accessed.
Daniel Atallah <datallah@pidgin.im>
parents: 21944
diff changeset
1073 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
1074
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
1075 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
1076 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
1077 g_free(bconv);
11477
98b4f8643569 [gaim-migrate @ 13719]
Mark Doliner <markdoliner@pidgin.im>
parents:
diff changeset
1078 }
98b4f8643569 [gaim-migrate @ 13719]
Mark Doliner <markdoliner@pidgin.im>
parents:
diff changeset
1079 }
98b4f8643569 [gaim-migrate @ 13719]
Mark Doliner <markdoliner@pidgin.im>
parents:
diff changeset
1080
11539
fbabe3f89777 [gaim-migrate @ 13794]
Mark Doliner <markdoliner@pidgin.im>
parents: 11515
diff changeset
1081 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
1082 bonjour_jabber_stop(BonjourJabber *jdata)
11477
98b4f8643569 [gaim-migrate @ 13719]
Mark Doliner <markdoliner@pidgin.im>
parents:
diff changeset
1083 {
17633
b76241c02857 Some more Bonjour cleanup and leak fixing.
Daniel Atallah <datallah@pidgin.im>
parents: 17632
diff changeset
1084 /* 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
1085 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
1086 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
1087 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
1088 purple_input_remove(jdata->watcher_id);
11539
fbabe3f89777 [gaim-migrate @ 13794]
Mark Doliner <markdoliner@pidgin.im>
parents: 11515
diff changeset
1089
17633
b76241c02857 Some more Bonjour cleanup and leak fixing.
Daniel Atallah <datallah@pidgin.im>
parents: 17632
diff changeset
1090 /* Close all the conversation sockets and remove all the watchers after sending end streams */
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
1091 if (jdata->account->gc != NULL) {
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
1092 GSList *buddies, *l;
17633
b76241c02857 Some more Bonjour cleanup and leak fixing.
Daniel Atallah <datallah@pidgin.im>
parents: 17632
diff changeset
1093
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
1094 buddies = purple_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
1095 for (l = buddies; l; l = l->next) {
fd736a4d91a9 Close conversation connections when logging out of the Bonjour account. This also fixes leakage.
Daniel Atallah <datallah@pidgin.im>
parents: 17662
diff changeset
1096 BonjourBuddy *bb = ((PurpleBuddy*) l->data)->proto_data;
23160
0aff8f3882f4 applied changes from 3d595739f53a259d5dae408a05f64d2836f02ac9
Daniel Atallah <datallah@pidgin.im>
parents: 23072
diff changeset
1097 if (bb != NULL) {
0aff8f3882f4 applied changes from 3d595739f53a259d5dae408a05f64d2836f02ac9
Daniel Atallah <datallah@pidgin.im>
parents: 23072
diff changeset
1098 bonjour_jabber_close_conversation(bb->conversation);
0aff8f3882f4 applied changes from 3d595739f53a259d5dae408a05f64d2836f02ac9
Daniel Atallah <datallah@pidgin.im>
parents: 23072
diff changeset
1099 bb->conversation = NULL;
0aff8f3882f4 applied changes from 3d595739f53a259d5dae408a05f64d2836f02ac9
Daniel Atallah <datallah@pidgin.im>
parents: 23072
diff changeset
1100 }
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
1101 }
17665
26bff2090889 Update Bonjour to do nonblocking I/O correctly.
Daniel Atallah <datallah@pidgin.im>
parents: 17663
diff changeset
1102
11477
98b4f8643569 [gaim-migrate @ 13719]
Mark Doliner <markdoliner@pidgin.im>
parents:
diff changeset
1103 g_slist_free(buddies);
98b4f8643569 [gaim-migrate @ 13719]
Mark Doliner <markdoliner@pidgin.im>
parents:
diff changeset
1104 }
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
1105
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
1106 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
1107 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
1108 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
1109 }
11477
98b4f8643569 [gaim-migrate @ 13719]
Mark Doliner <markdoliner@pidgin.im>
parents:
diff changeset
1110 }
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
1111
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
1112 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
1113 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
1114 {
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
1115 xmlnode *iq_node = 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
1116 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
1117
21548
b19c433f5af2 Cleanup and fix the socks5 proxy connect address to be correct.
Daniel Atallah <datallah@pidgin.im>
parents: 21547
diff changeset
1118 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
1119 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
1120 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
1121
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
1122 iq_node = xmlnode_new("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
1123
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
1124 xmlnode_set_attrib(iq_node, "to", 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
1125 xmlnode_set_attrib(iq_node, "from", from);
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
1126 xmlnode_set_attrib(iq_node, "id", id);
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
1127 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
1128 case XEP_IQ_SET:
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
1129 xmlnode_set_attrib(iq_node, "type", "set");
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
1130 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
1131 case XEP_IQ_GET:
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
1132 xmlnode_set_attrib(iq_node, "type", "get");
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
1133 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
1134 case XEP_IQ_RESULT:
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
1135 xmlnode_set_attrib(iq_node, "type", "result");
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
1136 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
1137 case XEP_IQ_ERROR:
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
1138 xmlnode_set_attrib(iq_node, "type", "error");
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
1139 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
1140 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
1141 default:
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
1142 xmlnode_set_attrib(iq_node, "type", "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
1143 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
1144 }
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
1145
21548
b19c433f5af2 Cleanup and fix the socks5 proxy connect address to be correct.
Daniel Atallah <datallah@pidgin.im>
parents: 21547
diff changeset
1146 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
1147 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
1148 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
1149 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
1150 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
1151
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
1152 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
1153 }
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
1154
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
1155 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
1156 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
1157 {
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
1158 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
1159 GSList *l = 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
1160 PurpleAccount *acc = 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
1161
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
1162 if(pb == 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
1163 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
1164
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
1165 acc = pb->account;
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
1166
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
1167 for(l = acc->deny; l != NULL; l = l->next) {
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
1168 if(!purple_utf8_strcasecmp(pb->name, (char *)l->data)) {
22622
1ecb840b5101 Fix a bunch of compiler warnings caused by my addition of G_GNUC_PRINTF()
Mark Doliner <markdoliner@pidgin.im>
parents: 22238
diff changeset
1169 purple_debug_info("bonjour", "%s has been blocked by %s.\n", pb->name, acc->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
1170 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
1171 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
1172 }
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
1173 }
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
1174 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
1175 }
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
1176
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
1177 static void
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
1178 xep_iq_parse(xmlnode *packet, PurpleConnection *connection, 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
1179 {
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
1180 xmlnode *child = 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
1181
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
1182 if(packet == NULL || pb == 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
1183 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
1184
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
1185 if(connection == 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
1186 if(pb->account != 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
1187 connection = (pb->account)->gc;
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
1188 }
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
1189
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
1190 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
1191 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
1192
21547
036a226f02e5 I messed this up at some point.
Daniel Atallah <datallah@pidgin.im>
parents: 21546
diff changeset
1193 if ((child = xmlnode_get_child(packet, "si")) || (child = xmlnode_get_child(packet, "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
1194 xep_si_parse(connection, packet, 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
1195 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
1196 xep_bytestreams_parse(connection, packet, 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
1197 }
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
1198
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
1199 int
21548
b19c433f5af2 Cleanup and fix the socks5 proxy connect address to be correct.
Daniel Atallah <datallah@pidgin.im>
parents: 21547
diff changeset
1200 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
1201 {
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
1202 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
1203 PurpleBuddy *pb = NULL;
21528
06532211eb62 Leak fix, cleanup and code reuse.
Daniel Atallah <datallah@pidgin.im>
parents: 21527
diff changeset
1204
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
1205 /* 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
1206 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
1207 /* Send the message */
21528
06532211eb62 Leak fix, cleanup and code reuse.
Daniel Atallah <datallah@pidgin.im>
parents: 21527
diff changeset
1208 if (pb != NULL) {
06532211eb62 Leak fix, cleanup and code reuse.
Daniel Atallah <datallah@pidgin.im>
parents: 21527
diff changeset
1209 /* Convert xml node into stream */
06532211eb62 Leak fix, cleanup and code reuse.
Daniel Atallah <datallah@pidgin.im>
parents: 21527
diff changeset
1210 gchar *msg = 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
1211 ret = _send_data(pb, msg);
21528
06532211eb62 Leak fix, cleanup and code reuse.
Daniel Atallah <datallah@pidgin.im>
parents: 21527
diff changeset
1212 g_free(msg);
06532211eb62 Leak fix, cleanup and code reuse.
Daniel Atallah <datallah@pidgin.im>
parents: 21527
diff changeset
1213 }
21548
b19c433f5af2 Cleanup and fix the socks5 proxy connect address to be correct.
Daniel Atallah <datallah@pidgin.im>
parents: 21547
diff changeset
1214
21528
06532211eb62 Leak fix, cleanup and code reuse.
Daniel Atallah <datallah@pidgin.im>
parents: 21527
diff changeset
1215 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
1216 iq->node = NULL;
b19c433f5af2 Cleanup and fix the socks5 proxy connect address to be correct.
Daniel Atallah <datallah@pidgin.im>
parents: 21547
diff changeset
1217 g_free(iq);
21528
06532211eb62 Leak fix, cleanup and code reuse.
Daniel Atallah <datallah@pidgin.im>
parents: 21527
diff changeset
1218
06532211eb62 Leak fix, cleanup and code reuse.
Daniel Atallah <datallah@pidgin.im>
parents: 21527
diff changeset
1219 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
1220 }
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
1221
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
1222 /* This returns a ';' delimited string containing all non-localhost IPs */
21548
b19c433f5af2 Cleanup and fix the socks5 proxy connect address to be correct.
Daniel Atallah <datallah@pidgin.im>
parents: 21547
diff changeset
1223 const char *
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
1224 purple_network_get_my_ip_ext2(int 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
1225 {
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
1226 char buffer[1024];
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
1227 static char ip_ext[17 * 10];
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
1228 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
1229 char *tip;
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
1230 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
1231 struct 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
1232 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
1233 guint32 lhost = htonl(127 * 256 * 256 * 256 + 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
1234 long unsigned int add;
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
1235 int source = fd;
21546
4e6a286108b2 Don't allow the buffer to be overrun when you have lots of local IPs.
Daniel Atallah <datallah@pidgin.im>
parents: 21528
diff changeset
1236 int len, count = 0;
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
1237
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
1238 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
1239 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
1240
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
1241 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
1242 ifc.ifc_req = (struct ifreq *)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
1243 ioctl(source, SIOCGIFCONF, &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
1244
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
1245 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
1246 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
1247
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
1248 memset(ip_ext, 0, sizeof(ip_ext));
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 memcpy(ip_ext, "0.0.0.0", 7);
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 tmp = 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
1251 tip = ip_ext;
21546
4e6a286108b2 Don't allow the buffer to be overrun when you have lots of local IPs.
Daniel Atallah <datallah@pidgin.im>
parents: 21528
diff changeset
1252 while (tmp < buffer + ifc.ifc_len && count < 10)
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
1253 {
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 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
1255 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
1256
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
1257 if (ifr->ifr_addr.sa_family == AF_INET)
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
1258 {
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 sinptr = (struct sockaddr_in *)&ifr->ifr_addr;
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
1260 if (sinptr->sin_addr.s_addr != lhost)
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 {
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
1262 add = ntohl(sinptr->sin_addr.s_addr);
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
1263 len = g_snprintf(tip, 17, "%lu.%lu.%lu.%lu;",
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
1264 ((add >> 24) & 255),
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 ((add >> 16) & 255),
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 ((add >> 8) & 255),
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
1267 add & 255);
21638
514856e8d5c5 Get rid of two compile warnings:
Mark Doliner <markdoliner@pidgin.im>
parents: 21612
diff changeset
1268 tip = &tip[len];
21546
4e6a286108b2 Don't allow the buffer to be overrun when you have lots of local IPs.
Daniel Atallah <datallah@pidgin.im>
parents: 21528
diff changeset
1269 count++;
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
1270 continue;
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 }
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 }
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
1273 }
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
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 return ip_ext;
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
1276 }

mercurial