Peer invitation refactor, Contact invitationId, Qrcode compression
This commit is contained in:
76
client/config.go
Normal file
76
client/config.go
Normal file
@ -0,0 +1,76 @@
|
||||
package client
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
"io/ioutil"
|
||||
"sync"
|
||||
)
|
||||
|
||||
type Config struct {
|
||||
// UserConfig
|
||||
SavePassword bool `json:"save_password,omitempty"`
|
||||
SavedPassword string `json:"saved_password,omitempty"`
|
||||
// Technical
|
||||
StoragePath string `json:"storage_path,omitempty"`
|
||||
MaxIdsPerUser int `json:"max_ids_per_user,omitempty"`
|
||||
MsgDbRollingPeriod int `json:"msg_db_rolling_period,omitempty"`
|
||||
Chunksize int `json:"chunksize,omitempty"`
|
||||
ServerPollInterval int `json:"server_poll_interval,omitempty"`
|
||||
// GUI
|
||||
LastOpenChat string `json:"last_open_chat,omitempty"`
|
||||
SoundNotification bool `json:"sound_notification,omitempty"`
|
||||
DefaultNotificationSound string `json:"default_notification_sound,omitempty"`
|
||||
NotificationVibe string `json:"notification_vibe,omitempty"`
|
||||
DefaultNotificationVibe string `json:"default_notification_vibe,omitempty"`
|
||||
NotificationLED string `json:"notification_led,omitempty"`
|
||||
DefaultNotificationLEDColor string `json:"default_notification_led_color,omitempty"`
|
||||
VisualNotification bool `json:"visual_notification,omitempty"`
|
||||
VisualNotifiactionModes string `json:"visual_notifiaction_modes,omitempty"`
|
||||
PrivateChatNotifiactions bool `json:"private_chat_notifiactions,omitempty"`
|
||||
GroupChatNotifiactions bool `json:"group_chat_notifiactions,omitempty"`
|
||||
ChannelNotifications bool `json:"channel_notifications,omitempty"`
|
||||
// Inner
|
||||
memoryPassword string `json:"memory_password,omitempty"`
|
||||
}
|
||||
|
||||
var instance *Config
|
||||
var once sync.Once
|
||||
|
||||
func GetConfig() *Config {
|
||||
once.Do(func() {
|
||||
instance = &Config{}
|
||||
})
|
||||
return instance
|
||||
}
|
||||
|
||||
func (c *Config) Load(filename string) error {
|
||||
data, err := ioutil.ReadFile(filename)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
err = json.Unmarshal(data, c)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func (c *Config) Save(filename string) error {
|
||||
data, err := json.Marshal(c)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
ioutil.WriteFile(filename, data, 0644)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func (c *Config) SetMemPass(pass string) {
|
||||
c.memoryPassword = pass
|
||||
}
|
||||
|
||||
func (c *Config) GetMemPass() string {
|
||||
return c.memoryPassword
|
||||
}
|
Reference in New Issue
Block a user