refix the add account option

Signed-off-by: Jeff Carr <jcarr@wit.com>
This commit is contained in:
Jeff Carr 2019-05-25 01:38:06 -07:00
parent 18ee965fee
commit 3f5ff714ca
3 changed files with 27 additions and 38 deletions

View File

@ -212,6 +212,13 @@ func loadConfigFromFilename(filename string) pb.Config {
b, err := ioutil.ReadFile(filename)
if err != nil {
log.Println("ioutil.ReadFile() ERROR =", err)
// This probably means this is the first time the user is opening this
sets.Errors += 1
sets.Crash = "err"
sets.Counter = 1
sets.Width = 500
sets.Height = 500
return sets
}
log.Println("ioutil.ReadFile() b =", b)

22
main.go
View File

@ -175,13 +175,23 @@ func mainMouseClick(b *gui.ButtonMap) {
log.Println("FINISHED FULL STACK DUMP")
} else if (b.Action == "ADD") {
log.Println("\tSHOULD ADD ACCOUNT HERE")
/*
if (gui.Data.AccNick != "") {
config.Set("accounts." + gui.Data.AccNick + ".username", gui.Data.AccUser)
config.Set("accounts." + gui.Data.AccNick + ".password", gui.Data.AccPass)
config.Set("accounts." + gui.Data.AccNick + ".hostname", "v000185.testing.com.customers.wprod.wit.com")
if (gui.Data.CurrentTab != nil) {
if (gui.Data.CurrentTab.EntryNick != nil) {
nick := gui.Data.CurrentTab.EntryNick.Text()
username := gui.Data.CurrentTab.EntryUser.Text()
password := gui.Data.CurrentTab.EntryPass.Text()
log.Println("\tEntryNick =", nick)
log.Println("\tEntryName =", username)
log.Println("\tEntryPass =", password)
acc := new(pb.Config_Account)
acc.Nick = nick
acc.Username = username
acc.Password = password
config.Accounts = append(config.Accounts, acc)
}
}
*/
} else if (b.Action == "LOGIN") {
log.Println("\tTRIGGER LOGIN ACCOUNT")
gui.Data.State = "SEND LOGIN"

View File

@ -19,15 +19,10 @@ import pb "git.wit.com/wit/witProtobuf"
import "github.com/davecgh/go-spew/spew"
// will load the default config from within the go binary
// TEST UNMARSHAL JSON TO PROTOBUF
// This is known to crash unless done exactly like this
// with strings.NewReader & 'sets'
func loadDefaultConfig(a string) pb.Config {
log.Println("TRY TO LOAD DEFAULT CONFIG")
log.Println("a =", a)
log.Println("NEED TO UNMARSHAL THIS HERE")
log.Println("NEED TO UNMARSHAL THIS HERE")
log.Println("NEED TO UNMARSHAL THIS HERE")
var newpb *pb.Config
// var newpb *pb.Config
sets := pb.Config{}
b, err := ioutil.ReadFile("../resources/protobuf-config.json")
@ -42,31 +37,8 @@ func loadDefaultConfig(a string) pb.Config {
}
spew.Dump(sets)
return sets
//
// err := jsonpb.UnmarshalString(defaultConfig, newpb)
log.Println("ATTEMTED TO UNMARSHAL err =", err)
spew.Dump(newpb)
if (err == nil) {
log.Println("SETTING config to the default config", err)
// TODO: save the protobuf somewhere as the user could loose the tokens
log.Println("THIS IS PROBABLY REALLY BAD", err)
log.Println("THIS IS PROBABLY REALLY BAD", err)
log.Println("THIS IS PROBABLY REALLY BAD", err)
// config = newpb
}
return sets
}
func unmarshalConfig(a string) *pb.Event {
var newpb *pb.Event
log.Println("ATTEMTED TO UNMARSHAL string =", a)
err := jsonpb.UnmarshalString(a, newpb)
log.Println("ATTEMTED TO UNMARSHAL err =", err)
spew.Dump(newpb)
return newpb
}
func main() {
blah := "{}"
loadDefaultConfig(blah)
loadDefaultConfig("")
}