comparison src/protocols/irc/irc.c @ 4621:69f028a6f357

[gaim-migrate @ 4912] Added half-op support, used on some IRC networks. Also fixed the bug where trying to IM a person in a chat with a @, %, or + prefix was keeping that prefix for the username in the IM window. committer: Tailor Script <tailor@pidgin.im>
author Christian Hammond <chipx86@chipx86.com>
date Thu, 27 Feb 2003 09:42:18 +0000
parents 5fcb44d771d2
children d19872836812
comparison
equal deleted inserted replaced
4620:fb520992d5a1 4621:69f028a6f357
757 irc_user_mode(struct gaim_connection *gc, char *room, char sign, char mode, char *nick) 757 irc_user_mode(struct gaim_connection *gc, char *room, char sign, char mode, char *nick)
758 { 758 {
759 struct gaim_conversation *c = irc_find_chat(gc, room); 759 struct gaim_conversation *c = irc_find_chat(gc, room);
760 GList *r; 760 GList *r;
761 761
762 if (mode != 'o' && mode != 'v') 762 if (mode != 'o' && mode != 'v' && mode != 'h')
763 return; 763 return;
764 764
765 if (!c) 765 if (!c)
766 return; 766 return;
767 767
768 r = gaim_chat_get_users(GAIM_CHAT(c)); 768 r = gaim_chat_get_users(GAIM_CHAT(c));
769 while (r) { 769 while (r) {
770 gboolean op = FALSE, voice = FALSE; 770 gboolean op = FALSE, halfop = FALSE, voice = FALSE;
771 char *who = r->data; 771 char *who = r->data;
772
772 if (*who == '@') { 773 if (*who == '@') {
773 op = TRUE; 774 op = TRUE;
774 who++; 775 who++;
775 } 776 }
777
778 if (*who == '%') {
779 halfop = TRUE;
780 who++;
781 }
782
776 if (*who == '+') { 783 if (*who == '+') {
777 voice = TRUE; 784 voice = TRUE;
778 who++; 785 who++;
779 } 786 }
787
780 if (!strcmp(who, nick)) { 788 if (!strcmp(who, nick)) {
781 char *tmp, buf[IRC_BUF_LEN]; 789 char *tmp, buf[IRC_BUF_LEN];
790
782 if (mode == 'o') { 791 if (mode == 'o') {
783 if (sign == '-') 792 if (sign == '-')
784 op = FALSE; 793 op = FALSE;
785 else 794 else
786 op = TRUE; 795 op = TRUE;
787 } 796 }
797
798 if (mode == 'h') {
799 if (sign == '-')
800 halfop = FALSE;
801 else
802 halfop = TRUE;
803 }
804
788 if (mode == 'v') { 805 if (mode == 'v') {
789 if (sign == '-') 806 if (sign == '-')
790 voice = FALSE; 807 voice = FALSE;
791 else 808 else
792 voice = TRUE; 809 voice = TRUE;
793 } 810 }
811
794 tmp = g_strdup(r->data); 812 tmp = g_strdup(r->data);
795 g_snprintf(buf, sizeof(buf), "%s%s%s", op ? "@" : "", 813 g_snprintf(buf, sizeof(buf), "%s%s%s",
796 voice ? "+" : "", nick); 814 (op ? "@" : (halfop ? "%" : "")),
815 voice ? "+" : "", nick);
797 gaim_chat_rename_user(GAIM_CHAT(c), tmp, buf); 816 gaim_chat_rename_user(GAIM_CHAT(c), tmp, buf);
798 g_free(tmp); 817 g_free(tmp);
799 return; 818 return;
800 } 819 }
801 r = r->next; 820 r = r->next;
1112 1131
1113 while (r) { 1132 while (r) {
1114 char *who = r->data; 1133 char *who = r->data;
1115 if (*who == '@') 1134 if (*who == '@')
1116 who++; 1135 who++;
1136 if (*who == '%')
1137 who++;
1117 if (*who == '+') 1138 if (*who == '+')
1118 who++; 1139 who++;
1119 if (!g_strcasecmp(who, nick)) { 1140 if (!g_strcasecmp(who, nick)) {
1120 char *tmp = g_strdup(r->data); 1141 char *tmp = g_strdup(r->data);
1121 gaim_chat_remove_user(chat, tmp, reason); 1142 gaim_chat_remove_user(chat, tmp, reason);
1151 1172
1152 while (r) { 1173 while (r) {
1153 char *who = r->data; 1174 char *who = r->data;
1154 int n = 0; 1175 int n = 0;
1155 if (*who == '@') 1176 if (*who == '@')
1177 buf[n++] = *who++;
1178 if (*who == '%')
1156 buf[n++] = *who++; 1179 buf[n++] = *who++;
1157 if (*who == '+') 1180 if (*who == '+')
1158 buf[n++] = *who++; 1181 buf[n++] = *who++;
1159 g_snprintf(buf + n, sizeof(buf) - n, "%s", new); 1182 g_snprintf(buf + n, sizeof(buf) - n, "%s", new);
1160 if (!strcmp(who, old)) { 1183 if (!strcmp(who, old)) {
1630 r = gaim_chat_get_users(GAIM_CHAT(c)); 1653 r = gaim_chat_get_users(GAIM_CHAT(c));
1631 1654
1632 while (r) { 1655 while (r) {
1633 char *who = r->data; 1656 char *who = r->data;
1634 if (*who == '@') 1657 if (*who == '@')
1658 who++;
1659 if (*who == '%')
1635 who++; 1660 who++;
1636 if (*who == '+') 1661 if (*who == '+')
1637 who++; 1662 who++;
1638 if (!g_strcasecmp(who, nick)) { 1663 if (!g_strcasecmp(who, nick)) {
1639 char *tmp = g_strdup(r->data); 1664 char *tmp = g_strdup(r->data);
2289 } 2314 }
2290 2315
2291 static int 2316 static int
2292 irc_send_im(struct gaim_connection *gc, char *who, char *what, int len, int flags) 2317 irc_send_im(struct gaim_connection *gc, char *who, char *what, int len, int flags)
2293 { 2318 {
2294 if (*who == '@' || *who == '+') 2319 if (*who == '@' || *who == '%' || *who == '+')
2295 return send_msg(gc, who + 1, what); 2320 return send_msg(gc, who + 1, what);
2296 return send_msg(gc, who, what); 2321 return send_msg(gc, who, what);
2297 } 2322 }
2298 2323
2299 /* IRC doesn't have a buddy list, but we can still figure out who's online with ISON */ 2324 /* IRC doesn't have a buddy list, but we can still figure out who's online with ISON */
2707 { 2732 {
2708 struct irc_data *idata = gc->proto_data; 2733 struct irc_data *idata = gc->proto_data;
2709 char buf[IRC_BUF_LEN]; 2734 char buf[IRC_BUF_LEN];
2710 2735
2711 if (*who == '@') 2736 if (*who == '@')
2737 who++;
2738 if (*who == '%')
2712 who++; 2739 who++;
2713 if (*who == '+') 2740 if (*who == '+')
2714 who++; 2741 who++;
2715 2742
2716 g_snprintf(buf, sizeof(buf), "WHOIS %s\r\n", who); 2743 g_snprintf(buf, sizeof(buf), "WHOIS %s\r\n", who);