Documentation
¶
Index ¶
- func ConfigDir() string
- func ConfigExists() bool
- func ConfigPath() string
- func DefaultIconBytes() []byte
- func DownloadAsset(ctx context.Context, client *http.Client, downloadURL string, destPath string, ...) error
- func GetStatusIcon(s Status) fyne.Resource
- func IsUpdateAvailable(currentVer, latestTag string) (available bool, isDev bool)
- func LogDir() string
- func SaveConfig(cfg TrayConfig) error
- func ShowAbout(fyneApp fyne.App) fyne.Window
- func ShowUpdateWindow(fyneApp fyne.App, checker UpdateChecker, opts ...UpdateWindowOption) fyne.Window
- type App
- type ConnectionManager
- func (cm *ConnectionManager) Connect() error
- func (cm *ConnectionManager) Disconnect()
- func (cm *ConnectionManager) Events() <-chan event.Event
- func (cm *ConnectionManager) IsConnected() bool
- func (cm *ConnectionManager) Reconnect() error
- func (cm *ConnectionManager) SetAddress(address string)
- func (cm *ConnectionManager) SetPort(port uint)
- type ConnectionOption
- type EventClient
- type EventClientOption
- type GitHubUpdateChecker
- type ReleaseAsset
- type ReleaseInfo
- type Status
- type StatusTracker
- type TrayConfig
- type UpdateChecker
- type UpdateWindowOption
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ConfigDir ¶
func ConfigDir() string
ConfigDir returns the platform-specific directory for storing configuration files. It can be overridden by the ADDER_TRAY_CONFIG_DIR environment variable.
func ConfigExists ¶
func ConfigExists() bool
ConfigExists reports whether the configuration file exists on disk.
func ConfigPath ¶
func ConfigPath() string
ConfigPath returns the full path to the tray configuration file.
func DefaultIconBytes ¶ added in v0.40.0
func DefaultIconBytes() []byte
DefaultIconBytes returns the raw bytes for the default gray icon.
func DownloadAsset ¶ added in v0.45.0
func DownloadAsset( ctx context.Context, client *http.Client, downloadURL string, destPath string, expectedDigest string, progress func(downloaded, total int64), ) error
DownloadAsset downloads a release asset to destPath with progress reporting and checksum integrity verification.
func GetStatusIcon ¶ added in v0.40.0
GetStatusIcon returns a fyne.Resource with the branded logo filtered by status.
func IsUpdateAvailable ¶ added in v0.45.0
IsUpdateAvailable compares the current version string against the latest release tag. It returns whether an update is available and whether the running binary is an unversioned/development build.
func LogDir ¶
func LogDir() string
LogDir returns the platform-specific directory for storing log files. It can be overridden by the ADDER_TRAY_LOG_DIR environment variable.
func SaveConfig ¶
func SaveConfig(cfg TrayConfig) error
SaveConfig writes the tray configuration to disk, creating the config directory if necessary.
func ShowAbout ¶ added in v0.45.0
ShowAbout creates and displays the About dialog window showing the current release version, description, and project links.
func ShowUpdateWindow ¶ added in v0.45.0
func ShowUpdateWindow( fyneApp fyne.App, checker UpdateChecker, opts ...UpdateWindowOption, ) fyne.Window
ShowUpdateWindow displays a Sparkle-style update checking window.
Types ¶
type App ¶
type App struct {
// contains filtered or unexported fields
}
App holds references to all major components of the tray application.
func (*App) Config ¶ added in v0.40.0
func (a *App) Config() TrayConfig
Config returns a consistent snapshot of the current tray configuration. It is safe to call from any goroutine.
type ConnectionManager ¶ added in v0.40.0
type ConnectionManager struct {
// contains filtered or unexported fields
}
ConnectionManager manages the EventClient WS connection to adder's API. It replaces the old ProcessManager — the tray no longer manages adder as a subprocess but connects to it as an API client.
func NewConnectionManager ¶ added in v0.40.0
func NewConnectionManager(opts ...ConnectionOption) *ConnectionManager
NewConnectionManager creates a ConnectionManager with the given options.
func (*ConnectionManager) Connect ¶ added in v0.40.0
func (cm *ConnectionManager) Connect() error
Connect creates and starts an EventClient that connects to adder's /events WebSocket endpoint. Returns an error if already connected.
func (*ConnectionManager) Disconnect ¶ added in v0.40.0
func (cm *ConnectionManager) Disconnect()
Disconnect stops the EventClient and cleans up.
func (*ConnectionManager) Events ¶ added in v0.40.0
func (cm *ConnectionManager) Events() <-chan event.Event
Events returns a read-only channel of events received from adder.
func (*ConnectionManager) IsConnected ¶ added in v0.40.0
func (cm *ConnectionManager) IsConnected() bool
IsConnected reports whether the EventClient is actively connected.
func (*ConnectionManager) Reconnect ¶ added in v0.40.0
func (cm *ConnectionManager) Reconnect() error
Reconnect atomically disconnects and reconnects under a single lock acquisition, so concurrent Connect/Disconnect/Reconnect callers cannot interleave and leave the manager in an inconsistent state (e.g., Reconnect reporting "already connected" because another goroutine raced in between the inner Disconnect and Connect).
func (*ConnectionManager) SetAddress ¶ added in v0.40.0
func (cm *ConnectionManager) SetAddress(address string)
SetAddress updates the adder API address for future connections.
func (*ConnectionManager) SetPort ¶ added in v0.40.0
func (cm *ConnectionManager) SetPort(port uint)
SetPort updates the adder API port for future connections.
type ConnectionOption ¶ added in v0.40.0
type ConnectionOption func(*ConnectionManager)
ConnectionOption is a functional option for ConnectionManager.
func WithConnectionAddress ¶ added in v0.40.0
func WithConnectionAddress(address string) ConnectionOption
WithConnectionAddress sets the adder API address.
func WithConnectionPort ¶ added in v0.40.0
func WithConnectionPort(port uint) ConnectionOption
WithConnectionPort sets the adder API port.
func WithConnectionStatusTracker ¶ added in v0.40.0
func WithConnectionStatusTracker(t *StatusTracker) ConnectionOption
WithConnectionStatusTracker sets a StatusTracker that the manager updates as the connection state changes.
type EventClient ¶ added in v0.39.0
type EventClient struct {
// contains filtered or unexported fields
}
EventClient connects to adder's /events WebSocket endpoint and delivers parsed events on a channel. It reconnects automatically with exponential backoff when the connection drops.
func NewEventClient ¶ added in v0.39.0
func NewEventClient( address string, port uint, opts ...EventClientOption, ) *EventClient
NewEventClient creates an EventClient that will connect to the given address and port.
func (*EventClient) Events ¶ added in v0.39.0
func (c *EventClient) Events() <-chan event.Event
Events returns a read-only channel of events received from the server.
func (*EventClient) Start ¶ added in v0.39.0
func (c *EventClient) Start() error
Start begins the background connection loop. Returns an error if already started.
func (*EventClient) Stop ¶ added in v0.39.0
func (c *EventClient) Stop()
Stop closes the connection and stops reconnection. It is safe to call multiple times or without a prior Start.
type EventClientOption ¶ added in v0.39.0
type EventClientOption func(*EventClient)
EventClientOption is a functional option for EventClient.
func WithEventStatusTracker ¶ added in v0.39.0
func WithEventStatusTracker(t *StatusTracker) EventClientOption
WithEventStatusTracker sets a StatusTracker that the client updates as its connection state changes. A nil tracker is ignored.
func WithEventTypes ¶ added in v0.39.0
func WithEventTypes(types []string) EventClientOption
WithEventTypes sets the event types to subscribe to. The types are sent as a query parameter on the WS URL for server-side filtering.
type GitHubUpdateChecker ¶ added in v0.45.0
GitHubUpdateChecker queries GitHub releases API for latest published release.
func NewGitHubUpdateChecker ¶ added in v0.45.0
func NewGitHubUpdateChecker(repo string) *GitHubUpdateChecker
NewGitHubUpdateChecker returns a configured GitHubUpdateChecker.
func (*GitHubUpdateChecker) CheckLatestRelease ¶ added in v0.45.0
func (c *GitHubUpdateChecker) CheckLatestRelease( ctx context.Context, ) (*ReleaseInfo, error)
CheckLatestRelease fetches the latest release from GitHub.
type ReleaseAsset ¶ added in v0.45.0
type ReleaseAsset struct {
Name string `json:"name"`
BrowserDownloadURL string `json:"browser_download_url"`
Size int64 `json:"size"`
Digest string `json:"digest"`
}
ReleaseAsset represents an artifact asset attached to a GitHub release.
func FindAssetForPlatform ¶ added in v0.45.0
func FindAssetForPlatform( assets []ReleaseAsset, goos, goarch string, ) *ReleaseAsset
FindAssetForPlatform matches a release installer asset for the target OS and architecture. Only platform package installers (.pkg on darwin, .msi on windows) are returned. Platforms that only distribute tarballs (Linux, FreeBSD) return nil so the application directs the user to the release page.
type ReleaseInfo ¶ added in v0.45.0
type ReleaseInfo struct {
TagName string `json:"tag_name"`
Name string `json:"name"`
HTMLURL string `json:"html_url"`
Body string `json:"body"`
PublishedAt string `json:"published_at"`
Assets []ReleaseAsset `json:"assets"`
}
ReleaseInfo represents the GitHub release payload.
type Status ¶ added in v0.39.0
type Status int
Status represents the connection status of the tray application.
type StatusTracker ¶ added in v0.39.0
type StatusTracker struct {
// contains filtered or unexported fields
}
StatusTracker provides thread-safe status tracking with change notification. It notifies an optional observer when the status changes. Transitions are delivered to the observer by a single long-lived worker goroutine, so the observer always sees them in the order they occurred (rapid flips can no longer race).
func NewStatusTracker ¶ added in v0.39.0
func NewStatusTracker() *StatusTracker
NewStatusTracker creates a StatusTracker with initial status StatusStopped and starts its ordered-delivery worker.
func (*StatusTracker) OnChange ¶ added in v0.39.0
func (t *StatusTracker) OnChange(fn func(Status))
OnChange registers a callback that is invoked whenever the status changes. It is immediately called once with the current status synchronously. Only one observer can be registered at a time.
func (*StatusTracker) Set ¶ added in v0.39.0
func (t *StatusTracker) Set(s Status)
Set updates the status and enqueues an ordered observer notification if the status changed.
func (*StatusTracker) Status ¶ added in v0.39.0
func (t *StatusTracker) Status() Status
Status returns the current status.
type TrayConfig ¶
type TrayConfig = setup.TrayConfig
TrayConfig is an alias for setup.TrayConfig to maintain backward compatibility.
func DefaultConfig ¶
func DefaultConfig() TrayConfig
DefaultConfig returns a TrayConfig with sensible defaults.
func LoadConfig ¶
func LoadConfig() (TrayConfig, error)
LoadConfig reads the tray configuration from disk. If the file does not exist, it returns the default configuration.
type UpdateChecker ¶ added in v0.45.0
type UpdateChecker interface {
CheckLatestRelease(ctx context.Context) (*ReleaseInfo, error)
}
UpdateChecker retrieves latest release metadata from a remote source.
type UpdateWindowOption ¶ added in v0.45.0
type UpdateWindowOption func(*updateWindowConfig)
UpdateWindowOption configures optional behavior for ShowUpdateWindow.
func WithCheckWeekly ¶ added in v0.45.0
func WithCheckWeekly(initial bool, onToggle func(bool)) UpdateWindowOption
WithCheckWeekly sets the initial state and callback for the weekly update check preference in the update window.
func WithOnClosed ¶ added in v0.45.0
func WithOnClosed(fn func()) UpdateWindowOption
WithOnClosed sets the callback invoked after the update window is closed.
func WithOnRelaunch ¶ added in v0.45.0
func WithOnRelaunch(fn func()) UpdateWindowOption
WithOnRelaunch sets the callback invoked when the user confirms relaunching after an update has downloaded and the installer has launched.
func WithOnSkip ¶ added in v0.45.0
func WithOnSkip(fn func(version string)) UpdateWindowOption
WithOnSkip sets the callback invoked when the user chooses to skip a release.
Source Files
¶
Directories
¶
| Path | Synopsis |
|---|---|
|
Package notifications implements the tray notification engine: it consumes events from the tray's ConnectionManager, evaluates them against a rule set derived from the user's setup plan, and emits notification Requests.
|
Package notifications implements the tray notification engine: it consumes events from the tray's ConnectionManager, evaluates them against a rule set derived from the user's setup plan, and emits notification Requests. |