47{
48
49 int result = 0;
50
51 AppConfig* app_config = wxGetApp().app_config;
52 if (!app_config)
53 return;
54
55 BOOST_LOG_TRIVIAL(info) << "[UpgradeNetworkJob process]: enter";
56
57
58 fs::path target_file_path = (fs::temp_directory_path() /
package_name);
59 fs::path tmp_path = target_file_path;
60 auto path_str = tmp_path.string() + wxString::Format(
".%d%s",
get_current_pid(),
".tmp").ToStdString();
61 tmp_path = fs::path(path_str);
62
63 BOOST_LOG_TRIVIAL(info) << "UpgradeNetworkJob: save netowrk_plugin to " << tmp_path.string();
64
65 auto cancel_fn = [&ctl]() {
66 return ctl.was_canceled();
67 };
68 int curr_percent = 0;
70 [this, &ctl, &curr_percent](int state, int percent, bool &cancel) {
75 } else {
77 }
78 curr_percent = percent;
79 }, cancel_fn);
80
81 if (ctl.was_canceled()) {
83 wxCommandEvent event(wxEVT_CLOSE_WINDOW);
86 return;
87 }
88
89 if (result < 0) {
91 wxCommandEvent event(EVT_DOWNLOAD_NETWORK_FAILED);
94 return;
95 }
96
97 result = wxGetApp().install_plugin(
99 [this, &ctl](int state, int percent, bool &cancel) {
102 } else {
104 }
105 }, cancel_fn);
106
107 if (ctl.was_canceled()) {
109 wxCommandEvent event(wxEVT_CLOSE_WINDOW);
112 return;
113 }
114
115 if (result != 0) {
117 wxCommandEvent event(EVT_INSTALL_NETWORK_FAILED);
120 return;
121 }
122
123 wxCommandEvent event(EVT_UPGRADE_NETWORK_SUCCESS);
126 BOOST_LOG_TRIVIAL(info) << "[UpgradeNetworkJob process]: exit";
127 return;
128}
wxWindow * m_event_handle
Definition UpgradeNetworkJob.hpp:30
void update_status(Ctl &ctl, int st, const std::string &msg)
Definition UpgradeNetworkJob.cpp:36
@ InstallStatusInstallCompleted
Definition UpgradeNetworkJob.hpp:23
@ InstallStatusDownloadFailed
Definition UpgradeNetworkJob.hpp:20
@ InstallStatusNormal
Definition UpgradeNetworkJob.hpp:19
unsigned get_current_pid()
Definition utils.cpp:1480
#define _u8L(s)
Definition I18N.hpp:11