/* * Process a new message passed to us on the message queue from some * protocol. This includes adding it to the message list, updating the * view and scrolling if appropriate, logging it, and so on. * * Either a pointer is kept to the message internally, or it is freed * if unneeded. The caller no longer ``owns'' the message's memory. * * Returns 1 if the message was added to the message list, and 0 if it * was ignored due to user settings or otherwise. */ static int owl_process_message(owl_message *m) { const owl_filter *f; /* if this message it on the puntlist, nuke it and continue */ if (owl_global_message_is_puntable(&g, m)) { owl_message_delete(m); return 0; } /* login or logout that should be ignored? */ if (owl_global_is_ignorelogins(&g) && owl_message_is_loginout(m)) { owl_message_delete(m); return 0; } if (!owl_global_is_displayoutgoing(&g) && owl_message_is_direction_out(m)) { owl_message_delete(m); return 0; } /* add it to the global list */ owl_messagelist_append_element(owl_global_get_msglist(&g), m); /* add it to any necessary views; right now there's only the current view */ owl_view_consider_message(owl_global_get_current_view(&g), m); if(owl_message_is_direction_in(m)) { /* let perl know about it*/ owl_perlconfig_getmsg(m, NULL); /* do we need to autoreply? */ if (owl_global_is_zaway(&g) && !owl_message_get_attribute_value(m, "isauto")) { if (owl_message_is_type_zephyr(m)) { owl_zephyr_zaway(m); } else if (owl_message_is_type_aim(m)) { if (owl_message_is_private(m)) { owl_function_send_aimawymsg(owl_message_get_sender(m), owl_global_get_zaway_msg(&g)); } } } /* ring the bell if it's a personal */ if (!strcmp(owl_global_get_personalbell(&g), "on")) { if (!owl_message_is_loginout(m) && !owl_message_is_mail(m) && owl_message_is_personal(m)) { owl_function_beep(); } } else if (!strcmp(owl_global_get_personalbell(&g), "off")) { /* do nothing */ } else { f=owl_global_get_filter(&g, owl_global_get_personalbell(&g)); if (f && owl_filter_message_match(f, m)) { owl_function_beep(); } } /* if it matches the alert filter, do the alert action */ f=owl_global_get_filter(&g, owl_global_get_alert_filter(&g)); if (f && owl_filter_message_match(f, m)) { owl_function_command_norv(owl_global_get_alert_action(&g)); } /* if it's a zephyr login or logout, update the zbuddylist */ if (owl_message_is_type_zephyr(m) && owl_message_is_loginout(m)) { if (owl_message_is_login(m)) { owl_zbuddylist_adduser(owl_global_get_zephyr_buddylist(&g), owl_message_get_sender(m)); } else if (owl_message_is_logout(m)) { owl_zbuddylist_deluser(owl_global_get_zephyr_buddylist(&g), owl_message_get_sender(m)); } else { owl_function_error("Internal error: received login notice that is neither login nor logout"); } } } /* let perl know about it */ owl_perlconfig_newmsg(m, NULL); /* log the message if we need to */ owl_log_message(m); /* redraw the sepbar; TODO: don't violate layering */ owl_global_sepbar_dirty(&g); return 1; }
static void sepbar_redraw(owl_window *w, WINDOW *sepwin, void *user_data) { const owl_messagelist *ml; const owl_view *v; int x, y, i; const char *foo, *appendtosepbar; ml=owl_global_get_msglist(&g); v=owl_global_get_current_view(&g); werase(sepwin); wattron(sepwin, A_REVERSE); if (owl_global_is_fancylines(&g)) { whline(sepwin, ACS_HLINE, owl_global_get_cols(&g)); } else { whline(sepwin, '-', owl_global_get_cols(&g)); } if (owl_global_is_sepbar_disable(&g)) { getyx(sepwin, y, x); wmove(sepwin, y, owl_global_get_cols(&g)-1); return; } wmove(sepwin, 0, 2); if (owl_messagelist_get_size(ml) == 0) waddstr(sepwin, " (-/-) "); else wprintw(sepwin, " (%i/%i/%i) ", owl_global_get_curmsg(&g) + 1, owl_view_get_size(v), owl_messagelist_get_size(ml)); foo=owl_view_get_filtname(v); if (strcmp(foo, owl_global_get_view_home(&g))) wattroff(sepwin, A_REVERSE); wprintw(sepwin, " %s ", owl_view_get_filtname(v)); if (strcmp(foo, owl_global_get_view_home(&g))) wattron(sepwin, A_REVERSE); if (owl_mainwin_is_curmsg_truncated(owl_global_get_mainwin(&g))) { getyx(sepwin, y, x); wmove(sepwin, y, x+2); wattron(sepwin, A_BOLD); waddstr(sepwin, " <truncated> "); wattroff(sepwin, A_BOLD); } i=owl_mainwin_get_last_msg(owl_global_get_mainwin(&g)); if ((i != -1) && (i < owl_view_get_size(v)-1)) { getyx(sepwin, y, x); wmove(sepwin, y, x+2); wattron(sepwin, A_BOLD); waddstr(sepwin, " <more> "); wattroff(sepwin, A_BOLD); } if (owl_global_get_rightshift(&g)>0) { getyx(sepwin, y, x); wmove(sepwin, y, x+2); wprintw(sepwin, " right: %i ", owl_global_get_rightshift(&g)); } if (owl_global_is_zaway(&g) || owl_global_is_aaway(&g)) { getyx(sepwin, y, x); wmove(sepwin, y, x+2); wattron(sepwin, A_BOLD); wattroff(sepwin, A_REVERSE); if (owl_global_is_zaway(&g) && owl_global_is_aaway(&g)) { waddstr(sepwin, " AWAY "); } else if (owl_global_is_zaway(&g)) { waddstr(sepwin, " Z-AWAY "); } else if (owl_global_is_aaway(&g)) { waddstr(sepwin, " A-AWAY "); } wattron(sepwin, A_REVERSE); wattroff(sepwin, A_BOLD); } if (owl_global_get_curmsg_vert_offset(&g)) { getyx(sepwin, y, x); wmove(sepwin, y, x+2); wattron(sepwin, A_BOLD); wattroff(sepwin, A_REVERSE); waddstr(sepwin, " SCROLL "); wattron(sepwin, A_REVERSE); wattroff(sepwin, A_BOLD); } appendtosepbar = owl_global_get_appendtosepbar(&g); if (appendtosepbar && *appendtosepbar) { getyx(sepwin, y, x); wmove(sepwin, y, x+2); waddstr(sepwin, " "); waddstr(sepwin, owl_global_get_appendtosepbar(&g)); waddstr(sepwin, " "); } getyx(sepwin, y, x); wmove(sepwin, y, owl_global_get_cols(&g)-1); wattroff(sepwin, A_BOLD); wattroff(sepwin, A_REVERSE); }