summaryrefslogtreecommitdiff
path: root/indra/newview/llpanelmarketplaceoutbox.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'indra/newview/llpanelmarketplaceoutbox.cpp')
-rw-r--r--indra/newview/llpanelmarketplaceoutbox.cpp231
1 files changed, 71 insertions, 160 deletions
diff --git a/indra/newview/llpanelmarketplaceoutbox.cpp b/indra/newview/llpanelmarketplaceoutbox.cpp
index 12960fd0d6..e3af7fd906 100644
--- a/indra/newview/llpanelmarketplaceoutbox.cpp
+++ b/indra/newview/llpanelmarketplaceoutbox.cpp
@@ -36,6 +36,7 @@
#include "llfloatersidepanelcontainer.h"
#include "llinventorypanel.h"
#include "llloadingindicator.h"
+#include "llmarketplacefunctions.h"
#include "llnotificationsutil.h"
#include "llpanelmarketplaceinbox.h"
#include "llsdutil.h"
@@ -47,6 +48,11 @@
#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<LLPanelMarketplaceOutbox> t_panel_marketplace_outbox("panel_marketplace_outbox");
const LLPanelMarketplaceOutbox::Params& LLPanelMarketplaceOutbox::getDefaultParams()
@@ -58,9 +64,9 @@ const LLPanelMarketplaceOutbox::Params& LLPanelMarketplaceOutbox::getDefaultPara
LLPanelMarketplaceOutbox::LLPanelMarketplaceOutbox(const Params& p)
: LLPanel(p)
, mInventoryPanel(NULL)
- , mSyncButton(NULL)
- , mSyncIndicator(NULL)
- , mSyncInProgress(false)
+ , mImportButton(NULL)
+ , mImportIndicator(NULL)
+ , mOutboxButton(NULL)
{
}
@@ -80,11 +86,13 @@ BOOL LLPanelMarketplaceOutbox::postBuild()
void LLPanelMarketplaceOutbox::handleLoginComplete()
{
- mSyncButton = getChild<LLButton>("outbox_sync_btn");
- mSyncButton->setCommitCallback(boost::bind(&LLPanelMarketplaceOutbox::onSyncButtonClicked, this));
- mSyncButton->setEnabled(!isOutboxEmpty());
+ mImportButton = getChild<LLButton>("outbox_import_btn");
+ mImportButton->setCommitCallback(boost::bind(&LLPanelMarketplaceOutbox::onImportButtonClicked, this));
+ mImportButton->setEnabled(!isOutboxEmpty());
- mSyncIndicator = getChild<LLLoadingIndicator>("outbox_sync_indicator");
+ mImportIndicator = getChild<LLLoadingIndicator>("outbox_import_indicator");
+
+ mOutboxButton = getChild<LLButton>("outbox_btn");
}
void LLPanelMarketplaceOutbox::onFocusReceived()
@@ -134,9 +142,44 @@ LLInventoryPanel * LLPanelMarketplaceOutbox::setupInventoryPanel()
// Hide the placeholder text
outbox_inventory_placeholder->setVisible(FALSE);
+ // 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;
}
+void LLPanelMarketplaceOutbox::importReportResults(U32 status, const LLSD& content)
+{
+ 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());
+ }
+}
+
+void LLPanelMarketplaceOutbox::importStatusChanged(bool inProgress)
+{
+ updateImportButtonStatus();
+}
+
BOOL LLPanelMarketplaceOutbox::handleDragAndDrop(S32 x, S32 y, MASK mask, BOOL drop,
EDragAndDropType cargo_type,
void* cargo_data,
@@ -163,159 +206,23 @@ bool LLPanelMarketplaceOutbox::isOutboxEmpty() const
return (getTotalItemCount() == 0);
}
-bool LLPanelMarketplaceOutbox::isSyncInProgress() const
+void LLPanelMarketplaceOutbox::updateImportButtonStatus()
{
- return mSyncInProgress;
-}
-
-
-std::string gTimeDelayDebugFunc = "";
-
-void timeDelay(LLCoros::self& self, LLPanelMarketplaceOutbox* outboxPanel)
-{
- waitForEventOn(self, "mainloop");
-
- LLTimer delayTimer;
- delayTimer.reset();
- delayTimer.setTimerExpirySec(5.0f);
-
- while (!delayTimer.hasExpired())
- {
- waitForEventOn(self, "mainloop");
- }
-
- outboxPanel->onSyncComplete(true, LLSD::emptyMap());
-
- gTimeDelayDebugFunc = "";
-}
-
-
-class LLInventorySyncResponder : public LLHTTPClient::Responder
-{
-public:
- LLInventorySyncResponder(LLPanelMarketplaceOutbox * outboxPanel)
- : LLCurl::Responder()
- , mOutboxPanel(outboxPanel)
- {
- }
-
- void completed(U32 status, const std::string& reason, const LLSD& content)
+ if (LLMarketplaceInventoryImporter::instance().isImportInProgress())
{
- llinfos << "inventory_import complete status: " << status << ", reason: " << reason << llendl;
+ mImportButton->setVisible(false);
- if (isGoodStatus(status))
- {
- // Complete success
- llinfos << "success" << llendl;
- }
- else
- {
- llwarns << "failed" << llendl;
- }
-
- mOutboxPanel->onSyncComplete(isGoodStatus(status), content);
- }
-
-private:
- LLPanelMarketplaceOutbox * mOutboxPanel;
-};
-
-void LLPanelMarketplaceOutbox::onSyncButtonClicked()
-{
- // Get the sync animation going
- mSyncInProgress = true;
- 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";
-
- llinfos << "http get: " << url << llendl;
- LLHTTPClient::get(url, new LLInventorySyncResponder(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)
-{
- mSyncInProgress = false;
- updateSyncButtonStatus();
-
- const LLSD& errors_list = content["errors"];
-
- if (goodStatus && (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<LLOutboxFolderViewFolder *>(item_folder);
-
- llassert(outbox_item_folder);
-
- outbox_item_folder->setErrorString(error_string);
- }
-}
-
-void LLPanelMarketplaceOutbox::updateSyncButtonStatus()
-{
- if (isSyncInProgress())
- {
- mSyncButton->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(!isOutboxEmpty());
+ mImportButton->setVisible(true);
+ mImportButton->setEnabled(!isOutboxEmpty());
}
}
@@ -330,12 +237,21 @@ U32 LLPanelMarketplaceOutbox::getTotalItemCount() const
if (outbox_folder)
{
item_count += outbox_folder->getFoldersCount();
+ item_count += outbox_folder->getItemsCount();
}
}
return item_count;
}
+void LLPanelMarketplaceOutbox::onImportButtonClicked()
+{
+ LLMarketplaceInventoryImporter::instance().triggerImport();
+
+ // Get the import animation going
+ updateImportButtonStatus();
+}
+
void LLPanelMarketplaceOutbox::draw()
{
const U32 item_count = getTotalItemCount();
@@ -347,16 +263,11 @@ void LLPanelMarketplaceOutbox::draw()
LLStringUtil::format_map_t args;
args["[NUM]"] = item_count_str;
- getChild<LLButton>("outbox_btn")->setLabel(getString("OutboxLabelWithArg", args));
+ mOutboxButton->setLabel(getString("OutboxLabelWithArg", args));
}
else
{
- getChild<LLButton>("outbox_btn")->setLabel(getString("OutboxLabelNoArg"));
- }
-
- if (!isSyncInProgress())
- {
- mSyncButton->setEnabled(not_empty);
+ mOutboxButton->setLabel(getString("OutboxLabelNoArg"));
}
LLPanel::draw();