void ring_notify_init() { #if USE_LIBNOTIFY notify_init("Ring"); /* get notify server info */ if (notify_get_server_info(&server_info.name, &server_info.vendor, &server_info.version, &server_info.spec)) { g_debug("notify server name: %s, vendor: %s, version: %s, spec: %s", server_info.name, server_info.vendor, server_info.version, server_info.spec); } /* check notify server capabilities */ auto list = notify_get_server_caps(); while (list) { if (g_strcmp0((const char *)list->data, "append") == 0 || g_strcmp0((const char *)list->data, "x-canonical-append") == 0) { server_info.append = TRUE; } if (g_strcmp0((const char *)list->data, "actions") == 0) { server_info.actions = TRUE; } list = g_list_next(list); } g_list_free_full(list, g_free); #endif }
DesktopNotifierLinux::DesktopNotifierLinux() { if (notify_init("Emerald Viewer")) { LL_INFOS("DesktopNotifierLinux") << "Linux desktop notifications initialized." << LL_ENDL; // Find the name of our notification server. I kinda don't expect it to change after the start of the program. gchar* name = NULL; gchar* vendor = NULL; gchar* version = NULL; gchar* spec = NULL; bool info_success = notify_get_server_info(&name, &vendor, &version, &spec); if (info_success) { LL_INFOS("DesktopNotifierLinux") << "Server name: " << name << LL_ENDL; LL_INFOS("DesktopNotifierLinux") << "Server vendor: " << vendor << LL_ENDL; LL_INFOS("DesktopNotifierLinux") << "Server version: " << version << LL_ENDL; LL_INFOS("DesktopNotifierLinux") << "Server spec: " << spec << LL_ENDL; } if (!info_success || strncmp("notification-daemon", name, 19)) { // We're likely talking to notification-daemon, and I don't feel like scaling. Use a premade 128x128 icon. icon_wholename = Find_BMP_Resource(ICON_128); } else { // Talking to NotifyOSD or something else. Try the 512x512 icon and let it scale on its own. icon_wholename = Find_BMP_Resource(ICON_512); } LL_INFOS("DesktopNotifierLinux") << "Linux desktop notification icon: " << icon_wholename << LL_ENDL; } else { LL_WARNS("DesktopNotifierLinux") << "Linux desktop notifications FAILED to initialize." << LL_ENDL; } }
int main (int argc, char **argv) { GList *l, *caps; char *name, *vendor, *version, *spec_version; notify_init ("TestCaps"); if (!notify_get_server_info (&name, &vendor, &version, &spec_version)) { fprintf (stderr, "Failed to receive server info.\n"); exit (1); } printf ("Name: %s\n", name); printf ("Vendor: %s\n", vendor); printf ("Version: %s\n", version); printf ("Spec Version: %s\n", spec_version); printf ("Capabilities:\n"); caps = notify_get_server_caps (); if (caps == NULL) { fprintf (stderr, "Failed to receive server caps.\n"); exit (1); } for (l = caps; l != NULL; l = l->next) printf ("\t%s\n", (char *) l->data); g_list_foreach (caps, (GFunc) g_free, NULL); g_list_free (caps); return 0; }
static gboolean _notify_update_spec_version (void) { char *spec_version; if (!notify_get_server_info (NULL, NULL, NULL, &spec_version)) { return FALSE; } sscanf (spec_version, "%d.%d", &_spec_version_major, &_spec_version_minor); g_free (spec_version); return TRUE; }
static gboolean thunar_notify_init (void) { gchar *spec_version = NULL; if (!thunar_notify_initted && notify_init (PACKAGE_NAME)) { /* we do this to work around bugs in libnotify < 0.6.0. Older * versions crash in notify_uninit() when no notifications are * displayed before. These versions also segfault when the * ret_spec_version parameter of notify_get_server_info is * NULL... */ notify_get_server_info (NULL, NULL, NULL, &spec_version); g_free (spec_version); thunar_notify_initted = TRUE; } return thunar_notify_initted; }