Skip to content

Commit

Permalink
Removed debug stuff
Browse files Browse the repository at this point in the history
  • Loading branch information
DeathByDenim committed Oct 7, 2014
1 parent 4994e88 commit b721ee7
Show file tree
Hide file tree
Showing 4 changed files with 37 additions and 84 deletions.
3 changes: 0 additions & 3 deletions PAAlternativeLauncher.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -387,9 +387,6 @@ void PAAlternativeLauncher::closeEvent(QCloseEvent* event)

void PAAlternativeLauncher::downloadPushButtonClicked(bool)
{
// m_patcher.test();
// return;

QSettings settings(QSettings::UserScope, "DeathByDenim", "PAAlternativeLauncher");
settings.setValue(m_streams_combo_box->currentText() + "/installpath", m_installPathLineEdit->text());
m_patcher.setInstallPath(m_installPathLineEdit->text());
Expand Down
66 changes: 22 additions & 44 deletions bundle.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -31,12 +31,6 @@ Bundle::Bundle(QString installpath, QVariant bundlevariant, QString downloadurl,
entry.checksum = entryvariantmap["checksum"].toString();
entry.executable = entryvariantmap.contains("executable") ? entryvariantmap["executable"].toBool() : false;
m_entries.push_back(entry);

if(entry.fullfilename[0].right(strlen("ATIIXP-MODEM.conf")) == "ATIIXP-MODEM.conf")
{
qDebug() << "Here I am";
}

}
m_size = bundle["size"].toString().toULong();
m_checksum = bundle["checksum"].toString();
Expand Down Expand Up @@ -79,15 +73,6 @@ if(entry.fullfilename[0].right(strlen("ATIIXP-MODEM.conf")) == "ATIIXP-MODEM.con
m_entries[i].next_offset = lastoffset;
lastoffset = m_entries[i].offset;
}
/*
QFile jsonfile(m_checksum + ".json");
if(jsonfile.open(QIODevice::WriteOnly))
{
QJson::Serializer serializer;
QByteArray jsondata = serializer.serialize(bundlevariant);
jsonfile.write(jsondata);
jsonfile.close();
}*/
}

Bundle::~Bundle()
Expand Down Expand Up @@ -135,10 +120,6 @@ void Bundle::verifyFinished()
{
if(!*bundle_ok)
{
/*
m_cache_file.setFileName(m_checksum + ".bundle");
m_cache_file.open(QIODevice::WriteOnly);
*/
m_verification_state = bad;
download();
emit verifyDone(m_size);
Expand Down Expand Up @@ -169,16 +150,12 @@ void Bundle::download()
QFileInfo fileinfo(m_entries[0].fullfilename[i]);
fileinfo.absoluteDir().mkpath(".");

if(m_entries[0].fullfilename[i].right(strlen("ATIIXP-MODEM.conf")) == "ATIIXP-MODEM.conf")
{
qDebug() << "Here I am!";
}

QFile *entryfile = new QFile(m_entries[0].fullfilename[i]);
m_entry_file << entryfile;
if(!m_entry_file[i]->open(QIODevice::WriteOnly))
{
qFatal("Could not open file for writing.");
info.critical(tr("I/O error"), tr("Could not open file \"%1\" for writing.").arg(m_entries[0].fullfilename[i]));
exit(1);
}

if(m_entries[0].executable)
Expand All @@ -197,10 +174,10 @@ void Bundle::download()
// 16+MAX_WBITS means read as gzip.
if(inflateInit2(&m_gzipstream, 16 + MAX_WBITS) != Z_OK)
{
qFatal("Couldn't init zlibstream.");
info.critical("ZLib", tr("Couldn't init zlibstream."));
exit(1);
}


m_alreadyread = 0;
m_alreadydownloaded = 0;
QNetworkRequest request(m_url);
Expand All @@ -227,23 +204,22 @@ void Bundle::nextFile()
}

if(m_current_entry_index >= m_entries.count())
qFatal("More files than expected!");
{
info.critical("I/O error", "More files than expected!");
exit(1);
}

for(int i = 0; i < m_entries[m_current_entry_index].fullfilename.count(); i++)
{
QFileInfo fileinfo(m_entries[m_current_entry_index].fullfilename[i]);
fileinfo.absoluteDir().mkpath(".");

if(m_entries[m_current_entry_index].fullfilename[i].right(strlen("ATIIXP-MODEM.conf")) == "ATIIXP-MODEM.conf")
{
qDebug() << "Here I am!";
}

QFile *entryfile = new QFile(m_entries[m_current_entry_index].fullfilename[i]);
m_entry_file << entryfile;
if(!m_entry_file[i]->open(QIODevice::WriteOnly))
{
qFatal("Could not open file for writing.");
info.critical(tr("I/O error"), tr("Could not open file \"%1\" for writing.").arg(m_entries[m_current_entry_index].fullfilename[i]));
exit(1);
}

if(m_entries[m_current_entry_index].executable)
Expand All @@ -261,7 +237,10 @@ void Bundle::nextFile()

// 16+MAX_WBITS means read as gzip.
if(inflateInit2(&m_gzipstream, 16 + MAX_WBITS) != Z_OK)
qFatal("Couldn't init zlibstream.");
{
info.critical("ZLib", tr("Couldn't init zlibstream."));
exit(1);
}
}


Expand All @@ -275,15 +254,17 @@ void Bundle::downloadFinished()
if(reply->error())
{
QString error = reply->errorString();
qDebug() << error;
qFatal(error.toAscii());
info.critical(tr("Download error"), error);
exit(1);
}
else
{
QByteArray streamdata = reply->readAll();
//m_cache_file.write(streamdata);
if(streamdata.count() != 0)
qFatal("Still data left!");
{
info.critical("Download error", "Still data left!");
exit(1);
}

emit done();
}
Expand All @@ -309,7 +290,6 @@ void Bundle::readyRead()
break;

QByteArray streamdata = reply->read(m_entries[m_current_entry_index].next_offset - m_alreadyread);
//m_cache_file.write(streamdata);
if(streamdata.count() == 0)
break;

Expand Down Expand Up @@ -355,10 +335,8 @@ void Bundle::readyRead()
nextFile();
else if(inflate_status < 0)
{
qDebug() << streamdata.count();
qDebug() << m_checksum;
qDebug() << m_entries.count();
qFatal("Decompress error");
info.critical(tr("I/O error"), tr("Decompress error"));
exit(1);
}
}
}
Expand Down
51 changes: 15 additions & 36 deletions patcher.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,14 @@
#include <QNetworkAccessManager>
#include <QNetworkReply>
#include <QNetworkRequest>
#include <QMessageBox>
#include <zlib.h>
#include <qjson/parser.h>
#include <QDebug>
#include <QDir>
#include <QtConcurrentMap>
#include <QFuture>
#include <QFutureWatcher>
#include "sha1.h"
#include "information.h"

Patcher::Patcher(QWidget* parent)
: m_parent(parent)
Expand All @@ -38,7 +37,7 @@ void Patcher::decodeStreamsData(QByteArray data)
QVariantList streams = parser.parse(data, &ok).toMap()["Streams"].toList();
if(!ok)
{
QMessageBox::critical(m_parent, tr("JSON error"), tr("Could not decode streams JSON. File was corrupted."));
info.critical(tr("JSON error"), tr("Could not decode streams JSON. File was corrupted."));
return;
}

Expand Down Expand Up @@ -96,7 +95,8 @@ void Patcher::downloadManifest(const Patcher::Stream &stream)
// 16+MAX_WBITS means read as gzip.
if(inflateInit2(&m_manifest_zstream, 16 + MAX_WBITS) != Z_OK)
{
qFatal("Couldn't init zlibstream.");
info.critical("ZLib", tr("Couldn't init zlibstream."));
exit(1);
}

QUrl manifesturl(stream.DownloadUrl + '/' + stream.TitleFolder + '/' + stream.ManifestName + stream.AuthSuffix);
Expand Down Expand Up @@ -132,7 +132,10 @@ void Patcher::manifestReadyRead()
while(inflate_status == Z_OK && m_manifest_zstream.avail_in > 0);

if(inflate_status < 0)
qFatal("Decompress error");
{
info.critical(tr("I/O error"), tr("Decompress error"));
exit(1);
}
}
}

Expand All @@ -144,7 +147,7 @@ void Patcher::manifestFinished()

if(reply->error() != QNetworkReply::NoError)
{
QMessageBox::critical(m_parent, QString("Communication error"), "Error while downloading manifest.\nDetails: " + reply->errorString() + ".");
info.critical(QString("Communication error"), "Error while downloading manifest.\nDetails: " + reply->errorString() + ".");
}
else
{
Expand All @@ -155,7 +158,10 @@ void Patcher::manifestFinished()
inflateEnd(&m_manifest_zstream);

if(inflate_status != Z_STREAM_END)
qFatal("Decompress error");
{
info.critical(tr("I/O error"), tr("Decompress error"));
exit(1);
}
else
verify();
}
Expand All @@ -172,15 +178,7 @@ void Patcher::verify()
bool ok;
QJson::Parser parser;
m_manifest = parser.parse(m_manifest_bytearray, &ok).toMap();
/*
// TODO: Remove me
QFile manifestfile("manifest.json");
if(manifestfile.open(QIODevice::WriteOnly))
{
manifestfile.write(m_manifest_bytearray);
manifestfile.close();
}
*/

m_manifest_bytearray.resize(0);
if(ok)
processManifest(m_manifest);
Expand Down Expand Up @@ -246,7 +244,7 @@ void Patcher::setInstallPath(QString installpath)
QDir installdir(installpath);
if(!installdir.mkpath("."))
{
QMessageBox::critical(m_parent, "Directory creation", QString("Failed to create directory at \"%1\".)").arg(installpath));
info.critical("Directory creation", QString("Failed to create directory at \"%1\".)").arg(installpath));
return;
}

Expand All @@ -267,23 +265,4 @@ void Patcher::bundleDownloadProgress(qint64 value)
}
}

void Patcher::test()
{
QFile jsonfile("701e589bf732070c256a943aa9d4e64fc5e7617c.json");
if(!jsonfile.open(QIODevice::ReadOnly))
return;

QByteArray data = jsonfile.readAll();

QJson::Parser parser;
bool ok;
QVariantMap vmap = parser.parse(data, &ok).toMap();
if(ok)
{
Bundle *bundle = new Bundle("/home/jarno/temp/PA/", vmap, "", "", "", m_access_manager, m_parent);
bundle->verifyAndMaybeDownload();
// delete bundle;
}
}

#include "patcher.moc"
1 change: 0 additions & 1 deletion patcher.h
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,6 @@ class Patcher : public QObject
QStringList streamNames();
void downloadStream(const QString streamname);
void setInstallPath(QString installpath);
void test();

private:
QWidget *m_parent;
Expand Down

0 comments on commit b721ee7

Please sign in to comment.