From f4bce0d0624ad539f03794d2d7760bfdf216ed6e Mon Sep 17 00:00:00 2001 From: Christian Hammond Date: Thu, 30 Sep 2004 04:53:30 +0000 Subject: [PATCH] Updated to match the spec. --- ChangeLog | 15 +++++ libnotify/notify.c | 75 ++++++++---------------- libnotify/notify.h | 17 +++--- tests/test-animation.c | 63 ++++++++++---------- tests/test-basic.c | 29 ++++----- tests/test-default-action.c | 47 ++++++++------- tests/test-error.c | 37 ++++++------ tests/test-image.c | 114 ++++++++++++++++++------------------ tests/test-markup.c | 33 ++++++----- tests/test-multi-actions.c | 73 ++++++++++++----------- tests/test-replace.c | 38 ++++++------ tools/notify-send.c | 32 +++++----- 12 files changed, 290 insertions(+), 283 deletions(-) diff --git a/ChangeLog b/ChangeLog index 4db8ce3..f08f4b3 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,18 @@ +Wed Sep 29 21:53:15 PDT 2004 Christian Hammond + + * libnotify/notify.c: + * libnotify/notify.h: + * tests/test-animation.c: + * tests/test-basic.c: + * tests/test-default-action.c: + * tests/test-error.c: + * tests/test-image.c: + * tests/test-markup.c: + * tests/test-multi-actions.c: + * tests/test-replace.c: + * tools/notify-send.c: + - Updated to match the spec. + Sat Sep 25 12:59:26 PDT 2004 Christian Hammond * libnotify/notify.c: diff --git a/libnotify/notify.c b/libnotify/notify.c index 08ef086..fc7a38c 100644 --- a/libnotify/notify.c +++ b/libnotify/notify.c @@ -21,8 +21,6 @@ * Boston, MA 02111-1307, USA. */ -/* FIXME: do we want so many arguments in the API? */ - #ifdef HAVE_CONFIG_H # include "config.h" #endif @@ -169,34 +167,6 @@ _notify_dbus_message_iter_append_string_or_nil(DBusMessageIter *iter, dbus_message_iter_append_string(iter, str); } -#if 0 -static char * -_notify_dbus_message_iter_get_string_or_nil(DBusMessageIter *iter) -{ - int arg_type; - - g_return_val_if_fail(iter != NULL, NULL); - - arg_type = dbus_message_iter_get_arg_type(iter); - - if (arg_type == DBUS_TYPE_STRING) - return dbus_message_iter_get_string(iter); - - g_return_val_if_fail(arg_type == DBUS_TYPE_NIL, NULL); - - return NULL; -} - -static void -_notify_dbus_message_iter_append_app_info(DBusMessageIter *iter) -{ - g_return_if_fail(iter != NULL); - - dbus_message_iter_append_string(iter, _app_name); - dbus_message_iter_append_nil(iter); /* App Icon */ -} -#endif - static DBusHandlerResult _filter_func(DBusConnection *dbus_conn, DBusMessage *message, void *user_data) { @@ -584,9 +554,10 @@ notify_icon_destroy(NotifyIcon *icon) * Notifications API **************************************************************************/ NotifyHandle * -notify_send_notification(NotifyHandle *replaces, NotifyUrgency urgency, const char *summary, - const char *detailed, const NotifyIcon *icon, - gboolean expires, time_t expire_time, +notify_send_notification(NotifyHandle *replaces, const char *type, + NotifyUrgency urgency, const char *summary, + const char *body, const NotifyIcon *icon, + gboolean expires, time_t timeout, gpointer user_data, size_t action_count, ...) { va_list actions; @@ -595,8 +566,9 @@ notify_send_notification(NotifyHandle *replaces, NotifyUrgency urgency, const ch g_return_val_if_fail(summary != NULL, 0); va_start(actions, action_count); - handle = notify_send_notification_varg(replaces, urgency, summary, detailed, icon, - expires, expire_time, user_data, + handle = notify_send_notification_varg(replaces, type, urgency, summary, + body, icon, expires, + timeout, user_data, action_count, actions); va_end(actions); @@ -604,9 +576,10 @@ notify_send_notification(NotifyHandle *replaces, NotifyUrgency urgency, const ch } NotifyHandle * -notify_send_notification_varg(NotifyHandle *replaces, NotifyUrgency urgency, const char *summary, - const char *detailed, const NotifyIcon *icon, - gboolean expires, time_t expire_time, +notify_send_notification_varg(NotifyHandle *replaces, const char *type, + NotifyUrgency urgency, const char *summary, + const char *body, const NotifyIcon *icon, + gboolean expires, time_t timeout, gpointer user_data, size_t action_count, va_list actions) { @@ -622,14 +595,14 @@ notify_send_notification_varg(NotifyHandle *replaces, NotifyUrgency urgency, con g_return_val_if_fail(message != NULL, 0); -#if 0 - _notify_dbus_message_iter_append_app_info(&iter); -#endif - - dbus_message_iter_append_uint32(&iter, replaces ? replaces->id : 0); + _notify_dbus_message_iter_append_string_or_nil(&iter, _app_name); + dbus_message_iter_append_nil(&iter); + dbus_message_iter_append_uint32(&iter, + (replaces != NULL ? replaces->id : 0)); + _notify_dbus_message_iter_append_string_or_nil(&iter, type); dbus_message_iter_append_byte(&iter, urgency); dbus_message_iter_append_string(&iter, summary); - _notify_dbus_message_iter_append_string_or_nil(&iter, detailed); + _notify_dbus_message_iter_append_string_or_nil(&iter, body); /* * NOTE: D-BUS 0.22cvs is the first to allow empty arrays, *I think*. @@ -671,10 +644,14 @@ notify_send_notification_varg(NotifyHandle *replaces, NotifyUrgency urgency, con g_hash_table_insert(table, &action->id, action); } - if (expires) - dbus_message_iter_append_uint32(&iter, expire_time); - else - dbus_message_iter_append_nil(&iter); + /* Hints */ + dbus_message_iter_append_nil(&iter); + + /* Expires */ + dbus_message_iter_append_boolean(&iter, expires); + + /* Expire Timeout */ + dbus_message_iter_append_uint32(&iter, (expires ? timeout : 0)); dbus_error_init(&error); @@ -693,7 +670,7 @@ notify_send_notification_varg(NotifyHandle *replaces, NotifyUrgency urgency, con return 0; } - + dbus_message_iter_init(reply, &iter); id = dbus_message_iter_get_uint32(&iter); diff --git a/libnotify/notify.h b/libnotify/notify.h index db53201..69bf640 100644 --- a/libnotify/notify.h +++ b/libnotify/notify.h @@ -31,7 +31,6 @@ typedef enum { NOTIFY_URGENCY_LOW, /**< Low urgency. */ NOTIFY_URGENCY_NORMAL, /**< Normal urgency. */ - NOTIFY_URGENCY_HIGH, /**< High urgency. */ NOTIFY_URGENCY_CRITICAL, /**< Critical urgency. */ } NotifyUrgency; @@ -152,13 +151,14 @@ void notify_icon_destroy(NotifyIcon *icon); * @endcode * * @param replaces The ID of the notification to atomically replace + * @param type The optional notification type. * @param urgency The urgency level. * @param summary The summary of the notification. - * @param detailed The optional detailed information. + * @param body The optional body. * @param icon The optional icon. * @param expires TRUE if the notification should automatically expire,, * or FALSE to keep it open until manually closed. - * @param expire_time The optional time to automatically close the + * @param timeout The optional timeout to automatically close the * notification, or 0 for the daemon's default. * @param user_data User-specified data to send to a callback. * @param action_count The number of actions. @@ -167,11 +167,12 @@ void notify_icon_destroy(NotifyIcon *icon); * @return A unique ID for the notification. */ NotifyHandle *notify_send_notification(NotifyHandle *replaces, + const char *type, NotifyUrgency urgency, const char *summary, const char *detailed, const NotifyIcon *icon, - gboolean expires, time_t expire_time, + gboolean expires, time_t timeout, gpointer user_data, size_t action_count, ...); @@ -185,13 +186,14 @@ NotifyHandle *notify_send_notification(NotifyHandle *replaces, * @endcode * * @param replaces The handle of the notification to atomically replace + * @param type The optional notification type. * @param urgency The urgency level. * @param summary The summary of the notification. - * @param detailed The optional detailed information. + * @param detailed The optional body. * @param icon The optional icon. * @param expires TRUE if the notification should automatically expire, * or FALSE to keep it open until manually closed. - * @param expire_time The optional time to automatically close the + * @param timeout The optional timeout to automatically close the * notification, or 0 for the daemon's default. * @param user_data User-specified data to send to a callback. * @param action_count The number of actions. @@ -200,12 +202,13 @@ NotifyHandle *notify_send_notification(NotifyHandle *replaces, * @return A unique ID for the notification. */ NotifyHandle *notify_send_notification_varg(NotifyHandle *replaces, + const char *type, NotifyUrgency urgency, const char *summary, const char *detailed, const NotifyIcon *icon, gboolean expires, - time_t expire_time, + time_t timeout, gpointer user_data, size_t action_count, va_list actions); diff --git a/tests/test-animation.c b/tests/test-animation.c index f42e709..66c8dd9 100644 --- a/tests/test-animation.c +++ b/tests/test-animation.c @@ -34,26 +34,26 @@ int frames = 10; // returns array of pixbufs for a pulsing animation GdkPixbuf **generate_animation() { - int i; - GdkPixbuf *file = gdk_pixbuf_new_from_file("applet-critical.png", NULL); - double alpha = 1.0; + int i; + GdkPixbuf *file = gdk_pixbuf_new_from_file("applet-critical.png", NULL); + double alpha = 1.0; - GdkPixbuf **array = g_malloc(sizeof(GdkPixbuf *) * frames); + GdkPixbuf **array = g_malloc(sizeof(GdkPixbuf *) * frames); - for (i = 0; i < frames; i++) - { - GdkPixbuf *buf = gdk_pixbuf_copy(file); + for (i = 0; i < frames; i++) + { + GdkPixbuf *buf = gdk_pixbuf_copy(file); - alpha = sin(M_PI + ((M_PI / frames) * i)) + 1.0; + alpha = sin(M_PI + ((M_PI / frames) * i)) + 1.0; - gdk_pixbuf_composite(file, buf, 0, 0, - gdk_pixbuf_get_width(buf), - gdk_pixbuf_get_height(buf), - 0, 0, 1.0, 1.0, GDK_INTERP_NEAREST, - alpha); + gdk_pixbuf_composite(file, buf, 0, 0, + gdk_pixbuf_get_width(buf), + gdk_pixbuf_get_height(buf), + 0, 0, 1.0, 1.0, GDK_INTERP_NEAREST, + alpha); - array[i] = buf; - } + array[i] = buf; + } return array; } @@ -62,25 +62,26 @@ GdkPixbuf **generate_animation() int main() { int i; - notify_init("Animations"); + notify_init("Animations"); - for (i = 0; i < frames; i++) - { + for (i = 0; i < frames; i++) + { - } + } - NotifyHandle *n = notify_send_notification(NULL, // replaces nothing - NOTIFY_URGENCY_NORMAL, - "Summary", "Content", - NULL, // no icon - TRUE, time(NULL) + 5, - NULL, // no user data - 0); // no actions + NotifyHandle *n = notify_send_notification(NULL, // replaces nothing + NULL, + NOTIFY_URGENCY_NORMAL, + "Summary", "Content", + NULL, // no icon + TRUE, time(NULL) + 5, + NULL, // no user data + 0); // no actions - if (!n) { - fprintf(stderr, "failed to send notification\n"); - return 1; - } + if (!n) { + fprintf(stderr, "failed to send notification\n"); + return 1; + } - return 0; + return 0; } diff --git a/tests/test-basic.c b/tests/test-basic.c index 9db1ecf..aca0871 100644 --- a/tests/test-basic.c +++ b/tests/test-basic.c @@ -24,20 +24,21 @@ #include int main() { - notify_init("Basics"); - - NotifyHandle *n = notify_send_notification(NULL, // replaces nothing - NOTIFY_URGENCY_NORMAL, - "Summary", "Content", - NULL, // no icon - TRUE, time(NULL) + 5, - NULL, // no user data - 0); // no actions + notify_init("Basics"); - if (!n) { - fprintf(stderr, "failed to send notification\n"); - return 1; - } + NotifyHandle *n = notify_send_notification(NULL, // replaces nothing + NULL, + NOTIFY_URGENCY_NORMAL, + "Summary", "Content", + NULL, // no icon + TRUE, time(NULL) + 5, + NULL, // no user data + 0); // no actions - return 0; + if (!n) { + fprintf(stderr, "failed to send notification\n"); + return 1; + } + + return 0; } diff --git a/tests/test-default-action.c b/tests/test-default-action.c index b7e0030..0b763ef 100644 --- a/tests/test-default-action.c +++ b/tests/test-default-action.c @@ -37,36 +37,39 @@ static NotifyHandle *n; static void callback(NotifyHandle *handle, guint32 uid, void *user_data) { - assert( uid == 0 ); + assert( uid == 0 ); - notify_close(n); + notify_close(n); - g_main_loop_quit(loop); + g_main_loop_quit(loop); } -int main() { - if (!notify_init("Default Action Test")) exit(1); +int +main() +{ + if (!notify_init("Default Action Test")) exit(1); - DBusConnection *conn = dbus_bus_get(DBUS_BUS_SESSION, NULL); - loop = g_main_loop_new(NULL, FALSE); + DBusConnection *conn = dbus_bus_get(DBUS_BUS_SESSION, NULL); + loop = g_main_loop_new(NULL, FALSE); - dbus_connection_setup_with_g_main(conn, NULL); + dbus_connection_setup_with_g_main(conn, NULL); - n = notify_send_notification(NULL, // replaces nothing - NOTIFY_URGENCY_NORMAL, - "Matt is online", NULL, - NULL, // no icon - FALSE, 0, // does not expire - NULL, // no user data - 1, - 0, "default", callback); // 1 action + n = notify_send_notification(NULL, // replaces nothing + "presence.online", + NOTIFY_URGENCY_NORMAL, + "Matt is online", NULL, + NULL, // no icon + FALSE, 0, // does not expire + NULL, // no user data + 1, + 0, "default", callback); // 1 action - if (!n) { - fprintf(stderr, "failed to send notification\n"); - return 1; - } + if (!n) { + fprintf(stderr, "failed to send notification\n"); + return 1; + } - g_main_loop_run(loop); + g_main_loop_run(loop); - return 0; + return 0; } diff --git a/tests/test-error.c b/tests/test-error.c index b81e210..094ffbc 100644 --- a/tests/test-error.c +++ b/tests/test-error.c @@ -24,24 +24,25 @@ #include int main() { - notify_init("Error Handling"); - - NotifyIcon *icon = notify_icon_new("/no-such"); - - NotifyHandle *n = notify_send_notification(NULL, // replaces nothing - NOTIFY_URGENCY_NORMAL, - "Summary", "Content", - icon, // no icon - TRUE, time(NULL) + 5, - NULL, // no user data - 0); + notify_init("Error Handling"); - notify_icon_destroy(icon); - - if (n) { - fprintf(stderr, "failed to get an error ??\n"); - return 1; - } + NotifyIcon *icon = notify_icon_new("/no-such"); - return 0; + NotifyHandle *n = notify_send_notification(NULL, // replaces nothing + NULL, + NOTIFY_URGENCY_NORMAL, + "Summary", "Content", + icon, // no icon + TRUE, time(NULL) + 5, + NULL, // no user data + 0); + + notify_icon_destroy(icon); + + if (n) { + fprintf(stderr, "failed to get an error ??\n"); + return 1; + } + + return 0; } diff --git a/tests/test-image.c b/tests/test-image.c index be0b242..10735ef 100644 --- a/tests/test-image.c +++ b/tests/test-image.c @@ -36,81 +36,83 @@ #include #include #include +#include GMainLoop *loop; NotifyHandle *n; static void send(char *i, size_t rawlen, char *s, char *b) { - NotifyIcon *icon; + NotifyIcon *icon; - if (rawlen > 0) - icon = notify_icon_new_with_data(rawlen, i); - else - icon = notify_icon_new(i); - - n = notify_send_notification(NULL, // replaces nothing - NOTIFY_URGENCY_NORMAL, - s, b, - icon, - TRUE, time(NULL) + 5, - NULL, // no user data - 0); + if (rawlen > 0) + icon = notify_icon_new_with_data(rawlen, i); + else + icon = notify_icon_new(i); - if (!n) { - fprintf(stderr, "failed to send notification\n"); - exit(1); - } + n = notify_send_notification(NULL, // replaces nothing + NULL, + NOTIFY_URGENCY_NORMAL, + s, b, + icon, + TRUE, time(NULL) + 5, + NULL, // no user data + 0); - notify_icon_destroy(icon); + if (!n) { + fprintf(stderr, "failed to send notification\n"); + exit(1); + } + + notify_icon_destroy(icon); } int main() { - if (!notify_init("Images Test")) exit(1); + if (!notify_init("Images Test")) exit(1); - DBusConnection *conn = dbus_bus_get(DBUS_BUS_SESSION, NULL); - loop = g_main_loop_new(NULL, FALSE); + DBusConnection *conn = dbus_bus_get(DBUS_BUS_SESSION, NULL); + loop = g_main_loop_new(NULL, FALSE); - dbus_connection_setup_with_g_main(conn, NULL); + dbus_connection_setup_with_g_main(conn, NULL); - // these images exist on fedora core 2 workstation profile. might not on yours - - send("gnome-starthere", - 0, - "Welcome to Linux!", - "This is your first login. To begin exploring the system, click on 'Start Here', 'Computer' or 'Applications'"); + // these images exist on fedora core 2 workstation profile. might not on yours - char file[1024]; - readlink("/proc/self/exe", file, sizeof(file)); - *strrchr(file, '/') = '\0'; - strcat(file, "/../applet-critical.png"); - - printf("sending %s\n", file); + send("gnome-starthere", + 0, + "Welcome to Linux!", + "This is your first login. To begin exploring the system, click on 'Start Here', 'Computer' or 'Applications'"); - send(file, - 0, - "Alert!", - "Warning!"); + char file[1024]; + readlink("/proc/self/exe", file, sizeof(file)); + *strrchr(file, '/') = '\0'; + strcat(file, "/../applet-critical.png"); - - // FIXME: test raw image transfer - struct stat buf; - if (stat(file, &buf) == -1) - { - fprintf(stderr, "could not stat %s: %s", file, strerror(errno)); - exit(1); - } + printf("sending %s\n", file); - int fd = open(file, O_RDONLY); - - void *pngbase = mmap(NULL, buf.st_size, PROT_READ, MAP_PRIVATE, fd, 0); + send(file, + 0, + "Alert!", + "Warning!"); - close(fd); - - send(pngbase, - buf.st_size, - "Raw image test", - "This is an image marshalling test"); - return 0; + // FIXME: test raw image transfer + struct stat buf; + if (stat(file, &buf) == -1) + { + fprintf(stderr, "could not stat %s: %s", file, strerror(errno)); + exit(1); + } + + int fd = open(file, O_RDONLY); + + void *pngbase = mmap(NULL, buf.st_size, PROT_READ, MAP_PRIVATE, fd, 0); + + close(fd); + + send(pngbase, + buf.st_size, + "Raw image test", + "This is an image marshalling test"); + + return 0; } diff --git a/tests/test-markup.c b/tests/test-markup.c index 05eb8ea..b2f9a29 100644 --- a/tests/test-markup.c +++ b/tests/test-markup.c @@ -24,23 +24,24 @@ #include int main() { - notify_init("Markup"); - - NotifyHandle *n = notify_send_notification(NULL, // replaces nothing - NOTIFY_URGENCY_NORMAL, - "Summary", + notify_init("Markup"); - "Some bold, underlined, italic, linked text", - - NULL, // no icon - TRUE, time(NULL) + 5, - NULL, // no user data - 0); // no actions + NotifyHandle *n = notify_send_notification( + NULL, // replaces nothing + NULL, + NOTIFY_URGENCY_NORMAL, + "Summary", + "Some bold, underlined, italic, " + "linked text", + NULL, // no icon + TRUE, time(NULL) + 5, + NULL, // no user data + 0); // no actions - if (!n) { - fprintf(stderr, "failed to send notification\n"); - return 1; - } + if (!n) { + fprintf(stderr, "failed to send notification\n"); + return 1; + } - return 0; + return 0; } diff --git a/tests/test-multi-actions.c b/tests/test-multi-actions.c index 5dd011a..94e0cb3 100644 --- a/tests/test-multi-actions.c +++ b/tests/test-multi-actions.c @@ -30,56 +30,59 @@ #include #include #include +#include GMainLoop *loop; NotifyHandle *n; static void callback(NotifyHandle *handle, guint32 uid, void *user_data) { - char *s = NULL; + char *s = NULL; - assert( uid >= 0 && uid <= 2 ); - - switch (uid) - { - case 0: s = "the notification"; break; - case 1: s = "Empty Trash"; break; - case 2: s = "Help Me"; break; - } - - printf("You clicked %s\n", s); + assert( uid >= 0 && uid <= 2 ); - notify_close(n); + switch (uid) + { + case 0: s = "the notification"; break; + case 1: s = "Empty Trash"; break; + case 2: s = "Help Me"; break; + } - g_main_loop_quit(loop); + printf("You clicked %s\n", s); + + notify_close(n); + + g_main_loop_quit(loop); } int main() { - if (!notify_init("Multi Action Test")) exit(1); + if (!notify_init("Multi Action Test")) exit(1); - DBusConnection *conn = dbus_bus_get(DBUS_BUS_SESSION, NULL); - loop = g_main_loop_new(NULL, FALSE); + DBusConnection *conn = dbus_bus_get(DBUS_BUS_SESSION, NULL); + loop = g_main_loop_new(NULL, FALSE); - dbus_connection_setup_with_g_main(conn, NULL); - - n = notify_send_notification(NULL, // replaces nothing - NOTIFY_URGENCY_NORMAL, - "Low disk space", "You can free up some disk space by emptying the trash can.", - NULL, // no icon - FALSE, 0, // does not expire - NULL, // no user data - - 3, // 3 actions - 0, "default", callback, - 1, "Empty Trash", callback, - 2, "Help Me", callback ); + dbus_connection_setup_with_g_main(conn, NULL); - if (!n) { - fprintf(stderr, "failed to send notification\n"); - return 1; - } + n = notify_send_notification(NULL, // replaces nothing + "device", + NOTIFY_URGENCY_NORMAL, + "Low disk space", + "You can free up some disk space by " + "emptying the trash can.", + NULL, // no icon + FALSE, 0, // does not expire + NULL, // no user data + 3, // 3 actions + 0, "default", callback, + 1, "Empty Trash", callback, + 2, "Help Me", callback ); - g_main_loop_run(loop); + if (!n) { + fprintf(stderr, "failed to send notification\n"); + return 1; + } - return 0; + g_main_loop_run(loop); + + return 0; } diff --git a/tests/test-replace.c b/tests/test-replace.c index cd7c6d8..282eb69 100644 --- a/tests/test-replace.c +++ b/tests/test-replace.c @@ -24,26 +24,28 @@ #include int main() { - notify_init("Replace Test"); - - NotifyHandle *n = notify_send_notification(NULL, // replaces nothing - NOTIFY_URGENCY_NORMAL, - "Summary", "Content", - NULL, // no icon - FALSE, 0, // does not expire - NULL, // no user data - 0); // no actions + notify_init("Replace Test"); - if (!n) { - fprintf(stderr, "failed to send notification\n"); - return 1; - } + NotifyHandle *n = notify_send_notification(NULL, // replaces nothing + NULL, + NOTIFY_URGENCY_NORMAL, + "Summary", "Content", + NULL, // no icon + FALSE, 0, // does not expire + NULL, // no user data + 0); // no actions + + if (!n) { + fprintf(stderr, "failed to send notification\n"); + return 1; + } - sleep(3); + sleep(3); - notify_send_notification(n, NOTIFY_URGENCY_NORMAL, "Second Summary", "Second Content", - NULL, TRUE, time(NULL) + 5, NULL, 0); - - return 0; + notify_send_notification(n, NULL, NOTIFY_URGENCY_NORMAL, + "Second Summary", "Second Content", + NULL, TRUE, 5, NULL, 0); + + return 0; } diff --git a/tools/notify-send.c b/tools/notify-send.c index a0be7d6..5f6a266 100644 --- a/tools/notify-send.c +++ b/tools/notify-send.c @@ -31,36 +31,39 @@ int main(int argc, const char **argv) { const gchar *summary = NULL; - const gchar *description = NULL; + const gchar *body = NULL; + const gchar *type = NULL; char *urgency_str = NULL; - gchar *sound = NULL; gchar *icons = NULL; gchar *icon_str = NULL; NotifyIcon *icon = NULL; NotifyUrgency urgency = NOTIFY_URGENCY_NORMAL; - time_t expire_time = 0; + time_t expire_timeout = 0; char ch; poptContext opt_ctx; const char **args; struct poptOption options[] = { { "urgency", 'u', POPT_ARG_STRING | POPT_ARGFLAG_STRIP, &urgency_str, - 0, N_("Specifies the urgency level (low, normal, high, critical)"), + 0, N_("Specifies the urgency level (low, normal, critical)."), NULL }, - { "expire-time", 't', POPT_ARG_INT | POPT_ARGFLAG_STRIP, &expire_time, - 0, N_("Specifies the timestamp at which to expire the notification, or if < current time, specifies timeout in seconds from current time"), + { "expire-time", 't', POPT_ARG_INT | POPT_ARGFLAG_STRIP, + &expire_timeout, 0, + N_("Specifies the timeout in seconds at which to expire the " + "notification."), NULL }, - { "sound", 's', POPT_ARG_STRING | POPT_ARGFLAG_STRIP, &sound, 0, - N_("Specifies a sound file to play on notification."), NULL }, { "icon", 'i', POPT_ARG_STRING | POPT_ARGFLAG_STRIP, &icons, 0, N_("Specifies an icon filename or stock icon to display."), N_("ICON1,ICON2,...") }, + { "type", 't', POPT_ARG_STRING | POPT_ARGFLAG_STRIP, &type, 0, + N_("Specifies the notification type."), + N_("ICON1,ICON2,...") }, POPT_AUTOHELP POPT_TABLEEND }; opt_ctx = poptGetContext("notify-send", argc, argv, options, 0); - poptSetOtherOptionHelp(opt_ctx, "[OPTIONS]* [description]"); + poptSetOtherOptionHelp(opt_ctx, "[OPTIONS]* [body]"); while ((ch = poptGetNextOpt(opt_ctx)) >= 0) ; @@ -82,7 +85,7 @@ main(int argc, const char **argv) if (args[1] != NULL) { - description = args[1]; + body = args[1]; if (args[2] != NULL) { @@ -110,8 +113,6 @@ main(int argc, const char **argv) urgency = NOTIFY_URGENCY_LOW; else if (!strcasecmp(urgency_str, "normal")) urgency = NOTIFY_URGENCY_NORMAL; - else if (!strcasecmp(urgency_str, "high")) - urgency = NOTIFY_URGENCY_HIGH; else if (!strcasecmp(urgency_str, "critical")) urgency = NOTIFY_URGENCY_CRITICAL; else @@ -123,11 +124,8 @@ main(int argc, const char **argv) if (!notify_init("notify-send")) exit(1); - /* if the given time is < current time, treat it as a timeout in seconds (ie 5 seconds) */ - if (expire_time && expire_time < time(NULL)) expire_time += time(NULL); - - notify_send_notification(NULL, urgency, summary, description, icon, - TRUE, expire_time, NULL, 0); + notify_send_notification(NULL, type, urgency, summary, body, icon, + TRUE, expire_timeout, NULL, 0); if (icon != NULL) notify_icon_destroy(icon);