summaryrefslogtreecommitdiff
path: root/indra/llcommon
diff options
context:
space:
mode:
authorJon Wolk <jwolk@lindenlab.com>2007-12-19 00:56:59 +0000
committerJon Wolk <jwolk@lindenlab.com>2007-12-19 00:56:59 +0000
commit7dd08303a3ebf9718c2c60a4d94b81d5d7845f8c (patch)
tree6195a8585cc7998647afcaec2167e728e4abd3c1 /indra/llcommon
parent4d87303e78c1accde85b217b325e0c08930b0c4c (diff)
svn merge -r 75354:76103 svn+ssh://svn.lindenlab.com/svn/linden/branches/voice-group-moderation-3 -> release. Finished product of QAR-134
Diffstat (limited to 'indra/llcommon')
-rw-r--r--indra/llcommon/lldefs.h18
-rw-r--r--indra/llcommon/llevent.h2
-rw-r--r--indra/llcommon/llmortician.cpp12
-rw-r--r--indra/llcommon/llmortician.h2
-rw-r--r--indra/llcommon/llsdutil.cpp120
-rw-r--r--indra/llcommon/llsdutil.h10
-rw-r--r--indra/llcommon/llstring.h39
-rw-r--r--indra/llcommon/roles_constants.h20
8 files changed, 205 insertions, 18 deletions
diff --git a/indra/llcommon/lldefs.h b/indra/llcommon/lldefs.h
index cd8c79a84d..96b2ab169b 100644
--- a/indra/llcommon/lldefs.h
+++ b/indra/llcommon/lldefs.h
@@ -183,7 +183,15 @@ template <class LLDATATYPE>
inline LLDATATYPE llmax(const LLDATATYPE& d1, const LLDATATYPE& d2, const LLDATATYPE& d3)
{
LLDATATYPE r = llmax(d1,d2);
- return (r > d3 ? r : d3);
+ return llmax(r, d3);
+}
+
+template <class LLDATATYPE>
+inline LLDATATYPE llmax(const LLDATATYPE& d1, const LLDATATYPE& d2, const LLDATATYPE& d3, const LLDATATYPE& d4)
+{
+ LLDATATYPE r1 = llmax(d1,d2);
+ LLDATATYPE r2 = llmax(d3,d4);
+ return llmax(r1, r2);
}
template <class LLDATATYPE>
@@ -200,6 +208,14 @@ inline LLDATATYPE llmin(const LLDATATYPE& d1, const LLDATATYPE& d2, const LLDATA
}
template <class LLDATATYPE>
+inline LLDATATYPE llmin(const LLDATATYPE& d1, const LLDATATYPE& d2, const LLDATATYPE& d3, const LLDATATYPE& d4)
+{
+ LLDATATYPE r1 = llmin(d1,d2);
+ LLDATATYPE r2 = llmin(d3,d4);
+ return llmin(r1, r2);
+}
+
+template <class LLDATATYPE>
inline LLDATATYPE llclamp(const LLDATATYPE& a, const LLDATATYPE& minval, const LLDATATYPE& maxval)
{
return llmin(llmax(a, minval), maxval);
diff --git a/indra/llcommon/llevent.h b/indra/llcommon/llevent.h
index 3018cc671b..8ba883a0ee 100644
--- a/indra/llcommon/llevent.h
+++ b/indra/llcommon/llevent.h
@@ -179,7 +179,7 @@ public:
if (mDispatcher.notNull()) mDispatcher->removeListener(listener);
}
// Notifies the dispatcher of an event being fired.
- void fireEvent(LLPointer<LLEvent> event, LLSD filter);
+ void fireEvent(LLPointer<LLEvent> event, LLSD filter = LLSD());
protected:
LLPointer<LLEventDispatcher> mDispatcher;
diff --git a/indra/llcommon/llmortician.cpp b/indra/llcommon/llmortician.cpp
index cab3a7f973..b3e25104cb 100644
--- a/indra/llcommon/llmortician.cpp
+++ b/indra/llcommon/llmortician.cpp
@@ -33,20 +33,20 @@
#include <list>
-std::list<LLMortician*> gGraveyard;
+std::list<LLMortician*> LLMortician::sGraveyard;
BOOL LLMortician::sDestroyImmediate = FALSE;
LLMortician::~LLMortician()
{
- gGraveyard.remove(this);
+ sGraveyard.remove(this);
}
void LLMortician::updateClass()
{
- while (!gGraveyard.empty())
+ while (!sGraveyard.empty())
{
- LLMortician* dead = gGraveyard.front();
+ LLMortician* dead = sGraveyard.front();
delete dead;
}
}
@@ -56,7 +56,7 @@ void LLMortician::die()
// It is valid to call die() more than once on something that hasn't died yet
if (sDestroyImmediate)
{
- // *NOTE: This is a hack to ensure destruction order on shutdown.
+ // *NOTE: This is a hack to ensure destruction order on shutdown (relative to non-mortician controlled classes).
mIsDead = TRUE;
delete this;
return;
@@ -64,7 +64,7 @@ void LLMortician::die()
else if (!mIsDead)
{
mIsDead = TRUE;
- gGraveyard.push_back(this);
+ sGraveyard.push_back(this);
}
}
diff --git a/indra/llcommon/llmortician.h b/indra/llcommon/llmortician.h
index 24a38520e9..606ac0dc39 100644
--- a/indra/llcommon/llmortician.h
+++ b/indra/llcommon/llmortician.h
@@ -50,6 +50,8 @@ private:
static BOOL sDestroyImmediate;
BOOL mIsDead;
+
+ static std::list<LLMortician*> sGraveyard;
};
#endif
diff --git a/indra/llcommon/llsdutil.cpp b/indra/llcommon/llsdutil.cpp
index a0f337c2de..992c883a7e 100644
--- a/indra/llcommon/llsdutil.cpp
+++ b/indra/llcommon/llsdutil.cpp
@@ -301,3 +301,123 @@ char* ll_pretty_print_sd(const LLSD& sd)
buffer[bufferSize - 1] = '\0';
return buffer;
}
+
+//compares the structure of an LLSD to a template LLSD and stores the
+//"valid" values in a 3rd LLSD. Default values are stored in the template
+//
+//If the llsd to test has a specific key to a map and the values
+//are not of the same type, false is returned or if the LLSDs are not
+//of the same value. Ordering of arrays matters
+//Otherwise, returns true
+BOOL compare_llsd_with_template(
+ const LLSD& llsd_to_test,
+ const LLSD& template_llsd,
+ LLSD& resultant_llsd)
+{
+ if (
+ llsd_to_test.isUndefined() &&
+ template_llsd.isDefined() )
+ {
+ resultant_llsd = template_llsd;
+ return TRUE;
+ }
+ else if ( llsd_to_test.type() != template_llsd.type() )
+ {
+ resultant_llsd = LLSD();
+ return FALSE;
+ }
+
+ if ( llsd_to_test.isArray() )
+ {
+ //they are both arrays
+ //we loop over all the items in the template
+ //verifying that the to_test has a subset (in the same order)
+ //any shortcoming in the testing_llsd are just taken
+ //to be the rest of the template
+ LLSD data;
+ LLSD::array_const_iterator test_iter;
+ LLSD::array_const_iterator template_iter;
+
+ resultant_llsd = LLSD::emptyArray();
+ test_iter = llsd_to_test.beginArray();
+
+ for (
+ template_iter = template_llsd.beginArray();
+ (template_iter != template_llsd.endArray() &&
+ test_iter != llsd_to_test.endArray());
+ ++template_iter)
+ {
+ if ( !compare_llsd_with_template(
+ *test_iter,
+ *template_iter,
+ data) )
+ {
+ resultant_llsd = LLSD();
+ return FALSE;
+ }
+ else
+ {
+ resultant_llsd.append(data);
+ }
+
+ ++test_iter;
+ }
+
+ //so either the test or the template ended
+ //we do another loop now to the end of the template
+ //grabbing the default values
+ for (;
+ template_iter != template_llsd.endArray();
+ ++template_iter)
+ {
+ resultant_llsd.append(*template_iter);
+ }
+ }
+ else if ( llsd_to_test.isMap() )
+ {
+ //now we loop over the keys of the two maps
+ //any excess is taken from the template
+ //excess is ignored in the test
+ LLSD value;
+ LLSD::map_const_iterator template_iter;
+
+ resultant_llsd = LLSD::emptyMap();
+ for (
+ template_iter = template_llsd.beginMap();
+ template_iter != template_llsd.endMap();
+ ++template_iter)
+ {
+ if ( llsd_to_test.has(template_iter->first) )
+ {
+ //the test LLSD has the same key
+ if ( !compare_llsd_with_template(
+ llsd_to_test[template_iter->first],
+ template_iter->second,
+ value) )
+ {
+ resultant_llsd = LLSD();
+ return FALSE;
+ }
+ else
+ {
+ resultant_llsd[template_iter->first] = value;
+ }
+ }
+ else
+ {
+ //test llsd doesn't have it...take the
+ //template as default value
+ resultant_llsd[template_iter->first] =
+ template_iter->second;
+ }
+ }
+ }
+ else
+ {
+ //of same type...take the test llsd's value
+ resultant_llsd = llsd_to_test;
+ }
+
+
+ return TRUE;
+}
diff --git a/indra/llcommon/llsdutil.h b/indra/llcommon/llsdutil.h
index 699d5093e1..17a881d9cb 100644
--- a/indra/llcommon/llsdutil.h
+++ b/indra/llcommon/llsdutil.h
@@ -91,4 +91,14 @@ char* ll_print_sd(const LLSD& sd);
// Serializes sd to static buffer and returns pointer, using "pretty printing" mode.
char* ll_pretty_print_sd(const LLSD& sd);
+//compares the structure of an LLSD to a template LLSD and stores the
+//"valid" values in a 3rd LLSD. Default values
+//are pulled from the template. Ordering of arrays matters
+//Returns false if the test is of same type but values differ in type
+//Otherwise, returns true
+BOOL compare_llsd_with_template(
+ const LLSD& llsd_to_test,
+ const LLSD& template_llsd,
+ LLSD& resultant_llsd);
+
#endif // LL_LLSDUTIL_H
diff --git a/indra/llcommon/llstring.h b/indra/llcommon/llstring.h
index ec4ff335c9..d4925d8bee 100644
--- a/indra/llcommon/llstring.h
+++ b/indra/llcommon/llstring.h
@@ -299,6 +299,10 @@ public:
// a.k.a. strdictcmp()
static S32 compareDict(const std::basic_string<T>& a, const std::basic_string<T>& b);
+ // Case *in*sensitive comparison with good handling of numbers. Does not use current locale.
+ // a.k.a. strdictcmp()
+ static S32 compareDictInsensitive(const std::basic_string<T>& a, const std::basic_string<T>& b);
+
// Puts compareDict() in a form appropriate for LL container classes to use for sorting.
static BOOL precedesDict( const std::basic_string<T>& a, const std::basic_string<T>& b );
@@ -310,7 +314,7 @@ public:
// Copies src into dst at a given offset.
static void copyInto(std::basic_string<T>& dst, const std::basic_string<T>& src, size_type offset);
-#ifdef _DEBUG
+#ifdef _DEBUG
static void testHarness();
#endif
@@ -678,6 +682,39 @@ S32 LLStringBase<T>::compareDict(const std::basic_string<T>& astr, const std::ba
return ca-cb;
}
+template<class T>
+S32 LLStringBase<T>::compareDictInsensitive(const std::basic_string<T>& astr, const std::basic_string<T>& bstr)
+{
+ const T* a = astr.c_str();
+ const T* b = bstr.c_str();
+ T ca, cb;
+ S32 ai, bi, cnt = 0;
+
+ ca = *(a++);
+ cb = *(b++);
+ while( ca && cb ){
+ if( LLStringOps::isUpper(ca) ){ ca = LLStringOps::toLower(ca); }
+ if( LLStringOps::isUpper(cb) ){ cb = LLStringOps::toLower(cb); }
+ if( LLStringOps::isDigit(ca) ){
+ if( cnt-->0 ){
+ if( cb!=ca ) break;
+ }else{
+ if( !LLStringOps::isDigit(cb) ) break;
+ for(ai=0; LLStringOps::isDigit(a[ai]); ai++);
+ for(bi=0; LLStringOps::isDigit(b[bi]); bi++);
+ if( ai<bi ){ ca=0; break; }
+ if( bi<ai ){ cb=0; break; }
+ if( ca!=cb ) break;
+ cnt = ai;
+ }
+ }else if( ca!=cb ){ break;
+ }
+ ca = *(a++);
+ cb = *(b++);
+ }
+ return ca-cb;
+}
+
// Puts compareDict() in a form appropriate for LL container classes to use for sorting.
// static
template<class T>
diff --git a/indra/llcommon/roles_constants.h b/indra/llcommon/roles_constants.h
index 1a7c977f21..12bd21ec20 100644
--- a/indra/llcommon/roles_constants.h
+++ b/indra/llcommon/roles_constants.h
@@ -56,12 +56,12 @@ enum LLRoleChangeType
// Powers
//
-// KNOWN HOLES:
-// bit 0x1 << 37 (GP_OBJECT_RETURN)
+// KNOWN HOLES: use these for any single bit powers you need
+// bit 0x1 << 41
+// bit 0x1 << 46
+// bit 0x1 << 49 and above
// These powers were removed to make group roles simpler
-// bit 0x1 << 27 (GP_LAND_ALLOW_SCRIPTS)
-// bit 0x1 << 16 (GP_LAND_VIEW_OWNED)
// bit 0x1 << 41 (GP_ACCOUNTING_VIEW)
// bit 0x1 << 46 (GP_PROPOSAL_VIEW)
@@ -116,18 +116,19 @@ const U64 GP_LAND_MANAGE_PASSES = 0x1LL << 31; // Change Sell Pass Settings
const U64 GP_LAND_ADMIN = 0x1LL << 32; // Eject and Freeze Users on the land
// Parcel Content
-const U64 GP_LAND_RETURN_GROUP_OWNED= 0x1LL << 48; // Return objects on parcel that are owned by the group
const U64 GP_LAND_RETURN_GROUP_SET = 0x1LL << 33; // Return objects on parcel that are set to group
const U64 GP_LAND_RETURN_NON_GROUP = 0x1LL << 34; // Return objects on parcel that are not set to group
+const U64 GP_LAND_RETURN_GROUP_OWNED= 0x1LL << 48; // Return objects on parcel that are owned by the group
+
// Select a power-bit based on an object's relationship to a parcel.
const U64 GP_LAND_RETURN = GP_LAND_RETURN_GROUP_OWNED
| GP_LAND_RETURN_GROUP_SET
| GP_LAND_RETURN_NON_GROUP;
+
const U64 GP_LAND_GARDENING = 0x1LL << 35; // Parcel Gardening - plant and move linden trees
// Object Management
const U64 GP_OBJECT_DEED = 0x1LL << 36; // Deed Object
-// HOLE -- 0x1LL << 37
const U64 GP_OBJECT_MANIPULATE = 0x1LL << 38; // Manipulate Group Owned Objects (Move, Copy, Mod)
const U64 GP_OBJECT_SET_SALE = 0x1LL << 39; // Set Group Owned Object for Sale
@@ -142,9 +143,10 @@ const U64 GP_NOTICES_RECEIVE = 0x1LL << 43; // Receive Notices and View Notice
const U64 GP_PROPOSAL_START = 0x1LL << 44; // Start Proposal
const U64 GP_PROPOSAL_VOTE = 0x1LL << 45; // Vote on Proposal
-const U64 GP_SESSION_JOIN = 0x1LL << 46; //can join session
-const U64 GP_SESSION_VOICE = 0x1LL << 47; //can hear/talk
-const U64 GP_SESSION_MODERATOR = 0x1LL << 49; //can mute people's session
+// Group chat moderation related
+const U64 GP_SESSION_JOIN = 0x1LL << 16; //can join session
+const U64 GP_SESSION_VOICE = 0x1LL << 27; //can hear/talk
+const U64 GP_SESSION_MODERATOR = 0x1LL << 37; //can mute people's session
const U64 GP_DEFAULT_MEMBER = GP_ACCOUNTING_ACCOUNTABLE
| GP_LAND_ALLOW_SET_HOME