-
Notifications
You must be signed in to change notification settings - Fork 8
/
Copy pathdcoinnotmobile.go
70 lines (63 loc) · 1.92 KB
/
dcoinnotmobile.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
// +build !ios,!android
package main
import (
"github.com/democratic-coin/dcoin-go/packages/dcoin"
"github.com/go-thrust/thrust"
"github.com/go-thrust/lib/commands"
"github.com/democratic-coin/dcoin-go/packages/static"
"fmt"
"net/http"
"github.com/go-thrust/lib/bindings/window"
"os"
"github.com/democratic-coin/dcoin-go/packages/utils"
"runtime"
"github.com/democratic-coin/dcoin-go/packages/system"
)
func main_loader(w http.ResponseWriter, r *http.Request) {
data, _ := static.Asset("static/img/main_loader.gif")
fmt.Fprint(w, string(data))
}
func main_loader_html(w http.ResponseWriter, r *http.Request) {
html := `<html><title>Dcoin</title><body style="margin:0;padding:0;overflow:hidden;"><img src="static/img/main_loader.gif"/></body></html>`
fmt.Fprint(w, html)
}
func main() {
runtime.LockOSThread()
var width uint = 800
var height uint = 600
var thrustWindow *window.Window
if runtime.GOOS == "darwin" {
height = 578
}
if utils.Desktop() && (winVer() >= 6 || winVer() == 0) {
thrust.Start()
thrustWindow = thrust.NewWindow(thrust.WindowOptions{
RootUrl: "http://localhost:8989/loader.html",
HasFrame: winVer() != 6,
Title : "Dcoin",
Size: commands.SizeHW{Width:width, Height:height},
})
thrust.NewEventHandler("*", func(cr commands.CommandResponse) {
//fmt.Println(fmt.Sprintf("======Event(%s %d) - Signaled by Command (%s)", cr.TargetID, cr.Type))
if cr.TargetID > 1 && cr.Type == "closed" {
if utils.DB != nil && utils.DB.DB != nil {
utils.DB.ExecSql(`INSERT INTO stop_daemons(stop_time) VALUES (?)`, utils.Time())
} else {
system.FinishThrust(0)
os.Exit(0)
}
}
})
thrustWindow.Show()
thrustWindow.Focus()
go func() {
http.HandleFunc("/static/img/main_loader.gif", main_loader)
http.HandleFunc("/loader.html", main_loader_html)
http.ListenAndServe(":8989", nil)
}()
}
tray()
go dcoin.Start("", thrustWindow)
enterLoop()
system.Finish(0)
}