1 /* Copyright (C) 2016-2018 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 #include <glib.h>
20 
21 #include "core/core.h"
22 #include "sui/sui.h"
23 #include "ret.h"
24 #include "i18n.h"
25 #include "utils.h"
26 
srn_chat_config_new()27 SrnChatConfig* srn_chat_config_new(){
28     SrnChatConfig *cfg;
29 
30     cfg = g_malloc0(sizeof(SrnChatConfig));
31     cfg->ui = sui_buffer_config_new();
32 
33     return cfg;
34 }
35 
srn_chat_config_check(SrnChatConfig * cfg)36 SrnRet srn_chat_config_check(SrnChatConfig *cfg){
37     if (!cfg){
38         return RET_ERR(_("Invalid chat config instance"));
39     }
40     return sui_buffer_config_check(cfg->ui);
41 }
42 
srn_chat_config_free(SrnChatConfig * cfg)43 void srn_chat_config_free(SrnChatConfig *cfg){
44     g_return_if_fail(cfg);
45 
46     str_assign(&cfg->password, NULL);
47     g_list_free_full(cfg->auto_run_cmd_list, g_free);
48     sui_buffer_config_free(cfg->ui);
49     g_free(cfg);
50 }
51