kobo

package
v2.0.1 Latest Latest
Warning

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

Go to latest
Published: Feb 9, 2020 License: MIT Imports: 15 Imported by: 0

Documentation

Overview

Package kobo contains stuff related to Kobo devices, firmware, and nickel.

Index

Constants

This section is empty.

Variables

View Source
var ErrCommandNotFound = errors.New("required command not found")

ErrCommandNotFound is thrown when a required command is not found.

Functions

func ContentIDToImageID

func ContentIDToImageID(contentID string) string

ContentIDToImageID converts the Kobo ContentId to the ImageId.

func Find

func Find() ([]string, error)

Find gets the paths to the kobos.

func IsKobo

func IsKobo(path string) bool

IsKobo checks if a path is a kobo.

func ParseKoboAffiliate

func ParseKoboAffiliate(kpath string) (affiliate string, err error)

ParseKoboAffiliate parses the affiliate from the .kobo/affiliate.conf file.

func ParseKoboVersion

func ParseKoboVersion(kpath string) (serial, version, id string, err error)

ParseKoboVersion gets the info from the .kobo/version file.

func PathToContentID

func PathToContentID(relpath string) string

PathToContentID generates the Kobo ContentId for a path relative to the internal storage root (slashes are converted to forward slashes automatically).

func VersionCompare

func VersionCompare(a, b string) int

VersionCompare compares two firmware versions. a < b = -1 a = b = 0 a > b = 1

Types

type CodeName

type CodeName string

CodeName represents an individual codename. Note that a codename can be used for more than one thing in a triplet.

const (
	CodeNameNone          CodeName = ""
	CodeNameDesktop       CodeName = "desktop"
	CodeNameNickel1       CodeName = "nickel1"
	CodeNameNickel2       CodeName = "nickel2"
	CodeNameMerch         CodeName = "merch"
	CodeNameVox           CodeName = "vox"
	CodeNameTrilogy       CodeName = "trilogy"
	CodeNamePixie         CodeName = "pixie"
	CodeNamePika          CodeName = "pika"
	CodeNameDragon        CodeName = "dragon"
	CodeNameDahlia        CodeName = "dahlia"
	CodeNameAlyssum       CodeName = "alyssum"
	CodeNameSnow          CodeName = "snow"
	CodeNameNova          CodeName = "nova"
	CodeNameStorm         CodeName = "storm"
	CodeNameDaylight      CodeName = "daylight"
	CodeNameSuperDaylight CodeName = "superDaylight"
	CodeNameFrost         CodeName = "frost"
	CodeNameFrost32       CodeName = "frost32"
	CodeNamePhoenix       CodeName = "phoenix"
	CodeNameKraken        CodeName = "kraken"
	CodeNameStar          CodeName = "star"
)

Codenames.

func (CodeName) String

func (c CodeName) String() string

type CodeNameTriplet

type CodeNameTriplet [3]CodeName

CodeNameTriplet represents a triplet of class/family/secondary codenames. Note that nothing in nickel says a device can only have 3, but everything so far implies that (and it makes sense).

func (CodeNameTriplet) Class

func (c CodeNameTriplet) Class() CodeName

Class gets the class/category.

func (CodeNameTriplet) Family

func (c CodeNameTriplet) Family() CodeName

Family gets the family/model (i.e. part of a class)

func (CodeNameTriplet) FamilyString

func (c CodeNameTriplet) FamilyString() string

FamilyString gets the human readable family/model.

func (CodeNameTriplet) Secondary

func (c CodeNameTriplet) Secondary() CodeName

Secondary gets the secondary device codename (i.e. refines the family).

func (CodeNameTriplet) SecondaryString

func (c CodeNameTriplet) SecondaryString() string

SecondaryString returns the human readable string to append to FamilyString if applicable (e.g. Limited Edition, 32GB).

func (CodeNameTriplet) String

func (c CodeNameTriplet) String() string

type CoverType

type CoverType string

CoverType is used to identify different cover dimensions used for different purposes by nickel.

const (
	CoverTypeFull    CoverType = "N3_FULL"
	CoverTypeLibFull CoverType = "N3_LIBRARY_FULL"
	CoverTypeLibList CoverType = "N3_LIBRARY_LIST"
	CoverTypeLibGrid CoverType = "N3_LIBRARY_GRID"
)

Cover types.

func CoverTypes

func CoverTypes() []CoverType

CoverTypes returns a slice of all implemented nickel cover types.

func (CoverType) GeneratePath

func (c CoverType) GeneratePath(external bool, iid string) string

GeneratePath generates the path for the cover of an ImageID. The path is always separated with forward slashes.

func (CoverType) NickelString

func (c CoverType) NickelString() string

NickelString returns the internal string used in nickel to identify the cover type.

func (CoverType) Resize

func (c CoverType) Resize(target image.Point, sz image.Point) image.Point

Resize returns the dimensions to resize sz to for the cover type and target size.

func (CoverType) String

func (c CoverType) String() string

type Device

type Device int

Device is a device model.

const (
	DeviceTouchAB               Device = 310
	DeviceTouchC                Device = 320
	DeviceGlo                   Device = 330
	DeviceMini                  Device = 340
	DeviceAuraHD                Device = 350
	DeviceAura                  Device = 360
	DeviceAuraH2O               Device = 370
	DeviceGloHD                 Device = 371
	DeviceTouch2                Device = 372
	DeviceAuraONE               Device = 373
	DeviceAuraH2OEdition2v1     Device = 374
	DeviceAuraEdition2v1        Device = 375
	DeviceClaraHD               Device = 376
	DeviceForma                 Device = 377
	DeviceAuraH2OEdition2v2     Device = 378
	DeviceAuraEdition2v2        Device = 379
	DeviceForma32               Device = 380
	DeviceAuraONELimitedEdition Device = 381
	DeviceLibraH2O              Device = 384
)

Devices (not including really old ones, like Kobo eReader, Wireless, Literati, and Vox).

func DeviceByID

func DeviceByID(id string) (Device, bool)

DeviceByID gets a device by its full ID string.

func Devices

func Devices() []Device

Devices returns a slice of all supported devices.

func (Device) CodeNames

func (d Device) CodeNames() CodeNameTriplet

CodeNames returns the codename triplet for the device (like libnickel). Note: Nickel has a slightly different definition if Class, Family, and Secondary, but these triplets are correct (i.e. Device::is* will match nickel, and the hierachy is correct). These were determined by static analysis of libnickel. See PR#1 for details.

func (Device) CoverSize

func (d Device) CoverSize(t CoverType) image.Point

CoverSize returns the cover size for a cover type for a Device. Currently, everything except for the Full cover is the same for every device.

func (Device) CoverSized

func (d Device) CoverSized(t CoverType, orig image.Point) image.Point

CoverSized returns a size resized to the correct size using the same logic as nickel.

func (Device) Family

func (d Device) Family() string

Family is short for Device.CodeNames().FamilyString().

func (Device) Hardware

func (d Device) Hardware() Hardware

Hardware returns the hardware revision.

func (Device) ID

func (d Device) ID() int

ID returns the numerical device ID.

func (Device) IDString

func (d Device) IDString() string

IDString returns the full ID string.

func (Device) Is

func (d Device) Is(n CodeName) bool

Is replicates the Device::is* functions in libnickel.

func (Device) Name

func (d Device) Name() string

Name returns the full device name.

func (Device) StorageGB

func (d Device) StorageGB() int

StorageGB returns the advertised storage capacity of a Device.

func (Device) String

func (d Device) String() string

type Hardware

type Hardware int

Hardware is a hardware revision.

const (
	HardwareKobo3 Hardware = 3
	HardwareKobo4 Hardware = 4
	HardwareKobo5 Hardware = 5
	HardwareKobo6 Hardware = 6
	HardwareKobo7 Hardware = 7
)

Hardware revisions.

func (Hardware) Hardware

func (h Hardware) Hardware() int

Hardware returns the numerical hardware revision.

func (Hardware) String

func (h Hardware) String() string

type UpgradeCheckResult

type UpgradeCheckResult struct {
	Data           interface{}
	ReleaseNoteURL string
	UpgradeType    UpgradeType
	UpgradeURL     string
}

UpgradeCheckResult represents an update check result from the Kobo API.

func CheckUpgrade

func CheckUpgrade(device, affiliate, curVersion, serial string) (*UpgradeCheckResult, error)

CheckUpgrade queries the Kobo API for an update.

func (UpgradeCheckResult) ParseVersion

func (u UpgradeCheckResult) ParseVersion() string

ParseVersion tries to extract the version from the UpgradeURL. It returns 0.0.0 if none is present.

type UpgradeType

type UpgradeType int

UpgradeType represents an upgrade type.

const (
	UpgradeTypeNone      UpgradeType = 0 // No upgrade available.
	UpgradeTypeAvailable UpgradeType = 1 // Optional update, but never seen this before.
	UpgradeTypeRequired  UpgradeType = 2 // Automatic update.
)

Upgrade types.

func (UpgradeType) IsUpdate

func (u UpgradeType) IsUpdate() bool

IsUpdate checks if an UpdateType signifies an available update.

func (UpgradeType) String

func (u UpgradeType) String() string

Jump to

Keyboard shortcuts

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