Documentation ¶
Overview ¶
Package grail implements a GUI email client.
Index ¶
- Constants
- Variables
- func FilenameBase32(s string) string
- type App
- func (a *App) AppBar(tb *gi.Toolbar)
- func (a *App) AppStyles()
- func (a *App) Auth() error
- func (a *App) CacheMessages() error
- func (a *App) CacheMessagesForAccount(email string) error
- func (a *App) CacheMessagesForMailbox(c *imapclient.Client, email string, mailbox string) error
- func (a *App) Compose()
- func (a *App) ConfigWidget()
- func (a *App) GetMail() error
- func (a *App) Init()
- func (t *App) KiType() *gti.Type
- func (a *App) MoveMessage(mailbox string) error
- func (t *App) New() ki.Ki
- func (a *App) OnInit()
- func (a *App) OpenPrefs() error
- func (a *App) SavePrefs() error
- func (a *App) SendMessage() error
- func (t *App) SetAuthClient(v map[string]sasl.Client) *App
- func (t *App) SetAuthToken(v map[string]*oauth2.Token) *App
- func (t *App) SetCache(v map[string]map[string][]*CacheData) *App
- func (t *App) SetClass(v string) *App
- func (t *App) SetComposeMessage(v *Message) *App
- func (t *App) SetCurEmail(v string) *App
- func (t *App) SetCurMailbox(v string) *App
- func (t *App) SetCustomContextMenu(v func(m *gi.Scene)) *App
- func (t *App) SetImapclient(v map[string]*imapclient.Client) *App
- func (t *App) SetPriorityEvents(v []events.Types) *App
- func (t *App) SetReadMessage(v *CacheData) *App
- func (t *App) SetStackTop(v int) *App
- func (t *App) SetStripes(v gi.Stripes) *App
- func (t *App) SetTooltip(v string) *App
- func (a *App) SignIn() (string, error)
- func (a *App) UpdateMessageList()
- func (a *App) UpdateReadMessage() error
- type CacheData
- type Message
- type Preferences
Constants ¶
const ( // Version is the version of this package being used Version = "v0.0.12" // GitCommit is the commit just before the latest version commit GitCommit = "f2cf6a9" // VersionDate is the date-time of the latest version commit in UTC (in the format 'YYYY-MM-DD HH:MM', which is the Go format '2006-01-02 15:04') VersionDate = "2023-12-26 23:43" )
Variables ¶
var AppType = gti.AddType(>i.Type{ Name: "goki.dev/grail/grail.App", ShortName: "grail.App", IDName: "app", Doc: "App is an email client app.", Directives: gti.Directives{}, Fields: ordmap.Make([]ordmap.KeyVal[string, *gti.Field]{ {"AuthToken", >i.Field{Name: "AuthToken", Type: "map[string]*golang.org/x/oauth2.Token", LocalType: "map[string]*oauth2.Token", Doc: "AuthToken contains the [oauth2.Token] for each account.", Directives: gti.Directives{}, Tag: ""}}, {"AuthClient", >i.Field{Name: "AuthClient", Type: "map[string]github.com/emersion/go-sasl.Client", LocalType: "map[string]sasl.Client", Doc: "AuthClient contains the [sasl.Client] authentication for sending messages for each account.", Directives: gti.Directives{}, Tag: ""}}, {"IMAPClient", >i.Field{Name: "IMAPClient", Type: "map[string]*github.com/emersion/go-imap/v2/imapclient.Client", LocalType: "map[string]*imapclient.Client", Doc: "IMAPCLient contains the imap clients for each account.", Directives: gti.Directives{}, Tag: ""}}, {"ComposeMessage", >i.Field{Name: "ComposeMessage", Type: "*goki.dev/grail/grail.Message", LocalType: "*Message", Doc: "ComposeMessage is the current message we are editing", Directives: gti.Directives{}, Tag: ""}}, {"Cache", >i.Field{Name: "Cache", Type: "map[string]map[string][]*goki.dev/grail/grail.CacheData", LocalType: "map[string]map[string][]*CacheData", Doc: "Cache contains the cache data, keyed by account and then mailbox.", Directives: gti.Directives{}, Tag: ""}}, {"ReadMessage", >i.Field{Name: "ReadMessage", Type: "*goki.dev/grail/grail.CacheData", LocalType: "*CacheData", Doc: "ReadMessage is the current message we are reading", Directives: gti.Directives{}, Tag: ""}}, {"CurEmail", >i.Field{Name: "CurEmail", Type: "string", LocalType: "string", Doc: "The current email account", Directives: gti.Directives{}, Tag: ""}}, {"CurMailbox", >i.Field{Name: "CurMailbox", Type: "string", LocalType: "string", Doc: "The current mailbox", Directives: gti.Directives{}, Tag: ""}}, }), Embeds: ordmap.Make([]ordmap.KeyVal[string, *gti.Field]{ {"Frame", >i.Field{Name: "Frame", Type: "goki.dev/gi/v2/gi.Frame", LocalType: "gi.Frame", Doc: "", Directives: gti.Directives{}, Tag: ""}}, }), Methods: ordmap.Make([]ordmap.KeyVal[string, *gti.Method]{ {"Compose", >i.Method{Name: "Compose", Doc: "Compose pulls up a dialog to send a new message", Directives: gti.Directives{ >i.Directive{Tool: "gti", Directive: "add", Args: []string{}}, }, Args: ordmap.Make([]ordmap.KeyVal[string, *gti.Field]{}), Returns: ordmap.Make([]ordmap.KeyVal[string, *gti.Field]{})}}, {"SendMessage", >i.Method{Name: "SendMessage", Doc: "SendMessage sends the current message", Directives: gti.Directives{ >i.Directive{Tool: "gti", Directive: "add", Args: []string{}}, }, Args: ordmap.Make([]ordmap.KeyVal[string, *gti.Field]{}), Returns: ordmap.Make([]ordmap.KeyVal[string, *gti.Field]{ {"error", >i.Field{Name: "error", Type: "error", LocalType: "error", Doc: "", Directives: gti.Directives{}, Tag: ""}}, })}}, {"MoveMessage", >i.Method{Name: "MoveMessage", Doc: "MoveMessage moves the current message to the given mailbox.", Directives: gti.Directives{ >i.Directive{Tool: "gti", Directive: "add", Args: []string{}}, }, Args: ordmap.Make([]ordmap.KeyVal[string, *gti.Field]{ {"mailbox", >i.Field{Name: "mailbox", Type: "string", LocalType: "string", Doc: "", Directives: gti.Directives{}, Tag: ""}}, }), Returns: ordmap.Make([]ordmap.KeyVal[string, *gti.Field]{ {"error", >i.Field{Name: "error", Type: "error", LocalType: "error", Doc: "", Directives: gti.Directives{}, Tag: ""}}, })}}, }), Instance: &App{}, })
AppType is the gti.Type for App
var Prefs = &Preferences{}
Prefs is the global instance of Preferences, loaded on startup.
Functions ¶
func FilenameBase32 ¶ added in v0.0.2
FilenameBase32 converts the given string to a filename-safe base32 version.
Types ¶
type App ¶
type App struct { gi.Frame // AuthToken contains the [oauth2.Token] for each account. AuthToken map[string]*oauth2.Token // AuthClient contains the [sasl.Client] authentication for sending messages for each account. AuthClient map[string]sasl.Client // IMAPCLient contains the imap clients for each account. IMAPClient map[string]*imapclient.Client // ComposeMessage is the current message we are editing ComposeMessage *Message // Cache contains the cache data, keyed by account and then mailbox. Cache map[string]map[string][]*CacheData // ReadMessage is the current message we are reading ReadMessage *CacheData // The current email account CurEmail string // The current mailbox CurMailbox string }
App is an email client app.
func NewApp ¶
NewApp adds a new App with the given name to the given parent. If the name is unspecified, it defaults to the ID (kebab-case) name of the type, plus the ki.Ki.NumLifetimeChildren of the given parent.
func (*App) Auth ¶
Auth authorizes access to the user's mail and sets [App.AuthClient]. If the user does not already have a saved auth token, it calls [SignIn].
func (*App) CacheMessages ¶ added in v0.0.2
CacheMessages caches all of the messages from the server that have not already been cached. It caches them using maildir in the app's prefs directory.
func (*App) CacheMessagesForAccount ¶ added in v0.0.2
CacheMessages caches all of the messages from the server that have not already been cached for the given email account. It caches them using maildir in the app's prefs directory.
func (*App) CacheMessagesForMailbox ¶ added in v0.0.2
CacheMessagesForMailbox caches all of the messages from the server that have not already been cached for the given email account and mailbox. It caches them using maildir in the app's prefs directory.
func (*App) ConfigWidget ¶
func (a *App) ConfigWidget()
func (*App) MoveMessage ¶ added in v0.0.2
MoveMessage moves the current message to the given mailbox.
func (*App) SetAuthClient ¶ added in v0.0.2
SetAuthClient sets the [App.AuthClient]: AuthClient contains the sasl.Client authentication for sending messages for each account.
func (*App) SetAuthToken ¶ added in v0.0.2
SetAuthToken sets the [App.AuthToken]: AuthToken contains the oauth2.Token for each account.
func (*App) SetCache ¶ added in v0.0.2
SetCache sets the [App.Cache]: Cache contains the cache data, keyed by account and then mailbox.
func (*App) SetComposeMessage ¶
SetComposeMessage sets the [App.ComposeMessage]: ComposeMessage is the current message we are editing
func (*App) SetCurEmail ¶ added in v0.0.2
SetCurEmail sets the [App.CurEmail]: The current email account
func (*App) SetCurMailbox ¶ added in v0.0.2
SetCurMailbox sets the [App.CurMailbox]: The current mailbox
func (*App) SetCustomContextMenu ¶
SetCustomContextMenu sets the [App.CustomContextMenu]
func (*App) SetImapclient ¶ added in v0.0.2
func (t *App) SetImapclient(v map[string]*imapclient.Client) *App
SetImapclient sets the [App.IMAPClient]: IMAPCLient contains the imap clients for each account.
func (*App) SetPriorityEvents ¶ added in v0.0.2
SetPriorityEvents sets the [App.PriorityEvents]
func (*App) SetReadMessage ¶
SetReadMessage sets the [App.ReadMessage]: ReadMessage is the current message we are reading
func (*App) SetStripes ¶
SetStripes sets the [App.Stripes]
func (*App) SignIn ¶ added in v0.0.2
SignIn displays a dialog for the user to sign in with the platform of their choice. It returns the user's email address.
func (*App) UpdateMessageList ¶ added in v0.0.2
func (a *App) UpdateMessageList()
UpdateMessageList updates the message list from [App.Cache].
func (*App) UpdateReadMessage ¶ added in v0.0.2
UpdateReadMessage updates the view of the message currently being read.
type CacheData ¶ added in v0.0.2
CacheData contains the data stored for a cached message in the cached messages file. It contains basic information about the message so that it can be displayed in the mail list in the GUI.
type Message ¶
type Message struct { From []*mail.Address `view:"inline"` To []*mail.Address `view:"inline"` Subject string // only for sending Body string `view:"text-editor" viewif:"BodyReader==nil"` // only for receiving BodyReader imap.LiteralReader `view:"-"` }
Message contains the relevant information for an email message.
type Preferences ¶ added in v0.0.2
type Preferences struct { // Accounts are the email accounts the user is signed into. Accounts []string }
Preferences are the preferences that control grail.