store

package
v0.6.8 Latest Latest
Warning

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

Go to latest
Published: Oct 2, 2019 License: GPL-3.0 Imports: 22 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ActiveSessionID string
View Source
var AllGroups []*GroupRecord
View Source
var AllSessions []*Session

TODO that hasn't to be in the db controller

View Source
var Groups = map[string]*GroupRecord{}
View Source
var SessionsModel = &Sessions{
	Sess: make([]*Session, 0),
}

Functions

func AddDevice

func AddDevice(url string) error

func AvatarImageProvider

func AvatarImageProvider(id string, width, height int) image.Image

func CopyAttachment

func CopyAttachment(src string) (string, error)

copyAttachment makes a copy of a file that is in the volatile content hub cache

func DeleteGroup

func DeleteGroup(hexid string) error

func DeleteMessage

func DeleteMessage(id int64) error
func LoadMessagesList(id int64) (error, *MessageList) {
	messageList := &MessageList{
		ID: id,
	}
	log.Printf("Loading Messages for " + string(id))
	err := DS.Dbx.Select(&messageList.Messages, messagesSelectWhere, id)
	if err != nil {
		return err, nil
	}
	return nil, messageList
}

func DeleteSession

func DeleteSession(tel string) error

func FetchAllGroups

func FetchAllGroups() error

func GetContactForTel

func GetContactForTel(tel string) *textsecure.Contact

func GroupUpdateMsg

func GroupUpdateMsg(tels []string, title string) string

func IsEncrypted

func IsEncrypted(filename string) (bool, error)

IsEncrypted returns true, if the database with the given filename is encrypted, and false otherwise. If the database header cannot be read properly an error is returned.

func LoadChats

func LoadChats() error

func LoadMessagesFromDB

func LoadMessagesFromDB() error

func RefreshContacts

func RefreshContacts() error

func SaveAttachment

func SaveAttachment(a *textsecure.Attachment) (string, error)

func SaveGroup

func SaveGroup(g *GroupRecord) error

func SaveSession

func SaveSession(s *Session) error

func TelToName

func TelToName(tel string) string

func UpdateGroup

func UpdateGroup(g *GroupRecord) error

func UpdateMessageRead

func UpdateMessageRead(m *Message) error

func UpdateMessageSent

func UpdateMessageSent(m *Message) error

func UpdateSession

func UpdateSession(s *Session) error

func UpdateSessionTable

func UpdateSessionTable() error

This is needed for version .26

func UpdateTimestamps

func UpdateTimestamps()

updateTimestamps keeps the timestamps of the last message of each session updated in human readable form. FIXME: make this lazier, to only update timestamps the user sees at the moment

Types

type Contacts

type Contacts struct {
	Contacts []textsecure.Contact
	Len      int
}
var ContactsModel *Contacts = &Contacts{}

func (*Contacts) GetContact

func (c *Contacts) GetContact(i int) textsecure.Contact

type DataStore

type DataStore struct {
	Dbx *sqlx.DB
}
var DS *DataStore

func NewDataStore

func NewDataStore(dbPath, saltPath, password string) (*DataStore, error)

func NewStorage

func NewStorage(password string) (*DataStore, error)

NewStorage

func (*DataStore) Convert

func (ds *DataStore) Convert(password string) error

func (*DataStore) DBX

func (ds *DataStore) DBX() *sqlx.DB

func (*DataStore) Decrypt

func (ds *DataStore) Decrypt(dbPath string) error

Decrypt database and closes connection

func (*DataStore) DecryptDb

func (ds *DataStore) DecryptDb(password string) bool

func (*DataStore) Encrypt

func (ds *DataStore) Encrypt(dbFile string, password string) error

func (*DataStore) EncryptDb

func (ds *DataStore) EncryptDb(password string) bool

func (*DataStore) ResetDb

func (ds *DataStore) ResetDb()

func (*DataStore) SetupDb

func (ds *DataStore) SetupDb(password string) bool

type GroupRecord

type GroupRecord struct {
	ID      int64
	GroupID string
	Name    string
	Members string
	Avatar  []byte
	Active  bool
}

type LinkedDevices

type LinkedDevices struct {
	LinkedDevices []textsecure.DeviceInfo
	Len           int
}
var LinkedDevicesModel *LinkedDevices = &LinkedDevices{}

func RefreshDevices

func RefreshDevices() (*LinkedDevices, error)

func (*LinkedDevices) DeleteDevice

func (c *LinkedDevices) DeleteDevice() error

func (*LinkedDevices) GetDevice

func (c *LinkedDevices) GetDevice(i int) textsecure.DeviceInfo

func (*LinkedDevices) RefreshDevices

func (c *LinkedDevices) RefreshDevices() error

func (*LinkedDevices) UnlinkDevice

func (c *LinkedDevices) UnlinkDevice(id int) error

type Message

type Message struct {
	ID         int64
	SID        int64
	Source     string
	Message    string
	Outgoing   bool
	SentAt     uint64
	ReceivedAt uint64
	HTime      string
	CType      int
	Attachment string
	IsSent     bool
	IsRead     bool
	Flags      int
}

func SaveMessage

func SaveMessage(m *Message) (error, *Message)

func (*Message) GetName

func (m *Message) GetName() string

type MessageList

type MessageList struct {
	ID       string
	Session  *Session
	Messages []*Message
}

type Session

type Session struct {
	ID           int64
	Name         string
	Tel          string
	IsGroup      bool
	Last         string
	Timestamp    uint64
	When         string
	CType        int
	Messages     []*Message
	Unread       int
	Active       bool
	Len          int
	Notification bool
}

func (*Session) Add

func (s *Session) Add(text string, source string, file string, mimetype string, outgoing bool, sessionID string) *Message
func (s *Sessions) GetActiveChat() *string {
	return s.ActiveChat
}

func (*Session) GetMessages

func (s *Session) GetMessages(i int) *Message

func (*Session) MarkRead

func (s *Session) MarkRead()

func (*Session) ToggleSessionNotifcation

func (s *Session) ToggleSessionNotifcation(notification bool)

type Sessions

type Sessions struct {
	Sess       []*Session
	ActiveChat string
	Len        int
	Type       string
}

func (*Sessions) Get

func (s *Sessions) Get(tel string) *Session

func (*Sessions) GetIndex

func (s *Sessions) GetIndex(tel string) int

func (*Sessions) GetMessageList

func (s *Sessions) GetMessageList(id string) (error, *MessageList)

func (*Sessions) GetMoreMessageList

func (s *Sessions) GetMoreMessageList(id string, lastId string) (error, *MessageList)

func (*Sessions) GetSession

func (s *Sessions) GetSession(i int) *Session

func (*Sessions) UpdateSessionNames

func (s *Sessions) UpdateSessionNames()

Jump to

Keyboard shortcuts

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