1
0
mirror of https://github.com/gnosygnu/xowa.git synced 2026-03-02 03:49:30 +00:00

Cfg: Remove more of old cfg system

This commit is contained in:
gnosygnu
2016-12-26 10:49:43 -05:00
parent 6f3500d129
commit dad76714d5
7 changed files with 6 additions and 72 deletions

View File

@@ -21,11 +21,7 @@ public class Xoa_cfg_mgr implements Gfo_invk {
private final Ordered_hash hash = Ordered_hash_.New_bry();
public Xoa_cfg_mgr(Xoa_app app) {this.app = app;}
public Xoa_app App() {return app;} private final Xoa_app app;
public Xoa_cfg_itm Get_itm_or_null(byte[] grp_key, byte[] itm_key) {
Xoa_cfg_grp grp = (Xoa_cfg_grp)hash.Get_by(grp_key);
return grp == null ? null : grp.Get_by_or_null(itm_key);
}
public Xoa_cfg_itm Get_itm_or_make(byte[] grp_key, byte[] itm_key) {
Xoa_cfg_itm Get_itm_or_make(byte[] grp_key, byte[] itm_key) {
Xoa_cfg_grp grp = null;
Object grp_obj = hash.Get_by(grp_key);
if (grp_obj == null) {
@@ -39,7 +35,6 @@ public class Xoa_cfg_mgr implements Gfo_invk {
}
public void Set_by_app(String grp_key, String val) {Set(Bry_.new_u8(grp_key), Xoa_cfg_grp_tid.Key_app_bry, val);}
public void Set_by_all(String grp_key, String val) {Set(Bry_.new_u8(grp_key), Xoa_cfg_grp_tid.Key_all_bry, val);}
public void Set_by_type(String grp_key, byte tid, String val) {Set(Bry_.new_u8(grp_key), Xow_domain_tid_.Get_type_as_bry(tid), val);}
private void Set(byte[] grp_key, byte[] tid_key, String val) {Get_itm_or_make(grp_key, tid_key).Val_(val);}
public void Init(Xow_wiki wiki) {
int len = hash.Count();
@@ -79,24 +74,8 @@ public class Xoa_cfg_mgr implements Gfo_invk {
throw Err_.new_unhandled(tid_byte);
}
}
public void Reset_all() {
hash.Clear();
db_txt.Cfg_reset_all(this);
}
public void Db_load_txt() {Db_load(db_txt);}
public void Db_load(Xoa_cfg_db db) {
db.Cfg_load_run(this);
this.Db_load_end();
}
private void Db_load_end() {
int len = hash.Count();
for (int i = 0; i < len; i++) {
Xoa_cfg_grp grp = (Xoa_cfg_grp)hash.Get_at(i);
grp.Db_load_end();
}
}
public void Db_save_txt() {Db_save(db_txt);} private final Xoa_cfg_db_txt db_txt = new Xoa_cfg_db_txt();
public void Db_save(Xoa_cfg_db db) {
private void Db_save(Xoa_cfg_db db) {
int len = hash.Count();
db.Cfg_save_bgn(this);
for (int i = 0; i < len; i++) {
@@ -110,14 +89,8 @@ public class Xoa_cfg_mgr implements Gfo_invk {
Object rslt = app.Gfs_mgr().Run_str_for(invk, msg_str);
return rslt != Gfo_invk_.Rv_error;
}
public Object Eval_get(Gfo_invk invk, String key) {
String msg_str = key + ";";
return app.Gfs_mgr().Run_str_for(invk, msg_str);
}
public Object Invk(GfsCtx ctx, int ikey, String k, GfoMsg m) {
if (ctx.Match(k, Invk_get)) return Get_itm_or_make(m.ReadBry("itm_key"), m.ReadBry("grp_key"));
else if (ctx.Match(k, Invk_reset_all)) Reset_all();
else return Gfo_invk_.Rv_unhandled;
return this;
} private static final String Invk_get = "get", Invk_reset_all = "reset_all";
} private static final String Invk_get = "get";
}

View File

@@ -46,7 +46,6 @@ public class Xoa_fsys_mgr implements Gfo_invk {
public Io_url Cfg_lang_core_dir() {return cfg_lang_core_dir;} private final Io_url cfg_lang_core_dir;
public Io_url Cfg_wiki_core_dir() {return cfg_wiki_core_dir;} private final Io_url cfg_wiki_core_dir;
public Io_url Cfg_site_meta_fil() {return cfg_site_meta_fil;} private final Io_url cfg_site_meta_fil;
public Io_url Bin_data_os_cfg_fil() {return bin_plat_dir.GenSubFil_nest("xowa", "cfg", Xoa_gfs_mgr.Cfg_os);}
public Io_url Wiki_css_dir(String wiki) {return css_dir.GenSubDir_nest(wiki, "html");} // EX: /xowa/temp/simple.wikipedia.org/html/xowa_common.css
public Io_url Wiki_file_dir(String wiki) {return file_dir.GenSubDir_nest(wiki);} // EX: /xowa/temp/simple.wikipedia.org/orig/
public Io_url Home_wiki_dir() {return home_wiki_dir;} private final Io_url home_wiki_dir;

View File

@@ -56,9 +56,7 @@ public class Xoa_gfs_mgr implements Gfo_invk, Gfo_invk_root_wkr {
Io_url app_data_dir = usr_fsys_mgr.App_data_dir();
Io_url url = null;
if (String_.Eq(type, "user_system_cfg")) url = app_data_dir.GenSubFil_nest("cfg", "user_system_cfg.gfs");
else if (String_.Eq(type, "xowa_cfg_custom")) url = usr_fsys_mgr.App_data_cfg_custom_fil();
else if (String_.Eq(type, "xowa_cfg_user")) url = usr_fsys_mgr.App_data_cfg_user_fil();
else if (String_.Eq(type, "xowa_cfg_os")) {url = app_fsys_mgr.Bin_data_os_cfg_fil(); Xoa_gfs_mgr_.Cfg_os_assert(url);}
else if (String_.Eq(type, "xowa_cfg_os")) {url = app_fsys_mgr.Bin_plat_dir().GenSubFil_nest("xowa", "cfg", Cfg_os); Xoa_gfs_mgr_.Cfg_os_assert(url);}
else if (String_.Eq(type, "xowa_cfg_app")) url = app_fsys_mgr.Cfg_app_fil();
else throw Err_.new_wo_type("invalid gfs type", "type", type);
try {Run_url(url);}
@@ -76,6 +74,6 @@ public class Xoa_gfs_mgr implements Gfo_invk, Gfo_invk_root_wkr {
return this;
} private static final String Invk_run_file_by_type = "run_file_by_type", Invk_fail_if_unhandled_ = "fail_if_unhandled_", Invk_txns = "txns";
public static void Msg_parser_init() {GfsCore.Instance.MsgParser_(gplx.langs.gfs.Gfs_msg_bldr.Instance);}
public static final String Cfg_user_file = "xowa_user_cfg.gfs", Cfg_user_custom_file = "user_custom_cfg.gfs", Cfg_os = "xowa_cfg_os.gfs";
private static final String Cfg_os = "xowa_cfg_os.gfs";
public static boolean Fail_if_unhandled = false;
}