comparison mcabber/mcabber/histolog.c @ 2205:1177b33d4550

Do not hardcode the default logging location The current configuration directory is used as a base.
author Mikael Berthe <mikael@lilotux.net>
date Sat, 17 Oct 2015 20:19:58 +0200
parents 09508eeb81dc
children 736f9323d701
comparison
equal deleted inserted replaced
2204:ccd4ffa41a1b 2205:1177b33d4550
356 fclose(fp); 356 fclose(fp);
357 g_free(data); 357 g_free(data);
358 } 358 }
359 359
360 // hlog_enable() 360 // hlog_enable()
361 // Enable logging to files. If root_dir is NULL, then $HOME/.mcabber is used. 361 // Enable logging to files. If root_dir is NULL, then the subdirectory "histo"
362 // in mcabber configuration directory is used.
362 // If loadfiles is TRUE, we will try to load buddies history logs from file. 363 // If loadfiles is TRUE, we will try to load buddies history logs from file.
363 void hlog_enable(guint enable, const char *root_dir, guint loadfiles) 364 void hlog_enable(guint enable, const char *root_dir, guint loadfiles)
364 { 365 {
365 UseFileLogging = enable; 366 UseFileLogging = enable;
366 FileLoadLogs = loadfiles; 367 FileLoadLogs = loadfiles;
381 } else { 382 } else {
382 RootDir = g_strdup_printf("%s/", xp_root_dir); 383 RootDir = g_strdup_printf("%s/", xp_root_dir);
383 g_free(xp_root_dir); 384 g_free(xp_root_dir);
384 } 385 }
385 } else { 386 } else {
386 char *home = getenv("HOME"); 387 const char *cfgdir = settings_get_mcabber_config_dir();
387 const char *dir = "/.mcabber/histo/"; 388 const char *hdir = "/histo/";
388 RootDir = g_strdup_printf("%s%s", home, dir); 389 RootDir = g_strdup_printf("%s%s", cfgdir, hdir);
389 } 390 }
390 // Check directory permissions (should not be readable by group/others) 391 // Check directory permissions (should not be readable by group/others)
391 if (checkset_perm(RootDir, TRUE) == -1) { 392 if (checkset_perm(RootDir, TRUE) == -1) {
392 // The directory does not actually exists 393 // The directory does not actually exists
393 g_free(RootDir); 394 g_free(RootDir);