mirror of
https://github.com/gnosygnu/xowa.git
synced 2026-03-02 03:49:30 +00:00
Cfg: Convert 'App - Startup' (finished)
This commit is contained in:
@@ -17,7 +17,7 @@ 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.*;
|
||||
import gplx.xowa.guis.views.*;
|
||||
import gplx.xowa.apps.apis.xowa.apps.*; import gplx.xowa.apps.apis.xowa.envs.*; import gplx.xowa.apps.apis.xowa.startups.*;
|
||||
import gplx.xowa.apps.apis.xowa.apps.*; import gplx.xowa.apps.apis.xowa.envs.*;
|
||||
public class Xoapi_app implements Gfo_invk {
|
||||
private Xog_win_itm win;
|
||||
public void Ctor_by_app(Xoae_app app) {
|
||||
@@ -29,14 +29,12 @@ public class Xoapi_app implements Gfo_invk {
|
||||
public Xoapi_fsys Fsys() {return fsys;} private Xoapi_fsys fsys = new Xoapi_fsys();
|
||||
public void Exit() {win.App__exit();}
|
||||
public Xoapi_env Env() {return env;} private Xoapi_env env = new Xoapi_env();
|
||||
public Xoapi_startups Startup() {return startup;} private Xoapi_startups startup = new Xoapi_startups();
|
||||
public Object Invk(GfsCtx ctx, int ikey, String k, GfoMsg m) {
|
||||
if (ctx.Match(k, Invk_exit)) this.Exit();
|
||||
else if (ctx.Match(k, Invk_fsys)) return fsys;
|
||||
else if (ctx.Match(k, Invk_startup)) return startup;
|
||||
else if (ctx.Match(k, Invk_env)) return env;
|
||||
else return Gfo_invk_.Rv_unhandled;
|
||||
return this;
|
||||
}
|
||||
private static final String Invk_exit = "exit", Invk_startup = "startup", Invk_env = "env", Invk_fsys = "fsys";
|
||||
private static final String Invk_exit = "exit", Invk_env = "env", Invk_fsys = "fsys";
|
||||
}
|
||||
|
||||
@@ -1,29 +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.startups; 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.startups.tabs.*;
|
||||
public class Xoapi_startups implements Gfo_invk {
|
||||
public void Init_by_kit(Xoae_app app) {
|
||||
}
|
||||
public Xoapi_startup_tabs Tabs() {return tabs;} private Xoapi_startup_tabs tabs = new Xoapi_startup_tabs();
|
||||
public Object Invk(GfsCtx ctx, int ikey, String k, GfoMsg m) {
|
||||
if (ctx.Match(k, Invk_tabs)) return tabs;
|
||||
else return Gfo_invk_.Rv_unhandled;
|
||||
}
|
||||
private static final String Invk_tabs = "tabs";
|
||||
}
|
||||
@@ -1,87 +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.startups.tabs; 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.startups.*;
|
||||
import gplx.xowa.specials.*;
|
||||
public class Xoapi_startup_tabs implements Gfo_invk {
|
||||
public String Custom() {return custom;} private String custom;
|
||||
public boolean Custom_is_expr() {return custom_is_expr;} private boolean custom_is_expr;
|
||||
public String Previous() {return previous;} private String previous;
|
||||
public String Manual() {return manual;} public void Manual_(String v) {manual = v;} private String manual;
|
||||
public byte Type() {return type;} private byte type = Xoapi_startup_tabs_tid_.Tid_previous;
|
||||
public Object Invk(GfsCtx ctx, int ikey, String k, GfoMsg m) {
|
||||
if (ctx.Match(k, Invk_type)) return Xoapi_startup_tabs_tid_.Xto_key(type);
|
||||
else if (ctx.Match(k, Invk_type_)) type = Xoapi_startup_tabs_tid_.Xto_tid(m.ReadStr("v"));
|
||||
else if (ctx.Match(k, Invk_type_list)) return Xoapi_startup_tabs_tid_.Options__list;
|
||||
else if (ctx.Match(k, Invk_previous)) return previous;
|
||||
else if (ctx.Match(k, Invk_previous_)) previous = m.ReadStr("v");
|
||||
else if (ctx.Match(k, Invk_custom)) return custom;
|
||||
else if (ctx.Match(k, Invk_custom_)) custom = m.ReadStr("v");
|
||||
else if (ctx.Match(k, Invk_custom_is_expr)) return Yn.To_str(custom_is_expr);
|
||||
else if (ctx.Match(k, Invk_custom_is_expr_)) custom_is_expr = m.ReadYn("v");
|
||||
else return Gfo_invk_.Rv_unhandled;
|
||||
return this;
|
||||
}
|
||||
private static final String
|
||||
Invk_type = "type", Invk_type_ = "type_", Invk_type_list = "type_list"
|
||||
, Invk_custom = "custom", Invk_custom_ = "custom_"
|
||||
, Invk_previous = "previous", Invk_previous_ = "previous_"
|
||||
, Invk_custom_is_expr = "custom_is_expr", Invk_custom_is_expr_ = "custom_is_expr_"
|
||||
;
|
||||
public String[] Calc_startup_strs(Xoae_app app) {
|
||||
List_adp rv = List_adp_.New();
|
||||
String xowa_home = gplx.xowa.users.Xouc_pages_mgr.Page_xowa;
|
||||
if (manual == null) {
|
||||
switch (type) {
|
||||
case Xoapi_startup_tabs_tid_.Tid_blank: rv.Add(Xow_special_meta_.Itm__default_tab.Ttl_str()); break;
|
||||
case Xoapi_startup_tabs_tid_.Tid_xowa: rv.Add(xowa_home); break;
|
||||
case Xoapi_startup_tabs_tid_.Tid_custom: Add_ary(rv, custom); break;
|
||||
case Xoapi_startup_tabs_tid_.Tid_previous: Add_ary(rv, previous); break;
|
||||
default: throw Err_.new_unhandled(type);
|
||||
}
|
||||
}
|
||||
else
|
||||
rv.Add(manual);
|
||||
Add_xowa_home_if_new_version(rv, app, xowa_home);
|
||||
return rv.To_str_ary();
|
||||
}
|
||||
private static void Add_ary(List_adp list, String s) {
|
||||
if (String_.Len_eq_0(s)) return;
|
||||
String[] ary = String_.SplitLines_nl(String_.Trim(s));
|
||||
int len = ary.length;
|
||||
for (int i = 0; i < len; ++i) {
|
||||
String itm = ary[i];
|
||||
if (String_.Len_eq_0(itm)) continue;
|
||||
list.Add(itm);
|
||||
}
|
||||
}
|
||||
private static void Add_xowa_home_if_new_version(List_adp rv, Xoae_app app, String xowa_home) {
|
||||
if (gplx.xowa.apps.versions.Xoa_version_.Compare(app.Api_root().App().Env().Version_previous(), Xoa_app_.Version) == CompareAble_.Less) {
|
||||
boolean xowa_home_exists = false;
|
||||
int len = rv.Count();
|
||||
for (int i = 0; i < len; ++i) {
|
||||
String itm = (String)rv.Get_at(i);
|
||||
if (String_.Eq(itm, xowa_home)) {
|
||||
xowa_home_exists = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (!xowa_home_exists)
|
||||
rv.Add(xowa_home);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,39 +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.startups.tabs; 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.startups.*;
|
||||
public class Xoapi_startup_tabs_tid_ {
|
||||
public static final byte Tid_blank = 0, Tid_xowa = 1, Tid_previous = 2, Tid_custom = 3;
|
||||
public static final String Key_blank = "blank", Key_xowa = "xowa", Key_previous = "previous", Key_custom = "custom";
|
||||
public static String Xto_key(byte v) {
|
||||
switch (v) {
|
||||
case Tid_blank: return Key_blank;
|
||||
case Tid_xowa: return Key_xowa;
|
||||
case Tid_previous: return Key_previous;
|
||||
case Tid_custom: return Key_custom;
|
||||
default: throw Err_.new_unimplemented();
|
||||
}
|
||||
}
|
||||
public static byte Xto_tid(String s) {
|
||||
if (String_.Eq(s, Key_blank)) return Tid_blank;
|
||||
else if (String_.Eq(s, Key_xowa)) return Tid_xowa;
|
||||
else if (String_.Eq(s, Key_previous)) return Tid_previous;
|
||||
else if (String_.Eq(s, Key_custom)) return Tid_custom;
|
||||
else throw Err_.new_unimplemented();
|
||||
}
|
||||
public static Keyval[] Options__list = Keyval_.Ary(Keyval_.new_(Key_blank), Keyval_.new_(Key_xowa), Keyval_.new_(Key_previous), Keyval_.new_(Key_custom));
|
||||
}
|
||||
@@ -73,7 +73,7 @@ public class Xoa_boot_mgr {
|
||||
try {
|
||||
app.Sys_cfg().Lang_(System_lang());
|
||||
String launch_url = arg_mgr.Gui__home_page();
|
||||
if (launch_url != null) app.Api_root().App().Startup().Tabs().Manual_(launch_url);
|
||||
if (launch_url != null) gplx.xowa.guis.views.Xog_startup_tabs_.Manual = launch_url;
|
||||
app.Tcp_server().Rdr_port_(arg_mgr.Tcp__port_recv()).Wtr_port_(arg_mgr.Tcp__port_send());
|
||||
gplx.xowa.apps.servers.http.Http_server_mgr server_mgr = app.Http_server();
|
||||
server_mgr.Port_(arg_mgr.Http__port());
|
||||
|
||||
@@ -20,7 +20,7 @@ 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);
|
||||
app.Cfg().Bind_many_app(this, Cfg__web_enabled, Cfg__logs_enabled, Cfg__script);
|
||||
}
|
||||
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");
|
||||
@@ -33,8 +33,15 @@ public class Xoa_misc_mgr implements Gfo_invk {
|
||||
Io_mgr.Instance.DeleteFil_args(appe.Log_wtr().Session_fil()).MissingFails_off().Exec();
|
||||
}
|
||||
}
|
||||
else if (ctx.Match(k, Cfg__script)) {
|
||||
String script = m.ReadStr("v");
|
||||
Object rslt = app.Gfs_mgr().Run_str(script);
|
||||
if (rslt == Gfo_invk_.Rv_error) {
|
||||
app.Usr_dlg().Warn_many("", "", "custom script failed: ~{0}", script);
|
||||
}
|
||||
}
|
||||
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";
|
||||
private static final String Cfg__web_enabled = "xowa.app.web.enabled", Cfg__logs_enabled = "xowa.app.logs.enabled", Cfg__script = "xowa.app.startup.script";
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user