20 #include <wx/filename.h>
23 #include <wx/snglinst.h>
24 #include <wx/string.h>
26 #include "model/base_platform.h"
27 #include "model/nav_object_database.h"
35 bool OnExec(
const wxString &topic,
const wxString &data);
47 std::function<void()>
raise;
57 wxConnectionBase *OnMakeConnection() {
return new StConnection; }
62 bool StConnection::OnExec(
const wxString &topic,
const wxString &data) {
71 pSet->load_file(path.fn_str());
74 pSet->LoadAllGPXObjects(!pSet->IsOpenCPN(), wpt_dups,
true);
76 LLBBox box = pSet->GetBBox();
89 wxConnectionBase *OnAcceptConnection(
const wxString &topic);
93 static bool IsToplevelModal() {
94 for (
auto w = wxTopLevelWindows.GetFirst(); w; w = w->GetNext()) {
95 wxDialog *dlg =
dynamic_cast<wxDialog*
>(w->GetData());
96 if (dlg && dlg->IsModal()) {
104 wxConnectionBase *StServer::OnAcceptConnection(
const wxString& topic) {
105 if (topic.Lower() ==
"opencpn" && !IsToplevelModal()) {
115 bool Init(
const std::vector<std::string>& params) {
116 if (wxSingleInstanceChecker::IsAnotherRunning()) {
117 wxChar separator = wxFileName::GetPathSeparator();
118 wxString service_name =
121 auto checker =
new wxSingleInstanceChecker(_T(
"_OpenCPN_SILock"),
123 if (!checker->IsAnotherRunning()) {
125 if (!m_server->Create(service_name)) {
126 wxLogDebug(wxT(
"Failed to create an IPC service."));
133 wxString hostName = wxT(
"localhost");
135 wxConnectionBase *connection =
136 client->MakeConnection(hostName, service_name, _T(
"OpenCPN"));
139 if (params.empty()) {
140 for (
size_t n = 0; n < params.size(); n++) {
141 wxString path(params[n]);
142 if (::wxFileExists(path)) {
143 connection->Execute(path);
147 connection->Execute(wxT(
""));
148 connection->Disconnect();
158 separator + _T(
"_OpenCPN_SILock"));
159 if (wxFileExists(lockFile)) wxRemoveFile(lockFile);
162 _(
"Sorry, an existing instance of OpenCPN may be too busy "
163 "to respond.\nPlease retry."),
164 wxT(
"OpenCPN"), wxICON_INFORMATION | wxOK);
std::function< void(LLBBox)> gframe_center_view
Center global view to a given box callback.
std::function< void()> update_route_mgr_dlg
Update RouteManagerDialog callback.