Skip to content

Commit

Permalink
Merge branch 'hook-debug'
Browse files Browse the repository at this point in the history
  • Loading branch information
pcolby committed Oct 8, 2014
2 parents c314b2a + 8c50b20 commit d5e970f
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 4 deletions.
25 changes: 23 additions & 2 deletions hook/qt/qnetworkaccessmanager.patch
Original file line number Diff line number Diff line change
@@ -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"
Expand All @@ -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-"))) {
Expand All @@ -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('-')));
+ }
+ }
Expand Down
4 changes: 2 additions & 2 deletions hook/qt/winmakefile.patch
Original file line number Diff line number Diff line change
@@ -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";

0 comments on commit d5e970f

Please sign in to comment.