lib

package
v0.0.0-...-854a73e Latest Latest
Warning

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

Go to latest
Published: Dec 21, 2024 License: MIT Imports: 39 Imported by: 0

Documentation

Index

Constants

View Source
const MagicUid = models.UID("")

Variables

This section is empty.

Functions

func EqualParts

func EqualParts(a []int, b []int) bool

func FindAllNonMultipart

func FindAllNonMultipart(bs *models.BodyStructure, path []int, pathlist [][]int) [][]int

func FindCalendartext

func FindCalendartext(bs *models.BodyStructure, path []int) []int

func FindFirstNonMultipart

func FindFirstNonMultipart(bs *models.BodyStructure, path []int) []int

func FindMIMEPart

func FindMIMEPart(mime string, bs *models.BodyStructure, path []int) []int

FindMIMEPart finds the first message part with the provided MIME type. FindMIMEPart recurses inside multipart containers.

func FindMimeType

func FindMimeType(filename string, reader *bufio.Reader) (string, map[string]string, error)

func FindPlaintext

func FindPlaintext(bs *models.BodyStructure, path []int) []int

func GetRefreshToken

func GetRefreshToken(acct string) ([]byte, error)

func NewEmlMessageView

func NewEmlMessageView(full []byte, pgp crypto.Provider,
	decryptKeys openpgp.PromptFunction, cb func(MessageView, error),
)

NewEmlMessageView provides a MessageView for a full message that is not stored in a message store

func NewMessageStoreView

func NewMessageStoreView(messageInfo *models.MessageInfo, setSeen bool,
	store *MessageStore, pgp crypto.Provider, decryptKeys openpgp.PromptFunction,
	innerCb func(MessageView, error),
)

func NewXoauth2Client

func NewXoauth2Client(username, token string) sasl.Client

An implementation of the XOAUTH2 authentication mechanism, as described in https://developers.google.com/gmail/xoauth2_protocol.

func NotmuchVersion

func NotmuchVersion() (string, bool)

func SaveRefreshToken

func SaveRefreshToken(refreshToken string, acct string) error

func SetTcpKeepaliveInterval

func SetTcpKeepaliveInterval(fd, interval int) error

func SetTcpKeepaliveProbes

func SetTcpKeepaliveProbes(fd, count int) error

func SetUtf8Charset

func SetUtf8Charset(origParams map[string]string) map[string]string

SetUtf8Charset sets the charset in a params map to UTF-8.

func XDGOpenMime

func XDGOpenMime(
	uri string, mimeType string, args string,
) error

Types

type Attachment

type Attachment interface {
	Name() string
	WriteTo(w *mail.Writer) error
}

type DirStore

type DirStore struct {
	// contains filtered or unexported fields
}

func NewDirStore

func NewDirStore() *DirStore

func (*DirStore) Directory

func (store *DirStore) Directory(name string) *models.Directory

func (*DirStore) List

func (store *DirStore) List() []string

func (*DirStore) MessageStore

func (store *DirStore) MessageStore(dirname string) (*MessageStore, bool)

func (*DirStore) Remove

func (store *DirStore) Remove(name string)

func (*DirStore) SetMessageStore

func (store *DirStore) SetMessageStore(dir *models.Directory, msgStore *MessageStore)

type EmlMessage

type EmlMessage []byte

EmlMessage implements the RawMessage interface

func (*EmlMessage) Labels

func (fm *EmlMessage) Labels() ([]string, error)

func (*EmlMessage) ModelFlags

func (fm *EmlMessage) ModelFlags() (models.Flags, error)

func (*EmlMessage) NewReader

func (fm *EmlMessage) NewReader() (io.ReadCloser, error)

func (*EmlMessage) UID

func (fm *EmlMessage) UID() models.UID

type FileAttachment

type FileAttachment struct {
	// contains filtered or unexported fields
}

func NewFileAttachment

func NewFileAttachment(path string) *FileAttachment

func (*FileAttachment) Name

func (fa *FileAttachment) Name() string

func (*FileAttachment) WriteTo

func (fa *FileAttachment) WriteTo(w *mail.Writer) error

type History

type History interface {
	// Add a new element to the history
	Add(string)
	// Get the next element in history
	Next() string
	// Get the previous element in history
	Prev() string
	// Reset the current location in history
	Reset()
}

History represents a list of elements ordered by time.

type MessageStore

type MessageStore struct {
	sync.Mutex
	Name     string
	Deleted  map[models.UID]interface{}
	Messages map[models.UID]*models.MessageInfo
	Sorting  bool
	// contains filtered or unexported fields
}

Accesses to fields must be guarded by MessageStore.Lock/Unlock

func NewMessageStore

func NewMessageStore(worker *types.Worker, name string,
	ui func() *config.UIConfig,
	triggerNewEmail func(*models.MessageInfo),
	triggerDirectoryChange func(), triggerMailDeleted func(),
	triggerMailAdded func(string), triggerTagModified func([]string, []string),
	triggerFlagChanged func(string),
	onSelect func(*models.MessageInfo),
) *MessageStore

func (*MessageStore) Answered

func (store *MessageStore) Answered(uids []models.UID, answered bool,
	cb func(msg types.WorkerMessage),
)

func (*MessageStore) Append

func (store *MessageStore) Append(dest string, flags models.Flags, date time.Time,
	reader io.Reader, length int, cb func(msg types.WorkerMessage),
)

func (*MessageStore) ApplyClear

func (store *MessageStore) ApplyClear()

func (*MessageStore) ApplySearch

func (store *MessageStore) ApplySearch(results []models.UID)

func (*MessageStore) BuildThreads

func (store *MessageStore) BuildThreads() bool

func (*MessageStore) Capabilities

func (store *MessageStore) Capabilities() *models.Capabilities

Capabilities returns a models.Capabilities struct or nil if not available

func (*MessageStore) Configure

func (store *MessageStore) Configure(
	defaultSort []*types.SortCriterion,
)

func (*MessageStore) Copy

func (store *MessageStore) Copy(uids []models.UID, dest string, createDest bool,
	mfs *types.MultiFileStrategy, cb func(msg types.WorkerMessage),
)

func (*MessageStore) Delete

func (store *MessageStore) Delete(uids []models.UID, mfs *types.MultiFileStrategy,
	cb func(msg types.WorkerMessage),
)

func (*MessageStore) FetchBodyPart

func (store *MessageStore) FetchBodyPart(uid models.UID, part []int, cb func(io.Reader))

func (*MessageStore) FetchFull

func (store *MessageStore) FetchFull(uids []models.UID, cb func(*types.FullMessage))

func (*MessageStore) FetchHeaders

func (store *MessageStore) FetchHeaders(uids []models.UID,
	cb func(types.WorkerMessage),
)

func (*MessageStore) FindIndexByUid

func (store *MessageStore) FindIndexByUid(uid models.UID) int

FindIndexByUid returns the index in store.Uids() or -1 if not found

func (*MessageStore) Flag

func (store *MessageStore) Flag(uids []models.UID, flags models.Flags,
	enable bool, cb func(msg types.WorkerMessage),
)

func (*MessageStore) Fold

func (store *MessageStore) Fold(uid models.UID, toggle bool) error

func (*MessageStore) Forwarded

func (store *MessageStore) Forwarded(uids []models.UID, forwarded bool,
	cb func(msg types.WorkerMessage),
)

func (*MessageStore) GetCurrentSortCriteria

func (store *MessageStore) GetCurrentSortCriteria() []*types.SortCriterion

func (*MessageStore) IsResult

func (store *MessageStore) IsResult(uid models.UID) bool

IsResult returns true if uid is a search result

func (*MessageStore) Marker

func (store *MessageStore) Marker() marker.Marker

func (*MessageStore) ModifyLabels

func (store *MessageStore) ModifyLabels(uids []models.UID, add, remove []string,
	cb func(msg types.WorkerMessage),
)

func (*MessageStore) Move

func (store *MessageStore) Move(uids []models.UID, dest string, createDest bool,
	mfs *types.MultiFileStrategy, cb func(msg types.WorkerMessage),
)

func (*MessageStore) Next

func (store *MessageStore) Next()

func (*MessageStore) NextPrev

func (store *MessageStore) NextPrev(delta int)

func (*MessageStore) NextResult

func (store *MessageStore) NextResult()

func (*MessageStore) OnFilterChange

func (store *MessageStore) OnFilterChange(fn func(store *MessageStore))

func (*MessageStore) OnUpdate

func (store *MessageStore) OnUpdate(fn func(store *MessageStore))

func (*MessageStore) OnUpdateDirs

func (store *MessageStore) OnUpdateDirs(fn func())

func (*MessageStore) Prev

func (store *MessageStore) Prev()

func (*MessageStore) PrevResult

func (store *MessageStore) PrevResult()

func (*MessageStore) ReverseThreadOrder

func (store *MessageStore) ReverseThreadOrder() bool

func (*MessageStore) Search

func (store *MessageStore) Search(terms *types.SearchCriteria, cb func([]models.UID))

func (*MessageStore) Select

func (store *MessageStore) Select(uid models.UID)

func (*MessageStore) Selected

func (store *MessageStore) Selected() *models.MessageInfo

func (*MessageStore) SelectedIndex

func (store *MessageStore) SelectedIndex() int

SelectedIndex returns the index of the selected message in the uid list or -1 if not found

func (*MessageStore) SelectedThread

func (store *MessageStore) SelectedThread() (*types.Thread, error)

SelectedThread returns the thread with the UID from the selected message

func (*MessageStore) SelectedUid

func (store *MessageStore) SelectedUid() models.UID

func (*MessageStore) SetContext

func (store *MessageStore) SetContext(ctx context.Context)

func (*MessageStore) SetFilter

func (store *MessageStore) SetFilter(terms *types.SearchCriteria)

func (*MessageStore) SetMarker

func (store *MessageStore) SetMarker(m marker.Marker)

func (*MessageStore) SetThreadedView

func (store *MessageStore) SetThreadedView(thread bool)

func (*MessageStore) Sort

func (store *MessageStore) Sort(criteria []*types.SortCriterion, cb func(types.WorkerMessage))

func (*MessageStore) Thread

func (store *MessageStore) Thread(uid models.UID) (*types.Thread, error)

Thread returns the thread for the given UId

func (*MessageStore) ThreadedView

func (store *MessageStore) ThreadedView() bool

func (*MessageStore) ThreadsIterator

func (store *MessageStore) ThreadsIterator() iterator.Iterator

func (*MessageStore) ToggleThreadContext

func (store *MessageStore) ToggleThreadContext()

func (*MessageStore) Uids

func (store *MessageStore) Uids() []models.UID

func (*MessageStore) UidsIterator

func (store *MessageStore) UidsIterator() iterator.Iterator

func (*MessageStore) Unfold

func (store *MessageStore) Unfold(uid models.UID, toggle bool) error

func (*MessageStore) Update

func (store *MessageStore) Update(msg types.WorkerMessage)

func (*MessageStore) UpdateScroll

func (store *MessageStore) UpdateScroll(offset, length int)

type MessageStoreView

type MessageStoreView struct {
	// contains filtered or unexported fields
}

func (*MessageStoreView) BodyStructure

func (msv *MessageStoreView) BodyStructure() *models.BodyStructure

func (*MessageStoreView) FetchBodyPart

func (msv *MessageStoreView) FetchBodyPart(part []int, cb func(io.Reader))

func (*MessageStoreView) FetchFull

func (msv *MessageStoreView) FetchFull(cb func(io.Reader))

func (*MessageStoreView) MessageDetails

func (msv *MessageStoreView) MessageDetails() *models.MessageDetails

func (*MessageStoreView) MessageInfo

func (msv *MessageStoreView) MessageInfo() *models.MessageInfo

func (*MessageStoreView) SeenFlagSet

func (msv *MessageStoreView) SeenFlagSet() bool

func (*MessageStoreView) Store

func (msv *MessageStoreView) Store() *MessageStore

type MessageView

type MessageView interface {
	// Returns the MessageInfo for this message
	MessageInfo() *models.MessageInfo

	// Returns the BodyStructure for this message
	BodyStructure() *models.BodyStructure

	// Returns the message store that this message was originally sourced from
	Store() *MessageStore

	// Fetches the full message
	FetchFull(cb func(io.Reader))

	// Fetches a specific body part for this message
	FetchBodyPart(part []int, cb func(io.Reader))

	MessageDetails() *models.MessageDetails

	// SeenFlagSet returns true if the "seen" flag has been set
	SeenFlagSet() bool
}

This is an abstraction for viewing a message with semi-transparent PGP support.

type OAuthBearer

type OAuthBearer struct {
	OAuth2  *oauth2.Config
	Enabled bool
}

func (*OAuthBearer) Authenticate

func (c *OAuthBearer) Authenticate(username string, password string, client *client.Client) error

func (*OAuthBearer) ExchangeRefreshToken

func (c *OAuthBearer) ExchangeRefreshToken(refreshToken string) (*oauth2.Token, error)

type Part

type Part struct {
	MimeType        string
	Params          map[string]string
	Data            []byte
	Converted       bool
	ConversionError error
}

func NewPart

func NewPart(mimetype string, params map[string]string, body io.Reader,
) (*Part, error)

func (*Part) NewReader

func (p *Part) NewReader() io.Reader

type PartAttachment

type PartAttachment struct {
	// contains filtered or unexported fields
}

func NewPartAttachment

func NewPartAttachment(part *Part, name string) *PartAttachment

func (*PartAttachment) Name

func (pa *PartAttachment) Name() string

func (*PartAttachment) WriteTo

func (pa *PartAttachment) WriteTo(w *mail.Writer) error

type ThreadBuilder

type ThreadBuilder struct {
	sync.Mutex
	// contains filtered or unexported fields
}

func NewThreadBuilder

func NewThreadBuilder(i iterator.Factory, bySubject bool) *ThreadBuilder

func (*ThreadBuilder) RebuildUids

func (builder *ThreadBuilder) RebuildUids(threads []*types.Thread, inverse bool)

RebuildUids rebuilds the uids from the given slice of threads

func (*ThreadBuilder) ThreadForUid

func (builder *ThreadBuilder) ThreadForUid(uid models.UID) (*types.Thread, error)

func (*ThreadBuilder) Threads

func (builder *ThreadBuilder) Threads(uids []models.UID, inverse bool, sort bool,
) []*types.Thread

Threads returns a slice of threads for the given list of uids

func (*ThreadBuilder) Uids

func (builder *ThreadBuilder) Uids() []models.UID

Uids returns the uids in threading order

func (*ThreadBuilder) Update

func (builder *ThreadBuilder) Update(msg *models.MessageInfo)

Update updates the thread builder with a new message header

type Xoauth2

type Xoauth2 struct {
	OAuth2  *oauth2.Config
	Enabled bool
}

func (*Xoauth2) Authenticate

func (c *Xoauth2) Authenticate(
	username string,
	password string,
	account string,
	client *client.Client,
) error

func (*Xoauth2) ExchangeRefreshToken

func (c *Xoauth2) ExchangeRefreshToken(refreshToken string) (*oauth2.Token, error)

type Xoauth2Error

type Xoauth2Error struct {
	Status  string `json:"status"`
	Schemes string `json:"schemes"`
	Scope   string `json:"scope"`
}

An XOAUTH2 error.

func (*Xoauth2Error) Error

func (err *Xoauth2Error) Error() string

Implements error.

Jump to

Keyboard shortcuts

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