Skip to content

Commit

Permalink
Fixes #5
Browse files Browse the repository at this point in the history
  • Loading branch information
julian-poidevin committed Mar 9, 2017
1 parent c0adcc9 commit 7c26526
Show file tree
Hide file tree
Showing 3 changed files with 52 additions and 12 deletions.
1 change: 0 additions & 1 deletion main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,5 @@ int main(int argc, char *argv[])

ui.show();


return app.exec();
}
57 changes: 46 additions & 11 deletions mainwindow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,12 @@ MainWindow::~MainWindow()
delete ui;
}

void MainWindow::exit()
{
close();
qApp->quit();
}

void MainWindow::on_patchButton_clicked()
{
//Display Warning Message
Expand Down Expand Up @@ -47,24 +53,40 @@ void MainWindow::on_restoreButton_clicked()

void MainWindow::init()
{

ui->patchButton->setEnabled(false);
ui->restoreButton->setEnabled(false);

//Search for compatibility
isCompatibleVersion(getMBPModelVersion());

ui->patchButton->setEnabled(true);
ui->restoreButton->setEnabled(true);
if(isCompatibleVersion(getMBPModelVersion()))
{
ui->patchButton->setEnabled(true);
ui->restoreButton->setEnabled(true);
}
else
{
QMessageBox *QuitWindow = new QMessageBox;
QuitWindow->information(this,"Mac not compatible","Sorry, your Mac is not compatible.\nThe application will close");
// TODO: Find a way to force close the app
}
}

QString MainWindow::getMBPModelVersion()
{
/* Execute Following Command Line and return result */
//sysctl -n hw.model
//or
//ioreg -l | awk '/product-name/ { split($0, line, "\""); printf("%s\n", line[4]); }'

QString MBPModelVersion;
QProcess process;

//Execute commande line
process.start("sysctl -n hw.model");

//Wait forever until finished
process.waitForFinished(-1);

//Get command line output
MBPModelVersion = process.readAllStandardOutput();

//Remove carriage return ("\n") from string
MBPModelVersion = MBPModelVersion.simplified();

return MBPModelVersion;
}
Expand All @@ -83,15 +105,28 @@ bool MainWindow::isCompatibleVersion(QString modelVersion)
{
//Compare version with compatible versions of MBPs
bool isCompatibleVersion;
QString MBPModelVersion;

return isCompatibleVersion;
MBPModelVersion = getMBPModelVersion();

//TODO : Search in a list
if(MBPModelVersion == "MacBookPro6,2")
{
std::cout<<"Succes"<<std::endl;
isCompatibleVersion = true;
}
else
{
std::cout<<"Fail"<<std::endl;
isCompatibleVersion = false;
}

return isCompatibleVersion;
}

void MainWindow::backupKernelExtension()
{
//Save File to current location adding .bak extension

}

void MainWindow::patchKernelExtensionFile(QFile *kernelFile)
Expand Down
6 changes: 6 additions & 0 deletions mainwindow.h
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,11 @@
#include <QHBoxLayout>
#include <QFile>
#include <QTextStream>
#include <QApplication>
#include <QProcess>
#include <iostream> // Inclut la bibliothèque iostream (affichage de texte)

using namespace std; // Indique quel espace de noms on va utiliser

//GoogleC++ Style Guide : https://google.github.io/styleguide/cppguide.html

Expand All @@ -28,6 +33,7 @@ private slots:

void on_restoreButton_clicked();

void exit();
private:
Ui::MainWindow *ui;

Expand Down

0 comments on commit 7c26526

Please sign in to comment.