Mercurial > ~mikael > mcabber > hg
comparison mcabber/src/main.c @ 279:f5dd437c057b
Rewrite the settings system
Settings now use glibc library, and can be used for aliases and bindings.
author | Mikael Berthe <mikael@lilotux.net> |
---|---|
date | Tue, 05 Jul 2005 23:50:50 +0100 |
parents | 7f2e61392b2e |
children | f562b9af2de7 |
comparison
equal
deleted
inserted
replaced
278:a7af5517b453 | 279:f5dd437c057b |
---|---|
11 #include <glib.h> | 11 #include <glib.h> |
12 | 12 |
13 #include "jabglue.h" | 13 #include "jabglue.h" |
14 #include "screen.h" | 14 #include "screen.h" |
15 #include "parsecfg.h" | 15 #include "parsecfg.h" |
16 #include "settings.h" | |
16 #include "roster.h" | 17 #include "roster.h" |
17 #include "commands.h" | 18 #include "commands.h" |
18 #include "histolog.h" | 19 #include "histolog.h" |
19 #include "hooks.h" | 20 #include "hooks.h" |
20 #include "utils.h" | 21 #include "utils.h" |
130 /* Parsing config file... */ | 131 /* Parsing config file... */ |
131 ut_WriteLog("Parsing config file...\n"); | 132 ut_WriteLog("Parsing config file...\n"); |
132 cfg_file(configFile); | 133 cfg_file(configFile); |
133 if (configFile) g_free(configFile); | 134 if (configFile) g_free(configFile); |
134 | 135 |
135 optstring = cfg_read("debug"); | 136 optstring = settings_opt_get("debug"); |
136 if (optstring) ut_InitDebug(1, optstring); | 137 if (optstring) ut_InitDebug(1, optstring); |
137 | 138 |
138 servername = cfg_read("server"); | 139 servername = settings_opt_get("server"); |
139 username = cfg_read("username"); | 140 username = settings_opt_get("username"); |
140 password = cfg_read("password"); | 141 password = settings_opt_get("password"); |
141 resource = cfg_read("resource"); | 142 resource = settings_opt_get("resource"); |
142 | 143 |
143 if (!servername) { | 144 if (!servername) { |
144 printf("Server name has not been specified in the config file!\n"); | 145 printf("Server name has not been specified in the config file!\n"); |
145 return -1; | 146 return -1; |
146 } | 147 } |
164 scr_InitCurses(); | 165 scr_InitCurses(); |
165 | 166 |
166 ut_WriteLog("Drawing main window...\n"); | 167 ut_WriteLog("Drawing main window...\n"); |
167 scr_DrawMainWindow(TRUE); | 168 scr_DrawMainWindow(TRUE); |
168 | 169 |
169 optval = (cfg_read_int("logging") > 0); | 170 optval = (settings_opt_get_int("logging") > 0); |
170 optval2 = (cfg_read_int("load_logs") > 0); | 171 optval2 = (settings_opt_get_int("load_logs") > 0); |
171 if (optval || optval2) | 172 if (optval || optval2) |
172 hlog_enable(optval, cfg_read("logging_dir"), optval2); | 173 hlog_enable(optval, settings_opt_get("logging_dir"), |
173 | 174 optval2); |
174 if ((optstring = cfg_read("events_command")) != NULL) | 175 |
176 optstring = settings_opt_get("events_command"); | |
177 if (optstring) | |
175 hk_ext_cmd_init(optstring); | 178 hk_ext_cmd_init(optstring); |
176 | 179 |
177 ssl = (cfg_read_int("ssl") > 0); | 180 ssl = (settings_opt_get_int("ssl") > 0); |
178 port = (unsigned int) cfg_read_int("port"); | 181 port = (unsigned int) settings_opt_get_int("port"); |
179 | 182 |
180 jb_set_priority(cfg_read_int("priority")); | 183 jb_set_priority(settings_opt_get_int("priority")); |
181 | 184 |
182 /* Connect to server */ | 185 /* Connect to server */ |
183 ut_WriteLog("Connecting to server: %s:%d\n", servername, port); | 186 ut_WriteLog("Connecting to server: %s:%d\n", servername, port); |
184 scr_LogPrint("Connecting to server: %s:%d", servername, port); | 187 scr_LogPrint("Connecting to server: %s:%d", servername, port); |
185 | 188 |
192 scr_TerminateCurses(); | 195 scr_TerminateCurses(); |
193 return -2; | 196 return -2; |
194 } | 197 } |
195 | 198 |
196 ping = 40; | 199 ping = 40; |
197 if (cfg_read("pinginterval")) | 200 if (settings_opt_get("pinginterval")) |
198 ping = (unsigned int) atoi(cfg_read("pinginterval")); | 201 ping = (unsigned int) settings_opt_get_int("pinginterval"); |
199 jb_set_keepalive_delay(ping); | 202 jb_set_keepalive_delay(ping); |
200 ut_WriteLog("Ping interval stablished: %d secs\n", ping); | 203 ut_WriteLog("Ping interval stablished: %d secs\n", ping); |
201 | 204 |
202 if (cfg_read_int("hide_offline_buddies") > 0) | 205 if (settings_opt_get_int("hide_offline_buddies") > 0) |
203 buddylist_set_hide_offline_buddies(TRUE); | 206 buddylist_set_hide_offline_buddies(TRUE); |
204 | 207 |
205 /* Initialize commands system */ | 208 /* Initialize commands system */ |
206 cmd_init(); | 209 cmd_init(); |
207 | 210 |