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

'v3.6.3.1'

This commit is contained in:
gnosygnu
2016-06-19 23:58:10 -04:00
parent 96636f3161
commit d4e8590345
1960 changed files with 20790 additions and 9272 deletions

View File

@@ -23,10 +23,10 @@ public class Xog_cbk_mgr { // INSTANCE:app
this.wkrs = (Xog_cbk_wkr[])Array_.Resize_add_one(wkrs, wkrs_len, wkr);
++wkrs_len;
}
public void Send_json(String func, Gfobj_nde data) {
public void Send_json(Xog_cbk_trg trg, String func, Gfobj_nde data) {
for (int i = 0; i < wkrs_len; ++i) {
Xog_cbk_wkr wkr = wkrs[i];
wkr.Send_json(func, data);
wkr.Send_json(trg, func, data);
}
}
}

View File

@@ -0,0 +1,27 @@
/*
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.guis.cbks; import gplx.*; import gplx.xowa.*; import gplx.xowa.guis.*;
public class Xog_cbk_trg {
Xog_cbk_trg(byte tid, byte[] page_ttl) {this.tid = tid; this.page_ttl = page_ttl;}
public byte Tid() {return tid;} private final byte tid;
public byte[] Page_ttl() {return page_ttl;} private final byte[] page_ttl; // same as ttl.Full_db(); EX: Special:XowaDownloadCentral
public static final byte Tid__cbk_enabled = 0, Tid__specific_page = 1;
public static final Xog_cbk_trg Any = new Xog_cbk_trg(Tid__cbk_enabled, null);
public static Xog_cbk_trg New(byte[] page_ttl) {return new Xog_cbk_trg(Tid__specific_page, page_ttl);}
}

View File

@@ -18,7 +18,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
package gplx.xowa.guis.cbks; import gplx.*; import gplx.xowa.*; import gplx.xowa.guis.*;
import gplx.core.gfobjs.*;
public interface Xog_cbk_wkr {
Object Send_json(String func, Gfobj_nde data);
Object Send_json(Xog_cbk_trg trg, String func, Gfobj_nde data);
}
class Xog_cbk_wkr_ {
public static final Xog_cbk_wkr[] Ary_empty = new Xog_cbk_wkr[0];

View File

@@ -0,0 +1,22 @@
/*
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.guis.cbks; import gplx.*; import gplx.xowa.*; import gplx.xowa.guis.*;
import gplx.core.gfobjs.*;
public interface Xog_json_wkr {
void Send_json(String func, Gfobj_nde data);
}

View File

@@ -0,0 +1,34 @@
/*
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.guis.cbks.swts; import gplx.*; import gplx.xowa.*; import gplx.xowa.guis.*; import gplx.xowa.guis.cbks.*;
import gplx.core.logs.*; import gplx.core.gfobjs.*; import gplx.xowa.guis.cbks.*;
public class Gfo_log__swt extends Gfo_log__file { private final Xog_cbk_mgr cbk_mgr;
public Gfo_log__swt(Xog_cbk_mgr cbk_mgr, Io_url url, Gfo_log_itm_wtr fmtr) {super(url, fmtr);this.cbk_mgr = cbk_mgr;}
@Override public void Exec(byte type, long time, long elapsed, String msg, Object[] args) {
if (type == Gfo_log_itm.Type__prog) return;
super.Exec(type, time, elapsed, msg, args);
Gfobj_nde nde = Gfobj_nde.New().Add_str("msg", msg);
int args_len = args.length;
for (int i = 0; i < args_len; i += 2) {
String key = Object_.Xto_str_strict_or_null_mark(args[i]);
Object val = i + 1 < args_len ? args[i + 1] : "<<NULL>>";
nde.Add_str(key, Object_.Xto_str_strict_or_null_mark(val));
}
cbk_mgr.Send_json(Xog_cbk_trg.Any, "xo.log.add__recv", nde);
}
}

View File

@@ -17,13 +17,15 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package gplx.xowa.guis.cbks.swts; import gplx.*; import gplx.xowa.*; import gplx.xowa.guis.*; import gplx.xowa.guis.cbks.*;
import gplx.core.gfobjs.*;
public class Gfobj_wtr__json__swt extends Gfobj_wtr__json { private final Bry_bfr bfr;
public Gfobj_wtr__json__swt() {
this.Opt_ws_(Bool_.N);
public class Gfobj_wtr__json__browser extends Gfobj_wtr__json { private final Bry_bfr bfr;
public Gfobj_wtr__json__browser() {
this.Opt_ws_(Bool_.N).Opt_backslash_2x_(Bool_.Y);
this.bfr = this.Bfr();
}
public String Write_as_func(String func_name, Gfobj_grp root) {
bfr.Add(Bry__func_bgn);
public String Write_as_func__swt(String func_name, Gfobj_grp root) {return Write_as_func(Bool_.Y, func_name, root);}
public String Write_as_func__drd(String func_name, Gfobj_grp root) {return Write_as_func(Bool_.N, func_name, root);}
private String Write_as_func(boolean write_return, String func_name, Gfobj_grp root) {
if (write_return) bfr.Add(Bry__func_bgn); // NOTE: Android WebView fails if return is passed; EX: "return 'true'" works on SWT.Browser, but not WebView
bfr.Add_str_u8(func_name);
bfr.Add(Bry__args_bgn);
this.Write(root);

View File

@@ -18,8 +18,8 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
package gplx.xowa.guis.cbks.swts; import gplx.*; import gplx.xowa.*; import gplx.xowa.guis.*; import gplx.xowa.guis.cbks.*;
import org.junit.*; import gplx.core.tests.*;
import gplx.core.gfobjs.*;
public class Gfobj_wtr__json__swt_tst {
private final Gfobj_wtr__json__swt_fxt fxt = new Gfobj_wtr__json__swt_fxt();
public class Gfobj_wtr__json__browser__tst {
private final Gfobj_wtr__json__browser__fxt fxt = new Gfobj_wtr__json__browser__fxt();
@Test public void Json_proc() {
fxt.Test__json_proc
( "proc_name"
@@ -32,10 +32,10 @@ public class Gfobj_wtr__json__swt_tst {
);
}
}
class Gfobj_wtr__json__swt_fxt extends Gfobj_wtr__json_fxt { public Gfobj_wtr__json__swt_fxt Test__json_proc() {return this;}
class Gfobj_wtr__json__browser__fxt extends Gfobj_wtr__json_fxt { public Gfobj_wtr__json__browser__fxt Test__json_proc() {return this;}
public void Test__json_proc(String proc_name, Gfobj_nde root, String expd) {
Gfobj_wtr__json__swt wtr = new Gfobj_wtr__json__swt();
String actl = wtr.Write_as_func(proc_name, root);
Gfobj_wtr__json__browser wtr = new Gfobj_wtr__json__browser();
String actl = wtr.Write_as_func__swt(proc_name, root);
Gftest.Eq__str(expd, actl, "json_write");
}
}

View File

@@ -17,32 +17,48 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package gplx.xowa.guis.cbks.swts; import gplx.*; import gplx.xowa.*; import gplx.xowa.guis.*; import gplx.xowa.guis.cbks.*;
import gplx.core.gfobjs.*;
import gplx.gfui.*; import gplx.xowa.guis.*;
import gplx.gfui.*; import gplx.gfui.kits.core.*; import gplx.xowa.guis.*; import gplx.xowa.guis.views.*;
public class Xog_cbk_wkr__swt implements Xog_cbk_wkr {
private final Xoa_gui_mgr gui_mgr;
private final Xog_browser_func browser_func;
private final Gfobj_wtr__json__swt json_wtr = new Gfobj_wtr__json__swt();
private final Gfobj_wtr__json__browser json_wtr = new Gfobj_wtr__json__browser();
public Xog_cbk_wkr__swt(Xoa_gui_mgr gui_mgr) {
this.gui_mgr = gui_mgr;
this.browser_func = new Xog_browser_func(gui_mgr.Browser_win().Active_tab().Html_box());
this.browser_func = new Xog_browser_func();
}
public Object Send_json(String func, Gfobj_nde data) {
String script = json_wtr.Write_as_func(func, data);
GfuiInvkCmd swt_cmd = gui_mgr.Kit().New_cmd_sync(browser_func.Init(script));
return GfoInvkAble_.Invk(swt_cmd);
public Object Send_json(Xog_cbk_trg trg, String func, Gfobj_nde data) {
if (gui_mgr.Kit().Tid() != Gfui_kit_.Swt_tid) return null; // guard against calling when HTTP_server
String script = json_wtr.Write_as_func__swt(func, data);
GfuiInvkCmd swt_cmd = gui_mgr.Kit().New_cmd_sync(browser_func.Script_(script));
Xog_tab_mgr tab_mgr = gui_mgr.Browser_win().Tab_mgr();
int tabs_len = tab_mgr.Tabs_len();
Object rv = null;
for (int i = 0; i < tabs_len; ++i) {
Xog_tab_itm tab = tab_mgr.Tabs_get_at(i);
Xoa_page page = tab.Page();
boolean match = false;
switch (trg.Tid()) {
case Xog_cbk_trg.Tid__cbk_enabled:
match = page.Html_data().Cbk_enabled();
break;
case Xog_cbk_trg.Tid__specific_page:
match = Bry_.Eq(trg.Page_ttl(), page.Ttl().Full_db());
break;
}
if (match) {
browser_func.Tab_(tab);
rv = Gfo_invk_.Invk_no_key(swt_cmd);
if (rv == null && !String_.Eq(func, "xo.log.add__recv")) throw Err_.new_("gplx.swt", "send_json was not acknowledged", "func", func, "script", script);
}
}
return rv;
}
}
class Xog_browser_func implements GfoInvkAble {
private final Gfui_html html_box;
class Xog_browser_func implements Gfo_invk {
private String script;
public Xog_browser_func(Gfui_html html_box) {
this.html_box = html_box;
}
public Xog_browser_func Init(String script) {
this.script = script;
return this;
}
public Xog_browser_func Script_(String v) {this.script = v; return this;}
public void Tab_(Xog_tab_itm v) {this.tab = v;} private Xog_tab_itm tab;
public Object Invk(GfsCtx ctx, int ikey, String k, GfoMsg m) {
return html_box.Html_js_eval_script(script);
return tab.Html_box().Html_js_eval_script_as_obj(script);
}
}