storage

package
v0.0.0-...-7af50d5 Latest Latest
Warning

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

Go to latest
Published: Oct 12, 2016 License: MIT Imports: 17 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrInvalidCert      = errors.New("Invalid certificate")
	ErrCouldNotSaveCert = errors.New("Could not save certificate")
)
View Source
var (
	Path directory
)

Functions

func Close

func Close()

func DefaultDirectory

func DefaultDirectory() string

func Initialize

func Initialize(dir string)

func Open

func Open()

Types

type Channel

type Channel struct {
	Server string `json:"server"`
	Name   string `json:"name"`
	Topic  string `json:"topic,omitempty"`
}

func (*Channel) Marshal

func (d *Channel) Marshal(buf []byte) ([]byte, error)

func (*Channel) Size

func (d *Channel) Size() (s uint64)

func (*Channel) Unmarshal

func (d *Channel) Unmarshal(buf []byte) (uint64, error)

type ChannelStore

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

func NewChannelStore

func NewChannelStore() *ChannelStore

func (*ChannelStore) AddUser

func (c *ChannelStore) AddUser(user, server, channel string)

func (*ChannelStore) FindUserChannels

func (c *ChannelStore) FindUserChannels(user, server string) []string

func (*ChannelStore) GetTopic

func (c *ChannelStore) GetTopic(server, channel string) string

func (*ChannelStore) GetUsers

func (c *ChannelStore) GetUsers(server, channel string) []string

func (*ChannelStore) RemoveUser

func (c *ChannelStore) RemoveUser(user, server, channel string)

func (*ChannelStore) RemoveUserAll

func (c *ChannelStore) RemoveUserAll(user, server string)

func (*ChannelStore) RenameUser

func (c *ChannelStore) RenameUser(oldNick, newNick, server string)

func (*ChannelStore) SetMode

func (c *ChannelStore) SetMode(server, channel, user, add, remove string)

func (*ChannelStore) SetTopic

func (c *ChannelStore) SetTopic(topic, server, channel string)

func (*ChannelStore) SetUsers

func (c *ChannelStore) SetUsers(users []string, server, channel string)

type Message

type Message struct {
	ID      uint64 `json:"id"`
	Server  string `json:"server"`
	From    string `json:"from"`
	To      string `json:"to,omitempty"`
	Content string `json:"content"`
	Time    int64  `json:"time"`
}

func (*Message) Marshal

func (d *Message) Marshal(buf []byte) ([]byte, error)

func (*Message) Size

func (d *Message) Size() (s uint64)

func (*Message) Unmarshal

func (d *Message) Unmarshal(buf []byte) (uint64, error)

type Server

type Server struct {
	Name      string `json:"name"`
	Host      string `json:"host"`
	Port      string `json:"port,omitempty"`
	TLS       bool   `json:"tls,omitempty"`
	Password  string `json:"password,omitempty"`
	Nick      string `json:"nick"`
	Username  string `json:"username,omitempty"`
	Realname  string `json:"realname,omitempty"`
	Connected bool   `json:"connected"`
}

func (*Server) Marshal

func (d *Server) Marshal(buf []byte) ([]byte, error)

func (*Server) Size

func (d *Server) Size() (s uint64)

func (*Server) Unmarshal

func (d *Server) Unmarshal(buf []byte) (uint64, error)

type User

type User struct {
	ID       uint64
	Username string
	// contains filtered or unexported fields
}

func LoadUsers

func LoadUsers() []*User

func NewUser

func NewUser() (*User, error)

func (*User) AddChannel

func (u *User) AddChannel(channel Channel)

func (*User) AddServer

func (u *User) AddServer(server Server)

func (*User) GetCertificate

func (u *User) GetCertificate() *tls.Certificate

func (*User) GetChannels

func (u *User) GetChannels() []Channel

func (*User) GetLastMessages

func (u *User) GetLastMessages(server, channel string, count int) ([]Message, error)

func (*User) GetMessages

func (u *User) GetMessages(server, channel string, count int, fromID uint64) ([]Message, error)

func (*User) GetServers

func (u *User) GetServers() []Server

func (*User) LogMessage

func (u *User) LogMessage(server, from, to, content string) error

func (*User) Marshal

func (d *User) Marshal(buf []byte) ([]byte, error)

func (*User) Remove

func (u *User) Remove()

func (*User) RemoveChannel

func (u *User) RemoveChannel(server, channel string)

func (*User) RemoveServer

func (u *User) RemoveServer(address string)

func (*User) SearchMessages

func (u *User) SearchMessages(server, channel, q string) ([]Message, error)

func (*User) SetCertificate

func (u *User) SetCertificate(certPEM, keyPEM []byte) error

func (*User) SetNick

func (u *User) SetNick(nick, address string)

func (*User) Size

func (d *User) Size() (s uint64)

func (*User) Unmarshal

func (d *User) Unmarshal(buf []byte) (uint64, error)

Jump to

Keyboard shortcuts

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