1 #ifndef SETTINGS_H
2 #define SETTINGS_H
3 
4 typedef struct utox_save UTOX_SAVE;
5 
6 #include "debug.h"
7 #include "../langs/i18n_decls.h"
8 
9 #include <stdio.h>
10 #include <stdint.h>
11 #include <stdbool.h>
12 
13 #define DEFAULT_FPS 25
14 
15 extern uint16_t loaded_audio_in_device, loaded_audio_out_device;
16 
17 typedef struct utox_settings {
18     // uTox versions settings
19     uint32_t last_version;
20     uint32_t curr_version;
21     uint32_t next_version;
22 
23     bool     show_splash;
24 
25     // Low level settings (network, profile, portable-mode)
26     bool portable_mode;
27 
28     bool save_encryption;
29 
30     bool auto_update;       /* Unused, included for compatibility */
31     bool update_to_develop; /* Unused, included for compatibility */
32     bool send_version;      /* Unused, included for compatibility */
33 
34     bool force_proxy;
35     bool enable_udp;
36     bool enable_ipv6;
37 
38     bool block_friend_requests;
39 
40     bool use_proxy;
41     uint16_t proxy_port;
42 
43     // User interface settings
44     UTOX_LANG language;
45     bool audiofilter_enabled;
46     bool push_to_talk;
47     bool audio_preview;
48     bool video_preview;
49     bool send_typing_status;
50     bool inline_video;
51     bool use_long_time_msg;
52     bool accept_inline_images;
53 
54     // UX Settings
55     bool logging_enabled;
56     bool close_to_tray;
57     bool start_in_tray;
58     bool start_with_system;
59     bool use_mini_flist;
60     bool magic_flist_enabled;
61 
62     // Notifications / Alerts
63     bool    ringtone_enabled;
64     bool    status_notifications;
65     uint8_t group_notifications;
66 
67     LOG_LVL verbose;
68     FILE *debug_file;
69 
70     uint32_t theme;
71 
72     // OS interface settings
73     uint32_t window_x;
74     uint32_t window_y;
75     uint32_t window_height;
76     uint32_t window_width;
77     uint32_t window_baseline;
78 
79     bool    window_maximized;
80     uint8_t video_fps;
81 } SETTINGS;
82 
83 extern SETTINGS settings;
84 
85 /* House keeping for uTox save file. */
86 #define UTOX_SAVE_VERSION 3
87 typedef struct utox_save {
88     uint8_t save_version;
89     uint8_t scale;
90     uint8_t enableipv6;
91     uint8_t disableudp;
92 
93     uint16_t window_x, window_y, window_width, window_height;
94     uint16_t proxy_port;
95 
96     uint8_t proxyenable;
97 
98     uint8_t logging_enabled : 1;
99     uint8_t audible_notifications_enabled : 1;
100     uint8_t filter : 1;
101     uint8_t audio_filtering_enabled : 1;
102     uint8_t close_to_tray : 1;
103     uint8_t start_in_tray : 1;
104     uint8_t auto_startup : 1;
105     uint8_t no_typing_notifications : 1;
106 
107     uint16_t audio_device_in;
108     uint16_t audio_device_out;
109 
110     uint8_t theme;
111 
112     uint8_t push_to_talk         : 1;
113     uint8_t use_mini_flist       : 1;
114     uint8_t group_notifications  : 4;
115     uint8_t status_notifications : 1;
116     uint8_t magic_flist_enabled  : 1;
117 
118     uint32_t utox_last_version; // I don't like this here either,
119     // but I'm not ready to rewrite and update this struct yet.
120 
121     uint8_t auto_update         : 1; /* Unused, included for compatibility */
122     uint8_t update_to_develop   : 1; /* Unused, included for compatibility */
123     uint8_t send_version        : 1; /* Unused, included for compatibility */
124     uint8_t zero_2              : 5;
125     uint8_t zero_3              : 8;
126 
127     uint16_t language;
128     uint8_t video_fps;
129     uint8_t force_proxy;
130     uint8_t use_long_time_msg;
131 
132     uint8_t  unused[51];
133     uint8_t  proxy_ip[];
134 } UTOX_SAVE;
135 
136 /*
137  * Loads the config file and returns a settings struct
138  */
139 UTOX_SAVE *config_load(void);
140 
141 /*
142  * Writes save_in to the disk
143  */
144 void config_save(UTOX_SAVE *save_in);
145 
146 
147 /**
148  * Saves the settings for uTox
149  *
150  * Returns a bool indicating if it succeeded or not
151  */
152 bool utox_data_save_utox(UTOX_SAVE *data, size_t length);
153 
154 /**
155  * Loads uTox settings
156  *
157  * Returns a memory pointer of *size, the caller needs to free this
158  * Returns NULL on failure
159  */
160 UTOX_SAVE *utox_data_load_utox(void);
161 
162 #endif
163