15#define GETTEXT_DOMAIN "wesnoth-lib"
30#include <boost/algorithm/string.hpp>
33#define ERR_LOG_VERSION_MIGRATION LOG_STREAM(err, log_version_migration)
34#define WRN_LOG_VERSION_MIGRATION LOG_STREAM(warn, log_version_migration)
35#define LOG_LOG_VERSION_MIGRATION LOG_STREAM(info, log_version_migration)
36#define DBG_LOG_VERSION_MIGRATION LOG_STREAM(debug, log_version_migration)
63 std::string previous_version_str = std::to_string(current_version.
major_version()) +
"."
65 std::string previous_addons_dir
69 versions_.push_back(previous_version_str);
76 listbox& version_list = find_widget<listbox>(
"versions_listbox");
87 listbox& version_list = find_widget<listbox>(
"versions_listbox");
89 std::string selected =
versions_.at(selected_row);
91 std::string migrate_addons_dir
93 std::string migrate_synced_prefs_file
95 std::string migrate_unsynced_prefs_file
97 std::string migrate_credentials_file
103 std::vector<std::string> old_addons;
104 std::vector<std::string> current_addons;
105 std::vector<std::string> migrate_addons;
110 std::set_difference(old_addons.begin(), old_addons.end(), current_addons.begin(), current_addons.end(), std::back_inserter(migrate_addons));
112 if(migrate_addons.size() > 0) {
117#if !defined(_WIN32) && !defined(__APPLE__)
118 bool already_migrated =
false;
120 std::string old_migrate_prefs_file = linux_old_config_dir +
"/preferences";
121 std::string old_migrate_credentials_file = linux_old_config_dir +
"/credentials-aes";
124 already_migrated =
true;
128 already_migrated =
true;
132 if(!already_migrated)
159 char const* xdg_config = getenv(
"XDG_CONFIG_HOME");
162 if(!xdg_config || xdg_config[0] ==
'\0') {
163 xdg_config = getenv(
"HOME");
@ auto_close
Enables auto close.
This shows the dialog to select a previous version of Wesnoth to migrate preferences from and redownl...
virtual void post_show() override
Actions to be taken after the window has been shown.
std::string old_config_dir()
Prior to 1.19 linux installs would usually store the credentials and preferences file under XDG_CONFI...
migrate_version_selection()
std::vector< std::string > versions_
void migrate_credentials(const std::string &credentials_dir)
virtual void pre_show() override
Actions to be taken before showing the window.
Abstract base class for all modal dialogs.
bool show(const unsigned auto_close_time=0)
Shows the window.
grid & add_row(const widget_item &item, const int index=-1)
When an item in the list is selected by the user we need to update the state.
int get_selected_row() const
Returns the first selected row.
void set_initial_gui2_theme()
void set_campaign_rng_mode_default_for_migration()
void migrate_preferences(const std::string &prefs_dir)
void reload_preferences()
Represents version numbers.
unsigned int minor_version() const
Retrieves the minor version number (x2 in "x1.x2.x3").
unsigned int major_version() const
Retrieves the major version number (x1 in "x1.x2.x3").
Declarations for File-IO.
Interfaces for manipulating version numbers of engine, add-ons, etc.
static std::string _(const char *str)
bool ad_hoc_addon_fetch_session(const std::vector< std::string > &addon_ids)
Conducts an ad-hoc add-ons server connection to download an add-on with a particular id and all it's ...
static lg::log_domain log_version_migration
#define REGISTER_DIALOG(window_id)
Wrapper for REGISTER_DIALOG2.
const std::string & get_version_path_suffix()
bool file_exists(const std::string &name)
Returns true if a file or directory with such name already exists.
void get_files_in_dir(const std::string &dir, std::vector< std::string > *files, std::vector< std::string > *dirs=nullptr, name_mode mode=name_mode::FILE_NAME_ONLY, filter_mode filter=filter_mode::NO_FILTER, reorder_mode reorder=reorder_mode::DONT_REORDER, file_tree_checksum *checksum=nullptr)
Get a list of all files and/or directories in a given directory.
std::string get_user_data_dir()
void copy_file(const std::string &src, const std::string &dest)
Read a file and then writes it back out.
std::string get_synced_prefs_file()
location of preferences file containing preferences that are synced between computers note that wesno...
std::string get_unsynced_prefs_file()
location of preferences file containing preferences that aren't synced between computers
std::string get_credentials_file()
std::string get_addons_dir()
const version_info wesnoth_version(VERSION)
std::map< std::string, widget_item > widget_data
void switch_theme(const std::string &theme_id)
Set and activate the given gui2 theme.
void show_message(const std::string &title, const std::string &msg, const std::string &button_caption, const bool auto_close, const bool message_use_markup, const bool title_use_markup)
Shows a message to the user.
@ OK
Dialog was closed with the OK button.