]> granicus.if.org Git - icinga2/blob - icinga-studio/icinga-studio.cpp
Hide console windows during installation
[icinga2] / icinga-studio / icinga-studio.cpp
1 /******************************************************************************
2  * Icinga 2                                                                   *
3  * Copyright (C) 2012-2016 Icinga Development Team (https://www.icinga.org/)  *
4  *                                                                            *
5  * This program is free software; you can redistribute it and/or              *
6  * modify it under the terms of the GNU General Public License                *
7  * as published by the Free Software Foundation; either version 2             *
8  * of the License, or (at your option) any later version.                     *
9  *                                                                            *
10  * This program is distributed in the hope that it will be useful,            *
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of             *
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the              *
13  * GNU General Public License for more details.                               *
14  *                                                                            *
15  * You should have received a copy of the GNU General Public License          *
16  * along with this program; if not, write to the Free Software Foundation     *
17  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA.             *
18  ******************************************************************************/
19
20 #include "icinga-studio/connectform.hpp"
21 #include "icinga-studio/mainform.hpp"
22 #include "base/application.hpp"
23 #include <wx/wx.h>
24 #include <wx/app.h>
25 #include <wx/config.h>
26
27 using namespace icinga;
28
29 class IcingaStudio : public wxApp
30 {
31 public:
32         virtual bool OnInit(void) override
33         {
34                 Application::InitializeBase();
35
36                 Url::Ptr pUrl;
37
38                 if (argc < 2) {
39                         wxConfig config("IcingaStudio");
40                         wxString wUrl;
41
42                         if (!config.Read("url", &wUrl))
43                                 wUrl = "https://localhost:5665/";
44
45                         std::string url = wUrl.ToStdString();
46
47                         ConnectForm f(NULL, new Url(url));
48                         if (f.ShowModal() != wxID_OK)
49                                 return false;
50
51                         pUrl = f.GetUrl();
52                         url = pUrl->Format(true);
53                         wUrl = url;
54                         config.Write("url", wUrl);
55                 } else {
56                         pUrl = new Url(argv[1].ToStdString());
57                 }
58
59                 MainForm *m = new MainForm(NULL, pUrl);
60                 m->Show();
61
62                 return true;
63         }
64 };
65
66 wxIMPLEMENT_APP(IcingaStudio);