comparison mcabber/src/main.c @ 872:a0ddc43b421e

Don't stop when there is no configuration file
author Mikael Berthe <mikael@lilotux.net>
date Thu, 25 May 2006 22:39:37 +0200
parents cbeedd730b1b
children b461d7ee6d96
comparison
equal deleted inserted replaced
871:cb54c9d76853 872:a0ddc43b421e
263 /* Parsing config file... */ 263 /* Parsing config file... */
264 ret = cfg_read_file(configFile); 264 ret = cfg_read_file(configFile);
265 /* free() configFile if it has been allocated during options parsing */ 265 /* free() configFile if it has been allocated during options parsing */
266 g_free(configFile); 266 g_free(configFile);
267 /* Leave if there was an error in the config. file */ 267 /* Leave if there was an error in the config. file */
268 if (ret) 268 if (ret == -2)
269 exit(EXIT_FAILURE); 269 exit(EXIT_FAILURE);
270 270
271 optstring = settings_opt_get("tracelog_file"); 271 optstring = settings_opt_get("tracelog_file");
272 if (optstring) 272 if (optstring)
273 ut_InitDebug(settings_opt_get_int("tracelog_level"), optstring); 273 ut_InitDebug(settings_opt_get_int("tracelog_level"), optstring);
274 274
275 /* If no password is stored, we ask for it before entering 275 /* If no password is stored, we ask for it before entering
276 ncurses mode */ 276 ncurses mode -- unless the username is unknown. */
277 if (!settings_opt_get("password")) { 277 if (settings_opt_get("username") && !settings_opt_get("password")) {
278 const char *p; 278 const char *p;
279 p = settings_opt_get("server"); 279 p = settings_opt_get("server");
280 if (p) 280 if (p)
281 printf("Server: %s\n", p); 281 printf("Server: %s\n", p);
282 p = settings_opt_get("username"); 282 p = settings_opt_get("username");
306 scr_LogPrint(LPRINT_DEBUG, "Ping interval established: %d secs", ping); 306 scr_LogPrint(LPRINT_DEBUG, "Ping interval established: %d secs", ping);
307 307
308 if (settings_opt_get_int("hide_offline_buddies") > 0) 308 if (settings_opt_get_int("hide_offline_buddies") > 0)
309 buddylist_set_hide_offline_buddies(TRUE); 309 buddylist_set_hide_offline_buddies(TRUE);
310 310
311 /* Connection */ 311 if (ret < 0) {
312 if (settings_opt_get("password")) 312 scr_LogPrint(LPRINT_NORMAL, "No configuration file has been found.");
313 scr_ShowBuddyWindow();
314 } else {
315 /* Connection */
313 mcabber_connect(); 316 mcabber_connect();
314 else 317 }
315 scr_LogPrint(LPRINT_LOGNORM, "Can't connect: no password supplied");
316 318
317 scr_LogPrint(LPRINT_DEBUG, "Entering into main loop..."); 319 scr_LogPrint(LPRINT_DEBUG, "Entering into main loop...");
318 320
319 for (ret = 0 ; ret != 255 ; ) { 321 for (ret = 0 ; ret != 255 ; ) {
320 scr_Getch(&kcode); 322 scr_Getch(&kcode);