[Galago-commits] r2987 - in trunk/notification-daemon: . src/daemon

galago-commits at freedesktop.org galago-commits at freedesktop.org
Sat Aug 25 17:59:05 PDT 2007


Author: chipx86
Date: 2007-08-25 17:59:04 -0700 (Sat, 25 Aug 2007)
New Revision: 2987

Modified:
   trunk/notification-daemon/ChangeLog
   trunk/notification-daemon/src/daemon/daemon.c
   trunk/notification-daemon/src/daemon/daemon.h
Log:
Return an error when attempting to close a notification of ID 0.


Modified: trunk/notification-daemon/ChangeLog
===================================================================
--- trunk/notification-daemon/ChangeLog	2007-06-13 10:13:26 UTC (rev 2986)
+++ trunk/notification-daemon/ChangeLog	2007-08-26 00:59:04 UTC (rev 2987)
@@ -1,3 +1,9 @@
+Sat Aug 25 17:58:35 PDT 2007  Christian Hammond <chipx86 at chipx86.com>
+
+	* src/daemon/daemon.c:
+	* src/daemon/daemon.h:
+	  - Return an error when attempting to close a notification of ID 0.
+
 Wed Jun 13 03:12:31 PDT 2007  Christian Hammond <chipx86 at chipx86.com>
 
 	* src/themes/standard/theme.c:

Modified: trunk/notification-daemon/src/daemon/daemon.c
===================================================================
--- trunk/notification-daemon/src/daemon/daemon.c	2007-06-13 10:13:26 UTC (rev 2986)
+++ trunk/notification-daemon/src/daemon/daemon.c	2007-08-26 00:59:04 UTC (rev 2987)
@@ -266,10 +266,13 @@
 	NotifyDaemonPrivate *priv = daemon->priv;
 	NotifyTimeout *nt;
 
+	printf("Closing notification %d (%d)\n", id, hide_notification);
+
 	nt = (NotifyTimeout *)g_hash_table_lookup(priv->notification_hash, &id);
 
 	if (nt != NULL)
 	{
+		printf("Found.\n");
 		_emit_closed_signal(nt->nw);
 
 		if (hide_notification)
@@ -451,6 +454,8 @@
 	nt->id = id;
 	nt->nw = nw;
 
+	printf("Assigning id %d\n",id);
+
 	_calculate_timeout(daemon, nt, timeout);
 
 	g_hash_table_insert(priv->notification_hash,
@@ -806,6 +811,17 @@
 	return FALSE;
 }
 
+GQuark
+notify_daemon_error_quark(void)
+{
+	static GQuark q = 0;
+
+	if (q == 0)
+		q = g_quark_from_static_string("notification-daemon-error-quark");
+
+	return q;
+}
+
 gboolean
 notify_daemon_notify_handler(NotifyDaemon *daemon,
 							 const gchar *app_name,
@@ -1079,9 +1095,15 @@
 notify_daemon_close_notification_handler(NotifyDaemon *daemon,
 										 guint id, GError **error)
 {
-	_close_notification(daemon, id, TRUE);
-
-	return TRUE;
+	if (id == 0)
+	{
+		g_set_error(error, notify_daemon_error_quark(), 100,
+					_("%u is not a valid notification ID"), id);
+		return FALSE;
+	} else {
+		_close_notification(daemon, id, TRUE);
+		return TRUE;
+	}
 }
 
 gboolean

Modified: trunk/notification-daemon/src/daemon/daemon.h
===================================================================
--- trunk/notification-daemon/src/daemon/daemon.h	2007-06-13 10:13:26 UTC (rev 2986)
+++ trunk/notification-daemon/src/daemon/daemon.h	2007-08-26 00:59:04 UTC (rev 2987)
@@ -72,17 +72,11 @@
 	GObjectClass parent_class;
 };
 
-enum _NotifyDaemonError
-{
-	NOTIFY_DAEMON_ERROR_GENERIC = 0,
-};
-
 G_BEGIN_DECLS
 
 GType notify_daemon_get_type(void);
 
-NotifyDaemon *notify_daemon_new(void)
-	G_GNUC_MALLOC;
+GQuark notify_daemon_error_quark(void);
 
 gboolean notify_daemon_notify_handler(NotifyDaemon *daemon,
 									  const gchar *app_name,



More information about the galago-commits mailing list