Changes in protocols/jabber/conference.c [c34247d:3d31618]
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
protocols/jabber/conference.c
rc34247d r3d31618 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);29 28 30 29 struct groupchat *jabber_chat_join(struct im_connection *ic, const char *room, const char *nick, const char *password) … … 122 121 } 123 122 if (bud) { 124 struct groupchat *c = jabber_chat_by_jid(ic, bud->bare_jid); 125 if (c) { 126 jabber_chat_free(c); 127 } 123 jabber_chat_free(jabber_chat_by_jid(ic, bud->bare_jid)); 128 124 } 129 125 130 126 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;137 127 } 138 128 … … 181 171 node = jabber_make_packet("message", "groupchat", jc->name, node); 182 172 183 jabber_cache_add(ic, node, jabber_chat_self_message); 184 185 return !jabber_write_packet(ic, node); 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; 186 180 } 187 181 … … 305 299 } 306 300 } 301 302 /* Some program-specific restrictions. */ 303 imcb_clean_handle(ic, bud->ext_jid); 307 304 } 308 305 bud->flags |= JBFLAG_IS_ANONYMOUS; … … 334 331 } else if (type) { /* type can only be NULL or "unavailable" in this function */ 335 332 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 377 333 s = strchr(bud->ext_jid, '/'); 378 334 if (s) { 379 335 *s = 0; 380 336 } 381 imcb_chat_remove_buddy(chat, bud->ext_jid, reason);337 imcb_chat_remove_buddy(chat, bud->ext_jid, NULL); 382 338 if (bud != jc->me && bud->flags & JBFLAG_IS_ANONYMOUS) { 383 imcb_remove_buddy(ic, bud->ext_jid, reason);339 imcb_remove_buddy(ic, bud->ext_jid, NULL); 384 340 } 385 341 if (s) { 386 342 *s = '/'; 387 343 } 388 389 g_free(reason);390 344 } 391 345 … … 406 360 char *final_from = NULL; 407 361 char *bare_jid = NULL; 408 guint32 flags = 0;409 362 410 363 from = (bud) ? bud->full_jid : xt_find_attr(node, "from"); … … 443 396 444 397 if (subject && chat) { 445 char *subject_text = subject->text_len > 0 ? subject->text : "";398 char *subject_text = subject->text_len > 0 ? subject->text : NULL; 446 399 if (g_strcmp0(chat->topic, subject_text) != 0) { 447 400 bare_jid = (bud) ? jabber_get_bare_jid(bud->ext_jid) : NULL; … … 449 402 jabber_get_timestamp(node)); 450 403 g_free(bare_jid); 451 bare_jid = NULL;452 404 } 453 405 } … … 470 422 imcb_chat_log(chat, "From conference server: %s", body->text); 471 423 return; 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*/424 } else if (jc && jc->flags & JCFLAG_MESSAGE_SENT && bud == jc->me) { 425 /* exclude self-messages since they would get filtered out 426 * but not the ones in the backlog */ 475 427 return; 476 428 } 477 429 478 if (bud ) {430 if (bud && jc && bud != jc->me) { 479 431 bare_jid = jabber_get_bare_jid(bud->ext_jid ? bud->ext_jid : bud->full_jid); 480 432 final_from = bare_jid; 481 flags = (bud == jc->me) ? OPT_SELFMESSAGE : 0;482 433 } else { 483 434 final_from = nick; 484 435 } 485 436 486 imcb_chat_msg(chat, final_from, body->text, flags, jabber_get_timestamp(node));437 imcb_chat_msg(chat, final_from, body->text, 0, jabber_get_timestamp(node)); 487 438 488 439 g_free(bare_jid);
Note: See TracChangeset
for help on using the changeset viewer.