Changeset 3fbce97 for protocols/jabber/conference.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/conference.c
r63cad66 r3fbce97 26 26 27 27 static xt_status jabber_chat_join_failed(struct im_connection *ic, struct xt_node *node, struct xt_node *orig); 28 static xt_status jabber_chat_self_message(struct im_connection *ic, struct xt_node *node, struct xt_node *orig); 28 29 29 30 struct groupchat *jabber_chat_join(struct im_connection *ic, const char *room, const char *nick, const char *password) … … 121 122 } 122 123 if (bud) { 123 jabber_chat_free(jabber_chat_by_jid(ic, bud->bare_jid)); 124 struct groupchat *c = jabber_chat_by_jid(ic, bud->bare_jid); 125 if (c) { 126 jabber_chat_free(c); 127 } 124 128 } 125 129 126 130 return XT_HANDLED; 131 } 132 133 static xt_status jabber_chat_self_message(struct im_connection *ic, struct xt_node *node, struct xt_node *orig) 134 { 135 /* This is a self message sent by this bitlbee - just drop it */ 136 return XT_ABORT; 127 137 } 128 138 … … 171 181 node = jabber_make_packet("message", "groupchat", jc->name, node); 172 182 173 if (!jabber_write_packet(ic, node)) { 174 xt_free_node(node); 175 return 0; 176 } 177 xt_free_node(node); 178 179 return 1; 183 jabber_cache_add(ic, node, jabber_chat_self_message); 184 185 return !jabber_write_packet(ic, node); 180 186 } 181 187 … … 299 305 } 300 306 } 301 302 /* Some program-specific restrictions. */303 imcb_clean_handle(ic, bud->ext_jid);304 307 } 305 308 bud->flags |= JBFLAG_IS_ANONYMOUS; … … 331 334 } else if (type) { /* type can only be NULL or "unavailable" in this function */ 332 335 if ((bud->flags & JBFLAG_IS_CHATROOM) && bud->ext_jid) { 336 char *reason = NULL; 337 char *status = NULL; 338 char *status_text = NULL; 339 340 if ((c = xt_find_node_by_attr(node->children, "x", "xmlns", XMLNS_MUC_USER))) { 341 struct xt_node *c2 = c->children; 342 343 while ((c2 = xt_find_node(c2, "status"))) { 344 char *code = xt_find_attr(c2, "code"); 345 if (g_strcmp0(code, "301") == 0) { 346 status = "Banned"; 347 break; 348 } else if (g_strcmp0(code, "303") == 0) { 349 /* This could be handled in a cleverer way, 350 * but let's just show a literal part/join for now */ 351 status = "Changing nicks"; 352 break; 353 } else if (g_strcmp0(code, "307") == 0) { 354 status = "Kicked"; 355 break; 356 } 357 c2 = c2->next; 358 } 359 360 /* Sometimes the status message is in presence/x/item/reason */ 361 if ((c2 = xt_find_path(c, "item/reason")) && c2->text && c2->text_len) { 362 status_text = c2->text; 363 } 364 } 365 366 /* Sometimes the status message is right inside <presence> */ 367 if ((c = xt_find_node(node->children, "status")) && c->text && c->text_len) { 368 status_text = c->text; 369 } 370 371 if (status_text && status) { 372 reason = g_strdup_printf("%s: %s", status, status_text); 373 } else { 374 reason = g_strdup(status_text ? : status); 375 } 376 333 377 s = strchr(bud->ext_jid, '/'); 334 378 if (s) { 335 379 *s = 0; 336 380 } 337 imcb_chat_remove_buddy(chat, bud->ext_jid, NULL);381 imcb_chat_remove_buddy(chat, bud->ext_jid, reason); 338 382 if (bud != jc->me && bud->flags & JBFLAG_IS_ANONYMOUS) { 339 imcb_remove_buddy(ic, bud->ext_jid, NULL);383 imcb_remove_buddy(ic, bud->ext_jid, reason); 340 384 } 341 385 if (s) { 342 386 *s = '/'; 343 387 } 388 389 g_free(reason); 344 390 } 345 391 … … 360 406 char *final_from = NULL; 361 407 char *bare_jid = NULL; 408 guint32 flags = 0; 362 409 363 410 from = (bud) ? bud->full_jid : xt_find_attr(node, "from"); … … 396 443 397 444 if (subject && chat) { 398 char *subject_text = subject->text_len > 0 ? subject->text : NULL;445 char *subject_text = subject->text_len > 0 ? subject->text : ""; 399 446 if (g_strcmp0(chat->topic, subject_text) != 0) { 400 447 bare_jid = (bud) ? jabber_get_bare_jid(bud->ext_jid) : NULL; … … 402 449 jabber_get_timestamp(node)); 403 450 g_free(bare_jid); 451 bare_jid = NULL; 404 452 } 405 453 } … … 422 470 imcb_chat_log(chat, "From conference server: %s", body->text); 423 471 return; 424 } else if (jc && jc->flags & JCFLAG_MESSAGE_SENT && bud == jc->me ) {425 /* exclude self-messages since they would get filtered out426 * but not the ones in the backlog*/472 } else if (jc && jc->flags & JCFLAG_MESSAGE_SENT && bud == jc->me && 473 (jabber_cache_handle_packet(ic, node) == XT_ABORT)) { 474 /* Self message marked by this bitlbee, don't show it */ 427 475 return; 428 476 } 429 477 430 if (bud && jc && bud != jc->me) {478 if (bud) { 431 479 bare_jid = jabber_get_bare_jid(bud->ext_jid ? bud->ext_jid : bud->full_jid); 432 480 final_from = bare_jid; 481 flags = (bud == jc->me) ? OPT_SELFMESSAGE : 0; 433 482 } else { 434 483 final_from = nick; 435 484 } 436 485 437 imcb_chat_msg(chat, final_from, body->text, 0, jabber_get_timestamp(node));486 imcb_chat_msg(chat, final_from, body->text, flags, jabber_get_timestamp(node)); 438 487 439 488 g_free(bare_jid);
Note: See TracChangeset
for help on using the changeset viewer.