OpenCPN Partial API docs
safe_mode_gui.cpp
1 #include <cstdio>
2 #include <string>
3 #include <fstream>
4 
5 #include <wx/dialog.h>
6 #include <wx/filename.h>
7 #include <wx/sizer.h>
8 
9 #include "model/cmdline.h"
10 #include "gui_lib.h"
11 #include "model/ocpn_utils.h"
12 
13 #include "model/safe_mode.h"
14 
15 namespace safe_mode {
16 
17 static const int TIMEOUT_SECONDS = 15;
18 
19 static const char* LAST_RUN_ERROR_MSG =
20  _("<p>The last opencpn run seems to have failed. Do you want to run\n"
21  "in safe mode without plugins and other possibly problematic\n"
22  "features?\n</p><br/></br><p>You may consider visiting the <a href=\"https://github.com/OpenCPN/OpenCPN/wiki/OpenCPN-5.8-known-issues\">list of known issues</a>.</p>");
23 
29  std::string path = check_file_path();
30  if (!ocpn::exists(path)) {
31  std::ofstream dest(path, std::ios::binary);
32  dest << "Internal opencpn use" << std::endl;
33  dest.close();
34  return;
35  }
36  long style = wxYES | wxNO | wxNO_DEFAULT | wxICON_QUESTION;
37  auto dlg = new OCPN_TimedHTMLMessageDialog(0, LAST_RUN_ERROR_MSG,
38  _("Safe restart"), TIMEOUT_SECONDS,
39  style, false, wxDefaultPosition);
40  int reply = dlg->ShowModal();
41  safe_mode = reply == wxID_YES;
42  dlg->Destroy();
43 }
44 
45 } // namespace safe_mode
Global variables reflecting command line options and arguments.
General purpose GUI support.
Safe mode handling.
Definition: safe_mode.cpp:14
void check_last_start()
Check if the last start failed, possibly invoke user dialog and set safe mode state.