/* * Save settings */ static void timeshift_conf_class_save ( idnode_t *self ) { htsmsg_t *m; timeshift_fixup(); m = htsmsg_create_map(); idnode_save(×hift_conf.idnode, m); hts_settings_save(m, "timeshift/config"); htsmsg_destroy(m); }
/* * Intialise global file manager */ void timeshift_init ( void ) { htsmsg_t *m; const char *str; uint32_t u32; timeshift_filemgr_init(); /* Defaults */ timeshift_enabled = 0; // Disabled timeshift_ondemand = 0; // Permanent timeshift_path = NULL; // setting dir timeshift_unlimited_period = 0; timeshift_max_period = 3600; // 1Hr timeshift_unlimited_size = 0; timeshift_max_size = 10000 * (size_t)1048576; // 10G timeshift_ram_size = 0; timeshift_ram_segment_size = 0; /* Load settings */ if ((m = hts_settings_load("timeshift/config"))) { if (!htsmsg_get_u32(m, "enabled", &u32)) timeshift_enabled = u32 ? 1 : 0; if (!htsmsg_get_u32(m, "ondemand", &u32)) timeshift_ondemand = u32 ? 1 : 0; if ((str = htsmsg_get_str(m, "path"))) timeshift_path = strdup(str); if (!htsmsg_get_u32(m, "unlimited_period", &u32)) timeshift_unlimited_period = u32 ? 1 : 0; htsmsg_get_u32(m, "max_period", ×hift_max_period); if (!htsmsg_get_u32(m, "unlimited_size", &u32)) timeshift_unlimited_size = u32 ? 1 : 0; if (!htsmsg_get_u32(m, "max_size", &u32)) timeshift_max_size = 1048576LL * u32; if (!htsmsg_get_u32(m, "ram_size", &u32)) { timeshift_ram_size = 1048576LL * u32; timeshift_ram_segment_size = timeshift_ram_size / 10; } if (!htsmsg_get_u32(m, "ram_only", &u32)) timeshift_ram_only = u32 ? 1 : 0; htsmsg_destroy(m); timeshift_fixup(); } }
/* * Intialise global file manager */ void timeshift_init ( void ) { htsmsg_t *m; timeshift_filemgr_init(); /* Defaults */ memset(×hift_conf, 0, sizeof(timeshift_conf)); timeshift_conf.idnode.in_class = ×hift_conf_class; timeshift_conf.max_period = 60; // Hr (60mins) timeshift_conf.max_size = 10000 * (size_t)1048576; // 10G /* Load settings */ if ((m = hts_settings_load("timeshift/config"))) { idnode_load(×hift_conf.idnode, m); htsmsg_destroy(m); timeshift_fixup(); } }
/* * Save settings */ void timeshift_save ( void ) { htsmsg_t *m; timeshift_fixup(); m = htsmsg_create_map(); htsmsg_add_u32(m, "enabled", timeshift_enabled); htsmsg_add_u32(m, "ondemand", timeshift_ondemand); if (timeshift_path) htsmsg_add_str(m, "path", timeshift_path); htsmsg_add_u32(m, "unlimited_period", timeshift_unlimited_period); htsmsg_add_u32(m, "max_period", timeshift_max_period); htsmsg_add_u32(m, "unlimited_size", timeshift_unlimited_size); htsmsg_add_u32(m, "max_size", timeshift_max_size / 1048576); htsmsg_add_u32(m, "ram_size", timeshift_ram_size / 1048576); htsmsg_add_u32(m, "ram_only", timeshift_ram_only); hts_settings_save(m, "timeshift/config"); }
/* * Changed settings */ static void timeshift_conf_class_changed ( idnode_t *self ) { timeshift_fixup(); }