ddnet/src/engine/client/notifications.cpp

45 lines
1.1 KiB
C++
Raw Normal View History

#include "notifications.h"
#include <base/detect.h>
#if defined(CONF_PLATFORM_MACOS)
// Code is in src/macos/notification.mm.
void NotificationsNotifyMacOsInternal(const char *pTitle, const char *pMessage);
2022-03-25 08:26:37 +00:00
#elif defined(CONF_FAMILY_UNIX) && !defined(CONF_PLATFORM_ANDROID) && !defined(CONF_PLATFORM_HAIKU) && !defined(CONF_WEBASM)
#include <libnotify/notify.h>
#define NOTIFICATIONS_USE_LIBNOTIFY
#endif
void CNotifications::Init(const char *pAppname)
{
#if defined(NOTIFICATIONS_USE_LIBNOTIFY)
notify_init(pAppname);
#endif
}
void CNotifications::Shutdown()
{
#if defined(NOTIFICATIONS_USE_LIBNOTIFY)
notify_uninit();
#endif
}
void CNotifications::Notify(const char *pTitle, const char *pMessage)
{
#if defined(CONF_PLATFORM_MACOS)
NotificationsNotifyMacOsInternal(pTitle, pMessage);
#elif defined(NOTIFICATIONS_USE_LIBNOTIFY)
2020-09-30 20:40:19 +00:00
NotifyNotification *pNotif = notify_notification_new(pTitle, pMessage, "ddnet");
2023-10-08 12:01:02 +00:00
if(pNotif)
{
notify_notification_show(pNotif, NULL);
g_object_unref(G_OBJECT(pNotif));
}
#endif
}
INotifications *CreateNotifications()
{
return new CNotifications();
}