Merge pull request #124 from vcuculo/sound_notification

Added support to sound notifications
This commit is contained in:
vysheng 2014-03-05 00:21:25 +03:00
commit 12e14e25e8
2 changed files with 15 additions and 1 deletions

View File

@ -51,6 +51,7 @@ char *default_prompt = "> ";
int unread_messages;
int msg_num_mode;
int alert_sound;
int safe_quit;
@ -901,6 +902,7 @@ void interpreter (char *line UU) {
"\t\tLevel 2: prints line, when somebody is typing in chat\n"
"\t\tLevel 3: prints line, when somebody changes online status\n"
"\tmsg_num - enables/disables numeration of messages\n"
"\talert - enables/disables alert sound notifications\n"
"chat_with_peer <peer> - starts chat with this peer. Every command after is message to this peer. Type /exit or /quit to end this mode\n"
);
pop_color ();
@ -1081,6 +1083,8 @@ void interpreter (char *line UU) {
log_level = num;
} else if (IS_WORD ("msg_num")) {
msg_num_mode = num;
} else if (IS_WORD ("alert")) {
alert_sound = num;
}
} else if (IS_WORD ("chat_with_peer")) {
GET_PEER;
@ -1483,6 +1487,9 @@ void print_message (struct message *M) {
} else {
printf (" »»» ");
}
if (alert_sound) {
play_sound();
}
}
} else if (get_peer_type (M->to_id) == PEER_ENCR_CHAT) {
peer_t *P = user_chat_get (M->to_id);
@ -1516,8 +1523,10 @@ void print_message (struct message *M) {
} else {
printf (" »»» ");
}
if (alert_sound) {
play_sound();
}
}
} else {
assert (get_peer_type (M->to_id) == PEER_CHAT);
push_color (COLOR_MAGENTA);
@ -1558,6 +1567,10 @@ void print_message (struct message *M) {
print_end();
}
void play_sound (void) {
printf ("\a");
}
void set_interface_callbacks (void) {
readline_active = 1;
rl_callback_handler_install (get_default_prompt (), interpreter);

View File

@ -57,6 +57,7 @@ void print_end (void);
void print_date_full (long t);
void print_date (long t);
void play_sound (void);
void update_prompt (void);
void set_interface_callbacks (void);
#endif