aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--Makefile6
-rw-r--r--s2u.c34
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, <sbenedict@mandriva.com>
* Frederic Lepied, <flepied@mandriva.com>
+ * Eugeni Dodonov <eugeni@mandriva.com>
*
* 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 <errno.h>
#include <signal.h>
#include <gdk/gdk.h>
+#include <libnotify/notify.h>
#include <dbus/dbus.h>
#include <dbus/dbus-glib.h>
@@ -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 */