diff options
| author | Leslie Linden <leslie@lindenlab.com> | 2011-12-07 15:04:39 -0800 | 
|---|---|---|
| committer | Leslie Linden <leslie@lindenlab.com> | 2011-12-07 15:04:39 -0800 | 
| commit | 35020db3a9310742c9759673e3aa1bbb1d7aa02f (patch) | |
| tree | 90e769fc43b8112461035b0b26c9b9b9df50877d | |
| parent | e860925818fe9376fa9abb0520680dba986ab42e (diff) | |
Refactored marketplace inventory import HTTP requests and surrounding support to remove it from the UI panel code.
| -rw-r--r-- | indra/newview/llappviewer.cpp | 4 | ||||
| -rw-r--r-- | indra/newview/llmarketplacefunctions.cpp | 302 | ||||
| -rw-r--r-- | indra/newview/llmarketplacefunctions.h | 43 | ||||
| -rw-r--r-- | indra/newview/llpanelmarketplaceoutbox.cpp | 304 | ||||
| -rw-r--r-- | indra/newview/llpanelmarketplaceoutbox.h | 14 | 
5 files changed, 362 insertions, 305 deletions
| 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 <llsd.h> +#include <boost/function.hpp> +#include <boost/signals2.hpp> + +#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<LLMarketplaceInventoryImporter> +{ +public: +	static void update(); +	 +	LLMarketplaceInventoryImporter(); +	 +	void initialize(); + +	typedef boost::signals2::signal<void (bool)> status_changed_signal_t; +	typedef boost::signals2::signal<void (U32, const LLSD&)> 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<LLPanelMarketplaceOutbox> t_panel_marketplace_outbox("panel_marketplace_outbox"); -static std::string sMarketplaceCookie = ""; -  const LLPanelMarketplaceOutbox::Params& LLPanelMarketplaceOutbox::getDefaultParams()   {   	return LLUICtrlFactory::getDefaultParams<LLPanelMarketplaceOutbox>();  @@ -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<LLButton>("outbox_import_btn");  	mImportButton->setCommitCallback(boost::bind(&LLPanelMarketplaceOutbox::onImportButtonClicked, this)); -	mImportButton->setEnabled(getMarketplaceImportEnabled() && !isOutboxEmpty()); +	mImportButton->setEnabled(!isOutboxEmpty());  	mImportIndicator = getChild<LLLoadingIndicator>("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;  }; | 
