Mercurial > pidgin.yaz
annotate src/protocols/jabber/jabber.c @ 13485:9ad3d85fffeb
[gaim-migrate @ 15861]
don't crash when a conversation is open and the account logs out
committer: Tailor Script <tailor@pidgin.im>
author | Daniel Atallah <daniel.atallah@gmail.com> |
---|---|
date | Fri, 10 Mar 2006 02:24:24 +0000 |
parents | a580ffe73314 |
children | cfc2f7fcb3dd |
rev | line source |
---|---|
2086 | 1 /* |
7014 | 2 * gaim - Jabber Protocol Plugin |
2086 | 3 * |
7014 | 4 * Copyright (C) 2003, Nathan Walp <faceprint@faceprint.com> |
2086 | 5 * |
6 * This program is free software; you can redistribute it and/or modify | |
7 * it under the terms of the GNU General Public License as published by | |
8 * the Free Software Foundation; either version 2 of the License, or | |
9 * (at your option) any later version. | |
7014 | 10 * |
2086 | 11 * This program is distributed in the hope that it will be useful, |
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of | |
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
14 * GNU General Public License for more details. | |
15 * | |
16 * You should have received a copy of the GNU General Public License | |
17 * along with this program; if not, write to the Free Software | |
18 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA | |
19 * | |
20 */ | |
5872
059d95c67cda
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5685
diff
changeset
|
21 #include "internal.h" |
059d95c67cda
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5685
diff
changeset
|
22 |
7014 | 23 #include "account.h" |
24 #include "accountopt.h" | |
9030 | 25 #include "blist.h" |
9130 | 26 #include "cmds.h" |
10740 | 27 #include "connection.h" |
7014 | 28 #include "debug.h" |
11387 | 29 #include "dnssrv.h" |
7014 | 30 #include "message.h" |
7072 | 31 #include "notify.h" |
8713 | 32 #include "pluginpref.h" |
7014 | 33 #include "prpl.h" |
7072 | 34 #include "request.h" |
7014 | 35 #include "server.h" |
7095
c8bf2da398e3
[gaim-migrate @ 7660]
Christian Hammond <chipx86@chipx86.com>
parents:
7072
diff
changeset
|
36 #include "util.h" |
9943 | 37 #include "version.h" |
5872
059d95c67cda
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5685
diff
changeset
|
38 |
7014 | 39 #include "auth.h" |
40 #include "buddy.h" | |
41 #include "chat.h" | |
8312 | 42 #include "disco.h" |
7014 | 43 #include "iq.h" |
44 #include "jutil.h" | |
45 #include "message.h" | |
46 #include "parser.h" | |
47 #include "presence.h" | |
48 #include "jabber.h" | |
49 #include "roster.h" | |
9466 | 50 #include "si.h" |
7923 | 51 #include "xdata.h" |
5872
059d95c67cda
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5685
diff
changeset
|
52 |
7014 | 53 #define JABBER_CONNECT_STEPS (js->gsc ? 8 : 5) |
2086 | 54 |
5205
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5174
diff
changeset
|
55 static GaimPlugin *my_protocol = NULL; |
4249 | 56 |
7014 | 57 static void jabber_stream_init(JabberStream *js) |
58 { | |
59 char *open_stream; | |
3340 | 60 |
7014 | 61 open_stream = g_strdup_printf("<stream:stream to='%s' " |
62 "xmlns='jabber:client' " | |
7395 | 63 "xmlns:stream='http://etherx.jabber.org/streams' " |
64 "version='1.0'>", | |
7291 | 65 js->user->domain); |
3311 | 66 |
7642 | 67 jabber_send_raw(js, open_stream, -1); |
2086 | 68 |
7014 | 69 g_free(open_stream); |
2086 | 70 } |
71 | |
7395 | 72 static void |
73 jabber_session_initialized_cb(JabberStream *js, xmlnode *packet, gpointer data) | |
3311 | 74 { |
7014 | 75 const char *type = xmlnode_get_attrib(packet, "type"); |
76 if(type && !strcmp(type, "result")) { | |
77 jabber_stream_set_state(js, JABBER_STREAM_CONNECTED); | |
78 } else { | |
79 gaim_connection_error(js->gc, _("Error initializing session")); | |
3311 | 80 } |
81 } | |
82 | |
7014 | 83 static void jabber_session_init(JabberStream *js) |
3311 | 84 { |
7014 | 85 JabberIq *iq = jabber_iq_new(js, JABBER_IQ_SET); |
86 xmlnode *session; | |
3311 | 87 |
7395 | 88 jabber_iq_set_callback(iq, jabber_session_initialized_cb, NULL); |
3311 | 89 |
7014 | 90 session = xmlnode_new_child(iq->node, "session"); |
91 xmlnode_set_attrib(session, "xmlns", "urn:ietf:params:xml:ns:xmpp-session"); | |
3311 | 92 |
7014 | 93 jabber_iq_send(iq); |
3311 | 94 } |
95 | |
7395 | 96 static void jabber_bind_result_cb(JabberStream *js, xmlnode *packet, |
97 gpointer data) | |
98 { | |
8401 | 99 const char *type = xmlnode_get_attrib(packet, "type"); |
100 xmlnode *bind; | |
101 | |
102 if(type && !strcmp(type, "result") && | |
103 (bind = xmlnode_get_child_with_namespace(packet, "bind", "urn:ietf:params:xml:ns:xmpp-bind"))) { | |
104 xmlnode *jid; | |
105 char *full_jid; | |
106 if((jid = xmlnode_get_child(bind, "jid")) && (full_jid = xmlnode_get_data(jid))) { | |
10289 | 107 JabberBuddy *my_jb = NULL; |
8401 | 108 jabber_id_free(js->user); |
109 if(!(js->user = jabber_id_new(full_jid))) { | |
110 gaim_connection_error(js->gc, _("Invalid response from server.")); | |
111 } | |
10289 | 112 if((my_jb = jabber_buddy_find(js, full_jid, TRUE))) |
113 my_jb->subscription |= JABBER_SUB_BOTH; | |
10504 | 114 g_free(full_jid); |
8401 | 115 } |
116 } else { | |
117 char *msg = jabber_parse_error(js, packet); | |
118 gaim_connection_error(js->gc, msg); | |
119 g_free(msg); | |
120 } | |
7395 | 121 |
122 jabber_session_init(js); | |
123 } | |
124 | |
125 static void jabber_stream_features_parse(JabberStream *js, xmlnode *packet) | |
126 { | |
8296 | 127 if(xmlnode_get_child(packet, "starttls")) { |
128 if(jabber_process_starttls(js, packet)) | |
129 return; | |
130 } | |
131 | |
10988 | 132 if(js->registration) { |
133 jabber_register_start(js); | |
134 } else if(xmlnode_get_child(packet, "mechanisms")) { | |
7395 | 135 jabber_auth_start(js, packet); |
136 } else if(xmlnode_get_child(packet, "bind")) { | |
137 xmlnode *bind, *resource; | |
138 JabberIq *iq = jabber_iq_new(js, JABBER_IQ_SET); | |
139 bind = xmlnode_new_child(iq->node, "bind"); | |
140 xmlnode_set_attrib(bind, "xmlns", "urn:ietf:params:xml:ns:xmpp-bind"); | |
141 resource = xmlnode_new_child(bind, "resource"); | |
142 xmlnode_insert_data(resource, js->user->resource, -1); | |
143 | |
144 jabber_iq_set_callback(iq, jabber_bind_result_cb, NULL); | |
145 | |
146 jabber_iq_send(iq); | |
8296 | 147 } else /* if(xmlnode_get_child_with_namespace(packet, "auth")) */ { |
148 /* If we get an empty stream:features packet, or we explicitly get | |
149 * an auth feature with namespace http://jabber.org/features/iq-auth | |
150 * we should revert back to iq:auth authentication, even though we're | |
151 * connecting to an XMPP server. */ | |
152 js->auth_type = JABBER_AUTH_IQ_AUTH; | |
153 jabber_stream_set_state(js, JABBER_STREAM_AUTHENTICATING); | |
7395 | 154 } |
155 } | |
156 | |
7014 | 157 static void jabber_stream_handle_error(JabberStream *js, xmlnode *packet) |
3311 | 158 { |
8401 | 159 char *msg = jabber_parse_error(js, packet); |
3311 | 160 |
8401 | 161 gaim_connection_error(js->gc, msg); |
162 g_free(msg); | |
2086 | 163 } |
164 | |
7014 | 165 static void tls_init(JabberStream *js); |
2086 | 166 |
7014 | 167 void jabber_process_packet(JabberStream *js, xmlnode *packet) |
2086 | 168 { |
7014 | 169 if(!strcmp(packet->name, "iq")) { |
7395 | 170 jabber_iq_parse(js, packet); |
7014 | 171 } else if(!strcmp(packet->name, "presence")) { |
172 jabber_presence_parse(js, packet); | |
173 } else if(!strcmp(packet->name, "message")) { | |
174 jabber_message_parse(js, packet); | |
175 } else if(!strcmp(packet->name, "stream:features")) { | |
7395 | 176 jabber_stream_features_parse(js, packet); |
7014 | 177 } else if(!strcmp(packet->name, "stream:error")) { |
178 jabber_stream_handle_error(js, packet); | |
179 } else if(!strcmp(packet->name, "challenge")) { | |
180 if(js->state == JABBER_STREAM_AUTHENTICATING) | |
181 jabber_auth_handle_challenge(js, packet); | |
182 } else if(!strcmp(packet->name, "success")) { | |
183 if(js->state == JABBER_STREAM_AUTHENTICATING) | |
184 jabber_auth_handle_success(js, packet); | |
185 } else if(!strcmp(packet->name, "failure")) { | |
186 if(js->state == JABBER_STREAM_AUTHENTICATING) | |
187 jabber_auth_handle_failure(js, packet); | |
188 } else if(!strcmp(packet->name, "proceed")) { | |
189 if(js->state == JABBER_STREAM_AUTHENTICATING && !js->gsc) | |
190 tls_init(js); | |
191 } else { | |
192 gaim_debug(GAIM_DEBUG_WARNING, "jabber", "Unknown packet: %s\n", | |
193 packet->name); | |
2086 | 194 } |
195 } | |
196 | |
13200
33bef17125c2
[gaim-migrate @ 15563]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
13153
diff
changeset
|
197 static int jabber_do_send(JabberStream *js, const char *data, int len) |
33bef17125c2
[gaim-migrate @ 15563]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
13153
diff
changeset
|
198 { |
33bef17125c2
[gaim-migrate @ 15563]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
13153
diff
changeset
|
199 int ret; |
33bef17125c2
[gaim-migrate @ 15563]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
13153
diff
changeset
|
200 |
33bef17125c2
[gaim-migrate @ 15563]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
13153
diff
changeset
|
201 if (js->gsc) |
33bef17125c2
[gaim-migrate @ 15563]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
13153
diff
changeset
|
202 ret = gaim_ssl_write(js->gsc, data, len); |
33bef17125c2
[gaim-migrate @ 15563]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
13153
diff
changeset
|
203 else |
33bef17125c2
[gaim-migrate @ 15563]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
13153
diff
changeset
|
204 ret = write(js->fd, data, len); |
33bef17125c2
[gaim-migrate @ 15563]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
13153
diff
changeset
|
205 |
33bef17125c2
[gaim-migrate @ 15563]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
13153
diff
changeset
|
206 return ret; |
33bef17125c2
[gaim-migrate @ 15563]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
13153
diff
changeset
|
207 } |
33bef17125c2
[gaim-migrate @ 15563]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
13153
diff
changeset
|
208 |
33bef17125c2
[gaim-migrate @ 15563]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
13153
diff
changeset
|
209 static void jabber_send_cb(gpointer data, gint source, GaimInputCondition cond) |
33bef17125c2
[gaim-migrate @ 15563]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
13153
diff
changeset
|
210 { |
33bef17125c2
[gaim-migrate @ 15563]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
13153
diff
changeset
|
211 JabberStream *js = data; |
33bef17125c2
[gaim-migrate @ 15563]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
13153
diff
changeset
|
212 int ret, writelen; |
33bef17125c2
[gaim-migrate @ 15563]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
13153
diff
changeset
|
213 writelen = gaim_circ_buffer_get_max_read(js->write_buffer); |
33bef17125c2
[gaim-migrate @ 15563]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
13153
diff
changeset
|
214 |
33bef17125c2
[gaim-migrate @ 15563]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
13153
diff
changeset
|
215 if (writelen == 0) { |
33bef17125c2
[gaim-migrate @ 15563]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
13153
diff
changeset
|
216 gaim_input_remove(js->writeh); |
33bef17125c2
[gaim-migrate @ 15563]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
13153
diff
changeset
|
217 js->writeh = -1; |
33bef17125c2
[gaim-migrate @ 15563]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
13153
diff
changeset
|
218 return; |
33bef17125c2
[gaim-migrate @ 15563]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
13153
diff
changeset
|
219 } |
33bef17125c2
[gaim-migrate @ 15563]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
13153
diff
changeset
|
220 |
33bef17125c2
[gaim-migrate @ 15563]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
13153
diff
changeset
|
221 ret = jabber_do_send(js, js->write_buffer->outptr, writelen); |
33bef17125c2
[gaim-migrate @ 15563]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
13153
diff
changeset
|
222 |
33bef17125c2
[gaim-migrate @ 15563]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
13153
diff
changeset
|
223 if (ret < 0 && errno == EAGAIN) |
33bef17125c2
[gaim-migrate @ 15563]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
13153
diff
changeset
|
224 return; |
33bef17125c2
[gaim-migrate @ 15563]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
13153
diff
changeset
|
225 else if (ret <= 0) { |
33bef17125c2
[gaim-migrate @ 15563]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
13153
diff
changeset
|
226 gaim_connection_error(js->gc, _("Write error")); |
33bef17125c2
[gaim-migrate @ 15563]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
13153
diff
changeset
|
227 return; |
33bef17125c2
[gaim-migrate @ 15563]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
13153
diff
changeset
|
228 } |
33bef17125c2
[gaim-migrate @ 15563]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
13153
diff
changeset
|
229 |
33bef17125c2
[gaim-migrate @ 15563]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
13153
diff
changeset
|
230 gaim_circ_buffer_mark_read(js->write_buffer, ret); |
33bef17125c2
[gaim-migrate @ 15563]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
13153
diff
changeset
|
231 } |
33bef17125c2
[gaim-migrate @ 15563]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
13153
diff
changeset
|
232 |
7642 | 233 void jabber_send_raw(JabberStream *js, const char *data, int len) |
2086 | 234 { |
7014 | 235 int ret; |
2086 | 236 |
7014 | 237 /* because printing a tab to debug every minute gets old */ |
238 if(strcmp(data, "\t")) | |
8401 | 239 gaim_debug(GAIM_DEBUG_MISC, "jabber", "Sending%s: %s\n", |
7014 | 240 js->gsc ? " (ssl)" : "", data); |
2086 | 241 |
12508 | 242 /* If we've got a security layer, we need to encode the data, |
243 * splitting it on the maximum buffer length negotiated */ | |
244 | |
245 #ifdef HAVE_CYRUS_SASL | |
246 if (js->sasl_maxbuf>0) { | |
247 int pos; | |
248 | |
249 if (!js->gsc && js->fd<0) | |
250 return; | |
251 pos = 0; | |
252 if (len == -1) | |
253 len = strlen(data); | |
254 while (pos < len) { | |
255 int towrite; | |
256 const char *out; | |
257 unsigned olen; | |
258 | |
259 if ((len - pos) < js->sasl_maxbuf) | |
260 towrite = len - pos; | |
261 else | |
262 towrite = js->sasl_maxbuf; | |
263 | |
264 sasl_encode(js->sasl, &data[pos], towrite, &out, &olen); | |
265 pos += towrite; | |
266 | |
13200
33bef17125c2
[gaim-migrate @ 15563]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
13153
diff
changeset
|
267 if (js->writeh != -1) |
33bef17125c2
[gaim-migrate @ 15563]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
13153
diff
changeset
|
268 ret = jabber_do_send(js, out, olen); |
33bef17125c2
[gaim-migrate @ 15563]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
13153
diff
changeset
|
269 else { |
33bef17125c2
[gaim-migrate @ 15563]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
13153
diff
changeset
|
270 ret = -1; |
33bef17125c2
[gaim-migrate @ 15563]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
13153
diff
changeset
|
271 errno = EAGAIN; |
33bef17125c2
[gaim-migrate @ 15563]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
13153
diff
changeset
|
272 } |
33bef17125c2
[gaim-migrate @ 15563]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
13153
diff
changeset
|
273 |
33bef17125c2
[gaim-migrate @ 15563]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
13153
diff
changeset
|
274 if (ret < 0 && errno != EAGAIN) |
12508 | 275 gaim_connection_error(js->gc, _("Write error")); |
13200
33bef17125c2
[gaim-migrate @ 15563]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
13153
diff
changeset
|
276 else if (ret < olen) { |
33bef17125c2
[gaim-migrate @ 15563]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
13153
diff
changeset
|
277 if (ret < 0) |
33bef17125c2
[gaim-migrate @ 15563]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
13153
diff
changeset
|
278 ret = 0; |
33bef17125c2
[gaim-migrate @ 15563]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
13153
diff
changeset
|
279 if (js->writeh == -1) |
33bef17125c2
[gaim-migrate @ 15563]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
13153
diff
changeset
|
280 js->writeh = gaim_input_add( |
33bef17125c2
[gaim-migrate @ 15563]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
13153
diff
changeset
|
281 js->gsc ? js->gsc->fd : js->fd, |
33bef17125c2
[gaim-migrate @ 15563]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
13153
diff
changeset
|
282 GAIM_INPUT_WRITE, |
33bef17125c2
[gaim-migrate @ 15563]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
13153
diff
changeset
|
283 jabber_send_cb, js); |
33bef17125c2
[gaim-migrate @ 15563]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
13153
diff
changeset
|
284 gaim_circ_buffer_append(js->write_buffer, |
33bef17125c2
[gaim-migrate @ 15563]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
13153
diff
changeset
|
285 out + ret, olen - ret); |
33bef17125c2
[gaim-migrate @ 15563]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
13153
diff
changeset
|
286 } |
12508 | 287 } |
288 return; | |
289 } | |
290 #endif | |
13200
33bef17125c2
[gaim-migrate @ 15563]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
13153
diff
changeset
|
291 |
33bef17125c2
[gaim-migrate @ 15563]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
13153
diff
changeset
|
292 if (len == -1) |
33bef17125c2
[gaim-migrate @ 15563]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
13153
diff
changeset
|
293 len = strlen(data); |
33bef17125c2
[gaim-migrate @ 15563]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
13153
diff
changeset
|
294 |
33bef17125c2
[gaim-migrate @ 15563]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
13153
diff
changeset
|
295 if (js->writeh == -1) |
33bef17125c2
[gaim-migrate @ 15563]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
13153
diff
changeset
|
296 ret = jabber_do_send(js, data, len); |
33bef17125c2
[gaim-migrate @ 15563]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
13153
diff
changeset
|
297 else { |
33bef17125c2
[gaim-migrate @ 15563]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
13153
diff
changeset
|
298 ret = -1; |
33bef17125c2
[gaim-migrate @ 15563]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
13153
diff
changeset
|
299 errno = EAGAIN; |
2814
f4f9e5a01890
[gaim-migrate @ 2827]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2800
diff
changeset
|
300 } |
f4f9e5a01890
[gaim-migrate @ 2827]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2800
diff
changeset
|
301 |
13200
33bef17125c2
[gaim-migrate @ 15563]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
13153
diff
changeset
|
302 if (ret < 0 && errno != EAGAIN) |
7014 | 303 gaim_connection_error(js->gc, _("Write error")); |
13200
33bef17125c2
[gaim-migrate @ 15563]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
13153
diff
changeset
|
304 else if (ret < len) { |
33bef17125c2
[gaim-migrate @ 15563]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
13153
diff
changeset
|
305 if (ret < 0) |
33bef17125c2
[gaim-migrate @ 15563]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
13153
diff
changeset
|
306 ret = 0; |
33bef17125c2
[gaim-migrate @ 15563]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
13153
diff
changeset
|
307 if (js->writeh == -1) |
33bef17125c2
[gaim-migrate @ 15563]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
13153
diff
changeset
|
308 js->writeh = gaim_input_add( |
33bef17125c2
[gaim-migrate @ 15563]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
13153
diff
changeset
|
309 js->gsc ? js->gsc->fd : js->fd, |
33bef17125c2
[gaim-migrate @ 15563]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
13153
diff
changeset
|
310 GAIM_INPUT_WRITE, jabber_send_cb, js); |
33bef17125c2
[gaim-migrate @ 15563]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
13153
diff
changeset
|
311 gaim_circ_buffer_append(js->write_buffer, |
33bef17125c2
[gaim-migrate @ 15563]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
13153
diff
changeset
|
312 data + ret, len - ret); |
33bef17125c2
[gaim-migrate @ 15563]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
13153
diff
changeset
|
313 } |
7014 | 314 |
2814
f4f9e5a01890
[gaim-migrate @ 2827]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2800
diff
changeset
|
315 } |
f4f9e5a01890
[gaim-migrate @ 2827]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2800
diff
changeset
|
316 |
7014 | 317 void jabber_send(JabberStream *js, xmlnode *packet) |
2086 | 318 { |
7014 | 319 char *txt; |
7642 | 320 int len; |
2086 | 321 |
7642 | 322 txt = xmlnode_to_str(packet, &len); |
323 jabber_send_raw(js, txt, len); | |
7014 | 324 g_free(txt); |
2086 | 325 } |
326 | |
7014 | 327 static void jabber_keepalive(GaimConnection *gc) |
2086 | 328 { |
7642 | 329 jabber_send_raw(gc->proto_data, "\t", -1); |
2086 | 330 } |
331 | |
7014 | 332 static void |
333 jabber_recv_cb_ssl(gpointer data, GaimSslConnection *gsc, | |
6764 | 334 GaimInputCondition cond) |
335 { | |
7014 | 336 GaimConnection *gc = data; |
337 JabberStream *js = gc->proto_data; | |
6764 | 338 int len; |
7014 | 339 static char buf[4096]; |
6768 | 340 |
7014 | 341 if(!g_list_find(gaim_connections_get_all(), gc)) { |
6768 | 342 gaim_ssl_close(gsc); |
343 return; | |
344 } | |
345 | |
13279
0c50401679d3
[gaim-migrate @ 15645]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
13274
diff
changeset
|
346 while((len = gaim_ssl_read(gsc, buf, sizeof(buf) - 1)) > 0) { |
6764 | 347 buf[len] = '\0'; |
7014 | 348 gaim_debug(GAIM_DEBUG_INFO, "jabber", "Recv (ssl)(%d): %s\n", len, buf); |
349 jabber_parser_process(js, buf, len); | |
13279
0c50401679d3
[gaim-migrate @ 15645]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
13274
diff
changeset
|
350 } |
0c50401679d3
[gaim-migrate @ 15645]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
13274
diff
changeset
|
351 |
0c50401679d3
[gaim-migrate @ 15645]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
13274
diff
changeset
|
352 if(errno == EAGAIN) |
13200
33bef17125c2
[gaim-migrate @ 15563]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
13153
diff
changeset
|
353 return; |
13279
0c50401679d3
[gaim-migrate @ 15645]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
13274
diff
changeset
|
354 else |
7177 | 355 gaim_connection_error(gc, _("Read Error")); |
2086 | 356 } |
357 | |
7014 | 358 static void |
359 jabber_recv_cb(gpointer data, gint source, GaimInputCondition condition) | |
2086 | 360 { |
5572 | 361 GaimConnection *gc = data; |
7014 | 362 JabberStream *js = gc->proto_data; |
363 int len; | |
364 static char buf[4096]; | |
2086 | 365 |
7014 | 366 if(!g_list_find(gaim_connections_get_all(), gc)) |
367 return; | |
2956 | 368 |
7014 | 369 if((len = read(js->fd, buf, sizeof(buf) - 1)) > 0) { |
12508 | 370 #ifdef HAVE_CYRUS_SASL |
371 if (js->sasl_maxbuf>0) { | |
372 const char *out; | |
373 int olen; | |
374 sasl_decode(js->sasl, buf, len, &out, &olen); | |
375 if (olen>0) { | |
376 gaim_debug(GAIM_DEBUG_INFO, "jabber", "RecvSASL (%d): %s\n", olen, out); | |
377 jabber_parser_process(js,out,olen); | |
378 } | |
379 return; | |
380 } | |
381 #endif | |
7014 | 382 buf[len] = '\0'; |
383 gaim_debug(GAIM_DEBUG_INFO, "jabber", "Recv (%d): %s\n", len, buf); | |
384 jabber_parser_process(js, buf, len); | |
13200
33bef17125c2
[gaim-migrate @ 15563]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
13153
diff
changeset
|
385 } else if(errno == EAGAIN) { |
33bef17125c2
[gaim-migrate @ 15563]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
13153
diff
changeset
|
386 return; |
7177 | 387 } else { |
388 gaim_connection_error(gc, _("Read Error")); | |
7014 | 389 } |
2086 | 390 } |
391 | |
7014 | 392 static void |
393 jabber_login_callback_ssl(gpointer data, GaimSslConnection *gsc, | |
6764 | 394 GaimInputCondition cond) |
395 { | |
396 GaimConnection *gc = data; | |
7014 | 397 JabberStream *js = gc->proto_data; |
6764 | 398 |
7014 | 399 if(!g_list_find(gaim_connections_get_all(), gc)) { |
6764 | 400 gaim_ssl_close(gsc); |
401 return; | |
402 } | |
403 | |
7014 | 404 js->gsc = gsc; |
6764 | 405 |
7014 | 406 if(js->state == JABBER_STREAM_CONNECTING) |
7642 | 407 jabber_send_raw(js, "<?xml version='1.0' ?>", -1); |
6764 | 408 |
7014 | 409 jabber_stream_set_state(js, JABBER_STREAM_INITIALIZING); |
410 gaim_ssl_input_add(gsc, jabber_recv_cb_ssl, gc); | |
6764 | 411 } |
412 | |
7014 | 413 |
414 static void | |
415 jabber_login_callback(gpointer data, gint source, GaimInputCondition cond) | |
6764 | 416 { |
5572 | 417 GaimConnection *gc = data; |
7014 | 418 JabberStream *js = gc->proto_data; |
2086 | 419 |
8783 | 420 if (source < 0) { |
421 gaim_connection_error(gc, _("Couldn't connect to host")); | |
422 return; | |
423 } | |
424 | |
7014 | 425 if(!g_list_find(gaim_connections_get_all(), gc)) { |
2086 | 426 close(source); |
427 return; | |
428 } | |
429 | |
7014 | 430 js->fd = source; |
2956 | 431 |
7014 | 432 if(js->state == JABBER_STREAM_CONNECTING) |
7642 | 433 jabber_send_raw(js, "<?xml version='1.0' ?>", -1); |
2300
d2686f757d6e
[gaim-migrate @ 2310]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2289
diff
changeset
|
434 |
7014 | 435 jabber_stream_set_state(js, JABBER_STREAM_INITIALIZING); |
436 gc->inpa = gaim_input_add(js->fd, GAIM_INPUT_READ, jabber_recv_cb, gc); | |
437 } | |
2086 | 438 |
7014 | 439 static void |
7426 | 440 jabber_ssl_connect_failure(GaimSslConnection *gsc, GaimSslErrorType error, |
441 gpointer data) | |
442 { | |
443 GaimConnection *gc = data; | |
8360 | 444 JabberStream *js = gc->proto_data; |
7426 | 445 |
446 switch(error) { | |
8362 | 447 case GAIM_SSL_CONNECT_FAILED: |
448 gaim_connection_error(gc, _("Connection Failed")); | |
449 break; | |
7426 | 450 case GAIM_SSL_HANDSHAKE_FAILED: |
451 gaim_connection_error(gc, _("SSL Handshake Failed")); | |
452 break; | |
453 } | |
8360 | 454 |
455 js->gsc = NULL; | |
7426 | 456 } |
457 | |
7427 | 458 static void tls_init(JabberStream *js) |
459 { | |
460 gaim_input_remove(js->gc->inpa); | |
461 js->gc->inpa = 0; | |
462 js->gsc = gaim_ssl_connect_fd(js->gc->account, js->fd, | |
463 jabber_login_callback_ssl, jabber_ssl_connect_failure, js->gc); | |
464 } | |
465 | |
11387 | 466 static void jabber_login_connect(JabberStream *js, const char *server, int port) |
467 { | |
468 int rc; | |
469 | |
470 rc = gaim_proxy_connect(js->gc->account, server, | |
471 port, jabber_login_callback, js->gc); | |
472 | |
473 if (rc != 0) | |
474 gaim_connection_error(js->gc, _("Unable to create socket")); | |
475 } | |
476 | |
12686
5f65a0cca87c
[gaim-migrate @ 15029]
Richard Laager <rlaager@wiktel.com>
parents:
12658
diff
changeset
|
477 static void srv_resolved_cb(GaimSrvResponse *resp, int results, gpointer data) |
11387 | 478 { |
479 JabberStream *js = (JabberStream*)data; | |
480 | |
481 if(results) { | |
12810
b0ede7907dd0
[gaim-migrate @ 15158]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
12686
diff
changeset
|
482 jabber_login_connect(js, resp->hostname, resp->port); |
11387 | 483 g_free(resp); |
484 } else { | |
12810
b0ede7907dd0
[gaim-migrate @ 15158]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
12686
diff
changeset
|
485 jabber_login_connect(js, js->user->domain, |
b0ede7907dd0
[gaim-migrate @ 15158]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
12686
diff
changeset
|
486 gaim_account_get_int(js->gc->account, "port", 0)); |
11387 | 487 } |
488 } | |
489 | |
490 | |
7427 | 491 |
7426 | 492 static void |
11837 | 493 jabber_login(GaimAccount *account) |
2086 | 494 { |
7014 | 495 GaimConnection *gc = gaim_account_get_connection(account); |
496 const char *connect_server = gaim_account_get_string(account, | |
497 "connect_server", ""); | |
498 JabberStream *js; | |
10289 | 499 JabberBuddy *my_jb = NULL; |
2086 | 500 |
7014 | 501 gc->flags |= GAIM_CONNECTION_HTML; |
502 js = gc->proto_data = g_new0(JabberStream, 1); | |
503 js->gc = gc; | |
8013 | 504 js->fd = -1; |
8312 | 505 js->iq_callbacks = g_hash_table_new_full(g_str_hash, g_str_equal, |
506 g_free, g_free); | |
507 js->disco_callbacks = g_hash_table_new_full(g_str_hash, g_str_equal, | |
7395 | 508 g_free, g_free); |
7014 | 509 js->buddies = g_hash_table_new_full(g_str_hash, g_str_equal, |
7116 | 510 g_free, (GDestroyNotify)jabber_buddy_free); |
7014 | 511 js->chats = g_hash_table_new_full(g_str_hash, g_str_equal, |
8396 | 512 g_free, (GDestroyNotify)jabber_chat_free); |
8043 | 513 js->chat_servers = g_list_append(NULL, g_strdup("conference.jabber.org")); |
7014 | 514 js->user = jabber_id_new(gaim_account_get_username(account)); |
7322 | 515 js->next_id = g_random_int(); |
13200
33bef17125c2
[gaim-migrate @ 15563]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
13153
diff
changeset
|
516 js->write_buffer = gaim_circ_buffer_new(512); |
33bef17125c2
[gaim-migrate @ 15563]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
13153
diff
changeset
|
517 js->writeh = -1; |
5613 | 518 |
7310 | 519 if(!js->user) { |
520 gaim_connection_error(gc, _("Invalid Jabber ID")); | |
521 return; | |
522 } | |
523 | |
7147 | 524 if(!js->user->resource) { |
525 char *me; | |
11939
85c25a32bb48
[gaim-migrate @ 14230]
Etan Reisner <pidgin@unreliablesource.net>
parents:
11837
diff
changeset
|
526 js->user->resource = g_strdup("Home"); |
7147 | 527 if(!js->user->node) { |
528 js->user->node = js->user->domain; | |
529 js->user->domain = g_strdup("jabber.org"); | |
530 } | |
531 me = g_strdup_printf("%s@%s/%s", js->user->node, js->user->domain, | |
532 js->user->resource); | |
533 gaim_account_set_username(account, me); | |
534 g_free(me); | |
7145 | 535 } |
536 | |
10289 | 537 if((my_jb = jabber_buddy_find(js, gaim_account_get_username(account), TRUE))) |
538 my_jb->subscription |= JABBER_SUB_BOTH; | |
539 | |
7014 | 540 jabber_stream_set_state(js, JABBER_STREAM_CONNECTING); |
2956 | 541 |
11387 | 542 /* if they've got old-ssl mode going, we probably want to ignore SRV lookups */ |
543 if(gaim_account_get_bool(js->gc->account, "old_ssl", FALSE)) { | |
7630 | 544 if(gaim_ssl_is_supported()) { |
11387 | 545 js->gsc = gaim_ssl_connect(js->gc->account, |
546 connect_server[0] ? connect_server : js->user->domain, | |
547 gaim_account_get_int(account, "port", 5223), jabber_login_callback_ssl, | |
548 jabber_ssl_connect_failure, js->gc); | |
7630 | 549 } else { |
11387 | 550 gaim_connection_error(js->gc, _("SSL support unavailable")); |
7630 | 551 } |
3311 | 552 } |
3770 | 553 |
11387 | 554 /* no old-ssl, so if they've specified a connect server, we'll use that, otherwise we'll |
555 * invoke the magic of SRV lookups, to figure out host and port */ | |
7014 | 556 if(!js->gsc) { |
11387 | 557 if(connect_server[0]) { |
558 jabber_login_connect(js, connect_server, gaim_account_get_int(account, "port", 5222)); | |
559 } else { | |
560 gaim_srv_resolve("xmpp-client", "tcp", js->user->domain, srv_resolved_cb, js); | |
561 } | |
2956 | 562 } |
2086 | 563 } |
564 | |
11387 | 565 |
7072 | 566 static gboolean |
567 conn_close_cb(gpointer data) | |
568 { | |
569 JabberStream *js = data; | |
10740 | 570 GaimAccount *account = gaim_connection_get_account(js->gc); |
571 | |
572 gaim_account_disconnect(account); | |
573 | |
7072 | 574 return FALSE; |
575 } | |
576 | |
577 static void | |
578 jabber_connection_schedule_close(JabberStream *js) | |
579 { | |
8273
f24172f53650
[gaim-migrate @ 8997]
Christian Hammond <chipx86@chipx86.com>
parents:
8194
diff
changeset
|
580 gaim_timeout_add(0, conn_close_cb, js); |
7072 | 581 } |
582 | |
583 static void | |
7395 | 584 jabber_registration_result_cb(JabberStream *js, xmlnode *packet, gpointer data) |
7072 | 585 { |
586 const char *type = xmlnode_get_attrib(packet, "type"); | |
587 char *buf; | |
588 | |
589 if(!strcmp(type, "result")) { | |
590 buf = g_strdup_printf(_("Registration of %s@%s successful"), | |
591 js->user->node, js->user->domain); | |
592 gaim_notify_info(NULL, _("Registration Successful"), | |
593 _("Registration Successful"), buf); | |
594 g_free(buf); | |
595 } else { | |
8401 | 596 char *msg = jabber_parse_error(js, packet); |
7072 | 597 |
8401 | 598 if(!msg) |
599 msg = g_strdup(_("Unknown Error")); | |
7072 | 600 |
601 gaim_notify_error(NULL, _("Registration Failed"), | |
8401 | 602 _("Registration Failed"), msg); |
603 g_free(msg); | |
7072 | 604 } |
605 jabber_connection_schedule_close(js); | |
606 } | |
607 | |
608 static void | |
609 jabber_register_cb(JabberStream *js, GaimRequestFields *fields) | |
610 { | |
611 GList *groups, *flds; | |
612 xmlnode *query, *y; | |
613 JabberIq *iq; | |
7264 | 614 char *username; |
7072 | 615 |
616 iq = jabber_iq_new_query(js, JABBER_IQ_SET, "jabber:iq:register"); | |
617 query = xmlnode_get_child(iq->node, "query"); | |
618 | |
619 for(groups = gaim_request_fields_get_groups(fields); groups; | |
620 groups = groups->next) { | |
621 for(flds = gaim_request_field_group_get_fields(groups->data); | |
622 flds; flds = flds->next) { | |
623 GaimRequestField *field = flds->data; | |
624 const char *id = gaim_request_field_get_id(field); | |
625 const char *value = gaim_request_field_string_get_value(field); | |
626 | |
627 if(!strcmp(id, "username")) { | |
628 y = xmlnode_new_child(query, "username"); | |
629 } else if(!strcmp(id, "password")) { | |
630 y = xmlnode_new_child(query, "password"); | |
631 } else if(!strcmp(id, "name")) { | |
632 y = xmlnode_new_child(query, "name"); | |
633 } else if(!strcmp(id, "email")) { | |
634 y = xmlnode_new_child(query, "email"); | |
635 } else if(!strcmp(id, "nick")) { | |
636 y = xmlnode_new_child(query, "nick"); | |
637 } else if(!strcmp(id, "first")) { | |
638 y = xmlnode_new_child(query, "first"); | |
639 } else if(!strcmp(id, "last")) { | |
640 y = xmlnode_new_child(query, "last"); | |
641 } else if(!strcmp(id, "address")) { | |
642 y = xmlnode_new_child(query, "address"); | |
643 } else if(!strcmp(id, "city")) { | |
644 y = xmlnode_new_child(query, "city"); | |
645 } else if(!strcmp(id, "state")) { | |
646 y = xmlnode_new_child(query, "state"); | |
647 } else if(!strcmp(id, "zip")) { | |
648 y = xmlnode_new_child(query, "zip"); | |
649 } else if(!strcmp(id, "phone")) { | |
650 y = xmlnode_new_child(query, "phone"); | |
651 } else if(!strcmp(id, "url")) { | |
652 y = xmlnode_new_child(query, "url"); | |
653 } else if(!strcmp(id, "date")) { | |
654 y = xmlnode_new_child(query, "date"); | |
655 } else { | |
656 continue; | |
657 } | |
658 xmlnode_insert_data(y, value, -1); | |
7264 | 659 if(!strcmp(id, "username")) { |
660 if(js->user->node) | |
661 g_free(js->user->node); | |
662 js->user->node = g_strdup(value); | |
663 } | |
7072 | 664 } |
665 } | |
666 | |
7264 | 667 username = g_strdup_printf("%s@%s/%s", js->user->node, js->user->domain, |
668 js->user->resource); | |
669 gaim_account_set_username(js->gc->account, username); | |
670 g_free(username); | |
671 | |
7395 | 672 jabber_iq_set_callback(iq, jabber_registration_result_cb, NULL); |
7072 | 673 |
674 jabber_iq_send(iq); | |
675 | |
676 } | |
677 | |
678 static void | |
679 jabber_register_cancel_cb(JabberStream *js, GaimRequestFields *fields) | |
680 { | |
681 jabber_connection_schedule_close(js); | |
682 } | |
683 | |
7923 | 684 static void jabber_register_x_data_cb(JabberStream *js, xmlnode *result, gpointer data) |
685 { | |
686 xmlnode *query; | |
687 JabberIq *iq; | |
688 | |
689 iq = jabber_iq_new_query(js, JABBER_IQ_SET, "jabber:iq:register"); | |
690 query = xmlnode_get_child(iq->node, "query"); | |
691 | |
692 xmlnode_insert_child(query, result); | |
693 | |
694 jabber_iq_set_callback(iq, jabber_registration_result_cb, NULL); | |
695 jabber_iq_send(iq); | |
696 } | |
697 | |
7072 | 698 void jabber_register_parse(JabberStream *js, xmlnode *packet) |
699 { | |
700 if(js->registration) { | |
701 GaimRequestFields *fields; | |
702 GaimRequestFieldGroup *group; | |
703 GaimRequestField *field; | |
7923 | 704 xmlnode *query, *x, *y; |
7072 | 705 char *instructions; |
706 | |
707 /* get rid of the login thingy */ | |
708 gaim_connection_set_state(js->gc, GAIM_CONNECTED); | |
709 | |
710 query = xmlnode_get_child(packet, "query"); | |
711 | |
712 if(xmlnode_get_child(query, "registered")) { | |
713 gaim_notify_error(NULL, _("Already Registered"), | |
714 _("Already Registered"), NULL); | |
715 jabber_connection_schedule_close(js); | |
716 return; | |
717 } | |
718 | |
8398 | 719 if((x = xmlnode_get_child_with_namespace(packet, "x", |
720 "jabber:x:data"))) { | |
721 jabber_x_data_request(js, x, jabber_register_x_data_cb, NULL); | |
722 return; | |
723 } else if((x = xmlnode_get_child_with_namespace(packet, "x", | |
724 "jabber:x:oob"))) { | |
725 xmlnode *url; | |
7923 | 726 |
8398 | 727 if((url = xmlnode_get_child(x, "url"))) { |
728 char *href; | |
729 if((href = xmlnode_get_data(url))) { | |
10240
95ca0db2d01d
[gaim-migrate @ 11377]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
10216
diff
changeset
|
730 gaim_notify_uri(NULL, href); |
8398 | 731 g_free(href); |
732 js->gc->wants_to_die = TRUE; | |
733 jabber_connection_schedule_close(js); | |
734 return; | |
735 } | |
7923 | 736 } |
737 } | |
738 | |
739 /* as a last resort, use the old jabber:iq:register syntax */ | |
740 | |
7072 | 741 fields = gaim_request_fields_new(); |
742 group = gaim_request_field_group_new(NULL); | |
743 gaim_request_fields_add_group(fields, group); | |
744 | |
745 field = gaim_request_field_string_new("username", _("Username"), | |
746 js->user->node, FALSE); | |
747 gaim_request_field_group_add_field(group, field); | |
748 | |
749 field = gaim_request_field_string_new("password", _("Password"), | |
10740 | 750 gaim_connection_get_password(js->gc), FALSE); |
7072 | 751 gaim_request_field_string_set_masked(field, TRUE); |
752 gaim_request_field_group_add_field(group, field); | |
753 | |
754 if(xmlnode_get_child(query, "name")) { | |
755 field = gaim_request_field_string_new("name", _("Name"), | |
756 gaim_account_get_alias(js->gc->account), FALSE); | |
757 gaim_request_field_group_add_field(group, field); | |
758 } | |
759 if(xmlnode_get_child(query, "email")) { | |
760 field = gaim_request_field_string_new("email", _("E-Mail"), | |
761 NULL, FALSE); | |
762 gaim_request_field_group_add_field(group, field); | |
763 } | |
764 if(xmlnode_get_child(query, "nick")) { | |
765 field = gaim_request_field_string_new("nick", _("Nickname"), | |
766 NULL, FALSE); | |
767 gaim_request_field_group_add_field(group, field); | |
768 } | |
769 if(xmlnode_get_child(query, "first")) { | |
770 field = gaim_request_field_string_new("first", _("First Name"), | |
771 NULL, FALSE); | |
772 gaim_request_field_group_add_field(group, field); | |
773 } | |
774 if(xmlnode_get_child(query, "last")) { | |
775 field = gaim_request_field_string_new("last", _("Last Name"), | |
776 NULL, FALSE); | |
777 gaim_request_field_group_add_field(group, field); | |
778 } | |
779 if(xmlnode_get_child(query, "address")) { | |
780 field = gaim_request_field_string_new("address", _("Address"), | |
781 NULL, FALSE); | |
782 gaim_request_field_group_add_field(group, field); | |
783 } | |
784 if(xmlnode_get_child(query, "city")) { | |
785 field = gaim_request_field_string_new("city", _("City"), | |
786 NULL, FALSE); | |
787 gaim_request_field_group_add_field(group, field); | |
788 } | |
789 if(xmlnode_get_child(query, "state")) { | |
790 field = gaim_request_field_string_new("state", _("State"), | |
791 NULL, FALSE); | |
792 gaim_request_field_group_add_field(group, field); | |
793 } | |
794 if(xmlnode_get_child(query, "zip")) { | |
795 field = gaim_request_field_string_new("zip", _("Postal Code"), | |
796 NULL, FALSE); | |
797 gaim_request_field_group_add_field(group, field); | |
798 } | |
799 if(xmlnode_get_child(query, "phone")) { | |
800 field = gaim_request_field_string_new("phone", _("Phone"), | |
801 NULL, FALSE); | |
802 gaim_request_field_group_add_field(group, field); | |
803 } | |
804 if(xmlnode_get_child(query, "url")) { | |
805 field = gaim_request_field_string_new("url", _("URL"), | |
806 NULL, FALSE); | |
807 gaim_request_field_group_add_field(group, field); | |
808 } | |
809 if(xmlnode_get_child(query, "date")) { | |
810 field = gaim_request_field_string_new("date", _("Date"), | |
811 NULL, FALSE); | |
812 gaim_request_field_group_add_field(group, field); | |
813 } | |
814 | |
815 if((y = xmlnode_get_child(query, "instructions"))) | |
816 instructions = xmlnode_get_data(y); | |
817 else | |
818 instructions = g_strdup(_("Please fill out the information below " | |
819 "to register your new account.")); | |
820 | |
821 gaim_request_fields(js->gc, _("Register New Jabber Account"), | |
822 _("Register New Jabber Account"), instructions, fields, | |
823 _("Register"), G_CALLBACK(jabber_register_cb), | |
824 _("Cancel"), G_CALLBACK(jabber_register_cancel_cb), js); | |
825 } | |
826 } | |
827 | |
8016 | 828 void jabber_register_start(JabberStream *js) |
7072 | 829 { |
830 JabberIq *iq; | |
831 | |
832 iq = jabber_iq_new_query(js, JABBER_IQ_GET, "jabber:iq:register"); | |
833 jabber_iq_send(iq); | |
834 } | |
835 | |
836 static void jabber_register_account(GaimAccount *account) | |
837 { | |
838 GaimConnection *gc = gaim_account_get_connection(account); | |
839 JabberStream *js; | |
10289 | 840 JabberBuddy *my_jb = NULL; |
7072 | 841 const char *connect_server = gaim_account_get_string(account, |
842 "connect_server", ""); | |
843 const char *server; | |
844 int rc; | |
845 | |
846 js = gc->proto_data = g_new0(JabberStream, 1); | |
847 js->gc = gc; | |
848 js->registration = TRUE; | |
8312 | 849 js->iq_callbacks = g_hash_table_new_full(g_str_hash, g_str_equal, |
850 g_free, g_free); | |
851 js->disco_callbacks = g_hash_table_new_full(g_str_hash, g_str_equal, | |
7395 | 852 g_free, g_free); |
7072 | 853 js->user = jabber_id_new(gaim_account_get_username(account)); |
7322 | 854 js->next_id = g_random_int(); |
7072 | 855 |
7310 | 856 if(!js->user) { |
857 gaim_connection_error(gc, _("Invalid Jabber ID")); | |
858 return; | |
859 } | |
860 | |
13200
33bef17125c2
[gaim-migrate @ 15563]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
13153
diff
changeset
|
861 js->write_buffer = gaim_circ_buffer_new(512); |
33bef17125c2
[gaim-migrate @ 15563]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
13153
diff
changeset
|
862 js->writeh = -1; |
33bef17125c2
[gaim-migrate @ 15563]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
13153
diff
changeset
|
863 |
7147 | 864 if(!js->user->resource) { |
865 char *me; | |
11939
85c25a32bb48
[gaim-migrate @ 14230]
Etan Reisner <pidgin@unreliablesource.net>
parents:
11837
diff
changeset
|
866 js->user->resource = g_strdup("Home"); |
7147 | 867 if(!js->user->node) { |
868 js->user->node = js->user->domain; | |
869 js->user->domain = g_strdup("jabber.org"); | |
870 } | |
871 me = g_strdup_printf("%s@%s/%s", js->user->node, js->user->domain, | |
872 js->user->resource); | |
873 gaim_account_set_username(account, me); | |
874 g_free(me); | |
875 } | |
876 | |
10289 | 877 if((my_jb = jabber_buddy_find(js, gaim_account_get_username(account), TRUE))) |
878 my_jb->subscription |= JABBER_SUB_BOTH; | |
879 | |
7072 | 880 server = connect_server[0] ? connect_server : js->user->domain; |
881 | |
882 jabber_stream_set_state(js, JABBER_STREAM_CONNECTING); | |
883 | |
7630 | 884 if(gaim_account_get_bool(account, "old_ssl", FALSE)) { |
885 if(gaim_ssl_is_supported()) { | |
886 js->gsc = gaim_ssl_connect(account, server, | |
887 gaim_account_get_int(account, "port", 5222), | |
888 jabber_login_callback_ssl, jabber_ssl_connect_failure, gc); | |
889 } else { | |
890 gaim_connection_error(gc, _("SSL support unavailable")); | |
891 } | |
7072 | 892 } |
893 | |
894 if(!js->gsc) { | |
895 rc = gaim_proxy_connect(account, server, | |
896 gaim_account_get_int(account, "port", 5222), | |
897 jabber_login_callback, gc); | |
898 | |
899 if (rc != 0) | |
900 gaim_connection_error(gc, _("Unable to create socket")); | |
901 } | |
902 } | |
903 | |
5572 | 904 static void jabber_close(GaimConnection *gc) |
2086 | 905 { |
7014 | 906 JabberStream *js = gc->proto_data; |
2956 | 907 |
13274
6ae034aa4485
[gaim-migrate @ 15640]
Richard Laager <rlaager@wiktel.com>
parents:
13242
diff
changeset
|
908 /* This is for Adium. Gaim never uses OpenSSL, because of licensing issues, |
6ae034aa4485
[gaim-migrate @ 15640]
Richard Laager <rlaager@wiktel.com>
parents:
13242
diff
changeset
|
909 * and our configure doesn't check for it. -- rlaager */ |
13242
cdd107258f11
[gaim-migrate @ 15608]
Evan Schoenberg <evan.s@dreskin.net>
parents:
13237
diff
changeset
|
910 #ifdef HAVE_OPENSSL |
13274
6ae034aa4485
[gaim-migrate @ 15640]
Richard Laager <rlaager@wiktel.com>
parents:
13242
diff
changeset
|
911 /* If using OpenSSL, don't perform any actions on the ssl connection |
6ae034aa4485
[gaim-migrate @ 15640]
Richard Laager <rlaager@wiktel.com>
parents:
13242
diff
changeset
|
912 * if we were forcibly disconnected because it will crash. -- evands |
13153
caee920323e2
[gaim-migrate @ 15516]
Evan Schoenberg <evan.s@dreskin.net>
parents:
13051
diff
changeset
|
913 */ |
caee920323e2
[gaim-migrate @ 15516]
Evan Schoenberg <evan.s@dreskin.net>
parents:
13051
diff
changeset
|
914 if (!gc->disconnect_timeout) |
13384 | 915 #endif |
13242
cdd107258f11
[gaim-migrate @ 15608]
Evan Schoenberg <evan.s@dreskin.net>
parents:
13237
diff
changeset
|
916 jabber_send_raw(js, "</stream:stream>", -1); |
3311 | 917 |
7014 | 918 if(js->gsc) { |
13242
cdd107258f11
[gaim-migrate @ 15608]
Evan Schoenberg <evan.s@dreskin.net>
parents:
13237
diff
changeset
|
919 #ifdef HAVE_OPENSSL |
cdd107258f11
[gaim-migrate @ 15608]
Evan Schoenberg <evan.s@dreskin.net>
parents:
13237
diff
changeset
|
920 if (!gc->disconnect_timeout) |
13384 | 921 #endif |
13242
cdd107258f11
[gaim-migrate @ 15608]
Evan Schoenberg <evan.s@dreskin.net>
parents:
13237
diff
changeset
|
922 gaim_ssl_close(js->gsc); |
8360 | 923 } else if (js->fd > 0) { |
7072 | 924 if(js->gc->inpa) |
925 gaim_input_remove(js->gc->inpa); | |
7014 | 926 close(js->fd); |
927 } | |
3311 | 928 |
7587 | 929 if(js->context) |
930 g_markup_parse_context_free(js->context); | |
8312 | 931 if(js->iq_callbacks) |
932 g_hash_table_destroy(js->iq_callbacks); | |
933 if(js->disco_callbacks) | |
934 g_hash_table_destroy(js->disco_callbacks); | |
7072 | 935 if(js->buddies) |
936 g_hash_table_destroy(js->buddies); | |
937 if(js->chats) | |
938 g_hash_table_destroy(js->chats); | |
8043 | 939 while(js->chat_servers) { |
940 g_free(js->chat_servers->data); | |
941 js->chat_servers = g_list_delete_link(js->chat_servers, js->chat_servers); | |
942 } | |
11675 | 943 while(js->user_directories) { |
944 g_free(js->user_directories->data); | |
945 js->user_directories = g_list_delete_link(js->user_directories, js->user_directories); | |
946 } | |
7014 | 947 if(js->stream_id) |
948 g_free(js->stream_id); | |
7587 | 949 if(js->user) |
950 jabber_id_free(js->user); | |
10189 | 951 if(js->avatar_hash) |
952 g_free(js->avatar_hash); | |
13200
33bef17125c2
[gaim-migrate @ 15563]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
13153
diff
changeset
|
953 gaim_circ_buffer_destroy(js->write_buffer); |
33bef17125c2
[gaim-migrate @ 15563]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
13153
diff
changeset
|
954 if(js->writeh) |
33bef17125c2
[gaim-migrate @ 15563]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
13153
diff
changeset
|
955 gaim_input_remove(js->writeh); |
12508 | 956 #ifdef HAVE_CYRUS_SASL |
957 if(js->sasl) | |
958 sasl_dispose(&js->sasl); | |
959 if(js->sasl_mechs) | |
960 g_string_free(js->sasl_mechs, TRUE); | |
961 if(js->sasl_cb) | |
962 g_free(js->sasl_cb); | |
963 #endif | |
7014 | 964 g_free(js); |
11389 | 965 |
966 gc->proto_data = NULL; | |
5093 | 967 } |
968 | |
7014 | 969 void jabber_stream_set_state(JabberStream *js, JabberStreamState state) |
3105 | 970 { |
9954 | 971 GaimPresence *gpresence; |
972 GaimStatus *status; | |
973 | |
7014 | 974 js->state = state; |
975 switch(state) { | |
976 case JABBER_STREAM_OFFLINE: | |
977 break; | |
978 case JABBER_STREAM_CONNECTING: | |
979 gaim_connection_update_progress(js->gc, _("Connecting"), 1, | |
980 JABBER_CONNECT_STEPS); | |
981 break; | |
982 case JABBER_STREAM_INITIALIZING: | |
983 gaim_connection_update_progress(js->gc, _("Initializing Stream"), | |
984 js->gsc ? 5 : 2, JABBER_CONNECT_STEPS); | |
985 jabber_stream_init(js); | |
986 jabber_parser_setup(js); | |
987 break; | |
988 case JABBER_STREAM_AUTHENTICATING: | |
989 gaim_connection_update_progress(js->gc, _("Authenticating"), | |
990 js->gsc ? 6 : 3, JABBER_CONNECT_STEPS); | |
8296 | 991 if(js->protocol_version == JABBER_PROTO_0_9 && js->registration) { |
992 jabber_register_start(js); | |
993 } else if(js->auth_type == JABBER_AUTH_IQ_AUTH) { | |
994 jabber_auth_start_old(js); | |
8016 | 995 } |
7014 | 996 break; |
997 case JABBER_STREAM_REINITIALIZING: | |
998 gaim_connection_update_progress(js->gc, _("Re-initializing Stream"), | |
999 6, JABBER_CONNECT_STEPS); | |
1000 jabber_stream_init(js); | |
1001 break; | |
1002 case JABBER_STREAM_CONNECTED: | |
1003 jabber_roster_request(js); | |
9954 | 1004 gpresence = gaim_account_get_presence(js->gc->account); |
1005 status = gaim_presence_get_active_status(gpresence); | |
10216 | 1006 jabber_presence_send(js->gc->account, status); |
10941 | 1007 gaim_connection_set_state(js->gc, GAIM_CONNECTED); |
8312 | 1008 jabber_disco_items_server(js); |
7014 | 1009 break; |
3105 | 1010 } |
1011 } | |
1012 | |
7014 | 1013 char *jabber_get_next_id(JabberStream *js) |
2086 | 1014 { |
7322 | 1015 return g_strdup_printf("gaim%x", js->next_id++); |
2086 | 1016 } |
1017 | |
7923 | 1018 |
1019 static void jabber_idle_set(GaimConnection *gc, int idle) | |
3340 | 1020 { |
7014 | 1021 JabberStream *js = gc->proto_data; |
3340 | 1022 |
7014 | 1023 js->idle = idle ? time(NULL) - idle : idle; |
3314 | 1024 } |
1025 | |
6695 | 1026 static const char *jabber_list_icon(GaimAccount *a, GaimBuddy *b) |
2086 | 1027 { |
4687 | 1028 return "jabber"; |
1029 } | |
4916 | 1030 |
9954 | 1031 static void jabber_list_emblems(GaimBuddy *b, const char **se, const char **sw, |
1032 const char **nw, const char **ne) | |
4916 | 1033 { |
7014 | 1034 JabberStream *js; |
13485
9ad3d85fffeb
[gaim-migrate @ 15861]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
13384
diff
changeset
|
1035 JabberBuddy *jb = NULL; |
7014 | 1036 |
1037 if(!b->account->gc) | |
1038 return; | |
1039 js = b->account->gc->proto_data; | |
13485
9ad3d85fffeb
[gaim-migrate @ 15861]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
13384
diff
changeset
|
1040 if(js) |
9ad3d85fffeb
[gaim-migrate @ 15861]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
13384
diff
changeset
|
1041 jb = jabber_buddy_find(js, b->name, FALSE); |
5135 | 1042 |
1043 if(!GAIM_BUDDY_IS_ONLINE(b)) { | |
7014 | 1044 if(jb && jb->error_msg) |
4927 | 1045 *nw = "error"; |
5135 | 1046 |
7014 | 1047 if(jb && (jb->subscription & JABBER_SUB_PENDING || |
1048 !(jb->subscription & JABBER_SUB_TO))) | |
5135 | 1049 *se = "notauthorized"; |
1050 else | |
1051 *se = "offline"; | |
4916 | 1052 } else { |
9954 | 1053 GaimStatusType *status_type = gaim_status_get_type(gaim_presence_get_active_status(gaim_buddy_get_presence(b))); |
12595
3169cd6727ad
[gaim-migrate @ 14925]
Richard Laager <rlaager@wiktel.com>
parents:
12554
diff
changeset
|
1054 GaimStatusPrimitive primitive = gaim_status_type_get_primitive(status_type); |
9954 | 1055 |
12595
3169cd6727ad
[gaim-migrate @ 14925]
Richard Laager <rlaager@wiktel.com>
parents:
12554
diff
changeset
|
1056 if(primitive > GAIM_STATUS_AVAILABLE) { |
9954 | 1057 *se = gaim_status_type_get_id(status_type); |
4916 | 1058 } |
2086 | 1059 } |
4916 | 1060 } |
2086 | 1061 |
7014 | 1062 static char *jabber_status_text(GaimBuddy *b) |
2205
cff4fbe01c7b
[gaim-migrate @ 2215]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2170
diff
changeset
|
1063 { |
7014 | 1064 JabberBuddy *jb = jabber_buddy_find(b->account->gc->proto_data, b->name, |
1065 FALSE); | |
1066 char *ret = NULL; | |
5234 | 1067 |
7014 | 1068 if(jb && !GAIM_BUDDY_IS_ONLINE(b) && (jb->subscription & JABBER_SUB_PENDING || !(jb->subscription & JABBER_SUB_TO))) { |
1069 ret = g_strdup(_("Not Authorized")); | |
1070 } else if(jb && !GAIM_BUDDY_IS_ONLINE(b) && jb->error_msg) { | |
1071 ret = g_strdup(jb->error_msg); | |
2956 | 1072 } else { |
7095
c8bf2da398e3
[gaim-migrate @ 7660]
Christian Hammond <chipx86@chipx86.com>
parents:
7072
diff
changeset
|
1073 char *stripped; |
c8bf2da398e3
[gaim-migrate @ 7660]
Christian Hammond <chipx86@chipx86.com>
parents:
7072
diff
changeset
|
1074 |
9954 | 1075 if(!(stripped = gaim_markup_strip_html(jabber_buddy_get_status_msg(jb)))) { |
1076 GaimStatus *status = gaim_presence_get_active_status(gaim_buddy_get_presence(b)); | |
2956 | 1077 |
9954 | 1078 if(!gaim_status_is_available(status)) |
1079 stripped = g_strdup(gaim_status_get_name(status)); | |
1080 } | |
2086 | 1081 |
7014 | 1082 if(stripped) { |
1083 ret = g_markup_escape_text(stripped, -1); | |
1084 g_free(stripped); | |
1085 } | |
2086 | 1086 } |
1087 | |
7014 | 1088 return ret; |
2956 | 1089 } |
1090 | |
12970
ec9b92104904
[gaim-migrate @ 15323]
Richard Laager <rlaager@wiktel.com>
parents:
12948
diff
changeset
|
1091 static void jabber_tooltip_text(GaimBuddy *b, GString *str, gboolean full) |
4744 | 1092 { |
11609 | 1093 JabberBuddy *jb; |
1094 | |
12970
ec9b92104904
[gaim-migrate @ 15323]
Richard Laager <rlaager@wiktel.com>
parents:
12948
diff
changeset
|
1095 g_return_if_fail(b != NULL); |
ec9b92104904
[gaim-migrate @ 15323]
Richard Laager <rlaager@wiktel.com>
parents:
12948
diff
changeset
|
1096 g_return_if_fail(b->account != NULL); |
ec9b92104904
[gaim-migrate @ 15323]
Richard Laager <rlaager@wiktel.com>
parents:
12948
diff
changeset
|
1097 g_return_if_fail(b->account->gc != NULL); |
ec9b92104904
[gaim-migrate @ 15323]
Richard Laager <rlaager@wiktel.com>
parents:
12948
diff
changeset
|
1098 g_return_if_fail(b->account->gc->proto_data != NULL); |
11609 | 1099 |
1100 jb = jabber_buddy_find(b->account->gc->proto_data, b->name, | |
7014 | 1101 FALSE); |
1102 | |
8194 | 1103 if(jb) { |
11609 | 1104 JabberBuddyResource *jbr = NULL; |
8194 | 1105 const char *sub; |
11609 | 1106 GList *l; |
1107 | |
12948
563fb4f1e9fc
[gaim-migrate @ 15301]
Richard Laager <rlaager@wiktel.com>
parents:
12944
diff
changeset
|
1108 if (full) { |
563fb4f1e9fc
[gaim-migrate @ 15301]
Richard Laager <rlaager@wiktel.com>
parents:
12944
diff
changeset
|
1109 if(jb->subscription & JABBER_SUB_FROM) { |
563fb4f1e9fc
[gaim-migrate @ 15301]
Richard Laager <rlaager@wiktel.com>
parents:
12944
diff
changeset
|
1110 if(jb->subscription & JABBER_SUB_TO) |
563fb4f1e9fc
[gaim-migrate @ 15301]
Richard Laager <rlaager@wiktel.com>
parents:
12944
diff
changeset
|
1111 sub = _("Both"); |
563fb4f1e9fc
[gaim-migrate @ 15301]
Richard Laager <rlaager@wiktel.com>
parents:
12944
diff
changeset
|
1112 else if(jb->subscription & JABBER_SUB_PENDING) |
563fb4f1e9fc
[gaim-migrate @ 15301]
Richard Laager <rlaager@wiktel.com>
parents:
12944
diff
changeset
|
1113 sub = _("From (To pending)"); |
563fb4f1e9fc
[gaim-migrate @ 15301]
Richard Laager <rlaager@wiktel.com>
parents:
12944
diff
changeset
|
1114 else |
563fb4f1e9fc
[gaim-migrate @ 15301]
Richard Laager <rlaager@wiktel.com>
parents:
12944
diff
changeset
|
1115 sub = _("From"); |
563fb4f1e9fc
[gaim-migrate @ 15301]
Richard Laager <rlaager@wiktel.com>
parents:
12944
diff
changeset
|
1116 } else { |
563fb4f1e9fc
[gaim-migrate @ 15301]
Richard Laager <rlaager@wiktel.com>
parents:
12944
diff
changeset
|
1117 if(jb->subscription & JABBER_SUB_TO) |
563fb4f1e9fc
[gaim-migrate @ 15301]
Richard Laager <rlaager@wiktel.com>
parents:
12944
diff
changeset
|
1118 sub = _("To"); |
563fb4f1e9fc
[gaim-migrate @ 15301]
Richard Laager <rlaager@wiktel.com>
parents:
12944
diff
changeset
|
1119 else if(jb->subscription & JABBER_SUB_PENDING) |
563fb4f1e9fc
[gaim-migrate @ 15301]
Richard Laager <rlaager@wiktel.com>
parents:
12944
diff
changeset
|
1120 sub = _("None (To pending)"); |
563fb4f1e9fc
[gaim-migrate @ 15301]
Richard Laager <rlaager@wiktel.com>
parents:
12944
diff
changeset
|
1121 else |
563fb4f1e9fc
[gaim-migrate @ 15301]
Richard Laager <rlaager@wiktel.com>
parents:
12944
diff
changeset
|
1122 sub = _("None"); |
563fb4f1e9fc
[gaim-migrate @ 15301]
Richard Laager <rlaager@wiktel.com>
parents:
12944
diff
changeset
|
1123 } |
12970
ec9b92104904
[gaim-migrate @ 15323]
Richard Laager <rlaager@wiktel.com>
parents:
12948
diff
changeset
|
1124 g_string_append_printf(str, "\n<b>%s:</b> %s", _("Subscription"), sub); |
8194 | 1125 } |
1126 | |
11609 | 1127 for(l=jb->resources; l; l = l->next) { |
8194 | 1128 char *text = NULL; |
11609 | 1129 char *res = NULL; |
12944
07eaae27e674
[gaim-migrate @ 15297]
Richard Laager <rlaager@wiktel.com>
parents:
12943
diff
changeset
|
1130 const char *state; |
11609 | 1131 |
1132 jbr = l->data; | |
1133 | |
8194 | 1134 if(jbr->status) { |
11646 | 1135 char *tmp; |
1136 text = gaim_strreplace(jbr->status, "\n", "<br />\n"); | |
1137 tmp = gaim_markup_strip_html(text); | |
1138 g_free(text); | |
1139 text = g_markup_escape_text(tmp, -1); | |
1140 g_free(tmp); | |
8194 | 1141 } |
1142 | |
11609 | 1143 if(jbr->name) |
11610 | 1144 res = g_strdup_printf(" (%s)", jbr->name); |
11609 | 1145 |
12944
07eaae27e674
[gaim-migrate @ 15297]
Richard Laager <rlaager@wiktel.com>
parents:
12943
diff
changeset
|
1146 state = jabber_buddy_state_get_name(jbr->state); |
07eaae27e674
[gaim-migrate @ 15297]
Richard Laager <rlaager@wiktel.com>
parents:
12943
diff
changeset
|
1147 if (text != NULL && !gaim_utf8_strcasecmp(state, text)) { |
07eaae27e674
[gaim-migrate @ 15297]
Richard Laager <rlaager@wiktel.com>
parents:
12943
diff
changeset
|
1148 g_free(text); |
07eaae27e674
[gaim-migrate @ 15297]
Richard Laager <rlaager@wiktel.com>
parents:
12943
diff
changeset
|
1149 text = NULL; |
07eaae27e674
[gaim-migrate @ 15297]
Richard Laager <rlaager@wiktel.com>
parents:
12943
diff
changeset
|
1150 } |
07eaae27e674
[gaim-migrate @ 15297]
Richard Laager <rlaager@wiktel.com>
parents:
12943
diff
changeset
|
1151 |
12970
ec9b92104904
[gaim-migrate @ 15323]
Richard Laager <rlaager@wiktel.com>
parents:
12948
diff
changeset
|
1152 g_string_append_printf(str, "\n<b>%s%s:</b> %s%s%s", |
8194 | 1153 _("Status"), |
11609 | 1154 res ? res : "", |
12944
07eaae27e674
[gaim-migrate @ 15297]
Richard Laager <rlaager@wiktel.com>
parents:
12943
diff
changeset
|
1155 state, |
8194 | 1156 text ? ": " : "", |
1157 text ? text : ""); | |
12944
07eaae27e674
[gaim-migrate @ 15297]
Richard Laager <rlaager@wiktel.com>
parents:
12943
diff
changeset
|
1158 |
07eaae27e674
[gaim-migrate @ 15297]
Richard Laager <rlaager@wiktel.com>
parents:
12943
diff
changeset
|
1159 g_free(text); |
07eaae27e674
[gaim-migrate @ 15297]
Richard Laager <rlaager@wiktel.com>
parents:
12943
diff
changeset
|
1160 g_free(res); |
11609 | 1161 } |
1162 | |
1163 if(!GAIM_BUDDY_IS_ONLINE(b) && jb->error_msg) { | |
12970
ec9b92104904
[gaim-migrate @ 15323]
Richard Laager <rlaager@wiktel.com>
parents:
12948
diff
changeset
|
1164 g_string_append_printf(str, "\n<b>%s:</b> %s", |
8194 | 1165 _("Error"), jb->error_msg); |
1166 } | |
4745 | 1167 } |
4732 | 1168 } |
1169 | |
9954 | 1170 static GList *jabber_status_types(GaimAccount *account) |
7014 | 1171 { |
9954 | 1172 GaimStatusType *type; |
1173 GList *types = NULL; | |
11568 | 1174 GaimValue *priority_value; |
9954 | 1175 |
11568 | 1176 priority_value = gaim_value_new(GAIM_TYPE_INT); |
11569 | 1177 gaim_value_set_int(priority_value, 1); |
12595
3169cd6727ad
[gaim-migrate @ 14925]
Richard Laager <rlaager@wiktel.com>
parents:
12554
diff
changeset
|
1178 type = gaim_status_type_new_with_attrs(GAIM_STATUS_AVAILABLE, |
3169cd6727ad
[gaim-migrate @ 14925]
Richard Laager <rlaager@wiktel.com>
parents:
12554
diff
changeset
|
1179 jabber_buddy_state_get_status_id(JABBER_BUDDY_STATE_ONLINE), |
3169cd6727ad
[gaim-migrate @ 14925]
Richard Laager <rlaager@wiktel.com>
parents:
12554
diff
changeset
|
1180 NULL, TRUE, TRUE, FALSE, |
3169cd6727ad
[gaim-migrate @ 14925]
Richard Laager <rlaager@wiktel.com>
parents:
12554
diff
changeset
|
1181 "priority", _("Priority"), priority_value, |
3169cd6727ad
[gaim-migrate @ 14925]
Richard Laager <rlaager@wiktel.com>
parents:
12554
diff
changeset
|
1182 "message", _("Message"), gaim_value_new(GAIM_TYPE_STRING), |
3169cd6727ad
[gaim-migrate @ 14925]
Richard Laager <rlaager@wiktel.com>
parents:
12554
diff
changeset
|
1183 NULL); |
9980 | 1184 types = g_list_append(types, type); |
1185 | |
11568 | 1186 priority_value = gaim_value_new(GAIM_TYPE_INT); |
11569 | 1187 gaim_value_set_int(priority_value, 1); |
12595
3169cd6727ad
[gaim-migrate @ 14925]
Richard Laager <rlaager@wiktel.com>
parents:
12554
diff
changeset
|
1188 type = gaim_status_type_new_with_attrs(GAIM_STATUS_AVAILABLE, |
3169cd6727ad
[gaim-migrate @ 14925]
Richard Laager <rlaager@wiktel.com>
parents:
12554
diff
changeset
|
1189 jabber_buddy_state_get_status_id(JABBER_BUDDY_STATE_CHAT), |
3169cd6727ad
[gaim-migrate @ 14925]
Richard Laager <rlaager@wiktel.com>
parents:
12554
diff
changeset
|
1190 _("Chatty"), TRUE, TRUE, FALSE, |
3169cd6727ad
[gaim-migrate @ 14925]
Richard Laager <rlaager@wiktel.com>
parents:
12554
diff
changeset
|
1191 "priority", _("Priority"), priority_value, |
3169cd6727ad
[gaim-migrate @ 14925]
Richard Laager <rlaager@wiktel.com>
parents:
12554
diff
changeset
|
1192 "message", _("Message"), gaim_value_new(GAIM_TYPE_STRING), |
3169cd6727ad
[gaim-migrate @ 14925]
Richard Laager <rlaager@wiktel.com>
parents:
12554
diff
changeset
|
1193 NULL); |
9954 | 1194 types = g_list_append(types, type); |
2086 | 1195 |
11568 | 1196 priority_value = gaim_value_new(GAIM_TYPE_INT); |
11569 | 1197 gaim_value_set_int(priority_value, 0); |
12595
3169cd6727ad
[gaim-migrate @ 14925]
Richard Laager <rlaager@wiktel.com>
parents:
12554
diff
changeset
|
1198 type = gaim_status_type_new_with_attrs(GAIM_STATUS_AWAY, |
3169cd6727ad
[gaim-migrate @ 14925]
Richard Laager <rlaager@wiktel.com>
parents:
12554
diff
changeset
|
1199 jabber_buddy_state_get_status_id(JABBER_BUDDY_STATE_AWAY), |
3169cd6727ad
[gaim-migrate @ 14925]
Richard Laager <rlaager@wiktel.com>
parents:
12554
diff
changeset
|
1200 NULL, TRUE, TRUE, FALSE, |
3169cd6727ad
[gaim-migrate @ 14925]
Richard Laager <rlaager@wiktel.com>
parents:
12554
diff
changeset
|
1201 "priority", _("Priority"), priority_value, |
3169cd6727ad
[gaim-migrate @ 14925]
Richard Laager <rlaager@wiktel.com>
parents:
12554
diff
changeset
|
1202 "message", _("Message"), gaim_value_new(GAIM_TYPE_STRING), |
3169cd6727ad
[gaim-migrate @ 14925]
Richard Laager <rlaager@wiktel.com>
parents:
12554
diff
changeset
|
1203 NULL); |
9954 | 1204 types = g_list_append(types, type); |
1205 | |
11568 | 1206 priority_value = gaim_value_new(GAIM_TYPE_INT); |
11569 | 1207 gaim_value_set_int(priority_value, 0); |
12595
3169cd6727ad
[gaim-migrate @ 14925]
Richard Laager <rlaager@wiktel.com>
parents:
12554
diff
changeset
|
1208 type = gaim_status_type_new_with_attrs(GAIM_STATUS_EXTENDED_AWAY, |
3169cd6727ad
[gaim-migrate @ 14925]
Richard Laager <rlaager@wiktel.com>
parents:
12554
diff
changeset
|
1209 jabber_buddy_state_get_status_id(JABBER_BUDDY_STATE_XA), |
3169cd6727ad
[gaim-migrate @ 14925]
Richard Laager <rlaager@wiktel.com>
parents:
12554
diff
changeset
|
1210 NULL, TRUE, TRUE, FALSE, |
3169cd6727ad
[gaim-migrate @ 14925]
Richard Laager <rlaager@wiktel.com>
parents:
12554
diff
changeset
|
1211 "priority", _("Priority"), priority_value, |
3169cd6727ad
[gaim-migrate @ 14925]
Richard Laager <rlaager@wiktel.com>
parents:
12554
diff
changeset
|
1212 "message", _("Message"), gaim_value_new(GAIM_TYPE_STRING), |
3169cd6727ad
[gaim-migrate @ 14925]
Richard Laager <rlaager@wiktel.com>
parents:
12554
diff
changeset
|
1213 NULL); |
9954 | 1214 types = g_list_append(types, type); |
1215 | |
11568 | 1216 priority_value = gaim_value_new(GAIM_TYPE_INT); |
11569 | 1217 gaim_value_set_int(priority_value, 0); |
12595
3169cd6727ad
[gaim-migrate @ 14925]
Richard Laager <rlaager@wiktel.com>
parents:
12554
diff
changeset
|
1218 type = gaim_status_type_new_with_attrs(GAIM_STATUS_UNAVAILABLE, |
3169cd6727ad
[gaim-migrate @ 14925]
Richard Laager <rlaager@wiktel.com>
parents:
12554
diff
changeset
|
1219 jabber_buddy_state_get_status_id(JABBER_BUDDY_STATE_DND), |
3169cd6727ad
[gaim-migrate @ 14925]
Richard Laager <rlaager@wiktel.com>
parents:
12554
diff
changeset
|
1220 _("Do Not Disturb"), TRUE, TRUE, FALSE, |
3169cd6727ad
[gaim-migrate @ 14925]
Richard Laager <rlaager@wiktel.com>
parents:
12554
diff
changeset
|
1221 "priority", _("Priority"), priority_value, |
3169cd6727ad
[gaim-migrate @ 14925]
Richard Laager <rlaager@wiktel.com>
parents:
12554
diff
changeset
|
1222 "message", _("Message"), gaim_value_new(GAIM_TYPE_STRING), |
3169cd6727ad
[gaim-migrate @ 14925]
Richard Laager <rlaager@wiktel.com>
parents:
12554
diff
changeset
|
1223 NULL); |
9954 | 1224 types = g_list_append(types, type); |
1225 | |
1226 /* | |
8166 | 1227 if(js->protocol_version == JABBER_PROTO_0_9) |
1228 m = g_list_append(m, _("Invisible")); | |
10009 | 1229 */ |
2086 | 1230 |
12658 | 1231 type = gaim_status_type_new_with_attrs(GAIM_STATUS_OFFLINE, |
1232 jabber_buddy_state_get_status_id(JABBER_BUDDY_STATE_UNAVAILABLE), | |
1233 NULL, FALSE, TRUE, FALSE, | |
1234 "message", _("Message"), gaim_value_new(GAIM_TYPE_STRING), | |
1235 NULL); | |
1236 types = g_list_append(types, type); | |
1237 | |
9954 | 1238 return types; |
2086 | 1239 } |
1240 | |
7395 | 1241 static void |
1242 jabber_password_change_result_cb(JabberStream *js, xmlnode *packet, | |
1243 gpointer data) | |
7124 | 1244 { |
1245 const char *type; | |
1246 | |
1247 type = xmlnode_get_attrib(packet, "type"); | |
1248 | |
9414 | 1249 if(type && !strcmp(type, "result")) { |
7124 | 1250 gaim_notify_info(js->gc, _("Password Changed"), _("Password Changed"), |
1251 _("Your password has been changed.")); | |
1252 } else { | |
8401 | 1253 char *msg = jabber_parse_error(js, packet); |
7124 | 1254 |
8401 | 1255 gaim_notify_error(js->gc, _("Error changing password"), |
1256 _("Error changing password"), msg); | |
1257 g_free(msg); | |
7124 | 1258 } |
1259 } | |
1260 | |
1261 static void jabber_password_change_cb(JabberStream *js, | |
1262 GaimRequestFields *fields) | |
1263 { | |
1264 const char *p1, *p2; | |
1265 JabberIq *iq; | |
1266 xmlnode *query, *y; | |
1267 | |
1268 p1 = gaim_request_fields_get_string(fields, "password1"); | |
1269 p2 = gaim_request_fields_get_string(fields, "password2"); | |
1270 | |
1271 if(strcmp(p1, p2)) { | |
1272 gaim_notify_error(js->gc, NULL, _("New passwords do not match."), NULL); | |
1273 return; | |
1274 } | |
1275 | |
1276 iq = jabber_iq_new_query(js, JABBER_IQ_SET, "jabber:iq:register"); | |
1277 | |
1278 xmlnode_set_attrib(iq->node, "to", js->user->domain); | |
1279 | |
1280 query = xmlnode_get_child(iq->node, "query"); | |
1281 | |
1282 y = xmlnode_new_child(query, "username"); | |
1283 xmlnode_insert_data(y, js->user->node, -1); | |
1284 y = xmlnode_new_child(query, "password"); | |
1285 xmlnode_insert_data(y, p1, -1); | |
1286 | |
7395 | 1287 jabber_iq_set_callback(iq, jabber_password_change_result_cb, NULL); |
7124 | 1288 |
1289 jabber_iq_send(iq); | |
1290 | |
1291 gaim_account_set_password(js->gc->account, p1); | |
1292 } | |
1293 | |
9015 | 1294 static void jabber_password_change(GaimPluginAction *action) |
7124 | 1295 { |
9015 | 1296 |
1297 GaimConnection *gc = (GaimConnection *) action->context; | |
7124 | 1298 JabberStream *js = gc->proto_data; |
1299 GaimRequestFields *fields; | |
1300 GaimRequestFieldGroup *group; | |
1301 GaimRequestField *field; | |
1302 | |
1303 fields = gaim_request_fields_new(); | |
1304 group = gaim_request_field_group_new(NULL); | |
1305 gaim_request_fields_add_group(fields, group); | |
1306 | |
1307 field = gaim_request_field_string_new("password1", _("Password"), | |
1308 "", FALSE); | |
1309 gaim_request_field_string_set_masked(field, TRUE); | |
1310 gaim_request_field_group_add_field(group, field); | |
1311 | |
1312 field = gaim_request_field_string_new("password2", _("Password (again)"), | |
1313 "", FALSE); | |
1314 gaim_request_field_string_set_masked(field, TRUE); | |
1315 gaim_request_field_group_add_field(group, field); | |
1316 | |
1317 gaim_request_fields(js->gc, _("Change Jabber Password"), | |
1318 _("Change Jabber Password"), _("Please enter your new password"), | |
1319 fields, _("OK"), G_CALLBACK(jabber_password_change_cb), | |
1320 _("Cancel"), NULL, js); | |
1321 } | |
1322 | |
9015 | 1323 static GList *jabber_actions(GaimPlugin *plugin, gpointer context) |
2956 | 1324 { |
1325 GList *m = NULL; | |
9015 | 1326 GaimPluginAction *act; |
4333 | 1327 |
12243
d3cb077caf3e
[gaim-migrate @ 14545]
Richard Laager <rlaager@wiktel.com>
parents:
12143
diff
changeset
|
1328 act = gaim_plugin_action_new(_("Set User Info..."), |
12286
255e6912607b
[gaim-migrate @ 14590]
Etan Reisner <pidgin@unreliablesource.net>
parents:
12284
diff
changeset
|
1329 jabber_setup_set_info); |
9015 | 1330 m = g_list_append(m, act); |
4333 | 1331 |
8296 | 1332 /* if (js->protocol_options & CHANGE_PASSWORD) { */ |
12243
d3cb077caf3e
[gaim-migrate @ 14545]
Richard Laager <rlaager@wiktel.com>
parents:
12143
diff
changeset
|
1333 act = gaim_plugin_action_new(_("Change Password..."), |
12286
255e6912607b
[gaim-migrate @ 14590]
Etan Reisner <pidgin@unreliablesource.net>
parents:
12284
diff
changeset
|
1334 jabber_password_change); |
9015 | 1335 m = g_list_append(m, act); |
8296 | 1336 /* } */ |
2956 | 1337 |
12243
d3cb077caf3e
[gaim-migrate @ 14545]
Richard Laager <rlaager@wiktel.com>
parents:
12143
diff
changeset
|
1338 act = gaim_plugin_action_new(_("Search for Users..."), |
12286
255e6912607b
[gaim-migrate @ 14590]
Etan Reisner <pidgin@unreliablesource.net>
parents:
12284
diff
changeset
|
1339 jabber_user_search_begin); |
11675 | 1340 m = g_list_append(m, act); |
1341 | |
2956 | 1342 return m; |
1343 } | |
1344 | |
7999 | 1345 static GaimChat *jabber_find_blist_chat(GaimAccount *account, const char *name) |
1346 { | |
1347 GaimBlistNode *gnode, *cnode; | |
1348 JabberID *jid; | |
1349 | |
1350 if(!(jid = jabber_id_new(name))) | |
1351 return NULL; | |
1352 | |
1353 for(gnode = gaim_get_blist()->root; gnode; gnode = gnode->next) { | |
1354 for(cnode = gnode->child; cnode; cnode = cnode->next) { | |
1355 GaimChat *chat = (GaimChat*)cnode; | |
1356 const char *room, *server; | |
1357 if(!GAIM_BLIST_NODE_IS_CHAT(cnode)) | |
1358 continue; | |
1359 | |
1360 if(chat->account != account) | |
8011 | 1361 continue; |
7999 | 1362 |
1363 if(!(room = g_hash_table_lookup(chat->components, "room"))) | |
1364 continue; | |
1365 if(!(server = g_hash_table_lookup(chat->components, "server"))) | |
1366 continue; | |
1367 | |
8158 | 1368 if(jid->node && jid->domain && |
1369 !g_utf8_collate(room, jid->node) && !g_utf8_collate(server, jid->domain)) { | |
7999 | 1370 jabber_id_free(jid); |
1371 return chat; | |
1372 } | |
1373 } | |
1374 } | |
1375 jabber_id_free(jid); | |
1376 return NULL; | |
1377 } | |
1378 | |
8400 | 1379 static void jabber_convo_closed(GaimConnection *gc, const char *who) |
1380 { | |
1381 JabberStream *js = gc->proto_data; | |
1382 JabberID *jid; | |
1383 JabberBuddy *jb; | |
1384 JabberBuddyResource *jbr; | |
1385 | |
1386 if(!(jid = jabber_id_new(who))) | |
1387 return; | |
1388 | |
1389 if((jb = jabber_buddy_find(js, who, TRUE)) && | |
1390 (jbr = jabber_buddy_find_resource(jb, jid->resource))) { | |
1391 if(jbr->thread_id) { | |
1392 g_free(jbr->thread_id); | |
1393 jbr->thread_id = NULL; | |
1394 } | |
1395 } | |
1396 | |
1397 jabber_id_free(jid); | |
1398 } | |
1399 | |
8401 | 1400 |
1401 char *jabber_parse_error(JabberStream *js, xmlnode *packet) | |
1402 { | |
1403 xmlnode *error; | |
1404 const char *code = NULL, *text = NULL; | |
1405 const char *xmlns = xmlnode_get_attrib(packet, "xmlns"); | |
1406 char *cdata = NULL; | |
1407 | |
1408 if((error = xmlnode_get_child(packet, "error"))) { | |
1409 cdata = xmlnode_get_data(error); | |
1410 code = xmlnode_get_attrib(error, "code"); | |
1411 | |
1412 /* Stanza errors */ | |
1413 if(xmlnode_get_child(error, "bad-request")) { | |
1414 text = _("Bad Request"); | |
1415 } else if(xmlnode_get_child(error, "conflict")) { | |
1416 text = _("Conflict"); | |
1417 } else if(xmlnode_get_child(error, "feature-not-implemented")) { | |
1418 text = _("Feature Not Implemented"); | |
1419 } else if(xmlnode_get_child(error, "forbidden")) { | |
1420 text = _("Forbidden"); | |
1421 } else if(xmlnode_get_child(error, "gone")) { | |
1422 text = _("Gone"); | |
1423 } else if(xmlnode_get_child(error, "internal-server-error")) { | |
1424 text = _("Internal Server Error"); | |
1425 } else if(xmlnode_get_child(error, "item-not-found")) { | |
1426 text = _("Item Not Found"); | |
1427 } else if(xmlnode_get_child(error, "jid-malformed")) { | |
1428 text = _("Malformed Jabber ID"); | |
1429 } else if(xmlnode_get_child(error, "not-acceptable")) { | |
1430 text = _("Not Acceptable"); | |
1431 } else if(xmlnode_get_child(error, "not-allowed")) { | |
1432 text = _("Not Allowed"); | |
1433 } else if(xmlnode_get_child(error, "not-authorized")) { | |
1434 text = _("Not Authorized"); | |
1435 } else if(xmlnode_get_child(error, "payment-required")) { | |
1436 text = _("Payment Required"); | |
1437 } else if(xmlnode_get_child(error, "recipient-unavailable")) { | |
1438 text = _("Recipient Unavailable"); | |
1439 } else if(xmlnode_get_child(error, "redirect")) { | |
1440 /* XXX */ | |
1441 } else if(xmlnode_get_child(error, "registration-required")) { | |
1442 text = _("Registration Required"); | |
1443 } else if(xmlnode_get_child(error, "remote-server-not-found")) { | |
1444 text = _("Remote Server Not Found"); | |
1445 } else if(xmlnode_get_child(error, "remote-server-timeout")) { | |
1446 text = _("Remote Server Timeout"); | |
1447 } else if(xmlnode_get_child(error, "resource-constraint")) { | |
1448 text = _("Server Overloaded"); | |
1449 } else if(xmlnode_get_child(error, "service-unavailable")) { | |
1450 text = _("Service Unavailable"); | |
1451 } else if(xmlnode_get_child(error, "subscription-required")) { | |
1452 text = _("Subscription Required"); | |
1453 } else if(xmlnode_get_child(error, "unexpected-request")) { | |
1454 text = _("Unexpected Request"); | |
1455 } else if(xmlnode_get_child(error, "undefined-condition")) { | |
1456 text = _("Unknown Error"); | |
1457 } | |
1458 } else if(xmlns && !strcmp(xmlns, "urn:ietf:params:xml:ns:xmpp-sasl")) { | |
1459 if(xmlnode_get_child(packet, "aborted")) { | |
1460 js->gc->wants_to_die = TRUE; | |
1461 text = _("Authorization Aborted"); | |
1462 } else if(xmlnode_get_child(error, "incorrect-encoding")) { | |
1463 text = _("Incorrect encoding in authorization"); | |
1464 } else if(xmlnode_get_child(error, "invalid-authzid")) { | |
1465 js->gc->wants_to_die = TRUE; | |
1466 text = _("Invalid authzid"); | |
1467 } else if(xmlnode_get_child(error, "invalid-mechanism")) { | |
1468 js->gc->wants_to_die = TRUE; | |
1469 text = _("Invalid Authorization Mechanism"); | |
1470 } else if(xmlnode_get_child(error, "mechanism-too-weak")) { | |
1471 js->gc->wants_to_die = TRUE; | |
1472 text = _("Authorization mechanism too weak"); | |
1473 } else if(xmlnode_get_child(error, "not-authorized")) { | |
1474 js->gc->wants_to_die = TRUE; | |
1475 text = _("Not Authorized"); | |
1476 } else if(xmlnode_get_child(error, "temporary-auth-failure")) { | |
1477 text = _("Temporary Authentication Failure"); | |
1478 } else { | |
13051 | 1479 js->gc->wants_to_die = TRUE; |
8401 | 1480 text = _("Authentication Failure"); |
1481 } | |
8402 | 1482 } else if(!strcmp(packet->name, "stream:error")) { |
1483 if(xmlnode_get_child(packet, "bad-format")) { | |
1484 text = _("Bad Format"); | |
1485 } else if(xmlnode_get_child(packet, "bad-namespace-prefix")) { | |
1486 text = _("Bad Namespace Prefix"); | |
1487 } else if(xmlnode_get_child(packet, "conflict")) { | |
1488 js->gc->wants_to_die = TRUE; | |
1489 text = _("Resource Conflict"); | |
1490 } else if(xmlnode_get_child(packet, "connection-timeout")) { | |
1491 text = _("Connection Timeout"); | |
1492 } else if(xmlnode_get_child(packet, "host-gone")) { | |
1493 text = _("Host Gone"); | |
1494 } else if(xmlnode_get_child(packet, "host-unknown")) { | |
1495 text = _("Host Unknown"); | |
1496 } else if(xmlnode_get_child(packet, "improper-addressing")) { | |
1497 text = _("Improper Addressing"); | |
1498 } else if(xmlnode_get_child(packet, "internal-server-error")) { | |
1499 text = _("Internal Server Error"); | |
1500 } else if(xmlnode_get_child(packet, "invalid-id")) { | |
1501 text = _("Invalid ID"); | |
1502 } else if(xmlnode_get_child(packet, "invalid-namespace")) { | |
1503 text = _("Invalid Namespace"); | |
1504 } else if(xmlnode_get_child(packet, "invalid-xml")) { | |
1505 text = _("Invalid XML"); | |
1506 } else if(xmlnode_get_child(packet, "nonmatching-hosts")) { | |
1507 text = _("Non-matching Hosts"); | |
1508 } else if(xmlnode_get_child(packet, "not-authorized")) { | |
1509 text = _("Not Authorized"); | |
1510 } else if(xmlnode_get_child(packet, "policy-violation")) { | |
1511 text = _("Policy Violation"); | |
1512 } else if(xmlnode_get_child(packet, "remote-connection-failed")) { | |
1513 text = _("Remote Connection Failed"); | |
1514 } else if(xmlnode_get_child(packet, "resource-constraint")) { | |
1515 text = _("Resource Constraint"); | |
1516 } else if(xmlnode_get_child(packet, "restricted-xml")) { | |
1517 text = _("Restricted XML"); | |
1518 } else if(xmlnode_get_child(packet, "see-other-host")) { | |
1519 text = _("See Other Host"); | |
1520 } else if(xmlnode_get_child(packet, "system-shutdown")) { | |
1521 text = _("System Shutdown"); | |
1522 } else if(xmlnode_get_child(packet, "undefined-condition")) { | |
1523 text = _("Undefined Condition"); | |
1524 } else if(xmlnode_get_child(packet, "unsupported-encoding")) { | |
1525 text = _("Unsupported Encoding"); | |
1526 } else if(xmlnode_get_child(packet, "unsupported-stanza-type")) { | |
1527 text = _("Unsupported Stanza Type"); | |
1528 } else if(xmlnode_get_child(packet, "unsupported-version")) { | |
1529 text = _("Unsupported Version"); | |
1530 } else if(xmlnode_get_child(packet, "xml-not-well-formed")) { | |
1531 text = _("XML Not Well Formed"); | |
1532 } else { | |
1533 text = _("Stream Error"); | |
1534 } | |
8401 | 1535 } |
1536 | |
1537 if(text || cdata) { | |
1538 char *ret = g_strdup_printf("%s%s%s", code ? code : "", | |
1539 code ? ": " : "", text ? text : cdata); | |
1540 g_free(cdata); | |
1541 return ret; | |
1542 } else { | |
1543 return NULL; | |
1544 } | |
1545 } | |
1546 | |
9130 | 1547 static GaimCmdRet jabber_cmd_chat_config(GaimConversation *conv, |
9597 | 1548 const char *cmd, char **args, char **error, void *data) |
9130 | 1549 { |
1550 JabberChat *chat = jabber_chat_find_by_conv(conv); | |
1551 jabber_chat_request_room_configure(chat); | |
1552 return GAIM_CMD_RET_OK; | |
1553 } | |
1554 | |
1555 static GaimCmdRet jabber_cmd_chat_register(GaimConversation *conv, | |
9597 | 1556 const char *cmd, char **args, char **error, void *data) |
9130 | 1557 { |
1558 JabberChat *chat = jabber_chat_find_by_conv(conv); | |
1559 jabber_chat_register(chat); | |
1560 return GAIM_CMD_RET_OK; | |
1561 } | |
1562 | |
1563 static GaimCmdRet jabber_cmd_chat_topic(GaimConversation *conv, | |
9597 | 1564 const char *cmd, char **args, char **error, void *data) |
9130 | 1565 { |
1566 JabberChat *chat = jabber_chat_find_by_conv(conv); | |
1567 jabber_chat_change_topic(chat, args ? args[0] : NULL); | |
1568 return GAIM_CMD_RET_OK; | |
1569 } | |
1570 | |
1571 static GaimCmdRet jabber_cmd_chat_nick(GaimConversation *conv, | |
9597 | 1572 const char *cmd, char **args, char **error, void *data) |
9130 | 1573 { |
1574 JabberChat *chat = jabber_chat_find_by_conv(conv); | |
1575 | |
1576 if(!args || !args[0]) | |
1577 return GAIM_CMD_RET_FAILED; | |
1578 | |
1579 jabber_chat_change_nick(chat, args[0]); | |
1580 return GAIM_CMD_RET_OK; | |
1581 } | |
1582 | |
1583 static GaimCmdRet jabber_cmd_chat_part(GaimConversation *conv, | |
9597 | 1584 const char *cmd, char **args, char **error, void *data) |
9130 | 1585 { |
1586 JabberChat *chat = jabber_chat_find_by_conv(conv); | |
1587 jabber_chat_part(chat, args ? args[0] : NULL); | |
1588 return GAIM_CMD_RET_OK; | |
1589 } | |
1590 | |
9152 | 1591 static GaimCmdRet jabber_cmd_chat_ban(GaimConversation *conv, |
9597 | 1592 const char *cmd, char **args, char **error, void *data) |
9152 | 1593 { |
1594 JabberChat *chat = jabber_chat_find_by_conv(conv); | |
1595 | |
1596 if(!args || !args[0]) | |
1597 return GAIM_CMD_RET_FAILED; | |
1598 | |
1599 if(!jabber_chat_ban_user(chat, args[0], args[1])) { | |
1600 *error = g_strdup_printf(_("Unable to ban user %s"), args[0]); | |
1601 return GAIM_CMD_RET_FAILED; | |
1602 } | |
1603 | |
1604 return GAIM_CMD_RET_OK; | |
1605 } | |
1606 | |
11393 | 1607 static GaimCmdRet jabber_cmd_chat_affiliate(GaimConversation *conv, |
1608 const char *cmd, char **args, char **error, void *data) | |
1609 { | |
1610 JabberChat *chat = jabber_chat_find_by_conv(conv); | |
1611 | |
1612 if (!args || !args[0] || !args[1]) | |
1613 return GAIM_CMD_RET_FAILED; | |
1614 | |
13237
b0d020a66144
[gaim-migrate @ 15603]
Etan Reisner <pidgin@unreliablesource.net>
parents:
13200
diff
changeset
|
1615 if (strcmp(args[1], "owner") != 0 && |
b0d020a66144
[gaim-migrate @ 15603]
Etan Reisner <pidgin@unreliablesource.net>
parents:
13200
diff
changeset
|
1616 strcmp(args[1], "admin") != 0 && |
b0d020a66144
[gaim-migrate @ 15603]
Etan Reisner <pidgin@unreliablesource.net>
parents:
13200
diff
changeset
|
1617 strcmp(args[1], "member") != 0 && |
b0d020a66144
[gaim-migrate @ 15603]
Etan Reisner <pidgin@unreliablesource.net>
parents:
13200
diff
changeset
|
1618 strcmp(args[1], "outcast") != 0 && |
b0d020a66144
[gaim-migrate @ 15603]
Etan Reisner <pidgin@unreliablesource.net>
parents:
13200
diff
changeset
|
1619 strcmp(args[1], "none") != 0) { |
11393 | 1620 *error = g_strdup_printf(_("Unknown affiliation: \"%s\""), args[1]); |
1621 return GAIM_CMD_RET_FAILED; | |
1622 } | |
1623 | |
1624 if (!jabber_chat_affiliate_user(chat, args[0], args[1])) { | |
1625 *error = g_strdup_printf(_("Unable to affiliate user %s as \"%s\""), args[0], args[1]); | |
1626 return GAIM_CMD_RET_FAILED; | |
1627 } | |
1628 | |
1629 return GAIM_CMD_RET_OK; | |
1630 } | |
1631 | |
13237
b0d020a66144
[gaim-migrate @ 15603]
Etan Reisner <pidgin@unreliablesource.net>
parents:
13200
diff
changeset
|
1632 static GaimCmdRet jabber_cmd_chat_role(GaimConversation *conv, |
b0d020a66144
[gaim-migrate @ 15603]
Etan Reisner <pidgin@unreliablesource.net>
parents:
13200
diff
changeset
|
1633 const char *cmd, char **args, char **error, void *data) |
b0d020a66144
[gaim-migrate @ 15603]
Etan Reisner <pidgin@unreliablesource.net>
parents:
13200
diff
changeset
|
1634 { |
b0d020a66144
[gaim-migrate @ 15603]
Etan Reisner <pidgin@unreliablesource.net>
parents:
13200
diff
changeset
|
1635 JabberChat *chat; |
b0d020a66144
[gaim-migrate @ 15603]
Etan Reisner <pidgin@unreliablesource.net>
parents:
13200
diff
changeset
|
1636 |
b0d020a66144
[gaim-migrate @ 15603]
Etan Reisner <pidgin@unreliablesource.net>
parents:
13200
diff
changeset
|
1637 if (!args || !args[0] || !args[1]) |
b0d020a66144
[gaim-migrate @ 15603]
Etan Reisner <pidgin@unreliablesource.net>
parents:
13200
diff
changeset
|
1638 return GAIM_CMD_RET_FAILED; |
b0d020a66144
[gaim-migrate @ 15603]
Etan Reisner <pidgin@unreliablesource.net>
parents:
13200
diff
changeset
|
1639 |
b0d020a66144
[gaim-migrate @ 15603]
Etan Reisner <pidgin@unreliablesource.net>
parents:
13200
diff
changeset
|
1640 if (strcmp(args[1], "moderator") != 0 && |
b0d020a66144
[gaim-migrate @ 15603]
Etan Reisner <pidgin@unreliablesource.net>
parents:
13200
diff
changeset
|
1641 strcmp(args[1], "participant") != 0 && |
b0d020a66144
[gaim-migrate @ 15603]
Etan Reisner <pidgin@unreliablesource.net>
parents:
13200
diff
changeset
|
1642 strcmp(args[1], "visitor") != 0 && |
b0d020a66144
[gaim-migrate @ 15603]
Etan Reisner <pidgin@unreliablesource.net>
parents:
13200
diff
changeset
|
1643 strcmp(args[1], "none") != 0) { |
b0d020a66144
[gaim-migrate @ 15603]
Etan Reisner <pidgin@unreliablesource.net>
parents:
13200
diff
changeset
|
1644 *error = g_strdup_printf(_("Unknown role: \"%s\""), args[1]); |
b0d020a66144
[gaim-migrate @ 15603]
Etan Reisner <pidgin@unreliablesource.net>
parents:
13200
diff
changeset
|
1645 return GAIM_CMD_RET_FAILED; |
b0d020a66144
[gaim-migrate @ 15603]
Etan Reisner <pidgin@unreliablesource.net>
parents:
13200
diff
changeset
|
1646 } |
b0d020a66144
[gaim-migrate @ 15603]
Etan Reisner <pidgin@unreliablesource.net>
parents:
13200
diff
changeset
|
1647 |
b0d020a66144
[gaim-migrate @ 15603]
Etan Reisner <pidgin@unreliablesource.net>
parents:
13200
diff
changeset
|
1648 chat = jabber_chat_find_by_conv(conv); |
b0d020a66144
[gaim-migrate @ 15603]
Etan Reisner <pidgin@unreliablesource.net>
parents:
13200
diff
changeset
|
1649 |
b0d020a66144
[gaim-migrate @ 15603]
Etan Reisner <pidgin@unreliablesource.net>
parents:
13200
diff
changeset
|
1650 if (!jabber_chat_role_user(chat, args[0], args[1])) { |
b0d020a66144
[gaim-migrate @ 15603]
Etan Reisner <pidgin@unreliablesource.net>
parents:
13200
diff
changeset
|
1651 *error = g_strdup_printf(_("Unable to set role \"%s\" for user: %s"), |
b0d020a66144
[gaim-migrate @ 15603]
Etan Reisner <pidgin@unreliablesource.net>
parents:
13200
diff
changeset
|
1652 args[1], args[0]); |
b0d020a66144
[gaim-migrate @ 15603]
Etan Reisner <pidgin@unreliablesource.net>
parents:
13200
diff
changeset
|
1653 return GAIM_CMD_RET_FAILED; |
b0d020a66144
[gaim-migrate @ 15603]
Etan Reisner <pidgin@unreliablesource.net>
parents:
13200
diff
changeset
|
1654 } |
b0d020a66144
[gaim-migrate @ 15603]
Etan Reisner <pidgin@unreliablesource.net>
parents:
13200
diff
changeset
|
1655 |
b0d020a66144
[gaim-migrate @ 15603]
Etan Reisner <pidgin@unreliablesource.net>
parents:
13200
diff
changeset
|
1656 return GAIM_CMD_RET_OK; |
b0d020a66144
[gaim-migrate @ 15603]
Etan Reisner <pidgin@unreliablesource.net>
parents:
13200
diff
changeset
|
1657 } |
b0d020a66144
[gaim-migrate @ 15603]
Etan Reisner <pidgin@unreliablesource.net>
parents:
13200
diff
changeset
|
1658 |
9152 | 1659 static GaimCmdRet jabber_cmd_chat_invite(GaimConversation *conv, |
9597 | 1660 const char *cmd, char **args, char **error, void *data) |
9152 | 1661 { |
1662 if(!args || !args[0]) | |
1663 return GAIM_CMD_RET_FAILED; | |
1664 | |
1665 jabber_chat_invite(gaim_conversation_get_gc(conv), | |
1666 gaim_conv_chat_get_id(GAIM_CONV_CHAT(conv)), args[1] ? args[1] : "", | |
1667 args[0]); | |
1668 | |
1669 return GAIM_CMD_RET_OK; | |
1670 } | |
1671 | |
1672 static GaimCmdRet jabber_cmd_chat_join(GaimConversation *conv, | |
9597 | 1673 const char *cmd, char **args, char **error, void *data) |
9152 | 1674 { |
1675 JabberChat *chat = jabber_chat_find_by_conv(conv); | |
1676 GHashTable *components; | |
1677 | |
1678 if(!args || !args[0]) | |
1679 return GAIM_CMD_RET_FAILED; | |
1680 | |
1681 components = g_hash_table_new_full(g_str_hash, g_str_equal, NULL, NULL); | |
1682 | |
1683 g_hash_table_replace(components, "room", args[0]); | |
1684 g_hash_table_replace(components, "server", chat->server); | |
1685 g_hash_table_replace(components, "handle", chat->handle); | |
1686 if(args[1]) | |
1687 g_hash_table_replace(components, "password", args[1]); | |
1688 | |
1689 jabber_chat_join(gaim_conversation_get_gc(conv), components); | |
1690 | |
1691 g_hash_table_destroy(components); | |
1692 return GAIM_CMD_RET_OK; | |
1693 } | |
1694 | |
1695 static GaimCmdRet jabber_cmd_chat_kick(GaimConversation *conv, | |
9597 | 1696 const char *cmd, char **args, char **error, void *data) |
9152 | 1697 { |
1698 JabberChat *chat = jabber_chat_find_by_conv(conv); | |
1699 | |
1700 if(!args || !args[0]) | |
1701 return GAIM_CMD_RET_FAILED; | |
1702 | |
1703 if(!jabber_chat_kick_user(chat, args[0], args[1])) { | |
1704 *error = g_strdup_printf(_("Unable to kick user %s"), args[0]); | |
1705 return GAIM_CMD_RET_FAILED; | |
1706 } | |
1707 | |
1708 return GAIM_CMD_RET_OK; | |
1709 } | |
1710 | |
1711 static GaimCmdRet jabber_cmd_chat_msg(GaimConversation *conv, | |
9597 | 1712 const char *cmd, char **args, char **error, void *data) |
9152 | 1713 { |
1714 JabberChat *chat = jabber_chat_find_by_conv(conv); | |
1715 char *who; | |
1716 | |
1717 who = g_strdup_printf("%s@%s/%s", chat->room, chat->server, args[0]); | |
1718 | |
1719 jabber_message_send_im(gaim_conversation_get_gc(conv), who, args[1], 0); | |
1720 | |
1721 g_free(who); | |
1722 return GAIM_CMD_RET_OK; | |
1723 } | |
1724 | |
12646
5c5e03b9aed6
[gaim-migrate @ 14984]
Richard Laager <rlaager@wiktel.com>
parents:
12645
diff
changeset
|
1725 static gboolean jabber_offline_message(const GaimBuddy *buddy) |
12645
fc28451f5d96
[gaim-migrate @ 14983]
Richard Laager <rlaager@wiktel.com>
parents:
12600
diff
changeset
|
1726 { |
fc28451f5d96
[gaim-migrate @ 14983]
Richard Laager <rlaager@wiktel.com>
parents:
12600
diff
changeset
|
1727 return TRUE; |
fc28451f5d96
[gaim-migrate @ 14983]
Richard Laager <rlaager@wiktel.com>
parents:
12600
diff
changeset
|
1728 } |
fc28451f5d96
[gaim-migrate @ 14983]
Richard Laager <rlaager@wiktel.com>
parents:
12600
diff
changeset
|
1729 |
9130 | 1730 static void jabber_register_commands(void) |
1731 { | |
1732 gaim_cmd_register("config", "", GAIM_CMD_P_PRPL, | |
9597 | 1733 GAIM_CMD_FLAG_CHAT | GAIM_CMD_FLAG_PRPL_ONLY, |
1734 "prpl-jabber", jabber_cmd_chat_config, | |
1735 _("config: Configure a chat room."), NULL); | |
9130 | 1736 gaim_cmd_register("configure", "", GAIM_CMD_P_PRPL, |
9597 | 1737 GAIM_CMD_FLAG_CHAT | GAIM_CMD_FLAG_PRPL_ONLY, |
1738 "prpl-jabber", jabber_cmd_chat_config, | |
1739 _("configure: Configure a chat room."), NULL); | |
9130 | 1740 gaim_cmd_register("nick", "s", GAIM_CMD_P_PRPL, |
9597 | 1741 GAIM_CMD_FLAG_CHAT | GAIM_CMD_FLAG_PRPL_ONLY, |
1742 "prpl-jabber", jabber_cmd_chat_nick, | |
1743 _("nick <new nickname>: Change your nickname."), | |
1744 NULL); | |
9130 | 1745 gaim_cmd_register("part", "s", GAIM_CMD_P_PRPL, |
9597 | 1746 GAIM_CMD_FLAG_CHAT | GAIM_CMD_FLAG_PRPL_ONLY | |
1747 GAIM_CMD_FLAG_ALLOW_WRONG_ARGS, "prpl-jabber", | |
1748 jabber_cmd_chat_part, _("part [room]: Leave the room."), | |
1749 NULL); | |
9130 | 1750 gaim_cmd_register("register", "", GAIM_CMD_P_PRPL, |
9597 | 1751 GAIM_CMD_FLAG_CHAT | GAIM_CMD_FLAG_PRPL_ONLY, |
1752 "prpl-jabber", jabber_cmd_chat_register, | |
1753 _("register: Register with a chat room."), NULL); | |
9130 | 1754 /* XXX: there needs to be a core /topic cmd, methinks */ |
1755 gaim_cmd_register("topic", "s", GAIM_CMD_P_PRPL, | |
9597 | 1756 GAIM_CMD_FLAG_CHAT | GAIM_CMD_FLAG_PRPL_ONLY | |
1757 GAIM_CMD_FLAG_ALLOW_WRONG_ARGS, "prpl-jabber", | |
1758 jabber_cmd_chat_topic, | |
1759 _("topic [new topic]: View or change the topic."), | |
1760 NULL); | |
9152 | 1761 gaim_cmd_register("ban", "ws", GAIM_CMD_P_PRPL, |
9597 | 1762 GAIM_CMD_FLAG_CHAT | GAIM_CMD_FLAG_PRPL_ONLY | |
1763 GAIM_CMD_FLAG_ALLOW_WRONG_ARGS, "prpl-jabber", | |
1764 jabber_cmd_chat_ban, | |
1765 _("ban <user> [room]: Ban a user from the room."), | |
1766 NULL); | |
11393 | 1767 gaim_cmd_register("affiliate", "ws", GAIM_CMD_P_PRPL, |
13237
b0d020a66144
[gaim-migrate @ 15603]
Etan Reisner <pidgin@unreliablesource.net>
parents:
13200
diff
changeset
|
1768 GAIM_CMD_FLAG_CHAT | GAIM_CMD_FLAG_PRPL_ONLY | |
b0d020a66144
[gaim-migrate @ 15603]
Etan Reisner <pidgin@unreliablesource.net>
parents:
13200
diff
changeset
|
1769 GAIM_CMD_FLAG_ALLOW_WRONG_ARGS, "prpl-jabber", |
b0d020a66144
[gaim-migrate @ 15603]
Etan Reisner <pidgin@unreliablesource.net>
parents:
13200
diff
changeset
|
1770 jabber_cmd_chat_affiliate, |
b0d020a66144
[gaim-migrate @ 15603]
Etan Reisner <pidgin@unreliablesource.net>
parents:
13200
diff
changeset
|
1771 _("affiliate <user> <owner|admin|member|outcast|none>: Set a user's affiliation with the room."), |
b0d020a66144
[gaim-migrate @ 15603]
Etan Reisner <pidgin@unreliablesource.net>
parents:
13200
diff
changeset
|
1772 NULL); |
b0d020a66144
[gaim-migrate @ 15603]
Etan Reisner <pidgin@unreliablesource.net>
parents:
13200
diff
changeset
|
1773 gaim_cmd_register("role", "ws", GAIM_CMD_P_PRPL, |
b0d020a66144
[gaim-migrate @ 15603]
Etan Reisner <pidgin@unreliablesource.net>
parents:
13200
diff
changeset
|
1774 GAIM_CMD_FLAG_CHAT | GAIM_CMD_FLAG_PRPL_ONLY | |
b0d020a66144
[gaim-migrate @ 15603]
Etan Reisner <pidgin@unreliablesource.net>
parents:
13200
diff
changeset
|
1775 GAIM_CMD_FLAG_ALLOW_WRONG_ARGS, "prpl-jabber", |
b0d020a66144
[gaim-migrate @ 15603]
Etan Reisner <pidgin@unreliablesource.net>
parents:
13200
diff
changeset
|
1776 jabber_cmd_chat_role, |
b0d020a66144
[gaim-migrate @ 15603]
Etan Reisner <pidgin@unreliablesource.net>
parents:
13200
diff
changeset
|
1777 _("role <user> <moderator|participant|visitor|none>: Set a user's role in the room."), |
b0d020a66144
[gaim-migrate @ 15603]
Etan Reisner <pidgin@unreliablesource.net>
parents:
13200
diff
changeset
|
1778 NULL); |
9152 | 1779 gaim_cmd_register("invite", "ws", GAIM_CMD_P_PRPL, |
9597 | 1780 GAIM_CMD_FLAG_CHAT | GAIM_CMD_FLAG_PRPL_ONLY | |
1781 GAIM_CMD_FLAG_ALLOW_WRONG_ARGS, "prpl-jabber", | |
1782 jabber_cmd_chat_invite, | |
11158
2c930d591492
[gaim-migrate @ 13245]
Etan Reisner <pidgin@unreliablesource.net>
parents:
11033
diff
changeset
|
1783 _("invite <user> [message]: Invite a user to the room."), |
9597 | 1784 NULL); |
9152 | 1785 gaim_cmd_register("join", "ws", GAIM_CMD_P_PRPL, |
9597 | 1786 GAIM_CMD_FLAG_CHAT | GAIM_CMD_FLAG_PRPL_ONLY | |
1787 GAIM_CMD_FLAG_ALLOW_WRONG_ARGS, "prpl-jabber", | |
1788 jabber_cmd_chat_join, | |
1789 _("join: <room> [server]: Join a chat on this server."), | |
1790 NULL); | |
9152 | 1791 gaim_cmd_register("kick", "ws", GAIM_CMD_P_PRPL, |
9597 | 1792 GAIM_CMD_FLAG_CHAT | GAIM_CMD_FLAG_PRPL_ONLY | |
1793 GAIM_CMD_FLAG_ALLOW_WRONG_ARGS, "prpl-jabber", | |
1794 jabber_cmd_chat_kick, | |
1795 _("kick <user> [room]: Kick a user from the room."), | |
1796 NULL); | |
9152 | 1797 gaim_cmd_register("msg", "ws", GAIM_CMD_P_PRPL, |
9597 | 1798 GAIM_CMD_FLAG_CHAT | GAIM_CMD_FLAG_PRPL_ONLY, |
1799 "prpl-jabber", jabber_cmd_chat_msg, | |
1800 _("msg <user> <message>: Send a private message to another user."), | |
1801 NULL); | |
9130 | 1802 } |
1803 | |
5205
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5174
diff
changeset
|
1804 static GaimPluginProtocolInfo prpl_info = |
2086 | 1805 { |
12554 | 1806 OPT_PROTO_CHAT_TOPIC | OPT_PROTO_UNIQUE_CHATNAME, |
9475 | 1807 NULL, /* user_splits */ |
1808 NULL, /* protocol_options */ | |
10189 | 1809 {"jpeg,gif,png", 0, 0, 96, 96, GAIM_ICON_SCALE_DISPLAY}, /* icon_spec */ |
9475 | 1810 jabber_list_icon, /* list_icon */ |
1811 jabber_list_emblems, /* list_emblems */ | |
1812 jabber_status_text, /* status_text */ | |
1813 jabber_tooltip_text, /* tooltip_text */ | |
9954 | 1814 jabber_status_types, /* status_types */ |
9475 | 1815 jabber_blist_node_menu, /* blist_node_menu */ |
1816 jabber_chat_info, /* chat_info */ | |
9754 | 1817 jabber_chat_info_defaults, /* chat_info_defaults */ |
9475 | 1818 jabber_login, /* login */ |
1819 jabber_close, /* close */ | |
1820 jabber_message_send_im, /* send_im */ | |
1821 jabber_set_info, /* set_info */ | |
1822 jabber_send_typing, /* send_typing */ | |
1823 jabber_buddy_get_info, /* get_info */ | |
10216 | 1824 jabber_presence_send, /* set_away */ |
9475 | 1825 jabber_idle_set, /* set_idle */ |
1826 NULL, /* change_passwd */ | |
1827 jabber_roster_add_buddy, /* add_buddy */ | |
1828 NULL, /* add_buddies */ | |
1829 jabber_roster_remove_buddy, /* remove_buddy */ | |
1830 NULL, /* remove_buddies */ | |
1831 NULL, /* add_permit */ | |
1832 NULL, /* add_deny */ | |
1833 NULL, /* rem_permit */ | |
1834 NULL, /* rem_deny */ | |
1835 NULL, /* set_permit_deny */ | |
1836 jabber_chat_join, /* join_chat */ | |
1837 NULL, /* reject_chat */ | |
9917 | 1838 jabber_get_chat_name, /* get_chat_name */ |
9475 | 1839 jabber_chat_invite, /* chat_invite */ |
1840 jabber_chat_leave, /* chat_leave */ | |
1841 NULL, /* chat_whisper */ | |
1842 jabber_message_send_chat, /* chat_send */ | |
1843 jabber_keepalive, /* keepalive */ | |
1844 jabber_register_account, /* register_user */ | |
1845 jabber_buddy_get_info_chat, /* get_cb_info */ | |
1846 NULL, /* get_cb_away */ | |
1847 jabber_roster_alias_change, /* alias_buddy */ | |
1848 jabber_roster_group_change, /* group_buddy */ | |
1849 jabber_roster_group_rename, /* rename_group */ | |
1850 NULL, /* buddy_free */ | |
1851 jabber_convo_closed, /* convo_closed */ | |
1852 jabber_normalize, /* normalize */ | |
10189 | 1853 jabber_set_buddy_icon, /* set_buddy_icon */ |
9475 | 1854 NULL, /* remove_group */ |
1855 jabber_chat_buddy_real_name, /* get_cb_real_name */ | |
1856 jabber_chat_set_topic, /* set_chat_topic */ | |
1857 jabber_find_blist_chat, /* find_blist_chat */ | |
1858 jabber_roomlist_get_list, /* roomlist_get_list */ | |
1859 jabber_roomlist_cancel, /* roomlist_cancel */ | |
1860 NULL, /* roomlist_expand_category */ | |
1861 NULL, /* can_receive_file */ | |
12143
cbebda5f019c
[gaim-migrate @ 14444]
Richard Laager <rlaager@wiktel.com>
parents:
11939
diff
changeset
|
1862 jabber_si_xfer_send, /* send_file */ |
cbebda5f019c
[gaim-migrate @ 14444]
Richard Laager <rlaager@wiktel.com>
parents:
11939
diff
changeset
|
1863 jabber_si_new_xfer, /* new_xfer */ |
12645
fc28451f5d96
[gaim-migrate @ 14983]
Richard Laager <rlaager@wiktel.com>
parents:
12600
diff
changeset
|
1864 jabber_offline_message, /* offline_message */ |
12600
e856f985a0b9
[gaim-migrate @ 14934]
Richard Laager <rlaager@wiktel.com>
parents:
12595
diff
changeset
|
1865 NULL, /* whiteboard_prpl_ops */ |
5205
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5174
diff
changeset
|
1866 }; |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5174
diff
changeset
|
1867 |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5174
diff
changeset
|
1868 static GaimPluginInfo info = |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5174
diff
changeset
|
1869 { |
9943 | 1870 GAIM_PLUGIN_MAGIC, |
1871 GAIM_MAJOR_VERSION, | |
1872 GAIM_MINOR_VERSION, | |
5205
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5174
diff
changeset
|
1873 GAIM_PLUGIN_PROTOCOL, /**< type */ |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5174
diff
changeset
|
1874 NULL, /**< ui_requirement */ |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5174
diff
changeset
|
1875 0, /**< flags */ |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5174
diff
changeset
|
1876 NULL, /**< dependencies */ |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5174
diff
changeset
|
1877 GAIM_PRIORITY_DEFAULT, /**< priority */ |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5174
diff
changeset
|
1878 |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5174
diff
changeset
|
1879 "prpl-jabber", /**< id */ |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5174
diff
changeset
|
1880 "Jabber", /**< name */ |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5174
diff
changeset
|
1881 VERSION, /**< version */ |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5174
diff
changeset
|
1882 /** summary */ |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5174
diff
changeset
|
1883 N_("Jabber Protocol Plugin"), |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5174
diff
changeset
|
1884 /** description */ |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5174
diff
changeset
|
1885 N_("Jabber Protocol Plugin"), |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5174
diff
changeset
|
1886 NULL, /**< author */ |
6371
8f94cce8faa5
[gaim-migrate @ 6876]
Christian Hammond <chipx86@chipx86.com>
parents:
6357
diff
changeset
|
1887 GAIM_WEBSITE, /**< homepage */ |
5205
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5174
diff
changeset
|
1888 |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5174
diff
changeset
|
1889 NULL, /**< load */ |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5174
diff
changeset
|
1890 NULL, /**< unload */ |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5174
diff
changeset
|
1891 NULL, /**< destroy */ |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5174
diff
changeset
|
1892 |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5174
diff
changeset
|
1893 NULL, /**< ui_info */ |
8993 | 1894 &prpl_info, /**< extra_info */ |
10487 | 1895 NULL, /**< prefs_info */ |
9015 | 1896 jabber_actions |
5205
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5174
diff
changeset
|
1897 }; |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5174
diff
changeset
|
1898 |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5174
diff
changeset
|
1899 static void |
5920
7d385de2f9cd
[gaim-migrate @ 6360]
Christian Hammond <chipx86@chipx86.com>
parents:
5894
diff
changeset
|
1900 init_plugin(GaimPlugin *plugin) |
5205
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5174
diff
changeset
|
1901 { |
5638
0bdfa28c678e
[gaim-migrate @ 6047]
Christian Hammond <chipx86@chipx86.com>
parents:
5613
diff
changeset
|
1902 GaimAccountUserSplit *split; |
0bdfa28c678e
[gaim-migrate @ 6047]
Christian Hammond <chipx86@chipx86.com>
parents:
5613
diff
changeset
|
1903 GaimAccountOption *option; |
0bdfa28c678e
[gaim-migrate @ 6047]
Christian Hammond <chipx86@chipx86.com>
parents:
5613
diff
changeset
|
1904 |
0bdfa28c678e
[gaim-migrate @ 6047]
Christian Hammond <chipx86@chipx86.com>
parents:
5613
diff
changeset
|
1905 split = gaim_account_user_split_new(_("Server"), "jabber.org", '@'); |
0bdfa28c678e
[gaim-migrate @ 6047]
Christian Hammond <chipx86@chipx86.com>
parents:
5613
diff
changeset
|
1906 prpl_info.user_splits = g_list_append(prpl_info.user_splits, split); |
0bdfa28c678e
[gaim-migrate @ 6047]
Christian Hammond <chipx86@chipx86.com>
parents:
5613
diff
changeset
|
1907 |
11939
85c25a32bb48
[gaim-migrate @ 14230]
Etan Reisner <pidgin@unreliablesource.net>
parents:
11837
diff
changeset
|
1908 split = gaim_account_user_split_new(_("Resource"), "Home", '/'); |
5638
0bdfa28c678e
[gaim-migrate @ 6047]
Christian Hammond <chipx86@chipx86.com>
parents:
5613
diff
changeset
|
1909 prpl_info.user_splits = g_list_append(prpl_info.user_splits, split); |
0bdfa28c678e
[gaim-migrate @ 6047]
Christian Hammond <chipx86@chipx86.com>
parents:
5613
diff
changeset
|
1910 |
7630 | 1911 option = gaim_account_option_bool_new(_("Use TLS if available"), "use_tls", |
1912 TRUE); | |
1913 prpl_info.protocol_options = g_list_append(prpl_info.protocol_options, | |
1914 option); | |
1915 | |
10941 | 1916 option = gaim_account_option_bool_new(_("Require TLS"), "require_tls", TRUE); |
1917 prpl_info.protocol_options = g_list_append(prpl_info.protocol_options, option); | |
1918 | |
1919 option = gaim_account_option_bool_new(_("Force old (port 5223) SSL"), "old_ssl", FALSE); | |
7124 | 1920 prpl_info.protocol_options = g_list_append(prpl_info.protocol_options, |
1921 option); | |
6764 | 1922 |
8086 | 1923 option = gaim_account_option_bool_new( |
1924 _("Allow plaintext auth over unencrypted streams"), | |
1925 "auth_plain_in_clear", FALSE); | |
1926 prpl_info.protocol_options = g_list_append(prpl_info.protocol_options, | |
1927 option); | |
1928 | |
11387 | 1929 option = gaim_account_option_int_new(_("Connect port"), "port", 5222); |
5638
0bdfa28c678e
[gaim-migrate @ 6047]
Christian Hammond <chipx86@chipx86.com>
parents:
5613
diff
changeset
|
1930 prpl_info.protocol_options = g_list_append(prpl_info.protocol_options, |
7014 | 1931 option); |
5638
0bdfa28c678e
[gaim-migrate @ 6047]
Christian Hammond <chipx86@chipx86.com>
parents:
5613
diff
changeset
|
1932 |
5685
43ea75092684
[gaim-migrate @ 6106]
Christian Hammond <chipx86@chipx86.com>
parents:
5681
diff
changeset
|
1933 option = gaim_account_option_string_new(_("Connect server"), |
7014 | 1934 "connect_server", NULL); |
5638
0bdfa28c678e
[gaim-migrate @ 6047]
Christian Hammond <chipx86@chipx86.com>
parents:
5613
diff
changeset
|
1935 prpl_info.protocol_options = g_list_append(prpl_info.protocol_options, |
7014 | 1936 option); |
5205
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5174
diff
changeset
|
1937 |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5174
diff
changeset
|
1938 my_protocol = plugin; |
7014 | 1939 |
10487 | 1940 gaim_prefs_remove("/plugins/prpl/jabber"); |
9130 | 1941 |
12508 | 1942 /* XXX - If any other plugin wants SASL this won't be good ... */ |
1943 #ifdef HAVE_CYRUS_SASL | |
1944 sasl_client_init(NULL); | |
1945 #endif | |
9130 | 1946 jabber_register_commands(); |
2086 | 1947 } |
1948 | |
5920
7d385de2f9cd
[gaim-migrate @ 6360]
Christian Hammond <chipx86@chipx86.com>
parents:
5894
diff
changeset
|
1949 GAIM_INIT_PLUGIN(jabber, init_plugin, info); |