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 <boost/algorithm/string/split.hpp>
|
|
|
|
#include <boost/algorithm/string/classification.hpp>
|
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
|
|
|
ConnectForm::ConnectForm(wxWindow *parent, const Url::Ptr& url)
|
|
|
|
: ConnectFormBase(parent)
|
2014-04-12 04:21:09 +02:00
|
|
|
{
|
2015-08-29 01:16:16 +02:00
|
|
|
#ifdef _WIN32
|
|
|
|
SetIcon(wxICON(icinga));
|
|
|
|
#endif /* _WIN32 */
|
2014-04-12 04:21:09 +02:00
|
|
|
|
2015-08-29 01:16:16 +02:00
|
|
|
std::string authority = url->GetAuthority();
|
2014-05-03 20:02:22 +02:00
|
|
|
|
2015-08-29 01:16:16 +02:00
|
|
|
std::vector<std::string> tokens;
|
|
|
|
boost::algorithm::split(tokens, authority, boost::is_any_of("@"));
|
2014-05-03 20:02:22 +02:00
|
|
|
|
2015-08-29 01:16:16 +02:00
|
|
|
if (tokens.size() > 1) {
|
|
|
|
std::vector<std::string> userinfo;
|
|
|
|
boost::algorithm::split(userinfo, tokens[0], boost::is_any_of(":"));
|
2014-05-03 20:02:22 +02:00
|
|
|
|
2015-08-29 01:16:16 +02:00
|
|
|
m_UserText->SetValue(userinfo[0]);
|
|
|
|
m_PasswordText->SetValue(userinfo[1]);
|
|
|
|
}
|
2014-05-03 20:02:22 +02:00
|
|
|
|
2015-08-29 01:16:16 +02:00
|
|
|
std::vector<std::string> hostport;
|
|
|
|
boost::algorithm::split(hostport, tokens.size() > 1 ? tokens[1] : tokens[0], boost::is_any_of(":"));
|
2015-02-14 16:34:36 +01:00
|
|
|
|
2015-08-29 01:16:16 +02:00
|
|
|
m_HostText->SetValue(hostport[0]);
|
2015-02-26 12:41:47 +01:00
|
|
|
|
2015-08-29 01:16:16 +02:00
|
|
|
if (hostport.size() > 1)
|
|
|
|
m_PortText->SetValue(hostport[1]);
|
|
|
|
else
|
|
|
|
m_PortText->SetValue("5665");
|
2015-10-01 06:07:40 +02:00
|
|
|
|
|
|
|
SetDefaultItem(m_ButtonsOK);
|
2015-08-29 01:16:16 +02:00
|
|
|
}
|
2015-06-22 11:11:21 +02:00
|
|
|
|
2015-08-29 01:16:16 +02:00
|
|
|
Url::Ptr ConnectForm::GetUrl(void) const
|
|
|
|
{
|
|
|
|
wxString url = "https://" + m_UserText->GetValue() + ":" + m_PasswordText->GetValue()
|
|
|
|
+ "@" + m_HostText->GetValue() + ":" + m_PortText->GetValue() + "/";
|
2014-04-12 04:21:09 +02:00
|
|
|
|
2015-08-29 01:16:16 +02:00
|
|
|
return new Url(url.ToStdString());
|
2014-04-12 04:21:09 +02:00
|
|
|
}
|