History

Add getUserAgent function that includes plugin information

Ryan Huffman committed 10 years ago

Commit cf49c8e1 parent 335d9ab2 files · +37 −0Browse files

Showing the changes to interface/src/Application.cpp (1 of 2 files). Show all

Unified · Split

interface/src/Application.cpp+34−0
@@ -1057,6 +1057,40 @@ Application::Application(int& argc, char** argv, QElapsedTimer& startupTimer) : · 1056 unmodified lines
10571057 firstRun.set(false);
10581058 }
10591059
1060+QString Application::getUserAgent() {
1061+ if (QThread::currentThread() != thread()) {
1062+ QString userAgent;
1063+
1064+ QMetaObject::invokeMethod(this, "getUserAgent", Qt::BlockingQueuedConnection, Q_RETURN_ARG(QString, userAgent));
1065+
1066+ return userAgent;
1067+ }
1068+
1069+ QString userAgent = "Mozilla/5.0 (HighFidelityInterface/" + BuildInfo::VERSION + "; "
1070+ + QSysInfo::productType() + " " + QSysInfo::productVersion() + ")";
1071+
1072+ auto formatPluginName = [](QString name) -> QString { return name.trimmed().replace(" ", "-"); };
1073+
1074+ // For each plugin, add to userAgent
1075+ auto displayPlugins = PluginManager::getInstance()->getDisplayPlugins();
1076+ foreach(auto dp, displayPlugins) {
1077+ if (dp->isActive() && dp->isHmd()) {
1078+ userAgent += " " + formatPluginName(dp->getName());
1079+ }
1080+ }
1081+
1082+ // For each plugin, add to userAgent
1083+ auto inputPlugins= PluginManager::getInstance()->getInputPlugins();
1084+ foreach(auto ip, inputPlugins) {
1085+ if (ip->isActive()) {
1086+ userAgent += " " + formatPluginName(ip->getName());
1087+ }
1088+ }
1089+
1090+ return userAgent;
1091+}
1092+
1093+
10601094
10611095 void Application::checkChangeCursor() {
10621096 QMutexLocker locker(&_changeCursorLock);