blob: fc4e27bda20915387c8247321136a2d5617646e2 (
plain)
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
|
package responses
import (
"github.com/emersion/go-imap"
)
// An ENABLED response, defined in RFC 5161 section 3.2.
type Enabled struct {
Caps []string
}
func (r *Enabled) Handle(resp imap.Resp) error {
name, fields, ok := imap.ParseNamedResp(resp)
if !ok || name != "ENABLED" {
return ErrUnhandled
}
if caps, err := imap.ParseStringList(fields); err != nil {
return err
} else {
r.Caps = append(r.Caps, caps...)
}
return nil
}
func (r *Enabled) WriteTo(w *imap.Writer) error {
fields := []interface{}{imap.RawString("ENABLED")}
for _, cap := range r.Caps {
fields = append(fields, imap.RawString(cap))
}
return imap.NewUntaggedResp(fields).WriteTo(w)
}
|