Skip to content

Commit 0773f99

Browse files
committed
refactor: integrate systray into hub structure and update newHub function
1 parent 3bbf371 commit 0773f99

File tree

2 files changed

+8
-5
lines changed

2 files changed

+8
-5
lines changed

hub.go

+7-4
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ import (
2626
"strconv"
2727
"strings"
2828

29+
"github.com/arduino/arduino-create-agent/systray"
2930
"github.com/arduino/arduino-create-agent/tools"
3031
"github.com/arduino/arduino-create-agent/upload"
3132
log "github.com/sirupsen/logrus"
@@ -53,9 +54,11 @@ type hub struct {
5354
serialPortList *serialPortList
5455

5556
tools *tools.Tools
57+
58+
systray *systray.Systray
5659
}
5760

58-
func newHub(serialhub *serialhub, serialList *serialPortList, tools *tools.Tools) *hub {
61+
func newHub(serialhub *serialhub, serialList *serialPortList, tools *tools.Tools, systray *systray.Systray) *hub {
5962
hub := &hub{
6063
broadcast: make(chan []byte, 1000),
6164
broadcastSys: make(chan []byte, 1000),
@@ -65,6 +68,7 @@ func newHub(serialhub *serialhub, serialList *serialPortList, tools *tools.Tools
6568
serialHub: serialhub,
6669
serialPortList: serialList,
6770
tools: tools,
71+
systray: systray,
6872
}
6973

7074
hub.serialHub.OnRegister = func(port *serport) {
@@ -259,10 +263,9 @@ func (h *hub) checkCmd(m []byte) {
259263
go h.logAction(sl)
260264
} else if strings.HasPrefix(sl, "restart") {
261265
log.Println("Received restart from the daemon. Why? Boh")
262-
// TODO enable them
263-
// Systray.Restart()
266+
h.systray.Restart()
264267
} else if strings.HasPrefix(sl, "exit") {
265-
// Systray.Quit()
268+
h.systray.Quit()
266269
} else if strings.HasPrefix(sl, "memstats") {
267270
h.memoryStats()
268271
} else if strings.HasPrefix(sl, "gc") {

main.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -179,7 +179,7 @@ func loop(stray *systray.Systray) {
179179
serialPorts := newSerialPortList(tools)
180180
serialHub := newSerialHub()
181181

182-
hub := newHub(serialHub, serialPorts, tools)
182+
hub := newHub(serialHub, serialPorts, tools, stray)
183183

184184
// Let's handle the config
185185
configDir := config.GetDefaultConfigDir()

0 commit comments

Comments
 (0)