1 /* Copyright (C) 2016-2017 Shengyu Zhang <i@silverrainz.me>
2  *
3  * This file is part of Srain.
4  *
5  * Srain is free software: you can redistribute it and/or modify
6  * it under the terms of the GNU General Public License as published by
7  * the Free Software Foundation, either version 3 of the License, or
8  * (at your option) any later version.
9  *
10  * This program is distributed in the hope that it will be useful,
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13  * GNU General Public License for more details.
14  *
15  * You should have received a copy of the GNU General Public License
16  * along with this program.  If not, see <http://www.gnu.org/licenses/>.
17  */
18 
19 #ifndef __SUI_H
20 #define __SUI_H
21 
22 #include <time.h>
23 #include "srain.h"
24 
25 typedef struct _SuiApplication SuiApplication;
26 typedef struct _SuiWindow SuiWindow;
27 typedef struct _SuiBuffer SuiBuffer;
28 typedef int SuiBufferFlag;
29 typedef struct _SuiUser SuiUser;
30 typedef struct _SuiMessage SuiMessage;
31 typedef enum _SuiMiscMessageStyle SuiMiscMessageStyle;
32 
33 enum _SuiMiscMessageStyle {
34     SUI_MISC_MESSAGE_STYLE_NONE = 0,
35     SUI_MISC_MESSAGE_STYLE_NORMAL,
36     SUI_MISC_MESSAGE_STYLE_ERROR,
37     SUI_MISC_MESSAGE_STYLE_ACTION,
38     SUI_MISC_MESSAGE_STYLE_UNKNOWN,
39 };
40 
41 #define __IN_SUI_H
42 #include "sui_event.h"
43 #include "sui_config.h"
44 #undef __IN_SUI_H
45 
46 void sui_proc_pending_event(void);
47 
48 /* SuiAppliaction */
49 SuiApplication* sui_new_application(const char *id, void *ctx, SuiApplicationEvents *events, SuiApplicationConfig *cfg);
50 void sui_free_application(SuiApplication *app);
51 void sui_run_application(SuiApplication *app, int argc, char *argv[]);
52 
53 void* sui_application_get_ctx(SuiApplication *app);
54 
55 void sui_application_set_config(SuiApplication *app, SuiApplicationConfig *cfg);
56 SuiApplicationConfig* sui_application_get_config(SuiApplication *app);
57 SuiApplicationOptions* sui_application_get_options(SuiApplication *app);
58 
59 /* SuiWindow */
60 SuiWindow* sui_new_window(SuiApplication *app, SuiWindowEvents *events);
61 void sui_free_window(SuiWindow *win);
62 
63 /* SuiBuffer */
64 SuiBuffer* sui_new_buffer(void *ctx, SuiBufferEvents *events, SuiBufferConfig *cfg);
65 void sui_free_buffer(SuiBuffer *buf);
66 void sui_activate_buffer(SuiBuffer *buf);
67 
68 void* sui_buffer_get_ctx(SuiBuffer *buf);
69 void sui_buffer_set_config(SuiBuffer *buf, SuiBufferConfig *cfg);
70 void sui_buffer_add_message(SuiBuffer *buf, SuiMessage *msg);
71 
72 /* SuiMessage */
73 SuiMessage *sui_new_misc_message(void *ctx, SuiMiscMessageStyle style);
74 SuiMessage *sui_new_send_message(void *ctx);
75 SuiMessage *sui_new_recv_message(void *ctx);
76 
77 void sui_update_message(SuiMessage *msg);
78 void sui_notify_message(SuiMessage *msg);
79 
80 /* User */
81 SuiUser* sui_new_user(void *ctx);
82 void sui_free_user(SuiUser *user);
83 void sui_add_user(SuiBuffer *buf, SuiUser *user);
84 void sui_rm_user(SuiBuffer *buf, SuiUser *user);
85 void sui_update_user(SuiBuffer *buf, SuiUser *user);
86 
87 /* Misc */
88 void sui_set_topic(SuiBuffer *sui, const char *topic);
89 void sui_set_topic_setter(SuiBuffer *sui, const char *setter);
90 void sui_message_box(const char *title, const char *msg);
91 
92 void sui_chan_list_start(SuiBuffer *sui);
93 void sui_chan_list_add(SuiBuffer *sui, const char *chan, int users, const char *topic);
94 void sui_chan_list_end(SuiBuffer *sui);
95 
96 #endif /* __SUI_H */
97