aboutsummaryrefslogtreecommitdiffstats
path: root/ethereal/gui.go
diff options
context:
space:
mode:
authorobscuren <geffobscura@gmail.com>2014-08-20 16:00:02 +0800
committerobscuren <geffobscura@gmail.com>2014-08-20 16:00:02 +0800
commitecc2c609d4dfe210c66c9316cf5b060f9b3a4ff0 (patch)
tree7646add8e4c6ce26accdf00a271383fd06511156 /ethereal/gui.go
parenta8409b0a8bfa7f8434ede495094fd8d892c28c91 (diff)
downloaddexon-ecc2c609d4dfe210c66c9316cf5b060f9b3a4ff0.tar.gz
dexon-ecc2c609d4dfe210c66c9316cf5b060f9b3a4ff0.tar.zst
dexon-ecc2c609d4dfe210c66c9316cf5b060f9b3a4ff0.zip
Implemented QML message filtering
Diffstat (limited to 'ethereal/gui.go')
-rw-r--r--ethereal/gui.go48
1 files changed, 46 insertions, 2 deletions
diff --git a/ethereal/gui.go b/ethereal/gui.go
index 1765c3fb2..3f989fe51 100644
--- a/ethereal/gui.go
+++ b/ethereal/gui.go
@@ -2,6 +2,7 @@ package main
import (
"bytes"
+ "encoding/json"
"fmt"
"math/big"
"os"
@@ -24,6 +25,11 @@ import (
var logger = ethlog.NewLogger("GUI")
+type plugin struct {
+ Name string `json:"name"`
+ Path string `json:"path"`
+}
+
type Gui struct {
// The main application window
win *qml.Window
@@ -48,6 +54,8 @@ type Gui struct {
clientIdentity *ethwire.SimpleClientIdentity
config *ethutil.ConfigManager
+ plugins map[string]plugin
+
miner *ethminer.Miner
}
@@ -59,8 +67,16 @@ func NewWindow(ethereum *eth.Ethereum, config *ethutil.ConfigManager, clientIden
}
pipe := ethpipe.NewJSPipe(ethereum)
+ gui := &Gui{eth: ethereum, txDb: db, pipe: pipe, logLevel: ethlog.LogLevel(logLevel), Session: session, open: false, clientIdentity: clientIdentity, config: config, plugins: make(map[string]plugin)}
+ data, err := ethutil.ReadAllFile(ethutil.Config.ExecPath + "/plugins.json")
+ if err != nil {
+ fmt.Println(err)
+ }
+ fmt.Println(string(data))
- return &Gui{eth: ethereum, txDb: db, pipe: pipe, logLevel: ethlog.LogLevel(logLevel), Session: session, open: false, clientIdentity: clientIdentity, config: config}
+ json.Unmarshal([]byte(data), &gui.plugins)
+
+ return gui
}
func (gui *Gui) Start(assetPath string) {
@@ -193,6 +209,7 @@ func (self *Gui) DumpState(hash, path string) {
// The done handler will be called by QML when all views have been loaded
func (gui *Gui) Done() {
gui.qmlDone = true
+
}
func (gui *Gui) ImportKey(filePath string) {
@@ -375,6 +392,10 @@ func (gui *Gui) update() {
gui.readPreviousTransactions()
}()
+ for _, plugin := range gui.plugins {
+ gui.win.Root().Call("addPlugin", plugin.Path, "")
+ }
+
var (
blockChan = make(chan ethreact.Event, 100)
txChan = make(chan ethreact.Event, 100)
@@ -504,7 +525,16 @@ func (gui *Gui) address() []byte {
}
func (gui *Gui) Transact(recipient, value, gas, gasPrice, d string) (*ethpipe.JSReceipt, error) {
- data := ethutil.Bytes2Hex(utils.FormatTransactionData(d))
+ var data string
+ if len(recipient) == 0 {
+ code, err := ethutil.Compile(d, false)
+ if err != nil {
+ return nil, err
+ }
+ data = ethutil.Bytes2Hex(code)
+ } else {
+ data = ethutil.Bytes2Hex(utils.FormatTransactionData(d))
+ }
return gui.pipe.Transact(gui.privateKey(), recipient, value, gas, gasPrice, data)
}
@@ -528,6 +558,20 @@ func (gui *Gui) GetLogLevel() ethlog.LogLevel {
return gui.logLevel
}
+func (self *Gui) AddPlugin(pluginPath string) {
+ self.plugins[pluginPath] = plugin{Name: "SomeName", Path: pluginPath}
+
+ json, _ := json.MarshalIndent(self.plugins, "", " ")
+ ethutil.WriteFile(ethutil.Config.ExecPath+"/plugins.json", json)
+}
+
+func (self *Gui) RemovePlugin(pluginPath string) {
+ delete(self.plugins, pluginPath)
+
+ json, _ := json.MarshalIndent(self.plugins, "", " ")
+ ethutil.WriteFile(ethutil.Config.ExecPath+"/plugins.json", json)
+}
+
// this extra function needed to give int typecast value to gui widget
// that sets initial loglevel to default
func (gui *Gui) GetLogLevelInt() int {