0
0
Fork 0
mirror of https://github.com/schollz/croc.git synced 2025-10-11 13:21:00 +02:00

sending is working for wincroc

This commit is contained in:
Zack Scholl 2018-10-17 07:01:44 -07:00
parent 6a899492f5
commit 157ab169aa

View file

@ -5,6 +5,7 @@ package main
import ( import (
"fmt" "fmt"
"os" "os"
"path/filepath"
"time" "time"
"github.com/schollz/croc/src/cli" "github.com/schollz/croc/src/cli"
@ -30,7 +31,7 @@ func main() {
app := widgets.NewQApplication(len(os.Args), os.Args) app := widgets.NewQApplication(len(os.Args), os.Args)
window := widgets.NewQMainWindow(nil, 0) window := widgets.NewQMainWindow(nil, 0)
window.SetFixedSize2(250, 200) window.SetFixedSize2(300, 200)
window.SetWindowTitle("croc - secure data transfer") window.SetWindowTitle("croc - secure data transfer")
widget := widgets.NewQWidget(nil, 0) widget := widgets.NewQWidget(nil, 0)
@ -71,24 +72,33 @@ func main() {
cr := croc.Init(false) cr := croc.Init(false)
done := make(chan bool) done := make(chan bool)
go func() { go func() {
cr.Send(fn, utils.GetRandomName()) codePhrase := utils.GetRandomName()
_, fname := filepath.Split(fn)
labels[0].SetText(fmt.Sprintf("Sending '%'", fname))
labels[1].SetText(fmt.Sprintf("Code phrase: %s", codePhrase))
cr.Send(fn, codePhrase)
done <- true done <- true
}() }()
for { go func() {
select { for {
case _ <- done: fmt.Println(cr.FileInfo, cr.Bar)
break if cr.FileInfo.SentName != "" {
labels[0].UpdateTextFromGoroutine(fmt.Sprintf("%s", cr.FileInfo.SentName))
}
if cr.Bar != nil {
barState := cr.Bar.State()
labels[1].UpdateTextFromGoroutine(fmt.Sprintf("%2.1f", barState.CurrentPercent))
}
time.Sleep(100 * time.Millisecond)
select {
case _ = <-done:
break
default:
continue
}
} }
if cr.FileInfo != nil { }()
labels[0].SetText(fmt.Sprintf("%s",cr.FileInfo.SentName))
}
if cr.Bar != nil {
barState := cr.Bar.State()
labels[1].SetText(fmt.Sprintf("%2.1f",barState.CurrentPercent)
}
time.Sleep(100 * time.Millisecond)
}
// for i, label := range labels { // for i, label := range labels {
// go func(i int, label *CustomLabel) { // go func(i int, label *CustomLabel) {
@ -137,22 +147,22 @@ func main() {
cr := croc.Init(false) cr := croc.Init(false)
done := make(chan bool) done := make(chan bool)
go func() { go func() {
cr.Receive(codephrase) cr.Receive(codePhrase)
done <- true done <- true
}() }()
for { for {
select { select {
case _ <- done: case _ = <-done:
break break
} }
labels[0].SetText(cr.StateString) labels[0].SetText(cr.StateString)
if cr.FileInfo != nil { if cr.FileInfo.SentName != "" {
labels[0].SetText(fmt.Sprintf("%s",cr.FileInfo.SentName)) labels[0].SetText(fmt.Sprintf("%s", cr.FileInfo.SentName))
} }
if cr.Bar != nil { if cr.Bar != nil {
barState := cr.Bar.State() barState := cr.Bar.State()
labels[1].SetText(fmt.Sprintf("%2.1f",barState.CurrentPercent) labels[1].SetText(fmt.Sprintf("%2.1f", barState.CurrentPercent))
} }
time.Sleep(100 * time.Millisecond) time.Sleep(100 * time.Millisecond)
} }