2014-04-12 04:21:09 +02:00
|
|
|
/******************************************************************************
|
|
|
|
* Icinga 2 *
|
2016-01-12 08:29:59 +01:00
|
|
|
* Copyright (C) 2012-2016 Icinga Development Team (https://www.icinga.org/) *
|
2014-04-12 04:21:09 +02:00
|
|
|
* *
|
|
|
|
* This program is free software; you can redistribute it and/or *
|
|
|
|
* modify it under the terms of the GNU General Public License *
|
|
|
|
* as published by the Free Software Foundation; either version 2 *
|
|
|
|
* of the License, or (at your option) any later version. *
|
|
|
|
* *
|
|
|
|
* This program is distributed in the hope that it will be useful, *
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
|
|
|
|
* GNU General Public License for more details. *
|
|
|
|
* *
|
|
|
|
* You should have received a copy of the GNU General Public License *
|
|
|
|
* along with this program; if not, write to the Free Software Foundation *
|
|
|
|
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA. *
|
|
|
|
******************************************************************************/
|
|
|
|
|
2015-08-29 01:16:16 +02:00
|
|
|
#include "icinga-studio/connectform.hpp"
|
|
|
|
#include "icinga-studio/mainform.hpp"
|
|
|
|
#include "base/application.hpp"
|
|
|
|
#include <wx/wx.h>
|
|
|
|
#include <wx/app.h>
|
|
|
|
#include <wx/config.h>
|
2014-04-12 04:21:09 +02:00
|
|
|
|
2015-08-29 01:16:16 +02:00
|
|
|
using namespace icinga;
|
2014-04-12 04:21:09 +02:00
|
|
|
|
2015-08-29 01:16:16 +02:00
|
|
|
class IcingaStudio : public wxApp
|
2014-04-12 04:21:09 +02:00
|
|
|
{
|
|
|
|
public:
|
2015-08-29 01:16:16 +02:00
|
|
|
virtual bool OnInit(void) override
|
|
|
|
{
|
|
|
|
Application::InitializeBase();
|
2014-05-03 20:02:22 +02:00
|
|
|
|
2015-08-29 01:16:16 +02:00
|
|
|
Url::Ptr pUrl;
|
2014-05-03 20:02:22 +02:00
|
|
|
|
2015-08-29 01:16:16 +02:00
|
|
|
if (argc < 2) {
|
|
|
|
wxConfig config("IcingaStudio");
|
|
|
|
wxString wUrl;
|
2014-05-03 20:02:22 +02:00
|
|
|
|
2015-08-29 01:16:16 +02:00
|
|
|
if (!config.Read("url", &wUrl))
|
|
|
|
wUrl = "https://localhost:5665/";
|
2014-05-03 20:02:22 +02:00
|
|
|
|
2015-08-29 01:16:16 +02:00
|
|
|
std::string url = wUrl.ToStdString();
|
2014-05-03 20:02:22 +02:00
|
|
|
|
2015-08-29 01:16:16 +02:00
|
|
|
ConnectForm f(NULL, new Url(url));
|
|
|
|
if (f.ShowModal() != wxID_OK)
|
|
|
|
return false;
|
2014-05-03 20:02:22 +02:00
|
|
|
|
2015-08-29 01:16:16 +02:00
|
|
|
pUrl = f.GetUrl();
|
2015-09-29 08:09:48 +02:00
|
|
|
url = pUrl->Format(true);
|
2015-08-29 01:16:16 +02:00
|
|
|
wUrl = url;
|
|
|
|
config.Write("url", wUrl);
|
|
|
|
} else {
|
|
|
|
pUrl = new Url(argv[1].ToStdString());
|
|
|
|
}
|
2015-02-14 16:34:36 +01:00
|
|
|
|
2015-08-29 01:16:16 +02:00
|
|
|
MainForm *m = new MainForm(NULL, pUrl);
|
|
|
|
m->Show();
|
2015-02-26 12:41:47 +01:00
|
|
|
|
2015-08-29 01:16:16 +02:00
|
|
|
return true;
|
|
|
|
}
|
2014-04-12 04:21:09 +02:00
|
|
|
};
|
|
|
|
|
2015-08-29 01:16:16 +02:00
|
|
|
wxIMPLEMENT_APP(IcingaStudio);
|