Changeset 29ff5c2 for protocols/jabber/conference.c
- Timestamp:
- 2015-11-21T00:01:50Z (9 years ago)
- Parents:
- e4f08bf (diff), 8fdeaa5 (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
re4f08bf r29ff5c2 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) … … 127 128 } 128 129 130 static xt_status jabber_chat_self_message(struct im_connection *ic, struct xt_node *node, struct xt_node *orig) 131 { 132 /* This is a self message sent by this bitlbee - just drop it */ 133 return XT_ABORT; 134 } 135 129 136 struct groupchat *jabber_chat_by_jid(struct im_connection *ic, const char *name) 130 137 { … … 171 178 node = jabber_make_packet("message", "groupchat", jc->name, node); 172 179 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; 180 jabber_cache_add(ic, node, jabber_chat_self_message); 181 182 return !jabber_write_packet(ic, node); 180 183 } 181 184 … … 299 302 } 300 303 } 301 302 /* Some program-specific restrictions. */303 imcb_clean_handle(ic, bud->ext_jid);304 304 } 305 305 bud->flags |= JBFLAG_IS_ANONYMOUS; … … 331 331 } else if (type) { /* type can only be NULL or "unavailable" in this function */ 332 332 if ((bud->flags & JBFLAG_IS_CHATROOM) && bud->ext_jid) { 333 char *reason = NULL; 334 char *status = NULL; 335 char *status_text = NULL; 336 337 if ((c = xt_find_node_by_attr(node->children, "x", "xmlns", XMLNS_MUC_USER))) { 338 struct xt_node *c2 = c->children; 339 340 while ((c2 = xt_find_node(c2, "status"))) { 341 char *code = xt_find_attr(c2, "code"); 342 if (g_strcmp0(code, "301") == 0) { 343 status = "Banned"; 344 break; 345 } else if (g_strcmp0(code, "303") == 0) { 346 /* This could be handled in a cleverer way, 347 * but let's just show a literal part/join for now */ 348 status = "Changing nicks"; 349 break; 350 } else if (g_strcmp0(code, "307") == 0) { 351 status = "Kicked"; 352 break; 353 } 354 c2 = c2->next; 355 } 356 357 /* Sometimes the status message is in presence/x/item/reason */ 358 if ((c2 = xt_find_path(c, "item/reason")) && c2->text && c2->text_len) { 359 status_text = c2->text; 360 } 361 } 362 363 /* Sometimes the status message is right inside <presence> */ 364 if ((c = xt_find_node(node->children, "status")) && c->text && c->text_len) { 365 status_text = c->text; 366 } 367 368 if (status_text && status) { 369 reason = g_strdup_printf("%s: %s", status, status_text); 370 } else { 371 reason = g_strdup(status_text ? : status); 372 } 373 333 374 s = strchr(bud->ext_jid, '/'); 334 375 if (s) { 335 376 *s = 0; 336 377 } 337 imcb_chat_remove_buddy(chat, bud->ext_jid, NULL);378 imcb_chat_remove_buddy(chat, bud->ext_jid, reason); 338 379 if (bud != jc->me && bud->flags & JBFLAG_IS_ANONYMOUS) { 339 imcb_remove_buddy(ic, bud->ext_jid, NULL);380 imcb_remove_buddy(ic, bud->ext_jid, reason); 340 381 } 341 382 if (s) { 342 383 *s = '/'; 343 384 } 385 386 g_free(reason); 344 387 } 345 388 … … 360 403 char *final_from = NULL; 361 404 char *bare_jid = NULL; 405 guint32 flags = 0; 362 406 363 407 from = (bud) ? bud->full_jid : xt_find_attr(node, "from"); … … 396 440 397 441 if (subject && chat) { 398 char *subject_text = subject->text_len > 0 ? subject->text : NULL;442 char *subject_text = subject->text_len > 0 ? subject->text : ""; 399 443 if (g_strcmp0(chat->topic, subject_text) != 0) { 400 444 bare_jid = (bud) ? jabber_get_bare_jid(bud->ext_jid) : NULL; … … 402 446 jabber_get_timestamp(node)); 403 447 g_free(bare_jid); 448 bare_jid = NULL; 404 449 } 405 450 } … … 422 467 imcb_chat_log(chat, "From conference server: %s", body->text); 423 468 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*/469 } else if (jc && jc->flags & JCFLAG_MESSAGE_SENT && bud == jc->me && 470 (jabber_cache_handle_packet(ic, node) == XT_ABORT)) { 471 /* Self message marked by this bitlbee, don't show it */ 427 472 return; 428 473 } 429 474 430 if (bud && jc && bud != jc->me) {475 if (bud) { 431 476 bare_jid = jabber_get_bare_jid(bud->ext_jid ? bud->ext_jid : bud->full_jid); 432 477 final_from = bare_jid; 478 flags = (bud == jc->me) ? OPT_SELFMESSAGE : 0; 433 479 } else { 434 480 final_from = nick; 435 481 } 436 482 437 imcb_chat_msg(chat, final_from, body->text, 0, jabber_get_timestamp(node));483 imcb_chat_msg(chat, final_from, body->text, flags, jabber_get_timestamp(node)); 438 484 439 485 g_free(bare_jid);
Note: See TracChangeset
for help on using the changeset viewer.