core

package
v0.0.0-...-a5d9707 Latest Latest
Warning

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

Go to latest
Published: Mar 24, 2014 License: MIT Imports: 17 Imported by: 0

Documentation

Overview

Provides a state management interface for all current downloads and the settings object

Index

Constants

View Source
const (
	RPC_PORT = 7696
)

Variables

This section is empty.

Functions

func NewRpcClient

func NewRpcClient() (client *rpc.Client, err error)

func StartRpcServer

func StartRpcServer(m *Manager) (err error)

Types

type AllChunksDownloadingError

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

Move to main package

func (AllChunksDownloadingError) Error

type BasicAuthCredentials

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

func (*BasicAuthCredentials) Authenticate

func (c *BasicAuthCredentials) Authenticate(client *http.Client, req *http.Request) (err error)

type ByteSize

type ByteSize float64
const (
	KB ByteSize = 1 << (10 * iota)
	MB
	GB
	TB
	PB
	EB
	ZB
	YB
)

func (ByteSize) String

func (b ByteSize) String() string

type Chunk

type Chunk struct {
	io.ReadCloser
	Downloadable

	Percent int
	// contains filtered or unexported fields
}

func NewChunk

func NewChunk(res *Resource, index int, start, end ByteSize, resume bool) (c Chunk, err error)

func (*Chunk) Close

func (c *Chunk) Close() (err error)

func (*Chunk) DestinationFile

func (c *Chunk) DestinationFile() string

func (*Chunk) DestinationFolder

func (c *Chunk) DestinationFolder() string

func (*Chunk) Dl

func (c *Chunk) Dl() (err error)

func (*Chunk) Download

func (c *Chunk) Download()

func (*Chunk) IsChunkCompleteError

func (c *Chunk) IsChunkCompleteError(err error) (ok bool)

func (*Chunk) Read

func (c *Chunk) Read(p []byte) (n int, err error)

func (*Chunk) Setup

func (c *Chunk) Setup() (err error)

func (*Chunk) Write

func (c *Chunk) Write(p []byte) (n int, err error)

type ChunkCompleteError

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

func (ChunkCompleteError) Error

func (e ChunkCompleteError) Error() string

type ChunkStore

type ChunkStore struct {
	io.ReadWriteCloser
	// contains filtered or unexported fields
}

func NewChunkStore

func NewChunkStore(location string) *ChunkStore

func (*ChunkStore) Open

func (cs *ChunkStore) Open() (err error)

func (*ChunkStore) Remove

func (cs *ChunkStore) Remove() (err error)

func (*ChunkStore) Size

func (cs *ChunkStore) Size() (b ByteSize, err error)

type Credentials

type Credentials interface {
	Authenticate(c *http.Client, req *http.Request) error
}

type Display

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

type Downloadable

type Downloadable struct {
	Downloaded ByteSize
	Size       ByteSize

	Resource *Resource
	// contains filtered or unexported fields
}

func (*Downloadable) Progress

func (d *Downloadable) Progress() int

type Downloader

type Downloader struct {
	Downloadable
	io.WriteCloser

	Chunks         []*Chunk
	CompleteChunks int
	MaxChunks      int
	SpeedMonitor   *SpeedMonitor
	TotalChunks    int
	// contains filtered or unexported fields
}

func NewDownloader

func NewDownloader(url string, updater chan *Downloader) (d Downloader, err error)

func (*Downloader) AreAllChunksDownloading

func (d *Downloader) AreAllChunksDownloading(err error) (ok bool)

func (*Downloader) Close

func (d *Downloader) Close()

func (*Downloader) DestinationFile

func (d *Downloader) DestinationFile() string

func (*Downloader) Start

func (d *Downloader) Start(resume bool)

func (*Downloader) Write

func (d *Downloader) Write(p []byte) (n int, err error)

type Manager

type Manager struct {
	Downloads map[url.URL]*Downloader
	Publisher *Publisher
	// contains filtered or unexported fields
}

func NewManager

func NewManager(s *Settings) *Manager

func (*Manager) AddUrl

func (m *Manager) AddUrl(url string) (err error)

func (*Manager) RestoreState

func (m *Manager) RestoreState(s *Settings) error

func (*Manager) Start

func (m *Manager) Start()

type Publisher

type Publisher struct {
	Subscribers []string
}

func NewPublisher

func NewPublisher() *Publisher

func (*Publisher) Subscribe

func (p *Publisher) Subscribe()

type Resource

type Resource struct {
	Name   string
	Hoster hosters.Hoster
	Url    *url.URL
	// contains filtered or unexported fields
}

func NewResource

func NewResource(address string) (res Resource, err error)

type RpcController

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

func (*RpcController) AddDownload

func (c *RpcController) AddDownload(url string, ok *bool) (err error)

type Settings

type Settings struct {
	io.Writer         `json:"-"`
	Location          string                 `json:"-"`
	DownloadDirectory string                 `json:"download_directory"`
	HosterCredentials map[string]Credentials `json:"hoster_credentials"`
}

func LoadSettings

func LoadSettings() (s *Settings, err error)

TODO: Make me… better.

func (*Settings) Save

func (s *Settings) Save() (err error)

func (*Settings) String

func (s *Settings) String() string

type SettingsStore

type SettingsStore struct {
	io.ReadWriter
}

type SpeedMonitor

type SpeedMonitor struct {
	Speed ByteSize // Bytes / Second
	// contains filtered or unexported fields
}

func NewSpeedMonitor

func NewSpeedMonitor(updater chan ByteSize) *SpeedMonitor

func (*SpeedMonitor) Start

func (s *SpeedMonitor) Start()

func (*SpeedMonitor) Stop

func (s *SpeedMonitor) Stop()

Jump to

Keyboard shortcuts

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