|
|
|
@ -2,6 +2,7 @@
|
|
|
|
|
|
|
|
|
|
#include <QDebug>
|
|
|
|
|
|
|
|
|
|
#include <QFileDialog>
|
|
|
|
|
#include <QFileInfo>
|
|
|
|
|
#include <QFileInfoListIterator>
|
|
|
|
|
#include <QMessageBox>
|
|
|
|
@ -20,6 +21,10 @@ Wizard::UnshieldWorker::UnshieldWorker(QObject *parent) :
|
|
|
|
|
{
|
|
|
|
|
unshield_set_log_level(0);
|
|
|
|
|
|
|
|
|
|
mMorrowindPath = QString();
|
|
|
|
|
mTribunalPath = QString();
|
|
|
|
|
mBloodmoonPath = QString();
|
|
|
|
|
|
|
|
|
|
mPath = QString();
|
|
|
|
|
mIniPath = QString();
|
|
|
|
|
|
|
|
|
@ -42,19 +47,101 @@ Wizard::UnshieldWorker::~UnshieldWorker()
|
|
|
|
|
|
|
|
|
|
void Wizard::UnshieldWorker::setInstallMorrowind(bool install)
|
|
|
|
|
{
|
|
|
|
|
// QMutexLocker locker(&mMutex);
|
|
|
|
|
mInstallMorrowind = install;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void Wizard::UnshieldWorker::setInstallTribunal(bool install)
|
|
|
|
|
{
|
|
|
|
|
// QMutexLocker locker(&mMutex);
|
|
|
|
|
mInstallTribunal = install;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void Wizard::UnshieldWorker::setInstallBloodmoon(bool install)
|
|
|
|
|
{
|
|
|
|
|
// QMutexLocker locker(&mMutex);
|
|
|
|
|
mInstallBloodmoon = install;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
bool Wizard::UnshieldWorker::getInstallMorrowind()
|
|
|
|
|
{
|
|
|
|
|
// QMutexLocker locker(&mMutex);
|
|
|
|
|
return mInstallMorrowind;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
bool Wizard::UnshieldWorker::getInstallTribunal()
|
|
|
|
|
{
|
|
|
|
|
// QMutexLocker locker(&mMutex);
|
|
|
|
|
return mInstallTribunal;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
bool Wizard::UnshieldWorker::getInstallBloodmoon()
|
|
|
|
|
{
|
|
|
|
|
// QMutexLocker locker(&mMutex);
|
|
|
|
|
return mInstallBloodmoon;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//bool Wizard::UnshieldWorker::getMorrowindDone()
|
|
|
|
|
//{
|
|
|
|
|
// QMutexLocker locker(&mMutex);
|
|
|
|
|
// return mMorrowindDone;
|
|
|
|
|
//}
|
|
|
|
|
|
|
|
|
|
//bool Wizard::UnshieldWorker::tribunalDone()
|
|
|
|
|
//{
|
|
|
|
|
// QMutexLocker locker(&mMutex);
|
|
|
|
|
// return mTribunalDone;
|
|
|
|
|
//}
|
|
|
|
|
|
|
|
|
|
//bool Wizard::UnshieldWorker::bloodmoonDone()
|
|
|
|
|
//{
|
|
|
|
|
// return mBloodmoonDone;
|
|
|
|
|
//}
|
|
|
|
|
|
|
|
|
|
void Wizard::UnshieldWorker::setMorrowindPath(const QString &path)
|
|
|
|
|
{
|
|
|
|
|
qDebug() << "setmorrowindpath!";
|
|
|
|
|
QMutexLocker locker(&mMutex);
|
|
|
|
|
mMorrowindPath = path;
|
|
|
|
|
mWait.wakeAll();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void Wizard::UnshieldWorker::setTribunalPath(const QString &path)
|
|
|
|
|
{
|
|
|
|
|
//QMutexLocker locker(&mMutex);
|
|
|
|
|
mTribunalPath = path;
|
|
|
|
|
mWait.wakeAll();
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void Wizard::UnshieldWorker::setBloodmoonPath(const QString &path)
|
|
|
|
|
{
|
|
|
|
|
//QMutexLocker locker(&mMutex);
|
|
|
|
|
mBloodmoonPath = path;
|
|
|
|
|
mWait.wakeAll();
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
QString Wizard::UnshieldWorker::getMorrowindPath()
|
|
|
|
|
{
|
|
|
|
|
qDebug() << "getmorrowindpath!";
|
|
|
|
|
//QMutexLocker locker(&mMutex);
|
|
|
|
|
//mWait.wakeAll();
|
|
|
|
|
return mMorrowindPath;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
QString Wizard::UnshieldWorker::getTribunalPath()
|
|
|
|
|
{
|
|
|
|
|
//QMutexLocker locker(&mMutex);
|
|
|
|
|
return mTribunalPath;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
QString Wizard::UnshieldWorker::getBloodmoonPath()
|
|
|
|
|
{
|
|
|
|
|
//QMutexLocker locker(&mMutex);
|
|
|
|
|
return mBloodmoonPath;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void Wizard::UnshieldWorker::setPath(const QString &path)
|
|
|
|
|
{
|
|
|
|
|
mPath = path;
|
|
|
|
@ -224,15 +311,173 @@ void Wizard::UnshieldWorker::installDirectories(const QString &source)
|
|
|
|
|
copyDirectory(info.absoluteFilePath(), mPath + QDir::separator() + info.fileName());
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Copy the Data Files dir too, but only the subdirectories
|
|
|
|
|
QFileInfo info(dir.absoluteFilePath("Data Files"));
|
|
|
|
|
if (info.exists()) {
|
|
|
|
|
emit textChanged(tr("Extracting: Data Files directory"));
|
|
|
|
|
copyDirectory(info.absoluteFilePath(), mPath);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void Wizard::UnshieldWorker::extract()
|
|
|
|
|
{
|
|
|
|
|
emit textChanged(QLatin1String("Starting installation"));
|
|
|
|
|
emit textChanged(QLatin1String("Installation target: ") + mPath);
|
|
|
|
|
qDebug() << "extract!";
|
|
|
|
|
|
|
|
|
|
QMutexLocker locker(&mMutex);
|
|
|
|
|
|
|
|
|
|
QDir disk;
|
|
|
|
|
|
|
|
|
|
qDebug() << "hi!";
|
|
|
|
|
|
|
|
|
|
if (getInstallMorrowind())
|
|
|
|
|
{
|
|
|
|
|
while (!mMorrowindDone)
|
|
|
|
|
{
|
|
|
|
|
if (getMorrowindPath().isEmpty()) {
|
|
|
|
|
qDebug() << "request file dialog";
|
|
|
|
|
emit requestFileDialog(QLatin1String("Morrowind"));
|
|
|
|
|
mWait.wait(&mMutex);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (!mMorrowindDone && !getMorrowindPath().isEmpty()) {
|
|
|
|
|
disk.setPath(getMorrowindPath());
|
|
|
|
|
|
|
|
|
|
if (!findFile(disk.absoluteFilePath(QLatin1String("data1.hdr")), QLatin1String("Morrowind.bsa"))) {
|
|
|
|
|
qDebug() << "found";
|
|
|
|
|
emit requestFileDialog(QLatin1String("Morrowind"));
|
|
|
|
|
mWait.wait(&mMutex);
|
|
|
|
|
|
|
|
|
|
} else {
|
|
|
|
|
qDebug() << "install morrowind!";
|
|
|
|
|
|
|
|
|
|
if (installMorrowind()) {
|
|
|
|
|
mMorrowindDone = true;
|
|
|
|
|
} else {
|
|
|
|
|
qDebug() << "Erorr installing Morrowind";
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (getInstallTribunal())
|
|
|
|
|
{
|
|
|
|
|
while (!mTribunalDone)
|
|
|
|
|
{
|
|
|
|
|
QDir tribunal(disk);
|
|
|
|
|
|
|
|
|
|
if (!tribunal.cd(QLatin1String("Tribunal"))) {
|
|
|
|
|
qDebug() << "not found on cd!";
|
|
|
|
|
emit requestFileDialog(QLatin1String("Tribunal"));
|
|
|
|
|
mWait.wait(&mMutex);
|
|
|
|
|
|
|
|
|
|
} else if (tribunal.exists(QLatin1String("data1.hdr"))) {
|
|
|
|
|
qDebug() << "Exists! " << tribunal.absolutePath();
|
|
|
|
|
mTribunalPath = tribunal.absolutePath();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (getTribunalPath().isEmpty()) {
|
|
|
|
|
qDebug() << "request file dialog";
|
|
|
|
|
emit requestFileDialog(QLatin1String("Tribunal"));
|
|
|
|
|
mWait.wait(&mMutex);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Make sure the dir is up-to-date
|
|
|
|
|
tribunal.setPath(getTribunalPath());
|
|
|
|
|
|
|
|
|
|
if (!findFile(tribunal.absoluteFilePath(QLatin1String("data1.hdr")), QLatin1String("Tribunal.bsa"))) {
|
|
|
|
|
qDebug() << "file not found!";
|
|
|
|
|
emit requestFileDialog(QLatin1String("Tribunal"));
|
|
|
|
|
mWait.wait(&mMutex);
|
|
|
|
|
|
|
|
|
|
} else {
|
|
|
|
|
qDebug() << "install tribunal!";
|
|
|
|
|
if (installTribunal()) {
|
|
|
|
|
mTribunalDone = true;
|
|
|
|
|
} else {
|
|
|
|
|
qDebug() << "Erorr installing Tribunal";
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (getInstallBloodmoon())
|
|
|
|
|
{
|
|
|
|
|
while (!mBloodmoonDone)
|
|
|
|
|
{
|
|
|
|
|
QDir bloodmoon(disk);
|
|
|
|
|
|
|
|
|
|
qDebug() << "bloodmoon!: " << bloodmoon.absolutePath();
|
|
|
|
|
|
|
|
|
|
if (!bloodmoon.cd(QLatin1String("Bloodmoon"))) {
|
|
|
|
|
emit requestFileDialog(QLatin1String("Bloodmoon"));
|
|
|
|
|
mWait.wait(&mMutex);
|
|
|
|
|
|
|
|
|
|
} else if (bloodmoon.exists(QLatin1String("data1.hdr"))) {
|
|
|
|
|
mBloodmoonPath = bloodmoon.absolutePath();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (getBloodmoonPath().isEmpty()) {
|
|
|
|
|
qDebug() << "request file dialog";
|
|
|
|
|
emit requestFileDialog(QLatin1String("Bloodmoon"));
|
|
|
|
|
mWait.wait(&mMutex);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Make sure the dir is up-to-date
|
|
|
|
|
bloodmoon.setPath(getBloodmoonPath());
|
|
|
|
|
|
|
|
|
|
if (!findFile(bloodmoon.absoluteFilePath(QLatin1String("data1.hdr")), QLatin1String("Bloodmoon.bsa"))) {
|
|
|
|
|
emit requestFileDialog(QLatin1String("Bloodmoon"));
|
|
|
|
|
mWait.wait(&mMutex);
|
|
|
|
|
|
|
|
|
|
} else {
|
|
|
|
|
qDebug() << "install bloodmoon!";
|
|
|
|
|
if (installBloodmoon()) {
|
|
|
|
|
mBloodmoonDone = true;
|
|
|
|
|
} else {
|
|
|
|
|
qDebug() << "Erorr installing Bloodmoon";
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Remove the temporary directory
|
|
|
|
|
removeDirectory(mPath + QDir::separator() + QLatin1String("extract-temp"));
|
|
|
|
|
|
|
|
|
|
locker.unlock();
|
|
|
|
|
|
|
|
|
|
int total = 0;
|
|
|
|
|
|
|
|
|
|
if (mInstallMorrowind)
|
|
|
|
|
total = 100;
|
|
|
|
|
|
|
|
|
|
if (mInstallTribunal)
|
|
|
|
|
total = total + 100;
|
|
|
|
|
|
|
|
|
|
if (mInstallBloodmoon)
|
|
|
|
|
total = total + 100;
|
|
|
|
|
|
|
|
|
|
emit textChanged(tr("Installation finished!"));
|
|
|
|
|
emit progressChanged(total);
|
|
|
|
|
emit finished();
|
|
|
|
|
|
|
|
|
|
qDebug() << "installation finished!";
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
bool Wizard::UnshieldWorker::installMorrowind()
|
|
|
|
|
{
|
|
|
|
|
emit textChanged(QLatin1String("Installing Morrowind\n"));
|
|
|
|
|
|
|
|
|
|
QString diskPath("/mnt/cdrom/");
|
|
|
|
|
QDir disk(diskPath);
|
|
|
|
|
QDir disk(getMorrowindPath());
|
|
|
|
|
|
|
|
|
|
if (!disk.exists())
|
|
|
|
|
return false;
|
|
|
|
|
|
|
|
|
|
// Create temporary extract directory
|
|
|
|
|
// TODO: Use QTemporaryDir in Qt 5.0
|
|
|
|
@ -244,156 +489,168 @@ void Wizard::UnshieldWorker::extract()
|
|
|
|
|
|
|
|
|
|
if (!temp.mkpath(tempPath)) {
|
|
|
|
|
qDebug() << "Can't make path";
|
|
|
|
|
return;
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
temp.setPath(tempPath);
|
|
|
|
|
disk.setPath(diskPath);
|
|
|
|
|
|
|
|
|
|
if (mInstallMorrowind)
|
|
|
|
|
{
|
|
|
|
|
emit textChanged(QLatin1String("Installing Morrowind\n"));
|
|
|
|
|
QString cabFile(disk.absoluteFilePath(QLatin1String("data1.hdr")));
|
|
|
|
|
|
|
|
|
|
if (!temp.mkdir(QLatin1String("morrowind"))) {
|
|
|
|
|
qDebug() << "Can't make dir";
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
if (!temp.mkdir(QLatin1String("morrowind"))) {
|
|
|
|
|
qDebug() << "Can't make dir";
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (!temp.cd(QLatin1String("morrowind"))) {
|
|
|
|
|
qDebug() << "Can't cd to dir";
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
if (!temp.cd(QLatin1String("morrowind"))) {
|
|
|
|
|
qDebug() << "Can't cd to dir";
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (!disk.exists(QLatin1String("data1.hdr"))) {
|
|
|
|
|
qDebug() << "No data found!";
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
// Extract the installation files
|
|
|
|
|
extractCab(disk.absoluteFilePath(QLatin1String("data1.hdr")), temp.absolutePath());
|
|
|
|
|
|
|
|
|
|
// Extract the installation files
|
|
|
|
|
extractCab(disk.absoluteFilePath(QLatin1String("data1.hdr")), temp.absolutePath());
|
|
|
|
|
// TODO: Throw error;
|
|
|
|
|
// Move the files from the temporary path to the destination folder
|
|
|
|
|
if (!moveDirectory(temp.absoluteFilePath(QLatin1String("Data Files")), mPath)) {
|
|
|
|
|
qDebug() << "failed to move files!";
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// TODO: Throw error;
|
|
|
|
|
// Move the files from the temporary path to the destination folder
|
|
|
|
|
// Install files outside of cab archives
|
|
|
|
|
installDirectories(disk.absolutePath());
|
|
|
|
|
|
|
|
|
|
//qDebug() << "rename: " << morrowindTempPath << " to: " << mPath;
|
|
|
|
|
if (!moveDirectory(temp.absoluteFilePath(QLatin1String("Data Files")), mPath))
|
|
|
|
|
qDebug() << "failed!";
|
|
|
|
|
// Copy Morrowind configuration file
|
|
|
|
|
QString iniPath(temp.absoluteFilePath(QLatin1String("App Executables")));
|
|
|
|
|
iniPath.append(QDir::separator() + QLatin1String("Morrowind.ini"));
|
|
|
|
|
|
|
|
|
|
// Install files outside of cab archives
|
|
|
|
|
qDebug() << temp.absolutePath() << disk.absolutePath();
|
|
|
|
|
installDirectories(disk.absolutePath());
|
|
|
|
|
QFileInfo info(iniPath);
|
|
|
|
|
|
|
|
|
|
// Copy Morrowind configuration file
|
|
|
|
|
QString iniPath(temp.absoluteFilePath(QLatin1String("App Executables")));
|
|
|
|
|
iniPath.append(QDir::separator() + QLatin1String("Morrowind.ini"));
|
|
|
|
|
qDebug() << info.absoluteFilePath() << mPath;
|
|
|
|
|
|
|
|
|
|
QFileInfo info(iniPath);
|
|
|
|
|
if (info.exists()) {
|
|
|
|
|
emit textChanged(tr("Extracting: Morrowind.ini"));
|
|
|
|
|
moveFile(info.absoluteFilePath(), mPath + QDir::separator() + QLatin1String("Morrowind.ini"));
|
|
|
|
|
} else {
|
|
|
|
|
qDebug() << "Could not find ini file!";
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
qDebug() << info.absoluteFilePath() << mPath;
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (info.exists()) {
|
|
|
|
|
emit textChanged(tr("Extracting: Morrowind.ini"));
|
|
|
|
|
moveFile(info.absoluteFilePath(), mPath + QDir::separator() + QLatin1String("Morrowind.ini"));
|
|
|
|
|
} else {
|
|
|
|
|
qDebug() << "Could not find ini file!";
|
|
|
|
|
}
|
|
|
|
|
bool Wizard::UnshieldWorker::installTribunal()
|
|
|
|
|
{
|
|
|
|
|
emit textChanged(QLatin1String("Installing Tribunal"));
|
|
|
|
|
|
|
|
|
|
mMorrowindDone = true;
|
|
|
|
|
QDir disk(getTribunalPath());
|
|
|
|
|
|
|
|
|
|
if (!disk.exists()) {
|
|
|
|
|
qDebug() << "disk does not exist! " << disk.absolutePath() << getTribunalPath();
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
temp.setPath(tempPath);
|
|
|
|
|
disk.setPath(diskPath);
|
|
|
|
|
|
|
|
|
|
if (mInstallTribunal)
|
|
|
|
|
{
|
|
|
|
|
emit textChanged(QLatin1String("Installing Tribunal\n"));
|
|
|
|
|
|
|
|
|
|
if (!temp.mkdir(QLatin1String("tribunal"))) {
|
|
|
|
|
qDebug() << "Can't make dir";
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
// Create temporary extract directory
|
|
|
|
|
// TODO: Use QTemporaryDir in Qt 5.0
|
|
|
|
|
QString tempPath(mPath + QDir::separator() + QLatin1String("extract-temp"));
|
|
|
|
|
QDir temp;
|
|
|
|
|
|
|
|
|
|
if (!temp.cd(QLatin1String("tribunal"))) {
|
|
|
|
|
qDebug() << "Can't cd to dir";
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
// Make sure the temporary folder is empty
|
|
|
|
|
removeDirectory(tempPath);
|
|
|
|
|
|
|
|
|
|
if (!disk.cd(QLatin1String("Tribunal")))
|
|
|
|
|
qDebug() << "Show file selector";
|
|
|
|
|
if (!temp.mkpath(tempPath)) {
|
|
|
|
|
qDebug() << "Can't make path";
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (!disk.exists(QLatin1String("data1.hdr"))) {
|
|
|
|
|
qDebug() << "No data found!";
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
temp.setPath(tempPath);
|
|
|
|
|
|
|
|
|
|
// Extract the installation files
|
|
|
|
|
extractCab(disk.absoluteFilePath(QLatin1String("data1.hdr")), temp.absolutePath());
|
|
|
|
|
if (!temp.mkdir(QLatin1String("tribunal"))) {
|
|
|
|
|
qDebug() << "Can't make dir";
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (!moveDirectory(temp.absoluteFilePath(QLatin1String("Data Files")), mPath))
|
|
|
|
|
qDebug() << "failed!";
|
|
|
|
|
if (!temp.cd(QLatin1String("tribunal"))) {
|
|
|
|
|
qDebug() << "Can't cd to dir";
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Install files outside of cab archives
|
|
|
|
|
installDirectories(disk.absolutePath());
|
|
|
|
|
// Extract the installation files
|
|
|
|
|
extractCab(disk.absoluteFilePath(QLatin1String("data1.hdr")), temp.absolutePath());
|
|
|
|
|
|
|
|
|
|
mTribunalDone = true;
|
|
|
|
|
// TODO: Throw error;
|
|
|
|
|
// Move the files from the temporary path to the destination folder
|
|
|
|
|
if (!moveDirectory(temp.absoluteFilePath(QLatin1String("Data Files")), mPath)) {
|
|
|
|
|
qDebug() << "failed to move files!";
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
temp.setPath(tempPath);
|
|
|
|
|
disk.setPath(diskPath);
|
|
|
|
|
// Install files outside of cab archives
|
|
|
|
|
installDirectories(disk.absolutePath());
|
|
|
|
|
|
|
|
|
|
if (mInstallBloodmoon)
|
|
|
|
|
{
|
|
|
|
|
emit textChanged(QLatin1String("Installing Bloodmoon\n"));
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (!temp.mkdir(QLatin1String("bloodmoon"))) {
|
|
|
|
|
qDebug() << "Can't make dir";
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
bool Wizard::UnshieldWorker::installBloodmoon()
|
|
|
|
|
{
|
|
|
|
|
emit textChanged(QLatin1String("Installing Bloodmoon"));
|
|
|
|
|
|
|
|
|
|
if (!temp.cd(QLatin1String("bloodmoon"))) {
|
|
|
|
|
qDebug() << "Can't cd to dir";
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
QDir disk(getBloodmoonPath());
|
|
|
|
|
|
|
|
|
|
if (!disk.cd(QLatin1String("Bloodmoon")))
|
|
|
|
|
qDebug() << "Show file selector";
|
|
|
|
|
if (!disk.exists()) {
|
|
|
|
|
qDebug() << "disk does not exist! " << disk.absolutePath() << getTribunalPath();
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (!disk.exists(QLatin1String("data1.hdr"))) {
|
|
|
|
|
qDebug() << "No data found!";
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
// Create temporary extract directory
|
|
|
|
|
// TODO: Use QTemporaryDir in Qt 5.0
|
|
|
|
|
QString tempPath(mPath + QDir::separator() + QLatin1String("extract-temp"));
|
|
|
|
|
QDir temp;
|
|
|
|
|
|
|
|
|
|
// Extract the installation files
|
|
|
|
|
extractCab(disk.absoluteFilePath(QLatin1String("data1.hdr")), temp.absolutePath());
|
|
|
|
|
// Make sure the temporary folder is empty
|
|
|
|
|
removeDirectory(tempPath);
|
|
|
|
|
|
|
|
|
|
if (!moveDirectory(temp.absoluteFilePath(QLatin1String("Data Files")), mPath))
|
|
|
|
|
qDebug() << "failed!";
|
|
|
|
|
if (!temp.mkpath(tempPath)) {
|
|
|
|
|
qDebug() << "Can't make path";
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Install files outside of cab archives
|
|
|
|
|
installDirectories(disk.absolutePath());
|
|
|
|
|
temp.setPath(tempPath);
|
|
|
|
|
|
|
|
|
|
mBloodmoonDone = true;
|
|
|
|
|
if (!temp.mkdir(QLatin1String("bloodmoon"))) {
|
|
|
|
|
qDebug() << "Can't make dir";
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (!temp.cd(QLatin1String("bloodmoon"))) {
|
|
|
|
|
qDebug() << "Can't cd to dir";
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
int total = 0;
|
|
|
|
|
// Extract the installation files
|
|
|
|
|
extractCab(disk.absoluteFilePath(QLatin1String("data1.hdr")), temp.absolutePath());
|
|
|
|
|
|
|
|
|
|
if (mInstallMorrowind)
|
|
|
|
|
total = 100;
|
|
|
|
|
// TODO: Throw error;
|
|
|
|
|
// Move the files from the temporary path to the destination folder
|
|
|
|
|
if (!moveDirectory(temp.absoluteFilePath(QLatin1String("Data Files")), mPath)) {
|
|
|
|
|
qDebug() << "failed to move files!";
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (mInstallTribunal)
|
|
|
|
|
total = total + 100;
|
|
|
|
|
// Install files outside of cab archives
|
|
|
|
|
installDirectories(disk.absolutePath());
|
|
|
|
|
|
|
|
|
|
if (mInstallBloodmoon)
|
|
|
|
|
total = total + 100;
|
|
|
|
|
QFileInfo patch(temp.absoluteFilePath(QLatin1String("Tribunal Patch") + QDir::separator() + QLatin1String("Tribunal.esm")));
|
|
|
|
|
QFileInfo original(mPath + QDir::separator() + QLatin1String("Tribunal.esm"));
|
|
|
|
|
|
|
|
|
|
emit textChanged(tr("Installation finished!"));
|
|
|
|
|
emit progressChanged(total);
|
|
|
|
|
emit finished();
|
|
|
|
|
if (original.exists() && patch.exists()) {
|
|
|
|
|
emit textChanged(tr("Extracting: Tribunal patch"));
|
|
|
|
|
copyFile(patch.absoluteFilePath(), original.absoluteFilePath());
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
bool Wizard::UnshieldWorker::extractFile(Unshield *unshield, const QString &outputDir, const QString &prefix, int index, int counter)
|
|
|
|
|
{
|
|
|
|
|
bool success;
|
|
|
|
@ -444,11 +701,46 @@ bool Wizard::UnshieldWorker::extractFile(Unshield *unshield, const QString &outp
|
|
|
|
|
return success;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
bool Wizard::UnshieldWorker::findFile(const QString &cabFile, const QString &fileName)
|
|
|
|
|
{
|
|
|
|
|
Unshield *unshield;
|
|
|
|
|
unshield = unshield_open(cabFile.toLatin1().constData());
|
|
|
|
|
|
|
|
|
|
// TODO: Proper error
|
|
|
|
|
if (!unshield) {
|
|
|
|
|
emit error(tr("Failed to open %1").arg(cabFile));
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
for (int i=0; i<unshield_file_group_count(unshield); ++i)
|
|
|
|
|
{
|
|
|
|
|
UnshieldFileGroup *group = unshield_file_group_get(unshield, i);
|
|
|
|
|
|
|
|
|
|
for (size_t j=group->first_file; j<=group->last_file; ++j)
|
|
|
|
|
{
|
|
|
|
|
QString current(QString::fromLatin1(unshield_file_name(unshield, j)));
|
|
|
|
|
|
|
|
|
|
qDebug() << "File is: " << unshield_file_name(unshield, j);
|
|
|
|
|
if (current == fileName)
|
|
|
|
|
return true; // File is found!
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
unshield_close(unshield);
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void Wizard::UnshieldWorker::extractCab(const QString &cabFile, const QString &outputDir)
|
|
|
|
|
{
|
|
|
|
|
Unshield *unshield;
|
|
|
|
|
unshield = unshield_open(cabFile.toLatin1().constData());
|
|
|
|
|
|
|
|
|
|
// TODO: Proper error
|
|
|
|
|
if (!unshield) {
|
|
|
|
|
emit error(tr("Failed to open %1").arg(cabFile));
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
int counter = 0;
|
|
|
|
|
|
|
|
|
|
for (int i=0; i<unshield_file_group_count(unshield); ++i)
|
|
|
|
|