imapc

package module
v0.0.0-...-67039d6 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 25, 2016 License: ISC Imports: 18 Imported by: 0

Documentation

Index

Constants

View Source
const IMAPDateFormat = "02-Jan-2006"

Variables

This section is empty.

Functions

func AStringEncode

func AStringEncode(s string) []byte

func AStringEncodeByteString

func AStringEncodeByteString(bs []byte) []byte

func ByteStringAll

func ByteStringAll(str []byte, fn func(byte) bool) bool

func IsAstringChar

func IsAstringChar(b byte) bool

func IsAtomChar

func IsAtomChar(b byte) bool

func IsAtomSpecialChar

func IsAtomSpecialChar(b byte) bool

func IsChar

func IsChar(b byte) bool

func IsCtlChar

func IsCtlChar(b byte) bool

func IsDigitChar

func IsDigitChar(b byte) bool

func IsListWildcardChar

func IsListWildcardChar(b byte) bool

func IsQuotedSpecialChar

func IsQuotedSpecialChar(b byte) bool

func IsRespSpecialChar

func IsRespSpecialChar(b byte) bool

func MailboxNameEncode

func MailboxNameEncode(s string) []byte

func ModifiedBase64Decode

func ModifiedBase64Decode(data []byte) ([]byte, error)

func ModifiedBase64Encode

func ModifiedBase64Encode(data []byte) []byte

func ModifiedUTF7Decode

func ModifiedUTF7Decode(data []byte) ([]byte, error)

func ModifiedUTF7Encode

func ModifiedUTF7Encode(data []byte) []byte

func QuotedStringEncode

func QuotedStringEncode(str string) []byte

func QuotedStringEncodeByteString

func QuotedStringEncodeByteString(str []byte) []byte

func UTF16BEToUTF8

func UTF16BEToUTF8(data []byte) []byte

func UTF8ToUTF16BE

func UTF8ToUTF16BE(data []byte) []byte

Types

type BufferedWriter

type BufferedWriter struct {
	Writer io.Writer
	Buffer []byte
}

func NewBufferedWriter

func NewBufferedWriter(w io.Writer) *BufferedWriter

func (*BufferedWriter) Append

func (w *BufferedWriter) Append(data []byte)

func (*BufferedWriter) AppendString

func (w *BufferedWriter) AppendString(s string)

func (*BufferedWriter) Flush

func (w *BufferedWriter) Flush() error

func (*BufferedWriter) Reset

func (w *BufferedWriter) Reset()

func (*BufferedWriter) Write

func (w *BufferedWriter) Write(data []byte) (int, error)

type Client

type Client struct {
	Host       string
	Port       int
	TLS        bool
	CACertPath string
	CertPath   string
	KeyPath    string

	AuthMechanism string
	Login         string
	Password      string

	Conn   net.Conn
	Stream *Stream
	Writer *BufferedWriter

	State ClientState

	Caps map[string]bool

	Tag int
	// contains filtered or unexported fields
}

---------------------------------------------------------------------------

Client

---------------------------------------------------------------------------

func NewClient

func NewClient() *Client

func (*Client) Connect

func (c *Client) Connect() error

func (*Client) HasCap

func (c *Client) HasCap(cap string) bool

func (*Client) SendCommand

func (c *Client) SendCommand(cmd Command) ([]Response, *ResponseStatus, error)

func (*Client) SendCommandClose

func (c *Client) SendCommandClose() error

func (*Client) SendCommandCreate

func (c *Client) SendCommandCreate(mailboxName string) error

func (*Client) SendCommandDelete

func (c *Client) SendCommandDelete(mailboxName string) error

func (*Client) SendCommandExamine

func (c *Client) SendCommandExamine(mailboxName string) (*ResponseSetExamine, error)

func (*Client) SendCommandLSub

func (c *Client) SendCommandLSub(ref, pattern string) (*ResponseSetLSub, error)

func (*Client) SendCommandList

func (c *Client) SendCommandList(ref, pattern string) (*ResponseSetList, error)

func (*Client) SendCommandLogout

func (c *Client) SendCommandLogout() error

func (*Client) SendCommandRename

func (c *Client) SendCommandRename(mailboxName, mailboxNewName string) error

func (*Client) SendCommandSearch

func (c *Client) SendCommandSearch(charset string, key SearchKey) (*ResponseSetSearch, error)

func (*Client) SendCommandSelect

func (c *Client) SendCommandSelect(mailboxName string) (*ResponseSetSelect, error)

func (*Client) SendCommandSubscribe

func (c *Client) SendCommandSubscribe(mailboxName string) error

func (*Client) SendCommandUnsubscribe

func (c *Client) SendCommandUnsubscribe(mailboxName string) error

func (*Client) SendCommandWithResponseSet

func (c *Client) SendCommandWithResponseSet(cmd Command, rs ResponseSet) error

type ClientState

type ClientState string

---------------------------------------------------------------------------

Client state

---------------------------------------------------------------------------

const (
	ClientStateDisconnected     ClientState = "disconnected"
	ClientStateNotAuthenticated ClientState = "not-authenticated"
	ClientStateAuthenticated    ClientState = "authenticated"
	ClientStateLogout           ClientState = "logout"
)

type Command

type Command interface {
	Args() []interface{}
	Continue(*BufferedWriter, *ResponseContinuation) error
}

type CommandAuthenticateCramMD5

type CommandAuthenticateCramMD5 struct {
	Login    string
	Password string
}

CRAM-MD5 (RFC 2195)

func (*CommandAuthenticateCramMD5) Args

func (c *CommandAuthenticateCramMD5) Args() []interface{}

func (*CommandAuthenticateCramMD5) Continue

type CommandAuthenticatePlain

type CommandAuthenticatePlain struct {
	Login    string
	Password string
}

---------------------------------------------------------------------------

Command: AUTHENTICATE

--------------------------------------------------------------------------- PLAIN (RFC 4616)

func (*CommandAuthenticatePlain) Args

func (c *CommandAuthenticatePlain) Args() []interface{}

func (*CommandAuthenticatePlain) Continue

type CommandCapability

type CommandCapability struct {
}

---------------------------------------------------------------------------

Command: CAPABILITY

---------------------------------------------------------------------------

func (*CommandCapability) Args

func (c *CommandCapability) Args() []interface{}

func (*CommandCapability) Continue

type CommandClose

type CommandClose struct{}

---------------------------------------------------------------------------

Command: CLOSE

---------------------------------------------------------------------------

func (*CommandClose) Args

func (c *CommandClose) Args() []interface{}

func (*CommandClose) Continue

type CommandCreate

type CommandCreate struct {
	MailboxName string
}

---------------------------------------------------------------------------

Command: CREATE

---------------------------------------------------------------------------

func (*CommandCreate) Args

func (c *CommandCreate) Args() []interface{}

func (*CommandCreate) Continue

type CommandDelete

type CommandDelete struct {
	MailboxName string
}

---------------------------------------------------------------------------

Command: DELETE

---------------------------------------------------------------------------

func (*CommandDelete) Args

func (c *CommandDelete) Args() []interface{}

func (*CommandDelete) Continue

type CommandExamine

type CommandExamine struct {
	MailboxName string
}

---------------------------------------------------------------------------

Command: EXAMINE

---------------------------------------------------------------------------

func (*CommandExamine) Args

func (c *CommandExamine) Args() []interface{}

func (*CommandExamine) Continue

type CommandLSub

type CommandLSub struct {
	Ref     string
	Pattern string
}

---------------------------------------------------------------------------

Command: LSUB

---------------------------------------------------------------------------

func (*CommandLSub) Args

func (c *CommandLSub) Args() []interface{}

func (*CommandLSub) Continue

type CommandList

type CommandList struct {
	Ref     string
	Pattern string
}

---------------------------------------------------------------------------

Command: LIST

---------------------------------------------------------------------------

func (*CommandList) Args

func (c *CommandList) Args() []interface{}

func (*CommandList) Continue

type CommandLogout

type CommandLogout struct{}

---------------------------------------------------------------------------

Command: LOGOUT

---------------------------------------------------------------------------

func (*CommandLogout) Args

func (c *CommandLogout) Args() []interface{}

func (*CommandLogout) Continue

type CommandRename

type CommandRename struct {
	MailboxName    string
	MailboxNewName string
}

---------------------------------------------------------------------------

Command: RENAME

---------------------------------------------------------------------------

func (*CommandRename) Args

func (c *CommandRename) Args() []interface{}

func (*CommandRename) Continue

type CommandResponse

type CommandResponse struct {
	Data   []Response
	Status *ResponseStatus
	Error  error
}

type CommandSearch

type CommandSearch struct {
	Charset string
	Key     SearchKey
	UID     bool
}

---------------------------------------------------------------------------

Command: SEARCH

---------------------------------------------------------------------------

func (*CommandSearch) Args

func (c *CommandSearch) Args() []interface{}

func (*CommandSearch) Continue

type CommandSelect

type CommandSelect struct {
	MailboxName string
}

---------------------------------------------------------------------------

Command: SELECT

---------------------------------------------------------------------------

func (*CommandSelect) Args

func (c *CommandSelect) Args() []interface{}

func (*CommandSelect) Continue

type CommandSubscribe

type CommandSubscribe struct {
	MailboxName string
}

---------------------------------------------------------------------------

Command: SUBSCRIBE

---------------------------------------------------------------------------

func (*CommandSubscribe) Args

func (c *CommandSubscribe) Args() []interface{}

func (*CommandSubscribe) Continue

type CommandUnsubscribe

type CommandUnsubscribe struct {
	MailboxName string
}

---------------------------------------------------------------------------

Command: UNSUBSCRIBE

---------------------------------------------------------------------------

func (*CommandUnsubscribe) Args

func (c *CommandUnsubscribe) Args() []interface{}

func (*CommandUnsubscribe) Continue

type Literal

type Literal []byte

type MailboxList

type MailboxList struct {
	Flags              []string
	HierarchyDelimiter rune
	Name               string
}

type Response

type Response interface {
	fmt.GoStringer
	Read(*Stream) error
}

func ReadResponse

func ReadResponse(s *Stream) (Response, error)

func ReadResponseContinuation

func ReadResponseContinuation(s *Stream) (Response, error)

---------------------------------------------------------------------------

Command continuation responses

---------------------------------------------------------------------------

func ReadResponseData

func ReadResponseData(s *Stream) (Response, error)

---------------------------------------------------------------------------

Server data responses

---------------------------------------------------------------------------

func ReadResponseStatus

func ReadResponseStatus(s *Stream) (Response, error)

---------------------------------------------------------------------------

Status responses

---------------------------------------------------------------------------

type ResponseBad

type ResponseBad struct {
	Text *ResponseText
}

BAD

func (*ResponseBad) GoString

func (r *ResponseBad) GoString() string

func (*ResponseBad) Read

func (r *ResponseBad) Read(s *Stream) error

type ResponseBye

type ResponseBye struct {
	Text *ResponseText
}

BYE

func (*ResponseBye) GoString

func (r *ResponseBye) GoString() string

func (*ResponseBye) Read

func (r *ResponseBye) Read(s *Stream) error

type ResponseCapability

type ResponseCapability struct {
	Caps []string
}

CAPABILITY

func (*ResponseCapability) GoString

func (r *ResponseCapability) GoString() string

func (*ResponseCapability) Read

func (r *ResponseCapability) Read(s *Stream) error

type ResponseContinuation

type ResponseContinuation struct {
	Text string
}

func (*ResponseContinuation) GoString

func (r *ResponseContinuation) GoString() string

func (*ResponseContinuation) Read

func (r *ResponseContinuation) Read(s *Stream) error

type ResponseExists

type ResponseExists struct {
	Count uint32
}

EXISTS

func (*ResponseExists) GoString

func (r *ResponseExists) GoString() string

func (*ResponseExists) Read

func (r *ResponseExists) Read(s *Stream) error

type ResponseFlags

type ResponseFlags struct {
	Flags []string
}

FLAGS

func (*ResponseFlags) GoString

func (r *ResponseFlags) GoString() string

func (*ResponseFlags) Read

func (r *ResponseFlags) Read(s *Stream) error

type ResponseLSub

type ResponseLSub MailboxList

LSUB

func (*ResponseLSub) GoString

func (r *ResponseLSub) GoString() string

func (*ResponseLSub) Read

func (r *ResponseLSub) Read(s *Stream) error

type ResponseList

type ResponseList MailboxList

LIST

func (*ResponseList) GoString

func (r *ResponseList) GoString() string

func (*ResponseList) Read

func (r *ResponseList) Read(s *Stream) error

type ResponseNo

type ResponseNo struct {
	Text *ResponseText
}

NO

func (*ResponseNo) GoString

func (r *ResponseNo) GoString() string

func (*ResponseNo) Read

func (r *ResponseNo) Read(s *Stream) error

type ResponseOk

type ResponseOk struct {
	Text *ResponseText
}

OK

func (*ResponseOk) GoString

func (r *ResponseOk) GoString() string

func (*ResponseOk) Read

func (r *ResponseOk) Read(s *Stream) error

type ResponsePreAuth

type ResponsePreAuth struct {
	Text *ResponseText
}

PREAUTH

func (*ResponsePreAuth) GoString

func (r *ResponsePreAuth) GoString() string

func (*ResponsePreAuth) Read

func (r *ResponsePreAuth) Read(s *Stream) error

type ResponseRecent

type ResponseRecent struct {
	Count uint32
}

RECENT

func (*ResponseRecent) GoString

func (r *ResponseRecent) GoString() string

func (*ResponseRecent) Read

func (r *ResponseRecent) Read(s *Stream) error

type ResponseSearch

type ResponseSearch struct {
	MessageIds []uint32
}

SEARCH

func (*ResponseSearch) GoString

func (r *ResponseSearch) GoString() string

func (*ResponseSearch) Read

func (r *ResponseSearch) Read(s *Stream) error

type ResponseSet

type ResponseSet interface {
	Init([]Response, *ResponseStatus) error
}

type ResponseSetExamine

type ResponseSetExamine struct {
	Flags          []string
	Exists         uint32
	Recent         uint32
	Unseen         uint32
	PermanentFlags []string
	UIDNext        uint32
	UIDValidity    uint32
}

---------------------------------------------------------------------------

Response set: EXAMINE

---------------------------------------------------------------------------

func (*ResponseSetExamine) Init

func (rs *ResponseSetExamine) Init(resps []Response, status *ResponseStatus) error

type ResponseSetLSub

type ResponseSetLSub struct {
	Mailboxes []MailboxList
}

---------------------------------------------------------------------------

Response set: LSUB

---------------------------------------------------------------------------

func (*ResponseSetLSub) Init

func (rs *ResponseSetLSub) Init(resps []Response, status *ResponseStatus) error

type ResponseSetList

type ResponseSetList struct {
	Mailboxes []MailboxList
}

---------------------------------------------------------------------------

Response set: LIST

---------------------------------------------------------------------------

func (*ResponseSetList) Init

func (rs *ResponseSetList) Init(resps []Response, status *ResponseStatus) error

type ResponseSetSearch

type ResponseSetSearch struct {
	MessageIds SequenceSet
}

---------------------------------------------------------------------------

Response set: SEARCH

---------------------------------------------------------------------------

func (*ResponseSetSearch) Init

func (rs *ResponseSetSearch) Init(resps []Response, status *ResponseStatus) error

type ResponseSetSelect

type ResponseSetSelect struct {
	Flags          []string
	Exists         uint32
	Recent         uint32
	Unseen         uint32
	PermanentFlags []string
	UIDNext        uint32
	UIDValidity    uint32
}

---------------------------------------------------------------------------

Response set: SELECT

---------------------------------------------------------------------------

func (*ResponseSetSelect) Init

func (rs *ResponseSetSelect) Init(resps []Response, status *ResponseStatus) error

type ResponseStatus

type ResponseStatus struct {
	Tag          string
	ResponseName string
	Response     Response
}

func (*ResponseStatus) GoString

func (r *ResponseStatus) GoString() string

func (*ResponseStatus) IsOk

func (r *ResponseStatus) IsOk() bool

func (*ResponseStatus) Read

func (r *ResponseStatus) Read(s *Stream) error

type ResponseText

type ResponseText struct {
	Text string

	// Optional
	Code       string
	CodeString string
	CodeData   interface{}
}

---------------------------------------------------------------------------

Response text

---------------------------------------------------------------------------

func (*ResponseText) GoString

func (r *ResponseText) GoString() string

func (*ResponseText) Read

func (r *ResponseText) Read(s *Stream) error

func (*ResponseText) ReadCodeData

func (r *ResponseText) ReadCodeData(data []byte) error

type SearchKey

type SearchKey []interface{}

func ParseSearchString

func ParseSearchString(str string) (SearchKey, error)

func SearchKeyAll

func SearchKeyAll() SearchKey

func SearchKeyAnswered

func SearchKeyAnswered() SearchKey

func SearchKeyBCC

func SearchKeyBCC(str string) SearchKey

func SearchKeyBefore

func SearchKeyBefore(date time.Time) SearchKey

func SearchKeyBody

func SearchKeyBody(str string) SearchKey

func SearchKeyCC

func SearchKeyCC(str string) SearchKey

func SearchKeyDeleted

func SearchKeyDeleted() SearchKey

func SearchKeyDraft

func SearchKeyDraft() SearchKey

func SearchKeyFlagged

func SearchKeyFlagged() SearchKey

func SearchKeyFrom

func SearchKeyFrom(str string) SearchKey

func SearchKeyHeader

func SearchKeyHeader(name, str string) SearchKey

func SearchKeyKeyword

func SearchKeyKeyword(keyword string) SearchKey

func SearchKeyLarger

func SearchKeyLarger(size uint32) SearchKey

func SearchKeyList

func SearchKeyList(list []SearchKey) SearchKey

func SearchKeyNew

func SearchKeyNew() SearchKey

func SearchKeyNot

func SearchKeyNot(key SearchKey) SearchKey

func SearchKeyOld

func SearchKeyOld() SearchKey

func SearchKeyOn

func SearchKeyOn(date time.Time) SearchKey

func SearchKeyOr

func SearchKeyOr(key1, key2 SearchKey) SearchKey

func SearchKeyRecent

func SearchKeyRecent() SearchKey

func SearchKeySeen

func SearchKeySeen() SearchKey

func SearchKeySentBefore

func SearchKeySentBefore(date time.Time) SearchKey

func SearchKeySentOn

func SearchKeySentOn(date time.Time) SearchKey

func SearchKeySentSince

func SearchKeySentSince(date time.Time) SearchKey

func SearchKeySequenceSet

func SearchKeySequenceSet(set SequenceSet) SearchKey

func SearchKeySince

func SearchKeySince(date time.Time) SearchKey

func SearchKeySmaller

func SearchKeySmaller(size uint32) SearchKey

func SearchKeySubject

func SearchKeySubject(str string) SearchKey

func SearchKeyText

func SearchKeyText(str string) SearchKey

func SearchKeyTo

func SearchKeyTo(str string) SearchKey

func SearchKeyUID

func SearchKeyUID(set SequenceSet) SearchKey

func SearchKeyUnanswered

func SearchKeyUnanswered() SearchKey

func SearchKeyUndeleted

func SearchKeyUndeleted() SearchKey

func SearchKeyUndraft

func SearchKeyUndraft() SearchKey

func SearchKeyUnflagged

func SearchKeyUnflagged() SearchKey

func SearchKeyUnkeyword

func SearchKeyUnkeyword(keyword string) SearchKey

func SearchKeyUnseen

func SearchKeyUnseen() SearchKey

type SequenceNumber

type SequenceNumber uint32

---------------------------------------------------------------------------

Sequence number

---------------------------------------------------------------------------

const SequenceStar SequenceNumber = 0

SequenceStar represents '*', i.e. the largest number in use in the current context. We use zero since it's available: sequence numbers are always greater than zero.

func (SequenceNumber) GoString

func (n SequenceNumber) GoString() string

func (SequenceNumber) MarshalText

func (n SequenceNumber) MarshalText() ([]byte, error)

func (SequenceNumber) String

func (n SequenceNumber) String() string

type SequenceRange

type SequenceRange struct {
	First SequenceNumber
	Last  SequenceNumber
}

---------------------------------------------------------------------------

Sequence range

---------------------------------------------------------------------------

func NewSequenceRange

func NewSequenceRange(first, last SequenceNumber) SequenceRange

func (SequenceRange) GoString

func (r SequenceRange) GoString() string

func (SequenceRange) MarshalText

func (r SequenceRange) MarshalText() ([]byte, error)

func (SequenceRange) String

func (r SequenceRange) String() string

type SequenceSet

type SequenceSet []SequenceSetEntry

func NewSequenceSet

func NewSequenceSet() SequenceSet

func (*SequenceSet) Append

func (s *SequenceSet) Append(e SequenceSetEntry)

func (SequenceSet) GoString

func (s SequenceSet) GoString() string

func (SequenceSet) MarshalText

func (s SequenceSet) MarshalText() ([]byte, error)

func (SequenceSet) String

func (s SequenceSet) String() string

type SequenceSetEntry

type SequenceSetEntry interface {
	fmt.Stringer
	fmt.GoStringer
	encoding.TextMarshaler
}

---------------------------------------------------------------------------

Sequence set

---------------------------------------------------------------------------

type Stream

type Stream struct {
	Reader io.Reader
	Buf    []byte
}

func NewStream

func NewStream(r io.Reader) *Stream

func (*Stream) IsEmpty

func (s *Stream) IsEmpty() (bool, error)

func (*Stream) Peek

func (s *Stream) Peek(n int) ([]byte, error)

func (*Stream) PeekUntil

func (s *Stream) PeekUntil(delim []byte) ([]byte, error)

func (*Stream) PeekUntilByte

func (s *Stream) PeekUntilByte(delim byte) ([]byte, error)

func (*Stream) PeekUpTo

func (s *Stream) PeekUpTo(n int) ([]byte, error)

func (*Stream) Read

func (s *Stream) Read(n int) ([]byte, error)

func (*Stream) ReadAll

func (s *Stream) ReadAll() ([]byte, error)

func (*Stream) ReadIMAPAstring

func (s *Stream) ReadIMAPAstring() ([]byte, error)

func (*Stream) ReadIMAPFlagList

func (s *Stream) ReadIMAPFlagList() ([]string, error)

func (*Stream) ReadIMAPLiteralString

func (s *Stream) ReadIMAPLiteralString() ([]byte, error)

func (*Stream) ReadIMAPMailboxList

func (s *Stream) ReadIMAPMailboxList() (*MailboxList, error)

func (*Stream) ReadIMAPNumber

func (s *Stream) ReadIMAPNumber() (uint32, error)

func (*Stream) ReadIMAPQuotedChar

func (s *Stream) ReadIMAPQuotedChar() (byte, bool, error)

func (*Stream) ReadIMAPQuotedString

func (s *Stream) ReadIMAPQuotedString() ([]byte, error)

func (*Stream) ReadUntil

func (s *Stream) ReadUntil(delim []byte) ([]byte, error)

func (*Stream) ReadUntilAndSkip

func (s *Stream) ReadUntilAndSkip(delim []byte) ([]byte, error)

func (*Stream) ReadUntilByte

func (s *Stream) ReadUntilByte(delim byte) ([]byte, error)

func (*Stream) ReadUntilByteAndSkip

func (s *Stream) ReadUntilByteAndSkip(delim byte) ([]byte, error)

func (*Stream) ReadWhile

func (s *Stream) ReadWhile(fn func(byte) bool) ([]byte, error)

func (*Stream) Skip

func (s *Stream) Skip(n int) error

func (*Stream) SkipByte

func (s *Stream) SkipByte(b byte) (bool, error)

func (*Stream) SkipBytes

func (s *Stream) SkipBytes(bs []byte) (bool, error)

func (*Stream) SkipWhile

func (s *Stream) SkipWhile(fn func(byte) bool) error

func (*Stream) StartsWithByte

func (s *Stream) StartsWithByte(b byte) (bool, error)

func (*Stream) StartsWithBytes

func (s *Stream) StartsWithBytes(bs []byte) (bool, error)

Directories

Path Synopsis
utils

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL