diff options
Diffstat (limited to 'ui/qt')
-rw-r--r-- | ui/qt/filter.go | 1 | ||||
-rw-r--r-- | ui/qt/qwhisper/message.go | 23 | ||||
-rw-r--r-- | ui/qt/qwhisper/watch.go | 13 | ||||
-rw-r--r-- | ui/qt/qwhisper/whisper.go | 113 | ||||
-rw-r--r-- | ui/qt/qwhisper/whisper_test.go | 15 | ||||
-rw-r--r-- | ui/qt/webengine/all.cpp | 1 | ||||
-rw-r--r-- | ui/qt/webengine/cpp/webengine.cpp | 6 | ||||
-rw-r--r-- | ui/qt/webengine/cpp/webengine.h | 14 | ||||
-rw-r--r-- | ui/qt/webengine/webengine.go | 18 |
9 files changed, 0 insertions, 204 deletions
diff --git a/ui/qt/filter.go b/ui/qt/filter.go deleted file mode 100644 index 090260e4e..000000000 --- a/ui/qt/filter.go +++ /dev/null @@ -1 +0,0 @@ -package qt diff --git a/ui/qt/qwhisper/message.go b/ui/qt/qwhisper/message.go deleted file mode 100644 index f8bed8a2d..000000000 --- a/ui/qt/qwhisper/message.go +++ /dev/null @@ -1,23 +0,0 @@ -package qwhisper - -import ( - "github.com/ethereum/go-ethereum/crypto" - "github.com/ethereum/go-ethereum/common" - "github.com/ethereum/go-ethereum/whisper" -) - -type Message struct { - ref *whisper.Message - Flags int32 `json:"flags"` - Payload string `json:"payload"` - From string `json:"from"` -} - -func ToQMessage(msg *whisper.Message) *Message { - return &Message{ - ref: msg, - Flags: int32(msg.Flags), - Payload: "0x" + common.Bytes2Hex(msg.Payload), - From: "0x" + common.Bytes2Hex(crypto.FromECDSAPub(msg.Recover())), - } -} diff --git a/ui/qt/qwhisper/watch.go b/ui/qt/qwhisper/watch.go deleted file mode 100644 index 0ccedc719..000000000 --- a/ui/qt/qwhisper/watch.go +++ /dev/null @@ -1,13 +0,0 @@ -package qwhisper - -import ( - "fmt" - "unsafe" -) - -type Watch struct { -} - -func (self *Watch) Arrived(v unsafe.Pointer) { - fmt.Println(v) -} diff --git a/ui/qt/qwhisper/whisper.go b/ui/qt/qwhisper/whisper.go deleted file mode 100644 index 4ab6d2e5a..000000000 --- a/ui/qt/qwhisper/whisper.go +++ /dev/null @@ -1,113 +0,0 @@ -// QWhisper package. This package is temporarily on hold until QML DApp dev will reemerge. -package qwhisper - -import ( - "time" - - "github.com/ethereum/go-ethereum/common" - "github.com/ethereum/go-ethereum/crypto" - "github.com/ethereum/go-ethereum/logger" - "github.com/ethereum/go-ethereum/whisper" - "github.com/obscuren/qml" -) - -var qlogger = logger.NewLogger("QSHH") - -type Whisper struct { - *whisper.Whisper - view qml.Object - - watches map[int]*Watch -} - -func New(w *whisper.Whisper) *Whisper { - return &Whisper{w, nil, make(map[int]*Watch)} -} - -func (self *Whisper) SetView(view qml.Object) { - self.view = view -} - -func (self *Whisper) Post(payload []string, to, from string, topics []string, priority, ttl uint32) { - var data []byte - for _, d := range payload { - data = append(data, common.FromHex(d)...) - } - - pk := crypto.ToECDSAPub(common.FromHex(from)) - if key := self.Whisper.GetIdentity(pk); key != nil { - msg := whisper.NewMessage(data) - envelope, err := msg.Wrap(time.Duration(priority*100000), whisper.Options{ - TTL: time.Duration(ttl) * time.Second, - To: crypto.ToECDSAPub(common.FromHex(to)), - From: key, - Topics: whisper.NewTopicsFromStrings(topics...), - }) - - if err != nil { - qlogger.Infoln(err) - // handle error - return - } - - if err := self.Whisper.Send(envelope); err != nil { - qlogger.Infoln(err) - // handle error - return - } - } else { - qlogger.Infoln("unmatched pub / priv for seal") - } - -} - -func (self *Whisper) NewIdentity() string { - key := self.Whisper.NewIdentity() - - return common.ToHex(crypto.FromECDSAPub(&key.PublicKey)) -} - -func (self *Whisper) HasIdentity(key string) bool { - return self.Whisper.HasIdentity(crypto.ToECDSAPub(common.FromHex(key))) -} - -func (self *Whisper) Watch(opts map[string]interface{}, view *qml.Common) int { - filter := filterFromMap(opts) - var i int - filter.Fn = func(msg *whisper.Message) { - if view != nil { - view.Call("onShhMessage", ToQMessage(msg), i) - } - } - - i = self.Whisper.Watch(filter) - self.watches[i] = &Watch{} - - return i -} - -func (self *Whisper) Messages(id int) (messages *common.List) { - msgs := self.Whisper.Messages(id) - messages = common.EmptyList() - for _, message := range msgs { - messages.Append(ToQMessage(message)) - } - - return -} - -func filterFromMap(opts map[string]interface{}) (f whisper.Filter) { - if to, ok := opts["to"].(string); ok { - f.To = crypto.ToECDSAPub(common.FromHex(to)) - } - if from, ok := opts["from"].(string); ok { - f.From = crypto.ToECDSAPub(common.FromHex(from)) - } - if topicList, ok := opts["topics"].(*qml.List); ok { - var topics []string - topicList.Convert(&topics) - f.Topics = whisper.NewFilterTopicsFromStringsFlat(topics...) - } - - return -} diff --git a/ui/qt/qwhisper/whisper_test.go b/ui/qt/qwhisper/whisper_test.go deleted file mode 100644 index efa4e6238..000000000 --- a/ui/qt/qwhisper/whisper_test.go +++ /dev/null @@ -1,15 +0,0 @@ -package qwhisper - -import ( - "testing" - - "github.com/ethereum/go-ethereum/whisper" -) - -func TestHasIdentity(t *testing.T) { - qw := New(whisper.New()) - id := qw.NewIdentity() - if !qw.HasIdentity(id) { - t.Error("expected to have identity") - } -} diff --git a/ui/qt/webengine/all.cpp b/ui/qt/webengine/all.cpp deleted file mode 100644 index 3b7c2f7b8..000000000 --- a/ui/qt/webengine/all.cpp +++ /dev/null @@ -1 +0,0 @@ -#include "cpp/webengine.cpp" diff --git a/ui/qt/webengine/cpp/webengine.cpp b/ui/qt/webengine/cpp/webengine.cpp deleted file mode 100644 index 118b451ef..000000000 --- a/ui/qt/webengine/cpp/webengine.cpp +++ /dev/null @@ -1,6 +0,0 @@ -#include <QtWebEngine> -#include "webengine.h" - -void webengineInitialize() { - QtWebEngine::initialize(); -} diff --git a/ui/qt/webengine/cpp/webengine.h b/ui/qt/webengine/cpp/webengine.h deleted file mode 100644 index 9c3b13bfa..000000000 --- a/ui/qt/webengine/cpp/webengine.h +++ /dev/null @@ -1,14 +0,0 @@ -#ifndef WEBENGINE_H -#define WEBENGINE_H - -#ifdef __cplusplus -extern "C" { -#endif - -void webengineInitialize(); - -#ifdef __cplusplus -} // extern "C" -#endif - -#endif // WEBENGINE_H diff --git a/ui/qt/webengine/webengine.go b/ui/qt/webengine/webengine.go deleted file mode 100644 index 600dbb6cb..000000000 --- a/ui/qt/webengine/webengine.go +++ /dev/null @@ -1,18 +0,0 @@ -package webengine - -// #cgo CPPFLAGS: -I./ -// #cgo CXXFLAGS: -std=c++0x -pedantic-errors -Wall -fno-strict-aliasing -// #cgo LDFLAGS: -lstdc++ -// #cgo pkg-config: Qt5WebEngine -// -// #include "cpp/webengine.h" -import "C" - -import "github.com/obscuren/qml" - -// Initializes the WebEngine extension. -func Initialize() { - qml.RunMain(func() { - C.webengineInitialize() - }) -} |