ipc

package
v1.12.1 Latest Latest
Warning

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

Go to latest
Published: May 23, 2026 License: MIT Imports: 14 Imported by: 0

Documentation

Overview

Package ipc defines the local Unix socket protocol used between the daemon and the command line interface.

Index

Constants

View Source
const (
	CmdDevices              = "devices"
	CmdPair                 = "pair"
	CmdPairListen           = "pair_listen"
	CmdUnpair               = "unpair"
	CmdPing                 = "ping"
	CmdBattery              = "battery"
	CmdClipboardPush        = "clipboard_push"
	CmdRunList              = "run_list"
	CmdRunExec              = "run_exec"
	CmdShare                = "share"
	CmdConnect              = "connect"
	CmdBroadcastStart       = "broadcast_start"
	CmdBroadcastStop        = "broadcast_stop"
	CmdWatch                = "watch"
	CmdSftpMount            = "sftp_mount"
	CmdSftpInfo             = "sftp_info"
	CmdSftpVolumes          = "sftp_volumes"
	CmdNotifyReply          = "notify_reply"
	CmdCallMute             = "call_mute"
	CmdFindMyPhone          = "findmyphone"
	CmdLock                 = "lock"
	CmdUnlock               = "unlock"
	CmdSendSMS              = "send_sms"
	CmdSmsRequestConvs      = "sms_request_conversations"
	CmdSmsRequestConv       = "sms_request_conversation"
	CmdSmsRequestAttachment = "sms_request_attachment"
	CmdSftpMountLocal       = "sftp_mount_local"
	CmdSftpUnmount          = "sftp_unmount"
	CmdStatus               = "status"
	CmdMprisStatus          = "mpris_status"
	CmdMprisAction          = "mpris_action"
	CmdMprisRemote          = "mpris_remote"
)

Supported IPC command constants.

Variables

This section is empty.

Functions

This section is empty.

Types

type ConnectPayload added in v1.0.1

type ConnectPayload struct {
	IP string `json:"ip"`
}

ConnectPayload carries the target IP for the CmdConnect command.

type DevicePayload

type DevicePayload struct {
	DeviceID string `json:"deviceId"`
	Key      string `json:"key,omitempty"`
}

DevicePayload is sent in requests requiring a device ID (like pair/unpair/ping).

type Handler

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

Handler handles incoming IPC requests.

func NewHandler

func NewHandler(devices *device.Registry, plugins *plugin.Registry, pairPlugin *pair.PairPlugin, statePath string, bus *events.Bus) *Handler

NewHandler creates a new IPC command handler.

func (*Handler) HandleRequest

func (h *Handler) HandleRequest(req Request) Response

HandleRequest processes an incoming IPC request and returns a response.

func (*Handler) Register

func (h *Handler) Register(command string, fn func(Request) Response)

Register adds a custom handler for a given command.

type MprisActionPayload added in v1.11.0

type MprisActionPayload struct {
	DeviceID string `json:"deviceId"`
	Player   string `json:"player,omitempty"`
	Action   string `json:"action,omitempty"`
	Volume   *int   `json:"volume,omitempty"`
	Seek     *int64 `json:"seek,omitempty"`
}

type MprisPlayerInfo added in v1.10.0

type MprisPlayerInfo struct {
	DisplayName    string `json:"displayName"`
	BusName        string `json:"busName"`
	ShortName      string `json:"shortName"`
	Title          string `json:"title"`
	Artist         string `json:"artist"`
	Album          string `json:"album"`
	PlaybackStatus string `json:"playbackStatus"`
	IsPlaying      bool   `json:"isPlaying"`
	Volume         int    `json:"volume"`
	Pos            int64  `json:"pos"`
	Length         int64  `json:"length"`
	AlbumArtUrl    string `json:"albumArtUrl"`
	CanSeek        bool   `json:"canSeek"`
	CanGoNext      bool   `json:"canGoNext"`
	CanGoPrevious  bool   `json:"canGoPrevious"`
	CanPlay        bool   `json:"canPlay"`
	CanPause       bool   `json:"canPause"`
	Error          string `json:"error,omitempty"`
}

type MprisRemotePlayer added in v1.11.0

type MprisRemotePlayer struct {
	DeviceID       string `json:"deviceId"`
	Player         string `json:"player"`
	Title          string `json:"title"`
	Artist         string `json:"artist"`
	Album          string `json:"album"`
	AlbumArtUrl    string `json:"albumArtUrl"`
	Url            string `json:"url,omitempty"`
	Length         int64  `json:"length"`
	Pos            int64  `json:"pos"`
	IsPlaying      bool   `json:"isPlaying"`
	Volume         int    `json:"volume"`
	PlaybackStatus string `json:"playbackStatus"`
	CanSeek        bool   `json:"canSeek"`
	CanGoNext      bool   `json:"canGoNext"`
	CanGoPrevious  bool   `json:"canGoPrevious"`
	CanPlay        bool   `json:"canPlay"`
	CanPause       bool   `json:"canPause"`
	CanControl     bool   `json:"canControl"`
}

type MprisRemoteResponse added in v1.11.0

type MprisRemoteResponse struct {
	Players []MprisRemotePlayer `json:"players"`
}

type MprisStatusResponse added in v1.10.0

type MprisStatusResponse struct {
	WatcherRunning bool              `json:"watcherRunning"`
	DeviceCount    int               `json:"deviceCount"`
	Players        []MprisPlayerInfo `json:"players"`
	PlayerMappings map[string]string `json:"playerMappings"`
}

type NotifyReplyPayload

type NotifyReplyPayload struct {
	DeviceID string `json:"deviceId"`
	ReplyID  string `json:"replyId"`
	Message  string `json:"message"`
}

NotifyReplyPayload is used for CmdNotifyReply.

type PairListenResult added in v1.10.0

type PairListenResult struct {
	DeviceID        string `json:"deviceId"`
	DeviceName      string `json:"deviceName"`
	VerificationKey string `json:"verificationKey,omitempty"`
}

PairListenResult is returned by CmdPairListen on success.

type Request

type Request struct {
	Command string          `json:"cmd"`
	Payload json.RawMessage `json:"payload,omitempty"`
}

Request is sent from the client to the local daemon.

type Response

type Response struct {
	OK    bool            `json:"ok"`
	Error string          `json:"error,omitempty"`
	Data  json.RawMessage `json:"data,omitempty"`
}

Response is sent from the daemon back to the client.

type SMSAttachmentPayload added in v1.11.0

type SMSAttachmentPayload struct {
	DeviceID         string `json:"deviceId"`
	PartID           int64  `json:"partID"`
	UniqueIdentifier string `json:"uniqueIdentifier"`
}

SMSAttachmentPayload is used for CmdSmsRequestAttachment.

type SMSConvPayload added in v1.11.0

type SMSConvPayload struct {
	DeviceID            string `json:"deviceId"`
	ThreadID            int64  `json:"threadID"`
	RangeStartTimestamp int64  `json:"rangeStartTimestamp,omitempty"`
	NumberToRequest     int64  `json:"numberToRequest,omitempty"`
}

SMSConvPayload is used for CmdSmsRequestConv.

type SMSPayload

type SMSPayload struct {
	DeviceID    string `json:"deviceId"`
	PhoneNumber string `json:"phoneNumber"`
	Message     string `json:"message"`
}

SMSPayload is used for CmdSendSMS.

type Server

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

Server handles listening for JSON IPC requests over a Unix socket.

func NewServer

func NewServer(path string, handler *Handler, logger *zap.Logger) *Server

NewServer creates a new IPC server.

func (*Server) Listen

func (s *Server) Listen(ctx context.Context) error

Listen starts listening on the Unix socket and processes incoming connections.

type SftpInfoResponse added in v1.10.0

type SftpInfoResponse struct {
	IP       string                  `json:"ip"`
	Port     json.Number             `json:"port"`
	User     string                  `json:"user"`
	Password string                  `json:"password"`
	Path     string                  `json:"path"`
	Volumes  []StorageVolumeResponse `json:"volumes,omitempty"`
}

SftpInfoResponse carries cached SFTP connection details returned by CmdSftpInfo.

type SharePayload

type SharePayload struct {
	DeviceID string `json:"deviceId"`
	FilePath string `json:"filePath"`
}

SharePayload is used for CmdShare.

type StatusResponse added in v1.0.5

type StatusResponse struct {
	Version        string   `json:"version"`
	StartedAt      string   `json:"startedAt"`
	UptimeHuman    string   `json:"uptimeHuman"`
	SocketPath     string   `json:"socketPath"`
	ConfigPath     string   `json:"configPath"`
	Plugins        []string `json:"plugins"`
	DeviceCount    int      `json:"deviceCount"`
	ConnectedCount int      `json:"connectedCount"`
}

StatusResponse is returned by CmdStatus.

type StorageVolumeResponse added in v1.10.0

type StorageVolumeResponse struct {
	Name string `json:"name"`
	Path string `json:"path"`
}

StorageVolumeResponse describes a single browsable storage root on a device.

type WatchPayload

type WatchPayload struct {
	Events []string `json:"events,omitempty"`
}

WatchPayload is used for CmdWatch to configure event streaming.

Jump to

Keyboard shortcuts

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