Merge pull request #124 from vcuculo/sound_notification
Added support to sound notifications
This commit is contained in:
commit
12e14e25e8
15
interface.c
15
interface.c
@ -51,6 +51,7 @@ char *default_prompt = "> ";
|
|||||||
|
|
||||||
int unread_messages;
|
int unread_messages;
|
||||||
int msg_num_mode;
|
int msg_num_mode;
|
||||||
|
int alert_sound;
|
||||||
|
|
||||||
int safe_quit;
|
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 2: prints line, when somebody is typing in chat\n"
|
||||||
"\t\tLevel 3: prints line, when somebody changes online status\n"
|
"\t\tLevel 3: prints line, when somebody changes online status\n"
|
||||||
"\tmsg_num - enables/disables numeration of messages\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"
|
"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 ();
|
pop_color ();
|
||||||
@ -1081,6 +1083,8 @@ void interpreter (char *line UU) {
|
|||||||
log_level = num;
|
log_level = num;
|
||||||
} else if (IS_WORD ("msg_num")) {
|
} else if (IS_WORD ("msg_num")) {
|
||||||
msg_num_mode = num;
|
msg_num_mode = num;
|
||||||
|
} else if (IS_WORD ("alert")) {
|
||||||
|
alert_sound = num;
|
||||||
}
|
}
|
||||||
} else if (IS_WORD ("chat_with_peer")) {
|
} else if (IS_WORD ("chat_with_peer")) {
|
||||||
GET_PEER;
|
GET_PEER;
|
||||||
@ -1483,6 +1487,9 @@ void print_message (struct message *M) {
|
|||||||
} else {
|
} else {
|
||||||
printf (" »»» ");
|
printf (" »»» ");
|
||||||
}
|
}
|
||||||
|
if (alert_sound) {
|
||||||
|
play_sound();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
} else if (get_peer_type (M->to_id) == PEER_ENCR_CHAT) {
|
} else if (get_peer_type (M->to_id) == PEER_ENCR_CHAT) {
|
||||||
peer_t *P = user_chat_get (M->to_id);
|
peer_t *P = user_chat_get (M->to_id);
|
||||||
@ -1516,8 +1523,10 @@ void print_message (struct message *M) {
|
|||||||
} else {
|
} else {
|
||||||
printf (" »»» ");
|
printf (" »»» ");
|
||||||
}
|
}
|
||||||
|
if (alert_sound) {
|
||||||
|
play_sound();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
assert (get_peer_type (M->to_id) == PEER_CHAT);
|
assert (get_peer_type (M->to_id) == PEER_CHAT);
|
||||||
push_color (COLOR_MAGENTA);
|
push_color (COLOR_MAGENTA);
|
||||||
@ -1558,6 +1567,10 @@ void print_message (struct message *M) {
|
|||||||
print_end();
|
print_end();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void play_sound (void) {
|
||||||
|
printf ("\a");
|
||||||
|
}
|
||||||
|
|
||||||
void set_interface_callbacks (void) {
|
void set_interface_callbacks (void) {
|
||||||
readline_active = 1;
|
readline_active = 1;
|
||||||
rl_callback_handler_install (get_default_prompt (), interpreter);
|
rl_callback_handler_install (get_default_prompt (), interpreter);
|
||||||
|
@ -57,6 +57,7 @@ void print_end (void);
|
|||||||
void print_date_full (long t);
|
void print_date_full (long t);
|
||||||
void print_date (long t);
|
void print_date (long t);
|
||||||
|
|
||||||
|
void play_sound (void);
|
||||||
void update_prompt (void);
|
void update_prompt (void);
|
||||||
void set_interface_callbacks (void);
|
void set_interface_callbacks (void);
|
||||||
#endif
|
#endif
|
||||||
|
Loading…
x
Reference in New Issue
Block a user