Skip to content

Commit

Permalink
Merge pull request #849 from subutai-io/dev
Browse files Browse the repository at this point in the history
Dev
  • Loading branch information
crioto authored Apr 16, 2018
2 parents 20f04a1 + 4bf62bd commit f11b663
Show file tree
Hide file tree
Showing 8 changed files with 65 additions and 52 deletions.
6 changes: 6 additions & 0 deletions DlgCreatePeer.ui
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,9 @@
</item>
<item row="15" column="0">
<widget class="QPushButton" name="btn_cancel">
<property name="focusPolicy">
<enum>Qt::NoFocus</enum>
</property>
<property name="text">
<string>Cancel</string>
</property>
Expand Down Expand Up @@ -238,6 +241,9 @@
<property name="text">
<string>Create</string>
</property>
<property name="default">
<bool>true</bool>
</property>
</widget>
</item>
<item row="9" column="1">
Expand Down
2 changes: 1 addition & 1 deletion hub/forms/DlgPeer.ui
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@
<item row="2" column="3">
<widget class="QPushButton" name="btn_ssh_peer">
<property name="toolTip">
<string>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p&gt;SSH into container&lt;/p&gt;&lt;p&gt;&lt;br/&gt;&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
<string>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p&gt;SSH into RH&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
</property>
<property name="text">
<string>SSH into Peer</string>
Expand Down
6 changes: 3 additions & 3 deletions hub/include/DlgEnvironment.h
Original file line number Diff line number Diff line change
Expand Up @@ -41,9 +41,9 @@ class DlgEnvironment : public QDialog
std::vector <QCheckBox*> checkboxs;

signals:
void ssh_to_container_sig(const CEnvironment*, const CHubContainer*);
void desktop_to_container_sig(const CEnvironment*, const CHubContainer*);
void upload_to_container_sig(const CEnvironment*, const CHubContainer*);
void ssh_to_container_sig(const CEnvironment, const CHubContainer);
void desktop_to_container_sig(const CEnvironment, const CHubContainer);
void upload_to_container_sig(const CEnvironment, const CHubContainer);
};

#endif // DLGENVIRONMENT_H
9 changes: 6 additions & 3 deletions hub/include/TrayControlWindow.h
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,9 @@ class TrayControlWindow : public QMainWindow
/*tray icon end*/

void show_dialog(QDialog* (*pf_dlg_create)(QWidget*), const QString &title);

/* mutexes */
QMutex m_mutex_peer_menu;
public slots:
/*tray slots*/
void show_about();
Expand Down Expand Up @@ -155,9 +158,9 @@ private slots:
void ssh_to_rh_triggered(const QString &peer_fingerprint);
void ssh_to_rh_finished_sl(const QString &peer_fingerprint, system_call_wrapper_error_t res, int libssh_exit_code);

void upload_to_container_triggered(const CEnvironment *env, const CHubContainer *cont);
void ssh_to_container_triggered(const CEnvironment *env, const CHubContainer *cont);
void desktop_to_container_triggered(const CEnvironment *env, const CHubContainer *cont);
void upload_to_container_triggered(const CEnvironment &env, const CHubContainer &cont);
void ssh_to_container_triggered(const CEnvironment &env, const CHubContainer &cont);
void desktop_to_container_triggered(const CEnvironment &env, const CHubContainer &cont);

void ssh_key_generate_triggered();

Expand Down
12 changes: 6 additions & 6 deletions hub/src/DlgEnvironment.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -47,11 +47,11 @@ void DlgEnvironment::upload_selected() {
QCheckBox *current_check_box = selected_conts[cont.id()];
if (current_check_box->isChecked())
{
emit upload_to_container_sig(&env, &cont);
emit upload_to_container_sig(env, cont);
}
}

QTimer::singleShot(2000, [this](){
QTimer::singleShot(2000, this, [this](){
this->ui->btn_upload_selected->setEnabled(true);
this->ui->btn_upload_selected->setText(tr("Transfer File"));
});
Expand All @@ -68,10 +68,10 @@ void DlgEnvironment::desktop_selected() {
QCheckBox *current_check_box = selected_conts[cont.id()];
if (current_check_box->isChecked())
{
emit desktop_to_container_sig(&env, &cont);
emit desktop_to_container_sig(env, cont);
}
}
QTimer::singleShot(2000, [this](){
QTimer::singleShot(2000, this, [this](){
this->ui->btn_desktop_selected->setEnabled(true);
this->ui->btn_desktop_selected->setText(tr("Remote Desktop"));
});
Expand All @@ -88,10 +88,10 @@ void DlgEnvironment::ssh_selected() {
QCheckBox *current_check_box = selected_conts[cont.id()];
if (current_check_box->isChecked())
{
emit ssh_to_container_sig(&env, &cont);
emit ssh_to_container_sig(env, cont);
}
}
QTimer::singleShot(2000, [this](){
QTimer::singleShot(2000, this, [this](){
this->ui->btn_ssh_selected->setEnabled(true);
this->ui->btn_ssh_selected->setText(tr("SSH"));
});
Expand Down
1 change: 0 additions & 1 deletion hub/src/PeerController.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,6 @@ void CPeerController::get_peer_info(const QFileInfo &fi, QDir dir){
return;
number_threads++;
dir.cd(fi.fileName());
emit got_peer_info(3, peer_name, dir.absolutePath(), QString(""));
// get status of peer
GetPeerInfo *thread_for_status = new GetPeerInfo(this);
thread_for_status->init(dir.absolutePath(), status_type);
Expand Down
35 changes: 25 additions & 10 deletions hub/src/SystemCallWrapper.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1074,7 +1074,7 @@ system_call_wrapper_error_t vagrant_command_terminal_internal<Os2Type<OS_MAC> >
UNUSED_ARG(name);
QString str_command = QString("cd %1; %2 %3 2> %4_%5;").arg(dir,
CSettingsManager::Instance().vagrant_path(),
*(command.split(" ").begin()),
command,
name, *(command.split(" ").begin()));
if(command == "reload"){
str_command += QString("%1 provision 2>> %3_%2; ").arg(CSettingsManager::Instance().vagrant_path(), command, name);
Expand All @@ -1099,13 +1099,20 @@ template <>
system_call_wrapper_error_t vagrant_command_terminal_internal<Os2Type<OS_LINUX> >(const QString &dir,
const QString &command,
const QString &name){
if(command.isEmpty()){
return SCWE_CREATE_PROCESS;
}

UNUSED_ARG(name);
QString str_command = QString("cd %1; %2 %3 2> %4_%5;").arg(dir,
CSettingsManager::Instance().vagrant_path(),
command,
name, command);
if(command == "reload")
name, *(command.split(" ").begin()));
if(command == "reload"){
str_command += QString("%1 provision 2>> %3_%2; ").arg(CSettingsManager::Instance().vagrant_path(), command, name);
str_command += QString("echo finished > %1_finished; exit").arg(command);
}

str_command += QString("echo finished > %1_finished; exit").arg(*(command.split(" ").begin()));

QString cmd;
QFile cmd_file(CSettingsManager::Instance().terminal_cmd());
Expand All @@ -1132,12 +1139,20 @@ UNUSED_ARG(name);
UNUSED_ARG(dir);
UNUSED_ARG(command);
#ifdef RT_OS_WINDOWS
QString str_command = QString("cd %1 & \"%2\" %3 2> %4_%5 & echo finished > %3_finished; & exit")
.arg(dir)
.arg(CSettingsManager::Instance().vagrant_path())
.arg(command)
.arg(name)
.arg(command);

if(command.isEmpty()){
return SCWE_CREATE_PROCESS;
}

QString str_command = QString("cd %1 & %2 %3 2> %4_%5 & ").arg(dir,
CSettingsManager::Instance().vagrant_path(),
command,
name, *(command.split(" ").begin()));
if(command == "reload"){
str_command += QString("%1 provision 2>> %3_%2 & ").arg(CSettingsManager::Instance().vagrant_path(), command, name);
}

str_command += QString("echo finished > %1_finished & exit").arg(*(command.split(" ").begin()));

QString cmd;
QFile cmd_file(CSettingsManager::Instance().terminal_cmd());
Expand Down
46 changes: 18 additions & 28 deletions hub/src/TrayControlWindow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -456,12 +456,8 @@ void TrayControlWindow::login_success() {
////////////////////////////////////////////////////////////////////////////
#include "DlgTransferFile.h"

void TrayControlWindow::upload_to_container_triggered(const CEnvironment* env,
const CHubContainer* cont) {
if(env == nullptr || cont == nullptr){
CNotificationObserver::Instance()->Info(tr("Failed to parse from dialog box. Please close and open again environment dialog."), DlgNotification::N_NO_ACTION);
return;
}
void TrayControlWindow::upload_to_container_triggered(const CEnvironment &env,
const CHubContainer &cont) {
//generate_transferfile_dlg();
DlgTransferFile *dlg_transfer_file = new DlgTransferFile(this);
Qt::WindowFlags flags = 0;
Expand All @@ -471,9 +467,9 @@ void TrayControlWindow::upload_to_container_triggered(const CEnvironment* env,
flags |= Qt::WindowCloseButtonHint;
dlg_transfer_file->setWindowFlags(flags);
CSystemCallWrapper::container_ip_and_port cip =
CSystemCallWrapper::container_ip_from_ifconfig_analog(cont->port(), cont->ip(), cont->rh_ip());
CSystemCallWrapper::container_ip_from_ifconfig_analog(cont.port(), cont.ip(), cont.rh_ip());

QString ssh_key = CHubController::Instance().get_env_key(env->id());
QString ssh_key = CHubController::Instance().get_env_key(env.id());
QString ip = cip.ip;
QString port = cip.port;
QString username = CSettingsManager::Instance().ssh_user();
Expand All @@ -482,19 +478,15 @@ void TrayControlWindow::upload_to_container_triggered(const CEnvironment* env,
dlg_transfer_file->addSSHKey(ssh_key);
dlg_transfer_file->addUser(username);
m_last_generated_tranferfile_dlg = dlg_transfer_file;
show_dialog(last_generated_transferfile_dlg, "Transfer File " + env->name() + "/" + cont->name());
show_dialog(last_generated_transferfile_dlg, "Transfer File " + env.name() + "/" + cont.name());
}

void TrayControlWindow::ssh_to_container_triggered(const CEnvironment* env,
const CHubContainer* cont) {
if(env == nullptr || cont == nullptr){
CNotificationObserver::Instance()->Info(tr("Failed to parse from dialog box. Please close and open again environment dialog."), DlgNotification::N_NO_ACTION);
return;
}
void TrayControlWindow::ssh_to_container_triggered(const CEnvironment &env,
const CHubContainer &cont) {
qDebug()
<< QString("Environment [name: %1, id: %2]").arg(env->name(), env->id())
<< QString("Container [name: %1, id: %2]").arg(cont->name(), cont->id());
CHubController::Instance().ssh_to_container_from_tray(*env, *cont);
<< QString("Environment [name: %1, id: %2]").arg(env.name(), env.id())
<< QString("Container [name: %1, id: %2]").arg(cont.name(), cont.id());
CHubController::Instance().ssh_to_container_from_tray(env, cont);
}

////////////////////////////////////////////////////////////////////////////
Expand Down Expand Up @@ -523,22 +515,18 @@ void TrayControlWindow::ssh_to_rh_finished_sl(const QString &peer_fingerprint, s

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

void TrayControlWindow::desktop_to_container_triggered(const CEnvironment* env,
const CHubContainer* cont) {
if(env == nullptr || cont == nullptr){
CNotificationObserver::Instance()->Info(tr("Failed to parse from dialog box. Please close and open again environment dialog."), DlgNotification::N_NO_ACTION);
return;
}
void TrayControlWindow::desktop_to_container_triggered(const CEnvironment &env,
const CHubContainer &cont) {
qDebug()
<< QString("Environment [name: %1, id: %2]").arg(env->name(), env->id())
<< QString("Container [name: %1, id: %2]").arg(cont->name(), cont->id())
<< QString("Environment [name: %1, id: %2]").arg(env.name(), env.id())
<< QString("Container [name: %1, id: %2]").arg(cont.name(), cont.id())
<< QString("X2go is Launchable: %1").arg(CSystemCallWrapper::x2goclient_check());
if (!CSystemCallWrapper::x2goclient_check()) {
CNotificationObserver::Error(QObject::tr("X2Go-Client is not launchable. Make sure x2go-client is istalled from \"About\" settings.")
CNotificationObserver::Error(QObject::tr("X2Go-Client is not launchable. Make sure x2go-client is installed from \"About\" settings.")
.arg(x2goclient_url()), DlgNotification::N_ABOUT);
return;
}
CHubController::Instance().desktop_to_container_from_tray(*env, *cont);
CHubController::Instance().desktop_to_container_from_tray(env, cont);
}


Expand Down Expand Up @@ -735,6 +723,8 @@ void TrayControlWindow::my_peers_updated_sl() {
}

void TrayControlWindow::update_peer_menu() {
QMutexLocker locker(&m_mutex_peer_menu);

static QIcon online_icon(":/hub/GOOD.png");
static QIcon offline_icon(":/hub/BAD.png");
static QIcon unknown_icon(":/hub/OK.png");
Expand Down

0 comments on commit f11b663

Please sign in to comment.