diff options
author | James Booth <boothj5@gmail.com> | 2012-10-04 23:18:48 +0100 |
---|---|---|
committer | James Booth <boothj5@gmail.com> | 2012-10-04 23:18:48 +0100 |
commit | e486114e05b30357a96076c98d8423e962d8f491 (patch) | |
tree | 441d27717a54eda5307de67f289fc7b91f40e0e1 /src/windows.c | |
parent | 9e2306098617dad0683e7024dc9c0695a428a29a (diff) | |
download | profani-tty-e486114e05b30357a96076c98d8423e962d8f491.tar.gz |
Now checks for exitence of contact before sending message
Diffstat (limited to 'src/windows.c')
-rw-r--r-- | src/windows.c | 25 |
1 files changed, 17 insertions, 8 deletions
diff --git a/src/windows.c b/src/windows.c index 724a904f..872a3617 100644 --- a/src/windows.c +++ b/src/windows.c @@ -38,6 +38,7 @@ #include "command.h" #include "contact.h" +#include "contact_list.h" #include "log.h" #include "preferences.h" #include "ui.h" @@ -357,15 +358,23 @@ void win_show_outgoing_msg(const char * const from, const char * const to, const char * const message) { - int win_index = _find_prof_win_index(to); - if (win_index == NUM_WINS) - win_index = _new_prof_win(to); + // if the contact is offline, show a message + PContact contact = contact_list_get_contact(to); + + if (contact == NULL) { + cons_show("%s is not one of your contacts."); + } else { + int win_index = _find_prof_win_index(to); - WINDOW *win = _wins[win_index].win; - _win_show_time(win); - _win_show_user(win, from, 0); - _win_show_message(win, message); - _win_switch_if_active(win_index); + if (win_index == NUM_WINS) + win_index = _new_prof_win(to); + + WINDOW *win = _wins[win_index].win; + _win_show_time(win); + _win_show_user(win, from, 0); + _win_show_message(win, message); + _win_switch_if_active(win_index); + } } void |