86 lines
1.8 KiB
Go
86 lines
1.8 KiB
Go
package main
|
|
|
|
import (
|
|
"crypto/tls"
|
|
"fmt"
|
|
"git.nevets.tech/Steven/ezconf"
|
|
"github.com/getlantern/systray"
|
|
"github.com/sqweek/dialog"
|
|
"os"
|
|
"time"
|
|
)
|
|
|
|
var Config *ezconf.Configuration
|
|
var Connection *tls.Conn
|
|
|
|
func main() {
|
|
Config = ezconf.NewConfiguration("./config.ini")
|
|
|
|
//var err error
|
|
//Connection, err = NewSFSConnection(Config.GetAsString("General.server"), Config.GetAsInt("General.port"))
|
|
//if err != nil {
|
|
// fmt.Printf("Error establishing connection: %v", err)
|
|
// os.Exit(1)
|
|
//}
|
|
|
|
//_, err = Connection.Write(NewSFS(254).ToBytes())
|
|
//if err != nil {
|
|
// fmt.Printf("Error sending data: %v", err)
|
|
// os.Exit(1)
|
|
//}
|
|
//
|
|
//rawData := make([]byte, 1)
|
|
//_, err = Connection.Read(rawData)
|
|
//if err != nil {
|
|
// fmt.Printf("Error reading data: %v", err)
|
|
// os.Exit(1)
|
|
//}
|
|
//sfsData := NewSFSFromBytes(rawData)
|
|
//fmt.Printf("SFS Data: %v", sfsData)
|
|
//
|
|
//err = Connection.Close()
|
|
//if err != nil {
|
|
// fmt.Printf("Error closing connection: %v", err)
|
|
// os.Exit(1)
|
|
//}
|
|
|
|
systray.Run(onReady, onExit)
|
|
}
|
|
|
|
func onReady() {
|
|
systray.SetIcon(getIcon("assets/icon.ico"))
|
|
systray.SetTooltip("SimpleFileSync")
|
|
itemOne := systray.AddMenuItem("Dialog", "Opens Dialog Box")
|
|
systray.AddSeparator()
|
|
sync := systray.AddMenuItem("Sync", "Trigger Sync Now")
|
|
systray.AddSeparator()
|
|
quit := systray.AddMenuItem("Quit", "Quit")
|
|
|
|
go func() {
|
|
for {
|
|
select {
|
|
case <-itemOne.ClickedCh:
|
|
dialog.Message("This is a popup from Simple File Sync!").Title("Simple File Sync").Info()
|
|
case <-sync.ClickedCh:
|
|
sync.SetTitle("Syncing...")
|
|
time.Sleep(1000)
|
|
sync.SetTitle("Last sync at " + time.Now().Format(time.TimeOnly))
|
|
case <-quit.ClickedCh:
|
|
systray.Quit()
|
|
}
|
|
}
|
|
}()
|
|
}
|
|
|
|
func onExit() {
|
|
Config.Save()
|
|
}
|
|
|
|
func getIcon(location string) []byte {
|
|
bytes, err := os.ReadFile(location)
|
|
if err != nil {
|
|
fmt.Print(err)
|
|
}
|
|
return bytes
|
|
}
|