|
@@ -8,89 +8,11 @@
|
|
|
#include <QResource>
|
|
|
#include <QFontDatabase>
|
|
|
#include <QMessageLogContext>
|
|
|
-#include <QTextStream>
|
|
|
-#include <QTcpSocket>
|
|
|
|
|
|
-extern Q_CORE_EXPORT int qt_ntfs_permission_lookup;
|
|
|
-
|
|
|
-bool urlExists(QUrl theurl){
|
|
|
- QTextStream out(stdout);
|
|
|
- QTcpSocket socket;
|
|
|
- QByteArray buffer;
|
|
|
-
|
|
|
- socket.connectToHost(theurl.host(), 80);
|
|
|
- if (socket.waitForConnected()) {
|
|
|
-
|
|
|
- socket.write("GET / HTTP/1.1\r\n"
|
|
|
- "host: " + theurl.host().toUtf8() + "\r\n\r\n");
|
|
|
- if (socket.waitForReadyRead()) {
|
|
|
- while(socket.bytesAvailable()){
|
|
|
- buffer.append(socket.readAll());
|
|
|
- int packetSize=buffer.size();
|
|
|
- while(packetSize>0)
|
|
|
- {
|
|
|
-
|
|
|
- out << "[" << buffer.data() << "]" <<endl;
|
|
|
-
|
|
|
-
|
|
|
- if (buffer.contains("200 OK") ||
|
|
|
- buffer.contains("302 Found") ||
|
|
|
- buffer.contains("301 Moved")) {
|
|
|
- return true;
|
|
|
- }
|
|
|
- buffer.remove(0,packetSize);
|
|
|
-
|
|
|
- packetSize=buffer.size();
|
|
|
-
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- }
|
|
|
- }
|
|
|
-return false;
|
|
|
-}
|
|
|
+#include "utils.h"
|
|
|
|
|
|
-void logMessageHandler(QtMsgType type, const QMessageLogContext &context, const QString &msg)
|
|
|
-{
|
|
|
- QString message_type;
|
|
|
-
|
|
|
- switch (type) {
|
|
|
- case QtDebugMsg:
|
|
|
- message_type = "[DEBG]";
|
|
|
- break;
|
|
|
- case QtInfoMsg:
|
|
|
- message_type = "[INFO]";
|
|
|
- break;
|
|
|
- case QtWarningMsg:
|
|
|
- message_type = "[WARN]";
|
|
|
- break;
|
|
|
- case QtCriticalMsg:
|
|
|
- message_type = "[CRIT]";
|
|
|
- break;
|
|
|
- case QtFatalMsg:
|
|
|
- message_type = "[FATL]";
|
|
|
- break;
|
|
|
- default:
|
|
|
- message_type = "[UNKN]";
|
|
|
- break;
|
|
|
- }
|
|
|
+extern Q_CORE_EXPORT int qt_ntfs_permission_lookup;
|
|
|
|
|
|
- QString filename = context.category;
|
|
|
- QString function = context.function;
|
|
|
- QString line_number = QString::number(context.line);
|
|
|
-
|
|
|
- QString s = QString("%1: %2\n")
|
|
|
- .arg(message_type)
|
|
|
- .arg(msg);
|
|
|
-
|
|
|
- QFile log_file("legacy_v2.log");
|
|
|
- log_file.open(QIODevice::ReadWrite | QIODevice::Append);
|
|
|
- QTextStream stream(&log_file);
|
|
|
- stream << s;
|
|
|
- log_file.close();
|
|
|
- fprintf(stderr, "%s", qUtf8Printable(s));
|
|
|
- fflush(stderr);
|
|
|
-}
|
|
|
|
|
|
LegacyApplication::LegacyApplication(int &argc, char **argv)
|
|
|
: QApplication(argc, argv)
|
|
@@ -231,7 +153,7 @@ LegacyApplication::ErrorStatus LegacyApplication::CheckErrorStatus()
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- if (!urlExists(QUrl(Settings::getValue("Network/patch_updates_url").toString()))) {
|
|
|
+ if (!checkInternetConnection(QUrl(Settings::getValue("Network/patch_updates_url").toString()))) {
|
|
|
status |= E_NO_SERVER_CONNECTION;
|
|
|
}
|
|
|
|
|
@@ -270,14 +192,14 @@ QDebug operator<<(QDebug dbg, const LegacyApplication::ErrorStatus &status)
|
|
|
bool dat_file_incorrect = (status & LegacyApplication::E_DAT_FILE_INCORRECT);
|
|
|
bool no_server_connection = (status & LegacyApplication::E_NO_SERVER_CONNECTION);
|
|
|
|
|
|
- dbg << "ErrorStatus( "
|
|
|
- << (wrong_game_folder ? "Wrong game folder!" : "")
|
|
|
- << (dat_files_missing ? "Dat files missing!" : "")
|
|
|
- << (wrong_file_permissions ? "Wrong file permissions!" : "")
|
|
|
- << (cannot_access_dat_files ? "Cannot access dat files!" : "")
|
|
|
- << (dat_file_incorrect ? "Incorrect dat file!" : "")
|
|
|
- << (no_server_connection ? "No server connection!" : "")
|
|
|
- <<")";
|
|
|
+ dbg.nospace() << "ErrorStatus ( "
|
|
|
+ << (wrong_game_folder ? "Wrong game folder! " : "")
|
|
|
+ << (dat_files_missing ? "Dat files missing! " : "")
|
|
|
+ << (wrong_file_permissions ? "Wrong file permissions! " : "")
|
|
|
+ << (cannot_access_dat_files ? "Cannot access dat files! " : "")
|
|
|
+ << (dat_file_incorrect ? "Incorrect dat file! " : "")
|
|
|
+ << (no_server_connection ? "No server connection! " : "")
|
|
|
+ << ")";
|
|
|
|
|
|
return dbg;
|
|
|
}
|