annotate libpurple/protocols/bonjour/jabber.c @ 21438:4fe9acb6b514

Some platforms require additional includes before net/if.h, and this is taken care of in internal.h. This fixes bonjour compile on FreeBSD.
author Ethan Blanton <elb@pidgin.im>
date Tue, 27 Nov 2007 15:56:20 +0000
parents db7fa42845f6
children 919338d399ae
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1 /*
15822
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15811
diff changeset
2 * purple - Bonjour Protocol Plugin
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
3 *
15822
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15811
diff changeset
4 * Purple is the legal property of its developers, whose names are too numerous
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
5 * to list here. Please refer to the COPYRIGHT file distributed with this
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
6 * source distribution.
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
7 *
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
8 * This program is free software; you can redistribute it and/or modify
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
9 * it under the terms of the GNU General Public License as published by
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
10 * the Free Software Foundation; either version 2 of the License, or
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
11 * (at your option) any later version.
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
12 *
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
13 * This program is distributed in the hope that it will be useful,
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
16 * GNU General Public License for more details.
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
17 *
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
18 * You should have received a copy of the GNU General Public License
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
19 * along with this program; if not, write to the Free Software
19681
44b4e8bd759b The FSF changed its address a while ago; our files were out of date.
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 19654
diff changeset
20 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02111-1301 USA
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
21 */
21438
4fe9acb6b514 Some platforms require additional includes before net/if.h, and this
Ethan Blanton <elb@pidgin.im>
parents: 21437
diff changeset
22
4fe9acb6b514 Some platforms require additional includes before net/if.h, and this
Ethan Blanton <elb@pidgin.im>
parents: 21437
diff changeset
23 #include "internal.h"
4fe9acb6b514 Some platforms require additional includes before net/if.h, and this
Ethan Blanton <elb@pidgin.im>
parents: 21437
diff changeset
24
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
25 #ifndef _WIN32
21437
db7fa42845f6 Patch from some Intel folks to implement file transfer in Bonjour using XEP-0096 and 0065. This hopefully will work with Gaijm (haven't yet tested) and, of course, between libpurple instances; it will not work with Adium or iChat.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 21418
diff changeset
26 #include <net/if.h>
db7fa42845f6 Patch from some Intel folks to implement file transfer in Bonjour using XEP-0096 and 0065. This hopefully will work with Gaijm (haven't yet tested) and, of course, between libpurple instances; it will not work with Adium or iChat.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 21418
diff changeset
27 #include <sys/ioctl.h>
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
28 #include <sys/socket.h>
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
29 #include <netinet/in.h>
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
30 #include <arpa/inet.h>
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
31 #else
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
32 #include "libc_interface.h"
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
33 #endif
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
34 #include <sys/types.h>
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
35 #include <glib.h>
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
36 #include <unistd.h>
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
37 #include <fcntl.h>
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
38
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
39 #include "network.h"
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
40 #include "eventloop.h"
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
41 #include "connection.h"
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
42 #include "blist.h"
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
43 #include "xmlnode.h"
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
44 #include "debug.h"
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
45 #include "notify.h"
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
46 #include "util.h"
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
47
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
48 #include "jabber.h"
18761
316be7e715c6 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 <daniel.atallah@gmail.com>
parents: 18651
diff changeset
49 #include "parser.h"
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
50 #include "bonjour.h"
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
51 #include "buddy.h"
21437
db7fa42845f6 Patch from some Intel folks to implement file transfer in Bonjour using XEP-0096 and 0065. This hopefully will work with Gaijm (haven't yet tested) and, of course, between libpurple instances; it will not work with Adium or iChat.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 21418
diff changeset
52 #include "bonjour_ft.h"
db7fa42845f6 Patch from some Intel folks to implement file transfer in Bonjour using XEP-0096 and 0065. This hopefully will work with Gaijm (haven't yet tested) and, of course, between libpurple instances; it will not work with Adium or iChat.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 21418
diff changeset
53
db7fa42845f6 Patch from some Intel folks to implement file transfer in Bonjour using XEP-0096 and 0065. This hopefully will work with Gaijm (haven't yet tested) and, of course, between libpurple instances; it will not work with Adium or iChat.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 21418
diff changeset
54 #ifdef _SIZEOF_ADDR_IFREQ
db7fa42845f6 Patch from some Intel folks to implement file transfer in Bonjour using XEP-0096 and 0065. This hopefully will work with Gaijm (haven't yet tested) and, of course, between libpurple instances; it will not work with Adium or iChat.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 21418
diff changeset
55 # define HX_SIZE_OF_IFREQ(a) _SIZEOF_ADDR_IFREQ(a)
db7fa42845f6 Patch from some Intel folks to implement file transfer in Bonjour using XEP-0096 and 0065. This hopefully will work with Gaijm (haven't yet tested) and, of course, between libpurple instances; it will not work with Adium or iChat.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 21418
diff changeset
56 #else
db7fa42845f6 Patch from some Intel folks to implement file transfer in Bonjour using XEP-0096 and 0065. This hopefully will work with Gaijm (haven't yet tested) and, of course, between libpurple instances; it will not work with Adium or iChat.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 21418
diff changeset
57 # define HX_SIZE_OF_IFREQ(a) sizeof(a)
db7fa42845f6 Patch from some Intel folks to implement file transfer in Bonjour using XEP-0096 and 0065. This hopefully will work with Gaijm (haven't yet tested) and, of course, between libpurple instances; it will not work with Adium or iChat.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 21418
diff changeset
58 #endif
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
59
17554
a1d05bc43d95 Send 'to' and 'from' attributes in the stream start message.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 17553
diff changeset
60 #define STREAM_END "</stream:stream>"
a1d05bc43d95 Send 'to' and 'from' attributes in the stream start message.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 17553
diff changeset
61 /* TODO: specify version='1.0' and send stream features */
a1d05bc43d95 Send 'to' and 'from' attributes in the stream start message.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 17553
diff changeset
62 #define DOCTYPE "<?xml version=\"1.0\" encoding=\"UTF-8\" ?>\n" \
a1d05bc43d95 Send 'to' and 'from' attributes in the stream start message.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 17553
diff changeset
63 "<stream:stream xmlns=\"jabber:client\" xmlns:stream=\"http://etherx.jabber.org/streams\" from=\"%s\" to=\"%s\">"
a1d05bc43d95 Send 'to' and 'from' attributes in the stream start message.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 17553
diff changeset
64
21437
db7fa42845f6 Patch from some Intel folks to implement file transfer in Bonjour using XEP-0096 and 0065. This hopefully will work with Gaijm (haven't yet tested) and, of course, between libpurple instances; it will not work with Adium or iChat.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 21418
diff changeset
65 static void
db7fa42845f6 Patch from some Intel folks to implement file transfer in Bonjour using XEP-0096 and 0065. This hopefully will work with Gaijm (haven't yet tested) and, of course, between libpurple instances; it will not work with Adium or iChat.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 21418
diff changeset
66 xep_iq_parse(xmlnode *packet, PurpleConnection *connection, PurpleBuddy *pb);
db7fa42845f6 Patch from some Intel folks to implement file transfer in Bonjour using XEP-0096 and 0065. This hopefully will work with Gaijm (haven't yet tested) and, of course, between libpurple instances; it will not work with Adium or iChat.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 21418
diff changeset
67
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
68 #if 0 /* this isn't used anywhere... */
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
69 static const char *
15822
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15811
diff changeset
70 _font_size_purple_to_ichat(int size)
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
71 {
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
72 switch (size) {
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
73 case 1:
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
74 return "8";
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
75 case 2:
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
76 return "10";
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
77 case 3:
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
78 return "12";
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
79 case 4:
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
80 return "14";
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
81 case 5:
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
82 return "17";
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
83 case 6:
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
84 return "21";
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
85 case 7:
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
86 return "24";
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
87 }
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
88
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
89 return "12";
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
90 }
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
91 #endif
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
92
17555
b13850d13391 Consolidate BonjourJabberConversation creation and deletion.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 17554
diff changeset
93 static BonjourJabberConversation *
17556
612dc5149964 Close conversation connections when logging out of the Bonjour account. This also fixes leakage.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 17555
diff changeset
94 bonjour_jabber_conv_new() {
17555
b13850d13391 Consolidate BonjourJabberConversation creation and deletion.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 17554
diff changeset
95
b13850d13391 Consolidate BonjourJabberConversation creation and deletion.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 17554
diff changeset
96 BonjourJabberConversation *bconv = g_new0(BonjourJabberConversation, 1);
b13850d13391 Consolidate BonjourJabberConversation creation and deletion.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 17554
diff changeset
97 bconv->socket = -1;
17558
6e4e2d234c3a Update Bonjour to do nonblocking I/O correctly.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 17556
diff changeset
98 bconv->tx_buf = purple_circ_buffer_new(512);
19399
649ac48fce1d Reset unsigned int input handlers to 0 instead of -1.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 19233
diff changeset
99 bconv->tx_handler = 0;
649ac48fce1d Reset unsigned int input handlers to 0 instead of -1.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 19233
diff changeset
100 bconv->rx_handler = 0;
17555
b13850d13391 Consolidate BonjourJabberConversation creation and deletion.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 17554
diff changeset
101
b13850d13391 Consolidate BonjourJabberConversation creation and deletion.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 17554
diff changeset
102 return bconv;
b13850d13391 Consolidate BonjourJabberConversation creation and deletion.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 17554
diff changeset
103 }
b13850d13391 Consolidate BonjourJabberConversation creation and deletion.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 17554
diff changeset
104
17558
6e4e2d234c3a Update Bonjour to do nonblocking I/O correctly.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 17556
diff changeset
105
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
106 static const char *
15822
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15811
diff changeset
107 _font_size_ichat_to_purple(int size)
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
108 {
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
109 if (size > 24) {
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
110 return "7";
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
111 } else if (size >= 21) {
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
112 return "6";
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
113 } else if (size >= 17) {
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
114 return "5";
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
115 } else if (size >= 14) {
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
116 return "4";
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
117 } else if (size >= 12) {
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
118 return "3";
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
119 } else if (size >= 10) {
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
120 return "2";
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
121 }
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
122
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
123 return "1";
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
124 }
17542
496d007a8912 Some more Bonjour cleanup and leak fixing.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 17541
diff changeset
125
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
126 static void
18761
316be7e715c6 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 <daniel.atallah@gmail.com>
parents: 18651
diff changeset
127 _jabber_parse_and_write_message_to_ui(xmlnode *message_node, PurpleBuddy *pb)
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
128 {
17553
61005dea822b Cleanup, fix a leak and prevent the inbound xml from being parsed twice for every message.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 17542
diff changeset
129 xmlnode *body_node, *html_node, *events_node;
18761
316be7e715c6 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 <daniel.atallah@gmail.com>
parents: 18651
diff changeset
130 PurpleConnection *gc = pb->account->gc;
17542
496d007a8912 Some more Bonjour cleanup and leak fixing.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 17541
diff changeset
131 char *body, *html_body = NULL;
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
132 const char *ichat_balloon_color = NULL;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
133 const char *ichat_text_color = NULL;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
134 const char *font_face = NULL;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
135 const char *font_size = NULL;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
136 const char *font_color = NULL;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
137 gboolean composing_event = FALSE;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
138
17553
61005dea822b Cleanup, fix a leak and prevent the inbound xml from being parsed twice for every message.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 17542
diff changeset
139 body_node = xmlnode_get_child(message_node, "body");
61005dea822b Cleanup, fix a leak and prevent the inbound xml from being parsed twice for every message.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 17542
diff changeset
140 if (body_node == NULL)
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
141 return;
17542
496d007a8912 Some more Bonjour cleanup and leak fixing.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 17541
diff changeset
142 body = xmlnode_get_data(body_node);
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
143
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
144 html_node = xmlnode_get_child(message_node, "html");
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
145 if (html_node != NULL)
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
146 {
17542
496d007a8912 Some more Bonjour cleanup and leak fixing.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 17541
diff changeset
147 xmlnode *html_body_node;
496d007a8912 Some more Bonjour cleanup and leak fixing.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 17541
diff changeset
148
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
149 html_body_node = xmlnode_get_child(html_node, "body");
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
150 if (html_body_node != NULL)
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
151 {
17542
496d007a8912 Some more Bonjour cleanup and leak fixing.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 17541
diff changeset
152 xmlnode *html_body_font_node;
496d007a8912 Some more Bonjour cleanup and leak fixing.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 17541
diff changeset
153
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
154 ichat_balloon_color = xmlnode_get_attrib(html_body_node, "ichatballooncolor");
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
155 ichat_text_color = xmlnode_get_attrib(html_body_node, "ichattextcolor");
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
156 html_body_font_node = xmlnode_get_child(html_body_node, "font");
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
157 if (html_body_font_node != NULL)
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
158 { /* Types of messages sent by iChat */
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
159 font_face = xmlnode_get_attrib(html_body_font_node, "face");
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
160 /* The absolute iChat font sizes should be converted to 1..7 range */
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
161 font_size = xmlnode_get_attrib(html_body_font_node, "ABSZ");
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
162 if (font_size != NULL)
15822
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15811
diff changeset
163 font_size = _font_size_ichat_to_purple(atoi(font_size));
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
164 font_color = xmlnode_get_attrib(html_body_font_node, "color");
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
165 html_body = xmlnode_get_data(html_body_font_node);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
166 if (html_body == NULL)
15822
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15811
diff changeset
167 /* This is the kind of formated messages that Purple creates */
17553
61005dea822b Cleanup, fix a leak and prevent the inbound xml from being parsed twice for every message.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 17542
diff changeset
168 html_body = xmlnode_to_str(html_body_font_node, NULL);
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
169 }
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
170 }
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
171 }
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
172
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
173 events_node = xmlnode_get_child_with_namespace(message_node, "x", "jabber:x:event");
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
174 if (events_node != NULL)
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
175 {
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
176 if (xmlnode_get_child(events_node, "composing") != NULL)
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
177 composing_event = TRUE;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
178 if (xmlnode_get_child(events_node, "id") != NULL)
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
179 {
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
180 /* The user is just typing */
17542
496d007a8912 Some more Bonjour cleanup and leak fixing.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 17541
diff changeset
181 /* TODO: Deal with typing notification */
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
182 g_free(body);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
183 g_free(html_body);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
184 return;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
185 }
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
186 }
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
187
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
188 /* Compose the message */
17542
496d007a8912 Some more Bonjour cleanup and leak fixing.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 17541
diff changeset
189 if (html_body != NULL)
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
190 {
17542
496d007a8912 Some more Bonjour cleanup and leak fixing.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 17541
diff changeset
191 g_free(body);
496d007a8912 Some more Bonjour cleanup and leak fixing.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 17541
diff changeset
192
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
193 if (font_face == NULL) font_face = "Helvetica";
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
194 if (font_size == NULL) font_size = "3";
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
195 if (ichat_text_color == NULL) ichat_text_color = "#000000";
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
196 if (ichat_balloon_color == NULL) ichat_balloon_color = "#FFFFFF";
17553
61005dea822b Cleanup, fix a leak and prevent the inbound xml from being parsed twice for every message.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 17542
diff changeset
197 body = g_strdup_printf("<font face='%s' size='%s' color='%s' back='%s'>%s</font>",
61005dea822b Cleanup, fix a leak and prevent the inbound xml from being parsed twice for every message.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 17542
diff changeset
198 font_face, font_size, ichat_text_color, ichat_balloon_color,
61005dea822b Cleanup, fix a leak and prevent the inbound xml from being parsed twice for every message.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 17542
diff changeset
199 html_body);
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
200 }
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
201
17542
496d007a8912 Some more Bonjour cleanup and leak fixing.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 17541
diff changeset
202 /* TODO: Should we do something with "composing_event" here? */
496d007a8912 Some more Bonjour cleanup and leak fixing.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 17541
diff changeset
203
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
204 /* Send the message to the UI */
18761
316be7e715c6 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 <daniel.atallah@gmail.com>
parents: 18651
diff changeset
205 serv_got_im(gc, pb->name, body, 0, time(NULL));
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
206
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
207 g_free(body);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
208 g_free(html_body);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
209 }
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
210
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
211 struct _check_buddy_by_address_t {
17542
496d007a8912 Some more Bonjour cleanup and leak fixing.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 17541
diff changeset
212 const char *address;
17554
a1d05bc43d95 Send 'to' and 'from' attributes in the stream start message.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 17553
diff changeset
213 PurpleBuddy **pb;
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
214 BonjourJabber *bj;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
215 };
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
216
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
217 static void
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
218 _check_buddy_by_address(gpointer key, gpointer value, gpointer data)
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
219 {
17554
a1d05bc43d95 Send 'to' and 'from' attributes in the stream start message.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 17553
diff changeset
220 PurpleBuddy *pb = value;
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
221 BonjourBuddy *bb;
17542
496d007a8912 Some more Bonjour cleanup and leak fixing.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 17541
diff changeset
222 struct _check_buddy_by_address_t *cbba = data;
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
223
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
224 /*
15822
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15811
diff changeset
225 * If the current PurpleBuddy's data is not null and the PurpleBuddy's account
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
226 * is the same as the account requesting the check then continue to determine
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
227 * whether the buddies IP matches the target IP.
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
228 */
17554
a1d05bc43d95 Send 'to' and 'from' attributes in the stream start message.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 17553
diff changeset
229 if (cbba->bj->account == pb->account)
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
230 {
17554
a1d05bc43d95 Send 'to' and 'from' attributes in the stream start message.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 17553
diff changeset
231 bb = pb->proto_data;
17082
7ade887fd3f6 Replace strcasecmp() calls with glib equivalents.
Richard Laager <rlaager@wiktel.com>
parents: 15822
diff changeset
232 if ((bb != NULL) && (g_ascii_strcasecmp(bb->ip, cbba->address) == 0))
17554
a1d05bc43d95 Send 'to' and 'from' attributes in the stream start message.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 17553
diff changeset
233 *(cbba->pb) = pb;
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
234 }
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
235 }
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
236
17558
6e4e2d234c3a Update Bonjour to do nonblocking I/O correctly.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 17556
diff changeset
237 static void
6e4e2d234c3a Update Bonjour to do nonblocking I/O correctly.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 17556
diff changeset
238 _send_data_write_cb(gpointer data, gint source, PurpleInputCondition cond)
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
239 {
17558
6e4e2d234c3a Update Bonjour to do nonblocking I/O correctly.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 17556
diff changeset
240 PurpleBuddy *pb = data;
6e4e2d234c3a Update Bonjour to do nonblocking I/O correctly.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 17556
diff changeset
241 BonjourBuddy *bb = pb->proto_data;
6e4e2d234c3a Update Bonjour to do nonblocking I/O correctly.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 17556
diff changeset
242 BonjourJabberConversation *bconv = bb->conversation;
6e4e2d234c3a Update Bonjour to do nonblocking I/O correctly.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 17556
diff changeset
243 int ret, writelen;
6e4e2d234c3a Update Bonjour to do nonblocking I/O correctly.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 17556
diff changeset
244
6e4e2d234c3a Update Bonjour to do nonblocking I/O correctly.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 17556
diff changeset
245 /* TODO: Make sure that the stream has been established before sending */
6e4e2d234c3a Update Bonjour to do nonblocking I/O correctly.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 17556
diff changeset
246
6e4e2d234c3a Update Bonjour to do nonblocking I/O correctly.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 17556
diff changeset
247 writelen = purple_circ_buffer_get_max_read(bconv->tx_buf);
6e4e2d234c3a Update Bonjour to do nonblocking I/O correctly.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 17556
diff changeset
248
6e4e2d234c3a Update Bonjour to do nonblocking I/O correctly.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 17556
diff changeset
249 if (writelen == 0) {
6e4e2d234c3a Update Bonjour to do nonblocking I/O correctly.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 17556
diff changeset
250 purple_input_remove(bconv->tx_handler);
19399
649ac48fce1d Reset unsigned int input handlers to 0 instead of -1.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 19233
diff changeset
251 bconv->tx_handler = 0;
17558
6e4e2d234c3a Update Bonjour to do nonblocking I/O correctly.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 17556
diff changeset
252 return;
6e4e2d234c3a Update Bonjour to do nonblocking I/O correctly.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 17556
diff changeset
253 }
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
254
17558
6e4e2d234c3a Update Bonjour to do nonblocking I/O correctly.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 17556
diff changeset
255 ret = send(bconv->socket, bconv->tx_buf->outptr, writelen, 0);
6e4e2d234c3a Update Bonjour to do nonblocking I/O correctly.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 17556
diff changeset
256
6e4e2d234c3a Update Bonjour to do nonblocking I/O correctly.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 17556
diff changeset
257 if (ret < 0 && errno == EAGAIN)
6e4e2d234c3a Update Bonjour to do nonblocking I/O correctly.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 17556
diff changeset
258 return;
6e4e2d234c3a Update Bonjour to do nonblocking I/O correctly.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 17556
diff changeset
259 else if (ret <= 0) {
6e4e2d234c3a Update Bonjour to do nonblocking I/O correctly.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 17556
diff changeset
260 PurpleConversation *conv;
21121
35b4f1dc4c8d replace most calls to strerror with calls to g_strerror. strerror will return
Nathan Walp <nwalp@pidgin.im>
parents: 21017
diff changeset
261 const char *error = g_strerror(errno);
17558
6e4e2d234c3a Update Bonjour to do nonblocking I/O correctly.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 17556
diff changeset
262
6e4e2d234c3a Update Bonjour to do nonblocking I/O correctly.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 17556
diff changeset
263 purple_debug_error("bonjour", "Error sending message to buddy %s error: %s\n",
6e4e2d234c3a Update Bonjour to do nonblocking I/O correctly.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 17556
diff changeset
264 purple_buddy_get_name(pb), error ? error : "(null)");
6e4e2d234c3a Update Bonjour to do nonblocking I/O correctly.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 17556
diff changeset
265
6e4e2d234c3a Update Bonjour to do nonblocking I/O correctly.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 17556
diff changeset
266 conv = purple_find_conversation_with_account(PURPLE_CONV_TYPE_IM, bb->name, pb->account);
6e4e2d234c3a Update Bonjour to do nonblocking I/O correctly.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 17556
diff changeset
267 if (conv != NULL)
6e4e2d234c3a Update Bonjour to do nonblocking I/O correctly.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 17556
diff changeset
268 purple_conversation_write(conv, NULL,
6e4e2d234c3a Update Bonjour to do nonblocking I/O correctly.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 17556
diff changeset
269 _("Unable to send message."),
6e4e2d234c3a Update Bonjour to do nonblocking I/O correctly.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 17556
diff changeset
270 PURPLE_MESSAGE_SYSTEM, time(NULL));
6e4e2d234c3a Update Bonjour to do nonblocking I/O correctly.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 17556
diff changeset
271
6e4e2d234c3a Update Bonjour to do nonblocking I/O correctly.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 17556
diff changeset
272 bonjour_jabber_close_conversation(bb->conversation);
6e4e2d234c3a Update Bonjour to do nonblocking I/O correctly.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 17556
diff changeset
273 bb->conversation = NULL;
6e4e2d234c3a Update Bonjour to do nonblocking I/O correctly.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 17556
diff changeset
274 return;
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
275 }
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
276
17558
6e4e2d234c3a Update Bonjour to do nonblocking I/O correctly.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 17556
diff changeset
277 purple_circ_buffer_mark_read(bconv->tx_buf, ret);
6e4e2d234c3a Update Bonjour to do nonblocking I/O correctly.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 17556
diff changeset
278 }
6e4e2d234c3a Update Bonjour to do nonblocking I/O correctly.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 17556
diff changeset
279
6e4e2d234c3a Update Bonjour to do nonblocking I/O correctly.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 17556
diff changeset
280 static gint
6e4e2d234c3a Update Bonjour to do nonblocking I/O correctly.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 17556
diff changeset
281 _send_data(PurpleBuddy *pb, char *message)
6e4e2d234c3a Update Bonjour to do nonblocking I/O correctly.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 17556
diff changeset
282 {
6e4e2d234c3a Update Bonjour to do nonblocking I/O correctly.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 17556
diff changeset
283 gint ret;
6e4e2d234c3a Update Bonjour to do nonblocking I/O correctly.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 17556
diff changeset
284 int len = strlen(message);
6e4e2d234c3a Update Bonjour to do nonblocking I/O correctly.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 17556
diff changeset
285 BonjourBuddy *bb = pb->proto_data;
6e4e2d234c3a Update Bonjour to do nonblocking I/O correctly.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 17556
diff changeset
286 BonjourJabberConversation *bconv = bb->conversation;
6e4e2d234c3a Update Bonjour to do nonblocking I/O correctly.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 17556
diff changeset
287
6e4e2d234c3a Update Bonjour to do nonblocking I/O correctly.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 17556
diff changeset
288 /* If we're not ready to actually send, append it to the buffer */
19399
649ac48fce1d Reset unsigned int input handlers to 0 instead of -1.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 19233
diff changeset
289 if (bconv->tx_handler != 0
17558
6e4e2d234c3a Update Bonjour to do nonblocking I/O correctly.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 17556
diff changeset
290 || bconv->connect_data != NULL
18761
316be7e715c6 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 <daniel.atallah@gmail.com>
parents: 18651
diff changeset
291 || !bconv->sent_stream_start
316be7e715c6 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 <daniel.atallah@gmail.com>
parents: 18651
diff changeset
292 || !bconv->recv_stream_start
17558
6e4e2d234c3a Update Bonjour to do nonblocking I/O correctly.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 17556
diff changeset
293 || purple_circ_buffer_get_max_read(bconv->tx_buf) > 0) {
6e4e2d234c3a Update Bonjour to do nonblocking I/O correctly.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 17556
diff changeset
294 ret = -1;
6e4e2d234c3a Update Bonjour to do nonblocking I/O correctly.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 17556
diff changeset
295 errno = EAGAIN;
6e4e2d234c3a Update Bonjour to do nonblocking I/O correctly.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 17556
diff changeset
296 } else {
6e4e2d234c3a Update Bonjour to do nonblocking I/O correctly.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 17556
diff changeset
297 ret = send(bconv->socket, message, len, 0);
6e4e2d234c3a Update Bonjour to do nonblocking I/O correctly.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 17556
diff changeset
298 }
6e4e2d234c3a Update Bonjour to do nonblocking I/O correctly.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 17556
diff changeset
299
6e4e2d234c3a Update Bonjour to do nonblocking I/O correctly.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 17556
diff changeset
300 if (ret == -1 && errno == EAGAIN)
6e4e2d234c3a Update Bonjour to do nonblocking I/O correctly.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 17556
diff changeset
301 ret = 0;
6e4e2d234c3a Update Bonjour to do nonblocking I/O correctly.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 17556
diff changeset
302 else if (ret <= 0) {
6e4e2d234c3a Update Bonjour to do nonblocking I/O correctly.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 17556
diff changeset
303 PurpleConversation *conv;
21121
35b4f1dc4c8d replace most calls to strerror with calls to g_strerror. strerror will return
Nathan Walp <nwalp@pidgin.im>
parents: 21017
diff changeset
304 const char *error = g_strerror(errno);
17558
6e4e2d234c3a Update Bonjour to do nonblocking I/O correctly.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 17556
diff changeset
305
6e4e2d234c3a Update Bonjour to do nonblocking I/O correctly.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 17556
diff changeset
306 purple_debug_error("bonjour", "Error sending message to buddy %s error: %s\n",
6e4e2d234c3a Update Bonjour to do nonblocking I/O correctly.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 17556
diff changeset
307 purple_buddy_get_name(pb), error ? error : "(null)");
6e4e2d234c3a Update Bonjour to do nonblocking I/O correctly.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 17556
diff changeset
308
6e4e2d234c3a Update Bonjour to do nonblocking I/O correctly.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 17556
diff changeset
309 conv = purple_find_conversation_with_account(PURPLE_CONV_TYPE_IM, bb->name, pb->account);
6e4e2d234c3a Update Bonjour to do nonblocking I/O correctly.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 17556
diff changeset
310 if (conv != NULL)
6e4e2d234c3a Update Bonjour to do nonblocking I/O correctly.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 17556
diff changeset
311 purple_conversation_write(conv, NULL,
6e4e2d234c3a Update Bonjour to do nonblocking I/O correctly.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 17556
diff changeset
312 _("Unable to send message."),
6e4e2d234c3a Update Bonjour to do nonblocking I/O correctly.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 17556
diff changeset
313 PURPLE_MESSAGE_SYSTEM, time(NULL));
6e4e2d234c3a Update Bonjour to do nonblocking I/O correctly.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 17556
diff changeset
314
6e4e2d234c3a Update Bonjour to do nonblocking I/O correctly.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 17556
diff changeset
315 bonjour_jabber_close_conversation(bb->conversation);
6e4e2d234c3a Update Bonjour to do nonblocking I/O correctly.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 17556
diff changeset
316 bb->conversation = NULL;
6e4e2d234c3a Update Bonjour to do nonblocking I/O correctly.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 17556
diff changeset
317 return -1;
6e4e2d234c3a Update Bonjour to do nonblocking I/O correctly.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 17556
diff changeset
318 }
6e4e2d234c3a Update Bonjour to do nonblocking I/O correctly.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 17556
diff changeset
319
6e4e2d234c3a Update Bonjour to do nonblocking I/O correctly.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 17556
diff changeset
320 if (ret < len) {
19399
649ac48fce1d Reset unsigned int input handlers to 0 instead of -1.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 19233
diff changeset
321 if (bconv->tx_handler == 0)
17558
6e4e2d234c3a Update Bonjour to do nonblocking I/O correctly.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 17556
diff changeset
322 bconv->tx_handler = purple_input_add(bconv->socket, PURPLE_INPUT_WRITE,
6e4e2d234c3a Update Bonjour to do nonblocking I/O correctly.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 17556
diff changeset
323 _send_data_write_cb, pb);
6e4e2d234c3a Update Bonjour to do nonblocking I/O correctly.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 17556
diff changeset
324 purple_circ_buffer_append(bconv->tx_buf, message + ret, len - ret);
6e4e2d234c3a Update Bonjour to do nonblocking I/O correctly.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 17556
diff changeset
325 }
6e4e2d234c3a Update Bonjour to do nonblocking I/O correctly.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 17556
diff changeset
326
6e4e2d234c3a Update Bonjour to do nonblocking I/O correctly.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 17556
diff changeset
327 return ret;
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
328 }
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
329
18761
316be7e715c6 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 <daniel.atallah@gmail.com>
parents: 18651
diff changeset
330 void bonjour_jabber_process_packet(PurpleBuddy *pb, xmlnode *packet) {
316be7e715c6 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 <daniel.atallah@gmail.com>
parents: 18651
diff changeset
331 if (!strcmp(packet->name, "message"))
316be7e715c6 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 <daniel.atallah@gmail.com>
parents: 18651
diff changeset
332 _jabber_parse_and_write_message_to_ui(packet, pb);
21437
db7fa42845f6 Patch from some Intel folks to implement file transfer in Bonjour using XEP-0096 and 0065. This hopefully will work with Gaijm (haven't yet tested) and, of course, between libpurple instances; it will not work with Adium or iChat.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 21418
diff changeset
333 else if(!strcmp(packet->name, "iq"))
db7fa42845f6 Patch from some Intel folks to implement file transfer in Bonjour using XEP-0096 and 0065. This hopefully will work with Gaijm (haven't yet tested) and, of course, between libpurple instances; it will not work with Adium or iChat.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 21418
diff changeset
334 xep_iq_parse(packet, NULL, pb);
18761
316be7e715c6 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 <daniel.atallah@gmail.com>
parents: 18651
diff changeset
335 else
316be7e715c6 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 <daniel.atallah@gmail.com>
parents: 18651
diff changeset
336 purple_debug_warning("bonjour", "Unknown packet: %s\n",
316be7e715c6 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 <daniel.atallah@gmail.com>
parents: 18651
diff changeset
337 packet->name);
316be7e715c6 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 <daniel.atallah@gmail.com>
parents: 18651
diff changeset
338 }
316be7e715c6 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 <daniel.atallah@gmail.com>
parents: 18651
diff changeset
339
316be7e715c6 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 <daniel.atallah@gmail.com>
parents: 18651
diff changeset
340
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
341 static void
15822
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15811
diff changeset
342 _client_socket_handler(gpointer data, gint socket, PurpleInputCondition condition)
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
343 {
17554
a1d05bc43d95 Send 'to' and 'from' attributes in the stream start message.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 17553
diff changeset
344 PurpleBuddy *pb = data;
18761
316be7e715c6 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 <daniel.atallah@gmail.com>
parents: 18651
diff changeset
345 gint len, message_length;
316be7e715c6 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 <daniel.atallah@gmail.com>
parents: 18651
diff changeset
346 static char message[4096];
316be7e715c6 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 <daniel.atallah@gmail.com>
parents: 18651
diff changeset
347
316be7e715c6 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 <daniel.atallah@gmail.com>
parents: 18651
diff changeset
348 /*TODO: use a static buffer */
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
349
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
350 /* Read the data from the socket */
18761
316be7e715c6 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 <daniel.atallah@gmail.com>
parents: 18651
diff changeset
351 if ((len = recv(socket, message, sizeof(message) - 1, 0)) == -1) {
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
352 /* There have been an error reading from the socket */
17558
6e4e2d234c3a Update Bonjour to do nonblocking I/O correctly.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 17556
diff changeset
353 if (errno != EAGAIN) {
18761
316be7e715c6 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 <daniel.atallah@gmail.com>
parents: 18651
diff changeset
354 BonjourBuddy *bb = pb->proto_data;
316be7e715c6 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 <daniel.atallah@gmail.com>
parents: 18651
diff changeset
355
21121
35b4f1dc4c8d replace most calls to strerror with calls to g_strerror. strerror will return
Nathan Walp <nwalp@pidgin.im>
parents: 21017
diff changeset
356 purple_debug_warning("bonjour", "receive error: %s\n", g_strerror(errno));
18761
316be7e715c6 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 <daniel.atallah@gmail.com>
parents: 18651
diff changeset
357
17558
6e4e2d234c3a Update Bonjour to do nonblocking I/O correctly.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 17556
diff changeset
358 bonjour_jabber_close_conversation(bb->conversation);
6e4e2d234c3a Update Bonjour to do nonblocking I/O correctly.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 17556
diff changeset
359 bb->conversation = NULL;
6e4e2d234c3a Update Bonjour to do nonblocking I/O correctly.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 17556
diff changeset
360
6e4e2d234c3a Update Bonjour to do nonblocking I/O correctly.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 17556
diff changeset
361 /* I guess we really don't need to notify the user.
6e4e2d234c3a Update Bonjour to do nonblocking I/O correctly.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 17556
diff changeset
362 * If they try to send another message it'll reconnect */
6e4e2d234c3a Update Bonjour to do nonblocking I/O correctly.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 17556
diff changeset
363 }
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
364 return;
18761
316be7e715c6 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 <daniel.atallah@gmail.com>
parents: 18651
diff changeset
365 } else if (len == 0) { /* The other end has closed the socket */
316be7e715c6 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 <daniel.atallah@gmail.com>
parents: 18651
diff changeset
366 purple_debug_warning("bonjour", "Connection closed (without stream end) by %s.\n", pb->name);
316be7e715c6 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 <daniel.atallah@gmail.com>
parents: 18651
diff changeset
367 bonjour_jabber_stream_ended(pb);
316be7e715c6 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 <daniel.atallah@gmail.com>
parents: 18651
diff changeset
368 return;
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
369 } else {
18761
316be7e715c6 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 <daniel.atallah@gmail.com>
parents: 18651
diff changeset
370 message_length = len;
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
371 message[message_length] = '\0';
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
372
18761
316be7e715c6 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 <daniel.atallah@gmail.com>
parents: 18651
diff changeset
373 while (message_length > 0 && g_ascii_iscntrl(message[message_length - 1])) {
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
374 message[message_length - 1] = '\0';
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
375 message_length--;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
376 }
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
377 }
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
378
18761
316be7e715c6 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 <daniel.atallah@gmail.com>
parents: 18651
diff changeset
379 purple_debug_info("bonjour", "Receive: -%s- %d bytes\n", message, len);
316be7e715c6 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 <daniel.atallah@gmail.com>
parents: 18651
diff changeset
380
316be7e715c6 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 <daniel.atallah@gmail.com>
parents: 18651
diff changeset
381 bonjour_parser_process(pb, message, message_length);
316be7e715c6 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 <daniel.atallah@gmail.com>
parents: 18651
diff changeset
382 }
17542
496d007a8912 Some more Bonjour cleanup and leak fixing.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 17541
diff changeset
383
18761
316be7e715c6 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 <daniel.atallah@gmail.com>
parents: 18651
diff changeset
384 void bonjour_jabber_stream_ended(PurpleBuddy *pb) {
316be7e715c6 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 <daniel.atallah@gmail.com>
parents: 18651
diff changeset
385 BonjourBuddy *bb = pb->proto_data;
316be7e715c6 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 <daniel.atallah@gmail.com>
parents: 18651
diff changeset
386
316be7e715c6 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 <daniel.atallah@gmail.com>
parents: 18651
diff changeset
387 purple_debug_info("bonjour", "Recieved conversation close notification from %s.\n", pb->name);
316be7e715c6 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 <daniel.atallah@gmail.com>
parents: 18651
diff changeset
388
19233
6e3cd5e80420 Don't trigger another libxml2 parse from within one of the parsing callbacks. References #1652.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 18761
diff changeset
389 g_return_if_fail(bb != NULL);
6e3cd5e80420 Don't trigger another libxml2 parse from within one of the parsing callbacks. References #1652.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 18761
diff changeset
390
19574
917b6f45c458 Prevent duplicate window closed notifications.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 19399
diff changeset
391 /* Inform the user that the conversation has been closed */
917b6f45c458 Prevent duplicate window closed notifications.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 19399
diff changeset
392 if (bb->conversation != NULL) {
21007
d55617a15301 don't assume </stream:stream> means the conversation window is closed. Fixes #3690
Sean Egan <seanegan@gmail.com>
parents: 20347
diff changeset
393 #if 0
21017
8b74b226e023 Fix a double-free that was not fun to track down. Fixes #3688.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 21007
diff changeset
394 PurpleConversation *conv;
19574
917b6f45c458 Prevent duplicate window closed notifications.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 19399
diff changeset
395 conv = purple_find_conversation_with_account(PURPLE_CONV_TYPE_IM, pb->name, pb->account);
917b6f45c458 Prevent duplicate window closed notifications.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 19399
diff changeset
396 if (conv != NULL) {
917b6f45c458 Prevent duplicate window closed notifications.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 19399
diff changeset
397 char *tmp = g_strdup_printf(_("%s has closed the conversation."), pb->name);
917b6f45c458 Prevent duplicate window closed notifications.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 19399
diff changeset
398 purple_conversation_write(conv, NULL, tmp, PURPLE_MESSAGE_SYSTEM, time(NULL));
917b6f45c458 Prevent duplicate window closed notifications.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 19399
diff changeset
399 g_free(tmp);
917b6f45c458 Prevent duplicate window closed notifications.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 19399
diff changeset
400 }
21007
d55617a15301 don't assume </stream:stream> means the conversation window is closed. Fixes #3690
Sean Egan <seanegan@gmail.com>
parents: 20347
diff changeset
401 #endif
19574
917b6f45c458 Prevent duplicate window closed notifications.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 19399
diff changeset
402 /* Close the socket, clear the watcher and free memory */
917b6f45c458 Prevent duplicate window closed notifications.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 19399
diff changeset
403 bonjour_jabber_close_conversation(bb->conversation);
917b6f45c458 Prevent duplicate window closed notifications.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 19399
diff changeset
404 bb->conversation = NULL;
917b6f45c458 Prevent duplicate window closed notifications.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 19399
diff changeset
405 }
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
406
18761
316be7e715c6 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 <daniel.atallah@gmail.com>
parents: 18651
diff changeset
407 }
18651
b981d3c39d0b Fix memory leak (also includes an efficiency rearrangement for the xmlnode parsing that has been sitting on my machine for a while).
Daniel Atallah <daniel.atallah@gmail.com>
parents: 18276
diff changeset
408
18761
316be7e715c6 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 <daniel.atallah@gmail.com>
parents: 18651
diff changeset
409 void bonjour_jabber_stream_started(PurpleBuddy *pb) {
316be7e715c6 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 <daniel.atallah@gmail.com>
parents: 18651
diff changeset
410 BonjourBuddy *bb = pb->proto_data;
316be7e715c6 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 <daniel.atallah@gmail.com>
parents: 18651
diff changeset
411 BonjourJabberConversation *bconv = bb->conversation;
18651
b981d3c39d0b Fix memory leak (also includes an efficiency rearrangement for the xmlnode parsing that has been sitting on my machine for a while).
Daniel Atallah <daniel.atallah@gmail.com>
parents: 18276
diff changeset
412
18761
316be7e715c6 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 <daniel.atallah@gmail.com>
parents: 18651
diff changeset
413 /* If the stream has been completely started, we can start doing stuff */
316be7e715c6 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 <daniel.atallah@gmail.com>
parents: 18651
diff changeset
414 if (bconv->sent_stream_start && bconv->recv_stream_start && purple_circ_buffer_get_max_read(bconv->tx_buf) > 0) {
316be7e715c6 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 <daniel.atallah@gmail.com>
parents: 18651
diff changeset
415 /* Watch for when we can write the buffered messages */
316be7e715c6 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 <daniel.atallah@gmail.com>
parents: 18651
diff changeset
416 bconv->tx_handler = purple_input_add(bconv->socket, PURPLE_INPUT_WRITE,
316be7e715c6 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 <daniel.atallah@gmail.com>
parents: 18651
diff changeset
417 _send_data_write_cb, pb);
316be7e715c6 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 <daniel.atallah@gmail.com>
parents: 18651
diff changeset
418 /* We can probably write the data right now. */
316be7e715c6 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 <daniel.atallah@gmail.com>
parents: 18651
diff changeset
419 _send_data_write_cb(pb, bconv->socket, PURPLE_INPUT_WRITE);
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
420 }
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
421
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
422 }
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
423
17558
6e4e2d234c3a Update Bonjour to do nonblocking I/O correctly.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 17556
diff changeset
424 struct _stream_start_data {
6e4e2d234c3a Update Bonjour to do nonblocking I/O correctly.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 17556
diff changeset
425 char *msg;
6e4e2d234c3a Update Bonjour to do nonblocking I/O correctly.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 17556
diff changeset
426 };
6e4e2d234c3a Update Bonjour to do nonblocking I/O correctly.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 17556
diff changeset
427
18761
316be7e715c6 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 <daniel.atallah@gmail.com>
parents: 18651
diff changeset
428
17558
6e4e2d234c3a Update Bonjour to do nonblocking I/O correctly.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 17556
diff changeset
429 static void
6e4e2d234c3a Update Bonjour to do nonblocking I/O correctly.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 17556
diff changeset
430 _start_stream(gpointer data, gint source, PurpleInputCondition condition)
6e4e2d234c3a Update Bonjour to do nonblocking I/O correctly.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 17556
diff changeset
431 {
6e4e2d234c3a Update Bonjour to do nonblocking I/O correctly.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 17556
diff changeset
432 PurpleBuddy *pb = data;
6e4e2d234c3a Update Bonjour to do nonblocking I/O correctly.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 17556
diff changeset
433 BonjourBuddy *bb = pb->proto_data;
18761
316be7e715c6 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 <daniel.atallah@gmail.com>
parents: 18651
diff changeset
434 BonjourJabberConversation *bconv = bb->conversation;
316be7e715c6 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 <daniel.atallah@gmail.com>
parents: 18651
diff changeset
435 struct _stream_start_data *ss = bconv->stream_data;
17558
6e4e2d234c3a Update Bonjour to do nonblocking I/O correctly.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 17556
diff changeset
436 int len, ret;
6e4e2d234c3a Update Bonjour to do nonblocking I/O correctly.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 17556
diff changeset
437
6e4e2d234c3a Update Bonjour to do nonblocking I/O correctly.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 17556
diff changeset
438 len = strlen(ss->msg);
6e4e2d234c3a Update Bonjour to do nonblocking I/O correctly.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 17556
diff changeset
439
6e4e2d234c3a Update Bonjour to do nonblocking I/O correctly.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 17556
diff changeset
440 /* Start Stream */
6e4e2d234c3a Update Bonjour to do nonblocking I/O correctly.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 17556
diff changeset
441 ret = send(source, ss->msg, len, 0);
6e4e2d234c3a Update Bonjour to do nonblocking I/O correctly.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 17556
diff changeset
442
6e4e2d234c3a Update Bonjour to do nonblocking I/O correctly.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 17556
diff changeset
443 if (ret == -1 && errno == EAGAIN)
6e4e2d234c3a Update Bonjour to do nonblocking I/O correctly.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 17556
diff changeset
444 return;
6e4e2d234c3a Update Bonjour to do nonblocking I/O correctly.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 17556
diff changeset
445 else if (ret <= 0) {
21121
35b4f1dc4c8d replace most calls to strerror with calls to g_strerror. strerror will return
Nathan Walp <nwalp@pidgin.im>
parents: 21017
diff changeset
446 const char *err = g_strerror(errno);
17558
6e4e2d234c3a Update Bonjour to do nonblocking I/O correctly.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 17556
diff changeset
447 PurpleConversation *conv;
6e4e2d234c3a Update Bonjour to do nonblocking I/O correctly.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 17556
diff changeset
448
6e4e2d234c3a Update Bonjour to do nonblocking I/O correctly.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 17556
diff changeset
449 purple_debug_error("bonjour", "Error starting stream with buddy %s at %s:%d error: %s\n",
6e4e2d234c3a Update Bonjour to do nonblocking I/O correctly.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 17556
diff changeset
450 purple_buddy_get_name(pb), bb->ip ? bb->ip : "(null)", bb->port_p2pj, err ? err : "(null)");
6e4e2d234c3a Update Bonjour to do nonblocking I/O correctly.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 17556
diff changeset
451
6e4e2d234c3a Update Bonjour to do nonblocking I/O correctly.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 17556
diff changeset
452 conv = purple_find_conversation_with_account(PURPLE_CONV_TYPE_IM, bb->name, pb->account);
6e4e2d234c3a Update Bonjour to do nonblocking I/O correctly.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 17556
diff changeset
453 if (conv != NULL)
6e4e2d234c3a Update Bonjour to do nonblocking I/O correctly.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 17556
diff changeset
454 purple_conversation_write(conv, NULL,
6e4e2d234c3a Update Bonjour to do nonblocking I/O correctly.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 17556
diff changeset
455 _("Unable to send the message, the conversation couldn't be started."),
6e4e2d234c3a Update Bonjour to do nonblocking I/O correctly.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 17556
diff changeset
456 PURPLE_MESSAGE_SYSTEM, time(NULL));
6e4e2d234c3a Update Bonjour to do nonblocking I/O correctly.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 17556
diff changeset
457
18761
316be7e715c6 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 <daniel.atallah@gmail.com>
parents: 18651
diff changeset
458 bonjour_jabber_close_conversation(bconv);
17558
6e4e2d234c3a Update Bonjour to do nonblocking I/O correctly.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 17556
diff changeset
459 bb->conversation = NULL;
6e4e2d234c3a Update Bonjour to do nonblocking I/O correctly.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 17556
diff changeset
460
6e4e2d234c3a Update Bonjour to do nonblocking I/O correctly.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 17556
diff changeset
461 return;
6e4e2d234c3a Update Bonjour to do nonblocking I/O correctly.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 17556
diff changeset
462 }
6e4e2d234c3a Update Bonjour to do nonblocking I/O correctly.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 17556
diff changeset
463
6e4e2d234c3a Update Bonjour to do nonblocking I/O correctly.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 17556
diff changeset
464 /* This is EXTREMELY unlikely to happen */
6e4e2d234c3a Update Bonjour to do nonblocking I/O correctly.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 17556
diff changeset
465 if (ret < len) {
6e4e2d234c3a Update Bonjour to do nonblocking I/O correctly.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 17556
diff changeset
466 char *tmp = g_strdup(ss->msg + ret);
6e4e2d234c3a Update Bonjour to do nonblocking I/O correctly.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 17556
diff changeset
467 g_free(ss->msg);
6e4e2d234c3a Update Bonjour to do nonblocking I/O correctly.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 17556
diff changeset
468 ss->msg = tmp;
6e4e2d234c3a Update Bonjour to do nonblocking I/O correctly.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 17556
diff changeset
469 return;
6e4e2d234c3a Update Bonjour to do nonblocking I/O correctly.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 17556
diff changeset
470 }
6e4e2d234c3a Update Bonjour to do nonblocking I/O correctly.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 17556
diff changeset
471
6e4e2d234c3a Update Bonjour to do nonblocking I/O correctly.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 17556
diff changeset
472 g_free(ss->msg);
6e4e2d234c3a Update Bonjour to do nonblocking I/O correctly.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 17556
diff changeset
473 g_free(ss);
18761
316be7e715c6 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 <daniel.atallah@gmail.com>
parents: 18651
diff changeset
474 bconv->stream_data = NULL;
316be7e715c6 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 <daniel.atallah@gmail.com>
parents: 18651
diff changeset
475
316be7e715c6 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 <daniel.atallah@gmail.com>
parents: 18651
diff changeset
476 /* Stream started; process the send buffer if there is one */
316be7e715c6 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 <daniel.atallah@gmail.com>
parents: 18651
diff changeset
477 purple_input_remove(bconv->tx_handler);
19399
649ac48fce1d Reset unsigned int input handlers to 0 instead of -1.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 19233
diff changeset
478 bconv->tx_handler= 0;
18761
316be7e715c6 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 <daniel.atallah@gmail.com>
parents: 18651
diff changeset
479 bconv->sent_stream_start = TRUE;
316be7e715c6 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 <daniel.atallah@gmail.com>
parents: 18651
diff changeset
480
316be7e715c6 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 <daniel.atallah@gmail.com>
parents: 18651
diff changeset
481 bonjour_jabber_stream_started(pb);
316be7e715c6 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 <daniel.atallah@gmail.com>
parents: 18651
diff changeset
482
316be7e715c6 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 <daniel.atallah@gmail.com>
parents: 18651
diff changeset
483 }
316be7e715c6 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 <daniel.atallah@gmail.com>
parents: 18651
diff changeset
484
316be7e715c6 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 <daniel.atallah@gmail.com>
parents: 18651
diff changeset
485 static gboolean bonjour_jabber_stream_init(PurpleBuddy *pb, int client_socket)
316be7e715c6 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 <daniel.atallah@gmail.com>
parents: 18651
diff changeset
486 {
316be7e715c6 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 <daniel.atallah@gmail.com>
parents: 18651
diff changeset
487 int ret, len;
316be7e715c6 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 <daniel.atallah@gmail.com>
parents: 18651
diff changeset
488 char *stream_start;
316be7e715c6 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 <daniel.atallah@gmail.com>
parents: 18651
diff changeset
489 BonjourBuddy *bb = pb->proto_data;
316be7e715c6 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 <daniel.atallah@gmail.com>
parents: 18651
diff changeset
490
316be7e715c6 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 <daniel.atallah@gmail.com>
parents: 18651
diff changeset
491 stream_start = g_strdup_printf(DOCTYPE, purple_account_get_username(pb->account),
316be7e715c6 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 <daniel.atallah@gmail.com>
parents: 18651
diff changeset
492 purple_buddy_get_name(pb));
316be7e715c6 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 <daniel.atallah@gmail.com>
parents: 18651
diff changeset
493 len = strlen(stream_start);
316be7e715c6 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 <daniel.atallah@gmail.com>
parents: 18651
diff changeset
494
316be7e715c6 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 <daniel.atallah@gmail.com>
parents: 18651
diff changeset
495 /* Start the stream */
316be7e715c6 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 <daniel.atallah@gmail.com>
parents: 18651
diff changeset
496 ret = send(client_socket, stream_start, len, 0);
316be7e715c6 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 <daniel.atallah@gmail.com>
parents: 18651
diff changeset
497
316be7e715c6 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 <daniel.atallah@gmail.com>
parents: 18651
diff changeset
498 if (ret == -1 && errno == EAGAIN)
316be7e715c6 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 <daniel.atallah@gmail.com>
parents: 18651
diff changeset
499 ret = 0;
316be7e715c6 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 <daniel.atallah@gmail.com>
parents: 18651
diff changeset
500 else if (ret <= 0) {
21121
35b4f1dc4c8d replace most calls to strerror with calls to g_strerror. strerror will return
Nathan Walp <nwalp@pidgin.im>
parents: 21017
diff changeset
501 const char *err = g_strerror(errno);
17558
6e4e2d234c3a Update Bonjour to do nonblocking I/O correctly.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 17556
diff changeset
502
18761
316be7e715c6 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 <daniel.atallah@gmail.com>
parents: 18651
diff changeset
503 purple_debug_error("bonjour", "Error starting stream with buddy %s at %s:%d error: %s\n",
316be7e715c6 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 <daniel.atallah@gmail.com>
parents: 18651
diff changeset
504 purple_buddy_get_name(pb), bb->ip ? bb->ip : "(null)", bb->port_p2pj, err ? err : "(null)");
316be7e715c6 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 <daniel.atallah@gmail.com>
parents: 18651
diff changeset
505
316be7e715c6 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 <daniel.atallah@gmail.com>
parents: 18651
diff changeset
506 close(client_socket);
316be7e715c6 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 <daniel.atallah@gmail.com>
parents: 18651
diff changeset
507 g_free(stream_start);
316be7e715c6 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 <daniel.atallah@gmail.com>
parents: 18651
diff changeset
508
316be7e715c6 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 <daniel.atallah@gmail.com>
parents: 18651
diff changeset
509 return FALSE;
17558
6e4e2d234c3a Update Bonjour to do nonblocking I/O correctly.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 17556
diff changeset
510 }
18761
316be7e715c6 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 <daniel.atallah@gmail.com>
parents: 18651
diff changeset
511
316be7e715c6 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 <daniel.atallah@gmail.com>
parents: 18651
diff changeset
512 /* This is unlikely to happen */
316be7e715c6 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 <daniel.atallah@gmail.com>
parents: 18651
diff changeset
513 if (ret < len) {
316be7e715c6 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 <daniel.atallah@gmail.com>
parents: 18651
diff changeset
514 struct _stream_start_data *ss = g_new(struct _stream_start_data, 1);
316be7e715c6 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 <daniel.atallah@gmail.com>
parents: 18651
diff changeset
515 ss->msg = g_strdup(stream_start + ret);
316be7e715c6 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 <daniel.atallah@gmail.com>
parents: 18651
diff changeset
516 bb->conversation->stream_data = ss;
316be7e715c6 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 <daniel.atallah@gmail.com>
parents: 18651
diff changeset
517 /* Finish sending the stream start */
316be7e715c6 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 <daniel.atallah@gmail.com>
parents: 18651
diff changeset
518 bb->conversation->tx_handler = purple_input_add(client_socket,
316be7e715c6 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 <daniel.atallah@gmail.com>
parents: 18651
diff changeset
519 PURPLE_INPUT_WRITE, _start_stream, pb);
316be7e715c6 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 <daniel.atallah@gmail.com>
parents: 18651
diff changeset
520 } else
316be7e715c6 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 <daniel.atallah@gmail.com>
parents: 18651
diff changeset
521 bb->conversation->sent_stream_start = TRUE;
316be7e715c6 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 <daniel.atallah@gmail.com>
parents: 18651
diff changeset
522
316be7e715c6 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 <daniel.atallah@gmail.com>
parents: 18651
diff changeset
523 g_free(stream_start);
316be7e715c6 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 <daniel.atallah@gmail.com>
parents: 18651
diff changeset
524
316be7e715c6 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 <daniel.atallah@gmail.com>
parents: 18651
diff changeset
525 /* setup the parser fresh for each stream */
316be7e715c6 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 <daniel.atallah@gmail.com>
parents: 18651
diff changeset
526 bonjour_parser_setup(bb->conversation);
316be7e715c6 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 <daniel.atallah@gmail.com>
parents: 18651
diff changeset
527
316be7e715c6 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 <daniel.atallah@gmail.com>
parents: 18651
diff changeset
528 bb->conversation->socket = client_socket;
316be7e715c6 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 <daniel.atallah@gmail.com>
parents: 18651
diff changeset
529 bb->conversation->rx_handler = purple_input_add(client_socket,
316be7e715c6 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 <daniel.atallah@gmail.com>
parents: 18651
diff changeset
530 PURPLE_INPUT_READ, _client_socket_handler, pb);
316be7e715c6 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 <daniel.atallah@gmail.com>
parents: 18651
diff changeset
531
316be7e715c6 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 <daniel.atallah@gmail.com>
parents: 18651
diff changeset
532 return TRUE;
17558
6e4e2d234c3a Update Bonjour to do nonblocking I/O correctly.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 17556
diff changeset
533 }
6e4e2d234c3a Update Bonjour to do nonblocking I/O correctly.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 17556
diff changeset
534
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
535 static void
15822
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15811
diff changeset
536 _server_socket_handler(gpointer data, int server_socket, PurpleInputCondition condition)
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
537 {
17554
a1d05bc43d95 Send 'to' and 'from' attributes in the stream start message.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 17553
diff changeset
538 PurpleBuddy *pb = NULL;
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
539 struct sockaddr_in their_addr; /* connector's address information */
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
540 socklen_t sin_size = sizeof(struct sockaddr);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
541 int client_socket;
20347
04fe5601fedb applied changes from 2762c6075c0dc52a96098c5478c5bf68cfd890a3
Luke Schierer <lschiere@pidgin.im>
parents: 19681
diff changeset
542 int flags;
17542
496d007a8912 Some more Bonjour cleanup and leak fixing.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 17541
diff changeset
543 BonjourBuddy *bb;
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
544 char *address_text = NULL;
15822
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15811
diff changeset
545 PurpleBuddyList *bl = purple_get_blist();
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
546 struct _check_buddy_by_address_t *cbba;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
547
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
548 /* Check that it is a read condition */
17542
496d007a8912 Some more Bonjour cleanup and leak fixing.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 17541
diff changeset
549 if (condition != PURPLE_INPUT_READ)
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
550 return;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
551
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
552 if ((client_socket = accept(server_socket, (struct sockaddr *)&their_addr, &sin_size)) == -1)
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
553 return;
17542
496d007a8912 Some more Bonjour cleanup and leak fixing.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 17541
diff changeset
554
20347
04fe5601fedb applied changes from 2762c6075c0dc52a96098c5478c5bf68cfd890a3
Luke Schierer <lschiere@pidgin.im>
parents: 19681
diff changeset
555 flags = fcntl(client_socket, F_GETFL);
04fe5601fedb applied changes from 2762c6075c0dc52a96098c5478c5bf68cfd890a3
Luke Schierer <lschiere@pidgin.im>
parents: 19681
diff changeset
556 fcntl(client_socket, F_SETFL, flags | O_NONBLOCK);
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
557
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
558 /* Look for the buddy that has opened the conversation and fill information */
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
559 address_text = inet_ntoa(their_addr.sin_addr);
19654
941965d6fd88 Patch from QuLogic. Fixes #2903 ('Missing newlines in debug messages.')
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 19574
diff changeset
560 purple_debug_info("bonjour", "Received incoming connection from %s.\n", address_text);
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
561 cbba = g_new0(struct _check_buddy_by_address_t, 1);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
562 cbba->address = address_text;
17554
a1d05bc43d95 Send 'to' and 'from' attributes in the stream start message.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 17553
diff changeset
563 cbba->pb = &pb;
17542
496d007a8912 Some more Bonjour cleanup and leak fixing.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 17541
diff changeset
564 cbba->bj = data;
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
565 g_hash_table_foreach(bl->buddies, _check_buddy_by_address, cbba);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
566 g_free(cbba);
17554
a1d05bc43d95 Send 'to' and 'from' attributes in the stream start message.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 17553
diff changeset
567 if (pb == NULL)
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
568 {
15822
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15811
diff changeset
569 purple_debug_info("bonjour", "We don't like invisible buddies, this is not a superheros comic\n");
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
570 close(client_socket);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
571 return;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
572 }
17554
a1d05bc43d95 Send 'to' and 'from' attributes in the stream start message.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 17553
diff changeset
573 bb = pb->proto_data;
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
574
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
575 /* Check if the conversation has been previously started */
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
576 if (bb->conversation == NULL)
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
577 {
18761
316be7e715c6 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 <daniel.atallah@gmail.com>
parents: 18651
diff changeset
578 bb->conversation = bonjour_jabber_conv_new();
17558
6e4e2d234c3a Update Bonjour to do nonblocking I/O correctly.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 17556
diff changeset
579
18761
316be7e715c6 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 <daniel.atallah@gmail.com>
parents: 18651
diff changeset
580 if (!bonjour_jabber_stream_init(pb, client_socket)) {
17558
6e4e2d234c3a Update Bonjour to do nonblocking I/O correctly.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 17556
diff changeset
581 close(client_socket);
6e4e2d234c3a Update Bonjour to do nonblocking I/O correctly.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 17556
diff changeset
582 return;
6e4e2d234c3a Update Bonjour to do nonblocking I/O correctly.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 17556
diff changeset
583 }
6e4e2d234c3a Update Bonjour to do nonblocking I/O correctly.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 17556
diff changeset
584
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
585 } else {
18761
316be7e715c6 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 <daniel.atallah@gmail.com>
parents: 18651
diff changeset
586 purple_debug_warning("bonjour", "Ignoring incoming connection because an existing connection exists.\n");
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
587 close(client_socket);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
588 }
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
589 }
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
590
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
591 gint
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
592 bonjour_jabber_start(BonjourJabber *data)
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
593 {
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
594 struct sockaddr_in my_addr;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
595 int yes = 1;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
596 int i;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
597 gboolean bind_successful;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
598
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
599 /* Open a listening socket for incoming conversations */
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
600 if ((data->socket = socket(PF_INET, SOCK_STREAM, 0)) < 0)
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
601 {
21121
35b4f1dc4c8d replace most calls to strerror with calls to g_strerror. strerror will return
Nathan Walp <nwalp@pidgin.im>
parents: 21017
diff changeset
602 purple_debug_error("bonjour", "Cannot open socket: %s\n", g_strerror(errno));
20070
efadfc6e2117 Fix up Bonjour to use purple_connection_error_reason.
Will Thompson <will.thompson@collabora.co.uk>
parents: 19681
diff changeset
603 purple_connection_error_reason (data->account->gc,
21358
ba41f2a60253 Rename:
Will Thompson <will.thompson@collabora.co.uk>
parents: 20070
diff changeset
604 PURPLE_CONNECTION_ERROR_NETWORK_ERROR,
ba41f2a60253 Rename:
Will Thompson <will.thompson@collabora.co.uk>
parents: 20070
diff changeset
605 _("Cannot open socket"));
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
606 return -1;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
607 }
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
608
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
609 /* Make the socket reusable */
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
610 if (setsockopt(data->socket, SOL_SOCKET, SO_REUSEADDR, &yes, sizeof(int)) != 0)
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
611 {
21121
35b4f1dc4c8d replace most calls to strerror with calls to g_strerror. strerror will return
Nathan Walp <nwalp@pidgin.im>
parents: 21017
diff changeset
612 purple_debug_error("bonjour", "Error setting socket options: %s\n", g_strerror(errno));
20070
efadfc6e2117 Fix up Bonjour to use purple_connection_error_reason.
Will Thompson <will.thompson@collabora.co.uk>
parents: 19681
diff changeset
613 purple_connection_error_reason (data->account->gc,
21358
ba41f2a60253 Rename:
Will Thompson <will.thompson@collabora.co.uk>
parents: 20070
diff changeset
614 PURPLE_CONNECTION_ERROR_NETWORK_ERROR,
ba41f2a60253 Rename:
Will Thompson <will.thompson@collabora.co.uk>
parents: 20070
diff changeset
615 _("Error setting socket options"));
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
616 return -1;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
617 }
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
618
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
619 memset(&my_addr, 0, sizeof(struct sockaddr_in));
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
620 my_addr.sin_family = PF_INET;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
621
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
622 /* Attempt to find a free port */
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
623 bind_successful = FALSE;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
624 for (i = 0; i < 10; i++)
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
625 {
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
626 my_addr.sin_port = htons(data->port);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
627 if (bind(data->socket, (struct sockaddr*)&my_addr, sizeof(struct sockaddr)) == 0)
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
628 {
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
629 bind_successful = TRUE;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
630 break;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
631 }
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
632 data->port++;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
633 }
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
634
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
635 /* On no! We tried 10 ports and could not bind to ANY of them */
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
636 if (!bind_successful)
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
637 {
21121
35b4f1dc4c8d replace most calls to strerror with calls to g_strerror. strerror will return
Nathan Walp <nwalp@pidgin.im>
parents: 21017
diff changeset
638 purple_debug_error("bonjour", "Cannot bind socket: %s\n", g_strerror(errno));
20070
efadfc6e2117 Fix up Bonjour to use purple_connection_error_reason.
Will Thompson <will.thompson@collabora.co.uk>
parents: 19681
diff changeset
639 purple_connection_error_reason (data->account->gc,
21358
ba41f2a60253 Rename:
Will Thompson <will.thompson@collabora.co.uk>
parents: 20070
diff changeset
640 PURPLE_CONNECTION_ERROR_NETWORK_ERROR,
ba41f2a60253 Rename:
Will Thompson <will.thompson@collabora.co.uk>
parents: 20070
diff changeset
641 _("Could not bind socket to port"));
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
642 return -1;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
643 }
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
644
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
645 /* Attempt to listen on the bound socket */
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
646 if (listen(data->socket, 10) != 0)
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
647 {
21121
35b4f1dc4c8d replace most calls to strerror with calls to g_strerror. strerror will return
Nathan Walp <nwalp@pidgin.im>
parents: 21017
diff changeset
648 purple_debug_error("bonjour", "Cannot listen on socket: %s\n", g_strerror(errno));
20070
efadfc6e2117 Fix up Bonjour to use purple_connection_error_reason.
Will Thompson <will.thompson@collabora.co.uk>
parents: 19681
diff changeset
649 purple_connection_error_reason (data->account->gc,
21358
ba41f2a60253 Rename:
Will Thompson <will.thompson@collabora.co.uk>
parents: 20070
diff changeset
650 PURPLE_CONNECTION_ERROR_NETWORK_ERROR,
ba41f2a60253 Rename:
Will Thompson <will.thompson@collabora.co.uk>
parents: 20070
diff changeset
651 _("Could not listen on socket"));
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
652 return -1;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
653 }
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
654
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
655 #if 0
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
656 /* TODO: Why isn't this being used? */
15822
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15811
diff changeset
657 data->socket = purple_network_listen(data->port, SOCK_STREAM);
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
658
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
659 if (data->socket == -1)
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
660 {
15822
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15811
diff changeset
661 purple_debug_error("bonjour", "No se ha podido crear el socket\n");
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
662 }
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
663 #endif
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
664
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
665 /* Open a watcher in the socket we have just opened */
15822
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15811
diff changeset
666 data->watcher_id = purple_input_add(data->socket, PURPLE_INPUT_READ, _server_socket_handler, data);
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
667
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
668 return data->port;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
669 }
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
670
17558
6e4e2d234c3a Update Bonjour to do nonblocking I/O correctly.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 17556
diff changeset
671 static void
6e4e2d234c3a Update Bonjour to do nonblocking I/O correctly.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 17556
diff changeset
672 _connected_to_buddy(gpointer data, gint source, const gchar *error)
6e4e2d234c3a Update Bonjour to do nonblocking I/O correctly.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 17556
diff changeset
673 {
6e4e2d234c3a Update Bonjour to do nonblocking I/O correctly.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 17556
diff changeset
674 PurpleBuddy *pb = data;
6e4e2d234c3a Update Bonjour to do nonblocking I/O correctly.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 17556
diff changeset
675 BonjourBuddy *bb = pb->proto_data;
6e4e2d234c3a Update Bonjour to do nonblocking I/O correctly.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 17556
diff changeset
676
6e4e2d234c3a Update Bonjour to do nonblocking I/O correctly.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 17556
diff changeset
677 bb->conversation->connect_data = NULL;
6e4e2d234c3a Update Bonjour to do nonblocking I/O correctly.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 17556
diff changeset
678
6e4e2d234c3a Update Bonjour to do nonblocking I/O correctly.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 17556
diff changeset
679 if (source < 0) {
6e4e2d234c3a Update Bonjour to do nonblocking I/O correctly.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 17556
diff changeset
680 PurpleConversation *conv;
6e4e2d234c3a Update Bonjour to do nonblocking I/O correctly.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 17556
diff changeset
681
6e4e2d234c3a Update Bonjour to do nonblocking I/O correctly.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 17556
diff changeset
682 purple_debug_error("bonjour", "Error connecting to buddy %s at %s:%d error: %s\n",
6e4e2d234c3a Update Bonjour to do nonblocking I/O correctly.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 17556
diff changeset
683 purple_buddy_get_name(pb), bb->ip ? bb->ip : "(null)", bb->port_p2pj, error ? error : "(null)");
6e4e2d234c3a Update Bonjour to do nonblocking I/O correctly.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 17556
diff changeset
684
6e4e2d234c3a Update Bonjour to do nonblocking I/O correctly.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 17556
diff changeset
685 conv = purple_find_conversation_with_account(PURPLE_CONV_TYPE_IM, bb->name, pb->account);
6e4e2d234c3a Update Bonjour to do nonblocking I/O correctly.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 17556
diff changeset
686 if (conv != NULL)
6e4e2d234c3a Update Bonjour to do nonblocking I/O correctly.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 17556
diff changeset
687 purple_conversation_write(conv, NULL,
6e4e2d234c3a Update Bonjour to do nonblocking I/O correctly.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 17556
diff changeset
688 _("Unable to send the message, the conversation couldn't be started."),
6e4e2d234c3a Update Bonjour to do nonblocking I/O correctly.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 17556
diff changeset
689 PURPLE_MESSAGE_SYSTEM, time(NULL));
6e4e2d234c3a Update Bonjour to do nonblocking I/O correctly.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 17556
diff changeset
690
6e4e2d234c3a Update Bonjour to do nonblocking I/O correctly.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 17556
diff changeset
691 bonjour_jabber_close_conversation(bb->conversation);
6e4e2d234c3a Update Bonjour to do nonblocking I/O correctly.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 17556
diff changeset
692 bb->conversation = NULL;
6e4e2d234c3a Update Bonjour to do nonblocking I/O correctly.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 17556
diff changeset
693 return;
6e4e2d234c3a Update Bonjour to do nonblocking I/O correctly.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 17556
diff changeset
694 }
6e4e2d234c3a Update Bonjour to do nonblocking I/O correctly.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 17556
diff changeset
695
18761
316be7e715c6 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 <daniel.atallah@gmail.com>
parents: 18651
diff changeset
696 if (!bonjour_jabber_stream_init(pb, source)) {
21121
35b4f1dc4c8d replace most calls to strerror with calls to g_strerror. strerror will return
Nathan Walp <nwalp@pidgin.im>
parents: 21017
diff changeset
697 const char *err = g_strerror(errno);
17558
6e4e2d234c3a Update Bonjour to do nonblocking I/O correctly.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 17556
diff changeset
698 PurpleConversation *conv;
6e4e2d234c3a Update Bonjour to do nonblocking I/O correctly.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 17556
diff changeset
699
6e4e2d234c3a Update Bonjour to do nonblocking I/O correctly.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 17556
diff changeset
700 purple_debug_error("bonjour", "Error starting stream with buddy %s at %s:%d error: %s\n",
6e4e2d234c3a Update Bonjour to do nonblocking I/O correctly.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 17556
diff changeset
701 purple_buddy_get_name(pb), bb->ip ? bb->ip : "(null)", bb->port_p2pj, err ? err : "(null)");
6e4e2d234c3a Update Bonjour to do nonblocking I/O correctly.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 17556
diff changeset
702
6e4e2d234c3a Update Bonjour to do nonblocking I/O correctly.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 17556
diff changeset
703 conv = purple_find_conversation_with_account(PURPLE_CONV_TYPE_IM, bb->name, pb->account);
6e4e2d234c3a Update Bonjour to do nonblocking I/O correctly.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 17556
diff changeset
704 if (conv != NULL)
6e4e2d234c3a Update Bonjour to do nonblocking I/O correctly.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 17556
diff changeset
705 purple_conversation_write(conv, NULL,
6e4e2d234c3a Update Bonjour to do nonblocking I/O correctly.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 17556
diff changeset
706 _("Unable to send the message, the conversation couldn't be started."),
6e4e2d234c3a Update Bonjour to do nonblocking I/O correctly.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 17556
diff changeset
707 PURPLE_MESSAGE_SYSTEM, time(NULL));
6e4e2d234c3a Update Bonjour to do nonblocking I/O correctly.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 17556
diff changeset
708
6e4e2d234c3a Update Bonjour to do nonblocking I/O correctly.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 17556
diff changeset
709 close(source);
6e4e2d234c3a Update Bonjour to do nonblocking I/O correctly.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 17556
diff changeset
710 bonjour_jabber_close_conversation(bb->conversation);
6e4e2d234c3a Update Bonjour to do nonblocking I/O correctly.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 17556
diff changeset
711 bb->conversation = NULL;
6e4e2d234c3a Update Bonjour to do nonblocking I/O correctly.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 17556
diff changeset
712 return;
6e4e2d234c3a Update Bonjour to do nonblocking I/O correctly.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 17556
diff changeset
713 }
6e4e2d234c3a Update Bonjour to do nonblocking I/O correctly.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 17556
diff changeset
714 }
6e4e2d234c3a Update Bonjour to do nonblocking I/O correctly.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 17556
diff changeset
715
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
716 int
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
717 bonjour_jabber_send_message(BonjourJabber *data, const gchar *to, const gchar *body)
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
718 {
17553
61005dea822b Cleanup, fix a leak and prevent the inbound xml from being parsed twice for every message.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 17542
diff changeset
719 xmlnode *message_node, *node, *node2;
61005dea822b Cleanup, fix a leak and prevent the inbound xml from being parsed twice for every message.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 17542
diff changeset
720 gchar *message;
61005dea822b Cleanup, fix a leak and prevent the inbound xml from being parsed twice for every message.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 17542
diff changeset
721 PurpleBuddy *pb;
61005dea822b Cleanup, fix a leak and prevent the inbound xml from being parsed twice for every message.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 17542
diff changeset
722 BonjourBuddy *bb;
61005dea822b Cleanup, fix a leak and prevent the inbound xml from being parsed twice for every message.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 17542
diff changeset
723 int ret;
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
724
17553
61005dea822b Cleanup, fix a leak and prevent the inbound xml from being parsed twice for every message.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 17542
diff changeset
725 pb = purple_find_buddy(data->account, to);
61005dea822b Cleanup, fix a leak and prevent the inbound xml from being parsed twice for every message.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 17542
diff changeset
726 if (pb == NULL) {
17500
bca2780f7669 Improve error handling while connecting to a bonjour buddy.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 17495
diff changeset
727 purple_debug_info("bonjour", "Can't send a message to an offline buddy (%s).\n", to);
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
728 /* You can not send a message to an offline buddy */
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
729 return -10000;
17500
bca2780f7669 Improve error handling while connecting to a bonjour buddy.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 17495
diff changeset
730 }
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
731
17553
61005dea822b Cleanup, fix a leak and prevent the inbound xml from being parsed twice for every message.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 17542
diff changeset
732 bb = pb->proto_data;
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
733
17500
bca2780f7669 Improve error handling while connecting to a bonjour buddy.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 17495
diff changeset
734 /* Check if there is a previously open conversation */
bca2780f7669 Improve error handling while connecting to a bonjour buddy.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 17495
diff changeset
735 if (bb->conversation == NULL)
bca2780f7669 Improve error handling while connecting to a bonjour buddy.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 17495
diff changeset
736 {
17558
6e4e2d234c3a Update Bonjour to do nonblocking I/O correctly.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 17556
diff changeset
737 PurpleProxyConnectData *connect_data;
17599
bce4211c4980 More robust hack to force Bonjour to use no proxy when directly connecting to buddy.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 17558
diff changeset
738 PurpleProxyInfo *proxy_info;
17558
6e4e2d234c3a Update Bonjour to do nonblocking I/O correctly.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 17556
diff changeset
739
6e4e2d234c3a Update Bonjour to do nonblocking I/O correctly.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 17556
diff changeset
740 /* Make sure that the account always has a proxy of "none".
6e4e2d234c3a Update Bonjour to do nonblocking I/O correctly.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 17556
diff changeset
741 * This is kind of dirty, but proxy_connect_none() isn't exposed. */
17599
bce4211c4980 More robust hack to force Bonjour to use no proxy when directly connecting to buddy.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 17558
diff changeset
742 proxy_info = purple_account_get_proxy_info(data->account);
bce4211c4980 More robust hack to force Bonjour to use no proxy when directly connecting to buddy.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 17558
diff changeset
743 if (proxy_info == NULL) {
bce4211c4980 More robust hack to force Bonjour to use no proxy when directly connecting to buddy.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 17558
diff changeset
744 proxy_info = purple_proxy_info_new();
bce4211c4980 More robust hack to force Bonjour to use no proxy when directly connecting to buddy.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 17558
diff changeset
745 purple_account_set_proxy_info(data->account, proxy_info);
17558
6e4e2d234c3a Update Bonjour to do nonblocking I/O correctly.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 17556
diff changeset
746 }
17599
bce4211c4980 More robust hack to force Bonjour to use no proxy when directly connecting to buddy.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 17558
diff changeset
747 purple_proxy_info_set_type(proxy_info, PURPLE_PROXY_NONE);
17558
6e4e2d234c3a Update Bonjour to do nonblocking I/O correctly.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 17556
diff changeset
748
6e4e2d234c3a Update Bonjour to do nonblocking I/O correctly.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 17556
diff changeset
749 connect_data =
6e4e2d234c3a Update Bonjour to do nonblocking I/O correctly.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 17556
diff changeset
750 purple_proxy_connect(data->account->gc, data->account, bb->ip,
6e4e2d234c3a Update Bonjour to do nonblocking I/O correctly.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 17556
diff changeset
751 bb->port_p2pj, _connected_to_buddy, pb);
6e4e2d234c3a Update Bonjour to do nonblocking I/O correctly.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 17556
diff changeset
752
6e4e2d234c3a Update Bonjour to do nonblocking I/O correctly.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 17556
diff changeset
753 if (connect_data == NULL) {
6e4e2d234c3a Update Bonjour to do nonblocking I/O correctly.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 17556
diff changeset
754 purple_debug_error("bonjour", "Unable to connect to buddy (%s).\n", to);
17500
bca2780f7669 Improve error handling while connecting to a bonjour buddy.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 17495
diff changeset
755 return -10001;
17558
6e4e2d234c3a Update Bonjour to do nonblocking I/O correctly.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 17556
diff changeset
756 }
17500
bca2780f7669 Improve error handling while connecting to a bonjour buddy.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 17495
diff changeset
757
17556
612dc5149964 Close conversation connections when logging out of the Bonjour account. This also fixes leakage.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 17555
diff changeset
758 bb->conversation = bonjour_jabber_conv_new();
17558
6e4e2d234c3a Update Bonjour to do nonblocking I/O correctly.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 17556
diff changeset
759 bb->conversation->connect_data = connect_data;
6e4e2d234c3a Update Bonjour to do nonblocking I/O correctly.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 17556
diff changeset
760 /* We don't want _send_data() to register the tx_handler;
6e4e2d234c3a Update Bonjour to do nonblocking I/O correctly.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 17556
diff changeset
761 * that neeeds to wait until we're actually connected. */
6e4e2d234c3a Update Bonjour to do nonblocking I/O correctly.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 17556
diff changeset
762 bb->conversation->tx_handler = 0;
17500
bca2780f7669 Improve error handling while connecting to a bonjour buddy.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 17495
diff changeset
763 }
bca2780f7669 Improve error handling while connecting to a bonjour buddy.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 17495
diff changeset
764
17553
61005dea822b Cleanup, fix a leak and prevent the inbound xml from being parsed twice for every message.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 17542
diff changeset
765 message_node = xmlnode_new("message");
61005dea822b Cleanup, fix a leak and prevent the inbound xml from being parsed twice for every message.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 17542
diff changeset
766 xmlnode_set_attrib(message_node, "to", bb->name);
61005dea822b Cleanup, fix a leak and prevent the inbound xml from being parsed twice for every message.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 17542
diff changeset
767 xmlnode_set_attrib(message_node, "from", purple_account_get_username(data->account));
61005dea822b Cleanup, fix a leak and prevent the inbound xml from being parsed twice for every message.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 17542
diff changeset
768 xmlnode_set_attrib(message_node, "type", "chat");
61005dea822b Cleanup, fix a leak and prevent the inbound xml from being parsed twice for every message.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 17542
diff changeset
769
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
770 /* Enclose the message from the UI within a "font" node */
17553
61005dea822b Cleanup, fix a leak and prevent the inbound xml from being parsed twice for every message.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 17542
diff changeset
771 node = xmlnode_new_child(message_node, "body");
61005dea822b Cleanup, fix a leak and prevent the inbound xml from being parsed twice for every message.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 17542
diff changeset
772 message = purple_markup_strip_html(body);
61005dea822b Cleanup, fix a leak and prevent the inbound xml from being parsed twice for every message.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 17542
diff changeset
773 xmlnode_insert_data(node, message, strlen(message));
61005dea822b Cleanup, fix a leak and prevent the inbound xml from being parsed twice for every message.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 17542
diff changeset
774 g_free(message);
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
775
17553
61005dea822b Cleanup, fix a leak and prevent the inbound xml from being parsed twice for every message.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 17542
diff changeset
776 node = xmlnode_new_child(message_node, "html");
61005dea822b Cleanup, fix a leak and prevent the inbound xml from being parsed twice for every message.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 17542
diff changeset
777 xmlnode_set_namespace(node, "http://www.w3.org/1999/xhtml");
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
778
17553
61005dea822b Cleanup, fix a leak and prevent the inbound xml from being parsed twice for every message.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 17542
diff changeset
779 node = xmlnode_new_child(node, "body");
61005dea822b Cleanup, fix a leak and prevent the inbound xml from being parsed twice for every message.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 17542
diff changeset
780 message = g_strdup_printf("<font>%s</font>", body);
61005dea822b Cleanup, fix a leak and prevent the inbound xml from being parsed twice for every message.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 17542
diff changeset
781 node2 = xmlnode_from_str(message, strlen(message));
61005dea822b Cleanup, fix a leak and prevent the inbound xml from being parsed twice for every message.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 17542
diff changeset
782 g_free(message);
61005dea822b Cleanup, fix a leak and prevent the inbound xml from being parsed twice for every message.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 17542
diff changeset
783 xmlnode_insert_child(node, node2);
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
784
17553
61005dea822b Cleanup, fix a leak and prevent the inbound xml from being parsed twice for every message.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 17542
diff changeset
785 node = xmlnode_new_child(message_node, "x");
61005dea822b Cleanup, fix a leak and prevent the inbound xml from being parsed twice for every message.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 17542
diff changeset
786 xmlnode_set_namespace(node, "jabber:x:event");
61005dea822b Cleanup, fix a leak and prevent the inbound xml from being parsed twice for every message.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 17542
diff changeset
787 xmlnode_insert_child(node, xmlnode_new("composing"));
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
788
17553
61005dea822b Cleanup, fix a leak and prevent the inbound xml from being parsed twice for every message.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 17542
diff changeset
789 message = xmlnode_to_str(message_node, NULL);
15811
71b017348c39 plug some memory leaks
Stu Tomlinson <stu@nosnilmot.com>
parents: 15373
diff changeset
790 xmlnode_free(message_node);
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
791
17558
6e4e2d234c3a Update Bonjour to do nonblocking I/O correctly.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 17556
diff changeset
792 ret = _send_data(pb, message) >= 0;
17553
61005dea822b Cleanup, fix a leak and prevent the inbound xml from being parsed twice for every message.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 17542
diff changeset
793
15811
71b017348c39 plug some memory leaks
Stu Tomlinson <stu@nosnilmot.com>
parents: 15373
diff changeset
794 g_free(message);
71b017348c39 plug some memory leaks
Stu Tomlinson <stu@nosnilmot.com>
parents: 15373
diff changeset
795
17558
6e4e2d234c3a Update Bonjour to do nonblocking I/O correctly.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 17556
diff changeset
796 return ret;
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
797 }
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
798
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
799 void
17556
612dc5149964 Close conversation connections when logging out of the Bonjour account. This also fixes leakage.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 17555
diff changeset
800 bonjour_jabber_close_conversation(BonjourJabberConversation *bconv)
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
801 {
17553
61005dea822b Cleanup, fix a leak and prevent the inbound xml from being parsed twice for every message.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 17542
diff changeset
802 if (bconv != NULL)
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
803 {
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
804 /* Close the socket and remove the watcher */
17553
61005dea822b Cleanup, fix a leak and prevent the inbound xml from being parsed twice for every message.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 17542
diff changeset
805 if (bconv->socket >= 0) {
61005dea822b Cleanup, fix a leak and prevent the inbound xml from being parsed twice for every message.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 17542
diff changeset
806 /* Send the end of the stream to the other end of the conversation */
18761
316be7e715c6 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 <daniel.atallah@gmail.com>
parents: 18651
diff changeset
807 if (bconv->sent_stream_start)
17553
61005dea822b Cleanup, fix a leak and prevent the inbound xml from being parsed twice for every message.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 17542
diff changeset
808 send(bconv->socket, STREAM_END, strlen(STREAM_END), 0);
61005dea822b Cleanup, fix a leak and prevent the inbound xml from being parsed twice for every message.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 17542
diff changeset
809 /* TODO: We're really supposed to wait for "</stream:stream>" before closing the socket */
61005dea822b Cleanup, fix a leak and prevent the inbound xml from being parsed twice for every message.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 17542
diff changeset
810 close(bconv->socket);
61005dea822b Cleanup, fix a leak and prevent the inbound xml from being parsed twice for every message.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 17542
diff changeset
811 }
19399
649ac48fce1d Reset unsigned int input handlers to 0 instead of -1.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 19233
diff changeset
812 if (bconv->rx_handler != 0)
17558
6e4e2d234c3a Update Bonjour to do nonblocking I/O correctly.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 17556
diff changeset
813 purple_input_remove(bconv->rx_handler);
6e4e2d234c3a Update Bonjour to do nonblocking I/O correctly.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 17556
diff changeset
814 if (bconv->tx_handler > 0)
6e4e2d234c3a Update Bonjour to do nonblocking I/O correctly.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 17556
diff changeset
815 purple_input_remove(bconv->tx_handler);
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
816
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
817 /* Free all the data related to the conversation */
17558
6e4e2d234c3a Update Bonjour to do nonblocking I/O correctly.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 17556
diff changeset
818 purple_circ_buffer_destroy(bconv->tx_buf);
6e4e2d234c3a Update Bonjour to do nonblocking I/O correctly.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 17556
diff changeset
819 if (bconv->connect_data != NULL)
6e4e2d234c3a Update Bonjour to do nonblocking I/O correctly.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 17556
diff changeset
820 purple_proxy_connect_cancel(bconv->connect_data);
6e4e2d234c3a Update Bonjour to do nonblocking I/O correctly.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 17556
diff changeset
821 if (bconv->stream_data != NULL) {
6e4e2d234c3a Update Bonjour to do nonblocking I/O correctly.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 17556
diff changeset
822 struct _stream_start_data *ss = bconv->stream_data;
6e4e2d234c3a Update Bonjour to do nonblocking I/O correctly.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 17556
diff changeset
823 g_free(ss->msg);
6e4e2d234c3a Update Bonjour to do nonblocking I/O correctly.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 17556
diff changeset
824 g_free(ss);
6e4e2d234c3a Update Bonjour to do nonblocking I/O correctly.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 17556
diff changeset
825 }
18761
316be7e715c6 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 <daniel.atallah@gmail.com>
parents: 18651
diff changeset
826
316be7e715c6 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 <daniel.atallah@gmail.com>
parents: 18651
diff changeset
827 if (bconv->context != NULL)
316be7e715c6 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 <daniel.atallah@gmail.com>
parents: 18651
diff changeset
828 bonjour_parser_setup(bconv);
316be7e715c6 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 <daniel.atallah@gmail.com>
parents: 18651
diff changeset
829
17553
61005dea822b Cleanup, fix a leak and prevent the inbound xml from being parsed twice for every message.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 17542
diff changeset
830 g_free(bconv);
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
831 }
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
832 }
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
833
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
834 void
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
835 bonjour_jabber_stop(BonjourJabber *data)
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
836 {
17542
496d007a8912 Some more Bonjour cleanup and leak fixing.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 17541
diff changeset
837 /* Close the server socket and remove the watcher */
17541
a62a695ccfb5 Improve Bonjour error handling when there are errors "connecting".
Daniel Atallah <daniel.atallah@gmail.com>
parents: 17500
diff changeset
838 if (data->socket >= 0)
a62a695ccfb5 Improve Bonjour error handling when there are errors "connecting".
Daniel Atallah <daniel.atallah@gmail.com>
parents: 17500
diff changeset
839 close(data->socket);
a62a695ccfb5 Improve Bonjour error handling when there are errors "connecting".
Daniel Atallah <daniel.atallah@gmail.com>
parents: 17500
diff changeset
840 if (data->watcher_id > 0)
a62a695ccfb5 Improve Bonjour error handling when there are errors "connecting".
Daniel Atallah <daniel.atallah@gmail.com>
parents: 17500
diff changeset
841 purple_input_remove(data->watcher_id);
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
842
17542
496d007a8912 Some more Bonjour cleanup and leak fixing.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 17541
diff changeset
843 /* Close all the conversation sockets and remove all the watchers after sending end streams */
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
844 if (data->account->gc != NULL)
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
845 {
17553
61005dea822b Cleanup, fix a leak and prevent the inbound xml from being parsed twice for every message.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 17542
diff changeset
846 GSList *buddies, *l;
17542
496d007a8912 Some more Bonjour cleanup and leak fixing.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 17541
diff changeset
847
17553
61005dea822b Cleanup, fix a leak and prevent the inbound xml from being parsed twice for every message.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 17542
diff changeset
848 buddies = purple_find_buddies(data->account, purple_account_get_username(data->account));
17556
612dc5149964 Close conversation connections when logging out of the Bonjour account. This also fixes leakage.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 17555
diff changeset
849 for (l = buddies; l; l = l->next) {
612dc5149964 Close conversation connections when logging out of the Bonjour account. This also fixes leakage.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 17555
diff changeset
850 BonjourBuddy *bb = ((PurpleBuddy*) l->data)->proto_data;
612dc5149964 Close conversation connections when logging out of the Bonjour account. This also fixes leakage.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 17555
diff changeset
851 bonjour_jabber_close_conversation(bb->conversation);
612dc5149964 Close conversation connections when logging out of the Bonjour account. This also fixes leakage.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 17555
diff changeset
852 bb->conversation = NULL;
612dc5149964 Close conversation connections when logging out of the Bonjour account. This also fixes leakage.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 17555
diff changeset
853 }
17558
6e4e2d234c3a Update Bonjour to do nonblocking I/O correctly.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 17556
diff changeset
854
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
855 g_slist_free(buddies);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
856 }
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
857 }
21437
db7fa42845f6 Patch from some Intel folks to implement file transfer in Bonjour using XEP-0096 and 0065. This hopefully will work with Gaijm (haven't yet tested) and, of course, between libpurple instances; it will not work with Adium or iChat.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 21418
diff changeset
858 static PurpleBuddy *
db7fa42845f6 Patch from some Intel folks to implement file transfer in Bonjour using XEP-0096 and 0065. This hopefully will work with Gaijm (haven't yet tested) and, of course, between libpurple instances; it will not work with Adium or iChat.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 21418
diff changeset
859 _start_conversation(BonjourJabber *data, const gchar *to)
db7fa42845f6 Patch from some Intel folks to implement file transfer in Bonjour using XEP-0096 and 0065. This hopefully will work with Gaijm (haven't yet tested) and, of course, between libpurple instances; it will not work with Adium or iChat.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 21418
diff changeset
860 {
db7fa42845f6 Patch from some Intel folks to implement file transfer in Bonjour using XEP-0096 and 0065. This hopefully will work with Gaijm (haven't yet tested) and, of course, between libpurple instances; it will not work with Adium or iChat.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 21418
diff changeset
861 PurpleBuddy *pb = NULL;
db7fa42845f6 Patch from some Intel folks to implement file transfer in Bonjour using XEP-0096 and 0065. This hopefully will work with Gaijm (haven't yet tested) and, of course, between libpurple instances; it will not work with Adium or iChat.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 21418
diff changeset
862 BonjourBuddy *bb = NULL;
db7fa42845f6 Patch from some Intel folks to implement file transfer in Bonjour using XEP-0096 and 0065. This hopefully will work with Gaijm (haven't yet tested) and, of course, between libpurple instances; it will not work with Adium or iChat.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 21418
diff changeset
863
db7fa42845f6 Patch from some Intel folks to implement file transfer in Bonjour using XEP-0096 and 0065. This hopefully will work with Gaijm (haven't yet tested) and, of course, between libpurple instances; it will not work with Adium or iChat.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 21418
diff changeset
864 if(data == NULL || to == NULL)
db7fa42845f6 Patch from some Intel folks to implement file transfer in Bonjour using XEP-0096 and 0065. This hopefully will work with Gaijm (haven't yet tested) and, of course, between libpurple instances; it will not work with Adium or iChat.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 21418
diff changeset
865 return NULL;
db7fa42845f6 Patch from some Intel folks to implement file transfer in Bonjour using XEP-0096 and 0065. This hopefully will work with Gaijm (haven't yet tested) and, of course, between libpurple instances; it will not work with Adium or iChat.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 21418
diff changeset
866
db7fa42845f6 Patch from some Intel folks to implement file transfer in Bonjour using XEP-0096 and 0065. This hopefully will work with Gaijm (haven't yet tested) and, of course, between libpurple instances; it will not work with Adium or iChat.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 21418
diff changeset
867 purple_debug_info("Bonjour", "start-conversation with %s - \n", to);
db7fa42845f6 Patch from some Intel folks to implement file transfer in Bonjour using XEP-0096 and 0065. This hopefully will work with Gaijm (haven't yet tested) and, of course, between libpurple instances; it will not work with Adium or iChat.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 21418
diff changeset
868
db7fa42845f6 Patch from some Intel folks to implement file transfer in Bonjour using XEP-0096 and 0065. This hopefully will work with Gaijm (haven't yet tested) and, of course, between libpurple instances; it will not work with Adium or iChat.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 21418
diff changeset
869 pb = purple_find_buddy(data->account, to);
db7fa42845f6 Patch from some Intel folks to implement file transfer in Bonjour using XEP-0096 and 0065. This hopefully will work with Gaijm (haven't yet tested) and, of course, between libpurple instances; it will not work with Adium or iChat.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 21418
diff changeset
870 if (pb == NULL)
db7fa42845f6 Patch from some Intel folks to implement file transfer in Bonjour using XEP-0096 and 0065. This hopefully will work with Gaijm (haven't yet tested) and, of course, between libpurple instances; it will not work with Adium or iChat.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 21418
diff changeset
871 /* You can not send a message to an offline buddy */
db7fa42845f6 Patch from some Intel folks to implement file transfer in Bonjour using XEP-0096 and 0065. This hopefully will work with Gaijm (haven't yet tested) and, of course, between libpurple instances; it will not work with Adium or iChat.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 21418
diff changeset
872 return NULL;
db7fa42845f6 Patch from some Intel folks to implement file transfer in Bonjour using XEP-0096 and 0065. This hopefully will work with Gaijm (haven't yet tested) and, of course, between libpurple instances; it will not work with Adium or iChat.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 21418
diff changeset
873
db7fa42845f6 Patch from some Intel folks to implement file transfer in Bonjour using XEP-0096 and 0065. This hopefully will work with Gaijm (haven't yet tested) and, of course, between libpurple instances; it will not work with Adium or iChat.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 21418
diff changeset
874 bb = (BonjourBuddy *) pb->proto_data;
db7fa42845f6 Patch from some Intel folks to implement file transfer in Bonjour using XEP-0096 and 0065. This hopefully will work with Gaijm (haven't yet tested) and, of course, between libpurple instances; it will not work with Adium or iChat.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 21418
diff changeset
875 if(bb == NULL)
db7fa42845f6 Patch from some Intel folks to implement file transfer in Bonjour using XEP-0096 and 0065. This hopefully will work with Gaijm (haven't yet tested) and, of course, between libpurple instances; it will not work with Adium or iChat.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 21418
diff changeset
876 return NULL;
db7fa42845f6 Patch from some Intel folks to implement file transfer in Bonjour using XEP-0096 and 0065. This hopefully will work with Gaijm (haven't yet tested) and, of course, between libpurple instances; it will not work with Adium or iChat.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 21418
diff changeset
877
db7fa42845f6 Patch from some Intel folks to implement file transfer in Bonjour using XEP-0096 and 0065. This hopefully will work with Gaijm (haven't yet tested) and, of course, between libpurple instances; it will not work with Adium or iChat.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 21418
diff changeset
878 /* Check if there is a previously open conversation */
db7fa42845f6 Patch from some Intel folks to implement file transfer in Bonjour using XEP-0096 and 0065. This hopefully will work with Gaijm (haven't yet tested) and, of course, between libpurple instances; it will not work with Adium or iChat.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 21418
diff changeset
879 if (bb->conversation == NULL)
db7fa42845f6 Patch from some Intel folks to implement file transfer in Bonjour using XEP-0096 and 0065. This hopefully will work with Gaijm (haven't yet tested) and, of course, between libpurple instances; it will not work with Adium or iChat.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 21418
diff changeset
880 {
db7fa42845f6 Patch from some Intel folks to implement file transfer in Bonjour using XEP-0096 and 0065. This hopefully will work with Gaijm (haven't yet tested) and, of course, between libpurple instances; it will not work with Adium or iChat.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 21418
diff changeset
881 PurpleProxyConnectData *connect_data;
db7fa42845f6 Patch from some Intel folks to implement file transfer in Bonjour using XEP-0096 and 0065. This hopefully will work with Gaijm (haven't yet tested) and, of course, between libpurple instances; it will not work with Adium or iChat.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 21418
diff changeset
882 PurpleProxyInfo *proxy_info;
db7fa42845f6 Patch from some Intel folks to implement file transfer in Bonjour using XEP-0096 and 0065. This hopefully will work with Gaijm (haven't yet tested) and, of course, between libpurple instances; it will not work with Adium or iChat.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 21418
diff changeset
883
db7fa42845f6 Patch from some Intel folks to implement file transfer in Bonjour using XEP-0096 and 0065. This hopefully will work with Gaijm (haven't yet tested) and, of course, between libpurple instances; it will not work with Adium or iChat.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 21418
diff changeset
884 /* Make sure that the account always has a proxy of "none".
db7fa42845f6 Patch from some Intel folks to implement file transfer in Bonjour using XEP-0096 and 0065. This hopefully will work with Gaijm (haven't yet tested) and, of course, between libpurple instances; it will not work with Adium or iChat.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 21418
diff changeset
885 * This is kind of dirty, but proxy_connect_none() isn't exposed. */
db7fa42845f6 Patch from some Intel folks to implement file transfer in Bonjour using XEP-0096 and 0065. This hopefully will work with Gaijm (haven't yet tested) and, of course, between libpurple instances; it will not work with Adium or iChat.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 21418
diff changeset
886 proxy_info = purple_account_get_proxy_info(data->account);
db7fa42845f6 Patch from some Intel folks to implement file transfer in Bonjour using XEP-0096 and 0065. This hopefully will work with Gaijm (haven't yet tested) and, of course, between libpurple instances; it will not work with Adium or iChat.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 21418
diff changeset
887 if (proxy_info == NULL) {
db7fa42845f6 Patch from some Intel folks to implement file transfer in Bonjour using XEP-0096 and 0065. This hopefully will work with Gaijm (haven't yet tested) and, of course, between libpurple instances; it will not work with Adium or iChat.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 21418
diff changeset
888 proxy_info = purple_proxy_info_new();
db7fa42845f6 Patch from some Intel folks to implement file transfer in Bonjour using XEP-0096 and 0065. This hopefully will work with Gaijm (haven't yet tested) and, of course, between libpurple instances; it will not work with Adium or iChat.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 21418
diff changeset
889 purple_account_set_proxy_info(data->account, proxy_info);
db7fa42845f6 Patch from some Intel folks to implement file transfer in Bonjour using XEP-0096 and 0065. This hopefully will work with Gaijm (haven't yet tested) and, of course, between libpurple instances; it will not work with Adium or iChat.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 21418
diff changeset
890 }
db7fa42845f6 Patch from some Intel folks to implement file transfer in Bonjour using XEP-0096 and 0065. This hopefully will work with Gaijm (haven't yet tested) and, of course, between libpurple instances; it will not work with Adium or iChat.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 21418
diff changeset
891 purple_proxy_info_set_type(proxy_info, PURPLE_PROXY_NONE);
db7fa42845f6 Patch from some Intel folks to implement file transfer in Bonjour using XEP-0096 and 0065. This hopefully will work with Gaijm (haven't yet tested) and, of course, between libpurple instances; it will not work with Adium or iChat.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 21418
diff changeset
892
db7fa42845f6 Patch from some Intel folks to implement file transfer in Bonjour using XEP-0096 and 0065. This hopefully will work with Gaijm (haven't yet tested) and, of course, between libpurple instances; it will not work with Adium or iChat.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 21418
diff changeset
893 connect_data = purple_proxy_connect(data->account->gc, data->account,
db7fa42845f6 Patch from some Intel folks to implement file transfer in Bonjour using XEP-0096 and 0065. This hopefully will work with Gaijm (haven't yet tested) and, of course, between libpurple instances; it will not work with Adium or iChat.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 21418
diff changeset
894 bb->ip, bb->port_p2pj, _connected_to_buddy, pb);
db7fa42845f6 Patch from some Intel folks to implement file transfer in Bonjour using XEP-0096 and 0065. This hopefully will work with Gaijm (haven't yet tested) and, of course, between libpurple instances; it will not work with Adium or iChat.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 21418
diff changeset
895
db7fa42845f6 Patch from some Intel folks to implement file transfer in Bonjour using XEP-0096 and 0065. This hopefully will work with Gaijm (haven't yet tested) and, of course, between libpurple instances; it will not work with Adium or iChat.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 21418
diff changeset
896 if (connect_data == NULL) {
db7fa42845f6 Patch from some Intel folks to implement file transfer in Bonjour using XEP-0096 and 0065. This hopefully will work with Gaijm (haven't yet tested) and, of course, between libpurple instances; it will not work with Adium or iChat.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 21418
diff changeset
897 purple_debug_error("bonjour", "Unable to connect to buddy (%s).\n", to);
db7fa42845f6 Patch from some Intel folks to implement file transfer in Bonjour using XEP-0096 and 0065. This hopefully will work with Gaijm (haven't yet tested) and, of course, between libpurple instances; it will not work with Adium or iChat.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 21418
diff changeset
898 return NULL;
db7fa42845f6 Patch from some Intel folks to implement file transfer in Bonjour using XEP-0096 and 0065. This hopefully will work with Gaijm (haven't yet tested) and, of course, between libpurple instances; it will not work with Adium or iChat.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 21418
diff changeset
899 }
db7fa42845f6 Patch from some Intel folks to implement file transfer in Bonjour using XEP-0096 and 0065. This hopefully will work with Gaijm (haven't yet tested) and, of course, between libpurple instances; it will not work with Adium or iChat.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 21418
diff changeset
900
db7fa42845f6 Patch from some Intel folks to implement file transfer in Bonjour using XEP-0096 and 0065. This hopefully will work with Gaijm (haven't yet tested) and, of course, between libpurple instances; it will not work with Adium or iChat.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 21418
diff changeset
901 bb->conversation = bonjour_jabber_conv_new();
db7fa42845f6 Patch from some Intel folks to implement file transfer in Bonjour using XEP-0096 and 0065. This hopefully will work with Gaijm (haven't yet tested) and, of course, between libpurple instances; it will not work with Adium or iChat.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 21418
diff changeset
902 bb->conversation->connect_data = connect_data;
db7fa42845f6 Patch from some Intel folks to implement file transfer in Bonjour using XEP-0096 and 0065. This hopefully will work with Gaijm (haven't yet tested) and, of course, between libpurple instances; it will not work with Adium or iChat.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 21418
diff changeset
903 /* We don't want _send_data() to register the tx_handler;
db7fa42845f6 Patch from some Intel folks to implement file transfer in Bonjour using XEP-0096 and 0065. This hopefully will work with Gaijm (haven't yet tested) and, of course, between libpurple instances; it will not work with Adium or iChat.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 21418
diff changeset
904 * that neeeds to wait until we're actually connected. */
db7fa42845f6 Patch from some Intel folks to implement file transfer in Bonjour using XEP-0096 and 0065. This hopefully will work with Gaijm (haven't yet tested) and, of course, between libpurple instances; it will not work with Adium or iChat.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 21418
diff changeset
905 bb->conversation->tx_handler = 0;
db7fa42845f6 Patch from some Intel folks to implement file transfer in Bonjour using XEP-0096 and 0065. This hopefully will work with Gaijm (haven't yet tested) and, of course, between libpurple instances; it will not work with Adium or iChat.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 21418
diff changeset
906 }
db7fa42845f6 Patch from some Intel folks to implement file transfer in Bonjour using XEP-0096 and 0065. This hopefully will work with Gaijm (haven't yet tested) and, of course, between libpurple instances; it will not work with Adium or iChat.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 21418
diff changeset
907 return pb;
db7fa42845f6 Patch from some Intel folks to implement file transfer in Bonjour using XEP-0096 and 0065. This hopefully will work with Gaijm (haven't yet tested) and, of course, between libpurple instances; it will not work with Adium or iChat.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 21418
diff changeset
908 }
db7fa42845f6 Patch from some Intel folks to implement file transfer in Bonjour using XEP-0096 and 0065. This hopefully will work with Gaijm (haven't yet tested) and, of course, between libpurple instances; it will not work with Adium or iChat.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 21418
diff changeset
909
db7fa42845f6 Patch from some Intel folks to implement file transfer in Bonjour using XEP-0096 and 0065. This hopefully will work with Gaijm (haven't yet tested) and, of course, between libpurple instances; it will not work with Adium or iChat.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 21418
diff changeset
910 XepIq *
db7fa42845f6 Patch from some Intel folks to implement file transfer in Bonjour using XEP-0096 and 0065. This hopefully will work with Gaijm (haven't yet tested) and, of course, between libpurple instances; it will not work with Adium or iChat.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 21418
diff changeset
911 xep_iq_new(void *data, XepIqType type, const gchar *to, const gchar *id)
db7fa42845f6 Patch from some Intel folks to implement file transfer in Bonjour using XEP-0096 and 0065. This hopefully will work with Gaijm (haven't yet tested) and, of course, between libpurple instances; it will not work with Adium or iChat.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 21418
diff changeset
912 {
db7fa42845f6 Patch from some Intel folks to implement file transfer in Bonjour using XEP-0096 and 0065. This hopefully will work with Gaijm (haven't yet tested) and, of course, between libpurple instances; it will not work with Adium or iChat.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 21418
diff changeset
913 xmlnode *iq_node = NULL;
db7fa42845f6 Patch from some Intel folks to implement file transfer in Bonjour using XEP-0096 and 0065. This hopefully will work with Gaijm (haven't yet tested) and, of course, between libpurple instances; it will not work with Adium or iChat.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 21418
diff changeset
914 XepIq *iq = NULL;
db7fa42845f6 Patch from some Intel folks to implement file transfer in Bonjour using XEP-0096 and 0065. This hopefully will work with Gaijm (haven't yet tested) and, of course, between libpurple instances; it will not work with Adium or iChat.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 21418
diff changeset
915
db7fa42845f6 Patch from some Intel folks to implement file transfer in Bonjour using XEP-0096 and 0065. This hopefully will work with Gaijm (haven't yet tested) and, of course, between libpurple instances; it will not work with Adium or iChat.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 21418
diff changeset
916 if(data == NULL || to == NULL || id == NULL)
db7fa42845f6 Patch from some Intel folks to implement file transfer in Bonjour using XEP-0096 and 0065. This hopefully will work with Gaijm (haven't yet tested) and, of course, between libpurple instances; it will not work with Adium or iChat.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 21418
diff changeset
917 return NULL;
db7fa42845f6 Patch from some Intel folks to implement file transfer in Bonjour using XEP-0096 and 0065. This hopefully will work with Gaijm (haven't yet tested) and, of course, between libpurple instances; it will not work with Adium or iChat.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 21418
diff changeset
918 iq = g_new0(XepIq, 1);
db7fa42845f6 Patch from some Intel folks to implement file transfer in Bonjour using XEP-0096 and 0065. This hopefully will work with Gaijm (haven't yet tested) and, of course, between libpurple instances; it will not work with Adium or iChat.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 21418
diff changeset
919 if(iq == NULL)
db7fa42845f6 Patch from some Intel folks to implement file transfer in Bonjour using XEP-0096 and 0065. This hopefully will work with Gaijm (haven't yet tested) and, of course, between libpurple instances; it will not work with Adium or iChat.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 21418
diff changeset
920 return NULL;
db7fa42845f6 Patch from some Intel folks to implement file transfer in Bonjour using XEP-0096 and 0065. This hopefully will work with Gaijm (haven't yet tested) and, of course, between libpurple instances; it will not work with Adium or iChat.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 21418
diff changeset
921
db7fa42845f6 Patch from some Intel folks to implement file transfer in Bonjour using XEP-0096 and 0065. This hopefully will work with Gaijm (haven't yet tested) and, of course, between libpurple instances; it will not work with Adium or iChat.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 21418
diff changeset
922 iq_node = xmlnode_new("iq");
db7fa42845f6 Patch from some Intel folks to implement file transfer in Bonjour using XEP-0096 and 0065. This hopefully will work with Gaijm (haven't yet tested) and, of course, between libpurple instances; it will not work with Adium or iChat.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 21418
diff changeset
923 if(iq_node == NULL) {
db7fa42845f6 Patch from some Intel folks to implement file transfer in Bonjour using XEP-0096 and 0065. This hopefully will work with Gaijm (haven't yet tested) and, of course, between libpurple instances; it will not work with Adium or iChat.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 21418
diff changeset
924 g_free(iq);
db7fa42845f6 Patch from some Intel folks to implement file transfer in Bonjour using XEP-0096 and 0065. This hopefully will work with Gaijm (haven't yet tested) and, of course, between libpurple instances; it will not work with Adium or iChat.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 21418
diff changeset
925 return NULL;
db7fa42845f6 Patch from some Intel folks to implement file transfer in Bonjour using XEP-0096 and 0065. This hopefully will work with Gaijm (haven't yet tested) and, of course, between libpurple instances; it will not work with Adium or iChat.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 21418
diff changeset
926 }
db7fa42845f6 Patch from some Intel folks to implement file transfer in Bonjour using XEP-0096 and 0065. This hopefully will work with Gaijm (haven't yet tested) and, of course, between libpurple instances; it will not work with Adium or iChat.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 21418
diff changeset
927
db7fa42845f6 Patch from some Intel folks to implement file transfer in Bonjour using XEP-0096 and 0065. This hopefully will work with Gaijm (haven't yet tested) and, of course, between libpurple instances; it will not work with Adium or iChat.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 21418
diff changeset
928 xmlnode_set_attrib(iq_node, "to", to);
db7fa42845f6 Patch from some Intel folks to implement file transfer in Bonjour using XEP-0096 and 0065. This hopefully will work with Gaijm (haven't yet tested) and, of course, between libpurple instances; it will not work with Adium or iChat.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 21418
diff changeset
929 xmlnode_set_attrib(iq_node, "id", id);
db7fa42845f6 Patch from some Intel folks to implement file transfer in Bonjour using XEP-0096 and 0065. This hopefully will work with Gaijm (haven't yet tested) and, of course, between libpurple instances; it will not work with Adium or iChat.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 21418
diff changeset
930 switch (type) {
db7fa42845f6 Patch from some Intel folks to implement file transfer in Bonjour using XEP-0096 and 0065. This hopefully will work with Gaijm (haven't yet tested) and, of course, between libpurple instances; it will not work with Adium or iChat.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 21418
diff changeset
931 case XEP_IQ_SET:
db7fa42845f6 Patch from some Intel folks to implement file transfer in Bonjour using XEP-0096 and 0065. This hopefully will work with Gaijm (haven't yet tested) and, of course, between libpurple instances; it will not work with Adium or iChat.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 21418
diff changeset
932 xmlnode_set_attrib(iq_node, "type", "set");
db7fa42845f6 Patch from some Intel folks to implement file transfer in Bonjour using XEP-0096 and 0065. This hopefully will work with Gaijm (haven't yet tested) and, of course, between libpurple instances; it will not work with Adium or iChat.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 21418
diff changeset
933 break;
db7fa42845f6 Patch from some Intel folks to implement file transfer in Bonjour using XEP-0096 and 0065. This hopefully will work with Gaijm (haven't yet tested) and, of course, between libpurple instances; it will not work with Adium or iChat.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 21418
diff changeset
934 case XEP_IQ_GET:
db7fa42845f6 Patch from some Intel folks to implement file transfer in Bonjour using XEP-0096 and 0065. This hopefully will work with Gaijm (haven't yet tested) and, of course, between libpurple instances; it will not work with Adium or iChat.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 21418
diff changeset
935 xmlnode_set_attrib(iq_node, "type", "get");
db7fa42845f6 Patch from some Intel folks to implement file transfer in Bonjour using XEP-0096 and 0065. This hopefully will work with Gaijm (haven't yet tested) and, of course, between libpurple instances; it will not work with Adium or iChat.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 21418
diff changeset
936 break;
db7fa42845f6 Patch from some Intel folks to implement file transfer in Bonjour using XEP-0096 and 0065. This hopefully will work with Gaijm (haven't yet tested) and, of course, between libpurple instances; it will not work with Adium or iChat.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 21418
diff changeset
937 case XEP_IQ_RESULT:
db7fa42845f6 Patch from some Intel folks to implement file transfer in Bonjour using XEP-0096 and 0065. This hopefully will work with Gaijm (haven't yet tested) and, of course, between libpurple instances; it will not work with Adium or iChat.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 21418
diff changeset
938 xmlnode_set_attrib(iq_node, "type", "result");
db7fa42845f6 Patch from some Intel folks to implement file transfer in Bonjour using XEP-0096 and 0065. This hopefully will work with Gaijm (haven't yet tested) and, of course, between libpurple instances; it will not work with Adium or iChat.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 21418
diff changeset
939 break;
db7fa42845f6 Patch from some Intel folks to implement file transfer in Bonjour using XEP-0096 and 0065. This hopefully will work with Gaijm (haven't yet tested) and, of course, between libpurple instances; it will not work with Adium or iChat.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 21418
diff changeset
940 case XEP_IQ_ERROR:
db7fa42845f6 Patch from some Intel folks to implement file transfer in Bonjour using XEP-0096 and 0065. This hopefully will work with Gaijm (haven't yet tested) and, of course, between libpurple instances; it will not work with Adium or iChat.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 21418
diff changeset
941 xmlnode_set_attrib(iq_node, "type", "error");
db7fa42845f6 Patch from some Intel folks to implement file transfer in Bonjour using XEP-0096 and 0065. This hopefully will work with Gaijm (haven't yet tested) and, of course, between libpurple instances; it will not work with Adium or iChat.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 21418
diff changeset
942 break;
db7fa42845f6 Patch from some Intel folks to implement file transfer in Bonjour using XEP-0096 and 0065. This hopefully will work with Gaijm (haven't yet tested) and, of course, between libpurple instances; it will not work with Adium or iChat.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 21418
diff changeset
943 case XEP_IQ_NONE:
db7fa42845f6 Patch from some Intel folks to implement file transfer in Bonjour using XEP-0096 and 0065. This hopefully will work with Gaijm (haven't yet tested) and, of course, between libpurple instances; it will not work with Adium or iChat.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 21418
diff changeset
944 default:
db7fa42845f6 Patch from some Intel folks to implement file transfer in Bonjour using XEP-0096 and 0065. This hopefully will work with Gaijm (haven't yet tested) and, of course, between libpurple instances; it will not work with Adium or iChat.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 21418
diff changeset
945 xmlnode_set_attrib(iq_node, "type", "none");
db7fa42845f6 Patch from some Intel folks to implement file transfer in Bonjour using XEP-0096 and 0065. This hopefully will work with Gaijm (haven't yet tested) and, of course, between libpurple instances; it will not work with Adium or iChat.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 21418
diff changeset
946 break;
db7fa42845f6 Patch from some Intel folks to implement file transfer in Bonjour using XEP-0096 and 0065. This hopefully will work with Gaijm (haven't yet tested) and, of course, between libpurple instances; it will not work with Adium or iChat.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 21418
diff changeset
947 }
db7fa42845f6 Patch from some Intel folks to implement file transfer in Bonjour using XEP-0096 and 0065. This hopefully will work with Gaijm (haven't yet tested) and, of course, between libpurple instances; it will not work with Adium or iChat.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 21418
diff changeset
948
db7fa42845f6 Patch from some Intel folks to implement file transfer in Bonjour using XEP-0096 and 0065. This hopefully will work with Gaijm (haven't yet tested) and, of course, between libpurple instances; it will not work with Adium or iChat.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 21418
diff changeset
949 iq->node = iq_node;
db7fa42845f6 Patch from some Intel folks to implement file transfer in Bonjour using XEP-0096 and 0065. This hopefully will work with Gaijm (haven't yet tested) and, of course, between libpurple instances; it will not work with Adium or iChat.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 21418
diff changeset
950 iq->type = type;
db7fa42845f6 Patch from some Intel folks to implement file transfer in Bonjour using XEP-0096 and 0065. This hopefully will work with Gaijm (haven't yet tested) and, of course, between libpurple instances; it will not work with Adium or iChat.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 21418
diff changeset
951 iq->data = ((BonjourData*)data)->jabber_data;
db7fa42845f6 Patch from some Intel folks to implement file transfer in Bonjour using XEP-0096 and 0065. This hopefully will work with Gaijm (haven't yet tested) and, of course, between libpurple instances; it will not work with Adium or iChat.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 21418
diff changeset
952 iq->to = (char*)to;
db7fa42845f6 Patch from some Intel folks to implement file transfer in Bonjour using XEP-0096 and 0065. This hopefully will work with Gaijm (haven't yet tested) and, of course, between libpurple instances; it will not work with Adium or iChat.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 21418
diff changeset
953 return iq;
db7fa42845f6 Patch from some Intel folks to implement file transfer in Bonjour using XEP-0096 and 0065. This hopefully will work with Gaijm (haven't yet tested) and, of course, between libpurple instances; it will not work with Adium or iChat.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 21418
diff changeset
954 }
db7fa42845f6 Patch from some Intel folks to implement file transfer in Bonjour using XEP-0096 and 0065. This hopefully will work with Gaijm (haven't yet tested) and, of course, between libpurple instances; it will not work with Adium or iChat.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 21418
diff changeset
955
db7fa42845f6 Patch from some Intel folks to implement file transfer in Bonjour using XEP-0096 and 0065. This hopefully will work with Gaijm (haven't yet tested) and, of course, between libpurple instances; it will not work with Adium or iChat.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 21418
diff changeset
956 static gboolean
db7fa42845f6 Patch from some Intel folks to implement file transfer in Bonjour using XEP-0096 and 0065. This hopefully will work with Gaijm (haven't yet tested) and, of course, between libpurple instances; it will not work with Adium or iChat.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 21418
diff changeset
957 check_if_blocked(PurpleBuddy *pb)
db7fa42845f6 Patch from some Intel folks to implement file transfer in Bonjour using XEP-0096 and 0065. This hopefully will work with Gaijm (haven't yet tested) and, of course, between libpurple instances; it will not work with Adium or iChat.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 21418
diff changeset
958 {
db7fa42845f6 Patch from some Intel folks to implement file transfer in Bonjour using XEP-0096 and 0065. This hopefully will work with Gaijm (haven't yet tested) and, of course, between libpurple instances; it will not work with Adium or iChat.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 21418
diff changeset
959 gboolean blocked = FALSE;
db7fa42845f6 Patch from some Intel folks to implement file transfer in Bonjour using XEP-0096 and 0065. This hopefully will work with Gaijm (haven't yet tested) and, of course, between libpurple instances; it will not work with Adium or iChat.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 21418
diff changeset
960 GSList *l = NULL;
db7fa42845f6 Patch from some Intel folks to implement file transfer in Bonjour using XEP-0096 and 0065. This hopefully will work with Gaijm (haven't yet tested) and, of course, between libpurple instances; it will not work with Adium or iChat.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 21418
diff changeset
961 PurpleAccount *acc = NULL;
db7fa42845f6 Patch from some Intel folks to implement file transfer in Bonjour using XEP-0096 and 0065. This hopefully will work with Gaijm (haven't yet tested) and, of course, between libpurple instances; it will not work with Adium or iChat.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 21418
diff changeset
962
db7fa42845f6 Patch from some Intel folks to implement file transfer in Bonjour using XEP-0096 and 0065. This hopefully will work with Gaijm (haven't yet tested) and, of course, between libpurple instances; it will not work with Adium or iChat.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 21418
diff changeset
963 if(pb == NULL)
db7fa42845f6 Patch from some Intel folks to implement file transfer in Bonjour using XEP-0096 and 0065. This hopefully will work with Gaijm (haven't yet tested) and, of course, between libpurple instances; it will not work with Adium or iChat.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 21418
diff changeset
964 return FALSE;
db7fa42845f6 Patch from some Intel folks to implement file transfer in Bonjour using XEP-0096 and 0065. This hopefully will work with Gaijm (haven't yet tested) and, of course, between libpurple instances; it will not work with Adium or iChat.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 21418
diff changeset
965
db7fa42845f6 Patch from some Intel folks to implement file transfer in Bonjour using XEP-0096 and 0065. This hopefully will work with Gaijm (haven't yet tested) and, of course, between libpurple instances; it will not work with Adium or iChat.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 21418
diff changeset
966 acc = pb->account;
db7fa42845f6 Patch from some Intel folks to implement file transfer in Bonjour using XEP-0096 and 0065. This hopefully will work with Gaijm (haven't yet tested) and, of course, between libpurple instances; it will not work with Adium or iChat.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 21418
diff changeset
967
db7fa42845f6 Patch from some Intel folks to implement file transfer in Bonjour using XEP-0096 and 0065. This hopefully will work with Gaijm (haven't yet tested) and, of course, between libpurple instances; it will not work with Adium or iChat.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 21418
diff changeset
968 for(l = acc->deny; l != NULL; l = l->next) {
db7fa42845f6 Patch from some Intel folks to implement file transfer in Bonjour using XEP-0096 and 0065. This hopefully will work with Gaijm (haven't yet tested) and, of course, between libpurple instances; it will not work with Adium or iChat.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 21418
diff changeset
969 if(!purple_utf8_strcasecmp(pb->name, (char *)l->data)) {
db7fa42845f6 Patch from some Intel folks to implement file transfer in Bonjour using XEP-0096 and 0065. This hopefully will work with Gaijm (haven't yet tested) and, of course, between libpurple instances; it will not work with Adium or iChat.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 21418
diff changeset
970 purple_debug_info("Bonjour", "%s has been blocked.\n", pb->name, acc->username);
db7fa42845f6 Patch from some Intel folks to implement file transfer in Bonjour using XEP-0096 and 0065. This hopefully will work with Gaijm (haven't yet tested) and, of course, between libpurple instances; it will not work with Adium or iChat.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 21418
diff changeset
971 blocked = TRUE;
db7fa42845f6 Patch from some Intel folks to implement file transfer in Bonjour using XEP-0096 and 0065. This hopefully will work with Gaijm (haven't yet tested) and, of course, between libpurple instances; it will not work with Adium or iChat.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 21418
diff changeset
972 break;
db7fa42845f6 Patch from some Intel folks to implement file transfer in Bonjour using XEP-0096 and 0065. This hopefully will work with Gaijm (haven't yet tested) and, of course, between libpurple instances; it will not work with Adium or iChat.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 21418
diff changeset
973 }
db7fa42845f6 Patch from some Intel folks to implement file transfer in Bonjour using XEP-0096 and 0065. This hopefully will work with Gaijm (haven't yet tested) and, of course, between libpurple instances; it will not work with Adium or iChat.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 21418
diff changeset
974 }
db7fa42845f6 Patch from some Intel folks to implement file transfer in Bonjour using XEP-0096 and 0065. This hopefully will work with Gaijm (haven't yet tested) and, of course, between libpurple instances; it will not work with Adium or iChat.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 21418
diff changeset
975 return blocked;
db7fa42845f6 Patch from some Intel folks to implement file transfer in Bonjour using XEP-0096 and 0065. This hopefully will work with Gaijm (haven't yet tested) and, of course, between libpurple instances; it will not work with Adium or iChat.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 21418
diff changeset
976 }
db7fa42845f6 Patch from some Intel folks to implement file transfer in Bonjour using XEP-0096 and 0065. This hopefully will work with Gaijm (haven't yet tested) and, of course, between libpurple instances; it will not work with Adium or iChat.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 21418
diff changeset
977
db7fa42845f6 Patch from some Intel folks to implement file transfer in Bonjour using XEP-0096 and 0065. This hopefully will work with Gaijm (haven't yet tested) and, of course, between libpurple instances; it will not work with Adium or iChat.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 21418
diff changeset
978 static void
db7fa42845f6 Patch from some Intel folks to implement file transfer in Bonjour using XEP-0096 and 0065. This hopefully will work with Gaijm (haven't yet tested) and, of course, between libpurple instances; it will not work with Adium or iChat.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 21418
diff changeset
979 xep_iq_parse(xmlnode *packet, PurpleConnection *connection, PurpleBuddy *pb)
db7fa42845f6 Patch from some Intel folks to implement file transfer in Bonjour using XEP-0096 and 0065. This hopefully will work with Gaijm (haven't yet tested) and, of course, between libpurple instances; it will not work with Adium or iChat.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 21418
diff changeset
980 {
db7fa42845f6 Patch from some Intel folks to implement file transfer in Bonjour using XEP-0096 and 0065. This hopefully will work with Gaijm (haven't yet tested) and, of course, between libpurple instances; it will not work with Adium or iChat.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 21418
diff changeset
981 xmlnode *child = NULL;
db7fa42845f6 Patch from some Intel folks to implement file transfer in Bonjour using XEP-0096 and 0065. This hopefully will work with Gaijm (haven't yet tested) and, of course, between libpurple instances; it will not work with Adium or iChat.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 21418
diff changeset
982
db7fa42845f6 Patch from some Intel folks to implement file transfer in Bonjour using XEP-0096 and 0065. This hopefully will work with Gaijm (haven't yet tested) and, of course, between libpurple instances; it will not work with Adium or iChat.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 21418
diff changeset
983 if(packet == NULL || pb == NULL)
db7fa42845f6 Patch from some Intel folks to implement file transfer in Bonjour using XEP-0096 and 0065. This hopefully will work with Gaijm (haven't yet tested) and, of course, between libpurple instances; it will not work with Adium or iChat.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 21418
diff changeset
984 return;
db7fa42845f6 Patch from some Intel folks to implement file transfer in Bonjour using XEP-0096 and 0065. This hopefully will work with Gaijm (haven't yet tested) and, of course, between libpurple instances; it will not work with Adium or iChat.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 21418
diff changeset
985
db7fa42845f6 Patch from some Intel folks to implement file transfer in Bonjour using XEP-0096 and 0065. This hopefully will work with Gaijm (haven't yet tested) and, of course, between libpurple instances; it will not work with Adium or iChat.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 21418
diff changeset
986 if(connection == NULL) {
db7fa42845f6 Patch from some Intel folks to implement file transfer in Bonjour using XEP-0096 and 0065. This hopefully will work with Gaijm (haven't yet tested) and, of course, between libpurple instances; it will not work with Adium or iChat.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 21418
diff changeset
987 if(pb->account != NULL)
db7fa42845f6 Patch from some Intel folks to implement file transfer in Bonjour using XEP-0096 and 0065. This hopefully will work with Gaijm (haven't yet tested) and, of course, between libpurple instances; it will not work with Adium or iChat.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 21418
diff changeset
988 connection = (pb->account)->gc;
db7fa42845f6 Patch from some Intel folks to implement file transfer in Bonjour using XEP-0096 and 0065. This hopefully will work with Gaijm (haven't yet tested) and, of course, between libpurple instances; it will not work with Adium or iChat.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 21418
diff changeset
989 }
db7fa42845f6 Patch from some Intel folks to implement file transfer in Bonjour using XEP-0096 and 0065. This hopefully will work with Gaijm (haven't yet tested) and, of course, between libpurple instances; it will not work with Adium or iChat.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 21418
diff changeset
990
db7fa42845f6 Patch from some Intel folks to implement file transfer in Bonjour using XEP-0096 and 0065. This hopefully will work with Gaijm (haven't yet tested) and, of course, between libpurple instances; it will not work with Adium or iChat.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 21418
diff changeset
991 if(check_if_blocked(pb))
db7fa42845f6 Patch from some Intel folks to implement file transfer in Bonjour using XEP-0096 and 0065. This hopefully will work with Gaijm (haven't yet tested) and, of course, between libpurple instances; it will not work with Adium or iChat.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 21418
diff changeset
992 return;
db7fa42845f6 Patch from some Intel folks to implement file transfer in Bonjour using XEP-0096 and 0065. This hopefully will work with Gaijm (haven't yet tested) and, of course, between libpurple instances; it will not work with Adium or iChat.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 21418
diff changeset
993
db7fa42845f6 Patch from some Intel folks to implement file transfer in Bonjour using XEP-0096 and 0065. This hopefully will work with Gaijm (haven't yet tested) and, of course, between libpurple instances; it will not work with Adium or iChat.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 21418
diff changeset
994 if ((child = xmlnode_get_child(packet, "si")) || (child = xmlnode_get_child(packet, "si")))
db7fa42845f6 Patch from some Intel folks to implement file transfer in Bonjour using XEP-0096 and 0065. This hopefully will work with Gaijm (haven't yet tested) and, of course, between libpurple instances; it will not work with Adium or iChat.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 21418
diff changeset
995 xep_si_parse(connection, packet, pb);
db7fa42845f6 Patch from some Intel folks to implement file transfer in Bonjour using XEP-0096 and 0065. This hopefully will work with Gaijm (haven't yet tested) and, of course, between libpurple instances; it will not work with Adium or iChat.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 21418
diff changeset
996 else
db7fa42845f6 Patch from some Intel folks to implement file transfer in Bonjour using XEP-0096 and 0065. This hopefully will work with Gaijm (haven't yet tested) and, of course, between libpurple instances; it will not work with Adium or iChat.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 21418
diff changeset
997 xep_bytestreams_parse(connection, packet, pb);
db7fa42845f6 Patch from some Intel folks to implement file transfer in Bonjour using XEP-0096 and 0065. This hopefully will work with Gaijm (haven't yet tested) and, of course, between libpurple instances; it will not work with Adium or iChat.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 21418
diff changeset
998 }
db7fa42845f6 Patch from some Intel folks to implement file transfer in Bonjour using XEP-0096 and 0065. This hopefully will work with Gaijm (haven't yet tested) and, of course, between libpurple instances; it will not work with Adium or iChat.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 21418
diff changeset
999
db7fa42845f6 Patch from some Intel folks to implement file transfer in Bonjour using XEP-0096 and 0065. This hopefully will work with Gaijm (haven't yet tested) and, of course, between libpurple instances; it will not work with Adium or iChat.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 21418
diff changeset
1000 int
db7fa42845f6 Patch from some Intel folks to implement file transfer in Bonjour using XEP-0096 and 0065. This hopefully will work with Gaijm (haven't yet tested) and, of course, between libpurple instances; it will not work with Adium or iChat.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 21418
diff changeset
1001 xep_iq_send(XepIq *iq)
db7fa42845f6 Patch from some Intel folks to implement file transfer in Bonjour using XEP-0096 and 0065. This hopefully will work with Gaijm (haven't yet tested) and, of course, between libpurple instances; it will not work with Adium or iChat.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 21418
diff changeset
1002 {
db7fa42845f6 Patch from some Intel folks to implement file transfer in Bonjour using XEP-0096 and 0065. This hopefully will work with Gaijm (haven't yet tested) and, of course, between libpurple instances; it will not work with Adium or iChat.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 21418
diff changeset
1003 char *msg = NULL;
db7fa42845f6 Patch from some Intel folks to implement file transfer in Bonjour using XEP-0096 and 0065. This hopefully will work with Gaijm (haven't yet tested) and, of course, between libpurple instances; it will not work with Adium or iChat.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 21418
diff changeset
1004 gint msg_len = 0;
db7fa42845f6 Patch from some Intel folks to implement file transfer in Bonjour using XEP-0096 and 0065. This hopefully will work with Gaijm (haven't yet tested) and, of course, between libpurple instances; it will not work with Adium or iChat.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 21418
diff changeset
1005 int ret = -1;
db7fa42845f6 Patch from some Intel folks to implement file transfer in Bonjour using XEP-0096 and 0065. This hopefully will work with Gaijm (haven't yet tested) and, of course, between libpurple instances; it will not work with Adium or iChat.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 21418
diff changeset
1006 PurpleBuddy *pb = NULL;
db7fa42845f6 Patch from some Intel folks to implement file transfer in Bonjour using XEP-0096 and 0065. This hopefully will work with Gaijm (haven't yet tested) and, of course, between libpurple instances; it will not work with Adium or iChat.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 21418
diff changeset
1007 /* Convert xml node into stream */
db7fa42845f6 Patch from some Intel folks to implement file transfer in Bonjour using XEP-0096 and 0065. This hopefully will work with Gaijm (haven't yet tested) and, of course, between libpurple instances; it will not work with Adium or iChat.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 21418
diff changeset
1008 msg = xmlnode_to_str(iq->node, &msg_len);
db7fa42845f6 Patch from some Intel folks to implement file transfer in Bonjour using XEP-0096 and 0065. This hopefully will work with Gaijm (haven't yet tested) and, of course, between libpurple instances; it will not work with Adium or iChat.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 21418
diff changeset
1009 xmlnode_free(iq->node);
db7fa42845f6 Patch from some Intel folks to implement file transfer in Bonjour using XEP-0096 and 0065. This hopefully will work with Gaijm (haven't yet tested) and, of course, between libpurple instances; it will not work with Adium or iChat.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 21418
diff changeset
1010 /* start the talk, reuse the message socket */
db7fa42845f6 Patch from some Intel folks to implement file transfer in Bonjour using XEP-0096 and 0065. This hopefully will work with Gaijm (haven't yet tested) and, of course, between libpurple instances; it will not work with Adium or iChat.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 21418
diff changeset
1011 pb = _start_conversation ((BonjourJabber*)iq->data, iq->to);
db7fa42845f6 Patch from some Intel folks to implement file transfer in Bonjour using XEP-0096 and 0065. This hopefully will work with Gaijm (haven't yet tested) and, of course, between libpurple instances; it will not work with Adium or iChat.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 21418
diff changeset
1012 /* Send the message */
db7fa42845f6 Patch from some Intel folks to implement file transfer in Bonjour using XEP-0096 and 0065. This hopefully will work with Gaijm (haven't yet tested) and, of course, between libpurple instances; it will not work with Adium or iChat.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 21418
diff changeset
1013 if (pb != NULL)
db7fa42845f6 Patch from some Intel folks to implement file transfer in Bonjour using XEP-0096 and 0065. This hopefully will work with Gaijm (haven't yet tested) and, of course, between libpurple instances; it will not work with Adium or iChat.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 21418
diff changeset
1014 ret = _send_data(pb, msg);
db7fa42845f6 Patch from some Intel folks to implement file transfer in Bonjour using XEP-0096 and 0065. This hopefully will work with Gaijm (haven't yet tested) and, of course, between libpurple instances; it will not work with Adium or iChat.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 21418
diff changeset
1015 g_free(msg);
db7fa42845f6 Patch from some Intel folks to implement file transfer in Bonjour using XEP-0096 and 0065. This hopefully will work with Gaijm (haven't yet tested) and, of course, between libpurple instances; it will not work with Adium or iChat.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 21418
diff changeset
1016 if (ret == -1)
db7fa42845f6 Patch from some Intel folks to implement file transfer in Bonjour using XEP-0096 and 0065. This hopefully will work with Gaijm (haven't yet tested) and, of course, between libpurple instances; it will not work with Adium or iChat.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 21418
diff changeset
1017 return -1;
db7fa42845f6 Patch from some Intel folks to implement file transfer in Bonjour using XEP-0096 and 0065. This hopefully will work with Gaijm (haven't yet tested) and, of course, between libpurple instances; it will not work with Adium or iChat.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 21418
diff changeset
1018 return 0;
db7fa42845f6 Patch from some Intel folks to implement file transfer in Bonjour using XEP-0096 and 0065. This hopefully will work with Gaijm (haven't yet tested) and, of course, between libpurple instances; it will not work with Adium or iChat.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 21418
diff changeset
1019 }
db7fa42845f6 Patch from some Intel folks to implement file transfer in Bonjour using XEP-0096 and 0065. This hopefully will work with Gaijm (haven't yet tested) and, of course, between libpurple instances; it will not work with Adium or iChat.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 21418
diff changeset
1020
db7fa42845f6 Patch from some Intel folks to implement file transfer in Bonjour using XEP-0096 and 0065. This hopefully will work with Gaijm (haven't yet tested) and, of course, between libpurple instances; it will not work with Adium or iChat.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 21418
diff changeset
1021 char *
db7fa42845f6 Patch from some Intel folks to implement file transfer in Bonjour using XEP-0096 and 0065. This hopefully will work with Gaijm (haven't yet tested) and, of course, between libpurple instances; it will not work with Adium or iChat.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 21418
diff changeset
1022 purple_network_get_my_ip_ext2(int fd)
db7fa42845f6 Patch from some Intel folks to implement file transfer in Bonjour using XEP-0096 and 0065. This hopefully will work with Gaijm (haven't yet tested) and, of course, between libpurple instances; it will not work with Adium or iChat.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 21418
diff changeset
1023 {
db7fa42845f6 Patch from some Intel folks to implement file transfer in Bonjour using XEP-0096 and 0065. This hopefully will work with Gaijm (haven't yet tested) and, of course, between libpurple instances; it will not work with Adium or iChat.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 21418
diff changeset
1024 char buffer[1024];
db7fa42845f6 Patch from some Intel folks to implement file transfer in Bonjour using XEP-0096 and 0065. This hopefully will work with Gaijm (haven't yet tested) and, of course, between libpurple instances; it will not work with Adium or iChat.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 21418
diff changeset
1025 static char ip_ext[17 * 10];
db7fa42845f6 Patch from some Intel folks to implement file transfer in Bonjour using XEP-0096 and 0065. This hopefully will work with Gaijm (haven't yet tested) and, of course, between libpurple instances; it will not work with Adium or iChat.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 21418
diff changeset
1026 char *tmp;
db7fa42845f6 Patch from some Intel folks to implement file transfer in Bonjour using XEP-0096 and 0065. This hopefully will work with Gaijm (haven't yet tested) and, of course, between libpurple instances; it will not work with Adium or iChat.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 21418
diff changeset
1027 char *tip;
db7fa42845f6 Patch from some Intel folks to implement file transfer in Bonjour using XEP-0096 and 0065. This hopefully will work with Gaijm (haven't yet tested) and, of course, between libpurple instances; it will not work with Adium or iChat.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 21418
diff changeset
1028 struct ifconf ifc;
db7fa42845f6 Patch from some Intel folks to implement file transfer in Bonjour using XEP-0096 and 0065. This hopefully will work with Gaijm (haven't yet tested) and, of course, between libpurple instances; it will not work with Adium or iChat.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 21418
diff changeset
1029 struct ifreq *ifr;
db7fa42845f6 Patch from some Intel folks to implement file transfer in Bonjour using XEP-0096 and 0065. This hopefully will work with Gaijm (haven't yet tested) and, of course, between libpurple instances; it will not work with Adium or iChat.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 21418
diff changeset
1030 struct sockaddr_in *sinptr;
db7fa42845f6 Patch from some Intel folks to implement file transfer in Bonjour using XEP-0096 and 0065. This hopefully will work with Gaijm (haven't yet tested) and, of course, between libpurple instances; it will not work with Adium or iChat.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 21418
diff changeset
1031 guint32 lhost = htonl(127 * 256 * 256 * 256 + 1);
db7fa42845f6 Patch from some Intel folks to implement file transfer in Bonjour using XEP-0096 and 0065. This hopefully will work with Gaijm (haven't yet tested) and, of course, between libpurple instances; it will not work with Adium or iChat.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 21418
diff changeset
1032 long unsigned int add;
db7fa42845f6 Patch from some Intel folks to implement file transfer in Bonjour using XEP-0096 and 0065. This hopefully will work with Gaijm (haven't yet tested) and, of course, between libpurple instances; it will not work with Adium or iChat.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 21418
diff changeset
1033 int source = fd;
db7fa42845f6 Patch from some Intel folks to implement file transfer in Bonjour using XEP-0096 and 0065. This hopefully will work with Gaijm (haven't yet tested) and, of course, between libpurple instances; it will not work with Adium or iChat.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 21418
diff changeset
1034 int len;
db7fa42845f6 Patch from some Intel folks to implement file transfer in Bonjour using XEP-0096 and 0065. This hopefully will work with Gaijm (haven't yet tested) and, of course, between libpurple instances; it will not work with Adium or iChat.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 21418
diff changeset
1035
db7fa42845f6 Patch from some Intel folks to implement file transfer in Bonjour using XEP-0096 and 0065. This hopefully will work with Gaijm (haven't yet tested) and, of course, between libpurple instances; it will not work with Adium or iChat.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 21418
diff changeset
1036 if (fd < 0)
db7fa42845f6 Patch from some Intel folks to implement file transfer in Bonjour using XEP-0096 and 0065. This hopefully will work with Gaijm (haven't yet tested) and, of course, between libpurple instances; it will not work with Adium or iChat.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 21418
diff changeset
1037 source = socket(PF_INET, SOCK_STREAM, 0);
db7fa42845f6 Patch from some Intel folks to implement file transfer in Bonjour using XEP-0096 and 0065. This hopefully will work with Gaijm (haven't yet tested) and, of course, between libpurple instances; it will not work with Adium or iChat.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 21418
diff changeset
1038
db7fa42845f6 Patch from some Intel folks to implement file transfer in Bonjour using XEP-0096 and 0065. This hopefully will work with Gaijm (haven't yet tested) and, of course, between libpurple instances; it will not work with Adium or iChat.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 21418
diff changeset
1039 ifc.ifc_len = sizeof(buffer);
db7fa42845f6 Patch from some Intel folks to implement file transfer in Bonjour using XEP-0096 and 0065. This hopefully will work with Gaijm (haven't yet tested) and, of course, between libpurple instances; it will not work with Adium or iChat.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 21418
diff changeset
1040 ifc.ifc_req = (struct ifreq *)buffer;
db7fa42845f6 Patch from some Intel folks to implement file transfer in Bonjour using XEP-0096 and 0065. This hopefully will work with Gaijm (haven't yet tested) and, of course, between libpurple instances; it will not work with Adium or iChat.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 21418
diff changeset
1041 ioctl(source, SIOCGIFCONF, &ifc);
db7fa42845f6 Patch from some Intel folks to implement file transfer in Bonjour using XEP-0096 and 0065. This hopefully will work with Gaijm (haven't yet tested) and, of course, between libpurple instances; it will not work with Adium or iChat.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 21418
diff changeset
1042
db7fa42845f6 Patch from some Intel folks to implement file transfer in Bonjour using XEP-0096 and 0065. This hopefully will work with Gaijm (haven't yet tested) and, of course, between libpurple instances; it will not work with Adium or iChat.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 21418
diff changeset
1043 if (fd < 0)
db7fa42845f6 Patch from some Intel folks to implement file transfer in Bonjour using XEP-0096 and 0065. This hopefully will work with Gaijm (haven't yet tested) and, of course, between libpurple instances; it will not work with Adium or iChat.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 21418
diff changeset
1044 close(source);
db7fa42845f6 Patch from some Intel folks to implement file transfer in Bonjour using XEP-0096 and 0065. This hopefully will work with Gaijm (haven't yet tested) and, of course, between libpurple instances; it will not work with Adium or iChat.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 21418
diff changeset
1045 memset(ip_ext, 0, 17 * 10);
db7fa42845f6 Patch from some Intel folks to implement file transfer in Bonjour using XEP-0096 and 0065. This hopefully will work with Gaijm (haven't yet tested) and, of course, between libpurple instances; it will not work with Adium or iChat.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 21418
diff changeset
1046 memcpy(ip_ext, "0.0.0.0", 7);
db7fa42845f6 Patch from some Intel folks to implement file transfer in Bonjour using XEP-0096 and 0065. This hopefully will work with Gaijm (haven't yet tested) and, of course, between libpurple instances; it will not work with Adium or iChat.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 21418
diff changeset
1047 tmp = buffer;
db7fa42845f6 Patch from some Intel folks to implement file transfer in Bonjour using XEP-0096 and 0065. This hopefully will work with Gaijm (haven't yet tested) and, of course, between libpurple instances; it will not work with Adium or iChat.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 21418
diff changeset
1048 tip = ip_ext;
db7fa42845f6 Patch from some Intel folks to implement file transfer in Bonjour using XEP-0096 and 0065. This hopefully will work with Gaijm (haven't yet tested) and, of course, between libpurple instances; it will not work with Adium or iChat.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 21418
diff changeset
1049 while (tmp < buffer + ifc.ifc_len)
db7fa42845f6 Patch from some Intel folks to implement file transfer in Bonjour using XEP-0096 and 0065. This hopefully will work with Gaijm (haven't yet tested) and, of course, between libpurple instances; it will not work with Adium or iChat.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 21418
diff changeset
1050 {
db7fa42845f6 Patch from some Intel folks to implement file transfer in Bonjour using XEP-0096 and 0065. This hopefully will work with Gaijm (haven't yet tested) and, of course, between libpurple instances; it will not work with Adium or iChat.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 21418
diff changeset
1051 ifr = (struct ifreq *)tmp;
db7fa42845f6 Patch from some Intel folks to implement file transfer in Bonjour using XEP-0096 and 0065. This hopefully will work with Gaijm (haven't yet tested) and, of course, between libpurple instances; it will not work with Adium or iChat.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 21418
diff changeset
1052 tmp += HX_SIZE_OF_IFREQ(*ifr);
db7fa42845f6 Patch from some Intel folks to implement file transfer in Bonjour using XEP-0096 and 0065. This hopefully will work with Gaijm (haven't yet tested) and, of course, between libpurple instances; it will not work with Adium or iChat.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 21418
diff changeset
1053
db7fa42845f6 Patch from some Intel folks to implement file transfer in Bonjour using XEP-0096 and 0065. This hopefully will work with Gaijm (haven't yet tested) and, of course, between libpurple instances; it will not work with Adium or iChat.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 21418
diff changeset
1054 if (ifr->ifr_addr.sa_family == AF_INET)
db7fa42845f6 Patch from some Intel folks to implement file transfer in Bonjour using XEP-0096 and 0065. This hopefully will work with Gaijm (haven't yet tested) and, of course, between libpurple instances; it will not work with Adium or iChat.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 21418
diff changeset
1055 {
db7fa42845f6 Patch from some Intel folks to implement file transfer in Bonjour using XEP-0096 and 0065. This hopefully will work with Gaijm (haven't yet tested) and, of course, between libpurple instances; it will not work with Adium or iChat.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 21418
diff changeset
1056 sinptr = (struct sockaddr_in *)&ifr->ifr_addr;
db7fa42845f6 Patch from some Intel folks to implement file transfer in Bonjour using XEP-0096 and 0065. This hopefully will work with Gaijm (haven't yet tested) and, of course, between libpurple instances; it will not work with Adium or iChat.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 21418
diff changeset
1057 if (sinptr->sin_addr.s_addr != lhost)
db7fa42845f6 Patch from some Intel folks to implement file transfer in Bonjour using XEP-0096 and 0065. This hopefully will work with Gaijm (haven't yet tested) and, of course, between libpurple instances; it will not work with Adium or iChat.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 21418
diff changeset
1058 {
db7fa42845f6 Patch from some Intel folks to implement file transfer in Bonjour using XEP-0096 and 0065. This hopefully will work with Gaijm (haven't yet tested) and, of course, between libpurple instances; it will not work with Adium or iChat.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 21418
diff changeset
1059 add = ntohl(sinptr->sin_addr.s_addr);
db7fa42845f6 Patch from some Intel folks to implement file transfer in Bonjour using XEP-0096 and 0065. This hopefully will work with Gaijm (haven't yet tested) and, of course, between libpurple instances; it will not work with Adium or iChat.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 21418
diff changeset
1060 len = g_snprintf(tip, 17, "%lu.%lu.%lu.%lu;",
db7fa42845f6 Patch from some Intel folks to implement file transfer in Bonjour using XEP-0096 and 0065. This hopefully will work with Gaijm (haven't yet tested) and, of course, between libpurple instances; it will not work with Adium or iChat.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 21418
diff changeset
1061 ((add >> 24) & 255),
db7fa42845f6 Patch from some Intel folks to implement file transfer in Bonjour using XEP-0096 and 0065. This hopefully will work with Gaijm (haven't yet tested) and, of course, between libpurple instances; it will not work with Adium or iChat.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 21418
diff changeset
1062 ((add >> 16) & 255),
db7fa42845f6 Patch from some Intel folks to implement file transfer in Bonjour using XEP-0096 and 0065. This hopefully will work with Gaijm (haven't yet tested) and, of course, between libpurple instances; it will not work with Adium or iChat.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 21418
diff changeset
1063 ((add >> 8) & 255),
db7fa42845f6 Patch from some Intel folks to implement file transfer in Bonjour using XEP-0096 and 0065. This hopefully will work with Gaijm (haven't yet tested) and, of course, between libpurple instances; it will not work with Adium or iChat.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 21418
diff changeset
1064 add & 255);
db7fa42845f6 Patch from some Intel folks to implement file transfer in Bonjour using XEP-0096 and 0065. This hopefully will work with Gaijm (haven't yet tested) and, of course, between libpurple instances; it will not work with Adium or iChat.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 21418
diff changeset
1065 tip = (char*) ((int) tip + len);
db7fa42845f6 Patch from some Intel folks to implement file transfer in Bonjour using XEP-0096 and 0065. This hopefully will work with Gaijm (haven't yet tested) and, of course, between libpurple instances; it will not work with Adium or iChat.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 21418
diff changeset
1066 continue;
db7fa42845f6 Patch from some Intel folks to implement file transfer in Bonjour using XEP-0096 and 0065. This hopefully will work with Gaijm (haven't yet tested) and, of course, between libpurple instances; it will not work with Adium or iChat.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 21418
diff changeset
1067 }
db7fa42845f6 Patch from some Intel folks to implement file transfer in Bonjour using XEP-0096 and 0065. This hopefully will work with Gaijm (haven't yet tested) and, of course, between libpurple instances; it will not work with Adium or iChat.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 21418
diff changeset
1068 }
db7fa42845f6 Patch from some Intel folks to implement file transfer in Bonjour using XEP-0096 and 0065. This hopefully will work with Gaijm (haven't yet tested) and, of course, between libpurple instances; it will not work with Adium or iChat.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 21418
diff changeset
1069 }
db7fa42845f6 Patch from some Intel folks to implement file transfer in Bonjour using XEP-0096 and 0065. This hopefully will work with Gaijm (haven't yet tested) and, of course, between libpurple instances; it will not work with Adium or iChat.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 21418
diff changeset
1070
db7fa42845f6 Patch from some Intel folks to implement file transfer in Bonjour using XEP-0096 and 0065. This hopefully will work with Gaijm (haven't yet tested) and, of course, between libpurple instances; it will not work with Adium or iChat.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 21418
diff changeset
1071 return ip_ext;
db7fa42845f6 Patch from some Intel folks to implement file transfer in Bonjour using XEP-0096 and 0065. This hopefully will work with Gaijm (haven't yet tested) and, of course, between libpurple instances; it will not work with Adium or iChat.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 21418
diff changeset
1072 }