dbafa5b11b4a57e714769337dd17134a01c79f93
[freerdp-ubuntu-pcb-backport.git] / libfreerdp-core / settings.c
1 /**
2  * FreeRDP: A Remote Desktop Protocol Client
3  * RDP Settings
4  *
5  * Copyright 2009-2011 Jay Sorg
6  *
7  * Licensed under the Apache License, Version 2.0 (the "License");
8  * you may not use this file except in compliance with the License.
9  * You may obtain a copy of the License at
10  *
11  *     http://www.apache.org/licenses/LICENSE-2.0
12  *
13  * Unless required by applicable law or agreed to in writing, software
14  * distributed under the License is distributed on an "AS IS" BASIS,
15  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16  * See the License for the specific language governing permissions and
17  * limitations under the License.
18  */
19
20 #include "config.h"
21 #include "capabilities.h"
22 #include <freerdp/utils/memory.h>
23
24 #ifdef HAVE_UNISTD_H
25 #include <unistd.h>
26 #endif
27
28 #include <freerdp/settings.h>
29 #include <freerdp/utils/file.h>
30
31 static const char client_dll[] = "C:\\Windows\\System32\\mstscax.dll";
32
33 rdpSettings* settings_new(void* instance)
34 {
35         rdpSettings* settings;
36
37         settings = (rdpSettings*) xzalloc(sizeof(rdpSettings));
38
39         if (settings != NULL)
40         {
41                 settings->instance = instance;
42
43                 settings->width = 1024;
44                 settings->height = 768;
45                 settings->workarea = false;
46                 settings->fullscreen = false;
47                 settings->grab_keyboard = true;
48                 settings->decorations = true;
49                 settings->rdp_version = 7;
50                 settings->color_depth = 16;
51                 settings->nla_security = true;
52                 settings->tls_security = true;
53                 settings->rdp_security = true;
54                 settings->client_build = 2600;
55                 settings->kbd_type = 0;
56                 settings->kbd_subtype = 0;
57                 settings->kbd_fn_keys = 0;
58                 settings->kbd_layout = 0;
59                 settings->encryption = false;
60                 settings->secure_checksum = false;
61                 settings->port = 3389;
62                 settings->desktop_resize = true;
63
64                 settings->performance_flags =
65                                 PERF_DISABLE_FULLWINDOWDRAG |
66                                 PERF_DISABLE_MENUANIMATIONS |
67                                 PERF_DISABLE_WALLPAPER;
68
69                 settings->auto_reconnection = true;
70
71                 settings->encryption_method = ENCRYPTION_METHOD_NONE;
72                 settings->encryption_level = ENCRYPTION_LEVEL_NONE;
73
74                 settings->authentication = true;
75
76                 settings->order_support[NEG_DSTBLT_INDEX] = true;
77                 settings->order_support[NEG_PATBLT_INDEX] = true;
78                 settings->order_support[NEG_SCRBLT_INDEX] = true;
79                 settings->order_support[NEG_OPAQUE_RECT_INDEX] = true;
80                 settings->order_support[NEG_DRAWNINEGRID_INDEX] = true;
81                 settings->order_support[NEG_MULTIDSTBLT_INDEX] = true;
82                 settings->order_support[NEG_MULTIPATBLT_INDEX] = true;
83                 settings->order_support[NEG_MULTISCRBLT_INDEX] = true;
84                 settings->order_support[NEG_MULTIOPAQUERECT_INDEX] = true;
85                 settings->order_support[NEG_MULTI_DRAWNINEGRID_INDEX] = true;
86                 settings->order_support[NEG_LINETO_INDEX] = true;
87                 settings->order_support[NEG_POLYLINE_INDEX] = true;
88                 settings->order_support[NEG_MEMBLT_INDEX] = true;
89                 settings->order_support[NEG_MEM3BLT_INDEX] = true;
90                 settings->order_support[NEG_SAVEBITMAP_INDEX] = true;
91                 settings->order_support[NEG_GLYPH_INDEX_INDEX] = true;
92                 settings->order_support[NEG_FAST_INDEX_INDEX] = true;
93                 settings->order_support[NEG_FAST_GLYPH_INDEX] = true;
94                 settings->order_support[NEG_POLYGON_SC_INDEX] = true;
95                 settings->order_support[NEG_POLYGON_CB_INDEX] = true;
96                 settings->order_support[NEG_ELLIPSE_SC_INDEX] = true;
97                 settings->order_support[NEG_ELLIPSE_CB_INDEX] = true;
98
99                 settings->color_pointer = true;
100                 settings->large_pointer = true;
101                 settings->pointer_cache_size = 20;
102                 settings->sound_beeps = true;
103                 settings->disable_wallpaper = false;
104                 settings->disable_full_window_drag = false;
105                 settings->disable_menu_animations = false;
106                 settings->disable_theming = false;
107                 settings->connection_type = 0;
108
109                 settings->draw_gdi_plus = false;
110
111                 settings->frame_marker = false;
112                 settings->bitmap_cache_v3 = false;
113
114                 settings->bitmap_cache = true;
115                 settings->persistent_bitmap_cache = false;
116                 settings->bitmapCacheV2CellInfo = xzalloc(sizeof(BITMAP_CACHE_V2_CELL_INFO) * 6);
117
118                 settings->refresh_rect = true;
119                 settings->suppress_output = true;
120
121                 settings->glyph_cache = true;
122                 settings->glyphSupportLevel = GLYPH_SUPPORT_NONE;
123                 settings->glyphCache = xzalloc(sizeof(GLYPH_CACHE_DEFINITION) * 10);
124                 settings->fragCache = xnew(GLYPH_CACHE_DEFINITION);
125                 settings->glyphCache[0].cacheEntries = 254;
126                 settings->glyphCache[0].cacheMaximumCellSize = 4;
127                 settings->glyphCache[1].cacheEntries = 254;
128                 settings->glyphCache[1].cacheMaximumCellSize = 4;
129                 settings->glyphCache[2].cacheEntries = 254;
130                 settings->glyphCache[2].cacheMaximumCellSize = 8;
131                 settings->glyphCache[3].cacheEntries = 254;
132                 settings->glyphCache[3].cacheMaximumCellSize = 8;
133                 settings->glyphCache[4].cacheEntries = 254;
134                 settings->glyphCache[4].cacheMaximumCellSize = 16;
135                 settings->glyphCache[5].cacheEntries = 254;
136                 settings->glyphCache[5].cacheMaximumCellSize = 32;
137                 settings->glyphCache[6].cacheEntries = 254;
138                 settings->glyphCache[6].cacheMaximumCellSize = 64;
139                 settings->glyphCache[7].cacheEntries = 254;
140                 settings->glyphCache[7].cacheMaximumCellSize = 128;
141                 settings->glyphCache[8].cacheEntries = 254;
142                 settings->glyphCache[8].cacheMaximumCellSize = 256;
143                 settings->glyphCache[9].cacheEntries = 64;
144                 settings->glyphCache[9].cacheMaximumCellSize = 256;
145                 settings->fragCache->cacheEntries = 256;
146                 settings->fragCache->cacheMaximumCellSize = 256;
147
148                 settings->offscreen_bitmap_cache = true;
149                 settings->offscreen_bitmap_cache_size = 7680;
150                 settings->offscreen_bitmap_cache_entries = 100;
151
152                 settings->draw_nine_grid_cache_size = 2560;
153                 settings->draw_nine_grid_cache_entries = 256;
154
155                 settings->client_dir = xstrdup(client_dll);
156
157                 settings->num_icon_caches = 3;
158                 settings->num_icon_cache_entries = 12;
159
160                 settings->vc_chunk_size = CHANNEL_CHUNK_LENGTH;
161
162                 settings->multifrag_max_request_size = 0x200000;
163
164                 settings->fastpath_input = true;
165                 settings->fastpath_output = true;
166
167                 settings->uniconv = freerdp_uniconv_new();
168                 gethostname(settings->client_hostname, sizeof(settings->client_hostname) - 1);
169                 settings->mouse_motion = true;
170
171                 settings->client_auto_reconnect_cookie = xnew(ARC_CS_PRIVATE_PACKET);
172                 settings->server_auto_reconnect_cookie = xnew(ARC_SC_PRIVATE_PACKET);
173
174                 settings->client_time_zone = xnew(TIME_ZONE_INFO);
175                 settings->server_random = xnew(rdpBlob);
176                 settings->server_certificate = xnew(rdpBlob);
177
178                 freerdp_detect_paths(settings);
179         }
180
181         return settings;
182 }
183
184 void settings_free(rdpSettings* settings)
185 {
186         if (settings != NULL)
187         {
188                 freerdp_uniconv_free(settings->uniconv);
189                 xfree(settings->hostname);
190                 xfree(settings->username);
191                 xfree(settings->password);
192                 xfree(settings->domain);
193                 xfree(settings->shell);
194                 xfree(settings->directory);
195                 xfree(settings->ip_address);
196                 xfree(settings->client_dir);
197                 xfree(settings->cert_file);
198                 xfree(settings->privatekey_file);
199                 freerdp_blob_free(settings->server_random);
200                 freerdp_blob_free(settings->server_certificate);
201                 xfree(settings->server_random);
202                 xfree(settings->server_certificate);
203                 xfree(settings->rdp_key_file);
204                 certificate_free(settings->server_cert);
205                 xfree(settings->client_auto_reconnect_cookie);
206                 xfree(settings->server_auto_reconnect_cookie);
207                 xfree(settings->client_time_zone);
208                 xfree(settings->bitmapCacheV2CellInfo);
209                 xfree(settings->glyphCache);
210                 xfree(settings->fragCache);
211                 key_free(settings->server_key);
212                 xfree(settings->config_path);
213                 xfree(settings->current_path);
214                 xfree(settings->development_path);
215                 xfree(settings);
216         }
217 }