1
0
mirror of https://github.com/gnosygnu/xowa.git synced 2026-03-02 03:49:30 +00:00
This commit is contained in:
gnosygnu
2015-02-22 21:03:49 -05:00
parent 3df6db4b7b
commit f495595da4
1119 changed files with 11513 additions and 11734 deletions

View File

@@ -16,6 +16,7 @@ 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.cache; import gplx.*;
import gplx.core.primitives.*;
public class Gfo_cache_mgr_bry extends Gfo_cache_mgr_base {
public Object Get_or_null(byte[] key) {return Base_get_or_null(key);}
public void Add(byte[] key, Object val) {Base_add(key, val);}
@@ -36,3 +37,17 @@ class Gfo_cache_itm_comparer implements gplx.lists.ComparerAble {
}
public static final Gfo_cache_itm_comparer Touched_asc = new Gfo_cache_itm_comparer();
}
class Io_url_exists_mgr {
private gplx.cache.Gfo_cache_mgr_bry cache_mgr = new gplx.cache.Gfo_cache_mgr_bry();
public Io_url_exists_mgr() {
cache_mgr.Compress_max_(Int_.MaxValue);
}
public boolean Has(Io_url url) {
byte[] url_key = url.RawBry();
Object rv_obj = cache_mgr.Get_or_null(url_key);
if (rv_obj != null) return ((Bool_obj_ref)rv_obj).Val(); // cached val exists; use it
boolean exists = Io_mgr._.ExistsFil(url);
cache_mgr.Add(url_key, Bool_obj_ref.new_(exists));
return exists;
}
}

View File

@@ -15,7 +15,7 @@ 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.fsdb; import gplx.*;
package gplx.core.lists; import gplx.*; import gplx.core.*;
public class Binary_search_ {
public static int Search(CompareAble[] ary, int ary_len, CompareAble val) {
if (ary_len == 1) return 0;

View File

@@ -15,7 +15,7 @@ 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.fsdb; import gplx.*;
package gplx.core.lists; import gplx.*; import gplx.core.*;
import org.junit.*; import gplx.core.primitives.*;
public class Binary_search__tst {
private Binary_search__fxt fxt = new Binary_search__fxt();

View File

@@ -15,25 +15,25 @@ 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.fsdb; import gplx.*;
public class Fsdb_cfg_grp {
package gplx.dbs.cfgs; import gplx.*; import gplx.dbs.*;
public class Db_cfg_grp {
private OrderedHash itms = OrderedHash_.new_();
public Fsdb_cfg_grp(String grp) {this.grp = grp;}
public Db_cfg_grp(String grp) {this.grp = grp;}
public String Grp() {return grp;} private String grp;
public void Insert(String key, String val) {
if (itms.Has(key)) throw Err_.new_fmt_("cfg_grp.Insert failed; key={0}", key);
Fsdb_cfg_itm itm = new Fsdb_cfg_itm(grp, key, val);
Fsm_cfg_itm itm = new Fsm_cfg_itm(grp, key, val);
itms.Add(key, itm);
}
public void Update(String key, String val) {
Fsdb_cfg_itm itm = (Fsdb_cfg_itm)itms.Fetch(key);
Fsm_cfg_itm itm = (Fsm_cfg_itm)itms.Fetch(key);
if (itm == null) throw Err_.new_fmt_("cfg_grp.Update failed; key={0}", key);
itm.Val_(val);
}
public void Upsert(String key, String val) {
Fsdb_cfg_itm itm = (Fsdb_cfg_itm)itms.Fetch(key);
Fsm_cfg_itm itm = (Fsm_cfg_itm)itms.Fetch(key);
if (itm == null) {
itm = new Fsdb_cfg_itm(grp, key, val);
itm = new Fsm_cfg_itm(grp, key, val);
itms.Add(key, itm);
}
else
@@ -50,14 +50,14 @@ public class Fsdb_cfg_grp {
return rv == null ? or : Int_.parse_(rv);
}
public String Get_str_or(String key, String or) {
Fsdb_cfg_itm itm = (Fsdb_cfg_itm)itms.Fetch(key);
Fsm_cfg_itm itm = (Fsm_cfg_itm)itms.Fetch(key);
return itm == null ? or : itm.Val();
}
public static final Fsdb_cfg_grp Null = new Fsdb_cfg_grp(); Fsdb_cfg_grp() {}
public static final Db_cfg_grp Null = new Db_cfg_grp(); Db_cfg_grp() {}
}
class Fsdb_cfg_itm {
public Fsdb_cfg_itm(String grp, String key, String val) {this.grp = grp; this.key = key; this.val = val;}
class Fsm_cfg_itm {
public Fsm_cfg_itm(String grp, String key, String val) {this.grp = grp; this.key = key; this.val = val;}
public String Grp() {return grp;} private String grp;
public String Key() {return key;} private String key;
public String Val() {return val;} public Fsdb_cfg_itm Val_(String v) {val = v; return this;} private String val;
public String Val() {return val;} public Fsm_cfg_itm Val_(String v) {val = v; return this;} private String val;
}

View File

@@ -0,0 +1,84 @@
/*
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.dbs.cfgs; import gplx.*; import gplx.dbs.*;
import gplx.dbs.*;
public class Db_cfg_tbl {
private String tbl_name; private final Db_meta_fld_list flds = Db_meta_fld_list.new_();
private String fld_grp, fld_key, fld_val;
private Db_conn conn; private Db_stmt stmt_insert, stmt_update, stmt_select;
public void Conn_(Db_conn new_conn, boolean created, boolean version_is_1, String tbl_v1, String tbl_v2) {
this.conn = new_conn; flds.Clear();
String fld_prefix = "";
if (version_is_1) {
tbl_name = tbl_v1;
fld_prefix = "cfg_";
}
else
tbl_name = tbl_v2;
fld_grp = flds.Add_str(fld_prefix + "grp", 255);
fld_key = flds.Add_str(fld_prefix + "key", 255);
fld_val = flds.Add_str(fld_prefix + "val", 1024);
if (created) {
Db_meta_tbl meta = Db_meta_tbl.new_(tbl_name, flds
, Db_meta_idx.new_unique_by_tbl(tbl_name, "main", fld_grp, fld_key, fld_val)
);
conn.Exec_create_tbl_and_idx(meta);
}
stmt_insert = stmt_update = stmt_select = null;
}
public void Insert(String grp, String key, String val) {
if (stmt_insert == null) stmt_insert = conn.Rls_reg(conn.Stmt_insert(tbl_name, flds));
stmt_insert.Clear().Val_str(fld_grp, grp).Val_str(fld_key, key).Val_str(fld_val, val).Exec_insert();
}
public void Update(String grp, String key, String val) {
if (stmt_update == null) stmt_update = conn.Rls_reg(conn.Stmt_update_exclude(tbl_name, flds, fld_grp, fld_key));
stmt_update.Clear().Val_str(fld_val, val).Crt_str(fld_grp, grp).Crt_str(fld_key, key).Exec_update();
}
public int Select_as_int_or_fail(String grp, String key) {
int rv = Select_as_int_or(grp, key, Int_.MinValue);
if (rv == Int_.MinValue) throw Err_.new_fmt_("dbs.cfg_tbl.Select_as_int_or_fail: tbl={0} grp={1} key={2}", tbl_name, grp, key);
return rv;
}
public int Select_as_int_or(String grp, String key, int or) {return Int_.parse_or_(Select_as_str_or(grp, key, null), or);}
public String Select_as_str_or(String grp, String key, String or) {
if (stmt_select == null) stmt_select = conn.Rls_reg(conn.Stmt_select(tbl_name, String_.Ary(fld_val), fld_grp, fld_key));
Db_rdr rdr = Db_rdr_.Null;
try {
rdr = stmt_select.Clear()
.Crt_str(fld_grp, grp)
.Crt_str(fld_key, key)
.Exec_select_as_rdr();
return rdr.Move_next() ? rdr.Read_str(fld_val) : or;
} finally {rdr.Rls();}
}
public Db_cfg_grp Select_as_grp(String grp) {
Db_cfg_grp rv = null;
Db_stmt stmt = conn.Stmt_select(tbl_name, flds, fld_grp);
Db_rdr rdr = Db_rdr_.Null;
try {
rdr = stmt.Clear().Crt_str(fld_grp, grp).Exec_select_as_rdr();
while (rdr.Move_next()) {
if (rv == null) rv = new Db_cfg_grp(grp);
rv.Upsert(rdr.Read_str(fld_key), rdr.Read_str(fld_val));
}
}
finally {rdr.Rls();}
return rv == null ? Db_cfg_grp.Null : rv;
}
public void Rls() {conn.Conn_term();}
}

View File

@@ -16,6 +16,7 @@ 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.dbs.schemas; import gplx.*; import gplx.dbs.*;
import gplx.dbs.qrys.*;
public class Schema_loader_mgr_ {
public static final Schema_loader_mgr Null = new Schema_loader_mgr__null();
public static final Schema_loader_mgr Sqlite = new Schema_loader_mgr__sqlite();

View File

@@ -16,6 +16,7 @@ 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.dbs.schemas.updates; import gplx.*; import gplx.dbs.*; import gplx.dbs.schemas.*;
import gplx.dbs.engines.sqlite.*;
public class Schema_update_cmd_ {
public static Schema_update_cmd Make_tbl_create(String tbl_name, String tbl_sql, Db_idx_itm... tbl_idxs) {return new Schema_update_cmd__tbl_create(tbl_name, tbl_sql, tbl_idxs);}
}

View File

@@ -1,131 +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.fsdb; import gplx.*;
import gplx.dbs.*; import gplx.ios.*;
public class Fsdb_bin_tbl {
public static void Create_table(Db_conn p) {Sqlite_engine_.Tbl_create(p, Tbl_name, Tbl_sql);}
public static Db_stmt Insert_stmt(Db_conn p) {return Db_stmt_.new_insert_(p, Tbl_name, Fld_bin_owner_id, Fld_bin_owner_tid, Fld_bin_part_id, Fld_bin_data_url, Fld_bin_data);}
public static void Insert_rdr(Db_conn p, int id, byte tid, long bin_len, Io_stream_rdr bin_rdr) {
Db_stmt stmt = Insert_stmt(p);
try {Insert_rdr(stmt, id, tid, bin_len, bin_rdr);}
finally {stmt.Rls();}
}
public static long Insert_rdr(Db_stmt stmt, int id, byte tid, long bin_len, Io_stream_rdr bin_rdr) {
long rv = bin_len;
stmt.Clear()
.Val_int(id)
.Val_byte(tid)
.Val_int(Null_part_id)
.Val_str(Null_data_url)
;
if (Sqlite_engine_.Supports_read_binary_stream)
stmt.Val_rdr_(bin_rdr, bin_len);
else {
byte[] bin_ary = Io_stream_rdr_.Load_all_as_bry(Bry_bfr.new_(), bin_rdr);
stmt.Val_bry(bin_ary);
rv = bin_ary.length;
}
stmt.Exec_insert();
return rv;
}
public static void Delete(Db_conn p, int id) {
Db_stmt stmt = Delete_stmt(p);
try {Delete(stmt, id);}
finally {stmt.Rls();}
}
private static Db_stmt Delete_stmt(Db_conn p) {return Db_stmt_.new_delete_(p, Tbl_name, Fld_bin_owner_id);}
private static void Delete(Db_stmt stmt, int id) {
stmt.Clear()
.Val_int(id)
.Exec_delete();
}
public static Io_stream_rdr Select_as_rdr(Db_conn p, int owner) {
Db_qry qry = Db_qry_.select_().From_(Tbl_name).Cols_(Fld_bin_data).Where_(Db_crt_.eq_(Fld_bin_owner_id, owner));
DataRdr rdr = DataRdr_.Null;
try {
rdr = p.Exec_qry_as_rdr(qry);
if (rdr.MoveNextPeer()) {
if (Sqlite_engine_.Supports_read_binary_stream)
return rdr.ReadRdr(Fld_bin_data);
else
return gplx.ios.Io_stream_rdr_.mem_(Read_bin_data(rdr));
}
else
return gplx.ios.Io_stream_rdr_.Null;
}
finally {rdr.Rls();}
}
public static boolean Select_to_url(Db_conn p, int owner, Io_url url, byte[] bin_bfr, int bin_flush_when) {
Db_qry qry = Db_qry_.select_().From_(Tbl_name).Cols_(Fld_bin_data).Where_(Db_crt_.eq_(Fld_bin_owner_id, owner));
DataRdr rdr = DataRdr_.Null;
try {
rdr = p.Exec_qry_as_rdr(qry);
if (rdr.MoveNextPeer()) {
if (Sqlite_engine_.Supports_read_binary_stream)
return Select_to_fsys__stream(rdr, url, bin_bfr, bin_flush_when);
else {
byte[] bry = Read_bin_data(rdr);
Io_mgr._.SaveFilBry(url, bry);
return true;
}
}
else
return false;
}
finally {rdr.Rls();}
}
public static boolean Select_to_fsys__stream(DataRdr rdr, Io_url url, byte[] bin_bfr, int bin_flush_when) {
Io_stream_rdr db_stream = Io_stream_rdr_.Null;
IoStream fs_stream = IoStream_.Null;
try {
db_stream = rdr.ReadRdr(Fld_bin_data); if (db_stream == Io_stream_rdr_.Null) return false;
fs_stream = Io_mgr._.OpenStreamWrite(url);
int pos = 0, flush_nxt = bin_flush_when;
while (true) {
int read = db_stream.Read(bin_bfr, pos, bin_bfr.length); if (read == Io_stream_rdr_.Read_done) break;
fs_stream.Write(bin_bfr, 0, read);
if (pos > flush_nxt) {
fs_stream.Flush();
flush_nxt += bin_flush_when;
}
}
fs_stream.Flush();
return true;
} finally {
db_stream.Rls();
fs_stream.Rls();
}
}
private static byte[] Read_bin_data(DataRdr rdr) {
byte[] rv = rdr.ReadBry(Fld_bin_data);
return rv == null ? Bry_.Empty : rv; // NOTE: bug in v0.10.1 where .ogg would save as null; return Bry_.Empty instead, else java.io.ByteArrayInputStream would fail on null
}
public static final String Tbl_name = "fsdb_bin", Fld_bin_owner_id = "bin_owner_id", Fld_bin_owner_tid = "bin_owner_tid", Fld_bin_part_id = "bin_part_id", Fld_bin_data_url = "bin_data_url", Fld_bin_data = "bin_data";
private static final String Tbl_sql = String_.Concat_lines_nl
( "CREATE TABLE IF NOT EXISTS fsdb_bin"
, "( bin_owner_id integer NOT NULL PRIMARY KEY"
, ", bin_owner_tid byte NOT NULL"
, ", bin_part_id integer NOT NULL"
, ", bin_data_url varchar(255) NOT NULL"
, ", bin_data mediumblob NOT NULL"
, ");"
);
public static final byte Owner_tid_fil = 1, Owner_tid_thm = 2;
public static final int Null_db_bin_id = -1, Null_size = -1, Null_part_id = -1;
public static final String Null_data_url = "";
}

View File

@@ -1,143 +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.fsdb; import gplx.*;
import gplx.dbs.*;
public interface Fsdb_cfg_tbl extends RlsAble {
Fsdb_cfg_tbl Ctor(Db_conn conn, boolean created);
void Insert(String grp, String key, String val);
void Update(String grp, String key, String val);
int Select_as_int_or(String grp, String key, int or);
int Select_as_int_or_fail(String grp, String key);
String Select_as_str_or(String grp, String key, String or);
Fsdb_cfg_grp Select_as_grp(String grp);
}
abstract class Fsdb_cfg_tbl_base {
public abstract int Select_as_int_or(String grp, String key, int or);
public int Select_as_int_or_fail(String grp, String key) {
int rv = Select_as_int_or(grp, key, Int_.MinValue);
if (rv == Int_.MinValue) throw Err_.new_fmt_("fsdb_cfg did not have itm: grp={0} key={1}", grp, key);
return rv;
}
}
class Fsdb_cfg_tbl_mem extends Fsdb_cfg_tbl_base implements Fsdb_cfg_tbl {
private HashAdp grps = HashAdp_.new_();
public Fsdb_cfg_tbl Ctor(Db_conn conn, boolean created) {return this;}
public void Insert(String grp, String key, String val) {
Fsdb_cfg_grp grp_itm = Grps_get_or_make(grp);
grp_itm.Insert(key, val);
}
public void Update(String grp, String key, String val) {
Fsdb_cfg_grp grp_itm = Grps_get_or_make(grp);
grp_itm.Update(key, val);
}
@Override public int Select_as_int_or(String grp, String key, int or) {
Fsdb_cfg_grp grp_itm = Grps_get_or_null(grp);
return grp_itm == null ? or : grp_itm.Get_int_or(grp, or);
}
public String Select_as_str_or(String grp, String key, String or) {
Fsdb_cfg_grp grp_itm = Grps_get_or_null(grp);
return grp_itm == null ? or : grp_itm.Get_str_or(grp, or);
}
public Fsdb_cfg_grp Select_as_grp(String grp) {return Grps_get_or_null(grp);}
public void Rls() {}
private Fsdb_cfg_grp Grps_get_or_make(String grp) {
Fsdb_cfg_grp rv = (Fsdb_cfg_grp)grps.Fetch(grp);
if (rv == null) {
rv = new Fsdb_cfg_grp(grp);
grps.Add(grp, rv);
}
return rv;
}
public Fsdb_cfg_grp Grps_get_or_null(String grp) {return (Fsdb_cfg_grp)grps.Fetch(grp);}
}
class Fsdb_cfg_tbl_sql extends Fsdb_cfg_tbl_base implements Fsdb_cfg_tbl {
private Db_conn conn;
private Db_stmt stmt_insert, stmt_update, stmt_select;
public Fsdb_cfg_tbl Ctor(Db_conn conn, boolean created) {
this.conn = conn;
if (created) Create_table();
return this;
}
private void Create_table() {
Sqlite_engine_.Tbl_create(conn, Tbl_name, Tbl_sql);
Sqlite_engine_.Idx_create(conn, Idx_main);
}
private Db_stmt Insert_stmt() {return Db_stmt_.new_insert_(conn, Tbl_name, Fld_cfg_grp, Fld_cfg_key, Fld_cfg_val);}
public void Insert(String grp, String key, String val) {
if (stmt_insert == null) stmt_insert = Insert_stmt();
stmt_insert.Clear()
.Val_str(grp)
.Val_str(key)
.Val_str(val)
.Exec_insert();
}
private Db_stmt Update_stmt() {return Db_stmt_.new_update_(conn, Tbl_name, String_.Ary(Fld_cfg_grp, Fld_cfg_key), Fld_cfg_val);}
public void Update(String grp, String key, String val) {
if (stmt_update == null) stmt_update = Update_stmt();
stmt_update.Clear()
.Val_str(val)
.Val_str(grp)
.Val_str(key)
.Exec_update();
}
private Db_stmt Select_stmt() {
Db_qry_select qry = Db_qry_.select_val_(Tbl_name, Fld_cfg_val, gplx.core.criterias.Criteria_.And_many(Db_crt_.eq_(Fld_cfg_grp, ""), Db_crt_.eq_(Fld_cfg_key, "")));
return conn.New_stmt(qry);
}
@Override public int Select_as_int_or(String grp, String key, int or) {return Int_.parse_or_(Select_as_str_or(grp, key, null), or);}
public String Select_as_str_or(String grp, String key, String or) {
if (stmt_select == null) stmt_select = Select_stmt();
Object rv = (String)stmt_select.Clear()
.Val_str(grp)
.Val_str(key)
.Exec_select_val();
return rv == null ? or : (String)rv;
}
public Fsdb_cfg_grp Select_as_grp(String grp) {
Fsdb_cfg_grp rv = null;
Db_qry_select qry = Db_qry_.select_cols_(Tbl_name, gplx.core.criterias.Criteria_.And_many(Db_crt_.eq_(Fld_cfg_grp, "")), Fld_cfg_key, Fld_cfg_val);
DataRdr rdr = DataRdr_.Null;
try {
rdr = conn.New_stmt(qry).Clear().Val_str(grp).Exec_select();
while (rdr.MoveNextPeer()) {
if (rv == null) rv = new Fsdb_cfg_grp(grp);
String key = rdr.ReadStr(Fld_cfg_key);
String val = rdr.ReadStr(Fld_cfg_val);
rv.Upsert(key, val);
}
}
finally {rdr.Rls();}
return rv == null ? Fsdb_cfg_grp.Null : rv;
}
public void Rls() {
if (stmt_insert != null) {stmt_insert.Rls(); stmt_insert = null;}
if (stmt_update != null) {stmt_update.Rls(); stmt_update = null;}
if (stmt_select != null) {stmt_select.Rls(); stmt_select = null;}
}
private static final String Tbl_name = "fsdb_cfg", Fld_cfg_grp = "cfg_grp", Fld_cfg_key = "cfg_key", Fld_cfg_val = "cfg_val";
private static final String Tbl_sql = String_.Concat_lines_nl
( "CREATE TABLE IF NOT EXISTS fsdb_cfg"
, "( cfg_grp varchar(255) NOT NULL"
, ", cfg_key varchar(255) NOT NULL"
, ", cfg_val varchar(1024) NOT NULL"
, ");"
);
private static final Db_idx_itm
Idx_main = Db_idx_itm.sql_("CREATE INDEX IF NOT EXISTS fsdb_cfg__main ON fsdb_cfg (cfg_grp, cfg_key, cfg_val);")
;
}

View File

@@ -1,112 +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.fsdb; import gplx.*;
import gplx.dbs.*; import gplx.dbs.engines.sqlite.*;
public class Fsdb_db_abc_mgr implements RlsAble {
private Db_conn boot_provider;
public int Next_id() {return cfg_mgr.Next_id();}
public Fsdb_mnt_mgr Mnt_mgr() {return mnt_mgr;} private Fsdb_mnt_mgr mnt_mgr;
public Fsdb_db_abc_mgr(Fsdb_mnt_mgr mnt_mgr) {this.mnt_mgr = mnt_mgr;}
public Fsdb_db_atr_mgr Atr_mgr() {return atr_mgr;} private Fsdb_db_atr_mgr atr_mgr;
public Fsdb_db_bin_mgr Bin_mgr() {return bin_mgr;} private Fsdb_db_bin_mgr bin_mgr;
public Fsdb_cfg_mgr Cfg_mgr() {return cfg_mgr;} private Fsdb_cfg_mgr cfg_mgr;
public Fsdb_db_abc_mgr Init(Io_url dir) {
Io_url url = dir.GenSubFil("fsdb.abc.sqlite3");
if (Io_mgr._.ExistsFil(url))
Init_load(dir, url);
else
Init_make(dir, url);
return this;
}
public void Fil_insert(Fsdb_fil_itm rv , byte[] dir, byte[] fil, int ext_id, DateAdp modified, String hash, long bin_len, gplx.ios.Io_stream_rdr bin_rdr) {
int bin_db_id = bin_mgr.Get_id_for_insert(bin_len);
rv.Db_bin_id_(bin_db_id);
int fil_id = atr_mgr.Fil_insert(rv, dir, fil, ext_id, modified, hash, bin_db_id, bin_len, bin_rdr);
bin_len = bin_mgr.Insert(bin_db_id, fil_id, Fsdb_bin_tbl.Owner_tid_fil, bin_len, bin_rdr);
bin_mgr.Increment(bin_len);
}
public void Thm_insert(Fsdb_xtn_thm_itm rv, byte[] dir, byte[] fil, int ext_id, int w, int h, double thumbtime, int page, DateAdp modified, String hash, long bin_len, gplx.ios.Io_stream_rdr bin_rdr) {
int bin_db_id = bin_mgr.Get_id_for_insert(bin_len);
rv.Db_bin_id_(bin_db_id);
int thm_id = atr_mgr.Thm_insert(rv, dir, fil, ext_id, w, h, thumbtime, page, modified, hash, bin_db_id, bin_len, bin_rdr);
bin_len = bin_mgr.Insert(bin_db_id, thm_id, Fsdb_bin_tbl.Owner_tid_thm, bin_len, bin_rdr);
bin_mgr.Increment(bin_len);
}
public void Img_insert(Fsdb_xtn_img_itm rv, byte[] dir, byte[] fil, int ext_id, DateAdp modified, String hash, long bin_len, gplx.ios.Io_stream_rdr bin_rdr, int img_w, int img_h) {
int bin_db_id = bin_mgr.Get_id_for_insert(bin_len);
rv.Db_bin_id_(bin_db_id);
int fil_id = atr_mgr.Img_insert(rv, String_.new_utf8_(dir), String_.new_utf8_(fil), ext_id, img_w, img_h, modified, hash, bin_db_id, bin_len, bin_rdr);
bin_len = bin_mgr.Insert(bin_db_id, fil_id, Fsdb_bin_tbl.Owner_tid_fil, bin_len, bin_rdr);
bin_mgr.Increment(bin_len);
}
public boolean Thm_select_bin(byte[] dir, byte[] fil, Fsdb_xtn_thm_itm thm) {
Fsdb_fil_itm fil_itm = atr_mgr.Fil_select(dir, fil);
return atr_mgr.Thm_select(fil_itm.Id(), thm);
}
public Fsdb_fil_itm Fil_select_bin(byte[] dir, byte[] fil, boolean is_thumb, int width, double thumbtime) {
return atr_mgr.Fil_select(dir, fil);
}
public void Txn_open() {
boot_provider.Txn_mgr().Txn_bgn_if_none();
atr_mgr.Txn_open();
bin_mgr.Txn_open();
}
public void Txn_save() {
atr_mgr.Txn_save(boot_provider);
bin_mgr.Txn_save();
cfg_mgr.Txn_save();
}
public void Rls() {
atr_mgr.Rls();
bin_mgr.Rls();
cfg_mgr.Rls();
boot_provider.Conn_term();
}
private void Init_load(Io_url dir, Io_url boot_url) {
Db_url connect = Db_url__sqlite.load_(boot_url);
boot_provider = Db_conn_.new_and_open_(connect);
atr_mgr = Fsdb_db_atr_mgr.load_(this, boot_provider, dir);
bin_mgr = Fsdb_db_bin_mgr.load_(boot_provider, dir);
cfg_mgr = Fsdb_cfg_mgr.load_(this, boot_provider);
if (!cfg_mgr.Patch_next_id()) Fsdb_db_abc_mgr_.Patch_next_id(this, dir);
}
private void Init_make(Io_url dir, Io_url boot_url) {
Db_url connect = Db_url__sqlite.make_(boot_url);
boot_provider = Db_conn_.new_and_open_(connect);
Sqlite_engine_.Pragma_page_size_4096(boot_provider);
atr_mgr = Fsdb_db_atr_mgr.make_(this, boot_provider, dir);
bin_mgr = Fsdb_db_bin_mgr.make_(boot_provider, dir);
cfg_mgr = Fsdb_cfg_mgr.make_(this, boot_provider);
this.Txn_save(); // immediately save new entries in atr,cfg
}
}
class Fsdb_db_abc_mgr_ {
public static void Patch_next_id(Fsdb_db_abc_mgr abc_mgr, Io_url dir) {
if (!String_.Eq(dir.NameOnly(), "fsdb.user")) return;
Fsdb_db_atr_mgr atr_mgr = abc_mgr.Atr_mgr();
Fsdb_cfg_mgr cfg_mgr = abc_mgr.Cfg_mgr();
int last_id = -1;
if (atr_mgr.Len() > 0) {
Fsdb_db_atr_fil atr_fil = atr_mgr.Get_at(0);
int max_fil_id = Db_conn_.Select_fld0_as_int_or(atr_fil.Conn(), "SELECT Max(fil_id) AS MaxId FROM fsdb_fil;", -1);
int max_thm_id = Db_conn_.Select_fld0_as_int_or(atr_fil.Conn(), "SELECT Max(thm_id) AS MaxId FROM fsdb_xtn_thm;", -1);
last_id = max_fil_id > max_thm_id ? max_fil_id : max_thm_id;
}
cfg_mgr.Patch_next_id_exec(last_id);
}
}

View File

@@ -1,76 +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.fsdb; import gplx.*;
import gplx.dbs.*; import gplx.cache.*;
public class Fsdb_db_atr_mgr implements RlsAble {
private Fsdb_db_atr_fil[] itms; private Fsdb_db_atr_fil itms_0;
public int Len() {return itms.length;}
public Fsdb_db_atr_fil Get_at(int i) {return i == Id_0 ? itms_0 : itms[i];}
public Fsdb_fil_itm Fil_select(byte[] dir, byte[] fil) {return itms_0.Fil_select(dir, fil);}
public boolean Thm_select(int owner_id, Fsdb_xtn_thm_itm thm) {return itms_0.Thm_select(owner_id, thm);}
public int Fil_insert(Fsdb_fil_itm rv , byte[] dir, byte[] fil, int ext_id, DateAdp modified, String hash, int bin_db_id, long bin_len, gplx.ios.Io_stream_rdr bin_rdr) {
return itms_0.Fil_insert(rv, String_.new_utf8_(dir), String_.new_utf8_(fil), ext_id, modified, hash, bin_db_id, bin_len, bin_rdr);
}
public int Img_insert(Fsdb_xtn_img_itm rv, String dir, String fil, int ext_id, int img_w, int img_h, DateAdp modified, String hash, int bin_db_id, long bin_len, gplx.ios.Io_stream_rdr bin_rdr) {
return itms_0.Img_insert(rv, dir, fil, ext_id, img_w, img_h, modified, hash, bin_db_id, bin_len, bin_rdr);
}
public int Thm_insert(Fsdb_xtn_thm_itm rv, byte[] dir, byte[] fil, int ext_id, int width, int height, double thumbtime, int page, DateAdp modified, String hash, int bin_db_id, long bin_len, gplx.ios.Io_stream_rdr bin_rdr) {
return itms_0.Thm_insert(rv, String_.new_utf8_(dir), String_.new_utf8_(fil), ext_id, width, height, thumbtime, page, modified, hash, bin_db_id, bin_len, bin_rdr);
}
public void Txn_open() {
int len = itms.length;
for (int i = 0; i < len; i++) {
Fsdb_db_atr_fil itm = itms[i];
itm.Txn_open();
}
}
public void Txn_save(Db_conn conn) {
Fsdb_db_atr_tbl.Commit_all(conn, itms);
int len = itms.length;
for (int i = 0; i < len; i++) {
Fsdb_db_atr_fil itm = itms[i];
itm.Txn_save();
}
}
public void Rls() {
int len = itms.length;
for (int i = 0; i < len; i++) {
Fsdb_db_atr_fil itm = itms[i];
itm.Rls();
}
}
public static Fsdb_db_atr_mgr load_(Fsdb_db_abc_mgr abc_mgr, Db_conn p, Io_url dir) {
Fsdb_db_atr_mgr rv = new Fsdb_db_atr_mgr();
rv.itms = Fsdb_db_atr_tbl.Select_all(abc_mgr, p, dir);
rv.itms_0 = rv.itms[0];
return rv;
}
public static Fsdb_db_atr_mgr make_(Fsdb_db_abc_mgr abc_mgr, Db_conn p, Io_url dir) {
Fsdb_db_atr_tbl.Create_table(p);
Fsdb_db_atr_mgr rv = new Fsdb_db_atr_mgr();
Fsdb_db_atr_fil itm = Fsdb_db_atr_fil.make_(abc_mgr, Id_0, url_(dir, Id_0), Path_bgn_0);
rv.itms_0 = itm;
rv.itms = new Fsdb_db_atr_fil[] {itm};
return rv;
}
private static Io_url url_(Io_url dir, int id) {
return dir.GenSubFil_ary("fsdb.atr.", Int_.Xto_str_pad_bgn(id, 2), ".sqlite3");
}
public static final int Id_0 = 0;
public static final String Path_bgn_0 = "";
}

View File

@@ -1,81 +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.fsdb; import gplx.*;
import gplx.dbs.*;
public class Fsdb_db_atr_tbl {
public static void Create_table(Db_conn p) {Sqlite_engine_.Tbl_create(p, Tbl_name, Tbl_sql);}
public static Fsdb_db_atr_fil[] Select_all(Fsdb_db_abc_mgr abc_mgr, Db_conn p, Io_url dir) {
ListAdp rv = ListAdp_.new_();
Db_qry qry = Db_qry_select.new_().From_(Tbl_name).Cols_all_().OrderBy_asc_(Fld_uid);
DataRdr rdr = DataRdr_.Null;
try {
rdr = p.Exec_qry_as_rdr(qry);
while (rdr.MoveNextPeer()) {
Fsdb_db_atr_fil itm = Fsdb_db_atr_fil.load_(abc_mgr, rdr, dir);
rv.Add(itm);
}
} finally {rdr.Rls();}
return (Fsdb_db_atr_fil[])rv.Xto_ary(Fsdb_db_atr_fil.class);
}
public static void Commit_all(Db_conn conn, Fsdb_db_atr_fil[] ary) {
stmt_bldr.Init(conn);
try {
int len = ary.length;
for (int i = 0; i < len; i++)
Commit_itm(ary[i]);
stmt_bldr.Commit();
} finally {stmt_bldr.Rls();}
}
private static void Commit_itm(Fsdb_db_atr_fil itm) {
Db_stmt stmt = stmt_bldr.Get(itm.Cmd_mode());
switch (itm.Cmd_mode()) {
case Db_cmd_mode.Create: stmt.Clear().Val_int(itm.Id()) .Val_str(itm.Url().NameAndExt()).Val_str(itm.Path_bgn()).Exec_insert(); break;
case Db_cmd_mode.Update: stmt.Clear() .Val_str(itm.Url().NameAndExt()).Val_str(itm.Path_bgn()).Val_int(itm.Id()).Exec_update(); break;
case Db_cmd_mode.Delete: stmt.Clear().Val_int(itm.Id()).Exec_delete(); break;
case Db_cmd_mode.Ignore: break;
default: throw Err_.unhandled(itm.Cmd_mode());
}
itm.Cmd_mode_(Db_cmd_mode.Ignore);
}
public static final String Tbl_name = "fsdb_db_atr", Fld_uid = "uid", Fld_url = "url", Fld_path_bgn = "path_bgn";
private static final String Tbl_sql = String_.Concat_lines_nl
( "CREATE TABLE IF NOT EXISTS fsdb_db_atr"
, "( uid integer NOT NULL PRIMARY KEY"
, ", url varchar(255) NOT NULL"
, ", path_bgn varchar(255) NOT NULL"
, ");"
);
private static Db_stmt_bldr stmt_bldr = new Db_stmt_bldr(Tbl_name, String_.Ary(Fld_uid), Fld_url, Fld_path_bgn);
}
// class tmptbl {
// private String Tbl_name = "file_url_atr";
// private String Fld_wiki_id
// , Fld_uid, Fld_url, Fld_path_bgn
// ;
// private Db_meta_tbl meta;
// private Db_meta_fld_list Flds = Db_meta_fld_list.new_();
// private void Conn_() {
// Fld_wiki_id = Flds.Add_int("wiki_id");
// Fld_uid = Flds.Add_int("uid");
// Fld_url = Flds.Add_str("url", 255);
// Fld_path_bgn = Flds.Add_str("path_bgn", 255);
// meta = Db_meta_tbl.new_(Tbl_name, Flds
// , Db_meta_idx.new_unique(Tbl_name, "pkey", Fld_wiki_id, Fld_uid)
// );
// }
// }

View File

@@ -1,85 +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.fsdb; import gplx.*;
import gplx.ios.*; import gplx.dbs.*; import gplx.dbs.engines.sqlite.*;
public class Fsdb_db_bin_fil implements RlsAble {
public int Id() {return id;} private int id;
public Io_url Url() {return url;} private Io_url url;
public long Bin_max() {return bin_max;} private long bin_max;
public void Bin_max_(long v) {
bin_max = v;
if (cmd_mode == Db_cmd_mode.Ignore) cmd_mode = Db_cmd_mode.Update;
}
public long Bin_len() {return bin_len;} private long bin_len;
public void Bin_len_(long v) {
bin_len = v;
if (cmd_mode == Db_cmd_mode.Ignore) cmd_mode = Db_cmd_mode.Update;
}
public byte Cmd_mode() {return cmd_mode;} public Fsdb_db_bin_fil Cmd_mode_(byte v) {cmd_mode = v; return this;} private byte cmd_mode;
public Db_conn Conn() {
if (conn == null) {
if (cmd_mode == Db_cmd_mode.Create) {
conn = Db_conn_.new_and_open_(Db_url__sqlite.make_(url));
Sqlite_engine_.Pragma_page_size_4096(conn);
Fsdb_bin_tbl.Create_table(conn);
}
else
conn = Db_conn_.new_and_open_(Db_url__sqlite.load_(url));
}
return conn;
} private Db_conn conn;
public void Rls() {if (conn != null) conn.Conn_term();}
public long Insert(int bin_id, byte owner_tid, long bin_len, gplx.ios.Io_stream_rdr bin_rdr) {
Db_stmt stmt = Db_stmt_.Null;
try {
stmt = Fsdb_bin_tbl.Insert_stmt(this.Conn());
return Fsdb_bin_tbl.Insert_rdr(stmt, bin_id, owner_tid, bin_len, bin_rdr);
}
finally {stmt.Rls();}
}
public boolean Get_to_url(int id, Io_url url, byte[] bin_bfr, int bin_flush_when) {
return Fsdb_bin_tbl.Select_to_url(this.Conn(), id, url, bin_bfr, bin_flush_when);
}
public Io_stream_rdr Get_as_rdr(int id) {
return Fsdb_bin_tbl.Select_as_rdr(this.Conn(), id);
}
public static Fsdb_db_bin_fil load_(DataRdr rdr, Io_url dir) {
return new_
( rdr.ReadInt(Fsdb_db_bin_tbl.Fld_uid)
, dir.GenSubFil(rdr.ReadStr(Fsdb_db_bin_tbl.Fld_url))
, rdr.ReadLong(Fsdb_db_bin_tbl.Fld_bin_len)
, rdr.ReadLong(Fsdb_db_bin_tbl.Fld_bin_max)
, Db_cmd_mode.Ignore
);
}
public static Fsdb_db_bin_fil make_(int id, Io_url url, long bin_len, long bin_max) {
Fsdb_db_bin_fil rv = new_(id, url, bin_len, bin_max, Db_cmd_mode.Create);
rv.Conn(); // force table create
return rv;
}
private static Fsdb_db_bin_fil new_(int id, Io_url url, long bin_len, long bin_max, byte cmd_mode) {
Fsdb_db_bin_fil rv = new Fsdb_db_bin_fil();
rv.id = id;
rv.url = url;
rv.bin_len = bin_len;
rv.bin_max = bin_max;
rv.cmd_mode = cmd_mode;
return rv;
}
public static final Fsdb_db_bin_fil[] Ary_empty = new Fsdb_db_bin_fil[0];
}

View File

@@ -1,99 +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.fsdb; import gplx.*;
import gplx.dbs.*;
public class Fsdb_db_bin_mgr implements RlsAble {
private Io_url dir;
private Fsdb_db_bin_fil[] itms = Fsdb_db_bin_fil.Ary_empty; private int itms_len = 0;
private Fsdb_db_bin_fil itms_n;
private Db_conn conn;
private Fsdb_db_bin_mgr(Io_url dir) {this.dir = dir;}
public int Len() {return itms.length;}
public long Db_bin_max() {return db_bin_max;}
public int Insert_to_bin() {return insert_to_bin;} public Fsdb_db_bin_mgr Insert_to_bin_(int v) {insert_to_bin = v; return this;} private int insert_to_bin = Fsdb_mnt_mgr.Insert_to_bin_null;
public Fsdb_db_bin_mgr Db_bin_max_(long v) {
db_bin_max = v;
for (int i = 0; i < itms_len; i++)
itms[i].Bin_max_(v);
return this;
} private long db_bin_max = Io_mgr.Len_mb * Long_.Xby_int(188);
public Fsdb_db_bin_fil Get_at(int i) {return itms[i];}
private Fsdb_db_bin_fil Get_cur() {return itms_len == 0 ? null : itms[itms_len - 1];}
public void Txn_open() {
Get_cur().Conn().Txn_mgr().Txn_bgn_if_none();
}
public void Txn_save() {
Fsdb_db_bin_tbl.Commit_all(conn, itms);
Get_cur().Conn().Txn_mgr().Txn_end_all();
}
public void Rls() {
int len = itms.length;
for (int i = 0; i < len; i++) {
Fsdb_db_bin_fil itm = itms[i];
itm.Rls();
}
}
public int Get_id_for_insert(long bin_len) {
if (insert_to_bin != Fsdb_mnt_mgr.Insert_to_bin_null) return insert_to_bin; // insert_to_bin specified; return it
if (itms_n.Bin_len() > itms_n.Bin_max())
Itms_add(0);
return itms_n.Id();
}
public void Increment(long bin_len) {
long new_bin_len = itms_n.Bin_len() + bin_len;
itms_n.Bin_len_(new_bin_len);
}
public long Insert(int db_id, int bin_id, byte owner_tid, long bin_len, gplx.ios.Io_stream_rdr bin_rdr) {
Fsdb_db_bin_fil bin_fil = itms[db_id];
return bin_fil.Insert(bin_id, owner_tid, bin_len, bin_rdr);
}
public static Fsdb_db_bin_mgr load_(Db_conn p, Io_url dir) {
Fsdb_db_bin_mgr rv = new Fsdb_db_bin_mgr(dir);
rv.conn = p;
rv.itms = Fsdb_db_bin_tbl.Select_all(p, dir);
rv.itms_len = rv.itms.length;
rv.itms_n = rv.itms[rv.itms_len - 1];
return rv;
}
public static Fsdb_db_bin_mgr make_(Db_conn p, Io_url dir) {
Fsdb_db_bin_tbl.Create_table(p);
Fsdb_db_bin_mgr rv = new Fsdb_db_bin_mgr(dir);
rv.conn = p;
rv.Itms_add(0);
return rv;
}
private void Itms_add(long bin_len) {
Fsdb_db_bin_fil cur = Get_cur();
if (cur != null) {
cur.Conn().Txn_mgr().Txn_end_all();
cur.Conn().Conn_term();
}
int new_itms_len = itms_len + 1;
Fsdb_db_bin_fil[] new_itms = new Fsdb_db_bin_fil[new_itms_len];
for (int i = 0; i < itms_len; i++)
new_itms[i] = itms[i];
itms_n = Fsdb_db_bin_fil.make_(itms_len, url_(dir, itms_len), bin_len, db_bin_max);
itms = new_itms;
itms_len = new_itms_len;
itms[itms_len - 1] = itms_n;
this.Txn_open();
}
private static Io_url url_(Io_url dir, int id) {
return dir.GenSubFil_ary("fsdb.bin.", Int_.Xto_str_pad_bgn(id, 4), ".sqlite3");
}
}

View File

@@ -1,90 +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.fsdb; import gplx.*;
import gplx.dbs.*;
public class Fsdb_db_bin_tbl {
public static void Create_table(Db_conn p) {Sqlite_engine_.Tbl_create(p, Tbl_name, Tbl_sql);}
public static void Commit_all(Db_conn conn, Fsdb_db_bin_fil[] ary) {
stmt_bldr.Init(conn);
try {
int len = ary.length;
for (int i = 0; i < len; i++)
Commit_itm(ary[i]);
stmt_bldr.Commit();
} finally {stmt_bldr.Rls();}
}
private static void Commit_itm(Fsdb_db_bin_fil itm) {
Db_stmt stmt = stmt_bldr.Get(itm.Cmd_mode());
switch (itm.Cmd_mode()) {
case Db_cmd_mode.Create: stmt.Clear().Val_int(itm.Id()) .Val_str(itm.Url().NameAndExt()).Val_long(itm.Bin_len()).Val_long(itm.Bin_max()).Exec_insert(); break;
case Db_cmd_mode.Update: stmt.Clear() .Val_str(itm.Url().NameAndExt()).Val_long(itm.Bin_len()).Val_long(itm.Bin_max()).Val_int(itm.Id()).Exec_update(); break;
case Db_cmd_mode.Delete: stmt.Clear().Val_int(itm.Id()).Exec_delete(); break;
case Db_cmd_mode.Ignore: break;
default: throw Err_.unhandled(itm.Cmd_mode());
}
itm.Cmd_mode_(Db_cmd_mode.Ignore);
}
public static Fsdb_db_bin_fil[] Select_all(Db_conn p, Io_url dir) {
ListAdp rv = ListAdp_.new_();
Db_qry qry = Db_qry_select.new_().From_(Tbl_name).Cols_all_().OrderBy_asc_(Fld_uid);
DataRdr rdr = DataRdr_.Null;
try {
rdr = p.Exec_qry_as_rdr(qry);
while (rdr.MoveNextPeer()) {
Fsdb_db_bin_fil itm = Fsdb_db_bin_fil.load_(rdr, dir);
rv.Add(itm);
}
} finally {rdr.Rls();}
return (Fsdb_db_bin_fil[])rv.Xto_ary(Fsdb_db_bin_fil.class);
}
public static final String Tbl_name = "fsdb_db_bin", Fld_uid = "uid", Fld_url = "url", Fld_bin_len = "bin_len", Fld_bin_max = "bin_max";
private static final String Tbl_sql = String_.Concat_lines_nl
( "CREATE TABLE IF NOT EXISTS fsdb_db_bin"
, "( uid integer NOT NULL PRIMARY KEY"
, ", url varchar(255) NOT NULL"
, ", bin_len bigint NOT NULL"
, ", bin_max bigint NOT NULL"
, ");"
);
// public void Conn_(boolean version_is_1) {
// this.version_is_1 = version_is_1;
// if (version_is_1) {
// where_cols = String_.Ary(Fld_ns_id);
// }
// else {
// where_cols = String_.Ary(Fld_wiki_id, Fld_ns_id);
// Tbl_name = "wiki_ns_regy";
// Fld_wiki_id = Flds.Add_int("wiki_id");
// }
// Fld_ns_id = Flds.Add_int("ns_id");
// Fld_ns_name = Flds.Add_str("ns_name", 255);
// Fld_ns_case = Flds.Add_byte("ns_case");
// Fld_ns_is_alias = Flds.Add_bool("ns_is_alias");
// Fld_ns_count = Flds.Add_int("ns_count");
// }
private static Db_stmt_bldr stmt_bldr = new Db_stmt_bldr(Tbl_name, String_.Ary(Fld_uid), Fld_url, Fld_bin_len, Fld_bin_max);
// private String tbl_name = "file_fsdb_bin";
// private static final Db_meta_fld_list Flds = Db_meta_fld_list.new_();
// private static final String
// Fld_wiki_id = Flds.Add_int("wiki_id")
// , Fld_uid = Flds.Add_int("uid")
// , Fld_url = Flds.Add_str("url", 255)
// , Fld_bin_len = Flds.Add_long("bin_len")
// , Fld_bin_max = Flds.Add_long("bin_max")
// ;
}

View File

@@ -1,36 +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.fsdb; import gplx.*;
public class Fsdb_db_tid_ {
public static final byte Tid_cfg = 0, Tid_atr = 1, Tid_bin = 2;
public static final String Key_cfg = "cfg", Key_atr = "atr", Key_bin = "bin";
public static byte Xto_tid(String s) {
if (String_.Eq(s, Key_cfg)) return Tid_cfg;
else if (String_.Eq(s, Key_atr)) return Tid_atr;
else if (String_.Eq(s, Key_bin)) return Tid_bin;
else throw Err_.unhandled(s);
}
public static String Xto_key(byte v) {
switch (v) {
case Tid_cfg: return Key_cfg;
case Tid_atr: return Key_atr;
case Tid_bin: return Key_bin;
default: throw Err_.unhandled(v);
}
}
}

View File

@@ -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.fsdb; import gplx.*;
import gplx.dbs.*;
public class Fsdb_dir_tbl {
private Db_conn conn;
private Db_stmt stmt_insert, stmt_update, stmt_select_by_name;
public Fsdb_dir_tbl(Db_conn conn, boolean created) {
this.conn = conn;
if (created) Create_table();
}
public void Rls() {
if (stmt_insert != null) {stmt_insert.Rls(); stmt_insert = null;}
if (stmt_update != null) {stmt_update.Rls(); stmt_update = null;}
if (stmt_select_by_name != null) {stmt_select_by_name.Rls(); stmt_select_by_name = null;}
}
public void Create_table() {
Sqlite_engine_.Tbl_create(conn, Tbl_name, Tbl_sql);
Sqlite_engine_.Idx_create(conn, Idx_name);
}
private Db_stmt Insert_stmt() {return Db_stmt_.new_insert_(conn, Tbl_name, Fld_dir_id, Fld_dir_owner_id, Fld_dir_name);}
public void Insert(int id, String name, int owner_id) {
if (stmt_insert == null) stmt_insert = Insert_stmt();
try {
stmt_insert.Clear()
.Val_int(id)
.Val_int(owner_id)
.Val_str(name)
.Exec_insert();
} catch (Exception exc) {stmt_insert = null; throw Err_.err_(exc, "stmt failed");} // must reset stmt, else next call will fail
}
private Db_stmt Update_stmt() {return Db_stmt_.new_update_(conn, Tbl_name, String_.Ary(Fld_dir_id), Fld_dir_owner_id, Fld_dir_name);}
public void Update(int id, String name, int owner_id) {
if (stmt_update == null) stmt_update = Update_stmt();
try {
stmt_update.Clear()
.Val_int(id)
.Val_str(name)
.Val_int(owner_id)
.Exec_update();
} catch (Exception exc) {stmt_update = null; throw Err_.err_(exc, "stmt failed");} // must reset stmt, else next call will fail
}
private Db_stmt Select_itm_stmt() {
Db_qry qry = Db_qry_.select_().From_(Tbl_name).Cols_(Fld_dir_id, Fld_dir_owner_id).Where_(Db_crt_.eq_(Fld_dir_name, Bry_.Empty));
return conn.New_stmt(qry);
}
public Fsdb_dir_itm Select_itm(String dir_name) {
if (stmt_select_by_name == null) stmt_select_by_name = Select_itm_stmt();
DataRdr rdr = DataRdr_.Null;
try {
rdr = stmt_select_by_name.Clear()
.Val_str(dir_name)
.Exec_select();
while (rdr.MoveNextPeer()) {
return new Fsdb_dir_itm(rdr.ReadInt(Fld_dir_id), rdr.ReadInt(Fld_dir_owner_id), dir_name);
}
return Fsdb_dir_itm.Null;
}
finally {rdr.Rls();}
}
public static final String Tbl_name = "fsdb_dir", Fld_dir_id = "dir_id", Fld_dir_owner_id = "dir_owner_id", Fld_dir_name = "dir_name";
private static final String Tbl_sql = String_.Concat_lines_nl
( "CREATE TABLE IF NOT EXISTS fsdb_dir"
, "( dir_id integer NOT NULL PRIMARY KEY"
, ", dir_owner_id integer NOT NULL"
, ", dir_name varchar(255) NOT NULL"
, ");"
);
public static final Db_idx_itm
Idx_name = Db_idx_itm.sql_("CREATE INDEX IF NOT EXISTS fsdb_dir__name ON fsdb_dir (dir_name, dir_owner_id, dir_id);")
;
}

View File

@@ -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.fsdb; import gplx.*;
public class Fsdb_fil_itm {
public int Id() {return id;} public Fsdb_fil_itm Id_(int v) {id = v; return this;} private int id;
public int Owner() {return owner;} public Fsdb_fil_itm Owner_(int v) {owner = v; return this;} private int owner;
public int Ext_id() {return ext_id;} public Fsdb_fil_itm Ext_id_(int v) {ext_id = v; return this;} private int ext_id;
public String Name() {return name;} public Fsdb_fil_itm Name_(String v) {name = v; return this;} private String name;
public int Db_bin_id() {return bin_db_id;} public Fsdb_fil_itm Db_bin_id_(int v) {bin_db_id = v; return this;} private int bin_db_id;
public int Mnt_id() {return mnt_id;} public Fsdb_fil_itm Mnt_id_(int v) {mnt_id = v; return this;} private int mnt_id;
public Fsdb_fil_itm Init(int id, int owner, int ext_id, String name, int bin_db_id) {this.id = id; this.owner = owner; this.ext_id = ext_id; this.name = name; this.bin_db_id = bin_db_id; return this;}
public static final int Null_id = 0;
public static final Fsdb_fil_itm Null = new Fsdb_fil_itm().Init(Null_id, 0, 0, "", Fsdb_bin_tbl.Null_db_bin_id);
}

View File

@@ -1,158 +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.fsdb; import gplx.*;
import gplx.dbs.*;
public class Fsdb_fil_tbl {
private Db_conn conn;
private Db_stmt stmt_insert, stmt_update, stmt_select_by_name, stmt_select_by_id;
public Fsdb_fil_tbl(Db_conn conn, boolean created) {
this.conn = conn;
if (created) Create_table();
}
private void Create_table() {
Sqlite_engine_.Tbl_create(conn, Tbl_name, Tbl_sql);
Sqlite_engine_.Idx_create(conn, Idx_owner);
}
public void Rls() {
if (stmt_insert != null) {stmt_insert.Rls(); stmt_insert = null;}
if (stmt_update != null) {stmt_update.Rls(); stmt_update = null;}
if (stmt_select_by_name != null) {stmt_select_by_name.Rls(); stmt_select_by_name = null;}
if (stmt_select_by_id != null) {stmt_select_by_id.Rls(); stmt_select_by_id = null;}
}
private Db_stmt Insert_stmt() {return Db_stmt_.new_insert_(conn, Tbl_name, Fld_fil_id, Fld_fil_owner_id, Fld_fil_name, Fld_fil_xtn_id, Fld_fil_ext_id, Fld_fil_bin_db_id, Fld_fil_size, Fld_fil_modified, Fld_fil_hash);}
public void Insert(int id, int owner_id, String name, int xtn_id, int ext_id, long size, DateAdp modified, String hash, int bin_db_id) {
if (stmt_insert == null) stmt_insert = Insert_stmt();
try {
stmt_insert.Clear()
.Val_int(id)
.Val_int(owner_id)
.Val_str(name)
.Val_int(xtn_id)
.Val_int(ext_id)
.Val_int(bin_db_id)
.Val_long(size)
.Val_str(Sqlite_engine_.X_date_to_str(modified))
.Val_str(hash)
.Exec_insert();
} catch (Exception exc) {stmt_insert = null; throw Err_.err_(exc, "stmt failed");} // must reset stmt, else next call will fail
}
private Db_stmt Update_stmt() {return Db_stmt_.new_update_(conn, Tbl_name, String_.Ary(Fld_fil_id), Fld_fil_owner_id, Fld_fil_name, Fld_fil_xtn_id, Fld_fil_ext_id, Fld_fil_bin_db_id, Fld_fil_size, Fld_fil_modified, Fld_fil_hash);}
public void Update(int id, int owner_id, String name, int xtn_id, int ext_id, long size, DateAdp modified, String hash, int bin_db_id) {
if (stmt_update == null) stmt_update = Update_stmt();
try {
stmt_update.Clear()
.Val_int(owner_id)
.Val_str(name)
.Val_int(xtn_id)
.Val_int(ext_id)
.Val_int(bin_db_id)
.Val_long(size)
.Val_str(Sqlite_engine_.X_date_to_str(modified))
.Val_str(hash)
.Val_int(id)
.Exec_update();
} catch (Exception exc) {stmt_update = null; throw Err_.err_(exc, "stmt failed");} // must reset stmt, else next call will fail
}
private Db_stmt Select_by_name_stmt() {
Db_qry qry = Sqlite_engine_.Supports_indexed_by
? (Db_qry)Db_qry_sql.rdr_("SELECT * FROM fsdb_fil INDEXED BY fsdb_fil__owner WHERE fil_owner_id = ? AND fil_name = ?;")
: Db_qry_.select_().From_(Tbl_name).Cols_all_().Where_(gplx.core.criterias.Criteria_.And_many(Db_crt_.eq_(Fld_fil_owner_id, Int_.MinValue), Db_crt_.eq_(Fld_fil_name, "")))
;
return conn.New_stmt(qry);
}
public Fsdb_fil_itm Select_itm_by_name(int dir_id, String fil_name) {
if (stmt_select_by_name == null) stmt_select_by_name = Select_by_name_stmt();
DataRdr rdr = DataRdr_.Null;
try {
rdr = stmt_select_by_name.Clear()
.Val_int(dir_id)
.Val_str(fil_name)
.Exec_select();
if (rdr.MoveNextPeer())
return load_(rdr);
else
return Fsdb_fil_itm.Null;
}
finally {rdr.Rls();}
}
private Db_stmt Select_by_id_stmt() {
Db_qry qry = Db_qry_.select_().From_(Tbl_name).Cols_all_().Where_(Db_crt_.eq_(Fld_fil_id, 0));
return conn.New_stmt(qry);
}
public Fsdb_fil_itm Select_itm_by_id(int fil_id) {
if (stmt_select_by_id == null) stmt_select_by_id = Select_by_id_stmt();
DataRdr rdr = DataRdr_.Null;
try {
rdr = stmt_select_by_name.Clear()
.Val_int(fil_id)
.Exec_select();
if (rdr.MoveNextPeer())
return load_(rdr);
else
return Fsdb_fil_itm.Null;
}
finally {rdr.Rls();}
}
private Fsdb_fil_itm load_(DataRdr rdr) {
return new Fsdb_fil_itm().Init(rdr.ReadInt(Fld_fil_id), rdr.ReadInt(Fld_fil_owner_id), rdr.ReadInt(Fld_fil_ext_id), rdr.ReadStr(Fld_fil_name), rdr.ReadInt(Fld_fil_bin_db_id));
}
public static final String Tbl_name = "fsdb_fil", Fld_fil_id = "fil_id", Fld_fil_owner_id = "fil_owner_id", Fld_fil_name = "fil_name", Fld_fil_xtn_id = "fil_xtn_id", Fld_fil_ext_id = "fil_ext_id"
, Fld_fil_size = "fil_size", Fld_fil_modified = "fil_modified", Fld_fil_hash = "fil_hash", Fld_fil_bin_db_id = "fil_bin_db_id"
;
private static final String Tbl_sql = String_.Concat_lines_nl
( "CREATE TABLE IF NOT EXISTS fsdb_fil"
, "( fil_id integer NOT NULL PRIMARY KEY"
, ", fil_owner_id integer NOT NULL"
, ", fil_xtn_id integer NOT NULL"
, ", fil_ext_id integer NOT NULL"
, ", fil_bin_db_id integer NOT NULL" // group ints at beginning of table
, ", fil_name varchar(255) NOT NULL"
, ", fil_size bigint NOT NULL"
, ", fil_modified varchar(14) NOT NULL" // stored as yyyyMMddHHmmss
, ", fil_hash varchar(40) NOT NULL"
, ");"
);
public static final Db_idx_itm
// Idx_name = Db_idx_itm.sql_ ("CREATE INDEX IF NOT EXISTS fsdb_fil__name ON fsdb_fil (fil_name, fil_owner_id, fil_id, fil_ext_id);")
Idx_owner = Db_idx_itm.sql_ ("CREATE INDEX IF NOT EXISTS fsdb_fil__owner ON fsdb_fil (fil_owner_id, fil_name, fil_id);")
;
}
// class tmptbl {
// private String Tbl_name = "file_fsdb_fil";
// private String Fld_wiki_id, Fld_fil_id, Fld_fil_owner_id, Fld_fil_name, Fld_fil_xtn_id, Fld_fil_ext_id
// , Fld_fil_size, Fld_fil_modified, Fld_fil_hash, Fld_fil_bin_db_id
// ;
// private Db_meta_tbl meta;
// private Db_meta_fld_list Flds = Db_meta_fld_list.new_();
// private void Conn_() {
// Fld_wiki_id = Flds.Add_int("wiki_id");
// Fld_fil_id = Flds.Add_int("fil_id");
// Fld_fil_owner_id = Flds.Add_int("fil_owner_id");
// Fld_fil_xtn_id = Flds.Add_int("fil_xtn_id");
// Fld_fil_ext_id = Flds.Add_int("fil_ext_id");
// Fld_fil_bin_db_id = Flds.Add_int("fil_bin_db_id"); // group ints at beginning of table
// Fld_fil_name = Flds.Add_str("fil_name", 255);
// Fld_fil_size = Flds.Add_long("fil_size");
// Fld_fil_modified = Flds.Add_str("fil_modified", 14); // stored as yyyyMMddHHmmss
// Fld_fil_hash = Flds.Add_str("fil_hash", 40);
// meta = Db_meta_tbl.new_(Tbl_name, Flds
// , Db_meta_idx.new_unique(Tbl_name, "pkey", Fld_wiki_id, Fld_fil_id)
// , Db_meta_idx.new_unique(Tbl_name, "fil_owner", Fld_wiki_id, Fld_fil_owner_id, Fld_fil_name, Fld_fil_id)
// );
// }
// }

View File

@@ -1,26 +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.fsdb; import gplx.*;
public class Fsdb_mnt_itm {
public Fsdb_mnt_itm(int id, String name, String url) {this.id = id; this.name = name; this.url = url;}
public int Id() {return id;} public Fsdb_mnt_itm Id_(int v) {id = v; return this;} private int id;
public String Name() {return name;} public Fsdb_mnt_itm Name_(String v) {name = v; return this;} private String name;
public String Url() {return url;} public Fsdb_mnt_itm Url_(String v) {url = v; return this;} private String url;
public static final Fsdb_mnt_itm Null = new Fsdb_mnt_itm(0, "", "");
public static final Fsdb_mnt_itm[] Ary_empty = new Fsdb_mnt_itm[0];
}

View File

@@ -1,121 +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.fsdb; import gplx.*;
import gplx.core.primitives.*;
import gplx.dbs.*; import gplx.xowa.files.fsdb.*;
public class Fsdb_mnt_mgr implements GfoInvkAble {
private Db_conn conn;
private Fsdb_cfg_tbl tbl_cfg;
private Fsdb_db_abc_mgr[] ary; int ary_len = 0;
public Gfo_usr_dlg Usr_dlg() {return usr_dlg;} public Fsdb_mnt_mgr Usr_dlg_(Gfo_usr_dlg v) {usr_dlg = v; return this;} private Gfo_usr_dlg usr_dlg = Gfo_usr_dlg_.Null;
public void Init(Io_url cur_dir) {
Fsdb_mnt_itm[] mnts = Db_load_or_make(cur_dir);
ary_len = mnts.length;
ary = new Fsdb_db_abc_mgr[ary_len];
for (int i = 0; i < ary_len; i++) {
Fsdb_mnt_itm itm = mnts[i];
Io_url abc_url = cur_dir.GenSubFil_nest(itm.Url(), "fsdb.abc.sqlite3");
ary[i] = new Fsdb_db_abc_mgr(this).Init(abc_url.OwnerDir());
}
insert_to_mnt = tbl_cfg.Select_as_int_or_fail("core", "mnt.insert_idx");
}
public int Insert_to_mnt() {return insert_to_mnt;} public Fsdb_mnt_mgr Insert_to_mnt_(int v) {insert_to_mnt = v; return this;} private int insert_to_mnt = Mnt_idx_user;
public int Abc_mgr_len() {return ary == null ? 0 : ary.length;}
public Fsdb_db_abc_mgr Abc_mgr_at(int i) {return ary[i];}
private Fsdb_mnt_itm[] Db_load_or_make(Io_url cur_dir) {
Bool_obj_ref created = Bool_obj_ref.n_();
conn = Sqlite_engine_.Conn_load_or_make_(cur_dir.GenSubFil("wiki.mnt.sqlite3"), created);
tbl_cfg = new Fsdb_cfg_tbl_sql().Ctor(conn, created.Val());
if (created.Val()) {
Fsdb_mnt_tbl.Create_table(conn);
Fsdb_mnt_tbl.Insert(conn, Mnt_idx_main, "fsdb.main", "fsdb.main");
Fsdb_mnt_tbl.Insert(conn, Mnt_idx_user, "fsdb.user", "fsdb.user");
tbl_cfg.Insert("core", "mnt.insert_idx", Int_.Xto_str(Mnt_idx_user));
}
return Fsdb_mnt_tbl.Select_all(conn);
}
public Fsdb_db_bin_fil Bin_db_get(int mnt_id, int bin_db_id) {
return ary[mnt_id].Bin_mgr().Get_at(bin_db_id);
}
public Fsdb_fil_itm Fil_select_bin(byte[] dir, byte[] fil, boolean is_thumb, int width, double thumbtime) {
for (int i = 0; i < ary_len; i++) {
Fsdb_fil_itm rv = ary[i].Fil_select_bin(dir, fil, is_thumb, width, thumbtime);
if (rv != Fsdb_fil_itm.Null && rv.Db_bin_id() != Fsdb_bin_tbl.Null_db_bin_id) { // NOTE: mnt_0 can have thumb, but mnt_1 can have itm; check for itm with Db_bin_id; DATE:2013-11-16
rv.Mnt_id_(i);
return rv;
}
}
return Fsdb_fil_itm.Null;
}
public boolean Thm_select_bin(byte[] dir, byte[] fil, Fsdb_xtn_thm_itm thm) {
for (int i = 0; i < ary_len; i++) {
boolean rv = ary[i].Thm_select_bin(dir, fil, thm);
if (rv) {
thm.Mnt_id_(i);
return rv;
}
}
return false;
}
public void Fil_insert(Fsdb_fil_itm rv , byte[] dir, byte[] fil, int ext_id, DateAdp modified, String hash, long bin_len, gplx.ios.Io_stream_rdr bin_rdr) {
ary[insert_to_mnt].Fil_insert(rv, dir, fil, ext_id, modified, hash, bin_len, bin_rdr);
}
public void Thm_insert(Fsdb_xtn_thm_itm rv, byte[] dir, byte[] fil, int ext_id, int w, int h, double thumbtime, int page, DateAdp modified, String hash, long bin_len, gplx.ios.Io_stream_rdr bin_rdr) {
ary[insert_to_mnt].Thm_insert(rv, dir, fil, ext_id, w, h, thumbtime, page, modified, hash, bin_len, bin_rdr);
}
public void Img_insert(Fsdb_xtn_img_itm rv, byte[] dir, byte[] fil, int ext_id, DateAdp modified, String hash, long bin_len, gplx.ios.Io_stream_rdr bin_rdr, int img_w, int img_h) {
ary[insert_to_mnt].Img_insert(rv, dir, fil, ext_id, modified, hash, bin_len, bin_rdr, img_w, img_h);
}
public void Bin_db_max_(long v) {
for (int i = 0; i < ary_len; i++)
ary[i].Bin_mgr().Db_bin_max_(v);
}
public void Insert_to_bin_(int v) {
for (int i = 0; i < ary_len; i++)
ary[i].Bin_mgr().Insert_to_bin_(v);
}
public void Txn_open() {
for (int i = 0; i < ary_len; i++)
ary[i].Txn_open();
}
public void Txn_save() {
for (int i = 0; i < ary_len; i++)
ary[i].Txn_save();
}
public void Rls() {
for (int i = 0; i < ary_len; i++)
ary[i].Rls();
tbl_cfg.Rls();
}
public Object Invk(GfsCtx ctx, int ikey, String k, GfoMsg m) {
if (ctx.Match(k, Invk_bin_db_max_in_mb_)) this.Bin_db_max_(m.ReadLong("v") * Io_mgr.Len_mb);
else if (ctx.Match(k, Invk_insert_to_mnt_)) insert_to_mnt = m.ReadInt("v");
else if (ctx.Match(k, Invk_insert_to_bin_)) this.Insert_to_bin_(m.ReadInt("v"));
else return GfoInvkAble_.Rv_unhandled;
return this;
} private static final String Invk_bin_db_max_in_mb_ = "bin_db_max_in_mb_", Invk_insert_to_mnt_ = "insert_to_mnt_", Invk_insert_to_bin_ = "insert_to_bin_";
public static final int Mnt_idx_main = 0, Mnt_idx_user = 1, Insert_to_bin_null = -1;
public static void Patch(Fsdb_mnt_mgr mnt_mgr) {
mnt_mgr.Abc_mgr_at(Fsdb_mnt_mgr.Mnt_idx_main).Cfg_mgr()
.Update(Xof_fsdb_mgr_cfg.Grp_xowa, Xof_fsdb_mgr_cfg.Key_gallery_fix_defaults , "y")
.Update(Xof_fsdb_mgr_cfg.Grp_xowa, Xof_fsdb_mgr_cfg.Key_gallery_packed , "y")
.Update(Xof_fsdb_mgr_cfg.Grp_xowa, Xof_fsdb_mgr_cfg.Key_upright_use_thumb_w , "y")
.Update(Xof_fsdb_mgr_cfg.Grp_xowa, Xof_fsdb_mgr_cfg.Key_upright_fix_default , "y")
;
}
}

View File

@@ -1,84 +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.fsdb; import gplx.*;
import gplx.dbs.*;
public class Fsdb_mnt_tbl {
public static void Create_table(Db_conn p) {
Sqlite_engine_.Tbl_create(p, Tbl_name, Tbl_sql);
}
public static void Insert(Db_conn p, int id, String name, String url) {
Db_stmt stmt = Insert_stmt(p);
try {Insert(stmt, id, name, url);}
finally {stmt.Rls();}
}
private static Db_stmt Insert_stmt(Db_conn p) {return Db_stmt_.new_insert_(p, Tbl_name, Fld_mnt_id, Fld_mnt_name, Fld_mnt_url);}
private static void Insert(Db_stmt stmt, int id, String name, String url) {
stmt.Clear()
.Val_int(id)
.Val_str(name)
.Val_str(url)
.Exec_insert();
}
public static Db_stmt Update_stmt(Db_conn p) {return Db_stmt_.new_update_(p, Tbl_name, String_.Ary(Fld_mnt_id), Fld_mnt_name, Fld_mnt_url);}
public static void Update(Db_stmt stmt, int id, String name, String url) {
stmt.Clear()
.Val_str(name)
.Val_str(url)
.Val_int(id)
.Exec_update();
}
public static Fsdb_mnt_itm[] Select_all(Db_conn p) {
Db_qry qry = Db_qry_.select_().From_(Tbl_name);
DataRdr rdr = DataRdr_.Null;
ListAdp list = ListAdp_.new_();
try {
rdr = p.Exec_qry_as_rdr(qry);
while (rdr.MoveNextPeer()) {
Fsdb_mnt_itm itm = new Fsdb_mnt_itm(rdr.ReadInt(Fld_mnt_id), rdr.ReadStr(Fld_mnt_name), rdr.ReadStr(Fld_mnt_url));
list.Add(itm);
}
}
finally {rdr.Rls();}
return (Fsdb_mnt_itm[])list.Xto_ary_and_clear(Fsdb_mnt_itm.class);
}
public static final String Tbl_name = "fsdb_mnt", Fld_mnt_id = "mnt_id", Fld_mnt_name = "mnt_name", Fld_mnt_url = "mnt_url";
private static final String Tbl_sql = String_.Concat_lines_nl
( "CREATE TABLE IF NOT EXISTS fsdb_mnt"
, "( mnt_id integer NOT NULL PRIMARY KEY"
, ", mnt_name varchar(255) NOT NULL"
, ", mnt_url varchar(255) NOT NULL"
, ");"
);
}
// class tmptbl {
// private String Tbl_name = "file_url_mnt";
// private String Fld_wiki_id
// , Fld_id, Fld_name, Fld_url
// ;
// private Db_meta_tbl meta;
// private Db_meta_fld_list Flds = Db_meta_fld_list.new_();
// private void Conn_() {
// Fld_wiki_id = Flds.Add_int("wiki_id");
// Fld_id = Flds.Add_int("id");
// Fld_name = Flds.Add_str("name", 255);
// Fld_url = Flds.Add_str("url", 255);
// meta = Db_meta_tbl.new_(Tbl_name, Flds
// , Db_meta_idx.new_unique(Tbl_name, "pkey", Fld_wiki_id, Fld_id)
// );
// }
// }

View File

@@ -1,56 +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.fsdb; import gplx.*;
public class Fsdb_xtn_thm_itm {
protected Fsdb_xtn_thm_itm() {}
public int Id() {return id;} public Fsdb_xtn_thm_itm Id_(int v) {id = v; return this;} private int id;
public Fsdb_fil_itm Owner() {return owner;} public Fsdb_xtn_thm_itm Owner_(Fsdb_fil_itm v) {owner = v; return this;} private Fsdb_fil_itm owner = Fsdb_fil_itm.Null;
public int Owner_id() {return owner_id;} public Fsdb_xtn_thm_itm Owner_id_(int v) {owner_id = v; return this;} private int owner_id;
public int Width() {return width;} public Fsdb_xtn_thm_itm Width_(int v) {width = v; return this;} private int width;
public double Thumbtime() {return thumbtime;} public Fsdb_xtn_thm_itm Thumbtime_(double v) {thumbtime = v; return this;} private double thumbtime;
public int Page() {return page;} public Fsdb_xtn_thm_itm Page_(int v) {page = v; return this;} private int page;
public int Height() {return height;} public Fsdb_xtn_thm_itm Height_(int v) {height = v; return this;} private int height;
public long Size() {return size;} public Fsdb_xtn_thm_itm Size_(long v) {size = v; return this;} private long size;
public String Modified() {return modified;} public Fsdb_xtn_thm_itm Modified_(String v) {modified = v; return this;} private String modified;
public String Hash() {return hash;} public Fsdb_xtn_thm_itm Hash_(String v) {hash = v; return this;} private String hash;
public int Dir_id() {return dir_id;} public Fsdb_xtn_thm_itm Dir_id_(int v) {dir_id = v; return this;} private int dir_id;
public int Db_bin_id() {return bin_db_id;} public Fsdb_xtn_thm_itm Db_bin_id_(int v) {bin_db_id = v; return this;} private int bin_db_id;
public int Mnt_id() {return mnt_id;} public Fsdb_xtn_thm_itm Mnt_id_(int v) {mnt_id = v; return this;} private int mnt_id;
public void Init_by_load(DataRdr rdr, boolean schema_thm_page) {
this.id = rdr.ReadInt(Fsdb_xtn_thm_tbl.Fld_thm_id);
this.owner_id = rdr.ReadInt(Fsdb_xtn_thm_tbl.Fld_thm_owner_id);
this.width = rdr.ReadInt(Fsdb_xtn_thm_tbl.Fld_thm_w);
this.height = rdr.ReadInt(Fsdb_xtn_thm_tbl.Fld_thm_h);
this.size = rdr.ReadLong(Fsdb_xtn_thm_tbl.Fld_thm_size);
this.modified = rdr.ReadStr(Fsdb_xtn_thm_tbl.Fld_thm_modified);
this.hash = rdr.ReadStr(Fsdb_xtn_thm_tbl.Fld_thm_hash);
this.bin_db_id = rdr.ReadInt(Fsdb_xtn_thm_tbl.Fld_thm_bin_db_id);
if (schema_thm_page) {
this.thumbtime = gplx.xowa.files.Xof_doc_thumb.Db_load_double(rdr, Fsdb_xtn_thm_tbl.Fld_thm_time);
this.page = gplx.xowa.files.Xof_doc_page.Db_load_int(rdr, Fsdb_xtn_thm_tbl.Fld_thm_page);
}
else {
this.thumbtime = gplx.xowa.files.Xof_doc_thumb.Db_load_int(rdr, Fsdb_xtn_thm_tbl.Fld_thm_thumbtime);
this.page = gplx.xowa.files.Xof_doc_page.Null;
}
}
public static Fsdb_xtn_thm_itm new_() {return new Fsdb_xtn_thm_itm();} // NOTE: Owner is null by default
public static Fsdb_xtn_thm_itm load_() {return new Fsdb_xtn_thm_itm().Owner_(new Fsdb_fil_itm());} // NOTE: Owner is new'd b/c load will use owner.Ext_id
public static final Fsdb_xtn_thm_itm Null = new Fsdb_xtn_thm_itm();
public static final Fsdb_xtn_thm_itm[] Ary_empty = new Fsdb_xtn_thm_itm[0];
}

View File

@@ -1,155 +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.fsdb; import gplx.*;
import gplx.dbs.*;
public class Fsdb_xtn_thm_tbl {
private Fsdb_db_atr_fil atr_fil; private Db_conn conn;
private Db_stmt stmt_insert, stmt_select_by_fil_w;
public Fsdb_xtn_thm_tbl(Fsdb_db_atr_fil atr_fil, Db_conn conn, boolean created) {
this.atr_fil = atr_fil; this.conn = conn;
if (created) Create_table();
}
private void Create_table() {
Sqlite_engine_.Tbl_create(conn, Tbl_name, Tbl_sql);
Sqlite_engine_.Idx_create(conn, Idx_name);
}
public void Rls() {
if (stmt_insert != null) {stmt_insert.Rls(); stmt_insert = null;}
if (stmt_select_by_fil_w != null) {stmt_select_by_fil_w.Rls(); stmt_select_by_fil_w = null;}
}
private boolean Schema_thm_page() {
if (schema_thm_page_init) {
schema_thm_page = atr_fil.Abc_mgr().Cfg_mgr().Schema_thm_page();
schema_thm_page_init = false;
}
return schema_thm_page;
} private boolean schema_thm_page, schema_thm_page_init = true;
private Db_stmt Make_stmt_insert() {
return this.Schema_thm_page()
? Db_stmt_.new_insert_(conn, Tbl_name, Fld_thm_id, Fld_thm_owner_id, Fld_thm_w, Fld_thm_h, Fld_thm_bin_db_id, Fld_thm_size, Fld_thm_modified, Fld_thm_hash, Fld_thm_time, Fld_thm_page)
: Db_stmt_.new_insert_(conn, Tbl_name, Fld_thm_id, Fld_thm_owner_id, Fld_thm_w, Fld_thm_h, Fld_thm_bin_db_id, Fld_thm_size, Fld_thm_modified, Fld_thm_hash, Fld_thm_thumbtime)
;
}
public void Insert(int id, int thm_owner_id, int width, int height, double thumbtime, int page, int bin_db_id, long size, DateAdp modified, String hash) {
if (stmt_insert == null) stmt_insert = Make_stmt_insert();
try {
stmt_insert.Clear()
.Val_int(id)
.Val_int(thm_owner_id)
.Val_int(width)
.Val_int(height)
.Val_int(bin_db_id)
.Val_long(size)
.Val_str(Sqlite_engine_.X_date_to_str(modified))
.Val_str(hash);
if (this.Schema_thm_page()) {
stmt_insert.Val_double (gplx.xowa.files.Xof_doc_thumb.Db_save_double(thumbtime));
stmt_insert.Val_int (gplx.xowa.files.Xof_doc_page.Db_save_int(page));
}
else
stmt_insert.Val_int(gplx.xowa.files.Xof_doc_thumb.Db_save_int(thumbtime));
stmt_insert.Exec_insert();
} catch (Exception exc) {stmt_insert = null; throw Err_.err_(exc, "stmt failed");} // must reset stmt, else next call will fail
}
private Db_stmt Select_by_fil_w_stmt() {
Db_qry_select qry = Db_qry_.select_().From_(Tbl_name).Cols_all_();
gplx.core.criterias.Criteria crt
= this.Schema_thm_page()
? gplx.core.criterias.Criteria_.And_many(Db_crt_.eq_(Fld_thm_owner_id, Int_.MinValue), Db_crt_.eq_(Fld_thm_w, Int_.MinValue), Db_crt_.eq_(Fld_thm_time, Int_.MinValue), Db_crt_.eq_(Fld_thm_page, Int_.MinValue))
: gplx.core.criterias.Criteria_.And_many(Db_crt_.eq_(Fld_thm_owner_id, Int_.MinValue), Db_crt_.eq_(Fld_thm_w, Int_.MinValue), Db_crt_.eq_(Fld_thm_thumbtime, Int_.MinValue))
;
qry.Where_(crt);
return conn.New_stmt(qry);
}
public boolean Select_itm_by_fil_width(int owner_id, Fsdb_xtn_thm_itm thm) {
if (stmt_select_by_fil_w == null) stmt_select_by_fil_w = Select_by_fil_w_stmt();
DataRdr rdr = DataRdr_.Null;
try {
stmt_select_by_fil_w.Clear()
.Val_int(owner_id)
.Val_int(thm.Width())
;
if (this.Schema_thm_page()) {
stmt_select_by_fil_w.Val_double(gplx.xowa.files.Xof_doc_thumb.Db_save_double(thm.Thumbtime()));
stmt_select_by_fil_w.Val_int(gplx.xowa.files.Xof_doc_page.Db_save_int(thm.Page()));
}
else {
stmt_select_by_fil_w.Val_int(gplx.xowa.files.Xof_doc_thumb.Db_save_int(thm.Thumbtime()));
}
rdr = stmt_select_by_fil_w.Exec_select();
if (rdr.MoveNextPeer()) {
thm.Init_by_load(rdr, this.Schema_thm_page());
return true;
}
else
return false;
}
finally {rdr.Rls();}
}
public static final String Tbl_name = "fsdb_xtn_thm"
, Fld_thm_id = "thm_id", Fld_thm_owner_id = "thm_owner_id", Fld_thm_w = "thm_w", Fld_thm_h = "thm_h"
, Fld_thm_thumbtime = "thm_thumbtime", Fld_thm_time = "thm_time", Fld_thm_page = "thm_page"
, Fld_thm_bin_db_id = "thm_bin_db_id", Fld_thm_size = "thm_size", Fld_thm_modified = "thm_modified", Fld_thm_hash = "thm_hash";
private static final String Tbl_sql = String_.Concat_lines_nl
( "CREATE TABLE IF NOT EXISTS fsdb_xtn_thm"
, "( thm_id integer NOT NULL PRIMARY KEY"
, ", thm_owner_id integer NOT NULL"
, ", thm_w integer NOT NULL"
, ", thm_h integer NOT NULL"
//, ", thm_thumbtime integer NOT NULL" // removed; DATE:2014-01-23
, ", thm_time double NOT NULL" // replacement for thm_time
, ", thm_page integer NOT NULL"
, ", thm_bin_db_id integer NOT NULL"
, ", thm_size bigint NOT NULL"
, ", thm_modified varchar(14) NOT NULL" // stored as yyyyMMddHHmmss
, ", thm_hash varchar(40) NOT NULL"
, ");"
);
public static final Db_idx_itm
Idx_name = Db_idx_itm.sql_("CREATE INDEX IF NOT EXISTS fsdb_xtn_thm__owner ON fsdb_xtn_thm (thm_owner_id, thm_id, thm_w, thm_time, thm_page);")
;
public static final DateAdp Modified_null = null;
public static final String Hash_null = "";
}
// class tmptbl {
// private String Tbl_name = "file_data_thm";
// private String Fld_wiki_id
// , Fld_id, Fld_owner_id, Fld_w, Fld_h
// , Fld_time, Fld_page
// , Fld_bin_db_id, Fld_size, Fld_modified, Fld_hash
// ;
// private Db_meta_tbl meta;
// private Db_meta_fld_list Flds = Db_meta_fld_list.new_();
// private void Conn_() {
// Fld_wiki_id = Flds.Add_int("wiki_id");
// Fld_id = Flds.Add_int("id");
// Fld_owner_id = Flds.Add_int("owner_id");
// Fld_w = Flds.Add_int("w");
// Fld_h = Flds.Add_int("h");
// Fld_time = Flds.Add_double("time");
// Fld_page = Flds.Add_int("page");
// Fld_bin_db_id = Flds.Add_int("bin_db_id");
// Fld_size = Flds.Add_long("size");
// Fld_modified = Flds.Add_str("modified", 14); // stored as yyyyMMddHHmmss
// Fld_hash = Flds.Add_str("hash", 40);
// meta = Db_meta_tbl.new_(Tbl_name, Flds
// , Db_meta_idx.new_unique(Tbl_name, "pkey", Fld_wiki_id, Fld_id)
// , Db_meta_idx.new_unique(Tbl_name, "owner", Fld_wiki_id, Fld_owner_id, Fld_id, Fld_w, Fld_time, Fld_page)
// );
// }
// }

View File

@@ -0,0 +1,93 @@
/*
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.fsdb.data; import gplx.*; import gplx.fsdb.*;
import gplx.dbs.*; import gplx.ios.*;
import gplx.dbs.engines.sqlite.*;
public class Fsd_bin_tbl {
private String tbl_name = "file_data_bin"; private final Db_meta_fld_list flds = Db_meta_fld_list.new_();
private String fld_owner_id, fld_owner_tid, fld_part_id, fld_data_url, fld_data;
private Db_conn conn;
private Bry_bfr tmp_bfr = Bry_bfr.reset_(Io_mgr.Len_kb);
public void Conn_(Db_conn new_conn, boolean created, boolean version_is_1) {
this.conn = new_conn; flds.Clear();
String fld_prefix = "";
if (version_is_1) {
tbl_name = "fsdb_bin";
fld_prefix = "bin_";
}
fld_owner_id = flds.Add_int(fld_prefix + "owner_id");
fld_owner_tid = flds.Add_byte(fld_prefix + "owner_tid");
fld_part_id = flds.Add_int(fld_prefix + "part_id");
fld_data_url = flds.Add_str(fld_prefix + "data_url", 255);
fld_data = flds.Add_bry(fld_prefix + "data"); // mediumblob
if (created) {
Db_meta_tbl meta = Db_meta_tbl.new_(tbl_name, flds
, Db_meta_idx.new_unique_by_tbl(tbl_name, "pkey", fld_owner_id)
);
conn.Exec_create_tbl_and_idx(meta);
}
}
public long Insert_rdr(int id, byte tid, long bin_len, Io_stream_rdr bin_rdr) {
synchronized (tmp_bfr) {
Db_stmt stmt = conn.Stmt_insert(tbl_name, flds);
byte[] bin_ary = Io_stream_rdr_.Load_all_as_bry(tmp_bfr, bin_rdr);
long rv = bin_ary.length;
stmt.Clear()
.Val_int(fld_owner_id, id)
.Val_byte(fld_owner_tid, tid)
.Val_int(fld_part_id, Null_part_id)
.Val_str(fld_data_url, Null_data_url)
.Val_bry(bin_ary)
.Exec_insert();
return rv;
}
}
public Io_stream_rdr Select_as_rdr(Db_conn conn, int owner_id) {
Db_rdr rdr = Db_rdr_.Null;
try {
Db_stmt stmt = conn.Stmt_select(tbl_name, String_.Ary(fld_data), fld_owner_id);
rdr = stmt.Clear().Crt_int(fld_owner_id, owner_id).Exec_select_as_rdr();
return rdr.Move_next()
? Io_stream_rdr_.mem_(Read_bin_data(rdr))
: Io_stream_rdr_.Null;
}
finally {rdr.Rls();}
}
public boolean Select_to_url(int owner_id, Io_url url) {
Db_rdr rdr = Db_rdr_.Null;
try {
Db_stmt stmt = conn.Stmt_select(tbl_name, String_.Ary(fld_data), fld_owner_id);
rdr = stmt.Clear().Crt_int(fld_owner_id, owner_id).Exec_select_as_rdr();
if (rdr.Move_next()) {
byte[] bry = Read_bin_data(rdr);
Io_mgr._.SaveFilBry(url, bry);
return true;
}
else
return false;
}
finally {rdr.Rls();}
}
private byte[] Read_bin_data(Db_rdr rdr) {
byte[] rv = rdr.Read_bry(fld_data);
return rv == null ? Bry_.Empty : rv; // NOTE: bug in v0.10.1 where .ogg would save as null; return Bry_.Empty instead, else java.io.ByteArrayInputStream would fail on null
}
public static final byte Owner_tid_fil = 1, Owner_tid_thm = 2;
public static final int Null_db_bin_id = -1, Null_size = -1, Null_part_id = -1;
public static final String Null_data_url = "";
}

View File

@@ -15,11 +15,11 @@ 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.fsdb; import gplx.*;
public class Fsdb_dir_itm {
public Fsdb_dir_itm(int id, int owner, String name) {this.id = id; this.owner = owner; this.name = name;}
public int Id() {return id;} public Fsdb_dir_itm Id_(int v) {id = v; return this;} private int id;
public int Owner() {return owner;} public Fsdb_dir_itm Owner_(int v) {owner = v; return this;} private int owner;
public String Name() {return name;} public Fsdb_dir_itm Name_(String v) {name = v; return this;} private String name;
public static final Fsdb_dir_itm Null = new Fsdb_dir_itm(0, 0, "");
package gplx.fsdb.data; import gplx.*; import gplx.fsdb.*;
public class Fsd_dir_itm {
public Fsd_dir_itm(int id, int owner, String name) {this.id = id; this.owner = owner; this.name = name;}
public int Id() {return id;} public Fsd_dir_itm Id_(int v) {id = v; return this;} private int id;
public int Owner() {return owner;} public Fsd_dir_itm Owner_(int v) {owner = v; return this;} private int owner;
public String Name() {return name;} public Fsd_dir_itm Name_(String v) {name = v; return this;} private String name;
public static final Fsd_dir_itm Null = new Fsd_dir_itm(0, 0, "");
}

View File

@@ -0,0 +1,71 @@
/*
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.fsdb.data; import gplx.*; import gplx.fsdb.*;
import gplx.dbs.*;
public class Fsd_dir_tbl {
private String tbl_name = "file_data_dir"; private final Db_meta_fld_list flds = Db_meta_fld_list.new_();
private String fld_id, fld_owner_id, fld_name;
private Db_conn conn; private Db_stmt stmt_insert, stmt_update, stmt_select_by_name;
public void Conn_(Db_conn new_conn, boolean created, boolean version_is_1) {
this.conn = new_conn; flds.Clear();
String fld_prefix = "";
if (version_is_1) {
tbl_name = "fsdb_dir";
fld_prefix = "dir_";
}
fld_id = flds.Add_int(fld_prefix + "id");
fld_owner_id = flds.Add_int(fld_prefix + "owner_id");
fld_name = flds.Add_str(fld_prefix + "name", 255);
if (created) {
Db_meta_tbl meta = Db_meta_tbl.new_(tbl_name, flds
, Db_meta_idx.new_unique_by_tbl(tbl_name, "pkey", fld_id)
, Db_meta_idx.new_normal_by_tbl(tbl_name, "name", fld_name, fld_owner_id, fld_id)
);
conn.Exec_create_tbl_and_idx(meta);
}
stmt_insert = stmt_update = stmt_select_by_name = null;
}
public void Insert(int id, String name, int owner_id) {
if (stmt_insert == null) stmt_insert = conn.Rls_reg(conn.Stmt_insert(tbl_name, flds));
stmt_insert.Clear()
.Val_int(fld_id, id)
.Val_int(fld_owner_id, owner_id)
.Val_str(fld_name, name)
.Exec_insert();
}
public void Update(int id, String name, int owner_id) {
if (stmt_update == null) stmt_update = conn.Rls_reg(conn.Stmt_update_exclude(tbl_name, flds, fld_id));
stmt_update.Clear()
.Val_int(fld_owner_id, owner_id)
.Val_str(fld_name, name)
.Crt_int(fld_id, id)
.Exec_update();
}
public Fsd_dir_itm Select_itm(String name) {
if (stmt_select_by_name == null) stmt_select_by_name = conn.Rls_reg(conn.Stmt_select(tbl_name, flds, fld_name));
Db_rdr rdr = Db_rdr_.Null;
try {
rdr = stmt_select_by_name.Clear().Crt_str(fld_name, name).Exec_select_as_rdr();
return rdr.Move_next()
? new Fsd_dir_itm(rdr.Read_int(fld_id), rdr.Read_int(fld_owner_id), name)
: Fsd_dir_itm.Null
;
}
finally {rdr.Rls();}
}
}

View File

@@ -0,0 +1,29 @@
/*
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.fsdb.data; import gplx.*; import gplx.fsdb.*;
public class Fsd_fil_itm {
public int Id() {return id;} public Fsd_fil_itm Id_(int v) {id = v; return this;} private int id;
public int Owner() {return owner;} public Fsd_fil_itm Owner_(int v) {owner = v; return this;} private int owner;
public int Ext_id() {return ext_id;} public Fsd_fil_itm Ext_id_(int v) {ext_id = v; return this;} private int ext_id;
public String Name() {return name;} public Fsd_fil_itm Name_(String v) {name = v; return this;} private String name;
public int Db_bin_id() {return bin_db_id;} public Fsd_fil_itm Db_bin_id_(int v) {bin_db_id = v; return this;} private int bin_db_id;
public int Mnt_id() {return mnt_id;} public Fsd_fil_itm Mnt_id_(int v) {mnt_id = v; return this;} private int mnt_id;
public Fsd_fil_itm Init(int id, int owner, int ext_id, String name, int bin_db_id) {this.id = id; this.owner = owner; this.ext_id = ext_id; this.name = name; this.bin_db_id = bin_db_id; return this;}
public static final int Null_id = 0;
public static final Fsd_fil_itm Null = new Fsd_fil_itm().Init(Null_id, 0, 0, "", Fsd_bin_tbl.Null_db_bin_id);
}

View File

@@ -0,0 +1,96 @@
/*
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.fsdb.data; import gplx.*; import gplx.fsdb.*;
import gplx.dbs.*; import gplx.dbs.qrys.*; import gplx.dbs.engines.sqlite.*;
public class Fsd_fil_tbl {
private String tbl_name = "file_data_fil"; private final Db_meta_fld_list flds = Db_meta_fld_list.new_();
private String fld_id, fld_owner_id, fld_name, fld_xtn_id, fld_ext_id, fld_size, fld_modified, fld_hash, fld_bin_db_id;
private String Idx_owner;
private Db_conn conn; private Db_stmt stmt_insert, stmt_update, stmt_select_by_name;
public void Conn_(Db_conn new_conn, boolean created, boolean version_is_1) {
this.conn = new_conn; flds.Clear();
String fld_prefix = "";
if (version_is_1) {
tbl_name = "fsdb_fil";
fld_prefix = "fil_";
}
fld_id = flds.Add_int(fld_prefix + "id");
fld_owner_id = flds.Add_int(fld_prefix + "owner_id");
fld_xtn_id = flds.Add_int(fld_prefix + "xtn_id");
fld_ext_id = flds.Add_int(fld_prefix + "ext_id");
fld_bin_db_id = flds.Add_int(fld_prefix + "bin_db_id"); // group ints at beginning of table
fld_name = flds.Add_str(fld_prefix + "name", 255);
fld_size = flds.Add_long(fld_prefix + "size");
fld_modified = flds.Add_str(fld_prefix + "modified", 14); // stored as yyyyMMddHHmmss
fld_hash = flds.Add_str(fld_prefix + "hash", 40);
Idx_owner = Db_meta_idx.Bld_idx_name(tbl_name, "owner");
if (created) {
Db_meta_tbl meta = Db_meta_tbl.new_(tbl_name, flds
, Db_meta_idx.new_unique_by_tbl(tbl_name, "pkey", fld_id)
, Db_meta_idx.new_unique_by_name(tbl_name, Idx_owner, fld_owner_id, fld_name, fld_id)
);
conn.Exec_create_tbl_and_idx(meta);
}
stmt_insert = stmt_update = stmt_select_by_name = null;
}
public void Insert(int id, int owner_id, String name, int xtn_id, int ext_id, long size, DateAdp modified, String hash, int bin_db_id) {
if (stmt_insert == null) stmt_insert = conn.Rls_reg(conn.Stmt_insert(tbl_name, flds));
stmt_insert.Clear()
.Val_int(fld_id, id)
.Val_int(fld_owner_id, owner_id)
.Val_int(fld_xtn_id, xtn_id)
.Val_int(fld_ext_id, ext_id)
.Val_int(fld_bin_db_id, bin_db_id)
.Val_str(fld_name, name)
.Val_long(fld_size, size)
.Val_str(fld_modified, Sqlite_engine_.X_date_to_str(modified))
.Val_str(fld_hash, hash)
.Exec_insert();
}
public void Update(int id, int owner_id, String name, int xtn_id, int ext_id, long size, DateAdp modified, String hash, int bin_db_id) {
if (stmt_update == null) stmt_update = conn.Rls_reg(conn.Stmt_update_exclude(tbl_name, flds, fld_id));
stmt_update.Clear()
.Val_int(fld_owner_id, owner_id)
.Val_int(fld_xtn_id, xtn_id)
.Val_int(fld_ext_id, ext_id)
.Val_int(fld_bin_db_id, bin_db_id)
.Val_str(fld_name, name)
.Val_long(fld_size, size)
.Val_str(fld_modified, Sqlite_engine_.X_date_to_str(modified))
.Val_str(fld_hash, hash)
.Crt_int(fld_id, id)
.Exec_update();
}
public Fsd_fil_itm Select_itm_by_name(int dir_id, String fil_name) {
if (stmt_select_by_name == null) {
Db_qry_select qry = Db_qry_select.new_().From_(tbl_name).Cols_(flds.To_str_ary()).Where_(Db_crt_.eq_many_(fld_owner_id, fld_name)).Indexed_by_(Idx_owner);
stmt_select_by_name = conn.Rls_reg(conn.Stmt_new(qry));
}
Db_rdr rdr = Db_rdr_.Null;
try {
rdr = stmt_select_by_name.Clear()
.Crt_int(fld_owner_id, dir_id)
.Crt_str(fld_name, fil_name)
.Exec_select_as_rdr();
return rdr.Move_next()
? new Fsd_fil_itm().Init(rdr.Read_int(fld_id), rdr.Read_int(fld_owner_id), rdr.Read_int(fld_ext_id), rdr.Read_str(fld_name), rdr.Read_int(fld_bin_db_id))
: Fsd_fil_itm.Null;
}
finally {rdr.Rls();}
}
}

View File

@@ -15,13 +15,13 @@ 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.fsdb; import gplx.*;
public class Fsdb_xtn_img_itm {
package gplx.fsdb.data; import gplx.*; import gplx.fsdb.*;
public class Fsd_img_itm {
public int Id() {return id;} public void Id_(int v) {this.id = v;} private int id;
public int W() {return w;} public void W_(int v) {this.w = v;} private int w;
public int H() {return h;} public void H_(int v) {this.h = v;} private int h;
public int Db_bin_id() {return bin_db_id;} public Fsdb_xtn_img_itm Db_bin_id_(int v) {bin_db_id = v; return this;} private int bin_db_id;
public Fsdb_xtn_img_itm Init_by_load(int id, int w, int h) {this.id = id; this.w = w; this.h = h; return this;}
public static final Fsdb_xtn_img_itm Null = new Fsdb_xtn_img_itm();
public int Db_bin_id() {return bin_db_id;} public Fsd_img_itm Db_bin_id_(int v) {bin_db_id = v; return this;} private int bin_db_id;
public Fsd_img_itm Init_by_load(int id, int w, int h) {this.id = id; this.w = w; this.h = h; return this;}
public static final Fsd_img_itm Null = new Fsd_img_itm();
public static final int Bits_default = 8;
}

View File

@@ -0,0 +1,41 @@
/*
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.fsdb.data; import gplx.*; import gplx.fsdb.*;
public class Fsd_thm_itm {
protected Fsd_thm_itm() {}
public void Ctor(int id, int owner_id, int w, double time, int page, int h, long size, String modified, String hash) {
this.id = id; this.owner_id = owner_id; this.width = w; this.thumbtime = time; this.page = page; this.height = h; this.size = size; this.modified = modified; this.hash = hash;
}
public int Id() {return id;} public Fsd_thm_itm Id_(int v) {id = v; return this;} private int id;
public Fsd_fil_itm Owner() {return owner;} public Fsd_thm_itm Owner_(Fsd_fil_itm v) {owner = v; return this;} private Fsd_fil_itm owner = Fsd_fil_itm.Null;
public int Owner_id() {return owner_id;} public Fsd_thm_itm Owner_id_(int v) {owner_id = v; return this;} private int owner_id;
public int Width() {return width;} public Fsd_thm_itm Width_(int v) {width = v; return this;} private int width;
public double Thumbtime() {return thumbtime;} public Fsd_thm_itm Thumbtime_(double v) {thumbtime = v; return this;} private double thumbtime;
public int Page() {return page;} public Fsd_thm_itm Page_(int v) {page = v; return this;} private int page;
public int Height() {return height;} public Fsd_thm_itm Height_(int v) {height = v; return this;} private int height;
public long Size() {return size;} public Fsd_thm_itm Size_(long v) {size = v; return this;} private long size;
public String Modified() {return modified;} public Fsd_thm_itm Modified_(String v) {modified = v; return this;} private String modified;
public String Hash() {return hash;} public Fsd_thm_itm Hash_(String v) {hash = v; return this;} private String hash;
public int Dir_id() {return dir_id;} public Fsd_thm_itm Dir_id_(int v) {dir_id = v; return this;} private int dir_id;
public int Db_bin_id() {return bin_db_id;} public Fsd_thm_itm Db_bin_id_(int v) {bin_db_id = v; return this;} private int bin_db_id;
public int Mnt_id() {return mnt_id;} public Fsd_thm_itm Mnt_id_(int v) {mnt_id = v; return this;} private int mnt_id;
public static Fsd_thm_itm new_() {return new Fsd_thm_itm();} // NOTE: Owner is null by default
public static Fsd_thm_itm load_() {return new Fsd_thm_itm().Owner_(new Fsd_fil_itm());} // NOTE: Owner is new'd b/c load will use owner.Ext_id
public static final Fsd_thm_itm Null = new Fsd_thm_itm();
public static final Fsd_thm_itm[] Ary_empty = new Fsd_thm_itm[0];
}

View File

@@ -0,0 +1,147 @@
/*
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.fsdb.data; import gplx.*; import gplx.fsdb.*;
import gplx.dbs.*; import gplx.dbs.qrys.*; import gplx.dbs.engines.sqlite.*;
import gplx.fsdb.meta.*;
public class Fsd_thm_tbl {
private String tbl_name = "file_data_thm"; private final Db_meta_fld_list flds = Db_meta_fld_list.new_();
private String fld_id, fld_owner_id, fld_w, fld_h, fld_time, fld_page, fld_bin_db_id, fld_size, fld_modified, fld_hash, fld_thumbtime;
private Db_conn conn; private Db_stmt stmt_insert, stmt_select_by_fil_w;
private Fsm_atr_fil atr_fil;
public void Conn_(Db_conn new_conn, boolean created, boolean version_is_1, Fsm_atr_fil atr_fil) {
this.conn = new_conn; flds.Clear(); this.atr_fil = atr_fil;
String fld_prefix = "";
if (version_is_1) {
tbl_name = "fsdb_xtn_thm";
fld_prefix = "thm_";
}
fld_id = flds.Add_int(fld_prefix + "id");
fld_owner_id = flds.Add_int(fld_prefix + "owner_id");
fld_w = flds.Add_int(fld_prefix + "w");
fld_h = flds.Add_int(fld_prefix + "h");
fld_time = flds.Add_double(fld_prefix + "time");
fld_page = flds.Add_int(fld_prefix + "page");
fld_bin_db_id = flds.Add_int(fld_prefix + "bin_db_id");
fld_size = flds.Add_long(fld_prefix + "size");
fld_modified = flds.Add_str(fld_prefix + "modified", 14); // stored as yyyyMMddHHmmss
fld_hash = flds.Add_str(fld_prefix + "hash", 40);
if (created) {
Db_meta_tbl meta = Db_meta_tbl.new_(tbl_name, flds
, Db_meta_idx.new_unique_by_tbl(tbl_name, "pkey", fld_id)
, Db_meta_idx.new_unique_by_tbl(tbl_name, "owner", fld_owner_id, fld_id, fld_w, fld_time, fld_page)
);
conn.Exec_create_tbl_and_idx(meta);
}
stmt_insert = stmt_select_by_fil_w = null;
schema_thm_page_init = true;
}
private boolean Schema_thm_page() {
if (schema_thm_page_init) {
schema_thm_page = atr_fil.Abc_mgr().Cfg_mgr().Schema_thm_page();
schema_thm_page_init = false;
if (schema_thm_page) {
fld_thumbtime = Db_meta_fld.Key_null;
}
else {
fld_time = Db_meta_fld.Key_null;
fld_page = Db_meta_fld.Key_null;
}
}
return schema_thm_page;
} private boolean schema_thm_page, schema_thm_page_init = true;
public void Insert(int id, int thm_owner_id, int width, int height, double thumbtime, int page, int bin_db_id, long size, DateAdp modified, String hash) {
if (stmt_insert == null) {
String tmp_fld_time = this.Schema_thm_page() ? fld_time : fld_thumbtime;
stmt_insert = conn.Rls_reg(conn.Stmt_insert(tbl_name, fld_id, fld_owner_id, fld_w, fld_h, tmp_fld_time, fld_page, fld_bin_db_id, fld_size, fld_modified, fld_hash));
}
stmt_insert.Clear()
.Val_int(fld_id, id)
.Val_int(fld_owner_id, thm_owner_id)
.Val_int(fld_w, width)
.Val_int(fld_h, height);
if (this.Schema_thm_page()) {
stmt_insert.Val_double (fld_time, gplx.xowa.files.Xof_doc_thumb.Db_save_double(thumbtime));
stmt_insert.Val_int (fld_page, gplx.xowa.files.Xof_doc_page.Db_save_int(page));
}
else
stmt_insert.Val_int (fld_thumbtime, gplx.xowa.files.Xof_doc_thumb.Db_save_int(thumbtime));
stmt_insert
.Val_int(fld_bin_db_id, bin_db_id)
.Val_long(fld_size, size)
.Val_str(fld_modified, Sqlite_engine_.X_date_to_str(modified))
.Val_str(fld_hash, hash)
.Exec_insert();
}
private Db_stmt Select_by_fil_w_stmt() {
Db_qry_select qry = Db_qry_.select_().From_(tbl_name).Cols_all_();
gplx.core.criterias.Criteria crt
= this.Schema_thm_page()
? Db_crt_.eq_many_(fld_owner_id, fld_w, fld_time, fld_page)
: Db_crt_.eq_many_(fld_owner_id, fld_w, fld_thumbtime)
;
qry.Where_(crt);
return conn.Stmt_new(qry);
}
public boolean Select_itm_by_fil_width(int owner_id, Fsd_thm_itm thm) {
if (stmt_select_by_fil_w == null) stmt_select_by_fil_w = conn.Rls_reg(Select_by_fil_w_stmt());
Db_rdr rdr = Db_rdr_.Null;
try {
stmt_select_by_fil_w.Clear()
.Crt_int(fld_owner_id, owner_id)
.Crt_int(fld_w, thm.Width())
;
if (this.Schema_thm_page()) {
stmt_select_by_fil_w.Crt_double(fld_time, gplx.xowa.files.Xof_doc_thumb.Db_save_double(thm.Thumbtime()));
stmt_select_by_fil_w.Crt_int(fld_page, gplx.xowa.files.Xof_doc_page.Db_save_int(thm.Page()));
}
else {
stmt_select_by_fil_w.Crt_int(fld_time, gplx.xowa.files.Xof_doc_thumb.Db_save_int(thm.Thumbtime()));
}
rdr = stmt_select_by_fil_w.Exec_select_as_rdr();
return rdr.Move_next()
? Ctor_by_load(thm, rdr, this.Schema_thm_page())
: false;
}
finally {rdr.Rls();}
}
private boolean Ctor_by_load(Fsd_thm_itm itm, Db_rdr rdr, boolean schema_thm_page) {
int id = rdr.Read_int(fld_id);
int owner_id = rdr.Read_int(fld_owner_id);
int width = rdr.Read_int(fld_w);
int height = rdr.Read_int(fld_h);
long size = rdr.Read_long(fld_size);
String modified = rdr.Read_str(fld_modified);
String hash = rdr.Read_str(fld_hash);
int bin_db_id = rdr.Read_int(fld_bin_db_id);
double time = 0;
int page = 0;
if (schema_thm_page) {
time = gplx.xowa.files.Xof_doc_thumb.Db_load_double(rdr, fld_time);
page = gplx.xowa.files.Xof_doc_page.Db_load_int(rdr, fld_page);
}
else {
time = gplx.xowa.files.Xof_doc_thumb.Db_load_int(rdr, fld_thumbtime);
page = gplx.xowa.files.Xof_doc_page.Null;
}
itm.Ctor(id, owner_id, width, time, page, height, size, modified, hash);
itm.Db_bin_id_(bin_db_id);
return true;
}
public static final DateAdp Modified_null = null;
public static final String Hash_null = "";
}

View File

@@ -0,0 +1,94 @@
/*
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.fsdb.meta; import gplx.*; import gplx.fsdb.*;
import gplx.dbs.*; import gplx.dbs.engines.sqlite.*;
import gplx.fsdb.data.*;
public class Fsm_abc_mgr implements RlsAble {
private Db_conn conn;
public Fsm_atr_mgr Atr_mgr() {return atr_mgr;} private final Fsm_atr_mgr atr_mgr = new Fsm_atr_mgr();
public Fsm_bin_mgr Bin_mgr() {return bin_mgr;} private final Fsm_bin_mgr bin_mgr = new Fsm_bin_mgr();
public Fsm_cfg_mgr Cfg_mgr() {return cfg_mgr;} private final Fsm_cfg_mgr cfg_mgr = new Fsm_cfg_mgr();
public int Next_id() {return cfg_mgr.Next_id();}
private static final String Db_conn_bldr_type = "gplx.fsdb.abc";
public void Init_for_db(boolean version_is_1, Io_url dir) {
Io_url abc_url = dir.GenSubFil("fsdb.abc.sqlite3");
Db_conn_bldr_data conn_data = Db_conn_bldr.I.Get_or_new(Db_conn_bldr_type, abc_url);
boolean created = conn_data.Created();
conn = conn_data.Conn();
atr_mgr.Init_for_db(conn, created, version_is_1, dir, this);
bin_mgr.Init_for_db(conn, created, version_is_1, dir);
cfg_mgr.Init_for_db(conn, created, version_is_1);
if (created) {
this.Txn_save(); // immediately save new entries in atr,cfg
}
else {
if (!cfg_mgr.Patch_next_id()) Fsdb_db_abc_mgr_.Patch_next_id(this, dir);
}
}
public void Fil_insert(Fsd_fil_itm rv , byte[] dir, byte[] fil, int ext_id, DateAdp modified, String hash, long bin_len, gplx.ios.Io_stream_rdr bin_rdr) {
int bin_db_id = bin_mgr.Get_id_for_insert(bin_len);
rv.Db_bin_id_(bin_db_id);
int fil_id = atr_mgr.Fil_insert(rv, dir, fil, ext_id, modified, hash, bin_db_id, bin_len, bin_rdr);
bin_len = bin_mgr.Insert(bin_db_id, fil_id, Fsd_bin_tbl.Owner_tid_fil, bin_len, bin_rdr);
bin_mgr.Increment(bin_len);
}
public void Thm_insert(Fsd_thm_itm rv, byte[] dir, byte[] fil, int ext_id, int w, int h, double thumbtime, int page, DateAdp modified, String hash, long bin_len, gplx.ios.Io_stream_rdr bin_rdr) {
int bin_db_id = bin_mgr.Get_id_for_insert(bin_len);
rv.Db_bin_id_(bin_db_id);
int thm_id = atr_mgr.Thm_insert(rv, dir, fil, ext_id, w, h, thumbtime, page, modified, hash, bin_db_id, bin_len, bin_rdr);
bin_len = bin_mgr.Insert(bin_db_id, thm_id, Fsd_bin_tbl.Owner_tid_thm, bin_len, bin_rdr);
bin_mgr.Increment(bin_len);
}
public void Img_insert(Fsd_img_itm rv, byte[] dir, byte[] fil, int ext_id, DateAdp modified, String hash, long bin_len, gplx.ios.Io_stream_rdr bin_rdr, int img_w, int img_h) {
int bin_db_id = bin_mgr.Get_id_for_insert(bin_len);
rv.Db_bin_id_(bin_db_id);
int fil_id = atr_mgr.Img_insert(rv, String_.new_utf8_(dir), String_.new_utf8_(fil), ext_id, img_w, img_h, modified, hash, bin_db_id, bin_len, bin_rdr);
bin_len = bin_mgr.Insert(bin_db_id, fil_id, Fsd_bin_tbl.Owner_tid_fil, bin_len, bin_rdr);
bin_mgr.Increment(bin_len);
}
public boolean Thm_select_bin(byte[] dir, byte[] fil, Fsd_thm_itm thm) {
Fsd_fil_itm fil_itm = atr_mgr.Fil_select(dir, fil);
return atr_mgr.Thm_select(fil_itm.Id(), thm);
}
public Fsd_fil_itm Fil_select_bin(byte[] dir, byte[] fil, boolean is_thumb, int width, double thumbtime) {
return atr_mgr.Fil_select(dir, fil);
}
public void Txn_open() {
conn.Txn_mgr().Txn_bgn_if_none();
atr_mgr.Txn_open();
bin_mgr.Txn_open();
}
public void Txn_save() {atr_mgr.Txn_save(); bin_mgr.Txn_save(); cfg_mgr.Txn_save();}
public void Rls() {atr_mgr.Rls(); bin_mgr.Rls(); cfg_mgr.Rls(); conn.Conn_term();}
public static final String Cfg_tbl_v1 = "fsdb_cfg", Cfg_tbl_v2 = "file_meta_cfg";
}
class Fsdb_db_abc_mgr_ {
public static void Patch_next_id(Fsm_abc_mgr abc_mgr, Io_url dir) {
if (!String_.Eq(dir.NameOnly(), "fsdb.user")) return;
Fsm_atr_mgr atr_mgr = abc_mgr.Atr_mgr();
Fsm_cfg_mgr cfg_mgr = abc_mgr.Cfg_mgr();
int last_id = -1;
if (atr_mgr.Len() > 0) {
Fsm_atr_fil atr_fil = atr_mgr.Get_at(0);
int max_fil_id = Db_conn_.Select_fld0_as_int_or(atr_fil.Conn(), "SELECT Max(fil_id) AS MaxId FROM fsdb_fil;", -1);
int max_thm_id = Db_conn_.Select_fld0_as_int_or(atr_fil.Conn(), "SELECT Max(thm_id) AS MaxId FROM fsdb_xtn_thm;", -1);
last_id = max_fil_id > max_thm_id ? max_fil_id : max_thm_id;
}
cfg_mgr.Patch_next_id_exec(last_id);
}
}

View File

@@ -15,31 +15,36 @@ 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.fsdb; import gplx.*;
package gplx.fsdb.meta; import gplx.*; import gplx.fsdb.*;
import gplx.core.primitives.*; import gplx.cache.*;
import gplx.dbs.*; import gplx.dbs.engines.sqlite.*;
public class Fsdb_db_atr_fil implements RlsAble {
import gplx.fsdb.data.*;
public class Fsm_atr_fil implements RlsAble {
private Gfo_cache_mgr_bry dir_cache = new Gfo_cache_mgr_bry();
private Fsdb_dir_tbl tbl_dir; private Fsdb_fil_tbl tbl_fil; private Fsdb_xtn_thm_tbl tbl_thm;
public Fsdb_db_atr_fil(Fsdb_db_abc_mgr abc_mgr, Io_url url, boolean create) {
private final Fsd_dir_tbl tbl_dir = new Fsd_dir_tbl(); private final Fsd_fil_tbl tbl_fil = new Fsd_fil_tbl(); private Fsd_thm_tbl tbl_thm = new Fsd_thm_tbl();
private static final String Db_conn_bldr_type = "gplx.fsdb.fsm_atr_fil";
public Fsm_atr_fil(Fsm_abc_mgr abc_mgr, Io_url io_url) {
this.abc_mgr = abc_mgr;
Db_url connect = create ? Db_url__sqlite.make_(url) : Db_url__sqlite.load_(url);
conn = Db_conn_.new_and_open_(connect);
Sqlite_engine_.Pragma_page_size_4096(conn);
tbl_dir = new Fsdb_dir_tbl(conn, create);
tbl_fil = new Fsdb_fil_tbl(conn, create);
tbl_thm = new Fsdb_xtn_thm_tbl(this, conn, create);
Db_conn_bldr_data conn_data = Db_conn_bldr.I.Get_or_new(Db_conn_bldr_type, io_url);
boolean created = conn_data.Created(); conn = conn_data.Conn();
boolean version_is_1 = Bool_.Y;
tbl_dir.Conn_(conn, created, version_is_1);
tbl_fil.Conn_(conn, created, version_is_1);
tbl_thm.Conn_(conn, created, version_is_1, this);
}
public Fsdb_db_abc_mgr Abc_mgr() {return abc_mgr;} private Fsdb_db_abc_mgr abc_mgr;
public Fsm_abc_mgr Abc_mgr() {return abc_mgr;} private Fsm_abc_mgr abc_mgr;
public Db_conn Conn() {return conn;} private Db_conn conn;
public int Id() {return id;} private int id;
public Io_url Url() {return url;} private Io_url url;
public String Path_bgn() {return path_bgn;} private String path_bgn;
public byte Cmd_mode() {return cmd_mode;} public Fsdb_db_atr_fil Cmd_mode_(byte v) {cmd_mode = v; return this;} private byte cmd_mode;
public byte Cmd_mode() {return cmd_mode;} public Fsm_atr_fil Cmd_mode_(byte v) {cmd_mode = v; return this;} private byte cmd_mode;
public void Ctor_by_load(int id, Io_url url, String path_bgn, byte cmd_mode) {
this.id = id;
this.url = url;
this.path_bgn = path_bgn;
this.cmd_mode = cmd_mode;
}
public void Rls() {
tbl_dir.Rls();
tbl_fil.Rls();
tbl_thm.Rls();
conn.Txn_mgr().Txn_end_all();
conn.Conn_term();
}
@@ -49,57 +54,48 @@ public class Fsdb_db_atr_fil implements RlsAble {
public void Txn_save() {
conn.Txn_mgr().Txn_end_all();
}
public Fsdb_fil_itm Fil_select(byte[] dir, byte[] fil) {
public Fsd_fil_itm Fil_select(byte[] dir, byte[] fil) {
Int_obj_ref dir_id_obj = (Int_obj_ref)dir_cache.Get_or_null(dir);
int dir_id = -1;
if (dir_id_obj == null) {
Fsdb_dir_itm dir_itm = tbl_dir.Select_itm(String_.new_utf8_(dir));
dir_id = dir_itm == Fsdb_dir_itm.Null ? -1 : dir_itm.Id();
Fsd_dir_itm dir_itm = tbl_dir.Select_itm(String_.new_utf8_(dir));
dir_id = dir_itm == Fsd_dir_itm.Null ? -1 : dir_itm.Id();
dir_cache.Add(dir, Int_obj_ref.new_(dir_id));
}
else
dir_id = dir_id_obj.Val();
if (dir_id == Int_.Neg1) return Fsdb_fil_itm.Null;
if (dir_id == Int_.Neg1) return Fsd_fil_itm.Null;
return tbl_fil.Select_itm_by_name(dir_id, String_.new_utf8_(fil));
}
public boolean Thm_select(int owner_id, Fsdb_xtn_thm_itm thm) {
public boolean Thm_select(int owner_id, Fsd_thm_itm thm) {
return tbl_thm.Select_itm_by_fil_width(owner_id, thm);
}
public int Fil_insert(Fsdb_fil_itm rv, String dir, String fil, int ext_id, DateAdp modified, String hash, int bin_db_id, long bin_len, gplx.ios.Io_stream_rdr bin_rdr) {
public int Fil_insert(Fsd_fil_itm rv, String dir, String fil, int ext_id, DateAdp modified, String hash, int bin_db_id, long bin_len, gplx.ios.Io_stream_rdr bin_rdr) {
int dir_id = Dir_id__get_or_insert(dir);
int fil_id = Fil_id__get_or_insert(Fsdb_xtn_tid_.Tid_none, dir_id, fil, ext_id, modified, hash, bin_db_id, bin_len);
int fil_id = Fil_id__get_or_insert(Xtn_tid_none, dir_id, fil, ext_id, modified, hash, bin_db_id, bin_len);
rv.Id_(fil_id).Owner_(dir_id);
return fil_id;
}
public int Img_insert(Fsdb_xtn_img_itm rv, String dir, String fil, int ext_id, int img_w, int img_h, DateAdp modified, String hash, int bin_db_id, long bin_len, gplx.ios.Io_stream_rdr bin_rdr) {
public int Img_insert(Fsd_img_itm rv, String dir, String fil, int ext_id, int img_w, int img_h, DateAdp modified, String hash, int bin_db_id, long bin_len, gplx.ios.Io_stream_rdr bin_rdr) {
int dir_id = Dir_id__get_or_insert(dir);
int fil_id = Fil_id__get_or_insert(Fsdb_xtn_tid_.Tid_img, dir_id, fil, ext_id, modified, hash, bin_db_id, bin_len);
int fil_id = Fil_id__get_or_insert(Xtn_tid_img, dir_id, fil, ext_id, modified, hash, bin_db_id, bin_len);
rv.Id_(fil_id);
return fil_id;
}
public int Thm_insert(Fsdb_xtn_thm_itm rv, String dir, String fil, int ext_id, int thm_w, int thm_h, double thumbtime, int page, DateAdp modified, String hash, int bin_db_id, long bin_len, gplx.ios.Io_stream_rdr bin_rdr) {
public int Thm_insert(Fsd_thm_itm rv, String dir, String fil, int ext_id, int thm_w, int thm_h, double thumbtime, int page, DateAdp modified, String hash, int bin_db_id, long bin_len, gplx.ios.Io_stream_rdr bin_rdr) {
int dir_id = Dir_id__get_or_insert(dir);
int fil_id = Fil_id__get_or_insert(Fsdb_xtn_tid_.Tid_thm, dir_id, fil, ext_id, modified, hash, Fsdb_bin_tbl.Null_db_bin_id, Fsdb_bin_tbl.Null_size); // NOTE: bin_db_id must be set to NULL
int fil_id = Fil_id__get_or_insert(Xtn_tid_thm, dir_id, fil, ext_id, modified, hash, Fsd_bin_tbl.Null_db_bin_id, Fsd_bin_tbl.Null_size); // NOTE: bin_db_id must be set to NULL
int thm_id = abc_mgr.Next_id();
tbl_thm.Insert(thm_id, fil_id, thm_w, thm_h, thumbtime, page, bin_db_id, bin_len, modified, hash);
rv.Id_(thm_id).Owner_id_(fil_id).Dir_id_(dir_id);
return thm_id;
}
public static Fsdb_db_atr_fil load_(Fsdb_db_abc_mgr abc_mgr, DataRdr rdr, Io_url dir) {
Io_url url = dir.GenSubFil(rdr.ReadStr(Fsdb_db_atr_tbl.Fld_url));
Fsdb_db_atr_fil rv = new Fsdb_db_atr_fil(abc_mgr, url, false);
rv.id = rdr.ReadInt(Fsdb_db_atr_tbl.Fld_uid);
rv.url = url;
rv.path_bgn = rdr.ReadStr(Fsdb_db_atr_tbl.Fld_path_bgn);
rv.cmd_mode = Db_cmd_mode.Ignore;
return rv;
}
public static Fsdb_db_atr_fil make_(Fsdb_db_abc_mgr abc_mgr, int id, Io_url url, String path_bgn) {
Fsdb_db_atr_fil rv = new Fsdb_db_atr_fil(abc_mgr, url, true);
public static Fsm_atr_fil make_(Fsm_abc_mgr abc_mgr, int id, Io_url url, String path_bgn) {
Fsm_atr_fil rv = new Fsm_atr_fil(abc_mgr, url);
rv.id = id;
rv.url = url;
rv.path_bgn = path_bgn;
rv.cmd_mode = Db_cmd_mode.Create;
rv.cmd_mode = Db_cmd_mode.Tid_create;
return rv;
}
private int Dir_id__get_or_insert(String dir_str) {
@@ -112,8 +108,8 @@ public class Fsdb_db_atr_fil implements RlsAble {
dir_cache.Del(dir_bry);
}
if (rv == -1) {
Fsdb_dir_itm itm = tbl_dir.Select_itm(dir_str);
if (itm == Fsdb_dir_itm.Null) {
Fsd_dir_itm itm = tbl_dir.Select_itm(dir_str);
if (itm == Fsd_dir_itm.Null) {
rv = abc_mgr.Next_id();
tbl_dir.Insert(rv, dir_str, 0); // 0: always assume root owner
}
@@ -125,19 +121,20 @@ public class Fsdb_db_atr_fil implements RlsAble {
return rv;
}
private int Fil_id__get_or_insert(int xtn_tid, int dir_id, String fil, int ext_id, DateAdp modified, String hash, int bin_db_id, long bin_len) {
Fsdb_fil_itm fil_itm = tbl_fil.Select_itm_by_name(dir_id, fil);
Fsd_fil_itm fil_itm = tbl_fil.Select_itm_by_name(dir_id, fil);
int fil_id = fil_itm.Id();
if (fil_id == Fsdb_fil_itm.Null_id) { // new item
if (fil_id == Fsd_fil_itm.Null_id) { // new item
fil_id = abc_mgr.Next_id();
tbl_fil.Insert(fil_id, dir_id, fil, xtn_tid, ext_id, bin_len, modified, hash, bin_db_id);
}
else { // existing item
if ( fil_itm.Db_bin_id() == Fsdb_bin_tbl.Null_db_bin_id // prv row was previously inserted by thumb
&& xtn_tid != Fsdb_xtn_tid_.Tid_thm // cur row is not thumb
if ( fil_itm.Db_bin_id() == Fsd_bin_tbl.Null_db_bin_id // prv row was previously inserted by thumb
&& xtn_tid != Xtn_tid_thm // cur row is not thumb
) {
tbl_fil.Update(fil_id, dir_id, fil, xtn_tid, ext_id, bin_len, modified, hash, bin_db_id); // update props; note that thumb inserts null props, whereas file will insert real props (EX: bin_db_id)
}
}
return fil_id;
}
private static final int Xtn_tid_none = 0, Xtn_tid_thm = 1, Xtn_tid_img = 2;
}

View File

@@ -0,0 +1,76 @@
/*
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.fsdb.meta; import gplx.*; import gplx.fsdb.*;
import gplx.dbs.*; import gplx.cache.*;
import gplx.fsdb.data.*;
public class Fsm_atr_mgr implements RlsAble {
private Fsm_atr_tbl tbl = new Fsm_atr_tbl();
private Fsm_atr_fil[] itms; private Fsm_atr_fil itms_0;
public int Len() {return itms.length;}
public Fsm_atr_fil Get_at(int i) {return i == Id_0 ? itms_0 : itms[i];}
public Fsd_fil_itm Fil_select(byte[] dir, byte[] fil) {return itms_0.Fil_select(dir, fil);}
public boolean Thm_select(int owner_id, Fsd_thm_itm thm) {return itms_0.Thm_select(owner_id, thm);}
public int Fil_insert(Fsd_fil_itm rv , byte[] dir, byte[] fil, int ext_id, DateAdp modified, String hash, int bin_db_id, long bin_len, gplx.ios.Io_stream_rdr bin_rdr) {
return itms_0.Fil_insert(rv, String_.new_utf8_(dir), String_.new_utf8_(fil), ext_id, modified, hash, bin_db_id, bin_len, bin_rdr);
}
public int Img_insert(Fsd_img_itm rv, String dir, String fil, int ext_id, int img_w, int img_h, DateAdp modified, String hash, int bin_db_id, long bin_len, gplx.ios.Io_stream_rdr bin_rdr) {
return itms_0.Img_insert(rv, dir, fil, ext_id, img_w, img_h, modified, hash, bin_db_id, bin_len, bin_rdr);
}
public int Thm_insert(Fsd_thm_itm rv, byte[] dir, byte[] fil, int ext_id, int width, int height, double thumbtime, int page, DateAdp modified, String hash, int bin_db_id, long bin_len, gplx.ios.Io_stream_rdr bin_rdr) {
return itms_0.Thm_insert(rv, String_.new_utf8_(dir), String_.new_utf8_(fil), ext_id, width, height, thumbtime, page, modified, hash, bin_db_id, bin_len, bin_rdr);
}
public void Txn_open() {
int len = itms.length;
for (int i = 0; i < len; i++) {
Fsm_atr_fil itm = itms[i];
itm.Txn_open();
}
}
public void Txn_save() {
tbl.Commit_all(itms);
int len = itms.length;
for (int i = 0; i < len; i++) {
Fsm_atr_fil itm = itms[i];
itm.Txn_save();
}
}
public void Rls() {
int len = itms.length;
for (int i = 0; i < len; i++) {
Fsm_atr_fil itm = itms[i];
itm.Rls();
}
}
public void Init_for_db(Db_conn conn, boolean created, boolean version_is_1, Io_url dir, Fsm_abc_mgr abc_mgr) {
tbl.Conn_(conn, created, version_is_1);
if (created) {
Fsm_atr_fil itm = Fsm_atr_fil.make_(abc_mgr, Id_0, url_(dir, Id_0), Path_bgn_0);
this.itms = new Fsm_atr_fil[] {itm};
this.itms_0 = itm;
}
else {
this.itms = tbl.Select_all(abc_mgr, dir);
this.itms_0 = this.itms[0];
}
}
private static Io_url url_(Io_url dir, int id) {
return dir.GenSubFil_ary("fsdb.atr.", Int_.Xto_str_pad_bgn(id, 2), ".sqlite3");
}
public static final int Id_0 = 0;
public static final String Path_bgn_0 = "";
}

View File

@@ -0,0 +1,79 @@
/*
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.fsdb.meta; import gplx.*; import gplx.fsdb.*;
import gplx.dbs.*; import gplx.dbs.qrys.*;
public class Fsm_atr_tbl {
private String tbl_name = "file_meta_atr"; private final Db_meta_fld_list flds = Db_meta_fld_list.new_();
private String fld_uid, fld_url, fld_path_bgn;
private Db_conn conn; private final Db_stmt_bldr stmt_bldr = new Db_stmt_bldr();
public void Conn_(Db_conn new_conn, boolean created, boolean version_is_1) {
this.conn = new_conn; flds.Clear();
if (version_is_1) {
tbl_name = "fsdb_db_atr";
}
fld_uid = flds.Add_int("uid");
fld_url = flds.Add_str("url", 255);
fld_path_bgn = flds.Add_str("path_bgn", 255);
if (created) {
Db_meta_tbl meta = Db_meta_tbl.new_(tbl_name, flds
, Db_meta_idx.new_unique_by_tbl(tbl_name, "pkey", fld_uid)
);
conn.Exec_create_tbl_and_idx(meta);
}
stmt_bldr.Conn_(conn, tbl_name, flds, fld_uid);
}
public Fsm_atr_fil[] Select_all(Fsm_abc_mgr abc_mgr, Io_url dir) {
ListAdp rv = ListAdp_.new_();
Db_rdr rdr = Db_rdr_.Null;
try {
rdr = conn.Stmt_select(tbl_name, flds, Db_meta_fld.Ary_empy).Exec_select_as_rdr();
while (rdr.Move_next()) {
Io_url url = dir.GenSubFil(rdr.Read_str(fld_url));
Fsm_atr_fil itm = new Fsm_atr_fil(abc_mgr, url);
itm.Ctor_by_load
( rdr.Read_int(fld_uid)
, url
, rdr.Read_str(fld_path_bgn)
, Db_cmd_mode.Tid_ignore
);
rv.Add(itm);
}
}
finally {rdr.Rls();}
return (Fsm_atr_fil[])rv.Xto_ary(Fsm_atr_fil.class);
}
public void Commit_all(Fsm_atr_fil[] ary) {
stmt_bldr.Batch_bgn();
try {
int len = ary.length;
for (int i = 0; i < len; i++)
Commit_itm(ary[i]);
} finally {stmt_bldr.Batch_end();}
}
private void Commit_itm(Fsm_atr_fil itm) {
Db_stmt stmt = stmt_bldr.Get(itm.Cmd_mode());
switch (itm.Cmd_mode()) {
case Db_cmd_mode.Tid_create: stmt.Clear().Val_int(fld_uid, itm.Id()) .Val_str(fld_url, itm.Url().NameAndExt()).Val_str(fld_path_bgn, itm.Path_bgn()).Exec_insert(); break;
case Db_cmd_mode.Tid_update: stmt.Clear() .Val_str(fld_url, itm.Url().NameAndExt()).Val_str(fld_path_bgn, itm.Path_bgn()).Crt_int(fld_uid, itm.Id()).Exec_update(); break;
case Db_cmd_mode.Tid_delete: stmt.Clear().Crt_int(fld_uid, itm.Id()).Exec_delete(); break;
case Db_cmd_mode.Tid_ignore: break;
default: throw Err_.unhandled(itm.Cmd_mode());
}
itm.Cmd_mode_(Db_cmd_mode.Tid_ignore);
}
}

View File

@@ -0,0 +1,58 @@
/*
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.fsdb.meta; import gplx.*; import gplx.fsdb.*;
import gplx.ios.*; import gplx.dbs.*; import gplx.dbs.engines.sqlite.*;
import gplx.fsdb.data.*;
public class Fsm_bin_fil implements RlsAble {
public Fsm_bin_fil(int id, Io_url url, long bin_len, long bin_max, byte cmd_mode) {
this.id = id; this.url = url; this.bin_len = bin_len; this.bin_max = bin_max; this.cmd_mode = cmd_mode;
}
public int Id() {return id;} private final int id;
public Io_url Url() {return url;} private final Io_url url;
public long Bin_max() {return bin_max;} private long bin_max;
public void Bin_max_(long v) {
bin_max = v;
if (cmd_mode == Db_cmd_mode.Tid_ignore) cmd_mode = Db_cmd_mode.Tid_update;
}
public long Bin_len() {return bin_len;} private long bin_len;
public void Bin_len_(long v) {
bin_len = v;
if (cmd_mode == Db_cmd_mode.Tid_ignore) cmd_mode = Db_cmd_mode.Tid_update;
}
public byte Cmd_mode() {return cmd_mode;} public Fsm_bin_fil Cmd_mode_(byte v) {cmd_mode = v; return this;} private byte cmd_mode;
public static final Fsm_bin_fil[] Ary_empty = new Fsm_bin_fil[0];
private Fsd_bin_tbl bin_tbl = new Fsd_bin_tbl(); private Db_conn conn;
public static Fsm_bin_fil make_(int id, Io_url url, long bin_len, long bin_max) {
Fsm_bin_fil rv = new Fsm_bin_fil(id, url, bin_len, bin_max, Db_cmd_mode.Tid_create);
rv.Conn(); // force table create
return rv;
}
private static final String Db_conn_bldr_type = "gplx.fsdb.fsm_bin";
public Db_conn Conn() {
if (conn == null) {
Db_conn_bldr_data conn_data = Db_conn_bldr.I.Get_or_new(Db_conn_bldr_type, url);
conn = conn_data.Conn();
bin_tbl.Conn_(conn, conn_data.Created(), Bool_.Y);
}
return conn;
}
public long Insert(int bin_id, byte owner_tid, long bin_len, gplx.ios.Io_stream_rdr bin_rdr) {this.Conn(); return bin_tbl.Insert_rdr(bin_id, owner_tid, bin_len, bin_rdr);}
public boolean Get_to_url(int id, Io_url url) {this.Conn(); return bin_tbl.Select_to_url(id, url);}
public Io_stream_rdr Get_as_rdr(int id) {return bin_tbl.Select_as_rdr(this.Conn(), id);}
public void Rls() {if (conn != null) conn.Conn_term();}
}

View File

@@ -0,0 +1,94 @@
/*
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.fsdb.meta; import gplx.*; import gplx.fsdb.*;
import gplx.dbs.*;
public class Fsm_bin_mgr implements RlsAble {
private Io_url dir;
private final Fsm_bin_tbl tbl = new Fsm_bin_tbl();
private Fsm_bin_fil[] fil_ary = Fsm_bin_fil.Ary_empty; private int fil_ary_len = 0;
private Fsm_bin_fil fil_cur;
public int Len() {return fil_ary.length;}
public long Db_bin_max() {return db_bin_max;}
public int Insert_to_bin() {return insert_to_bin;} public Fsm_bin_mgr Insert_to_bin_(int v) {insert_to_bin = v; return this;} private int insert_to_bin = Fsm_mnt_mgr.Insert_to_bin_null;
public Fsm_bin_mgr Db_bin_max_(long v) {
db_bin_max = v;
for (int i = 0; i < fil_ary_len; i++)
fil_ary[i].Bin_max_(v);
return this;
} private long db_bin_max = Io_mgr.Len_mb * Long_.Xby_int(188);
public Fsm_bin_fil Get_at(int i) {return fil_ary[i];}
private Fsm_bin_fil Get_cur() {return fil_ary_len == 0 ? null : fil_ary[fil_ary_len - 1];}
public void Txn_open() {
Get_cur().Conn().Txn_mgr().Txn_bgn_if_none();
}
public void Txn_save() {
tbl.Commit_all(fil_ary);
Get_cur().Conn().Txn_mgr().Txn_end_all();
}
public void Rls() {
int len = fil_ary.length;
for (int i = 0; i < len; i++) {
Fsm_bin_fil itm = fil_ary[i];
itm.Rls();
}
}
public int Get_id_for_insert(long bin_len) {
if (insert_to_bin != Fsm_mnt_mgr.Insert_to_bin_null) return insert_to_bin; // insert_to_bin specified; return it
if (fil_cur.Bin_len() > fil_cur.Bin_max())
Itms_add(0);
return fil_cur.Id();
}
public void Increment(long bin_len) {
long new_bin_len = fil_cur.Bin_len() + bin_len;
fil_cur.Bin_len_(new_bin_len);
}
public long Insert(int db_id, int bin_id, byte owner_tid, long bin_len, gplx.ios.Io_stream_rdr bin_rdr) {
Fsm_bin_fil bin_fil = fil_ary[db_id];
return bin_fil.Insert(bin_id, owner_tid, bin_len, bin_rdr);
}
public void Init_for_db(Db_conn conn, boolean created, boolean version_is_1, Io_url dir) {
this.dir = dir;
tbl.Conn_(conn, created, version_is_1);
if (created)
this.Itms_add(0);
else {
fil_ary = tbl.Select_all(dir);
fil_ary_len = this.fil_ary.length;
fil_cur = this.fil_ary[fil_ary_len - 1];
}
}
private void Itms_add(long bin_len) {
Fsm_bin_fil cur = Get_cur();
if (cur != null) {
cur.Conn().Txn_mgr().Txn_end_all();
cur.Conn().Conn_term();
}
int new_itms_len = fil_ary_len + 1;
Fsm_bin_fil[] new_itms = new Fsm_bin_fil[new_itms_len];
for (int i = 0; i < fil_ary_len; i++)
new_itms[i] = fil_ary[i];
fil_cur = Fsm_bin_fil.make_(fil_ary_len, url_(dir, fil_ary_len), bin_len, db_bin_max);
fil_ary = new_itms;
fil_ary_len = new_itms_len;
fil_ary[fil_ary_len - 1] = fil_cur;
this.Txn_open();
}
private static Io_url url_(Io_url dir, int id) {
return dir.GenSubFil_ary("fsdb.bin.", Int_.Xto_str_pad_bgn(id, 4), ".sqlite3");
}
}

View File

@@ -0,0 +1,79 @@
/*
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.fsdb.meta; import gplx.*; import gplx.fsdb.*;
import gplx.dbs.*; import gplx.dbs.qrys.*;
public class Fsm_bin_tbl {
private String tbl_name = "file_meta_bin"; private final Db_meta_fld_list flds = Db_meta_fld_list.new_();
private String fld_uid, fld_url, fld_bin_len, fld_bin_max;
private Db_conn conn; private final Db_stmt_bldr stmt_bldr = new Db_stmt_bldr();
public void Conn_(Db_conn new_conn, boolean created, boolean version_is_1) {
this.conn = new_conn; flds.Clear();
if (version_is_1) {
tbl_name = "fsdb_db_bin";
}
fld_uid = flds.Add_int("uid");
fld_url = flds.Add_str("url", 255);
fld_bin_len = flds.Add_long("bin_len");
fld_bin_max = flds.Add_long("bin_max");
if (created) {
Db_meta_tbl meta = Db_meta_tbl.new_(tbl_name, flds
, Db_meta_idx.new_unique_by_tbl(tbl_name, "pkey", fld_uid)
);
conn.Exec_create_tbl_and_idx(meta);
}
stmt_bldr.Conn_(conn, tbl_name, flds, fld_uid);
}
public Fsm_bin_fil[] Select_all(Io_url dir) {
ListAdp rv = ListAdp_.new_();
Db_qry qry = Db_qry_select.new_().From_(tbl_name).Cols_all_().Where_(Db_crt_.eq_many_(Db_meta_fld.Ary_empy)).OrderBy_asc_(fld_uid);
Db_rdr rdr = Db_rdr_.Null;
try {
rdr = conn.Stmt_new(qry).Clear().Exec_select_as_rdr();
while (rdr.Move_next()) {
Fsm_bin_fil itm = new Fsm_bin_fil
( rdr.Read_int(fld_uid)
, dir.GenSubFil(rdr.Read_str(fld_url))
, rdr.Read_long(fld_bin_len)
, rdr.Read_long(fld_bin_max)
, Db_cmd_mode.Tid_ignore
);
rv.Add(itm);
}
} finally {rdr.Rls();}
return (Fsm_bin_fil[])rv.Xto_ary(Fsm_bin_fil.class);
}
public void Commit_all(Fsm_bin_fil[] ary) {
stmt_bldr.Batch_bgn();
try {
int len = ary.length;
for (int i = 0; i < len; i++)
Commit_itm(ary[i]);
} finally {stmt_bldr.Batch_end();}
}
private void Commit_itm(Fsm_bin_fil itm) {
Db_stmt stmt = stmt_bldr.Get(itm.Cmd_mode());
switch (itm.Cmd_mode()) {
case Db_cmd_mode.Tid_create: stmt.Clear().Crt_int(fld_uid, itm.Id()) .Val_str(fld_url, itm.Url().NameAndExt()).Val_long(fld_bin_len, itm.Bin_len()).Val_long(fld_bin_max, itm.Bin_max()).Exec_insert(); break;
case Db_cmd_mode.Tid_update: stmt.Clear() .Val_str(fld_url, itm.Url().NameAndExt()).Val_long(fld_bin_len, itm.Bin_len()).Val_long(fld_bin_max, itm.Bin_max()).Crt_int(fld_uid, itm.Id()).Exec_update(); break;
case Db_cmd_mode.Tid_delete: stmt.Clear().Crt_int(fld_uid, itm.Id()).Exec_delete(); break;
case Db_cmd_mode.Tid_ignore: break;
default: throw Err_.unhandled(itm.Cmd_mode());
}
itm.Cmd_mode_(Db_cmd_mode.Tid_ignore);
}
}

View File

@@ -15,11 +15,12 @@ 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.fsdb; import gplx.*;
import gplx.dbs.*;
public class Fsdb_cfg_mgr {
private HashAdp grps = HashAdp_.new_();
private Fsdb_cfg_tbl cfg_tbl;
package gplx.fsdb.meta; import gplx.*; import gplx.fsdb.*;
import gplx.dbs.*; import gplx.dbs.cfgs.*; import gplx.xowa.*;
import gplx.fsdb.meta.*;
public class Fsm_cfg_mgr {
private final Db_cfg_tbl cfg_tbl = new Db_cfg_tbl();
private final HashAdp grps = HashAdp_.new_();
public int Next_id() {return next_id++;} private int next_id = 1;
public boolean Schema_thm_page() {return schema_thm_page;} private boolean schema_thm_page = true;
public boolean Patch_next_id() {return patch_next_id;} private boolean patch_next_id = true;
@@ -33,7 +34,7 @@ public class Fsdb_cfg_mgr {
}
public void Rls() {cfg_tbl.Rls();}
private void Update_next_id() {cfg_tbl.Update("core", "next_id", Int_.Xto_str(next_id));}
public Fsdb_cfg_mgr Update(String grp, String key, String new_val) {
public Fsm_cfg_mgr Update(String grp, String key, String new_val) {
String cur_val = cfg_tbl.Select_as_str_or(grp, key, null);
if (cur_val == null)
cfg_tbl.Insert(grp, key, new_val);
@@ -41,38 +42,36 @@ public class Fsdb_cfg_mgr {
cfg_tbl.Update(grp, key, new_val);
return this;
}
public Fsdb_cfg_grp Grps_get_or_load(String grp_key) {
Fsdb_cfg_grp grp = (Fsdb_cfg_grp)grps.Fetch(grp_key);
public Db_cfg_grp Grps_get_or_load(String grp_key) {
Db_cfg_grp grp = (Db_cfg_grp)grps.Fetch(grp_key);
if (grp == null) {
grp = cfg_tbl.Select_as_grp(grp_key);
grps.Add(grp_key, grp);
}
return grp;
}
public Fsdb_cfg_grp Grps_get_or_add(String grp_key) { // TEST:
Fsdb_cfg_grp grp = (Fsdb_cfg_grp)grps.Fetch(grp_key);
public Db_cfg_grp Grps_get_or_add(String grp_key) { // TEST:
Db_cfg_grp grp = (Db_cfg_grp)grps.Fetch(grp_key);
if (grp == null) {
grp = new Fsdb_cfg_grp(grp_key);
grp = new Db_cfg_grp(grp_key);
grps.Add(grp_key, grp);
}
return grp;
}
public static Fsdb_cfg_mgr load_(Fsdb_db_abc_mgr abc_mgr, Db_conn p) {return new Fsdb_cfg_mgr().Init_by_load(p);}
public static Fsdb_cfg_mgr make_(Fsdb_db_abc_mgr abc_mgr, Db_conn p) {return new Fsdb_cfg_mgr().Init_by_make(p);}
private Fsdb_cfg_mgr Init_by_load(Db_conn p) {
this.cfg_tbl = new Fsdb_cfg_tbl_sql().Ctor(p, false);
Fsdb_cfg_grp core_grp = Grps_get_or_load(Grp_core);
this.next_id = core_grp.Get_int_or(Key_next_id, -1); if (next_id == -1) throw Err_.new_("next_id not found in fsdb_cfg");
this.schema_thm_page = core_grp.Get_yn_or_n(Key_schema_thm_page);
this.patch_next_id = core_grp.Get_yn_or_n(Key_patch_next_id);
return this;
}
private Fsdb_cfg_mgr Init_by_make(Db_conn p) {
this.cfg_tbl = new Fsdb_cfg_tbl_sql().Ctor(p, true);
this.cfg_tbl.Insert(Grp_core, Key_next_id , "1"); // start next_id at 1
this.cfg_tbl.Insert(Grp_core, Key_schema_thm_page , "y"); // new dbs automatically have page and time in fsdb_xtn_tm
this.cfg_tbl.Insert(Grp_core, Key_patch_next_id , "y"); // new dbs automatically have correct next_id
return this;
public static Fsm_cfg_mgr new_() {return new Fsm_cfg_mgr();}
public void Init_for_db(Db_conn conn, boolean created, boolean version_is_1) {
cfg_tbl.Conn_(conn, created, version_is_1, Fsm_abc_mgr.Cfg_tbl_v1, Fsm_abc_mgr.Cfg_tbl_v2);
if (created) {
cfg_tbl.Insert(Fsm_cfg_mgr.Grp_core, Fsm_cfg_mgr.Key_next_id , "1"); // start next_id at 1
cfg_tbl.Insert(Fsm_cfg_mgr.Grp_core, Fsm_cfg_mgr.Key_schema_thm_page , "y"); // new dbs automatically have page and time in fsdb_xtn_tm
cfg_tbl.Insert(Fsm_cfg_mgr.Grp_core, Fsm_cfg_mgr.Key_patch_next_id , "y"); // new dbs automatically have correct next_id
}
else {
Db_cfg_grp core_grp = Grps_get_or_load(Grp_core);
this.next_id = core_grp.Get_int_or(Key_next_id, -1); if (next_id == -1) throw Err_.new_("next_id not found in fsdb_cfg");
this.schema_thm_page = core_grp.Get_yn_or_n(Key_schema_thm_page);
this.patch_next_id = core_grp.Get_yn_or_n(Key_patch_next_id);
}
}
public static final String Grp_core = "core";
public static final String Key_next_id = "next_id", Key_schema_thm_page = "schema.thm.page", Key_patch_next_id = "patch.next_id";

View File

@@ -0,0 +1,24 @@
/*
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.fsdb.meta; import gplx.*; import gplx.fsdb.*;
public class Fsm_id_itm {
public Fsm_id_itm(String key, int id, int version) {this.key = key; this.id = id; this.version = version;}
public String Key() {return key;} private final String key;
public int Id() {return id;} private final int id;
public int Version() {return version;} private final int version;
}

View File

@@ -0,0 +1,24 @@
/*
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.fsdb.meta; import gplx.*; import gplx.fsdb.*;
public class Fsm_mnt_itm {
public Fsm_mnt_itm(int id, String name, String url) {this.id = id; this.name = name; this.url = url;}
public int Id() {return id;} private final int id;
public String Name() {return name;} private final String name;
public String Url() {return url;} private final String url;
}

View File

@@ -0,0 +1,130 @@
/*
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.fsdb.meta; import gplx.*; import gplx.fsdb.*;
import gplx.core.primitives.*;
import gplx.dbs.*; import gplx.dbs.cfgs.*; import gplx.xowa.files.*; import gplx.xowa.files.fsdb.*;
import gplx.fsdb.data.*; import gplx.fsdb.meta.*;
public class Fsm_mnt_mgr implements GfoInvkAble {
private final Db_cfg_tbl cfg_tbl = new Db_cfg_tbl(); private final Fsm_mnt_tbl mnt_tbl = new Fsm_mnt_tbl();
private Fsm_abc_mgr[] ary; private int ary_len = 0;
private static final String Db_conn_bldr_type_mnt = "gplx.fsdb.mnt";
public void Init_by_wiki(Io_url db_dir, boolean version_is_1) {
Db_conn_bldr_data conn_data = Db_conn_bldr.I.Get_or_new(Db_conn_bldr_type_mnt, db_dir.GenSubFil("wiki.mnt.sqlite3"));
Fsm_mnt_itm[] mnts = Mnts__load_or_make(conn_data, version_is_1);
ary_len = mnts.length;
ary = new Fsm_abc_mgr[ary_len];
for (int i = 0; i < ary_len; i++) {
Fsm_mnt_itm itm = mnts[i];
Fsm_abc_mgr abc_mgr = new Fsm_abc_mgr();
ary[i] = abc_mgr;
if (version_is_1) {
Io_url abc_url = db_dir.GenSubFil_nest(itm.Url(), "fsdb.abc.sqlite3");
abc_mgr.Init_for_db(version_is_1, abc_url.OwnerDir());
}
else
throw Err_.not_implemented_();
}
if (conn_data.Created()) Fsm_mnt_mgr.Patch(this);
insert_to_mnt = cfg_tbl.Select_as_int_or_fail("core", "mnt.insert_idx");
if (ary_len > 0) {
Db_cfg_grp cfg_grp = this.Mnts__at(0).Cfg_mgr().Grps_get_or_load(Xof_fsdb_mgr_cfg.Grp_xowa);
boolean use_thumb_w = cfg_grp.Get_yn_or(Xof_fsdb_mgr_cfg.Key_upright_use_thumb_w, Bool_.N);
boolean fix_default = cfg_grp.Get_yn_or(Xof_fsdb_mgr_cfg.Key_upright_fix_default, Bool_.N);
patch_upright_tid = Xof_patch_upright_tid_.Merge(use_thumb_w, fix_default);
}
else // TEST: no cfg dbs
patch_upright_tid = Xof_patch_upright_tid_.Tid_all;
}
public Fsm_abc_mgr Mnts__at(int i) {return ary[i];}
public Fsm_bin_fil Bins__at(int mnt_id, int bin_db_id) {return ary[mnt_id].Bin_mgr().Get_at(bin_db_id);}
public Fsd_fil_itm Fil_select_bin(byte[] dir, byte[] fil, boolean is_thumb, int width, double thumbtime) {
for (int i = 0; i < ary_len; i++) {
Fsd_fil_itm rv = ary[i].Fil_select_bin(dir, fil, is_thumb, width, thumbtime);
if (rv != Fsd_fil_itm.Null && rv.Db_bin_id() != Fsd_bin_tbl.Null_db_bin_id) { // NOTE: mnt_0 can have thumb, but mnt_1 can have itm; check for itm with Db_bin_id; DATE:2013-11-16
rv.Mnt_id_(i);
return rv;
}
}
return Fsd_fil_itm.Null;
}
public boolean Thm_select_bin(byte[] dir, byte[] fil, Fsd_thm_itm thm) {
for (int i = 0; i < ary_len; i++) {
boolean rv = ary[i].Thm_select_bin(dir, fil, thm);
if (rv) {
thm.Mnt_id_(i);
return rv;
}
}
return false;
}
public int Insert_to_mnt() {return insert_to_mnt;} public Fsm_mnt_mgr Insert_to_mnt_(int v) {insert_to_mnt = v; return this;} private int insert_to_mnt = Mnt_idx_user;
public void Fil_insert(Fsd_fil_itm rv , byte[] dir, byte[] fil, int ext_id, DateAdp modified, String hash, long bin_len, gplx.ios.Io_stream_rdr bin_rdr) {
ary[insert_to_mnt].Fil_insert(rv, dir, fil, ext_id, modified, hash, bin_len, bin_rdr);
}
public void Thm_insert(Fsd_thm_itm rv, byte[] dir, byte[] fil, int ext_id, int w, int h, double thumbtime, int page, DateAdp modified, String hash, long bin_len, gplx.ios.Io_stream_rdr bin_rdr) {
ary[insert_to_mnt].Thm_insert(rv, dir, fil, ext_id, w, h, thumbtime, page, modified, hash, bin_len, bin_rdr);
}
public void Img_insert(Fsd_img_itm rv, byte[] dir, byte[] fil, int ext_id, int img_w, int img_h, DateAdp modified, String hash, long bin_len, gplx.ios.Io_stream_rdr bin_rdr) {
ary[insert_to_mnt].Img_insert(rv, dir, fil, ext_id, modified, hash, bin_len, bin_rdr, img_w, img_h);
}
public void Bin_db_max_(long v) {
for (int i = 0; i < ary_len; i++)
ary[i].Bin_mgr().Db_bin_max_(v);
}
public void Insert_to_bin_(int v) {
for (int i = 0; i < ary_len; i++)
ary[i].Bin_mgr().Insert_to_bin_(v);
}
public int Patch_upright() {return patch_upright_tid;} private int patch_upright_tid = Xof_patch_upright_tid_.Tid_all;
public void Txn_open() {
for (int i = 0; i < ary_len; i++)
ary[i].Txn_open();
}
public void Txn_save() {
for (int i = 0; i < ary_len; i++)
ary[i].Txn_save();
}
public void Rls() {
for (int i = 0; i < ary_len; i++)
ary[i].Rls();
cfg_tbl.Rls();
}
public Object Invk(GfsCtx ctx, int ikey, String k, GfoMsg m) {
if (ctx.Match(k, Invk_bin_db_max_in_mb_)) this.Bin_db_max_(m.ReadLong("v") * Io_mgr.Len_mb);
else if (ctx.Match(k, Invk_insert_to_mnt_)) insert_to_mnt = m.ReadInt("v");
else if (ctx.Match(k, Invk_insert_to_bin_)) this.Insert_to_bin_(m.ReadInt("v"));
else return GfoInvkAble_.Rv_unhandled;
return this;
} private static final String Invk_bin_db_max_in_mb_ = "bin_db_max_in_mb_", Invk_insert_to_mnt_ = "insert_to_mnt_", Invk_insert_to_bin_ = "insert_to_bin_";
public static final int Mnt_idx_main = 0, Mnt_idx_user = 1, Insert_to_bin_null = -1;
public static void Patch(Fsm_mnt_mgr mnt_mgr) {
mnt_mgr.Mnts__at(Fsm_mnt_mgr.Mnt_idx_main).Cfg_mgr()
.Update(Xof_fsdb_mgr_cfg.Grp_xowa, Xof_fsdb_mgr_cfg.Key_gallery_fix_defaults , "y")
.Update(Xof_fsdb_mgr_cfg.Grp_xowa, Xof_fsdb_mgr_cfg.Key_gallery_packed , "y")
.Update(Xof_fsdb_mgr_cfg.Grp_xowa, Xof_fsdb_mgr_cfg.Key_upright_use_thumb_w , "y")
.Update(Xof_fsdb_mgr_cfg.Grp_xowa, Xof_fsdb_mgr_cfg.Key_upright_fix_default , "y")
;
}
private Fsm_mnt_itm[] Mnts__load_or_make(Db_conn_bldr_data conn_data, boolean version_is_1) {
Db_conn conn = conn_data.Conn(); boolean created = conn_data.Created();
cfg_tbl.Conn_(conn, created, version_is_1, Fsm_abc_mgr.Cfg_tbl_v1, Fsm_abc_mgr.Cfg_tbl_v2);
mnt_tbl.Conn_(conn, created, version_is_1);
if (created) cfg_tbl.Insert("core", "mnt.insert_idx", Int_.Xto_str(Mnt_idx_user));
return mnt_tbl.Select_all();
}
}

View File

@@ -0,0 +1,65 @@
/*
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.fsdb.meta; import gplx.*; import gplx.fsdb.*;
import gplx.dbs.*;
public class Fsm_mnt_tbl {
private String tbl_name = "file_meta_mnt"; private final Db_meta_fld_list flds = Db_meta_fld_list.new_();
private String fld_id, fld_name, fld_url;
private Db_conn conn;
public void Conn_(Db_conn new_conn, boolean created, boolean version_is_1) {
this.conn = new_conn; flds.Clear();
String fld_prefix = "";
if (version_is_1) {
tbl_name = "fsdb_mnt";
fld_prefix = "mnt_";
}
fld_id = flds.Add_int(fld_prefix + "id");
fld_name = flds.Add_str(fld_prefix + "name", 255);
fld_url = flds.Add_str(fld_prefix + "url", 255);
if (created) {
Db_meta_tbl meta = Db_meta_tbl.new_(tbl_name, flds
, Db_meta_idx.new_unique_by_tbl(tbl_name, "pkey", fld_id)
);
conn.Exec_create_tbl_and_idx(meta);
this.Insert(Fsm_mnt_mgr.Mnt_idx_main, "fsdb.main", "fsdb.main");
this.Insert(Fsm_mnt_mgr.Mnt_idx_user, "fsdb.user", "fsdb.user");
}
}
public void Insert(int id, String name, String url) {
Db_stmt stmt = conn.Stmt_insert(tbl_name, flds);
stmt.Clear().Val_int(fld_id, id).Val_str(fld_name, name).Val_str(fld_url, url).Exec_insert();
}
public void Update(int id, String name, String url) {
Db_stmt stmt = conn.Stmt_update_exclude(tbl_name, flds, fld_id);
stmt.Clear().Val_str(fld_name, name).Val_str(fld_url, url).Crt_int(fld_id, id).Exec_update();
}
public Fsm_mnt_itm[] Select_all() {
Db_stmt stmt = conn.Stmt_select(tbl_name, flds, Db_meta_fld.Ary_empy);
Db_rdr rdr = Db_rdr_.Null;
ListAdp list = ListAdp_.new_();
try {
rdr = stmt.Clear().Exec_select_as_rdr();
while (rdr.Move_next()) {
Fsm_mnt_itm itm = new Fsm_mnt_itm(rdr.Read_int(fld_id), rdr.Read_str(fld_name), rdr.Read_str(fld_url));
list.Add(itm);
}
}
finally {rdr.Rls();}
return (Fsm_mnt_itm[])list.Xto_ary_and_clear(Fsm_mnt_itm.class);
}
}

View File

@@ -249,8 +249,7 @@ public class Php_evaluator implements Php_tkn_wkr {
msg_log.Add_itm_many(itm, src, bgn, end, args);
}
public static final Gfo_msg_itm Expecting_itm_failed = Gfo_msg_itm_.new_warn_(Php_parser.Log_nde, "expecting_itm_failed", "expecting_itm ~{0} but got ~{1} instead");
static final byte Mode_key_bgn = 1, Mode_key_end = 2, Mode_expect = 3, Mode_suspend = 4, Mode_val = 5, Mode_ary_subs = 6, Mode_ary_dlm = 7, Mode_ary_term = 8, Mode_brack_itm = 9;
private static final byte Mode_key_bgn = 1, Mode_key_end = 2, Mode_expect = 3, Mode_suspend = 4, Mode_val = 5, Mode_ary_subs = 6, Mode_ary_dlm = 7, Mode_ary_term = 8, Mode_brack_itm = 9;
}
class Php_scanner_frame {
public Php_scanner_frame(Php_itm_ary ary) {this.ary = ary;}

View File

@@ -19,10 +19,39 @@ package gplx.srls.dsvs; import gplx.*; import gplx.srls.*;
public class Dsv_fld_parser_ {
public static final Dsv_fld_parser Bry_parser = Dsv_fld_parser_bry._;
public static final Dsv_fld_parser Int_parser = Dsv_fld_parser_int._;
public static final Dsv_fld_parser Line_parser__comment_is_pipe = new Dsv_fld_parser_line(Byte_ascii.Pipe);
public static Err err_fld_unhandled(Dsv_fld_parser parser, Dsv_wkr_base wkr, int fld_idx, byte[] src, int bgn, int end) {
throw Err_.new_fmt_("fld unhandled; parser={0} wkr={1} fld_idx={2} val={3}", ClassAdp_.NameOf_obj(parser), ClassAdp_.NameOf_obj(wkr), fld_idx, String_.new_utf8_(src, bgn, end));
}
}
class Dsv_fld_parser_line implements Dsv_fld_parser {
private byte row_dlm = Byte_ascii.NewLine; private final byte comment_dlm;
public Dsv_fld_parser_line(byte comment_dlm) {this.comment_dlm = comment_dlm;}
public void Init(byte fld_dlm, byte row_dlm) {
this.row_dlm = row_dlm;
}
public int Parse(Dsv_tbl_parser parser, Dsv_wkr_base wkr, byte[] src, int pos, int src_len, int fld_idx, int fld_bgn) {
while (true) {
boolean pos_is_last = pos == src_len;
byte b = pos_is_last ? row_dlm : src[pos];
if (b == comment_dlm) {
pos = Bry_finder.Find_fwd_until(src, pos, src_len, row_dlm);
if (pos == Bry_finder.Not_found)
pos = src_len;
}
else if (b == row_dlm) {
boolean pass = wkr.Write_bry(parser, fld_idx, src, fld_bgn, pos);
if (!pass) throw Dsv_fld_parser_.err_fld_unhandled(this, wkr, fld_idx, src, fld_bgn, pos);
wkr.Commit_itm(parser, pos);
int rv = pos + 1; // row_dlm is always 1 byte
parser.Update_by_row(rv);
return rv;
}
else
++pos;
}
}
}
class Dsv_fld_parser_bry implements Dsv_fld_parser {
private byte fld_dlm = Byte_ascii.Pipe, row_dlm = Byte_ascii.NewLine;
public void Init(byte fld_dlm, byte row_dlm) {

View File

@@ -16,195 +16,12 @@ 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; import gplx.*;
import gplx.core.btries.*; import gplx.core.flds.*; import gplx.ios.*; import gplx.threads.*;
import gplx.xowa.apps.*; import gplx.xowa.apps.caches.*; import gplx.xowa.apps.fsys.*; import gplx.xowa.apis.*; import gplx.xowa.urls.encoders.*;
import gplx.xowa.langs.*; import gplx.xowa.specials.*; import gplx.xowa.cfgs2.*;
import gplx.xowa.wikis.*; import gplx.xowa.users.*; import gplx.xowa.gui.*; import gplx.xowa.cfgs.*; import gplx.xowa.ctgs.*; import gplx.xowa.html.tocs.*; import gplx.xowa.fmtrs.*; import gplx.xowa.html.*;
import gplx.xowa.parsers.*; import gplx.xowa.parsers.amps.*; import gplx.xowa.parsers.tblws.*;
import gplx.xowa.xtns.*; import gplx.xowa.xtns.scribunto.*; import gplx.xowa.xtns.math.*;
import gplx.xowa.parsers.logs.*; import gplx.xowa.servers.tcp.*; import gplx.xowa.servers.http.*;
public class Xoa_app implements GfoInvkAble {
public Xoa_app(Gfo_usr_dlg usr_dlg, Io_url root_dir, Io_url user_dir, String bin_dir_name) {
this.usr_dlg = usr_dlg;
Io_url.Http_file_str_encoder = encoder_mgr.Fsys();
log_wtr = usr_dlg.Log_wtr();
cfg_mgr = new Xoa_cfg_mgr(this);
api_root = new Xoapi_root(this);
url_cmd_eval = new Xoa_fsys_eval(this);
fsys_mgr = new Xoa_fsys_mgr(bin_dir_name, root_dir);
launcher = new Launcher_app_mgr(this);
fsys_mgr.Init_by_app(launcher);
user = new Xou_user(this, user_dir);
log_wtr.Log_dir_(user.Fsys_mgr().App_temp_dir().GenSubDir("log"));
lang_mgr = new Xoa_lang_mgr(this);
wiki_mgr = new Xoa_wiki_mgr(this);
gui_mgr = new Xoa_gui_mgr(this);
bldr = new Xob_bldr(this);
file_mgr.Init_app(this, usr_dlg);
href_parser = new Xoh_href_parser(encoder_mgr.Href(), url_parser.Url_parser());
sanitizer = new Xop_sanitizer(parser_amp_mgr, msg_log);
user_mgr = new Xou_user_mgr(this, user);
sys_cfg = new Xoa_sys_cfg(this);
cur_redirect = new Xoa_cur(this);
shell = new Xoa_shell(this);
setup_mgr = new Xoi_setup_mgr(this);
gfs_mgr = new Xoa_gfs_mgr(this);
xtn_mgr = new Xow_xtn_mgr().Ctor_by_app(this);
hive_mgr = new Xoa_hive_mgr(this);
tcp_server.App_ctor(this);
fmtr_mgr = new Xoa_fmtr_mgr(this);
log_mgr = new Xop_log_mgr(this);
http_server = new Http_server_mgr(this);
cfg_regy = new Xocfg_regy(this);
html_mgr = new Xoh_html_mgr(this);
// queue_file = new Xop_queue_mgr(this);
}
public NumberParser Utl_num_parser() {return utl_num_parser;} private NumberParser utl_num_parser = new NumberParser();
public void Init() {
stage = Xoa_stage_.Tid_init;
launcher.Init();
xtn_mgr.Init_by_app(this);
log_wtr.Init();
gui_mgr.Init_by_app();
user.Init_by_app();
file_mgr.Init_by_app();
wiki_mgr.Init_by_app();
gplx.xowa.utls.upgrades.Xoa_upgrade_mgr.Check(this);
ctg_mgr.Init_by_app(this);
setup_mgr.Init_by_app(this);
thread_mgr.Usr_dlg_(usr_dlg);
html_mgr.Init_by_app(this);
api_root.Init_by_app(this);
}
public boolean Launch_done() {return stage == Xoa_stage_.Tid_launch;}
public void Launch() {
if (Launch_done()) return;
stage = Xoa_stage_.Tid_launch;
user.Cfg_mgr().Setup_mgr().Setup_run_check(this); log_bfr.Add("app.upgrade.done");
gplx.xowa.users.prefs.Prefs_converter._.Check(this);
user.Wiki().Init_assert(); // NOTE: must assert wiki and load langs first, else will be asserted during Portal_mgr().Init(), which will cause IndexOutOfBounds; DATE:2014-10-04
}
public byte Stage() {return stage;} public Xoa_app Stage_(byte v) {stage = v; return this;} private byte stage = Xoa_stage_.Tid_ctor;
public boolean Term_cbk() {
usr_dlg.Log_many("", "", "term:bgn");
if (setup_mgr.Cmd_mgr().Working()) {
if (!gui_mgr.Kit().Ask_yes_no("", "", "An import is in progress. Are you sure you want to exit?")) return false;
}
gui_mgr.Browser_win().Usr_dlg().Canceled_y_();
user.App_term(); usr_dlg.Log_many("", "", "term:app_term");
log_wtr.Term(); usr_dlg.Log_many("", "", "term:log_wtr");
log_mgr.Rls(); usr_dlg.Log_many("", "", "term:log_mgr");
if (Scrib_core.Core() != null) {Scrib_core.Core().Term(); usr_dlg.Log_many("", "", "term:scrib");}
wiki_mgr.Rls(); usr_dlg.Log_many("", "", "term:wiki_mgr");
return true;
}
public Xoa_wiki_mgr Wiki_mgr() {return wiki_mgr;} private Xoa_wiki_mgr wiki_mgr;
public Xou_user_mgr User_mgr() {return user_mgr;} private Xou_user_mgr user_mgr;
public Xof_file_mgr File_mgr() {return file_mgr;} private Xof_file_mgr file_mgr = new Xof_file_mgr();
public Xoa_lang_mgr Lang_mgr() {return lang_mgr;} private Xoa_lang_mgr lang_mgr;
public Xoa_gui_mgr Gui_mgr() {return gui_mgr;} private Xoa_gui_mgr gui_mgr;
public Xou_user User() {return user;} private Xou_user user;
public Xob_bldr Bldr() {return bldr;} private Xob_bldr bldr;
public Xow_xtn_mgr Xtn_mgr() {return xtn_mgr;} private Xow_xtn_mgr xtn_mgr;
public Xoapi_root Api_root() {return api_root;} private Xoapi_root api_root;
public Xop_tkn_mkr Tkn_mkr() {return tkn_mkr;} private Xop_tkn_mkr tkn_mkr = new Xop_tkn_mkr();
public Gfo_usr_dlg Usr_dlg() {return usr_dlg;} private Gfo_usr_dlg usr_dlg;
public Gfo_log_wtr Log_wtr() {return log_wtr;} private Gfo_log_wtr log_wtr;
public Xoa_gfs_mgr Gfs_mgr() {return gfs_mgr;} private Xoa_gfs_mgr gfs_mgr;
public Xoa_special_mgr Special_mgr() {return special_mgr;} private Xoa_special_mgr special_mgr = new gplx.xowa.specials.Xoa_special_mgr();
public Xoh_html_mgr Html_mgr() {return html_mgr;} private Xoh_html_mgr html_mgr;
public Xop_log_mgr Log_mgr() {return log_mgr;} private Xop_log_mgr log_mgr;
public Xoa_shell Shell() {return shell;} private Xoa_shell shell;
public byte Mode() {return mode;} public Xoa_app Mode_(byte v) {mode = v; return this;} private byte mode = Xoa_app_.Mode_console;
public Xop_amp_mgr Parser_amp_mgr() {return parser_amp_mgr;} private Xop_amp_mgr parser_amp_mgr = new Xop_amp_mgr();
public Xoa_thread_mgr Thread_mgr() {return thread_mgr;} private Xoa_thread_mgr thread_mgr = new Xoa_thread_mgr();
public Url_encoder_mgr Encoder_mgr() {return encoder_mgr;} private Url_encoder_mgr encoder_mgr = new Url_encoder_mgr();
public Xoa_fsys_mgr Fsys_mgr() {return fsys_mgr;} private Xoa_fsys_mgr fsys_mgr;
public Xoa_hive_mgr Hive_mgr() {return hive_mgr;} private Xoa_hive_mgr hive_mgr;
public Xoa_url_parser Url_parser() {return url_parser;} private Xoa_url_parser url_parser = new Xoa_url_parser();
public Xoh_href_parser Href_parser() {return href_parser;} private Xoh_href_parser href_parser;
public Xop_sanitizer Sanitizer() {return sanitizer;} private Xop_sanitizer sanitizer;
public Xop_xatr_parser Xatr_parser() {return xatr_parser;} private Xop_xatr_parser xatr_parser = new Xop_xatr_parser();
public Xop_xnde_tag_regy Xnde_tag_regy() {return xnde_tag_regy;} private Xop_xnde_tag_regy xnde_tag_regy = new Xop_xnde_tag_regy();
public Xof_math_subst_regy Math_subst_regy() {return math_subst_regy;} private Xof_math_subst_regy math_subst_regy = new Xof_math_subst_regy();
public Gfo_usr_dlg Gui_wtr() {return gui_mgr.Browser_win().Usr_dlg();}
public Launcher_app_mgr Launcher() {return launcher;} private Launcher_app_mgr launcher;
public Gfo_async_mgr Async_mgr() {return async_mgr;} private Gfo_async_mgr async_mgr = new Gfo_async_mgr();
public Xoi_setup_mgr Setup_mgr() {return setup_mgr;} private Xoi_setup_mgr setup_mgr;
public Gfo_msg_log Msg_log() {return msg_log;} private Gfo_msg_log msg_log = new Gfo_msg_log(Xoa_app_.Name);
public Gfo_msg_log Msg_log_null() {return msg_log_null;} private Gfo_msg_log msg_log_null = new Gfo_msg_log("null_log");
public Xoh_file_main_wkr File_main_wkr() {return file_main_wkr;} private Xoh_file_main_wkr file_main_wkr = new Xoh_file_main_wkr();
public Btrie_slim_mgr Utl_trie_tblw_ws() {return utl_trie_tblw_ws;} private Btrie_slim_mgr utl_trie_tblw_ws = Xop_tblw_ws_itm.trie_();
public Bry_bfr_mkr Utl_bry_bfr_mkr() {return utl_bry_bfr_mkr;} Bry_bfr_mkr utl_bry_bfr_mkr = new Bry_bfr_mkr();
public Gfo_fld_rdr Utl_fld_rdr() {return utl_fld_rdr;} Gfo_fld_rdr utl_fld_rdr = Gfo_fld_rdr.xowa_();
public Gfo_log_bfr Log_bfr() {return log_bfr;} private Gfo_log_bfr log_bfr = new Gfo_log_bfr();
public Xoa_sys_cfg Sys_cfg() {return sys_cfg;} private Xoa_sys_cfg sys_cfg;
public Bry_fmtr Tmp_fmtr() {return tmp_fmtr;} Bry_fmtr tmp_fmtr = Bry_fmtr.new_("");
public boolean Xwiki_missing(byte[] wiki_key) {return user.Wiki().Xwiki_mgr().Get_by_key(wiki_key) == null;} // NOTE: only the user_wiki has a full list of all wikis b/c it has xwiki objects; wiki_mgr does not, b/c it has heavier wiki objects which are loaded dynamically;
public boolean Xwiki_exists(byte[] wiki_key) {return user.Wiki().Xwiki_mgr().Get_by_key(wiki_key) != null;}
public Xoa_ctg_mgr Ctg_mgr() {return ctg_mgr;} private Xoa_ctg_mgr ctg_mgr = new Xoa_ctg_mgr();
public Xoa_fsys_eval Url_cmd_eval() {return url_cmd_eval;} Xoa_fsys_eval url_cmd_eval;
public Xoa_cur Cur_redirect() {return cur_redirect;} private Xoa_cur cur_redirect;
public Xoa_cfg_mgr Cfg_mgr() {return cfg_mgr;} private Xoa_cfg_mgr cfg_mgr;
public Xocfg_regy Cfg_regy() {return cfg_regy;} private Xocfg_regy cfg_regy;
public Io_stream_zip_mgr Zip_mgr() {return zip_mgr;} Io_stream_zip_mgr zip_mgr = new Io_stream_zip_mgr();
public Xoa_cache_mgr Cache_mgr() {return cache_mgr;} private Xoa_cache_mgr cache_mgr = new Xoa_cache_mgr();
public Xosrv_server Tcp_server() {return tcp_server;} private Xosrv_server tcp_server = new Xosrv_server();
public Http_server_mgr Http_server() {return http_server;} private Http_server_mgr http_server;
private Xoa_fmtr_mgr fmtr_mgr;
public void Reset_all() {
this.Free_mem(true);
gplx.xowa.xtns.scribunto.Scrib_core.Core_invalidate();
Env_.GarbageCollect();
}
public void Free_mem(boolean clear_ctx) {
utl_bry_bfr_mkr.Clear();
msg_log.Clear();
wiki_mgr.Free_mem(clear_ctx);
}
public Object Invk(GfsCtx ctx, int ikey, String k, GfoMsg m) {
if (ctx.Match(k, Invk_gui)) return gui_mgr;
else if (ctx.Match(k, Invk_api)) return api_root;
else if (ctx.Match(k, Invk_bldr)) return bldr;
else if (ctx.Match(k, Invk_wikis)) return wiki_mgr;
else if (ctx.Match(k, Invk_fsys)) return fsys_mgr;
else if (ctx.Match(k, Invk_files)) return file_mgr;
else if (ctx.Match(k, Invk_langs)) return lang_mgr;
else if (ctx.Match(k, Invk_users)) return user_mgr;
else if (ctx.Match(k, Invk_user)) return user;
else if (ctx.Match(k, Invk_sys_cfg)) return sys_cfg;
else if (ctx.Match(k, Invk_cur)) return cur_redirect;
else if (ctx.Match(k, Invk_html)) return html_mgr;
else if (ctx.Match(k, Invk_shell)) return shell;
else if (ctx.Match(k, Invk_log)) return log_wtr;
else if (ctx.Match(k, Invk_setup)) return setup_mgr;
else if (ctx.Match(k, Invk_scripts)) return gfs_mgr;
else if (ctx.MatchPriv(k, Invk_term_cbk)) return this.Term_cbk();
else if (ctx.Match(k, Invk_xtns)) return xtn_mgr;
else if (ctx.Match(k, Invk_ctg_mgr)) return ctg_mgr;
else if (ctx.Match(k, Invk_cfgs)) return cfg_mgr;
else if (ctx.Match(k, Invk_usr_dlg)) return usr_dlg;
else if (ctx.Match(k, Invk_specials)) return special_mgr;
else if (ctx.Match(k, Invk_server)) return tcp_server;
else if (ctx.Match(k, Invk_http_server)) return http_server;
else if (ctx.Match(k, Invk_app)) return this;
else if (ctx.Match(k, Invk_xowa)) return this;
else if (ctx.Match(k, Invk_fmtrs)) return fmtr_mgr;
else if (ctx.Match(k, Invk_cfg)) return cfg_regy;
else return GfoInvkAble_.Rv_unhandled;
}
public static final String Invk_gui = "gui", Invk_bldr = "bldr", Invk_wikis = "wikis", Invk_files = "files", Invk_langs = "langs", Invk_users = "users"
, Invk_sys_cfg = "sys_cfg", Invk_fsys = "fsys", Invk_cur = "cur", Invk_shell = "shell", Invk_log = "log"
, Invk_setup = "setup", Invk_scripts = "scripts", Invk_user = "user", Invk_xtns = "xtns", Invk_ctg_mgr = "ctg_mgr"
, Invk_cfgs = "cfgs", Invk_app = "app", Invk_xowa = "xowa", Invk_usr_dlg = "usr_dlg", Invk_specials = "specials", Invk_html = "html"
, Invk_server = "tcp_server", Invk_http_server = "http_server"
, Invk_fmtrs = "fmtrs"
, Invk_cfg = "cfg"
, Invk_api = "api"
;
public static final String Invk_term_cbk = "term_cbk";
import gplx.xowa.apps.fsys.*;
import gplx.xowa.files.caches.*; import gplx.xowa.files.imgs.*;
import gplx.xowa.wmfs.*;
public interface Xoa_app {
Xoa_fsys_mgr Fsys_mgr();
Xof_cache_mgr File_mgr__cache_mgr();
Xof_img_mgr File_mgr__img_mgr();
Xowmf_mgr Wmf_mgr();
}

View File

@@ -16,15 +16,17 @@ 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; import gplx.*;
import gplx.gfui.*; import gplx.xowa.users.*;
import gplx.dbs.*; import gplx.gfui.*;
import gplx.xowa.apps.*; import gplx.xowa.langs.*; import gplx.xowa.users.*;
import gplx.xowa.hdumps.*; import gplx.xowa.hdumps.core.*;
import gplx.xowa.urls.encoders.*;
public class Xoa_app_ {
public static void Run(String... args) {
Xoa_app_boot_mgr boot_mgr = new Xoa_app_boot_mgr();
boot_mgr.Run(args);
}
public static final String Name = "xowa";
public static final String Version = "2.2.1.1";
public static final String Version = "2.2.4.1";
public static String Build_date = "2012-12-30 00:00:00";
public static String Op_sys;
public static String User_agent = "";
@@ -36,6 +38,15 @@ public class Xoa_app_ {
rv.Log_wtr().Queue_enabled_(true);
return rv;
}
public static byte Mode = Xoa_app_.Mode_console;
public static Gfo_usr_dlg Usr_dlg() {return usr_dlg;} public static void Usr_dlg_(Gfo_usr_dlg v) {usr_dlg = v;} private static Gfo_usr_dlg usr_dlg;
public static Bry_bfr_mkr Utl_bry_bfr_mkr() {return utl_bry_bfr_mkr;} private static final Bry_bfr_mkr utl_bry_bfr_mkr = new Bry_bfr_mkr();
public static Url_encoder_mgr Utl_encoder_mgr() {return encoder_mgr;} private static final Url_encoder_mgr encoder_mgr = new Url_encoder_mgr();
public static Xoa_gfs_mgr Gfs_mgr() {return gfs_mgr;} public static void Gfs_mgr_(Xoa_gfs_mgr v) {gfs_mgr = v;} private static Xoa_gfs_mgr gfs_mgr;
// public static Xoa_lang_mgr Lang_mgr() {return lang_mgr;} public static void Lang_mgr_(Xoa_lang_mgr v) {lang_mgr = v;} private static Xoa_lang_mgr lang_mgr;
public static final byte Mode_console = 0, Mode_gui = 1, Mode_http = 2;
}
class Xoa_app_boot_mgr {
@@ -113,7 +124,7 @@ class Xoa_app_boot_mgr {
}
private void Run_app(App_cmd_mgr args_mgr) {
boolean app_mode_gui = false;
Xoa_app app = null;
Xoae_app app = null;
try {
// init vars
Io_url jar_dir = Env_.AppUrl().OwnerDir();
@@ -133,7 +144,8 @@ class Xoa_app_boot_mgr {
app_mode_gui = String_.Eq(app_mode, "gui");
// init app
app = new Xoa_app(usr_dlg, root_dir, user_dir, Xoa_app_.Op_sys); usr_dlg.Log_wtr().Queue_enabled_(false); log_wtr.Log_msg_to_session_fmt("app.init");
Db_conn_bldr.I.Reg_default_sqlite();
app = new Xoae_app(usr_dlg, root_dir, user_dir, Xoa_app_.Op_sys); usr_dlg.Log_wtr().Queue_enabled_(false); log_wtr.Log_msg_to_session_fmt("app.init");
app.Fsys_mgr().Wiki_dir_(wiki_dir);
try {
app.Sys_cfg().Lang_(System_lang());
@@ -142,10 +154,10 @@ class Xoa_app_boot_mgr {
app.Tcp_server().Rdr_port_(server_port_recv).Wtr_port_(server_port_send);
app.Http_server().Port_(http_server_port);
app.Http_server().Home_(http_server_home);
app.Init(); chkpoint = "init_gfs";
app.Init_by_app(); chkpoint = "init_gfs";
}
catch (Exception e) {usr_dlg.Warn_many("", "", "app init failed: ~{0} ~{1}", chkpoint, Err_.Message_gplx(e));}
app.Gui_wtr().Log_wtr_(app.Log_wtr()); // NOTE: log_wtr must be set for cmd-line (else process will fail);
app.Usr_dlg().Log_wtr_(app.Log_wtr()); // NOTE: log_wtr must be set for cmd-line (else process will fail);
// run gfs
gplx.xowa.users.prefs.Prefs_rename_mgr._.Check(app.User().Fsys_mgr().App_data_cfg_user_fil());
@@ -162,14 +174,14 @@ class Xoa_app_boot_mgr {
if (String_.Eq(app_mode, "server"))
app.Tcp_server().Run();
else if (String_.Eq(app_mode, "http_server")) {
app.Mode_(Xoa_app_.Mode_http);
Xoa_app_.Mode = Xoa_app_.Mode_http;
app.Http_server().Run();
}
else {
if (cmd_text != null)
ConsoleAdp._.WriteLine_utf8(Object_.Xto_str_strict_or_empty(app.Gfs_mgr().Run_str(cmd_text)));
if (app_mode_gui) {
app.Mode_(Xoa_app_.Mode_gui);
Xoa_app_.Mode = Xoa_app_.Mode_gui;
app.Gui_mgr().Run(); chkpoint = "run";
}
else // teardown app, else lua will keep process running

View File

@@ -18,36 +18,36 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
package gplx.xowa; import gplx.*;
import gplx.xowa.apps.*;
public class Xoa_app_fxt {
public static Xoa_app app_() {
public static Xoae_app app_() {
Io_mgr._.InitEngine_mem();
return app_(Io_url_.mem_dir_("mem/xowa/"), "linux");
return app_("linux", Io_url_.mem_dir_("mem/xowa/"));
}
public static Xoa_app app_(Io_url root_dir, String op_sys) {
public static Xoae_app app_(String op_sys, Io_url root_dir) {
Io_url user_dir = root_dir.GenSubDir_nest("user", "test_user");
Gfo_log_wtr_base._.Log_dir_(user_dir.GenSubDir_nest("tmp", "current"));
Xoa_app app = new Xoa_app(Gfo_usr_dlg_base.test_(), root_dir, user_dir, op_sys);
Xoae_app app = new Xoae_app(Gfo_usr_dlg_base.test_(), root_dir, user_dir, op_sys);
app.Setup_mgr().Dump_mgr().Data_storage_format_(gplx.ios.Io_stream_.Tid_file); // TEST: set data_storage_format to file, else bldr tests will fails (expects plain text)
GfsCore._.Clear(); // NOTE: must clear
GfsCore._.AddCmd(app, Xoa_app.Invk_app); // NOTE: must add app to GfsCore; app.Gfs_mgr() always adds current app to GfsCore; note this causes old test to leave behind GfsCore for new test
GfsCore._.AddCmd(app, Xoa_app.Invk_xowa); // add alias for app; DATE:2014-06-09
GfsCore._.AddCmd(app, Xoae_app.Invk_app); // NOTE: must add app to GfsCore; app.Gfs_mgr() always adds current app to GfsCore; note this causes old test to leave behind GfsCore for new test
GfsCore._.AddCmd(app, Xoae_app.Invk_xowa); // add alias for app; DATE:2014-06-09
return app;
}
public static Xow_wiki wiki_tst_(Xoa_app app) {return wiki_(app, "en.wikipedia.org");}
public static Xow_wiki wiki_(Xoa_app app, String key) {return wiki_(app, key, app.Lang_mgr().Lang_en());}
public static Xow_wiki wiki_(Xoa_app app, String key, Xol_lang lang) {
public static Xowe_wiki wiki_tst_(Xoae_app app) {return wiki_(app, "en.wikipedia.org");}
public static Xowe_wiki wiki_(Xoae_app app, String key) {return wiki_(app, key, app.Lang_mgr().Lang_en());}
public static Xowe_wiki wiki_(Xoae_app app, String key, Xol_lang lang) {
Io_url wiki_dir = app.Fsys_mgr().Wiki_dir().GenSubDir(key);
Xow_wiki rv = new Xow_wiki(app, wiki_dir, Xow_ns_mgr_.default_(lang.Case_mgr()), lang);
Xowe_wiki rv = new Xowe_wiki(app, wiki_dir, Xow_ns_mgr_.default_(lang.Case_mgr()), lang);
rv.File_mgr().Meta_mgr().Depth_(2); // TEST: written for 2 depth
rv.Props().Main_page_(Xoa_page_.Main_page_bry); // TEST: default to Main Page (nothing tests loading Main Page from wiki.gfs)
rv.Ns_mgr().Ids_get_or_null(Xow_ns_.Id_main).Subpages_enabled_(true);
app.Wiki_mgr().Add(rv);
return rv;
}
public static void Init_gui(Xoa_app app) {
public static void Init_gui(Xoae_app app, Xowe_wiki wiki) {
app.Gui_mgr().Browser_win().Init_by_kit(gplx.gfui.Mem_kit._);
app.Gui_mgr().Browser_win().Tab_mgr().Tabs_new_init(Xoa_page.Empty);
app.Gui_mgr().Browser_win().Tab_mgr().Tabs_new_init(wiki, Xoae_page.Empty);
}
public static Xob_bldr bldr_(Xoa_app app) {
public static Xob_bldr bldr_(Xoae_app app) {
Xob_bldr rv = new Xob_bldr(app);
rv.Sort_mem_len_(Io_mgr.Len_kb).Dump_fil_len_(Io_mgr.Len_kb).Make_fil_len_(Io_mgr.Len_kb);
return rv;

View File

@@ -16,9 +16,21 @@ 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; import gplx.*;
import gplx.dbs.*;
public class Xoa_test_ {
public static boolean Db_skip() {return Bool_.N;}
public static boolean Fsdb_is_mem = false;
public static boolean Db_skip() {return Bool_.N;}
public static boolean Db_is_mem_dflt() {return Bool_.Y;}
public static void Db_init(Io_url sqlite_url) {Db_init(Db_is_mem_dflt(), sqlite_url);}
public static void Db_init(boolean db_is_mem, Io_url sqlite_url) {
if (db_is_mem) {
Io_mgr._.InitEngine_mem();
Db_conn_bldr.I.Reg_default_mem();
}
else {
Io_mgr._.DeleteDirDeep(sqlite_url);
Db_conn_bldr.I.Reg_default_sqlite();
}
}
public static Io_url Url_root() {return Io_url_.Usr().GenSubDir_nest("xowa", "dev", "tst", "400_xowa");}
public static Io_url Url_wiki_enwiki() {return Url_root().GenSubDir_nest("root", "wiki", "en.wikipedia.org");}
public static Io_url Url_file_enwiki() {return Url_root().GenSubDir_nest("root", "file", "en.wikipedia.org");}

View File

@@ -0,0 +1,215 @@
/*
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; import gplx.*;
import gplx.core.btries.*; import gplx.core.flds.*; import gplx.ios.*; import gplx.threads.*;
import gplx.xowa.apps.*; import gplx.xowa.apps.caches.*; import gplx.xowa.apps.fsys.*; import gplx.xowa.apis.*; import gplx.xowa.urls.encoders.*; import gplx.xowa.apps.progs.*;
import gplx.xowa.langs.*; import gplx.xowa.specials.*; import gplx.xowa.cfgs2.*;
import gplx.xowa.files.caches.*; import gplx.xowa.files.imgs.*;
import gplx.xowa.wikis.*; import gplx.xowa.users.*; import gplx.xowa.gui.*; import gplx.xowa.cfgs.*; import gplx.xowa.ctgs.*; import gplx.xowa.html.tocs.*; import gplx.xowa.fmtrs.*; import gplx.xowa.html.*;
import gplx.xowa.parsers.*; import gplx.xowa.parsers.amps.*; import gplx.xowa.parsers.tblws.*;
import gplx.xowa.xtns.*; import gplx.xowa.xtns.scribunto.*; import gplx.xowa.xtns.math.*;
import gplx.xowa.parsers.logs.*; import gplx.xowa.servers.tcp.*; import gplx.xowa.servers.http.*;
import gplx.xowa.wmfs.*;
public class Xoae_app implements Xoa_app, GfoInvkAble {
public Xoae_app(Gfo_usr_dlg usr_dlg, Io_url root_dir, Io_url user_dir, String bin_dir_name) {
Xoa_app_.Usr_dlg_(usr_dlg);
Io_url.Http_file_str_encoder = Xoa_app_.Utl_encoder_mgr().Fsys();
fsys_mgr = new Xoa_fsys_mgr(bin_dir_name, root_dir);
log_wtr = usr_dlg.Log_wtr();
cfg_mgr = new Xoa_cfg_mgr(this);
api_root = new Xoapi_root(this);
user = new Xou_user(this, user_dir);
url_cmd_eval = new Xoa_fsys_eval(fsys_mgr, user.Fsys_mgr());
fsys_mgr.Init_by_app(prog_mgr);
log_wtr.Log_dir_(user.Fsys_mgr().App_temp_dir().GenSubDir("log"));
lang_mgr = new Xoa_lang_mgr(this);
wiki_mgr = new Xoa_wiki_mgr(this);
gui_mgr = new Xoa_gui_mgr(this);
bldr = new Xob_bldr(this);
file_mgr.Ctor_by_app(this);
href_parser = new Xoh_href_parser(Xoa_app_.Utl_encoder_mgr().Href(), url_parser.Url_parser());
sanitizer = new Xop_sanitizer(parser_amp_mgr, msg_log);
user_mgr = new Xou_user_mgr(this, user);
sys_cfg = new Xoa_sys_cfg(this);
cur_redirect = new Xoa_cur(this);
shell = new Xoa_shell(this);
setup_mgr = new Xoi_setup_mgr(this);
Xoa_app_.Gfs_mgr_(new Xoa_gfs_mgr(this, fsys_mgr, user.Fsys_mgr()));
xtn_mgr = new Xow_xtn_mgr().Ctor_by_app(this);
hive_mgr = new Xoa_hive_mgr(this);
tcp_server.App_ctor(this);
fmtr_mgr = new Xoa_fmtr_mgr(this);
log_mgr = new Xop_log_mgr(this);
http_server = new Http_server_mgr(this);
cfg_regy = new Xocfg_regy(this);
html_mgr = new Xoh_html_mgr(this);
// queue_file = new Xop_queue_mgr(this);
}
public byte Mode() {return Xoa_app_.Mode;}
public Xoa_fsys_mgr Fsys_mgr() {return fsys_mgr;} private final Xoa_fsys_mgr fsys_mgr;
public Xof_cache_mgr File_mgr__cache_mgr() {return file_mgr.Cache_mgr();}
public Xof_img_mgr File_mgr__img_mgr() {return file_mgr.Img_mgr();}
public Xowmf_mgr Wmf_mgr() {return wmf_mgr;} private final Xowmf_mgr wmf_mgr = new Xowmf_mgr();
public Xoa_wiki_mgr Wiki_mgr() {return wiki_mgr;} private Xoa_wiki_mgr wiki_mgr;
public Xou_user_mgr User_mgr() {return user_mgr;} private Xou_user_mgr user_mgr;
public Xof_file_mgr File_mgr() {return file_mgr;} private Xof_file_mgr file_mgr = new Xof_file_mgr();
public Xoa_lang_mgr Lang_mgr() {return lang_mgr;} private Xoa_lang_mgr lang_mgr;
public Xoa_gui_mgr Gui_mgr() {return gui_mgr;} private Xoa_gui_mgr gui_mgr;
public Xou_user User() {return user;} private Xou_user user;
public Xob_bldr Bldr() {return bldr;} private Xob_bldr bldr;
public Xow_xtn_mgr Xtn_mgr() {return xtn_mgr;} private Xow_xtn_mgr xtn_mgr;
public Xoapi_root Api_root() {return api_root;} private Xoapi_root api_root;
public Xop_tkn_mkr Tkn_mkr() {return tkn_mkr;} private Xop_tkn_mkr tkn_mkr = new Xop_tkn_mkr();
public Gfo_usr_dlg Usr_dlg() {return Xoa_app_.Usr_dlg();}
public Gfo_log_wtr Log_wtr() {return log_wtr;} private Gfo_log_wtr log_wtr;
public Xoa_gfs_mgr Gfs_mgr() {return Xoa_app_.Gfs_mgr();}
public Xoa_special_mgr Special_mgr() {return special_mgr;} private Xoa_special_mgr special_mgr = new gplx.xowa.specials.Xoa_special_mgr();
public Xoh_html_mgr Html_mgr() {return html_mgr;} private Xoh_html_mgr html_mgr;
public Xop_log_mgr Log_mgr() {return log_mgr;} private Xop_log_mgr log_mgr;
public Xoa_shell Shell() {return shell;} private Xoa_shell shell;
public Xoa_thread_mgr Thread_mgr() {return thread_mgr;} private Xoa_thread_mgr thread_mgr = new Xoa_thread_mgr();
public Xoa_hive_mgr Hive_mgr() {return hive_mgr;} private Xoa_hive_mgr hive_mgr;
public Xoa_url_parser Url_parser() {return url_parser;} private Xoa_url_parser url_parser = new Xoa_url_parser();
public Xoh_href_parser Href_parser() {return href_parser;} private Xoh_href_parser href_parser;
public Xop_sanitizer Sanitizer() {return sanitizer;} private Xop_sanitizer sanitizer;
public Xop_xatr_parser Xatr_parser() {return xatr_parser;} private Xop_xatr_parser xatr_parser = new Xop_xatr_parser();
public Xop_xnde_tag_regy Xnde_tag_regy() {return xnde_tag_regy;} private Xop_xnde_tag_regy xnde_tag_regy = new Xop_xnde_tag_regy();
public Xof_math_subst_regy Math_subst_regy() {return math_subst_regy;} private Xof_math_subst_regy math_subst_regy = new Xof_math_subst_regy();
public Xoa_prog_mgr Prog_mgr() {return prog_mgr;} private final Xoa_prog_mgr prog_mgr = new Xoa_prog_mgr();
public Gfo_async_mgr Async_mgr() {return async_mgr;} private Gfo_async_mgr async_mgr = new Gfo_async_mgr();
public Xoi_setup_mgr Setup_mgr() {return setup_mgr;} private Xoi_setup_mgr setup_mgr;
public Gfo_msg_log Msg_log() {return msg_log;} private Gfo_msg_log msg_log = new Gfo_msg_log(Xoa_app_.Name);
public Gfo_msg_log Msg_log_null() {return msg_log_null;} private Gfo_msg_log msg_log_null = new Gfo_msg_log("null_log");
public Xoh_file_main_wkr File_main_wkr() {return file_main_wkr;} private Xoh_file_main_wkr file_main_wkr = new Xoh_file_main_wkr();
public Btrie_slim_mgr Utl_trie_tblw_ws() {return utl_trie_tblw_ws;} private Btrie_slim_mgr utl_trie_tblw_ws = Xop_tblw_ws_itm.trie_();
public Bry_bfr_mkr Utl_bry_bfr_mkr() {return Xoa_app_.Utl_bry_bfr_mkr();}
public Gfo_fld_rdr Utl_fld_rdr() {return utl_fld_rdr;} Gfo_fld_rdr utl_fld_rdr = Gfo_fld_rdr.xowa_();
public Gfo_log_bfr Log_bfr() {return log_bfr;} private Gfo_log_bfr log_bfr = new Gfo_log_bfr();
public Xoa_sys_cfg Sys_cfg() {return sys_cfg;} private Xoa_sys_cfg sys_cfg;
public Bry_fmtr Tmp_fmtr() {return tmp_fmtr;} Bry_fmtr tmp_fmtr = Bry_fmtr.new_("");
public boolean Xwiki_missing(byte[] wiki_key) {return user.Wiki().Xwiki_mgr().Get_by_key(wiki_key) == null;} // NOTE: only the user_wiki has a full list of all wikis b/c it has xwiki objects; wiki_mgr does not, b/c it has heavier wiki objects which are loaded dynamically;
public boolean Xwiki_exists(byte[] wiki_key) {return user.Wiki().Xwiki_mgr().Get_by_key(wiki_key) != null;}
public Xoa_ctg_mgr Ctg_mgr() {return ctg_mgr;} private Xoa_ctg_mgr ctg_mgr = new Xoa_ctg_mgr();
public Xoa_fsys_eval Url_cmd_eval() {return url_cmd_eval;} Xoa_fsys_eval url_cmd_eval;
public Xoa_cur Cur_redirect() {return cur_redirect;} private Xoa_cur cur_redirect;
public Xoa_cfg_mgr Cfg_mgr() {return cfg_mgr;} private Xoa_cfg_mgr cfg_mgr;
public Xocfg_regy Cfg_regy() {return cfg_regy;} private Xocfg_regy cfg_regy;
public Io_stream_zip_mgr Zip_mgr() {return zip_mgr;} Io_stream_zip_mgr zip_mgr = new Io_stream_zip_mgr();
public Xoa_cache_mgr Cache_mgr() {return cache_mgr;} private Xoa_cache_mgr cache_mgr = new Xoa_cache_mgr();
public Xosrv_server Tcp_server() {return tcp_server;} private Xosrv_server tcp_server = new Xosrv_server();
public Http_server_mgr Http_server() {return http_server;} private Http_server_mgr http_server;
public Xop_amp_mgr Parser_amp_mgr() {return parser_amp_mgr;} private Xop_amp_mgr parser_amp_mgr = new Xop_amp_mgr();
private Xoa_fmtr_mgr fmtr_mgr;
public NumberParser Utl_num_parser() {return utl_num_parser;} private NumberParser utl_num_parser = new NumberParser();
public void Init_by_app() {
stage = Xoa_stage_.Tid_init;
prog_mgr.Init_by_app(url_cmd_eval);
xtn_mgr.Init_by_app(this);
log_wtr.Init();
gui_mgr.Init_by_app();
user.Init_by_app(this);
file_mgr.Init_by_app(this);
wiki_mgr.Init_by_app();
gplx.xowa.utls.upgrades.Xoa_upgrade_mgr.Check(this);
ctg_mgr.Init_by_app(this);
setup_mgr.Init_by_app(this);
thread_mgr.Usr_dlg_(Xoa_app_.Usr_dlg());
html_mgr.Init_by_app(this);
api_root.Init_by_app(this);
}
public boolean Launch_done() {return stage == Xoa_stage_.Tid_launch;}
public void Launch() {
if (Launch_done()) return;
stage = Xoa_stage_.Tid_launch;
user.Cfg_mgr().Setup_mgr().Setup_run_check(this); log_bfr.Add("app.upgrade.done");
gplx.xowa.users.prefs.Prefs_converter._.Check(this);
user.Wiki().Init_assert(); // NOTE: must assert wiki and load langs first, else will be asserted during Portal_mgr().Init(), which will cause IndexOutOfBounds; DATE:2014-10-04
}
public byte Stage() {return stage;} public Xoae_app Stage_(byte v) {stage = v; return this;} private byte stage = Xoa_stage_.Tid_ctor;
public boolean Term_cbk() {
Gfo_usr_dlg usr_dlg = Xoa_app_.Usr_dlg();
usr_dlg.Log_many("", "", "term:bgn");
if (setup_mgr.Cmd_mgr().Working()) {
if (!gui_mgr.Kit().Ask_yes_no("", "", "An import is in progress. Are you sure you want to exit?")) return false;
}
gui_mgr.Browser_win().Usr_dlg().Canceled_y_();
user.App_term(); usr_dlg.Log_many("", "", "term:app_term");
log_wtr.Term(); usr_dlg.Log_many("", "", "term:log_wtr");
log_mgr.Rls(); usr_dlg.Log_many("", "", "term:log_mgr");
if (Scrib_core.Core() != null) {Scrib_core.Core().Term(); usr_dlg.Log_many("", "", "term:scrib");}
wiki_mgr.Rls(); usr_dlg.Log_many("", "", "term:wiki_mgr");
return true;
}
public void Reset_all() {
this.Free_mem(true);
gplx.xowa.xtns.scribunto.Scrib_core.Core_invalidate();
Env_.GarbageCollect();
}
public void Free_mem(boolean clear_ctx) {
this.Utl_bry_bfr_mkr().Clear();
msg_log.Clear();
wiki_mgr.Free_mem(clear_ctx);
}
public Object Invk(GfsCtx ctx, int ikey, String k, GfoMsg m) {
if (ctx.Match(k, Invk_gui)) return gui_mgr;
else if (ctx.Match(k, Invk_api)) return api_root;
else if (ctx.Match(k, Invk_bldr)) return bldr;
else if (ctx.Match(k, Invk_wikis)) return wiki_mgr;
else if (ctx.Match(k, Invk_fsys)) return fsys_mgr;
else if (ctx.Match(k, Invk_files)) return file_mgr;
else if (ctx.Match(k, Invk_langs)) return lang_mgr;
else if (ctx.Match(k, Invk_users)) return user_mgr;
else if (ctx.Match(k, Invk_user)) return user;
else if (ctx.Match(k, Invk_sys_cfg)) return sys_cfg;
else if (ctx.Match(k, Invk_cur)) return cur_redirect;
else if (ctx.Match(k, Invk_html)) return html_mgr;
else if (ctx.Match(k, Invk_shell)) return shell;
else if (ctx.Match(k, Invk_log)) return log_wtr;
else if (ctx.Match(k, Invk_setup)) return setup_mgr;
else if (ctx.Match(k, Invk_scripts)) return Xoa_app_.Gfs_mgr();
else if (ctx.MatchPriv(k, Invk_term_cbk)) return this.Term_cbk();
else if (ctx.Match(k, Invk_xtns)) return xtn_mgr;
else if (ctx.Match(k, Invk_ctg_mgr)) return ctg_mgr;
else if (ctx.Match(k, Invk_cfgs)) return cfg_mgr;
else if (ctx.Match(k, Invk_usr_dlg)) return Xoa_app_.Usr_dlg();
else if (ctx.Match(k, Invk_specials)) return special_mgr;
else if (ctx.Match(k, Invk_server)) return tcp_server;
else if (ctx.Match(k, Invk_http_server)) return http_server;
else if (ctx.Match(k, Invk_app)) return this;
else if (ctx.Match(k, Invk_xowa)) return this;
else if (ctx.Match(k, Invk_fmtrs)) return fmtr_mgr;
else if (ctx.Match(k, Invk_cfg)) return cfg_regy;
else return GfoInvkAble_.Rv_unhandled;
}
public static final String Invk_gui = "gui", Invk_bldr = "bldr", Invk_wikis = "wikis", Invk_files = "files", Invk_langs = "langs", Invk_users = "users"
, Invk_sys_cfg = "sys_cfg", Invk_fsys = "fsys", Invk_cur = "cur", Invk_shell = "shell", Invk_log = "log"
, Invk_setup = "setup", Invk_scripts = "scripts", Invk_user = "user", Invk_xtns = "xtns", Invk_ctg_mgr = "ctg_mgr"
, Invk_cfgs = "cfgs", Invk_app = "app", Invk_xowa = "xowa", Invk_usr_dlg = "usr_dlg", Invk_specials = "specials", Invk_html = "html"
, Invk_server = "tcp_server", Invk_http_server = "http_server"
, Invk_fmtrs = "fmtrs"
, Invk_cfg = "cfg"
, Invk_api = "api"
;
public static final String Invk_term_cbk = "term_cbk";
}

View File

@@ -18,29 +18,33 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
package gplx.xowa.apis; import gplx.*; import gplx.xowa.*;
import gplx.xowa.apis.xowa.*; import gplx.xowa.gui.cmds.*;
public class Xoapi_root implements GfoInvkAble {
private Xoa_app app;
public Xoapi_root(Xoa_app app) {usr_api.Ctor_by_app(app);}
public void Init_by_kit(Xoa_app app) {
private Xoae_app app;
public Xoapi_root(Xoae_app app) {
usr_api.Ctor_by_app(app);
bldr_api.Ctor_by_app(app);
}
public void Init_by_kit(Xoae_app app) {
this.app = app;
app_api.Init_by_kit(app);
nav.Init_by_kit(app);
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);
}
public void Init_by_app(Xoa_app app) {
public void Init_by_app(Xoae_app app) {
Io_url img_dir = app.User().Fsys_mgr().App_img_dir().GenSubDir_nest("window", "portal");
html_api.Page().Toggle_mgr().Img_dir_(img_dir);
}
public Xoapi_app App() {return app_api;} private Xoapi_app app_api = new Xoapi_app();
public Xoapi_nav Nav() {return nav;} private Xoapi_nav nav = new Xoapi_nav();
public Xoapi_gui Gui() {return gui_api;} private Xoapi_gui gui_api = new Xoapi_gui();
public Xoapi_html Html() {return html_api;} private Xoapi_html html_api = new Xoapi_html();
public Xoapi_net Net() {return net_api;} private Xoapi_net net_api = new Xoapi_net();
public Xoapi_usr Usr() {return usr_api;} private Xoapi_usr usr_api = new Xoapi_usr();
public Xoapi_xtns Xtns() {return xtns_api;} private Xoapi_xtns xtns_api = new Xoapi_xtns();
public Xoapi_app App() {return app_api;} private final Xoapi_app app_api = new Xoapi_app();
public Xoapi_nav Nav() {return nav_api;} private final Xoapi_nav nav_api = new Xoapi_nav();
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_xtns Xtns() {return xtns_api;} private final Xoapi_xtns xtns_api = new Xoapi_xtns();
private void Exec(String key) {
Xog_cmd_itm cmd_itm = app.Gui_mgr().Cmd_mgr().Get_or_null(key);
if (cmd_itm == null) app.Usr_dlg().Warn_many("", "", "could not find cmd; key=~{0}", key);
@@ -48,7 +52,8 @@ public class Xoapi_root implements GfoInvkAble {
}
public Object Invk(GfsCtx ctx, int ikey, String k, GfoMsg m) {
if (ctx.Match(k, Invk_app)) return app_api;
else if (ctx.Match(k, Invk_nav)) return nav;
else if (ctx.Match(k, Invk_bldr)) return bldr_api;
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;
@@ -59,6 +64,6 @@ public class Xoapi_root implements GfoInvkAble {
}
private static final String
Invk_exec = "exec"
, Invk_app = "app", Invk_nav = "nav", Invk_gui = "gui", Invk_html = "html", Invk_net = "net", Invk_usr = "usr", Invk_xtns = "xtns"
, Invk_app = "app", Invk_bldr = "bldr", Invk_nav = "nav", Invk_gui = "gui", Invk_html = "html", Invk_net = "net", Invk_usr = "usr", Invk_xtns = "xtns"
;
}

View File

@@ -20,7 +20,7 @@ import gplx.xowa.gui.views.*;
import gplx.xowa.apis.xowa.envs.*; import gplx.xowa.apis.xowa.startups.*;
public class Xoapi_app implements GfoInvkAble {
private Xog_win_itm win;
public void Init_by_kit(Xoa_app app) {
public void Init_by_kit(Xoae_app app) {
win = app.Gui_mgr().Browser_win();
}
public void Exit() {win.App__exit();}

View File

@@ -0,0 +1,28 @@
/*
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.apis.xowa; import gplx.*; import gplx.xowa.*; import gplx.xowa.apis.*;
import gplx.xowa.apis.xowa.bldrs.*;
public class Xoapi_bldr implements GfoInvkAble {
public void Ctor_by_app(Xoa_app app) {wikis.Ctor_by_app(app);}
public Xoapi_bldr_wikis Wikis() {return wikis;} private final Xoapi_bldr_wikis wikis = new Xoapi_bldr_wikis();
public Object Invk(GfsCtx ctx, int ikey, String k, GfoMsg m) {
if (ctx.Match(k, Invk_wikis)) return wikis;
else return GfoInvkAble_.Rv_unhandled;
}
private static final String Invk_wikis = "wikis";
}

View File

@@ -18,7 +18,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
package gplx.xowa.apis.xowa; import gplx.*; import gplx.xowa.*; import gplx.xowa.apis.*;
import gplx.xowa.apis.xowa.gui.*;
public class Xoapi_gui implements GfoInvkAble {
public void Init_by_kit(Xoa_app app) {
public void Init_by_kit(Xoae_app app) {
browser.Init_by_kit(app);
font.Init_by_kit(app);
page.Init_by_kit(app);

View File

@@ -18,7 +18,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
package gplx.xowa.apis.xowa; import gplx.*; import gplx.xowa.*; import gplx.xowa.apis.*;
import gplx.xowa.apis.xowa.html.*;
public class Xoapi_html implements GfoInvkAble {
public void Init_by_kit(Xoa_app app) {
public void Init_by_kit(Xoae_app app) {
tidy.Init_by_kit(app);
modules.Init_by_kit(app);
}

View File

@@ -20,7 +20,7 @@ import gplx.xowa.gui.views.*;
import gplx.xowa.apis.xowa.navs.*;
public class Xoapi_nav implements GfoInvkAble {
private Xog_win_itm win;
public void Init_by_kit(Xoa_app app) {
public void Init_by_kit(Xoae_app app) {
win = app.Gui_mgr().Browser_win();
wiki.Init_by_kit(app);
}

View File

@@ -19,7 +19,7 @@ package gplx.xowa.apis.xowa; import gplx.*; import gplx.xowa.*; import gplx.xowa
public class Xoapi_net implements GfoInvkAble, GfoEvObj {
public Xoapi_net() {this.ev_mgr = GfoEvMgr.new_(this);}
public GfoEvMgr EvMgr() {return ev_mgr;} private GfoEvMgr ev_mgr;
public void Init_by_kit(Xoa_app app) {
public void Init_by_kit(Xoae_app app) {
}
public boolean Enabled() {return enabled;} private boolean enabled = true;
public void Enabled_(boolean v) {

View File

@@ -18,12 +18,12 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
package gplx.xowa.apis.xowa; import gplx.*; import gplx.xowa.*; import gplx.xowa.apis.*;
import gplx.xowa.apis.xowa.usrs.*;
public class Xoapi_usr implements GfoInvkAble {
public void Ctor_by_app(Xoa_app app) {
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_kit(Xoa_app app) {
public void Init_by_kit(Xoae_app app) {
bookmarks.Init_by_kit(app);
history.Init_by_kit(app);
}

View File

@@ -18,7 +18,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
package gplx.xowa.apis.xowa; import gplx.*; import gplx.xowa.*; import gplx.xowa.apis.*;
import gplx.xowa.apis.xowa.xtns.*;
public class Xoapi_xtns implements GfoInvkAble {
public void Init_by_kit(Xoa_app app) {
public void Init_by_kit(Xoae_app app) {
scribunto.Init_by_kit(app);
}
public Xoapi_scribunto Scribunto() {return scribunto;} private final Xoapi_scribunto scribunto = new Xoapi_scribunto();

View File

@@ -0,0 +1,28 @@
/*
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.apis.xowa.bldrs; import gplx.*; import gplx.xowa.*; import gplx.xowa.apis.*; import gplx.xowa.apis.xowa.*;
import gplx.xowa.apis.xowa.bldrs.filters.*;
public class Xoapi_bldr_wikis implements GfoInvkAble {
public void Ctor_by_app(Xoa_app app) {filters.Ctor_by_app(app);}
public Xoapi_filters Filters() {return filters;} private final Xoapi_filters filters = new Xoapi_filters();
public Object Invk(GfsCtx ctx, int ikey, String k, GfoMsg m) {
if (ctx.Match(k, Invk_filters)) return filters;
else return GfoInvkAble_.Rv_unhandled;
}
private static final String Invk_filters = "filters";
}

View File

@@ -0,0 +1,28 @@
/*
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.apis.xowa.bldrs.filters; import gplx.*; import gplx.xowa.*; import gplx.xowa.apis.*; import gplx.xowa.apis.xowa.*; import gplx.xowa.apis.xowa.bldrs.*;
import gplx.xowa.apis.xowa.bldrs.filters.dansguardians.*;
public class Xoapi_filters implements GfoInvkAble {
public void Ctor_by_app(Xoa_app app) {dansguardians.Ctor_by_app(app);}
public Xoapi_dansguardians Dansguardians() {return dansguardians;} private final Xoapi_dansguardians dansguardians = new Xoapi_dansguardians();
public Object Invk(GfsCtx ctx, int ikey, String k, GfoMsg m) {
if (ctx.Match(k, Invk_dansguardians)) return dansguardians;
else return GfoInvkAble_.Rv_unhandled;
}
private static final String Invk_dansguardians = "dansguardians";
}

View File

@@ -0,0 +1,76 @@
/*
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.apis.xowa.bldrs.filters.dansguardians; import gplx.*; import gplx.xowa.*; import gplx.xowa.apis.*; import gplx.xowa.apis.xowa.*; import gplx.xowa.apis.xowa.bldrs.*; import gplx.xowa.apis.xowa.bldrs.filters.*;
import gplx.ios.*; import gplx.xowa.bldrs.filters.dansguardians.*;
public class Xoapi_dansguardians implements GfoInvkAble {
public void Ctor_by_app(Xoa_app app) {
root_dir = app.Fsys_mgr().Bin_xowa_dir().GenSubDir_nest("cfg", "bldr", "filter");
}
public boolean Enabled() {return enabled;} private boolean enabled = Bool_.N;
public Io_url Root_dir() {return root_dir;} private Io_url root_dir;
public int Score_init() {return score_init;} private int score_init = 0;
public int Score_fail() {return score_fail;} private int score_fail = 0;
public boolean Case_match() {return case_match;} private boolean case_match = Bool_.N;
public boolean Wildcard_enabled() {return wildcard_enabled;} private boolean wildcard_enabled = Bool_.N;
public byte[] Wildcard_char() {return wildcard_char;} private byte[] wildcard_char = Byte_ascii.Space_bry;
public byte[][] Wildcard_list() {return wildcard_list;} private byte[][] wildcard_list = Bry_.Ary(Byte_ascii.Space_bry);// \s,.!?:;'"-() /@#$%^&*()[]{}<>_+=|\~`
public int Target_tid() {return target_tid;} private int target_tid = Dg_match_mgr.Target_tid_wikitext;
public boolean Log_enabled() {return log_enabled;} private boolean log_enabled = Bool_.Y;
public Dg_match_mgr New_mgr(String domain_str, Io_url wiki_root_dir) {
if (!enabled) return null;
Io_url log_url = wiki_root_dir.GenSubFil("dansguardian_log.sqlite3");
Dg_match_mgr rv = new Dg_match_mgr(root_dir.GenSubDir(domain_str), score_init, score_fail, case_match, log_enabled, log_url);
return rv;
}
public Object Invk(GfsCtx ctx, int ikey, String k, GfoMsg m) {
if (ctx.Match(k, Invk_enabled)) return Yn.Xto_str(enabled);
else if (ctx.Match(k, Invk_enabled_)) enabled = m.ReadYn("v");
else if (ctx.Match(k, Invk_root_dir)) return root_dir.Raw();
else if (ctx.Match(k, Invk_root_dir_)) root_dir = m.ReadIoUrl("v");
else if (ctx.Match(k, Invk_score_init)) return Int_.Xto_str(score_init);
else if (ctx.Match(k, Invk_score_init_)) score_init = m.ReadInt("v");
else if (ctx.Match(k, Invk_score_fail)) return Int_.Xto_str(score_fail);
else if (ctx.Match(k, Invk_score_fail_)) score_fail = m.ReadInt("v");
else if (ctx.Match(k, Invk_case_match)) return Yn.Xto_str(case_match);
else if (ctx.Match(k, Invk_case_match_)) case_match = m.ReadYn("v");
else if (ctx.Match(k, Invk_wildcard_enabled)) return Yn.Xto_str(wildcard_enabled);
else if (ctx.Match(k, Invk_wildcard_enabled_)) wildcard_enabled = m.ReadYn("v");
else if (ctx.Match(k, Invk_wildcard_char)) return String_.new_utf8_(wildcard_char);
else if (ctx.Match(k, Invk_wildcard_char_)) wildcard_char = m.ReadBry("v");
else if (ctx.Match(k, Invk_wildcard_list)) return "";
else if (ctx.Match(k, Invk_wildcard_list_)) {}
else if (ctx.Match(k, Invk_target_tid)) return Int_.Xto_str(target_tid);
else if (ctx.Match(k, Invk_target_tid_)) target_tid = m.ReadInt("v");
else if (ctx.Match(k, Invk_log_enabled)) return Yn.Xto_str(log_enabled);
else if (ctx.Match(k, Invk_log_enabled_)) log_enabled = m.ReadYn("v");
else return GfoInvkAble_.Rv_unhandled;
return this;
}
private static final String
Invk_enabled = "enabled" , Invk_enabled_ = "enabled_"
, Invk_root_dir = "root_dir" , Invk_root_dir_ = "root_dir_"
, Invk_score_init = "score_init" , Invk_score_init_ = "score_init_"
, Invk_score_fail = "score_fail" , Invk_score_fail_ = "score_fail_"
, Invk_case_match = "case_match" , Invk_case_match_ = "case_match_"
, Invk_wildcard_enabled = "wildcard_enabled" , Invk_wildcard_enabled_ = "wildcard_enabled_"
, Invk_wildcard_char = "wildcard_char" , Invk_wildcard_char_ = "wildcard_char_"
, Invk_wildcard_list = "wildcard_list" , Invk_wildcard_list_ = "wildcard_list_"
, Invk_target_tid = "target_tid" , Invk_target_tid_ = "target_tid_"
, Invk_log_enabled = "log_enabled" , Invk_log_enabled_ = "log_enabled_"
;
}

View File

@@ -0,0 +1,49 @@
/*
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.apis.xowa.bldrs.filters.titles; import gplx.*; import gplx.xowa.*; import gplx.xowa.apis.*; import gplx.xowa.apis.xowa.*; import gplx.xowa.apis.xowa.bldrs.*; import gplx.xowa.apis.xowa.bldrs.filters.*;
public class Xoapi_titles implements GfoInvkAble {
public void Init_by_kit(Xoae_app app) {
// wordlist_dir = app.Fsys_mgr().Bin_xtns_dir().GenSubDir_nest("xowa", "DansGuardian");
}
public boolean Enabled() {return enabled;} private boolean enabled = Bool_.Y;
public Io_url Wordlist_dir() {return wordlist_dir;} private Io_url wordlist_dir;
public int Score_init() {return score_init;} private int score_init = 0;
public int Score_pass() {return score_pass;} private int score_pass = 0;
public boolean Log_enabled() {return log_enabled;} private boolean log_enabled = Bool_.Y;
public Object Invk(GfsCtx ctx, int ikey, String k, GfoMsg m) {
if (ctx.Match(k, Invk_enabled)) return Yn.Xto_str(enabled);
else if (ctx.Match(k, Invk_enabled_)) enabled = m.ReadYn("v");
else if (ctx.Match(k, Invk_wordlist_dir)) return Int_.Xto_str(score_init);
else if (ctx.Match(k, Invk_wordlist_dir_)) wordlist_dir= m.ReadIoUrl("v");
else if (ctx.Match(k, Invk_score_init)) return Int_.Xto_str(score_init);
else if (ctx.Match(k, Invk_score_init_)) score_init = m.ReadInt("v");
else if (ctx.Match(k, Invk_score_pass)) return Int_.Xto_str(score_pass);
else if (ctx.Match(k, Invk_score_pass_)) score_pass = m.ReadInt("v");
else if (ctx.Match(k, Invk_log_enabled)) return Yn.Xto_str(enabled);
else if (ctx.Match(k, Invk_log_enabled_)) log_enabled = m.ReadYn("v");
else return GfoInvkAble_.Rv_unhandled;
return this;
}
private static final String
Invk_enabled = "enabled" , Invk_enabled_ = "enabled_"
, Invk_wordlist_dir = "wordlist_dir" , Invk_wordlist_dir_ = "wordlist_dir_"
, Invk_score_init = "score_init" , Invk_score_init_ = "score_init_"
, Invk_score_pass = "score_pas" , Invk_score_pass_ = "score_pass_"
, Invk_log_enabled = "log_enabled" , Invk_log_enabled_ = "log_enabled_"
;
}

View File

@@ -17,7 +17,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package gplx.xowa.apis.xowa.envs; import gplx.*; import gplx.xowa.*; import gplx.xowa.apis.*; import gplx.xowa.apis.xowa.*;
public class Xoapi_env implements GfoInvkAble {
public void Init_by_kit(Xoa_app app) {}
public void Init_by_kit(Xoae_app app) {}
public String Version_previous() {return version_previous;} private String version_previous = "";
public Object Invk(GfsCtx ctx, int ikey, String k, GfoMsg m) {
if (ctx.Match(k, Invk_version_previous)) return version_previous;

View File

@@ -18,7 +18,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
package gplx.xowa.apis.xowa.gui; import gplx.*; import gplx.xowa.*; import gplx.xowa.apis.*; import gplx.xowa.apis.xowa.*;
import gplx.xowa.apis.xowa.gui.browsers.*;
public class Xoapi_browser implements GfoInvkAble {
public void Init_by_kit(Xoa_app app) {
public void Init_by_kit(Xoae_app app) {
url.Init_by_kit(app);
search.Init_by_kit(app);
tabs.Init_by_kit(app);

View File

@@ -18,8 +18,8 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
package gplx.xowa.apis.xowa.gui; import gplx.*; import gplx.xowa.*; import gplx.xowa.apis.*; import gplx.xowa.apis.xowa.*;
import gplx.xowa.cfgs.gui.*; import gplx.xowa.html.*;
public class Xoapi_font implements GfoInvkAble {
private Xoa_app app;
public void Init_by_kit(Xoa_app app) {
private Xoae_app app;
public void Init_by_kit(Xoae_app app) {
this.app = app;
}
public void Increase() {Adj(1);}

View File

@@ -18,7 +18,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
package gplx.xowa.apis.xowa.gui; import gplx.*; import gplx.xowa.*; import gplx.xowa.apis.*; import gplx.xowa.apis.xowa.*;
import gplx.xowa.apis.xowa.gui.pages.*;
public class Xoapi_page implements GfoInvkAble {
public void Init_by_kit(Xoa_app app) {
public void Init_by_kit(Xoae_app app) {
view.Init_by_kit(app);
selection.Init_by_kit(app);
edit.Init_by_kit(app);

View File

@@ -19,7 +19,7 @@ package gplx.xowa.apis.xowa.gui.browsers; import gplx.*; import gplx.xowa.*; imp
import gplx.gfui.*; import gplx.xowa.pages.*; import gplx.xowa.gui.*; import gplx.xowa.gui.views.*;
public class Xoapi_find implements GfoInvkAble {
private Xog_find_box find_box;
public void Init_by_kit(Xoa_app app) {
public void Init_by_kit(Xoae_app app) {
find_box = new Xog_find_box(app);
}
public Object Invk(GfsCtx ctx, int ikey, String k, GfoMsg m) {
@@ -39,9 +39,9 @@ public class Xoapi_find implements GfoInvkAble {
, Invk_find_bwd = "find_bwd", Invk_find_fwd = "find_fwd", Invk_case_toggle = "case_toggle", Invk_wrap_toggle = "wrap_toggle";
}
class Xog_find_box {
private Xoa_app app; private Xog_win_itm win; private GfuiTextBox find_box;
private Xoae_app app; private Xog_win_itm win; private GfuiTextBox find_box;
private boolean dir_fwd = true, case_match = false, wrap_search = true;
public Xog_find_box(Xoa_app app) {
public Xog_find_box(Xoae_app app) {
this.app = app;
this.win = app.Gui_mgr().Browser_win();
this.find_box = win.Find_box();

View File

@@ -23,7 +23,7 @@ public class Xoapi_html_box implements GfoInvkAble, GfoEvMgrOwner {
evMgr = GfoEvMgr.new_(this);
}
public GfoEvMgr EvMgr() {return evMgr;} private GfoEvMgr evMgr;
public void Init_by_kit(Xoa_app app) {this.win = app.Gui_mgr().Browser_win();}
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;

View File

@@ -18,13 +18,13 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
package gplx.xowa.apis.xowa.gui.browsers; import gplx.*; import gplx.xowa.*; import gplx.xowa.apis.*; import gplx.xowa.apis.xowa.*; import gplx.xowa.apis.xowa.gui.*;
import gplx.gfui.*; import gplx.xowa.gui.views.*;
public class Xoapi_info implements Gfo_usr_dlg_ui_opt, GfoInvkAble {
public void Init_by_kit(Xoa_app app) {this.app = app;} private Xoa_app app;
public void Init_by_kit(Xoae_app app) {this.app = app;} private Xoae_app app;
private Xog_win_itm Win() {return app.Gui_mgr().Browser_win();}
public void Focus() {this.Win().Info_box().Focus();}
public void Clear() {app.Usr_dlg().Ui_wkr().Clear();}
public void Launch() {
Io_url session_fil = app.Log_wtr().Session_fil();
app.Launcher().App_view_text().Run(session_fil);
app.Prog_mgr().App_view_text().Run(session_fil);
}
public boolean Warn_enabled() {return warn_enabled;} private boolean warn_enabled;
public boolean Note_enabled() {return note_enabled;} private boolean note_enabled;

View File

@@ -18,7 +18,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
package gplx.xowa.apis.xowa.gui.browsers; import gplx.*; import gplx.xowa.*; import gplx.xowa.apis.*; import gplx.xowa.apis.xowa.*; import gplx.xowa.apis.xowa.gui.*;
import gplx.gfui.*; import gplx.xowa.gui.views.*;
public class Xoapi_prog implements GfoInvkAble {
public void Init_by_kit(Xoa_app app) {this.app = app;} private Xoa_app app;
public void Init_by_kit(Xoae_app app) {this.app = app;} private Xoae_app app;
private Xog_win_itm Win() {return app.Gui_mgr().Browser_win();}
public void Focus() {this.Win().Prog_box().Focus();}
public Object Invk(GfsCtx ctx, int ikey, String k, GfoMsg m) {

View File

@@ -18,7 +18,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
package gplx.xowa.apis.xowa.gui.browsers; import gplx.*; import gplx.xowa.*; import gplx.xowa.apis.*; import gplx.xowa.apis.xowa.*; import gplx.xowa.apis.xowa.gui.*;
import gplx.gfui.*; import gplx.xowa.gui.views.*;
public class Xoapi_prog_log implements GfoInvkAble {
public void Init_by_kit(Xoa_app app) {this.app = app;} private Xoa_app app;
public void Init_by_kit(Xoae_app app) {this.app = app;} private Xoae_app app;
public void Show() {app.Gui_mgr().Show_prog();}
public Object Invk(GfsCtx ctx, int ikey, String k, GfoMsg m) {
if (ctx.Match(k, Invk_show)) this.Show();

View File

@@ -18,7 +18,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
package gplx.xowa.apis.xowa.gui.browsers; import gplx.*; import gplx.xowa.*; import gplx.xowa.apis.*; import gplx.xowa.apis.xowa.*; import gplx.xowa.apis.xowa.gui.*;
import gplx.gfui.*; import gplx.xowa.gui.views.*;
public class Xoapi_search implements GfoInvkAble {
public void Init_by_kit(Xoa_app app) {this.app = app;} private Xoa_app app;
public void Init_by_kit(Xoae_app app) {this.app = app;} private Xoae_app app;
private GfuiTextBox Search_box() {return app.Gui_mgr().Browser_win().Search_box();}
private Xog_win_itm Win() {return app.Gui_mgr().Browser_win();}
public void Focus() {this.Search_box().Focus_select_all();}

View File

@@ -19,7 +19,7 @@ package gplx.xowa.apis.xowa.gui.browsers; import gplx.*; import gplx.xowa.*; imp
import gplx.xowa.gui.views.*;
public class Xoapi_tabs implements GfoInvkAble {
private Xog_tab_mgr tab_mgr;
public void Init_by_kit(Xoa_app app) {
public void Init_by_kit(Xoae_app app) {
this.tab_mgr = app.Gui_mgr().Browser_win().Tab_mgr();
}
private boolean Active_tab_is_null() {return tab_mgr.Active_tab_is_null();}

View File

@@ -18,7 +18,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
package gplx.xowa.apis.xowa.gui.browsers; import gplx.*; import gplx.xowa.*; import gplx.xowa.apis.*; import gplx.xowa.apis.xowa.*; import gplx.xowa.apis.xowa.gui.*;
import gplx.gfui.*; import gplx.xowa.gui.views.*;
public class Xoapi_url implements GfoInvkAble {
public void Init_by_kit(Xoa_app app) {this.app = app;} private Xoa_app app;
public void Init_by_kit(Xoae_app app) {this.app = app;} private Xoae_app app;
private GfuiTextBox Url_box() {return app.Gui_mgr().Browser_win().Url_box();}
public void Focus() {this.Url_box().Focus_select_all();}
public void Exec() {Exec_wkr(Bool_.N, this.Url_box().Text());}

View File

@@ -19,7 +19,7 @@ package gplx.xowa.apis.xowa.gui.pages; import gplx.*; import gplx.xowa.*; import
import gplx.xowa.gui.*; import gplx.xowa.gui.views.*; import gplx.xowa.pages.*;
public class Xoapi_edit implements GfoInvkAble {
private Xog_win_itm win;
public void Init_by_kit(Xoa_app app) {
public void Init_by_kit(Xoae_app app) {
win = app.Gui_mgr().Browser_win();
}
private boolean Active_tab_is_null() {return win.Tab_mgr().Active_tab_is_null();}

View File

@@ -18,8 +18,8 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
package gplx.xowa.apis.xowa.gui.pages; import gplx.*; import gplx.xowa.*; import gplx.xowa.apis.*; import gplx.xowa.apis.xowa.*; import gplx.xowa.apis.xowa.gui.*;
import gplx.gfui.*; import gplx.xowa.gui.*; import gplx.xowa.gui.views.*;
public class Xoapi_selection implements GfoInvkAble {
private Xoa_app app; private Xog_win_itm win;
public void Init_by_kit(Xoa_app app) {
private Xoae_app app; private Xog_win_itm win;
public void Init_by_kit(Xoae_app app) {
this.app = app;
win = app.Gui_mgr().Browser_win();
}

View File

@@ -18,8 +18,8 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
package gplx.xowa.apis.xowa.gui.pages; import gplx.*; import gplx.xowa.*; import gplx.xowa.apis.*; import gplx.xowa.apis.xowa.*; import gplx.xowa.apis.xowa.gui.*;
import gplx.gfui.*; import gplx.xowa.gui.*; import gplx.xowa.gui.views.*; import gplx.xowa.pages.*;
public class Xoapi_view implements GfoInvkAble {
private Xoa_app app; private Xog_win_itm win;
public void Init_by_kit(Xoa_app app) {
private Xoae_app app; private Xog_win_itm win;
public void Init_by_kit(Xoae_app app) {
this.app = app; this.win = app.Gui_mgr().Browser_win();
}
private boolean Active_tab_is_null() {return win.Tab_mgr().Active_tab_is_null();}
@@ -36,7 +36,7 @@ public class Xoapi_view implements GfoInvkAble {
public void Save_as() {
if (this.Active_tab_is_null()) return;
Xog_tab_itm tab = win.Tab_mgr().Active_tab();
String file_name = app.Encoder_mgr().Fsys_safe().Encode_str(String_.new_utf8_(tab.Page().Ttl().Full_url())) + ".html";
String file_name = Xoa_app_.Utl_encoder_mgr().Fsys_safe().Encode_str(String_.new_utf8_(tab.Page().Ttl().Full_url())) + ".html";
String file_url = app.Gui_mgr().Kit().New_dlg_file(Gfui_kit_.File_dlg_type_save, "Select file to save to:").Init_file_(file_name).Ask();
if (String_.Len_eq_0(file_url)) return;
Io_mgr._.SaveFilStr(file_url, tab.Html_box().Text());

View File

@@ -18,7 +18,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
package gplx.xowa.apis.xowa.html; import gplx.*; import gplx.xowa.*; import gplx.xowa.apis.*; import gplx.xowa.apis.xowa.*;
import gplx.xowa.apis.xowa.html.modules.*;
public class Xoapi_modules implements GfoInvkAble {
public void Init_by_kit(Xoa_app app) {
public void Init_by_kit(Xoae_app app) {
popups.Init_by_app(app);
}
public Xoapi_collapsible Collapsible() {return collapsible;} private Xoapi_collapsible collapsible = new Xoapi_collapsible();

View File

@@ -18,8 +18,8 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
package gplx.xowa.apis.xowa.html; import gplx.*; import gplx.xowa.*; import gplx.xowa.apis.*; import gplx.xowa.apis.xowa.*;
import gplx.xowa.html.tidy.*;
public class Xoapi_tidy implements GfoInvkAble {
private Xoa_app app;
public void Init_by_kit(Xoa_app app) {
private Xoae_app app;
public void Init_by_kit(Xoae_app app) {
this.app = app;
}
public void Toggle() {

View File

@@ -24,9 +24,9 @@ public class Xoapi_toggle_itm implements GfoInvkAble {
public byte[] Elem_display() {return elem_display;} private byte[] elem_display = Bry_.Empty;
public byte[] Html_toggle_hdr_cls() {return html_toggle_hdr_cls;} public Xoapi_toggle_itm Html_toggle_hdr_cls_(byte[] v) {html_toggle_hdr_cls = v; return this;} private byte[] html_toggle_hdr_cls = Bry_.Empty;
public boolean Visible() {return visible;} private boolean visible;
public Xoapi_toggle_itm Init(Xow_wiki wiki) {
public Xoapi_toggle_itm Init(Xowe_wiki wiki) {
if (Img_src_y == null) {
Io_url img_dir = wiki.App().User().Fsys_mgr().App_img_dir().GenSubDir_nest("window", "portal");
Io_url img_dir = wiki.Appe().User().Fsys_mgr().App_img_dir().GenSubDir_nest("window", "portal");
Img_src_y = img_dir.GenSubFil("twisty_down.png").To_http_file_bry();
Img_src_n = img_dir.GenSubFil("twisty_right.png").To_http_file_bry();
}

View File

@@ -17,7 +17,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package gplx.xowa.apis.xowa.html.modules; import gplx.*; import gplx.xowa.*; import gplx.xowa.apis.*; import gplx.xowa.apis.xowa.*; import gplx.xowa.apis.xowa.html.*;
public class Xoapi_collapsible implements GfoInvkAble {
public void Init_by_kit(Xoa_app app) {
public void Init_by_kit(Xoae_app app) {
}
public boolean Collapsed() {return collapsed;} private boolean collapsed;
public Object Invk(GfsCtx ctx, int ikey, String k, GfoMsg m) {

View File

@@ -17,7 +17,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package gplx.xowa.apis.xowa.html.modules; import gplx.*; import gplx.xowa.*; import gplx.xowa.apis.*; import gplx.xowa.apis.xowa.*; import gplx.xowa.apis.xowa.html.*;
public class Xoapi_navframe implements GfoInvkAble {
public void Init_by_kit(Xoa_app app) {
public void Init_by_kit(Xoae_app app) {
}
public boolean Collapsed() {return collapsed;} private boolean collapsed;
public Object Invk(GfsCtx ctx, int ikey, String k, GfoMsg m) {

View File

@@ -18,12 +18,12 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
package gplx.xowa.apis.xowa.html.modules; import gplx.*; import gplx.xowa.*; import gplx.xowa.apis.*; import gplx.xowa.apis.xowa.*; import gplx.xowa.apis.xowa.html.*;
import gplx.xowa.html.modules.popups.*;
public class Xoapi_popups implements GfoInvkAble, GfoEvMgrOwner {
private Xoa_app app;
private Xoae_app app;
public Xoapi_popups() {
evMgr = GfoEvMgr.new_(this);
}
public GfoEvMgr EvMgr() {return evMgr;} private GfoEvMgr evMgr;
public void Init_by_app(Xoa_app app) {this.app = app;}
public void Init_by_app(Xoae_app app) {this.app = app;}
public boolean Enabled() {return enabled;} public void Enabled_(boolean v) {enabled = v;} private boolean enabled = true;
public int Show_init_word_count() {return show_init_word_count;} private int show_init_word_count = Dflt_show_init_word_count;
public int Show_more_word_count() {return show_more_word_count;} private int show_more_word_count = Dflt_show_more_word_count;
@@ -52,11 +52,11 @@ public class Xoapi_popups implements GfoInvkAble, GfoEvMgrOwner {
public byte[] Html_fmtr_next_sect_fmt() {return html_fmtr_next_sect;} private byte[] html_fmtr_next_sect = Dflt_html_fmtr_next_sect;
public byte[] Html_fmtr_next_sect_fmt_dflt() {return html_fmtr_next_sect_dflt;} private byte[] html_fmtr_next_sect_dflt = Dflt_html_fmtr_next_sect;
public void Show_more(String popup_id) {
Xow_wiki wiki = app.Gui_mgr().Browser_win().Active_tab().Page().Wiki();
Xowe_wiki wiki = app.Gui_mgr().Browser_win().Active_tab().Wiki();
wiki.Html_mgr().Module_mgr().Popup_mgr().Show_more(popup_id);
}
public void Show_all(String popup_id) {
Xow_wiki wiki = app.Gui_mgr().Browser_win().Active_tab().Page().Wiki();
Xowe_wiki wiki = app.Gui_mgr().Browser_win().Active_tab().Wiki();
wiki.Html_mgr().Module_mgr().Popup_mgr().Show_all(popup_id);
}
public Object Invk(GfsCtx ctx, int ikey, String k, GfoMsg m) {

View File

@@ -17,7 +17,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package gplx.xowa.apis.xowa.html.modules; import gplx.*; import gplx.xowa.*; import gplx.xowa.apis.*; import gplx.xowa.apis.xowa.*; import gplx.xowa.apis.xowa.html.*;
public class Xoapi_toc implements GfoInvkAble {
public void Init_by_kit(Xoa_app app) {
public void Init_by_kit(Xoae_app app) {
}
public boolean Collapsed() {return collapsed;} private boolean collapsed = false;
public Object Invk(GfsCtx ctx, int ikey, String k, GfoMsg m) {

View File

@@ -17,7 +17,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package gplx.xowa.apis.xowa.html.skins; import gplx.*; import gplx.xowa.*; import gplx.xowa.apis.*; import gplx.xowa.apis.xowa.*; import gplx.xowa.apis.xowa.html.*;
public class Xoapi_skin_app_base implements GfoInvkAble {
public void Init_by_kit(Xoa_app app) {
public void Init_by_kit(Xoae_app app) {
}
public boolean Sidebar_home_enabled() {return sidebar_home_enabled;} public void Sidebar_home_enabled_(boolean v) {sidebar_home_enabled = v;} private boolean sidebar_home_enabled;
public Object Invk(GfsCtx ctx, int ikey, String k, GfoMsg m) {

View File

@@ -19,14 +19,14 @@ package gplx.xowa.apis.xowa.navs; import gplx.*; import gplx.xowa.*; import gplx
import gplx.xowa.gui.views.*;
public class Xoapi_wiki implements GfoInvkAble {
private Xog_win_itm win;
public void Init_by_kit(Xoa_app app) {
public void Init_by_kit(Xoae_app app) {
win = app.Gui_mgr().Browser_win();
}
public void Random() {win.Page__navigate_by_url_bar("Special:Random");}
public void Sandbox() {win.Page__navigate_by_url_bar("Project:Sandbox");}
public void Main_page() {
win.Tab_mgr().Active_tab_assert(); // force an active tab in case all tabs are closed; needed for win.Active_page() below; DATE:2014-09-17
win.Page__navigate_by_url_bar(win.Active_page().Wiki().Domain_str() + Xoh_href_parser.Href_wiki_str); // NOTE: add "/wiki/" to generate non-page like url; EX: "home" -> "home/wiki/" which will be interpreted as a url, as opposed to "home" which will be intrepretted as page; DATE:2014-04-14
win.Page__navigate_by_url_bar(win.Active_tab().Wiki().Domain_str() + Xoh_href_parser.Href_wiki_str); // NOTE: add "/wiki/" to generate non-page like url; EX: "home" -> "home/wiki/" which will be interpreted as a url, as opposed to "home" which will be intrepretted as page; DATE:2014-04-14
}
public Object Invk(GfsCtx ctx, int ikey, String k, GfoMsg m) {
if (ctx.Match(k, Invk_main_page)) this.Main_page();

View File

@@ -18,7 +18,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
package gplx.xowa.apis.xowa.startups; import gplx.*; import gplx.xowa.*; import gplx.xowa.apis.*; import gplx.xowa.apis.xowa.*;
import gplx.xowa.apis.xowa.startups.tabs.*;
public class Xoapi_startups implements GfoInvkAble {
public void Init_by_kit(Xoa_app app) {
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) {

View File

@@ -41,7 +41,7 @@ public class Xoapi_startup_tabs implements GfoInvkAble {
, 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(Xoa_app app) {
public String[] Calc_startup_strs(Xoae_app app) {
ListAdp rv = ListAdp_.new_();
String xowa_home = gplx.xowa.users.Xouc_pages_mgr.Page_xowa;
if (manual == null) {
@@ -68,7 +68,7 @@ public class Xoapi_startup_tabs implements GfoInvkAble {
list.Add(itm);
}
}
private static void Add_xowa_home_if_new_version(ListAdp rv, Xoa_app app, String xowa_home) {
private static void Add_xowa_home_if_new_version(ListAdp 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();

View File

@@ -18,22 +18,22 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
package gplx.xowa.apis.xowa.usrs; import gplx.*; import gplx.xowa.*; import gplx.xowa.apis.*; import gplx.xowa.apis.xowa.*;
import gplx.xowa.gui.history.*; import gplx.xowa.gui.views.*;
public class Xoapi_bookmarks implements GfoInvkAble {
private Xoa_app app; private Xog_win_itm win;
public void Ctor_by_app(Xoa_app app) {this.app = app;}
public void Init_by_kit(Xoa_app app) {this.win = app.Gui_mgr().Browser_win();}
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 Add(String url_str) {
if (!enabled) return;
Xog_tab_itm tab = win.Active_tab(); if (tab == Xog_tab_itm_.Null) return;
Xoa_page page = tab.Page();
Xowe_wiki wiki = tab.Wiki(); Xoae_page page = tab.Page();
byte[] wiki_domain = null, ttl_full_txt = null;
if (url_str == null) {
wiki_domain = page.Wiki().Domain_bry();
wiki_domain = wiki.Domain_bry();
ttl_full_txt = page.Ttl().Full_txt();
}
else {
Xoa_url url = Xoa_url_parser.Parse_from_url_bar(app, page.Wiki(), url_str);
Xoa_url url = Xoa_url_parser.Parse_from_url_bar(app, wiki, url_str);
wiki_domain = url.Wiki_bry();
ttl_full_txt = url.Page_bry();
}

View File

@@ -18,9 +18,9 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
package gplx.xowa.apis.xowa.usrs; import gplx.*; import gplx.xowa.*; import gplx.xowa.apis.*; import gplx.xowa.apis.xowa.*;
import gplx.xowa.gui.views.*;
public class Xoapi_history implements GfoInvkAble {
private Xoa_app app; private Xog_win_itm win;
public void Ctor_by_app(Xoa_app app) {this.app = app;}
public void Init_by_kit(Xoa_app app) {this.win = app.Gui_mgr().Browser_win();}
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.User().History_mgr().Get_at_last());}

View File

@@ -18,9 +18,9 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
package gplx.xowa.apis.xowa.usrs; import gplx.*; import gplx.xowa.*; import gplx.xowa.apis.*; import gplx.xowa.apis.xowa.*;
import gplx.xowa.gui.views.*;
public class Xoapi_logs implements GfoInvkAble {
private Xoa_app app;
public void Ctor_by_app(Xoa_app app) {this.app = app;}
public void Init_by_kit(Xoa_app app) {}
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);

View File

@@ -18,8 +18,8 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
package gplx.xowa.apis.xowa.xtns; import gplx.*; import gplx.xowa.*; import gplx.xowa.apis.*; import gplx.xowa.apis.xowa.*;
import gplx.xowa.xtns.scribunto.*; import gplx.xowa.xtns.scribunto.engines.*;
public class Xoapi_scribunto implements GfoInvkAble {
private Xoa_app app;
public void Init_by_kit(Xoa_app app) {
private Xoae_app app;
public void Init_by_kit(Xoae_app app) {
this.app = app;
}
public void Engine_(byte v) {

View File

@@ -17,37 +17,38 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package gplx.xowa.apps; import gplx.*; import gplx.xowa.*;
import gplx.gfs.*;
import gplx.xowa.users.*;
import gplx.xowa.users.*; import gplx.xowa.apps.fsys.*;
public class Xoa_gfs_mgr implements GfoInvkAble, GfoInvkRootWkr {
public Xoa_gfs_mgr(Xoa_app app) {
this.app = app;
GfsCore._.AddCmd(app, Xoa_app.Invk_app);
GfsCore._.AddCmd(app, Xoa_app.Invk_xowa);
eval_mgr = new Xoa_app_eval(app);
} private Xoa_app app;
public Xoa_app_eval Eval_mgr() {return eval_mgr;} private Xoa_app_eval eval_mgr;
private final GfoInvkAble root_invk; private final Xoa_fsys_mgr app_fsys_mgr; private final Xou_fsys_mgr usr_fsys_mgr;
public Xoa_gfs_mgr(GfoInvkAble root_invk, Xoa_fsys_mgr app_fsys_mgr, Xou_fsys_mgr usr_fsys_mgr) {
this.root_invk = root_invk; this.app_fsys_mgr = app_fsys_mgr; this.usr_fsys_mgr = usr_fsys_mgr;
GfsCore._.AddCmd(root_invk, Xoae_app.Invk_app);
GfsCore._.AddCmd(root_invk, Xoae_app.Invk_xowa);
}
public GfoInvkAble Root_invk() {return root_invk;}
public Xoa_fsys_mgr App_fsys_mgr() {return app_fsys_mgr;}
public Xoa_app_eval Eval_mgr() {return eval_mgr;} private final Xoa_app_eval eval_mgr = new Xoa_app_eval();
private void Run_url_by_type(String type) {
Xou_fsys_mgr fsys_mgr = app.User().Fsys_mgr();
Io_url app_data_dir = fsys_mgr.App_data_dir();
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 = fsys_mgr.App_data_cfg_custom_fil();
else if (String_.Eq(type, "xowa_cfg_user")) url = 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_app")) url = app.Fsys_mgr().Root_dir().GenSubFil("xowa.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_app")) url = app_fsys_mgr.Root_dir().GenSubFil("xowa.gfs");
else throw Err_mgr._.fmt_(GRP_KEY, "invalid_gfs_type", "invalid gfs type: ~{0}", type);
try {Run_url(url);}
catch (Exception e) { // gfs is corrupt; may happen if multiple XOWAs opened, and "Close all" chosen in OS; DATE:2014-07-01
if (!String_.Eq(type, "xowa")) // check if user.gfs
Io_mgr._.MoveFil(url, url.GenNewNameOnly(url.NameOnly() + "-" + DateAdp_.Now().XtoStr_fmt_yyyyMMdd_HHmmss())); // move file
app.Usr_dlg().Warn_many("", "", "invalid gfs; obsoleting: src=~{0} err=~{1}", url.Raw(), Err_.Message_gplx(e));
Gfo_usr_dlg_._.Warn_many("", "", "invalid gfs; obsoleting: src=~{0} err=~{1}", url.Raw(), Err_.Message_gplx(e));
}
}
public GfoMsg Parse_root_msg(String v) {return gplx.gfs.Gfs_msg_bldr._.ParseToMsg(v);}
public Gfs_wtr Wtr() {return wtr;} private Gfs_wtr wtr = new Gfs_wtr();
public void Run_url(Io_url url) {
Run_url_for(GfsCore._.Root(), url);
app.Log_wtr().Log_msg_to_session_fmt("gfs.done: ~{0}", url.Raw());
Gfo_usr_dlg_._.Log_wtr().Log_msg_to_session_fmt("gfs.done: ~{0}", url.Raw());
}
public void Run_url_for(GfoInvkAble invk, Io_url url) {
String raw = Io_mgr._.LoadFilStr_args(url).MissingIgnored_().Exec(); if (String_.Len_eq_0(raw)) return;
@@ -58,7 +59,7 @@ public class Xoa_gfs_mgr implements GfoInvkAble, GfoInvkRootWkr {
public Object Run_str_for(GfoInvkAble invk, GfoMsg root_msg) {
try {
int sub_msgs_len = root_msg.Subs_count();
GfsCtx ctx = GfsCtx.new_().Fail_if_unhandled_(Fail_if_unhandled).Usr_dlg_(app.Usr_dlg());
GfsCtx ctx = GfsCtx.new_().Fail_if_unhandled_(Fail_if_unhandled).Usr_dlg_(Gfo_usr_dlg_._);
Object rv = null;
for (int i = 0; i < sub_msgs_len; i++) {
GfoMsg sub_msg = root_msg.Subs_getAt(i);
@@ -66,13 +67,13 @@ public class Xoa_gfs_mgr implements GfoInvkAble, GfoInvkRootWkr {
}
return rv;
} catch (Exception e) {
app.Usr_dlg().Warn_many("", "", "error while executing script: err=~{0}", Err_.Message_gplx(e));
Gfo_usr_dlg_._.Warn_many("", "", "error while executing script: err=~{0}", Err_.Message_gplx(e));
return GfoInvkAble_.Rv_error;
}
}
public GfoEvObj Get_owner_as_event_obj(String cmd) {
GfoMsg cur_msg = Parse_root_msg(cmd).Subs_getAt(0); // ignore root_msg which is ""
GfoInvkAble cur_invk = app;
GfoInvkAble cur_invk = root_invk;
while (true) {
if (cur_msg.Subs_count() == 0) return (GfoEvObj)cur_invk; // terminal msg; return cur_invk
cur_invk = (GfoInvkAble)GfoInvkAble_.InvkCmd(cur_invk, cur_msg.Key());

View File

@@ -17,7 +17,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package gplx.xowa.apps; import gplx.*; import gplx.xowa.*;
public class Xoa_shell implements GfoInvkAble {
public Xoa_shell(Xoa_app app) {this.app = app;} private Xoa_app app;
public Xoa_shell(Xoae_app app) {this.app = app;} private Xoae_app app;
public boolean Fetch_page_exec_async() {return fetch_page_exec_async;} private boolean fetch_page_exec_async = true;
public Object Invk(GfsCtx ctx, int ikey, String k, GfoMsg m) {
if (ctx.Match(k, Invk_fetch_page)) return Fetch_page(m);

View File

@@ -20,7 +20,7 @@ import org.junit.*;
public class Xoa_shell_tst {
@Test public void Fetch_page() { // PURPOSE.fix: fetch_page failed with nullRef; DATE:2013-04-12
Xop_fxt parser_fxt = new Xop_fxt();
Xoa_app app = parser_fxt.App(); Xow_wiki wiki = parser_fxt.Wiki();
Xoae_app app = parser_fxt.App(); Xowe_wiki wiki = parser_fxt.Wiki();
parser_fxt.Init_page_create("A", "test"); // need to create page in order for html output to gen
wiki.Html_mgr().Page_wtr_mgr().Html_capable_(true); // need to set html_capable in order for div_home to load
Xoa_gfs_mgr.Msg_parser_init();

View File

@@ -16,27 +16,27 @@ 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.fsys; import gplx.*; import gplx.xowa.*; import gplx.xowa.apps.*;
import gplx.core.primitives.*;
import gplx.core.primitives.*; import gplx.xowa.users.*;
public class Xoa_fsys_eval implements Bry_fmtr_eval_mgr {
public Xoa_fsys_eval(Xoa_app app) {this.app = app;} private Xoa_app app;
private final Xoa_fsys_mgr app_fsys_mgr; private final Xou_fsys_mgr usr_fsys_mgr;
public Xoa_fsys_eval(Xoa_fsys_mgr app_fsys_mgr, Xou_fsys_mgr usr_fsys_mgr) {this.app_fsys_mgr = app_fsys_mgr; this.usr_fsys_mgr = usr_fsys_mgr;}
public boolean Enabled() {return enabled;} public void Enabled_(boolean v) {enabled = v;} private boolean enabled = true;
public byte[] Eval(byte[] cmd) {
Object o = hash.Get_by_bry(cmd);
if (o == null) return null;
Object o = hash.Get_by_bry(cmd); if (o == null) return null;
byte val = ((Byte_obj_val)o).Val();
switch (val) {
case Tid_bin_plat_dir: return app.Fsys_mgr().Bin_plat_dir().RawBry();
case Tid_user_temp_dir: return app.User().Fsys_mgr().App_temp_dir().RawBry();
case Tid_xowa_root_dir: return app.Fsys_mgr().Root_dir().RawBry();
case Tid_user_cfg_dir: return app.User().Fsys_mgr().App_data_cfg_dir().RawBry();
case Tid_xowa_root_dir: return app_fsys_mgr.Root_dir().RawBry();
case Tid_bin_plat_dir: return app_fsys_mgr.Bin_plat_dir().RawBry();
case Tid_user_temp_dir: return usr_fsys_mgr.App_temp_dir().RawBry();
case Tid_user_cfg_dir: return usr_fsys_mgr.App_data_cfg_dir().RawBry();
default: throw Err_mgr._.unhandled_(val);
}
}
private static final byte Tid_bin_plat_dir = 0, Tid_user_temp_dir = 1, Tid_xowa_root_dir = 2, Tid_user_cfg_dir = 3;
private static final Hash_adp_bry hash = Hash_adp_bry.ci_ascii_()
.Add_str_byte("bin_plat_dir", Tid_bin_plat_dir)
.Add_str_byte("user_temp_dir", Tid_user_temp_dir)
.Add_str_byte("xowa_root_dir", Tid_xowa_root_dir)
.Add_str_byte("user_cfg_dir", Tid_user_cfg_dir)
.Add_str_byte("bin_plat_dir" , Tid_bin_plat_dir)
.Add_str_byte("user_temp_dir" , Tid_user_temp_dir)
.Add_str_byte("xowa_root_dir" , Tid_xowa_root_dir)
.Add_str_byte("user_cfg_dir" , Tid_user_cfg_dir)
;
}

View File

@@ -17,36 +17,32 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package gplx.xowa.apps.fsys; import gplx.*; import gplx.xowa.*; import gplx.xowa.apps.*;
public class Xoa_fsys_mgr implements GfoInvkAble {
public Xoa_fsys_mgr() {} // DRD
public Xoa_fsys_mgr(String plat_name, Io_url root_dir) {
Init_by_boot(plat_name, root_dir);
}
public Io_url Root_dir() {return root_dir;} private Io_url root_dir;
public byte[] Root_dir_bry() {return root_dir_bry;} private byte[] root_dir_bry;
public Io_url File_dir() {return file_dir;} private Io_url file_dir;
public Io_url Wiki_dir() {return wiki_dir;} private Io_url wiki_dir;
public Io_url Wiki_dir() {return wiki_dir;} public void Wiki_dir_(Io_url v) {wiki_dir = v;} private Io_url wiki_dir;
public Io_url Bin_plat_dir() {return bin_plat_dir;} private Io_url bin_plat_dir;
public Io_url Bin_any_dir() {return bin_any_dir;} private Io_url bin_any_dir;
public Io_url Bin_xowa_dir() {return bin_any_dir.GenSubDir("xowa");}
public Io_url Bin_xowa_dir() {return bin_xowa_dir;} private Io_url bin_xowa_dir;
public Io_url Bin_xtns_dir() {return bin_xtns_dir;} private Io_url bin_xtns_dir;
public Io_url Cfg_lang_core_dir() {return cfg_lang_core_dir;} private Io_url cfg_lang_core_dir;
public Io_url Cfg_wiki_core_dir() {return cfg_wiki_core_dir;} private Io_url cfg_wiki_core_dir;
public Io_url Bin_data_os_cfg_fil() {return bin_plat_dir.GenSubFil_nest("xowa", "cfg", Xoa_gfs_mgr.Cfg_os);}
public void Init_by_boot(String plat_name, Io_url root_dir) {
private void Init_by_boot(String plat_name, Io_url root_dir) {
this.root_dir = root_dir;
root_dir_bry = root_dir.To_http_file_bry();
file_dir = root_dir.GenSubDir("file");
bin_plat_dir = root_dir.GenSubDir("bin").GenSubDir(plat_name);
bin_any_dir = root_dir.GenSubDir("bin").GenSubDir("any");
bin_xowa_dir = bin_any_dir.GenSubDir("xowa");
bin_xtns_dir = bin_any_dir.GenSubDir_nest("xowa", "xtns");
cfg_lang_core_dir = bin_any_dir.GenSubDir_nest("xowa", "cfg", "lang", "core");
cfg_wiki_core_dir = bin_any_dir.GenSubDir_nest("xowa", "cfg", "wiki", "core");
Wiki_dir_ (root_dir.GenSubDir("wiki"));
}
public Xoa_fsys_mgr Wiki_dir_(Io_url v) {
wiki_dir = v;
return this;
}
public void Init_by_app(GfoInvkAble app_mgr_invk) {// for gfs and app.launcher
this.app_mgr_invk = app_mgr_invk;
} private GfoInvkAble app_mgr_invk;
@@ -56,5 +52,4 @@ public class Xoa_fsys_mgr implements GfoInvkAble {
else return GfoInvkAble_.Rv_unhandled;
}
private static final String Invk_apps = "apps", Invk_root_dir = "root_dir";
public static final String DirName_wiki = "wiki", DirName_user = "user";
}

View File

@@ -15,33 +15,33 @@ 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.fsys; import gplx.*; import gplx.xowa.*; import gplx.xowa.apps.*;
public class Launcher_app_mgr implements GfoInvkAble {
public Launcher_app_mgr(Xoa_app app) {this.app = app;} private Xoa_app app;
public void Init() {
Xoa_fsys_eval cmd_eval = app.Url_cmd_eval();
ProcessAdp.ini_(this, app.Gui_wtr(), app_query_img_size , cmd_eval, ProcessAdp.Run_mode_sync_timeout , 10 * 60, "~{<>bin_plat_dir<>}imagemagick\\identify", "-ping -format \"<{%w,%h}>\" \"~{file}\"", "file");
ProcessAdp.ini_(this, app.Gui_wtr(), app_resize_img , cmd_eval, ProcessAdp.Run_mode_sync_timeout , 10 * 60, "~{<>bin_plat_dir<>}imagemagick\\convert", "\"~{source}\" -coalesce -resize ~{width}x~{height} \"~{target}\"", "source", "target", "width", "height");
ProcessAdp.ini_(this, app.Gui_wtr(), app_convert_svg_to_png , cmd_eval, ProcessAdp.Run_mode_sync_timeout , 10 * 60, "~{<>bin_plat_dir<>}inkscape\\inkscape", "-z -w ~{width} -f \"~{source}\" -e \"~{target}\"", "source", "target", "width").Thread_kill_name_("inkscape.exe"); // // -z=without-gui; -w=width; -f=file -e=export-png
ProcessAdp.ini_(this, app.Gui_wtr(), app_convert_tex_to_dvi , cmd_eval, ProcessAdp.Run_mode_sync_timeout , 2 * 60, "~{<>bin_plat_dir<>}miktex\\miktex\\bin\\latex", "-quiet -output-directory=~{temp_dir} -job-name=xowa_temp ~{tex_file}", "tex_file", "temp_dir");
ProcessAdp.ini_(this, app.Gui_wtr(), app_convert_dvi_to_png , cmd_eval, ProcessAdp.Run_mode_sync_timeout , 2 * 60, "~{<>bin_plat_dir<>}miktex\\miktex\\bin\\dvipng", "~{dvi_file} -o ~{png_file} -q* -T tight -bg Transparent", "dvi_file", "png_file", "temp_dir");
ProcessAdp.ini_(this, app.Gui_wtr(), app_convert_djvu_to_tiff , cmd_eval, ProcessAdp.Run_mode_sync_timeout , 1 * 60, "~{<>bin_plat_dir<>}djvulibre\\ddjvu", "-format=tiff -page=1 \"~{source}\" \"~{target}\"", "source", "target");
ProcessAdp.ini_(this, app.Gui_wtr(), app_decompress_bz2 , cmd_eval, ProcessAdp.Run_mode_sync_timeout , 0 , "~{<>bin_plat_dir<>}7-zip\\7za", "x -y \"~{src}\" -o\"~{trg_dir}\"", "src", "trg", "trg_dir"); // x=extract; -y=yes on all queries; -o=output_dir
ProcessAdp.ini_(this, app.Gui_wtr(), app_decompress_bz2_by_stdout, cmd_eval, ProcessAdp.Run_mode_sync_timeout , 0 , "~{<>bin_plat_dir<>}7-zip\\7za", "x -so \"~{src}\"", "src"); // x=extract; -so=stdout
ProcessAdp.ini_(this, app.Gui_wtr(), app_decompress_zip , cmd_eval, ProcessAdp.Run_mode_sync_timeout , 0 , "~{<>bin_plat_dir<>}7-zip\\7za", "x -y \"~{src}\" -o\"~{trg_dir}\"", "src", "trg", "trg_dir"); // x=extract; -y=yes on all queries; -o=output_dir
ProcessAdp.ini_(this, app.Gui_wtr(), app_decompress_gz , cmd_eval, ProcessAdp.Run_mode_sync_timeout , 0 , "~{<>bin_plat_dir<>}7-zip\\7za", "x -y \"~{src}\" -o\"~{trg_dir}\"", "src", "trg", "trg_dir"); // x=extract; -y=yes on all queries; -o=output_dir
ProcessAdp.ini_(this, app.Gui_wtr(), app_lua , cmd_eval, ProcessAdp.Run_mode_async , 0 , "~{<>bin_plat_dir<>}lua\\lua", "", "");
ProcessAdp.ini_(this, app.Gui_wtr(), app_lilypond , cmd_eval, ProcessAdp.Run_mode_sync_timeout , 1 * 60, "~{<>bin_plat_dir<>}lilypond\\usr\\bin\\lilypond.exe", "\"-dsafe=#t\" -dbackend=ps --png --header=texidoc -dmidi-extension=midi \"~{file}\"", "file");
ProcessAdp.ini_(this, app.Gui_wtr(), app_abc2ly , cmd_eval, ProcessAdp.Run_mode_sync_timeout , 1 * 60, "~{<>bin_plat_dir<>}lilypond\\usr\\bin\\python.exe", "abc2ly.py -s \"--output=~{target}\" \"~{source}\"", "source", "target");
ProcessAdp.ini_(this, app.Gui_wtr(), app_trim_img , cmd_eval, ProcessAdp.Run_mode_sync_timeout , 1 * 60, "~{<>bin_plat_dir<>}imagemagick\\convert", "-trim \"~{source}\" \"~{target}\"", "source", "target");
ProcessAdp.ini_(this, app.Gui_wtr(), app_convert_midi_to_ogg , cmd_eval, ProcessAdp.Run_mode_sync_timeout , 1 * 60, "~{<>bin_plat_dir<>}timidity\\timidity", "-Ov \"--output-file=~{target}\" \"~{source}\"", "source", "target");
ProcessAdp.ini_(this, app.Gui_wtr(), app_view_web , cmd_eval, ProcessAdp.Run_mode_async , 0 , "cmd", "/c start \"~{url}\"", "url");
ProcessAdp.ini_(this, app.Gui_wtr(), app_view_text , cmd_eval, ProcessAdp.Run_mode_async , 0 , "cmd", "/c start \"~{url}\"", "url");
package gplx.xowa.apps.progs; import gplx.*; import gplx.xowa.*; import gplx.xowa.apps.*;
import gplx.xowa.apps.fsys.*;
public class Xoa_prog_mgr implements GfoInvkAble {
public void Init_by_app(Xoa_fsys_eval cmd_eval) {
Gfo_usr_dlg usr_dlg = Xoa_app_.Usr_dlg();
ProcessAdp.ini_(this, usr_dlg, app_query_img_size , cmd_eval, ProcessAdp.Run_mode_sync_timeout , 10 * 60, "~{<>bin_plat_dir<>}imagemagick\\identify", "-ping -format \"<{%w,%h}>\" \"~{file}\"", "file");
ProcessAdp.ini_(this, usr_dlg, app_resize_img , cmd_eval, ProcessAdp.Run_mode_sync_timeout , 10 * 60, "~{<>bin_plat_dir<>}imagemagick\\convert", "\"~{source}\" -coalesce -resize ~{width}x~{height} \"~{target}\"", "source", "target", "width", "height");
ProcessAdp.ini_(this, usr_dlg, app_convert_svg_to_png , cmd_eval, ProcessAdp.Run_mode_sync_timeout , 10 * 60, "~{<>bin_plat_dir<>}inkscape\\inkscape", "-z -w ~{width} -f \"~{source}\" -e \"~{target}\"", "source", "target", "width").Thread_kill_name_("inkscape.exe"); // // -z=without-gui; -w=width; -f=file -e=export-png
ProcessAdp.ini_(this, usr_dlg, app_convert_tex_to_dvi , cmd_eval, ProcessAdp.Run_mode_sync_timeout , 2 * 60, "~{<>bin_plat_dir<>}miktex\\miktex\\bin\\latex", "-quiet -output-directory=~{temp_dir} -job-name=xowa_temp ~{tex_file}", "tex_file", "temp_dir");
ProcessAdp.ini_(this, usr_dlg, app_convert_dvi_to_png , cmd_eval, ProcessAdp.Run_mode_sync_timeout , 2 * 60, "~{<>bin_plat_dir<>}miktex\\miktex\\bin\\dvipng", "~{dvi_file} -o ~{png_file} -q* -T tight -bg Transparent", "dvi_file", "png_file", "temp_dir");
ProcessAdp.ini_(this, usr_dlg, app_convert_djvu_to_tiff , cmd_eval, ProcessAdp.Run_mode_sync_timeout , 1 * 60, "~{<>bin_plat_dir<>}djvulibre\\ddjvu", "-format=tiff -page=1 \"~{source}\" \"~{target}\"", "source", "target");
ProcessAdp.ini_(this, usr_dlg, app_decompress_bz2 , cmd_eval, ProcessAdp.Run_mode_sync_timeout , 0 , "~{<>bin_plat_dir<>}7-zip\\7za", "x -y \"~{src}\" -o\"~{trg_dir}\"", "src", "trg", "trg_dir"); // x=extract; -y=yes on all queries; -o=output_dir
ProcessAdp.ini_(this, usr_dlg, app_decompress_bz2_by_stdout , cmd_eval, ProcessAdp.Run_mode_sync_timeout , 0 , "~{<>bin_plat_dir<>}7-zip\\7za", "x -so \"~{src}\"", "src"); // x=extract; -so=stdout
ProcessAdp.ini_(this, usr_dlg, app_decompress_zip , cmd_eval, ProcessAdp.Run_mode_sync_timeout , 0 , "~{<>bin_plat_dir<>}7-zip\\7za", "x -y \"~{src}\" -o\"~{trg_dir}\"", "src", "trg", "trg_dir"); // x=extract; -y=yes on all queries; -o=output_dir
ProcessAdp.ini_(this, usr_dlg, app_decompress_gz , cmd_eval, ProcessAdp.Run_mode_sync_timeout , 0 , "~{<>bin_plat_dir<>}7-zip\\7za", "x -y \"~{src}\" -o\"~{trg_dir}\"", "src", "trg", "trg_dir"); // x=extract; -y=yes on all queries; -o=output_dir
ProcessAdp.ini_(this, usr_dlg, app_lua , cmd_eval, ProcessAdp.Run_mode_async , 0 , "~{<>bin_plat_dir<>}lua\\lua", "", "");
ProcessAdp.ini_(this, usr_dlg, app_lilypond , cmd_eval, ProcessAdp.Run_mode_sync_timeout , 1 * 60, "~{<>bin_plat_dir<>}lilypond\\usr\\bin\\lilypond.exe", "\"-dsafe=#t\" -dbackend=ps --png --header=texidoc -dmidi-extension=midi \"~{file}\"", "file");
ProcessAdp.ini_(this, usr_dlg, app_abc2ly , cmd_eval, ProcessAdp.Run_mode_sync_timeout , 1 * 60, "~{<>bin_plat_dir<>}lilypond\\usr\\bin\\python.exe", "abc2ly.py -s \"--output=~{target}\" \"~{source}\"", "source", "target");
ProcessAdp.ini_(this, usr_dlg, app_trim_img , cmd_eval, ProcessAdp.Run_mode_sync_timeout , 1 * 60, "~{<>bin_plat_dir<>}imagemagick\\convert", "-trim \"~{source}\" \"~{target}\"", "source", "target");
ProcessAdp.ini_(this, usr_dlg, app_convert_midi_to_ogg , cmd_eval, ProcessAdp.Run_mode_sync_timeout , 1 * 60, "~{<>bin_plat_dir<>}timidity\\timidity", "-Ov \"--output-file=~{target}\" \"~{source}\"", "source", "target");
ProcessAdp.ini_(this, usr_dlg, app_view_web , cmd_eval, ProcessAdp.Run_mode_async , 0 , "cmd", "/c start \"~{url}\"", "url");
ProcessAdp.ini_(this, usr_dlg, app_view_text , cmd_eval, ProcessAdp.Run_mode_async , 0 , "cmd", "/c start \"~{url}\"", "url");
int cmds_view_file_by_ext_len = cmds_view_file_by_ext.length;
for (int i= 0; i < cmds_view_file_by_ext_len; i++) {
ProcessAdp cmd = new ProcessAdp();
cmds_view_file_by_ext [i] = cmd;
ProcessAdp.ini_(this, app.Gui_wtr(), cmd , cmd_eval, ProcessAdp.Run_mode_async , 0 , "cmd", "/c start \"~{file}\"", "file");
ProcessAdp.ini_(this, usr_dlg, cmd , cmd_eval, ProcessAdp.Run_mode_async , 0 , "cmd", "/c start \"~{file}\"", "file");
}
}
public ProcessAdp App_query_img_size() {return app_query_img_size;} private ProcessAdp app_query_img_size = new ProcessAdp();

Some files were not shown because too many files have changed in this diff Show More