Documentation
¶
Index ¶
- Constants
- Variables
- func Configure(fn string) error
- func MIMEDecode(s string) (string, error)
- func MIMEEncode(s string) string
- type Attachment
- type CmdG
- func (c *CmdG) BatchArchive(ctx context.Context, ids []string) error
- func (c *CmdG) BatchDelete(ctx context.Context, ids []string) error
- func (c *CmdG) BatchLabel(ctx context.Context, ids []string, labelID string) error
- func (c *CmdG) BatchTrash(ctx context.Context, ids []string) error
- func (c *CmdG) BatchUnlabel(ctx context.Context, ids []string, labelID string) (err error)
- func (c *CmdG) Contacts() []string
- func (c *CmdG) GetContacts(ctx context.Context) ([]string, error)
- func (c *CmdG) GetDefaultSender() string
- func (c *CmdG) GetFile(ctx context.Context, fn string) ([]byte, error)
- func (c *CmdG) GetProfile(ctx context.Context) (*gmail.Profile, error)
- func (c *CmdG) GetTokenInfo(ctx context.Context) (*TokenInfo, error)
- func (c *CmdG) GmailService() *gmail.Service
- func (c *CmdG) History(ctx context.Context, startID HistoryID, labelID string) ([]*gmail.History, HistoryID, error)
- func (c *CmdG) HistoryID(ctx context.Context) (HistoryID, error)
- func (c *CmdG) LabelCache(label *Label) *Label
- func (c *CmdG) Labels() []*Label
- func (c *CmdG) ListDrafts(ctx context.Context) ([]*Draft, error)
- func (c *CmdG) ListMessages(ctx context.Context, label, query, token string) (*Page, error)
- func (c *CmdG) LoadContacts(ctx context.Context) error
- func (c *CmdG) LoadLabels(ctx context.Context) error
- func (c *CmdG) LoadSettings(ctx context.Context) error
- func (c *CmdG) MakeDraft(ctx context.Context, msg string) error
- func (c *CmdG) MessageCache(msg *Message) *Message
- func (c *CmdG) MoreHistory(ctx context.Context, start HistoryID, labelID string) (bool, error)
- func (c *CmdG) PutFile(ctx context.Context, fn string, contents []byte) error
- func (c *CmdG) SaveSettings(ctx context.Context) error
- func (c *CmdG) SendParts(ctx context.Context, threadID ThreadID, mp string, head mail.Header, ...) error
- func (c *CmdG) SetDefaultSender(s string)
- func (c *CmdG) UpdateFile(ctx context.Context, fn string, contents []byte) error
- type Config
- type ConfigOAuth
- type DataLevel
- type Draft
- func (d *Draft) Delete(ctx context.Context) error
- func (d *Draft) GetBody(ctx context.Context) (string, error)
- func (d *Draft) GetHeader(ctx context.Context, h string) (string, error)
- func (d *Draft) GetSubject(ctx context.Context) (string, error)
- func (d *Draft) HasData(level DataLevel) bool
- func (d *Draft) Send(ctx context.Context) error
- func (d *Draft) Update(ctx context.Context, content string) error
- func (d *Draft) UpdateParts(ctx context.Context, head mail.Header, parts []*Part) error
- type HistoryID
- type Label
- type Message
- func (msg *Message) AddLabelID(ctx context.Context, labelID string) error
- func (msg *Message) AddLabelIDLocal(labelID string)
- func (msg *Message) Attachments(ctx context.Context) ([]*Attachment, error)
- func (msg *Message) GPGStatus() *gpg.Status
- func (msg *Message) GetBody(ctx context.Context) (string, error)
- func (msg *Message) GetBodyHTML(ctx context.Context) (string, error)
- func (msg *Message) GetDateHeader(ctx context.Context) (string, error)
- func (msg *Message) GetFrom(ctx context.Context) (string, error)
- func (msg *Message) GetHeader(ctx context.Context, k string) (string, error)
- func (msg *Message) GetLabelColors(ctx context.Context, exclude string) (string, string, error)
- func (msg *Message) GetLabels(ctx context.Context, withUnread bool) ([]*Label, error)
- func (msg *Message) GetLabelsString(ctx context.Context) (string, error)
- func (msg *Message) GetOriginalTime(ctx context.Context) (time.Time, error)
- func (msg *Message) GetReferences(ctx context.Context) ([]string, error)
- func (msg *Message) GetReplyTo(ctx context.Context) (string, error)
- func (msg *Message) GetReplyToAll(ctx context.Context) (string, string, error)
- func (msg *Message) GetSubject(ctx context.Context) (string, error)
- func (msg *Message) GetTime(ctx context.Context) (time.Time, error)
- func (msg *Message) GetTimeFmt(ctx context.Context) (string, error)
- func (msg *Message) GetUnpatchedBody(ctx context.Context) (string, error)
- func (msg *Message) HasData(level DataLevel) bool
- func (msg *Message) HasLabel(labelID string) bool
- func (msg *Message) IsUnread() bool
- func (msg *Message) LocalLabels() []string
- func (msg *Message) Preload(ctx context.Context, level DataLevel) error
- func (msg *Message) Raw(ctx context.Context) (string, error)
- func (msg *Message) Reload(ctx context.Context, level DataLevel) error
- func (msg *Message) ReloadLabels(ctx context.Context) error
- func (msg *Message) RemoveLabelID(ctx context.Context, labelID string) error
- func (msg *Message) RemoveLabelIDLocal(labelID string)
- func (msg *Message) ThreadID(ctx context.Context) (ThreadID, error)
- type Page
- type Part
- type Settings
- type ThreadID
- type TokenInfo
Constants ¶
const ( Inbox = "INBOX" Trash = "TRASH" Unread = "UNREAD" Starred = "STARRED" )
Special labels.
Variables ¶
var ( // DefaultClientID is the Oauth client ID. DefaultClientID = "" // DefaultClientSecret is the Oauth client secret. DefaultClientSecret = "" )
var ( // GPG is the handle to a GPG config. GPG *gpg.GPG // Openssl is the executable is used to verify some signatures. Openssl = "openssl" // ErrMissing is used e.g. if a header is not present. As opposed to malformed. ErrMissing = fmt.Errorf("resource missing") )
Functions ¶
func MIMEDecode ¶
MIMEDecode does mime encode for fmail. Seems to be a special version of base64.
func MIMEEncode ¶
MIMEEncode does mime decode for gmail. Seems to be special version of base64.
Types ¶
type Attachment ¶
type Attachment struct {
ID string
MsgID string
Part *gmail.MessagePart
// contains filtered or unexported fields
}
Attachment is an attachment.
type CmdG ¶
type CmdG struct {
// contains filtered or unexported fields
}
CmdG is the main app for cmdg. It holds both rpc clients and various caches. Everything except the UI.
func (*CmdG) BatchArchive ¶
BatchArchive archives all the given message IDs.
func (*CmdG) BatchDelete ¶
BatchDelete deletes. Does not put in trash. Does not pass go: "Immediately and permanently deletes the specified message. This operation cannot be undone."
cmdg doesn't actually request oauth permission to do this, so this function is never used. Instead BatchTrash is used.
func (*CmdG) BatchLabel ¶
BatchLabel adds one new label to many messages.
func (*CmdG) BatchTrash ¶
BatchTrash trashes the messages.
There isn't actually a BatchTrash, so we'll pretend with just labels.
func (*CmdG) BatchUnlabel ¶
BatchUnlabel removes one label from many messages.
func (*CmdG) GetContacts ¶
GetContacts gets all contact's email addresses in "Name Name <email@example.com>" format.
func (*CmdG) GetDefaultSender ¶
GetDefaultSender gets the default sender, if no From was provided at compose.
func (*CmdG) GetProfile ¶
GetProfile returns the profile for the current user.
func (*CmdG) GetTokenInfo ¶
GetTokenInfo retrieves information about the current OAuth token.
func (*CmdG) GmailService ¶
GmailService returns the Gmail API service.
func (*CmdG) History ¶
func (c *CmdG) History(ctx context.Context, startID HistoryID, labelID string) ([]*gmail.History, HistoryID, error)
History returns history since startID (all pages).
func (*CmdG) LabelCache ¶
LabelCache returns the label fro the cache, or nil if not found.
func (*CmdG) ListDrafts ¶
ListDrafts lists all drafts.
func (*CmdG) ListMessages ¶
ListMessages lists messages in a given label or query, with optional page token.
func (*CmdG) LoadContacts ¶
LoadContacts reads all contacts from the cloud.
func (*CmdG) LoadLabels ¶
LoadLabels batch loads all labels into the cache.
func (*CmdG) LoadSettings ¶
LoadSettings loads settings from app specific folder on Google Drive.
func (*CmdG) MessageCache ¶
MessageCache returns the message from the cache, or nil if not found.
func (*CmdG) MoreHistory ¶
MoreHistory returns if stuff happened since start ID.
func (*CmdG) SaveSettings ¶
SaveSettings saves settings to app specific folder on Google Drive.
func (*CmdG) SendParts ¶
func (c *CmdG) SendParts(ctx context.Context, threadID ThreadID, mp string, head mail.Header, parts []*Part) error
SendParts sends a multipart message. Args:
mp: multipart type. "mixed" is a typical type. head: Email header. parts: Email parts.
func (*CmdG) SetDefaultSender ¶
SetDefaultSender sets default sender, used if the user didn't enter a From line manually.
type Config ¶
type Config struct {
OAuth ConfigOAuth
}
Config is… hmm… this should probably be cleand up.
type ConfigOAuth ¶
type ConfigOAuth struct {
ClientID, ClientSecret, RefreshToken, AccessToken, APIKey string
}
ConfigOAuth contains the config for the oauth.
type Draft ¶
Draft is a draft.
func (*Draft) GetSubject ¶
GetSubject returns the draft subject.
type Label ¶
type Label struct {
ID string
Label string
Response *gmail.Label
// contains filtered or unexported fields
}
Label is a gmail label.
func (*Label) LabelColor ¶
LabelColor returns an ANSI escape to render this label's color.
func (*Label) LabelColorChar ¶
LabelColorChar returns a full string to render just one char wide label.
func (*Label) LabelString ¶
LabelString is the string of the label.
type Message ¶
Message is an email message.
func NewMessageWithResponse ¶
NewMessageWithResponse creates a new message from data already received from the gmail API.
func (*Message) AddLabelID ¶
AddLabelID adds a label to a message.
func (*Message) AddLabelIDLocal ¶
AddLabelIDLocal adds a local label to the local cache *only*. It'll be overwritten at next sync. It's used for faster UI response time on label adding.
func (*Message) Attachments ¶
func (msg *Message) Attachments(ctx context.Context) ([]*Attachment, error)
Attachments returns a list of attachments.
func (*Message) GetBodyHTML ¶
GetBodyHTML returns the message's HTML body.
func (*Message) GetDateHeader ¶
GetDateHeader returns the string that the Date header is set to.
func (*Message) GetLabelColors ¶
GetLabelColors returns two strings: Labels with just colors, and one with the label strings in those colors.
func (*Message) GetLabelsString ¶
GetLabelsString returns labels as a printable string. With colors, but without "UNREAD".
func (*Message) GetOriginalTime ¶
GetOriginalTime returns the timestamp as claimed by the headers in its original timezone.
func (*Message) GetReferences ¶
GetReferences returns a slice of references.
func (*Message) GetReplyTo ¶
GetReplyTo returns the address to use for replies as the `To` line.
func (*Message) GetReplyToAll ¶
GetReplyToAll returns both To and CC lines for reply-all.
func (*Message) GetSubject ¶
GetSubject returns the message subject.
func (*Message) GetTimeFmt ¶
GetTimeFmt returns a `time` format string appropriate for the age of the message.
func (*Message) GetUnpatchedBody ¶
GetUnpatchedBody returns the raw body, before fixups.
func (*Message) LocalLabels ¶
LocalLabels returns the label IDs, whatever they are. If we have not downloaded anything then empty list is returned.
func (*Message) ReloadLabels ¶
ReloadLabels reloads label data for the message.
func (*Message) RemoveLabelID ¶
RemoveLabelID removes a label.
func (*Message) RemoveLabelIDLocal ¶
RemoveLabelIDLocal removes a local label from the local cache *only*. It'll be overwritten at next sync. It's used for faster UI response time on label removing.
type Page ¶
type Page struct {
Label string
Query string
Messages []*Message
Response *gmail.ListMessagesResponse
// contains filtered or unexported fields
}
Page implements some pagination thingy. TODO: document better.
type Part ¶
type Part struct {
Contents string
Header textproto.MIMEHeader
}
Part is a part of a message. Contents and header.
func ParseUserMessage ¶
ParseUserMessage parses what's in the user's editor and turns into into a Part and message headers.
func (*Part) FullString ¶
FullString returns the "serialized" part.
type Settings ¶
type Settings struct {
Sender string `json:"sender,omitempty"`
}
Settings stores settings in the app specific folder on Google Drive.
type ThreadID ¶
type ThreadID string
ThreadID is IDs of threads.
var ( // Version is the app version as reported in RPCs. Version = "unspecified" // NewThread is the thread ID to use for new threads. NewThread ThreadID )
type TokenInfo ¶
type TokenInfo struct {
Email string `json:"email"`
EmailVerified bool `json:"email_verified"`
ExpiresIn int64 `json:"expires_in"`
Scope string `json:"scope"`
Scopes []string `json:"scopes"`
UserID string `json:"user_id"`
Audience string `json:"aud"`
IssuedTo string `json:"issued_to"`
AppName string `json:"app_name"`
}
TokenInfo contains information about the OAuth token.