daemonrpc

package
v0.35.0 Latest Latest
Warning

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

Go to latest
Published: Apr 26, 2026 License: MIT Imports: 7 Imported by: 0

Documentation

Index

Constants

View Source
const (
	ErrCodeParse      = -32700
	ErrCodeInvalidReq = -32600
	ErrCodeNotFound   = -32601
	ErrCodeInternal   = -32603
)

Standard error codes.

View Source
const (
	MethodPing            = "Ping"
	MethodGetStatus       = "GetStatus"
	MethodGetAccounts     = "GetAccounts"
	MethodReloadConfig    = "ReloadConfig"
	MethodFetchEmails     = "FetchEmails"
	MethodFetchEmailBody  = "FetchEmailBody"
	MethodSendEmail       = "SendEmail"
	MethodDeleteEmails    = "DeleteEmails"
	MethodArchiveEmails   = "ArchiveEmails"
	MethodMoveEmails      = "MoveEmails"
	MethodMarkRead        = "MarkRead"
	MethodFetchFolders    = "FetchFolders"
	MethodRefreshFolder   = "RefreshFolder"
	MethodSubscribe       = "Subscribe"
	MethodUnsubscribe     = "Unsubscribe"
	MethodSendRSVP        = "SendRSVP"
	MethodGetCachedEmails = "GetCachedEmails"
	MethodGetCachedBody   = "GetCachedBody"
	MethodExportContacts  = "ExportContacts"
)

RPC method names.

View Source
const (
	EventNewMail        = "NewMail"
	EventSyncStarted    = "SyncStarted"
	EventSyncComplete   = "SyncComplete"
	EventSyncError      = "SyncError"
	EventEmailsUpdated  = "EmailsUpdated"
	EventConfigReloaded = "ConfigReloaded"
)

Event type names.

Variables

This section is empty.

Functions

func EnsureRuntimeDir

func EnsureRuntimeDir() error

EnsureRuntimeDir creates the runtime directory if it doesn't exist.

func PIDPath

func PIDPath() string

PIDPath returns the path to the daemon's PID file.

func SocketPath

func SocketPath() string

SocketPath returns the path to the daemon's Unix domain socket.

Types

type AccountInfo

type AccountInfo struct {
	ID       string `json:"id"`
	Name     string `json:"name"`
	Email    string `json:"email"`
	Protocol string `json:"protocol"`
}

type ArchiveEmailsParams

type ArchiveEmailsParams struct {
	AccountID string   `json:"account_id"`
	Folder    string   `json:"folder"`
	UIDs      []uint32 `json:"uids"`
}

type AttachmentInfo

type AttachmentInfo struct {
	Filename         string `json:"filename"`
	PartID           string `json:"part_id"`
	Encoding         string `json:"encoding"`
	MIMEType         string `json:"mime_type"`
	IsCalendarInvite bool   `json:"is_calendar_invite,omitempty"`
	CalendarData     []byte `json:"calendar_data,omitempty"`
}

type Conn

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

Conn wraps a net.Conn with newline-delimited JSON encoding/decoding.

func NewConn

func NewConn(c net.Conn) *Conn

NewConn wraps an existing network connection.

func (*Conn) Close

func (c *Conn) Close() error

Close closes the underlying connection.

func (*Conn) LocalAddr

func (c *Conn) LocalAddr() net.Addr

LocalAddr returns the local address of the connection.

func (*Conn) ReceiveMessage

func (c *Conn) ReceiveMessage() (Message, error)

ReceiveMessage reads and decodes the next JSON message, returning a discriminated Message (Request, Response, or Event).

func (*Conn) RemoteAddr

func (c *Conn) RemoteAddr() net.Addr

RemoteAddr returns the remote address of the connection.

func (*Conn) Send

func (c *Conn) Send(v interface{}) error

Send writes a JSON-encoded message followed by a newline. Thread-safe.

func (*Conn) SendError

func (c *Conn) SendError(id uint64, code int, message string) error

SendError sends an error response.

func (*Conn) SendEvent

func (c *Conn) SendEvent(eventType string, data interface{}) error

SendEvent sends a push event to the client.

func (*Conn) SendResponse

func (c *Conn) SendResponse(id uint64, result interface{}) error

SendResponse sends a successful response with the given result.

type DeleteEmailsParams

type DeleteEmailsParams struct {
	AccountID string   `json:"account_id"`
	Folder    string   `json:"folder"`
	UIDs      []uint32 `json:"uids"`
}

type Error

type Error struct {
	Code    int    `json:"code"`
	Message string `json:"message"`
}

Error returned in a Response.

func (*Error) Error

func (e *Error) Error() string

type Event

type Event struct {
	Type string          `json:"type"`
	Data json.RawMessage `json:"data,omitempty"`
}

Event pushed from daemon to subscribed clients. No ID field.

type ExportContactsParams

type ExportContactsParams struct {
	Format string `json:"format"` // "json" or "csv"
}

type FetchEmailBodyParams

type FetchEmailBodyParams struct {
	AccountID string `json:"account_id"`
	Folder    string `json:"folder"`
	UID       uint32 `json:"uid"`
}

type FetchEmailBodyResult

type FetchEmailBodyResult struct {
	Body        string           `json:"body"`
	Attachments []AttachmentInfo `json:"attachments"`
}

type FetchEmailsParams

type FetchEmailsParams struct {
	AccountID string `json:"account_id"`
	Folder    string `json:"folder"`
	Limit     uint32 `json:"limit"`
	Offset    uint32 `json:"offset"`
}

type FetchFoldersParams

type FetchFoldersParams struct {
	AccountID string `json:"account_id"`
}

type GetCachedBodyParams

type GetCachedBodyParams struct {
	Folder    string `json:"folder"`
	UID       uint32 `json:"uid"`
	AccountID string `json:"account_id"`
}

type GetCachedEmailsParams

type GetCachedEmailsParams struct {
	Folder string `json:"folder"`
}

type MarkReadParams

type MarkReadParams struct {
	AccountID string   `json:"account_id"`
	Folder    string   `json:"folder"`
	UIDs      []uint32 `json:"uids"`
	Read      bool     `json:"read"`
}

type Message

type Message struct {
	Request  *Request
	Response *Response
	Event    *Event
}

Message is a union type for wire decoding. Exactly one of the fields will be populated based on the presence of "id" and "type".

func DecodeMessage

func DecodeMessage(raw json.RawMessage) (Message, error)

Discriminate: if "type" present → Event, if "method" present → Request, else → Response.

type MoveEmailsParams

type MoveEmailsParams struct {
	AccountID    string   `json:"account_id"`
	UIDs         []uint32 `json:"uids"`
	SourceFolder string   `json:"source_folder"`
	DestFolder   string   `json:"dest_folder"`
}

type NewMailEvent

type NewMailEvent struct {
	AccountID string `json:"account_id"`
	Folder    string `json:"folder"`
}

type PingResult

type PingResult struct {
	Pong bool `json:"pong"`
}

type RefreshFolderParams

type RefreshFolderParams struct {
	AccountID string `json:"account_id"`
	Folder    string `json:"folder"`
}

type Request

type Request struct {
	ID     uint64          `json:"id"`
	Method string          `json:"method"`
	Params json.RawMessage `json:"params,omitempty"`
}

Request from client to daemon. Has an ID for matching responses.

type Response

type Response struct {
	ID     uint64          `json:"id"`
	Result json.RawMessage `json:"result,omitempty"`
	Error  *Error          `json:"error,omitempty"`
}

Response from daemon to client. Matched to request by ID.

type SendEmailParams

type SendEmailParams struct {
	AccountID    string            `json:"account_id"`
	To           []string          `json:"to"`
	Cc           []string          `json:"cc,omitempty"`
	Bcc          []string          `json:"bcc,omitempty"`
	Subject      string            `json:"subject"`
	Body         string            `json:"body"`
	HTMLBody     string            `json:"html_body,omitempty"`
	Attachments  map[string][]byte `json:"attachments,omitempty"`
	InReplyTo    string            `json:"in_reply_to,omitempty"`
	References   []string          `json:"references,omitempty"`
	SignSMIME    bool              `json:"sign_smime,omitempty"`
	EncryptSMIME bool              `json:"encrypt_smime,omitempty"`
	SignPGP      bool              `json:"sign_pgp,omitempty"`
	EncryptPGP   bool              `json:"encrypt_pgp,omitempty"`
}

type SendRSVPParams

type SendRSVPParams struct {
	AccountID   string   `json:"account_id"`
	OriginalICS []byte   `json:"original_ics"`
	Response    string   `json:"response"`
	InReplyTo   string   `json:"in_reply_to,omitempty"`
	References  []string `json:"references,omitempty"`
}

type StatusResult

type StatusResult struct {
	Running  bool     `json:"running"`
	Uptime   int64    `json:"uptime_seconds"`
	Accounts []string `json:"accounts"`
	PID      int      `json:"pid"`
}

type SubscribeParams

type SubscribeParams struct {
	AccountID string `json:"account_id"`
	Folder    string `json:"folder"`
}

type SyncCompleteEvent

type SyncCompleteEvent struct {
	AccountID  string `json:"account_id"`
	Folder     string `json:"folder"`
	EmailCount int    `json:"email_count"`
}

type SyncErrorEvent

type SyncErrorEvent struct {
	AccountID string `json:"account_id"`
	Folder    string `json:"folder"`
	Error     string `json:"error"`
}

type SyncStartedEvent

type SyncStartedEvent struct {
	AccountID string `json:"account_id"`
	Folder    string `json:"folder"`
}

type UnsubscribeParams

type UnsubscribeParams struct {
	AccountID string `json:"account_id"`
	Folder    string `json:"folder"`
}

Jump to

Keyboard shortcuts

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