]> crepu.dev Git - config.git/blame - djavu-asus/elpa/jabber-20230715.456/jabber-notifications.el
Se agregan las configuraciones del tarro
[config.git] / djavu-asus / elpa / jabber-20230715.456 / jabber-notifications.el
CommitLineData
53e6db90
DC
1;; jabber-notifications.el - emacs-jabber interface to notifications.el -*- lexical-binding: t; -*-
2
3;; Copyright (C) 2014 - Adam Sjøgren - asjo@koldfront.dk
4;; Copyright (C) 2010 - Kirill A. Korinskiy - catap@catap.ru
5;; Copyright (C) 2007 - Rodrigo Lazo - rlazo.paz@gmail.com
6
7;; This program is free software; you can redistribute it and/or modify
8;; it under the terms of the GNU General Public License as published by
9;; the Free Software Foundation; either version 2 of the License, or
10;; (at your option) any later version.
11
12;; This program is distributed in the hope that it will be useful,
13;; but WITHOUT ANY WARRANTY; without even the implied warranty of
14;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15;; GNU General Public License for more details.
16
17;; You should have received a copy of the GNU General Public License
18;; along with this program; if not, write to the Free Software
19;; Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
20
21;; Built on jabber-libnotify.el.
22
23(eval-when-compile (require 'jabber-alert))
24(unless (string< emacs-version "24.1") ;notifications.el preset since Emacs 24.1
25 (require 'notifications)
26
27 (defcustom jabber-notifications-icon ""
28 "Icon to be used on the notification pop-up. Default is empty"
29 :type '(file :must-match t)
30 :group 'jabber-alerts)
31
32 (defcustom jabber-notifications-timeout nil
33 "Specifies the timeout of the pop up window in millisecond"
34 :type 'integer
35 :group 'jabber-alerts)
36
37 (defcustom jabber-notifications-message-header "Jabber message"
38 "Defines the header of the pop up."
39 :type 'string
40 :group 'jabber-alerts)
41
42 (defcustom jabber-notifications-app "Emacs Jabber"
43 "Defines the app of the pop up."
44 :type 'string
45 :group 'jabber-alerts)
46
47 (defcustom jabber-notifications-urgency "low"
48 "Urgency of message"
49 :type '(choice (const :tag "Low" "low")
50 (const :tag "Normal" "normal")
51 (const :tag "Critical" "critical"))
52 :group 'jabber-alerts)
53
54 (defun jabber-message-notifications (from buffer text title)
55 "Show a message through the notifications.el interface"
56 (let
57 ((body (or (jabber-escape-xml text) " "))
58 (head (jabber-escape-xml
59 (or title
60 (or jabber-notifications-message-header " ")
61 text)))
62 (avatar-hash (get (jabber-jid-symbol from) 'avatar-hash)))
63 (notifications-notify
64 :title title
65 :body body
66 :app-icon (or (and avatar-hash (jabber-avatar-find-cached avatar-hash))
67 jabber-notifications-icon)
68 :app-name jabber-notifications-app
69 :category "jabber.message"
70 :timeout jabber-notifications-timeout)))
71
72 (defun jabber-muc-notifications (nick group buffer text title)
73 "Show MUC message through the notifications.el interface"
74 (jabber-message-notifications group buffer (if nick (format "%s: %s" nick text) text) title)
75 )
76
77 (defun jabber-muc-notifications-personal (nick group buffer text title)
78 "Show personal MUC message through the notifications.el interface"
79 (if (jabber-muc-looks-like-personal-p text group)
80 (jabber-muc-notifications nick group buffer text title))
81 )
82
83 ;; jabber-*-notifications* requires "from" argument, so we cant use
84 ;; define-jabber-alert/define-personal-jabber-alert here and do the
85 ;; work by hand:
86 (cl-pushnew 'jabber-message-notifications (get 'jabber-alert-message-hooks 'custom-options))
87 (cl-pushnew 'jabber-muc-notifications (get 'jabber-alert-muc-hooks 'custom-options))
88 (cl-pushnew 'jabber-muc-notifications-personal (get 'jabber-alert-muc-hooks 'custom-options)))
89
90(provide 'jabber-notifications)