diff --git a/interface/src/Application.cpp b/interface/src/Application.cpp index 26c244a9d3..2eb6336e77 100644 --- a/interface/src/Application.cpp +++ b/interface/src/Application.cpp @@ -3429,8 +3429,7 @@ void Application::handleSandboxStatus(QNetworkReply* reply) { if (urlIndex != -1) { QUrl url(arguments().value(urlIndex + 1)); if (url.scheme() == URL_SCHEME_HIFIAPP) { - QmlCommerce commerce; - commerce.openSystemApp(url.path()); + Setting::Handle("startUpApp").set(url.path()); } else { addressLookupString = arguments().value(urlIndex + 1); } diff --git a/interface/src/commerce/QmlCommerce.cpp b/interface/src/commerce/QmlCommerce.cpp index 8a77c078b9..f6f5d64f67 100644 --- a/interface/src/commerce/QmlCommerce.cpp +++ b/interface/src/commerce/QmlCommerce.cpp @@ -47,11 +47,49 @@ QmlCommerce::QmlCommerce() { _appsPath = PathUtils::getAppDataPath() + "Apps/"; } -void QmlCommerce::openSystemApp(const QString& appPath) { + + + +void QmlCommerce::openSystemApp(const QString& appName) { + static QMap systemApps { + {"GOTO", "hifi/tablet/TabletAddressDialog.qml"}, + {"PEOPLE", "hifi/Pal.qml"}, + {"WALLET", "hifi/commerce/wallet/Wallet.qml"}, + {"MARKET", "/marketplace.html"} + }; + + static QMap systemInject{ + {"MARKET", "/scripts/system/html/js/marketplacesInject.js"} + }; + auto tablet = dynamic_cast( DependencyManager::get()->getTablet("com.highfidelity.interface.tablet.system")); - tablet->loadQMLSource(appPath); + + QMap::const_iterator appPathIter = systemApps.find(appName); + if (appPathIter != systemApps.end()) { + if (appPathIter->contains(".qml", Qt::CaseInsensitive)) { + tablet->loadQMLSource(*appPathIter); + } + else if (appPathIter->contains(".html", Qt::CaseInsensitive)) { + QMap::const_iterator injectIter = systemInject.find(appName); + if (appPathIter == systemInject.end()) { + tablet->gotoWebScreen(NetworkingConstants::METAVERSE_SERVER_URL().toString() + *appPathIter); + } + else { + QString inject = "file:///" + qApp->applicationDirPath() + *injectIter; + tablet->gotoWebScreen(NetworkingConstants::METAVERSE_SERVER_URL().toString() + *appPathIter, inject); + } + } + else { + qCDebug(commerce) << "Attempted to open unknown type of URL!"; + return; + } + } + else { + qCDebug(commerce) << "Attempted to open unknown APP!"; + return; + } DependencyManager::get()->openTablet(); } diff --git a/scripts/modules/appUi.js b/scripts/modules/appUi.js index dab377911b..0e7461c5f1 100644 --- a/scripts/modules/appUi.js +++ b/scripts/modules/appUi.js @@ -324,5 +324,11 @@ function AppUi(properties) { that.button.clicked.connect(that.onClicked); Script.scriptEnding.connect(that.onScriptEnding); GlobalServices.findableByChanged.connect(availabilityChanged); + if (that.buttonName == Settings.getValue("startUpApp")) { + Settings.setValue("startUpApp", ""); + Script.setTimeout(function () { + that.open(); + }, 1000); + } } module.exports = AppUi; diff --git a/server-console/src/main.js b/server-console/src/main.js index 1a71e9b1d3..16bc74a286 100644 --- a/server-console/src/main.js +++ b/server-console/src/main.js @@ -392,8 +392,8 @@ var labels = { label: 'Version - ' + buildInfo.buildIdentifier, enabled: false }, - enableNotifications: { - label: 'Enable Notifications', + showNotifications: { + label: 'Show Notifications', type: 'checkbox', checked: true, click: function() { @@ -402,9 +402,9 @@ var labels = { } }, goto: { - label: 'Goto', + label: 'GoTo', click: function() { - StartInterface("hifiapp:hifi/tablet/TabletAddressDialog.qml"); + StartInterface("hifiapp:GOTO"); pendingNotifications[HifiNotificationType.GOTO] = false; updateTrayMenu(homeServer ? homeServer.state : ProcessGroupStates.STOPPED); } @@ -412,7 +412,7 @@ var labels = { people: { label: 'People', click: function() { - StartInterface("hifiapp:hifi/Pal.qml"); + StartInterface("hifiapp:PEOPLE"); pendingNotifications[HifiNotificationType.PEOPLE] = false; updateTrayMenu(homeServer ? homeServer.state : ProcessGroupStates.STOPPED); } @@ -420,7 +420,7 @@ var labels = { wallet: { label: 'Wallet', click: function() { - StartInterface("hifiapp:hifi/commerce/wallet/Wallet.qml"); + StartInterface("hifiapp:WALLET"); pendingNotifications[HifiNotificationType.WALLET] = false; updateTrayMenu(homeServer ? homeServer.state : ProcessGroupStates.STOPPED); } @@ -428,7 +428,7 @@ var labels = { marketplace: { label: 'Market', click: function() { - StartInterface("hifiapp:hifi/commerce/purchases/Purchases.qml"); + StartInterface("hifiapp:MARKET"); pendingNotifications[HifiNotificationType.MARKETPLACE] = false; updateTrayMenu(homeServer ? homeServer.state : ProcessGroupStates.STOPPED); } @@ -502,14 +502,6 @@ function buildMenuArray(serverState) { menuArray.push(labels.version); menuArray.push(separator); } - if(isInterfaceInstalled()) { - menuArray.push(labels.enableNotifications); - menuArray.push(labels.goto); - menuArray.push(labels.people); - menuArray.push(labels.wallet); - menuArray.push(labels.marketplace); - menuArray.push(separator); - } if(isServerInstalled() && isInterfaceInstalled()) { menuArray.push(labels.goHome); menuArray.push(separator); @@ -523,10 +515,18 @@ function buildMenuArray(serverState) { } menuArray.push(labels.share); menuArray.push(separator); + if(isInterfaceInstalled()) { + menuArray.push(labels.goto); + menuArray.push(labels.people); + menuArray.push(labels.wallet); + menuArray.push(labels.marketplace); + menuArray.push(separator); + menuArray.push(labels.showNotifications); + menuArray.push(separator); + } menuArray.push(labels.quit); } - return menuArray; } @@ -551,7 +551,7 @@ function updateLabels(serverState) { labels.restart.enabled = false; } - labels.enableNotifications.checked = trayNotifications.enabled(); + labels.showNotifications.checked = trayNotifications.enabled(); labels.people.visible = trayNotifications.enabled(); labels.goto.visible = trayNotifications.enabled(); labels.wallet.visible = trayNotifications.enabled(); diff --git a/server-console/src/modules/hf-notifications.js b/server-console/src/modules/hf-notifications.js index 8fb262e9f0..bfa65f3ae2 100644 --- a/server-console/src/modules/hf-notifications.js +++ b/server-console/src/modules/hf-notifications.js @@ -33,7 +33,7 @@ const NotificationType = { MARKETPLACE: 'marketplace' }; -function HifiNotification(notificationType, notificationData) { +function HifiNotification(notificationType, notificationData, menuNotificationCallback) { this.type = notificationType; this.data = notificationData; } @@ -54,7 +54,7 @@ HifiNotification.prototype = { text = "You have " + this.data + " event invitations pending." } message = "Click to open GOTO."; - url="hifiapp:hifi/tablet/TabletAddressDialog.qml" + url="hifiapp:GOTO" } else { text = this.data.username + " " + this.data.action_string + " in " + this.data.place_name + "."; @@ -72,7 +72,7 @@ HifiNotification.prototype = { text = this.data + " of your connections are online." } message = "Click to open PEOPLE."; - url="hifiapp:hifi/Pal.qml" + url="hifiapp:PEOPLE" } else { text = this.data.username + " is available in " + this.data.location.root.name + "."; @@ -95,7 +95,7 @@ HifiNotification.prototype = { } text = this.data.message.replace(/<\/?[^>]+(>|$)/g, ""); message = "Click to open WALLET."; - url = "hifiapp:hifi/commerce/wallet/Wallet.qml"; + url = "hifiapp:WALLET"; break; case NotificationType.MARKETPLACE: @@ -111,7 +111,7 @@ HifiNotification.prototype = { text = "Update available for " + this.data.base_item_title + "."; } message = "Click to open MARKET."; - url = "hifiapp:hifi/commerce/purchases/Purchases.qml"; + url = "hifiapp:MARKET"; break; } notifier.notify({ @@ -136,8 +136,11 @@ function HifiNotifications(config, menuNotificationCallback) { this.marketplaceSince = new Date(this.config.get("marketplaceNotifySince", "1970-01-01T00:00:00.000Z")); this.enable(this.enabled()); + + var _menuNotificationCallback = menuNotificationCallback; notifier.on('click', function(notifierObject, options) { StartInterface(options.url); + _menuNotificationCallback(options.notificationType, false); }); } @@ -175,8 +178,8 @@ HifiNotifications.prototype = { MARKETPLACE_NOTIFICATION_POLL_TIME_MS); } else { - if(this.storiesTimer) { - clearInterval(this.storiesTimer); + if(this.storiesPollTimer) { + clearInterval(this.storiesPollTimer); } if(this.peoplePollTimer) { clearInterval(this.peoplePollTimer); @@ -205,13 +208,11 @@ HifiNotifications.prototype = { console.log("Error: unable to get " + url); return false; } - console.log(data.body); var content = JSON.parse(data.body); if(!content || content.status != 'success') { console.log("Error: unable to get " + url); return false; } - console.log(content); if(!content.total_entries) { this.menuNotificationCallback(notifyType, false); } @@ -298,7 +299,7 @@ HifiNotifications.prototype = { var url = METAVERSE_SERVER_URL + STORIES_URL + '?' + options.join('&'); console.log(url); - _this._pollCommon(NotificationType.STORIES, + _this._pollCommon(NotificationType.GOTO, url, since, function (success, token) { @@ -425,6 +426,7 @@ HifiNotifications.prototype = { 'page=1', 'per_page=1' ]; + var url = METAVERSE_SERVER_URL + UPDATES_URL + '?' + options.join('&'); request.get({ uri: url, 'auth': {