Changes in irc_im.c [03df717:24de9fa]
Legend:
- Unmodified
- Added
- Removed
-
irc_im.c
r03df717 r24de9fa 84 84 } 85 85 86 /* Sanitize */87 str_reject_chars(iu->user, " ", '_');88 str_reject_chars(iu->host, " ", '_');86 while ((s = strchr(iu->user, ' '))) { 87 *s = '_'; 88 } 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);126 120 } 127 121 … … 207 201 } 208 202 209 static gboolean bee_irc_user_msg(bee_t *bee, bee_user_t *bu, const char *msg_, guint32 flags,time_t sent_at)203 static gboolean bee_irc_user_msg(bee_t *bee, bee_user_t *bu, const char *msg_, time_t sent_at) 210 204 { 211 205 irc_t *irc = bee->ui_data; 212 206 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;215 207 const char *dst; 216 208 char *prefix = NULL; 217 209 char *wrapped, *ts = NULL; 218 210 char *msg = g_strdup(msg_); 219 char *message_type = "PRIVMSG";220 211 GSList *l; 221 212 … … 225 216 226 217 dst = irc_user_msgdest(iu); 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 ? : ""); 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 ? : ""); 265 221 } else { 266 222 prefix = ts; … … 293 249 294 250 wrapped = word_wrap(msg, 425); 295 irc_send_msg( src_iu, message_type, dst, wrapped, prefix);251 irc_send_msg(iu, "PRIVMSG", dst, wrapped, prefix); 296 252 g_free(wrapped); 297 253 … … 304 260 } 305 261 306 static gboolean bee_irc_user_typing(bee_t *bee, bee_user_t *bu, guint32flags)262 static gboolean bee_irc_user_typing(bee_t *bee, bee_user_t *bu, uint32_t flags) 307 263 { 308 264 irc_t *irc = (irc_t *) bee->ui_data; … … 661 617 } 662 618 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)619 static gboolean bee_irc_chat_msg(bee_t *bee, struct groupchat *c, bee_user_t *bu, const char *msg, time_t sent_at) 664 620 { 665 621 irc_t *irc = bee->ui_data; 666 irc_user_t *iu = flags & OPT_SELFMESSAGE ? irc->user :bu->ui_data;622 irc_user_t *iu = bu->ui_data; 667 623 irc_channel_t *ic = c->ui_data; 668 624 char *wrapped, *ts = NULL; … … 698 654 } 699 655 700 static gboolean bee_irc_chat_remove_user(bee_t *bee, struct groupchat *c, bee_user_t *bu , const char *reason)656 static gboolean bee_irc_chat_remove_user(bee_t *bee, struct groupchat *c, bee_user_t *bu) 701 657 { 702 658 irc_t *irc = bee->ui_data; … … 710 666 using imcb_chat_free() and the channel was IRC_CHANNEL_TEMP, we get into 711 667 a broken state around here. */ 712 irc_channel_del_user(ic, bu == bee->user ? irc->user : bu->ui_data, IRC_CDU_PART, reason);668 irc_channel_del_user(ic, bu == bee->user ? irc->user : bu->ui_data, IRC_CDU_PART, NULL); 713 669 714 670 return TRUE; … … 883 839 acc->prpl->chat_join) { 884 840 char *nick; 885 struct groupchat *gc;886 841 887 842 if (!(nick = set_getstr(&ic->set, "nick"))) { … … 890 845 891 846 ic->flags |= IRC_CHANNEL_CHAT_PICKME; 892 gc =acc->prpl->chat_join(acc->ic, room, nick, NULL, &ic->set);847 acc->prpl->chat_join(acc->ic, room, nick, NULL, &ic->set); 893 848 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 }898 849 899 850 return FALSE; … … 912 863 } 913 864 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 } 865 /* Remove the reference. We don't need it anymore. */ 866 ic->data = NULL; 919 867 920 868 return TRUE; … … 1107 1055 df->proto_finished = TRUE; 1108 1056 } 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);1116 1057 } 1117 1058 … … 1144 1085 bee_irc_ft_close, 1145 1086 bee_irc_ft_finished, 1146 1147 bee_irc_log,1148 1087 };
Note: See TracChangeset
for help on using the changeset viewer.