- Timestamp:
- 2015-11-21T00:01:50Z (8 years ago)
- Parents:
- e4f08bf (diff), 8fdeaa5 (diff)
Note: this is a merge changeset, the changes displayed below correspond to the merge itself.
Use the(diff)
links above to see all the changes relative to each parent. - File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
irc_im.c
re4f08bf r29ff5c2 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; … … 646 690 } 647 691 648 static gboolean bee_irc_chat_msg(bee_t *bee, struct groupchat *c, bee_user_t *bu, const char *msg, time_t sent_at)692 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) 649 693 { 650 694 irc_t *irc = bee->ui_data; 651 irc_user_t *iu = bu->ui_data;695 irc_user_t *iu = flags & OPT_SELFMESSAGE ? irc->user : bu->ui_data; 652 696 irc_channel_t *ic = c->ui_data; 653 697 char *wrapped, *ts = NULL; … … 683 727 } 684 728 685 static gboolean bee_irc_chat_remove_user(bee_t *bee, struct groupchat *c, bee_user_t *bu )729 static gboolean bee_irc_chat_remove_user(bee_t *bee, struct groupchat *c, bee_user_t *bu, const char *reason) 686 730 { 687 731 irc_t *irc = bee->ui_data; … … 695 739 using imcb_chat_free() and the channel was IRC_CHANNEL_TEMP, we get into 696 740 a broken state around here. */ 697 irc_channel_del_user(ic, bu == bee->user ? irc->user : bu->ui_data, IRC_CDU_PART, NULL);741 irc_channel_del_user(ic, bu == bee->user ? irc->user : bu->ui_data, IRC_CDU_PART, reason); 698 742 699 743 return TRUE; … … 867 911 (room = set_getstr(&ic->set, "room")) && 868 912 (acc = account_get(ic->irc->b, acc_s)) && 869 acc->ic && acc->prpl->chat_join) { 913 acc->ic && (acc->ic->flags & OPT_LOGGED_IN) && 914 acc->prpl->chat_join) { 870 915 char *nick; 871 916 … … 893 938 } 894 939 895 /* Remove the reference. We don't need it anymore. */ 896 ic->data = NULL; 940 if (!(ic->flags & IRC_CHANNEL_TEMP)) { 941 /* Remove the reference. 942 * We only need it for temp channels that are being freed */ 943 ic->data = NULL; 944 } 897 945 898 946 return TRUE;
Note: See TracChangeset
for help on using the changeset viewer.