void worker::install() { progress_ = 5; emit progress(progress_); run_async_function(export_from_8x_and_uninstall, [this](const installer::error& _err) { if (!_err.is_ok()) { emit error(_err); return; } run_async_function(terminate_process, [this](const installer::error& _err) { if (!_err.is_ok()) { emit error(_err); return; } run_async_function(copy_files, [this](const installer::error& _err) { if (!_err.is_ok()) { emit error(_err); return; } run_async_function(write_registry, [this](const installer::error& _err) { if (!_err.is_ok()) { emit error(_err); return; } run_async_function(create_links, [this](const installer::error& _err) { if (!_err.is_ok()) { emit error(_err); return; } if (get_exported_data().get_accounts().size()) { if (get_exported_data().get_accounts().size() > 1) { emit select_account(); return; } else { get_exported_data().set_exported_account(*get_exported_data().get_accounts().begin()); } } final_install(); }, 85); }, 60); }, 40); }, 30); }, 20 ); }
installer::error write_registry() { installer::error err; QString exe_path = get_icq_exe(); exe_path = exe_path.replace('/', '\\'); if (!get_exported_data().get_settings() || get_exported_data().get_settings()->auto_run_) { CRegKey key_software_run; if (ERROR_SUCCESS != key_software_run.Open(HKEY_CURRENT_USER, L"Software\\Microsoft\\Windows\\CurrentVersion\\Run", KEY_SET_VALUE)) return installer::error(errorcode::open_registry_key, "open registry key: Software\\Microsoft\\Windows\\CurrentVersion\\Run"); if (ERROR_SUCCESS != key_software_run.SetStringValue((const wchar_t*) get_product_name().utf16(), (const wchar_t*)(QString("\"") + exe_path + "\"").utf16())) return installer::error(errorcode::set_registry_value, "set registry value: Software\\Microsoft\\Windows\\CurrentVersion\\Run icq.desktop"); } CRegKey key_software; if (ERROR_SUCCESS != key_software.Open(HKEY_CURRENT_USER, L"Software")) return installer::error(errorcode::open_registry_key, "open registry key: Software"); CRegKey key_product; if (ERROR_SUCCESS != key_product.Create(key_software, (const wchar_t*) get_product_name().utf16())) return installer::error(errorcode::create_registry_key, QString("create registry key: ") + get_product_name()); if (ERROR_SUCCESS != key_product.SetStringValue(L"path", (const wchar_t*) exe_path.utf16())) return installer::error(errorcode::set_registry_value, "set registry value: Software\\icq.desktop path"); write_referer(key_product); HKEY key_cmd, key_icq = 0, key_icon = 0; DWORD disp = 0; CAtlString command_string = CAtlString("\"") + (const wchar_t*) exe_path.utf16() + L"\" -urlcommand \"%1\""; CAtlString url_link_string = "URL:ICQ Link"; if (ERROR_SUCCESS == ::RegCreateKeyEx(HKEY_CURRENT_USER, L"Software\\Classes\\icq\\shell\\open\\command", 0, L"", REG_OPTION_NON_VOLATILE, KEY_ALL_ACCESS, NULL, &key_cmd, &disp)) { ::RegSetValueEx(key_cmd, NULL, 0, REG_SZ, (LPBYTE) command_string.GetBuffer(), sizeof(TCHAR)*(command_string.GetLength() + 1)); if (ERROR_SUCCESS == ::RegOpenKeyEx(HKEY_CURRENT_USER, L"Software\\Classes\\icq", REG_OPTION_NON_VOLATILE, KEY_ALL_ACCESS, &key_icq)) { ::RegSetValueEx(key_icq, NULL, 0, REG_SZ, (LPBYTE) url_link_string.GetBuffer(), sizeof(TCHAR)*(url_link_string.GetLength() + 1)); ::RegSetValueEx(key_icq, L"URL Protocol", 0, REG_SZ, (LPBYTE) L"", sizeof(TCHAR)); if (ERROR_SUCCESS == ::RegCreateKeyEx(key_icq, L"DefaultIcon", 0, L"", REG_OPTION_NON_VOLATILE, KEY_ALL_ACCESS, NULL, &key_icon, &disp)) { CAtlString icon_path = (const wchar_t*) exe_path.utf16(); ::RegSetValueEx(key_icon, NULL, 0, REG_SZ, (LPBYTE) icon_path.GetBuffer(), sizeof(TCHAR)*(icon_path.GetLength() + 1)); ::RegCloseKey(key_icon); } ::RegCloseKey(key_icq); } ::RegCloseKey(key_cmd); } err = write_to_uninstall_key(); if (!err.is_ok()) return err; return err; }