comparison mcabber/mcabber/xmpp_muc.c @ 2126:36170c97a0b7

show actor's nick and jid on kick/ban if available
author sh!zeeg <shizeeque@gmail.com>
date Wed, 14 May 2014 17:57:20 +0400
parents fef71336e429
children a09cdfceae17
comparison
equal deleted inserted replaced
2125:fef71336e429 2126:36170c97a0b7
305 enum imrole *mbrole, enum imaffiliation *mbaffil, 305 enum imrole *mbrole, enum imaffiliation *mbaffil,
306 const char **mbjid, const char **mbnick, 306 const char **mbjid, const char **mbnick,
307 const char **actorjid, const char **reason) 307 const char **actorjid, const char **reason)
308 { 308 {
309 LmMessageNode *y, *z; 309 LmMessageNode *y, *z;
310 const char *p; 310 const char *p, *actornick;
311 311
312 y = lm_message_node_find_child(xmldata, "item"); 312 y = lm_message_node_find_child(xmldata, "item");
313 if (!y) 313 if (!y)
314 return; 314 return;
315 315
335 *mbjid = lm_message_node_get_attribute(y, "jid"); 335 *mbjid = lm_message_node_get_attribute(y, "jid");
336 *mbnick = lm_message_node_get_attribute(y, "nick"); 336 *mbnick = lm_message_node_get_attribute(y, "nick");
337 // For kick/ban, there can be actor and reason tags 337 // For kick/ban, there can be actor and reason tags
338 z = lm_message_node_find_child(y, "actor"); 338 z = lm_message_node_find_child(y, "actor");
339 if (z) { 339 if (z) {
340 // prefer nick over jid 340 actornick = lm_message_node_get_attribute(z, "nick");
341 *actorjid = lm_message_node_get_attribute(z, "nick"); 341 *actorjid = lm_message_node_get_attribute(z, "jid");
342 if (!*actorjid) 342 if (*actorjid) { // we have actor's jid, check if we also have nick.
343 *actorjid = lm_message_node_get_attribute(z, "jid"); 343 *actorjid = (!actornick) ? *actorjid : g_strdup_printf(
344 "%s <%s>", actornick, *actorjid
345 );
346 } else if (actornick) *actorjid = actornick; // we have nick only.
344 } 347 }
345 348
346 *reason = lm_message_node_get_child_value(y, "reason"); 349 *reason = lm_message_node_get_child_value(y, "reason");
347 if (*reason && !**reason) 350 if (*reason && !**reason)
348 *reason = NULL; 351 *reason = NULL;
625 if (how) { 628 if (how) {
626 gchar *mbuf_end; 629 gchar *mbuf_end;
627 gchar *reason_msg = NULL; 630 gchar *reason_msg = NULL;
628 // Forced leave 631 // Forced leave
629 if (actorjid) { 632 if (actorjid) {
630 mbuf_end = g_strdup_printf("%s from %s by <%s>.", 633 mbuf_end = g_strdup_printf("%s from %s by %s",
631 (how == ban ? "banned" : "kicked"), 634 (how == ban ? "banned" : "kicked"),
632 roomjid, actorjid); 635 roomjid, actorjid);
633 } else { 636 } else {
634 mbuf_end = g_strdup_printf("%s from %s.", 637 mbuf_end = g_strdup_printf("%s from %s",
635 (how == ban ? "banned" : "kicked"), 638 (how == ban ? "banned" : "kicked"),
636 roomjid); 639 roomjid);
637 } 640 }
638 if (reason) 641 if (reason)
639 reason_msg = g_strdup_printf("\nReason: %s", reason); 642 reason_msg = g_strdup_printf("\nReason: %s", reason);