summaryrefslogtreecommitdiff
path: root/indra/newview/llgroupmgr.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'indra/newview/llgroupmgr.cpp')
-rw-r--r--indra/newview/llgroupmgr.cpp119
1 files changed, 100 insertions, 19 deletions
diff --git a/indra/newview/llgroupmgr.cpp b/indra/newview/llgroupmgr.cpp
index af58e81ca4..996553ccf7 100644
--- a/indra/newview/llgroupmgr.cpp
+++ b/indra/newview/llgroupmgr.cpp
@@ -54,8 +54,19 @@
#include "llgroupactions.h"
#include "llnotificationsutil.h"
#include "lluictrlfactory.h"
+#include "lltrans.h"
#include <boost/regex.hpp>
+#if LL_MSVC
+// disable boost::lexical_cast warning
+#pragma warning (disable:4702)
+#endif
+
+#include <boost/lexical_cast.hpp>
+
+#if LL_MSVC
+#pragma warning(pop) // Restore all warnings to the previous state
+#endif
const U32 MAX_CACHED_GROUPS = 10;
@@ -149,7 +160,7 @@ LLGroupRoleData::~LLGroupRoleData()
{
}
-S32 LLGroupRoleData::getMembersInRole(std::vector<LLUUID> members,
+S32 LLGroupRoleData::getMembersInRole(uuid_vec_t members,
BOOL needs_sort)
{
if (mRoleID.isNull())
@@ -173,8 +184,8 @@ S32 LLGroupRoleData::getMembersInRole(std::vector<LLUUID> members,
// Return the number of members in the intersection.
S32 max_size = llmin( members.size(), mMemberIDs.size() );
- std::vector<LLUUID> in_role( max_size );
- std::vector<LLUUID>::iterator in_role_end;
+ uuid_vec_t in_role( max_size );
+ uuid_vec_t::iterator in_role_end;
in_role_end = std::set_intersection(mMemberIDs.begin(), mMemberIDs.end(),
members.begin(), members.end(),
in_role.begin());
@@ -189,7 +200,7 @@ void LLGroupRoleData::addMember(const LLUUID& member)
bool LLGroupRoleData::removeMember(const LLUUID& member)
{
- std::vector<LLUUID>::iterator it = std::find(mMemberIDs.begin(),mMemberIDs.end(),member);
+ uuid_vec_t::iterator it = std::find(mMemberIDs.begin(),mMemberIDs.end(),member);
if (it != mMemberIDs.end())
{
@@ -677,9 +688,12 @@ void LLGroupMgrGroupData::sendRoleChanges()
break;
}
case RC_UPDATE_ALL:
+ // fall through
case RC_UPDATE_POWERS:
need_power_recalc = true;
+ // fall through
case RC_UPDATE_DATA:
+ // fall through
default:
{
LLGroupRoleData* group_role_data = (*role_it).second;
@@ -762,6 +776,14 @@ void LLGroupMgr::addObserver(LLGroupMgrObserver* observer)
mObservers.insert(std::pair<LLUUID, LLGroupMgrObserver*>(observer->getID(), observer));
}
+void LLGroupMgr::addObserver(const LLUUID& group_id, LLParticularGroupObserver* observer)
+{
+ if(group_id.notNull() && observer)
+ {
+ mParticularObservers[group_id].insert(observer);
+ }
+}
+
void LLGroupMgr::removeObserver(LLGroupMgrObserver* observer)
{
if (!observer)
@@ -784,6 +806,23 @@ void LLGroupMgr::removeObserver(LLGroupMgrObserver* observer)
}
}
+void LLGroupMgr::removeObserver(const LLUUID& group_id, LLParticularGroupObserver* observer)
+{
+ if(group_id.isNull() || !observer)
+ {
+ return;
+ }
+
+ observer_map_t::iterator obs_it = mParticularObservers.find(group_id);
+ if(obs_it == mParticularObservers.end())
+ return;
+
+ obs_it->second.erase(observer);
+
+ if (obs_it->second.size() == 0)
+ mParticularObservers.erase(obs_it);
+}
+
LLGroupMgrGroupData* LLGroupMgr::getGroupData(const LLUUID& id)
{
group_map_t::iterator gi = mGroups.find(id);
@@ -805,12 +844,13 @@ static void formatDateString(std::string &date_string)
const regex expression("([0-9]{1,2})/([0-9]{1,2})/([0-9]{4})");
if (regex_match(date_string.c_str(), result, expression))
{
- std::string year = result[3];
- std::string month = result[1];
- std::string day = result[2];
+ // convert matches to integers so that we can pad them with zeroes on Linux
+ S32 year = boost::lexical_cast<S32>(result[3]);
+ S32 month = boost::lexical_cast<S32>(result[1]);
+ S32 day = boost::lexical_cast<S32>(result[2]);
// ISO 8601 date format
- date_string = llformat("%02s/%02s/%04s", month.c_str(), day.c_str(), year.c_str());
+ date_string = llformat("%04d/%02d/%02d", year, month, day);
}
}
@@ -1023,6 +1063,24 @@ void LLGroupMgr::processGroupRoleDataReply(LLMessageSystem* msg, void** data)
msg->getU64("RoleData","Powers",powers,i);
msg->getU32("RoleData","Members",member_count,i);
+ //there are 3 predifined roles - Owners, Officers, Everyone
+ //there names are defined in lldatagroups.cpp
+ //lets change names from server to localized strings
+ if(name == "Everyone")
+ {
+ name = LLTrans::getString("group_role_everyone");
+ }
+ else if(name == "Officers")
+ {
+ name = LLTrans::getString("group_role_officers");
+ }
+ else if(name == "Owners")
+ {
+ name = LLTrans::getString("group_role_owners");
+ }
+
+
+
lldebugs << "Adding role data: " << name << " {" << role_id << "}" << llendl;
LLGroupRoleData* rd = new LLGroupRoleData(role_id,name,title,desc,powers,member_count);
group_data->mRoles[role_id] = rd;
@@ -1325,6 +1383,7 @@ void LLGroupMgr::notifyObservers(LLGroupChange gc)
LLUUID group_id = gi->first;
if (gi->second->mChanged)
{
+ // notify LLGroupMgrObserver
// Copy the map because observers may remove themselves on update
observer_multimap_t observers = mObservers;
@@ -1336,6 +1395,18 @@ void LLGroupMgr::notifyObservers(LLGroupChange gc)
oi->second->changed(gc);
}
gi->second->mChanged = FALSE;
+
+
+ // notify LLParticularGroupObserver
+ observer_map_t::iterator obs_it = mParticularObservers.find(group_id);
+ if(obs_it == mParticularObservers.end())
+ return;
+
+ observer_set_t& obs = obs_it->second;
+ for (observer_set_t::iterator ob_it = obs.begin(); ob_it != obs.end(); ++ob_it)
+ {
+ (*ob_it)->changed(group_id, gc);
+ }
}
}
}
@@ -1665,22 +1736,26 @@ void LLGroupMgr::sendGroupMemberInvites(const LLUUID& group_id, std::map<LLUUID,
//static
void LLGroupMgr::sendGroupMemberEjects(const LLUUID& group_id,
- std::vector<LLUUID>& member_ids)
+ uuid_vec_t& member_ids)
{
bool start_message = true;
LLMessageSystem* msg = gMessageSystem;
+
+
LLGroupMgrGroupData* group_datap = LLGroupMgr::getInstance()->getGroupData(group_id);
if (!group_datap) return;
- for (std::vector<LLUUID>::iterator it = member_ids.begin();
+ for (uuid_vec_t::iterator it = member_ids.begin();
it != member_ids.end(); ++it)
{
+ LLUUID& ejected_member_id = (*it);
+
// Can't use 'eject' to leave a group.
- if ((*it) == gAgent.getID()) continue;
+ if (ejected_member_id == gAgent.getID()) continue;
// Make sure they are in the group, and we need the member data
- LLGroupMgrGroupData::member_list_t::iterator mit = group_datap->mMembers.find(*it);
+ LLGroupMgrGroupData::member_list_t::iterator mit = group_datap->mMembers.find(ejected_member_id);
if (mit != group_datap->mMembers.end())
{
// Add them to the message
@@ -1696,7 +1771,7 @@ void LLGroupMgr::sendGroupMemberEjects(const LLUUID& group_id,
}
msg->nextBlock("EjectData");
- msg->addUUID("EjecteeID",(*it));
+ msg->addUUID("EjecteeID",ejected_member_id);
if (msg->isSendFull())
{
@@ -1704,17 +1779,23 @@ void LLGroupMgr::sendGroupMemberEjects(const LLUUID& group_id,
start_message = true;
}
+ LLGroupMemberData* member_data = (*mit).second;
+
// Clean up groupmgr
- for (LLGroupMemberData::role_list_t::iterator rit = (*mit).second->roleBegin();
- rit != (*mit).second->roleEnd(); ++rit)
+ for (LLGroupMemberData::role_list_t::iterator rit = member_data->roleBegin();
+ rit != member_data->roleEnd(); ++rit)
{
- if ((*rit).first.notNull())
+ if ((*rit).first.notNull() && (*rit).second!=0)
{
- (*rit).second->removeMember(*it);
+ (*rit).second->removeMember(ejected_member_id);
}
}
- delete (*mit).second;
- group_datap->mMembers.erase(*it);
+
+ group_datap->mMembers.erase(ejected_member_id);
+
+ // member_data was introduced and is used here instead of (*mit).second to avoid crash because of invalid iterator
+ // It becomes invalid after line with erase above. EXT-4778
+ delete member_data;
}
}