Merged in pile of fixes from Ansariel

Mon, 27 Feb 2012 23:59:10 -0800

author
Kadah_Coba <kadah.coba@gmail.com>
date
Mon, 27 Feb 2012 23:59:10 -0800
changeset 1624
693177f51f33
parent 1623
f1619d9f0ce0
parent 1619
534401934b7a
child 1625
d10f3caca2fe

Merged in pile of fixes from Ansariel

indra/newview/app_settings/settings.xml file | annotate | diff | revisions
indra/newview/llpanelaudioprefs.cpp file | annotate | diff | revisions
indra/newview/llpanelaudioprefs.h file | annotate | diff | revisions
indra/newview/llpanelmorph.cpp file | annotate | diff | revisions
indra/newview/llpanelmorph.h file | annotate | diff | revisions
indra/newview/skins/default/xui/da/panel_preferences_audio.xml file | annotate | diff | revisions
indra/newview/skins/default/xui/de/panel_preferences_audio.xml file | annotate | diff | revisions
indra/newview/skins/default/xui/en-us/panel_preferences_audio.xml file | annotate | diff | revisions
indra/newview/skins/default/xui/es/panel_preferences_audio.xml file | annotate | diff | revisions
indra/newview/skins/default/xui/fr/panel_preferences_audio.xml file | annotate | diff | revisions
indra/newview/skins/default/xui/hu/panel_preferences_audio.xml file | annotate | diff | revisions
indra/newview/skins/default/xui/it/panel_preferences_audio.xml file | annotate | diff | revisions
indra/newview/skins/default/xui/ja/panel_preferences_audio.xml file | annotate | diff | revisions
indra/newview/skins/default/xui/ko/panel_preferences_audio.xml file | annotate | diff | revisions
indra/newview/skins/default/xui/nl/panel_preferences_audio.xml file | annotate | diff | revisions
indra/newview/skins/default/xui/pl/panel_preferences_audio.xml file | annotate | diff | revisions
indra/newview/skins/default/xui/pt/panel_preferences_audio.xml file | annotate | diff | revisions
indra/newview/skins/default/xui/ru/panel_preferences_audio.xml file | annotate | diff | revisions
indra/newview/skins/default/xui/tr/panel_preferences_audio.xml file | annotate | diff | revisions
indra/newview/skins/default/xui/uk/panel_preferences_audio.xml file | annotate | diff | revisions
indra/newview/skins/default/xui/zh/panel_preferences_audio.xml file | annotate | diff | revisions
     1.1 --- a/indra/llaudio/llaudioengine.cpp	Mon Feb 27 23:28:58 2012 -0800
     1.2 +++ b/indra/llaudio/llaudioengine.cpp	Mon Feb 27 23:59:10 2012 -0800
     1.3 @@ -534,7 +534,7 @@
     1.4  	{
     1.5  		if (adp->hasDecodedData())
     1.6  		{
     1.7 -			adp->load();
     1.8 +			return adp->load();
     1.9  		}
    1.10  		else if (adp->hasLocalData())
    1.11  		{
    1.12 @@ -1434,7 +1434,7 @@
    1.13  	{
    1.14  		if (getCurrentData())
    1.15  		{
    1.16 -			// Hack - try and load the sound.  Will do this as a callback
    1.17 +			// Hack - try and load the sound. Will do this as a callback
    1.18  			// on decode later.
    1.19  			if (getCurrentData()->load())
    1.20  			{
     2.1 --- a/indra/llaudio/llaudioengine_openal.cpp	Mon Feb 27 23:28:58 2012 -0800
     2.2 +++ b/indra/llaudio/llaudioengine_openal.cpp	Mon Feb 27 23:59:10 2012 -0800
     2.3 @@ -341,6 +341,12 @@
     2.4  
     2.5  bool LLAudioBufferOpenAL::loadWAV(const std::string& filename)
     2.6  {
     2.7 +	if (filename.empty())
     2.8 +	{
     2.9 +		// invalid filename, abort.
    2.10 +		return false;
    2.11 +	}
    2.12 +
    2.13  	cleanup();
    2.14  	mALBuffer = alutCreateBufferFromFile(filename.c_str());
    2.15  	if(mALBuffer == AL_NONE)
    2.16 @@ -352,6 +358,12 @@
    2.17  				"LLAudioBufferOpenAL::loadWAV() Error loading "
    2.18  				<< filename
    2.19  				<< " " << alutGetErrorString(error) << llendl;
    2.20 +			//
    2.21 +			// If we EVER want to load wav files provided by end users, we need
    2.22 +			// to rethink this!
    2.23 +			//
    2.24 +			// file is probably corrupt - remove it.
    2.25 +			LLFile::remove(filename);
    2.26  		}
    2.27  		else
    2.28  		{
     3.1 --- a/indra/llcommon/llfasttimer.h	Mon Feb 27 23:28:58 2012 -0800
     3.2 +++ b/indra/llcommon/llfasttimer.h	Mon Feb 27 23:59:10 2012 -0800
     3.3 @@ -173,6 +173,7 @@
     3.4  		FTM_LOD_UPDATE,
     3.5  		FTM_UPDATE_RIGGED_VOLUME,
     3.6  		FTM_SKIN_RIGGED,
     3.7 +		FTM_SKIN_RIGGED_DEFORM,
     3.8  		FTM_RIGGED_OCTREE,
     3.9  		FTM_REGION_UPDATE,
    3.10  		FTM_CLEANUP,
    3.11 @@ -200,6 +201,7 @@
    3.12  
    3.13  //		FTM_VFILE_WAIT,			// Disabled because it would be called from a thread in the mesh repository
    3.14  		FTM_FLEXIBLE_UPDATE,
    3.15 +		FTM_OCCLUSION_WAIT,
    3.16  		FTM_OCCLUSION_READBACK,
    3.17  		FTM_BUILD_OCCLUSION,
    3.18  		FTM_PUSH_OCCLUSION_VERTS,
    3.19 @@ -213,6 +215,11 @@
    3.20  		FTM_REFRESH,
    3.21  		FTM_SORT,
    3.22  		FTM_PICK,
    3.23 +		FTM_TEXTURE_CACHE,
    3.24 +		FTM_DECODE,
    3.25 +		FTM_FETCH,
    3.26 +		FTM_VFS,
    3.27 +		FTM_LFS,
    3.28  		
    3.29  		// Temp
    3.30  		FTM_TEMP1,
     4.1 --- a/indra/llcommon/llprocessor.cpp	Mon Feb 27 23:28:58 2012 -0800
     4.2 +++ b/indra/llcommon/llprocessor.cpp	Mon Feb 27 23:59:10 2012 -0800
     4.3 @@ -44,20 +44,6 @@
     4.4  
     4.5  #include "llsd.h"
     4.6  
     4.7 -#if LL_MSVC && _M_X64
     4.8 -#      define LL_X86_64 1
     4.9 -#      define LL_X86 1
    4.10 -#elif LL_MSVC && _M_IX86
    4.11 -#      define LL_X86 1
    4.12 -#elif LL_GNUC && ( defined(__amd64__) || defined(__x86_64__) )
    4.13 -#      define LL_X86_64 1
    4.14 -#      define LL_X86 1
    4.15 -#elif LL_GNUC && ( defined(__i386__) )
    4.16 -#      define LL_X86 1
    4.17 -#elif LL_GNUC && ( defined(__powerpc__) || defined(__ppc__) )
    4.18 -#      define LL_PPC 1
    4.19 -#endif
    4.20 -
    4.21  class LLProcessorInfoImpl; // foward declaration for the mImpl;
    4.22  
    4.23  namespace 
     5.1 --- a/indra/llcommon/llprocessor.h	Mon Feb 27 23:28:58 2012 -0800
     5.2 +++ b/indra/llcommon/llprocessor.h	Mon Feb 27 23:59:10 2012 -0800
     5.3 @@ -27,6 +27,21 @@
     5.4  
     5.5  #ifndef LLPROCESSOR_H
     5.6  #define LLPROCESSOR_H
     5.7 +
     5.8 +#if LL_MSVC && _M_X64
     5.9 +#      define LL_X86_64 1
    5.10 +#      define LL_X86 1
    5.11 +#elif LL_MSVC && _M_IX86
    5.12 +#      define LL_X86 1
    5.13 +#elif LL_GNUC && ( defined(__amd64__) || defined(__x86_64__) )
    5.14 +#      define LL_X86_64 1
    5.15 +#      define LL_X86 1
    5.16 +#elif LL_GNUC && ( defined(__i386__) )
    5.17 +#      define LL_X86 1
    5.18 +#elif LL_GNUC && ( defined(__powerpc__) || defined(__ppc__) )
    5.19 +#      define LL_PPC 1
    5.20 +#endif
    5.21 +
    5.22  class LLProcessorInfoImpl;
    5.23  
    5.24  class LL_COMMON_API LLProcessorInfo
     6.1 --- a/indra/llcommon/llqueuedthread.cpp	Mon Feb 27 23:28:58 2012 -0800
     6.2 +++ b/indra/llcommon/llqueuedthread.cpp	Mon Feb 27 23:59:10 2012 -0800
     6.3 @@ -115,7 +115,7 @@
     6.4  
     6.5  // MAIN THREAD
     6.6  // virtual
     6.7 -S32 LLQueuedThread::update(U32 max_time_ms)
     6.8 +S32 LLQueuedThread::update(F32 max_time_ms)
     6.9  {
    6.10  	if (!mStarted)
    6.11  	{
    6.12 @@ -128,7 +128,7 @@
    6.13  	return updateQueue(max_time_ms);
    6.14  }
    6.15  
    6.16 -S32 LLQueuedThread::updateQueue(U32 max_time_ms)
    6.17 +S32 LLQueuedThread::updateQueue(F32 max_time_ms)
    6.18  {
    6.19  	F64 max_time = (F64)max_time_ms * .001;
    6.20  	LLTimer timer;
     7.1 --- a/indra/llcommon/llqueuedthread.h	Mon Feb 27 23:28:58 2012 -0800
     7.2 +++ b/indra/llcommon/llqueuedthread.h	Mon Feb 27 23:59:10 2012 -0800
     7.3 @@ -180,8 +180,8 @@
     7.4  public:
     7.5  	bool waitForResult(handle_t handle, bool auto_complete = true);
     7.6  
     7.7 -	virtual S32 update(U32 max_time_ms);
     7.8 -	S32 updateQueue(U32 max_time_ms);
     7.9 +	virtual S32 update(F32 max_time_ms);
    7.10 +	S32 updateQueue(F32 max_time_ms);
    7.11  	
    7.12  	void waitOnPending();
    7.13  	void printQueueStats();
     8.1 --- a/indra/llcommon/llworkerthread.cpp	Mon Feb 27 23:28:58 2012 -0800
     8.2 +++ b/indra/llcommon/llworkerthread.cpp	Mon Feb 27 23:59:10 2012 -0800
     8.3 @@ -84,7 +84,7 @@
     8.4  }
     8.5  
     8.6  // virtual
     8.7 -S32 LLWorkerThread::update(U32 max_time_ms)
     8.8 +S32 LLWorkerThread::update(F32 max_time_ms)
     8.9  {
    8.10  	S32 res = LLQueuedThread::update(max_time_ms);
    8.11  	// Delete scheduled workers
     9.1 --- a/indra/llcommon/llworkerthread.h	Mon Feb 27 23:28:58 2012 -0800
     9.2 +++ b/indra/llcommon/llworkerthread.h	Mon Feb 27 23:59:10 2012 -0800
     9.3 @@ -94,7 +94,7 @@
     9.4  				   bool should_pause = false);
     9.5  	~LLWorkerThread();
     9.6  
     9.7 -	/*virtual*/ S32 update(U32 max_time_ms);
     9.8 +	/*virtual*/ S32 update(F32 max_time_ms);
     9.9  	
    9.10  	handle_t addWorkRequest(LLWorkerClass* workerclass, S32 param, U32 priority = PRIORITY_NORMAL);
    9.11  	
    10.1 --- a/indra/llimage/llimage.cpp	Mon Feb 27 23:28:58 2012 -0800
    10.2 +++ b/indra/llimage/llimage.cpp	Mon Feb 27 23:59:10 2012 -0800
    10.3 @@ -180,7 +180,8 @@
    10.4  		mData = new U8[size];
    10.5  		if (!mData)
    10.6  		{
    10.7 -			llwarns << "allocate image data: " << size << llendl;
    10.8 +			llwarns << "Could not allocate image data for requested size: "
    10.9 +					<< size << llendl;
   10.10  			size = 0 ;
   10.11  			mWidth = mHeight = 0 ;
   10.12  			mBadBufferAllocation = true ;
    11.1 --- a/indra/llimage/llimageworker.cpp	Mon Feb 27 23:28:58 2012 -0800
    11.2 +++ b/indra/llimage/llimageworker.cpp	Mon Feb 27 23:59:10 2012 -0800
    11.3 @@ -50,7 +50,7 @@
    11.4  
    11.5  // MAIN THREAD
    11.6  // virtual
    11.7 -S32 LLImageDecodeThread::update(U32 max_time_ms)
    11.8 +S32 LLImageDecodeThread::update(F32 max_time_ms)
    11.9  {
   11.10  	LLMutexLock lock(&mCreationMutex);
   11.11  	for (creation_list_t::iterator iter = mCreationList.begin();
    12.1 --- a/indra/llimage/llimageworker.h	Mon Feb 27 23:28:58 2012 -0800
    12.2 +++ b/indra/llimage/llimageworker.h	Mon Feb 27 23:59:10 2012 -0800
    12.3 @@ -84,7 +84,7 @@
    12.4  	handle_t decodeImage(LLImageFormatted* image,
    12.5  						 U32 priority, S32 discard, BOOL needs_aux,
    12.6  						 Responder* responder);
    12.7 -	S32 update(U32 max_time_ms);
    12.8 +	S32 update(F32 max_time_ms);
    12.9  
   12.10  	// Used by unit tests to check the consistency of the thread instance
   12.11  	S32 tut_size();
    13.1 --- a/indra/llmath/llvolume.cpp	Mon Feb 27 23:28:58 2012 -0800
    13.2 +++ b/indra/llmath/llvolume.cpp	Mon Feb 27 23:59:10 2012 -0800
    13.3 @@ -4267,13 +4267,21 @@
    13.4  	return count;
    13.5  }
    13.6  
    13.7 -S32 LLVolume::getNumTriangles() const
    13.8 -{
    13.9 -	U32 triangle_count = 0;
   13.10 +S32 LLVolume::getNumTriangles(S32* vcount) const
   13.11 +{
   13.12 + 	U32 triangle_count = 0;
   13.13 +	U32 vertex_count = 0;
   13.14  
   13.15  	for (S32 i = 0; i < getNumVolumeFaces(); ++i)
   13.16  	{
   13.17 -		triangle_count += getVolumeFace(i).mNumIndices/3;
   13.18 +		const LLVolumeFace& face = getVolumeFace(i);
   13.19 +		triangle_count += face.mNumIndices / 3;
   13.20 +		vertex_count += face.mNumVertices;
   13.21 +	}
   13.22 +
   13.23 +	if (vcount)
   13.24 +	{
   13.25 +		*vcount = vertex_count;
   13.26  	}
   13.27  
   13.28  	return triangle_count;
   13.29 @@ -4562,23 +4570,88 @@
   13.30  
   13.31          if (LLLineSegmentBoxIntersect(start, end, box_center, box_size))
   13.32  		{
   13.33 -			if (bi_normal != NULL) // if the caller wants binormals, we may need to generate them
   13.34 +			// if the caller wants binormals, we may need to generate them
   13.35 +			if (bi_normal != NULL)
   13.36  			{
   13.37  				genBinormals(i);
   13.38  			}
   13.39  
   13.40 -			if (!face.mOctree)
   13.41 +			if (isUnique())
   13.42 +			{	// don't bother with an octree for flexi volumes
   13.43 +				U32 tri_count = face.mNumIndices / 3;
   13.44 +
   13.45 +				for (U32 j = 0; j < tri_count; ++j)
   13.46 +				{
   13.47 +					U16 idx0 = face.mIndices[j * 3];
   13.48 +					U16 idx1 = face.mIndices[j * 3 + 1];
   13.49 +					U16 idx2 = face.mIndices[j * 3 + 2];
   13.50 +
   13.51 +					const LLVector4a& v0 = face.mPositions[idx0];
   13.52 +					const LLVector4a& v1 = face.mPositions[idx1];
   13.53 +					const LLVector4a& v2 = face.mPositions[idx2];
   13.54 +
   13.55 +					F32 a,b,t;
   13.56 +
   13.57 +					if (LLTriangleRayIntersect(v0, v1, v2, start, dir, a, b, t))
   13.58 +					{
   13.59 +						if (t >= 0.f &&		// if hit is after start
   13.60 +							t <= 1.f &&		// and before end
   13.61 +							t < closest_t)	// and this hit is closer
   13.62 +						{
   13.63 +							closest_t = t;
   13.64 +							hit_face = i;
   13.65 +
   13.66 +							if (intersection != NULL)
   13.67 +							{
   13.68 +								LLVector4a intersect = dir;
   13.69 +								intersect.mul(closest_t);
   13.70 +								intersect.add(start);
   13.71 +								intersection->set(intersect.getF32ptr());
   13.72 +							}
   13.73 +
   13.74 +							if (tex_coord != NULL)
   13.75 +							{
   13.76 +								LLVector2* tc = (LLVector2*) face.mTexCoords;
   13.77 +								*tex_coord = (1.f - a - b) * tc[idx0] +
   13.78 +											 a * tc[idx1] + b * tc[idx2];
   13.79 +							}
   13.80 +
   13.81 +							if (normal != NULL)
   13.82 +							{
   13.83 +								LLVector4* norm = (LLVector4*) face.mNormals;
   13.84 +
   13.85 +								*normal = (1.f - a - b) * LLVector3(norm[idx0]) +
   13.86 +										  a * LLVector3(norm[idx1]) +
   13.87 +										  b * LLVector3(norm[idx2]);
   13.88 +							}
   13.89 +
   13.90 +							if (bi_normal != NULL)
   13.91 +							{
   13.92 +								LLVector4* binormal = (LLVector4*) face.mBinormals;
   13.93 +								*bi_normal = (1.f - a - b) * LLVector3(binormal[idx0]) +
   13.94 +											 a * LLVector3(binormal[idx1]) +
   13.95 +											 b * LLVector3(binormal[idx2]);
   13.96 +							}
   13.97 +						}
   13.98 +					}
   13.99 +				}
  13.100 +			}
  13.101 +			else
  13.102  			{
  13.103 -				face.createOctree();
  13.104 -			}
  13.105 -
  13.106 -			//LLVector4a* p = (LLVector4a*) face.mPositions;
  13.107 -
  13.108 -			LLOctreeTriangleRayIntersect intersect(start, dir, &face, &closest_t, intersection, tex_coord, normal, bi_normal);
  13.109 -			intersect.traverse(face.mOctree);
  13.110 -			if (intersect.mHitFace)
  13.111 -			{
  13.112 -				hit_face = i;
  13.113 +				if (!face.mOctree)
  13.114 +				{
  13.115 +					face.createOctree();
  13.116 +				}
  13.117 +
  13.118 +				LLOctreeTriangleRayIntersect intersect(start, dir, &face,
  13.119 +													   &closest_t, intersection,
  13.120 +													   tex_coord, normal,
  13.121 +													   bi_normal);
  13.122 +				intersect.traverse(face.mOctree);
  13.123 +				if (intersect.mHitFace)
  13.124 +				{
  13.125 +					hit_face = i;
  13.126 +				}
  13.127  			}
  13.128  		}
  13.129  	}
    14.1 --- a/indra/llmath/llvolume.h	Mon Feb 27 23:28:58 2012 -0800
    14.2 +++ b/indra/llmath/llvolume.h	Mon Feb 27 23:59:10 2012 -0800
    14.3 @@ -999,7 +999,7 @@
    14.4  	S32 getNumTriangleIndices() const;
    14.5  	static void getLoDTriangleCounts(const LLVolumeParams& params, S32* counts);
    14.6  
    14.7 -	S32 getNumTriangles() const;
    14.8 +	S32 getNumTriangles(S32* vcount = NULL) const;
    14.9  
   14.10  	void generateSilhouetteVertices(std::vector<LLVector3> &vertices, 
   14.11  									std::vector<LLVector3> &normals, 
    15.1 --- a/indra/llmath/m4math.cpp	Mon Feb 27 23:28:58 2012 -0800
    15.2 +++ b/indra/llmath/m4math.cpp	Mon Feb 27 23:59:10 2012 -0800
    15.3 @@ -280,6 +280,64 @@
    15.4  	return *this;
    15.5  }
    15.6  
    15.7 +// does an actual inversion
    15.8 +const LLMatrix4& LLMatrix4::invert_real()
    15.9 +{
   15.10 +	F32* m = &mMatrix[0][0];
   15.11 +
   15.12 +	F32 inv[16];
   15.13 +	F32 det;
   15.14 +
   15.15 +	inv[0] =   m[5]*m[10]*m[15] - m[5]*m[11]*m[14] - m[9]*m[6]*m[15]
   15.16 +	+ m[9]*m[7]*m[14] + m[13]*m[6]*m[11] - m[13]*m[7]*m[10];
   15.17 +	inv[4] =  -m[4]*m[10]*m[15] + m[4]*m[11]*m[14] + m[8]*m[6]*m[15]
   15.18 +	- m[8]*m[7]*m[14] - m[12]*m[6]*m[11] + m[12]*m[7]*m[10];
   15.19 +	inv[8] =   m[4]*m[9]*m[15] - m[4]*m[11]*m[13] - m[8]*m[5]*m[15]
   15.20 +	+ m[8]*m[7]*m[13] + m[12]*m[5]*m[11] - m[12]*m[7]*m[9];
   15.21 +	inv[12] = -m[4]*m[9]*m[14] + m[4]*m[10]*m[13] + m[8]*m[5]*m[14]
   15.22 +	- m[8]*m[6]*m[13] - m[12]*m[5]*m[10] + m[12]*m[6]*m[9];
   15.23 +	inv[1] =  -m[1]*m[10]*m[15] + m[1]*m[11]*m[14] + m[9]*m[2]*m[15]
   15.24 +	- m[9]*m[3]*m[14] - m[13]*m[2]*m[11] + m[13]*m[3]*m[10];
   15.25 +	inv[5] =   m[0]*m[10]*m[15] - m[0]*m[11]*m[14] - m[8]*m[2]*m[15]
   15.26 +	+ m[8]*m[3]*m[14] + m[12]*m[2]*m[11] - m[12]*m[3]*m[10];
   15.27 +	inv[9] =  -m[0]*m[9]*m[15] + m[0]*m[11]*m[13] + m[8]*m[1]*m[15]
   15.28 +	- m[8]*m[3]*m[13] - m[12]*m[1]*m[11] + m[12]*m[3]*m[9];
   15.29 +	inv[13] =  m[0]*m[9]*m[14] - m[0]*m[10]*m[13] - m[8]*m[1]*m[14]
   15.30 +	+ m[8]*m[2]*m[13] + m[12]*m[1]*m[10] - m[12]*m[2]*m[9];
   15.31 +	inv[2] =   m[1]*m[6]*m[15] - m[1]*m[7]*m[14] - m[5]*m[2]*m[15]
   15.32 +	+ m[5]*m[3]*m[14] + m[13]*m[2]*m[7] - m[13]*m[3]*m[6];
   15.33 +	inv[6] =  -m[0]*m[6]*m[15] + m[0]*m[7]*m[14] + m[4]*m[2]*m[15]
   15.34 +	- m[4]*m[3]*m[14] - m[12]*m[2]*m[7] + m[12]*m[3]*m[6];
   15.35 +	inv[10] =  m[0]*m[5]*m[15] - m[0]*m[7]*m[13] - m[4]*m[1]*m[15]
   15.36 +	+ m[4]*m[3]*m[13] + m[12]*m[1]*m[7] - m[12]*m[3]*m[5];
   15.37 +	inv[14] = -m[0]*m[5]*m[14] + m[0]*m[6]*m[13] + m[4]*m[1]*m[14]
   15.38 +	- m[4]*m[2]*m[13] - m[12]*m[1]*m[6] + m[12]*m[2]*m[5];
   15.39 +	inv[3] =  -m[1]*m[6]*m[11] + m[1]*m[7]*m[10] + m[5]*m[2]*m[11]
   15.40 +	- m[5]*m[3]*m[10] - m[9]*m[2]*m[7] + m[9]*m[3]*m[6];
   15.41 +	inv[7] =   m[0]*m[6]*m[11] - m[0]*m[7]*m[10] - m[4]*m[2]*m[11]
   15.42 +	+ m[4]*m[3]*m[10] + m[8]*m[2]*m[7] - m[8]*m[3]*m[6];
   15.43 +	inv[11] = -m[0]*m[5]*m[11] + m[0]*m[7]*m[9] + m[4]*m[1]*m[11]
   15.44 +	- m[4]*m[3]*m[9] - m[8]*m[1]*m[7] + m[8]*m[3]*m[5];
   15.45 +	inv[15] =  m[0]*m[5]*m[10] - m[0]*m[6]*m[9] - m[4]*m[1]*m[10]
   15.46 +	+ m[4]*m[2]*m[9] + m[8]*m[1]*m[6] - m[8]*m[2]*m[5];
   15.47 +
   15.48 +	det = m[0]*inv[0] + m[1]*inv[4] + m[2]*inv[8] + m[3]*inv[12];
   15.49 +
   15.50 +	if (det == 0)
   15.51 +	{
   15.52 +		setZero();
   15.53 +	}
   15.54 +	else 
   15.55 +	{
   15.56 +		det = 1.0 / det;
   15.57 +
   15.58 +		for (int i = 0; i < 16; i++)
   15.59 +			m[i] = inv[i] * det;
   15.60 +	}
   15.61 +
   15.62 +	return *this;
   15.63 +}
   15.64 +
   15.65  LLVector4 LLMatrix4::getFwdRow4() const
   15.66  {
   15.67  	return LLVector4(mMatrix[VX][VX], mMatrix[VX][VY], mMatrix[VX][VZ], mMatrix[VX][VW]);
    16.1 --- a/indra/llmath/m4math.h	Mon Feb 27 23:28:58 2012 -0800
    16.2 +++ b/indra/llmath/m4math.h	Mon Feb 27 23:59:10 2012 -0800
    16.3 @@ -208,7 +208,8 @@
    16.4  	//
    16.5  
    16.6  	const LLMatrix4& transpose();						// Transpose LLMatrix4
    16.7 -	const LLMatrix4& invert();						// Invert LLMatrix4
    16.8 +	const LLMatrix4& invert();						// Invert LLMatrix4 
    16.9 +	const LLMatrix4& invert_real();					// Invert LLMatrix4 - works for all matrices
   16.10  
   16.11  	// Rotate existing matrix
   16.12  	// These are really, really, inefficient as implemented! - djs
    17.1 --- a/indra/llmath/v4coloru.cpp	Mon Feb 27 23:28:58 2012 -0800
    17.2 +++ b/indra/llmath/v4coloru.cpp	Mon Feb 27 23:59:10 2012 -0800
    17.3 @@ -126,13 +126,11 @@
    17.4  # define LL_X86_64 1
    17.5  #elif LL_GNUC && (defined(__amd64__) || defined(__x86_64__))
    17.6  # define LL_X86_64 1
    17.7 -#else
    17.8 -# define LL_X86_64 0
    17.9  #endif
   17.10  
   17.11  U32 LLColor4U::asRGBA() const
   17.12  {
   17.13 -#if LL_X86_64
   17.14 +#ifdef LL_X86_64
   17.15  	U32 rgba(0);
   17.16  
   17.17  	// Little endian: values are swapped in memory. The original code access
   17.18 @@ -153,7 +151,7 @@
   17.19  
   17.20  void LLColor4U::fromRGBA(U32 rgba)
   17.21  {
   17.22 -#if LL_X86_64
   17.23 +#ifdef LL_X86_64
   17.24  	// Little endian: values are swapped in memory. The original code access
   17.25  	// the array like a U32, so we need to swap here
   17.26  	mV[0] = rgba & 0xFF;
    18.1 --- a/indra/llmessage/lliosocket.cpp	Mon Feb 27 23:28:58 2012 -0800
    18.2 +++ b/indra/llmessage/lliosocket.cpp	Mon Feb 27 23:59:10 2012 -0800
    18.3 @@ -186,7 +186,7 @@
    18.4  LLSocket::ptr_t LLSocket::create(apr_status_t& status, LLSocket::ptr_t& listen_socket)
    18.5  {
    18.6  	LLMemType m1(LLMemType::MTYPE_IO_TCP);
    18.7 -	if (!listen_socket->getSocket())
    18.8 +	if (!listen_socket || !listen_socket->getSocket())
    18.9  	{
   18.10  		status = APR_ENOSOCKET;
   18.11  		return LLSocket::ptr_t();
    19.1 --- a/indra/llrender/llrendertarget.cpp	Mon Feb 27 23:28:58 2012 -0800
    19.2 +++ b/indra/llrender/llrendertarget.cpp	Mon Feb 27 23:59:10 2012 -0800
    19.3 @@ -465,7 +465,8 @@
    19.4  	gGL.flush();
    19.5  	if (!source.mFBO || !mFBO)
    19.6  	{
    19.7 -		llerrs << "Cannot copy framebuffer contents for non FBO render targets." << llendl;
    19.8 +		llwarns << "Cannot copy framebuffer contents for non FBO render targets." << llendl;
    19.9 +		return;
   19.10  	}
   19.11  
   19.12  	if (mSampleBuffer)
    20.1 --- a/indra/llrender/llvertexbuffer.cpp	Mon Feb 27 23:28:58 2012 -0800
    20.2 +++ b/indra/llrender/llvertexbuffer.cpp	Mon Feb 27 23:59:10 2012 -0800
    20.3 @@ -937,8 +937,8 @@
    20.4  			//check the availability of memory
    20.5  			U32 avail_phy_mem, avail_vir_mem;
    20.6  			LLMemoryInfo::getAvailableMemoryKB(avail_phy_mem, avail_vir_mem);
    20.7 -			llinfos << "Available physical mwmory(KB): " << avail_phy_mem << llendl; 
    20.8 -			llinfos << "Available virtual memory(KB): " << avail_vir_mem << llendl;
    20.9 +			llinfos << "Available physical memory: " << avail_phy_mem << "KB" << llendl; 
   20.10 +			llinfos << "Available virtual memory: " << avail_vir_mem << "KB" << llendl;
   20.11  
   20.12  			if (!sDisableVBOMapping)
   20.13  			{
    21.1 --- a/indra/llwindow/llwindow.cpp	Mon Feb 27 23:28:58 2012 -0800
    21.2 +++ b/indra/llwindow/llwindow.cpp	Mon Feb 27 23:59:10 2012 -0800
    21.3 @@ -268,6 +268,7 @@
    21.4  	  mSupportedResolutions(NULL),
    21.5  	  mNumSupportedResolutions(0),
    21.6  	  mCurrentCursor(UI_CURSOR_ARROW),
    21.7 +	  mNextCursor(UI_CURSOR_ARROW),
    21.8  	  mCursorHidden(FALSE),
    21.9  	  mBusyCount(0),
   21.10  	  mIsMouseClipping(FALSE),
    22.1 --- a/indra/llwindow/llwindow.h	Mon Feb 27 23:28:58 2012 -0800
    22.2 +++ b/indra/llwindow/llwindow.h	Mon Feb 27 23:59:10 2012 -0800
    22.3 @@ -139,8 +139,9 @@
    22.4  	virtual S32 getBusyCount() const { return mBusyCount; }
    22.5  
    22.6  	// Sets cursor, may set to arrow+hourglass
    22.7 -	virtual void setCursor(ECursorType cursor) = 0;
    22.8 -	virtual ECursorType getCursor() const { return mCurrentCursor; }
    22.9 +	virtual void setCursor(ECursorType cursor)	{ mNextCursor = cursor; }
   22.10 +	virtual ECursorType getCursor() const		{ return mCurrentCursor; }
   22.11 +	virtual void updateCursor() = 0;
   22.12  
   22.13  	virtual void captureMouse() = 0;
   22.14  	virtual void releaseMouse() = 0;
   22.15 @@ -227,6 +228,7 @@
   22.16  	LLWindowResolution* mSupportedResolutions;
   22.17  	S32			mNumSupportedResolutions;
   22.18  	ECursorType	mCurrentCursor;
   22.19 +	ECursorType	mNextCursor;
   22.20  	BOOL		mCursorHidden;
   22.21  	S32			mBusyCount;	// how deep is the "cursor busy" stack?
   22.22  	BOOL		mIsMouseClipping;  // Is this window currently clipping the mouse
    23.1 --- a/indra/llwindow/llwindowheadless.h	Mon Feb 27 23:28:58 2012 -0800
    23.2 +++ b/indra/llwindow/llwindowheadless.h	Mon Feb 27 23:59:10 2012 -0800
    23.3 @@ -60,7 +60,7 @@
    23.4  	/*virtual*/ void showCursorFromMouseMove() {};
    23.5  	/*virtual*/ void hideCursorUntilMouseMove() {};
    23.6  	/*virtual*/ BOOL isCursorHidden() {return FALSE;};
    23.7 -	/*virtual*/ void setCursor(ECursorType cursor) {};
    23.8 +	/*virtual*/ void updateCursor() {};
    23.9  	//virtual ECursorType getCursor() { return mCurrentCursor; };
   23.10  	/*virtual*/ void captureMouse() {};
   23.11  	/*virtual*/ void releaseMouse() {};
    24.1 --- a/indra/llwindow/llwindowmacosx.cpp	Mon Feb 27 23:28:58 2012 -0800
    24.2 +++ b/indra/llwindow/llwindowmacosx.cpp	Mon Feb 27 23:59:10 2012 -0800
    24.3 @@ -1165,6 +1165,8 @@
    24.4  
    24.5  		}
    24.6  	}
    24.7 +
    24.8 +	updateCursor();
    24.9  }
   24.10  
   24.11  BOOL LLWindowMacOSX::getPosition(LLCoordScreen *position)
   24.12 @@ -2776,30 +2778,30 @@
   24.13  	gCursors[cursorid] = createImageCursor(fullpath.c_str(), hotspotX, hotspotY);
   24.14  }
   24.15  
   24.16 -void LLWindowMacOSX::setCursor(ECursorType cursor)
   24.17 +void LLWindowMacOSX::updateCursor()
   24.18  {
   24.19  	OSStatus result = noErr;
   24.20  
   24.21 -	if (cursor == UI_CURSOR_ARROW
   24.22 +	if (mNextCursor == UI_CURSOR_ARROW
   24.23  		&& mBusyCount > 0)
   24.24  	{
   24.25 -		cursor = UI_CURSOR_WORKING;
   24.26 +		mNextCursor = UI_CURSOR_WORKING;
   24.27  	}
   24.28  	
   24.29 -	if(mCurrentCursor == cursor)
   24.30 +	if(mCurrentCursor == mNextCursor)
   24.31  		return;
   24.32  
   24.33  	// RN: replace multi-drag cursors with single versions
   24.34 -	if (cursor == UI_CURSOR_ARROWDRAGMULTI)
   24.35 +	if (mNextCursor == UI_CURSOR_ARROWDRAGMULTI)
   24.36  	{
   24.37 -		cursor = UI_CURSOR_ARROWDRAG;
   24.38 +		mNextCursor = UI_CURSOR_ARROWDRAG;
   24.39  	}
   24.40 -	else if (cursor == UI_CURSOR_ARROWCOPYMULTI)
   24.41 +	else if (mNextCursor == UI_CURSOR_ARROWCOPYMULTI)
   24.42  	{
   24.43 -		cursor = UI_CURSOR_ARROWCOPY;
   24.44 +		mNextCursor = UI_CURSOR_ARROWCOPY;
   24.45  	}
   24.46  
   24.47 -	switch(cursor)
   24.48 +	switch(mNextCursor)
   24.49  	{
   24.50  	default:
   24.51  	case UI_CURSOR_ARROW:
   24.52 @@ -2851,7 +2853,7 @@
   24.53  	case UI_CURSOR_TOOLPLAY:
   24.54  	case UI_CURSOR_TOOLPAUSE:
   24.55  	case UI_CURSOR_TOOLMEDIAOPEN:
   24.56 -		result = setImageCursor(gCursors[cursor]);
   24.57 +		result = setImageCursor(gCursors[mNextCursor]);
   24.58  		break;
   24.59  
   24.60  	}
   24.61 @@ -2861,7 +2863,7 @@
   24.62  		InitCursor();
   24.63  	}
   24.64  
   24.65 -	mCurrentCursor = cursor;
   24.66 +	mCurrentCursor = mNextCursor;
   24.67  }
   24.68  
   24.69  ECursorType LLWindowMacOSX::getCursor() const
    25.1 --- a/indra/llwindow/llwindowmacosx.h	Mon Feb 27 23:28:58 2012 -0800
    25.2 +++ b/indra/llwindow/llwindowmacosx.h	Mon Feb 27 23:59:10 2012 -0800
    25.3 @@ -70,7 +70,7 @@
    25.4  	/*virtual*/ void showCursorFromMouseMove();
    25.5  	/*virtual*/ void hideCursorUntilMouseMove();
    25.6  	/*virtual*/ BOOL isCursorHidden();
    25.7 -	/*virtual*/ void setCursor(ECursorType cursor);
    25.8 +	/*virtual*/ void updateCursor();
    25.9  	/*virtual*/ ECursorType getCursor() const;
   25.10  	/*virtual*/ void captureMouse();
   25.11  	/*virtual*/ void releaseMouse();
    26.1 --- a/indra/llwindow/llwindowmesaheadless.h	Mon Feb 27 23:28:58 2012 -0800
    26.2 +++ b/indra/llwindow/llwindowmesaheadless.h	Mon Feb 27 23:59:10 2012 -0800
    26.3 @@ -64,7 +64,7 @@
    26.4  	/*virtual*/ void showCursorFromMouseMove() {};
    26.5  	/*virtual*/ void hideCursorUntilMouseMove() {};
    26.6  	/*virtual*/ BOOL isCursorHidden() {return FALSE;};
    26.7 -	/*virtual*/ void setCursor(ECursorType cursor) {};
    26.8 +	/*virtual*/ void updateCursor();
    26.9  	//virtual ECursorType getCursor() { return mCurrentCursor; };
   26.10  	/*virtual*/ void captureMouse() {};
   26.11  	/*virtual*/ void releaseMouse() {};
    27.1 --- a/indra/llwindow/llwindowsdl.cpp	Mon Feb 27 23:28:58 2012 -0800
    27.2 +++ b/indra/llwindow/llwindowsdl.cpp	Mon Feb 27 23:59:10 2012 -0800
    27.3 @@ -1783,6 +1783,8 @@
    27.4          }
    27.5      }
    27.6  
    27.7 +	updateCursor();
    27.8 +
    27.9  #if LL_X11
   27.10      // This is a good time to stop flashing the icon if our mFlashTimer has
   27.11      // expired.
   27.12 @@ -1868,7 +1870,7 @@
   27.13  	return sdlcursor;
   27.14  }
   27.15  
   27.16 -void LLWindowSDL::setCursor(ECursorType cursor)
   27.17 +void LLWindowSDL::updateCursor()
   27.18  {
   27.19  	if (ATIbug) {
   27.20  		// cursor-updating is very flaky when this bug is
   27.21 @@ -1876,11 +1878,11 @@
   27.22  		return;
   27.23  	}
   27.24  
   27.25 -	if (mCurrentCursor != cursor)
   27.26 +	if (mCurrentCursor != mNextCursor)
   27.27  	{
   27.28 -		if (cursor < UI_CURSOR_COUNT)
   27.29 +		if (mNextCursor < UI_CURSOR_COUNT)
   27.30  		{
   27.31 -			SDL_Cursor *sdlcursor = mSDLCursors[cursor];
   27.32 +			SDL_Cursor *sdlcursor = mSDLCursors[mNextCursor];
   27.33  			// Try to default to the arrow for any cursors that
   27.34  			// did not load correctly.
   27.35  			if (!sdlcursor && mSDLCursors[UI_CURSOR_ARROW])
   27.36 @@ -1888,9 +1890,9 @@
   27.37  			if (sdlcursor)
   27.38  				SDL_SetCursor(sdlcursor);
   27.39  		} else {
   27.40 -			llwarns << "Tried to set invalid cursor number " << cursor << llendl;
   27.41 +			llwarns << "Tried to set invalid cursor number " << mNextCursor << llendl;
   27.42  		}
   27.43 -		mCurrentCursor = cursor;
   27.44 +		mCurrentCursor = mNextCursor;
   27.45  	}
   27.46  }
   27.47  
    28.1 --- a/indra/llwindow/llwindowsdl.h	Mon Feb 27 23:28:58 2012 -0800
    28.2 +++ b/indra/llwindow/llwindowsdl.h	Mon Feb 27 23:59:10 2012 -0800
    28.3 @@ -78,7 +78,7 @@
    28.4  	/*virtual*/ void showCursorFromMouseMove();
    28.5  	/*virtual*/ void hideCursorUntilMouseMove();
    28.6  	/*virtual*/ BOOL isCursorHidden();
    28.7 -	/*virtual*/ void setCursor(ECursorType cursor);
    28.8 +	/*virtual*/ void updateCursor();
    28.9  	/*virtual*/ void captureMouse();
   28.10  	/*virtual*/ void releaseMouse();
   28.11  	/*virtual*/ void setMouseClipping( BOOL b );
    29.1 --- a/indra/llwindow/llwindowwin32.cpp	Mon Feb 27 23:28:58 2012 -0800
    29.2 +++ b/indra/llwindow/llwindowwin32.cpp	Mon Feb 27 23:59:10 2012 -0800
    29.3 @@ -1578,18 +1578,18 @@
    29.4  
    29.5  
    29.6  
    29.7 -void LLWindowWin32::setCursor(ECursorType cursor)
    29.8 +void LLWindowWin32::updateCursor()
    29.9  {
   29.10 -	if (cursor == UI_CURSOR_ARROW
   29.11 +	if (mNextCursor == UI_CURSOR_ARROW
   29.12  		&& mBusyCount > 0)
   29.13  	{
   29.14 -		cursor = UI_CURSOR_WORKING;
   29.15 +		mNextCursor = UI_CURSOR_WORKING;
   29.16  	}
   29.17  
   29.18 -	if( mCurrentCursor != cursor )
   29.19 +	if( mCurrentCursor != mNextCursor )
   29.20  	{
   29.21 -		mCurrentCursor = cursor;
   29.22 -		SetCursor( mCursor[cursor] );
   29.23 +		mCurrentCursor = mNextCursor;
   29.24 +		SetCursor( mCursor[mNextCursor] );
   29.25  	}
   29.26  }
   29.27  
   29.28 @@ -1669,6 +1669,8 @@
   29.29  
   29.30  	mInputProcessingPaused = FALSE;
   29.31  
   29.32 +	updateCursor();
   29.33 +
   29.34  	// clear this once we've processed all mouse messages that might have occurred after
   29.35  	// we slammed the mouse position
   29.36  	mMousePositionModified = FALSE;
    30.1 --- a/indra/llwindow/llwindowwin32.h	Mon Feb 27 23:28:58 2012 -0800
    30.2 +++ b/indra/llwindow/llwindowwin32.h	Mon Feb 27 23:59:10 2012 -0800
    30.3 @@ -69,7 +69,7 @@
    30.4  	/*virtual*/ void showCursorFromMouseMove();
    30.5  	/*virtual*/ void hideCursorUntilMouseMove();
    30.6  	/*virtual*/ BOOL isCursorHidden();
    30.7 -	/*virtual*/ void setCursor(ECursorType cursor);
    30.8 +	/*virtual*/ void updateCursor();
    30.9  	/*virtual*/ ECursorType getCursor() const;
   30.10  	/*virtual*/ void captureMouse();
   30.11  	/*virtual*/ void releaseMouse();
    31.1 --- a/indra/newview/CMakeLists.txt	Mon Feb 27 23:28:58 2012 -0800
    31.2 +++ b/indra/newview/CMakeLists.txt	Mon Feb 27 23:59:10 2012 -0800
    31.3 @@ -306,6 +306,7 @@
    31.4      llinventoryclipboard.cpp
    31.5      llinventoryicon.cpp
    31.6      llinventorymodel.cpp
    31.7 +    llinventorymodelbackgroundfetch.cpp
    31.8      llinventoryview.cpp
    31.9      lljoystickbutton.cpp
   31.10      lllandmarklist.cpp
   31.11 @@ -330,7 +331,6 @@
   31.12      llnetmap.cpp
   31.13      llnotify.cpp
   31.14      lloverlaybar.cpp
   31.15 -    llpanelaudioprefs.cpp
   31.16      llpanelaudiovolume.cpp
   31.17      llpanelavatar.cpp
   31.18      llpanelclassified.cpp
   31.19 @@ -364,7 +364,6 @@
   31.20      llpanellandobjects.cpp
   31.21      llpanellandoptions.cpp
   31.22      llpanellogin.cpp
   31.23 -    llpanelmorph.cpp
   31.24      llpanelmediahud.cpp
   31.25      llpanelmsgs.cpp
   31.26      llpanelnetwork.cpp
   31.27 @@ -384,6 +383,7 @@
   31.28      llpolymorph.cpp
   31.29      llprefschat.cpp
   31.30      llprefsim.cpp
   31.31 +    llprefsmedia.cpp
   31.32      llprefsvoice.cpp
   31.33      llpreviewanim.cpp
   31.34      llpreview.cpp
   31.35 @@ -521,6 +521,7 @@
   31.36      llwaterparamset.cpp
   31.37      llwearable.cpp
   31.38      llwearablelist.cpp
   31.39 +    llwearabletype.cpp
   31.40      llweb.cpp
   31.41      llmediactrl.cpp
   31.42      llwind.cpp
   31.43 @@ -784,6 +785,7 @@
   31.44      llinventoryclipboard.h
   31.45      llinventoryicon.h
   31.46      llinventorymodel.h
   31.47 +    llinventorymodelbackgroundfetch.h
   31.48      llinventoryview.h
   31.49      lljoystickbutton.h
   31.50      lllandmarklist.h
   31.51 @@ -809,7 +811,6 @@
   31.52      llnetmap.h
   31.53      llnotify.h
   31.54      lloverlaybar.h
   31.55 -    llpanelaudioprefs.h
   31.56      llpanelaudiovolume.h
   31.57      llpanelavatar.h
   31.58      llpanelclassified.h
   31.59 @@ -844,7 +845,6 @@
   31.60      llpanellandoptions.h
   31.61      llpanelLCD.h
   31.62      llpanellogin.h
   31.63 -    llpanelmorph.h
   31.64      llpanelmediahud.h
   31.65      llpanelmsgs.h
   31.66      llpanelnetwork.h
   31.67 @@ -864,6 +864,7 @@
   31.68      llpolymorph.h
   31.69      llprefschat.h
   31.70      llprefsim.h
   31.71 +    llprefsmedia.h
   31.72      llprefsvoice.h
   31.73      llpreview.h
   31.74      llpreviewanim.h
   31.75 @@ -1007,6 +1008,7 @@
   31.76      llwaterparamset.h
   31.77      llwearable.h
   31.78      llwearablelist.h
   31.79 +    llwearabletype.h
   31.80      llweb.h
   31.81      llmediactrl.h
   31.82      llwind.h
    32.1 --- a/indra/newview/app_settings/settings.xml	Mon Feb 27 23:28:58 2012 -0800
    32.2 +++ b/indra/newview/app_settings/settings.xml	Mon Feb 27 23:59:10 2012 -0800
    32.3 @@ -6364,6 +6364,17 @@
    32.4  			<key>Value</key>
    32.5  			<integer>16</integer>
    32.6  		</map>
    32.7 +		<key>MeshEnableDeformer</key>
    32.8 +		<map>
    32.9 +			<key>Comment</key>
   32.10 +			<string>Enable mesh deformer (tailoring): this is alpha code</string>
   32.11 +			<key>Persist</key>
   32.12 +			<integer>1</integer>
   32.13 +			<key>Type</key>
   32.14 +			<string>Boolean</string>
   32.15 +			<key>Value</key>
   32.16 +			<real>0</real>
   32.17 +		</map>
   32.18  		<key>MeshImportUseSLM</key>
   32.19  		<map>
   32.20  			<key>Comment</key>
   32.21 @@ -16330,6 +16341,17 @@
   32.22  			<key>Value</key>
   32.23  			<integer>0</integer>
   32.24  		</map>
   32.25 +		<key>UseHTTPInventory</key>
   32.26 +		<map>
   32.27 +			<key>Comment</key>
   32.28 +			<string>Allow use of http inventory transfers instead of UDP</string>
   32.29 +			<key>Persist</key>
   32.30 +			<integer>1</integer>
   32.31 +			<key>Type</key>
   32.32 +			<string>Boolean</string>
   32.33 +			<key>Value</key>
   32.34 +			<integer>1</integer>
   32.35 +		</map>
   32.36  		<key>UseInventoryLinks</key>
   32.37  		<map>
   32.38  			<key>Comment</key>
    33.1 --- a/indra/newview/chatbar_as_cmdline.cpp	Mon Feb 27 23:28:58 2012 -0800
    33.2 +++ b/indra/newview/chatbar_as_cmdline.cpp	Mon Feb 27 23:59:10 2012 -0800
    33.3 @@ -447,7 +447,7 @@
    33.4  	LLViewerInventoryCategory::cat_array_t cats;
    33.5  	LLViewerInventoryItem::item_array_t items;
    33.6  	//ObjectContentNameMatches objectnamematches(ifolder);
    33.7 -	gInventory.collectDescendents(gAgent.getInventoryRootID(),cats,items,FALSE);//,objectnamematches);
    33.8 +	gInventory.collectDescendents(gInventory.getRootFolderID(),cats,items,FALSE);//,objectnamematches);
    33.9  }
   33.10  
   33.11  /*static BOOL *sPhoenixCmdLine;
    34.1 --- a/indra/newview/cofmgr.cpp	Mon Feb 27 23:28:58 2012 -0800
    34.2 +++ b/indra/newview/cofmgr.cpp	Mon Feb 27 23:59:10 2012 -0800
    34.3 @@ -79,9 +79,9 @@
    34.4  		}
    34.5  
    34.6  		// Add all currently worn wearables
    34.7 -		for (S32 idxType = 0; idxType < WT_COUNT; idxType++)
    34.8 +		for (S32 idxType = 0; idxType < LLWearableType::WT_COUNT; idxType++)
    34.9  		{
   34.10 -			const LLUUID& idItem = gAgent.getWearableItem((EWearableType)idxType);
   34.11 +			const LLUUID& idItem = gAgent.getWearableItem((LLWearableType::EType)idxType);
   34.12  			if (idItem.isNull())
   34.13  				continue;
   34.14  			idItems.push_back(idItem);
   34.15 @@ -218,7 +218,7 @@
   34.16  
   34.17  		LLCOFFetcher* pFetcher = new LLCOFFetcher();
   34.18  		pFetcher->fetchDescendents(fetchFolders);
   34.19 -		if (pFetcher->isEverythingComplete())
   34.20 +		if (pFetcher->isFinished())
   34.21  			pFetcher->done();
   34.22  		else
   34.23  			gInventory.addObserver(pFetcher);
   34.24 @@ -456,9 +456,9 @@
   34.25  
   34.26  	// Grab the item UUIDs of all currently worn wearables
   34.27  	uuid_vec_t newItems;
   34.28 -	for (S32 idxType = 0; idxType < WT_COUNT; idxType++)
   34.29 +	for (S32 idxType = 0; idxType < LLWearableType::WT_COUNT; idxType++)
   34.30  	{
   34.31 -		const LLUUID& idItem = gAgent.getWearableItem((EWearableType)idxType);
   34.32 +		const LLUUID& idItem = gAgent.getWearableItem((LLWearableType::EType)idxType);
   34.33  		if (idItem.isNull())
   34.34  			continue;
   34.35  		newItems.push_back(idItem);
    35.1 --- a/indra/newview/floaterao.cpp	Mon Feb 27 23:28:58 2012 -0800
    35.2 +++ b/indra/newview/floaterao.cpp	Mon Feb 27 23:59:10 2012 -0800
    35.3 @@ -14,6 +14,7 @@
    35.4  #include "llvoavatar.h"
    35.5  #include "llanimationstates.h"
    35.6  #include "lluictrlfactory.h"
    35.7 +#include "llinventorymodelbackgroundfetch.h"
    35.8  #include "llinventoryview.h"
    35.9  #include "llstartup.h"
   35.10  #include "llpreviewnotecard.h"
   35.11 @@ -586,7 +587,7 @@
   35.12  					{
   35.13  						fullfetch = TRUE;
   35.14  						//no choice, can't move the AO till we find it, should only have to happen once
   35.15 -						gInventory.startBackgroundFetch();
   35.16 +						LLInventoryModelBackgroundFetch::instance().start();
   35.17  						return FALSE;
   35.18  					}
   35.19  				}
    36.1 --- a/indra/newview/importtracker.cpp	Mon Feb 27 23:28:58 2012 -0800
    36.2 +++ b/indra/newview/importtracker.cpp	Mon Feb 27 23:59:10 2012 -0800
    36.3 @@ -320,7 +320,7 @@
    36.4  	U32 localid;
    36.5  	LLAssetType::EType type;
    36.6  	LLInventoryType::EType inv_type;
    36.7 -	EWearableType wear_type;
    36.8 +	LLWearableType::EType wear_type;
    36.9  	LLTransactionID tid;
   36.10  	LLUUID assetid;
   36.11  	std::string name;
    37.1 --- a/indra/newview/jc_lslviewerbridge.cpp	Mon Feb 27 23:28:58 2012 -0800
    37.2 +++ b/indra/newview/jc_lslviewerbridge.cpp	Mon Feb 27 23:59:10 2012 -0800
    37.3 @@ -48,6 +48,7 @@
    37.4  #include "llviewerobject.h"
    37.5  #include "llvoavatar.h"
    37.6  #include "llinventorymodel.h"
    37.7 +#include "llinventorymodelbackgroundfetch.h"
    37.8  #include "lltooldraganddrop.h"
    37.9  #include "llmd5.h"
   37.10  #include "llstartup.h"
   37.11 @@ -365,7 +366,7 @@
   37.12  	phoenix_category = gInventory.findCategoryByName(phoenix_category_name);
   37.13  	if(phoenix_category.isNull())
   37.14  	{
   37.15 -		phoenix_category = gInventory.createNewCategory(gAgent.getInventoryRootID(), LLFolderType::FT_NONE, phoenix_category_name);
   37.16 +		phoenix_category = gInventory.createNewCategory(gInventory.getRootFolderID(), LLFolderType::FT_NONE, phoenix_category_name);
   37.17  	}
   37.18  	return phoenix_category;
   37.19  }
   37.20 @@ -382,7 +383,7 @@
   37.21  		category = findCategoryByNameOrCreate(catname);
   37.22  	}else
   37.23  	{
   37.24 -		category = gAgent.getInventoryRootID();
   37.25 +		category = gInventory.getRootFolderID();
   37.26  	}
   37.27  
   37.28  	gInventory.collectDescendentsIf(category,cats,items,FALSE,objectnamematches);
   37.29 @@ -658,7 +659,7 @@
   37.30  		LLViewerInventoryCategory::cat_array_t cats;
   37.31  		LLViewerInventoryItem::item_array_t items;
   37.32  
   37.33 -		gInventory.collectDescendentsIf(gAgent.getInventoryRootID(),cats,items,FALSE,prefixmatcher);
   37.34 +		gInventory.collectDescendentsIf(gInventory.getRootFolderID(),cats,items,FALSE,prefixmatcher);
   37.35  
   37.36  		LLViewerInventoryItem::item_array_t delete_queue;
   37.37  
   37.38 @@ -704,7 +705,7 @@
   37.39  		}
   37.40  		
   37.41  		static BOOL first_full_load = TRUE;
   37.42 -		if (first_full_load && gInventory.isEverythingFetched()) // when the inv is done fetching, check for old bridges
   37.43 +		if (first_full_load && LLInventoryModelBackgroundFetch::instance().isEverythingFetched()) // when the inv is done fetching, check for old bridges
   37.44  		{
   37.45  			//cmdline_printchat("--first full inv load");
   37.46  			first_full_load = FALSE;
    38.1 --- a/indra/newview/jclslpreproc.cpp	Mon Feb 27 23:28:58 2012 -0800
    38.2 +++ b/indra/newview/jclslpreproc.cpp	Mon Feb 27 23:59:10 2012 -0800
    38.3 @@ -77,7 +77,7 @@
    38.4  	LLViewerInventoryCategory::cat_array_t cats;
    38.5  	LLViewerInventoryItem::item_array_t items;
    38.6  	ScriptMatches namematches(name);
    38.7 -	gInventory.collectDescendentsIf(gAgent.getInventoryRootID(),cats,items,FALSE,namematches);
    38.8 +	gInventory.collectDescendentsIf(gInventory.getRootFolderID(),cats,items,FALSE,namematches);
    38.9  
   38.10  	if (items.count())
   38.11  	{
    39.1 --- a/indra/newview/llagent.cpp	Mon Feb 27 23:28:58 2012 -0800
    39.2 +++ b/indra/newview/llagent.cpp	Mon Feb 27 23:59:10 2012 -0800
    39.3 @@ -36,30 +36,37 @@
    39.4  #include "stdenums.h"
    39.5  
    39.6  #include "cofmgr.h"
    39.7 -#include "llagent.h" 
    39.8 +#include "llagent.h"
    39.9 +
   39.10 +#include "imageids.h"
   39.11 +#include "indra_constants.h"
   39.12 +#include "llbutton.h"
   39.13  #include "llcamera.h"
   39.14  #include "llcoordframe.h"
   39.15 -#include "indra_constants.h"
   39.16 -#include "llmath.h"
   39.17  #include "llcriticaldamp.h"
   39.18  #include "llfocusmgr.h"
   39.19  #include "llglheaders.h"
   39.20 +#include "llmath.h"
   39.21 +#include "llmenugl.h"
   39.22 +#include "llmd5.h"
   39.23  #include "llparcel.h"
   39.24  #include "llpermissions.h"
   39.25 +#include "llquantize.h"
   39.26 +#include "llquaternion.h"
   39.27  #include "llregionhandle.h"
   39.28 +#include "llrendersphere.h"
   39.29 +#include "llsdutil.h"
   39.30 +#include "llsmoothstep.h"
   39.31 +#include "llui.h"				// for make_ui_sound
   39.32  #include "m3math.h"
   39.33  #include "m4math.h"
   39.34  #include "message.h"
   39.35 -#include "llquaternion.h"
   39.36 +#include "roles_constants.h"
   39.37  #include "v3math.h"
   39.38  #include "v4math.h"
   39.39 -#include "llsmoothstep.h"
   39.40 -#include "llsdutil.h"
   39.41 -//#include "vmath.h"
   39.42 -
   39.43 -#include "imageids.h"
   39.44 +
   39.45 +#include "llappviewer.h"
   39.46  #include "llbox.h"
   39.47 -#include "llbutton.h"
   39.48  #include "llcallingcard.h"
   39.49  #include "llchatbar.h"
   39.50  #include "llconsole.h"
   39.51 @@ -82,25 +89,22 @@
   39.52  #include "llfloatersnapshot.h"
   39.53  #include "llfloatertools.h"
   39.54  #include "llfloaterworldmap.h"
   39.55 +#include "llfollowcam.h"
   39.56  #include "llgroupmgr.h"
   39.57  #include "llhomelocationresponder.h"
   39.58  #include "llhudeffectlookat.h"
   39.59  #include "llhudmanager.h"
   39.60 +#include "llimview.h"
   39.61  #include "llinventorymodel.h"
   39.62  #include "llinventoryview.h"
   39.63  #include "lljoystickbutton.h"
   39.64 -#include "llmenugl.h"
   39.65  #include "llmorphview.h"
   39.66  #include "llmoveview.h"
   39.67  #include "llnotify.h"
   39.68 -#include "llquantize.h"
   39.69 -#include "llsdutil.h"
   39.70  #include "llselectmgr.h"
   39.71  #include "llsky.h"
   39.72 -#include "llrendersphere.h"
   39.73  #include "llstatusbar.h"
   39.74  #include "llstartup.h"
   39.75 -#include "llimview.h"
   39.76  #include "lltexturestats.h"
   39.77  #include "lltool.h"
   39.78  #include "lltoolcomp.h"
   39.79 @@ -109,10 +113,11 @@
   39.80  #include "lltoolmgr.h"
   39.81  #include "lltoolpie.h"
   39.82  #include "lltoolview.h"
   39.83 -#include "llui.h"			// for make_ui_sound
   39.84  #include "llurldispatcher.h"
   39.85  #include "llviewercamera.h"
   39.86 +#include "llviewercontrol.h"
   39.87  #include "llviewerinventory.h"
   39.88 +#include "llviewerjoystick.h"
   39.89  #include "llviewermediafocus.h"
   39.90  #include "llviewermenu.h"
   39.91  #include "llviewernetwork.h"
   39.92 @@ -131,11 +136,7 @@
   39.93  #include "llworld.h"
   39.94  #include "llworldmap.h"
   39.95  #include "pipeline.h"
   39.96 -#include "roles_constants.h"
   39.97 -#include "llviewercontrol.h"
   39.98 -#include "llappviewer.h"
   39.99 -#include "llviewerjoystick.h"
  39.100 -#include "llfollowcam.h"
  39.101 +
  39.102  #include "llfloaterteleporthistory.h"
  39.103  #include "jc_lslviewerbridge.h"
  39.104  #include "llenvmanager.h"
  39.105 @@ -6201,15 +6202,30 @@
  39.106  		mesgsys->getUUIDFast(_PREHASH_WearableData, _PREHASH_TextureID, texture_id, texture_block);
  39.107  		mesgsys->getU8Fast(_PREHASH_WearableData, _PREHASH_TextureIndex, texture_index, texture_block);
  39.108  
  39.109 -		if (texture_id.notNull() 
  39.110 -			&& (S32)texture_index < BAKED_NUM_INDICES 
  39.111 -			&& gAgent.mActiveCacheQueries[ texture_index ] == query_id)
  39.112 -		{
  39.113 -			//llinfos << "Received cached texture " << (U32)texture_index << ": " << texture_id << llendl;
  39.114 -			avatarp->setCachedBakedTexture(getTextureIndex((EBakedTextureIndex)texture_index), texture_id);
  39.115 -			//avatarp->setTETexture( LLVOAvatar::sBakedTextureIndices[texture_index], texture_id );
  39.116 -			gAgent.mActiveCacheQueries[ texture_index ] = 0;
  39.117 -			num_results++;
  39.118 +		if ((S32)texture_index < TEX_NUM_INDICES)
  39.119 +		{	
  39.120 +			const LLVOAvatarDictionary::TextureEntry *texture_entry = LLVOAvatarDictionary::instance().getTexture((ETextureIndex)texture_index);
  39.121 +			if (texture_entry)
  39.122 +			{
  39.123 +				EBakedTextureIndex baked_index = texture_entry->mBakedTextureIndex;
  39.124 +
  39.125 +				if (gAgent.mActiveCacheQueries[baked_index] == query_id)
  39.126 +				{
  39.127 +					if (texture_id.notNull())
  39.128 +					{
  39.129 +						//llinfos << "Received cached texture " << (U32)texture_index << ": " << texture_id << llendl;
  39.130 +						avatarp->setCachedBakedTexture((ETextureIndex)texture_index, texture_id);
  39.131 +						//avatarp->setTETexture(LLVOAvatar::sBakedTextureIndices[texture_index], texture_id);
  39.132 +						gAgent.mActiveCacheQueries[baked_index] = 0;
  39.133 +						num_results++;
  39.134 +					}
  39.135 +				}
  39.136 +				else
  39.137 +				{
  39.138 +					// no cache of this bake. request upload.
  39.139 +					//avatarp->requestLayerSetUpload(baked_index);
  39.140 +				}
  39.141 +			}
  39.142  		}
  39.143  	}
  39.144  
  39.145 @@ -6852,7 +6868,7 @@
  39.146  {
  39.147  	// First make sure that we have inventory items for each wearable
  39.148  	S32 i;
  39.149 -	for(i=0; i < WT_COUNT; ++i)
  39.150 +	for (i = 0; i < LLWearableType::WT_COUNT; ++i)
  39.151  	{
  39.152  		LLWearable* wearable = mWearableEntry[ i ].mWearable;
  39.153  		if (wearable)
  39.154 @@ -6889,7 +6905,7 @@
  39.155  	gMessageSystem->addUUIDFast(_PREHASH_SessionID, getSessionID());
  39.156  
  39.157  	LL_DEBUGS("Wearables") << "sendAgentWearablesUpdate()" << LL_ENDL;
  39.158 -	for(i=0; i < WT_COUNT; ++i)
  39.159 +	for (i = 0; i < LLWearableType::WT_COUNT; ++i)
  39.160  	{
  39.161  		gMessageSystem->nextBlockFast(_PREHASH_WearableData);
  39.162  
  39.163 @@ -6912,16 +6928,22 @@
  39.164  		}
  39.165  		else
  39.166  		{
  39.167 -			LL_DEBUGS("Wearables") << "Not wearing wearable type " << LLWearable::typeToTypeName((EWearableType)i) << LL_ENDL;
  39.168 +			LL_DEBUGS("Wearables") << "Not wearing wearable type: "
  39.169 +								   << LLWearableType::getTypeName((LLWearableType::EType)i)
  39.170 +								   << LL_ENDL;
  39.171  			gMessageSystem->addUUIDFast(_PREHASH_ItemID, LLUUID::null );
  39.172  		}
  39.173  
  39.174 -		LL_DEBUGS("Wearables") << "       " << LLWearable::typeToTypeLabel((EWearableType)i) << " : " << (wearable ? wearable->getID() : LLUUID::null) << LL_ENDL;
  39.175 +		LL_DEBUGS("Wearables") << "       "
  39.176 +							   << LLWearableType::getTypeLabel((LLWearableType::EType)i)
  39.177 +							   << " : "
  39.178 +							   << (wearable ? wearable->getID() : LLUUID::null)
  39.179 +							   << LL_ENDL;
  39.180  	}
  39.181  	gAgent.sendReliableMessage();
  39.182  }
  39.183  
  39.184 -void LLAgent::saveWearable( EWearableType type, BOOL send_update )
  39.185 +void LLAgent::saveWearable(LLWearableType::EType type, BOOL send_update)
  39.186  {
  39.187  	LLWearable* old_wearable = mWearableEntry[(S32)type].mWearable;
  39.188  	if( old_wearable && (old_wearable->isDirty() || old_wearable->isOldVersion()) )
  39.189 @@ -6977,7 +6999,7 @@
  39.190  }
  39.191  
  39.192  void LLAgent::saveWearableAs(
  39.193 -	EWearableType type,
  39.194 +	LLWearableType::EType type,
  39.195  	const std::string& new_name,
  39.196  	BOOL save_in_lost_and_found)
  39.197  {
  39.198 @@ -7070,7 +7092,7 @@
  39.199  */
  39.200  }
  39.201  
  39.202 -void LLAgent::revertWearable( EWearableType type )
  39.203 +void LLAgent::revertWearable(LLWearableType::EType type)
  39.204  {
  39.205  	LLWearable* wearable = mWearableEntry[(S32)type].mWearable;
  39.206  	if( wearable )
  39.207 @@ -7082,9 +7104,9 @@
  39.208  
  39.209  void LLAgent::revertAllWearables()
  39.210  {
  39.211 -	for( S32 i=0; i < WT_COUNT; i++ )
  39.212 -	{
  39.213 -		revertWearable( (EWearableType)i );
  39.214 +	for (S32 i = 0; i < LLWearableType::WT_COUNT; i++)
  39.215 +	{
  39.216 +		revertWearable((LLWearableType::EType)i);
  39.217  	}
  39.218  }
  39.219  
  39.220 @@ -7095,9 +7117,9 @@
  39.221  	//	return;
  39.222  	//}
  39.223  
  39.224 -	for( S32 i=0; i < WT_COUNT; i++ )
  39.225 -	{
  39.226 -		saveWearable( (EWearableType)i, FALSE );
  39.227 +	for (S32 i = 0; i < LLWearableType::WT_COUNT; i++)
  39.228 +	{
  39.229 +		saveWearable((LLWearableType::EType)i, FALSE);
  39.230  	}
  39.231  	sendAgentWearablesUpdate();
  39.232  }
  39.233 @@ -7105,7 +7127,7 @@
  39.234  // Called when the user changes the name of a wearable inventory item that is currenlty being worn.
  39.235  void LLAgent::setWearableName( const LLUUID& item_id, const std::string& new_name )
  39.236  {
  39.237 -	for( S32 i=0; i < WT_COUNT; i++ )
  39.238 +	for (S32 i = 0; i < LLWearableType::WT_COUNT; i++)
  39.239  	{
  39.240  		if( mWearableEntry[i].mItemID == item_id )
  39.241  		{
  39.242 @@ -7130,7 +7152,7 @@
  39.243  }
  39.244  
  39.245  
  39.246 -BOOL LLAgent::isWearableModifiable(EWearableType type)
  39.247 +BOOL LLAgent::isWearableModifiable(LLWearableType::EType type)
  39.248  {
  39.249  	LLUUID item_id = getWearableItem(type);
  39.250  	if(!item_id.isNull())
  39.251 @@ -7145,7 +7167,7 @@
  39.252  	return FALSE;
  39.253  }
  39.254  
  39.255 -BOOL LLAgent::isWearableCopyable(EWearableType type)
  39.256 +BOOL LLAgent::isWearableCopyable(LLWearableType::EType type)
  39.257  {
  39.258  	LLUUID item_id = getWearableItem(type);
  39.259  	if(!item_id.isNull())
  39.260 @@ -7160,7 +7182,7 @@
  39.261  	return FALSE;
  39.262  }
  39.263  
  39.264 -U32 LLAgent::getWearablePermMask(EWearableType type)
  39.265 +U32 LLAgent::getWearablePermMask(LLWearableType::EType type)
  39.266  {
  39.267  	LLUUID item_id = getWearableItem(type);
  39.268  	if(!item_id.isNull())
  39.269 @@ -7174,7 +7196,7 @@
  39.270  	return PERM_NONE;
  39.271  }
  39.272  
  39.273 -LLInventoryItem* LLAgent::getWearableInventoryItem(EWearableType type)
  39.274 +LLInventoryItem* LLAgent::getWearableInventoryItem(LLWearableType::EType type)
  39.275  {
  39.276  	LLUUID item_id = getWearableItem(type);
  39.277  	LLInventoryItem* item = NULL;
  39.278 @@ -7187,7 +7209,7 @@
  39.279  
  39.280  LLWearable* LLAgent::getWearableFromWearableItem( const LLUUID& item_id )
  39.281  {
  39.282 -	for( S32 i=0; i < WT_COUNT; i++ )
  39.283 +	for (S32 i = 0; i < LLWearableType::WT_COUNT; i++)
  39.284  	{
  39.285  		if( mWearableEntry[i].mItemID == item_id )
  39.286  		{
  39.287 @@ -7211,7 +7233,7 @@
  39.288  // static
  39.289  BOOL LLAgent::selfHasWearable( void* userdata )
  39.290  {
  39.291 -	EWearableType type = (EWearableType)(intptr_t)userdata;
  39.292 +	LLWearableType::EType type = (LLWearableType::EType)(intptr_t)userdata;
  39.293  	return gAgent.getWearable( type ) != NULL;
  39.294  }
  39.295  
  39.296 @@ -7257,19 +7279,19 @@
  39.297  		//	 gAgent.setGenderChosen(TRUE);
  39.298  		//}
  39.299  
  39.300 -		//lldebugs << "processAgentInitialWearablesUpdate()" << llendl;
  39.301 +		//LL_DEBUGS("Wearables") << "processAgentInitialWearablesUpdate()" << LL_ENDL;
  39.302  		// Add wearables
  39.303 -		LLUUID asset_id_array[ WT_COUNT ];
  39.304 +		LLUUID asset_id_array[LLWearableType::WT_COUNT];
  39.305  		S32 i;
  39.306  		for( i=0; i < num_wearables; i++ )
  39.307  		{
  39.308  			U8 type_u8 = 0;
  39.309  			gMessageSystem->getU8Fast(_PREHASH_WearableData, _PREHASH_WearableType, type_u8, i );
  39.310 -			if( type_u8 >= WT_COUNT )
  39.311 +			if (type_u8 >= LLWearableType::WT_COUNT)
  39.312  			{
  39.313  				continue;
  39.314  			}
  39.315 -			EWearableType type = (EWearableType) type_u8;
  39.316 +			LLWearableType::EType type = (LLWearableType::EType) type_u8;
  39.317  
  39.318  			LLUUID item_id;
  39.319  			gMessageSystem->getUUIDFast(_PREHASH_WearableData, _PREHASH_ItemID, item_id, i );
  39.320 @@ -7282,7 +7304,7 @@
  39.321  			}
  39.322  			else
  39.323  			{
  39.324 -				LLAssetType::EType asset_type = LLWearable::typeToAssetType( type );
  39.325 +				LLAssetType::EType asset_type = LLWearableType::getAssetType(type);
  39.326  				if( asset_type == LLAssetType::AT_NONE )
  39.327  				{
  39.328  					continue;
  39.329 @@ -7292,13 +7314,16 @@
  39.330  				asset_id_array[type] = asset_id;
  39.331  			}
  39.332  
  39.333 -			LL_DEBUGS("Wearables") << "       " << LLWearable::typeToTypeLabel(type) << " " << asset_id << " item id " << gAgent.mWearableEntry[type].mItemID.asString() << LL_ENDL;
  39.334 +			LL_DEBUGS("Wearables") << "       " << LLWearableType::getTypeLabel(type)
  39.335 + 								   << " " << asset_id << " item id "
  39.336 + 								   << gAgent.mWearableEntry[type].mItemID.asString()
  39.337 + 								   << LL_ENDL;
  39.338  		}
  39.339  
  39.340  		LLCOFMgr::instance().fetchCOF();
  39.341  
  39.342  		// now that we have the asset ids...request the wearable assets
  39.343 -		for( i = 0; i < WT_COUNT; i++ )
  39.344 +		for (i = 0; i < LLWearableType::WT_COUNT; i++)
  39.345  		{
  39.346  			LL_DEBUGS("Wearables") << "      fetching " << asset_id_array[i] << LL_ENDL;
  39.347  			if( !gAgent.mWearableEntry[i].mItemID.isNull() )
  39.348 @@ -7306,7 +7331,7 @@
  39.349  				gWearableList.getAsset( 
  39.350  					asset_id_array[i],
  39.351  					LLStringUtil::null,
  39.352 -					LLWearable::typeToAssetType( (EWearableType) i ), 
  39.353 +					LLWearableType::getAssetType((LLWearableType::EType)i),
  39.354  					LLAgent::onInitialWearableAssetArrived, (void*)(intptr_t)i );
  39.355  			}
  39.356  		}
  39.357 @@ -7320,7 +7345,7 @@
  39.358  // static
  39.359  void LLAgent::onInitialWearableAssetArrived( LLWearable* wearable, void* userdata )
  39.360  {
  39.361 -	EWearableType type = (EWearableType)(intptr_t)userdata;
  39.362 +	LLWearableType::EType type = (LLWearableType::EType)(intptr_t)userdata;
  39.363  
  39.364  	LLVOAvatar* avatar = gAgent.getAvatarObject();
  39.365  	if( !avatar )
  39.366 @@ -7353,7 +7378,7 @@
  39.367  	if( !gAgent.mWearablesLoaded )
  39.368  	{
  39.369  		gAgent.mWearablesLoaded = TRUE;
  39.370 -		for( S32 i = 0; i < WT_COUNT; i++ )
  39.371 +		for (S32 i = 0; i < LLWearableType::WT_COUNT; i++)
  39.372  		{
  39.373  			if( !gAgent.mWearableEntry[i].mItemID.isNull() && !gAgent.mWearableEntry[i].mWearable )
  39.374  			{
  39.375 @@ -7380,11 +7405,13 @@
  39.376  // Normally, all wearables referred to "AgentWearablesUpdate" will correspond to actual assets in the
  39.377  // database.  If for some reason, we can't load one of those assets, we can try to reconstruct it so that
  39.378  // the user isn't left without a shape, for example.  (We can do that only after the inventory has loaded.)
  39.379 -void LLAgent::recoverMissingWearable( EWearableType type )
  39.380 +void LLAgent::recoverMissingWearable(LLWearableType::EType type)
  39.381  {
  39.382  	// Try to recover by replacing missing wearable with a new one.
  39.383  	LLNotifications::instance().add("ReplacedMissingWearable");
  39.384 -	lldebugs << "Wearable " << LLWearable::typeToTypeLabel( type ) << " could not be downloaded.  Replaced inventory item with default wearable." << llendl;
  39.385 +	LL_DEBUGS("Wearables") << "Wearable " << LLWearableType::getTypeLabel(type)
  39.386 +						   << " could not be downloaded. Replaced inventory item with default wearable."
  39.387 +						   << LL_ENDL;
  39.388  	LLWearable* new_wearable = gWearableList.createNewWearable(type);
  39.389  
  39.390  	S32 type_s32 = (S32) type;
  39.391 @@ -7409,7 +7436,7 @@
  39.392  {
  39.393  	// Have all the wearables that the avatar was wearing at log-in arrived or been fabricated?
  39.394  	mWearablesLoaded = TRUE;
  39.395 -	for( S32 i = 0; i < WT_COUNT; i++ )
  39.396 +	for (S32 i = 0; i < LLWearableType::WT_COUNT; i++)
  39.397  	{
  39.398  		if( !mWearableEntry[i].mItemID.isNull() && !mWearableEntry[i].mWearable )
  39.399  		{
  39.400 @@ -7443,7 +7470,7 @@
  39.401  	if(female) mAvatarObject->setSex(SEX_FEMALE);
  39.402  	else mAvatarObject->setSex(SEX_MALE);
  39.403  
  39.404 -	BOOL create[WT_COUNT] = 
  39.405 +	BOOL create[LLWearableType::WT_COUNT] = 
  39.406  	{
  39.407  		TRUE,  //WT_SHAPE
  39.408  		TRUE,  //WT_SKIN
  39.409 @@ -7463,7 +7490,7 @@
  39.410  		FALSE   //WT_PHYSICS
  39.411  	};
  39.412  
  39.413 -	for( S32 i=0; i < WT_COUNT; i++ )
  39.414 +	for (S32 i = 0; i < LLWearableType::WT_COUNT; i++)
  39.415  	{
  39.416  		bool once = false;
  39.417  		LLPointer<LLRefCount> donecb = NULL;
  39.418 @@ -7475,7 +7502,7 @@
  39.419  				donecb = new createStandardWearablesAllDoneCallback;
  39.420  			}
  39.421  			llassert( mWearableEntry[i].mWearable == NULL );
  39.422 -			LLWearable* wearable = gWearableList.createNewWearable((EWearableType)i);
  39.423 +			LLWearable* wearable = gWearableList.createNewWearable((LLWearableType::EType)i);
  39.424  			mWearableEntry[i].mWearable = wearable;
  39.425  			// no need to update here...
  39.426  			LLPointer<LLInventoryCallback> cb =
  39.427 @@ -7575,7 +7602,7 @@
  39.428  						LLStringUtil::truncate(new_name, DB_INV_ITEM_NAME_STR_LEN);
  39.429  					}
  39.430  
  39.431 -					if (fUseLinks || isWearableCopyable((EWearableType)index))
  39.432 +					if (fUseLinks || isWearableCopyable((LLWearableType::EType)index))
  39.433  					{
  39.434  						LLWearable* new_wearable = gWearableList.createCopy(old_wearable);
  39.435  						if (rename_clothing)
  39.436 @@ -7598,7 +7625,7 @@
  39.437  								index,
  39.438  								new_wearable,
  39.439  								todo);
  39.440 -						if (isWearableCopyable((EWearableType)index))
  39.441 +						if (isWearableCopyable((LLWearableType::EType)index))
  39.442  						{
  39.443  							copy_inventory_item(
  39.444  								gAgent.getID(),
  39.445 @@ -7745,6 +7772,61 @@
  39.446  		cb);
  39.447  }
  39.448  
  39.449 +// *TODO: move to llagentwearables.cpp once ported
  39.450 +LLUUID LLAgent::computeBakedTextureHash(LLVOAvatarDefines::EBakedTextureIndex baked_index,
  39.451 +										BOOL generate_valid_hash) // Set to false if you want to upload the baked texture w/o putting it in the cache
  39.452 +{
  39.453 +	LLUUID hash_id;
  39.454 +	bool hash_computed = false;
  39.455 +	LLMD5 hash;
  39.456 +	const LLVOAvatarDictionary::BakedEntry *baked_dict;
  39.457 +	baked_dict = LLVOAvatarDictionary::getInstance()->getBakedTexture(baked_index);
  39.458 +
  39.459 +	for (U8 i = 0; i < baked_dict->mWearables.size(); i++)
  39.460 +	{
  39.461 +		const LLWearableType::EType baked_type = baked_dict->mWearables[i];
  39.462 +#ifdef MULTIPLE_LAYERS
  39.463 +		const U32 num_wearables = getWearableCount(baked_type);
  39.464 +		for (U32 index = 0; index < num_wearables; ++index)
  39.465 +		{
  39.466 +			const LLWearable* wearable = getWearable(baked_type, index);
  39.467 +			if (wearable)
  39.468 +			{
  39.469 +				LLUUID asset_id = wearable->getID();
  39.470 +				hash.update((const unsigned char*)asset_id.mData, UUID_BYTES);
  39.471 +				hash_computed = true;
  39.472 +			}
  39.473 +		}
  39.474 +#else
  39.475 +		const LLWearable* wearable = getWearable(baked_type);
  39.476 +		if (wearable)
  39.477 +		{
  39.478 +			LLUUID asset_id = wearable->getID();
  39.479 +			hash.update((const unsigned char*)asset_id.mData, UUID_BYTES);
  39.480 +			hash_computed = true;
  39.481 +		}
  39.482 +#endif
  39.483 +	}
  39.484 +	if (hash_computed)
  39.485 +	{
  39.486 +		hash.update((const unsigned char*)baked_dict->mWearablesHashID.mData, UUID_BYTES);
  39.487 +
  39.488 +		// Add some garbage into the hash so that it becomes invalid.
  39.489 +		if (!generate_valid_hash)
  39.490 +		{
  39.491 +			if (mAvatarObject && mAvatarObject->getRegion() != NULL &&
  39.492 +				!mAvatarObject->isDead())
  39.493 +			{
  39.494 +				hash.update((const unsigned char*)mAvatarObject->getID().mData, UUID_BYTES);
  39.495 +			}
  39.496 +		}
  39.497 +		hash.finalize();
  39.498 +		hash.raw_digest(hash_id.mData);
  39.499 +	}
  39.500 +
  39.501 +	return hash_id;
  39.502 +}
  39.503 +
  39.504  //-----------------------------------------------------------------------------
  39.505  // sendAgentSetAppearance()
  39.506  //-----------------------------------------------------------------------------
  39.507 @@ -7789,10 +7871,11 @@
  39.508  
  39.509  	for(U8 baked_index = 0; baked_index < BAKED_NUM_INDICES; baked_index++ )
  39.510  	{
  39.511 -		const ETextureIndex texture_index = getTextureIndex((EBakedTextureIndex)baked_index);
  39.512 +		const ETextureIndex texture_index = LLVOAvatarDictionary::bakedToLocalTextureIndex((EBakedTextureIndex)baked_index);
  39.513  
  39.514  		// if we're not wearing a skirt, we don't need the texture to be baked
  39.515 -		if (texture_index == TEX_SKIRT_BAKED && !mAvatarObject->isWearingWearableType(WT_SKIRT))
  39.516 +		if (texture_index == TEX_SKIRT_BAKED &&
  39.517 +			!mAvatarObject->isWearingWearableType(LLWearableType::WT_SKIRT))
  39.518  		{
  39.519  			continue;
  39.520  		}
  39.521 @@ -7811,28 +7894,24 @@
  39.522  		llinfos << "TAT: Sending cached texture data" << llendl;
  39.523  		for (U8 baked_index = 0; baked_index < BAKED_NUM_INDICES; baked_index++)
  39.524  		{
  39.525 -			const LLVOAvatarDictionary::WearableDictionaryEntry *wearable_dict = LLVOAvatarDictionary::getInstance()->getWearable((EBakedTextureIndex)baked_index);
  39.526 -			LLUUID hash;
  39.527 -			for (U8 i=0; i < wearable_dict->mWearablesVec.size(); i++)
  39.528 +			BOOL generate_valid_hash = TRUE;
  39.529 +/*
  39.530 +			if (mAvatarObject && mAvatarObject->getRegion() != NULL &&
  39.531 +				!mAvatarObject->isDead() &&
  39.532 +				!mAvatarObject->isBakedTextureFinal((LLVOAvatarDefines::EBakedTextureIndex)baked_index))
  39.533  			{
  39.534 -				// EWearableType wearable_type = gBakedWearableMap[baked_index][wearable_num];
  39.535 -				const EWearableType wearable_type = wearable_dict->mWearablesVec[i];
  39.536 -				const LLWearable* wearable = getWearable(wearable_type);
  39.537 -				if (wearable)
  39.538 -				{
  39.539 -					hash ^= wearable->getID();
  39.540 -				}
  39.541 +				generate_valid_hash = FALSE;
  39.542 +				llinfos << "Not caching baked texture upload for " << (U32)baked_index << " due to being uploaded at low resolution." << llendl;
  39.543  			}
  39.544 +*/
  39.545 +			const LLUUID hash = computeBakedTextureHash((EBakedTextureIndex) baked_index, generate_valid_hash);
  39.546  			if (hash.notNull())
  39.547  			{
  39.548 -				hash ^= wearable_dict->mHashID;
  39.549 +				ETextureIndex texture_index = LLVOAvatarDictionary::bakedToLocalTextureIndex((EBakedTextureIndex) baked_index);
  39.550 +				msg->nextBlockFast(_PREHASH_WearableData);
  39.551 +				msg->addUUIDFast(_PREHASH_CacheID, hash);
  39.552 +				msg->addU8Fast(_PREHASH_TextureIndex, (U8)texture_index);
  39.553  			}
  39.554 -
  39.555 -			const ETextureIndex texture_index = getTextureIndex((EBakedTextureIndex)baked_index);
  39.556 -
  39.557 -			msg->nextBlockFast(_PREHASH_WearableData);
  39.558 -			msg->addUUIDFast(_PREHASH_CacheID, hash);
  39.559 -			msg->addU8Fast(_PREHASH_TextureIndex, (U8)texture_index);
  39.560  		}
  39.561  		msg->nextBlockFast(_PREHASH_ObjectData);
  39.562  		mAvatarObject->packTEMessage( gMessageSystem, TRUE );
  39.563 @@ -7847,7 +7926,7 @@
  39.564  	}
  39.565  
  39.566  	BOOL send_v1_message = gSavedSettings.getBOOL("PhoenixDontSendAvPhysicsParms");
  39.567 -	BOOL wearing_physics = (getWearable(WT_PHYSICS) != NULL);
  39.568 +	BOOL wearing_physics = (getWearable(LLWearableType::WT_PHYSICS) != NULL);
  39.569  	S32 transmitted_params = 0;
  39.570  	for (LLViewerVisualParam* param = (LLViewerVisualParam*)mAvatarObject->getFirstVisualParam();
  39.571  		 param;
  39.572 @@ -7890,12 +7969,13 @@
  39.573  	sendReliableMessage();
  39.574  }
  39.575  
  39.576 -void LLAgent::removeWearable( EWearableType type )
  39.577 +void LLAgent::removeWearable(LLWearableType::EType type)
  39.578  {
  39.579  	LLWearable* old_wearable = mWearableEntry[ type ].mWearable;
  39.580  
  39.581 -	if ( (gAgent.isTeen())
  39.582 -		 && (type == WT_UNDERSHIRT || type == WT_UNDERPANTS))
  39.583 +	if (gAgent.isTeen() &&
  39.584 +		(type == LLWearableType::WT_UNDERSHIRT ||
  39.585 +		 type == LLWearableType::WT_UNDERPANTS))
  39.586  	{
  39.587  		// Can't take off underclothing in simple UI mode or on PG accounts
  39.588  		return;
  39.589 @@ -7929,7 +8009,7 @@
  39.590  bool LLAgent::onRemoveWearableDialog(const LLSD& notification, const LLSD& response )
  39.591  {
  39.592  	S32 option = LLNotification::getSelectedOption(notification, response);
  39.593 -	EWearableType type = (EWearableType)notification["payload"]["wearable_type"].asInteger();
  39.594 +	LLWearableType::EType type = (LLWearableType::EType)notification["payload"]["wearable_type"].asInteger();
  39.595  	switch( option )
  39.596  	{
  39.597  	case 0:  // "Save"
  39.598 @@ -7952,7 +8032,7 @@
  39.599  }
  39.600  
  39.601  // Called by removeWearable() and onRemoveWearableDialog() to actually do the removal.
  39.602 -void LLAgent::removeWearableFinal( EWearableType type )
  39.603 +void LLAgent::removeWearableFinal(LLWearableType::EType type)
  39.604  {
  39.605  	LLWearable* old_wearable = mWearableEntry[ type ].mWearable;
  39.606  
  39.607 @@ -7974,7 +8054,7 @@
  39.608  	gInventory.notifyObservers();
  39.609  }
  39.610  
  39.611 -void LLAgent::copyWearableToInventory( EWearableType type )
  39.612 +void LLAgent::copyWearableToInventory(LLWearableType::EType type)
  39.613  {
  39.614  	LLWearable* wearable = mWearableEntry[ type ].mWearable;
  39.615  	if( wearable )
  39.616 @@ -8013,7 +8093,7 @@
  39.617  	LLWearable*			mNewWearable;
  39.618  };
  39.619  
  39.620 -BOOL LLAgent::needsReplacement(EWearableType  wearableType, S32 remove)
  39.621 +BOOL LLAgent::needsReplacement(LLWearableType::EType  wearableType, S32 remove)
  39.622  {
  39.623  	return TRUE;
  39.624  	/*if (remove) return TRUE;
  39.625 @@ -8027,26 +8107,26 @@
  39.626  	const LLDynamicArray< LLWearable* >& wearables,
  39.627  	BOOL remove )
  39.628  {
  39.629 -	lldebugs << "setWearableOutfit() start" << llendl;
  39.630 -
  39.631 -	BOOL wearables_to_remove[WT_COUNT];
  39.632 -	wearables_to_remove[WT_SHAPE]		= FALSE;
  39.633 -	wearables_to_remove[WT_SKIN]		= FALSE;
  39.634 -	wearables_to_remove[WT_HAIR]		= FALSE;
  39.635 -	wearables_to_remove[WT_EYES]		= FALSE;
  39.636 +	LL_DEBUGS("Wearables") << "setWearableOutfit() start" << LL_ENDL;
  39.637 +
  39.638 +	BOOL wearables_to_remove[LLWearableType::WT_COUNT];
  39.639 +	wearables_to_remove[LLWearableType::WT_SHAPE]		= FALSE;
  39.640 +	wearables_to_remove[LLWearableType::WT_SKIN]		= FALSE;
  39.641 +	wearables_to_remove[LLWearableType::WT_HAIR]		= FALSE;
  39.642 +	wearables_to_remove[LLWearableType::WT_EYES]		= FALSE;
  39.643  // [RLVa:KB] - Checked: 2009-07-06 (RLVa-1.1.3b) | Added: RLVa-0.2.2a
  39.644 -	wearables_to_remove[WT_SHIRT]		= remove && gRlvWearableLocks.canRemove(WT_SHIRT);
  39.645 -	wearables_to_remove[WT_PANTS]		= remove && gRlvWearableLocks.canRemove(WT_PANTS);
  39.646 -	wearables_to_remove[WT_SHOES]		= remove && gRlvWearableLocks.canRemove(WT_SHOES);
  39.647 -	wearables_to_remove[WT_SOCKS]		= remove && gRlvWearableLocks.canRemove(WT_SOCKS);
  39.648 -	wearables_to_remove[WT_JACKET]		= remove && gRlvWearableLocks.canRemove(WT_JACKET);
  39.649 -	wearables_to_remove[WT_GLOVES]		= remove && gRlvWearableLocks.canRemove(WT_GLOVES);
  39.650 -	wearables_to_remove[WT_UNDERSHIRT]	= (!gAgent.isTeen()) && remove && gRlvWearableLocks.canRemove(WT_UNDERSHIRT);
  39.651 -	wearables_to_remove[WT_UNDERPANTS]	= (!gAgent.isTeen()) && remove && gRlvWearableLocks.canRemove(WT_UNDERPANTS);
  39.652 -	wearables_to_remove[WT_SKIRT]		= remove && gRlvWearableLocks.canRemove(WT_SKIRT);
  39.653 -	wearables_to_remove[WT_ALPHA]		= remove && gRlvWearableLocks.canRemove(WT_ALPHA);
  39.654 -	wearables_to_remove[WT_TATTOO]		= remove && gRlvWearableLocks.canRemove(WT_TATTOO);
  39.655 -	wearables_to_remove[WT_PHYSICS]     = remove && gRlvWearableLocks.canRemove(WT_PHYSICS);
  39.656 +	wearables_to_remove[LLWearableType::WT_SHIRT]		= remove && gRlvWearableLocks.canRemove(LLWearableType::WT_SHIRT);
  39.657 +	wearables_to_remove[LLWearableType::WT_PANTS]		= remove && gRlvWearableLocks.canRemove(LLWearableType::WT_PANTS);
  39.658 +	wearables_to_remove[LLWearableType::WT_SHOES]		= remove && gRlvWearableLocks.canRemove(LLWearableType::WT_SHOES);
  39.659 +	wearables_to_remove[LLWearableType::WT_SOCKS]		= remove && gRlvWearableLocks.canRemove(LLWearableType::WT_SOCKS);
  39.660 +	wearables_to_remove[LLWearableType::WT_JACKET]		= remove && gRlvWearableLocks.canRemove(LLWearableType::WT_JACKET);
  39.661 +	wearables_to_remove[LLWearableType::WT_GLOVES]		= remove && gRlvWearableLocks.canRemove(LLWearableType::WT_GLOVES);
  39.662 +	wearables_to_remove[LLWearableType::WT_UNDERSHIRT]	= (!gAgent.isTeen()) && remove && gRlvWearableLocks.canRemove(LLWearableType::WT_UNDERSHIRT);
  39.663 +	wearables_to_remove[LLWearableType::WT_UNDERPANTS]	= (!gAgent.isTeen()) && remove && gRlvWearableLocks.canRemove(LLWearableType::WT_UNDERPANTS);
  39.664 +	wearables_to_remove[LLWearableType::WT_SKIRT]		= remove && gRlvWearableLocks.canRemove(LLWearableType::WT_SKIRT);
  39.665 +	wearables_to_remove[LLWearableType::WT_ALPHA]		= remove && gRlvWearableLocks.canRemove(LLWearableType::WT_ALPHA);
  39.666 +	wearables_to_remove[LLWearableType::WT_TATTOO]		= remove && gRlvWearableLocks.canRemove(LLWearableType::WT_TATTOO);
  39.667 +	wearables_to_remove[LLWearableType::WT_PHYSICS]     = remove && gRlvWearableLocks.canRemove(LLWearableType::WT_PHYSICS);
  39.668  // [/RLVa:KB]
  39.669  
  39.670  	S32 count = wearables.count();
  39.671 @@ -8058,7 +8138,7 @@
  39.672  		LLWearable* new_wearable = wearables[i];
  39.673  		LLPointer<LLInventoryItem> new_item = items[i];
  39.674  
  39.675 -		EWearableType type = new_wearable->getType();
  39.676 +		LLWearableType::EType type = new_wearable->getType();
  39.677  		wearables_to_remove[type] = FALSE;
  39.678  
  39.679  		LLWearable* old_wearable = mWearableEntry[ type ].mWearable;
  39.680 @@ -8068,7 +8148,9 @@
  39.681  			if( (old_wearable->getID() == new_wearable->getID()) &&
  39.682  				(old_item_id == new_item->getLinkedUUID()) )
  39.683  			{
  39.684 -				lldebugs << "No change to wearable asset and item: " << LLWearable::typeToTypeName( type ) << llendl;
  39.685 +				LL_DEBUGS("Wearables") << "No change to wearable asset and item: "
  39.686 +									   << LLWearableType::getTypeName(type)
  39.687 +									   << LL_ENDL;
  39.688  				continue;
  39.689  			}
  39.690  
  39.691 @@ -8088,7 +8170,7 @@
  39.692  
  39.693  	std::vector<LLWearable*> wearables_being_removed;
  39.694  
  39.695 -	for( i = 0; i < WT_COUNT; i++ )
  39.696 +	for (i = 0; i < LLWearableType::WT_COUNT; i++)
  39.697  	{
  39.698  		if( wearables_to_remove[i] )
  39.699  		{
  39.700 @@ -8127,14 +8209,14 @@
  39.701  	sendAgentWearablesUpdate();
  39.702  	sendAgentSetAppearance();
  39.703  
  39.704 -	lldebugs << "setWearableOutfit() end" << llendl;
  39.705 +	LL_DEBUGS("Wearables") << "setWearableOutfit() end" << LL_ENDL;
  39.706  }
  39.707  
  39.708  
  39.709  // User has picked "wear on avatar" from a menu.
  39.710  void LLAgent::setWearable( LLInventoryItem* new_item, LLWearable* new_wearable )
  39.711  {
  39.712 -	EWearableType type = new_wearable->getType();
  39.713 +	LLWearableType::EType type = new_wearable->getType();
  39.714  
  39.715  	LLWearable* old_wearable = mWearableEntry[ type ].mWearable;
  39.716  
  39.717 @@ -8152,7 +8234,9 @@
  39.718  		if( (old_wearable->getID() == new_wearable->getID()) &&
  39.719  			(old_item_id == new_item->getUUID()) )
  39.720  		{
  39.721 -			lldebugs << "No change to wearable asset and item: " << LLWearable::typeToTypeName( type ) << llendl;
  39.722 +			LL_DEBUGS("Wearables") << "No change to wearable asset and item: "
  39.723 +								   << LLWearableType::getTypeName(type)
  39.724 +								   << LL_ENDL;
  39.725  			return;
  39.726  		}
  39.727  
  39.728 @@ -8209,7 +8293,7 @@
  39.729  // Called from setWearable() and onSetWearableDialog() to actually set the wearable.
  39.730  void LLAgent::setWearableFinal( LLInventoryItem* new_item, LLWearable* new_wearable )
  39.731  {
  39.732 -	EWearableType type = new_wearable->getType();
  39.733 +	LLWearableType::EType type = new_wearable->getType();
  39.734  
  39.735  	// Replace the old wearable with a new one.
  39.736  	llassert( new_item->getAssetUUID() == new_wearable->getID() );
  39.737 @@ -8257,47 +8341,43 @@
  39.738  	S32 num_queries = 0;
  39.739  	for (U8 baked_index = 0; baked_index < BAKED_NUM_INDICES; baked_index++ )
  39.740  	{
  39.741 -		const LLVOAvatarDictionary::WearableDictionaryEntry *wearable_dict = LLVOAvatarDictionary::getInstance()->getWearable((EBakedTextureIndex)baked_index);
  39.742 -		LLUUID hash;
  39.743 -		for (U8 i=0; i < wearable_dict->mWearablesVec.size(); i++)
  39.744 -		{
  39.745 -			// EWearableType wearable_type = gBakedWearableMap[baked_index][wearable_num];
  39.746 -			const EWearableType wearable_type = wearable_dict->mWearablesVec[i];
  39.747 -			const LLWearable* wearable = getWearable(wearable_type);
  39.748 -			if (wearable)
  39.749 -			{
  39.750 -				hash ^= wearable->getID();
  39.751 -			}
  39.752 -		}
  39.753 -		if (hash.notNull())
  39.754 -		{
  39.755 -			hash ^= wearable_dict->mHashID;
  39.756 +		LLUUID hash_id = computeBakedTextureHash((EBakedTextureIndex) baked_index);
  39.757 +		if (hash_id.notNull())
  39.758 +		{
  39.759  			num_queries++;
  39.760  			// *NOTE: make sure at least one request gets packed
  39.761  
  39.762 +			ETextureIndex te_index = LLVOAvatarDictionary::bakedToLocalTextureIndex((EBakedTextureIndex)baked_index);
  39.763 +
  39.764  			//llinfos << "Requesting texture for hash " << hash << " in baked texture slot " << baked_index << llendl;
  39.765  			gMessageSystem->nextBlockFast(_PREHASH_WearableData);
  39.766 -			gMessageSystem->addUUIDFast(_PREHASH_ID, hash);
  39.767 -			gMessageSystem->addU8Fast(_PREHASH_TextureIndex, (U8)baked_index);
  39.768 +			gMessageSystem->addUUIDFast(_PREHASH_ID, hash_id);
  39.769 +			gMessageSystem->addU8Fast(_PREHASH_TextureIndex, (U8)te_index);
  39.770  		}
  39.771  
  39.772  		mActiveCacheQueries[ baked_index ] = mTextureCacheQueryID;
  39.773  	}
  39.774  
  39.775 -	llinfos << "Requesting texture cache entry for " << num_queries << " baked textures" << llendl;
  39.776 -	gMessageSystem->sendReliable(getRegion()->getHost());
  39.777 -	mNumPendingQueries++;
  39.778 -	mTextureCacheQueryID++;
  39.779 +	// VWR-22113: getRegion() can return null if invalid, seen here on logout
  39.780 +	if (getRegion())
  39.781 +	{
  39.782 +		llinfos << "Requesting texture cache entry for " << num_queries << " baked textures" << llendl;
  39.783 +		gMessageSystem->sendReliable(getRegion()->getHost());
  39.784 +		mNumPendingQueries++;
  39.785 +		mTextureCacheQueryID++;
  39.786 +	}
  39.787  }
  39.788  
  39.789  // User has picked "remove from avatar" from a menu.
  39.790  // static
  39.791  void LLAgent::userRemoveWearable( void* userdata )
  39.792  {
  39.793 -	EWearableType type = (EWearableType)(intptr_t)userdata;
  39.794 +	LLWearableType::EType type = (LLWearableType::EType)(intptr_t)userdata;
  39.795  	
  39.796 -	if( !(type==WT_SHAPE || type==WT_SKIN || type==WT_HAIR || type==WT_EYES) ) //&&
  39.797 -		//!((!gAgent.isTeen()) && ( type==WT_UNDERPANTS || type==WT_UNDERSHIRT )) )
  39.798 +	if (type != LLWearableType::WT_SHAPE && type != LLWearableType::WT_SKIN &&
  39.799 +		type != LLWearableType::WT_HAIR && type != LLWearableType::WT_EYES)
  39.800 +		// && (!gAgent.isTeen() || (type != LLWearableType::WT_UNDERPANTS &&
  39.801 +		//						    type != LLWearableType::WT_UNDERSHIRT)))
  39.802  	{
  39.803  		gAgent.removeWearable( type );
  39.804  	}
  39.805 @@ -8320,18 +8400,17 @@
  39.806  {
  39.807  	if( proceed )
  39.808  	{
  39.809 -		gAgent.removeWearable( WT_SHIRT );
  39.810 -		gAgent.removeWearable( WT_PANTS );
  39.811 -		gAgent.removeWearable( WT_SHOES );
  39.812 -		gAgent.removeWearable( WT_SOCKS );
  39.813 -		gAgent.removeWearable( WT_JACKET );
  39.814 -		gAgent.removeWearable( WT_GLOVES );
  39.815 -		gAgent.removeWearable( WT_UNDERSHIRT );
  39.816 -		gAgent.removeWearable( WT_UNDERPANTS );
  39.817 -		gAgent.removeWearable( WT_SKIRT );
  39.818 -		gAgent.removeWearable( WT_ALPHA );
  39.819 -		gAgent.removeWearable( WT_TATTOO );
  39.820 -		gAgent.removeWearable( WT_PHYSICS );
  39.821 +		gAgent.removeWearable(LLWearableType::WT_SHIRT);
  39.822 +		gAgent.removeWearable(LLWearableType::WT_PANTS);
  39.823 +		gAgent.removeWearable(LLWearableType::WT_SHOES);
  39.824 +		gAgent.removeWearable(LLWearableType::WT_SOCKS);
  39.825 +		gAgent.removeWearable(LLWearableType::WT_JACKET);
  39.826 +		gAgent.removeWearable(LLWearableType::WT_GLOVES);
  39.827 +		gAgent.removeWearable(LLWearableType::WT_UNDERSHIRT);
  39.828 +		gAgent.removeWearable(LLWearableType::WT_UNDERPANTS);
  39.829 +		gAgent.removeWearable(LLWearableType::WT_SKIRT);
  39.830 +		gAgent.removeWearable(LLWearableType::WT_ALPHA);
  39.831 +		gAgent.removeWearable(LLWearableType::WT_TATTOO);
  39.832  	}
  39.833  }
  39.834  
    40.1 --- a/indra/newview/llagent.h	Mon Feb 27 23:28:58 2012 -0800
    40.2 +++ b/indra/newview/llagent.h	Mon Feb 27 23:59:10 2012 -0800
    40.3 @@ -61,6 +61,7 @@
    40.4  #include "v4math.h"
    40.5  //#include "vmath.h"
    40.6  #include "stdenums.h"
    40.7 +#include "llvoavatardefines.h"
    40.8  #include "llwearable.h"
    40.9  #include "llcharacter.h"
   40.10  #include "llinventory.h"
   40.11 @@ -190,7 +191,7 @@
   40.12  
   40.13  	// Set the home data
   40.14  	void			setRegion(LLViewerRegion *regionp);
   40.15 -	LLViewerRegion	*getRegion() const;
   40.16 +	LLViewerRegion*	getRegion() const;
   40.17  	const LLHost&	getRegionHost() const;
   40.18  	std::string		getSLURL() const;
   40.19  	
   40.20 @@ -307,8 +308,6 @@
   40.21  	bool			getAlwaysRun() const { return mbAlwaysRun; }
   40.22  	bool			getRunning() const { return mbRunning; }
   40.23  
   40.24 -	const LLUUID&	getInventoryRootID() const 	{ return mInventoryRootID; }
   40.25 -
   40.26  	void			buildFullname(std::string &name) const;
   40.27  	void			buildFullnameAndTitle(std::string &name) const;
   40.28  
   40.29 @@ -646,6 +645,8 @@
   40.30  	void			requestEnterGodMode();
   40.31  	void			requestLeaveGodMode();
   40.32  
   40.33 +	LLUUID			computeBakedTextureHash(LLVOAvatarDefines::EBakedTextureIndex baked_index,
   40.34 +											BOOL generate_valid_hash = TRUE);
   40.35  	void			sendAgentSetAppearance();
   40.36  
   40.37  	void 			sendAgentDataUpdateRequest();
   40.38 @@ -657,28 +658,28 @@
   40.39  	//--------------------------------------------------------------------
   40.40  	// Wearables
   40.41  	//--------------------------------------------------------------------
   40.42 -	void			setWearable( LLInventoryItem* new_item, LLWearable* wearable );
   40.43 -	static bool		onSetWearableDialog( const LLSD& notification, const LLSD& response, LLWearable* wearable );
   40.44 -	void			setWearableFinal( LLInventoryItem* new_item, LLWearable* new_wearable );
   40.45 -	void			setWearableOutfit( 	const LLInventoryItem::item_array_t& items, const LLDynamicArray< LLWearable* >& wearables, BOOL remove );
   40.46 +	void			setWearable(LLInventoryItem* new_item, LLWearable* wearable);
   40.47 +	static bool		onSetWearableDialog(const LLSD& notification, const LLSD& response, LLWearable* wearable);
   40.48 +	void			setWearableFinal(LLInventoryItem* new_item, LLWearable* new_wearable);
   40.49 +	void			setWearableOutfit(	const LLInventoryItem::item_array_t& items, const LLDynamicArray< LLWearable* >& wearables, BOOL remove);
   40.50  	void			queryWearableCache();
   40.51  
   40.52 -	BOOL			isWearableModifiable(EWearableType type);
   40.53 -	BOOL			isWearableCopyable(EWearableType type);
   40.54 -	BOOL			needsReplacement(EWearableType wearableType, S32 remove);
   40.55 -	U32				getWearablePermMask(EWearableType type);
   40.56 +	BOOL			isWearableModifiable(LLWearableType::EType type);
   40.57 +	BOOL			isWearableCopyable(LLWearableType::EType type);
   40.58 +	BOOL			needsReplacement(LLWearableType::EType wearableType, S32 remove);
   40.59 +	U32				getWearablePermMask(LLWearableType::EType type);
   40.60  
   40.61 -	LLInventoryItem* getWearableInventoryItem(EWearableType type);
   40.62 +	LLInventoryItem* getWearableInventoryItem(LLWearableType::EType type);
   40.63  
   40.64 -	LLWearable*		getWearable( EWearableType type ) { return (type < WT_COUNT) ? mWearableEntry[ type ].mWearable : NULL; }
   40.65 -	BOOL			isWearingItem( const LLUUID& item_id );
   40.66 -	LLWearable*		getWearableFromWearableItem( const LLUUID& item_id );
   40.67 -	const LLUUID&	getWearableItem( EWearableType type ) { return (type < WT_COUNT) ? mWearableEntry[ type ].mItemID : LLUUID::null; }
   40.68 +	LLWearable*		getWearable(LLWearableType::EType type) { return (type < LLWearableType::WT_COUNT) ? mWearableEntry[ type ].mWearable : NULL; }
   40.69 +	BOOL			isWearingItem(const LLUUID& item_id);
   40.70 +	LLWearable*		getWearableFromWearableItem(const LLUUID& item_id);
   40.71 +	const LLUUID&	getWearableItem(LLWearableType::EType type) { return (type < LLWearableType::WT_COUNT) ? mWearableEntry[ type ].mItemID : LLUUID::null; }
   40.72  
   40.73 -	static EWearableType getTEWearableType( S32 te );
   40.74 -	static LLUUID	getDefaultTEImageID( S32 te );
   40.75 -	
   40.76 -	void			copyWearableToInventory( EWearableType type );
   40.77 +	static LLWearableType::EType getTEWearableType(S32 te);
   40.78 +	static LLUUID	getDefaultTEImageID(S32 te);
   40.79 +
   40.80 +	void			copyWearableToInventory(LLWearableType::EType type);
   40.81  
   40.82  	void			makeNewOutfit(
   40.83  						const std::string& new_folder_name,
   40.84 @@ -687,9 +688,9 @@
   40.85  						BOOL rename_clothing);
   40.86  	void			makeNewOutfitDone(S32 index);
   40.87  
   40.88 -	void			removeWearable( EWearableType type );
   40.89 -	static bool		onRemoveWearableDialog(const LLSD& notification, const LLSD& response );
   40.90 -	void			removeWearableFinal( EWearableType type );
   40.91 +	void			removeWearable(LLWearableType::EType type);
   40.92 +	static bool		onRemoveWearableDialog(const LLSD& notification, const LLSD& response);
   40.93 +	void			removeWearableFinal(LLWearableType::EType type);
   40.94  	
   40.95  	void			sendAgentWearablesUpdate();
   40.96  
   40.97 @@ -708,14 +709,14 @@
   40.98  		const LLUUID& item_id,
   40.99  		LLWearable* wearable);
  40.100  	
  40.101 -	void			saveWearableAs( EWearableType type, const std::string& new_name, BOOL save_in_lost_and_found );
  40.102 -	void			saveWearable( EWearableType type, BOOL send_update = TRUE );
  40.103 +	void			saveWearableAs(LLWearableType::EType type, const std::string& new_name, BOOL save_in_lost_and_found);
  40.104 +	void			saveWearable(LLWearableType::EType type, BOOL send_update = TRUE);
  40.105  	void			saveAllWearables();
  40.106  	
  40.107 -	void			revertWearable( EWearableType type );
  40.108 +	void			revertWearable(LLWearableType::EType type);
  40.109  	void			revertAllWearables();
  40.110  
  40.111 -	void			setWearableName( const LLUUID& item_id, const std::string& new_name );
  40.112 +	void			setWearableName(const LLUUID& item_id, const std::string& new_name);
  40.113  	void			createStandardWearables(BOOL female);
  40.114  	void			createStandardWearablesDone(S32 index);
  40.115  	void			createStandardWearablesAllDone();
  40.116 @@ -761,7 +762,7 @@
  40.117  	// internal wearable functions
  40.118  	void			sendAgentWearablesRequest();
  40.119  	static void		onInitialWearableAssetArrived(LLWearable* wearable, void* userdata);
  40.120 -	void			recoverMissingWearable(EWearableType type);
  40.121 +	void			recoverMissingWearable(LLWearableType::EType type);
  40.122  	void			recoverMissingWearableDone();
  40.123  	void			addWearableToAgentInventory(LLPointer<LLInventoryCallback> cb,
  40.124  						LLWearable* wearable, const LLUUID& category_id = LLUUID::null,
  40.125 @@ -777,8 +778,7 @@
  40.126  	std::string		mGroupTitle; // honorific, like "Sir"
  40.127  	std::string		mGroupName;
  40.128  	LLUUID			mGroupID;
  40.129 -	//LLUUID			mGroupInsigniaID;
  40.130 -	LLUUID			mInventoryRootID;
  40.131 +	//LLUUID		mGroupInsigniaID;
  40.132  	LLUUID			mMapID;
  40.133  	F64				mMapOriginX;	// Global x coord of mMapID's bottom left corner.
  40.134  	F64				mMapOriginY;	// Global y coord of mMapID's bottom left corner.
  40.135 @@ -990,7 +990,7 @@
  40.136  		LLUUID		mItemID;	// ID of the inventory item in the agent's inventory.
  40.137  		LLWearable*	mWearable;
  40.138  	};
  40.139 -	LLWearableEntry mWearableEntry[ WT_COUNT ];
  40.140 +	LLWearableEntry mWearableEntry[LLWearableType::WT_COUNT];
  40.141  	U32				mAgentWearablesUpdateSerialNum;
  40.142  	BOOL			mWearablesLoaded;
  40.143  	S32				mTextureCacheQueryID;
    41.1 --- a/indra/newview/llappviewer.cpp	Mon Feb 27 23:28:58 2012 -0800
    41.2 +++ b/indra/newview/llappviewer.cpp	Mon Feb 27 23:59:10 2012 -0800
    41.3 @@ -255,17 +255,14 @@
    41.4  static const F32 LOGOUT_REQUEST_TIME = 6.f;  // this will be cut short by the LogoutReply msg.
    41.5  F32 gLogoutMaxTime = LOGOUT_REQUEST_TIME;
    41.6  
    41.7 -LLUUID gInventoryLibraryOwner;
    41.8 -LLUUID gInventoryLibraryRoot;
    41.9 -
   41.10 -BOOL				gDisconnected = FALSE;
   41.11 +BOOL gDisconnected = FALSE;
   41.12  
   41.13  // Minimap scale in pixels per region
   41.14  
   41.15  // used to restore texture state after a mode switch
   41.16  LLFrameTimer	gRestoreGLTimer;
   41.17  BOOL			gRestoreGL = FALSE;
   41.18 -BOOL				gUseWireframe = FALSE;
   41.19 +BOOL			gUseWireframe = FALSE;
   41.20  
   41.21  // VFS globals - see llappviewer.h
   41.22  LLVFS* gStaticVFS = NULL;
   41.23 @@ -1227,16 +1224,31 @@
   41.24  				bool is_slow = (frameTimer.getElapsedTimeF64() > FRAME_SLOW_THRESHOLD) ;
   41.25  				S32 total_work_pending = 0;
   41.26  				S32 total_io_pending = 0;
   41.27 +				F32 max_time = llmin(gFrameIntervalSeconds * 10.f, 1.f);
   41.28  				while(!is_slow)//do not unpause threads if the frame rates are very low.
   41.29  				{
   41.30  					S32 work_pending = 0;
   41.31  					S32 io_pending = 0;
   41.32 - 					work_pending += LLAppViewer::getTextureCache()->update(1); // unpauses the texture cache thread
   41.33 - 					work_pending += LLAppViewer::getImageDecodeThread()->update(1); // unpauses the image thread
   41.34 - 					work_pending += LLAppViewer::getTextureFetch()->update(1); // unpauses the texture fetch thread
   41.35 -
   41.36 -					io_pending += LLVFSThread::updateClass(1);
   41.37 -					io_pending += LLLFSThread::updateClass(1);
   41.38 +					{
   41.39 +						LLFastTimer t3(LLFastTimer::FTM_TEXTURE_CACHE);
   41.40 +	 					work_pending = LLAppViewer::getTextureCache()->update(max_time); // unpauses the texture cache thread
   41.41 +					}
   41.42 +					{
   41.43 +						LLFastTimer t3(LLFastTimer::FTM_DECODE);
   41.44 + 						work_pending += LLAppViewer::getImageDecodeThread()->update(max_time); // unpauses the image thread
   41.45 +					}
   41.46 +					{
   41.47 +						LLFastTimer t3(LLFastTimer::FTM_FETCH);
   41.48 + 						work_pending += LLAppViewer::getTextureFetch()->update(max_time); // unpauses the texture fetch thread
   41.49 +					}
   41.50 +					{
   41.51 +						LLFastTimer t3(LLFastTimer::FTM_VFS);
   41.52 +						io_pending += LLVFSThread::updateClass(1);
   41.53 +					}
   41.54 +					{
   41.55 +						LLFastTimer t3(LLFastTimer::FTM_LFS);
   41.56 +						io_pending += LLLFSThread::updateClass(1);
   41.57 +					}
   41.58  					if (io_pending > 1000)
   41.59  					{
   41.60  						ms_sleep(llmin(io_pending / 100, 100)); // give the fs some time to catch up
   41.61 @@ -1415,8 +1427,7 @@
   41.62  
   41.63  		// shut down the audio subsystem
   41.64  
   41.65 -		bool want_longname = false;
   41.66 -		if (gAudiop->getDriverName(want_longname) == "FMOD")
   41.67 +		if (gAudiop->getDriverName(false) == "FMOD")
   41.68  		{
   41.69  			// This hack exists because fmod likes to occasionally
   41.70  			// crash or hang forever when shutting down, for no
   41.71 @@ -1470,7 +1481,8 @@
   41.72  		llinfos << "Waiting for pending IO to finish: " << pending << llendflush;
   41.73  		ms_sleep(100);
   41.74  	}
   41.75 -	llinfos << "Shutting down." << llendflush;
   41.76 +
   41.77 +	llinfos << "Shutting down Views" << llendflush;
   41.78  
   41.79  	// Destroy the UI
   41.80  	if (gViewerWindow)
   41.81 @@ -1478,6 +1490,12 @@
   41.82  		gViewerWindow->shutdownViews();
   41.83  	}
   41.84  
   41.85 +	llinfos << "Cleaning up Inventory" << llendflush;
   41.86 +	
   41.87 +	// Cleanup Inventory after the UI since it will delete any remaining observers
   41.88 +	// (Deleted observers should have already removed themselves)
   41.89 +	gInventory.cleanupInventory();
   41.90 +
   41.91  	// Clean up selection managers after UI is destroyed, as UI may be observing them.
   41.92  	// Clean up before GL is shut down because we might be holding on to objects with texture references
   41.93  	LLSelectMgr::cleanupGlobals();
   41.94 @@ -3798,6 +3816,7 @@
   41.95  		gEventNotifier.update();
   41.96  
   41.97  		gIdleCallbacks.callFunctions();
   41.98 +		gInventory.idleNotifyObservers();
   41.99  	}
  41.100  
  41.101  	gViewerWindow->handlePerFrameHover();
  41.102 @@ -4344,10 +4363,12 @@
  41.103  	if (!gNoRender)
  41.104  	{
  41.105  		// save inventory if appropriate
  41.106 -		gInventory.cache(gAgent.getInventoryRootID(), gAgent.getID());
  41.107 -		if(gInventoryLibraryRoot.notNull() && gInventoryLibraryOwner.notNull())
  41.108 +		gInventory.cache(gInventory.getRootFolderID(), gAgent.getID());
  41.109 +		if (gInventory.getLibraryRootFolderID().notNull() &&
  41.110 +			gInventory.getLibraryOwnerID().notNull())
  41.111  		{
  41.112 -			gInventory.cache(gInventoryLibraryRoot, gInventoryLibraryOwner);
  41.113 +			gInventory.cache(gInventory.getLibraryRootFolderID(),
  41.114 +							 gInventory.getLibraryOwnerID());
  41.115  		}
  41.116  	}
  41.117  
    42.1 --- a/indra/newview/llappviewer.h	Mon Feb 27 23:28:58 2012 -0800
    42.2 +++ b/indra/newview/llappviewer.h	Mon Feb 27 23:59:10 2012 -0800
    42.3 @@ -305,13 +305,13 @@
    42.4  // currently in daylight savings time?
    42.5  extern BOOL gPacificDaylightTime;
    42.6  
    42.7 -extern U64      gFrameTime;					// The timestamp of the most-recently-processed frame
    42.8 -extern F32		gFrameTimeSeconds;			// Loses msec precision after ~4.5 hours...
    42.9 -extern F32		gFrameIntervalSeconds;		// Elapsed time between current and previous gFrameTimeSeconds
   42.10 -extern F32		gFPSClamped;				// Frames per second, smoothed, weighted toward last frame
   42.11 -extern F32		gFrameDTClamped;
   42.12 -extern U64		gStartTime;
   42.13 -extern U32 		gFrameStalls;
   42.14 +extern U64 gFrameTime;                 // The timestamp of the most-recently-processed frame
   42.15 +extern F32 gFrameTimeSeconds;          // Loses msec precision after ~4.5 hours...
   42.16 +extern F32 gFrameIntervalSeconds;      // Elapsed time between current and previous gFrameTimeSeconds
   42.17 +extern F32 gFPSClamped;                // Frames per second, smoothed, weighted toward last frame
   42.18 +extern F32 gFrameDTClamped;
   42.19 +extern U64 gStartTime;
   42.20 +extern U32 gFrameStalls;
   42.21  
   42.22  extern LLTimer gRenderStartTime;
   42.23  extern LLFrameTimer gForegroundTime;
   42.24 @@ -322,21 +322,18 @@
   42.25  extern F32 gSimLastTime; 
   42.26  extern F32 gSimFrames;
   42.27  
   42.28 -extern LLUUID gInventoryLibraryOwner;
   42.29 -extern LLUUID gInventoryLibraryRoot;
   42.30 -
   42.31 -extern BOOL		gDisconnected;
   42.32 +extern BOOL gDisconnected;
   42.33  
   42.34  // Minimap scale in pixels per region
   42.35  
   42.36  extern LLFrameTimer	gRestoreGLTimer;
   42.37  extern BOOL			gRestoreGL;
   42.38 -extern BOOL		gUseWireframe;
   42.39 +extern BOOL			gUseWireframe;
   42.40  
   42.41  // VFS globals - gVFS is for general use
   42.42  // gStaticVFS is read-only and is shipped w/ the viewer
   42.43  // it has pre-cache data like the UI .TGAs
   42.44 -extern LLVFS	*gStaticVFS;
   42.45 +extern LLVFS* gStaticVFS;
   42.46  
   42.47  extern LLMemoryInfo gSysMemory;
   42.48  extern U64 gMemoryAllocated;
    43.1 --- a/indra/newview/lldrawable.cpp	Mon Feb 27 23:28:58 2012 -0800
    43.2 +++ b/indra/newview/lldrawable.cpp	Mon Feb 27 23:59:10 2012 -0800
    43.3 @@ -124,16 +124,16 @@
    43.4  		gPipeline.checkReferences(this);
    43.5  	}
    43.6  
    43.7 +	if (LLSpatialGroup::sNoDelete)
    43.8 +	{
    43.9 +		llerrs << "Illegal deletion of LLDrawable!" << llendl;
   43.10 +	}
   43.11 +
   43.12  	if (isDead())
   43.13  	{
   43.14  		sNumZombieDrawables--;
   43.15  	}
   43.16  
   43.17 -	if (LLSpatialGroup::sNoDelete)
   43.18 -	{
   43.19 -		llerrs << "Illegal deletion of LLDrawable!" << llendl;
   43.20 -	}
   43.21 -
   43.22  	std::for_each(mFaces.begin(), mFaces.end(), DeletePointer());
   43.23  	mFaces.clear();
   43.24  		
   43.25 @@ -1258,7 +1258,14 @@
   43.26  	
   43.27  	void visit(const LLOctreeNode<LLDrawable>* branch)
   43.28  	{
   43.29 -		gPipeline.markNotCulled((LLSpatialGroup*) branch->getListener(0), *mCamera);
   43.30 +		if (branch)
   43.31 +		{
   43.32 +			gPipeline.markNotCulled((LLSpatialGroup*) branch->getListener(0), *mCamera);
   43.33 +		}
   43.34 +		else
   43.35 +		{
   43.36 +			llwarns << "LLOctreeMarkNotCulled::visit() called for a NULL branch" << llendl;
   43.37 +		}
   43.38  	}
   43.39  };
   43.40  
    44.1 --- a/indra/newview/lldrawpoolavatar.cpp	Mon Feb 27 23:28:58 2012 -0800
    44.2 +++ b/indra/newview/lldrawpoolavatar.cpp	Mon Feb 27 23:59:10 2012 -0800
    44.3 @@ -46,6 +46,7 @@
    44.4  #include "llmeshrepository.h"
    44.5  #include "llsky.h"
    44.6  #include "llviewercamera.h"
    44.7 +#include "llviewercontrol.h"
    44.8  #include "llviewerregion.h"
    44.9  #include "noise.h"
   44.10  #include "pipeline.h"
   44.11 @@ -1271,7 +1272,9 @@
   44.12  	}
   44.13  }
   44.14  
   44.15 -void LLDrawPoolAvatar::updateRiggedFaceVertexBuffer(LLVOAvatar* avatar, LLFace* face, const LLMeshSkinInfo* skin, LLVolume* volume, const LLVolumeFace& vol_face)
   44.16 +void LLDrawPoolAvatar::updateRiggedFaceVertexBuffer(LLVOAvatar* avatar, LLFace* face, 
   44.17 +													const LLMeshSkinInfo* skin, LLVolume* volume, 
   44.18 +													const LLVolumeFace& vol_face, LLVOVolume* vobj)
   44.19  {
   44.20  	LLVector4a* weight = vol_face.mWeights;
   44.21  	if (!weight)
   44.22 @@ -1323,10 +1326,21 @@
   44.23  						m.m[4], m.m[5], m.m[6],
   44.24  						m.m[8], m.m[9], m.m[10] };
   44.25  
   44.26 -		LLMatrix3 mat_normal(mat3);				
   44.27 +		LLMatrix3 mat_normal(mat3);
   44.28  
   44.29 -		face->getGeometryVolume(*volume, face->getTEOffset(), mat_vert,
   44.30 -								mat_normal, offset, true);
   44.31 +		static LLCachedControl<bool> mesh_enable_deformer(gSavedSettings, "MeshEnableDeformer");
   44.32 +		if (mesh_enable_deformer)
   44.33 +		{
   44.34 +			LLDeformedVolume* deformed_volume = vobj->getDeformedVolume();
   44.35 +			deformed_volume->deform(volume, avatar, skin, face->getTEOffset());
   44.36 +			face->getGeometryVolume(*deformed_volume, face->getTEOffset(), mat_vert,
   44.37 +									mat_normal, offset, true);
   44.38 +		}
   44.39 +		else
   44.40 +		{
   44.41 +			face->getGeometryVolume(*volume, face->getTEOffset(), mat_vert,
   44.42 + 									mat_normal, offset, true);
   44.43 +		}
   44.44  	}
   44.45  
   44.46  	if (sShaderLevel <= 0 && face->mLastSkinTime < avatar->getLastSkinTime())
   44.47 @@ -1463,7 +1477,7 @@
   44.48  		stop_glerror();
   44.49  
   44.50  		const LLVolumeFace& vol_face = volume->getVolumeFace(te);
   44.51 -		updateRiggedFaceVertexBuffer(avatar, face, skin, volume, vol_face);
   44.52 +		updateRiggedFaceVertexBuffer(avatar, face, skin, volume, vol_face, vobj);
   44.53  
   44.54  		stop_glerror();
   44.55  
    45.1 --- a/indra/newview/lldrawpoolavatar.h	Mon Feb 27 23:28:58 2012 -0800
    45.2 +++ b/indra/newview/lldrawpoolavatar.h	Mon Feb 27 23:59:10 2012 -0800
    45.3 @@ -41,6 +41,7 @@
    45.4  class LLMeshSkinInfo;
    45.5  class LLVolume;
    45.6  class LLVolumeFace;
    45.7 +class LLVOVolume;
    45.8  
    45.9  class LLDrawPoolAvatar : public LLFacePool
   45.10  {
   45.11 @@ -138,7 +139,8 @@
   45.12  									  LLFace* facep, 
   45.13  									  const LLMeshSkinInfo* skin, 
   45.14  									  LLVolume* volume,
   45.15 -									  const LLVolumeFace& vol_face);
   45.16 +									  const LLVolumeFace& vol_face,
   45.17 +									  LLVOVolume* vobj);
   45.18  
   45.19  	void renderRigged(LLVOAvatar* avatar, U32 type, bool glow = false);
   45.20  	void renderRiggedSimple(LLVOAvatar* avatar);
    46.1 --- a/indra/newview/llfasttimerview.cpp	Mon Feb 27 23:28:58 2012 -0800
    46.2 +++ b/indra/newview/llfasttimerview.cpp	Mon Feb 27 23:59:10 2012 -0800
    46.3 @@ -79,9 +79,14 @@
    46.4  {
    46.5  	{ LLFastTimer::FTM_FRAME,				"Frame",				&LLColor4::white, 0 },
    46.6  	{ LLFastTimer::FTM_MESSAGES,			" System Messages",		&LLColor4::grey1, 1 },
    46.7 -	{ LLFastTimer::FTM_MOUSEHANDLER,		"  Mouse",				&LLColor4::grey1, 0 },
    46.8 -	{ LLFastTimer::FTM_KEYHANDLER,			"  Keyboard",			&LLColor4::grey1, 0 },
    46.9 -	{ LLFastTimer::FTM_SLEEP,				" Sleep & BG Threads",	&LLColor4::grey2, 1 },
   46.10 +	{ LLFastTimer::FTM_MOUSEHANDLER,		"  Mouse",				&LLColor4::grey2, 0 },
   46.11 +	{ LLFastTimer::FTM_KEYHANDLER,			"  Keyboard",			&LLColor4::grey4, 0 },
   46.12 +	{ LLFastTimer::FTM_SLEEP,				" Sleep & BG Threads",	&LLColor4::yellow1, 1 },
   46.13 +	{ LLFastTimer::FTM_FETCH,				"  Texture Fetch",		&LLColor4::yellow5, 0 },
   46.14 +	{ LLFastTimer::FTM_TEXTURE_CACHE,		"  Texture Cache",		&LLColor4::yellow3, 0 },
   46.15 +	{ LLFastTimer::FTM_DECODE,				"  Texture Decode",		&LLColor4::yellow7, 0 },
   46.16 +	{ LLFastTimer::FTM_VFS,					"  VFS Thread",			&LLColor4::yellow4, 0 },
   46.17 +	{ LLFastTimer::FTM_LFS,					"  LFS Thread",			&LLColor4::yellow6, 0 },
   46.18  	{ LLFastTimer::FTM_IDLE,				" Idle",				&blue0, 0 },
   46.19  	{ LLFastTimer::FTM_PUMP,				"  Pump",				&LLColor4::magenta2, 1 },
   46.20  	{ LLFastTimer::FTM_ARES,				"   Ares",				&LLColor4::magenta4, 0 },
   46.21 @@ -157,7 +162,8 @@
   46.22  	{ LLFastTimer::FTM_FRUSTUM_CULL,		"   Frustum Cull",		&LLColor4::blue4, 0 },
   46.23  	{ LLFastTimer::FTM_OCCLUSION_EARLY_FAIL,"    Occl. Early Fail",	&LLColor4::blue1, 0 },
   46.24  
   46.25 -	{ LLFastTimer::FTM_OCCLUSION_READBACK,	"   Occlusion Read", &LLColor4::red2, 0 },
   46.26 +	{ LLFastTimer::FTM_OCCLUSION_WAIT,		"   Occlusion Wait",	&LLColor4::red1, 0 },
   46.27 +	{ LLFastTimer::FTM_OCCLUSION_READBACK,	"   Occlusion Read",	&LLColor4::red2, 0 },
   46.28  	{ LLFastTimer::FTM_BUILD_OCCLUSION,		"   Occlusion Build",	&LLColor4::red3, 0 },
   46.29  	{ LLFastTimer::FTM_PUSH_OCCLUSION_VERTS,"   Occlusion Push",	&LLColor4::red4, 0 },
   46.30  	{ LLFastTimer::FTM_SET_OCCLUSION_STATE,	"   Occlusion State",	&LLColor4::orange1, 0 },
   46.31 @@ -207,6 +213,7 @@
   46.32  	{ LLFastTimer::FTM_RENDER_TERRAIN,		"     Terrain",			&LLColor4::green6, 0 },
   46.33  	{ LLFastTimer::FTM_AVATAR_FACE,			"     Avatar Face",		&LLColor4::yellow1, 0 },
   46.34  	{ LLFastTimer::FTM_RENDER_CHARACTERS,	"     Avatars",			&LLColor4::yellow2, 0 },
   46.35 +	{ LLFastTimer::FTM_SKIN_RIGGED_DEFORM,	"      Rigged Deform",	&LLColor4::yellow3, 0 },
   46.36  	{ LLFastTimer::FTM_RENDER_SIMPLE,		"     Simple",			&LLColor4::yellow4, 0 },
   46.37  	{ LLFastTimer::FTM_RENDER_FULLBRIGHT,	"     Fullbright",		&LLColor4::yellow5, 0 },
   46.38  	{ LLFastTimer::FTM_RENDER_GLOW,			"     Glow",			&LLColor4::orange1, 0 },
    47.1 --- a/indra/newview/llfloatercustomize.cpp	Mon Feb 27 23:28:58 2012 -0800
    47.2 +++ b/indra/newview/llfloatercustomize.cpp	Mon Feb 27 23:59:10 2012 -0800
    47.3 @@ -158,12 +158,12 @@
    47.4  
    47.5  ////////////////////////////////////////////////////////////////////////////
    47.6  
    47.7 -BOOL edit_wearable_for_teens(EWearableType type)
    47.8 +BOOL edit_wearable_for_teens(LLWearableType::EType type)
    47.9  {
   47.10  	switch(type)
   47.11  	{
   47.12 -	case WT_UNDERSHIRT:
   47.13 -	case WT_UNDERPANTS:
   47.14 +		case LLWearableType::WT_UNDERSHIRT:
   47.15 +		case LLWearableType::WT_UNDERPANTS:
   47.16  		return FALSE;
   47.17  	default:
   47.18  		return TRUE;
   47.19 @@ -187,16 +187,16 @@
   47.20  		LLUICtrlFactory::getInstance()->buildFloater(this, "floater_new_outfit_dialog.xml");
   47.21  		
   47.22  		// Build list of check boxes
   47.23 -		for( S32 i = 0; i < WT_COUNT; i++ )
   47.24 +		for( S32 i = 0; i < LLWearableType::WT_COUNT; i++ )
   47.25  		{
   47.26 -			std::string name = std::string("checkbox_") + LLWearable::typeToTypeLabel( (EWearableType)i );
   47.27 +			std::string name = std::string("checkbox_") + LLWearableType::getTypeLabel( (LLWearableType::EType)i );
   47.28  			mCheckBoxList.push_back(std::make_pair(name,i));
   47.29  			// Hide teen items
   47.30  			if (gAgent.isTeen() &&
   47.31 -				!edit_wearable_for_teens((EWearableType)i))
   47.32 +				!edit_wearable_for_teens((LLWearableType::EType)i))
   47.33  			{
   47.34  				// hide wearable checkboxes that don't apply to this account
   47.35 -				std::string name = std::string("checkbox_") + LLWearable::typeToTypeLabel( (EWearableType)i );
   47.36 +				std::string name = std::string("checkbox_") + LLWearableType::getTypeLabel( (LLWearableType::EType)i );
   47.37  				childSetVisible(name, FALSE);
   47.38  			}
   47.39  			else //KC: Check all by default
   47.40 @@ -262,11 +262,11 @@
   47.41  
   47.42  	void setWearableToInclude( S32 wearable, S32 enabled, S32 selected )
   47.43  	{
   47.44 -		EWearableType wtType = (EWearableType)wearable;
   47.45 -		if ( ( (0 <= wtType) && (wtType < WT_COUNT) ) && 
   47.46 -			 ( (LLAssetType::AT_BODYPART != LLWearable::typeToAssetType(wtType)) || (!gSavedSettings.getBOOL("UseOutfitFolders")) ) )
   47.47 +		LLWearableType::EType wtType = (LLWearableType::EType)wearable;
   47.48 +		if ( ( (0 <= wtType) && (wtType < LLWearableType::WT_COUNT) ) && 
   47.49 +			 ( (LLAssetType::AT_BODYPART != LLWearableType::getAssetType(wtType)) || (!gSavedSettings.getBOOL("UseOutfitFolders")) ) )
   47.50  		{
   47.51 -			std::string name = std::string("checkbox_") + LLWearable::typeToTypeLabel(wtType);
   47.52 +			std::string name = std::string("checkbox_") + LLWearableType::getTypeLabel(wtType);
   47.53  			childSetEnabled(name, enabled);
   47.54  			childSetValue(name, selected);
   47.55  		}
   47.56 @@ -278,7 +278,7 @@
   47.57  		{
   47.58  			std::string name = mCheckBoxList[i].first;
   47.59  			BOOL checked = childGetValue(name).asBoolean();
   47.60 -			if (i < WT_COUNT )
   47.61 +			if (i < LLWearableType::WT_COUNT )
   47.62  			{
   47.63  				if( checked )
   47.64  				{
   47.65 @@ -352,12 +352,12 @@
   47.66  	{
   47.67  		BOOL fUseOutfits = gSavedSettings.getBOOL("UseOutfitFolders");
   47.68  
   47.69 -		for (S32 idxType = 0; idxType < WT_COUNT; idxType++ )
   47.70 +		for (S32 idxType = 0; idxType < LLWearableType::WT_COUNT; idxType++ )
   47.71  		{
   47.72 -			EWearableType wtType = (EWearableType)idxType;
   47.73 -			if (LLAssetType::AT_BODYPART != LLWearable::typeToAssetType(wtType))
   47.74 +			LLWearableType::EType wtType = (LLWearableType::EType)idxType;
   47.75 +			if (LLAssetType::AT_BODYPART != LLWearableType::getAssetType(wtType))
   47.76  				continue;
   47.77 -			LLCheckBoxCtrl* pCheckCtrl = getChild<LLCheckBoxCtrl>(std::string("checkbox_") + LLWearable::typeToTypeLabel(wtType));
   47.78 +			LLCheckBoxCtrl* pCheckCtrl = getChild<LLCheckBoxCtrl>(std::string("checkbox_") + LLWearableType::getTypeLabel(wtType));
   47.79  			if (!pCheckCtrl)
   47.80  				continue;
   47.81  
   47.82 @@ -438,7 +438,7 @@
   47.83  class LLPanelEditWearable : public LLPanel
   47.84  {
   47.85  public:
   47.86 -	LLPanelEditWearable( EWearableType type );
   47.87 +	LLPanelEditWearable(LLWearableType::EType type);
   47.88  	virtual ~LLPanelEditWearable();
   47.89  
   47.90  	virtual BOOL 		postBuild();
   47.91 @@ -450,8 +450,8 @@
   47.92  	void				addInvisibilityCheckbox(ETextureIndex te, const std::string& name);
   47.93  	void				addColorSwatch( ETextureIndex te, const std::string& name );
   47.94  
   47.95 -	const std::string&	getLabel()	{ return LLWearable::typeToTypeLabel( mType ); }
   47.96 -	EWearableType		getType()	{ return mType; }
   47.97 +	const std::string&		getLabel()	{ return LLWearableType::getTypeLabel(mType); }
   47.98 +	LLWearableType::EType	getType()	{ return mType; }
   47.99  
  47.100  	LLSubpart*			getCurrentSubpart() { return mSubpartList[mCurrentSubpart]; }
  47.101  	ESubpart			getDefaultSubpart();
  47.102 @@ -489,27 +489,27 @@
  47.103  
  47.104  
  47.105  private:
  47.106 -	EWearableType		mType;
  47.107 -	BOOL				mCanTakeOff;
  47.108 -	std::map<std::string, S32> mTextureList;
  47.109 -	std::map<std::string, S32> mInvisibilityList;
  47.110 -	std::map<std::string, S32> mColorList;
  47.111 -	std::map<ESubpart, LLSubpart*> mSubpartList;
  47.112 -	std::map<S32, LLUUID> mPreviousTextureList;
  47.113 -	ESubpart			mCurrentSubpart;
  47.114 +	LLWearableType::EType			mType;
  47.115 +	BOOL							mCanTakeOff;
  47.116 +	std::map<std::string, S32>		mTextureList;
  47.117 +	std::map<std::string, S32>		mInvisibilityList;
  47.118 +	std::map<std::string, S32>		mColorList;
  47.119 +	std::map<ESubpart, LLSubpart*>	mSubpartList;
  47.120 +	std::map<S32, LLUUID>			mPreviousTextureList;
  47.121 +	ESubpart						mCurrentSubpart;
  47.122  };
  47.123  
  47.124  ////////////////////////////////////////////////////////////////////////////
  47.125  
  47.126 -LLPanelEditWearable::LLPanelEditWearable( EWearableType type )
  47.127 -	: LLPanel( LLWearable::typeToTypeLabel( type ) ),
  47.128 +LLPanelEditWearable::LLPanelEditWearable(LLWearableType::EType type)
  47.129 +	: LLPanel(LLWearableType::getTypeLabel(type)),
  47.130  	  mType( type )
  47.131  {
  47.132  }
  47.133  
  47.134  BOOL LLPanelEditWearable::postBuild()
  47.135  {
  47.136 -	LLAssetType::EType asset_type = LLWearable::typeToAssetType( mType );
  47.137 +	LLAssetType::EType asset_type = LLWearableType::getAssetType(mType);
  47.138  	std::string icon_name = LLInventoryIcon::getIconName(asset_type,
  47.139  														 LLInventoryType::IT_WEARABLE,
  47.140  														 mType, FALSE);
  47.141 @@ -519,9 +519,10 @@
  47.142  	childSetAction("Create New", LLPanelEditWearable::onBtnCreateNew, this );
  47.143  
  47.144  	// If PG, can't take off underclothing or shirt
  47.145 -	mCanTakeOff =
  47.146 -		LLWearable::typeToAssetType( mType ) == LLAssetType::AT_CLOTHING &&
  47.147 -		!( gAgent.isTeen() && (mType == WT_UNDERSHIRT || mType == WT_UNDERPANTS) );
  47.148 +	mCanTakeOff = LLWearableType::getAssetType(mType) == LLAssetType::AT_CLOTHING &&
  47.149 +				  !(gAgent.isTeen() &&
  47.150 +					(mType == LLWearableType::WT_UNDERSHIRT ||
  47.151 +					 mType == LLWearableType::WT_UNDERPANTS));
  47.152  	childSetVisible("Take Off", mCanTakeOff);
  47.153  	childSetAction("Take Off", LLPanelEditWearable::onBtnTakeOff, this );
  47.154  
  47.155 @@ -596,7 +597,7 @@
  47.156  		if(item)
  47.157  		{
  47.158  			perm_mask = item->getPermissions().getMaskOwner();
  47.159 -			is_complete = item->isComplete();
  47.160 +			is_complete = item->isFinished();
  47.161  		}
  47.162  		setUIPermissions(perm_mask, is_complete);
  47.163  		BOOL editable = ((perm_mask & PERM_MODIFY) && is_complete) ? TRUE : FALSE;
  47.164 @@ -703,7 +704,7 @@
  47.165  	if(avatar)
  47.166  	{
  47.167  		// Create a new wearable in the default folder for the wearable's asset type.
  47.168 -		LLWearable* wearable = gWearableList.createNewWearable( (EWearableType)notification["payload"]["wearable_type"].asInteger() );
  47.169 +		LLWearable* wearable = gWearableList.createNewWearable((LLWearableType::EType)notification["payload"]["wearable_type"].asInteger());
  47.170  		LLAssetType::EType asset_type = wearable->getAssetType();
  47.171  
  47.172  		LLUUID folder_id;
  47.173 @@ -860,7 +861,7 @@
  47.174  	if (avatar)
  47.175  	{
  47.176  		LLWearable* wearable = gAgent.getWearable(mType);
  47.177 -		if (wearable && mType == WT_ALPHA)
  47.178 +		if (wearable && mType == LLWearableType::WT_ALPHA)
  47.179  		{
  47.180  			const LLTextureEntry* current_te = avatar->getTE(te);
  47.181  			if (current_te)
  47.182 @@ -894,7 +895,7 @@
  47.183  			avatar->setLocTexTE(te, image, TRUE);
  47.184  			avatar->wearableUpdated(self->mType, FALSE);
  47.185  		}
  47.186 -		if (self->mType == WT_ALPHA && image->getID() != IMG_INVISIBLE)
  47.187 +		if (self->mType == LLWearableType::WT_ALPHA && image->getID() != IMG_INVISIBLE)
  47.188  		{
  47.189  			self->mPreviousTextureList[te] = image->getID();
  47.190  		}
  47.191 @@ -906,22 +907,22 @@
  47.192  {
  47.193  	switch( mType )
  47.194  	{
  47.195 -		case WT_SHAPE:		return SUBPART_SHAPE_WHOLE;
  47.196 -		case WT_SKIN:		return SUBPART_SKIN_COLOR;
  47.197 -		case WT_HAIR:		return SUBPART_HAIR_COLOR;
  47.198 -		case WT_EYES:		return SUBPART_EYES;
  47.199 -		case WT_SHIRT:		return SUBPART_SHIRT;
  47.200 -		case WT_PANTS:		return SUBPART_PANTS;
  47.201 -		case WT_SHOES:		return SUBPART_SHOES;
  47.202 -		case WT_SOCKS:		return SUBPART_SOCKS;
  47.203 -		case WT_JACKET:		return SUBPART_JACKET;
  47.204 -		case WT_GLOVES:		return SUBPART_GLOVES;
  47.205 -		case WT_UNDERSHIRT:	return SUBPART_UNDERSHIRT;
  47.206 -		case WT_UNDERPANTS:	return SUBPART_UNDERPANTS;
  47.207 -		case WT_SKIRT:		return SUBPART_SKIRT;
  47.208 -		case WT_ALPHA:		return SUBPART_ALPHA;
  47.209 -		case WT_TATTOO:		return SUBPART_TATTOO;
  47.210 -		case WT_PHYSICS:  return SUBPART_PHYSICS_BELLY_UPDOWN;
  47.211 +		case LLWearableType::WT_SHAPE:		return SUBPART_SHAPE_WHOLE;
  47.212 +		case LLWearableType::WT_SKIN:		return SUBPART_SKIN_COLOR;
  47.213 +		case LLWearableType::WT_HAIR:		return SUBPART_HAIR_COLOR;
  47.214 +		case LLWearableType::WT_EYES:		return SUBPART_EYES;
  47.215 +		case LLWearableType::WT_SHIRT:		return SUBPART_SHIRT;
  47.216 +		case LLWearableType::WT_PANTS:		return SUBPART_PANTS;
  47.217 +		case LLWearableType::WT_SHOES:		return SUBPART_SHOES;
  47.218 +		case LLWearableType::WT_SOCKS:		return SUBPART_SOCKS;
  47.219 +		case LLWearableType::WT_JACKET:		return SUBPART_JACKET;
  47.220 +		case LLWearableType::WT_GLOVES:		return SUBPART_GLOVES;
  47.221 +		case LLWearableType::WT_UNDERSHIRT:	return SUBPART_UNDERSHIRT;
  47.222 +		case LLWearableType::WT_UNDERPANTS:	return SUBPART_UNDERPANTS;
  47.223 +		case LLWearableType::WT_SKIRT:		return SUBPART_SKIRT;
  47.224 +		case LLWearableType::WT_ALPHA:		return SUBPART_ALPHA;
  47.225 +		case LLWearableType::WT_TATTOO:		return SUBPART_TATTOO;
  47.226 +		case LLWearableType::WT_PHYSICS:	return SUBPART_PHYSICS_BELLY_UPDOWN;
  47.227  
  47.228  		default:	llassert(0);		return SUBPART_SHAPE_WHOLE;
  47.229  	}
  47.230 @@ -954,7 +955,7 @@
  47.231  		const LLPermissions& perm = item->getPermissions();
  47.232  		is_modifiable = perm.allowModifyBy(gAgent.getID(), gAgent.getGroupID());
  47.233  		is_copyable = perm.allowCopyBy(gAgent.getID(), gAgent.getGroupID());
  47.234 -		is_complete = item->isComplete();
  47.235 +		is_complete = item->isFinished();
  47.236  	}
  47.237  
  47.238  	childSetEnabled("Save", is_modifiable && is_complete && has_wearable && is_dirty);
  47.239 @@ -1013,7 +1014,7 @@
  47.240  	{
  47.241  		// *TODO:Translate
  47.242  		childSetVisible("title_no_modify", TRUE);
  47.243 -		childSetTextArg("title_no_modify", "[DESC]", std::string(LLWearable::typeToTypeLabel( mType )));
  47.244 +		childSetTextArg("title_no_modify", "[DESC]", std::string(LLWearableType::getTypeLabel(mType)));
  47.245  		
  47.246  		hideTextureControls();
  47.247  	}
  47.248 @@ -1021,7 +1022,7 @@
  47.249  	{
  47.250  		// *TODO:Translate
  47.251  		childSetVisible("title_loading", TRUE);
  47.252 -		childSetTextArg("title_loading", "[DESC]", std::string(LLWearable::typeToTypeLabel( mType )));
  47.253 +		childSetTextArg("title_loading", "[DESC]", std::string(LLWearableType::getTypeLabel(mType)));
  47.254  			
  47.255  		std::string path;
  47.256  		const LLUUID& item_id = gAgent.getWearableItem( wearable->getType() );
  47.257 @@ -1108,7 +1109,7 @@
  47.258  	{
  47.259  		// *TODO:Translate
  47.260  		childSetVisible("title_not_worn", TRUE);
  47.261 -		childSetTextArg("title_not_worn", "[DESC]", std::string(LLWearable::typeToTypeLabel( mType )));
  47.262 +		childSetTextArg("title_not_worn", "[DESC]", std::string(LLWearableType::getTypeLabel(mType)));
  47.263  
  47.264  		hideTextureControls();
  47.265  	}
  47.266 @@ -1142,7 +1143,7 @@
  47.267  	if( wearable )
  47.268  	{
  47.269  		setUIPermissions(perm_mask, is_complete);
  47.270 -		if (mType == WT_ALPHA)
  47.271 +		if (mType == LLWearableType::WT_ALPHA)
  47.272  		{
  47.273  			initPreviousTextureList();
  47.274  		}
  47.275 @@ -1676,14 +1677,14 @@
  47.276  // LLFloaterCustomize
  47.277  
  47.278  // statics
  47.279 -EWearableType	LLFloaterCustomize::sCurrentWearableType = WT_INVALID;
  47.280 +LLWearableType::EType LLFloaterCustomize::sCurrentWearableType = LLWearableType::WT_INVALID;
  47.281  
  47.282  struct WearablePanelData
  47.283  {
  47.284 -	WearablePanelData(LLFloaterCustomize* floater, EWearableType type)
  47.285 +	WearablePanelData(LLFloaterCustomize* floater, LLWearableType::EType type)
  47.286  		: mFloater(floater), mType(type) {}
  47.287  	LLFloaterCustomize* mFloater;
  47.288 -	EWearableType mType;
  47.289 +	LLWearableType::EType mType;
  47.290  };
  47.291  
  47.292  LLFloaterCustomize::LLFloaterCustomize()
  47.293 @@ -1693,7 +1694,7 @@
  47.294  	mNextStepAfterSaveCallback( NULL ),
  47.295  	mNextStepAfterSaveUserdata( NULL )
  47.296  {
  47.297 -	memset(&mWearablePanelList[0],0,sizeof(char*)*WT_COUNT); //Initialize to 0
  47.298 +	memset(&mWearablePanelList[0], 0, sizeof(char*)*LLWearableType::WT_COUNT); //Initialize to 0
  47.299  
  47.300  	gSavedSettings.setU32("AvatarSex", (gAgent.getAvatarObject()->getSex() == SEX_MALE) );
  47.301  
  47.302 @@ -1704,22 +1705,22 @@
  47.303  	gInventory.addObserver(mInventoryObserver);
  47.304  
  47.305  	LLCallbackMap::map_t factory_map;
  47.306 -	factory_map["Shape"] = LLCallbackMap(createWearablePanel, (void*)(new WearablePanelData(this, WT_SHAPE) ) );
  47.307 -	factory_map["Skin"] = LLCallbackMap(createWearablePanel, (void*)(new WearablePanelData(this, WT_SKIN) ) );
  47.308 -	factory_map["Hair"] = LLCallbackMap(createWearablePanel, (void*)(new WearablePanelData(this, WT_HAIR) ) );
  47.309 -	factory_map["Eyes"] = LLCallbackMap(createWearablePanel, (void*)(new WearablePanelData(this, WT_EYES) ) );
  47.310 -	factory_map["Shirt"] = LLCallbackMap(createWearablePanel, (void*)(new WearablePanelData(this, WT_SHIRT) ) );
  47.311 -	factory_map["Pants"] = LLCallbackMap(createWearablePanel, (void*)(new WearablePanelData(this, WT_PANTS) ) );
  47.312 -	factory_map["Shoes"] = LLCallbackMap(createWearablePanel, (void*)(new WearablePanelData(this, WT_SHOES) ) );
  47.313 -	factory_map["Socks"] = LLCallbackMap(createWearablePanel, (void*)(new WearablePanelData(this, WT_SOCKS) ) );
  47.314 -	factory_map["Jacket"] = LLCallbackMap(createWearablePanel, (void*)(new WearablePanelData(this, WT_JACKET) ) );
  47.315 -	factory_map["Gloves"] = LLCallbackMap(createWearablePanel, (void*)(new WearablePanelData(this, WT_GLOVES) ) );
  47.316 -	factory_map["Undershirt"] = LLCallbackMap(createWearablePanel, (void*)(new WearablePanelData(this, WT_UNDERSHIRT) ) );
  47.317 -	factory_map["Underpants"] = LLCallbackMap(createWearablePanel, (void*)(new WearablePanelData(this, WT_UNDERPANTS) ) );
  47.318 -	factory_map["Skirt"] = LLCallbackMap(createWearablePanel, (void*)(new WearablePanelData(this, WT_SKIRT) ) );
  47.319 -	factory_map["Alpha"] = LLCallbackMap(createWearablePanel, (void*)(new WearablePanelData(this, WT_ALPHA)));
  47.320 -	factory_map["Tattoo"] = LLCallbackMap(createWearablePanel, (void*)(new WearablePanelData(this, WT_TATTOO)));
  47.321 -	factory_map["Physics"] = LLCallbackMap(createWearablePanel, (void*)(new WearablePanelData(this, WT_PHYSICS)));
  47.322 +	factory_map["Shape"] = LLCallbackMap(createWearablePanel, (void*)(new WearablePanelData(this, LLWearableType::WT_SHAPE)));
  47.323 +	factory_map["Skin"] = LLCallbackMap(createWearablePanel, (void*)(new WearablePanelData(this, LLWearableType::WT_SKIN)));
  47.324 +	factory_map["Hair"] = LLCallbackMap(createWearablePanel, (void*)(new WearablePanelData(this, LLWearableType::WT_HAIR)));
  47.325 +	factory_map["Eyes"] = LLCallbackMap(createWearablePanel, (void*)(new WearablePanelData(this, LLWearableType::WT_EYES)));
  47.326 +	factory_map["Shirt"] = LLCallbackMap(createWearablePanel, (void*)(new WearablePanelData(this, LLWearableType::WT_SHIRT)));
  47.327 +	factory_map["Pants"] = LLCallbackMap(createWearablePanel, (void*)(new WearablePanelData(this, LLWearableType::WT_PANTS)));
  47.328 +	factory_map["Shoes"] = LLCallbackMap(createWearablePanel, (void*)(new WearablePanelData(this, LLWearableType::WT_SHOES)));
  47.329 +	factory_map["Socks"] = LLCallbackMap(createWearablePanel, (void*)(new WearablePanelData(this, LLWearableType::WT_SOCKS)));
  47.330 +	factory_map["Jacket"] = LLCallbackMap(createWearablePanel, (void*)(new WearablePanelData(this, LLWearableType::WT_JACKET)));
  47.331 +	factory_map["Gloves"] = LLCallbackMap(createWearablePanel, (void*)(new WearablePanelData(this, LLWearableType::WT_GLOVES)));
  47.332 +	factory_map["Undershirt"] = LLCallbackMap(createWearablePanel, (void*)(new WearablePanelData(this, LLWearableType::WT_UNDERSHIRT)));
  47.333 +	factory_map["Underpants"] = LLCallbackMap(createWearablePanel, (void*)(new WearablePanelData(this, LLWearableType::WT_UNDERPANTS)));
  47.334 +	factory_map["Skirt"] = LLCallbackMap(createWearablePanel, (void*)(new WearablePanelData(this, LLWearableType::WT_SKIRT)));
  47.335 +	factory_map["Alpha"] = LLCallbackMap(createWearablePanel, (void*)(new WearablePanelData(this, LLWearableType::WT_ALPHA)));
  47.336 +	factory_map["Tattoo"] = LLCallbackMap(createWearablePanel, (void*)(new WearablePanelData(this, LLWearableType::WT_TATTOO)));
  47.337 +	factory_map["Physics"] = LLCallbackMap(createWearablePanel, (void*)(new WearablePanelData(this, LLWearableType::WT_PHYSICS)));
  47.338  
  47.339  	LLUICtrlFactory::getInstance()->buildFloater(this, "floater_customize.xml", &factory_map);
  47.340  }
  47.341 @@ -1744,22 +1745,22 @@
  47.342  	initWearablePanels();
  47.343  
  47.344  	// Tab container
  47.345 -	childSetTabChangeCallback("customize tab container", "Shape", onTabChanged, (void*)WT_SHAPE, onTabPrecommit );
  47.346 -	childSetTabChangeCallback("customize tab container", "Skin", onTabChanged, (void*)WT_SKIN, onTabPrecommit );
  47.347 -	childSetTabChangeCallback("customize tab container", "Hair", onTabChanged, (void*)WT_HAIR, onTabPrecommit );
  47.348 -	childSetTabChangeCallback("customize tab container", "Eyes", onTabChanged, (void*)WT_EYES, onTabPrecommit );
  47.349 -	childSetTabChangeCallback("customize tab container", "Shirt", onTabChanged, (void*)WT_SHIRT, onTabPrecommit );
  47.350 -	childSetTabChangeCallback("customize tab container", "Pants", onTabChanged, (void*)WT_PANTS, onTabPrecommit );
  47.351 -	childSetTabChangeCallback("customize tab container", "Shoes", onTabChanged, (void*)WT_SHOES, onTabPrecommit );
  47.352 -	childSetTabChangeCallback("customize tab container", "Socks", onTabChanged, (void*)WT_SOCKS, onTabPrecommit );
  47.353 -	childSetTabChangeCallback("customize tab container", "Jacket", onTabChanged, (void*)WT_JACKET, onTabPrecommit );
  47.354 -	childSetTabChangeCallback("customize tab container", "Gloves", onTabChanged, (void*)WT_GLOVES, onTabPrecommit );
  47.355 -	childSetTabChangeCallback("customize tab container", "Undershirt", onTabChanged, (void*)WT_UNDERSHIRT, onTabPrecommit );
  47.356 -	childSetTabChangeCallback("customize tab container", "Underpants", onTabChanged, (void*)WT_UNDERPANTS, onTabPrecommit );
  47.357 -	childSetTabChangeCallback("customize tab container", "Skirt", onTabChanged, (void*)WT_SKIRT, onTabPrecommit );
  47.358 -	childSetTabChangeCallback("customize tab container", "Alpha", onTabChanged, (void*)WT_ALPHA, onTabPrecommit);
  47.359 -	childSetTabChangeCallback("customize tab container", "Tattoo", onTabChanged, (void*)WT_TATTOO, onTabPrecommit);
  47.360 -	childSetTabChangeCallback("customize tab container", "Physics", onTabChanged, (void*)WT_PHYSICS, onTabPrecommit);
  47.361 +	childSetTabChangeCallback("customize tab container", "Shape", onTabChanged, (void*)LLWearableType::WT_SHAPE, onTabPrecommit);
  47.362 +	childSetTabChangeCallback("customize tab container", "Skin", onTabChanged, (void*)LLWearableType::WT_SKIN, onTabPrecommit);
  47.363 +	childSetTabChangeCallback("customize tab container", "Hair", onTabChanged, (void*)LLWearableType::WT_HAIR, onTabPrecommit);
  47.364 +	childSetTabChangeCallback("customize tab container", "Eyes", onTabChanged, (void*)LLWearableType::WT_EYES, onTabPrecommit);
  47.365 +	childSetTabChangeCallback("customize tab container", "Shirt", onTabChanged, (void*)LLWearableType::WT_SHIRT, onTabPrecommit);
  47.366 +	childSetTabChangeCallback("customize tab container", "Pants", onTabChanged, (void*)LLWearableType::WT_PANTS, onTabPrecommit);
  47.367 +	childSetTabChangeCallback("customize tab container", "Shoes", onTabChanged, (void*)LLWearableType::WT_SHOES, onTabPrecommit);
  47.368 +	childSetTabChangeCallback("customize tab container", "Socks", onTabChanged, (void*)LLWearableType::WT_SOCKS, onTabPrecommit);
  47.369 +	childSetTabChangeCallback("customize tab container", "Jacket", onTabChanged, (void*)LLWearableType::WT_JACKET, onTabPrecommit);
  47.370 +	childSetTabChangeCallback("customize tab container", "Gloves", onTabChanged, (void*)LLWearableType::WT_GLOVES, onTabPrecommit);
  47.371 +	childSetTabChangeCallback("customize tab container", "Undershirt", onTabChanged, (void*)LLWearableType::WT_UNDERSHIRT, onTabPrecommit);
  47.372 +	childSetTabChangeCallback("customize tab container", "Underpants", onTabChanged, (void*)LLWearableType::WT_UNDERPANTS, onTabPrecommit);
  47.373 +	childSetTabChangeCallback("customize tab container", "Skirt", onTabChanged, (void*)LLWearableType::WT_SKIRT, onTabPrecommit);
  47.374 +	childSetTabChangeCallback("customize tab container", "Alpha", onTabChanged, (void*)LLWearableType::WT_ALPHA, onTabPrecommit);
  47.375 +	childSetTabChangeCallback("customize tab container", "Tattoo", onTabChanged, (void*)LLWearableType::WT_TATTOO, onTabPrecommit);
  47.376 +	childSetTabChangeCallback("customize tab container", "Physics", onTabChanged, (void*)LLWearableType::WT_PHYSICS, onTabPrecommit);
  47.377  
  47.378  	// Remove underwear panels for teens
  47.379  	if (gAgent.isTeen())
  47.380 @@ -1786,13 +1787,13 @@
  47.381  	LLFloater::open();
  47.382  	// childShowTab depends on gFloaterCustomize being defined and therefore must be called after the constructor. - Nyx
  47.383  	childShowTab("customize tab container", "Shape", true);
  47.384 -	setCurrentWearableType(WT_SHAPE);
  47.385 +	setCurrentWearableType(LLWearableType::WT_SHAPE);
  47.386  }
  47.387  
  47.388  ////////////////////////////////////////////////////////////////////////////
  47.389  
  47.390  // static
  47.391 -void LLFloaterCustomize::setCurrentWearableType( EWearableType type )
  47.392 +void LLFloaterCustomize::setCurrentWearableType(LLWearableType::EType type)
  47.393  {
  47.394  	if( LLFloaterCustomize::sCurrentWearableType != type )
  47.395  	{
  47.396 @@ -1838,12 +1839,12 @@
  47.397  		LLMakeOutfitDialog* dialog = new LLMakeOutfitDialog( onMakeOutfitCommit, NULL );
  47.398  		// LLMakeOutfitDialog deletes itself.
  47.399  
  47.400 -		for( S32 i = 0; i < WT_COUNT; i++ )
  47.401 +		for( S32 i = 0; i < LLWearableType::WT_COUNT; i++ )
  47.402  		{
  47.403 -			BOOL enabled = (gAgent.getWearable( (EWearableType) i ) != NULL);
  47.404 -			BOOL selected = (enabled && (WT_SHIRT <= i) && (i < WT_COUNT)); // only select clothing by default
  47.405 +			BOOL enabled = (gAgent.getWearable( (LLWearableType::EType) i ) != NULL);
  47.406 +			BOOL selected = (enabled && (LLWearableType::WT_SHIRT <= i) && (i < LLWearableType::WT_COUNT)); // only select clothing by default
  47.407  			if (gAgent.isTeen()
  47.408 -				&& !edit_wearable_for_teens((EWearableType)i))
  47.409 +				&& !edit_wearable_for_teens((LLWearableType::EType)i))
  47.410  			{
  47.411  				dialog->setWearableToInclude( i, FALSE, FALSE );
  47.412  			}
  47.413 @@ -1877,7 +1878,7 @@
  47.414  void* LLFloaterCustomize::createWearablePanel(void* userdata)
  47.415  {
  47.416  	WearablePanelData* data = (WearablePanelData*)userdata;
  47.417 -	EWearableType type = data->mType;
  47.418 +	LLWearableType::EType type = data->mType;
  47.419  	LLPanelEditWearable* panel;
  47.420  	if ((gAgent.isTeen() && !edit_wearable_for_teens(data->mType) ))
  47.421  	{
  47.422 @@ -1898,7 +1899,7 @@
  47.423  	
  47.424  	/////////////////////////////////////////
  47.425  	// Shape
  47.426 -	LLPanelEditWearable* panel = mWearablePanelList[ WT_SHAPE ];
  47.427 +	LLPanelEditWearable* panel = mWearablePanelList[LLWearableType::WT_SHAPE];
  47.428  
  47.429  	// body
  47.430  	part = new LLSubpart();
  47.431 @@ -1973,7 +1974,7 @@
  47.432  
  47.433  	/////////////////////////////////////////
  47.434  	// Skin
  47.435 -	panel = mWearablePanelList[ WT_SKIN ];
  47.436 +	panel = mWearablePanelList[LLWearableType::WT_SKIN];
  47.437  
  47.438  	part = new LLSubpart();
  47.439  	part->mTargetJoint = "mHead";
  47.440 @@ -2009,7 +2010,7 @@
  47.441  
  47.442  	/////////////////////////////////////////
  47.443  	// Hair
  47.444 -	panel = mWearablePanelList[ WT_HAIR ];
  47.445 +	panel = mWearablePanelList[LLWearableType::WT_HAIR];
  47.446  
  47.447  	part = new LLSubpart();
  47.448  	part->mTargetJoint = "mHead";
  47.449 @@ -2046,7 +2047,7 @@
  47.450  
  47.451  	/////////////////////////////////////////
  47.452  	// Eyes
  47.453 -	panel = mWearablePanelList[ WT_EYES ];
  47.454 +	panel = mWearablePanelList[LLWearableType::WT_EYES];
  47.455  
  47.456  	part = new LLSubpart();
  47.457  	part->mTargetJoint = "mHead";
  47.458 @@ -2061,7 +2062,7 @@
  47.459  
  47.460  	/////////////////////////////////////////
  47.461  	// Shirt
  47.462 -	panel = mWearablePanelList[ WT_SHIRT ];
  47.463 +	panel = mWearablePanelList[LLWearableType::WT_SHIRT];
  47.464  
  47.465  	part = new LLSubpart();
  47.466  	part->mTargetJoint = "mTorso";
  47.467 @@ -2079,7 +2080,7 @@
  47.468  
  47.469  	/////////////////////////////////////////
  47.470  	// Pants
  47.471 -	panel = mWearablePanelList[ WT_PANTS ];
  47.472 +	panel = mWearablePanelList[LLWearableType::WT_PANTS];
  47.473  
  47.474  	part = new LLSubpart();
  47.475  	part->mTargetJoint = "mPelvis";
  47.476 @@ -2097,7 +2098,7 @@
  47.477  
  47.478  	/////////////////////////////////////////
  47.479  	// Shoes
  47.480 -	panel = mWearablePanelList[ WT_SHOES ];
  47.481 +	panel = mWearablePanelList[LLWearableType::WT_SHOES];
  47.482  
  47.483  	if (panel)
  47.484  	{
  47.485 @@ -2118,7 +2119,7 @@
  47.486  
  47.487  	/////////////////////////////////////////
  47.488  	// Socks
  47.489 -	panel = mWearablePanelList[ WT_SOCKS ];
  47.490 +	panel = mWearablePanelList[LLWearableType::WT_SOCKS];
  47.491  
  47.492  	if (panel)
  47.493  	{
  47.494 @@ -2138,7 +2139,7 @@
  47.495  
  47.496  	/////////////////////////////////////////
  47.497  	// Jacket
  47.498 -	panel = mWearablePanelList[ WT_JACKET ];
  47.499 +	panel = mWearablePanelList[LLWearableType::WT_JACKET];
  47.500  
  47.501  	if (panel)
  47.502  	{
  47.503 @@ -2161,7 +2162,7 @@
  47.504  
  47.505  	/////////////////////////////////////////
  47.506  	// Skirt
  47.507 -	panel = mWearablePanelList[ WT_SKIRT ];
  47.508 +	panel = mWearablePanelList[LLWearableType::WT_SKIRT];
  47.509  
  47.510  	if (panel)
  47.511  	{
  47.512 @@ -2182,7 +2183,7 @@
  47.513  
  47.514  	/////////////////////////////////////////
  47.515  	// Gloves
  47.516 -	panel = mWearablePanelList[ WT_GLOVES ];
  47.517 +	panel = mWearablePanelList[LLWearableType::WT_GLOVES];
  47.518  
  47.519  	if (panel)
  47.520  	{
  47.521 @@ -2203,7 +2204,7 @@
  47.522  
  47.523  	/////////////////////////////////////////
  47.524  	// Undershirt
  47.525 -	panel = mWearablePanelList[ WT_UNDERSHIRT ];
  47.526 +	panel = mWearablePanelList[LLWearableType::WT_UNDERSHIRT];
  47.527  
  47.528  	if (panel)
  47.529  	{
  47.530 @@ -2223,7 +2224,7 @@
  47.531  
  47.532  	/////////////////////////////////////////
  47.533  	// Underpants
  47.534 -	panel = mWearablePanelList[ WT_UNDERPANTS ];
  47.535 +	panel = mWearablePanelList[LLWearableType::WT_UNDERPANTS];
  47.536  
  47.537  	if (panel)
  47.538  	{
  47.539 @@ -2243,7 +2244,7 @@
  47.540  
  47.541  	/////////////////////////////////////////
  47.542  	// Alpha
  47.543 -	panel = mWearablePanelList[WT_ALPHA];
  47.544 +	panel = mWearablePanelList[LLWearableType::WT_ALPHA];
  47.545  
  47.546  	if (panel)
  47.547  	{
  47.548 @@ -2279,7 +2280,7 @@
  47.549  
  47.550  	/////////////////////////////////////////
  47.551  	// Tattoo
  47.552 -	panel = mWearablePanelList[WT_TATTOO];
  47.553 +	panel = mWearablePanelList[LLWearableType::WT_TATTOO];
  47.554  
  47.555  	if (panel)
  47.556  	{
  47.557 @@ -2304,7 +2305,7 @@
  47.558  	/////////////////////////////////////////
  47.559  	// Physics
  47.560  
  47.561 -	panel = mWearablePanelList[WT_PHYSICS];
  47.562 +	panel = mWearablePanelList[LLWearableType::WT_PHYSICS];
  47.563  	
  47.564  	if(panel)
  47.565  	{
  47.566 @@ -2407,7 +2408,7 @@
  47.567  
  47.568  BOOL LLFloaterCustomize::isDirty() const
  47.569  {
  47.570 -	for(S32 i = 0; i < WT_COUNT; i++)
  47.571 +	for (S32 i = 0; i < LLWearableType::WT_COUNT; i++)
  47.572  	{
  47.573  		if( mWearablePanelList[i]
  47.574  			&& mWearablePanelList[i]->isDirty() )
  47.575 @@ -2421,8 +2422,9 @@
  47.576  // static
  47.577  void LLFloaterCustomize::onTabPrecommit( void* userdata, bool from_click )
  47.578  {
  47.579 -	EWearableType type = (EWearableType)(intptr_t) userdata;
  47.580 -	if (type != WT_INVALID && gFloaterCustomize && gFloaterCustomize->getCurrentWearableType() != type)
  47.581 +	LLWearableType::EType type = (LLWearableType::EType)(intptr_t) userdata;
  47.582 +	if (type != LLWearableType::WT_INVALID && gFloaterCustomize &&
  47.583 +		gFloaterCustomize->getCurrentWearableType() != type)
  47.584  	{
  47.585  		gFloaterCustomize->askToSaveIfDirty(onCommitChangeTab, userdata);
  47.586  	}
  47.587 @@ -2436,8 +2438,8 @@
  47.588  // static
  47.589  void LLFloaterCustomize::onTabChanged( void* userdata, bool from_click )
  47.590  {
  47.591 -	EWearableType wearable_type = (EWearableType) (intptr_t)userdata;
  47.592 -	if (wearable_type != WT_INVALID)
  47.593 +	LLWearableType::EType wearable_type = (LLWearableType::EType) (intptr_t)userdata;
  47.594 +	if (wearable_type != LLWearableType::WT_INVALID)
  47.595  	{
  47.596  		LLFloaterCustomize::setCurrentWearableType(wearable_type);
  47.597  	}
  47.598 @@ -2515,9 +2517,9 @@
  47.599  	}
  47.600  }
  47.601  
  47.602 -void LLFloaterCustomize::setWearable(EWearableType type, LLWearable* wearable, U32 perm_mask, BOOL is_complete)
  47.603 +void LLFloaterCustomize::setWearable(LLWearableType::EType type, LLWearable* wearable, U32 perm_mask, BOOL is_complete)
  47.604  {
  47.605 -	llassert( type < WT_COUNT );
  47.606 +	llassert(type < LLWearableType::WT_COUNT);
  47.607  	gSavedSettings.setU32("AvatarSex", (gAgent.getAvatarObject()->getSex() == SEX_MALE) );
  47.608  	
  47.609  	LLPanelEditWearable* panel = mWearablePanelList[ type ];
  47.610 @@ -2565,7 +2567,7 @@
  47.611  	S32 option = LLNotification::getSelectedOption(notification, response);
  47.612  
  47.613  	BOOL proceed = FALSE;
  47.614 -	EWearableType cur = getCurrentWearableType();
  47.615 +	LLWearableType::EType cur = getCurrentWearableType();
  47.616  
  47.617  	switch( option )
  47.618  	{
  47.619 @@ -2610,9 +2612,10 @@
  47.620  	// Fetch currently worn items
  47.621  	LLInventoryFetchObserver::item_ref_t ids;
  47.622  	LLUUID item_id;
  47.623 -	for(S32 type = (S32)WT_SHAPE; type < (S32)WT_COUNT; ++type)
  47.624 +	for (S32 type = (S32)LLWearableType::WT_SHAPE;
  47.625 +		 type < (S32)LLWearableType::WT_COUNT; ++type)
  47.626  	{
  47.627 -		item_id = gAgent.getWearableItem((EWearableType)type);
  47.628 +		item_id = gAgent.getWearableItem((LLWearableType::EType)type);
  47.629  		if(item_id.notNull())
  47.630  		{
  47.631  			ids.push_back(item_id);
  47.632 @@ -2632,7 +2635,7 @@
  47.633  	U32 perm_mask = 0x0;
  47.634  	LLPanelEditWearable* panel;
  47.635  	LLViewerInventoryItem* item;
  47.636 -	for(S32 i = 0; i < WT_COUNT; ++i)
  47.637 +	for (S32 i = 0; i < LLWearableType::WT_COUNT; ++i)
  47.638  	{
  47.639  		item = NULL;
  47.640  		panel = mWearablePanelList[i];
  47.641 @@ -2642,7 +2645,7 @@
  47.642  		}
  47.643  		if(item)
  47.644  		{
  47.645 -			is_complete = item->isComplete();
  47.646 +			is_complete = item->isFinished();
  47.647  			if(!is_complete)
  47.648  			{
  47.649  				all_complete = FALSE;
  47.650 @@ -2684,7 +2687,7 @@
  47.651  		if(item)
  47.652  		{
  47.653  			U32 perm_mask = item->getPermissions().getMaskOwner();
  47.654 -			BOOL is_complete = item->isComplete();
  47.655 +			BOOL is_complete = item->isFinished();
  47.656  			updateScrollingPanelList((perm_mask & PERM_MODIFY) ? is_complete : FALSE);
  47.657  		}
  47.658  	}
    48.1 --- a/indra/newview/llfloatercustomize.h	Mon Feb 27 23:28:58 2012 -0800
    48.2 +++ b/indra/newview/llfloatercustomize.h	Mon Feb 27 23:59:10 2012 -0800
    48.3 @@ -80,8 +80,8 @@
    48.4  	virtual BOOL 	postBuild();
    48.5  
    48.6  	// Inherted methods from LLFloater (and above)
    48.7 -	virtual void	onClose(bool app_quitting);
    48.8 -	virtual void	draw();
    48.9 +	/*virtual*/ void onClose(bool app_quitting);
   48.10 +	/*virtual*/ void draw();
   48.11  	/*virtual*/ void open();
   48.12  
   48.13  
   48.14 @@ -93,8 +93,11 @@
   48.15  	const std::string& getEditGroup();
   48.16  	void 			updateScrollingPanelList(BOOL allow_modify);
   48.17  
   48.18 -	void			setWearable(EWearableType type, LLWearable* wearable, U32 perm_mask, BOOL is_complete);
   48.19 -	LLPanelEditWearable* getCurrentWearablePanel() { return mWearablePanelList[ sCurrentWearableType ]; }
   48.20 +	void			setWearable(LLWearableType::EType type,
   48.21 +								LLWearable* wearable,
   48.22 +								U32 perm_mask,
   48.23 +								BOOL is_complete);
   48.24 +	LLPanelEditWearable* getCurrentWearablePanel()	{ return mWearablePanelList[sCurrentWearableType]; }
   48.25  
   48.26  	virtual BOOL	isDirty() const;
   48.27  
   48.28 @@ -102,8 +105,8 @@
   48.29  
   48.30  	void			switchToDefaultSubpart();
   48.31  
   48.32 -	static void		setCurrentWearableType( EWearableType type );
   48.33 -	static EWearableType getCurrentWearableType()					{ return sCurrentWearableType; }
   48.34 +	static void		setCurrentWearableType(LLWearableType::EType type);
   48.35 +	static LLWearableType::EType getCurrentWearableType()	{ return sCurrentWearableType; }
   48.36  
   48.37  	// Callbacks
   48.38  	static void		onBtnOk( void* userdata );
   48.39 @@ -120,9 +123,9 @@
   48.40  	void updateScrollingPanelUI();
   48.41  
   48.42  protected:
   48.43 -	LLPanelEditWearable*	mWearablePanelList[ WT_COUNT ];
   48.44 +	LLPanelEditWearable*	mWearablePanelList[LLWearableType::WT_COUNT];
   48.45  
   48.46 -	static EWearableType	sCurrentWearableType;
   48.47 +	static LLWearableType::EType sCurrentWearableType;
   48.48  
   48.49  	LLScrollingPanelList*	mScrollingPanelList;
   48.50  	LLScrollableContainerView* mScrollContainer;
    49.1 --- a/indra/newview/llfloaterlandmark.cpp	Mon Feb 27 23:28:58 2012 -0800
    49.2 +++ b/indra/newview/llfloaterlandmark.cpp	Mon Feb 27 23:59:10 2012 -0800
    49.3 @@ -190,7 +190,7 @@
    49.4  		{
    49.5  			if (!root_folder->getCurSelectedItem())
    49.6  			{
    49.7 -				LLFolderViewItem* itemp = root_folder->getItemByID(gAgent.getInventoryRootID());
    49.8 +				LLFolderViewItem* itemp = root_folder->getItemByID(gInventory.getRootFolderID());
    49.9  				if (itemp)
   49.10  				{
   49.11  					root_folder->setSelection(itemp, FALSE, FALSE);
    50.1 --- a/indra/newview/llfloateropenobject.cpp	Mon Feb 27 23:28:58 2012 -0800
    50.2 +++ b/indra/newview/llfloateropenobject.cpp	Mon Feb 27 23:59:10 2012 -0800
    50.3 @@ -153,31 +153,72 @@
    50.4  	}
    50.5  	else
    50.6  	{
    50.7 -		parent_category_id = gAgent.getInventoryRootID();
    50.8 +		parent_category_id = gInventory.getRootFolderID();
    50.9  	}
   50.10 -	LLUUID category_id = gInventory.createNewCategory(parent_category_id, 
   50.11 -		LLFolderType::FT_NONE, 
   50.12 -		name);
   50.13  
   50.14 -	LLCatAndWear* data = new LLCatAndWear;
   50.15 -	data->mCatID = category_id;
   50.16 -	data->mWear = wear;
   50.17 +	LLCategoryCreate* cat_data = new LLCategoryCreate(object_id, wear);
   50.18 +	LLUUID category_id = gInventory.createNewCategory(parent_category_id,
   50.19 +													  LLFolderType::FT_NONE,
   50.20 +													  name,
   50.21 +													  callbackCreateInventoryCategory,
   50.22 +													  (void*)cat_data);
   50.23  
   50.24 -	// Copy and/or move the items into the newly created folder.
   50.25 -	// Ignore any "you're going to break this item" messages.
   50.26 -	BOOL success = move_inv_category_world_to_agent(object_id, category_id, TRUE,
   50.27 -													callbackMoveInventory, 
   50.28 -													(void*)data);
   50.29 -	if (!success)
   50.30 +	// If we get a null category ID, we are using a capability in
   50.31 +	// createNewCategory and we will handle the following in the
   50.32 +	// callbackCreateInventoryCategory routine.
   50.33 +	if (category_id.notNull())
   50.34  	{
   50.35 -		delete data;
   50.36 -		data = NULL;
   50.37 +		delete cat_data;
   50.38  
   50.39 -		LLNotifications::instance().add("OpenObjectCannotCopy");
   50.40 +		LLCatAndWear* data = new LLCatAndWear;
   50.41 +		data->mCatID = category_id;
   50.42 +		data->mWear = wear;
   50.43 +		data->mFolderResponded = false;
   50.44 +
   50.45 +		// Copy and/or move the items into the newly created folder.
   50.46 +		// Ignore any "you're going to break this item" messages.
   50.47 +		BOOL success = move_inv_category_world_to_agent(object_id, category_id, TRUE,
   50.48 +														callbackMoveInventory, 
   50.49 +														(void*)data);
   50.50 +		if (!success)
   50.51 +		{
   50.52 +			delete data;
   50.53 +			data = NULL;
   50.54 +
   50.55 +			LLNotifications::instance().add("OpenObjectCannotCopy");
   50.56 +		}
   50.57  	}
   50.58  }
   50.59  
   50.60  // static
   50.61 +void LLFloaterOpenObject::callbackCreateInventoryCategory(const LLSD& result, void* data)
   50.62 +{
   50.63 +	LLCategoryCreate* cat_data = (LLCategoryCreate*)data;
   50.64 +
   50.65 +	LLUUID category_id = result["folder_id"].asUUID();
   50.66 +	LLCatAndWear* wear_data = new LLCatAndWear;
   50.67 +
   50.68 +	wear_data->mCatID = category_id;
   50.69 +	wear_data->mWear = cat_data->mWear;
   50.70 +	wear_data->mFolderResponded = true;
   50.71 +
   50.72 + 	// Copy and/or move the items into the newly created folder.
   50.73 + 	// Ignore any "you're going to break this item" messages.
   50.74 +
   50.75 +	BOOL success = move_inv_category_world_to_agent(cat_data->mObjectID, category_id, TRUE,
   50.76 + 													callbackMoveInventory, 
   50.77 +													(void*)wear_data);
   50.78 + 	if (!success)
   50.79 + 	{
   50.80 +		delete wear_data;
   50.81 +		wear_data = NULL;
   50.82 +
   50.83 + 		LLNotifications::instance().add("OpenObjectCannotCopy");
   50.84 + 	}
   50.85 +	delete cat_data;	
   50.86 + }
   50.87 +
   50.88 +// static
   50.89  void LLFloaterOpenObject::callbackMoveInventory(S32 result, void* data)
   50.90  {
   50.91  	LLCatAndWear* cat = (LLCatAndWear*)data;
    51.1 --- a/indra/newview/llfloateropenobject.h	Mon Feb 27 23:28:58 2012 -0800
    51.2 +++ b/indra/newview/llfloateropenobject.h	Mon Feb 27 23:59:10 2012 -0800
    51.3 @@ -50,10 +50,24 @@
    51.4  	static void show();
    51.5  	static void dirty();
    51.6  	
    51.7 +	class LLCategoryCreate
    51.8 +	{
    51.9 +		public:
   51.10 +			LLCategoryCreate(LLUUID object_id, bool wear)
   51.11 +			:	mObjectID(object_id),
   51.12 +				mWear(wear)
   51.13 +			{}
   51.14 +
   51.15 +		public:
   51.16 +			LLUUID mObjectID;
   51.17 +			bool mWear;
   51.18 +	};
   51.19 +
   51.20  	struct LLCatAndWear
   51.21  	{
   51.22  		LLUUID mCatID;
   51.23  		bool mWear;
   51.24 +		bool mFolderResponded;
   51.25  	};
   51.26  
   51.27  protected:
   51.28 @@ -67,6 +81,7 @@
   51.29  
   51.30  	static void onClickMoveToInventory(void* data);
   51.31  	static void onClickMoveAndWear(void* data);
   51.32 +	static void callbackCreateInventoryCategory(const LLSD& result, void* data);
   51.33  	static void callbackMoveInventory(S32 result, void* data);
   51.34  	static void* createPanelInventory(void* data);
   51.35  
    52.1 --- a/indra/newview/llfloaterpreference.cpp	Mon Feb 27 23:28:58 2012 -0800
    52.2 +++ b/indra/newview/llfloaterpreference.cpp	Mon Feb 27 23:59:10 2012 -0800
    52.3 @@ -52,7 +52,6 @@
    52.4  #include "llfloaterabout.h"
    52.5  #include "llfloaterpreference.h"
    52.6  #include "llpanelnetwork.h"
    52.7 -#include "llpanelaudioprefs.h"
    52.8  #include "llpaneldisplay.h"
    52.9  #include "llpaneldebug.h"
   52.10  #include "llpanelgeneral.h"
   52.11 @@ -66,6 +65,7 @@
   52.12  #include "llprefschat.h"
   52.13  #include "llprefsvoice.h"
   52.14  #include "llprefsim.h"
   52.15 +#include "llprefsmedia.h"
   52.16  #include "llresizehandle.h"
   52.17  #include "llresmgr.h"
   52.18  #include "llassetstorage.h"
   52.19 @@ -158,7 +158,7 @@
   52.20  	mTabContainer->addTabPanel(mDisplayPanel, mDisplayPanel->getLabel(), FALSE, onTabChanged, mTabContainer);
   52.21  	mDisplayPanel->setDefaultBtn(default_btn);
   52.22  
   52.23 -	mAudioPanel = new LLPanelAudioPrefs();
   52.24 +	mAudioPanel = new LLPrefsMedia();
   52.25  	mTabContainer->addTabPanel(mAudioPanel, mAudioPanel->getLabel(), FALSE, onTabChanged, mTabContainer);
   52.26  	mAudioPanel->setDefaultBtn(default_btn);
   52.27  
    53.1 --- a/indra/newview/llfloaterpreference.h	Mon Feb 27 23:28:58 2012 -0800
    53.2 +++ b/indra/newview/llfloaterpreference.h	Mon Feb 27 23:59:10 2012 -0800
    53.3 @@ -47,7 +47,6 @@
    53.4  class LLPanelInput;
    53.5  class LLPanelLCD;
    53.6  class LLPanelDisplay;
    53.7 -class LLPanelAudioPrefs;
    53.8  class LLPanelDebug;
    53.9  class LLPanelNetwork;
   53.10  class LLPanelWeb;
   53.11 @@ -56,6 +55,7 @@
   53.12  class LLPrefsChat;
   53.13  class LLPrefsVoice;
   53.14  class LLPrefsIM;
   53.15 +class LLPrefsMedia;
   53.16  class LLPanelMsgs;
   53.17  class LLPanelSkins;
   53.18  class LLScrollListCtrl;
   53.19 @@ -93,11 +93,11 @@
   53.20  	LLPanelInput			*mInputPanel;
   53.21  	LLPanelNetwork	        *mNetworkPanel;
   53.22  	LLPanelDisplay	        *mDisplayPanel;
   53.23 -	LLPanelAudioPrefs		*mAudioPanel;
   53.24  //	LLPanelDebug			*mDebugPanel;
   53.25  	LLPrefsChat				*mPrefsChat;
   53.26  	LLPrefsVoice			*mPrefsVoice;
   53.27  	LLPrefsIM				*mPrefsIM;
   53.28 +	LLPrefsMedia			*mAudioPanel;
   53.29  	LLPanelWeb				*mWebPanel;
   53.30  	LLPanelMsgs				*mMsgPanel;
   53.31  	LLPanelLCD				*mLCDPanel;
    54.1 --- a/indra/newview/llfloaterproperties.cpp	Mon Feb 27 23:28:58 2012 -0800
    54.2 +++ b/indra/newview/llfloaterproperties.cpp	Mon Feb 27 23:59:10 2012 -0800
    54.3 @@ -289,7 +289,7 @@
    54.4  
    54.5  	// do not enable the UI for incomplete items.
    54.6  	LLViewerInventoryItem* i = (LLViewerInventoryItem*)item;
    54.7 -	BOOL is_complete = i->isComplete();
    54.8 +	BOOL is_complete = i->isFinished();
    54.9  
   54.10  	const LLPermissions& perm = item->getPermissions();
   54.11  	BOOL can_agent_manipulate = gAgent.allowOperation(PERM_OWNER, perm, 
   54.12 @@ -753,7 +753,7 @@
   54.13  							CheckNextOwnerTransfer->get(), PERM_TRANSFER);
   54.14  	}
   54.15  	if(perm != item->getPermissions()
   54.16 -		&& item->isComplete())
   54.17 +		&& item->isFinished())
   54.18  	{
   54.19  		LLPointer<LLViewerInventoryItem> new_item = new LLViewerInventoryItem(item);
   54.20  		new_item->setPermissions(perm);
   54.21 @@ -889,7 +889,7 @@
   54.22  		sale_info.setSaleType(LLSaleInfo::FS_NOT);
   54.23  	}
   54.24  	if(sale_info != item->getSaleInfo()
   54.25 -		&& item->isComplete())
   54.26 +		&& item->isFinished())
   54.27  	{
   54.28  		LLPointer<LLViewerInventoryItem> new_item = new LLViewerInventoryItem(item);
   54.29  
    55.1 --- a/indra/newview/llfloaterwater.cpp	Mon Feb 27 23:28:58 2012 -0800
    55.2 +++ b/indra/newview/llfloaterwater.cpp	Mon Feb 27 23:59:10 2012 -0800
    55.3 @@ -639,7 +639,7 @@
    55.4  		const LLUUID trash_id = gInventory.findCategoryUUIDForType(LLFolderType::FT_TRASH);
    55.5  		if(LLWaterParamManager::instance()->mCurParams.mInventoryID.notNull() 
    55.6  			&& !gInventory.isObjectDescendentOf(LLWaterParamManager::instance()->mCurParams.mInventoryID, trash_id)
    55.7 -			&& gInventory.isObjectDescendentOf(LLWaterParamManager::instance()->mCurParams.mInventoryID, gAgent.getInventoryRootID())
    55.8 +			&& gInventory.isObjectDescendentOf(LLWaterParamManager::instance()->mCurParams.mInventoryID, gInventory.getRootFolderID())
    55.9  		)
   55.10  		{
   55.11  			LLNotifications::instance().add("KittyWLSaveNotecardAlert", LLSD(), LLSD(), saveNotecardCallback);
    56.1 --- a/indra/newview/llfloaterwindlight.cpp	Mon Feb 27 23:28:58 2012 -0800
    56.2 +++ b/indra/newview/llfloaterwindlight.cpp	Mon Feb 27 23:59:10 2012 -0800
    56.3 @@ -832,7 +832,7 @@
    56.4  		const LLUUID trash_id = gInventory.findCategoryUUIDForType(LLFolderType::FT_TRASH);
    56.5  		if(LLWLParamManager::instance()->mCurParams.mInventoryID.notNull() 
    56.6  			&& !gInventory.isObjectDescendentOf(LLWLParamManager::instance()->mCurParams.mInventoryID, trash_id)
    56.7 -			&& gInventory.isObjectDescendentOf(LLWLParamManager::instance()->mCurParams.mInventoryID, gAgent.getInventoryRootID())
    56.8 +			&& gInventory.isObjectDescendentOf(LLWLParamManager::instance()->mCurParams.mInventoryID, gInventory.getRootFolderID())
    56.9  		)
   56.10   		{
   56.11  			LLNotifications::instance().add("KittyWLSaveNotecardAlert", LLSD(), LLSD(), saveNotecardCallback);
    57.1 --- a/indra/newview/llfloaterworldmap.cpp	Mon Feb 27 23:28:58 2012 -0800
    57.2 +++ b/indra/newview/llfloaterworldmap.cpp	Mon Feb 27 23:59:10 2012 -0800
    57.3 @@ -50,6 +50,7 @@
    57.4  #include "llviewercontrol.h"
    57.5  #include "lldraghandle.h"
    57.6  #include "llfirstuse.h"
    57.7 +#include "llinventorymodelbackgroundfetch.h"
    57.8  #include "llfocusmgr.h"
    57.9  #include "lllandmarklist.h"
   57.10  #include "lllineeditor.h"
   57.11 @@ -374,7 +375,7 @@
   57.12  
   57.13  		// Start speculative download of landmarks
   57.14  		LLUUID landmark_folder_id = gInventory.findCategoryUUIDForType(LLFolderType::FT_LANDMARK);
   57.15 -		gInventory.startBackgroundFetch(landmark_folder_id);
   57.16 +		LLInventoryModelBackgroundFetch::instance().start(landmark_folder_id);
   57.17  
   57.18  		gFloaterWorldMap->childSetFocus("location", TRUE);
   57.19  		gFocusMgr.triggerFocusFlash();
   57.20 @@ -969,7 +970,7 @@
   57.21  	LLInventoryModel::cat_array_t cats;
   57.22  	LLInventoryModel::item_array_t items;
   57.23  	LLIsType is_landmark(LLAssetType::AT_LANDMARK);
   57.24 -	gInventory.collectDescendentsIf(gAgent.getInventoryRootID(),
   57.25 +	gInventory.collectDescendentsIf(gInventory.getRootFolderID(),
   57.26  									cats,
   57.27  									items,
   57.28  									LLInventoryModel::EXCLUDE_TRASH,
    58.1 --- a/indra/newview/llfolderview.cpp	Mon Feb 27 23:28:58 2012 -0800
    58.2 +++ b/indra/newview/llfolderview.cpp	Mon Feb 27 23:59:10 2012 -0800
    58.3 @@ -46,14 +46,15 @@
    58.4  #include "llinventory.h"
    58.5  
    58.6  #include "llcallbacklist.h"
    58.7 -#include "llinventoryclipboard.h" // *TODO: remove this once hack below gone.
    58.8 -#include "llinventoryview.h"// hacked in for the bonus context menu items.
    58.9 +#include "llinventoryclipboard.h"	// *TODO: remove this once hack below gone.
   58.10 +#include "llinventorymodelbackgroundfetch.h"
   58.11 +#include "llinventoryview.h"		// hacked in for the bonus context menu items.
   58.12  #include "llkeyboard.h"
   58.13  #include "lllineeditor.h"
   58.14  #include "llmenugl.h"
   58.15  #include "llresmgr.h"
   58.16  #include "llpreview.h"
   58.17 -#include "llscrollcontainer.h" // hack to allow scrolling
   58.18 +#include "llscrollcontainer.h"		// hack to allow scrolling
   58.19  #include "lltooldraganddrop.h"
   58.20  #include "llui.h"
   58.21  #include "llviewertexturelist.h"
   58.22 @@ -785,11 +786,11 @@
   58.23  
   58.24  				// *TODO: push this into listener and remove
   58.25  				// dependency on llagent
   58.26 -				if(mListener && gInventory.isObjectDescendentOf(mListener->getUUID(), gAgent.getInventoryRootID()))
   58.27 +				if (mListener && gInventory.isObjectDescendentOf(mListener->getUUID(), gInventory.getRootFolderID()))
   58.28  				{
   58.29  					src = LLToolDragAndDrop::SOURCE_AGENT;
   58.30  				}
   58.31 -				else if (mListener && gInventory.isObjectDescendentOf(mListener->getUUID(), gInventoryLibraryRoot))
   58.32 +				else if (mListener && gInventory.isObjectDescendentOf(mListener->getUUID(), gInventory.getLibraryRootFolderID()))
   58.33  				{
   58.34  					src = LLToolDragAndDrop::SOURCE_LIBRARY;
   58.35  				}
   58.36 @@ -1362,7 +1363,7 @@
   58.37  	// when applying a filter, matching folders get their contents downloaded first
   58.38  	if (filter.isNotDefault() && getFiltered(filter.getMinRequiredGeneration()) && (mListener && !gInventory.isCategoryComplete(mListener->getUUID())))
   58.39  	{
   58.40 -		gInventory.startBackgroundFetch(mListener->getUUID());
   58.41 +		LLInventoryModelBackgroundFetch::instance().start(mListener->getUUID());
   58.42  	}
   58.43  
   58.44  	// now query children
   58.45 @@ -2794,10 +2795,10 @@
   58.46  	return mSortOrder;
   58.47  }
   58.48  
   58.49 -BOOL LLFolderView::addFolder( LLFolderViewFolder* folder)
   58.50 +BOOL LLFolderView::addFolder(LLFolderViewFolder* folder)
   58.51  {
   58.52  	// enforce sort order of My Inventory followed by Library
   58.53 -	if (folder->getListener()->getUUID() == gInventoryLibraryRoot)
   58.54 +	if (folder->getListener()->getUUID() == gInventory.getLibraryRootFolderID())
   58.55  	{
   58.56  		mFolders.push_back(folder);
   58.57  	}
   58.58 @@ -3209,7 +3210,7 @@
   58.59  		else
   58.60  		{
   58.61  			// nothing selected to start with, so pick "My Inventory" as best guess
   58.62 -			new_selection = getItemByID(gAgent.getInventoryRootID());
   58.63 +			new_selection = getItemByID(gInventory.getRootFolderID());
   58.64  		}
   58.65  
   58.66  		if (new_selection)
   58.67 @@ -3324,7 +3325,8 @@
   58.68  	}
   58.69  	else
   58.70  	{
   58.71 -		if (gInventory.backgroundFetchActive() || mCompletedFilterGeneration < mFilter.getMinRequiredGeneration())
   58.72 +		if (LLInventoryModelBackgroundFetch::instance().backgroundFetchActive() ||
   58.73 +			mCompletedFilterGeneration < mFilter.getMinRequiredGeneration())
   58.74  		{
   58.75  			mStatusText = std::string("Searching..."); // *TODO:translate
   58.76  			sFont->renderUTF8(mStatusText, 0, 2, 1, sSearchStatusColor, LLFontGL::LEFT, LLFontGL::TOP, LLFontGL::NORMAL, S32_MAX, S32_MAX, NULL, FALSE );
   58.77 @@ -5186,7 +5188,8 @@
   58.78  		filtered_by_all_types = FALSE;
   58.79  	}
   58.80  
   58.81 -	if (!gInventory.backgroundFetchActive() && filtered_by_type && !filtered_by_all_types)
   58.82 +	if (!LLInventoryModelBackgroundFetch::instance().backgroundFetchActive() &&
   58.83 +		filtered_by_type && !filtered_by_all_types)
   58.84  	{
   58.85  		mFilterText += " - ";
   58.86  		if (num_filter_types < 5)
    59.1 --- a/indra/newview/llinventoryactions.cpp	Mon Feb 27 23:28:58 2012 -0800
    59.2 +++ b/indra/newview/llinventoryactions.cpp	Mon Feb 27 23:59:10 2012 -0800
    59.3 @@ -341,7 +341,7 @@
    59.4  		}
    59.5  		else
    59.6  		{
    59.7 -			category = model->createNewCategory(gAgent.getInventoryRootID(),
    59.8 +			category = model->createNewCategory(gInventory.getRootFolderID(),
    59.9  												LLFolderType::FT_NONE, LLStringUtil::null);
   59.10  		}
   59.11  		model->notifyObservers();
   59.12 @@ -377,82 +377,82 @@
   59.13  	else if ("shirt" == type)
   59.14  	{
   59.15  		LLUUID parent_id = self ? self->getUUID() : gInventory.findCategoryUUIDForType(LLFolderType::FT_CLOTHING);
   59.16 -		LLFolderBridge::createWearable(parent_id, WT_SHIRT);
   59.17 +		LLFolderBridge::createWearable(parent_id, LLWearableType::WT_SHIRT);
   59.18  	}
   59.19  	else if ("pants" == type)
   59.20  	{
   59.21  		LLUUID parent_id = self ? self->getUUID() : gInventory.findCategoryUUIDForType(LLFolderType::FT_CLOTHING);
   59.22 -		LLFolderBridge::createWearable(parent_id, WT_PANTS);
   59.23 +		LLFolderBridge::createWearable(parent_id, LLWearableType::WT_PANTS);
   59.24  	}
   59.25  	else if ("shoes" == type)
   59.26  	{
   59.27  		LLUUID parent_id = self ? self->getUUID() : gInventory.findCategoryUUIDForType(LLFolderType::FT_CLOTHING);
   59.28 -		LLFolderBridge::createWearable(parent_id, WT_SHOES);
   59.29 +		LLFolderBridge::createWearable(parent_id, LLWearableType::WT_SHOES);
   59.30  	}
   59.31  	else if ("socks" == type)
   59.32  	{
   59.33  		LLUUID parent_id = self ? self->getUUID() : gInventory.findCategoryUUIDForType(LLFolderType::FT_CLOTHING);
   59.34 -		LLFolderBridge::createWearable(parent_id, WT_SOCKS);
   59.35 +		LLFolderBridge::createWearable(parent_id, LLWearableType::WT_SOCKS);
   59.36  	}
   59.37  	else if ("jacket" == type)
   59.38  	{
   59.39  		LLUUID parent_id = self ? self->getUUID() : gInventory.findCategoryUUIDForType(LLFolderType::FT_CLOTHING);
   59.40 -		LLFolderBridge::createWearable(parent_id, WT_JACKET);
   59.41 +		LLFolderBridge::createWearable(parent_id, LLWearableType::WT_JACKET);
   59.42  	}
   59.43  	else if ("skirt" == type)
   59.44  	{
   59.45  		LLUUID parent_id = self ? self->getUUID() : gInventory.findCategoryUUIDForType(LLFolderType::FT_CLOTHING);
   59.46 -		LLFolderBridge::createWearable(parent_id, WT_SKIRT);
   59.47 +		LLFolderBridge::createWearable(parent_id, LLWearableType::WT_SKIRT);
   59.48  	}
   59.49  	else if ("gloves" == type)
   59.50  	{
   59.51  		LLUUID parent_id = self ? self->getUUID() : gInventory.findCategoryUUIDForType(LLFolderType::FT_CLOTHING);
   59.52 -		LLFolderBridge::createWearable(parent_id, WT_GLOVES);
   59.53 +		LLFolderBridge::createWearable(parent_id, LLWearableType::WT_GLOVES);
   59.54  	}
   59.55  	else if ("undershirt" == type)
   59.56  	{
   59.57  		LLUUID parent_id = self ? self->getUUID() : gInventory.findCategoryUUIDForType(LLFolderType::FT_CLOTHING);
   59.58 -		LLFolderBridge::createWearable(parent_id, WT_UNDERSHIRT);
   59.59 +		LLFolderBridge::createWearable(parent_id, LLWearableType::WT_UNDERSHIRT);
   59.60  	}
   59.61  	else if ("underpants" == type)
   59.62  	{
   59.63  		LLUUID parent_id = self ? self->getUUID() : gInventory.findCategoryUUIDForType(LLFolderType::FT_CLOTHING);
   59.64 -		LLFolderBridge::createWearable(parent_id, WT_UNDERPANTS);
   59.65 +		LLFolderBridge::createWearable(parent_id, LLWearableType::WT_UNDERPANTS);
   59.66  	}
   59.67  	else if ("alpha" == type)
   59.68  	{
   59.69  		LLUUID parent_id = self ? self->getUUID() : gInventory.findCategoryUUIDForType(LLFolderType::FT_CLOTHING);
   59.70 -		LLFolderBridge::createWearable(parent_id, WT_ALPHA);
   59.71 +		LLFolderBridge::createWearable(parent_id, LLWearableType::WT_ALPHA);
   59.72  	}
   59.73  	else if ("tattoo" == type)
   59.74  	{
   59.75  		LLUUID parent_id = self ? self->getUUID() : gInventory.findCategoryUUIDForType(LLFolderType::FT_CLOTHING);
   59.76 -		LLFolderBridge::createWearable(parent_id, WT_TATTOO);
   59.77 +		LLFolderBridge::createWearable(parent_id, LLWearableType::WT_TATTOO);
   59.78  	}
   59.79  	else if ("physics" == type)
   59.80  	{
   59.81  		LLUUID parent_id = self ? self->getUUID() : gInventory.findCategoryUUIDForType(LLFolderType::FT_CLOTHING);
   59.82 -		LLFolderBridge::createWearable(parent_id, WT_PHYSICS);
   59.83 +		LLFolderBridge::createWearable(parent_id, LLWearableType::WT_PHYSICS);
   59.84  	}
   59.85  	else if ("shape" == type)
   59.86  	{
   59.87  		LLUUID parent_id = self ? self->getUUID() : gInventory.findCategoryUUIDForType(LLFolderType::FT_BODYPART);
   59.88 -		LLFolderBridge::createWearable(parent_id, WT_SHAPE);
   59.89 +		LLFolderBridge::createWearable(parent_id, LLWearableType::WT_SHAPE);
   59.90  	}
   59.91  	else if ("skin" == type)
   59.92  	{
   59.93  		LLUUID parent_id = self ? self->getUUID() : gInventory.findCategoryUUIDForType(LLFolderType::FT_BODYPART);
   59.94 -		LLFolderBridge::createWearable(parent_id, WT_SKIN);
   59.95 +		LLFolderBridge::createWearable(parent_id, LLWearableType::WT_SKIN);
   59.96  	}
   59.97  	else if ("hair" == type)
   59.98  	{
   59.99  		LLUUID parent_id = self ? self->getUUID() : gInventory.findCategoryUUIDForType(LLFolderType::FT_BODYPART);
  59.100 -		LLFolderBridge::createWearable(parent_id, WT_HAIR);
  59.101 +		LLFolderBridge::createWearable(parent_id, LLWearableType::WT_HAIR);
  59.102  	}
  59.103  	else if ("eyes" == type)
  59.104  	{
  59.105  		LLUUID parent_id = self ? self->getUUID() : gInventory.findCategoryUUIDForType(LLFolderType::FT_BODYPART);
  59.106 -		LLFolderBridge::createWearable(parent_id, WT_EYES);
  59.107 +		LLFolderBridge::createWearable(parent_id, LLWearableType::WT_EYES);
  59.108  	}
  59.109  
  59.110  	ptr->getRootFolder()->setNeedsAutoRename(TRUE);	
  59.111 @@ -787,11 +787,11 @@
  59.112  		}
  59.113  		LLViewerInventoryItem* item = (LLViewerInventoryItem*)gInventory.getItem(id);
  59.114  
  59.115 -		if(item && gInventory.isObjectDescendentOf(id, gAgent.getInventoryRootID()))
  59.116 +		if (item && gInventory.isObjectDescendentOf(id, gInventory.getRootFolderID()))
  59.117  		{
  59.118  			rez_attachment(item, attachmentp);
  59.119  		}
  59.120 -		else if(item && item->isComplete())
  59.121 +		else if(item && item->isFinished())
  59.122  		{
  59.123  			// must be in library. copy it to our inventory and put it on.
  59.124  			LLPointer<LLInventoryCallback> cb = new RezAttachmentCallback(attachmentp);
    60.1 --- a/indra/newview/llinventorybridge.cpp	Mon Feb 27 23:28:58 2012 -0800
    60.2 +++ b/indra/newview/llinventorybridge.cpp	Mon Feb 27 23:59:10 2012 -0800
    60.3 @@ -62,6 +62,7 @@
    60.4  #include "lliconctrl.h"
    60.5  #include "llinventoryicon.h"
    60.6  #include "llinventorymodel.h"
    60.7 +#include "llinventorymodelbackgroundfetch.h"
    60.8  #include "llinventoryclipboard.h"
    60.9  #include "lllineeditor.h"
   60.10  #include "llmenugl.h"
   60.11 @@ -199,7 +200,7 @@
   60.12  	{
   60.13  		return TRUE;
   60.14  	}
   60.15 -	if (model->isObjectDescendentOf(mUUID, gAgent.getInventoryRootID()))
   60.16 +	if (model->isObjectDescendentOf(mUUID, gInventory.getRootFolderID()))
   60.17  	{
   60.18  		return TRUE;
   60.19  	}
   60.20 @@ -380,7 +381,7 @@
   60.21  		return FALSE;
   60.22  	}
   60.23  
   60.24 -	BOOL is_agent_inventory = model->isObjectDescendentOf(mUUID, gAgent.getInventoryRootID());
   60.25 +	BOOL is_agent_inventory = model->isObjectDescendentOf(mUUID, gInventory.getRootFolderID());
   60.26  	if (!LLInventoryClipboard::instance().hasContents() || !is_agent_inventory)
   60.27  	{
   60.28  		return FALSE;
   60.29 @@ -641,7 +642,7 @@
   60.30  
   60.31  		if (*type == DAD_CATEGORY)
   60.32  		{
   60.33 -			gInventory.startBackgroundFetch(obj->getUUID());
   60.34 +			LLInventoryModelBackgroundFetch::instance().start(obj->getUUID());
   60.35  		}
   60.36  
   60.37  		rv = TRUE;
   60.38 @@ -702,8 +703,8 @@
   60.39  {
   60.40  	LLInventoryModel* model = mInventoryPanel->getModel();
   60.41  	if(!model) return FALSE;
   60.42 -	if(gAgent.getInventoryRootID() == mUUID) return TRUE;
   60.43 -	return model->isObjectDescendentOf(mUUID, gAgent.getInventoryRootID());
   60.44 +	if(gInventory.getRootFolderID() == mUUID) return TRUE;
   60.45 +	return model->isObjectDescendentOf(mUUID, gInventory.getRootFolderID());
   60.46  }
   60.47  
   60.48  BOOL LLInvFVBridge::isItemPermissive() const
   60.49 @@ -869,7 +870,7 @@
   60.50  			warn = true;
   60.51  		}
   60.52  		new_listener = new LLWearableBridge(inventory, uuid, asset_type,
   60.53 -											inv_type, (EWearableType)flags);
   60.54 +											inv_type, (LLWearableType::EType)flags);
   60.55  		break;
   60.56  
   60.57  	case LLAssetType::AT_CATEGORY:
   60.58 @@ -1020,7 +1021,7 @@
   60.59  void LLItemBridge::selectItem()
   60.60  {
   60.61  	LLViewerInventoryItem* item = (LLViewerInventoryItem*)getItem();
   60.62 -	if(item && !item->isComplete())
   60.63 +	if(item && !item->isFinished())
   60.64  	{
   60.65  		item->fetchFromServer();
   60.66  	}
   60.67 @@ -1360,8 +1361,7 @@
   60.68  BOOL LLFolderBridge::isItemRemovable()
   60.69  {
   60.70  	LLInventoryModel* model = mInventoryPanel->getModel();
   60.71 -
   60.72 -	if(!model->isObjectDescendentOf(mUUID, gAgent.getInventoryRootID()))
   60.73 +	if (!model || !model->isObjectDescendentOf(mUUID, gInventory.getRootFolderID()))
   60.74  	{
   60.75  		return FALSE;
   60.76  	}
   60.77 @@ -1866,7 +1866,7 @@
   60.78  	outfit->fetchItems(ids);
   60.79  	outfit->done();				//Not interested in waiting and this will be right 99% of the time.
   60.80  //Uncomment the following code for laggy Inventory UI.
   60.81 -/*	if(outfit->isEverythingComplete())
   60.82 +/*	if(outfit->isFinished())
   60.83  	{
   60.84  		// everything is already here - call done.
   60.85  		outfit->done();
   60.86 @@ -1889,14 +1889,20 @@
   60.87  class LLInventoryCopyAndWearObserver : public LLInventoryObserver
   60.88  {
   60.89  public:
   60.90 -	LLInventoryCopyAndWearObserver(const LLUUID& cat_id, int count) :mCatID(cat_id), mContentsCount(count), mFolderAdded(FALSE) {}
   60.91 +	LLInventoryCopyAndWearObserver(const LLUUID& cat_id,
   60.92 +								   int count,
   60.93 +								   bool folder_added = false)
   60.94 +	:	mCatID(cat_id),
   60.95 +		mContentsCount(count),
   60.96 +		mFolderAdded(folder_added)
   60.97 +	{}
   60.98  	virtual ~LLInventoryCopyAndWearObserver() {}
   60.99  	virtual void changed(U32 mask);
  60.100  
  60.101  protected:
  60.102  	LLUUID mCatID;
  60.103  	int    mContentsCount;
  60.104 -	BOOL   mFolderAdded;
  60.105 +	bool   mFolderAdded;
  60.106  };
  60.107  
  60.108  
  60.109 @@ -2388,7 +2394,7 @@
  60.110  		folders.push_back(category->getUUID());
  60.111  		fetch->fetchDescendents(folders);
  60.112  		inc_busy_count();
  60.113 -		if (fetch->isEverythingComplete())
  60.114 +		if (fetch->isFinished())
  60.115  		{
  60.116  			// everything is already here - call done.
  60.117  			fetch->done();
  60.118 @@ -2488,86 +2494,86 @@
  60.119  
  60.120  void LLFolderBridge::createNewShirt(void* user_data)
  60.121  {
  60.122 -	LLFolderBridge::createWearable((LLFolderBridge*)user_data, WT_SHIRT);
  60.123 +	LLFolderBridge::createWearable((LLFolderBridge*)user_data, LLWearableType::WT_SHIRT);
  60.124  }
  60.125  
  60.126  void LLFolderBridge::createNewPants(void* user_data)
  60.127  {
  60.128 -	LLFolderBridge::createWearable((LLFolderBridge*)user_data, WT_PANTS);
  60.129 +	LLFolderBridge::createWearable((LLFolderBridge*)user_data, LLWearableType::WT_PANTS);
  60.130  }
  60.131  
  60.132  void LLFolderBridge::createNewShoes(void* user_data)
  60.133  {
  60.134 -	LLFolderBridge::createWearable((LLFolderBridge*)user_data, WT_SHOES);
  60.135 +	LLFolderBridge::createWearable((LLFolderBridge*)user_data, LLWearableType::WT_SHOES);
  60.136  }
  60.137  
  60.138  void LLFolderBridge::createNewSocks(void* user_data)
  60.139  {
  60.140 -	LLFolderBridge::createWearable((LLFolderBridge*)user_data, WT_SOCKS);
  60.141 +	LLFolderBridge::createWearable((LLFolderBridge*)user_data, LLWearableType::WT_SOCKS);
  60.142  }
  60.143  
  60.144  void LLFolderBridge::createNewJacket(void* user_data)
  60.145  {
  60.146 -	LLFolderBridge::createWearable((LLFolderBridge*)user_data, WT_JACKET);
  60.147 +	LLFolderBridge::createWearable((LLFolderBridge*)user_data, LLWearableType::WT_JACKET);
  60.148  }
  60.149  
  60.150  void LLFolderBridge::createNewSkirt(void* user_data)
  60.151  {
  60.152 -	LLFolderBridge::createWearable((LLFolderBridge*)user_data, WT_SKIRT);
  60.153 +	LLFolderBridge::createWearable((LLFolderBridge*)user_data, LLWearableType::WT_SKIRT);
  60.154  }
  60.155  
  60.156  void LLFolderBridge::createNewGloves(void* user_data)
  60.157  {
  60.158 -	LLFolderBridge::createWearable((LLFolderBridge*)user_data, WT_GLOVES);
  60.159 +	LLFolderBridge::createWearable((LLFolderBridge*)user_data, LLWearableType::WT_GLOVES);
  60.160  }
  60.161  
  60.162  void LLFolderBridge::createNewUndershirt(void* user_data)
  60.163  {
  60.164 -	LLFolderBridge::createWearable((LLFolderBridge*)user_data, WT_UNDERSHIRT);
  60.165 +	LLFolderBridge::createWearable((LLFolderBridge*)user_data, LLWearableType::WT_UNDERSHIRT);
  60.166  }
  60.167  
  60.168  void LLFolderBridge::createNewUnderpants(void* user_data)
  60.169  {
  60.170 -	LLFolderBridge::createWearable((LLFolderBridge*)user_data, WT_UNDERPANTS);
  60.171 +	LLFolderBridge::createWearable((LLFolderBridge*)user_data, LLWearableType::WT_UNDERPANTS);
  60.172  }
  60.173  
  60.174  void LLFolderBridge::createNewAlpha(void* user_data)
  60.175  {
  60.176 -	LLFolderBridge::createWearable((LLFolderBridge*)user_data, WT_ALPHA);
  60.177 +	LLFolderBridge::createWearable((LLFolderBridge*)user_data, LLWearableType::WT_ALPHA);
  60.178  }
  60.179  
  60.180  void LLFolderBridge::createNewTattoo(void* user_data)
  60.181  {
  60.182 -	LLFolderBridge::createWearable((LLFolderBridge*)user_data, WT_TATTOO);
  60.183 +	LLFolderBridge::createWearable((LLFolderBridge*)user_data, LLWearableType::WT_TATTOO);
  60.184  }
  60.185  
  60.186  void LLFolderBridge::createNewShape(void* user_data)
  60.187  {
  60.188 -	LLFolderBridge::createWearable((LLFolderBridge*)user_data, WT_SHAPE);
  60.189 +	LLFolderBridge::createWearable((LLFolderBridge*)user_data, LLWearableType::WT_SHAPE);
  60.190  }
  60.191  
  60.192  void LLFolderBridge::createNewSkin(void* user_data)
  60.193  {
  60.194 -	LLFolderBridge::createWearable((LLFolderBridge*)user_data, WT_SKIN);
  60.195 +	LLFolderBridge::createWearable((LLFolderBridge*)user_data, LLWearableType::WT_SKIN);
  60.196  }
  60.197  
  60.198  void LLFolderBridge::createNewHair(void* user_data)
  60.199  {
  60.200 -	LLFolderBridge::createWearable((LLFolderBridge*)user_data, WT_HAIR);
  60.201 +	LLFolderBridge::createWearable((LLFolderBridge*)user_data, LLWearableType::WT_HAIR);
  60.202  }
  60.203  
  60.204  void LLFolderBridge::createNewEyes(void* user_data)
  60.205  {
  60.206 -	LLFolderBridge::createWearable((LLFolderBridge*)user_data, WT_EYES);
  60.207 +	LLFolderBridge::createWearable((LLFolderBridge*)user_data, LLWearableType::WT_EYES);
  60.208  }
  60.209  
  60.210  void LLFolderBridge::createNewPhysics(void* user_data)
  60.211  {
  60.212 -	LLFolderBridge::createWearable((LLFolderBridge*)user_data, WT_PHYSICS);
  60.213 +	LLFolderBridge::createWearable((LLFolderBridge*)user_data, LLWearableType::WT_PHYSICS);
  60.214  }
  60.215  
  60.216  // static
  60.217 -void LLFolderBridge::createWearable(LLFolderBridge* bridge, EWearableType type)
  60.218 +void LLFolderBridge::createWearable(LLFolderBridge* bridge, LLWearableType::EType type)
  60.219  {
  60.220  	if(!bridge) return;
  60.221  	LLUUID parent_id = bridge->getUUID();
  60.222 @@ -2577,7 +2583,7 @@
  60.223  // Separate function so can be called by global menu as well as right-click
  60.224  // menu.
  60.225  // static
  60.226 -void LLFolderBridge::createWearable(LLUUID parent_id, EWearableType type)
  60.227 +void LLFolderBridge::createWearable(LLUUID parent_id, LLWearableType::EType type)
  60.228  {
  60.229  	LLWearable* wearable = gWearableList.createNewWearable(type);
  60.230  	LLAssetType::EType asset_type = wearable->getAssetType();
  60.231 @@ -2608,13 +2614,16 @@
  60.232  
  60.233  	if(option == 0 && object)
  60.234  	{
  60.235 -		if (cat_and_wear && cat_and_wear->mWear)
  60.236 +		if (cat_and_wear && cat_and_wear->mWear) // && !cat_and_wear->mFolderResponded)
  60.237  		{
  60.238  			InventoryObjectList inventory_objects;
  60.239  			object->getInventoryContents(inventory_objects);
  60.240  			int contents_count = inventory_objects.size()-1; //subtract one for containing folder
  60.241  
  60.242 -			LLInventoryCopyAndWearObserver* inventoryObserver = new LLInventoryCopyAndWearObserver(cat_and_wear->mCatID, contents_count);
  60.243 +			LLInventoryCopyAndWearObserver* inventoryObserver;
  60.244 +			inventoryObserver = new LLInventoryCopyAndWearObserver(cat_and_wear->mCatID,
  60.245 +																   contents_count,
  60.246 +																   cat_and_wear->mFolderResponded);
  60.247  			gInventory.addObserver(inventoryObserver);
  60.248  		}
  60.249  
  60.250 @@ -2831,7 +2840,7 @@
  60.251  	else if (LLToolDragAndDrop::SOURCE_LIBRARY == source)
  60.252  	{
  60.253  		LLViewerInventoryItem* item = (LLViewerInventoryItem*)inv_item;
  60.254 -		if (item && item->isComplete())
  60.255 +		if (item && item->isFinished())
  60.256  		{
  60.257  			accept = TRUE;
  60.258  			if (drop)
  60.259 @@ -3878,11 +3887,11 @@
  60.260  		LLUUID object_id = mUUID;
  60.261  		LLViewerInventoryItem* item;
  60.262  		item = (LLViewerInventoryItem*)gInventory.getItem(object_id);
  60.263 -		if(item && gInventory.isObjectDescendentOf(object_id, gAgent.getInventoryRootID()))
  60.264 +		if(item && gInventory.isObjectDescendentOf(object_id, gInventory.getRootFolderID()))
  60.265  		{
  60.266  			rez_attachment(item, NULL, replace);
  60.267  		}
  60.268 -		else if(item && item->isComplete())
  60.269 +		else if(item && item->isFinished())
  60.270  		{
  60.271  			// must be in library. copy it to our inventory and put it on.
  60.272  			LLPointer<LLInventoryCallback> cb = new RezAttachmentCallback(0, replace);
  60.273 @@ -3967,11 +3976,11 @@
  60.274  	item = (LLViewerInventoryItem*)gInventory.getItem(object_id);
  60.275  	if (gSavedSettings.getBOOL("PhoenixDoubleClickWearInventoryObjects"))
  60.276  	{
  60.277 -		if(item && gInventory.isObjectDescendentOf(object_id, gAgent.getInventoryRootID()))
  60.278 +		if(item && gInventory.isObjectDescendentOf(object_id, gInventory.getRootFolderID()))
  60.279  		{
  60.280  			rez_attachment(item, NULL);
  60.281  		}
  60.282 -		else if(item && item->isComplete())
  60.283 +		else if(item && item->isFinished())
  60.284  		{
  60.285  			// must be in library. copy it to our inventory and put it on.
  60.286  			LLPointer<LLInventoryCallback> cb = new RezAttachmentCallback(0);
  60.287 @@ -4495,7 +4504,7 @@
  60.288  		}
  60.289  		if (pid.isNull())
  60.290  		{
  60.291 -			pid = gAgent.getInventoryRootID();
  60.292 +			pid = gInventory.getRootFolderID();
  60.293  		}
  60.294  		
  60.295  		LLUUID cat_id = gInventory.createNewCategory(pid, LLFolderType::FT_NONE, name);
  60.296 @@ -4511,6 +4520,8 @@
  60.297  									item->getUUID(), cat_id, std::string(), cb);
  60.298  			}
  60.299  		}
  60.300 +		// BAP fixes a lag in display of created dir.
  60.301 +		gInventory.notifyObservers();
  60.302  	}
  60.303  	else
  60.304  	{
  60.305 @@ -4573,7 +4584,7 @@
  60.306  
  60.307  	// do the fetch
  60.308  	outfit->fetchItems(ids);
  60.309 -	if(outfit->isEverythingComplete())
  60.310 +	if(outfit->isFinished())
  60.311  	{
  60.312  		// everything is already here - call done.
  60.313  		outfit->done();
  60.314 @@ -4594,7 +4605,7 @@
  60.315  	LLInventoryModel::cat_array_t cat_array;
  60.316  	LLInventoryModel::item_array_t item_array;
  60.317  	LLNameCategoryCollector has_name(name);
  60.318 -	gInventory.collectDescendentsIf(gAgent.getInventoryRootID(),
  60.319 +	gInventory.collectDescendentsIf(gInventory.getRootFolderID(),
  60.320  									cat_array,
  60.321  									item_array,
  60.322  									LLInventoryModel::EXCLUDE_TRASH,
  60.323 @@ -4648,7 +4659,7 @@
  60.324  	folders.push_back(category->getUUID());
  60.325  	outfit->fetchDescendents(folders);
  60.326  	inc_busy_count();
  60.327 -	if(outfit->isEverythingComplete())
  60.328 +	if(outfit->isFinished())
  60.329  	{
  60.330  		// everything is already here - call done.
  60.331  		outfit->done();
  60.332 @@ -4882,7 +4893,7 @@
  60.333  
  60.334  	// For each wearable type, find the first instance in the category
  60.335  	// that we recursed through.
  60.336 -	for( S32 i = 0; i < WT_COUNT; i++ )
  60.337 +	for( S32 i = 0; i < LLWearableType::WT_COUNT; i++ )
  60.338  	{
  60.339  		for (LLWearableHoldingPattern::found_list_t::iterator iter = holder->mFoundList.begin();
  60.340  			 iter != holder->mFoundList.end(); ++iter)
  60.341 @@ -4895,18 +4906,6 @@
  60.342  				item = (LLViewerInventoryItem*)gInventory.getLinkedItem(data->mItemID);
  60.343  				if( item && (item->getAssetUUID() == wearable->getID()) )
  60.344  				{
  60.345 -				//RN: after discussing with Brashears, I disabled this code
  60.346 -				//Metadata should reside in the item, not the asset
  60.347 -				//And this code does not handle failed asset uploads properly
  60.348 -//					if(!wearable->isMatchedToInventoryItem(item ))
  60.349 -//					{
  60.350 -//						wearable = gWearableList.createWearableMatchedToInventoryItem( wearable, item );
  60.351 -//						// Now that we have an asset that matches the
  60.352 -//						// item, update the item to point to the new
  60.353 -//						// asset.
  60.354 -//						item->setAssetUUID(wearable->getID());
  60.355 -//						item->updateAssetOnServer();
  60.356 -//					}
  60.357  // [RLVa:KB] - Checked: 2010-09-28 (RLVa-1.1.3b) | Modified: RLVa-1.1.4a
  60.358  					if (!gRlvWearableLocks.canWear(item))
  60.359  					{
  60.360 @@ -5185,7 +5184,7 @@
  60.361  		// must be in the inventory library. copy it to our inventory
  60.362  		// and put it on right away.
  60.363  		LLViewerInventoryItem* item = getItem();
  60.364 -		if(item && item->isComplete())
  60.365 +		if(item && item->isFinished())
  60.366  		{
  60.367  			LLPointer<LLInventoryCallback> cb = new WearOnAvatarCallback();
  60.368  			copy_inventory_item(
  60.369 @@ -5292,7 +5291,7 @@
  60.370  	if(!self->isAgentInventory())
  60.371  	{
  60.372  		LLViewerInventoryItem* item = (LLViewerInventoryItem*)self->getItem();
  60.373 -		if(!item || !item->isComplete()) return FALSE;
  60.374 +		if(!item || !item->isFinished()) return FALSE;
  60.375  	}
  60.376  	return (!gAgent.isWearingItem(self->mUUID));
  60.377  }
  60.378 @@ -5349,21 +5348,6 @@
  60.379  		{
  60.380  			if(item->getAssetUUID() == wearable->getID())
  60.381  			{
  60.382 -				//RN: after discussing with Brashears, I disabled this code
  60.383 -				//Metadata should reside in the item, not the asset
  60.384 -				//And this code does not handle failed asset uploads properly
  60.385 -
  60.386 -//				if(!wearable->isMatchedToInventoryItem(item))
  60.387 -//				{
  60.388 -//					LLWearable* new_wearable = gWearableList.createWearableMatchedToInventoryItem( wearable, item );
  60.389 -//
  60.390 -//					// Now that we have an asset that matches the
  60.391 -//					// item, update the item to point to the new
  60.392 -//					// asset.
  60.393 -//					item->setAssetUUID(new_wearable->getID());
  60.394 -//					item->updateAssetOnServer();
  60.395 -//					wearable = new_wearable;
  60.396 -//				}
  60.397  				gAgent.setWearable(item, wearable);
  60.398  				gInventory.notifyObservers();
  60.399  				//self->getFolderItem()->refreshFromRoot();
  60.400 @@ -5453,10 +5437,12 @@
  60.401  	{
  60.402  		if (gAgent.isWearingItem(item_id))
  60.403  		{
  60.404 -			EWearableType type = wearable->getType();
  60.405 -	
  60.406 -			if( !(type==WT_SHAPE || type==WT_SKIN || type==WT_HAIR || type==WT_EYES) ) //&&
  60.407 -				//!((!gAgent.isTeen()) && ( type==WT_UNDERPANTS || type==WT_UNDERSHIRT )) )
  60.408 +			LLWearableType::EType type = wearable->getType();
  60.409 +
  60.410 +			if (type != LLWearableType::WT_SHAPE && type != LLWearableType::WT_SKIN &&
  60.411 +				type != LLWearableType::WT_HAIR && type != LLWearableType::WT_EYES)
  60.412 +				// && (!gAgent.isTeen() || (type != LLWearableType::WT_UNDERPANTS &&
  60.413 +				//						    type != LLWearableType::WT_UNDERSHIRT)))
  60.414  			{
  60.415  				gAgent.removeWearable( type );
  60.416  			}
    61.1 --- a/indra/newview/llinventorybridge.h	Mon Feb 27 23:28:58 2012 -0800
    61.2 +++ b/indra/newview/llinventorybridge.h	Mon Feb 27 23:59:10 2012 -0800
    61.3 @@ -306,8 +306,8 @@
    61.4  	virtual BOOL isItemMovable();
    61.5  	virtual BOOL isUpToDate() const;
    61.6  
    61.7 -	static void createWearable(LLFolderBridge* bridge, EWearableType type);
    61.8 -	static void createWearable(LLUUID parent_folder_id, EWearableType type);
    61.9 +	static void createWearable(LLFolderBridge* bridge, LLWearableType::EType type);
   61.10 +	static void createWearable(LLUUID parent_folder_id, LLWearableType::EType type);
   61.11  
   61.12  	LLViewerInventoryCategory* getCategory() const;
   61.13  
   61.14 @@ -617,17 +617,21 @@
   61.15  	static void		onRemoveFromAvatarArrived( LLWearable* wearable, void* userdata );
   61.16  
   61.17  protected:
   61.18 -	LLWearableBridge(LLInventoryPanel* inventory, const LLUUID& uuid, LLAssetType::EType asset_type, LLInventoryType::EType inv_type, EWearableType  wearable_type) :
   61.19 -		LLItemBridge(inventory, uuid),
   61.20 -		mAssetType( asset_type ),
   61.21 +	LLWearableBridge(LLInventoryPanel* inventory,
   61.22 +					 const LLUUID& uuid,
   61.23 +					 LLAssetType::EType asset_type,
   61.24 +					 LLInventoryType::EType inv_type,
   61.25 +					 LLWearableType::EType  wearable_type)
   61.26 +	:	LLItemBridge(inventory, uuid),
   61.27 +		mAssetType(asset_type),
   61.28  		mInvType(inv_type),
   61.29  		mWearableType(wearable_type)
   61.30  		{}
   61.31  
   61.32  protected:
   61.33 -	LLAssetType::EType mAssetType;
   61.34 -	LLInventoryType::EType mInvType;
   61.35 -	EWearableType  mWearableType;
   61.36 +	LLAssetType::EType		mAssetType;
   61.37 +	LLInventoryType::EType	mInvType;
   61.38 +	LLWearableType::EType	mWearableType;
   61.39  };
   61.40  
   61.41  class LLLinkItemBridge : public LLItemBridge
    62.1 --- a/indra/newview/llinventoryicon.cpp	Mon Feb 27 23:28:58 2012 -0800
    62.2 +++ b/indra/newview/llinventoryicon.cpp	Mon Feb 27 23:59:10 2012 -0800
    62.3 @@ -37,7 +37,7 @@
    62.4  #include "lldictionary.h"
    62.5  #include "llinventory.h"
    62.6  #include "llui.h"
    62.7 -#include "llwearable.h"
    62.8 +#include "llwearabletype.h"
    62.9  
   62.10  struct IconEntry : public LLDictionaryEntry
   62.11  {
   62.12 @@ -187,28 +187,6 @@
   62.13  
   62.14  LLInventoryIcon::EIconName LLInventoryIcon::assignWearableIcon(U32 misc_flag)
   62.15  {
   62.16 -	const EWearableType wearable_type = (EWearableType)(LLInventoryItem::II_FLAGS_WEARABLES_MASK & misc_flag);
   62.17 -	EIconName res;
   62.18 -	// *TODO: change to use LLWearableType::getIconName() once it is implemented.
   62.19 -	switch (wearable_type)
   62.20 -	{
   62.21 -		case WT_SHAPE:		res = ICONNAME_BODYPART_SHAPE;		break;
   62.22 -		case WT_SKIN:		res = ICONNAME_BODYPART_SKIN;		break;
   62.23 -		case WT_HAIR:		res = ICONNAME_BODYPART_HAIR;		break;
   62.24 -		case WT_EYES:		res = ICONNAME_BODYPART_EYES;		break;
   62.25 -		case WT_SHIRT:		res = ICONNAME_CLOTHING_SHIRT;		break;
   62.26 -		case WT_PANTS:		res = ICONNAME_CLOTHING_PANTS;		break;
   62.27 -		case WT_SHOES:		res = ICONNAME_CLOTHING_SHOES;		break;
   62.28 -		case WT_SOCKS:		res = ICONNAME_CLOTHING_SOCKS;		break;
   62.29 -		case WT_JACKET:		res = ICONNAME_CLOTHING_JACKET;		break;
   62.30 -		case WT_GLOVES:		res = ICONNAME_CLOTHING_GLOVES;		break;
   62.31 -		case WT_UNDERSHIRT:	res = ICONNAME_CLOTHING_UNDERSHIRT;	break;
   62.32 -		case WT_UNDERPANTS:	res = ICONNAME_CLOTHING_UNDERPANTS;	break;
   62.33 -		case WT_SKIRT:		res = ICONNAME_CLOTHING_SKIRT;		break;
   62.34 -		case WT_ALPHA:		res = ICONNAME_CLOTHING_ALPHA;		break;
   62.35 -		case WT_TATTOO:		res = ICONNAME_CLOTHING_TATTOO;		break;
   62.36 -		case WT_PHYSICS:	res = ICONNAME_CLOTHING_PHYSICS;	break;
   62.37 -		default:			res = ICONNAME_NONE;				break;
   62.38 -	}
   62.39 -	return res;
   62.40 +	const LLWearableType::EType wearable_type = LLWearableType::EType(LLInventoryItem::II_FLAGS_WEARABLES_MASK & misc_flag);
   62.41 +	return LLWearableType::getIconName(wearable_type);
   62.42  }
    63.1 --- a/indra/newview/llinventorymodel.cpp	Mon Feb 27 23:28:58 2012 -0800
    63.2 +++ b/indra/newview/llinventorymodel.cpp	Mon Feb 27 23:59:10 2012 -0800
    63.3 @@ -34,55 +34,28 @@
    63.4  
    63.5  #include "llinventorymodel.h"
    63.6  
    63.7 -#include "llassetstorage.h"
    63.8 -#include "llcrc.h"
    63.9  #include "lldir.h"
   63.10 -#include "llsys.h"
   63.11 -#include "llxfermanager.h"
   63.12 -#include "message.h"
   63.13 +#include "llsdutil.h"
   63.14  
   63.15  #include "llagent.h"
   63.16 -#include "llfloater.h"
   63.17 -#include "llfocusmgr.h"
   63.18 +#include "llappviewer.h"
   63.19 +#include "llcallbacklist.h"
   63.20  #include "llinventoryview.h"
   63.21 -#include "llviewerinventory.h"
   63.22 -#include "llviewermessage.h"
   63.23 -#include "llviewerwindow.h"
   63.24 -#include "llviewerregion.h"
   63.25 -#include "llappviewer.h"
   63.26 -#include "lldbstrings.h"
   63.27 -#include "llviewerstats.h"
   63.28  #include "llmutelist.h"
   63.29 -#include "llcallbacklist.h"
   63.30  #include "llpreview.h"
   63.31  #include "llviewercontrol.h"
   63.32  #include "llviewerfoldertype.h"
   63.33 +#include "llviewerinventory.h"
   63.34 +#include "llviewermessage.h"
   63.35 +#include "llviewerregion.h"
   63.36 +#include "llviewerstats.h"
   63.37 +#include "llviewerwindow.h"
   63.38  #include "llvoavatar.h"
   63.39 -#include "llsdutil.h"
   63.40 -#include <deque>
   63.41  
   63.42  // [RLVa:KB]
   63.43  #include "rlvhandler.h"
   63.44  // [/RLVa:KB]
   63.45  
   63.46 -//#define DIFF_INVENTORY_FILES
   63.47 -#ifdef DIFF_INVENTORY_FILES
   63.48 -#include "process.h"
   63.49 -#endif
   63.50 -
   63.51 -BOOL LLInventoryModel::sBackgroundFetchActive = FALSE;
   63.52 -BOOL LLInventoryModel::sAllFoldersFetched = FALSE;
   63.53 -BOOL LLInventoryModel::sFullFetchStarted = FALSE;
   63.54 -S32  LLInventoryModel::sNumFetchRetries = 0;
   63.55 -F32  LLInventoryModel::sMinTimeBetweenFetches = 0.3f;
   63.56 -F32  LLInventoryModel::sMaxTimeBetweenFetches = 10.f;
   63.57 -BOOL LLInventoryModel::sTimelyFetchPending = FALSE;
   63.58 -LLFrameTimer LLInventoryModel::sFetchTimer;
   63.59 -S16 LLInventoryModel::sBulkFetchCount = 0;
   63.60 -
   63.61 -// RN: for some reason, using std::queue in the header file confuses the compiler which thinks it's an xmlrpc_queue
   63.62 -static std::deque<LLUUID> sFetchQueue;
   63.63 -
   63.64  // Increment this if the inventory contents change in a non-backwards-compatible way.
   63.65  // For viewers with link items support, former caches are incorrect.
   63.66  const S32 LLInventoryModel::sCurrentInvCacheVersion = 2;
   63.67 @@ -92,8 +65,6 @@
   63.68  ///----------------------------------------------------------------------------
   63.69  
   63.70  //BOOL decompress_file(const char* src_filename, const char* dst_filename);
   63.71 -const F32 MAX_TIME_FOR_SINGLE_FETCH = 10.f;
   63.72 -const S32 MAX_FETCH_RETRIES = 10;
   63.73  const char CACHE_FORMAT_STRING[] = "%s.inv"; 
   63.74  
   63.75  struct InventoryIDPtrLess
   63.76 @@ -161,8 +132,8 @@
   63.77  LLInventoryModel gInventory;
   63.78  
   63.79  // Default constructor
   63.80 -LLInventoryModel::LLInventoryModel() :
   63.81 -	mModifyMask(LLInventoryObserver::ALL),
   63.82 +LLInventoryModel::LLInventoryModel()
   63.83 +:	mModifyMask(LLInventoryObserver::ALL),
   63.84  	mChangedItemIDs(),
   63.85  	mCategoryMap(),
   63.86  	mItemMap(),
   63.87 @@ -172,6 +143,10 @@
   63.88  	mParentChildCategoryTree(),
   63.89  	mParentChildItemTree(),
   63.90  	mObservers(),
   63.91 +	mRootFolderID(),
   63.92 +	mLibraryRootFolderID(),
   63.93 +	mLibraryOwnerID(),
   63.94 +	mIsNotifyObservers(false),
   63.95  	mIsAgentInvUsable(false)
   63.96  {
   63.97  }
   63.98 @@ -179,6 +154,11 @@
   63.99  // Destroys the object
  63.100  LLInventoryModel::~LLInventoryModel()
  63.101  {
  63.102 +	cleanupInventory();
  63.103 +}
  63.104 +
  63.105 +void LLInventoryModel::cleanupInventory()
  63.106 +{
  63.107  	empty();
  63.108  	// Deleting one observer might erase others from the list, so always pop off the front
  63.109  	while (!mObservers.empty())
  63.110 @@ -257,10 +237,13 @@
  63.111  LLViewerInventoryCategory* LLInventoryModel::getCategory(const LLUUID& id) const
  63.112  {
  63.113  	LLViewerInventoryCategory* category = NULL;
  63.114 -	cat_map_t::const_iterator iter = mCategoryMap.find(id);
  63.115 -	if (iter != mCategoryMap.end())
  63.116 +	if (mCategoryMap.size() > 0)
  63.117  	{
  63.118 -		category = iter->second;
  63.119 +		cat_map_t::const_iterator iter = mCategoryMap.find(id);
  63.120 +		if (iter != mCategoryMap.end())
  63.121 +		{
  63.122 +			category = iter->second;
  63.123 +		}
  63.124  	}
  63.125  	return category;
  63.126  }
  63.127 @@ -319,7 +302,7 @@
  63.128  	LLUUID rv = findCatUUID(t);
  63.129  	if (rv.isNull() && isInventoryUsable() && create_folder)
  63.130  	{
  63.131 -		LLUUID root_id = gAgent.getInventoryRootID();
  63.132 +		LLUUID root_id = gInventory.getRootFolderID();
  63.133  		if (root_id.notNull())
  63.134  		{
  63.135  			rv = createNewCategory(root_id, t, LLStringUtil::null);
  63.136 @@ -339,9 +322,6 @@
  63.137  	{
  63.138  		const LLViewerInventoryCategory *cat = getCategory(parent_id);
  63.139  		if (!cat) break;
  63.140 -		// Ansariel: Original version
  63.141 -		//const LLAssetType::EType folder_type = cat->getPreferredType();
  63.142 -		//if (folder_type != LLAssetType::AT_NONE && folder_type != LLAssetType::AT_ROOT_CATEGORY)
  63.143  		const LLFolderType::EType folder_type = cat->getPreferredType();
  63.144  		if (folder_type != LLFolderType::FT_NONE && folder_type != LLFolderType::FT_ROOT_INVENTORY)
  63.145  		{
  63.146 @@ -356,7 +336,7 @@
  63.147  // preferred type. Returns LLUUID::null if not found.
  63.148  LLUUID LLInventoryModel::findCatUUID(LLFolderType::EType preferred_type)
  63.149  {
  63.150 -	LLUUID root_id = gAgent.getInventoryRootID();
  63.151 +	LLUUID root_id = gInventory.getRootFolderID();
  63.152  	if (preferred_type == LLFolderType::FT_ROOT_INVENTORY)
  63.153  	{
  63.154  		return root_id;
  63.155 @@ -382,7 +362,7 @@
  63.156  
  63.157  LLUUID LLInventoryModel::findCategoryByName(std::string name)
  63.158  {
  63.159 -	LLUUID root_id = gAgent.getInventoryRootID();
  63.160 +	LLUUID root_id = gInventory.getRootFolderID();
  63.161  	if(root_id.notNull())
  63.162  	{
  63.163  		cat_array_t* cats = NULL;
  63.164 @@ -402,13 +382,64 @@
  63.165  	return LLUUID::null;
  63.166  }
  63.167  
  63.168 +class LLCreateInventoryCategoryResponder : public LLHTTPClient::Responder
  63.169 +{
  63.170 +public:
  63.171 +	LLCreateInventoryCategoryResponder(LLInventoryModel* model, 
  63.172 +									   void (*callback)(const LLSD&, void*),
  63.173 +									   void* user_data)
  63.174 +	:	mModel(model),
  63.175 +		mCallback(callback), 
  63.176 +		mData(user_data) 
  63.177 +	{
  63.178 +	}
  63.179 +
  63.180 +	virtual void error(U32 status, const std::string& reason)
  63.181 +	{
  63.182 +		llwarns << "CreateInventoryCategory failed. status = " << status
  63.183 +				<< ", reason = \"" << reason << "\"" << llendl;
  63.184 +	}
  63.185 +
  63.186 +	virtual void result(const LLSD& content)
  63.187 +	{
  63.188 +		// Server has created folder.
  63.189 +
  63.190 +		LLUUID category_id = content["folder_id"].asUUID();
  63.191 +
  63.192 +		// Add the category to the internal representation
  63.193 +		LLPointer<LLViewerInventoryCategory> cat;
  63.194 +		cat = new LLViewerInventoryCategory(category_id,
  63.195 +											content["parent_id"].asUUID(),
  63.196 +											(LLFolderType::EType)content["type"].asInteger(),
  63.197 +											content["name"].asString(), 
  63.198 +											gAgent.getID());
  63.199 +		cat->setVersion(LLViewerInventoryCategory::VERSION_INITIAL);
  63.200 +		cat->setDescendentCount(0);
  63.201 +		LLInventoryModel::LLCategoryUpdate update(cat->getParentUUID(), 1);
  63.202 +		mModel->accountForUpdate(update);
  63.203 +		mModel->updateCategory(cat);
  63.204 +
  63.205 +		if (mCallback && mData)
  63.206 +		{
  63.207 +			mCallback(content, mData);
  63.208 +		}
  63.209 +	}
  63.210 +
  63.211 +private:
  63.212 +	void (*mCallback)(const LLSD&, void*);
  63.213 +	void* mData;
  63.214 +	LLInventoryModel* mModel;
  63.215 +};
  63.216 +
  63.217  // Convenience function to create a new category. You could call
  63.218  // updateCategory() with a newly generated UUID category, but this
  63.219  // version will take care of details like what the name should be
  63.220  // based on preferred type. Returns the UUID of the new category.
  63.221  LLUUID LLInventoryModel::createNewCategory(const LLUUID& parent_id,
  63.222  										   LLFolderType::EType preferred_type,
  63.223 -										   const std::string& pname)
  63.224 +										   const std::string& pname,
  63.225 +										   void (*callback)(const LLSD&, void*),
  63.226 +										   void* user_data)
  63.227  {
  63.228  	LLUUID id;
  63.229  	if(!isInventoryUsable())
  63.230 @@ -434,6 +465,37 @@
  63.231  		name.assign(LLViewerFolderType::lookupNewCategoryName(preferred_type));
  63.232  	}
  63.233  
  63.234 +	if (callback && user_data)  // callback required for acked message.
  63.235 +	{
  63.236 +		LLViewerRegion* viewer_region = gAgent.getRegion();
  63.237 +		std::string url;
  63.238 +		if (viewer_region)
  63.239 +		{
  63.240 +			url = viewer_region->getCapability("CreateInventoryCategory");
  63.241 +		}
  63.242 +	
  63.243 +		if (!url.empty())
  63.244 +		{
  63.245 +			LL_DEBUGS("Inventory") << "Using the CreateInventoryCategory capability."
  63.246 +								   << LL_ENDL;
  63.247 +			// Let's use the new capability.
  63.248 +			LLSD request, body;
  63.249 +			body["folder_id"] = id;
  63.250 +			body["parent_id"] = parent_id;
  63.251 +			body["type"] = (LLSD::Integer) preferred_type;
  63.252 +			body["name"] = name;
  63.253 +
  63.254 +			request["message"] = "CreateInventoryCategory";
  63.255 +			request["payload"] = body;
  63.256 +
  63.257 +			LLHTTPClient::post(url, body,
  63.258 +							   new LLCreateInventoryCategoryResponder(this,
  63.259 +																	  callback,
  63.260 +																	  user_data));
  63.261 +			return LLUUID::null;
  63.262 +		}
  63.263 +	}
  63.264 +
  63.265  	// Add the category to the internal representation
  63.266  	LLPointer<LLViewerInventoryCategory> cat =
  63.267  		new LLViewerInventoryCategory(id, parent_id, preferred_type, name, gAgent.getID());
  63.268 @@ -579,7 +641,7 @@
  63.269  	LLInventoryModel::cat_array_t cat_array;
  63.270  	LLInventoryModel::item_array_t item_array;
  63.271  	LLLinkedItemIDMatches is_linked_item_match(object_id);
  63.272 -	collectDescendentsIf(gAgent.getInventoryRootID(),
  63.273 +	collectDescendentsIf(gInventory.getRootFolderID(),
  63.274  						 cat_array,
  63.275  						 item_array,
  63.276  						 LLInventoryModel::INCLUDE_TRASH,
  63.277 @@ -629,7 +691,7 @@
  63.278  	item_array_t items;
  63.279  	LLInventoryModel::cat_array_t cat_array;
  63.280  	LLLinkedItemIDMatches is_linked_item_match(id);
  63.281 -	collectDescendentsIf((start_folder_id == LLUUID::null ? gAgent.getInventoryRootID() : start_folder_id),
  63.282 +	collectDescendentsIf((start_folder_id == LLUUID::null ? gInventory.getRootFolderID() : start_folder_id),
  63.283  						 cat_array,
  63.284  						 items,
  63.285  						 LLInventoryModel::INCLUDE_TRASH,
  63.286 @@ -658,14 +720,9 @@
  63.287  	path.append(temp);
  63.288  }
  63.289  
  63.290 -bool LLInventoryModel::isInventoryUsable()
  63.291 +bool LLInventoryModel::isInventoryUsable() const
  63.292  {
  63.293 -	bool result = false;
  63.294 -	if(gAgent.getInventoryRootID().notNull() && mIsAgentInvUsable)
  63.295 -	{
  63.296 -		result = true;
  63.297 -	}
  63.298 -	return result;	
  63.299 +	return gInventory.getRootFolderID().notNull() && mIsAgentInvUsable;
  63.300  }
  63.301  
  63.302  // Calling this method with an inventory item will either change an
  63.303 @@ -1147,11 +1204,17 @@
  63.304  	return mObservers.find(observer) != mObservers.end();
  63.305  }
  63.306  
  63.307 -// Call this method when it's time to update everyone on a new state,
  63.308 -// by default, the inventory model will not update observers
  63.309 -// automatically.
  63.310 -// The optional argument 'service_name' is used by Agent Inventory Service [DEV-20328]
  63.311 -void LLInventoryModel::notifyObservers(const std::string service_name)
  63.312 +void LLInventoryModel::idleNotifyObservers()
  63.313 +{
  63.314 +	if (mModifyMask == LLInventoryObserver::NONE && (mChangedItemIDs.size() == 0))
  63.315 +	{
  63.316 +		return;
  63.317 +	}
  63.318 +	notifyObservers();
  63.319 +}
  63.320 +
  63.321 +// Call this method when it's time to update everyone on a new state.
  63.322 +void LLInventoryModel::notifyObservers()
  63.323  {
  63.324  	if (mIsNotifyObservers)
  63.325  	{
  63.326 @@ -1162,29 +1225,21 @@
  63.327  		return;
  63.328  	}
  63.329  
  63.330 -	mIsNotifyObservers = TRUE;
  63.331 +	mIsNotifyObservers = true;
  63.332  	for (observer_list_t::iterator iter = mObservers.begin();
  63.333  		 iter != mObservers.end(); )
  63.334  	{
  63.335  		LLInventoryObserver* observer = *iter;
  63.336  		
  63.337 -		if (service_name.empty())
  63.338 -		{
  63.339 -			observer->changed(mModifyMask);
  63.340 -		}
  63.341 -		else
  63.342 -		{
  63.343 -			observer->mMessageName = service_name;
  63.344 -			observer->changed(mModifyMask);
  63.345 -		}
  63.346 +		observer->changed(mModifyMask);
  63.347  
  63.348 -		// safe way to incrament since changed may delete entries! (@!##%@!@&*!)
  63.349 +		// safe way to increment since changed may delete entries! (@!##%@!@&*!)
  63.350  		iter = mObservers.upper_bound(observer); 
  63.351  	}
  63.352  
  63.353  	mModifyMask = LLInventoryObserver::NONE;
  63.354  	mChangedItemIDs.clear();
  63.355 -	mIsNotifyObservers = FALSE;
  63.356 +	mIsNotifyObservers = false;
  63.357  }
  63.358  
  63.359  // store flag for change
  63.360 @@ -1213,10 +1268,7 @@
  63.361  	}
  63.362  }
  63.363  
  63.364 -//If we get back a normal response, handle it here
  63.365 -// Note: this is the responder used in "fetchInventory" cap, 
  63.366 -// this is not responder for "WebFetchInventoryDescendents" or "agent/inventory" cap
  63.367 -
  63.368 +// If we get back a normal response, handle it here
  63.369  void  LLInventoryModel::fetchInventoryResponder::result(const LLSD& content)
  63.370  {	
  63.371  	start_new_inventory_observer();
  63.372 @@ -1277,16 +1329,15 @@
  63.373  	{
  63.374  		changes |= gInventory.updateItem(*it);
  63.375  	}
  63.376 -	gInventory.notifyObservers("fetchinventory");
  63.377 +	gInventory.notifyObservers();
  63.378  	gViewerWindow->getWindow()->decBusyCount();
  63.379  }
  63.380  
  63.381  //If we get back an error (not found, etc...), handle it here
  63.382  void LLInventoryModel::fetchInventoryResponder::error(U32 status, const std::string& reason)
  63.383  {
  63.384 -	LL_INFOS("Inventory") << "fetchInventory::error "
  63.385 -		<< status << ": " << reason << LL_ENDL;
  63.386 -	gInventory.notifyObservers("fetchinventory");
  63.387 +	llinfos << "fetchInventory::error " << status << ": " << reason << llendl;
  63.388 +	gInventory.notifyObservers();
  63.389  }
  63.390  
  63.391  void LLInventoryModel::fetchDescendentsOf(const LLUUID& folder_id)
  63.392 @@ -1314,508 +1365,14 @@
  63.393  	//{
  63.394  	//	known_descendents += items->count();
  63.395  	//}
  63.396 -	if(!cat->fetchDescendents())
  63.397 +	if (!cat->fetch())
  63.398  	{
  63.399  		LL_DEBUGS("Inventory") << "Not fetching descendents" <<  LL_ENDL;
  63.400  	}
  63.401  }
  63.402  
  63.403 -//Initialize statics.
  63.404 -bool LLInventoryModel::isBulkFetchProcessingComplete()
  63.405 -{
  63.406 -	return ( (sFetchQueue.empty() 
  63.407 -			&& sBulkFetchCount<=0)  ?  TRUE : FALSE ) ;
  63.408 -}
  63.409 -
  63.410 -class fetchDescendentsResponder: public LLHTTPClient::Responder
  63.411 -{
  63.412 -	public:
  63.413 -		fetchDescendentsResponder(const LLSD& request_sd) : mRequestSD(request_sd) {};
  63.414 -		//fetchDescendentsResponder() {};
  63.415 -		void result(const LLSD& content);
  63.416 -		void error(U32 status, const std::string& reason);
  63.417 -	public:
  63.418 -		typedef std::vector<LLViewerInventoryCategory*> folder_ref_t;
  63.419 -	protected:
  63.420 -		LLSD mRequestSD;
  63.421 -};
  63.422 -
  63.423 -//If we get back a normal response, handle it here
  63.424 -// Note: this is the handler for WebFetchInventoryDescendents and agent/inventory caps
  63.425 -void  fetchDescendentsResponder::result(const LLSD& content)
  63.426 -{
  63.427 -	LL_DEBUGS("Inventory") << " fetch descendents got " << ll_pretty_print_sd(content) << LL_ENDL; // OGPX
  63.428 -	if (content.has("folders"))	
  63.429 -	{
  63.430 -		for (LLSD::array_const_iterator folder_it = content["folders"].beginArray();
  63.431 -			 folder_it != content["folders"].endArray(); ++folder_it)
  63.432 -		{	
  63.433 -			LLSD folder_sd = *folder_it;		
  63.434 -
  63.435 -			//LLUUID agent_id = folder_sd["agent_id"];
  63.436 -			//if(agent_id != gAgent.getID())	//This should never happen.
  63.437 -			//{
  63.438 -			//	llwarns << "Got a UpdateInventoryItem for the wrong agent."
  63.439 -			//			<< llendl;
  63.440 -			//	break;
  63.441 -			//}
  63.442 -
  63.443 -			LLUUID parent_id = folder_sd["folder_id"];
  63.444 -			LLUUID owner_id = folder_sd["owner_id"];
  63.445 -			S32    version  = (S32)folder_sd["version"].asInteger();
  63.446 -			S32    descendents = (S32)folder_sd["descendents"].asInteger();
  63.447 -			LLPointer<LLViewerInventoryCategory> tcategory = new LLViewerInventoryCategory(owner_id);
  63.448 -
  63.449 -            if (parent_id.isNull())
  63.450 -            {
  63.451 -			    LLPointer<LLViewerInventoryItem> titem = new LLViewerInventoryItem;
  63.452 -			    for(LLSD::array_const_iterator item_it = folder_sd["items"].beginArray();
  63.453 -				    item_it != folder_sd["items"].endArray();
  63.454 -				    ++item_it)
  63.455 -			    {	
  63.456 -                    const LLUUID lost_uuid = gInventory.findCategoryUUIDForType(LLFolderType::FT_LOST_AND_FOUND);
  63.457 -                    if (lost_uuid.notNull())
  63.458 -                    {
  63.459 -				        LLSD item = *item_it;
  63.460 -				        titem->unpackMessage(item);
  63.461 -
  63.462 -                        LLInventoryModel::update_list_t update;
  63.463 -                        LLInventoryModel::LLCategoryUpdate new_folder(lost_uuid, 1);
  63.464 -                        update.push_back(new_folder);
  63.465 -                        gInventory.accountForUpdate(update);
  63.466 -
  63.467 -                        titem->setParent(lost_uuid);
  63.468 -                        titem->updateParentOnServer(FALSE);
  63.469 -                        gInventory.updateItem(titem);
  63.470 -                        gInventory.notifyObservers("fetchDescendents");
  63.471 -                        
  63.472 -                    }
  63.473 -                }
  63.474 -            }
  63.475 -
  63.476 -	        LLViewerInventoryCategory* pcat = gInventory.getCategory(parent_id);
  63.477 -			if (!pcat)
  63.478 -			{
  63.479 -				continue;
  63.480 -			}
  63.481 -
  63.482 -			for (LLSD::array_const_iterator category_it = folder_sd["categories"].beginArray();
  63.483 -				 category_it != folder_sd["categories"].endArray(); ++category_it)
  63.484 -			{
  63.485 -				LLSD category = *category_it;
  63.486 -				tcategory->fromLLSD(category); 
  63.487 -
  63.488 -				if (LLInventoryModel::sFullFetchStarted)
  63.489 -				{
  63.490 -					sFetchQueue.push_back(tcategory->getUUID());
  63.491 -				}
  63.492 -				else if ( !gInventory.isCategoryComplete(tcategory->getUUID()))
  63.493 -				{
  63.494 -					gInventory.updateCategory(tcategory);
  63.495 -				}
  63.496 -			}
  63.497 -
  63.498 -			LLPointer<LLViewerInventoryItem> titem = new LLViewerInventoryItem;
  63.499 -			for (LLSD::array_const_iterator item_it = folder_sd["items"].beginArray();
  63.500 -				item_it != folder_sd["items"].endArray();
  63.501 -				++item_it)
  63.502 -			{	
  63.503 -				LLSD item = *item_it;
  63.504 -				titem->unpackMessage(item);
  63.505 -				gInventory.updateItem(titem);
  63.506 -			}
  63.507 -
  63.508 -			// set version and descendentcount according to message.
  63.509 -			LLViewerInventoryCategory* cat = gInventory.getCategory(parent_id);
  63.510 -			if (cat)
  63.511 -			{
  63.512 -				cat->setVersion(version);
  63.513 -				cat->setDescendentCount(descendents);
  63.514 -			}
  63.515 -		}
  63.516 -	}
  63.517 -
  63.518 -	if (content.has("bad_folders"))
  63.519 -	{
  63.520 -		for(LLSD::array_const_iterator folder_it = content["bad_folders"].beginArray();
  63.521 -			folder_it != content["bad_folders"].endArray();
  63.522 -			++folder_it)
  63.523 -		{	
  63.524 -			LLSD folder_sd = *folder_it;
  63.525 -
  63.526 -			//These folders failed on the dataserver.  We probably don't want to retry them.
  63.527 -			LL_INFOS("Inventory") << "Folder " << folder_sd["folder_id"].asString() 
  63.528 -					<< "Error: " << folder_sd["error"].asString() << LL_ENDL;
  63.529 -		}
  63.530 -	}
  63.531 -
  63.532 -	LLInventoryModel::incrBulkFetch(-1);
  63.533 -
  63.534 -	if (LLInventoryModel::isBulkFetchProcessingComplete())
  63.535 -	{
  63.536 -		LL_DEBUGS("Inventory") << "Inventory fetch completed" << LL_ENDL;
  63.537 -		if (LLInventoryModel::sFullFetchStarted)
  63.538 -		{
  63.539 -			LLInventoryModel::sAllFoldersFetched = TRUE;
  63.540 -		}
  63.541 -		LLInventoryModel::stopBackgroundFetch();
  63.542 -	}
  63.543 -
  63.544 -	gInventory.notifyObservers("fetchDescendents");
  63.545 -}
  63.546 -
  63.547 -//If we get back an error (not found, etc...), handle it here
  63.548 -void fetchDescendentsResponder::error(U32 status, const std::string& reason)
  63.549 -{
  63.550 -	LL_INFOS("Inventory") << "fetchDescendentsResponder::error " << status << ": " << reason << LL_ENDL;
  63.551 -
  63.552 -	LLInventoryModel::incrBulkFetch(-1);
  63.553 -
  63.554 -	if (status==499)		//timed out.  Let's be awesome!
  63.555 -	{
  63.556 -		for(LLSD::array_const_iterator folder_it = mRequestSD["folders"].beginArray();
  63.557 -			folder_it != mRequestSD["folders"].endArray();
  63.558 -			++folder_it)
  63.559 -		{	
  63.560 -			LLSD folder_sd = *folder_it;
  63.561 -			LLUUID folder_id = folder_sd["folder_id"];
  63.562 -			sFetchQueue.push_front(folder_id);
  63.563 -		}
  63.564 -	}
  63.565 -	else
  63.566 -	{
  63.567 -		if (LLInventoryModel::isBulkFetchProcessingComplete())
  63.568 -		{
  63.569 -			if (LLInventoryModel::sFullFetchStarted)
  63.570 -			{
  63.571 -				LLInventoryModel::sAllFoldersFetched = TRUE;
  63.572 -			}
  63.573 -			LLInventoryModel::stopBackgroundFetch();
  63.574 -		}
  63.575 -	}
  63.576 -	gInventory.notifyObservers("fetchDescendents");
  63.577 -}
  63.578 -
  63.579 -//static   Bundle up a bunch of requests to send all at once.
  63.580 -void LLInventoryModel::bulkFetch(std::string url)
  63.581 -{
  63.582 -	//Background fetch is called from gIdleCallbacks in a loop until background fetch is stopped.
  63.583 -	//If there are items in sFetchQueue, we want to check the time since the last bulkFetch was 
  63.584 -	//sent.  If it exceeds our retry time, go ahead and fire off another batch.  
  63.585 -	//Stopbackgroundfetch will be run from the Responder instead of here.  
  63.586 -
  63.587 -	S16 max_concurrent_fetches=8;
  63.588 -	F32 new_min_time = 0.5f;			//HACK!  Clean this up when old code goes away entirely.
  63.589 -	if (sMinTimeBetweenFetches < new_min_time) sMinTimeBetweenFetches=new_min_time;  //HACK!  See above.
  63.590 -	
  63.591 -	if (gDisconnected || sBulkFetchCount > max_concurrent_fetches ||
  63.592 -		sFetchTimer.getElapsedTimeF32() < sMinTimeBetweenFetches)
  63.593 -	{
  63.594 -		return; // just bail if we are disconnected.
  63.595 -	}	
  63.596 -
  63.597 -	U32 folder_count=0;
  63.598 -	U32 max_batch_size=5;
  63.599 -
  63.600 -	U32 sort_order = gSavedSettings.getU32("InventorySortOrder") & 0x1;
  63.601 -
  63.602 -	LLSD body;
  63.603 -	LLSD body_lib;
  63.604 -	while( !(sFetchQueue.empty() ) && (folder_count < max_batch_size) )
  63.605 -	{
  63.606 -        if (sFetchQueue.front().isNull()) //DEV-17797
  63.607 -        {
  63.608 -			LLSD folder_sd;
  63.609 -			folder_sd["folder_id"]		= LLUUID::null.asString();
  63.610 -			folder_sd["owner_id"]		= gAgent.getID();
  63.611 -			folder_sd["sort_order"]		= (LLSD::Integer)sort_order;
  63.612 -			folder_sd["fetch_folders"]	= (LLSD::Boolean)FALSE;
  63.613 -			folder_sd["fetch_items"]	= (LLSD::Boolean)TRUE;
  63.614 -			body["folders"].append(folder_sd);
  63.615 -            folder_count++;
  63.616 -        }
  63.617 -        else
  63.618 -        {
  63.619 -		    LLViewerInventoryCategory* cat = gInventory.getCategory(sFetchQueue.front());
  63.620 -		    if (cat)
  63.621 -		    {
  63.622 -			    if (LLViewerInventoryCategory::VERSION_UNKNOWN == cat->getVersion())
  63.623 -			    {
  63.624 -				    LLSD folder_sd;
  63.625 -				    folder_sd["folder_id"]		= cat->getUUID();
  63.626 -				    folder_sd["owner_id"]		= cat->getOwnerID();
  63.627 -				    folder_sd["sort_order"]		= (LLSD::Integer)sort_order;
  63.628 -				    folder_sd["fetch_folders"]	= TRUE; //(LLSD::Boolean)sFullFetchStarted;
  63.629 -				    folder_sd["fetch_items"]	= (LLSD::Boolean)TRUE;
  63.630 -
  63.631 -					LL_DEBUGS("Inventory") << " fetching "<<cat->getUUID()<<" with cat owner "<<cat->getOwnerID()<<" and agent" << gAgent.getID() << LL_ENDL;
  63.632 -				    //OGPX if (ALEXANDRIA_LINDEN_ID == cat->getOwnerID())
  63.633 -					// for OGP it really doesnt make sense to have the decision about whether to fetch
  63.634 -					// from the library or user cap be determined by a hard coded UUID. 
  63.635 -					// if it isnt an item that belongs to the agent, then fetch from the library
  63.636 -					if (gAgent.getID() != cat->getOwnerID()) //if i am not the owner, it must be in the library
  63.637 -					    body_lib["folders"].append(folder_sd);
  63.638 -				    else
  63.639 -					    body["folders"].append(folder_sd);
  63.640 -				    folder_count++;
  63.641 -			    }
  63.642 -			    if (sFullFetchStarted)
  63.643 -			    {	//Already have this folder but append child folders to list.
  63.644 -				    // add all children to queue
  63.645 -				    parent_cat_map_t::iterator cat_it = gInventory.mParentChildCategoryTree.find(cat->getUUID());
  63.646 -				    if (cat_it != gInventory.mParentChildCategoryTree.end())
  63.647 -				    {
  63.648 -					    cat_array_t* child_categories = cat_it->second;
  63.649 -
  63.650 -					    for (S32 child_num = 0; child_num < child_categories->count(); child_num++)
  63.651 -					    {
  63.652 -						    sFetchQueue.push_back(child_categories->get(child_num)->getUUID());
  63.653 -					    }
  63.654 -				    }
  63.655 -    
  63.656 -			    }
  63.657 -		    }
  63.658 -        }
  63.659 -		sFetchQueue.pop_front();
  63.660 -	}
  63.661 -
  63.662 -	if (folder_count > 0)
  63.663 -	{
  63.664 -		sBulkFetchCount++;
  63.665 -		if (body["folders"].size())
  63.666 -		{
  63.667 -			LL_DEBUGS("Inventory") << " fetch descendents post to " << url << ": " << ll_pretty_print_sd(body) << LL_ENDL; // OGPX
  63.668 -			LLHTTPClient::post(url, body, new fetchDescendentsResponder(body),300.0);
  63.669 -		}
  63.670 -		if (body_lib["folders"].size())
  63.671 -		{
  63.672 -			std::string url_lib;
  63.673 -			if (!gSavedSettings.getBOOL("OpenGridProtocol"))
  63.674 -			{
  63.675 -				url_lib = gAgent.getRegion()->getCapability("FetchLibDescendents");
  63.676 -			}
  63.677 -			else
  63.678 -			{
  63.679 -				url_lib = gAgent.getCapability("agent/inventory_library");
  63.680 -			}
  63.681 -			LL_DEBUGS("Inventory") << " fetch descendents lib post: " << ll_pretty_print_sd(body_lib) << LL_ENDL; // OGPX
  63.682 -			LLHTTPClient::post(url_lib, body_lib, new fetchDescendentsResponder(body_lib),300.0);
  63.683 -		}
  63.684 -		sFetchTimer.reset();
  63.685 -	}
  63.686 -	else if (isBulkFetchProcessingComplete())
  63.687 -	{
  63.688 -		if (sFullFetchStarted)
  63.689 -		{
  63.690 -			sAllFoldersFetched = TRUE;
  63.691 -		}
  63.692 -		stopBackgroundFetch();
  63.693 -	}	
  63.694 -}
  63.695 -
  63.696 -// static
  63.697 -bool LLInventoryModel::isEverythingFetched()
  63.698 -{
  63.699 -	return (sAllFoldersFetched ? true : false);
  63.700 -}
  63.701 -
  63.702 -//static
  63.703 -BOOL LLInventoryModel::backgroundFetchActive()
  63.704 -{
  63.705 -	return sBackgroundFetchActive;
  63.706 -}
  63.707 -
  63.708 -//static 
  63.709 -void LLInventoryModel::startBackgroundFetch(const LLUUID& cat_id)
  63.710 -{
  63.711 -	if (!sAllFoldersFetched)
  63.712 -	{
  63.713 -		sBackgroundFetchActive = TRUE;
  63.714 -		if (cat_id.isNull())
  63.715 -		{
  63.716 -			if (!sFullFetchStarted)
  63.717 -			{
  63.718 -				sFullFetchStarted = TRUE;
  63.719 -				sFetchQueue.push_back(gInventoryLibraryRoot);
  63.720 -				sFetchQueue.push_back(gAgent.getInventoryRootID());
  63.721 -				gIdleCallbacks.addFunction(&LLInventoryModel::backgroundFetch, NULL);
  63.722 -			}
  63.723 -		}
  63.724 -		else
  63.725 -		{
  63.726 -			// specific folder requests go to front of queue
  63.727 -			if (sFetchQueue.empty() || sFetchQueue.front() != cat_id)
  63.728 -			{
  63.729 -				sFetchQueue.push_front(cat_id);
  63.730 -				gIdleCallbacks.addFunction(&LLInventoryModel::backgroundFetch, NULL);
  63.731 -			}
  63.732 -		}
  63.733 -	}
  63.734 -}
  63.735 -
  63.736 -//static
  63.737 -void LLInventoryModel::findLostItems()
  63.738 -{
  63.739 -	sBackgroundFetchActive = TRUE;
  63.740 -    sFetchQueue.push_back(LLUUID::null);
  63.741 -    gIdleCallbacks.addFunction(&LLInventoryModel::backgroundFetch, NULL);
  63.742 -}
  63.743 -
  63.744 -//static
  63.745 -void LLInventoryModel::stopBackgroundFetch()
  63.746 -{
  63.747 -	if (sBackgroundFetchActive)
  63.748 -	{
  63.749 -		sBackgroundFetchActive = FALSE;
  63.750 -		gIdleCallbacks.deleteFunction(&LLInventoryModel::backgroundFetch, NULL);
  63.751 -		sBulkFetchCount=0;
  63.752 -		sMinTimeBetweenFetches=0.0f;
  63.753 -//		sFullFetchStarted=FALSE;
  63.754 -	}
  63.755 -}
  63.756 -
  63.757 -//static 
  63.758 -void LLInventoryModel::backgroundFetch(void*)
  63.759 -{
  63.760 -	if (sBackgroundFetchActive && gAgent.getRegion())
  63.761 -	{
  63.762 -	    // OGPX : agent/inventory is on gAgent for OGPX. I check both, and give
  63.763 -		// ...preference to the one on gAgent. That way the existing non OGP path will remain the same. 
  63.764 -        // Q: How *should* I handle deciding which cap to use? Maybe I don't want to trust fetching inventory from the region
  63.765 -		// OGPX TODO: manage getting caps from more than one service securely. 
  63.766 -		std::string url = gAgent.getCapability("agent/inventory"); // was WebFetchInventoryDescendents
  63.767 -		if (url.empty()) 
  63.768 -		{
  63.769 -			// OGPX : if we didn't get an agent/inventory cap from the Agent Domain, check to see if there was one on the region
  63.770 -			// If we'll be using the capability, we'll be sending batches and the background thing isn't as important.
  63.771 -			// OGPX TODO: this should change when Capabilities are refactored. 
  63.772 -			// ... this is a trust/security issue. if we have an agent/inventory from the Agent Domain, 
  63.773 -			// maybe we shouldn't trust WFID from region.
  63.774 -			LL_DEBUGS("Inventory") << " no agent/inventory not on AD, checking fallback to region " << LL_ENDL; 
  63.775 -			url = gAgent.getRegion()->getCapability("WebFetchInventoryDescendents"); 
  63.776 -		}
  63.777 -		if (!url.empty()) 
  63.778 -		{
  63.779 -			bulkFetch(url);
  63.780 -			return;
  63.781 -		}
  63.782 -
  63.783 -		// If there was no HTTP cap to fetch with, then do the UDP fetch
  63.784 -		//DEPRECATED OLD CODE FOLLOWS.
  63.785 -		// no more categories to fetch, stop fetch process
  63.786 -		if (sFetchQueue.empty())
  63.787 -		{
  63.788 -			LL_DEBUGS("Inventory") << "Inventory fetch completed" << LL_ENDL;
  63.789 -			if (sFullFetchStarted)
  63.790 -			{
  63.791 -				sAllFoldersFetched = TRUE;
  63.792 -			}
  63.793 -			stopBackgroundFetch();
  63.794 -			return;
  63.795 -		}
  63.796 -
  63.797 -		F32 fast_fetch_time = lerp(sMinTimeBetweenFetches, sMaxTimeBetweenFetches, 0.1f);
  63.798 -		F32 slow_fetch_time = lerp(sMinTimeBetweenFetches, sMaxTimeBetweenFetches, 0.5f);
  63.799 -		if (sTimelyFetchPending && sFetchTimer.getElapsedTimeF32() > slow_fetch_time)
  63.800 -		{
  63.801 -			// double timeouts on failure
  63.802 -			sMinTimeBetweenFetches = llmin(sMinTimeBetweenFetches * 2.f, 10.f);
  63.803 -			sMaxTimeBetweenFetches = llmin(sMaxTimeBetweenFetches * 2.f, 120.f);
  63.804 -			LL_DEBUGS("Inventory") << "Inventory fetch times grown to (" << sMinTimeBetweenFetches << ", " << sMaxTimeBetweenFetches << ")" << LL_ENDL;
  63.805 -			// fetch is no longer considered "timely" although we will wait for full time-out
  63.806 -			sTimelyFetchPending = FALSE;
  63.807 -		}
  63.808 -
  63.809 -		while(1)
  63.810 -		{
  63.811 -			if (gDisconnected || sFetchQueue.empty())
  63.812 -			{
  63.813 -				break;
  63.814 -			}
  63.815 -
  63.816 -			LLViewerInventoryCategory* cat = gInventory.getCategory(sFetchQueue.front());
  63.817 -
  63.818 -			// category has been deleted, remove from queue.
  63.819 -			if (!cat)
  63.820 -			{
  63.821 -				sFetchQueue.pop_front();
  63.822 -				continue;
  63.823 -			}
  63.824 -
  63.825 -			if (sFetchTimer.getElapsedTimeF32() > sMinTimeBetweenFetches && 
  63.826 -				LLViewerInventoryCategory::VERSION_UNKNOWN == cat->getVersion())
  63.827 -			{
  63.828 -				// category exists but has no children yet, fetch the descendants
  63.829 -				// for now, just request every time and rely on retry timer to throttle
  63.830 -				if (cat->fetchDescendents())
  63.831 -				{
  63.832 -					sFetchTimer.reset();
  63.833 -					sTimelyFetchPending = TRUE;
  63.834 -				}
  63.835 -				else
  63.836 -				{
  63.837 -					//  The catagory also tracks if it has expired and here it says it hasn't
  63.838 -					//  yet.  Get out of here because nothing is going to happen until we
  63.839 -					//  update the timers.
  63.840 -					break;
  63.841 -				}
  63.842 -			}
  63.843 -			// do I have all my children?
  63.844 -			else if (gInventory.isCategoryComplete(sFetchQueue.front()))
  63.845 -			{
  63.846 -				// finished with this category, remove from queue
  63.847 -				sFetchQueue.pop_front();
  63.848 -
  63.849 -				// add all children to queue
  63.850 -				parent_cat_map_t::iterator cat_it = gInventory.mParentChildCategoryTree.find(cat->getUUID());
  63.851 -				if (cat_it != gInventory.mParentChildCategoryTree.end())
  63.852 -				{
  63.853 -					cat_array_t* child_categories = cat_it->second;
  63.854 -
  63.855 -					for (S32 child_num = 0; child_num < child_categories->count(); child_num++)
  63.856 -					{
  63.857 -						sFetchQueue.push_back(child_categories->get(child_num)->getUUID());
  63.858 -					}
  63.859 -				}
  63.860 -
  63.861 -				// we received a response in less than the fast time
  63.862 -				if (sTimelyFetchPending && sFetchTimer.getElapsedTimeF32() < fast_fetch_time)
  63.863 -				{
  63.864 -					// shrink timeouts based on success
  63.865 -					sMinTimeBetweenFetches = llmax(sMinTimeBetweenFetches * 0.8f, 0.3f);
  63.866 -					sMaxTimeBetweenFetches = llmax(sMaxTimeBetweenFetches * 0.8f, 10.f);
  63.867 -					//llinfos << "Inventory fetch times shrunk to (" << sMinTimeBetweenFetches << ", " << sMaxTimeBetweenFetches << ")" << llendl;
  63.868 -				}
  63.869 -
  63.870 -				sTimelyFetchPending = FALSE;
  63.871 -				continue;
  63.872 -			}
  63.873 -			else if (sFetchTimer.getElapsedTimeF32() > sMaxTimeBetweenFetches)
  63.874 -			{
  63.875 -				// received first packet, but our num descendants does not match db's num descendants
  63.876 -				// so try again later
  63.877 -				LLUUID fetch_id = sFetchQueue.front();
  63.878 -				sFetchQueue.pop_front();
  63.879 -
  63.880 -				if (sNumFetchRetries++ < MAX_FETCH_RETRIES)
  63.881 -				{
  63.882 -					// push on back of queue
  63.883 -					sFetchQueue.push_back(fetch_id);
  63.884 -				}
  63.885 -				sTimelyFetchPending = FALSE;
  63.886 -				sFetchTimer.reset();
  63.887 -				break;
  63.888 -			}
  63.889 -
  63.890 -			// not enough time has elapsed to do a new fetch
  63.891 -			break;
  63.892 -		}
  63.893 -	}
  63.894 -}
  63.895 -
  63.896 -void LLInventoryModel::cache(
  63.897 -	const LLUUID& parent_folder_id,
  63.898 -	const LLUUID& agent_id)
  63.899 +void LLInventoryModel::cache(const LLUUID& parent_folder_id,
  63.900 +							 const LLUUID& agent_id)
  63.901  {
  63.902  	lldebugs << "Caching " << parent_folder_id << " for " << agent_id
  63.903  			 << llendl;
  63.904 @@ -1827,12 +1384,8 @@
  63.905  
  63.906  	LLCanCache can_cache(this);
  63.907  	can_cache(root_cat, NULL);
  63.908 -	collectDescendentsIf(
  63.909 -		parent_folder_id,
  63.910 -		categories,
  63.911 -		items,
  63.912 -		INCLUDE_TRASH,
  63.913 -		can_cache);
  63.914 +	collectDescendentsIf(parent_folder_id, categories, items, INCLUDE_TRASH,
  63.915 +						 can_cache);
  63.916  	std::string agent_id_str;
  63.917  	std::string inventory_filename;
  63.918  	agent_id.toString(agent_id_str);
  63.919 @@ -2075,68 +1628,57 @@
  63.920  	return false;
  63.921  }
  63.922  
  63.923 -// OGPX : This loadSkeleton() takes LLSD formated data, other loadSkeleton is for XML-RPC data.
  63.924 -//  There are major differences in what is returned from the XML-RPC authenticate call versus
  63.925 -//  the style and sequence of OGP/llsd style authentication. 
  63.926 -//  In OGP, authentication returns a cap to the skeleton on agent domain. An HTTP GET then occurs on
  63.927 -//  this "agent/inventory-skeleton" cap. This loadSkeleton() 
  63.928 -//  routine is called after that HTTP GET of "agent/inventory-skeleton" cap occurs.  
  63.929 -bool LLInventoryModel::loadSkeleton(
  63.930 -	const LLSD& options,
  63.931 -	const LLUUID& owner_id)
  63.932 +bool LLInventoryModel::loadSkeleton(const LLSD& options, const LLUUID& owner_id)
  63.933  {
  63.934 -	LL_INFOS("OGPX") << "importing inventory skeleton for " << owner_id << LL_ENDL;
  63.935 -	LL_DEBUGS("Inventory") << " skeleton is " << ll_pretty_print_sd(options) << LL_ENDL;
  63.936 +	LL_DEBUGS("LoadInventory") << "Importing inventory skeleton for "
  63.937 +							   << owner_id << LL_ENDL;
  63.938  
  63.939  	typedef std::set<LLPointer<LLViewerInventoryCategory>, InventoryIDPtrLess> cat_set_t;
  63.940  	cat_set_t temp_cats;
  63.941  
  63.942 -	update_map_t child_counts;
  63.943 +	bool rv = true;
  63.944 +	for(LLSD::array_const_iterator it = options.beginArray(), end = options.endArray();
  63.945 +		it != end; ++it)
  63.946 +	{
  63.947 +		LLSD name = (*it)["name"];
  63.948 +		LLSD folder_id = (*it)["folder_id"];
  63.949 +		LLSD parent_id = (*it)["parent_id"];
  63.950 +		LLSD version = (*it)["version"];
  63.951 +		if (name.isDefined() && folder_id.isDefined() &&
  63.952 +			parent_id.isDefined() && version.isDefined() &&
  63.953 +			folder_id.asUUID().notNull())	// if an id is null, it locks the viewer.
  63.954 +		{
  63.955 +			LLPointer<LLViewerInventoryCategory> cat = new LLViewerInventoryCategory(owner_id);
  63.956 +			cat->rename(name.asString());
  63.957 +			cat->setUUID(folder_id.asUUID());
  63.958 +			cat->setParent(parent_id.asUUID());
  63.959  
  63.960 -	LLUUID id;
  63.961 -	LLFolderType::EType preferred_type;
  63.962 -	bool rv = true;
  63.963 -	for (LLSD::array_const_iterator it = options.beginArray(); it < options.endArray(); ++it)
  63.964 -	{
  63.965 -		LLPointer<LLViewerInventoryCategory> cat = new LLViewerInventoryCategory(owner_id);
  63.966 +			LLFolderType::EType preferred_type = LLFolderType::FT_NONE;
  63.967 +			LLSD type_default = (*it)["type_default"];
  63.968 +			if (type_default.isDefined())
  63.969 +            {
  63.970 +				preferred_type = (LLFolderType::EType)type_default.asInteger();
  63.971 +            }
  63.972 +            cat->setPreferredType(preferred_type);
  63.973 +			cat->setVersion(version.asInteger());
  63.974 +            temp_cats.insert(cat);
  63.975 +		}
  63.976 +		else
  63.977 +		{
  63.978 +			llwarns << "Unable to import near " << name.asString() << llendl;
  63.979 +            rv = false;
  63.980 +		}
  63.981 +	}
  63.982  
  63.983 -		LL_DEBUGS("Inventory") << "cat name, folder, parent, type " << (*it)["name"].asString() << " " << (*it)["folder_id"].asUUID() << " " << (*it)["parent_id"].asUUID() << " " << (*it)["type_default"].asString() << " " << LL_ENDL; // OGPX
  63.984 -		if ((*it)["name"].asString().empty()) goto clean_cat;
  63.985 -		cat->rename((*it)["name"].asString().c_str());
  63.986 -		if ((*it)["folder_id"].asUUID().isNull()) goto clean_cat;
  63.987 -		id = (*it)["folder_id"].asUUID();
  63.988 -		// if an id is null, it locks the viewer.
  63.989 -		if (id.isNull()) goto clean_cat;
  63.990 -		cat->setUUID(id);
  63.991 -		// OGPX : slight change in snowglobe non OGP handling of things with null parents vs OGP9 SVN branch
  63.992 -		// OGPX : so commented this line out for OGPX as well. if((*it)["parent_id"].asUUID().isNull()) goto clean_cat;
  63.993 -		id = (*it)["parent_id"].asUUID();
  63.994 -		cat->setParent(id);
  63.995 -
  63.996 -		preferred_type = LLFolderType::FT_NONE;
  63.997 -		if (!(*it)["type_default"].asString().empty())
  63.998 -		{
  63.999 -			S32 t = (*it)["type_default"].asInteger();
 63.1000 -			preferred_type = (LLFolderType::EType)t;
 63.1001 -		}
 63.1002 -		cat->setPreferredType(preferred_type);
 63.1003 -		if ((*it)["version"].asString().empty()) goto clean_cat;
 63.1004 -		cat->setVersion((*it)["version"].asInteger());
 63.1005 -		temp_cats.insert(cat);
 63.1006 -		continue;
 63.1007 -	clean_cat:
 63.1008 -		llwarns << "Unable to import near " << cat->getName() << llendl;
 63.1009 -		rv = false;
 63.1010 -		//delete cat; // automatic when cat is reasigned or destroyed
 63.1011 -	}
 63.1012 - 
 63.1013  	S32 cached_category_count = 0;
 63.1014  	S32 cached_item_count = 0;
 63.1015  	if (!temp_cats.empty())
 63.1016  	{
 63.1017 +		update_map_t child_counts;
 63.1018  		cat_array_t categories;
 63.1019  		item_array_t items;
 63.1020 -		cat_set_t invalid_categories; // Used to mark categories that weren't successfully loaded.
 63.1021 +		// Used to mark categories that weren't successfully loaded.
 63.1022 +		cat_set_t invalid_categories;
 63.1023  		std::string owner_id_str;
 63.1024  		owner_id.toString(owner_id_str);
 63.1025  		std::string path(gDirUtilp->getExpandedFilename(LL_PATH_CACHE, owner_id_str));
 63.1026 @@ -2203,9 +1745,10 @@
 63.1027  			}
 63.1028  
 63.1029  			// go ahead and add the cats returned during the download
 63.1030 -			std::set<LLUUID>::iterator not_cached_id = cached_ids.end();
 63.1031 +			std::set<LLUUID>::const_iterator not_cached_id = cached_ids.end();
 63.1032  			cached_category_count = cached_ids.size();
 63.1033 -			for (cat_set_t::iterator it = temp_cats.begin(); it != temp_cats.end(); ++it)
 63.1034 +			for (cat_set_t::iterator it = temp_cats.begin();
 63.1035 +				 it != temp_cats.end(); ++it)
 63.1036  			{
 63.1037  				if (cached_ids.find((*it)->getUUID()) == not_cached_id)
 63.1038  				{
 63.1039 @@ -2219,34 +1762,67 @@
 63.1040  				++child_counts[(*it)->getParentUUID()];
 63.1041  			}
 63.1042  
 63.1043 -			// Add all the items loaded which are parented to a
 63.1044 -			// category with a correctly cached parent
 63.1045 -			count = items.count();
 63.1046 -			S32 bad_link_count = 0;
 63.1047 +			// Add all the items loaded which are parented to a category with a
 63.1048 +			// correctly cached parent
 63.1049  			cat_map_t::iterator unparented = mCategoryMap.end();
 63.1050 -			for (int i = 0; i < count; ++i)
 63.1051 +			// First, we add non-link items and links which base objects have
 63.1052 +			// been loaded
 63.1053 +			for (item_array_t::const_iterator item_iter = items.begin();
 63.1054 +				 item_iter != items.end();
 63.1055 +				 ++item_iter)
 63.1056  			{
 63.1057 -				cat_map_t::iterator cit = mCategoryMap.find(items[i]->getParentUUID());
 63.1058 +				LLViewerInventoryItem *item = (*item_iter).get();
 63.1059 +				const cat_map_t::iterator cit = mCategoryMap.find(item->getParentUUID());
 63.1060  				
 63.1061  				if (cit != unparented)
 63.1062  				{
 63.1063 -					LLViewerInventoryCategory* cat = cit->second;
 63.1064 +					const LLViewerInventoryCategory* cat = cit->second.get();
 63.1065 +					if (cat->getVersion() != NO_VERSION && !item->getIsBrokenLink())
 63.1066 +					{
 63.1067 +						addItem(item);
 63.1068 +						cached_item_count++;
 63.1069 +						++child_counts[cat->getUUID()];
 63.1070 +					}
 63.1071 +				}
 63.1072 +			}
 63.1073 +			// Then we can add the remaining links since their base objects have
 63.1074 +			// now all been loaded...
 63.1075 +			S32 bad_link_count = 0;
 63.1076 +			item_map_t::const_iterator iit;
 63.1077 +			for (item_array_t::const_iterator item_iter = items.begin();
 63.1078 +				 item_iter != items.end();
 63.1079 +				 ++item_iter)
 63.1080 +			{
 63.1081 +				LLViewerInventoryItem *item = (*item_iter).get();
 63.1082 +				const cat_map_t::iterator cit = mCategoryMap.find(item->getParentUUID());
 63.1083 +				
 63.1084 +				if (cit != unparented)
 63.1085 +				{
 63.1086 +					const LLViewerInventoryCategory* cat = cit->second.get();
 63.1087  					if (cat->getVersion() != NO_VERSION)
 63.1088  					{
 63.1089 -						// This can happen if the linked object's baseobj is removed from the cache but the linked object is still in the cache.
 63.1090 -						if (items[i]->getIsBrokenLink())
 63.1091 +						iit = mItemMap.find(item->getUUID());
 63.1092 +						if (iit == mItemMap.end())	// not yet added
 63.1093  						{
 63.1094 -							bad_link_count++;
 63.1095 -							lldebugs << "Attempted to add cached link item without baseobj present ( name: "
 63.1096 -									 << items[i]->getName() << " itemID: " << items[i]->getUUID()
 63.1097 -									 << " assetID: " << items[i]->getAssetUUID()
 63.1098 -									 << " ).  Ignoring and invalidating " << cat->getName() << " . " << llendl;
 63.1099 -							invalid_categories.insert(cit->second);
 63.1100 -							continue;
 63.1101 +							// This can happen if the linked object's baseobj is
 63.1102 +							// removed from the cache but the linked object is
 63.1103 +							// still in the cache.
 63.1104 +							if (item->getIsBrokenLink())
 63.1105 +							{
 63.1106 +								bad_link_count++;
 63.1107 +								LL_DEBUGS("LoadInventory") << "Attempted to add cached link item without baseobj present (name: "
 63.1108 +										 << item->getName() << " - itemID: "
 63.1109 +										 << item->getUUID() << " - assetID: "
 63.1110 +										 << item->getAssetUUID()
 63.1111 +										 << "). Ignoring and invalidating: "
 63.1112 +										 << cat->getName() << LL_ENDL;
 63.1113 +								invalid_categories.insert(cit->second);
 63.1114 +								continue;
 63.1115 +							}
 63.1116 +							addItem(item);
 63.1117 +							cached_item_count++;
 63.1118 +							++child_counts[cat->getUUID()];
 63.1119  						}
 63.1120 -						addItem(items[i]);
 63.1121 -						cached_item_count += 1;
 63.1122 -						++child_counts[cat->getUUID()];
 63.1123  					}
 63.1124  				}
 63.1125  			}
 63.1126 @@ -2261,7 +1837,8 @@
 63.1127  		{
 63.1128  			// go ahead and add everything after stripping the version
 63.1129  			// information.
 63.1130 -			for (cat_set_t::iterator it = temp_cats.begin(); it != temp_cats.end(); ++it)
 63.1131 +			for (cat_set_t::iterator it = temp_cats.begin();
 63.1132 +				 it != temp_cats.end(); ++it)
 63.1133  			{
 63.1134  				LLViewerInventoryCategory *llvic = (*it);
 63.1135  				llvic->setVersion(NO_VERSION);
 63.1136 @@ -2277,23 +1854,26 @@
 63.1137  		{
 63.1138  			LLViewerInventoryCategory* cat = (*invalid_cat_it).get();
 63.1139  			cat->setVersion(NO_VERSION);
 63.1140 -			llinfos << "Invalidating category name: " << cat->getName() << " UUID: " << cat->getUUID() << " due to invalid descendents cache" << llendl;
 63.1141 +			llinfos << "Invalidating category name: " << cat->getName()
 63.1142 +					<< " - UUID: " << cat->getUUID()
 63.1143 +					<< ", due to invalid descendents cache" << llendl;
 63.1144  		}
 63.1145  
 63.1146  		// At this point, we need to set the known descendents for each
 63.1147  		// category which successfully cached so that we do not
 63.1148  		// needlessly fetch descendents for categories which we have.
 63.1149 -		update_map_t::iterator no_child_counts = child_counts.end();
 63.1150 -		update_map_t::iterator the_count;
 63.1151 -		for (cat_set_t::iterator it = temp_cats.begin(); it != temp_cats.end(); ++it)
 63.1152 +		update_map_t::const_iterator no_child_counts = child_counts.end();
 63.1153 +		for (cat_set_t::iterator it = temp_cats.begin();
 63.1154 +			 it != temp_cats.end(); ++it)
 63.1155  		{
 63.1156 -			LLViewerInventoryCategory* cat = (*it);
 63.1157 +			LLViewerInventoryCategory* cat = (*it).get();
 63.1158  			if (cat->getVersion() != NO_VERSION)
 63.1159  			{
 63.1160 -				the_count = child_counts.find(cat->getUUID());
 63.1161 +				update_map_t::const_iterator the_count = child_counts.find(cat->getUUID());
 63.1162  				if (the_count != no_child_counts)
 63.1163  				{
 63.1164 -					cat->setDescendentCount((*the_count).second.mValue);
 63.1165 +					const S32 num_descendents = (*the_count).second.mValue;
 63.1166 +					cat->setDescendentCount(num_descendents);
 63.1167  				}
 63.1168  				else
 63.1169  				{
 63.1170 @@ -2316,255 +1896,31 @@
 63.1171  		categories.clear(); // will unref and delete entries
 63.1172  	}
 63.1173  
 63.1174 -	LL_DEBUGS("Inventory") << "Successfully loaded " << cached_category_count
 63.1175 +	llinfos << "Successfully loaded " << cached_category_count
 63.1176  			<< " categories and " << cached_item_count << " items from cache."
 63.1177 -			<< LL_ENDL;
 63.1178 +			<< llendl;
 63.1179  
 63.1180  	return rv;
 63.1181  }
 63.1182  
 63.1183 -bool LLInventoryModel::loadSkeleton(
 63.1184 -	const LLInventoryModel::options_t& options,
 63.1185 -	const LLUUID& owner_id)
 63.1186 +// TODO: get rid of this version once we migrated to the new login method
 63.1187 +// (we'd need LLLoginInstance::getInstance()->getResponse() implemented).
 63.1188 +bool LLInventoryModel::loadSkeleton(const LLInventoryModel::options_t& options,
 63.1189 +									const LLUUID& owner_id)
 63.1190  {
 63.1191 -	lldebugs << "importing inventory skeleton for " << owner_id << llendl;
 63.1192 -
 63.1193 -	typedef std::set<LLPointer<LLViewerInventoryCategory>, InventoryIDPtrLess> cat_set_t;
 63.1194 -	cat_set_t temp_cats;
 63.1195 -
 63.1196 -	update_map_t child_counts;
 63.1197 -
 63.1198 -	LLUUID id;
 63.1199 -	LLFolderType::EType preferred_type;
 63.1200 -	bool rv = true;
 63.1201 -	for(options_t::const_iterator it = options.begin(); it < options.end(); ++it)
 63.1202 +	LLSD options_list;
 63.1203 +	for (options_t::const_iterator it = options.begin(); it < options.end();
 63.1204 +		 it++)
 63.1205  	{
 63.1206 -		LLPointer<LLViewerInventoryCategory> cat = new LLViewerInventoryCategory(owner_id);
 63.1207 -		response_t::const_iterator no_response = (*it).end();
 63.1208 -		response_t::const_iterator skel;
 63.1209 -		skel = (*it).find("name");
 63.1210 -		if(skel == no_response) goto clean_cat;
 63.1211 -		cat->rename(std::string((*skel).second));
 63.1212 -		skel = (*it).find("folder_id");
 63.1213 -		if(skel == no_response) goto clean_cat;
 63.1214 -		id.set((*skel).second);
 63.1215 -		// if an id is null, it locks the viewer.
 63.1216 -		if(id.isNull()) goto clean_cat;
 63.1217 -		cat->setUUID(id);
 63.1218 -		skel = (*it).find("parent_id");
 63.1219 -		if(skel == no_response) goto clean_cat;
 63.1220 -		id.set((*skel).second);
 63.1221 -		cat->setParent(id);
 63.1222 -		skel = (*it).find("type_default");
 63.1223 -		preferred_type = LLFolderType::FT_NONE;
 63.1224 -		if (skel != no_response)
 63.1225 +		LLSD entry;
 63.1226 +		for (response_t::const_iterator it2 = it->begin(); it2 != it->end();
 63.1227 +			 it2++)
 63.1228  		{
 63.1229 -			S32 t = atoi((*skel).second.c_str());
 63.1230 -			preferred_type = (LLFolderType::EType)t;
 63.1231 +			entry[it2->first] = it2->second;
 63.1232  		}
 63.1233 -		cat->setPreferredType(preferred_type);
 63.1234 -		skel = (*it).find("version");
 63.1235 -		if(skel == no_response) goto clean_cat;
 63.1236 -		cat->setVersion(atoi((*skel).second.c_str()));
 63.1237 -		temp_cats.insert(cat);
 63.1238 -		continue;
 63.1239 -	clean_cat:
 63.1240 -		llwarns << "Unable to import near " << cat->getName() << llendl;
 63.1241 -		rv = false;
 63.1242 -		//delete cat; // automatic when cat is reasigned or destroyed
 63.1243 +		options_list.append(entry);
 63.1244  	}
 63.1245 -
 63.1246 -	S32 cached_category_count = 0;
 63.1247 -	S32 cached_item_count = 0;
 63.1248 -	if(!temp_cats.empty())
 63.1249 -	{
 63.1250 -		cat_array_t categories;
 63.1251 -		item_array_t items;
 63.1252 -		cat_set_t invalid_categories; // Used to mark categories that weren't successfully loaded.
 63.1253 -		std::string owner_id_str;
 63.1254 -		owner_id.toString(owner_id_str);
 63.1255 -		std::string path(gDirUtilp->getExpandedFilename(LL_PATH_CACHE, owner_id_str));
 63.1256 -		std::string inventory_filename;
 63.1257 -		inventory_filename = llformat(CACHE_FORMAT_STRING, path.c_str());
 63.1258 -		const S32 NO_VERSION = LLViewerInventoryCategory::VERSION_UNKNOWN;
 63.1259 -		std::string gzip_filename(inventory_filename);
 63.1260 -		gzip_filename.append(".gz");
 63.1261 -		LLFILE* fp = LLFile::fopen(gzip_filename, "rb");
 63.1262 -		bool remove_inventory_file = false;
 63.1263 -		if(fp)
 63.1264 -		{
 63.1265 -			fclose(fp);
 63.1266 -			fp = NULL;
 63.1267 -			if(gunzip_file(gzip_filename, inventory_filename))
 63.1268 -			{
 63.1269 -				// we only want to remove the inventory file if it was
 63.1270 -				// gzipped before we loaded, and we successfully
 63.1271 -				// gunziped it.
 63.1272 -				remove_inventory_file = true;
 63.1273 -			}
 63.1274 -			else
 63.1275 -			{
 63.1276 -				llinfos << "Unable to gunzip " << gzip_filename << llendl;
 63.1277 -			}
 63.1278 -		}
 63.1279 -		bool is_cache_obsolete = false;
 63.1280 -		if (loadFromFile(inventory_filename, categories, items, is_cache_obsolete))
 63.1281 -		{
 63.1282 -			// We were able to find a cache of files. So, use what we
 63.1283 -			// found to generate a set of categories we should add. We
 63.1284 -			// will go through each category loaded and if the version
 63.1285 -			// does not match, invalidate the version.
 63.1286 -			S32 count = categories.count();
 63.1287 -			cat_set_t::iterator not_cached = temp_cats.end();
 63.1288 -			std::set<LLUUID> cached_ids;
 63.1289 -			for(S32 i = 0; i < count; ++i)
 63.1290 -			{
 63.1291 -				LLViewerInventoryCategory* cat = categories[i];
 63.1292 -				cat_set_t::iterator cit = temp_cats.find(cat);
 63.1293 -				if (cit == temp_cats.end())
 63.1294 -				{
 63.1295 -					continue; // cache corruption?? not sure why this happens -SJB
 63.1296 -				}
 63.1297 -				LLViewerInventoryCategory* tcat = *cit;
 63.1298 -				
 63.1299 -				// we can safely ignore anything loaded from file, but
 63.1300 -				// not sent down in the skeleton.
 63.1301 -				if(cit == not_cached)
 63.1302 -				{
 63.1303 -					continue;
 63.1304 -				}
 63.1305 -				if(cat->getVersion() != tcat->getVersion())
 63.1306 -				{
 63.1307 -					// if the cached version does not match the server version,
 63.1308 -					// throw away the version we have so we can fetch the
 63.1309 -					// correct contents the next time the viewer opens the folder.
 63.1310 -					tcat->setVersion(NO_VERSION);
 63.1311 -				}
 63.1312 -				else
 63.1313 -				{
 63.1314 -					cached_ids.insert(tcat->getUUID());
 63.1315 -				}
 63.1316 -			}
 63.1317 -
 63.1318 -			// go ahead and add the cats returned during the download
 63.1319 -			std::set<LLUUID>::iterator not_cached_id = cached_ids.end();
 63.1320 -			cached_category_count = cached_ids.size();
 63.1321 -			for(cat_set_t::iterator it = temp_cats.begin(); it != temp_cats.end(); ++it)
 63.1322 -			{
 63.1323 -				if(cached_ids.find((*it)->getUUID()) == not_cached_id)
 63.1324 -				{
 63.1325 -					// this check is performed so that we do not
 63.1326 -					// mark new folders in the skeleton (and not in cache)
 63.1327 -					// as being cached.
 63.1328 -					LLViewerInventoryCategory *llvic = (*it);
 63.1329 -					llvic->setVersion(NO_VERSION);
 63.1330 -				}
 63.1331 -				addCategory(*it);
 63.1332 -				++child_counts[(*it)->getParentUUID()];
 63.1333 -			}
 63.1334 -
 63.1335 -			// Add all the items loaded which are parented to a
 63.1336 -			// category with a correctly cached parent
 63.1337 -			count = items.count();
 63.1338 -			S32 bad_link_count = 0;
 63.1339 -			cat_map_t::iterator unparented = mCategoryMap.end();
 63.1340 -			for(int i = 0; i < count; ++i)
 63.1341 -			{
 63.1342 -				cat_map_t::iterator cit = mCategoryMap.find(items[i]->getParentUUID());
 63.1343 -				
 63.1344 -				if(cit != unparented)
 63.1345 -				{
 63.1346 -					LLViewerInventoryCategory* cat = cit->second;
 63.1347 -					if(cat->getVersion() != NO_VERSION)
 63.1348 -					{
 63.1349 -						// This can happen if the linked object's baseobj is removed from the cache but the linked object is still in the cache.
 63.1350 -						if (items[i]->getIsBrokenLink())
 63.1351 -						{
 63.1352 -							bad_link_count++;
 63.1353 -							lldebugs << "Attempted to add cached link item without baseobj present ( name: "
 63.1354 -									 << items[i]->getName() << " itemID: " << items[i]->getUUID()
 63.1355 -									 << " assetID: " << items[i]->getAssetUUID()
 63.1356 -									 << " ).  Ignoring and invalidating " << cat->getName() << " . " << llendl;
 63.1357 -							invalid_categories.insert(cit->second);
 63.1358 -							continue;
 63.1359 -						}
 63.1360 -						addItem(items[i]);
 63.1361 -						cached_item_count += 1;
 63.1362 -						++child_counts[cat->getUUID()];
 63.1363 -					}
 63.1364 -				}
 63.1365 -			}
 63.1366 -			if (bad_link_count > 0)
 63.1367 -			{
 63.1368 -				llinfos << "Attempted to add " << bad_link_count
 63.1369 -						<< " cached link items without baseobj present. "
 63.1370 -						<< "The corresponding categories were invalidated." << llendl;
 63.1371 -			}
 63.1372 -		}
 63.1373 -		else
 63.1374 -		{
 63.1375 -			// go ahead and add everything after stripping the version
 63.1376 -			// information.
 63.1377 -			for(cat_set_t::iterator it = temp_cats.begin(); it != temp_cats.end(); ++it)
 63.1378 -			{
 63.1379 -				LLViewerInventoryCategory *llvic = (*it);
 63.1380 -				llvic->setVersion(NO_VERSION);
 63.1381 -				addCategory(*it);
 63.1382 -			}
 63.1383 -		}
 63.1384 -
 63.1385 -		// Invalidate all categories that failed fetching descendents for whatever
 63.1386 -		// reason (e.g. one of the descendents was a broken link).
 63.1387 -		for (cat_set_t::iterator invalid_cat_it = invalid_categories.begin();
 63.1388 -			 invalid_cat_it != invalid_categories.end();
 63.1389 -			 invalid_cat_it++)
 63.1390 -		{
 63.1391 -			LLViewerInventoryCategory* cat = (*invalid_cat_it).get();
 63.1392 -			cat->setVersion(NO_VERSION);
 63.1393 -			llinfos << "Invalidating category name: " << cat->getName() << " UUID: " << cat->getUUID() << " due to invalid descendents cache" << llendl;
 63.1394 -		}
 63.1395 -
 63.1396 -		// At this point, we need to set the known descendents for each
 63.1397 -		// category which successfully cached so that we do not
 63.1398 -		// needlessly fetch descendents for categories which we have.
 63.1399 -		update_map_t::iterator no_child_counts = child_counts.end();
 63.1400 -		update_map_t::iterator the_count;
 63.1401 -		for(cat_set_t::iterator it = temp_cats.begin(); it != temp_cats.end(); ++it)
 63.1402 -		{
 63.1403 -			LLViewerInventoryCategory* cat = (*it);
 63.1404 -			if(cat->getVersion() != NO_VERSION)
 63.1405 -			{
 63.1406 -				the_count = child_counts.find(cat->getUUID());
 63.1407 -				if(the_count != no_child_counts)
 63.1408 -				{
 63.1409 -					cat->setDescendentCount((*the_count).second.mValue);
 63.1410 -				}
 63.1411 -				else
 63.1412 -				{
 63.1413 -					cat->setDescendentCount(0);
 63.1414 -				}
 63.1415 -			}
 63.1416 -		}
 63.1417 -
 63.1418 -		if(remove_inventory_file)
 63.1419 -		{
 63.1420 -			// clean up the gunzipped file.
 63.1421 -			LLFile::remove(inventory_filename);
 63.1422 -		}
 63.1423 -		if (is_cache_obsolete)
 63.1424 -		{
 63.1425 -			// If out of date, remove the gzipped file too.
 63.1426 -			llwarns << "Inv cache out of date, removing" << llendl;
 63.1427 -			LLFile::remove(gzip_filename);
 63.1428 -		}
 63.1429 -		categories.clear(); // will unref and delete entries
 63.1430 -	}
 63.1431 -
 63.1432 -	LL_DEBUGS("Inventory") << "Successfully loaded " << cached_category_count
 63.1433 -			<< " categories and " << cached_item_count << " items from cache."
 63.1434 -			<< LL_ENDL;
 63.1435 -
 63.1436 -	return rv;
 63.1437 +	return loadSkeleton(options_list,owner_id);
 63.1438  }
 63.1439  
 63.1440  // This is a brute force method to rebuild the entire parent-child
 63.1441 @@ -2653,7 +2009,7 @@
 63.1442  			else
 63.1443  			{
 63.1444  				// it's a protected folder.
 63.1445 -				cat->setParent(gAgent.getInventoryRootID());
 63.1446 +				cat->setParent(gInventory.getRootFolderID());
 63.1447  			}
 63.1448  			cat->updateServer(TRUE);
 63.1449  			catsp = getUnlockedCatArray(cat->getParentUUID());
 63.1450 @@ -2753,7 +2109,7 @@
 63.1451  		}
 63.1452  	}
 63.1453  
 63.1454 -	const LLUUID& agent_inv_root_id = gAgent.getInventoryRootID();
 63.1455 +	const LLUUID& agent_inv_root_id = gInventory.getRootFolderID();
 63.1456  	if (agent_inv_root_id.notNull())
 63.1457  	{
 63.1458  		cat_array_t* catsp = get_ptr_in_map(mParentChildCategoryTree, agent_inv_root_id);
 63.1459 @@ -2946,12 +2302,6 @@
 63.1460  // static
 63.1461  void LLInventoryModel::registerCallbacks(LLMessageSystem* msg)
 63.1462  {
 63.1463 -	//msg->setHandlerFuncFast(_PREHASH_InventoryUpdate,
 63.1464 -	//					processInventoryUpdate,
 63.1465 -	//					NULL);
 63.1466 -	//msg->setHandlerFuncFast(_PREHASH_UseCachedInventory,
 63.1467 -	//					processUseCachedInventory,
 63.1468 -	//					NULL);
 63.1469  	msg->setHandlerFuncFast(_PREHASH_UpdateCreateInventoryItem,
 63.1470  						processUpdateCreateInventoryItem,
 63.1471  						NULL);
 63.1472 @@ -2964,15 +2314,6 @@
 63.1473  	msg->setHandlerFuncFast(_PREHASH_RemoveInventoryFolder,
 63.1474  						processRemoveInventoryFolder,
 63.1475  						NULL);
 63.1476 -	//msg->setHandlerFuncFast(_PREHASH_ExchangeCallingCard,
 63.1477 -	//						processExchangeCallingcard,
 63.1478 -	//						NULL);
 63.1479 -	//msg->setHandlerFuncFast(_PREHASH_AddCallingCard,
 63.1480 -	//					processAddCallingcard,
 63.1481 -	//					NULL);
 63.1482 -	//msg->setHandlerFuncFast(_PREHASH_DeclineCallingCard,
 63.1483 -	//					processDeclineCallingcard,
 63.1484 -	//					NULL);
 63.1485  	msg->setHandlerFuncFast(_PREHASH_SaveAssetIntoInventory,
 63.1486  						processSaveAssetIntoInventory,
 63.1487  						NULL);
 63.1488 @@ -3348,7 +2689,7 @@
 63.1489  		//		<< titem->getParentUUID() << llendl;
 63.1490  		U32 callback_id;
 63.1491  		msg->getU32Fast(_PREHASH_ItemData, _PREHASH_CallbackID, callback_id);
 63.1492 -		if(titem->getUUID().notNull())
 63.1493 +		if(titem->getUUID().notNull()) // && callback_id.notNull())
 63.1494  		{
 63.1495  			items.push_back(titem);
 63.1496  			cblist.push_back(InventoryCallbackInfo(callback_id, titem->getUUID()));
 63.1497 @@ -3614,6 +2955,36 @@
 63.1498  	}
 63.1499  }
 63.1500  
 63.1501 +const LLUUID &LLInventoryModel::getRootFolderID() const
 63.1502 +{
 63.1503 +	return mRootFolderID;
 63.1504 +}
 63.1505 +
 63.1506 +void LLInventoryModel::setRootFolderID(const LLUUID& val)
 63.1507 +{
 63.1508 +	mRootFolderID = val;
 63.1509 +}
 63.1510 +
 63.1511 +const LLUUID &LLInventoryModel::getLibraryRootFolderID() const
 63.1512 +{
 63.1513 +	return mLibraryRootFolderID;
 63.1514 +}
 63.1515 +
 63.1516 +void LLInventoryModel::setLibraryRootFolderID(const LLUUID& val)
 63.1517 +{
 63.1518 +	mLibraryRootFolderID = val;
 63.1519 +}
 63.1520 +
 63.1521 +const LLUUID &LLInventoryModel::getLibraryOwnerID() const
 63.1522 +{
 63.1523 +	return mLibraryOwnerID;
 63.1524 +}
 63.1525 +
 63.1526 +void LLInventoryModel::setLibraryOwnerID(const LLUUID& val)
 63.1527 +{
 63.1528 +	mLibraryOwnerID = val;
 63.1529 +}
 63.1530 +
 63.1531  ///----------------------------------------------------------------------------
 63.1532  /// LLInventoryCollectFunctor implementations
 63.1533  ///----------------------------------------------------------------------------
 63.1534 @@ -3782,7 +3153,7 @@
 63.1535  				it = mIncomplete.erase(it);
 63.1536  				continue;
 63.1537  			}
 63.1538 -			if(item->isComplete())
 63.1539 +			if(item->isFinished())
 63.1540  			{
 63.1541  				mComplete.push_back(*it);
 63.1542  				it = mIncomplete.erase(it);
 63.1543 @@ -3823,7 +3194,7 @@
 63.1544  				it = mIncomplete.erase(it);
 63.1545  				continue;
 63.1546  			}
 63.1547 -			if(item->isComplete())
 63.1548 +			if(item->isFinished())
 63.1549  			{
 63.1550  				mComplete.push_back(*it);
 63.1551  				it = mIncomplete.erase(it);
 63.1552 @@ -3840,7 +3211,7 @@
 63.1553  	//llinfos << "LLInventoryFetchObserver::changed() mIncomplete size " << mIncomplete.size() << llendl;
 63.1554  }
 63.1555  
 63.1556 -bool LLInventoryFetchObserver::isEverythingComplete() const
 63.1557 +bool LLInventoryFetchObserver::isFinished() const
 63.1558  {
 63.1559  	return mIncomplete.empty();
 63.1560  }
 63.1561 @@ -3849,9 +3220,19 @@
 63.1562  {
 63.1563  	if (!items_llsd.size()) return;
 63.1564  	LLSD body;
 63.1565 -	body[0]["cap_name"] = "FetchInventory";
 63.1566 -	body[1]["cap_name"] = "FetchLib";
 63.1567 -	for (S32 i=0; i<items_llsd.size();i++)
 63.1568 +	std::string url = gAgent.getRegion()->getCapability("FetchInventory2");
 63.1569 +	if (url.empty())
 63.1570 +	{
 63.1571 +		body[0]["cap_name"] = "FetchInventory";
 63.1572 +		body[1]["cap_name"] = "FetchLib";
 63.1573 +	}
 63.1574 +	else
 63.1575 +	{
 63.1576 +		body[0]["cap_name"] = "FetchInventory2";
 63.1577 +		body[1]["cap_name"] = "FetchLib2";
 63.1578 +	}
 63.1579 +
 63.1580 +	for (S32 i = 0; i < items_llsd.size(); i++)
 63.1581  	{
 63.1582  		if (items_llsd[i]["owner_id"].asString() == gAgent.getID().asString())
 63.1583  		{
 63.1584 @@ -3865,10 +3246,10 @@
 63.1585  		}
 63.1586  	}
 63.1587  		
 63.1588 -	for (S32 i=0; i<body.size(); i++)
 63.1589 +	for (S32 i = 0; i < body.size(); i++)
 63.1590  	{
 63.1591  		if (0 >= body[i].size()) continue;
 63.1592 -		std::string url = gAgent.getRegion()->getCapability(body[i]["cap_name"].asString());
 63.1593 +		url = gAgent.getRegion()->getCapability(body[i]["cap_name"].asString());
 63.1594  
 63.1595  		if (!url.empty())
 63.1596  		{
 63.1597 @@ -3879,7 +3260,7 @@
 63.1598  
 63.1599  		LLMessageSystem* msg = gMessageSystem;
 63.1600  		BOOL start_new_message = TRUE;
 63.1601 -		for (S32 j=0; j<body[i]["items"].size(); j++)
 63.1602 +		for (S32 j = 0; j < body[i]["items"].size(); j++)
 63.1603  		{
 63.1604  			LLSD item_entry = body[i]["items"][j];
 63.1605  			if(start_new_message)
 63.1606 @@ -3916,7 +3297,7 @@
 63.1607  		LLViewerInventoryItem* item = gInventory.getItem(*it);
 63.1608  		if(item)
 63.1609  		{
 63.1610 -			if(item->isComplete())
 63.1611 +			if(item->isFinished())
 63.1612  			{
 63.1613  				// It's complete, so put it on the complete container.
 63.1614  				mComplete.push_back(*it);
 63.1615 @@ -3957,7 +3338,7 @@
 63.1616  			it = mIncompleteFolders.erase(it);
 63.1617  			continue;
 63.1618  		}
 63.1619 -		if(isComplete(cat))
 63.1620 +		if (isCategoryComplete(cat))
 63.1621  		{
 63.1622  			mCompleteFolders.push_back(*it);
 63.1623  			it = mIncompleteFolders.erase(it);
 63.1624 @@ -3978,9 +3359,9 @@
 63.1625  	{
 63.1626  		LLViewerInventoryCategory* cat = gInventory.getCategory(*it);
 63.1627  		if(!cat) continue;
 63.1628 -		if(!isComplete(cat))
 63.1629 +		if (!isCategoryComplete(cat))
 63.1630  		{
 63.1631 -			cat->fetchDescendents();		//blindly fetch it without seeing if anything else is fetching it.
 63.1632 +			cat->fetch();	// blindly fetch it without seeing if anything else is fetching it.
 63.1633  			mIncompleteFolders.push_back(*it);	//Add to list of things being downloaded for this observer.
 63.1634  		}
 63.1635  		else
 63.1636 @@ -3990,12 +3371,12 @@
 63.1637  	}
 63.1638  }
 63.1639  
 63.1640 -bool LLInventoryFetchDescendentsObserver::isEverythingComplete() const
 63.1641 +bool LLInventoryFetchDescendentsObserver::isFinished() const
 63.1642  {
 63.1643  	return mIncompleteFolders.empty();
 63.1644  }
 63.1645  
 63.1646 -bool LLInventoryFetchDescendentsObserver::isComplete(LLViewerInventoryCategory* cat)
 63.1647 +bool LLInventoryFetchDescendentsObserver::isCategoryComplete(LLViewerInventoryCategory* cat)
 63.1648  {
 63.1649  	S32 version = cat->getVersion();
 63.1650  	S32 descendents = cat->getDescendentCount();
 63.1651 @@ -4037,7 +3418,7 @@
 63.1652  				it = mIncompleteItems.erase(it);
 63.1653  				continue;
 63.1654  			}
 63.1655 -			if(item->isComplete())
 63.1656 +			if(item->isFinished())
 63.1657  			{
 63.1658  				mCompleteItems.push_back(*it);
 63.1659  				it = mIncompleteItems.erase(it);
 63.1660 @@ -4083,7 +3464,7 @@
 63.1661  		if(!cat) continue;
 63.1662  		if(!gInventory.isCategoryComplete(*fit))
 63.1663  		{
 63.1664 -			cat->fetchDescendents();
 63.1665 +			cat->fetch();
 63.1666  			lldebugs << "fetching folder " << *fit <<llendl;
 63.1667  			mIncompleteFolders.push_back(*fit);
 63.1668  		}
 63.1669 @@ -4108,7 +3489,7 @@
 63.1670  			lldebugs << "uanble to find item " << *iit << llendl;
 63.1671  			continue;
 63.1672  		}
 63.1673 -		if(item->isComplete())
 63.1674 +		if(item->isFinished())
 63.1675  		{
 63.1676  			// It's complete, so put it on the complete container.
 63.1677  			mCompleteItems.push_back(*iit);
 63.1678 @@ -4178,16 +3559,7 @@
 63.1679  	// the network, figure out which item was updated.
 63.1680  	LLMessageSystem* msg = gMessageSystem;
 63.1681  
 63.1682 -	std::string msg_name;
 63.1683 -	if (mMessageName.empty())
 63.1684 -	{
 63.1685 -		msg_name = msg->getMessageName();
 63.1686 -	}
 63.1687 -	else
 63.1688 -	{
 63.1689 -		msg_name = mMessageName;
 63.1690 -	}
 63.1691 -
 63.1692 +	std::string msg_name = msg->getMessageName();
 63.1693  	if (msg_name.empty())
 63.1694  	{
 63.1695  		return;
    64.1 --- a/indra/newview/llinventorymodel.h	Mon Feb 27 23:28:58 2012 -0800
    64.2 +++ b/indra/newview/llinventorymodel.h	Mon Feb 27 23:59:10 2012 -0800
    64.3 @@ -71,7 +71,6 @@
    64.4  	};
    64.5  	virtual ~LLInventoryObserver() {};
    64.6  	virtual void changed(U32 mask) = 0;
    64.7 -	std::string mMessageName; // used by Agent Inventory Service only. [DEV-20328]
    64.8  };
    64.9  
   64.10  //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
   64.11 @@ -95,22 +94,30 @@
   64.12  class LLMessageSystem;
   64.13  class LLInventoryCollectFunctor;
   64.14  
   64.15 +//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
   64.16 +// LLInventoryModel
   64.17 +//
   64.18 +// Represents a collection of inventory, and provides efficient ways to access 
   64.19 +// that information.
   64.20 +//   NOTE: This class could in theory be used for any place where you need 
   64.21 +//   inventory, though it optimizes for time efficiency - not space efficiency, 
   64.22 +//   probably making it inappropriate for use on tasks.
   64.23 +//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
   64.24  class LLInventoryModel
   64.25  {
   64.26  public:
   64.27 -	typedef enum e_has_children
   64.28 +	friend class LLInventoryModelFetchDescendentsResponder;
   64.29 +
   64.30 +	enum EHasChildren
   64.31  	{
   64.32  		CHILDREN_NO,
   64.33  		CHILDREN_YES,
   64.34  		CHILDREN_MAYBE
   64.35 -	}EHasChildren;
   64.36 +	};
   64.37  
   64.38 -	// These are used a lot...
   64.39  	typedef LLDynamicArray<LLPointer<LLViewerInventoryCategory> > cat_array_t;
   64.40  	typedef LLDynamicArray<LLPointer<LLViewerInventoryItem> > item_array_t;
   64.41 -	// construction & destruction
   64.42 -	LLInventoryModel();
   64.43 -	~LLInventoryModel();
   64.44 +	typedef std::set<LLUUID> changed_items_t;
   64.45  
   64.46  	class fetchInventoryResponder: public LLHTTPClient::Responder
   64.47  	{
   64.48 @@ -119,61 +126,119 @@
   64.49  		void result(const LLSD& content);			
   64.50  		void error(U32 status, const std::string& reason);
   64.51  
   64.52 -	public:
   64.53  		typedef std::vector<LLViewerInventoryCategory*> folder_ref_t;
   64.54 +
   64.55  	protected:
   64.56  		LLSD mRequestSD;
   64.57  	};
   64.58  
   64.59 +	//--------------------------------------------------------------------
   64.60 +	// Constructors / Destructors
   64.61 +	//--------------------------------------------------------------------
   64.62 +public:
   64.63 +	LLInventoryModel();
   64.64 +	~LLInventoryModel();
   64.65 +	void cleanupInventory();
   64.66 +
   64.67 +protected:
   64.68 +	// Empty the entire contents
   64.69 +	void empty();
   64.70 +
   64.71 +	//--------------------------------------------------------------------
   64.72 +	// Initialization
   64.73 +	//--------------------------------------------------------------------
   64.74 +public:
   64.75 +	// The inventory model usage is sensitive to the initial construction of the model
   64.76 +	bool isInventoryUsable() const;
   64.77 +
   64.78 +private:
   64.79 +	bool mIsAgentInvUsable; // used to handle an invalid inventory state
   64.80 +
   64.81 +	//--------------------------------------------------------------------
   64.82 +	// Root Folders
   64.83 +	//--------------------------------------------------------------------
   64.84 +public:
   64.85 +	// The following are set during login with data from the server
   64.86 +	void setRootFolderID(const LLUUID& id);
   64.87 +	void setLibraryOwnerID(const LLUUID& id);
   64.88 +	void setLibraryRootFolderID(const LLUUID& id);
   64.89 +
   64.90 +	const LLUUID &getRootFolderID() const;
   64.91 +	const LLUUID &getLibraryOwnerID() const;
   64.92 +	const LLUUID &getLibraryRootFolderID() const;
   64.93 +
   64.94 +private:
   64.95 +	LLUUID mRootFolderID;
   64.96 +	LLUUID mLibraryRootFolderID;
   64.97 +	LLUUID mLibraryOwnerID;
   64.98 +
   64.99 +	//--------------------------------------------------------------------
  64.100 +	// Structure
  64.101 +	//--------------------------------------------------------------------
  64.102 +public:
  64.103 +	// Methods to load up inventory skeleton & meat. These are used
  64.104 +	// during authentication. Returns true if everything parsed.
  64.105 +	bool loadSkeleton(const LLSD& options, const LLUUID& owner_id);
  64.106 +	// Legacy method for old XML-RPC login (to remove once llstartup.cpp is
  64.107 +	// updated to v2/3 viewer code).
  64.108 +	typedef std::map<std::string, std::string> response_t;
  64.109 +	typedef std::vector<response_t> options_t;
  64.110 +	bool loadSkeleton(const options_t& options, const LLUUID& owner_id);
  64.111 +
  64.112 +	// Brute force method to rebuild the entire parent-child relations.
  64.113 +	void buildParentChildMap();
  64.114 +
  64.115 +	// Call on logout to save a terse representation.
  64.116 +	void cache(const LLUUID& parent_folder_id, const LLUUID& agent_id);
  64.117 +
  64.118 +private:
  64.119 +	// Information for tracking the actual inventory. We index this
  64.120 +	// information in a lot of different ways so we can access
  64.121 +	// the inventory using several different identifiers.
  64.122 +	// mCategoryMap and mItemMap store uuid->object mappings. 
  64.123 +	typedef std::map<LLUUID, LLPointer<LLViewerInventoryCategory> > cat_map_t;
  64.124 +	typedef std::map<LLUUID, LLPointer<LLViewerInventoryItem> > item_map_t;
  64.125 +	cat_map_t mCategoryMap;
  64.126 +	item_map_t mItemMap;
  64.127 +	// This last set of indices is used to map parents to children.
  64.128 +	typedef std::map<LLUUID, cat_array_t*> parent_cat_map_t;
  64.129 +	typedef std::map<LLUUID, item_array_t*> parent_item_map_t;
  64.130 +	parent_cat_map_t mParentChildCategoryTree;
  64.131 +	parent_item_map_t mParentChildItemTree;
  64.132 +
  64.133 +
  64.134 +	//--------------------------------------------------------------------
  64.135 +	// Login
  64.136 +	//--------------------------------------------------------------------
  64.137 +private:
  64.138 +	const static S32 sCurrentInvCacheVersion; // expected inventory cache version
  64.139 +
  64.140  	//
  64.141  	// Accessors
  64.142  	//
  64.143  
  64.144 -	// This is a convenience function to check if one object has a
  64.145 -	// parent chain up to the category specified by UUID.
  64.146 -	BOOL isObjectDescendentOf(const LLUUID& obj_id, const LLUUID& cat_id);
  64.147 -
  64.148 -	// Get the object by id. Returns NULL if not found.
  64.149 -	// * WARNING: use the pointer returned for read operations - do
  64.150 -	// not modify the object values in place or you will break stuff.
  64.151 -	LLInventoryObject* getObject(const LLUUID& id) const;
  64.152 -
  64.153 -	// Get the item by id. Returns NULL if not found.
  64.154 -	// * WARNING: use the pointer for read operations - use the
  64.155 -	// updateItem() method to actually modify values.
  64.156 -	LLViewerInventoryItem* getItem(const LLUUID& id) const;
  64.157 -
  64.158 -	// Get the category by id. Returns NULL if not found.
  64.159 -	// * WARNING: use the pointer for read operations - use the
  64.160 -	// updateCategory() method to actually modify values.
  64.161 -	LLViewerInventoryCategory* getCategory(const LLUUID& id) const;
  64.162 -
  64.163 -	// Return the number of items or categories
  64.164 -	S32 getItemCount() const;
  64.165 -	S32 getCategoryCount() const;
  64.166 +	//--------------------------------------------------------------------
  64.167 +	// Descendents
  64.168 +	//--------------------------------------------------------------------
  64.169 +public:
  64.170 +	// Make sure we have the descendents in the structure.
  64.171 +	void fetchDescendentsOf(const LLUUID& folder_id);
  64.172  
  64.173  	// Return the direct descendents of the id provided.Set passed
  64.174  	// in values to NULL if the call fails.
  64.175 -	// *WARNING: The array provided points straight into the guts of
  64.176 -	// this object, and should only be used for read operations, since
  64.177 -	// modifications may invalidate the internal state of the
  64.178 -	// inventory.
  64.179 +	//    NOTE: The array provided points straight into the guts of
  64.180 +	//    this object, and should only be used for read operations, since
  64.181 +	//    modifications may invalidate the internal state of the inventory.
  64.182  	void getDirectDescendentsOf(const LLUUID& cat_id,
  64.183  								cat_array_t*& categories,
  64.184  								item_array_t*& items) const;
  64.185  	
  64.186 -	// SJB: Added version to lock the arrays to catch potential logic bugs
  64.187 -	void lockDirectDescendentArrays(const LLUUID& cat_id,
  64.188 -									cat_array_t*& categories,
  64.189 -									item_array_t*& items);
  64.190 -	void unlockDirectDescendentArrays(const LLUUID& cat_id);
  64.191 -	
  64.192 -	// Starting with the object specified, add it's descendents to the
  64.193 +	// Starting with the object specified, add its descendents to the
  64.194  	// array provided, but do not add the inventory object specified
  64.195 -	// by id. There is no guaranteed order. Neither array will be
  64.196 -	// erased before adding objects to it. Do not store a copy of the
  64.197 -	// pointers collected - use them, and collect them again later if
  64.198 -	// you need to reference the same objects.
  64.199 +	// by id. There is no guaranteed order. 
  64.200 +	//    NOTE: Neither array will be erased before adding objects to it. 
  64.201 +	//    Do not store a copy of the pointers collected - use them, and 
  64.202 +	//    collect them again later if you need to reference the same objects.
  64.203  	enum {
  64.204  		EXCLUDE_TRASH = FALSE,
  64.205  		INCLUDE_TRASH = TRUE
  64.206 @@ -194,50 +259,91 @@
  64.207  	item_array_t collectLinkedItems(const LLUUID& item_id,
  64.208  									const LLUUID& start_folder_id = LLUUID::null);
  64.209  
  64.210 +	// Check if one object has a parent chain up to the category specified by UUID.
  64.211 +	BOOL isObjectDescendentOf(const LLUUID& obj_id, const LLUUID& cat_id);
  64.212 +
  64.213 +	//--------------------------------------------------------------------
  64.214 +	// Find
  64.215 +	//--------------------------------------------------------------------
  64.216 +public:
  64.217 +	// Returns the uuid of the category that specifies 'type' as what it
  64.218 +	// defaults to containing. The category is not necessarily only for that type.
  64.219 +	// NOTE: If create_folder is true, this will create a new inventory category
  64.220 +	// on the fly if one does not exist.
  64.221 +	LLUUID findCategoryUUIDForType(LLFolderType::EType preferred_type,
  64.222 +								   bool create_folder = true);
  64.223 +
  64.224 +	// Get the object by id. Returns NULL if not found.
  64.225 +	//   NOTE: Use the pointer returned for read operations - do
  64.226 +	//   not modify the object values in place or you will break stuff.
  64.227 +	LLInventoryObject* getObject(const LLUUID& id) const;
  64.228 +
  64.229 +	// Get the item by id. Returns NULL if not found.
  64.230 +	//    NOTE: Use the pointer for read operations - use the
  64.231 +	//    updateItem() method to actually modify values.
  64.232 +	LLViewerInventoryItem* getItem(const LLUUID& id) const;
  64.233 +
  64.234 +	// Get the category by id. Returns NULL if not found.
  64.235 +	//    NOTE: Use the pointer for read operations - use the
  64.236 +	//    updateCategory() method to actually modify values.
  64.237 +	LLViewerInventoryCategory* getCategory(const LLUUID& id) const;
  64.238 +
  64.239  	// Get the inventoryID that this item points to, else just return item_id
  64.240  	const LLUUID& getLinkedItemID(const LLUUID& object_id) const;
  64.241  	LLViewerInventoryItem* getLinkedItem(const LLUUID& object_id) const;
  64.242  
  64.243 -	// This method will return false if this inventory model is in an usabel state.
  64.244 -	// The inventory model usage is sensitive to the initial construction of the 
  64.245 -	// model. 
  64.246 -	bool isInventoryUsable();
  64.247 +protected:
  64.248 +	// Internal method which looks for a category with the specified
  64.249 +	// preferred type. Returns LLUUID::null if not found
  64.250 + 	LLUUID findCatUUID(LLFolderType::EType preferred_type);
  64.251 +
  64.252 +private:
  64.253 +	mutable LLPointer<LLViewerInventoryItem> mLastItem; // cache recent lookups
  64.254 +
  64.255 +	//--------------------------------------------------------------------
  64.256 +	// Count
  64.257 +	//--------------------------------------------------------------------
  64.258 +public:
  64.259 +	// Return the number of items or categories
  64.260 +	S32 getItemCount() const;
  64.261 +	S32 getCategoryCount() const;
  64.262  
  64.263  	//
  64.264  	// Mutators
  64.265  	//
  64.266  
  64.267 -	// Calling this method with an inventory item will either change
  64.268 -	// an existing item with a matching item_id, or will add the item
  64.269 +public:
  64.270 +	// Change an existing item with a matching item_id or add the item
  64.271  	// to the current inventory. Returns the change mask generated by
  64.272 -	// the update. No notifcation will be sent to observers. This
  64.273 +	// the update. No notification will be sent to observers. This
  64.274  	// method will only generate network traffic if the item had to be
  64.275  	// reparented.
  64.276 -	// *NOTE: In usage, you will want to perform cache accounting
  64.277 -	// operations in LLInventoryModel::accountForUpdate() or
  64.278 -	// LLViewerInventoryItem::updateServer() before calling this
  64.279 -	// method.
  64.280 +	//    NOTE: In usage, you will want to perform cache accounting
  64.281 +	//    operations in LLInventoryModel::accountForUpdate() or
  64.282 +	//    LLViewerInventoryItem::updateServer() before calling this method.
  64.283  	U32 updateItem(const LLViewerInventoryItem* item);
  64.284  
  64.285 -	// Calling this method with an inventory category will either
  64.286 -	// change an existing item with the matching id, or it will add
  64.287 +	// Change an existing item with the matching id or add
  64.288  	// the category. No notifcation will be sent to observers. This
  64.289  	// method will only generate network traffic if the item had to be
  64.290  	// reparented.
  64.291 -	// *NOTE: In usage, you will want to perform cache accounting
  64.292 -	// operations in LLInventoryModel::accountForUpdate() or
  64.293 -	// LLViewerInventoryCategory::updateServer() before calling this
  64.294 -	// method.
  64.295 +	//    NOTE: In usage, you will want to perform cache accounting
  64.296 +	//    operations in accountForUpdate() or LLViewerInventoryCategory::
  64.297 +	//    updateServer() before calling this method.
  64.298  	void updateCategory(const LLViewerInventoryCategory* cat);
  64.299  
  64.300 -	// This method will move the specified object id to the specified
  64.301 -	// category, update the internal structures. No cache accounting,
  64.302 +	// Move the specified object id to the specified category and
  64.303 +	// update the internal structures. No cache accounting,
  64.304  	// observer notification, or server update is performed.
  64.305  	void moveObject(const LLUUID& object_id, const LLUUID& cat_id);
  64.306  
  64.307 -	// delete a particular inventory object by ID. This will purge one
  64.308 -	// object from the internal data structures maintaining a
  64.309 -	// cosistent internal state. No cache accounting, observer
  64.310 +	//--------------------------------------------------------------------
  64.311 +	// Delete
  64.312 +	//--------------------------------------------------------------------
  64.313 +public:
  64.314 +	// Delete a particular inventory object by ID. Will purge one
  64.315 +	// object from the internal data structures, maintaining a
  64.316 +	// consistent internal state. No cache accounting, observer
  64.317  	// notification, or server update is performed.
  64.318  	void deleteObject(const LLUUID& id);
  64.319  	void removeItem(const LLUUID& item_id);
  64.320 @@ -246,12 +352,12 @@
  64.321  	// the server. Also updates linked items.
  64.322  	void purgeObject(const LLUUID& id);
  64.323  
  64.324 -	// This is a method which collects the descendents of the id
  64.325 +	// Collects and purges the descendants of the id
  64.326  	// provided. If the category is not found, no action is
  64.327  	// taken. This method goes through the long winded process of
  64.328  	// removing server representation of folders and items while doing
  64.329  	// cache accounting in a fairly efficient manner. This method does
  64.330 -	// not notify observers (though maybe it shouldd...)
  64.331 +	// not notify observers (though maybe it should...)
  64.332  	void purgeDescendentsOf(const LLUUID& id);
  64.333  
  64.334  	// This method optimally removes the referenced categories and
  64.335 @@ -261,101 +367,38 @@
  64.336  	void deleteFromServer(LLDynamicArray<LLUUID>& category_ids,
  64.337  						  LLDynamicArray<LLUUID>& item_ids);
  64.338  
  64.339 -	// Add/remove an observer. If the observer is destroyed, be sure
  64.340 -	// to remove it.
  64.341 -	void addObserver(LLInventoryObserver* observer);
  64.342 -	void removeObserver(LLInventoryObserver* observer);
  64.343 -	BOOL containsObserver(LLInventoryObserver* observer);
  64.344 -
  64.345 -	//
  64.346 -	// Misc Methods 
  64.347 -	//
  64.348 -
  64.349 -	// findCategoryUUIDForType() returns the uuid of the category that
  64.350 -	// specifies 'type' as what it defaults to containing. The
  64.351 -	// category is not necessarily only for that type. *NOTE: This
  64.352 -	// will create a new inventory category on the fly if one does not
  64.353 -	// exist.
  64.354 -
  64.355 -	// SDK: Added flag to specify whether the folder should be created if not found.  This fixes the horrible
  64.356 -	// multiple trash can bug.
  64.357 -	LLUUID findCategoryUUIDForType(LLFolderType::EType preferred_type, bool create_folder = true);
  64.358 -
  64.359  	// Get whatever special folder this object is a child of, if any.
  64.360  	const LLViewerInventoryCategory *getFirstNondefaultParent(const LLUUID& obj_id) const;
  64.361  
  64.362 -	// Call this method when it's time to update everyone on a new
  64.363 -	// state, by default, the inventory model will not update
  64.364 -	// observers automatically.
  64.365 -	// The optional argument 'service_name' is used by Agent Inventory Service [DEV-20328]
  64.366 -	void notifyObservers(const std::string service_name="");
  64.367  
  64.368 -	// This allows outsiders to tell the inventory if something has
  64.369 -	// been changed 'under the hood', but outside the control of the
  64.370 -	// inventory. For example, if we grant someone modify permissions,
  64.371 -	// then that changes the data structures for LLAvatarTracker, but
  64.372 -	// potentially affects inventory observers. This API makes sure
  64.373 -	// that the next notify will include that notification.
  64.374 -	void addChangedMask(U32 mask, const LLUUID& referent);
  64.375 -
  64.376 -	const std::set<LLUUID>& getChangedIDs() { return mChangedItemIDs; }
  64.377 -
  64.378 -	// This method to prepares a set of mock inventory which provides
  64.379 -	// minimal functionality before the actual arrival of inventory.
  64.380 -	//void mock(const LLUUID& root_id);
  64.381 -
  64.382 -	// make sure we have the descendents in the structure.
  64.383 -	void fetchDescendentsOf(const LLUUID& folder_id);
  64.384 -	
  64.385 -	// Add categories to a list to be fetched in bulk.
  64.386 -	static void bulkFetch(std::string url);
  64.387 -
  64.388 -	// call this method to request the inventory.
  64.389 -	//void requestFromServer(const LLUUID& agent_id);
  64.390 -
  64.391 -	// call this method on logout to save a terse representation
  64.392 -	void cache(const LLUUID& parent_folder_id, const LLUUID& agent_id);
  64.393 -
  64.394 -	// Generates a string containing the path to the item specified by
  64.395 -	// item_id.
  64.396 -	void appendPath(const LLUUID& id, std::string& path);
  64.397 -
  64.398 -	// message handling functionality
  64.399 -	static void registerCallbacks(LLMessageSystem* msg);
  64.400 -
  64.401 -	// Convenience function to create a new category. You could call
  64.402 -	// updateCatgory() with a newly generated UUID category, but this
  64.403 -	// version will take care of details like what the name should be
  64.404 -	// based on preferred type. Returns the UUID of the new
  64.405 -	// category. If you want to use the default name based on type,
  64.406 -	// pass in a NULL to the 'name parameter.
  64.407 +	//--------------------------------------------------------------------
  64.408 +	// Creation
  64.409 +	//--------------------------------------------------------------------
  64.410 +public:
  64.411 +	// Returns the UUID of the new category. If you want to use the default 
  64.412 +	// name based on type, pass in a NULL to the 'name' parameter.
  64.413  	LLUUID createNewCategory(const LLUUID& parent_id,
  64.414  							 LLFolderType::EType preferred_type,
  64.415 -							 const std::string& name);
  64.416 +							 const std::string& name,
  64.417 +							 void (*callback)(const LLSD&, void*) = NULL,
  64.418 +							 void* user_data = NULL);
  64.419  
  64.420  	LLUUID findCategoryByName(std::string name);
  64.421  
  64.422 -	// methods to load up inventory skeleton & meat. These are used
  64.423 -	// during authentication. return true if everything parsed.
  64.424 -	typedef std::map<std::string, std::string> response_t;
  64.425 -	typedef std::vector<response_t> options_t;
  64.426 -	// OGPX : Two loadSkeleton(), one for the XML-RPC logins, one for LLSD
  64.427 -	//... The concept of a skeleton being different from the cap that 
  64.428 -	//... we do inventory queries on should be examined, and the usage of
  64.429 -	//... the skeleton in querying the wearables needs to be examined as well.
  64.430 -	bool loadSkeleton(const options_t& options, const LLUUID& owner_id);
  64.431 -	bool loadSkeleton(const LLSD& options, const LLUUID& owner_id); 
  64.432 -
  64.433 -	// This is a brute force method to rebuild the entire parent-child
  64.434 -	// relations.
  64.435 -	void buildParentChildMap();
  64.436 +protected:
  64.437 +	// Internal methods that add inventory and make sure that all of
  64.438 +	// the internal data structures are consistent. These methods
  64.439 +	// should be passed pointers of newly created objects, and the
  64.440 +	// instance will take over the memory management from there.
  64.441 +	void addCategory(LLViewerInventoryCategory* category);
  64.442 +	void addItem(LLViewerInventoryItem* item);
  64.443  
  64.444  	//
  64.445  	// Category accounting.
  64.446  	//
  64.447  
  64.448 -	// This structure represents the number of items added or removed
  64.449 -	// from a category.
  64.450 +public:
  64.451 +	// Represents the number of items added or removed from a category.
  64.452  	struct LLCategoryUpdate
  64.453  	{
  64.454  		LLCategoryUpdate() : mDescendentDelta(0) {}
  64.455 @@ -367,8 +410,7 @@
  64.456  	};
  64.457  	typedef std::vector<LLCategoryUpdate> update_list_t;
  64.458  
  64.459 -	// This structure eixts to make it easier to account for deltas in
  64.460 -	// a map.
  64.461 +	// This exists to make it easier to account for deltas in a map.
  64.462  	struct LLInitializedS32
  64.463  	{
  64.464  		LLInitializedS32() : mValue(0) {}
  64.465 @@ -386,38 +428,72 @@
  64.466  	void accountForUpdate(const update_list_t& updates);
  64.467  	void accountForUpdate(const update_map_t& updates);
  64.468  
  64.469 -	// Return child status of category children. yes/no/maybe
  64.470 +	// Return (yes/no/maybe) child status of category children.
  64.471  	EHasChildren categoryHasChildren(const LLUUID& cat_id) const;
  64.472  
  64.473 -	// returns true iff category version is known and theoretical
  64.474 +	// Returns true if category version is known and theoretical
  64.475  	// descendents == actual descendents.
  64.476  	bool isCategoryComplete(const LLUUID& cat_id) const;
  64.477  
  64.478 -	// start and stop background breadth-first fetching of inventory contents
  64.479 -	// this gets triggered when performing a filter-search
  64.480 -	static void startBackgroundFetch(const LLUUID& cat_id = LLUUID::null); // start fetch process
  64.481 -    static void findLostItems();
  64.482 -	static BOOL backgroundFetchActive();
  64.483 -	static bool isEverythingFetched();
  64.484 -	static void backgroundFetch(void*); // background fetch idle function
  64.485 -	static void incrBulkFetch(S16 fetching) {  sBulkFetchCount+=fetching; if (sBulkFetchCount<0) sBulkFetchCount=0; }
  64.486 +	//
  64.487 +	// Notifications
  64.488 +	//
  64.489 +public:
  64.490 +	// Called by the idle loop.  Only updates if new state is detected.  Call 
  64.491 +	// notifyObservers() manually to update regardless of whether state change 
  64.492 +	// has been indicated.
  64.493 +	void idleNotifyObservers();
  64.494 +
  64.495 +	// Call to explicitly update everyone on a new state.
  64.496 +	void notifyObservers();
  64.497 +
  64.498 +	// Allows outsiders to tell the inventory if something has
  64.499 +	// been changed 'under the hood', but outside the control of the
  64.500 +	// inventory. The next notify will include that notification.
  64.501 +	void addChangedMask(U32 mask, const LLUUID& referent);
  64.502 +	const changed_items_t& getChangedIDs() { return mChangedItemIDs; }
  64.503 +
  64.504  protected:
  64.505 +	// Updates all linked items pointing to this id.
  64.506 +	void addChangedMaskForLinks(const LLUUID& object_id, U32 mask);
  64.507  
  64.508 -	// Internal methods which add inventory and make sure that all of
  64.509 -	// the internal data structures are consistent. These methods
  64.510 -	// should be passed pointers of newly created objects, and the
  64.511 -	// instance will take over the memory management from there.
  64.512 -	void addCategory(LLViewerInventoryCategory* category);
  64.513 -	void addItem(LLViewerInventoryItem* item);
  64.514 +private:
  64.515 +	// Flag set when notifyObservers is being called, to look for bugs
  64.516 +	// where it's called recursively.
  64.517 +	bool mIsNotifyObservers;
  64.518 +	// Variables used to track what has changed since the last notify.
  64.519 +	U32 mModifyMask;
  64.520 +	changed_items_t mChangedItemIDs;
  64.521  
  64.522 -	// Internal method which looks for a category with the specified
  64.523 -	// preferred type. Returns LLUUID::null if not found
  64.524 - 	LLUUID findCatUUID(LLFolderType::EType preferred_type);
  64.525  
  64.526 -	// Empty the entire contents
  64.527 -	void empty();
  64.528 +	//--------------------------------------------------------------------
  64.529 +	// Observers
  64.530 +	//--------------------------------------------------------------------
  64.531 +public:
  64.532 +	// If the observer is destroyed, be sure to remove it.
  64.533 +	void addObserver(LLInventoryObserver* observer);
  64.534 +	void removeObserver(LLInventoryObserver* observer);
  64.535 +	BOOL containsObserver(LLInventoryObserver* observer);
  64.536  
  64.537 -	// file import/export.
  64.538 +private:
  64.539 +	typedef std::set<LLInventoryObserver*> observer_list_t;
  64.540 +	observer_list_t mObservers;
  64.541 +
  64.542 +	//
  64.543 +	// Misc Methods 
  64.544 +	//
  64.545 +
  64.546 +	//--------------------------------------------------------------------
  64.547 +	// Callbacks
  64.548 +	//--------------------------------------------------------------------
  64.549 +public:
  64.550 +	// message handling functionality
  64.551 +	static void registerCallbacks(LLMessageSystem* msg);
  64.552 +
  64.553 +	//--------------------------------------------------------------------
  64.554 +	// File I/O
  64.555 +	//--------------------------------------------------------------------
  64.556 +protected:
  64.557  	static bool loadFromFile(const std::string& filename,
  64.558  							 cat_array_t& categories,
  64.559  							 item_array_t& items,
  64.560 @@ -426,88 +502,53 @@
  64.561  						   const cat_array_t& categories,
  64.562  						   const item_array_t& items); 
  64.563  
  64.564 -	// message handling functionality
  64.565 -	//static void processUseCachedInventory(LLMessageSystem* msg, void**);
  64.566 +	//--------------------------------------------------------------------
  64.567 +	// Message handling functionality
  64.568 +	//--------------------------------------------------------------------
  64.569 +public:
  64.570  	static void processUpdateCreateInventoryItem(LLMessageSystem* msg, void**);
  64.571  	static void processRemoveInventoryItem(LLMessageSystem* msg, void**);
  64.572  	static void processUpdateInventoryFolder(LLMessageSystem* msg, void**);
  64.573  	static void processRemoveInventoryFolder(LLMessageSystem* msg, void**);
  64.574 -	//static void processExchangeCallingcard(LLMessageSystem* msg, void**);
  64.575 -	//static void processAddCallingcard(LLMessageSystem* msg, void**);
  64.576 -	//static void processDeclineCallingcard(LLMessageSystem* msg, void**);
  64.577  	static void processSaveAssetIntoInventory(LLMessageSystem* msg, void**);
  64.578  	static void processBulkUpdateInventory(LLMessageSystem* msg, void**);
  64.579  	static void processInventoryDescendents(LLMessageSystem* msg, void**);
  64.580  	static void processMoveInventoryItem(LLMessageSystem* msg, void**);
  64.581  	static void processFetchInventoryReply(LLMessageSystem* msg, void**);
  64.582  	
  64.583 +protected:
  64.584  	bool messageUpdateCore(LLMessageSystem* msg, bool do_accounting);
  64.585  
  64.586 -	// Updates all linked items pointing to this id.
  64.587 -	void addChangedMaskForLinks(const LLUUID& object_id, U32 mask);
  64.588 +	//--------------------------------------------------------------------
  64.589 +	// Locking
  64.590 +	//--------------------------------------------------------------------
  64.591 +public:
  64.592 +	void lockDirectDescendentArrays(const LLUUID& cat_id,
  64.593 +									cat_array_t*& categories,
  64.594 +									item_array_t*& items);
  64.595 +	void unlockDirectDescendentArrays(const LLUUID& cat_id);
  64.596  
  64.597  protected:
  64.598  	cat_array_t* getUnlockedCatArray(const LLUUID& id);
  64.599  	item_array_t* getUnlockedItemArray(const LLUUID& id);
  64.600  	
  64.601 -protected:
  64.602 -	// Varaibles used to track what has changed since the last notify.
  64.603 -	U32 mModifyMask;
  64.604 -	typedef std::set<LLUUID> changed_items_t;
  64.605 -	changed_items_t mChangedItemIDs;
  64.606 -
  64.607 -	// Information for tracking the actual inventory. We index this
  64.608 -	// information in a lot of different ways so we can access
  64.609 -	// the inventory using several different identifiers.
  64.610 -	// mInventory member data is the 'master' list of inventory, and
  64.611 -	// mCategoryMap and mItemMap store uuid->object mappings. 
  64.612 -	typedef std::map<LLUUID, LLPointer<LLViewerInventoryCategory> > cat_map_t;
  64.613 -	typedef std::map<LLUUID, LLPointer<LLViewerInventoryItem> > item_map_t;
  64.614 -	//inv_map_t mInventory;
  64.615 -	cat_map_t mCategoryMap;
  64.616 -	item_map_t mItemMap;
  64.617 -
  64.618 +private:
  64.619  	std::map<LLUUID, bool> mCategoryLock;
  64.620  	std::map<LLUUID, bool> mItemLock;
  64.621  	
  64.622 -	// cache recent lookups
  64.623 -	mutable LLPointer<LLViewerInventoryItem> mLastItem;
  64.624 -
  64.625 -	// This last set of indices is used to map parents to children.
  64.626 -	typedef std::map<LLUUID, cat_array_t*> parent_cat_map_t;
  64.627 -	typedef std::map<LLUUID, item_array_t*> parent_item_map_t;
  64.628 -	parent_cat_map_t mParentChildCategoryTree;
  64.629 -	parent_item_map_t mParentChildItemTree;
  64.630 -
  64.631 -	typedef std::set<LLInventoryObserver*> observer_list_t;
  64.632 -	observer_list_t mObservers;
  64.633 -
  64.634 -	// completing the fetch once per session should be sufficient
  64.635 -	static BOOL sBackgroundFetchActive;
  64.636 -	static BOOL sTimelyFetchPending;
  64.637 -	static S32  sNumFetchRetries;
  64.638 -	static LLFrameTimer sFetchTimer;
  64.639 -	static F32 sMinTimeBetweenFetches;
  64.640 -	static F32 sMaxTimeBetweenFetches;
  64.641 -	static S16 sBulkFetchCount;
  64.642 -
  64.643 -	// This flag is used to handle an invalid inventory state.
  64.644 -	bool mIsAgentInvUsable;
  64.645 -
  64.646 -private:
  64.647 -	const static S32 sCurrentInvCacheVersion; // expected inventory cache version
  64.648 -	// Flag set when notifyObservers is being called, to look for bugs
  64.649 -	// where it's called recursively.
  64.650 -	BOOL mIsNotifyObservers;
  64.651 +	//--------------------------------------------------------------------
  64.652 +	// Debugging
  64.653 +	//--------------------------------------------------------------------
  64.654  
  64.655  public:
  64.656 -	// *NOTE: DEBUG functionality
  64.657  	void dumpInventory();
  64.658 -	static bool isBulkFetchProcessingComplete();
  64.659 -	static void stopBackgroundFetch(); // stop fetch process
  64.660 -
  64.661 -	static BOOL sFullFetchStarted;
  64.662 -	static BOOL sAllFoldersFetched; 
  64.663 +	//--------------------------------------------------------------------
  64.664 +	// Other
  64.665 +	//--------------------------------------------------------------------
  64.666 +public:
  64.667 +	// Generates a string containing the path to the item specified by
  64.668 +	// item_id.
  64.669 +	void appendPath(const LLUUID& id, std::string& path);
  64.670  };
  64.671  
  64.672  // a special inventory model for the agent
  64.673 @@ -758,7 +799,7 @@
  64.674  
  64.675  	typedef std::vector<LLUUID> item_ref_t;
  64.676  
  64.677 -	bool isEverythingComplete() const;
  64.678 +	bool isFinished() const;
  64.679  	void fetchItems(const item_ref_t& ids);
  64.680  	virtual void done() = 0;
  64.681  
  64.682 @@ -782,11 +823,11 @@
  64.683  
  64.684  	typedef std::vector<LLUUID> folder_ref_t;
  64.685  	void fetchDescendents(const folder_ref_t& ids);
  64.686 -	bool isEverythingComplete() const;
  64.687 +	bool isFinished() const;
  64.688  	virtual void done() = 0;
  64.689  
  64.690  protected:
  64.691 -	bool isComplete(LLViewerInventoryCategory* cat);
  64.692 +	bool isCategoryComplete(LLViewerInventoryCategory* cat);
  64.693  	folder_ref_t mIncompleteFolders;
  64.694  	folder_ref_t mCompleteFolders;
  64.695  };
    65.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    65.2 +++ b/indra/newview/llinventorymodelbackgroundfetch.cpp	Mon Feb 27 23:59:10 2012 -0800
    65.3 @@ -0,0 +1,640 @@
    65.4 +/** 
    65.5 + * @file llinventorymodelbackgroundfetch.cpp
    65.6 + * @brief Implementation of the inventory fetcher.
    65.7 + *
    65.8 + * $LicenseInfo:firstyear=2002&license=viewergpl$
    65.9 + * 
   65.10 + * Copyright (c) 2010, Linden Research, Inc.
   65.11 + * 
   65.12 + * Second Life Viewer Source Code
   65.13 + * The source code in this file ("Source Code") is provided by Linden Lab
   65.14 + * to you under the terms of the GNU General Public License, version 2.0
   65.15 + * ("GPL"), unless you have obtained a separate licensing agreement
   65.16 + * ("Other License"), formally executed by you and Linden Lab.  Terms of
   65.17 + * the GPL can be found in doc/GPL-license.txt in this distribution, or
   65.18 + * online at http://secondlifegrid.net/programs/open_source/licensing/gplv2
   65.19 + * 
   65.20 + * There are special exceptions to the terms and conditions of the GPL as
   65.21 + * it is applied to this Source Code. View the full text of the exception
   65.22 + * in the file doc/FLOSS-exception.txt in this software distribution, or
   65.23 + * online at
   65.24 + * http://secondlifegrid.net/programs/open_source/licensing/flossexception
   65.25 + * 
   65.26 + * By copying, modifying or distributing this software, you acknowledge
   65.27 + * that you have read and understood your obligations described above,
   65.28 + * and agree to abide by those obligations.
   65.29 + * 
   65.30 + * ALL LINDEN LAB SOURCE CODE IS PROVIDED "AS IS." LINDEN LAB MAKES NO
   65.31 + * WARRANTIES, EXPRESS, IMPLIED OR OTHERWISE, REGARDING ITS ACCURACY,
   65.32 + * COMPLETENESS OR PERFORMANCE.
   65.33 + * $/LicenseInfo$
   65.34 + */
   65.35 +
   65.36 +#include "llviewerprecompiledheaders.h"
   65.37 +
   65.38 +#include "llinventorymodelbackgroundfetch.h"
   65.39 +
   65.40 +#include "llagent.h"
   65.41 +#include "llappviewer.h"
   65.42 +#include "llcallbacklist.h"
   65.43 +#include "llinventorymodel.h"
   65.44 +#include "llinventoryview.h"
   65.45 +#include "llviewercontrol.h"
   65.46 +#include "llviewerinventory.h"
   65.47 +#include "llviewermessage.h"
   65.48 +#include "llviewerregion.h"
   65.49 +#include "llviewerwindow.h"
   65.50 +
   65.51 +const F32 MAX_TIME_FOR_SINGLE_FETCH = 10.f;
   65.52 +const S32 MAX_FETCH_RETRIES = 10;
   65.53 +
   65.54 +LLInventoryModelBackgroundFetch::LLInventoryModelBackgroundFetch()
   65.55 +:	mBackgroundFetchActive(FALSE),
   65.56 +	mAllFoldersFetched(FALSE),
   65.57 +	mRecursiveInventoryFetchStarted(FALSE),
   65.58 +	mRecursiveLibraryFetchStarted(FALSE),
   65.59 +	mNumFetchRetries(0),
   65.60 +	mMinTimeBetweenFetches(0.3f),
   65.61 +	mMaxTimeBetweenFetches(10.f),
   65.62 +	mTimelyFetchPending(FALSE),
   65.63 +	mBulkFetchCount(0)
   65.64 +{
   65.65 +}
   65.66 +
   65.67 +LLInventoryModelBackgroundFetch::~LLInventoryModelBackgroundFetch()
   65.68 +{
   65.69 +}
   65.70 +
   65.71 +bool LLInventoryModelBackgroundFetch::isBulkFetchProcessingComplete() const
   65.72 +{
   65.73 +	return mFetchQueue.empty() && mBulkFetchCount <= 0;
   65.74 +}
   65.75 +
   65.76 +bool LLInventoryModelBackgroundFetch::libraryFetchStarted() const
   65.77 +{
   65.78 +	return mRecursiveLibraryFetchStarted;
   65.79 +}
   65.80 +
   65.81 +bool LLInventoryModelBackgroundFetch::libraryFetchCompleted() const
   65.82 +{
   65.83 +	return libraryFetchStarted() && fetchQueueContainsNoDescendentsOf(gInventory.getLibraryRootFolderID());
   65.84 +}
   65.85 +
   65.86 +bool LLInventoryModelBackgroundFetch::libraryFetchInProgress() const
   65.87 +{
   65.88 +	return libraryFetchStarted() && !libraryFetchCompleted();
   65.89 +}
   65.90 +
   65.91 +bool LLInventoryModelBackgroundFetch::inventoryFetchStarted() const
   65.92 +{
   65.93 +	return mRecursiveInventoryFetchStarted;
   65.94 +}
   65.95 +
   65.96 +bool LLInventoryModelBackgroundFetch::inventoryFetchCompleted() const
   65.97 +{
   65.98 +	return inventoryFetchStarted() && fetchQueueContainsNoDescendentsOf(gInventory.getRootFolderID());
   65.99 +}
  65.100 +
  65.101 +bool LLInventoryModelBackgroundFetch::inventoryFetchInProgress() const
  65.102 +{
  65.103 +	return inventoryFetchStarted() && !inventoryFetchCompleted();
  65.104 +}
  65.105 +
  65.106 +bool LLInventoryModelBackgroundFetch::isEverythingFetched() const
  65.107 +{
  65.108 +	return mAllFoldersFetched;
  65.109 +}
  65.110 +
  65.111 +BOOL LLInventoryModelBackgroundFetch::backgroundFetchActive() const
  65.112 +{
  65.113 +	return mBackgroundFetchActive;
  65.114 +}
  65.115 +
  65.116 +void LLInventoryModelBackgroundFetch::start(const LLUUID& cat_id, BOOL recursive)
  65.117 +{
  65.118 +	if (!mAllFoldersFetched || cat_id.notNull())
  65.119 +	{
  65.120 +		LL_DEBUGS("InventoryFetch") << "Start fetching category: " << cat_id
  65.121 +									<< ", recursive: " << recursive << LL_ENDL;
  65.122 +
  65.123 +		mBackgroundFetchActive = TRUE;
  65.124 +		if (cat_id.isNull())
  65.125 +		{
  65.126 +			if (!mRecursiveInventoryFetchStarted)
  65.127 +			{
  65.128 +				mRecursiveInventoryFetchStarted |= recursive;
  65.129 +				mFetchQueue.push_back(FetchQueueInfo(gInventory.getRootFolderID(), recursive));
  65.130 +				gIdleCallbacks.addFunction(&LLInventoryModelBackgroundFetch::backgroundFetchCB, NULL);
  65.131 +			}
  65.132 +			if (!mRecursiveLibraryFetchStarted)
  65.133 +			{
  65.134 +				mRecursiveLibraryFetchStarted |= recursive;
  65.135 +				mFetchQueue.push_back(FetchQueueInfo(gInventory.getLibraryRootFolderID(), recursive));
  65.136 +				gIdleCallbacks.addFunction(&LLInventoryModelBackgroundFetch::backgroundFetchCB, NULL);
  65.137 +			}
  65.138 +		}
  65.139 +		else
  65.140 +		{
  65.141 +			// Specific folder requests go to front of queue.
  65.142 +			if (mFetchQueue.empty() || mFetchQueue.front().mCatUUID != cat_id)
  65.143 +			{
  65.144 +				mFetchQueue.push_front(FetchQueueInfo(cat_id, recursive));
  65.145 +				gIdleCallbacks.addFunction(&LLInventoryModelBackgroundFetch::backgroundFetchCB, NULL);
  65.146 +			}
  65.147 +			if (cat_id == gInventory.getLibraryRootFolderID())
  65.148 +			{
  65.149 +				mRecursiveLibraryFetchStarted |= recursive;
  65.150 +			}
  65.151 +			if (cat_id == gInventory.getRootFolderID())
  65.152 +			{
  65.153 +				mRecursiveInventoryFetchStarted |= recursive;
  65.154 +			}
  65.155 +		}
  65.156 +	}
  65.157 +}
  65.158 +
  65.159 +void LLInventoryModelBackgroundFetch::findLostItems()
  65.160 +{
  65.161 +	mBackgroundFetchActive = TRUE;
  65.162 +    mFetchQueue.push_back(FetchQueueInfo(LLUUID::null, TRUE));
  65.163 +    gIdleCallbacks.addFunction(&LLInventoryModelBackgroundFetch::backgroundFetchCB, NULL);
  65.164 +}
  65.165 +
  65.166 +void LLInventoryModelBackgroundFetch::stopBackgroundFetch()
  65.167 +{
  65.168 +	if (mBackgroundFetchActive)
  65.169 +	{
  65.170 +		mBackgroundFetchActive = FALSE;
  65.171 +		gIdleCallbacks.deleteFunction(&LLInventoryModelBackgroundFetch::backgroundFetchCB, NULL);
  65.172 +		mBulkFetchCount = 0;
  65.173 +		mMinTimeBetweenFetches = 0.0f;
  65.174 +	}
  65.175 +}
  65.176 +
  65.177 +void LLInventoryModelBackgroundFetch::setAllFoldersFetched()
  65.178 +{
  65.179 +	if (mRecursiveInventoryFetchStarted &&
  65.180 +		mRecursiveLibraryFetchStarted)
  65.181 +	{
  65.182 +		mAllFoldersFetched = TRUE;
  65.183 +	}
  65.184 +	stopBackgroundFetch();
  65.185 +}
  65.186 +
  65.187 +void LLInventoryModelBackgroundFetch::backgroundFetchCB(void *)
  65.188 +{
  65.189 +	LLInventoryModelBackgroundFetch::instance().backgroundFetch();
  65.190 +}
  65.191 +
  65.192 +void LLInventoryModelBackgroundFetch::backgroundFetch()
  65.193 +{
  65.194 +	if (mBackgroundFetchActive && gAgent.getRegion())
  65.195 +	{
  65.196 +		// If we'll be using the capability, we'll be sending batches and the
  65.197 +		// background thing isn't as important.
  65.198 +		std::string url = gAgent.getRegion()->getCapability("FetchInventoryDescendents2");   
  65.199 +		if (!url.empty()) 
  65.200 +		{
  65.201 +			bulkFetch(url);
  65.202 +			return;
  65.203 +		}
  65.204 +
  65.205 +		// No more categories to fetch, stop fetch process.
  65.206 +		if (mFetchQueue.empty())
  65.207 +		{
  65.208 +			llinfos << "Inventory fetch completed" << llendl;
  65.209 +
  65.210 +			setAllFoldersFetched();
  65.211 +			return;
  65.212 +		}
  65.213 +
  65.214 +		F32 fast_fetch_time = lerp(mMinTimeBetweenFetches, mMaxTimeBetweenFetches, 0.1f);
  65.215 +		F32 slow_fetch_time = lerp(mMinTimeBetweenFetches, mMaxTimeBetweenFetches, 0.5f);
  65.216 +		if (mTimelyFetchPending && mFetchTimer.getElapsedTimeF32() > slow_fetch_time)
  65.217 +		{
  65.218 +			// Double timeouts on failure.
  65.219 +			mMinTimeBetweenFetches = llmin(mMinTimeBetweenFetches * 2.f, 10.f);
  65.220 +			mMaxTimeBetweenFetches = llmin(mMaxTimeBetweenFetches * 2.f, 120.f);
  65.221 +			LL_DEBUGS("InventoryFetch") << "Inventory fetch times grown to ("
  65.222 +										<< mMinTimeBetweenFetches << ", "
  65.223 +										<< mMaxTimeBetweenFetches << ")"
  65.224 +										<< LL_ENDL;
  65.225 +			// fetch is no longer considered "timely" although we will wait for full time-out.
  65.226 +			mTimelyFetchPending = FALSE;
  65.227 +		}
  65.228 +
  65.229 +		while (1)
  65.230 +		{
  65.231 +			if (mFetchQueue.empty())
  65.232 +			{
  65.233 +				break;
  65.234 +			}
  65.235 +
  65.236 +			if (gDisconnected)
  65.237 +			{
  65.238 +				// Just bail if we are disconnected.
  65.239 +				break;
  65.240 +			}
  65.241 +
  65.242 +			const FetchQueueInfo info = mFetchQueue.front();
  65.243 +			LLViewerInventoryCategory* cat = gInventory.getCategory(info.mCatUUID);
  65.244 +
  65.245 +			// Category has been deleted, remove from queue.
  65.246 +			if (!cat)
  65.247 +			{
  65.248 +				mFetchQueue.pop_front();
  65.249 +				continue;
  65.250 +			}
  65.251 +
  65.252 +			if (mFetchTimer.getElapsedTimeF32() > mMinTimeBetweenFetches && 
  65.253 +				LLViewerInventoryCategory::VERSION_UNKNOWN == cat->getVersion())
  65.254 +			{
  65.255 +				// Category exists but has no children yet, fetch the descendants
  65.256 +				// for now, just request every time and rely on retry timer to throttle.
  65.257 +				if (cat->fetch())
  65.258 +				{
  65.259 +					mFetchTimer.reset();
  65.260 +					mTimelyFetchPending = TRUE;
  65.261 +				}
  65.262 +				else
  65.263 +				{
  65.264 +					//  The catagory also tracks if it has expired and here it says it hasn't
  65.265 +					//  yet.  Get out of here because nothing is going to happen until we
  65.266 +					//  update the timers.
  65.267 +					break;
  65.268 +				}
  65.269 +			}
  65.270 +			// Do I have all my children?
  65.271 +			else if (gInventory.isCategoryComplete(info.mCatUUID))
  65.272 +			{
  65.273 +				// Finished with this category, remove from queue.
  65.274 +				mFetchQueue.pop_front();
  65.275 +
  65.276 +				// Add all children to queue.
  65.277 +				LLInventoryModel::cat_array_t* categories;
  65.278 +				LLInventoryModel::item_array_t* items;
  65.279 +				gInventory.getDirectDescendentsOf(cat->getUUID(), categories, items);
  65.280 +				for (LLInventoryModel::cat_array_t::const_iterator it = categories->begin();
  65.281 +					 it != categories->end(); ++it)
  65.282 +				{
  65.283 +					mFetchQueue.push_back(FetchQueueInfo((*it)->getUUID(),info.mRecursive));
  65.284 +				}
  65.285 +
  65.286 +				// We received a response in less than the fast time.
  65.287 +				if (mTimelyFetchPending && mFetchTimer.getElapsedTimeF32() < fast_fetch_time)
  65.288 +				{
  65.289 +					// Shrink timeouts based on success.
  65.290 +					mMinTimeBetweenFetches = llmax(mMinTimeBetweenFetches * 0.8f, 0.3f);
  65.291 +					mMaxTimeBetweenFetches = llmax(mMaxTimeBetweenFetches * 0.8f, 10.f);
  65.292 +					LL_DEBUGS("InventoryFetch") << "Inventory fetch times shrunk to ("
  65.293 +												<< mMinTimeBetweenFetches << ", "
  65.294 +												<< mMaxTimeBetweenFetches << ")"
  65.295 +												<< LL_ENDL;
  65.296 +				}
  65.297 +
  65.298 +				mTimelyFetchPending = FALSE;
  65.299 +				continue;
  65.300 +			}
  65.301 +			else if (mFetchTimer.getElapsedTimeF32() > mMaxTimeBetweenFetches)
  65.302 +			{
  65.303 +				// Received first packet, but our num descendants does not match db's num descendants
  65.304 +				// so try again later.
  65.305 +				mFetchQueue.pop_front();
  65.306 +
  65.307 +				if (mNumFetchRetries++ < MAX_FETCH_RETRIES)
  65.308 +				{
  65.309 +					// push on back of queue
  65.310 +					mFetchQueue.push_back(info);
  65.311 +				}
  65.312 +				mTimelyFetchPending = FALSE;
  65.313 +				mFetchTimer.reset();
  65.314 +				break;
  65.315 +			}
  65.316 +
  65.317 +			// Not enough time has elapsed to do a new fetch
  65.318 +			break;
  65.319 +		}
  65.320 +	}
  65.321 +}
  65.322 +
  65.323 +void LLInventoryModelBackgroundFetch::incrBulkFetch(S16 fetching) 
  65.324 +{  
  65.325 +	mBulkFetchCount += fetching; 
  65.326 +	if (mBulkFetchCount < 0)
  65.327 +	{
  65.328 +		mBulkFetchCount = 0; 
  65.329 +	}
  65.330 +}
  65.331 +
  65.332 +class LLInventoryModelFetchDescendentsResponder: public LLHTTPClient::Responder
  65.333 +{
  65.334 +public:
  65.335 +	LLInventoryModelFetchDescendentsResponder(const LLSD& request_sd, uuid_vec_t recursive_cats)
  65.336 +	:	mRequestSD(request_sd),
  65.337 +		mRecursiveCatUUIDs(recursive_cats)
  65.338 +	{
  65.339 +	}
  65.340 +	//LLInventoryModelFetchDescendentsResponder() {};
  65.341 +	void result(const LLSD& content);
  65.342 +	void error(U32 status, const std::string& reason);
  65.343 +
  65.344 +protected:
  65.345 +	BOOL getIsRecursive(const LLUUID& cat_id) const;
  65.346 +
  65.347 +private:
  65.348 +	LLSD mRequestSD;
  65.349 +	uuid_vec_t mRecursiveCatUUIDs; // hack for storing away which cat fetches are recursive
  65.350 +};
  65.351 +
  65.352 +// If we get back a normal response, handle it here.
  65.353 +void LLInventoryModelFetchDescendentsResponder::result(const LLSD& content)
  65.354 +{
  65.355 +	LLInventoryModelBackgroundFetch *fetcher = LLInventoryModelBackgroundFetch::getInstance();
  65.356 +	if (content.has("folders"))
  65.357 +	{
  65.358 +		for (LLSD::array_const_iterator folder_it = content["folders"].beginArray();
  65.359 +			folder_it != content["folders"].endArray(); ++folder_it)
  65.360 +		{
  65.361 +			LLSD folder_sd = *folder_it;
  65.362 +
  65.363 +			//LLUUID agent_id = folder_sd["agent_id"];
  65.364 +
  65.365 +			//if (agent_id != gAgent.getID())	//This should never happen.
  65.366 +			//{
  65.367 +			//	llwarns << "Got a UpdateInventoryItem for the wrong agent."
  65.368 +			//			<< llendl;
  65.369 +			//	break;
  65.370 +			//}
  65.371 +
  65.372 +			LLUUID parent_id = folder_sd["folder_id"];
  65.373 +			LLUUID owner_id = folder_sd["owner_id"];
  65.374 +			S32    version  = (S32)folder_sd["version"].asInteger();
  65.375 +			S32    descendents = (S32)folder_sd["descendents"].asInteger();
  65.376 +			LLPointer<LLViewerInventoryCategory> tcategory = new LLViewerInventoryCategory(owner_id);
  65.377 +
  65.378 +            if (parent_id.isNull())
  65.379 +            {
  65.380 +			    LLPointer<LLViewerInventoryItem> titem = new LLViewerInventoryItem;
  65.381 +			    for (LLSD::array_const_iterator item_it = folder_sd["items"].beginArray();
  65.382 +				    item_it != folder_sd["items"].endArray(); ++item_it)
  65.383 +			    {
  65.384 +                    const LLUUID lost_uuid = gInventory.findCategoryUUIDForType(LLFolderType::FT_LOST_AND_FOUND);
  65.385 +                    if (lost_uuid.notNull())
  65.386 +                    {
  65.387 +				        LLSD item = *item_it;
  65.388 +				        titem->unpackMessage(item);
  65.389 +
  65.390 +                        LLInventoryModel::update_list_t update;
  65.391 +                        LLInventoryModel::LLCategoryUpdate new_folder(lost_uuid, 1);
  65.392 +                        update.push_back(new_folder);
  65.393 +                        gInventory.accountForUpdate(update);
  65.394 +
  65.395 +                        titem->setParent(lost_uuid);
  65.396 +                        titem->updateParentOnServer(FALSE);
  65.397 +                        gInventory.updateItem(titem);
  65.398 +                        gInventory.notifyObservers();
  65.399 +                    }
  65.400 +                }
  65.401 +            }
  65.402 +
  65.403 +	        LLViewerInventoryCategory* pcat = gInventory.getCategory(parent_id);
  65.404 +			if (!pcat)
  65.405 +			{
  65.406 +				continue;
  65.407 +			}
  65.408 +
  65.409 +			for (LLSD::array_const_iterator category_it = folder_sd["categories"].beginArray();
  65.410 +				category_it != folder_sd["categories"].endArray();
  65.411 +				++category_it)
  65.412 +			{
  65.413 +				LLSD category = *category_it;
  65.414 +				tcategory->fromLLSD(category); 
  65.415 +
  65.416 +				const BOOL recursive = getIsRecursive(tcategory->getUUID());
  65.417 +
  65.418 +				if (recursive)
  65.419 +				{
  65.420 +					fetcher->mFetchQueue.push_back(LLInventoryModelBackgroundFetch::FetchQueueInfo(tcategory->getUUID(), recursive));
  65.421 +				}
  65.422 +				else if (!gInventory.isCategoryComplete(tcategory->getUUID()))
  65.423 +				{
  65.424 +					gInventory.updateCategory(tcategory);
  65.425 +				}
  65.426 +			}
  65.427 +			LLPointer<LLViewerInventoryItem> titem = new LLViewerInventoryItem;
  65.428 +			for (LLSD::array_const_iterator item_it = folder_sd["items"].beginArray();
  65.429 +				item_it != folder_sd["items"].endArray(); ++item_it)
  65.430 +			{
  65.431 +				LLSD item = *item_it;
  65.432 +				titem->unpackMessage(item);
  65.433 +
  65.434 +				gInventory.updateItem(titem);
  65.435 +			}
  65.436 +
  65.437 +			// Set version and descendentcount according to message.
  65.438 +			LLViewerInventoryCategory* cat = gInventory.getCategory(parent_id);
  65.439 +			if (cat)
  65.440 +			{
  65.441 +				cat->setVersion(version);
  65.442 +				cat->setDescendentCount(descendents);
  65.443 +			}
  65.444 +		}
  65.445 +	}
  65.446 +
  65.447 +	if (content.has("bad_folders"))
  65.448 +	{
  65.449 +		for (LLSD::array_const_iterator folder_it = content["bad_folders"].beginArray();
  65.450 +			folder_it != content["bad_folders"].endArray(); ++folder_it)
  65.451 +		{
  65.452 +			LLSD folder_sd = *folder_it;
  65.453 +
  65.454 +			// These folders failed on the dataserver.  We probably don't want to retry them.
  65.455 +			llinfos << "Folder " << folder_sd["folder_id"].asString() 
  65.456 +					<< "Error: " << folder_sd["error"].asString() << llendl;
  65.457 +		}
  65.458 +	}
  65.459 +
  65.460 +	fetcher->incrBulkFetch(-1);
  65.461 +
  65.462 +	if (fetcher->isBulkFetchProcessingComplete())
  65.463 +	{
  65.464 +		llinfos << "Inventory fetch completed" << llendl;
  65.465 +		fetcher->setAllFoldersFetched();
  65.466 +	}
  65.467 +
  65.468 +	gInventory.notifyObservers();
  65.469 +}
  65.470 +
  65.471 +// If we get back an error (not found, etc...), handle it here.
  65.472 +void LLInventoryModelFetchDescendentsResponder::error(U32 status, const std::string& reason)
  65.473 +{
  65.474 +	LLInventoryModelBackgroundFetch *fetcher = LLInventoryModelBackgroundFetch::getInstance();
  65.475 +
  65.476 +	llinfos << "LLInventoryModelFetchDescendentsResponder::error " << status
  65.477 +			<< ": " << reason << llendl;
  65.478 +
  65.479 +	fetcher->incrBulkFetch(-1);
  65.480 +
  65.481 +	if (status == 499) // timed out
  65.482 +	{
  65.483 +		for (LLSD::array_const_iterator folder_it = mRequestSD["folders"].beginArray();
  65.484 +			folder_it != mRequestSD["folders"].endArray(); ++folder_it)
  65.485 +		{
  65.486 +			LLSD folder_sd = *folder_it;
  65.487 +			LLUUID folder_id = folder_sd["folder_id"];
  65.488 +			const BOOL recursive = getIsRecursive(folder_id);
  65.489 +			fetcher->mFetchQueue.push_front(LLInventoryModelBackgroundFetch::FetchQueueInfo(folder_id, recursive));
  65.490 +		}
  65.491 +	}
  65.492 +	else
  65.493 +	{
  65.494 +		if (fetcher->isBulkFetchProcessingComplete())
  65.495 +		{
  65.496 +			fetcher->setAllFoldersFetched();
  65.497 +		}
  65.498 +	}
  65.499 +	gInventory.notifyObservers();
  65.500 +}
  65.501 +
  65.502 +BOOL LLInventoryModelFetchDescendentsResponder::getIsRecursive(const LLUUID& cat_id) const
  65.503 +{
  65.504 +	return (std::find(mRecursiveCatUUIDs.begin(),mRecursiveCatUUIDs.end(), cat_id) != mRecursiveCatUUIDs.end());
  65.505 +}
  65.506 +
  65.507 +// Bundle up a bunch of requests to send all at once.
  65.508 +// static   
  65.509 +void LLInventoryModelBackgroundFetch::bulkFetch(std::string url)
  65.510 +{
  65.511 +	// Background fetch is called from gIdleCallbacks in a loop until background
  65.512 +	// fetch is stopped.
  65.513 +	// If there are items in mFetchQueue, we want to check the time since the
  65.514 +	// last bulkFetch was sent.
  65.515 +	// If it exceeds our retry time, go ahead and fire off another batch.  
  65.516 +	// Stopbackgroundfetch will be run from the Responder instead of here.  
  65.517 +
  65.518 +	S16 max_concurrent_fetches = 8;
  65.519 +	F32 new_min_time = 0.5f;			//HACK!  Clean this up when old code goes away entirely.
  65.520 +	if (mMinTimeBetweenFetches < new_min_time) 
  65.521 +	{
  65.522 +		mMinTimeBetweenFetches=new_min_time;  //HACK!  See above.
  65.523 +	}
  65.524 +
  65.525 +	if (gDisconnected || mBulkFetchCount > max_concurrent_fetches ||
  65.526 +		mFetchTimer.getElapsedTimeF32() < mMinTimeBetweenFetches)
  65.527 +	{
  65.528 +		return; // just bail if we are disconnected
  65.529 +	}
  65.530 +
  65.531 +	U32 folder_count = 0;
  65.532 +	U32 max_batch_size = 5;
  65.533 +
  65.534 +	U32 sort_order = gSavedSettings.getU32(LLInventoryPanel::DEFAULT_SORT_ORDER) & 0x1;
  65.535 +
  65.536 +	uuid_vec_t recursive_cats;
  65.537 +
  65.538 +	LLSD body;
  65.539 +	LLSD body_lib;
  65.540 +
  65.541 +	while (!mFetchQueue.empty() && folder_count < max_batch_size)
  65.542 +	{
  65.543 +		const FetchQueueInfo& fetch_info = mFetchQueue.front();
  65.544 +		const LLUUID &cat_id = fetch_info.mCatUUID;
  65.545 +        if (cat_id.isNull()) //DEV-17797
  65.546 +        {
  65.547 +			LLSD folder_sd;
  65.548 +			folder_sd["folder_id"]		= LLUUID::null.asString();
  65.549 +			folder_sd["owner_id"]		= gAgent.getID();
  65.550 +			folder_sd["sort_order"]		= (LLSD::Integer)sort_order;
  65.551 +			folder_sd["fetch_folders"]	= (LLSD::Boolean)FALSE;
  65.552 +			folder_sd["fetch_items"]	= (LLSD::Boolean)TRUE;
  65.553 +			body["folders"].append(folder_sd);
  65.554 +            folder_count++;
  65.555 +        }
  65.556 +        else
  65.557 +        {
  65.558 +		    const LLViewerInventoryCategory* cat = gInventory.getCategory(cat_id);
  65.559 +
  65.560 +		    if (cat)
  65.561 +		    {
  65.562 +			    if (LLViewerInventoryCategory::VERSION_UNKNOWN == cat->getVersion())
  65.563 +			    {
  65.564 +				    LLSD folder_sd;
  65.565 +				    folder_sd["folder_id"]		= cat->getUUID();
  65.566 +				    folder_sd["owner_id"]		= cat->getOwnerID();
  65.567 +				    folder_sd["sort_order"]		= (LLSD::Integer)sort_order;
  65.568 +				    folder_sd["fetch_folders"]	= TRUE; //(LLSD::Boolean)sFullFetchStarted;
  65.569 +				    folder_sd["fetch_items"]	= (LLSD::Boolean)TRUE;
  65.570 +				    
  65.571 +				    if (ALEXANDRIA_LINDEN_ID == cat->getOwnerID())
  65.572 +					    body_lib["folders"].append(folder_sd);
  65.573 +				    else
  65.574 +					    body["folders"].append(folder_sd);
  65.575 +				    folder_count++;
  65.576 +			    }
  65.577 +				// May already have this folder, but append child folders to list.
  65.578 +			    if (fetch_info.mRecursive)
  65.579 +			    {
  65.580 +					LLInventoryModel::cat_array_t* categories;
  65.581 +					LLInventoryModel::item_array_t* items;
  65.582 +					gInventory.getDirectDescendentsOf(cat->getUUID(), categories, items);
  65.583 +					for (LLInventoryModel::cat_array_t::const_iterator it = categories->begin();
  65.584 +						 it != categories->end(); ++it)
  65.585 +					{
  65.586 +						mFetchQueue.push_back(FetchQueueInfo((*it)->getUUID(), fetch_info.mRecursive));
  65.587 +				    }
  65.588 +			    }
  65.589 +		    }
  65.590 +        }
  65.591 +		if (fetch_info.mRecursive)
  65.592 +			recursive_cats.push_back(cat_id);
  65.593 +
  65.594 +		mFetchQueue.pop_front();
  65.595 +	}
  65.596 +
  65.597 +	if (folder_count > 0)
  65.598 +	{
  65.599 +		mBulkFetchCount++;
  65.600 +		if (body["folders"].size())
  65.601 +		{
  65.602 +			LLInventoryModelFetchDescendentsResponder *fetcher = new LLInventoryModelFetchDescendentsResponder(body, recursive_cats);
  65.603 +			LLHTTPClient::post(url, body, fetcher, 300.0);
  65.604 +		}
  65.605 +		if (body_lib["folders"].size())
  65.606 +		{
  65.607 +			std::string capability = "FetchLibDescendents2";
  65.608 +			std::string url_lib = gAgent.getRegion()->getCapability(capability);
  65.609 +			if (url_lib.empty())
  65.610 +			{
  65.611 +				capability = "FetchLibDescendents";
  65.612 +				url_lib = gAgent.getRegion()->getCapability(capability);
  65.613 +			}
  65.614 +			if (url_lib.empty() && gSavedSettings.getBOOL("OpenGridProtocol"))
  65.615 +			{
  65.616 +				capability = "agent/inventory_library";
  65.617 +				url_lib = gAgent.getCapability(capability);
  65.618 +			}
  65.619 +			LL_DEBUGS("InventoryFetch") << "Using capability " << capability
  65.620 +										<< " for fetch" << LL_ENDL;
  65.621 +
  65.622 +			LLInventoryModelFetchDescendentsResponder *fetcher = new LLInventoryModelFetchDescendentsResponder(body_lib, recursive_cats);
  65.623 +			LLHTTPClient::post(url_lib, body_lib, fetcher, 300.0);
  65.624 +		}
  65.625 +		mFetchTimer.reset();
  65.626 +	}
  65.627 +	else if (isBulkFetchProcessingComplete())
  65.628 +	{
  65.629 +		setAllFoldersFetched();
  65.630 +	}
  65.631 +}
  65.632 +
  65.633 +bool LLInventoryModelBackgroundFetch::fetchQueueContainsNoDescendentsOf(const LLUUID& cat_id) const
  65.634 +{
  65.635 +	for (fetch_queue_t::const_iterator it = mFetchQueue.begin();
  65.636 +		 it != mFetchQueue.end(); ++it)
  65.637 +	{
  65.638 +		const LLUUID& fetch_id = (*it).mCatUUID;
  65.639 +		if (gInventory.isObjectDescendentOf(fetch_id, cat_id))
  65.640 +			return false;
  65.641 +	}
  65.642 +	return true;
  65.643 +}
    66.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    66.2 +++ b/indra/newview/llinventorymodelbackgroundfetch.h	Mon Feb 27 23:59:10 2012 -0800
    66.3 @@ -0,0 +1,107 @@
    66.4 +/** 
    66.5 + * @file llinventorymodelbackgroundfetch.h
    66.6 + * @brief LLInventoryModelBackgroundFetch class header file
    66.7 + *
    66.8 + * $LicenseInfo:firstyear=2002&license=viewergpl$
    66.9 + * 
   66.10 + * Copyright (c) 2010, Linden Research, Inc.
   66.11 + * 
   66.12 + * Second Life Viewer Source Code
   66.13 + * The source code in this file ("Source Code") is provided by Linden Lab
   66.14 + * to you under the terms of the GNU General Public License, version 2.0
   66.15 + * ("GPL"), unless you have obtained a separate licensing agreement
   66.16 + * ("Other License"), formally executed by you and Linden Lab.  Terms of
   66.17 + * the GPL can be found in doc/GPL-license.txt in this distribution, or
   66.18 + * online at http://secondlifegrid.net/programs/open_source/licensing/gplv2
   66.19 + * 
   66.20 + * There are special exceptions to the terms and conditions of the GPL as
   66.21 + * it is applied to this Source Code. View the full text of the exception
   66.22 + * in the file doc/FLOSS-exception.txt in this software distribution, or
   66.23 + * online at
   66.24 + * http://secondlifegrid.net/programs/open_source/licensing/flossexception
   66.25 + * 
   66.26 + * By copying, modifying or distributing this software, you acknowledge
   66.27 + * that you have read and understood your obligations described above,
   66.28 + * and agree to abide by those obligations.
   66.29 + * 
   66.30 + * ALL LINDEN LAB SOURCE CODE IS PROVIDED "AS IS." LINDEN LAB MAKES NO
   66.31 + * WARRANTIES, EXPRESS, IMPLIED OR OTHERWISE, REGARDING ITS ACCURACY,
   66.32 + * COMPLETENESS OR PERFORMANCE.
   66.33 + * $/LicenseInfo$
   66.34 + */
   66.35 +
   66.36 +#ifndef LL_LLINVENTORYMODELBACKGROUNDFETCH_H
   66.37 +#define LL_LLINVENTORYMODELBACKGROUNDFETCH_H
   66.38 +
   66.39 +#include "llsingleton.h"
   66.40 +#include "lluuid.h"
   66.41 +
   66.42 +//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
   66.43 +// Class LLInventoryModelBackgroundFetch
   66.44 +//
   66.45 +// This class handles background fetches, which are fetches of
   66.46 +// inventory folder.  Fetches can be recursive or not.
   66.47 +//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
   66.48 +class LLInventoryModelBackgroundFetch : public LLSingleton<LLInventoryModelBackgroundFetch>
   66.49 +{
   66.50 +	friend class LLInventoryModelFetchDescendentsResponder;
   66.51 +
   66.52 +public:
   66.53 +	LLInventoryModelBackgroundFetch();
   66.54 +	~LLInventoryModelBackgroundFetch();
   66.55 +
   66.56 +	// Start and stop background breadth-first fetching of inventory contents.
   66.57 +	// This gets triggered when performing a filter-search.
   66.58 +	void start(const LLUUID& cat_id = LLUUID::null, BOOL recursive = TRUE);
   66.59 +
   66.60 +	BOOL backgroundFetchActive() const;
   66.61 +	bool isEverythingFetched() const; // completing the fetch once per session should be sufficient
   66.62 +
   66.63 +	bool libraryFetchStarted() const;
   66.64 +	bool libraryFetchCompleted() const;
   66.65 +	bool libraryFetchInProgress() const;
   66.66 +
   66.67 +	bool inventoryFetchStarted() const;
   66.68 +	bool inventoryFetchCompleted() const;
   66.69 +	bool inventoryFetchInProgress() const;
   66.70 +
   66.71 +    void findLostItems();
   66.72 +protected:
   66.73 +	void incrBulkFetch(S16 fetching);
   66.74 +	bool isBulkFetchProcessingComplete() const;
   66.75 +	void bulkFetch(std::string url);
   66.76 +
   66.77 +	void backgroundFetch();
   66.78 +	static void backgroundFetchCB(void*); // background fetch idle function
   66.79 +	void stopBackgroundFetch(); // stop fetch process
   66.80 +
   66.81 +	void setAllFoldersFetched();
   66.82 +	bool fetchQueueContainsNoDescendentsOf(const LLUUID& cat_id) const;
   66.83 +private:
   66.84 + 	BOOL mRecursiveInventoryFetchStarted;
   66.85 +	BOOL mRecursiveLibraryFetchStarted;
   66.86 +	BOOL mAllFoldersFetched;
   66.87 +
   66.88 +	BOOL mBackgroundFetchActive;
   66.89 +	S16 mBulkFetchCount;
   66.90 +	BOOL mTimelyFetchPending;
   66.91 +	S32 mNumFetchRetries;
   66.92 +
   66.93 +	LLFrameTimer mFetchTimer;
   66.94 +	F32 mMinTimeBetweenFetches;
   66.95 +	F32 mMaxTimeBetweenFetches;
   66.96 +
   66.97 +	struct FetchQueueInfo
   66.98 +	{
   66.99 +		FetchQueueInfo(const LLUUID& id, BOOL recursive) :
  66.100 +			mCatUUID(id), mRecursive(recursive)
  66.101 +		{
  66.102 +		}
  66.103 +		LLUUID mCatUUID;
  66.104 +		BOOL mRecursive;
  66.105 +	};
  66.106 +	typedef std::deque<FetchQueueInfo> fetch_queue_t;
  66.107 +	fetch_queue_t mFetchQueue;
  66.108 +};
  66.109 +
  66.110 +#endif // LL_LLINVENTORYMODELBACKGROUNDFETCH_H
    67.1 --- a/indra/newview/llinventoryview.cpp	Mon Feb 27 23:28:58 2012 -0800
    67.2 +++ b/indra/newview/llinventoryview.cpp	Mon Feb 27 23:59:10 2012 -0800
    67.3 @@ -57,6 +57,7 @@
    67.4  #include "llgesturemgr.h"
    67.5  #include "lliconctrl.h"
    67.6  #include "llinventorymodel.h"
    67.7 +#include "llinventorymodelbackgroundfetch.h"
    67.8  #include "llinventoryclipboard.h"
    67.9  #include "lllineeditor.h"
   67.10  #include "llmenugl.h"
   67.11 @@ -674,7 +675,7 @@
   67.12  
   67.13  void LLInventoryView::draw()
   67.14  {
   67.15 - 	if (LLInventoryModel::isEverythingFetched())
   67.16 + 	if (LLInventoryModelBackgroundFetch::instance().isEverythingFetched())
   67.17  	{
   67.18  		LLLocale locale(LLLocale::USER_LOCALE);
   67.19  		std::ostringstream title;
   67.20 @@ -849,7 +850,7 @@
   67.21  {
   67.22  	std::ostringstream title;
   67.23  	title << "Inventory";
   67.24 - 	if (LLInventoryModel::backgroundFetchActive())
   67.25 + 	if (LLInventoryModelBackgroundFetch::instance().backgroundFetchActive())
   67.26  	{
   67.27  		LLLocale locale(LLLocale::USER_LOCALE);
   67.28  		std::string item_count_string;
   67.29 @@ -1006,7 +1007,7 @@
   67.30  		addDependentFloater(mFinderHandle);
   67.31  
   67.32  		// start background fetch of folders
   67.33 -		gInventory.startBackgroundFetch();
   67.34 +		LLInventoryModelBackgroundFetch::instance().start();
   67.35  
   67.36  		mFloaterControls[std::string("Inventory.ShowFilters")]->setValue(TRUE);
   67.37  	}
   67.38 @@ -1082,7 +1083,7 @@
   67.39  		return;
   67.40  	}
   67.41  
   67.42 -	gInventory.startBackgroundFetch();
   67.43 +	LLInventoryModelBackgroundFetch::instance().start();
   67.44  
   67.45  	std::string filter_text = search_string;
   67.46  	std::string uppercase_search_string = filter_text;
   67.47 @@ -1435,7 +1436,7 @@
   67.48  	if (filter->isActive())
   67.49  	{
   67.50  		// If our filter is active we may be the first thing requiring a fetch so we better start it here.
   67.51 -		gInventory.startBackgroundFetch();
   67.52 +		LLInventoryModelBackgroundFetch::instance().start();
   67.53  	}
   67.54  	self->setFilterTextFromFilter();
   67.55  	self->updateSortControls();
   67.56 @@ -1960,7 +1961,8 @@
   67.57  	if(handled)
   67.58  	{
   67.59  		ECursorType cursor = getWindow()->getCursor();
   67.60 -		if (LLInventoryModel::backgroundFetchActive() && cursor == UI_CURSOR_ARROW)
   67.61 +		if (LLInventoryModelBackgroundFetch::instance().backgroundFetchActive()
   67.62 +			&& cursor == UI_CURSOR_ARROW)
   67.63  		{
   67.64  			// replace arrow cursor with arrow and hourglass cursor
   67.65  			getWindow()->setCursor(UI_CURSOR_WORKING);
    68.1 --- a/indra/newview/llmeshrepository.cpp	Mon Feb 27 23:28:58 2012 -0800
    68.2 +++ b/indra/newview/llmeshrepository.cpp	Mon Feb 27 23:59:10 2012 -0800
    68.3 @@ -1066,17 +1066,19 @@
    68.4  
    68.5  bool LLMeshRepoThread::lodReceived(const LLVolumeParams& mesh_params, S32 lod, U8* data, S32 data_size)
    68.6  {
    68.7 -	LLVolume* volume = new LLVolume(mesh_params, LLVolumeLODGroup::getVolumeScaleFromDetail(lod));
    68.8 +	LLPointer<LLVolume> volume = new LLVolume(mesh_params, LLVolumeLODGroup::getVolumeScaleFromDetail(lod));
    68.9  	std::string mesh_string((char*) data, data_size);
   68.10  	std::istringstream stream(mesh_string);
   68.11  
   68.12  	if (volume->unpackVolumeFaces(stream, data_size))
   68.13  	{
   68.14 -		LoadedMesh mesh(volume, mesh_params, lod);
   68.15  		if (volume->getNumFaces() > 0)
   68.16  		{
   68.17 -			LLMutexLock lock(mMutex);
   68.18 -			mLoadedQ.push(mesh);
   68.19 +			LoadedMesh mesh(volume, mesh_params, lod);
   68.20 +			{
   68.21 +				LLMutexLock lock(mMutex);
   68.22 +				mLoadedQ.push(mesh);
   68.23 +			}
   68.24  			return true;
   68.25  		}
   68.26  	}
    69.1 --- a/indra/newview/llpanelaudioprefs.cpp	Mon Feb 27 23:28:58 2012 -0800
    69.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
    69.3 @@ -1,143 +0,0 @@
    69.4 -/** 
    69.5 - * @file llpanelaudioprefs.cpp
    69.6 - * @brief Audio preference implementation
    69.7 - *
    69.8 - * $LicenseInfo:firstyear=2001&license=viewergpl$
    69.9 - * 
   69.10 - * Copyright (c) 2001-2009, Linden Research, Inc.
   69.11 - * 
   69.12 - * Second Life Viewer Source Code
   69.13 - * The source code in this file ("Source Code") is provided by Linden Lab
   69.14 - * to you under the terms of the GNU General Public License, version 2.0
   69.15 - * ("GPL"), unless you have obtained a separate licensing agreement
   69.16 - * ("Other License"), formally executed by you and Linden Lab.  Terms of
   69.17 - * the GPL can be found in doc/GPL-license.txt in this distribution, or
   69.18 - * online at http://secondlifegrid.net/programs/open_source/licensing/gplv2
   69.19 - * 
   69.20 - * There are special exceptions to the terms and conditions of the GPL as
   69.21 - * it is applied to this Source Code. View the full text of the exception
   69.22 - * in the file doc/FLOSS-exception.txt in this software distribution, or
   69.23 - * online at
   69.24 - * http://secondlifegrid.net/programs/open_source/licensing/flossexception
   69.25 - * 
   69.26 - * By copying, modifying or distributing this software, you acknowledge
   69.27 - * that you have read and understood your obligations described above,
   69.28 - * and agree to abide by those obligations.
   69.29 - * 
   69.30 - * ALL LINDEN LAB SOURCE CODE IS PROVIDED "AS IS." LINDEN LAB MAKES NO
   69.31 - * WARRANTIES, EXPRESS, IMPLIED OR OTHERWISE, REGARDING ITS ACCURACY,
   69.32 - * COMPLETENESS OR PERFORMANCE.
   69.33 - * $/LicenseInfo$
   69.34 - */
   69.35 -
   69.36 -#include "llviewerprecompiledheaders.h"
   69.37 -
   69.38 -// file include
   69.39 -#include "llpanelaudioprefs.h"
   69.40 -
   69.41 -// linden library includes
   69.42 -#include "llerror.h"
   69.43 -#include "llrect.h"
   69.44 -#include "llstring.h"
   69.45 -#include "llfontgl.h"
   69.46 -
   69.47 -// project includes
   69.48 -#include "llaudioengine.h"
   69.49 -#include "llbutton.h"
   69.50 -#include "llcheckboxctrl.h"
   69.51 -#include "llcombobox.h"
   69.52 -#include "llfirstuse.h"
   69.53 -#include "llnotify.h"
   69.54 -#include "llpanelaudiovolume.h"
   69.55 -#include "llparcel.h"
   69.56 -#include "llradiogroup.h"
   69.57 -#include "llresmgr.h"
   69.58 -#include "llslider.h"
   69.59 -#include "llsliderctrl.h"
   69.60 -#include "llspinctrl.h"
   69.61 -#include "lltextbox.h"
   69.62 -#include "llui.h"
   69.63 -#include "llviewerparcelmgr.h"
   69.64 -#include "lluictrlfactory.h"
   69.65 -#include "llviewerwindow.h"
   69.66 -#include "llviewercontrol.h"
   69.67 -#include "llstartup.h"
   69.68 -#include "floatermedialists.h"
   69.69 -
   69.70 -//
   69.71 -// Static functions
   69.72 -//
   69.73 -
   69.74 -//static
   69.75 -void* LLPanelAudioPrefs::createVolumePanel(void* data)
   69.76 -{
   69.77 -	LLPanelAudioVolume* panel = new LLPanelAudioVolume();
   69.78 -	return panel;
   69.79 -}
   69.80 -
   69.81 -LLPanelAudioPrefs::LLPanelAudioPrefs()
   69.82 -{
   69.83 -	mFactoryMap["Volume Panel"]	= LLCallbackMap(createVolumePanel, NULL);
   69.84 -	
   69.85 -	LLUICtrlFactory::getInstance()->buildPanel(this, "panel_preferences_audio.xml", &getFactoryMap());
   69.86 -}
   69.87 -
   69.88 -LLPanelAudioPrefs::~LLPanelAudioPrefs()
   69.89 -{
   69.90 -	// Children all cleaned up by default view destructor.
   69.91 -}
   69.92 -
   69.93 -BOOL LLPanelAudioPrefs::postBuild()
   69.94 -{
   69.95 -	
   69.96 -	getChild<LLButton>("open_media_lists")->setClickedCallback(FloaterMediaLists::show, NULL);
   69.97 -	if(LLStartUp::getStartupState() >= STATE_INVENTORY_SEND)childSetEnabled("open_media_lists",true);
   69.98 -	
   69.99 -	refreshValues(); // initialize member data from saved settings
  69.100 -	return TRUE;
  69.101 -}
  69.102 -
  69.103 -void LLPanelAudioPrefs::refreshValues()
  69.104 -{
  69.105 -	mPreviousVolume = gSavedSettings.getF32("AudioLevelMaster");
  69.106 -	mPreviousSFX = gSavedSettings.getF32("AudioLevelSFX");
  69.107 -	mPreviousUI = gSavedSettings.getF32("AudioLevelUI");
  69.108 -	mPreviousEnvironment = gSavedSettings.getF32("AudioLevelAmbient");
  69.109 -	mPreviousMusicVolume = gSavedSettings.getF32("AudioLevelMusic");
  69.110 -	mPreviousMediaVolume = gSavedSettings.getF32("AudioLevelMedia");
  69.111 -	mPreviousDoppler = gSavedSettings.getF32("AudioLevelDoppler");
  69.112 -	mPreviousRolloff = gSavedSettings.getF32("AudioLevelRolloff");
  69.113 -
  69.114 -	mPreviousMoneyThreshold = gSavedSettings.getF32("UISndMoneyChangeThreshold");
  69.115 -	mPreviousHealthThreshold = gSavedSettings.getF32("UISndHealthReductionThreshold");
  69.116 -
  69.117 -	mPreviousStreamingMusic = gSavedSettings.getBOOL("AudioStreamingMusic");
  69.118 -	mPreviousStreamingVideo = gSavedSettings.getBOOL("AudioStreamingVideo");
  69.119 -	mPreviousMediaFilter = gSavedSettings.getBOOL("MediaEnableFilter");
  69.120 -	
  69.121 -	mPreviousMuteAudio = gSavedSettings.getBOOL("MuteAudio");
  69.122 -	mPreviousMuteWhenMinimized = gSavedSettings.getBOOL("MuteWhenMinimized");
  69.123 -}
  69.124 -
  69.125 -void LLPanelAudioPrefs::cancel()
  69.126 -{
  69.127 -	gSavedSettings.setF32("AudioLevelMaster", mPreviousVolume );
  69.128 -	gSavedSettings.setF32("AudioLevelUI", mPreviousUI );
  69.129 -	gSavedSettings.setF32("AudioLevelSFX", mPreviousSFX );
  69.130 -	gSavedSettings.setF32("AudioLevelAmbient", mPreviousEnvironment );
  69.131 -	gSavedSettings.setF32("AudioLevelMusic", mPreviousMusicVolume);
  69.132 -	gSavedSettings.setF32("AudioLevelMedia", mPreviousMediaVolume);
  69.133 -	gSavedSettings.setF32("AudioLevelDoppler", mPreviousDoppler );
  69.134 -	gSavedSettings.setF32("AudioLevelRolloff", mPreviousRolloff );
  69.135 -
  69.136 -	gSavedSettings.setF32("UISndMoneyChangeThreshold", mPreviousMoneyThreshold );
  69.137 -	gSavedSettings.setF32("UISndHealthReductionThreshold", mPreviousHealthThreshold );
  69.138 -
  69.139 -	gSavedSettings.setBOOL("AudioStreamingMusic", mPreviousStreamingMusic );
  69.140 -	gSavedSettings.setBOOL("AudioStreamingVideo", mPreviousStreamingVideo );
  69.141 -	gSavedSettings.setBOOL("MediaEnableFilter", mPreviousMediaFilter);
  69.142 -
  69.143 -	
  69.144 -	gSavedSettings.setBOOL("MuteAudio", mPreviousMuteAudio );
  69.145 -	gSavedSettings.setBOOL("MuteWhenMinimized", mPreviousMuteWhenMinimized );
  69.146 -}
    70.1 --- a/indra/newview/llpanelaudioprefs.h	Mon Feb 27 23:28:58 2012 -0800
    70.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
    70.3 @@ -1,83 +0,0 @@
    70.4 -/** 
    70.5 - * @file llpanelaudioprefs.h
    70.6 - * @brief Audio preference definitions
    70.7 - *
    70.8 - * $LicenseInfo:firstyear=2001&license=viewergpl$
    70.9 - * 
   70.10 - * Copyright (c) 2001-2009, Linden Research, Inc.
   70.11 - * 
   70.12 - * Second Life Viewer Source Code
   70.13 - * The source code in this file ("Source Code") is provided by Linden Lab
   70.14 - * to you under the terms of the GNU General Public License, version 2.0
   70.15 - * ("GPL"), unless you have obtained a separate licensing agreement
   70.16 - * ("Other License"), formally executed by you and Linden Lab.  Terms of
   70.17 - * the GPL can be found in doc/GPL-license.txt in this distribution, or
   70.18 - * online at http://secondlifegrid.net/programs/open_source/licensing/gplv2
   70.19 - * 
   70.20 - * There are special exceptions to the terms and conditions of the GPL as
   70.21 - * it is applied to this Source Code. View the full text of the exception
   70.22 - * in the file doc/FLOSS-exception.txt in this software distribution, or
   70.23 - * online at
   70.24 - * http://secondlifegrid.net/programs/open_source/licensing/flossexception
   70.25 - * 
   70.26 - * By copying, modifying or distributing this software, you acknowledge
   70.27 - * that you have read and understood your obligations described above,
   70.28 - * and agree to abide by those obligations.
   70.29 - * 
   70.30 - * ALL LINDEN LAB SOURCE CODE IS PROVIDED "AS IS." LINDEN LAB MAKES NO
   70.31 - * WARRANTIES, EXPRESS, IMPLIED OR OTHERWISE, REGARDING ITS ACCURACY,
   70.32 - * COMPLETENESS OR PERFORMANCE.
   70.33 - * $/LicenseInfo$
   70.34 - */
   70.35 -
   70.36 -#ifndef LL_LLPANELAUDIOPREFS_H
   70.37 -#define LL_LLPANELAUDIOPREFS_H
   70.38 -
   70.39 -#include "llpanel.h"
   70.40 -
   70.41 -class LLSpinCtrl;
   70.42 -class LLSlider;
   70.43 -class LLSliderCtrl;
   70.44 -class LLCheckBoxCtrl;
   70.45 -class LLTextBox;
   70.46 -class LLRadioGroup;
   70.47 -
   70.48 -class LLPanelAudioPrefs : public LLPanel
   70.49 -{
   70.50 -public:
   70.51 -	LLPanelAudioPrefs();
   70.52 -	virtual ~LLPanelAudioPrefs();
   70.53 -	
   70.54 -	void apply() { refreshValues(); }
   70.55 -	void cancel();	// Cancel the changed values.
   70.56 -
   70.57 -	virtual BOOL postBuild();
   70.58 -
   70.59 -	static void* createVolumePanel(void* data);
   70.60 -	
   70.61 -private:
   70.62 -	void refreshValues();
   70.63 -
   70.64 -	F32             mPreviousVolume;
   70.65 -	F32             mPreviousMusicVolume;
   70.66 -	F32             mPreviousMediaVolume;
   70.67 -	F32             mPreviousSFX;
   70.68 -	F32             mPreviousUI;
   70.69 -	F32             mPreviousEnvironment;
   70.70 -	F32             mPreviousDoppler;
   70.71 -	F32             mPreviousDistance;
   70.72 -	F32             mPreviousRolloff;
   70.73 -
   70.74 -	S32             mPreviousBitrate;
   70.75 -
   70.76 -	F32             mPreviousMoneyThreshold;
   70.77 -	F32             mPreviousHealthThreshold;
   70.78 -
   70.79 -	BOOL			mPreviousStreamingMusic;
   70.80 -	BOOL			mPreviousStreamingVideo;
   70.81 -	BOOL            mPreviousMuteAudio;
   70.82 -	BOOL            mPreviousMuteWhenMinimized;
   70.83 -	BOOL			mPreviousMediaFilter;
   70.84 -};
   70.85 -
   70.86 -#endif
    71.1 --- a/indra/newview/llpanelface.cpp	Mon Feb 27 23:28:58 2012 -0800
    71.2 +++ b/indra/newview/llpanelface.cpp	Mon Feb 27 23:59:10 2012 -0800
    71.3 @@ -1228,7 +1228,7 @@
    71.4  		LLSD face = objectp->getTE(i)->asLLSD();
    71.5  		LLUUID image_id = objectp->getTE(i)->getID();
    71.6  		BOOL allow_texture = FALSE;
    71.7 -		if (gInventory.isObjectDescendentOf(face["imageid"], gInventoryLibraryRoot)
    71.8 +		if (gInventory.isObjectDescendentOf(face["imageid"], gInventory.getLibraryRootFolderID())
    71.9  			|| image_id == LLUUID(gSavedSettings.getString( "DefaultObjectTexture" ))
   71.10  			|| image_id == LLUUID(gSavedSettings.getString( "UIImgWhiteUUID" ))
   71.11  			|| image_id == LLUUID(gSavedSettings.getString( "UIImgInvisibleUUID" ))
    72.1 --- a/indra/newview/llpanelmorph.cpp	Mon Feb 27 23:28:58 2012 -0800
    72.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
    72.3 @@ -1,351 +0,0 @@
    72.4 -/** 
    72.5 - * @file llpanelmorph.cpp
    72.6 - * @brief LLPanelMorph class implementation
    72.7 - *
    72.8 - * $LicenseInfo:firstyear=2001&license=viewergpl$
    72.9 - * 
   72.10 - * Copyright (c) 2001-2009, Linden Research, Inc.
   72.11 - * 
   72.12 - * Second Life Viewer Source Code
   72.13 - * The source code in this file ("Source Code") is provided by Linden Lab
   72.14 - * to you under the terms of the GNU General Public License, version 2.0
   72.15 - * ("GPL"), unless you have obtained a separate licensing agreement
   72.16 - * ("Other License"), formally executed by you and Linden Lab.  Terms of
   72.17 - * the GPL can be found in doc/GPL-license.txt in this distribution, or
   72.18 - * online at http://secondlifegrid.net/programs/open_source/licensing/gplv2
   72.19 - * 
   72.20 - * There are special exceptions to the terms and conditions of the GPL as
   72.21 - * it is applied to this Source Code. View the full text of the exception
   72.22 - * in the file doc/FLOSS-exception.txt in this software distribution, or
   72.23 - * online at
   72.24 - * http://secondlifegrid.net/programs/open_source/licensing/flossexception
   72.25 - * 
   72.26 - * By copying, modifying or distributing this software, you acknowledge
   72.27 - * that you have read and understood your obligations described above,
   72.28 - * and agree to abide by those obligations.
   72.29 - * 
   72.30 - * ALL LINDEN LAB SOURCE CODE IS PROVIDED "AS IS." LINDEN LAB MAKES NO
   72.31 - * WARRANTIES, EXPRESS, IMPLIED OR OTHERWISE, REGARDING ITS ACCURACY,
   72.32 - * COMPLETENESS OR PERFORMANCE.
   72.33 - * $/LicenseInfo$
   72.34 - */
   72.35 -
   72.36 -// file include
   72.37 -#include "llviewerprecompiledheaders.h"
   72.38 -
   72.39 -/*
   72.40 -#include "llpanelmorph.h"
   72.41 -
   72.42 -// library includes
   72.43 -#include "llerror.h"
   72.44 -#include "llrect.h"
   72.45 -#include "llstring.h"
   72.46 -#include "llfontgl.h"
   72.47 -
   72.48 -// project includes
   72.49 -#include "llui.h"
   72.50 -#include "llspinctrl.h"
   72.51 -#include "llcheckboxctrl.h"
   72.52 -#include "lltextbox.h"
   72.53 -#include "llbutton.h"
   72.54 -//#include "lldraghandle.h"
   72.55 -
   72.56 -#include "llviewerwindow.h"
   72.57 -#include "llviewerobject.h"
   72.58 -#include "llresmgr.h"
   72.59 -
   72.60 -#include "llcontrol.h"
   72.61 -
   72.62 -#include "llagent.h"
   72.63 -#include "llvoavatar.h"
   72.64 -#include "lltoolmgr.h"
   72.65 -#include "lltoolmorph.h"
   72.66 -#include "llquantize.h"
   72.67 -
   72.68 -//
   72.69 -// Constants
   72.70 -//
   72.71 -const S32 VPAD = 2;
   72.72 -const S32 HPAD = 4;
   72.73 -
   72.74 -const S32 TITLE_WIDTH = 100;
   72.75 -const S32 TITLE_HEIGHT = 16;
   72.76 -
   72.77 -const S32 CLOSE_BOX_SIZE = 16;
   72.78 -
   72.79 -const S32 LABEL_HOFF = 8;
   72.80 -const S32 LABEL_WIDTH = 140;
   72.81 -const S32 SPIN_WIDTH = 250;
   72.82 -
   72.83 -// minimum and maximum morph weight values (a UI/network constraint, not inherent to morphs)
   72.84 -const F32 MORPH_WEIGHT_MIN = (-1.f);
   72.85 -const F32 MORPH_WEIGHT_MAX = (1.f);
   72.86 -// this is the magic number that morph values are quantized to for network transmission purposes
   72.87 -// the 200 value is a result of encoding the weights as a string (and avoiding NULL terminators
   72.88 -// and avoiding \n (the between-NV-pair delimiter).  Map -1 to 1 to 50-250.  HACK.  JC
   72.89 -const S32 MORPH_WEIGHT_OFFSET = (50);
   72.90 -const S32 MORPH_WEIGHT_QUANTUM = ((MORPH_WEIGHT_MAX - MORPH_WEIGHT_MIN) / MAXSTRINGVAL);
   72.91 -
   72.92 -//#define MORPH_PANEL_SHOW_SPINNERS
   72.93 -
   72.94 -//
   72.95 -// Globals
   72.96 -//
   72.97 -LLPanelMorph *gPanelMorph = NULL;
   72.98 -
   72.99 -//
  72.100 -// Methods
  72.101 -//
  72.102 -
  72.103 -//static
  72.104 -//-----------------------------------------------------------------------------
  72.105 -// LLPanelMorph()
  72.106 -//-----------------------------------------------------------------------------
  72.107 -LLPanelMorph::LLPanelMorph(const std::string& name, const LLRect& rect)
  72.108 -:	LLPanel( name, rect )
  72.109 -{
  72.110 -	mParamSpinners = NULL;
  72.111 -	mSexRadioGroup = NULL;
  72.112 -	mRect = rect;
  72.113 -	mMesh = NULL;
  72.114 -	setBackgroundVisible( TRUE );
  72.115 -}
  72.116 -
  72.117 -//-----------------------------------------------------------------------------
  72.118 -// ~LLPanelMorph()
  72.119 -//-----------------------------------------------------------------------------
  72.120 -LLPanelMorph::~LLPanelMorph()
  72.121 -{
  72.122 -#ifdef MORPH_PANEL_SHOW_SPINNERS
  72.123 -	for (S32 i = 0; i < mNumParamSpinners; i++)
  72.124 -	{
  72.125 -		removeChild(mParamSpinners[i]);
  72.126 -		delete mParamSpinners[i];
  72.127 -	}
  72.128 -	delete [] mParamSpinners;
  72.129 -#endif
  72.130 -}
  72.131 -
  72.132 -// static
  72.133 -//-----------------------------------------------------------------------------
  72.134 -// onCommitSexChange()
  72.135 -//-----------------------------------------------------------------------------
  72.136 -void LLPanelMorph::onCommitSexChange( void *data)
  72.137 -{
  72.138 -//	LLRadioGroup *group = (LLRadioGroup *)data;
  72.139 -
  72.140 -//	LLVOAvatar *avatarp = gAgent.getAvatarObject();
  72.141 -//	
  72.142 -//	LLNameValue* avatarSexNV = avatarp->getNVPair("AvatarSex");
  72.143 -//	if (!avatarSexNV)
  72.144 -//	{
  72.145 -//		avatarp->addNVPair( "AvatarSex U32 READ_WRITE SIM_SPACE_VIEWER 0");
  72.146 -//		avatarSexNV = avatarp->getNVPair("AvatarSex");
  72.147 -//	}
  72.148 -//
  72.149 -//	avatarSexNV->setU32(gSavedSettings.getU32("AvatarSex"));
  72.150 -//
  72.151 -//	avatarp->sendNVPairToSimulator("AvatarSex");
  72.152 -//
  72.153 -//	// preemptively update sex based on local value
  72.154 -//	avatarp->updateSex();
  72.155 -//
  72.156 -//	LLVisualParamHint::requestHintUpdates();
  72.157 -
  72.158 -}
  72.159 -
  72.160 -
  72.161 -// static
  72.162 -//-----------------------------------------------------------------------------
  72.163 -// onCommitMorphChange()
  72.164 -//-----------------------------------------------------------------------------
  72.165 -void LLPanelMorph::onCommitMorphChange( LLUICtrl* ctrl, void* userdata )
  72.166 -{
  72.167 -//#ifdef MORPH_PANEL_SHOW_SPINNERS
  72.168 -//	LLVOAvatar *avatarp = gAgent.getAvatarObject();
  72.169 -//
  72.170 -//	LLPanelMorph* self = (LLPanelMorph*) userdata;
  72.171 -//
  72.172 -//	S32 i = 0;
  72.173 -//	for(LLPolyMorphTarget* morphTargetp = self->mMesh->getFirstVisualParam();
  72.174 -//	morphTargetp;
  72.175 -//	morphTargetp = self->mMesh->getNextVisualParam())
  72.176 -//	{
  72.177 -//		for(S32 j = 0; j < self->mNumParamSpinners; j++)
  72.178 -//		{
  72.179 -//			if (!strcmp(self->mParamSpinners[j]->getName(), morphTargetp->getName()))
  72.180 -//			{
  72.181 -//				avatarp->mHeadMesh0.getMesh()->setDistortionWeight(morphTargetp, self->mParamSpinners[j]->get());
  72.182 -//			}
  72.183 -//		}
  72.184 -//		i++;
  72.185 -//	}
  72.186 -//	avatarp->updateDistortions();
  72.187 -//	avatarp->sendVisualParams();
  72.188 -//#endif
  72.189 -}
  72.190 -
  72.191 -//-----------------------------------------------------------------------------
  72.192 -// updateSpinners()
  72.193 -//-----------------------------------------------------------------------------
  72.194 -void LLPanelMorph::updateSpinners(LLPolyMesh *mesh)
  72.195 -{
  72.196 -	if (mesh != mMesh) return;
  72.197 -#ifdef MORPH_PANEL_SHOW_SPINNERS
  72.198 -
  72.199 -	for(LLViewerVisualParam *param = (LLViewerVisualParam*)gAgent.getAvatarObject()->getFirstVisualParam();
  72.200 -		param;
  72.201 -		param = gAgent.getAvatarObject()->getNextVisualParam())
  72.202 -	{
  72.203 -		if (param->getID() == -1 ||
  72.204 -			!param->isTweakable()) continue;
  72.205 -
  72.206 -		F32 paramWeight = gAgent.getAvatarObject()->getVisualParamWeight(morphTargetp);
  72.207 -
  72.208 -		for (S32 i = 0; i < mNumParamSpinners; i++)
  72.209 -		{
  72.210 -			if (!strcmp(mParamSpinners[i]->getName() , morphTargetp->getName()))
  72.211 -			{
  72.212 -				mParamSpinners[i]->set(paramWeight);
  72.213 -			}
  72.214 -		}
  72.215 -	}
  72.216 -#endif
  72.217 -}
  72.218 -
  72.219 -//-----------------------------------------------------------------------------
  72.220 -// createSpinners()
  72.221 -//-----------------------------------------------------------------------------
  72.222 -void LLPanelMorph::createSpinners(LLPolyMesh *mesh)
  72.223 -{
  72.224 -	const LLFontGL* font = LLResMgr::getInstance()->getRes( LLFONT_SANSSERIF_SMALL );
  72.225 -	S32 cur_y;
  72.226 -	S32 new_height;
  72.227 -	S32 control_focus = -1;
  72.228 -
  72.229 -	if (mSexRadioGroup)
  72.230 -	{
  72.231 -		removeChild(mSexRadioGroup);
  72.232 -		delete mSexRadioGroup;
  72.233 -	}
  72.234 -
  72.235 -	if (mParamSpinners)
  72.236 -	{
  72.237 -		for (S32 i = 0; i < mNumParamSpinners; i++)
  72.238 -		{
  72.239 -			if (mParamSpinners[i]->hasFocus())
  72.240 -			{
  72.241 -				control_focus = i;
  72.242 -				mParamSpinners[i]->setFocus(FALSE);
  72.243 -			}
  72.244 -		}
  72.245 -		for (i = 0; i < mNumParamSpinners; i++)
  72.246 -		{
  72.247 -			removeChild(mParamSpinners[i]);
  72.248 -			delete mParamSpinners[i];
  72.249 -		}
  72.250 -		delete [] mParamSpinners;
  72.251 -		mParamSpinners = NULL;
  72.252 -	}
  72.253 -	
  72.254 -#ifdef MORPH_PANEL_SHOW_SPINNERS
  72.255 -	S32 numSpinners = 0;
  72.256 -
  72.257 -	for(LLViewerVisualParam *param = (LLViewerVisualParam*)gAgent.getAvatarObject()->getFirstVisualParam();
  72.258 -		param;
  72.259 -		param = gAgent.getAvatarObject()->getNextVisualParam())
  72.260 -	{
  72.261 -		if(param->getID() != -1 &&
  72.262 -			param->isTweakable())
  72.263 -		{
  72.264 -			numSpinners++;
  72.265 -		}
  72.266 -	}
  72.267 -
  72.268 -	if (numSpinners != 0)
  72.269 -	{
  72.270 -		mParamSpinners = new LLSpinCtrl*[numSpinners];
  72.271 -	}
  72.272 -
  72.273 -	// set focus back to control #n
  72.274 -	if (control_focus >= 0 && control_focus < numSpinners)
  72.275 -	{
  72.276 -		mParamSpinners[control_focus]->setFocus(TRUE);
  72.277 -	}
  72.278 -	new_height = numSpinners * (SPINCTRL_HEIGHT + VPAD) + (VPAD * 3) + CHECKBOXCTRL_HEIGHT + VPAD + VPAD;
  72.279 -
  72.280 -#else
  72.281 -	new_height = (VPAD * 3) + CHECKBOXCTRL_HEIGHT + VPAD + VPAD;
  72.282 -#endif
  72.283 -
  72.284 -	LLRect panelRect = getRect();
  72.285 -	reshape(panelRect.getWidth(), new_height, TRUE);
  72.286 -
  72.287 -	cur_y = new_height - VPAD - VPAD;
  72.288 -
  72.289 -	LLRect radio_rect;
  72.290 -	radio_rect.setLeftTopAndSize(HPAD + LABEL_HOFF, 
  72.291 -		cur_y, 
  72.292 -		getRect().getWidth() - HPAD - HPAD - LABEL_HOFF, 
  72.293 -		CHECKBOXCTRL_HEIGHT + VPAD);
  72.294 -	mSexRadioGroup = new LLRadioGroup("sex radio", 
  72.295 -		radio_rect, 
  72.296 -		"AvatarSex", 
  72.297 -		&LLPanelMorph::onCommitSexChange, 
  72.298 -		(void *)this);
  72.299 -	addChild(mSexRadioGroup);
  72.300 -	
  72.301 -	radio_rect.setLeftTopAndSize(HPAD + LABEL_HOFF, 
  72.302 -		0, 
  72.303 -		(getRect().getWidth() - HPAD - HPAD - LABEL_HOFF) / 2.f, 
  72.304 -		0);
  72.305 -	mSexRadioGroup->addRadioButton("Female", "Female", radio_rect, font);
  72.306 -
  72.307 -	radio_rect.setLeftTopAndSize(((getRect().getWidth() - HPAD - HPAD - LABEL_HOFF) / 2.f) + HPAD + LABEL_HOFF, 
  72.308 -		0, 
  72.309 -		(getRect().getWidth() - HPAD - HPAD - LABEL_HOFF) / 2.f, 
  72.310 -		0);
  72.311 -	mSexRadioGroup->addRadioButton("Male", "Male", radio_rect, font);
  72.312 -
  72.313 -	cur_y -= CHECKBOXCTRL_HEIGHT + VPAD + VPAD;
  72.314 -
  72.315 -#ifdef MORPH_PANEL_SHOW_SPINNERS
  72.316 -	S32 i = 0;
  72.317 -
  72.318 -	for(LLViewerVisualParam *param = (LLViewerVisualParam*)gAgent.getAvatarObject()->getFirstVisualParam();
  72.319 -		param;
  72.320 -		param = gAgent.getAvatarObject()->getNextVisualParam())
  72.321 -	{
  72.322 -		if (param->getID() == -1 ||
  72.323 -			!param->isTweakable()) continue;
  72.324 -		LLRect spinnerRect;
  72.325 -		spinnerRect.setLeftTopAndSize(HPAD + LABEL_HOFF, 
  72.326 -			cur_y, 
  72.327 -			getRect().getWidth() - HPAD - HPAD - LABEL_HOFF, 
  72.328 -			cur_y - SPINCTRL_HEIGHT);
  72.329 -		mParamSpinners[i] = new LLSpinCtrl(param->getName(),
  72.330 -			spinnerRect,
  72.331 -			font,
  72.332 -			param->getName(),
  72.333 -			&LLPanelMorph::onCommitMorphChange, 
  72.334 -			this,
  72.335 -			param->getWeight(),
  72.336 -			param->getMinWeight(), 
  72.337 -			param->getMaxWeight(), 
  72.338 -			MORPH_WEIGHT_QUANTUM * 2, 
  72.339 -			NULL, 
  72.340 -			LABEL_WIDTH );
  72.341 -
  72.342 -		mParamSpinners[i]->setPrecision(2);
  72.343 -		mParamSpinners[i]->setFollowsTop();
  72.344 -		mParamSpinners[i]->setFollowsLeft();
  72.345 -		addChild(mParamSpinners[i]); 
  72.346 -		cur_y -= VPAD + SPINCTRL_HEIGHT;
  72.347 -		i++;
  72.348 -	}
  72.349 -
  72.350 -	mNumParamSpinners = numSpinners;
  72.351 -#endif
  72.352 -	mMesh = mesh;
  72.353 -}
  72.354 -*/
    73.1 --- a/indra/newview/llpanelmorph.h	Mon Feb 27 23:28:58 2012 -0800
    73.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
    73.3 @@ -1,66 +0,0 @@
    73.4 -/** 
    73.5 - * @file llpanelmorph.h
    73.6 - * @brief LLPanelMorph class definition
    73.7 - *
    73.8 - * $LicenseInfo:firstyear=2001&license=viewergpl$
    73.9 - * 
   73.10 - * Copyright (c) 2001-2009, Linden Research, Inc.
   73.11 - * 
   73.12 - * Second Life Viewer Source Code
   73.13 - * The source code in this file ("Source Code") is provided by Linden Lab
   73.14 - * to you under the terms of the GNU General Public License, version 2.0
   73.15 - * ("GPL"), unless you have obtained a separate licensing agreement
   73.16 - * ("Other License"), formally executed by you and Linden Lab.  Terms of
   73.17 - * the GPL can be found in doc/GPL-license.txt in this distribution, or
   73.18 - * online at http://secondlifegrid.net/programs/open_source/licensing/gplv2
   73.19 - * 
   73.20 - * There are special exceptions to the terms and conditions of the GPL as
   73.21 - * it is applied to this Source Code. View the full text of the exception
   73.22 - * in the file doc/FLOSS-exception.txt in this software distribution, or
   73.23 - * online at
   73.24 - * http://secondlifegrid.net/programs/open_source/licensing/flossexception
   73.25 - * 
   73.26 - * By copying, modifying or distributing this software, you acknowledge
   73.27 - * that you have read and understood your obligations described above,
   73.28 - * and agree to abide by those obligations.
   73.29 - * 
   73.30 - * ALL LINDEN LAB SOURCE CODE IS PROVIDED "AS IS." LINDEN LAB MAKES NO
   73.31 - * WARRANTIES, EXPRESS, IMPLIED OR OTHERWISE, REGARDING ITS ACCURACY,
   73.32 - * COMPLETENESS OR PERFORMANCE.
   73.33 - * $/LicenseInfo$
   73.34 - */
   73.35 -
   73.36 -/*
   73.37 -#ifndef LL_LLPANELMORPH_H
   73.38 -#define LL_LLPANELMORPH_H
   73.39 -
   73.40 -
   73.41 -#include "llfloater.h"
   73.42 -#include "llpolymesh.h"
   73.43 -#include "llradiogroup.h"
   73.44 -#include "llquantize.h"
   73.45 -
   73.46 -class LLSpinCtrl;
   73.47 -
   73.48 -class LLPanelMorph : public LLPanel
   73.49 -{
   73.50 -public:
   73.51 -	LLPanelMorph(const std::string& name, const LLRect& rect);
   73.52 -	~LLPanelMorph();
   73.53 -	static void				onCommitSexChange( void *data);
   73.54 -	static void 			onCommitMorphChange(LLUICtrl* ctrl, void* userdata);
   73.55 -	void					updateSpinners(LLPolyMesh *mesh);
   73.56 -	void					createSpinners(LLPolyMesh *mesh);
   73.57 -	
   73.58 -protected:					
   73.59 -	S32						mNumParamSpinners;
   73.60 -	LLRadioGroup*			mSexRadioGroup;
   73.61 -	LLSpinCtrl**			mParamSpinners;
   73.62 -	LLRect					mRect;
   73.63 -	LLPolyMesh*				mMesh;
   73.64 -};
   73.65 -
   73.66 -extern LLPanelMorph *gPanelMorph;
   73.67 -
   73.68 -#endif
   73.69 -*/
    74.1 --- a/indra/newview/llpanelobject.cpp	Mon Feb 27 23:28:58 2012 -0800
    74.2 +++ b/indra/newview/llpanelobject.cpp	Mon Feb 27 23:59:10 2012 -0800
    74.3 @@ -2619,7 +2619,7 @@
    74.4  
    74.5  		LLUUID image_id = sculpt_params->getSculptTexture();
    74.6  		BOOL allow_texture = FALSE;
    74.7 -		if (gInventory.isObjectDescendentOf(image_id, gInventoryLibraryRoot)
    74.8 +		if (gInventory.isObjectDescendentOf(image_id, gInventory.getLibraryRootFolderID())
    74.9  			|| image_id == LLUUID(gSavedSettings.getString( "DefaultObjectTexture" ))
   74.10  			|| image_id == LLUUID(gSavedSettings.getString( "UIImgWhiteUUID" ))
   74.11  			|| image_id == LLUUID(gSavedSettings.getString( "UIImgInvisibleUUID" ))
    75.1 --- a/indra/newview/llpolymesh.h	Mon Feb 27 23:28:58 2012 -0800
    75.2 +++ b/indra/newview/llpolymesh.h	Mon Feb 27 23:59:10 2012 -0800
    75.3 @@ -259,6 +259,12 @@
    75.4  		return mBinormals; 
    75.5  	}
    75.6  
    75.7 +	// Get base mesh coords
    75.8 +	const LLVector3 *getBaseCoords() const{
    75.9 +		llassert(mSharedData);
   75.10 +		return mSharedData->mBaseCoords;
   75.11 +	}
   75.12 +
   75.13  	// Get base mesh normals
   75.14  	const LLVector3 *getBaseNormals() const{
   75.15  		llassert(mSharedData);
    76.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    76.2 +++ b/indra/newview/llprefsmedia.cpp	Mon Feb 27 23:59:10 2012 -0800
    76.3 @@ -0,0 +1,143 @@
    76.4 +/** 
    76.5 + * @file llprefsmedia.cpp
    76.6 + * @brief Media preference implementation
    76.7 + *
    76.8 + * $LicenseInfo:firstyear=2001&license=viewergpl$
    76.9 + * 
   76.10 + * Copyright (c) 2001-2009, Linden Research, Inc.
   76.11 + * 
   76.12 + * Second Life Viewer Source Code
   76.13 + * The source code in this file ("Source Code") is provided by Linden Lab
   76.14 + * to you under the terms of the GNU General Public License, version 2.0
   76.15 + * ("GPL"), unless you have obtained a separate licensing agreement
   76.16 + * ("Other License"), formally executed by you and Linden Lab.  Terms of
   76.17 + * the GPL can be found in doc/GPL-license.txt in this distribution, or
   76.18 + * online at http://secondlifegrid.net/programs/open_source/licensing/gplv2
   76.19 + * 
   76.20 + * There are special exceptions to the terms and conditions of the GPL as
   76.21 + * it is applied to this Source Code. View the full text of the exception
   76.22 + * in the file doc/FLOSS-exception.txt in this software distribution, or
   76.23 + * online at
   76.24 + * http://secondlifegrid.net/programs/open_source/licensing/flossexception
   76.25 + * 
   76.26 + * By copying, modifying or distributing this software, you acknowledge
   76.27 + * that you have read and understood your obligations described above,
   76.28 + * and agree to abide by those obligations.
   76.29 + * 
   76.30 + * ALL LINDEN LAB SOURCE CODE IS PROVIDED "AS IS." LINDEN LAB MAKES NO
   76.31 + * WARRANTIES, EXPRESS, IMPLIED OR OTHERWISE, REGARDING ITS ACCURACY,
   76.32 + * COMPLETENESS OR PERFORMANCE.
   76.33 + * $/LicenseInfo$
   76.34 + */
   76.35 +
   76.36 +#include "llviewerprecompiledheaders.h"
   76.37 +
   76.38 +// file include
   76.39 +#include "llprefsmedia.h"
   76.40 +
   76.41 +// linden library includes
   76.42 +#include "llerror.h"
   76.43 +#include "llrect.h"
   76.44 +#include "llstring.h"
   76.45 +#include "llfontgl.h"
   76.46 +
   76.47 +// project includes
   76.48 +#include "llaudioengine.h"
   76.49 +#include "llbutton.h"
   76.50 +#include "llcheckboxctrl.h"
   76.51 +#include "llcombobox.h"
   76.52 +#include "llfirstuse.h"
   76.53 +#include "llnotify.h"
   76.54 +#include "llpanelaudiovolume.h"
   76.55 +#include "llparcel.h"
   76.56 +#include "llradiogroup.h"
   76.57 +#include "llresmgr.h"
   76.58 +#include "llslider.h"
   76.59 +#include "llsliderctrl.h"
   76.60 +#include "llspinctrl.h"
   76.61 +#include "lltextbox.h"
   76.62 +#include "llui.h"
   76.63 +#include "llviewerparcelmgr.h"
   76.64 +#include "lluictrlfactory.h"
   76.65 +#include "llviewerwindow.h"
   76.66 +#include "llviewercontrol.h"
   76.67 +#include "llstartup.h"
   76.68 +#include "floatermedialists.h"
   76.69 +
   76.70 +//
   76.71 +// Static functions
   76.72 +//
   76.73 +
   76.74 +//static
   76.75 +void* LLPrefsMedia::createVolumePanel(void* data)
   76.76 +{
   76.77 +	LLPanelAudioVolume* panel = new LLPanelAudioVolume();
   76.78 +	return panel;
   76.79 +}
   76.80 +
   76.81 +LLPrefsMedia::LLPrefsMedia()
   76.82 +{
   76.83 +	mFactoryMap["Volume Panel"]	= LLCallbackMap(createVolumePanel, NULL);
   76.84 +	
   76.85 +	LLUICtrlFactory::getInstance()->buildPanel(this, "panel_preferences_media.xml", &getFactoryMap());
   76.86 +}
   76.87 +
   76.88 +LLPrefsMedia::~LLPrefsMedia()
   76.89 +{
   76.90 +	// Children all cleaned up by default view destructor.
   76.91 +}
   76.92 +
   76.93 +BOOL LLPrefsMedia::postBuild()
   76.94 +{
   76.95 +	
   76.96 +	getChild<LLButton>("open_media_lists")->setClickedCallback(FloaterMediaLists::show, NULL);
   76.97 +	if(LLStartUp::getStartupState() >= STATE_INVENTORY_SEND)childSetEnabled("open_media_lists",true);
   76.98 +	
   76.99 +	refreshValues(); // initialize member data from saved settings
  76.100 +	return TRUE;
  76.101 +}
  76.102 +
  76.103 +void LLPrefsMedia::refreshValues()
  76.104 +{
  76.105 +	mPreviousVolume = gSavedSettings.getF32("AudioLevelMaster");
  76.106 +	mPreviousSFX = gSavedSettings.getF32("AudioLevelSFX");
  76.107 +	mPreviousUI = gSavedSettings.getF32("AudioLevelUI");
  76.108 +	mPreviousEnvironment = gSavedSettings.getF32("AudioLevelAmbient");
  76.109 +	mPreviousMusicVolume = gSavedSettings.getF32("AudioLevelMusic");
  76.110 +	mPreviousMediaVolume = gSavedSettings.getF32("AudioLevelMedia");
  76.111 +	mPreviousDoppler = gSavedSettings.getF32("AudioLevelDoppler");
  76.112 +	mPreviousRolloff = gSavedSettings.getF32("AudioLevelRolloff");
  76.113 +
  76.114 +	mPreviousMoneyThreshold = gSavedSettings.getF32("UISndMoneyChangeThreshold");
  76.115 +	mPreviousHealthThreshold = gSavedSettings.getF32("UISndHealthReductionThreshold");
  76.116 +
  76.117 +	mPreviousStreamingMusic = gSavedSettings.getBOOL("AudioStreamingMusic");
  76.118 +	mPreviousStreamingVideo = gSavedSettings.getBOOL("AudioStreamingVideo");
  76.119 +	mPreviousMediaFilter = gSavedSettings.getBOOL("MediaEnableFilter");
  76.120 +	
  76.121 +	mPreviousMuteAudio = gSavedSettings.getBOOL("MuteAudio");
  76.122 +	mPreviousMuteWhenMinimized = gSavedSettings.getBOOL("MuteWhenMinimized");
  76.123 +}
  76.124 +
  76.125 +void LLPrefsMedia::cancel()
  76.126 +{
  76.127 +	gSavedSettings.setF32("AudioLevelMaster", mPreviousVolume );
  76.128 +	gSavedSettings.setF32("AudioLevelUI", mPreviousUI );
  76.129 +	gSavedSettings.setF32("AudioLevelSFX", mPreviousSFX );
  76.130 +	gSavedSettings.setF32("AudioLevelAmbient", mPreviousEnvironment );
  76.131 +	gSavedSettings.setF32("AudioLevelMusic", mPreviousMusicVolume);
  76.132 +	gSavedSettings.setF32("AudioLevelMedia", mPreviousMediaVolume);
  76.133 +	gSavedSettings.setF32("AudioLevelDoppler", mPreviousDoppler );
  76.134 +	gSavedSettings.setF32("AudioLevelRolloff", mPreviousRolloff );
  76.135 +
  76.136 +	gSavedSettings.setF32("UISndMoneyChangeThreshold", mPreviousMoneyThreshold );
  76.137 +	gSavedSettings.setF32("UISndHealthReductionThreshold", mPreviousHealthThreshold );
  76.138 +
  76.139 +	gSavedSettings.setBOOL("AudioStreamingMusic", mPreviousStreamingMusic );
  76.140 +	gSavedSettings.setBOOL("AudioStreamingVideo", mPreviousStreamingVideo );
  76.141 +	gSavedSettings.setBOOL("MediaEnableFilter", mPreviousMediaFilter);
  76.142 +
  76.143 +	
  76.144 +	gSavedSettings.setBOOL("MuteAudio", mPreviousMuteAudio );
  76.145 +	gSavedSettings.setBOOL("MuteWhenMinimized", mPreviousMuteWhenMinimized );
  76.146 +}
    77.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    77.2 +++ b/indra/newview/llprefsmedia.h	Mon Feb 27 23:59:10 2012 -0800
    77.3 @@ -0,0 +1,83 @@
    77.4 +/** 
    77.5 + * @file llprefsmedia.h
    77.6 + * @brief Media preference definitions
    77.7 + *
    77.8 + * $LicenseInfo:firstyear=2001&license=viewergpl$
    77.9 + * 
   77.10 + * Copyright (c) 2001-2009, Linden Research, Inc.
   77.11 + * 
   77.12 + * Second Life Viewer Source Code
   77.13 + * The source code in this file ("Source Code") is provided by Linden Lab
   77.14 + * to you under the terms of the GNU General Public License, version 2.0
   77.15 + * ("GPL"), unless you have obtained a separate licensing agreement
   77.16 + * ("Other License"), formally executed by you and Linden Lab.  Terms of
   77.17 + * the GPL can be found in doc/GPL-license.txt in this distribution, or
   77.18 + * online at http://secondlifegrid.net/programs/open_source/licensing/gplv2
   77.19 + * 
   77.20 + * There are special exceptions to the terms and conditions of the GPL as
   77.21 + * it is applied to this Source Code. View the full text of the exception
   77.22 + * in the file doc/FLOSS-exception.txt in this software distribution, or
   77.23 + * online at
   77.24 + * http://secondlifegrid.net/programs/open_source/licensing/flossexception
   77.25 + * 
   77.26 + * By copying, modifying or distributing this software, you acknowledge
   77.27 + * that you have read and understood your obligations described above,
   77.28 + * and agree to abide by those obligations.
   77.29 + * 
   77.30 + * ALL LINDEN LAB SOURCE CODE IS PROVIDED "AS IS." LINDEN LAB MAKES NO
   77.31 + * WARRANTIES, EXPRESS, IMPLIED OR OTHERWISE, REGARDING ITS ACCURACY,
   77.32 + * COMPLETENESS OR PERFORMANCE.
   77.33 + * $/LicenseInfo$
   77.34 + */
   77.35 +
   77.36 +#ifndef LL_LLPREFSMEDIA_H
   77.37 +#define LL_LLPREFSMEDIA_H
   77.38 +
   77.39 +#include "llpanel.h"
   77.40 +
   77.41 +class LLSpinCtrl;
   77.42 +class LLSlider;
   77.43 +class LLSliderCtrl;
   77.44 +class LLCheckBoxCtrl;
   77.45 +class LLTextBox;
   77.46 +class LLRadioGroup;
   77.47 +
   77.48 +class LLPrefsMedia : public LLPanel
   77.49 +{
   77.50 +public:
   77.51 +	LLPrefsMedia();
   77.52 +	virtual ~LLPrefsMedia();
   77.53 +	
   77.54 +	void apply() { refreshValues(); }
   77.55 +	void cancel();	// Cancel the changed values.
   77.56 +
   77.57 +	virtual BOOL postBuild();
   77.58 +
   77.59 +	static void* createVolumePanel(void* data);
   77.60 +	
   77.61 +private:
   77.62 +	void refreshValues();
   77.63 +
   77.64 +	F32             mPreviousVolume;
   77.65 +	F32             mPreviousMusicVolume;
   77.66 +	F32             mPreviousMediaVolume;
   77.67 +	F32             mPreviousSFX;
   77.68 +	F32             mPreviousUI;
   77.69 +	F32             mPreviousEnvironment;
   77.70 +	F32             mPreviousDoppler;
   77.71 +	F32             mPreviousDistance;
   77.72 +	F32             mPreviousRolloff;
   77.73 +
   77.74 +	S32             mPreviousBitrate;
   77.75 +
   77.76 +	F32             mPreviousMoneyThreshold;
   77.77 +	F32             mPreviousHealthThreshold;
   77.78 +
   77.79 +	BOOL			mPreviousStreamingMusic;
   77.80 +	BOOL			mPreviousStreamingVideo;
   77.81 +	BOOL            mPreviousMuteAudio;
   77.82 +	BOOL            mPreviousMuteWhenMinimized;
   77.83 +	BOOL			mPreviousMediaFilter;
   77.84 +};
   77.85 +
   77.86 +#endif
    78.1 --- a/indra/newview/llpreview.cpp	Mon Feb 27 23:28:58 2012 -0800
    78.2 +++ b/indra/newview/llpreview.cpp	Mon Feb 27 23:59:10 2012 -0800
    78.3 @@ -196,7 +196,7 @@
    78.4  	const LLViewerInventoryItem *item = getItem();
    78.5  	if(item)
    78.6  	{
    78.7 -		if (!item->isComplete())
    78.8 +		if (!item->isFinished())
    78.9  		{
   78.10  			// We are attempting to save an item that was never loaded
   78.11  			llwarns << "LLPreview::onCommit() called with mIsComplete == FALSE"
    79.1 --- a/indra/newview/llpreviewgesture.cpp	Mon Feb 27 23:28:58 2012 -0800
    79.2 +++ b/indra/newview/llpreviewgesture.cpp	Mon Feb 27 23:59:10 2012 -0800
    79.3 @@ -63,6 +63,7 @@
    79.4  #include "llfloatergesture.h"			// for some label constants
    79.5  #include "llgesturemgr.h"
    79.6  #include "llinventorymodel.h"
    79.7 +#include "llinventorymodelbackgroundfetch.h"
    79.8  #include "llviewerinventory.h"
    79.9  #include "llviewerobjectlist.h"
   79.10  #include "llviewerregion.h"
   79.11 @@ -153,14 +154,14 @@
   79.12  
   79.13  	// Start speculative download of sounds and animations
   79.14  	const LLUUID animation_folder_id = gInventory.findCategoryUUIDForType(LLFolderType::FT_ANIMATION);
   79.15 -	gInventory.startBackgroundFetch(animation_folder_id);
   79.16 +	LLInventoryModelBackgroundFetch::instance().start(animation_folder_id);
   79.17  
   79.18  	const LLUUID sound_folder_id = gInventory.findCategoryUUIDForType(LLFolderType::FT_SOUND);
   79.19 -	gInventory.startBackgroundFetch(sound_folder_id);
   79.20 +	LLInventoryModelBackgroundFetch::instance().start(sound_folder_id);
   79.21  
   79.22  	// this will call refresh when we have everything.
   79.23  	LLViewerInventoryItem* item = (LLViewerInventoryItem*)self->getItem();
   79.24 -	if(item && !item->isComplete())
   79.25 +	if(item && !item->isFinished())
   79.26  	{
   79.27  		LLInventoryGestureAvailable* observer;
   79.28  		observer = new LLInventoryGestureAvailable();
   79.29 @@ -622,7 +623,7 @@
   79.30  													PERM_ITEM_UNRESTRICTED,
   79.31  													gAgent.getID(),
   79.32  													gAgent.getGroupID());
   79.33 -	gInventory.collectDescendentsIf(gAgent.getInventoryRootID(),
   79.34 +	gInventory.collectDescendentsIf(gInventory.getRootFolderID(),
   79.35  									cats,
   79.36  									items,
   79.37  									LLInventoryModel::EXCLUDE_TRASH,
   79.38 @@ -667,7 +668,7 @@
   79.39  													PERM_ITEM_UNRESTRICTED,
   79.40  													gAgent.getID(),
   79.41  													gAgent.getGroupID());
   79.42 -	gInventory.collectDescendentsIf(gAgent.getInventoryRootID(),
   79.43 +	gInventory.collectDescendentsIf(gInventory.getRootFolderID(),
   79.44  									cats,
   79.45  									items,
   79.46  									LLInventoryModel::EXCLUDE_TRASH,
   79.47 @@ -709,7 +710,7 @@
   79.48  {
   79.49  	// If previewing or item is incomplete, all controls are disabled
   79.50  	LLViewerInventoryItem* item = (LLViewerInventoryItem*)getItem();
   79.51 -	bool is_complete = (item && item->isComplete()) ? true : false;
   79.52 +	bool is_complete = (item && item->isFinished()) ? true : false;
   79.53  	if (mPreviewGesture || !is_complete)
   79.54  	{
   79.55  		
    80.1 --- a/indra/newview/llpreviewscript.cpp	Mon Feb 27 23:28:58 2012 -0800
    80.2 +++ b/indra/newview/llpreviewscript.cpp	Mon Feb 27 23:59:10 2012 -0800
    80.3 @@ -1649,7 +1649,7 @@
    80.4  	const LLInventoryItem* item = gInventory.getItem(mItemUUID);
    80.5  	BOOL is_library = item
    80.6  		&& !gInventory.isObjectDescendentOf(mItemUUID,
    80.7 -											gAgent.getInventoryRootID());
    80.8 +											gInventory.getRootFolderID());
    80.9  	if(!item)
   80.10  	{
   80.11  		// do the more generic search.
   80.12 @@ -2603,7 +2603,7 @@
   80.13  		return;
   80.14  	}
   80.15  
   80.16 -	if(mItem.isNull() || !mItem->isComplete())
   80.17 +	if(mItem.isNull() || !mItem->isFinished())
   80.18  	{
   80.19  		// $NOTE: While the error message may not be exactly correct,
   80.20  		// it's pretty close.
    81.1 --- a/indra/newview/llselectmgr.cpp	Mon Feb 27 23:28:58 2012 -0800
    81.2 +++ b/indra/newview/llselectmgr.cpp	Mon Feb 27 23:59:10 2012 -0800
    81.3 @@ -6421,7 +6421,7 @@
    81.4  	return cost;
    81.5  }
    81.6  
    81.7 -U32 LLObjectSelection::getSelectedObjectTriangleCount()
    81.8 +U32 LLObjectSelection::getSelectedObjectTriangleCount(S32* vcount)
    81.9  {
   81.10  	U32 count = 0;
   81.11  	for (list_t::iterator iter = mList.begin(); iter != mList.end(); ++iter)
   81.12 @@ -6431,7 +6431,7 @@
   81.13  
   81.14  		if (object)
   81.15  		{
   81.16 -			count += object->getTriangleCount();
   81.17 +			count += object->getTriangleCount(vcount);
   81.18  		}
   81.19  	}
   81.20  
    82.1 --- a/indra/newview/llselectmgr.h	Mon Feb 27 23:28:58 2012 -0800
    82.2 +++ b/indra/newview/llselectmgr.h	Mon Feb 27 23:59:10 2012 -0800
    82.3 @@ -311,7 +311,7 @@
    82.4  	F32 getSelectedLinksetPhysicsCost();
    82.5  
    82.6  	F32 getSelectedObjectStreamingCost(S32* total_bytes = NULL, S32* visible_bytes = NULL);
    82.7 -	U32 getSelectedObjectTriangleCount();
    82.8 +	U32 getSelectedObjectTriangleCount(S32* vcount = NULL);
    82.9  
   82