comparison mcabber/mcabber/commands.c @ 2270:5d05e8128ef4

Use nick to set the role This should fix issue #152, reported by Stefan Haller.
author Mikael Berthe <mikael@lilotux.net>
date Sat, 17 Sep 2016 10:02:56 +0200
parents f5402d705f67
children 0d350e979bde
comparison
equal deleted inserted replaced
2269:766666eb6928 2270:5d05e8128ef4
2699 } 2699 }
2700 2700
2701 static void room_role(gpointer bud, char *arg) 2701 static void room_role(gpointer bud, char *arg)
2702 { 2702 {
2703 char **paramlst; 2703 char **paramlst;
2704 gchar *fjid, *rolename; 2704 gchar *nick, *rolename;
2705 struct role_affil ra; 2705 struct role_affil ra;
2706 const char *roomid = buddy_getjid(bud); 2706 const char *roomid = buddy_getjid(bud);
2707 2707
2708 paramlst = split_arg(arg, 3, 1); // jid, new_role, [reason] 2708 paramlst = split_arg(arg, 3, 1); // nick, new_role, [reason]
2709 fjid = *paramlst; 2709 nick = *paramlst;
2710 rolename = *(paramlst+1); 2710 rolename = *(paramlst+1);
2711 arg = *(paramlst+2); 2711 arg = *(paramlst+2);
2712 2712
2713 if (!fjid || !*fjid || !rolename || !*rolename) { 2713 if (!nick || !*nick || !rolename || !*rolename) {
2714 scr_LogPrint(LPRINT_NORMAL, "Please specify both a Jabber ID and a role."); 2714 scr_LogPrint(LPRINT_NORMAL, "Please specify both a nickname and a role.");
2715 free_arg_lst(paramlst); 2715 free_arg_lst(paramlst);
2716 return; 2716 return;
2717 } 2717 }
2718 2718
2719 ra.type = type_role; 2719 ra.type = type_role;
2721 for (; ra.val.role < imrole_size; ra.val.role++) 2721 for (; ra.val.role < imrole_size; ra.val.role++)
2722 if (!strcasecmp(rolename, strrole[ra.val.role])) 2722 if (!strcasecmp(rolename, strrole[ra.val.role]))
2723 break; 2723 break;
2724 2724
2725 if (ra.val.role < imrole_size) { 2725 if (ra.val.role < imrole_size) {
2726 gchar *jid_utf8, *reason_utf8; 2726 gchar *nick_utf8, *reason_utf8;
2727 jid_utf8 = to_utf8(fjid); 2727 nick_utf8 = to_utf8(nick);
2728 reason_utf8 = to_utf8(arg); 2728 reason_utf8 = to_utf8(arg);
2729 xmpp_room_setattrib(roomid, jid_utf8, NULL, ra, reason_utf8); 2729 xmpp_room_setattrib(roomid, NULL, nick_utf8, ra, reason_utf8);
2730 g_free(jid_utf8); 2730 g_free(nick_utf8);
2731 g_free(reason_utf8); 2731 g_free(reason_utf8);
2732 } else { 2732 } else {
2733 scr_LogPrint(LPRINT_NORMAL, "Wrong role parameter."); 2733 scr_LogPrint(LPRINT_NORMAL, "Wrong role parameter.");
2734 } 2734 }
2735 2735