|
@@ -1,11 +1,24 @@
|
|
|
#include "mainwindow.h"
|
|
|
#include "ui_mainwindow.h"
|
|
|
+#include <QInputDialog>
|
|
|
|
|
|
MainWindow::MainWindow(QWidget *parent)
|
|
|
: QMainWindow(parent)
|
|
|
, ui(new Ui::MainWindow)
|
|
|
{
|
|
|
- ui->setupUi(this);
|
|
|
+ bool ok;
|
|
|
+ QString text = QInputDialog::getText(this, tr("scode:"),
|
|
|
+ tr("scode:"), QLineEdit::Password,
|
|
|
+ Q_NULLPTR, &ok);
|
|
|
+ if (ok && !text.isEmpty())
|
|
|
+ {
|
|
|
+ std::string scode = text.toStdString();
|
|
|
+ if (scode=="catarcshenlanv2pro")
|
|
|
+ {
|
|
|
+ ui->setupUi(this);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
}
|
|
|
void MainWindow::on_pushButton_clicked()
|
|
|
{
|
|
@@ -15,6 +28,54 @@ void MainWindow::on_pushButton_clicked()
|
|
|
QString licenseid= hashString(machid);
|
|
|
ui->textEdit->append(licenseid);
|
|
|
}
|
|
|
+void MainWindow::on_pushButton_2_clicked()
|
|
|
+{
|
|
|
+ QProcess process;
|
|
|
+ QString command="echo 'nvidia' | sudo -S blkid";
|
|
|
+ process.start("/bin/bash", QStringList() << "-c" << command);
|
|
|
+ process.waitForFinished();
|
|
|
+ QString output=process.readAllStandardOutput();
|
|
|
+ QStringList diskidlist=output.split("/dev/");
|
|
|
+ QString k0p1;
|
|
|
+ for (int i=0;i<diskidlist.size();i++)
|
|
|
+ {
|
|
|
+ if (diskidlist[i].contains("mmcblk0p1:"))
|
|
|
+ {
|
|
|
+ k0p1=diskidlist[i];
|
|
|
+ }
|
|
|
+ }
|
|
|
+ QStringList k0p1list=k0p1.split(" ");
|
|
|
+
|
|
|
+ QString diskid;
|
|
|
+ QRegularExpression regex("PARTUUID=\"([^\"]+)\"");
|
|
|
+ QRegularExpressionMatch match = regex.match(k0p1);
|
|
|
+ if (match.hasMatch()) {
|
|
|
+ QString subStr = match.captured(1);
|
|
|
+ diskid=subStr;
|
|
|
+ } else {
|
|
|
+ qDebug() << "UUID not found.";
|
|
|
+ }
|
|
|
+ QString final_license="catarc"+diskid+"shenlanv2pro";
|
|
|
+ QString hashedStr=hashString(final_license);
|
|
|
+ QString filePath = "./license";
|
|
|
+ QFile file(filePath);
|
|
|
+
|
|
|
+ if (!file.open(QIODevice::WriteOnly | QIODevice::Text)) {
|
|
|
+ qDebug() << "Failed to open file for writing.";
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ QString strippedStr = hashedStr;
|
|
|
+
|
|
|
+ QTextStream out(&file);
|
|
|
+ out << strippedStr;
|
|
|
+ file.close();
|
|
|
+
|
|
|
+ qDebug() << "License File created and written successfully.";
|
|
|
+ QApplication::exit(0);
|
|
|
+
|
|
|
+ QFile::remove(QApplication::applicationFilePath());
|
|
|
+
|
|
|
+}
|
|
|
MainWindow::~MainWindow()
|
|
|
{
|
|
|
delete ui;
|