From f68a7654728a73d2e7f080a9af0d08954b1b7351 Mon Sep 17 00:00:00 2001 From: Cinders Date: Fri, 22 Mar 2013 16:25:00 -0600 Subject: [PATCH] Run lggcontactsets.* through astyle to make it more readable --- indra/newview/lggcontactsets.cpp | 175 +++++++++++++++++++++---------- indra/newview/lggcontactsets.h | 2 +- 2 files changed, 118 insertions(+), 59 deletions(-) diff --git a/indra/newview/lggcontactsets.cpp b/indra/newview/lggcontactsets.cpp index 9461bb4011..048c47ed57 100644 --- a/indra/newview/lggcontactsets.cpp +++ b/indra/newview/lggcontactsets.cpp @@ -17,6 +17,7 @@ 02111-1307, USA. */ #include "llviewerprecompiledheaders.h" + #include "lggcontactsets.h" #include "llsdserialize.h" #include "llboost.h" @@ -43,25 +44,28 @@ LGGContactSets::~LGGContactSets() LGGContactSets* LGGContactSets::getInstance() { - if(sInstance)return sInstance; + if (sInstance) + { + return sInstance; + } else { sInstance = new LGGContactSets(); return sInstance; } } + LLColor4 LGGContactSets::toneDownColor(LLColor4 inColor, float strength, bool usedForBackground) { - if(usedForBackground) + if (usedForBackground) { if(strength<.4f)strength=.4f; static LLCachedControl maxAlphaInt(gSavedSettings,"FSContactSetsMaxColorStrength"); strength *= ((F32)maxAlphaInt/100.0f); } - - return LLColor4(LLColor3(inColor),strength); } + bool LGGContactSets::callbackAliasReset(const LLSD& notification, const LLSD& response) { S32 option = LLNotification::getSelectedOption(notification, response); @@ -75,10 +79,12 @@ bool LGGContactSets::callbackAliasReset(const LLSD& notification, const LLSD& re } return false; } + void LGGContactSets::save() { saveToDisk(mContactSets); } + std::string LGGContactSets::getFileName() { std::string path=gDirUtilp->getExpandedFilename(LL_PATH_PER_SL_ACCOUNT, ""); @@ -87,12 +93,13 @@ std::string LGGContactSets::getFileName() { path = gDirUtilp->getExpandedFilename(LL_PATH_PER_SL_ACCOUNT, "settings_friends_groups.xml"); } - return path; + return path; } + std::string LGGContactSets::getOldFileName() { std::string path = gDirUtilp->getOSUserDir()+gDirUtilp->getDirDelimiter()+"SecondLife"+gDirUtilp->getDirDelimiter(); - + std::string normalPath=gDirUtilp->getExpandedFilename(LL_PATH_PER_SL_ACCOUNT, ""); //we want to steal the last directory off this one std::string userNameDir = normalPath.substr(normalPath.find_last_of(gDirUtilp->getDirDelimiter())); @@ -105,6 +112,7 @@ std::string LGGContactSets::getOldFileName() llinfos << "returning a old path name of "<getExpandedFilename(LL_PATH_APP_SETTINGS, ""); @@ -113,8 +121,9 @@ std::string LGGContactSets::getDefaultFileName() { path = gDirUtilp->getExpandedFilename(LL_PATH_APP_SETTINGS, "settings_friends_groups.xml"); } - return path; + return path; } + LLSD LGGContactSets::exportGroup(std::string groupName) { LLSD toReturn; @@ -127,23 +136,26 @@ LLSD LGGContactSets::exportGroup(std::string groupName) } return toReturn; } + LLSD LGGContactSets::getContactSets() { //loadFromDisk(); return mContactSets; } + void LGGContactSets::loadFromDisk() { std::string filename=getFileName(); if (filename.empty()) { - llinfos << "no valid user directory." << llendl; + llinfos << "no valid user directory." << llendl; } - if(!gDirUtilp->fileExists(filename)) + + if (!gDirUtilp->fileExists(filename)) { //try to find the phoenix file to load std::string phoenixFileName = getOldFileName(); - if(gDirUtilp->fileExists(phoenixFileName)) + if (gDirUtilp->fileExists(phoenixFileName)) { LLSD blankllsd; llifstream file; @@ -154,12 +166,13 @@ void LGGContactSets::loadFromDisk() } file.close(); saveToDisk(blankllsd); - }else + } + else { std::string defaultName = getDefaultFileName(); llinfos << " user settings file doesnt exist, going to try and read default one from "<fileExists(defaultName)) + if (gDirUtilp->fileExists(defaultName)) { LLSD blankllsd; llifstream file; @@ -170,8 +183,11 @@ void LGGContactSets::loadFromDisk() } file.close(); saveToDisk(blankllsd); - }else + } + else + { saveToDisk(mContactSets); + } } } else @@ -183,8 +199,9 @@ void LGGContactSets::loadFromDisk() LLSDSerialize::fromXML(mContactSets, file); } file.close(); - } + } } + void LGGContactSets::saveToDisk(LLSD newSettings) { mContactSets=newSettings; @@ -194,11 +211,12 @@ void LGGContactSets::saveToDisk(LLSD newSettings) LLSDSerialize::toPrettyXML(mContactSets, file); file.close(); } + void LGGContactSets::runTest() { - -mContactSets.clear(); + mContactSets.clear(); } + BOOL LGGContactSets::saveGroupToDisk(std::string groupName, std::string fileName) { if(mContactSets.has(groupName)) @@ -211,6 +229,7 @@ BOOL LGGContactSets::saveGroupToDisk(std::string groupName, std::string fileName } return FALSE; } + LLSD LGGContactSets::getExampleLLSD() { LLSD toReturn; @@ -239,48 +258,66 @@ LLSD LGGContactSets::getExampleLLSD() itemTwo["right"]="secondright2"; listone[1]=itemTwo; - toReturn["listTwo"]=listone; + toReturn["listTwo"]=listone; return toReturn; } LLColor4 LGGContactSets::getGroupColor(std::string groupName) { - if(groupName!="" && groupName!="All Sets" && groupName!="All Groups" && groupName !="globalSettings" && groupName!="No Sets" && groupName!="ReNamed" && groupName!="Non Friends") - if(mContactSets[groupName].has("color")) + if(groupName != "" && groupName != "All Sets" && groupName != "All Groups" && groupName != "globalSettings" && groupName != "No Sets" && groupName != "ReNamed" && groupName != "Non Friends") + if (mContactSets[groupName].has("color")) + { return LLColor4(mContactSets[groupName]["color"]); + } return getDefaultColor(); }; -LLColor4 LGGContactSets::getFriendColor( - LLUUID friend_id, std::string ignoredGroupName) + +LLColor4 LGGContactSets::getFriendColor(LLUUID friend_id, std::string ignoredGroupName) { LLColor4 toReturn = getDefaultColor(); - if(ignoredGroupName=="No Sets") return toReturn; + if(ignoredGroupName=="No Sets") + { + return toReturn; + } int lowest = 9999; std::vector groups = getFriendGroups(friend_id); - for(int i =0;i<(int)groups.size();i++) + for (int i =0; i<(int)groups.size(); i++) { if(groups[i]!=ignoredGroupName) { int membersNum = getFriendsInGroup(groups[i]).size(); - if(membersNum==0)continue; - if(membersNum contactSetsColorizeRadar(gSavedSettings,"FSContactSetsColorizeRadar"); static LLCachedControl contactSetsColorizeMiniMap(gSavedSettings,"FSContactSetsColorizeMiniMap"); - if(miniMap&&!contactSetsColorizeMiniMap)return FALSE; - if(tag&&!contactSetsColorizeTag)return FALSE; - if(chat &&!(sPhoenixColorContactSetsChat))return FALSE; - if(radar && !contactSetsColorizeRadar)return FALSE; + if (miniMap&&!contactSetsColorizeMiniMap) + { + return FALSE; + } + if (tag&&!contactSetsColorizeTag) + { + return FALSE; + } + if (chat && !(sPhoenixColorContactSetsChat)) + { + return FALSE; + } + if(radar && !contactSetsColorizeRadar) + { + return FALSE; + } - //don't show friend color if they are no longer a friend + //don't show friend color if they are no longer a friend //(and if are also not on the "non friends" list) - if( (!LLAvatarTracker::instance().isBuddy(friend_id)) - &&(!isNonFriend(friend_id))) return FALSE; + if ((!LLAvatarTracker::instance().isBuddy(friend_id)) && (!isNonFriend(friend_id))) + { + return FALSE; + } - - if(getFriendColor(friend_id)==getDefaultColor())return FALSE; + if(getFriendColor(friend_id)==getDefaultColor()) + { + return FALSE; + } return TRUE; } LLColor4 LGGContactSets::getDefaultColor() { - LLColor4 toReturn= LLColor4::grey; + LLColor4 toReturn = LLColor4::grey; if(mContactSets.has("globalSettings")) + { if(mContactSets["globalSettings"].has("defaultColor")) + { toReturn = LLColor4(mContactSets["globalSettings"]["defaultColor"]); + } + } return toReturn; } + void LGGContactSets::setDefaultColor(LLColor4 dColor) { mContactSets["globalSettings"]["defaultColor"]=dColor.getValue(); } + std::vector LGGContactSets::getInnerGroups(std::string groupName) { std::vector toReturn; @@ -323,22 +382,22 @@ std::vector LGGContactSets::getInnerGroups(std::string groupName) static LLCachedControl useFolders(gSavedSettings, "FSContactSetsShowFolders"); static LLCachedControl showOnline(gSavedSettings, "FSContactSetsShowOnline"); static LLCachedControl showOffline(gSavedSettings, "FSContactSetsShowOffline"); - + if(!(useFolders))return toReturn; std::set newGroups; newGroups.clear(); if(groupName!="All Sets" && getAllGroups(FALSE).size()>0)newGroups.insert("All Sets"); std::vector freindsInGroup = getFriendsInGroup(groupName); - for(int fn = 0; fn<(int)freindsInGroup.size();fn++) + for(int fn = 0; fn<(int)freindsInGroup.size(); fn++) { LLUUID friend_id = freindsInGroup[fn]; BOOL online = LLAvatarTracker::instance().isBuddyOnline(friend_id); if(online && !(showOnline))continue; if(!online && !(showOffline))continue; - + std::vector innerGroups = getFriendGroups(friend_id); - for(int inIter=0;inIter<(int)innerGroups.size();inIter++) + for(int inIter=0; inIter<(int)innerGroups.size(); inIter++) { std::string innerGroupName = innerGroups[inIter]; if(groupName!=innerGroupName) @@ -375,7 +434,7 @@ std::vector LGGContactSets::getFriendsInGroup(std::string groupName) if(groupName=="pseudonym"||groupName=="ReNamed")return getListOfPseudonymAvs(); if(groupName=="Non Friends")return getListOfNonFriends(); - LLSD friends = mContactSets[groupName]["friends"]; + LLSD friends = mContactSets[groupName]["friends"]; LLSD::map_const_iterator loc_it = friends.beginMap(); LLSD::map_const_iterator loc_end = friends.endMap(); for ( ; loc_it != loc_end; ++loc_it) @@ -383,7 +442,7 @@ std::vector LGGContactSets::getFriendsInGroup(std::string groupName) const LLSD& friendID = (*loc_it).first; toReturn.push_back(friendID.asUUID()); - } + } return toReturn; } @@ -420,9 +479,9 @@ std::vector LGGContactSets::getFriendsInAnyGroup() { std::set friendsInAnyGroup; std::vector groups = getAllGroups(FALSE); - for(int g=0;g<(int)groups.size();g++) + for(int g=0; g<(int)groups.size(); g++) { - LLSD friends = mContactSets[groups[g]]["friends"]; + LLSD friends = mContactSets[groups[g]]["friends"]; LLSD::map_const_iterator loc_it = friends.beginMap(); LLSD::map_const_iterator loc_end = friends.endMap(); for ( ; loc_it != loc_end; ++loc_it) @@ -436,7 +495,7 @@ std::vector LGGContactSets::getFriendsInAnyGroup() BOOL LGGContactSets::isFriendInAnyGroup(LLUUID friend_id) { std::vector groups = getAllGroups(FALSE); - for(int g=0;g<(int)groups.size();g++) + for(int g=0; g<(int)groups.size(); g++) { if(mContactSets[groups[g]].has("friends")) if(mContactSets[groups[g]]["friends"].has(friend_id.asString())) @@ -445,7 +504,7 @@ BOOL LGGContactSets::isFriendInAnyGroup(LLUUID friend_id) return FALSE; } BOOL LGGContactSets::isFriendInGroup(LLUUID friend_id, std::string groupName) -{ +{ if(groupName=="All Sets") return isFriendInAnyGroup(friend_id); if(groupName=="No Sets") return !isFriendInAnyGroup(friend_id); if(groupName=="ReNamed") return hasPseudonym(friend_id); @@ -458,7 +517,7 @@ BOOL LGGContactSets::notifyForFriend(LLUUID friend_id) { BOOL notify = FALSE; std::vector groups = getFriendGroups(friend_id); - for(int i =0;i<(int)groups.size();i++) + for(int i =0; i<(int)groups.size(); i++) { if(mContactSets[groups[i]]["notify"].asBoolean())return TRUE; } @@ -493,7 +552,7 @@ void LGGContactSets::removeNonFriendFromList(LLUUID non_friend_id) void LGGContactSets::removeFriendFromAllGroups(LLUUID friend_id) { std::vector groups = getFriendGroups(friend_id); - for(int i=0;i<(int)groups.size();i++) + for(int i=0; i<(int)groups.size(); i++) { removeFriendFromGroup(friend_id,groups[i]); } @@ -509,7 +568,7 @@ std::vector LGGContactSets::getListOfNonFriends() std::vector toReturn; toReturn.clear(); - LLSD friends = mContactSets["extraAvs"]; + LLSD friends = mContactSets["extraAvs"]; LLSD::map_const_iterator loc_it = friends.beginMap(); LLSD::map_const_iterator loc_end = friends.endMap(); for ( ; loc_it != loc_end; ++loc_it) @@ -523,7 +582,7 @@ std::vector LGGContactSets::getListOfNonFriends() if(friendID.asUUID().notNull()) if(!LLAvatarTracker::instance().isBuddy(friendID)) toReturn.push_back(friendID.asUUID()); - } + } return toReturn; } @@ -532,7 +591,7 @@ std::vector LGGContactSets::getListOfPseudonymAvs() std::vector toReturn; toReturn.clear(); - LLSD friends = mContactSets["pseudonym"]; + LLSD friends = mContactSets["pseudonym"]; LLSD::map_const_iterator loc_it = friends.beginMap(); LLSD::map_const_iterator loc_end = friends.endMap(); for ( ; loc_it != loc_end; ++loc_it) @@ -545,7 +604,7 @@ std::vector LGGContactSets::getListOfPseudonymAvs() } if(friendID.asUUID().notNull()) toReturn.push_back(friendID.asUUID()); - } + } return toReturn; } @@ -599,7 +658,7 @@ void LGGContactSets::removeFriendFromGroup(LLUUID friend_id, std::string groupNa return clearPseudonym(friend_id); } if(friend_id.notNull() && groupName!="") - { + { if(mContactSets[groupName]["friends"].has(friend_id.asString())) { mContactSets[groupName]["friends"].erase(friend_id.asString()); diff --git a/indra/newview/lggcontactsets.h b/indra/newview/lggcontactsets.h index 58df7075e4..e3d7531a7a 100644 --- a/indra/newview/lggcontactsets.h +++ b/indra/newview/lggcontactsets.h @@ -79,7 +79,7 @@ public: private: void saveToDisk(LLSD newSettings); - LLSD getExampleLLSD(); + LLSD getExampleLLSD(); std::string getFileName(); std::string getDefaultFileName(); std::string getOldFileName();