1 /*
2 * Copyright (C) 2011-2020 Daniel Scharrer
3 *
4 * This software is provided 'as-is', without any express or implied
5 * warranty. In no event will the author(s) be held liable for any damages
6 * arising from the use of this software.
7 *
8 * Permission is granted to anyone to use this software for any purpose,
9 * including commercial applications, and to alter it and redistribute it
10 * freely, subject to the following restrictions:
11 *
12 * 1. The origin of this software must not be misrepresented; you must not
13 * claim that you wrote the original software. If you use this software
14 * in a product, an acknowledgment in the product documentation would be
15 * appreciated but is not required.
16 * 2. Altered source versions must be plainly marked as such, and must not be
17 * misrepresented as being the original software.
18 * 3. This notice may not be removed or altered from any source distribution.
19 */
20
21 #include "setup/icon.hpp"
22
23 #include "setup/info.hpp"
24 #include "setup/version.hpp"
25 #include "util/load.hpp"
26 #include "util/storedenum.hpp"
27
28 namespace setup {
29
30 namespace {
31
32 STORED_ENUM_MAP(stored_close_setting, icon_entry::NoSetting,
33 icon_entry::NoSetting,
34 icon_entry::CloseOnExit,
35 icon_entry::DontCloseOnExit,
36 );
37
38 } // anonymous namespace
39
load(std::istream & is,const info & i)40 void icon_entry::load(std::istream & is, const info & i) {
41
42 if(i.version < INNO_VERSION(1, 3, 0)) {
43 (void)util::load<boost::uint32_t>(is); // uncompressed size of the entry
44 }
45
46 is >> util::encoded_string(name, i.codepage, i.header.lead_bytes);
47 is >> util::encoded_string(filename, i.codepage, i.header.lead_bytes);
48 is >> util::encoded_string(parameters, i.codepage, i.header.lead_bytes);
49 is >> util::encoded_string(working_dir, i.codepage, i.header.lead_bytes);
50 is >> util::encoded_string(icon_file, i.codepage, i.header.lead_bytes);
51 is >> util::encoded_string(comment, i.codepage);
52
53 load_condition_data(is, i);
54
55 if(i.version >= INNO_VERSION(5, 3, 5)) {
56 is >> util::encoded_string(app_user_model_id, i.codepage);
57 } else {
58 app_user_model_id.clear();
59 }
60
61 if(i.version >= INNO_VERSION(6, 1, 0)) {
62 const size_t guid_size = 16;
63 app_user_model_toast_activator_clsid.resize(guid_size);
64 is.read(&app_user_model_toast_activator_clsid[0], std::streamsize(guid_size));
65 } else {
66 app_user_model_toast_activator_clsid.clear();
67 }
68
69 load_version_data(is, i.version);
70
71 icon_index = util::load<boost::int32_t>(is, i.version.bits());
72
73 if(i.version >= INNO_VERSION(1, 3, 24)) {
74 show_command = util::load<boost::int32_t>(is);
75 } else {
76 show_command = 1;
77 }
78 if(i.version >= INNO_VERSION(1, 3, 15)) {
79 close_on_exit = stored_enum<stored_close_setting>(is).get();
80 } else {
81 close_on_exit = NoSetting;
82 }
83
84 if(i.version >= INNO_VERSION(2, 0, 7)) {
85 hotkey = util::load<boost::uint16_t>(is);
86 } else {
87 hotkey = 0;
88 }
89
90 stored_flag_reader<flags> flagreader(is, i.version.bits());
91
92 flagreader.add(NeverUninstall);
93 if(i.version < INNO_VERSION(1, 3, 26)) {
94 flagreader.add(RunMinimized);
95 }
96 flagreader.add(CreateOnlyIfFileExists);
97 if(i.version.bits() != 16) {
98 flagreader.add(UseAppPaths);
99 }
100 if(i.version >= INNO_VERSION(5, 0, 3)) {
101 flagreader.add(FolderShortcut);
102 }
103 if(i.version >= INNO_VERSION(5, 4, 2)) {
104 flagreader.add(ExcludeFromShowInNewInstall);
105 }
106 if(i.version >= INNO_VERSION(5, 5, 0)) {
107 flagreader.add(PreventPinning);
108 }
109 if(i.version >= INNO_VERSION(6, 1, 0)) {
110 flagreader.add(HasAppUserModelToastActivatorCLSID);
111 }
112
113 options = flagreader;
114 }
115
116 } // namespace setup
117
118 NAMES(setup::icon_entry::flags, "Icon Option",
119 "never uninstall",
120 "create only if file exists",
121 "use app paths",
122 "folder shortcut",
123 "exclude from show in new install",
124 "prevent pinning",
125 "run minimized",
126 )
127
128 NAMES(setup::icon_entry::close_setting, "Close on Exit",
129 "no setting",
130 "close on exit",
131 "don't close on exit",
132 )
133