Skip to content

Commit

Permalink
Merge pull request #774 from subutai-io/dev
Browse files Browse the repository at this point in the history
Dev
  • Loading branch information
Erkin Matkaziev authored Mar 29, 2018
2 parents 02de65c + c10b273 commit 528cf31
Show file tree
Hide file tree
Showing 16 changed files with 355 additions and 106 deletions.
2 changes: 1 addition & 1 deletion SubutaiControlCenter.pro
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
#
#-------------------------------------------------

QT += core gui network websockets
QT += core gui network websockets quick
CONFIG += c++11


Expand Down
1 change: 1 addition & 0 deletions commons/include/OsBranchConsts.h
Original file line number Diff line number Diff line change
Expand Up @@ -83,4 +83,5 @@ const QString& x2goclient_url();
const QString& current_branch_name();
const QString& branch_name_str();
const QString& base_interface_name();
void current_os_info(std::vector<std::pair<QString, QString> >& v);
#endif // OSBRANCHCONSTS_H
91 changes: 71 additions & 20 deletions commons/src/OsBranchConsts.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@

#include <QApplication>
#include <QDir>
#include <QSysInfo>
#include "SystemCallWrapper.h"

template<class BR, class OS> const QString& p2p_kurjun_file_name_temp_internal();

Expand Down Expand Up @@ -51,28 +53,42 @@ p2p_kurjun_package_name() {
return p2p_kurjun_package_name_temp_internal<Branch2Type<CURRENT_BRANCH>, Os2Type<CURRENT_OS> >();
}
//////////////////////////////////////////////////////////////////////////////////////////
template<class BR, class OS> const QString& oracle_virtualbox_kurjun_package_name_temp_internal();

#define oracle_virtualbox_kurjun_package_name_def(BT_TYPE, OS_TYPE, STRING) \
template<> \
const QString& oracle_virtualbox_kurjun_package_name_temp_internal<Branch2Type<BT_TYPE>, Os2Type<OS_TYPE> >() { \
static QString res(STRING); \
return res; \
}

oracle_virtualbox_kurjun_package_name_def(BT_MASTER, OS_MAC, "VirtualBox.pkg")
oracle_virtualbox_kurjun_package_name_def(BT_MASTER, OS_WIN, "VirtualBox-5.2.8-121009-Win.exe")
oracle_virtualbox_kurjun_package_name_def(BT_MASTER, OS_LINUX, "virtualBox-5.2.8-Linux_amd64.run")
oracle_virtualbox_kurjun_package_name_def(BT_DEV, OS_LINUX, "subutai-p2p-dev.deb")
oracle_virtualbox_kurjun_package_name_def(BT_DEV, OS_MAC, "VirtualBox.pkg")
oracle_virtualbox_kurjun_package_name_def(BT_DEV, OS_WIN, "VirtualBox-5.2.8-121009-Win.exe")
oracle_virtualbox_kurjun_package_name_def(BT_PROD, OS_LINUX, "virtualBox-5.2.8-Linux_amd64.run")
oracle_virtualbox_kurjun_package_name_def(BT_PROD, OS_MAC, "VirtualBox.pkg")
oracle_virtualbox_kurjun_package_name_def(BT_PROD, OS_WIN, "VirtualBox-5.2.8-121009-Win.exe")

const QString &
oracle_virtualbox_kurjun_package_name() {
return oracle_virtualbox_kurjun_package_name_temp_internal<Branch2Type<CURRENT_BRANCH>, Os2Type<CURRENT_OS> >();
static std::vector <std::pair<QString , QString> > info;
static QString kurjun_file = "not_found";
if(info.empty())
current_os_info(info);
if(info.empty())
return kurjun_file;
//first check type of os
QString type = info.begin()->second;
if(type == "Windows")
kurjun_file = "VirtualBox-5.2.8-121009-Win.exe";
else if(type == "Mac")
kurjun_file = "VirtualBox.pkg";
if(kurjun_file != "not_found")
return kurjun_file;
if(info.size() < 2 || info[0].second != "Linux")
return kurjun_file;
QString codename = info[1].second;
if(codename == "bionic")
kurjun_file = "virtualbox-5.2_5.2.8-121009_Ubuntu_bionic_amd64.deb";
else if(codename == "zesty")
kurjun_file = "";
else if(codename == "yakkety")
kurjun_file = "";
else if(codename == "xenial")
kurjun_file = "virtualbox-5.2_5.2.8-121009_Ubuntu_xenial_amd64.deb";
else if(codename == "trusty")
kurjun_file = "virtualbox-5.2_5.2.8-121009_Ubuntu_trusty_amd64.deb";
else if(codename == "stretch")
kurjun_file = "virtualbox-5.2_5.2.8-121009_Debian_stretch_amd64.deb";
else if(codename == "jessie")
kurjun_file = "virtualbox-5.2_5.2.8-121009_Debian_jessie_amd64.deb";
else if(codename == "wheezy")
kurjun_file = "";
return kurjun_file;
}
//////////////////////////////////////////////////////////////////////////////////////////
template<class BR, class OS> const QString& x2go_kurjun_package_name_temp_internal();
Expand Down Expand Up @@ -712,3 +728,38 @@ const QString&
base_interface_name() {
return base_interface_name_internal< Os2Type<CURRENT_OS> >();
}

////////////////////////////////////////////////////////////////////////////

void current_os_info(std::vector<std::pair<QString, QString> >& v){
v.clear();
QString flag, st;
QStringList output;
switch (CURRENT_OS) {
case OS_WIN:
v.push_back(std::make_pair("TYPE", "Windows"));
v.push_back(std::make_pair("VERSION:",QSysInfo::productVersion()));
break;
case OS_MAC:
v.push_back(std::make_pair("TYPE", "Mac"));
v.push_back(std::make_pair("VERSION:", QSysInfo::productVersion()));
break;
case OS_LINUX:
v.push_back(std::make_pair("TYPE", "Linux"));
output = CSystemCallWrapper::lsb_release();
for (auto s : output){
flag = st = "";
for (int i = 0; i < s.length(); i++)
if(s[i] == '\t'){
flag = st;
st = "";
}
else st += s[i];
if(flag == "Codename:")
v.push_back(std::make_pair("CODE", st));
}
break;
default:
break;
}
}
75 changes: 41 additions & 34 deletions hub/forms/DlgLogin.ui
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,31 @@
<layout class="QVBoxLayout" name="verticalLayout">
<item>
<layout class="QGridLayout" name="gridLayout_5">
<item row="3" column="0">
<layout class="QGridLayout" name="gridLayout_2">
<item row="0" column="0">
<widget class="QPushButton" name="btn_ok">
<property name="text">
<string>Sign in</string>
</property>
</widget>
</item>
<item row="0" column="1">
<widget class="QLabel" name="lbl_register_link">
<property name="text">
<string>Register</string>
</property>
</widget>
</item>
<item row="0" column="2">
<widget class="QPushButton" name="btn_cancel">
<property name="text">
<string>Cancel</string>
</property>
</widget>
</item>
</layout>
</item>
<item row="0" column="0">
<layout class="QGridLayout" name="gridLayout" columnstretch="1,3">
<item row="0" column="0">
Expand Down Expand Up @@ -48,6 +73,19 @@
</item>
</layout>
</item>
<item row="4" column="0">
<widget class="QLabel" name="lbl_status">
<property name="text">
<string>lbl_status</string>
</property>
<property name="textFormat">
<enum>Qt::RichText</enum>
</property>
<property name="alignment">
<set>Qt::AlignCenter</set>
</property>
</widget>
</item>
<item row="1" column="0">
<layout class="QGridLayout" name="gridLayout_4" columnstretch="2,1,2">
<item row="0" column="0">
Expand Down Expand Up @@ -122,41 +160,10 @@
</item>
</layout>
</item>
<item row="3" column="0">
<layout class="QGridLayout" name="gridLayout_2">
<item row="0" column="0">
<widget class="QPushButton" name="btn_ok">
<property name="text">
<string>Sign in</string>
</property>
</widget>
</item>
<item row="0" column="1">
<widget class="QLabel" name="lbl_register_link">
<property name="text">
<string>Register</string>
</property>
</widget>
</item>
<item row="0" column="2">
<widget class="QPushButton" name="btn_cancel">
<property name="text">
<string>Cancel</string>
</property>
</widget>
</item>
</layout>
</item>
<item row="4" column="0">
<widget class="QLabel" name="lbl_status">
<item row="5" column="0">
<widget class="QPushButton" name="btn_resolve">
<property name="text">
<string>lbl_status</string>
</property>
<property name="textFormat">
<enum>Qt::RichText</enum>
</property>
<property name="alignment">
<set>Qt::AlignCenter</set>
<string>Resolve</string>
</property>
</widget>
</item>
Expand Down
1 change: 1 addition & 0 deletions hub/include/DlgLogin.h
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ class DlgLogin : public QDialog
* \brief Run dialog in different modes. When "Remember me" flag checked - it tries to login without dialog.
*/
void run_dialog(QSplashScreen *sc);
void solve_libssl();

private slots:
void btn_ok_released();
Expand Down
3 changes: 2 additions & 1 deletion hub/include/DlgNotification.h
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,8 @@ class DlgNotification : public QDialog
public:

enum NOTIFICATION_ACTION_TYPE{N_UPDATE_P2P = 0, N_UPDATE_TRAY, N_UPDATE_RH, N_UPDATE_RHM,
N_SETTINGS, N_GO_TO_HUB, N_NOTF_HISTORY, N_RESTART_TRAY, N_ABOUT, N_NO_ACTION, N_START_P2P, N_INSTALL_P2P};
N_SETTINGS, N_GO_TO_HUB, N_NOTF_HISTORY, N_RESTART_TRAY, N_ABOUT, N_NO_ACTION,
N_START_P2P, N_INSTALL_P2P, N_RESOLVE_LIBSSL, N_STOP_P2P};


explicit DlgNotification(size_t notification_level,
Expand Down
9 changes: 8 additions & 1 deletion hub/include/SystemCallWrapper.h
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,8 @@
//give type for restart p2p
enum restart_p2p_type{
UPDATED_P2P=0, //when p2p updated, stop and start
STOPPED_P2P //when p2p is stopped, start
STOPPED_P2P, //when p2p is stopped, start
STARTED_P2P //when p2p is started, stop
};

// if you are going to change this - change method
Expand Down Expand Up @@ -157,6 +158,12 @@ class CSystemCallWrapper {

static system_call_wrapper_error_t install_oracle_virtualbox(const QString &dir, const QString &file_name);

static void run_linux_script(QStringList args);

static system_call_wrapper_error_t install_libssl();

static QStringList lsb_release();

static system_call_wrapper_error_t run_sshpass_in_terminal(const QString &user,
const QString &ip,
const QString &port,
Expand Down
6 changes: 3 additions & 3 deletions hub/include/TrayControlWindow.h
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ class TrayControlWindow : public QMainWindow

public:
explicit TrayControlWindow(QWidget *parent = 0);
virtual ~TrayControlWindow();
virtual ~TrayControlWindow();
P2PStatus_checker::P2P_STATUS p2p_current_status;
static TrayControlWindow* Instance(){
static TrayControlWindow *tcw = new TrayControlWindow();
Expand Down Expand Up @@ -86,7 +86,7 @@ class TrayControlWindow : public QMainWindow
QAction *m_act_notifications_history;

QSystemTrayIcon* m_sys_tray_icon;
QMenu* m_tray_menu;
QMenu* m_tray_menu;

QAction *m_act_p2p_status; // p2p status

Expand All @@ -98,7 +98,7 @@ class TrayControlWindow : public QMainWindow
void get_sys_tray_icon_coordinates_for_dialog(int &src_x, int &src_y,
int &dst_x, int &dst_y, int dlg_w, int dlg_h,
bool use_cursor_position);
void fill_launch_menu();
void fill_launch_menu();

/*tray icon end*/

Expand Down
3 changes: 3 additions & 0 deletions hub/include/updater/HubComponentsUpdater.h
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,12 @@
#include <QTimer>
#include <map>
#include <QFuture>
#include <QCoreApplication>
#include <QtConcurrent/QtConcurrent>

#include "updater/IUpdaterComponent.h"
#include "NotificationObserver.h"
#include "DlgNotification.h"
#include "SystemCallWrapper.h"
#include "SettingsManager.h"

Expand Down
4 changes: 0 additions & 4 deletions hub/src/DlgAbout.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -389,10 +389,6 @@ DlgAboutInitializer::do_initialization() {
////////////////////////////////////////////////////////////////////////////
void DlgAbout::install_finished(const QString &file_id, bool success){
qDebug()<<"Install finished for"<<file_id<<"with result"<<success;
if(!success){
CNotificationObserver::Error(tr("Installation of %1 failed").arg(CHubComponentsUpdater::Instance()->component_name(file_id)),
DlgNotification::N_NO_ACTION);
}
if (m_dct_fpb.find(file_id) == m_dct_fpb.end()) return;
m_dct_fpb[file_id].btn->setEnabled(false);
m_dct_fpb[file_id].pb->setEnabled(false);
Expand Down
17 changes: 16 additions & 1 deletion hub/src/DlgEnvironment.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,8 @@ DlgEnvironment::DlgEnvironment(QWidget *parent) :

void DlgEnvironment::select_all(bool checked) {
for (CHubContainer cont : env.containers()) {
if(selected_conts.find(cont.id()) == selected_conts.end())
continue;
QCheckBox *current_check_box = selected_conts[cont.id()];
current_check_box->setChecked(checked);
}
Expand All @@ -40,6 +42,8 @@ void DlgEnvironment::upload_selected() {
ui->btn_upload_selected->setEnabled(false);
ui->btn_upload_selected->setText(tr("Loading.."));
for (CHubContainer cont : env.containers()) {
if(selected_conts.find(cont.id()) == selected_conts.end())
continue;
QCheckBox *current_check_box = selected_conts[cont.id()];
if (current_check_box->isChecked())
{
Expand All @@ -59,6 +63,8 @@ void DlgEnvironment::desktop_selected() {
ui->btn_desktop_selected->setEnabled(false);
ui->btn_desktop_selected->setText(tr("Opening X2Go-Client.."));
for (CHubContainer cont : env.containers()) {
if(selected_conts.find(cont.id()) == selected_conts.end())
continue;
QCheckBox *current_check_box = selected_conts[cont.id()];
if (current_check_box->isChecked())
{
Expand All @@ -77,6 +83,8 @@ void DlgEnvironment::ssh_selected() {
ui->btn_ssh_selected->setEnabled(false);
ui->btn_ssh_selected->setText(tr("Running ssh commands.."));
for (CHubContainer cont : env.containers()) {
if(selected_conts.find(cont.id()) == selected_conts.end())
continue;
QCheckBox *current_check_box = selected_conts[cont.id()];
if (current_check_box->isChecked())
{
Expand Down Expand Up @@ -124,8 +132,8 @@ void DlgEnvironment::addEnvironment(const CEnvironment *_env) {
timer->setInterval(7000);
connect(timer, &QTimer::timeout, this, &DlgEnvironment::check_environment_status);
timer->start();

check_environment_status();
timers.push_back(timer);
}

//////////////////////////////////////////////////////////////////////////
Expand All @@ -137,6 +145,11 @@ void DlgEnvironment::addContainer(const CHubContainer *cont) {
QLabel *cont_desktop_info = new QLabel(cont->is_desktop() ? cont->desk_env().isEmpty() ? "MATE" : cont->desk_env() : "No Desktop", this);
QCheckBox *cont_select = new QCheckBox("READY" , this);

labels.push_back(cont_name);
labels.push_back(cont_rhip_port);
labels.push_back(cont_desktop_info);
checkboxs.push_back(cont_select);

cont_name->setTextInteractionFlags(Qt::TextSelectableByMouse);
cont_rhip_port->setTextInteractionFlags(Qt::TextSelectableByMouse);
cont_desktop_info->setTextInteractionFlags(Qt::TextSelectableByMouse);
Expand Down Expand Up @@ -254,6 +267,8 @@ void DlgEnvironment::check_buttons() {
bool connected_to_swarm = (env.healthy() & (swarm_status == P2PController::CONNECTION_SUCCESS));
if(connected_to_swarm){
for (CHubContainer cont : env.containers()) {
if(selected_conts.find(cont.id()) == selected_conts.end())
continue;
QCheckBox *current_check_box = selected_conts[cont.id()];
if(current_check_box->checkState() == Qt::Checked){
if(current_check_box->text() != "READY"){
Expand Down
Loading

0 comments on commit 528cf31

Please sign in to comment.