Skip to content
This repository has been archived by the owner on Nov 25, 2020. It is now read-only.

Commit

Permalink
show installed firmware
Browse files Browse the repository at this point in the history
  • Loading branch information
LazyT committed Oct 5, 2018
1 parent 6472e12 commit 57235aa
Show file tree
Hide file tree
Showing 9 changed files with 242 additions and 102 deletions.
Binary file modified lng/rrcc_de.qm
Binary file not shown.
240 changes: 140 additions & 100 deletions lng/rrcc_de.ts

Large diffs are not rendered by default.

74 changes: 74 additions & 0 deletions mainwindow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -893,6 +893,60 @@ void MainWindow::parseJSON(int mid, QByteArray data)
}
}

void MainWindow::ssh_connected()
{
if(cfg.ssh_auth == "PKey")
{
QFile file_key(cfg.ssh_pkey);

if(file_key.open(QIODevice::ReadOnly))
{
QByteArray key = file_key.readAll();

file_key.close();

ssh->loginKey(cfg.ssh_user, key, cfg.ssh_pkpp);
}
}
else
{
ssh->login(cfg.ssh_user, cfg.ssh_pass);
}
}

void MainWindow::ssh_loginSuccessful()
{
ssh->executeCommand("cat /etc/os-release | grep ROBOROCK_VERSION");
}

void MainWindow::ssh_commandExecuted(__attribute__((unused)) QString command, QString response)
{
QByteArray firmware = response.toUtf8();

ssh->disconnectFromHost();

if(firmware.contains("ROBOROCK_VERSION"))
{
QMessageBox::information(this, APPNAME, tr("Firmware %1 installed.").arg(QString(firmware.split('=').at(1))));
}
else
{
QMessageBox::warning(this, APPNAME, tr("Firmware detection failed:\n\n%1").arg(response.isEmpty() ? tr("got empty response") : response));
}
}

void MainWindow::ssh_disconnected()
{
delete ssh;
}

void MainWindow::ssh_error(QSshSocket::SshError error)
{
ssh->disconnectFromHost();

QMessageBox::warning(this, APPNAME, tr("SSH connection error!\n\n%1").arg(ssh_error_strings.at(error)));
}

void MainWindow::on_actionExit_triggered()
{
close();
Expand Down Expand Up @@ -1006,6 +1060,26 @@ void MainWindow::on_actionValetudoUninstall_triggered()
}
}

void MainWindow::on_actionCheckFirmware_triggered()
{
if(cfg.ssh_pass.isEmpty() && cfg.ssh_pkey.isEmpty())
{
QMessageBox::warning(this, APPNAME, tr("Please setup your ssh settings first!"));
}
else
{
ssh = new QSshSocket(this);

connect(ssh, SIGNAL(connected()), this, SLOT(ssh_connected()));
connect(ssh, SIGNAL(disconnected()), this, SLOT(ssh_disconnected()));
connect(ssh, SIGNAL(error(QSshSocket::SshError)), this, SLOT(ssh_error(QSshSocket::SshError)));
connect(ssh, SIGNAL(loginSuccessful()), this, SLOT(ssh_loginSuccessful()));
connect(ssh, SIGNAL(commandExecuted(QString, QString)), this, SLOT(ssh_commandExecuted(QString, QString)));

ssh->connectToHost(cfg.ip);
}
}

void MainWindow::on_actionUpdateFirmware_triggered()
{
if(QMessageBox::question(this, APPNAME, tr("Are you really sure you want to install a firmware update?\n\nPlease choose the correct version for your model or you will brick your device!"), QMessageBox::Yes | QMessageBox::No, QMessageBox::No) == QMessageBox::Yes)
Expand Down
8 changes: 8 additions & 0 deletions mainwindow.h
Original file line number Diff line number Diff line change
Expand Up @@ -349,6 +349,7 @@ class MainWindow : public QMainWindow, private Ui::MainWindow
QActionGroup *group_map;
QRubberBand *rubberBand;
qreal scale;
QSshSocket *ssh;

private slots:

Expand All @@ -362,6 +363,7 @@ private slots:
void on_actionZones_triggered();
void on_actionValetudoInstall_triggered();
void on_actionValetudoUninstall_triggered();
void on_actionCheckFirmware_triggered();
void on_actionUpdateFirmware_triggered();
void on_actionHelp_triggered();
void on_actionAbout_triggered();
Expand Down Expand Up @@ -392,6 +394,12 @@ private slots:
void hovered(QAction*);
void aboutToHide();

void ssh_connected();
void ssh_disconnected();
void ssh_error(QSshSocket::SshError);
void ssh_loginSuccessful();
void ssh_commandExecuted(QString, QString);

void resizeEvent(QResizeEvent*);
void mousePressEvent(QMouseEvent*);
void mouseMoveEvent(QMouseEvent*);
Expand Down
Binary file added res/png/fw_chk.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added res/png/fw_upd.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file removed res/png/parcel.png
Binary file not shown.
3 changes: 2 additions & 1 deletion res/rrcc.qrc
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,7 @@
<file>png/rotate.png</file>
<file>png/flip.png</file>
<file>png/question.png</file>
<file>png/parcel.png</file>
<file>png/fw_chk.png</file>
<file>png/fw_upd.png</file>
</qresource>
</RCC>
19 changes: 18 additions & 1 deletion res/ui/mainwindow.ui
Original file line number Diff line number Diff line change
Expand Up @@ -768,6 +768,7 @@
<property name="title">
<string>Firmware</string>
</property>
<addaction name="actionCheckFirmware"/>
<addaction name="actionUpdateFirmware"/>
</widget>
<addaction name="menuFile"/>
Expand Down Expand Up @@ -808,6 +809,7 @@
<addaction name="actionValetudoInstall"/>
<addaction name="actionValetudoUninstall"/>
<addaction name="separator"/>
<addaction name="actionCheckFirmware"/>
<addaction name="actionUpdateFirmware"/>
<addaction name="separator"/>
<addaction name="actionHelp"/>
Expand Down Expand Up @@ -1109,7 +1111,7 @@
<action name="actionUpdateFirmware">
<property name="icon">
<iconset resource="../rrcc.qrc">
<normaloff>:/png/png/parcel.png</normaloff>:/png/png/parcel.png</iconset>
<normaloff>:/png/png/fw_upd.png</normaloff>:/png/png/fw_upd.png</iconset>
</property>
<property name="text">
<string>Update</string>
Expand All @@ -1121,6 +1123,21 @@
<string>Update Firmware</string>
</property>
</action>
<action name="actionCheckFirmware">
<property name="icon">
<iconset resource="../rrcc.qrc">
<normaloff>:/png/png/fw_chk.png</normaloff>:/png/png/fw_chk.png</iconset>
</property>
<property name="text">
<string>Version</string>
</property>
<property name="toolTip">
<string>Check Firmware</string>
</property>
<property name="statusTip">
<string>Check Firmware</string>
</property>
</action>
</widget>
<resources>
<include location="../rrcc.qrc"/>
Expand Down

0 comments on commit 57235aa

Please sign in to comment.