lockbook

package
v0.8.4 Latest Latest
Warning

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

Go to latest
Published: Feb 5, 2024 License: Unlicense Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var DefaultAPILocation = C.GoString((*C.char)(unsafe.Pointer(&C.LB_DEFAULT_API_LOCATION[0])))

Functions

func FileTypeString

func FileTypeString(t FileType) string

func SortFiles

func SortFiles(files []File)

Types

type Account

type Account struct {
	Username string
	APIURL   string
}

type AppStoreAccountState

type AppStoreAccountState int
const (
	AppStoreNone AppStoreAccountState = iota
	AppStoreOk
	AppStoreGracePeriod
	AppStoreFailedToRenew
	AppStoreExpired
)

func (AppStoreAccountState) String

func (s AppStoreAccountState) String() string

type Core

type Core interface {
	WriteablePath() string

	GetAccount() (Account, error)
	CreateAccount(uname, apiURL string, welcome bool) (Account, error)
	ImportAccount(acctStr string) (Account, error)
	ExportAccount() (string, error)

	FileByID(id FileID) (File, error)
	FileByPath(lbPath string) (File, error)
	GetRoot() (File, error)
	GetChildren(id FileID) ([]File, error)
	GetAndGetChildrenRecursively(id FileID) ([]File, error)
	ListMetadatas() ([]File, error)
	PathByID(id FileID) (string, error)

	ReadDocument(id FileID) ([]byte, error)
	WriteDocument(id FileID, data []byte) error

	CreateFile(name string, parentID FileID, typ FileType) (File, error)
	CreateFileAtPath(lbPath string) (File, error)
	DeleteFile(id FileID) error
	RenameFile(id FileID, newName string) error
	MoveFile(srcID, destID FileID) error

	ImportFile(src string, dest FileID, fn func(ImportFileInfo)) error
	ExportFile(id FileID, dest string, fn func(ExportFileInfo)) error
	ExportDrawing(id FileID, imgFmt ImageFormat) ([]byte, error)
	ExportDrawingToDisk(id FileID, imgFmt ImageFormat, dest string) error

	GetLastSynced() (time.Time, error)
	GetLastSyncedHumanString() (string, error)
	GetUsage() (UsageMetrics, error)
	GetUncompressedUsage() (UsageItemMetric, error)
	CalculateWork() (WorkCalculated, error)
	SyncAll(fn func(SyncProgress)) error

	ShareFile(id FileID, uname string, mode ShareMode) error
	GetPendingShares() ([]File, error)
	DeletePendingShare(id FileID) error

	GetSubscriptionInfo() (SubscriptionInfo, error)
	UpgradeViaStripe(card *CreditCard) error
	CancelSubscription() error

	Validate() ([]string, error)
}

func NewCore

func NewCore(fpath string) (Core, error)

type CreditCard

type CreditCard struct {
	Number      string
	ExpiryYear  int
	ExpiryMonth int
	CVC         string
}

type Error

type Error struct {
	Code  ErrorCode
	Msg   string
	Trace string
}

func (*Error) Error

func (e *Error) Error() string

type ErrorCode

type ErrorCode uint32
const (
	CodeSuccess ErrorCode = iota
	CodeUnexpected
	CodeAccountExists
	CodeAccountNonexistent
	CodeAccountStringCorrupted
	CodeAlreadyCanceled
	CodeAlreadyPremium
	CodeAppStoreAccountAlreadyLinked
	CodeCannotCancelSubscriptionForAppStore
	CodeCardDecline
	CodeCardExpired
	CodeCardInsufficientFunds
	CodeCardInvalidCvc
	CodeCardInvalidExpMonth
	CodeCardInvalidExpYear
	CodeCardInvalidNumber
	CodeCardNotSupported
	CodeClientUpdateRequired
	CodeCurrentUsageIsMoreThanNewTier
	CodeDiskPathInvalid
	CodeDiskPathTaken
	CodeDrawingInvalid
	CodeExistingRequestPending
	CodeFileNameContainsSlash
	CodeFileNameEmpty
	CodeFileNonexistent
	CodeFileNotDocument
	CodeFileNotFolder
	CodeFileParentNonexistent
	CodeFolderMovedIntoSelf
	CodeInsufficientPermission
	CodeInvalidPurchaseToken
	CodeInvalidAuthDetails
	CodeLinkInSharedFolder
	CodeLinkTargetIsOwned
	CodeLinkTargetNonexistent
	CodeMultipleLinksToSameFile
	CodeNotPremium
	CodeOldCardDoesNotExist
	CodePathContainsEmptyFileName
	CodePathTaken
	CodeRootModificationInvalid
	CodeRootNonexistent
	CodeServerDisabled
	CodeServerUnreachable
	CodeShareAlreadyExists
	CodeShareNonexistent
	CodeTryAgain
	CodeUsageIsOverFreeTierDataCap
	CodeUsernameInvalid
	CodeUsernameNotFound
	CodeUsernamePublicKeyMismatch
	CodeUsernameTaken
)

type ExportFileInfo

type ExportFileInfo struct {
	DiskPath string
	LbPath   string
}

type File

type File struct {
	ID        FileID
	Parent    FileID
	Name      string
	Type      FileType
	Lastmod   time.Time
	LastmodBy string
	Shares    []Share
}

func MaybeFileByPath

func MaybeFileByPath(core Core, p string) (File, bool, error)

func (*File) IsDir

func (f *File) IsDir() bool

func (*File) IsRoot

func (f *File) IsRoot() bool

type FileID

type FileID = uuid.UUID

type FileType

type FileType interface {
	// contains filtered or unexported methods
}

type FileTypeDocument

type FileTypeDocument struct{}

type FileTypeFolder

type FileTypeFolder struct{}
type FileTypeLink struct{ Target FileID }

type FileUsage

type FileUsage struct {
	FileID    FileID
	SizeBytes uint64
}

type GooglePlayAccountState

type GooglePlayAccountState int
const (
	GooglePlayNone GooglePlayAccountState = iota
	GooglePlayOk
	GooglePlayCanceled
	GooglePlayGracePeriod
	GooglePlayOnHold
)

func (GooglePlayAccountState) String

func (s GooglePlayAccountState) String() string

type ImageFormat

type ImageFormat int
const (
	ImgFmtPNG ImageFormat = iota
	ImgFmtJPEG
	ImgFmtPNM
	ImgFmtTGA
	ImgFmtFarbfeld
	ImgFmtBMP
)

type ImportFileInfo

type ImportFileInfo struct {
	Total    int
	DiskPath string
	FileDone *File
}

ImportFileInfo is the data sent (via closure) at certain stages of file import. The stage and type of information is determined by the zero value of each field. A non-zero `Total` means a "total calculated" update. A non-empty `DiskPath` means a "file started" update. A non-nil `FileDone` means a "file finished" update.

type Share

type Share struct {
	Mode       ShareMode
	SharedBy   string
	SharedWith string
}

type ShareMode

type ShareMode int
const (
	ShareModeRead ShareMode = iota
	ShareModeWrite
)

func (ShareMode) String

func (s ShareMode) String() string

type StripeInfo

type StripeInfo struct {
	Last4 string
}

type SubscriptionInfo

type SubscriptionInfo struct {
	StripeLast4 string
	GooglePlay  GooglePlayAccountState
	AppStore    AppStoreAccountState
	PeriodEnd   time.Time
}

type SyncProgress

type SyncProgress struct {
	Total    uint64
	Progress uint64
	Msg      string
}

SyncProgress is the data sent (via closure) at certain stages of sync.

type UsageItemMetric

type UsageItemMetric struct {
	Exact    uint64
	Readable string
}

type UsageMetrics

type UsageMetrics struct {
	Usages      []FileUsage
	ServerUsage UsageItemMetric
	DataCap     UsageItemMetric
}

type WorkCalculated

type WorkCalculated struct {
	LastServerUpdateAt uint64
	WorkUnits          []WorkUnit
}

type WorkUnit

type WorkUnit struct {
	Type WorkUnitType
	ID   FileID
}

type WorkUnitType

type WorkUnitType int
const (
	WorkUnitTypeLocal WorkUnitType = iota
	WorkUnitTypeServer
)

Jump to

Keyboard shortcuts

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