libpurple/protocols/bonjour/jabber.c

Tue, 02 Jul 2019 02:12:08 -0400

author
Elliott Sales de Andrade <qulogic@pidgin.im>
date
Tue, 02 Jul 2019 02:12:08 -0400
changeset 39639
fe7fa102e766
parent 39638
635c8b6ca9a9
child 39656
378ed2b4e242
permissions
-rw-r--r--

Convert Bonjour client side to GIO.

11477
98b4f8643569 [gaim-migrate @ 13719]
Mark Doliner <markdoliner@pidgin.im>
parents:
diff changeset
1 /*
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15873
diff changeset
2 * purple - Bonjour Protocol Plugin
11477
98b4f8643569 [gaim-migrate @ 13719]
Mark Doliner <markdoliner@pidgin.im>
parents:
diff changeset
3 *
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15873
diff changeset
4 * Purple is the legal property of its developers, whose names are too numerous
11477
98b4f8643569 [gaim-migrate @ 13719]
Mark Doliner <markdoliner@pidgin.im>
parents:
diff changeset
5 * to list here. Please refer to the COPYRIGHT file distributed with this
98b4f8643569 [gaim-migrate @ 13719]
Mark Doliner <markdoliner@pidgin.im>
parents:
diff changeset
6 * source distribution.
98b4f8643569 [gaim-migrate @ 13719]
Mark Doliner <markdoliner@pidgin.im>
parents:
diff changeset
7 *
98b4f8643569 [gaim-migrate @ 13719]
Mark Doliner <markdoliner@pidgin.im>
parents:
diff changeset
8 * This program is free software; you can redistribute it and/or modify
98b4f8643569 [gaim-migrate @ 13719]
Mark Doliner <markdoliner@pidgin.im>
parents:
diff changeset
9 * it under the terms of the GNU General Public License as published by
98b4f8643569 [gaim-migrate @ 13719]
Mark Doliner <markdoliner@pidgin.im>
parents:
diff changeset
10 * the Free Software Foundation; either version 2 of the License, or
98b4f8643569 [gaim-migrate @ 13719]
Mark Doliner <markdoliner@pidgin.im>
parents:
diff changeset
11 * (at your option) any later version.
98b4f8643569 [gaim-migrate @ 13719]
Mark Doliner <markdoliner@pidgin.im>
parents:
diff changeset
12 *
98b4f8643569 [gaim-migrate @ 13719]
Mark Doliner <markdoliner@pidgin.im>
parents:
diff changeset
13 * This program is distributed in the hope that it will be useful,
98b4f8643569 [gaim-migrate @ 13719]
Mark Doliner <markdoliner@pidgin.im>
parents:
diff changeset
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
98b4f8643569 [gaim-migrate @ 13719]
Mark Doliner <markdoliner@pidgin.im>
parents:
diff changeset
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
98b4f8643569 [gaim-migrate @ 13719]
Mark Doliner <markdoliner@pidgin.im>
parents:
diff changeset
16 * GNU General Public License for more details.
98b4f8643569 [gaim-migrate @ 13719]
Mark Doliner <markdoliner@pidgin.im>
parents:
diff changeset
17 *
98b4f8643569 [gaim-migrate @ 13719]
Mark Doliner <markdoliner@pidgin.im>
parents:
diff changeset
18 * You should have received a copy of the GNU General Public License
98b4f8643569 [gaim-migrate @ 13719]
Mark Doliner <markdoliner@pidgin.im>
parents:
diff changeset
19 * along with this program; if not, write to the Free Software
19859
71d37b57eff2 The FSF changed its address a while ago; our files were out of date.
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 19832
diff changeset
20 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02111-1301 USA
11477
98b4f8643569 [gaim-migrate @ 13719]
Mark Doliner <markdoliner@pidgin.im>
parents:
diff changeset
21 */
21720
235394d5c7f4 Pull a bunch of bugfix only changes to im.pidgin.pidgin.2.3.1,
Stu Tomlinson <nosnilmot@pidgin.im>
parents: 21638
diff changeset
22
235394d5c7f4 Pull a bunch of bugfix only changes to im.pidgin.pidgin.2.3.1,
Stu Tomlinson <nosnilmot@pidgin.im>
parents: 21638
diff changeset
23 #include "internal.h"
235394d5c7f4 Pull a bunch of bugfix only changes to im.pidgin.pidgin.2.3.1,
Stu Tomlinson <nosnilmot@pidgin.im>
parents: 21638
diff changeset
24
11688
d5a7c35ddc80 [gaim-migrate @ 13974]
Daniel Atallah <datallah@pidgin.im>
parents: 11539
diff changeset
25 #ifndef _WIN32
21524
472e58992083 Patch from some Intel folks to implement file transfer in Bonjour using XEP-0096 and 0065. This hopefully will work with Gaijm (haven't yet tested) and, of course, between libpurple instances; it will not work with Adium or iChat.
Daniel Atallah <datallah@pidgin.im>
parents: 21503
diff changeset
26 #include <net/if.h>
472e58992083 Patch from some Intel folks to implement file transfer in Bonjour using XEP-0096 and 0065. This hopefully will work with Gaijm (haven't yet tested) and, of course, between libpurple instances; it will not work with Adium or iChat.
Daniel Atallah <datallah@pidgin.im>
parents: 21503
diff changeset
27 #include <sys/ioctl.h>
11477
98b4f8643569 [gaim-migrate @ 13719]
Mark Doliner <markdoliner@pidgin.im>
parents:
diff changeset
28 #include <sys/socket.h>
98b4f8643569 [gaim-migrate @ 13719]
Mark Doliner <markdoliner@pidgin.im>
parents:
diff changeset
29 #include <netinet/in.h>
98b4f8643569 [gaim-migrate @ 13719]
Mark Doliner <markdoliner@pidgin.im>
parents:
diff changeset
30 #include <arpa/inet.h>
11688
d5a7c35ddc80 [gaim-migrate @ 13974]
Daniel Atallah <datallah@pidgin.im>
parents: 11539
diff changeset
31 #endif
d5a7c35ddc80 [gaim-migrate @ 13974]
Daniel Atallah <datallah@pidgin.im>
parents: 11539
diff changeset
32 #include <sys/types.h>
21917
7786f5730f36 Fix #4079 for real.
Daniel Atallah <datallah@pidgin.im>
parents: 21913
diff changeset
33
7786f5730f36 Fix #4079 for real.
Daniel Atallah <datallah@pidgin.im>
parents: 21913
diff changeset
34 /* Solaris */
7786f5730f36 Fix #4079 for real.
Daniel Atallah <datallah@pidgin.im>
parents: 21913
diff changeset
35 #if defined (__SVR4) && defined (__sun)
7786f5730f36 Fix #4079 for real.
Daniel Atallah <datallah@pidgin.im>
parents: 21913
diff changeset
36 #include <sys/sockio.h>
7786f5730f36 Fix #4079 for real.
Daniel Atallah <datallah@pidgin.im>
parents: 21913
diff changeset
37 #endif
7786f5730f36 Fix #4079 for real.
Daniel Atallah <datallah@pidgin.im>
parents: 21913
diff changeset
38
11477
98b4f8643569 [gaim-migrate @ 13719]
Mark Doliner <markdoliner@pidgin.im>
parents:
diff changeset
39 #include <glib.h>
23072
6e7c147d622a Bonjour build fixes for MSVC.
Daniel Atallah <datallah@pidgin.im>
parents: 22824
diff changeset
40 #ifdef HAVE_UNISTD_H
11477
98b4f8643569 [gaim-migrate @ 13719]
Mark Doliner <markdoliner@pidgin.im>
parents:
diff changeset
41 #include <unistd.h>
23072
6e7c147d622a Bonjour build fixes for MSVC.
Daniel Atallah <datallah@pidgin.im>
parents: 22824
diff changeset
42 #endif
11477
98b4f8643569 [gaim-migrate @ 13719]
Mark Doliner <markdoliner@pidgin.im>
parents:
diff changeset
43 #include <fcntl.h>
98b4f8643569 [gaim-migrate @ 13719]
Mark Doliner <markdoliner@pidgin.im>
parents:
diff changeset
44
29761
0f6862f2782f Implementation of IPv6 support for Bonjour
Daniel Atallah <datallah@pidgin.im>
parents: 27625
diff changeset
45 #ifdef HAVE_GETIFADDRS
0f6862f2782f Implementation of IPv6 support for Bonjour
Daniel Atallah <datallah@pidgin.im>
parents: 27625
diff changeset
46 #include <ifaddrs.h>
0f6862f2782f Implementation of IPv6 support for Bonjour
Daniel Atallah <datallah@pidgin.im>
parents: 27625
diff changeset
47 #endif
0f6862f2782f Implementation of IPv6 support for Bonjour
Daniel Atallah <datallah@pidgin.im>
parents: 27625
diff changeset
48
39639
fe7fa102e766 Convert Bonjour client side to GIO.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39638
diff changeset
49 #include "buddylist.h"
11477
98b4f8643569 [gaim-migrate @ 13719]
Mark Doliner <markdoliner@pidgin.im>
parents:
diff changeset
50 #include "connection.h"
39639
fe7fa102e766 Convert Bonjour client side to GIO.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39638
diff changeset
51 #include "debug.h"
fe7fa102e766 Convert Bonjour client side to GIO.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39638
diff changeset
52 #include "eventloop.h"
fe7fa102e766 Convert Bonjour client side to GIO.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39638
diff changeset
53 #include "network.h"
fe7fa102e766 Convert Bonjour client side to GIO.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39638
diff changeset
54 #include "notify.h"
fe7fa102e766 Convert Bonjour client side to GIO.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39638
diff changeset
55 #include "purple-gio.h"
fe7fa102e766 Convert Bonjour client side to GIO.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39638
diff changeset
56 #include "util.h"
11477
98b4f8643569 [gaim-migrate @ 13719]
Mark Doliner <markdoliner@pidgin.im>
parents:
diff changeset
57 #include "xmlnode.h"
98b4f8643569 [gaim-migrate @ 13719]
Mark Doliner <markdoliner@pidgin.im>
parents:
diff changeset
58
98b4f8643569 [gaim-migrate @ 13719]
Mark Doliner <markdoliner@pidgin.im>
parents:
diff changeset
59 #include "jabber.h"
19056
05cd9ab28312 Update the Bonjour prpl to use libxml explicitly instead of the xml_node stuff. This allows us to deal with partial reads. I also fixed issues related to starting conversations with iChat and a couple other things. Fixes #2022,#1652
Daniel Atallah <datallah@pidgin.im>
parents: 18947
diff changeset
60 #include "parser.h"
11477
98b4f8643569 [gaim-migrate @ 13719]
Mark Doliner <markdoliner@pidgin.im>
parents:
diff changeset
61 #include "bonjour.h"
98b4f8643569 [gaim-migrate @ 13719]
Mark Doliner <markdoliner@pidgin.im>
parents:
diff changeset
62 #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
63 #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
64
472e58992083 Patch from some Intel folks to implement file transfer in Bonjour using XEP-0096 and 0065. This hopefully will work with Gaijm (haven't yet tested) and, of course, between libpurple instances; it will not work with Adium or iChat.
Daniel Atallah <datallah@pidgin.im>
parents: 21503
diff changeset
65 #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
66 # 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
67 #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
68 # 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
69 #endif
11477
98b4f8643569 [gaim-migrate @ 13719]
Mark Doliner <markdoliner@pidgin.im>
parents:
diff changeset
70
17661
96c6a21c4139 Send 'to' and 'from' attributes in the stream start message.
Daniel Atallah <datallah@pidgin.im>
parents: 17660
diff changeset
71 #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
72 /* 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
73 #define DOCTYPE "<?xml version=\"1.0\" encoding=\"UTF-8\" ?>\n" \
96c6a21c4139 Send 'to' and 'from' attributes in the stream start message.
Daniel Atallah <datallah@pidgin.im>
parents: 17660
diff changeset
74 "<stream:stream xmlns=\"jabber:client\" xmlns:stream=\"http://etherx.jabber.org/streams\" from=\"%s\" to=\"%s\">"
96c6a21c4139 Send 'to' and 'from' attributes in the stream start message.
Daniel Atallah <datallah@pidgin.im>
parents: 17660
diff changeset
75
21727
decfc3a613ff applied changes from b9c97ed0f9ada9069e8bd994b01fdde0b484083c
Daniel Atallah <datallah@pidgin.im>
parents: 21720
diff changeset
76 enum sent_stream_start_types {
decfc3a613ff applied changes from b9c97ed0f9ada9069e8bd994b01fdde0b484083c
Daniel Atallah <datallah@pidgin.im>
parents: 21720
diff changeset
77 NOT_SENT = 0,
decfc3a613ff applied changes from b9c97ed0f9ada9069e8bd994b01fdde0b484083c
Daniel Atallah <datallah@pidgin.im>
parents: 21720
diff changeset
78 PARTIALLY_SENT = 1,
decfc3a613ff applied changes from b9c97ed0f9ada9069e8bd994b01fdde0b484083c
Daniel Atallah <datallah@pidgin.im>
parents: 21720
diff changeset
79 FULLY_SENT = 2
decfc3a613ff applied changes from b9c97ed0f9ada9069e8bd994b01fdde0b484083c
Daniel Atallah <datallah@pidgin.im>
parents: 21720
diff changeset
80 };
decfc3a613ff applied changes from b9c97ed0f9ada9069e8bd994b01fdde0b484083c
Daniel Atallah <datallah@pidgin.im>
parents: 21720
diff changeset
81
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
82 static void
34935
686fa55b0deb Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents: 34911
diff changeset
83 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
84
17662
233ff0515d7b Consolidate BonjourJabberConversation creation and deletion.
Daniel Atallah <datallah@pidgin.im>
parents: 17661
diff changeset
85 static BonjourJabberConversation *
21944
c41d17a1b8d9 This is the second part of the fix to support having multiple presence records in Bonjour (and also supporting multiple presences using the same IP). Incoming conversations are no longer immediately attached to a buddy - we use an algorithm to match a conversation to a buddy based on the IP and, if possible the "from" attribute of the stream or the first tag in the stream. Thanks to Sjoerd Simons from Telepahy Salut for noticing and suggesting the algorithm. Fixes #4187. It'd be good if a few people test this.
Daniel Atallah <datallah@pidgin.im>
parents: 21936
diff changeset
86 bonjour_jabber_conv_new(PurpleBuddy *pb, PurpleAccount *account, const char *ip) {
17662
233ff0515d7b Consolidate BonjourJabberConversation creation and deletion.
Daniel Atallah <datallah@pidgin.im>
parents: 17661
diff changeset
87
233ff0515d7b Consolidate BonjourJabberConversation creation and deletion.
Daniel Atallah <datallah@pidgin.im>
parents: 17661
diff changeset
88 BonjourJabberConversation *bconv = g_new0(BonjourJabberConversation, 1);
39639
fe7fa102e766 Convert Bonjour client side to GIO.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39638
diff changeset
89 bconv->cancellable = g_cancellable_new();
34529
68cf25486001 GObjectify PurpleCircBuffer as PurpleCircularBuffer (from gobjectification branch)
Ankit Vani <a@nevitus.org>
parents: 33892
diff changeset
90 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
91 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
92 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
93 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
94 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
95 bconv->ip = g_strdup(ip);
17662
233ff0515d7b Consolidate BonjourJabberConversation creation and deletion.
Daniel Atallah <datallah@pidgin.im>
parents: 17661
diff changeset
96
21727
decfc3a613ff applied changes from b9c97ed0f9ada9069e8bd994b01fdde0b484083c
Daniel Atallah <datallah@pidgin.im>
parents: 21720
diff changeset
97 bonjour_parser_setup(bconv);
decfc3a613ff applied changes from b9c97ed0f9ada9069e8bd994b01fdde0b484083c
Daniel Atallah <datallah@pidgin.im>
parents: 21720
diff changeset
98
17662
233ff0515d7b Consolidate BonjourJabberConversation creation and deletion.
Daniel Atallah <datallah@pidgin.im>
parents: 17661
diff changeset
99 return bconv;
233ff0515d7b Consolidate BonjourJabberConversation creation and deletion.
Daniel Atallah <datallah@pidgin.im>
parents: 17661
diff changeset
100 }
233ff0515d7b Consolidate BonjourJabberConversation creation and deletion.
Daniel Atallah <datallah@pidgin.im>
parents: 17661
diff changeset
101
12443
ad94864144f8 [gaim-migrate @ 14750]
Stu Tomlinson <nosnilmot@pidgin.im>
parents: 11830
diff changeset
102 static const char *
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15873
diff changeset
103 _font_size_ichat_to_purple(int size)
11477
98b4f8643569 [gaim-migrate @ 13719]
Mark Doliner <markdoliner@pidgin.im>
parents:
diff changeset
104 {
98b4f8643569 [gaim-migrate @ 13719]
Mark Doliner <markdoliner@pidgin.im>
parents:
diff changeset
105 if (size > 24) {
11826
10ebbc41f163 [gaim-migrate @ 14117]
Richard Laager <rlaager@pidgin.im>
parents: 11823
diff changeset
106 return "7";
11539
fbabe3f89777 [gaim-migrate @ 13794]
Mark Doliner <markdoliner@pidgin.im>
parents: 11515
diff changeset
107 } else if (size >= 21) {
11826
10ebbc41f163 [gaim-migrate @ 14117]
Richard Laager <rlaager@pidgin.im>
parents: 11823
diff changeset
108 return "6";
11539
fbabe3f89777 [gaim-migrate @ 13794]
Mark Doliner <markdoliner@pidgin.im>
parents: 11515
diff changeset
109 } else if (size >= 17) {
11826
10ebbc41f163 [gaim-migrate @ 14117]
Richard Laager <rlaager@pidgin.im>
parents: 11823
diff changeset
110 return "5";
11539
fbabe3f89777 [gaim-migrate @ 13794]
Mark Doliner <markdoliner@pidgin.im>
parents: 11515
diff changeset
111 } else if (size >= 14) {
11826
10ebbc41f163 [gaim-migrate @ 14117]
Richard Laager <rlaager@pidgin.im>
parents: 11823
diff changeset
112 return "4";
11539
fbabe3f89777 [gaim-migrate @ 13794]
Mark Doliner <markdoliner@pidgin.im>
parents: 11515
diff changeset
113 } else if (size >= 12) {
11826
10ebbc41f163 [gaim-migrate @ 14117]
Richard Laager <rlaager@pidgin.im>
parents: 11823
diff changeset
114 return "3";
11539
fbabe3f89777 [gaim-migrate @ 13794]
Mark Doliner <markdoliner@pidgin.im>
parents: 11515
diff changeset
115 } else if (size >= 10) {
11826
10ebbc41f163 [gaim-migrate @ 14117]
Richard Laager <rlaager@pidgin.im>
parents: 11823
diff changeset
116 return "2";
11477
98b4f8643569 [gaim-migrate @ 13719]
Mark Doliner <markdoliner@pidgin.im>
parents:
diff changeset
117 }
98b4f8643569 [gaim-migrate @ 13719]
Mark Doliner <markdoliner@pidgin.im>
parents:
diff changeset
118
11826
10ebbc41f163 [gaim-migrate @ 14117]
Richard Laager <rlaager@pidgin.im>
parents: 11823
diff changeset
119 return "1";
11477
98b4f8643569 [gaim-migrate @ 13719]
Mark Doliner <markdoliner@pidgin.im>
parents:
diff changeset
120 }
17633
b76241c02857 Some more Bonjour cleanup and leak fixing.
Daniel Atallah <datallah@pidgin.im>
parents: 17632
diff changeset
121
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
122 static gchar *
34935
686fa55b0deb Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents: 34911
diff changeset
123 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
124 {
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 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
126
34935
686fa55b0deb Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents: 34911
diff changeset
127 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
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 /* 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
130 * 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
131
fba8507310d3 Fix an issue with formatting in Bonjour messages. It looks like it has been
Daniel Atallah <datallah@pidgin.im>
parents: 22622
diff changeset
132 if (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
133 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
134 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
135 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
136 *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
137 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
138 }
fba8507310d3 Fix an issue with formatting in Bonjour messages. It looks like it has been
Daniel Atallah <datallah@pidgin.im>
parents: 22622
diff changeset
139 }
fba8507310d3 Fix an issue with formatting in Bonjour messages. It looks like it has been
Daniel Atallah <datallah@pidgin.im>
parents: 22622
diff changeset
140
fba8507310d3 Fix an issue with formatting in Bonjour messages. It looks like it has been
Daniel Atallah <datallah@pidgin.im>
parents: 22622
diff changeset
141 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
142 }
fba8507310d3 Fix an issue with formatting in Bonjour messages. It looks like it has been
Daniel Atallah <datallah@pidgin.im>
parents: 22622
diff changeset
143
12443
ad94864144f8 [gaim-migrate @ 14750]
Stu Tomlinson <nosnilmot@pidgin.im>
parents: 11830
diff changeset
144 static void
34935
686fa55b0deb Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents: 34911
diff changeset
145 _jabber_parse_and_write_message_to_ui(PurpleXmlNode *message_node, PurpleBuddy *pb)
11477
98b4f8643569 [gaim-migrate @ 13719]
Mark Doliner <markdoliner@pidgin.im>
parents:
diff changeset
146 {
34935
686fa55b0deb Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents: 34911
diff changeset
147 PurpleXmlNode *body_node, *html_node, *events_node;
24562
22ed1e1ef32f More Bonjour struct hiding fixes.
Richard Laager <rlaager@pidgin.im>
parents: 24333
diff changeset
148 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
149 gchar *body = NULL;
11477
98b4f8643569 [gaim-migrate @ 13719]
Mark Doliner <markdoliner@pidgin.im>
parents:
diff changeset
150
34935
686fa55b0deb Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents: 34911
diff changeset
151 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
152 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
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 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
155 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
156 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
157 }
11539
fbabe3f89777 [gaim-migrate @ 13794]
Mark Doliner <markdoliner@pidgin.im>
parents: 11515
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 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
160 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
161 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
162 /* The user is just typing */
79f3a365cffb Cleanup to prevent unnecessary alloc/free. Also a small fix to remove the possiblity that a message will be sent before the stream is started.
Daniel Atallah <datallah@pidgin.im>
parents: 21920
diff changeset
163 /* TODO: Deal with typing notification */
79f3a365cffb Cleanup to prevent unnecessary alloc/free. Also a small fix to remove the possiblity that a message will be sent before the stream is started.
Daniel Atallah <datallah@pidgin.im>
parents: 21920
diff changeset
164 return;
79f3a365cffb Cleanup to prevent unnecessary alloc/free. Also a small fix to remove the possiblity that a message will be sent before the stream is started.
Daniel Atallah <datallah@pidgin.im>
parents: 21920
diff changeset
165 }
79f3a365cffb Cleanup to prevent unnecessary alloc/free. Also a small fix to remove the possiblity that a message will be sent before the stream is started.
Daniel Atallah <datallah@pidgin.im>
parents: 21920
diff changeset
166 }
79f3a365cffb Cleanup to prevent unnecessary alloc/free. Also a small fix to remove the possiblity that a message will be sent before the stream is started.
Daniel Atallah <datallah@pidgin.im>
parents: 21920
diff changeset
167
79f3a365cffb Cleanup to prevent unnecessary alloc/free. Also a small fix to remove the possiblity that a message will be sent before the stream is started.
Daniel Atallah <datallah@pidgin.im>
parents: 21920
diff changeset
168 if (html_node != NULL) {
34935
686fa55b0deb Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents: 34911
diff changeset
169 PurpleXmlNode *html_body_node;
17633
b76241c02857 Some more Bonjour cleanup and leak fixing.
Daniel Atallah <datallah@pidgin.im>
parents: 17632
diff changeset
170
34935
686fa55b0deb Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents: 34911
diff changeset
171 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
172 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
173 PurpleXmlNode *html_body_font_node;
17633
b76241c02857 Some more Bonjour cleanup and leak fixing.
Daniel Atallah <datallah@pidgin.im>
parents: 17632
diff changeset
174
34935
686fa55b0deb Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents: 34911
diff changeset
175 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
176 /* 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
177 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
178 gchar *html_body;
33799
c8a9082d50d1 Apply libpurple3 changes to recently merged code.
Daniel Atallah <datallah@pidgin.im>
parents: 33796
diff changeset
179 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
180 *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
181
34935
686fa55b0deb Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents: 34911
diff changeset
182 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
183 /* 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
184 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
185 if (font_size != NULL)
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15873
diff changeset
186 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
187 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
188 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
189 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
190
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
191 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
192
11539
fbabe3f89777 [gaim-migrate @ 13794]
Mark Doliner <markdoliner@pidgin.im>
parents: 11515
diff changeset
193 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
194 /* 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
195 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
196
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
197 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
198 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
199
24196
864b0ca6577c Don't arbitrarily default font settings when none are specified for incoming
Daniel Atallah <datallah@pidgin.im>
parents: 24039
diff changeset
200 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
201 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
202 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
203 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
204 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
205 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
206 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
207 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
208 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
209 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
210 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
211
864b0ca6577c Don't arbitrarily default font settings when none are specified for incoming
Daniel Atallah <datallah@pidgin.im>
parents: 24039
diff changeset
212 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
213
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 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
215 }
11477
98b4f8643569 [gaim-migrate @ 13719]
Mark Doliner <markdoliner@pidgin.im>
parents:
diff changeset
216 }
98b4f8643569 [gaim-migrate @ 13719]
Mark Doliner <markdoliner@pidgin.im>
parents:
diff changeset
217 }
98b4f8643569 [gaim-migrate @ 13719]
Mark Doliner <markdoliner@pidgin.im>
parents:
diff changeset
218 }
11539
fbabe3f89777 [gaim-migrate @ 13794]
Mark Doliner <markdoliner@pidgin.im>
parents: 11515
diff changeset
219
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
220 /* 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
221 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
222 body = purple_xmlnode_get_data(body_node);
11539
fbabe3f89777 [gaim-migrate @ 13794]
Mark Doliner <markdoliner@pidgin.im>
parents: 11515
diff changeset
223
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
224 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
225 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
226 return;
11477
98b4f8643569 [gaim-migrate @ 13719]
Mark Doliner <markdoliner@pidgin.im>
parents:
diff changeset
227 }
11539
fbabe3f89777 [gaim-migrate @ 13794]
Mark Doliner <markdoliner@pidgin.im>
parents: 11515
diff changeset
228
11826
10ebbc41f163 [gaim-migrate @ 14117]
Richard Laager <rlaager@pidgin.im>
parents: 11823
diff changeset
229 /* Send the message to the UI */
35499
c4c5e0a670b1 Fix namespaces issues in libpurple.
Ankit Vani <a@nevitus.org>
parents: 35378
diff changeset
230 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
231
11477
98b4f8643569 [gaim-migrate @ 13719]
Mark Doliner <markdoliner@pidgin.im>
parents:
diff changeset
232 g_free(body);
98b4f8643569 [gaim-migrate @ 13719]
Mark Doliner <markdoliner@pidgin.im>
parents:
diff changeset
233 }
98b4f8643569 [gaim-migrate @ 13719]
Mark Doliner <markdoliner@pidgin.im>
parents:
diff changeset
234
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
235 struct _match_buddies_by_address_t {
17633
b76241c02857 Some more Bonjour cleanup and leak fixing.
Daniel Atallah <datallah@pidgin.im>
parents: 17632
diff changeset
236 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
237 GSList *matched_buddies;
12708
54098581385f [gaim-migrate @ 15052]
Sean Egan <seanegan@pidgin.im>
parents: 12443
diff changeset
238 };
54098581385f [gaim-migrate @ 15052]
Sean Egan <seanegan@pidgin.im>
parents: 12443
diff changeset
239
54098581385f [gaim-migrate @ 15052]
Sean Egan <seanegan@pidgin.im>
parents: 12443
diff changeset
240 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
241 _match_buddies_by_address(gpointer value, gpointer data)
11477
98b4f8643569 [gaim-migrate @ 13719]
Mark Doliner <markdoliner@pidgin.im>
parents:
diff changeset
242 {
17661
96c6a21c4139 Send 'to' and 'from' attributes in the stream start message.
Daniel Atallah <datallah@pidgin.im>
parents: 17660
diff changeset
243 PurpleBuddy *pb = value;
24938
fc6952107e1f Finished moving to api for bonjour
Gary Kramlich <grim@reaperworld.com>
parents: 24562
diff changeset
244 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
245 struct _match_buddies_by_address_t *mbba = data;
11539
fbabe3f89777 [gaim-migrate @ 13794]
Mark Doliner <markdoliner@pidgin.im>
parents: 11515
diff changeset
246
24938
fc6952107e1f Finished moving to api for bonjour
Gary Kramlich <grim@reaperworld.com>
parents: 24562
diff changeset
247 bb = purple_buddy_get_protocol_data(pb);
fc6952107e1f Finished moving to api for bonjour
Gary Kramlich <grim@reaperworld.com>
parents: 24562
diff changeset
248
13962
71617bf27d00 [gaim-migrate @ 16386]
Jono Cole
parents: 13267
diff changeset
249 /*
26990
385ad4d15ae5 Use more efficient purple_find_buddies in bonjour.
Paul Aurich <darkrain42@pidgin.im>
parents: 26767
diff changeset
250 * 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
251 * whether one of the buddies IPs matches the target IP.
13962
71617bf27d00 [gaim-migrate @ 16386]
Jono Cole
parents: 13267
diff changeset
252 */
26990
385ad4d15ae5 Use more efficient purple_find_buddies in bonjour.
Paul Aurich <darkrain42@pidgin.im>
parents: 26767
diff changeset
253 if (bb != NULL)
13962
71617bf27d00 [gaim-migrate @ 16386]
Jono Cole
parents: 13267
diff changeset
254 {
21944
c41d17a1b8d9 This is the second part of the fix to support having multiple presence records in Bonjour (and also supporting multiple presences using the same IP). Incoming conversations are no longer immediately attached to a buddy - we use an algorithm to match a conversation to a buddy based on the IP and, if possible the "from" attribute of the stream or the first tag in the stream. Thanks to Sjoerd Simons from Telepahy Salut for noticing and suggesting the algorithm. Fixes #4187. It'd be good if a few people test this.
Daniel Atallah <datallah@pidgin.im>
parents: 21936
diff changeset
255 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
256 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
257
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
258 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
259 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
260 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
261 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
262 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
263 }
21944
c41d17a1b8d9 This is the second part of the fix to support having multiple presence records in Bonjour (and also supporting multiple presences using the same IP). Incoming conversations are no longer immediately attached to a buddy - we use an algorithm to match a conversation to a buddy based on the IP and, if possible the "from" attribute of the stream or the first tag in the stream. Thanks to Sjoerd Simons from Telepahy Salut for noticing and suggesting the algorithm. Fixes #4187. It'd be good if a few people test this.
Daniel Atallah <datallah@pidgin.im>
parents: 21936
diff changeset
264 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
265 }
11477
98b4f8643569 [gaim-migrate @ 13719]
Mark Doliner <markdoliner@pidgin.im>
parents:
diff changeset
266 }
98b4f8643569 [gaim-migrate @ 13719]
Mark Doliner <markdoliner@pidgin.im>
parents:
diff changeset
267 }
98b4f8643569 [gaim-migrate @ 13719]
Mark Doliner <markdoliner@pidgin.im>
parents:
diff changeset
268
17665
26bff2090889 Update Bonjour to do nonblocking I/O correctly.
Daniel Atallah <datallah@pidgin.im>
parents: 17663
diff changeset
269 static void
39639
fe7fa102e766 Convert Bonjour client side to GIO.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39638
diff changeset
270 _send_data_write_cb(GObject *stream, gpointer data)
11477
98b4f8643569 [gaim-migrate @ 13719]
Mark Doliner <markdoliner@pidgin.im>
parents:
diff changeset
271 {
17665
26bff2090889 Update Bonjour to do nonblocking I/O correctly.
Daniel Atallah <datallah@pidgin.im>
parents: 17663
diff changeset
272 PurpleBuddy *pb = data;
24938
fc6952107e1f Finished moving to api for bonjour
Gary Kramlich <grim@reaperworld.com>
parents: 24562
diff changeset
273 BonjourBuddy *bb = purple_buddy_get_protocol_data(pb);
17665
26bff2090889 Update Bonjour to do nonblocking I/O correctly.
Daniel Atallah <datallah@pidgin.im>
parents: 17663
diff changeset
274 BonjourJabberConversation *bconv = bb->conversation;
39639
fe7fa102e766 Convert Bonjour client side to GIO.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39638
diff changeset
275 gsize writelen;
fe7fa102e766 Convert Bonjour client side to GIO.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39638
diff changeset
276 gssize ret;
fe7fa102e766 Convert Bonjour client side to GIO.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39638
diff changeset
277 GError *error = NULL;
17665
26bff2090889 Update Bonjour to do nonblocking I/O correctly.
Daniel Atallah <datallah@pidgin.im>
parents: 17663
diff changeset
278
34529
68cf25486001 GObjectify PurpleCircBuffer as PurpleCircularBuffer (from gobjectification branch)
Ankit Vani <a@nevitus.org>
parents: 33892
diff changeset
279 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
280
26bff2090889 Update Bonjour to do nonblocking I/O correctly.
Daniel Atallah <datallah@pidgin.im>
parents: 17663
diff changeset
281 if (writelen == 0) {
39639
fe7fa102e766 Convert Bonjour client side to GIO.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39638
diff changeset
282 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
283 bconv->tx_handler = 0;
17665
26bff2090889 Update Bonjour to do nonblocking I/O correctly.
Daniel Atallah <datallah@pidgin.im>
parents: 17663
diff changeset
284 return;
26bff2090889 Update Bonjour to do nonblocking I/O correctly.
Daniel Atallah <datallah@pidgin.im>
parents: 17663
diff changeset
285 }
11539
fbabe3f89777 [gaim-migrate @ 13794]
Mark Doliner <markdoliner@pidgin.im>
parents: 11515
diff changeset
286
39639
fe7fa102e766 Convert Bonjour client side to GIO.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39638
diff changeset
287 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
288 G_POLLABLE_OUTPUT_STREAM(stream),
fe7fa102e766 Convert Bonjour client side to GIO.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39638
diff changeset
289 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
290 bconv->cancellable, &error);
17665
26bff2090889 Update Bonjour to do nonblocking I/O correctly.
Daniel Atallah <datallah@pidgin.im>
parents: 17663
diff changeset
291
39639
fe7fa102e766 Convert Bonjour client side to GIO.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39638
diff changeset
292 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
293 g_clear_error(&error);
17665
26bff2090889 Update Bonjour to do nonblocking I/O correctly.
Daniel Atallah <datallah@pidgin.im>
parents: 17663
diff changeset
294 return;
39639
fe7fa102e766 Convert Bonjour client side to GIO.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39638
diff changeset
295 } else if (ret <= 0) {
24938
fc6952107e1f Finished moving to api for bonjour
Gary Kramlich <grim@reaperworld.com>
parents: 24562
diff changeset
296 PurpleConversation *conv = NULL;
fc6952107e1f Finished moving to api for bonjour
Gary Kramlich <grim@reaperworld.com>
parents: 24562
diff changeset
297 PurpleAccount *account = NULL;
17665
26bff2090889 Update Bonjour to do nonblocking I/O correctly.
Daniel Atallah <datallah@pidgin.im>
parents: 17663
diff changeset
298
39639
fe7fa102e766 Convert Bonjour client side to GIO.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39638
diff changeset
299 purple_debug_error(
fe7fa102e766 Convert Bonjour client side to GIO.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39638
diff changeset
300 "bonjour",
fe7fa102e766 Convert Bonjour client side to GIO.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39638
diff changeset
301 "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
302 purple_buddy_get_name(pb),
fe7fa102e766 Convert Bonjour client side to GIO.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39638
diff changeset
303 error ? error->message : "(null)");
17665
26bff2090889 Update Bonjour to do nonblocking I/O correctly.
Daniel Atallah <datallah@pidgin.im>
parents: 17663
diff changeset
304
24938
fc6952107e1f Finished moving to api for bonjour
Gary Kramlich <grim@reaperworld.com>
parents: 24562
diff changeset
305 account = purple_buddy_get_account(pb);
fc6952107e1f Finished moving to api for bonjour
Gary Kramlich <grim@reaperworld.com>
parents: 24562
diff changeset
306
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
307 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
308 if (conv != NULL)
36089
c035b9a63457 Use purple_conversation_write_system_message where appropriate
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 36073
diff changeset
309 purple_conversation_write_system_message(conv,
c035b9a63457 Use purple_conversation_write_system_message where appropriate
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 36073
diff changeset
310 _("Unable to send message."),
c035b9a63457 Use purple_conversation_write_system_message where appropriate
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 36073
diff changeset
311 PURPLE_MESSAGE_ERROR);
17665
26bff2090889 Update Bonjour to do nonblocking I/O correctly.
Daniel Atallah <datallah@pidgin.im>
parents: 17663
diff changeset
312
26bff2090889 Update Bonjour to do nonblocking I/O correctly.
Daniel Atallah <datallah@pidgin.im>
parents: 17663
diff changeset
313 bonjour_jabber_close_conversation(bb->conversation);
26bff2090889 Update Bonjour to do nonblocking I/O correctly.
Daniel Atallah <datallah@pidgin.im>
parents: 17663
diff changeset
314 bb->conversation = NULL;
39639
fe7fa102e766 Convert Bonjour client side to GIO.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39638
diff changeset
315 g_clear_error(&error);
17665
26bff2090889 Update Bonjour to do nonblocking I/O correctly.
Daniel Atallah <datallah@pidgin.im>
parents: 17663
diff changeset
316 return;
11477
98b4f8643569 [gaim-migrate @ 13719]
Mark Doliner <markdoliner@pidgin.im>
parents:
diff changeset
317 }
11539
fbabe3f89777 [gaim-migrate @ 13794]
Mark Doliner <markdoliner@pidgin.im>
parents: 11515
diff changeset
318
34529
68cf25486001 GObjectify PurpleCircBuffer as PurpleCircularBuffer (from gobjectification branch)
Ankit Vani <a@nevitus.org>
parents: 33892
diff changeset
319 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
320 }
26bff2090889 Update Bonjour to do nonblocking I/O correctly.
Daniel Atallah <datallah@pidgin.im>
parents: 17663
diff changeset
321
26bff2090889 Update Bonjour to do nonblocking I/O correctly.
Daniel Atallah <datallah@pidgin.im>
parents: 17663
diff changeset
322 static gint
26bff2090889 Update Bonjour to do nonblocking I/O correctly.
Daniel Atallah <datallah@pidgin.im>
parents: 17663
diff changeset
323 _send_data(PurpleBuddy *pb, char *message)
26bff2090889 Update Bonjour to do nonblocking I/O correctly.
Daniel Atallah <datallah@pidgin.im>
parents: 17663
diff changeset
324 {
24938
fc6952107e1f Finished moving to api for bonjour
Gary Kramlich <grim@reaperworld.com>
parents: 24562
diff changeset
325 BonjourBuddy *bb = purple_buddy_get_protocol_data(pb);
17665
26bff2090889 Update Bonjour to do nonblocking I/O correctly.
Daniel Atallah <datallah@pidgin.im>
parents: 17663
diff changeset
326 BonjourJabberConversation *bconv = bb->conversation;
39639
fe7fa102e766 Convert Bonjour client side to GIO.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39638
diff changeset
327 gsize len = strlen(message);
fe7fa102e766 Convert Bonjour client side to GIO.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39638
diff changeset
328 gssize ret;
fe7fa102e766 Convert Bonjour client side to GIO.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39638
diff changeset
329 GError *error = NULL;
17665
26bff2090889 Update Bonjour to do nonblocking I/O correctly.
Daniel Atallah <datallah@pidgin.im>
parents: 17663
diff changeset
330
26bff2090889 Update Bonjour to do nonblocking I/O correctly.
Daniel Atallah <datallah@pidgin.im>
parents: 17663
diff changeset
331 /* 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
332 if (bconv->tx_handler != 0
17665
26bff2090889 Update Bonjour to do nonblocking I/O correctly.
Daniel Atallah <datallah@pidgin.im>
parents: 17663
diff changeset
333 || bconv->connect_data != NULL
21727
decfc3a613ff applied changes from b9c97ed0f9ada9069e8bd994b01fdde0b484083c
Daniel Atallah <datallah@pidgin.im>
parents: 21720
diff changeset
334 || 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
335 || !bconv->recv_stream_start
34529
68cf25486001 GObjectify PurpleCircBuffer as PurpleCircularBuffer (from gobjectification branch)
Ankit Vani <a@nevitus.org>
parents: 33892
diff changeset
336 || 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
337 ret = -1;
39639
fe7fa102e766 Convert Bonjour client side to GIO.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39638
diff changeset
338 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
339 "Not yet ready to send.");
17665
26bff2090889 Update Bonjour to do nonblocking I/O correctly.
Daniel Atallah <datallah@pidgin.im>
parents: 17663
diff changeset
340 } else {
39639
fe7fa102e766 Convert Bonjour client side to GIO.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39638
diff changeset
341 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
342 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
343 bconv->cancellable, &error);
17665
26bff2090889 Update Bonjour to do nonblocking I/O correctly.
Daniel Atallah <datallah@pidgin.im>
parents: 17663
diff changeset
344 }
26bff2090889 Update Bonjour to do nonblocking I/O correctly.
Daniel Atallah <datallah@pidgin.im>
parents: 17663
diff changeset
345
39639
fe7fa102e766 Convert Bonjour client side to GIO.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39638
diff changeset
346 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
347 ret = 0;
39639
fe7fa102e766 Convert Bonjour client side to GIO.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39638
diff changeset
348 g_clear_error(&error);
fe7fa102e766 Convert Bonjour client side to GIO.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39638
diff changeset
349 } else if (ret <= 0) {
17665
26bff2090889 Update Bonjour to do nonblocking I/O correctly.
Daniel Atallah <datallah@pidgin.im>
parents: 17663
diff changeset
350 PurpleConversation *conv;
25140
7c494d2bc5e4 propagate from branch 'im.pidgin.pidgin' (head 009f3ea551248605298fbf1b88d7a873b2a6c7a3)
Richard Laager <rlaager@pidgin.im>
parents: 25097 24954
diff changeset
351 PurpleAccount *account;
17665
26bff2090889 Update Bonjour to do nonblocking I/O correctly.
Daniel Atallah <datallah@pidgin.im>
parents: 17663
diff changeset
352
39639
fe7fa102e766 Convert Bonjour client side to GIO.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39638
diff changeset
353 purple_debug_error(
fe7fa102e766 Convert Bonjour client side to GIO.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39638
diff changeset
354 "bonjour",
fe7fa102e766 Convert Bonjour client side to GIO.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39638
diff changeset
355 "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
356 purple_buddy_get_name(pb),
fe7fa102e766 Convert Bonjour client side to GIO.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39638
diff changeset
357 error ? error->message : "(null)");
17665
26bff2090889 Update Bonjour to do nonblocking I/O correctly.
Daniel Atallah <datallah@pidgin.im>
parents: 17663
diff changeset
358
24938
fc6952107e1f Finished moving to api for bonjour
Gary Kramlich <grim@reaperworld.com>
parents: 24562
diff changeset
359 account = purple_buddy_get_account(pb);
fc6952107e1f Finished moving to api for bonjour
Gary Kramlich <grim@reaperworld.com>
parents: 24562
diff changeset
360
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
361 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
362 if (conv != NULL)
36089
c035b9a63457 Use purple_conversation_write_system_message where appropriate
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 36073
diff changeset
363 purple_conversation_write_system_message(conv,
c035b9a63457 Use purple_conversation_write_system_message where appropriate
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 36073
diff changeset
364 _("Unable to send message."),
c035b9a63457 Use purple_conversation_write_system_message where appropriate
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 36073
diff changeset
365 PURPLE_MESSAGE_ERROR);
17665
26bff2090889 Update Bonjour to do nonblocking I/O correctly.
Daniel Atallah <datallah@pidgin.im>
parents: 17663
diff changeset
366
26bff2090889 Update Bonjour to do nonblocking I/O correctly.
Daniel Atallah <datallah@pidgin.im>
parents: 17663
diff changeset
367 bonjour_jabber_close_conversation(bb->conversation);
26bff2090889 Update Bonjour to do nonblocking I/O correctly.
Daniel Atallah <datallah@pidgin.im>
parents: 17663
diff changeset
368 bb->conversation = NULL;
39639
fe7fa102e766 Convert Bonjour client side to GIO.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39638
diff changeset
369 g_clear_error(&error);
17665
26bff2090889 Update Bonjour to do nonblocking I/O correctly.
Daniel Atallah <datallah@pidgin.im>
parents: 17663
diff changeset
370 return -1;
26bff2090889 Update Bonjour to do nonblocking I/O correctly.
Daniel Atallah <datallah@pidgin.im>
parents: 17663
diff changeset
371 }
26bff2090889 Update Bonjour to do nonblocking I/O correctly.
Daniel Atallah <datallah@pidgin.im>
parents: 17663
diff changeset
372
26bff2090889 Update Bonjour to do nonblocking I/O correctly.
Daniel Atallah <datallah@pidgin.im>
parents: 17663
diff changeset
373 if (ret < len) {
21727
decfc3a613ff applied changes from b9c97ed0f9ada9069e8bd994b01fdde0b484083c
Daniel Atallah <datallah@pidgin.im>
parents: 21720
diff changeset
374 /* 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
375 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
376 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
377 GSource *source =
fe7fa102e766 Convert Bonjour client side to GIO.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39638
diff changeset
378 g_pollable_output_stream_create_source(
fe7fa102e766 Convert Bonjour client side to GIO.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39638
diff changeset
379 G_POLLABLE_OUTPUT_STREAM(bconv->output),
fe7fa102e766 Convert Bonjour client side to GIO.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39638
diff changeset
380 bconv->cancellable);
fe7fa102e766 Convert Bonjour client side to GIO.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39638
diff changeset
381 g_source_set_callback(source,
fe7fa102e766 Convert Bonjour client side to GIO.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39638
diff changeset
382 (GSourceFunc)_send_data_write_cb,
fe7fa102e766 Convert Bonjour client side to GIO.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39638
diff changeset
383 pb, NULL);
fe7fa102e766 Convert Bonjour client side to GIO.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39638
diff changeset
384 bconv->tx_handler = g_source_attach(source, NULL);
fe7fa102e766 Convert Bonjour client side to GIO.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39638
diff changeset
385 }
34529
68cf25486001 GObjectify PurpleCircBuffer as PurpleCircularBuffer (from gobjectification branch)
Ankit Vani <a@nevitus.org>
parents: 33892
diff changeset
386 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
387 }
26bff2090889 Update Bonjour to do nonblocking I/O correctly.
Daniel Atallah <datallah@pidgin.im>
parents: 17663
diff changeset
388
26bff2090889 Update Bonjour to do nonblocking I/O correctly.
Daniel Atallah <datallah@pidgin.im>
parents: 17663
diff changeset
389 return ret;
11477
98b4f8643569 [gaim-migrate @ 13719]
Mark Doliner <markdoliner@pidgin.im>
parents:
diff changeset
390 }
98b4f8643569 [gaim-migrate @ 13719]
Mark Doliner <markdoliner@pidgin.im>
parents:
diff changeset
391
34935
686fa55b0deb Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents: 34911
diff changeset
392 void bonjour_jabber_process_packet(PurpleBuddy *pb, PurpleXmlNode *packet) {
21612
9fce536735e3 Various bugfixes including using purple_account_remove_buddy() in addition to purple_blist_remove_buddy() to make sure that the buddy gets cleaned up fully when logging out or we go offline.
Daniel Atallah <datallah@pidgin.im>
parents: 21609
diff changeset
393
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
394 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
395 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
396
38257
1a294a6d2a57 Replace g_strcmp0() with purple_strequal()
qarkai <qarkai@gmail.com>
parents: 38213
diff changeset
397 if (purple_strequal(packet->name, "message"))
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
398 _jabber_parse_and_write_message_to_ui(packet, pb);
38257
1a294a6d2a57 Replace g_strcmp0() with purple_strequal()
qarkai <qarkai@gmail.com>
parents: 38213
diff changeset
399 else if (purple_strequal(packet->name, "iq"))
25097
c950e59e30bf Further cleanup to fix CID 373.
Daniel Atallah <datallah@pidgin.im>
parents: 25096
diff changeset
400 xep_iq_parse(packet, pb);
35997
23e05a4a90b3 Silence some already dismissed coverity warnings
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35991
diff changeset
401 else {
23e05a4a90b3 Silence some already dismissed coverity warnings
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35991
diff changeset
402 purple_debug_warning("bonjour", "Unknown packet: %s\n",
23e05a4a90b3 Silence some already dismissed coverity warnings
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35991
diff changeset
403 packet->name ? packet->name : "(null)");
23e05a4a90b3 Silence some already dismissed coverity warnings
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35991
diff changeset
404 }
19056
05cd9ab28312 Update the Bonjour prpl to use libxml explicitly instead of the xml_node stuff. This allows us to deal with partial reads. I also fixed issues related to starting conversations with iChat and a couple other things. Fixes #2022,#1652
Daniel Atallah <datallah@pidgin.im>
parents: 18947
diff changeset
405 }
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
406
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
407 static void bonjour_jabber_stream_ended(BonjourJabberConversation *bconv) {
0e356664879d Clean up some stuff that the behavior has changed on to fix CID 398.
Daniel Atallah <datallah@pidgin.im>
parents: 24562
diff changeset
408
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 /* 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
410 BonjourBuddy *bb = NULL;
25870
ccb76c75d39f a few struct hiding clean ups
Gary Kramlich <grim@reaperworld.com>
parents: 25150
diff changeset
411 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
412
30270
8380aae8b132 I before E, except after C
Stu Tomlinson <nosnilmot@pidgin.im>
parents: 30249
diff changeset
413 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
414
0e356664879d Clean up some stuff that the behavior has changed on to fix CID 398.
Daniel Atallah <datallah@pidgin.im>
parents: 24562
diff changeset
415 if(bconv->pb != NULL)
25150
b0e1b122d83a merge of 'c93933e47474a5522b300e0ac9f8aa777205e964'
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 25141 25119
diff changeset
416 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
417
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
418 /* Close the socket, clear the watcher and free memory */
0e356664879d Clean up some stuff that the behavior has changed on to fix CID 398.
Daniel Atallah <datallah@pidgin.im>
parents: 24562
diff changeset
419 bonjour_jabber_close_conversation(bconv);
0e356664879d Clean up some stuff that the behavior has changed on to fix CID 398.
Daniel Atallah <datallah@pidgin.im>
parents: 24562
diff changeset
420 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
421 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
422 }
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
423
39639
fe7fa102e766 Convert Bonjour client side to GIO.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39638
diff changeset
424 static gboolean
fe7fa102e766 Convert Bonjour client side to GIO.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39638
diff changeset
425 _client_socket_handler(GObject *stream, gpointer data)
11477
98b4f8643569 [gaim-migrate @ 13719]
Mark Doliner <markdoliner@pidgin.im>
parents:
diff changeset
426 {
21944
c41d17a1b8d9 This is the second part of the fix to support having multiple presence records in Bonjour (and also supporting multiple presences using the same IP). Incoming conversations are no longer immediately attached to a buddy - we use an algorithm to match a conversation to a buddy based on the IP and, if possible the "from" attribute of the stream or the first tag in the stream. Thanks to Sjoerd Simons from Telepahy Salut for noticing and suggesting the algorithm. Fixes #4187. It'd be good if a few people test this.
Daniel Atallah <datallah@pidgin.im>
parents: 21936
diff changeset
427 BonjourJabberConversation *bconv = data;
39639
fe7fa102e766 Convert Bonjour client side to GIO.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39638
diff changeset
428 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
429 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
430 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
431
11826
10ebbc41f163 [gaim-migrate @ 14117]
Richard Laager <rlaager@pidgin.im>
parents: 11823
diff changeset
432 /* 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
433 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
434 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
435 bconv->cancellable, &error);
fe7fa102e766 Convert Bonjour client side to GIO.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39638
diff changeset
436 if (len == -1) {
fe7fa102e766 Convert Bonjour client side to GIO.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39638
diff changeset
437 /* 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
438 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
439 error->code != G_IO_ERROR_CANCELLED)) {
fe7fa102e766 Convert Bonjour client side to GIO.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39638
diff changeset
440 purple_debug_warning(
fe7fa102e766 Convert Bonjour client side to GIO.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39638
diff changeset
441 "bonjour",
fe7fa102e766 Convert Bonjour client side to GIO.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39638
diff changeset
442 "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
443 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
444
21944
c41d17a1b8d9 This is the second part of the fix to support having multiple presence records in Bonjour (and also supporting multiple presences using the same IP). Incoming conversations are no longer immediately attached to a buddy - we use an algorithm to match a conversation to a buddy based on the IP and, if possible the "from" attribute of the stream or the first tag in the stream. Thanks to Sjoerd Simons from Telepahy Salut for noticing and suggesting the algorithm. Fixes #4187. It'd be good if a few people test this.
Daniel Atallah <datallah@pidgin.im>
parents: 21936
diff changeset
445 bonjour_jabber_close_conversation(bconv);
24938
fc6952107e1f Finished moving to api for bonjour
Gary Kramlich <grim@reaperworld.com>
parents: 24562
diff changeset
446 if (bconv->pb != NULL) {
fc6952107e1f Finished moving to api for bonjour
Gary Kramlich <grim@reaperworld.com>
parents: 24562
diff changeset
447 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
448
24938
fc6952107e1f Finished moving to api for bonjour
Gary Kramlich <grim@reaperworld.com>
parents: 24562
diff changeset
449 if(bb != NULL)
fc6952107e1f Finished moving to api for bonjour
Gary Kramlich <grim@reaperworld.com>
parents: 24562
diff changeset
450 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
451 }
17665
26bff2090889 Update Bonjour to do nonblocking I/O correctly.
Daniel Atallah <datallah@pidgin.im>
parents: 17663
diff changeset
452
26bff2090889 Update Bonjour to do nonblocking I/O correctly.
Daniel Atallah <datallah@pidgin.im>
parents: 17663
diff changeset
453 /* 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
454 * 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
455 }
39639
fe7fa102e766 Convert Bonjour client side to GIO.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39638
diff changeset
456 g_clear_error(&error);
fe7fa102e766 Convert Bonjour client side to GIO.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39638
diff changeset
457 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
458 } 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
459 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
460 purple_debug_warning("bonjour", "Connection closed (without stream end) by %s.\n", (name) ? name : "(unknown)");
21944
c41d17a1b8d9 This is the second part of the fix to support having multiple presence records in Bonjour (and also supporting multiple presences using the same IP). Incoming conversations are no longer immediately attached to a buddy - we use an algorithm to match a conversation to a buddy based on the IP and, if possible the "from" attribute of the stream or the first tag in the stream. Thanks to Sjoerd Simons from Telepahy Salut for noticing and suggesting the algorithm. Fixes #4187. It'd be good if a few people test this.
Daniel Atallah <datallah@pidgin.im>
parents: 21936
diff changeset
461 bonjour_jabber_stream_ended(bconv);
39639
fe7fa102e766 Convert Bonjour client side to GIO.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39638
diff changeset
462 return FALSE;
11477
98b4f8643569 [gaim-migrate @ 13719]
Mark Doliner <markdoliner@pidgin.im>
parents:
diff changeset
463 }
11539
fbabe3f89777 [gaim-migrate @ 13794]
Mark Doliner <markdoliner@pidgin.im>
parents: 11515
diff changeset
464
33783
8b37d3593783 bonjour: Similify code and get rid of some unnecessary control character removal
Daniel Atallah <datallah@pidgin.im>
parents: 33782
diff changeset
465 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
466
33783
8b37d3593783 bonjour: Similify code and get rid of some unnecessary control character removal
Daniel Atallah <datallah@pidgin.im>
parents: 33782
diff changeset
467 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
468 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
469
fe7fa102e766 Convert Bonjour client side to GIO.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39638
diff changeset
470 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
471 }
17633
b76241c02857 Some more Bonjour cleanup and leak fixing.
Daniel Atallah <datallah@pidgin.im>
parents: 17632
diff changeset
472
17665
26bff2090889 Update Bonjour to do nonblocking I/O correctly.
Daniel Atallah <datallah@pidgin.im>
parents: 17663
diff changeset
473 struct _stream_start_data {
26bff2090889 Update Bonjour to do nonblocking I/O correctly.
Daniel Atallah <datallah@pidgin.im>
parents: 17663
diff changeset
474 char *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
26bff2090889 Update Bonjour to do nonblocking I/O correctly.
Daniel Atallah <datallah@pidgin.im>
parents: 17663
diff changeset
477 static void
39639
fe7fa102e766 Convert Bonjour client side to GIO.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39638
diff changeset
478 _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
479 {
21944
c41d17a1b8d9 This is the second part of the fix to support having multiple presence records in Bonjour (and also supporting multiple presences using the same IP). Incoming conversations are no longer immediately attached to a buddy - we use an algorithm to match a conversation to a buddy based on the IP and, if possible the "from" attribute of the stream or the first tag in the stream. Thanks to Sjoerd Simons from Telepahy Salut for noticing and suggesting the algorithm. Fixes #4187. It'd be good if a few people test this.
Daniel Atallah <datallah@pidgin.im>
parents: 21936
diff changeset
480 BonjourJabberConversation *bconv = data;
19056
05cd9ab28312 Update the Bonjour prpl to use libxml explicitly instead of the xml_node stuff. This allows us to deal with partial reads. I also fixed issues related to starting conversations with iChat and a couple other things. Fixes #2022,#1652
Daniel Atallah <datallah@pidgin.im>
parents: 18947
diff changeset
481 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
482 GError *error = NULL;
fe7fa102e766 Convert Bonjour client side to GIO.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39638
diff changeset
483 gsize len;
fe7fa102e766 Convert Bonjour client side to GIO.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39638
diff changeset
484 gssize ret;
17665
26bff2090889 Update Bonjour to do nonblocking I/O correctly.
Daniel Atallah <datallah@pidgin.im>
parents: 17663
diff changeset
485
26bff2090889 Update Bonjour to do nonblocking I/O correctly.
Daniel Atallah <datallah@pidgin.im>
parents: 17663
diff changeset
486 len = strlen(ss->msg);
26bff2090889 Update Bonjour to do nonblocking I/O correctly.
Daniel Atallah <datallah@pidgin.im>
parents: 17663
diff changeset
487
26bff2090889 Update Bonjour to do nonblocking I/O correctly.
Daniel Atallah <datallah@pidgin.im>
parents: 17663
diff changeset
488 /* Start Stream */
39639
fe7fa102e766 Convert Bonjour client side to GIO.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39638
diff changeset
489 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
490 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
491 bconv->cancellable, &error);
17665
26bff2090889 Update Bonjour to do nonblocking I/O correctly.
Daniel Atallah <datallah@pidgin.im>
parents: 17663
diff changeset
492
39639
fe7fa102e766 Convert Bonjour client side to GIO.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39638
diff changeset
493 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
494 g_clear_error(&error);
17665
26bff2090889 Update Bonjour to do nonblocking I/O correctly.
Daniel Atallah <datallah@pidgin.im>
parents: 17663
diff changeset
495 return;
39639
fe7fa102e766 Convert Bonjour client side to GIO.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39638
diff changeset
496 } else if (ret <= 0) {
17665
26bff2090889 Update Bonjour to do nonblocking I/O correctly.
Daniel Atallah <datallah@pidgin.im>
parents: 17663
diff changeset
497 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
498 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
499 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
500
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
501 if(bconv->pb) {
24938
fc6952107e1f Finished moving to api for bonjour
Gary Kramlich <grim@reaperworld.com>
parents: 24562
diff changeset
502 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
503 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
504 }
17665
26bff2090889 Update Bonjour to do nonblocking I/O correctly.
Daniel Atallah <datallah@pidgin.im>
parents: 17663
diff changeset
505
39639
fe7fa102e766 Convert Bonjour client side to GIO.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39638
diff changeset
506 purple_debug_error(
fe7fa102e766 Convert Bonjour client side to GIO.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39638
diff changeset
507 "bonjour",
fe7fa102e766 Convert Bonjour client side to GIO.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39638
diff changeset
508 "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
509 bname ? bname : "(unknown)", bconv->ip,
fe7fa102e766 Convert Bonjour client side to GIO.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39638
diff changeset
510 error ? error->message : "(null)");
17665
26bff2090889 Update Bonjour to do nonblocking I/O correctly.
Daniel Atallah <datallah@pidgin.im>
parents: 17663
diff changeset
511
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
512 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
513 if (conv != NULL)
36089
c035b9a63457 Use purple_conversation_write_system_message where appropriate
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 36073
diff changeset
514 purple_conversation_write_system_message(conv,
c035b9a63457 Use purple_conversation_write_system_message where appropriate
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 36073
diff changeset
515 _("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
516 PURPLE_MESSAGE_ERROR);
17665
26bff2090889 Update Bonjour to do nonblocking I/O correctly.
Daniel Atallah <datallah@pidgin.im>
parents: 17663
diff changeset
517
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
518 bonjour_jabber_close_conversation(bconv);
21944
c41d17a1b8d9 This is the second part of the fix to support having multiple presence records in Bonjour (and also supporting multiple presences using the same IP). Incoming conversations are no longer immediately attached to a buddy - we use an algorithm to match a conversation to a buddy based on the IP and, if possible the "from" attribute of the stream or the first tag in the stream. Thanks to Sjoerd Simons from Telepahy Salut for noticing and suggesting the algorithm. Fixes #4187. It'd be good if a few people test this.
Daniel Atallah <datallah@pidgin.im>
parents: 21936
diff changeset
519 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
520 bb->conversation = NULL;
17665
26bff2090889 Update Bonjour to do nonblocking I/O correctly.
Daniel Atallah <datallah@pidgin.im>
parents: 17663
diff changeset
521
39639
fe7fa102e766 Convert Bonjour client side to GIO.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39638
diff changeset
522 g_clear_error(&error);
17665
26bff2090889 Update Bonjour to do nonblocking I/O correctly.
Daniel Atallah <datallah@pidgin.im>
parents: 17663
diff changeset
523 return;
26bff2090889 Update Bonjour to do nonblocking I/O correctly.
Daniel Atallah <datallah@pidgin.im>
parents: 17663
diff changeset
524 }
26bff2090889 Update Bonjour to do nonblocking I/O correctly.
Daniel Atallah <datallah@pidgin.im>
parents: 17663
diff changeset
525
26bff2090889 Update Bonjour to do nonblocking I/O correctly.
Daniel Atallah <datallah@pidgin.im>
parents: 17663
diff changeset
526 /* This is EXTREMELY unlikely to happen */
26bff2090889 Update Bonjour to do nonblocking I/O correctly.
Daniel Atallah <datallah@pidgin.im>
parents: 17663
diff changeset
527 if (ret < len) {
26bff2090889 Update Bonjour to do nonblocking I/O correctly.
Daniel Atallah <datallah@pidgin.im>
parents: 17663
diff changeset
528 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
529 g_free(ss->msg);
26bff2090889 Update Bonjour to do nonblocking I/O correctly.
Daniel Atallah <datallah@pidgin.im>
parents: 17663
diff changeset
530 ss->msg = tmp;
26bff2090889 Update Bonjour to do nonblocking I/O correctly.
Daniel Atallah <datallah@pidgin.im>
parents: 17663
diff changeset
531 return;
26bff2090889 Update Bonjour to do nonblocking I/O correctly.
Daniel Atallah <datallah@pidgin.im>
parents: 17663
diff changeset
532 }
26bff2090889 Update Bonjour to do nonblocking I/O correctly.
Daniel Atallah <datallah@pidgin.im>
parents: 17663
diff changeset
533
26bff2090889 Update Bonjour to do nonblocking I/O correctly.
Daniel Atallah <datallah@pidgin.im>
parents: 17663
diff changeset
534 g_free(ss->msg);
26bff2090889 Update Bonjour to do nonblocking I/O correctly.
Daniel Atallah <datallah@pidgin.im>
parents: 17663
diff changeset
535 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
536 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
537
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
538 /* 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
539 g_source_remove(bconv->tx_handler);
21727
decfc3a613ff applied changes from b9c97ed0f9ada9069e8bd994b01fdde0b484083c
Daniel Atallah <datallah@pidgin.im>
parents: 21720
diff changeset
540 bconv->tx_handler = 0;
decfc3a613ff applied changes from b9c97ed0f9ada9069e8bd994b01fdde0b484083c
Daniel Atallah <datallah@pidgin.im>
parents: 21720
diff changeset
541 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
542
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
543 bonjour_jabber_stream_started(bconv);
19056
05cd9ab28312 Update the Bonjour prpl to use libxml explicitly instead of the xml_node stuff. This allows us to deal with partial reads. I also fixed issues related to starting conversations with iChat and a couple other things. Fixes #2022,#1652
Daniel Atallah <datallah@pidgin.im>
parents: 18947
diff changeset
544 }
05cd9ab28312 Update the Bonjour prpl to use libxml explicitly instead of the xml_node stuff. This allows us to deal with partial reads. I also fixed issues related to starting conversations with iChat and a couple other things. Fixes #2022,#1652
Daniel Atallah <datallah@pidgin.im>
parents: 18947
diff changeset
545
39639
fe7fa102e766 Convert Bonjour client side to GIO.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39638
diff changeset
546 static gboolean
fe7fa102e766 Convert Bonjour client side to GIO.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39638
diff changeset
547 bonjour_jabber_send_stream_init(BonjourJabberConversation *bconv,
fe7fa102e766 Convert Bonjour client side to GIO.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39638
diff changeset
548 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
549 {
39639
fe7fa102e766 Convert Bonjour client side to GIO.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39638
diff changeset
550 gchar *stream_start;
fe7fa102e766 Convert Bonjour client side to GIO.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39638
diff changeset
551 gsize len;
fe7fa102e766 Convert Bonjour client side to GIO.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39638
diff changeset
552 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
553 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
554
c41d17a1b8d9 This is the second part of the fix to support having multiple presence records in Bonjour (and also supporting multiple presences using the same IP). Incoming conversations are no longer immediately attached to a buddy - we use an algorithm to match a conversation to a buddy based on the IP and, if possible the "from" attribute of the stream or the first tag in the stream. Thanks to Sjoerd Simons from Telepahy Salut for noticing and suggesting the algorithm. Fixes #4187. It'd be good if a few people test this.
Daniel Atallah <datallah@pidgin.im>
parents: 21936
diff changeset
555 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
556 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
557
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
558 /* 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
559 * 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
560 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
561 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
562
30825
87a79bbdc985 The hostname used for a bonjour account should always be the current machine
Daniel Atallah <datallah@pidgin.im>
parents: 30626
diff changeset
563 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
564 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
565
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
566 bconv->sent_stream_start = PARTIALLY_SENT;
21727
decfc3a613ff applied changes from b9c97ed0f9ada9069e8bd994b01fdde0b484083c
Daniel Atallah <datallah@pidgin.im>
parents: 21720
diff changeset
567
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
568 /* Start the stream */
39639
fe7fa102e766 Convert Bonjour client side to GIO.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39638
diff changeset
569 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
570 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
571 bconv->cancellable, error);
fe7fa102e766 Convert Bonjour client side to GIO.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39638
diff changeset
572 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
573 ret = 0;
39639
fe7fa102e766 Convert Bonjour client side to GIO.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39638
diff changeset
574 g_clear_error(error);
fe7fa102e766 Convert Bonjour client side to GIO.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39638
diff changeset
575 } else if (ret <= 0) {
fe7fa102e766 Convert Bonjour client side to GIO.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39638
diff changeset
576 purple_debug_error(
fe7fa102e766 Convert Bonjour client side to GIO.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39638
diff changeset
577 "bonjour",
fe7fa102e766 Convert Bonjour client side to GIO.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39638
diff changeset
578 "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
579 (*bname) ? bname : "(unknown)", bconv->ip,
fe7fa102e766 Convert Bonjour client side to GIO.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39638
diff changeset
580 *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
581
21944
c41d17a1b8d9 This is the second part of the fix to support having multiple presence records in Bonjour (and also supporting multiple presences using the same IP). Incoming conversations are no longer immediately attached to a buddy - we use an algorithm to match a conversation to a buddy based on the IP and, if possible the "from" attribute of the stream or the first tag in the stream. Thanks to Sjoerd Simons from Telepahy Salut for noticing and suggesting the algorithm. Fixes #4187. It'd be good if a few people test this.
Daniel Atallah <datallah@pidgin.im>
parents: 21936
diff changeset
582 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
583 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
584 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
585 if (conv != NULL)
36089
c035b9a63457 Use purple_conversation_write_system_message where appropriate
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 36073
diff changeset
586 purple_conversation_write_system_message(conv,
c035b9a63457 Use purple_conversation_write_system_message where appropriate
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 36073
diff changeset
587 _("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
588 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
589 }
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
590
39639
fe7fa102e766 Convert Bonjour client side to GIO.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39638
diff changeset
591 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
592 G_INPUT_STREAM(bconv->input),
fe7fa102e766 Convert Bonjour client side to GIO.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39638
diff changeset
593 G_OUTPUT_STREAM(bconv->output));
fe7fa102e766 Convert Bonjour client side to GIO.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39638
diff changeset
594 g_clear_object(&bconv->socket);
fe7fa102e766 Convert Bonjour client side to GIO.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39638
diff changeset
595 bconv->input = NULL;
fe7fa102e766 Convert Bonjour client side to GIO.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39638
diff changeset
596 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
597 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
598
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
599 return FALSE;
17665
26bff2090889 Update Bonjour to do nonblocking I/O correctly.
Daniel Atallah <datallah@pidgin.im>
parents: 17663
diff changeset
600 }
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
601
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
602 /* 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
603 if (ret < len) {
39639
fe7fa102e766 Convert Bonjour client side to GIO.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39638
diff changeset
604 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
605 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
606 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
607 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
608 /* Finish sending the stream start */
39639
fe7fa102e766 Convert Bonjour client side to GIO.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39638
diff changeset
609 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
610 G_POLLABLE_OUTPUT_STREAM(bconv->output),
fe7fa102e766 Convert Bonjour client side to GIO.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39638
diff changeset
611 bconv->cancellable);
fe7fa102e766 Convert Bonjour client side to GIO.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39638
diff changeset
612 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
613 NULL);
fe7fa102e766 Convert Bonjour client side to GIO.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39638
diff changeset
614 bconv->tx_handler = g_source_attach(source, NULL);
fe7fa102e766 Convert Bonjour client side to GIO.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39638
diff changeset
615 } 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
616 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
617 }
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
618
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
619 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
620
21727
decfc3a613ff applied changes from b9c97ed0f9ada9069e8bd994b01fdde0b484083c
Daniel Atallah <datallah@pidgin.im>
parents: 21720
diff changeset
621 return TRUE;
decfc3a613ff applied changes from b9c97ed0f9ada9069e8bd994b01fdde0b484083c
Daniel Atallah <datallah@pidgin.im>
parents: 21720
diff changeset
622 }
decfc3a613ff applied changes from b9c97ed0f9ada9069e8bd994b01fdde0b484083c
Daniel Atallah <datallah@pidgin.im>
parents: 21720
diff changeset
623
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 /* 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
625 * 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
626 void
fe7fa102e766 Convert Bonjour client side to GIO.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39638
diff changeset
627 bonjour_jabber_stream_started(BonjourJabberConversation *bconv)
fe7fa102e766 Convert Bonjour client side to GIO.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39638
diff changeset
628 {
fe7fa102e766 Convert Bonjour client side to GIO.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39638
diff changeset
629 GError *error = NULL;
21727
decfc3a613ff applied changes from b9c97ed0f9ada9069e8bd994b01fdde0b484083c
Daniel Atallah <datallah@pidgin.im>
parents: 21720
diff changeset
630
39639
fe7fa102e766 Convert Bonjour client side to GIO.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39638
diff changeset
631 if (bconv->sent_stream_start == NOT_SENT &&
fe7fa102e766 Convert Bonjour client side to GIO.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39638
diff changeset
632 !bonjour_jabber_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
633 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
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 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
637
39639
fe7fa102e766 Convert Bonjour client side to GIO.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39638
diff changeset
638 purple_debug_error(
fe7fa102e766 Convert Bonjour client side to GIO.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39638
diff changeset
639 "bonjour",
fe7fa102e766 Convert Bonjour client side to GIO.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39638
diff changeset
640 "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
641 bname ? bname : "(unknown)", bconv->ip,
fe7fa102e766 Convert Bonjour client side to GIO.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39638
diff changeset
642 error ? error->message : "(null)");
21727
decfc3a613ff applied changes from b9c97ed0f9ada9069e8bd994b01fdde0b484083c
Daniel Atallah <datallah@pidgin.im>
parents: 21720
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 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
645 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
646 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
647 if (conv != NULL)
36089
c035b9a63457 Use purple_conversation_write_system_message where appropriate
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 36073
diff changeset
648 purple_conversation_write_system_message(conv,
c035b9a63457 Use purple_conversation_write_system_message where appropriate
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 36073
diff changeset
649 _("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
650 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
651 }
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
652
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
653 /* 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
654 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
655 G_INPUT_STREAM(bconv->input),
fe7fa102e766 Convert Bonjour client side to GIO.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39638
diff changeset
656 G_OUTPUT_STREAM(bconv->output));
fe7fa102e766 Convert Bonjour client side to GIO.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39638
diff changeset
657 g_clear_object(&bconv->socket);
fe7fa102e766 Convert Bonjour client side to GIO.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39638
diff changeset
658 bconv->input = NULL;
fe7fa102e766 Convert Bonjour client side to GIO.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39638
diff changeset
659 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
660
21727
decfc3a613ff applied changes from b9c97ed0f9ada9069e8bd994b01fdde0b484083c
Daniel Atallah <datallah@pidgin.im>
parents: 21720
diff changeset
661 /* 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
662 * may be in the middle of parsing.
decfc3a613ff applied changes from b9c97ed0f9ada9069e8bd994b01fdde0b484083c
Daniel Atallah <datallah@pidgin.im>
parents: 21720
diff changeset
663 */
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
664 async_bonjour_jabber_close_conversation(bconv);
39639
fe7fa102e766 Convert Bonjour client side to GIO.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39638
diff changeset
665 g_clear_error(&error);
21727
decfc3a613ff applied changes from b9c97ed0f9ada9069e8bd994b01fdde0b484083c
Daniel Atallah <datallah@pidgin.im>
parents: 21720
diff changeset
666 return;
decfc3a613ff applied changes from b9c97ed0f9ada9069e8bd994b01fdde0b484083c
Daniel Atallah <datallah@pidgin.im>
parents: 21720
diff changeset
667 }
decfc3a613ff applied changes from b9c97ed0f9ada9069e8bd994b01fdde0b484083c
Daniel Atallah <datallah@pidgin.im>
parents: 21720
diff changeset
668
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
669 /* 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
670 /* 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
671 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
672 && 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
673 /* 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
674 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
675 G_POLLABLE_OUTPUT_STREAM(bconv->output),
fe7fa102e766 Convert Bonjour client side to GIO.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39638
diff changeset
676 bconv->cancellable);
fe7fa102e766 Convert Bonjour client side to GIO.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39638
diff changeset
677 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
678 bconv->pb, NULL);
fe7fa102e766 Convert Bonjour client side to GIO.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39638
diff changeset
679 bconv->tx_handler = g_source_attach(source, NULL);
21727
decfc3a613ff applied changes from b9c97ed0f9ada9069e8bd994b01fdde0b484083c
Daniel Atallah <datallah@pidgin.im>
parents: 21720
diff changeset
680 /* 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
681 _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
682 }
17665
26bff2090889 Update Bonjour to do nonblocking I/O correctly.
Daniel Atallah <datallah@pidgin.im>
parents: 17663
diff changeset
683 }
26bff2090889 Update Bonjour to do nonblocking I/O correctly.
Daniel Atallah <datallah@pidgin.im>
parents: 17663
diff changeset
684
29761
0f6862f2782f Implementation of IPv6 support for Bonjour
Daniel Atallah <datallah@pidgin.im>
parents: 27625
diff changeset
685 #ifndef INET6_ADDRSTRLEN
0f6862f2782f Implementation of IPv6 support for Bonjour
Daniel Atallah <datallah@pidgin.im>
parents: 27625
diff changeset
686 #define INET6_ADDRSTRLEN 46
0f6862f2782f Implementation of IPv6 support for Bonjour
Daniel Atallah <datallah@pidgin.im>
parents: 27625
diff changeset
687 #endif
0f6862f2782f Implementation of IPv6 support for Bonjour
Daniel Atallah <datallah@pidgin.im>
parents: 27625
diff changeset
688
12443
ad94864144f8 [gaim-migrate @ 14750]
Stu Tomlinson <nosnilmot@pidgin.im>
parents: 11830
diff changeset
689 static void
39638
635c8b6ca9a9 Convert Bonjour server to GSocketService.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39636
diff changeset
690 _server_socket_handler(GSocketService *service, GSocketConnection *connection,
635c8b6ca9a9 Convert Bonjour server to GSocketService.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39636
diff changeset
691 GObject *source_object, gpointer data)
11477
98b4f8643569 [gaim-migrate @ 13719]
Mark Doliner <markdoliner@pidgin.im>
parents:
diff changeset
692 {
21944
c41d17a1b8d9 This is the second part of the fix to support having multiple presence records in Bonjour (and also supporting multiple presences using the same IP). Incoming conversations are no longer immediately attached to a buddy - we use an algorithm to match a conversation to a buddy based on the IP and, if possible the "from" attribute of the stream or the first tag in the stream. Thanks to Sjoerd Simons from Telepahy Salut for noticing and suggesting the algorithm. Fixes #4187. It'd be good if a few people test this.
Daniel Atallah <datallah@pidgin.im>
parents: 21936
diff changeset
693 BonjourJabber *jdata = data;
39638
635c8b6ca9a9 Convert Bonjour server to GSocketService.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39636
diff changeset
694 GSocketAddress *their_addr; /* connector's address information */
635c8b6ca9a9 Convert Bonjour server to GSocketService.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39636
diff changeset
695 GInetAddress *their_inet_addr;
635c8b6ca9a9 Convert Bonjour server to GSocketService.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39636
diff changeset
696 gchar *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
697 struct _match_buddies_by_address_t *mbba;
c41d17a1b8d9 This is the second part of the fix to support having multiple presence records in Bonjour (and also supporting multiple presences using the same IP). Incoming conversations are no longer immediately attached to a buddy - we use an algorithm to match a conversation to a buddy based on the IP and, if possible the "from" attribute of the stream or the first tag in the stream. Thanks to Sjoerd Simons from Telepahy Salut for noticing and suggesting the algorithm. Fixes #4187. It'd be good if a few people test this.
Daniel Atallah <datallah@pidgin.im>
parents: 21936
diff changeset
698 BonjourJabberConversation *bconv;
26767
7489049a3bde Change purple_blist_get_buddies to return a list instead of the hash table.
Paul Aurich <darkrain42@pidgin.im>
parents: 25911
diff changeset
699 GSList *buddies;
39639
fe7fa102e766 Convert Bonjour client side to GIO.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39638
diff changeset
700 GSource *source;
11477
98b4f8643569 [gaim-migrate @ 13719]
Mark Doliner <markdoliner@pidgin.im>
parents:
diff changeset
701
39638
635c8b6ca9a9 Convert Bonjour server to GSocketService.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39636
diff changeset
702 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
703 if (their_addr == NULL) {
11477
98b4f8643569 [gaim-migrate @ 13719]
Mark Doliner <markdoliner@pidgin.im>
parents:
diff changeset
704 return;
39638
635c8b6ca9a9 Convert Bonjour server to GSocketService.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39636
diff changeset
705 }
635c8b6ca9a9 Convert Bonjour server to GSocketService.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39636
diff changeset
706 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
707 G_INET_SOCKET_ADDRESS(their_addr));
11477
98b4f8643569 [gaim-migrate @ 13719]
Mark Doliner <markdoliner@pidgin.im>
parents:
diff changeset
708
13962
71617bf27d00 [gaim-migrate @ 16386]
Jono Cole
parents: 13267
diff changeset
709 /* 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
710 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
711 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
712 G_SOCKET_FAMILY_IPV6 &&
635c8b6ca9a9 Convert Bonjour server to GSocketService.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39636
diff changeset
713 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
714 gchar *tmp = g_strdup_printf(
635c8b6ca9a9 Convert Bonjour server to GSocketService.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39636
diff changeset
715 "%s%%%d", address_text,
635c8b6ca9a9 Convert Bonjour server to GSocketService.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39636
diff changeset
716 g_inet_socket_address_get_scope_id(
635c8b6ca9a9 Convert Bonjour server to GSocketService.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39636
diff changeset
717 G_INET_SOCKET_ADDRESS(their_addr)));
635c8b6ca9a9 Convert Bonjour server to GSocketService.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39636
diff changeset
718 g_free(address_text);
635c8b6ca9a9 Convert Bonjour server to GSocketService.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39636
diff changeset
719 address_text = tmp;
635c8b6ca9a9 Convert Bonjour server to GSocketService.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39636
diff changeset
720 }
635c8b6ca9a9 Convert Bonjour server to GSocketService.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39636
diff changeset
721 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
722
19832
84b69b21672b Patch from QuLogic. Fixes #2903 ('Missing newlines in debug messages.')
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 19749
diff changeset
723 purple_debug_info("bonjour", "Received incoming connection from %s.\n", address_text);
21944
c41d17a1b8d9 This is the second part of the fix to support having multiple presence records in Bonjour (and also supporting multiple presences using the same IP). Incoming conversations are no longer immediately attached to a buddy - we use an algorithm to match a conversation to a buddy based on the IP and, if possible the "from" attribute of the stream or the first tag in the stream. Thanks to Sjoerd Simons from Telepahy Salut for noticing and suggesting the algorithm. Fixes #4187. It'd be good if a few people test this.
Daniel Atallah <datallah@pidgin.im>
parents: 21936
diff changeset
724 mbba = g_new0(struct _match_buddies_by_address_t, 1);
c41d17a1b8d9 This is the second part of the fix to support having multiple presence records in Bonjour (and also supporting multiple presences using the same IP). Incoming conversations are no longer immediately attached to a buddy - we use an algorithm to match a conversation to a buddy based on the IP and, if possible the "from" attribute of the stream or the first tag in the stream. Thanks to Sjoerd Simons from Telepahy Salut for noticing and suggesting the algorithm. Fixes #4187. It'd be good if a few people test this.
Daniel Atallah <datallah@pidgin.im>
parents: 21936
diff changeset
725 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
726
34728
8efd73063ecf Renamed buddy list functions to more appropriate/simler names.
Ankit Vani <a@nevitus.org>
parents: 34706
diff changeset
727 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
728 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
729 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
730
c41d17a1b8d9 This is the second part of the fix to support having multiple presence records in Bonjour (and also supporting multiple presences using the same IP). Incoming conversations are no longer immediately attached to a buddy - we use an algorithm to match a conversation to a buddy based on the IP and, if possible the "from" attribute of the stream or the first tag in the stream. Thanks to Sjoerd Simons from Telepahy Salut for noticing and 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 if (mbba->matched_buddies == NULL) {
29999
Paul Aurich <darkrain42@pidgin.im>
parents: 29932
diff changeset
732 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
733 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
734 g_free(mbba);
11477
98b4f8643569 [gaim-migrate @ 13719]
Mark Doliner <markdoliner@pidgin.im>
parents:
diff changeset
735 return;
98b4f8643569 [gaim-migrate @ 13719]
Mark Doliner <markdoliner@pidgin.im>
parents:
diff changeset
736 }
98b4f8643569 [gaim-migrate @ 13719]
Mark Doliner <markdoliner@pidgin.im>
parents:
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 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
739 g_free(mbba);
17665
26bff2090889 Update Bonjour to do nonblocking I/O correctly.
Daniel Atallah <datallah@pidgin.im>
parents: 17663
diff changeset
740
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
741 /* 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
742 * 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
743 */
c41d17a1b8d9 This is the second part of the fix to support having multiple presence records in Bonjour (and also supporting multiple presences using the same IP). Incoming conversations are no longer immediately attached to a buddy - we use an algorithm to match a conversation to a buddy based on the IP and, if possible the "from" attribute of the stream or the first tag in the stream. Thanks to Sjoerd Simons from Telepahy Salut for noticing and suggesting the algorithm. Fixes #4187. It'd be good if a few people test this.
Daniel Atallah <datallah@pidgin.im>
parents: 21936
diff changeset
744 bconv = bonjour_jabber_conv_new(NULL, jdata->account, address_text);
17665
26bff2090889 Update Bonjour to do nonblocking I/O correctly.
Daniel Atallah <datallah@pidgin.im>
parents: 17663
diff changeset
745
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
746 /* 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
747 bconv->socket = g_object_ref(connection);
fe7fa102e766 Convert Bonjour client side to GIO.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39638
diff changeset
748 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
749 bconv->output =
fe7fa102e766 Convert Bonjour client side to GIO.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39638
diff changeset
750 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
751 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
752 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
753 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
754 bconv, NULL);
fe7fa102e766 Convert Bonjour client side to GIO.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39638
diff changeset
755 bconv->rx_handler = g_source_attach(source, NULL);
39638
635c8b6ca9a9 Convert Bonjour server to GSocketService.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39636
diff changeset
756 g_free(address_text);
29761
0f6862f2782f Implementation of IPv6 support for Bonjour
Daniel Atallah <datallah@pidgin.im>
parents: 27625
diff changeset
757 }
0f6862f2782f Implementation of IPv6 support for Bonjour
Daniel Atallah <datallah@pidgin.im>
parents: 27625
diff changeset
758
0f6862f2782f Implementation of IPv6 support for Bonjour
Daniel Atallah <datallah@pidgin.im>
parents: 27625
diff changeset
759 gint
0f6862f2782f Implementation of IPv6 support for Bonjour
Daniel Atallah <datallah@pidgin.im>
parents: 27625
diff changeset
760 bonjour_jabber_start(BonjourJabber *jdata)
0f6862f2782f Implementation of IPv6 support for Bonjour
Daniel Atallah <datallah@pidgin.im>
parents: 27625
diff changeset
761 {
39638
635c8b6ca9a9 Convert Bonjour server to GSocketService.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39636
diff changeset
762 GError *error = NULL;
635c8b6ca9a9 Convert Bonjour server to GSocketService.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39636
diff changeset
763 guint16 port;
635c8b6ca9a9 Convert Bonjour server to GSocketService.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39636
diff changeset
764
635c8b6ca9a9 Convert Bonjour server to GSocketService.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39636
diff changeset
765 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
766 jdata->port);
29761
0f6862f2782f Implementation of IPv6 support for Bonjour
Daniel Atallah <datallah@pidgin.im>
parents: 27625
diff changeset
767
39638
635c8b6ca9a9 Convert Bonjour server to GSocketService.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39636
diff changeset
768 /* Open a listening server for incoming conversations */
635c8b6ca9a9 Convert Bonjour server to GSocketService.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39636
diff changeset
769 jdata->service = g_socket_service_new();
635c8b6ca9a9 Convert Bonjour server to GSocketService.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39636
diff changeset
770 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
771 port = jdata->port;
635c8b6ca9a9 Convert Bonjour server to GSocketService.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39636
diff changeset
772 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
773 port, NULL, &error)) {
635c8b6ca9a9 Convert Bonjour server to GSocketService.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39636
diff changeset
774 purple_debug_info("bonjour",
635c8b6ca9a9 Convert Bonjour server to GSocketService.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39636
diff changeset
775 "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
776 port, 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);
635c8b6ca9a9 Convert Bonjour server to GSocketService.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39636
diff changeset
778 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
779 G_SOCKET_LISTENER(jdata->service), NULL, &error);
635c8b6ca9a9 Convert Bonjour server to GSocketService.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39636
diff changeset
780 if (port == 0) {
635c8b6ca9a9 Convert Bonjour server to GSocketService.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39636
diff changeset
781 purple_debug_error(
635c8b6ca9a9 Convert Bonjour server to GSocketService.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39636
diff changeset
782 "bonjour", "Unable to create socket: %s",
635c8b6ca9a9 Convert Bonjour server to GSocketService.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39636
diff changeset
783 error ? error->message : "(unknown)");
635c8b6ca9a9 Convert Bonjour server to GSocketService.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39636
diff changeset
784 g_clear_error(&error);
35991
e6937e52930b Fix some CWE-252 coverity warnings
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35983
diff changeset
785 return -1;
e6937e52930b Fix some CWE-252 coverity warnings
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35983
diff changeset
786 }
29761
0f6862f2782f Implementation of IPv6 support for Bonjour
Daniel Atallah <datallah@pidgin.im>
parents: 27625
diff changeset
787 }
39638
635c8b6ca9a9 Convert Bonjour server to GSocketService.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39636
diff changeset
788 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
789 jdata->port = port;
29761
0f6862f2782f Implementation of IPv6 support for Bonjour
Daniel Atallah <datallah@pidgin.im>
parents: 27625
diff changeset
790
39638
635c8b6ca9a9 Convert Bonjour server to GSocketService.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39636
diff changeset
791 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
792 G_CALLBACK(_server_socket_handler), jdata);
11539
fbabe3f89777 [gaim-migrate @ 13794]
Mark Doliner <markdoliner@pidgin.im>
parents: 11515
diff changeset
793
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
794 return jdata->port;
11477
98b4f8643569 [gaim-migrate @ 13719]
Mark Doliner <markdoliner@pidgin.im>
parents:
diff changeset
795 }
98b4f8643569 [gaim-migrate @ 13719]
Mark Doliner <markdoliner@pidgin.im>
parents:
diff changeset
796
17665
26bff2090889 Update Bonjour to do nonblocking I/O correctly.
Daniel Atallah <datallah@pidgin.im>
parents: 17663
diff changeset
797 static void
39639
fe7fa102e766 Convert Bonjour client side to GIO.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39638
diff changeset
798 _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
799 {
39639
fe7fa102e766 Convert Bonjour client side to GIO.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39638
diff changeset
800 PurpleBuddy *pb = user_data;
24938
fc6952107e1f Finished moving to api for bonjour
Gary Kramlich <grim@reaperworld.com>
parents: 24562
diff changeset
801 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
802 GSocketConnection *conn;
fe7fa102e766 Convert Bonjour client side to GIO.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39638
diff changeset
803 GSource *rx_source;
fe7fa102e766 Convert Bonjour client side to GIO.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39638
diff changeset
804 GError *error = NULL;
17665
26bff2090889 Update Bonjour to do nonblocking I/O correctly.
Daniel Atallah <datallah@pidgin.im>
parents: 17663
diff changeset
805
39639
fe7fa102e766 Convert Bonjour client side to GIO.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39638
diff changeset
806 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
807 res, &error);
17665
26bff2090889 Update Bonjour to do nonblocking I/O correctly.
Daniel Atallah <datallah@pidgin.im>
parents: 17663
diff changeset
808
39639
fe7fa102e766 Convert Bonjour client side to GIO.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39638
diff changeset
809 if (conn == NULL) {
24938
fc6952107e1f Finished moving to api for bonjour
Gary Kramlich <grim@reaperworld.com>
parents: 24562
diff changeset
810 PurpleConversation *conv = NULL;
fc6952107e1f Finished moving to api for bonjour
Gary Kramlich <grim@reaperworld.com>
parents: 24562
diff changeset
811 PurpleAccount *account = NULL;
31748
45c25b4868cb bonjour: Recurse through user IP addresses instead of using the first one only
Simon van der Linden <simon@vanderlinden.eu.org>
parents: 30827
diff changeset
812 GSList *tmp = bb->ips;
17665
26bff2090889 Update Bonjour to do nonblocking I/O correctly.
Daniel Atallah <datallah@pidgin.im>
parents: 17663
diff changeset
813
39639
fe7fa102e766 Convert Bonjour client side to GIO.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39638
diff changeset
814 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
815 /* 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
816 g_error_free(error);
fe7fa102e766 Convert Bonjour client side to GIO.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39638
diff changeset
817 return;
fe7fa102e766 Convert Bonjour client side to GIO.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39638
diff changeset
818 }
fe7fa102e766 Convert Bonjour client side to GIO.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39638
diff changeset
819
fe7fa102e766 Convert Bonjour client side to GIO.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39638
diff changeset
820 purple_debug_error("bonjour",
fe7fa102e766 Convert Bonjour client side to GIO.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39638
diff changeset
821 "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
822 "(%s); Trying next IP address",
fe7fa102e766 Convert Bonjour client side to GIO.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39638
diff changeset
823 purple_buddy_get_name(pb),
fe7fa102e766 Convert Bonjour client side to GIO.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39638
diff changeset
824 bb->conversation->ip, bb->port_p2pj,
fe7fa102e766 Convert Bonjour client side to GIO.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39638
diff changeset
825 error ? error->message : "(unknown)");
fe7fa102e766 Convert Bonjour client side to GIO.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39638
diff changeset
826 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
827
31749
710d5d207306 bonjour: Update to 427f3622bbeb4 to match the last used IP more reliably.
Daniel Atallah <datallah@pidgin.im>
parents: 31748
diff changeset
828 /* 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
829 * 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
830 * 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
831 */
710d5d207306 bonjour: Update to 427f3622bbeb4 to match the last used IP more reliably.
Daniel Atallah <datallah@pidgin.im>
parents: 31748
diff changeset
832 while (tmp && bb->conversation->ip_link != tmp->data)
710d5d207306 bonjour: Update to 427f3622bbeb4 to match the last used IP more reliably.
Daniel Atallah <datallah@pidgin.im>
parents: 31748
diff changeset
833 tmp = g_slist_next(tmp);
710d5d207306 bonjour: Update to 427f3622bbeb4 to match the last used IP more reliably.
Daniel Atallah <datallah@pidgin.im>
parents: 31748
diff changeset
834 if (tmp)
710d5d207306 bonjour: Update to 427f3622bbeb4 to match the last used IP more reliably.
Daniel Atallah <datallah@pidgin.im>
parents: 31748
diff changeset
835 tmp = g_slist_next(tmp);
17665
26bff2090889 Update Bonjour to do nonblocking I/O correctly.
Daniel Atallah <datallah@pidgin.im>
parents: 17663
diff changeset
836
24938
fc6952107e1f Finished moving to api for bonjour
Gary Kramlich <grim@reaperworld.com>
parents: 24562
diff changeset
837 account = purple_buddy_get_account(pb);
fc6952107e1f Finished moving to api for bonjour
Gary Kramlich <grim@reaperworld.com>
parents: 24562
diff changeset
838
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
839 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
840 const gchar *ip;
39639
fe7fa102e766 Convert Bonjour client side to GIO.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39638
diff changeset
841 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
842
31749
710d5d207306 bonjour: Update to 427f3622bbeb4 to match the last used IP more reliably.
Daniel Atallah <datallah@pidgin.im>
parents: 31748
diff changeset
843 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
844
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
845 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
846 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
847
39639
fe7fa102e766 Convert Bonjour client side to GIO.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39638
diff changeset
848 /* 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
849 client = g_socket_client_new();
fe7fa102e766 Convert Bonjour client side to GIO.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39638
diff changeset
850 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
851 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
852 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
853 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
854 client, ip, bb->port_p2pj,
fe7fa102e766 Convert Bonjour client side to GIO.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39638
diff changeset
855 bb->conversation->cancellable,
fe7fa102e766 Convert Bonjour client side to GIO.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39638
diff changeset
856 _connected_to_buddy, pb);
fe7fa102e766 Convert Bonjour client side to GIO.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39638
diff changeset
857 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
858 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
859 }
45c25b4868cb bonjour: Recurse through user IP addresses instead of using the first one only
Simon van der Linden <simon@vanderlinden.eu.org>
parents: 30827
diff changeset
860 }
45c25b4868cb bonjour: Recurse through user IP addresses instead of using the first one only
Simon van der Linden <simon@vanderlinden.eu.org>
parents: 30827
diff changeset
861
45c25b4868cb bonjour: Recurse through user IP addresses instead of using the first one only
Simon van der Linden <simon@vanderlinden.eu.org>
parents: 30827
diff changeset
862 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
863
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
864 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
865 if (conv != NULL)
36089
c035b9a63457 Use purple_conversation_write_system_message where appropriate
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 36073
diff changeset
866 purple_conversation_write_system_message(conv,
c035b9a63457 Use purple_conversation_write_system_message where appropriate
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 36073
diff changeset
867 _("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
868 PURPLE_MESSAGE_ERROR);
17665
26bff2090889 Update Bonjour to do nonblocking I/O correctly.
Daniel Atallah <datallah@pidgin.im>
parents: 17663
diff changeset
869
26bff2090889 Update Bonjour to do nonblocking I/O correctly.
Daniel Atallah <datallah@pidgin.im>
parents: 17663
diff changeset
870 bonjour_jabber_close_conversation(bb->conversation);
26bff2090889 Update Bonjour to do nonblocking I/O correctly.
Daniel Atallah <datallah@pidgin.im>
parents: 17663
diff changeset
871 bb->conversation = NULL;
26bff2090889 Update Bonjour to do nonblocking I/O correctly.
Daniel Atallah <datallah@pidgin.im>
parents: 17663
diff changeset
872 return;
26bff2090889 Update Bonjour to do nonblocking I/O correctly.
Daniel Atallah <datallah@pidgin.im>
parents: 17663
diff changeset
873 }
26bff2090889 Update Bonjour to do nonblocking I/O correctly.
Daniel Atallah <datallah@pidgin.im>
parents: 17663
diff changeset
874
39639
fe7fa102e766 Convert Bonjour client side to GIO.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39638
diff changeset
875 bb->conversation->socket = conn;
fe7fa102e766 Convert Bonjour client side to GIO.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39638
diff changeset
876 bb->conversation->input =
fe7fa102e766 Convert Bonjour client side to GIO.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39638
diff changeset
877 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
878 bb->conversation->output =
fe7fa102e766 Convert Bonjour client side to GIO.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39638
diff changeset
879 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
880
fe7fa102e766 Convert Bonjour client side to GIO.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39638
diff changeset
881 if (!bonjour_jabber_send_stream_init(bb->conversation, &error)) {
24938
fc6952107e1f Finished moving to api for bonjour
Gary Kramlich <grim@reaperworld.com>
parents: 24562
diff changeset
882 PurpleConversation *conv = NULL;
fc6952107e1f Finished moving to api for bonjour
Gary Kramlich <grim@reaperworld.com>
parents: 24562
diff changeset
883 PurpleAccount *account = NULL;
17665
26bff2090889 Update Bonjour to do nonblocking I/O correctly.
Daniel Atallah <datallah@pidgin.im>
parents: 17663
diff changeset
884
39639
fe7fa102e766 Convert Bonjour client side to GIO.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39638
diff changeset
885 purple_debug_error("bonjour",
fe7fa102e766 Convert Bonjour client side to GIO.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39638
diff changeset
886 "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
887 "%s:%d error: %s",
fe7fa102e766 Convert Bonjour client side to GIO.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39638
diff changeset
888 purple_buddy_get_name(pb),
fe7fa102e766 Convert Bonjour client side to GIO.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39638
diff changeset
889 bb->conversation->ip, bb->port_p2pj,
fe7fa102e766 Convert Bonjour client side to GIO.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39638
diff changeset
890 error ? error->message : "(null)");
17665
26bff2090889 Update Bonjour to do nonblocking I/O correctly.
Daniel Atallah <datallah@pidgin.im>
parents: 17663
diff changeset
891
24938
fc6952107e1f Finished moving to api for bonjour
Gary Kramlich <grim@reaperworld.com>
parents: 24562
diff changeset
892 account = purple_buddy_get_account(pb);
fc6952107e1f Finished moving to api for bonjour
Gary Kramlich <grim@reaperworld.com>
parents: 24562
diff changeset
893
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
894 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
895 if (conv != NULL)
36089
c035b9a63457 Use purple_conversation_write_system_message where appropriate
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 36073
diff changeset
896 purple_conversation_write_system_message(conv,
c035b9a63457 Use purple_conversation_write_system_message where appropriate
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 36073
diff changeset
897 _("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
898 PURPLE_MESSAGE_ERROR);
17665
26bff2090889 Update Bonjour to do nonblocking I/O correctly.
Daniel Atallah <datallah@pidgin.im>
parents: 17663
diff changeset
899
26bff2090889 Update Bonjour to do nonblocking I/O correctly.
Daniel Atallah <datallah@pidgin.im>
parents: 17663
diff changeset
900 bonjour_jabber_close_conversation(bb->conversation);
26bff2090889 Update Bonjour to do nonblocking I/O correctly.
Daniel Atallah <datallah@pidgin.im>
parents: 17663
diff changeset
901 bb->conversation = NULL;
39639
fe7fa102e766 Convert Bonjour client side to GIO.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39638
diff changeset
902 g_clear_error(&error);
17665
26bff2090889 Update Bonjour to do nonblocking I/O correctly.
Daniel Atallah <datallah@pidgin.im>
parents: 17663
diff changeset
903 return;
26bff2090889 Update Bonjour to do nonblocking I/O correctly.
Daniel Atallah <datallah@pidgin.im>
parents: 17663
diff changeset
904 }
21727
decfc3a613ff applied changes from b9c97ed0f9ada9069e8bd994b01fdde0b484083c
Daniel Atallah <datallah@pidgin.im>
parents: 21720
diff changeset
905
decfc3a613ff applied changes from b9c97ed0f9ada9069e8bd994b01fdde0b484083c
Daniel Atallah <datallah@pidgin.im>
parents: 21720
diff changeset
906 /* 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
907 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
908 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
909 bb->conversation->cancellable);
fe7fa102e766 Convert Bonjour client side to GIO.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39638
diff changeset
910 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
911 bb->conversation, NULL);
fe7fa102e766 Convert Bonjour client side to GIO.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39638
diff changeset
912 bb->conversation->rx_handler = g_source_attach(rx_source, 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
913 }
c41d17a1b8d9 This is the second part of the fix to support having multiple presence records in Bonjour (and also supporting multiple presences using the same IP). Incoming conversations are no longer immediately attached to a buddy - we use an algorithm to match a conversation to a buddy based on the IP and, if possible the "from" attribute of the stream or the first tag in the stream. Thanks to Sjoerd Simons from Telepahy Salut for noticing and 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
c41d17a1b8d9 This is the second part of the fix to support having multiple presence records in Bonjour (and also supporting multiple presences using the same IP). Incoming conversations are no longer immediately attached to a buddy - we use an algorithm to match a conversation to a buddy based on the IP and, if possible the "from" attribute of the stream or the first tag in the stream. Thanks to Sjoerd Simons from Telepahy Salut for noticing and 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 void
c41d17a1b8d9 This is the second part of the fix to support having multiple presence records in Bonjour (and also supporting multiple presences using the same IP). Incoming conversations are no longer immediately attached to a buddy - we use an algorithm to match a conversation to a buddy based on the IP and, if possible the "from" attribute of the stream or the first tag in the stream. Thanks to Sjoerd Simons from Telepahy Salut for noticing and suggesting the algorithm. Fixes #4187. It'd be good if a few people test this.
Daniel Atallah <datallah@pidgin.im>
parents: 21936
diff changeset
916 bonjour_jabber_conv_match_by_name(BonjourJabberConversation *bconv) {
24938
fc6952107e1f Finished moving to api for bonjour
Gary Kramlich <grim@reaperworld.com>
parents: 24562
diff changeset
917 PurpleBuddy *pb = NULL;
fc6952107e1f Finished moving to api for bonjour
Gary Kramlich <grim@reaperworld.com>
parents: 24562
diff changeset
918 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
919
c41d17a1b8d9 This is the second part of the fix to support having multiple presence records in Bonjour (and also supporting multiple presences using the same IP). Incoming conversations are no longer immediately attached to a buddy - we use an algorithm to match a conversation to a buddy based on the IP and, if possible the "from" attribute of the stream or the first tag in the stream. Thanks to Sjoerd Simons from Telepahy Salut for noticing and 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 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
921 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
922
34728
8efd73063ecf Renamed buddy list functions to more appropriate/simler names.
Ankit Vani <a@nevitus.org>
parents: 34706
diff changeset
923 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
924 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
925 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
926 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
927
c41d17a1b8d9 This is the second part of the fix to support having multiple presence records in Bonjour (and also supporting multiple presences using the same IP). Incoming conversations are no longer immediately attached to a buddy - we use an algorithm to match a conversation to a buddy based on the IP and, if possible the "from" attribute of the stream or the first tag in the stream. Thanks to Sjoerd Simons from Telepahy Salut for noticing and suggesting the algorithm. Fixes #4187. It'd be good if a few people test this.
Daniel Atallah <datallah@pidgin.im>
parents: 21936
diff changeset
928 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
929 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
930
c41d17a1b8d9 This is the second part of the fix to support having multiple presence records in Bonjour (and also supporting multiple presences using the same IP). Incoming conversations are no longer immediately attached to a buddy - we use an algorithm to match a conversation to a buddy based on the IP and, if possible the "from" attribute of the stream or the first tag in the stream. Thanks to Sjoerd Simons from Telepahy Salut for noticing and 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 /* 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
932 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
933 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
934 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
935 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
936 BonjourData *bd = purple_connection_get_protocol_data(pc);
5b0ecccb3bbb Convert bonjour prpl to use accessor functions purple_connection_get_protocol_data() and purple_connection_set_protocol_data().
Andrew Victor <andrew.victor@mxit.com>
parents: 32215
diff changeset
937 BonjourJabber *jdata = bd->jabber_data;
21944
c41d17a1b8d9 This is the second part of the fix to support having multiple presence records in Bonjour (and also supporting multiple presences using the same IP). Incoming conversations are no longer immediately attached to a buddy - we use an algorithm to match a conversation to a buddy based on the IP and, if possible the "from" attribute of the stream or the first tag in the stream. Thanks to Sjoerd Simons from Telepahy Salut for noticing and suggesting the algorithm. Fixes #4187. It'd be good if a few people test this.
Daniel Atallah <datallah@pidgin.im>
parents: 21936
diff changeset
938
c41d17a1b8d9 This is the second part of the fix to support having multiple presence records in Bonjour (and also supporting multiple presences using the same IP). Incoming conversations are no longer immediately attached to a buddy - we use an algorithm to match a conversation to a buddy based on the IP and, if possible the "from" attribute of the stream or the first tag in the stream. Thanks to Sjoerd Simons from Telepahy Salut for noticing and 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 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
940 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
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 /* 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
943 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
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 /* 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
946 if(bb->conversation != NULL && bb->conversation != bconv)
c41d17a1b8d9 This is the second part of the fix to support having multiple presence records in Bonjour (and also supporting multiple presences using the same IP). Incoming conversations are no longer immediately attached to a buddy - we use an algorithm to match a conversation to a buddy based on the IP and, if possible the "from" attribute of the stream or the first tag in the stream. Thanks to Sjoerd Simons from Telepahy Salut for noticing and suggesting the algorithm. Fixes #4187. It'd be good if a few people test this.
Daniel Atallah <datallah@pidgin.im>
parents: 21936
diff changeset
947 bonjour_jabber_close_conversation(bb->conversation);
c41d17a1b8d9 This is the second part of the fix to support having multiple presence records in Bonjour (and also supporting multiple presences using the same IP). Incoming conversations are no longer immediately attached to a buddy - we use an algorithm to match a conversation to a buddy based on the IP and, if possible the "from" attribute of the stream or the first tag in the stream. Thanks to Sjoerd Simons from Telepahy Salut for noticing and suggesting the algorithm. Fixes #4187. It'd be good if a few people test this.
Daniel Atallah <datallah@pidgin.im>
parents: 21936
diff changeset
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 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
950 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
951
c41d17a1b8d9 This is the second part of the fix to support having multiple presence records in Bonjour (and also supporting multiple presences using the same IP). Incoming conversations are no longer immediately attached to a buddy - we use an algorithm to match a conversation to a buddy based on the IP and, if possible the "from" attribute of the stream or the first tag in the stream. Thanks to Sjoerd Simons from Telepahy Salut for noticing and suggesting the algorithm. Fixes #4187. It'd be good if a few people test this.
Daniel Atallah <datallah@pidgin.im>
parents: 21936
diff changeset
952 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
953 }
c41d17a1b8d9 This is the second part of the fix to support having multiple presence records in Bonjour (and also supporting multiple presences using the same IP). Incoming conversations are no longer immediately attached to a buddy - we use an algorithm to match a conversation to a buddy based on the IP and, if possible the "from" attribute of the stream or the first tag in the stream. Thanks to Sjoerd Simons from Telepahy Salut for noticing and suggesting the algorithm. Fixes #4187. It'd be good if a few people test this.
Daniel Atallah <datallah@pidgin.im>
parents: 21936
diff changeset
954 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
955 }
c41d17a1b8d9 This is the second part of the fix to support having multiple presence records in Bonjour (and also supporting multiple presences using the same IP). Incoming conversations are no longer immediately attached to a buddy - we use an algorithm to match a conversation to a buddy based on the IP and, if possible the "from" attribute of the stream or the first tag in the stream. Thanks to Sjoerd Simons from Telepahy Salut for noticing and suggesting the algorithm. Fixes #4187. It'd be good if a few people test this.
Daniel Atallah <datallah@pidgin.im>
parents: 21936
diff changeset
956 }
c41d17a1b8d9 This is the second part of the fix to support having multiple presence records in Bonjour (and also supporting multiple presences using the same IP). Incoming conversations are no longer immediately attached to a buddy - we use an algorithm to match a conversation to a buddy based on the IP and, if possible the "from" attribute of the stream or the first tag in the stream. Thanks to Sjoerd Simons from Telepahy Salut for noticing and 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 /* 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
959 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
960 /* 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
961 * 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
962 */
c41d17a1b8d9 This is the second part of the fix to support having multiple presence records in Bonjour (and also supporting multiple presences using the same IP). Incoming conversations are no longer immediately attached to a buddy - we use an algorithm to match a conversation to a buddy based on the IP and, if possible the "from" attribute of the stream or the first tag in the stream. Thanks to Sjoerd Simons from Telepahy Salut for noticing and suggesting the algorithm. Fixes #4187. It'd be good if a few people test this.
Daniel Atallah <datallah@pidgin.im>
parents: 21936
diff changeset
963 async_bonjour_jabber_close_conversation(bconv);
c41d17a1b8d9 This is the second part of the fix to support having multiple presence records in Bonjour (and also supporting multiple presences using the same IP). Incoming conversations are no longer immediately attached to a buddy - we use an algorithm to match a conversation to a buddy based on the IP and, if possible the "from" attribute of the stream or the first tag in the stream. Thanks to Sjoerd Simons from Telepahy Salut for noticing and suggesting the algorithm. Fixes #4187. It'd be good if a few people test this.
Daniel Atallah <datallah@pidgin.im>
parents: 21936
diff changeset
964 }
c41d17a1b8d9 This is the second part of the fix to support having multiple presence records in Bonjour (and also supporting multiple presences using the same IP). Incoming conversations are no longer immediately attached to a buddy - we use an algorithm to match a conversation to a buddy based on the IP and, if possible the "from" attribute of the stream or the first tag in the stream. Thanks to Sjoerd Simons from Telepahy Salut for noticing and suggesting the algorithm. Fixes #4187. It'd be good if a few people test this.
Daniel Atallah <datallah@pidgin.im>
parents: 21936
diff changeset
965 }
c41d17a1b8d9 This is the second part of the fix to support having multiple presence records in Bonjour (and also supporting multiple presences using the same IP). Incoming conversations are no longer immediately attached to a buddy - we use an algorithm to match a conversation to a buddy based on the IP and, if possible the "from" attribute of the stream or the first tag in the stream. Thanks to Sjoerd Simons from Telepahy Salut for noticing and suggesting the algorithm. Fixes #4187. It'd be good if a few people test this.
Daniel Atallah <datallah@pidgin.im>
parents: 21936
diff changeset
966
c41d17a1b8d9 This is the second part of the fix to support having multiple presence records in Bonjour (and also supporting multiple presences using the same IP). Incoming conversations are no longer immediately attached to a buddy - we use an algorithm to match a conversation to a buddy based on the IP and, if possible the "from" attribute of the stream or the first tag in the stream. Thanks to Sjoerd Simons from Telepahy Salut for noticing and suggesting the algorithm. Fixes #4187. It'd be good if a few people test this.
Daniel Atallah <datallah@pidgin.im>
parents: 21936
diff changeset
967
c41d17a1b8d9 This is the second part of the fix to support having multiple presence records in Bonjour (and also supporting multiple presences using the same IP). Incoming conversations are no longer immediately attached to a buddy - we use an algorithm to match a conversation to a buddy based on the IP and, if possible the "from" attribute of the stream or the first tag in the stream. Thanks to Sjoerd Simons from Telepahy Salut for noticing and 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 void
c41d17a1b8d9 This is the second part of the fix to support having multiple presence records in Bonjour (and also supporting multiple presences using the same IP). Incoming conversations are no longer immediately attached to a buddy - we use an algorithm to match a conversation to a buddy based on the IP and, if possible the "from" attribute of the stream or the first tag in the stream. Thanks to Sjoerd Simons from Telepahy Salut for noticing and suggesting the algorithm. Fixes #4187. It'd be good if a few people test this.
Daniel Atallah <datallah@pidgin.im>
parents: 21936
diff changeset
969 bonjour_jabber_conv_match_by_ip(BonjourJabberConversation *bconv) {
32215
0a4e72c8a67e Use accessor functions in a few places
Mark Doliner <markdoliner@pidgin.im>
parents: 31749
diff changeset
970 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
971 BonjourData *bd = purple_connection_get_protocol_data(pc);
5b0ecccb3bbb Convert bonjour prpl to use accessor functions purple_connection_get_protocol_data() and purple_connection_set_protocol_data().
Andrew Victor <andrew.victor@mxit.com>
parents: 32215
diff changeset
972 BonjourJabber *jdata = bd->jabber_data;
21944
c41d17a1b8d9 This is the second part of the fix to support having multiple presence records in Bonjour (and also supporting multiple presences using the same IP). Incoming conversations are no longer immediately attached to a buddy - we use an algorithm to match a conversation to a buddy based on the IP and, if possible the "from" attribute of the stream or the first tag in the stream. Thanks to Sjoerd Simons from Telepahy Salut for noticing and suggesting the algorithm. Fixes #4187. It'd be good if a few people test this.
Daniel Atallah <datallah@pidgin.im>
parents: 21936
diff changeset
973 struct _match_buddies_by_address_t *mbba;
26767
7489049a3bde Change purple_blist_get_buddies to return a list instead of the hash table.
Paul Aurich <darkrain42@pidgin.im>
parents: 25911
diff changeset
974 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
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 mbba = g_new0(struct _match_buddies_by_address_t, 1);
c41d17a1b8d9 This is the second part of the fix to support having multiple presence records in Bonjour (and also supporting multiple presences using the same IP). Incoming conversations are no longer immediately attached to a buddy - we use an algorithm to match a conversation to a buddy based on the IP and, if possible the "from" attribute of the stream or the first tag in the stream. Thanks to Sjoerd Simons from Telepahy Salut for noticing and suggesting the algorithm. Fixes #4187. It'd be good if a few people test this.
Daniel Atallah <datallah@pidgin.im>
parents: 21936
diff changeset
977 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
978
34728
8efd73063ecf Renamed buddy list functions to more appropriate/simler names.
Ankit Vani <a@nevitus.org>
parents: 34706
diff changeset
979 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
980 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
981 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
982
c41d17a1b8d9 This is the second part of the fix to support having multiple presence records in Bonjour (and also supporting multiple presences using the same IP). Incoming conversations are no longer immediately attached to a buddy - we use an algorithm to match a conversation to a buddy based on the IP and, if possible the "from" attribute of the stream or the first tag in the stream. Thanks to Sjoerd Simons from Telepahy Salut for noticing and suggesting the algorithm. Fixes #4187. It'd be good if a few people test this.
Daniel Atallah <datallah@pidgin.im>
parents: 21936
diff changeset
983 /* If 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
984 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
985 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
986 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
987 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
988 PurpleBuddy *pb = mbba->matched_buddies->data;
24938
fc6952107e1f Finished moving to api for bonjour
Gary Kramlich <grim@reaperworld.com>
parents: 24562
diff changeset
989 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
990
c41d17a1b8d9 This is the second part of the fix to support having multiple presence records in Bonjour (and also supporting multiple presences using the same IP). Incoming conversations are no longer immediately attached to a buddy - we use an algorithm to match a conversation to a buddy based on the IP and, if possible the "from" attribute of the stream or the first tag in the stream. Thanks to Sjoerd Simons from Telepahy Salut for noticing and 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 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
992 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
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 /* 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
995 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
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 /* 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
998 if (bb->conversation != NULL && bb->conversation != bconv)
c41d17a1b8d9 This is the second part of the fix to support having multiple presence records in Bonjour (and also supporting multiple presences using the same IP). Incoming conversations are no longer immediately attached to a buddy - we use an algorithm to match a conversation to a buddy based on the IP and, if possible the "from" attribute of the stream or the first tag in the stream. Thanks to Sjoerd Simons from Telepahy Salut for noticing and suggesting the algorithm. Fixes #4187. It'd be good if a few people test this.
Daniel Atallah <datallah@pidgin.im>
parents: 21936
diff changeset
999 bonjour_jabber_close_conversation(bb->conversation);
c41d17a1b8d9 This is the second part of the fix to support having multiple presence records in Bonjour (and also supporting multiple presences using the same IP). Incoming conversations are no longer immediately attached to a buddy - we use an algorithm to match a conversation to a buddy based on the IP and, if possible the "from" attribute of the stream or the first tag in the stream. Thanks to Sjoerd Simons from Telepahy Salut for noticing and suggesting the algorithm. Fixes #4187. It'd be good if a few people test this.
Daniel Atallah <datallah@pidgin.im>
parents: 21936
diff changeset
1000
c41d17a1b8d9 This is the second part of the fix to support having multiple presence records in Bonjour (and also supporting multiple presences using the same IP). Incoming conversations are no longer immediately attached to a buddy - we use an algorithm to match a conversation to a buddy based on the IP and, if possible the "from" attribute of the stream or the first tag in the stream. Thanks to Sjoerd Simons from Telepahy Salut for noticing and 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 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
1002 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
1003 }
c41d17a1b8d9 This is the second part of the fix to support having multiple presence records in Bonjour (and also supporting multiple presences using the same IP). Incoming conversations are no longer immediately attached to a buddy - we use an algorithm to match a conversation to a buddy based on the IP and, if possible the "from" attribute of the stream or the first tag in the stream. Thanks to Sjoerd Simons from Telepahy Salut for noticing and suggesting the algorithm. Fixes #4187. It'd be good if a few people test this.
Daniel Atallah <datallah@pidgin.im>
parents: 21936
diff changeset
1004 } 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
1005 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
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 /* 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
1008 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
1009 /* 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
1010 * 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
1011 */
c41d17a1b8d9 This is the second part of the fix to support having multiple presence records in Bonjour (and also supporting multiple presences using the same IP). Incoming conversations are no longer immediately attached to a buddy - we use an algorithm to match a conversation to a buddy based on the IP and, if possible the "from" attribute of the stream or the first tag in the stream. Thanks to Sjoerd Simons from Telepahy Salut for noticing and suggesting the algorithm. Fixes #4187. It'd be good if a few people test this.
Daniel Atallah <datallah@pidgin.im>
parents: 21936
diff changeset
1012 async_bonjour_jabber_close_conversation(bconv);
c41d17a1b8d9 This is the second part of the fix to support having multiple presence records in Bonjour (and also supporting multiple presences using the same IP). Incoming conversations are no longer immediately attached to a buddy - we use an algorithm to match a conversation to a buddy based on the IP and, if possible the "from" attribute of the stream or the first tag in the stream. Thanks to Sjoerd Simons from Telepahy Salut for noticing and suggesting the algorithm. Fixes #4187. It'd be good if a few people test this.
Daniel Atallah <datallah@pidgin.im>
parents: 21936
diff changeset
1013 }
c41d17a1b8d9 This is the second part of the fix to support having multiple presence records in Bonjour (and also supporting multiple presences using the same IP). Incoming conversations are no longer immediately attached to a buddy - we use an algorithm to match a conversation to a buddy based on the IP and, if possible the "from" attribute of the stream or the first tag in the stream. Thanks to Sjoerd Simons from Telepahy Salut for noticing and suggesting the algorithm. Fixes #4187. It'd be good if a few people test this.
Daniel Atallah <datallah@pidgin.im>
parents: 21936
diff changeset
1014
c41d17a1b8d9 This is the second part of the fix to support having multiple presence records in Bonjour (and also supporting multiple presences using the same IP). Incoming conversations are no longer immediately attached to a buddy - we use an algorithm to match a conversation to a buddy based on the IP and, if possible the "from" attribute of the stream or the first tag in the stream. Thanks to Sjoerd Simons from Telepahy Salut for noticing and suggesting the algorithm. Fixes #4187. It'd be good if a few people test this.
Daniel Atallah <datallah@pidgin.im>
parents: 21936
diff changeset
1015 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
1016 g_free(mbba);
17665
26bff2090889 Update Bonjour to do nonblocking I/O correctly.
Daniel Atallah <datallah@pidgin.im>
parents: 17663
diff changeset
1017 }
26bff2090889 Update Bonjour to do nonblocking I/O correctly.
Daniel Atallah <datallah@pidgin.im>
parents: 17663
diff changeset
1018
21528
06532211eb62 Leak fix, cleanup and code reuse.
Daniel Atallah <datallah@pidgin.im>
parents: 21527
diff changeset
1019 static PurpleBuddy *
21944
c41d17a1b8d9 This is the second part of the fix to support having multiple presence records in Bonjour (and also supporting multiple presences using the same IP). Incoming conversations are no longer immediately attached to a buddy - we use an algorithm to match a conversation to a buddy based on the IP and, if possible the "from" attribute of the stream or the first tag in the stream. Thanks to Sjoerd Simons from Telepahy Salut for noticing and suggesting the algorithm. Fixes #4187. It'd be good if a few people test this.
Daniel Atallah <datallah@pidgin.im>
parents: 21936
diff changeset
1020 _find_or_start_conversation(BonjourJabber *jdata, const gchar *to)
11477
98b4f8643569 [gaim-migrate @ 13719]
Mark Doliner <markdoliner@pidgin.im>
parents:
diff changeset
1021 {
21528
06532211eb62 Leak fix, cleanup and code reuse.
Daniel Atallah <datallah@pidgin.im>
parents: 21527
diff changeset
1022 PurpleBuddy *pb = NULL;
06532211eb62 Leak fix, cleanup and code reuse.
Daniel Atallah <datallah@pidgin.im>
parents: 21527
diff changeset
1023 BonjourBuddy *bb = NULL;
06532211eb62 Leak fix, cleanup and code reuse.
Daniel Atallah <datallah@pidgin.im>
parents: 21527
diff changeset
1024
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
1025 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
1026 g_return_val_if_fail(to != NULL, NULL);
11539
fbabe3f89777 [gaim-migrate @ 13794]
Mark Doliner <markdoliner@pidgin.im>
parents: 11515
diff changeset
1027
34728
8efd73063ecf Renamed buddy list functions to more appropriate/simler names.
Ankit Vani <a@nevitus.org>
parents: 34706
diff changeset
1028 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
1029 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
1030 /* 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
1031 return NULL;
11693
1a42a66ca0f8 [gaim-migrate @ 13979]
Mark Doliner <markdoliner@pidgin.im>
parents: 11688
diff changeset
1032
17607
4d7a1c0f169b Improve error handling while connecting to a bonjour buddy.
Daniel Atallah <datallah@pidgin.im>
parents: 17596
diff changeset
1033 /* 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
1034 if (bb->conversation == NULL) {
fe7fa102e766 Convert Bonjour client side to GIO.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39638
diff changeset
1035 GSocketClient *client;
fe7fa102e766 Convert Bonjour client side to GIO.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39638
diff changeset
1036 /* Start with the first IP address. */
fe7fa102e766 Convert Bonjour client side to GIO.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39638
diff changeset
1037 const gchar *ip = bb->ips->data;
21528
06532211eb62 Leak fix, cleanup and code reuse.
Daniel Atallah <datallah@pidgin.im>
parents: 21527
diff changeset
1038
39639
fe7fa102e766 Convert Bonjour client side to GIO.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39638
diff changeset
1039 purple_debug_info("bonjour",
fe7fa102e766 Convert Bonjour client side to GIO.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39638
diff changeset
1040 "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
1041 ip, bb->port_p2pj);
17665
26bff2090889 Update Bonjour to do nonblocking I/O correctly.
Daniel Atallah <datallah@pidgin.im>
parents: 17663
diff changeset
1042
39639
fe7fa102e766 Convert Bonjour client side to GIO.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39638
diff changeset
1043 /* 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
1044 client = g_socket_client_new();
fe7fa102e766 Convert Bonjour client side to GIO.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39638
diff changeset
1045 if (client == NULL) {
fe7fa102e766 Convert Bonjour client side to GIO.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39638
diff changeset
1046 purple_debug_error("bonjour",
fe7fa102e766 Convert Bonjour client side to GIO.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39638
diff changeset
1047 "Unable to connect to buddy (%s).",
fe7fa102e766 Convert Bonjour client side to GIO.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39638
diff changeset
1048 to);
21528
06532211eb62 Leak fix, cleanup and code reuse.
Daniel Atallah <datallah@pidgin.im>
parents: 21527
diff changeset
1049 return NULL;
17665
26bff2090889 Update Bonjour to do nonblocking I/O correctly.
Daniel Atallah <datallah@pidgin.im>
parents: 17663
diff changeset
1050 }
17607
4d7a1c0f169b Improve error handling while connecting to a bonjour buddy.
Daniel Atallah <datallah@pidgin.im>
parents: 17596
diff changeset
1051
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
1052 bb->conversation = bonjour_jabber_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
1053 bb->conversation->ip_link = ip;
39639
fe7fa102e766 Convert Bonjour client side to GIO.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39638
diff changeset
1054
fe7fa102e766 Convert Bonjour client side to GIO.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39638
diff changeset
1055 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
1056 client, ip, bb->port_p2pj,
fe7fa102e766 Convert Bonjour client side to GIO.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39638
diff changeset
1057 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
1058 g_object_unref(client);
17607
4d7a1c0f169b Improve error handling while connecting to a bonjour buddy.
Daniel Atallah <datallah@pidgin.im>
parents: 17596
diff changeset
1059 }
21528
06532211eb62 Leak fix, cleanup and code reuse.
Daniel Atallah <datallah@pidgin.im>
parents: 21527
diff changeset
1060 return pb;
06532211eb62 Leak fix, cleanup and code reuse.
Daniel Atallah <datallah@pidgin.im>
parents: 21527
diff changeset
1061 }
06532211eb62 Leak fix, cleanup and code reuse.
Daniel Atallah <datallah@pidgin.im>
parents: 21527
diff changeset
1062
06532211eb62 Leak fix, cleanup and code reuse.
Daniel Atallah <datallah@pidgin.im>
parents: 21527
diff changeset
1063 int
21944
c41d17a1b8d9 This is the second part of the fix to support having multiple presence records in Bonjour (and also supporting multiple presences using the same IP). Incoming conversations are no longer immediately attached to a buddy - we use an algorithm to match a conversation to a buddy based on the IP and, if possible the "from" attribute of the stream or the first tag in the stream. Thanks to Sjoerd Simons from Telepahy Salut for noticing and suggesting the algorithm. Fixes #4187. It'd be good if a few people test this.
Daniel Atallah <datallah@pidgin.im>
parents: 21936
diff changeset
1064 bonjour_jabber_send_message(BonjourJabber *jdata, const gchar *to, const gchar *body)
21528
06532211eb62 Leak fix, cleanup and code reuse.
Daniel Atallah <datallah@pidgin.im>
parents: 21527
diff changeset
1065 {
34935
686fa55b0deb Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents: 34911
diff changeset
1066 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
1067 gchar *message, *xhtml;
21528
06532211eb62 Leak fix, cleanup and code reuse.
Daniel Atallah <datallah@pidgin.im>
parents: 21527
diff changeset
1068 PurpleBuddy *pb;
06532211eb62 Leak fix, cleanup and code reuse.
Daniel Atallah <datallah@pidgin.im>
parents: 21527
diff changeset
1069 BonjourBuddy *bb;
06532211eb62 Leak fix, cleanup and code reuse.
Daniel Atallah <datallah@pidgin.im>
parents: 21527
diff changeset
1070 int ret;
06532211eb62 Leak fix, cleanup and code reuse.
Daniel Atallah <datallah@pidgin.im>
parents: 21527
diff changeset
1071
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
1072 pb = _find_or_start_conversation(jdata, to);
24938
fc6952107e1f Finished moving to api for bonjour
Gary Kramlich <grim@reaperworld.com>
parents: 24562
diff changeset
1073 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
1074 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
1075 /* 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
1076 return -10000;
06532211eb62 Leak fix, cleanup and code reuse.
Daniel Atallah <datallah@pidgin.im>
parents: 21527
diff changeset
1077 }
06532211eb62 Leak fix, cleanup and code reuse.
Daniel Atallah <datallah@pidgin.im>
parents: 21527
diff changeset
1078
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
1079 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
1080
34935
686fa55b0deb Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents: 34911
diff changeset
1081 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
1082 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
1083 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
1084 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
1085
11826
10ebbc41f163 [gaim-migrate @ 14117]
Richard Laager <rlaager@pidgin.im>
parents: 11823
diff changeset
1086 /* 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
1087 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
1088 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
1089 g_free(message);
11539
fbabe3f89777 [gaim-migrate @ 13794]
Mark Doliner <markdoliner@pidgin.im>
parents: 11515
diff changeset
1090
34935
686fa55b0deb Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents: 34911
diff changeset
1091 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
1092 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
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(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
1095 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
1096 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
1097 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
1098 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
1099 purple_xmlnode_insert_child(node, node2);
11539
fbabe3f89777 [gaim-migrate @ 13794]
Mark Doliner <markdoliner@pidgin.im>
parents: 11515
diff changeset
1100
34935
686fa55b0deb Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents: 34911
diff changeset
1101 node = purple_xmlnode_new_child(message_node, "x");
686fa55b0deb Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents: 34911
diff changeset
1102 purple_xmlnode_set_namespace(node, "jabber:x:event");
686fa55b0deb Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents: 34911
diff changeset
1103 purple_xmlnode_insert_child(node, purple_xmlnode_new("composing"));
11539
fbabe3f89777 [gaim-migrate @ 13794]
Mark Doliner <markdoliner@pidgin.im>
parents: 11515
diff changeset
1104
34935
686fa55b0deb Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents: 34911
diff changeset
1105 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
1106 purple_xmlnode_free(message_node);
11477
98b4f8643569 [gaim-migrate @ 13719]
Mark Doliner <markdoliner@pidgin.im>
parents:
diff changeset
1107
17665
26bff2090889 Update Bonjour to do nonblocking I/O correctly.
Daniel Atallah <datallah@pidgin.im>
parents: 17663
diff changeset
1108 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
1109
15873
78d3aa0fb61e plug some memory leaks
Stu Tomlinson <nosnilmot@pidgin.im>
parents: 15435
diff changeset
1110 g_free(message);
78d3aa0fb61e plug some memory leaks
Stu Tomlinson <nosnilmot@pidgin.im>
parents: 15435
diff changeset
1111
17665
26bff2090889 Update Bonjour to do nonblocking I/O correctly.
Daniel Atallah <datallah@pidgin.im>
parents: 17663
diff changeset
1112 return ret;
11477
98b4f8643569 [gaim-migrate @ 13719]
Mark Doliner <markdoliner@pidgin.im>
parents:
diff changeset
1113 }
98b4f8643569 [gaim-migrate @ 13719]
Mark Doliner <markdoliner@pidgin.im>
parents:
diff changeset
1114
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
1115 static gboolean
c41d17a1b8d9 This is the second part of the fix to support having multiple presence records in Bonjour (and also supporting multiple presences using the same IP). Incoming conversations are no longer immediately attached to a buddy - we use an algorithm to match a conversation to a buddy based on the IP and, if possible the "from" attribute of the stream or the first tag in the stream. Thanks to Sjoerd Simons from Telepahy Salut for noticing and suggesting the algorithm. Fixes #4187. It'd be good if a few people test this.
Daniel Atallah <datallah@pidgin.im>
parents: 21936
diff changeset
1116 _async_bonjour_jabber_close_conversation_cb(gpointer data) {
c41d17a1b8d9 This is the second part of the fix to support having multiple presence records in Bonjour (and also supporting multiple presences using the same IP). Incoming conversations are no longer immediately attached to a buddy - we use an algorithm to match a conversation to a buddy based on the IP and, if possible the "from" attribute of the stream or the first tag in the stream. Thanks to Sjoerd Simons from Telepahy Salut for noticing and suggesting the algorithm. Fixes #4187. It'd be good if a few people test this.
Daniel Atallah <datallah@pidgin.im>
parents: 21936
diff changeset
1117 BonjourJabberConversation *bconv = data;
c41d17a1b8d9 This is the second part of the fix to support having multiple presence records in Bonjour (and also supporting multiple presences using the same IP). Incoming conversations are no longer immediately attached to a buddy - we use an algorithm to match a conversation to a buddy based on the IP and, if possible the "from" attribute of the stream or the first tag in the stream. Thanks to Sjoerd Simons from Telepahy Salut for noticing and suggesting the algorithm. Fixes #4187. It'd be good if a few people test this.
Daniel Atallah <datallah@pidgin.im>
parents: 21936
diff changeset
1118 bonjour_jabber_close_conversation(bconv);
c41d17a1b8d9 This is the second part of the fix to support having multiple presence records in Bonjour (and also supporting multiple presences using the same IP). Incoming conversations are no longer immediately attached to a buddy - we use an algorithm to match a conversation to a buddy based on the IP and, if possible the "from" attribute of the stream or the first tag in the stream. Thanks to Sjoerd Simons from Telepahy Salut for noticing and suggesting the algorithm. Fixes #4187. It'd be good if a few people test this.
Daniel Atallah <datallah@pidgin.im>
parents: 21936
diff changeset
1119 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
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
c41d17a1b8d9 This is the second part of the fix to support having multiple presence records in Bonjour (and also supporting multiple presences using the same IP). Incoming conversations are no longer immediately attached to a buddy - we use an algorithm to match a conversation to a buddy based on the IP and, if possible the "from" attribute of the stream or the first tag in the stream. Thanks to Sjoerd Simons from Telepahy Salut for noticing and 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 void
c41d17a1b8d9 This is the second part of the fix to support having multiple presence records in Bonjour (and also supporting multiple presences using the same IP). Incoming conversations are no longer immediately attached to a buddy - we use an algorithm to match a conversation to a buddy based on the IP and, if possible the "from" attribute of the stream or the first tag in the stream. Thanks to Sjoerd Simons from Telepahy Salut for noticing and suggesting the algorithm. Fixes #4187. It'd be good if a few people test this.
Daniel Atallah <datallah@pidgin.im>
parents: 21936
diff changeset
1123 async_bonjour_jabber_close_conversation(BonjourJabberConversation *bconv) {
32215
0a4e72c8a67e Use accessor functions in a few places
Mark Doliner <markdoliner@pidgin.im>
parents: 31749
diff changeset
1124 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
1125 BonjourData *bd = purple_connection_get_protocol_data(pc);
5b0ecccb3bbb Convert bonjour prpl to use accessor functions purple_connection_get_protocol_data() and purple_connection_set_protocol_data().
Andrew Victor <andrew.victor@mxit.com>
parents: 32215
diff changeset
1126 BonjourJabber *jdata = bd->jabber_data;
21944
c41d17a1b8d9 This is the second part of the fix to support having multiple presence records in Bonjour (and also supporting multiple presences using the same IP). Incoming conversations are no longer immediately attached to a buddy - we use an algorithm to match a conversation to a buddy based on the IP and, if possible the "from" attribute of the stream or the first tag in the stream. Thanks to Sjoerd Simons from Telepahy Salut for noticing and suggesting the algorithm. Fixes #4187. It'd be good if a few people test this.
Daniel Atallah <datallah@pidgin.im>
parents: 21936
diff changeset
1127
c41d17a1b8d9 This is the second part of the fix to support having multiple presence records in Bonjour (and also supporting multiple presences using the same IP). Incoming conversations are no longer immediately attached to a buddy - we use an algorithm to match a conversation to a buddy based on the IP and, if possible the "from" attribute of the stream or the first tag in the stream. Thanks to Sjoerd Simons from Telepahy Salut for noticing and suggesting the algorithm. Fixes #4187. It'd be good if a few people test this.
Daniel Atallah <datallah@pidgin.im>
parents: 21936
diff changeset
1128 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
1129
c41d17a1b8d9 This is the second part of the fix to support having multiple presence records in Bonjour (and also supporting multiple presences using the same IP). Incoming conversations are no longer immediately attached to a buddy - we use an algorithm to match a conversation to a buddy based on the IP and, if possible the "from" attribute of the stream or the first tag in the stream. Thanks to Sjoerd Simons from Telepahy Salut for noticing and suggesting the algorithm. Fixes #4187. It'd be good if a few people test this.
Daniel Atallah <datallah@pidgin.im>
parents: 21936
diff changeset
1130 /* 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
1131 if(bconv->pb != NULL) {
24938
fc6952107e1f Finished moving to api for bonjour
Gary Kramlich <grim@reaperworld.com>
parents: 24562
diff changeset
1132 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
1133 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
1134 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
1135 }
c41d17a1b8d9 This is the second part of the fix to support having multiple presence records in Bonjour (and also supporting multiple presences using the same IP). Incoming conversations are no longer immediately attached to a buddy - we use an algorithm to match a conversation to a buddy based on the IP and, if possible the "from" attribute of the stream or the first tag in the stream. Thanks to Sjoerd Simons from Telepahy Salut for noticing and suggesting the algorithm. Fixes #4187. It'd be good if a few people test this.
Daniel Atallah <datallah@pidgin.im>
parents: 21936
diff changeset
1136
38433
361c801c4536 Remove purple_timeout_* function usage
Mike Ruprecht <cmaiku@gmail.com>
parents: 38358
diff changeset
1137 bconv->close_timeout = g_timeout_add(0, _async_bonjour_jabber_close_conversation_cb, bconv);
21944
c41d17a1b8d9 This is the second part of the fix to support having multiple presence records in Bonjour (and also supporting multiple presences using the same IP). Incoming conversations are no longer immediately attached to a buddy - we use an algorithm to match a conversation to a buddy based on the IP and, if possible the "from" attribute of the stream or the first tag in the stream. Thanks to Sjoerd Simons from Telepahy Salut for noticing and suggesting the algorithm. Fixes #4187. It'd be good if a few people test this.
Daniel Atallah <datallah@pidgin.im>
parents: 21936
diff changeset
1138 }
c41d17a1b8d9 This is the second part of the fix to support having multiple presence records in Bonjour (and also supporting multiple presences using the same IP). Incoming conversations are no longer immediately attached to a buddy - we use an algorithm to match a conversation to a buddy based on the IP and, if possible the "from" attribute of the stream or the first tag in the stream. Thanks to Sjoerd Simons from Telepahy Salut for noticing and suggesting the algorithm. Fixes #4187. It'd be good if a few people test this.
Daniel Atallah <datallah@pidgin.im>
parents: 21936
diff changeset
1139
11539
fbabe3f89777 [gaim-migrate @ 13794]
Mark Doliner <markdoliner@pidgin.im>
parents: 11515
diff changeset
1140 void
17663
fd736a4d91a9 Close conversation connections when logging out of the Bonjour account. This also fixes leakage.
Daniel Atallah <datallah@pidgin.im>
parents: 17662
diff changeset
1141 bonjour_jabber_close_conversation(BonjourJabberConversation *bconv)
11477
98b4f8643569 [gaim-migrate @ 13719]
Mark Doliner <markdoliner@pidgin.im>
parents:
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 BonjourData *bd = NULL;
df4819a9eb48 Remove extra indent in bonjour_jabber_close_conversation.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39190
diff changeset
1144 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
1145
39636
df4819a9eb48 Remove extra indent in bonjour_jabber_close_conversation.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39190
diff changeset
1146 if (bconv == NULL) {
df4819a9eb48 Remove extra indent in bonjour_jabber_close_conversation.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39190
diff changeset
1147 return;
df4819a9eb48 Remove extra indent in bonjour_jabber_close_conversation.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39190
diff changeset
1148 }
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
1149
39636
df4819a9eb48 Remove extra indent in bonjour_jabber_close_conversation.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39190
diff changeset
1150 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
1151 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
1152
39636
df4819a9eb48 Remove extra indent in bonjour_jabber_close_conversation.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39190
diff changeset
1153 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
1154 if (bd) {
df4819a9eb48 Remove extra indent in bonjour_jabber_close_conversation.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39190
diff changeset
1155 bd->jabber_data->pending_conversations = g_slist_remove(
df4819a9eb48 Remove extra indent in bonjour_jabber_close_conversation.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39190
diff changeset
1156 bd->jabber_data->pending_conversations, bconv);
df4819a9eb48 Remove extra indent in bonjour_jabber_close_conversation.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39190
diff changeset
1157 }
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
1158
39636
df4819a9eb48 Remove extra indent in bonjour_jabber_close_conversation.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39190
diff changeset
1159 /* 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
1160 /* 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
1161 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
1162 GSList *xfers, *tmp_next;
df4819a9eb48 Remove extra indent in bonjour_jabber_close_conversation.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39190
diff changeset
1163 xfers = bd->xfer_lists;
df4819a9eb48 Remove extra indent in bonjour_jabber_close_conversation.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39190
diff changeset
1164 while (xfers != NULL) {
df4819a9eb48 Remove extra indent in bonjour_jabber_close_conversation.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39190
diff changeset
1165 PurpleXfer *xfer = xfers->data;
df4819a9eb48 Remove extra indent in bonjour_jabber_close_conversation.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39190
diff changeset
1166 tmp_next = xfers->next;
df4819a9eb48 Remove extra indent in bonjour_jabber_close_conversation.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39190
diff changeset
1167 /* 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
1168 /* 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
1169 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
1170 && (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
1171 || 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
1172 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
1173 }
df4819a9eb48 Remove extra indent in bonjour_jabber_close_conversation.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39190
diff changeset
1174 xfers = tmp_next;
df4819a9eb48 Remove extra indent in bonjour_jabber_close_conversation.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39190
diff changeset
1175 }
df4819a9eb48 Remove extra indent in bonjour_jabber_close_conversation.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39190
diff changeset
1176 }
df4819a9eb48 Remove extra indent in bonjour_jabber_close_conversation.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39190
diff changeset
1177
df4819a9eb48 Remove extra indent in bonjour_jabber_close_conversation.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39190
diff changeset
1178 /* 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
1179 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
1180 /* 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
1181 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
1182 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
1183 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
1184 G_POLLABLE_OUTPUT_STREAM(bconv->output),
fe7fa102e766 Convert Bonjour client side to GIO.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39638
diff changeset
1185 STREAM_END, len, bconv->cancellable,
fe7fa102e766 Convert Bonjour client side to GIO.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39638
diff changeset
1186 NULL) != (gssize)len) {
39636
df4819a9eb48 Remove extra indent in bonjour_jabber_close_conversation.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39190
diff changeset
1187 purple_debug_error("bonjour",
df4819a9eb48 Remove extra indent in bonjour_jabber_close_conversation.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39190
diff changeset
1188 "bonjour_jabber_close_conversation: "
df4819a9eb48 Remove extra indent in bonjour_jabber_close_conversation.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39190
diff changeset
1189 "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
1190 }
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
1191 }
39636
df4819a9eb48 Remove extra indent in bonjour_jabber_close_conversation.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39190
diff changeset
1192 /* 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
1193 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
1194 G_INPUT_STREAM(bconv->input),
fe7fa102e766 Convert Bonjour client side to GIO.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39638
diff changeset
1195 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
1196 }
df4819a9eb48 Remove extra indent in bonjour_jabber_close_conversation.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39190
diff changeset
1197 if (bconv->rx_handler != 0) {
39639
fe7fa102e766 Convert Bonjour client side to GIO.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39638
diff changeset
1198 g_source_remove(bconv->rx_handler);
fe7fa102e766 Convert Bonjour client side to GIO.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39638
diff changeset
1199 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
1200 }
39639
fe7fa102e766 Convert Bonjour client side to GIO.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39638
diff changeset
1201 if (bconv->tx_handler != 0) {
fe7fa102e766 Convert Bonjour client side to GIO.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39638
diff changeset
1202 g_source_remove(bconv->tx_handler);
fe7fa102e766 Convert Bonjour client side to GIO.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39638
diff changeset
1203 bconv->tx_handler = 0;
fe7fa102e766 Convert Bonjour client side to GIO.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39638
diff changeset
1204 }
fe7fa102e766 Convert Bonjour client side to GIO.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39638
diff changeset
1205
fe7fa102e766 Convert Bonjour client side to GIO.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39638
diff changeset
1206 /* Cancel any pending operations. */
fe7fa102e766 Convert Bonjour client side to GIO.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39638
diff changeset
1207 if (bconv->cancellable != NULL) {
fe7fa102e766 Convert Bonjour client side to GIO.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39638
diff changeset
1208 g_cancellable_cancel(bconv->cancellable);
fe7fa102e766 Convert Bonjour client side to GIO.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39638
diff changeset
1209 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
1210 }
11539
fbabe3f89777 [gaim-migrate @ 13794]
Mark Doliner <markdoliner@pidgin.im>
parents: 11515
diff changeset
1211
39636
df4819a9eb48 Remove extra indent in bonjour_jabber_close_conversation.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39190
diff changeset
1212 /* 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
1213 g_clear_object(&bconv->socket);
fe7fa102e766 Convert Bonjour client side to GIO.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39638
diff changeset
1214 bconv->input = NULL;
fe7fa102e766 Convert Bonjour client side to GIO.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39638
diff changeset
1215 bconv->output = NULL;
fe7fa102e766 Convert Bonjour client side to GIO.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39638
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 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
1218 if (bconv->connect_data != NULL) {
df4819a9eb48 Remove extra indent in bonjour_jabber_close_conversation.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39190
diff changeset
1219 purple_proxy_connect_cancel(bconv->connect_data);
df4819a9eb48 Remove extra indent in bonjour_jabber_close_conversation.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39190
diff changeset
1220 }
df4819a9eb48 Remove extra indent in bonjour_jabber_close_conversation.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39190
diff changeset
1221 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
1222 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
1223 g_free(ss->msg);
df4819a9eb48 Remove extra indent in bonjour_jabber_close_conversation.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39190
diff changeset
1224 g_free(ss);
df4819a9eb48 Remove extra indent in bonjour_jabber_close_conversation.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39190
diff changeset
1225 }
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
1226
39636
df4819a9eb48 Remove extra indent in bonjour_jabber_close_conversation.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39190
diff changeset
1227 if (bconv->context != NULL) {
df4819a9eb48 Remove extra indent in bonjour_jabber_close_conversation.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39190
diff changeset
1228 bonjour_parser_setup(bconv);
df4819a9eb48 Remove extra indent in bonjour_jabber_close_conversation.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39190
diff changeset
1229 }
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
1230
39636
df4819a9eb48 Remove extra indent in bonjour_jabber_close_conversation.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39190
diff changeset
1231 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
1232 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
1233 }
22238
c69aff70828d Prevent a crash caused by freed memory being accessed.
Daniel Atallah <datallah@pidgin.im>
parents: 21944
diff changeset
1234
39636
df4819a9eb48 Remove extra indent in bonjour_jabber_close_conversation.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39190
diff changeset
1235 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
1236 g_free(bconv->ip);
df4819a9eb48 Remove extra indent in bonjour_jabber_close_conversation.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39190
diff changeset
1237 g_free(bconv);
11477
98b4f8643569 [gaim-migrate @ 13719]
Mark Doliner <markdoliner@pidgin.im>
parents:
diff changeset
1238 }
98b4f8643569 [gaim-migrate @ 13719]
Mark Doliner <markdoliner@pidgin.im>
parents:
diff changeset
1239
11539
fbabe3f89777 [gaim-migrate @ 13794]
Mark Doliner <markdoliner@pidgin.im>
parents: 11515
diff changeset
1240 void
21944
c41d17a1b8d9 This is the second part of the fix to support having multiple presence records in Bonjour (and also supporting multiple presences using the same IP). Incoming conversations are no longer immediately attached to a buddy - we use an algorithm to match a conversation to a buddy based on the IP and, if possible the "from" attribute of the stream or the first tag in the stream. Thanks to Sjoerd Simons from Telepahy Salut for noticing and suggesting the algorithm. Fixes #4187. It'd be good if a few people test this.
Daniel Atallah <datallah@pidgin.im>
parents: 21936
diff changeset
1241 bonjour_jabber_stop(BonjourJabber *jdata)
11477
98b4f8643569 [gaim-migrate @ 13719]
Mark Doliner <markdoliner@pidgin.im>
parents:
diff changeset
1242 {
17633
b76241c02857 Some more Bonjour cleanup and leak fixing.
Daniel Atallah <datallah@pidgin.im>
parents: 17632
diff changeset
1243 /* 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
1244 if (jdata->service) {
635c8b6ca9a9 Convert Bonjour server to GSocketService.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39636
diff changeset
1245 g_socket_service_stop(jdata->service);
635c8b6ca9a9 Convert Bonjour server to GSocketService.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39636
diff changeset
1246 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
1247 g_clear_object(&jdata->service);
635c8b6ca9a9 Convert Bonjour server to GSocketService.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39636
diff changeset
1248 }
11539
fbabe3f89777 [gaim-migrate @ 13794]
Mark Doliner <markdoliner@pidgin.im>
parents: 11515
diff changeset
1249
17633
b76241c02857 Some more Bonjour cleanup and leak fixing.
Daniel Atallah <datallah@pidgin.im>
parents: 17632
diff changeset
1250 /* 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
1251 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
1252 GSList *buddies, *l;
17633
b76241c02857 Some more Bonjour cleanup and leak fixing.
Daniel Atallah <datallah@pidgin.im>
parents: 17632
diff changeset
1253
34728
8efd73063ecf Renamed buddy list functions to more appropriate/simler names.
Ankit Vani <a@nevitus.org>
parents: 34706
diff changeset
1254 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
1255 for (l = buddies; l; l = l->next) {
24938
fc6952107e1f Finished moving to api for bonjour
Gary Kramlich <grim@reaperworld.com>
parents: 24562
diff changeset
1256 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
1257 if (bb && bb->conversation) {
29932
2ac5b74d0649 Fix two related on-disconnect double frees.
Paul Aurich <darkrain42@pidgin.im>
parents: 29761
diff changeset
1258 /* 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
1259 * when a connection is destroyed */
29932
2ac5b74d0649 Fix two related on-disconnect double frees.
Paul Aurich <darkrain42@pidgin.im>
parents: 29761
diff changeset
1260 bb->conversation->connect_data = NULL;
23160
0aff8f3882f4 applied changes from 3d595739f53a259d5dae408a05f64d2836f02ac9
Daniel Atallah <datallah@pidgin.im>
parents: 23072
diff changeset
1261 bonjour_jabber_close_conversation(bb->conversation);
0aff8f3882f4 applied changes from 3d595739f53a259d5dae408a05f64d2836f02ac9
Daniel Atallah <datallah@pidgin.im>
parents: 23072
diff changeset
1262 bb->conversation = NULL;
0aff8f3882f4 applied changes from 3d595739f53a259d5dae408a05f64d2836f02ac9
Daniel Atallah <datallah@pidgin.im>
parents: 23072
diff changeset
1263 }
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
1264 }
17665
26bff2090889 Update Bonjour to do nonblocking I/O correctly.
Daniel Atallah <datallah@pidgin.im>
parents: 17663
diff changeset
1265
11477
98b4f8643569 [gaim-migrate @ 13719]
Mark Doliner <markdoliner@pidgin.im>
parents:
diff changeset
1266 g_slist_free(buddies);
98b4f8643569 [gaim-migrate @ 13719]
Mark Doliner <markdoliner@pidgin.im>
parents:
diff changeset
1267 }
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
1268
c41d17a1b8d9 This is the second part of the fix to support having multiple presence records in Bonjour (and also supporting multiple presences using the same IP). Incoming conversations are no longer immediately attached to a buddy - we use an algorithm to match a conversation to a buddy based on the IP and, if possible the "from" attribute of the stream or the first tag in the stream. Thanks to Sjoerd Simons from Telepahy Salut for noticing and suggesting the algorithm. Fixes #4187. It'd be good if a few people test this.
Daniel Atallah <datallah@pidgin.im>
parents: 21936
diff changeset
1269 while (jdata->pending_conversations != NULL) {
c41d17a1b8d9 This is the second part of the fix to support having multiple presence records in Bonjour (and also supporting multiple presences using the same IP). Incoming conversations are no longer immediately attached to a buddy - we use an algorithm to match a conversation to a buddy based on the IP and, if possible the "from" attribute of the stream or the first tag in the stream. Thanks to Sjoerd Simons from Telepahy Salut for noticing and suggesting the algorithm. Fixes #4187. It'd be good if a few people test this.
Daniel Atallah <datallah@pidgin.im>
parents: 21936
diff changeset
1270 bonjour_jabber_close_conversation(jdata->pending_conversations->data);
c41d17a1b8d9 This is the second part of the fix to support having multiple presence records in Bonjour (and also supporting multiple presences using the same IP). Incoming conversations are no longer immediately attached to a buddy - we use an algorithm to match a conversation to a buddy based on the IP and, if possible the "from" attribute of the stream or the first tag in the stream. Thanks to Sjoerd Simons from Telepahy Salut for noticing and suggesting the algorithm. Fixes #4187. It'd be good if a few people test this.
Daniel Atallah <datallah@pidgin.im>
parents: 21936
diff changeset
1271 jdata->pending_conversations = g_slist_delete_link(jdata->pending_conversations, jdata->pending_conversations);
c41d17a1b8d9 This is the second part of the fix to support having multiple presence records in Bonjour (and also supporting multiple presences using the same IP). Incoming conversations are no longer immediately attached to a buddy - we use an algorithm to match a conversation to a buddy based on the IP and, if possible the "from" attribute of the stream or the first tag in the stream. Thanks to Sjoerd Simons from Telepahy Salut for noticing and suggesting the algorithm. Fixes #4187. It'd be good if a few people test this.
Daniel Atallah <datallah@pidgin.im>
parents: 21936
diff changeset
1272 }
11477
98b4f8643569 [gaim-migrate @ 13719]
Mark Doliner <markdoliner@pidgin.im>
parents:
diff changeset
1273 }
21524
472e58992083 Patch from some Intel folks to implement file transfer in Bonjour using XEP-0096 and 0065. This hopefully will work with Gaijm (haven't yet tested) and, of course, between libpurple instances; it will not work with Adium or iChat.
Daniel Atallah <datallah@pidgin.im>
parents: 21503
diff changeset
1274
472e58992083 Patch from some Intel folks to implement file transfer in Bonjour using XEP-0096 and 0065. This hopefully will work with Gaijm (haven't yet tested) and, of course, between libpurple instances; it will not work with Adium or iChat.
Daniel Atallah <datallah@pidgin.im>
parents: 21503
diff changeset
1275 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
1276 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
1277 {
34935
686fa55b0deb Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents: 34911
diff changeset
1278 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
1279 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
1280
21548
b19c433f5af2 Cleanup and fix the socks5 proxy connect address to be correct.
Daniel Atallah <datallah@pidgin.im>
parents: 21547
diff changeset
1281 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
1282 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
1283 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
1284
34935
686fa55b0deb Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents: 34911
diff changeset
1285 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
1286
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, "to", to);
686fa55b0deb Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents: 34911
diff changeset
1288 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
1289 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
1290 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
1291 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
1292 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
1293 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
1294 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
1295 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
1296 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
1297 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
1298 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
1299 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
1300 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
1301 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
1302 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
1303 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
1304 default:
34935
686fa55b0deb Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents: 34911
diff changeset
1305 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
1306 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
1307 }
472e58992083 Patch from some Intel folks to implement file transfer in Bonjour using XEP-0096 and 0065. This hopefully will work with Gaijm (haven't yet 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
21548
b19c433f5af2 Cleanup and fix the socks5 proxy connect address to be correct.
Daniel Atallah <datallah@pidgin.im>
parents: 21547
diff changeset
1309 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
1310 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
1311 iq->type = type;
472e58992083 Patch from some Intel folks to implement file transfer in Bonjour using XEP-0096 and 0065. This hopefully will work with Gaijm (haven't yet tested) and, of course, between libpurple instances; it will not work with Adium or iChat.
Daniel Atallah <datallah@pidgin.im>
parents: 21503
diff changeset
1312 iq->data = ((BonjourData*)data)->jabber_data;
472e58992083 Patch from some Intel folks to implement file transfer in Bonjour using XEP-0096 and 0065. This hopefully will work with Gaijm (haven't yet tested) and, of course, between libpurple instances; it will not work with Adium or iChat.
Daniel Atallah <datallah@pidgin.im>
parents: 21503
diff changeset
1313 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
1314
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
1315 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
1316 }
472e58992083 Patch from some Intel folks to implement file transfer in Bonjour using XEP-0096 and 0065. This hopefully will work with Gaijm (haven't yet tested) and, of course, between libpurple instances; it will not work with Adium or iChat.
Daniel Atallah <datallah@pidgin.im>
parents: 21503
diff changeset
1317
472e58992083 Patch from some Intel folks to implement file transfer in Bonjour using XEP-0096 and 0065. This hopefully will work with Gaijm (haven't yet tested) and, of course, between libpurple instances; it will not work with Adium or iChat.
Daniel Atallah <datallah@pidgin.im>
parents: 21503
diff changeset
1318 static 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
1319 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
1320 {
472e58992083 Patch from some Intel folks to implement file transfer in Bonjour using XEP-0096 and 0065. This hopefully will work with Gaijm (haven't yet tested) and, of course, between libpurple instances; it will not work with Adium or iChat.
Daniel Atallah <datallah@pidgin.im>
parents: 21503
diff changeset
1321 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
1322 GSList *l = NULL;
25097
c950e59e30bf Further cleanup to fix CID 373.
Daniel Atallah <datallah@pidgin.im>
parents: 25096
diff changeset
1323 PurpleAccount *acc = purple_buddy_get_account(pb);
21524
472e58992083 Patch from some Intel folks to implement file transfer in Bonjour using XEP-0096 and 0065. This hopefully will work with Gaijm (haven't yet tested) and, of course, between libpurple instances; it will not work with Adium or iChat.
Daniel Atallah <datallah@pidgin.im>
parents: 21503
diff changeset
1324
25097
c950e59e30bf Further cleanup to fix CID 373.
Daniel Atallah <datallah@pidgin.im>
parents: 25096
diff changeset
1325 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
1326 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
1327
24398
4865c2ee6ea8 Start hiding blist.h internals in prpls.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 24333
diff changeset
1328 acc = purple_buddy_get_account(pb);
21524
472e58992083 Patch from some Intel folks to implement file transfer in Bonjour using XEP-0096 and 0065. This hopefully will work with Gaijm (haven't yet tested) and, of course, between libpurple instances; it will not work with Adium or iChat.
Daniel Atallah <datallah@pidgin.im>
parents: 21503
diff changeset
1329
34578
cfb2f856a5d0 Refactored prpls according to the changed PurpleAccount API
Ankit Vani <a@nevitus.org>
parents: 34529
diff changeset
1330 for(l = purple_account_privacy_get_denied(acc); l != NULL; l = l->next) {
24938
fc6952107e1f Finished moving to api for bonjour
Gary Kramlich <grim@reaperworld.com>
parents: 24562
diff changeset
1331 const gchar *name = purple_buddy_get_name(pb);
30825
87a79bbdc985 The hostname used for a bonjour account should always be the current machine
Daniel Atallah <datallah@pidgin.im>
parents: 30626
diff changeset
1332 const gchar *username = bonjour_get_jid(acc);
24938
fc6952107e1f Finished moving to api for bonjour
Gary Kramlich <grim@reaperworld.com>
parents: 24562
diff changeset
1333
fc6952107e1f Finished moving to api for bonjour
Gary Kramlich <grim@reaperworld.com>
parents: 24562
diff changeset
1334 if(!purple_utf8_strcasecmp(name, (char *)l->data)) {
fc6952107e1f Finished moving to api for bonjour
Gary Kramlich <grim@reaperworld.com>
parents: 24562
diff changeset
1335 purple_debug_info("bonjour", "%s has been blocked by %s.\n", name, username);
21524
472e58992083 Patch from some Intel folks to implement file transfer in Bonjour using XEP-0096 and 0065. This hopefully will work with Gaijm (haven't yet tested) and, of course, between libpurple instances; it will not work with Adium or iChat.
Daniel Atallah <datallah@pidgin.im>
parents: 21503
diff changeset
1336 blocked = TRUE;
472e58992083 Patch from some Intel folks to implement file transfer in Bonjour using XEP-0096 and 0065. This hopefully will work with Gaijm (haven't yet tested) and, of course, between libpurple instances; it will not work with Adium or iChat.
Daniel Atallah <datallah@pidgin.im>
parents: 21503
diff changeset
1337 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
1338 }
472e58992083 Patch from some Intel folks to implement file transfer in Bonjour using XEP-0096 and 0065. This hopefully will work with Gaijm (haven't yet tested) and, of course, between libpurple instances; it will not work with Adium or iChat.
Daniel Atallah <datallah@pidgin.im>
parents: 21503
diff changeset
1339 }
472e58992083 Patch from some Intel folks to implement file transfer in Bonjour using XEP-0096 and 0065. This hopefully will work with Gaijm (haven't yet tested) and, of course, between libpurple instances; it will not work with Adium or iChat.
Daniel Atallah <datallah@pidgin.im>
parents: 21503
diff changeset
1340 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
1341 }
472e58992083 Patch from some Intel folks to implement file transfer in Bonjour using XEP-0096 and 0065. This hopefully will work with Gaijm (haven't yet tested) and, of course, between libpurple instances; it will not work with Adium or iChat.
Daniel Atallah <datallah@pidgin.im>
parents: 21503
diff changeset
1342
472e58992083 Patch from some Intel folks to implement file transfer in Bonjour using XEP-0096 and 0065. This hopefully will work with Gaijm (haven't yet 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 static void
34935
686fa55b0deb Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents: 34911
diff changeset
1344 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
1345 {
25140
7c494d2bc5e4 propagate from branch 'im.pidgin.pidgin' (head 009f3ea551248605298fbf1b88d7a873b2a6c7a3)
Richard Laager <rlaager@pidgin.im>
parents: 25097 24954
diff changeset
1346 PurpleAccount *account;
7c494d2bc5e4 propagate from branch 'im.pidgin.pidgin' (head 009f3ea551248605298fbf1b88d7a873b2a6c7a3)
Richard Laager <rlaager@pidgin.im>
parents: 25097 24954
diff changeset
1347 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
1348
472e58992083 Patch from some Intel folks to implement file transfer in Bonjour using XEP-0096 and 0065. This hopefully will work with Gaijm (haven't yet 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 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
1350 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
1351
38213
fe644fbe41c9 Fix some build warnings
dx <dx@dxzone.com.ar>
parents: 36256
diff changeset
1352 account = purple_buddy_get_account(pb);
fe644fbe41c9 Fix some build warnings
dx <dx@dxzone.com.ar>
parents: 36256
diff changeset
1353 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
1354
34935
686fa55b0deb Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents: 34911
diff changeset
1355 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
1356 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
1357 else
25140
7c494d2bc5e4 propagate from branch 'im.pidgin.pidgin' (head 009f3ea551248605298fbf1b88d7a873b2a6c7a3)
Richard Laager <rlaager@pidgin.im>
parents: 25097 24954
diff changeset
1358 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
1359 }
472e58992083 Patch from some Intel folks to implement file transfer in Bonjour using XEP-0096 and 0065. This hopefully will work with Gaijm (haven't yet tested) and, of course, between libpurple instances; it will not work with Adium or iChat.
Daniel Atallah <datallah@pidgin.im>
parents: 21503
diff changeset
1360
472e58992083 Patch from some Intel folks to implement file transfer in Bonjour using XEP-0096 and 0065. This hopefully will work with Gaijm (haven't yet tested) and, of course, between libpurple instances; it will not work with Adium or iChat.
Daniel Atallah <datallah@pidgin.im>
parents: 21503
diff changeset
1361 int
21548
b19c433f5af2 Cleanup and fix the socks5 proxy connect address to be correct.
Daniel Atallah <datallah@pidgin.im>
parents: 21547
diff changeset
1362 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
1363 {
472e58992083 Patch from some Intel folks to implement file transfer in Bonjour using XEP-0096 and 0065. This hopefully will work with Gaijm (haven't yet tested) and, of course, between libpurple instances; it will not work with Adium or iChat.
Daniel Atallah <datallah@pidgin.im>
parents: 21503
diff changeset
1364 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
1365 PurpleBuddy *pb = NULL;
21528
06532211eb62 Leak fix, cleanup and code reuse.
Daniel Atallah <datallah@pidgin.im>
parents: 21527
diff changeset
1366
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
1367 /* start the talk, reuse the message socket */
21944
c41d17a1b8d9 This is the second part of the fix to support having multiple presence records in Bonjour (and also supporting multiple presences using the same IP). Incoming conversations are no longer immediately attached to a buddy - we use an algorithm to match a conversation to a buddy based on the IP and, if possible the "from" attribute of the stream or the first tag in the stream. Thanks to Sjoerd Simons from Telepahy Salut for noticing and suggesting the algorithm. Fixes #4187. It'd be good if a few people test this.
Daniel Atallah <datallah@pidgin.im>
parents: 21936
diff changeset
1368 pb = _find_or_start_conversation((BonjourJabber*) iq->data, iq->to);
21524
472e58992083 Patch from some Intel folks to implement file transfer in Bonjour using XEP-0096 and 0065. This hopefully will work with Gaijm (haven't yet tested) and, of course, between libpurple instances; it will not work with Adium or iChat.
Daniel Atallah <datallah@pidgin.im>
parents: 21503
diff changeset
1369 /* Send the message */
21528
06532211eb62 Leak fix, cleanup and code reuse.
Daniel Atallah <datallah@pidgin.im>
parents: 21527
diff changeset
1370 if (pb != NULL) {
06532211eb62 Leak fix, cleanup and code reuse.
Daniel Atallah <datallah@pidgin.im>
parents: 21527
diff changeset
1371 /* 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
1372 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
1373 ret = _send_data(pb, msg);
21528
06532211eb62 Leak fix, cleanup and code reuse.
Daniel Atallah <datallah@pidgin.im>
parents: 21527
diff changeset
1374 g_free(msg);
06532211eb62 Leak fix, cleanup and code reuse.
Daniel Atallah <datallah@pidgin.im>
parents: 21527
diff changeset
1375 }
21548
b19c433f5af2 Cleanup and fix the socks5 proxy connect address to be correct.
Daniel Atallah <datallah@pidgin.im>
parents: 21547
diff changeset
1376
34935
686fa55b0deb Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents: 34911
diff changeset
1377 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
1378 iq->node = NULL;
b19c433f5af2 Cleanup and fix the socks5 proxy connect address to be correct.
Daniel Atallah <datallah@pidgin.im>
parents: 21547
diff changeset
1379 g_free(iq);
21528
06532211eb62 Leak fix, cleanup and code reuse.
Daniel Atallah <datallah@pidgin.im>
parents: 21527
diff changeset
1380
06532211eb62 Leak fix, cleanup and code reuse.
Daniel Atallah <datallah@pidgin.im>
parents: 21527
diff changeset
1381 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
1382 }
472e58992083 Patch from some Intel folks to implement file transfer in Bonjour using XEP-0096 and 0065. This hopefully will work with Gaijm (haven't yet tested) and, of course, between libpurple instances; it will not work with Adium or iChat.
Daniel Atallah <datallah@pidgin.im>
parents: 21503
diff changeset
1383
29761
0f6862f2782f Implementation of IPv6 support for Bonjour
Daniel Atallah <datallah@pidgin.im>
parents: 27625
diff changeset
1384 /* This returns a list containing all non-localhost IPs */
0f6862f2782f Implementation of IPv6 support for Bonjour
Daniel Atallah <datallah@pidgin.im>
parents: 27625
diff changeset
1385 GSList *
0f6862f2782f Implementation of IPv6 support for Bonjour
Daniel Atallah <datallah@pidgin.im>
parents: 27625
diff changeset
1386 bonjour_jabber_get_local_ips(int fd)
21524
472e58992083 Patch from some Intel folks to implement file transfer in Bonjour using XEP-0096 and 0065. This hopefully will work with Gaijm (haven't yet tested) and, of course, between libpurple instances; it will not work with Adium or iChat.
Daniel Atallah <datallah@pidgin.im>
parents: 21503
diff changeset
1387 {
29761
0f6862f2782f Implementation of IPv6 support for Bonjour
Daniel Atallah <datallah@pidgin.im>
parents: 27625
diff changeset
1388 GSList *ips = NULL;
0f6862f2782f Implementation of IPv6 support for Bonjour
Daniel Atallah <datallah@pidgin.im>
parents: 27625
diff changeset
1389 const char *address_text;
0f6862f2782f Implementation of IPv6 support for Bonjour
Daniel Atallah <datallah@pidgin.im>
parents: 27625
diff changeset
1390 int ret;
0f6862f2782f Implementation of IPv6 support for Bonjour
Daniel Atallah <datallah@pidgin.im>
parents: 27625
diff changeset
1391
0f6862f2782f Implementation of IPv6 support for Bonjour
Daniel Atallah <datallah@pidgin.im>
parents: 27625
diff changeset
1392 #ifdef HAVE_GETIFADDRS /* This is required for IPv6 */
0f6862f2782f Implementation of IPv6 support for Bonjour
Daniel Atallah <datallah@pidgin.im>
parents: 27625
diff changeset
1393 struct ifaddrs *ifap, *ifa;
35676
d9fdd45925ec Fix some of invalid alignment warnings
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35578
diff changeset
1394 common_sockaddr_t addr;
29761
0f6862f2782f Implementation of IPv6 support for Bonjour
Daniel Atallah <datallah@pidgin.im>
parents: 27625
diff changeset
1395 char addrstr[INET6_ADDRSTRLEN];
0f6862f2782f Implementation of IPv6 support for Bonjour
Daniel Atallah <datallah@pidgin.im>
parents: 27625
diff changeset
1396
0f6862f2782f Implementation of IPv6 support for Bonjour
Daniel Atallah <datallah@pidgin.im>
parents: 27625
diff changeset
1397 ret = getifaddrs(&ifap);
0f6862f2782f Implementation of IPv6 support for Bonjour
Daniel Atallah <datallah@pidgin.im>
parents: 27625
diff changeset
1398 if (ret != 0) {
0f6862f2782f Implementation of IPv6 support for Bonjour
Daniel Atallah <datallah@pidgin.im>
parents: 27625
diff changeset
1399 const char *error = g_strerror(errno);
0f6862f2782f Implementation of IPv6 support for Bonjour
Daniel Atallah <datallah@pidgin.im>
parents: 27625
diff changeset
1400 purple_debug_error("bonjour", "getifaddrs() error: %s\n", error ? error : "(null)");
0f6862f2782f Implementation of IPv6 support for Bonjour
Daniel Atallah <datallah@pidgin.im>
parents: 27625
diff changeset
1401 return NULL;
0f6862f2782f Implementation of IPv6 support for Bonjour
Daniel Atallah <datallah@pidgin.im>
parents: 27625
diff changeset
1402 }
0f6862f2782f Implementation of IPv6 support for Bonjour
Daniel Atallah <datallah@pidgin.im>
parents: 27625
diff changeset
1403
0f6862f2782f Implementation of IPv6 support for Bonjour
Daniel Atallah <datallah@pidgin.im>
parents: 27625
diff changeset
1404 for (ifa = ifap; ifa != NULL; ifa = ifa->ifa_next) {
0f6862f2782f Implementation of IPv6 support for Bonjour
Daniel Atallah <datallah@pidgin.im>
parents: 27625
diff changeset
1405 if (!(ifa->ifa_flags & IFF_RUNNING) || (ifa->ifa_flags & IFF_LOOPBACK) || ifa->ifa_addr == NULL)
0f6862f2782f Implementation of IPv6 support for Bonjour
Daniel Atallah <datallah@pidgin.im>
parents: 27625
diff changeset
1406 continue;
0f6862f2782f Implementation of IPv6 support for Bonjour
Daniel Atallah <datallah@pidgin.im>
parents: 27625
diff changeset
1407
35676
d9fdd45925ec Fix some of invalid alignment warnings
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35578
diff changeset
1408 memcpy(&addr, ifa->ifa_addr, sizeof(addr));
29761
0f6862f2782f Implementation of IPv6 support for Bonjour
Daniel Atallah <datallah@pidgin.im>
parents: 27625
diff changeset
1409 address_text = NULL;
35676
d9fdd45925ec Fix some of invalid alignment warnings
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35578
diff changeset
1410 switch (addr.sa.sa_family) {
29761
0f6862f2782f Implementation of IPv6 support for Bonjour
Daniel Atallah <datallah@pidgin.im>
parents: 27625
diff changeset
1411 case AF_INET:
35676
d9fdd45925ec Fix some of invalid alignment warnings
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35578
diff changeset
1412 address_text = inet_ntop(addr.sa.sa_family,
d9fdd45925ec Fix some of invalid alignment warnings
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35578
diff changeset
1413 &addr.in.sin_addr,
29761
0f6862f2782f Implementation of IPv6 support for Bonjour
Daniel Atallah <datallah@pidgin.im>
parents: 27625
diff changeset
1414 addrstr, sizeof(addrstr));
0f6862f2782f Implementation of IPv6 support for Bonjour
Daniel Atallah <datallah@pidgin.im>
parents: 27625
diff changeset
1415 break;
0f6862f2782f Implementation of IPv6 support for Bonjour
Daniel Atallah <datallah@pidgin.im>
parents: 27625
diff changeset
1416 #ifdef PF_INET6
0f6862f2782f Implementation of IPv6 support for Bonjour
Daniel Atallah <datallah@pidgin.im>
parents: 27625
diff changeset
1417 case AF_INET6:
35676
d9fdd45925ec Fix some of invalid alignment warnings
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35578
diff changeset
1418 address_text = inet_ntop(addr.sa.sa_family,
d9fdd45925ec Fix some of invalid alignment warnings
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35578
diff changeset
1419 &addr.in6.sin6_addr,
29761
0f6862f2782f Implementation of IPv6 support for Bonjour
Daniel Atallah <datallah@pidgin.im>
parents: 27625
diff changeset
1420 addrstr, sizeof(addrstr));
0f6862f2782f Implementation of IPv6 support for Bonjour
Daniel Atallah <datallah@pidgin.im>
parents: 27625
diff changeset
1421 break;
0f6862f2782f Implementation of IPv6 support for Bonjour
Daniel Atallah <datallah@pidgin.im>
parents: 27625
diff changeset
1422 #endif
0f6862f2782f Implementation of IPv6 support for Bonjour
Daniel Atallah <datallah@pidgin.im>
parents: 27625
diff changeset
1423 }
0f6862f2782f Implementation of IPv6 support for Bonjour
Daniel Atallah <datallah@pidgin.im>
parents: 27625
diff changeset
1424
0f6862f2782f Implementation of IPv6 support for Bonjour
Daniel Atallah <datallah@pidgin.im>
parents: 27625
diff changeset
1425 if (address_text != NULL) {
35676
d9fdd45925ec Fix some of invalid alignment warnings
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35578
diff changeset
1426 if (addr.sa.sa_family == AF_INET)
29761
0f6862f2782f Implementation of IPv6 support for Bonjour
Daniel Atallah <datallah@pidgin.im>
parents: 27625
diff changeset
1427 ips = g_slist_append(ips, g_strdup(address_text));
0f6862f2782f Implementation of IPv6 support for Bonjour
Daniel Atallah <datallah@pidgin.im>
parents: 27625
diff changeset
1428 else
0f6862f2782f Implementation of IPv6 support for Bonjour
Daniel Atallah <datallah@pidgin.im>
parents: 27625
diff changeset
1429 ips = g_slist_prepend(ips, g_strdup(address_text));
0f6862f2782f Implementation of IPv6 support for Bonjour
Daniel Atallah <datallah@pidgin.im>
parents: 27625
diff changeset
1430 }
0f6862f2782f Implementation of IPv6 support for Bonjour
Daniel Atallah <datallah@pidgin.im>
parents: 27625
diff changeset
1431 }
0f6862f2782f Implementation of IPv6 support for Bonjour
Daniel Atallah <datallah@pidgin.im>
parents: 27625
diff changeset
1432
0f6862f2782f Implementation of IPv6 support for Bonjour
Daniel Atallah <datallah@pidgin.im>
parents: 27625
diff changeset
1433 freeifaddrs(ifap);
0f6862f2782f Implementation of IPv6 support for Bonjour
Daniel Atallah <datallah@pidgin.im>
parents: 27625
diff changeset
1434 #else
21524
472e58992083 Patch from some Intel folks to implement file transfer in Bonjour using XEP-0096 and 0065. This hopefully will work with Gaijm (haven't yet tested) and, of course, between libpurple instances; it will not work with Adium or iChat.
Daniel Atallah <datallah@pidgin.im>
parents: 21503
diff changeset
1435 char *tmp;
472e58992083 Patch from some Intel folks to implement file transfer in Bonjour using XEP-0096 and 0065. This hopefully will work with Gaijm (haven't yet tested) and, of course, between libpurple instances; it will not work with Adium or iChat.
Daniel Atallah <datallah@pidgin.im>
parents: 21503
diff changeset
1436 struct ifconf ifc;
472e58992083 Patch from some Intel folks to implement file transfer in Bonjour using XEP-0096 and 0065. This hopefully will work with Gaijm (haven't yet tested) and, of course, between libpurple instances; it will not work with Adium or iChat.
Daniel Atallah <datallah@pidgin.im>
parents: 21503
diff changeset
1437 struct ifreq *ifr;
29761
0f6862f2782f Implementation of IPv6 support for Bonjour
Daniel Atallah <datallah@pidgin.im>
parents: 27625
diff changeset
1438 char buffer[1024];
21524
472e58992083 Patch from some Intel folks to implement file transfer in Bonjour using XEP-0096 and 0065. This hopefully will work with Gaijm (haven't yet tested) and, of course, between libpurple instances; it will not work with Adium or iChat.
Daniel Atallah <datallah@pidgin.im>
parents: 21503
diff changeset
1439 struct sockaddr_in *sinptr;
472e58992083 Patch from some Intel folks to implement file transfer in Bonjour using XEP-0096 and 0065. This hopefully will work with Gaijm (haven't yet tested) and, of course, between libpurple instances; it will not work with Adium or iChat.
Daniel Atallah <datallah@pidgin.im>
parents: 21503
diff changeset
1440 int source = fd;
472e58992083 Patch from some Intel folks to implement file transfer in Bonjour using XEP-0096 and 0065. This hopefully will work with Gaijm (haven't yet tested) and, of course, between libpurple instances; it will not work with Adium or iChat.
Daniel Atallah <datallah@pidgin.im>
parents: 21503
diff changeset
1441
472e58992083 Patch from some Intel folks to implement file transfer in Bonjour using XEP-0096 and 0065. This hopefully will work with Gaijm (haven't yet tested) and, of course, between libpurple instances; it will not work with Adium or iChat.
Daniel Atallah <datallah@pidgin.im>
parents: 21503
diff changeset
1442 if (fd < 0)
472e58992083 Patch from some Intel folks to implement file transfer in Bonjour using XEP-0096 and 0065. This hopefully will work with Gaijm (haven't yet tested) and, of course, between libpurple instances; it will not work with Adium or iChat.
Daniel Atallah <datallah@pidgin.im>
parents: 21503
diff changeset
1443 source = socket(PF_INET, SOCK_STREAM, 0);
472e58992083 Patch from some Intel folks to implement file transfer in Bonjour using XEP-0096 and 0065. This hopefully will work with Gaijm (haven't yet tested) and, of course, between libpurple instances; it will not work with Adium or iChat.
Daniel Atallah <datallah@pidgin.im>
parents: 21503
diff changeset
1444
472e58992083 Patch from some Intel folks to implement file transfer in Bonjour using XEP-0096 and 0065. This hopefully will work with Gaijm (haven't yet tested) and, of course, between libpurple instances; it will not work with Adium or iChat.
Daniel Atallah <datallah@pidgin.im>
parents: 21503
diff changeset
1445 ifc.ifc_len = sizeof(buffer);
472e58992083 Patch from some Intel folks to implement file transfer in Bonjour using XEP-0096 and 0065. This hopefully will work with Gaijm (haven't yet tested) and, of course, between libpurple instances; it will not work with Adium or iChat.
Daniel Atallah <datallah@pidgin.im>
parents: 21503
diff changeset
1446 ifc.ifc_req = (struct ifreq *)buffer;
29761
0f6862f2782f Implementation of IPv6 support for Bonjour
Daniel Atallah <datallah@pidgin.im>
parents: 27625
diff changeset
1447 ret = ioctl(source, SIOCGIFCONF, &ifc);
21524
472e58992083 Patch from some Intel folks to implement file transfer in Bonjour using XEP-0096 and 0065. This hopefully will work with Gaijm (haven't yet tested) and, of course, between libpurple instances; it will not work with Adium or iChat.
Daniel Atallah <datallah@pidgin.im>
parents: 21503
diff changeset
1448
472e58992083 Patch from some Intel folks to implement file transfer in Bonjour using XEP-0096 and 0065. This hopefully will work with Gaijm (haven't yet tested) and, of course, between libpurple instances; it will not work with Adium or iChat.
Daniel Atallah <datallah@pidgin.im>
parents: 21503
diff changeset
1449 if (fd < 0)
472e58992083 Patch from some Intel folks to implement file transfer in Bonjour using XEP-0096 and 0065. This hopefully will work with Gaijm (haven't yet tested) and, of course, between libpurple instances; it will not work with Adium or iChat.
Daniel Atallah <datallah@pidgin.im>
parents: 21503
diff changeset
1450 close(source);
21527
fe89b20df0f7 I thought I was just fixing a leak in this commit, but it turns out I forgot to add the new files in the previous commit.
Daniel Atallah <datallah@pidgin.im>
parents: 21524
diff changeset
1451
29761
0f6862f2782f Implementation of IPv6 support for Bonjour
Daniel Atallah <datallah@pidgin.im>
parents: 27625
diff changeset
1452 if (ret < 0) {
0f6862f2782f Implementation of IPv6 support for Bonjour
Daniel Atallah <datallah@pidgin.im>
parents: 27625
diff changeset
1453 const char *error = g_strerror(errno);
0f6862f2782f Implementation of IPv6 support for Bonjour
Daniel Atallah <datallah@pidgin.im>
parents: 27625
diff changeset
1454 purple_debug_error("bonjour", "ioctl(SIOCGIFCONF) error: %s\n", error ? error : "(null)");
0f6862f2782f Implementation of IPv6 support for Bonjour
Daniel Atallah <datallah@pidgin.im>
parents: 27625
diff changeset
1455 return NULL;
0f6862f2782f Implementation of IPv6 support for Bonjour
Daniel Atallah <datallah@pidgin.im>
parents: 27625
diff changeset
1456 }
0f6862f2782f Implementation of IPv6 support for Bonjour
Daniel Atallah <datallah@pidgin.im>
parents: 27625
diff changeset
1457
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
1458 tmp = buffer;
29761
0f6862f2782f Implementation of IPv6 support for Bonjour
Daniel Atallah <datallah@pidgin.im>
parents: 27625
diff changeset
1459 while (tmp < buffer + ifc.ifc_len) {
21524
472e58992083 Patch from some Intel folks to implement file transfer in Bonjour using XEP-0096 and 0065. This hopefully will work with Gaijm (haven't yet tested) and, of course, between libpurple instances; it will not work with Adium or iChat.
Daniel Atallah <datallah@pidgin.im>
parents: 21503
diff changeset
1460 ifr = (struct ifreq *)tmp;
472e58992083 Patch from some Intel folks to implement file transfer in Bonjour using XEP-0096 and 0065. This hopefully will work with Gaijm (haven't yet tested) and, of course, between libpurple instances; it will not work with Adium or iChat.
Daniel Atallah <datallah@pidgin.im>
parents: 21503
diff changeset
1461 tmp += HX_SIZE_OF_IFREQ(*ifr);
472e58992083 Patch from some Intel folks to implement file transfer in Bonjour using XEP-0096 and 0065. This hopefully will work with Gaijm (haven't yet tested) and, of course, between libpurple instances; it will not work with Adium or iChat.
Daniel Atallah <datallah@pidgin.im>
parents: 21503
diff changeset
1462
29761
0f6862f2782f Implementation of IPv6 support for Bonjour
Daniel Atallah <datallah@pidgin.im>
parents: 27625
diff changeset
1463 if (ifr->ifr_addr.sa_family == AF_INET) {
21524
472e58992083 Patch from some Intel folks to implement file transfer in Bonjour using XEP-0096 and 0065. This hopefully will work with Gaijm (haven't yet tested) and, of course, between libpurple instances; it will not work with Adium or iChat.
Daniel Atallah <datallah@pidgin.im>
parents: 21503
diff changeset
1464 sinptr = (struct sockaddr_in *)&ifr->ifr_addr;
29761
0f6862f2782f Implementation of IPv6 support for Bonjour
Daniel Atallah <datallah@pidgin.im>
parents: 27625
diff changeset
1465 if ((ntohl(sinptr->sin_addr.s_addr) >> 24) != 127) {
0f6862f2782f Implementation of IPv6 support for Bonjour
Daniel Atallah <datallah@pidgin.im>
parents: 27625
diff changeset
1466 address_text = inet_ntoa(sinptr->sin_addr);
0f6862f2782f Implementation of IPv6 support for Bonjour
Daniel Atallah <datallah@pidgin.im>
parents: 27625
diff changeset
1467 ips = g_slist_prepend(ips, g_strdup(address_text));
21524
472e58992083 Patch from some Intel folks to implement file transfer in Bonjour using XEP-0096 and 0065. This hopefully will work with Gaijm (haven't yet tested) and, of course, between libpurple instances; it will not work with Adium or iChat.
Daniel Atallah <datallah@pidgin.im>
parents: 21503
diff changeset
1468 }
39636
df4819a9eb48 Remove extra indent in bonjour_jabber_close_conversation.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39190
diff changeset
1469 }
29761
0f6862f2782f Implementation of IPv6 support for Bonjour
Daniel Atallah <datallah@pidgin.im>
parents: 27625
diff changeset
1470 }
0f6862f2782f Implementation of IPv6 support for Bonjour
Daniel Atallah <datallah@pidgin.im>
parents: 27625
diff changeset
1471 #endif
21524
472e58992083 Patch from some Intel folks to implement file transfer in Bonjour using XEP-0096 and 0065. This hopefully will work with Gaijm (haven't yet tested) and, of course, between libpurple instances; it will not work with Adium or iChat.
Daniel Atallah <datallah@pidgin.im>
parents: 21503
diff changeset
1472
29761
0f6862f2782f Implementation of IPv6 support for Bonjour
Daniel Atallah <datallah@pidgin.im>
parents: 27625
diff changeset
1473 return ips;
21524
472e58992083 Patch from some Intel folks to implement file transfer in Bonjour using XEP-0096 and 0065. This hopefully will work with Gaijm (haven't yet tested) and, of course, between libpurple instances; it will not work with Adium or iChat.
Daniel Atallah <datallah@pidgin.im>
parents: 21503
diff changeset
1474 }
32058
95953bd2f239 Append interface ID only to local interfaces for IPv6 Bonjour.
Linus Lüssing <linus.luessing@web.de>
parents: 31749
diff changeset
1475
95953bd2f239 Append interface ID only to local interfaces for IPv6 Bonjour.
Linus Lüssing <linus.luessing@web.de>
parents: 31749
diff changeset
1476 void
32069
fc06dd6b7c3f Fix the compilation of the Bonjour prpl on Windows.
Eion Robb <eion@robbmob.com>
parents: 32058
diff changeset
1477 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
1478 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
1479 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
1480
95953bd2f239 Append interface ID only to local interfaces for IPv6 Bonjour.
Linus Lüssing <linus.luessing@web.de>
parents: 31749
diff changeset
1481 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
1482 return;
95953bd2f239 Append interface ID only to local interfaces for IPv6 Bonjour.
Linus Lüssing <linus.luessing@web.de>
parents: 31749
diff changeset
1483
95953bd2f239 Append interface ID only to local interfaces for IPv6 Bonjour.
Linus Lüssing <linus.luessing@web.de>
parents: 31749
diff changeset
1484 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
1485 !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
1486 return;
95953bd2f239 Append interface ID only to local interfaces for IPv6 Bonjour.
Linus Lüssing <linus.luessing@web.de>
parents: 31749
diff changeset
1487
95953bd2f239 Append interface ID only to local interfaces for IPv6 Bonjour.
Linus Lüssing <linus.luessing@web.de>
parents: 31749
diff changeset
1488 snprintf(ip + strlen(ip), len_remain, "%%%d",
32069
fc06dd6b7c3f Fix the compilation of the Bonjour prpl on Windows.
Eion Robb <eion@robbmob.com>
parents: 32058
diff changeset
1489 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
1490 }

mercurial