Documentation
¶
Overview ¶
Package mobile provides gomobile-compatible bindings for KeibiDrop. All exported types and functions follow gomobile restrictions: no maps, no slices (except []byte), no channels, no complex types. File lists use index-based access (GetRemoteFileCount + GetRemoteFileName).
Index ¶
- Constants
- func FileTypeFromName(name string) string
- func FormatFileSize(bytes int64) string
- type API
- func (api *API) CancelDownload(remoteName string) error
- func (api *API) CancelOp() error
- func (api *API) Connect() error
- func (api *API) ConnectAsync() error
- func (api *API) CreateRoom() error
- func (api *API) CreateRoomAsync() error
- func (api *API) Disconnect() error
- func (api *API) ExportFile(remoteName string, destPath string) error
- func (api *API) Fingerprint() (string, error)
- func (api *API) GetConnectionMode() string
- func (api *API) GetConnectionStatus() int
- func (api *API) GetDiscoveredPeerAddr(i int) string
- func (api *API) GetDiscoveredPeerCount() int
- func (api *API) GetDiscoveredPeerName(i int) string
- func (api *API) GetDiscoveryName() string
- func (api *API) GetDownloadProgress(remoteName string) int
- func (api *API) GetLastError() string
- func (api *API) GetLocalAddress() string
- func (api *API) GetLocalFileCount() int
- func (api *API) GetLocalFileName(i int) string
- func (api *API) GetOpStatus() *OpStatus
- func (api *API) GetRemoteFileCount() int
- func (api *API) GetRemoteFileName(i int) string
- func (api *API) GetRemoteFileSize(i int) int64
- func (api *API) GetSavePath() string
- func (api *API) GetVersion() string
- func (api *API) HasResumableDownload(remoteName string) bool
- func (api *API) ImportFile(localPath string) error
- func (api *API) ImportFileAs(localPath string, remoteName string) error
- func (api *API) Initialize(logFilePath string, relayURL string, inboundPort int, outboundPort int, ...) error
- func (api *API) JoinRoom() error
- func (api *API) JoinRoomAsync() error
- func (api *API) PeerFingerprint() string
- func (api *API) PollEvent() string
- func (api *API) RefreshFileList()
- func (api *API) RegisterPeer(fingerprint string) error
- func (api *API) RelayEndpoint() string
- func (api *API) SaveAllFiles() int
- func (api *API) SaveFile(remoteName string) (string, error)
- func (api *API) SetBridgeAddr(addr string)
- func (api *API) SetPeerDirectAddress(addr string) error
- func (api *API) SetStrictMode(enabled bool)
- func (api *API) SetupEventCallbacks()
- func (api *API) Start() error
- func (api *API) StartDiscovery()
- func (api *API) Stop() error
- func (api *API) StopDiscovery()
- type OpStatus
Constants ¶
const ( OpStatusIdle = "idle" OpStatusRunning = "running" OpStatusSucceeded = "succeeded" OpStatusFailed = "failed" OpStatusTimeout = "timeout" )
Operation status constants (polled from Swift/Kotlin).
Variables ¶
This section is empty.
Functions ¶
func FileTypeFromName ¶
FileTypeFromName returns a category string for a file based on its extension. Returns one of: "pdf", "image", "video", "audio", "code", "archive", "text", "other".
func FormatFileSize ¶
FormatFileSize returns a human-readable file size string.
Types ¶
type API ¶
type API struct {
// contains filtered or unexported fields
}
API is the main entry point for mobile apps. Create one instance, call Initialize, then Start in a background thread.
func (*API) CancelDownload ¶
CancelDownload stops an active download. Partial data is preserved. Call SaveFile or ExportFile again to resume.
func (*API) Connect ¶
Connect determines the creator/joiner role automatically via fingerprint comparison, then creates or joins a room. Blocking.
func (*API) ConnectAsync ¶
ConnectAsync starts Connect in the background. Poll GetOpStatus() to check progress.
func (*API) CreateRoom ¶
CreateRoom creates a room and waits for the peer to join. Blocking.
func (*API) CreateRoomAsync ¶
CreateRoomAsync starts room creation in the background. Poll GetOpStatus() to check progress.
func (*API) Disconnect ¶
Disconnect ends the current session but keeps the engine alive. You can CreateRoom/JoinRoom again after this.
func (*API) ExportFile ¶
ExportFile downloads a file from the peer and saves it to destPath. destPath is where to write on the device (app sandbox, then share via OS).
func (*API) Fingerprint ¶
Fingerprint returns your local fingerprint code. Share this with your peer via Signal, Telegram, email, etc.
func (*API) GetConnectionMode ¶
GetConnectionMode returns the current connection mode: "lan", "direct", "bridge", or "" if not connected.
func (*API) GetConnectionStatus ¶
GetConnectionStatus returns 0=disconnected, 2=connected, 3=reconnecting.
func (*API) GetDiscoveredPeerAddr ¶
GetDiscoveredPeerAddr returns the address of the discovered peer at index i.
func (*API) GetDiscoveredPeerCount ¶
GetDiscoveredPeerCount returns the number of discovered peers on the LAN.
func (*API) GetDiscoveredPeerName ¶
GetDiscoveredPeerName returns the name of the discovered peer at index i.
func (*API) GetDiscoveryName ¶
GetDiscoveryName returns this device's random display name for LAN discovery.
func (*API) GetDownloadProgress ¶
GetDownloadProgress returns download progress as 0-100, or -1 if not active.
func (*API) GetLastError ¶
GetLastError returns the last error message, or empty string.
func (*API) GetLocalAddress ¶
GetLocalAddress returns the link-local IPv6 address for local mode connections. Format: "fe80::1234:5678%en0:26431"
func (*API) GetLocalFileCount ¶
GetLocalFileCount returns the number of local files in the last snapshot.
func (*API) GetLocalFileName ¶
GetLocalFileName returns the name of the local file at index i in the last snapshot. Returns empty string if i is out of bounds.
func (*API) GetOpStatus ¶
GetOpStatus returns the status of the current async operation.
func (*API) GetRemoteFileCount ¶
GetRemoteFileCount returns the number of remote files in the last snapshot.
func (*API) GetRemoteFileName ¶
GetRemoteFileName returns the name of the remote file at index i in the last snapshot. Returns empty string if i is out of bounds.
func (*API) GetRemoteFileSize ¶
GetRemoteFileSize returns the size in bytes of the remote file at index i in the last snapshot. Returns 0 if i is out of bounds.
func (*API) GetSavePath ¶
GetSavePath returns the configured save folder path.
func (*API) HasResumableDownload ¶
HasResumableDownload returns true if a .kdbitmap file exists for the given file, meaning a previous download was interrupted and can be resumed.
func (*API) ImportFile ¶
ImportFile adds a local file to share with the peer. localPath is a path to a file on the device (from file picker, Photos, etc).
func (*API) ImportFileAs ¶
ImportFileAs adds a local file with a custom remote name (preserving folder paths).
func (*API) Initialize ¶
func (api *API) Initialize(logFilePath string, relayURL string, inboundPort int, outboundPort int, savePath string) error
Initialize sets up the KeibiDrop engine. Call once before Start. savePath is where received files are stored (app sandbox directory). No FUSE on mobile. prefetchOnOpen and pushOnWrite are ignored.
func (*API) JoinRoomAsync ¶
JoinRoomAsync starts joining a room in the background. Poll GetOpStatus() to check progress.
func (*API) PeerFingerprint ¶
PeerFingerprint returns the registered peer's fingerprint, or empty string.
func (*API) PollEvent ¶
PollEvent returns the next event string, or empty string if none. Non-blocking. Event format: "type:payload" (e.g. "health_changed:healthy:disconnected").
func (*API) RefreshFileList ¶
func (api *API) RefreshFileList()
RefreshFileList takes a consistent snapshot of remote and local files. Call this once per poll cycle, then use the count/name/size getters.
func (*API) RegisterPeer ¶
RegisterPeer registers the peer's fingerprint code.
func (*API) RelayEndpoint ¶
RelayEndpoint returns the relay URL string.
func (*API) SaveAllFiles ¶
SaveAllFiles downloads all remote files to the save folder sequentially. Returns the number of files successfully saved.
func (*API) SaveFile ¶
SaveFile downloads a file from the peer into the save folder. If the file already exists at the correct size, it skips the download. Returns the local path where the file was saved.
func (*API) SetBridgeAddr ¶
SetBridgeAddr overrides the default bridge relay address.
func (*API) SetPeerDirectAddress ¶
SetPeerDirectAddress sets the peer's address for local mode (no relay). Automatically enables local mode (skips relay, uses TOFU handshake).
func (*API) SetStrictMode ¶
SetStrictMode enables/disables strict mode (no data relay fallback).
func (*API) SetupEventCallbacks ¶
func (api *API) SetupEventCallbacks()
SetupEventCallbacks wires health/reconnect events into the event queue. Call once after Initialize, before Start.
func (*API) Start ¶
Start runs the KeibiDrop event loop. Blocks until Stop is called. Call this from a background thread on mobile.
func (*API) StartDiscovery ¶
func (api *API) StartDiscovery()
StartDiscovery begins broadcasting presence and listening for peers on the LAN. Also enables local mode (skips relay for connections).
func (*API) StopDiscovery ¶
func (api *API) StopDiscovery()
StopDiscovery stops LAN discovery and disables local mode.