summaryrefslogtreecommitdiff
path: root/indra/newview/llfloaterfriends.cpp
diff options
context:
space:
mode:
authorKent Quirk <q@lindenlab.com>2009-01-05 18:59:12 +0000
committerKent Quirk <q@lindenlab.com>2009-01-05 18:59:12 +0000
commit667ca55bad0108c4bdf8f007b89e1a52fc766aad (patch)
tree7bd62ac8d9af079c3994565f3f200ccc250bbc28 /indra/newview/llfloaterfriends.cpp
parent95f365789f4cebc7bd97ccefd538f14d481a8373 (diff)
svn merge -r106715:HEAD svn+ssh://svn.lindenlab.com/svn/linden/branches/q/notifications-merge-r106715 . QAR-1149 -- Final merge of notifications to trunk.
Diffstat (limited to 'indra/newview/llfloaterfriends.cpp')
-rw-r--r--indra/newview/llfloaterfriends.cpp156
1 files changed, 81 insertions, 75 deletions
diff --git a/indra/newview/llfloaterfriends.cpp b/indra/newview/llfloaterfriends.cpp
index 2d7d2ee15d..f5493172ba 100644
--- a/indra/newview/llfloaterfriends.cpp
+++ b/indra/newview/llfloaterfriends.cpp
@@ -523,9 +523,9 @@ void LLPanelFriends::onSelectName(LLUICtrl* ctrl, void* user_data)
//static
void LLPanelFriends::onMaximumSelect(void* user_data)
{
- LLStringUtil::format_map_t args;
- args["[MAX_SELECT]"] = llformat("%d", MAX_FRIEND_SELECT);
- LLNotifyBox::showXml("MaxListSelectMessage", args);
+ LLSD args;
+ args["MAX_SELECT"] = llformat("%d", MAX_FRIEND_SELECT);
+ LLNotifications::instance().add("MaxListSelectMessage", args);
};
// static
@@ -585,27 +585,22 @@ void LLPanelFriends::requestFriendship(const LLUUID& target_id, const std::strin
calling_card_folder_id);
}
-struct LLAddFriendData
-{
- LLUUID mID;
- std::string mName;
-};
-
// static
-void LLPanelFriends::callbackAddFriendWithMessage(S32 option, const std::string& text, void* data)
+bool LLPanelFriends::callbackAddFriendWithMessage(const LLSD& notification, const LLSD& response)
{
- LLAddFriendData* add = (LLAddFriendData*)data;
+ S32 option = LLNotification::getSelectedOption(notification, response);
if (option == 0)
{
- requestFriendship(add->mID, add->mName, text);
+ requestFriendship(notification["payload"]["id"].asUUID(),
+ notification["payload"]["name"].asString(),
+ response["message"].asString());
}
- delete add;
+ return false;
}
-// static
-void LLPanelFriends::callbackAddFriend(S32 option, void* data)
+bool LLPanelFriends::callbackAddFriend(const LLSD& notification, const LLSD& response)
{
- LLAddFriendData* add = (LLAddFriendData*)data;
+ S32 option = LLNotification::getSelectedOption(notification, response);
if (option == 0)
{
// Servers older than 1.25 require the text of the message to be the
@@ -613,9 +608,11 @@ void LLPanelFriends::callbackAddFriend(S32 option, void* data)
LLUUID calling_card_folder_id =
gInventory.findCategoryUUIDForType(LLAssetType::AT_CALLINGCARD);
std::string message = calling_card_folder_id.asString();
- requestFriendship(add->mID, add->mName, message);
+ requestFriendship(notification["payload"]["id"].asUUID(),
+ notification["payload"]["name"].asString(),
+ message);
}
- delete add;
+ return false;
}
// static
@@ -634,27 +631,25 @@ void LLPanelFriends::requestFriendshipDialog(const LLUUID& id,
{
if(id == gAgentID)
{
- LLNotifyBox::showXml("AddSelfFriend");
+ LLNotifications::instance().add("AddSelfFriend");
return;
}
- LLAddFriendData* data = new LLAddFriendData();
- data->mID = id;
- data->mName = name;
-
- LLStringUtil::format_map_t args;
- args["[NAME]"] = name;
-
- // Look for server versions like: Second Life Server 1.24.4.95600
+ LLSD args;
+ args["NAME"] = name;
+ LLSD payload;
+ payload["id"] = id;
+ payload["name"] = name;
+ // Look for server versions like: Second Life Server 1.24.4.95600
if (gLastVersionChannel.find(" 1.24.") != std::string::npos)
{
// Old and busted server version, doesn't support friend
// requests with messages.
- gViewerWindow->alertXml("AddFriend", args, callbackAddFriend, data);
+ LLNotifications::instance().add("AddFriend", args, payload, &callbackAddFriend);
}
else
{
- gViewerWindow->alertXmlEditText("AddFriendWithMessage", args, NULL, NULL, callbackAddFriendWithMessage, data);
+ LLNotifications::instance().add("AddFriendWithMessage", args, payload, &callbackAddFriendWithMessage);
}
}
@@ -677,7 +672,7 @@ void LLPanelFriends::onClickRemove(void* user_data)
//llinfos << "LLPanelFriends::onClickRemove()" << llendl;
LLDynamicArray<LLUUID> ids = panelp->getSelectedIDs();
- LLStringUtil::format_map_t args;
+ LLSD args;
if(ids.size() > 0)
{
std::string msgType = "RemoveFromFriends";
@@ -687,18 +682,27 @@ void LLPanelFriends::onClickRemove(void* user_data)
std::string first, last;
if(gCacheName->getName(agent_id, first, last))
{
- args["[FIRST_NAME]"] = first;
- args["[LAST_NAME]"] = last;
+ args["FIRST_NAME"] = first;
+ args["LAST_NAME"] = last;
}
}
else
{
msgType = "RemoveMultipleFromFriends";
}
- gViewerWindow->alertXml(msgType,
+ LLSD payload;
+
+ for (LLDynamicArray<LLUUID>::iterator it = ids.begin();
+ it != ids.end();
+ ++it)
+ {
+ payload["ids"].append(*it);
+ }
+
+ LLNotifications::instance().add(msgType,
args,
- &handleRemove,
- (void*)new LLDynamicArray<LLUUID>(ids));
+ payload,
+ &handleRemove);
}
}
@@ -730,13 +734,10 @@ void LLPanelFriends::confirmModifyRights(rights_map_t& ids, EGrantRevoke command
{
if (ids.empty()) return;
- LLStringUtil::format_map_t args;
+ LLSD args;
if(ids.size() > 0)
{
- // copy map of ids onto heap
- rights_map_t* rights = new rights_map_t(ids);
- // package with panel pointer
- std::pair<LLPanelFriends*, rights_map_t*>* user_data = new std::pair<LLPanelFriends*, rights_map_t*>(this, rights);
+ rights_map_t* rights = new rights_map_t(ids);
// for single friend, show their name
if(ids.size() == 1)
@@ -745,62 +746,65 @@ void LLPanelFriends::confirmModifyRights(rights_map_t& ids, EGrantRevoke command
std::string first, last;
if(gCacheName->getName(agent_id, first, last))
{
- args["[FIRST_NAME]"] = first;
- args["[LAST_NAME]"] = last;
+ args["FIRST_NAME"] = first;
+ args["LAST_NAME"] = last;
}
if (command == GRANT)
{
- gViewerWindow->alertXml("GrantModifyRights", args, modifyRightsConfirmation, user_data);
+ LLNotifications::instance().add("GrantModifyRights",
+ args,
+ LLSD(),
+ boost::bind(&LLPanelFriends::modifyRightsConfirmation, this, _1, _2, rights));
}
else
{
- gViewerWindow->alertXml("RevokeModifyRights", args, modifyRightsConfirmation, user_data);
+ LLNotifications::instance().add("RevokeModifyRights",
+ args,
+ LLSD(),
+ boost::bind(&LLPanelFriends::modifyRightsConfirmation, this, _1, _2, rights));
}
}
else
{
if (command == GRANT)
{
- gViewerWindow->alertXml("GrantModifyRightsMultiple", args, modifyRightsConfirmation, user_data);
+ LLNotifications::instance().add("GrantModifyRightsMultiple",
+ args,
+ LLSD(),
+ boost::bind(&LLPanelFriends::modifyRightsConfirmation, this, _1, _2, rights));
}
else
{
- gViewerWindow->alertXml("RevokeModifyRightsMultiple", args, modifyRightsConfirmation, user_data);
+ LLNotifications::instance().add("RevokeModifyRightsMultiple",
+ args,
+ LLSD(),
+ boost::bind(&LLPanelFriends::modifyRightsConfirmation, this, _1, _2, rights));
}
}
}
}
-// static
-void LLPanelFriends::modifyRightsConfirmation(S32 option, void* user_data)
+bool LLPanelFriends::modifyRightsConfirmation(const LLSD& notification, const LLSD& response, rights_map_t* rights)
{
- std::pair<LLPanelFriends*, rights_map_t*>* data = (std::pair<LLPanelFriends*, rights_map_t*>*)user_data;
- LLPanelFriends* panelp = data->first;
-
- if(panelp)
+ S32 option = LLNotification::getSelectedOption(notification, response);
+ if(0 == option)
{
- if(0 == option)
- {
- panelp->sendRightsGrant(*(data->second));
- }
- else
+ sendRightsGrant(*rights);
+ }
+ else
+ {
+ // need to resync view with model, since user cancelled operation
+ rights_map_t::iterator rights_it;
+ for (rights_it = rights->begin(); rights_it != rights->end(); ++rights_it)
{
- // need to resync view with model, since user cancelled operation
- rights_map_t* rights = data->second;
- rights_map_t::iterator rights_it;
- for (rights_it = rights->begin(); rights_it != rights->end(); ++rights_it)
- {
- const LLRelationship* info = LLAvatarTracker::instance().getBuddyInfo(rights_it->first);
- panelp->updateFriendItem(rights_it->first, info);
- // Might have changed the column the user is sorted on.
- panelp->mFriendsList->sortItems();
- }
+ const LLRelationship* info = LLAvatarTracker::instance().getBuddyInfo(rights_it->first);
+ updateFriendItem(rights_it->first, info);
}
- panelp->refreshUI();
}
+ refreshUI();
- delete data->second;
- delete data;
+ delete rights;
+ return false;
}
void LLPanelFriends::applyRightsToFriends()
@@ -924,12 +928,14 @@ void LLPanelFriends::sendRightsGrant(rights_map_t& ids)
// static
-void LLPanelFriends::handleRemove(S32 option, void* user_data)
+bool LLPanelFriends::handleRemove(const LLSD& notification, const LLSD& response)
{
- LLDynamicArray<LLUUID>* ids = static_cast<LLDynamicArray<LLUUID>*>(user_data);
- for(LLDynamicArray<LLUUID>::iterator itr = ids->begin(); itr != ids->end(); ++itr)
+ S32 option = LLNotification::getSelectedOption(notification, response);
+
+ const LLSD& ids = notification["payload"]["ids"];
+ for(LLSD::array_const_iterator itr = ids.beginArray(); itr != ids.endArray(); ++itr)
{
- LLUUID id = (*itr);
+ LLUUID id = itr->asUUID();
const LLRelationship* ip = LLAvatarTracker::instance().getBuddyInfo(id);
if(ip)
{
@@ -955,5 +961,5 @@ void LLPanelFriends::handleRemove(S32 option, void* user_data)
}
}
- delete ids;
+ return false;
}