Sun, 14 Oct 2007 21:08:42 +0000
Rename:
* PurpleDisconnectReason to PurpleConnectionError;
* elements of that enum from PURPLE_REASON_* to PURPLE_CONNECTION_ERROR_*;
* purple_connection_reason_is_fatal to purple_connection_error_is_fatal.
| 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 | */ |
|
11688
d5a7c35ddc80
[gaim-migrate @ 13974]
Daniel Atallah <datallah@pidgin.im>
parents:
11539
diff
changeset
|
22 | #ifndef _WIN32 |
| 11477 | 23 | #include <sys/socket.h> |
| 24 | #include <netinet/in.h> | |
| 25 | #include <arpa/inet.h> | |
|
11688
d5a7c35ddc80
[gaim-migrate @ 13974]
Daniel Atallah <datallah@pidgin.im>
parents:
11539
diff
changeset
|
26 | #else |
|
d5a7c35ddc80
[gaim-migrate @ 13974]
Daniel Atallah <datallah@pidgin.im>
parents:
11539
diff
changeset
|
27 | #include "libc_interface.h" |
|
d5a7c35ddc80
[gaim-migrate @ 13974]
Daniel Atallah <datallah@pidgin.im>
parents:
11539
diff
changeset
|
28 | #endif |
|
d5a7c35ddc80
[gaim-migrate @ 13974]
Daniel Atallah <datallah@pidgin.im>
parents:
11539
diff
changeset
|
29 | #include <sys/types.h> |
| 11477 | 30 | #include <glib.h> |
| 31 | #include <unistd.h> | |
| 32 | #include <fcntl.h> | |
| 33 | ||
|
18338
d3cb08f27e04
More compile fixes from rekkanoryo for G_GNUC_NULL_TERMINATED issues
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
17699
diff
changeset
|
34 | #include "internal.h" |
| 11477 | 35 | #include "network.h" |
| 36 | #include "eventloop.h" | |
| 37 | #include "connection.h" | |
| 38 | #include "blist.h" | |
| 39 | #include "xmlnode.h" | |
| 40 | #include "debug.h" | |
| 41 | #include "notify.h" | |
| 42 | #include "util.h" | |
| 43 | ||
| 44 | #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
|
45 | #include "parser.h" |
| 11477 | 46 | #include "bonjour.h" |
| 47 | #include "buddy.h" | |
| 48 | ||
|
17661
96c6a21c4139
Send 'to' and 'from' attributes in the stream start message.
Daniel Atallah <datallah@pidgin.im>
parents:
17660
diff
changeset
|
49 | #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
|
50 | /* 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
|
51 | #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
|
52 | "<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
|
53 | |
|
12443
ad94864144f8
[gaim-migrate @ 14750]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
11830
diff
changeset
|
54 | #if 0 /* this isn't used anywhere... */ |
|
ad94864144f8
[gaim-migrate @ 14750]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
11830
diff
changeset
|
55 | static const char * |
| 15884 | 56 | _font_size_purple_to_ichat(int size) |
| 11477 | 57 | { |
|
11826
10ebbc41f163
[gaim-migrate @ 14117]
Richard Laager <rlaager@pidgin.im>
parents:
11823
diff
changeset
|
58 | switch (size) { |
|
10ebbc41f163
[gaim-migrate @ 14117]
Richard Laager <rlaager@pidgin.im>
parents:
11823
diff
changeset
|
59 | case 1: |
|
10ebbc41f163
[gaim-migrate @ 14117]
Richard Laager <rlaager@pidgin.im>
parents:
11823
diff
changeset
|
60 | return "8"; |
|
10ebbc41f163
[gaim-migrate @ 14117]
Richard Laager <rlaager@pidgin.im>
parents:
11823
diff
changeset
|
61 | case 2: |
|
10ebbc41f163
[gaim-migrate @ 14117]
Richard Laager <rlaager@pidgin.im>
parents:
11823
diff
changeset
|
62 | return "10"; |
|
10ebbc41f163
[gaim-migrate @ 14117]
Richard Laager <rlaager@pidgin.im>
parents:
11823
diff
changeset
|
63 | case 3: |
|
10ebbc41f163
[gaim-migrate @ 14117]
Richard Laager <rlaager@pidgin.im>
parents:
11823
diff
changeset
|
64 | return "12"; |
|
10ebbc41f163
[gaim-migrate @ 14117]
Richard Laager <rlaager@pidgin.im>
parents:
11823
diff
changeset
|
65 | case 4: |
|
10ebbc41f163
[gaim-migrate @ 14117]
Richard Laager <rlaager@pidgin.im>
parents:
11823
diff
changeset
|
66 | return "14"; |
|
10ebbc41f163
[gaim-migrate @ 14117]
Richard Laager <rlaager@pidgin.im>
parents:
11823
diff
changeset
|
67 | case 5: |
|
10ebbc41f163
[gaim-migrate @ 14117]
Richard Laager <rlaager@pidgin.im>
parents:
11823
diff
changeset
|
68 | return "17"; |
|
10ebbc41f163
[gaim-migrate @ 14117]
Richard Laager <rlaager@pidgin.im>
parents:
11823
diff
changeset
|
69 | case 6: |
|
10ebbc41f163
[gaim-migrate @ 14117]
Richard Laager <rlaager@pidgin.im>
parents:
11823
diff
changeset
|
70 | return "21"; |
|
10ebbc41f163
[gaim-migrate @ 14117]
Richard Laager <rlaager@pidgin.im>
parents:
11823
diff
changeset
|
71 | case 7: |
|
10ebbc41f163
[gaim-migrate @ 14117]
Richard Laager <rlaager@pidgin.im>
parents:
11823
diff
changeset
|
72 | return "24"; |
| 11477 | 73 | } |
|
11539
fbabe3f89777
[gaim-migrate @ 13794]
Mark Doliner <markdoliner@pidgin.im>
parents:
11515
diff
changeset
|
74 | |
|
11826
10ebbc41f163
[gaim-migrate @ 14117]
Richard Laager <rlaager@pidgin.im>
parents:
11823
diff
changeset
|
75 | return "12"; |
| 11477 | 76 | } |
|
12443
ad94864144f8
[gaim-migrate @ 14750]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
11830
diff
changeset
|
77 | #endif |
| 11477 | 78 | |
|
17662
233ff0515d7b
Consolidate BonjourJabberConversation creation and deletion.
Daniel Atallah <datallah@pidgin.im>
parents:
17661
diff
changeset
|
79 | static BonjourJabberConversation * |
|
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
|
80 | bonjour_jabber_conv_new() { |
|
17662
233ff0515d7b
Consolidate BonjourJabberConversation creation and deletion.
Daniel Atallah <datallah@pidgin.im>
parents:
17661
diff
changeset
|
81 | |
|
233ff0515d7b
Consolidate BonjourJabberConversation creation and deletion.
Daniel Atallah <datallah@pidgin.im>
parents:
17661
diff
changeset
|
82 | BonjourJabberConversation *bconv = g_new0(BonjourJabberConversation, 1); |
|
233ff0515d7b
Consolidate BonjourJabberConversation creation and deletion.
Daniel Atallah <datallah@pidgin.im>
parents:
17661
diff
changeset
|
83 | bconv->socket = -1; |
|
17665
26bff2090889
Update Bonjour to do nonblocking I/O correctly.
Daniel Atallah <datallah@pidgin.im>
parents:
17663
diff
changeset
|
84 | 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
|
85 | 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
|
86 | bconv->rx_handler = 0; |
|
17662
233ff0515d7b
Consolidate BonjourJabberConversation creation and deletion.
Daniel Atallah <datallah@pidgin.im>
parents:
17661
diff
changeset
|
87 | |
|
233ff0515d7b
Consolidate BonjourJabberConversation creation and deletion.
Daniel Atallah <datallah@pidgin.im>
parents:
17661
diff
changeset
|
88 | return bconv; |
|
233ff0515d7b
Consolidate BonjourJabberConversation creation and deletion.
Daniel Atallah <datallah@pidgin.im>
parents:
17661
diff
changeset
|
89 | } |
|
233ff0515d7b
Consolidate BonjourJabberConversation creation and deletion.
Daniel Atallah <datallah@pidgin.im>
parents:
17661
diff
changeset
|
90 | |
|
17665
26bff2090889
Update Bonjour to do nonblocking I/O correctly.
Daniel Atallah <datallah@pidgin.im>
parents:
17663
diff
changeset
|
91 | |
|
12443
ad94864144f8
[gaim-migrate @ 14750]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
11830
diff
changeset
|
92 | static const char * |
| 15884 | 93 | _font_size_ichat_to_purple(int size) |
| 11477 | 94 | { |
| 95 | if (size > 24) { | |
|
11826
10ebbc41f163
[gaim-migrate @ 14117]
Richard Laager <rlaager@pidgin.im>
parents:
11823
diff
changeset
|
96 | return "7"; |
|
11539
fbabe3f89777
[gaim-migrate @ 13794]
Mark Doliner <markdoliner@pidgin.im>
parents:
11515
diff
changeset
|
97 | } else if (size >= 21) { |
|
11826
10ebbc41f163
[gaim-migrate @ 14117]
Richard Laager <rlaager@pidgin.im>
parents:
11823
diff
changeset
|
98 | return "6"; |
|
11539
fbabe3f89777
[gaim-migrate @ 13794]
Mark Doliner <markdoliner@pidgin.im>
parents:
11515
diff
changeset
|
99 | } else if (size >= 17) { |
|
11826
10ebbc41f163
[gaim-migrate @ 14117]
Richard Laager <rlaager@pidgin.im>
parents:
11823
diff
changeset
|
100 | return "5"; |
|
11539
fbabe3f89777
[gaim-migrate @ 13794]
Mark Doliner <markdoliner@pidgin.im>
parents:
11515
diff
changeset
|
101 | } else if (size >= 14) { |
|
11826
10ebbc41f163
[gaim-migrate @ 14117]
Richard Laager <rlaager@pidgin.im>
parents:
11823
diff
changeset
|
102 | return "4"; |
|
11539
fbabe3f89777
[gaim-migrate @ 13794]
Mark Doliner <markdoliner@pidgin.im>
parents:
11515
diff
changeset
|
103 | } else if (size >= 12) { |
|
11826
10ebbc41f163
[gaim-migrate @ 14117]
Richard Laager <rlaager@pidgin.im>
parents:
11823
diff
changeset
|
104 | return "3"; |
|
11539
fbabe3f89777
[gaim-migrate @ 13794]
Mark Doliner <markdoliner@pidgin.im>
parents:
11515
diff
changeset
|
105 | } else if (size >= 10) { |
|
11826
10ebbc41f163
[gaim-migrate @ 14117]
Richard Laager <rlaager@pidgin.im>
parents:
11823
diff
changeset
|
106 | return "2"; |
| 11477 | 107 | } |
| 108 | ||
|
11826
10ebbc41f163
[gaim-migrate @ 14117]
Richard Laager <rlaager@pidgin.im>
parents:
11823
diff
changeset
|
109 | return "1"; |
| 11477 | 110 | } |
|
17633
b76241c02857
Some more Bonjour cleanup and leak fixing.
Daniel Atallah <datallah@pidgin.im>
parents:
17632
diff
changeset
|
111 | |
|
12443
ad94864144f8
[gaim-migrate @ 14750]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
11830
diff
changeset
|
112 | 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
|
113 | _jabber_parse_and_write_message_to_ui(xmlnode *message_node, PurpleBuddy *pb) |
| 11477 | 114 | { |
|
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
|
115 | 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
|
116 | PurpleConnection *gc = pb->account->gc; |
|
17633
b76241c02857
Some more Bonjour cleanup and leak fixing.
Daniel Atallah <datallah@pidgin.im>
parents:
17632
diff
changeset
|
117 | char *body, *html_body = NULL; |
|
11539
fbabe3f89777
[gaim-migrate @ 13794]
Mark Doliner <markdoliner@pidgin.im>
parents:
11515
diff
changeset
|
118 | const char *ichat_balloon_color = NULL; |
|
fbabe3f89777
[gaim-migrate @ 13794]
Mark Doliner <markdoliner@pidgin.im>
parents:
11515
diff
changeset
|
119 | const char *ichat_text_color = NULL; |
|
fbabe3f89777
[gaim-migrate @ 13794]
Mark Doliner <markdoliner@pidgin.im>
parents:
11515
diff
changeset
|
120 | const char *font_face = NULL; |
|
fbabe3f89777
[gaim-migrate @ 13794]
Mark Doliner <markdoliner@pidgin.im>
parents:
11515
diff
changeset
|
121 | const char *font_size = NULL; |
|
fbabe3f89777
[gaim-migrate @ 13794]
Mark Doliner <markdoliner@pidgin.im>
parents:
11515
diff
changeset
|
122 | const char *font_color = NULL; |
| 11477 | 123 | gboolean composing_event = FALSE; |
| 124 | ||
|
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
|
125 | 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
|
126 | if (body_node == NULL) |
| 11477 | 127 | return; |
|
17633
b76241c02857
Some more Bonjour cleanup and leak fixing.
Daniel Atallah <datallah@pidgin.im>
parents:
17632
diff
changeset
|
128 | body = xmlnode_get_data(body_node); |
|
11539
fbabe3f89777
[gaim-migrate @ 13794]
Mark Doliner <markdoliner@pidgin.im>
parents:
11515
diff
changeset
|
129 | |
| 11477 | 130 | html_node = xmlnode_get_child(message_node, "html"); |
|
11539
fbabe3f89777
[gaim-migrate @ 13794]
Mark Doliner <markdoliner@pidgin.im>
parents:
11515
diff
changeset
|
131 | if (html_node != NULL) |
|
fbabe3f89777
[gaim-migrate @ 13794]
Mark Doliner <markdoliner@pidgin.im>
parents:
11515
diff
changeset
|
132 | { |
|
17633
b76241c02857
Some more Bonjour cleanup and leak fixing.
Daniel Atallah <datallah@pidgin.im>
parents:
17632
diff
changeset
|
133 | xmlnode *html_body_node; |
|
b76241c02857
Some more Bonjour cleanup and leak fixing.
Daniel Atallah <datallah@pidgin.im>
parents:
17632
diff
changeset
|
134 | |
| 11477 | 135 | html_body_node = xmlnode_get_child(html_node, "body"); |
|
11539
fbabe3f89777
[gaim-migrate @ 13794]
Mark Doliner <markdoliner@pidgin.im>
parents:
11515
diff
changeset
|
136 | if (html_body_node != NULL) |
|
fbabe3f89777
[gaim-migrate @ 13794]
Mark Doliner <markdoliner@pidgin.im>
parents:
11515
diff
changeset
|
137 | { |
|
17633
b76241c02857
Some more Bonjour cleanup and leak fixing.
Daniel Atallah <datallah@pidgin.im>
parents:
17632
diff
changeset
|
138 | xmlnode *html_body_font_node; |
|
b76241c02857
Some more Bonjour cleanup and leak fixing.
Daniel Atallah <datallah@pidgin.im>
parents:
17632
diff
changeset
|
139 | |
| 11477 | 140 | ichat_balloon_color = xmlnode_get_attrib(html_body_node, "ichatballooncolor"); |
| 141 | ichat_text_color = xmlnode_get_attrib(html_body_node, "ichattextcolor"); | |
| 142 | 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
|
143 | if (html_body_font_node != NULL) |
|
11826
10ebbc41f163
[gaim-migrate @ 14117]
Richard Laager <rlaager@pidgin.im>
parents:
11823
diff
changeset
|
144 | { /* Types of messages sent by iChat */ |
| 11477 | 145 | font_face = xmlnode_get_attrib(html_body_font_node, "face"); |
|
11826
10ebbc41f163
[gaim-migrate @ 14117]
Richard Laager <rlaager@pidgin.im>
parents:
11823
diff
changeset
|
146 | /* The absolute iChat font sizes should be converted to 1..7 range */ |
| 11477 | 147 | font_size = xmlnode_get_attrib(html_body_font_node, "ABSZ"); |
|
11539
fbabe3f89777
[gaim-migrate @ 13794]
Mark Doliner <markdoliner@pidgin.im>
parents:
11515
diff
changeset
|
148 | if (font_size != NULL) |
| 15884 | 149 | font_size = _font_size_ichat_to_purple(atoi(font_size)); |
| 11477 | 150 | font_color = xmlnode_get_attrib(html_body_font_node, "color"); |
| 151 | html_body = xmlnode_get_data(html_body_font_node); | |
|
11539
fbabe3f89777
[gaim-migrate @ 13794]
Mark Doliner <markdoliner@pidgin.im>
parents:
11515
diff
changeset
|
152 | if (html_body == NULL) |
| 15884 | 153 | /* 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
|
154 | html_body = xmlnode_to_str(html_body_font_node, NULL); |
| 11477 | 155 | } |
| 156 | } | |
| 157 | } | |
|
11539
fbabe3f89777
[gaim-migrate @ 13794]
Mark Doliner <markdoliner@pidgin.im>
parents:
11515
diff
changeset
|
158 | |
| 11477 | 159 | 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
|
160 | if (events_node != NULL) |
|
fbabe3f89777
[gaim-migrate @ 13794]
Mark Doliner <markdoliner@pidgin.im>
parents:
11515
diff
changeset
|
161 | { |
|
fbabe3f89777
[gaim-migrate @ 13794]
Mark Doliner <markdoliner@pidgin.im>
parents:
11515
diff
changeset
|
162 | if (xmlnode_get_child(events_node, "composing") != NULL) |
| 11477 | 163 | composing_event = TRUE; |
|
11539
fbabe3f89777
[gaim-migrate @ 13794]
Mark Doliner <markdoliner@pidgin.im>
parents:
11515
diff
changeset
|
164 | if (xmlnode_get_child(events_node, "id") != NULL) |
|
fbabe3f89777
[gaim-migrate @ 13794]
Mark Doliner <markdoliner@pidgin.im>
parents:
11515
diff
changeset
|
165 | { |
|
11826
10ebbc41f163
[gaim-migrate @ 14117]
Richard Laager <rlaager@pidgin.im>
parents:
11823
diff
changeset
|
166 | /* The user is just typing */ |
|
17633
b76241c02857
Some more Bonjour cleanup and leak fixing.
Daniel Atallah <datallah@pidgin.im>
parents:
17632
diff
changeset
|
167 | /* TODO: Deal with typing notification */ |
| 11477 | 168 | g_free(body); |
| 169 | g_free(html_body); | |
| 170 | return; | |
| 171 | } | |
| 172 | } | |
|
11539
fbabe3f89777
[gaim-migrate @ 13794]
Mark Doliner <markdoliner@pidgin.im>
parents:
11515
diff
changeset
|
173 | |
|
11826
10ebbc41f163
[gaim-migrate @ 14117]
Richard Laager <rlaager@pidgin.im>
parents:
11823
diff
changeset
|
174 | /* Compose the message */ |
|
17633
b76241c02857
Some more Bonjour cleanup and leak fixing.
Daniel Atallah <datallah@pidgin.im>
parents:
17632
diff
changeset
|
175 | if (html_body != NULL) |
|
11539
fbabe3f89777
[gaim-migrate @ 13794]
Mark Doliner <markdoliner@pidgin.im>
parents:
11515
diff
changeset
|
176 | { |
|
17633
b76241c02857
Some more Bonjour cleanup and leak fixing.
Daniel Atallah <datallah@pidgin.im>
parents:
17632
diff
changeset
|
177 | g_free(body); |
|
b76241c02857
Some more Bonjour cleanup and leak fixing.
Daniel Atallah <datallah@pidgin.im>
parents:
17632
diff
changeset
|
178 | |
| 11477 | 179 | if (font_face == NULL) font_face = "Helvetica"; |
| 180 | if (font_size == NULL) font_size = "3"; | |
| 181 | if (ichat_text_color == NULL) ichat_text_color = "#000000"; | |
| 182 | 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
|
183 | 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
|
184 | 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
|
185 | html_body); |
| 11477 | 186 | } |
|
11539
fbabe3f89777
[gaim-migrate @ 13794]
Mark Doliner <markdoliner@pidgin.im>
parents:
11515
diff
changeset
|
187 | |
|
17633
b76241c02857
Some more Bonjour cleanup and leak fixing.
Daniel Atallah <datallah@pidgin.im>
parents:
17632
diff
changeset
|
188 | /* 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
|
189 | |
|
11826
10ebbc41f163
[gaim-migrate @ 14117]
Richard Laager <rlaager@pidgin.im>
parents:
11823
diff
changeset
|
190 | /* 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
|
191 | serv_got_im(gc, pb->name, body, 0, time(NULL)); |
|
11539
fbabe3f89777
[gaim-migrate @ 13794]
Mark Doliner <markdoliner@pidgin.im>
parents:
11515
diff
changeset
|
192 | |
| 11477 | 193 | g_free(body); |
| 194 | g_free(html_body); | |
| 195 | } | |
| 196 | ||
| 12708 | 197 | struct _check_buddy_by_address_t { |
|
17633
b76241c02857
Some more Bonjour cleanup and leak fixing.
Daniel Atallah <datallah@pidgin.im>
parents:
17632
diff
changeset
|
198 | const char *address; |
|
17661
96c6a21c4139
Send 'to' and 'from' attributes in the stream start message.
Daniel Atallah <datallah@pidgin.im>
parents:
17660
diff
changeset
|
199 | PurpleBuddy **pb; |
| 13962 | 200 | BonjourJabber *bj; |
| 12708 | 201 | }; |
| 202 | ||
| 203 | static void | |
| 204 | _check_buddy_by_address(gpointer key, gpointer value, gpointer data) | |
| 11477 | 205 | { |
|
17661
96c6a21c4139
Send 'to' and 'from' attributes in the stream start message.
Daniel Atallah <datallah@pidgin.im>
parents:
17660
diff
changeset
|
206 | PurpleBuddy *pb = value; |
| 13962 | 207 | BonjourBuddy *bb; |
|
17633
b76241c02857
Some more Bonjour cleanup and leak fixing.
Daniel Atallah <datallah@pidgin.im>
parents:
17632
diff
changeset
|
208 | struct _check_buddy_by_address_t *cbba = data; |
|
11539
fbabe3f89777
[gaim-migrate @ 13794]
Mark Doliner <markdoliner@pidgin.im>
parents:
11515
diff
changeset
|
209 | |
| 13962 | 210 | /* |
| 15884 | 211 | * If the current PurpleBuddy's data is not null and the PurpleBuddy's account |
| 13962 | 212 | * is the same as the account requesting the check then continue to determine |
| 213 | * whether the buddies IP matches the target IP. | |
| 214 | */ | |
|
17661
96c6a21c4139
Send 'to' and 'from' attributes in the stream start message.
Daniel Atallah <datallah@pidgin.im>
parents:
17660
diff
changeset
|
215 | if (cbba->bj->account == pb->account) |
| 13962 | 216 | { |
|
17661
96c6a21c4139
Send 'to' and 'from' attributes in the stream start message.
Daniel Atallah <datallah@pidgin.im>
parents:
17660
diff
changeset
|
217 | bb = pb->proto_data; |
|
17155
143ff2796376
Replace strcasecmp() calls with glib equivalents.
Richard Laager <rlaager@pidgin.im>
parents:
15884
diff
changeset
|
218 | 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
|
219 | *(cbba->pb) = pb; |
| 11477 | 220 | } |
| 221 | } | |
| 222 | ||
|
17665
26bff2090889
Update Bonjour to do nonblocking I/O correctly.
Daniel Atallah <datallah@pidgin.im>
parents:
17663
diff
changeset
|
223 | static void |
|
26bff2090889
Update Bonjour to do nonblocking I/O correctly.
Daniel Atallah <datallah@pidgin.im>
parents:
17663
diff
changeset
|
224 | _send_data_write_cb(gpointer data, gint source, PurpleInputCondition cond) |
| 11477 | 225 | { |
|
17665
26bff2090889
Update Bonjour to do nonblocking I/O correctly.
Daniel Atallah <datallah@pidgin.im>
parents:
17663
diff
changeset
|
226 | PurpleBuddy *pb = data; |
|
26bff2090889
Update Bonjour to do nonblocking I/O correctly.
Daniel Atallah <datallah@pidgin.im>
parents:
17663
diff
changeset
|
227 | BonjourBuddy *bb = pb->proto_data; |
|
26bff2090889
Update Bonjour to do nonblocking I/O correctly.
Daniel Atallah <datallah@pidgin.im>
parents:
17663
diff
changeset
|
228 | BonjourJabberConversation *bconv = bb->conversation; |
|
26bff2090889
Update Bonjour to do nonblocking I/O correctly.
Daniel Atallah <datallah@pidgin.im>
parents:
17663
diff
changeset
|
229 | int ret, writelen; |
|
26bff2090889
Update Bonjour to do nonblocking I/O correctly.
Daniel Atallah <datallah@pidgin.im>
parents:
17663
diff
changeset
|
230 | |
|
26bff2090889
Update Bonjour to do nonblocking I/O correctly.
Daniel Atallah <datallah@pidgin.im>
parents:
17663
diff
changeset
|
231 | /* 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
|
232 | |
|
26bff2090889
Update Bonjour to do nonblocking I/O correctly.
Daniel Atallah <datallah@pidgin.im>
parents:
17663
diff
changeset
|
233 | 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
|
234 | |
|
26bff2090889
Update Bonjour to do nonblocking I/O correctly.
Daniel Atallah <datallah@pidgin.im>
parents:
17663
diff
changeset
|
235 | if (writelen == 0) { |
|
26bff2090889
Update Bonjour to do nonblocking I/O correctly.
Daniel Atallah <datallah@pidgin.im>
parents:
17663
diff
changeset
|
236 | 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
|
237 | bconv->tx_handler = 0; |
|
17665
26bff2090889
Update Bonjour to do nonblocking I/O correctly.
Daniel Atallah <datallah@pidgin.im>
parents:
17663
diff
changeset
|
238 | return; |
|
26bff2090889
Update Bonjour to do nonblocking I/O correctly.
Daniel Atallah <datallah@pidgin.im>
parents:
17663
diff
changeset
|
239 | } |
|
11539
fbabe3f89777
[gaim-migrate @ 13794]
Mark Doliner <markdoliner@pidgin.im>
parents:
11515
diff
changeset
|
240 | |
|
17665
26bff2090889
Update Bonjour to do nonblocking I/O correctly.
Daniel Atallah <datallah@pidgin.im>
parents:
17663
diff
changeset
|
241 | 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
|
242 | |
|
26bff2090889
Update Bonjour to do nonblocking I/O correctly.
Daniel Atallah <datallah@pidgin.im>
parents:
17663
diff
changeset
|
243 | if (ret < 0 && errno == EAGAIN) |
|
26bff2090889
Update Bonjour to do nonblocking I/O correctly.
Daniel Atallah <datallah@pidgin.im>
parents:
17663
diff
changeset
|
244 | return; |
|
26bff2090889
Update Bonjour to do nonblocking I/O correctly.
Daniel Atallah <datallah@pidgin.im>
parents:
17663
diff
changeset
|
245 | else if (ret <= 0) { |
|
26bff2090889
Update Bonjour to do nonblocking I/O correctly.
Daniel Atallah <datallah@pidgin.im>
parents:
17663
diff
changeset
|
246 | PurpleConversation *conv; |
|
26bff2090889
Update Bonjour to do nonblocking I/O correctly.
Daniel Atallah <datallah@pidgin.im>
parents:
17663
diff
changeset
|
247 | const char *error = strerror(errno); |
|
26bff2090889
Update Bonjour to do nonblocking I/O correctly.
Daniel Atallah <datallah@pidgin.im>
parents:
17663
diff
changeset
|
248 | |
|
26bff2090889
Update Bonjour to do nonblocking I/O correctly.
Daniel Atallah <datallah@pidgin.im>
parents:
17663
diff
changeset
|
249 | 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
|
250 | 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
|
251 | |
|
26bff2090889
Update Bonjour to do nonblocking I/O correctly.
Daniel Atallah <datallah@pidgin.im>
parents:
17663
diff
changeset
|
252 | 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
|
253 | if (conv != NULL) |
|
26bff2090889
Update Bonjour to do nonblocking I/O correctly.
Daniel Atallah <datallah@pidgin.im>
parents:
17663
diff
changeset
|
254 | purple_conversation_write(conv, NULL, |
|
26bff2090889
Update Bonjour to do nonblocking I/O correctly.
Daniel Atallah <datallah@pidgin.im>
parents:
17663
diff
changeset
|
255 | _("Unable to send message."), |
|
26bff2090889
Update Bonjour to do nonblocking I/O correctly.
Daniel Atallah <datallah@pidgin.im>
parents:
17663
diff
changeset
|
256 | PURPLE_MESSAGE_SYSTEM, time(NULL)); |
|
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 | bonjour_jabber_close_conversation(bb->conversation); |
|
26bff2090889
Update Bonjour to do nonblocking I/O correctly.
Daniel Atallah <datallah@pidgin.im>
parents:
17663
diff
changeset
|
259 | bb->conversation = NULL; |
|
26bff2090889
Update Bonjour to do nonblocking I/O correctly.
Daniel Atallah <datallah@pidgin.im>
parents:
17663
diff
changeset
|
260 | return; |
| 11477 | 261 | } |
|
11539
fbabe3f89777
[gaim-migrate @ 13794]
Mark Doliner <markdoliner@pidgin.im>
parents:
11515
diff
changeset
|
262 | |
|
17665
26bff2090889
Update Bonjour to do nonblocking I/O correctly.
Daniel Atallah <datallah@pidgin.im>
parents:
17663
diff
changeset
|
263 | 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
|
264 | } |
|
26bff2090889
Update Bonjour to do nonblocking I/O correctly.
Daniel Atallah <datallah@pidgin.im>
parents:
17663
diff
changeset
|
265 | |
|
26bff2090889
Update Bonjour to do nonblocking I/O correctly.
Daniel Atallah <datallah@pidgin.im>
parents:
17663
diff
changeset
|
266 | static gint |
|
26bff2090889
Update Bonjour to do nonblocking I/O correctly.
Daniel Atallah <datallah@pidgin.im>
parents:
17663
diff
changeset
|
267 | _send_data(PurpleBuddy *pb, char *message) |
|
26bff2090889
Update Bonjour to do nonblocking I/O correctly.
Daniel Atallah <datallah@pidgin.im>
parents:
17663
diff
changeset
|
268 | { |
|
26bff2090889
Update Bonjour to do nonblocking I/O correctly.
Daniel Atallah <datallah@pidgin.im>
parents:
17663
diff
changeset
|
269 | gint ret; |
|
26bff2090889
Update Bonjour to do nonblocking I/O correctly.
Daniel Atallah <datallah@pidgin.im>
parents:
17663
diff
changeset
|
270 | int len = strlen(message); |
|
26bff2090889
Update Bonjour to do nonblocking I/O correctly.
Daniel Atallah <datallah@pidgin.im>
parents:
17663
diff
changeset
|
271 | BonjourBuddy *bb = pb->proto_data; |
|
26bff2090889
Update Bonjour to do nonblocking I/O correctly.
Daniel Atallah <datallah@pidgin.im>
parents:
17663
diff
changeset
|
272 | BonjourJabberConversation *bconv = bb->conversation; |
|
26bff2090889
Update Bonjour to do nonblocking I/O correctly.
Daniel Atallah <datallah@pidgin.im>
parents:
17663
diff
changeset
|
273 | |
|
26bff2090889
Update Bonjour to do nonblocking I/O correctly.
Daniel Atallah <datallah@pidgin.im>
parents:
17663
diff
changeset
|
274 | /* 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
|
275 | if (bconv->tx_handler != 0 |
|
17665
26bff2090889
Update Bonjour to do nonblocking I/O correctly.
Daniel Atallah <datallah@pidgin.im>
parents:
17663
diff
changeset
|
276 | || 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
|
277 | || !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
|
278 | || !bconv->recv_stream_start |
|
17665
26bff2090889
Update Bonjour to do nonblocking I/O correctly.
Daniel Atallah <datallah@pidgin.im>
parents:
17663
diff
changeset
|
279 | || 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
|
280 | ret = -1; |
|
26bff2090889
Update Bonjour to do nonblocking I/O correctly.
Daniel Atallah <datallah@pidgin.im>
parents:
17663
diff
changeset
|
281 | errno = EAGAIN; |
|
26bff2090889
Update Bonjour to do nonblocking I/O correctly.
Daniel Atallah <datallah@pidgin.im>
parents:
17663
diff
changeset
|
282 | } else { |
|
26bff2090889
Update Bonjour to do nonblocking I/O correctly.
Daniel Atallah <datallah@pidgin.im>
parents:
17663
diff
changeset
|
283 | 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
|
284 | } |
|
26bff2090889
Update Bonjour to do nonblocking I/O correctly.
Daniel Atallah <datallah@pidgin.im>
parents:
17663
diff
changeset
|
285 | |
|
26bff2090889
Update Bonjour to do nonblocking I/O correctly.
Daniel Atallah <datallah@pidgin.im>
parents:
17663
diff
changeset
|
286 | if (ret == -1 && errno == EAGAIN) |
|
26bff2090889
Update Bonjour to do nonblocking I/O correctly.
Daniel Atallah <datallah@pidgin.im>
parents:
17663
diff
changeset
|
287 | ret = 0; |
|
26bff2090889
Update Bonjour to do nonblocking I/O correctly.
Daniel Atallah <datallah@pidgin.im>
parents:
17663
diff
changeset
|
288 | else if (ret <= 0) { |
|
26bff2090889
Update Bonjour to do nonblocking I/O correctly.
Daniel Atallah <datallah@pidgin.im>
parents:
17663
diff
changeset
|
289 | PurpleConversation *conv; |
|
26bff2090889
Update Bonjour to do nonblocking I/O correctly.
Daniel Atallah <datallah@pidgin.im>
parents:
17663
diff
changeset
|
290 | const char *error = strerror(errno); |
|
26bff2090889
Update Bonjour to do nonblocking I/O correctly.
Daniel Atallah <datallah@pidgin.im>
parents:
17663
diff
changeset
|
291 | |
|
26bff2090889
Update Bonjour to do nonblocking I/O correctly.
Daniel Atallah <datallah@pidgin.im>
parents:
17663
diff
changeset
|
292 | 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
|
293 | 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
|
294 | |
|
26bff2090889
Update Bonjour to do nonblocking I/O correctly.
Daniel Atallah <datallah@pidgin.im>
parents:
17663
diff
changeset
|
295 | 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
|
296 | if (conv != NULL) |
|
26bff2090889
Update Bonjour to do nonblocking I/O correctly.
Daniel Atallah <datallah@pidgin.im>
parents:
17663
diff
changeset
|
297 | purple_conversation_write(conv, NULL, |
|
26bff2090889
Update Bonjour to do nonblocking I/O correctly.
Daniel Atallah <datallah@pidgin.im>
parents:
17663
diff
changeset
|
298 | _("Unable to send message."), |
|
26bff2090889
Update Bonjour to do nonblocking I/O correctly.
Daniel Atallah <datallah@pidgin.im>
parents:
17663
diff
changeset
|
299 | PURPLE_MESSAGE_SYSTEM, time(NULL)); |
|
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 | bonjour_jabber_close_conversation(bb->conversation); |
|
26bff2090889
Update Bonjour to do nonblocking I/O correctly.
Daniel Atallah <datallah@pidgin.im>
parents:
17663
diff
changeset
|
302 | bb->conversation = NULL; |
|
26bff2090889
Update Bonjour to do nonblocking I/O correctly.
Daniel Atallah <datallah@pidgin.im>
parents:
17663
diff
changeset
|
303 | return -1; |
|
26bff2090889
Update Bonjour to do nonblocking I/O correctly.
Daniel Atallah <datallah@pidgin.im>
parents:
17663
diff
changeset
|
304 | } |
|
26bff2090889
Update Bonjour to do nonblocking I/O correctly.
Daniel Atallah <datallah@pidgin.im>
parents:
17663
diff
changeset
|
305 | |
|
26bff2090889
Update Bonjour to do nonblocking I/O correctly.
Daniel Atallah <datallah@pidgin.im>
parents:
17663
diff
changeset
|
306 | 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
|
307 | if (bconv->tx_handler == 0) |
|
17665
26bff2090889
Update Bonjour to do nonblocking I/O correctly.
Daniel Atallah <datallah@pidgin.im>
parents:
17663
diff
changeset
|
308 | 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
|
309 | _send_data_write_cb, pb); |
|
26bff2090889
Update Bonjour to do nonblocking I/O correctly.
Daniel Atallah <datallah@pidgin.im>
parents:
17663
diff
changeset
|
310 | 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
|
311 | } |
|
26bff2090889
Update Bonjour to do nonblocking I/O correctly.
Daniel Atallah <datallah@pidgin.im>
parents:
17663
diff
changeset
|
312 | |
|
26bff2090889
Update Bonjour to do nonblocking I/O correctly.
Daniel Atallah <datallah@pidgin.im>
parents:
17663
diff
changeset
|
313 | return ret; |
| 11477 | 314 | } |
| 315 | ||
|
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
|
316 | void bonjour_jabber_process_packet(PurpleBuddy *pb, xmlnode *packet) { |
|
05cd9ab28312
Update the Bonjour prpl to use libxml explicitly instead of the xml_node stuff. This allows us to deal with partial reads. I also fixed issues related to starting conversations with iChat and a couple other things. Fixes #2022,#1652
Daniel Atallah <datallah@pidgin.im>
parents:
18947
diff
changeset
|
317 | 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
|
318 | _jabber_parse_and_write_message_to_ui(packet, 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
|
319 | 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
|
320 | purple_debug_warning("bonjour", "Unknown packet: %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
|
321 | packet->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
|
322 | } |
|
05cd9ab28312
Update the Bonjour prpl to use libxml explicitly instead of the xml_node stuff. This allows us to deal with partial reads. I also fixed issues related to starting conversations with iChat and a couple other things. Fixes #2022,#1652
Daniel Atallah <datallah@pidgin.im>
parents:
18947
diff
changeset
|
323 | |
|
05cd9ab28312
Update the Bonjour prpl to use libxml explicitly instead of the xml_node stuff. This allows us to deal with partial reads. I also fixed issues related to starting conversations with iChat and a couple other things. Fixes #2022,#1652
Daniel Atallah <datallah@pidgin.im>
parents:
18947
diff
changeset
|
324 | |
|
12443
ad94864144f8
[gaim-migrate @ 14750]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
11830
diff
changeset
|
325 | static void |
| 15884 | 326 | _client_socket_handler(gpointer data, gint socket, PurpleInputCondition condition) |
| 11477 | 327 | { |
|
17661
96c6a21c4139
Send 'to' and 'from' attributes in the stream start message.
Daniel Atallah <datallah@pidgin.im>
parents:
17660
diff
changeset
|
328 | 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
|
329 | 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
|
330 | 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
|
331 | |
|
05cd9ab28312
Update the Bonjour prpl to use libxml explicitly instead of the xml_node stuff. This allows us to deal with partial reads. I also fixed issues related to starting conversations with iChat and a couple other things. Fixes #2022,#1652
Daniel Atallah <datallah@pidgin.im>
parents:
18947
diff
changeset
|
332 | /*TODO: use a static buffer */ |
| 11477 | 333 | |
|
11826
10ebbc41f163
[gaim-migrate @ 14117]
Richard Laager <rlaager@pidgin.im>
parents:
11823
diff
changeset
|
334 | /* 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
|
335 | if ((len = recv(socket, message, sizeof(message) - 1, 0)) == -1) { |
|
11826
10ebbc41f163
[gaim-migrate @ 14117]
Richard Laager <rlaager@pidgin.im>
parents:
11823
diff
changeset
|
336 | /* 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
|
337 | 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
|
338 | 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
|
339 | |
|
05cd9ab28312
Update the Bonjour prpl to use libxml explicitly instead of the xml_node stuff. This allows us to deal with partial reads. I also fixed issues related to starting conversations with iChat and a couple other things. Fixes #2022,#1652
Daniel Atallah <datallah@pidgin.im>
parents:
18947
diff
changeset
|
340 | purple_debug_warning("bonjour", "receive error: %s\n", strerror(errno)); |
|
05cd9ab28312
Update the Bonjour prpl to use libxml explicitly instead of the xml_node stuff. This allows us to deal with partial reads. I also fixed 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 | |
|
17665
26bff2090889
Update Bonjour to do nonblocking I/O correctly.
Daniel Atallah <datallah@pidgin.im>
parents:
17663
diff
changeset
|
342 | bonjour_jabber_close_conversation(bb->conversation); |
|
26bff2090889
Update Bonjour to do nonblocking I/O correctly.
Daniel Atallah <datallah@pidgin.im>
parents:
17663
diff
changeset
|
343 | bb->conversation = NULL; |
|
26bff2090889
Update Bonjour to do nonblocking I/O correctly.
Daniel Atallah <datallah@pidgin.im>
parents:
17663
diff
changeset
|
344 | |
|
26bff2090889
Update Bonjour to do nonblocking I/O correctly.
Daniel Atallah <datallah@pidgin.im>
parents:
17663
diff
changeset
|
345 | /* 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
|
346 | * 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
|
347 | } |
| 11477 | 348 | 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
|
349 | } else if (len == 0) { /* The other end has closed the 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
|
350 | purple_debug_warning("bonjour", "Connection closed (without stream end) by %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
|
351 | 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
|
352 | return; |
| 11477 | 353 | } 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
|
354 | message_length = len; |
| 11477 | 355 | message[message_length] = '\0'; |
|
11539
fbabe3f89777
[gaim-migrate @ 13794]
Mark Doliner <markdoliner@pidgin.im>
parents:
11515
diff
changeset
|
356 | |
|
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 | while (message_length > 0 && g_ascii_iscntrl(message[message_length - 1])) { |
| 11477 | 358 | message[message_length - 1] = '\0'; |
| 359 | message_length--; | |
| 360 | } | |
| 361 | } | |
|
11539
fbabe3f89777
[gaim-migrate @ 13794]
Mark Doliner <markdoliner@pidgin.im>
parents:
11515
diff
changeset
|
362 | |
|
19056
05cd9ab28312
Update the Bonjour prpl to use libxml explicitly instead of the xml_node stuff. This allows us to deal with partial reads. I also fixed issues related to starting conversations with iChat and a couple other things. Fixes #2022,#1652
Daniel Atallah <datallah@pidgin.im>
parents:
18947
diff
changeset
|
363 | 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
|
364 | |
|
05cd9ab28312
Update the Bonjour prpl to use libxml explicitly instead of the xml_node stuff. This allows us to deal with partial reads. I also fixed issues related to starting conversations with iChat and a couple other things. Fixes #2022,#1652
Daniel Atallah <datallah@pidgin.im>
parents:
18947
diff
changeset
|
365 | 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
|
366 | } |
|
17633
b76241c02857
Some more Bonjour cleanup and leak fixing.
Daniel Atallah <datallah@pidgin.im>
parents:
17632
diff
changeset
|
367 | |
|
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
|
368 | 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
|
369 | 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
|
370 | PurpleConversation *conv; |
|
05cd9ab28312
Update the Bonjour prpl to use libxml explicitly instead of the xml_node stuff. This allows us to deal with partial reads. I also fixed 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 | |
|
05cd9ab28312
Update the Bonjour prpl to use libxml explicitly instead of the xml_node stuff. This allows us to deal with partial reads. I also fixed 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 | 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
|
373 | |
|
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
|
374 | 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
|
375 | |
|
19749
21cc72fa3f6f
Prevent duplicate window closed notifications.
Daniel Atallah <datallah@pidgin.im>
parents:
19579
diff
changeset
|
376 | /* Inform the user that the conversation has been closed */ |
|
21cc72fa3f6f
Prevent duplicate window closed notifications.
Daniel Atallah <datallah@pidgin.im>
parents:
19579
diff
changeset
|
377 | if (bb->conversation != NULL) { |
|
21cc72fa3f6f
Prevent duplicate window closed notifications.
Daniel Atallah <datallah@pidgin.im>
parents:
19579
diff
changeset
|
378 | 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
|
379 | if (conv != NULL) { |
|
21cc72fa3f6f
Prevent duplicate window closed notifications.
Daniel Atallah <datallah@pidgin.im>
parents:
19579
diff
changeset
|
380 | 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
|
381 | 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
|
382 | g_free(tmp); |
|
21cc72fa3f6f
Prevent duplicate window closed notifications.
Daniel Atallah <datallah@pidgin.im>
parents:
19579
diff
changeset
|
383 | } |
|
21cc72fa3f6f
Prevent duplicate window closed notifications.
Daniel Atallah <datallah@pidgin.im>
parents:
19579
diff
changeset
|
384 | /* Close the socket, clear the watcher and free memory */ |
|
21cc72fa3f6f
Prevent duplicate window closed notifications.
Daniel Atallah <datallah@pidgin.im>
parents:
19579
diff
changeset
|
385 | bonjour_jabber_close_conversation(bb->conversation); |
|
21cc72fa3f6f
Prevent duplicate window closed notifications.
Daniel Atallah <datallah@pidgin.im>
parents:
19579
diff
changeset
|
386 | bb->conversation = NULL; |
|
21cc72fa3f6f
Prevent duplicate window closed notifications.
Daniel Atallah <datallah@pidgin.im>
parents:
19579
diff
changeset
|
387 | } |
|
11539
fbabe3f89777
[gaim-migrate @ 13794]
Mark Doliner <markdoliner@pidgin.im>
parents:
11515
diff
changeset
|
388 | |
|
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
|
389 | } |
|
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
|
390 | |
|
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
|
391 | 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
|
392 | 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
|
393 | 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
|
394 | |
|
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
|
395 | /* 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
|
396 | 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
|
397 | /* 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
|
398 | 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
|
399 | _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
|
400 | /* 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
|
401 | _send_data_write_cb(pb, bconv->socket, PURPLE_INPUT_WRITE); |
| 11477 | 402 | } |
| 13964 | 403 | |
| 11477 | 404 | } |
| 405 | ||
|
17665
26bff2090889
Update Bonjour to do nonblocking I/O correctly.
Daniel Atallah <datallah@pidgin.im>
parents:
17663
diff
changeset
|
406 | struct _stream_start_data { |
|
26bff2090889
Update Bonjour to do nonblocking I/O correctly.
Daniel Atallah <datallah@pidgin.im>
parents:
17663
diff
changeset
|
407 | char *msg; |
|
26bff2090889
Update Bonjour to do nonblocking I/O correctly.
Daniel Atallah <datallah@pidgin.im>
parents:
17663
diff
changeset
|
408 | }; |
|
26bff2090889
Update Bonjour to do nonblocking I/O correctly.
Daniel Atallah <datallah@pidgin.im>
parents:
17663
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 | |
|
17665
26bff2090889
Update Bonjour to do nonblocking I/O correctly.
Daniel Atallah <datallah@pidgin.im>
parents:
17663
diff
changeset
|
411 | static void |
|
26bff2090889
Update Bonjour to do nonblocking I/O correctly.
Daniel Atallah <datallah@pidgin.im>
parents:
17663
diff
changeset
|
412 | _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
|
413 | { |
|
26bff2090889
Update Bonjour to do nonblocking I/O correctly.
Daniel Atallah <datallah@pidgin.im>
parents:
17663
diff
changeset
|
414 | PurpleBuddy *pb = data; |
|
26bff2090889
Update Bonjour to do nonblocking I/O correctly.
Daniel Atallah <datallah@pidgin.im>
parents:
17663
diff
changeset
|
415 | 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
|
416 | 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
|
417 | 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
|
418 | int len, ret; |
|
26bff2090889
Update Bonjour to do nonblocking I/O correctly.
Daniel Atallah <datallah@pidgin.im>
parents:
17663
diff
changeset
|
419 | |
|
26bff2090889
Update Bonjour to do nonblocking I/O correctly.
Daniel Atallah <datallah@pidgin.im>
parents:
17663
diff
changeset
|
420 | len = strlen(ss->msg); |
|
26bff2090889
Update Bonjour to do nonblocking I/O correctly.
Daniel Atallah <datallah@pidgin.im>
parents:
17663
diff
changeset
|
421 | |
|
26bff2090889
Update Bonjour to do nonblocking I/O correctly.
Daniel Atallah <datallah@pidgin.im>
parents:
17663
diff
changeset
|
422 | /* Start Stream */ |
|
26bff2090889
Update Bonjour to do nonblocking I/O correctly.
Daniel Atallah <datallah@pidgin.im>
parents:
17663
diff
changeset
|
423 | 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
|
424 | |
|
26bff2090889
Update Bonjour to do nonblocking I/O correctly.
Daniel Atallah <datallah@pidgin.im>
parents:
17663
diff
changeset
|
425 | if (ret == -1 && errno == EAGAIN) |
|
26bff2090889
Update Bonjour to do nonblocking I/O correctly.
Daniel Atallah <datallah@pidgin.im>
parents:
17663
diff
changeset
|
426 | return; |
|
26bff2090889
Update Bonjour to do nonblocking I/O correctly.
Daniel Atallah <datallah@pidgin.im>
parents:
17663
diff
changeset
|
427 | else if (ret <= 0) { |
|
26bff2090889
Update Bonjour to do nonblocking I/O correctly.
Daniel Atallah <datallah@pidgin.im>
parents:
17663
diff
changeset
|
428 | const char *err = strerror(errno); |
|
26bff2090889
Update Bonjour to do nonblocking I/O correctly.
Daniel Atallah <datallah@pidgin.im>
parents:
17663
diff
changeset
|
429 | PurpleConversation *conv; |
|
26bff2090889
Update Bonjour to do nonblocking I/O correctly.
Daniel Atallah <datallah@pidgin.im>
parents:
17663
diff
changeset
|
430 | |
|
26bff2090889
Update Bonjour to do nonblocking I/O correctly.
Daniel Atallah <datallah@pidgin.im>
parents:
17663
diff
changeset
|
431 | 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
|
432 | 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
|
433 | |
|
26bff2090889
Update Bonjour to do nonblocking I/O correctly.
Daniel Atallah <datallah@pidgin.im>
parents:
17663
diff
changeset
|
434 | 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
|
435 | if (conv != NULL) |
|
26bff2090889
Update Bonjour to do nonblocking I/O correctly.
Daniel Atallah <datallah@pidgin.im>
parents:
17663
diff
changeset
|
436 | purple_conversation_write(conv, NULL, |
|
26bff2090889
Update Bonjour to do nonblocking I/O correctly.
Daniel Atallah <datallah@pidgin.im>
parents:
17663
diff
changeset
|
437 | _("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
|
438 | PURPLE_MESSAGE_SYSTEM, time(NULL)); |
|
26bff2090889
Update Bonjour to do nonblocking I/O correctly.
Daniel Atallah <datallah@pidgin.im>
parents:
17663
diff
changeset
|
439 | |
|
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
|
440 | bonjour_jabber_close_conversation(bconv); |
|
17665
26bff2090889
Update Bonjour to do nonblocking I/O correctly.
Daniel Atallah <datallah@pidgin.im>
parents:
17663
diff
changeset
|
441 | bb->conversation = NULL; |
|
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 | return; |
|
26bff2090889
Update Bonjour to do nonblocking I/O correctly.
Daniel Atallah <datallah@pidgin.im>
parents:
17663
diff
changeset
|
444 | } |
|
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 | /* This is EXTREMELY unlikely to happen */ |
|
26bff2090889
Update Bonjour to do nonblocking I/O correctly.
Daniel Atallah <datallah@pidgin.im>
parents:
17663
diff
changeset
|
447 | if (ret < len) { |
|
26bff2090889
Update Bonjour to do nonblocking I/O correctly.
Daniel Atallah <datallah@pidgin.im>
parents:
17663
diff
changeset
|
448 | 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
|
449 | g_free(ss->msg); |
|
26bff2090889
Update Bonjour to do nonblocking I/O correctly.
Daniel Atallah <datallah@pidgin.im>
parents:
17663
diff
changeset
|
450 | ss->msg = tmp; |
|
26bff2090889
Update Bonjour to do nonblocking I/O correctly.
Daniel Atallah <datallah@pidgin.im>
parents:
17663
diff
changeset
|
451 | return; |
|
26bff2090889
Update Bonjour to do nonblocking I/O correctly.
Daniel Atallah <datallah@pidgin.im>
parents:
17663
diff
changeset
|
452 | } |
|
26bff2090889
Update Bonjour to do nonblocking I/O correctly.
Daniel Atallah <datallah@pidgin.im>
parents:
17663
diff
changeset
|
453 | |
|
26bff2090889
Update Bonjour to do nonblocking I/O correctly.
Daniel Atallah <datallah@pidgin.im>
parents:
17663
diff
changeset
|
454 | g_free(ss->msg); |
|
26bff2090889
Update Bonjour to do nonblocking I/O correctly.
Daniel Atallah <datallah@pidgin.im>
parents:
17663
diff
changeset
|
455 | 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
|
456 | 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
|
457 | |
|
05cd9ab28312
Update the Bonjour prpl to use libxml explicitly instead of the xml_node stuff. This allows us to deal with partial reads. I also fixed issues related to starting conversations with iChat and a couple other things. Fixes #2022,#1652
Daniel Atallah <datallah@pidgin.im>
parents:
18947
diff
changeset
|
458 | /* 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
|
459 | 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
|
460 | 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
|
461 | 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
|
462 | |
|
05cd9ab28312
Update the Bonjour prpl to use libxml explicitly instead of the xml_node stuff. This allows us to deal with partial reads. I also fixed issues related to starting conversations with iChat and a couple other things. Fixes #2022,#1652
Daniel Atallah <datallah@pidgin.im>
parents:
18947
diff
changeset
|
463 | 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
|
464 | |
|
05cd9ab28312
Update the Bonjour prpl to use libxml explicitly instead of the xml_node stuff. This allows us to deal with partial reads. I also fixed issues related to starting conversations with iChat and a couple other things. Fixes #2022,#1652
Daniel Atallah <datallah@pidgin.im>
parents:
18947
diff
changeset
|
465 | } |
|
05cd9ab28312
Update the Bonjour prpl to use libxml explicitly instead of the xml_node stuff. This allows us to deal with partial reads. I also fixed issues related to starting conversations with iChat and a couple other things. Fixes #2022,#1652
Daniel Atallah <datallah@pidgin.im>
parents:
18947
diff
changeset
|
466 | |
|
05cd9ab28312
Update the Bonjour prpl to use libxml explicitly instead of the xml_node stuff. This allows us to deal with partial reads. I also fixed issues related to starting conversations with iChat and a couple other things. Fixes #2022,#1652
Daniel Atallah <datallah@pidgin.im>
parents:
18947
diff
changeset
|
467 | 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
|
468 | { |
|
05cd9ab28312
Update the Bonjour prpl to use libxml explicitly instead of the xml_node stuff. This allows us to deal with partial reads. I also fixed issues related to starting conversations with iChat and a couple other things. Fixes #2022,#1652
Daniel Atallah <datallah@pidgin.im>
parents:
18947
diff
changeset
|
469 | 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
|
470 | 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
|
471 | 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
|
472 | |
|
05cd9ab28312
Update the Bonjour prpl to use libxml explicitly instead of the xml_node stuff. This allows us to deal with partial reads. I also fixed issues related to starting conversations with iChat and a couple other things. Fixes #2022,#1652
Daniel Atallah <datallah@pidgin.im>
parents:
18947
diff
changeset
|
473 | 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
|
474 | 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
|
475 | 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
|
476 | |
|
05cd9ab28312
Update the Bonjour prpl to use libxml explicitly instead of the xml_node stuff. This allows us to deal with partial reads. I also fixed 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 | /* 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
|
478 | 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
|
479 | |
|
05cd9ab28312
Update the Bonjour prpl to use libxml explicitly instead of the xml_node stuff. This allows us to deal with partial reads. I also fixed 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 | 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
|
481 | 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
|
482 | else if (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
|
483 | const char *err = strerror(errno); |
|
17665
26bff2090889
Update Bonjour to do nonblocking I/O correctly.
Daniel Atallah <datallah@pidgin.im>
parents:
17663
diff
changeset
|
484 | |
|
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
|
485 | 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
|
486 | 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
|
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 | 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
|
489 | 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
|
490 | |
|
05cd9ab28312
Update the Bonjour prpl to use libxml explicitly instead of the xml_node stuff. This allows us to deal with partial reads. I also fixed 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 | return FALSE; |
|
17665
26bff2090889
Update Bonjour to do nonblocking I/O correctly.
Daniel Atallah <datallah@pidgin.im>
parents:
17663
diff
changeset
|
492 | } |
|
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
|
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 | /* 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
|
495 | 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
|
496 | 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
|
497 | 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
|
498 | 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
|
499 | /* 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
|
500 | 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
|
501 | 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
|
502 | } 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
|
503 | 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
|
504 | |
|
05cd9ab28312
Update the Bonjour prpl to use libxml explicitly instead of the xml_node stuff. This allows us to deal with partial reads. I also fixed issues related to starting conversations with iChat and a couple other things. Fixes #2022,#1652
Daniel Atallah <datallah@pidgin.im>
parents:
18947
diff
changeset
|
505 | 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
|
506 | |
|
05cd9ab28312
Update the Bonjour prpl to use libxml explicitly instead of the xml_node stuff. This allows us to deal with partial reads. I also fixed 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 | /* 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
|
508 | 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
|
509 | |
|
05cd9ab28312
Update the Bonjour prpl to use libxml explicitly instead of the xml_node stuff. This allows us to deal with partial reads. I also fixed issues related to starting conversations with iChat and a couple other things. Fixes #2022,#1652
Daniel Atallah <datallah@pidgin.im>
parents:
18947
diff
changeset
|
510 | 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
|
511 | 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
|
512 | 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
|
513 | |
|
05cd9ab28312
Update the Bonjour prpl to use libxml explicitly instead of the xml_node stuff. This allows us to deal with partial reads. I also fixed 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 | return TRUE; |
|
17665
26bff2090889
Update Bonjour to do nonblocking I/O correctly.
Daniel Atallah <datallah@pidgin.im>
parents:
17663
diff
changeset
|
515 | } |
|
26bff2090889
Update Bonjour to do nonblocking I/O correctly.
Daniel Atallah <datallah@pidgin.im>
parents:
17663
diff
changeset
|
516 | |
|
12443
ad94864144f8
[gaim-migrate @ 14750]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
11830
diff
changeset
|
517 | static void |
| 15884 | 518 | _server_socket_handler(gpointer data, int server_socket, PurpleInputCondition condition) |
| 11477 | 519 | { |
|
17661
96c6a21c4139
Send 'to' and 'from' attributes in the stream start message.
Daniel Atallah <datallah@pidgin.im>
parents:
17660
diff
changeset
|
520 | PurpleBuddy *pb = NULL; |
|
11826
10ebbc41f163
[gaim-migrate @ 14117]
Richard Laager <rlaager@pidgin.im>
parents:
11823
diff
changeset
|
521 | struct sockaddr_in their_addr; /* connector's address information */ |
|
11515
09651c1daa98
[gaim-migrate @ 13760]
Mark Doliner <markdoliner@pidgin.im>
parents:
11498
diff
changeset
|
522 | socklen_t sin_size = sizeof(struct sockaddr); |
| 11477 | 523 | int client_socket; |
|
17633
b76241c02857
Some more Bonjour cleanup and leak fixing.
Daniel Atallah <datallah@pidgin.im>
parents:
17632
diff
changeset
|
524 | BonjourBuddy *bb; |
|
11539
fbabe3f89777
[gaim-migrate @ 13794]
Mark Doliner <markdoliner@pidgin.im>
parents:
11515
diff
changeset
|
525 | char *address_text = NULL; |
| 15884 | 526 | PurpleBuddyList *bl = purple_get_blist(); |
|
12733
0c1de18b51ed
[gaim-migrate @ 15077]
Mark Doliner <markdoliner@pidgin.im>
parents:
12730
diff
changeset
|
527 | struct _check_buddy_by_address_t *cbba; |
| 11477 | 528 | |
|
11826
10ebbc41f163
[gaim-migrate @ 14117]
Richard Laager <rlaager@pidgin.im>
parents:
11823
diff
changeset
|
529 | /* 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
|
530 | if (condition != PURPLE_INPUT_READ) |
| 11477 | 531 | return; |
| 532 | ||
|
11539
fbabe3f89777
[gaim-migrate @ 13794]
Mark Doliner <markdoliner@pidgin.im>
parents:
11515
diff
changeset
|
533 | if ((client_socket = accept(server_socket, (struct sockaddr *)&their_addr, &sin_size)) == -1) |
| 11477 | 534 | return; |
|
17633
b76241c02857
Some more Bonjour cleanup and leak fixing.
Daniel Atallah <datallah@pidgin.im>
parents:
17632
diff
changeset
|
535 | |
| 11477 | 536 | fcntl(client_socket, F_SETFL, O_NONBLOCK); |
| 537 | ||
| 13962 | 538 | /* Look for the buddy that has opened the conversation and fill information */ |
| 11477 | 539 | 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
|
540 | 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
|
541 | cbba = g_new0(struct _check_buddy_by_address_t, 1); |
| 12708 | 542 | 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
|
543 | cbba->pb = &pb; |
|
17633
b76241c02857
Some more Bonjour cleanup and leak fixing.
Daniel Atallah <datallah@pidgin.im>
parents:
17632
diff
changeset
|
544 | cbba->bj = data; |
|
13250
3857dfd699c5
[gaim-migrate @ 15615]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
13006
diff
changeset
|
545 | g_hash_table_foreach(bl->buddies, _check_buddy_by_address, cbba); |
| 12708 | 546 | g_free(cbba); |
|
17661
96c6a21c4139
Send 'to' and 'from' attributes in the stream start message.
Daniel Atallah <datallah@pidgin.im>
parents:
17660
diff
changeset
|
547 | if (pb == NULL) |
|
11539
fbabe3f89777
[gaim-migrate @ 13794]
Mark Doliner <markdoliner@pidgin.im>
parents:
11515
diff
changeset
|
548 | { |
| 15884 | 549 | purple_debug_info("bonjour", "We don't like invisible buddies, this is not a superheros comic\n"); |
| 11477 | 550 | close(client_socket); |
| 551 | return; | |
| 552 | } | |
|
17661
96c6a21c4139
Send 'to' and 'from' attributes in the stream start message.
Daniel Atallah <datallah@pidgin.im>
parents:
17660
diff
changeset
|
553 | bb = pb->proto_data; |
| 11477 | 554 | |
|
11826
10ebbc41f163
[gaim-migrate @ 14117]
Richard Laager <rlaager@pidgin.im>
parents:
11823
diff
changeset
|
555 | /* Check if the conversation has been previously started */ |
|
11539
fbabe3f89777
[gaim-migrate @ 13794]
Mark Doliner <markdoliner@pidgin.im>
parents:
11515
diff
changeset
|
556 | if (bb->conversation == NULL) |
|
fbabe3f89777
[gaim-migrate @ 13794]
Mark Doliner <markdoliner@pidgin.im>
parents:
11515
diff
changeset
|
557 | { |
|
19056
05cd9ab28312
Update the Bonjour prpl to use libxml explicitly instead of the xml_node stuff. This allows us to deal with partial reads. I also fixed issues related to starting conversations with iChat and a couple other things. Fixes #2022,#1652
Daniel Atallah <datallah@pidgin.im>
parents:
18947
diff
changeset
|
558 | bb->conversation = bonjour_jabber_conv_new(); |
|
17665
26bff2090889
Update Bonjour to do nonblocking I/O correctly.
Daniel Atallah <datallah@pidgin.im>
parents:
17663
diff
changeset
|
559 | |
|
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
|
560 | 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
|
561 | close(client_socket); |
|
26bff2090889
Update Bonjour to do nonblocking I/O correctly.
Daniel Atallah <datallah@pidgin.im>
parents:
17663
diff
changeset
|
562 | return; |
|
26bff2090889
Update Bonjour to do nonblocking I/O correctly.
Daniel Atallah <datallah@pidgin.im>
parents:
17663
diff
changeset
|
563 | } |
|
26bff2090889
Update Bonjour to do nonblocking I/O correctly.
Daniel Atallah <datallah@pidgin.im>
parents:
17663
diff
changeset
|
564 | |
| 11477 | 565 | } 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
|
566 | purple_debug_warning("bonjour", "Ignoring incoming connection because an existing connection exists.\n"); |
| 11477 | 567 | close(client_socket); |
| 568 | } | |
| 569 | } | |
| 570 | ||
|
11539
fbabe3f89777
[gaim-migrate @ 13794]
Mark Doliner <markdoliner@pidgin.im>
parents:
11515
diff
changeset
|
571 | gint |
|
fbabe3f89777
[gaim-migrate @ 13794]
Mark Doliner <markdoliner@pidgin.im>
parents:
11515
diff
changeset
|
572 | bonjour_jabber_start(BonjourJabber *data) |
| 11477 | 573 | { |
| 574 | struct sockaddr_in my_addr; | |
| 575 | int yes = 1; | |
| 13971 | 576 | int i; |
| 577 | gboolean bind_successful; | |
| 11477 | 578 | |
|
11826
10ebbc41f163
[gaim-migrate @ 14117]
Richard Laager <rlaager@pidgin.im>
parents:
11823
diff
changeset
|
579 | /* Open a listening socket for incoming conversations */ |
|
11539
fbabe3f89777
[gaim-migrate @ 13794]
Mark Doliner <markdoliner@pidgin.im>
parents:
11515
diff
changeset
|
580 | if ((data->socket = socket(PF_INET, SOCK_STREAM, 0)) < 0) |
|
fbabe3f89777
[gaim-migrate @ 13794]
Mark Doliner <markdoliner@pidgin.im>
parents:
11515
diff
changeset
|
581 | { |
| 15884 | 582 | purple_debug_error("bonjour", "Cannot open socket: %s\n", strerror(errno)); |
|
20435
bc4b48f6fbaa
Fix up Bonjour to use purple_connection_error_reason.
Will Thompson <resiak@pidgin.im>
parents:
19859
diff
changeset
|
583 | purple_connection_error_reason (data->account->gc, |
| 21279 | 584 | PURPLE_CONNECTION_ERROR_NETWORK_ERROR, |
| 585 | _("Cannot open socket")); | |
| 11477 | 586 | return -1; |
| 587 | } | |
|
11539
fbabe3f89777
[gaim-migrate @ 13794]
Mark Doliner <markdoliner@pidgin.im>
parents:
11515
diff
changeset
|
588 | |
|
11826
10ebbc41f163
[gaim-migrate @ 14117]
Richard Laager <rlaager@pidgin.im>
parents:
11823
diff
changeset
|
589 | /* Make the socket reusable */ |
|
11539
fbabe3f89777
[gaim-migrate @ 13794]
Mark Doliner <markdoliner@pidgin.im>
parents:
11515
diff
changeset
|
590 | 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
|
591 | { |
| 15884 | 592 | purple_debug_error("bonjour", "Error setting socket options: %s\n", strerror(errno)); |
|
20435
bc4b48f6fbaa
Fix up Bonjour to use purple_connection_error_reason.
Will Thompson <resiak@pidgin.im>
parents:
19859
diff
changeset
|
593 | purple_connection_error_reason (data->account->gc, |
| 21279 | 594 | PURPLE_CONNECTION_ERROR_NETWORK_ERROR, |
| 595 | _("Error setting socket options")); | |
| 11477 | 596 | return -1; |
| 597 | } | |
| 598 | ||
| 599 | memset(&my_addr, 0, sizeof(struct sockaddr_in)); | |
| 600 | my_addr.sin_family = PF_INET; | |
|
11539
fbabe3f89777
[gaim-migrate @ 13794]
Mark Doliner <markdoliner@pidgin.im>
parents:
11515
diff
changeset
|
601 | |
| 13971 | 602 | /* Attempt to find a free port */ |
| 603 | bind_successful = FALSE; | |
| 604 | for (i = 0; i < 10; i++) | |
| 605 | { | |
| 606 | my_addr.sin_port = htons(data->port); | |
| 607 | if (bind(data->socket, (struct sockaddr*)&my_addr, sizeof(struct sockaddr)) == 0) | |
| 608 | { | |
| 609 | bind_successful = TRUE; | |
| 610 | break; | |
| 611 | } | |
| 612 | data->port++; | |
| 613 | } | |
| 614 | ||
| 615 | /* On no! We tried 10 ports and could not bind to ANY of them */ | |
| 616 | if (!bind_successful) | |
|
11539
fbabe3f89777
[gaim-migrate @ 13794]
Mark Doliner <markdoliner@pidgin.im>
parents:
11515
diff
changeset
|
617 | { |
| 15884 | 618 | purple_debug_error("bonjour", "Cannot bind socket: %s\n", strerror(errno)); |
|
20435
bc4b48f6fbaa
Fix up Bonjour to use purple_connection_error_reason.
Will Thompson <resiak@pidgin.im>
parents:
19859
diff
changeset
|
619 | purple_connection_error_reason (data->account->gc, |
| 21279 | 620 | PURPLE_CONNECTION_ERROR_NETWORK_ERROR, |
| 621 | _("Could not bind socket to port")); | |
| 11477 | 622 | return -1; |
| 623 | } | |
|
11539
fbabe3f89777
[gaim-migrate @ 13794]
Mark Doliner <markdoliner@pidgin.im>
parents:
11515
diff
changeset
|
624 | |
| 13971 | 625 | /* Attempt to listen on the bound socket */ |
|
11539
fbabe3f89777
[gaim-migrate @ 13794]
Mark Doliner <markdoliner@pidgin.im>
parents:
11515
diff
changeset
|
626 | if (listen(data->socket, 10) != 0) |
|
fbabe3f89777
[gaim-migrate @ 13794]
Mark Doliner <markdoliner@pidgin.im>
parents:
11515
diff
changeset
|
627 | { |
| 15884 | 628 | purple_debug_error("bonjour", "Cannot listen on socket: %s\n", strerror(errno)); |
|
20435
bc4b48f6fbaa
Fix up Bonjour to use purple_connection_error_reason.
Will Thompson <resiak@pidgin.im>
parents:
19859
diff
changeset
|
629 | purple_connection_error_reason (data->account->gc, |
| 21279 | 630 | PURPLE_CONNECTION_ERROR_NETWORK_ERROR, |
| 631 | _("Could not listen on socket")); | |
| 11477 | 632 | return -1; |
| 633 | } | |
| 634 | ||
|
11826
10ebbc41f163
[gaim-migrate @ 14117]
Richard Laager <rlaager@pidgin.im>
parents:
11823
diff
changeset
|
635 | #if 0 |
|
12730
f64fdbc34677
[gaim-migrate @ 15074]
Daniel Atallah <datallah@pidgin.im>
parents:
12708
diff
changeset
|
636 | /* TODO: Why isn't this being used? */ |
| 15884 | 637 | data->socket = purple_network_listen(data->port, SOCK_STREAM); |
| 11477 | 638 | |
|
11826
10ebbc41f163
[gaim-migrate @ 14117]
Richard Laager <rlaager@pidgin.im>
parents:
11823
diff
changeset
|
639 | if (data->socket == -1) |
|
10ebbc41f163
[gaim-migrate @ 14117]
Richard Laager <rlaager@pidgin.im>
parents:
11823
diff
changeset
|
640 | { |
| 15884 | 641 | 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
|
642 | } |
|
10ebbc41f163
[gaim-migrate @ 14117]
Richard Laager <rlaager@pidgin.im>
parents:
11823
diff
changeset
|
643 | #endif |
| 11477 | 644 | |
|
11826
10ebbc41f163
[gaim-migrate @ 14117]
Richard Laager <rlaager@pidgin.im>
parents:
11823
diff
changeset
|
645 | /* Open a watcher in the socket we have just opened */ |
| 15884 | 646 | 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
|
647 | |
| 13971 | 648 | return data->port; |
| 11477 | 649 | } |
| 650 | ||
|
17665
26bff2090889
Update Bonjour to do nonblocking I/O correctly.
Daniel Atallah <datallah@pidgin.im>
parents:
17663
diff
changeset
|
651 | static void |
|
26bff2090889
Update Bonjour to do nonblocking I/O correctly.
Daniel Atallah <datallah@pidgin.im>
parents:
17663
diff
changeset
|
652 | _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
|
653 | { |
|
26bff2090889
Update Bonjour to do nonblocking I/O correctly.
Daniel Atallah <datallah@pidgin.im>
parents:
17663
diff
changeset
|
654 | PurpleBuddy *pb = data; |
|
26bff2090889
Update Bonjour to do nonblocking I/O correctly.
Daniel Atallah <datallah@pidgin.im>
parents:
17663
diff
changeset
|
655 | BonjourBuddy *bb = pb->proto_data; |
|
26bff2090889
Update Bonjour to do nonblocking I/O correctly.
Daniel Atallah <datallah@pidgin.im>
parents:
17663
diff
changeset
|
656 | |
|
26bff2090889
Update Bonjour to do nonblocking I/O correctly.
Daniel Atallah <datallah@pidgin.im>
parents:
17663
diff
changeset
|
657 | bb->conversation->connect_data = NULL; |
|
26bff2090889
Update Bonjour to do nonblocking I/O correctly.
Daniel Atallah <datallah@pidgin.im>
parents:
17663
diff
changeset
|
658 | |
|
26bff2090889
Update Bonjour to do nonblocking I/O correctly.
Daniel Atallah <datallah@pidgin.im>
parents:
17663
diff
changeset
|
659 | if (source < 0) { |
|
26bff2090889
Update Bonjour to do nonblocking I/O correctly.
Daniel Atallah <datallah@pidgin.im>
parents:
17663
diff
changeset
|
660 | PurpleConversation *conv; |
|
26bff2090889
Update Bonjour to do nonblocking I/O correctly.
Daniel Atallah <datallah@pidgin.im>
parents:
17663
diff
changeset
|
661 | |
|
26bff2090889
Update Bonjour to do nonblocking I/O correctly.
Daniel Atallah <datallah@pidgin.im>
parents:
17663
diff
changeset
|
662 | 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
|
663 | 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
|
664 | |
|
26bff2090889
Update Bonjour to do nonblocking I/O correctly.
Daniel Atallah <datallah@pidgin.im>
parents:
17663
diff
changeset
|
665 | 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
|
666 | if (conv != NULL) |
|
26bff2090889
Update Bonjour to do nonblocking I/O correctly.
Daniel Atallah <datallah@pidgin.im>
parents:
17663
diff
changeset
|
667 | purple_conversation_write(conv, NULL, |
|
26bff2090889
Update Bonjour to do nonblocking I/O correctly.
Daniel Atallah <datallah@pidgin.im>
parents:
17663
diff
changeset
|
668 | _("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
|
669 | PURPLE_MESSAGE_SYSTEM, time(NULL)); |
|
26bff2090889
Update Bonjour to do nonblocking I/O correctly.
Daniel Atallah <datallah@pidgin.im>
parents:
17663
diff
changeset
|
670 | |
|
26bff2090889
Update Bonjour to do nonblocking I/O correctly.
Daniel Atallah <datallah@pidgin.im>
parents:
17663
diff
changeset
|
671 | bonjour_jabber_close_conversation(bb->conversation); |
|
26bff2090889
Update Bonjour to do nonblocking I/O correctly.
Daniel Atallah <datallah@pidgin.im>
parents:
17663
diff
changeset
|
672 | bb->conversation = NULL; |
|
26bff2090889
Update Bonjour to do nonblocking I/O correctly.
Daniel Atallah <datallah@pidgin.im>
parents:
17663
diff
changeset
|
673 | return; |
|
26bff2090889
Update Bonjour to do nonblocking I/O correctly.
Daniel Atallah <datallah@pidgin.im>
parents:
17663
diff
changeset
|
674 | } |
|
26bff2090889
Update Bonjour to do nonblocking I/O correctly.
Daniel Atallah <datallah@pidgin.im>
parents:
17663
diff
changeset
|
675 | |
|
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
|
676 | if (!bonjour_jabber_stream_init(pb, source)) { |
|
17665
26bff2090889
Update Bonjour to do nonblocking I/O correctly.
Daniel Atallah <datallah@pidgin.im>
parents:
17663
diff
changeset
|
677 | const char *err = strerror(errno); |
|
26bff2090889
Update Bonjour to do nonblocking I/O correctly.
Daniel Atallah <datallah@pidgin.im>
parents:
17663
diff
changeset
|
678 | PurpleConversation *conv; |
|
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 | 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
|
681 | 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
|
682 | |
|
26bff2090889
Update Bonjour to do nonblocking I/O correctly.
Daniel Atallah <datallah@pidgin.im>
parents:
17663
diff
changeset
|
683 | 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
|
684 | if (conv != NULL) |
|
26bff2090889
Update Bonjour to do nonblocking I/O correctly.
Daniel Atallah <datallah@pidgin.im>
parents:
17663
diff
changeset
|
685 | purple_conversation_write(conv, NULL, |
|
26bff2090889
Update Bonjour to do nonblocking I/O correctly.
Daniel Atallah <datallah@pidgin.im>
parents:
17663
diff
changeset
|
686 | _("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
|
687 | PURPLE_MESSAGE_SYSTEM, time(NULL)); |
|
26bff2090889
Update Bonjour to do nonblocking I/O correctly.
Daniel Atallah <datallah@pidgin.im>
parents:
17663
diff
changeset
|
688 | |
|
26bff2090889
Update Bonjour to do nonblocking I/O correctly.
Daniel Atallah <datallah@pidgin.im>
parents:
17663
diff
changeset
|
689 | close(source); |
|
26bff2090889
Update Bonjour to do nonblocking I/O correctly.
Daniel Atallah <datallah@pidgin.im>
parents:
17663
diff
changeset
|
690 | bonjour_jabber_close_conversation(bb->conversation); |
|
26bff2090889
Update Bonjour to do nonblocking I/O correctly.
Daniel Atallah <datallah@pidgin.im>
parents:
17663
diff
changeset
|
691 | bb->conversation = NULL; |
|
26bff2090889
Update Bonjour to do nonblocking I/O correctly.
Daniel Atallah <datallah@pidgin.im>
parents:
17663
diff
changeset
|
692 | return; |
|
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 | } |
|
26bff2090889
Update Bonjour to do nonblocking I/O correctly.
Daniel Atallah <datallah@pidgin.im>
parents:
17663
diff
changeset
|
695 | |
|
11693
1a42a66ca0f8
[gaim-migrate @ 13979]
Mark Doliner <markdoliner@pidgin.im>
parents:
11688
diff
changeset
|
696 | int |
|
11539
fbabe3f89777
[gaim-migrate @ 13794]
Mark Doliner <markdoliner@pidgin.im>
parents:
11515
diff
changeset
|
697 | bonjour_jabber_send_message(BonjourJabber *data, const gchar *to, const gchar *body) |
| 11477 | 698 | { |
|
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
|
699 | xmlnode *message_node, *node, *node2; |
|
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
|
700 | gchar *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
|
701 | PurpleBuddy *pb; |
|
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
|
702 | BonjourBuddy *bb; |
|
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
|
703 | int ret; |
|
11539
fbabe3f89777
[gaim-migrate @ 13794]
Mark Doliner <markdoliner@pidgin.im>
parents:
11515
diff
changeset
|
704 | |
|
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
|
705 | pb = purple_find_buddy(data->account, to); |
|
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
|
706 | if (pb == NULL) { |
|
17607
4d7a1c0f169b
Improve error handling while connecting to a bonjour buddy.
Daniel Atallah <datallah@pidgin.im>
parents:
17596
diff
changeset
|
707 | purple_debug_info("bonjour", "Can't send a message to an offline buddy (%s).\n", to); |
|
11693
1a42a66ca0f8
[gaim-migrate @ 13979]
Mark Doliner <markdoliner@pidgin.im>
parents:
11688
diff
changeset
|
708 | /* You can not send a message to an offline buddy */ |
|
1a42a66ca0f8
[gaim-migrate @ 13979]
Mark Doliner <markdoliner@pidgin.im>
parents:
11688
diff
changeset
|
709 | return -10000; |
|
17607
4d7a1c0f169b
Improve error handling while connecting to a bonjour buddy.
Daniel Atallah <datallah@pidgin.im>
parents:
17596
diff
changeset
|
710 | } |
|
11693
1a42a66ca0f8
[gaim-migrate @ 13979]
Mark Doliner <markdoliner@pidgin.im>
parents:
11688
diff
changeset
|
711 | |
|
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
|
712 | bb = pb->proto_data; |
|
11693
1a42a66ca0f8
[gaim-migrate @ 13979]
Mark Doliner <markdoliner@pidgin.im>
parents:
11688
diff
changeset
|
713 | |
|
17607
4d7a1c0f169b
Improve error handling while connecting to a bonjour buddy.
Daniel Atallah <datallah@pidgin.im>
parents:
17596
diff
changeset
|
714 | /* 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
|
715 | if (bb->conversation == NULL) |
|
4d7a1c0f169b
Improve error handling while connecting to a bonjour buddy.
Daniel Atallah <datallah@pidgin.im>
parents:
17596
diff
changeset
|
716 | { |
|
17665
26bff2090889
Update Bonjour to do nonblocking I/O correctly.
Daniel Atallah <datallah@pidgin.im>
parents:
17663
diff
changeset
|
717 | 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
|
718 | PurpleProxyInfo *proxy_info; |
|
17665
26bff2090889
Update Bonjour to do nonblocking I/O correctly.
Daniel Atallah <datallah@pidgin.im>
parents:
17663
diff
changeset
|
719 | |
|
26bff2090889
Update Bonjour to do nonblocking I/O correctly.
Daniel Atallah <datallah@pidgin.im>
parents:
17663
diff
changeset
|
720 | /* 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
|
721 | * 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
|
722 | 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
|
723 | 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
|
724 | 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
|
725 | 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
|
726 | } |
|
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
|
727 | 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
|
728 | |
|
26bff2090889
Update Bonjour to do nonblocking I/O correctly.
Daniel Atallah <datallah@pidgin.im>
parents:
17663
diff
changeset
|
729 | connect_data = |
|
26bff2090889
Update Bonjour to do nonblocking I/O correctly.
Daniel Atallah <datallah@pidgin.im>
parents:
17663
diff
changeset
|
730 | purple_proxy_connect(data->account->gc, data->account, bb->ip, |
|
26bff2090889
Update Bonjour to do nonblocking I/O correctly.
Daniel Atallah <datallah@pidgin.im>
parents:
17663
diff
changeset
|
731 | bb->port_p2pj, _connected_to_buddy, pb); |
|
26bff2090889
Update Bonjour to do nonblocking I/O correctly.
Daniel Atallah <datallah@pidgin.im>
parents:
17663
diff
changeset
|
732 | |
|
26bff2090889
Update Bonjour to do nonblocking I/O correctly.
Daniel Atallah <datallah@pidgin.im>
parents:
17663
diff
changeset
|
733 | if (connect_data == NULL) { |
|
26bff2090889
Update Bonjour to do nonblocking I/O correctly.
Daniel Atallah <datallah@pidgin.im>
parents:
17663
diff
changeset
|
734 | purple_debug_error("bonjour", "Unable to connect to buddy (%s).\n", to); |
|
17607
4d7a1c0f169b
Improve error handling while connecting to a bonjour buddy.
Daniel Atallah <datallah@pidgin.im>
parents:
17596
diff
changeset
|
735 | return -10001; |
|
17665
26bff2090889
Update Bonjour to do nonblocking I/O correctly.
Daniel Atallah <datallah@pidgin.im>
parents:
17663
diff
changeset
|
736 | } |
|
17607
4d7a1c0f169b
Improve error handling while connecting to a bonjour buddy.
Daniel Atallah <datallah@pidgin.im>
parents:
17596
diff
changeset
|
737 | |
|
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
|
738 | bb->conversation = bonjour_jabber_conv_new(); |
|
17665
26bff2090889
Update Bonjour to do nonblocking I/O correctly.
Daniel Atallah <datallah@pidgin.im>
parents:
17663
diff
changeset
|
739 | bb->conversation->connect_data = connect_data; |
|
26bff2090889
Update Bonjour to do nonblocking I/O correctly.
Daniel Atallah <datallah@pidgin.im>
parents:
17663
diff
changeset
|
740 | /* 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
|
741 | * 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
|
742 | 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
|
743 | } |
|
4d7a1c0f169b
Improve error handling while connecting to a bonjour buddy.
Daniel Atallah <datallah@pidgin.im>
parents:
17596
diff
changeset
|
744 | |
|
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
|
745 | 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
|
746 | 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
|
747 | 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
|
748 | 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
|
749 | |
|
11826
10ebbc41f163
[gaim-migrate @ 14117]
Richard Laager <rlaager@pidgin.im>
parents:
11823
diff
changeset
|
750 | /* 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
|
751 | 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
|
752 | 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
|
753 | 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
|
754 | g_free(message); |
|
11539
fbabe3f89777
[gaim-migrate @ 13794]
Mark Doliner <markdoliner@pidgin.im>
parents:
11515
diff
changeset
|
755 | |
|
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
|
756 | 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
|
757 | xmlnode_set_namespace(node, "http://www.w3.org/1999/xhtml"); |
|
11539
fbabe3f89777
[gaim-migrate @ 13794]
Mark Doliner <markdoliner@pidgin.im>
parents:
11515
diff
changeset
|
758 | |
|
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
|
759 | 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
|
760 | 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
|
761 | 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
|
762 | 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
|
763 | xmlnode_insert_child(node, node2); |
|
11539
fbabe3f89777
[gaim-migrate @ 13794]
Mark Doliner <markdoliner@pidgin.im>
parents:
11515
diff
changeset
|
764 | |
|
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
|
765 | 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
|
766 | 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
|
767 | xmlnode_insert_child(node, xmlnode_new("composing")); |
|
11539
fbabe3f89777
[gaim-migrate @ 13794]
Mark Doliner <markdoliner@pidgin.im>
parents:
11515
diff
changeset
|
768 | |
|
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
|
769 | message = xmlnode_to_str(message_node, NULL); |
|
15873
78d3aa0fb61e
plug some memory leaks
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
15435
diff
changeset
|
770 | xmlnode_free(message_node); |
| 11477 | 771 | |
|
17665
26bff2090889
Update Bonjour to do nonblocking I/O correctly.
Daniel Atallah <datallah@pidgin.im>
parents:
17663
diff
changeset
|
772 | 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
|
773 | |
|
15873
78d3aa0fb61e
plug some memory leaks
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
15435
diff
changeset
|
774 | g_free(message); |
|
78d3aa0fb61e
plug some memory leaks
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
15435
diff
changeset
|
775 | |
|
17665
26bff2090889
Update Bonjour to do nonblocking I/O correctly.
Daniel Atallah <datallah@pidgin.im>
parents:
17663
diff
changeset
|
776 | return ret; |
| 11477 | 777 | } |
| 778 | ||
|
11539
fbabe3f89777
[gaim-migrate @ 13794]
Mark Doliner <markdoliner@pidgin.im>
parents:
11515
diff
changeset
|
779 | 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
|
780 | bonjour_jabber_close_conversation(BonjourJabberConversation *bconv) |
| 11477 | 781 | { |
|
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
|
782 | if (bconv != NULL) |
|
11539
fbabe3f89777
[gaim-migrate @ 13794]
Mark Doliner <markdoliner@pidgin.im>
parents:
11515
diff
changeset
|
783 | { |
|
11826
10ebbc41f163
[gaim-migrate @ 14117]
Richard Laager <rlaager@pidgin.im>
parents:
11823
diff
changeset
|
784 | /* 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
|
785 | 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
|
786 | /* 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
|
787 | 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
|
788 | 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
|
789 | /* 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
|
790 | 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
|
791 | } |
|
19579
d79d5c95ce5a
Reset unsigned int input handlers to 0 instead of -1.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
19373
diff
changeset
|
792 | if (bconv->rx_handler != 0) |
|
17665
26bff2090889
Update Bonjour to do nonblocking I/O correctly.
Daniel Atallah <datallah@pidgin.im>
parents:
17663
diff
changeset
|
793 | purple_input_remove(bconv->rx_handler); |
|
26bff2090889
Update Bonjour to do nonblocking I/O correctly.
Daniel Atallah <datallah@pidgin.im>
parents:
17663
diff
changeset
|
794 | if (bconv->tx_handler > 0) |
|
26bff2090889
Update Bonjour to do nonblocking I/O correctly.
Daniel Atallah <datallah@pidgin.im>
parents:
17663
diff
changeset
|
795 | purple_input_remove(bconv->tx_handler); |
|
11539
fbabe3f89777
[gaim-migrate @ 13794]
Mark Doliner <markdoliner@pidgin.im>
parents:
11515
diff
changeset
|
796 | |
|
11826
10ebbc41f163
[gaim-migrate @ 14117]
Richard Laager <rlaager@pidgin.im>
parents:
11823
diff
changeset
|
797 | /* 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
|
798 | 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
|
799 | if (bconv->connect_data != NULL) |
|
26bff2090889
Update Bonjour to do nonblocking I/O correctly.
Daniel Atallah <datallah@pidgin.im>
parents:
17663
diff
changeset
|
800 | 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
|
801 | if (bconv->stream_data != NULL) { |
|
26bff2090889
Update Bonjour to do nonblocking I/O correctly.
Daniel Atallah <datallah@pidgin.im>
parents:
17663
diff
changeset
|
802 | 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
|
803 | g_free(ss->msg); |
|
26bff2090889
Update Bonjour to do nonblocking I/O correctly.
Daniel Atallah <datallah@pidgin.im>
parents:
17663
diff
changeset
|
804 | g_free(ss); |
|
26bff2090889
Update Bonjour to do nonblocking I/O correctly.
Daniel Atallah <datallah@pidgin.im>
parents:
17663
diff
changeset
|
805 | } |
|
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
|
806 | |
|
05cd9ab28312
Update the Bonjour prpl to use libxml explicitly instead of the xml_node stuff. This allows us to deal with partial reads. I also fixed issues related to starting conversations with iChat and a couple other things. Fixes #2022,#1652
Daniel Atallah <datallah@pidgin.im>
parents:
18947
diff
changeset
|
807 | 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
|
808 | 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
|
809 | |
|
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
|
810 | g_free(bconv); |
| 11477 | 811 | } |
| 812 | } | |
| 813 | ||
|
11539
fbabe3f89777
[gaim-migrate @ 13794]
Mark Doliner <markdoliner@pidgin.im>
parents:
11515
diff
changeset
|
814 | void |
|
fbabe3f89777
[gaim-migrate @ 13794]
Mark Doliner <markdoliner@pidgin.im>
parents:
11515
diff
changeset
|
815 | bonjour_jabber_stop(BonjourJabber *data) |
| 11477 | 816 | { |
|
17633
b76241c02857
Some more Bonjour cleanup and leak fixing.
Daniel Atallah <datallah@pidgin.im>
parents:
17632
diff
changeset
|
817 | /* 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
|
818 | if (data->socket >= 0) |
|
b27a15168d33
Improve Bonjour error handling when there are errors "connecting".
Daniel Atallah <datallah@pidgin.im>
parents:
17607
diff
changeset
|
819 | close(data->socket); |
|
b27a15168d33
Improve Bonjour error handling when there are errors "connecting".
Daniel Atallah <datallah@pidgin.im>
parents:
17607
diff
changeset
|
820 | if (data->watcher_id > 0) |
|
b27a15168d33
Improve Bonjour error handling when there are errors "connecting".
Daniel Atallah <datallah@pidgin.im>
parents:
17607
diff
changeset
|
821 | purple_input_remove(data->watcher_id); |
|
11539
fbabe3f89777
[gaim-migrate @ 13794]
Mark Doliner <markdoliner@pidgin.im>
parents:
11515
diff
changeset
|
822 | |
|
17633
b76241c02857
Some more Bonjour cleanup and leak fixing.
Daniel Atallah <datallah@pidgin.im>
parents:
17632
diff
changeset
|
823 | /* 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
|
824 | if (data->account->gc != NULL) |
|
fbabe3f89777
[gaim-migrate @ 13794]
Mark Doliner <markdoliner@pidgin.im>
parents:
11515
diff
changeset
|
825 | { |
|
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
|
826 | GSList *buddies, *l; |
|
17633
b76241c02857
Some more Bonjour cleanup and leak fixing.
Daniel Atallah <datallah@pidgin.im>
parents:
17632
diff
changeset
|
827 | |
|
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
|
828 | 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
|
829 | 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
|
830 | 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
|
831 | 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
|
832 | 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
|
833 | } |
|
17665
26bff2090889
Update Bonjour to do nonblocking I/O correctly.
Daniel Atallah <datallah@pidgin.im>
parents:
17663
diff
changeset
|
834 | |
| 11477 | 835 | g_slist_free(buddies); |
| 836 | } | |
| 837 | } |