[Xfce4-commits] [apps/xfce4-notifyd] 01/29: Try to add a basic notification log
noreply at xfce.org
noreply at xfce.org
Sun Jan 29 20:51:51 CET 2017
This is an automated email from the git hooks/post-receive script.
ochosi pushed a commit to branch master
in repository apps/xfce4-notifyd.
commit 71ba7c3fa219eeb7595aa176dd1916533871c757
Author: Simon Steinbeiss <simon.steinbeiss at elfenbeinturm.at>
Date: Tue Oct 11 17:14:50 2016 +0200
Try to add a basic notification log
---
xfce4-notifyd/xfce-notify-daemon.c | 3 ++
xfce4-notifyd/xfce-notify-log.c | 92 ++++++++++++++++++++++++++++++++++++++
xfce4-notifyd/xfce-notify-log.h | 31 +++++++++++++
3 files changed, 126 insertions(+)
diff --git a/xfce4-notifyd/xfce-notify-daemon.c b/xfce4-notifyd/xfce-notify-daemon.c
index 7f11e58..ab3c548 100644
--- a/xfce4-notifyd/xfce-notify-daemon.c
+++ b/xfce4-notifyd/xfce-notify-daemon.c
@@ -43,6 +43,7 @@
#include "xfce-notify-daemon.h"
#include "xfce-notify-window.h"
+#include "xfce-notify-log.h"
#include "xfce-notify-marshal.h"
#define SPACE 16
@@ -1218,6 +1219,8 @@ notify_notify (XfceNotifyGBus *skeleton,
xndaemon->close_timeout = 0;
+ xfce_notify_log_insert_line (new_app_name);
+
xfce_notify_gbus_complete_notify(skeleton, invocation, OUT_id);
return TRUE;
}
diff --git a/xfce4-notifyd/xfce-notify-log.c b/xfce4-notifyd/xfce-notify-log.c
new file mode 100644
index 0000000..33e3727
--- /dev/null
+++ b/xfce4-notifyd/xfce-notify-log.c
@@ -0,0 +1,92 @@
+/*
+ * xfce4-notifyd
+ *
+ * Copyright (c) 2016 Simon Steinbeiß <ochosi at xfce.org>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; version 2 of the License ONLY.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+
+#ifdef HAVE_STRING_H
+#include <string.h>
+#endif
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+
+#include <libxfce4util/libxfce4util.h>
+
+#include <glib.h>
+
+#include "xfce-notify-log.h"
+
+gchar **
+xfce_notify_log_get (void)
+{
+ gchar **lines = NULL;
+ gchar *notify_log = NULL;
+ gchar *contents = NULL;
+ gsize length = 0;
+
+ notify_log = xfce_resource_lookup (XFCE_RESOURCE_CACHE, XFCE_NOTIFY_LOG_FILE);
+
+ if (notify_log && g_file_get_contents (notify_log, &contents, &length, NULL))
+ {
+ lines = g_strsplit (contents, "\n", -1);
+ g_free (contents);
+ }
+
+ g_free (notify_log);
+
+ return lines;
+}
+
+void xfce_notify_log_insert_line (const gchar *line)
+{
+ gchar *notify_log = NULL;
+
+ notify_log = xfce_resource_save_location (XFCE_RESOURCE_CACHE,
+ XFCE_NOTIFY_LOG_FILE, TRUE);
+
+ if (notify_log)
+ {
+ FILE *f;
+ f = fopen (notify_log, "a");
+ fprintf (f, "%s\n", line);
+ fclose (f);
+ g_free (notify_log);
+ }
+ else
+ g_warning ("Unable to open cache file");
+}
+
+void xfce_notify_log_clear (void)
+{
+ gchar *notify_log = NULL;
+
+ notify_log = xfce_resource_save_location (XFCE_RESOURCE_CACHE,
+ XFCE_NOTIFY_LOG_FILE, FALSE);
+
+ if (notify_log)
+ {
+ FILE *f;
+ f = fopen (notify_log, "w");
+ fclose (f);
+ g_free (notify_log);
+ }
+}
diff --git a/xfce4-notifyd/xfce-notify-log.h b/xfce4-notifyd/xfce-notify-log.h
new file mode 100644
index 0000000..810fc5f
--- /dev/null
+++ b/xfce4-notifyd/xfce-notify-log.h
@@ -0,0 +1,31 @@
+/*
+ * xfce4-notifyd
+ *
+ * Copyright (c) 2016 Simon Steinbeiß <ochosi at xfce.org>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; version 2 of the License ONLY.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+#ifndef __XFCE_NOTIFY_LOG_H_
+#define __XFCE_NOTIFY_LOG_H_
+
+
+#define XFCE_NOTIFY_LOG_FILE "xfce4/notifyd/log"
+
+gchar **
+xfce_notify_log_get (void);
+void xfce_notify_log_insert_line (const gchar *line);
+void xfce_notify_log_clear (void);
+
+#endif /* __XFCE_NOTIFY_LOG_H_ */
--
To stop receiving notification emails like this one, please contact
the administrator of this repository.
More information about the Xfce4-commits
mailing list