service

package
v0.0.0-...-6789dc4 Latest Latest
Warning

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

Go to latest
Published: Jul 30, 2021 License: GPL-3.0, GPL-3.0 Imports: 29 Imported by: 0

Documentation

Overview

package service implements the dbus-level service with which client applications are expected to interact.

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrNotConfigured  = errors.New("not configured")
	ErrAlreadyStarted = errors.New("already started")
	ErrBadArgCount    = errors.New("wrong number of arguments")
	ErrBadArgType     = errors.New("bad argument type")
	ErrBadJSON        = errors.New("bad json data")
	ErrAppIdMismatch  = errors.New("package must be prefix of app id")
)
View Source
var (
	ErrBadServer  = errors.New("bad server")
	ErrBadRequest = errors.New("bad request")
	ErrBadToken   = errors.New("bad token")
	ErrBadAuth    = errors.New("bad auth")
)
View Source
var (
	PostalServiceBusAddress = bus.Address{
		Interface: "com.lomiri.Postal",
		Path:      "/com/lomiri/Postal",
		Name:      "com.lomiri.Postal",
	}
)
View Source
var (
	PushServiceBusAddress = bus.Address{
		Interface: "com.lomiri.PushNotifications",
		Path:      "/com/lomiri/PushNotifications",
		Name:      "com.lomiri.PushNotifications",
	}
)
View Source
var (
	SystemUpdateUrl = "settings:///system/system-update"
)

Functions

This section is empty.

Types

type DBusService

type DBusService struct {
	Log logger.Logger
	Bus bus.Endpoint
	// contains filtered or unexported fields
}

func (*DBusService) IsRunning

func (svc *DBusService) IsRunning() bool

IsRunning() returns whether the service's state is StateRunning

func (*DBusService) Start

func (svc *DBusService) Start(dispatchMap bus.DispatchMap, busAddr bus.Address, init func() error) error

Start() dials the bus, grab the name, and listens for method calls.

func (*DBusService) Stop

func (svc *DBusService) Stop()

Stop() closes the bus and sets the state to StateFinished

type PostalService

type PostalService struct {
	DBusService

	HelperPool launch_helper.HelperPool

	// the endpoints are only exposed for testing from client
	// XXX: uncouple some more so this isn't necessary
	EmblemCounterEndp bus.Endpoint
	AccountsEndp      bus.Endpoint
	HapticEndp        bus.Endpoint
	NotificationsEndp bus.Endpoint
	GreeterEndp       bus.Endpoint
	WindowStackEndp   bus.Endpoint
	// presenters:
	Presenters []Presenter
	// contains filtered or unexported fields
}

PostalService is the dbus api

func NewPostalService

func NewPostalService(setup *PostalServiceSetup, log logger.Logger) *PostalService

NewPostalService() builds a new service and returns it.

func (*PostalService) GetMessageHandler

func (svc *PostalService) GetMessageHandler() messageHandler

GetMessageHandler() returns the (possibly nil) messaging handler callback

func (*PostalService) Post

func (svc *PostalService) Post(app *click.AppId, nid string, payload json.RawMessage)

Post() signals to an application over dbus that a notification has arrived. If nid is "" generate one.

func (*PostalService) SetMessageHandler

func (svc *PostalService) SetMessageHandler(callback messageHandler)

SetMessageHandler() sets the message-handling callback

func (*PostalService) Start

func (svc *PostalService) Start() error

Start() dials the bus, grab the name, and listens for method calls.

type PostalServiceSetup

type PostalServiceSetup struct {
	InstalledChecker  click.InstalledChecker
	FallbackVibration *launch_helper.Vibration
	FallbackSound     string
}

PostalServiceSetup is a configuration object for the service

type Presenter

type Presenter interface {
	Present(*click.AppId, string, *launch_helper.Notification) bool
}

a Presenter is something that knows how to present a Notification

type PushService

type PushService struct {
	DBusService
	// contains filtered or unexported fields
}

PushService is the dbus api

func NewPushService

func NewPushService(setup *PushServiceSetup, log logger.Logger) *PushService

NewPushService() builds a new service and returns it.

func (*PushService) Start

func (svc *PushService) Start() error

func (*PushService) Unregister

func (svc *PushService) Unregister(appId string) error

type PushServiceSetup

type PushServiceSetup struct {
	RegURL           *url.URL
	DeviceId         string
	InstalledChecker click.InstalledChecker
}

PushServiceSetup encapsulates the params for setting up a PushService.

type ServiceState

type ServiceState uint8

the service can be in a numnber of states

const (
	StateUnknown  ServiceState = iota
	StateRunning               // Start() has been successfully called
	StateFinished              // Stop() has been successfully called
)

Jump to

Keyboard shortcuts

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