libpurple/protocols/bonjour/xmpp.c

Fri, 20 Nov 2020 02:10:50 -0600

author
Gary Kramlich <grim@reaperworld.com>
date
Fri, 20 Nov 2020 02:10:50 -0600
changeset 40617
3e8d3f5d6b01
parent 40474
1341be8e3402
child 40666
2d9bed1714c7
permissions
-rw-r--r--

Depend on libnice as farstream already pulled it in and replace purple_network_get_all_local_system_ips with nice_interfaces_get_local_ips.

Testing Done:
Compiled and ran the unit tests.

Reviewed at https://reviews.imfreedom.org/r/239/

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
40441
f23c7e772667 Make sure we're not including the gettext macros in header files and deal with the repercussions of that.
Gary Kramlich <grim@reaperworld.com>
parents: 40439
diff changeset
23 #include <glib/gi18n-lib.h>
f23c7e772667 Make sure we're not including the gettext macros in header files and deal with the repercussions of that.
Gary Kramlich <grim@reaperworld.com>
parents: 40439
diff changeset
24
39960
4a5610d858ef update bonjour to just use purple.h
Gary Kramlich <grim@reaperworld.com>
parents: 39660
diff changeset
25 #include <purple.h>
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
26
11688
d5a7c35ddc80 [gaim-migrate @ 13974]
Daniel Atallah <datallah@pidgin.im>
parents: 11539
diff changeset
27 #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
28 #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
29 #include <sys/ioctl.h>
11477
98b4f8643569 [gaim-migrate @ 13719]
Mark Doliner <markdoliner@pidgin.im>
parents:
diff changeset
30 #include <sys/socket.h>
98b4f8643569 [gaim-migrate @ 13719]
Mark Doliner <markdoliner@pidgin.im>
parents:
diff changeset
31 #include <netinet/in.h>
98b4f8643569 [gaim-migrate @ 13719]
Mark Doliner <markdoliner@pidgin.im>
parents:
diff changeset
32 #include <arpa/inet.h>
11688
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
40080
a58c06469198 Rename Jabber to XMPP in Bonjour, as the official name is now XMPP and has been
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 40052
diff changeset
47 #include "xmpp.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
48 #include "parser.h"
11477
98b4f8643569 [gaim-migrate @ 13719]
Mark Doliner <markdoliner@pidgin.im>
parents:
diff changeset
49 #include "bonjour.h"
98b4f8643569 [gaim-migrate @ 13719]
Mark Doliner <markdoliner@pidgin.im>
parents:
diff changeset
50 #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
51 #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
52
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
53 #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
54 # 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
55 #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
56 # 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
57 #endif
11477
98b4f8643569 [gaim-migrate @ 13719]
Mark Doliner <markdoliner@pidgin.im>
parents:
diff changeset
58
17661
96c6a21c4139 Send 'to' and 'from' attributes in the stream start message.
Daniel Atallah <datallah@pidgin.im>
parents: 17660
diff changeset
59 #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
60 /* 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
61 #define DOCTYPE "<?xml version=\"1.0\" encoding=\"UTF-8\" ?>\n" \
40082
b8e9a7b626d4 Fix some namespace changes that I made accidentally. Also add a G_UNLIKELY
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 40081
diff changeset
62 "<stream:stream xmlns=\"jabber:client\" xmlns:stream=\"http://etherx.jabber.org/streams\" from=\"%s\" to=\"%s\">"
17661
96c6a21c4139 Send 'to' and 'from' attributes in the stream start message.
Daniel Atallah <datallah@pidgin.im>
parents: 17660
diff changeset
63
21727
decfc3a613ff applied changes from b9c97ed0f9ada9069e8bd994b01fdde0b484083c
Daniel Atallah <datallah@pidgin.im>
parents: 21720
diff changeset
64 enum sent_stream_start_types {
decfc3a613ff applied changes from b9c97ed0f9ada9069e8bd994b01fdde0b484083c
Daniel Atallah <datallah@pidgin.im>
parents: 21720
diff changeset
65 NOT_SENT = 0,
decfc3a613ff applied changes from b9c97ed0f9ada9069e8bd994b01fdde0b484083c
Daniel Atallah <datallah@pidgin.im>
parents: 21720
diff changeset
66 PARTIALLY_SENT = 1,
decfc3a613ff applied changes from b9c97ed0f9ada9069e8bd994b01fdde0b484083c
Daniel Atallah <datallah@pidgin.im>
parents: 21720
diff changeset
67 FULLY_SENT = 2
decfc3a613ff applied changes from b9c97ed0f9ada9069e8bd994b01fdde0b484083c
Daniel Atallah <datallah@pidgin.im>
parents: 21720
diff changeset
68 };
decfc3a613ff applied changes from b9c97ed0f9ada9069e8bd994b01fdde0b484083c
Daniel Atallah <datallah@pidgin.im>
parents: 21720
diff changeset
69
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
70 static void
34935
686fa55b0deb Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents: 34911
diff changeset
71 xep_iq_parse(PurpleXmlNode *packet, PurpleBuddy *pb);
21524
472e58992083 Patch from some Intel folks to implement file transfer in Bonjour using XEP-0096 and 0065. This hopefully will work with Gaijm (haven't yet tested) and, of course, between libpurple instances; it will not work with Adium or iChat.
Daniel Atallah <datallah@pidgin.im>
parents: 21503
diff changeset
72
40080
a58c06469198 Rename Jabber to XMPP in Bonjour, as the official name is now XMPP and has been
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 40052
diff changeset
73 static BonjourXMPPConversation *
a58c06469198 Rename Jabber to XMPP in Bonjour, as the official name is now XMPP and has been
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 40052
diff changeset
74 bonjour_xmpp_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
75
40080
a58c06469198 Rename Jabber to XMPP in Bonjour, as the official name is now XMPP and has been
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 40052
diff changeset
76 BonjourXMPPConversation *bconv = g_new0(BonjourXMPPConversation, 1);
39639
fe7fa102e766 Convert Bonjour client side to GIO.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39638
diff changeset
77 bconv->cancellable = g_cancellable_new();
34529
68cf25486001 GObjectify PurpleCircBuffer as PurpleCircularBuffer (from gobjectification branch)
Ankit Vani <a@nevitus.org>
parents: 33892
diff changeset
78 bconv->tx_buf = purple_circular_buffer_new(512);
19579
d79d5c95ce5a Reset unsigned int input handlers to 0 instead of -1.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 19373
diff changeset
79 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
80 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
81 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
82 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
83 bconv->ip = g_strdup(ip);
17662
233ff0515d7b Consolidate BonjourJabberConversation creation and deletion.
Daniel Atallah <datallah@pidgin.im>
parents: 17661
diff changeset
84
21727
decfc3a613ff applied changes from b9c97ed0f9ada9069e8bd994b01fdde0b484083c
Daniel Atallah <datallah@pidgin.im>
parents: 21720
diff changeset
85 bonjour_parser_setup(bconv);
decfc3a613ff applied changes from b9c97ed0f9ada9069e8bd994b01fdde0b484083c
Daniel Atallah <datallah@pidgin.im>
parents: 21720
diff changeset
86
17662
233ff0515d7b Consolidate BonjourJabberConversation creation and deletion.
Daniel Atallah <datallah@pidgin.im>
parents: 17661
diff changeset
87 return bconv;
233ff0515d7b Consolidate BonjourJabberConversation creation and deletion.
Daniel Atallah <datallah@pidgin.im>
parents: 17661
diff changeset
88 }
233ff0515d7b Consolidate BonjourJabberConversation creation and deletion.
Daniel Atallah <datallah@pidgin.im>
parents: 17661
diff changeset
89
12443
ad94864144f8 [gaim-migrate @ 14750]
Stu Tomlinson <nosnilmot@pidgin.im>
parents: 11830
diff changeset
90 static const char *
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15873
diff changeset
91 _font_size_ichat_to_purple(int size)
11477
98b4f8643569 [gaim-migrate @ 13719]
Mark Doliner <markdoliner@pidgin.im>
parents:
diff changeset
92 {
98b4f8643569 [gaim-migrate @ 13719]
Mark Doliner <markdoliner@pidgin.im>
parents:
diff changeset
93 if (size > 24) {
11826
10ebbc41f163 [gaim-migrate @ 14117]
Richard Laager <rlaager@pidgin.im>
parents: 11823
diff changeset
94 return "7";
11539
fbabe3f89777 [gaim-migrate @ 13794]
Mark Doliner <markdoliner@pidgin.im>
parents: 11515
diff changeset
95 } else if (size >= 21) {
11826
10ebbc41f163 [gaim-migrate @ 14117]
Richard Laager <rlaager@pidgin.im>
parents: 11823
diff changeset
96 return "6";
11539
fbabe3f89777 [gaim-migrate @ 13794]
Mark Doliner <markdoliner@pidgin.im>
parents: 11515
diff changeset
97 } else if (size >= 17) {
11826
10ebbc41f163 [gaim-migrate @ 14117]
Richard Laager <rlaager@pidgin.im>
parents: 11823
diff changeset
98 return "5";
11539
fbabe3f89777 [gaim-migrate @ 13794]
Mark Doliner <markdoliner@pidgin.im>
parents: 11515
diff changeset
99 } else if (size >= 14) {
11826
10ebbc41f163 [gaim-migrate @ 14117]
Richard Laager <rlaager@pidgin.im>
parents: 11823
diff changeset
100 return "4";
11539
fbabe3f89777 [gaim-migrate @ 13794]
Mark Doliner <markdoliner@pidgin.im>
parents: 11515
diff changeset
101 } else if (size >= 12) {
11826
10ebbc41f163 [gaim-migrate @ 14117]
Richard Laager <rlaager@pidgin.im>
parents: 11823
diff changeset
102 return "3";
11539
fbabe3f89777 [gaim-migrate @ 13794]
Mark Doliner <markdoliner@pidgin.im>
parents: 11515
diff changeset
103 } else if (size >= 10) {
11826
10ebbc41f163 [gaim-migrate @ 14117]
Richard Laager <rlaager@pidgin.im>
parents: 11823
diff changeset
104 return "2";
11477
98b4f8643569 [gaim-migrate @ 13719]
Mark Doliner <markdoliner@pidgin.im>
parents:
diff changeset
105 }
98b4f8643569 [gaim-migrate @ 13719]
Mark Doliner <markdoliner@pidgin.im>
parents:
diff changeset
106
11826
10ebbc41f163 [gaim-migrate @ 14117]
Richard Laager <rlaager@pidgin.im>
parents: 11823
diff changeset
107 return "1";
11477
98b4f8643569 [gaim-migrate @ 13719]
Mark Doliner <markdoliner@pidgin.im>
parents:
diff changeset
108 }
17633
b76241c02857 Some more Bonjour cleanup and leak fixing.
Daniel Atallah <datallah@pidgin.im>
parents: 17632
diff changeset
109
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
110 static gchar *
34935
686fa55b0deb Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents: 34911
diff changeset
111 get_xmlnode_contents(PurpleXmlNode *node)
22824
fba8507310d3 Fix an issue with formatting in Bonjour messages. It looks like it has been
Daniel Atallah <datallah@pidgin.im>
parents: 22622
diff changeset
112 {
fba8507310d3 Fix an issue with formatting in Bonjour messages. It looks like it has been
Daniel Atallah <datallah@pidgin.im>
parents: 22622
diff changeset
113 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
114
34935
686fa55b0deb Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents: 34911
diff changeset
115 contents = purple_xmlnode_to_str(node, NULL);
22824
fba8507310d3 Fix an issue with formatting in Bonjour messages. It looks like it has been
Daniel Atallah <datallah@pidgin.im>
parents: 22622
diff changeset
116
fba8507310d3 Fix an issue with formatting in Bonjour messages. It looks like it has been
Daniel Atallah <datallah@pidgin.im>
parents: 22622
diff changeset
117 /* we just want the stuff inside <font></font>
34935
686fa55b0deb Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents: 34911
diff changeset
118 * There isn't stuff exposed in PurpleXmlNode.c to do this more cleanly. */
22824
fba8507310d3 Fix an issue with formatting in Bonjour messages. It looks like it has been
Daniel Atallah <datallah@pidgin.im>
parents: 22622
diff changeset
119
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 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
121 char *bodystart = strchr(contents, '>');
25096
55cf9c998554 Fix CID 399 - I'm reasonably sure this couldn't ever actually cause a NULL deref.
Daniel Atallah <datallah@pidgin.im>
parents: 25095
diff changeset
122 char *bodyend = bodystart ? strrchr(bodystart, '<') : NULL;
22824
fba8507310d3 Fix an issue with formatting in Bonjour messages. It looks like it has been
Daniel Atallah <datallah@pidgin.im>
parents: 22622
diff changeset
123 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
124 *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
125 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
126 }
fba8507310d3 Fix an issue with formatting in Bonjour messages. It looks like it has been
Daniel Atallah <datallah@pidgin.im>
parents: 22622
diff changeset
127 }
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 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
130 }
fba8507310d3 Fix an issue with formatting in Bonjour messages. It looks like it has been
Daniel Atallah <datallah@pidgin.im>
parents: 22622
diff changeset
131
12443
ad94864144f8 [gaim-migrate @ 14750]
Stu Tomlinson <nosnilmot@pidgin.im>
parents: 11830
diff changeset
132 static void
40080
a58c06469198 Rename Jabber to XMPP in Bonjour, as the official name is now XMPP and has been
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 40052
diff changeset
133 _xmpp_parse_and_write_message_to_ui(PurpleXmlNode *message_node, PurpleBuddy *pb)
11477
98b4f8643569 [gaim-migrate @ 13719]
Mark Doliner <markdoliner@pidgin.im>
parents:
diff changeset
134 {
34935
686fa55b0deb Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents: 34911
diff changeset
135 PurpleXmlNode *body_node, *html_node, *events_node;
24562
22ed1e1ef32f More Bonjour struct hiding fixes.
Richard Laager <rlaager@pidgin.im>
parents: 24333
diff changeset
136 PurpleConnection *gc = purple_account_get_connection(purple_buddy_get_account(pb));
21936
79f3a365cffb Cleanup to prevent unnecessary alloc/free. Also a small fix to remove the possiblity that a message will be sent before the stream is started.
Daniel Atallah <datallah@pidgin.im>
parents: 21920
diff changeset
137 gchar *body = NULL;
11477
98b4f8643569 [gaim-migrate @ 13719]
Mark Doliner <markdoliner@pidgin.im>
parents:
diff changeset
138
34935
686fa55b0deb Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents: 34911
diff changeset
139 body_node = purple_xmlnode_get_child(message_node, "body");
686fa55b0deb Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents: 34911
diff changeset
140 html_node = purple_xmlnode_get_child(message_node, "html");
21936
79f3a365cffb Cleanup to prevent unnecessary alloc/free. Also a small fix to remove the possiblity that a message will be sent before the stream is started.
Daniel Atallah <datallah@pidgin.im>
parents: 21920
diff changeset
141
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
142 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
143 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
144 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
145 }
11539
fbabe3f89777 [gaim-migrate @ 13794]
Mark Doliner <markdoliner@pidgin.im>
parents: 11515
diff changeset
146
40082
b8e9a7b626d4 Fix some namespace changes that I made accidentally. Also add a G_UNLIKELY
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 40081
diff changeset
147 events_node = purple_xmlnode_get_child_with_namespace(message_node, "x", "jabber:x:event");
21936
79f3a365cffb Cleanup to prevent unnecessary alloc/free. Also a small fix to remove the possiblity that a message will be sent before the stream is started.
Daniel Atallah <datallah@pidgin.im>
parents: 21920
diff changeset
148 if (events_node != NULL) {
34935
686fa55b0deb Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents: 34911
diff changeset
149 if (purple_xmlnode_get_child(events_node, "id") != NULL) {
21936
79f3a365cffb Cleanup to prevent unnecessary alloc/free. Also a small fix to remove the possiblity that a message will be sent before the stream is started.
Daniel Atallah <datallah@pidgin.im>
parents: 21920
diff changeset
150 /* 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
151 /* 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
152 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
153 }
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
154 }
79f3a365cffb Cleanup to prevent unnecessary alloc/free. Also a small fix to remove the possiblity that a message will be sent before the stream is started.
Daniel Atallah <datallah@pidgin.im>
parents: 21920
diff changeset
155
79f3a365cffb Cleanup to prevent unnecessary alloc/free. Also a small fix to remove the possiblity that a message will be sent before the stream is started.
Daniel Atallah <datallah@pidgin.im>
parents: 21920
diff changeset
156 if (html_node != NULL) {
34935
686fa55b0deb Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents: 34911
diff changeset
157 PurpleXmlNode *html_body_node;
17633
b76241c02857 Some more Bonjour cleanup and leak fixing.
Daniel Atallah <datallah@pidgin.im>
parents: 17632
diff changeset
158
34935
686fa55b0deb Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents: 34911
diff changeset
159 html_body_node = purple_xmlnode_get_child(html_node, "body");
21936
79f3a365cffb Cleanup to prevent unnecessary alloc/free. Also a small fix to remove the possiblity that a message will be sent before the stream is started.
Daniel Atallah <datallah@pidgin.im>
parents: 21920
diff changeset
160 if (html_body_node != NULL) {
34935
686fa55b0deb Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents: 34911
diff changeset
161 PurpleXmlNode *html_body_font_node;
17633
b76241c02857 Some more Bonjour cleanup and leak fixing.
Daniel Atallah <datallah@pidgin.im>
parents: 17632
diff changeset
162
34935
686fa55b0deb Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents: 34911
diff changeset
163 html_body_font_node = purple_xmlnode_get_child(html_body_node, "font");
21936
79f3a365cffb Cleanup to prevent unnecessary alloc/free. Also a small fix to remove the possiblity that a message will be sent before the stream is started.
Daniel Atallah <datallah@pidgin.im>
parents: 21920
diff changeset
164 /* 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
165 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
166 gchar *html_body;
33799
c8a9082d50d1 Apply libpurple3 changes to recently merged code.
Daniel Atallah <datallah@pidgin.im>
parents: 33796
diff changeset
167 const char *font_face, *font_size, *font_color,
24196
864b0ca6577c Don't arbitrarily default font settings when none are specified for incoming
Daniel Atallah <datallah@pidgin.im>
parents: 24039
diff changeset
168 *ichat_balloon_color, *ichat_text_color;
21936
79f3a365cffb Cleanup to prevent unnecessary alloc/free. Also a small fix to remove the possiblity that a message will be sent before the stream is started.
Daniel Atallah <datallah@pidgin.im>
parents: 21920
diff changeset
169
34935
686fa55b0deb Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents: 34911
diff changeset
170 font_face = purple_xmlnode_get_attrib(html_body_font_node, "face");
11826
10ebbc41f163 [gaim-migrate @ 14117]
Richard Laager <rlaager@pidgin.im>
parents: 11823
diff changeset
171 /* The absolute iChat font sizes should be converted to 1..7 range */
34935
686fa55b0deb Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents: 34911
diff changeset
172 font_size = purple_xmlnode_get_attrib(html_body_font_node, "ABSZ");
11539
fbabe3f89777 [gaim-migrate @ 13794]
Mark Doliner <markdoliner@pidgin.im>
parents: 11515
diff changeset
173 if (font_size != NULL)
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15873
diff changeset
174 font_size = _font_size_ichat_to_purple(atoi(font_size));
34935
686fa55b0deb Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents: 34911
diff changeset
175 font_color = purple_xmlnode_get_attrib(html_body_font_node, "color");
686fa55b0deb Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents: 34911
diff changeset
176 ichat_balloon_color = purple_xmlnode_get_attrib(html_body_node, "ichatballooncolor");
686fa55b0deb Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents: 34911
diff changeset
177 ichat_text_color = purple_xmlnode_get_attrib(html_body_node, "ichattextcolor");
24196
864b0ca6577c Don't arbitrarily default font settings when none are specified for incoming
Daniel Atallah <datallah@pidgin.im>
parents: 24039
diff changeset
178
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
179 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
180
11539
fbabe3f89777 [gaim-migrate @ 13794]
Mark Doliner <markdoliner@pidgin.im>
parents: 11515
diff changeset
181 if (html_body == NULL)
24196
864b0ca6577c Don't arbitrarily default font settings when none are specified for incoming
Daniel Atallah <datallah@pidgin.im>
parents: 24039
diff changeset
182 /* This is the kind of formatted messages that Purple creates */
34935
686fa55b0deb Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents: 34911
diff changeset
183 html_body = purple_xmlnode_to_str(html_body_font_node, NULL);
21936
79f3a365cffb Cleanup to prevent unnecessary alloc/free. Also a small fix to remove the possiblity that a message will be sent before the stream is started.
Daniel Atallah <datallah@pidgin.im>
parents: 21920
diff changeset
184
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 != NULL) {
24196
864b0ca6577c Don't arbitrarily default font settings when none are specified for incoming
Daniel Atallah <datallah@pidgin.im>
parents: 24039
diff changeset
186 GString *str = g_string_new("<font");
21936
79f3a365cffb Cleanup to prevent unnecessary alloc/free. Also a small fix to remove the possiblity that a message will be sent before the stream is started.
Daniel Atallah <datallah@pidgin.im>
parents: 21920
diff changeset
187
24196
864b0ca6577c Don't arbitrarily default font settings when none are specified for incoming
Daniel Atallah <datallah@pidgin.im>
parents: 24039
diff changeset
188 if (font_face)
864b0ca6577c Don't arbitrarily default font settings when none are specified for incoming
Daniel Atallah <datallah@pidgin.im>
parents: 24039
diff changeset
189 g_string_append_printf(str, " face='%s'", font_face);
864b0ca6577c Don't arbitrarily default font settings when none are specified for incoming
Daniel Atallah <datallah@pidgin.im>
parents: 24039
diff changeset
190 if (font_size)
864b0ca6577c Don't arbitrarily default font settings when none are specified for incoming
Daniel Atallah <datallah@pidgin.im>
parents: 24039
diff changeset
191 g_string_append_printf(str, " size='%s'", font_size);
32762
19da30ca0ffb It seems like we should be using this color tag for something...
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32744
diff changeset
192 if (font_color)
19da30ca0ffb It seems like we should be using this color tag for something...
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32744
diff changeset
193 g_string_append_printf(str, " color='%s'", font_color);
19da30ca0ffb It seems like we should be using this color tag for something...
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32744
diff changeset
194 else if (ichat_text_color)
24196
864b0ca6577c Don't arbitrarily default font settings when none are specified for incoming
Daniel Atallah <datallah@pidgin.im>
parents: 24039
diff changeset
195 g_string_append_printf(str, " color='%s'", ichat_text_color);
864b0ca6577c Don't arbitrarily default font settings when none are specified for incoming
Daniel Atallah <datallah@pidgin.im>
parents: 24039
diff changeset
196 if (ichat_balloon_color)
864b0ca6577c Don't arbitrarily default font settings when none are specified for incoming
Daniel Atallah <datallah@pidgin.im>
parents: 24039
diff changeset
197 g_string_append_printf(str, " back='%s'", ichat_balloon_color);
864b0ca6577c Don't arbitrarily default font settings when none are specified for incoming
Daniel Atallah <datallah@pidgin.im>
parents: 24039
diff changeset
198 g_string_append_printf(str, ">%s</font>", html_body);
864b0ca6577c Don't arbitrarily default font settings when none are specified for incoming
Daniel Atallah <datallah@pidgin.im>
parents: 24039
diff changeset
199
864b0ca6577c Don't arbitrarily default font settings when none are specified for incoming
Daniel Atallah <datallah@pidgin.im>
parents: 24039
diff changeset
200 body = g_string_free(str, FALSE);
21936
79f3a365cffb Cleanup to prevent unnecessary alloc/free. Also a small fix to remove the possiblity that a message will be sent before the stream is started.
Daniel Atallah <datallah@pidgin.im>
parents: 21920
diff changeset
201
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 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
203 }
11477
98b4f8643569 [gaim-migrate @ 13719]
Mark Doliner <markdoliner@pidgin.im>
parents:
diff changeset
204 }
98b4f8643569 [gaim-migrate @ 13719]
Mark Doliner <markdoliner@pidgin.im>
parents:
diff changeset
205 }
98b4f8643569 [gaim-migrate @ 13719]
Mark Doliner <markdoliner@pidgin.im>
parents:
diff changeset
206 }
11539
fbabe3f89777 [gaim-migrate @ 13794]
Mark Doliner <markdoliner@pidgin.im>
parents: 11515
diff changeset
207
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
208 /* 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
209 if (body == NULL && body_node != NULL)
34935
686fa55b0deb Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents: 34911
diff changeset
210 body = purple_xmlnode_get_data(body_node);
11539
fbabe3f89777 [gaim-migrate @ 13794]
Mark Doliner <markdoliner@pidgin.im>
parents: 11515
diff changeset
211
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
212 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
213 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
214 return;
11477
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
11826
10ebbc41f163 [gaim-migrate @ 14117]
Richard Laager <rlaager@pidgin.im>
parents: 11823
diff changeset
217 /* Send the message to the UI */
35499
c4c5e0a670b1 Fix namespaces issues in libpurple.
Ankit Vani <a@nevitus.org>
parents: 35378
diff changeset
218 purple_serv_got_im(gc, purple_buddy_get_name(pb), body, 0, time(NULL));
11539
fbabe3f89777 [gaim-migrate @ 13794]
Mark Doliner <markdoliner@pidgin.im>
parents: 11515
diff changeset
219
11477
98b4f8643569 [gaim-migrate @ 13719]
Mark Doliner <markdoliner@pidgin.im>
parents:
diff changeset
220 g_free(body);
98b4f8643569 [gaim-migrate @ 13719]
Mark Doliner <markdoliner@pidgin.im>
parents:
diff changeset
221 }
98b4f8643569 [gaim-migrate @ 13719]
Mark Doliner <markdoliner@pidgin.im>
parents:
diff changeset
222
39660
4ddb9885a38b Fix reserved name usage of struct *_t.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39657
diff changeset
223 struct _match_buddies_by_address {
17633
b76241c02857 Some more Bonjour cleanup and leak fixing.
Daniel Atallah <datallah@pidgin.im>
parents: 17632
diff changeset
224 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
225 GSList *matched_buddies;
12708
54098581385f [gaim-migrate @ 15052]
Sean Egan <seanegan@pidgin.im>
parents: 12443
diff changeset
226 };
54098581385f [gaim-migrate @ 15052]
Sean Egan <seanegan@pidgin.im>
parents: 12443
diff changeset
227
54098581385f [gaim-migrate @ 15052]
Sean Egan <seanegan@pidgin.im>
parents: 12443
diff changeset
228 static void
26767
7489049a3bde Change purple_blist_get_buddies to return a list instead of the hash table.
Paul Aurich <darkrain42@pidgin.im>
parents: 25911
diff changeset
229 _match_buddies_by_address(gpointer value, gpointer data)
11477
98b4f8643569 [gaim-migrate @ 13719]
Mark Doliner <markdoliner@pidgin.im>
parents:
diff changeset
230 {
17661
96c6a21c4139 Send 'to' and 'from' attributes in the stream start message.
Daniel Atallah <datallah@pidgin.im>
parents: 17660
diff changeset
231 PurpleBuddy *pb = value;
24938
fc6952107e1f Finished moving to api for bonjour
Gary Kramlich <grim@reaperworld.com>
parents: 24562
diff changeset
232 BonjourBuddy *bb = NULL;
39660
4ddb9885a38b Fix reserved name usage of struct *_t.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39657
diff changeset
233 struct _match_buddies_by_address *mbba = data;
11539
fbabe3f89777 [gaim-migrate @ 13794]
Mark Doliner <markdoliner@pidgin.im>
parents: 11515
diff changeset
234
24938
fc6952107e1f Finished moving to api for bonjour
Gary Kramlich <grim@reaperworld.com>
parents: 24562
diff changeset
235 bb = purple_buddy_get_protocol_data(pb);
fc6952107e1f Finished moving to api for bonjour
Gary Kramlich <grim@reaperworld.com>
parents: 24562
diff changeset
236
13962
71617bf27d00 [gaim-migrate @ 16386]
Jono Cole
parents: 13267
diff changeset
237 /*
26990
385ad4d15ae5 Use more efficient purple_find_buddies in bonjour.
Paul Aurich <darkrain42@pidgin.im>
parents: 26767
diff changeset
238 * If the current PurpleBuddy's data is not null, then continue to determine
21920
3087a567aedf Update Bonjour prpl to support multiple presence records for the same buddy. Eliminate the Howl backend to avoid having to maintain yet another set of code. References #4187 (more to come to fix the rest of the ticket).
Daniel Atallah <datallah@pidgin.im>
parents: 21917
diff changeset
239 * whether one of the buddies IPs matches the target IP.
13962
71617bf27d00 [gaim-migrate @ 16386]
Jono Cole
parents: 13267
diff changeset
240 */
26990
385ad4d15ae5 Use more efficient purple_find_buddies in bonjour.
Paul Aurich <darkrain42@pidgin.im>
parents: 26767
diff changeset
241 if (bb != NULL)
13962
71617bf27d00 [gaim-migrate @ 16386]
Jono Cole
parents: 13267
diff changeset
242 {
21944
c41d17a1b8d9 This is the second part of the fix to support having multiple presence records in Bonjour (and also supporting multiple presences using the same IP). Incoming conversations are no longer immediately attached to a buddy - we use an algorithm to match a conversation to a buddy based on the IP and, if possible the "from" attribute of the stream or the first tag in the stream. Thanks to Sjoerd Simons from Telepahy Salut for noticing and suggesting the algorithm. Fixes #4187. It'd be good if a few people test this.
Daniel Atallah <datallah@pidgin.im>
parents: 21936
diff changeset
243 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
244 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
245
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
246 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
247 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
248 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
249 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
250 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
251 }
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
252 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
253 }
11477
98b4f8643569 [gaim-migrate @ 13719]
Mark Doliner <markdoliner@pidgin.im>
parents:
diff changeset
254 }
98b4f8643569 [gaim-migrate @ 13719]
Mark Doliner <markdoliner@pidgin.im>
parents:
diff changeset
255 }
98b4f8643569 [gaim-migrate @ 13719]
Mark Doliner <markdoliner@pidgin.im>
parents:
diff changeset
256
17665
26bff2090889 Update Bonjour to do nonblocking I/O correctly.
Daniel Atallah <datallah@pidgin.im>
parents: 17663
diff changeset
257 static void
39639
fe7fa102e766 Convert Bonjour client side to GIO.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39638
diff changeset
258 _send_data_write_cb(GObject *stream, gpointer data)
11477
98b4f8643569 [gaim-migrate @ 13719]
Mark Doliner <markdoliner@pidgin.im>
parents:
diff changeset
259 {
17665
26bff2090889 Update Bonjour to do nonblocking I/O correctly.
Daniel Atallah <datallah@pidgin.im>
parents: 17663
diff changeset
260 PurpleBuddy *pb = data;
24938
fc6952107e1f Finished moving to api for bonjour
Gary Kramlich <grim@reaperworld.com>
parents: 24562
diff changeset
261 BonjourBuddy *bb = purple_buddy_get_protocol_data(pb);
40080
a58c06469198 Rename Jabber to XMPP in Bonjour, as the official name is now XMPP and has been
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 40052
diff changeset
262 BonjourXMPPConversation *bconv = bb->conversation;
39639
fe7fa102e766 Convert Bonjour client side to GIO.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39638
diff changeset
263 gsize writelen;
fe7fa102e766 Convert Bonjour client side to GIO.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39638
diff changeset
264 gssize ret;
fe7fa102e766 Convert Bonjour client side to GIO.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39638
diff changeset
265 GError *error = NULL;
17665
26bff2090889 Update Bonjour to do nonblocking I/O correctly.
Daniel Atallah <datallah@pidgin.im>
parents: 17663
diff changeset
266
34529
68cf25486001 GObjectify PurpleCircBuffer as PurpleCircularBuffer (from gobjectification branch)
Ankit Vani <a@nevitus.org>
parents: 33892
diff changeset
267 writelen = purple_circular_buffer_get_max_read(bconv->tx_buf);
17665
26bff2090889 Update Bonjour to do nonblocking I/O correctly.
Daniel Atallah <datallah@pidgin.im>
parents: 17663
diff changeset
268
26bff2090889 Update Bonjour to do nonblocking I/O correctly.
Daniel Atallah <datallah@pidgin.im>
parents: 17663
diff changeset
269 if (writelen == 0) {
39639
fe7fa102e766 Convert Bonjour client side to GIO.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39638
diff changeset
270 g_source_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
271 bconv->tx_handler = 0;
17665
26bff2090889 Update Bonjour to do nonblocking I/O correctly.
Daniel Atallah <datallah@pidgin.im>
parents: 17663
diff changeset
272 return;
26bff2090889 Update Bonjour to do nonblocking I/O correctly.
Daniel Atallah <datallah@pidgin.im>
parents: 17663
diff changeset
273 }
11539
fbabe3f89777 [gaim-migrate @ 13794]
Mark Doliner <markdoliner@pidgin.im>
parents: 11515
diff changeset
274
39639
fe7fa102e766 Convert Bonjour client side to GIO.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39638
diff changeset
275 ret = g_pollable_output_stream_write_nonblocking(
fe7fa102e766 Convert Bonjour client side to GIO.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39638
diff changeset
276 G_POLLABLE_OUTPUT_STREAM(stream),
fe7fa102e766 Convert Bonjour client side to GIO.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39638
diff changeset
277 purple_circular_buffer_get_output(bconv->tx_buf), writelen,
fe7fa102e766 Convert Bonjour client side to GIO.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39638
diff changeset
278 bconv->cancellable, &error);
17665
26bff2090889 Update Bonjour to do nonblocking I/O correctly.
Daniel Atallah <datallah@pidgin.im>
parents: 17663
diff changeset
279
39639
fe7fa102e766 Convert Bonjour client side to GIO.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39638
diff changeset
280 if (ret < 0 && error->code == G_IO_ERROR_WOULD_BLOCK) {
fe7fa102e766 Convert Bonjour client side to GIO.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39638
diff changeset
281 g_clear_error(&error);
17665
26bff2090889 Update Bonjour to do nonblocking I/O correctly.
Daniel Atallah <datallah@pidgin.im>
parents: 17663
diff changeset
282 return;
39639
fe7fa102e766 Convert Bonjour client side to GIO.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39638
diff changeset
283 } else if (ret <= 0) {
24938
fc6952107e1f Finished moving to api for bonjour
Gary Kramlich <grim@reaperworld.com>
parents: 24562
diff changeset
284 PurpleConversation *conv = NULL;
fc6952107e1f Finished moving to api for bonjour
Gary Kramlich <grim@reaperworld.com>
parents: 24562
diff changeset
285 PurpleAccount *account = NULL;
17665
26bff2090889 Update Bonjour to do nonblocking I/O correctly.
Daniel Atallah <datallah@pidgin.im>
parents: 17663
diff changeset
286
39639
fe7fa102e766 Convert Bonjour client side to GIO.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39638
diff changeset
287 purple_debug_error(
fe7fa102e766 Convert Bonjour client side to GIO.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39638
diff changeset
288 "bonjour",
fe7fa102e766 Convert Bonjour client side to GIO.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39638
diff changeset
289 "Error sending message to buddy %s error: %s",
fe7fa102e766 Convert Bonjour client side to GIO.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39638
diff changeset
290 purple_buddy_get_name(pb),
fe7fa102e766 Convert Bonjour client side to GIO.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39638
diff changeset
291 error ? error->message : "(null)");
17665
26bff2090889 Update Bonjour to do nonblocking I/O correctly.
Daniel Atallah <datallah@pidgin.im>
parents: 17663
diff changeset
292
24938
fc6952107e1f Finished moving to api for bonjour
Gary Kramlich <grim@reaperworld.com>
parents: 24562
diff changeset
293 account = purple_buddy_get_account(pb);
fc6952107e1f Finished moving to api for bonjour
Gary Kramlich <grim@reaperworld.com>
parents: 24562
diff changeset
294
34632
ebe6b2a60305 Changed all arguments and return types of Chat and IMs to PurpleChatConversation and PurpleIMConversation.
Ankit Vani <a@nevitus.org>
parents: 34625
diff changeset
295 conv = PURPLE_CONVERSATION(purple_conversations_find_im_with_account(bb->name, account));
17665
26bff2090889 Update Bonjour to do nonblocking I/O correctly.
Daniel Atallah <datallah@pidgin.im>
parents: 17663
diff changeset
296 if (conv != NULL)
36089
c035b9a63457 Use purple_conversation_write_system_message where appropriate
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 36073
diff changeset
297 purple_conversation_write_system_message(conv,
c035b9a63457 Use purple_conversation_write_system_message where appropriate
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 36073
diff changeset
298 _("Unable to send message."),
c035b9a63457 Use purple_conversation_write_system_message where appropriate
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 36073
diff changeset
299 PURPLE_MESSAGE_ERROR);
17665
26bff2090889 Update Bonjour to do nonblocking I/O correctly.
Daniel Atallah <datallah@pidgin.im>
parents: 17663
diff changeset
300
40080
a58c06469198 Rename Jabber to XMPP in Bonjour, as the official name is now XMPP and has been
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 40052
diff changeset
301 bonjour_xmpp_close_conversation(bb->conversation);
17665
26bff2090889 Update Bonjour to do nonblocking I/O correctly.
Daniel Atallah <datallah@pidgin.im>
parents: 17663
diff changeset
302 bb->conversation = NULL;
39639
fe7fa102e766 Convert Bonjour client side to GIO.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39638
diff changeset
303 g_clear_error(&error);
17665
26bff2090889 Update Bonjour to do nonblocking I/O correctly.
Daniel Atallah <datallah@pidgin.im>
parents: 17663
diff changeset
304 return;
11477
98b4f8643569 [gaim-migrate @ 13719]
Mark Doliner <markdoliner@pidgin.im>
parents:
diff changeset
305 }
11539
fbabe3f89777 [gaim-migrate @ 13794]
Mark Doliner <markdoliner@pidgin.im>
parents: 11515
diff changeset
306
34529
68cf25486001 GObjectify PurpleCircBuffer as PurpleCircularBuffer (from gobjectification branch)
Ankit Vani <a@nevitus.org>
parents: 33892
diff changeset
307 purple_circular_buffer_mark_read(bconv->tx_buf, ret);
17665
26bff2090889 Update Bonjour to do nonblocking I/O correctly.
Daniel Atallah <datallah@pidgin.im>
parents: 17663
diff changeset
308 }
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 static gint
26bff2090889 Update Bonjour to do nonblocking I/O correctly.
Daniel Atallah <datallah@pidgin.im>
parents: 17663
diff changeset
311 _send_data(PurpleBuddy *pb, char *message)
26bff2090889 Update Bonjour to do nonblocking I/O correctly.
Daniel Atallah <datallah@pidgin.im>
parents: 17663
diff changeset
312 {
24938
fc6952107e1f Finished moving to api for bonjour
Gary Kramlich <grim@reaperworld.com>
parents: 24562
diff changeset
313 BonjourBuddy *bb = purple_buddy_get_protocol_data(pb);
40080
a58c06469198 Rename Jabber to XMPP in Bonjour, as the official name is now XMPP and has been
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 40052
diff changeset
314 BonjourXMPPConversation *bconv = bb->conversation;
39639
fe7fa102e766 Convert Bonjour client side to GIO.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39638
diff changeset
315 gsize len = strlen(message);
fe7fa102e766 Convert Bonjour client side to GIO.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39638
diff changeset
316 gssize ret;
fe7fa102e766 Convert Bonjour client side to GIO.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39638
diff changeset
317 GError *error = NULL;
17665
26bff2090889 Update Bonjour to do nonblocking I/O correctly.
Daniel Atallah <datallah@pidgin.im>
parents: 17663
diff changeset
318
26bff2090889 Update Bonjour to do nonblocking I/O correctly.
Daniel Atallah <datallah@pidgin.im>
parents: 17663
diff changeset
319 /* 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
320 if (bconv->tx_handler != 0
21727
decfc3a613ff applied changes from b9c97ed0f9ada9069e8bd994b01fdde0b484083c
Daniel Atallah <datallah@pidgin.im>
parents: 21720
diff changeset
321 || 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
322 || !bconv->recv_stream_start
34529
68cf25486001 GObjectify PurpleCircBuffer as PurpleCircularBuffer (from gobjectification branch)
Ankit Vani <a@nevitus.org>
parents: 33892
diff changeset
323 || purple_circular_buffer_get_max_read(bconv->tx_buf) > 0) {
17665
26bff2090889 Update Bonjour to do nonblocking I/O correctly.
Daniel Atallah <datallah@pidgin.im>
parents: 17663
diff changeset
324 ret = -1;
39639
fe7fa102e766 Convert Bonjour client side to GIO.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39638
diff changeset
325 g_set_error_literal(&error, G_IO_ERROR, G_IO_ERROR_WOULD_BLOCK,
fe7fa102e766 Convert Bonjour client side to GIO.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39638
diff changeset
326 "Not yet ready to send.");
17665
26bff2090889 Update Bonjour to do nonblocking I/O correctly.
Daniel Atallah <datallah@pidgin.im>
parents: 17663
diff changeset
327 } else {
39639
fe7fa102e766 Convert Bonjour client side to GIO.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39638
diff changeset
328 ret = g_pollable_output_stream_write_nonblocking(
fe7fa102e766 Convert Bonjour client side to GIO.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39638
diff changeset
329 G_POLLABLE_OUTPUT_STREAM(bconv->output), message, len,
fe7fa102e766 Convert Bonjour client side to GIO.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39638
diff changeset
330 bconv->cancellable, &error);
17665
26bff2090889 Update Bonjour to do nonblocking I/O correctly.
Daniel Atallah <datallah@pidgin.im>
parents: 17663
diff changeset
331 }
26bff2090889 Update Bonjour to do nonblocking I/O correctly.
Daniel Atallah <datallah@pidgin.im>
parents: 17663
diff changeset
332
39639
fe7fa102e766 Convert Bonjour client side to GIO.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39638
diff changeset
333 if (ret == -1 && error->code == G_IO_ERROR_WOULD_BLOCK) {
17665
26bff2090889 Update Bonjour to do nonblocking I/O correctly.
Daniel Atallah <datallah@pidgin.im>
parents: 17663
diff changeset
334 ret = 0;
39639
fe7fa102e766 Convert Bonjour client side to GIO.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39638
diff changeset
335 g_clear_error(&error);
fe7fa102e766 Convert Bonjour client side to GIO.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39638
diff changeset
336 } else if (ret <= 0) {
17665
26bff2090889 Update Bonjour to do nonblocking I/O correctly.
Daniel Atallah <datallah@pidgin.im>
parents: 17663
diff changeset
337 PurpleConversation *conv;
25140
7c494d2bc5e4 propagate from branch 'im.pidgin.pidgin' (head 009f3ea551248605298fbf1b88d7a873b2a6c7a3)
Richard Laager <rlaager@pidgin.im>
parents: 25097 24954
diff changeset
338 PurpleAccount *account;
17665
26bff2090889 Update Bonjour to do nonblocking I/O correctly.
Daniel Atallah <datallah@pidgin.im>
parents: 17663
diff changeset
339
39639
fe7fa102e766 Convert Bonjour client side to GIO.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39638
diff changeset
340 purple_debug_error(
fe7fa102e766 Convert Bonjour client side to GIO.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39638
diff changeset
341 "bonjour",
fe7fa102e766 Convert Bonjour client side to GIO.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39638
diff changeset
342 "Error sending message to buddy %s error: %s",
fe7fa102e766 Convert Bonjour client side to GIO.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39638
diff changeset
343 purple_buddy_get_name(pb),
fe7fa102e766 Convert Bonjour client side to GIO.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39638
diff changeset
344 error ? error->message : "(null)");
17665
26bff2090889 Update Bonjour to do nonblocking I/O correctly.
Daniel Atallah <datallah@pidgin.im>
parents: 17663
diff changeset
345
24938
fc6952107e1f Finished moving to api for bonjour
Gary Kramlich <grim@reaperworld.com>
parents: 24562
diff changeset
346 account = purple_buddy_get_account(pb);
fc6952107e1f Finished moving to api for bonjour
Gary Kramlich <grim@reaperworld.com>
parents: 24562
diff changeset
347
34632
ebe6b2a60305 Changed all arguments and return types of Chat and IMs to PurpleChatConversation and PurpleIMConversation.
Ankit Vani <a@nevitus.org>
parents: 34625
diff changeset
348 conv = PURPLE_CONVERSATION(purple_conversations_find_im_with_account(bb->name, account));
17665
26bff2090889 Update Bonjour to do nonblocking I/O correctly.
Daniel Atallah <datallah@pidgin.im>
parents: 17663
diff changeset
349 if (conv != NULL)
36089
c035b9a63457 Use purple_conversation_write_system_message where appropriate
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 36073
diff changeset
350 purple_conversation_write_system_message(conv,
c035b9a63457 Use purple_conversation_write_system_message where appropriate
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 36073
diff changeset
351 _("Unable to send message."),
c035b9a63457 Use purple_conversation_write_system_message where appropriate
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 36073
diff changeset
352 PURPLE_MESSAGE_ERROR);
17665
26bff2090889 Update Bonjour to do nonblocking I/O correctly.
Daniel Atallah <datallah@pidgin.im>
parents: 17663
diff changeset
353
40080
a58c06469198 Rename Jabber to XMPP in Bonjour, as the official name is now XMPP and has been
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 40052
diff changeset
354 bonjour_xmpp_close_conversation(bb->conversation);
17665
26bff2090889 Update Bonjour to do nonblocking I/O correctly.
Daniel Atallah <datallah@pidgin.im>
parents: 17663
diff changeset
355 bb->conversation = NULL;
39639
fe7fa102e766 Convert Bonjour client side to GIO.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39638
diff changeset
356 g_clear_error(&error);
17665
26bff2090889 Update Bonjour to do nonblocking I/O correctly.
Daniel Atallah <datallah@pidgin.im>
parents: 17663
diff changeset
357 return -1;
26bff2090889 Update Bonjour to do nonblocking I/O correctly.
Daniel Atallah <datallah@pidgin.im>
parents: 17663
diff changeset
358 }
26bff2090889 Update Bonjour to do nonblocking I/O correctly.
Daniel Atallah <datallah@pidgin.im>
parents: 17663
diff changeset
359
26bff2090889 Update Bonjour to do nonblocking I/O correctly.
Daniel Atallah <datallah@pidgin.im>
parents: 17663
diff changeset
360 if (ret < len) {
21727
decfc3a613ff applied changes from b9c97ed0f9ada9069e8bd994b01fdde0b484083c
Daniel Atallah <datallah@pidgin.im>
parents: 21720
diff changeset
361 /* Don't interfere with the stream starting */
39639
fe7fa102e766 Convert Bonjour client side to GIO.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39638
diff changeset
362 if (bconv->sent_stream_start == FULLY_SENT &&
fe7fa102e766 Convert Bonjour client side to GIO.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39638
diff changeset
363 bconv->recv_stream_start && bconv->tx_handler == 0) {
fe7fa102e766 Convert Bonjour client side to GIO.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39638
diff changeset
364 GSource *source =
fe7fa102e766 Convert Bonjour client side to GIO.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39638
diff changeset
365 g_pollable_output_stream_create_source(
fe7fa102e766 Convert Bonjour client side to GIO.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39638
diff changeset
366 G_POLLABLE_OUTPUT_STREAM(bconv->output),
fe7fa102e766 Convert Bonjour client side to GIO.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39638
diff changeset
367 bconv->cancellable);
fe7fa102e766 Convert Bonjour client side to GIO.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39638
diff changeset
368 g_source_set_callback(source,
fe7fa102e766 Convert Bonjour client side to GIO.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39638
diff changeset
369 (GSourceFunc)_send_data_write_cb,
fe7fa102e766 Convert Bonjour client side to GIO.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39638
diff changeset
370 pb, NULL);
fe7fa102e766 Convert Bonjour client side to GIO.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39638
diff changeset
371 bconv->tx_handler = g_source_attach(source, NULL);
40344
489c56155c33 Fix leaks of GSources.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 40094
diff changeset
372 g_source_unref(source);
39639
fe7fa102e766 Convert Bonjour client side to GIO.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39638
diff changeset
373 }
34529
68cf25486001 GObjectify PurpleCircBuffer as PurpleCircularBuffer (from gobjectification branch)
Ankit Vani <a@nevitus.org>
parents: 33892
diff changeset
374 purple_circular_buffer_append(bconv->tx_buf, message + ret, len - ret);
17665
26bff2090889 Update Bonjour to do nonblocking I/O correctly.
Daniel Atallah <datallah@pidgin.im>
parents: 17663
diff changeset
375 }
26bff2090889 Update Bonjour to do nonblocking I/O correctly.
Daniel Atallah <datallah@pidgin.im>
parents: 17663
diff changeset
376
26bff2090889 Update Bonjour to do nonblocking I/O correctly.
Daniel Atallah <datallah@pidgin.im>
parents: 17663
diff changeset
377 return ret;
11477
98b4f8643569 [gaim-migrate @ 13719]
Mark Doliner <markdoliner@pidgin.im>
parents:
diff changeset
378 }
98b4f8643569 [gaim-migrate @ 13719]
Mark Doliner <markdoliner@pidgin.im>
parents:
diff changeset
379
40080
a58c06469198 Rename Jabber to XMPP in Bonjour, as the official name is now XMPP and has been
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 40052
diff changeset
380 void bonjour_xmpp_process_packet(PurpleBuddy *pb, PurpleXmlNode *packet) {
21612
9fce536735e3 Various bugfixes including using purple_account_remove_buddy() in addition to purple_blist_remove_buddy() to make sure that the buddy gets cleaned up fully when logging out or we go offline.
Daniel Atallah <datallah@pidgin.im>
parents: 21609
diff changeset
381
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
382 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
383 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
384
38257
1a294a6d2a57 Replace g_strcmp0() with purple_strequal()
qarkai <qarkai@gmail.com>
parents: 38213
diff changeset
385 if (purple_strequal(packet->name, "message"))
40080
a58c06469198 Rename Jabber to XMPP in Bonjour, as the official name is now XMPP and has been
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 40052
diff changeset
386 _xmpp_parse_and_write_message_to_ui(packet, pb);
38257
1a294a6d2a57 Replace g_strcmp0() with purple_strequal()
qarkai <qarkai@gmail.com>
parents: 38213
diff changeset
387 else if (purple_strequal(packet->name, "iq"))
25097
c950e59e30bf Further cleanup to fix CID 373.
Daniel Atallah <datallah@pidgin.im>
parents: 25096
diff changeset
388 xep_iq_parse(packet, pb);
35997
23e05a4a90b3 Silence some already dismissed coverity warnings
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35991
diff changeset
389 else {
23e05a4a90b3 Silence some already dismissed coverity warnings
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35991
diff changeset
390 purple_debug_warning("bonjour", "Unknown packet: %s\n",
23e05a4a90b3 Silence some already dismissed coverity warnings
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35991
diff changeset
391 packet->name ? packet->name : "(null)");
23e05a4a90b3 Silence some already dismissed coverity warnings
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35991
diff changeset
392 }
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
393 }
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
394
40080
a58c06469198 Rename Jabber to XMPP in Bonjour, as the official name is now XMPP and has been
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 40052
diff changeset
395 static void bonjour_xmpp_stream_ended(BonjourXMPPConversation *bconv) {
25095
0e356664879d Clean up some stuff that the behavior has changed on to fix CID 398.
Daniel Atallah <datallah@pidgin.im>
parents: 24562
diff changeset
396
0e356664879d Clean up some stuff that the behavior has changed on to fix CID 398.
Daniel Atallah <datallah@pidgin.im>
parents: 24562
diff changeset
397 /* Inform the user that the conversation has been closed */
0e356664879d Clean up some stuff that the behavior has changed on to fix CID 398.
Daniel Atallah <datallah@pidgin.im>
parents: 24562
diff changeset
398 BonjourBuddy *bb = NULL;
25870
ccb76c75d39f a few struct hiding clean ups
Gary Kramlich <grim@reaperworld.com>
parents: 25150
diff changeset
399 const gchar *name = bconv->pb ? purple_buddy_get_name(bconv->pb) : "(unknown)";
25095
0e356664879d Clean up some stuff that the behavior has changed on to fix CID 398.
Daniel Atallah <datallah@pidgin.im>
parents: 24562
diff changeset
400
30270
8380aae8b132 I before E, except after C
Stu Tomlinson <nosnilmot@pidgin.im>
parents: 30249
diff changeset
401 purple_debug_info("bonjour", "Received conversation close notification from %s.\n", name);
25095
0e356664879d Clean up some stuff that the behavior has changed on to fix CID 398.
Daniel Atallah <datallah@pidgin.im>
parents: 24562
diff changeset
402
0e356664879d Clean up some stuff that the behavior has changed on to fix CID 398.
Daniel Atallah <datallah@pidgin.im>
parents: 24562
diff changeset
403 if(bconv->pb != NULL)
25150
b0e1b122d83a merge of 'c93933e47474a5522b300e0ac9f8aa777205e964'
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 25141 25119
diff changeset
404 bb = purple_buddy_get_protocol_data(bconv->pb);
38854
086e15ec656d Remove all #if 0's from the prpls
Gary Kramlich <grim@reaperworld.com>
parents: 38433
diff changeset
405
25095
0e356664879d Clean up some stuff that the behavior has changed on to fix CID 398.
Daniel Atallah <datallah@pidgin.im>
parents: 24562
diff changeset
406 /* Close the socket, clear the watcher and free memory */
40080
a58c06469198 Rename Jabber to XMPP in Bonjour, as the official name is now XMPP and has been
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 40052
diff changeset
407 bonjour_xmpp_close_conversation(bconv);
25095
0e356664879d Clean up some stuff that the behavior has changed on to fix CID 398.
Daniel Atallah <datallah@pidgin.im>
parents: 24562
diff changeset
408 if(bb)
0e356664879d Clean up some stuff that the behavior has changed on to fix CID 398.
Daniel Atallah <datallah@pidgin.im>
parents: 24562
diff changeset
409 bb->conversation = NULL;
0e356664879d Clean up some stuff that the behavior has changed on to fix CID 398.
Daniel Atallah <datallah@pidgin.im>
parents: 24562
diff changeset
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
39639
fe7fa102e766 Convert Bonjour client side to GIO.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39638
diff changeset
412 static gboolean
fe7fa102e766 Convert Bonjour client side to GIO.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39638
diff changeset
413 _client_socket_handler(GObject *stream, gpointer data)
11477
98b4f8643569 [gaim-migrate @ 13719]
Mark Doliner <markdoliner@pidgin.im>
parents:
diff changeset
414 {
40080
a58c06469198 Rename Jabber to XMPP in Bonjour, as the official name is now XMPP and has been
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 40052
diff changeset
415 BonjourXMPPConversation *bconv = data;
39639
fe7fa102e766 Convert Bonjour client side to GIO.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39638
diff changeset
416 GError *error = NULL;
33783
8b37d3593783 bonjour: Similify code and get rid of some unnecessary control character removal
Daniel Atallah <datallah@pidgin.im>
parents: 33782
diff changeset
417 gssize len;
19056
05cd9ab28312 Update the Bonjour prpl to use libxml explicitly instead of the xml_node stuff. This allows us to deal with partial reads. I also fixed issues related to starting conversations with iChat and a couple other things. Fixes #2022,#1652
Daniel Atallah <datallah@pidgin.im>
parents: 18947
diff changeset
418 static char message[4096];
05cd9ab28312 Update the Bonjour prpl to use libxml explicitly instead of the xml_node stuff. This allows us to deal with partial reads. I also fixed issues related to starting conversations with iChat and a couple other things. Fixes #2022,#1652
Daniel Atallah <datallah@pidgin.im>
parents: 18947
diff changeset
419
11826
10ebbc41f163 [gaim-migrate @ 14117]
Richard Laager <rlaager@pidgin.im>
parents: 11823
diff changeset
420 /* Read the data from the socket */
39639
fe7fa102e766 Convert Bonjour client side to GIO.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39638
diff changeset
421 len = g_pollable_input_stream_read_nonblocking(
fe7fa102e766 Convert Bonjour client side to GIO.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39638
diff changeset
422 G_POLLABLE_INPUT_STREAM(stream), message, sizeof(message) - 1,
fe7fa102e766 Convert Bonjour client side to GIO.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39638
diff changeset
423 bconv->cancellable, &error);
fe7fa102e766 Convert Bonjour client side to GIO.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39638
diff changeset
424 if (len == -1) {
fe7fa102e766 Convert Bonjour client side to GIO.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39638
diff changeset
425 /* There has been an error reading from the socket */
fe7fa102e766 Convert Bonjour client side to GIO.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39638
diff changeset
426 if (error == NULL || (error->code != G_IO_ERROR_WOULD_BLOCK &&
fe7fa102e766 Convert Bonjour client side to GIO.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39638
diff changeset
427 error->code != G_IO_ERROR_CANCELLED)) {
fe7fa102e766 Convert Bonjour client side to GIO.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39638
diff changeset
428 purple_debug_warning(
fe7fa102e766 Convert Bonjour client side to GIO.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39638
diff changeset
429 "bonjour",
fe7fa102e766 Convert Bonjour client side to GIO.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39638
diff changeset
430 "receive of %" G_GSSIZE_FORMAT " error: %s",
fe7fa102e766 Convert Bonjour client side to GIO.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39638
diff changeset
431 len, error ? error->message : "(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
432
40080
a58c06469198 Rename Jabber to XMPP in Bonjour, as the official name is now XMPP and has been
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 40052
diff changeset
433 bonjour_xmpp_close_conversation(bconv);
24938
fc6952107e1f Finished moving to api for bonjour
Gary Kramlich <grim@reaperworld.com>
parents: 24562
diff changeset
434 if (bconv->pb != NULL) {
fc6952107e1f Finished moving to api for bonjour
Gary Kramlich <grim@reaperworld.com>
parents: 24562
diff changeset
435 BonjourBuddy *bb = purple_buddy_get_protocol_data(bconv->pb);
30825
87a79bbdc985 The hostname used for a bonjour account should always be the current machine
Daniel Atallah <datallah@pidgin.im>
parents: 30626
diff changeset
436
24938
fc6952107e1f Finished moving to api for bonjour
Gary Kramlich <grim@reaperworld.com>
parents: 24562
diff changeset
437 if(bb != NULL)
fc6952107e1f Finished moving to api for bonjour
Gary Kramlich <grim@reaperworld.com>
parents: 24562
diff changeset
438 bb->conversation = NULL;
21944
c41d17a1b8d9 This is the second part of the fix to support having multiple presence records in Bonjour (and also supporting multiple presences using the same IP). Incoming conversations are no longer immediately attached to a buddy - we use an algorithm to match a conversation to a buddy based on the IP and, if possible the "from" attribute of the stream or the first tag in the stream. Thanks to Sjoerd Simons from Telepahy Salut for noticing and suggesting the algorithm. Fixes #4187. It'd be good if a few people test this.
Daniel Atallah <datallah@pidgin.im>
parents: 21936
diff changeset
439 }
17665
26bff2090889 Update Bonjour to do nonblocking I/O correctly.
Daniel Atallah <datallah@pidgin.im>
parents: 17663
diff changeset
440
26bff2090889 Update Bonjour to do nonblocking I/O correctly.
Daniel Atallah <datallah@pidgin.im>
parents: 17663
diff changeset
441 /* 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
442 * 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
443 }
39639
fe7fa102e766 Convert Bonjour client side to GIO.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39638
diff changeset
444 g_clear_error(&error);
fe7fa102e766 Convert Bonjour client side to GIO.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39638
diff changeset
445 return FALSE;
19056
05cd9ab28312 Update the Bonjour prpl to use libxml explicitly instead of the xml_node stuff. This allows us to deal with partial reads. I also fixed issues related to starting conversations with iChat and a couple other things. Fixes #2022,#1652
Daniel Atallah <datallah@pidgin.im>
parents: 18947
diff changeset
446 } else if (len == 0) { /* The other end has closed the socket */
24938
fc6952107e1f Finished moving to api for bonjour
Gary Kramlich <grim@reaperworld.com>
parents: 24562
diff changeset
447 const gchar *name = purple_buddy_get_name(bconv->pb);
fc6952107e1f Finished moving to api for bonjour
Gary Kramlich <grim@reaperworld.com>
parents: 24562
diff changeset
448 purple_debug_warning("bonjour", "Connection closed (without stream end) by %s.\n", (name) ? name : "(unknown)");
40080
a58c06469198 Rename Jabber to XMPP in Bonjour, as the official name is now XMPP and has been
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 40052
diff changeset
449 bonjour_xmpp_stream_ended(bconv);
39639
fe7fa102e766 Convert Bonjour client side to GIO.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39638
diff changeset
450 return FALSE;
11477
98b4f8643569 [gaim-migrate @ 13719]
Mark Doliner <markdoliner@pidgin.im>
parents:
diff changeset
451 }
11539
fbabe3f89777 [gaim-migrate @ 13794]
Mark Doliner <markdoliner@pidgin.im>
parents: 11515
diff changeset
452
33783
8b37d3593783 bonjour: Similify code and get rid of some unnecessary control character removal
Daniel Atallah <datallah@pidgin.im>
parents: 33782
diff changeset
453 message[len] = '\0';
19056
05cd9ab28312 Update the Bonjour prpl to use libxml explicitly instead of the xml_node stuff. This allows us to deal with partial reads. I also fixed issues related to starting conversations with iChat and a couple other things. Fixes #2022,#1652
Daniel Atallah <datallah@pidgin.im>
parents: 18947
diff changeset
454
33783
8b37d3593783 bonjour: Similify code and get rid of some unnecessary control character removal
Daniel Atallah <datallah@pidgin.im>
parents: 33782
diff changeset
455 purple_debug_info("bonjour", "Receive: -%s- %" G_GSSIZE_FORMAT " bytes\n", message, len);
8b37d3593783 bonjour: Similify code and get rid of some unnecessary control character removal
Daniel Atallah <datallah@pidgin.im>
parents: 33782
diff changeset
456 bonjour_parser_process(bconv, message, len);
39639
fe7fa102e766 Convert Bonjour client side to GIO.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39638
diff changeset
457
fe7fa102e766 Convert Bonjour client side to GIO.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39638
diff changeset
458 return TRUE;
19056
05cd9ab28312 Update the Bonjour prpl to use libxml explicitly instead of the xml_node stuff. This allows us to deal with partial reads. I also fixed issues related to starting conversations with iChat and a couple other things. Fixes #2022,#1652
Daniel Atallah <datallah@pidgin.im>
parents: 18947
diff changeset
459 }
17633
b76241c02857 Some more Bonjour cleanup and leak fixing.
Daniel Atallah <datallah@pidgin.im>
parents: 17632
diff changeset
460
17665
26bff2090889 Update Bonjour to do nonblocking I/O correctly.
Daniel Atallah <datallah@pidgin.im>
parents: 17663
diff changeset
461 struct _stream_start_data {
26bff2090889 Update Bonjour to do nonblocking I/O correctly.
Daniel Atallah <datallah@pidgin.im>
parents: 17663
diff changeset
462 char *msg;
26bff2090889 Update Bonjour to do nonblocking I/O correctly.
Daniel Atallah <datallah@pidgin.im>
parents: 17663
diff changeset
463 };
26bff2090889 Update Bonjour to do nonblocking I/O correctly.
Daniel Atallah <datallah@pidgin.im>
parents: 17663
diff changeset
464
26bff2090889 Update Bonjour to do nonblocking I/O correctly.
Daniel Atallah <datallah@pidgin.im>
parents: 17663
diff changeset
465 static void
39639
fe7fa102e766 Convert Bonjour client side to GIO.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39638
diff changeset
466 _start_stream(GObject *stream, gpointer data)
17665
26bff2090889 Update Bonjour to do nonblocking I/O correctly.
Daniel Atallah <datallah@pidgin.im>
parents: 17663
diff changeset
467 {
40080
a58c06469198 Rename Jabber to XMPP in Bonjour, as the official name is now XMPP and has been
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 40052
diff changeset
468 BonjourXMPPConversation *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
469 struct _stream_start_data *ss = bconv->stream_data;
39639
fe7fa102e766 Convert Bonjour client side to GIO.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39638
diff changeset
470 GError *error = NULL;
fe7fa102e766 Convert Bonjour client side to GIO.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39638
diff changeset
471 gsize len;
fe7fa102e766 Convert Bonjour client side to GIO.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39638
diff changeset
472 gssize ret;
17665
26bff2090889 Update Bonjour to do nonblocking I/O correctly.
Daniel Atallah <datallah@pidgin.im>
parents: 17663
diff changeset
473
26bff2090889 Update Bonjour to do nonblocking I/O correctly.
Daniel Atallah <datallah@pidgin.im>
parents: 17663
diff changeset
474 len = strlen(ss->msg);
26bff2090889 Update Bonjour to do nonblocking I/O correctly.
Daniel Atallah <datallah@pidgin.im>
parents: 17663
diff changeset
475
26bff2090889 Update Bonjour to do nonblocking I/O correctly.
Daniel Atallah <datallah@pidgin.im>
parents: 17663
diff changeset
476 /* Start Stream */
39639
fe7fa102e766 Convert Bonjour client side to GIO.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39638
diff changeset
477 ret = g_pollable_output_stream_write_nonblocking(
fe7fa102e766 Convert Bonjour client side to GIO.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39638
diff changeset
478 G_POLLABLE_OUTPUT_STREAM(stream), ss->msg, len,
fe7fa102e766 Convert Bonjour client side to GIO.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39638
diff changeset
479 bconv->cancellable, &error);
17665
26bff2090889 Update Bonjour to do nonblocking I/O correctly.
Daniel Atallah <datallah@pidgin.im>
parents: 17663
diff changeset
480
39639
fe7fa102e766 Convert Bonjour client side to GIO.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39638
diff changeset
481 if (ret == -1 && error->code == G_IO_ERROR_WOULD_BLOCK) {
fe7fa102e766 Convert Bonjour client side to GIO.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39638
diff changeset
482 g_clear_error(&error);
17665
26bff2090889 Update Bonjour to do nonblocking I/O correctly.
Daniel Atallah <datallah@pidgin.im>
parents: 17663
diff changeset
483 return;
39639
fe7fa102e766 Convert Bonjour client side to GIO.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39638
diff changeset
484 } else if (ret <= 0) {
17665
26bff2090889 Update Bonjour to do nonblocking I/O correctly.
Daniel Atallah <datallah@pidgin.im>
parents: 17663
diff changeset
485 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
486 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
487 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
488
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
489 if(bconv->pb) {
24938
fc6952107e1f Finished moving to api for bonjour
Gary Kramlich <grim@reaperworld.com>
parents: 24562
diff changeset
490 bb = purple_buddy_get_protocol_data(bconv->pb);
21944
c41d17a1b8d9 This is the second part of the fix to support having multiple presence records in Bonjour (and also supporting multiple presences using the same IP). Incoming conversations are no longer immediately attached to a buddy - we use an algorithm to match a conversation to a buddy based on the IP and, if possible the "from" attribute of the stream or the first tag in the stream. Thanks to Sjoerd Simons from Telepahy Salut for noticing and suggesting the algorithm. Fixes #4187. It'd be good if a few people test this.
Daniel Atallah <datallah@pidgin.im>
parents: 21936
diff changeset
491 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
492 }
17665
26bff2090889 Update Bonjour to do nonblocking I/O correctly.
Daniel Atallah <datallah@pidgin.im>
parents: 17663
diff changeset
493
39639
fe7fa102e766 Convert Bonjour client side to GIO.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39638
diff changeset
494 purple_debug_error(
fe7fa102e766 Convert Bonjour client side to GIO.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39638
diff changeset
495 "bonjour",
fe7fa102e766 Convert Bonjour client side to GIO.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39638
diff changeset
496 "Error starting stream with buddy %s at %s error: %s",
fe7fa102e766 Convert Bonjour client side to GIO.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39638
diff changeset
497 bname ? bname : "(unknown)", bconv->ip,
fe7fa102e766 Convert Bonjour client side to GIO.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39638
diff changeset
498 error ? error->message : "(null)");
17665
26bff2090889 Update Bonjour to do nonblocking I/O correctly.
Daniel Atallah <datallah@pidgin.im>
parents: 17663
diff changeset
499
34632
ebe6b2a60305 Changed all arguments and return types of Chat and IMs to PurpleChatConversation and PurpleIMConversation.
Ankit Vani <a@nevitus.org>
parents: 34625
diff changeset
500 conv = PURPLE_CONVERSATION(purple_conversations_find_im_with_account(bname, bconv->account));
17665
26bff2090889 Update Bonjour to do nonblocking I/O correctly.
Daniel Atallah <datallah@pidgin.im>
parents: 17663
diff changeset
501 if (conv != NULL)
36089
c035b9a63457 Use purple_conversation_write_system_message where appropriate
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 36073
diff changeset
502 purple_conversation_write_system_message(conv,
c035b9a63457 Use purple_conversation_write_system_message where appropriate
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 36073
diff changeset
503 _("Unable to send the message, the conversation couldn't be started."),
c035b9a63457 Use purple_conversation_write_system_message where appropriate
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 36073
diff changeset
504 PURPLE_MESSAGE_ERROR);
17665
26bff2090889 Update Bonjour to do nonblocking I/O correctly.
Daniel Atallah <datallah@pidgin.im>
parents: 17663
diff changeset
505
40080
a58c06469198 Rename Jabber to XMPP in Bonjour, as the official name is now XMPP and has been
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 40052
diff changeset
506 bonjour_xmpp_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
507 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
508 bb->conversation = NULL;
17665
26bff2090889 Update Bonjour to do nonblocking I/O correctly.
Daniel Atallah <datallah@pidgin.im>
parents: 17663
diff changeset
509
39639
fe7fa102e766 Convert Bonjour client side to GIO.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39638
diff changeset
510 g_clear_error(&error);
17665
26bff2090889 Update Bonjour to do nonblocking I/O correctly.
Daniel Atallah <datallah@pidgin.im>
parents: 17663
diff changeset
511 return;
26bff2090889 Update Bonjour to do nonblocking I/O correctly.
Daniel Atallah <datallah@pidgin.im>
parents: 17663
diff changeset
512 }
26bff2090889 Update Bonjour to do nonblocking I/O correctly.
Daniel Atallah <datallah@pidgin.im>
parents: 17663
diff changeset
513
26bff2090889 Update Bonjour to do nonblocking I/O correctly.
Daniel Atallah <datallah@pidgin.im>
parents: 17663
diff changeset
514 /* This is EXTREMELY unlikely to happen */
40082
b8e9a7b626d4 Fix some namespace changes that I made accidentally. Also add a G_UNLIKELY
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 40081
diff changeset
515 if (G_UNLIKELY(ret < len)) {
17665
26bff2090889 Update Bonjour to do nonblocking I/O correctly.
Daniel Atallah <datallah@pidgin.im>
parents: 17663
diff changeset
516 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
517 g_free(ss->msg);
26bff2090889 Update Bonjour to do nonblocking I/O correctly.
Daniel Atallah <datallah@pidgin.im>
parents: 17663
diff changeset
518 ss->msg = tmp;
26bff2090889 Update Bonjour to do nonblocking I/O correctly.
Daniel Atallah <datallah@pidgin.im>
parents: 17663
diff changeset
519 return;
26bff2090889 Update Bonjour to do nonblocking I/O correctly.
Daniel Atallah <datallah@pidgin.im>
parents: 17663
diff changeset
520 }
26bff2090889 Update Bonjour to do nonblocking I/O correctly.
Daniel Atallah <datallah@pidgin.im>
parents: 17663
diff changeset
521
26bff2090889 Update Bonjour to do nonblocking I/O correctly.
Daniel Atallah <datallah@pidgin.im>
parents: 17663
diff changeset
522 g_free(ss->msg);
26bff2090889 Update Bonjour to do nonblocking I/O correctly.
Daniel Atallah <datallah@pidgin.im>
parents: 17663
diff changeset
523 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
524 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
525
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 /* Stream started; process the send buffer if there is one */
39639
fe7fa102e766 Convert Bonjour client side to GIO.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39638
diff changeset
527 g_source_remove(bconv->tx_handler);
21727
decfc3a613ff applied changes from b9c97ed0f9ada9069e8bd994b01fdde0b484083c
Daniel Atallah <datallah@pidgin.im>
parents: 21720
diff changeset
528 bconv->tx_handler = 0;
decfc3a613ff applied changes from b9c97ed0f9ada9069e8bd994b01fdde0b484083c
Daniel Atallah <datallah@pidgin.im>
parents: 21720
diff changeset
529 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
530
40080
a58c06469198 Rename Jabber to XMPP in Bonjour, as the official name is now XMPP and has been
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 40052
diff changeset
531 bonjour_xmpp_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
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
39639
fe7fa102e766 Convert Bonjour client side to GIO.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39638
diff changeset
534 static gboolean
40080
a58c06469198 Rename Jabber to XMPP in Bonjour, as the official name is now XMPP and has been
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 40052
diff changeset
535 bonjour_xmpp_send_stream_init(BonjourXMPPConversation *bconv,
39639
fe7fa102e766 Convert Bonjour client side to GIO.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39638
diff changeset
536 GError **error)
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
537 {
39639
fe7fa102e766 Convert Bonjour client side to GIO.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39638
diff changeset
538 gchar *stream_start;
fe7fa102e766 Convert Bonjour client side to GIO.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39638
diff changeset
539 gsize len;
fe7fa102e766 Convert Bonjour client side to GIO.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39638
diff changeset
540 gssize 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
541 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
542
39657
a868a210169e Assert some pointers are non-NULL.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39656
diff changeset
543 g_return_val_if_fail(error != NULL, FALSE);
a868a210169e Assert some pointers are non-NULL.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39656
diff changeset
544
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
545 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
546 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
547
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
548 /* 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
549 * 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
550 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
551 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
552
30825
87a79bbdc985 The hostname used for a bonjour account should always be the current machine
Daniel Atallah <datallah@pidgin.im>
parents: 30626
diff changeset
553 stream_start = g_strdup_printf(DOCTYPE, bonjour_get_jid(bconv->account), bname);
19056
05cd9ab28312 Update the Bonjour prpl to use libxml explicitly instead of the xml_node stuff. This allows us to deal with partial reads. I also fixed issues related to starting conversations with iChat and a couple other things. Fixes #2022,#1652
Daniel Atallah <datallah@pidgin.im>
parents: 18947
diff changeset
554 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
555
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
556 bconv->sent_stream_start = PARTIALLY_SENT;
21727
decfc3a613ff applied changes from b9c97ed0f9ada9069e8bd994b01fdde0b484083c
Daniel Atallah <datallah@pidgin.im>
parents: 21720
diff changeset
557
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
558 /* Start the stream */
39639
fe7fa102e766 Convert Bonjour client side to GIO.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39638
diff changeset
559 ret = g_pollable_output_stream_write_nonblocking(
fe7fa102e766 Convert Bonjour client side to GIO.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39638
diff changeset
560 G_POLLABLE_OUTPUT_STREAM(bconv->output), stream_start, len,
fe7fa102e766 Convert Bonjour client side to GIO.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39638
diff changeset
561 bconv->cancellable, error);
fe7fa102e766 Convert Bonjour client side to GIO.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39638
diff changeset
562 if (ret == -1 && (*error)->code == G_IO_ERROR_WOULD_BLOCK) {
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
563 ret = 0;
39639
fe7fa102e766 Convert Bonjour client side to GIO.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39638
diff changeset
564 g_clear_error(error);
fe7fa102e766 Convert Bonjour client side to GIO.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39638
diff changeset
565 } else if (ret <= 0) {
fe7fa102e766 Convert Bonjour client side to GIO.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39638
diff changeset
566 purple_debug_error(
fe7fa102e766 Convert Bonjour client side to GIO.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39638
diff changeset
567 "bonjour",
fe7fa102e766 Convert Bonjour client side to GIO.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39638
diff changeset
568 "Error starting stream with buddy %s at %s error: %s",
fe7fa102e766 Convert Bonjour client side to GIO.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39638
diff changeset
569 (*bname) ? bname : "(unknown)", bconv->ip,
fe7fa102e766 Convert Bonjour client side to GIO.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39638
diff changeset
570 *error ? (*error)->message : "(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
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 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
573 PurpleConversation *conv;
34632
ebe6b2a60305 Changed all arguments and return types of Chat and IMs to PurpleChatConversation and PurpleIMConversation.
Ankit Vani <a@nevitus.org>
parents: 34625
diff changeset
574 conv = PURPLE_CONVERSATION(purple_conversations_find_im_with_account(bname, bconv->account));
21944
c41d17a1b8d9 This is the second part of the fix to support having multiple presence records in Bonjour (and also supporting multiple presences using the same IP). Incoming conversations are no longer immediately attached to a buddy - we use an algorithm to match a conversation to a buddy based on the IP and, if possible the "from" attribute of the stream or the first tag in the stream. Thanks to Sjoerd Simons from Telepahy Salut for noticing and suggesting the algorithm. Fixes #4187. It'd be good if a few people test this.
Daniel Atallah <datallah@pidgin.im>
parents: 21936
diff changeset
575 if (conv != NULL)
36089
c035b9a63457 Use purple_conversation_write_system_message where appropriate
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 36073
diff changeset
576 purple_conversation_write_system_message(conv,
c035b9a63457 Use purple_conversation_write_system_message where appropriate
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 36073
diff changeset
577 _("Unable to send the message, the conversation couldn't be started."),
c035b9a63457 Use purple_conversation_write_system_message where appropriate
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 36073
diff changeset
578 PURPLE_MESSAGE_ERROR);
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
579 }
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
580
39639
fe7fa102e766 Convert Bonjour client side to GIO.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39638
diff changeset
581 purple_gio_graceful_close(G_IO_STREAM(bconv->socket),
fe7fa102e766 Convert Bonjour client side to GIO.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39638
diff changeset
582 G_INPUT_STREAM(bconv->input),
fe7fa102e766 Convert Bonjour client side to GIO.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39638
diff changeset
583 G_OUTPUT_STREAM(bconv->output));
fe7fa102e766 Convert Bonjour client side to GIO.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39638
diff changeset
584 g_clear_object(&bconv->socket);
fe7fa102e766 Convert Bonjour client side to GIO.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39638
diff changeset
585 bconv->input = NULL;
fe7fa102e766 Convert Bonjour client side to GIO.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39638
diff changeset
586 bconv->output = 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
587 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
588
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
589 return FALSE;
17665
26bff2090889 Update Bonjour to do nonblocking I/O correctly.
Daniel Atallah <datallah@pidgin.im>
parents: 17663
diff changeset
590 }
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
591
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
592 /* 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
593 if (ret < len) {
39639
fe7fa102e766 Convert Bonjour client side to GIO.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39638
diff changeset
594 GSource *source;
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
595 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
596 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
597 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
598 /* Finish sending the stream start */
39639
fe7fa102e766 Convert Bonjour client side to GIO.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39638
diff changeset
599 source = g_pollable_output_stream_create_source(
fe7fa102e766 Convert Bonjour client side to GIO.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39638
diff changeset
600 G_POLLABLE_OUTPUT_STREAM(bconv->output),
fe7fa102e766 Convert Bonjour client side to GIO.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39638
diff changeset
601 bconv->cancellable);
fe7fa102e766 Convert Bonjour client side to GIO.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39638
diff changeset
602 g_source_set_callback(source, (GSourceFunc)_start_stream, bconv,
fe7fa102e766 Convert Bonjour client side to GIO.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39638
diff changeset
603 NULL);
fe7fa102e766 Convert Bonjour client side to GIO.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39638
diff changeset
604 bconv->tx_handler = g_source_attach(source, NULL);
40344
489c56155c33 Fix leaks of GSources.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 40094
diff changeset
605 g_source_unref(source);
39639
fe7fa102e766 Convert Bonjour client side to GIO.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39638
diff changeset
606 } 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
607 bconv->sent_stream_start = FULLY_SENT;
39639
fe7fa102e766 Convert Bonjour client side to GIO.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39638
diff changeset
608 }
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
609
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
610 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
611
21727
decfc3a613ff applied changes from b9c97ed0f9ada9069e8bd994b01fdde0b484083c
Daniel Atallah <datallah@pidgin.im>
parents: 21720
diff changeset
612 return TRUE;
decfc3a613ff applied changes from b9c97ed0f9ada9069e8bd994b01fdde0b484083c
Daniel Atallah <datallah@pidgin.im>
parents: 21720
diff changeset
613 }
decfc3a613ff applied changes from b9c97ed0f9ada9069e8bd994b01fdde0b484083c
Daniel Atallah <datallah@pidgin.im>
parents: 21720
diff changeset
614
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
615 /* This gets called when we've successfully sent our <stream:stream />
30270
8380aae8b132 I before E, except after C
Stu Tomlinson <nosnilmot@pidgin.im>
parents: 30249
diff changeset
616 * AND when we've received a <stream:stream /> */
39639
fe7fa102e766 Convert Bonjour client side to GIO.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39638
diff changeset
617 void
40080
a58c06469198 Rename Jabber to XMPP in Bonjour, as the official name is now XMPP and has been
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 40052
diff changeset
618 bonjour_xmpp_stream_started(BonjourXMPPConversation *bconv)
39639
fe7fa102e766 Convert Bonjour client side to GIO.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39638
diff changeset
619 {
fe7fa102e766 Convert Bonjour client side to GIO.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39638
diff changeset
620 GError *error = NULL;
21727
decfc3a613ff applied changes from b9c97ed0f9ada9069e8bd994b01fdde0b484083c
Daniel Atallah <datallah@pidgin.im>
parents: 21720
diff changeset
621
39639
fe7fa102e766 Convert Bonjour client side to GIO.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39638
diff changeset
622 if (bconv->sent_stream_start == NOT_SENT &&
40080
a58c06469198 Rename Jabber to XMPP in Bonjour, as the official name is now XMPP and has been
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 40052
diff changeset
623 !bonjour_xmpp_send_stream_init(bconv, &error)) {
21944
c41d17a1b8d9 This is the second part of the fix to support having multiple presence records in Bonjour (and also supporting multiple presences using the same IP). Incoming conversations are no longer immediately attached to a buddy - we use an algorithm to match a conversation to a buddy based on the IP and, if possible the "from" attribute of the stream or the first tag in the stream. Thanks to Sjoerd Simons from Telepahy Salut for noticing and suggesting the algorithm. Fixes #4187. It'd be good if a few people test this.
Daniel Atallah <datallah@pidgin.im>
parents: 21936
diff changeset
624 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
625
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
626 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
627 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
628
39639
fe7fa102e766 Convert Bonjour client side to GIO.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39638
diff changeset
629 purple_debug_error(
fe7fa102e766 Convert Bonjour client side to GIO.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39638
diff changeset
630 "bonjour",
fe7fa102e766 Convert Bonjour client side to GIO.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39638
diff changeset
631 "Error starting stream with buddy %s at %s error: %s",
fe7fa102e766 Convert Bonjour client side to GIO.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39638
diff changeset
632 bname ? bname : "(unknown)", bconv->ip,
fe7fa102e766 Convert Bonjour client side to GIO.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39638
diff changeset
633 error ? error->message : "(null)");
21727
decfc3a613ff applied changes from b9c97ed0f9ada9069e8bd994b01fdde0b484083c
Daniel Atallah <datallah@pidgin.im>
parents: 21720
diff changeset
634
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
635 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
636 PurpleConversation *conv;
34632
ebe6b2a60305 Changed all arguments and return types of Chat and IMs to PurpleChatConversation and PurpleIMConversation.
Ankit Vani <a@nevitus.org>
parents: 34625
diff changeset
637 conv = PURPLE_CONVERSATION(purple_conversations_find_im_with_account(bname, bconv->account));
21944
c41d17a1b8d9 This is the second part of the fix to support having multiple presence records in Bonjour (and also supporting multiple presences using the same IP). Incoming conversations are no longer immediately attached to a buddy - we use an algorithm to match a conversation to a buddy based on the IP and, if possible the "from" attribute of the stream or the first tag in the stream. Thanks to Sjoerd Simons from Telepahy Salut for noticing and suggesting the algorithm. Fixes #4187. It'd be good if a few people test this.
Daniel Atallah <datallah@pidgin.im>
parents: 21936
diff changeset
638 if (conv != NULL)
36089
c035b9a63457 Use purple_conversation_write_system_message where appropriate
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 36073
diff changeset
639 purple_conversation_write_system_message(conv,
c035b9a63457 Use purple_conversation_write_system_message where appropriate
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 36073
diff changeset
640 _("Unable to send the message, the conversation couldn't be started."),
c035b9a63457 Use purple_conversation_write_system_message where appropriate
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 36073
diff changeset
641 PURPLE_MESSAGE_ERROR);
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
642 }
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
643
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 /* We don't want to recieve anything else */
39639
fe7fa102e766 Convert Bonjour client side to GIO.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39638
diff changeset
645 purple_gio_graceful_close(G_IO_STREAM(bconv->socket),
fe7fa102e766 Convert Bonjour client side to GIO.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39638
diff changeset
646 G_INPUT_STREAM(bconv->input),
fe7fa102e766 Convert Bonjour client side to GIO.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39638
diff changeset
647 G_OUTPUT_STREAM(bconv->output));
fe7fa102e766 Convert Bonjour client side to GIO.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39638
diff changeset
648 g_clear_object(&bconv->socket);
fe7fa102e766 Convert Bonjour client side to GIO.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39638
diff changeset
649 bconv->input = NULL;
fe7fa102e766 Convert Bonjour client side to GIO.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39638
diff changeset
650 bconv->output = 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
651
21727
decfc3a613ff applied changes from b9c97ed0f9ada9069e8bd994b01fdde0b484083c
Daniel Atallah <datallah@pidgin.im>
parents: 21720
diff changeset
652 /* 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
653 * may be in the middle of parsing.
decfc3a613ff applied changes from b9c97ed0f9ada9069e8bd994b01fdde0b484083c
Daniel Atallah <datallah@pidgin.im>
parents: 21720
diff changeset
654 */
40080
a58c06469198 Rename Jabber to XMPP in Bonjour, as the official name is now XMPP and has been
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 40052
diff changeset
655 async_bonjour_xmpp_close_conversation(bconv);
39639
fe7fa102e766 Convert Bonjour client side to GIO.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39638
diff changeset
656 g_clear_error(&error);
21727
decfc3a613ff applied changes from b9c97ed0f9ada9069e8bd994b01fdde0b484083c
Daniel Atallah <datallah@pidgin.im>
parents: 21720
diff changeset
657 return;
decfc3a613ff applied changes from b9c97ed0f9ada9069e8bd994b01fdde0b484083c
Daniel Atallah <datallah@pidgin.im>
parents: 21720
diff changeset
658 }
decfc3a613ff applied changes from b9c97ed0f9ada9069e8bd994b01fdde0b484083c
Daniel Atallah <datallah@pidgin.im>
parents: 21720
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 /* 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
661 /* 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
662 if (bconv->sent_stream_start == FULLY_SENT && bconv->recv_stream_start
34529
68cf25486001 GObjectify PurpleCircBuffer as PurpleCircularBuffer (from gobjectification branch)
Ankit Vani <a@nevitus.org>
parents: 33892
diff changeset
663 && bconv->pb && purple_circular_buffer_get_max_read(bconv->tx_buf) > 0) {
21727
decfc3a613ff applied changes from b9c97ed0f9ada9069e8bd994b01fdde0b484083c
Daniel Atallah <datallah@pidgin.im>
parents: 21720
diff changeset
664 /* Watch for when we can write the buffered messages */
39639
fe7fa102e766 Convert Bonjour client side to GIO.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39638
diff changeset
665 GSource *source = g_pollable_output_stream_create_source(
fe7fa102e766 Convert Bonjour client side to GIO.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39638
diff changeset
666 G_POLLABLE_OUTPUT_STREAM(bconv->output),
fe7fa102e766 Convert Bonjour client side to GIO.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39638
diff changeset
667 bconv->cancellable);
fe7fa102e766 Convert Bonjour client side to GIO.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39638
diff changeset
668 g_source_set_callback(source, (GSourceFunc)_send_data_write_cb,
fe7fa102e766 Convert Bonjour client side to GIO.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39638
diff changeset
669 bconv->pb, NULL);
fe7fa102e766 Convert Bonjour client side to GIO.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39638
diff changeset
670 bconv->tx_handler = g_source_attach(source, NULL);
40344
489c56155c33 Fix leaks of GSources.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 40094
diff changeset
671 g_source_unref(source);
21727
decfc3a613ff applied changes from b9c97ed0f9ada9069e8bd994b01fdde0b484083c
Daniel Atallah <datallah@pidgin.im>
parents: 21720
diff changeset
672 /* We can probably write the data right now. */
39639
fe7fa102e766 Convert Bonjour client side to GIO.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39638
diff changeset
673 _send_data_write_cb(G_OBJECT(bconv->output), bconv->pb);
21727
decfc3a613ff applied changes from b9c97ed0f9ada9069e8bd994b01fdde0b484083c
Daniel Atallah <datallah@pidgin.im>
parents: 21720
diff changeset
674 }
17665
26bff2090889 Update Bonjour to do nonblocking I/O correctly.
Daniel Atallah <datallah@pidgin.im>
parents: 17663
diff changeset
675 }
26bff2090889 Update Bonjour to do nonblocking I/O correctly.
Daniel Atallah <datallah@pidgin.im>
parents: 17663
diff changeset
676
29761
0f6862f2782f Implementation of IPv6 support for Bonjour
Daniel Atallah <datallah@pidgin.im>
parents: 27625
diff changeset
677 #ifndef INET6_ADDRSTRLEN
0f6862f2782f Implementation of IPv6 support for Bonjour
Daniel Atallah <datallah@pidgin.im>
parents: 27625
diff changeset
678 #define INET6_ADDRSTRLEN 46
0f6862f2782f Implementation of IPv6 support for Bonjour
Daniel Atallah <datallah@pidgin.im>
parents: 27625
diff changeset
679 #endif
0f6862f2782f Implementation of IPv6 support for Bonjour
Daniel Atallah <datallah@pidgin.im>
parents: 27625
diff changeset
680
12443
ad94864144f8 [gaim-migrate @ 14750]
Stu Tomlinson <nosnilmot@pidgin.im>
parents: 11830
diff changeset
681 static void
39638
635c8b6ca9a9 Convert Bonjour server to GSocketService.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39636
diff changeset
682 _server_socket_handler(GSocketService *service, GSocketConnection *connection,
635c8b6ca9a9 Convert Bonjour server to GSocketService.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39636
diff changeset
683 GObject *source_object, gpointer data)
11477
98b4f8643569 [gaim-migrate @ 13719]
Mark Doliner <markdoliner@pidgin.im>
parents:
diff changeset
684 {
40080
a58c06469198 Rename Jabber to XMPP in Bonjour, as the official name is now XMPP and has been
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 40052
diff changeset
685 BonjourXMPP *jdata = data;
39638
635c8b6ca9a9 Convert Bonjour server to GSocketService.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39636
diff changeset
686 GSocketAddress *their_addr; /* connector's address information */
635c8b6ca9a9 Convert Bonjour server to GSocketService.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39636
diff changeset
687 GInetAddress *their_inet_addr;
635c8b6ca9a9 Convert Bonjour server to GSocketService.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39636
diff changeset
688 gchar *address_text;
39660
4ddb9885a38b Fix reserved name usage of struct *_t.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39657
diff changeset
689 struct _match_buddies_by_address *mbba;
40080
a58c06469198 Rename Jabber to XMPP in Bonjour, as the official name is now XMPP and has been
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 40052
diff changeset
690 BonjourXMPPConversation *bconv;
26767
7489049a3bde Change purple_blist_get_buddies to return a list instead of the hash table.
Paul Aurich <darkrain42@pidgin.im>
parents: 25911
diff changeset
691 GSList *buddies;
39639
fe7fa102e766 Convert Bonjour client side to GIO.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39638
diff changeset
692 GSource *source;
11477
98b4f8643569 [gaim-migrate @ 13719]
Mark Doliner <markdoliner@pidgin.im>
parents:
diff changeset
693
39638
635c8b6ca9a9 Convert Bonjour server to GSocketService.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39636
diff changeset
694 their_addr = g_socket_connection_get_remote_address(connection, NULL);
635c8b6ca9a9 Convert Bonjour server to GSocketService.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39636
diff changeset
695 if (their_addr == NULL) {
11477
98b4f8643569 [gaim-migrate @ 13719]
Mark Doliner <markdoliner@pidgin.im>
parents:
diff changeset
696 return;
39638
635c8b6ca9a9 Convert Bonjour server to GSocketService.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39636
diff changeset
697 }
635c8b6ca9a9 Convert Bonjour server to GSocketService.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39636
diff changeset
698 their_inet_addr = g_inet_socket_address_get_address(
635c8b6ca9a9 Convert Bonjour server to GSocketService.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39636
diff changeset
699 G_INET_SOCKET_ADDRESS(their_addr));
11477
98b4f8643569 [gaim-migrate @ 13719]
Mark Doliner <markdoliner@pidgin.im>
parents:
diff changeset
700
13962
71617bf27d00 [gaim-migrate @ 16386]
Jono Cole
parents: 13267
diff changeset
701 /* Look for the buddy that has opened the conversation and fill information */
39638
635c8b6ca9a9 Convert Bonjour server to GSocketService.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39636
diff changeset
702 address_text = g_inet_address_to_string(their_inet_addr);
635c8b6ca9a9 Convert Bonjour server to GSocketService.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39636
diff changeset
703 if (g_inet_address_get_family(their_inet_addr) ==
635c8b6ca9a9 Convert Bonjour server to GSocketService.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39636
diff changeset
704 G_SOCKET_FAMILY_IPV6 &&
635c8b6ca9a9 Convert Bonjour server to GSocketService.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39636
diff changeset
705 g_inet_address_get_is_link_local(their_inet_addr)) {
635c8b6ca9a9 Convert Bonjour server to GSocketService.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39636
diff changeset
706 gchar *tmp = g_strdup_printf(
635c8b6ca9a9 Convert Bonjour server to GSocketService.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39636
diff changeset
707 "%s%%%d", address_text,
635c8b6ca9a9 Convert Bonjour server to GSocketService.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39636
diff changeset
708 g_inet_socket_address_get_scope_id(
635c8b6ca9a9 Convert Bonjour server to GSocketService.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39636
diff changeset
709 G_INET_SOCKET_ADDRESS(their_addr)));
635c8b6ca9a9 Convert Bonjour server to GSocketService.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39636
diff changeset
710 g_free(address_text);
635c8b6ca9a9 Convert Bonjour server to GSocketService.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39636
diff changeset
711 address_text = tmp;
635c8b6ca9a9 Convert Bonjour server to GSocketService.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39636
diff changeset
712 }
635c8b6ca9a9 Convert Bonjour server to GSocketService.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39636
diff changeset
713 g_object_unref(their_addr);
32058
95953bd2f239 Append interface ID only to local interfaces for IPv6 Bonjour.
Linus Lüssing <linus.luessing@web.de>
parents: 31749
diff changeset
714
19832
84b69b21672b Patch from QuLogic. Fixes #2903 ('Missing newlines in debug messages.')
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 19749
diff changeset
715 purple_debug_info("bonjour", "Received incoming connection from %s.\n", address_text);
39660
4ddb9885a38b Fix reserved name usage of struct *_t.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39657
diff changeset
716 mbba = g_new0(struct _match_buddies_by_address, 1);
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 mbba->address = address_text;
26767
7489049a3bde Change purple_blist_get_buddies to return a list instead of the hash table.
Paul Aurich <darkrain42@pidgin.im>
parents: 25911
diff changeset
718
34728
8efd73063ecf Renamed buddy list functions to more appropriate/simler names.
Ankit Vani <a@nevitus.org>
parents: 34706
diff changeset
719 buddies = purple_blist_find_buddies(jdata->account, NULL);
26767
7489049a3bde Change purple_blist_get_buddies to return a list instead of the hash table.
Paul Aurich <darkrain42@pidgin.im>
parents: 25911
diff changeset
720 g_slist_foreach(buddies, _match_buddies_by_address, mbba);
7489049a3bde Change purple_blist_get_buddies to return a list instead of the hash table.
Paul Aurich <darkrain42@pidgin.im>
parents: 25911
diff changeset
721 g_slist_free(buddies);
21944
c41d17a1b8d9 This is the second part of the fix to support having multiple presence records in Bonjour (and also supporting multiple presences using the same IP). Incoming conversations are no longer immediately attached to a buddy - we use an algorithm to match a conversation to a buddy based on the IP and, if possible the "from" attribute of the stream or the first tag in the stream. Thanks to Sjoerd Simons from Telepahy Salut for noticing and suggesting the algorithm. Fixes #4187. It'd be good if a few people test this.
Daniel Atallah <datallah@pidgin.im>
parents: 21936
diff changeset
722
c41d17a1b8d9 This is the second part of the fix to support having multiple presence records in Bonjour (and also supporting multiple presences using the same IP). Incoming conversations are no longer immediately attached to a buddy - we use an algorithm to match a conversation to a buddy based on the IP and, if possible the "from" attribute of the stream or the first tag in the stream. Thanks to Sjoerd Simons from Telepahy Salut for noticing and suggesting the algorithm. Fixes #4187. It'd be good if a few people test this.
Daniel Atallah <datallah@pidgin.im>
parents: 21936
diff changeset
723 if (mbba->matched_buddies == NULL) {
29999
Paul Aurich <darkrain42@pidgin.im>
parents: 29932
diff changeset
724 purple_debug_info("bonjour", "We don't like invisible buddies, this is not a superheroes comic\n");
39638
635c8b6ca9a9 Convert Bonjour server to GSocketService.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39636
diff changeset
725 g_free(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
726 g_free(mbba);
11477
98b4f8643569 [gaim-migrate @ 13719]
Mark Doliner <markdoliner@pidgin.im>
parents:
diff changeset
727 return;
98b4f8643569 [gaim-migrate @ 13719]
Mark Doliner <markdoliner@pidgin.im>
parents:
diff changeset
728 }
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 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
731 g_free(mbba);
17665
26bff2090889 Update Bonjour to do nonblocking I/O correctly.
Daniel Atallah <datallah@pidgin.im>
parents: 17663
diff changeset
732
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
733 /* 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
734 * 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
735 */
40080
a58c06469198 Rename Jabber to XMPP in Bonjour, as the official name is now XMPP and has been
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 40052
diff changeset
736 bconv = bonjour_xmpp_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
737
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
738 /* We wait for the stream start before doing anything else */
39639
fe7fa102e766 Convert Bonjour client side to GIO.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39638
diff changeset
739 bconv->socket = g_object_ref(connection);
fe7fa102e766 Convert Bonjour client side to GIO.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39638
diff changeset
740 bconv->input = g_io_stream_get_input_stream(G_IO_STREAM(bconv->socket));
fe7fa102e766 Convert Bonjour client side to GIO.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39638
diff changeset
741 bconv->output =
fe7fa102e766 Convert Bonjour client side to GIO.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39638
diff changeset
742 g_io_stream_get_output_stream(G_IO_STREAM(bconv->socket));
fe7fa102e766 Convert Bonjour client side to GIO.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39638
diff changeset
743 source = g_pollable_input_stream_create_source(
fe7fa102e766 Convert Bonjour client side to GIO.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39638
diff changeset
744 G_POLLABLE_INPUT_STREAM(bconv->input), bconv->cancellable);
fe7fa102e766 Convert Bonjour client side to GIO.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39638
diff changeset
745 g_source_set_callback(source, (GSourceFunc)_client_socket_handler,
fe7fa102e766 Convert Bonjour client side to GIO.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39638
diff changeset
746 bconv, NULL);
fe7fa102e766 Convert Bonjour client side to GIO.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39638
diff changeset
747 bconv->rx_handler = g_source_attach(source, NULL);
40344
489c56155c33 Fix leaks of GSources.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 40094
diff changeset
748 g_source_unref(source);
39638
635c8b6ca9a9 Convert Bonjour server to GSocketService.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39636
diff changeset
749 g_free(address_text);
29761
0f6862f2782f Implementation of IPv6 support for Bonjour
Daniel Atallah <datallah@pidgin.im>
parents: 27625
diff changeset
750 }
0f6862f2782f Implementation of IPv6 support for Bonjour
Daniel Atallah <datallah@pidgin.im>
parents: 27625
diff changeset
751
0f6862f2782f Implementation of IPv6 support for Bonjour
Daniel Atallah <datallah@pidgin.im>
parents: 27625
diff changeset
752 gint
40080
a58c06469198 Rename Jabber to XMPP in Bonjour, as the official name is now XMPP and has been
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 40052
diff changeset
753 bonjour_xmpp_start(BonjourXMPP *jdata)
29761
0f6862f2782f Implementation of IPv6 support for Bonjour
Daniel Atallah <datallah@pidgin.im>
parents: 27625
diff changeset
754 {
39638
635c8b6ca9a9 Convert Bonjour server to GSocketService.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39636
diff changeset
755 GError *error = NULL;
635c8b6ca9a9 Convert Bonjour server to GSocketService.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39636
diff changeset
756 guint16 port;
635c8b6ca9a9 Convert Bonjour server to GSocketService.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39636
diff changeset
757
635c8b6ca9a9 Convert Bonjour server to GSocketService.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39636
diff changeset
758 purple_debug_info("bonjour", "Attempting to bind IP socket to port %d.",
635c8b6ca9a9 Convert Bonjour server to GSocketService.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39636
diff changeset
759 jdata->port);
29761
0f6862f2782f Implementation of IPv6 support for Bonjour
Daniel Atallah <datallah@pidgin.im>
parents: 27625
diff changeset
760
39638
635c8b6ca9a9 Convert Bonjour server to GSocketService.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39636
diff changeset
761 /* Open a listening server for incoming conversations */
635c8b6ca9a9 Convert Bonjour server to GSocketService.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39636
diff changeset
762 jdata->service = g_socket_service_new();
635c8b6ca9a9 Convert Bonjour server to GSocketService.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39636
diff changeset
763 g_socket_listener_set_backlog(G_SOCKET_LISTENER(jdata->service), 10);
635c8b6ca9a9 Convert Bonjour server to GSocketService.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39636
diff changeset
764 port = jdata->port;
635c8b6ca9a9 Convert Bonjour server to GSocketService.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39636
diff changeset
765 if (!g_socket_listener_add_inet_port(G_SOCKET_LISTENER(jdata->service),
635c8b6ca9a9 Convert Bonjour server to GSocketService.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39636
diff changeset
766 port, NULL, &error)) {
635c8b6ca9a9 Convert Bonjour server to GSocketService.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39636
diff changeset
767 purple_debug_info("bonjour",
635c8b6ca9a9 Convert Bonjour server to GSocketService.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39636
diff changeset
768 "Unable to bind to specified port %i: %s",
635c8b6ca9a9 Convert Bonjour server to GSocketService.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39636
diff changeset
769 port, error ? error->message : "(unknown)");
635c8b6ca9a9 Convert Bonjour server to GSocketService.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39636
diff changeset
770 g_clear_error(&error);
635c8b6ca9a9 Convert Bonjour server to GSocketService.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39636
diff changeset
771 port = g_socket_listener_add_any_inet_port(
635c8b6ca9a9 Convert Bonjour server to GSocketService.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39636
diff changeset
772 G_SOCKET_LISTENER(jdata->service), NULL, &error);
635c8b6ca9a9 Convert Bonjour server to GSocketService.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39636
diff changeset
773 if (port == 0) {
635c8b6ca9a9 Convert Bonjour server to GSocketService.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39636
diff changeset
774 purple_debug_error(
635c8b6ca9a9 Convert Bonjour server to GSocketService.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39636
diff changeset
775 "bonjour", "Unable to create socket: %s",
635c8b6ca9a9 Convert Bonjour server to GSocketService.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39636
diff changeset
776 error ? error->message : "(unknown)");
635c8b6ca9a9 Convert Bonjour server to GSocketService.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39636
diff changeset
777 g_clear_error(&error);
35991
e6937e52930b Fix some CWE-252 coverity warnings
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35983
diff changeset
778 return -1;
e6937e52930b Fix some CWE-252 coverity warnings
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35983
diff changeset
779 }
29761
0f6862f2782f Implementation of IPv6 support for Bonjour
Daniel Atallah <datallah@pidgin.im>
parents: 27625
diff changeset
780 }
39638
635c8b6ca9a9 Convert Bonjour server to GSocketService.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39636
diff changeset
781 purple_debug_info("bonjour", "Bound IP socket to port %u.", port);
635c8b6ca9a9 Convert Bonjour server to GSocketService.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39636
diff changeset
782 jdata->port = port;
29761
0f6862f2782f Implementation of IPv6 support for Bonjour
Daniel Atallah <datallah@pidgin.im>
parents: 27625
diff changeset
783
39638
635c8b6ca9a9 Convert Bonjour server to GSocketService.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39636
diff changeset
784 g_signal_connect(G_OBJECT(jdata->service), "incoming",
635c8b6ca9a9 Convert Bonjour server to GSocketService.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39636
diff changeset
785 G_CALLBACK(_server_socket_handler), jdata);
11539
fbabe3f89777 [gaim-migrate @ 13794]
Mark Doliner <markdoliner@pidgin.im>
parents: 11515
diff changeset
786
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
787 return jdata->port;
11477
98b4f8643569 [gaim-migrate @ 13719]
Mark Doliner <markdoliner@pidgin.im>
parents:
diff changeset
788 }
98b4f8643569 [gaim-migrate @ 13719]
Mark Doliner <markdoliner@pidgin.im>
parents:
diff changeset
789
17665
26bff2090889 Update Bonjour to do nonblocking I/O correctly.
Daniel Atallah <datallah@pidgin.im>
parents: 17663
diff changeset
790 static void
39639
fe7fa102e766 Convert Bonjour client side to GIO.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39638
diff changeset
791 _connected_to_buddy(GObject *source, GAsyncResult *res, gpointer user_data)
17665
26bff2090889 Update Bonjour to do nonblocking I/O correctly.
Daniel Atallah <datallah@pidgin.im>
parents: 17663
diff changeset
792 {
39639
fe7fa102e766 Convert Bonjour client side to GIO.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39638
diff changeset
793 PurpleBuddy *pb = user_data;
24938
fc6952107e1f Finished moving to api for bonjour
Gary Kramlich <grim@reaperworld.com>
parents: 24562
diff changeset
794 BonjourBuddy *bb = purple_buddy_get_protocol_data(pb);
39639
fe7fa102e766 Convert Bonjour client side to GIO.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39638
diff changeset
795 GSocketConnection *conn;
fe7fa102e766 Convert Bonjour client side to GIO.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39638
diff changeset
796 GSource *rx_source;
fe7fa102e766 Convert Bonjour client side to GIO.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39638
diff changeset
797 GError *error = NULL;
17665
26bff2090889 Update Bonjour to do nonblocking I/O correctly.
Daniel Atallah <datallah@pidgin.im>
parents: 17663
diff changeset
798
39639
fe7fa102e766 Convert Bonjour client side to GIO.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39638
diff changeset
799 conn = g_socket_client_connect_to_host_finish(G_SOCKET_CLIENT(source),
fe7fa102e766 Convert Bonjour client side to GIO.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39638
diff changeset
800 res, &error);
17665
26bff2090889 Update Bonjour to do nonblocking I/O correctly.
Daniel Atallah <datallah@pidgin.im>
parents: 17663
diff changeset
801
39639
fe7fa102e766 Convert Bonjour client side to GIO.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39638
diff changeset
802 if (conn == NULL) {
24938
fc6952107e1f Finished moving to api for bonjour
Gary Kramlich <grim@reaperworld.com>
parents: 24562
diff changeset
803 PurpleConversation *conv = NULL;
fc6952107e1f Finished moving to api for bonjour
Gary Kramlich <grim@reaperworld.com>
parents: 24562
diff changeset
804 PurpleAccount *account = NULL;
40052
cc03b5af25ea Use GSList functions instead of manual iterations
qarkai <qarkai@gmail.com>
parents: 39960
diff changeset
805 GSList *tmp;
17665
26bff2090889 Update Bonjour to do nonblocking I/O correctly.
Daniel Atallah <datallah@pidgin.im>
parents: 17663
diff changeset
806
39639
fe7fa102e766 Convert Bonjour client side to GIO.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39638
diff changeset
807 if (error && error->code == G_IO_ERROR_CANCELLED) {
fe7fa102e766 Convert Bonjour client side to GIO.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39638
diff changeset
808 /* This conversation was closed before it started. */
fe7fa102e766 Convert Bonjour client side to GIO.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39638
diff changeset
809 g_error_free(error);
fe7fa102e766 Convert Bonjour client side to GIO.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39638
diff changeset
810 return;
fe7fa102e766 Convert Bonjour client side to GIO.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39638
diff changeset
811 }
fe7fa102e766 Convert Bonjour client side to GIO.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39638
diff changeset
812
fe7fa102e766 Convert Bonjour client side to GIO.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39638
diff changeset
813 purple_debug_error("bonjour",
fe7fa102e766 Convert Bonjour client side to GIO.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39638
diff changeset
814 "Error connecting to buddy %s at %s:%d "
fe7fa102e766 Convert Bonjour client side to GIO.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39638
diff changeset
815 "(%s); Trying next IP address",
fe7fa102e766 Convert Bonjour client side to GIO.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39638
diff changeset
816 purple_buddy_get_name(pb),
fe7fa102e766 Convert Bonjour client side to GIO.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39638
diff changeset
817 bb->conversation->ip, bb->port_p2pj,
fe7fa102e766 Convert Bonjour client side to GIO.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39638
diff changeset
818 error ? error->message : "(unknown)");
fe7fa102e766 Convert Bonjour client side to GIO.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39638
diff changeset
819 g_clear_error(&error);
31748
45c25b4868cb bonjour: Recurse through user IP addresses instead of using the first one only
Simon van der Linden <simon@vanderlinden.eu.org>
parents: 30827
diff changeset
820
31749
710d5d207306 bonjour: Update to 427f3622bbeb4 to match the last used IP more reliably.
Daniel Atallah <datallah@pidgin.im>
parents: 31748
diff changeset
821 /* There may be multiple entries for the same IP - one per
710d5d207306 bonjour: Update to 427f3622bbeb4 to match the last used IP more reliably.
Daniel Atallah <datallah@pidgin.im>
parents: 31748
diff changeset
822 * presence recieved (e.g. multiple interfaces).
710d5d207306 bonjour: Update to 427f3622bbeb4 to match the last used IP more reliably.
Daniel Atallah <datallah@pidgin.im>
parents: 31748
diff changeset
823 * We need to make sure that we find the previously used entry.
710d5d207306 bonjour: Update to 427f3622bbeb4 to match the last used IP more reliably.
Daniel Atallah <datallah@pidgin.im>
parents: 31748
diff changeset
824 */
40052
cc03b5af25ea Use GSList functions instead of manual iterations
qarkai <qarkai@gmail.com>
parents: 39960
diff changeset
825 tmp = g_slist_find(bb->ips, bb->conversation->ip_link);
31749
710d5d207306 bonjour: Update to 427f3622bbeb4 to match the last used IP more reliably.
Daniel Atallah <datallah@pidgin.im>
parents: 31748
diff changeset
826 if (tmp)
710d5d207306 bonjour: Update to 427f3622bbeb4 to match the last used IP more reliably.
Daniel Atallah <datallah@pidgin.im>
parents: 31748
diff changeset
827 tmp = g_slist_next(tmp);
17665
26bff2090889 Update Bonjour to do nonblocking I/O correctly.
Daniel Atallah <datallah@pidgin.im>
parents: 17663
diff changeset
828
24938
fc6952107e1f Finished moving to api for bonjour
Gary Kramlich <grim@reaperworld.com>
parents: 24562
diff changeset
829 account = purple_buddy_get_account(pb);
fc6952107e1f Finished moving to api for bonjour
Gary Kramlich <grim@reaperworld.com>
parents: 24562
diff changeset
830
31748
45c25b4868cb bonjour: Recurse through user IP addresses instead of using the first one only
Simon van der Linden <simon@vanderlinden.eu.org>
parents: 30827
diff changeset
831 if (tmp != NULL) {
45c25b4868cb bonjour: Recurse through user IP addresses instead of using the first one only
Simon van der Linden <simon@vanderlinden.eu.org>
parents: 30827
diff changeset
832 const gchar *ip;
39639
fe7fa102e766 Convert Bonjour client side to GIO.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39638
diff changeset
833 GSocketClient *client;
31748
45c25b4868cb bonjour: Recurse through user IP addresses instead of using the first one only
Simon van der Linden <simon@vanderlinden.eu.org>
parents: 30827
diff changeset
834
31749
710d5d207306 bonjour: Update to 427f3622bbeb4 to match the last used IP more reliably.
Daniel Atallah <datallah@pidgin.im>
parents: 31748
diff changeset
835 bb->conversation->ip_link = ip = tmp->data;
31748
45c25b4868cb bonjour: Recurse through user IP addresses instead of using the first one only
Simon van der Linden <simon@vanderlinden.eu.org>
parents: 30827
diff changeset
836
45c25b4868cb bonjour: Recurse through user IP addresses instead of using the first one only
Simon van der Linden <simon@vanderlinden.eu.org>
parents: 30827
diff changeset
837 purple_debug_info("bonjour", "Starting conversation with %s at %s:%d\n",
45c25b4868cb bonjour: Recurse through user IP addresses instead of using the first one only
Simon van der Linden <simon@vanderlinden.eu.org>
parents: 30827
diff changeset
838 purple_buddy_get_name(pb), ip, bb->port_p2pj);
45c25b4868cb bonjour: Recurse through user IP addresses instead of using the first one only
Simon van der Linden <simon@vanderlinden.eu.org>
parents: 30827
diff changeset
839
39639
fe7fa102e766 Convert Bonjour client side to GIO.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39638
diff changeset
840 /* Make sure to connect without a proxy. */
fe7fa102e766 Convert Bonjour client side to GIO.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39638
diff changeset
841 client = g_socket_client_new();
fe7fa102e766 Convert Bonjour client side to GIO.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39638
diff changeset
842 if (client != NULL) {
31748
45c25b4868cb bonjour: Recurse through user IP addresses instead of using the first one only
Simon van der Linden <simon@vanderlinden.eu.org>
parents: 30827
diff changeset
843 g_free(bb->conversation->ip);
45c25b4868cb bonjour: Recurse through user IP addresses instead of using the first one only
Simon van der Linden <simon@vanderlinden.eu.org>
parents: 30827
diff changeset
844 bb->conversation->ip = g_strdup(ip);
39639
fe7fa102e766 Convert Bonjour client side to GIO.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39638
diff changeset
845 g_socket_client_connect_to_host_async(
fe7fa102e766 Convert Bonjour client side to GIO.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39638
diff changeset
846 client, ip, bb->port_p2pj,
fe7fa102e766 Convert Bonjour client side to GIO.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39638
diff changeset
847 bb->conversation->cancellable,
fe7fa102e766 Convert Bonjour client side to GIO.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39638
diff changeset
848 _connected_to_buddy, pb);
fe7fa102e766 Convert Bonjour client side to GIO.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39638
diff changeset
849 g_object_unref(client);
31748
45c25b4868cb bonjour: Recurse through user IP addresses instead of using the first one only
Simon van der Linden <simon@vanderlinden.eu.org>
parents: 30827
diff changeset
850 return;
45c25b4868cb bonjour: Recurse through user IP addresses instead of using the first one only
Simon van der Linden <simon@vanderlinden.eu.org>
parents: 30827
diff changeset
851 }
45c25b4868cb bonjour: Recurse through user IP addresses instead of using the first one only
Simon van der Linden <simon@vanderlinden.eu.org>
parents: 30827
diff changeset
852 }
45c25b4868cb bonjour: Recurse through user IP addresses instead of using the first one only
Simon van der Linden <simon@vanderlinden.eu.org>
parents: 30827
diff changeset
853
45c25b4868cb bonjour: Recurse through user IP addresses instead of using the first one only
Simon van der Linden <simon@vanderlinden.eu.org>
parents: 30827
diff changeset
854 purple_debug_error("bonjour", "No more addresses for buddy %s. Aborting", purple_buddy_get_name(pb));
45c25b4868cb bonjour: Recurse through user IP addresses instead of using the first one only
Simon van der Linden <simon@vanderlinden.eu.org>
parents: 30827
diff changeset
855
34632
ebe6b2a60305 Changed all arguments and return types of Chat and IMs to PurpleChatConversation and PurpleIMConversation.
Ankit Vani <a@nevitus.org>
parents: 34625
diff changeset
856 conv = PURPLE_CONVERSATION(purple_conversations_find_im_with_account(bb->name, account));
17665
26bff2090889 Update Bonjour to do nonblocking I/O correctly.
Daniel Atallah <datallah@pidgin.im>
parents: 17663
diff changeset
857 if (conv != NULL)
36089
c035b9a63457 Use purple_conversation_write_system_message where appropriate
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 36073
diff changeset
858 purple_conversation_write_system_message(conv,
c035b9a63457 Use purple_conversation_write_system_message where appropriate
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 36073
diff changeset
859 _("Unable to send the message, the conversation couldn't be started."),
c035b9a63457 Use purple_conversation_write_system_message where appropriate
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 36073
diff changeset
860 PURPLE_MESSAGE_ERROR);
17665
26bff2090889 Update Bonjour to do nonblocking I/O correctly.
Daniel Atallah <datallah@pidgin.im>
parents: 17663
diff changeset
861
40080
a58c06469198 Rename Jabber to XMPP in Bonjour, as the official name is now XMPP and has been
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 40052
diff changeset
862 bonjour_xmpp_close_conversation(bb->conversation);
17665
26bff2090889 Update Bonjour to do nonblocking I/O correctly.
Daniel Atallah <datallah@pidgin.im>
parents: 17663
diff changeset
863 bb->conversation = NULL;
26bff2090889 Update Bonjour to do nonblocking I/O correctly.
Daniel Atallah <datallah@pidgin.im>
parents: 17663
diff changeset
864 return;
26bff2090889 Update Bonjour to do nonblocking I/O correctly.
Daniel Atallah <datallah@pidgin.im>
parents: 17663
diff changeset
865 }
26bff2090889 Update Bonjour to do nonblocking I/O correctly.
Daniel Atallah <datallah@pidgin.im>
parents: 17663
diff changeset
866
39639
fe7fa102e766 Convert Bonjour client side to GIO.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39638
diff changeset
867 bb->conversation->socket = conn;
fe7fa102e766 Convert Bonjour client side to GIO.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39638
diff changeset
868 bb->conversation->input =
fe7fa102e766 Convert Bonjour client side to GIO.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39638
diff changeset
869 g_io_stream_get_input_stream(G_IO_STREAM(conn));
fe7fa102e766 Convert Bonjour client side to GIO.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39638
diff changeset
870 bb->conversation->output =
fe7fa102e766 Convert Bonjour client side to GIO.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39638
diff changeset
871 g_io_stream_get_output_stream(G_IO_STREAM(conn));
fe7fa102e766 Convert Bonjour client side to GIO.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39638
diff changeset
872
40080
a58c06469198 Rename Jabber to XMPP in Bonjour, as the official name is now XMPP and has been
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 40052
diff changeset
873 if (!bonjour_xmpp_send_stream_init(bb->conversation, &error)) {
24938
fc6952107e1f Finished moving to api for bonjour
Gary Kramlich <grim@reaperworld.com>
parents: 24562
diff changeset
874 PurpleConversation *conv = NULL;
fc6952107e1f Finished moving to api for bonjour
Gary Kramlich <grim@reaperworld.com>
parents: 24562
diff changeset
875 PurpleAccount *account = NULL;
17665
26bff2090889 Update Bonjour to do nonblocking I/O correctly.
Daniel Atallah <datallah@pidgin.im>
parents: 17663
diff changeset
876
39639
fe7fa102e766 Convert Bonjour client side to GIO.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39638
diff changeset
877 purple_debug_error("bonjour",
fe7fa102e766 Convert Bonjour client side to GIO.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39638
diff changeset
878 "Error starting stream with buddy %s at "
fe7fa102e766 Convert Bonjour client side to GIO.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39638
diff changeset
879 "%s:%d error: %s",
fe7fa102e766 Convert Bonjour client side to GIO.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39638
diff changeset
880 purple_buddy_get_name(pb),
fe7fa102e766 Convert Bonjour client side to GIO.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39638
diff changeset
881 bb->conversation->ip, bb->port_p2pj,
fe7fa102e766 Convert Bonjour client side to GIO.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39638
diff changeset
882 error ? error->message : "(null)");
17665
26bff2090889 Update Bonjour to do nonblocking I/O correctly.
Daniel Atallah <datallah@pidgin.im>
parents: 17663
diff changeset
883
24938
fc6952107e1f Finished moving to api for bonjour
Gary Kramlich <grim@reaperworld.com>
parents: 24562
diff changeset
884 account = purple_buddy_get_account(pb);
fc6952107e1f Finished moving to api for bonjour
Gary Kramlich <grim@reaperworld.com>
parents: 24562
diff changeset
885
34632
ebe6b2a60305 Changed all arguments and return types of Chat and IMs to PurpleChatConversation and PurpleIMConversation.
Ankit Vani <a@nevitus.org>
parents: 34625
diff changeset
886 conv = PURPLE_CONVERSATION(purple_conversations_find_im_with_account(bb->name, account));
17665
26bff2090889 Update Bonjour to do nonblocking I/O correctly.
Daniel Atallah <datallah@pidgin.im>
parents: 17663
diff changeset
887 if (conv != NULL)
36089
c035b9a63457 Use purple_conversation_write_system_message where appropriate
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 36073
diff changeset
888 purple_conversation_write_system_message(conv,
c035b9a63457 Use purple_conversation_write_system_message where appropriate
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 36073
diff changeset
889 _("Unable to send the message, the conversation couldn't be started."),
c035b9a63457 Use purple_conversation_write_system_message where appropriate
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 36073
diff changeset
890 PURPLE_MESSAGE_ERROR);
17665
26bff2090889 Update Bonjour to do nonblocking I/O correctly.
Daniel Atallah <datallah@pidgin.im>
parents: 17663
diff changeset
891
40080
a58c06469198 Rename Jabber to XMPP in Bonjour, as the official name is now XMPP and has been
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 40052
diff changeset
892 bonjour_xmpp_close_conversation(bb->conversation);
17665
26bff2090889 Update Bonjour to do nonblocking I/O correctly.
Daniel Atallah <datallah@pidgin.im>
parents: 17663
diff changeset
893 bb->conversation = NULL;
39639
fe7fa102e766 Convert Bonjour client side to GIO.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39638
diff changeset
894 g_clear_error(&error);
17665
26bff2090889 Update Bonjour to do nonblocking I/O correctly.
Daniel Atallah <datallah@pidgin.im>
parents: 17663
diff changeset
895 return;
26bff2090889 Update Bonjour to do nonblocking I/O correctly.
Daniel Atallah <datallah@pidgin.im>
parents: 17663
diff changeset
896 }
21727
decfc3a613ff applied changes from b9c97ed0f9ada9069e8bd994b01fdde0b484083c
Daniel Atallah <datallah@pidgin.im>
parents: 21720
diff changeset
897
decfc3a613ff applied changes from b9c97ed0f9ada9069e8bd994b01fdde0b484083c
Daniel Atallah <datallah@pidgin.im>
parents: 21720
diff changeset
898 /* Start listening for the stream acknowledgement */
39639
fe7fa102e766 Convert Bonjour client side to GIO.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39638
diff changeset
899 rx_source = g_pollable_input_stream_create_source(
fe7fa102e766 Convert Bonjour client side to GIO.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39638
diff changeset
900 G_POLLABLE_INPUT_STREAM(bb->conversation->input),
fe7fa102e766 Convert Bonjour client side to GIO.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39638
diff changeset
901 bb->conversation->cancellable);
fe7fa102e766 Convert Bonjour client side to GIO.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39638
diff changeset
902 g_source_set_callback(rx_source, (GSourceFunc)_client_socket_handler,
fe7fa102e766 Convert Bonjour client side to GIO.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39638
diff changeset
903 bb->conversation, NULL);
fe7fa102e766 Convert Bonjour client side to GIO.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39638
diff changeset
904 bb->conversation->rx_handler = g_source_attach(rx_source, NULL);
40344
489c56155c33 Fix leaks of GSources.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 40094
diff changeset
905 g_source_unref(rx_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
906 }
c41d17a1b8d9 This is the second part of the fix to support having multiple presence records in Bonjour (and also supporting multiple presences using the same IP). Incoming conversations are no longer immediately attached to a buddy - we use an algorithm to match a conversation to a buddy based on the IP and, if possible the "from" attribute of the stream or the first tag in the stream. Thanks to Sjoerd Simons from Telepahy Salut for noticing and suggesting the algorithm. Fixes #4187. It'd be good if a few people test this.
Daniel Atallah <datallah@pidgin.im>
parents: 21936
diff changeset
907
c41d17a1b8d9 This is the second part of the fix to support having multiple presence records in Bonjour (and also supporting multiple presences using the same IP). Incoming conversations are no longer immediately attached to a buddy - we use an algorithm to match a conversation to a buddy based on the IP and, if possible the "from" attribute of the stream or the first tag in the stream. Thanks to Sjoerd Simons from Telepahy Salut for noticing and suggesting the algorithm. Fixes #4187. It'd be good if a few people test this.
Daniel Atallah <datallah@pidgin.im>
parents: 21936
diff changeset
908 void
40080
a58c06469198 Rename Jabber to XMPP in Bonjour, as the official name is now XMPP and has been
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 40052
diff changeset
909 bonjour_xmpp_conv_match_by_name(BonjourXMPPConversation *bconv) {
24938
fc6952107e1f Finished moving to api for bonjour
Gary Kramlich <grim@reaperworld.com>
parents: 24562
diff changeset
910 PurpleBuddy *pb = NULL;
fc6952107e1f Finished moving to api for bonjour
Gary Kramlich <grim@reaperworld.com>
parents: 24562
diff changeset
911 BonjourBuddy *bb = NULL;
21944
c41d17a1b8d9 This is the second part of the fix to support having multiple presence records in Bonjour (and also supporting multiple presences using the same IP). Incoming conversations are no longer immediately attached to a buddy - we use an algorithm to match a conversation to a buddy based on the IP and, if possible the "from" attribute of the stream or the first tag in the stream. Thanks to Sjoerd Simons from Telepahy Salut for noticing and suggesting the algorithm. Fixes #4187. It'd be good if a few people test this.
Daniel Atallah <datallah@pidgin.im>
parents: 21936
diff changeset
912
c41d17a1b8d9 This is the second part of the fix to support having multiple presence records in Bonjour (and also supporting multiple presences using the same IP). Incoming conversations are no longer immediately attached to a buddy - we use an algorithm to match a conversation to a buddy based on the IP and, if possible the "from" attribute of the stream or the first tag in the stream. Thanks to Sjoerd Simons from Telepahy Salut for noticing and suggesting the algorithm. Fixes #4187. It'd be good if a few people test this.
Daniel Atallah <datallah@pidgin.im>
parents: 21936
diff changeset
913 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
914 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
915
34728
8efd73063ecf Renamed buddy list functions to more appropriate/simler names.
Ankit Vani <a@nevitus.org>
parents: 34706
diff changeset
916 pb = purple_blist_find_buddy(bconv->account, bconv->buddy_name);
24938
fc6952107e1f Finished moving to api for bonjour
Gary Kramlich <grim@reaperworld.com>
parents: 24562
diff changeset
917 if (pb && (bb = purple_buddy_get_protocol_data(pb))) {
21944
c41d17a1b8d9 This is the second part of the fix to support having multiple presence records in Bonjour (and also supporting multiple presences using the same IP). Incoming conversations are no longer immediately attached to a buddy - we use an algorithm to match a conversation to a buddy based on the IP and, if possible the "from" attribute of the stream or the first tag in the stream. Thanks to Sjoerd Simons from Telepahy Salut for noticing and suggesting the algorithm. Fixes #4187. It'd be good if a few people test this.
Daniel Atallah <datallah@pidgin.im>
parents: 21936
diff changeset
918 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
919 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
920
c41d17a1b8d9 This is the second part of the fix to support having multiple presence records in Bonjour (and also supporting multiple presences using the same IP). Incoming conversations are no longer immediately attached to a buddy - we use an algorithm to match a conversation to a buddy based on the IP and, if possible the "from" attribute of the stream or the first tag in the stream. Thanks to Sjoerd Simons from Telepahy Salut for noticing and suggesting the algorithm. Fixes #4187. It'd be good if a few people test this.
Daniel Atallah <datallah@pidgin.im>
parents: 21936
diff changeset
921 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
922 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
923
c41d17a1b8d9 This is the second part of the fix to support having multiple presence records in Bonjour (and also supporting multiple presences using the same IP). Incoming conversations are no longer immediately attached to a buddy - we use an algorithm to match a conversation to a buddy based on the IP and, if possible the "from" attribute of the stream or the first tag in the stream. Thanks to Sjoerd Simons from Telepahy Salut for noticing and 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 /* 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
925 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
926 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
927 if (ip != NULL && g_ascii_strcasecmp(ip, bconv->ip) == 0) {
32215
0a4e72c8a67e Use accessor functions in a few places
Mark Doliner <markdoliner@pidgin.im>
parents: 31749
diff changeset
928 PurpleConnection *pc = purple_account_get_connection(bconv->account);
32260
5b0ecccb3bbb Convert bonjour prpl to use accessor functions purple_connection_get_protocol_data() and purple_connection_set_protocol_data().
Andrew Victor <andrew.victor@mxit.com>
parents: 32215
diff changeset
929 BonjourData *bd = purple_connection_get_protocol_data(pc);
40080
a58c06469198 Rename Jabber to XMPP in Bonjour, as the official name is now XMPP and has been
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 40052
diff changeset
930 BonjourXMPP *jdata = bd->xmpp_data;
21944
c41d17a1b8d9 This is the second part of the fix to support having multiple presence records in Bonjour (and also supporting multiple presences using the same IP). Incoming conversations are no longer immediately attached to a buddy - we use an algorithm to match a conversation to a buddy based on the IP and, if possible the "from" attribute of the stream or the first tag in the stream. Thanks to Sjoerd Simons from Telepahy Salut for noticing and suggesting the algorithm. Fixes #4187. It'd be good if a few people test this.
Daniel Atallah <datallah@pidgin.im>
parents: 21936
diff changeset
931
c41d17a1b8d9 This is the second part of the fix to support having multiple presence records in Bonjour (and also supporting multiple presences using the same IP). Incoming conversations are no longer immediately attached to a buddy - we use an algorithm to match a conversation to a buddy based on the IP and, if possible the "from" attribute of the stream or the first tag in the stream. Thanks to Sjoerd Simons from Telepahy Salut for noticing and 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 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
933 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
934
c41d17a1b8d9 This is the second part of the fix to support having multiple presence records in Bonjour (and also supporting multiple presences using the same IP). Incoming conversations are no longer immediately attached to a buddy - we use an algorithm to match a conversation to a buddy based on the IP and, if possible the "from" attribute of the stream or the first tag in the stream. Thanks to Sjoerd Simons from Telepahy Salut for noticing and suggesting the algorithm. Fixes #4187. It'd be good if a few people test this.
Daniel Atallah <datallah@pidgin.im>
parents: 21936
diff changeset
935 /* 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
936 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
937
c41d17a1b8d9 This is the second part of the fix to support having multiple presence records in Bonjour (and also supporting multiple presences using the same IP). Incoming conversations are no longer immediately attached to a buddy - we use an algorithm to match a conversation to a buddy based on the IP and, if possible the "from" attribute of the stream or the first tag in the stream. Thanks to Sjoerd Simons from Telepahy Salut for noticing and suggesting the algorithm. Fixes #4187. It'd be good if a few people test this.
Daniel Atallah <datallah@pidgin.im>
parents: 21936
diff changeset
938 /* 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
939 if(bb->conversation != NULL && bb->conversation != bconv)
40080
a58c06469198 Rename Jabber to XMPP in Bonjour, as the official name is now XMPP and has been
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 40052
diff changeset
940 bonjour_xmpp_close_conversation(bb->conversation);
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
941
c41d17a1b8d9 This is the second part of the fix to support having multiple presence records in Bonjour (and also supporting multiple presences using the same IP). Incoming conversations are no longer immediately attached to a buddy - we use an algorithm to match a conversation to a buddy based on the IP and, if possible the "from" attribute of the stream or the first tag in the stream. Thanks to Sjoerd Simons from Telepahy Salut for noticing and 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 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
943 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
944
c41d17a1b8d9 This is the second part of the fix to support having multiple presence records in Bonjour (and also supporting multiple presences using the same IP). Incoming conversations are no longer immediately attached to a buddy - we use an algorithm to match a conversation to a buddy based on the IP and, if possible the "from" attribute of the stream or the first tag in the stream. Thanks to Sjoerd Simons from Telepahy Salut for noticing and suggesting the algorithm. Fixes #4187. It'd be good if a few people test this.
Daniel Atallah <datallah@pidgin.im>
parents: 21936
diff changeset
945 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
946 }
c41d17a1b8d9 This is the second part of the fix to support having multiple presence records in Bonjour (and also supporting multiple presences using the same IP). Incoming conversations are no longer immediately attached to a buddy - we use an algorithm to match a conversation to a buddy based on the IP and, if possible the "from" attribute of the stream or the first tag in the stream. Thanks to Sjoerd Simons from Telepahy Salut for noticing and suggesting the algorithm. Fixes #4187. It'd be good if a few people test this.
Daniel Atallah <datallah@pidgin.im>
parents: 21936
diff changeset
947 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
948 }
c41d17a1b8d9 This is the second part of the fix to support having multiple presence records in Bonjour (and also supporting multiple presences using the same IP). Incoming conversations are no longer immediately attached to a buddy - we use an algorithm to match a conversation to a buddy based on the IP and, if possible the "from" attribute of the stream or the first tag in the stream. Thanks to Sjoerd Simons from Telepahy Salut for noticing and suggesting the algorithm. Fixes #4187. It'd be good if a few people test this.
Daniel Atallah <datallah@pidgin.im>
parents: 21936
diff changeset
949 }
c41d17a1b8d9 This is the second part of the fix to support having multiple presence records in Bonjour (and also supporting multiple presences using the same IP). Incoming conversations are no longer immediately attached to a buddy - we use an algorithm to match a conversation to a buddy based on the IP and, if possible the "from" attribute of the stream or the first tag in the stream. Thanks to Sjoerd Simons from Telepahy Salut for noticing and suggesting the algorithm. Fixes #4187. It'd be good if a few people test this.
Daniel Atallah <datallah@pidgin.im>
parents: 21936
diff changeset
950
c41d17a1b8d9 This is the second part of the fix to support having multiple presence records in Bonjour (and also supporting multiple presences using the same IP). Incoming conversations are no longer immediately attached to a buddy - we use an algorithm to match a conversation to a buddy based on the IP and, if possible the "from" attribute of the stream or the first tag in the stream. Thanks to Sjoerd Simons from Telepahy Salut for noticing and suggesting the algorithm. Fixes #4187. It'd be good if a few people test this.
Daniel Atallah <datallah@pidgin.im>
parents: 21936
diff changeset
951 /* 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
952 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
953 /* 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
954 * 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
955 */
40080
a58c06469198 Rename Jabber to XMPP in Bonjour, as the official name is now XMPP and has been
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 40052
diff changeset
956 async_bonjour_xmpp_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
957 }
c41d17a1b8d9 This is the second part of the fix to support having multiple presence records in Bonjour (and also supporting multiple presences using the same IP). Incoming conversations are no longer immediately attached to a buddy - we use an algorithm to match a conversation to a buddy based on the IP and, if possible the "from" attribute of the stream or the first tag in the stream. Thanks to Sjoerd Simons from Telepahy Salut for noticing and suggesting the algorithm. Fixes #4187. It'd be good if a few people test this.
Daniel Atallah <datallah@pidgin.im>
parents: 21936
diff changeset
958 }
c41d17a1b8d9 This is the second part of the fix to support having multiple presence records in Bonjour (and also supporting multiple presences using the same IP). Incoming conversations are no longer immediately attached to a buddy - we use an algorithm to match a conversation to a buddy based on the IP and, if possible the "from" attribute of the stream or the first tag in the stream. Thanks to Sjoerd Simons from Telepahy Salut for noticing and suggesting the algorithm. Fixes #4187. It'd be good if a few people test this.
Daniel Atallah <datallah@pidgin.im>
parents: 21936
diff changeset
959
c41d17a1b8d9 This is the second part of the fix to support having multiple presence records in Bonjour (and also supporting multiple presences using the same IP). Incoming conversations are no longer immediately attached to a buddy - we use an algorithm to match a conversation to a buddy based on the IP and, if possible the "from" attribute of the stream or the first tag in the stream. Thanks to Sjoerd Simons from Telepahy Salut for noticing and suggesting the algorithm. Fixes #4187. It'd be good if a few people test this.
Daniel Atallah <datallah@pidgin.im>
parents: 21936
diff changeset
960
c41d17a1b8d9 This is the second part of the fix to support having multiple presence records in Bonjour (and also supporting multiple presences using the same IP). Incoming conversations are no longer immediately attached to a buddy - we use an algorithm to match a conversation to a buddy based on the IP and, if possible the "from" attribute of the stream or the first tag in the stream. Thanks to Sjoerd Simons from Telepahy Salut for noticing and suggesting the algorithm. Fixes #4187. It'd be good if a few people test this.
Daniel Atallah <datallah@pidgin.im>
parents: 21936
diff changeset
961 void
40080
a58c06469198 Rename Jabber to XMPP in Bonjour, as the official name is now XMPP and has been
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 40052
diff changeset
962 bonjour_xmpp_conv_match_by_ip(BonjourXMPPConversation *bconv) {
32215
0a4e72c8a67e Use accessor functions in a few places
Mark Doliner <markdoliner@pidgin.im>
parents: 31749
diff changeset
963 PurpleConnection *pc = purple_account_get_connection(bconv->account);
32260
5b0ecccb3bbb Convert bonjour prpl to use accessor functions purple_connection_get_protocol_data() and purple_connection_set_protocol_data().
Andrew Victor <andrew.victor@mxit.com>
parents: 32215
diff changeset
964 BonjourData *bd = purple_connection_get_protocol_data(pc);
40080
a58c06469198 Rename Jabber to XMPP in Bonjour, as the official name is now XMPP and has been
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 40052
diff changeset
965 BonjourXMPP *jdata = bd->xmpp_data;
39660
4ddb9885a38b Fix reserved name usage of struct *_t.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39657
diff changeset
966 struct _match_buddies_by_address *mbba;
26767
7489049a3bde Change purple_blist_get_buddies to return a list instead of the hash table.
Paul Aurich <darkrain42@pidgin.im>
parents: 25911
diff changeset
967 GSList *buddies;
21944
c41d17a1b8d9 This is the second part of the fix to support having multiple presence records in Bonjour (and also supporting multiple presences using the same IP). Incoming conversations are no longer immediately attached to a buddy - we use an algorithm to match a conversation to a buddy based on the IP and, if possible the "from" attribute of the stream or the first tag in the stream. Thanks to Sjoerd Simons from Telepahy Salut for noticing and suggesting the algorithm. Fixes #4187. It'd be good if a few people test this.
Daniel Atallah <datallah@pidgin.im>
parents: 21936
diff changeset
968
39660
4ddb9885a38b Fix reserved name usage of struct *_t.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39657
diff changeset
969 mbba = g_new0(struct _match_buddies_by_address, 1);
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
970 mbba->address = bconv->ip;
26767
7489049a3bde Change purple_blist_get_buddies to return a list instead of the hash table.
Paul Aurich <darkrain42@pidgin.im>
parents: 25911
diff changeset
971
34728
8efd73063ecf Renamed buddy list functions to more appropriate/simler names.
Ankit Vani <a@nevitus.org>
parents: 34706
diff changeset
972 buddies = purple_blist_find_buddies(jdata->account, NULL);
26767
7489049a3bde Change purple_blist_get_buddies to return a list instead of the hash table.
Paul Aurich <darkrain42@pidgin.im>
parents: 25911
diff changeset
973 g_slist_foreach(buddies, _match_buddies_by_address, mbba);
7489049a3bde Change purple_blist_get_buddies to return a list instead of the hash table.
Paul Aurich <darkrain42@pidgin.im>
parents: 25911
diff changeset
974 g_slist_free(buddies);
21944
c41d17a1b8d9 This is the second part of the fix to support having multiple presence records in Bonjour (and also supporting multiple presences using the same IP). Incoming conversations are no longer immediately attached to a buddy - we use an algorithm to match a conversation to a buddy based on the IP and, if possible the "from" attribute of the stream or the first tag in the stream. Thanks to Sjoerd Simons from Telepahy Salut for noticing and suggesting the algorithm. Fixes #4187. It'd be good if a few people test this.
Daniel Atallah <datallah@pidgin.im>
parents: 21936
diff changeset
975
c41d17a1b8d9 This is the second part of the fix to support having multiple presence records in Bonjour (and also supporting multiple presences using the same IP). Incoming conversations are no longer immediately attached to a buddy - we use an algorithm to match a conversation to a buddy based on the IP and, if possible the "from" attribute of the stream or the first tag in the stream. Thanks to Sjoerd Simons from Telepahy Salut for noticing and suggesting the algorithm. Fixes #4187. It'd be good if a few people test this.
Daniel Atallah <datallah@pidgin.im>
parents: 21936
diff changeset
976 /* 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
977 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
978 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
979 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
980 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
981 PurpleBuddy *pb = mbba->matched_buddies->data;
24938
fc6952107e1f Finished moving to api for bonjour
Gary Kramlich <grim@reaperworld.com>
parents: 24562
diff changeset
982 BonjourBuddy *bb = purple_buddy_get_protocol_data(pb);
21944
c41d17a1b8d9 This is the second part of the fix to support having multiple presence records in Bonjour (and also supporting multiple presences using the same IP). Incoming conversations are no longer immediately attached to a buddy - we use an algorithm to match a conversation to a buddy based on the IP and, if possible the "from" attribute of the stream or the first tag in the stream. Thanks to Sjoerd Simons from Telepahy Salut for noticing and suggesting the algorithm. Fixes #4187. It'd be good if a few people test this.
Daniel Atallah <datallah@pidgin.im>
parents: 21936
diff changeset
983
c41d17a1b8d9 This is the second part of the fix to support having multiple presence records in Bonjour (and also supporting multiple presences using the same IP). Incoming conversations are no longer immediately attached to a buddy - we use an algorithm to match a conversation to a buddy based on the IP and, if possible the "from" attribute of the stream or the first tag in the stream. Thanks to Sjoerd Simons from Telepahy Salut for noticing and suggesting the algorithm. Fixes #4187. It'd be good if a few people test this.
Daniel Atallah <datallah@pidgin.im>
parents: 21936
diff changeset
984 purple_debug_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
985 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
986
c41d17a1b8d9 This is the second part of the fix to support having multiple presence records in Bonjour (and also supporting multiple presences using the same IP). Incoming conversations are no longer immediately attached to a buddy - we use an algorithm to match a conversation to a buddy based on the IP and, if possible the "from" attribute of the stream or the first tag in the stream. Thanks to Sjoerd Simons from Telepahy Salut for noticing and suggesting the algorithm. Fixes #4187. It'd be good if a few people test this.
Daniel Atallah <datallah@pidgin.im>
parents: 21936
diff changeset
987 /* 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
988 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
989
c41d17a1b8d9 This is the second part of the fix to support having multiple presence records in Bonjour (and also supporting multiple presences using the same IP). Incoming conversations are no longer immediately attached to a buddy - we use an algorithm to match a conversation to a buddy based on the IP and, if possible the "from" attribute of the stream or the first tag in the stream. Thanks to Sjoerd Simons from Telepahy Salut for noticing and suggesting the algorithm. Fixes #4187. It'd be good if a few people test this.
Daniel Atallah <datallah@pidgin.im>
parents: 21936
diff changeset
990 /* 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
991 if (bb->conversation != NULL && bb->conversation != bconv)
40080
a58c06469198 Rename Jabber to XMPP in Bonjour, as the official name is now XMPP and has been
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 40052
diff changeset
992 bonjour_xmpp_close_conversation(bb->conversation);
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
c41d17a1b8d9 This is the second part of the fix to support having multiple presence records in Bonjour (and also supporting multiple presences using the same IP). Incoming conversations are no longer immediately attached to a buddy - we use an algorithm to match a conversation to a buddy based on the IP and, if possible the "from" attribute of the stream or the first tag in the stream. Thanks to Sjoerd Simons from Telepahy Salut for noticing and 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 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
995 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
996 }
c41d17a1b8d9 This is the second part of the fix to support having multiple presence records in Bonjour (and also supporting multiple presences using the same IP). Incoming conversations are no longer immediately attached to a buddy - we use an algorithm to match a conversation to a buddy based on the IP and, if possible the "from" attribute of the stream or the first tag in the stream. Thanks to Sjoerd Simons from Telepahy Salut for noticing and 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 } 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
998 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
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 /* 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
1001 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
1002 /* 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
1003 * 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
1004 */
40080
a58c06469198 Rename Jabber to XMPP in Bonjour, as the official name is now XMPP and has been
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 40052
diff changeset
1005 async_bonjour_xmpp_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
1006 }
c41d17a1b8d9 This is the second part of the fix to support having multiple presence records in Bonjour (and also supporting multiple presences using the same IP). Incoming conversations are no longer immediately attached to a buddy - we use an algorithm to match a conversation to a buddy based on the IP and, if possible the "from" attribute of the stream or the first tag in the stream. Thanks to Sjoerd Simons from Telepahy Salut for noticing and 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
c41d17a1b8d9 This is the second part of the fix to support having multiple presence records in Bonjour (and also supporting multiple presences using the same IP). Incoming conversations are no longer immediately attached to a buddy - we use an algorithm to match a conversation to a buddy based on the IP and, if possible the "from" attribute of the stream or the first tag in the stream. Thanks to Sjoerd Simons from Telepahy Salut for noticing and 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 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
1009 g_free(mbba);
17665
26bff2090889 Update Bonjour to do nonblocking I/O correctly.
Daniel Atallah <datallah@pidgin.im>
parents: 17663
diff changeset
1010 }
26bff2090889 Update Bonjour to do nonblocking I/O correctly.
Daniel Atallah <datallah@pidgin.im>
parents: 17663
diff changeset
1011
21528
06532211eb62 Leak fix, cleanup and code reuse.
Daniel Atallah <datallah@pidgin.im>
parents: 21527
diff changeset
1012 static PurpleBuddy *
40080
a58c06469198 Rename Jabber to XMPP in Bonjour, as the official name is now XMPP and has been
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 40052
diff changeset
1013 _find_or_start_conversation(BonjourXMPP *jdata, const gchar *to)
11477
98b4f8643569 [gaim-migrate @ 13719]
Mark Doliner <markdoliner@pidgin.im>
parents:
diff changeset
1014 {
21528
06532211eb62 Leak fix, cleanup and code reuse.
Daniel Atallah <datallah@pidgin.im>
parents: 21527
diff changeset
1015 PurpleBuddy *pb = NULL;
06532211eb62 Leak fix, cleanup and code reuse.
Daniel Atallah <datallah@pidgin.im>
parents: 21527
diff changeset
1016 BonjourBuddy *bb = NULL;
06532211eb62 Leak fix, cleanup and code reuse.
Daniel Atallah <datallah@pidgin.im>
parents: 21527
diff changeset
1017
21944
c41d17a1b8d9 This is the second part of the fix to support having multiple presence records in Bonjour (and also supporting multiple presences using the same IP). Incoming conversations are no longer immediately attached to a buddy - we use an algorithm to match a conversation to a buddy based on the IP and, if possible the "from" attribute of the stream or the first tag in the stream. Thanks to Sjoerd Simons from Telepahy Salut for noticing and suggesting the algorithm. Fixes #4187. It'd be good if a few people test this.
Daniel Atallah <datallah@pidgin.im>
parents: 21936
diff changeset
1018 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
1019 g_return_val_if_fail(to != NULL, NULL);
11539
fbabe3f89777 [gaim-migrate @ 13794]
Mark Doliner <markdoliner@pidgin.im>
parents: 11515
diff changeset
1020
34728
8efd73063ecf Renamed buddy list functions to more appropriate/simler names.
Ankit Vani <a@nevitus.org>
parents: 34706
diff changeset
1021 pb = purple_blist_find_buddy(jdata->account, to);
24938
fc6952107e1f Finished moving to api for bonjour
Gary Kramlich <grim@reaperworld.com>
parents: 24562
diff changeset
1022 if (pb == NULL || (bb = purple_buddy_get_protocol_data(pb)) == NULL)
11693
1a42a66ca0f8 [gaim-migrate @ 13979]
Mark Doliner <markdoliner@pidgin.im>
parents: 11688
diff changeset
1023 /* 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
1024 return NULL;
11693
1a42a66ca0f8 [gaim-migrate @ 13979]
Mark Doliner <markdoliner@pidgin.im>
parents: 11688
diff changeset
1025
17607
4d7a1c0f169b Improve error handling while connecting to a bonjour buddy.
Daniel Atallah <datallah@pidgin.im>
parents: 17596
diff changeset
1026 /* Check if there is a previously open conversation */
39639
fe7fa102e766 Convert Bonjour client side to GIO.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39638
diff changeset
1027 if (bb->conversation == NULL) {
fe7fa102e766 Convert Bonjour client side to GIO.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39638
diff changeset
1028 GSocketClient *client;
fe7fa102e766 Convert Bonjour client side to GIO.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39638
diff changeset
1029 /* Start with the first IP address. */
fe7fa102e766 Convert Bonjour client side to GIO.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39638
diff changeset
1030 const gchar *ip = bb->ips->data;
21528
06532211eb62 Leak fix, cleanup and code reuse.
Daniel Atallah <datallah@pidgin.im>
parents: 21527
diff changeset
1031
39639
fe7fa102e766 Convert Bonjour client side to GIO.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39638
diff changeset
1032 purple_debug_info("bonjour",
fe7fa102e766 Convert Bonjour client side to GIO.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39638
diff changeset
1033 "Starting conversation with %s at %s:%d", to,
fe7fa102e766 Convert Bonjour client side to GIO.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39638
diff changeset
1034 ip, bb->port_p2pj);
17665
26bff2090889 Update Bonjour to do nonblocking I/O correctly.
Daniel Atallah <datallah@pidgin.im>
parents: 17663
diff changeset
1035
39639
fe7fa102e766 Convert Bonjour client side to GIO.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39638
diff changeset
1036 /* Make sure to connect without a proxy. */
fe7fa102e766 Convert Bonjour client side to GIO.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39638
diff changeset
1037 client = g_socket_client_new();
fe7fa102e766 Convert Bonjour client side to GIO.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39638
diff changeset
1038 if (client == NULL) {
fe7fa102e766 Convert Bonjour client side to GIO.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39638
diff changeset
1039 purple_debug_error("bonjour",
fe7fa102e766 Convert Bonjour client side to GIO.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39638
diff changeset
1040 "Unable to connect to buddy (%s).",
fe7fa102e766 Convert Bonjour client side to GIO.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39638
diff changeset
1041 to);
21528
06532211eb62 Leak fix, cleanup and code reuse.
Daniel Atallah <datallah@pidgin.im>
parents: 21527
diff changeset
1042 return NULL;
17665
26bff2090889 Update Bonjour to do nonblocking I/O correctly.
Daniel Atallah <datallah@pidgin.im>
parents: 17663
diff changeset
1043 }
17607
4d7a1c0f169b Improve error handling while connecting to a bonjour buddy.
Daniel Atallah <datallah@pidgin.im>
parents: 17596
diff changeset
1044
40080
a58c06469198 Rename Jabber to XMPP in Bonjour, as the official name is now XMPP and has been
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 40052
diff changeset
1045 bb->conversation = bonjour_xmpp_conv_new(pb, jdata->account, ip);
31749
710d5d207306 bonjour: Update to 427f3622bbeb4 to match the last used IP more reliably.
Daniel Atallah <datallah@pidgin.im>
parents: 31748
diff changeset
1046 bb->conversation->ip_link = ip;
39639
fe7fa102e766 Convert Bonjour client side to GIO.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39638
diff changeset
1047
fe7fa102e766 Convert Bonjour client side to GIO.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39638
diff changeset
1048 g_socket_client_connect_to_host_async(
fe7fa102e766 Convert Bonjour client side to GIO.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39638
diff changeset
1049 client, ip, bb->port_p2pj,
fe7fa102e766 Convert Bonjour client side to GIO.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39638
diff changeset
1050 bb->conversation->cancellable, _connected_to_buddy, pb);
fe7fa102e766 Convert Bonjour client side to GIO.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39638
diff changeset
1051 g_object_unref(client);
17607
4d7a1c0f169b Improve error handling while connecting to a bonjour buddy.
Daniel Atallah <datallah@pidgin.im>
parents: 17596
diff changeset
1052 }
21528
06532211eb62 Leak fix, cleanup and code reuse.
Daniel Atallah <datallah@pidgin.im>
parents: 21527
diff changeset
1053 return pb;
06532211eb62 Leak fix, cleanup and code reuse.
Daniel Atallah <datallah@pidgin.im>
parents: 21527
diff changeset
1054 }
06532211eb62 Leak fix, cleanup and code reuse.
Daniel Atallah <datallah@pidgin.im>
parents: 21527
diff changeset
1055
06532211eb62 Leak fix, cleanup and code reuse.
Daniel Atallah <datallah@pidgin.im>
parents: 21527
diff changeset
1056 int
40080
a58c06469198 Rename Jabber to XMPP in Bonjour, as the official name is now XMPP and has been
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 40052
diff changeset
1057 bonjour_xmpp_send_message(BonjourXMPP *jdata, const gchar *to, const gchar *body)
21528
06532211eb62 Leak fix, cleanup and code reuse.
Daniel Atallah <datallah@pidgin.im>
parents: 21527
diff changeset
1058 {
34935
686fa55b0deb Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents: 34911
diff changeset
1059 PurpleXmlNode *message_node, *node, *node2;
24333
9f23bb1c02c9 Looks like we need to convert the message into XHTML first. Fixes #7160.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 24196
diff changeset
1060 gchar *message, *xhtml;
21528
06532211eb62 Leak fix, cleanup and code reuse.
Daniel Atallah <datallah@pidgin.im>
parents: 21527
diff changeset
1061 PurpleBuddy *pb;
06532211eb62 Leak fix, cleanup and code reuse.
Daniel Atallah <datallah@pidgin.im>
parents: 21527
diff changeset
1062 BonjourBuddy *bb;
06532211eb62 Leak fix, cleanup and code reuse.
Daniel Atallah <datallah@pidgin.im>
parents: 21527
diff changeset
1063 int ret;
06532211eb62 Leak fix, cleanup and code reuse.
Daniel Atallah <datallah@pidgin.im>
parents: 21527
diff changeset
1064
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
1065 pb = _find_or_start_conversation(jdata, to);
24938
fc6952107e1f Finished moving to api for bonjour
Gary Kramlich <grim@reaperworld.com>
parents: 24562
diff changeset
1066 if (pb == NULL || (bb = purple_buddy_get_protocol_data(pb)) == NULL) {
21528
06532211eb62 Leak fix, cleanup and code reuse.
Daniel Atallah <datallah@pidgin.im>
parents: 21527
diff changeset
1067 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
1068 /* 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
1069 return -10000;
06532211eb62 Leak fix, cleanup and code reuse.
Daniel Atallah <datallah@pidgin.im>
parents: 21527
diff changeset
1070 }
06532211eb62 Leak fix, cleanup and code reuse.
Daniel Atallah <datallah@pidgin.im>
parents: 21527
diff changeset
1071
24333
9f23bb1c02c9 Looks like we need to convert the message into XHTML first. Fixes #7160.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 24196
diff changeset
1072 purple_markup_html_to_xhtml(body, &xhtml, &message);
9f23bb1c02c9 Looks like we need to convert the message into XHTML first. Fixes #7160.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 24196
diff changeset
1073
34935
686fa55b0deb Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents: 34911
diff changeset
1074 message_node = purple_xmlnode_new("message");
686fa55b0deb Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents: 34911
diff changeset
1075 purple_xmlnode_set_attrib(message_node, "to", bb->name);
686fa55b0deb Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents: 34911
diff changeset
1076 purple_xmlnode_set_attrib(message_node, "from", bonjour_get_jid(jdata->account));
686fa55b0deb Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents: 34911
diff changeset
1077 purple_xmlnode_set_attrib(message_node, "type", "chat");
17660
23c712d0a795 Cleanup, fix a leak and prevent the inbound xml from being parsed twice for every message.
Daniel Atallah <datallah@pidgin.im>
parents: 17633
diff changeset
1078
11826
10ebbc41f163 [gaim-migrate @ 14117]
Richard Laager <rlaager@pidgin.im>
parents: 11823
diff changeset
1079 /* Enclose the message from the UI within a "font" node */
34935
686fa55b0deb Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents: 34911
diff changeset
1080 node = purple_xmlnode_new_child(message_node, "body");
686fa55b0deb Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents: 34911
diff changeset
1081 purple_xmlnode_insert_data(node, message, strlen(message));
17660
23c712d0a795 Cleanup, fix a leak and prevent the inbound xml from being parsed twice for every message.
Daniel Atallah <datallah@pidgin.im>
parents: 17633
diff changeset
1082 g_free(message);
11539
fbabe3f89777 [gaim-migrate @ 13794]
Mark Doliner <markdoliner@pidgin.im>
parents: 11515
diff changeset
1083
34935
686fa55b0deb Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents: 34911
diff changeset
1084 node = purple_xmlnode_new_child(message_node, "html");
686fa55b0deb Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents: 34911
diff changeset
1085 purple_xmlnode_set_namespace(node, "http://www.w3.org/1999/xhtml");
11539
fbabe3f89777 [gaim-migrate @ 13794]
Mark Doliner <markdoliner@pidgin.im>
parents: 11515
diff changeset
1086
34935
686fa55b0deb Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents: 34911
diff changeset
1087 node = purple_xmlnode_new_child(node, "body");
24333
9f23bb1c02c9 Looks like we need to convert the message into XHTML first. Fixes #7160.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 24196
diff changeset
1088 message = g_strdup_printf("<font>%s</font>", xhtml);
34935
686fa55b0deb Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents: 34911
diff changeset
1089 node2 = purple_xmlnode_from_str(message, strlen(message));
24333
9f23bb1c02c9 Looks like we need to convert the message into XHTML first. Fixes #7160.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 24196
diff changeset
1090 g_free(xhtml);
17660
23c712d0a795 Cleanup, fix a leak and prevent the inbound xml from being parsed twice for every message.
Daniel Atallah <datallah@pidgin.im>
parents: 17633
diff changeset
1091 g_free(message);
34935
686fa55b0deb Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents: 34911
diff changeset
1092 purple_xmlnode_insert_child(node, node2);
11539
fbabe3f89777 [gaim-migrate @ 13794]
Mark Doliner <markdoliner@pidgin.im>
parents: 11515
diff changeset
1093
34935
686fa55b0deb Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents: 34911
diff changeset
1094 node = purple_xmlnode_new_child(message_node, "x");
40082
b8e9a7b626d4 Fix some namespace changes that I made accidentally. Also add a G_UNLIKELY
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 40081
diff changeset
1095 purple_xmlnode_set_namespace(node, "jabber:x:event");
34935
686fa55b0deb Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents: 34911
diff changeset
1096 purple_xmlnode_insert_child(node, purple_xmlnode_new("composing"));
11539
fbabe3f89777 [gaim-migrate @ 13794]
Mark Doliner <markdoliner@pidgin.im>
parents: 11515
diff changeset
1097
34935
686fa55b0deb Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents: 34911
diff changeset
1098 message = purple_xmlnode_to_str(message_node, NULL);
686fa55b0deb Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents: 34911
diff changeset
1099 purple_xmlnode_free(message_node);
11477
98b4f8643569 [gaim-migrate @ 13719]
Mark Doliner <markdoliner@pidgin.im>
parents:
diff changeset
1100
17665
26bff2090889 Update Bonjour to do nonblocking I/O correctly.
Daniel Atallah <datallah@pidgin.im>
parents: 17663
diff changeset
1101 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
1102
15873
78d3aa0fb61e plug some memory leaks
Stu Tomlinson <nosnilmot@pidgin.im>
parents: 15435
diff changeset
1103 g_free(message);
78d3aa0fb61e plug some memory leaks
Stu Tomlinson <nosnilmot@pidgin.im>
parents: 15435
diff changeset
1104
17665
26bff2090889 Update Bonjour to do nonblocking I/O correctly.
Daniel Atallah <datallah@pidgin.im>
parents: 17663
diff changeset
1105 return ret;
11477
98b4f8643569 [gaim-migrate @ 13719]
Mark Doliner <markdoliner@pidgin.im>
parents:
diff changeset
1106 }
98b4f8643569 [gaim-migrate @ 13719]
Mark Doliner <markdoliner@pidgin.im>
parents:
diff changeset
1107
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
1108 static gboolean
40080
a58c06469198 Rename Jabber to XMPP in Bonjour, as the official name is now XMPP and has been
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 40052
diff changeset
1109 _async_bonjour_xmpp_close_conversation_cb(gpointer data) {
a58c06469198 Rename Jabber to XMPP in Bonjour, as the official name is now XMPP and has been
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 40052
diff changeset
1110 BonjourXMPPConversation *bconv = data;
a58c06469198 Rename Jabber to XMPP in Bonjour, as the official name is now XMPP and has been
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 40052
diff changeset
1111 bonjour_xmpp_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
1112 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
1113 }
c41d17a1b8d9 This is the second part of the fix to support having multiple presence records in Bonjour (and also supporting multiple presences using the same IP). Incoming conversations are no longer immediately attached to a buddy - we use an algorithm to match a conversation to a buddy based on the IP and, if possible the "from" attribute of the stream or the first tag in the stream. Thanks to Sjoerd Simons from Telepahy Salut for noticing and suggesting the algorithm. Fixes #4187. It'd be good if a few people test this.
Daniel Atallah <datallah@pidgin.im>
parents: 21936
diff changeset
1114
c41d17a1b8d9 This is the second part of the fix to support having multiple presence records in Bonjour (and also supporting multiple presences using the same IP). Incoming conversations are no longer immediately attached to a buddy - we use an algorithm to match a conversation to a buddy based on the IP and, if possible the "from" attribute of the stream or the first tag in the stream. Thanks to Sjoerd Simons from Telepahy Salut for noticing and suggesting the algorithm. Fixes #4187. It'd be good if a few people test this.
Daniel Atallah <datallah@pidgin.im>
parents: 21936
diff changeset
1115 void
40080
a58c06469198 Rename Jabber to XMPP in Bonjour, as the official name is now XMPP and has been
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 40052
diff changeset
1116 async_bonjour_xmpp_close_conversation(BonjourXMPPConversation *bconv) {
32215
0a4e72c8a67e Use accessor functions in a few places
Mark Doliner <markdoliner@pidgin.im>
parents: 31749
diff changeset
1117 PurpleConnection *pc = purple_account_get_connection(bconv->account);
32260
5b0ecccb3bbb Convert bonjour prpl to use accessor functions purple_connection_get_protocol_data() and purple_connection_set_protocol_data().
Andrew Victor <andrew.victor@mxit.com>
parents: 32215
diff changeset
1118 BonjourData *bd = purple_connection_get_protocol_data(pc);
40080
a58c06469198 Rename Jabber to XMPP in Bonjour, as the official name is now XMPP and has been
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 40052
diff changeset
1119 BonjourXMPP *jdata = bd->xmpp_data;
21944
c41d17a1b8d9 This is the second part of the fix to support having multiple presence records in Bonjour (and also supporting multiple presences using the same IP). Incoming conversations are no longer immediately attached to a buddy - we use an algorithm to match a conversation to a buddy based on the IP and, if possible the "from" attribute of the stream or the first tag in the stream. Thanks to Sjoerd Simons from Telepahy Salut for noticing and suggesting the algorithm. Fixes #4187. It'd be good if a few people test this.
Daniel Atallah <datallah@pidgin.im>
parents: 21936
diff changeset
1120
c41d17a1b8d9 This is the second part of the fix to support having multiple presence records in Bonjour (and also supporting multiple presences using the same IP). Incoming conversations are no longer immediately attached to a buddy - we use an algorithm to match a conversation to a buddy based on the IP and, if possible the "from" attribute of the stream or the first tag in the stream. Thanks to Sjoerd Simons from Telepahy Salut for noticing and suggesting the algorithm. Fixes #4187. It'd be good if a few people test this.
Daniel Atallah <datallah@pidgin.im>
parents: 21936
diff changeset
1121 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
1122
c41d17a1b8d9 This is the second part of the fix to support having multiple presence records in Bonjour (and also supporting multiple presences using the same IP). Incoming conversations are no longer immediately attached to a buddy - we use an algorithm to match a conversation to a buddy based on the IP and, if possible the "from" attribute of the stream or the first tag in the stream. Thanks to Sjoerd Simons from Telepahy Salut for noticing and suggesting the algorithm. Fixes #4187. It'd be good if a few people test this.
Daniel Atallah <datallah@pidgin.im>
parents: 21936
diff changeset
1123 /* 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
1124 if(bconv->pb != NULL) {
24938
fc6952107e1f Finished moving to api for bonjour
Gary Kramlich <grim@reaperworld.com>
parents: 24562
diff changeset
1125 BonjourBuddy *bb = purple_buddy_get_protocol_data(bconv->pb);
21944
c41d17a1b8d9 This is the second part of the fix to support having multiple presence records in Bonjour (and also supporting multiple presences using the same IP). Incoming conversations are no longer immediately attached to a buddy - we use an algorithm to match a conversation to a buddy based on the IP and, if possible the "from" attribute of the stream or the first tag in the stream. Thanks to Sjoerd Simons from Telepahy Salut for noticing and suggesting the algorithm. Fixes #4187. It'd be good if a few people test this.
Daniel Atallah <datallah@pidgin.im>
parents: 21936
diff changeset
1126 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
1127 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
1128 }
c41d17a1b8d9 This is the second part of the fix to support having multiple presence records in Bonjour (and also supporting multiple presences using the same IP). Incoming conversations are no longer immediately attached to a buddy - we use an algorithm to match a conversation to a buddy based on the IP and, if possible the "from" attribute of the stream or the first tag in the stream. Thanks to Sjoerd Simons from Telepahy Salut for noticing and suggesting the algorithm. Fixes #4187. It'd be good if a few people test this.
Daniel Atallah <datallah@pidgin.im>
parents: 21936
diff changeset
1129
40080
a58c06469198 Rename Jabber to XMPP in Bonjour, as the official name is now XMPP and has been
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 40052
diff changeset
1130 bconv->close_timeout = g_timeout_add(0, _async_bonjour_xmpp_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
1131 }
c41d17a1b8d9 This is the second part of the fix to support having multiple presence records in Bonjour (and also supporting multiple presences using the same IP). Incoming conversations are no longer immediately attached to a buddy - we use an algorithm to match a conversation to a buddy based on the IP and, if possible the "from" attribute of the stream or the first tag in the stream. Thanks to Sjoerd Simons from Telepahy Salut for noticing and suggesting the algorithm. Fixes #4187. It'd be good if a few people test this.
Daniel Atallah <datallah@pidgin.im>
parents: 21936
diff changeset
1132
11539
fbabe3f89777 [gaim-migrate @ 13794]
Mark Doliner <markdoliner@pidgin.im>
parents: 11515
diff changeset
1133 void
40080
a58c06469198 Rename Jabber to XMPP in Bonjour, as the official name is now XMPP and has been
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 40052
diff changeset
1134 bonjour_xmpp_close_conversation(BonjourXMPPConversation *bconv)
11477
98b4f8643569 [gaim-migrate @ 13719]
Mark Doliner <markdoliner@pidgin.im>
parents:
diff changeset
1135 {
39636
df4819a9eb48 Remove extra indent in bonjour_jabber_close_conversation.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39190
diff changeset
1136 BonjourData *bd = NULL;
df4819a9eb48 Remove extra indent in bonjour_jabber_close_conversation.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39190
diff changeset
1137 PurpleConnection *pc = 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
1138
39636
df4819a9eb48 Remove extra indent in bonjour_jabber_close_conversation.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39190
diff changeset
1139 if (bconv == NULL) {
df4819a9eb48 Remove extra indent in bonjour_jabber_close_conversation.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39190
diff changeset
1140 return;
df4819a9eb48 Remove extra indent in bonjour_jabber_close_conversation.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39190
diff changeset
1141 }
36068
e9b9320a985a Drop PURPLE_CONNECTION_IS_VALID in favor of (temporary) PURPLE_ASSERT_CONNECTION_IS_VALID
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 36031
diff changeset
1142
39636
df4819a9eb48 Remove extra indent in bonjour_jabber_close_conversation.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39190
diff changeset
1143 pc = purple_account_get_connection(bconv->account);
df4819a9eb48 Remove extra indent in bonjour_jabber_close_conversation.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39190
diff changeset
1144 PURPLE_ASSERT_CONNECTION_IS_VALID(pc);
36068
e9b9320a985a Drop PURPLE_CONNECTION_IS_VALID in favor of (temporary) PURPLE_ASSERT_CONNECTION_IS_VALID
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 36031
diff changeset
1145
39636
df4819a9eb48 Remove extra indent in bonjour_jabber_close_conversation.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39190
diff changeset
1146 bd = purple_connection_get_protocol_data(pc);
df4819a9eb48 Remove extra indent in bonjour_jabber_close_conversation.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39190
diff changeset
1147 if (bd) {
40080
a58c06469198 Rename Jabber to XMPP in Bonjour, as the official name is now XMPP and has been
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 40052
diff changeset
1148 bd->xmpp_data->pending_conversations = g_slist_remove(
a58c06469198 Rename Jabber to XMPP in Bonjour, as the official name is now XMPP and has been
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 40052
diff changeset
1149 bd->xmpp_data->pending_conversations, bconv);
39636
df4819a9eb48 Remove extra indent in bonjour_jabber_close_conversation.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39190
diff changeset
1150 }
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
39636
df4819a9eb48 Remove extra indent in bonjour_jabber_close_conversation.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39190
diff changeset
1152 /* Cancel any file transfers that are waiting to begin */
df4819a9eb48 Remove extra indent in bonjour_jabber_close_conversation.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39190
diff changeset
1153 /* There wont be any transfers if it hasn't been attached to a buddy */
df4819a9eb48 Remove extra indent in bonjour_jabber_close_conversation.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39190
diff changeset
1154 if (bconv->pb != NULL && bd != NULL) {
df4819a9eb48 Remove extra indent in bonjour_jabber_close_conversation.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39190
diff changeset
1155 GSList *xfers, *tmp_next;
df4819a9eb48 Remove extra indent in bonjour_jabber_close_conversation.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39190
diff changeset
1156 xfers = bd->xfer_lists;
df4819a9eb48 Remove extra indent in bonjour_jabber_close_conversation.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39190
diff changeset
1157 while (xfers != NULL) {
df4819a9eb48 Remove extra indent in bonjour_jabber_close_conversation.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39190
diff changeset
1158 PurpleXfer *xfer = xfers->data;
df4819a9eb48 Remove extra indent in bonjour_jabber_close_conversation.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39190
diff changeset
1159 tmp_next = xfers->next;
df4819a9eb48 Remove extra indent in bonjour_jabber_close_conversation.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39190
diff changeset
1160 /* We only need to cancel this if it hasn't actually started transferring. */
df4819a9eb48 Remove extra indent in bonjour_jabber_close_conversation.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39190
diff changeset
1161 /* This will change if we ever support IBB transfers. */
df4819a9eb48 Remove extra indent in bonjour_jabber_close_conversation.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39190
diff changeset
1162 if (purple_strequal(purple_xfer_get_remote_user(xfer), purple_buddy_get_name(bconv->pb))
df4819a9eb48 Remove extra indent in bonjour_jabber_close_conversation.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39190
diff changeset
1163 && (purple_xfer_get_status(xfer) == PURPLE_XFER_STATUS_NOT_STARTED
df4819a9eb48 Remove extra indent in bonjour_jabber_close_conversation.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39190
diff changeset
1164 || purple_xfer_get_status(xfer) == PURPLE_XFER_STATUS_UNKNOWN)) {
df4819a9eb48 Remove extra indent in bonjour_jabber_close_conversation.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39190
diff changeset
1165 purple_xfer_cancel_remote(xfer);
df4819a9eb48 Remove extra indent in bonjour_jabber_close_conversation.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39190
diff changeset
1166 }
df4819a9eb48 Remove extra indent in bonjour_jabber_close_conversation.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39190
diff changeset
1167 xfers = tmp_next;
df4819a9eb48 Remove extra indent in bonjour_jabber_close_conversation.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39190
diff changeset
1168 }
df4819a9eb48 Remove extra indent in bonjour_jabber_close_conversation.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39190
diff changeset
1169 }
df4819a9eb48 Remove extra indent in bonjour_jabber_close_conversation.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39190
diff changeset
1170
df4819a9eb48 Remove extra indent in bonjour_jabber_close_conversation.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39190
diff changeset
1171 /* Close the socket and remove the watcher */
39639
fe7fa102e766 Convert Bonjour client side to GIO.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39638
diff changeset
1172 if (bconv->socket != NULL) {
39636
df4819a9eb48 Remove extra indent in bonjour_jabber_close_conversation.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39190
diff changeset
1173 /* Send the end of the stream to the other end of the conversation */
df4819a9eb48 Remove extra indent in bonjour_jabber_close_conversation.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39190
diff changeset
1174 if (bconv->sent_stream_start == FULLY_SENT) {
df4819a9eb48 Remove extra indent in bonjour_jabber_close_conversation.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39190
diff changeset
1175 size_t len = strlen(STREAM_END);
39639
fe7fa102e766 Convert Bonjour client side to GIO.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39638
diff changeset
1176 if (g_pollable_output_stream_write_nonblocking(
fe7fa102e766 Convert Bonjour client side to GIO.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39638
diff changeset
1177 G_POLLABLE_OUTPUT_STREAM(bconv->output),
fe7fa102e766 Convert Bonjour client side to GIO.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39638
diff changeset
1178 STREAM_END, len, bconv->cancellable,
fe7fa102e766 Convert Bonjour client side to GIO.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39638
diff changeset
1179 NULL) != (gssize)len) {
39636
df4819a9eb48 Remove extra indent in bonjour_jabber_close_conversation.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39190
diff changeset
1180 purple_debug_error("bonjour",
40080
a58c06469198 Rename Jabber to XMPP in Bonjour, as the official name is now XMPP and has been
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 40052
diff changeset
1181 "bonjour_xmpp_close_conversation: "
39636
df4819a9eb48 Remove extra indent in bonjour_jabber_close_conversation.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39190
diff changeset
1182 "couldn't send data\n");
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
1183 }
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
1184 }
39636
df4819a9eb48 Remove extra indent in bonjour_jabber_close_conversation.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39190
diff changeset
1185 /* TODO: We're really supposed to wait for "</stream:stream>" before closing the socket */
39639
fe7fa102e766 Convert Bonjour client side to GIO.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39638
diff changeset
1186 purple_gio_graceful_close(G_IO_STREAM(bconv->socket),
fe7fa102e766 Convert Bonjour client side to GIO.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39638
diff changeset
1187 G_INPUT_STREAM(bconv->input),
fe7fa102e766 Convert Bonjour client side to GIO.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39638
diff changeset
1188 G_OUTPUT_STREAM(bconv->output));
39636
df4819a9eb48 Remove extra indent in bonjour_jabber_close_conversation.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39190
diff changeset
1189 }
df4819a9eb48 Remove extra indent in bonjour_jabber_close_conversation.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39190
diff changeset
1190 if (bconv->rx_handler != 0) {
39639
fe7fa102e766 Convert Bonjour client side to GIO.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39638
diff changeset
1191 g_source_remove(bconv->rx_handler);
fe7fa102e766 Convert Bonjour client side to GIO.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39638
diff changeset
1192 bconv->rx_handler = 0;
39636
df4819a9eb48 Remove extra indent in bonjour_jabber_close_conversation.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39190
diff changeset
1193 }
39639
fe7fa102e766 Convert Bonjour client side to GIO.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39638
diff changeset
1194 if (bconv->tx_handler != 0) {
fe7fa102e766 Convert Bonjour client side to GIO.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39638
diff changeset
1195 g_source_remove(bconv->tx_handler);
fe7fa102e766 Convert Bonjour client side to GIO.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39638
diff changeset
1196 bconv->tx_handler = 0;
fe7fa102e766 Convert Bonjour client side to GIO.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39638
diff changeset
1197 }
fe7fa102e766 Convert Bonjour client side to GIO.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39638
diff changeset
1198
fe7fa102e766 Convert Bonjour client side to GIO.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39638
diff changeset
1199 /* Cancel any pending operations. */
fe7fa102e766 Convert Bonjour client side to GIO.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39638
diff changeset
1200 if (bconv->cancellable != NULL) {
fe7fa102e766 Convert Bonjour client side to GIO.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39638
diff changeset
1201 g_cancellable_cancel(bconv->cancellable);
fe7fa102e766 Convert Bonjour client side to GIO.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39638
diff changeset
1202 g_clear_object(&bconv->cancellable);
39636
df4819a9eb48 Remove extra indent in bonjour_jabber_close_conversation.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39190
diff changeset
1203 }
11539
fbabe3f89777 [gaim-migrate @ 13794]
Mark Doliner <markdoliner@pidgin.im>
parents: 11515
diff changeset
1204
39636
df4819a9eb48 Remove extra indent in bonjour_jabber_close_conversation.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39190
diff changeset
1205 /* Free all the data related to the conversation */
39639
fe7fa102e766 Convert Bonjour client side to GIO.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39638
diff changeset
1206 g_clear_object(&bconv->socket);
fe7fa102e766 Convert Bonjour client side to GIO.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39638
diff changeset
1207 bconv->input = NULL;
fe7fa102e766 Convert Bonjour client side to GIO.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39638
diff changeset
1208 bconv->output = NULL;
fe7fa102e766 Convert Bonjour client side to GIO.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39638
diff changeset
1209
39636
df4819a9eb48 Remove extra indent in bonjour_jabber_close_conversation.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39190
diff changeset
1210 g_object_unref(G_OBJECT(bconv->tx_buf));
df4819a9eb48 Remove extra indent in bonjour_jabber_close_conversation.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39190
diff changeset
1211 if (bconv->stream_data != NULL) {
df4819a9eb48 Remove extra indent in bonjour_jabber_close_conversation.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39190
diff changeset
1212 struct _stream_start_data *ss = bconv->stream_data;
df4819a9eb48 Remove extra indent in bonjour_jabber_close_conversation.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39190
diff changeset
1213 g_free(ss->msg);
df4819a9eb48 Remove extra indent in bonjour_jabber_close_conversation.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39190
diff changeset
1214 g_free(ss);
df4819a9eb48 Remove extra indent in bonjour_jabber_close_conversation.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39190
diff changeset
1215 }
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
1216
39636
df4819a9eb48 Remove extra indent in bonjour_jabber_close_conversation.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39190
diff changeset
1217 if (bconv->context != NULL) {
df4819a9eb48 Remove extra indent in bonjour_jabber_close_conversation.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39190
diff changeset
1218 bonjour_parser_setup(bconv);
df4819a9eb48 Remove extra indent in bonjour_jabber_close_conversation.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39190
diff changeset
1219 }
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
1220
39636
df4819a9eb48 Remove extra indent in bonjour_jabber_close_conversation.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39190
diff changeset
1221 if (bconv->close_timeout != 0) {
df4819a9eb48 Remove extra indent in bonjour_jabber_close_conversation.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39190
diff changeset
1222 g_source_remove(bconv->close_timeout);
df4819a9eb48 Remove extra indent in bonjour_jabber_close_conversation.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39190
diff changeset
1223 }
22238
c69aff70828d Prevent a crash caused by freed memory being accessed.
Daniel Atallah <datallah@pidgin.im>
parents: 21944
diff changeset
1224
39636
df4819a9eb48 Remove extra indent in bonjour_jabber_close_conversation.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39190
diff changeset
1225 g_free(bconv->buddy_name);
df4819a9eb48 Remove extra indent in bonjour_jabber_close_conversation.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39190
diff changeset
1226 g_free(bconv->ip);
df4819a9eb48 Remove extra indent in bonjour_jabber_close_conversation.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39190
diff changeset
1227 g_free(bconv);
11477
98b4f8643569 [gaim-migrate @ 13719]
Mark Doliner <markdoliner@pidgin.im>
parents:
diff changeset
1228 }
98b4f8643569 [gaim-migrate @ 13719]
Mark Doliner <markdoliner@pidgin.im>
parents:
diff changeset
1229
11539
fbabe3f89777 [gaim-migrate @ 13794]
Mark Doliner <markdoliner@pidgin.im>
parents: 11515
diff changeset
1230 void
40080
a58c06469198 Rename Jabber to XMPP in Bonjour, as the official name is now XMPP and has been
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 40052
diff changeset
1231 bonjour_xmpp_stop(BonjourXMPP *jdata)
11477
98b4f8643569 [gaim-migrate @ 13719]
Mark Doliner <markdoliner@pidgin.im>
parents:
diff changeset
1232 {
17633
b76241c02857 Some more Bonjour cleanup and leak fixing.
Daniel Atallah <datallah@pidgin.im>
parents: 17632
diff changeset
1233 /* Close the server socket and remove the watcher */
39638
635c8b6ca9a9 Convert Bonjour server to GSocketService.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39636
diff changeset
1234 if (jdata->service) {
635c8b6ca9a9 Convert Bonjour server to GSocketService.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39636
diff changeset
1235 g_socket_service_stop(jdata->service);
635c8b6ca9a9 Convert Bonjour server to GSocketService.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39636
diff changeset
1236 g_socket_listener_close(G_SOCKET_LISTENER(jdata->service));
635c8b6ca9a9 Convert Bonjour server to GSocketService.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39636
diff changeset
1237 g_clear_object(&jdata->service);
635c8b6ca9a9 Convert Bonjour server to GSocketService.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39636
diff changeset
1238 }
11539
fbabe3f89777 [gaim-migrate @ 13794]
Mark Doliner <markdoliner@pidgin.im>
parents: 11515
diff changeset
1239
17633
b76241c02857 Some more Bonjour cleanup and leak fixing.
Daniel Atallah <datallah@pidgin.im>
parents: 17632
diff changeset
1240 /* Close all the conversation sockets and remove all the watchers after sending end streams */
32215
0a4e72c8a67e Use accessor functions in a few places
Mark Doliner <markdoliner@pidgin.im>
parents: 31749
diff changeset
1241 if (!purple_account_is_disconnected(jdata->account)) {
17660
23c712d0a795 Cleanup, fix a leak and prevent the inbound xml from being parsed twice for every message.
Daniel Atallah <datallah@pidgin.im>
parents: 17633
diff changeset
1242 GSList *buddies, *l;
17633
b76241c02857 Some more Bonjour cleanup and leak fixing.
Daniel Atallah <datallah@pidgin.im>
parents: 17632
diff changeset
1243
34728
8efd73063ecf Renamed buddy list functions to more appropriate/simler names.
Ankit Vani <a@nevitus.org>
parents: 34706
diff changeset
1244 buddies = purple_blist_find_buddies(jdata->account, NULL);
17663
fd736a4d91a9 Close conversation connections when logging out of the Bonjour account. This also fixes leakage.
Daniel Atallah <datallah@pidgin.im>
parents: 17662
diff changeset
1245 for (l = buddies; l; l = l->next) {
24938
fc6952107e1f Finished moving to api for bonjour
Gary Kramlich <grim@reaperworld.com>
parents: 24562
diff changeset
1246 BonjourBuddy *bb = purple_buddy_get_protocol_data((PurpleBuddy*) l->data);
30249
8e9926aa236a bonjour: Fix a crash-on-disconnect I introduced. Closes #11851
Paul Aurich <darkrain42@pidgin.im>
parents: 29999
diff changeset
1247 if (bb && bb->conversation) {
29932
2ac5b74d0649 Fix two related on-disconnect double frees.
Paul Aurich <darkrain42@pidgin.im>
parents: 29761
diff changeset
1248 /* Any ongoing connection attempt is cancelled
34751
374a9500c430 Added _purple_connection_wants_to_die() to internal.h to be used by account.c. Removed _purple_connection_destroy().
Ankit Vani <a@nevitus.org>
parents: 34728
diff changeset
1249 * when a connection is destroyed */
40080
a58c06469198 Rename Jabber to XMPP in Bonjour, as the official name is now XMPP and has been
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 40052
diff changeset
1250 bonjour_xmpp_close_conversation(bb->conversation);
23160
0aff8f3882f4 applied changes from 3d595739f53a259d5dae408a05f64d2836f02ac9
Daniel Atallah <datallah@pidgin.im>
parents: 23072
diff changeset
1251 bb->conversation = NULL;
0aff8f3882f4 applied changes from 3d595739f53a259d5dae408a05f64d2836f02ac9
Daniel Atallah <datallah@pidgin.im>
parents: 23072
diff changeset
1252 }
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
1253 }
17665
26bff2090889 Update Bonjour to do nonblocking I/O correctly.
Daniel Atallah <datallah@pidgin.im>
parents: 17663
diff changeset
1254
11477
98b4f8643569 [gaim-migrate @ 13719]
Mark Doliner <markdoliner@pidgin.im>
parents:
diff changeset
1255 g_slist_free(buddies);
98b4f8643569 [gaim-migrate @ 13719]
Mark Doliner <markdoliner@pidgin.im>
parents:
diff changeset
1256 }
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
1257
40080
a58c06469198 Rename Jabber to XMPP in Bonjour, as the official name is now XMPP and has been
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 40052
diff changeset
1258 g_slist_free_full(jdata->pending_conversations, (GDestroyNotify)bonjour_xmpp_close_conversation);
11477
98b4f8643569 [gaim-migrate @ 13719]
Mark Doliner <markdoliner@pidgin.im>
parents:
diff changeset
1259 }
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
1260
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 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
1262 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
1263 {
34935
686fa55b0deb Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents: 34911
diff changeset
1264 PurpleXmlNode *iq_node = NULL;
21524
472e58992083 Patch from some Intel folks to implement file transfer in Bonjour using XEP-0096 and 0065. This hopefully will work with Gaijm (haven't yet tested) and, of course, between libpurple instances; it will not work with Adium or iChat.
Daniel Atallah <datallah@pidgin.im>
parents: 21503
diff changeset
1265 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
1266
21548
b19c433f5af2 Cleanup and fix the socks5 proxy connect address to be correct.
Daniel Atallah <datallah@pidgin.im>
parents: 21547
diff changeset
1267 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
1268 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
1269 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
1270
34935
686fa55b0deb Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents: 34911
diff changeset
1271 iq_node = purple_xmlnode_new("iq");
21524
472e58992083 Patch from some Intel folks to implement file transfer in Bonjour using XEP-0096 and 0065. This hopefully will work with Gaijm (haven't yet tested) and, of course, between libpurple instances; it will not work with Adium or iChat.
Daniel Atallah <datallah@pidgin.im>
parents: 21503
diff changeset
1272
34935
686fa55b0deb Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents: 34911
diff changeset
1273 purple_xmlnode_set_attrib(iq_node, "to", to);
686fa55b0deb Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents: 34911
diff changeset
1274 purple_xmlnode_set_attrib(iq_node, "from", from);
686fa55b0deb Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents: 34911
diff changeset
1275 purple_xmlnode_set_attrib(iq_node, "id", id);
21524
472e58992083 Patch from some Intel folks to implement file transfer in Bonjour using XEP-0096 and 0065. This hopefully will work with Gaijm (haven't yet tested) and, of course, between libpurple instances; it will not work with Adium or iChat.
Daniel Atallah <datallah@pidgin.im>
parents: 21503
diff changeset
1276 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
1277 case XEP_IQ_SET:
34935
686fa55b0deb Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents: 34911
diff changeset
1278 purple_xmlnode_set_attrib(iq_node, "type", "set");
21524
472e58992083 Patch from some Intel folks to implement file transfer in Bonjour using XEP-0096 and 0065. This hopefully will work with Gaijm (haven't yet tested) and, of course, between libpurple instances; it will not work with Adium or iChat.
Daniel Atallah <datallah@pidgin.im>
parents: 21503
diff changeset
1279 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
1280 case XEP_IQ_GET:
34935
686fa55b0deb Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents: 34911
diff changeset
1281 purple_xmlnode_set_attrib(iq_node, "type", "get");
21524
472e58992083 Patch from some Intel folks to implement file transfer in Bonjour using XEP-0096 and 0065. This hopefully will work with Gaijm (haven't yet tested) and, of course, between libpurple instances; it will not work with Adium or iChat.
Daniel Atallah <datallah@pidgin.im>
parents: 21503
diff changeset
1282 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
1283 case XEP_IQ_RESULT:
34935
686fa55b0deb Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents: 34911
diff changeset
1284 purple_xmlnode_set_attrib(iq_node, "type", "result");
21524
472e58992083 Patch from some Intel folks to implement file transfer in Bonjour using XEP-0096 and 0065. This hopefully will work with Gaijm (haven't yet tested) and, of course, between libpurple instances; it will not work with Adium or iChat.
Daniel Atallah <datallah@pidgin.im>
parents: 21503
diff changeset
1285 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
1286 case XEP_IQ_ERROR:
34935
686fa55b0deb Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents: 34911
diff changeset
1287 purple_xmlnode_set_attrib(iq_node, "type", "error");
21524
472e58992083 Patch from some Intel folks to implement file transfer in Bonjour using XEP-0096 and 0065. This hopefully will work with Gaijm (haven't yet tested) and, of course, between libpurple instances; it will not work with Adium or iChat.
Daniel Atallah <datallah@pidgin.im>
parents: 21503
diff changeset
1288 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
1289 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
1290 default:
34935
686fa55b0deb Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents: 34911
diff changeset
1291 purple_xmlnode_set_attrib(iq_node, "type", "none");
21524
472e58992083 Patch from some Intel folks to implement file transfer in Bonjour using XEP-0096 and 0065. This hopefully will work with Gaijm (haven't yet tested) and, of course, between libpurple instances; it will not work with Adium or iChat.
Daniel Atallah <datallah@pidgin.im>
parents: 21503
diff changeset
1292 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
1293 }
472e58992083 Patch from some Intel folks to implement file transfer in Bonjour using XEP-0096 and 0065. This hopefully will work with Gaijm (haven't yet tested) and, of course, between libpurple instances; it will not work with Adium or iChat.
Daniel Atallah <datallah@pidgin.im>
parents: 21503
diff changeset
1294
21548
b19c433f5af2 Cleanup and fix the socks5 proxy connect address to be correct.
Daniel Atallah <datallah@pidgin.im>
parents: 21547
diff changeset
1295 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
1296 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
1297 iq->type = type;
40080
a58c06469198 Rename Jabber to XMPP in Bonjour, as the official name is now XMPP and has been
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 40052
diff changeset
1298 iq->data = ((BonjourData*)data)->xmpp_data;
21524
472e58992083 Patch from some Intel folks to implement file transfer in Bonjour using XEP-0096 and 0065. This hopefully will work with Gaijm (haven't yet tested) and, of course, between libpurple instances; it will not work with Adium or iChat.
Daniel Atallah <datallah@pidgin.im>
parents: 21503
diff changeset
1299 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
1300
21524
472e58992083 Patch from some Intel folks to implement file transfer in Bonjour using XEP-0096 and 0065. This hopefully will work with Gaijm (haven't yet tested) and, of course, between libpurple instances; it will not work with Adium or iChat.
Daniel Atallah <datallah@pidgin.im>
parents: 21503
diff changeset
1301 return 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
1302 }
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
1303
472e58992083 Patch from some Intel folks to implement file transfer in Bonjour using XEP-0096 and 0065. This hopefully will work with Gaijm (haven't yet tested) and, of course, between libpurple instances; it will not work with Adium or iChat.
Daniel Atallah <datallah@pidgin.im>
parents: 21503
diff changeset
1304 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
1305 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
1306 {
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
1307 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
1308 GSList *l = NULL;
25097
c950e59e30bf Further cleanup to fix CID 373.
Daniel Atallah <datallah@pidgin.im>
parents: 25096
diff changeset
1309 PurpleAccount *acc = purple_buddy_get_account(pb);
40052
cc03b5af25ea Use GSList functions instead of manual iterations
qarkai <qarkai@gmail.com>
parents: 39960
diff changeset
1310 const gchar *name;
21524
472e58992083 Patch from some Intel folks to implement file transfer in Bonjour using XEP-0096 and 0065. This hopefully will work with Gaijm (haven't yet tested) and, of course, between libpurple instances; it will not work with Adium or iChat.
Daniel Atallah <datallah@pidgin.im>
parents: 21503
diff changeset
1311
25097
c950e59e30bf Further cleanup to fix CID 373.
Daniel Atallah <datallah@pidgin.im>
parents: 25096
diff changeset
1312 if(acc == NULL)
21524
472e58992083 Patch from some Intel folks to implement file transfer in Bonjour using XEP-0096 and 0065. This hopefully will work with Gaijm (haven't yet tested) and, of course, between libpurple instances; it will not work with Adium or iChat.
Daniel Atallah <datallah@pidgin.im>
parents: 21503
diff changeset
1313 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
1314
40052
cc03b5af25ea Use GSList functions instead of manual iterations
qarkai <qarkai@gmail.com>
parents: 39960
diff changeset
1315 l = purple_account_privacy_get_denied(acc);
cc03b5af25ea Use GSList functions instead of manual iterations
qarkai <qarkai@gmail.com>
parents: 39960
diff changeset
1316 name = purple_buddy_get_name(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
1317
40052
cc03b5af25ea Use GSList functions instead of manual iterations
qarkai <qarkai@gmail.com>
parents: 39960
diff changeset
1318 if(g_slist_find_custom(l, name, (GCompareFunc)purple_utf8_strcasecmp) != NULL) {
30825
87a79bbdc985 The hostname used for a bonjour account should always be the current machine
Daniel Atallah <datallah@pidgin.im>
parents: 30626
diff changeset
1319 const gchar *username = bonjour_get_jid(acc);
24938
fc6952107e1f Finished moving to api for bonjour
Gary Kramlich <grim@reaperworld.com>
parents: 24562
diff changeset
1320
40052
cc03b5af25ea Use GSList functions instead of manual iterations
qarkai <qarkai@gmail.com>
parents: 39960
diff changeset
1321 purple_debug_info("bonjour", "%s has been blocked by %s.\n", name, username);
cc03b5af25ea Use GSList functions instead of manual iterations
qarkai <qarkai@gmail.com>
parents: 39960
diff changeset
1322 blocked = TRUE;
21524
472e58992083 Patch from some Intel folks to implement file transfer in Bonjour using XEP-0096 and 0065. This hopefully will work with Gaijm (haven't yet tested) and, of course, between libpurple instances; it will not work with Adium or iChat.
Daniel Atallah <datallah@pidgin.im>
parents: 21503
diff changeset
1323 }
472e58992083 Patch from some Intel folks to implement file transfer in Bonjour using XEP-0096 and 0065. This hopefully will work with Gaijm (haven't yet tested) and, of course, between libpurple instances; it will not work with Adium or iChat.
Daniel Atallah <datallah@pidgin.im>
parents: 21503
diff changeset
1324 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
1325 }
472e58992083 Patch from some Intel folks to implement file transfer in Bonjour using XEP-0096 and 0065. This hopefully will work with Gaijm (haven't yet tested) and, of course, between libpurple instances; it will not work with Adium or iChat.
Daniel Atallah <datallah@pidgin.im>
parents: 21503
diff changeset
1326
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
1327 static void
34935
686fa55b0deb Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents: 34911
diff changeset
1328 xep_iq_parse(PurpleXmlNode *packet, PurpleBuddy *pb)
21524
472e58992083 Patch from some Intel folks to implement file transfer in Bonjour using XEP-0096 and 0065. This hopefully will work with Gaijm (haven't yet tested) and, of course, between libpurple instances; it will not work with Adium or iChat.
Daniel Atallah <datallah@pidgin.im>
parents: 21503
diff changeset
1329 {
25140
7c494d2bc5e4 propagate from branch 'im.pidgin.pidgin' (head 009f3ea551248605298fbf1b88d7a873b2a6c7a3)
Richard Laager <rlaager@pidgin.im>
parents: 25097 24954
diff changeset
1330 PurpleAccount *account;
7c494d2bc5e4 propagate from branch 'im.pidgin.pidgin' (head 009f3ea551248605298fbf1b88d7a873b2a6c7a3)
Richard Laager <rlaager@pidgin.im>
parents: 25097 24954
diff changeset
1331 PurpleConnection *gc;
21524
472e58992083 Patch from some Intel folks to implement file transfer in Bonjour using XEP-0096 and 0065. This hopefully will work with Gaijm (haven't yet tested) and, of course, between libpurple instances; it will not work with Adium or iChat.
Daniel Atallah <datallah@pidgin.im>
parents: 21503
diff changeset
1332
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
1333 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
1334 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
1335
38213
fe644fbe41c9 Fix some build warnings
dx <dx@dxzone.com.ar>
parents: 36256
diff changeset
1336 account = purple_buddy_get_account(pb);
fe644fbe41c9 Fix some build warnings
dx <dx@dxzone.com.ar>
parents: 36256
diff changeset
1337 gc = purple_account_get_connection(account);
25140
7c494d2bc5e4 propagate from branch 'im.pidgin.pidgin' (head 009f3ea551248605298fbf1b88d7a873b2a6c7a3)
Richard Laager <rlaager@pidgin.im>
parents: 25097 24954
diff changeset
1338
34935
686fa55b0deb Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents: 34911
diff changeset
1339 if (purple_xmlnode_get_child(packet, "si") != NULL || purple_xmlnode_get_child(packet, "error") != NULL)
25140
7c494d2bc5e4 propagate from branch 'im.pidgin.pidgin' (head 009f3ea551248605298fbf1b88d7a873b2a6c7a3)
Richard Laager <rlaager@pidgin.im>
parents: 25097 24954
diff changeset
1340 xep_si_parse(gc, packet, pb);
21524
472e58992083 Patch from some Intel folks to implement file transfer in Bonjour using XEP-0096 and 0065. This hopefully will work with Gaijm (haven't yet tested) and, of course, between libpurple instances; it will not work with Adium or iChat.
Daniel Atallah <datallah@pidgin.im>
parents: 21503
diff changeset
1341 else
25140
7c494d2bc5e4 propagate from branch 'im.pidgin.pidgin' (head 009f3ea551248605298fbf1b88d7a873b2a6c7a3)
Richard Laager <rlaager@pidgin.im>
parents: 25097 24954
diff changeset
1342 xep_bytestreams_parse(gc, packet, pb);
21524
472e58992083 Patch from some Intel folks to implement file transfer in Bonjour using XEP-0096 and 0065. This hopefully will work with Gaijm (haven't yet tested) and, of course, between libpurple instances; it will not work with Adium or iChat.
Daniel Atallah <datallah@pidgin.im>
parents: 21503
diff changeset
1343 }
472e58992083 Patch from some Intel folks to implement file transfer in Bonjour using XEP-0096 and 0065. This hopefully will work with Gaijm (haven't yet tested) and, of course, between libpurple instances; it will not work with Adium or iChat.
Daniel Atallah <datallah@pidgin.im>
parents: 21503
diff changeset
1344
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
1345 int
21548
b19c433f5af2 Cleanup and fix the socks5 proxy connect address to be correct.
Daniel Atallah <datallah@pidgin.im>
parents: 21547
diff changeset
1346 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
1347 {
472e58992083 Patch from some Intel folks to implement file transfer in Bonjour using XEP-0096 and 0065. This hopefully will work with Gaijm (haven't yet tested) and, of course, between libpurple instances; it will not work with Adium or iChat.
Daniel Atallah <datallah@pidgin.im>
parents: 21503
diff changeset
1348 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
1349 PurpleBuddy *pb = NULL;
21528
06532211eb62 Leak fix, cleanup and code reuse.
Daniel Atallah <datallah@pidgin.im>
parents: 21527
diff changeset
1350
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
1351 /* start the talk, reuse the message socket */
40080
a58c06469198 Rename Jabber to XMPP in Bonjour, as the official name is now XMPP and has been
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 40052
diff changeset
1352 pb = _find_or_start_conversation((BonjourXMPP*) 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
1353 /* Send the message */
21528
06532211eb62 Leak fix, cleanup and code reuse.
Daniel Atallah <datallah@pidgin.im>
parents: 21527
diff changeset
1354 if (pb != NULL) {
06532211eb62 Leak fix, cleanup and code reuse.
Daniel Atallah <datallah@pidgin.im>
parents: 21527
diff changeset
1355 /* Convert xml node into stream */
34935
686fa55b0deb Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents: 34911
diff changeset
1356 gchar *msg = purple_xmlnode_to_str(iq->node, NULL);
21524
472e58992083 Patch from some Intel folks to implement file transfer in Bonjour using XEP-0096 and 0065. This hopefully will work with Gaijm (haven't yet tested) and, of course, between libpurple instances; it will not work with Adium or iChat.
Daniel Atallah <datallah@pidgin.im>
parents: 21503
diff changeset
1357 ret = _send_data(pb, msg);
21528
06532211eb62 Leak fix, cleanup and code reuse.
Daniel Atallah <datallah@pidgin.im>
parents: 21527
diff changeset
1358 g_free(msg);
06532211eb62 Leak fix, cleanup and code reuse.
Daniel Atallah <datallah@pidgin.im>
parents: 21527
diff changeset
1359 }
21548
b19c433f5af2 Cleanup and fix the socks5 proxy connect address to be correct.
Daniel Atallah <datallah@pidgin.im>
parents: 21547
diff changeset
1360
34935
686fa55b0deb Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents: 34911
diff changeset
1361 purple_xmlnode_free(iq->node);
21548
b19c433f5af2 Cleanup and fix the socks5 proxy connect address to be correct.
Daniel Atallah <datallah@pidgin.im>
parents: 21547
diff changeset
1362 iq->node = NULL;
b19c433f5af2 Cleanup and fix the socks5 proxy connect address to be correct.
Daniel Atallah <datallah@pidgin.im>
parents: 21547
diff changeset
1363 g_free(iq);
21528
06532211eb62 Leak fix, cleanup and code reuse.
Daniel Atallah <datallah@pidgin.im>
parents: 21527
diff changeset
1364
06532211eb62 Leak fix, cleanup and code reuse.
Daniel Atallah <datallah@pidgin.im>
parents: 21527
diff changeset
1365 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
1366 }
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
1367
32058
95953bd2f239 Append interface ID only to local interfaces for IPv6 Bonjour.
Linus Lüssing <linus.luessing@web.de>
parents: 31749
diff changeset
1368 void
32069
fc06dd6b7c3f Fix the compilation of the Bonjour prpl on Windows.
Eion Robb <eion@robbmob.com>
parents: 32058
diff changeset
1369 append_iface_if_linklocal(char *ip, guint32 interface_param) {
32058
95953bd2f239 Append interface ID only to local interfaces for IPv6 Bonjour.
Linus Lüssing <linus.luessing@web.de>
parents: 31749
diff changeset
1370 struct in6_addr in6_addr;
95953bd2f239 Append interface ID only to local interfaces for IPv6 Bonjour.
Linus Lüssing <linus.luessing@web.de>
parents: 31749
diff changeset
1371 int len_remain = INET6_ADDRSTRLEN - strlen(ip);
95953bd2f239 Append interface ID only to local interfaces for IPv6 Bonjour.
Linus Lüssing <linus.luessing@web.de>
parents: 31749
diff changeset
1372
95953bd2f239 Append interface ID only to local interfaces for IPv6 Bonjour.
Linus Lüssing <linus.luessing@web.de>
parents: 31749
diff changeset
1373 if (len_remain <= 1)
95953bd2f239 Append interface ID only to local interfaces for IPv6 Bonjour.
Linus Lüssing <linus.luessing@web.de>
parents: 31749
diff changeset
1374 return;
95953bd2f239 Append interface ID only to local interfaces for IPv6 Bonjour.
Linus Lüssing <linus.luessing@web.de>
parents: 31749
diff changeset
1375
95953bd2f239 Append interface ID only to local interfaces for IPv6 Bonjour.
Linus Lüssing <linus.luessing@web.de>
parents: 31749
diff changeset
1376 if (inet_pton(AF_INET6, ip, &in6_addr) != 1 ||
95953bd2f239 Append interface ID only to local interfaces for IPv6 Bonjour.
Linus Lüssing <linus.luessing@web.de>
parents: 31749
diff changeset
1377 !IN6_IS_ADDR_LINKLOCAL(&in6_addr))
95953bd2f239 Append interface ID only to local interfaces for IPv6 Bonjour.
Linus Lüssing <linus.luessing@web.de>
parents: 31749
diff changeset
1378 return;
95953bd2f239 Append interface ID only to local interfaces for IPv6 Bonjour.
Linus Lüssing <linus.luessing@web.de>
parents: 31749
diff changeset
1379
40094
8e6d91e4dd8f Use g_(v)snprintf so we need less wrappers.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 40082
diff changeset
1380 g_snprintf(ip + strlen(ip), len_remain, "%%%d", interface_param);
32058
95953bd2f239 Append interface ID only to local interfaces for IPv6 Bonjour.
Linus Lüssing <linus.luessing@web.de>
parents: 31749
diff changeset
1381 }

mercurial