AmendHub

Download

jcs

/

wallops

/

chatter.h

 

(View History)

jcs   *: Add support for Pushover notifications when screen saver is running Latest amendment: 131 on 2024-09-24

1 /*
2 * Copyright (c) 2021-2022 joshua stein <jcs@jcs.org>
3 *
4 * Permission to use, copy, modify, and distribute this software for any
5 * purpose with or without fee is hereby granted, provided that the above
6 * copyright notice and this permission notice appear in all copies.
7 *
8 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
9 * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
10 * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
11 * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
12 * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
13 * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
14 * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
15 */
16
17 #ifndef __CHATTER_H__
18 #define __CHATTER_H__
19
20 #include <stdio.h>
21
22 #include "focusable.h"
23 #include "irc.h"
24 #include "util.h"
25
26 #define PROGRAM_NAME "Wallops"
27 #define HOMEPAGE "http://jcs.org/wallops"
28
29 #define CHATTER_FONT geneva
30 #define CHATTER_FONT_SIZE 10
31
32 #define MBAR_ID 128
33
34 #define NOTIFICATION_ICON_ID 128
35
36 #define ABOUT_DLOG_ID 130
37
38 #define APPLE_MENU_ID 128
39 #define APPLE_MENU_ABOUT_ID 1
40
41 #define FILE_MENU_ID 129
42 #define FILE_MENU_CONNECT_ID 1
43 #define FILE_MENU_SETTINGS_ID 2
44 #define FILE_MENU_QUIT_ID 4
45
46 #define EDIT_MENU_ID 130
47 #define EDIT_MENU_CUT_ID 1
48 #define EDIT_MENU_COPY_ID 2
49 #define EDIT_MENU_PASTE_ID 3
50
51 #define VIEW_MENU_ID 131
52 #define VIEW_MENU_PREV_TAB_ID 1
53 #define VIEW_MENU_NEXT_TAB_ID 2
54 #define VIEW_MENU_CLOSE_ID 3
55 #define VIEW_MENU_IGNORE_ID 4
56
57 #define IGNORE_MENU_ID 132
58 #define IGNORE_MENU_JOINS_ID 1
59 #define IGNORE_MENU_QUITS_ID 2
60 #define IGNORE_MENU_NICKS_ID 3
61
62 #define WINDOW_MENU_ID 133
63 #define WINDOW_MENU_HIDE_ID 1
64 #define WINDOW_MENU_N_ID 3
65
66 #define WAIT_TYPE_NONE (1 << 0)
67 #define WAIT_TYPE_BACKGROUND (1 << 1)
68 #define WAIT_TYPE_FOREGROUND (1 << 2)
69 #define WAIT_TYPE_URGENT (1 << 3)
70
71 #define IGNORE_NONE (1 << 0)
72 #define IGNORE_JOINS (1 << 1)
73 #define IGNORE_QUITS (1 << 2)
74 #define IGNORE_NICKS (1 << 3)
75
76 struct chatter_tab {
77 SLIST_ENTRY(chatter_tab) list;
78 struct irc_connection *conn;
79 struct irc_channel *channel;
80 char query_nick[member_size(struct irc_user, nick)];
81 TEHandle messages_te;
82 ControlHandle messages_scroller;
83 ListHandle nick_list;
84 Rect label_rect;
85 bool have_activity;
86 bool ignore_activity;
87 };
88 SLIST_HEAD(chatter_tabs_head, chatter_tab);
89
90 struct chatter {
91 struct focusable *focusable;
92 WindowPtr win;
93 BitMap shadow;
94 Rect shadow_bounds;
95 short shadow_refcnt;
96 TEHandle input_te;
97 char input[IRC_MAX_MSG_SIZE];
98 char tab_comp_input[member_size(struct irc_user, nick)];
99 char tab_comp_match[member_size(struct irc_user, nick)];
100 bool quitting;
101 bool need_tab_bar_redraw;
102 short ntabs;
103 struct chatter_tabs_head tabs_list;
104 struct chatter_tab *current_tab;
105 };
106
107 extern MenuHandle apple_menu, file_menu, edit_menu, view_menu, ignore_menu,
108 window_menu;
109
110 void notify(struct focusable *focusable, char *msg, char *titlefmt, ...);
111 void cancel_notification(void);
112
113 struct chatter * chatter_init(const char *server,
114 const unsigned short port, const char *password, const char *nick,
115 const char *ident, const char *realname, bool hide_motd,
116 const char *channel);
117 void chatter_update_titlebar(struct chatter *chatter);
118 size_t chatter_printf(struct chatter *chatter, struct irc_connection *conn,
119 char *dest_tab, const char *format, ...);
120 void chatter_insert_to_nick_list(struct chatter *chatter,
121 struct irc_channel *channel, struct irc_channel_nick *nick, short pos);
122 void chatter_remove_from_nick_list(struct chatter *chatter,
123 struct irc_channel *channel, struct irc_channel_nick *nick, short pos);
124 void chatter_sync_nick_list(struct chatter *chatter,
125 struct irc_channel *channel);
126 void chatter_clear_messages(struct chatter *chatter,
127 struct chatter_tab *tab);
128 struct chatter_tab * chatter_add_tab(struct chatter *chatter,
129 Rect *win_bounds, struct irc_connection *conn,
130 struct irc_channel *channel, char *query_nick);
131 void chatter_close_tab(struct chatter *chatter, struct chatter_tab *tab);
132 struct chatter_tab * chatter_find_tab(struct chatter *chatter,
133 struct irc_connection *conn, char *dest_tab);
134
135 #endif