mirror of
https://github.com/Tha14/toxic.git
synced 2024-11-23 01:03:02 +01:00
Merge pull request #195 from Ansa89/notify-fix
Add hardcoded path for sound notifications
This commit is contained in:
commit
04fbf5f724
@ -29,6 +29,7 @@
|
|||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
#include <time.h>
|
#include <time.h>
|
||||||
|
#include <sys/stat.h>
|
||||||
|
|
||||||
#ifdef __APPLE__
|
#ifdef __APPLE__
|
||||||
#include <OpenAL/al.h>
|
#include <OpenAL/al.h>
|
||||||
@ -232,13 +233,16 @@ void terminate_notify()
|
|||||||
}
|
}
|
||||||
|
|
||||||
#ifdef _SOUND_NOTIFY
|
#ifdef _SOUND_NOTIFY
|
||||||
void set_sound(Notification sound, const char* value)
|
int set_sound(Notification sound, const char* value)
|
||||||
{
|
{
|
||||||
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(1, len);
|
||||||
memcpy(Control.sounds[sound], value, len);
|
memcpy(Control.sounds[sound], value, len);
|
||||||
|
|
||||||
|
struct stat buf;
|
||||||
|
return stat(value, &buf) == 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
int play_sound_internal(Notification what, _Bool loop)
|
int play_sound_internal(Notification what, _Bool loop)
|
||||||
|
@ -66,8 +66,8 @@ void terminate_notify();
|
|||||||
int notify(ToxWindow* self, Notification notif, uint64_t flags);
|
int notify(ToxWindow* self, Notification notif, uint64_t flags);
|
||||||
|
|
||||||
#ifdef _SOUND_NOTIFY
|
#ifdef _SOUND_NOTIFY
|
||||||
void set_sound(Notification sound, const char* value);
|
int set_sound(Notification sound, const char* value);
|
||||||
void stop_sound(int sound);
|
void stop_sound(int sound);
|
||||||
#endif /* _SOUND_NOTIFY */
|
#endif /* _SOUND_NOTIFY */
|
||||||
|
|
||||||
#endif /* _notify_h */
|
#endif /* _notify_h */
|
||||||
|
@ -36,6 +36,10 @@
|
|||||||
#include "settings.h"
|
#include "settings.h"
|
||||||
#include "line_info.h"
|
#include "line_info.h"
|
||||||
|
|
||||||
|
#ifndef PACKAGE_DATADIR
|
||||||
|
#define PACKAGE_DATADIR "."
|
||||||
|
#endif
|
||||||
|
|
||||||
const struct _ui_strings {
|
const struct _ui_strings {
|
||||||
const char* self;
|
const char* self;
|
||||||
const char* timestamps;
|
const char* timestamps;
|
||||||
@ -197,38 +201,60 @@ int settings_load(struct user_settings *s, const char *patharg)
|
|||||||
|
|
||||||
#ifdef _SOUND_NOTIFY
|
#ifdef _SOUND_NOTIFY
|
||||||
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) )
|
||||||
|
set_sound(error, PACKAGE_DATADIR "/sounds/Error.wav");
|
||||||
if ( config_setting_lookup_string(setting, sound_strings.user_log_in, &str) )
|
|
||||||
set_sound(user_log_in, str);
|
|
||||||
|
|
||||||
if ( config_setting_lookup_string(setting, sound_strings.self_log_in, &str) )
|
if ( !config_setting_lookup_string(setting, sound_strings.user_log_in, &str) ||
|
||||||
set_sound(self_log_in, str);
|
!set_sound(user_log_in, str) )
|
||||||
|
set_sound(user_log_in, PACKAGE_DATADIR "/sounds/ContactLogsIn.wav");
|
||||||
|
|
||||||
if ( config_setting_lookup_string(setting, sound_strings.user_log_out, &str) )
|
if ( !config_setting_lookup_string(setting, sound_strings.self_log_in, &str) ||
|
||||||
set_sound(user_log_out, str);
|
!set_sound(self_log_in, str) )
|
||||||
|
set_sound(self_log_in, PACKAGE_DATADIR "/sounds/LogIn.wav");
|
||||||
|
|
||||||
if ( config_setting_lookup_string(setting, sound_strings.self_log_out, &str) )
|
if ( !config_setting_lookup_string(setting, sound_strings.user_log_out, &str) ||
|
||||||
set_sound(self_log_out, str);
|
!set_sound(user_log_out, str) )
|
||||||
|
set_sound(user_log_out, PACKAGE_DATADIR "/sounds/ContactLogsOut.wav");
|
||||||
|
|
||||||
if ( config_setting_lookup_string(setting, sound_strings.call_incoming, &str) )
|
if ( !config_setting_lookup_string(setting, sound_strings.self_log_out, &str) ||
|
||||||
set_sound(call_incoming, str);
|
!set_sound(self_log_out, str) )
|
||||||
|
set_sound(self_log_out, PACKAGE_DATADIR "/sounds/LogOut.wav");
|
||||||
|
|
||||||
if ( config_setting_lookup_string(setting, sound_strings.call_outgoing, &str) )
|
if ( !config_setting_lookup_string(setting, sound_strings.call_incoming, &str) ||
|
||||||
set_sound(call_outgoing, str);
|
!set_sound(call_incoming, str) )
|
||||||
|
set_sound(call_incoming, PACKAGE_DATADIR "/sounds/IncomingCall.wav");
|
||||||
|
|
||||||
if ( config_setting_lookup_string(setting, sound_strings.generic_message, &str) )
|
if ( !config_setting_lookup_string(setting, sound_strings.call_outgoing, &str) ||
|
||||||
set_sound(generic_message, str);
|
!set_sound(call_outgoing, str) )
|
||||||
|
set_sound(call_outgoing, PACKAGE_DATADIR "/sounds/OutgoingCall.wav");
|
||||||
|
|
||||||
if ( config_setting_lookup_string(setting, sound_strings.transfer_pending, &str) )
|
if ( config_setting_lookup_string(setting, sound_strings.generic_message, &str) ||
|
||||||
set_sound(transfer_pending, str);
|
!set_sound(generic_message, str) )
|
||||||
|
set_sound(generic_message, PACKAGE_DATADIR "/sounds/NewMessage.wav");
|
||||||
|
|
||||||
if ( config_setting_lookup_string(setting, sound_strings.transfer_completed, &str) )
|
if ( !config_setting_lookup_string(setting, sound_strings.transfer_pending, &str) ||
|
||||||
set_sound(transfer_completed, str);
|
!set_sound(transfer_pending, str) )
|
||||||
|
set_sound(transfer_pending, PACKAGE_DATADIR "/sounds/TransferPending.wav");
|
||||||
|
|
||||||
|
if ( !config_setting_lookup_string(setting, sound_strings.transfer_completed, &str) ||
|
||||||
|
!set_sound(transfer_completed, str) )
|
||||||
|
set_sound(transfer_completed, PACKAGE_DATADIR "/sounds/TransferComplete.wav");
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
set_sound(error, PACKAGE_DATADIR "/sounds/Error.wav");
|
||||||
|
set_sound(user_log_in, PACKAGE_DATADIR "/sounds/ContactLogsIn.wav");
|
||||||
|
set_sound(self_log_in, PACKAGE_DATADIR "/sounds/LogIn.wav");
|
||||||
|
set_sound(user_log_out, PACKAGE_DATADIR "/sounds/ContactLogsOut.wav");
|
||||||
|
set_sound(self_log_out, PACKAGE_DATADIR "/sounds/LogOut.wav");
|
||||||
|
set_sound(call_incoming, PACKAGE_DATADIR "/sounds/IncomingCall.wav");
|
||||||
|
set_sound(call_outgoing, PACKAGE_DATADIR "/sounds/OutgoingCall.wav");
|
||||||
|
set_sound(generic_message, PACKAGE_DATADIR "/sounds/NewMessage.wav");
|
||||||
|
set_sound(transfer_pending, PACKAGE_DATADIR "/sounds/TransferPending.wav");
|
||||||
|
set_sound(transfer_completed, PACKAGE_DATADIR "/sounds/TransferComplete.wav");
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
config_destroy(cfg);
|
config_destroy(cfg);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user