From: Samuli Suominen Date: Mon, 28 Mar 2011 00:16:33 +0000 (+0200) Subject: notify_desktop plugin: Add compatibility code for libnotify 0.7. X-Git-Tag: collectd-4.10.4~21 X-Git-Url: https://git.tokkee.org/?a=commitdiff_plain;h=e6bfb0e87a4751459ff1920bb57acfcfd5661454;p=collectd.git notify_desktop plugin: Add compatibility code for libnotify 0.7. The current code in src/notify_desktop.c is not compatible with the new libnotify 0.7 API This: notification = notify_notification_new (summary, n->message, NULL, NULL); Should now be: notification = notify_notification_new (summary, n->message, NULL; As in, one argument less for notify_notification_new. But we can't just remove it or it'll break compability with libnotify 0.4.x and 0.5.x. This piece of code sets dummy NOTIFY_CHECK_VERSION for libnotify-0.4.x, because NOTIFY_CHECK_VERSION was added only in 0.5.x: #ifndef NOTIFY_CHECK_VERSION #define NOTIFY_CHECK_VERSION(x,y,z) 0 #endif Then we can freely use NOTIFY_CHECK_VERSION, and it will work with all of 0.4, 0.5 and 0.7 series: #if NOTIFY_CHECK_VERSION (0, 7, 0) do something cool #endif I'm attaching the working patch. It's been tested with all of the mentioned versions, as well as it's in active use at Gentoo Linux. Thanks, Samuli Signed-off-by: Florian Forster --- diff --git a/src/notify_desktop.c b/src/notify_desktop.c index 839bc610..3f3c6dfc 100644 --- a/src/notify_desktop.c +++ b/src/notify_desktop.c @@ -31,6 +31,10 @@ #include #include +#ifndef NOTIFY_CHECK_VERSION +# define NOTIFY_CHECK_VERSION(x,y,z) 0 +#endif + #define log_info(...) INFO ("notify_desktop: " __VA_ARGS__) #define log_warn(...) WARNING ("notify_desktop: " __VA_ARGS__) #define log_err(...) ERROR ("notify_desktop: " __VA_ARGS__) @@ -95,7 +99,12 @@ static int c_notify (const notification_t *n, : (NOTIF_WARNING == n->severity) ? "WARNING" : (NOTIF_OKAY == n->severity) ? "OKAY" : "UNKNOWN"); - notification = notify_notification_new (summary, n->message, NULL, NULL); + notification = notify_notification_new (summary, n->message, NULL +#if NOTIFY_CHECK_VERSION (0, 7, 0) + ); +#else + , NULL); +#endif if (NULL == notification) { log_err ("Failed to create a new notification."); return -1;