More contact groups shit. Pain in my ass.
This commit is contained in:
@@ -13,6 +13,19 @@
|
|||||||
<string />
|
<string />
|
||||||
</array>
|
</array>
|
||||||
</map>
|
</map>
|
||||||
|
<key>AscentContactGroups</key>
|
||||||
|
<map>
|
||||||
|
<key>Comment</key>
|
||||||
|
<string>List for contact groups</string>
|
||||||
|
<key>Persist</key>
|
||||||
|
<integer>1</integer>
|
||||||
|
<key>Type</key>
|
||||||
|
<string>LLSD</string>
|
||||||
|
<key>Value</key>
|
||||||
|
<array>
|
||||||
|
<string />
|
||||||
|
</array>
|
||||||
|
</map>
|
||||||
<key>Responder.Settings</key>
|
<key>Responder.Settings</key>
|
||||||
<map>
|
<map>
|
||||||
<key>Comment</key>
|
<key>Comment</key>
|
||||||
|
|||||||
@@ -32,6 +32,7 @@
|
|||||||
|
|
||||||
ASFloaterContactGroups* ASFloaterContactGroups::sInstance = NULL;
|
ASFloaterContactGroups* ASFloaterContactGroups::sInstance = NULL;
|
||||||
LLDynamicArray<LLUUID> ASFloaterContactGroups::mSelectedUUIDs;
|
LLDynamicArray<LLUUID> ASFloaterContactGroups::mSelectedUUIDs;
|
||||||
|
LLSD ASFloaterContactGroups::mContactGroupData;
|
||||||
|
|
||||||
ASFloaterContactGroups::ASFloaterContactGroups()
|
ASFloaterContactGroups::ASFloaterContactGroups()
|
||||||
: LLFloater(std::string("floater_contact_groups"), std::string("FloaterContactRect"), LLStringUtil::null)
|
: LLFloater(std::string("floater_contact_groups"), std::string("FloaterContactRect"), LLStringUtil::null)
|
||||||
@@ -140,129 +141,37 @@ void ASFloaterContactGroups::populateFriendList()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string ASFloaterContactGroups::cleanFileName(std::string filename)
|
|
||||||
{
|
|
||||||
std::string invalidChars = "\"\'\\/?*:<>| ";
|
|
||||||
S32 position = filename.find_first_of(invalidChars);
|
|
||||||
while (position != filename.npos)
|
|
||||||
{
|
|
||||||
filename[position] = '_';
|
|
||||||
position = filename.find_first_of(invalidChars, position);
|
|
||||||
}
|
|
||||||
return filename;
|
|
||||||
}
|
|
||||||
|
|
||||||
void ASFloaterContactGroups::addContactMember(std::string contact_grp, LLUUID to_add)
|
void ASFloaterContactGroups::addContactMember(std::string contact_grp, LLUUID to_add)
|
||||||
{
|
{
|
||||||
std::string clean_contact_grp = cleanFileName(contact_grp);
|
ASFloaterContactGroups::mContactGroupData[contact_grp].append(to_add.asString());
|
||||||
std::string member_string = "Ascent." + clean_contact_grp + ".Members";
|
gSavedPerAccountSettings.setLLSD("AscentContactGroups", ASFloaterContactGroups::mContactGroupData);
|
||||||
|
|
||||||
if (!gSavedSettings.controlExists(member_string))
|
|
||||||
gSavedSettings.declareString(member_string, to_add.asString(), "Stores UUIDs of members for " + clean_contact_grp, TRUE);
|
|
||||||
else
|
|
||||||
gSavedSettings.setString(member_string, gSavedSettings.getString(member_string) + " " + to_add.asString());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void ASFloaterContactGroups::deleteContactGroup(std::string contact_grp)
|
void ASFloaterContactGroups::deleteContactGroup(std::string contact_grp)
|
||||||
{
|
{
|
||||||
std::string clean_contact_grp = cleanFileName(contact_grp);
|
|
||||||
std::string display_string = "Ascent." + clean_contact_grp + ".Display";
|
|
||||||
gSavedSettings.setString(display_string, "##DELETED##");
|
|
||||||
|
|
||||||
std::string group_list(gSavedSettings.getString("AscentContactGroups"));
|
|
||||||
|
|
||||||
if (group_list.find(clean_contact_grp) != group_list.npos)
|
|
||||||
{
|
|
||||||
gSavedSettings.setString(
|
|
||||||
"AscentContactGroups",
|
|
||||||
group_list.erase(
|
|
||||||
group_list.find_first_of(clean_contact_grp),
|
|
||||||
clean_contact_grp.length()
|
|
||||||
)
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void ASFloaterContactGroups::createContactGroup(std::string contact_grp)
|
void ASFloaterContactGroups::createContactGroup(std::string contact_grp)
|
||||||
{
|
{
|
||||||
std::string clean_contact_grp = cleanFileName(contact_grp);
|
ASFloaterContactGroups::mContactGroupData["ASC_MASTER_GROUP_LIST"].append(contact_grp);
|
||||||
std::string display_string = "Ascent." + clean_contact_grp + ".Display";
|
gSavedPerAccountSettings.setLLSD("AscentContactGroups", ASFloaterContactGroups::mContactGroupData);
|
||||||
std::string member_string = "Ascent." + clean_contact_grp + ".Members";
|
populateGroupList();
|
||||||
|
|
||||||
if (gSavedSettings.controlExists(display_string))
|
|
||||||
{
|
|
||||||
std::string s_display = gSavedSettings.getString(display_string);
|
|
||||||
if (s_display != "##DELETED##")
|
|
||||||
{
|
|
||||||
LLChat msg("Can't create duplicate group names.");
|
|
||||||
LLFloaterChat::addChat(msg);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
gSavedSettings.declareString(member_string, "NULL_KEY", "Stores UUIDs of members for " + clean_contact_grp, TRUE);
|
|
||||||
gSavedSettings.declareString(display_string, contact_grp, "Stores the real name of " + clean_contact_grp, TRUE);
|
|
||||||
|
|
||||||
gSavedSettings.setString(display_string, contact_grp);
|
|
||||||
gSavedSettings.saveToFile(gSavedSettings.getString("ClientSettingsFile"), TRUE);
|
|
||||||
|
|
||||||
gSavedSettings.setString(member_string, "NULL_KEY");
|
|
||||||
gSavedSettings.saveToFile(gSavedSettings.getString("ClientSettingsFile"), TRUE);
|
|
||||||
|
|
||||||
if (!gSavedSettings.controlExists("AscentContactGroups"))
|
|
||||||
{
|
|
||||||
gSavedSettings.declareString("AscentContactGroups", clean_contact_grp, "Stores titles of all Contact Groups", TRUE);
|
|
||||||
gSavedSettings.setString("AscentContactGroups", clean_contact_grp);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
std::string group_list(gSavedSettings.getString("AscentContactGroups"));
|
|
||||||
group_list += " " + clean_contact_grp;
|
|
||||||
gSavedSettings.setString("AscentContactGroups", group_list);
|
|
||||||
}
|
|
||||||
|
|
||||||
gSavedSettings.saveToFile(gSavedSettings.getString("ClientSettingsFile"), TRUE);
|
|
||||||
}
|
|
||||||
|
|
||||||
void StringSplit(std::string str, std::string delim, std::vector<std::string> results)
|
|
||||||
{
|
|
||||||
int cutAt;
|
|
||||||
while((cutAt = str.find_first_of(delim)) != str.npos)
|
|
||||||
{
|
|
||||||
if(cutAt > 0)
|
|
||||||
{
|
|
||||||
results.push_back(str.substr(0,cutAt));
|
|
||||||
}
|
|
||||||
str = str.substr(cutAt+1);
|
|
||||||
}
|
|
||||||
|
|
||||||
if(str.length() > 0)
|
|
||||||
{
|
|
||||||
results.push_back(str);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void ASFloaterContactGroups::populateGroupList()
|
void ASFloaterContactGroups::populateGroupList()
|
||||||
{
|
{
|
||||||
|
ASFloaterContactGroups::mContactGroupData = gSavedPerAccountSettings.getLLSD("AscentContactGroups");
|
||||||
LLScrollListCtrl* scroller = getChild<LLScrollListCtrl>("group_scroll_list");
|
LLScrollListCtrl* scroller = getChild<LLScrollListCtrl>("group_scroll_list");
|
||||||
if(scroller != NULL)
|
if(scroller != NULL)
|
||||||
{
|
{
|
||||||
scroller->deleteAllItems();
|
scroller->deleteAllItems();
|
||||||
|
|
||||||
if (gSavedSettings.controlExists("AscentContactGroups"))
|
S32 count = ASFloaterContactGroups::mContactGroupData["ASC_MASTER_GROUP_LIST"].size();
|
||||||
|
S32 index;
|
||||||
|
for (index = 0; index < count; index++)
|
||||||
{
|
{
|
||||||
scroller->addSimpleElement(gSavedSettings.getString("AscentContactGroups"), ADD_BOTTOM);
|
scroller->addSimpleElement(ASFloaterContactGroups::mContactGroupData["ASC_MASTER_GROUP_LIST"][index].asString(), ADD_BOTTOM);
|
||||||
/**
|
|
||||||
std::vector<std::string> group_list;
|
|
||||||
StringSplit(gSavedSettings.getString("AscentContactGroups"), " ", group_list);
|
|
||||||
|
|
||||||
for (S32 i=0; i < group_list.size(); i++)
|
|
||||||
{
|
|
||||||
scroller->addSimpleElement(group_list[i], ADD_BOTTOM);
|
|
||||||
LLChat msg("Add " + group_list[i]);
|
|
||||||
LLFloaterChat::addChat(msg);
|
|
||||||
}
|
|
||||||
**/
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
|||||||
@@ -17,6 +17,7 @@
|
|||||||
|
|
||||||
#include "llfloater.h"
|
#include "llfloater.h"
|
||||||
#include "lldarray.h"
|
#include "lldarray.h"
|
||||||
|
#include "llsdserialize.h"
|
||||||
|
|
||||||
class LLScrollListCtrl;
|
class LLScrollListCtrl;
|
||||||
|
|
||||||
@@ -29,7 +30,6 @@ public:
|
|||||||
|
|
||||||
// by convention, this shows the floater and does instance management
|
// by convention, this shows the floater and does instance management
|
||||||
static void show(LLDynamicArray<LLUUID> ids);
|
static void show(LLDynamicArray<LLUUID> ids);
|
||||||
static std::string cleanFileName(std::string filename);
|
|
||||||
|
|
||||||
void populateGroupList();
|
void populateGroupList();
|
||||||
void populateFriendList();
|
void populateFriendList();
|
||||||
@@ -47,6 +47,7 @@ private:
|
|||||||
//assuming we just need one, which is typical
|
//assuming we just need one, which is typical
|
||||||
static ASFloaterContactGroups* sInstance;
|
static ASFloaterContactGroups* sInstance;
|
||||||
static LLDynamicArray<LLUUID> mSelectedUUIDs;
|
static LLDynamicArray<LLUUID> mSelectedUUIDs;
|
||||||
|
static LLSD mContactGroupData;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // ASCENT_CONTACT_GROUPS
|
#endif // ASCENT_CONTACT_GROUPS
|
||||||
|
|||||||
@@ -105,6 +105,7 @@ public:
|
|||||||
}
|
}
|
||||||
virtual BOOL tick()
|
virtual BOOL tick()
|
||||||
{
|
{
|
||||||
|
mFloater->populateContactGroupSelect();
|
||||||
mFloater->updateFriends(mMask);
|
mFloater->updateFriends(mMask);
|
||||||
|
|
||||||
mEventTimer.stop();
|
mEventTimer.stop();
|
||||||
@@ -222,27 +223,13 @@ void LLPanelFriends::populateContactGroupSelect()
|
|||||||
combo->removeall();
|
combo->removeall();
|
||||||
combo->add("All", ADD_BOTTOM);
|
combo->add("All", ADD_BOTTOM);
|
||||||
|
|
||||||
std::string name;
|
LLSD groups = gSavedPerAccountSettings.getLLSD("AscentContactGroups");
|
||||||
gDirUtilp->getNextFileInDir(gDirUtilp->getPerAccountChatLogsDir(),"*",name,false);//stupid hack to clear last file search
|
|
||||||
|
|
||||||
std::string path_name(gDirUtilp->getPerAccountChatLogsDir() + gDirUtilp->getDirDelimiter());
|
S32 count = groups["ASC_MASTER_GROUP_LIST"].size();
|
||||||
bool found = true;
|
S32 index;
|
||||||
while(found = gDirUtilp->getNextFileInDir(path_name, "*.grp", name, false))
|
for (index = 0; index < count; index++)
|
||||||
{
|
{
|
||||||
if ((name == ".") || (name == "..")) continue;
|
combo->addSimpleElement(groups["ASC_MASTER_GROUP_LIST"][index].asString(), ADD_BOTTOM);
|
||||||
|
|
||||||
//llinfos << "path name " << path_name << " and name " << name << " and found " << found << llendl;
|
|
||||||
if(found)
|
|
||||||
{
|
|
||||||
S32 periodIndex = name.find_last_of(".");
|
|
||||||
name = name.substr(0, periodIndex);
|
|
||||||
|
|
||||||
if ((name == ".") || (name == "..")) continue;
|
|
||||||
|
|
||||||
combo->add(name, ADD_BOTTOM);
|
|
||||||
//LLChat msg("Combo Add " + name);
|
|
||||||
//LLFloaterChat::addChat(msg);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@@ -254,41 +241,50 @@ void LLPanelFriends::populateContactGroupSelect()
|
|||||||
|
|
||||||
void LLPanelFriends::setContactGroup(std::string contact_grp)
|
void LLPanelFriends::setContactGroup(std::string contact_grp)
|
||||||
{
|
{
|
||||||
std::string group_path = gDirUtilp->getPerAccountChatLogsDir() + gDirUtilp->getDirDelimiter();
|
if (contact_grp != "All")
|
||||||
std::string filename = group_path + cleanFileName(contact_grp + ".grp");
|
|
||||||
|
|
||||||
FILE* fp = LLFile::fopen(filename, "w");
|
|
||||||
|
|
||||||
if (fp)
|
|
||||||
{
|
{
|
||||||
char buffer[10000]; /*Flawfinder: ignore*/
|
filterContacts();
|
||||||
char *bptr;
|
categorizeContacts();
|
||||||
S32 len = 0;
|
}
|
||||||
|
else refreshNames(LLFriendObserver::ADD);
|
||||||
|
}
|
||||||
|
|
||||||
while ( fgets(buffer, 10000, fp) && !feof(fp) )
|
void LLPanelFriends::categorizeContacts()
|
||||||
|
{
|
||||||
|
LLSD contact_groups = gSavedPerAccountSettings.getLLSD("AscentContactGroups");
|
||||||
|
std::string group_name = "All";
|
||||||
|
|
||||||
|
LLComboBox* combo = getChild<LLComboBox>("buddy_group_combobox");
|
||||||
|
if (combo)
|
||||||
|
{
|
||||||
|
group_name = combo->getValue().asString();
|
||||||
|
|
||||||
|
if (group_name != "All")
|
||||||
{
|
{
|
||||||
len = strlen(buffer) - 1; /*Flawfinder: ignore*/
|
std::vector<LLScrollListItem*> vFriends = mFriendsList->getAllData(); // all of it.
|
||||||
for ( bptr = (buffer + len); (*bptr == '\n' || *bptr == '\r') && bptr>buffer; bptr--) *bptr='\0';
|
for (std::vector<LLScrollListItem*>::iterator itr = vFriends.begin(); itr != vFriends.end(); ++itr)
|
||||||
|
{
|
||||||
|
BOOL show_entry = (contact_groups[group_name][(*itr)->getUUID().asString()].size() != 0);
|
||||||
|
|
||||||
|
if (!show_entry)
|
||||||
|
{
|
||||||
|
mFriendsList->deleteItems((*itr)->getValue());
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string file_contents(buffer);
|
refreshUI();
|
||||||
mContactFilter = file_contents;
|
|
||||||
|
|
||||||
LLChat msg(mContactFilter);
|
|
||||||
LLFloaterChat::addChat(msg);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void LLPanelFriends::filterContacts()
|
void LLPanelFriends::filterContacts()
|
||||||
{
|
{
|
||||||
//LLComboBox* combo = getChild<LLComboBox>("buddy_group_combobox");
|
|
||||||
//if (combo->getValue().asString() != "All")
|
|
||||||
std::string friend_name;
|
std::string friend_name;
|
||||||
std::string search_name;
|
std::string search_name;
|
||||||
|
|
||||||
search_name = LLPanelFriends::getChild<LLLineEditor>("buddy_search_lineedit")->getValue().asString();
|
search_name = LLPanelFriends::getChild<LLLineEditor>("buddy_search_lineedit")->getValue().asString();
|
||||||
|
|
||||||
if (search_name != "" && search_name != mLastContactSearch)
|
if ((search_name != "" /*&& search_name != mLastContactSearch*/))
|
||||||
{
|
{
|
||||||
mLastContactSearch = search_name;
|
mLastContactSearch = search_name;
|
||||||
refreshNames(LLFriendObserver::ADD);
|
refreshNames(LLFriendObserver::ADD);
|
||||||
@@ -298,6 +294,7 @@ void LLPanelFriends::filterContacts()
|
|||||||
{
|
{
|
||||||
friend_name = utf8str_tolower((*itr)->getColumn(LIST_FRIEND_NAME)->getValue().asString());
|
friend_name = utf8str_tolower((*itr)->getColumn(LIST_FRIEND_NAME)->getValue().asString());
|
||||||
BOOL show_entry = (friend_name.find(utf8str_tolower(search_name)) != std::string::npos);
|
BOOL show_entry = (friend_name.find(utf8str_tolower(search_name)) != std::string::npos);
|
||||||
|
|
||||||
if (!show_entry)
|
if (!show_entry)
|
||||||
{
|
{
|
||||||
mFriendsList->deleteItems((*itr)->getValue());
|
mFriendsList->deleteItems((*itr)->getValue());
|
||||||
@@ -698,7 +695,6 @@ BOOL LLPanelFriends::refreshNamesPresence(const LLAvatarTracker::buddy_map_t & a
|
|||||||
// meal disk
|
// meal disk
|
||||||
void LLPanelFriends::refreshUI()
|
void LLPanelFriends::refreshUI()
|
||||||
{
|
{
|
||||||
populateContactGroupSelect();
|
|
||||||
BOOL single_selected = FALSE;
|
BOOL single_selected = FALSE;
|
||||||
BOOL multiple_selected = FALSE;
|
BOOL multiple_selected = FALSE;
|
||||||
int num_selected = mFriendsList->getAllSelected().size();
|
int num_selected = mFriendsList->getAllSelected().size();
|
||||||
|
|||||||
@@ -83,6 +83,8 @@ public:
|
|||||||
static void requestFriendship(const LLUUID& target_id,
|
static void requestFriendship(const LLUUID& target_id,
|
||||||
const std::string& target_name, const std::string& message);
|
const std::string& target_name, const std::string& message);
|
||||||
|
|
||||||
|
void populateContactGroupSelect();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
||||||
enum FRIENDS_COLUMN_ORDER
|
enum FRIENDS_COLUMN_ORDER
|
||||||
@@ -103,8 +105,8 @@ private:
|
|||||||
void refreshNames(U32 changed_mask);
|
void refreshNames(U32 changed_mask);
|
||||||
// <dogmode> Contacts search and group system
|
// <dogmode> Contacts search and group system
|
||||||
void filterContacts();
|
void filterContacts();
|
||||||
|
void categorizeContacts();
|
||||||
void setContactGroup(std::string contact_grp);
|
void setContactGroup(std::string contact_grp);
|
||||||
void populateContactGroupSelect();
|
|
||||||
std::string cleanFileName(std::string filename);
|
std::string cleanFileName(std::string filename);
|
||||||
// --
|
// --
|
||||||
BOOL refreshNamesSync(const LLAvatarTracker::buddy_map_t & all_buddies);
|
BOOL refreshNamesSync(const LLAvatarTracker::buddy_map_t & all_buddies);
|
||||||
|
|||||||
Reference in New Issue
Block a user