From b953c49461dc26176336770f5cd1f6afdfb26eec Mon Sep 17 00:00:00 2001 From: Cain Kilgore Date: Fri, 8 Sep 2017 03:20:55 +0100 Subject: [PATCH 01/17] Commit for Better Logger - WL 21537 --- interface/src/Application.cpp | 13 +++++++++++-- libraries/shared/src/shared/FileLogger.cpp | 11 ++++++++++- libraries/shared/src/shared/FileLogger.h | 1 + 3 files changed, 22 insertions(+), 3 deletions(-) diff --git a/interface/src/Application.cpp b/interface/src/Application.cpp index 3650c495f2..f0ad0fe85b 100644 --- a/interface/src/Application.cpp +++ b/interface/src/Application.cpp @@ -510,6 +510,13 @@ void messageHandler(QtMsgType type, const QMessageLogContext& context, const QSt OutputDebugStringA(logMessage.toLocal8Bit().constData()); OutputDebugStringA("\n"); #endif + auto avatarManager = DependencyManager::get(); + auto myAvatar = avatarManager ? avatarManager->getMyAvatar() : nullptr; + + QUuid fileLoggerSessionID = myAvatar->getSessionUUID(); + if (!fileLoggerSessionID.isNull()) { + qApp->getLogger()->setSessionID(fileLoggerSessionID); + } qApp->getLogger()->addMessage(qPrintable(logMessage + "\n")); } } @@ -804,6 +811,10 @@ Application::Application(int& argc, char** argv, QElapsedTimer& startupTimer, bo _deadlockWatchdogThread = new DeadlockWatchdogThread(); _deadlockWatchdogThread->start(); + // Set File Logger Session UUID + auto avatarManager = DependencyManager::get(); + auto myAvatar = avatarManager ? avatarManager->getMyAvatar() : nullptr; + if (steamClient) { qCDebug(interfaceapp) << "[VERSION] SteamVR buildID:" << steamClient->getSteamVRBuildID(); } @@ -920,8 +931,6 @@ Application::Application(int& argc, char** argv, QElapsedTimer& startupTimer, bo // send a location update immediately discoverabilityManager->updateLocation(); - auto myAvatar = getMyAvatar(); - connect(nodeList.data(), &NodeList::nodeAdded, this, &Application::nodeAdded); connect(nodeList.data(), &NodeList::nodeKilled, this, &Application::nodeKilled); connect(nodeList.data(), &NodeList::nodeActivated, this, &Application::nodeActivated); diff --git a/libraries/shared/src/shared/FileLogger.cpp b/libraries/shared/src/shared/FileLogger.cpp index bea28b2b6f..1ac87907bf 100644 --- a/libraries/shared/src/shared/FileLogger.cpp +++ b/libraries/shared/src/shared/FileLogger.cpp @@ -48,6 +48,8 @@ static const QString LOGS_DIRECTORY = "Logs"; static const QString IPADDR_WILDCARD = "[0-9]*.[0-9]*.[0-9]*.[0-9]*"; static const QString DATETIME_WILDCARD = "20[0-9][0-9]-[0,1][0-9]-[0-3][0-9]_[0-2][0-9].[0-6][0-9].[0-6][0-9]"; static const QString FILENAME_WILDCARD = "hifi-log_" + IPADDR_WILDCARD + "_" + DATETIME_WILDCARD + ".txt"; +static QUuid& SESSION_ID = QUuid::QUuid("{00000000-0000-0000-0000-000000000000}"); + // Max log size is 512 KB. We send log files to our crash reporter, so we want to keep this relatively // small so it doesn't go over the 2MB zipped limit for all of the files we send. static const qint64 MAX_LOG_SIZE = 512 * 1024; @@ -62,7 +64,10 @@ QString getLogRollerFilename() { QString result = FileUtils::standardPath(LOGS_DIRECTORY); QHostAddress clientAddress = getGuessedLocalAddress(); QDateTime now = QDateTime::currentDateTime(); - result.append(QString(FILENAME_FORMAT).arg(clientAddress.toString(), now.toString(DATETIME_FORMAT))); + + auto FILE_SESSION_ID = SESSION_ID.toString().replace("{", "").replace("}", ""); + + result.append(QString(FILENAME_FORMAT).arg(FILE_SESSION_ID, now.toString(DATETIME_FORMAT))); return result; } @@ -142,6 +147,10 @@ FileLogger::~FileLogger() { _persistThreadInstance->terminate(); } +void FileLogger::setSessionID(const QUuid& message) { + SESSION_ID = message; // This is for the output of log files. It will change if the Avatar enters a different domain. +} + void FileLogger::addMessage(const QString& message) { _persistThreadInstance->queueItem(message); emit logReceived(message); diff --git a/libraries/shared/src/shared/FileLogger.h b/libraries/shared/src/shared/FileLogger.h index 15d211afe8..d9d7651147 100644 --- a/libraries/shared/src/shared/FileLogger.h +++ b/libraries/shared/src/shared/FileLogger.h @@ -26,6 +26,7 @@ public: QString getFilename() const { return _fileName; } virtual void addMessage(const QString&) override; + virtual void setSessionID(const QUuid&); virtual QString getLogData() override; virtual void locateLog() override; virtual void sync() override; From 7f4cc0ed2a6382e289eaf7907ac51537e5531fc0 Mon Sep 17 00:00:00 2001 From: Cain Kilgore Date: Fri, 8 Sep 2017 20:21:17 +0100 Subject: [PATCH 02/17] Should fix the Mac Build --- libraries/shared/src/shared/FileLogger.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libraries/shared/src/shared/FileLogger.cpp b/libraries/shared/src/shared/FileLogger.cpp index 1ac87907bf..56393f4f32 100644 --- a/libraries/shared/src/shared/FileLogger.cpp +++ b/libraries/shared/src/shared/FileLogger.cpp @@ -48,7 +48,7 @@ static const QString LOGS_DIRECTORY = "Logs"; static const QString IPADDR_WILDCARD = "[0-9]*.[0-9]*.[0-9]*.[0-9]*"; static const QString DATETIME_WILDCARD = "20[0-9][0-9]-[0,1][0-9]-[0-3][0-9]_[0-2][0-9].[0-6][0-9].[0-6][0-9]"; static const QString FILENAME_WILDCARD = "hifi-log_" + IPADDR_WILDCARD + "_" + DATETIME_WILDCARD + ".txt"; -static QUuid& SESSION_ID = QUuid::QUuid("{00000000-0000-0000-0000-000000000000}"); +static QUuid& SESSION_ID = QUuid("{00000000-0000-0000-0000-000000000000}"); // Max log size is 512 KB. We send log files to our crash reporter, so we want to keep this relatively // small so it doesn't go over the 2MB zipped limit for all of the files we send. From dfbd25fd77ffe1e6b9b6ec5938dc250126ade69b Mon Sep 17 00:00:00 2001 From: Cain Kilgore Date: Fri, 8 Sep 2017 20:51:41 +0100 Subject: [PATCH 03/17] Now pls --- libraries/shared/src/shared/FileLogger.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libraries/shared/src/shared/FileLogger.cpp b/libraries/shared/src/shared/FileLogger.cpp index 56393f4f32..652cca79a3 100644 --- a/libraries/shared/src/shared/FileLogger.cpp +++ b/libraries/shared/src/shared/FileLogger.cpp @@ -48,7 +48,7 @@ static const QString LOGS_DIRECTORY = "Logs"; static const QString IPADDR_WILDCARD = "[0-9]*.[0-9]*.[0-9]*.[0-9]*"; static const QString DATETIME_WILDCARD = "20[0-9][0-9]-[0,1][0-9]-[0-3][0-9]_[0-2][0-9].[0-6][0-9].[0-6][0-9]"; static const QString FILENAME_WILDCARD = "hifi-log_" + IPADDR_WILDCARD + "_" + DATETIME_WILDCARD + ".txt"; -static QUuid& SESSION_ID = QUuid("{00000000-0000-0000-0000-000000000000}"); +QUuid& SESSION_ID = QUuid("{00000000-0000-0000-0000-000000000000}"); // Max log size is 512 KB. We send log files to our crash reporter, so we want to keep this relatively // small so it doesn't go over the 2MB zipped limit for all of the files we send. From 7b39cb77916e032aa7dcb954c64b165e8f197d75 Mon Sep 17 00:00:00 2001 From: Cain Kilgore Date: Fri, 8 Sep 2017 21:44:38 +0100 Subject: [PATCH 04/17] Should work now --- libraries/shared/src/shared/FileLogger.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libraries/shared/src/shared/FileLogger.cpp b/libraries/shared/src/shared/FileLogger.cpp index 652cca79a3..46ba45e238 100644 --- a/libraries/shared/src/shared/FileLogger.cpp +++ b/libraries/shared/src/shared/FileLogger.cpp @@ -48,7 +48,7 @@ static const QString LOGS_DIRECTORY = "Logs"; static const QString IPADDR_WILDCARD = "[0-9]*.[0-9]*.[0-9]*.[0-9]*"; static const QString DATETIME_WILDCARD = "20[0-9][0-9]-[0,1][0-9]-[0-3][0-9]_[0-2][0-9].[0-6][0-9].[0-6][0-9]"; static const QString FILENAME_WILDCARD = "hifi-log_" + IPADDR_WILDCARD + "_" + DATETIME_WILDCARD + ".txt"; -QUuid& SESSION_ID = QUuid("{00000000-0000-0000-0000-000000000000}"); +QUuid SESSION_ID = QUuid("{00000000-0000-0000-0000-000000000000}"); // Max log size is 512 KB. We send log files to our crash reporter, so we want to keep this relatively // small so it doesn't go over the 2MB zipped limit for all of the files we send. From f109a86b23fb0476e8d9b40e1dac7229a7b9c042 Mon Sep 17 00:00:00 2001 From: Cain Kilgore Date: Fri, 8 Sep 2017 23:05:22 +0100 Subject: [PATCH 05/17] Fixed small crash bug on exit --- interface/src/Application.cpp | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/interface/src/Application.cpp b/interface/src/Application.cpp index f0ad0fe85b..3ee5406ad0 100644 --- a/interface/src/Application.cpp +++ b/interface/src/Application.cpp @@ -513,10 +513,13 @@ void messageHandler(QtMsgType type, const QMessageLogContext& context, const QSt auto avatarManager = DependencyManager::get(); auto myAvatar = avatarManager ? avatarManager->getMyAvatar() : nullptr; - QUuid fileLoggerSessionID = myAvatar->getSessionUUID(); - if (!fileLoggerSessionID.isNull()) { - qApp->getLogger()->setSessionID(fileLoggerSessionID); + if (myAvatar) { + QUuid fileLoggerSessionID = myAvatar->getSessionUUID(); + if (!fileLoggerSessionID.isNull()) { + qApp->getLogger()->setSessionID(fileLoggerSessionID); + } } + qApp->getLogger()->addMessage(qPrintable(logMessage + "\n")); } } From 387e474889fd7961d63b198a6718a7ccc2ad285f Mon Sep 17 00:00:00 2001 From: Cain Kilgore Date: Fri, 8 Sep 2017 23:48:09 +0100 Subject: [PATCH 06/17] WIP --- interface/src/Application.cpp | 24 ++++++++++++------------ libraries/avatars/src/AvatarData.h | 10 ++++++++-- 2 files changed, 20 insertions(+), 14 deletions(-) diff --git a/interface/src/Application.cpp b/interface/src/Application.cpp index 3ee5406ad0..e373e321f2 100644 --- a/interface/src/Application.cpp +++ b/interface/src/Application.cpp @@ -510,16 +510,6 @@ void messageHandler(QtMsgType type, const QMessageLogContext& context, const QSt OutputDebugStringA(logMessage.toLocal8Bit().constData()); OutputDebugStringA("\n"); #endif - auto avatarManager = DependencyManager::get(); - auto myAvatar = avatarManager ? avatarManager->getMyAvatar() : nullptr; - - if (myAvatar) { - QUuid fileLoggerSessionID = myAvatar->getSessionUUID(); - if (!fileLoggerSessionID.isNull()) { - qApp->getLogger()->setSessionID(fileLoggerSessionID); - } - } - qApp->getLogger()->addMessage(qPrintable(logMessage + "\n")); } } @@ -798,10 +788,19 @@ Application::Application(int& argc, char** argv, QElapsedTimer& startupTimer, bo installNativeEventFilter(&MyNativeEventFilter::getInstance()); #endif - _logger = new FileLogger(this); // After setting organization name in order to get correct directory - + qInstallMessageHandler(messageHandler); + _logger = new FileLogger(this); + + connect(getMyAvatar().get(), &AvatarData::sessionUUIDChanged, _logger, [this] { + auto myAvatar = getMyAvatar(); + if (myAvatar) { + _logger->setSessionID(myAvatar->getSessionUUID()); + } + }); + + QFontDatabase::addApplicationFont(PathUtils::resourcesPath() + "styles/Inconsolata.otf"); _window->setWindowTitle("High Fidelity Interface"); @@ -2102,6 +2101,7 @@ Application::~Application() { _octreeProcessor.terminate(); _entityEditSender.terminate(); + disconnect(getMyAvatar().get(), &AvatarData::sessionUUIDChanged, _logger, nullptr); DependencyManager::destroy(); DependencyManager::destroy(); diff --git a/libraries/avatars/src/AvatarData.h b/libraries/avatars/src/AvatarData.h index b4c36dba70..b5bce50e68 100644 --- a/libraries/avatars/src/AvatarData.h +++ b/libraries/avatars/src/AvatarData.h @@ -381,7 +381,7 @@ class AvatarData : public QObject, public SpatiallyNestable { Q_PROPERTY(QStringList jointNames READ getJointNames) - Q_PROPERTY(QUuid sessionUUID READ getSessionUUID) + Q_PROPERTY(QUuid sessionUUID READ getSessionUUID NOTIFY sessionUUIDChanged) Q_PROPERTY(glm::mat4 sensorToWorldMatrix READ getSensorToWorldMatrix) Q_PROPERTY(glm::mat4 controllerLeftHandMatrix READ getControllerLeftHandMatrix) @@ -667,13 +667,19 @@ public: signals: void displayNameChanged(); void lookAtSnappingChanged(bool enabled); + void sessionUUIDChanged(); public slots: void sendAvatarDataPacket(); void sendIdentityPacket(); void setJointMappingsFromNetworkReply(); - void setSessionUUID(const QUuid& sessionUUID) { setID(sessionUUID); } + void setSessionUUID(const QUuid& sessionUUID) { + if (sessionUUID != getID()) { + setID(sessionUUID); + emit sessionUUIDChanged(); + } + } virtual glm::quat getAbsoluteJointRotationInObjectFrame(int index) const override; virtual glm::vec3 getAbsoluteJointTranslationInObjectFrame(int index) const override; From 0820eadc5b154949466311ce190aad83c8b5c00e Mon Sep 17 00:00:00 2001 From: Cain Kilgore Date: Fri, 8 Sep 2017 23:52:04 +0100 Subject: [PATCH 07/17] Fixed a thing --- interface/src/Application.cpp | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/interface/src/Application.cpp b/interface/src/Application.cpp index e373e321f2..874cf34726 100644 --- a/interface/src/Application.cpp +++ b/interface/src/Application.cpp @@ -789,9 +789,8 @@ Application::Application(int& argc, char** argv, QElapsedTimer& startupTimer, bo #endif - qInstallMessageHandler(messageHandler); - _logger = new FileLogger(this); + qInstallMessageHandler(messageHandler); connect(getMyAvatar().get(), &AvatarData::sessionUUIDChanged, _logger, [this] { auto myAvatar = getMyAvatar(); From f6e22b0733569d27a55aac233224cb7fc33abc2c Mon Sep 17 00:00:00 2001 From: Cain Kilgore Date: Sat, 9 Sep 2017 17:21:42 +0100 Subject: [PATCH 08/17] Changes The ID no longer relies on the Avatar Session ID as this changed per domain switch. The intention of this PR is to be able to group the log files easier, hence why it now relies on Interface ID instead. Additionally, when no ID is found when the interface is first launched, the ID doesn't appear in the rolled over log file. It will just appear blank. --- interface/src/Application.cpp | 13 ++++--------- libraries/shared/src/shared/FileLogger.cpp | 9 ++++++--- 2 files changed, 10 insertions(+), 12 deletions(-) diff --git a/interface/src/Application.cpp b/interface/src/Application.cpp index 874cf34726..a063dfd0a1 100644 --- a/interface/src/Application.cpp +++ b/interface/src/Application.cpp @@ -792,14 +792,6 @@ Application::Application(int& argc, char** argv, QElapsedTimer& startupTimer, bo _logger = new FileLogger(this); qInstallMessageHandler(messageHandler); - connect(getMyAvatar().get(), &AvatarData::sessionUUIDChanged, _logger, [this] { - auto myAvatar = getMyAvatar(); - if (myAvatar) { - _logger->setSessionID(myAvatar->getSessionUUID()); - } - }); - - QFontDatabase::addApplicationFont(PathUtils::resourcesPath() + "styles/Inconsolata.otf"); _window->setWindowTitle("High Fidelity Interface"); @@ -815,6 +807,9 @@ Application::Application(int& argc, char** argv, QElapsedTimer& startupTimer, bo // Set File Logger Session UUID auto avatarManager = DependencyManager::get(); auto myAvatar = avatarManager ? avatarManager->getMyAvatar() : nullptr; + auto accountManager = DependencyManager::get(); + + _logger->setSessionID(accountManager->getSessionID()); if (steamClient) { qCDebug(interfaceapp) << "[VERSION] SteamVR buildID:" << steamClient->getSteamVRBuildID(); @@ -943,7 +938,7 @@ Application::Application(int& argc, char** argv, QElapsedTimer& startupTimer, bo connect(nodeList.data(), &NodeList::limitOfSilentDomainCheckInsReached, nodeList.data(), &NodeList::reset); // connect to appropriate slots on AccountManager - auto accountManager = DependencyManager::get(); + // auto accountManager = DependencyManager::get(); auto dialogsManager = DependencyManager::get(); connect(accountManager.data(), &AccountManager::authRequired, dialogsManager.data(), &DialogsManager::showLoginDialog); diff --git a/libraries/shared/src/shared/FileLogger.cpp b/libraries/shared/src/shared/FileLogger.cpp index 46ba45e238..f712a341fe 100644 --- a/libraries/shared/src/shared/FileLogger.cpp +++ b/libraries/shared/src/shared/FileLogger.cpp @@ -42,13 +42,13 @@ private: -static const QString FILENAME_FORMAT = "hifi-log_%1_%2.txt"; +static const QString FILENAME_FORMAT = "hifi-log%1_%2.txt"; static const QString DATETIME_FORMAT = "yyyy-MM-dd_hh.mm.ss"; static const QString LOGS_DIRECTORY = "Logs"; static const QString IPADDR_WILDCARD = "[0-9]*.[0-9]*.[0-9]*.[0-9]*"; static const QString DATETIME_WILDCARD = "20[0-9][0-9]-[0,1][0-9]-[0-3][0-9]_[0-2][0-9].[0-6][0-9].[0-6][0-9]"; static const QString FILENAME_WILDCARD = "hifi-log_" + IPADDR_WILDCARD + "_" + DATETIME_WILDCARD + ".txt"; -QUuid SESSION_ID = QUuid("{00000000-0000-0000-0000-000000000000}"); +QUuid SESSION_ID; // Max log size is 512 KB. We send log files to our crash reporter, so we want to keep this relatively // small so it doesn't go over the 2MB zipped limit for all of the files we send. @@ -64,8 +64,11 @@ QString getLogRollerFilename() { QString result = FileUtils::standardPath(LOGS_DIRECTORY); QHostAddress clientAddress = getGuessedLocalAddress(); QDateTime now = QDateTime::currentDateTime(); + QString FILE_SESSION_ID; - auto FILE_SESSION_ID = SESSION_ID.toString().replace("{", "").replace("}", ""); + if (!SESSION_ID.isNull()) { + FILE_SESSION_ID = "_" + SESSION_ID.toString().replace("{", "").replace("}", ""); + } result.append(QString(FILENAME_FORMAT).arg(FILE_SESSION_ID, now.toString(DATETIME_FORMAT))); return result; From b69bd0ef49f2c04862ca31c56a8f101082309a06 Mon Sep 17 00:00:00 2001 From: Cain Kilgore Date: Sat, 9 Sep 2017 17:23:18 +0100 Subject: [PATCH 09/17] Removed old Disconnect --- interface/src/Application.cpp | 2 -- 1 file changed, 2 deletions(-) diff --git a/interface/src/Application.cpp b/interface/src/Application.cpp index a063dfd0a1..2fa141a44f 100644 --- a/interface/src/Application.cpp +++ b/interface/src/Application.cpp @@ -2095,8 +2095,6 @@ Application::~Application() { _octreeProcessor.terminate(); _entityEditSender.terminate(); - disconnect(getMyAvatar().get(), &AvatarData::sessionUUIDChanged, _logger, nullptr); - DependencyManager::destroy(); DependencyManager::destroy(); DependencyManager::destroy(); From 1c05311056cb64385ff93f69de0d66310174e0f4 Mon Sep 17 00:00:00 2001 From: Cain Kilgore Date: Wed, 13 Sep 2017 16:48:18 +0100 Subject: [PATCH 10/17] Some code cleanup --- interface/src/Application.cpp | 3 --- libraries/shared/src/shared/FileLogger.cpp | 16 +++++++++------- 2 files changed, 9 insertions(+), 10 deletions(-) diff --git a/interface/src/Application.cpp b/interface/src/Application.cpp index 2fa141a44f..8de6d93dd6 100644 --- a/interface/src/Application.cpp +++ b/interface/src/Application.cpp @@ -937,9 +937,6 @@ Application::Application(int& argc, char** argv, QElapsedTimer& startupTimer, bo // you might think we could just do this in NodeList but we only want this connection for Interface connect(nodeList.data(), &NodeList::limitOfSilentDomainCheckInsReached, nodeList.data(), &NodeList::reset); - // connect to appropriate slots on AccountManager - // auto accountManager = DependencyManager::get(); - auto dialogsManager = DependencyManager::get(); connect(accountManager.data(), &AccountManager::authRequired, dialogsManager.data(), &DialogsManager::showLoginDialog); connect(accountManager.data(), &AccountManager::usernameChanged, this, &Application::updateWindowTitle); diff --git a/libraries/shared/src/shared/FileLogger.cpp b/libraries/shared/src/shared/FileLogger.cpp index f712a341fe..50b0ccb43c 100644 --- a/libraries/shared/src/shared/FileLogger.cpp +++ b/libraries/shared/src/shared/FileLogger.cpp @@ -48,7 +48,7 @@ static const QString LOGS_DIRECTORY = "Logs"; static const QString IPADDR_WILDCARD = "[0-9]*.[0-9]*.[0-9]*.[0-9]*"; static const QString DATETIME_WILDCARD = "20[0-9][0-9]-[0,1][0-9]-[0-3][0-9]_[0-2][0-9].[0-6][0-9].[0-6][0-9]"; static const QString FILENAME_WILDCARD = "hifi-log_" + IPADDR_WILDCARD + "_" + DATETIME_WILDCARD + ".txt"; -QUuid SESSION_ID; +QUuid _sessionId; // Max log size is 512 KB. We send log files to our crash reporter, so we want to keep this relatively // small so it doesn't go over the 2MB zipped limit for all of the files we send. @@ -64,13 +64,13 @@ QString getLogRollerFilename() { QString result = FileUtils::standardPath(LOGS_DIRECTORY); QHostAddress clientAddress = getGuessedLocalAddress(); QDateTime now = QDateTime::currentDateTime(); - QString FILE_SESSION_ID; + QString fileSessionID; - if (!SESSION_ID.isNull()) { - FILE_SESSION_ID = "_" + SESSION_ID.toString().replace("{", "").replace("}", ""); + if (!_sessionId.isNull()) { + fileSessionID = "_" + _sessionId.toString().replace("{", "").replace("}", ""); } - result.append(QString(FILENAME_FORMAT).arg(FILE_SESSION_ID, now.toString(DATETIME_FORMAT))); + result.append(QString(FILENAME_FORMAT).arg(fileSessionID, now.toString(DATETIME_FORMAT))); return result; } @@ -151,8 +151,10 @@ FileLogger::~FileLogger() { } void FileLogger::setSessionID(const QUuid& message) { - SESSION_ID = message; // This is for the output of log files. It will change if the Avatar enters a different domain. -} + // This is for the output of log files. Once the application is first started, + // this function runs and grabs the AccountManager Session ID and saves it here. + _sessionId = message; + } void FileLogger::addMessage(const QString& message) { _persistThreadInstance->queueItem(message); From 2427008ff333ad534c2c0e3c14c7e3de0a4b90a5 Mon Sep 17 00:00:00 2001 From: Cain Kilgore Date: Wed, 13 Sep 2017 17:40:04 +0100 Subject: [PATCH 11/17] Static --- libraries/shared/src/shared/FileLogger.cpp | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/libraries/shared/src/shared/FileLogger.cpp b/libraries/shared/src/shared/FileLogger.cpp index 50b0ccb43c..b019b69fb8 100644 --- a/libraries/shared/src/shared/FileLogger.cpp +++ b/libraries/shared/src/shared/FileLogger.cpp @@ -26,7 +26,6 @@ class FilePersistThread : public GenericQueueThread < QString > { Q_OBJECT public: FilePersistThread(const FileLogger& logger); - signals: void rollingLogFile(QString newFilename); @@ -48,7 +47,7 @@ static const QString LOGS_DIRECTORY = "Logs"; static const QString IPADDR_WILDCARD = "[0-9]*.[0-9]*.[0-9]*.[0-9]*"; static const QString DATETIME_WILDCARD = "20[0-9][0-9]-[0,1][0-9]-[0-3][0-9]_[0-2][0-9].[0-6][0-9].[0-6][0-9]"; static const QString FILENAME_WILDCARD = "hifi-log_" + IPADDR_WILDCARD + "_" + DATETIME_WILDCARD + ".txt"; -QUuid _sessionId; +static QUuid SESSION_ID; // Max log size is 512 KB. We send log files to our crash reporter, so we want to keep this relatively // small so it doesn't go over the 2MB zipped limit for all of the files we send. @@ -66,8 +65,8 @@ QString getLogRollerFilename() { QDateTime now = QDateTime::currentDateTime(); QString fileSessionID; - if (!_sessionId.isNull()) { - fileSessionID = "_" + _sessionId.toString().replace("{", "").replace("}", ""); + if (!SESSION_ID.isNull()) { + fileSessionID = "_" + SESSION_ID.toString().replace("{", "").replace("}", ""); } result.append(QString(FILENAME_FORMAT).arg(fileSessionID, now.toString(DATETIME_FORMAT))); @@ -153,7 +152,7 @@ FileLogger::~FileLogger() { void FileLogger::setSessionID(const QUuid& message) { // This is for the output of log files. Once the application is first started, // this function runs and grabs the AccountManager Session ID and saves it here. - _sessionId = message; + SESSION_ID = message; } void FileLogger::addMessage(const QString& message) { From d605bd9ef4f1da448ccc1561df1cb12d5ce5b480 Mon Sep 17 00:00:00 2001 From: Zach Fox Date: Thu, 5 Oct 2017 11:01:15 -0700 Subject: [PATCH 12/17] Preprocess inventory endpoint result --- .../qml/hifi/commerce/purchases/Purchases.qml | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/interface/resources/qml/hifi/commerce/purchases/Purchases.qml b/interface/resources/qml/hifi/commerce/purchases/Purchases.qml index 0bb1515b69..1f7f2e6e53 100644 --- a/interface/resources/qml/hifi/commerce/purchases/Purchases.qml +++ b/interface/resources/qml/hifi/commerce/purchases/Purchases.qml @@ -81,8 +81,10 @@ Rectangle { if (result.status !== 'success') { console.log("Failed to get purchases", result.message); } else { + var inventoryResult = processInventoryResult(result.data.assets); + purchasesModel.clear(); - purchasesModel.append(result.data.assets); + purchasesModel.append(inventoryResult); if (previousPurchasesModel.count !== 0) { checkIfAnyItemStatusChanged(); @@ -93,7 +95,7 @@ Rectangle { purchasesModel.setProperty(i, "statusChanged", false); } } - previousPurchasesModel.append(result.data.assets); + previousPurchasesModel.append(inventoryResult); buildFilteredPurchasesModel(); @@ -590,6 +592,17 @@ Rectangle { // FUNCTION DEFINITIONS START // + function processInventoryResult(inventory) { + for (var i = 0; i < inventory.length; i++) { + if (inventory[i].status.length > 1) { + console.log("WARNING: Inventory result index " + i + " has a status of length >1!") + } + inventory[i].status = inventory[i].status[0]; + inventory[i].categories = inventory[i].categories.join(';'); + } + return inventory; + } + function populateDisplayedItemCounts() { var itemCountDictionary = {}; var currentItemId; From b3c3b2d34fbab47b720c8a6b1876568433ed8097 Mon Sep 17 00:00:00 2001 From: Cain Kilgore Date: Thu, 5 Oct 2017 19:42:31 +0100 Subject: [PATCH 13/17] Switched Time & Session ID Over --- libraries/shared/src/shared/FileLogger.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/libraries/shared/src/shared/FileLogger.cpp b/libraries/shared/src/shared/FileLogger.cpp index b019b69fb8..8ceb378574 100644 --- a/libraries/shared/src/shared/FileLogger.cpp +++ b/libraries/shared/src/shared/FileLogger.cpp @@ -41,7 +41,7 @@ private: -static const QString FILENAME_FORMAT = "hifi-log%1_%2.txt"; +static const QString FILENAME_FORMAT = "hifi-log_%1%2.txt"; static const QString DATETIME_FORMAT = "yyyy-MM-dd_hh.mm.ss"; static const QString LOGS_DIRECTORY = "Logs"; static const QString IPADDR_WILDCARD = "[0-9]*.[0-9]*.[0-9]*.[0-9]*"; @@ -69,7 +69,7 @@ QString getLogRollerFilename() { fileSessionID = "_" + SESSION_ID.toString().replace("{", "").replace("}", ""); } - result.append(QString(FILENAME_FORMAT).arg(fileSessionID, now.toString(DATETIME_FORMAT))); + result.append(QString(FILENAME_FORMAT).arg(now.toString(DATETIME_FORMAT), fileSessionID)); return result; } From 8e8209513502e97c83e8716c0c156300c00ad23b Mon Sep 17 00:00:00 2001 From: Zach Fox Date: Thu, 5 Oct 2017 12:11:31 -0700 Subject: [PATCH 14/17] Number sold and limited run --- .../resources/qml/hifi/commerce/purchases/PurchasedItem.qml | 4 ++++ interface/resources/qml/hifi/commerce/purchases/Purchases.qml | 2 ++ 2 files changed, 6 insertions(+) diff --git a/interface/resources/qml/hifi/commerce/purchases/PurchasedItem.qml b/interface/resources/qml/hifi/commerce/purchases/PurchasedItem.qml index a026a818c0..1e26806b30 100644 --- a/interface/resources/qml/hifi/commerce/purchases/PurchasedItem.qml +++ b/interface/resources/qml/hifi/commerce/purchases/PurchasedItem.qml @@ -36,6 +36,8 @@ Item { property string itemHref; property int displayedItemCount; property int itemEdition; + property int numberSold; + property int limitedRun; property string originalStatusText; property string originalStatusColor; @@ -222,6 +224,8 @@ Item { "PENDING..." } else if (root.purchaseStatus === "invalidated") { "INVALIDATED" + } else if (root.numberSold !== -1) { + ("Sales: " + root.numberSold + "/" + (root.limitedRun === -1 ? "INFTY" : root.limitedRun)) } else { "" } diff --git a/interface/resources/qml/hifi/commerce/purchases/Purchases.qml b/interface/resources/qml/hifi/commerce/purchases/Purchases.qml index 1f7f2e6e53..990fd348c6 100644 --- a/interface/resources/qml/hifi/commerce/purchases/Purchases.qml +++ b/interface/resources/qml/hifi/commerce/purchases/Purchases.qml @@ -430,6 +430,8 @@ Rectangle { purchaseStatus: status; purchaseStatusChanged: statusChanged; itemEdition: model.edition_number; + numberSold: model.number_sold; + limitedRun: model.limited_run; displayedItemCount: model.displayedItemCount; anchors.topMargin: 12; anchors.bottomMargin: 12; From 9290a516851f7e70a437468cc313752baa65e504 Mon Sep 17 00:00:00 2001 From: Zach Fox Date: Thu, 5 Oct 2017 14:03:56 -0700 Subject: [PATCH 15/17] Fix confirmed text --- .../resources/qml/hifi/commerce/purchases/PurchasedItem.qml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/interface/resources/qml/hifi/commerce/purchases/PurchasedItem.qml b/interface/resources/qml/hifi/commerce/purchases/PurchasedItem.qml index 1e26806b30..5eb5516519 100644 --- a/interface/resources/qml/hifi/commerce/purchases/PurchasedItem.qml +++ b/interface/resources/qml/hifi/commerce/purchases/PurchasedItem.qml @@ -52,7 +52,6 @@ Item { statusText.text = "CONFIRMED!"; statusText.color = hifi.colors.blueAccent; confirmedTimer.start(); - root.purchaseStatusChanged = false; } } @@ -62,6 +61,7 @@ Item { onTriggered: { statusText.text = root.originalStatusText; statusText.color = root.originalStatusColor; + root.purchaseStatusChanged = false; } } @@ -205,7 +205,7 @@ Item { Item { id: statusContainer; - visible: root.purchaseStatus === "pending" || root.purchaseStatus === "invalidated"; + visible: root.purchaseStatus === "pending" || root.purchaseStatus === "invalidated" || root.purchaseStatusChanged; anchors.left: itemName.left; anchors.top: certificateContainer.bottom; anchors.topMargin: 8; From 0b600a74c3b6990e4caf90bb9c9adbfccc582163 Mon Sep 17 00:00:00 2001 From: Zach Fox Date: Thu, 5 Oct 2017 14:34:53 -0700 Subject: [PATCH 16/17] Fix passphrase input focus problem; fix getting inventory and balance after logging in on Checkout --- interface/resources/qml/hifi/commerce/checkout/Checkout.qml | 4 ++++ .../qml/hifi/commerce/common/EmulatedMarketplaceHeader.qml | 2 +- .../resources/qml/hifi/commerce/wallet/PassphraseModal.qml | 4 +++- 3 files changed, 8 insertions(+), 2 deletions(-) diff --git a/interface/resources/qml/hifi/commerce/checkout/Checkout.qml b/interface/resources/qml/hifi/commerce/checkout/Checkout.qml index 32f324aea9..09c2f6fa76 100644 --- a/interface/resources/qml/hifi/commerce/checkout/Checkout.qml +++ b/interface/resources/qml/hifi/commerce/checkout/Checkout.qml @@ -892,6 +892,10 @@ Rectangle { } else { root.activeView = "checkoutSuccess"; } + root.balanceReceived = false; + root.purchasesReceived = false; + commerce.inventory(); + commerce.balance(); } // diff --git a/interface/resources/qml/hifi/commerce/common/EmulatedMarketplaceHeader.qml b/interface/resources/qml/hifi/commerce/common/EmulatedMarketplaceHeader.qml index 420b51ba15..cc316a70e9 100644 --- a/interface/resources/qml/hifi/commerce/common/EmulatedMarketplaceHeader.qml +++ b/interface/resources/qml/hifi/commerce/common/EmulatedMarketplaceHeader.qml @@ -39,7 +39,7 @@ Item { sendToParent({method: "needsLogIn"}); } else if (walletStatus === 3) { commerce.getSecurityImage(); - } else { + } else if (walletStatus > 3) { console.log("ERROR in EmulatedMarketplaceHeader.qml: Unknown wallet status: " + walletStatus); } } diff --git a/interface/resources/qml/hifi/commerce/wallet/PassphraseModal.qml b/interface/resources/qml/hifi/commerce/wallet/PassphraseModal.qml index 5bd88ba790..8d5d9f97de 100644 --- a/interface/resources/qml/hifi/commerce/wallet/PassphraseModal.qml +++ b/interface/resources/qml/hifi/commerce/wallet/PassphraseModal.qml @@ -197,6 +197,8 @@ Item { height: 50; echoMode: TextInput.Password; placeholderText: "passphrase"; + activeFocusOnPress: true; + activeFocusOnTab: true; onFocusChanged: { root.keyboardRaised = focus; @@ -206,8 +208,8 @@ Item { anchors.fill: parent; onClicked: { - parent.focus = true; root.keyboardRaised = true; + mouse.accepted = false; } } From 525e0d8f61418a567e6f15d0f602f67e8be78279 Mon Sep 17 00:00:00 2001 From: Zach Fox Date: Thu, 5 Oct 2017 16:51:13 -0700 Subject: [PATCH 17/17] Make SettingsScriptingInterface accessible to tablet --- interface/src/ui/overlays/Web3DOverlay.cpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/interface/src/ui/overlays/Web3DOverlay.cpp b/interface/src/ui/overlays/Web3DOverlay.cpp index 811e169faf..526890b9c1 100644 --- a/interface/src/ui/overlays/Web3DOverlay.cpp +++ b/interface/src/ui/overlays/Web3DOverlay.cpp @@ -40,6 +40,7 @@ #include "scripting/HMDScriptingInterface.h" #include "scripting/AssetMappingsScriptingInterface.h" #include "scripting/MenuScriptingInterface.h" +#include "scripting/SettingsScriptingInterface.h" #include #include #include "FileDialogHelper.h" @@ -243,6 +244,7 @@ void Web3DOverlay::setupQmlSurface() { _webSurface->getSurfaceContext()->setContextProperty("InputConfiguration", DependencyManager::get().data()); _webSurface->getSurfaceContext()->setContextProperty("SoundCache", DependencyManager::get().data()); _webSurface->getSurfaceContext()->setContextProperty("MenuInterface", MenuScriptingInterface::getInstance()); + _webSurface->getSurfaceContext()->setContextProperty("Settings", SettingsScriptingInterface::getInstance()); _webSurface->getSurfaceContext()->setContextProperty("pathToFonts", "../../");