From df4d167cd13fd89a85e4d30dca94e40c934707d7 Mon Sep 17 00:00:00 2001
From: Josh Bell <josh@lindenlab.com>
Date: Fri, 21 Dec 2007 06:44:41 +0000
Subject: [PATCH] svn merge -r74200:76302
 svn+ssh://svn.lindenlab.com/svn/linden/branches/Branch_1-18-6-Viewer -->
 release

Wheee, this was fun. Um, let's back-port fixes a little more rapidly next time. Reviewed by CG until alexandria died, did the rest by my lonesome.
---
 indra/llcommon/indra_constants.h              |   2 +-
 indra/llcommon/llstring.cpp                   |  58 ++++--
 indra/llcommon/llstring.h                     |  32 +++-
 indra/llcommon/llsys.cpp                      |  77 +++++---
 indra/llcommon/llsys.h                        |   2 +
 indra/llcommon/llversionviewer.h              |   2 +-
 indra/llmath/llvolume.cpp                     |  32 ++--
 indra/llmessage/llhttpclient.cpp              |   5 +
 indra/llmessage/llhttpclient.h                |   1 +
 indra/llmessage/lltemplatemessagereader.cpp   |   6 +-
 indra/llmessage/llurlrequest.cpp              |   7 +
 indra/llmessage/llurlrequest.h                |   1 +
 indra/llui/llfloater.cpp                      |  23 ++-
 indra/llui/llfloater.h                        |   3 +-
 indra/llvfs/lldir.cpp                         |   8 +
 indra/llvfs/lldir.h                           |   3 +-
 indra/llwindow/llwindowwin32.cpp              |  22 +--
 indra/mac_crash_logger/llcrashloggermac.cpp   |  78 +++++---
 indra/newview/English.lproj/InfoPlist.strings |   4 +-
 indra/newview/Info-SecondLife.plist           |   2 +-
 indra/newview/llappviewer.cpp                 | 174 ++++++++++++++----
 indra/newview/llappviewer.h                   |   7 +-
 indra/newview/llfloaterland.cpp               |   2 +-
 indra/newview/llfloaterreporter.cpp           |   2 +-
 indra/newview/llfolderview.cpp                |  31 +++-
 indra/newview/llfolderview.h                  |   3 +
 indra/newview/llinventorybridge.h             |   1 +
 indra/newview/llpanelavatar.cpp               |  11 +-
 indra/newview/llpanelclassified.cpp           |  62 ++++++-
 indra/newview/llpanelclassified.h             |   2 +-
 indra/newview/llpanellogin.cpp                | 127 ++++++++++---
 indra/newview/llpanellogin.h                  |   9 +
 indra/newview/llselectmgr.cpp                 |   3 +-
 indra/newview/llstartup.cpp                   |  46 ++++-
 indra/newview/lltexturectrl.cpp               |   6 -
 indra/newview/llvieweraudio.cpp               |  16 +-
 indra/newview/llviewermenu.cpp                | 102 +++++-----
 indra/newview/llviewermessage.cpp             |  17 +-
 indra/newview/llviewernetwork.cpp             |  28 +++
 indra/newview/llviewernetwork.h               |   7 +
 indra/newview/llviewerobject.cpp              |  18 +-
 indra/newview/llviewerstats.cpp               |  33 +++-
 indra/newview/llviewerstats.h                 |   3 +
 indra/newview/llviewertexteditor.cpp          |   5 +-
 indra/newview/llviewerwindow.cpp              |  73 ++++++--
 indra/newview/llviewerwindow.h                |   1 +
 indra/newview/llvoavatar.cpp                  |   5 +-
 indra/newview/llvovolume.cpp                  |   3 +-
 indra/newview/llwindebug.cpp                  |  59 +++---
 indra/test/llhttpclient_tut.cpp               |   8 +
 indra/win_crash_logger/StdAfx.h               |   3 -
 .../win_crash_logger/llcrashloggerwindows.cpp |  72 +++++---
 52 files changed, 943 insertions(+), 364 deletions(-)

diff --git a/indra/llcommon/indra_constants.h b/indra/llcommon/indra_constants.h
index b7d35780ae0..0195893b160 100644
--- a/indra/llcommon/indra_constants.h
+++ b/indra/llcommon/indra_constants.h
@@ -336,7 +336,7 @@ const U32 MAP_ITEM_CLASSIFIED = 0x08;
 
 // Crash reporter behavior
 const char* const CRASH_SETTINGS_FILE = "crash_settings.xml";
-const char* const CRASH_BEHAVIOR_SETTING = "CrashBehavior";
+const char* const CRASH_BEHAVIOR_SETTING = "CrashLogBehavior";
 const S32 CRASH_BEHAVIOR_ASK = 0;
 const S32 CRASH_BEHAVIOR_ALWAYS_SEND = 1;
 const S32 CRASH_BEHAVIOR_NEVER_SEND = 2;
diff --git a/indra/llcommon/llstring.cpp b/indra/llcommon/llstring.cpp
index 9895a684b2a..a688bc1c6fd 100644
--- a/indra/llcommon/llstring.cpp
+++ b/indra/llcommon/llstring.cpp
@@ -34,6 +34,13 @@
 #include "llstring.h"
 #include "llerror.h"
 
+#if LL_WINDOWS
+#define WIN32_LEAN_AND_MEAN
+#include <winsock2.h>
+#include <windows.h>
+#include <winnls.h> // for WideCharToMultiByte
+#endif
+
 std::string ll_safe_string(const char* in)
 {
 	if(in) return std::string(in);
@@ -796,19 +803,7 @@ std::string utf8str_removeCRLF(const std::string& utf8str)
 }
 
 #if LL_WINDOWS
-/* If the size of the passed in buffer is not large enough to hold the string,
- * two bad things happen:
- * 1. resulting formatted string is NOT null terminated
- * 2. Depending on the platform, the return value could be a) the required
- *    size of the buffer to copy the entire formatted string or b) -1.
- *    On Windows with VS.Net 2003, it returns -1 e.g. 
- *
- * safe_snprintf always adds a NULL terminator so that the caller does not
- * need to check for return value or need to add the NULL terminator.
- * It does not, however change the return value - to let the caller know
- * that the passed in buffer size was not large enough to hold the formatted string.
- *
- */
+// documentation moved to header. Phoenix 2007-11-27
 int safe_snprintf(char *str, size_t size, const char *format, ...)
 {
 	va_list args;
@@ -820,6 +815,43 @@ int safe_snprintf(char *str, size_t size, const char *format, ...)
 	str[size-1] = '\0'; // always null terminate
 	return num_written;
 }
+
+std::string ll_convert_wide_to_string(const wchar_t* in)
+{
+	std::string out;
+	if(in)
+	{
+		int len_in = wcslen(in);
+		int len_out = WideCharToMultiByte(
+			CP_ACP,
+			0,
+			in,
+			len_in,
+			NULL,
+			0,
+			0,
+			0);
+		// We will need two more bytes for the double NULL ending
+		// created in WideCharToMultiByte().
+		char* pout = new char [len_out + 2];
+		memset(pout, 0, len_out + 2);
+		if(pout)
+		{
+			WideCharToMultiByte(
+				CP_ACP,
+				0,
+				in,
+				len_in,
+				pout,
+				len_out,
+				0,
+				0);
+			out.assign(pout);
+			delete[] pout;
+		}
+	}
+	return out;
+}
 #endif // LL_WINDOWS
 
 S32	LLStringOps::collate(const llwchar* a, const llwchar* b)
diff --git a/indra/llcommon/llstring.h b/indra/llcommon/llstring.h
index e2f605db4f3..88d7e88edc7 100644
--- a/indra/llcommon/llstring.h
+++ b/indra/llcommon/llstring.h
@@ -494,7 +494,37 @@ std::ostream& operator<<(std::ostream &s, const LLStringBase<T> &str)
 std::ostream& operator<<(std::ostream &s, const LLWString &wstr);
 
 #if LL_WINDOWS
-int safe_snprintf(char *str, size_t size, const char *format, ...);
+/* @name Windows string helpers
+ */
+//@{
+
+/**
+ * @brief Implementation the expected snprintf interface.
+ *
+ * If the size of the passed in buffer is not large enough to hold the string,
+ * two bad things happen:
+ * 1. resulting formatted string is NOT null terminated
+ * 2. Depending on the platform, the return value could be a) the required
+ *    size of the buffer to copy the entire formatted string or b) -1.
+ *    On Windows with VS.Net 2003, it returns -1 e.g. 
+ *
+ * safe_snprintf always adds a NULL terminator so that the caller does not
+ * need to check for return value or need to add the NULL terminator.
+ * It does not, however change the return value - to let the caller know
+ * that the passed in buffer size was not large enough to hold the
+ * formatted string.
+ *
+ */
+int safe_snprintf(char* str, size_t size, const char* format, ...);
+
+/**
+ * @brief Convert a wide string to std::string
+ *
+ * This replaces the unsafe W2A macro from ATL.
+ */
+std::string ll_convert_wide_to_string(const wchar_t* in);
+
+//@}
 #endif // LL_WINDOWS
 
 /**
diff --git a/indra/llcommon/llsys.cpp b/indra/llcommon/llsys.cpp
index 3b57db772c1..7346b29fb17 100644
--- a/indra/llcommon/llsys.cpp
+++ b/indra/llcommon/llsys.cpp
@@ -65,8 +65,7 @@ static const S32 CPUINFO_BUFFER_SIZE = 16383;
 LLCPUInfo gSysCPU;
 
 LLOSInfo::LLOSInfo() :
-	mMajorVer(0), mMinorVer(0), mBuild(0),
-	mOSString("")
+	mMajorVer(0), mMinorVer(0), mBuild(0)
 {
 
 #if LL_WINDOWS
@@ -94,27 +93,28 @@ LLOSInfo::LLOSInfo() :
 			// Test for the product.
 			if(osvi.dwMajorVersion <= 4)
 			{
-				mOSString = "Microsoft Windows NT ";
+				mOSStringSimple = "Microsoft Windows NT ";
 			}
 			else if(osvi.dwMajorVersion == 5 && osvi.dwMinorVersion == 0)
 			{
-				mOSString = "Microsoft Windows 2000 ";
+				mOSStringSimple = "Microsoft Windows 2000 ";
 			}
 			else if(osvi.dwMajorVersion ==5 && osvi.dwMinorVersion == 1)
 			{
-				mOSString = "Microsoft Windows XP ";
+				mOSStringSimple = "Microsoft Windows XP ";
 			}
 			else if(osvi.dwMajorVersion == 5 && osvi.dwMinorVersion == 2)
 			{
 				 if(osvi.wProductType == VER_NT_WORKSTATION)
-					mOSString = "Microsoft Windows XP x64 Edition ";
-				 else mOSString = "Microsoft Windows Server 2003 ";
+					mOSStringSimple = "Microsoft Windows XP x64 Edition ";
+				 else
+					 mOSStringSimple = "Microsoft Windows Server 2003 ";
 			}
 			else if(osvi.dwMajorVersion == 6 && osvi.dwMinorVersion == 0)
 			{
 				 if(osvi.wProductType == VER_NT_WORKSTATION)
-					mOSString = "Microsoft Windows Vista ";
-				 else mOSString = "Microsoft Windows Vista Server ";
+					mOSStringSimple = "Microsoft Windows Vista ";
+				 else mOSStringSimple = "Microsoft Windows Vista Server ";
 			}
 			else   // Use the registry on early versions of Windows NT.
 			{
@@ -129,15 +129,15 @@ LLOSInfo::LLOSInfo() :
 				RegCloseKey( hKey );
 				if ( lstrcmpi( L"WINNT", szProductType) == 0 )
 				{
-					mOSString += "Professional ";
+					mOSStringSimple += "Professional ";
 				}
 				else if ( lstrcmpi( L"LANMANNT", szProductType) == 0 )
 				{
-					mOSString += "Server ";
+					mOSStringSimple += "Server ";
 				}
 				else if ( lstrcmpi( L"SERVERNT", szProductType) == 0 )
 				{
-					mOSString += "Advanced Server ";
+					mOSStringSimple += "Advanced Server ";
 				}
 			}
 
@@ -164,7 +164,7 @@ LLOSInfo::LLOSInfo() :
 					csdversion.c_str(),
 					(osvi.dwBuildNumber & 0xffff));	 
 			}
-			mOSString += tmp;
+			mOSString = mOSStringSimple + tmp;
 		}
 		break;
 
@@ -172,41 +172,65 @@ LLOSInfo::LLOSInfo() :
 		// Test for the Windows 95 product family.
 		if(osvi.dwMajorVersion == 4 && osvi.dwMinorVersion == 0)
 		{
-			mOSString = "Microsoft Windows 95 ";
+			mOSStringSimple = "Microsoft Windows 95 ";
 			if ( osvi.szCSDVersion[1] == 'C' || osvi.szCSDVersion[1] == 'B' )
 			{
-                mOSString += "OSR2 ";
+                mOSStringSimple += "OSR2 ";
 			}
 		} 
 		if(osvi.dwMajorVersion == 4 && osvi.dwMinorVersion == 10)
 		{
-			mOSString = "Microsoft Windows 98 ";
+			mOSStringSimple = "Microsoft Windows 98 ";
 			if ( osvi.szCSDVersion[1] == 'A' )
 			{
-                mOSString += "SE ";
+                mOSStringSimple += "SE ";
 			}
 		} 
 		if(osvi.dwMajorVersion == 4 && osvi.dwMinorVersion == 90)
 		{
-			mOSString = "Microsoft Windows Millennium Edition ";
-		} 
+			mOSStringSimple = "Microsoft Windows Millennium Edition ";
+		}
+		mOSString = mOSStringSimple;
 		break;
 	}
 #else
 	struct utsname un;
-        if(uname(&un) != -1)
+	if(uname(&un) != -1)
 	{
-		mOSString.append(un.sysname);
-		mOSString.append(" ");
-		mOSString.append(un.release);
+		mOSStringSimple.append(un.sysname);
+		mOSStringSimple.append(" ");
+		mOSStringSimple.append(un.release);
+
+		mOSString = mOSStringSimple;
 		mOSString.append(" ");
 		mOSString.append(un.version);
 		mOSString.append(" ");
 		mOSString.append(un.machine);
+
+		// Simplify 'Simple'
+		std::string ostype = mOSStringSimple.substr(0, mOSStringSimple.find_first_of(" ", 0));
+		if (ostype == "Darwin")
+		{
+			// Only care about major Darwin versions, truncate at first '.'
+			S32 idx1 = mOSStringSimple.find_first_of(".", 0);
+			std::string simple = mOSStringSimple.substr(0, idx1);
+			if (simple.length() > 0)
+				mOSStringSimple = simple;
+		}
+		else if (ostype == "Linux")
+		{
+			// Only care about major and minor Linux versions, truncate at second '.'
+			S32 idx1 = mOSStringSimple.find_first_of(".", 0);
+			S32 idx2 = (idx1 != std::string::npos) ? mOSStringSimple.find_first_of(".", idx1+1) : std::string::npos;
+			std::string simple = mOSStringSimple.substr(0, idx2);
+			if (simple.length() > 0)
+				mOSStringSimple = simple;
+		}
 	}
 	else
 	{
-		mOSString.append("Unable to collect OS info");
+		mOSStringSimple.append("Unable to collect OS info");
+		mOSString = mOSStringSimple;
 	}
 #endif
 
@@ -255,6 +279,11 @@ const std::string& LLOSInfo::getOSString() const
 	return mOSString;
 }
 
+const std::string& LLOSInfo::getOSStringSimple() const
+{
+	return mOSStringSimple;
+}
+
 const S32 STATUS_SIZE = 8192;
 
 //static
diff --git a/indra/llcommon/llsys.h b/indra/llcommon/llsys.h
index fc4e02763c7..332d62c1861 100644
--- a/indra/llcommon/llsys.h
+++ b/indra/llcommon/llsys.h
@@ -51,6 +51,7 @@ class LLOSInfo
 	void stream(std::ostream& s) const;
 
 	const std::string& getOSString() const;
+	const std::string& getOSStringSimple() const;
 
 	S32 mMajorVer;
 	S32 mMinorVer;
@@ -64,6 +65,7 @@ class LLOSInfo
 	static U32 getProcessResidentSizeKB();
 private:
 	std::string mOSString;
+	std::string mOSStringSimple;
 };
 
 
diff --git a/indra/llcommon/llversionviewer.h b/indra/llcommon/llversionviewer.h
index f9f3bf20874..e041bc52a9e 100644
--- a/indra/llcommon/llversionviewer.h
+++ b/indra/llcommon/llversionviewer.h
@@ -35,7 +35,7 @@
 const S32 LL_VERSION_MAJOR = 1;
 const S32 LL_VERSION_MINOR = 18;
 const S32 LL_VERSION_PATCH = 6;
-const S32 LL_VERSION_BUILD = 0;
+const S32 LL_VERSION_BUILD = 2;
 
 const char * const LL_CHANNEL = "Second Life Release";
 
diff --git a/indra/llmath/llvolume.cpp b/indra/llmath/llvolume.cpp
index 7c8fe86d2b2..037357c92ee 100644
--- a/indra/llmath/llvolume.cpp
+++ b/indra/llmath/llvolume.cpp
@@ -1659,6 +1659,8 @@ LLVolume::~LLVolume()
 
 BOOL LLVolume::generate()
 {
+	llassert_always(mProfilep);
+	
 	//Added 10.03.05 Dave Parks
 	// Split is a parameter to LLProfile::generate that tesselates edges on the profile 
 	// to prevent lighting and texture interpolation errors on triangles that are 
@@ -1702,41 +1704,38 @@ BOOL LLVolume::generate()
 		mMesh.resize(mProfilep->mProfile.size() * mPathp->mPath.size());
 		sNumMeshPoints += mMesh.size();
 
-		S32 s = 0, t=0;
 		S32 sizeS = mPathp->mPath.size();
 		S32 sizeT = mProfilep->mProfile.size();
-		S32 line  = 0;
 
 		//generate vertex positions
 
 		// Run along the path.
-		while (s < sizeS)
+		for (S32 s = 0; s < sizeS; ++s)
 		{
 			LLVector2  scale = mPathp->mPath[s].mScale;
 			LLQuaternion rot = mPathp->mPath[s].mRot;
 
-			t = 0;
 			// Run along the profile.
-			while (t < sizeT)
+			for (S32 t = 0; t < sizeT; ++t)
 			{
-				S32 i = t + line;
-				Point& pt = mMesh[i];
+				S32 m = s*sizeT + t;
+				Point& pt = mMesh[m];
 				
 				pt.mPos.mV[0] = mProfilep->mProfile[t].mV[0] * scale.mV[0];
 				pt.mPos.mV[1] = mProfilep->mProfile[t].mV[1] * scale.mV[1];
 				pt.mPos.mV[2] = 0.0f;
 				pt.mPos       = pt.mPos * rot;
 				pt.mPos      += mPathp->mPath[s].mPos;
-				t++;
 			}
-			line += sizeT;
-			s++;
 		}
 
-		for (S32 i = 0; i < (S32)mProfilep->mFaces.size(); i++)
+		for (std::vector<LLProfile::Face>::iterator iter = mProfilep->mFaces.begin();
+			 iter != mProfilep->mFaces.end(); ++iter)
 		{
-			mFaceMask |= mProfilep->mFaces[i].mFaceID;
+			LLFaceID id = iter->mFaceID;
+			mFaceMask |= id;
 		}
+		
 		return TRUE;
 	}
 	return FALSE;
@@ -1857,7 +1856,6 @@ void LLVolume::sculpt(U16 sculpt_width, U16 sculpt_height, S8 sculpt_components,
 
 	mPathp->generate(mDetail, 0, TRUE);
 	mProfilep->generate(mPathp->isOpen(), mDetail, 0, TRUE);
-
 	
 	S32 sizeS = mPathp->mPath.size();
 	S32 sizeT = mProfilep->mProfile.size();
@@ -1871,6 +1869,7 @@ void LLVolume::sculpt(U16 sculpt_width, U16 sculpt_height, S8 sculpt_components,
 	if (!data_is_empty)
 	{
 		for (S32 s = 0; s < sizeS - 1; s++)
+		{
 			for (S32 t = 0; t < sizeT - 1; t++)
 			{
 				// first coordinate
@@ -1896,7 +1895,7 @@ void LLVolume::sculpt(U16 sculpt_width, U16 sculpt_height, S8 sculpt_components,
 				LLVector3 cross = (p1 - p2) % (p1 - p3);
 				area += cross.magVec();
 			}
-		
+		}
 		if (area < SCULPT_MIN_AREA)
 			data_is_empty = TRUE;
 	}
@@ -1926,8 +1925,7 @@ void LLVolume::sculpt(U16 sculpt_width, U16 sculpt_height, S8 sculpt_components,
 			}
 			line += sizeT;
 		}
-	}
-	
+	}	
 	else
 	{
 		S32 line = 0;
@@ -1986,8 +1984,6 @@ void LLVolume::sculpt(U16 sculpt_width, U16 sculpt_height, S8 sculpt_components,
 					}
 				}
 
-
-				
 				U32 index = (x + y * sculpt_width) * sculpt_components;
 				pt.mPos = sculpt_rgb_to_vector(sculpt_data[index], sculpt_data[index+1], sculpt_data[index+2]);
 			}
diff --git a/indra/llmessage/llhttpclient.cpp b/indra/llmessage/llhttpclient.cpp
index 7144f1313e0..bf5fa4073d5 100644
--- a/indra/llmessage/llhttpclient.cpp
+++ b/indra/llmessage/llhttpclient.cpp
@@ -325,6 +325,11 @@ static void request(
     request(url, method, body_injector, responder, LLSD(), timeout);
 }
 
+void LLHTTPClient::head(const std::string& url, ResponderPtr responder, const F32 timeout)
+{
+	request(url, LLURLRequest::HTTP_HEAD, NULL, responder, timeout);
+}
+
 void LLHTTPClient::get(const std::string& url, ResponderPtr responder, const LLSD& headers, const F32 timeout)
 {
 	request(url, LLURLRequest::HTTP_GET, NULL, responder, headers, timeout);
diff --git a/indra/llmessage/llhttpclient.h b/indra/llmessage/llhttpclient.h
index 8c2309cccaf..6323defb76c 100644
--- a/indra/llmessage/llhttpclient.h
+++ b/indra/llmessage/llhttpclient.h
@@ -89,6 +89,7 @@ class LLHTTPClient
 
 	typedef boost::intrusive_ptr<Responder>	ResponderPtr;
 	
+	static void head(const std::string& url, ResponderPtr, const F32 timeout=HTTP_REQUEST_EXPIRY_SECS);
 	static void get(const std::string& url, ResponderPtr, const F32 timeout=HTTP_REQUEST_EXPIRY_SECS);
 	static void get(const std::string& url, ResponderPtr, const LLSD& headers, const F32 timeout=HTTP_REQUEST_EXPIRY_SECS);
 	static void get(const std::string& url, const LLSD& query, ResponderPtr, const F32 timeout=HTTP_REQUEST_EXPIRY_SECS);
diff --git a/indra/llmessage/lltemplatemessagereader.cpp b/indra/llmessage/lltemplatemessagereader.cpp
index 114c312aea7..f9b703b52a4 100644
--- a/indra/llmessage/lltemplatemessagereader.cpp
+++ b/indra/llmessage/lltemplatemessagereader.cpp
@@ -753,9 +753,9 @@ BOOL LLTemplateMessageReader::validateMessage(const U8* buffer,
 	if(result)
 	{
 		mCurrentRMessageTemplate->mReceiveCount++;
-		lldebugst(LLERR_MESSAGE) << "MessageRecvd:" 
-								 << mCurrentRMessageTemplate->mName 
-								 << " from " << sender << llendl;
+		//lldebugs << "MessageRecvd:" 
+		//						 << mCurrentRMessageTemplate->mName 
+		//						 << " from " << sender << llendl;
 	}
 	return result;
 }
diff --git a/indra/llmessage/llurlrequest.cpp b/indra/llmessage/llurlrequest.cpp
index 6a09a8bbecc..42a64bdede6 100644
--- a/indra/llmessage/llurlrequest.cpp
+++ b/indra/llmessage/llurlrequest.cpp
@@ -428,6 +428,13 @@ bool LLURLRequest::configure()
 		NULL);
 	switch(mAction)
 	{
+	case HTTP_HEAD:
+		curl_easy_setopt(mDetail->mCurl, CURLOPT_HEADER, 1);
+		curl_easy_setopt(mDetail->mCurl, CURLOPT_NOBODY, 1);
+		curl_easy_setopt(mDetail->mCurl, CURLOPT_FOLLOWLOCATION, 1);
+		rv = true;
+		break;
+
 	case HTTP_GET:
 		curl_easy_setopt(mDetail->mCurl, CURLOPT_HTTPGET, 1);
 		curl_easy_setopt(mDetail->mCurl, CURLOPT_FOLLOWLOCATION, 1);
diff --git a/indra/llmessage/llurlrequest.h b/indra/llmessage/llurlrequest.h
index 7cb6b6a6184..5bdb6a1e69c 100644
--- a/indra/llmessage/llurlrequest.h
+++ b/indra/llmessage/llurlrequest.h
@@ -71,6 +71,7 @@ class LLURLRequest : public LLIOPipe
 	enum ERequestAction
 	{
 		INVALID,
+		HTTP_HEAD,
 		HTTP_GET,
 		HTTP_PUT,
 		HTTP_POST,
diff --git a/indra/llui/llfloater.cpp b/indra/llui/llfloater.cpp
index 59741a799af..76877c2dc42 100644
--- a/indra/llui/llfloater.cpp
+++ b/indra/llui/llfloater.cpp
@@ -843,7 +843,7 @@ void LLFloater::setMinimized(BOOL minimize)
 			LLView* viewp = *child_it;
 			if (!viewp->getVisible())
 			{
-				mMinimizedHiddenChildren.push_back(viewp);
+				mMinimizedHiddenChildren.push_back(viewp->mViewHandle);
 			}
 			viewp->setVisible(FALSE);
 		}
@@ -906,11 +906,14 @@ void LLFloater::setMinimized(BOOL minimize)
 			viewp->setVisible(TRUE);
 		}
 
-		std::vector<LLView*>::iterator itor = mMinimizedHiddenChildren.begin();
-		while (itor != mMinimizedHiddenChildren.end())
+		std::vector<LLViewHandle>::iterator itor = mMinimizedHiddenChildren.begin();
+		for ( ; itor != mMinimizedHiddenChildren.end(); ++itor)
 		{
-			(*itor)->setVisible(FALSE);
-			++itor;
+			LLView* viewp = LLView::getViewByHandle(*itor);
+			if(viewp)
+			{
+				viewp->setVisible(FALSE);
+			}
 		}
 		mMinimizedHiddenChildren.clear();
 
@@ -2275,14 +2278,22 @@ void LLFloaterView::adjustToFitScreen(LLFloater* floater, BOOL allow_partial_out
 		S32 min_height;
 		floater->getResizeLimits( &min_width, &min_height );
 
+		// Make sure floater isn't already smaller than its min height/width?
 		S32 new_width = llmax( min_width, view_width );
 		S32 new_height = llmax( min_height, view_height );
 
-		if( (new_width > screen_width) || (new_height > screen_height) )
+		if( !allow_partial_outside
+			&& ( (new_width > screen_width)
+			|| (new_height > screen_height) ) )
 		{
+			// We have to force this window to be inside the screen.
 			new_width = llmin(new_width, screen_width);
 			new_height = llmin(new_height, screen_height);
 
+			// Still respect minimum width/height
+			new_width = llmax(new_width, min_width);
+			new_height = llmax(new_height, min_height);
+
 			floater->reshape( new_width, new_height, TRUE );
 
 			// Make sure the damn thing is actually onscreen.
diff --git a/indra/llui/llfloater.h b/indra/llui/llfloater.h
index d0494ea6f03..1d88501b016 100644
--- a/indra/llui/llfloater.h
+++ b/indra/llui/llfloater.h
@@ -286,7 +286,7 @@ friend class LLFloaterView;
 	typedef std::map<LLViewHandle, LLFloater*>::iterator handle_map_iter_t;
 	static handle_map_t	sFloaterMap;
 
-	std::vector<LLView*> mMinimizedHiddenChildren;
+	std::vector<LLViewHandle> mMinimizedHiddenChildren;
 
 	BOOL			mHasBeenDraggedWhileMinimized;
 	S32				mPreviousMinimizedBottom;
@@ -429,3 +429,4 @@ extern LLFloaterView* gFloaterView;
 #endif  // LL_FLOATER_H
 
 
+
diff --git a/indra/llvfs/lldir.cpp b/indra/llvfs/lldir.cpp
index a20b21f743c..ae35b656d6d 100644
--- a/indra/llvfs/lldir.cpp
+++ b/indra/llvfs/lldir.cpp
@@ -324,6 +324,14 @@ std::string LLDir::getExpandedFilename(ELLPath location, const std::string& subd
 		prefix += "skins";
 		break;
 
+	case LL_PATH_HTML:
+		prefix = getAppRODataDir();
+		prefix += mDirDelimiter;
+		prefix += "skins";
+		prefix += mDirDelimiter;
+		prefix += "html";
+		break;
+
 	case LL_PATH_MOZILLA_PROFILE:
 		prefix = getOSUserAppDir();
 		prefix += mDirDelimiter;
diff --git a/indra/llvfs/lldir.h b/indra/llvfs/lldir.h
index b133b7db61b..4426935e5cc 100644
--- a/indra/llvfs/lldir.h
+++ b/indra/llvfs/lldir.h
@@ -49,7 +49,8 @@ typedef enum ELLPath
 	LL_PATH_CHAT_LOGS = 12,
 	LL_PATH_PER_ACCOUNT_CHAT_LOGS = 13,
 	LL_PATH_MOZILLA_PROFILE = 14,
-	LL_PATH_COUNT = 15
+	LL_PATH_HTML = 15,
+	LL_PATH_COUNT = 16
 } ELLPath;
 
 
diff --git a/indra/llwindow/llwindowwin32.cpp b/indra/llwindow/llwindowwin32.cpp
index b8fd9948e3e..736ff9df97d 100644
--- a/indra/llwindow/llwindowwin32.cpp
+++ b/indra/llwindow/llwindowwin32.cpp
@@ -3537,15 +3537,15 @@ void LLWindowWin32::fillCandidateForm(const LLCoordGL& caret, const LLRect& boun
 // Put the IME window at the right place (near current text input).   Point coordinates should be the top of the current text line.
 void LLWindowWin32::setLanguageTextInput( const LLCoordGL & position )
 {
-	if ( LLWinImm::isAvailable() )
-	{		
+	if (sLanguageTextInputAllowed && LLWinImm::isAvailable())
+	{
 		HIMC himc = LLWinImm::getContext(mWindowHandle);
 
 		LLCoordWindow win_pos;
 		convertCoords( position, &win_pos );
 
 		if ( win_pos.mX >= 0 && win_pos.mY >= 0 && 
-			(win_pos.mX >= 0 != sWinIMEWindowPosition.mX ) || (win_pos.mY >= 0 != sWinIMEWindowPosition.mY ) )
+			(win_pos.mX != sWinIMEWindowPosition.mX) || (win_pos.mY != sWinIMEWindowPosition.mY) )
 		{
 			COMPOSITIONFORM ime_form;
 			memset( &ime_form, 0, sizeof(ime_form) );
@@ -3558,22 +3558,6 @@ void LLWindowWin32::setLanguageTextInput( const LLCoordGL & position )
 			sWinIMEWindowPosition.set( win_pos.mX, win_pos.mY );
 		}
 
-		// Input not allowed, make sure it's set to alpha numeric mode
-		if ( !sLanguageTextInputAllowed )
-
-		{
-			if ( LLWinImm::getOpenStatus(himc) )
-			{
-				DWORD conversion_mode = 0;
-				DWORD sentence_mode = 0;
-				LLWinImm::getConversionStatus(himc, &conversion_mode, &sentence_mode);
-				if ( conversion_mode != IME_CMODE_ALPHANUMERIC )
-				{	// Set to no-conversion mode instead of turning it off
-					LLWinImm::setConversionStatus(himc, IME_CMODE_ALPHANUMERIC, IME_SMODE_NONE );
-				}
-			}
-		}
-
 		LLWinImm::releaseContext(mWindowHandle, himc);
 	}
 }
diff --git a/indra/mac_crash_logger/llcrashloggermac.cpp b/indra/mac_crash_logger/llcrashloggermac.cpp
index ba50af9d000..3d8abe58572 100644
--- a/indra/mac_crash_logger/llcrashloggermac.cpp
+++ b/indra/mac_crash_logger/llcrashloggermac.cpp
@@ -116,7 +116,8 @@ OSStatus dialogHandler(EventHandlerCallRef handler, EventRef event, void *userda
 					{
 						// Make sure the string is terminated.
 						buffer[size] = 0;
-						//setUserText(buffer);
+						gUserNotes = buffer;
+
 						llinfos << buffer << llendl;
 					}
 					
@@ -152,6 +153,8 @@ bool LLCrashLoggerMac::init(void)
 {	
 	bool ok = LLCrashLogger::init();
 	if(!ok) return false;
+	if(mCrashBehavior != CRASH_BEHAVIOR_ASK) return true;
+	
 	// Real UI...
 	OSStatus err;
 	
@@ -215,6 +218,7 @@ void LLCrashLoggerMac::gatherPlatformSpecificFiles()
 		{
 			struct stat dw_stat;
 			LLString mBuf;
+			bool isLeopard = false;
 			// Try the 10.3 path first...
 			LLString dw_file_name = LLString(path) + LLString("/CrashReporter/Second Life.crash.log");
 			int res = stat(dw_file_name.c_str(), &dw_stat);
@@ -225,7 +229,27 @@ void LLCrashLoggerMac::gatherPlatformSpecificFiles()
 				dw_file_name = LLString(path) + LLString("/Second Life.crash.log");
 				res = stat(dw_file_name.c_str(), &dw_stat);
 			}
-				
+	
+			if(res)
+			{
+				//10.5: Like 10.3+, except it puts the crash time in the file instead of dividing it up
+				//using asterisks. Get a directory listing, search for files starting with second life,
+				//use the last one found.
+				LLString old_file_name, current_file_name, pathname, mask;
+				pathname = LLString(path) + LLString("/CrashReporter/");
+				mask = "Second Life*";
+				while(gDirUtilp->getNextFileInDir(pathname, mask, current_file_name, false))
+				{
+					old_file_name = current_file_name;
+				}
+				if(old_file_name != "")
+				{
+					dw_file_name = pathname + old_file_name;
+					res=stat(dw_file_name.c_str(), &dw_stat);
+					isLeopard = true;
+				}
+			}
+			
 			if (!res)
 			{
 				std::ifstream fp(dw_file_name.c_str());
@@ -234,29 +258,32 @@ void LLCrashLoggerMac::gatherPlatformSpecificFiles()
 				str << fp.rdbuf();
 				mBuf = str.str();
 				
-				// Crash logs consist of a number of entries, one per crash.
-				// Each entry is preceeded by "**********" on a line by itself.
-				// We want only the most recent (i.e. last) one.
-				const char *sep = "**********";
-				const char *start = mBuf.c_str();
-				const char *cur = start;
-				const char *temp = strstr(cur, sep);
-				
-				while(temp != NULL)
+				if(!isLeopard)
 				{
-					// Skip past the marker we just found
-					cur = temp + strlen(sep);		/* Flawfinder: ignore */
-					
-					// and try to find another
-					temp = strstr(cur, sep);
-				}
+					// Crash logs consist of a number of entries, one per crash.
+					// Each entry is preceeded by "**********" on a line by itself.
+					// We want only the most recent (i.e. last) one.
+					const char *sep = "**********";
+					const char *start = mBuf.c_str();
+					const char *cur = start;
+					const char *temp = strstr(cur, sep);
 				
-				// If there's more than one entry in the log file, strip all but the last one.
-				if(cur != start)
-				{
-					mBuf.erase(0, cur - start);
+					while(temp != NULL)
+					{
+						// Skip past the marker we just found
+						cur = temp + strlen(sep);		/* Flawfinder: ignore */
+						
+						// and try to find another
+						temp = strstr(cur, sep);
+					}
+				
+					// If there's more than one entry in the log file, strip all but the last one.
+					if(cur != start)
+					{
+						mBuf.erase(0, cur - start);
+					}
 				}
-				mDebugLog["CrashInfo"] = mBuf;
+				mCrashInfo["CrashLog"] = mBuf;
 			}
 			else
 			{
@@ -270,10 +297,14 @@ bool LLCrashLoggerMac::mainLoop()
 {
 	OSStatus err = noErr;
 				
-	if(err == noErr)
+	if(err == noErr && mCrashBehavior == CRASH_BEHAVIOR_ASK)
 	{
 		RunAppModalLoopForWindow(gWindow);
 	}
+	else if (mCrashBehavior == CRASH_BEHAVIOR_ALWAYS_SEND)
+	{
+		gSendReport = true;
+	}
 	
 	if(gRememberChoice)
 	{
@@ -283,6 +314,7 @@ bool LLCrashLoggerMac::mainLoop()
 	
 	if(gSendReport)
 	{
+		setUserText(gUserNotes);
 		sendCrashLogs();
 	}		
 	
diff --git a/indra/newview/English.lproj/InfoPlist.strings b/indra/newview/English.lproj/InfoPlist.strings
index 85f7e2530fa..a4383ffbeb7 100644
--- a/indra/newview/English.lproj/InfoPlist.strings
+++ b/indra/newview/English.lproj/InfoPlist.strings
@@ -1,5 +1,5 @@
 /* Localized versions of Info.plist keys */
 
 CFBundleName = "Second Life";
-CFBundleShortVersionString = "Second Life version 1.18.6.0";
-CFBundleGetInfoString = "Second Life version 1.18.6.0, Copyright 2004-2007 Linden Research, Inc.";
+CFBundleShortVersionString = "Second Life version 1.18.6.2";
+CFBundleGetInfoString = "Second Life version 1.18.6.2, Copyright 2004-2007 Linden Research, Inc.";
diff --git a/indra/newview/Info-SecondLife.plist b/indra/newview/Info-SecondLife.plist
index 59822a1e4c0..c7534692121 100644
--- a/indra/newview/Info-SecondLife.plist
+++ b/indra/newview/Info-SecondLife.plist
@@ -32,7 +32,7 @@
 		</dict>
 	</array>
 	<key>CFBundleVersion</key>
-	<string>1.18.6.0</string>
+	<string>1.18.6.2</string>
 	<key>CSResourcesFileMapped</key>
 	<true/>
 </dict>
diff --git a/indra/newview/llappviewer.cpp b/indra/newview/llappviewer.cpp
index 8b126b7597b..be31d2481e0 100644
--- a/indra/newview/llappviewer.cpp
+++ b/indra/newview/llappviewer.cpp
@@ -108,22 +108,6 @@
 
 #include "llsdserialize.h"
 
-#if LL_WINDOWS && LL_LCD_COMPILE
-	#include "lllcd.h"
-#endif
-
-#if LL_QUICKTIME_ENABLED
-	#if LL_DARWIN
-		#include <QuickTime/QuickTime.h>
-	#else
-		// quicktime specific includes
-		#include "MacTypes.h"
-		#include "QTML.h"
-		#include "Movies.h"
-		#include "FixMath.h"
-	#endif
-#endif
-
 #include "llworld.h"
 #include "llhudeffecttrail.h"
 #include "llvectorperfoptions.h"
@@ -179,6 +163,28 @@ static char** gTempArgV;
 #include "llviewernetwork.h"
 // extern EGridInfo gGridChoice;
 
+
+////// Windows-specific includes to the bottom - nasty defines in these pollute the preprocessor
+//
+#if LL_WINDOWS && LL_LCD_COMPILE
+	#include "lllcd.h"
+#endif
+//
+#if LL_QUICKTIME_ENABLED
+	#if LL_DARWIN
+		#include <QuickTime/QuickTime.h>
+	#else
+		// quicktime specific includes
+		#include "MacTypes.h"
+		#include "QTML.h"
+		#include "Movies.h"
+		#include "FixMath.h"
+	#endif
+#endif
+//
+//////
+
+
 //----------------------------------------------------------------------------
 // viewer.cpp - these are only used in viewer, should be easily moved.
 extern void disable_win_error_reporting();
@@ -226,7 +232,6 @@ extern BOOL gPeriodicSlowFrame;
 void UnloadGStreamer();
 #endif
 
-extern void send_stats();
 ////////////////////////////////////////////////////////////
 // All from the last globals push...
 bool gVerifySSLCert = true;
@@ -246,8 +251,6 @@ LLString gDisabledMessage; // Set in LLAppViewer::initConfiguration used in idle
 
 BOOL gHideLinks = FALSE; // Set in LLAppViewer::initConfiguration, used externally
 
-BOOL gInProductionGrid	= FALSE; 
-
 BOOL				gAllowIdleAFK = TRUE;
 F32					gAFKTimeout = DEFAULT_AFK_TIMEOUT;
 BOOL				gShowObjectUpdates = FALSE;
@@ -366,6 +369,7 @@ static LLString gWindowTitle;
 	static char sWindowClass[] = "Second Life";
 #endif
 
+std::string gLoginPage;
 std::vector<std::string> gLoginURIs;
 static std::string gHelperURI;
 
@@ -374,6 +378,7 @@ static const char USAGE[] = "\n"
 "options:\n"
 " -login <first> <last> <password>     log in as a user\n"
 " -autologin                           log in as last saved user\n"
+" -loginpage <URL>                     login authentication page to use\n"
 " -loginuri <URI>                      login server and CGI script to use\n"
 " -helperuri <URI>                     helper web CGI prefix to use\n"
 " -settings <filename>                 specify the filename of a\n"
@@ -623,6 +628,41 @@ int parse_args(int argc, char **argv)
 			gGridChoice = GRID_INFO_UMA;
 			sprintf(gGridName,"%s", gGridInfo[gGridChoice].mName);
 		}
+		else if (!strcmp(argv[j], "--mohini"))
+		{
+			gGridChoice = GRID_INFO_MOHINI;
+			sprintf(gGridName,"%s", gGridInfo[gGridChoice].mName);
+		}
+		else if (!strcmp(argv[j], "--yami"))
+		{
+			gGridChoice = GRID_INFO_YAMI;
+			sprintf(gGridName,"%s", gGridInfo[gGridChoice].mName);
+		}
+		else if (!strcmp(argv[j], "--nandi"))
+		{
+			gGridChoice = GRID_INFO_NANDI;
+			sprintf(gGridName,"%s", gGridInfo[gGridChoice].mName);
+		}
+		else if (!strcmp(argv[j], "--mitra"))
+		{
+			gGridChoice = GRID_INFO_MITRA;
+			sprintf(gGridName,"%s", gGridInfo[gGridChoice].mName);
+		}
+		else if (!strcmp(argv[j], "--radha"))
+		{
+			gGridChoice = GRID_INFO_RADHA;
+			sprintf(gGridName,"%s", gGridInfo[gGridChoice].mName);
+		}
+		else if (!strcmp(argv[j], "--ravi"))
+		{
+			gGridChoice = GRID_INFO_RAVI;
+			sprintf(gGridName,"%s", gGridInfo[gGridChoice].mName);
+		}
+		else if (!strcmp(argv[j], "--aruna"))
+		{
+			gGridChoice = GRID_INFO_ARUNA;
+			sprintf(gGridName,"%s", gGridInfo[gGridChoice].mName);
+		}
 		else if (!strcmp(argv[j], "-user") && (++j < argc)) 
 		{
 			if (!strcmp(argv[j], "-"))
@@ -638,6 +678,10 @@ int parse_args(int argc, char **argv)
 				snprintf(gGridName, MAX_STRING, "%s", ip_string.c_str());		// Flawfinder: ignore
 			}
 		}
+		else if (!strcmp(argv[j], "-loginpage") && (++j < argc))
+		{
+			LLAppViewer::instance()->setLoginPage(utf8str_trim(argv[j]));
+		}
 		else if (!strcmp(argv[j], "-loginuri") && (++j < argc))
 		{
             LLAppViewer::instance()->addLoginURI(utf8str_trim(argv[j]));
@@ -998,7 +1042,7 @@ bool LLAppViewer::init()
 	writeSystemInfo();
 
 	// Build a string representing the current version number.
-	gCurrentVersion = llformat("%d.%d.%d", LL_VERSION_MAJOR, LL_VERSION_MINOR, LL_VERSION_PATCH );
+        gCurrentVersion = llformat("%s %d.%d.%d.%d", gChannelName.c_str(), LL_VERSION_MAJOR, LL_VERSION_MINOR, LL_VERSION_PATCH, LL_VERSION_BUILD );
 	
 	//
 	// Load the feature tables
@@ -1864,6 +1908,34 @@ bool LLAppViewer::initEarlyConfiguration()
 		{
 			sprintf(gGridName,"%s", gGridInfo[GRID_INFO_UMA].mName);
 		}
+		else if (!strcmp(argv[j], "--mohini"))
+		{
+			sprintf(gGridName,"%s", gGridInfo[GRID_INFO_MOHINI].mName);
+		}
+		else if (!strcmp(argv[j], "--yami"))
+		{
+			sprintf(gGridName,"%s", gGridInfo[GRID_INFO_YAMI].mName);
+		}
+		else if (!strcmp(argv[j], "--nandi"))
+		{
+			sprintf(gGridName,"%s", gGridInfo[GRID_INFO_NANDI].mName);
+		}
+		else if (!strcmp(argv[j], "--mitra"))
+		{
+			sprintf(gGridName,"%s", gGridInfo[GRID_INFO_MITRA].mName);
+		}
+		else if (!strcmp(argv[j], "--radha"))
+		{
+			sprintf(gGridName,"%s", gGridInfo[GRID_INFO_RADHA].mName);
+		}
+		else if (!strcmp(argv[j], "--ravi"))
+		{
+			sprintf(gGridName,"%s", gGridInfo[GRID_INFO_RAVI].mName);
+		}
+		else if (!strcmp(argv[j], "--aruna"))
+		{
+			sprintf(gGridName,"%s", gGridInfo[GRID_INFO_ARUNA].mName);
+		}
 		else if (!strcmp(argv[j], "-user") && (++j < argc))
 		{
 			if (!strcmp(argv[j], "-"))
@@ -2290,11 +2362,6 @@ bool LLAppViewer::doConfigFromCommandLine()
 		removeMarkerFile();
 		return false;
 	}
-	
-	if (!strcmp(gGridName, gGridInfo[GRID_INFO_AGNI].mName))
-	{
-		gInProductionGrid = TRUE;
-	}
 
 	return true;
 }
@@ -2447,14 +2514,12 @@ void LLAppViewer::writeSystemInfo()
 	gDebugInfo["CPUInfo"]["CPUSSE2"] = gSysCPU.hasSSE2();
 	
 	gDebugInfo["RAMInfo"] = llformat("%u", gSysMemory.getPhysicalMemoryKB());
-	gDebugInfo["OSInfo"] = mSysOSInfo.getOSString().c_str();
+	gDebugInfo["OSInfo"] = getOSInfo().getOSStringSimple();
 
 	// Dump some debugging info
-	llinfos << gSecondLife << " version "
-		<< LL_VERSION_MAJOR << "."
-		<< LL_VERSION_MINOR << "."
-		<< LL_VERSION_PATCH
-		<< llendl;
+	llinfos << gSecondLife
+			<< " version " << LL_VERSION_MAJOR << "." << LL_VERSION_MINOR << "." << LL_VERSION_PATCH
+			<< llendl;
 
 	// Dump the local time and time zone
 	time_t now;
@@ -2466,6 +2531,7 @@ void LLAppViewer::writeSystemInfo()
 	// query some system information
 	llinfos << "CPU info:\n" << gSysCPU << llendl;
 	llinfos << "Memory info:\n" << gSysMemory << llendl;
+	llinfos << "OS: " << getOSInfo().getOSStringSimple() << llendl;
 	llinfos << "OS info: " << getOSInfo() << llendl;
 }
 
@@ -2539,7 +2605,7 @@ bool LLAppViewer::anotherInstanceRunning()
 	llinfos << "Checking marker file for lock..." << llendl;
 
 	// If file doesn't exist, we create it
-	// If file does exist, try to get writing privilages
+	// If file does exist, try to get writing privileges
 	FILE* fMarker = LLFile::fopen(marker_file.c_str(), "rb");		// Flawfinder: ignore
 	if (fMarker != NULL)
 	{
@@ -2554,7 +2620,7 @@ bool LLAppViewer::anotherInstanceRunning()
 
 		// *FIX:Mani - rather than have this exception here, 
 		// LLFile::fopen() have consistent behavior across platforms?
-#if LL_DARWIN
+#if LL_DARWIN || LL_LINUX || LL_SOLARIS
 		// Try to lock it. On Mac, this is the only way to test if it's actually locked.
 		if (flock(fileno(fMarker), LOCK_EX | LOCK_NB) == -1)
 		{
@@ -2600,7 +2666,7 @@ void LLAppViewer::initMarkerFile()
 			llinfos << "Marker file is locked." << llendl;
 			return;
 		}
-#if LL_DARWIN
+#if LL_DARWIN || LL_LINUX || LL_SOLARIS
 		// Try to lock it. On Mac, this is the only way to test if it's actually locked.
 		if (flock(fileno(fMarker), LOCK_EX | LOCK_NB) == -1)
 		{
@@ -3043,6 +3109,17 @@ void LLAppViewer::setHelperURI(const std::string& uri)
     gHelperURI = uri;
 }
 
+void LLAppViewer::setLoginPage(const std::string& login_page)
+{
+	gLoginPage = login_page;
+}
+
+const std::string& LLAppViewer::getLoginPage()
+{
+	return gLoginPage;
+}
+
+
 // Callback from a dialog indicating user was logged out.  
 void finish_disconnect(S32 option, void* userdata)
 {
@@ -3171,6 +3248,28 @@ void LLAppViewer::saveNameCache()
 	}
 }
 
+bool LLAppViewer::isInProductionGrid()
+{
+    return (GRID_INFO_AGNI == gGridChoice);
+}
+
+
+/*!	@brief		This class is an LLFrameTimer that can be created with
+				an elapsed time that starts counting up from the given value
+				rather than 0.0.
+				
+				Otherwise it behaves the same way as LLFrameTimer.
+*/
+class LLFrameStatsTimer : public LLFrameTimer
+{
+public:
+	LLFrameStatsTimer(F64 elapsed_already = 0.0)
+		: LLFrameTimer()
+		{
+			mStartTime -= elapsed_already;
+		}
+};
+
 ///////////////////////////////////////////////////////
 // idle()
 //
@@ -3278,12 +3377,15 @@ void LLAppViewer::idle()
 	//
 
 	{
-		static LLFrameTimer	viewer_stats_timer;
+		// Initialize the viewer_stats_timer with an already elapsed time
+		// of SEND_STATS_PERIOD so that the initial stats report will
+		// be sent immediately.
+		static LLFrameStatsTimer viewer_stats_timer(SEND_STATS_PERIOD);
 		reset_statistics();
 
 		// Update session stats every large chunk of time
 		// *FIX: (???) SAMANTHA
-		if (viewer_stats_timer.getElapsedTimeF32() >= 300.f && !gDisconnected)
+		if (viewer_stats_timer.getElapsedTimeF32() >= SEND_STATS_PERIOD && !gDisconnected)
 		{
 			llinfos << "Transmitting sessions stats" << llendl;
 			send_stats();
diff --git a/indra/newview/llappviewer.h b/indra/newview/llappviewer.h
index e97aead9556..32501b46420 100644
--- a/indra/newview/llappviewer.h
+++ b/indra/newview/llappviewer.h
@@ -101,6 +101,8 @@ class LLAppViewer : public LLApp
     const std::vector<std::string>& getLoginURIs() const;
     const std::string& getHelperURI() const;
     void resetURIs() const;
+    void setLoginPage(const std::string& login_page);
+    const std::string& getLoginPage();
 
     void forceDisconnect(const LLString& msg); // Force disconnection, with a message to the user.
     void badNetworkHandler(); // Cause a crash state due to bad network packet.
@@ -111,6 +113,8 @@ class LLAppViewer : public LLApp
     void loadNameCache();
     void saveNameCache();
 
+    bool isInProductionGrid();
+
     // LLAppViewer testing helpers.
     // *NOTE: These will potentially crash the viewer. Only for debugging.
     virtual void forceErrorLLError();
@@ -169,7 +173,7 @@ class LLAppViewer : public LLApp
 	// Thread objects.
 	static LLTextureCache* sTextureCache; 
 	static LLWorkerThread* sImageDecodeThread; 
-	static LLTextureFetch* sTextureFetch; 
+	static LLTextureFetch* sTextureFetch;
 
 	S32 mNumSessions;
 
@@ -196,7 +200,6 @@ extern BOOL gHandleKeysAsync; // gSavedSettings used by llviewerdisplay.cpp & ll
 extern BOOL gProbeHardware;
 extern LLString gDisabledMessage; // llstartup
 extern BOOL gHideLinks; // used by llpanellogin, lllfloaterbuycurrency, llstartup
-extern BOOL gInProductionGrid; 
 extern LLSD gDebugInfo;
 
 extern BOOL	gAllowIdleAFK;
diff --git a/indra/newview/llfloaterland.cpp b/indra/newview/llfloaterland.cpp
index 2a352dfc3d9..1e04d61a1f1 100644
--- a/indra/newview/llfloaterland.cpp
+++ b/indra/newview/llfloaterland.cpp
@@ -2767,7 +2767,7 @@ void LLPanelLandAccess::refresh_ui()
 			{
 				childSetToolTip("Only Allow", LLString());
 			}
-			childSetEnabled("GroupCheck", FALSE);
+			childSetEnabled("GroupCheck", TRUE); // Should always be an option (overrides age, payment restrictions)
 			childSetEnabled("PassCheck", FALSE);
 			childSetEnabled("pass_combo", FALSE);
 			childSetEnabled("AccessList", FALSE);
diff --git a/indra/newview/llfloaterreporter.cpp b/indra/newview/llfloaterreporter.cpp
index 9170e70ccdd..6128909528f 100644
--- a/indra/newview/llfloaterreporter.cpp
+++ b/indra/newview/llfloaterreporter.cpp
@@ -656,7 +656,7 @@ LLSD LLFloaterReporter::gatherReport()
 	mCopyrightWarningSeen = FALSE;
 
 	std::ostringstream summary;
-	if (!gInProductionGrid)
+    if (!LLAppViewer::instance()->isInProductionGrid())
 	{
 		summary << "Preview ";
 	}
diff --git a/indra/newview/llfolderview.cpp b/indra/newview/llfolderview.cpp
index deffca3b791..90df2284c59 100644
--- a/indra/newview/llfolderview.cpp
+++ b/indra/newview/llfolderview.cpp
@@ -108,6 +108,7 @@ LLColor4 LLFolderViewItem::sHighlightBgColor;
 LLColor4 LLFolderViewItem::sHighlightFgColor;
 LLColor4 LLFolderViewItem::sFilterBGColor;
 LLColor4 LLFolderViewItem::sFilterTextColor;
+LLColor4 LLFolderViewItem::sLoadingMessageTextColor;
 
 // Default constructor
 LLFolderViewItem::LLFolderViewItem( const LLString& name, LLViewerImage* icon,
@@ -132,7 +133,8 @@ LLFolderViewItem::LLFolderViewItem( const LLString& name, LLViewerImage* icon,
 	mStringMatchOffset(LLString::npos),
 	mControlLabelRotation(0.f),
 	mRoot( root ),
-	mDragAndDropTarget(FALSE)
+	mDragAndDropTarget(FALSE),
+	mIsLoading(FALSE)
 {
 	setIcon(icon);
 	if( !LLFolderViewItem::sFont )
@@ -151,6 +153,7 @@ LLFolderViewItem::LLFolderViewItem( const LLString& name, LLViewerImage* icon,
 	LLFolderViewItem::sHighlightFgColor = gColors.getColor( "MenuItemHighlightFgColor" );
 	LLFolderViewItem::sFilterBGColor = gColors.getColor( "FilterBackgroundColor" );
 	LLFolderViewItem::sFilterTextColor = gColors.getColor( "FilterTextColor" );
+	LLFolderViewItem::sLoadingMessageTextColor = gColors.getColor( "FolderViewLoadingMessageTextColor" );
 
 	mArrowImage = gImageList.getImage(LLUUID(gViewerArt.getString("folder_arrow.tga")), MIPMAP_FALSE, TRUE); 
 	mBoxImage = gImageList.getImage(LLUUID(gViewerArt.getString("rounded_square.tga")), MIPMAP_FALSE, TRUE);
@@ -933,6 +936,14 @@ void LLFolderViewItem::draw()
 			text_left = right_x;
 		}
 
+
+		if ( mIsLoading && mTimeSinceRequestStart.getElapsedTimeF32() >= gSavedSettings.getF32("FolderLoadingMessageWaitTime") )
+		{
+			sFont->renderUTF8( "Loading... ", 0, text_left, y, sLoadingMessageTextColor,
+						LLFontGL::LEFT, LLFontGL::BOTTOM, mLabelStyle, S32_MAX, S32_MAX, &right_x, FALSE);
+			text_left = right_x;
+		}
+
 		sFont->renderUTF8( mLabel, 0, text_left, y, color,
 							LLFontGL::LEFT, LLFontGL::BOTTOM, mLabelStyle,
 							S32_MAX, S32_MAX, &right_x, FALSE );
@@ -2197,6 +2208,24 @@ void LLFolderViewFolder::draw()
 		mControlLabelRotation = lerp(mControlLabelRotation, 0.f, LLCriticalDamp::getInterpolant(0.025f));
 	}
 
+	bool possibly_has_children = false;
+	bool up_to_date = mListener && mListener->isUpToDate();
+	if(!up_to_date && mListener && mListener->hasChildren()) // we know we have children but haven't fetched them (doesn't obey filter)
+	{
+		possibly_has_children = true;
+	}
+	
+	
+	BOOL loading = ( mIsOpen && possibly_has_children && !up_to_date );
+	
+	if ( loading && !mIsLoading )
+	{
+		// Measure how long we've been in the loading state
+		mTimeSinceRequestStart.reset();
+	}
+	
+	mIsLoading = loading;
+
 	LLFolderViewItem::draw();
 
 	// draw children if root folder, or any other folder that is open or animating to closed state
diff --git a/indra/newview/llfolderview.h b/indra/newview/llfolderview.h
index 9fcf94d8024..37b9ee6c13e 100644
--- a/indra/newview/llfolderview.h
+++ b/indra/newview/llfolderview.h
@@ -323,6 +323,7 @@ class LLFolderViewItem : public LLUICtrl
 	static LLColor4				sHighlightFgColor;
 	static LLColor4				sFilterBGColor;
 	static LLColor4				sFilterTextColor;
+	static LLColor4				sLoadingMessageTextColor;
 
 	LLString					mLabel;
 	LLString					mSearchableLabel;
@@ -349,6 +350,8 @@ class LLFolderViewItem : public LLUICtrl
 	BOOL						mDragAndDropTarget;
 	LLPointer<LLViewerImage>	mArrowImage;
 	LLPointer<LLViewerImage>	mBoxImage;
+	BOOL                            mIsLoading;
+	LLTimer                         mTimeSinceRequestStart;
 	
 	// This function clears the currently selected item, and records
 	// the specified selected item appropriately for display and use
diff --git a/indra/newview/llinventorybridge.h b/indra/newview/llinventorybridge.h
index 8c2eb2b596f..c61fa7f2b67 100644
--- a/indra/newview/llinventorybridge.h
+++ b/indra/newview/llinventorybridge.h
@@ -383,6 +383,7 @@ class LLLandmarkBridge : public LLItemBridge
 {
 	friend class LLInvFVBridge;
 public:
+	static const LLString& prefix() { return sPrefix; }
 	virtual const LLString& getPrefix() { return sPrefix; }
 	virtual void performAction(LLFolderView* folder, LLInventoryModel* model, LLString action);
 	virtual void buildContextMenu(LLMenuGL& menu, U32 flags);
diff --git a/indra/newview/llpanelavatar.cpp b/indra/newview/llpanelavatar.cpp
index 46af3ec74f1..8058ab9595c 100644
--- a/indra/newview/llpanelavatar.cpp
+++ b/indra/newview/llpanelavatar.cpp
@@ -1879,16 +1879,15 @@ void LLPanelAvatar::processAvatarPropertiesReply(LLMessageSystem *msg, void**)
 					payment_text = "NoPaymentInfoOnFile";
 				}
 				args["[PAYMENTINFO]"] = self->mPanelSecondLife->childGetValue(payment_text).asString();
-				LLString age_text = "NotAgeVerified";
-				if(age_verified)
-				{
-					age_text = "AgeVerified";
-				}
-				args["[PAYMENTINFO]"] += self->mPanelSecondLife->childGetValue(age_text).asString();
+				LLString age_text = age_verified ? "AgeVerified" : "NotAgeVerified";
+				// Do not display age verification status at this time
+				//args["[AGEVERIFICATION]"] = self->mPanelSecondLife->childGetValue(age_text).asString();
+				args["[AGEVERIFICATION]"] = " ";
 			}
 			else
 			{
 				args["[PAYMENTINFO]"] = " ";
+				args["[AGEVERIFICATION]"] = " ";
 			}
 			LLString::format(caption_text, args);
 		}
diff --git a/indra/newview/llpanelclassified.cpp b/indra/newview/llpanelclassified.cpp
index 7263b11d96a..bc74562d6d0 100644
--- a/indra/newview/llpanelclassified.cpp
+++ b/indra/newview/llpanelclassified.cpp
@@ -48,6 +48,7 @@
 #include "llcheckboxctrl.h"
 #include "llclassifiedflags.h"
 #include "llclassifiedstatsresponder.h"
+#include "llcommandhandler.h" // for classified HTML detail page click tracking
 #include "llviewercontrol.h"
 #include "lllineeditor.h"
 #include "llfloateravatarinfo.h"
@@ -58,6 +59,7 @@
 #include "llviewertexteditor.h"
 #include "lltexturectrl.h"
 #include "lluiconstants.h"
+#include "llurldispatcher.h"	// for classified HTML detail click teleports
 #include "llvieweruictrlfactory.h"
 #include "llviewerparcelmgr.h"
 #include "llviewerwindow.h"
@@ -70,6 +72,9 @@
 
 const S32 MINIMUM_PRICE_FOR_LISTING = 50;	// L$
 
+//static
+std::list<LLPanelClassified*> LLPanelClassified::sAllPanels;
+
 // "classifiedclickthrough"
 // strings[0] = classified_id
 // strings[1] = teleport_clicks
@@ -96,11 +101,45 @@ class LLDispatchClassifiedClickThrough : public LLDispatchHandler
 		return true;
 	}
 };
-
 static LLDispatchClassifiedClickThrough sClassifiedClickThrough;
 
-//static
-std::list<LLPanelClassified*> LLPanelClassified::sAllPanels;
+
+// We need to count classified teleport clicks from the search HTML detail pages,
+// so we need have a teleport that also sends a click count message.
+class LLClassifiedTeleportHandler : public LLCommandHandler
+{
+public:
+    // Inform the system you handle commands starting
+	// with "foo"
+	LLClassifiedTeleportHandler() : LLCommandHandler("classifiedteleport") { }
+
+	bool handle(const LLSD& tokens, const LLSD& queryMap)
+	{
+		// Need at least classified id and region name, so 2 params
+		if (tokens.size() < 2) return false;
+		LLUUID classified_id = tokens[0].asUUID();
+		if (classified_id.isNull()) return false;
+		// *HACK: construct a SLURL to do the teleport
+		std::string url("secondlife:///app/teleport/");
+		// skip the uuid we took off above, rebuild URL
+		// separated by slashes.
+		for (S32 i = 1; i < tokens.size(); ++i)
+		{
+			url += tokens[i].asString();
+			url += "/";
+		}
+		llinfos << "classified teleport to " << url << llendl;
+		// *TODO: separately track old search, sidebar, and new search
+		// Right now detail HTML pages count as new search.
+		const bool from_search = true;
+		LLPanelClassified::sendClassifiedClickMessage(classified_id, "teleport", from_search);
+		// Invoke teleport
+		return LLURLDispatcher::dispatch(url);
+	}
+};
+// Creating the object registers with the dispatcher.
+LLClassifiedTeleportHandler gClassifiedTeleportHandler;
+
 
 LLPanelClassified::LLPanelClassified(BOOL in_finder, bool from_search)
 :	LLPanel("Classified Panel"),
@@ -842,7 +881,7 @@ void LLPanelClassified::onClickTeleport(void* data)
         gAgent.teleportViaLocation(self->mPosGlobal);
         gFloaterWorldMap->trackLocation(self->mPosGlobal);
 
-		self->sendClassifiedClickMessage("teleport");
+		sendClassifiedClickMessage(self->mClassifiedID, "teleport", self->mFromSearch);
     }
 }
 
@@ -854,7 +893,7 @@ void LLPanelClassified::onClickMap(void* data)
 	gFloaterWorldMap->trackLocation(self->mPosGlobal);
 	LLFloaterWorldMap::show(NULL, TRUE);
 
-	self->sendClassifiedClickMessage("map");
+	sendClassifiedClickMessage(self->mClassifiedID, "map", self->mFromSearch);
 }
 
 // static
@@ -862,7 +901,7 @@ void LLPanelClassified::onClickProfile(void* data)
 {
 	LLPanelClassified* self = (LLPanelClassified*)data;
 	LLFloaterAvatarInfo::showFromDirectory(self->mCreatorID);
-	self->sendClassifiedClickMessage("profile");
+	sendClassifiedClickMessage(self->mClassifiedID, "profile", self->mFromSearch);
 }
 
 // static
@@ -936,20 +975,23 @@ void LLPanelClassified::onFocusReceived(LLFocusableElement* ctrl, void* data)
 }
 
 
-void LLPanelClassified::sendClassifiedClickMessage(const char* type)
+// static
+void LLPanelClassified::sendClassifiedClickMessage(const LLUUID& classified_id,
+												   const char* type,
+												   bool from_search)
 {
 	// You're allowed to click on your own ads to reassure yourself
 	// that the system is working.
 	std::vector<std::string> strings;
-	strings.push_back(mClassifiedID.asString());
+	strings.push_back(classified_id.asString());
 	strings.push_back(type);
 	LLUUID no_invoice;
 
 	// New classified click-through handling
 	LLSD body;
 	body["type"] = type;
-	body["from_search"] = mFromSearch;
-	body["classified_id"] = mClassifiedID;
+	body["from_search"] = from_search;
+	body["classified_id"] = classified_id;
 	std::string url = gAgent.getRegion()->getCapability("SearchStatTracking");
 
 	// If the capability exists send to the new database, otherwise send to the old one.
diff --git a/indra/newview/llpanelclassified.h b/indra/newview/llpanelclassified.h
index 8884d1a25ef..89939f243f4 100644
--- a/indra/newview/llpanelclassified.h
+++ b/indra/newview/llpanelclassified.h
@@ -101,6 +101,7 @@ class LLPanelClassified : public LLPanel
 
 	static void callbackGotPriceForListing(S32 option, LLString text, void* data);
 	static void callbackConfirmPublish(S32 option, void* data);
+	static void sendClassifiedClickMessage(const LLUUID& classified_id, const char* type, bool from_search);
 
 protected:
 	static void saveCallback(S32 option, void* data);
@@ -114,7 +115,6 @@ class LLPanelClassified : public LLPanel
 	static void onFocusReceived(LLFocusableElement* ctrl, void* data);
 	static void onCommitAny(LLUICtrl* ctrl, void* data);
 
-	void sendClassifiedClickMessage(const char* type);
 	BOOL checkDirty();		// Update and return mDirty
 
 protected:
diff --git a/indra/newview/llpanellogin.cpp b/indra/newview/llpanellogin.cpp
index 74936dce0c5..7e97622c8b0 100644
--- a/indra/newview/llpanellogin.cpp
+++ b/indra/newview/llpanellogin.cpp
@@ -147,9 +147,46 @@ void LLLoginHandler::parse(const LLSD& queryMap)
 	{
 		gGridChoice = GRID_INFO_UMA;
 	}
+	else if (queryMap["grid"].asString() == "mohini")
+	{
+		gGridChoice = GRID_INFO_MOHINI;
+	}
+	else if (queryMap["grid"].asString() == "yami")
+	{
+		gGridChoice = GRID_INFO_YAMI;
+	}
+	else if (queryMap["grid"].asString() == "nandi")
+	{
+		gGridChoice = GRID_INFO_NANDI;
+	}
+	else if (queryMap["grid"].asString() == "mitra")
+	{
+		gGridChoice = GRID_INFO_MITRA;
+	}
+	else if (queryMap["grid"].asString() == "radha")
+	{
+		gGridChoice = GRID_INFO_RADHA;
+	}
+	else if (queryMap["grid"].asString() == "ravi")
+	{
+		gGridChoice = GRID_INFO_RAVI;
+	}
+	else if (queryMap["grid"].asString() == "aruna")
+	{
+		gGridChoice = GRID_INFO_ARUNA;
+	}
+#if !LL_RELEASE_FOR_DOWNLOAD
+	if (gGridChoice > GRID_INFO_NONE && gGridChoice < GRID_INFO_LOCAL)
+	{
+		gSavedSettings.setS32("ServerChoice", gGridChoice);
+	}
+#endif
 	
-	snprintf(gGridName, MAX_STRING, "%s", gGridInfo[gGridChoice].mName);		/* Flawfinder: ignore */
-	LLAppViewer::instance()->resetURIs();
+ 	if (LLAppViewer::instance()->getLoginURIs().size() == 0)
+ 	{
+ 	    snprintf(gGridName, MAX_STRING, "%s", gGridInfo[gGridChoice].mName);		/* Flawfinder: ignore */
+ 	    LLAppViewer::instance()->resetURIs();
+ 	}	    
 	
 	LLString startLocation = queryMap["location"].asString();
 
@@ -303,18 +340,12 @@ LLPanelLogin::LLPanelLogin(const LLRect &rect,
 	LLWebBrowserCtrl* web_browser = LLUICtrlFactory::getWebBrowserCtrlByName(this, "login_html");
 	if ( web_browser )
 	{
+		// observe browser events
+		web_browser->addObserver( this );
+
 		// don't make it a tab stop until SL-27594 is fixed
 		web_browser->setTabStop(FALSE);
-
-		// painfully build the path to the loading screen
-		std::string loading_path( gDirUtilp->getExpandedFilename( LL_PATH_SKINS, "" ) );
-		loading_path.append( gDirUtilp->getDirDelimiter() );
-		loading_path.append( "html" );
-		loading_path.append( gDirUtilp->getDirDelimiter() );
-		loading_path.append( "loading" );
-		loading_path.append( gDirUtilp->getDirDelimiter() );
-		loading_path.append( "loading.html" );
-		web_browser->navigateTo( loading_path.c_str() );
+		web_browser->navigateToLocalPage( "loading", "loading.html" );
 
 		// make links open in external browser
 		web_browser->setOpenInExternalBrowser( true );
@@ -328,7 +359,12 @@ LLPanelLogin::LLPanelLogin(const LLRect &rect,
 		
 		// kick off a request to grab the url manually
 		gResponsePtr = LLIamHereLogin::build( this );
-		LLHTTPClient::get( childGetValue( "real_url" ).asString(), gResponsePtr );
+ 		std::string login_page = LLAppViewer::instance()->getLoginPage();
+ 		if (login_page.empty())
+ 		{
+ 			login_page = childGetValue( "real_url" ).asString();
+ 		}
+ 		LLHTTPClient::head( login_page, gResponsePtr );
 	};
 	#else
 		mHtmlAvailable = FALSE;
@@ -350,20 +386,19 @@ void LLPanelLogin::setSiteIsAlive( bool alive )
 			
 			// mark as available
 			mHtmlAvailable = TRUE;
-		};
+		}
 	}
 	else
 	// the site is not available (missing page, server down, other badness)
 	{
 		if ( web_browser )
-		{
-			// hide browser control (revealing default one)
-			web_browser->setVisible( FALSE );
+		{	
+			web_browser->navigateToLocalPage( "loading-error" , "index.html" );
 
-			// mark as unavailable
-			mHtmlAvailable = FALSE;
-		};
-	};
+			// mark as available
+			mHtmlAvailable = TRUE;
+		}
+	}
 #else
 	mHtmlAvailable = FALSE;
 #endif
@@ -387,13 +422,6 @@ void LLPanelLogin::draw()
 {
 	if (!getVisible()) return;
 
-	BOOL target_fullscreen;
-	S32 target_width;
-	S32 target_height;
-	gViewerWindow->getTargetWindow(target_fullscreen, target_width, target_height);
-
-	childSetVisible("full_screen_text", target_fullscreen);
-
 	glPushMatrix();
 	{
 		F32 image_aspect = 1.333333f;
@@ -604,17 +632,36 @@ void LLPanelLogin::loadLoginPage()
 	char* curl_channel = curl_escape(gChannelName.c_str(), 0);
 	char* curl_version = curl_escape(version.c_str(), 0);
 
+	std::string login_page = LLAppViewer::instance()->getLoginPage();
+	if (login_page.empty())
+	{
+		login_page = sInstance->childGetValue( "real_url" ).asString();
+	}
 	
-	oStr << sInstance->childGetValue( "real_url" ).asString()  << "&firstname=" << firstname <<
+	// Use the right delimeter depending on how LLURI parses the URL
+	LLURI login_page_uri = LLURI(login_page);
+	std::string first_query_delimiter = "&";
+	if (login_page_uri.queryMap().size() == 0)
+	{
+		first_query_delimiter = "?";
+	}
+	oStr << login_page << first_query_delimiter << "firstname=" << firstname <<
 		"&lastname=" << lastname << "&location=" << location <<	"&region=" << curl_region <<
 		"&grid=" << gGridInfo[gGridChoice].mLabel << "&channel=" << curl_channel <<
 		"&version=" << curl_version;
-
 	
 	curl_free(curl_region);
 	curl_free(curl_channel);
 	curl_free(curl_version);
 
+	LLString language(gSavedSettings.getString("Language"));		
+	if(language == "default")
+	{
+		language = gSavedSettings.getString("SystemLanguage");
+	}
+
+	oStr << "&lang=" << language;
+
 	if (!gCmdLinePassword.empty())
 	{
 		oStr << "&password=" << gCmdLinePassword;
@@ -637,12 +684,32 @@ void LLPanelLogin::loadLoginPage()
 	}	
 #ifndef	LL_RELEASE_FOR_DOWNLOAD
 	oStr << "&show_grid=TRUE";
+#else
+	if (gSavedSettings.getBOOL("ForceShowGrid"))
+		oStr << "&show_grid=TRUE";
 #endif
 	
 	// navigate to the "real" page 
 	web_browser->navigateTo( oStr.str() );
 }
 
+#if LL_LIBXUL_ENABLED
+void LLPanelLogin::onNavigateComplete( const EventType& eventIn )
+{
+	LLWebBrowserCtrl* web_browser = LLUICtrlFactory::getWebBrowserCtrlByName(sInstance, "login_html");
+	if (web_browser)
+	{
+		// *HACK HACK HACK HACK!
+		/* Stuff a Tab key into the browser now so that the first field will
+		** get the focus!  The embedded javascript on the page that properly
+		** sets the initial focus in a real web browser is not working inside
+		** the viewer, so this is an UGLY HACK WORKAROUND for now.
+		*/
+		// Commented out as it's not reliable
+		//web_browser->handleKey(KEY_TAB, MASK_NONE, false);
+	}
+}
+#endif
 
 //---------------------------------------------------------------------------
 // Protected methods
diff --git a/indra/newview/llpanellogin.h b/indra/newview/llpanellogin.h
index 191e88c25bd..f2a58b7b5f4 100644
--- a/indra/newview/llpanellogin.h
+++ b/indra/newview/llpanellogin.h
@@ -39,6 +39,7 @@
 #include "llviewerimage.h"
 #include "llstring.h"
 #include "llmd5.h"
+#include "llwebbrowserctrl.h"
 
 class LLTextBox;
 class LLLineEditor;
@@ -64,6 +65,9 @@ extern LLLoginHandler gLoginHandler;
 
 class LLPanelLogin
 :	public LLPanel
+#if LL_LIBXUL_ENABLED
+	, public LLWebBrowserCtrlObserver
+#endif
 {
 public:
 	LLPanelLogin(const LLRect &rect, BOOL show_server, 
@@ -89,6 +93,11 @@ class LLPanelLogin
 private:
 	static void onClickQuit(void*);
 	static void onClickVersion(void*);
+
+#if LL_LIBXUL_ENABLED
+	// browser observer impls
+	virtual void onNavigateComplete( const EventType& eventIn );
+#endif
 	
 private:
 	LLPointer<LLViewerImage> mLogoImage;
diff --git a/indra/newview/llselectmgr.cpp b/indra/newview/llselectmgr.cpp
index e2e076e364b..ddd73fc0df4 100644
--- a/indra/newview/llselectmgr.cpp
+++ b/indra/newview/llselectmgr.cpp
@@ -5829,7 +5829,8 @@ bool LLObjectSelection::applyToTEs(LLSelectedTEFunctor* func, bool firstonly)
 		iterator nextiter = iter++;
 		LLSelectNode* node = *nextiter;
 		LLViewerObject* object = (*nextiter)->getObject();
-		for (S32 te = 0; te < object->getNumTEs(); ++te)
+		S32 num_tes = llmin((S32)object->getNumTEs(), (S32)object->getNumFaces()); // avatars have TEs but no faces
+		for (S32 te = 0; te < num_tes; ++te)
 		{
 			if (node->isTESelected(te))
 			{
diff --git a/indra/newview/llstartup.cpp b/indra/newview/llstartup.cpp
index b0b9fd33d15..21c97c2678f 100644
--- a/indra/newview/llstartup.cpp
+++ b/indra/newview/llstartup.cpp
@@ -48,6 +48,7 @@
 #include "audiosettings.h"
 #include "llares.h"
 #include "llcachename.h"
+#include "llcameraview.h"
 #include "llviewercontrol.h"
 #include "lldir.h"
 #include "lleconomy.h"
@@ -61,6 +62,7 @@
 #include "llmd5.h"
 #include "llmemorystream.h"
 #include "llmessageconfig.h"
+#include "llmoveview.h"
 #include "llregionhandle.h"
 #include "llsd.h"
 #include "llsdserialize.h"
@@ -592,6 +594,7 @@ BOOL idle_startup()
 		codec << " - " << LL_VERSION_MAJOR << "." << LL_VERSION_MINOR << "." << LL_VERSION_PATCH << "." << LL_VERSION_BUILD;
 		codec << "]";
 		LLMozLib::getInstance()->setBrowserAgentId( codec.str() );
+		LLMozLib::getInstance()->enableProxy( gSavedSettings.getBOOL("BrowserProxyEnabled"), gSavedSettings.getString("BrowserProxyAddress"), gSavedSettings.getS32("BrowserProxyPort") ); 
 		#endif
 
 		//-------------------------------------------------
@@ -736,6 +739,7 @@ BOOL idle_startup()
 		
 		gViewerWindow->setNormalControlsVisible( FALSE );	
 		gLoginMenuBarView->setVisible( TRUE );
+		gLoginMenuBarView->setEnabled( TRUE );
 
 		timeout.reset();
 		return do_normal_idle;
@@ -1009,6 +1013,10 @@ BOOL idle_startup()
 	if(STATE_LOGIN_NO_DATA_YET == LLStartUp::getStartupState())
 	{
 		//lldebugs << "STATE_LOGIN_NO_DATA_YET" << llendl;
+		// If we get here we have gotten past the potential stall
+		// in curl, so take "may appear frozen" out of progress bar. JC
+		auth_desc = "Logging in...";
+		set_startup_status(progress, auth_desc.c_str(), auth_message.c_str());
 		if (!gUserAuthp)
 		{
 			llerrs << "No userauth in STATE_LOGIN_NO_DATA_YET!" << llendl;
@@ -1552,9 +1560,19 @@ BOOL idle_startup()
 			gViewerWindow->setNormalControlsVisible( TRUE );
 		}	
 		gLoginMenuBarView->setVisible( FALSE );
+		gLoginMenuBarView->setEnabled( FALSE );
 
 		gFloaterMap->setVisible( gSavedSettings.getBOOL("ShowMiniMap") );
 
+		if (gSavedSettings.getBOOL("ShowCameraControls"))
+		{
+			LLFloaterCamera::show(NULL);
+		}
+		if (gSavedSettings.getBOOL("ShowMovementControls"))
+		{
+			LLFloaterMove::show(NULL);
+		}
+
 		if (!gNoRender)
 		{
 			// Move the progress view in front of the UI
@@ -1736,10 +1754,33 @@ BOOL idle_startup()
 					}
 					else
 					{
-						llinfos << ".. initialized successfully." << llendl;
-						set_startup_status(0.57f, "QuickTime initialized successfully.", gAgent.mMOTD.c_str());
+						//llinfos << "######### QuickTime version (hex) is " << std::hex << LLMediaEngine::getInstance()->getQuickTimeVersion() << llendl;
+						//llinfos << "######### QuickTime version is " << std::dec << LLMediaEngine::getInstance()->getQuickTimeVersion() << llendl;
+						if ( LLMediaEngine::getInstance()->getQuickTimeVersion() < LL_MIN_QUICKTIME_VERSION )
+						{
+							// turn off QuickTime if version is less than required
+							LLMediaEngine::getInstance ()->setAvailable ( FALSE );
+
+							// display a message here explaining why we disabled QuickTime
+							gViewerWindow->alertXml("QuickTimeOutOfDate");
+						}
+						else
+						{
+							llinfos << ".. initialized successfully." << llendl;
+							set_startup_status(0.57f, "QuickTime initialized successfully.", gAgent.mMOTD.c_str());
+						};
 					};
+				#elif LL_DARWIN
+					if ( LLMediaEngine::getInstance()->getQuickTimeVersion() < LL_MIN_QUICKTIME_VERSION )
+					{
+						// turn off QuickTime if version is less than required
+						LLMediaEngine::getInstance ()->setAvailable ( FALSE );
+
+						// display a message here explaining why we disabled QuickTime
+						gViewerWindow->alertXml("QuickTimeOutOfDate");
+					}
 				#endif
+
 				EnterMovies ();
 				gQuickTimeInitialized = true;
 			}
@@ -3583,6 +3624,7 @@ void reset_login()
 	{	// Hide menus and normal buttons
 		gViewerWindow->setNormalControlsVisible( FALSE );
 		gLoginMenuBarView->setVisible( TRUE );
+		gLoginMenuBarView->setEnabled( TRUE );
 	}
 
 	// Hide any other stuff
diff --git a/indra/newview/lltexturectrl.cpp b/indra/newview/lltexturectrl.cpp
index 706587abb05..c17f0007c26 100644
--- a/indra/newview/lltexturectrl.cpp
+++ b/indra/newview/lltexturectrl.cpp
@@ -351,12 +351,6 @@ void LLFloaterTexturePicker::updateImageStats()
 		{
 			mResolutionLabel->setTextArg("[DIMENSIONS]", LLString("[? x ?]"));
 		}
-		if (gAgent.isGodlike())
-		{
-			LLString tstring = "Pick: ";
-			tstring.append(mTexturep->getID().asString());
-			setTitle(tstring);
-		}
 	}
 }
 
diff --git a/indra/newview/llvieweraudio.cpp b/indra/newview/llvieweraudio.cpp
index 8e742bd655f..bb71be1aa45 100644
--- a/indra/newview/llvieweraudio.cpp
+++ b/indra/newview/llvieweraudio.cpp
@@ -8,15 +8,16 @@
 
 #include "llviewerprecompiledheaders.h"
 
-#include "llvieweraudio.h"
 #include "audioengine.h"
-#include "llviewercontrol.h"
-#include "llmediaengine.h"
+#include "audiosettings.h"
 #include "llagent.h"
 #include "llappviewer.h"
-#include "llvoiceclient.h"
-#include "llviewerwindow.h"
+#include "llmediaengine.h"
+#include "llvieweraudio.h"
 #include "llviewercamera.h"
+#include "llviewercontrol.h"
+#include "llviewerwindow.h"
+#include "llvoiceclient.h"
 
 /////////////////////////////////////////////////////////
 
@@ -210,7 +211,10 @@ void audio_update_wind(bool force_update)
 		// don't use the setter setMaxWindGain() because we don't
 		// want to screw up the fade-in on startup by setting actual source gain
 		// outside the fade-in.
-		gAudiop->mMaxWindGain = gSavedSettings.getBOOL("MuteAmbient") ? 0.f : gSavedSettings.getF32("AudioLevelAmbient");
+		F32 ambient_volume = gSavedSettings.getF32("AudioLevelAmbient");
+		gAudiop->mMaxWindGain = gSavedSettings.getBOOL("MuteAmbient") 
+			? 0.f 
+			: ambient_volume * ambient_volume;
 		
 		last_camera_water_height = camera_water_height;
 		gAudiop->updateWind(gRelativeWindVec, camera_water_height);
diff --git a/indra/newview/llviewermenu.cpp b/indra/newview/llviewermenu.cpp
index fdc0047f956..54396d083e4 100644
--- a/indra/newview/llviewermenu.cpp
+++ b/indra/newview/llviewermenu.cpp
@@ -677,7 +677,7 @@ void init_menus()
 	gPopupMenuView->setBackgroundColor( color );
 
 	// If we are not in production, use a different color to make it apparent.
-	if (gInProductionGrid)
+	if (LLAppViewer::instance()->isInProductionGrid())
 	{
 		color = gColors.getColor( "MenuBarBgColor" );
 	}
@@ -694,6 +694,9 @@ void init_menus()
 	// menu holder appears on top of menu bar so you can see the menu title
 	// flash when an item is triggered (the flash occurs in the holder)
 	gViewerWindow->getRootView()->addChild(gMenuHolder);
+   
+    gViewerWindow->setMenuBackgroundColor(false, 
+        LLAppViewer::instance()->isInProductionGrid());
 
 	// *TODO:Get the cost info from the server
 	const LLString upload_cost("10");
@@ -944,7 +947,7 @@ void init_client_menu(LLMenuGL* menu)
 
 
 #ifdef TOGGLE_HACKED_GODLIKE_VIEWER
-	if (!gInProductionGrid)
+	if (!LLAppViewer::instance()->isInProductionGrid())
 	{
 		menu->append(new LLMenuItemCheckGL("Hacked Godmode",
 										   &handle_toggle_hacked_godmode,
@@ -1070,7 +1073,7 @@ void init_client_menu(LLMenuGL* menu)
 										&menu_check_control,
 										(void*)"ShowConsoleWindow"));
 
-	if(gQAMode && !gInProductionGrid)
+	if(gQAMode)
 	{
 		LLMenuGL* sub = NULL;
 		sub = new LLMenuGL("Debugging");
@@ -2637,53 +2640,40 @@ void handle_leave_god_mode(void*)
 
 void set_god_level(U8 god_level)
 {
-		U8 old_god_level = gAgent.getGodLevel();
-		gAgent.setGodLevel( god_level );
-		show_debug_menus();
-		gIMMgr->refresh();
-		gParcelMgr->notifyObservers();
+	U8 old_god_level = gAgent.getGodLevel();
+	gAgent.setGodLevel( god_level );
+	show_debug_menus();
+	gIMMgr->refresh();
+	gParcelMgr->notifyObservers();
 
-		// Some classifieds change visibility on god mode
-		LLFloaterDirectory::requestClassifieds();
+	// Some classifieds change visibility on god mode
+	LLFloaterDirectory::requestClassifieds();
 
-		// God mode changes sim visibility
-		gWorldMap->reset();
-		gWorldMap->setCurrentLayer(0);
+	// God mode changes sim visibility
+	gWorldMap->reset();
+	gWorldMap->setCurrentLayer(0);
 
-		// inventory in items may change in god mode
-		gObjectList.dirtyAllObjectInventory();
+	// inventory in items may change in god mode
+	gObjectList.dirtyAllObjectInventory();
+
+    if(gViewerWindow)
+    {
+        gViewerWindow->setMenuBackgroundColor(god_level > GOD_NOT,
+            LLAppViewer::instance()->isInProductionGrid());
+    }
+
+    LLString::format_map_t args;
+	if(god_level > GOD_NOT)
+	{
+		args["[LEVEL]"] = llformat("%d",(S32)god_level);
+		LLNotifyBox::showXml("EnteringGodMode", args);
+	}
+	else
+	{
+		args["[LEVEL]"] = llformat("%d",(S32)old_god_level);
+		LLNotifyBox::showXml("LeavingGodMode", args);
+	}
 
-		LLString::format_map_t args;
-		if(god_level > GOD_NOT)
-		{
-			args["[LEVEL]"] = llformat("%d",(S32)god_level);
-			if (gInProductionGrid)
-			{
-				gMenuBarView->setBackgroundColor( gColors.getColor( "MenuBarGodBgColor" ) );
-				gStatusBar->setBackgroundColor( gColors.getColor( "MenuBarGodBgColor" ) );
-			}
-			else
-			{
-				gMenuBarView->setBackgroundColor( gColors.getColor( "MenuNonProductionGodBgColor" ) );
-				gStatusBar->setBackgroundColor( gColors.getColor( "MenuNonProductionGodBgColor" ) );
-			}
-			LLNotifyBox::showXml("EnteringGodMode", args);
-		}
-		else
-		{
-			args["[LEVEL]"] = llformat("%d",(S32)old_god_level);
-			if (gInProductionGrid)
-			{
-				gMenuBarView->setBackgroundColor( gColors.getColor( "MenuBarBgColor" ) );
-				gStatusBar->setBackgroundColor( gColors.getColor( "MenuBarBgColor" ) );
-			}
-			else
-			{
-				gMenuBarView->setBackgroundColor( gColors.getColor( "MenuNonProductionBgColor" ) );
-				gStatusBar->setBackgroundColor( gColors.getColor( "MenuNonProductionBgColor" ) );
-			}
-			LLNotifyBox::showXml("LeavingGodMode", args);
-		}
 }
 
 #ifdef TOGGLE_HACKED_GODLIKE_VIEWER
@@ -3990,7 +3980,8 @@ BOOL enable_take()
 		return TRUE;
 #else
 # ifdef TOGGLE_HACKED_GODLIKE_VIEWER
-		if (!gInProductionGrid && gAgent.isGodlike())
+		if (!LLAppViewer::instance()->isInProductionGrid() 
+            && gAgent.isGodlike())
 		{
 			return TRUE;
 		}
@@ -4549,7 +4540,8 @@ class LLObjectEnableDelete : public view_listener_t
 			TRUE;
 #else
 # ifdef TOGGLE_HACKED_GODLIKE_VIEWER
-			(!gInProductionGrid && gAgent.isGodlike()) ||
+			(!LLAppViewer::instance()->isInProductionGrid()
+             && gAgent.isGodlike()) ||
 # endif
 			(gSelectMgr && gSelectMgr->canDoDelete());
 #endif
@@ -6276,13 +6268,7 @@ void handle_selected_texture_info(void*)
 			S32 height = img->getHeight();
 			S32 width = img->getWidth();
 			S32 components = img->getComponents();
-			std::string image_id_string;
-			if (gAgent.isGodlike())
-			{
-				image_id_string = image_id.asString() + " ";
-			}
-			msg = llformat("%s%dx%d %s on face ",
-								image_id_string.c_str(),
+			msg = llformat("%dx%d %s on face ",
 								width,
 								height,
 								(components == 4 ? "alpha" : "opaque"));
@@ -6466,7 +6452,8 @@ class LLToolsEnableTakeCopy : public view_listener_t
 			all_valid = true;
 #ifndef HACKED_GODLIKE_VIEWER
 # ifdef TOGGLE_HACKED_GODLIKE_VIEWER
-			if (gInProductionGrid || !gAgent.isGodlike())
+			if (LLAppViewer::instance()->isInProductionGrid()
+                || !gAgent.isGodlike())
 # endif
 			{
 				struct f : public LLSelectedObjectFunctor
@@ -6571,7 +6558,8 @@ BOOL enable_save_into_inventory(void*)
 		return TRUE;
 #else
 # ifdef TOGGLE_HACKED_GODLIKE_VIEWER
-		if (!gInProductionGrid && gAgent.isGodlike())
+		if (!LLAppViewer::instance()->isInProductionGrid()
+            && gAgent.isGodlike())
 		{
 			return TRUE;
 		}
diff --git a/indra/newview/llviewermessage.cpp b/indra/newview/llviewermessage.cpp
index 8a4cd16c080..dd786da4d34 100644
--- a/indra/newview/llviewermessage.cpp
+++ b/indra/newview/llviewermessage.cpp
@@ -279,11 +279,6 @@ void process_logout_reply(LLMessageSystem* msg, void**)
 			llinfos << "process_logout_reply item not found: " << item_id << llendl;
 		}
 	}
-	if(!parents.empty())
-	{
-		gInventory.accountForUpdate(parents);
-		gInventory.notifyObservers();
-	}
     LLAppViewer::instance()->forceQuit();
 }
 
@@ -1348,7 +1343,7 @@ void process_improved_im(LLMessageSystem *msg, void **user_data)
 	S32 binary_bucket_size;
 	LLChat chat;
 
-	//*TODO:translate - need to fix the full name to first/last (maybe)
+	// *TODO:translate - need to fix the full name to first/last (maybe)
 	msg->getUUIDFast(_PREHASH_AgentData, _PREHASH_AgentID, from_id);
 	msg->getBOOLFast(_PREHASH_MessageBlock, _PREHASH_FromGroup, from_group);
 	msg->getUUIDFast(_PREHASH_MessageBlock, _PREHASH_ToAgentID, to_id);
@@ -1885,6 +1880,8 @@ void process_improved_im(LLMessageSystem *msg, void **user_data)
 
 	case IM_GOTO_URL:
 		{
+			// n.b. this is for URLs sent by the system, not for
+			// URLs sent by scripts (i.e. llLoadURL)
 			if (binary_bucket_size <= 0)
 			{
 				llwarns << "bad binary_bucket_size: "
@@ -5081,7 +5078,7 @@ void callback_load_url_name(const LLUUID& id, const char* first, const char* las
 				owner_name += last;
 			}
 
-			// TODO: Talk to james about using an id instead of a name for this.
+			// For legacy name-only mutes.
 			if (gMuteListp->isMuted(LLUUID::null, owner_name))
 			{
 				delete infop;
@@ -5116,8 +5113,12 @@ void process_load_url(LLMessageSystem* msg, void**)
 	// URL is safety checked in load_url above
 
 	// Check if object or owner is muted
-	if (gMuteListp->isMuted(infop->mObjectID, infop->mObjectName))
+	if (gMuteListp &&
+	    (gMuteListp->isMuted(infop->mObjectID, infop->mObjectName) ||
+	     gMuteListp->isMuted(infop->mOwnerID))
+	    )
 	{
+		llinfos<<"Ignoring load_url from muted object/owner."<<llendl;
 		delete infop;
 		infop = NULL;
 		return;
diff --git a/indra/newview/llviewernetwork.cpp b/indra/newview/llviewernetwork.cpp
index caa61d64185..ad0dacbd130 100644
--- a/indra/newview/llviewernetwork.cpp
+++ b/indra/newview/llviewernetwork.cpp
@@ -77,6 +77,34 @@ LLGridData gGridInfo[GRID_INFO_COUNT] =
 	  "util.uma.lindenlab.com",
 	  "https://login.uma.lindenlab.com/cgi-bin/login.cgi",
 	  "http://uma-secondlife.webdev.lindenlab.com/helpers/" },
+	{ "Mohini",
+	  "util.mohini.lindenlab.com",
+	  "https://login.mohini.lindenlab.com/cgi-bin/login.cgi",
+	  "http://mohini-secondlife.webdev.lindenlab.com/helpers/" },
+	{ "Yami",
+	  "util.yami.lindenlab.com",
+	  "https://login.yami.lindenlab.com/cgi-bin/login.cgi",
+	  "http://yami-secondlife.webdev.lindenlab.com/helpers/" },
+  	{ "Nandi",
+	  "util.nandi.lindenlab.com",
+	  "https://login.nandi.lindenlab.com/cgi-bin/login.cgi",
+	  "http://nandi-secondlife.webdev.lindenlab.com/helpers/" },
+	{ "Mitra",
+	  "util.mitra.lindenlab.com",
+	  "https://login.mitra.lindenlab.com/cgi-bin/login.cgi",
+	  "http://mitra-secondlife.webdev.lindenlab.com/helpers/" },
+	{ "Radha",
+	  "util.radha.lindenlab.com",
+	  "https://login.radha.lindenlab.com/cgi-bin/login.cgi",
+	  "http://radha-secondlife.webdev.lindenlab.com/helpers/" },
+	{ "Ravi",
+	  "util.ravi.lindenlab.com",
+	  "https://login.ravi.lindenlab.com/cgi-bin/login.cgi",
+	  "http://ravi-secondlife.webdev.lindenlab.com/helpers/" },
+	{ "Aruna",
+	  "util.aruna.lindenlab.com",
+	  "https://login.aruna.lindenlab.com/cgi-bin/login.cgi",
+	  "http://aruna-secondlife.webdev.lindenlab.com/helpers/" },
 	{ "Local", 
 	  "localhost", 
 	  "https://login.dmz.lindenlab.com/cgi-bin/login.cgi",
diff --git a/indra/newview/llviewernetwork.h b/indra/newview/llviewernetwork.h
index 118897aebcf..dbeaf2c1cd8 100644
--- a/indra/newview/llviewernetwork.h
+++ b/indra/newview/llviewernetwork.h
@@ -48,6 +48,13 @@ enum EGridInfo
 	GRID_INFO_GANGA,
 	GRID_INFO_VAAK,
 	GRID_INFO_UMA,
+	GRID_INFO_MOHINI,
+	GRID_INFO_YAMI,
+	GRID_INFO_NANDI,
+	GRID_INFO_MITRA,
+	GRID_INFO_RADHA,
+	GRID_INFO_RAVI,
+	GRID_INFO_ARUNA,
 	GRID_INFO_LOCAL,
 	GRID_INFO_OTHER, // IP address set via -user or other command line option
 	GRID_INFO_COUNT
diff --git a/indra/newview/llviewerobject.cpp b/indra/newview/llviewerobject.cpp
index 92432637946..f242b06d9b8 100644
--- a/indra/newview/llviewerobject.cpp
+++ b/indra/newview/llviewerobject.cpp
@@ -4511,7 +4511,8 @@ BOOL LLViewerObject::permYouOwner() const
 		return TRUE;
 #else
 # ifdef TOGGLE_HACKED_GODLIKE_VIEWER
-		if (!gInProductionGrid && (gAgent.getGodLevel() >= GOD_MAINTENANCE))
+		if (!LLAppViewer::instance()->isInProductionGrid()
+            && (gAgent.getGodLevel() >= GOD_MAINTENANCE))
 		{
 			return TRUE;
 		}
@@ -4547,7 +4548,8 @@ BOOL LLViewerObject::permOwnerModify() const
 		return TRUE;
 #else
 # ifdef TOGGLE_HACKED_GODLIKE_VIEWER
-		if (!gInProductionGrid && (gAgent.getGodLevel() >= GOD_MAINTENANCE))
+		if (!LLAppViewer::instance()->isInProductionGrid()
+            && (gAgent.getGodLevel() >= GOD_MAINTENANCE))
 	{
 			return TRUE;
 	}
@@ -4570,7 +4572,8 @@ BOOL LLViewerObject::permModify() const
 		return TRUE;
 #else
 # ifdef TOGGLE_HACKED_GODLIKE_VIEWER
-		if (!gInProductionGrid && (gAgent.getGodLevel() >= GOD_MAINTENANCE))
+		if (!LLAppViewer::instance()->isInProductionGrid()
+            && (gAgent.getGodLevel() >= GOD_MAINTENANCE))
 	{
 			return TRUE;
 	}
@@ -4593,7 +4596,8 @@ BOOL LLViewerObject::permCopy() const
 		return TRUE;
 #else
 # ifdef TOGGLE_HACKED_GODLIKE_VIEWER
-		if (!gInProductionGrid && (gAgent.getGodLevel() >= GOD_MAINTENANCE))
+		if (!LLAppViewer::instance()->isInProductionGrid()
+            && (gAgent.getGodLevel() >= GOD_MAINTENANCE))
 		{
 			return TRUE;
 		}
@@ -4616,7 +4620,8 @@ BOOL LLViewerObject::permMove() const
 		return TRUE;
 #else
 # ifdef TOGGLE_HACKED_GODLIKE_VIEWER
-		if (!gInProductionGrid && (gAgent.getGodLevel() >= GOD_MAINTENANCE))
+		if (!LLAppViewer::instance()->isInProductionGrid()
+            && (gAgent.getGodLevel() >= GOD_MAINTENANCE))
 		{
 			return TRUE;
 		}
@@ -4639,7 +4644,8 @@ BOOL LLViewerObject::permTransfer() const
 		return TRUE;
 #else
 # ifdef TOGGLE_HACKED_GODLIKE_VIEWER
-		if (!gInProductionGrid && (gAgent.getGodLevel() >= GOD_MAINTENANCE))
+		if (!LLAppViewer::instance()->isInProductionGrid()
+            && (gAgent.getGodLevel() >= GOD_MAINTENANCE))
 		{
 			return TRUE;
 		}
diff --git a/indra/newview/llviewerstats.cpp b/indra/newview/llviewerstats.cpp
index 9d5b301d26d..ec4f66d6811 100644
--- a/indra/newview/llviewerstats.cpp
+++ b/indra/newview/llviewerstats.cpp
@@ -47,6 +47,7 @@
 #include "llvlmanager.h"
 #include "llagent.h"
 #include "llviewercontrol.h"
+#include "llfloaterdirectory.h"
 #include "llfloatertools.h"
 #include "lldebugview.h"
 #include "llfasttimerview.h"
@@ -660,10 +661,27 @@ void send_stats()
 	F32 run_time = F32(LLFrameTimer::getElapsedSeconds());
 
 	agent["start_time"] = ltime - run_time;
-	agent["run_time"] = run_time;
+
+	// The first stat set must have a 0 run time if it doesn't actually
+	// contain useful data in terms of FPS, etc.  We use half the
+	// SEND_STATS_PERIOD seconds as the point at which these statistics become
+	// valid.  Data warehouse uses a 0 value here to easily discard these
+	// records with non-useful FPS values etc.
+	if (run_time < (SEND_STATS_PERIOD / 2))
+	{
+		agent["run_time"] = 0.0f;
+	}
+	else
+	{
+		agent["run_time"] = run_time;
+	}
+
 	// send fps only for time app spends in foreground
 	agent["fps"] = (F32)gForegroundFrameCount / gForegroundTime.getElapsedTimeF32();
 	agent["version"] = gCurrentVersion;
+	LLString language(gSavedSettings.getString("Language"));
+	if(language == "default") language = gSavedSettings.getString("SystemLanguage");	
+	agent["language"] = language;
 	
 	agent["sim_fps"] = ((F32) gFrameCount - gSimFrames) /
 		(F32) (gRenderStartTime.getElapsedTimeF32() - gSimLastTime);
@@ -680,7 +698,7 @@ void send_stats()
 	LLSD &system = body["system"];
 	
 	system["ram"] = (S32) gSysMemory.getPhysicalMemoryKB();
-	system["os"] = LLAppViewer::instance()->getOSInfo().getOSString();
+	system["os"] = LLAppViewer::instance()->getOSInfo().getOSStringSimple();
 	system["cpu"] = gSysCPU.getCPUString();
 
 	std::string gpu_desc = llformat(
@@ -725,6 +743,17 @@ void send_stats()
 	fail["off_circuit"] = (S32) gMessageSystem->mOffCircuitPackets;
 	fail["invalid"] = (S32) gMessageSystem->mInvalidOnCircuitPackets;
 
+	// Misc stats, two strings and two ints
+	// These are not expecticed to persist across multiple releases
+	// Comment any changes with your name and the expected release revision
+	// If the current revision is recent, ping the previous author before overriding
+	LLSD &misc = body["stats"]["misc"];
+
+	// misc["string_1"] = 
+	// misc["string_2"] = 
+	misc["int_1"] = LLFloaterDirectory::sOldSearchCount; // Steve: 1.18.6
+	misc["int_2"] = LLFloaterDirectory::sNewSearchCount; // Steve: 1.18.6
+	
 	gViewerStats->addToMessage(body);
 
 	LLHTTPClient::post(url, body, new ViewerStatsResponder());
diff --git a/indra/newview/llviewerstats.h b/indra/newview/llviewerstats.h
index 4c2a7412442..277bf44e480 100644
--- a/indra/newview/llviewerstats.h
+++ b/indra/newview/llviewerstats.h
@@ -187,10 +187,13 @@ class LLViewerStats
 
 extern LLViewerStats *gViewerStats;
 
+static const F32 SEND_STATS_PERIOD = 300.0f;
+
 // The following are from (older?) statistics code found in appviewer.
 void reset_statistics();
 void output_statistics(void*);
 void update_statistics(U32 frame_count);
+void send_stats();
 
 extern std::map<S32,LLFrameTimer> gDebugTimers;
 #endif // LL_LLVIEWERSTATS_H
diff --git a/indra/newview/llviewertexteditor.cpp b/indra/newview/llviewertexteditor.cpp
index 18f07efb444..5c613052eaf 100644
--- a/indra/newview/llviewertexteditor.cpp
+++ b/indra/newview/llviewertexteditor.cpp
@@ -37,6 +37,7 @@
 #include "llinventory.h"
 #include "llinventorymodel.h"
 #include "llinventoryview.h"
+#include "llinventorybridge.h"	// for landmark prefix string
 
 #include "llviewertexteditor.h"
 
@@ -1391,7 +1392,9 @@ void LLViewerTextEditor::openEmbeddedSound( LLInventoryItem* item )
 
 void LLViewerTextEditor::openEmbeddedLandmark( LLInventoryItem* item )
 {
-	open_landmark((LLViewerInventoryItem*)item, "   preview landmark", FALSE, item->getUUID(), TRUE);
+	LLString title =
+		LLString("  ") + LLLandmarkBridge::prefix()	+ item->getName();
+	open_landmark((LLViewerInventoryItem*)item, title, FALSE, item->getUUID(), TRUE);
 }
 
 void LLViewerTextEditor::openEmbeddedNotecard( LLInventoryItem* item, BOOL saved )
diff --git a/indra/newview/llviewerwindow.cpp b/indra/newview/llviewerwindow.cpp
index 4c960833377..2a496f66981 100644
--- a/indra/newview/llviewerwindow.cpp
+++ b/indra/newview/llviewerwindow.cpp
@@ -1849,16 +1849,6 @@ void LLViewerWindow::initWorldUI()
 
 		// keep onscreen
 		gFloaterView->adjustToFitScreen(gFloaterMap, FALSE);
-
-		if (gSavedSettings.getBOOL("ShowCameraControls"))
-		{
-			LLFloaterCamera::show(NULL);
-		}
-		
-		if (gSavedSettings.getBOOL("ShowMovementControls"))
-		{
-			LLFloaterMove::show(NULL);
-		}
 		
 		gIMMgr = LLIMMgr::getInstance();
 
@@ -2154,8 +2144,12 @@ void LLViewerWindow::setNormalControlsVisible( BOOL visible )
 	{
 		gMenuBarView->setVisible( visible );
 		gMenuBarView->setEnabled( visible );
+
+		// ...and set the menu color appropriately.
+		setMenuBackgroundColor(gAgent.getGodLevel() > GOD_NOT, 
+			LLAppViewer::instance()->isInProductionGrid());
 	}
-	
+        
 	if ( gStatusBar )
 	{
 		gStatusBar->setVisible( visible );	
@@ -2163,8 +2157,38 @@ void LLViewerWindow::setNormalControlsVisible( BOOL visible )
 	}
 }
 
-
-
+void LLViewerWindow::setMenuBackgroundColor(bool god_mode, bool dev_grid)
+{
+   	LLString::format_map_t args;
+    LLColor4 new_bg_color;
+
+    if(god_mode && LLAppViewer::instance()->isInProductionGrid())
+    {
+        new_bg_color = gColors.getColor( "MenuBarGodBgColor" );
+    }
+    else if(god_mode && !LLAppViewer::instance()->isInProductionGrid())
+    {
+        new_bg_color = gColors.getColor( "MenuNonProductionGodBgColor" );
+    }
+    else if(!god_mode && !LLAppViewer::instance()->isInProductionGrid())
+    {
+        new_bg_color = gColors.getColor( "MenuNonProductionBgColor" );
+    }
+    else 
+    {
+        new_bg_color = gColors.getColor( "MenuBarBgColor" );
+    }
+
+    if(gMenuBarView)
+    {
+        gMenuBarView->setBackgroundColor( new_bg_color );
+    }
+
+    if(gStatusBar)
+    {
+        gStatusBar->setBackgroundColor( new_bg_color );
+    }
+}
 
 void LLViewerWindow::drawDebugText()
 {
@@ -2369,6 +2393,18 @@ BOOL LLViewerWindow::handleKey(KEY key, MASK mask)
 		toggle_debug_menus(NULL);
 	}
 
+		// Explicit hack for debug menu.
+	if ((mask == (MASK_SHIFT | MASK_CONTROL)) &&
+		('G' == key || 'g' == key))
+	{
+		if  (LLStartUp::getStartupState() < STATE_LOGIN_CLEANUP)  //on splash page
+		{
+			BOOL visible = ! gSavedSettings.getBOOL("ForceShowGrid");
+			gSavedSettings.setBOOL("ForceShowGrid", visible);
+			LLPanelLogin::loadLoginPage();
+		}
+	}
+
 	// Example "bug" for bug reporter web page
 	if ((MASK_SHIFT & mask) 
 		&& (MASK_ALT & mask)
@@ -2410,6 +2446,11 @@ BOOL LLViewerWindow::handleKey(KEY key, MASK mask)
 	{
 		return TRUE;
 	}
+	// let menus handle navigation keys
+	if (gLoginMenuBarView && gLoginMenuBarView->handleKey(key, mask, TRUE))
+	{
+		return TRUE;
+	}
 
 	// Traverses up the hierarchy
 	LLUICtrl* keyboard_focus = gFocusMgr.getKeyboardFocus();
@@ -2515,6 +2556,12 @@ BOOL LLViewerWindow::handleKey(KEY key, MASK mask)
 	{
 		return TRUE;
 	}
+	
+	// give menus a chance to handle keys
+	if (gLoginMenuBarView && gLoginMenuBarView->handleAcceleratorKey(key, mask))
+	{
+		return TRUE;
+	}
 
 	// don't pass keys on to world when something in ui has focus
 	return gFocusMgr.childHasKeyboardFocus(mRootView) 
diff --git a/indra/newview/llviewerwindow.h b/indra/newview/llviewerwindow.h
index 36225cb7d33..612484e2dce 100644
--- a/indra/newview/llviewerwindow.h
+++ b/indra/newview/llviewerwindow.h
@@ -181,6 +181,7 @@ class LLViewerWindow : public LLWindowCallbacks
 
 	// Hide normal UI when a logon fails, re-show everything when logon is attempted again
 	void			setNormalControlsVisible( BOOL visible );
+    void            setMenuBackgroundColor(bool god_mode = false, bool dev_grid = false);
 
 	// Handle the application becoming active (frontmost) or inactive
 	//BOOL			handleActivate(BOOL activate);
diff --git a/indra/newview/llvoavatar.cpp b/indra/newview/llvoavatar.cpp
index c6a3ff192b9..1e800a372e9 100644
--- a/indra/newview/llvoavatar.cpp
+++ b/indra/newview/llvoavatar.cpp
@@ -3426,7 +3426,10 @@ void LLVOAvatar::updateCharacter(LLAgent &agent)
 //							AUDIO_STEP_LO_SPEED, AUDIO_STEP_HI_SPEED,
 //							AUDIO_STEP_LO_GAIN, AUDIO_STEP_HI_GAIN );
 
-			F32 gain = gSavedSettings.getBOOL("MuteAmbient") ? 0.f : (.30f * gSavedSettings.getF32("AudioLevelAmbient"));
+			F32 ambient_volume = gSavedSettings.getF32("AudioLevelAmbient");
+			F32 gain = gSavedSettings.getBOOL("MuteAmbient") 
+				? 0.f 
+				: (.50f * ambient_volume * ambient_volume);
 			LLUUID& step_sound_id = getStepSound();
 
 			LLVector3d foot_pos_global = gAgent.getPosGlobalFromAgent(foot_pos_agent);
diff --git a/indra/newview/llvovolume.cpp b/indra/newview/llvovolume.cpp
index 6867cacfa4d..70037d3c202 100644
--- a/indra/newview/llvovolume.cpp
+++ b/indra/newview/llvovolume.cpp
@@ -723,6 +723,7 @@ void LLVOVolume::sculpt()
 
 		
 		S32 current_discard = getVolume()->getSculptLevel();
+		llassert_always(current_discard >= -2 && current_discard <= max_discard);
 		if (current_discard == discard_level)  // no work to do here
 			return;
 		
@@ -756,7 +757,7 @@ BOOL LLVOVolume::calcLOD()
 
 	S32 cur_detail = 0;
 	
-	F32 radius = mVolumep->mLODScaleBias.scaledVec(getScale()).magVec();
+	F32 radius = getVolume()->mLODScaleBias.scaledVec(getScale()).magVec();
 	F32 distance = mDrawable->mDistanceWRTCamera;
 	distance *= sDistanceFactor;
 			
diff --git a/indra/newview/llwindebug.cpp b/indra/newview/llwindebug.cpp
index 13c5ac3bbb8..949ea71c56f 100644
--- a/indra/newview/llwindebug.cpp
+++ b/indra/newview/llwindebug.cpp
@@ -35,7 +35,6 @@
 
 #include <tchar.h>
 #include <tlhelp32.h>
-#include <atlbase.h>
 #include "llappviewer.h"
 #include "llwindebug.h"
 #include "llviewercontrol.h"
@@ -56,11 +55,11 @@ LLSD Block for Windows Dump Information
     <string></string>
     <key>Module</key>
     <string></string>
-    <key>Date Modified</key>
+    <key>DateModified</key>
     <string></string>
-    <key>Exception Code</key>
+    <key>ExceptionCode</key>
     <string></string>
-    <key>Exception Read/Write Address</key>
+    <key>ExceptionRead/WriteAddress</key>
     <string></string>
     <key>Instruction</key>
     <string></string>
@@ -75,11 +74,11 @@ LLSD Block for Windows Dump Information
     <array>
       <!-- One map per stack frame -->
       <map>
-	<key>Module Name</key>
+	<key>ModuleName</key>
 	<string></string>
-	<key>Module Base Address</key>
+	<key>ModuleBaseAddress</key>
 	<string></string>
-	<key>Module Offset Address</key>
+	<key>ModuleOffsetAddress</key>
 	<string></string>
 	<key>Parameters</key>
 	<array>
@@ -93,8 +92,6 @@ LLSD Block for Windows Dump Information
 
 */
 
-// From viewer.h
-extern BOOL gInProductionGrid;
 
 extern void (*gCrashCallback)(void);
 
@@ -124,6 +121,9 @@ MODULE32_NEST	Module32Next_;
 #define	CALL_TRACE_MAX	((DUMP_SIZE_MAX - 2000) / (MAX_PATH + 40))	//max number of traced calls
 #define	NL				L"\r\n"	//new line
 
+//Windows Call Stack Construction idea from 
+//http://www.codeproject.com/tools/minidump.asp
+
 //****************************************************************************************
 BOOL WINAPI Get_Module_By_Ret_Addr(PBYTE Ret_Addr, LPWSTR Module_Name, PBYTE & Module_Addr)
 //****************************************************************************************
@@ -168,9 +168,6 @@ void WINAPI Get_Call_Stack(PEXCEPTION_POINTERS pException, LLSD& info)
 // pException can be either GetExceptionInformation() or NULL.
 // If pException = NULL - get current call stack.
 {	
-
-	USES_CONVERSION;
-
 	LPWSTR	Module_Name = new WCHAR[MAX_PATH];
 	PBYTE	Module_Addr = 0;
 	
@@ -210,9 +207,9 @@ void WINAPI Get_Call_Stack(PEXCEPTION_POINTERS pException, LLSD& info)
 		if (Get_Module_By_Ret_Addr(Ebp->Ret_Addr, Module_Name, Module_Addr))
 		{
 			// Save module's address and full path.
-			info["Call Stack"][i]["Module Name"] = W2A(Module_Name);
-			info["Call Stack"][i]["Module Address"] = (int)Module_Addr;
-			info["Call Stack"][i]["Call Offset"] = (int)(Ebp->Ret_Addr - Module_Addr);
+			info["CallStack"][i]["ModuleName"] = ll_convert_wide_to_string(Module_Name);
+			info["CallStack"][i]["ModuleAddress"] = (int)Module_Addr;
+			info["CallStack"][i]["CallOffset"] = (int)(Ebp->Ret_Addr - Module_Addr);
 
 			LLSD params;
 			// Save 5 params of the call. We don't know the real number of params.
@@ -225,9 +222,9 @@ void WINAPI Get_Call_Stack(PEXCEPTION_POINTERS pException, LLSD& info)
 					params[j] = (int)Ebp->Param[j];
 				}
 			}
-			info["Call Stack"][i]["Parameters"] = params;
+			info["CallStack"][i]["Parameters"] = params;
 		}
-		info["Call Stack"][i]["Return Address"] = (int)Ebp->Ret_Addr;			
+		info["CallStack"][i]["ReturnAddress"] = (int)Ebp->Ret_Addr;			
 	}
 } //Get_Call_Stack
 
@@ -257,12 +254,10 @@ LLSD WINAPI Get_Exception_Info(PEXCEPTION_POINTERS pException)
 //*************************************************************
 // Allocate Str[DUMP_SIZE_MAX] and return Str with dump, if !pException - just return call stack in Str.
 {
-	USES_CONVERSION;
-
 	LLSD info;
 	LPWSTR		Str;
 	int			Str_Len;
-	int			i;
+//	int			i;
 	LPWSTR		Module_Name = new WCHAR[MAX_PATH];
 	PBYTE		Module_Addr;
 	HANDLE		hFile;
@@ -276,10 +271,9 @@ LLSD WINAPI Get_Exception_Info(PEXCEPTION_POINTERS pException)
 		return NULL;
 	
 	Get_Version_Str(info);
-
 	
 	GetModuleFileName(NULL, Str, MAX_PATH);
-	info["Process"] = W2A(Str);
+	info["Process"] = ll_convert_wide_to_string(Str);
 
 	// If exception occurred.
 	if (pException)
@@ -290,7 +284,7 @@ LLSD WINAPI Get_Exception_Info(PEXCEPTION_POINTERS pException)
 		// If module with E.ExceptionAddress found - save its path and date.
 		if (Get_Module_By_Ret_Addr((PBYTE)E.ExceptionAddress, Module_Name, Module_Addr))
 		{
-			info["Module"] = W2A(Module_Name);
+			info["Module"] = ll_convert_wide_to_string(Module_Name);
 
 			if ((hFile = CreateFile(Module_Name, GENERIC_READ, FILE_SHARE_READ, NULL, OPEN_EXISTING,
 				FILE_ATTRIBUTE_NORMAL, NULL)) != INVALID_HANDLE_VALUE)
@@ -300,17 +294,17 @@ LLSD WINAPI Get_Exception_Info(PEXCEPTION_POINTERS pException)
 					FileTimeToLocalFileTime(&Last_Write_Time, &Local_File_Time);
 					FileTimeToSystemTime(&Local_File_Time, &T);
 
-					info["Date Modified"] = llformat("%02d/%02d/%d", T.wMonth, T.wDay, T.wYear);
+					info["DateModified"] = llformat("%02d/%02d/%d", T.wMonth, T.wDay, T.wYear);
 				}
 				CloseHandle(hFile);
 			}
 		}
 		else
 		{
-			info["Exception Addr"] = (int)E.ExceptionAddress;
+			info["ExceptionAddr"] = (int)E.ExceptionAddress;
 		}
 		
-		info["Exception Code"] = (int)E.ExceptionCode;
+		info["ExceptionCode"] = (int)E.ExceptionCode;
 		
 		/*
 		//TODO: Fix this
@@ -326,11 +320,12 @@ LLSD WINAPI Get_Exception_Info(PEXCEPTION_POINTERS pException)
 
 		
 		// Save instruction that caused exception.
-		Str_Len = 0;
+		/*
+		LLString str;
 		for (i = 0; i < 16; i++)
-			Str_Len += wsprintf(Str + Str_Len, L" %02X", PBYTE(E.ExceptionAddress)[i]);
-		info["Instruction"] = W2A(Str);
-
+			str += llformat(" %02X", PBYTE(E.ExceptionAddress)[i]);
+		info["Instruction"] = str;
+		*/
 		LLSD registers;
 		registers["EAX"] = (int)C.Eax;
 		registers["EBX"] = (int)C.Ebx;
@@ -348,10 +343,6 @@ LLSD WINAPI Get_Exception_Info(PEXCEPTION_POINTERS pException)
 	// Save call stack info.
 	Get_Call_Stack(pException, info);
 
-	if (Str[0] == NL[0])
-		lstrcpy(Str, Str + sizeof(NL) - 1);
-	
-
 	return info;
 } //Get_Exception_Info
 
diff --git a/indra/test/llhttpclient_tut.cpp b/indra/test/llhttpclient_tut.cpp
index b29caf91f4e..21a0771d26a 100644
--- a/indra/test/llhttpclient_tut.cpp
+++ b/indra/test/llhttpclient_tut.cpp
@@ -341,6 +341,14 @@ namespace tut
 		ensure_equals("echoed result matches", body.size(), expected.size());
 	}
 
+	template<> template<>
+	void HTTPClientTestObject::test<8>()
+	{
+		LLHTTPClient::head("http://www.secondlife.com/", newResult());
+		runThePump();
+		ensureStatusOK();
+		ensure("result object wasn't destroyed", mResultDeleted);
+	}
 }
 
 #endif	// !LL_WINDOWS
diff --git a/indra/win_crash_logger/StdAfx.h b/indra/win_crash_logger/StdAfx.h
index d954823c748..3d43115d42c 100644
--- a/indra/win_crash_logger/StdAfx.h
+++ b/indra/win_crash_logger/StdAfx.h
@@ -51,9 +51,6 @@
 #include <stdlib.h>
 #include <malloc.h>
 #include <memory.h>
-#include <tchar.h>
-#include <atlbase.h>
-
 
 // Local Header Files
 
diff --git a/indra/win_crash_logger/llcrashloggerwindows.cpp b/indra/win_crash_logger/llcrashloggerwindows.cpp
index 007e2b0ed51..ab8f6939f12 100644
--- a/indra/win_crash_logger/llcrashloggerwindows.cpp
+++ b/indra/win_crash_logger/llcrashloggerwindows.cpp
@@ -48,6 +48,7 @@
 #include "llsdserialize.h"
 
 #define MAX_LOADSTRING 100
+#define MAX_STRING 2048
 const char* const SETTINGS_FILE_HEADER = "version";
 const S32 SETTINGS_FILE_VERSION = 101;
 
@@ -58,12 +59,33 @@ HINSTANCE hInst= NULL;					// current instance
 TCHAR szTitle[MAX_LOADSTRING];				/* Flawfinder: ignore */		// The title bar text
 TCHAR szWindowClass[MAX_LOADSTRING];		/* Flawfinder: ignore */		// The title bar text
 
+LLString gProductName;
 HWND gHwndReport = NULL;	// Send/Don't Send dialog
 HWND gHwndProgress = NULL;	// Progress window
 HCURSOR gCursorArrow = NULL;
 HCURSOR gCursorWait = NULL;
 BOOL gFirstDialog = TRUE;	// Are we currently handling the Send/Don't Send dialog?
 std::stringstream gDXInfo;
+bool gSendLogs = false;
+
+
+//Conversion from char* to wchar*
+//Replacement for ATL macros, doesn't allocate memory
+//For more info see: http://www.codeguru.com/forum/showthread.php?t=337247
+void ConvertLPCSTRToLPWSTR (const char* pCstring, WCHAR* outStr)
+{
+    if (pCstring != NULL)
+    {
+        int nInputStrLen = strlen (pCstring);
+        // Double NULL Termination
+        int nOutputStrLen = MultiByteToWideChar(CP_ACP, 0, pCstring, nInputStrLen, NULL, 0) + 2;
+        if (outStr)
+        {
+            memset (outStr, 0x00, sizeof (WCHAR)*nOutputStrLen);
+            MultiByteToWideChar (CP_ACP, 0, pCstring, nInputStrLen, outStr, nInputStrLen);
+        }
+    }
+}
 
 void write_debug(const char *str)
 {
@@ -116,27 +138,30 @@ void sleep_and_pump_messages( U32 seconds )
 // Include product name in the window caption.
 void LLCrashLoggerWindows::ProcessCaption(HWND hWnd)
 {
-	TCHAR templateText[1024];		/* Flawfinder: ignore */
-	TCHAR finalText[2048];		/* Flawfinder: ignore */
+	TCHAR templateText[MAX_STRING];		/* Flawfinder: ignore */
+	TCHAR header[MAX_STRING];
+	std::string final;
 	GetWindowText(hWnd, templateText, sizeof(templateText));
-	swprintf(finalText, sizeof(CA2T(mProductName.c_str())), templateText, CA2T(mProductName.c_str()));		/* Flawfinder: ignore */
-	SetWindowText(hWnd, finalText);
+	final = llformat(ll_convert_wide_to_string(templateText).c_str(), gProductName.c_str());
+	ConvertLPCSTRToLPWSTR(final.c_str(), header);
+	SetWindowText(hWnd, header);
 }
 
 
 // Include product name in the diaog item text.
 void LLCrashLoggerWindows::ProcessDlgItemText(HWND hWnd, int nIDDlgItem)
 {
-	TCHAR templateText[1024];		/* Flawfinder: ignore */
-	TCHAR finalText[2048];		/* Flawfinder: ignore */
+	TCHAR templateText[MAX_STRING];		/* Flawfinder: ignore */
+	TCHAR header[MAX_STRING];
+	std::string final;
 	GetDlgItemText(hWnd, nIDDlgItem, templateText, sizeof(templateText));
-	swprintf(finalText, sizeof(CA2T(mProductName.c_str())), templateText, CA2T(mProductName.c_str()));		/* Flawfinder: ignore */
-	SetDlgItemText(hWnd, nIDDlgItem, finalText);
+	final = llformat(ll_convert_wide_to_string(templateText).c_str(), gProductName.c_str());
+	ConvertLPCSTRToLPWSTR(final.c_str(), header);
+	SetDlgItemText(hWnd, nIDDlgItem, header);
 }
 
 bool handle_button_click(WORD button_id)
 {
-	USES_CONVERSION;
 	// Is this something other than Send or Don't Send?
 	if (button_id != IDOK
 		&& button_id != IDCANCEL)
@@ -166,13 +191,14 @@ bool handle_button_click(WORD button_id)
 	// Send the crash report if requested
 	if (button_id == IDOK)
 	{
+		gSendLogs = TRUE;
 		WCHAR wbuffer[20000];
 		GetDlgItemText(gHwndReport, // handle to dialog box
 						IDC_EDIT1,  // control identifier
 						wbuffer, // pointer to buffer for text
 						20000 // maximum size of string
 						);
-		LLString user_text(T2CA(wbuffer));
+		LLString user_text(ll_convert_wide_to_string(wbuffer));
 		// Activate and show the window.
 		ShowWindow(gHwndProgress, SW_SHOW); 
 		// Try doing this second to make the progress window go frontmost.
@@ -276,11 +302,10 @@ void LLCrashLoggerWindows::gatherPlatformSpecificFiles()
 bool LLCrashLoggerWindows::mainLoop()
 {	
 
-	USES_CONVERSION;
-
 	// Note: parent hwnd is 0 (the desktop).  No dlg proc.  See Petzold (5th ed) HexCalc example, Chapter 11, p529
 	// win_crash_logger.rc has been edited by hand.
 	// Dialogs defined with CLASS "WIN_CRASH_LOGGER" (must be same as szWindowClass)
+	gProductName = mProductName;
 
 	gHwndProgress = CreateDialog(hInst, MAKEINTRESOURCE(IDD_PROGRESS), 0, NULL);
 	ProcessCaption(gHwndProgress);
@@ -294,22 +319,23 @@ bool LLCrashLoggerWindows::mainLoop()
 	else if (mCrashBehavior == CRASH_BEHAVIOR_ASK)
 	{
 		gHwndReport = CreateDialog(hInst, MAKEINTRESOURCE(IDD_PREVREPORTBOX), 0, NULL);
-
+		LRESULT result = SendDlgItemMessage(gHwndReport, IDC_CHECK_AUTO, BM_SETCHECK, 1, 0);
 		// Include the product name in the caption and various dialog items.
 		ProcessCaption(gHwndReport);
 		ProcessDlgItemText(gHwndReport, IDC_STATIC_MSG);
 
 		// Update the header to include whether or not we crashed on the last run.
-		TCHAR header[2048];
-		CA2T product(mProductName.c_str());
+		std::string headerStr;
+		TCHAR header[MAX_STRING];
 		if (mCrashInPreviousExec)
 		{
-			swprintf(header, _T("%s appears to have crashed or frozen the last time it ran."), product);		/* Flawfinder: ignore */
+			headerStr = llformat("%s appears to have crashed or frozen the last time it ran.", mProductName.c_str());
 		}
 		else
 		{
-			swprintf(header, _T("%s appears to have crashed."), product);		/* Flawfinder: ignore */
+			headerStr = llformat("%s appears to have crashed.", mProductName.c_str());
 		}
+		ConvertLPCSTRToLPWSTR(headerStr.c_str(), header);
 		SetDlgItemText(gHwndReport, IDC_STATIC_HEADER, header);		
 		ShowWindow(gHwndReport, SW_SHOW );
 		
@@ -338,11 +364,15 @@ void LLCrashLoggerWindows::updateApplication(LLString message)
 
 bool LLCrashLoggerWindows::cleanup()
 {
-	if(mSentCrashLogs) show_progress("Done");
-	else show_progress("Could not connect to servers, logs not sent");
-	sleep_and_pump_messages(3);
-
+	if(gSendLogs)
+	{
+		if(mSentCrashLogs) show_progress("Done");
+		else show_progress("Could not connect to servers, logs not sent");
+		sleep_and_pump_messages(3);
+	}
 	PostQuitMessage(0);
 	return true;
 }
 
+
+
-- 
GitLab