1 /*
2  * Remmina - The GTK+ Remote Desktop Client
3  * Copyright (C) 2009-2011 Vic Lee
4  * Copyright (C) 2014-2015 Antenore Gatta, Fabio Castelli, Giovanni Panozzo
5  * Copyright (C) 2016-2021 Antenore Gatta, Giovanni Panozzo
6  *
7  * This program is free software; you can redistribute it and/or modify
8  * it under the terms of the GNU General Public License as published by
9  * the Free Software Foundation; either version 2 of the License, or
10  * (at your option) any later version.
11  *
12  * This program is distributed in the hope that it will be useful,
13  * but WITHOUT ANY WARRANTY; without even the implied warranty of
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15  * GNU General Public License for more details.
16  *
17  * You should have received a copy of the GNU General Public License
18  * along with this program; if not, write to the Free Software
19  * Foundation, Inc., 51 Franklin Street, Fifth Floor,
20  * Boston, MA  02110-1301, USA.
21  *
22  *  In addition, as a special exception, the copyright holders give
23  *  permission to link the code of portions of this program with the
24  *  OpenSSL library under certain conditions as described in each
25  *  individual source file, and distribute linked combinations
26  *  including the two.
27  *  You must obey the GNU General Public License in all respects
28  *  for all of the code used other than OpenSSL. *  If you modify
29  *  file(s) with this exception, you may extend this exception to your
30  *  version of the file(s), but you are not obligated to do so. *  If you
31  *  do not wish to do so, delete this exception statement from your
32  *  version. *  If you delete this exception statement from all source
33  *  files in the program, then also delete it here.
34  *
35  */
36 
37 #pragma once
38 #include <gtk/gtk.h>
39 
40 /*
41  * Remmina Preference Loader
42  */
43 
44 G_BEGIN_DECLS
45 
46 enum {
47 	REMMINA_VIEW_FILE_LIST,
48 	REMMINA_VIEW_FILE_TREE
49 };
50 
51 enum {
52 	REMMINA_ACTION_CONNECT	= 0,
53 	REMMINA_ACTION_EDIT	= 1
54 };
55 
56 enum {
57 	UNDEFINED_MODE			= 0,
58 	SCROLLED_WINDOW_MODE		= 1,
59 	FULLSCREEN_MODE			= 2,
60 	SCROLLED_FULLSCREEN_MODE	= 3,
61 	VIEWPORT_FULLSCREEN_MODE	= 4
62 };
63 
64 enum {
65 	FLOATING_TOOLBAR_PLACEMENT_TOP		= 0,
66 	FLOATING_TOOLBAR_PLACEMENT_BOTTOM	= 1
67 };
68 
69 enum {
70 	TOOLBAR_PLACEMENT_TOP		= 0,
71 	TOOLBAR_PLACEMENT_RIGHT		= 1,
72 	TOOLBAR_PLACEMENT_BOTTOM	= 2,
73 	TOOLBAR_PLACEMENT_LEFT		= 3
74 };
75 
76 enum {
77 	REMMINA_TAB_BY_GROUP	= 0,
78 	REMMINA_TAB_BY_PROTOCOL = 1,
79 	REMMINA_TAB_ALL		= 2,
80 	REMMINA_TAB_NONE	= 3
81 };
82 
83 enum {
84 	FLOATING_TOOLBAR_VISIBILITY_PEEKING	= 0,
85 	FLOATING_TOOLBAR_VISIBILITY_INVISIBLE	= 1, //"Invisible" corresponds to the "Hidden" option in the drop-down
86 	FLOATING_TOOLBAR_VISIBILITY_DISABLE	= 2
87 };
88 
89 typedef struct _RemminaColorPref {
90 	/* Color palette for VTE terminal */
91 	gchar * background;
92 	gchar * cursor;
93 	gchar * cursor_foreground;
94 	gchar * highlight;
95 	gchar * highlight_foreground;
96 	gchar * colorBD;
97 	gchar * foreground;
98 	gchar * color0;
99 	gchar * color1;
100 	gchar * color2;
101 	gchar * color3;
102 	gchar * color4;
103 	gchar * color5;
104 	gchar * color6;
105 	gchar * color7;
106 	gchar * color8;
107 	gchar * color9;
108 	gchar * color10;
109 	gchar * color11;
110 	gchar * color12;
111 	gchar * color13;
112 	gchar * color14;
113 	gchar * color15;
114 } RemminaColorPref;
115 
116 typedef struct _RemminaPref {
117 	/* In RemminaPrefDialog options tab */
118 	const gchar *		datadir_path;
119 	const gchar *		remmina_file_name;
120 	const gchar *		screenshot_path;
121 	gboolean		deny_screenshot_clipboard;
122 	const gchar *		screenshot_name;
123 	gboolean		save_view_mode;
124 	gint			default_action;
125 	gint			scale_quality;
126 	gint			auto_scroll_step;
127 	gint			recent_maximum;
128 	gchar *			resolutions;
129 	gchar *			keystrokes;
130 	/* In RemminaPrefDialog appearance tab */
131 	gboolean		dark_theme;
132 	gboolean		fullscreen_on_auto;
133 	gboolean		always_show_tab;
134 	gboolean		hide_connection_toolbar;
135 	gboolean		hide_searchbar;
136 	gint			default_mode;
137 	gint			tab_mode;
138 	gint			fullscreen_toolbar_visibility;
139 	const gchar *		grab_color;
140 	gboolean		grab_color_switch;
141 	/* In RemminaPrefDialog applet tab */
142 	gboolean		applet_new_ontop;
143 	gboolean		applet_hide_count;
144 	gboolean		disable_tray_icon;
145 	/* In RemminaPrefDialog SSH Option tab */
146 	gint			ssh_loglevel;
147 	gboolean		ssh_parseconfig;
148 	gint			sshtunnel_port;
149 	gint			ssh_tcp_keepidle;
150 	gint			ssh_tcp_keepintvl;
151 	gint			ssh_tcp_keepcnt;
152 	gint			ssh_tcp_usrtimeout;
153 	/* In RemminaPrefDialog keyboard tab */
154 	guint			hostkey;
155 	guint			shortcutkey_fullscreen;
156 	guint			shortcutkey_autofit;
157 	guint			shortcutkey_prevtab;
158 	guint			shortcutkey_nexttab;
159 	guint			shortcutkey_dynres;
160 	guint			shortcutkey_scale;
161 	guint			shortcutkey_multimon;
162 	guint			shortcutkey_grab;
163 	guint			shortcutkey_viewonly;
164 	guint			shortcutkey_screenshot;
165 	guint			shortcutkey_minimize;
166 	guint			shortcutkey_disconnect;
167 	guint			shortcutkey_toolbar;
168 	/* In RemminaPrefDialog security tab */
169 	gboolean		use_master_password;
170 	const gchar *		unlock_password;
171 	const gchar *		unlock_repassword;
172 	gint			unlock_timeout;
173 	gboolean		trust_all;
174 	/* In RemminaPrefDialog terminal tab */
175 	gchar *			vte_font;
176 	gboolean		vte_allow_bold_text;
177 	gboolean		vte_system_colors;
178 	gint			vte_lines;
179 	guint			vte_shortcutkey_copy;
180 	guint			vte_shortcutkey_paste;
181 	guint			vte_shortcutkey_select_all;
182 	guint			vte_shortcutkey_increase_font;
183 	guint			vte_shortcutkey_decrease_font;
184 	guint			vte_shortcutkey_search_text;
185 	/* In View menu */
186 	gboolean		hide_toolbar;
187 	gboolean		small_toolbutton;
188 	gint			view_file_mode;
189 	/* In tray icon */
190 	gboolean		applet_enable_avahi;
191 	/* Auto */
192 	gint			main_width;
193 	gint			main_height;
194 	gboolean		main_maximize;
195 	gint			main_sort_column_id;
196 	gint			main_sort_order;
197 	gchar *			expanded_group;
198 	gboolean		toolbar_pin_down;
199 	gint			floating_toolbar_placement;
200 	gint			toolbar_placement;
201 	gboolean		prevent_snap_welcome_message;
202 	gchar *			last_quickconnect_protocol;
203 
204 	/* Crypto */
205 	gchar *			secret;
206 
207 	/* UID */
208 	gchar *			uid;
209 
210 	RemminaColorPref	color_pref;
211 
212 	/* Usage stats */
213 	gboolean		periodic_usage_stats_permitted;
214 	glong			periodic_usage_stats_last_sent;
215 	gchar *			periodic_usage_stats_uuid_prefix;
216 	gchar *			last_success;
217 
218 	/* Remmina news */
219 	gboolean		periodic_news_permitted;
220 	glong			periodic_rmnews_last_get;
221 	glong			periodic_rmnews_get_count;
222 	gchar *			periodic_rmnews_uuid_prefix;
223 } RemminaPref;
224 
225 #define DEFAULT_SSH_PARSECONFIG TRUE
226 #define DEFAULT_SSHTUNNEL_PORT 4732
227 #define DEFAULT_SSH_PORT 22
228 #define DEFAULT_SSH_LOGLEVEL 1
229 #define SSH_SOCKET_TCP_KEEPIDLE 20
230 #define SSH_SOCKET_TCP_KEEPINTVL 10
231 #define SSH_SOCKET_TCP_KEEPCNT 3
232 #define SSH_SOCKET_TCP_USER_TIMEOUT 60000 // 60 seconds
233 
234 extern const gchar *default_resolutions;
235 extern gchar *remmina_pref_file;
236 extern gchar *remmina_colors_file;
237 extern RemminaPref remmina_pref;
238 
239 void remmina_pref_init(void);
240 gboolean remmina_pref_is_rw(void);
241 gboolean remmina_pref_save(void);
242 
243 void remmina_pref_add_recent(const gchar *protocol, const gchar *server);
244 gchar *remmina_pref_get_recent(const gchar *protocol);
245 void remmina_pref_clear_recent(void);
246 
247 guint remmina_pref_keymap_get_keyval(const gchar *keymap, guint keyval);
248 gchar **remmina_pref_keymap_groups(void);
249 
250 gint remmina_pref_get_scale_quality(void);
251 gint remmina_pref_get_ssh_loglevel(void);
252 gboolean remmina_pref_get_ssh_parseconfig(void);
253 gint remmina_pref_get_sshtunnel_port(void);
254 void remmina_pref_file_load_colors(GKeyFile *gkeyfile, RemminaColorPref *color_pref);
255 gint remmina_pref_get_ssh_tcp_keepidle(void);
256 gint remmina_pref_get_ssh_tcp_keepintvl(void);
257 gint remmina_pref_get_ssh_tcp_keepcnt(void);
258 gint remmina_pref_get_ssh_tcp_usrtimeout(void);
259 
260 void remmina_pref_set_value(const gchar *key, const gchar *value);
261 gchar *remmina_pref_get_value(const gchar *key);
262 gboolean remmina_pref_get_boolean(const gchar *key);
263 
264 G_END_DECLS
265