Changeset e11d494 in nscp for helpers/installer-dlls/main_dll
- Timestamp:
- 07/25/11 23:16:48 (22 months ago)
- Branches:
- master, 0.4.0, 0.4.1, 0.4.2
- Children:
- 04ef932
- Parents:
- 7ec3dd1
- File:
-
- 1 edited
-
helpers/installer-dlls/main_dll/main_dll.cpp (modified) (4 diffs)
Legend:
- Unmodified
- Added
- Removed
-
helpers/installer-dlls/main_dll/main_dll.cpp
r3bdaf18 re11d494 114 114 class installer_logger : public settings::logger_interface { 115 115 public: 116 msi_helper &h;116 msi_helper *h; 117 117 std::wstring error; 118 119 installer_logger(msi_helper &h) : h(h) {} 118 std::list<std::wstring> debug_log; 119 120 installer_logger(msi_helper *h) : h(h) {} 120 121 121 122 virtual void err(std::string file, int line, std::wstring message) { 122 123 error = message; 123 h.logMessage(_T("ERROR: ") + message); 124 h->logMessage(_T("ERROR: ") + message); 125 debug_log.push_back(_T("ERROR: ") + message); 124 126 } 125 127 virtual void warn(std::string file, int line, std::wstring message) { 126 h.logMessage(_T("WARN: ") + message); 128 h->logMessage(_T("WARN: ") + message); 129 debug_log.push_back(_T("WARN: ") + message); 127 130 } 128 131 virtual void info(std::string file, int line, std::wstring message) { 129 h.logMessage(_T("INFO: ") + message); 130 } 131 virtual void debug(std::string file, int line, std::wstring message) {} 132 h->logMessage(_T("INFO: ") + message); 133 debug_log.push_back(_T("INFO: ") + message); 134 } 135 virtual void debug(std::string file, int line, std::wstring message) { 136 debug_log.push_back(_T("DEBUG: ") + message); 137 } 138 std::list<std::wstring> get_debug() { 139 return debug_log; 140 } 132 141 }; 133 142 134 143 struct installer_settings_provider : public settings_manager::provider_interface { 135 144 136 msi_helper &h;145 msi_helper *h; 137 146 std::wstring basepath; 138 147 installer_logger logger; 139 148 140 installer_settings_provider(msi_helper &h, std::wstring basepath) : h(h), logger(h), basepath(basepath) {}149 installer_settings_provider(msi_helper *h, std::wstring basepath) : h(h), logger(h), basepath(basepath) {} 141 150 142 151 virtual std::wstring expand_path(std::wstring file) { … … 157 166 std::wstring get_error() { 158 167 return logger.error; 168 } 169 std::list<std::wstring> get_debug() { 170 return logger.get_debug(); 159 171 } 160 172 }; … … 199 211 } 200 212 201 installer_settings_provider provider( h, target);213 installer_settings_provider provider(&h, target); 202 214 if (!settings_manager::init_settings(&provider, _T(""))) { 215 h.logMessage(_T("Settings context had fatal errors")); 203 216 h.setProperty(_T("CONF_OLD_ERROR"), provider.get_error()); 204 217 h.setProperty(_T("CONF_CAN_CHANGE"), _T("0")); 205 218 h.setProperty(_T("CONF_OLD_FOUND"), _T("0")); 206 219 h.setProperty(_T("CONF_HAS_ERRORS"), _T("1")); 207 return ERROR_SUCCESS;208 220 } 209 221 if (provider.has_error()) { 210 h.setProperty(_T("CONF_OLD_ERROR"), provider.get_error()); 211 h.setProperty(_T("CONF_CAN_CHANGE"), _T("0")); 212 h.setProperty(_T("CONF_OLD_FOUND"), _T("0")); 213 h.setProperty(_T("CONF_HAS_ERRORS"), _T("1")); 214 return ERROR_SUCCESS; 215 } 222 h.logMessage(_T("Settings context reported errors (debug log end)")); 223 BOOST_FOREACH(std::wstring l, provider.get_debug()) { 224 h.logMessage(l); 225 } 226 h.logMessage(_T("Settings context reported errors (debug log end)")); 227 if (!settings_manager::has_boot_conf()) { 228 h.logMessage(_T("boot.conf was NOT found (so no new configuration)")); 229 if (settings_manager::context_exists(DEFAULT_CONF_OLD_LOCATION)) { 230 h.logMessage(std::wstring(_T("Old configuration found: ")) + DEFAULT_CONF_OLD_LOCATION); 231 h.setProperty(_T("CONF_OLD_ERROR"), std::wstring(_T("Old configuration (")) + DEFAULT_CONF_OLD_LOCATION + _T(") was found but we got errors accessing it: ") + provider.get_error()); 232 h.setProperty(_T("CONF_CAN_CHANGE"), _T("0")); 233 h.setProperty(_T("CONF_OLD_FOUND"), _T("0")); 234 h.setProperty(_T("CONF_HAS_ERRORS"), _T("1")); 235 return ERROR_SUCCESS; 236 } else { 237 h.logMessage(_T("Failed to read configuration but no configuration was found (so we are assuming there is no configuration).")); 238 h.setProperty(_T("CONF_CAN_CHANGE"), _T("1")); 239 h.setProperty(_T("CONF_OLD_FOUND"), _T("0")); 240 h.setProperty(_T("CONF_HAS_ERRORS"), _T("0")); 241 return ERROR_SUCCESS; 242 } 243 } else { 244 h.logMessage(_T("boot.conf was found but we got errors booting it...")); 245 h.setProperty(_T("CONF_OLD_ERROR"), provider.get_error()); 246 h.setProperty(_T("CONF_CAN_CHANGE"), _T("0")); 247 h.setProperty(_T("CONF_OLD_FOUND"), _T("0")); 248 h.setProperty(_T("CONF_HAS_ERRORS"), _T("1")); 249 return ERROR_SUCCESS; 250 } 251 } 252 253 216 254 h.setProperty(_T("CONFIGURATION_TYPE"), settings_manager::get_settings()->get_context()); 217 255 h.setProperty(_T("CONF_CAN_CHANGE"), _T("1")); 218 h.setProperty(_T("CONF_OLD_FOUND"), _T("1"));219 256 h.setProperty(_T("CONF_HAS_ERRORS"), _T("0")); 220 257 … … 341 378 int add_defaults = data.get_next_int(); 342 379 343 installer_settings_provider provider( h, target);344 if (!settings_manager::init_settings(&provider, _T(""))) {380 installer_settings_provider provider(&h, target); 381 if (!settings_manager::init_settings(&provider, context)) { 345 382 h.errorMessage(_T("Failed to boot settings: ") + provider.get_error()); 346 383 return ERROR_INSTALL_FAILURE; 347 384 } 385 h.logMessage(_T("Switching to: ") + context); 348 386 settings_manager::change_context(context); 349 387
Note: See TracChangeset
for help on using the changeset viewer.








