store

package
v0.5.1 Latest Latest
Warning

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

Go to latest
Published: Apr 1, 2018 License: GPL-3.0 Imports: 19 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// Signal fingerprint version
	FingerprintVersion = 0

	// The number of internal iterations to perform in the process of
	// generating a fingerprint
	Iterations = 5200
)
View Source
const (
	MessageSchema = `` /* 320-byte string literal not displayed */

	SentqSchema = `
		create table if not exists sentq
		(message_id integer primary key, timestamp timestamp)
	`
	SessionSchema = `` /* 322-byte string literal not displayed */

)
View Source
const (
	// Path to Sailfish read-only contacts database
	QtcontactsPath = "/home/nemo/.local/share/system/Contacts/qtcontacts-sqlite/contacts.db"
)

Variables

This section is empty.

Functions

func NumericFingerprint

func NumericFingerprint(localStableIdentifier string, localIdentityKey []byte, remoteStableIdentifier string, remoteIdentityKey []byte) string

Generate a displayable numeric fingerprint from the client's "stable" identifier localStableIdentifier, the client's identity key localIdentityKey, the remort party's stable identifier remoteStableIdentifier, and the remote party's identity key. Returns a unique fingerprint for the conversation. This is a port of libsignal-protocol-java NumericFingerprintGenerator.

Types

type Contact

type Contact struct {
	Name string `db:"name"`
	Tel  string `db:"tel"`
}

func SailfishContacts

func SailfishContacts(country string) ([]*Contact, error)

Get local sailfish contacts

type DataStore

type DataStore struct {
	// contains filtered or unexported fields
}
var DS *DataStore

func NewDataStore

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

Create new data store at path. If salt and password are provided the store will be encrypted

func (*DataStore) DBX

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

func (*DataStore) Decrypt

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

Decrypt database and closes connection

func (*DataStore) DeleteAllMessages

func (ds *DataStore) DeleteAllMessages(sid int64) error

func (*DataStore) DeleteMessage

func (ds *DataStore) DeleteMessage(id int64) error

func (*DataStore) DeleteSession

func (ds *DataStore) DeleteSession(id int64) error

func (*DataStore) DequeueSent

func (ds *DataStore) DequeueSent(id int64) error

func (*DataStore) Encrypt

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

Encrypt database and closes connection

func (*DataStore) FetchAllMessages

func (ds *DataStore) FetchAllMessages(sessionID int64) ([]*Message, error)

func (*DataStore) FetchAllSessions

func (ds *DataStore) FetchAllSessions() ([]*Session, error)

func (*DataStore) FetchMessage

func (ds *DataStore) FetchMessage(id int64) (*Message, error)

func (*DataStore) FetchQueuedMessage

func (ds *DataStore) FetchQueuedMessage(id int64) (*Message, error)

func (*DataStore) FetchSentq

func (ds *DataStore) FetchSentq() ([]*Message, error)

func (*DataStore) FetchSession

func (ds *DataStore) FetchSession(id int64) (*Session, error)

func (*DataStore) FetchSessionByGroupID

func (ds *DataStore) FetchSessionByGroupID(groupID string) (*Session, error)

func (*DataStore) FetchSessionBySource

func (ds *DataStore) FetchSessionBySource(source string) (*Session, error)

func (*DataStore) MarkMessageReceived

func (ds *DataStore) MarkMessageReceived(source string, ts uint64) (int64, int64, error)

func (*DataStore) MarkMessageSent

func (ds *DataStore) MarkMessageSent(id int64, ts uint64) error

func (*DataStore) MarkSessionRead

func (ds *DataStore) MarkSessionRead(id int64) error

func (*DataStore) MarkSessionSent

func (ds *DataStore) MarkSessionSent(id int64, msg string, ts uint64) error

func (*DataStore) ProcessMessage

func (ds *DataStore) ProcessMessage(message *Message, group *textsecure.Group, unread bool) (*Session, error)

Process message and store in database and update or create a session

func (*DataStore) QueueSent

func (ds *DataStore) QueueSent(message *Message) error

func (*DataStore) SaveMessage

func (ds *DataStore) SaveMessage(msg *Message) error

func (*DataStore) SaveSession

func (ds *DataStore) SaveSession(session *Session) error

func (*DataStore) TotalMessages

func (ds *DataStore) TotalMessages() (int, error)

func (*DataStore) TotalUnread

func (ds *DataStore) TotalUnread() (int, error)

type Message

type Message struct {
	ID            int64  `db:"id"`
	SID           int64  `db:"session_id"`
	Source        string `db:"source"`
	Message       string `db:"message"`
	Timestamp     uint64 `db:"timestamp"`
	Outgoing      bool   `db:"outgoing"`
	Sent          bool   `db:"sent"`
	Received      bool   `db:"received"`
	Attachment    string `db:"attachment"`
	MimeType      string `db:"mime_type"`
	HasAttachment bool   `db:"has_attachment"`
	Flags         uint32 `db:"flags"`
	Queued        bool   `db:"queued"`
}

func (*Message) SaveAttachment

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

type Session

type Session struct {
	ID            int64  `db:"id"`
	Source        string `db:"source"`
	IsGroup       bool   `db:"is_group"`
	GroupID       string `db:"group_id"`
	GroupName     string `db:"group_name"`
	Members       string `db:"group_members"`
	Message       string `db:"message"`
	Section       string `db:"-"`
	Timestamp     uint64 `db:"timestamp"`
	Unread        bool   `db:"unread"`
	Sent          bool   `db:"sent"`
	Received      bool   `db:"received"`
	HasAttachment bool   `db:"has_attachment"`
}

Jump to

Keyboard shortcuts

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