Changes in irc_im.c [24de9fa:03df717]
Legend:
- Unmodified
- Added
- Removed
-
irc_im.c
r24de9fa r03df717 84 84 } 85 85 86 while ((s = strchr(iu->user, ' '))) {87 *s = '_';88 }86 /* Sanitize */ 87 str_reject_chars(iu->user, " ", '_'); 88 str_reject_chars(iu->host, " ", '_'); 89 89 90 90 if (bu->flags & BEE_USER_LOCAL) { … … 118 118 if (bu->flags & BEE_USER_AWAY || !(bu->flags & BEE_USER_ONLINE)) { 119 119 iu->flags |= IRC_USER_AWAY; 120 } 121 122 if ((irc->caps & CAP_AWAY_NOTIFY) && 123 ((bu->flags & BEE_USER_AWAY) != (old->flags & BEE_USER_AWAY) || 124 (bu->flags & BEE_USER_ONLINE) != (old->flags & BEE_USER_ONLINE))) { 125 irc_send_away_notify(iu); 120 126 } 121 127 … … 201 207 } 202 208 203 static gboolean bee_irc_user_msg(bee_t *bee, bee_user_t *bu, const char *msg_, time_t sent_at)209 static gboolean bee_irc_user_msg(bee_t *bee, bee_user_t *bu, const char *msg_, guint32 flags, time_t sent_at) 204 210 { 205 211 irc_t *irc = bee->ui_data; 206 212 irc_user_t *iu = (irc_user_t *) bu->ui_data; 213 irc_user_t *src_iu = iu; 214 irc_user_t *dst_iu = irc->user; 207 215 const char *dst; 208 216 char *prefix = NULL; 209 217 char *wrapped, *ts = NULL; 210 218 char *msg = g_strdup(msg_); 219 char *message_type = "PRIVMSG"; 211 220 GSList *l; 212 221 … … 216 225 217 226 dst = irc_user_msgdest(iu); 218 if (dst != irc->user->nick) { 219 /* if not messaging directly, call user by name */ 220 prefix = g_strdup_printf("%s%s%s", irc->user->nick, set_getstr(&bee->set, "to_char"), ts ? : ""); 227 228 if (flags & OPT_SELFMESSAGE) { 229 char *setting = set_getstr(&irc->b->set, "self_messages"); 230 231 if (is_bool(setting)) { 232 if (bool2int(setting)) { 233 /* set to true, send it with src/dst flipped */ 234 235 dst_iu = iu; 236 src_iu = irc->user; 237 238 if (dst == irc->user->nick) { 239 dst = dst_iu->nick; 240 } 241 } else { 242 /* set to false, skip the message completely */ 243 goto cleanup; 244 } 245 } else if (g_strncasecmp(setting, "prefix", 6) == 0) { 246 /* third state, prefix, loosely imitates the znc privmsg_prefix module */ 247 248 g_free(msg); 249 if (g_strncasecmp(msg_, "/me ", 4) == 0) { 250 msg = g_strdup_printf("/me -> %s", msg_ + 4); 251 } else { 252 msg = g_strdup_printf("-> %s", msg_); 253 } 254 255 if (g_strcasecmp(setting, "prefix_notice") == 0) { 256 message_type = "NOTICE"; 257 } 258 } 259 260 } 261 262 if (dst != dst_iu->nick) { 263 /* if not messaging directly (control channel), call user by name */ 264 prefix = g_strdup_printf("%s%s%s", dst_iu->nick, set_getstr(&bee->set, "to_char"), ts ? : ""); 221 265 } else { 222 266 prefix = ts; … … 249 293 250 294 wrapped = word_wrap(msg, 425); 251 irc_send_msg( iu, "PRIVMSG", dst, wrapped, prefix);295 irc_send_msg(src_iu, message_type, dst, wrapped, prefix); 252 296 g_free(wrapped); 253 297 … … 260 304 } 261 305 262 static gboolean bee_irc_user_typing(bee_t *bee, bee_user_t *bu, uint32_tflags)306 static gboolean bee_irc_user_typing(bee_t *bee, bee_user_t *bu, guint32 flags) 263 307 { 264 308 irc_t *irc = (irc_t *) bee->ui_data; … … 617 661 } 618 662 619 static gboolean bee_irc_chat_msg(bee_t *bee, struct groupchat *c, bee_user_t *bu, const char *msg, time_t sent_at)663 static gboolean bee_irc_chat_msg(bee_t *bee, struct groupchat *c, bee_user_t *bu, const char *msg, guint32 flags, time_t sent_at) 620 664 { 621 665 irc_t *irc = bee->ui_data; 622 irc_user_t *iu = bu->ui_data;666 irc_user_t *iu = flags & OPT_SELFMESSAGE ? irc->user : bu->ui_data; 623 667 irc_channel_t *ic = c->ui_data; 624 668 char *wrapped, *ts = NULL; … … 654 698 } 655 699 656 static gboolean bee_irc_chat_remove_user(bee_t *bee, struct groupchat *c, bee_user_t *bu )700 static gboolean bee_irc_chat_remove_user(bee_t *bee, struct groupchat *c, bee_user_t *bu, const char *reason) 657 701 { 658 702 irc_t *irc = bee->ui_data; … … 666 710 using imcb_chat_free() and the channel was IRC_CHANNEL_TEMP, we get into 667 711 a broken state around here. */ 668 irc_channel_del_user(ic, bu == bee->user ? irc->user : bu->ui_data, IRC_CDU_PART, NULL);712 irc_channel_del_user(ic, bu == bee->user ? irc->user : bu->ui_data, IRC_CDU_PART, reason); 669 713 670 714 return TRUE; … … 839 883 acc->prpl->chat_join) { 840 884 char *nick; 885 struct groupchat *gc; 841 886 842 887 if (!(nick = set_getstr(&ic->set, "nick"))) { … … 845 890 846 891 ic->flags |= IRC_CHANNEL_CHAT_PICKME; 847 acc->prpl->chat_join(acc->ic, room, nick, NULL, &ic->set);892 gc = acc->prpl->chat_join(acc->ic, room, nick, NULL, &ic->set); 848 893 ic->flags &= ~IRC_CHANNEL_CHAT_PICKME; 894 895 if (!gc) { 896 irc_send_num(ic->irc, 403, "%s :Error joining channel (check control channel?)", ic->name); 897 } 849 898 850 899 return FALSE; … … 863 912 } 864 913 865 /* Remove the reference. We don't need it anymore. */ 866 ic->data = NULL; 914 if (!(ic->flags & IRC_CHANNEL_TEMP)) { 915 /* Remove the reference. 916 * We only need it for temp channels that are being freed */ 917 ic->data = NULL; 918 } 867 919 868 920 return TRUE; … … 1055 1107 df->proto_finished = TRUE; 1056 1108 } 1109 } 1110 1111 static void bee_irc_log(bee_t *bee, const char *tag, const char *msg) 1112 { 1113 irc_t *irc = (irc_t *) bee->ui_data; 1114 1115 irc_rootmsg(irc, "%s - %s", tag, msg); 1057 1116 } 1058 1117 … … 1085 1144 bee_irc_ft_close, 1086 1145 bee_irc_ft_finished, 1146 1147 bee_irc_log, 1087 1148 };
Note: See TracChangeset
for help on using the changeset viewer.