File tree Expand file tree Collapse file tree 2 files changed +56
-0
lines changed
Expand file tree Collapse file tree 2 files changed +56
-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 ENABLE command, defined in RFC 5161 section 3.1.
8+ type Enable struct {
9+ Caps []string
10+ }
11+
12+ func (cmd * Enable ) Command () * imap.Command {
13+ return & imap.Command {
14+ Name : "ENABLE" ,
15+ Arguments : imap .FormatStringList (cmd .Caps ),
16+ }
17+ }
18+
19+ func (cmd * Enable ) Parse (fields []interface {}) error {
20+ var err error
21+ cmd .Caps , err = imap .ParseStringList (fields )
22+ return err
23+ }
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 ENABLED response, defined in RFC 5161 section 3.2.
8+ type Enabled struct {
9+ Caps []string
10+ }
11+
12+ func (r * Enabled ) Handle (resp imap.Resp ) error {
13+ name , fields , ok := imap .ParseNamedResp (resp )
14+ if ! ok || name != "ENABLED" {
15+ return ErrUnhandled
16+ }
17+
18+ if caps , err := imap .ParseStringList (fields ); err != nil {
19+ return err
20+ } else {
21+ r .Caps = append (r .Caps , caps ... )
22+ }
23+
24+ return nil
25+ }
26+
27+ func (r * Enabled ) WriteTo (w * imap.Writer ) error {
28+ fields := []interface {}{imap .RawString ("ENABLED" )}
29+ for _ , cap := range r .Caps {
30+ fields = append (fields , imap .RawString (cap ))
31+ }
32+ return imap .NewUntaggedResp (fields ).WriteTo (w )
33+ }
You can’t perform that action at this time.
0 commit comments