1 /*  notify.h
2  *
3  *
4  *  Copyright (C) 2014 Toxic All Rights Reserved.
5  *
6  *  This file is part of Toxic.
7  *
8  *  Toxic is free software: you can redistribute it and/or modify
9  *  it under the terms of the GNU General Public License as published by
10  *  the Free Software Foundation, either version 3 of the License, or
11  *  (at your option) any later version.
12  *
13  *  Toxic is distributed in the hope that it will be useful,
14  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
15  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
16  *  GNU General Public License for more details.
17  *
18  *  You should have received a copy of the GNU General Public License
19  *  along with Toxic.  If not, see <http://www.gnu.org/licenses/>.
20  *
21  */
22 
23 #ifndef NOTIFY_H
24 #define NOTIFY_H
25 
26 #include <stdint.h>
27 #include "windows.h"
28 
29 typedef enum _Notification {
30     silent = -1,
31     notif_error,
32     self_log_in,
33     self_log_out,
34     user_log_in,
35     user_log_out,
36     call_incoming,
37     call_outgoing,
38     generic_message,
39     transfer_pending,
40     transfer_completed,
41 } Notification;
42 
43 typedef enum _Flags {
44     NT_NOFOCUS = 1 << 0,  /* Notify when focus is not on this terminal. NOTE: only works with x11,
45                              * if no x11 present this flag is ignored
46                              */
47     NT_BEEP = 1 << 1,     /* Play native sound instead: \a */
48     NT_LOOP = 1 << 2,       /* Loop sound. If this setting active, notify() will return id of the sound
49                              * so it could be stopped. It will return 0 if error or NT_NATIVE flag is set and play \a instead
50                              */
51     NT_RESTOL = 1 << 3,     /* Respect tolerance. Usually used to stop flood at toxic startup
52                              * Only works if login_cooldown is true when calling init_notify()
53                              */
54     NT_NOTIFWND = 1 << 4,   /* Pop notify window. NOTE: only works(/WILL WORK) if libnotify is present */
55     NT_WNDALERT_0 = 1 << 5, /* Alert toxic */
56     NT_WNDALERT_1 = 1 << 6, /* Alert toxic */
57     NT_WNDALERT_2 = 1 << 7, /* Alert toxic */
58 
59     NT_ALWAYS = 1 << 8,     /* Force sound to play */
60 } Flags;
61 
62 int init_notify(int login_cooldown, int notification_timeout);
63 void terminate_notify(void);
64 
65 /* Kills all notifications for `id`. This must be called before freeing a ToxWindow. */
66 void kill_notifs(int id);
67 
68 int sound_notify(ToxWindow *self, Notification notif, uint64_t flags, int *id_indicator);
69 int sound_notify2(ToxWindow *self, Notification notif, uint64_t flags, int id);
70 
71 void stop_sound(int id);
72 
73 int box_notify(ToxWindow *self, Notification notif, uint64_t flags, int *id_indicator, const char *title,
74                const char *format, ...);
75 int box_notify2(ToxWindow *self, Notification notif, uint64_t flags, int id, const char *format, ...);
76 int box_silent_notify(ToxWindow *self, uint64_t flags, int *id_indicator, const char *title, const char *format, ...);
77 int box_silent_notify2(ToxWindow *self, uint64_t flags, int id, const char *format, ...);
78 
79 #ifdef SOUND_NOTIFY
80 bool set_sound(Notification sound, const char *value);
81 #endif /* SOUND_NOTIFY */
82 
83 #endif /* NOTIFY_H */
84