From 42f3648814923edad8a040620cb3db233597cbb9 Mon Sep 17 00:00:00 2001
From: Todd Stinson <stinson@lindenlab.com>
Date: Mon, 11 Jun 2012 18:59:51 -0700
Subject: [PATCH] PATH-705: First pass at removing the agent state
 functionality. WIP -- still need to remove XXX_STINSON_AGENT_STATE_DELETE_ME
 ifdef'ed code.

---
 indra/newview/llpanelobject.cpp               |   7 -
 indra/newview/llpanelobject.h                 |   2 -
 indra/newview/llpathfindingmanager.cpp        | 125 ++++--------------
 indra/newview/llpathfindingmanager.h          |  49 +++----
 .../skins/default/xui/en/notifications.xml    |  19 ---
 5 files changed, 41 insertions(+), 161 deletions(-)

diff --git a/indra/newview/llpanelobject.cpp b/indra/newview/llpanelobject.cpp
index 0473866ac0c..3786480f2e8 100644
--- a/indra/newview/llpanelobject.cpp
+++ b/indra/newview/llpanelobject.cpp
@@ -279,8 +279,6 @@ BOOL	LLPanelObject::postBuild()
 	mCtrlSculptInvert = getChild<LLCheckBoxCtrl>("sculpt invert control");
 	childSetCommitCallback("sculpt invert control", onCommitSculptType, this);
 
-	LLPathfindingManager::getInstance()->registerAgentStateListener(boost::bind(&LLPanelObject::handleAgentStateCallback, this));
-	
 	// Start with everyone disabled
 	clearCtrls();
 
@@ -1995,11 +1993,6 @@ void LLPanelObject::onCommitSculpt( const LLSD& data )
 	sendSculpt();
 }
 
-void LLPanelObject::handleAgentStateCallback() const
-{
-	gFloaterTools->dirty();
-}
-
 BOOL LLPanelObject::onDropSculpt(LLInventoryItem* item)
 {
     LLTextureCtrl* mTextureCtrl = getChild<LLTextureCtrl>("sculpt texture control");
diff --git a/indra/newview/llpanelobject.h b/indra/newview/llpanelobject.h
index 307d63aada5..34a19b3dfa9 100644
--- a/indra/newview/llpanelobject.h
+++ b/indra/newview/llpanelobject.h
@@ -75,8 +75,6 @@ class LLPanelObject : public LLPanel
 	BOOL     		onDropSculpt(LLInventoryItem* item);
 	static void     onCommitSculptType(    LLUICtrl *ctrl, void* userdata);
 
-	void            handleAgentStateCallback() const;
-	
 protected:
 	void			getState();
 
diff --git a/indra/newview/llpathfindingmanager.cpp b/indra/newview/llpathfindingmanager.cpp
index 9893121980a..f54c9892dfe 100644
--- a/indra/newview/llpathfindingmanager.cpp
+++ b/indra/newview/llpathfindingmanager.cpp
@@ -53,22 +53,24 @@
 #include "llviewerregion.h"
 #include "llweb.h"
 
-#define CAP_SERVICE_RETRIEVE_NAVMESH  "RetrieveNavMeshSrc"
+#define CAP_SERVICE_RETRIEVE_NAVMESH      "RetrieveNavMeshSrc"
 
-#define CAP_SERVICE_NAVMESH_STATUS "NavMeshGenerationStatus"
+#define CAP_SERVICE_NAVMESH_STATUS        "NavMeshGenerationStatus"
 
-#define CAP_SERVICE_AGENT_STATE     "AgentPreferences"
-#define ALTER_NAVMESH_OBJECTS_FIELD "alter_navmesh_objects"
+#define CAP_SERVICE_OBJECT_LINKSETS       "ObjectNavMeshProperties"
+#define CAP_SERVICE_TERRAIN_LINKSETS      "TerrainNavMeshProperties"
 
-#define CAP_SERVICE_OBJECT_LINKSETS  "ObjectNavMeshProperties"
-#define CAP_SERVICE_TERRAIN_LINKSETS "TerrainNavMeshProperties"
-
-#define CAP_SERVICE_CHARACTERS  "CharacterProperties"
+#define CAP_SERVICE_CHARACTERS            "CharacterProperties"
 
 #define SIM_MESSAGE_NAVMESH_STATUS_UPDATE "/message/NavMeshStatusUpdate"
-#define SIM_MESSAGE_AGENT_STATE_UPDATE    "/message/AgentPreferencesUpdate"
 #define SIM_MESSAGE_BODY_FIELD            "body"
 
+#ifdef XXX_STINSON_AGENT_STATE_DELETE_ME
+#define CAP_SERVICE_AGENT_STATE     "AgentPreferences"
+#define ALTER_NAVMESH_OBJECTS_FIELD "alter_navmesh_objects"
+#define SIM_MESSAGE_AGENT_STATE_UPDATE    "/message/AgentPreferencesUpdate"
+#endif // XXX_STINSON_AGENT_STATE_DELETE_ME
+
 //---------------------------------------------------------------------------
 // LLNavMeshSimStateChangeNode
 //---------------------------------------------------------------------------
@@ -81,6 +83,7 @@ class LLNavMeshSimStateChangeNode : public LLHTTPNode
 
 LLHTTPRegistration<LLNavMeshSimStateChangeNode> gHTTPRegistrationNavMeshSimStateChangeNode(SIM_MESSAGE_NAVMESH_STATUS_UPDATE);
 
+#ifdef XXX_STINSON_AGENT_STATE_DELETE_ME
 //---------------------------------------------------------------------------
 // LLAgentStateChangeNode
 //---------------------------------------------------------------------------
@@ -92,6 +95,7 @@ class LLAgentStateChangeNode : public LLHTTPNode
 };
 
 LLHTTPRegistration<LLAgentStateChangeNode> gHTTPRegistrationAgentStateChangeNode(SIM_MESSAGE_AGENT_STATE_UPDATE);
+#endif // XXX_STINSON_AGENT_STATE_DELETE_ME
 
 //---------------------------------------------------------------------------
 // NavMeshStatusResponder
@@ -135,6 +139,7 @@ class NavMeshResponder : public LLHTTPClient::Responder
 	LLPathfindingNavMeshPtr mNavMeshPtr;
 };
 
+#ifdef XXX_STINSON_AGENT_STATE_DELETE_ME
 //---------------------------------------------------------------------------
 // AgentStateResponder
 //---------------------------------------------------------------------------
@@ -154,6 +159,7 @@ class AgentStateResponder : public LLHTTPClient::Responder
 	std::string                       mCapabilityURL;
 	LLPathfindingManager::EAgentState mRequestedAgentState;
 };
+#endif // XXX_STINSON_AGENT_STATE_DELETE_ME
 
 //---------------------------------------------------------------------------
 // LinksetsResponder
@@ -262,10 +268,7 @@ class CharactersResponder : public LLHTTPClient::Responder
 
 LLPathfindingManager::LLPathfindingManager()
 	: LLSingleton<LLPathfindingManager>(),
-	mNavMeshMap(),
-	mAgentStateSignal(),
-	mAgentState(kAgentStateUnknown),
-	mLastKnownNonErrorAgentState(kAgentStateUnknown)
+	mNavMeshMap()
 {
 }
 
@@ -336,51 +339,12 @@ void LLPathfindingManager::requestGetNavMeshForRegion(LLViewerRegion *pRegion)
 	}
 }
 
+#ifdef XXX_STINSON_AGENT_STATE_DELETE_ME
 LLPathfindingManager::agent_state_slot_t LLPathfindingManager::registerAgentStateListener(agent_state_callback_t pAgentStateCallback)
 {
 	return mAgentStateSignal.connect(pAgentStateCallback);
 }
-
-LLPathfindingManager::EAgentState LLPathfindingManager::getAgentState()
-{
-	if (!isPathfindingEnabledForCurrentRegion())
-	{
-		setAgentState(kAgentStateNotEnabled);
-	}
-	else
-	{
-		if (!isValidAgentState(mAgentState))
-		{
-			requestGetAgentState();
-		}
-	}
-
-	return mAgentState;
-}
-
-LLPathfindingManager::EAgentState LLPathfindingManager::getLastKnownNonErrorAgentState() const
-{
-	return mLastKnownNonErrorAgentState;
-}
-
-void LLPathfindingManager::requestSetAgentState(EAgentState pRequestedAgentState)
-{
-	llassert(isValidAgentState(pRequestedAgentState));
-	std::string agentStateURL = getAgentStateURLForCurrentRegion();
-
-	if (agentStateURL.empty())
-	{
-		setAgentState(kAgentStateNotEnabled);
-	}
-	else
-	{
-		LLSD request;
-		request[ALTER_NAVMESH_OBJECTS_FIELD] = static_cast<LLSD::Boolean>(pRequestedAgentState == kAgentStateUnfrozen);
-
-		LLHTTPClient::ResponderPtr responder = new AgentStateResponder(agentStateURL, pRequestedAgentState);
-		LLHTTPClient::post(agentStateURL, request, responder);
-	}
-}
+#endif // XXX_STINSON_AGENT_STATE_DELETE_ME
 
 void LLPathfindingManager::requestGetLinksets(request_id_t pRequestId, object_request_callback_t pLinksetsCallback) const
 {
@@ -623,18 +587,13 @@ LLPathfindingNavMeshPtr LLPathfindingManager::getNavMeshForRegion(LLViewerRegion
 	return getNavMeshForRegion(regionUUID);
 }
 
-bool LLPathfindingManager::isValidAgentState(EAgentState pAgentState)
-{
-	return ((pAgentState == kAgentStateFrozen) || (pAgentState == kAgentStateUnfrozen));
-}
-
+#ifdef XXX_STINSON_AGENT_STATE_DELETE_ME
 void LLPathfindingManager::requestGetAgentState()
 {
 	std::string agentStateURL = getAgentStateURLForCurrentRegion();
 
 	if (agentStateURL.empty())
 	{
-		setAgentState(kAgentStateNotEnabled);
 	}
 	else
 	{
@@ -643,58 +602,25 @@ void LLPathfindingManager::requestGetAgentState()
 	}
 }
 
-void LLPathfindingManager::setAgentState(EAgentState pAgentState)
-{
-	mAgentState = pAgentState;
-
-	if (mAgentState != kAgentStateError)
-	{
-		mLastKnownNonErrorAgentState = mAgentState;
-	}
-
-	mAgentStateSignal(mAgentState);
-}
-
 void LLPathfindingManager::handleAgentStateResult(const LLSD &pContent, EAgentState pRequestedAgentState)
 {
 	llassert(pContent.has(ALTER_NAVMESH_OBJECTS_FIELD));
 	llassert(pContent.get(ALTER_NAVMESH_OBJECTS_FIELD).isBoolean());
 	EAgentState agentState = (pContent.get(ALTER_NAVMESH_OBJECTS_FIELD).asBoolean() ? kAgentStateUnfrozen : kAgentStateFrozen);
 
-	if (isValidAgentState(pRequestedAgentState) && (agentState != pRequestedAgentState))
+	if ((agentState != pRequestedAgentState))
 	{
 		agentState = kAgentStateError;
 		llassert(0);
 	}
-
-	setAgentState(agentState);
 }
 
 void LLPathfindingManager::handleAgentStateError(U32 pStatus, const std::string &pReason, const std::string &pURL)
 {
 	llwarns << "error with request to URL '" << pURL << "' because " << pReason << " (statusCode:" << pStatus << ")" << llendl;
-	setAgentState(kAgentStateError);
 }
+#endif // XXX_STINSON_AGENT_STATE_DELETE_ME
 
-void LLPathfindingManager::handleAgentStateUpdate(const LLSD &pContent)
-{
-	llassert(pContent.has(ALTER_NAVMESH_OBJECTS_FIELD));
-	llassert(pContent.get(ALTER_NAVMESH_OBJECTS_FIELD).isBoolean());
-	EAgentState agentState = (pContent.get(ALTER_NAVMESH_OBJECTS_FIELD).asBoolean() ? kAgentStateUnfrozen : kAgentStateFrozen);
-
-	setAgentState(agentState);
-
-	LLSD substitutions, payload;
-	LLNotificationsUtil::add("AutomaticAgentStateUnfreeze", substitutions, payload, boost::bind(&LLPathfindingManager::handleAgentStateUserNotification, this, _1, _2));
-}
-
-void LLPathfindingManager::handleAgentStateUserNotification(const LLSD &pNotification, const LLSD &pResponse)
-{
-	if (LLNotificationsUtil::getSelectedOption(pNotification, pResponse) == 1)
-	{
-		LLWeb::loadURL(LLTrans::getString("Pathfinding_Wiki_URL"));
-	}
-}
 
 std::string LLPathfindingManager::getNavMeshStatusURLForRegion(LLViewerRegion *pRegion) const
 {
@@ -706,11 +632,6 @@ std::string LLPathfindingManager::getRetrieveNavMeshURLForRegion(LLViewerRegion
 	return getCapabilityURLForRegion(pRegion, CAP_SERVICE_RETRIEVE_NAVMESH);
 }
 
-std::string LLPathfindingManager::getAgentStateURLForCurrentRegion() const
-{
-	return getCapabilityURLForCurrentRegion(CAP_SERVICE_AGENT_STATE);
-}
-
 std::string LLPathfindingManager::getObjectLinksetsURLForCurrentRegion() const
 {
 	return getCapabilityURLForCurrentRegion(CAP_SERVICE_OBJECT_LINKSETS);
@@ -769,6 +690,7 @@ void LLNavMeshSimStateChangeNode::post(ResponsePtr pResponse, const LLSD &pConte
 	LLPathfindingManager::getInstance()->handleNavMeshStatusUpdate(navMeshStatus);
 }
 
+#ifdef XXX_STINSON_AGENT_STATE_DELETE_ME
 //---------------------------------------------------------------------------
 // LLAgentStateChangeNode
 //---------------------------------------------------------------------------
@@ -782,6 +704,7 @@ void LLAgentStateChangeNode::post(ResponsePtr pResponse, const LLSD &pContext, c
 	llassert(pInput.get(SIM_MESSAGE_BODY_FIELD).isMap());
 	LLPathfindingManager::getInstance()->handleAgentStateUpdate(pInput.get(SIM_MESSAGE_BODY_FIELD));
 }
+#endif // XXX_STINSON_AGENT_STATE_DELETE_ME
 
 //---------------------------------------------------------------------------
 // NavMeshStatusResponder
@@ -845,6 +768,7 @@ void NavMeshResponder::error(U32 pStatus, const std::string& pReason)
 	mNavMeshPtr->handleNavMeshError(pStatus, pReason, mCapabilityURL, mNavMeshVersion);
 }
 
+#ifdef XXX_STINSON_AGENT_STATE_DELETE_ME
 //---------------------------------------------------------------------------
 // AgentStateResponder
 //---------------------------------------------------------------------------
@@ -869,6 +793,7 @@ void AgentStateResponder::error(U32 pStatus, const std::string &pReason)
 {
 	LLPathfindingManager::getInstance()->handleAgentStateError(pStatus, pReason, mCapabilityURL);
 }
+#endif // XXX_STINSON_AGENT_STATE_DELETE_ME
 
 //---------------------------------------------------------------------------
 // LinksetsResponder
diff --git a/indra/newview/llpathfindingmanager.h b/indra/newview/llpathfindingmanager.h
index 3aafef35659..40c0e6b140f 100644
--- a/indra/newview/llpathfindingmanager.h
+++ b/indra/newview/llpathfindingmanager.h
@@ -46,24 +46,10 @@ class LLPathfindingNavMeshStatus;
 class LLPathfindingManager : public LLSingleton<LLPathfindingManager>
 {
 	friend class LLNavMeshSimStateChangeNode;
-	friend class LLAgentStateChangeNode;
 	friend class NavMeshStatusResponder;
-	friend class AgentStateResponder;
 public:
 	typedef std::map<LLUUID, LLPathfindingNavMeshPtr> NavMeshMap;
 
-	typedef enum {
-		kAgentStateUnknown,
-		kAgentStateFrozen,
-		kAgentStateUnfrozen,
-		kAgentStateNotEnabled,
-		kAgentStateError
-	} EAgentState;
-
-	typedef boost::function<void (EAgentState)>         agent_state_callback_t;
-	typedef boost::signals2::signal<void (EAgentState)> agent_state_signal_t;
-	typedef boost::signals2::connection                 agent_state_slot_t;
-
 	typedef enum {
 		kRequestStarted,
 		kRequestCompleted,
@@ -86,11 +72,6 @@ class LLPathfindingManager : public LLSingleton<LLPathfindingManager>
 	LLPathfindingNavMesh::navmesh_slot_t registerNavMeshListenerForRegion(LLViewerRegion *pRegion, LLPathfindingNavMesh::navmesh_callback_t pNavMeshCallback);
 	void requestGetNavMeshForRegion(LLViewerRegion *pRegion);
 
-	agent_state_slot_t registerAgentStateListener(agent_state_callback_t pAgentStateCallback);
-	EAgentState        getAgentState();
-	EAgentState        getLastKnownNonErrorAgentState() const;
-	void               requestSetAgentState(EAgentState pAgentState);
-
 	typedef U32 request_id_t;
 	typedef boost::function<void (request_id_t, ERequestStatus, LLPathfindingObjectListPtr)> object_request_callback_t;
 
@@ -99,6 +80,16 @@ class LLPathfindingManager : public LLSingleton<LLPathfindingManager>
 
 	void requestGetCharacters(request_id_t pRequestId, object_request_callback_t pCharactersCallback) const;
 
+#ifdef XXX_STINSON_AGENT_STATE_DELETE_ME
+	friend class LLAgentStateChangeNode;
+	friend class AgentStateResponder;
+	typedef boost::function<void (EAgentState)>         agent_state_callback_t;
+	typedef boost::signals2::signal<void (EAgentState)> agent_state_signal_t;
+	typedef boost::signals2::connection                 agent_state_slot_t;
+
+	agent_state_slot_t registerAgentStateListener(agent_state_callback_t pAgentStateCallback);
+#endif // XXX_STINSON_AGENT_STATE_DELETE_ME
+
 protected:
 
 private:
@@ -114,18 +105,8 @@ class LLPathfindingManager : public LLSingleton<LLPathfindingManager>
 	LLPathfindingNavMeshPtr getNavMeshForRegion(const LLUUID &pRegionUUID);
 	LLPathfindingNavMeshPtr getNavMeshForRegion(LLViewerRegion *pRegion);
 
-	static bool isValidAgentState(EAgentState pAgentState);
-
-	void requestGetAgentState();
-	void setAgentState(EAgentState pAgentState);
-	void handleAgentStateResult(const LLSD &pContent, EAgentState pRequestedAgentState);
-	void handleAgentStateError(U32 pStatus, const std::string &pReason, const std::string &pURL);
-	void handleAgentStateUpdate(const LLSD &pContent);
-	void handleAgentStateUserNotification(const LLSD &pNotification, const LLSD &pResponse);
-
 	std::string getNavMeshStatusURLForRegion(LLViewerRegion *pRegion) const;
 	std::string getRetrieveNavMeshURLForRegion(LLViewerRegion *pRegion) const;
-	std::string getAgentStateURLForCurrentRegion() const;
 	std::string getObjectLinksetsURLForCurrentRegion() const;
 	std::string getTerrainLinksetsURLForCurrentRegion() const;
 	std::string getCharactersURLForCurrentRegion() const;
@@ -134,11 +115,13 @@ class LLPathfindingManager : public LLSingleton<LLPathfindingManager>
 	std::string    getCapabilityURLForRegion(LLViewerRegion *pRegion, const std::string &pCapabilityName) const;
 	LLViewerRegion *getCurrentRegion() const;
 
-	NavMeshMap           mNavMeshMap;
+#ifdef XXX_STINSON_AGENT_STATE_DELETE_ME
+	void requestGetAgentState();
+	void handleAgentStateResult(const LLSD &pContent, EAgentState pRequestedAgentState);
+	void handleAgentStateError(U32 pStatus, const std::string &pReason, const std::string &pURL);
+#endif // XXX_STINSON_AGENT_STATE_DELETE_ME
 
-	agent_state_signal_t mAgentStateSignal;
-	EAgentState          mAgentState;
-	EAgentState          mLastKnownNonErrorAgentState;
+	NavMeshMap mNavMeshMap;
 };
 
 #endif // LL_LLPATHFINDINGMANAGER_H
diff --git a/indra/newview/skins/default/xui/en/notifications.xml b/indra/newview/skins/default/xui/en/notifications.xml
index af00d66ff93..62b2642b34a 100644
--- a/indra/newview/skins/default/xui/en/notifications.xml
+++ b/indra/newview/skins/default/xui/en/notifications.xml
@@ -1291,25 +1291,6 @@ The region [REGION] does not allow terraforming.
   <tag>fail</tag>
   </notification>
 
-  <notification
-   icon="alertmodal.tga"
-   name="AutomaticAgentStateUnfreeze"
-   type="alertmodal">
-You have automatically switched into Unfrozen mode because of one of the following reasons:
-
-- You rezzed an object marked as permanent
-- You returned an object marked as permanent
-
-After you finish modifying your permanent objects, please remember to switch back to Frozen mode  from the menu option Build->Pathfinding->Basic Setup.
-    <tag>confirm</tag>
-    <usetemplate
-      name="okhelpignore"
-      yestext="OK"
-      helptext="More Info"
-      ignoretext="Launch browser to view pathfinding help"
-      />
-  </notification>
-
   <notification
    icon="alertmodal.tga"
    name="CannotCopyWarning"
-- 
GitLab