2018-01-10 00:30:46 +01:00
|
|
|
package main
|
|
|
|
|
|
|
|
import (
|
|
|
|
"fmt"
|
2018-01-10 14:35:26 +01:00
|
|
|
"time"
|
2018-01-10 01:18:19 +01:00
|
|
|
|
|
|
|
"git.sr.ht/~sircmpwn/aerc2/config"
|
2018-01-10 02:39:00 +01:00
|
|
|
"git.sr.ht/~sircmpwn/aerc2/worker"
|
|
|
|
"git.sr.ht/~sircmpwn/aerc2/worker/types"
|
2018-01-10 00:30:46 +01:00
|
|
|
)
|
|
|
|
|
|
|
|
func main() {
|
2018-01-10 01:18:19 +01:00
|
|
|
var (
|
2018-01-10 03:24:50 +01:00
|
|
|
conf *config.AercConfig
|
|
|
|
err error
|
2018-01-10 01:18:19 +01:00
|
|
|
)
|
2018-01-10 03:24:50 +01:00
|
|
|
if conf, err = config.LoadConfig(nil); err != nil {
|
2018-01-10 01:18:19 +01:00
|
|
|
panic(err)
|
|
|
|
}
|
2018-01-10 03:24:50 +01:00
|
|
|
workers := make([]worker.Worker, 0)
|
|
|
|
for _, account := range conf.Accounts {
|
|
|
|
var work worker.Worker
|
|
|
|
if work, err = worker.NewWorker(account.Source); err != nil {
|
|
|
|
panic(err)
|
|
|
|
}
|
|
|
|
fmt.Printf("Initializing worker %s\n", account.Name)
|
|
|
|
go work.Run()
|
|
|
|
work.PostAction(types.Configure{Config: account})
|
|
|
|
workers = append(workers, work)
|
|
|
|
}
|
2018-01-10 02:39:00 +01:00
|
|
|
for {
|
2018-01-10 14:35:26 +01:00
|
|
|
activity := false
|
2018-01-10 03:24:50 +01:00
|
|
|
for _, worker := range workers {
|
|
|
|
if msg := worker.GetMessage(); msg != nil {
|
2018-01-10 14:35:26 +01:00
|
|
|
activity = true
|
2018-01-10 03:24:50 +01:00
|
|
|
fmt.Printf("<- %T\n", msg)
|
|
|
|
}
|
2018-01-10 02:39:00 +01:00
|
|
|
}
|
2018-01-10 14:35:26 +01:00
|
|
|
if !activity {
|
|
|
|
time.Sleep(100 * time.Millisecond)
|
|
|
|
}
|
2018-01-10 02:39:00 +01:00
|
|
|
}
|
2018-01-10 00:30:46 +01:00
|
|
|
}
|