aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/linden/indra/newview/llviewermessage.cpp
diff options
context:
space:
mode:
authorJacek Antonelli2008-08-15 23:45:34 -0500
committerJacek Antonelli2008-08-15 23:45:34 -0500
commitcd17687f01420952712a500107e0f93e7ab8d5f8 (patch)
treece48c2b706f2c1176290e39fb555fbdf6648ce01 /linden/indra/newview/llviewermessage.cpp
parentSecond Life viewer sources 1.19.0.5 (diff)
downloadmeta-impy-cd17687f01420952712a500107e0f93e7ab8d5f8.zip
meta-impy-cd17687f01420952712a500107e0f93e7ab8d5f8.tar.gz
meta-impy-cd17687f01420952712a500107e0f93e7ab8d5f8.tar.bz2
meta-impy-cd17687f01420952712a500107e0f93e7ab8d5f8.tar.xz
Second Life viewer sources 1.19.1.0
Diffstat (limited to 'linden/indra/newview/llviewermessage.cpp')
-rw-r--r--linden/indra/newview/llviewermessage.cpp92
1 files changed, 48 insertions, 44 deletions
diff --git a/linden/indra/newview/llviewermessage.cpp b/linden/indra/newview/llviewermessage.cpp
index fcebe70..37bd350 100644
--- a/linden/indra/newview/llviewermessage.cpp
+++ b/linden/indra/newview/llviewermessage.cpp
@@ -47,7 +47,6 @@
47#include "lldbstrings.h" 47#include "lldbstrings.h"
48#include "lleconomy.h" 48#include "lleconomy.h"
49#include "llfilepicker.h" 49#include "llfilepicker.h"
50#include "llfloaterimport.h"
51#include "llfocusmgr.h" 50#include "llfocusmgr.h"
52#include "llfollowcamparams.h" 51#include "llfollowcamparams.h"
53#include "llfloaterreleasemsg.h" 52#include "llfloaterreleasemsg.h"
@@ -919,37 +918,25 @@ void inventory_offer_mute_callback(const LLUUID& blocked_id,
919 gFloaterMute->selectMute(blocked_id); 918 gFloaterMute->selectMute(blocked_id);
920 } 919 }
921 920
922 // purge the offer queue of any previously queued inventory offers from the same source. 921 // purge the message queue of any previously queued inventory offers from the same source.
923 LLView::child_list_t notification_queue(*(gNotifyBoxView->getChildList())); 922 class OfferMatcher : public LLNotifyBoxView::Matcher
924 for(LLView::child_list_iter_t iter = notification_queue.begin();
925 iter != notification_queue.end();
926 iter++)
927 { 923 {
928 LLNotifyBox* notification = (LLNotifyBox*)*iter; 924 public:
929 // scan for other inventory offers (i.e. ignore other types of notifications). 925 OfferMatcher(const LLUUID& to_block) : blocked_id(to_block) {}
930 // we can tell by looking for the associated callback they were created with. 926 BOOL matches(LLNotifyBox::notify_callback_t callback, void* cb_data) const
931 if(notification->getNotifyCallback() == inventory_offer_callback)
932 { 927 {
933 // found one. 928 return callback == inventory_offer_callback && ((LLOfferInfo*)cb_data)->mFromID == blocked_id;
934 // safe to downcast user data because we know it's associated with offer callback.
935 LLOfferInfo* offer_data = (LLOfferInfo*)notification->getUserData();
936 if(offer_data == user_data)
937 {
938 continue; // don't remove the msg triggering us. it will be dequeued normally.
939 }
940 if(offer_data->mFromID == blocked_id)
941 {
942 gNotifyBoxView->removeChild(notification);
943 }
944 } 929 }
945 } 930 private:
931 const LLUUID& blocked_id;
932 };
933 gNotifyBoxView->purgeMessagesMatching(OfferMatcher(blocked_id));
946} 934}
947 935
948void inventory_offer_callback(S32 button, void* user_data) 936void inventory_offer_callback(S32 button, void* user_data)
949 { 937 {
950 LLChat chat; 938 LLChat chat;
951 LLString log_message; 939 LLString log_message;
952
953 LLOfferInfo* info = (LLOfferInfo*)user_data; 940 LLOfferInfo* info = (LLOfferInfo*)user_data;
954 if(!info) return; 941 if(!info) return;
955 942
@@ -997,7 +984,7 @@ void inventory_offer_callback(S32 button, void* user_data)
997 { 984 {
998 if (info->mFromGroup) 985 if (info->mFromGroup)
999 { 986 {
1000 char group_name[MAX_STRING]; /* Flawfinder: ignore */ 987 std::string group_name;
1001 if (gCacheName->getGroupName(info->mFromID, group_name)) 988 if (gCacheName->getGroupName(info->mFromID, group_name))
1002 { 989 {
1003 from_string = LLString("An object named '") + info->mFromName + "' owned by the group '" + group_name + "'"; 990 from_string = LLString("An object named '") + info->mFromName + "' owned by the group '" + group_name + "'";
@@ -1011,8 +998,7 @@ void inventory_offer_callback(S32 button, void* user_data)
1011 } 998 }
1012 else 999 else
1013 { 1000 {
1014 char first_name[MAX_STRING]; /* Flawfinder: ignore */ 1001 std::string first_name, last_name;
1015 char last_name[MAX_STRING]; /* Flawfinder: ignore */
1016 if (gCacheName->getName(info->mFromID, first_name, last_name)) 1002 if (gCacheName->getName(info->mFromID, first_name, last_name))
1017 { 1003 {
1018 from_string = LLString("An object named '") + info->mFromName + "' owned by " + first_name + " " + last_name; 1004 from_string = LLString("An object named '") + info->mFromName + "' owned by " + first_name + " " + last_name;
@@ -1194,8 +1180,8 @@ void inventory_offer_handler(LLOfferInfo* info, BOOL from_task)
1194 LLString::format_map_t args; 1180 LLString::format_map_t args;
1195 args["[OBJECTNAME]"] = info->mDesc; 1181 args["[OBJECTNAME]"] = info->mDesc;
1196 // must protect against a NULL return from lookupHumanReadable() 1182 // must protect against a NULL return from lookupHumanReadable()
1197 const char* typestr = LLAssetType::lookupHumanReadable(info->mType); 1183 std::string typestr = ll_safe_string(LLAssetType::lookupHumanReadable(info->mType));
1198 if (typestr) 1184 if (!typestr.empty())
1199 { 1185 {
1200 args["[OBJECTTYPE]"] = typestr; 1186 args["[OBJECTTYPE]"] = typestr;
1201 } 1187 }
@@ -1213,19 +1199,19 @@ void inventory_offer_handler(LLOfferInfo* info, BOOL from_task)
1213 // Name cache callbacks don't store userdata, so can't save 1199 // Name cache callbacks don't store userdata, so can't save
1214 // off the LLOfferInfo. Argh. JC 1200 // off the LLOfferInfo. Argh. JC
1215 BOOL name_found = FALSE; 1201 BOOL name_found = FALSE;
1216 char first_name[MAX_STRING]; /* Flawfinder: ignore */
1217 char last_name[MAX_STRING]; /* Flawfinder: ignore */
1218 if (info->mFromGroup) 1202 if (info->mFromGroup)
1219 { 1203 {
1220 if (gCacheName->getGroupName(info->mFromID, first_name)) 1204 std::string group_name;
1205 if (gCacheName->getGroupName(info->mFromID, group_name))
1221 { 1206 {
1222 args["[FIRST]"] = first_name; 1207 args["[FIRST]"] = group_name;
1223 args["[LAST]"] = ""; 1208 args["[LAST]"] = "";
1224 name_found = TRUE; 1209 name_found = TRUE;
1225 } 1210 }
1226 } 1211 }
1227 else 1212 else
1228 { 1213 {
1214 std::string first_name, last_name;
1229 if (gCacheName->getName(info->mFromID, first_name, last_name)) 1215 if (gCacheName->getName(info->mFromID, first_name, last_name))
1230 { 1216 {
1231 args["[FIRST]"] = first_name; 1217 args["[FIRST]"] = first_name;
@@ -4134,7 +4120,7 @@ void process_alert_core(const std::string& message, BOOL modal)
4134 } 4120 }
4135} 4121}
4136 4122
4137LLLinkedList<LLMeanCollisionData> gMeanCollisionList; 4123mean_collision_list_t gMeanCollisionList;
4138time_t gLastDisplayedTime = 0; 4124time_t gLastDisplayedTime = 0;
4139 4125
4140void handle_show_mean_events(void *) 4126void handle_show_mean_events(void *)
@@ -4154,15 +4140,19 @@ void mean_name_callback(const LLUUID &id, const char *first, const char *last, B
4154 return; 4140 return;
4155 } 4141 }
4156 4142
4157 while(gMeanCollisionList.getLength() > 20) 4143 static const int max_collision_list_size = 20;
4144 if (gMeanCollisionList.size() > max_collision_list_size)
4158 { 4145 {
4159 gMeanCollisionList.getLastData(); 4146 mean_collision_list_t::iterator iter = gMeanCollisionList.begin();
4160 gMeanCollisionList.deleteCurrentData(); 4147 for (S32 i=0; i<max_collision_list_size; i++) iter++;
4148 for_each(iter, gMeanCollisionList.end(), DeletePointer());
4149 gMeanCollisionList.erase(iter, gMeanCollisionList.end());
4161 } 4150 }
4162 4151
4163 LLMeanCollisionData *mcd; 4152 for (mean_collision_list_t::iterator iter = gMeanCollisionList.begin();
4164 for (mcd = gMeanCollisionList.getFirstData(); mcd; mcd = gMeanCollisionList.getNextData()) 4153 iter != gMeanCollisionList.end(); ++iter)
4165 { 4154 {
4155 LLMeanCollisionData *mcd = *iter;
4166 if (mcd->mPerp == id) 4156 if (mcd->mPerp == id)
4167 { 4157 {
4168 strncpy(mcd->mFirstName, first, DB_FIRST_NAME_BUF_SIZE -1); /* Flawfinder: ignore */ 4158 strncpy(mcd->mFirstName, first, DB_FIRST_NAME_BUF_SIZE -1); /* Flawfinder: ignore */
@@ -4203,12 +4193,12 @@ void process_mean_collision_alert_message(LLMessageSystem *msgsystem, void **use
4203 4193
4204 type = (EMeanCollisionType)u8type; 4194 type = (EMeanCollisionType)u8type;
4205 4195
4206 LLMeanCollisionData *mcd;
4207
4208 BOOL b_found = FALSE; 4196 BOOL b_found = FALSE;
4209 4197
4210 for (mcd = gMeanCollisionList.getFirstData(); mcd; mcd = gMeanCollisionList.getNextData()) 4198 for (mean_collision_list_t::iterator iter = gMeanCollisionList.begin();
4199 iter != gMeanCollisionList.end(); ++iter)
4211 { 4200 {
4201 LLMeanCollisionData *mcd = *iter;
4212 if ((mcd->mPerp == perp) && (mcd->mType == type)) 4202 if ((mcd->mPerp == perp) && (mcd->mType == type))
4213 { 4203 {
4214 mcd->mTime = time; 4204 mcd->mTime = time;
@@ -4221,7 +4211,7 @@ void process_mean_collision_alert_message(LLMessageSystem *msgsystem, void **use
4221 if (!b_found) 4211 if (!b_found)
4222 { 4212 {
4223 LLMeanCollisionData *mcd = new LLMeanCollisionData(gAgentID, perp, time, type, mag); 4213 LLMeanCollisionData *mcd = new LLMeanCollisionData(gAgentID, perp, time, type, mag);
4224 gMeanCollisionList.addData(mcd); 4214 gMeanCollisionList.push_front(mcd);
4225 const BOOL is_group = FALSE; 4215 const BOOL is_group = FALSE;
4226 gCacheName->get(perp, is_group, mean_name_callback); 4216 gCacheName->get(perp, is_group, mean_name_callback);
4227 } 4217 }
@@ -4423,9 +4413,23 @@ void script_question_cb(S32 option, void* user_data)
4423 notify_cautioned_script_question(cbdata, orig, allowed); 4413 notify_cautioned_script_question(cbdata, orig, allowed);
4424 } 4414 }
4425 4415
4426 if ( option == 2 ) 4416 if ( option == 2 ) // mute
4427 { 4417 {
4428 gMuteListp->add(LLMute(cbdata->mItemID, cbdata->mObjectName, LLMute::OBJECT)); 4418 gMuteListp->add(LLMute(cbdata->mItemID, cbdata->mObjectName, LLMute::OBJECT));
4419
4420 // purge the message queue of any previously queued requests from the same source. DEV-4879
4421 class OfferMatcher : public LLNotifyBoxView::Matcher
4422 {
4423 public:
4424 OfferMatcher(const LLUUID& to_block) : blocked_id(to_block) {}
4425 BOOL matches(LLNotifyBox::notify_callback_t callback, void* cb_data) const
4426 {
4427 return callback == script_question_cb && ((LLScriptQuestionCBData*)cb_data)->mItemID == blocked_id;
4428 }
4429 private:
4430 const LLUUID& blocked_id;
4431 };
4432 gNotifyBoxView->purgeMessagesMatching(OfferMatcher(cbdata->mItemID));
4429 } 4433 }
4430 delete cbdata; 4434 delete cbdata;
4431} 4435}
@@ -5049,7 +5053,7 @@ void callback_load_url(S32 option, void* data)
5049 5053
5050 if (0 == option) 5054 if (0 == option)
5051 { 5055 {
5052 LLWeb::loadURL(infop->mUrl); 5056 LLWeb::loadURL(infop->mUrl);
5053 } 5057 }
5054 5058
5055 delete infop; 5059 delete infop;