comparison mcabber/mcabber/xmpp_muc.c @ 2005:e0aedfa091ec

Print real jids in non-anonymous rooms.
author Hermitifier
date Tue, 07 Feb 2012 12:13:02 +0100
parents 024bdd1c6418
children fa6694a193ec
comparison
equal deleted inserted replaced
2004:aa7e03c35488 2005:e0aedfa091ec
348 // This function will return the new_member value TRUE if somebody else joins 348 // This function will return the new_member value TRUE if somebody else joins
349 // the room (and FALSE if _we_ are joining the room). 349 // the room (and FALSE if _we_ are joining the room).
350 static bool muc_handle_join(const GSList *room_elt, const char *rname, 350 static bool muc_handle_join(const GSList *room_elt, const char *rname,
351 const char *roomjid, const char *ournick, 351 const char *roomjid, const char *ournick,
352 enum room_printstatus printstatus, 352 enum room_printstatus printstatus,
353 time_t usttime, int log_muc_conf) 353 time_t usttime, int log_muc_conf,
354 enum room_autowhois autowhois, const char *mbjid)
354 { 355 {
355 bool new_member = FALSE; // True if somebody else joins the room (not us) 356 bool new_member = FALSE; // True if somebody else joins the room (not us)
357 gchar *nickjid;
356 gchar *mbuf; 358 gchar *mbuf;
357 enum room_flagjoins flagjoins; 359 enum room_flagjoins flagjoins;
360
361 if (mbjid && autowhois == autowhois_off)
362 nickjid = g_strdup_printf("%s <%s>", rname, mbjid);
363 else
364 nickjid = g_strdup(rname);
358 365
359 if (!buddy_getinsideroom(room_elt->data)) { 366 if (!buddy_getinsideroom(room_elt->data)) {
360 // We weren't inside the room yet. Now we are. 367 // We weren't inside the room yet. Now we are.
361 // However, this could be a presence packet from another room member 368 // However, this could be a presence packet from another room member
362 369
378 HBB_PREFIX_INFO|HBB_PREFIX_NOFLAG, 0); 385 HBB_PREFIX_INFO|HBB_PREFIX_NOFLAG, 0);
379 if (log_muc_conf) 386 if (log_muc_conf)
380 hlog_write_message(roomjid, 0, -1, mbuf); 387 hlog_write_message(roomjid, 0, -1, mbuf);
381 g_free(mbuf); 388 g_free(mbuf);
382 if (printstatus != status_none) 389 if (printstatus != status_none)
383 mbuf = g_strdup_printf("%s has joined", rname); 390 mbuf = g_strdup_printf("%s has joined", nickjid);
384 else 391 else
385 mbuf = NULL; 392 mbuf = NULL;
386 new_member = TRUE; 393 new_member = TRUE;
387 } 394 }
388 } else { 395 } else {
389 mbuf = NULL; 396 mbuf = NULL;
390 if (strcmp(ournick, rname)) { 397 if (strcmp(ournick, rname)) {
391 if (printstatus != status_none) 398 if (printstatus != status_none)
392 mbuf = g_strdup_printf("%s has joined", rname); 399 mbuf = g_strdup_printf("%s has joined", nickjid);
393 new_member = TRUE; 400 new_member = TRUE;
394 } 401 }
395 } 402 }
403
404 g_free(nickjid);
396 405
397 if (mbuf) { 406 if (mbuf) {
398 guint msgflags = HBB_PREFIX_INFO; 407 guint msgflags = HBB_PREFIX_INFO;
399 flagjoins = buddy_getflagjoins(room_elt->data); 408 flagjoins = buddy_getflagjoins(room_elt->data);
400 if (flagjoins == flagjoins_default && 409 if (flagjoins == flagjoins_default &&
571 // Maybe it's _our_ nickname... 580 // Maybe it's _our_ nickname...
572 if (our_presence) 581 if (our_presence)
573 buddy_setnickname(room_elt->data, mbnick); 582 buddy_setnickname(room_elt->data, mbnick);
574 nickchange = TRUE; 583 nickchange = TRUE;
575 } 584 }
585
586 autowhois = buddy_getautowhois(room_elt->data);
587 if (autowhois == autowhois_default)
588 autowhois = (settings_opt_get_int("muc_auto_whois") ?
589 autowhois_on : autowhois_off);
576 590
577 // Check for departure/arrival 591 // Check for departure/arrival
578 if (statuscode != 303 && ust == offline) { 592 if (statuscode != 303 && ust == offline) {
579 // Somebody is leaving 593 // Somebody is leaving
580 enum { leave=0, kick, ban } how = leave; 594 enum { leave=0, kick, ban } how = leave;
678 } else { 692 } else {
679 enum imstatus old_ust = buddy_getstatus(room_elt->data, rname); 693 enum imstatus old_ust = buddy_getstatus(room_elt->data, rname);
680 if (old_ust == offline && ust != offline) { 694 if (old_ust == offline && ust != offline) {
681 // Somebody is joining 695 // Somebody is joining
682 new_member = muc_handle_join(room_elt, rname, roomjid, ournick, 696 new_member = muc_handle_join(room_elt, rname, roomjid, ournick,
683 printstatus, usttime, log_muc_conf); 697 printstatus, usttime, log_muc_conf,
698 autowhois, mbjid);
684 } else { 699 } else {
685 // This is a simple member status change 700 // This is a simple member status change
686 701
687 if (printstatus == status_all && !nickchange) { 702 if (printstatus == status_all && !nickchange) {
688 const char *old_ustmsg = buddy_getstatusmsg(room_elt->data, rname); 703 const char *old_ustmsg = buddy_getstatusmsg(room_elt->data, rname);
702 return; 717 return;
703 718
704 // Update room member status 719 // Update room member status
705 roster_setstatus(roomjid, rname, bpprio, ust, ustmsg, usttime, 720 roster_setstatus(roomjid, rname, bpprio, ust, ustmsg, usttime,
706 mbrole, mbaffil, mbjid); 721 mbrole, mbaffil, mbjid);
707
708 autowhois = buddy_getautowhois(room_elt->data);
709 if (autowhois == autowhois_default)
710 autowhois = (settings_opt_get_int("muc_auto_whois") ?
711 autowhois_on : autowhois_off);
712 722
713 if (new_member && autowhois == autowhois_on) { 723 if (new_member && autowhois == autowhois_on) {
714 cmd_room_whois(room_elt->data, rname, FALSE); 724 cmd_room_whois(room_elt->data, rname, FALSE);
715 } 725 }
716 726