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