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