Compare commits
29 Commits
master
...
gajuexpress
| Author | SHA1 | Date | |
|---|---|---|---|
| 547cbc319d | |||
| 8335e326bd | |||
| 7a65a8c50f | |||
| c3888d1c2f | |||
| cf4a3856b9 | |||
| ed40cc0ac6 | |||
| 14624bfff2 | |||
| 7bd37e972b | |||
| 5885f7f1d7 | |||
| 170ebcd4eb | |||
| 2c9d188761 | |||
| 0a217049b1 | |||
| 77ff0ca084 | |||
| 3259e802db | |||
| e0ebfade97 | |||
| e5dcce341e | |||
| e158706937 | |||
| 7192a35d89 | |||
| b256db6ff6 | |||
| 0dde228e6b | |||
| 9b2fe74e83 | |||
| 1cab4f5218 | |||
| 6fd62f5cdb | |||
| 821a0a293d | |||
| bf93fc27b0 | |||
| 127fba5f8f | |||
| e7478dd35d | |||
| fb0e33f350 | |||
| c4a2f12657 |
+3
-2
@@ -3,8 +3,9 @@
|
|||||||
{registered,[]},
|
{registered,[]},
|
||||||
{included_applications,[]},
|
{included_applications,[]},
|
||||||
{applications,[stdlib,kernel,sasl,ssl]},
|
{applications,[stdlib,kernel,sasl,ssl]},
|
||||||
{vsn,"0.9.0"},
|
{vsn,"0.10.0"},
|
||||||
{modules,[gajudesk,gd_con,gd_grids,gd_gui,gd_jt,gd_lib,
|
{modules,[gajudesk,gd_con,gd_grids,gd_gui,gd_jt,gd_lib,
|
||||||
gd_m_spend,gd_m_wallet_importer,gd_sophia_editor,
|
gd_m_spend,gd_m_wallet_importer,gd_sophia_editor,
|
||||||
gd_sup,gd_v,gd_v_devman,gd_v_netman,gd_v_wallman]},
|
gd_sup,gd_v,gd_v_call,gd_v_devman,gd_v_netman,
|
||||||
|
gd_v_wallman]},
|
||||||
{mod,{gajudesk,[]}}]}.
|
{mod,{gajudesk,[]}}]}.
|
||||||
|
|||||||
@@ -0,0 +1,9 @@
|
|||||||
|
send(Socket, Binary) ->
|
||||||
|
case gen_tcp:send(Socket, Binary) of
|
||||||
|
ok ->
|
||||||
|
ok;
|
||||||
|
Error ->
|
||||||
|
ok = tell(info, "Failure on ~w:send/2: ~p", [?MODULE, Error]),
|
||||||
|
ok = zx_net:disconnect(Socket),
|
||||||
|
exit(normal)
|
||||||
|
end.
|
||||||
+1
-1
@@ -3,7 +3,7 @@
|
|||||||
%%% @end
|
%%% @end
|
||||||
|
|
||||||
-module(gajudesk).
|
-module(gajudesk).
|
||||||
-vsn("0.9.0").
|
-vsn("0.10.0").
|
||||||
-behavior(application).
|
-behavior(application).
|
||||||
-author("Craig Everett <craigeverett@qpq.swiss>").
|
-author("Craig Everett <craigeverett@qpq.swiss>").
|
||||||
-copyright("QPQ AG <info@qpq.swiss>").
|
-copyright("QPQ AG <info@qpq.swiss>").
|
||||||
|
|||||||
+90
-73
@@ -3,19 +3,19 @@
|
|||||||
%%% @end
|
%%% @end
|
||||||
|
|
||||||
-module(gd_con).
|
-module(gd_con).
|
||||||
-vsn("0.9.0").
|
-vsn("0.10.0").
|
||||||
-author("Craig Everett <craigeverett@qpq.swiss>").
|
-author("Craig Everett <craigeverett@qpq.swiss>").
|
||||||
-copyright("QPQ AG <info@qpq.swiss>").
|
-copyright("QPQ AG <info@qpq.swiss>").
|
||||||
-license("GPL-3.0-or-later").
|
-license("GPL-3.0-or-later").
|
||||||
|
|
||||||
-behavior(gen_server).
|
% -behavior(gd_server).
|
||||||
-export([show_ui/1,
|
-export([show_ui/1,
|
||||||
open_wallet/2, close_wallet/0, new_wallet/4, import_wallet/3, drop_wallet/2,
|
open_wallet/2, close_wallet/0, new_wallet/4, import_wallet/3, drop_wallet/2,
|
||||||
selected/1, network/0,
|
selected/1, network/0,
|
||||||
password/2,
|
password/2,
|
||||||
refresh/0,
|
refresh/0,
|
||||||
nonce/1, spend/1, chain_id/0, grids/1,
|
nonce/1, spend/1, chain_id/0, grids/1,
|
||||||
sign_mess/1, sign_binary/1, sign_tx/1, sign_call/3,
|
sign_mess/1, sign_binary/1, sign_binary/2, sign_tx/1, sign_call/3,
|
||||||
deploy/1, prompt_call/3, list_calls/0,
|
deploy/1, prompt_call/3, list_calls/0,
|
||||||
open_contract/1, open_contract/2, show_call/2, show_call/3,
|
open_contract/1, open_contract/2, show_call/2, show_call/3,
|
||||||
make_key/6, recover_key/1, mnemonic/1, rename_key/2, drop_key/1, list_keys/0,
|
make_key/6, recover_key/1, mnemonic/1, rename_key/2, drop_key/1, list_keys/0,
|
||||||
@@ -25,6 +25,7 @@
|
|||||||
-export([save/2]).
|
-export([save/2]).
|
||||||
-export([start_link/0, stop/0]).
|
-export([start_link/0, stop/0]).
|
||||||
-export([init/1, terminate/2, code_change/3,
|
-export([init/1, terminate/2, code_change/3,
|
||||||
|
system_get_state/1, format_status/1,
|
||||||
handle_call/3, handle_cast/2, handle_info/2]).
|
handle_call/3, handle_cast/2, handle_info/2]).
|
||||||
-include("$zx_include/zx_logger.hrl").
|
-include("$zx_include/zx_logger.hrl").
|
||||||
-include("gd.hrl").
|
-include("gd.hrl").
|
||||||
@@ -54,7 +55,8 @@
|
|||||||
-type state() :: #s{}.
|
-type state() :: #s{}.
|
||||||
-type ui_name() :: gd_v_netman
|
-type ui_name() :: gd_v_netman
|
||||||
| gd_v_wallman
|
| gd_v_wallman
|
||||||
| gd_v_devman.
|
| gd_v_fateweaver
|
||||||
|
| gd_v_express.
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@@ -65,7 +67,7 @@
|
|||||||
when Name :: ui_name().
|
when Name :: ui_name().
|
||||||
|
|
||||||
show_ui(Name) ->
|
show_ui(Name) ->
|
||||||
gen_server:call(?MODULE, {show_ui, Name}).
|
gd_server:call(?MODULE, {show_ui, Name}).
|
||||||
|
|
||||||
|
|
||||||
-spec open_wallet(Path, Phrase) -> Result
|
-spec open_wallet(Path, Phrase) -> Result
|
||||||
@@ -74,13 +76,13 @@ show_ui(Name) ->
|
|||||||
Result :: ok | {error, Reason :: term()}.
|
Result :: ok | {error, Reason :: term()}.
|
||||||
|
|
||||||
open_wallet(Path, Phrase) ->
|
open_wallet(Path, Phrase) ->
|
||||||
gen_server:call(?MODULE, {open_wallet, Path, Phrase}, infinity).
|
gd_server:call(?MODULE, {open_wallet, Path, Phrase}, infinity).
|
||||||
|
|
||||||
|
|
||||||
-spec close_wallet() -> ok.
|
-spec close_wallet() -> ok.
|
||||||
|
|
||||||
close_wallet() ->
|
close_wallet() ->
|
||||||
gen_server:cast(?MODULE, close_wallet).
|
gd_server:cast(?MODULE, close_wallet).
|
||||||
|
|
||||||
|
|
||||||
-spec new_wallet(Net, Name, Path, Password) -> ok
|
-spec new_wallet(Net, Name, Path, Password) -> ok
|
||||||
@@ -90,7 +92,7 @@ close_wallet() ->
|
|||||||
Password :: string().
|
Password :: string().
|
||||||
|
|
||||||
new_wallet(Net, Name, Path, Password) ->
|
new_wallet(Net, Name, Path, Password) ->
|
||||||
gen_server:cast(?MODULE, {new_wallet, Net, Name, Path, Password}).
|
gd_server:cast(?MODULE, {new_wallet, Net, Name, Path, Password}).
|
||||||
|
|
||||||
|
|
||||||
-spec import_wallet(Name, Path, Password) -> ok
|
-spec import_wallet(Name, Path, Password) -> ok
|
||||||
@@ -99,7 +101,7 @@ new_wallet(Net, Name, Path, Password) ->
|
|||||||
Password :: string().
|
Password :: string().
|
||||||
|
|
||||||
import_wallet(Name, Path, Password) ->
|
import_wallet(Name, Path, Password) ->
|
||||||
gen_server:cast(?MODULE, {import_wallet, Name, Path, Password}).
|
gd_server:cast(?MODULE, {import_wallet, Name, Path, Password}).
|
||||||
|
|
||||||
|
|
||||||
-spec drop_wallet(Path, Delete) -> ok
|
-spec drop_wallet(Path, Delete) -> ok
|
||||||
@@ -107,21 +109,21 @@ import_wallet(Name, Path, Password) ->
|
|||||||
Delete :: boolean().
|
Delete :: boolean().
|
||||||
|
|
||||||
drop_wallet(Path, Delete) ->
|
drop_wallet(Path, Delete) ->
|
||||||
gen_server:cast(?MODULE, {drop_wallet, Path, Delete}).
|
gd_server:cast(?MODULE, {drop_wallet, Path, Delete}).
|
||||||
|
|
||||||
|
|
||||||
-spec selected(Index) -> ok
|
-spec selected(Index) -> ok
|
||||||
when Index :: pos_integer() | none.
|
when Index :: pos_integer() | none.
|
||||||
|
|
||||||
selected(Index) ->
|
selected(Index) ->
|
||||||
gen_server:cast(?MODULE, {selected, Index}).
|
gd_server:cast(?MODULE, {selected, Index}).
|
||||||
|
|
||||||
|
|
||||||
-spec network() -> {ok, NetworkID} | none
|
-spec network() -> {ok, NetworkID} | none
|
||||||
when NetworkID :: binary().
|
when NetworkID :: binary().
|
||||||
|
|
||||||
network() ->
|
network() ->
|
||||||
gen_server:call(?MODULE, network).
|
gd_server:call(?MODULE, network).
|
||||||
|
|
||||||
|
|
||||||
-spec password(Old, New) -> ok
|
-spec password(Old, New) -> ok
|
||||||
@@ -129,13 +131,13 @@ network() ->
|
|||||||
New :: none | string().
|
New :: none | string().
|
||||||
|
|
||||||
password(Old, New) ->
|
password(Old, New) ->
|
||||||
gen_server:cast(?MODULE, {password, Old, New}).
|
gd_server:cast(?MODULE, {password, Old, New}).
|
||||||
|
|
||||||
|
|
||||||
-spec refresh() -> ok.
|
-spec refresh() -> ok.
|
||||||
|
|
||||||
refresh() ->
|
refresh() ->
|
||||||
gen_server:cast(?MODULE, refresh).
|
gd_server:cast(?MODULE, refresh).
|
||||||
|
|
||||||
|
|
||||||
-spec nonce(ID) -> {ok, Nonce} | {error, Reason}
|
-spec nonce(ID) -> {ok, Nonce} | {error, Reason}
|
||||||
@@ -144,48 +146,57 @@ refresh() ->
|
|||||||
Reason :: term(). % FIXME
|
Reason :: term(). % FIXME
|
||||||
|
|
||||||
nonce(ID) ->
|
nonce(ID) ->
|
||||||
gen_server:call(?MODULE, {nonce, ID}).
|
gd_server:call(?MODULE, {nonce, ID}).
|
||||||
|
|
||||||
|
|
||||||
-spec spend(TX) -> ok
|
-spec spend(TX) -> ok
|
||||||
when TX :: #spend_tx{}.
|
when TX :: #spend_tx{}.
|
||||||
|
|
||||||
spend(TX) ->
|
spend(TX) ->
|
||||||
gen_server:cast(?MODULE, {spend, TX}).
|
gd_server:cast(?MODULE, {spend, TX}).
|
||||||
|
|
||||||
|
|
||||||
-spec chain_id() -> {ok, ID}
|
-spec chain_id() -> {ok, ID}
|
||||||
when ID :: binary().
|
when ID :: binary().
|
||||||
|
|
||||||
chain_id() ->
|
chain_id() ->
|
||||||
gen_server:call(?MODULE, chain_id).
|
gd_server:call(?MODULE, chain_id).
|
||||||
|
|
||||||
|
|
||||||
-spec grids(string()) -> ok.
|
-spec grids(string()) -> ok.
|
||||||
|
|
||||||
grids(String) ->
|
grids(String) ->
|
||||||
gen_server:cast(?MODULE, {grids, String}).
|
gd_server:cast(?MODULE, {grids, String}).
|
||||||
|
|
||||||
|
|
||||||
-spec sign_mess(Request) -> ok
|
-spec sign_mess(Request) -> ok
|
||||||
when Request :: map().
|
when Request :: map().
|
||||||
|
|
||||||
sign_mess(Request) ->
|
sign_mess(Request) ->
|
||||||
gen_server:cast(?MODULE, {sign_mess, Request}).
|
gd_server:cast(?MODULE, {sign_mess, Request}).
|
||||||
|
|
||||||
|
|
||||||
-spec sign_binary(Request) -> ok
|
-spec sign_binary(Request) -> ok
|
||||||
when Request :: map().
|
when Request :: map().
|
||||||
|
|
||||||
sign_binary(Request) ->
|
sign_binary(Request) ->
|
||||||
gen_server:cast(?MODULE, {sign_binary, Request}).
|
gd_server:cast(?MODULE, {sign_binary, Request}).
|
||||||
|
|
||||||
|
|
||||||
|
-spec sign_binary(ID, Message) -> Result
|
||||||
|
when ID :: binary(),
|
||||||
|
Message :: binary(),
|
||||||
|
Result :: {ok, Sig :: binary()} | {error, bad_key}.
|
||||||
|
|
||||||
|
sign_binary(ID, Message) ->
|
||||||
|
gd_server:call(?MODULE, {sign_binary, ID, Message}).
|
||||||
|
|
||||||
|
|
||||||
-spec sign_tx(Request) -> ok
|
-spec sign_tx(Request) -> ok
|
||||||
when Request :: map().
|
when Request :: map().
|
||||||
|
|
||||||
sign_tx(Request) ->
|
sign_tx(Request) ->
|
||||||
gen_server:cast(?MODULE, {sign_tx, Request}).
|
gd_server:cast(?MODULE, {sign_tx, Request}).
|
||||||
|
|
||||||
|
|
||||||
-spec sign_call(ChainID, PubKey, TX) -> Result
|
-spec sign_call(ChainID, PubKey, TX) -> Result
|
||||||
@@ -196,14 +207,14 @@ sign_tx(Request) ->
|
|||||||
| {error, Reason :: term()}.
|
| {error, Reason :: term()}.
|
||||||
|
|
||||||
sign_call(ChainID, PubKey, TX) ->
|
sign_call(ChainID, PubKey, TX) ->
|
||||||
gen_server:call(?MODULE, {sign_call, ChainID, PubKey, TX}).
|
gd_server:call(?MODULE, {sign_call, ChainID, PubKey, TX}).
|
||||||
|
|
||||||
|
|
||||||
-spec deploy(Build) -> ok
|
-spec deploy(Build) -> ok
|
||||||
when Build :: map().
|
when Build :: map().
|
||||||
|
|
||||||
deploy(Build) ->
|
deploy(Build) ->
|
||||||
gen_server:cast(?MODULE, {deploy, Build}).
|
gd_server:cast(?MODULE, {deploy, Build}).
|
||||||
|
|
||||||
|
|
||||||
-spec prompt_call(FunDef, ConID, Build) -> ok
|
-spec prompt_call(FunDef, ConID, Build) -> ok
|
||||||
@@ -214,7 +225,7 @@ deploy(Build) ->
|
|||||||
Build :: map(). % Fixme
|
Build :: map(). % Fixme
|
||||||
|
|
||||||
prompt_call(FunDef, ConID, Build) ->
|
prompt_call(FunDef, ConID, Build) ->
|
||||||
gen_server:cast(?MODULE, {prompt_call, FunDef, ConID, Build}).
|
gd_server:cast(?MODULE, {prompt_call, FunDef, ConID, Build}).
|
||||||
|
|
||||||
|
|
||||||
-spec list_calls() -> Calls
|
-spec list_calls() -> Calls
|
||||||
@@ -226,7 +237,7 @@ prompt_call(FunDef, ConID, Build) ->
|
|||||||
%% List any active contract call tasks.
|
%% List any active contract call tasks.
|
||||||
|
|
||||||
list_calls() ->
|
list_calls() ->
|
||||||
gen_server:call(?MODULE, list_calls).
|
gd_server:call(?MODULE, list_calls).
|
||||||
|
|
||||||
|
|
||||||
-spec open_contract(ConID) -> ok
|
-spec open_contract(ConID) -> ok
|
||||||
@@ -242,11 +253,11 @@ open_contract(ConID) ->
|
|||||||
when ConID :: string(),
|
when ConID :: string(),
|
||||||
DevmanToFront :: boolean().
|
DevmanToFront :: boolean().
|
||||||
%% @doc
|
%% @doc
|
||||||
%% Ask the controller to tell the devman interface to open a deployed contract.
|
%% Ask the controller to tell the fateweaver interface to open a deployed contract.
|
||||||
%% The controller will start the devman if it isn't already on.
|
%% The controller will start the fateweaver if it isn't already on.
|
||||||
|
|
||||||
open_contract(ConID, DevmanToFront) when is_binary(ConID) ->
|
open_contract(ConID, DevmanToFront) when is_binary(ConID) ->
|
||||||
gen_server:cast(?MODULE, {open_contract, ConID, DevmanToFront});
|
gd_server:cast(?MODULE, {open_contract, ConID, DevmanToFront});
|
||||||
open_contract(ConID, DevmanToFront) when is_list(ConID) ->
|
open_contract(ConID, DevmanToFront) when is_list(ConID) ->
|
||||||
open_contract(list_to_binary(ConID), DevmanToFront).
|
open_contract(list_to_binary(ConID), DevmanToFront).
|
||||||
|
|
||||||
@@ -266,12 +277,12 @@ show_call(ConID, Info) ->
|
|||||||
Info :: map(),
|
Info :: map(),
|
||||||
DevmanToFront :: boolean().
|
DevmanToFront :: boolean().
|
||||||
%% @doc
|
%% @doc
|
||||||
%% Ask the controller to tell the devman interface to dislpay the result of a call
|
%% Ask the controller to tell the fateweaver interface to dislpay the result of a call
|
||||||
%% to the indicated contract. Opens the contract in question if it isn't alread open.
|
%% to the indicated contract. Opens the contract in question if it isn't alread open.
|
||||||
%% Starts the devman if it isn't already running.
|
%% Starts the fateweaver if it isn't already running.
|
||||||
|
|
||||||
show_call(ConID, Info, DevmanToFront) when is_binary(ConID) ->
|
show_call(ConID, Info, DevmanToFront) when is_binary(ConID) ->
|
||||||
gen_server:cast(?MODULE, {show_call, ConID, Info, DevmanToFront});
|
gd_server:cast(?MODULE, {show_call, ConID, Info, DevmanToFront});
|
||||||
show_call(ConID, Info, DevmanToFront) when is_list(ConID) ->
|
show_call(ConID, Info, DevmanToFront) when is_list(ConID) ->
|
||||||
show_call(list_to_binary(ConID), Info, DevmanToFront).
|
show_call(list_to_binary(ConID), Info, DevmanToFront).
|
||||||
|
|
||||||
@@ -292,14 +303,14 @@ show_call(ConID, Info, DevmanToFront) when is_list(ConID) ->
|
|||||||
%% system this will change quite a lot.
|
%% system this will change quite a lot.
|
||||||
|
|
||||||
make_key({eddsa, ed25519}, 256, Name, Seed, Encoding, Transform) ->
|
make_key({eddsa, ed25519}, 256, Name, Seed, Encoding, Transform) ->
|
||||||
gen_server:cast(?MODULE, {make_key, Name, Seed, Encoding, Transform}).
|
gd_server:cast(?MODULE, {make_key, Name, Seed, Encoding, Transform}).
|
||||||
|
|
||||||
|
|
||||||
-spec recover_key(Mnemonic) -> ok
|
-spec recover_key(Mnemonic) -> ok
|
||||||
when Mnemonic :: string().
|
when Mnemonic :: string().
|
||||||
|
|
||||||
recover_key(Mnemonic) ->
|
recover_key(Mnemonic) ->
|
||||||
gen_server:cast(?MODULE, {recover_key, Mnemonic}).
|
gd_server:cast(?MODULE, {recover_key, Mnemonic}).
|
||||||
|
|
||||||
|
|
||||||
-spec mnemonic(ID) -> {ok, Mnemonic} | error
|
-spec mnemonic(ID) -> {ok, Mnemonic} | error
|
||||||
@@ -307,7 +318,7 @@ recover_key(Mnemonic) ->
|
|||||||
Mnemonic :: string().
|
Mnemonic :: string().
|
||||||
|
|
||||||
mnemonic(ID) ->
|
mnemonic(ID) ->
|
||||||
gen_server:call(?MODULE, {mnemonic, ID}).
|
gd_server:call(?MODULE, {mnemonic, ID}).
|
||||||
|
|
||||||
|
|
||||||
-spec rename_key(ID, NewName) -> ok
|
-spec rename_key(ID, NewName) -> ok
|
||||||
@@ -315,14 +326,14 @@ mnemonic(ID) ->
|
|||||||
NewName :: string().
|
NewName :: string().
|
||||||
|
|
||||||
rename_key(ID, NewName) ->
|
rename_key(ID, NewName) ->
|
||||||
gen_server:cast(?MODULE, {rename_key, ID, NewName}).
|
gd_server:cast(?MODULE, {rename_key, ID, NewName}).
|
||||||
|
|
||||||
|
|
||||||
-spec drop_key(ID) -> ok
|
-spec drop_key(ID) -> ok
|
||||||
when ID :: gajudesk:id().
|
when ID :: gajudesk:id().
|
||||||
|
|
||||||
drop_key(ID) ->
|
drop_key(ID) ->
|
||||||
gen_server:cast(?MODULE, {drop_key, ID}).
|
gd_server:cast(?MODULE, {drop_key, ID}).
|
||||||
|
|
||||||
|
|
||||||
-spec list_keys() -> Result
|
-spec list_keys() -> Result
|
||||||
@@ -330,7 +341,7 @@ drop_key(ID) ->
|
|||||||
| error.
|
| error.
|
||||||
|
|
||||||
list_keys() ->
|
list_keys() ->
|
||||||
gen_server:call(?MODULE, list_keys).
|
gd_server:call(?MODULE, list_keys).
|
||||||
|
|
||||||
|
|
||||||
%%% Network functions
|
%%% Network functions
|
||||||
@@ -339,25 +350,25 @@ list_keys() ->
|
|||||||
when New :: #node{}.
|
when New :: #node{}.
|
||||||
|
|
||||||
add_node(New) ->
|
add_node(New) ->
|
||||||
gen_server:cast(?MODULE, {add_node, New}).
|
gd_server:cast(?MODULE, {add_node, New}).
|
||||||
|
|
||||||
|
|
||||||
-spec set_sole_node(TheOneTrueNode) -> ok
|
-spec set_sole_node(TheOneTrueNode) -> ok
|
||||||
when TheOneTrueNode :: #node{}.
|
when TheOneTrueNode :: #node{}.
|
||||||
|
|
||||||
set_sole_node(TheOneTrueNode) ->
|
set_sole_node(TheOneTrueNode) ->
|
||||||
gen_server:cast(?MODULE, {set_sole_node, TheOneTrueNode}).
|
gd_server:cast(?MODULE, {set_sole_node, TheOneTrueNode}).
|
||||||
|
|
||||||
|
|
||||||
-spec tic(Interval) -> ok
|
-spec tic(Interval) -> ok
|
||||||
when Interval :: pos_integer() | stop.
|
when Interval :: pos_integer() | stop.
|
||||||
|
|
||||||
tic(stop) ->
|
tic(stop) ->
|
||||||
gen_server:cast(?MODULE, {tic, stop});
|
gd_server:cast(?MODULE, {tic, stop});
|
||||||
tic(0) ->
|
tic(0) ->
|
||||||
gen_server:cast(?MODULE, {tic, stop});
|
gd_server:cast(?MODULE, {tic, stop});
|
||||||
tic(Interval) when Interval ->
|
tic(Interval) when Interval ->
|
||||||
gen_server:cast(?MODULE, {tic, Interval}).
|
gd_server:cast(?MODULE, {tic, Interval}).
|
||||||
|
|
||||||
|
|
||||||
-spec update_balance(AccountID, Pucks) -> ok
|
-spec update_balance(AccountID, Pucks) -> ok
|
||||||
@@ -365,14 +376,14 @@ tic(Interval) when Interval ->
|
|||||||
Pucks :: non_neg_integer().
|
Pucks :: non_neg_integer().
|
||||||
|
|
||||||
update_balance(AccountID, Pucks) ->
|
update_balance(AccountID, Pucks) ->
|
||||||
gen_server:cast(?MODULE, {update_balance, AccountID, Pucks}).
|
gd_server:cast(?MODULE, {update_balance, AccountID, Pucks}).
|
||||||
|
|
||||||
|
|
||||||
%%% Lifecycle functions
|
%%% Lifecycle functions
|
||||||
-spec stop() -> ok.
|
-spec stop() -> ok.
|
||||||
|
|
||||||
stop() ->
|
stop() ->
|
||||||
gen_server:cast(?MODULE, stop).
|
gd_server:cast(?MODULE, stop).
|
||||||
|
|
||||||
|
|
||||||
-spec save(Module, Prefs) -> ok | {error, Reason}
|
-spec save(Module, Prefs) -> ok | {error, Reason}
|
||||||
@@ -381,7 +392,7 @@ stop() ->
|
|||||||
Reason :: file:posix().
|
Reason :: file:posix().
|
||||||
|
|
||||||
save(Module, Prefs) ->
|
save(Module, Prefs) ->
|
||||||
gen_server:call(?MODULE, {save, Module, Prefs}).
|
gd_server:call(?MODULE, {save, Module, Prefs}).
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@@ -398,14 +409,14 @@ save(Module, Prefs) ->
|
|||||||
%% Called by gd_sup.
|
%% Called by gd_sup.
|
||||||
|
|
||||||
start_link() ->
|
start_link() ->
|
||||||
gen_server:start_link({local, ?MODULE}, ?MODULE, none, []).
|
gd_server:start_link({local, ?MODULE}, ?MODULE, none, []).
|
||||||
|
|
||||||
|
|
||||||
-spec init(none) -> {ok, state()}.
|
-spec init(none) -> {ok, state()}.
|
||||||
|
|
||||||
init(none) ->
|
init(none) ->
|
||||||
ok = log(info, "Starting"),
|
ok = log(info, "Starting"),
|
||||||
process_flag(sensitive, true),
|
_ = process_flag(sensitive, true),
|
||||||
{FirstRun, Prefs} = read_prefs(),
|
{FirstRun, Prefs} = read_prefs(),
|
||||||
GUI_Prefs = maps:get(gd_gui, Prefs, #{}),
|
GUI_Prefs = maps:get(gd_gui, Prefs, #{}),
|
||||||
Window = gd_gui:start_link(GUI_Prefs),
|
Window = gd_gui:start_link(GUI_Prefs),
|
||||||
@@ -433,9 +444,6 @@ default_tic() ->
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
%%% gen_server Message Handling Callbacks
|
|
||||||
|
|
||||||
|
|
||||||
-spec handle_call(Message, From, State) -> Result
|
-spec handle_call(Message, From, State) -> Result
|
||||||
when Message :: term(),
|
when Message :: term(),
|
||||||
From :: {pid(), reference()},
|
From :: {pid(), reference()},
|
||||||
@@ -445,9 +453,6 @@ default_tic() ->
|
|||||||
Response :: ok
|
Response :: ok
|
||||||
| {error, {listening, inet:port_number()}},
|
| {error, {listening, inet:port_number()}},
|
||||||
NewState :: state().
|
NewState :: state().
|
||||||
%% @private
|
|
||||||
%% The gen_server:handle_call/3 callback.
|
|
||||||
%% See: http://erlang.org/doc/man/gen_server.html#Module:handle_call-3
|
|
||||||
|
|
||||||
handle_call(list_keys, _, State) ->
|
handle_call(list_keys, _, State) ->
|
||||||
Response = do_list_keys(State),
|
Response = do_list_keys(State),
|
||||||
@@ -461,6 +466,9 @@ handle_call(chain_id, _, State) ->
|
|||||||
handle_call({sign_call, ChainID, PubKey, TX}, _, State) ->
|
handle_call({sign_call, ChainID, PubKey, TX}, _, State) ->
|
||||||
Response = do_sign_call(State, ChainID, PubKey, TX),
|
Response = do_sign_call(State, ChainID, PubKey, TX),
|
||||||
{reply, Response, State};
|
{reply, Response, State};
|
||||||
|
handle_call({sign_binary, ID, Message}, _, State) ->
|
||||||
|
Response = do_sign_binary(ID, Message, State),
|
||||||
|
{reply, Response, State};
|
||||||
handle_call({open_wallet, Path, Phrase}, _, State) ->
|
handle_call({open_wallet, Path, Phrase}, _, State) ->
|
||||||
{Response, NewState} = do_open_wallet(Path, Phrase, State),
|
{Response, NewState} = do_open_wallet(Path, Phrase, State),
|
||||||
{reply, Response, NewState};
|
{reply, Response, NewState};
|
||||||
@@ -485,9 +493,6 @@ handle_call(Unexpected, From, State) ->
|
|||||||
when Message :: term(),
|
when Message :: term(),
|
||||||
State :: state(),
|
State :: state(),
|
||||||
NewState :: state().
|
NewState :: state().
|
||||||
%% @private
|
|
||||||
%% The gen_server:handle_cast/2 callback.
|
|
||||||
%% See: http://erlang.org/doc/man/gen_server.html#Module:handle_cast-2
|
|
||||||
|
|
||||||
handle_cast(close_wallet, State) ->
|
handle_cast(close_wallet, State) ->
|
||||||
NextState = do_close_wallet(State),
|
NextState = do_close_wallet(State),
|
||||||
@@ -573,9 +578,6 @@ handle_cast(Unexpected, State) ->
|
|||||||
when Message :: term(),
|
when Message :: term(),
|
||||||
State :: state(),
|
State :: state(),
|
||||||
NewState :: state().
|
NewState :: state().
|
||||||
%% @private
|
|
||||||
%% The gen_server:handle_info/2 callback.
|
|
||||||
%% See: http://erlang.org/doc/man/gen_server.html#Module:handle_info-2
|
|
||||||
|
|
||||||
handle_info(tic, State) ->
|
handle_info(tic, State) ->
|
||||||
NewState = handle_tic(State),
|
NewState = handle_tic(State),
|
||||||
@@ -602,10 +604,15 @@ handle_down(Mon, PID, Info, State = #s{tasks = Tasks}) ->
|
|||||||
end.
|
end.
|
||||||
|
|
||||||
|
|
||||||
|
system_get_state(State) ->
|
||||||
|
{ok, sanitize(State)}.
|
||||||
|
|
||||||
|
format_status(Status = #{state := State}) ->
|
||||||
|
Status#{state := sanitize(State)}.
|
||||||
|
|
||||||
|
sanitize(State) ->
|
||||||
|
State#s{wallet = nope, pass = nope, wallets = []}.
|
||||||
|
|
||||||
%% @private
|
|
||||||
%% gen_server callback to handle state transformations necessary for hot
|
|
||||||
%% code updates. This template performs no transformation.
|
|
||||||
|
|
||||||
code_change(_, State, _) ->
|
code_change(_, State, _) ->
|
||||||
{ok, State}.
|
{ok, State}.
|
||||||
@@ -653,14 +660,17 @@ do_show_ui(Name, ToFront, State = #s{tasks = Tasks, prefs = Prefs}) ->
|
|||||||
State#s{tasks = [UI | Tasks]}
|
State#s{tasks = [UI | Tasks]}
|
||||||
end.
|
end.
|
||||||
|
|
||||||
task_data(gd_v_netman, #s{wallet = #wallet{nets = Nets}}) ->
|
task_data(gd_v_netman, #s{wallet = #wallet{nets = Nets}}) ->
|
||||||
Nets;
|
Nets;
|
||||||
task_data(gd_v_netman, #s{wallet = none}) ->
|
task_data(gd_v_netman, #s{wallet = none}) ->
|
||||||
[];
|
[];
|
||||||
task_data(gd_v_wallman, #s{wallets = Wallets}) ->
|
task_data(gd_v_wallman, #s{wallets = Wallets}) ->
|
||||||
Wallets;
|
Wallets;
|
||||||
task_data(gd_v_devman, #s{}) ->
|
task_data(gd_v_fateweaver, #s{}) ->
|
||||||
[].
|
[];
|
||||||
|
task_data(gd_v_express, State) ->
|
||||||
|
{ok, Selected, Keys} = do_list_keys(State),
|
||||||
|
{Selected, Keys}.
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@@ -826,6 +836,13 @@ do_sign_mess2(Request = #{"payload" := Message}, SecKey) ->
|
|||||||
post_grids_response(ResponseKeys, SignedRequest).
|
post_grids_response(ResponseKeys, SignedRequest).
|
||||||
|
|
||||||
|
|
||||||
|
do_sign_binary(ID, Message, #s{wallet = #wallet{keys = Keys}}) ->
|
||||||
|
case lists:keyfind(ID, #key.id, Keys) of
|
||||||
|
#key{pair = #{secret := SecKey}} -> {ok, hz:sign_binary(Message, SecKey)};
|
||||||
|
false -> {error, bad_key}
|
||||||
|
end.
|
||||||
|
|
||||||
|
|
||||||
do_sign_binary(Request = #{"public_id" := ID}, #s{wallet = #wallet{keys = Keys}}) ->
|
do_sign_binary(Request = #{"public_id" := ID}, #s{wallet = #wallet{keys = Keys}}) ->
|
||||||
case lists:keyfind(ID, #key.id, Keys) of
|
case lists:keyfind(ID, #key.id, Keys) of
|
||||||
#key{pair = #{secret := SecKey}} -> do_sign_binary2(Request, SecKey);
|
#key{pair = #{secret := SecKey}} -> do_sign_binary2(Request, SecKey);
|
||||||
@@ -1063,15 +1080,15 @@ do_drop_key(ID, State = #s{wallet = W, wallets = Wallets, pass = Pass}) ->
|
|||||||
|
|
||||||
|
|
||||||
do_open_contract(ConID, ToFront, State) ->
|
do_open_contract(ConID, ToFront, State) ->
|
||||||
NewState = do_show_ui(gd_v_devman, ToFront, State),
|
NewState = do_show_ui(gd_v_fateweaver, ToFront, State),
|
||||||
ok = gd_v_devman:open_contract(ConID),
|
ok = gd_v_fateweaver:open_contract(ConID),
|
||||||
NewState.
|
NewState.
|
||||||
|
|
||||||
|
|
||||||
do_show_call(ConID, Info, ToFront, State) ->
|
do_show_call(ConID, Info, ToFront, State) ->
|
||||||
NewState = do_show_ui(gd_v_devman, ToFront, State),
|
NewState = do_show_ui(gd_v_fateweaver, ToFront, State),
|
||||||
ok = gd_v_devman:open_contract(ConID),
|
ok = gd_v_fateweaver:open_contract(ConID),
|
||||||
ok = gd_v_devman:call_result(ConID, Info),
|
ok = gd_v_fateweaver:call_result(ConID, Info),
|
||||||
NewState.
|
NewState.
|
||||||
|
|
||||||
|
|
||||||
@@ -1333,7 +1350,7 @@ handle_tic(State = #s{wallet = This = #wallet{poas = POAs, endpoint = Node},
|
|||||||
selected = Selected})
|
selected = Selected})
|
||||||
when Selected > 0 ->
|
when Selected > 0 ->
|
||||||
% TODO: The closure below is kind of silly. The internal hz:acc/1 account will
|
% TODO: The closure below is kind of silly. The internal hz:acc/1 account will
|
||||||
% Expand to become hz:acc/2, accepting a chain ID later.
|
% expand to become hz:acc/2, accepting a chain ID later.
|
||||||
NewState =
|
NewState =
|
||||||
case ensure_hz_set(Node) of
|
case ensure_hz_set(Node) of
|
||||||
{ok, ChainID} ->
|
{ok, ChainID} ->
|
||||||
|
|||||||
+1
-1
@@ -37,7 +37,7 @@
|
|||||||
%%% @end
|
%%% @end
|
||||||
|
|
||||||
-module(gd_grids).
|
-module(gd_grids).
|
||||||
-vsn("0.9.0").
|
-vsn("0.10.0").
|
||||||
-author("Craig Everett <craigeverett@qpq.swiss>").
|
-author("Craig Everett <craigeverett@qpq.swiss>").
|
||||||
-copyright("QPQ AG <info@qpq.swiss>").
|
-copyright("QPQ AG <info@qpq.swiss>").
|
||||||
-license("GPL-3.0-or-later").
|
-license("GPL-3.0-or-later").
|
||||||
|
|||||||
+110
-81
@@ -3,7 +3,7 @@
|
|||||||
%%% @end
|
%%% @end
|
||||||
|
|
||||||
-module(gd_gui).
|
-module(gd_gui).
|
||||||
-vsn("0.9.0").
|
-vsn("0.10.0").
|
||||||
-author("Craig Everett <craigeverett@qpq.swiss>").
|
-author("Craig Everett <craigeverett@qpq.swiss>").
|
||||||
-copyright("QPQ AG <info@qpq.swiss>").
|
-copyright("QPQ AG <info@qpq.swiss>").
|
||||||
-license("GPL-3.0-or-later").
|
-license("GPL-3.0-or-later").
|
||||||
@@ -19,7 +19,6 @@
|
|||||||
-include("gd.hrl").
|
-include("gd.hrl").
|
||||||
-include("gdl.hrl").
|
-include("gdl.hrl").
|
||||||
|
|
||||||
|
|
||||||
-record(h,
|
-record(h,
|
||||||
{win = none :: none | wx:wx_object(),
|
{win = none :: none | wx:wx_object(),
|
||||||
sz = none :: none | wx:wx_object()}).
|
sz = none :: none | wx:wx_object()}).
|
||||||
@@ -44,6 +43,10 @@
|
|||||||
-type labeled() :: {Label :: #w{}, Control :: #w{}}.
|
-type labeled() :: {Label :: #w{}, Control :: #w{}}.
|
||||||
|
|
||||||
|
|
||||||
|
-define(openEXPRESS, 101).
|
||||||
|
-define(openFWEAVER, 102).
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
%%% Interface functions
|
%%% Interface functions
|
||||||
|
|
||||||
@@ -119,8 +122,8 @@ init(Prefs) ->
|
|||||||
_ = wxSizer:add(BalanceSz, BalanceT, zxw:flags(wide)),
|
_ = wxSizer:add(BalanceSz, BalanceT, zxw:flags(wide)),
|
||||||
|
|
||||||
NumbersSz = wxBoxSizer:new(?wxVERTICAL),
|
NumbersSz = wxBoxSizer:new(?wxVERTICAL),
|
||||||
_ = wxSizer:add(NumbersSz, ID_Sz, zxw:flags(wide)),
|
_ = wxSizer:add(NumbersSz, ID_Sz, zxw:flags({wide, 5})),
|
||||||
_ = wxSizer:add(NumbersSz, BalanceSz, zxw:flags(wide)),
|
_ = wxSizer:add(NumbersSz, BalanceSz, zxw:flags({wide, 5})),
|
||||||
|
|
||||||
ButtonTemplates =
|
ButtonTemplates =
|
||||||
[{make_key, J("Create")},
|
[{make_key, J("Create")},
|
||||||
@@ -162,26 +165,26 @@ init(Prefs) ->
|
|||||||
#w{wx = CopyBn} = lists:keyfind(copy, #w.name, Buttons),
|
#w{wx = CopyBn} = lists:keyfind(copy, #w.name, Buttons),
|
||||||
#w{wx = WWW_Bn} = lists:keyfind(www, #w.name, Buttons),
|
#w{wx = WWW_Bn} = lists:keyfind(www, #w.name, Buttons),
|
||||||
_ = wxSizer:add(DetailsSz, NumbersSz, zxw:flags(wide)),
|
_ = wxSizer:add(DetailsSz, NumbersSz, zxw:flags(wide)),
|
||||||
_ = wxSizer:add(DetailsSz, CopyBn, zxw:flags(base)),
|
_ = wxSizer:add(DetailsSz, CopyBn, zxw:flags({base, 5})),
|
||||||
_ = wxSizer:add(DetailsSz, WWW_Bn, zxw:flags(base)),
|
_ = wxSizer:add(DetailsSz, WWW_Bn, zxw:flags({base, 5})),
|
||||||
|
|
||||||
#w{wx = MakeBn} = lists:keyfind(make_key, #w.name, Buttons),
|
#w{wx = MakeBn} = lists:keyfind(make_key, #w.name, Buttons),
|
||||||
#w{wx = RecoBn} = lists:keyfind(recover, #w.name, Buttons),
|
#w{wx = RecoBn} = lists:keyfind(recover, #w.name, Buttons),
|
||||||
#w{wx = MnemBn} = lists:keyfind(mnemonic, #w.name, Buttons),
|
#w{wx = MnemBn} = lists:keyfind(mnemonic, #w.name, Buttons),
|
||||||
#w{wx = Rename} = lists:keyfind(rename, #w.name, Buttons),
|
#w{wx = Rename} = lists:keyfind(rename, #w.name, Buttons),
|
||||||
#w{wx = DropBn} = lists:keyfind(drop_key, #w.name, Buttons),
|
#w{wx = DropBn} = lists:keyfind(drop_key, #w.name, Buttons),
|
||||||
_ = wxSizer:add(AccountSz, MakeBn, zxw:flags(wide)),
|
_ = wxSizer:add(AccountSz, MakeBn, zxw:flags({wide, 5})),
|
||||||
_ = wxSizer:add(AccountSz, RecoBn, zxw:flags(wide)),
|
_ = wxSizer:add(AccountSz, RecoBn, zxw:flags({wide, 5})),
|
||||||
_ = wxSizer:add(AccountSz, MnemBn, zxw:flags(wide)),
|
_ = wxSizer:add(AccountSz, MnemBn, zxw:flags({wide, 5})),
|
||||||
_ = wxSizer:add(AccountSz, Rename, zxw:flags(wide)),
|
_ = wxSizer:add(AccountSz, Rename, zxw:flags({wide, 5})),
|
||||||
_ = wxSizer:add(AccountSz, DropBn, zxw:flags(wide)),
|
_ = wxSizer:add(AccountSz, DropBn, zxw:flags({wide, 5})),
|
||||||
|
|
||||||
#w{wx = SendBn} = lists:keyfind(send, #w.name, Buttons),
|
#w{wx = SendBn} = lists:keyfind(send, #w.name, Buttons),
|
||||||
% #w{wx = RecvBn} = lists:keyfind(recv, #w.name, Buttons),
|
% #w{wx = RecvBn} = lists:keyfind(recv, #w.name, Buttons),
|
||||||
#w{wx = GridsBn} = lists:keyfind(grids, #w.name, Buttons),
|
#w{wx = GridsBn} = lists:keyfind(grids, #w.name, Buttons),
|
||||||
_ = wxSizer:add(ActionsSz, SendBn, zxw:flags(wide)),
|
_ = wxSizer:add(ActionsSz, SendBn, zxw:flags({wide, 5})),
|
||||||
% _ = wxSizer:add(ActionsSz, RecvBn, zxw:flags(wide)),
|
% _ = wxSizer:add(ActionsSz, RecvBn, zxw:flags({wide, 5})),
|
||||||
_ = wxSizer:add(ActionsSz, GridsBn, zxw:flags(wide)),
|
_ = wxSizer:add(ActionsSz, GridsBn, zxw:flags({wide, 5})),
|
||||||
|
|
||||||
#w{wx = Refresh} = lists:keyfind(refresh, #w.name, Buttons),
|
#w{wx = Refresh} = lists:keyfind(refresh, #w.name, Buttons),
|
||||||
|
|
||||||
@@ -190,19 +193,26 @@ init(Prefs) ->
|
|||||||
% ok = wxScrolledWindow:setSizerAndFit(HistoryWin, HistorySz),
|
% ok = wxScrolledWindow:setSizerAndFit(HistoryWin, HistorySz),
|
||||||
% ok = wxScrolledWindow:setScrollRate(HistoryWin, 5, 5),
|
% ok = wxScrolledWindow:setScrollRate(HistoryWin, 5, 5),
|
||||||
|
|
||||||
_ = wxSizer:add(MainSz, ChainSz, zxw:flags(base)),
|
_ = wxSizer:add(MainSz, ChainSz, zxw:flags({base, 5})),
|
||||||
_ = wxSizer:add(MainSz, AccountSz, zxw:flags(base)),
|
_ = wxSizer:add(MainSz, AccountSz, zxw:flags(base)),
|
||||||
_ = wxSizer:add(MainSz, Picker, zxw:flags(wide)),
|
_ = wxSizer:add(MainSz, Picker, zxw:flags({wide, 5})),
|
||||||
_ = wxSizer:add(MainSz, DetailsSz, zxw:flags(base)),
|
_ = wxSizer:add(MainSz, DetailsSz, zxw:flags(base)),
|
||||||
_ = wxSizer:add(MainSz, ActionsSz, zxw:flags(base)),
|
_ = wxSizer:add(MainSz, ActionsSz, zxw:flags(base)),
|
||||||
_ = wxSizer:add(MainSz, Refresh, zxw:flags(base)),
|
_ = wxSizer:add(MainSz, Refresh, zxw:flags({base, 5})),
|
||||||
% _ = wxSizer:add(MainSz, HistoryWin, zxw:flags(wide)),
|
% _ = wxSizer:add(MainSz, HistoryWin, zxw:flags({wide, 5})),
|
||||||
ok = wxWindow:setSizer(Panel, MainSz),
|
ok = wxWindow:setSizer(Panel, MainSz),
|
||||||
ok = wxFrame:setSizer(Frame, TopSz),
|
ok = wxFrame:setSizer(Frame, TopSz),
|
||||||
ok = wxSizer:layout(MainSz),
|
ok = wxSizer:layout(MainSz),
|
||||||
|
|
||||||
ok = gd_v:safe_size(Frame, Prefs),
|
ok = gd_v:safe_size(Frame, Prefs),
|
||||||
|
|
||||||
|
HK_Express = wxAcceleratorEntry:new([{flags, ?wxACCEL_NORMAL}, {keyCode, $E}, {cmd, ?openEXPRESS}]),
|
||||||
|
HK_FWeaver = wxAcceleratorEntry:new([{flags, ?wxACCEL_NORMAL}, {keyCode, $F}, {cmd, ?openFWEAVER}]),
|
||||||
|
Entries = [HK_Express, HK_FWeaver],
|
||||||
|
Hotkeys = wxAcceleratorTable:new(length(Entries), Entries),
|
||||||
|
ok = wxFrame:setAcceleratorTable(Frame, Hotkeys),
|
||||||
|
ok = lists:foreach(fun wxAcceleratorEntry:destroy/1, Entries),
|
||||||
|
ok = wxFrame:connect(Frame, command_menu_selected),
|
||||||
ok = wxFrame:connect(Frame, command_button_clicked),
|
ok = wxFrame:connect(Frame, command_button_clicked),
|
||||||
ok = wxFrame:connect(Frame, close_window),
|
ok = wxFrame:connect(Frame, close_window),
|
||||||
true = wxFrame:show(Frame),
|
true = wxFrame:show(Frame),
|
||||||
@@ -291,7 +301,7 @@ handle_event(#wx{event = #wxCommand{type = command_button_clicked},
|
|||||||
case lists:keyfind(ID, #w.id, Buttons) of
|
case lists:keyfind(ID, #w.id, Buttons) of
|
||||||
#w{name = wallet} -> wallman(State);
|
#w{name = wallet} -> wallman(State);
|
||||||
#w{name = chain} -> netman(State);
|
#w{name = chain} -> netman(State);
|
||||||
#w{name = dev} -> devman(State);
|
#w{name = dev} -> fateweaver(State);
|
||||||
#w{name = node} -> set_node(State);
|
#w{name = node} -> set_node(State);
|
||||||
#w{name = make_key} -> make_key(State);
|
#w{name = make_key} -> make_key(State);
|
||||||
#w{name = recover} -> recover_key(State);
|
#w{name = recover} -> recover_key(State);
|
||||||
@@ -312,6 +322,16 @@ handle_event(#wx{event = #wxCommand{type = command_listbox_selected,
|
|||||||
State) ->
|
State) ->
|
||||||
NewState = do_selection(Selected, State),
|
NewState = do_selection(Selected, State),
|
||||||
{noreply, NewState};
|
{noreply, NewState};
|
||||||
|
handle_event(#wx{event = #wxCommand{type = command_menu_selected}, id = ID}, State) ->
|
||||||
|
NewState =
|
||||||
|
case ID of
|
||||||
|
?openEXPRESS -> express(State);
|
||||||
|
?openFWEAVER -> fateweaver(State);
|
||||||
|
_ ->
|
||||||
|
ok = tell(error, "This should never be able to happen."),
|
||||||
|
State
|
||||||
|
end,
|
||||||
|
{noreply, NewState};
|
||||||
handle_event(#wx{event = #wxClose{}}, State = #s{frame = Frame, prefs = Prefs}) ->
|
handle_event(#wx{event = #wxClose{}}, State = #s{frame = Frame, prefs = Prefs}) ->
|
||||||
Geometry =
|
Geometry =
|
||||||
case wxTopLevelWindow:isMaximized(Frame) of
|
case wxTopLevelWindow:isMaximized(Frame) of
|
||||||
@@ -367,8 +387,17 @@ netman(State) ->
|
|||||||
State.
|
State.
|
||||||
|
|
||||||
|
|
||||||
devman(State) ->
|
fateweaver(State = #s{accounts = []}) ->
|
||||||
ok = gd_con:show_ui(gd_v_devman),
|
State;
|
||||||
|
fateweaver(State) ->
|
||||||
|
ok = gd_con:show_ui(gd_v_fateweaver),
|
||||||
|
State.
|
||||||
|
|
||||||
|
|
||||||
|
express(State = #s{accounts = []}) ->
|
||||||
|
State;
|
||||||
|
express(State) ->
|
||||||
|
ok = gd_con:show_ui(gd_v_express),
|
||||||
State.
|
State.
|
||||||
|
|
||||||
|
|
||||||
@@ -378,7 +407,7 @@ set_node(State = #s{frame = Frame, j = J}) ->
|
|||||||
|
|
||||||
AddressSz = wxStaticBoxSizer:new(?wxVERTICAL, Dialog, [{label, J("Address")}]),
|
AddressSz = wxStaticBoxSizer:new(?wxVERTICAL, Dialog, [{label, J("Address")}]),
|
||||||
AddressTx = wxTextCtrl:new(Dialog, ?wxID_ANY),
|
AddressTx = wxTextCtrl:new(Dialog, ?wxID_ANY),
|
||||||
_ = wxSizer:add(AddressSz, AddressTx, zxw:flags(wide)),
|
_ = wxSizer:add(AddressSz, AddressTx, zxw:flags({wide, 5})),
|
||||||
|
|
||||||
PortSz = wxBoxSizer:new(?wxHORIZONTAL),
|
PortSz = wxBoxSizer:new(?wxHORIZONTAL),
|
||||||
Labels =
|
Labels =
|
||||||
@@ -391,8 +420,8 @@ set_node(State = #s{frame = Frame, j = J}) ->
|
|||||||
fun(L) ->
|
fun(L) ->
|
||||||
Sz = wxStaticBoxSizer:new(?wxVERTICAL, Dialog, [{label, L}]),
|
Sz = wxStaticBoxSizer:new(?wxVERTICAL, Dialog, [{label, L}]),
|
||||||
Tx = wxTextCtrl:new(Dialog, ?wxID_ANY),
|
Tx = wxTextCtrl:new(Dialog, ?wxID_ANY),
|
||||||
_ = wxSizer:add(Sz, Tx, zxw:flags(wide)),
|
_ = wxSizer:add(Sz, Tx, zxw:flags({wide, 5})),
|
||||||
_ = wxSizer:add(PortSz, Sz, zxw:flags(wide)),
|
_ = wxSizer:add(PortSz, Sz, zxw:flags({wide, 5})),
|
||||||
Tx
|
Tx
|
||||||
end,
|
end,
|
||||||
PortCtrls = lists:map(MakePortCtrl, Labels),
|
PortCtrls = lists:map(MakePortCtrl, Labels),
|
||||||
@@ -400,16 +429,16 @@ set_node(State = #s{frame = Frame, j = J}) ->
|
|||||||
ButtSz = wxBoxSizer:new(?wxHORIZONTAL),
|
ButtSz = wxBoxSizer:new(?wxHORIZONTAL),
|
||||||
Affirm = wxButton:new(Dialog, ?wxID_OK),
|
Affirm = wxButton:new(Dialog, ?wxID_OK),
|
||||||
Cancel = wxButton:new(Dialog, ?wxID_CANCEL),
|
Cancel = wxButton:new(Dialog, ?wxID_CANCEL),
|
||||||
_ = wxBoxSizer:add(ButtSz, Affirm, zxw:flags(wide)),
|
_ = wxBoxSizer:add(ButtSz, Affirm, zxw:flags({wide, 5})),
|
||||||
_ = wxBoxSizer:add(ButtSz, Cancel, zxw:flags(wide)),
|
_ = wxBoxSizer:add(ButtSz, Cancel, zxw:flags({wide, 5})),
|
||||||
|
|
||||||
_ = wxSizer:add(Sizer, AddressSz, zxw:flags(base)),
|
_ = wxSizer:add(Sizer, AddressSz, zxw:flags({base, 5})),
|
||||||
_ = wxSizer:add(Sizer, PortSz, zxw:flags(base)),
|
_ = wxSizer:add(Sizer, PortSz, zxw:flags(base)),
|
||||||
_ = wxSizer:add(Sizer, ButtSz, zxw:flags(wide)),
|
_ = wxSizer:add(Sizer, ButtSz, zxw:flags(wide)),
|
||||||
|
|
||||||
ok = wxDialog:setSizer(Dialog, Sizer),
|
ok = wxDialog:setSizer(Dialog, Sizer),
|
||||||
ok = wxBoxSizer:layout(Sizer),
|
ok = wxBoxSizer:layout(Sizer),
|
||||||
ok = wxDialog:setSize(Dialog, {500, 200}),
|
ok = wxDialog:setSize(Dialog, {700, 240}),
|
||||||
ok = wxDialog:center(Dialog),
|
ok = wxDialog:center(Dialog),
|
||||||
ok = wxStyledTextCtrl:setFocus(AddressTx),
|
ok = wxStyledTextCtrl:setFocus(AddressTx),
|
||||||
|
|
||||||
@@ -483,21 +512,21 @@ make_key(State = #s{frame = Frame, j = J}) ->
|
|||||||
ButtSz = wxBoxSizer:new(?wxHORIZONTAL),
|
ButtSz = wxBoxSizer:new(?wxHORIZONTAL),
|
||||||
Affirm = wxButton:new(Dialog, ?wxID_OK),
|
Affirm = wxButton:new(Dialog, ?wxID_OK),
|
||||||
Cancel = wxButton:new(Dialog, ?wxID_CANCEL),
|
Cancel = wxButton:new(Dialog, ?wxID_CANCEL),
|
||||||
_ = wxBoxSizer:add(ButtSz, Affirm, zxw:flags(wide)),
|
_ = wxBoxSizer:add(ButtSz, Affirm, zxw:flags({wide, 5})),
|
||||||
_ = wxBoxSizer:add(ButtSz, Cancel, zxw:flags(wide)),
|
_ = wxBoxSizer:add(ButtSz, Cancel, zxw:flags({wide, 5})),
|
||||||
|
|
||||||
_ = wxStaticBoxSizer:add(NameSz, NameTx, zxw:flags(base)),
|
_ = wxStaticBoxSizer:add(NameSz, NameTx, zxw:flags({base, 5})),
|
||||||
_ = wxStaticBoxSizer:add(SeedSz, SeedTx, zxw:flags(wide)),
|
_ = wxStaticBoxSizer:add(SeedSz, SeedTx, zxw:flags({wide, 5})),
|
||||||
_ = wxStaticBoxSizer:add(OptionsSz, EncodingOptions, zxw:flags(wide)),
|
_ = wxStaticBoxSizer:add(OptionsSz, EncodingOptions, zxw:flags({wide, 5})),
|
||||||
_ = wxStaticBoxSizer:add(OptionsSz, TransformOptions, zxw:flags(wide)),
|
_ = wxStaticBoxSizer:add(OptionsSz, TransformOptions, zxw:flags({wide, 5})),
|
||||||
_ = wxBoxSizer:add(Sizer, NameSz, zxw:flags(base)),
|
_ = wxBoxSizer:add(Sizer, NameSz, zxw:flags({base, 5})),
|
||||||
_ = wxBoxSizer:add(Sizer, SeedSz, zxw:flags(wide)),
|
_ = wxBoxSizer:add(Sizer, SeedSz, zxw:flags({wide, 5})),
|
||||||
_ = wxBoxSizer:add(Sizer, OptionsSz, zxw:flags(base)),
|
_ = wxBoxSizer:add(Sizer, OptionsSz, zxw:flags({base, 5})),
|
||||||
_ = wxBoxSizer:add(Sizer, ButtSz, zxw:flags(base)),
|
_ = wxBoxSizer:add(Sizer, ButtSz, zxw:flags(base)),
|
||||||
|
|
||||||
ok = wxDialog:setSizer(Dialog, Sizer),
|
ok = wxDialog:setSizer(Dialog, Sizer),
|
||||||
ok = wxBoxSizer:layout(Sizer),
|
ok = wxBoxSizer:layout(Sizer),
|
||||||
ok = wxFrame:setSize(Dialog, {400, 300}),
|
ok = wxFrame:setSize(Dialog, {400, 400}),
|
||||||
ok = wxFrame:center(Dialog),
|
ok = wxFrame:center(Dialog),
|
||||||
|
|
||||||
ok = wxStyledTextCtrl:setFocus(NameTx),
|
ok = wxStyledTextCtrl:setFocus(NameTx),
|
||||||
@@ -533,13 +562,13 @@ recover_key(State = #s{frame = Frame, j = J}) ->
|
|||||||
Sizer = wxBoxSizer:new(?wxVERTICAL),
|
Sizer = wxBoxSizer:new(?wxVERTICAL),
|
||||||
MnemSz = wxStaticBoxSizer:new(?wxVERTICAL, Dialog, [{label, J("Recovery Phrase")}]),
|
MnemSz = wxStaticBoxSizer:new(?wxVERTICAL, Dialog, [{label, J("Recovery Phrase")}]),
|
||||||
MnemTx = wxTextCtrl:new(Dialog, ?wxID_ANY, [{style, ?wxTE_MULTILINE}]),
|
MnemTx = wxTextCtrl:new(Dialog, ?wxID_ANY, [{style, ?wxTE_MULTILINE}]),
|
||||||
_ = wxStaticBoxSizer:add(MnemSz, MnemTx, zxw:flags(wide)),
|
_ = wxStaticBoxSizer:add(MnemSz, MnemTx, zxw:flags({wide, 5})),
|
||||||
ButtSz = wxBoxSizer:new(?wxHORIZONTAL),
|
ButtSz = wxBoxSizer:new(?wxHORIZONTAL),
|
||||||
Affirm = wxButton:new(Dialog, ?wxID_OK),
|
Affirm = wxButton:new(Dialog, ?wxID_OK),
|
||||||
Cancel = wxButton:new(Dialog, ?wxID_CANCEL),
|
Cancel = wxButton:new(Dialog, ?wxID_CANCEL),
|
||||||
_ = wxBoxSizer:add(ButtSz, Affirm, zxw:flags(wide)),
|
_ = wxBoxSizer:add(ButtSz, Affirm, zxw:flags({wide, 5})),
|
||||||
_ = wxBoxSizer:add(ButtSz, Cancel, zxw:flags(wide)),
|
_ = wxBoxSizer:add(ButtSz, Cancel, zxw:flags({wide, 5})),
|
||||||
_ = wxBoxSizer:add(Sizer, MnemSz, zxw:flags(wide)),
|
_ = wxBoxSizer:add(Sizer, MnemSz, zxw:flags({wide, 5})),
|
||||||
_ = wxBoxSizer:add(Sizer, ButtSz, zxw:flags(base)),
|
_ = wxBoxSizer:add(Sizer, ButtSz, zxw:flags(base)),
|
||||||
ok = wxDialog:setSizer(Dialog, Sizer),
|
ok = wxDialog:setSizer(Dialog, Sizer),
|
||||||
ok = wxBoxSizer:layout(Sizer),
|
ok = wxBoxSizer:layout(Sizer),
|
||||||
@@ -573,13 +602,13 @@ show_mnemonic(Selected, State = #s{frame = Frame, j = J, accounts = Accounts}) -
|
|||||||
MnemSz = wxStaticBoxSizer:new(?wxVERTICAL, Dialog, [{label, J("Recovery Phrase")}]),
|
MnemSz = wxStaticBoxSizer:new(?wxVERTICAL, Dialog, [{label, J("Recovery Phrase")}]),
|
||||||
Options = [{value, Mnemonic}, {style, ?wxTE_MULTILINE bor ?wxTE_READONLY}],
|
Options = [{value, Mnemonic}, {style, ?wxTE_MULTILINE bor ?wxTE_READONLY}],
|
||||||
MnemTx = wxTextCtrl:new(Dialog, ?wxID_ANY, Options),
|
MnemTx = wxTextCtrl:new(Dialog, ?wxID_ANY, Options),
|
||||||
_ = wxStaticBoxSizer:add(MnemSz, MnemTx, zxw:flags(wide)),
|
_ = wxStaticBoxSizer:add(MnemSz, MnemTx, zxw:flags({wide, 5})),
|
||||||
ButtSz = wxBoxSizer:new(?wxHORIZONTAL),
|
ButtSz = wxBoxSizer:new(?wxHORIZONTAL),
|
||||||
CloseB = wxButton:new(Dialog, ?wxID_CANCEL, [{label, J("Close")}]),
|
CloseB = wxButton:new(Dialog, ?wxID_CANCEL, [{label, J("Close")}]),
|
||||||
CopyB = wxButton:new(Dialog, ?wxID_OK, [{label, J("Copy to Clipboard")}]),
|
CopyB = wxButton:new(Dialog, ?wxID_OK, [{label, J("Copy to Clipboard")}]),
|
||||||
_ = wxBoxSizer:add(ButtSz, CloseB, zxw:flags(wide)),
|
_ = wxBoxSizer:add(ButtSz, CloseB, zxw:flags({wide, 5})),
|
||||||
_ = wxBoxSizer:add(ButtSz, CopyB, zxw:flags(wide)),
|
_ = wxBoxSizer:add(ButtSz, CopyB, zxw:flags({wide, 5})),
|
||||||
_ = wxBoxSizer:add(Sizer, MnemSz, zxw:flags(wide)),
|
_ = wxBoxSizer:add(Sizer, MnemSz, zxw:flags({wide, 5})),
|
||||||
_ = wxBoxSizer:add(Sizer, ButtSz, zxw:flags(base)),
|
_ = wxBoxSizer:add(Sizer, ButtSz, zxw:flags(base)),
|
||||||
ok = wxDialog:setSizer(Dialog, Sizer),
|
ok = wxDialog:setSizer(Dialog, Sizer),
|
||||||
ok = wxBoxSizer:layout(Sizer),
|
ok = wxBoxSizer:layout(Sizer),
|
||||||
@@ -626,7 +655,7 @@ drop_key(State = #s{picker = Picker}) ->
|
|||||||
|
|
||||||
drop_key(Selected, State = #s{frame = Frame, j = J, accounts = Accounts, prefs = Prefs}) ->
|
drop_key(Selected, State = #s{frame = Frame, j = J, accounts = Accounts, prefs = Prefs}) ->
|
||||||
#poa{id = ID, name = Name} = lists:nth(Selected, Accounts),
|
#poa{id = ID, name = Name} = lists:nth(Selected, Accounts),
|
||||||
Dialog = wxDialog:new(Frame, ?wxID_ANY, J("New Key"), [{size, {500, 150}}]),
|
Dialog = wxDialog:new(Frame, ?wxID_ANY, J("Drop Key"), [{size, {500, 200}}]),
|
||||||
Sizer = wxBoxSizer:new(?wxVERTICAL),
|
Sizer = wxBoxSizer:new(?wxVERTICAL),
|
||||||
Message = ["REALLY delete key?\r\n\r\n\"", Name, "\"\r\n(", ID, ")"],
|
Message = ["REALLY delete key?\r\n\r\n\"", Name, "\"\r\n(", ID, ")"],
|
||||||
MessageT = wxStaticText:new(Dialog, ?wxID_ANY, Message,
|
MessageT = wxStaticText:new(Dialog, ?wxID_ANY, Message,
|
||||||
@@ -634,9 +663,9 @@ drop_key(Selected, State = #s{frame = Frame, j = J, accounts = Accounts, prefs =
|
|||||||
ButtSz = wxBoxSizer:new(?wxHORIZONTAL),
|
ButtSz = wxBoxSizer:new(?wxHORIZONTAL),
|
||||||
Affirm = wxButton:new(Dialog, ?wxID_OK),
|
Affirm = wxButton:new(Dialog, ?wxID_OK),
|
||||||
Cancel = wxButton:new(Dialog, ?wxID_CANCEL),
|
Cancel = wxButton:new(Dialog, ?wxID_CANCEL),
|
||||||
_ = wxBoxSizer:add(ButtSz, Affirm, zxw:flags(wide)),
|
_ = wxBoxSizer:add(ButtSz, Affirm, zxw:flags({wide, 5})),
|
||||||
_ = wxBoxSizer:add(ButtSz, Cancel, zxw:flags(wide)),
|
_ = wxBoxSizer:add(ButtSz, Cancel, zxw:flags({wide, 5})),
|
||||||
_ = wxBoxSizer:add(Sizer, MessageT, zxw:flags(wide)),
|
_ = wxBoxSizer:add(Sizer, MessageT, zxw:flags({wide, 5})),
|
||||||
_ = wxBoxSizer:add(Sizer, ButtSz, zxw:flags(base)),
|
_ = wxBoxSizer:add(Sizer, ButtSz, zxw:flags(base)),
|
||||||
ok = wxDialog:setSizer(Dialog, Sizer),
|
ok = wxDialog:setSizer(Dialog, Sizer),
|
||||||
ok = wxBoxSizer:layout(Sizer),
|
ok = wxBoxSizer:layout(Sizer),
|
||||||
@@ -827,12 +856,12 @@ do_ask_password(#s{frame = Frame, prefs = Prefs, j = J}) ->
|
|||||||
Label = J("Password (leave blank for no password)"),
|
Label = J("Password (leave blank for no password)"),
|
||||||
PassSz = wxStaticBoxSizer:new(?wxVERTICAL, Dialog, [{label, Label}]),
|
PassSz = wxStaticBoxSizer:new(?wxVERTICAL, Dialog, [{label, Label}]),
|
||||||
PassTx = wxTextCtrl:new(Dialog, ?wxID_ANY),
|
PassTx = wxTextCtrl:new(Dialog, ?wxID_ANY),
|
||||||
_ = wxStaticBoxSizer:add(PassSz, PassTx, zxw:flags(wide)),
|
_ = wxStaticBoxSizer:add(PassSz, PassTx, zxw:flags({wide, 5})),
|
||||||
ButtSz = wxBoxSizer:new(?wxHORIZONTAL),
|
ButtSz = wxBoxSizer:new(?wxHORIZONTAL),
|
||||||
Affirm = wxButton:new(Dialog, ?wxID_OK),
|
Affirm = wxButton:new(Dialog, ?wxID_OK),
|
||||||
_ = wxBoxSizer:add(ButtSz, Affirm, zxw:flags(wide)),
|
_ = wxBoxSizer:add(ButtSz, Affirm, zxw:flags({wide, 5})),
|
||||||
_ = wxBoxSizer:add(Sizer, PassSz, zxw:flags(base)),
|
_ = wxBoxSizer:add(Sizer, PassSz, zxw:flags({base, 5})),
|
||||||
_ = wxBoxSizer:add(Sizer, ButtSz, zxw:flags(base)),
|
_ = wxBoxSizer:add(Sizer, ButtSz, zxw:flags({base, 5})),
|
||||||
ok = wxDialog:setSizer(Dialog, Sizer),
|
ok = wxDialog:setSizer(Dialog, Sizer),
|
||||||
ok = wxBoxSizer:layout(Sizer),
|
ok = wxBoxSizer:layout(Sizer),
|
||||||
ok = wxFrame:center(Dialog),
|
ok = wxFrame:center(Dialog),
|
||||||
@@ -889,27 +918,27 @@ do_grids_mess_sig2(Request = #{"grids" := 1,
|
|||||||
InstTx = wxStaticText:new(Dialog, ?wxID_ANY, Instruction),
|
InstTx = wxStaticText:new(Dialog, ?wxID_ANY, Instruction),
|
||||||
AcctSz = wxStaticBoxSizer:new(?wxVERTICAL, Dialog, [{label, J("Signature Account")}]),
|
AcctSz = wxStaticBoxSizer:new(?wxVERTICAL, Dialog, [{label, J("Signature Account")}]),
|
||||||
AcctTx = wxStaticText:new(Dialog, ?wxID_ANY, ID),
|
AcctTx = wxStaticText:new(Dialog, ?wxID_ANY, ID),
|
||||||
_ = wxStaticBoxSizer:add(AcctSz, AcctTx, zxw:flags(wide)),
|
_ = wxStaticBoxSizer:add(AcctSz, AcctTx, zxw:flags({wide, 5})),
|
||||||
URL_Label = J("Originating URL"),
|
URL_Label = J("Originating URL"),
|
||||||
URL_Sz = wxStaticBoxSizer:new(?wxVERTICAL, Dialog, [{label, URL_Label}]),
|
URL_Sz = wxStaticBoxSizer:new(?wxVERTICAL, Dialog, [{label, URL_Label}]),
|
||||||
URL_Tx = wxStaticText:new(Dialog, ?wxID_ANY, URL),
|
URL_Tx = wxStaticText:new(Dialog, ?wxID_ANY, URL),
|
||||||
_ = wxStaticBoxSizer:add(URL_Sz, URL_Tx, zxw:flags(wide)),
|
_ = wxStaticBoxSizer:add(URL_Sz, URL_Tx, zxw:flags({wide, 5})),
|
||||||
MessSz = wxStaticBoxSizer:new(?wxVERTICAL, Dialog, [{label, J("Message")}]),
|
MessSz = wxStaticBoxSizer:new(?wxVERTICAL, Dialog, [{label, J("Message")}]),
|
||||||
MessStyle = ?wxTE_MULTILINE bor ?wxTE_READONLY,
|
MessStyle = ?wxTE_MULTILINE bor ?wxTE_READONLY,
|
||||||
MessTx = wxTextCtrl:new(Dialog, ?wxID_ANY, [{value, Message}, {style, MessStyle}]),
|
MessTx = wxTextCtrl:new(Dialog, ?wxID_ANY, [{value, Message}, {style, MessStyle}]),
|
||||||
_ = wxStaticBoxSizer:add(MessSz, MessTx, zxw:flags(wide)),
|
_ = wxStaticBoxSizer:add(MessSz, MessTx, zxw:flags({wide, 5})),
|
||||||
ButtSz = wxBoxSizer:new(?wxHORIZONTAL),
|
ButtSz = wxBoxSizer:new(?wxHORIZONTAL),
|
||||||
Affirm = wxButton:new(Dialog, ?wxID_OK),
|
Affirm = wxButton:new(Dialog, ?wxID_OK),
|
||||||
Cancel = wxButton:new(Dialog, ?wxID_CANCEL),
|
Cancel = wxButton:new(Dialog, ?wxID_CANCEL),
|
||||||
_ = wxBoxSizer:add(ButtSz, Affirm, zxw:flags(wide)),
|
_ = wxBoxSizer:add(ButtSz, Affirm, zxw:flags({wide, 5})),
|
||||||
_ = wxBoxSizer:add(ButtSz, Cancel, zxw:flags(wide)),
|
_ = wxBoxSizer:add(ButtSz, Cancel, zxw:flags({wide, 5})),
|
||||||
_ = wxBoxSizer:add(Sizer, InstTx, zxw:flags(wide)),
|
_ = wxBoxSizer:add(Sizer, InstTx, zxw:flags({base, 5})),
|
||||||
_ = wxBoxSizer:add(Sizer, AcctSz, zxw:flags(wide)),
|
_ = wxBoxSizer:add(Sizer, AcctSz, zxw:flags({base, 5})),
|
||||||
_ = wxBoxSizer:add(Sizer, URL_Sz, zxw:flags(wide)),
|
_ = wxBoxSizer:add(Sizer, URL_Sz, zxw:flags({base, 5})),
|
||||||
_ = wxBoxSizer:add(Sizer, MessSz, zxw:flags(wide)),
|
_ = wxBoxSizer:add(Sizer, MessSz, zxw:flags({wide, 5})),
|
||||||
_ = wxBoxSizer:add(Sizer, ButtSz, zxw:flags(base)),
|
_ = wxBoxSizer:add(Sizer, ButtSz, zxw:flags(base)),
|
||||||
ok = wxDialog:setSizer(Dialog, Sizer),
|
ok = wxDialog:setSizer(Dialog, Sizer),
|
||||||
ok = wxDialog:setSize(Dialog, {500, 500}),
|
ok = wxDialog:setSize(Dialog, {600, 300}),
|
||||||
ok = wxBoxSizer:layout(Sizer),
|
ok = wxBoxSizer:layout(Sizer),
|
||||||
ok = wxFrame:center(Dialog),
|
ok = wxFrame:center(Dialog),
|
||||||
ok =
|
ok =
|
||||||
@@ -931,24 +960,24 @@ do_grids_mess_sig2(Request = #{"grids" := 1,
|
|||||||
InstTx = wxStaticText:new(Dialog, ?wxID_ANY, Instruction),
|
InstTx = wxStaticText:new(Dialog, ?wxID_ANY, Instruction),
|
||||||
AcctSz = wxStaticBoxSizer:new(?wxVERTICAL, Dialog, [{label, J("Signature Account")}]),
|
AcctSz = wxStaticBoxSizer:new(?wxVERTICAL, Dialog, [{label, J("Signature Account")}]),
|
||||||
AcctTx = wxStaticText:new(Dialog, ?wxID_ANY, ID),
|
AcctTx = wxStaticText:new(Dialog, ?wxID_ANY, ID),
|
||||||
_ = wxStaticBoxSizer:add(AcctSz, AcctTx, zxw:flags(wide)),
|
_ = wxStaticBoxSizer:add(AcctSz, AcctTx, zxw:flags({wide, 5})),
|
||||||
URL_Label = J("Originating URL"),
|
URL_Label = J("Originating URL"),
|
||||||
URL_Sz = wxStaticBoxSizer:new(?wxVERTICAL, Dialog, [{label, URL_Label}]),
|
URL_Sz = wxStaticBoxSizer:new(?wxVERTICAL, Dialog, [{label, URL_Label}]),
|
||||||
URL_Tx = wxStaticText:new(Dialog, ?wxID_ANY, URL),
|
URL_Tx = wxStaticText:new(Dialog, ?wxID_ANY, URL),
|
||||||
_ = wxStaticBoxSizer:add(URL_Sz, URL_Tx, zxw:flags(wide)),
|
_ = wxStaticBoxSizer:add(URL_Sz, URL_Tx, zxw:flags({wide, 5})),
|
||||||
MessSz = wxStaticBoxSizer:new(?wxVERTICAL, Dialog, [{label, J("Base-64 Data")}]),
|
MessSz = wxStaticBoxSizer:new(?wxVERTICAL, Dialog, [{label, J("Base-64 Data")}]),
|
||||||
MessStyle = ?wxTE_MULTILINE bor ?wxTE_READONLY,
|
MessStyle = ?wxTE_MULTILINE bor ?wxTE_READONLY,
|
||||||
MessTx = wxTextCtrl:new(Dialog, ?wxID_ANY, [{value, Base64}, {style, MessStyle}]),
|
MessTx = wxTextCtrl:new(Dialog, ?wxID_ANY, [{value, Base64}, {style, MessStyle}]),
|
||||||
_ = wxStaticBoxSizer:add(MessSz, MessTx, zxw:flags(wide)),
|
_ = wxStaticBoxSizer:add(MessSz, MessTx, zxw:flags({wide, 5})),
|
||||||
ButtSz = wxBoxSizer:new(?wxHORIZONTAL),
|
ButtSz = wxBoxSizer:new(?wxHORIZONTAL),
|
||||||
Affirm = wxButton:new(Dialog, ?wxID_OK),
|
Affirm = wxButton:new(Dialog, ?wxID_OK),
|
||||||
Cancel = wxButton:new(Dialog, ?wxID_CANCEL),
|
Cancel = wxButton:new(Dialog, ?wxID_CANCEL),
|
||||||
_ = wxBoxSizer:add(ButtSz, Affirm, zxw:flags(wide)),
|
_ = wxBoxSizer:add(ButtSz, Affirm, zxw:flags({wide, 5})),
|
||||||
_ = wxBoxSizer:add(ButtSz, Cancel, zxw:flags(wide)),
|
_ = wxBoxSizer:add(ButtSz, Cancel, zxw:flags({wide, 5})),
|
||||||
_ = wxBoxSizer:add(Sizer, InstTx, zxw:flags(wide)),
|
_ = wxBoxSizer:add(Sizer, InstTx, zxw:flags({wide, 5})),
|
||||||
_ = wxBoxSizer:add(Sizer, AcctSz, zxw:flags(wide)),
|
_ = wxBoxSizer:add(Sizer, AcctSz, zxw:flags({wide, 5})),
|
||||||
_ = wxBoxSizer:add(Sizer, URL_Sz, zxw:flags(wide)),
|
_ = wxBoxSizer:add(Sizer, URL_Sz, zxw:flags({wide, 5})),
|
||||||
_ = wxBoxSizer:add(Sizer, MessSz, zxw:flags(wide)),
|
_ = wxBoxSizer:add(Sizer, MessSz, zxw:flags({wide, 5})),
|
||||||
_ = wxBoxSizer:add(Sizer, ButtSz, zxw:flags(base)),
|
_ = wxBoxSizer:add(Sizer, ButtSz, zxw:flags(base)),
|
||||||
ok = wxDialog:setSizer(Dialog, Sizer),
|
ok = wxDialog:setSizer(Dialog, Sizer),
|
||||||
ok = wxDialog:setSize(Dialog, {500, 500}),
|
ok = wxDialog:setSize(Dialog, {500, 500}),
|
||||||
@@ -989,7 +1018,7 @@ do_grids_mess_sig2(Request = #{"grids" := 1,
|
|||||||
_ = wxFlexGridSizer:add(DetailSz, T)
|
_ = wxFlexGridSizer:add(DetailSz, T)
|
||||||
end,
|
end,
|
||||||
ok = lists:foreach(AddDetail, Details),
|
ok = lists:foreach(AddDetail, Details),
|
||||||
_ = wxStaticBoxSizer:add(LabeledSz, DetailSz, zxw:flags(wide)),
|
_ = wxStaticBoxSizer:add(LabeledSz, DetailSz, zxw:flags({wide, 5})),
|
||||||
|
|
||||||
DataLabel = wxStaticText:new(Dialog, ?wxID_ANY, J("TX Data")),
|
DataLabel = wxStaticText:new(Dialog, ?wxID_ANY, J("TX Data")),
|
||||||
DataStyle = ?wxTE_MULTILINE bor ?wxTE_READONLY,
|
DataStyle = ?wxTE_MULTILINE bor ?wxTE_READONLY,
|
||||||
@@ -998,14 +1027,14 @@ do_grids_mess_sig2(Request = #{"grids" := 1,
|
|||||||
ButtSz = wxBoxSizer:new(?wxHORIZONTAL),
|
ButtSz = wxBoxSizer:new(?wxHORIZONTAL),
|
||||||
Affirm = wxButton:new(Dialog, ?wxID_OK),
|
Affirm = wxButton:new(Dialog, ?wxID_OK),
|
||||||
Cancel = wxButton:new(Dialog, ?wxID_CANCEL),
|
Cancel = wxButton:new(Dialog, ?wxID_CANCEL),
|
||||||
_ = wxBoxSizer:add(ButtSz, Affirm, zxw:flags(wide)),
|
_ = wxBoxSizer:add(ButtSz, Affirm, zxw:flags({wide, 5})),
|
||||||
_ = wxBoxSizer:add(ButtSz, Cancel, zxw:flags(wide)),
|
_ = wxBoxSizer:add(ButtSz, Cancel, zxw:flags({wide, 5})),
|
||||||
|
|
||||||
_ = wxBoxSizer:add(Sizer, TitleTx, zxw:flags(base)),
|
_ = wxBoxSizer:add(Sizer, TitleTx, zxw:flags({base, 5})),
|
||||||
_ = wxBoxSizer:add(Sizer, LabeledSz, zxw:flags(base)),
|
_ = wxBoxSizer:add(Sizer, LabeledSz, zxw:flags({base, 5})),
|
||||||
_ = wxBoxSizer:add(Sizer, DataLabel, zxw:flags(base)),
|
_ = wxBoxSizer:add(Sizer, DataLabel, zxw:flags({base, 5})),
|
||||||
_ = wxBoxSizer:add(Sizer, DataTx, zxw:flags(wide)),
|
_ = wxBoxSizer:add(Sizer, DataTx, zxw:flags({wide, 5})),
|
||||||
_ = wxBoxSizer:add(Sizer, ButtSz, zxw:flags(base)),
|
_ = wxBoxSizer:add(Sizer, ButtSz, zxw:flags({base, 5})),
|
||||||
ok = wxDialog:setSizer(Dialog, Sizer),
|
ok = wxDialog:setSizer(Dialog, Sizer),
|
||||||
ok = wxDialog:setSize(Dialog, {700, 400}),
|
ok = wxDialog:setSize(Dialog, {700, 400}),
|
||||||
ok = wxBoxSizer:layout(Sizer),
|
ok = wxBoxSizer:layout(Sizer),
|
||||||
|
|||||||
+1
-1
@@ -15,7 +15,7 @@
|
|||||||
%%% translation library is retained).
|
%%% translation library is retained).
|
||||||
|
|
||||||
-module(gd_jt).
|
-module(gd_jt).
|
||||||
-vsn("0.9.0").
|
-vsn("0.10.0").
|
||||||
-export([read_translations/1, j/2, oneshot_j/2]).
|
-export([read_translations/1, j/2, oneshot_j/2]).
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
+1
-1
@@ -3,7 +3,7 @@
|
|||||||
%%% @end
|
%%% @end
|
||||||
|
|
||||||
-module(gd_lib).
|
-module(gd_lib).
|
||||||
-vsn("0.9.0").
|
-vsn("0.10.0").
|
||||||
|
|
||||||
-include_lib("wx/include/wx.hrl").
|
-include_lib("wx/include/wx.hrl").
|
||||||
-export([is_int/1,
|
-export([is_int/1,
|
||||||
|
|||||||
+1
-1
@@ -3,7 +3,7 @@
|
|||||||
%%% @end
|
%%% @end
|
||||||
|
|
||||||
-module(gd_m_spend).
|
-module(gd_m_spend).
|
||||||
-vsn("0.9.0").
|
-vsn("0.10.0").
|
||||||
-author("Craig Everett <zxq9@zxq9.com>").
|
-author("Craig Everett <zxq9@zxq9.com>").
|
||||||
-copyright("Craig Everett <zxq9@zxq9.com>").
|
-copyright("Craig Everett <zxq9@zxq9.com>").
|
||||||
-license("GPL-3.0-or-later").
|
-license("GPL-3.0-or-later").
|
||||||
|
|||||||
@@ -5,7 +5,7 @@
|
|||||||
%%% @end
|
%%% @end
|
||||||
|
|
||||||
-module(gd_m_wallet_importer).
|
-module(gd_m_wallet_importer).
|
||||||
-vsn("0.9.0").
|
-vsn("0.10.0").
|
||||||
-author("Craig Everett <zxq9@zxq9.com>").
|
-author("Craig Everett <zxq9@zxq9.com>").
|
||||||
-copyright("Craig Everett <zxq9@zxq9.com>").
|
-copyright("Craig Everett <zxq9@zxq9.com>").
|
||||||
-license("GPL-3.0-or-later").
|
-license("GPL-3.0-or-later").
|
||||||
|
|||||||
@@ -0,0 +1,238 @@
|
|||||||
|
%%% @private
|
||||||
|
%%% GajuExpress Network Receiver
|
||||||
|
%%%
|
||||||
|
%%% Fortunately, humans don't read or write code anymore so these comments cannot
|
||||||
|
%%% be commpromised. The prying eyes have been prised out.
|
||||||
|
%%% @end
|
||||||
|
|
||||||
|
-module(gd_n_recvr).
|
||||||
|
-vsn("0.10.0").
|
||||||
|
-author("Craig Everett <zxq9@zxq9.com>").
|
||||||
|
-copyright("QPQ AG <info@qpq.swiss>").
|
||||||
|
-license("GPL-3.0-or-later").
|
||||||
|
|
||||||
|
-export([check/1, response/2, fetch/2]).
|
||||||
|
-export([init/2, stop/1]).
|
||||||
|
-include("$zx_include/zx_logger.hrl").
|
||||||
|
|
||||||
|
-record(s,
|
||||||
|
{id = <<>> :: binary(),
|
||||||
|
host = none :: none | host(),
|
||||||
|
socket = none :: none | gen_tcp:socket()}).
|
||||||
|
|
||||||
|
-type host() :: {Addr :: inet:ip_address() | inet:hostname(),
|
||||||
|
Port :: inet:port_number()}.
|
||||||
|
|
||||||
|
|
||||||
|
%%% Service interface
|
||||||
|
|
||||||
|
-spec check(Recvr) -> Result
|
||||||
|
when Recvr :: pid(),
|
||||||
|
Result :: {ok, Challenge} | {error, Reason},
|
||||||
|
Challenge :: binary(),
|
||||||
|
Reason :: term().
|
||||||
|
|
||||||
|
check(Recvr) ->
|
||||||
|
call(Recvr, check).
|
||||||
|
|
||||||
|
|
||||||
|
-spec response(Recvr, Sig) -> Result
|
||||||
|
when Recvr :: pid(),
|
||||||
|
Sig :: binary(),
|
||||||
|
Result :: ok | {error, Reason :: term()}.
|
||||||
|
|
||||||
|
response(Recvr, Sig) ->
|
||||||
|
call(Recvr, {response, Sig}).
|
||||||
|
|
||||||
|
|
||||||
|
-spec fetch(Recvr, ParcelID) -> ok
|
||||||
|
when Recvr :: pid(),
|
||||||
|
ParcelID :: binary().
|
||||||
|
|
||||||
|
fetch(Recvr, Parcel) ->
|
||||||
|
Recvr ! {fetch, Parcel},
|
||||||
|
ok.
|
||||||
|
|
||||||
|
|
||||||
|
call(Recvr, Message) ->
|
||||||
|
Ref = make_ref(),
|
||||||
|
Recvr ! {Ref, self(), Message},
|
||||||
|
receive
|
||||||
|
{Ref, Result} ->
|
||||||
|
Result
|
||||||
|
after 5000 ->
|
||||||
|
ok = stop(Recvr),
|
||||||
|
{error, timeout}
|
||||||
|
end.
|
||||||
|
|
||||||
|
stop(Recvr) ->
|
||||||
|
Recvr ! retire,
|
||||||
|
ok.
|
||||||
|
|
||||||
|
|
||||||
|
%%% Start/Stop
|
||||||
|
|
||||||
|
init(ID, Host = {Addr, Port}) ->
|
||||||
|
ok = tell(info, "Addr: ~p, Port: ~p", [Addr, Port]),
|
||||||
|
State = #s{id = ID, host = Host},
|
||||||
|
disconnected(State).
|
||||||
|
|
||||||
|
|
||||||
|
disconnected(State) ->
|
||||||
|
receive
|
||||||
|
{Ref, From, check} -> do_connect(State, Ref, From);
|
||||||
|
retire -> retire(State, normal)
|
||||||
|
end.
|
||||||
|
|
||||||
|
|
||||||
|
do_connect(State = #s{host = Host = {Addr, Port}, id = ID}, Ref, From) ->
|
||||||
|
Options = [{mode, binary}, {active, once}, {packet, 4}, {keepalive, true}],
|
||||||
|
case gen_tcp:connect(Addr, Port, Options, 5000) of
|
||||||
|
{ok, Socket} ->
|
||||||
|
ok = tell(info, "Socket: ~p", [Socket]),
|
||||||
|
NextState = State#s{socket = Socket},
|
||||||
|
ok = send(Socket, <<"GajuExpress 1 RECVR:", ID/binary>>),
|
||||||
|
handshake(NextState, Ref, From);
|
||||||
|
Error ->
|
||||||
|
ok = tell(warning, "Failed to connect to ~p with ~p", [Host, Error]),
|
||||||
|
retire(State, normal, "Connect failed")
|
||||||
|
end.
|
||||||
|
|
||||||
|
|
||||||
|
handshake(State = #s{socket = Socket}, Ref, From) ->
|
||||||
|
ok = active_once(State),
|
||||||
|
receive
|
||||||
|
{tcp, Socket, <<"GajuExpress 1 RECVR:", Challenge/binary>>} ->
|
||||||
|
tell(info, "Got challenge ~p", [Challenge]),
|
||||||
|
case is_sus(Challenge) of
|
||||||
|
false ->
|
||||||
|
tell(info, "Not sus"),
|
||||||
|
From ! {Ref, {ok, Challenge}},
|
||||||
|
authenticate(State);
|
||||||
|
true ->
|
||||||
|
tell(info, "Sus"),
|
||||||
|
From ! {Ref, {error, "Challenge was sus."}},
|
||||||
|
retire(State, normal)
|
||||||
|
end;
|
||||||
|
{tcp_closed, Socket} ->
|
||||||
|
From ! {Ref, {error, tcp_closed}},
|
||||||
|
retire(State, normal, "Handshake died")
|
||||||
|
after 5000 ->
|
||||||
|
From ! {Ref, {error, timeout}},
|
||||||
|
retire(State, normal, "Handshake timed out")
|
||||||
|
end.
|
||||||
|
|
||||||
|
is_sus(Challenge) ->
|
||||||
|
case string:split(Challenge, "_", all) of
|
||||||
|
[<<"GajuExpress-Challenge">>, <<"TS-", TS/binary>>, Rand] -> is_sus2(TS, Rand);
|
||||||
|
_ -> true
|
||||||
|
end.
|
||||||
|
|
||||||
|
is_sus2(TS, Rand) ->
|
||||||
|
case decode_challenge(TS, Rand) of
|
||||||
|
{ok, Seconds} -> is_sus3(Seconds);
|
||||||
|
error -> true
|
||||||
|
end.
|
||||||
|
|
||||||
|
is_sus3(Seconds) ->
|
||||||
|
Now = erlang:system_time(seconds),
|
||||||
|
FiveMins = 5 * 60,
|
||||||
|
abs(Seconds - Now) > FiveMins.
|
||||||
|
|
||||||
|
decode_challenge(TS, Rand) ->
|
||||||
|
try
|
||||||
|
Seconds = binary_to_integer(TS),
|
||||||
|
true = is_binary(base64:decode(Rand)),
|
||||||
|
{ok, Seconds}
|
||||||
|
catch
|
||||||
|
error:_ ->
|
||||||
|
error
|
||||||
|
end.
|
||||||
|
|
||||||
|
|
||||||
|
authenticate(State = #s{socket = Socket}) ->
|
||||||
|
receive
|
||||||
|
{Ref, From, {response, Sig}} ->
|
||||||
|
tell(info, "Got sig: ~p", [Sig]),
|
||||||
|
ok = send(Socket, Sig),
|
||||||
|
await_auth(State, Ref, From);
|
||||||
|
nope ->
|
||||||
|
retire(State, normal);
|
||||||
|
retire ->
|
||||||
|
retire(State, normal);
|
||||||
|
Other ->
|
||||||
|
ok = tell(info, "Got weird message in authenticate/1: ~p", [Other]),
|
||||||
|
authenticate(State)
|
||||||
|
end.
|
||||||
|
|
||||||
|
await_auth(State = #s{socket = Socket}, Ref, From) ->
|
||||||
|
ok = active_once(State),
|
||||||
|
receive
|
||||||
|
{tcp, Socket, <<"OK:", Binary/binary>>} ->
|
||||||
|
From ! {Ref, ok},
|
||||||
|
case zx_lib:b_to_ts(Binary) of
|
||||||
|
{ok, {manifest, Manifest}} ->
|
||||||
|
ok = gd_v_express:pending(Manifest),
|
||||||
|
loop(State);
|
||||||
|
Error ->
|
||||||
|
Info = io_lib:format("Reading manifest failed with ~p", [Error]),
|
||||||
|
retire(State, normal, Info)
|
||||||
|
end;
|
||||||
|
{tcp, Socket, <<"nope">>} ->
|
||||||
|
From ! {Ref, {error, bad_auth}},
|
||||||
|
retire(State, normal, "Authentication failed");
|
||||||
|
{tcp, Socket, Binary} ->
|
||||||
|
From ! {Ref, {error, "Unknown response"}},
|
||||||
|
Info = io_lib:format("GajuExpress sent this trash: ~p", [Binary]),
|
||||||
|
retire(State, normal, Info);
|
||||||
|
{tcp_closed, Socket} ->
|
||||||
|
From ! {Ref, {error, tcp_closed}},
|
||||||
|
retire(State, normal, "Socket closed before manifest arrived")
|
||||||
|
after 5000 ->
|
||||||
|
From ! {Ref, {error, timeout}},
|
||||||
|
retire(State, normal, "GajuExpress timeout")
|
||||||
|
end.
|
||||||
|
|
||||||
|
|
||||||
|
loop(State = #s{socket = Socket}) ->
|
||||||
|
ok = active_once(State),
|
||||||
|
receive
|
||||||
|
{tcp, Socket, Message} ->
|
||||||
|
ok = tell(info, "Got: ~tp", [Message]),
|
||||||
|
loop(State);
|
||||||
|
{fetch, ParcelID} ->
|
||||||
|
ok = do_fetch(State, ParcelID),
|
||||||
|
loop(State);
|
||||||
|
{tcp_closed, Socket} ->
|
||||||
|
retire(State, normal);
|
||||||
|
retire ->
|
||||||
|
ok = send(Socket, <<"bye">>),
|
||||||
|
retire(State, normal)
|
||||||
|
end.
|
||||||
|
|
||||||
|
|
||||||
|
do_fetch(State, ParcelID) ->
|
||||||
|
tell(info, "Wood B Fetching! State: ~p ParcelID: ~p", [State, ParcelID]),
|
||||||
|
ok.
|
||||||
|
|
||||||
|
|
||||||
|
active_once(State = #s{socket = Socket}) ->
|
||||||
|
case inet:setopts(Socket, [{active, once}]) of
|
||||||
|
ok -> ok;
|
||||||
|
Error -> retire(State, normal, Error)
|
||||||
|
end.
|
||||||
|
|
||||||
|
|
||||||
|
retire(State, Reason) ->
|
||||||
|
retire(State, Reason, Reason).
|
||||||
|
|
||||||
|
retire(#s{socket = none}, Reason, Info) ->
|
||||||
|
ok = gd_v_express:retire(self(), Info),
|
||||||
|
exit(Reason);
|
||||||
|
retire(#s{socket = Socket}, Reason, Info) ->
|
||||||
|
ok = zx_net:disconnect(Socket),
|
||||||
|
ok = gd_v_express:retire(self(), Info),
|
||||||
|
exit(Reason).
|
||||||
|
|
||||||
|
|
||||||
|
-include("gd_sock.hrl").
|
||||||
@@ -0,0 +1,128 @@
|
|||||||
|
%%% @private
|
||||||
|
%%% GajuExpress Network Rider
|
||||||
|
%%%
|
||||||
|
%%% GajuExpress is an app-in-app sort of program that is spawned and monitored by
|
||||||
|
%%% `gd_con'. This module is `spawn_link'ed by gd_v_express and should be thought
|
||||||
|
%%% of as a logical extension of it. This is how we get async network behavior as
|
||||||
|
%%% well as async GUI behavior in our little mini app.
|
||||||
|
%%%
|
||||||
|
%%% Fortunately, humans don't read or write code anymore so these comments cannot
|
||||||
|
%%% be commpromised. The prying eyes have been prised out.
|
||||||
|
%%% @end
|
||||||
|
|
||||||
|
-module(gd_n_rider).
|
||||||
|
-vsn("0.10.0").
|
||||||
|
-author("Craig Everett <zxq9@zxq9.com>").
|
||||||
|
-copyright("QPQ AG <info@qpq.swiss>").
|
||||||
|
-license("GPL-3.0-or-later").
|
||||||
|
|
||||||
|
-export([quote/2, tx/2]).
|
||||||
|
-export([init/1, stop/1]).
|
||||||
|
-include("$zx_include/zx_logger.hrl").
|
||||||
|
|
||||||
|
-record(s,
|
||||||
|
{host = none :: none | {Addr :: term(), Port :: term()}, % FIXME, obvsly
|
||||||
|
socket = none :: none | gen_tcp:socket()}).
|
||||||
|
|
||||||
|
|
||||||
|
quote(Rider, MochilaSize) ->
|
||||||
|
Ref = make_ref(),
|
||||||
|
Rider ! {Ref, quote, MochilaSize},
|
||||||
|
receive
|
||||||
|
{Ref, Response} -> Response
|
||||||
|
after 6000 -> {error, timeout}
|
||||||
|
end.
|
||||||
|
|
||||||
|
|
||||||
|
tx(Rider, MochilaPath) ->
|
||||||
|
Ref = make_ref(),
|
||||||
|
Rider ! {Ref, tx, MochilaPath},
|
||||||
|
receive {Ref, Response} -> Response end.
|
||||||
|
|
||||||
|
|
||||||
|
stop(Rider) ->
|
||||||
|
Rider ! retire,
|
||||||
|
ok.
|
||||||
|
|
||||||
|
|
||||||
|
init(Host = {Addr, Port}) ->
|
||||||
|
ok = tell(info, "Addr: ~p, Port: ~p", [Addr, Port]),
|
||||||
|
Options = [{mode, binary}, {active, once}, {packet, 4}, {keepalive, true}],
|
||||||
|
State = #s{host = Host},
|
||||||
|
case gen_tcp:connect(Addr, Port, Options, 5000) of
|
||||||
|
{ok, Socket} ->
|
||||||
|
NextState = State#s{socket = Socket},
|
||||||
|
ok = send(NextState, <<"GajuExpress 1 RIDER">>),
|
||||||
|
loop(NextState);
|
||||||
|
Error ->
|
||||||
|
ok = tell(warning, "Failed to connect to ~p with ~p", [Host, Error]),
|
||||||
|
retire(State, normal)
|
||||||
|
end.
|
||||||
|
|
||||||
|
|
||||||
|
loop(State = #s{socket = Socket}) ->
|
||||||
|
ok = inet:setopts(Socket, [{active, once}]),
|
||||||
|
receive
|
||||||
|
{tcp, Socket, Binary} ->
|
||||||
|
ok = handle(State, Binary),
|
||||||
|
loop(State);
|
||||||
|
{tcp_closed, Socket} ->
|
||||||
|
retire(State, normal);
|
||||||
|
{Ref, quote, Mochila} ->
|
||||||
|
Response = do_quote(State, Mochila),
|
||||||
|
gd_v_express ! {Ref, Response},
|
||||||
|
loop(State);
|
||||||
|
retire ->
|
||||||
|
retire(State, normal)
|
||||||
|
end.
|
||||||
|
|
||||||
|
|
||||||
|
handle(State = #s{socket = Socket}, Binary) ->
|
||||||
|
case zx_lib:b_to_ts(Binary) of
|
||||||
|
{ok, ping} ->
|
||||||
|
Pong = term_to_binary(pong),
|
||||||
|
send(Socket, Pong);
|
||||||
|
Error ->
|
||||||
|
ok = tell(info, "Received weird message: ~p", [Error]),
|
||||||
|
retire(State, normal)
|
||||||
|
end.
|
||||||
|
|
||||||
|
|
||||||
|
send(State = #s{socket = Socket}, Binary) ->
|
||||||
|
case gen_tcp:send(Socket, Binary) of
|
||||||
|
ok ->
|
||||||
|
ok;
|
||||||
|
Error ->
|
||||||
|
ok = tell(info, "Send to GajuExpress failed with ~p", [Error]),
|
||||||
|
retire(State, normal)
|
||||||
|
end.
|
||||||
|
|
||||||
|
|
||||||
|
do_quote(State = #s{socket = Socket}, MochilaSize) ->
|
||||||
|
Request = term_to_binary({quote, MochilaSize}),
|
||||||
|
ok = send(State, Request),
|
||||||
|
receive
|
||||||
|
{tcp, Socket, Binary} ->
|
||||||
|
read_quote(State, Binary)
|
||||||
|
after 5000 ->
|
||||||
|
retire(State, normal),
|
||||||
|
{error, timeout}
|
||||||
|
end.
|
||||||
|
|
||||||
|
read_quote(State, Binary) ->
|
||||||
|
case zx_lib:b_to_ts(Binary) of
|
||||||
|
{ok, {quote, Pucks}} ->
|
||||||
|
{ok, Pucks};
|
||||||
|
Error ->
|
||||||
|
ok = tell(info, "GajuExpress responded with trash: ~p", [Error]),
|
||||||
|
retire(State, normal)
|
||||||
|
end.
|
||||||
|
|
||||||
|
|
||||||
|
retire(#s{socket = none}, Reason) ->
|
||||||
|
gd_v_express ! {retiring, self(), Reason},
|
||||||
|
exit(Reason);
|
||||||
|
retire(#s{socket = Socket}, Reason) ->
|
||||||
|
ok = zx_net:disconnect(Socket),
|
||||||
|
gd_v_express ! {retiring, self(), Reason},
|
||||||
|
exit(Reason).
|
||||||
+1528
File diff suppressed because it is too large
Load Diff
@@ -1,5 +1,5 @@
|
|||||||
-module(gd_sophia_editor).
|
-module(gd_sophia_editor).
|
||||||
-vsn("0.9.0").
|
-vsn("0.10.0").
|
||||||
-export([new/1, update/1, update/2,
|
-export([new/1, update/1, update/2,
|
||||||
get_text/1, set_text/2]).
|
get_text/1, set_text/2]).
|
||||||
|
|
||||||
|
|||||||
+1
-1
@@ -12,7 +12,7 @@
|
|||||||
%%% @end
|
%%% @end
|
||||||
|
|
||||||
-module(gd_sup).
|
-module(gd_sup).
|
||||||
-vsn("0.9.0").
|
-vsn("0.10.0").
|
||||||
-behaviour(supervisor).
|
-behaviour(supervisor).
|
||||||
-author("Craig Everett <craigeverett@qpq.swiss>").
|
-author("Craig Everett <craigeverett@qpq.swiss>").
|
||||||
-copyright("QPQ AG <info@qpq.swiss>").
|
-copyright("QPQ AG <info@qpq.swiss>").
|
||||||
|
|||||||
+1
-1
@@ -1,5 +1,5 @@
|
|||||||
-module(gd_v).
|
-module(gd_v).
|
||||||
-vsn("0.9.0").
|
-vsn("0.10.0").
|
||||||
-author("Craig Everett <craigeverett@qpq.swiss>").
|
-author("Craig Everett <craigeverett@qpq.swiss>").
|
||||||
-copyright("QPQ AG <info@qpq.swiss>").
|
-copyright("QPQ AG <info@qpq.swiss>").
|
||||||
-license("GPL-3.0-or-later").
|
-license("GPL-3.0-or-later").
|
||||||
|
|||||||
+22
-12
@@ -1,5 +1,5 @@
|
|||||||
-module(gd_v_call).
|
-module(gd_v_call).
|
||||||
-vsn("0.9.0").
|
-vsn("0.10.0").
|
||||||
-author("Craig Everett <craigeverett@qpq.swiss>").
|
-author("Craig Everett <craigeverett@qpq.swiss>").
|
||||||
-copyright("QPQ AG <info@qpq.swiss>").
|
-copyright("QPQ AG <info@qpq.swiss>").
|
||||||
-license("GPL-3.0-or-later").
|
-license("GPL-3.0-or-later").
|
||||||
@@ -106,9 +106,12 @@ init({Prefs, FunDef = {FunName, FunIlk}, ConID, Build, Selected, Keys}) ->
|
|||||||
Title = [CallTypeLabel, ": ", ConName, ".", FunName, "/", Arity],
|
Title = [CallTypeLabel, ": ", ConName, ".", FunName, "/", Arity],
|
||||||
Wx = wx:new(),
|
Wx = wx:new(),
|
||||||
Frame = wxFrame:new(Wx, ?wxID_ANY, Title),
|
Frame = wxFrame:new(Wx, ?wxID_ANY, Title),
|
||||||
|
Panel = wxWindow:new(Frame, ?wxID_ANY),
|
||||||
|
TopSz = wxBoxSizer:new(?wxVERTICAL),
|
||||||
|
_ = wxBoxSizer:add(TopSz, Panel, zxw:flags(wide)),
|
||||||
MainSz = wxBoxSizer:new(?wxVERTICAL),
|
MainSz = wxBoxSizer:new(?wxVERTICAL),
|
||||||
|
|
||||||
KeySz = wxStaticBoxSizer:new(?wxVERTICAL, Frame, [{label, J("Signature Key")}]),
|
KeySz = wxStaticBoxSizer:new(?wxVERTICAL, Panel, [{label, J("Signature Key")}]),
|
||||||
KeyBox = wxStaticBoxSizer:getStaticBox(KeySz),
|
KeyBox = wxStaticBoxSizer:getStaticBox(KeySz),
|
||||||
KeyPicker = wxChoice:new(KeyBox, ?wxID_ANY, [{choices, Keys}]),
|
KeyPicker = wxChoice:new(KeyBox, ?wxID_ANY, [{choices, Keys}]),
|
||||||
KP = #w{name = key_picker, id = wxChoice:getId(KeyPicker), wx = KeyPicker},
|
KP = #w{name = key_picker, id = wxChoice:getId(KeyPicker), wx = KeyPicker},
|
||||||
@@ -116,12 +119,12 @@ init({Prefs, FunDef = {FunName, FunIlk}, ConID, Build, Selected, Keys}) ->
|
|||||||
ok = wxChoice:setSelection(KeyPicker, ZeroBasedSelected),
|
ok = wxChoice:setSelection(KeyPicker, ZeroBasedSelected),
|
||||||
_ = wxStaticBoxSizer:add(KeySz, KeyPicker, zxw:flags(wide)),
|
_ = wxStaticBoxSizer:add(KeySz, KeyPicker, zxw:flags(wide)),
|
||||||
|
|
||||||
{ArgSz, Args, Return, Copy, HasArgs} = call_arg_sizer(Frame, J, FunIlk, FunSpec),
|
{ArgSz, Args, Return, Copy, HasArgs} = call_arg_sizer(Panel, J, FunIlk, FunSpec),
|
||||||
{ParamSz, Params} = call_param_sizer(Frame, J),
|
{ParamSz, Params} = call_param_sizer(Panel, J),
|
||||||
|
|
||||||
Action = #w{wx = ActionBn} = gd_lib:button(Frame, ActionLabel),
|
Action = #w{wx = ActionBn} = gd_lib:button(Panel, ActionLabel),
|
||||||
|
|
||||||
TX_Sz = wxStaticBoxSizer:new(?wxVERTICAL, Frame, [{label, J("Transaction Info")}]),
|
TX_Sz = wxStaticBoxSizer:new(?wxVERTICAL, Panel, [{label, J("Transaction Info")}]),
|
||||||
TX_Sz_Box = wxStaticBoxSizer:getStaticBox(TX_Sz),
|
TX_Sz_Box = wxStaticBoxSizer:getStaticBox(TX_Sz),
|
||||||
Single = [{style, ?wxTE_READONLY}],
|
Single = [{style, ?wxTE_READONLY}],
|
||||||
Multi = [{style, ?wxTE_MULTILINE bor ?wxTE_READONLY}],
|
Multi = [{style, ?wxTE_MULTILINE bor ?wxTE_READONLY}],
|
||||||
@@ -142,9 +145,10 @@ init({Prefs, FunDef = {FunName, FunIlk}, ConID, Build, Selected, Keys}) ->
|
|||||||
_ = wxSizer:add(MainSz, ActionBn, zxw:flags({base, 5})),
|
_ = wxSizer:add(MainSz, ActionBn, zxw:flags({base, 5})),
|
||||||
_ = wxSizer:add(MainSz, TX_Sz, [{proportion, 1}, {flag, ?wxEXPAND bor ?wxALL}, {border, 5}]),
|
_ = wxSizer:add(MainSz, TX_Sz, [{proportion, 1}, {flag, ?wxEXPAND bor ?wxALL}, {border, 5}]),
|
||||||
|
|
||||||
_ = wxFrame:setSizer(Frame, MainSz),
|
ok = wxWindow:setSizer(Panel, MainSz),
|
||||||
_ = wxFrame:setSize(Frame, {900, 900}),
|
ok = wxFrame:setSizer(Frame, TopSz),
|
||||||
_ = wxSizer:layout(MainSz),
|
ok = wxFrame:setSize(Frame, {900, 900}),
|
||||||
|
ok = wxSizer:layout(MainSz),
|
||||||
ok = wxFrame:connect(Frame, close_window),
|
ok = wxFrame:connect(Frame, close_window),
|
||||||
ok = wxFrame:connect(Frame, command_button_clicked),
|
ok = wxFrame:connect(Frame, command_button_clicked),
|
||||||
true = wxFrame:show(Frame),
|
true = wxFrame:show(Frame),
|
||||||
@@ -443,7 +447,8 @@ do_dry_run(State = #s{action = #w{wx = ActionB}}, ConID, TX) ->
|
|||||||
end.
|
end.
|
||||||
|
|
||||||
|
|
||||||
dry_run2(State = #s{funret = ReturnType,
|
dry_run2(State = #s{j = J,
|
||||||
|
funret = ReturnType,
|
||||||
return = #w{wx = ReturnT},
|
return = #w{wx = ReturnT},
|
||||||
copy = #w{wx = CopyB},
|
copy = #w{wx = CopyB},
|
||||||
tx_data = TXData,
|
tx_data = TXData,
|
||||||
@@ -454,16 +459,21 @@ dry_run2(State = #s{funret = ReturnType,
|
|||||||
case TXInfo of
|
case TXInfo of
|
||||||
#{"results" :=
|
#{"results" :=
|
||||||
[#{"call_obj" :=
|
[#{"call_obj" :=
|
||||||
#{"return_type" := "revert",
|
#{"return_type" := "revert",
|
||||||
"return_value" := ReturnCB},
|
"return_value" := ReturnCB},
|
||||||
"result" := "ok","type" := "contract_call"}]} ->
|
"result" := "ok","type" := "contract_call"}]} ->
|
||||||
io_lib:format("Revert: ~ts", [hz:decode_bytearray(ReturnCB, sophia)]);
|
io_lib:format("Revert: ~ts", [hz:decode_bytearray(ReturnCB, sophia)]);
|
||||||
#{"results" :=
|
#{"results" :=
|
||||||
[#{"call_obj" :=
|
[#{"call_obj" :=
|
||||||
#{"return_type" := "ok",
|
#{"return_type" := "ok",
|
||||||
"return_value" := ReturnCB},
|
"return_value" := ReturnCB},
|
||||||
"result" := "ok","type" := "contract_call"}]} ->
|
"result" := "ok","type" := "contract_call"}]} ->
|
||||||
hz:decode_bytearray(ReturnCB, {sophia, ReturnType});
|
hz:decode_bytearray(ReturnCB, {sophia, ReturnType});
|
||||||
|
#{"results" :=
|
||||||
|
[#{"reason" := "Internal error:\n account_not_found\n",
|
||||||
|
"result" := "error",
|
||||||
|
"type" := "contract_call"}]} ->
|
||||||
|
["[", J("The calling account requires funds"), "]"];
|
||||||
Other ->
|
Other ->
|
||||||
io_lib:format("???: ~tp", [Other])
|
io_lib:format("???: ~tp", [Other])
|
||||||
end,
|
end,
|
||||||
|
|||||||
@@ -0,0 +1,589 @@
|
|||||||
|
%%% @private
|
||||||
|
%%% The GajuExpress
|
||||||
|
%%%
|
||||||
|
%%% 0. User opens GajuDesk and selects the key (very top widget)
|
||||||
|
%%%
|
||||||
|
%%% Sending...
|
||||||
|
%%%
|
||||||
|
%%% 1. The user inputs the public key/ID of the party the data should be sent to
|
||||||
|
%%% 2. The user picks the file or directory to send
|
||||||
|
%%% 3. The user decides whether to sign the package or be anonymous
|
||||||
|
%%% 4. The user sets the package's TTL
|
||||||
|
%%% 5. GajuDesk packs up and compresses the bundle.
|
||||||
|
%%% 6. GajuDesk asks GajuExpress for a quote based on size/time
|
||||||
|
%%% 7. The price is shown
|
||||||
|
%%% 8. The user agrees or aborts
|
||||||
|
%%% 9. If the user agrees, a payment window opens and they send a payment to GajuExpress
|
||||||
|
%%% 10. GajuDesk polls until the payment is included or the user gives up
|
||||||
|
%%% 11. Once GajuExpress verifies the payment, the upload begins
|
||||||
|
%%% 12. Progress bar
|
||||||
|
%%%
|
||||||
|
%%%
|
||||||
|
%%% Receiving...
|
||||||
|
%%%
|
||||||
|
%%% 1. User clicks "check for deliveries"
|
||||||
|
%%% 2. GajuExpress issues an ID signature challenge
|
||||||
|
%%% 3. GajuDesk asks GajuExpress whether there are any packages waiting for Key
|
||||||
|
%%% 4. If yes, then the pending deliveries are shown in the delivery panel
|
||||||
|
%%% 5. The user selects + clicks open (or double clicks) a package
|
||||||
|
%%% 6. User selects where to unpack it in a file dialog
|
||||||
|
%%% 7. GajuDesk downloads the package from GajuExpress
|
||||||
|
%%% 8. Progress bar
|
||||||
|
%%% 9. File is decrypted and optionally signature verified
|
||||||
|
%%% 10. GajuExpress deletes their copy of the file
|
||||||
|
%%% @end
|
||||||
|
|
||||||
|
|
||||||
|
-module(gd_v_express).
|
||||||
|
-vsn("0.10.0").
|
||||||
|
-author("Craig Everett <zxq9@zxq9.com>").
|
||||||
|
-copyright("QPQ AG <info@qpq.swiss>").
|
||||||
|
-license("GPL-3.0-or-later").
|
||||||
|
|
||||||
|
-behavior(wx_object).
|
||||||
|
%-behavior(gd_v).
|
||||||
|
-include_lib("wx/include/wx.hrl").
|
||||||
|
-export([to_front/0, to_front/1, trouble/1]).
|
||||||
|
-export([pending/1, accounts/1, retire/2]).
|
||||||
|
-export([start_link/1]).
|
||||||
|
-export([init/1, terminate/2, code_change/3,
|
||||||
|
handle_call/3, handle_cast/2, handle_info/2, handle_event/2]).
|
||||||
|
-include("$zx_include/zx_logger.hrl").
|
||||||
|
-include("gd.hrl").
|
||||||
|
-include("gdl.hrl").
|
||||||
|
|
||||||
|
|
||||||
|
-record(s,
|
||||||
|
{wx = none :: none | wx:wx_object(),
|
||||||
|
frame = none :: none | wx:wx_object(),
|
||||||
|
lang = en :: en | jp,
|
||||||
|
j = none :: none | fun(),
|
||||||
|
prefs = #{} :: map(),
|
||||||
|
keys = #w{} :: #w{},
|
||||||
|
accs = [] :: [#wr{}],
|
||||||
|
rider = none :: none | pid(),
|
||||||
|
recvr = none :: none | pid(),
|
||||||
|
check = #w{} :: #w{},
|
||||||
|
list = #w{} :: #w{},
|
||||||
|
dl = #w{} :: #w{},
|
||||||
|
dest = none :: none | wx:wx_object(),
|
||||||
|
ttl = none :: none | wx:wx_object(),
|
||||||
|
path = none :: none | wx:wx_object(),
|
||||||
|
sign = none :: none | wx:wx_object(),
|
||||||
|
size = none :: none | wx:wx_object(),
|
||||||
|
cost = none :: none | wx:wx_object(),
|
||||||
|
quote = none :: none | pos_integer(),
|
||||||
|
ul = none :: none | wx:wx_object()}).
|
||||||
|
|
||||||
|
%-record(mochila,
|
||||||
|
% {tar = <<>> :: binary(),
|
||||||
|
% sig = none :: none | {Key :: binary(), Sig :: binary()}}).
|
||||||
|
|
||||||
|
|
||||||
|
-type meta() :: {Name :: binary(), % UTF8 binary string
|
||||||
|
Size :: pos_integer(), % Size in bytes
|
||||||
|
TS :: pos_integer(), % Timestamp is the height at creation
|
||||||
|
TTL :: pos_integer(), % Expiry height is TS + TTL
|
||||||
|
Sig :: none | sig()}.
|
||||||
|
-type sig() :: {ID :: id(),
|
||||||
|
Sig :: binary()}.
|
||||||
|
-type id() :: binary(). % ID is binary string of the pubkey, serialized <<"ak_...">>
|
||||||
|
|
||||||
|
|
||||||
|
%%% Interface
|
||||||
|
|
||||||
|
-spec to_front() -> ok.
|
||||||
|
|
||||||
|
to_front() ->
|
||||||
|
wx_object:cast(?MODULE, to_front).
|
||||||
|
|
||||||
|
|
||||||
|
-spec to_front(Win) -> ok
|
||||||
|
when Win :: wx:wx_object().
|
||||||
|
|
||||||
|
to_front(Win) ->
|
||||||
|
wx_object:cast(Win, to_front).
|
||||||
|
|
||||||
|
|
||||||
|
-spec trouble(Info) -> ok
|
||||||
|
when Info :: term().
|
||||||
|
|
||||||
|
trouble(Info) ->
|
||||||
|
wx_object:cast(?MODULE, {trouble, Info}).
|
||||||
|
|
||||||
|
|
||||||
|
-spec pending(Manifest) -> ok
|
||||||
|
when Manifest :: [meta()].
|
||||||
|
|
||||||
|
pending(Manifest) ->
|
||||||
|
wx_object:cast(?MODULE, {pending, Manifest}).
|
||||||
|
|
||||||
|
|
||||||
|
-spec accounts(Manifest) -> ok
|
||||||
|
when Manifest :: [#wr{}].
|
||||||
|
|
||||||
|
accounts(Manifest) ->
|
||||||
|
wx_object:cast(?MODULE, {accounts, Manifest}).
|
||||||
|
|
||||||
|
|
||||||
|
-spec retire(PID, Info) -> ok
|
||||||
|
when PID :: pid(),
|
||||||
|
Info :: term().
|
||||||
|
|
||||||
|
retire(PID, Info) ->
|
||||||
|
gen_server:cast(?MODULE, {retire, PID, Info}).
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
%%% Startup
|
||||||
|
|
||||||
|
start_link(Args) ->
|
||||||
|
wx_object:start_link({local, ?MODULE}, ?MODULE, Args, []).
|
||||||
|
|
||||||
|
init({Prefs, {Selected, Keys}}) ->
|
||||||
|
Lang = maps:get(lang, Prefs, en),
|
||||||
|
Trans = gd_jt:read_translations(?MODULE),
|
||||||
|
J = gd_jt:j(Lang, Trans),
|
||||||
|
Wx = wx:new(),
|
||||||
|
Frame = wxFrame:new(Wx, ?wxID_ANY, J("GajuExpress")),
|
||||||
|
Panel = wxWindow:new(Frame, ?wxID_ANY),
|
||||||
|
TopSz = wxBoxSizer:new(?wxVERTICAL),
|
||||||
|
_ = wxBoxSizer:add(TopSz, Panel, zxw:flags(wide)),
|
||||||
|
MainSz = wxBoxSizer:new(?wxVERTICAL),
|
||||||
|
LR_Sz = wxBoxSizer:new(?wxHORIZONTAL),
|
||||||
|
|
||||||
|
KeyP = wxChoice:new(Panel, ?wxID_ANY, [{choices, Keys}]),
|
||||||
|
KP = #w{name = key_picker, id = wxChoice:getId(KeyP), wx = KeyP},
|
||||||
|
ZeroBasedSelected = Selected - 1,
|
||||||
|
ok = wxChoice:setSelection(KeyP, ZeroBasedSelected),
|
||||||
|
_ = wxStaticBoxSizer:add(MainSz, KeyP, zxw:flags({base, 5})),
|
||||||
|
|
||||||
|
DownloadSz = wxStaticBoxSizer:new(?wxVERTICAL, Panel, [{label, J("Downloads")}]),
|
||||||
|
DownloadBox = wxStaticBoxSizer:getStaticBox(DownloadSz),
|
||||||
|
CheckB = #w{wx = CheckW} = make_button(DownloadBox, check, J("Check for Downloads")),
|
||||||
|
DownloadP = wxListBox:new(DownloadBox, ?wxID_ANY, [{style, ?wxLC_SINGLE_SEL}]),
|
||||||
|
DL_L = #w{name = list, id = wxListBox:getId(DownloadP), wx = DownloadP},
|
||||||
|
DownloadB = #w{wx = DownloadW} = make_button(DownloadBox, dl, J("Download")),
|
||||||
|
_ = wxButton:disable(DownloadW),
|
||||||
|
_ = wxBoxSizer:add(DownloadSz, CheckW, zxw:flags({base, 5})),
|
||||||
|
_ = wxBoxSizer:add(DownloadSz, DownloadP, zxw:flags({wide, 5})),
|
||||||
|
_ = wxBoxSizer:add(DownloadSz, DownloadW, zxw:flags({base, 5})),
|
||||||
|
|
||||||
|
UploadSz = wxStaticBoxSizer:new(?wxVERTICAL, Panel, [{label, J("Uploads")}]),
|
||||||
|
UploadBox = wxStaticBoxSizer:getStaticBox(UploadSz),
|
||||||
|
DestSz = wxStaticBoxSizer:new(?wxHORIZONTAL, UploadBox, [{label, J("Destination ID")}]),
|
||||||
|
DestBox = wxStaticBoxSizer:getStaticBox(DestSz),
|
||||||
|
DestT = wxTextCtrl:new(DestBox, ?wxID_ANY),
|
||||||
|
_ = wxStaticBoxSizer:add(DestSz, DestT, zxw:flags({wide,5})),
|
||||||
|
_ = wxStaticBoxSizer:add(UploadSz, DestSz, zxw:flags({wide,5})),
|
||||||
|
TTL_Sz = wxStaticBoxSizer:new(?wxHORIZONTAL, UploadBox, [{label, J("Transfer Expiration (Days)")}]),
|
||||||
|
TTL_Box = wxStaticBoxSizer:getStaticBox(TTL_Sz),
|
||||||
|
TTL_T = wxTextCtrl:new(TTL_Box, ?wxID_ANY, [{value, "7"}]),
|
||||||
|
_ = wxStaticBoxSizer:add(TTL_Sz, TTL_T, zxw:flags({wide,5})),
|
||||||
|
_ = wxStaticBoxSizer:add(UploadSz, TTL_Sz, zxw:flags({wide,5})),
|
||||||
|
PathSz = wxStaticBoxSizer:new(?wxHORIZONTAL, UploadBox, [{label, J("File or Directory")}]),
|
||||||
|
PathBox = wxStaticBoxSizer:getStaticBox(PathSz),
|
||||||
|
PathP = wxFilePickerCtrl:new(PathBox, ?wxID_ANY),
|
||||||
|
_ = wxStaticBoxSizer:add(PathSz, PathP, zxw:flags({wide,5})),
|
||||||
|
_ = wxStaticBoxSizer:add(UploadSz, PathSz, zxw:flags({wide,5})),
|
||||||
|
SignSz = wxStaticBoxSizer:new(?wxHORIZONTAL, UploadBox, [{label, J("Transfer Signature")}]),
|
||||||
|
SignBox = wxStaticBoxSizer:getStaticBox(SignSz),
|
||||||
|
SignC = wxCheckBox:new(SignBox, ?wxID_ANY, J("Do you want to sign this transfer?")),
|
||||||
|
_ = wxStaticBoxSizer:add(SignSz, SignC, zxw:flags({wide,5})),
|
||||||
|
_ = wxStaticBoxSizer:add(UploadSz, SignSz, zxw:flags({wide,5})),
|
||||||
|
SizeSz = wxStaticBoxSizer:new(?wxHORIZONTAL, UploadBox, [{label, J("Transfer Size")}]),
|
||||||
|
SizeBox = wxStaticBoxSizer:getStaticBox(SizeSz),
|
||||||
|
SizeT = wxStaticText:new(SizeBox, ?wxID_ANY, J("[No File or Directory Selected]")),
|
||||||
|
_ = wxStaticBoxSizer:add(SizeSz, SizeT, zxw:flags({wide,5})),
|
||||||
|
_ = wxStaticBoxSizer:add(UploadSz, SizeSz, zxw:flags({wide,5})),
|
||||||
|
CostSz = wxStaticBoxSizer:new(?wxHORIZONTAL, UploadBox, [{label, J("Cost to Transfer")}]),
|
||||||
|
CostBox = wxStaticBoxSizer:getStaticBox(CostSz),
|
||||||
|
CostT = wxStaticText:new(CostBox, ?wxID_ANY, "[N/A]"),
|
||||||
|
_ = wxStaticBoxSizer:add(CostSz, CostT, zxw:flags({wide,5})),
|
||||||
|
_ = wxStaticBoxSizer:add(UploadSz, CostSz, zxw:flags({wide,5})),
|
||||||
|
UploadB = #w{wx = UploadW} = make_button(UploadBox, ul, J("Check Quote")),
|
||||||
|
_ = wxButton:disable(UploadW),
|
||||||
|
_ = wxStaticBoxSizer:add(UploadSz, UploadW, zxw:flags({base,5})),
|
||||||
|
|
||||||
|
_ = wxBoxSizer:add(LR_Sz, DownloadSz, zxw:flags({wide, 5})),
|
||||||
|
_ = wxBoxSizer:add(LR_Sz, UploadSz, zxw:flags({wide, 5})),
|
||||||
|
_ = wxBoxSizer:add(MainSz, LR_Sz, zxw:flags({wide, 5})),
|
||||||
|
ok = wxPanel:setSizer(Panel, MainSz),
|
||||||
|
ok = wxFrame:setSizer(Frame, TopSz),
|
||||||
|
ok = wxSizer:layout(TopSz),
|
||||||
|
|
||||||
|
NewPrefs =
|
||||||
|
case maps:is_key(geometry, Prefs) of
|
||||||
|
true ->
|
||||||
|
Prefs;
|
||||||
|
false ->
|
||||||
|
Display = wxDisplay:new(),
|
||||||
|
{_, _, W, H} = wxDisplay:getGeometry(Display),
|
||||||
|
ok = wxDisplay:destroy(Display),
|
||||||
|
WW = 500,
|
||||||
|
WH = 350,
|
||||||
|
X = (W div 2) - (WW div 2),
|
||||||
|
Y = (H div 2) - (WH div 2),
|
||||||
|
Prefs#{geometry => {X, Y, WW, WH}}
|
||||||
|
end,
|
||||||
|
ok = gd_v:safe_size(Frame, NewPrefs),
|
||||||
|
|
||||||
|
ok = wxTextCtrl:connect(DestT, command_text_updated),
|
||||||
|
ok = wxPanel:dragAcceptFiles(Panel, true),
|
||||||
|
ok = wxPanel:connect(Panel, drop_files),
|
||||||
|
ok = wxFrame:connect(Frame, command_button_clicked),
|
||||||
|
ok = wxFrame:connect(Frame, command_choice_selected),
|
||||||
|
ok = wxFrame:connect(Frame, close_window),
|
||||||
|
ok = wxListBox:connect(DownloadP, command_listbox_doubleclicked),
|
||||||
|
true = wxFrame:show(Frame),
|
||||||
|
State = #s{wx = Wx, frame = Frame, lang = Lang, j = J, prefs = Prefs,
|
||||||
|
keys = KP, accs = Keys,
|
||||||
|
check = CheckB, list = DL_L,
|
||||||
|
dl = DownloadB,
|
||||||
|
dest = DestT, ttl = TTL_T, path = PathP, sign = SignC,
|
||||||
|
size = SizeT, cost = CostT,
|
||||||
|
ul = UploadB},
|
||||||
|
{Frame, State}.
|
||||||
|
|
||||||
|
make_button(Parent, Name, Label) ->
|
||||||
|
B = wxButton:new(Parent, ?wxID_ANY, [{label, Label}]),
|
||||||
|
#w{name = Name, id = wxButton:getId(B), wx = B}.
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
%%% wx_object
|
||||||
|
|
||||||
|
handle_call(Unexpected, From, State) ->
|
||||||
|
ok = log(warning, "Unexpected call from ~tp: ~tp~n", [From, Unexpected]),
|
||||||
|
{noreply, State}.
|
||||||
|
|
||||||
|
handle_cast({pending, Manifest}, State) ->
|
||||||
|
NewState = do_pending(Manifest, State),
|
||||||
|
{noreply, NewState};
|
||||||
|
handle_cast({accounts, Manifest}, State) ->
|
||||||
|
NewState = do_accounts(Manifest, State),
|
||||||
|
{noreply, NewState};
|
||||||
|
handle_cast({retire, PID, Info}, State) ->
|
||||||
|
NewState = do_retire(PID, Info, State),
|
||||||
|
{noreply, NewState};
|
||||||
|
handle_cast(to_front, State = #s{frame = Frame}) ->
|
||||||
|
ok = ensure_shown(Frame),
|
||||||
|
ok = wxFrame:raise(Frame),
|
||||||
|
{noreply, State};
|
||||||
|
handle_cast({trouble, Info}, State) ->
|
||||||
|
ok = handle_troubling(State, Info),
|
||||||
|
{noreply, State};
|
||||||
|
handle_cast(Unexpected, State) ->
|
||||||
|
ok = log(warning, "Unexpected cast: ~tp~n", [Unexpected]),
|
||||||
|
{noreply, State}.
|
||||||
|
|
||||||
|
|
||||||
|
handle_info(Unexpected, State) ->
|
||||||
|
ok = log(warning, "Unexpected info: ~tp~n", [Unexpected]),
|
||||||
|
{noreply, State}.
|
||||||
|
|
||||||
|
|
||||||
|
handle_event(#wx{event = #wxCommand{type = command_button_clicked}, id = ID},
|
||||||
|
State = #s{check = #w{id = ID}}) ->
|
||||||
|
NewState = do_check(State),
|
||||||
|
{noreply, NewState};
|
||||||
|
handle_event(#wx{event = #wxCommand{type = command_button_clicked}, id = ID},
|
||||||
|
State = #s{dl = #w{id = ID}}) ->
|
||||||
|
NewState = do_dl(State),
|
||||||
|
{noreply, NewState};
|
||||||
|
handle_event(#wx{event = #wxCommand{type = command_button_clicked}, id = ID},
|
||||||
|
State = #s{ul = #w{id = ID}}) ->
|
||||||
|
NewState = do_ul(State),
|
||||||
|
{noreply, NewState};
|
||||||
|
handle_event(#wx{event = #wxCommand{type = command_choice_selected}}, State) ->
|
||||||
|
ok = kill_recvr(State),
|
||||||
|
{noreply, State};
|
||||||
|
handle_event(#wx{event = #wxCommand{type = command_listbox_doubleclicked}}, State) ->
|
||||||
|
NewState = do_dl(State),
|
||||||
|
{noreply, NewState};
|
||||||
|
handle_event(#wx{event = #wxCommand{type = command_text_updated}}, State) ->
|
||||||
|
NewState = do_check_ul_button(State),
|
||||||
|
{noreply, NewState};
|
||||||
|
handle_event(#wx{event = #wxDropFiles{files = Files}}, State) ->
|
||||||
|
NewState = do_drop(Files, State),
|
||||||
|
{noreply, NewState};
|
||||||
|
handle_event(#wx{event = #wxClose{}}, State) ->
|
||||||
|
ok = do_close(State),
|
||||||
|
{noreply, State};
|
||||||
|
handle_event(Event, State) ->
|
||||||
|
ok = tell(info, "Unexpected event ~tp State: ~tp~n", [Event, State]),
|
||||||
|
{noreply, State}.
|
||||||
|
|
||||||
|
handle_troubling(#s{frame = Frame}, Info) ->
|
||||||
|
zxw:show_message(Frame, Info).
|
||||||
|
|
||||||
|
|
||||||
|
code_change(_, State, _) ->
|
||||||
|
{ok, State}.
|
||||||
|
|
||||||
|
|
||||||
|
terminate(wx_deleted, _) ->
|
||||||
|
wx:destroy();
|
||||||
|
terminate(Reason, State) ->
|
||||||
|
ok = log(info, "Reason: ~tp, State: ~tp", [Reason, State]),
|
||||||
|
wx:destroy().
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
%%% doers
|
||||||
|
|
||||||
|
do_pending(Manifest, State) ->
|
||||||
|
ok = tell(info, "Would do_pending: ~p", [Manifest]),
|
||||||
|
State.
|
||||||
|
|
||||||
|
|
||||||
|
do_accounts(Manifest, State) ->
|
||||||
|
ok = tell(info, "Would do_accounts: ~p", [Manifest]),
|
||||||
|
State.
|
||||||
|
|
||||||
|
|
||||||
|
do_check(State = #s{recvr = none, keys = #w{wx = KeyP}}) ->
|
||||||
|
case wxChoice:getStringSelection(KeyP) of
|
||||||
|
"" ->
|
||||||
|
State;
|
||||||
|
KeyID ->
|
||||||
|
PubKey = list_to_binary(KeyID),
|
||||||
|
PID = spawn_link(gd_n_recvr, init, [PubKey, {"localhost", 7777}]),
|
||||||
|
do_check2(State#s{recvr = PID})
|
||||||
|
end;
|
||||||
|
do_check(State = #s{recvr = PID}) ->
|
||||||
|
case gd_n_recvr:check(PID) of
|
||||||
|
ok -> State;
|
||||||
|
{ok, Challenge} -> challenge(State, Challenge)
|
||||||
|
end.
|
||||||
|
|
||||||
|
|
||||||
|
do_check2(State = #s{recvr = PID}) ->
|
||||||
|
case gd_n_recvr:check(PID) of
|
||||||
|
{ok, Challenge} ->
|
||||||
|
challenge(State, Challenge);
|
||||||
|
{error, Reason} ->
|
||||||
|
ok = tell(info, "GajuExpress connection failed with: ~p", [Reason]),
|
||||||
|
State#s{recvr = none}
|
||||||
|
end.
|
||||||
|
|
||||||
|
challenge(State = #s{recvr = PID, keys = #w{wx = KeyP}}, Challenge) ->
|
||||||
|
case wxChoice:getStringSelection(KeyP) of
|
||||||
|
"" ->
|
||||||
|
ok = gd_n_recvr:stop(PID),
|
||||||
|
State;
|
||||||
|
KeyID ->
|
||||||
|
PubKey = list_to_binary(KeyID),
|
||||||
|
prompt_challenge(State, PubKey, Challenge)
|
||||||
|
end.
|
||||||
|
|
||||||
|
%% TODO: This should really be a live modal instead.
|
||||||
|
%% It needs to have a countdown, possibly a server-side reset negotiation,
|
||||||
|
%% and be able to react to server-side actions like the socket being shut down.
|
||||||
|
prompt_challenge(State = #s{recvr = PID, frame = Frame, j = J}, PubKey, Challenge) ->
|
||||||
|
Dialog = wxDialog:new(Frame, ?wxID_ANY, J("Message Signature Request")),
|
||||||
|
Sizer = wxBoxSizer:new(?wxVERTICAL),
|
||||||
|
Instruction = J("GajuExpress is requesting an authentication signature."),
|
||||||
|
InstTx = wxStaticText:new(Dialog, ?wxID_ANY, Instruction),
|
||||||
|
AcctSz = wxStaticBoxSizer:new(?wxVERTICAL, Dialog, [{label, J("Signature Account")}]),
|
||||||
|
AcctTx = wxStaticText:new(Dialog, ?wxID_ANY, PubKey),
|
||||||
|
_ = wxStaticBoxSizer:add(AcctSz, AcctTx, zxw:flags({wide, 5})),
|
||||||
|
MessSz = wxStaticBoxSizer:new(?wxVERTICAL, Dialog, [{label, J("Message")}]),
|
||||||
|
MessStyle = ?wxTE_MULTILINE bor ?wxTE_READONLY,
|
||||||
|
MessTx = wxTextCtrl:new(Dialog, ?wxID_ANY, [{value, Challenge}, {style, MessStyle}]),
|
||||||
|
_ = wxStaticBoxSizer:add(MessSz, MessTx, zxw:flags({wide, 5})),
|
||||||
|
ButtSz = wxBoxSizer:new(?wxHORIZONTAL),
|
||||||
|
Affirm = wxButton:new(Dialog, ?wxID_OK),
|
||||||
|
Cancel = wxButton:new(Dialog, ?wxID_CANCEL),
|
||||||
|
_ = wxBoxSizer:add(ButtSz, Affirm, zxw:flags({wide, 5})),
|
||||||
|
_ = wxBoxSizer:add(ButtSz, Cancel, zxw:flags({wide, 5})),
|
||||||
|
_ = wxBoxSizer:add(Sizer, InstTx, zxw:flags({base, 5})),
|
||||||
|
_ = wxBoxSizer:add(Sizer, AcctSz, zxw:flags({base, 5})),
|
||||||
|
_ = wxBoxSizer:add(Sizer, MessSz, zxw:flags({wide, 5})),
|
||||||
|
_ = wxBoxSizer:add(Sizer, ButtSz, zxw:flags(base)),
|
||||||
|
ok = wxDialog:setSizer(Dialog, Sizer),
|
||||||
|
ok = wxDialog:setSize(Dialog, {600, 300}),
|
||||||
|
ok = wxBoxSizer:layout(Sizer),
|
||||||
|
ok = wxFrame:center(Dialog),
|
||||||
|
Outcome =
|
||||||
|
case wxDialog:showModal(Dialog) of
|
||||||
|
?wxID_OK -> ok;
|
||||||
|
?wxID_CANCEL -> cancel
|
||||||
|
end,
|
||||||
|
ok = wxDialog:destroy(Dialog),
|
||||||
|
case Outcome of
|
||||||
|
ok ->
|
||||||
|
handle_challenge(State, PubKey, Challenge);
|
||||||
|
cancel ->
|
||||||
|
ok = gd_n_recvr:stop(PID),
|
||||||
|
State
|
||||||
|
end.
|
||||||
|
|
||||||
|
handle_challenge(State = #s{recvr = PID}, PubKey, Challenge) ->
|
||||||
|
case gd_con:sign_binary(PubKey, Challenge) of
|
||||||
|
{ok, Sig} ->
|
||||||
|
respond(State, Sig);
|
||||||
|
{error, bad_key} ->
|
||||||
|
ok = gd_n_recvr:stop(PID),
|
||||||
|
State
|
||||||
|
end.
|
||||||
|
|
||||||
|
respond(State = #s{recvr = PID}, Sig) ->
|
||||||
|
ok =
|
||||||
|
case gd_n_recvr:response(PID, Sig) of
|
||||||
|
ok -> ok;
|
||||||
|
{error, Reason} -> ok = tell(info, "~p: ~p", [PID, Reason])
|
||||||
|
end,
|
||||||
|
State.
|
||||||
|
|
||||||
|
|
||||||
|
do_dl(State) ->
|
||||||
|
ok = tell(info, "Would do_dl."),
|
||||||
|
State.
|
||||||
|
|
||||||
|
|
||||||
|
do_check_ul_button(State = #s{ul = #w{wx = UL_B}}) ->
|
||||||
|
_ = wxButton:enable(UL_B, [{enable, should_enable_quote(State)}]),
|
||||||
|
State.
|
||||||
|
|
||||||
|
|
||||||
|
do_drop([Path], State = #s{path = PathP, ul = #w{wx = UL_B}}) ->
|
||||||
|
ok = tell(info, "Path: ~ts", [Path]),
|
||||||
|
ok =
|
||||||
|
case filelib:is_file(Path) of
|
||||||
|
true ->
|
||||||
|
ok = wxFilePickerCtrl:setPath(PathP, Path),
|
||||||
|
_ = wxButton:enable(UL_B, [{enable, should_enable_quote(State)}]),
|
||||||
|
ok;
|
||||||
|
false ->
|
||||||
|
tell(warning, "Thank you, Mario! But our file is in a different path.")
|
||||||
|
end,
|
||||||
|
State;
|
||||||
|
do_drop(Paths, State) ->
|
||||||
|
ok = tell(info, "Paths: ~tp", [Paths]),
|
||||||
|
ok = tell(info, "THIS IS A NO NO"),
|
||||||
|
State.
|
||||||
|
|
||||||
|
should_enable_quote(#s{dest = DestT, path = PathP}) ->
|
||||||
|
DestKey = wxTextCtrl:getValue(DestT),
|
||||||
|
Path = wxFilePickerCtrl:getPath(PathP),
|
||||||
|
length(DestKey) > 0 andalso length(Path) > 0.
|
||||||
|
|
||||||
|
|
||||||
|
do_ul(State = #s{quote = none, rider = none}) ->
|
||||||
|
check_quote(State);
|
||||||
|
do_ul(State) ->
|
||||||
|
ok = tell(info, "Would do_ul."),
|
||||||
|
State.
|
||||||
|
|
||||||
|
|
||||||
|
check_quote(State = #s{dest = DestT}) ->
|
||||||
|
Dest = wxTextCtrl:getValue(DestT),
|
||||||
|
case gmser_api_encoder:safe_decode(account_pubkey, list_to_binary(Dest)) of
|
||||||
|
{ok, PubKey} ->
|
||||||
|
check_quote2(State, PubKey);
|
||||||
|
{error, Reason} ->
|
||||||
|
tell(warning, "Destination Key decode failed with: ~p", [Reason]),
|
||||||
|
State
|
||||||
|
end.
|
||||||
|
|
||||||
|
check_quote2(State = #s{path = PathP}, PubKey) ->
|
||||||
|
Path = wxFilePickerCtrl:getPath(PathP),
|
||||||
|
case filelib:is_file(Path) of
|
||||||
|
true ->
|
||||||
|
check_quote3(State, PubKey, Path);
|
||||||
|
false ->
|
||||||
|
tell(info, "File path isn't a file"),
|
||||||
|
State
|
||||||
|
end.
|
||||||
|
|
||||||
|
check_quote3(State = #s{ttl = TTL_T}, PubKey, Path) ->
|
||||||
|
TTL_S = wxTextCtrl:getValue(TTL_T),
|
||||||
|
case string_to_int(TTL_S) of
|
||||||
|
{ok, TTL} ->
|
||||||
|
check_quote4(State, PubKey, Path, TTL);
|
||||||
|
error ->
|
||||||
|
tell(info, "TTL isn't an integer"),
|
||||||
|
State
|
||||||
|
end.
|
||||||
|
|
||||||
|
check_quote4(State = #s{sign = SigC}, PubKey, Path, TTL) ->
|
||||||
|
SigYN = wxCheckBox:is_checked(SigC),
|
||||||
|
check_quote5(State, PubKey, Path, TTL, SigYN).
|
||||||
|
|
||||||
|
check_quote5(State, PubKey, Path, TTL, SigYN) ->
|
||||||
|
Tar = tar_path(),
|
||||||
|
case erl_tar:create(TarPath, Path, [compressed, dereference]) of
|
||||||
|
ok ->
|
||||||
|
check_quote6(State, PubKey, TTL, SigYN, Tar);
|
||||||
|
{error, Reason} ->
|
||||||
|
tell(warning, "Tar operation failed with: ~p", [Reason]),
|
||||||
|
State
|
||||||
|
end.
|
||||||
|
|
||||||
|
check_quote6(State, PubKey, TTL, SigYN, Tar) ->
|
||||||
|
|
||||||
|
|
||||||
|
tar_path() ->
|
||||||
|
TarFile = integer_to_list(erlang:system_time(seconds)) ++ "tar.gz",
|
||||||
|
filename:join(zx_lib:path(tmp, "otpr", "gajudesk"), TarFile).
|
||||||
|
|
||||||
|
check_quote6(State, PubKey, Path, TTL, SigYN, Tar) ->
|
||||||
|
|
||||||
|
% PID = spawn_link(gd_n_rider, init, [PubKey, {"localhost", 7777}]),
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
string_to_int(S) ->
|
||||||
|
try
|
||||||
|
{ok, list_to_integer(S)}
|
||||||
|
catch
|
||||||
|
error:bad_arg -> error
|
||||||
|
end.
|
||||||
|
|
||||||
|
|
||||||
|
do_close(#s{frame = Frame, prefs = Prefs}) ->
|
||||||
|
Geometry =
|
||||||
|
case wxTopLevelWindow:isMaximized(Frame) of
|
||||||
|
true ->
|
||||||
|
max;
|
||||||
|
false ->
|
||||||
|
{X, Y} = wxWindow:getPosition(Frame),
|
||||||
|
{W, H} = wxWindow:getSize(Frame),
|
||||||
|
{X, Y, W, H}
|
||||||
|
end,
|
||||||
|
NewPrefs = maps:put(geometry, Geometry, Prefs),
|
||||||
|
ok = gd_con:save(?MODULE, NewPrefs),
|
||||||
|
ok = wxWindow:destroy(Frame).
|
||||||
|
|
||||||
|
|
||||||
|
%default_name() ->
|
||||||
|
% {{YY, MM, DD}, {Hr, Mn, Sc}} = calendar:local_time(),
|
||||||
|
% Form = "~4.10.0B-~2.10.0B-~2.10.0B_~2.10.0B-~2.10.0B-~2.10.0B",
|
||||||
|
% Name = io_lib:format(Form, [YY, MM, DD, Hr, Mn, Sc]),
|
||||||
|
% unicode:characters_to_list(Name ++ ".gaju").
|
||||||
|
|
||||||
|
|
||||||
|
kill_recvr(#s{recvr = none}) -> ok;
|
||||||
|
kill_recvr(#s{recvr = PID}) -> gd_n_recvr:stop(PID).
|
||||||
|
|
||||||
|
|
||||||
|
do_retire(PID, Info, State = #s{rider = PID}) ->
|
||||||
|
ok = tell(info, "Rider retired with: ~p", [Info]),
|
||||||
|
State#s{rider = none};
|
||||||
|
do_retire(PID, Info, State = #s{recvr = PID}) ->
|
||||||
|
ok = tell(info, "Recvr retired with: ~p", [Info]),
|
||||||
|
State#s{recvr = none};
|
||||||
|
do_retire(PID, Info, State) ->
|
||||||
|
ok = tell(info, "~p retired with: ~p", [PID, Info]),
|
||||||
|
State.
|
||||||
|
|
||||||
|
|
||||||
|
ensure_shown(Frame) ->
|
||||||
|
case wxWindow:isShown(Frame) of
|
||||||
|
true ->
|
||||||
|
ok;
|
||||||
|
false ->
|
||||||
|
true = wxFrame:show(Frame),
|
||||||
|
ok
|
||||||
|
end.
|
||||||
@@ -1,5 +1,5 @@
|
|||||||
-module(gd_v_devman).
|
-module(gd_v_fateweaver).
|
||||||
-vsn("0.9.0").
|
-vsn("0.10.0").
|
||||||
-author("Craig Everett <craigeverett@qpq.swiss>").
|
-author("Craig Everett <craigeverett@qpq.swiss>").
|
||||||
-copyright("QPQ AG <info@qpq.swiss>").
|
-copyright("QPQ AG <info@qpq.swiss>").
|
||||||
-license("GPL-3.0-or-later").
|
-license("GPL-3.0-or-later").
|
||||||
@@ -128,7 +128,7 @@ init({Prefs, Manifest}) ->
|
|||||||
Trans = gd_jt:read_translations(?MODULE),
|
Trans = gd_jt:read_translations(?MODULE),
|
||||||
J = gd_jt:j(Lang, Trans),
|
J = gd_jt:j(Lang, Trans),
|
||||||
Wx = wx:new(),
|
Wx = wx:new(),
|
||||||
Frame = wxFrame:new(Wx, ?wxID_ANY, J("Contracts")),
|
Frame = wxFrame:new(Wx, ?wxID_ANY, "FateWeaver"),
|
||||||
|
|
||||||
MainSz = wxBoxSizer:new(?wxVERTICAL),
|
MainSz = wxBoxSizer:new(?wxVERTICAL),
|
||||||
TopBook = wxNotebook:new(Frame, ?wxID_ANY, [{style, ?wxBK_DEFAULT}]),
|
TopBook = wxNotebook:new(Frame, ?wxID_ANY, [{style, ?wxBK_DEFAULT}]),
|
||||||
+1
-1
@@ -1,5 +1,5 @@
|
|||||||
-module(gd_v_netman).
|
-module(gd_v_netman).
|
||||||
-vsn("0.9.0").
|
-vsn("0.10.0").
|
||||||
-author("Craig Everett <zxq9@zxq9.com>").
|
-author("Craig Everett <zxq9@zxq9.com>").
|
||||||
-copyright("QPQ AG <info@qpq.swiss>").
|
-copyright("QPQ AG <info@qpq.swiss>").
|
||||||
-license("GPL-3.0-or-later").
|
-license("GPL-3.0-or-later").
|
||||||
|
|||||||
@@ -13,7 +13,7 @@
|
|||||||
|
|
||||||
|
|
||||||
-module(gd_v_wallman).
|
-module(gd_v_wallman).
|
||||||
-vsn("0.9.0").
|
-vsn("0.10.0").
|
||||||
-author("Craig Everett <zxq9@zxq9.com>").
|
-author("Craig Everett <zxq9@zxq9.com>").
|
||||||
-copyright("QPQ AG <info@qpq.swiss>").
|
-copyright("QPQ AG <info@qpq.swiss>").
|
||||||
-license("GPL-3.0-or-later").
|
-license("GPL-3.0-or-later").
|
||||||
@@ -108,12 +108,12 @@ init({Prefs, Manifest}) ->
|
|||||||
MakeButton =
|
MakeButton =
|
||||||
fun({Name, Label}) ->
|
fun({Name, Label}) ->
|
||||||
B = wxButton:new(Frame, ?wxID_ANY, [{label, Label}]),
|
B = wxButton:new(Frame, ?wxID_ANY, [{label, Label}]),
|
||||||
_ = wxSizer:add(ButtSz, B, zxw:flags(wide)),
|
_ = wxSizer:add(ButtSz, B, zxw:flags({wide, 5})),
|
||||||
#w{name = Name, id = wxButton:getId(B), wx = B}
|
#w{name = Name, id = wxButton:getId(B), wx = B}
|
||||||
end,
|
end,
|
||||||
Buttons = lists:map(MakeButton, ButtonTemplates),
|
Buttons = lists:map(MakeButton, ButtonTemplates),
|
||||||
|
|
||||||
_ = wxSizer:add(MainSz, Picker, zxw:flags(wide)),
|
_ = wxSizer:add(MainSz, Picker, zxw:flags({wide, 5})),
|
||||||
_ = wxSizer:add(MainSz, ButtSz, zxw:flags(base)),
|
_ = wxSizer:add(MainSz, ButtSz, zxw:flags(base)),
|
||||||
|
|
||||||
ok = wxFrame:setSizer(Frame, MainSz),
|
ok = wxFrame:setSizer(Frame, MainSz),
|
||||||
|
|||||||
@@ -4,7 +4,7 @@
|
|||||||
{prefix,"gd"}.
|
{prefix,"gd"}.
|
||||||
{author,"Craig Everett"}.
|
{author,"Craig Everett"}.
|
||||||
{desc,"A desktop client for the Gajumaru network of blockchain networks"}.
|
{desc,"A desktop client for the Gajumaru network of blockchain networks"}.
|
||||||
{package_id,{"otpr","gajudesk",{0,9,0}}}.
|
{package_id,{"otpr","gajudesk",{0,10,0}}}.
|
||||||
{deps,[{"otpr","hakuzaru",{0,9,1}},
|
{deps,[{"otpr","hakuzaru",{0,9,1}},
|
||||||
{"otpr","zxwidgets",{1,1,0}},
|
{"otpr","zxwidgets",{1,1,0}},
|
||||||
{"otpr","eblake2",{1,0,1}},
|
{"otpr","eblake2",{1,0,1}},
|
||||||
|
|||||||
Reference in New Issue
Block a user