utils

package
v1.10.5 Latest Latest
Warning

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

Go to latest
Published: Feb 8, 2023 License: MIT Imports: 24 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// TypeImageDistro is a reletive path to any of the distributed images in cwtch/ui in the assets folder
	TypeImageDistro = "distro"
	// TypeImageComposition will be an face image composed of a recipe of parts like faceType, eyeType, etc
	TypeImageComposition = "composition"
)

Image types we support

View Source
const (
	Warn  = event.Field("Warn")
	Error = event.Field("Error")
	Debug = event.Field("Debug")
	Info  = event.Field("Info")
)

Logging Levels as Event Fields. Note: Unlike most event we don't cae about the *value* of the field, only the presence. If more than one of these fields is present in a single SetLoggingLevel event then the highest logging level is used. INFO < WARN < ERROR < DEBUG

View Source
const (
	CwtchStarted         = event.Type("CwtchStarted")
	CwtchStartError      = event.Type("CwtchStartError")
	UpdateGlobalSettings = event.Type("UpdateGlobalSettings")
)
View Source
const (
	NotificationPolicyMute       = NotificationPolicy("NotificationPolicy.Mute")
	NotificationPolicyOptIn      = NotificationPolicy("NotificationPolicy.OptIn")
	NotificationPolicyDefaultAll = NotificationPolicy("NotificationPolicy.DefaultAll")
)
View Source
const GlobalSettingsFilename = "ui.globals"
View Source
const (
	SetLoggingLevel = event.Type("SetLoggingLevel")
)

An event to set the logging level dynamically from the UI

Variables

View Source
var DefaultGlobalSettings = GlobalSettings{
	Locale:                  "en",
	Theme:                   "dark",
	PreviousPid:             -1,
	ExperimentsEnabled:      false,
	Experiments:             map[string]bool{constants.MessageFormattingExperiment: true},
	StateRootPane:           0,
	FirstTime:               true,
	BlockUnknownConnections: false,
	StreamerMode:            false,
	UIColumnModePortrait:    "DualpaneMode.Single",
	UIColumnModeLandscape:   "DualpaneMode.CopyPortrait",
	NotificationPolicy:      "NotificationPolicy.Mute",
	NotificationContent:     "NotificationContent.SimpleEvent",
	DownloadPath:            "",
	AllowAdvancedTorConfig:  false,
	CustomTorrc:             "",
	UseCustomTorrc:          false,
	CustomSocksPort:         -1,
	CustomControlPort:       -1,
	UseTorCache:             false,
	TorCacheDir:             "",
}
View Source
var GlobalSettingsFile v1.FileStore

Functions

func GetProfileImage added in v1.6.0

func GetProfileImage(profile peer.CwtchPeer, conversationInfo *model.Conversation, basepath string) string

func ImageToString

func ImageToString(img *image) string

func InitGlobalSettingsFile

func InitGlobalSettingsFile(directory string, password string) error

func NewImage

func NewImage(val, t string) *image

func RandomGroupImage

func RandomGroupImage(handle string) string

func RandomProfileImage

func RandomProfileImage(onion string) string

temporary until we do real picture selection

func StringToImage

func StringToImage(str string) (*image, error)

func WriteGlobalSettings

func WriteGlobalSettings(globalSettings GlobalSettings)

Types

type Contact

type Contact struct {
	Name               string                  `json:"name"`
	Onion              string                  `json:"onion"`
	Status             string                  `json:"status"`
	Picture            string                  `json:"picture"`
	DefaultPicture     string                  `json:"defaultPicture"`
	Accepted           bool                    `json:"accepted"`
	AccessControlList  model.AccessControlList `json:"accessControlList"`
	Blocked            bool                    `json:"blocked"`
	SaveHistory        string                  `json:"saveConversationHistory"`
	Messages           int                     `json:"numMessages"`
	Unread             int                     `json:"numUnread"`
	LastSeenMessageId  int                     `json:"lastSeenMessageId"`
	LastMessage        string                  `json:"lastMsgTime"`
	IsGroup            bool                    `json:"isGroup"`
	GroupServer        string                  `json:"groupServer"`
	IsArchived         bool                    `json:"isArchived"`
	Identifier         int                     `json:"identifier"`
	NotificationPolicy string                  `json:"notificationPolicy"`
	Attributes         map[string]string       `json:"attributes"`
}

type EventHandler

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

func NewEventHandler

func NewEventHandler(api LCG_API_Handler) *EventHandler

func (*EventHandler) GetNextEvent

func (eh *EventHandler) GetNextEvent() string

func (*EventHandler) HandleApp

func (eh *EventHandler) HandleApp(application app.Application)

func (*EventHandler) Push

func (eh *EventHandler) Push(newEvent event.Event)

Push pushes an event onto the app event bus

It is also a way for libCwtch-go to publish an event for consumption by a UI before a Cwtch app has been initialized
  use: to signal an error before a cwtch app could be created

type EventProfileEnvelope

type EventProfileEnvelope struct {
	Event   event.Event
	Profile string
}

type GlobalSettings

type GlobalSettings struct {
	Locale                  string
	Theme                   string
	ThemeMode               string
	PreviousPid             int64
	ExperimentsEnabled      bool
	Experiments             map[string]bool
	BlockUnknownConnections bool
	NotificationPolicy      NotificationPolicy
	NotificationContent     string
	StreamerMode            bool
	StateRootPane           int
	FirstTime               bool
	UIColumnModePortrait    string
	UIColumnModeLandscape   string
	DownloadPath            string
	AllowAdvancedTorConfig  bool
	CustomTorrc             string
	UseCustomTorrc          bool
	UseExternalTor          bool
	CustomSocksPort         int
	CustomControlPort       int
	UseTorCache             bool
	TorCacheDir             string
}

func ReadGlobalSettings

func ReadGlobalSettings() *GlobalSettings

type LCG_API_Handler added in v1.9.0

type LCG_API_Handler struct {
	LaunchServers func()
	StopServers   func()
}

type NotificationPolicy added in v1.6.0

type NotificationPolicy string

Jump to

Keyboard shortcuts

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