Merge branch 'friend_list_groups_and_notes' into 'atys'

Friend list groups

See merge request ryzom/ryzom-core!4
ryzom/ui/improvements
Nuno Gonçalves (Ulukyn) 4 years ago
commit bca2a28187

@ -311,6 +311,8 @@ void CPeopleInterraction::release()
ChatInput.Tell.removeListeningPeopleList(&TeamList); ChatInput.Tell.removeListeningPeopleList(&TeamList);
ChatInput.Team.removeListeningPeopleList(&TeamList); ChatInput.Team.removeListeningPeopleList(&TeamList);
FriendList.saveContactGroups();
CChatWindowManager &cwm = getChatWndMgr(); CChatWindowManager &cwm = getChatWndMgr();
AroundMe.release(); AroundMe.release();
@ -333,7 +335,7 @@ void CPeopleInterraction::release()
SystemInfo = NULL; SystemInfo = NULL;
TellWindow = NULL; TellWindow = NULL;
DebugInfo = NULL; DebugInfo = NULL;
// TellWindow = NULL; // TellWindow = NULL;
for(uint i=0;i<CChatGroup::MaxDynChanPerPlayer;i++) for(uint i=0;i<CChatGroup::MaxDynChanPerPlayer;i++)
{ {
@ -390,7 +392,7 @@ void CPeopleInterraction::removeAllPartyChat()
//=========================================================================================================== //===========================================================================================================
bool CPeopleInterraction::isUserChat(CChatWindow *cw) const bool CPeopleInterraction::isUserChat(CChatWindow *cw) const
{ {
// if (cw == MainChat.Window) return true; // if (cw == MainChat.Window) return true;
if (cw == ChatGroup.Window) return true; if (cw == ChatGroup.Window) return true;
for(uint k = 0; k < MaxNumUserChats; ++k) for(uint k = 0; k < MaxNumUserChats; ++k)
{ {
@ -1266,6 +1268,9 @@ void CPeopleInterraction::initContactLists( const std::vector<uint32> &vFriendLi
addContactInList(contactIdPool++, vFriendListName[i], vFriendListOnline[i], 0); addContactInList(contactIdPool++, vFriendListName[i], vFriendListOnline[i], 0);
for (uint i = 0; i < vIgnoreListName.size(); ++i) for (uint i = 0; i < vIgnoreListName.size(); ++i)
addContactInList(contactIdPool++, vIgnoreListName[i], ccs_offline, 1); addContactInList(contactIdPool++, vIgnoreListName[i], ccs_offline, 1);
FriendList.readContactGroups();
CPeopleList::TSortOrder order = (CPeopleList::TSortOrder)(NLGUI::CDBManager::getInstance()->getDbProp("UI:SAVE:CONTACT_LIST:SORT_ORDER")->getValue32());
FriendList.sortEx(order);
updateAllFreeTellerHeaders(); updateAllFreeTellerHeaders();
} }
@ -1278,6 +1283,8 @@ void CPeopleInterraction::addContactInList(uint32 contactId, const ucstring &nam
// remove the shard name if possible // remove the shard name if possible
ucstring name= CEntityCL::removeShardFromName(nameIn); ucstring name= CEntityCL::removeShardFromName(nameIn);
// add the contact to this list // add the contact to this list
sint index = pl.getIndexFromName(name); sint index = pl.getIndexFromName(name);
// try to create if not found // try to create if not found
@ -1742,7 +1749,7 @@ bool CPeopleInterraction::loadUserChatsInfos(NLMISC::IStream &f)
f.serialCheck(NELID("TAHC")); f.serialCheck(NELID("TAHC"));
if (ver>=1) if (ver>=1)
{ {
// CChatGroupWindow *pCGW = PeopleInterraction.getChatGroupWindow(); // CChatGroupWindow *pCGW = PeopleInterraction.getChatGroupWindow();
sint32 index; sint32 index;
f.serial(index); f.serial(index);
/* Yoyo: decide to always start with the default channel (user) activated /* Yoyo: decide to always start with the default channel (user) activated
@ -2307,6 +2314,56 @@ public:
}; };
REGISTER_ACTION_HANDLER( CHandlerMoveContact, "move_contact"); REGISTER_ACTION_HANDLER( CHandlerMoveContact, "move_contact");
uint lastPeopleIndexChangeGroup;
//=================================================================================================================
class CHandlerChangeContactGroupBegin : public IActionHandler
{
public:
void execute (CCtrlBase * pCaller, const std::string &sParams)
{
// retrieve the index of the people
CPeopleList *srcList;
if (PeopleInterraction.getPeopleFromCurrentMenu(srcList, lastPeopleIndexChangeGroup))
{
string groupName= getParam(sParams, "group");
CInterfaceGroup *gc = dynamic_cast<CInterfaceGroup *>(CWidgetManager::getInstance()->getElementFromId(groupName));
if (gc)
{
CGroupEditBox *geb = dynamic_cast<CGroupEditBox *>(gc->getGroup("change_contact_group_eb:eb"));
geb->setInputString(ucstring(""));
}
CAHManager::getInstance()->runActionHandler("enter_modal", pCaller, sParams);
}
}
};
REGISTER_ACTION_HANDLER( CHandlerChangeContactGroupBegin, "change_contact_group_begin");
//=================================================================================================================
// Change the group of a contact in the list
class CHandlerChangeContactGroup : public IActionHandler
{
public:
void execute (CCtrlBase *pCaller, const std::string &/* sParams */)
{
CInterfaceManager *pIM = CInterfaceManager::getInstance();
if (pCaller)
{
// Get the modal edit box
CGroupEditBox *geb = dynamic_cast<CGroupEditBox *>(CWidgetManager::getInstance()->getElementFromId("ui:interface:change_contact_group:change_contact_group_eb:eb"));
if (geb)
{
PeopleInterraction.FriendList.changeGroup(lastPeopleIndexChangeGroup, geb->getInputString());
geb->setInputString(ucstring(""));
CPeopleList::TSortOrder order = (CPeopleList::TSortOrder)(NLGUI::CDBManager::getInstance()->getDbProp("UI:SAVE:CONTACT_LIST:SORT_ORDER")->getValue32());
PeopleInterraction.FriendList.sortEx(order);
}
}
CAHManager::getInstance()->runActionHandler("leave_modal", pCaller, "");
}
};
REGISTER_ACTION_HANDLER( CHandlerChangeContactGroup, "change_contact_group");
//================================================================================================================= //=================================================================================================================
class CHandlerSortContacts : public IActionHandler class CHandlerSortContacts : public IActionHandler
@ -2488,7 +2545,7 @@ class CHandlerAddAllTeamMembersToPartyChat : public IActionHandler
{ {
void execute (CCtrlBase * /* pCaller */, const std::string &/* sParams */) void execute (CCtrlBase * /* pCaller */, const std::string &/* sParams */)
{ {
// CChatWindow *chat = getChatWndMgr().getChatWindowFromCaller(CWidgetManager::getInstance()->getCtrlLaunchingModal()); // CChatWindow *chat = getChatWndMgr().getChatWindowFromCaller(CWidgetManager::getInstance()->getCtrlLaunchingModal());
// TODO GAMEDEV : add all team members // TODO GAMEDEV : add all team members
} }
}; };
@ -2501,7 +2558,7 @@ class CHandlerRemoveAllTeamMembersToPartyChat : public IActionHandler
{ {
void execute (CCtrlBase * /* pCaller */, const std::string &/* sParams */) void execute (CCtrlBase * /* pCaller */, const std::string &/* sParams */)
{ {
// CChatWindow *chat = getChatWndMgr().getChatWindowFromCaller(CWidgetManager::getInstance()->getCtrlLaunchingModal()); // CChatWindow *chat = getChatWndMgr().getChatWindowFromCaller(CWidgetManager::getInstance()->getCtrlLaunchingModal());
// TODO GAMEDEV : remove all team members // TODO GAMEDEV : remove all team members
} }
}; };
@ -2514,7 +2571,7 @@ class CHandlerAddAllGuildMembersToPartyChat : public IActionHandler
{ {
void execute (CCtrlBase * /* pCaller */, const std::string &/* sParams */) void execute (CCtrlBase * /* pCaller */, const std::string &/* sParams */)
{ {
// CChatWindow *chat = getChatWndMgr().getChatWindowFromCaller(CWidgetManager::getInstance()->getCtrlLaunchingModal()); // CChatWindow *chat = getChatWndMgr().getChatWindowFromCaller(CWidgetManager::getInstance()->getCtrlLaunchingModal());
// TODO GAMEDEV : add all guild members // TODO GAMEDEV : add all guild members
} }
}; };
@ -2527,7 +2584,7 @@ class CHandlerRemoveAllGuildMembersToPartyChat : public IActionHandler
{ {
void execute (CCtrlBase * /* pCaller */, const std::string &/* sParams */) void execute (CCtrlBase * /* pCaller */, const std::string &/* sParams */)
{ {
// CChatWindow *chat = getChatWndMgr().getChatWindowFromCaller(CWidgetManager::getInstance()->getCtrlLaunchingModal()); // CChatWindow *chat = getChatWndMgr().getChatWindowFromCaller(CWidgetManager::getInstance()->getCtrlLaunchingModal());
// TODO_GAMEDEV : remove all guild members // TODO_GAMEDEV : remove all guild members
} }
}; };
@ -2603,7 +2660,7 @@ public:
{ {
CInterfaceManager *pIM = CInterfaceManager::getInstance(); CInterfaceManager *pIM = CInterfaceManager::getInstance();
cw = PeopleInterraction.TheUserChat.Window; cw = PeopleInterraction.TheUserChat.Window;
// CChatStdInput &ci = PeopleInterraction.ChatInput; // CChatStdInput &ci = PeopleInterraction.ChatInput;
CGroupMenu *pMenu = dynamic_cast<CGroupMenu*>(CWidgetManager::getInstance()->getElementFromId("ui:interface:user_chat_target_menu")); CGroupMenu *pMenu = dynamic_cast<CGroupMenu*>(CWidgetManager::getInstance()->getElementFromId("ui:interface:user_chat_target_menu"));
CViewTextMenu *pMenuAround = dynamic_cast<CViewTextMenu*>(pMenu->getElement("ui:interface:user_chat_target_menu:around")); CViewTextMenu *pMenuAround = dynamic_cast<CViewTextMenu*>(pMenu->getElement("ui:interface:user_chat_target_menu:around"));
CViewTextMenu *pMenuRegion = dynamic_cast<CViewTextMenu*>(pMenu->getElement("ui:interface:user_chat_target_menu:region")); CViewTextMenu *pMenuRegion = dynamic_cast<CViewTextMenu*>(pMenu->getElement("ui:interface:user_chat_target_menu:region"));
@ -3186,80 +3243,80 @@ NLMISC_COMMAND(ignore, "add or remove a player from the ignore list", "<player n
} // ignore // } // ignore //
/* /*
**** ****
Yoyo: Party chat is not ended: DON'T LET THOSE COMMANDS AVAILABLE! Yoyo: Party chat is not ended: DON'T LET THOSE COMMANDS AVAILABLE!
they made the client crash (cf createNewPartyChat)... they made the client crash (cf createNewPartyChat)...
**** ****
// create a new party chat with the given name // create a new party chat with the given name
NLMISC_COMMAND(party_chat, "Create a new party chat", "<party_chat_name>") NLMISC_COMMAND(party_chat, "Create a new party chat", "<party_chat_name>")
{ {
if (args.size() != 1) if (args.size() != 1)
{ {
displayVisibleSystemMsg(CI18N::get("uiPartyChatCmd")); displayVisibleSystemMsg(CI18N::get("uiPartyChatCmd"));
return true; return true;
} }
CPeopleInterraction &pi = PeopleInterraction; CPeopleInterraction &pi = PeopleInterraction;
ucstring title = args[0]; ucstring title = args[0];
if (!pi.testValidPartyChatName(title)) if (!pi.testValidPartyChatName(title))
{ {
displayVisibleSystemMsg(CI18N::get("uiInvalidPartyChatName")); displayVisibleSystemMsg(CI18N::get("uiInvalidPartyChatName"));
return true; return true;
} }
PeopleInterraction.createNewPartyChat(title); PeopleInterraction.createNewPartyChat(title);
return true; return true;
} }
// Remove the party chat with the given name // Remove the party chat with the given name
NLMISC_COMMAND(remove_party_chat, "Remove a party chat", "<party_chat_name>") NLMISC_COMMAND(remove_party_chat, "Remove a party chat", "<party_chat_name>")
{ {
if (args.size() != 1) if (args.size() != 1)
{ {
displayVisibleSystemMsg(CI18N::get("uiRemovePartyChatCmd")); displayVisibleSystemMsg(CI18N::get("uiRemovePartyChatCmd"));
return true; return true;
} }
ucstring title = ucstring(args[0]); ucstring title = ucstring(args[0]);
CChatWindow *chat = getChatWndMgr().getChatWindow(title); CChatWindow *chat = getChatWndMgr().getChatWindow(title);
if (!chat) if (!chat)
{ {
displayVisibleSystemMsg(title + ucstring(" : ") + CI18N::get("uiBadPartyChatName")); displayVisibleSystemMsg(title + ucstring(" : ") + CI18N::get("uiBadPartyChatName"));
return true; return true;
} }
if (!PeopleInterraction.removePartyChat(chat)) if (!PeopleInterraction.removePartyChat(chat))
{ {
displayVisibleSystemMsg(title + ucstring(" : ") + CI18N::get("uiCantRemovePartyChat")); displayVisibleSystemMsg(title + ucstring(" : ") + CI18N::get("uiCantRemovePartyChat"));
return true; return true;
} }
return true; return true;
} }
// Join a party chat whose name is known // Join a party chat whose name is known
NLMISC_COMMAND(add_to_party_chat, "Join the given party chat", "<party_chat_name>") NLMISC_COMMAND(add_to_party_chat, "Join the given party chat", "<party_chat_name>")
{ {
if (args.size() != 1) if (args.size() != 1)
{ {
displayVisibleSystemMsg(CI18N::get("uiAddPartyChatCmd")); displayVisibleSystemMsg(CI18N::get("uiAddPartyChatCmd"));
return true; return true;
} }
// TODO GAMEDEV : join the party chat // TODO GAMEDEV : join the party chat
return true; return true;
} }
// Invite someone in a party chat // Invite someone in a party chat
NLMISC_COMMAND(invite, "Invite someone to a party chat", "<people_name> <party_chat_name>") NLMISC_COMMAND(invite, "Invite someone to a party chat", "<people_name> <party_chat_name>")
{ {
if (args.size() != 2) if (args.size() != 2)
{ {
displayVisibleSystemMsg(CI18N::get("uiInviteCmd")); displayVisibleSystemMsg(CI18N::get("uiInviteCmd"));
return true; return true;
} }
// TODO GAMEDEV : Send invite message to the server // TODO GAMEDEV : Send invite message to the server
// Check that the inviter has created the chat ? // Check that the inviter has created the chat ?
// The people being invited should receive a popup to announce that he is being invited // The people being invited should receive a popup to announce that he is being invited
return true; return true;
} }
*/ */

@ -31,6 +31,7 @@
#include "chat_text_manager.h" #include "chat_text_manager.h"
#include "people_interraction.h" #include "people_interraction.h"
#include "../user_entity.h" #include "../user_entity.h"
#include "nel/misc/o_xml.h"
using namespace std; using namespace std;
using namespace NLMISC; using namespace NLMISC;
@ -191,21 +192,28 @@ sint CPeopleList::getIndexFromContainerID(const std::string &id) const
//================================================================== //==================================================================
bool CPeopleList::sortExByContactId(const CPeople& a, const CPeople& b) bool CPeopleList::sortExByContactId(const CPeople& a, const CPeople& b)
{ {
if (a.Group == b.Group)
return (a.ContactId < b.ContactId); return (a.ContactId < b.ContactId);
else
return (a.Group < b.Group);
} }
//================================================================== //==================================================================
bool CPeopleList::sortExByName(const CPeople& a, const CPeople& b) bool CPeopleList::sortExByName(const CPeople& a, const CPeople& b)
{ {
if (a.Group == b.Group) {
ucstring name_a = toUpper(a.getName()); ucstring name_a = toUpper(a.getName());
ucstring name_b = toUpper(b.getName()); ucstring name_b = toUpper(b.getName());
return (name_a < name_b); return (name_a < name_b);
}
else
return (a.Group < b.Group);
} }
//================================================================== //==================================================================
bool CPeopleList::sortExByOnline(const CPeople& a, const CPeople& b) bool CPeopleList::sortExByOnline(const CPeople& a, const CPeople& b)
{ {
if (a.Group == b.Group) {
ucstring name_a = toUpper(a.getName()); ucstring name_a = toUpper(a.getName());
ucstring name_b = toUpper(b.getName()); ucstring name_b = toUpper(b.getName());
@ -234,9 +242,9 @@ bool CPeopleList::sortExByOnline(const CPeople& a, const CPeople& b)
break; break;
} }
} }
}
// Should not get here so just return something else
return true; return (a.Group < b.Group);
} }
//================================================================== //==================================================================
@ -245,9 +253,16 @@ void CPeopleList::sortEx(TSortOrder order)
// remove all people from the father container // remove all people from the father container
if (!_BaseContainer) return; if (!_BaseContainer) return;
uint k; uint k;
for(k = 0; k < _Peoples.size(); ++k) for(k = 0; k < _Peoples.size(); ++k)
{ {
_BaseContainer->detachContainer(_Peoples[k].Container); CGroupContainer *parentContainer = _Peoples[k].Container->getProprietaryContainer();
parentContainer->detachContainer(_Peoples[k].Container);
}
for (k = 0; k < _GroupContainers.size(); ++k)
{
if (_GroupContainers[k].second->getProprietaryContainer() != NULL)
_BaseContainer->detachContainer(_GroupContainers[k].second);
} }
switch (order) switch (order)
@ -265,9 +280,27 @@ void CPeopleList::sortEx(TSortOrder order)
break; break;
} }
CGroupContainer *group = _BaseContainer;
uint groupIndex = 0;
for(k = 0; k < _Peoples.size(); ++k) for(k = 0; k < _Peoples.size(); ++k)
{ {
_BaseContainer->attachContainer(_Peoples[k].Container); bool newGroup = false;
if (k == 0)
{
newGroup = true;
}
while (groupIndex < _GroupContainers.size() && _GroupContainers[groupIndex].first != _Peoples[k].Group.toString())
{
newGroup = true;
++groupIndex;
}
if (newGroup && groupIndex < _GroupContainers.size() && _GroupContainers.size() > 1)
{
group = _GroupContainers[groupIndex].second;
_BaseContainer->attachContainer(group);
}
group->attachContainer(_Peoples[k].Container);
} }
} }
@ -299,8 +332,8 @@ bool CPeopleList::isPeopleChatVisible(uint index) const
return (_Peoples[index].Chat != NULL); return (_Peoples[index].Chat != NULL);
} }
/* /*
bool CPeopleList::isPeopleWindowVisible(uint index) const bool CPeopleList::isPeopleWindowVisible(uint index) const
{ {
if (index >= _Peoples.size()) if (index >= _Peoples.size())
{ {
nlwarning("Bad index"); nlwarning("Bad index");
@ -326,7 +359,7 @@ bool CPeopleList::isPeopleWindowVisible(uint index) const
{ {
return false; return false;
} }
} }
*/ */
//================================================================== //==================================================================
@ -415,8 +448,9 @@ void CPeopleList::removePeople(uint index)
} }
else else
{ {
if (_BaseContainer) CGroupContainer *parentContainer = _Peoples[index].Container->getProprietaryContainer();
_BaseContainer->detachContainer(_Peoples[index].Container); if (parentContainer)
parentContainer->detachContainer(_Peoples[index].Container);
} }
CInterfaceManager *im = CInterfaceManager::getInstance(); CInterfaceManager *im = CInterfaceManager::getInstance();
CInterfaceGroup *pRoot = dynamic_cast<CInterfaceGroup*>(CWidgetManager::getInstance()->getElementFromId("ui:interface")); CInterfaceGroup *pRoot = dynamic_cast<CInterfaceGroup*>(CWidgetManager::getInstance()->getElementFromId("ui:interface"));
@ -447,6 +481,169 @@ void CPeopleList::setContactId(uint index, uint32 contactId)
_Peoples[index].ContactId = contactId; _Peoples[index].ContactId = contactId;
} }
//==================================================================
void CPeopleList::changeGroup(uint index, const ucstring &groupName)
{
if (index >= _Peoples.size())
{
nlwarning("<CPeopleList::changeGroup> bad index.");
return;
}
ucstring group = groupName;
if (group.toString() == "General")
group = ucstring("");
_Peoples[index].Group = group;
for (uint k = 0; k < _GroupContainers.size(); ++k)
{
if (_GroupContainers[k].first == group.toString())
return;
}
vector<pair<string, string> > properties;
properties.push_back(make_pair(string("posparent"), string("parent")));
properties.push_back(make_pair(string("id"), _ContainerID + "_group_" + toString(_GroupContainers.size())));
if (group.toString() == "")
properties.push_back(make_pair(string("title"), "General"));
else
properties.push_back(make_pair(string("title"), group.toString()));
CGroupContainer *gc = dynamic_cast<CGroupContainer *>(CWidgetManager::getInstance()->getParser()->createGroupInstance("people_list_group_header", "ui:interface", properties, false));
if (group.toString() == "")
gc->setUCTitle(ucstring("General"));
else
gc->setUCTitle(group.toString());
gc->setSavable(false);
CInterfaceGroup *pRoot = dynamic_cast<CInterfaceGroup*>(CWidgetManager::getInstance()->getElementFromId("ui:interface"));
pRoot->addGroup (gc);
_BaseContainer->attachContainer(gc);
_GroupContainers.push_back(make_pair(group.toString(), gc));
std::sort(_GroupContainers.begin(), _GroupContainers.end());
}
//==================================================================
void CPeopleList::readContactGroups()
{
_GroupContainers.clear();
// Create default group even if no groups defined
vector<pair<string, string> > properties;
properties.push_back(make_pair(string("posparent"), string("parent")));
properties.push_back(make_pair(string("id"), _ContainerID + "_group_0"));
properties.push_back(make_pair(string("title"), "General"));
CInterfaceGroup *group = CWidgetManager::getInstance()->getParser()->createGroupInstance("people_list_group_header", "ui:interface", properties, false);
CGroupContainer *gc = dynamic_cast<CGroupContainer *>(group);
gc->setUCTitle(ucstring("General"));
gc->setSavable(false);
CInterfaceGroup *pRoot = dynamic_cast<CInterfaceGroup*>(CWidgetManager::getInstance()->getElementFromId("ui:interface"));
pRoot->addGroup (gc);
_BaseContainer->attachContainer(gc);
_GroupContainers.push_back(make_pair("", gc));
const std::string filename = CInterfaceManager::getInstance()->getSaveFileName("contactgroups", "xml");
try
{
CIFile fd;
if (fd.open(CPath::lookup(filename)))
{
CIXml stream;
stream.init(fd);
xmlKeepBlanksDefault(0);
xmlNodePtr root = stream.getRootNode();
if (!root) return;
xmlNodePtr node = root->children;
uint nb = 0;
while (node)
{
CXMLAutoPtr propName;
propName = (char*) xmlGetProp(node, (xmlChar*)"name");
CXMLAutoPtr propGroup;
propGroup = (char*) xmlGetProp(node, (xmlChar*)"group");
if (propName && propGroup)
{
sint index = getIndexFromName(propName.str());
if (index < _Peoples.size())
{
_Peoples[index].Group = propGroup.str();
if (_GroupContainers.empty() || _GroupContainers.back().first != propGroup.str()) {
vector<pair<string, string> > properties;
properties.push_back(make_pair(string("posparent"), string("parent")));
properties.push_back(make_pair(string("id"), _ContainerID + "_group_" + toString(_GroupContainers.size())));
if (propGroup.str() == "")
properties.push_back(make_pair(string("title"), "General"));
else
properties.push_back(make_pair(string("title"), propGroup.str()));
CInterfaceGroup *group = CWidgetManager::getInstance()->getParser()->createGroupInstance("people_list_group_header", "ui:interface", properties, false);
CGroupContainer *gc = dynamic_cast<CGroupContainer *>(group);
if (propGroup.str() == "")
gc->setUCTitle(ucstring("General"));
else
gc->setUCTitle(propGroup.str());
gc->setSavable(false);
CInterfaceGroup *pRoot = dynamic_cast<CInterfaceGroup*>(CWidgetManager::getInstance()->getElementFromId("ui:interface"));
pRoot->addGroup (gc);
_BaseContainer->attachContainer(gc);
_GroupContainers.push_back(make_pair(propGroup.str(), gc));
}
}
}
node = node->next;
nb++;
}
fd.close();
}
std::sort(_GroupContainers.begin(), _GroupContainers.end());
}
catch (const Exception &e)
{
nlwarning("Error while parsing xml file %s : %s", filename.c_str(), e.what());
}
}
//==================================================================
void CPeopleList::saveContactGroups()
{
const std::string filename = CInterfaceManager::getInstance()->getSaveFileName("contactgroups", "xml");
try
{
COFile fd;
if (fd.open(filename, false, false, true))
{
COXml stream;
stream.init(&fd);
xmlDocPtr doc = stream.getDocument();
xmlNodePtr node = xmlNewDocNode(doc, NULL, (const xmlChar*)"contact_groups", NULL);
xmlDocSetRootElement(doc, node);
for (uint k = 0; k < _Peoples.size(); ++k)
{
xmlNodePtr newNode = xmlNewChild(node, NULL, (const xmlChar*)"contact", NULL);
xmlSetProp(newNode, (const xmlChar*)"name", (const xmlChar*)_Peoples[k].getName().toString().c_str());
xmlSetProp(newNode, (const xmlChar*)"group", (const xmlChar*)_Peoples[k].Group.toString().c_str());
}
stream.flush();
fd.close();
}
nlinfo("save %s", filename.c_str());
}
catch (const Exception &e)
{
nlwarning("Error while writing the file %s : %s", filename.c_str(), e.what());
}
}
//================================================================== //==================================================================
void CPeopleList::displayLocalPlayerTell(const ucstring &receiver, uint index, const ucstring &msg,uint numBlinks /*=0*/) void CPeopleList::displayLocalPlayerTell(const ucstring &receiver, uint index, const ucstring &msg,uint numBlinks /*=0*/)
{ {

@ -110,6 +110,11 @@ public:
void setContactId(uint index, uint32 contactId); void setContactId(uint index, uint32 contactId);
sint getIndexFromContactId(uint32 contactId); sint getIndexFromContactId(uint32 contactId);
// For Friend Groups management
void changeGroup(uint index, const ucstring &groupName);
void readContactGroups();
void saveContactGroups();
/** Display a message for the given people /** Display a message for the given people
* If the window is closed, it causes it to blink (and also the parent window) * If the window is closed, it causes it to blink (and also the parent window)
*/ */
@ -151,19 +156,21 @@ public:
private: private:
struct CPeople struct CPeople
{ {
CPeople() : Container(NULL), Chat(NULL), Online(ccs_offline), Blocked(false), ContactId(0) {} CPeople() : Container(NULL), Chat(NULL), Online(ccs_offline), Blocked(false), ContactId(0), Group("") {}
NLMISC::CRefPtr<CGroupContainer> Container; // todo : replace this with a CChatWindow one day, for consistency NLMISC::CRefPtr<CGroupContainer> Container; // todo : replace this with a CChatWindow one day, for consistency
NLMISC::CRefPtr<CGroupContainer> Chat; NLMISC::CRefPtr<CGroupContainer> Chat;
uint GlobalID; uint GlobalID;
TCharConnectionState Online; TCharConnectionState Online;
bool Blocked; bool Blocked;
uint32 ContactId; uint32 ContactId;
ucstring Group;
bool operator < (const CPeople &other) const { return getName() < other.getName(); } bool operator < (const CPeople &other) const { return getName() < other.getName(); }
ucstring getName() const { return Container->getUCTitle(); } ucstring getName() const { return Container->getUCTitle(); }
}; };
typedef std::vector<CPeople> TPeopleVect; typedef std::vector<CPeople> TPeopleVect;
private: private:
CGroupContainerPtr _BaseContainer; CGroupContainerPtr _BaseContainer;
std::vector<std::pair<std::string, NLMISC::CRefPtr<CGroupContainer> > > _GroupContainers;
NLMISC::CRefPtr<CChatWindow> _ChatWindow; NLMISC::CRefPtr<CChatWindow> _ChatWindow;
TPeopleVect _Peoples; TPeopleVect _Peoples;
CPeopleListDesc::TContactType _ContactType; CPeopleListDesc::TContactType _ContactType;

Loading…
Cancel
Save