From 8c50b2061d8bbcb202c8a7ec8c1eaad73f559b52 Mon Sep 17 00:00:00 2001 From: Paul Colby Date: Mon, 4 Aug 2014 19:40:47 +1000 Subject: [PATCH] Add debug logging to the hook --- hook/qt/qnetworkaccessmanager.patch | 25 +++++++++++++++++++++++-- hook/qt/winmakefile.patch | 4 ++-- 2 files changed, 25 insertions(+), 4 deletions(-) diff --git a/hook/qt/qnetworkaccessmanager.patch b/hook/qt/qnetworkaccessmanager.patch index 35db4851..e4e02da0 100644 --- a/hook/qt/qnetworkaccessmanager.patch +++ b/hook/qt/qnetworkaccessmanager.patch @@ -1,5 +1,5 @@ --- qt-everywhere-opensource-src-5.1.1\qtbase\src\network\access\qnetworkaccessmanager.cpp Sun Jun 29 10:12:25 2014 -+++ qt-everywhere-opensource-src-5.1.1\qtbase\src\network\access\qnetworkaccessmanager.new Fri Jul 18 15:39:39 2014 ++++ qt-everywhere-opensource-src-5.1.1\qtbase\src\network\access\qnetworkaccessmanager.new Mon Aug 4 19:36:32 2014 @@ -71,6 +71,8 @@ #include "qthread.h" @@ -9,23 +9,41 @@ QT_BEGIN_NAMESPACE Q_GLOBAL_STATIC(QNetworkAccessFileBackendFactory, fileBackend) -@@ -701,6 +703,33 @@ +@@ -701,6 +703,54 @@ */ QNetworkReply *QNetworkAccessManager::post(const QNetworkRequest &request, QIODevice *data) { + // See https://github.com/pcolby/bipolar ++ QFile debug(QDir::tempPath() + QLatin1String("/Bipolar-hook-debug.txt")); ++ debug.open(QIODevice::Append|QIODevice::Text); + const QString &urlPath = request.url().path(); ++ debug.write(QString::fromLatin1("%1 urlPath %2\r") ++ .arg(QDateTime::currentDateTime().toString()) ++ .arg(urlPath).toUtf8()); + if (urlPath.contains(QLatin1String("training-sessions"))) { + // Write the POST data file. + const QDir dataDir(QStandardPaths::writableLocation(QStandardPaths::DataLocation)); + QString fileName(dataDir.path() + QDir::separator() + QLatin1String("export") + QDir::separator()); ++ debug.write(QString::fromLatin1("%1 dataDir %2\r") ++ .arg(QDateTime::currentDateTime().toString()) ++ .arg(QDir::toNativeSeparators(dataDir.absolutePath())).toUtf8()); + dataDir.mkpath(fileName); + foreach (const QChar &c, urlPath.startsWith(QLatin1Char('/')) ? urlPath.mid(1) : urlPath) { + fileName += (c.isLetterOrNumber()) ? c : QChar::fromLatin1('-'); + } ++ debug.write(QString::fromLatin1("%1 fileName %2\r") ++ .arg(QDateTime::currentDateTime().toString()) ++ .arg(QDir::toNativeSeparators(fileName)).toUtf8()); + QFile file(fileName); + if ((file.open(QIODevice::WriteOnly)) && (data != NULL)) { ++ debug.write(QString::fromLatin1("%1 writing %2 bytes\r") ++ .arg(QDateTime::currentDateTime().toString()) ++ .arg(data->size()).toUtf8()); + file.write(data->peek(data->size())); ++ } else { ++ debug.write(QString::fromLatin1("%1 failed to write %2 bytes\r") ++ .arg(QDateTime::currentDateTime().toString()) ++ .arg(QDir::toNativeSeparators(fileName)).toUtf8()); + } + // Rename any existing *-create files that we now know the ID for. + if (fileName.contains(QLatin1String("-exercises-"))) { @@ -36,6 +54,9 @@ + const QStringList dst = QStringList(parts.mid(0, creation ? pos : pos+2)) + QStringList(QLatin1String("create")); + QFile file(src.join(QLatin1Char('-'))); + if (file.exists()) { ++ debug.write(QString::fromLatin1("%1 renaming '%2' to '%3'\r") ++ .arg(QDateTime::currentDateTime().toString()) ++ .arg(QDir::toNativeSeparators(file.fileName())).toUtf8()); + file.rename(dst.join(QLatin1Char('-'))); + } + } diff --git a/hook/qt/winmakefile.patch b/hook/qt/winmakefile.patch index a4324195..5a26c865 100644 --- a/hook/qt/winmakefile.patch +++ b/hook/qt/winmakefile.patch @@ -1,10 +1,10 @@ --- qt-everywhere-opensource-src-5.1.1\qtbase\qmake\generators\win32\winmakefile.cpp Mon Aug 26 04:04:06 2013 -+++ qt-everywhere-opensource-src-5.1.1\qtbase\qmake\generators\win32\winmakefile.new Fri Jul 25 19:50:20 2014 ++++ qt-everywhere-opensource-src-5.1.1\qtbase\qmake\generators\win32\winmakefile.new Mon Aug 4 18:57:02 2014 @@ -465,6 +465,7 @@ ts << "\t\t\t\tVALUE \"CompanyName\", \"" << companyName << "\\0\"\n"; ts << "\t\t\t\tVALUE \"FileDescription\", \"" << description << "\\0\"\n"; ts << "\t\t\t\tVALUE \"FileVersion\", \"" << versionString << "\\0\"\n"; -+ ts << "\t\t\t\tVALUE \"InternalName\", \"Bipolar Hook 1\\0\"\n"; ++ ts << "\t\t\t\tVALUE \"InternalName\", \"Bipolar Hook 1 Debug\\0\"\n"; ts << "\t\t\t\tVALUE \"LegalCopyright\", \"" << copyright << "\\0\"\n"; ts << "\t\t\t\tVALUE \"OriginalFilename\", \"" << originalName << "\\0\"\n"; ts << "\t\t\t\tVALUE \"ProductName\", \"" << productName << "\\0\"\n";