grail

package
v0.0.12 Latest Latest
Warning

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

Go to latest
Published: Dec 26, 2023 License: BSD-3-Clause Imports: 35 Imported by: 0

Documentation

Overview

Package grail implements a GUI email client.

Index

Constants

View Source
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

View Source
var AppType = gti.AddType(&gti.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", &gti.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", &gti.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", &gti.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", &gti.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", &gti.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", &gti.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", &gti.Field{Name: "CurEmail", Type: "string", LocalType: "string", Doc: "The current email account", Directives: gti.Directives{}, Tag: ""}},
		{"CurMailbox", &gti.Field{Name: "CurMailbox", Type: "string", LocalType: "string", Doc: "The current mailbox", Directives: gti.Directives{}, Tag: ""}},
	}),
	Embeds: ordmap.Make([]ordmap.KeyVal[string, *gti.Field]{
		{"Frame", &gti.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", &gti.Method{Name: "Compose", Doc: "Compose pulls up a dialog to send a new message", Directives: gti.Directives{
			&gti.Directive{Tool: "gti", Directive: "add", Args: []string{}},
		}, Args: ordmap.Make([]ordmap.KeyVal[string, *gti.Field]{}), Returns: ordmap.Make([]ordmap.KeyVal[string, *gti.Field]{})}},
		{"SendMessage", &gti.Method{Name: "SendMessage", Doc: "SendMessage sends the current message", Directives: gti.Directives{
			&gti.Directive{Tool: "gti", Directive: "add", Args: []string{}},
		}, Args: ordmap.Make([]ordmap.KeyVal[string, *gti.Field]{}), Returns: ordmap.Make([]ordmap.KeyVal[string, *gti.Field]{
			{"error", &gti.Field{Name: "error", Type: "error", LocalType: "error", Doc: "", Directives: gti.Directives{}, Tag: ""}},
		})}},
		{"MoveMessage", &gti.Method{Name: "MoveMessage", Doc: "MoveMessage moves the current message to the given mailbox.", Directives: gti.Directives{
			&gti.Directive{Tool: "gti", Directive: "add", Args: []string{}},
		}, Args: ordmap.Make([]ordmap.KeyVal[string, *gti.Field]{
			{"mailbox", &gti.Field{Name: "mailbox", Type: "string", LocalType: "string", Doc: "", Directives: gti.Directives{}, Tag: ""}},
		}), Returns: ordmap.Make([]ordmap.KeyVal[string, *gti.Field]{
			{"error", &gti.Field{Name: "error", Type: "error", LocalType: "error", Doc: "", Directives: gti.Directives{}, Tag: ""}},
		})}},
	}),
	Instance: &App{},
})

AppType is the gti.Type for App

View Source
var Prefs = &Preferences{}

Prefs is the global instance of Preferences, loaded on startup.

Functions

func FilenameBase32 added in v0.0.2

func FilenameBase32(s string) string

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

func NewApp(par ki.Ki, name ...string) *App

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) AppBar added in v0.0.5

func (a *App) AppBar(tb *gi.Toolbar)

func (*App) AppStyles added in v0.0.2

func (a *App) AppStyles()

func (*App) Auth

func (a *App) Auth() error

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

func (a *App) CacheMessages() error

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

func (a *App) CacheMessagesForAccount(email string) error

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

func (a *App) CacheMessagesForMailbox(c *imapclient.Client, email string, mailbox string) error

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) Compose

func (a *App) Compose()

Compose pulls up a dialog to send a new message

func (*App) ConfigWidget

func (a *App) ConfigWidget()

func (*App) GetMail

func (a *App) GetMail() error

func (*App) Init added in v0.0.5

func (a *App) Init()

Init initializes the grail preferences.

func (*App) KiType

func (t *App) KiType() *gti.Type

KiType returns the *gti.Type of App

func (*App) MoveMessage added in v0.0.2

func (a *App) MoveMessage(mailbox string) error

MoveMessage moves the current message to the given mailbox.

func (*App) New

func (t *App) New() ki.Ki

New returns a new *App value

func (*App) OnInit added in v0.0.2

func (a *App) OnInit()

func (*App) OpenPrefs added in v0.0.5

func (a *App) OpenPrefs() error

OpenPrefs opens Prefs from the default location.

func (*App) SavePrefs added in v0.0.5

func (a *App) SavePrefs() error

SavePrefs saves Prefs to the default location.

func (*App) SendMessage

func (a *App) SendMessage() error

SendMessage sends the current message

func (*App) SetAuthClient added in v0.0.2

func (t *App) SetAuthClient(v map[string]sasl.Client) *App

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

func (t *App) SetAuthToken(v map[string]*oauth2.Token) *App

SetAuthToken sets the [App.AuthToken]: AuthToken contains the oauth2.Token for each account.

func (*App) SetCache added in v0.0.2

func (t *App) SetCache(v map[string]map[string][]*CacheData) *App

SetCache sets the [App.Cache]: Cache contains the cache data, keyed by account and then mailbox.

func (*App) SetClass

func (t *App) SetClass(v string) *App

SetClass sets the [App.Class]

func (*App) SetComposeMessage

func (t *App) SetComposeMessage(v *Message) *App

SetComposeMessage sets the [App.ComposeMessage]: ComposeMessage is the current message we are editing

func (*App) SetCurEmail added in v0.0.2

func (t *App) SetCurEmail(v string) *App

SetCurEmail sets the [App.CurEmail]: The current email account

func (*App) SetCurMailbox added in v0.0.2

func (t *App) SetCurMailbox(v string) *App

SetCurMailbox sets the [App.CurMailbox]: The current mailbox

func (*App) SetCustomContextMenu

func (t *App) SetCustomContextMenu(v func(m *gi.Scene)) *App

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

func (t *App) SetPriorityEvents(v []events.Types) *App

SetPriorityEvents sets the [App.PriorityEvents]

func (*App) SetReadMessage

func (t *App) SetReadMessage(v *CacheData) *App

SetReadMessage sets the [App.ReadMessage]: ReadMessage is the current message we are reading

func (*App) SetStackTop

func (t *App) SetStackTop(v int) *App

SetStackTop sets the [App.StackTop]

func (*App) SetStripes

func (t *App) SetStripes(v gi.Stripes) *App

SetStripes sets the [App.Stripes]

func (*App) SetTooltip

func (t *App) SetTooltip(v string) *App

SetTooltip sets the [App.Tooltip]

func (*App) SignIn added in v0.0.2

func (a *App) SignIn() (string, error)

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

func (a *App) UpdateReadMessage() error

UpdateReadMessage updates the view of the message currently being read.

type CacheData added in v0.0.2

type CacheData struct {
	imap.Envelope
	UID      uint32
	Filename string
}

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.

Jump to

Keyboard shortcuts

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