Fri, 23 Dec 2005 19:26:04 +0000
[gaim-migrate @ 14983]
SF Patch #1314512 from Sadrul (who has a patch for everything)
"This patch introduces a flag for protocol plugins that
support offline messages (like Y!M and ICQ). This was
encouraged by the following conversation:
<sadrul> should offline buddies be listed/enabled in
the send-to menu?
<rekkanoryo> i would think only for protocols that
support offline messaging, if it's indicated that the
buddy is offline
-- <snip> --
<Bleeter> sadrul: personally, I'd like to see a
'supports offline' flag of some description
<Bleeter> one could then redirect (via plugins) through
email or alternative methods
<Bleeter> just a thought
<Paco-Paco> yeah, that sounds like a reasonble thing to have
This patch uses this flag to disable the buddies in the
send-to menu who are offline and the protocol doesn't
support offline messages."
I made this make the label insensitive instead of the whole menuitem. This
should address SimGuy's concerns about inconsistency (i.e. you could create a
conversation with someone via the buddy list that you couldn't create via the
Send To menu). I also hacked up some voodoo to show the label as sensitive when
moused-over, as that looks better (given the label-insensitive thing is itself a
hack). I think this works quite well.
BUG NOTE:
This makes more obvious an existing bug. The Send To menu isn't updated when
buddies sign on or off or change status (at least under some circumstances).
We need to fix that anyway, so I'm not going to let it hold up this commit.
Switching tabs will clear it up. I'm thinking we just might want to build the
contents of that menu when it is selected. That would save us a mess of
inefficient signal callbacks that update the Send To menus in open windows all
the time.
AIM NOTE:
This assumes that AIM can't offline message. That's not strictly true. You can
message invisible users on AIM. However, by design, we can't tell when a user
is invisible without resorting to dirty hackery. In practice, this isn't a
problem, as you can still select the AIM user from the menu. And really, how
often will you be choosing the Invisible contact, rather than the user going
Invisible in the middle of a conversation or IMing you while they're Invisible?
JABBER NOTE:
This assumes that Jabber can always offline message. This isn't strictly true.
Sadrul said:
I have updated Jabber according to this link which seems to
talk about how to determine the existence offline-message
support in a server:
http://www.jabber.org/jeps/jep-0013.html#discover
However, jabber.org doesn't seem to send the required
info. So I am not sure about it.
He later said:
I talked to Nathan and he said offline message support is
mostly assumed for most jabber servers. GTalk doesn't yet
support it, but they are working on it. So I have made
jabber to always return TRUE.
If there is truly no way to detect offline messaging capability, then this is
an acceptable solution. We could special case Google Talk because of its
popularity, and remove that later. It's probably not worth it though.
MSN NOTE:
This assumes that MSN can never offline message. That's effectively true, but
to be technically correct, MSN can offline message if there's already a
switchboard conversation open with a user. We could write an offline_message
function in the MSN prpl to detect that, but it'd be of limited usefulness,
especially given that under most circumstances (where this might matter), the
switchboard connection will be closed almost immediately.
CVS NOTE:
I'm writing to share a tragic little story.
I have a PC that I use for Gaim development. One day, I was writing a commit
message on it, when all of a suddent it went berserk. The screen started
flashing, and the whole commit message just disappeared. All of it. And it was
a good commit message! I had to cram and rewrite it really quickly. Needless to
say, my rushed commit message wasn't nearly as good, and I blame the PC for that.
Seriously, though, what kind of version control system loses your commit
message on a broken connection to the server? Stupid!
committer: Richard Laager <rlaager@pidgin.im>
| 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
754c63f29b77
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5685
diff
changeset
|
21 | #include "internal.h" |
|
754c63f29b77
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5685
diff
changeset
|
22 | |
| 7014 | 23 | #include "account.h" |
| 24 | #include "accountopt.h" | |
|
9030
7b574a641391
[gaim-migrate @ 9806]
Mark Doliner <markdoliner@pidgin.im>
parents:
9015
diff
changeset
|
25 | #include "blist.h" |
| 9130 | 26 | #include "cmds.h" |
|
10740
a1cb6b819a21
[gaim-migrate @ 12342]
Mark Doliner <markdoliner@pidgin.im>
parents:
10504
diff
changeset
|
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
17d2b54254f8
[gaim-migrate @ 7660]
Christian Hammond <chipx86@chipx86.com>
parents:
7072
diff
changeset
|
36 | #include "util.h" |
| 9943 | 37 | #include "version.h" |
|
5872
754c63f29b77
[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
b6425eab60ca
[gaim-migrate @ 10291]
Daniel Atallah <datallah@pidgin.im>
parents:
9414
diff
changeset
|
50 | #include "si.h" |
| 7923 | 51 | #include "xdata.h" |
|
5872
754c63f29b77
[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
242b8aa81328
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5174
diff
changeset
|
55 | static GaimPlugin *my_protocol = NULL; |
|
4249
62583b5d3663
[gaim-migrate @ 4499]
Robert McQueen <robot101@debian.org>
parents:
4245
diff
changeset
|
56 | |
| 7014 | 57 | static void jabber_stream_init(JabberStream *js) |
| 58 | { | |
| 59 | char *open_stream; | |
|
3340
7e59a209931d
[gaim-migrate @ 3359]
Jim Seymour <jseymour@users.sourceforge.net>
parents:
3337
diff
changeset
|
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
eae130eefbfe
[gaim-migrate @ 11796]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
10490
diff
changeset
|
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 | ||
| 7642 | 197 | void jabber_send_raw(JabberStream *js, const char *data, int len) |
| 2086 | 198 | { |
| 7014 | 199 | int ret; |
| 2086 | 200 | |
| 7014 | 201 | /* because printing a tab to debug every minute gets old */ |
| 202 | if(strcmp(data, "\t")) | |
| 8401 | 203 | gaim_debug(GAIM_DEBUG_MISC, "jabber", "Sending%s: %s\n", |
| 7014 | 204 | js->gsc ? " (ssl)" : "", data); |
| 2086 | 205 | |
| 12508 | 206 | /* If we've got a security layer, we need to encode the data, |
| 207 | * splitting it on the maximum buffer length negotiated */ | |
| 208 | ||
| 209 | #ifdef HAVE_CYRUS_SASL | |
| 210 | if (js->sasl_maxbuf>0) { | |
| 211 | int pos; | |
| 212 | ||
| 213 | if (!js->gsc && js->fd<0) | |
| 214 | return; | |
| 215 | pos = 0; | |
| 216 | if (len == -1) | |
| 217 | len = strlen(data); | |
| 218 | while (pos < len) { | |
| 219 | int towrite; | |
| 220 | const char *out; | |
| 221 | unsigned olen; | |
| 222 | ||
| 223 | if ((len - pos) < js->sasl_maxbuf) | |
| 224 | towrite = len - pos; | |
| 225 | else | |
| 226 | towrite = js->sasl_maxbuf; | |
| 227 | ||
| 228 | sasl_encode(js->sasl, &data[pos], towrite, &out, &olen); | |
| 229 | pos += towrite; | |
| 230 | ||
| 231 | if (js->gsc) | |
| 232 | ret = gaim_ssl_write(js->gsc, out, olen); | |
| 233 | else | |
| 234 | ret = write(js->fd, out, olen); | |
| 235 | if (ret < 0) | |
| 236 | gaim_connection_error(js->gc, _("Write error")); | |
| 237 | } | |
| 238 | return; | |
| 239 | } | |
| 240 | #endif | |
| 241 | ||
| 7014 | 242 | if(js->gsc) { |
| 7642 | 243 | ret = gaim_ssl_write(js->gsc, data, len == -1 ? strlen(data) : len); |
| 7014 | 244 | } else { |
|
8013
03f5b77cdaf0
[gaim-migrate @ 8693]
Olivier Blin <blino@users.sourceforge.net>
parents:
8011
diff
changeset
|
245 | if(js->fd < 0) |
|
03f5b77cdaf0
[gaim-migrate @ 8693]
Olivier Blin <blino@users.sourceforge.net>
parents:
8011
diff
changeset
|
246 | return; |
| 7642 | 247 | ret = write(js->fd, data, len == -1 ? strlen(data) : len); |
|
2814
91cc1a0cdee0
[gaim-migrate @ 2827]
Eric Warmenhoven <warmenhoven@yahoo.com>
parents:
2800
diff
changeset
|
248 | } |
|
91cc1a0cdee0
[gaim-migrate @ 2827]
Eric Warmenhoven <warmenhoven@yahoo.com>
parents:
2800
diff
changeset
|
249 | |
| 7014 | 250 | if(ret < 0) |
| 251 | gaim_connection_error(js->gc, _("Write error")); | |
| 252 | ||
|
2814
91cc1a0cdee0
[gaim-migrate @ 2827]
Eric Warmenhoven <warmenhoven@yahoo.com>
parents:
2800
diff
changeset
|
253 | } |
|
91cc1a0cdee0
[gaim-migrate @ 2827]
Eric Warmenhoven <warmenhoven@yahoo.com>
parents:
2800
diff
changeset
|
254 | |
| 7014 | 255 | void jabber_send(JabberStream *js, xmlnode *packet) |
| 2086 | 256 | { |
| 7014 | 257 | char *txt; |
| 7642 | 258 | int len; |
| 2086 | 259 | |
| 7642 | 260 | txt = xmlnode_to_str(packet, &len); |
| 261 | jabber_send_raw(js, txt, len); | |
| 7014 | 262 | g_free(txt); |
| 2086 | 263 | } |
| 264 | ||
| 7014 | 265 | static void jabber_keepalive(GaimConnection *gc) |
| 2086 | 266 | { |
| 7642 | 267 | jabber_send_raw(gc->proto_data, "\t", -1); |
| 2086 | 268 | } |
| 269 | ||
| 7014 | 270 | static void |
| 271 | jabber_recv_cb_ssl(gpointer data, GaimSslConnection *gsc, | |
| 6764 | 272 | GaimInputCondition cond) |
| 273 | { | |
| 7014 | 274 | GaimConnection *gc = data; |
| 275 | JabberStream *js = gc->proto_data; | |
| 6764 | 276 | int len; |
| 7014 | 277 | static char buf[4096]; |
| 6768 | 278 | |
| 7014 | 279 | if(!g_list_find(gaim_connections_get_all(), gc)) { |
| 6768 | 280 | gaim_ssl_close(gsc); |
| 281 | return; | |
| 282 | } | |
| 283 | ||
| 7014 | 284 | if((len = gaim_ssl_read(gsc, buf, sizeof(buf) - 1)) > 0) { |
| 6764 | 285 | buf[len] = '\0'; |
| 7014 | 286 | gaim_debug(GAIM_DEBUG_INFO, "jabber", "Recv (ssl)(%d): %s\n", len, buf); |
| 287 | jabber_parser_process(js, buf, len); | |
| 7177 | 288 | } else { |
| 289 | gaim_connection_error(gc, _("Read Error")); | |
| 2086 | 290 | } |
| 291 | } | |
| 292 | ||
| 7014 | 293 | static void |
| 294 | jabber_recv_cb(gpointer data, gint source, GaimInputCondition condition) | |
| 2086 | 295 | { |
| 5572 | 296 | GaimConnection *gc = data; |
| 7014 | 297 | JabberStream *js = gc->proto_data; |
| 298 | int len; | |
| 299 | static char buf[4096]; | |
| 2086 | 300 | |
| 7014 | 301 | if(!g_list_find(gaim_connections_get_all(), gc)) |
| 302 | return; | |
| 2956 | 303 | |
| 7014 | 304 | if((len = read(js->fd, buf, sizeof(buf) - 1)) > 0) { |
| 12508 | 305 | #ifdef HAVE_CYRUS_SASL |
| 306 | if (js->sasl_maxbuf>0) { | |
| 307 | const char *out; | |
| 308 | int olen; | |
| 309 | sasl_decode(js->sasl, buf, len, &out, &olen); | |
| 310 | if (olen>0) { | |
| 311 | gaim_debug(GAIM_DEBUG_INFO, "jabber", "RecvSASL (%d): %s\n", olen, out); | |
| 312 | jabber_parser_process(js,out,olen); | |
| 313 | } | |
| 314 | return; | |
| 315 | } | |
| 316 | #endif | |
| 7014 | 317 | buf[len] = '\0'; |
| 318 | gaim_debug(GAIM_DEBUG_INFO, "jabber", "Recv (%d): %s\n", len, buf); | |
| 319 | jabber_parser_process(js, buf, len); | |
| 7177 | 320 | } else { |
| 321 | gaim_connection_error(gc, _("Read Error")); | |
| 7014 | 322 | } |
| 2086 | 323 | } |
| 324 | ||
| 7014 | 325 | static void |
| 326 | jabber_login_callback_ssl(gpointer data, GaimSslConnection *gsc, | |
| 6764 | 327 | GaimInputCondition cond) |
| 328 | { | |
| 329 | GaimConnection *gc = data; | |
| 7014 | 330 | JabberStream *js = gc->proto_data; |
| 6764 | 331 | |
| 7014 | 332 | if(!g_list_find(gaim_connections_get_all(), gc)) { |
| 6764 | 333 | gaim_ssl_close(gsc); |
| 334 | return; | |
| 335 | } | |
| 336 | ||
| 7014 | 337 | js->gsc = gsc; |
| 6764 | 338 | |
| 7014 | 339 | if(js->state == JABBER_STREAM_CONNECTING) |
| 7642 | 340 | jabber_send_raw(js, "<?xml version='1.0' ?>", -1); |
| 6764 | 341 | |
| 7014 | 342 | jabber_stream_set_state(js, JABBER_STREAM_INITIALIZING); |
| 343 | gaim_ssl_input_add(gsc, jabber_recv_cb_ssl, gc); | |
| 6764 | 344 | } |
| 345 | ||
| 7014 | 346 | |
| 347 | static void | |
| 348 | jabber_login_callback(gpointer data, gint source, GaimInputCondition cond) | |
| 6764 | 349 | { |
| 5572 | 350 | GaimConnection *gc = data; |
| 7014 | 351 | JabberStream *js = gc->proto_data; |
| 2086 | 352 | |
|
8783
7be6da5bc279
[gaim-migrate @ 9545]
Mark Doliner <markdoliner@pidgin.im>
parents:
8778
diff
changeset
|
353 | if (source < 0) { |
|
7be6da5bc279
[gaim-migrate @ 9545]
Mark Doliner <markdoliner@pidgin.im>
parents:
8778
diff
changeset
|
354 | gaim_connection_error(gc, _("Couldn't connect to host")); |
|
7be6da5bc279
[gaim-migrate @ 9545]
Mark Doliner <markdoliner@pidgin.im>
parents:
8778
diff
changeset
|
355 | return; |
|
7be6da5bc279
[gaim-migrate @ 9545]
Mark Doliner <markdoliner@pidgin.im>
parents:
8778
diff
changeset
|
356 | } |
|
7be6da5bc279
[gaim-migrate @ 9545]
Mark Doliner <markdoliner@pidgin.im>
parents:
8778
diff
changeset
|
357 | |
| 7014 | 358 | if(!g_list_find(gaim_connections_get_all(), gc)) { |
| 2086 | 359 | close(source); |
| 360 | return; | |
| 361 | } | |
| 362 | ||
| 7014 | 363 | js->fd = source; |
| 2956 | 364 | |
| 7014 | 365 | if(js->state == JABBER_STREAM_CONNECTING) |
| 7642 | 366 | jabber_send_raw(js, "<?xml version='1.0' ?>", -1); |
|
2300
06a3c10f4918
[gaim-migrate @ 2310]
Eric Warmenhoven <warmenhoven@yahoo.com>
parents:
2289
diff
changeset
|
367 | |
| 7014 | 368 | jabber_stream_set_state(js, JABBER_STREAM_INITIALIZING); |
| 369 | gc->inpa = gaim_input_add(js->fd, GAIM_INPUT_READ, jabber_recv_cb, gc); | |
| 370 | } | |
| 2086 | 371 | |
| 7014 | 372 | static void |
| 7426 | 373 | jabber_ssl_connect_failure(GaimSslConnection *gsc, GaimSslErrorType error, |
| 374 | gpointer data) | |
| 375 | { | |
| 376 | GaimConnection *gc = data; | |
| 8360 | 377 | JabberStream *js = gc->proto_data; |
| 7426 | 378 | |
| 379 | switch(error) { | |
| 8362 | 380 | case GAIM_SSL_CONNECT_FAILED: |
| 381 | gaim_connection_error(gc, _("Connection Failed")); | |
| 382 | break; | |
| 7426 | 383 | case GAIM_SSL_HANDSHAKE_FAILED: |
| 384 | gaim_connection_error(gc, _("SSL Handshake Failed")); | |
| 385 | break; | |
| 386 | } | |
| 8360 | 387 | |
| 388 | js->gsc = NULL; | |
| 7426 | 389 | } |
| 390 | ||
| 7427 | 391 | static void tls_init(JabberStream *js) |
| 392 | { | |
| 393 | gaim_input_remove(js->gc->inpa); | |
| 394 | js->gc->inpa = 0; | |
| 395 | js->gsc = gaim_ssl_connect_fd(js->gc->account, js->fd, | |
| 396 | jabber_login_callback_ssl, jabber_ssl_connect_failure, js->gc); | |
| 397 | } | |
| 398 | ||
| 11387 | 399 | static void jabber_login_connect(JabberStream *js, const char *server, int port) |
| 400 | { | |
| 401 | int rc; | |
| 402 | ||
| 403 | rc = gaim_proxy_connect(js->gc->account, server, | |
| 404 | port, jabber_login_callback, js->gc); | |
| 405 | ||
| 406 | if (rc != 0) | |
| 407 | gaim_connection_error(js->gc, _("Unable to create socket")); | |
| 408 | } | |
| 409 | ||
| 410 | static void srv_resolved_cb(struct srv_response *resp, int results, gpointer data) | |
| 411 | { | |
| 412 | JabberStream *js = (JabberStream*)data; | |
| 413 | int config_port = gaim_account_get_int(js->gc->account, "port", 0); | |
| 414 | ||
| 415 | if(results) { | |
| 416 | jabber_login_connect(js, resp->hostname, config_port ? config_port : resp->port); | |
| 417 | g_free(resp); | |
| 418 | } else { | |
| 419 | jabber_login_connect(js, js->user->domain, config_port); | |
| 420 | } | |
| 421 | } | |
| 422 | ||
| 423 | ||
| 7427 | 424 | |
| 7426 | 425 | static void |
|
11837
2f1206084fef
[gaim-migrate @ 14128]
Mark Doliner <markdoliner@pidgin.im>
parents:
11675
diff
changeset
|
426 | jabber_login(GaimAccount *account) |
| 2086 | 427 | { |
| 7014 | 428 | GaimConnection *gc = gaim_account_get_connection(account); |
| 429 | const char *connect_server = gaim_account_get_string(account, | |
| 430 | "connect_server", ""); | |
| 431 | JabberStream *js; | |
| 10289 | 432 | JabberBuddy *my_jb = NULL; |
| 2086 | 433 | |
| 7014 | 434 | gc->flags |= GAIM_CONNECTION_HTML; |
| 435 | js = gc->proto_data = g_new0(JabberStream, 1); | |
| 436 | js->gc = gc; | |
|
8013
03f5b77cdaf0
[gaim-migrate @ 8693]
Olivier Blin <blino@users.sourceforge.net>
parents:
8011
diff
changeset
|
437 | js->fd = -1; |
| 8312 | 438 | js->iq_callbacks = g_hash_table_new_full(g_str_hash, g_str_equal, |
| 439 | g_free, g_free); | |
| 440 | js->disco_callbacks = g_hash_table_new_full(g_str_hash, g_str_equal, | |
| 7395 | 441 | g_free, g_free); |
| 7014 | 442 | js->buddies = g_hash_table_new_full(g_str_hash, g_str_equal, |
| 7116 | 443 | g_free, (GDestroyNotify)jabber_buddy_free); |
| 7014 | 444 | js->chats = g_hash_table_new_full(g_str_hash, g_str_equal, |
| 8396 | 445 | g_free, (GDestroyNotify)jabber_chat_free); |
| 8043 | 446 | js->chat_servers = g_list_append(NULL, g_strdup("conference.jabber.org")); |
| 7014 | 447 | js->user = jabber_id_new(gaim_account_get_username(account)); |
| 7322 | 448 | js->next_id = g_random_int(); |
| 5613 | 449 | |
| 7310 | 450 | if(!js->user) { |
| 451 | gaim_connection_error(gc, _("Invalid Jabber ID")); | |
| 452 | return; | |
| 453 | } | |
| 454 | ||
| 7147 | 455 | if(!js->user->resource) { |
| 456 | char *me; | |
| 11939 | 457 | js->user->resource = g_strdup("Home"); |
| 7147 | 458 | if(!js->user->node) { |
| 459 | js->user->node = js->user->domain; | |
| 460 | js->user->domain = g_strdup("jabber.org"); | |
| 461 | } | |
| 462 | me = g_strdup_printf("%s@%s/%s", js->user->node, js->user->domain, | |
| 463 | js->user->resource); | |
| 464 | gaim_account_set_username(account, me); | |
| 465 | g_free(me); | |
| 7145 | 466 | } |
| 467 | ||
| 10289 | 468 | if((my_jb = jabber_buddy_find(js, gaim_account_get_username(account), TRUE))) |
| 469 | my_jb->subscription |= JABBER_SUB_BOTH; | |
| 470 | ||
| 7014 | 471 | jabber_stream_set_state(js, JABBER_STREAM_CONNECTING); |
| 2956 | 472 | |
| 11387 | 473 | /* if they've got old-ssl mode going, we probably want to ignore SRV lookups */ |
| 474 | if(gaim_account_get_bool(js->gc->account, "old_ssl", FALSE)) { | |
| 7630 | 475 | if(gaim_ssl_is_supported()) { |
| 11387 | 476 | js->gsc = gaim_ssl_connect(js->gc->account, |
| 477 | connect_server[0] ? connect_server : js->user->domain, | |
| 478 | gaim_account_get_int(account, "port", 5223), jabber_login_callback_ssl, | |
| 479 | jabber_ssl_connect_failure, js->gc); | |
| 7630 | 480 | } else { |
| 11387 | 481 | gaim_connection_error(js->gc, _("SSL support unavailable")); |
| 7630 | 482 | } |
| 3311 | 483 | } |
| 3770 | 484 | |
| 11387 | 485 | /* no old-ssl, so if they've specified a connect server, we'll use that, otherwise we'll |
| 486 | * invoke the magic of SRV lookups, to figure out host and port */ | |
| 7014 | 487 | if(!js->gsc) { |
| 11387 | 488 | if(connect_server[0]) { |
| 489 | jabber_login_connect(js, connect_server, gaim_account_get_int(account, "port", 5222)); | |
| 490 | } else { | |
| 491 | gaim_srv_resolve("xmpp-client", "tcp", js->user->domain, srv_resolved_cb, js); | |
| 492 | } | |
| 2956 | 493 | } |
| 2086 | 494 | } |
| 495 | ||
| 11387 | 496 | |
| 7072 | 497 | static gboolean |
| 498 | conn_close_cb(gpointer data) | |
| 499 | { | |
| 500 | JabberStream *js = data; | |
|
10740
a1cb6b819a21
[gaim-migrate @ 12342]
Mark Doliner <markdoliner@pidgin.im>
parents:
10504
diff
changeset
|
501 | GaimAccount *account = gaim_connection_get_account(js->gc); |
|
a1cb6b819a21
[gaim-migrate @ 12342]
Mark Doliner <markdoliner@pidgin.im>
parents:
10504
diff
changeset
|
502 | |
|
a1cb6b819a21
[gaim-migrate @ 12342]
Mark Doliner <markdoliner@pidgin.im>
parents:
10504
diff
changeset
|
503 | gaim_account_disconnect(account); |
|
a1cb6b819a21
[gaim-migrate @ 12342]
Mark Doliner <markdoliner@pidgin.im>
parents:
10504
diff
changeset
|
504 | |
| 7072 | 505 | return FALSE; |
| 506 | } | |
| 507 | ||
| 508 | static void | |
| 509 | jabber_connection_schedule_close(JabberStream *js) | |
| 510 | { | |
| 8273 | 511 | gaim_timeout_add(0, conn_close_cb, js); |
| 7072 | 512 | } |
| 513 | ||
| 514 | static void | |
| 7395 | 515 | jabber_registration_result_cb(JabberStream *js, xmlnode *packet, gpointer data) |
| 7072 | 516 | { |
| 517 | const char *type = xmlnode_get_attrib(packet, "type"); | |
| 518 | char *buf; | |
| 519 | ||
| 520 | if(!strcmp(type, "result")) { | |
| 521 | buf = g_strdup_printf(_("Registration of %s@%s successful"), | |
| 522 | js->user->node, js->user->domain); | |
| 523 | gaim_notify_info(NULL, _("Registration Successful"), | |
| 524 | _("Registration Successful"), buf); | |
| 525 | g_free(buf); | |
| 526 | } else { | |
| 8401 | 527 | char *msg = jabber_parse_error(js, packet); |
| 7072 | 528 | |
| 8401 | 529 | if(!msg) |
| 530 | msg = g_strdup(_("Unknown Error")); | |
| 7072 | 531 | |
| 532 | gaim_notify_error(NULL, _("Registration Failed"), | |
| 8401 | 533 | _("Registration Failed"), msg); |
| 534 | g_free(msg); | |
| 7072 | 535 | } |
| 536 | jabber_connection_schedule_close(js); | |
| 537 | } | |
| 538 | ||
| 539 | static void | |
| 540 | jabber_register_cb(JabberStream *js, GaimRequestFields *fields) | |
| 541 | { | |
| 542 | GList *groups, *flds; | |
| 543 | xmlnode *query, *y; | |
| 544 | JabberIq *iq; | |
| 7264 | 545 | char *username; |
| 7072 | 546 | |
| 547 | iq = jabber_iq_new_query(js, JABBER_IQ_SET, "jabber:iq:register"); | |
| 548 | query = xmlnode_get_child(iq->node, "query"); | |
| 549 | ||
| 550 | for(groups = gaim_request_fields_get_groups(fields); groups; | |
| 551 | groups = groups->next) { | |
| 552 | for(flds = gaim_request_field_group_get_fields(groups->data); | |
| 553 | flds; flds = flds->next) { | |
| 554 | GaimRequestField *field = flds->data; | |
| 555 | const char *id = gaim_request_field_get_id(field); | |
| 556 | const char *value = gaim_request_field_string_get_value(field); | |
| 557 | ||
| 558 | if(!strcmp(id, "username")) { | |
| 559 | y = xmlnode_new_child(query, "username"); | |
| 560 | } else if(!strcmp(id, "password")) { | |
| 561 | y = xmlnode_new_child(query, "password"); | |
| 562 | } else if(!strcmp(id, "name")) { | |
| 563 | y = xmlnode_new_child(query, "name"); | |
| 564 | } else if(!strcmp(id, "email")) { | |
| 565 | y = xmlnode_new_child(query, "email"); | |
| 566 | } else if(!strcmp(id, "nick")) { | |
| 567 | y = xmlnode_new_child(query, "nick"); | |
| 568 | } else if(!strcmp(id, "first")) { | |
| 569 | y = xmlnode_new_child(query, "first"); | |
| 570 | } else if(!strcmp(id, "last")) { | |
| 571 | y = xmlnode_new_child(query, "last"); | |
| 572 | } else if(!strcmp(id, "address")) { | |
| 573 | y = xmlnode_new_child(query, "address"); | |
| 574 | } else if(!strcmp(id, "city")) { | |
| 575 | y = xmlnode_new_child(query, "city"); | |
| 576 | } else if(!strcmp(id, "state")) { | |
| 577 | y = xmlnode_new_child(query, "state"); | |
| 578 | } else if(!strcmp(id, "zip")) { | |
| 579 | y = xmlnode_new_child(query, "zip"); | |
| 580 | } else if(!strcmp(id, "phone")) { | |
| 581 | y = xmlnode_new_child(query, "phone"); | |
| 582 | } else if(!strcmp(id, "url")) { | |
| 583 | y = xmlnode_new_child(query, "url"); | |
| 584 | } else if(!strcmp(id, "date")) { | |
| 585 | y = xmlnode_new_child(query, "date"); | |
| 586 | } else { | |
| 587 | continue; | |
| 588 | } | |
| 589 | xmlnode_insert_data(y, value, -1); | |
| 7264 | 590 | if(!strcmp(id, "username")) { |
| 591 | if(js->user->node) | |
| 592 | g_free(js->user->node); | |
| 593 | js->user->node = g_strdup(value); | |
| 594 | } | |
| 7072 | 595 | } |
| 596 | } | |
| 597 | ||
| 7264 | 598 | username = g_strdup_printf("%s@%s/%s", js->user->node, js->user->domain, |
| 599 | js->user->resource); | |
| 600 | gaim_account_set_username(js->gc->account, username); | |
| 601 | g_free(username); | |
| 602 | ||
| 7395 | 603 | jabber_iq_set_callback(iq, jabber_registration_result_cb, NULL); |
| 7072 | 604 | |
| 605 | jabber_iq_send(iq); | |
| 606 | ||
| 607 | } | |
| 608 | ||
| 609 | static void | |
| 610 | jabber_register_cancel_cb(JabberStream *js, GaimRequestFields *fields) | |
| 611 | { | |
| 612 | jabber_connection_schedule_close(js); | |
| 613 | } | |
| 614 | ||
| 7923 | 615 | static void jabber_register_x_data_cb(JabberStream *js, xmlnode *result, gpointer data) |
| 616 | { | |
| 617 | xmlnode *query; | |
| 618 | JabberIq *iq; | |
| 619 | ||
| 620 | iq = jabber_iq_new_query(js, JABBER_IQ_SET, "jabber:iq:register"); | |
| 621 | query = xmlnode_get_child(iq->node, "query"); | |
| 622 | ||
| 623 | xmlnode_insert_child(query, result); | |
| 624 | ||
| 625 | jabber_iq_set_callback(iq, jabber_registration_result_cb, NULL); | |
| 626 | jabber_iq_send(iq); | |
| 627 | } | |
| 628 | ||
| 7072 | 629 | void jabber_register_parse(JabberStream *js, xmlnode *packet) |
| 630 | { | |
| 631 | if(js->registration) { | |
| 632 | GaimRequestFields *fields; | |
| 633 | GaimRequestFieldGroup *group; | |
| 634 | GaimRequestField *field; | |
| 7923 | 635 | xmlnode *query, *x, *y; |
| 7072 | 636 | char *instructions; |
| 637 | ||
| 638 | /* get rid of the login thingy */ | |
| 639 | gaim_connection_set_state(js->gc, GAIM_CONNECTED); | |
| 640 | ||
| 641 | query = xmlnode_get_child(packet, "query"); | |
| 642 | ||
| 643 | if(xmlnode_get_child(query, "registered")) { | |
| 644 | gaim_notify_error(NULL, _("Already Registered"), | |
| 645 | _("Already Registered"), NULL); | |
| 646 | jabber_connection_schedule_close(js); | |
| 647 | return; | |
| 648 | } | |
| 649 | ||
| 8398 | 650 | if((x = xmlnode_get_child_with_namespace(packet, "x", |
| 651 | "jabber:x:data"))) { | |
| 652 | jabber_x_data_request(js, x, jabber_register_x_data_cb, NULL); | |
| 653 | return; | |
| 654 | } else if((x = xmlnode_get_child_with_namespace(packet, "x", | |
| 655 | "jabber:x:oob"))) { | |
| 656 | xmlnode *url; | |
| 7923 | 657 | |
| 8398 | 658 | if((url = xmlnode_get_child(x, "url"))) { |
| 659 | char *href; | |
| 660 | if((href = xmlnode_get_data(url))) { | |
|
10240
09342bc554d9
[gaim-migrate @ 11377]
Herman Bloggs <herman@bluedigits.com>
parents:
10216
diff
changeset
|
661 | gaim_notify_uri(NULL, href); |
| 8398 | 662 | g_free(href); |
| 663 | js->gc->wants_to_die = TRUE; | |
| 664 | jabber_connection_schedule_close(js); | |
| 665 | return; | |
| 666 | } | |
| 7923 | 667 | } |
| 668 | } | |
| 669 | ||
| 670 | /* as a last resort, use the old jabber:iq:register syntax */ | |
| 671 | ||
| 7072 | 672 | fields = gaim_request_fields_new(); |
| 673 | group = gaim_request_field_group_new(NULL); | |
| 674 | gaim_request_fields_add_group(fields, group); | |
| 675 | ||
| 676 | field = gaim_request_field_string_new("username", _("Username"), | |
| 677 | js->user->node, FALSE); | |
| 678 | gaim_request_field_group_add_field(group, field); | |
| 679 | ||
| 680 | field = gaim_request_field_string_new("password", _("Password"), | |
|
10740
a1cb6b819a21
[gaim-migrate @ 12342]
Mark Doliner <markdoliner@pidgin.im>
parents:
10504
diff
changeset
|
681 | gaim_connection_get_password(js->gc), FALSE); |
| 7072 | 682 | gaim_request_field_string_set_masked(field, TRUE); |
| 683 | gaim_request_field_group_add_field(group, field); | |
| 684 | ||
| 685 | if(xmlnode_get_child(query, "name")) { | |
| 686 | field = gaim_request_field_string_new("name", _("Name"), | |
| 687 | gaim_account_get_alias(js->gc->account), FALSE); | |
| 688 | gaim_request_field_group_add_field(group, field); | |
| 689 | } | |
| 690 | if(xmlnode_get_child(query, "email")) { | |
| 691 | field = gaim_request_field_string_new("email", _("E-Mail"), | |
| 692 | NULL, FALSE); | |
| 693 | gaim_request_field_group_add_field(group, field); | |
| 694 | } | |
| 695 | if(xmlnode_get_child(query, "nick")) { | |
| 696 | field = gaim_request_field_string_new("nick", _("Nickname"), | |
| 697 | NULL, FALSE); | |
| 698 | gaim_request_field_group_add_field(group, field); | |
| 699 | } | |
| 700 | if(xmlnode_get_child(query, "first")) { | |
| 701 | field = gaim_request_field_string_new("first", _("First Name"), | |
| 702 | NULL, FALSE); | |
| 703 | gaim_request_field_group_add_field(group, field); | |
| 704 | } | |
| 705 | if(xmlnode_get_child(query, "last")) { | |
| 706 | field = gaim_request_field_string_new("last", _("Last Name"), | |
| 707 | NULL, FALSE); | |
| 708 | gaim_request_field_group_add_field(group, field); | |
| 709 | } | |
| 710 | if(xmlnode_get_child(query, "address")) { | |
| 711 | field = gaim_request_field_string_new("address", _("Address"), | |
| 712 | NULL, FALSE); | |
| 713 | gaim_request_field_group_add_field(group, field); | |
| 714 | } | |
| 715 | if(xmlnode_get_child(query, "city")) { | |
| 716 | field = gaim_request_field_string_new("city", _("City"), | |
| 717 | NULL, FALSE); | |
| 718 | gaim_request_field_group_add_field(group, field); | |
| 719 | } | |
| 720 | if(xmlnode_get_child(query, "state")) { | |
| 721 | field = gaim_request_field_string_new("state", _("State"), | |
| 722 | NULL, FALSE); | |
| 723 | gaim_request_field_group_add_field(group, field); | |
| 724 | } | |
| 725 | if(xmlnode_get_child(query, "zip")) { | |
| 726 | field = gaim_request_field_string_new("zip", _("Postal Code"), | |
| 727 | NULL, FALSE); | |
| 728 | gaim_request_field_group_add_field(group, field); | |
| 729 | } | |
| 730 | if(xmlnode_get_child(query, "phone")) { | |
| 731 | field = gaim_request_field_string_new("phone", _("Phone"), | |
| 732 | NULL, FALSE); | |
| 733 | gaim_request_field_group_add_field(group, field); | |
| 734 | } | |
| 735 | if(xmlnode_get_child(query, "url")) { | |
| 736 | field = gaim_request_field_string_new("url", _("URL"), | |
| 737 | NULL, FALSE); | |
| 738 | gaim_request_field_group_add_field(group, field); | |
| 739 | } | |
| 740 | if(xmlnode_get_child(query, "date")) { | |
| 741 | field = gaim_request_field_string_new("date", _("Date"), | |
| 742 | NULL, FALSE); | |
| 743 | gaim_request_field_group_add_field(group, field); | |
| 744 | } | |
| 745 | ||
| 746 | if((y = xmlnode_get_child(query, "instructions"))) | |
| 747 | instructions = xmlnode_get_data(y); | |
| 748 | else | |
| 749 | instructions = g_strdup(_("Please fill out the information below " | |
| 750 | "to register your new account.")); | |
| 751 | ||
| 752 | gaim_request_fields(js->gc, _("Register New Jabber Account"), | |
| 753 | _("Register New Jabber Account"), instructions, fields, | |
| 754 | _("Register"), G_CALLBACK(jabber_register_cb), | |
| 755 | _("Cancel"), G_CALLBACK(jabber_register_cancel_cb), js); | |
| 756 | } | |
| 757 | } | |
| 758 | ||
| 8016 | 759 | void jabber_register_start(JabberStream *js) |
| 7072 | 760 | { |
| 761 | JabberIq *iq; | |
| 762 | ||
| 763 | iq = jabber_iq_new_query(js, JABBER_IQ_GET, "jabber:iq:register"); | |
| 764 | jabber_iq_send(iq); | |
| 765 | } | |
| 766 | ||
| 767 | static void jabber_register_account(GaimAccount *account) | |
| 768 | { | |
| 769 | GaimConnection *gc = gaim_account_get_connection(account); | |
| 770 | JabberStream *js; | |
| 10289 | 771 | JabberBuddy *my_jb = NULL; |
| 7072 | 772 | const char *connect_server = gaim_account_get_string(account, |
| 773 | "connect_server", ""); | |
| 774 | const char *server; | |
| 775 | int rc; | |
| 776 | ||
| 777 | js = gc->proto_data = g_new0(JabberStream, 1); | |
| 778 | js->gc = gc; | |
| 779 | js->registration = TRUE; | |
| 8312 | 780 | js->iq_callbacks = g_hash_table_new_full(g_str_hash, g_str_equal, |
| 781 | g_free, g_free); | |
| 782 | js->disco_callbacks = g_hash_table_new_full(g_str_hash, g_str_equal, | |
| 7395 | 783 | g_free, g_free); |
| 7072 | 784 | js->user = jabber_id_new(gaim_account_get_username(account)); |
| 7322 | 785 | js->next_id = g_random_int(); |
| 7072 | 786 | |
| 7310 | 787 | if(!js->user) { |
| 788 | gaim_connection_error(gc, _("Invalid Jabber ID")); | |
| 789 | return; | |
| 790 | } | |
| 791 | ||
| 7147 | 792 | if(!js->user->resource) { |
| 793 | char *me; | |
| 11939 | 794 | js->user->resource = g_strdup("Home"); |
| 7147 | 795 | if(!js->user->node) { |
| 796 | js->user->node = js->user->domain; | |
| 797 | js->user->domain = g_strdup("jabber.org"); | |
| 798 | } | |
| 799 | me = g_strdup_printf("%s@%s/%s", js->user->node, js->user->domain, | |
| 800 | js->user->resource); | |
| 801 | gaim_account_set_username(account, me); | |
| 802 | g_free(me); | |
| 803 | } | |
| 804 | ||
| 10289 | 805 | if((my_jb = jabber_buddy_find(js, gaim_account_get_username(account), TRUE))) |
| 806 | my_jb->subscription |= JABBER_SUB_BOTH; | |
| 807 | ||
| 7072 | 808 | server = connect_server[0] ? connect_server : js->user->domain; |
| 809 | ||
| 810 | jabber_stream_set_state(js, JABBER_STREAM_CONNECTING); | |
| 811 | ||
| 7630 | 812 | if(gaim_account_get_bool(account, "old_ssl", FALSE)) { |
| 813 | if(gaim_ssl_is_supported()) { | |
| 814 | js->gsc = gaim_ssl_connect(account, server, | |
| 815 | gaim_account_get_int(account, "port", 5222), | |
| 816 | jabber_login_callback_ssl, jabber_ssl_connect_failure, gc); | |
| 817 | } else { | |
| 818 | gaim_connection_error(gc, _("SSL support unavailable")); | |
| 819 | } | |
| 7072 | 820 | } |
| 821 | ||
| 822 | if(!js->gsc) { | |
| 823 | rc = gaim_proxy_connect(account, server, | |
| 824 | gaim_account_get_int(account, "port", 5222), | |
| 825 | jabber_login_callback, gc); | |
| 826 | ||
| 827 | if (rc != 0) | |
| 828 | gaim_connection_error(gc, _("Unable to create socket")); | |
| 829 | } | |
| 830 | } | |
| 831 | ||
| 5572 | 832 | static void jabber_close(GaimConnection *gc) |
| 2086 | 833 | { |
| 7014 | 834 | JabberStream *js = gc->proto_data; |
| 2956 | 835 | |
| 7642 | 836 | jabber_send_raw(js, "</stream:stream>", -1); |
| 3311 | 837 | |
| 7014 | 838 | if(js->gsc) { |
| 839 | gaim_ssl_close(js->gsc); | |
| 8360 | 840 | } else if (js->fd > 0) { |
| 7072 | 841 | if(js->gc->inpa) |
| 842 | gaim_input_remove(js->gc->inpa); | |
| 7014 | 843 | close(js->fd); |
| 844 | } | |
| 3311 | 845 | |
| 7587 | 846 | if(js->context) |
| 847 | g_markup_parse_context_free(js->context); | |
| 8312 | 848 | if(js->iq_callbacks) |
| 849 | g_hash_table_destroy(js->iq_callbacks); | |
| 850 | if(js->disco_callbacks) | |
| 851 | g_hash_table_destroy(js->disco_callbacks); | |
| 7072 | 852 | if(js->buddies) |
| 853 | g_hash_table_destroy(js->buddies); | |
| 854 | if(js->chats) | |
| 855 | g_hash_table_destroy(js->chats); | |
| 8043 | 856 | while(js->chat_servers) { |
| 857 | g_free(js->chat_servers->data); | |
| 858 | js->chat_servers = g_list_delete_link(js->chat_servers, js->chat_servers); | |
| 859 | } | |
| 11675 | 860 | while(js->user_directories) { |
| 861 | g_free(js->user_directories->data); | |
| 862 | js->user_directories = g_list_delete_link(js->user_directories, js->user_directories); | |
| 863 | } | |
| 7014 | 864 | if(js->stream_id) |
| 865 | g_free(js->stream_id); | |
| 7587 | 866 | if(js->user) |
| 867 | jabber_id_free(js->user); | |
| 10189 | 868 | if(js->avatar_hash) |
| 869 | g_free(js->avatar_hash); | |
| 12508 | 870 | #ifdef HAVE_CYRUS_SASL |
| 871 | if(js->sasl) | |
| 872 | sasl_dispose(&js->sasl); | |
| 873 | if(js->sasl_mechs) | |
| 874 | g_string_free(js->sasl_mechs, TRUE); | |
| 875 | if(js->sasl_cb) | |
| 876 | g_free(js->sasl_cb); | |
| 877 | #endif | |
| 7014 | 878 | g_free(js); |
|
11389
c1e05b75b0b0
[gaim-migrate @ 13617]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
11387
diff
changeset
|
879 | |
|
c1e05b75b0b0
[gaim-migrate @ 13617]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
11387
diff
changeset
|
880 | gc->proto_data = NULL; |
| 5093 | 881 | } |
| 882 | ||
| 7014 | 883 | void jabber_stream_set_state(JabberStream *js, JabberStreamState state) |
|
3105
8c23b0ec1036
[gaim-migrate @ 3119]
Jim Seymour <jseymour@users.sourceforge.net>
parents:
3074
diff
changeset
|
884 | { |
| 9954 | 885 | GaimPresence *gpresence; |
| 886 | GaimStatus *status; | |
| 887 | ||
| 7014 | 888 | js->state = state; |
| 889 | switch(state) { | |
| 890 | case JABBER_STREAM_OFFLINE: | |
| 891 | break; | |
| 892 | case JABBER_STREAM_CONNECTING: | |
| 893 | gaim_connection_update_progress(js->gc, _("Connecting"), 1, | |
| 894 | JABBER_CONNECT_STEPS); | |
| 895 | break; | |
| 896 | case JABBER_STREAM_INITIALIZING: | |
| 897 | gaim_connection_update_progress(js->gc, _("Initializing Stream"), | |
| 898 | js->gsc ? 5 : 2, JABBER_CONNECT_STEPS); | |
| 899 | jabber_stream_init(js); | |
| 900 | jabber_parser_setup(js); | |
| 901 | break; | |
| 902 | case JABBER_STREAM_AUTHENTICATING: | |
| 903 | gaim_connection_update_progress(js->gc, _("Authenticating"), | |
| 904 | js->gsc ? 6 : 3, JABBER_CONNECT_STEPS); | |
| 8296 | 905 | if(js->protocol_version == JABBER_PROTO_0_9 && js->registration) { |
| 906 | jabber_register_start(js); | |
| 907 | } else if(js->auth_type == JABBER_AUTH_IQ_AUTH) { | |
| 908 | jabber_auth_start_old(js); | |
| 8016 | 909 | } |
| 7014 | 910 | break; |
| 911 | case JABBER_STREAM_REINITIALIZING: | |
| 912 | gaim_connection_update_progress(js->gc, _("Re-initializing Stream"), | |
| 913 | 6, JABBER_CONNECT_STEPS); | |
| 914 | jabber_stream_init(js); | |
| 915 | break; | |
| 916 | case JABBER_STREAM_CONNECTED: | |
| 917 | jabber_roster_request(js); | |
| 9954 | 918 | gpresence = gaim_account_get_presence(js->gc->account); |
| 919 | status = gaim_presence_get_active_status(gpresence); | |
| 10216 | 920 | jabber_presence_send(js->gc->account, status); |
| 10941 | 921 | gaim_connection_set_state(js->gc, GAIM_CONNECTED); |
| 8312 | 922 | jabber_disco_items_server(js); |
| 7014 | 923 | break; |
|
3105
8c23b0ec1036
[gaim-migrate @ 3119]
Jim Seymour <jseymour@users.sourceforge.net>
parents:
3074
diff
changeset
|
924 | } |
|
8c23b0ec1036
[gaim-migrate @ 3119]
Jim Seymour <jseymour@users.sourceforge.net>
parents:
3074
diff
changeset
|
925 | } |
|
8c23b0ec1036
[gaim-migrate @ 3119]
Jim Seymour <jseymour@users.sourceforge.net>
parents:
3074
diff
changeset
|
926 | |
| 7014 | 927 | char *jabber_get_next_id(JabberStream *js) |
| 2086 | 928 | { |
| 7322 | 929 | return g_strdup_printf("gaim%x", js->next_id++); |
| 2086 | 930 | } |
| 931 | ||
| 7923 | 932 | |
| 933 | static void jabber_idle_set(GaimConnection *gc, int idle) | |
|
3340
7e59a209931d
[gaim-migrate @ 3359]
Jim Seymour <jseymour@users.sourceforge.net>
parents:
3337
diff
changeset
|
934 | { |
| 7014 | 935 | JabberStream *js = gc->proto_data; |
|
3340
7e59a209931d
[gaim-migrate @ 3359]
Jim Seymour <jseymour@users.sourceforge.net>
parents:
3337
diff
changeset
|
936 | |
| 7014 | 937 | js->idle = idle ? time(NULL) - idle : idle; |
|
3314
12fa45677717
[gaim-migrate @ 3332]
Jim Seymour <jseymour@users.sourceforge.net>
parents:
3311
diff
changeset
|
938 | } |
|
12fa45677717
[gaim-migrate @ 3332]
Jim Seymour <jseymour@users.sourceforge.net>
parents:
3311
diff
changeset
|
939 | |
| 6695 | 940 | static const char *jabber_list_icon(GaimAccount *a, GaimBuddy *b) |
| 2086 | 941 | { |
| 4687 | 942 | return "jabber"; |
| 943 | } | |
| 4916 | 944 | |
| 9954 | 945 | static void jabber_list_emblems(GaimBuddy *b, const char **se, const char **sw, |
| 946 | const char **nw, const char **ne) | |
| 4916 | 947 | { |
| 7014 | 948 | JabberStream *js; |
| 949 | JabberBuddy *jb; | |
| 950 | ||
| 951 | if(!b->account->gc) | |
| 952 | return; | |
| 953 | js = b->account->gc->proto_data; | |
| 954 | jb = jabber_buddy_find(js, b->name, FALSE); | |
| 5135 | 955 | |
| 956 | if(!GAIM_BUDDY_IS_ONLINE(b)) { | |
| 7014 | 957 | if(jb && jb->error_msg) |
| 4927 | 958 | *nw = "error"; |
| 5135 | 959 | |
| 7014 | 960 | if(jb && (jb->subscription & JABBER_SUB_PENDING || |
| 961 | !(jb->subscription & JABBER_SUB_TO))) | |
| 5135 | 962 | *se = "notauthorized"; |
| 963 | else | |
| 964 | *se = "offline"; | |
| 4916 | 965 | } else { |
| 9954 | 966 | GaimStatusType *status_type = gaim_status_get_type(gaim_presence_get_active_status(gaim_buddy_get_presence(b))); |
|
12595
8108c22aa723
[gaim-migrate @ 14925]
Richard Laager <rlaager@pidgin.im>
parents:
12554
diff
changeset
|
967 | GaimStatusPrimitive primitive = gaim_status_type_get_primitive(status_type); |
| 9954 | 968 | |
|
12595
8108c22aa723
[gaim-migrate @ 14925]
Richard Laager <rlaager@pidgin.im>
parents:
12554
diff
changeset
|
969 | if(primitive > GAIM_STATUS_AVAILABLE) { |
| 9954 | 970 | *se = gaim_status_type_get_id(status_type); |
| 4916 | 971 | } |
| 2086 | 972 | } |
| 4916 | 973 | } |
| 2086 | 974 | |
| 7014 | 975 | static char *jabber_status_text(GaimBuddy *b) |
|
2205
68c42ce8eba6
[gaim-migrate @ 2215]
Eric Warmenhoven <warmenhoven@yahoo.com>
parents:
2170
diff
changeset
|
976 | { |
| 7014 | 977 | JabberBuddy *jb = jabber_buddy_find(b->account->gc->proto_data, b->name, |
| 978 | FALSE); | |
| 979 | char *ret = NULL; | |
| 5234 | 980 | |
| 7014 | 981 | if(jb && !GAIM_BUDDY_IS_ONLINE(b) && (jb->subscription & JABBER_SUB_PENDING || !(jb->subscription & JABBER_SUB_TO))) { |
| 982 | ret = g_strdup(_("Not Authorized")); | |
| 983 | } else if(jb && !GAIM_BUDDY_IS_ONLINE(b) && jb->error_msg) { | |
| 984 | ret = g_strdup(jb->error_msg); | |
| 2956 | 985 | } else { |
|
7095
17d2b54254f8
[gaim-migrate @ 7660]
Christian Hammond <chipx86@chipx86.com>
parents:
7072
diff
changeset
|
986 | char *stripped; |
|
17d2b54254f8
[gaim-migrate @ 7660]
Christian Hammond <chipx86@chipx86.com>
parents:
7072
diff
changeset
|
987 | |
| 9954 | 988 | if(!(stripped = gaim_markup_strip_html(jabber_buddy_get_status_msg(jb)))) { |
| 989 | GaimStatus *status = gaim_presence_get_active_status(gaim_buddy_get_presence(b)); | |
| 2956 | 990 | |
| 9954 | 991 | if(!gaim_status_is_available(status)) |
| 992 | stripped = g_strdup(gaim_status_get_name(status)); | |
| 993 | } | |
| 2086 | 994 | |
| 7014 | 995 | if(stripped) { |
| 996 | ret = g_markup_escape_text(stripped, -1); | |
| 997 | g_free(stripped); | |
| 998 | } | |
| 2086 | 999 | } |
| 1000 | ||
| 7014 | 1001 | return ret; |
| 2956 | 1002 | } |
| 1003 | ||
| 6695 | 1004 | static char *jabber_tooltip_text(GaimBuddy *b) |
| 4744 | 1005 | { |
| 11609 | 1006 | JabberBuddy *jb; |
| 1007 | GString *ret; | |
| 1008 | ||
| 1009 | g_return_val_if_fail(b != NULL, NULL); | |
| 1010 | g_return_val_if_fail(b->account != NULL, NULL); | |
| 1011 | g_return_val_if_fail(b->account->gc != NULL, NULL); | |
| 1012 | g_return_val_if_fail(b->account->gc->proto_data != NULL, NULL); | |
| 1013 | ||
| 1014 | jb = jabber_buddy_find(b->account->gc->proto_data, b->name, | |
| 7014 | 1015 | FALSE); |
| 11609 | 1016 | ret = g_string_new(""); |
| 7014 | 1017 | |
| 8194 | 1018 | if(jb) { |
| 11609 | 1019 | JabberBuddyResource *jbr = NULL; |
| 8194 | 1020 | const char *sub; |
| 11609 | 1021 | GList *l; |
| 1022 | ||
| 8194 | 1023 | if(jb->subscription & JABBER_SUB_FROM) { |
| 1024 | if(jb->subscription & JABBER_SUB_TO) | |
| 1025 | sub = _("Both"); | |
| 1026 | else if(jb->subscription & JABBER_SUB_PENDING) | |
| 1027 | sub = _("From (To pending)"); | |
| 1028 | else | |
| 1029 | sub = _("From"); | |
| 1030 | } else { | |
| 1031 | if(jb->subscription & JABBER_SUB_TO) | |
| 1032 | sub = _("To"); | |
| 1033 | else if(jb->subscription & JABBER_SUB_PENDING) | |
| 1034 | sub = _("None (To pending)"); | |
| 1035 | else | |
| 1036 | sub = _("None"); | |
| 1037 | } | |
|
8591
ae42ad1cd127
[gaim-migrate @ 9342]
Mark Doliner <markdoliner@pidgin.im>
parents:
8589
diff
changeset
|
1038 | g_string_append_printf(ret, "\n<b>%s:</b> %s", _("Subscription"), sub); |
| 8194 | 1039 | |
| 11609 | 1040 | for(l=jb->resources; l; l = l->next) { |
| 8194 | 1041 | char *text = NULL; |
| 11609 | 1042 | char *res = NULL; |
| 1043 | ||
| 1044 | jbr = l->data; | |
| 1045 | ||
| 8194 | 1046 | if(jbr->status) { |
| 11646 | 1047 | char *tmp; |
| 1048 | text = gaim_strreplace(jbr->status, "\n", "<br />\n"); | |
| 1049 | tmp = gaim_markup_strip_html(text); | |
| 1050 | g_free(text); | |
| 1051 | text = g_markup_escape_text(tmp, -1); | |
| 1052 | g_free(tmp); | |
| 8194 | 1053 | } |
| 1054 | ||
| 11609 | 1055 | if(jbr->name) |
| 11610 | 1056 | res = g_strdup_printf(" (%s)", jbr->name); |
| 11609 | 1057 | |
| 1058 | g_string_append_printf(ret, "\n<b>%s%s:</b> %s%s%s", | |
| 8194 | 1059 | _("Status"), |
| 11609 | 1060 | res ? res : "", |
| 9954 | 1061 | jabber_buddy_state_get_name(jbr->state), |
| 8194 | 1062 | text ? ": " : "", |
| 1063 | text ? text : ""); | |
| 1064 | if(text) | |
| 1065 | g_free(text); | |
| 11609 | 1066 | if(res) |
| 1067 | g_free(res); | |
| 1068 | } | |
| 1069 | ||
| 1070 | if(!GAIM_BUDDY_IS_ONLINE(b) && jb->error_msg) { | |
|
8591
ae42ad1cd127
[gaim-migrate @ 9342]
Mark Doliner <markdoliner@pidgin.im>
parents:
8589
diff
changeset
|
1071 | g_string_append_printf(ret, "\n<b>%s:</b> %s", |
| 8194 | 1072 | _("Error"), jb->error_msg); |
| 1073 | } | |
| 4745 | 1074 | } |
| 4744 | 1075 | |
|
8591
ae42ad1cd127
[gaim-migrate @ 9342]
Mark Doliner <markdoliner@pidgin.im>
parents:
8589
diff
changeset
|
1076 | return g_string_free(ret, FALSE); |
| 4732 | 1077 | } |
| 1078 | ||
| 9954 | 1079 | static GList *jabber_status_types(GaimAccount *account) |
| 7014 | 1080 | { |
| 9954 | 1081 | GaimStatusType *type; |
| 1082 | GList *types = NULL; | |
| 11568 | 1083 | GaimValue *priority_value; |
| 9954 | 1084 | |
|
12595
8108c22aa723
[gaim-migrate @ 14925]
Richard Laager <rlaager@pidgin.im>
parents:
12554
diff
changeset
|
1085 | type = gaim_status_type_new_with_attrs(GAIM_STATUS_OFFLINE, |
|
8108c22aa723
[gaim-migrate @ 14925]
Richard Laager <rlaager@pidgin.im>
parents:
12554
diff
changeset
|
1086 | jabber_buddy_state_get_status_id(JABBER_BUDDY_STATE_UNAVAILABLE), |
|
8108c22aa723
[gaim-migrate @ 14925]
Richard Laager <rlaager@pidgin.im>
parents:
12554
diff
changeset
|
1087 | NULL, FALSE, TRUE, FALSE, |
|
8108c22aa723
[gaim-migrate @ 14925]
Richard Laager <rlaager@pidgin.im>
parents:
12554
diff
changeset
|
1088 | "message", _("Message"), gaim_value_new(GAIM_TYPE_STRING), |
|
8108c22aa723
[gaim-migrate @ 14925]
Richard Laager <rlaager@pidgin.im>
parents:
12554
diff
changeset
|
1089 | NULL); |
| 9954 | 1090 | types = g_list_append(types, type); |
| 1091 | ||
| 11568 | 1092 | priority_value = gaim_value_new(GAIM_TYPE_INT); |
| 11569 | 1093 | gaim_value_set_int(priority_value, 1); |
|
12595
8108c22aa723
[gaim-migrate @ 14925]
Richard Laager <rlaager@pidgin.im>
parents:
12554
diff
changeset
|
1094 | type = gaim_status_type_new_with_attrs(GAIM_STATUS_AVAILABLE, |
|
8108c22aa723
[gaim-migrate @ 14925]
Richard Laager <rlaager@pidgin.im>
parents:
12554
diff
changeset
|
1095 | jabber_buddy_state_get_status_id(JABBER_BUDDY_STATE_ONLINE), |
|
8108c22aa723
[gaim-migrate @ 14925]
Richard Laager <rlaager@pidgin.im>
parents:
12554
diff
changeset
|
1096 | NULL, TRUE, TRUE, FALSE, |
|
8108c22aa723
[gaim-migrate @ 14925]
Richard Laager <rlaager@pidgin.im>
parents:
12554
diff
changeset
|
1097 | "priority", _("Priority"), priority_value, |
|
8108c22aa723
[gaim-migrate @ 14925]
Richard Laager <rlaager@pidgin.im>
parents:
12554
diff
changeset
|
1098 | "message", _("Message"), gaim_value_new(GAIM_TYPE_STRING), |
|
8108c22aa723
[gaim-migrate @ 14925]
Richard Laager <rlaager@pidgin.im>
parents:
12554
diff
changeset
|
1099 | NULL); |
| 9980 | 1100 | types = g_list_append(types, type); |
| 1101 | ||
| 11568 | 1102 | priority_value = gaim_value_new(GAIM_TYPE_INT); |
| 11569 | 1103 | gaim_value_set_int(priority_value, 1); |
|
12595
8108c22aa723
[gaim-migrate @ 14925]
Richard Laager <rlaager@pidgin.im>
parents:
12554
diff
changeset
|
1104 | type = gaim_status_type_new_with_attrs(GAIM_STATUS_AVAILABLE, |
|
8108c22aa723
[gaim-migrate @ 14925]
Richard Laager <rlaager@pidgin.im>
parents:
12554
diff
changeset
|
1105 | jabber_buddy_state_get_status_id(JABBER_BUDDY_STATE_CHAT), |
|
8108c22aa723
[gaim-migrate @ 14925]
Richard Laager <rlaager@pidgin.im>
parents:
12554
diff
changeset
|
1106 | _("Chatty"), TRUE, TRUE, FALSE, |
|
8108c22aa723
[gaim-migrate @ 14925]
Richard Laager <rlaager@pidgin.im>
parents:
12554
diff
changeset
|
1107 | "priority", _("Priority"), priority_value, |
|
8108c22aa723
[gaim-migrate @ 14925]
Richard Laager <rlaager@pidgin.im>
parents:
12554
diff
changeset
|
1108 | "message", _("Message"), gaim_value_new(GAIM_TYPE_STRING), |
|
8108c22aa723
[gaim-migrate @ 14925]
Richard Laager <rlaager@pidgin.im>
parents:
12554
diff
changeset
|
1109 | NULL); |
| 9954 | 1110 | types = g_list_append(types, type); |
| 2086 | 1111 | |
| 11568 | 1112 | priority_value = gaim_value_new(GAIM_TYPE_INT); |
| 11569 | 1113 | gaim_value_set_int(priority_value, 0); |
|
12595
8108c22aa723
[gaim-migrate @ 14925]
Richard Laager <rlaager@pidgin.im>
parents:
12554
diff
changeset
|
1114 | type = gaim_status_type_new_with_attrs(GAIM_STATUS_AWAY, |
|
8108c22aa723
[gaim-migrate @ 14925]
Richard Laager <rlaager@pidgin.im>
parents:
12554
diff
changeset
|
1115 | jabber_buddy_state_get_status_id(JABBER_BUDDY_STATE_AWAY), |
|
8108c22aa723
[gaim-migrate @ 14925]
Richard Laager <rlaager@pidgin.im>
parents:
12554
diff
changeset
|
1116 | NULL, TRUE, TRUE, FALSE, |
|
8108c22aa723
[gaim-migrate @ 14925]
Richard Laager <rlaager@pidgin.im>
parents:
12554
diff
changeset
|
1117 | "priority", _("Priority"), priority_value, |
|
8108c22aa723
[gaim-migrate @ 14925]
Richard Laager <rlaager@pidgin.im>
parents:
12554
diff
changeset
|
1118 | "message", _("Message"), gaim_value_new(GAIM_TYPE_STRING), |
|
8108c22aa723
[gaim-migrate @ 14925]
Richard Laager <rlaager@pidgin.im>
parents:
12554
diff
changeset
|
1119 | NULL); |
| 9954 | 1120 | types = g_list_append(types, type); |
| 1121 | ||
| 11568 | 1122 | priority_value = gaim_value_new(GAIM_TYPE_INT); |
| 11569 | 1123 | gaim_value_set_int(priority_value, 0); |
|
12595
8108c22aa723
[gaim-migrate @ 14925]
Richard Laager <rlaager@pidgin.im>
parents:
12554
diff
changeset
|
1124 | type = gaim_status_type_new_with_attrs(GAIM_STATUS_EXTENDED_AWAY, |
|
8108c22aa723
[gaim-migrate @ 14925]
Richard Laager <rlaager@pidgin.im>
parents:
12554
diff
changeset
|
1125 | jabber_buddy_state_get_status_id(JABBER_BUDDY_STATE_XA), |
|
8108c22aa723
[gaim-migrate @ 14925]
Richard Laager <rlaager@pidgin.im>
parents:
12554
diff
changeset
|
1126 | NULL, TRUE, TRUE, FALSE, |
|
8108c22aa723
[gaim-migrate @ 14925]
Richard Laager <rlaager@pidgin.im>
parents:
12554
diff
changeset
|
1127 | "priority", _("Priority"), priority_value, |
|
8108c22aa723
[gaim-migrate @ 14925]
Richard Laager <rlaager@pidgin.im>
parents:
12554
diff
changeset
|
1128 | "message", _("Message"), gaim_value_new(GAIM_TYPE_STRING), |
|
8108c22aa723
[gaim-migrate @ 14925]
Richard Laager <rlaager@pidgin.im>
parents:
12554
diff
changeset
|
1129 | NULL); |
| 9954 | 1130 | types = g_list_append(types, type); |
| 1131 | ||
| 11568 | 1132 | priority_value = gaim_value_new(GAIM_TYPE_INT); |
| 11569 | 1133 | gaim_value_set_int(priority_value, 0); |
|
12595
8108c22aa723
[gaim-migrate @ 14925]
Richard Laager <rlaager@pidgin.im>
parents:
12554
diff
changeset
|
1134 | type = gaim_status_type_new_with_attrs(GAIM_STATUS_UNAVAILABLE, |
|
8108c22aa723
[gaim-migrate @ 14925]
Richard Laager <rlaager@pidgin.im>
parents:
12554
diff
changeset
|
1135 | jabber_buddy_state_get_status_id(JABBER_BUDDY_STATE_DND), |
|
8108c22aa723
[gaim-migrate @ 14925]
Richard Laager <rlaager@pidgin.im>
parents:
12554
diff
changeset
|
1136 | _("Do Not Disturb"), TRUE, TRUE, FALSE, |
|
8108c22aa723
[gaim-migrate @ 14925]
Richard Laager <rlaager@pidgin.im>
parents:
12554
diff
changeset
|
1137 | "priority", _("Priority"), priority_value, |
|
8108c22aa723
[gaim-migrate @ 14925]
Richard Laager <rlaager@pidgin.im>
parents:
12554
diff
changeset
|
1138 | "message", _("Message"), gaim_value_new(GAIM_TYPE_STRING), |
|
8108c22aa723
[gaim-migrate @ 14925]
Richard Laager <rlaager@pidgin.im>
parents:
12554
diff
changeset
|
1139 | NULL); |
| 9954 | 1140 | types = g_list_append(types, type); |
| 1141 | ||
| 1142 | /* | |
| 8166 | 1143 | if(js->protocol_version == JABBER_PROTO_0_9) |
| 1144 | m = g_list_append(m, _("Invisible")); | |
|
10009
8a4fcc043f47
[gaim-migrate @ 10926]
Mark Doliner <markdoliner@pidgin.im>
parents:
9980
diff
changeset
|
1145 | */ |
| 2086 | 1146 | |
| 9954 | 1147 | return types; |
| 2086 | 1148 | } |
| 1149 | ||
| 7395 | 1150 | static void |
| 1151 | jabber_password_change_result_cb(JabberStream *js, xmlnode *packet, | |
| 1152 | gpointer data) | |
| 7124 | 1153 | { |
| 1154 | const char *type; | |
| 1155 | ||
| 1156 | type = xmlnode_get_attrib(packet, "type"); | |
| 1157 | ||
| 9414 | 1158 | if(type && !strcmp(type, "result")) { |
| 7124 | 1159 | gaim_notify_info(js->gc, _("Password Changed"), _("Password Changed"), |
| 1160 | _("Your password has been changed.")); | |
| 1161 | } else { | |
| 8401 | 1162 | char *msg = jabber_parse_error(js, packet); |
| 7124 | 1163 | |
| 8401 | 1164 | gaim_notify_error(js->gc, _("Error changing password"), |
| 1165 | _("Error changing password"), msg); | |
| 1166 | g_free(msg); | |
| 7124 | 1167 | } |
| 1168 | } | |
| 1169 | ||
| 1170 | static void jabber_password_change_cb(JabberStream *js, | |
| 1171 | GaimRequestFields *fields) | |
| 1172 | { | |
| 1173 | const char *p1, *p2; | |
| 1174 | JabberIq *iq; | |
| 1175 | xmlnode *query, *y; | |
| 1176 | ||
| 1177 | p1 = gaim_request_fields_get_string(fields, "password1"); | |
| 1178 | p2 = gaim_request_fields_get_string(fields, "password2"); | |
| 1179 | ||
| 1180 | if(strcmp(p1, p2)) { | |
| 1181 | gaim_notify_error(js->gc, NULL, _("New passwords do not match."), NULL); | |
| 1182 | return; | |
| 1183 | } | |
| 1184 | ||
| 1185 | iq = jabber_iq_new_query(js, JABBER_IQ_SET, "jabber:iq:register"); | |
| 1186 | ||
| 1187 | xmlnode_set_attrib(iq->node, "to", js->user->domain); | |
| 1188 | ||
| 1189 | query = xmlnode_get_child(iq->node, "query"); | |
| 1190 | ||
| 1191 | y = xmlnode_new_child(query, "username"); | |
| 1192 | xmlnode_insert_data(y, js->user->node, -1); | |
| 1193 | y = xmlnode_new_child(query, "password"); | |
| 1194 | xmlnode_insert_data(y, p1, -1); | |
| 1195 | ||
| 7395 | 1196 | jabber_iq_set_callback(iq, jabber_password_change_result_cb, NULL); |
| 7124 | 1197 | |
| 1198 | jabber_iq_send(iq); | |
| 1199 | ||
| 1200 | gaim_account_set_password(js->gc->account, p1); | |
| 1201 | } | |
| 1202 | ||
|
9015
3c27e9074fa2
[gaim-migrate @ 9791]
Christopher O'Brien <siege@pidgin.im>
parents:
8993
diff
changeset
|
1203 | static void jabber_password_change(GaimPluginAction *action) |
| 7124 | 1204 | { |
|
9015
3c27e9074fa2
[gaim-migrate @ 9791]
Christopher O'Brien <siege@pidgin.im>
parents:
8993
diff
changeset
|
1205 | |
|
3c27e9074fa2
[gaim-migrate @ 9791]
Christopher O'Brien <siege@pidgin.im>
parents:
8993
diff
changeset
|
1206 | GaimConnection *gc = (GaimConnection *) action->context; |
| 7124 | 1207 | JabberStream *js = gc->proto_data; |
| 1208 | GaimRequestFields *fields; | |
| 1209 | GaimRequestFieldGroup *group; | |
| 1210 | GaimRequestField *field; | |
| 1211 | ||
| 1212 | fields = gaim_request_fields_new(); | |
| 1213 | group = gaim_request_field_group_new(NULL); | |
| 1214 | gaim_request_fields_add_group(fields, group); | |
| 1215 | ||
| 1216 | field = gaim_request_field_string_new("password1", _("Password"), | |
| 1217 | "", FALSE); | |
| 1218 | gaim_request_field_string_set_masked(field, TRUE); | |
| 1219 | gaim_request_field_group_add_field(group, field); | |
| 1220 | ||
| 1221 | field = gaim_request_field_string_new("password2", _("Password (again)"), | |
| 1222 | "", FALSE); | |
| 1223 | gaim_request_field_string_set_masked(field, TRUE); | |
| 1224 | gaim_request_field_group_add_field(group, field); | |
| 1225 | ||
| 1226 | gaim_request_fields(js->gc, _("Change Jabber Password"), | |
| 1227 | _("Change Jabber Password"), _("Please enter your new password"), | |
| 1228 | fields, _("OK"), G_CALLBACK(jabber_password_change_cb), | |
| 1229 | _("Cancel"), NULL, js); | |
| 1230 | } | |
| 1231 | ||
|
9015
3c27e9074fa2
[gaim-migrate @ 9791]
Christopher O'Brien <siege@pidgin.im>
parents:
8993
diff
changeset
|
1232 | static GList *jabber_actions(GaimPlugin *plugin, gpointer context) |
| 2956 | 1233 | { |
| 1234 | GList *m = NULL; | |
|
9015
3c27e9074fa2
[gaim-migrate @ 9791]
Christopher O'Brien <siege@pidgin.im>
parents:
8993
diff
changeset
|
1235 | GaimPluginAction *act; |
|
4333
f4c095774bc2
[gaim-migrate @ 4597]
Mark Doliner <markdoliner@pidgin.im>
parents:
4316
diff
changeset
|
1236 | |
|
12243
7400b735e616
[gaim-migrate @ 14545]
Richard Laager <rlaager@pidgin.im>
parents:
12143
diff
changeset
|
1237 | act = gaim_plugin_action_new(_("Set User Info..."), |
| 12286 | 1238 | jabber_setup_set_info); |
|
9015
3c27e9074fa2
[gaim-migrate @ 9791]
Christopher O'Brien <siege@pidgin.im>
parents:
8993
diff
changeset
|
1239 | m = g_list_append(m, act); |
|
4333
f4c095774bc2
[gaim-migrate @ 4597]
Mark Doliner <markdoliner@pidgin.im>
parents:
4316
diff
changeset
|
1240 | |
| 8296 | 1241 | /* if (js->protocol_options & CHANGE_PASSWORD) { */ |
|
12243
7400b735e616
[gaim-migrate @ 14545]
Richard Laager <rlaager@pidgin.im>
parents:
12143
diff
changeset
|
1242 | act = gaim_plugin_action_new(_("Change Password..."), |
| 12286 | 1243 | jabber_password_change); |
|
9015
3c27e9074fa2
[gaim-migrate @ 9791]
Christopher O'Brien <siege@pidgin.im>
parents:
8993
diff
changeset
|
1244 | m = g_list_append(m, act); |
| 8296 | 1245 | /* } */ |
| 2956 | 1246 | |
|
12243
7400b735e616
[gaim-migrate @ 14545]
Richard Laager <rlaager@pidgin.im>
parents:
12143
diff
changeset
|
1247 | act = gaim_plugin_action_new(_("Search for Users..."), |
| 12286 | 1248 | jabber_user_search_begin); |
| 11675 | 1249 | m = g_list_append(m, act); |
| 1250 | ||
| 2956 | 1251 | return m; |
| 1252 | } | |
| 1253 | ||
| 7999 | 1254 | static GaimChat *jabber_find_blist_chat(GaimAccount *account, const char *name) |
| 1255 | { | |
| 1256 | GaimBlistNode *gnode, *cnode; | |
| 1257 | JabberID *jid; | |
| 1258 | ||
| 1259 | if(!(jid = jabber_id_new(name))) | |
| 1260 | return NULL; | |
| 1261 | ||
| 1262 | for(gnode = gaim_get_blist()->root; gnode; gnode = gnode->next) { | |
| 1263 | for(cnode = gnode->child; cnode; cnode = cnode->next) { | |
| 1264 | GaimChat *chat = (GaimChat*)cnode; | |
| 1265 | const char *room, *server; | |
| 1266 | if(!GAIM_BLIST_NODE_IS_CHAT(cnode)) | |
| 1267 | continue; | |
| 1268 | ||
| 1269 | if(chat->account != account) | |
| 8011 | 1270 | continue; |
| 7999 | 1271 | |
| 1272 | if(!(room = g_hash_table_lookup(chat->components, "room"))) | |
| 1273 | continue; | |
| 1274 | if(!(server = g_hash_table_lookup(chat->components, "server"))) | |
| 1275 | continue; | |
| 1276 | ||
| 8158 | 1277 | if(jid->node && jid->domain && |
| 1278 | !g_utf8_collate(room, jid->node) && !g_utf8_collate(server, jid->domain)) { | |
| 7999 | 1279 | jabber_id_free(jid); |
| 1280 | return chat; | |
| 1281 | } | |
| 1282 | } | |
| 1283 | } | |
| 1284 | jabber_id_free(jid); | |
| 1285 | return NULL; | |
| 1286 | } | |
| 1287 | ||
| 8400 | 1288 | static void jabber_convo_closed(GaimConnection *gc, const char *who) |
| 1289 | { | |
| 1290 | JabberStream *js = gc->proto_data; | |
| 1291 | JabberID *jid; | |
| 1292 | JabberBuddy *jb; | |
| 1293 | JabberBuddyResource *jbr; | |
| 1294 | ||
| 1295 | if(!(jid = jabber_id_new(who))) | |
| 1296 | return; | |
| 1297 | ||
| 1298 | if((jb = jabber_buddy_find(js, who, TRUE)) && | |
| 1299 | (jbr = jabber_buddy_find_resource(jb, jid->resource))) { | |
| 1300 | if(jbr->thread_id) { | |
| 1301 | g_free(jbr->thread_id); | |
| 1302 | jbr->thread_id = NULL; | |
| 1303 | } | |
| 1304 | } | |
| 1305 | ||
| 1306 | jabber_id_free(jid); | |
| 1307 | } | |
| 1308 | ||
| 8401 | 1309 | |
| 1310 | char *jabber_parse_error(JabberStream *js, xmlnode *packet) | |
| 1311 | { | |
| 1312 | xmlnode *error; | |
| 1313 | const char *code = NULL, *text = NULL; | |
| 1314 | const char *xmlns = xmlnode_get_attrib(packet, "xmlns"); | |
| 1315 | char *cdata = NULL; | |
| 1316 | ||
| 1317 | if((error = xmlnode_get_child(packet, "error"))) { | |
| 1318 | cdata = xmlnode_get_data(error); | |
| 1319 | code = xmlnode_get_attrib(error, "code"); | |
| 1320 | ||
| 1321 | /* Stanza errors */ | |
| 1322 | if(xmlnode_get_child(error, "bad-request")) { | |
| 1323 | text = _("Bad Request"); | |
| 1324 | } else if(xmlnode_get_child(error, "conflict")) { | |
| 1325 | text = _("Conflict"); | |
| 1326 | } else if(xmlnode_get_child(error, "feature-not-implemented")) { | |
| 1327 | text = _("Feature Not Implemented"); | |
| 1328 | } else if(xmlnode_get_child(error, "forbidden")) { | |
| 1329 | text = _("Forbidden"); | |
| 1330 | } else if(xmlnode_get_child(error, "gone")) { | |
| 1331 | text = _("Gone"); | |
| 1332 | } else if(xmlnode_get_child(error, "internal-server-error")) { | |
| 1333 | text = _("Internal Server Error"); | |
| 1334 | } else if(xmlnode_get_child(error, "item-not-found")) { | |
| 1335 | text = _("Item Not Found"); | |
| 1336 | } else if(xmlnode_get_child(error, "jid-malformed")) { | |
| 1337 | text = _("Malformed Jabber ID"); | |
| 1338 | } else if(xmlnode_get_child(error, "not-acceptable")) { | |
| 1339 | text = _("Not Acceptable"); | |
| 1340 | } else if(xmlnode_get_child(error, "not-allowed")) { | |
| 1341 | text = _("Not Allowed"); | |
| 1342 | } else if(xmlnode_get_child(error, "not-authorized")) { | |
| 1343 | text = _("Not Authorized"); | |
| 1344 | } else if(xmlnode_get_child(error, "payment-required")) { | |
| 1345 | text = _("Payment Required"); | |
| 1346 | } else if(xmlnode_get_child(error, "recipient-unavailable")) { | |
| 1347 | text = _("Recipient Unavailable"); | |
| 1348 | } else if(xmlnode_get_child(error, "redirect")) { | |
| 1349 | /* XXX */ | |
| 1350 | } else if(xmlnode_get_child(error, "registration-required")) { | |
| 1351 | text = _("Registration Required"); | |
| 1352 | } else if(xmlnode_get_child(error, "remote-server-not-found")) { | |
| 1353 | text = _("Remote Server Not Found"); | |
| 1354 | } else if(xmlnode_get_child(error, "remote-server-timeout")) { | |
| 1355 | text = _("Remote Server Timeout"); | |
| 1356 | } else if(xmlnode_get_child(error, "resource-constraint")) { | |
| 1357 | text = _("Server Overloaded"); | |
| 1358 | } else if(xmlnode_get_child(error, "service-unavailable")) { | |
| 1359 | text = _("Service Unavailable"); | |
| 1360 | } else if(xmlnode_get_child(error, "subscription-required")) { | |
| 1361 | text = _("Subscription Required"); | |
| 1362 | } else if(xmlnode_get_child(error, "unexpected-request")) { | |
| 1363 | text = _("Unexpected Request"); | |
| 1364 | } else if(xmlnode_get_child(error, "undefined-condition")) { | |
| 1365 | text = _("Unknown Error"); | |
| 1366 | } | |
| 1367 | } else if(xmlns && !strcmp(xmlns, "urn:ietf:params:xml:ns:xmpp-sasl")) { | |
| 1368 | if(xmlnode_get_child(packet, "aborted")) { | |
| 1369 | js->gc->wants_to_die = TRUE; | |
| 1370 | text = _("Authorization Aborted"); | |
| 1371 | } else if(xmlnode_get_child(error, "incorrect-encoding")) { | |
| 1372 | text = _("Incorrect encoding in authorization"); | |
| 1373 | } else if(xmlnode_get_child(error, "invalid-authzid")) { | |
| 1374 | js->gc->wants_to_die = TRUE; | |
| 1375 | text = _("Invalid authzid"); | |
| 1376 | } else if(xmlnode_get_child(error, "invalid-mechanism")) { | |
| 1377 | js->gc->wants_to_die = TRUE; | |
| 1378 | text = _("Invalid Authorization Mechanism"); | |
| 1379 | } else if(xmlnode_get_child(error, "mechanism-too-weak")) { | |
| 1380 | js->gc->wants_to_die = TRUE; | |
| 1381 | text = _("Authorization mechanism too weak"); | |
| 1382 | } else if(xmlnode_get_child(error, "not-authorized")) { | |
| 1383 | js->gc->wants_to_die = TRUE; | |
| 1384 | text = _("Not Authorized"); | |
| 1385 | } else if(xmlnode_get_child(error, "temporary-auth-failure")) { | |
| 1386 | text = _("Temporary Authentication Failure"); | |
| 1387 | } else { | |
| 1388 | text = _("Authentication Failure"); | |
| 1389 | } | |
| 8402 | 1390 | } else if(!strcmp(packet->name, "stream:error")) { |
| 1391 | if(xmlnode_get_child(packet, "bad-format")) { | |
| 1392 | text = _("Bad Format"); | |
| 1393 | } else if(xmlnode_get_child(packet, "bad-namespace-prefix")) { | |
| 1394 | text = _("Bad Namespace Prefix"); | |
| 1395 | } else if(xmlnode_get_child(packet, "conflict")) { | |
| 1396 | js->gc->wants_to_die = TRUE; | |
| 1397 | text = _("Resource Conflict"); | |
| 1398 | } else if(xmlnode_get_child(packet, "connection-timeout")) { | |
| 1399 | text = _("Connection Timeout"); | |
| 1400 | } else if(xmlnode_get_child(packet, "host-gone")) { | |
| 1401 | text = _("Host Gone"); | |
| 1402 | } else if(xmlnode_get_child(packet, "host-unknown")) { | |
| 1403 | text = _("Host Unknown"); | |
| 1404 | } else if(xmlnode_get_child(packet, "improper-addressing")) { | |
| 1405 | text = _("Improper Addressing"); | |
| 1406 | } else if(xmlnode_get_child(packet, "internal-server-error")) { | |
| 1407 | text = _("Internal Server Error"); | |
| 1408 | } else if(xmlnode_get_child(packet, "invalid-id")) { | |
| 1409 | text = _("Invalid ID"); | |
| 1410 | } else if(xmlnode_get_child(packet, "invalid-namespace")) { | |
| 1411 | text = _("Invalid Namespace"); | |
| 1412 | } else if(xmlnode_get_child(packet, "invalid-xml")) { | |
| 1413 | text = _("Invalid XML"); | |
| 1414 | } else if(xmlnode_get_child(packet, "nonmatching-hosts")) { | |
| 1415 | text = _("Non-matching Hosts"); | |
| 1416 | } else if(xmlnode_get_child(packet, "not-authorized")) { | |
| 1417 | text = _("Not Authorized"); | |
| 1418 | } else if(xmlnode_get_child(packet, "policy-violation")) { | |
| 1419 | text = _("Policy Violation"); | |
| 1420 | } else if(xmlnode_get_child(packet, "remote-connection-failed")) { | |
| 1421 | text = _("Remote Connection Failed"); | |
| 1422 | } else if(xmlnode_get_child(packet, "resource-constraint")) { | |
| 1423 | text = _("Resource Constraint"); | |
| 1424 | } else if(xmlnode_get_child(packet, "restricted-xml")) { | |
| 1425 | text = _("Restricted XML"); | |
| 1426 | } else if(xmlnode_get_child(packet, "see-other-host")) { | |
| 1427 | text = _("See Other Host"); | |
| 1428 | } else if(xmlnode_get_child(packet, "system-shutdown")) { | |
| 1429 | text = _("System Shutdown"); | |
| 1430 | } else if(xmlnode_get_child(packet, "undefined-condition")) { | |
| 1431 | text = _("Undefined Condition"); | |
| 1432 | } else if(xmlnode_get_child(packet, "unsupported-encoding")) { | |
| 1433 | text = _("Unsupported Encoding"); | |
| 1434 | } else if(xmlnode_get_child(packet, "unsupported-stanza-type")) { | |
| 1435 | text = _("Unsupported Stanza Type"); | |
| 1436 | } else if(xmlnode_get_child(packet, "unsupported-version")) { | |
| 1437 | text = _("Unsupported Version"); | |
| 1438 | } else if(xmlnode_get_child(packet, "xml-not-well-formed")) { | |
| 1439 | text = _("XML Not Well Formed"); | |
| 1440 | } else { | |
| 1441 | text = _("Stream Error"); | |
| 1442 | } | |
| 8401 | 1443 | } |
| 1444 | ||
| 1445 | if(text || cdata) { | |
| 1446 | char *ret = g_strdup_printf("%s%s%s", code ? code : "", | |
| 1447 | code ? ": " : "", text ? text : cdata); | |
| 1448 | g_free(cdata); | |
| 1449 | return ret; | |
| 1450 | } else { | |
| 1451 | return NULL; | |
| 1452 | } | |
| 1453 | } | |
| 1454 | ||
| 9130 | 1455 | static GaimCmdRet jabber_cmd_chat_config(GaimConversation *conv, |
| 9597 | 1456 | const char *cmd, char **args, char **error, void *data) |
| 9130 | 1457 | { |
| 1458 | JabberChat *chat = jabber_chat_find_by_conv(conv); | |
| 1459 | jabber_chat_request_room_configure(chat); | |
| 1460 | return GAIM_CMD_RET_OK; | |
| 1461 | } | |
| 1462 | ||
| 1463 | static GaimCmdRet jabber_cmd_chat_register(GaimConversation *conv, | |
| 9597 | 1464 | const char *cmd, char **args, char **error, void *data) |
| 9130 | 1465 | { |
| 1466 | JabberChat *chat = jabber_chat_find_by_conv(conv); | |
| 1467 | jabber_chat_register(chat); | |
| 1468 | return GAIM_CMD_RET_OK; | |
| 1469 | } | |
| 1470 | ||
| 1471 | static GaimCmdRet jabber_cmd_chat_topic(GaimConversation *conv, | |
| 9597 | 1472 | const char *cmd, char **args, char **error, void *data) |
| 9130 | 1473 | { |
| 1474 | JabberChat *chat = jabber_chat_find_by_conv(conv); | |
| 1475 | jabber_chat_change_topic(chat, args ? args[0] : NULL); | |
| 1476 | return GAIM_CMD_RET_OK; | |
| 1477 | } | |
| 1478 | ||
| 1479 | static GaimCmdRet jabber_cmd_chat_nick(GaimConversation *conv, | |
| 9597 | 1480 | const char *cmd, char **args, char **error, void *data) |
| 9130 | 1481 | { |
| 1482 | JabberChat *chat = jabber_chat_find_by_conv(conv); | |
| 1483 | ||
| 1484 | if(!args || !args[0]) | |
| 1485 | return GAIM_CMD_RET_FAILED; | |
| 1486 | ||
| 1487 | jabber_chat_change_nick(chat, args[0]); | |
| 1488 | return GAIM_CMD_RET_OK; | |
| 1489 | } | |
| 1490 | ||
| 1491 | static GaimCmdRet jabber_cmd_chat_part(GaimConversation *conv, | |
| 9597 | 1492 | const char *cmd, char **args, char **error, void *data) |
| 9130 | 1493 | { |
| 1494 | JabberChat *chat = jabber_chat_find_by_conv(conv); | |
| 1495 | jabber_chat_part(chat, args ? args[0] : NULL); | |
| 1496 | return GAIM_CMD_RET_OK; | |
| 1497 | } | |
| 1498 | ||
| 9152 | 1499 | static GaimCmdRet jabber_cmd_chat_ban(GaimConversation *conv, |
| 9597 | 1500 | const char *cmd, char **args, char **error, void *data) |
| 9152 | 1501 | { |
| 1502 | JabberChat *chat = jabber_chat_find_by_conv(conv); | |
| 1503 | ||
| 1504 | if(!args || !args[0]) | |
| 1505 | return GAIM_CMD_RET_FAILED; | |
| 1506 | ||
| 1507 | if(!jabber_chat_ban_user(chat, args[0], args[1])) { | |
| 1508 | *error = g_strdup_printf(_("Unable to ban user %s"), args[0]); | |
| 1509 | return GAIM_CMD_RET_FAILED; | |
| 1510 | } | |
| 1511 | ||
| 1512 | return GAIM_CMD_RET_OK; | |
| 1513 | } | |
| 1514 | ||
| 11393 | 1515 | static GaimCmdRet jabber_cmd_chat_affiliate(GaimConversation *conv, |
| 1516 | const char *cmd, char **args, char **error, void *data) | |
| 1517 | { | |
| 1518 | JabberChat *chat = jabber_chat_find_by_conv(conv); | |
| 1519 | ||
| 1520 | if (!args || !args[0] || !args[1]) | |
| 1521 | return GAIM_CMD_RET_FAILED; | |
| 1522 | ||
| 1523 | if ( | |
| 1524 | strcmp(args[1], "owner") != 0 && | |
| 1525 | strcmp(args[1], "admin") != 0 && | |
| 1526 | strcmp(args[1], "member") != 0 && | |
| 1527 | strcmp(args[1], "outcast") != 0 && | |
| 1528 | strcmp(args[1], "none") != 0 | |
| 1529 | ) { | |
| 1530 | *error = g_strdup_printf(_("Unknown affiliation: \"%s\""), args[1]); | |
| 1531 | return GAIM_CMD_RET_FAILED; | |
| 1532 | } | |
| 1533 | ||
| 1534 | if (!jabber_chat_affiliate_user(chat, args[0], args[1])) { | |
| 1535 | *error = g_strdup_printf(_("Unable to affiliate user %s as \"%s\""), args[0], args[1]); | |
| 1536 | return GAIM_CMD_RET_FAILED; | |
| 1537 | } | |
| 1538 | ||
| 1539 | return GAIM_CMD_RET_OK; | |
| 1540 | } | |
| 1541 | ||
| 9152 | 1542 | static GaimCmdRet jabber_cmd_chat_invite(GaimConversation *conv, |
| 9597 | 1543 | const char *cmd, char **args, char **error, void *data) |
| 9152 | 1544 | { |
| 1545 | if(!args || !args[0]) | |
| 1546 | return GAIM_CMD_RET_FAILED; | |
| 1547 | ||
| 1548 | jabber_chat_invite(gaim_conversation_get_gc(conv), | |
| 1549 | gaim_conv_chat_get_id(GAIM_CONV_CHAT(conv)), args[1] ? args[1] : "", | |
| 1550 | args[0]); | |
| 1551 | ||
| 1552 | return GAIM_CMD_RET_OK; | |
| 1553 | } | |
| 1554 | ||
| 1555 | static GaimCmdRet jabber_cmd_chat_join(GaimConversation *conv, | |
| 9597 | 1556 | const char *cmd, char **args, char **error, void *data) |
| 9152 | 1557 | { |
| 1558 | JabberChat *chat = jabber_chat_find_by_conv(conv); | |
| 1559 | GHashTable *components; | |
| 1560 | ||
| 1561 | if(!args || !args[0]) | |
| 1562 | return GAIM_CMD_RET_FAILED; | |
| 1563 | ||
| 1564 | components = g_hash_table_new_full(g_str_hash, g_str_equal, NULL, NULL); | |
| 1565 | ||
| 1566 | g_hash_table_replace(components, "room", args[0]); | |
| 1567 | g_hash_table_replace(components, "server", chat->server); | |
| 1568 | g_hash_table_replace(components, "handle", chat->handle); | |
| 1569 | if(args[1]) | |
| 1570 | g_hash_table_replace(components, "password", args[1]); | |
| 1571 | ||
| 1572 | jabber_chat_join(gaim_conversation_get_gc(conv), components); | |
| 1573 | ||
| 1574 | g_hash_table_destroy(components); | |
| 1575 | return GAIM_CMD_RET_OK; | |
| 1576 | } | |
| 1577 | ||
| 1578 | static GaimCmdRet jabber_cmd_chat_kick(GaimConversation *conv, | |
| 9597 | 1579 | const char *cmd, char **args, char **error, void *data) |
| 9152 | 1580 | { |
| 1581 | JabberChat *chat = jabber_chat_find_by_conv(conv); | |
| 1582 | ||
| 1583 | if(!args || !args[0]) | |
| 1584 | return GAIM_CMD_RET_FAILED; | |
| 1585 | ||
| 1586 | if(!jabber_chat_kick_user(chat, args[0], args[1])) { | |
| 1587 | *error = g_strdup_printf(_("Unable to kick user %s"), args[0]); | |
| 1588 | return GAIM_CMD_RET_FAILED; | |
| 1589 | } | |
| 1590 | ||
| 1591 | return GAIM_CMD_RET_OK; | |
| 1592 | } | |
| 1593 | ||
| 1594 | static GaimCmdRet jabber_cmd_chat_msg(GaimConversation *conv, | |
| 9597 | 1595 | const char *cmd, char **args, char **error, void *data) |
| 9152 | 1596 | { |
| 1597 | JabberChat *chat = jabber_chat_find_by_conv(conv); | |
| 1598 | char *who; | |
| 1599 | ||
| 1600 | who = g_strdup_printf("%s@%s/%s", chat->room, chat->server, args[0]); | |
| 1601 | ||
| 1602 | jabber_message_send_im(gaim_conversation_get_gc(conv), who, args[1], 0); | |
| 1603 | ||
| 1604 | g_free(who); | |
| 1605 | return GAIM_CMD_RET_OK; | |
| 1606 | } | |
| 1607 | ||
|
12645
a907ba243930
[gaim-migrate @ 14983]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
12600
diff
changeset
|
1608 | static gboolean jabber_offline_message(GaimBuddy *buddy) |
|
a907ba243930
[gaim-migrate @ 14983]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
12600
diff
changeset
|
1609 | { |
|
a907ba243930
[gaim-migrate @ 14983]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
12600
diff
changeset
|
1610 | return TRUE; |
|
a907ba243930
[gaim-migrate @ 14983]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
12600
diff
changeset
|
1611 | } |
|
a907ba243930
[gaim-migrate @ 14983]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
12600
diff
changeset
|
1612 | |
| 9130 | 1613 | static void jabber_register_commands(void) |
| 1614 | { | |
| 1615 | gaim_cmd_register("config", "", GAIM_CMD_P_PRPL, | |
| 9597 | 1616 | GAIM_CMD_FLAG_CHAT | GAIM_CMD_FLAG_PRPL_ONLY, |
| 1617 | "prpl-jabber", jabber_cmd_chat_config, | |
| 1618 | _("config: Configure a chat room."), NULL); | |
| 9130 | 1619 | gaim_cmd_register("configure", "", GAIM_CMD_P_PRPL, |
| 9597 | 1620 | GAIM_CMD_FLAG_CHAT | GAIM_CMD_FLAG_PRPL_ONLY, |
| 1621 | "prpl-jabber", jabber_cmd_chat_config, | |
| 1622 | _("configure: Configure a chat room."), NULL); | |
| 9130 | 1623 | gaim_cmd_register("nick", "s", GAIM_CMD_P_PRPL, |
| 9597 | 1624 | GAIM_CMD_FLAG_CHAT | GAIM_CMD_FLAG_PRPL_ONLY, |
| 1625 | "prpl-jabber", jabber_cmd_chat_nick, | |
| 1626 | _("nick <new nickname>: Change your nickname."), | |
| 1627 | NULL); | |
| 9130 | 1628 | gaim_cmd_register("part", "s", GAIM_CMD_P_PRPL, |
| 9597 | 1629 | GAIM_CMD_FLAG_CHAT | GAIM_CMD_FLAG_PRPL_ONLY | |
| 1630 | GAIM_CMD_FLAG_ALLOW_WRONG_ARGS, "prpl-jabber", | |
| 1631 | jabber_cmd_chat_part, _("part [room]: Leave the room."), | |
| 1632 | NULL); | |
| 9130 | 1633 | gaim_cmd_register("register", "", GAIM_CMD_P_PRPL, |
| 9597 | 1634 | GAIM_CMD_FLAG_CHAT | GAIM_CMD_FLAG_PRPL_ONLY, |
| 1635 | "prpl-jabber", jabber_cmd_chat_register, | |
| 1636 | _("register: Register with a chat room."), NULL); | |
| 9130 | 1637 | /* XXX: there needs to be a core /topic cmd, methinks */ |
| 1638 | gaim_cmd_register("topic", "s", GAIM_CMD_P_PRPL, | |
| 9597 | 1639 | GAIM_CMD_FLAG_CHAT | GAIM_CMD_FLAG_PRPL_ONLY | |
| 1640 | GAIM_CMD_FLAG_ALLOW_WRONG_ARGS, "prpl-jabber", | |
| 1641 | jabber_cmd_chat_topic, | |
| 1642 | _("topic [new topic]: View or change the topic."), | |
| 1643 | NULL); | |
| 9152 | 1644 | gaim_cmd_register("ban", "ws", GAIM_CMD_P_PRPL, |
| 9597 | 1645 | GAIM_CMD_FLAG_CHAT | GAIM_CMD_FLAG_PRPL_ONLY | |
| 1646 | GAIM_CMD_FLAG_ALLOW_WRONG_ARGS, "prpl-jabber", | |
| 1647 | jabber_cmd_chat_ban, | |
| 1648 | _("ban <user> [room]: Ban a user from the room."), | |
| 1649 | NULL); | |
| 11393 | 1650 | gaim_cmd_register("affiliate", "ws", GAIM_CMD_P_PRPL, |
| 1651 | GAIM_CMD_FLAG_CHAT | GAIM_CMD_FLAG_PRPL_ONLY | | |
| 1652 | GAIM_CMD_FLAG_ALLOW_WRONG_ARGS, "prpl-jabber", | |
| 1653 | jabber_cmd_chat_affiliate, | |
| 1654 | _("affiliate <user> <owner|admin|member|outcast|none>: Set a user's affiliation with the room."), | |
| 1655 | NULL); | |
| 9152 | 1656 | gaim_cmd_register("invite", "ws", GAIM_CMD_P_PRPL, |
| 9597 | 1657 | GAIM_CMD_FLAG_CHAT | GAIM_CMD_FLAG_PRPL_ONLY | |
| 1658 | GAIM_CMD_FLAG_ALLOW_WRONG_ARGS, "prpl-jabber", | |
| 1659 | jabber_cmd_chat_invite, | |
| 11158 | 1660 | _("invite <user> [message]: Invite a user to the room."), |
| 9597 | 1661 | NULL); |
| 9152 | 1662 | gaim_cmd_register("join", "ws", GAIM_CMD_P_PRPL, |
| 9597 | 1663 | GAIM_CMD_FLAG_CHAT | GAIM_CMD_FLAG_PRPL_ONLY | |
| 1664 | GAIM_CMD_FLAG_ALLOW_WRONG_ARGS, "prpl-jabber", | |
| 1665 | jabber_cmd_chat_join, | |
| 1666 | _("join: <room> [server]: Join a chat on this server."), | |
| 1667 | NULL); | |
| 9152 | 1668 | gaim_cmd_register("kick", "ws", GAIM_CMD_P_PRPL, |
| 9597 | 1669 | GAIM_CMD_FLAG_CHAT | GAIM_CMD_FLAG_PRPL_ONLY | |
| 1670 | GAIM_CMD_FLAG_ALLOW_WRONG_ARGS, "prpl-jabber", | |
| 1671 | jabber_cmd_chat_kick, | |
| 1672 | _("kick <user> [room]: Kick a user from the room."), | |
| 1673 | NULL); | |
| 9152 | 1674 | gaim_cmd_register("msg", "ws", GAIM_CMD_P_PRPL, |
| 9597 | 1675 | GAIM_CMD_FLAG_CHAT | GAIM_CMD_FLAG_PRPL_ONLY, |
| 1676 | "prpl-jabber", jabber_cmd_chat_msg, | |
| 1677 | _("msg <user> <message>: Send a private message to another user."), | |
| 1678 | NULL); | |
| 9130 | 1679 | } |
| 1680 | ||
|
5205
242b8aa81328
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5174
diff
changeset
|
1681 | static GaimPluginProtocolInfo prpl_info = |
| 2086 | 1682 | { |
| 12554 | 1683 | OPT_PROTO_CHAT_TOPIC | OPT_PROTO_UNIQUE_CHATNAME, |
|
9475
8c8d4ac992a6
[gaim-migrate @ 10300]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
9466
diff
changeset
|
1684 | NULL, /* user_splits */ |
|
8c8d4ac992a6
[gaim-migrate @ 10300]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
9466
diff
changeset
|
1685 | NULL, /* protocol_options */ |
| 10189 | 1686 | {"jpeg,gif,png", 0, 0, 96, 96, GAIM_ICON_SCALE_DISPLAY}, /* icon_spec */ |
|
9475
8c8d4ac992a6
[gaim-migrate @ 10300]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
9466
diff
changeset
|
1687 | jabber_list_icon, /* list_icon */ |
|
8c8d4ac992a6
[gaim-migrate @ 10300]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
9466
diff
changeset
|
1688 | jabber_list_emblems, /* list_emblems */ |
|
8c8d4ac992a6
[gaim-migrate @ 10300]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
9466
diff
changeset
|
1689 | jabber_status_text, /* status_text */ |
|
8c8d4ac992a6
[gaim-migrate @ 10300]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
9466
diff
changeset
|
1690 | jabber_tooltip_text, /* tooltip_text */ |
| 9954 | 1691 | jabber_status_types, /* status_types */ |
|
9475
8c8d4ac992a6
[gaim-migrate @ 10300]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
9466
diff
changeset
|
1692 | jabber_blist_node_menu, /* blist_node_menu */ |
|
8c8d4ac992a6
[gaim-migrate @ 10300]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
9466
diff
changeset
|
1693 | jabber_chat_info, /* chat_info */ |
|
9754
3a17eee239b2
[gaim-migrate @ 10621]
Nathan Fredrickson <nathan@silverorange.com>
parents:
9597
diff
changeset
|
1694 | jabber_chat_info_defaults, /* chat_info_defaults */ |
|
9475
8c8d4ac992a6
[gaim-migrate @ 10300]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
9466
diff
changeset
|
1695 | jabber_login, /* login */ |
|
8c8d4ac992a6
[gaim-migrate @ 10300]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
9466
diff
changeset
|
1696 | jabber_close, /* close */ |
|
8c8d4ac992a6
[gaim-migrate @ 10300]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
9466
diff
changeset
|
1697 | jabber_message_send_im, /* send_im */ |
|
8c8d4ac992a6
[gaim-migrate @ 10300]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
9466
diff
changeset
|
1698 | jabber_set_info, /* set_info */ |
|
8c8d4ac992a6
[gaim-migrate @ 10300]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
9466
diff
changeset
|
1699 | jabber_send_typing, /* send_typing */ |
|
8c8d4ac992a6
[gaim-migrate @ 10300]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
9466
diff
changeset
|
1700 | jabber_buddy_get_info, /* get_info */ |
| 10216 | 1701 | jabber_presence_send, /* set_away */ |
|
9475
8c8d4ac992a6
[gaim-migrate @ 10300]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
9466
diff
changeset
|
1702 | jabber_idle_set, /* set_idle */ |
|
8c8d4ac992a6
[gaim-migrate @ 10300]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
9466
diff
changeset
|
1703 | NULL, /* change_passwd */ |
|
8c8d4ac992a6
[gaim-migrate @ 10300]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
9466
diff
changeset
|
1704 | jabber_roster_add_buddy, /* add_buddy */ |
|
8c8d4ac992a6
[gaim-migrate @ 10300]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
9466
diff
changeset
|
1705 | NULL, /* add_buddies */ |
|
8c8d4ac992a6
[gaim-migrate @ 10300]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
9466
diff
changeset
|
1706 | jabber_roster_remove_buddy, /* remove_buddy */ |
|
8c8d4ac992a6
[gaim-migrate @ 10300]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
9466
diff
changeset
|
1707 | NULL, /* remove_buddies */ |
|
8c8d4ac992a6
[gaim-migrate @ 10300]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
9466
diff
changeset
|
1708 | NULL, /* add_permit */ |
|
8c8d4ac992a6
[gaim-migrate @ 10300]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
9466
diff
changeset
|
1709 | NULL, /* add_deny */ |
|
8c8d4ac992a6
[gaim-migrate @ 10300]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
9466
diff
changeset
|
1710 | NULL, /* rem_permit */ |
|
8c8d4ac992a6
[gaim-migrate @ 10300]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
9466
diff
changeset
|
1711 | NULL, /* rem_deny */ |
|
8c8d4ac992a6
[gaim-migrate @ 10300]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
9466
diff
changeset
|
1712 | NULL, /* set_permit_deny */ |
|
8c8d4ac992a6
[gaim-migrate @ 10300]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
9466
diff
changeset
|
1713 | jabber_chat_join, /* join_chat */ |
|
8c8d4ac992a6
[gaim-migrate @ 10300]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
9466
diff
changeset
|
1714 | NULL, /* reject_chat */ |
|
9917
2fbb3c9fab2b
[gaim-migrate @ 10809]
Daniel Atallah <datallah@pidgin.im>
parents:
9754
diff
changeset
|
1715 | jabber_get_chat_name, /* get_chat_name */ |
|
9475
8c8d4ac992a6
[gaim-migrate @ 10300]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
9466
diff
changeset
|
1716 | jabber_chat_invite, /* chat_invite */ |
|
8c8d4ac992a6
[gaim-migrate @ 10300]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
9466
diff
changeset
|
1717 | jabber_chat_leave, /* chat_leave */ |
|
8c8d4ac992a6
[gaim-migrate @ 10300]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
9466
diff
changeset
|
1718 | NULL, /* chat_whisper */ |
|
8c8d4ac992a6
[gaim-migrate @ 10300]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
9466
diff
changeset
|
1719 | jabber_message_send_chat, /* chat_send */ |
|
8c8d4ac992a6
[gaim-migrate @ 10300]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
9466
diff
changeset
|
1720 | jabber_keepalive, /* keepalive */ |
|
8c8d4ac992a6
[gaim-migrate @ 10300]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
9466
diff
changeset
|
1721 | jabber_register_account, /* register_user */ |
|
8c8d4ac992a6
[gaim-migrate @ 10300]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
9466
diff
changeset
|
1722 | jabber_buddy_get_info_chat, /* get_cb_info */ |
|
8c8d4ac992a6
[gaim-migrate @ 10300]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
9466
diff
changeset
|
1723 | NULL, /* get_cb_away */ |
|
8c8d4ac992a6
[gaim-migrate @ 10300]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
9466
diff
changeset
|
1724 | jabber_roster_alias_change, /* alias_buddy */ |
|
8c8d4ac992a6
[gaim-migrate @ 10300]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
9466
diff
changeset
|
1725 | jabber_roster_group_change, /* group_buddy */ |
|
8c8d4ac992a6
[gaim-migrate @ 10300]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
9466
diff
changeset
|
1726 | jabber_roster_group_rename, /* rename_group */ |
|
8c8d4ac992a6
[gaim-migrate @ 10300]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
9466
diff
changeset
|
1727 | NULL, /* buddy_free */ |
|
8c8d4ac992a6
[gaim-migrate @ 10300]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
9466
diff
changeset
|
1728 | jabber_convo_closed, /* convo_closed */ |
|
8c8d4ac992a6
[gaim-migrate @ 10300]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
9466
diff
changeset
|
1729 | jabber_normalize, /* normalize */ |
| 10189 | 1730 | jabber_set_buddy_icon, /* set_buddy_icon */ |
|
9475
8c8d4ac992a6
[gaim-migrate @ 10300]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
9466
diff
changeset
|
1731 | NULL, /* remove_group */ |
|
8c8d4ac992a6
[gaim-migrate @ 10300]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
9466
diff
changeset
|
1732 | jabber_chat_buddy_real_name, /* get_cb_real_name */ |
|
8c8d4ac992a6
[gaim-migrate @ 10300]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
9466
diff
changeset
|
1733 | jabber_chat_set_topic, /* set_chat_topic */ |
|
8c8d4ac992a6
[gaim-migrate @ 10300]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
9466
diff
changeset
|
1734 | jabber_find_blist_chat, /* find_blist_chat */ |
|
8c8d4ac992a6
[gaim-migrate @ 10300]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
9466
diff
changeset
|
1735 | jabber_roomlist_get_list, /* roomlist_get_list */ |
|
8c8d4ac992a6
[gaim-migrate @ 10300]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
9466
diff
changeset
|
1736 | jabber_roomlist_cancel, /* roomlist_cancel */ |
|
8c8d4ac992a6
[gaim-migrate @ 10300]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
9466
diff
changeset
|
1737 | NULL, /* roomlist_expand_category */ |
|
8c8d4ac992a6
[gaim-migrate @ 10300]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
9466
diff
changeset
|
1738 | NULL, /* can_receive_file */ |
|
12143
09f216663302
[gaim-migrate @ 14444]
Evan Schoenberg <evands@pidgin.im>
parents:
11939
diff
changeset
|
1739 | jabber_si_xfer_send, /* send_file */ |
|
09f216663302
[gaim-migrate @ 14444]
Evan Schoenberg <evands@pidgin.im>
parents:
11939
diff
changeset
|
1740 | jabber_si_new_xfer, /* new_xfer */ |
|
12645
a907ba243930
[gaim-migrate @ 14983]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
12600
diff
changeset
|
1741 | jabber_offline_message, /* offline_message */ |
|
12600
7ecd4441fdc7
[gaim-migrate @ 14934]
Richard Laager <rlaager@pidgin.im>
parents:
12595
diff
changeset
|
1742 | NULL, /* whiteboard_prpl_ops */ |
|
7ecd4441fdc7
[gaim-migrate @ 14934]
Richard Laager <rlaager@pidgin.im>
parents:
12595
diff
changeset
|
1743 | NULL, /* media_prpl_ops */ |
|
5205
242b8aa81328
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5174
diff
changeset
|
1744 | }; |
|
242b8aa81328
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5174
diff
changeset
|
1745 | |
|
242b8aa81328
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5174
diff
changeset
|
1746 | static GaimPluginInfo info = |
|
242b8aa81328
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5174
diff
changeset
|
1747 | { |
| 9943 | 1748 | GAIM_PLUGIN_MAGIC, |
| 1749 | GAIM_MAJOR_VERSION, | |
| 1750 | GAIM_MINOR_VERSION, | |
|
5205
242b8aa81328
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5174
diff
changeset
|
1751 | GAIM_PLUGIN_PROTOCOL, /**< type */ |
|
242b8aa81328
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5174
diff
changeset
|
1752 | NULL, /**< ui_requirement */ |
|
242b8aa81328
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5174
diff
changeset
|
1753 | 0, /**< flags */ |
|
242b8aa81328
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5174
diff
changeset
|
1754 | NULL, /**< dependencies */ |
|
242b8aa81328
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5174
diff
changeset
|
1755 | GAIM_PRIORITY_DEFAULT, /**< priority */ |
|
242b8aa81328
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5174
diff
changeset
|
1756 | |
|
242b8aa81328
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5174
diff
changeset
|
1757 | "prpl-jabber", /**< id */ |
|
242b8aa81328
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5174
diff
changeset
|
1758 | "Jabber", /**< name */ |
|
242b8aa81328
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5174
diff
changeset
|
1759 | VERSION, /**< version */ |
|
242b8aa81328
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5174
diff
changeset
|
1760 | /** summary */ |
|
242b8aa81328
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5174
diff
changeset
|
1761 | N_("Jabber Protocol Plugin"), |
|
242b8aa81328
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5174
diff
changeset
|
1762 | /** description */ |
|
242b8aa81328
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5174
diff
changeset
|
1763 | N_("Jabber Protocol Plugin"), |
|
242b8aa81328
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5174
diff
changeset
|
1764 | NULL, /**< author */ |
|
6371
e92b66ee5518
[gaim-migrate @ 6876]
Christian Hammond <chipx86@chipx86.com>
parents:
6357
diff
changeset
|
1765 | GAIM_WEBSITE, /**< homepage */ |
|
5205
242b8aa81328
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5174
diff
changeset
|
1766 | |
|
242b8aa81328
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5174
diff
changeset
|
1767 | NULL, /**< load */ |
|
242b8aa81328
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5174
diff
changeset
|
1768 | NULL, /**< unload */ |
|
242b8aa81328
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5174
diff
changeset
|
1769 | NULL, /**< destroy */ |
|
242b8aa81328
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5174
diff
changeset
|
1770 | |
|
242b8aa81328
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5174
diff
changeset
|
1771 | NULL, /**< ui_info */ |
| 8993 | 1772 | &prpl_info, /**< extra_info */ |
| 10487 | 1773 | NULL, /**< prefs_info */ |
|
9015
3c27e9074fa2
[gaim-migrate @ 9791]
Christopher O'Brien <siege@pidgin.im>
parents:
8993
diff
changeset
|
1774 | jabber_actions |
|
5205
242b8aa81328
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5174
diff
changeset
|
1775 | }; |
|
242b8aa81328
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5174
diff
changeset
|
1776 | |
|
242b8aa81328
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5174
diff
changeset
|
1777 | static void |
|
5920
963bfdefee02
[gaim-migrate @ 6360]
Christian Hammond <chipx86@chipx86.com>
parents:
5894
diff
changeset
|
1778 | init_plugin(GaimPlugin *plugin) |
|
5205
242b8aa81328
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5174
diff
changeset
|
1779 | { |
|
5638
53e752c88ea1
[gaim-migrate @ 6047]
Christian Hammond <chipx86@chipx86.com>
parents:
5613
diff
changeset
|
1780 | GaimAccountUserSplit *split; |
|
53e752c88ea1
[gaim-migrate @ 6047]
Christian Hammond <chipx86@chipx86.com>
parents:
5613
diff
changeset
|
1781 | GaimAccountOption *option; |
|
53e752c88ea1
[gaim-migrate @ 6047]
Christian Hammond <chipx86@chipx86.com>
parents:
5613
diff
changeset
|
1782 | |
|
53e752c88ea1
[gaim-migrate @ 6047]
Christian Hammond <chipx86@chipx86.com>
parents:
5613
diff
changeset
|
1783 | split = gaim_account_user_split_new(_("Server"), "jabber.org", '@'); |
|
53e752c88ea1
[gaim-migrate @ 6047]
Christian Hammond <chipx86@chipx86.com>
parents:
5613
diff
changeset
|
1784 | prpl_info.user_splits = g_list_append(prpl_info.user_splits, split); |
|
53e752c88ea1
[gaim-migrate @ 6047]
Christian Hammond <chipx86@chipx86.com>
parents:
5613
diff
changeset
|
1785 | |
| 11939 | 1786 | split = gaim_account_user_split_new(_("Resource"), "Home", '/'); |
|
5638
53e752c88ea1
[gaim-migrate @ 6047]
Christian Hammond <chipx86@chipx86.com>
parents:
5613
diff
changeset
|
1787 | prpl_info.user_splits = g_list_append(prpl_info.user_splits, split); |
|
53e752c88ea1
[gaim-migrate @ 6047]
Christian Hammond <chipx86@chipx86.com>
parents:
5613
diff
changeset
|
1788 | |
| 7630 | 1789 | option = gaim_account_option_bool_new(_("Use TLS if available"), "use_tls", |
| 1790 | TRUE); | |
| 1791 | prpl_info.protocol_options = g_list_append(prpl_info.protocol_options, | |
| 1792 | option); | |
| 1793 | ||
| 10941 | 1794 | option = gaim_account_option_bool_new(_("Require TLS"), "require_tls", TRUE); |
| 1795 | prpl_info.protocol_options = g_list_append(prpl_info.protocol_options, option); | |
| 1796 | ||
| 1797 | option = gaim_account_option_bool_new(_("Force old (port 5223) SSL"), "old_ssl", FALSE); | |
| 7124 | 1798 | prpl_info.protocol_options = g_list_append(prpl_info.protocol_options, |
| 1799 | option); | |
| 6764 | 1800 | |
| 8086 | 1801 | option = gaim_account_option_bool_new( |
| 1802 | _("Allow plaintext auth over unencrypted streams"), | |
| 1803 | "auth_plain_in_clear", FALSE); | |
| 1804 | prpl_info.protocol_options = g_list_append(prpl_info.protocol_options, | |
| 1805 | option); | |
| 1806 | ||
| 11387 | 1807 | option = gaim_account_option_int_new(_("Connect port"), "port", 5222); |
|
5638
53e752c88ea1
[gaim-migrate @ 6047]
Christian Hammond <chipx86@chipx86.com>
parents:
5613
diff
changeset
|
1808 | prpl_info.protocol_options = g_list_append(prpl_info.protocol_options, |
| 7014 | 1809 | option); |
|
5638
53e752c88ea1
[gaim-migrate @ 6047]
Christian Hammond <chipx86@chipx86.com>
parents:
5613
diff
changeset
|
1810 | |
|
5685
2523e4143d74
[gaim-migrate @ 6106]
Christian Hammond <chipx86@chipx86.com>
parents:
5681
diff
changeset
|
1811 | option = gaim_account_option_string_new(_("Connect server"), |
| 7014 | 1812 | "connect_server", NULL); |
|
5638
53e752c88ea1
[gaim-migrate @ 6047]
Christian Hammond <chipx86@chipx86.com>
parents:
5613
diff
changeset
|
1813 | prpl_info.protocol_options = g_list_append(prpl_info.protocol_options, |
| 7014 | 1814 | option); |
|
5205
242b8aa81328
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5174
diff
changeset
|
1815 | |
|
242b8aa81328
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5174
diff
changeset
|
1816 | my_protocol = plugin; |
| 7014 | 1817 | |
| 10487 | 1818 | gaim_prefs_remove("/plugins/prpl/jabber"); |
| 9130 | 1819 | |
| 12508 | 1820 | /* XXX - If any other plugin wants SASL this won't be good ... */ |
| 1821 | #ifdef HAVE_CYRUS_SASL | |
| 1822 | sasl_client_init(NULL); | |
| 1823 | #endif | |
| 9130 | 1824 | jabber_register_commands(); |
| 2086 | 1825 | } |
| 1826 | ||
|
5920
963bfdefee02
[gaim-migrate @ 6360]
Christian Hammond <chipx86@chipx86.com>
parents:
5894
diff
changeset
|
1827 | GAIM_INIT_PLUGIN(jabber, init_plugin, info); |