comparison mcabber/mcabber/commands.c @ 1938:26e437e79e60

Fix MUC whois / auto_whois This patch should fix issue #68: https://bitbucket.org/McKael/mcabber-crew/issue/68/
author Mikael Berthe <mikael@lilotux.net>
date Sat, 12 Feb 2011 19:00:59 +0100
parents 924f4552996c
children 932d1b250a55
comparison
equal deleted inserted replaced
1937:118524e9d7b6 1938:26e437e79e60
2828 free_arg_lst(paramlst); 2828 free_arg_lst(paramlst);
2829 } 2829 }
2830 2830
2831 // cmd_room_whois(..) 2831 // cmd_room_whois(..)
2832 // If interactive is TRUE, chatmode can be enabled. 2832 // If interactive is TRUE, chatmode can be enabled.
2833 void cmd_room_whois(gpointer bud, char *arg, guint interactive) 2833 // Please note that usernick is expected in UTF-8 locale iff interactive is FALSE
2834 { 2834 // (in order to work correctly with auto_whois).
2835 char **paramlst; 2835 void cmd_room_whois(gpointer bud, const char *usernick, guint interactive)
2836 {
2837 char **paramlst = NULL;
2836 gchar *nick, *buffer; 2838 gchar *nick, *buffer;
2837 const char *bjid, *realjid; 2839 const char *bjid, *realjid;
2838 const char *rst_msg; 2840 const char *rst_msg;
2839 gchar rprio; 2841 gchar rprio;
2840 enum imstatus rstatus; 2842 enum imstatus rstatus;
2841 enum imrole role; 2843 enum imrole role;
2842 enum imaffiliation affil; 2844 enum imaffiliation affil;
2843 time_t rst_time; 2845 time_t rst_time;
2844 guint msg_flag = HBB_PREFIX_INFO; 2846 guint msg_flag = HBB_PREFIX_INFO;
2845 2847
2846 paramlst = split_arg(arg, 1, 0); // nickname 2848 if (interactive) {
2847 nick = *paramlst; 2849 paramlst = split_arg(usernick, 1, 0); // nickname
2850 nick = to_utf8(*paramlst);
2851 } else {
2852 nick = g_strdup(usernick);
2853 }
2848 2854
2849 if (!nick || !*nick) { 2855 if (!nick || !*nick) {
2850 scr_LogPrint(LPRINT_NORMAL, "Please specify a nickname."); 2856 scr_LogPrint(LPRINT_NORMAL, "Please specify a nickname.");
2851 free_arg_lst(paramlst); 2857 if (paramlst)
2852 return; 2858 free_arg_lst(paramlst);
2853 } 2859 return;
2854 2860 }
2855 nick = to_utf8(nick);
2856 2861
2857 if (interactive) { 2862 if (interactive) {
2858 // Enter chat mode 2863 // Enter chat mode
2859 scr_set_chatmode(TRUE); 2864 scr_set_chatmode(TRUE);
2860 scr_show_buddy_window(); 2865 scr_show_buddy_window();
2864 bjid = buddy_getjid(bud); 2869 bjid = buddy_getjid(bud);
2865 rstatus = buddy_getstatus(bud, nick); 2870 rstatus = buddy_getstatus(bud, nick);
2866 2871
2867 if (rstatus == offline) { 2872 if (rstatus == offline) {
2868 scr_LogPrint(LPRINT_NORMAL, "No such member: %s", nick); 2873 scr_LogPrint(LPRINT_NORMAL, "No such member: %s", nick);
2869 free_arg_lst(paramlst); 2874 if (paramlst)
2875 free_arg_lst(paramlst);
2870 g_free(nick); 2876 g_free(nick);
2871 return; 2877 return;
2872 } 2878 }
2873 2879
2874 rst_time = buddy_getstatustime(bud, nick); 2880 rst_time = buddy_getstatustime(bud, nick);
2910 2916
2911 scr_WriteIncomingMessage(bjid, "End of WHOIS", 0, msg_flag, 0); 2917 scr_WriteIncomingMessage(bjid, "End of WHOIS", 0, msg_flag, 0);
2912 2918
2913 g_free(buffer); 2919 g_free(buffer);
2914 g_free(nick); 2920 g_free(nick);
2915 free_arg_lst(paramlst); 2921 if (paramlst)
2922 free_arg_lst(paramlst);
2916 } 2923 }
2917 2924
2918 static void room_bookmark(gpointer bud, char *arg) 2925 static void room_bookmark(gpointer bud, char *arg)
2919 { 2926 {
2920 const char *roomid; 2927 const char *roomid;