Reinitialise libnotify per notification
Fixes issue on Xfce4 where notification are not being sent after a period of time. Issue #370
This commit is contained in:
@@ -94,7 +94,6 @@ _ui_init(void)
|
|||||||
create_input_window();
|
create_input_window();
|
||||||
wins_init();
|
wins_init();
|
||||||
cons_about();
|
cons_about();
|
||||||
notifier_init();
|
|
||||||
#ifdef HAVE_LIBXSS
|
#ifdef HAVE_LIBXSS
|
||||||
display = XOpenDisplay(0);
|
display = XOpenDisplay(0);
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
@@ -40,14 +40,6 @@
|
|||||||
static void _notify(const char * const message, int timeout,
|
static void _notify(const char * const message, int timeout,
|
||||||
const char * const category);
|
const char * const category);
|
||||||
|
|
||||||
static void
|
|
||||||
_notifier_init(void)
|
|
||||||
{
|
|
||||||
#ifdef HAVE_LIBNOTIFY
|
|
||||||
notify_init("Profanity");
|
|
||||||
#endif
|
|
||||||
}
|
|
||||||
|
|
||||||
static void
|
static void
|
||||||
_notifier_uninit(void)
|
_notifier_uninit(void)
|
||||||
{
|
{
|
||||||
@@ -171,6 +163,15 @@ _notify(const char * const message, int timeout,
|
|||||||
const char * const category)
|
const char * const category)
|
||||||
{
|
{
|
||||||
#ifdef HAVE_LIBNOTIFY
|
#ifdef HAVE_LIBNOTIFY
|
||||||
|
log_debug("Attempting notification: %s", message);
|
||||||
|
if (notify_is_initted()) {
|
||||||
|
log_debug("Reinitialising libnotify");
|
||||||
|
notify_uninit();
|
||||||
|
notify_init("Profanity");
|
||||||
|
} else {
|
||||||
|
log_debug("Initialising libnotify");
|
||||||
|
notify_init("Profanity");
|
||||||
|
}
|
||||||
if (notify_is_initted()) {
|
if (notify_is_initted()) {
|
||||||
NotifyNotification *notification;
|
NotifyNotification *notification;
|
||||||
notification = notify_notification_new("Profanity", message, NULL);
|
notification = notify_notification_new("Profanity", message, NULL);
|
||||||
@@ -185,9 +186,11 @@ _notify(const char * const message, int timeout,
|
|||||||
log_error("Error sending desktop notification:");
|
log_error("Error sending desktop notification:");
|
||||||
log_error(" -> Message : %s", message);
|
log_error(" -> Message : %s", message);
|
||||||
log_error(" -> Error : %s", error->message);
|
log_error(" -> Error : %s", error->message);
|
||||||
}
|
} else {
|
||||||
|
log_debug("Notification sent.");
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
log_error("Libnotify initialisation error.");
|
log_error("Libnotify not initialised.");
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
#ifdef PLATFORM_CYGWIN
|
#ifdef PLATFORM_CYGWIN
|
||||||
@@ -244,7 +247,6 @@ _notify(const char * const message, int timeout,
|
|||||||
void
|
void
|
||||||
notifier_init_module(void)
|
notifier_init_module(void)
|
||||||
{
|
{
|
||||||
notifier_init = _notifier_init;
|
|
||||||
notifier_uninit = _notifier_uninit;
|
notifier_uninit = _notifier_uninit;
|
||||||
notify_typing = _notify_typing;
|
notify_typing = _notify_typing;
|
||||||
notify_invite = _notify_invite;
|
notify_invite = _notify_invite;
|
||||||
|
|||||||
@@ -259,7 +259,6 @@ void (*cons_show_contact_online)(PContact contact, Resource *resource, GDateTime
|
|||||||
void (*cons_show_contact_offline)(PContact contact, char *resource, char *status);
|
void (*cons_show_contact_offline)(PContact contact, char *resource, char *status);
|
||||||
|
|
||||||
// desktop notifier actions
|
// desktop notifier actions
|
||||||
void (*notifier_init)(void);
|
|
||||||
void (*notifier_uninit)(void);
|
void (*notifier_uninit)(void);
|
||||||
|
|
||||||
void (*notify_typing)(const char * const handle);
|
void (*notify_typing)(const char * const handle);
|
||||||
|
|||||||
Reference in New Issue
Block a user