From 2883e242854b42dadc55b24f44f7fc24b122947e Mon Sep 17 00:00:00 2001 From: David Rowe Date: Wed, 17 Jan 2018 12:00:35 +1300 Subject: [PATCH 1/3] Add Window.protocolVersion() as a replacement for location's --- interface/src/Application.cpp | 3 +-- interface/src/scripting/WindowScriptingInterface.cpp | 4 ++++ interface/src/scripting/WindowScriptingInterface.h | 7 +++++++ libraries/networking/src/AddressManager.h | 1 + scripts/system/tablet-goto.js | 2 +- .../marketplace/camera-move/app-camera-move.js | 2 +- .../modules/custom-settings-app/CustomSettingsApp.js | 2 +- 7 files changed, 16 insertions(+), 5 deletions(-) diff --git a/interface/src/Application.cpp b/interface/src/Application.cpp index cc4e951235..4e3a4d097d 100644 --- a/interface/src/Application.cpp +++ b/interface/src/Application.cpp @@ -573,8 +573,7 @@ bool setupEssentials(int& argc, char** argv, bool runningMarkerExisted) { } }; reportAndQuit("--protocolVersion", [&](FILE* fp) { - DependencyManager::set(); - auto version = DependencyManager::get()->protocolVersion(); + auto version = protocolVersionsSignatureBase64(); fputs(version.toLatin1().data(), fp); }); reportAndQuit("--version", [&](FILE* fp) { diff --git a/interface/src/scripting/WindowScriptingInterface.cpp b/interface/src/scripting/WindowScriptingInterface.cpp index e36b84ac96..0ef1090fef 100644 --- a/interface/src/scripting/WindowScriptingInterface.cpp +++ b/interface/src/scripting/WindowScriptingInterface.cpp @@ -390,6 +390,10 @@ QString WindowScriptingInterface::checkVersion() { return QCoreApplication::applicationVersion(); } +QString WindowScriptingInterface::protocolVersion() { + return protocolVersionsSignatureBase64(); +} + int WindowScriptingInterface::getInnerWidth() { return qApp->getDeviceSize().x; } diff --git a/interface/src/scripting/WindowScriptingInterface.h b/interface/src/scripting/WindowScriptingInterface.h index bfad5644bf..a02025bb39 100644 --- a/interface/src/scripting/WindowScriptingInterface.h +++ b/interface/src/scripting/WindowScriptingInterface.h @@ -305,6 +305,13 @@ public slots: */ QString checkVersion(); + /**jsdoc + * Get Interface's protocol version. + * @function Window.protocolVersion + * @returns {string} A string uniquely identifying the version of the metaverse protocol that Interface is using. + */ + QString protocolVersion(); + /**jsdoc * Copies text to the operating system's clipboard. * @function Window.copyToClipboard diff --git a/libraries/networking/src/AddressManager.h b/libraries/networking/src/AddressManager.h index 7302e0e997..ef55b57de1 100644 --- a/libraries/networking/src/AddressManager.h +++ b/libraries/networking/src/AddressManager.h @@ -73,6 +73,7 @@ public: * Get Interface's protocol version. * @function location.protocolVersion * @returns {string} A string uniquely identifying the version of the metaverse protocol that Interface is using. + * @deprecated This function is deprecated and will removed. Use {@link Window.protocolVersion} instead. */ Q_INVOKABLE QString protocolVersion(); diff --git a/scripts/system/tablet-goto.js b/scripts/system/tablet-goto.js index 2a0e827932..a4d549ee47 100644 --- a/scripts/system/tablet-goto.js +++ b/scripts/system/tablet-goto.js @@ -136,7 +136,7 @@ 'include_actions=' + actions, 'restriction=' + (Account.isLoggedIn() ? 'open,hifi' : 'open'), 'require_online=true', - 'protocol=' + encodeURIComponent(location.protocolVersion()), + 'protocol=' + encodeURIComponent(Window.protocolVersion()), 'per_page=' + count ]; var url = Account.metaverseServerURL + '/api/v1/user_stories?' + options.join('&'); diff --git a/unpublishedScripts/marketplace/camera-move/app-camera-move.js b/unpublishedScripts/marketplace/camera-move/app-camera-move.js index f58dd3d3bd..4596d8803e 100644 --- a/unpublishedScripts/marketplace/camera-move/app-camera-move.js +++ b/unpublishedScripts/marketplace/camera-move/app-camera-move.js @@ -133,7 +133,7 @@ var DEBUG_INFO = { Reticle: { supportsScale: 'scale' in Reticle, }, - protocolVersion: location.protocolVersion, + protocolVersion: Window.protocolVersion(), }; var globalState = { diff --git a/unpublishedScripts/marketplace/camera-move/modules/custom-settings-app/CustomSettingsApp.js b/unpublishedScripts/marketplace/camera-move/modules/custom-settings-app/CustomSettingsApp.js index c76adea940..4c7cf71218 100644 --- a/unpublishedScripts/marketplace/camera-move/modules/custom-settings-app/CustomSettingsApp.js +++ b/unpublishedScripts/marketplace/camera-move/modules/custom-settings-app/CustomSettingsApp.js @@ -52,7 +52,7 @@ function CustomSettingsApp(options) { this.extraParams = Object.assign(options.extraParams || {}, { customSettingsVersion: CustomSettingsApp.version+'', - protocolVersion: location.protocolVersion && location.protocolVersion() + protocolVersion: Window.protocolVersion && Window.protocolVersion() }); var params = { From 8c2427dd58c6e257e043e3872f8f67c505c01061 Mon Sep 17 00:00:00 2001 From: David Rowe Date: Fri, 19 Jan 2018 09:06:16 +1300 Subject: [PATCH 2/3] Rename Window.protocolVersion() to Window.protocolSignature() --- interface/src/scripting/WindowScriptingInterface.cpp | 2 +- interface/src/scripting/WindowScriptingInterface.h | 6 +++--- libraries/networking/src/AddressManager.h | 2 +- scripts/system/tablet-goto.js | 2 +- .../marketplace/camera-move/app-camera-move.js | 2 +- .../modules/custom-settings-app/CustomSettingsApp.js | 2 +- 6 files changed, 8 insertions(+), 8 deletions(-) diff --git a/interface/src/scripting/WindowScriptingInterface.cpp b/interface/src/scripting/WindowScriptingInterface.cpp index 0ef1090fef..5ded796dc0 100644 --- a/interface/src/scripting/WindowScriptingInterface.cpp +++ b/interface/src/scripting/WindowScriptingInterface.cpp @@ -390,7 +390,7 @@ QString WindowScriptingInterface::checkVersion() { return QCoreApplication::applicationVersion(); } -QString WindowScriptingInterface::protocolVersion() { +QString WindowScriptingInterface::protocolSignature() { return protocolVersionsSignatureBase64(); } diff --git a/interface/src/scripting/WindowScriptingInterface.h b/interface/src/scripting/WindowScriptingInterface.h index a02025bb39..1225342d89 100644 --- a/interface/src/scripting/WindowScriptingInterface.h +++ b/interface/src/scripting/WindowScriptingInterface.h @@ -306,11 +306,11 @@ public slots: QString checkVersion(); /**jsdoc - * Get Interface's protocol version. - * @function Window.protocolVersion + * Get the signature for Interface's protocol version. + * @function Window.protocolSignature * @returns {string} A string uniquely identifying the version of the metaverse protocol that Interface is using. */ - QString protocolVersion(); + QString protocolSignature(); /**jsdoc * Copies text to the operating system's clipboard. diff --git a/libraries/networking/src/AddressManager.h b/libraries/networking/src/AddressManager.h index ef55b57de1..0173a1fad7 100644 --- a/libraries/networking/src/AddressManager.h +++ b/libraries/networking/src/AddressManager.h @@ -73,7 +73,7 @@ public: * Get Interface's protocol version. * @function location.protocolVersion * @returns {string} A string uniquely identifying the version of the metaverse protocol that Interface is using. - * @deprecated This function is deprecated and will removed. Use {@link Window.protocolVersion} instead. + * @deprecated This function is deprecated and will be removed. Use {@link Window.protocolSignature} instead. */ Q_INVOKABLE QString protocolVersion(); diff --git a/scripts/system/tablet-goto.js b/scripts/system/tablet-goto.js index a4d549ee47..43dae9625a 100644 --- a/scripts/system/tablet-goto.js +++ b/scripts/system/tablet-goto.js @@ -136,7 +136,7 @@ 'include_actions=' + actions, 'restriction=' + (Account.isLoggedIn() ? 'open,hifi' : 'open'), 'require_online=true', - 'protocol=' + encodeURIComponent(Window.protocolVersion()), + 'protocol=' + encodeURIComponent(Window.protocolSignature()), 'per_page=' + count ]; var url = Account.metaverseServerURL + '/api/v1/user_stories?' + options.join('&'); diff --git a/unpublishedScripts/marketplace/camera-move/app-camera-move.js b/unpublishedScripts/marketplace/camera-move/app-camera-move.js index 4596d8803e..f9361c6091 100644 --- a/unpublishedScripts/marketplace/camera-move/app-camera-move.js +++ b/unpublishedScripts/marketplace/camera-move/app-camera-move.js @@ -133,7 +133,7 @@ var DEBUG_INFO = { Reticle: { supportsScale: 'scale' in Reticle, }, - protocolVersion: Window.protocolVersion(), + protocolVersion: Window.protocolSignature(), }; var globalState = { diff --git a/unpublishedScripts/marketplace/camera-move/modules/custom-settings-app/CustomSettingsApp.js b/unpublishedScripts/marketplace/camera-move/modules/custom-settings-app/CustomSettingsApp.js index 4c7cf71218..95dba5c558 100644 --- a/unpublishedScripts/marketplace/camera-move/modules/custom-settings-app/CustomSettingsApp.js +++ b/unpublishedScripts/marketplace/camera-move/modules/custom-settings-app/CustomSettingsApp.js @@ -52,7 +52,7 @@ function CustomSettingsApp(options) { this.extraParams = Object.assign(options.extraParams || {}, { customSettingsVersion: CustomSettingsApp.version+'', - protocolVersion: Window.protocolVersion && Window.protocolVersion() + protocolVersion: Window.protocolSignature && Window.protocolSignature() }); var params = { From 13bbd1fcbfa3e4b6501c661300977fef8f9cd71d Mon Sep 17 00:00:00 2001 From: David Rowe Date: Fri, 19 Jan 2018 10:10:33 +1300 Subject: [PATCH 3/3] Update places feed to use new function --- interface/resources/qml/hifi/Feed.qml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/interface/resources/qml/hifi/Feed.qml b/interface/resources/qml/hifi/Feed.qml index 8576e26fcd..a9629c0e4e 100644 --- a/interface/resources/qml/hifi/Feed.qml +++ b/interface/resources/qml/hifi/Feed.qml @@ -102,7 +102,7 @@ Column { 'include_actions=' + actions, 'restriction=' + (Account.isLoggedIn() ? 'open,hifi' : 'open'), 'require_online=true', - 'protocol=' + encodeURIComponent(AddressManager.protocolVersion()), + 'protocol=' + encodeURIComponent(Window.protocolSignature()), 'page=' + pageNumber ]; var url = metaverseBase + 'user_stories?' + options.join('&');