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