* riece-notify.el: New add-on.
authorDaiki Ueno <ueno@unixuser.org>
Mon, 8 Sep 2008 08:21:25 +0000 (08:21 +0000)
committerDaiki Ueno <ueno@unixuser.org>
Mon, 8 Sep 2008 08:21:25 +0000 (08:21 +0000)
* riece-addon-modules.el (riece-addon-modules): Add
riece-notify (commented).
* Makefile.am (EXTRA_DIST): Add riece-notify.el.

lisp/ChangeLog
lisp/Makefile.am
lisp/riece-addon-modules.el
lisp/riece-notify.el [new file with mode: 0644]

index c683f50..9799954 100644 (file)
@@ -1,3 +1,10 @@
+2008-09-08  Daiki Ueno  <ueno@unixuser.org>
+
+       * riece-notify.el: New add-on.
+       * riece-addon-modules.el (riece-addon-modules): Add
+       riece-notify (commented).
+       * Makefile.am (EXTRA_DIST): Add riece-notify.el.
+
 2008-08-25  TAKAHASHI Kaoru  <kaoru@kaisei.org>
 
        * riece-commands.el (riece-command-enter-message): Fix behavior at
index f96a937..66268d3 100644 (file)
@@ -20,6 +20,7 @@ EXTRA_DIST = COMPILE ChangeLog ChangeLog.Liece \
        riece-kakasi.el riece-foolproof.el riece-yank.el riece-toolbar.el \
        riece-eval.el riece-google.el riece-keepalive.el riece-eval-ruby.el \
        riece-shrink-buffer.el riece-xfaceb.el riece-epg.el riece-twitter.el \
+       riece-notify.el \
        url-riece.el \
        riece-command-previous-channel.xpm riece-command-next-channel.xpm \
        riece-command-configure-windows.xpm riece-command-list-addons.xpm \
index 017cc3a..d9500e1 100644 (file)
@@ -56,6 +56,8 @@
         (riece-mcat "Use Riece only on the minibuffer."))
 ;;;    (cons 'riece-ndcc
 ;;;     (riece-mcat "DCC file sending protocol support (written in elisp.)"))
+;;;    (cons 'riece-notify
+;;;     (riece-mcat "Display notification on status area."))
    (cons 'riece-rdcc
         (riece-mcat "DCC file sending protocol support (written in Ruby.)"))
    (cons 'riece-shrink-buffer
@@ -77,4 +79,4 @@
    (cons 'riece-yank
         (riece-mcat "Enter the element of kill-ring."))))
 
-(provide 'riece-addon-modules)
\ No newline at end of file
+(provide 'riece-addon-modules)
diff --git a/lisp/riece-notify.el b/lisp/riece-notify.el
new file mode 100644 (file)
index 0000000..dc223e2
--- /dev/null
@@ -0,0 +1,71 @@
+;;; riece-notify.el --- display notification on status area
+;; Copyright (C) 1998-2008 Daiki Ueno
+
+;; Author: Daiki Ueno <ueno@unixuser.org>
+;; Created: 1998-09-28
+;; Keywords: IRC, riece
+
+;; This file is part of Riece.
+
+;; 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; either version 2, or (at your option)
+;; any later version.
+
+;; 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 GNU Emacs; see the file COPYING.  If not, write to the
+;; Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+;; Boston, MA 02110-1301, USA.
+
+;;; Commentary:
+
+;; NOTE: This is an add-on module for Riece.
+
+;;; Code:
+
+(require 'riece-message)
+(eval-when-compile (require 'riece-keyword))
+(require 'dbus)
+
+(defconst riece-notify-description "Display notification on status area.")
+
+(defun riece-notify-keyword-notify-function (keyword message)
+  (riece--notify (format "%s: %s"
+                        (riece-format-identity (riece-message-speaker message))
+                        (riece-message-text message))))
+
+(defun riece--notify (string)
+  (dbus-call-method
+   :session "org.freedesktop.Notifications"
+   "/org/freedesktop/Notifications"
+   "org.freedesktop.Notifications" "Notify"
+   "GNU Emacs"                 ;; Application name.
+   0                           ;; No replacement of other notifications.
+   ""                          ;; No icon.
+   "Notification summary"      ;; Summary.
+   (encode-coding-string string 'utf-8) ;; Body.
+   '(:array)                   ;; No actions (empty array of strings).
+   '(:array :signature "{sv}") ;; No hints
+   ;; (empty array of dictionary entries).
+   ':int32 -1)                 ;; Default timeout.
+  )
+
+(defun riece-notify-requires ()
+  '(riece-keyword))
+
+(defun riece-notify-insinuate ()
+  (add-hook 'riece-keyword-notify-functions
+           'riece-notify-keyword-notify-function))
+
+(defun riece-notify-uninstall ()
+  (remove-hook 'riece-keyword-notify-functions
+              'riece-notify-keyword-notify-function))
+
+(provide 'riece-notify)
+
+;;; riece-notify.el ends here