From aabafd4a372c4eba90312a58fa5a9aa493bdd1ee Mon Sep 17 00:00:00 2001 From: eugeni Date: Mon, 23 Mar 2009 15:48:44 +0000 Subject: Added support for msec notifications. git-svn-id: svn+ssh://svn.mandriva.com/svn/soft/s2u/trunk@254590 99302b65-d5f7-0310-b3dd-f8cd6f4e3d94 --- Makefile | 6 +++--- s2u.c | 34 ++++++++++++++++++++++++++++++---- 2 files changed, 33 insertions(+), 7 deletions(-) diff --git a/Makefile b/Makefile index ffec8df..963ab80 100644 --- a/Makefile +++ b/Makefile @@ -18,15 +18,15 @@ FILES = Makefile README hostname-post s2u.c s2u.sh \ DEFS = -DDBUS_API_SUBJECT_TO_CHANGE=1 CC = gcc CFLAGS = -O2 -pipe -Wall -Werror -INCLUDES = $(shell pkg-config dbus-glib-1 gdk-2.0 --cflags) -LDFLAGS = $(shell pkg-config dbus-glib-1 gdk-2.0 --libs) +INCLUDES = $(shell pkg-config dbus-glib-1 gdk-2.0 gtk+-2.0 --cflags) +LIBS = $(shell pkg-config dbus-glib-1 gdk-2.0 gtk+-2.0 --libs) -lnotify COMPILE = $(CC) $(DEFS) $(CFLAGS) all: s2u s2u: s2u.o - $(CC) $(LDFLAGS) -o $@ $^ + $(CC) $(LDFLAGS) -o $@ $^ $(LIBS) .c.o: $(COMPILE) $(INCLUDES) -c $< diff --git a/s2u.c b/s2u.c index 9e09470..03ee852 100644 --- a/s2u.c +++ b/s2u.c @@ -11,11 +11,12 @@ /*************************************************************************** * - * Copyright (C) 2004,2005 Mandrakesoft + * Copyright (C) 2004,2005,2009 Mandrakesoft * Copyright (C) 2005 Mandriva * * Stew Benedict, * Frederic Lepied, + * Eugeni Dodonov * * code borrowed/adapted from the hal project - * http://www.freedesktop.org/Software/hal @@ -53,6 +54,7 @@ static const char compile_id[] = "$Compile: " __FILE__ " " __DATE__ " " __TIME__ #include #include #include +#include #include #include @@ -60,6 +62,7 @@ static const char compile_id[] = "$Compile: " __FILE__ " " __DATE__ " " __TIME__ static DBusConnection *dbus_connection; static gchar *cookie = NULL; +static NotifyNotification *n; /** Print out program usage. * @@ -134,8 +137,7 @@ filter_function (DBusConnection * connection, g_spawn_async("/", args, NULL, 0, NULL, NULL, NULL, NULL); return DBUS_HANDLER_RESULT_HANDLED; - } else { - if (dbus_message_is_signal (message, + } else if (dbus_message_is_signal (message, "com.mandriva.user", "updatemenu")) { @@ -144,8 +146,29 @@ filter_function (DBusConnection * connection, g_spawn_command_line_async("/etc/X11/xinit.d/menu", NULL); return DBUS_HANDLER_RESULT_HANDLED; + } else if (dbus_message_is_signal (message, + "com.mandriva.user", + "security_notification")) { + /* msec */ + char *string; + DBusError error; + dbus_error_init(&error); + if (dbus_message_get_args (message, + &error, + DBUS_TYPE_STRING, &string, + DBUS_TYPE_INVALID)) { + n = notify_notification_new("MSEC", string, GTK_STOCK_INFO, NULL); + if (!notify_notification_show (n, NULL)) { + g_printerr("notify_notification_show: failed to show notification\n"); + } + g_object_unref(G_OBJECT(n)); } - else + else { + fprintf (stderr, "an error occurred: %s\n", error.message); + } + dbus_error_free(&error); + return DBUS_HANDLER_RESULT_HANDLED; + } else { return DBUS_HANDLER_RESULT_NOT_YET_HANDLED; } } @@ -298,6 +321,9 @@ main (int argc, char *argv[]) gdk_init(&argc, &argv); + /* init libnotify */ + notify_init("s2u"); + loop = g_main_loop_new (NULL, FALSE); /* set up the dbus services */ -- cgit v1.2.1