updates-model.cpp
Go to the documentation of this file.
1 // License: Apache 2.0. See LICENSE file in root directory.
2 // Copyright(c) 2020 Intel Corporation. All Rights Reserved.
3 
4 #include <glad/glad.h>
5 #include "updates-model.h"
6 #include "model-views.h"
7 #include "os.h"
8 #include "res/l515-icon.h"
9 #include <stb_image.h>
11 
12 using namespace rs2;
13 using namespace sw_update;
14 using namespace http;
15 
16 void updates_model::draw(std::shared_ptr<notifications_model> not_model, ux_window& window, std::string& error_message)
17 {
18  // Protect resources
19  static std::vector<update_profile_model> updates_copy;
20  {
21  std::lock_guard<std::mutex> lock(_lock);
22  updates_copy = _updates;
23  }
24 
25  // Prepare camera icon
26  if (!_icon)
27  {
28  _icon = std::make_shared<rs2::texture_buffer>();
29  int x, y, comp;
31  _icon->upload_image(x, y, data);
33 
34  _progress.last_progress_time = std::chrono::system_clock::now();
35  }
36 
37  const auto window_name = "Updates Window";
38 
39  //Main window pop up only if essential updates exists
40  if (updates_copy.size())
41  {
42  ImGui::OpenPopup(window_name);
43  }
44 
45  position_params positions;
46 
47  positions.w = window.width() * 0.6f;
48  positions.h = 600;
49  positions.x0 = window.width() * 0.2f;
50  positions.y0 = std::max(window.height() - positions.h, 0.f) / 2;
51  ImGui::SetNextWindowPos({ positions.x0, positions.y0 });
52  ImGui::SetNextWindowSize({ positions.w, positions.h });
53 
56 
62 
63  if (ImGui::BeginPopupModal(window_name, nullptr, flags))
64  {
65 
66  std::string title_message = "SOFTWARE UPDATES";
67  auto title_size = ImGui::CalcTextSize(title_message.c_str());
68  ImGui::SetCursorPosX(positions.w / 2 - title_size.x / 2);
71  ImGui::Text("%s", title_message.c_str());
75 
76  positions.orig_pos = ImGui::GetCursorScreenPos();
77  positions.mid_y = (positions.orig_pos.y + positions.y0 + positions.h - 30) / 2;
78 
79  ImGui::GetWindowDrawList()->AddRectFilled({ positions.orig_pos.x + 140.f, positions.orig_pos.y },
80  { positions.x0 + positions.w - 5, positions.y0 + positions.h - 30 }, ImColor(header_color));
81  ImGui::GetWindowDrawList()->AddLine({ positions.orig_pos.x + 145.f, positions.mid_y },
82  { positions.x0 + positions.w - 10, positions.mid_y }, ImColor(sensor_bg));
83 
84  // ===========================================================================
85  // Draw Left Pane
86  // ===========================================================================
87 
88  for (int i = 0; i < static_cast<int>(updates_copy.size()); i++)
89  {
90  auto& update = updates_copy[i];
91 
92  if (ImGui::GetCursorPosY() + 150 > positions.h) break;
93 
95 
96  if (i == selected_index)
97  {
99  { pos.x + 140.f, pos.y + 185.f }, ImColor(header_color));
100  }
101 
104 
105  ImGui::Image((void*)(intptr_t)(_icon->get_gl_handle()), ImVec2{ 128.f, 114.f });
106 
116 
117  std::string limited_name = update.profile.device_name.substr(0, 40);
118  ImGui::Text("%s", limited_name.c_str());
121 
122  auto sn_size = ImGui::CalcTextSize(update.profile.serial_number.c_str());
123  ImGui::SetCursorPosX(ImGui::GetCursorPosX() + 70 - sn_size.x / 2);
124  ImGui::Text("%s", update.profile.serial_number.c_str());
125  }
126 
127  auto& update = updates_copy[selected_index];
128 
129  bool sw_update_needed(false), fw_update_needed(false);
130 
131  // Verify Device Exists
132  if (update.profile.dev_active || _fw_update_state == fw_update_states::started)
133  {
134  // ===========================================================================
135  // Draw Software update Pane
136  // ===========================================================================
137  sw_update_needed = draw_software_section(window_name, update, positions, window, error_message);
138 
139  // ===========================================================================
140  // Draw Firmware update Pane
141  // ===========================================================================
142  fw_update_needed = draw_firmware_section(not_model, window_name, update, positions, window, error_message);
143 
144  }
145  else
146  {
149  ImGui::SetCursorPos({ positions.orig_pos.x, positions.y0 - 100 });
151  ImGui::Text("%s","THE DEVICE HAS BEEN DISCONNECTED,");
152  ImGui::SetCursorPos({ positions.orig_pos.x - 100, positions.y0 - 70 });
153  ImGui::Text("%s", "PLEASE RECONNECT IT OR CLOSE THE UPDATES WINDOW.");
154  ImGui::PopFont();
155  ImGui::SetCursorPos({ positions.orig_pos.x + 230, positions.y0 });
157  ImGui::Text("%s", static_cast<const char *>(textual_icons::lock));
160 
161 
162  }
163  // ===========================================================================
164  // Draw Lower Pane
165  // ===========================================================================
166 
167  auto no_update_needed = (!sw_update_needed && !fw_update_needed);
168 
169  if (!no_update_needed)
170  {
171  ImGui::SetCursorPos({ 145, positions.h - 25 });
172  if (emphasize_dismiss_text)
173  {
175  }
176 
177  ImGui::Checkbox("I understand and would like to proceed anyway without updating", &ignore);
178 
179  if (emphasize_dismiss_text)
180  {
182  }
183  }
184 
185  ImGui::SetCursorPos({ positions.w - 145, positions.h - 25 });
186 
187  auto enabled = ignore || no_update_needed;
188  if (enabled)
189  {
190  if (_fw_update_state != fw_update_states::started)
191  {
192  if (ImGui::Button("Close", { 120, 20 }))
193  {
194  {
195  std::lock_guard<std::mutex> lock(_lock);
196  _updates.clear();
197  }
198 
200  emphasize_dismiss_text = false;
201  ignore = false;
202  _fw_update_state = fw_update_states::ready;
203  _fw_download_progress = 0;
204  }
205  }
206  else
207  {
209  ImGui::Button("Close", { 120, 20 });
211  }
212  }
213  else
214  {
217 
218  if (ImGui::Button("Close", { 120, 20 }))
219  {
220  emphasize_dismiss_text = true;
221  }
222  if (ImGui::IsItemHovered())
223  {
224  ImGui::SetTooltip("To close this window you must install all essential update\n"
225  "or agree to the warning of closing without it");
226 
227  }
229  }
230  ImGui::EndPopup();
231  }
234 
235 }
236 
237 bool updates_model::draw_software_section(const char * window_name, update_profile_model& selected_profile, position_params& pos, ux_window& window, std::string& error_message)
238 {
239  bool essential_sw_update_needed(false);
240  bool recommended_sw_update_needed(false);
241  {
242  // Prepare sorted array of SW updates profiles
243  // Assumption - essential updates version <= other policies versions
244  std::vector<dev_updates_profile::version_info> software_updates;
245  for (auto&& swu : selected_profile.profile.software_versions)
246  software_updates.push_back(swu.second);
247  std::sort(software_updates.begin(), software_updates.end(), [](dev_updates_profile::version_info& a, dev_updates_profile::version_info& b) {
248  return a.ver < b.ver;
249  });
250  if (static_cast<int>(software_updates.size()) <= selected_software_update_index) selected_software_update_index = 0;
251 
252  dev_updates_profile::version_info selected_software_update;
253  if (software_updates.size() != 0)
254  {
255  bool essential_found(false);
256  bool recommended_found(false);
257  for (auto sw_update : software_updates)
258  {
259  if (!essential_found)
260  {
261  essential_found = essential_found || sw_update.name_for_display.find("ESSENTIAL") != std::string::npos;
262  essential_sw_update_needed = essential_sw_update_needed || essential_found && (selected_profile.profile.software_version < sw_update.ver);
263  }
264 
265  if (!recommended_found)
266  {
267  recommended_found = recommended_found || sw_update.name_for_display.find("RECOMMENDED") != std::string::npos;
268  recommended_sw_update_needed = recommended_sw_update_needed || recommended_found && (selected_profile.profile.software_version < sw_update.ver);
269  }
270  }
271 
272  // If essential update found on DB but not needed - Remove it
273  if (essential_found && !essential_sw_update_needed)
274  {
275  auto it = std::find_if(software_updates.begin(), software_updates.end(), [&](dev_updates_profile::version_info& u) {
276  return (u.name_for_display.find("ESSENTIAL") != std::string::npos);
277  });
278  if (it != software_updates.end())
279  software_updates.erase(it);
280  }
281 
282  // If recommended update found on DB but not needed - Remove it
283  if (recommended_found && !recommended_sw_update_needed)
284  {
285  auto it = std::find_if(software_updates.begin(), software_updates.end(), [&](dev_updates_profile::version_info& u) {
286  return (u.name_for_display.find("RECOMMENDED") != std::string::npos);
287  });
288  if (it != software_updates.end())
289  software_updates.erase(it);
290  }
291 
292  if (essential_sw_update_needed || recommended_sw_update_needed)
293  {
294  selected_software_update = software_updates[selected_software_update_index];
295  }
296  }
297 
298  ImVec2 sw_text_pos(pos.orig_pos.x + 150, pos.orig_pos.y + 10);
299  ImGui::SetCursorScreenPos(sw_text_pos);
300 
303  ImGui::Text("LibRealSense SDK: ");
305  ImGui::SameLine();
306 
307  if (!essential_sw_update_needed || software_updates.size() == 0)
308  {
309  if (recommended_sw_update_needed)
310  {
312  ImGui::Text("Recommended update available!");
313  }
314  else
315  {
317  ImGui::Text("%s", static_cast<const char *>(textual_icons::check_square_o));
318  ImGui::SameLine();
319  ImGui::Text("%s", "Up to date.");
320  }
322  }
323  else if (essential_sw_update_needed)
324  {
326  ImGui::Text("Essential update is available. Please install!");
328  }
329 
330 
331  ImGui::PopFont();
332 
334  sw_text_pos.y += 30;
335  ImGui::SetCursorScreenPos(sw_text_pos);
337  ImGui::Text("%s", "Content:"); ImGui::SameLine();
339  ImGui::Text("%s", "Intel RealSense SDK 2.0, Intel RealSense Viewer and Depth Quality Tool");
340 
341  sw_text_pos.y += 20;
342  ImGui::SetCursorScreenPos(sw_text_pos);
344  ImGui::Text("%s", "Purpose:"); ImGui::SameLine();
346  ImGui::Text("%s", "Enhancements for stream alignment, texture mapping and camera accuracy health algorithms");
347 
348  sw_text_pos.y += 30;
349  ImGui::SetCursorScreenPos(sw_text_pos);
351  ImGui::Text("%s", "Current SW version:");
352  ImGui::SameLine();
354  auto current_sw_ver_str = std::string(selected_profile.profile.software_version);
355  ImGui::Text("%s", current_sw_ver_str.c_str());
356 
357  if (essential_sw_update_needed)
358  {
359  ImGui::SameLine();
361  ImGui::Text("%s", " (Your version is older than the minimum version required for the proper functioning of your device)");
363  }
364 
365  if ( selected_software_update.ver )
366  {
367  sw_text_pos.y += 25;
368  ImGui::SetCursorScreenPos(sw_text_pos);
370 
371  ImGui::Text("%s", (software_updates.size() >= 2) ?
372  "Versions available:" :
373  "Version to download:");
374  ImGui::SameLine();
376  // 3 box for multiple versions
377  if (software_updates.size() >= 2)
378  {
379  std::vector<const char*> swu_labels;
380  for (auto&& swu : software_updates)
381  {
382  swu_labels.push_back(swu.name_for_display.c_str());
383  }
386 
387  std::string combo_id = "##Software Update Version";
390  ImGui::Combo(combo_id.c_str(), &selected_software_update_index, swu_labels.data(), static_cast<int>(swu_labels.size()));
394  }
395  else
396  { // Single version
397  ImGui::Text("%s", std::string(selected_software_update.ver).c_str());
398  }
399  }
400 
401  if (selected_software_update.release_page != "")
402  {
403  sw_text_pos.y += 25;
404  ImGui::SetCursorScreenPos(sw_text_pos);
406  ImGui::Text("%s", "Release Link:"); ImGui::SameLine();
409  ImGui::Text("%s", selected_software_update.release_page.c_str());
410 
411  ImGui::SameLine();
412  auto underline_start = ImVec2(ImGui::GetCursorScreenPos().x - (ImGui::CalcTextSize(selected_software_update.release_page.c_str()).x + 8), ImGui::GetCursorScreenPos().y + ImGui::GetFontSize());
414  ImGui::GetWindowDrawList()->AddLine(underline_start, underline_end, ImColor(light_grey));
415 
417  if (ImGui::IsItemHovered())
418  window.link_hovered();
419  if (ImGui::IsItemClicked())
420  {
421  try
422  {
423  open_url(selected_software_update.release_page.c_str());
424  }
425  catch (...)
426  {
427  LOG_ERROR("Error opening URL: " + selected_software_update.release_page);
428  }
429  }
430  }
431 
432 
433  if (selected_software_update.description != "")
434  {
435  sw_text_pos.y += 25;
436  ImGui::SetCursorScreenPos(sw_text_pos);
438 
439  ImGui::Text("%s", "Description:");
441 
442  ImGui::PushTextWrapPos(pos.w - 150);
450  auto msg = selected_software_update.description.c_str();
451  sw_text_pos.x -= 4;
452  sw_text_pos.y += 15;
453  ImGui::SetCursorScreenPos(sw_text_pos);
454  ImGui::InputTextMultiline("##Software Update Description", const_cast<char*>(msg),
455  strlen(msg) + 1, ImVec2(ImGui::GetContentRegionAvailWidth() - 150, pos.mid_y - (pos.orig_pos.y + 160) - 40),
459  }
460 
461  if ( selected_software_update.ver )
462  {
463  ImGui::SetCursorScreenPos({ pos.orig_pos.x + pos.w - 150, pos.mid_y - 45 });
467 
468  if (ImGui::Button("Download", { 120, 40 }))
469  {
470  try
471  {
472  open_url(selected_software_update.download_link.c_str());
473  }
474  catch (...)
475  {
476  LOG_ERROR("Error opening URL: " + selected_software_update.download_link);
477  }
478  }
479 
480  if (ImGui::IsItemHovered())
481  {
482  std::string tooltip = "This will redirect you to download the selected software from:\n" + selected_software_update.download_link;
483  ImGui::SetTooltip("%s", tooltip.c_str());
484  window.link_hovered();
485  }
486 
488  ImGui::SetCursorScreenPos({ pos.orig_pos.x + 150, pos.mid_y - 25 });
489  ImGui::Text("%s", "Visit the release page before download to identify the most suitable package.");
490  }
491 
493  }
494  return essential_sw_update_needed;
495 }
496 bool updates_model::draw_firmware_section(std::shared_ptr<notifications_model> not_model, const char * window_name, update_profile_model& selected_profile, position_params& pos, ux_window& window, std::string& error_message)
497 {
498  bool essential_fw_update_needed(false);
499  bool recommended_fw_update_needed(false);
500 
501  // Prepare sorted array of FW updates profiles
502  // Assumption - essential updates version <= other policies versions
503  std::vector<dev_updates_profile::version_info> firmware_updates;
504  for (auto&& swu : selected_profile.profile.firmware_versions)
505  firmware_updates.push_back(swu.second);
506  std::sort(firmware_updates.begin(), firmware_updates.end(), [](dev_updates_profile::version_info& a, dev_updates_profile::version_info& b) {
507  return a.ver < b.ver;
508  });
509  if (static_cast<int>(firmware_updates.size()) <= selected_firmware_update_index) selected_firmware_update_index = 0;
510 
511  dev_updates_profile::version_info selected_firmware_update;
512 
513  if (firmware_updates.size() != 0)
514  {
515  bool essential_found(false);
516  bool recommended_found(false);
517 
518  for (auto fw_update : firmware_updates)
519  {
520  if (!essential_found)
521  {
522  essential_found = essential_found || fw_update.name_for_display.find("ESSENTIAL") != std::string::npos;
523  essential_fw_update_needed = essential_fw_update_needed || essential_found && (selected_profile.profile.firmware_version < fw_update.ver);
524  }
525 
526  if (!recommended_found)
527  {
528  recommended_found = recommended_found || fw_update.name_for_display.find("RECOMMENDED") != std::string::npos;
529  recommended_fw_update_needed = recommended_fw_update_needed || recommended_found && (selected_profile.profile.firmware_version < fw_update.ver);
530  }
531  }
532 
533  // If essential update found on DB but not needed - Remove it
534  if (essential_found && !essential_fw_update_needed)
535  {
536  auto it = std::find_if(firmware_updates.begin(), firmware_updates.end(), [&](dev_updates_profile::version_info& u) {
537  return (u.name_for_display.find("ESSENTIAL") != std::string::npos);
538  });
539  if (it != firmware_updates.end())
540  firmware_updates.erase(it);
541  }
542 
543  // If recommended update found on DB but not needed - Remove it
544  if (recommended_found && !recommended_fw_update_needed)
545  {
546  auto it = std::find_if(firmware_updates.begin(), firmware_updates.end(), [&](dev_updates_profile::version_info& u) {
547  return (u.name_for_display.find("RECOMMENDED") != std::string::npos);
548  });
549  if (it != firmware_updates.end())
550  firmware_updates.erase(it);
551  }
552  if (essential_fw_update_needed || recommended_fw_update_needed)
553  {
554  selected_firmware_update = firmware_updates[selected_firmware_update_index];
555  }
556 
557  }
558 
559  ImVec2 fw_text_pos(pos.orig_pos.x + 150, pos.mid_y + 15);
560  ImGui::SetCursorScreenPos(fw_text_pos);
561 
564  ImGui::Text("FIRMWARE: ");
566  ImGui::SameLine();
567  if (!essential_fw_update_needed || firmware_updates.size() == 0)
568  {
569  if (recommended_fw_update_needed)
570  {
572  ImGui::Text("Recommended update available!");
573  }
574  else
575  {
577  ImGui::Text("%s", static_cast<const char *>(textual_icons::check_square_o));
578  ImGui::SameLine();
579  ImGui::Text("%s", "Up to date.");
580  }
582  }
583  else if (essential_fw_update_needed)
584  {
586  ImGui::Text("Essential update is available. Please install!");
588  }
589 
590 
591  ImGui::PopFont();
592 
594  fw_text_pos.y += 25;
595  ImGui::SetCursorScreenPos(fw_text_pos);
597  ImGui::Text("%s", "Content:"); ImGui::SameLine();
599  ImGui::Text("%s", "Signed Firmware Image (.bin file)");
600 
601  fw_text_pos.y += 50;
602  ImGui::SetCursorScreenPos(fw_text_pos);
604  ImGui::Text("%s", "Current FW version:");
605  ImGui::SameLine();
607  auto current_fw_ver_str = std::string(selected_profile.profile.firmware_version);
608  ImGui::Text("%s", current_fw_ver_str.c_str());
609 
610 
611 
612  if (essential_fw_update_needed)
613  {
614  ImGui::SameLine();
616  ImGui::Text("%s", " (Your version is older than the minimum version required for the proper functioning of your device)");
618  }
619 
620  if ( selected_firmware_update.ver )
621  {
622  fw_text_pos.y += 25;
623  ImGui::SetCursorScreenPos(fw_text_pos);
625 
626  ImGui::Text("%s", (firmware_updates.size() >= 2) ?
627  "Versions available:" :
628  "Version to download:");
629  ImGui::SameLine();
631  // Combo box for multiple versions
632  if (firmware_updates.size() >= 2)
633  {
634  std::vector<const char*> fwu_labels;
635  for (auto&& fwu : firmware_updates)
636  {
637  fwu_labels.push_back(fwu.name_for_display.c_str());
638  }
639 
642 
643  std::string combo_id = "##Firmware Update Version";
646  ImGui::Combo(combo_id.c_str(), &selected_firmware_update_index, fwu_labels.data(), static_cast<int>(fwu_labels.size()));
650  }
651  else
652  { // Single version
653  ImGui::Text("%s", std::string(selected_firmware_update.ver).c_str());
654  }
655  }
656 
657  if (selected_firmware_update.release_page != "")
658  {
659  fw_text_pos.y += 25;
660  ImGui::SetCursorScreenPos(fw_text_pos);
662  ImGui::Text("%s", "Release Link:"); ImGui::SameLine();
665  ImGui::Text("%s", selected_firmware_update.release_page.c_str());
666 
667  ImGui::SameLine();
668  auto underline_start = ImVec2(ImGui::GetCursorScreenPos().x - (ImGui::CalcTextSize(selected_firmware_update.release_page.c_str()).x + 8), ImGui::GetCursorScreenPos().y + ImGui::GetFontSize());
670  ImGui::GetWindowDrawList()->AddLine(underline_start, underline_end, ImColor(light_grey));
671 
672 
674  if (ImGui::IsItemHovered())
675  window.link_hovered();
676  if (ImGui::IsItemClicked())
677  {
678  try
679  {
680  open_url(selected_firmware_update.release_page.c_str());
681  }
682  catch (...)
683  {
684  LOG_ERROR("Error opening URL: " + selected_firmware_update.release_page);
685  }
686  }
687  }
688 
689  if (selected_firmware_update.description != "")
690  {
691  fw_text_pos.y += 25;
692  ImGui::SetCursorScreenPos(fw_text_pos);
694  ImGui::Text("%s", "Description:");
696 
697  ImGui::PushTextWrapPos(pos.w - 150);
705  auto msg = selected_firmware_update.description.c_str();
706  fw_text_pos.x -= 4;
707  fw_text_pos.y += 15;
708  ImGui::SetCursorScreenPos(fw_text_pos);
709  ImGui::InputTextMultiline("##Firmware Update Description", const_cast<char*>(msg),
710  strlen(msg) + 1, ImVec2(ImGui::GetContentRegionAvailWidth() - 150, 75),
714  }
715 
716 
717  if( ( _fw_update_state == fw_update_states::ready || _fw_update_state == fw_update_states::completed )
718  && ( essential_fw_update_needed || recommended_fw_update_needed ) )
719  {
720  ImGui::SetCursorScreenPos({ pos.orig_pos.x + pos.w - 150, pos.orig_pos.y + pos.h - 115 });
723 
724  if (ImGui::Button("Download &\n Install", ImVec2(120, 40)) || _retry)
725  {
726  _retry = false;
727  auto link = selected_firmware_update.download_link;
728  std::thread download_thread([link, this]() {
729  std::vector<uint8_t> vec;
730  http_downloader client;
731 
732  if (!client.download_to_bytes_vector(link, vec,
733  [this](uint64_t dl_current_bytes, uint64_t dl_total_bytes) -> callback_result {
734  _fw_download_progress = static_cast<int>((dl_current_bytes * 100) / dl_total_bytes);
735  return callback_result::CONTINUE_DOWNLOAD;
736  }))
737  {
738  _fw_update_state = fw_update_states::failed_downloading;
739  LOG_ERROR("Error in download firmware version from: " + link);
740  }
741 
742  _fw_image = vec;
743 
744  _fw_download_progress = 100;
745  });
746  download_thread.detach();
747 
748  _fw_update_state = fw_update_states::downloading;
749  }
750  if (ImGui::IsItemHovered())
751  {
752  ImGui::SetTooltip("This will download selected firmware and install it to the device");
753  window.link_hovered();
754  }
756  }
757  else if (_fw_update_state == fw_update_states::downloading)
758  {
759  ImGui::SetCursorScreenPos({ pos.orig_pos.x + 150, pos.orig_pos.y + pos.h - 95 });
760  _progress.draw(window, static_cast<int>(pos.w) - 170, _fw_download_progress / 3);
761  if (_fw_download_progress == 100 && !_fw_image.empty())
762  {
763  _fw_download_progress = 0;
764  _fw_update_state = fw_update_states::started;
765 
766  _update_manager = std::make_shared<firmware_update_manager>(not_model,
767  *selected_profile.dev_model, selected_profile.profile.dev, selected_profile.ctx, _fw_image, true
768  );
769  auto invoke = [](std::function<void()> action) { action(); };
770  _update_manager->start(invoke);
771  }
772  }
773  else if (_fw_update_state == fw_update_states::started)
774  {
775  ImGui::SetCursorScreenPos({ pos.orig_pos.x + 150, pos.orig_pos.y + pos.h - 95 });
776  _progress.draw(window, static_cast<int>(pos.w) - 170, static_cast<int>(_update_manager->get_progress() * 0.66 + 33));
777  if (_update_manager->done()) {
778  _fw_update_state = fw_update_states::completed;
779  _fw_image.clear();
780  }
781 
782  if (_update_manager->failed()) {
783  _fw_update_state = fw_update_states::failed_updating;
784  _fw_image.clear();
785  _fw_download_progress = 0;
786  }
787  // Verify an error window will not pop up. ImGui cannot handle 2 PopUpModals in parallel.
788  if (!error_message.empty())
789  {
790  LOG_ERROR("error caught during update process, details: " + error_message);
791  error_message.clear();
792  }
793 
794  }
795  else if (_fw_update_state == fw_update_states::failed_downloading ||
796  _fw_update_state == fw_update_states::failed_updating)
797  {
798  ImGui::SetCursorScreenPos({ pos.orig_pos.x + 150, pos.orig_pos.y + pos.h - 95 });
800  std::string text = _fw_update_state == fw_update_states::failed_downloading ?
801  "Firmware download failed, check connection and press to retry" :
802  "Firmware update process failed, press to retry";
803  if (ImGui::Button(text.c_str(), ImVec2(pos.w - 170, 25)))
804  {
805  _fw_update_state = fw_update_states::ready;
806  _update_manager.reset();
807  _fw_image.clear();
808  _retry = true;
809  }
811  _fw_download_progress = 0;
812  }
813  else if (_fw_update_state == fw_update_states::completed)
814  {
815  _fw_update_state = fw_update_states::ready;
816  _update_manager.reset();
817  _fw_image.clear();
818  _fw_download_progress = 0;
819  }
820 
822 
823  return essential_fw_update_needed;
824 }
825 
static const textual_icon lock
Definition: model-views.h:218
IMGUI_API void PushStyleVar(ImGuiStyleVar idx, float val)
Definition: imgui.cpp:4650
static const ImVec4 transparent
Definition: model-views.h:44
IMGUI_API void Image(ImTextureID user_texture_id, const ImVec2 &size, const ImVec2 &uv0=ImVec2(0, 0), const ImVec2 &uv1=ImVec2(1, 1), const ImVec4 &tint_col=ImVec4(1, 1, 1, 1), const ImVec4 &border_col=ImVec4(0, 0, 0, 0))
Definition: imgui.cpp:5635
static const ImVec4 white
Definition: model-views.h:45
IMGUI_API float GetCursorPosX()
Definition: imgui.cpp:5082
IMGUI_API void AddRectFilled(const ImVec2 &a, const ImVec2 &b, ImU32 col, float rounding=0.0f, int rounding_corners=0x0F)
Definition: imgui_draw.cpp:814
GLboolean GLboolean GLboolean b
GLint y
static const ImVec4 light_red
Definition: model-views.h:53
IMGUI_API void SetTooltip(const char *fmt,...) IM_PRINTFARGS(1)
Definition: imgui.cpp:3288
IMGUI_API float GetFontSize()
Definition: imgui.cpp:5056
static const textual_icon check_square_o
Definition: model-views.h:244
IMGUI_API bool InputTextMultiline(const char *label, char *buf, size_t buf_size, const ImVec2 &size=ImVec2(0, 0), ImGuiInputTextFlags flags=0, ImGuiTextEditCallback callback=NULL, void *user_data=NULL)
Definition: imgui.cpp:8223
IMGUI_API void SetCursorPos(const ImVec2 &local_pos)
Definition: imgui.cpp:5094
static const ImVec4 light_grey
Definition: model-views.h:40
Definition: imgui.h:88
IMGUI_API bool IsItemClicked(int mouse_button=0)
Definition: imgui.cpp:3223
IMGUI_API void PopTextWrapPos()
Definition: imgui.cpp:4592
void draw(std::shared_ptr< notifications_model > not_model, ux_window &window, std::string &error_message)
static const ImVec4 light_blue
Definition: model-views.h:38
string _progress
Definition: log.py:34
IMGUI_API void SetNextWindowPos(const ImVec2 &pos, ImGuiSetCond cond=0)
Definition: imgui.cpp:4923
STBIDEF stbi_uc * stbi_load_from_memory(stbi_uc const *buffer, int len, int *x, int *y, int *comp, int req_comp)
bool download_to_bytes_vector(const std::string &url, std::vector< uint8_t > &output, user_callback_func_type user_callback_func=user_callback_func_type())
Definition: cah-model.h:10
GLsizei const GLchar *const * string
IMGUI_API void PushTextWrapPos(float wrap_pos_x=0.0f)
Definition: imgui.cpp:4585
IMGUI_API void AddLine(const ImVec2 &a, const ImVec2 &b, ImU32 col, float thickness=1.0f)
Definition: imgui_draw.cpp:796
void sort(sort_type m_sort_type, const std::string &in, const std::string &out)
GLboolean GLboolean GLboolean GLboolean a
IMGUI_API void SameLine(float pos_x=0.0f, float spacing_w=-1.0f)
Definition: imgui.cpp:9246
void update(rs2::update_device fwu_dev, std::vector< uint8_t > fw_image)
IMGUI_API ImDrawList * GetWindowDrawList()
Definition: imgui.cpp:5045
IMGUI_API void PopStyleVar(int count=1)
Definition: imgui.cpp:4675
IMGUI_API ImVec2 CalcTextSize(const char *text, const char *text_end=NULL, bool hide_text_after_double_hash=false, float wrap_width=-1.0f)
Definition: test-wrap.cpp:15
static const ImVec4 regular_blue
Definition: model-views.h:39
static const textual_icon link
Definition: model-views.h:257
GLdouble x
void open_url(const char *url)
Definition: os.cpp:58
static uint32_t camera_icon_l515_png_size
Definition: l515-icon.h:5
IMGUI_API void SetNextWindowSize(const ImVec2 &size, ImGuiSetCond cond=0)
Definition: imgui.cpp:4937
static const ImVec4 sensor_bg
Definition: model-views.h:51
GLbitfield flags
unsigned __int64 uint64_t
Definition: stdint.h:90
IMGUI_API void SetCursorPosX(float x)
Definition: imgui.cpp:5101
GLenum GLenum GLsizei const GLuint GLboolean enabled
IMGUI_API float GetContentRegionAvailWidth()
Definition: imgui.cpp:5003
IMGUI_API void PushItemWidth(float item_width)
Definition: imgui.cpp:4486
IMGUI_API void Text(const char *fmt,...) IM_PRINTFARGS(1)
Definition: imgui.cpp:5223
IMGUI_API bool Button(const char *label, const ImVec2 &size=ImVec2(0, 0))
Definition: imgui.cpp:5573
#define LOG_ERROR(...)
Definition: src/types.h:242
bool draw_software_section(const char *window_name, update_profile_model &selected_profile, position_params &pos_params, ux_window &window, std::string &error_message)
static const ImVec4 dark_grey
Definition: model-views.h:49
IMGUI_API void EndPopup()
Definition: imgui.cpp:3489
action
Definition: enums.py:62
static const ImVec4 header_color
Definition: model-views.h:57
IMGUI_API void PushStyleColor(ImGuiCol idx, const ImVec4 &col)
Definition: imgui.cpp:4599
IMGUI_API bool Combo(const char *label, int *current_item, const char **items, int items_count, int height_in_items=-1, bool show_arrow_down=true)
Definition: imgui.cpp:8418
IMGUI_API void PushFont(ImFont *font)
Definition: imgui.cpp:4539
float y
Definition: imgui.h:90
IMGUI_API ImVec2 GetCursorScreenPos()
Definition: imgui.cpp:5121
IMGUI_API void PopItemWidth()
Definition: imgui.cpp:4507
static auto it
static const ImVec4 yellowish
Definition: model-views.h:61
STBIDEF void stbi_image_free(void *retval_from_stbi_load)
IMGUI_API bool BeginPopupModal(const char *name, bool *p_open=NULL, ImGuiWindowFlags extra_flags=0)
Definition: imgui.cpp:3465
IMGUI_API bool Checkbox(const char *label, bool *v)
Definition: imgui.cpp:7269
float width() const
Definition: ux-window.h:41
float rs2_vector::* pos
IMGUI_API void SetCursorScreenPos(const ImVec2 &pos)
Definition: imgui.cpp:5127
sw_update::dev_updates_profile::update_profile profile
Definition: updates-model.h:24
int i
IMGUI_API void CloseCurrentPopup()
Definition: imgui.cpp:3408
ImFont * get_large_font() const
Definition: ux-window.h:62
IMGUI_API void OpenPopup(const char *str_id)
Definition: imgui.cpp:3343
IMGUI_API void SetCursorPosY(float y)
Definition: imgui.cpp:5108
IMGUI_API void SetWindowFontScale(float scale)
Definition: imgui.cpp:5066
_W64 signed int intptr_t
Definition: stdint.h:118
void link_hovered()
Definition: ux-window.cpp:166
static uint8_t camera_icon_l515_png_data[]
Definition: l515-icon.h:6
IMGUI_API float GetCursorPosY()
Definition: imgui.cpp:5088
IMGUI_API bool IsItemHovered()
Definition: imgui.cpp:3200
Definition: parser.hpp:150
IMGUI_API void PopFont()
Definition: imgui.cpp:4549
float x
Definition: imgui.h:90
bool draw_firmware_section(std::shared_ptr< notifications_model > not_model, const char *window_name, update_profile_model &selected_profile, position_params &pos_params, ux_window &window, std::string &error_message)
IMGUI_API void PopStyleColor(int count=1)
Definition: imgui.cpp:4609
float height() const
Definition: ux-window.h:42


librealsense2
Author(s): Sergey Dorodnicov , Doron Hirshberg , Mark Horn , Reagan Lopez , Itay Carpis
autogenerated on Mon May 3 2021 02:50:13