File tree Expand file tree Collapse file tree 2 files changed +55
-0
lines changed
Expand file tree Collapse file tree 2 files changed +55
-0
lines changed Original file line number Diff line number Diff line change 1+ package commands
2+
3+ import (
4+ "github.com/emersion/go-imap"
5+ )
6+
7+ // An IDLE command.
8+ // Se RFC 2177 section 3.
9+ type Idle struct {}
10+
11+ func (cmd * Idle ) Command () * imap.Command {
12+ return & imap.Command {Name : "IDLE" }
13+ }
14+
15+ func (cmd * Idle ) Parse (fields []interface {}) error {
16+ return nil
17+ }
Original file line number Diff line number Diff line change 1+ package responses
2+
3+ import (
4+ "github.com/emersion/go-imap"
5+ )
6+
7+ // An IDLE response.
8+ type Idle struct {
9+ RepliesCh chan []byte
10+ Stop <- chan struct {}
11+
12+ gotContinuationReq bool
13+ }
14+
15+ func (r * Idle ) Replies () <- chan []byte {
16+ return r .RepliesCh
17+ }
18+
19+ func (r * Idle ) stop () {
20+ r .RepliesCh <- []byte ("DONE\r \n " )
21+ }
22+
23+ func (r * Idle ) Handle (resp imap.Resp ) error {
24+ // Wait for a continuation request
25+ if _ , ok := resp .(* imap.ContinuationReq ); ok && ! r .gotContinuationReq {
26+ r .gotContinuationReq = true
27+
28+ // We got a continuation request, wait for r.Stop to be closed
29+ go func () {
30+ <- r .Stop
31+ r .stop ()
32+ }()
33+
34+ return nil
35+ }
36+
37+ return ErrUnhandled
38+ }
You can’t perform that action at this time.
0 commit comments