mirror of
https://github.com/Tha14/toxic.git
synced 2024-11-23 06:13:03 +01:00
commit
30ec7debba
@ -106,7 +106,7 @@ static void friendlist_onMessage(ToxWindow *self, Tox *m, int32_t num, const cha
|
|||||||
if (friends[num].chatwin == -1) {
|
if (friends[num].chatwin == -1) {
|
||||||
if (get_num_active_windows() < MAX_WINDOWS_NUM) {
|
if (get_num_active_windows() < MAX_WINDOWS_NUM) {
|
||||||
friends[num].chatwin = add_window(m, new_chat(m, friends[num].num));
|
friends[num].chatwin = add_window(m, new_chat(m, friends[num].num));
|
||||||
notify(self, generic_message, NT_NOFOCUS);
|
notify(self, generic_message, NT_WNDALERT_0 | NT_NOFOCUS);
|
||||||
} else {
|
} else {
|
||||||
char nick[TOX_MAX_NAME_LENGTH];
|
char nick[TOX_MAX_NAME_LENGTH];
|
||||||
get_nick_truncate(m, nick, num);
|
get_nick_truncate(m, nick, num);
|
||||||
@ -240,7 +240,7 @@ static void friendlist_onGroupInvite(ToxWindow *self, Tox *m, int32_t num, const
|
|||||||
if (friends[num].chatwin == -1) {
|
if (friends[num].chatwin == -1) {
|
||||||
if (get_num_active_windows() < MAX_WINDOWS_NUM) {
|
if (get_num_active_windows() < MAX_WINDOWS_NUM) {
|
||||||
friends[num].chatwin = add_window(m, new_chat(m, friends[num].num));
|
friends[num].chatwin = add_window(m, new_chat(m, friends[num].num));
|
||||||
notify(self, generic_message, NT_NOFOCUS);
|
notify(self, generic_message, NT_WNDALERT_0 | NT_NOFOCUS);
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
char nick[TOX_MAX_NAME_LENGTH];
|
char nick[TOX_MAX_NAME_LENGTH];
|
||||||
|
19
src/notify.c
19
src/notify.c
@ -235,10 +235,12 @@ void terminate_notify()
|
|||||||
#ifdef _SOUND_NOTIFY
|
#ifdef _SOUND_NOTIFY
|
||||||
int set_sound(Notification sound, const char* value)
|
int set_sound(Notification sound, const char* value)
|
||||||
{
|
{
|
||||||
|
if (sound == silent) return 0;
|
||||||
|
|
||||||
free(Control.sounds[sound]);
|
free(Control.sounds[sound]);
|
||||||
|
|
||||||
size_t len = strlen(value) + 1;
|
size_t len = strlen(value) + 1;
|
||||||
Control.sounds[sound] = calloc(1, len);
|
Control.sounds[sound] = calloc(len, 1);
|
||||||
memcpy(Control.sounds[sound], value, len);
|
memcpy(Control.sounds[sound], value, len);
|
||||||
|
|
||||||
struct stat buf;
|
struct stat buf;
|
||||||
@ -252,7 +254,7 @@ int play_sound_internal(Notification what, _Bool loop)
|
|||||||
|
|
||||||
alGenSources(1, &source);
|
alGenSources(1, &source);
|
||||||
alGenBuffers(1, &buffer);
|
alGenBuffers(1, &buffer);
|
||||||
buffer = alutCreateBufferFromFile((const char*)Control.sounds[what]);
|
buffer = alutCreateBufferFromFile(Control.sounds[what]);
|
||||||
alSourcei(source, AL_BUFFER, buffer);
|
alSourcei(source, AL_BUFFER, buffer);
|
||||||
alSourcei(source, AL_LOOPING, loop);
|
alSourcei(source, AL_LOOPING, loop);
|
||||||
|
|
||||||
@ -310,6 +312,13 @@ static int m_play_sound(Notification notif, uint64_t flags)
|
|||||||
|
|
||||||
int notify(ToxWindow* self, Notification notif, uint64_t flags)
|
int notify(ToxWindow* self, Notification notif, uint64_t flags)
|
||||||
{
|
{
|
||||||
|
/* Consider colored notify as primary */
|
||||||
|
if (self && self->alert == WINDOW_ALERT_NONE) {
|
||||||
|
if (flags & NT_WNDALERT_0) self->alert = WINDOW_ALERT_0;
|
||||||
|
else if (flags & NT_WNDALERT_1) self->alert = WINDOW_ALERT_1;
|
||||||
|
else if (flags & NT_WNDALERT_2) self->alert = WINDOW_ALERT_2;
|
||||||
|
}
|
||||||
|
|
||||||
if (flags & NT_NOFOCUS && Control.this_window == get_focused_window_id())
|
if (flags & NT_NOFOCUS && Control.this_window == get_focused_window_id())
|
||||||
return -1;
|
return -1;
|
||||||
|
|
||||||
@ -325,11 +334,5 @@ int notify(ToxWindow* self, Notification notif, uint64_t flags)
|
|||||||
/* TODO: pop notify window */
|
/* TODO: pop notify window */
|
||||||
}
|
}
|
||||||
|
|
||||||
if (self && self->alert == WINDOW_ALERT_NONE) {
|
|
||||||
if (flags & NT_WNDALERT_0) self->alert = WINDOW_ALERT_0;
|
|
||||||
else if (flags & NT_WNDALERT_1) self->alert = WINDOW_ALERT_1;
|
|
||||||
else if (flags & NT_WNDALERT_2) self->alert = WINDOW_ALERT_2;
|
|
||||||
}
|
|
||||||
|
|
||||||
return rc;
|
return rc;
|
||||||
}
|
}
|
||||||
|
@ -205,61 +205,61 @@ int settings_load(struct user_settings *s, const char *patharg)
|
|||||||
if ((setting = config_lookup(cfg, sound_strings.self)) != NULL) {
|
if ((setting = config_lookup(cfg, sound_strings.self)) != NULL) {
|
||||||
if ( (config_setting_lookup_string(setting, sound_strings.error, &str) != CONFIG_TRUE) ||
|
if ( (config_setting_lookup_string(setting, sound_strings.error, &str) != CONFIG_TRUE) ||
|
||||||
!set_sound(error, str) ) {
|
!set_sound(error, str) ) {
|
||||||
if (strcasecmp(str, NO_SOUND))
|
if (strcasecmp(str, NO_SOUND) != 0)
|
||||||
set_sound(error, PACKAGE_DATADIR "/sounds/Error.wav");
|
set_sound(error, PACKAGE_DATADIR "/sounds/Error.wav");
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( !config_setting_lookup_string(setting, sound_strings.user_log_in, &str) ||
|
if ( !config_setting_lookup_string(setting, sound_strings.user_log_in, &str) ||
|
||||||
!set_sound(user_log_in, str) ) {
|
!set_sound(user_log_in, str) ) {
|
||||||
if (strcasecmp(str, NO_SOUND))
|
if (strcasecmp(str, NO_SOUND) != 0)
|
||||||
set_sound(user_log_in, PACKAGE_DATADIR "/sounds/ContactLogsIn.wav");
|
set_sound(user_log_in, PACKAGE_DATADIR "/sounds/ContactLogsIn.wav");
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( !config_setting_lookup_string(setting, sound_strings.self_log_in, &str) ||
|
if ( !config_setting_lookup_string(setting, sound_strings.self_log_in, &str) ||
|
||||||
!set_sound(self_log_in, str) ) {
|
!set_sound(self_log_in, str) ) {
|
||||||
if (strcasecmp(str, NO_SOUND))
|
if (strcasecmp(str, NO_SOUND) != 0)
|
||||||
set_sound(self_log_in, PACKAGE_DATADIR "/sounds/LogIn.wav");
|
set_sound(self_log_in, PACKAGE_DATADIR "/sounds/LogIn.wav");
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( !config_setting_lookup_string(setting, sound_strings.user_log_out, &str) ||
|
if ( !config_setting_lookup_string(setting, sound_strings.user_log_out, &str) ||
|
||||||
!set_sound(user_log_out, str) ) {
|
!set_sound(user_log_out, str) ) {
|
||||||
if (strcasecmp(str, NO_SOUND))
|
if (strcasecmp(str, NO_SOUND) != 0)
|
||||||
set_sound(user_log_out, PACKAGE_DATADIR "/sounds/ContactLogsOut.wav");
|
set_sound(user_log_out, PACKAGE_DATADIR "/sounds/ContactLogsOut.wav");
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( !config_setting_lookup_string(setting, sound_strings.self_log_out, &str) ||
|
if ( !config_setting_lookup_string(setting, sound_strings.self_log_out, &str) ||
|
||||||
!set_sound(self_log_out, str) ) {
|
!set_sound(self_log_out, str) ) {
|
||||||
if (strcasecmp(str, NO_SOUND))
|
if (strcasecmp(str, NO_SOUND) != 0)
|
||||||
set_sound(self_log_out, PACKAGE_DATADIR "/sounds/LogOut.wav");
|
set_sound(self_log_out, PACKAGE_DATADIR "/sounds/LogOut.wav");
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( !config_setting_lookup_string(setting, sound_strings.call_incoming, &str) ||
|
if ( !config_setting_lookup_string(setting, sound_strings.call_incoming, &str) ||
|
||||||
!set_sound(call_incoming, str) ) {
|
!set_sound(call_incoming, str) ) {
|
||||||
if (strcasecmp(str, NO_SOUND))
|
if (strcasecmp(str, NO_SOUND) != 0)
|
||||||
set_sound(call_incoming, PACKAGE_DATADIR "/sounds/IncomingCall.wav");
|
set_sound(call_incoming, PACKAGE_DATADIR "/sounds/IncomingCall.wav");
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( !config_setting_lookup_string(setting, sound_strings.call_outgoing, &str) ||
|
if ( !config_setting_lookup_string(setting, sound_strings.call_outgoing, &str) ||
|
||||||
!set_sound(call_outgoing, str) ) {
|
!set_sound(call_outgoing, str) ) {
|
||||||
if (strcasecmp(str, NO_SOUND))
|
if (strcasecmp(str, NO_SOUND) != 0)
|
||||||
set_sound(call_outgoing, PACKAGE_DATADIR "/sounds/OutgoingCall.wav");
|
set_sound(call_outgoing, PACKAGE_DATADIR "/sounds/OutgoingCall.wav");
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( config_setting_lookup_string(setting, sound_strings.generic_message, &str) ||
|
if ( !config_setting_lookup_string(setting, sound_strings.generic_message, &str) ||
|
||||||
!set_sound(generic_message, str) ) {
|
!set_sound(generic_message, str) ) {
|
||||||
if (strcasecmp(str, NO_SOUND))
|
if (strcasecmp(str, NO_SOUND) != 0)
|
||||||
set_sound(generic_message, PACKAGE_DATADIR "/sounds/NewMessage.wav");
|
set_sound(generic_message, PACKAGE_DATADIR "/sounds/NewMessage.wav");
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( !config_setting_lookup_string(setting, sound_strings.transfer_pending, &str) ||
|
if ( !config_setting_lookup_string(setting, sound_strings.transfer_pending, &str) ||
|
||||||
!set_sound(transfer_pending, str) ) {
|
!set_sound(transfer_pending, str) ) {
|
||||||
if (strcasecmp(str, NO_SOUND))
|
if (strcasecmp(str, NO_SOUND) != 0)
|
||||||
set_sound(transfer_pending, PACKAGE_DATADIR "/sounds/TransferPending.wav");
|
set_sound(transfer_pending, PACKAGE_DATADIR "/sounds/TransferPending.wav");
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( !config_setting_lookup_string(setting, sound_strings.transfer_completed, &str) ||
|
if ( !config_setting_lookup_string(setting, sound_strings.transfer_completed, &str) ||
|
||||||
!set_sound(transfer_completed, str) ) {
|
!set_sound(transfer_completed, str) ) {
|
||||||
if (strcasecmp(str, NO_SOUND))
|
if (strcasecmp(str, NO_SOUND) != 0)
|
||||||
set_sound(transfer_completed, PACKAGE_DATADIR "/sounds/TransferComplete.wav");
|
set_sound(transfer_completed, PACKAGE_DATADIR "/sounds/TransferComplete.wav");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user