Changeset 3fbce97 for protocols/jabber/jabber.c
- Timestamp:
- 2016-09-24T20:14:34Z (8 years ago)
- Children:
- ba52ac5
- Parents:
- 63cad66 (diff), 82cb190 (diff)
Note: this is a merge changeset, the changes displayed below correspond to the merge itself.
Use the(diff)
links above to see all the changes relative to each parent. - File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
protocols/jabber/jabber.c
r63cad66 r3fbce97 114 114 s->flags |= ACC_SET_OFFLINE_ONLY | SET_NULL_OK; 115 115 116 s = set_add(&acc->set, "carbons", "true", set_eval_bool, acc); 117 s->flags |= ACC_SET_OFFLINE_ONLY; 118 116 119 acc->flags |= ACC_FLAG_AWAY_MESSAGE | ACC_FLAG_STATUS_MESSAGE | 117 120 ACC_FLAG_HANDLE_DOMAINS; … … 148 151 } 149 152 153 if (strstr(jd->server, ".facebook.com")) { 154 imcb_error(ic, "Facebook's XMPP service is gone. Try this instead: https://wiki.bitlbee.org/HowtoFacebookMQTT"); 155 imc_logout(ic, FALSE); 156 return; 157 } 158 150 159 if ((s = strchr(jd->server, '/'))) { 151 160 *s = 0; … … 167 176 jd->fd = jd->r_inpa = jd->w_inpa = -1; 168 177 169 if (strstr(jd->server, ".facebook.com")) { 170 jd->oauth2_service = &oauth2_service_facebook; 171 } else { 172 jd->oauth2_service = &oauth2_service_google; 173 } 178 /* There are no other options atm, so assume google for everything 179 Facebook and MSN XMPP used to be here. RIP. */ 180 jd->oauth2_service = &oauth2_service_google; 174 181 175 182 oauth_params_parse(&p_in, ic->acc->pass); … … 197 204 } else { 198 205 jabber_connect(ic); 206 } 207 } 208 209 static void jabber_xmlconsole_enable(struct im_connection *ic) 210 { 211 struct jabber_data *jd = ic->proto_data; 212 const char *handle = JABBER_XMLCONSOLE_HANDLE; 213 bee_user_t *bu; 214 215 jd->flags |= JFLAG_XMLCONSOLE; 216 217 if (!(bu = bee_user_by_handle(ic->bee, ic, handle))) { 218 bu = bee_user_new(ic->bee, ic, handle, 0); 219 bu->flags |= BEE_USER_NOOTR; 199 220 } 200 221 } … … 266 287 267 288 if (set_getbool(&acc->set, "xmlconsole")) { 268 jd->flags |= JFLAG_XMLCONSOLE; 269 /* Shouldn't really do this at this stage already, maybe. But 270 I think this shouldn't break anything. */ 271 imcb_add_buddy(ic, JABBER_XMLCONSOLE_HANDLE, NULL); 289 jabber_xmlconsole_enable(ic); 272 290 } 273 291 … … 334 352 } 335 353 if (jd->fd >= 0) { 336 closesocket(jd->fd);354 proxy_disconnect(jd->fd); 337 355 } 338 356 … … 345 363 } 346 364 347 jabber_buddy_remove_all(ic); 365 if (jd->buddies) { 366 jabber_buddy_remove_all(ic); 367 } 348 368 349 369 xt_free(jd->xt); … … 355 375 g_free(jd->internal_jid); 356 376 g_free(jd->gmail_tid); 377 g_free(jd->muc_host); 357 378 g_free(jd->username); 358 379 g_free(jd->me); … … 413 434 } 414 435 436 /* XEP-0364 suggests we add message processing hints (XEP-0334) to OTR messages, 437 mostly to avoid carbons (XEP-0280) and server-side message archiving. 438 OTR messages are roughly like this: /^\?OTR(.*\?| Error:|:)/ 439 But I'm going to simplify it to messages starting with "?OTR". */ 440 if (g_str_has_prefix(message, "?OTR")) { 441 int i; 442 char *hints[] = { 443 "no-copy", XMLNS_HINTS, 444 "no-permanent-store", XMLNS_HINTS, 445 "private", XMLNS_CARBONS, 446 NULL 447 }; 448 449 for (i = 0; hints[i]; i += 2) { 450 struct xt_node *hint; 451 hint = xt_new_node(hints[i], NULL, NULL); 452 xt_add_attr(hint, "xmlns", hints[i + 1]); 453 xt_add_child(node, hint); 454 } 455 } 456 415 457 st = jabber_write_packet(ic, node); 416 458 xt_free_node(node); … … 472 514 static void jabber_add_buddy(struct im_connection *ic, char *who, char *group) 473 515 { 474 struct jabber_data *jd = ic->proto_data;475 476 516 if (g_strcasecmp(who, JABBER_XMLCONSOLE_HANDLE) == 0) { 477 jd->flags |= JFLAG_XMLCONSOLE; 478 imcb_add_buddy(ic, JABBER_XMLCONSOLE_HANDLE, NULL); 517 jabber_xmlconsole_enable(ic); 479 518 return; 480 519 } … … 520 559 } 521 560 561 if (jd->flags & JFLAG_HIPCHAT && jd->muc_host && !g_str_has_suffix(room, jd->muc_host)) { 562 char *guessed_name = hipchat_guess_channel_name(ic, room); 563 if (guessed_name) { 564 set_setstr(sets, "room", guessed_name); 565 g_free(guessed_name); 566 567 /* call this same function again with the fixed name */ 568 return jabber_chat_join_(ic, set_getstr(sets, "room"), nick, password, sets); 569 } 570 } 571 522 572 if (strchr(room, '@') == NULL) { 523 573 imcb_error(ic, "%s is not a valid Jabber room name. Maybe you mean %s@conference.%s?", … … 526 576 imcb_error(ic, "Already present in chat `%s'", room); 527 577 } else { 578 /* jabber_chat_join without the underscore is the conference.c one */ 528 579 return jabber_chat_join(ic, room, final_nick, set_getstr(sets, "password")); 529 580 } … … 590 641 { 591 642 struct jabber_data *jd = ic->proto_data; 592 struct jabber_buddy *bud ;643 struct jabber_buddy *bud, *bare; 593 644 594 645 /* Enable typing notification related code from now. */ 595 646 jd->flags |= JFLAG_WANT_TYPING; 596 647 597 if ((bud = jabber_buddy_by_jid(ic, who, 0)) == NULL) { 648 if ((bud = jabber_buddy_by_jid(ic, who, 0)) == NULL || 649 (bare = jabber_buddy_by_jid(ic, who, GET_BUDDY_BARE)) == NULL) { 598 650 /* Sending typing notifications to unknown buddies is 599 651 unsupported for now. Shouldn't be a problem, I think. */ … … 601 653 } 602 654 603 if (bud->flags & JBFLAG_DOES_XEP85) { 655 656 if (bud->flags & JBFLAG_DOES_XEP85 || bare->flags & JBFLAG_DOES_XEP85) { 604 657 /* We're only allowed to send this stuff if we know the other 605 side supports it. */ 658 side supports it. If the bare JID has the flag, all other 659 resources get it, too (That is the case in gtalk) */ 606 660 607 661 struct xt_node *node;
Note: See TracChangeset
for help on using the changeset viewer.