diff --git a/AppEnv.cpp b/AppEnv.cpp index 52ba5fd..8e27021 100755 --- a/AppEnv.cpp +++ b/AppEnv.cpp @@ -121,9 +121,14 @@ QByteArray AppEnv::getUserAgent() return QString("Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101 Firefox/45.0 %1/%2").arg(GTA5SYNC_APPSTR, GTA5SYNC_APPVER).toUtf8(); } +// QUrl AppEnv::getCrewFetchingUrl(QString crewID) +// { +// return QUrl(QString("https://socialclub.rockstargames.com/reference/crewfeed/%1").arg(crewID)); +// } + QUrl AppEnv::getCrewFetchingUrl(QString crewID) { - return QUrl(QString("https://socialclub.rockstargames.com/reference/crewfeed/%1").arg(crewID)); + return QUrl(QString("https://socialclub.rockstargames.com/crew/%1/%1").arg(crewID)); } QUrl AppEnv::getPlayerFetchingUrl(QString crewID, QString pageNumber) diff --git a/DatabaseThread.cpp b/DatabaseThread.cpp index 6889912..0b090d0 100755 --- a/DatabaseThread.cpp +++ b/DatabaseThread.cpp @@ -82,6 +82,80 @@ void DatabaseThread::run() } } +// void DatabaseThread::scanCrewReference(QStringList crewList, int requestDelay) +// { +// foreach (const QString &crewID, crewList) +// { +// if (threadRunning && crewID != "0") +// { +// QNetworkAccessManager *netManager = new QNetworkAccessManager(); + +// QNetworkRequest netRequest(AppEnv::getCrewFetchingUrl(crewID)); +// netRequest.setRawHeader("User-Agent", AppEnv::getUserAgent()); +// netRequest.setRawHeader("Accept", "text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8"); +// netRequest.setRawHeader("Accept-Language", "en-US;q=0.5,en;q=0.3"); +// netRequest.setRawHeader("Connection", "keep-alive"); + +// QNetworkReply *netReply = netManager->get(netRequest); + +// QEventLoop *downloadLoop = new QEventLoop(); +// QObject::connect(netReply, SIGNAL(finished()), downloadLoop, SLOT(quit())); +// QObject::connect(this, SIGNAL(threadEndCommited()), downloadLoop, SLOT(quit())); +// QTimer::singleShot(30000, downloadLoop, SLOT(quit())); +// downloadLoop->exec(); +// delete downloadLoop; + +// if (netReply->isFinished()) +// { +// QByteArray crewJson = netReply->readAll(); +// QJsonDocument crewDocument = QJsonDocument::fromJson(crewJson); +// QJsonObject crewObject = crewDocument.object(); +// QVariantMap crewMap = crewObject.toVariantMap(); +// QString crewName; +// bool isFound = false; + +// if (crewMap.contains("activities")) +// { +// QList activitiesList = crewMap["activities"].toList(); +// foreach (const QVariant &activitiesVariant, activitiesList) +// { +// QMap activityRootMap = activitiesVariant.toMap(); +// foreach(const QVariant &activityRootVariant, activityRootMap) +// { +// QMap activityMap = activityRootVariant.toMap(); +// foreach(const QVariant &activityVariant, activityMap) +// { +// QMap activityFinalMap = activityVariant.toMap(); +// if (activityFinalMap.contains("id") && activityFinalMap["id"] == crewID) +// { +// if (activityFinalMap.contains("name") && isFound == false) +// { +// isFound = true; +// crewName = activityFinalMap["name"].toString(); +// } +// } +// } +// } +// } +// } +// if (!crewName.isNull()) +// { +// crewDB->setCrewName(crewID.toInt(), crewName); +// } +// } + +// QEventLoop *waitingLoop = new QEventLoop(); +// QTimer::singleShot(requestDelay, waitingLoop, SLOT(quit())); +// QObject::connect(this, SIGNAL(threadEndCommited()), waitingLoop, SLOT(quit())); +// waitingLoop->exec(); +// delete waitingLoop; + +// delete netReply; +// delete netManager; +// } +// } +// } + void DatabaseThread::scanCrewReference(QStringList crewList, int requestDelay) { foreach (const QString &crewID, crewList) @@ -91,6 +165,9 @@ void DatabaseThread::scanCrewReference(QStringList crewList, int requestDelay) QNetworkAccessManager *netManager = new QNetworkAccessManager(); QNetworkRequest netRequest(AppEnv::getCrewFetchingUrl(crewID)); +#if QT_VERSION >= 0x050600 + netRequest.setAttribute(QNetworkRequest::FollowRedirectsAttribute, true); +#endif netRequest.setRawHeader("User-Agent", AppEnv::getUserAgent()); netRequest.setRawHeader("Accept", "text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8"); netRequest.setRawHeader("Accept-Language", "en-US;q=0.5,en;q=0.3"); @@ -107,38 +184,18 @@ void DatabaseThread::scanCrewReference(QStringList crewList, int requestDelay) if (netReply->isFinished()) { - QByteArray crewJson = netReply->readAll(); - QJsonDocument crewDocument = QJsonDocument::fromJson(crewJson); - QJsonObject crewObject = crewDocument.object(); - QVariantMap crewMap = crewObject.toVariantMap(); QString crewName; - bool isFound = false; - - if (crewMap.contains("activities")) + QByteArray crewHtml = netReply->readAll(); + QStringList crewHtmlSplit1 = QString::fromUtf8(crewHtml).split("Rockstar Games Social Club - Crew : "); + if (crewHtmlSplit1.length() >= 2) { - QList<QVariant> activitiesList = crewMap["activities"].toList(); - foreach (const QVariant &activitiesVariant, activitiesList) + QStringList crewHtmlSplit2 = QString(crewHtmlSplit1.at(1)).split(""); + if (crewHtmlSplit2.length() >= 1) { - QMap activityRootMap = activitiesVariant.toMap(); - foreach(const QVariant &activityRootVariant, activityRootMap) - { - QMap activityMap = activityRootVariant.toMap(); - foreach(const QVariant &activityVariant, activityMap) - { - QMap activityFinalMap = activityVariant.toMap(); - if (activityFinalMap.contains("id") && activityFinalMap["id"] == crewID) - { - if (activityFinalMap.contains("name") && isFound == false) - { - isFound = true; - crewName = activityFinalMap["name"].toString(); - } - } - } - } + crewName = crewHtmlSplit2.at(0); } } - if (!crewName.isNull()) + if (!crewName.isEmpty()) { crewDB->setCrewName(crewID.toInt(), crewName); } @@ -150,9 +207,7 @@ void DatabaseThread::scanCrewReference(QStringList crewList, int requestDelay) waitingLoop->exec(); delete waitingLoop; - netReply->deleteLater(); delete netReply; - netManager->deleteLater(); delete netManager; } } @@ -173,6 +228,9 @@ void DatabaseThread::scanCrewMembersList(QStringList crewList, int maxPages, int QNetworkAccessManager *netManager = new QNetworkAccessManager(); QNetworkRequest netRequest(AppEnv::getPlayerFetchingUrl(crewID, QString::number(currentPage))); +#if QT_VERSION >= 0x050600 + netRequest.setAttribute(QNetworkRequest::FollowRedirectsAttribute, true); +#endif netRequest.setRawHeader("User-Agent", AppEnv::getUserAgent()); netRequest.setRawHeader("Accept", "text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8"); netRequest.setRawHeader("Accept-Language", "en-US;q=0.5,en;q=0.3"); @@ -224,9 +282,7 @@ void DatabaseThread::scanCrewMembersList(QStringList crewList, int maxPages, int currentPage++; } - netReply->deleteLater(); delete netReply; - netManager->deleteLater(); delete netManager; } } diff --git a/config.h b/config.h index a159ce9..ff71653 100755 --- a/config.h +++ b/config.h @@ -50,7 +50,7 @@ #ifndef GTA5SYNC_APPVER #ifndef GTA5SYNC_DAILYB -#define GTA5SYNC_APPVER "1.3.4" +#define GTA5SYNC_APPVER "1.3.5" #else #define GTA5SYNC_APPVER QString("%1").arg(GTA5SYNC_DAILYB) #endif diff --git a/res/app.rc b/res/app.rc index 7a643e1..6c5a245 100755 --- a/res/app.rc +++ b/res/app.rc @@ -7,8 +7,8 @@ CREATEPROCESS_MANIFEST_RESOURCE_ID RT_MANIFEST "gta5view.exe.manifest" #include VS_VERSION_INFO VERSIONINFO -FILEVERSION 1, 3, 4, 0 -PRODUCTVERSION 1, 3, 4, 0 +FILEVERSION 1, 3, 5, 0 +PRODUCTVERSION 1, 3, 5, 0 FILEFLAGSMASK 0x3fL FILEFLAGS 0 FILEOS VOS_NT_WINDOWS32 @@ -25,12 +25,12 @@ BEGIN BEGIN VALUE "CompanyName", "Syping" VALUE "FileDescription", "gta5view\0" - VALUE "FileVersion", "1.3.4\0" + VALUE "FileVersion", "1.3.5\0" VALUE "InternalName", "gta5view\0" VALUE "LegalCopyright", "Copyright © 2016-2017 Syping\0" VALUE "OriginalFilename", "gta5view.exe\0" VALUE "ProductName", "gta5view\0" - VALUE "ProductVersion", "1.3.4\0" + VALUE "ProductVersion", "1.3.5\0" END END END