From 10d92237adca8bffc82c887dbd37b988602b2d59 Mon Sep 17 00:00:00 2001 From: Leslie Linden Date: Thu, 15 Sep 2011 16:39:46 -0700 Subject: * Re-enabling outbox --- indra/newview/llinventorybridge.cpp | 2 +- indra/newview/llsidepanelinventory.cpp | 2 +- indra/newview/llviewermedia.cpp | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) (limited to 'indra/newview') diff --git a/indra/newview/llinventorybridge.cpp b/indra/newview/llinventorybridge.cpp index a36aa3dedf..5482b07ce5 100644 --- a/indra/newview/llinventorybridge.cpp +++ b/indra/newview/llinventorybridge.cpp @@ -71,7 +71,7 @@ #include "llwearablelist.h" // Marketplace outbox current disabled -#define ENABLE_MERCHANT_OUTBOX_CONTEXT_MENU 0 // keep in sync with ENABLE_INVENTORY_DISPLAY_OUTBOX, ENABLE_MERCHANT_OUTBOX_PANEL +#define ENABLE_MERCHANT_OUTBOX_CONTEXT_MENU 1 // keep in sync with ENABLE_INVENTORY_DISPLAY_OUTBOX, ENABLE_MERCHANT_OUTBOX_PANEL typedef std::pair two_uuids_t; typedef std::list two_uuids_list_t; diff --git a/indra/newview/llsidepanelinventory.cpp b/indra/newview/llsidepanelinventory.cpp index bd62b5c101..ec1de4af21 100644 --- a/indra/newview/llsidepanelinventory.cpp +++ b/indra/newview/llsidepanelinventory.cpp @@ -68,7 +68,7 @@ static LLRegisterPanelClassWrapper t_inventory("sidepanel_ #define AUTO_EXPAND_INBOX 0 // Temporarily disabling the outbox until we straighten out the API -#define ENABLE_MERCHANT_OUTBOX_PANEL 0 // keep in sync with ENABLE_INVENTORY_DISPLAY_OUTBOX, ENABLE_MERCHANT_OUTBOX_CONTEXT_MENU +#define ENABLE_MERCHANT_OUTBOX_PANEL 1 // keep in sync with ENABLE_INVENTORY_DISPLAY_OUTBOX, ENABLE_MERCHANT_OUTBOX_CONTEXT_MENU static const char * const INBOX_BUTTON_NAME = "inbox_btn"; static const char * const OUTBOX_BUTTON_NAME = "outbox_btn"; diff --git a/indra/newview/llviewermedia.cpp b/indra/newview/llviewermedia.cpp index 13dbc5e386..e7f05dcaa3 100644 --- a/indra/newview/llviewermedia.cpp +++ b/indra/newview/llviewermedia.cpp @@ -1368,7 +1368,7 @@ void LLViewerMedia::removeCookie(const std::string &name, const std::string &dom // This is defined in two files but I don't want to create a dependence between this and llsidepanelinventory // just to be able to temporarily disable the outbox. -#define ENABLE_INVENTORY_DISPLAY_OUTBOX 0 // keep in sync with ENABLE_MERCHANT_OUTBOX_PANEL, ENABLE_MERCHANT_OUTBOX_CONTEXT_MENU +#define ENABLE_INVENTORY_DISPLAY_OUTBOX 1 // keep in sync with ENABLE_MERCHANT_OUTBOX_PANEL, ENABLE_MERCHANT_OUTBOX_CONTEXT_MENU class LLInventoryUserStatusResponder : public LLHTTPClient::Responder { -- cgit v1.2.3 From 5af39ea28be1a76ec0c3042a0bf34e7d64835c18 Mon Sep 17 00:00:00 2001 From: Leslie Linden Date: Fri, 16 Sep 2011 11:46:37 -0700 Subject: EXP-1169 FIX -- No synch error icon given on Outbox on Agni where API does not exist * Moved marketplace URL related functions into a new file llmarketplacefunctions.cpp/h. This will the future home of more marketplace-related functions. * Disabled sync button when the marketplace API is unavailable. --- indra/newview/CMakeLists.txt | 2 + indra/newview/llmarketplacefunctions.cpp | 80 +++++++++++++++++++++++++++++ indra/newview/llmarketplacefunctions.h | 42 ++++++++++++++++ indra/newview/llpanelmarketplaceoutbox.cpp | 22 ++------ indra/newview/llviewermedia.cpp | 81 +++++++++++++----------------- 5 files changed, 165 insertions(+), 62 deletions(-) create mode 100644 indra/newview/llmarketplacefunctions.cpp create mode 100644 indra/newview/llmarketplacefunctions.h (limited to 'indra/newview') diff --git a/indra/newview/CMakeLists.txt b/indra/newview/CMakeLists.txt index 11b19ca4fe..8c1f98979b 100644 --- a/indra/newview/CMakeLists.txt +++ b/indra/newview/CMakeLists.txt @@ -310,6 +310,7 @@ set(viewer_SOURCE_FILES llmaniprotate.cpp llmanipscale.cpp llmaniptranslate.cpp + llmarketplacefunctions.cpp llmediactrl.cpp llmediadataclient.cpp llmemoryview.cpp @@ -873,6 +874,7 @@ set(viewer_HEADER_FILES llmaniprotate.h llmanipscale.h llmaniptranslate.h + llmarketplacefunctions.h llmediactrl.h llmediadataclient.h llmemoryview.h diff --git a/indra/newview/llmarketplacefunctions.cpp b/indra/newview/llmarketplacefunctions.cpp new file mode 100644 index 0000000000..599731a641 --- /dev/null +++ b/indra/newview/llmarketplacefunctions.cpp @@ -0,0 +1,80 @@ +/** + * @file llmarketplacefunctions.cpp + * @brief Implementation of assorted functions related to the marketplace + * + * $LicenseInfo:firstyear=2001&license=viewerlgpl$ + * Second Life Viewer Source Code + * Copyright (C) 2010, Linden Research, Inc. + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; + * version 2.1 of the License only. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * + * Linden Research, Inc., 945 Battery Street, San Francisco, CA 94111 USA + * $/LicenseInfo$ + */ + +#include "llviewerprecompiledheaders.h" + +#include "llmarketplacefunctions.h" + +#include "llagent.h" +#include "llviewernetwork.h" + + +std::string getMarketplaceBaseURL() +{ + std::string url = "https://marketplace.secondlife.com/"; + + if (!LLGridManager::getInstance()->isInProductionGrid()) + { + std::string gridLabel = LLGridManager::getInstance()->getGridLabel(); + url = llformat("https://marketplace.%s.lindenlab.com/", utf8str_tolower(gridLabel).c_str()); + } + + url += "api/1/users/"; + url += gAgent.getID().getString(); + + return url; +} + +std::string getMarketplaceURL_InventoryImport() +{ + std::string url = getMarketplaceBaseURL(); + + url += "/inventory_import"; + + return url; +} + +std::string getMarketplaceURL_UserStatus() +{ + std::string url = getMarketplaceBaseURL(); + + url += "/user_status"; + + return url; +} + + +static bool gMarketplaceSyncEnabled = false; + +bool getMarketplaceSyncEnabled() +{ + return gMarketplaceSyncEnabled; +} + +void setMarketplaceSyncEnabled(bool syncEnabled) +{ + gMarketplaceSyncEnabled = syncEnabled; +} diff --git a/indra/newview/llmarketplacefunctions.h b/indra/newview/llmarketplacefunctions.h new file mode 100644 index 0000000000..e80e6a471c --- /dev/null +++ b/indra/newview/llmarketplacefunctions.h @@ -0,0 +1,42 @@ +/** + * @file llmarketplacefunctions.h + * @brief Miscellaneous marketplace-related functions and classes + * class definition + * + * $LicenseInfo:firstyear=2001&license=viewerlgpl$ + * Second Life Viewer Source Code + * Copyright (C) 2011, Linden Research, Inc. + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; + * version 2.1 of the License only. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * + * Linden Research, Inc., 945 Battery Street, San Francisco, CA 94111 USA + * $/LicenseInfo$ + */ + +#ifndef LL_LLMARKETPLACEFUNCTIONS_H +#define LL_LLMARKETPLACEFUNCTIONS_H + + +std::string getMarketplaceURL_InventoryImport(); +std::string getMarketplaceURL_UserStatus(); + +bool getMarketplaceSyncEnabled(); +void setMarketplaceSyncEnabled(bool syncEnabled); + + +#endif // LL_LLMARKETPLACEFUNCTIONS_H + + + diff --git a/indra/newview/llpanelmarketplaceoutbox.cpp b/indra/newview/llpanelmarketplaceoutbox.cpp index 73fb92ff72..2764527c44 100644 --- a/indra/newview/llpanelmarketplaceoutbox.cpp +++ b/indra/newview/llpanelmarketplaceoutbox.cpp @@ -35,6 +35,7 @@ #include "lleventcoro.h" #include "llinventorypanel.h" #include "llloadingindicator.h" +#include "llmarketplacefunctions.h" #include "llnotificationsutil.h" #include "llpanelmarketplaceinbox.h" #include "llsdutil.h" @@ -82,7 +83,7 @@ void LLPanelMarketplaceOutbox::handleLoginComplete() { mSyncButton = getChild("outbox_sync_btn"); mSyncButton->setCommitCallback(boost::bind(&LLPanelMarketplaceOutbox::onSyncButtonClicked, this)); - mSyncButton->setEnabled(!isOutboxEmpty()); + mSyncButton->setEnabled(getMarketplaceSyncEnabled() && !isOutboxEmpty()); mSyncIndicator = getChild("outbox_sync_indicator"); } @@ -223,20 +224,7 @@ void LLPanelMarketplaceOutbox::onSyncButtonClicked() updateSyncButtonStatus(); // Make the url for the inventory import request - std::string url = "https://marketplace.secondlife.com/"; - - if (!LLGridManager::getInstance()->isInProductionGrid()) - { - std::string gridLabel = LLGridManager::getInstance()->getGridLabel(); - url = llformat("https://marketplace.%s.lindenlab.com/", utf8str_tolower(gridLabel).c_str()); - - // TEMP for Jim's pdp - //url = "http://pdp24.lindenlab.com:3000/"; - } - - url += "api/1/users/"; - url += gAgent.getID().getString(); - url += "/inventory_import"; + std::string url = getMarketplaceURL_InventoryImport(); llinfos << "http get: " << url << llendl; LLHTTPClient::get(url, new LLInventorySyncResponder(this), LLViewerMedia::getHeaders()); @@ -311,7 +299,7 @@ void LLPanelMarketplaceOutbox::updateSyncButtonStatus() mSyncIndicator->setVisible(false); mSyncButton->setVisible(true); - mSyncButton->setEnabled(!isOutboxEmpty()); + mSyncButton->setEnabled(getMarketplaceSyncEnabled() && !isOutboxEmpty()); } } @@ -352,7 +340,7 @@ void LLPanelMarketplaceOutbox::draw() if (!isSyncInProgress()) { - mSyncButton->setEnabled(not_empty); + mSyncButton->setEnabled(getMarketplaceSyncEnabled() && not_empty); } LLPanel::draw(); diff --git a/indra/newview/llviewermedia.cpp b/indra/newview/llviewermedia.cpp index e7f05dcaa3..b60881b5f1 100644 --- a/indra/newview/llviewermedia.cpp +++ b/indra/newview/llviewermedia.cpp @@ -26,51 +26,49 @@ #include "llviewerprecompiledheaders.h" +#include "llviewermedia.h" + #include "llagent.h" #include "llagentcamera.h" -#include "llviewermedia.h" -#include "llviewermediafocus.h" -#include "llmimetypes.h" +#include "llappviewer.h" +#include "llaudioengine.h" // for gAudiop +#include "llcallbacklist.h" +#include "lldir.h" +#include "lldiriterator.h" +#include "llevent.h" // LLSimpleListener +#include "llfilepicker.h" +#include "llfloatermediabrowser.h" // for handling window close requests and geometry change requests in media browser windows. +#include "llfloaterwebcontent.h" // for handling window close requests and geometry change requests in media browser windows. +#include "llfocusmgr.h" +#include "llkeyboard.h" +#include "lllogininstance.h" +#include "llmarketplacefunctions.h" #include "llmediaentry.h" +#include "llmimetypes.h" +#include "llmutelist.h" +#include "llnotifications.h" +#include "llnotificationsutil.h" +#include "llpanelprofile.h" +#include "llparcel.h" +#include "llpluginclassmedia.h" +#include "llplugincookiestore.h" +#include "llurldispatcher.h" +#include "lluuid.h" #include "llversioninfo.h" #include "llviewercontrol.h" -#include "llviewertexture.h" +#include "llviewermediafocus.h" #include "llviewerparcelmedia.h" #include "llviewerparcelmgr.h" +#include "llviewerregion.h" +#include "llviewertexture.h" #include "llviewertexturelist.h" -#include "llvovolume.h" -#include "llpluginclassmedia.h" -#include "llplugincookiestore.h" #include "llviewerwindow.h" -#include "llfocusmgr.h" -#include "llcallbacklist.h" -#include "llparcel.h" -#include "llaudioengine.h" // for gAudiop -#include "llurldispatcher.h" #include "llvoavatar.h" #include "llvoavatarself.h" -#include "llviewerregion.h" +#include "llvovolume.h" #include "llwebsharing.h" // For LLWebSharing::setOpenIDCookie(), *TODO: find a better way to do this! -#include "llfilepicker.h" -#include "llnotifications.h" -#include "lldir.h" -#include "lldiriterator.h" -#include "llevent.h" // LLSimpleListener -#include "llnotificationsutil.h" -#include "lluuid.h" -#include "llkeyboard.h" -#include "llmutelist.h" -#include "llpanelprofile.h" -#include "llappviewer.h" -#include "lllogininstance.h" -//#include "llfirstuse.h" -#include "llviewernetwork.h" #include "llwindow.h" - -#include "llfloatermediabrowser.h" // for handling window close requests and geometry change requests in media browser windows. -#include "llfloaterwebcontent.h" // for handling window close requests and geometry change requests in media browser windows. - #include // for SkinFolder listener #include @@ -1394,14 +1392,20 @@ public: #if ENABLE_INVENTORY_DISPLAY_OUTBOX gSavedSettings.setBOOL("InventoryDisplayOutbox", true); #endif + + setMarketplaceSyncEnabled(true); } else if (status == 401) { // API is available for use but OpenID authorization failed gSavedSettings.setBOOL("InventoryDisplayInbox", true); + + setMarketplaceSyncEnabled(false); } else { + setMarketplaceSyncEnabled(false); + // API in unavailable llinfos << "Marketplace API is unavailable -- Inbox may be disabled, status = " << status << ", reason = " << reason << llendl; } @@ -1411,20 +1415,7 @@ public: void doOnetimeEarlyHTTPRequests() { - std::string url = "https://marketplace.secondlife.com/"; - - if (!LLGridManager::getInstance()->isInProductionGrid()) - { - std::string gridLabel = LLGridManager::getInstance()->getGridLabel(); - url = llformat("https://marketplace.%s.lindenlab.com/", utf8str_tolower(gridLabel).c_str()); - - // TEMP for Jim's pdp - //url = "http://pdp24.lindenlab.com:3000/"; - } - - url += "api/1/users/"; - url += gAgent.getID().getString(); - url += "/user_status"; + std::string url = getMarketplaceURL_UserStatus(); llinfos << "http get: " << url << llendl; LLHTTPClient::get(url, new LLInventoryUserStatusResponder(), LLViewerMedia::getHeaders()); -- cgit v1.2.3 From 9740887b90791b3fad37e58ab9e2ac772e8d2e95 Mon Sep 17 00:00:00 2001 From: Leslie Linden Date: Mon, 14 Nov 2011 14:40:58 -0800 Subject: Build fix from bad merge --- indra/newview/llviewermedia.cpp | 29 ++++------------------------- 1 file changed, 4 insertions(+), 25 deletions(-) (limited to 'indra/newview') diff --git a/indra/newview/llviewermedia.cpp b/indra/newview/llviewermedia.cpp index 47aa2d8656..6fc4dd25af 100644 --- a/indra/newview/llviewermedia.cpp +++ b/indra/newview/llviewermedia.cpp @@ -33,37 +33,14 @@ #include "llappviewer.h" #include "llaudioengine.h" // for gAudiop #include "llcallbacklist.h" -#include "llparcel.h" -#include "llaudioengine.h" // for gAudiop -#include "llurldispatcher.h" -#include "llvoavatar.h" -#include "llvoavatarself.h" -#include "llviewerregion.h" -#include "llwebprofile.h" -#include "llwebsharing.h" // For LLWebSharing::setOpenIDCookie(), *TODO: find a better way to do this! -#include "llfilepicker.h" -#include "llnotifications.h" #include "lldir.h" #include "lldiriterator.h" #include "llevent.h" // LLSimpleListener #include "llfilepicker.h" -#include "llfloatermediabrowser.h" // for handling window close requests and geometry change requests in media browser windows. -#include "llnotificationsutil.h" -#include "lluuid.h" -#include "llkeyboard.h" -#include "llmutelist.h" -#include "llpanelprofile.h" -#include "llappviewer.h" -#include "lllogininstance.h" -//#include "llfirstuse.h" -#include "llviewernetwork.h" -#include "llwindow.h" - - #include "llfloaterwebcontent.h" // for handling window close requests and geometry change requests in media browser windows. #include "llfocusmgr.h" #include "llkeyboard.h" -#include "lllogininstance.h" +#include "lllogininstance.h" #include "llmarketplacefunctions.h" #include "llmediaentry.h" #include "llmimetypes.h" @@ -77,8 +54,9 @@ #include "llurldispatcher.h" #include "lluuid.h" #include "llversioninfo.h" -#include "llviewercontrol.h" #include "llviewermediafocus.h" +#include "llviewercontrol.h" +#include "llviewernetwork.h" #include "llviewerparcelmedia.h" #include "llviewerparcelmgr.h" #include "llviewerregion.h" @@ -88,6 +66,7 @@ #include "llvoavatar.h" #include "llvoavatarself.h" #include "llvovolume.h" +#include "llwebprofile.h" #include "llwebsharing.h" // For LLWebSharing::setOpenIDCookie(), *TODO: find a better way to do this! #include "llwindow.h" -- cgit v1.2.3 From c24645f7b51ea27e1686bbe72470a9f3c09fc676 Mon Sep 17 00:00:00 2001 From: Leslie Linden Date: Mon, 14 Nov 2011 14:41:26 -0800 Subject: Updated url for damballah to use secondlife-staging --- indra/newview/llmarketplacefunctions.cpp | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) (limited to 'indra/newview') diff --git a/indra/newview/llmarketplacefunctions.cpp b/indra/newview/llmarketplacefunctions.cpp index 599731a641..99b0389413 100644 --- a/indra/newview/llmarketplacefunctions.cpp +++ b/indra/newview/llmarketplacefunctions.cpp @@ -38,8 +38,16 @@ std::string getMarketplaceBaseURL() if (!LLGridManager::getInstance()->isInProductionGrid()) { - std::string gridLabel = LLGridManager::getInstance()->getGridLabel(); - url = llformat("https://marketplace.%s.lindenlab.com/", utf8str_tolower(gridLabel).c_str()); + std::string gridLabel = utf8str_tolower(LLGridManager::getInstance()->getGridLabel()); + + if (gridLabel == "damballah") + { + url = "https://marketplace.secondlife-staging.com/"; + } + else + { + url = llformat("https://marketplace.%s.lindenlab.com/", gridLabel.c_str()); + } } url += "api/1/users/"; @@ -67,7 +75,7 @@ std::string getMarketplaceURL_UserStatus() } -static bool gMarketplaceSyncEnabled = false; +static bool gMarketplaceSyncEnabled = true; bool getMarketplaceSyncEnabled() { -- cgit v1.2.3 From 570d02dc7e41c3e08477e7f759d632db78690eb4 Mon Sep 17 00:00:00 2001 From: Leslie Linden Date: Tue, 29 Nov 2011 16:57:37 -0800 Subject: Initial merchant outbox button --- indra/newview/CMakeLists.txt | 2 + indra/newview/app_settings/commands.xml | 10 ++ indra/newview/llfloateroutbox.cpp | 68 +++++++++++ indra/newview/llfloateroutbox.h | 56 +++++++++ indra/newview/llviewerfloaterreg.cpp | 2 + indra/newview/skins/default/textures/textures.xml | 1 + .../default/textures/toolbar_icons/outbox.png | Bin 0 -> 2987 bytes .../default/xui/en/floater_merchant_outbox.xml | 134 +++++++++++++++++++++ .../skins/default/xui/en/floater_toybox.xml | 12 +- indra/newview/skins/default/xui/en/strings.xml | 2 + 10 files changed, 281 insertions(+), 6 deletions(-) create mode 100644 indra/newview/llfloateroutbox.cpp create mode 100644 indra/newview/llfloateroutbox.h create mode 100644 indra/newview/skins/default/textures/toolbar_icons/outbox.png create mode 100644 indra/newview/skins/default/xui/en/floater_merchant_outbox.xml (limited to 'indra/newview') diff --git a/indra/newview/CMakeLists.txt b/indra/newview/CMakeLists.txt index 26e6c485f3..83db4548de 100644 --- a/indra/newview/CMakeLists.txt +++ b/indra/newview/CMakeLists.txt @@ -216,6 +216,7 @@ set(viewer_SOURCE_FILES llfloaternotificationsconsole.cpp llfloaterobjectweights.cpp llfloateropenobject.cpp + llfloateroutbox.cpp llfloaterpay.cpp llfloaterperms.cpp llfloaterpostprocess.cpp @@ -789,6 +790,7 @@ set(viewer_HEADER_FILES llfloaternotificationsconsole.h llfloaterobjectweights.h llfloateropenobject.h + llfloateroutbox.h llfloaterpay.h llfloaterperms.h llfloaterpostprocess.h diff --git a/indra/newview/app_settings/commands.xml b/indra/newview/app_settings/commands.xml index a44b895f7b..c12d22adc3 100644 --- a/indra/newview/app_settings/commands.xml +++ b/indra/newview/app_settings/commands.xml @@ -135,6 +135,16 @@ is_running_function="Floater.IsOpen" is_running_parameters="moveview" /> + addControlView(this); +} + +LLFloaterOutbox::~LLFloaterOutbox() +{ + LLTransientFloaterMgr::getInstance()->removeControlView(this); +} + +BOOL LLFloaterOutbox::postBuild() +{ + return TRUE; +} + +void LLFloaterOutbox::onOpen(const LLSD& key) +{ + //LLFirstUse::useInventory(); +} + +void LLFloaterOutbox::onClose(bool app_quitting) +{ + LLFloater::onClose(app_quitting); + if (mKey.asInteger() > 1) + { + destroy(); + } +} diff --git a/indra/newview/llfloateroutbox.h b/indra/newview/llfloateroutbox.h new file mode 100644 index 0000000000..cb5c2be81c --- /dev/null +++ b/indra/newview/llfloateroutbox.h @@ -0,0 +1,56 @@ +/** + * @file llfloateroutbox.h + * @brief LLFloaterOutbox + * class definition + * + * $LicenseInfo:firstyear=2001&license=viewerlgpl$ + * Second Life Viewer Source Code + * Copyright (C) 2010, Linden Research, Inc. + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; + * version 2.1 of the License only. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * ABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * + * Linden Research, Inc., 945 Battery Street, San Francisco, CA 94111 USA + * $/LicenseInfo$ + */ + +#ifndef LL_LLFLOATEROUTBOX_H +#define LL_LLFLOATEROUTBOX_H + +#include "llfloater.h" +#include "llfoldertype.h" + +class LLInventoryPanel; + +//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +// Class LLFloaterOutbox +//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +class LLFloaterOutbox : public LLFloater +{ +public: + LLFloaterOutbox(const LLSD& key); + ~LLFloaterOutbox(); + + BOOL postBuild(); + + // Inherited functionality + /*virtual*/ void onOpen(const LLSD& key); + /*virtual*/ void onClose(bool app_quitting); + +private: + LLInventoryPanel* mPanelOutboxInventory; +}; + +#endif // LL_LLFLOATEROUTBOX_H diff --git a/indra/newview/llviewerfloaterreg.cpp b/indra/newview/llviewerfloaterreg.cpp index acbc5f8fb6..24070018c2 100644 --- a/indra/newview/llviewerfloaterreg.cpp +++ b/indra/newview/llviewerfloaterreg.cpp @@ -82,6 +82,7 @@ #include "llfloaternotificationsconsole.h" #include "llfloaterobjectweights.h" #include "llfloateropenobject.h" +#include "llfloateroutbox.h" #include "llfloaterpay.h" #include "llfloaterperms.h" #include "llfloaterpostprocess.h" @@ -237,6 +238,7 @@ void LLViewerFloaterReg::registerFloaters() LLFloaterReg::add("object_weights", "floater_object_weights.xml", (LLFloaterBuildFunc)&LLFloaterReg::build); LLFloaterReg::add("openobject", "floater_openobject.xml", (LLFloaterBuildFunc)&LLFloaterReg::build); + LLFloaterReg::add("outbox", "floater_merchant_outbox.xml", (LLFloaterBuildFunc)&LLFloaterReg::build); LLFloaterReg::add("outgoing_call", "floater_outgoing_call.xml", (LLFloaterBuildFunc)&LLFloaterReg::build); LLFloaterPayUtil::registerFloater(); diff --git a/indra/newview/skins/default/textures/textures.xml b/indra/newview/skins/default/textures/textures.xml index 8702ebde2a..5da1276881 100644 --- a/indra/newview/skins/default/textures/textures.xml +++ b/indra/newview/skins/default/textures/textures.xml @@ -137,6 +137,7 @@ with the same filename but different name + diff --git a/indra/newview/skins/default/textures/toolbar_icons/outbox.png b/indra/newview/skins/default/textures/toolbar_icons/outbox.png new file mode 100644 index 0000000000..9fcf46794d Binary files /dev/null and b/indra/newview/skins/default/textures/toolbar_icons/outbox.png differ diff --git a/indra/newview/skins/default/xui/en/floater_merchant_outbox.xml b/indra/newview/skins/default/xui/en/floater_merchant_outbox.xml new file mode 100644 index 0000000000..2f8a83c072 --- /dev/null +++ b/indra/newview/skins/default/xui/en/floater_merchant_outbox.xml @@ -0,0 +1,134 @@ + + + + Merchant outbox ([NUM]) + Merchant outbox + @@ -107,7 +107,7 @@ layout="topleft" left="335" name="btn_restore_defaults" - top="285" + top="330" width="130"> diff --git a/indra/newview/skins/default/xui/en/strings.xml b/indra/newview/skins/default/xui/en/strings.xml index befcc5dd87..105c6095e6 100644 --- a/indra/newview/skins/default/xui/en/strings.xml +++ b/indra/newview/skins/default/xui/en/strings.xml @@ -3675,6 +3675,7 @@ Try enclosing path to the editor with double quotes. Marketplace Mini-map Move + Merchant outbox People Picks Places @@ -3700,6 +3701,7 @@ Try enclosing path to the editor with double quotes. Go shopping Show nearby people Moving your avatar + Transfer items to your marketplace for sale Friends, groups, and nearby people Places to show as favorites in your profile Places you've saved -- cgit v1.2.3 From 591891306366e683416b187207fa2b94bdc263a8 Mon Sep 17 00:00:00 2001 From: Leslie Linden Date: Mon, 5 Dec 2011 13:37:37 -0800 Subject: First pass at connecting to the new marketplace API --- indra/newview/llinventorybridge.cpp | 2 +- indra/newview/llmarketplacefunctions.cpp | 24 ++-- indra/newview/llmarketplacefunctions.h | 17 ++- indra/newview/llpanelmarketplaceoutbox.cpp | 158 ++++++++++++++++----- indra/newview/llpanelmarketplaceoutbox.h | 19 ++- indra/newview/llsidepanelinventory.cpp | 2 +- indra/newview/llviewermedia.cpp | 61 -------- .../newview/skins/default/xui/en/notifications.xml | 18 ++- .../skins/default/xui/en/sidepanel_inventory.xml | 4 +- 9 files changed, 170 insertions(+), 135 deletions(-) (limited to 'indra/newview') diff --git a/indra/newview/llinventorybridge.cpp b/indra/newview/llinventorybridge.cpp index 0eaa0a4627..017dabe2ad 100644 --- a/indra/newview/llinventorybridge.cpp +++ b/indra/newview/llinventorybridge.cpp @@ -71,7 +71,7 @@ #include "llwearablelist.h" // Marketplace outbox current disabled -#define ENABLE_MERCHANT_OUTBOX_CONTEXT_MENU 1 // keep in sync with ENABLE_INVENTORY_DISPLAY_OUTBOX, ENABLE_MERCHANT_OUTBOX_PANEL +#define ENABLE_MERCHANT_OUTBOX_CONTEXT_MENU 1 // keep in sync with ENABLE_MERCHANT_OUTBOX_PANEL typedef std::pair two_uuids_t; typedef std::list two_uuids_list_t; diff --git a/indra/newview/llmarketplacefunctions.cpp b/indra/newview/llmarketplacefunctions.cpp index 99b0389413..1c189f6ee2 100644 --- a/indra/newview/llmarketplacefunctions.cpp +++ b/indra/newview/llmarketplacefunctions.cpp @@ -50,8 +50,9 @@ std::string getMarketplaceBaseURL() } } - url += "api/1/users/"; + url += "api/1/"; url += gAgent.getID().getString(); + url += "/inventory"; return url; } @@ -60,29 +61,20 @@ std::string getMarketplaceURL_InventoryImport() { std::string url = getMarketplaceBaseURL(); - url += "/inventory_import"; - - return url; -} - -std::string getMarketplaceURL_UserStatus() -{ - std::string url = getMarketplaceBaseURL(); - - url += "/user_status"; + url += "/import"; return url; } -static bool gMarketplaceSyncEnabled = true; +static bool gMarketplaceImportEnabled = true; -bool getMarketplaceSyncEnabled() +bool getMarketplaceImportEnabled() { - return gMarketplaceSyncEnabled; + return gMarketplaceImportEnabled; } -void setMarketplaceSyncEnabled(bool syncEnabled) +void setMarketplaceImportEnabled(bool importEnabled) { - gMarketplaceSyncEnabled = syncEnabled; + gMarketplaceImportEnabled = importEnabled; } diff --git a/indra/newview/llmarketplacefunctions.h b/indra/newview/llmarketplacefunctions.h index e80e6a471c..fda2fbb935 100644 --- a/indra/newview/llmarketplacefunctions.h +++ b/indra/newview/llmarketplacefunctions.h @@ -30,11 +30,20 @@ std::string getMarketplaceURL_InventoryImport(); -std::string getMarketplaceURL_UserStatus(); - -bool getMarketplaceSyncEnabled(); -void setMarketplaceSyncEnabled(bool syncEnabled); +bool getMarketplaceImportEnabled(); +void setMarketplaceImportEnabled(bool syncEnabled); + +namespace MarketplaceErrorCodes +{ + enum eCodes + { + IMPORT_DONE = 200, + IMPORT_PROCESSING = 202, + IMPORT_DONE_WITH_ERRORS = 409, + IMPORT_JOB_FAILED = 410, + }; +} #endif // LL_LLMARKETPLACEFUNCTIONS_H diff --git a/indra/newview/llpanelmarketplaceoutbox.cpp b/indra/newview/llpanelmarketplaceoutbox.cpp index 0ad4d56051..3c8817c199 100644 --- a/indra/newview/llpanelmarketplaceoutbox.cpp +++ b/indra/newview/llpanelmarketplaceoutbox.cpp @@ -59,9 +59,12 @@ const LLPanelMarketplaceOutbox::Params& LLPanelMarketplaceOutbox::getDefaultPara LLPanelMarketplaceOutbox::LLPanelMarketplaceOutbox(const Params& p) : LLPanel(p) , mInventoryPanel(NULL) - , mSyncButton(NULL) - , mSyncIndicator(NULL) - , mSyncInProgress(false) + , mImportButton(NULL) + , mImportFrameTimer(0) + , mImportGetPending(false) + , mImportIndicator(NULL) + , mImportInProgress(false) + , mOutboxButton(NULL) { } @@ -81,11 +84,13 @@ BOOL LLPanelMarketplaceOutbox::postBuild() void LLPanelMarketplaceOutbox::handleLoginComplete() { - mSyncButton = getChild("outbox_sync_btn"); - mSyncButton->setCommitCallback(boost::bind(&LLPanelMarketplaceOutbox::onSyncButtonClicked, this)); - mSyncButton->setEnabled(getMarketplaceSyncEnabled() && !isOutboxEmpty()); + mImportButton = getChild("outbox_import_btn"); + mImportButton->setCommitCallback(boost::bind(&LLPanelMarketplaceOutbox::onImportButtonClicked, this)); + mImportButton->setEnabled(getMarketplaceImportEnabled() && !isOutboxEmpty()); - mSyncIndicator = getChild("outbox_sync_indicator"); + mImportIndicator = getChild("outbox_import_indicator"); + + mOutboxButton = getChild("outbox_btn"); } void LLPanelMarketplaceOutbox::onFocusReceived() @@ -164,9 +169,9 @@ bool LLPanelMarketplaceOutbox::isOutboxEmpty() const return (getTotalItemCount() == 0); } -bool LLPanelMarketplaceOutbox::isSyncInProgress() const +bool LLPanelMarketplaceOutbox::isImportInProgress() const { - return mSyncInProgress; + return mImportInProgress; } @@ -185,25 +190,55 @@ void timeDelay(LLCoros::self& self, LLPanelMarketplaceOutbox* outboxPanel) waitForEventOn(self, "mainloop"); } - outboxPanel->onSyncComplete(true, LLSD::emptyMap()); + outboxPanel->onImportPostComplete(MarketplaceErrorCodes::IMPORT_DONE, LLSD::emptyMap()); gTimeDelayDebugFunc = ""; } -class LLInventorySyncResponder : public LLHTTPClient::Responder +class LLInventoryImportPostResponder : public LLHTTPClient::Responder { public: - LLInventorySyncResponder(LLPanelMarketplaceOutbox * outboxPanel) + LLInventoryImportPostResponder(LLPanelMarketplaceOutbox * outboxPanel) : LLCurl::Responder() , mOutboxPanel(outboxPanel) { } - + void completed(U32 status, const std::string& reason, const LLSD& content) { - llinfos << "inventory_import complete status: " << status << ", reason: " << reason << llendl; + llinfos << "inventory/import post status: " << status << ", reason: " << reason << llendl; + + if (isGoodStatus(status)) + { + // Complete success + llinfos << "success" << llendl; + } + else + { + llwarns << "failed" << llendl; + } + + mOutboxPanel->onImportPostComplete(status, content); + } + +private: + LLPanelMarketplaceOutbox * mOutboxPanel; +}; +class LLInventoryImportGetResponder : public LLHTTPClient::Responder +{ +public: + LLInventoryImportGetResponder(LLPanelMarketplaceOutbox * outboxPanel) + : LLCurl::Responder() + , mOutboxPanel(outboxPanel) + { + } + + void completed(U32 status, const std::string& reason, const LLSD& content) + { + llinfos << "inventory/import get status: " << status << ", reason: " << reason << llendl; + if (isGoodStatus(status)) { // Complete success @@ -214,37 +249,67 @@ public: llwarns << "failed" << llendl; } - mOutboxPanel->onSyncComplete(isGoodStatus(status), content); + mOutboxPanel->onImportGetComplete(status, content); } private: LLPanelMarketplaceOutbox * mOutboxPanel; }; -void LLPanelMarketplaceOutbox::onSyncButtonClicked() +void LLPanelMarketplaceOutbox::onImportButtonClicked() { - // Get the sync animation going - mSyncInProgress = true; - updateSyncButtonStatus(); + // Get the import animation going + mImportInProgress = true; + mImportFrameTimer = 0; + + updateImportButtonStatus(); // Make the url for the inventory import request std::string url = getMarketplaceURL_InventoryImport(); - llinfos << "http get: " << url << llendl; - LLHTTPClient::get(url, new LLInventorySyncResponder(this), LLViewerMedia::getHeaders()); + llinfos << "http post: " << url << llendl; + LLHTTPClient::post(url, LLSD(), new LLInventoryImportPostResponder(this), LLViewerMedia::getHeaders()); // Set a timer (for testing only) //gTimeDelayDebugFunc = LLCoros::instance().launch("LLPanelMarketplaceOutbox timeDelay", boost::bind(&timeDelay, _1, this)); } -void LLPanelMarketplaceOutbox::onSyncComplete(bool goodStatus, const LLSD& content) +void LLPanelMarketplaceOutbox::onImportPostComplete(U32 status, const LLSD& content) { - mSyncInProgress = false; - updateSyncButtonStatus(); + llinfos << "onImportPostComplete status = " << status << llendl; + llinfos << "onImportPostComplete content = " << content.asString() << llendl; +} + +void LLPanelMarketplaceOutbox::onImportGetComplete(U32 status, const LLSD& content) +{ + mImportGetPending = false; + mImportInProgress = (status == MarketplaceErrorCodes::IMPORT_PROCESSING); + updateImportButtonStatus(); + + if (!mImportInProgress) + { + if (status == MarketplaceErrorCodes::IMPORT_DONE) + { + LLNotificationsUtil::add("OutboxImportComplete", LLSD::emptyMap(), LLSD::emptyMap()); + } + else if (status == MarketplaceErrorCodes::IMPORT_DONE_WITH_ERRORS) + { + LLNotificationsUtil::add("OutboxImportHadErrors", LLSD::emptyMap(), LLSD::emptyMap()); + } + else + { + llassert(status == MarketplaceErrorCodes::IMPORT_JOB_FAILED); + LLNotificationsUtil::add("OutboxImportFailed", LLSD::emptyMap(), LLSD::emptyMap()); + } + } + + return; + + const LLSD& errors_list = content["errors"]; - if (goodStatus && (errors_list.size() == 0)) + if (errors_list.size() == 0) { LLNotificationsUtil::add("OutboxUploadComplete", LLSD::emptyMap(), LLSD::emptyMap()); } @@ -287,23 +352,23 @@ void LLPanelMarketplaceOutbox::onSyncComplete(bool goodStatus, const LLSD& conte } } -void LLPanelMarketplaceOutbox::updateSyncButtonStatus() +void LLPanelMarketplaceOutbox::updateImportButtonStatus() { - if (isSyncInProgress()) + if (isImportInProgress()) { - mSyncButton->setVisible(false); + mImportButton->setVisible(false); - mSyncIndicator->setVisible(true); - mSyncIndicator->reset(); - mSyncIndicator->start(); + mImportIndicator->setVisible(true); + mImportIndicator->reset(); + mImportIndicator->start(); } else { - mSyncIndicator->stop(); - mSyncIndicator->setVisible(false); + mImportIndicator->stop(); + mImportIndicator->setVisible(false); - mSyncButton->setVisible(true); - mSyncButton->setEnabled(getMarketplaceSyncEnabled() && !isOutboxEmpty()); + mImportButton->setVisible(true); + mImportButton->setEnabled(getMarketplaceImportEnabled() && !isOutboxEmpty()); } } @@ -335,17 +400,32 @@ void LLPanelMarketplaceOutbox::draw() LLStringUtil::format_map_t args; args["[NUM]"] = item_count_str; - getChild("outbox_btn")->setLabel(getString("OutboxLabelWithArg", args)); + mOutboxButton->setLabel(getString("OutboxLabelWithArg", args)); } else { - getChild("outbox_btn")->setLabel(getString("OutboxLabelNoArg")); + mOutboxButton->setLabel(getString("OutboxLabelNoArg")); } - if (!isSyncInProgress()) + if (!isImportInProgress()) { - mSyncButton->setEnabled(getMarketplaceSyncEnabled() && not_empty); + mImportButton->setEnabled(getMarketplaceImportEnabled() && not_empty); } + else + { + ++mImportFrameTimer; + + if ((mImportFrameTimer % 50 == 0) && !mImportGetPending) + { + mImportGetPending = true; + + std::string url = getMarketplaceURL_InventoryImport(); + + llinfos << "http get: " << url << llendl; + LLHTTPClient::get(url, new LLInventoryImportGetResponder(this), LLViewerMedia::getHeaders()); + } + } + LLPanel::draw(); } diff --git a/indra/newview/llpanelmarketplaceoutbox.h b/indra/newview/llpanelmarketplaceoutbox.h index c6b4a5abe2..a776ee0919 100644 --- a/indra/newview/llpanelmarketplaceoutbox.h +++ b/indra/newview/llpanelmarketplaceoutbox.h @@ -59,9 +59,10 @@ public: U32 getTotalItemCount() const; bool isOutboxEmpty() const; - bool isSyncInProgress() const; + bool isImportInProgress() const; - void onSyncComplete(bool goodStatus, const LLSD& content); + void onImportPostComplete(U32 status, const LLSD& content); + void onImportGetComplete(U32 status, const LLSD& content); /*virtual*/ BOOL handleDragAndDrop(S32 x, S32 y, MASK mask, BOOL drop, EDragAndDropType cargo_type, @@ -70,8 +71,8 @@ public: std::string& tooltip_msg); protected: - void onSyncButtonClicked(); - void updateSyncButtonStatus(); + void onImportButtonClicked(); + void updateImportButtonStatus(); void handleLoginComplete(); void onFocusReceived(); @@ -80,9 +81,13 @@ protected: private: LLInventoryPanel * mInventoryPanel; - LLButton * mSyncButton; - LLLoadingIndicator * mSyncIndicator; - bool mSyncInProgress; + LLButton * mImportButton; + U32 mImportFrameTimer; + bool mImportGetPending; + LLLoadingIndicator * mImportIndicator; + bool mImportInProgress; + + LLButton * mOutboxButton; }; diff --git a/indra/newview/llsidepanelinventory.cpp b/indra/newview/llsidepanelinventory.cpp index d556b8523e..19a81b93bf 100644 --- a/indra/newview/llsidepanelinventory.cpp +++ b/indra/newview/llsidepanelinventory.cpp @@ -69,7 +69,7 @@ static LLRegisterPanelClassWrapper t_inventory("sidepanel_ #define AUTO_EXPAND_INBOX 0 // Temporarily disabling the outbox until we straighten out the API -#define ENABLE_MERCHANT_OUTBOX_PANEL 1 // keep in sync with ENABLE_INVENTORY_DISPLAY_OUTBOX, ENABLE_MERCHANT_OUTBOX_CONTEXT_MENU +#define ENABLE_MERCHANT_OUTBOX_PANEL 1 // keep in sync with ENABLE_MERCHANT_OUTBOX_CONTEXT_MENU static const char * const INBOX_BUTTON_NAME = "inbox_btn"; static const char * const OUTBOX_BUTTON_NAME = "outbox_btn"; diff --git a/indra/newview/llviewermedia.cpp b/indra/newview/llviewermedia.cpp index a5bd0223cc..02d8036666 100644 --- a/indra/newview/llviewermedia.cpp +++ b/indra/newview/llviewermedia.cpp @@ -1386,64 +1386,6 @@ void LLViewerMedia::removeCookie(const std::string &name, const std::string &dom } -// This is defined in two files but I don't want to create a dependence between this and llsidepanelinventory -// just to be able to temporarily disable the outbox. -#define ENABLE_INVENTORY_DISPLAY_OUTBOX 1 // keep in sync with ENABLE_MERCHANT_OUTBOX_PANEL, ENABLE_MERCHANT_OUTBOX_CONTEXT_MENU - -class LLInventoryUserStatusResponder : public LLHTTPClient::Responder -{ -public: - LLInventoryUserStatusResponder() - : LLCurl::Responder() - { - } - - void completed(U32 status, const std::string& reason, const LLSD& content) - { - if (isGoodStatus(status)) - { - std::string merchantStatus = content[gAgent.getID().getString()].asString(); - llinfos << "Marketplace merchant status: " << merchantStatus << llendl; - - // Save the merchant status before turning on the display - gSavedSettings.setString("InventoryMarketplaceUserStatus", merchantStatus); - - // Complete success - gSavedSettings.setBOOL("InventoryDisplayInbox", true); - -#if ENABLE_INVENTORY_DISPLAY_OUTBOX - gSavedSettings.setBOOL("InventoryDisplayOutbox", true); -#endif - - setMarketplaceSyncEnabled(true); - } - else if (status == 401) - { - // API is available for use but OpenID authorization failed - gSavedSettings.setBOOL("InventoryDisplayInbox", true); - - setMarketplaceSyncEnabled(false); - } - else - { - setMarketplaceSyncEnabled(false); - - // API in unavailable - llinfos << "Marketplace API is unavailable -- Inbox may be disabled, status = " << status << ", reason = " << reason << llendl; - } - } -}; - - -void doOnetimeEarlyHTTPRequests() -{ - std::string url = getMarketplaceURL_UserStatus(); - - llinfos << "http get: " << url << llendl; - LLHTTPClient::get(url, new LLInventoryUserStatusResponder(), LLViewerMedia::getHeaders()); -} - - LLSD LLViewerMedia::getHeaders() { LLSD headers = LLSD::emptyMap(); @@ -1502,9 +1444,6 @@ void LLViewerMedia::setOpenIDCookie() LLHTTPClient::get(profile_url, new LLViewerMediaWebProfileResponder(raw_profile_url.getAuthority()), headers); - - // FUI: No longer perform the user_status query - //doOnetimeEarlyHTTPRequests(); } } diff --git a/indra/newview/skins/default/xui/en/notifications.xml b/indra/newview/skins/default/xui/en/notifications.xml index d925bf8f96..46a6da2450 100644 --- a/indra/newview/skins/default/xui/en/notifications.xml +++ b/indra/newview/skins/default/xui/en/notifications.xml @@ -213,9 +213,9 @@ Save changes to current clothing/body part? -Marketplace upload complete. +Marketplace import complete. @@ -223,14 +223,24 @@ Marketplace upload complete. -Marketplace upload completed with errors! Please correct the problems in your outbox and retry. Thanks. +Marketplace import completed with errors! Please correct the problems in your outbox and retry. Thanks. + +Marketplace import failed! Please try again later. Thanks. + + + Date: Mon, 5 Dec 2011 14:23:49 -0800 Subject: Windows build fix --- indra/newview/llpanelmarketplaceoutbox.cpp | 89 +++++++++++++++--------------- 1 file changed, 43 insertions(+), 46 deletions(-) (limited to 'indra/newview') diff --git a/indra/newview/llpanelmarketplaceoutbox.cpp b/indra/newview/llpanelmarketplaceoutbox.cpp index 3c8817c199..6a2bf58701 100644 --- a/indra/newview/llpanelmarketplaceoutbox.cpp +++ b/indra/newview/llpanelmarketplaceoutbox.cpp @@ -303,53 +303,50 @@ void LLPanelMarketplaceOutbox::onImportGetComplete(U32 status, const LLSD& conte } } - return; - - - - const LLSD& errors_list = content["errors"]; - - if (errors_list.size() == 0) - { - LLNotificationsUtil::add("OutboxUploadComplete", LLSD::emptyMap(), LLSD::emptyMap()); - } - else - { - LLNotificationsUtil::add("OutboxUploadHadErrors", LLSD::emptyMap(), LLSD::emptyMap()); - } - - llinfos << "Marketplace upload llsd:" << llendl; - llinfos << ll_pretty_print_sd(content) << llendl; - llinfos << llendl; - const LLSD& imported_list = content["imported"]; - LLSD::array_const_iterator it = imported_list.beginArray(); - for ( ; it != imported_list.endArray(); ++it) - { - LLUUID imported_folder = (*it).asUUID(); - llinfos << "Successfully uploaded folder " << imported_folder.asString() << " to marketplace." << llendl; - } - - for (it = errors_list.beginArray(); it != errors_list.endArray(); ++it) - { - const LLSD& item_error_map = (*it); - - LLUUID error_folder = item_error_map["folder_id"].asUUID(); - const std::string& error_string = item_error_map["identifier"].asString(); - LLUUID error_item = item_error_map["item_id"].asUUID(); - const std::string& error_item_name = item_error_map["item_name"].asString(); - const std::string& error_message = item_error_map["message"].asString(); - - llinfos << "Error item " << error_folder.asString() << ", " << error_string << ", " - << error_item.asString() << ", " << error_item_name << ", " << error_message << llendl; - - LLFolderViewFolder * item_folder = mInventoryPanel->getRootFolder()->getFolderByID(error_folder); - LLOutboxFolderViewFolder * outbox_item_folder = dynamic_cast(item_folder); - - llassert(outbox_item_folder); - - outbox_item_folder->setErrorString(error_string); - } + //const LLSD& errors_list = content["errors"]; + + //if (errors_list.size() == 0) + //{ + // LLNotificationsUtil::add("OutboxUploadComplete", LLSD::emptyMap(), LLSD::emptyMap()); + //} + //else + //{ + // LLNotificationsUtil::add("OutboxUploadHadErrors", LLSD::emptyMap(), LLSD::emptyMap()); + //} + + //llinfos << "Marketplace upload llsd:" << llendl; + //llinfos << ll_pretty_print_sd(content) << llendl; + //llinfos << llendl; + + //const LLSD& imported_list = content["imported"]; + //LLSD::array_const_iterator it = imported_list.beginArray(); + //for ( ; it != imported_list.endArray(); ++it) + //{ + // LLUUID imported_folder = (*it).asUUID(); + // llinfos << "Successfully uploaded folder " << imported_folder.asString() << " to marketplace." << llendl; + //} + + //for (it = errors_list.beginArray(); it != errors_list.endArray(); ++it) + //{ + // const LLSD& item_error_map = (*it); + + // LLUUID error_folder = item_error_map["folder_id"].asUUID(); + // const std::string& error_string = item_error_map["identifier"].asString(); + // LLUUID error_item = item_error_map["item_id"].asUUID(); + // const std::string& error_item_name = item_error_map["item_name"].asString(); + // const std::string& error_message = item_error_map["message"].asString(); + + // llinfos << "Error item " << error_folder.asString() << ", " << error_string << ", " + // << error_item.asString() << ", " << error_item_name << ", " << error_message << llendl; + // + // LLFolderViewFolder * item_folder = mInventoryPanel->getRootFolder()->getFolderByID(error_folder); + // LLOutboxFolderViewFolder * outbox_item_folder = dynamic_cast(item_folder); + + // llassert(outbox_item_folder); + + // outbox_item_folder->setErrorString(error_string); + //} } void LLPanelMarketplaceOutbox::updateImportButtonStatus() -- cgit v1.2.3 From a255fadfab359931d591c6a874abbea5fcf13526 Mon Sep 17 00:00:00 2001 From: Leslie Linden Date: Tue, 6 Dec 2011 11:19:58 -0800 Subject: Updated to trigger a 'get' to establish marketplace session cookie when outbox panel created. --- indra/newview/llmarketplacefunctions.cpp | 4 +- indra/newview/llpanelmarketplaceoutbox.cpp | 194 +++++++++++++-------- indra/newview/llpanelmarketplaceoutbox.h | 6 +- indra/newview/llviewermedia.cpp | 1 + .../newview/skins/default/xui/en/notifications.xml | 2 +- 5 files changed, 129 insertions(+), 78 deletions(-) (limited to 'indra/newview') diff --git a/indra/newview/llmarketplacefunctions.cpp b/indra/newview/llmarketplacefunctions.cpp index 1c189f6ee2..2f8c5bc9ee 100644 --- a/indra/newview/llmarketplacefunctions.cpp +++ b/indra/newview/llmarketplacefunctions.cpp @@ -52,7 +52,7 @@ std::string getMarketplaceBaseURL() url += "api/1/"; url += gAgent.getID().getString(); - url += "/inventory"; + url += "/inventory/"; return url; } @@ -61,7 +61,7 @@ std::string getMarketplaceURL_InventoryImport() { std::string url = getMarketplaceBaseURL(); - url += "/import"; + url += "import/"; return url; } diff --git a/indra/newview/llpanelmarketplaceoutbox.cpp b/indra/newview/llpanelmarketplaceoutbox.cpp index 6a2bf58701..99d744891a 100644 --- a/indra/newview/llpanelmarketplaceoutbox.cpp +++ b/indra/newview/llpanelmarketplaceoutbox.cpp @@ -140,6 +140,11 @@ LLInventoryPanel * LLPanelMarketplaceOutbox::setupInventoryPanel() // Hide the placeholder text outbox_inventory_placeholder->setVisible(FALSE); + // Establish marketplace cookies for http client + establishMarketplaceSessionCookie(); + + updateImportButtonStatus(); + return mInventoryPanel; } @@ -195,6 +200,28 @@ void timeDelay(LLCoros::self& self, LLPanelMarketplaceOutbox* outboxPanel) gTimeDelayDebugFunc = ""; } +std::string gImportPollingFunc = ""; + +void importPoll(LLCoros::self& self, LLPanelMarketplaceOutbox* outboxPanel) +{ + waitForEventOn(self, "mainloop"); + + while (outboxPanel->isImportInProgress()) + { + LLTimer delayTimer; + delayTimer.reset(); + delayTimer.setTimerExpirySec(5.0f); + + while (!delayTimer.hasExpired()) + { + waitForEventOn(self, "mainloop"); + } + + //outboxPanel-> + } + + gImportPollingFunc = ""; +} class LLInventoryImportPostResponder : public LLHTTPClient::Responder { @@ -207,16 +234,16 @@ public: void completed(U32 status, const std::string& reason, const LLSD& content) { - llinfos << "inventory/import post status: " << status << ", reason: " << reason << llendl; + llinfos << "*** Marketplace *** " << "inventory/import post status: " << status << ", reason: " << reason << llendl; if (isGoodStatus(status)) { // Complete success - llinfos << "success" << llendl; + llinfos << "*** Marketplace *** " << "success" << llendl; } else { - llwarns << "failed" << llendl; + llwarns << "*** Marketplace *** " << "failed" << llendl; } mOutboxPanel->onImportPostComplete(status, content); @@ -229,64 +256,119 @@ private: class LLInventoryImportGetResponder : public LLHTTPClient::Responder { public: - LLInventoryImportGetResponder(LLPanelMarketplaceOutbox * outboxPanel) + LLInventoryImportGetResponder(LLPanelMarketplaceOutbox * outboxPanel, bool ignoreResults) : LLCurl::Responder() + , mIgnoreResults(ignoreResults) , mOutboxPanel(outboxPanel) { } void completed(U32 status, const std::string& reason, const LLSD& content) { - llinfos << "inventory/import get status: " << status << ", reason: " << reason << llendl; + llinfos << "*** Marketplace *** " << "inventory/import get status: " << status << ", reason: " << reason << llendl; if (isGoodStatus(status)) { // Complete success - llinfos << "success" << llendl; + llinfos << "*** Marketplace *** " << "success" << llendl; } else { - llwarns << "failed" << llendl; + llwarns << "*** Marketplace *** " << "failed" << llendl; } - mOutboxPanel->onImportGetComplete(status, content); + mOutboxPanel->onImportGetComplete(status, content, mIgnoreResults); } private: + bool mIgnoreResults; LLPanelMarketplaceOutbox * mOutboxPanel; }; -void LLPanelMarketplaceOutbox::onImportButtonClicked() +void LLPanelMarketplaceOutbox::importPostTrigger() { - // Get the import animation going mImportInProgress = true; mImportFrameTimer = 0; - - updateImportButtonStatus(); - + // Make the url for the inventory import request std::string url = getMarketplaceURL_InventoryImport(); - - llinfos << "http post: " << url << llendl; - LLHTTPClient::post(url, LLSD(), new LLInventoryImportPostResponder(this), LLViewerMedia::getHeaders()); - + + LLSD headers = LLViewerMedia::getHeaders(); + headers["Connection"] = "Keep-Alive"; + + llinfos << "*** Marketplace *** " << "http post: " << url << llendl; + llinfos << "*** Marketplace *** " << "headers: " << ll_pretty_print_sd(headers) << llendl; + + LLHTTPClient::post(url, LLSD(), new LLInventoryImportPostResponder(this), headers); + // Set a timer (for testing only) //gTimeDelayDebugFunc = LLCoros::instance().launch("LLPanelMarketplaceOutbox timeDelay", boost::bind(&timeDelay, _1, this)); } +void LLPanelMarketplaceOutbox::importGetTrigger() +{ + mImportGetPending = true; + + std::string url = getMarketplaceURL_InventoryImport(); + LLSD headers = LLViewerMedia::getHeaders(); + + llinfos << "*** Marketplace *** " << "http get: " << url << llendl; + llinfos << "*** Marketplace *** " << "headers: " << ll_pretty_print_sd(headers) << llendl; + + const bool do_not_ignore_results = false; + + LLHTTPClient::get(url, new LLInventoryImportGetResponder(this, do_not_ignore_results), headers); +} + +void LLPanelMarketplaceOutbox::establishMarketplaceSessionCookie() +{ + mImportInProgress = true; + mImportGetPending = true; + + std::string url = getMarketplaceURL_InventoryImport(); + LLSD headers = LLViewerMedia::getHeaders(); + + const bool ignore_results = true; + + LLHTTPClient::get(url, new LLInventoryImportGetResponder(this, ignore_results), headers); +} + void LLPanelMarketplaceOutbox::onImportPostComplete(U32 status, const LLSD& content) { - llinfos << "onImportPostComplete status = " << status << llendl; - llinfos << "onImportPostComplete content = " << content.asString() << llendl; + llinfos << "*** Marketplace *** " << "status = " << status << llendl; + llinfos << "*** Marketplace *** " << "content = " << ll_pretty_print_sd(content) << llendl; + + mImportInProgress = (status == MarketplaceErrorCodes::IMPORT_DONE); + updateImportButtonStatus(); + + if (!mImportInProgress) + { + char status_string[16]; + sprintf(status_string, "%d", status); + + LLSD subs; + subs["ERROR_CODE"] = status_string; + + LLNotificationsUtil::add("OutboxImportFailed", subs, LLSD::emptyMap()); + } + + // The POST request returns the IMPORT_DONE code on success + //if (status == MarketplaceErrorCodes::IMPORT_DONE) + //{ + // gImportPollingFunc = LLCoros::instance().launch("LLPanelMarketplaceOutbox importPoll", boost::bind(&importPoll, _1, this)); + //} } -void LLPanelMarketplaceOutbox::onImportGetComplete(U32 status, const LLSD& content) +void LLPanelMarketplaceOutbox::onImportGetComplete(U32 status, const LLSD& content, bool ignoreResults) { + llinfos << "*** Marketplace *** " << "status = " << status << llendl; + llinfos << "*** Marketplace *** " << "content = " << ll_pretty_print_sd(content) << llendl; + mImportGetPending = false; mImportInProgress = (status == MarketplaceErrorCodes::IMPORT_PROCESSING); updateImportButtonStatus(); - if (!mImportInProgress) + if (!mImportInProgress && !ignoreResults) { if (status == MarketplaceErrorCodes::IMPORT_DONE) { @@ -298,55 +380,16 @@ void LLPanelMarketplaceOutbox::onImportGetComplete(U32 status, const LLSD& conte } else { - llassert(status == MarketplaceErrorCodes::IMPORT_JOB_FAILED); + char status_string[16]; + sprintf(status_string, "%d", status); + + LLSD subs; + subs["ERROR_CODE"] = status_string; + + //llassert(status == MarketplaceErrorCodes::IMPORT_JOB_FAILED); LLNotificationsUtil::add("OutboxImportFailed", LLSD::emptyMap(), LLSD::emptyMap()); } } - - - //const LLSD& errors_list = content["errors"]; - - //if (errors_list.size() == 0) - //{ - // LLNotificationsUtil::add("OutboxUploadComplete", LLSD::emptyMap(), LLSD::emptyMap()); - //} - //else - //{ - // LLNotificationsUtil::add("OutboxUploadHadErrors", LLSD::emptyMap(), LLSD::emptyMap()); - //} - - //llinfos << "Marketplace upload llsd:" << llendl; - //llinfos << ll_pretty_print_sd(content) << llendl; - //llinfos << llendl; - - //const LLSD& imported_list = content["imported"]; - //LLSD::array_const_iterator it = imported_list.beginArray(); - //for ( ; it != imported_list.endArray(); ++it) - //{ - // LLUUID imported_folder = (*it).asUUID(); - // llinfos << "Successfully uploaded folder " << imported_folder.asString() << " to marketplace." << llendl; - //} - - //for (it = errors_list.beginArray(); it != errors_list.endArray(); ++it) - //{ - // const LLSD& item_error_map = (*it); - - // LLUUID error_folder = item_error_map["folder_id"].asUUID(); - // const std::string& error_string = item_error_map["identifier"].asString(); - // LLUUID error_item = item_error_map["item_id"].asUUID(); - // const std::string& error_item_name = item_error_map["item_name"].asString(); - // const std::string& error_message = item_error_map["message"].asString(); - - // llinfos << "Error item " << error_folder.asString() << ", " << error_string << ", " - // << error_item.asString() << ", " << error_item_name << ", " << error_message << llendl; - // - // LLFolderViewFolder * item_folder = mInventoryPanel->getRootFolder()->getFolderByID(error_folder); - // LLOutboxFolderViewFolder * outbox_item_folder = dynamic_cast(item_folder); - - // llassert(outbox_item_folder); - - // outbox_item_folder->setErrorString(error_string); - //} } void LLPanelMarketplaceOutbox::updateImportButtonStatus() @@ -380,12 +423,21 @@ U32 LLPanelMarketplaceOutbox::getTotalItemCount() const if (outbox_folder) { item_count += outbox_folder->getFoldersCount(); + item_count += outbox_folder->getItemsCount(); } } return item_count; } +void LLPanelMarketplaceOutbox::onImportButtonClicked() +{ + importPostTrigger(); + + // Get the import animation going + updateImportButtonStatus(); +} + void LLPanelMarketplaceOutbox::draw() { const U32 item_count = getTotalItemCount(); @@ -414,15 +466,9 @@ void LLPanelMarketplaceOutbox::draw() if ((mImportFrameTimer % 50 == 0) && !mImportGetPending) { - mImportGetPending = true; - - std::string url = getMarketplaceURL_InventoryImport(); - - llinfos << "http get: " << url << llendl; - LLHTTPClient::get(url, new LLInventoryImportGetResponder(this), LLViewerMedia::getHeaders()); + importGetTrigger(); } } - LLPanel::draw(); } diff --git a/indra/newview/llpanelmarketplaceoutbox.h b/indra/newview/llpanelmarketplaceoutbox.h index a776ee0919..9cbb9cf21b 100644 --- a/indra/newview/llpanelmarketplaceoutbox.h +++ b/indra/newview/llpanelmarketplaceoutbox.h @@ -62,7 +62,7 @@ public: bool isImportInProgress() const; void onImportPostComplete(U32 status, const LLSD& content); - void onImportGetComplete(U32 status, const LLSD& content); + void onImportGetComplete(U32 status, const LLSD& content, bool ignoreResults); /*virtual*/ BOOL handleDragAndDrop(S32 x, S32 y, MASK mask, BOOL drop, EDragAndDropType cargo_type, @@ -77,6 +77,10 @@ protected: void handleLoginComplete(); void onFocusReceived(); void onSelectionChange(); + + void importPostTrigger(); + void importGetTrigger(); + void establishMarketplaceSessionCookie(); private: LLInventoryPanel * mInventoryPanel; diff --git a/indra/newview/llviewermedia.cpp b/indra/newview/llviewermedia.cpp index 02d8036666..eb7a4aa538 100644 --- a/indra/newview/llviewermedia.cpp +++ b/indra/newview/llviewermedia.cpp @@ -1390,6 +1390,7 @@ LLSD LLViewerMedia::getHeaders() { LLSD headers = LLSD::emptyMap(); headers["Accept"] = "*/*"; + headers["Content-Type"] = "application/xml"; headers["Cookie"] = sOpenIDCookie; headers["User-Agent"] = getCurrentUserAgent(); diff --git a/indra/newview/skins/default/xui/en/notifications.xml b/indra/newview/skins/default/xui/en/notifications.xml index 46a6da2450..8d0d76b58e 100644 --- a/indra/newview/skins/default/xui/en/notifications.xml +++ b/indra/newview/skins/default/xui/en/notifications.xml @@ -235,7 +235,7 @@ Marketplace import completed with errors! Please correct the problems in your o icon="alertmodal.tga" name="OutboxImportFailed" type="alertmodal"> -Marketplace import failed! Please try again later. Thanks. +Marketplace import failed with error [ERROR_CODE]! Please try again later. Thanks. -- cgit v1.2.3 From 40f9de414fbd5755b7c040f786030157cf083771 Mon Sep 17 00:00:00 2001 From: Leslie Linden Date: Tue, 6 Dec 2011 11:45:21 -0800 Subject: Added code to set up the marketplace session cookie and use it for subsequent posts and gets to the inventory import API --- indra/newview/llpanelmarketplaceoutbox.cpp | 13 +++++++++++++ 1 file changed, 13 insertions(+) (limited to 'indra/newview') diff --git a/indra/newview/llpanelmarketplaceoutbox.cpp b/indra/newview/llpanelmarketplaceoutbox.cpp index 99d744891a..d4b0bead4c 100644 --- a/indra/newview/llpanelmarketplaceoutbox.cpp +++ b/indra/newview/llpanelmarketplaceoutbox.cpp @@ -50,6 +50,8 @@ static LLRegisterPanelClassWrapper t_panel_marketplace_outbox("panel_marketplace_outbox"); +static std::string sMarketplaceCookie; + const LLPanelMarketplaceOutbox::Params& LLPanelMarketplaceOutbox::getDefaultParams() { return LLUICtrlFactory::getDefaultParams(); @@ -263,6 +265,15 @@ public: { } + void completedHeader(U32 status, const std::string& reason, const LLSD& content) + { + std::string cookie = content["set-cookie"].asString(); + + llinfos << "*** Marketplace *** " << "inventory/import headers set-cookie: " << cookie << llendl; + + sMarketplaceCookie = cookie; + } + void completed(U32 status, const std::string& reason, const LLSD& content) { llinfos << "*** Marketplace *** " << "inventory/import get status: " << status << ", reason: " << reason << llendl; @@ -295,6 +306,7 @@ void LLPanelMarketplaceOutbox::importPostTrigger() LLSD headers = LLViewerMedia::getHeaders(); headers["Connection"] = "Keep-Alive"; + headers["Cookie"] = sMarketplaceCookie; llinfos << "*** Marketplace *** " << "http post: " << url << llendl; llinfos << "*** Marketplace *** " << "headers: " << ll_pretty_print_sd(headers) << llendl; @@ -311,6 +323,7 @@ void LLPanelMarketplaceOutbox::importGetTrigger() std::string url = getMarketplaceURL_InventoryImport(); LLSD headers = LLViewerMedia::getHeaders(); + headers["Cookie"] = sMarketplaceCookie; llinfos << "*** Marketplace *** " << "http get: " << url << llendl; llinfos << "*** Marketplace *** " << "headers: " << ll_pretty_print_sd(headers) << llendl; -- cgit v1.2.3 From 83cc0becf859275a810da4ce0ccb0d7f8147d614 Mon Sep 17 00:00:00 2001 From: Leslie Linden Date: Tue, 6 Dec 2011 11:51:09 -0800 Subject: Turning off marketplace logging verbosity by default --- indra/newview/llpanelmarketplaceoutbox.cpp | 21 ++++++++++++++++++++- 1 file changed, 20 insertions(+), 1 deletion(-) (limited to 'indra/newview') diff --git a/indra/newview/llpanelmarketplaceoutbox.cpp b/indra/newview/llpanelmarketplaceoutbox.cpp index d4b0bead4c..d7e4ed8bec 100644 --- a/indra/newview/llpanelmarketplaceoutbox.cpp +++ b/indra/newview/llpanelmarketplaceoutbox.cpp @@ -48,9 +48,14 @@ #include "llfolderview.h" #include "llinventoryfunctions.h" + +// Turn this on to get a bunch of console output for marketplace API calls, headers and status +#define DEBUG_MARKETPLACE_HTTP_API 0 + + static LLRegisterPanelClassWrapper t_panel_marketplace_outbox("panel_marketplace_outbox"); -static std::string sMarketplaceCookie; +static std::string sMarketplaceCookie = ""; const LLPanelMarketplaceOutbox::Params& LLPanelMarketplaceOutbox::getDefaultParams() { @@ -236,6 +241,7 @@ public: void completed(U32 status, const std::string& reason, const LLSD& content) { +#if DEBUG_MARKETPLACE_HTTP_API llinfos << "*** Marketplace *** " << "inventory/import post status: " << status << ", reason: " << reason << llendl; if (isGoodStatus(status)) @@ -247,6 +253,7 @@ public: { llwarns << "*** Marketplace *** " << "failed" << llendl; } +#endif // DEBUG_MARKETPLACE_HTTP_API mOutboxPanel->onImportPostComplete(status, content); } @@ -269,13 +276,16 @@ public: { std::string cookie = content["set-cookie"].asString(); +#if DEBUG_MARKETPLACE_HTTP_API llinfos << "*** Marketplace *** " << "inventory/import headers set-cookie: " << cookie << llendl; +#endif // DEBUG_MARKETPLACE_HTTP_API sMarketplaceCookie = cookie; } void completed(U32 status, const std::string& reason, const LLSD& content) { +#if DEBUG_MARKETPLACE_HTTP_API llinfos << "*** Marketplace *** " << "inventory/import get status: " << status << ", reason: " << reason << llendl; if (isGoodStatus(status)) @@ -287,6 +297,7 @@ public: { llwarns << "*** Marketplace *** " << "failed" << llendl; } +#endif // DEBUG_MARKETPLACE_HTTP_API mOutboxPanel->onImportGetComplete(status, content, mIgnoreResults); } @@ -308,8 +319,10 @@ void LLPanelMarketplaceOutbox::importPostTrigger() headers["Connection"] = "Keep-Alive"; headers["Cookie"] = sMarketplaceCookie; +#if DEBUG_MARKETPLACE_HTTP_API llinfos << "*** Marketplace *** " << "http post: " << url << llendl; llinfos << "*** Marketplace *** " << "headers: " << ll_pretty_print_sd(headers) << llendl; +#endif // DEBUG_MARKETPLACE_HTTP_API LLHTTPClient::post(url, LLSD(), new LLInventoryImportPostResponder(this), headers); @@ -325,8 +338,10 @@ void LLPanelMarketplaceOutbox::importGetTrigger() LLSD headers = LLViewerMedia::getHeaders(); headers["Cookie"] = sMarketplaceCookie; +#if DEBUG_MARKETPLACE_HTTP_API llinfos << "*** Marketplace *** " << "http get: " << url << llendl; llinfos << "*** Marketplace *** " << "headers: " << ll_pretty_print_sd(headers) << llendl; +#endif // DEBUG_MARKETPLACE_HTTP_API const bool do_not_ignore_results = false; @@ -348,8 +363,10 @@ void LLPanelMarketplaceOutbox::establishMarketplaceSessionCookie() void LLPanelMarketplaceOutbox::onImportPostComplete(U32 status, const LLSD& content) { +#if DEBUG_MARKETPLACE_HTTP_API llinfos << "*** Marketplace *** " << "status = " << status << llendl; llinfos << "*** Marketplace *** " << "content = " << ll_pretty_print_sd(content) << llendl; +#endif // DEBUG_MARKETPLACE_HTTP_API mImportInProgress = (status == MarketplaceErrorCodes::IMPORT_DONE); updateImportButtonStatus(); @@ -374,8 +391,10 @@ void LLPanelMarketplaceOutbox::onImportPostComplete(U32 status, const LLSD& cont void LLPanelMarketplaceOutbox::onImportGetComplete(U32 status, const LLSD& content, bool ignoreResults) { +#if DEBUG_MARKETPLACE_HTTP_API llinfos << "*** Marketplace *** " << "status = " << status << llendl; llinfos << "*** Marketplace *** " << "content = " << ll_pretty_print_sd(content) << llendl; +#endif // DEBUG_MARKETPLACE_HTTP_API mImportGetPending = false; mImportInProgress = (status == MarketplaceErrorCodes::IMPORT_PROCESSING); -- cgit v1.2.3 From 35020db3a9310742c9759673e3aa1bbb1d7aa02f Mon Sep 17 00:00:00 2001 From: Leslie Linden Date: Wed, 7 Dec 2011 15:04:39 -0800 Subject: Refactored marketplace inventory import HTTP requests and surrounding support to remove it from the UI panel code. --- indra/newview/llappviewer.cpp | 4 + indra/newview/llmarketplacefunctions.cpp | 302 ++++++++++++++++++++++++++-- indra/newview/llmarketplacefunctions.h | 43 +++- indra/newview/llpanelmarketplaceoutbox.cpp | 304 ++++------------------------- indra/newview/llpanelmarketplaceoutbox.h | 14 +- 5 files changed, 362 insertions(+), 305 deletions(-) (limited to 'indra/newview') diff --git a/indra/newview/llappviewer.cpp b/indra/newview/llappviewer.cpp index cbaddd74c4..401e9ef600 100644 --- a/indra/newview/llappviewer.cpp +++ b/indra/newview/llappviewer.cpp @@ -45,6 +45,7 @@ #include "llwindow.h" #include "llviewerstats.h" #include "llviewerstatsrecorder.h" +#include "llmarketplacefunctions.h" #include "llmd5.h" #include "llmeshrepository.h" #include "llpumpio.h" @@ -4393,6 +4394,9 @@ void LLAppViewer::idle() // update media focus LLViewerMediaFocus::getInstance()->update(); + + // Update marketplace importer + LLMarketplaceInventoryImporter::update(); // objects and camera should be in sync, do LOD calculations now { diff --git a/indra/newview/llmarketplacefunctions.cpp b/indra/newview/llmarketplacefunctions.cpp index 2f8c5bc9ee..b9e02a36b4 100644 --- a/indra/newview/llmarketplacefunctions.cpp +++ b/indra/newview/llmarketplacefunctions.cpp @@ -29,52 +29,312 @@ #include "llmarketplacefunctions.h" #include "llagent.h" +#include "llhttpclient.h" +#include "llviewermedia.h" #include "llviewernetwork.h" -std::string getMarketplaceBaseURL() +// +// Helpers +// + +namespace LLMarketplaceImport { - std::string url = "https://marketplace.secondlife.com/"; + // Basic interface for this namespace + + bool inProgress(); + bool resultPending(); + U32 getResultStatus(); + const LLSD& getResults(); + + void establishMarketplaceSessionCookie(); + void pollStatus(); + void triggerImport(); + + // Internal state variables + + static std::string sMarketplaceCookie = ""; + static bool sImportInProgress = false; + static bool sImportGetPending = false; + static U32 sImportResultStatus = 0; + static LLSD sImportResults = LLSD::emptyMap(); + + + // Internal helper functions + + std::string getBaseURL() + { + std::string url = "https://marketplace.secondlife.com/"; + + if (!LLGridManager::getInstance()->isInProductionGrid()) + { + std::string gridLabel = utf8str_tolower(LLGridManager::getInstance()->getGridLabel()); + + if (gridLabel == "damballah") + { + url = "https://marketplace.secondlife-staging.com/"; + } + else + { + url = llformat("https://marketplace.%s.lindenlab.com/", gridLabel.c_str()); + } + } + + url += "api/1/"; + url += gAgent.getID().getString(); + url += "/inventory/"; + + return url; + } + + std::string getInventoryImportURL() + { + std::string url = getBaseURL(); - if (!LLGridManager::getInstance()->isInProductionGrid()) + url += "import/"; + + return url; + } + + // Responders + + class LLImportPostResponder : public LLHTTPClient::Responder + { + public: + LLImportPostResponder() : LLCurl::Responder() {} + + void completed(U32 status, const std::string& reason, const LLSD& content) + { + sImportInProgress = (status == MarketplaceErrorCodes::IMPORT_DONE); + sImportResultStatus = status; + } + }; + + class LLImportGetResponder : public LLHTTPClient::Responder + { + public: + LLImportGetResponder() : LLCurl::Responder() {} + + void completedHeader(U32 status, const std::string& reason, const LLSD& content) + { + sMarketplaceCookie = content["set-cookie"].asString(); + } + + void completed(U32 status, const std::string& reason, const LLSD& content) + { + sImportInProgress = (status == MarketplaceErrorCodes::IMPORT_PROCESSING); + sImportGetPending = false; + sImportResultStatus = status; + sImportResults = content; + } + }; + + // Coroutine testing +/* + std::string gTimeDelayDebugFunc = ""; + + void timeDelay(LLCoros::self& self, LLPanelMarketplaceOutbox* outboxPanel) { - std::string gridLabel = utf8str_tolower(LLGridManager::getInstance()->getGridLabel()); + waitForEventOn(self, "mainloop"); + + LLTimer delayTimer; + delayTimer.reset(); + delayTimer.setTimerExpirySec(5.0f); - if (gridLabel == "damballah") + while (!delayTimer.hasExpired()) { - url = "https://marketplace.secondlife-staging.com/"; + waitForEventOn(self, "mainloop"); } - else + + outboxPanel->onImportPostComplete(MarketplaceErrorCodes::IMPORT_DONE, LLSD::emptyMap()); + + gTimeDelayDebugFunc = ""; + } + + std::string gImportPollingFunc = ""; + + void importPoll(LLCoros::self& self, LLPanelMarketplaceOutbox* outboxPanel) + { + waitForEventOn(self, "mainloop"); + + while (outboxPanel->isImportInProgress()) { - url = llformat("https://marketplace.%s.lindenlab.com/", gridLabel.c_str()); + LLTimer delayTimer; + delayTimer.reset(); + delayTimer.setTimerExpirySec(5.0f); + + while (!delayTimer.hasExpired()) + { + waitForEventOn(self, "mainloop"); + } + + //outboxPanel-> } + + gImportPollingFunc = ""; } + +*/ + + // Basic API - url += "api/1/"; - url += gAgent.getID().getString(); - url += "/inventory/"; + bool inProgress() + { + return sImportInProgress; + } + + bool resultPending() + { + return sImportGetPending; + } + + U32 getResultStatus() + { + return sImportResultStatus; + } + + const LLSD& getResults() + { + return sImportResults; + } + + void establishMarketplaceSessionCookie() + { + sImportInProgress = true; + sImportGetPending = true; + + std::string url = getInventoryImportURL(); + + LLHTTPClient::get(url, new LLImportGetResponder(), LLViewerMedia::getHeaders()); + } + + void pollStatus() + { + sImportGetPending = true; - return url; + std::string url = getInventoryImportURL(); + + // Make the headers for the post + LLSD headers = LLSD::emptyMap(); + headers["Accept"] = "*/*"; + headers["Cookie"] = sMarketplaceCookie; + headers["Content-Type"] = "application/xml"; + headers["User-Agent"] = LLViewerMedia::getCurrentUserAgent(); + + LLHTTPClient::get(url, new LLImportGetResponder(), headers); + } + + void triggerImport() + { + sImportInProgress = true; + sImportResultStatus = MarketplaceErrorCodes::IMPORT_PROCESSING; + sImportResults = LLSD::emptyMap(); + + std::string url = getInventoryImportURL(); + + // Make the headers for the post + LLSD headers = LLSD::emptyMap(); + headers["Accept"] = "*/*"; + headers["Connection"] = "Keep-Alive"; + headers["Cookie"] = sMarketplaceCookie; + headers["Content-Type"] = "application/xml"; + headers["User-Agent"] = LLViewerMedia::getCurrentUserAgent(); + + LLHTTPClient::post(url, LLSD(), new LLImportPostResponder(), headers); + + // Set a timer (for testing only) + //gTimeDelayDebugFunc = LLCoros::instance().launch("LLPanelMarketplaceOutbox timeDelay", boost::bind(&timeDelay, _1, this)); + } } -std::string getMarketplaceURL_InventoryImport() + +// +// Interface class +// + + +//static +void LLMarketplaceInventoryImporter::update() { - std::string url = getMarketplaceBaseURL(); + if (instanceExists()) + { + LLMarketplaceInventoryImporter::instance().updateImport(); + } +} - url += "import/"; +LLMarketplaceInventoryImporter::LLMarketplaceInventoryImporter() + : mImportInProgress(false) + , mInitialized(false) + , mStatusChangedSignal(NULL) + , mStatusReportSignal(NULL) +{ +} - return url; +void LLMarketplaceInventoryImporter::initialize() +{ + if (!mInitialized) + { + LLMarketplaceImport::establishMarketplaceSessionCookie(); + } } +boost::signals2::connection LLMarketplaceInventoryImporter::setStatusChangedCallback(const status_changed_signal_t::slot_type& cb) +{ + if (mStatusChangedSignal == NULL) + { + mStatusChangedSignal = new status_changed_signal_t(); + } -static bool gMarketplaceImportEnabled = true; + return mStatusChangedSignal->connect(cb); +} -bool getMarketplaceImportEnabled() +boost::signals2::connection LLMarketplaceInventoryImporter::setStatusReportCallback(const status_report_signal_t::slot_type& cb) { - return gMarketplaceImportEnabled; + if (mStatusReportSignal == NULL) + { + mStatusReportSignal = new status_report_signal_t(); + } + + return mStatusReportSignal->connect(cb); } -void setMarketplaceImportEnabled(bool importEnabled) +bool LLMarketplaceInventoryImporter::triggerImport() { - gMarketplaceImportEnabled = importEnabled; + LLMarketplaceImport::triggerImport(); + + return LLMarketplaceImport::inProgress(); } + +void LLMarketplaceInventoryImporter::updateImport() +{ + const bool in_progress = LLMarketplaceImport::inProgress(); + + if (in_progress && !LLMarketplaceImport::resultPending()) + { + LLMarketplaceImport::pollStatus(); + } + + if (mImportInProgress != in_progress) + { + mImportInProgress = in_progress; + + if (mStatusChangedSignal) + { + (*mStatusChangedSignal)(mImportInProgress); + } + + // If we are no longer in progress, report results + if (!mImportInProgress && mStatusReportSignal) + { + if (mInitialized) + { + (*mStatusReportSignal)(LLMarketplaceImport::getResultStatus(), LLMarketplaceImport::getResults()); + } + else + { + mInitialized = true; + } + } + } +} + diff --git a/indra/newview/llmarketplacefunctions.h b/indra/newview/llmarketplacefunctions.h index fda2fbb935..5ca0bdfe77 100644 --- a/indra/newview/llmarketplacefunctions.h +++ b/indra/newview/llmarketplacefunctions.h @@ -29,14 +29,16 @@ #define LL_LLMARKETPLACEFUNCTIONS_H -std::string getMarketplaceURL_InventoryImport(); +#include +#include +#include + +#include "llsingleton.h" -bool getMarketplaceImportEnabled(); -void setMarketplaceImportEnabled(bool syncEnabled); namespace MarketplaceErrorCodes { - enum eCodes + enum eCode { IMPORT_DONE = 200, IMPORT_PROCESSING = 202, @@ -45,7 +47,38 @@ namespace MarketplaceErrorCodes }; } -#endif // LL_LLMARKETPLACEFUNCTIONS_H +class LLMarketplaceInventoryImporter + : public LLSingleton +{ +public: + static void update(); + + LLMarketplaceInventoryImporter(); + + void initialize(); + + typedef boost::signals2::signal status_changed_signal_t; + typedef boost::signals2::signal status_report_signal_t; + boost::signals2::connection setStatusChangedCallback(const status_changed_signal_t::slot_type& cb); + boost::signals2::connection setStatusReportCallback(const status_report_signal_t::slot_type& cb); + + bool triggerImport(); + bool isImportInProgress() const { return mImportInProgress; } + +protected: + void updateImport(); + +private: + bool mImportInProgress; + bool mInitialized; + + status_changed_signal_t * mStatusChangedSignal; + status_report_signal_t * mStatusReportSignal; +}; + + + +#endif // LL_LLMARKETPLACEFUNCTIONS_H diff --git a/indra/newview/llpanelmarketplaceoutbox.cpp b/indra/newview/llpanelmarketplaceoutbox.cpp index d7e4ed8bec..e3af7fd906 100644 --- a/indra/newview/llpanelmarketplaceoutbox.cpp +++ b/indra/newview/llpanelmarketplaceoutbox.cpp @@ -55,8 +55,6 @@ static LLRegisterPanelClassWrapper t_panel_marketplace_outbox("panel_marketplace_outbox"); -static std::string sMarketplaceCookie = ""; - const LLPanelMarketplaceOutbox::Params& LLPanelMarketplaceOutbox::getDefaultParams() { return LLUICtrlFactory::getDefaultParams(); @@ -67,10 +65,7 @@ LLPanelMarketplaceOutbox::LLPanelMarketplaceOutbox(const Params& p) : LLPanel(p) , mInventoryPanel(NULL) , mImportButton(NULL) - , mImportFrameTimer(0) - , mImportGetPending(false) , mImportIndicator(NULL) - , mImportInProgress(false) , mOutboxButton(NULL) { } @@ -93,7 +88,7 @@ void LLPanelMarketplaceOutbox::handleLoginComplete() { mImportButton = getChild("outbox_import_btn"); mImportButton->setCommitCallback(boost::bind(&LLPanelMarketplaceOutbox::onImportButtonClicked, this)); - mImportButton->setEnabled(getMarketplaceImportEnabled() && !isOutboxEmpty()); + mImportButton->setEnabled(!isOutboxEmpty()); mImportIndicator = getChild("outbox_import_indicator"); @@ -147,286 +142,73 @@ LLInventoryPanel * LLPanelMarketplaceOutbox::setupInventoryPanel() // Hide the placeholder text outbox_inventory_placeholder->setVisible(FALSE); - // Establish marketplace cookies for http client - establishMarketplaceSessionCookie(); + // Set up marketplace importer + LLMarketplaceInventoryImporter::getInstance()->initialize(); + LLMarketplaceInventoryImporter::getInstance()->setStatusChangedCallback(boost::bind(&LLPanelMarketplaceOutbox::importStatusChanged, this, _1)); + LLMarketplaceInventoryImporter::getInstance()->setStatusReportCallback(boost::bind(&LLPanelMarketplaceOutbox::importReportResults, this, _1, _2)); updateImportButtonStatus(); return mInventoryPanel; } -BOOL LLPanelMarketplaceOutbox::handleDragAndDrop(S32 x, S32 y, MASK mask, BOOL drop, - EDragAndDropType cargo_type, - void* cargo_data, - EAcceptance* accept, - std::string& tooltip_msg) +void LLPanelMarketplaceOutbox::importReportResults(U32 status, const LLSD& content) { - BOOL handled = LLPanel::handleDragAndDrop(x, y, mask, drop, cargo_type, cargo_data, accept, tooltip_msg); - - if (!handled && mInventoryPanel && mInventoryPanel->getRootFolder()) + if (status == MarketplaceErrorCodes::IMPORT_DONE) { - handled = mInventoryPanel->getRootFolder()->handleDragAndDropFromChild(mask,drop,cargo_type,cargo_data,accept,tooltip_msg); - - if (handled) - { - mInventoryPanel->getRootFolder()->setDragAndDropThisFrame(); - } + LLNotificationsUtil::add("OutboxImportComplete", LLSD::emptyMap(), LLSD::emptyMap()); } - - return handled; -} - -bool LLPanelMarketplaceOutbox::isOutboxEmpty() const -{ - return (getTotalItemCount() == 0); -} - -bool LLPanelMarketplaceOutbox::isImportInProgress() const -{ - return mImportInProgress; -} - - -std::string gTimeDelayDebugFunc = ""; - -void timeDelay(LLCoros::self& self, LLPanelMarketplaceOutbox* outboxPanel) -{ - waitForEventOn(self, "mainloop"); - - LLTimer delayTimer; - delayTimer.reset(); - delayTimer.setTimerExpirySec(5.0f); - - while (!delayTimer.hasExpired()) + else if (status == MarketplaceErrorCodes::IMPORT_DONE_WITH_ERRORS) { - waitForEventOn(self, "mainloop"); + LLNotificationsUtil::add("OutboxImportHadErrors", LLSD::emptyMap(), LLSD::emptyMap()); } - - outboxPanel->onImportPostComplete(MarketplaceErrorCodes::IMPORT_DONE, LLSD::emptyMap()); - - gTimeDelayDebugFunc = ""; -} - -std::string gImportPollingFunc = ""; - -void importPoll(LLCoros::self& self, LLPanelMarketplaceOutbox* outboxPanel) -{ - waitForEventOn(self, "mainloop"); - - while (outboxPanel->isImportInProgress()) + else { - LLTimer delayTimer; - delayTimer.reset(); - delayTimer.setTimerExpirySec(5.0f); + char status_string[16]; + sprintf(status_string, "%d", status); - while (!delayTimer.hasExpired()) - { - waitForEventOn(self, "mainloop"); - } + LLSD subs; + subs["ERROR_CODE"] = status_string; - //outboxPanel-> + //llassert(status == MarketplaceErrorCodes::IMPORT_JOB_FAILED); + LLNotificationsUtil::add("OutboxImportFailed", LLSD::emptyMap(), LLSD::emptyMap()); } - - gImportPollingFunc = ""; } -class LLInventoryImportPostResponder : public LLHTTPClient::Responder +void LLPanelMarketplaceOutbox::importStatusChanged(bool inProgress) { -public: - LLInventoryImportPostResponder(LLPanelMarketplaceOutbox * outboxPanel) - : LLCurl::Responder() - , mOutboxPanel(outboxPanel) - { - } - - void completed(U32 status, const std::string& reason, const LLSD& content) - { -#if DEBUG_MARKETPLACE_HTTP_API - llinfos << "*** Marketplace *** " << "inventory/import post status: " << status << ", reason: " << reason << llendl; - - if (isGoodStatus(status)) - { - // Complete success - llinfos << "*** Marketplace *** " << "success" << llendl; - } - else - { - llwarns << "*** Marketplace *** " << "failed" << llendl; - } -#endif // DEBUG_MARKETPLACE_HTTP_API - - mOutboxPanel->onImportPostComplete(status, content); - } - -private: - LLPanelMarketplaceOutbox * mOutboxPanel; -}; + updateImportButtonStatus(); +} -class LLInventoryImportGetResponder : public LLHTTPClient::Responder +BOOL LLPanelMarketplaceOutbox::handleDragAndDrop(S32 x, S32 y, MASK mask, BOOL drop, + EDragAndDropType cargo_type, + void* cargo_data, + EAcceptance* accept, + std::string& tooltip_msg) { -public: - LLInventoryImportGetResponder(LLPanelMarketplaceOutbox * outboxPanel, bool ignoreResults) - : LLCurl::Responder() - , mIgnoreResults(ignoreResults) - , mOutboxPanel(outboxPanel) - { - } + BOOL handled = LLPanel::handleDragAndDrop(x, y, mask, drop, cargo_type, cargo_data, accept, tooltip_msg); - void completedHeader(U32 status, const std::string& reason, const LLSD& content) + if (!handled && mInventoryPanel && mInventoryPanel->getRootFolder()) { - std::string cookie = content["set-cookie"].asString(); - -#if DEBUG_MARKETPLACE_HTTP_API - llinfos << "*** Marketplace *** " << "inventory/import headers set-cookie: " << cookie << llendl; -#endif // DEBUG_MARKETPLACE_HTTP_API - - sMarketplaceCookie = cookie; - } + handled = mInventoryPanel->getRootFolder()->handleDragAndDropFromChild(mask,drop,cargo_type,cargo_data,accept,tooltip_msg); - void completed(U32 status, const std::string& reason, const LLSD& content) - { -#if DEBUG_MARKETPLACE_HTTP_API - llinfos << "*** Marketplace *** " << "inventory/import get status: " << status << ", reason: " << reason << llendl; - - if (isGoodStatus(status)) - { - // Complete success - llinfos << "*** Marketplace *** " << "success" << llendl; - } - else + if (handled) { - llwarns << "*** Marketplace *** " << "failed" << llendl; + mInventoryPanel->getRootFolder()->setDragAndDropThisFrame(); } -#endif // DEBUG_MARKETPLACE_HTTP_API - - mOutboxPanel->onImportGetComplete(status, content, mIgnoreResults); - } - -private: - bool mIgnoreResults; - LLPanelMarketplaceOutbox * mOutboxPanel; -}; - -void LLPanelMarketplaceOutbox::importPostTrigger() -{ - mImportInProgress = true; - mImportFrameTimer = 0; - - // Make the url for the inventory import request - std::string url = getMarketplaceURL_InventoryImport(); - - LLSD headers = LLViewerMedia::getHeaders(); - headers["Connection"] = "Keep-Alive"; - headers["Cookie"] = sMarketplaceCookie; - -#if DEBUG_MARKETPLACE_HTTP_API - llinfos << "*** Marketplace *** " << "http post: " << url << llendl; - llinfos << "*** Marketplace *** " << "headers: " << ll_pretty_print_sd(headers) << llendl; -#endif // DEBUG_MARKETPLACE_HTTP_API - - LLHTTPClient::post(url, LLSD(), new LLInventoryImportPostResponder(this), headers); - - // Set a timer (for testing only) - //gTimeDelayDebugFunc = LLCoros::instance().launch("LLPanelMarketplaceOutbox timeDelay", boost::bind(&timeDelay, _1, this)); -} - -void LLPanelMarketplaceOutbox::importGetTrigger() -{ - mImportGetPending = true; - - std::string url = getMarketplaceURL_InventoryImport(); - LLSD headers = LLViewerMedia::getHeaders(); - headers["Cookie"] = sMarketplaceCookie; - -#if DEBUG_MARKETPLACE_HTTP_API - llinfos << "*** Marketplace *** " << "http get: " << url << llendl; - llinfos << "*** Marketplace *** " << "headers: " << ll_pretty_print_sd(headers) << llendl; -#endif // DEBUG_MARKETPLACE_HTTP_API - - const bool do_not_ignore_results = false; - - LLHTTPClient::get(url, new LLInventoryImportGetResponder(this, do_not_ignore_results), headers); -} - -void LLPanelMarketplaceOutbox::establishMarketplaceSessionCookie() -{ - mImportInProgress = true; - mImportGetPending = true; - - std::string url = getMarketplaceURL_InventoryImport(); - LLSD headers = LLViewerMedia::getHeaders(); - - const bool ignore_results = true; - - LLHTTPClient::get(url, new LLInventoryImportGetResponder(this, ignore_results), headers); -} - -void LLPanelMarketplaceOutbox::onImportPostComplete(U32 status, const LLSD& content) -{ -#if DEBUG_MARKETPLACE_HTTP_API - llinfos << "*** Marketplace *** " << "status = " << status << llendl; - llinfos << "*** Marketplace *** " << "content = " << ll_pretty_print_sd(content) << llendl; -#endif // DEBUG_MARKETPLACE_HTTP_API - - mImportInProgress = (status == MarketplaceErrorCodes::IMPORT_DONE); - updateImportButtonStatus(); - - if (!mImportInProgress) - { - char status_string[16]; - sprintf(status_string, "%d", status); - - LLSD subs; - subs["ERROR_CODE"] = status_string; - - LLNotificationsUtil::add("OutboxImportFailed", subs, LLSD::emptyMap()); } - // The POST request returns the IMPORT_DONE code on success - //if (status == MarketplaceErrorCodes::IMPORT_DONE) - //{ - // gImportPollingFunc = LLCoros::instance().launch("LLPanelMarketplaceOutbox importPoll", boost::bind(&importPoll, _1, this)); - //} + return handled; } -void LLPanelMarketplaceOutbox::onImportGetComplete(U32 status, const LLSD& content, bool ignoreResults) +bool LLPanelMarketplaceOutbox::isOutboxEmpty() const { -#if DEBUG_MARKETPLACE_HTTP_API - llinfos << "*** Marketplace *** " << "status = " << status << llendl; - llinfos << "*** Marketplace *** " << "content = " << ll_pretty_print_sd(content) << llendl; -#endif // DEBUG_MARKETPLACE_HTTP_API - - mImportGetPending = false; - mImportInProgress = (status == MarketplaceErrorCodes::IMPORT_PROCESSING); - updateImportButtonStatus(); - - if (!mImportInProgress && !ignoreResults) - { - if (status == MarketplaceErrorCodes::IMPORT_DONE) - { - LLNotificationsUtil::add("OutboxImportComplete", LLSD::emptyMap(), LLSD::emptyMap()); - } - else if (status == MarketplaceErrorCodes::IMPORT_DONE_WITH_ERRORS) - { - LLNotificationsUtil::add("OutboxImportHadErrors", LLSD::emptyMap(), LLSD::emptyMap()); - } - else - { - char status_string[16]; - sprintf(status_string, "%d", status); - - LLSD subs; - subs["ERROR_CODE"] = status_string; - - //llassert(status == MarketplaceErrorCodes::IMPORT_JOB_FAILED); - LLNotificationsUtil::add("OutboxImportFailed", LLSD::emptyMap(), LLSD::emptyMap()); - } - } + return (getTotalItemCount() == 0); } void LLPanelMarketplaceOutbox::updateImportButtonStatus() { - if (isImportInProgress()) + if (LLMarketplaceInventoryImporter::instance().isImportInProgress()) { mImportButton->setVisible(false); @@ -440,7 +222,7 @@ void LLPanelMarketplaceOutbox::updateImportButtonStatus() mImportIndicator->setVisible(false); mImportButton->setVisible(true); - mImportButton->setEnabled(getMarketplaceImportEnabled() && !isOutboxEmpty()); + mImportButton->setEnabled(!isOutboxEmpty()); } } @@ -464,7 +246,7 @@ U32 LLPanelMarketplaceOutbox::getTotalItemCount() const void LLPanelMarketplaceOutbox::onImportButtonClicked() { - importPostTrigger(); + LLMarketplaceInventoryImporter::instance().triggerImport(); // Get the import animation going updateImportButtonStatus(); @@ -488,19 +270,5 @@ void LLPanelMarketplaceOutbox::draw() mOutboxButton->setLabel(getString("OutboxLabelNoArg")); } - if (!isImportInProgress()) - { - mImportButton->setEnabled(getMarketplaceImportEnabled() && not_empty); - } - else - { - ++mImportFrameTimer; - - if ((mImportFrameTimer % 50 == 0) && !mImportGetPending) - { - importGetTrigger(); - } - } - LLPanel::draw(); } diff --git a/indra/newview/llpanelmarketplaceoutbox.h b/indra/newview/llpanelmarketplaceoutbox.h index 9cbb9cf21b..6f038118b3 100644 --- a/indra/newview/llpanelmarketplaceoutbox.h +++ b/indra/newview/llpanelmarketplaceoutbox.h @@ -59,10 +59,6 @@ public: U32 getTotalItemCount() const; bool isOutboxEmpty() const; - bool isImportInProgress() const; - - void onImportPostComplete(U32 status, const LLSD& content); - void onImportGetComplete(U32 status, const LLSD& content, bool ignoreResults); /*virtual*/ BOOL handleDragAndDrop(S32 x, S32 y, MASK mask, BOOL drop, EDragAndDropType cargo_type, @@ -78,18 +74,14 @@ protected: void onFocusReceived(); void onSelectionChange(); - void importPostTrigger(); - void importGetTrigger(); - void establishMarketplaceSessionCookie(); - + void importReportResults(U32 status, const LLSD& content); + void importStatusChanged(bool inProgress); + private: LLInventoryPanel * mInventoryPanel; LLButton * mImportButton; - U32 mImportFrameTimer; - bool mImportGetPending; LLLoadingIndicator * mImportIndicator; - bool mImportInProgress; LLButton * mOutboxButton; }; -- cgit v1.2.3 From 67f1321f31d5988e7b383cfbf4fbd6537f3d2710 Mon Sep 17 00:00:00 2001 From: Leslie Linden Date: Thu, 8 Dec 2011 16:46:30 -0800 Subject: Initial functional merchant outbox floater --- indra/newview/llfloateroutbox.cpp | 309 ++++++++++++++++++++- indra/newview/llfloateroutbox.h | 44 ++- indra/newview/llmarketplacefunctions.cpp | 7 +- indra/newview/llsidepanelinventory.cpp | 2 +- .../default/xui/en/floater_merchant_outbox.xml | 137 ++++----- 5 files changed, 416 insertions(+), 83 deletions(-) (limited to 'indra/newview') diff --git a/indra/newview/llfloateroutbox.cpp b/indra/newview/llfloateroutbox.cpp index 8fea3d674e..79cd90ba1c 100644 --- a/indra/newview/llfloateroutbox.cpp +++ b/indra/newview/llfloateroutbox.cpp @@ -29,40 +29,333 @@ #include "llfloateroutbox.h" #include "llfloaterreg.h" +#include "llfolderview.h" +#include "llinventoryobserver.h" +#include "llinventorypanel.h" +#include "llloadingindicator.h" +#include "llmarketplacefunctions.h" +#include "llnotificationsutil.h" +#include "lltextbox.h" #include "lltransientfloatermgr.h" +#include "lltrans.h" +#include "llviewernetwork.h" +///---------------------------------------------------------------------------- +/// LLOutboxAddedObserver helper class +///---------------------------------------------------------------------------- + +class LLOutboxAddedObserver : public LLInventoryCategoryAddedObserver +{ +public: + LLOutboxAddedObserver(LLFloaterOutbox * outboxFloater) + : LLInventoryCategoryAddedObserver() + , mOutboxFloater(outboxFloater) + { + } + + void done() + { + for (cat_vec_t::iterator it = mAddedCategories.begin(); it != mAddedCategories.end(); ++it) + { + LLViewerInventoryCategory* added_category = *it; + + LLFolderType::EType added_category_type = added_category->getPreferredType(); + + if (added_category_type == LLFolderType::FT_OUTBOX) + { + mOutboxFloater->setupOutbox(added_category->getUUID()); + } + } + } + +private: + LLFloaterOutbox * mOutboxFloater; +}; + ///---------------------------------------------------------------------------- /// LLFloaterOutbox ///---------------------------------------------------------------------------- LLFloaterOutbox::LLFloaterOutbox(const LLSD& key) : LLFloater(key) - , mPanelOutboxInventory(NULL) + , mCategoriesObserver(NULL) + , mCategoryAddedObserver(NULL) + , mOutboxId(LLUUID::null) + , mOutboxInventoryPanel(NULL) + , mOutboxItemCount(0) + , mInventoryDisablePanel(NULL) + , mInventoryFolderCountText(NULL) + , mInventoryImportInProgress(NULL) + , mInventoryPlaceholder(NULL) + , mInventoryText(NULL) + , mInventoryTitle(NULL) + , mImportButton(NULL) { - LLTransientFloaterMgr::getInstance()->addControlView(this); } LLFloaterOutbox::~LLFloaterOutbox() { - LLTransientFloaterMgr::getInstance()->removeControlView(this); +// delete mCategoriesObserver; +// delete mCategoryAddedObserver; } BOOL LLFloaterOutbox::postBuild() { + mInventoryDisablePanel = getChild("outbox_inventory_disable_panel"); + mInventoryFolderCountText = getChild("outbox_folder_count"); + mInventoryImportInProgress = getChild("import_progress_indicator"); + mInventoryPlaceholder = getChild("outbox_inventory_placeholder_panel"); + mInventoryText = mInventoryPlaceholder->getChild("outbox_inventory_placeholder_text"); + mInventoryTitle = mInventoryPlaceholder->getChild("outbox_inventory_placeholder_title"); + + mImportButton = getChild("outbox_import_btn"); + mImportButton->setCommitCallback(boost::bind(&LLFloaterOutbox::onImportButtonClicked, this)); + return TRUE; } void LLFloaterOutbox::onOpen(const LLSD& key) { - //LLFirstUse::useInventory(); + // + // Initialize the marketplace import API + // + + LLMarketplaceInventoryImporter::getInstance()->initialize(); + LLMarketplaceInventoryImporter::getInstance()->setStatusChangedCallback(boost::bind(&LLFloaterOutbox::importStatusChanged, this, _1)); + LLMarketplaceInventoryImporter::getInstance()->setStatusReportCallback(boost::bind(&LLFloaterOutbox::importReportResults, this, _1, _2)); + + // + // Look for an outbox and set up the inventory API + // + + const bool do_not_create_folder = false; + const bool do_not_find_in_library = false; + + const LLUUID outbox_id = gInventory.findCategoryUUIDForType(LLFolderType::FT_OUTBOX, do_not_create_folder, do_not_find_in_library); + + if (outbox_id.isNull()) + { + // Observe category creation to catch outbox creation + mCategoryAddedObserver = new LLOutboxAddedObserver(this); + gInventory.addObserver(mCategoryAddedObserver); + } + else + { + setupOutbox(outbox_id); + } + + updateView(); +} + +void LLFloaterOutbox::setupOutbox(const LLUUID& outboxId) +{ + llassert(mOutboxId.isNull()); + llassert(mCategoriesObserver == NULL); + + mOutboxId = outboxId; + + // No longer need to observe new category creation + if (mCategoryAddedObserver != NULL) + { + gInventory.removeObserver(mCategoryAddedObserver); + } + + // Create observer for outbox modifications + mCategoriesObserver = new LLInventoryCategoriesObserver(); + gInventory.addObserver(mCategoriesObserver); + + mCategoriesObserver->addCategory(mOutboxId, boost::bind(&LLFloaterOutbox::onOutboxChanged, this)); + + // + // Set up the outbox inventory view + // + + mOutboxInventoryPanel = + LLUICtrlFactory::createFromFile("panel_outbox_inventory.xml", + mInventoryPlaceholder->getParent(), + LLInventoryPanel::child_registry_t::instance()); + + llassert(mOutboxInventoryPanel); + + // Reshape the inventory to the proper size + LLRect inventory_placeholder_rect = mInventoryPlaceholder->getRect(); + mOutboxInventoryPanel->setShape(inventory_placeholder_rect); + + // Set the sort order newest to oldest + mOutboxInventoryPanel->setSortOrder(LLInventoryFilter::SO_DATE); + mOutboxInventoryPanel->getFilter()->markDefault(); + + // Set selection callback for proper update of inventory status buttons + //mOutboxInventoryPanel->setSelectCallback(boost::bind(&LLPanelMarketplaceOutbox::onSelectionChange, this)); + + // Set up the note to display when the outbox is empty + mOutboxInventoryPanel->getFilter()->setEmptyLookupMessage("InventoryOutboxNoItems"); +} + +void LLFloaterOutbox::updateView() +{ + if (mOutboxItemCount > 0) + { + mOutboxInventoryPanel->setVisible(TRUE); + mInventoryPlaceholder->setVisible(FALSE); + } + else + { + mOutboxInventoryPanel->setVisible(FALSE); + mInventoryPlaceholder->setVisible(TRUE); + + std::string outbox_text; + std::string outbox_title; + std::string outbox_tooltip; + + if (mOutboxId.notNull()) + { + outbox_text = LLTrans::getString("InventoryOutboxNoItems"); + outbox_title = LLTrans::getString("InventoryOutboxNoItemsTitle"); + outbox_tooltip = LLTrans::getString("InventoryOutboxNoItemsTooltip"); + } + else + { + // + // The string to become a merchant contains 3 URL's which need the domain name patched in. + // + + std::string domain = "secondlife.com"; + + if (!LLGridManager::getInstance()->isInProductionGrid()) + { + std::string gridLabel = LLGridManager::getInstance()->getGridLabel(); + domain = llformat("%s.lindenlab.com", utf8str_tolower(gridLabel).c_str()); + } + + LLStringUtil::format_map_t domain_arg; + domain_arg["[DOMAIN_NAME]"] = domain; + + std::string marketplace_url = LLTrans::getString("MarketplaceURL", domain_arg); + std::string marketplace_url_create = LLTrans::getString("MarketplaceURL_CreateStore", domain_arg); + std::string marketplace_url_info = LLTrans::getString("MarketplaceURL_LearnMore", domain_arg); + + LLStringUtil::format_map_t args1, args2, args3; + args1["[MARKETPLACE_URL]"] = marketplace_url; + args2["[LEARN_MORE_URL]"] = marketplace_url_info; + args3["[CREATE_STORE_URL]"] = marketplace_url_create; + + // NOTE: This is dumb, ridiculous and very finicky. The order of these is very important + // to have these three string substitutions work properly. + outbox_text = LLTrans::getString("InventoryOutboxNotMerchant", args1); + LLStringUtil::format(outbox_text, args2); + LLStringUtil::format(outbox_text, args3); + + outbox_title = LLTrans::getString("InventoryOutboxNotMerchantTitle"); + outbox_tooltip = LLTrans::getString("InventoryOutboxNotMerchantTooltip"); + } + + mInventoryText->setValue(outbox_text); + mInventoryTitle->setValue(outbox_title); + mInventoryPlaceholder->getParent()->setToolTip(outbox_tooltip); + } +} + +BOOL LLFloaterOutbox::handleDragAndDrop(S32 x, S32 y, MASK mask, BOOL drop, + EDragAndDropType cargo_type, + void* cargo_data, + EAcceptance* accept, + std::string& tooltip_msg) +{ + // Pass drag and drop to this floater to the outbox inventory control + + S32 local_x = x - mOutboxInventoryPanel->getRect().mLeft; + S32 local_y = y - mOutboxInventoryPanel->getRect().mBottom; + + return mOutboxInventoryPanel->handleDragAndDrop(local_x, local_y, mask, drop, cargo_type, cargo_data, accept, tooltip_msg); +} + +void LLFloaterOutbox::onImportButtonClicked() +{ + LLMarketplaceInventoryImporter::instance().triggerImport(); +} + +void LLFloaterOutbox::onOutboxChanged() +{ + llassert(!mOutboxId.isNull()); + + U32 item_count = 0; + + const LLFolderViewFolder * outbox_folder = mOutboxInventoryPanel->getRootFolder(); + + if (outbox_folder) + { + item_count += outbox_folder->getFoldersCount(); + item_count += outbox_folder->getItemsCount(); + } + + mOutboxItemCount = item_count; + + switch (mOutboxItemCount) + { + case 0: mInventoryFolderCountText->setText(getString("OutboxFolderCount0")); break; + case 1: mInventoryFolderCountText->setText(getString("OutboxFolderCount1")); break; + default: + { + std::string item_count_str = llformat("%d", mOutboxItemCount); + + LLStringUtil::format_map_t args; + args["[NUM]"] = item_count_str; + + mInventoryFolderCountText->setText(getString("OutboxFolderCountN", args)); + break; + } + } + + mImportButton->setEnabled(mOutboxItemCount > 0); + + updateView(); } -void LLFloaterOutbox::onClose(bool app_quitting) +void LLFloaterOutbox::importReportResults(U32 status, const LLSD& content) { - LLFloater::onClose(app_quitting); - if (mKey.asInteger() > 1) + if (status == MarketplaceErrorCodes::IMPORT_DONE) + { + LLNotificationsUtil::add("OutboxImportComplete", LLSD::emptyMap(), LLSD::emptyMap()); + } + else if (status == MarketplaceErrorCodes::IMPORT_DONE_WITH_ERRORS) + { + LLNotificationsUtil::add("OutboxImportHadErrors", LLSD::emptyMap(), LLSD::emptyMap()); + } + else { - destroy(); + char status_string[16]; + sprintf(status_string, "%d", status); + + LLSD subs; + subs["ERROR_CODE"] = status_string; + + //llassert(status == MarketplaceErrorCodes::IMPORT_JOB_FAILED); + LLNotificationsUtil::add("OutboxImportFailed", LLSD::emptyMap(), LLSD::emptyMap()); } } + +void LLFloaterOutbox::importStatusChanged(bool inProgress) +{ + if (inProgress) + { + mImportButton->setEnabled(false); + + mInventoryDisablePanel->setVisible(true); + + mInventoryImportInProgress->setVisible(true); + mInventoryImportInProgress->reset(); + mInventoryImportInProgress->start(); + } + else + { + mImportButton->setEnabled(mOutboxItemCount > 0); + + mInventoryDisablePanel->setVisible(false); + + mInventoryImportInProgress->stop(); + mInventoryImportInProgress->setVisible(false); + } +} + diff --git a/indra/newview/llfloateroutbox.h b/indra/newview/llfloateroutbox.h index cb5c2be81c..1e8567ef12 100644 --- a/indra/newview/llfloateroutbox.h +++ b/indra/newview/llfloateroutbox.h @@ -31,7 +31,15 @@ #include "llfloater.h" #include "llfoldertype.h" + +class LLButton; +class LLInventoryCategoriesObserver; +class LLInventoryCategoryAddedObserver; class LLInventoryPanel; +class LLLoadingIndicator; +class LLTextBox; +class LLView; + //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ // Class LLFloaterOutbox @@ -42,15 +50,43 @@ class LLFloaterOutbox : public LLFloater public: LLFloaterOutbox(const LLSD& key); ~LLFloaterOutbox(); + + void setupOutbox(const LLUUID& outboxId); + // virtuals BOOL postBuild(); + void onOpen(const LLSD& key); + BOOL handleDragAndDrop(S32 x, S32 y, MASK mask, BOOL drop, + EDragAndDropType cargo_type, + void* cargo_data, + EAcceptance* accept, + std::string& tooltip_msg); - // Inherited functionality - /*virtual*/ void onOpen(const LLSD& key); - /*virtual*/ void onClose(bool app_quitting); +protected: + void importReportResults(U32 status, const LLSD& content); + void importStatusChanged(bool inProgress); + + void onImportButtonClicked(); + void onOutboxChanged(); + + void updateView(); private: - LLInventoryPanel* mPanelOutboxInventory; + LLInventoryCategoriesObserver * mCategoriesObserver; + LLInventoryCategoryAddedObserver * mCategoryAddedObserver; + + LLUUID mOutboxId; + LLInventoryPanel * mOutboxInventoryPanel; + U32 mOutboxItemCount; + + LLView * mInventoryDisablePanel; + LLTextBox * mInventoryFolderCountText; + LLLoadingIndicator * mInventoryImportInProgress; + LLView * mInventoryPlaceholder; + LLTextBox * mInventoryText; + LLTextBox * mInventoryTitle; + + LLButton * mImportButton; }; #endif // LL_LLFLOATEROUTBOX_H diff --git a/indra/newview/llmarketplacefunctions.cpp b/indra/newview/llmarketplacefunctions.cpp index b9e02a36b4..9c67c589b8 100644 --- a/indra/newview/llmarketplacefunctions.cpp +++ b/indra/newview/llmarketplacefunctions.cpp @@ -55,6 +55,7 @@ namespace LLMarketplaceImport static std::string sMarketplaceCookie = ""; static bool sImportInProgress = false; + static bool sImportPostPending = false; static bool sImportGetPending = false; static U32 sImportResultStatus = 0; static LLSD sImportResults = LLSD::emptyMap(); @@ -106,6 +107,7 @@ namespace LLMarketplaceImport void completed(U32 status, const std::string& reason, const LLSD& content) { sImportInProgress = (status == MarketplaceErrorCodes::IMPORT_DONE); + sImportPostPending = false; sImportResultStatus = status; } }; @@ -185,7 +187,7 @@ namespace LLMarketplaceImport bool resultPending() { - return sImportGetPending; + return (sImportPostPending || sImportGetPending); } U32 getResultStatus() @@ -226,7 +228,8 @@ namespace LLMarketplaceImport void triggerImport() { - sImportInProgress = true; + sImportInProgress = true; + sImportPostPending = true; sImportResultStatus = MarketplaceErrorCodes::IMPORT_PROCESSING; sImportResults = LLSD::emptyMap(); diff --git a/indra/newview/llsidepanelinventory.cpp b/indra/newview/llsidepanelinventory.cpp index 19a81b93bf..9c551be2d5 100644 --- a/indra/newview/llsidepanelinventory.cpp +++ b/indra/newview/llsidepanelinventory.cpp @@ -926,7 +926,7 @@ U32 LLSidepanelInventory::getSelectedCount() { selection_list = mInventoryPanelInbox->getRootFolder()->getSelectionList(); - count += selection_list.size(); + count += selection_list.size(); } if ((count == 0) && mOutboxEnabled && (mInventoryPanelOutbox != NULL)) diff --git a/indra/newview/skins/default/xui/en/floater_merchant_outbox.xml b/indra/newview/skins/default/xui/en/floater_merchant_outbox.xml index 2f8a83c072..86e27cbc71 100644 --- a/indra/newview/skins/default/xui/en/floater_merchant_outbox.xml +++ b/indra/newview/skins/default/xui/en/floater_merchant_outbox.xml @@ -3,90 +3,33 @@ open_positioning="cascading" can_close="true" can_resize="true" - height="400" + height="440" help_topic="floater_merchant_outbox" - min_width="333" - min_height="440" + min_width="300" + min_height="240" name="floater_merchant_outbox" save_rect="true" save_visibility="true" reuse_instance="true" title="MERCHANT OUTBOX" width="333" > + 0 folders + 1 folder + [NUM] folders - Merchant outbox ([NUM]) - Merchant outbox -