From 5cf4d63a82e2b6c2546a2bb5ef13ef142fc07cb9 Mon Sep 17 00:00:00 2001
From: Leyla Farazha <leyla@lindenlab.com>
Date: Fri, 29 Jul 2011 17:06:40 -0700
Subject: [PATCH] attempting to do the outbox import

---
 indra/newview/llpanelmarketplaceoutbox.cpp | 43 +++++++++++++++++++++-
 indra/newview/llviewermedia.cpp            | 11 ++++++
 indra/newview/llviewermedia.h              |  2 +
 3 files changed, 54 insertions(+), 2 deletions(-)

diff --git a/indra/newview/llpanelmarketplaceoutbox.cpp b/indra/newview/llpanelmarketplaceoutbox.cpp
index c96fb228621..074fea546d1 100644
--- a/indra/newview/llpanelmarketplaceoutbox.cpp
+++ b/indra/newview/llpanelmarketplaceoutbox.cpp
@@ -38,6 +38,9 @@
 #include "llsidepanelinventory.h"
 #include "llsidetray.h"
 #include "lltimer.h"
+#include "llviewernetwork.h"
+#include "llagent.h"
+#include "llviewermedia.h"
 #include "llfolderview.h"
 
 static LLRegisterPanelClassWrapper<LLPanelMarketplaceOutbox> t_panel_marketplace_outbox("panel_marketplace_outbox");
@@ -190,10 +193,46 @@ void timeDelay(LLCoros::self& self, LLPanelMarketplaceOutbox* outboxPanel)
 	gTimeDelayDebugFunc = "";
 }
 
+
+class LLInventorySyncResponder : public LLHTTPClient::Responder
+{
+public:
+	LLInventorySyncResponder()
+		: LLCurl::Responder()
+	{
+	}
+
+	void completed(U32 status, const std::string& reason, const LLSD& content)
+	{
+		if (isGoodStatus(status))
+		{
+			// Complete success
+			llinfos << "sync complete" << llendl;
+		}	
+		else
+		{
+			llwarns << "sync failed" << llendl;
+		}
+	}
+};
+
 void LLPanelMarketplaceOutbox::onSyncButtonClicked()
 {	
-	// TODO: Actually trigger sync to marketplace
-	
+	std::string url = "http://pdp24.lindenlab.com/3000"; /*"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();
+	url += "/inventory_import";
+
+	LLHTTPClient::get(url, new LLInventorySyncResponder(), LLViewerMedia::getHeaders());
+
+
 	mSyncInProgress = true;
 	updateSyncButtonStatus();
 
diff --git a/indra/newview/llviewermedia.cpp b/indra/newview/llviewermedia.cpp
index 384f7cd61d3..d5a8772461b 100644
--- a/indra/newview/llviewermedia.cpp
+++ b/indra/newview/llviewermedia.cpp
@@ -1394,6 +1394,17 @@ class LLInventoryUserStatusResponder : public LLHTTPClient::Responder
 	}
 };
 
+
+LLSD LLViewerMedia::getHeaders()
+{
+	LLSD headers = LLSD::emptyMap();
+	headers["Accept"] = "*/*";
+	headers["Cookie"] = sOpenIDCookie;
+	headers["User-Agent"] = getCurrentUserAgent();
+
+	return headers;
+}
+
 /////////////////////////////////////////////////////////////////////////////////////////
 // static
 void LLViewerMedia::setOpenIDCookie()
diff --git a/indra/newview/llviewermedia.h b/indra/newview/llviewermedia.h
index aeac6ba29ae..0b69b8f0c1c 100644
--- a/indra/newview/llviewermedia.h
+++ b/indra/newview/llviewermedia.h
@@ -162,6 +162,8 @@ class LLViewerMedia
 	static LLPluginClassMedia* getSpareBrowserMediaSource();
 
 	static void setOnlyAudibleMediaTextureID(const LLUUID& texture_id);
+
+	static LLSD getHeaders();
 	
 private:
 	static void setOpenIDCookie();
-- 
GitLab