Commit 31ffca6d authored by zelig's avatar zelig

remove jsre from mist

parent da440978
This diff is collapsed.
...@@ -25,9 +25,7 @@ import "C" ...@@ -25,9 +25,7 @@ import "C"
import ( import (
"encoding/json" "encoding/json"
"fmt" "fmt"
"io/ioutil"
"math/big" "math/big"
"os"
"path" "path"
"runtime" "runtime"
"sort" "sort"
...@@ -99,7 +97,7 @@ func NewWindow(ethereum *eth.Ethereum) *Gui { ...@@ -99,7 +97,7 @@ func NewWindow(ethereum *eth.Ethereum) *Gui {
return gui return gui
} }
func (gui *Gui) Start(assetPath string) { func (gui *Gui) Start(assetPath, libPath string) {
defer gui.txDb.Close() defer gui.txDb.Close()
guilogger.Infoln("Starting GUI") guilogger.Infoln("Starting GUI")
...@@ -117,7 +115,7 @@ func (gui *Gui) Start(assetPath string) { ...@@ -117,7 +115,7 @@ func (gui *Gui) Start(assetPath string) {
// Create a new QML engine // Create a new QML engine
gui.engine = qml.NewEngine() gui.engine = qml.NewEngine()
context := gui.engine.Context() context := gui.engine.Context()
gui.uiLib = NewUiLib(gui.engine, gui.eth, assetPath) gui.uiLib = NewUiLib(gui.engine, gui.eth, assetPath, libPath)
gui.whisper = qwhisper.New(gui.eth.Whisper()) gui.whisper = qwhisper.New(gui.eth.Whisper())
// Expose the eth library and the ui library to QML // Expose the eth library and the ui library to QML
...@@ -292,25 +290,6 @@ func (self *Gui) getObjectByName(objectName string) qml.Object { ...@@ -292,25 +290,6 @@ func (self *Gui) getObjectByName(objectName string) qml.Object {
return self.win.Root().ObjectByName(objectName) return self.win.Root().ObjectByName(objectName)
} }
func loadJavascriptAssets(gui *Gui) (jsfiles string) {
for _, fn := range []string{"ext/q.js", "ext/eth.js/main.js", "ext/eth.js/qt.js", "ext/setup.js"} {
f, err := os.Open(gui.uiLib.AssetPath(fn))
if err != nil {
fmt.Println(err)
continue
}
content, err := ioutil.ReadAll(f)
if err != nil {
fmt.Println(err)
continue
}
jsfiles += string(content)
}
return
}
func (gui *Gui) SendCommand(cmd ServEv) { func (gui *Gui) SendCommand(cmd ServEv) {
gui.serviceEvents <- cmd gui.serviceEvents <- cmd
} }
......
...@@ -65,6 +65,7 @@ func init() { ...@@ -65,6 +65,7 @@ func init() {
utils.NodeKeyFileFlag, utils.NodeKeyFileFlag,
utils.RPCListenAddrFlag, utils.RPCListenAddrFlag,
utils.RPCPortFlag, utils.RPCPortFlag,
utils.JSpathFlag,
} }
} }
...@@ -111,7 +112,7 @@ func run(ctx *cli.Context) { ...@@ -111,7 +112,7 @@ func run(ctx *cli.Context) {
gui := NewWindow(ethereum) gui := NewWindow(ethereum)
utils.RegisterInterrupt(func(os.Signal) { gui.Stop() }) utils.RegisterInterrupt(func(os.Signal) { gui.Stop() })
// gui blocks the main thread // gui blocks the main thread
gui.Start(ctx.GlobalString(assetPathFlag.Name)) gui.Start(ctx.GlobalString(assetPathFlag.Name), ctx.GlobalString(utils.JSpathFlag.Name))
return nil return nil
}) })
} }
...@@ -21,7 +21,6 @@ ...@@ -21,7 +21,6 @@
package main package main
import ( import (
"fmt"
"io/ioutil" "io/ioutil"
"path" "path"
...@@ -29,7 +28,6 @@ import ( ...@@ -29,7 +28,6 @@ import (
"github.com/ethereum/go-ethereum/eth" "github.com/ethereum/go-ethereum/eth"
"github.com/ethereum/go-ethereum/ethutil" "github.com/ethereum/go-ethereum/ethutil"
"github.com/ethereum/go-ethereum/event/filter" "github.com/ethereum/go-ethereum/event/filter"
"github.com/ethereum/go-ethereum/javascript"
"github.com/ethereum/go-ethereum/xeth" "github.com/ethereum/go-ethereum/xeth"
"github.com/obscuren/qml" "github.com/obscuren/qml"
) )
...@@ -49,15 +47,19 @@ type UiLib struct { ...@@ -49,15 +47,19 @@ type UiLib struct {
// The main application window // The main application window
win *qml.Window win *qml.Window
jsEngine *javascript.JSRE
filterCallbacks map[int][]int filterCallbacks map[int][]int
filterManager *filter.FilterManager filterManager *filter.FilterManager
} }
func NewUiLib(engine *qml.Engine, eth *eth.Ethereum, assetPath string) *UiLib { func NewUiLib(engine *qml.Engine, eth *eth.Ethereum, assetPath, libPath string) *UiLib {
x := xeth.New(eth, nil) x := xeth.New(eth, nil)
lib := &UiLib{XEth: x, engine: engine, eth: eth, assetPath: assetPath, jsEngine: javascript.NewJSRE(x), filterCallbacks: make(map[int][]int)} //, filters: make(map[int]*xeth.JSFilter)} lib := &UiLib{
XEth: x,
engine: engine,
eth: eth,
assetPath: assetPath,
filterCallbacks: make(map[int][]int),
}
lib.filterManager = filter.NewFilterManager(eth.EventMux()) lib.filterManager = filter.NewFilterManager(eth.EventMux())
go lib.filterManager.Start() go lib.filterManager.Start()
...@@ -76,19 +78,6 @@ func (self *UiLib) ImportTx(rlpTx string) { ...@@ -76,19 +78,6 @@ func (self *UiLib) ImportTx(rlpTx string) {
} }
} }
func (self *UiLib) EvalJavascriptFile(path string) {
self.jsEngine.LoadExtFile(path[7:])
}
func (self *UiLib) EvalJavascriptString(str string) string {
value, err := self.jsEngine.Run(str)
if err != nil {
return err.Error()
}
return fmt.Sprintf("%v", value)
}
func (ui *UiLib) Muted(content string) { func (ui *UiLib) Muted(content string) {
component, err := ui.engine.LoadFile(ui.AssetPath("qml/muted.qml")) component, err := ui.engine.LoadFile(ui.AssetPath("qml/muted.qml"))
if err != nil { if err != nil {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment