comparison mcabber/src/commands.c @ 1648:63d8473df2c3

Fix encoding issues in room command * /room join * /room nick * /room privmsg
author Myhailo Danylenko <isbear@ukrpost.net>
date Mon, 16 Nov 2009 19:26:41 +0200
parents a57f2634ee7c
children 44bbdc961234
comparison
equal deleted inserted replaced
1647:cfa1fff86f78 1648:63d8473df2c3
2336 scr_LogPrint(LPRINT_NORMAL, "Invalid room name."); 2336 scr_LogPrint(LPRINT_NORMAL, "Invalid room name.");
2337 free_arg_lst(paramlst); 2337 free_arg_lst(paramlst);
2338 return; 2338 return;
2339 } else { 2339 } else {
2340 // The room id has been specified. Let's convert it and use it. 2340 // The room id has been specified. Let's convert it and use it.
2341 roomname_tmp = to_utf8(roomname); 2341 mc_strtolower(roomname);
2342 mc_strtolower(roomname_tmp); 2342 roomname = roomname_tmp = to_utf8(roomname);
2343 roomname = roomname_tmp;
2344 } 2343 }
2345 2344
2346 // If no nickname is provided with the /join command, 2345 // If no nickname is provided with the /join command,
2347 // we try to get a default nickname. 2346 // we try to get a default nickname.
2348 if (!nick || !*nick) 2347 if (!nick || !*nick)
2611 if (nick) 2610 if (nick)
2612 scr_LogPrint(LPRINT_NORMAL, "Your nickname is: %s", nick); 2611 scr_LogPrint(LPRINT_NORMAL, "Your nickname is: %s", nick);
2613 else 2612 else
2614 scr_LogPrint(LPRINT_NORMAL, "You have no nickname in this room."); 2613 scr_LogPrint(LPRINT_NORMAL, "You have no nickname in this room.");
2615 } else { 2614 } else {
2616 gchar *roomname, *roomname_tmp, *nick; 2615 gchar *nick = to_utf8(arg);
2617 roomname_tmp = g_strdup(buddy_getjid(bud));
2618 mc_strtolower(roomname_tmp);
2619 roomname = to_utf8(roomname_tmp);
2620 g_free(roomname_tmp);
2621
2622 nick = to_utf8(arg);
2623 strip_arg_special_chars(nick); 2616 strip_arg_special_chars(nick);
2624 2617 xmpp_room_join(buddy_getjid(bud), nick, NULL);
2625 xmpp_room_join(roomname, nick, NULL);
2626 g_free(roomname);
2627 g_free(nick); 2618 g_free(nick);
2628 } 2619 }
2629 } 2620 }
2630 2621
2631 static void room_privmsg(gpointer bud, char *arg) 2622 static void room_privmsg(gpointer bud, char *arg)
2632 { 2623 {
2633 char **paramlst; 2624 char **paramlst;
2634 gchar *fjid, *nick, *fjid_utf8, *msg; 2625 gchar *fjid_utf8, *nick, *nick_utf8, *msg;
2635 2626
2636 paramlst = split_arg(arg, 2, 1); // nickname, message 2627 paramlst = split_arg(arg, 2, 1); // nickname, message
2637 nick = *paramlst; 2628 nick = *paramlst;
2638 arg = *(paramlst+1); 2629 arg = *(paramlst+1);
2639 2630
2642 "Please specify both a Jabber ID and a message."); 2633 "Please specify both a Jabber ID and a message.");
2643 free_arg_lst(paramlst); 2634 free_arg_lst(paramlst);
2644 return; 2635 return;
2645 } 2636 }
2646 2637
2647 fjid = g_strdup_printf("%s/%s", buddy_getjid(bud), nick); 2638 nick_utf8 = to_utf8(nick);
2648 fjid_utf8 = to_utf8(fjid); 2639 fjid_utf8 = g_strdup_printf("%s/%s", buddy_getjid(bud), nick_utf8);
2640 g_free (nick_utf8);
2649 msg = to_utf8(arg); 2641 msg = to_utf8(arg);
2650 send_message_to(fjid_utf8, msg, NULL, LM_MESSAGE_SUB_TYPE_NOT_SET, FALSE); 2642 send_message_to(fjid_utf8, msg, NULL, LM_MESSAGE_SUB_TYPE_NOT_SET, FALSE);
2651 g_free(fjid);
2652 g_free(fjid_utf8); 2643 g_free(fjid_utf8);
2653 g_free(msg); 2644 g_free(msg);
2654 free_arg_lst(paramlst); 2645 free_arg_lst(paramlst);
2655 } 2646 }
2656 2647