summary refs log tree commit diff stats
path: root/worker/worker.go
diff options
context:
space:
mode:
authorDrew DeVault <sir@cmpwn.com>2018-01-09 21:24:50 -0500
committerDrew DeVault <sir@cmpwn.com>2018-01-09 21:31:36 -0500
commitb5d5e0dbedee34bd5d3edf13616f055d4f227d36 (patch)
treed4353b88a830a29c570b0a54adcda2126427fc95 /worker/worker.go
parent6394e386c2a88c3b376cd422a7b7ce5ae7534984 (diff)
downloadaerc-b5d5e0dbedee34bd5d3edf13616f055d4f227d36.tar.gz
Parse account configuration
Diffstat (limited to 'worker/worker.go')
-rw-r--r--worker/worker.go20
1 files changed, 17 insertions, 3 deletions
diff --git a/worker/worker.go b/worker/worker.go
index 1f9f04c..a504790 100644
--- a/worker/worker.go
+++ b/worker/worker.go
@@ -3,6 +3,9 @@ package worker
 import (
 	"git.sr.ht/~sircmpwn/aerc2/worker/imap"
 	"git.sr.ht/~sircmpwn/aerc2/worker/types"
+
+	"fmt"
+	"net/url"
 )
 
 type Worker interface {
@@ -12,7 +15,18 @@ type Worker interface {
 }
 
 // Guesses the appropriate worker type based on the given source string
-func NewWorker(source string) Worker {
-	// TODO: Do this properly
-	return imap.NewIMAPWorker()
+func NewWorker(source string) (Worker, error) {
+	var (
+		u   *url.URL
+		err error
+	)
+	if u, err = url.Parse(source); err != nil {
+		return nil, err
+	}
+	switch u.Scheme {
+	case "imap":
+	case "imaps":
+		return imap.NewIMAPWorker(), nil
+	}
+	return nil, fmt.Errorf("Unknown backend %s", u.Scheme)
 }
r/commit/ranger.py?h=v1.8.1&id=240394a494b0bbb854687a34941bf90a5ccd5b4d'>240394a4 ^
f027adc0 ^
08f08fb9 ^
654af129 ^
08f08fb9 ^
d8084b41 ^

99400080 ^
08f08fb9 ^

654af129 ^

d1a1173d ^
d8084b41 ^
cba63cf3 ^
b4250dbc ^

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40