Mercurial > ~mikael > mcabber > hg
comparison mcabber/src/commands.c @ 1292:382ec54b584e
Muc nick coloring functionality
author | Michal 'vorner' Vaner <vorner@ucw.cz> |
---|---|
date | Tue, 28 Aug 2007 10:11:39 +0200 |
parents | e42f48103609 |
children | 3b338a5c01fc |
comparison
equal
deleted
inserted
replaced
1291:9f64f548ac16 | 1292:382ec54b584e |
---|---|
255 compl_add_category_word(COMPL_PGP, "info"); | 255 compl_add_category_word(COMPL_PGP, "info"); |
256 compl_add_category_word(COMPL_PGP, "setkey"); | 256 compl_add_category_word(COMPL_PGP, "setkey"); |
257 | 257 |
258 // Color category | 258 // Color category |
259 compl_add_category_word(COMPL_COLOR, "roster"); | 259 compl_add_category_word(COMPL_COLOR, "roster"); |
260 compl_add_category_word(COMPL_COLOR, "muc"); | |
261 compl_add_category_word(COMPL_COLOR, "mucnick"); | |
260 } | 262 } |
261 | 263 |
262 // expandalias(line) | 264 // expandalias(line) |
263 // If there is one, expand the alias in line and returns a new allocated line | 265 // If there is one, expand the alias in line and returns a new allocated line |
264 // If no alias is found, returns line | 266 // If no alias is found, returns line |
722 return; | 724 return; |
723 } | 725 } |
724 | 726 |
725 if (!strcasecmp(subcmd, "roster")) { | 727 if (!strcasecmp(subcmd, "roster")) { |
726 char **arglist = split_arg(arg, 3, 0); | 728 char **arglist = split_arg(arg, 3, 0); |
727 char *status = *arglist, *wildcard = arglist[1], *color = arglist[2]; | 729 char *status = *arglist, *wildcard = to_utf8(arglist[1]), *color = arglist[2]; |
728 if (status && !strcmp(status, "clear")) { // Not a color command, clear all | 730 if (status && !strcmp(status, "clear")) { // Not a color command, clear all |
729 scr_RosterClearColor(); | 731 scr_RosterClearColor(); |
730 update_roster = TRUE; | 732 update_roster = TRUE; |
731 } else { | 733 } else { |
732 if (!status || !*status || !wildcard || !*wildcard || !color || !*color) { | 734 if (!status || !*status || !wildcard || !*wildcard || !color || !*color) { |
734 } else { | 736 } else { |
735 update_roster = scr_RosterColor(status, wildcard, color) | 737 update_roster = scr_RosterColor(status, wildcard, color) |
736 || update_roster; | 738 || update_roster; |
737 } | 739 } |
738 } | 740 } |
741 free_arg_lst(arglist); | |
742 g_free(wildcard); | |
743 } else if (!strcasecmp(subcmd, "muc")) { | |
744 char **arglist = split_arg(arg, 2, 0); | |
745 char *free_muc = to_utf8(*arglist); | |
746 const char *muc = free_muc, *mode = arglist[1]; | |
747 if (!muc || !*muc) | |
748 scr_LogPrint(LPRINT_NORMAL, "What MUC?"); | |
749 else { | |
750 if (!strcmp(muc, ".")) | |
751 if (!(muc = CURRENT_JID)) | |
752 scr_LogPrint(LPRINT_NORMAL, "No JID selected"); | |
753 if (muc) { | |
754 if (check_jid_syntax(muc) && strcmp(muc, "*")) | |
755 scr_LogPrint(LPRINT_NORMAL, "Not a JID"); | |
756 else { | |
757 if (!mode || !*mode || !strcasecmp(mode, "on")) | |
758 scr_MucColor(muc, MC_ALL); | |
759 else if (!strcasecmp(mode, "preset")) | |
760 scr_MucColor(muc, MC_PRESET); | |
761 else if (!strcasecmp(mode, "off")) | |
762 scr_MucColor(muc, MC_OFF); | |
763 else if (!strcmp(mode, "-")) | |
764 scr_MucColor(muc, MC_REMOVE); | |
765 else | |
766 scr_LogPrint(LPRINT_NORMAL, "Unknown coloring mode"); | |
767 } | |
768 } | |
769 } | |
770 free_arg_lst(arglist); | |
771 g_free(free_muc); | |
772 } else if (!strcasecmp(subcmd, "mucnick")) { | |
773 char **arglist = split_arg(arg, 2, 0); | |
774 const char *nick = *arglist, *color = arglist[1]; | |
775 if (!nick || !*nick || !color || !*color) | |
776 scr_LogPrint(LPRINT_NORMAL, "Missing argument"); | |
777 else | |
778 scr_MucNickColor(nick, color); | |
739 free_arg_lst(arglist); | 779 free_arg_lst(arglist); |
740 } else | 780 } else |
741 scr_LogPrint(LPRINT_NORMAL, "Unrecognized parameter!"); | 781 scr_LogPrint(LPRINT_NORMAL, "Unrecognized parameter!"); |
742 free_arg_lst(paramlst); | 782 free_arg_lst(paramlst); |
743 } | 783 } |