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

Cfg: Convert 'App - Security'

This commit is contained in:
gnosygnu
2016-12-15 11:25:22 -05:00
parent 5073db8044
commit 38f5f6de7c
27 changed files with 107 additions and 205 deletions

View File

@@ -31,7 +31,7 @@ import gplx.xowa.bldrs.wms.*;
import gplx.langs.htmls.encoders.*;
import gplx.xowa.bldrs.*;
import gplx.xowa.addons.*; import gplx.xowa.specials.mgrs.*;
import gplx.xowa.addons.apps.cfgs.*;
import gplx.xowa.addons.apps.cfgs.*; import gplx.xowa.apps.miscs.*;
public class Xoav_app implements Xoa_app, Gfo_invk {
public Xoav_app(Gfo_usr_dlg usr_dlg, Xoa_app_mode mode, Xog_tab_mgr tab_mgr, String plat_name, Io_url root_dir, Io_url file_dir, Io_url css_dir, Io_url http_root) {
Xoa_app_.Usr_dlg_(usr_dlg); this.usr_dlg = usr_dlg; this.mode = mode;
@@ -81,6 +81,7 @@ public class Xoav_app implements Xoa_app, Gfo_invk {
public Gfo_thread_mgr Thread_mgr() {return thread_mgr;} private final Gfo_thread_mgr thread_mgr = new Gfo_thread_mgr();
public Xop_amp_mgr Parser_amp_mgr() {return parser_amp_mgr;} private final Xop_amp_mgr parser_amp_mgr = Xop_amp_mgr.Instance;
public Xocfg_mgr Cfg() {return cfg;} private final Xocfg_mgr cfg = new Xocfg_mgr();
public Xoa_misc_mgr Misc_mgr() {return misc_mgr;} private final Xoa_misc_mgr misc_mgr = new Xoa_misc_mgr();
public Xowmf_mgr Wmf_mgr() {return wmf_mgr;} private final Xowmf_mgr wmf_mgr = new Xowmf_mgr();
public Gfo_usr_dlg Usr_dlg() {return usr_dlg;} public void Usr_dlg_(Gfo_usr_dlg v) {usr_dlg = v; Xoa_app_.Usr_dlg_(usr_dlg);} private Gfo_usr_dlg usr_dlg = Gfo_usr_dlg_.Noop;
@@ -98,9 +99,9 @@ public class Xoav_app implements Xoa_app, Gfo_invk {
user.Init_db(this, wiki_mgr, user_db_url);
this.Addon_mgr().Add_dflts_by_app(this).Run_by_app(this);
cfg.Init_by_app(this);
misc_mgr.Init_by_app(this);
}
public void Free_mem() { // NOTE:not yet called in drd; DATE:2016-12-04
cfg.Clear();
}
public static Xoav_app New_by_drd(gplx.xowa.drds.files.Xod_fsys_mgr fsys_mgr, Xog_tab_mgr tab_mgr) {
// create log

View File

@@ -31,7 +31,6 @@ public class Xoapi_root implements Gfo_invk {
nav_api.Init_by_kit(app);
gui_api.Init_by_kit(app);
html_api.Init_by_kit(app);
net_api.Init_by_kit(app);
usr_api.Init_by_kit(app);
xtns_api.Init_by_kit(app);
}
@@ -46,7 +45,6 @@ public class Xoapi_root implements Gfo_invk {
public Xoapi_gui Gui() {return gui_api;} private final Xoapi_gui gui_api = new Xoapi_gui();
public Xoapi_html Html() {return html_api;} private final Xoapi_html html_api = new Xoapi_html();
public Xoapi_bldr Bldr() {return bldr_api;} private final Xoapi_bldr bldr_api = new Xoapi_bldr();
public Xoapi_net Net() {return net_api;} private final Xoapi_net net_api = new Xoapi_net();
public Xoapi_usr Usr() {return usr_api;} private final Xoapi_usr usr_api = new Xoapi_usr();
public Xoapi_special Special() {return special_api;} private final Xoapi_special special_api = new Xoapi_special();
public Xoapi_xtns Xtns() {return xtns_api;} private final Xoapi_xtns xtns_api = new Xoapi_xtns();
@@ -64,7 +62,6 @@ public class Xoapi_root implements Gfo_invk {
else if (ctx.Match(k, Invk_nav)) return nav_api;
else if (ctx.Match(k, Invk_gui)) return gui_api;
else if (ctx.Match(k, Invk_html)) return html_api;
else if (ctx.Match(k, Invk_net)) return net_api;
else if (ctx.Match(k, Invk_usr)) return usr_api;
else if (ctx.Match(k, Invk_special)) return special_api;
else if (ctx.Match(k, Invk_xtns)) return xtns_api;
@@ -77,7 +74,7 @@ public class Xoapi_root implements Gfo_invk {
private static final String
Invk_exec = "exec"
, Invk_app = "app", Invk_addon = "addon"
, Invk_bldr = "bldr", Invk_nav = "nav", Invk_gui = "gui", Invk_html = "html", Invk_net = "net", Invk_usr = "usr", Invk_special = "special", Invk_xtns = "xtns"
, Invk_bldr = "bldr", Invk_nav = "nav", Invk_gui = "gui", Invk_html = "html", Invk_usr = "usr", Invk_special = "special", Invk_xtns = "xtns"
, Invk_test_str = "test_str", Invk_test_str_ = "test_str_"
, Invk_wikis = "wikis"
;

View File

@@ -1,42 +0,0 @@
/*
XOWA: the XOWA Offline Wiki Application
Copyright (C) 2012 gnosygnu@gmail.com
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as
published by the Free Software Foundation, either version 3 of the
License, or (at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Affero General Public License for more details.
You should have received a copy of the GNU Affero General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package gplx.xowa.apps.apis.xowa; import gplx.*; import gplx.xowa.*; import gplx.xowa.apps.*; import gplx.xowa.apps.apis.*;
public class Xoapi_net implements Gfo_invk, Gfo_evt_itm {
public Xoapi_net() {this.ev_mgr = new Gfo_evt_mgr(this);}
public Gfo_evt_mgr Evt_mgr() {return ev_mgr;} private Gfo_evt_mgr ev_mgr;
public void Init_by_kit(Xoae_app app) {
}
public boolean Enabled() {return enabled;} private boolean enabled = true;
public void Enabled_(boolean v) {
this.enabled = v;
gplx.core.ios.IoEngine_system.Web_access_enabled = v;
Gfo_evt_mgr_.Pub_val(this, gplx.xowa.guis.menus.dom.Xog_mnu_evt_mgr.Evt_selected_changed, v);
}
public Object Invk(GfsCtx ctx, int ikey, String k, GfoMsg m) {
if (ctx.Match(k, Invk_enabled)) return this.Enabled();
else if (ctx.Match(k, Invk_enabled_n_)) this.Enabled_(Bool_.N);
else if (ctx.Match(k, Invk_enabled_y_)) this.Enabled_(Bool_.Y);
else if (ctx.Match(k, Invk_enabled_x_)) this.Enabled_(this.Enabled());
else return Gfo_invk_.Rv_unhandled;
return this;
}
private static final String
Invk_enabled = "enabled", Invk_enabled_n_ = "enabled_n_", Invk_enabled_y_ = "enabled_y_", Invk_enabled_x_ = "enabled_x_"
;
public static final String Evt_enabled_changed = "enabled_changed";
}

View File

@@ -21,7 +21,6 @@ public class Xoapi_usr implements Gfo_invk {
public void Ctor_by_app(Xoae_app app) {
bookmarks.Ctor_by_app(app);
history.Ctor_by_app(app);
logs.Ctor_by_app(app);
}
public void Init_by_app(Xoa_app app) {
cache.Init_by_app(app);
@@ -32,14 +31,12 @@ public class Xoapi_usr implements Gfo_invk {
}
public Xoapi_bookmarks Bookmarks() {return bookmarks;} private final Xoapi_bookmarks bookmarks = new Xoapi_bookmarks();
public Xoapi_history History() {return history;} private final Xoapi_history history = new Xoapi_history();
public Xoapi_logs Logs() {return logs;} private final Xoapi_logs logs = new Xoapi_logs();
public Xoapi_cache Cache() {return cache;} private final Xoapi_cache cache = new Xoapi_cache();
public Object Invk(GfsCtx ctx, int ikey, String k, GfoMsg m) {
if (ctx.Match(k, Invk_bookmarks)) return bookmarks;
else if (ctx.Match(k, Invk_history)) return history;
else if (ctx.Match(k, Invk_logs)) return logs;
else if (ctx.Match(k, Invk_cache)) return cache;
else return Gfo_invk_.Rv_unhandled;
}
private static final String Invk_bookmarks = "bookmarks", Invk_history = "history", Invk_logs = "logs", Invk_cache = "cache";
private static final String Invk_bookmarks = "bookmarks", Invk_history = "history", Invk_cache = "cache";
}

View File

@@ -18,14 +18,9 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
package gplx.xowa.apps.apis.xowa.gui.browsers; import gplx.*; import gplx.xowa.*; import gplx.xowa.apps.*; import gplx.xowa.apps.apis.*; import gplx.xowa.apps.apis.xowa.*; import gplx.xowa.apps.apis.xowa.gui.*;
import gplx.gfui.*; import gplx.gfui.controls.gxws.*; import gplx.gfui.controls.standards.*;
import gplx.xowa.wikis.pages.*; import gplx.xowa.guis.*; import gplx.xowa.guis.views.*;
public class Xoapi_html_box implements Gfo_invk, Gfo_evt_mgr_owner {
public class Xoapi_html_box implements Gfo_invk {
private Xog_win_itm win;
public Xoapi_html_box() {
evt_mgr = new Gfo_evt_mgr(this);
}
public Gfo_evt_mgr Evt_mgr() {return evt_mgr;} private Gfo_evt_mgr evt_mgr;
public void Init_by_kit(Xoae_app app) {this.win = app.Gui_mgr().Browser_win();}
public byte Load_tid() {return load_tid;} private byte load_tid;
public void Focus() {
Xog_tab_itm tab = win.Active_tab(); if (tab == Xog_tab_itm_.Null) return;
Gfui_html html_box = tab.Html_itm().Html_box();
@@ -41,14 +36,8 @@ public class Xoapi_html_box implements Gfo_invk, Gfo_evt_mgr_owner {
public Object Invk(GfsCtx ctx, int ikey, String k, GfoMsg m) {
if (ctx.Match(k, Invk_focus)) this.Focus();
else if (ctx.Match(k, Invk_selection_focus_toggle)) this.Selection_focus();
else if (ctx.Match(k, Invk_load_tid)) return Gxw_html_load_tid_.Xto_key(load_tid);
else if (ctx.Match(k, Invk_load_tid_)) {load_tid = Gxw_html_load_tid_.Xto_tid(m.ReadStr("v")); Gfo_evt_mgr_.Pub_val(this, Evt_load_tid_changed, load_tid);}
else if (ctx.Match(k, Invk_load_tid_list)) return Gxw_html_load_tid_.Options__list;
else return Gfo_invk_.Rv_unhandled;
return this;
}
private static final String Invk_focus = "focus", Invk_selection_focus_toggle = "selection_focus_toggle"
, Invk_load_tid = "load_tid", Invk_load_tid_ = "load_tid_", Invk_load_tid_list = "load_tid_list"
;
public static final String Evt_load_tid_changed = "load_tid_changed";
private static final String Invk_focus = "focus", Invk_selection_focus_toggle = "selection_focus_toggle";
}

View File

@@ -21,10 +21,12 @@ import gplx.xowa.users.bmks.*;
import gplx.xowa.wikis.*;
public class Xoapi_bookmarks implements Gfo_invk {
private Xoae_app app; private Xog_win_itm win;
private boolean enabled = true;
public void Ctor_by_app(Xoae_app app) {this.app = app;}
public void Init_by_kit(Xoae_app app) {this.win = app.Gui_mgr().Browser_win();}
public boolean Enabled() {return enabled;} private boolean enabled = true;
public void Enabled_(boolean v) {enabled = v;}
public void Init_by_kit(Xoae_app app) {
this.win = app.Gui_mgr().Browser_win();
app.Cfg().Bind_many_app(this, Cfg__enabled);
}
public boolean Delete_confirm() {return delete_confirm;} private boolean delete_confirm = true;
public void Show() {win.Page__navigate_by_url_bar("home/wiki/Special:XowaBookmarks");}
public String Add(String url_str) {
@@ -43,8 +45,7 @@ public class Xoapi_bookmarks implements Gfo_invk {
return rv;
}
public Object Invk(GfsCtx ctx, int ikey, String k, GfoMsg m) {
if (ctx.Match(k, Invk_enabled)) return Yn.To_str(enabled);
else if (ctx.Match(k, Invk_enabled_)) enabled = m.ReadYn("v");
if (ctx.Match(k, Cfg__enabled)) enabled = m.ReadYn("v");
else if (ctx.Match(k, Invk_delete_confirm)) return Yn.To_str(delete_confirm);
else if (ctx.Match(k, Invk_delete_confirm_)) delete_confirm = m.ReadYn("v");
else if (ctx.Match(k, Invk_add)) return this.Add(m.ReadStrOr("v", null));
@@ -53,7 +54,8 @@ public class Xoapi_bookmarks implements Gfo_invk {
return this;
}
private static final String
Invk_enabled = "enabled", Invk_enabled_ = "enabled_"
, Invk_delete_confirm = "delete_confirm", Invk_delete_confirm_ = "delete_confirm_"
, Invk_add = "add", Invk_show = "show";
Invk_delete_confirm = "delete_confirm", Invk_delete_confirm_ = "delete_confirm_"
, Invk_add = "add", Invk_show = "show"
, Cfg__enabled = "xowa.app.bookmarks.enabled"
;
}

View File

@@ -21,17 +21,13 @@ public class Xoapi_history implements Gfo_invk {
private Xoae_app app; private Xog_win_itm win;
public void Ctor_by_app(Xoae_app app) {this.app = app;}
public void Init_by_kit(Xoae_app app) {this.win = app.Gui_mgr().Browser_win();}
public boolean Enabled() {return enabled;} private boolean enabled = true;
public void Enabled_(boolean v) {enabled = v;}
public void Goto_recent() {win.Page__navigate_by_url_bar(app.Usere().History_mgr().Get_at_last());}
public void Show() {win.Page__navigate_by_url_bar("home/wiki/Special:XowaPageHistory");}
public Object Invk(GfsCtx ctx, int ikey, String k, GfoMsg m) {
if (ctx.Match(k, Invk_enabled)) return Yn.To_str(this.Enabled());
else if (ctx.Match(k, Invk_enabled_)) Enabled_(m.ReadYn("v"));
else if (ctx.Match(k, Invk_goto_recent)) this.Goto_recent();
if (ctx.Match(k, Invk_goto_recent)) this.Goto_recent();
else if (ctx.Match(k, Invk_show)) this.Show();
else return Gfo_invk_.Rv_unhandled;
return this;
}
private static final String Invk_enabled = "enabled", Invk_enabled_ = "enabled_", Invk_goto_recent = "goto_recent", Invk_show = "show";
private static final String Invk_goto_recent = "goto_recent", Invk_show = "show";
}

View File

@@ -1,37 +0,0 @@
/*
XOWA: the XOWA Offline Wiki Application
Copyright (C) 2012 gnosygnu@gmail.com
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as
published by the Free Software Foundation, either version 3 of the
License, or (at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Affero General Public License for more details.
You should have received a copy of the GNU Affero General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package gplx.xowa.apps.apis.xowa.usrs; import gplx.*; import gplx.xowa.*; import gplx.xowa.apps.*; import gplx.xowa.apps.apis.*; import gplx.xowa.apps.apis.xowa.*;
import gplx.xowa.guis.views.*;
public class Xoapi_logs implements Gfo_invk {
private Xoae_app app;
public void Ctor_by_app(Xoae_app app) {this.app = app;}
public void Init_by_kit(Xoae_app app) {}
public boolean Enabled() {return app.Log_wtr().Enabled();}
public void Enabled_(boolean v) {
app.Log_wtr().Enabled_(v);
if (!v)
Io_mgr.Instance.DeleteFil_args(app.Log_wtr().Session_fil()).MissingFails_off().Exec();
}
public Object Invk(GfsCtx ctx, int ikey, String k, GfoMsg m) {
if (ctx.Match(k, Invk_enabled)) return Yn.To_str(this.Enabled());
else if (ctx.Match(k, Invk_enabled_)) Enabled_(m.ReadYn("v"));
else return Gfo_invk_.Rv_unhandled;
return this;
}
private static final String Invk_enabled = "enabled", Invk_enabled_ = "enabled_";
}

View File

@@ -0,0 +1,40 @@
/*
XOWA: the XOWA Offline Wiki Application
Copyright (C) 2012 gnosygnu@gmail.com
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as
published by the Free Software Foundation, either version 3 of the
License, or (at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Affero General Public License for more details.
You should have received a copy of the GNU Affero General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package gplx.xowa.apps.miscs; import gplx.*; import gplx.xowa.*; import gplx.xowa.apps.*;
public class Xoa_misc_mgr implements Gfo_invk {
private Xoa_app app;
public void Init_by_app(Xoa_app app) {
this.app = app;
app.Cfg().Bind_many_app(this, Cfg__web_enabled, Cfg__logs_enabled);
}
public Object Invk(GfsCtx ctx, int ikey, String k, GfoMsg m) {
if (ctx.Match(k, Cfg__web_enabled)) gplx.core.ios.IoEngine_system.Web_access_enabled = m.ReadYn("v");
else if (ctx.Match(k, Cfg__logs_enabled)) {
if (app.Tid_is_edit()) {
Xoae_app appe = (Xoae_app)app;
boolean logs_enabled = m.ReadYn("v");
appe.Log_wtr().Enabled_(logs_enabled);
if (!logs_enabled)
Io_mgr.Instance.DeleteFil_args(appe.Log_wtr().Session_fil()).MissingFails_off().Exec();
}
}
else return Gfo_invk_.Rv_unhandled;
return this;
}
private static final String Cfg__web_enabled = "xowa.app.web.enabled", Cfg__logs_enabled = "xowa.app.logs.enabled";
}

View File

@@ -69,6 +69,7 @@ class Xoa_site_cfg_mgr_fxt {
private final Bry_bfr tmp_bfr = Bry_bfr_.New();
public Xoa_site_cfg_mgr_fxt() {
// Xoa_app_.Usr_dlg_(Xoa_app_.New__usr_dlg__console());
gplx.core.ios.IoEngine_system.Web_access_enabled = true; // HACK: must manually enable web_access else above tests will fail due to some other test disabling singleton; DATE:2016-12-15
Xoa_test_.Inet__init();
this.app = Xoa_app_fxt.Make__app__edit();
this.wiki = Xoa_app_fxt.Make__wiki__edit(app);