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